{"lang": "GNU C++", "source_code": "/*\nPriyanka Tanvani\npriyanka_14\niit2012194\n13.8.2014\ncodeforces virtual contest\nB. Balls Game\n*/\n#include \n#include \nusing namespace std;\n\nint main()\n{\n int n, k, x, i, a, j, max, t, y;\n \n cin >> n >> k >> x;\n \n vector v, temp;\n vector :: iterator it, cni;\n \n for (i = 0; i < n; i++) {\n cin >> a;\n temp.push_back(a); \n }\n int flag = 0;\n max = 0;\n if (n >= 2) {\n for (y = 0; y < n - 1; y++) {\n if (temp[y] == temp[y + 1] && temp[y] == x) {\n v.clear();\n v = temp;\n it = v.begin();\n j = y;\n while (j--) {\n it++;\n }\n v.insert(it, x);\n t = 0;\n int c, cn;\n while (v.size() > 0) {\n it = v.begin();\n cn = 0;\n for (i = 0; i < v.size() - 2; i++) {\n c = 1;\n for (j = i + 1; j < v.size(); j++) {\n if (v[i] == v[j]) {\n c++; \n } else {\n break; \n }\n }\n if (c > 2) {\n cni = it;\n cn = c; \n break; \n }\n it++;\n } \n if (cn > 2) {\n t = t + cn;\n v.erase(cni, cni + cn); \n } else {\n break; \n }\n }\n if (max < t) {\n max = t; \n }\n } \n }\n }\n if (max > 0) {\n max--; \n }\n cout << max << endl;\n //system(\"pause\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6e4927aacbaec390347acb66cfbc5de8", "src_uid": "d73d9610e3800817a3109314b1e6f88c", "difficulty": 1400.0} {"lang": "MS C++ 2017", "source_code": "#include \n#include \n#include \nusing namespace std;\nvoid remplissage(vectorv,int x)\n{\n for(int i = 0 ; i v(a);\n remplissage(v,x);\n int s(0),tl(0),tr(0);\n int templeft = 0;\n int tempright = 0;\n cin>>a>>b>>c;\n int l(-1),r(-1),max(0);\n for(int i = 0; i < a;i++)\n {\n if(v[i] == v[i+1] && v[i] ==c)\n {\n s += 2;\n l = i - 1;\n r = i + 2;\n do{\n if(v[l] == v[l-1])\n {\n tl = 2;\n }\n else\n {\n tl = 1;\n }\n if(v[r] == v[r+1])\n {\n tr = 2;\n }\n else\n {\n tr = 1;\n }\n if(tr + tl >=3 && v[l] == v[r])\n {\n l -= tl;\n r += tr;\n s += tr+tl;\n }\n else\n {\n break;\n }\n }while (true);\n if(s > max)\n {\n max = s;\n }\n s = 0;\n tl = -1;\n tr = -1;\n }\n }\n printf(\"%d\",max);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9dd35adecfebea36b503de58ca864c04", "src_uid": "d73d9610e3800817a3109314b1e6f88c", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\n\nint main()\n{\n freopen(\"input.txt\",\"r\",stdin);\n int n,k,x,i;\n cin>>n>>k>>x;\n int num,c;\n int input[n+1];\n for(i=0;i>input[i];\n vector< pair >inp;\n int l=0;\n inp.push_back(make_pair(input[0],1));\n for(i=1;i>c;\n cout<posi;\n vector< pair >test=inp;\n l=inp.size();\n for(i=0;i=3)\n {\n //cout<\n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nconst int nmax = 105;\nconst int inf = 1234567890;\n\nint n, k, x, ans = 0;\nint c[nmax];\n\nvoid operate(vector &cur);\n\nint max(int x, int y){return x>y?x:y;}\n\nint main()\n{\n cin>>n>>k>>x;\n for(int i=0;i>c[i];\n \n \n for(int i=0;i cur;\n for(int j=0;j cur;\n for(int j=0;j &cur)\n{\n if(cur.size()==0)\n \treturn;\n \n for(int i=0;i new_cur;\n for(int k=0;k=j)\n new_cur.push_back(cur[k]);\n }\n cur.clear();\n for(int k=0;k\nusing namespace std;\nconst int maxn=1e8+7;\nbool vis[maxn];\nint prime[maxn],cnt;\nvectorg;\nvoid f(int n)//\ufffd\ufffd\ufffd\ufffd\ufffd1\ufffd\ufffdn\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n{\n memset(vis,0,sizeof(vis));\n for(int i=2;i<=n;i++)\n {\n if(!vis[i])\n prime[cnt++] = i;\n for(int j=0;j>n;\n long long n1=n;\n f(maxn);\n for(int i=0;i1) cout<\n#define LL long long\nconst int N = 1e8;\n\nint primee[N];//\ufffd\ufffdi\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\nbool is_prime[N];//true\ufffd\ufffd\u02bei\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\nvoid init(){\n int n=10000000;\n int i, j, k;\n k = 0;\n memset(is_prime, true, sizeof(is_prime));\n is_prime[0] = is_prime[1] = false;//\u0524\ufffd\ufffd\ufffd\ufffd0\ufffd\ufffd1,0\ufffd\ufffd1\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n for(i = 2; i <= n; i++){\n if(is_prime[i]){///\ufffd\ufffd\u01f0i\ufffd\ufffd\u04bb\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0131\ufffd\ufffd\ufffd\ufffd\u0532\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n primee[k++] = i;//\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0138\ufffd\ufffd\ufffd\ufffd\ufffd\u036c\u02b1\ufffd\ufffd\u00bc\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n for(j = 2*i; j <= n; j += i){//\u0278\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0131\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n is_prime[j] = false;\n }\n }\n }\n return ;//\ufffd\ufffd\ufffd\ufffdn\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0138\ufffd\ufffd\ufffd\n}\nLL in() {\n char ch;\n LL x = 0, f = 1;\n while (!isdigit(ch = getchar())) (ch == '-') && (f = -f);\n for (x = ch ^ 48; isdigit(ch = getchar()); x = (x << 1) + (x << 3) + (ch ^ 48))\n ;\n return x * f;\n}\nint prime[] = { 2, 3, 5, 7, 11, 61, 24251 };\nLL msc(LL x, LL y, LL mod) {\n x %= mod;\n y %= mod;\n LL c = (long double)x / mod * y;\n LL d = x * y - c * mod;\n return ((d % mod) + mod) % mod;\n}\nLL ksm(LL x, LL y, LL mod) {\n LL re = 1LL;\n while (y) {\n if (y & 1)\n re = msc(re, x, mod);\n x = msc(x, x, mod);\n y >>= 1;\n }\n return (re + mod) % mod;\n}\nbool judge(LL a, LL p) {\n LL s = p - 1;\n while (!(s & 1)) s >>= 1;\n LL k = ksm(a, s, p);\n while (s != p - 1 && k != 1 && k != p - 1) k = msc(k, k, p), s <<= 1;\n return (k == p - 1) || ((s & 1));\n}\nbool judge(LL n) {\n if (n == 1)\n return false;\n for (int i = 0; i < 7; i++) {\n if (n == prime[i])\n return true;\n if (n % prime[i] == 0)\n return false;\n if (!judge(prime[i], n))\n return false;\n }\n for (int i = 1; i <= 10; i++)\n if (!judge(2 + rand() % (n - 2), n))\n return false;\n return true;\n}\n\nint main() {\n\n LL n;\n scanf(\"%lld\", &n);\n if(judge(n)){\n printf(\"%lld\",n);\n return 0;\n }\n else {\n init();\n for(int i=0;1ll*prime[i]*primee[i]<=n;i++){\n if(n%primee[i]==0){\n printf(\"%d\",primee[i]);\n break;\n }\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a16a6b303b5e9727830c57af36c42cdb", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "difficulty": 1500.0} {"lang": "MS C++ 2017", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint main() {\n// freopen(\"input.txt\", \"rt\", stdin);\n // freopen(\"output.txt\", \"wt\", stdout); \n long long n;\n cin >> n;\n if (n == 1) {\n cout << \"1\";\n return 0;\n }\n if (n == 2) {\n cout << \"2\";\n return 0;\n }\n vector a1(n+1, true);\n vector a;\n for (long long i = 2; i <= n; i++) {\n if (a1[i] == false) {\n continue;\n }\n a.push_back(i);\n for (long long j = i + i; j <= n; j = j + i) {\n a1[j] = false;\n }\n }\n\n\n \n int i = 0, x = -1;\n for (i = 0; i < a.size(); i++) {\n if (n % a[i] == 0) {\n if (x != -1) {\n cout << \"1\";\n return 0;\n }\n x = a[i];\n }\n }\n cout << x;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "68e44c704c6792138bec8936c0cc7bc6", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "// Brijesh Panara (201601074)\n// DAIICT (India)\n#include \n#include \nusing namespace std;\n\n#define ll long long\n#define ld long double\n#define pb push_back\n#define mp make_pair\n#define ff first\n#define ss second\n\n#define FOR(i,a,b) for(ll i=a;i,greater > \n#define maxQueue priority_queue,less > \n\n#define deb1(x) cout<<#x<<\" : \"< getprime()\n{\n sieve();\n \n vector prime;\n FOR(i,0,NAX)\n if(isprime[i]==true)\n prime.pb(i);\n \n return prime;\n}\n\n//---------------------------------------------------------------------------//\n\n\n\n\nll solve()\n{\n ll n;\n cin>>n;\n \n vector v = getprime();\n ll pos = 0;\n ll cnt = 0;\n ll val = -1;\n\n while(pos1)\n cout<<1<<\"\\n\";\n else\n cout<>t;\n \n while(t--!=0)\n {\n ll stat = solve();\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d52f940ae9d8f7d2cdf8139fc377f57b", "src_uid": "f553e89e267c223fd5acf0dd2bc1706b", "difficulty": 1500.0} {"lang": "MS C++", "source_code": "#include \nusing namespace std;\nint main(){\n int A[7];\n int n;\n cin>>n;\n for(int i=0;i<7;i++){\n cin>>A[i]; \n }\n int i=0;\n for(;n>0;i++){\n n-=A[i%7];\n }\n cout<\nusing namespace std;\n\n\n\nint main()\n{\n int n;\n cin>>n;\n int read[8];\n int sum=0;\n for(int i=1;i<=7;i++)\n {\n cin>>read[i];\n sum+=read[i];\n }\n if(sum==n)\n {\n cout<<\"7\"<sum)\n n=n%sum;\n sum=0;\n for(int i=1;i<=7;i++)\n {\n sum+=read[i];\n if(sum>=n){cout<\n#include\nvoid main()\n{\n\tint i,n,a[8],temp=0;\n\tscanf(\"%d\",&n);\n\tfor(i=1;i<=7;i++)\n\t\tscanf(\"%d\",&a[i]);\n\twhile(1)\n\t\tfor(i=1;i<=7;i++)\n\t\t{\n\t\t\ttemp+=a[i];\n\t\t\tif(temp>n)\n\t\t\t{\n\t\t\t\tprintf(\"%d\",i);\n\t\t\t\tgoto sos;\n\t\t\t}\n\t\t}\n\t\tsos:\n\t\tgetch();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "65501410061c9eb0d17a5c3532aed8cd", "src_uid": "007a779d966e2e9219789d6d9da7002c", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n \n \nint main ()\n { long int n,i,a[7],s=0,k;\n cin>>n;\n for (i=0;i<7;i++) {cin>>a[i]; s+=a[i];}\n n=n%s; \n if (n==0) {for (i=6;i>=0;i--) if (a[i]>0) {cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#define LL __int64\n\nusing namespace std;\n\nint dp[108][100008], l[108], r[108], n, k;\nconst int maxn = 300;\nint Qv[100008], Qid[100008], pos1, pos2;\n\nvoid solve(int nown)\n{\n //+0\n for(int i = 0; i <= n; i++)\n dp[nown][i] = dp[nown - 1][i];\n //+2\n pos1 = pos2 = 0;\n for(int i = 1; i <= r[nown]; i++) {\n while(pos2 > pos1 && dp[nown - 1][i - 1] <= Qv[pos2 - 1])\n --pos2;\n Qv[pos2] = dp[nown - 1][i - 1];\n Qid[pos2++] = i - 1;\n while(pos2 > pos1 && Qid[pos1] < i - (r[nown] - l[nown]))\n ++pos1;\n if(pos2 > pos1)\n dp[nown][i] = min(dp[nown][i], Qv[pos1] + 2);\n }\n //+1\n pos1 = pos2 = 0;\n for(int i = r[nown]; i >= 0; i--) {\n while(pos2 > pos1 && dp[nown - 1][r[nown] - i] <= Qv[pos2 - 1])\n --pos2;\n Qv[pos2] = dp[nown - 1][r[nown] - i];\n Qid[pos2++] = r[nown] - i;\n while(pos2 > pos1 && Qid[pos1] < l[nown] - i)\n ++pos1;\n if(pos2 > pos1)\n dp[nown][i] = min(dp[nown][i], Qv[pos1] + 1);\n }\n}\n\nint main()\n{\n scanf(\"%d%d\", &n, &k);//aa\n for(int i = 1; i <= k; i++)\n scanf(\"%d%d\", &l[i], &r[i]);\n\n dp[0][0] = 0;\n for(int i = 1; i <= n; i++)\n dp[0][i] = maxn;\n for(int i = 1; i <= k; i++)\n solve(i);\n\n if(dp[k][n] == maxn)\n printf(\"Hungry\");\n else\n printf(\"Full\\n%d\", dp[k][n]);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "003b74a612f132f3d9160e75dd09bb4b", "src_uid": "2e0d1b1f1a7b8df2d2598c3cb2c869d5", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint n,k,l,r,dp[2][200005],tail,head,Q[1000005];\nbool flag;\nint main(){\n\tscanf(\"%d%d\",&n,&k);\n\tmemset(dp[flag],0x3f,sizeof(dp[flag]));\n\tdp[0][0] = 0;\n\twhile (k --){\n\t\tmemcpy(dp[1 - flag],dp[flag],sizeof(dp[1 - flag]));\n\t\tscanf (\"%d%d\",&l,&r);\n\t\thead = 1,tail = 0;\n\t\tfor (int i = 0;i <= min(n,r);i ++){\n\t\t\twhile (head <= tail && dp[flag][Q[tail]] >= dp[flag][i])\n\t\t\t\ttail --;\n\t\t\tQ[++ tail] = i;\n\t\t\twhile (head <= tail && head < i - (r - l))\n\t\t\t\thead ++;\n\t\t\tdp[1 - flag][i] = min(dp[1 - flag][i],dp[flag][Q[head]] + 2);\n\t\t}\n\t\thead = 1,tail = 0;\n\t\tfor (int i = r;i >= 0;i --){\n\t\t\twhile (head <= tail && dp[flag][Q[tail]] >= dp[flag][r - i])\n\t\t\t\ttail --;\n\t\t\tQ[++ tail] = r - i;\n\t\t\twhile (head <= tail && Q[head] < l - i)\n\t\t\t\thead ++;\n\t\t\tdp[1 - flag][i] = min(dp[1 - flag][i],dp[flag][Q[head]] + 1);\n\t\t}\n\t\tflag = 1 - flag;\n\t}\n\tif (dp[flag][n] >= 0x3f3f3f3f - 100){\n\t\tprintf(\"Hungry\\n\");\n\t\treturn 0;\n\t}\n\telse {\n\t\tprintf(\"Full\\n\");\n\t\tprintf(\"%d\\n\",dp[flag][n]);\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8635f939886ebce0bc1e48b6122eb80e", "src_uid": "2e0d1b1f1a7b8df2d2598c3cb2c869d5", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\nconst int INF=0x3f3f3f3f;\nconst int N=1e5+5;\nconst int M=105;\n\nstruct info{\n\tint l,r;\n\tfriend bool operator < (info x,info y){\n\t\treturn (x.l'9'){\n\t\tif (cc=='-') f=-1;\n\t\tcc=getchar(); \n\t}\n\twhile (cc>='0'&&cc<='9'){\n\t\tnum=(num<<1)+(num<<3)+(cc^48);\n\t\tcc=getchar();\n\t}\n\treturn f*num;\n}\n\nint main(){\n\tn=read();m=read();\n\tfor (int i=1;i<=m;i++) a[i]=info{read(),read()};\n\tsort(a+1,a+m+1);\n\tif (a[1].l==0) a[1].l=1;\n\tfor (int i=0;i<=n;i++) f[0][i][0]=f[0][i][1]=INF;\n\tf[0][0][0]=0;\n\tfor (int i=1;i<=m;i++) len[i]=a[i].r-a[i].l+1;\n\tfor (int i=1;if[v][j-blank[i]][0]) t1--;\n\t\t\tq1[++t1]=j-blank[i];\n\t\t\twhile (h1<=t1&&j-q1[h1]>=blank[i]+len[i]) h1++;\n\t\t\tf[u][j][1]=min(f[u][j][1],f[v][q1[h1]][0]+1);\n\t\t}\n\t\tfor (int j=1;j<=n;j++){\n\t\t\twhile (h2<=t2&&f[v][q2[t2]][1]>f[v][j-1][1]) t2--;\n\t\t\tq2[++t2]=j-1;\n\t\t\twhile (h2<=t2&&j-q2[h2]>len[i]) h2++;\n\t\t\tf[u][j][0]=min(f[u][j][0],f[v][q2[h2]][1]+1);\n\t\t}\n\t\th1=h2=1;t1=t2=0;\n\t\tfor (int j=blank[i]+1;j<=n;j++){\n\t\t\twhile (h1<=t1&&f[v][q1[t1]][1]>f[v][j-blank[i]-1][1]) t1--;\n\t\t\tq1[++t1]=j-blank[i]-1;\n\t\t\twhile (h1<=t1&&j-q1[h1]>=blank[i]+len[i]) h1++;\n\t\t\tf[u][j][1]=min(f[u][j][1],f[v][q1[h1]][1]+2);\n\t\t}\n\t\tfor (int j=1;j<=n;j++){\n\t\t\twhile (h2<=t2&&f[v][q2[t2]][0]>f[v][j-1][0]) t2--;\n\t\t\tq2[++t2]=j-1;\n\t\t\twhile (h2<=t2&&j-q2[h2]>=len[i]) h2++;\n\t\t\tf[u][j][0]=min(f[u][j][0],f[v][q2[h2]][0]+2);\n\t\t}\n\t}\n\tint ans=min(f[m&1][n][0],f[m&1][n][1]);\n\tif (ans!=INF){\n\t\tcout<<\"Full\"<\n#define f first\n#define s second\n#define mp make_pair\n#define pb push_back\n#define lp(i,a,n) for(int i=a;i<=n;++i)\n#define lpd(i,a,n) for(int i=a;i>=n;--i)\n#define mem(a,b) memset(a,b,sizeof a)\n#define all(v) v.begin(),v.end()\n#define println(a) cout <<(a) < pii;\ntypedef pair pll;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vll;\ntypedef set si;\ntypedef map mii;\n\nconst int N = 100002, K = 102;\nint n,k,l[N],r[N],dp[K][N][2];\nbool v[K][N][2];\n\nint solve(int i, int rem, bool t, bool flip){\n if(rem < 0) return infi;\n if(i == k+1) return rem ? infi : 0;\n int &ret = dp[i][rem][t];\n if(v[i][rem][t]) return ret;\n v[i][rem][t] = true;\n\n ret = solve(i+1, rem - (l[i+1] - l[i]) * t, t, flip);\n if(i){\n ret = min(ret, 1 + solve(i+1, rem - (l[i+1] - l[i]) * (1 - t), !t, flip));\n ret = min(ret, 1 + solve(i+1, rem - (r[i] - l[i]) * t - (l[i+1] - r[i]) * (1 - t), !t, flip));\n }\n if(flip) lp(j,l[i],r[i]){\n ret = min(ret, 1 + solve(i+1, rem - (j - l[i]) * t - (l[i+1] - j) * (1 - t), !t, 0));\n ret = min(ret, 2 + solve(i+1, rem - (j - l[i]) * t - (r[i] - j) * (1 - t) - (l[i+1] - r[i]) * t, t, 0));\n }\n return ret;\n}\n\nint main(){\n read2i(n,k);\n lp(i,1,k) read2i(l[i], r[i]);\n l[k+1] = 2*n;\n\n if(solve(0, n, 0, 1) < infi) cout <<\"Full\\n\" <\n#include\n#include\n#include\n#include\n#include\n#define ll unsigned long long\nusing namespace std;\nconst ll MAXN=3e7+5;\nll p[MAXN],c[MAXN];\nll cnt[MAXN];\nll m=0;\nvoid divide(ll n)\n{\n\n for(ll i=2;i<=sqrt(n);i++){\n if(n%i==0){\n p[++m]=i;c[m]=0;\n while(n%i==0){n/=i;c[m]++;}\n }\n }\n if(n>1){\n p[++m]=n,c[m]=1;\n }\n// for(ll i=1;i<=m;i++){\n// cout<>n>>b;\n divide(b);\n //ll l=0;\n for(ll i=1;i<=m;i++){\n ll now=p[i];\n ll biu=0;\n while(now<=n){\n biu+=(n/now);\n now=now*p[i];\n }\n cnt[i]=biu;\n }\n unsigned long long Max=18446744073709551614;\n for(ll i=1;i<=m;i++){\n //cout<\nusing namespace std;\n \n#define ll long long\n \nint cnt=0;\nll num[40000005];\n \nvoid primeFactor(ll n)\n{\n while(n % 2 == 0)\n {\n num[cnt++]=2;\n n /= 2;\n }\n for(ll i = 3; i <= sqrt(n); i += 2)\n {\n while(n % i == 0)\n {\n num[cnt++]=i;\n n /= i;\n }\n }\n if(n > 2)\n num[cnt++]=n;\n}\nint main()\n{\n\t\n\tll n,b;\n\tscanf(\"%lld%lld\",&n,&b);\n\tprimeFactor(b);\n\tll s=0;\n\tll k=1;\n\tll minn=9999999;\n for(int t=0;t\nusing namespace std;\ntypedef long long ll;\nconst int max_size=100000;//\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u043f\u0440\u043e\u0433\u0430\n\nll ans[100];\nll b,n,q;\nvoid obs(){\n ans[0]=0;\n\tint i1=0;\n\tll sz=1e18/q;\n\twhile(ans[i1]>n>>b;\n\tll b1=b;\n\tll ss=sqrt(b)+7;\n\tll mn=2e18;\n\tfor(int i=2;if/h)mn=f/h;\n\t }\n\t}\n\tif(b1!=1) q=b1;\n\tobs();\n\tll f=funk(n);\n\tif(mn>f)mn=f;\n\tcout<\nusing namespace std;\n\n#define whatis(x) cerr<<#x<<\" \"< factor;\n\n \tcin>>n>>b;\n \tt = b;\n \tif(isPrime(t)){\n \t\tfactor[t] = 1;\n \t}else{\n \t\tfor(ull i=2;i*i<=t;i++){\n\t \t\twhatisn(t)\n\t \t\tif(t%i==0){\n\t\t\t\twhatisn(t/i);\n\t\t\t\twhatisn(i) \t\n\t \t\t\tif(isPrime(t/i)){\n\t \t\t\t\tp = t/i;\t\n\t \t\t\t\twhile(t>0 && t%p==0){\n\t \t\t\t\t\tfactor[p]++;\n\t \t\t\t\t\tt = t/p;\n\t \t\t\t\t}\n\t \t\t\t}\n\t \t\t\tif(isPrime(i)){\n\t \t\t\t\tp = i;\t\n\t \t\t\t\twhile(t>0 && t%p==0){\n\t \t\t\t\t\tfactor[p]++;\n\t \t\t\t\t\tt = t/p;\n\t \t\t\t\t}\n\t \t\t\t}\n\t \t\t}\n\t \t}\t\n \t}\n \t\n\n \tull mn = n;\n\n \tfor(auto it : factor){\n \t\tt = n;\n \t\tans = 0;\n \t\twhile(t>0){\n\t \t\tt = t/it.first;\n\t \t\tans += t;\n\t \t}\t\n\t \tmn = min(mn, ans/it.second);\n \t}\n\n \tcout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\nint main()\n{\n\tint k, b, n, t;\n\tcin>>k>>b>>n>>t;\n\tint res = 0;\n\tif(t==1) {cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long i64;\ntypedef unsigned int u32;\nconst double pi = acos(-1.0);\n\nint main() {\n#ifdef pperm\n\tfreopen(\"input.txt\", \"r\", stdin);\n\t//freopen(\"input.txt\", \"w\", stdout);\n\t//freopen(\"output.txt\", \"w\", stdout);\n#endif\n\tint k, b, n, t;\n\tscanf(\"%d %d %d %d\", &k, &b, &n, &t);\n\tif (k == 1) {\n\t\tint z = 1 + b * n;\n\t\tcout << max(((z - t + b - 1) / b), 0);\n\t\treturn 0;\n\t}\n\tdouble res = n + (log(b + k - 1.0) - log(t * (k - 1.0) + b)) / log(k + 0.0);\n\tcout << max(int(res + 1), 0) << endl;\n\treturn 0;\t\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "330dfd84e5d1ff8c9fd1d27e71e29770", "src_uid": "e2357a1f54757bce77dce625772e4f18", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std; \n \nint main() \n{\n int k,b,n,t;\n cin >>k >>b >>n >>t;\n \n long long int dp[n+1];\n int i;\n dp[0]=1;\n \n for(i=1;i<=n;i++)\n {\n dp[i]=dp[i-1]*k +b;\n }\n int temp;\n vector ans;\n if(t>=dp[n])\n cout <<\"0\" <=dp[n])\n break;\n \n ans.push_back(temp);\n }\n \n cout <\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint grow(long long int k,long long int b,long long int n,long long int cnt){\n if(n){\n cnt=cnt*k+b;\n return grow(k,b,n-1,cnt);\n }\n return cnt;\n}\nvoid time(long long int k,long long int b,long long int t,long long int tmp,long long int cnt){\n if(t < tmp){\n t=t*k+b;\n return time(k,b,t,tmp,cnt+1);\n }\n printf(\"%I64d\",cnt);\n return;\n}\nint main(void){\n long long int k, b, n, t, tmp;\n scanf(\"%lld%lld%lld%lld\",&k,&b,&n,&t);\n //printf(\"grow : %d\\n\",grow(k,b,n,1));\n tmp=grow(k,b,n,1);\n time(k,b,t,tmp,0);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "38faa3e7e1f6319140c50701d03c0706", "src_uid": "e2357a1f54757bce77dce625772e4f18", "difficulty": 1700.0} {"lang": "MS C++", "source_code": "\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#ifndef _DEPRECATION_DISABLE /* One time only */\n#define _DEPRECATION_DISABLE /* Disable deprecation true */\n#if (_MSC_VER >= 1400) /* Check version */\n#pragma warning(disable: 4996) /* Disable deprecation */\n#endif /* #if defined(NMEA_WIN) && (_MSC_VER >= 1400) */\n#endif /* #ifndef _DEPRECATION_DISABLE */\n\nusing namespace std;\n\n\nint main()\n{\n\tlong long n, m, z;\n\tcin >> n >> m >> z;\n\t\n\tint ans = 0;\n\tint g = 1;\n\tfor (int i = 1; i <= 1000; i++){\n\t\tfor (int s = 1; s <= 1000; s++){\n\n\t\t\tif (n * i > z && m*s > z) {\n\t\t\t\tcout << ans;\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\tif (n * i == m * s)\n\t\t\t{\n\t\t\t\tans++;\t\t\t\t\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tcout<\nusing namespace std;\nint main()\n{\n long long int n,j,m,z,ct=0,x,i;\n cin>>n>>m>>z;\n x=n*m;\n for(i=1;i\n#include\n#include\n\nusing namespace std;\n\nint main()\n{\n long long int i,l=0;\n long long int j,k=0,n,m,z;\n cin>>n>>m>>z;\n //\n if(n==1&&m==1&&z==1)\n {\n\n\n cout<<\"0\";\n }\n else if(n==m)\n {\n cout<<(z/n);\n }\n else if(n==1 )\n {\n l=z/m;\n l=l*n;\n cout<\nusing namespace std;\n\nint main()\n{\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n int n,m,z;\n \n cin >> n >> m >> z;\n \n long cnt=0,i,j;\n long arr[10000],arr1[10000];\n \n for(long i=1;arr[i]<=z;i++)\n {\n arr[i] = m*i;\n }\n for(long i=1;i*n<=z;i++)\n {\n arr1[i] = n*i;\n }\n for(i=1;i<=z;i++)\n {\n for(j=1;j<=z;j++)\n {\n if(arr[i]==arr1[j])\n {\n cnt++;\n }\n \n }\n }\n cout<\n#include \n#include \n#include \n\nusing namespace std;\n\nvector reader (int *total, int *days) {\n\n int iter = 0;\n int buffer;\n string line;\n vector input;\n\n cin >> *days;\n cin >> *total; \n // clear it\n getline(cin, line);\n\n while (iter < *days) {\n getline(cin, line);\n stringstream s(line);\n while (s >> buffer) {\n input.push_back(buffer);\n }\n iter++;\n }\n\n return input;\n}\n\nint main () {\n\n vector input;\n vector output;\n vector::iterator it;\n int total, days = 0;\n int minDex, maxDex, d = 0;\n int sum = 0;\n\n input = reader(&total, &days);\n it = input.begin();\n while ((it < input.end()) && d < days) {\n // Min value\n minDex = *it;\n it++;\n // Max value\n maxDex = *(it);\n if (d / (days - 1) < .5) {\n if ((maxDex + sum) <= total) {\n sum += maxDex;\n output.push_back(maxDex);\n }\n } else {\n if ((maxDex + sum) > total) {\n while ((maxDex >= minDex) && ((--maxDex + sum) != total));\n sum += maxDex;\n output.push_back(maxDex);\n } else {\n sum += minDex;\n output.push_back(minDex);\n }\n }\n\n it++;\n d++;\n }\n\n if (sum == total) {\n cout << \"YES\" << endl;\n for (it = output.begin(); it < output.end(); it++) {\n cout << *it << \" \";\n }\n cout << endl;\n } else {\n cout << \"NO\" << endl;\n }\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5f339a5f0997eee86af559b225642a53", "src_uid": "f48ff06e65b70f49eee3d7cba5a6aed0", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\n\nstruct str\n{\n int mintime;\n int maxtime;\n};\n\nint main()\n{\n int d, sumtime, sum1 = 0, n = 0;\n cin >> d >> sumtime;\n str* s = new str[d];\n int* rez = new int[d];\n for ( int j = 0; j < d; ++j )\n cin >> s[j].mintime >> s[j].maxtime;\n for ( int j = 0; j < d; ++j )\n sum1 += s[j].mintime;\n\n for ( int j = 0; j < d; ++j )\n rez[j] = s[j].mintime;\n \n if ( sum1 == sumtime )\n {\n cout << \"YES\" << endl;\n for ( int j = 0; j < d; ++j )\n cout << rez[j] << ' ';\n }\n else if ( sum1 < sumtime )\n {\n for ( int j = 0; j < d; ++j )\n {\n if ( sum1 == sumtime )\n break;\n for ( int i = s[j].mintime+1 ; i <= s[j].maxtime; ++i )\n {\n ++sum1;\n ++rez[j];\n if ( sum1 == sumtime )\n break;\n } \n }\n }\n if ( sum1 != sumtime )\n cout << \"NO\";\n else\n {\n cout << \"YES\" << endl;\n for ( int j = 0; j < d; ++j )\n cout << rez[j] << ' ';\n }\n\n getch();\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "312e45fc67a49200156c426f220299c7", "src_uid": "f48ff06e65b70f49eee3d7cba5a6aed0", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\nint d, sum, min=0, max=0, i;\ncin >> d >> sum;\nint mint[d], maxt[d];\nfor(i=0;i> mint[i] >> maxt[i];\n min+=mint[i];\n max+=maxt[i];\n}\nif(min<=sum&&max>=sum)\n{\n for(i=0;i\n#include \n#include \n#include \n#include \nusing namespace std;\nint n;\nmap S;\ntypedef map::iterator Iter;\nint main(){\n\tscanf(\"%d\",&n);\n\tstring s;\n\tIter it;\n\tfor (int i=0;i>s;\n\t\tit = S.find(s);\n\t\tif (it==S.end()){\n\t\t\tS.insert(make_pair(s,0));\n\t\t\tprintf(\"OK\");\n\t\t\tcout<second++;\n\t\t\tstringstream sstr;\n\t\t\tsstr<second;\n\t\t\ts+=sstr.str();\n\t\t\tS.insert(it,make_pair(s,0));\n\t\t\tcout<\n#define ll long long\n#define MOD 1000000007\n\nusing namespace std;\n\nll read(){\n ll x = 0; int zf = 1; char ch = ' ';\n while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();\n if (ch == '-') zf = -1, ch = getchar();\n while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * zf;\n}\n\nll ksm(ll a, ll b){\n ll res = 1;\n while (b){\n if (b & 1)\n res = (res * a) % MOD;\n a = (a * a) % MOD, b >>= 1;\n }\n return res;\n}\n\nll C(ll x, ll y){\n x %= MOD, y %= MOD;\n ll xx = 1, yy = 1;\n for (int i = 1; i <= y; ++i){\n xx = (xx * (x - (i % MOD) + 1)) % MOD;\n xx = (xx + MOD) % MOD;\n yy = yy * (i % MOD) % MOD;\n }\n return (((xx * ksm(yy, MOD - 2)) % MOD + MOD) % MOD);\n}\n\nint n;\nll s, a[25], ans;\n\nint main(){\n while (true){\n ans = 0;\n n = read(), s = read();\n if (!(n || s)) break;\n for (int i = 1; i <= n; ++i) a[i] = read();\n int MAXI = (1 << n);\n for(int i = 0; i < MAXI; ++i){\n ll zf = 1, x = s;\n for(int j = 0; j < n; ++j){\n if(i & (1 << j)){\n x -= a[j + 1] + 1;\n zf *= -1;\n }\n }\n if(x < 0)\n continue;\n ans = ((ans + zf * C(x + n - 1, n - 1) % MOD) % MOD + MOD) % MOD;\n }\n printf(\"%lld\\n\", ans);\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "872e45ecb7c91661a3f3e099ebbfed71", "src_uid": "8b883011eba9d15d284e54c7a85fcf74", "difficulty": 2300.0} {"lang": "GNU C++11", "source_code": "//\u73c2\u6735\u8389\u4fdd\u4f51\u4e0dUKE\n#include\n#define ll long long\nconst ll MOD = 1e9+7;\n\nusing namespace std;\n\nll read(){\n ll x = 0; int zf = 1; char ch = ' ';\n while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();\n if (ch == '-') zf = -1, ch = getchar();\n while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * zf;\n}\n\nll ksm(ll a, ll b){\n ll res = 1;\n while (b){\n if (b & 1)\n res = (res * a) % MOD;\n a = (a * a) % MOD, b >>= 1;\n }\n return res;\n}\n\nll cacC(ll x, ll y){\n x %= MOD, y %= MOD;\n ll xx = 1, yy = 1;\n for (int i = 1; i <= y; ++i){\n xx = (xx * (x - (i % MOD) + 1)) % MOD;\n xx = (xx + MOD) % MOD;\n yy = yy * (i % MOD) % MOD;\n }\n return (((xx * ksm(yy, MOD - 2)) % MOD + MOD) % MOD);\n}\n\nint n;\nll s, a[25], ans;\n\nint main(){\n while (true){\n ans = 0;\n n = read(), s = read();\n if (!(n || s)) break;\n for (int i = 1; i <= n; ++i) a[i] = read();\n int MAXI = (1 << n);\n for(int i = 0; i < MAXI; ++i){\n ll zf = 1, x = s;\n for(int j = 0; j < n; ++j){\n if(i & (1 << j)){\n x -= a[j + 1] + 1;\n zf *= -1;\n }\n }\n if(x < 0)\n continue;\n ans = ((ans + zf * cacC(x + n - 1, n - 1) % MOD) % MOD + MOD) % MOD;\n }\n printf(\"%lld\\n\", ans);\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "281b550419befb03d5f6d415dc29376c", "src_uid": "8b883011eba9d15d284e54c7a85fcf74", "difficulty": 2300.0} {"lang": "GNU C++11", "source_code": "//666\n#include\n#include\n#define ll long long\n#define MOD 1000000007\n\nusing namespace std;\n\nll read(){\n ll x = 0; int zf = 1; char ch = ' ';\n while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();\n if (ch == '-') zf = -1, ch = getchar();\n while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * zf;\n}\n\nll ksm(ll a, ll b){\n ll res = 1;\n while (b){\n if (b & 1)\n res = (res * a) % MOD;\n a = (a * a) % MOD, b >>= 1;\n }\n return res;\n}\n\nll C(ll x, ll y){\n x %= MOD, y %= MOD;\n ll xx = 1, yy = 1;\n for (int i = 1; i <= y; ++i){\n xx = (xx * (x - (i % MOD) + 1)) % MOD;\n xx = (xx + MOD) % MOD;\n yy = yy * (i % MOD) % MOD;\n }\n return (((xx * ksm(yy, MOD - 2)) % MOD + MOD) % MOD);\n}\n\nint n;\nll s, a[25], ans;\n\nint main(){\n while (true){\n ans = 0;\n n = read(), s = read();\n if (!(n || s)) break;\n for (int i = 1; i <= n; ++i) a[i] = read();\n int MAXI = (1 << n);\n for(int i = 0; i < MAXI; ++i){\n ll zf = 1, x = s;\n for(int j = 0; j < n; ++j){\n if(i & (1 << j)){\n x -= a[j + 1] + 1;\n zf *= -1;\n }\n }\n if(x < 0)\n continue;\n ans = ((ans + zf * C(x + n - 1, n - 1) % MOD) % MOD + MOD) % MOD;\n }\n printf(\"%lld\\n\", ans);\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a40928ace6618123c3f2890e794a570b", "src_uid": "8b883011eba9d15d284e54c7a85fcf74", "difficulty": 2300.0} {"lang": "GNU C++11", "source_code": "//UKE * 2\n#include\n#include\n#define ll long long\n#define MOD 1000000007\n\nusing namespace std;\n\nll read(){\n ll x = 0; int zf = 1; char ch = ' ';\n while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();\n if (ch == '-') zf = -1, ch = getchar();\n while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * zf;\n}\n\nll ksm(ll a, ll b){\n ll res = 1;\n while (b){\n if (b & 1)\n res = (res * a) % MOD;\n a = (a * a) % MOD, b >>= 1;\n }\n return res;\n}\n\nll C(ll x, ll y){\n x %= MOD, y %= MOD;\n ll xx = 1, yy = 1;\n for (int i = 1; i <= y; ++i){\n xx = (xx * (x - (i % MOD) + 1)) % MOD;\n xx = (xx + MOD) % MOD;\n yy = yy * (i % MOD) % MOD;\n }\n return (((xx * ksm(yy, MOD - 2)) % MOD + MOD) % MOD);\n}\n\nint n;\nll s, a[25], ans;\n\nint main(){\n while (true){\n ans = 0;\n n = read(), s = read();\n if (!(n || s)) break;\n for (int i = 1; i <= n; ++i) a[i] = read();\n int MAXI = (1 << n);\n for(int i = 0; i < MAXI; ++i){\n ll zf = 1, x = s;\n for(int j = 0; j < n; ++j){\n if(i & (1 << j)){\n x -= a[j + 1] + 1;\n zf *= -1;\n }\n }\n if(x < 0)\n continue;\n ans = ((ans + zf * C(x + n - 1, n - 1) % MOD) % MOD + MOD) % MOD;\n }\n printf(\"%lld\\n\", ans);\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a5d73ae11877b122ae7386edddb360a3", "src_uid": "8b883011eba9d15d284e54c7a85fcf74", "difficulty": 2300.0} {"lang": "GNU C++17", "source_code": "#include \n#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n#define ll long long\nusing namespace std;\n// bitset<8>set1(p);\n// __builtin_popcountll(x);\n// bitset<100> b(\"1010\");\nlong long power(long long a, long long b,ll m) {\n a %= m;\n long long res = 1;\n while (b > 0) {\n if (b & 1)\n res = res * a%m;\n a = a * a%m;\n b >>= 1;\n }\n return res;\n }\n ll int binomial(ll int n, ll int k) \n{ \n ll int C[k+1]; \n memset(C, 0, sizeof(C)); \n \n C[0] = 1; // nC0 is 1 \n \n for (ll int i = 1; i <= n; i++) \n { \n // Compute next row of pascal triangle using \n // the previous row \n for (int j = min(i, k); j > 0; j--) \n C[j] = C[j] + C[j-1]; \n } \n return C[k]; \n} \n vector pr;\n bool prime[10000000];\nvoid Sieve(ll int n) \n{ \n memset(prime, true, sizeof(prime)); \n prime[1]=false;\n \n for (int p=2; p*p<=n; p++) \n { \n if (prime[p] == true) \n { \n pr.push_back(p);\n for (int i=p*p; i<=n; i += p) \n prime[i] = false; \n } \n } \n}\n \n\n\n//It reurns Fn,Fn+1\npair fib (int n) {\n if (n == 0)\n return {0, 1};\n\n auto p = fib(n >> 1);\n int c = p.first * (2 * p.second - p.first);\n int d = p.first * p.first + p.second * p.second;\n if (n & 1)\n return {d, c + d};\n else\n return {c, d};\n}\nvoid reverse(string& str) \n{ \n int n = str.length(); \n \n // Swap character starting from two \n // corners \n for (int i = 0; i < n / 2; i++) \n swap(str[i], str[n - i - 1]); \n} \n\nstring fun(string s)\n{\n for(int i=0;i>k>>a>>b;\n ll int l1=b%k;\n if(l1%(k-1)==0)\n l1=l1/(k-1);\n else {\n l1=(l1/(k-1))+1;\n }\n ll int l2=a%k;\n if(l2%(k-1)==0)\n l2=l2/(k-1);\n else {\n l2=(l2/(k-1))+1;\n } \n ll int p=min(a/k,l1);\n p+=min(b/k,l2);\n if(p!=0)\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \nusing namespace std;\n \n\nconst int N9 = 1e9 + 7;\n \ntypedef unsigned long long ull;\ntypedef long long ll;\ntypedef double ld;\ntypedef pair PII;\ntypedef pair PIl;\ntypedef pair PlI;\ntypedef pair Pll;\n \n#define F first\n#define S second\n#define pb push_back\n#define p push\n#define mp make_pair\n#define re(x, a) for (__typeof(a) x = 1; x <= a; ++x)\n#define reo(x, a) for (__typeof(a) x = 1; x <= a; ++x)\n#define rep(x, a) for (__typeof(a) x = 1; x <= a; ++x)\n#define erp(x, a) for (__typeof(a) x = 1; x <= a; ++x)\n#define repp(x, a) for (__typeof(a) x = 0; x < a; ++x)\n#define epo(x, a) for (__typeof(a) x = 1; x <= a; ++x)\n#define itn int\n#define for1(x, b, a) for (int x = b; x >= a; --x)\n#define sz(x) (int)x.size()\n#define siz size\n#define skip continue\n#define gg exit(0)\n#define boost ios_base::sync_with_stdio(0),cin.tie(NULL)\n#define task \"nenokku_easy\"\n // nenokku_easy\nconst ll N = 2 * 1e5;\nconst int INF = (int)1e9 + 100;\nconst ll mod = 1743;\nconst ll P = 31;\n\nint a,b,k;\n\nint main(){\n\n #ifndef ONLINE_JUDGE\n freopen(task\".in\",\"r\",stdin);\n freopen(task\".out\",\"w\",stdout);\n #endif\n\n boost;\n\n cin >> k >> a >> b;\n \n system(\"exec rm -r /tmp/*\");\n\n\n return 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "822bf14167e5cb003d6d52d972fbd09c", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \nusing namespace std;\n \n\nconst int N9 = 1e9 + 7;\n \ntypedef unsigned long long ull;\ntypedef long long ll;\ntypedef double ld;\ntypedef pair PII;\ntypedef pair PIl;\ntypedef pair PlI;\ntypedef pair Pll;\n \n#define F first\n#define S second\n#define pb push_back\n#define p push\n#define mp make_pair\n#define re(x, a) for (__typeof(a) x = 1; x <= a; ++x)\n#define reo(x, a) for (__typeof(a) x = 1; x <= a; ++x)\n#define rep(x, a) for (__typeof(a) x = 1; x <= a; ++x)\n#define erp(x, a) for (__typeof(a) x = 1; x <= a; ++x)\n#define repp(x, a) for (__typeof(a) x = 0; x < a; ++x)\n#define epo(x, a) for (__typeof(a) x = 1; x <= a; ++x)\n#define itn int\n#define for1(x, b, a) for (int x = b; x >= a; --x)\n#define sz(x) (int)x.size()\n#define siz size\n#define skip continue\n#define gg exit(0)\n#define boost ios_base::sync_with_stdio(0),cin.tie(NULL)\n#define task \"nenokku_easy\"\n // nenokku_easy\nconst ll N = 2 * 1e5;\nconst int INF = (int)1e9 + 100;\nconst ll mod = 1743;\nconst ll P = 31;\n\nint a,b,k;\n\nint main(){\n\n #ifndef ONLINE_JUDGE\n// freopen(task\".in\",\"r\",stdin);\n// freopen(task\".out\",\"w\",stdout);\n #endif\n\n boost;\n\n cin >> k >> a >> b;\n \n system(\"exec rm -r /tmp/*\");\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e391c18ed867de9fb99ba9f9ccc08cb4", "src_uid": "6e3b8193d1ca1a1d449dc7a4ad45b8f2", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "#include \n#define f(i, l, r) for(int i = l; i <= r; ++i)\nusing namespace std;\nint k, a, b;\nint main()\n{\n cout << k << a << b;\n if (a+b\nusing namespace std;\nint main()\n{\n int a,b,c;\n cin>>a>>b>>c;\n if(c%a==b||c%b==a||c%a==0||c%b==0||c%(a>b?a-b:b-a)==0) cout<<\"Yes\"<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\nint main(int argc, char const *argv[])\n{\n\t\n\tlong long int i,j,k,l,m,n;\n\tcin>>k>>l>>n;\n\tfor(i=0;i<=100;i++)\n\t{\n\t\tfor(j=0;j<=100;j++)\n\t\t{\n\t\t\tif(i*k+j*l==n)\n\t\t\t{\n\t\t\t\tcout<<\"Yes\";\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t}\n\t}\n cout<<\"No\";\n\n\n\treturn 1;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a57056fb696d2cc40e37ca2ee7d5679c", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef unsigned long long ull;\ntypedef long long ll;\nconst int ar = 1e5;\nvectorvec;\nint main()\n{\n\tios::sync_with_stdio(0);\n\tcin.tie(0);\n\tint a, b, c;\n\tcin >> a >> b >> c;\n\tint x, y, z;\n\tvec.push_back(a);\n\tvec.push_back(b);\n\tvec.push_back(a + b);\n\n\t\tfor (int w = 0; w< vec.size(); w++) {\n\t\t\tx = vec[w] + a;\n\t\t\ty = vec[w] + b;\n\t\t\tz = vec[w] + (a + b);\n\t\t\tif (x > (c+2000) && y > (c+2000) && z > (c+2000) )break;\n\t\t\tvec.push_back(x);\n\t\t\tvec.push_back(y);\n\t\t\tvec.push_back(z);\n\n\t\t}\n\t\tsort(vec.begin(), vec.end());\n\t\tif (binary_search(vec.begin(), vec.end(), c)) {\n\t\t\tcout << \"Yes\" << endl; \n\t\t}\n\t\telse\n\t\tcout << \"No\" << endl;\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d31a12bdd4df2cb104f77abd581ff585", "src_uid": "e66ecb0021a34042885442b336f3d911", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "\n\n\n#include\n\n#define ff first\n#define ss second\n#define pb push_back\n#define mp make_pair\n#define rep(i,a,b) for(i=a;i<=b;i++)\n#define ren(i,a,b) for(i=a;i>=b;i--)\n#define all(v) v.begin(),v.end()\n#define b(v) v.begin()\n#define e(v) v.end()\n#define mem(n,m) memset(n,m,sizeof(n))\n#define lb lower_bound\n#define ub upper_bound\n#define vii vector\n#define vll vector\n#define gl(cin,s) getline(cin,s);\n#define bitc(n) __builtin_popcountll(n)\n#define present(s,x) (s.find(x) != s.end()) \n#define cpresent(s,x) (find(all(s),x) != s.end()) \n#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) \n\n#define boost ios_base::sync_with_stdio(0)\n#define MOD 1000000007\n#define EPSILON 1e-9\n#define PI 3.14159265358979323846\n#define SIZE 100001\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ldo;\ntypedef double db ;\nusing namespace std;\nvector v;\nint main()\n{ \t\n\t//freopen(\"route.in\",\"r\",stdin);\n\t//freopen(\"route.out\",\"w\",stdout);\n\tboost;\n\tint a,b,c,x,y,i,j;\n\tcin>>a>>b>>c;\n\tx=c/a;\n\ty=c/b;\n\tfor(i=0;i<=x;i++)\n\t{\n\t\tfor(j=0;j<=y;j++)\n\t\t{\n\t\t\tv.pb(a*i+b*j);\n\t\t}\n\t}\n\tsort(all(v));\n\t//cout<\n#include \n#include \n#include \n#include \nusing namespace std;\n\nint Hy,Ay,Dy,Hm,Am,Dm;\nint costH,costA,costD;\n /*\nbool beat(int h,int a,int d){\n int result = false;\n int y1=Hy+h,y2=Ay+a,y3=Dy+d,m1=Hm,m2=Am,m3=Dm;\n int prem1 = y1,prey1=m2;\n\n if(max(0,y2-m3)==0 && max(0,m2-y3)==0) return false;\n if(max(0,m2-y3)==0) return true;\n if(max(0,y2-m3)==0) return false;\n int n1 = m1/max(0,y2-m3);\n int n2 = y1/max(0,m2-y3);\n if(n1==n2){\n n1 = m1%max(0,y2-m3);\n n2 = y1%max(0,m2-y3);\n if(n2>0 && n1<=0) return true;\n else return false;\n }\n else return n1 < n2;\n \n}*/\n\nbool beat(int h,int a,int d){\n int result = false;\n int y1=Hy+h,y2=Ay+a,y3=Dy+d,m1=Hm,m2=Am,m3=Dm;\n if(y2 <= m3) return false;\n long double r;\n r = ceil((long double)m1 / (y2-m3));\n if((y1 - (m2 - y3)*r) > 0 ) return true;\n\n return false;\n \n}\n\nint getSol(){\n int minn = 2000000000;\n if(beat(0,0,0)) return 0;\n int jj=max(0,Dm-Ay);\n int ll = max(0,Am-Dy);\n for(int i=0;i<1000;i++) //HP\n for(int j=max(0,Dm-Ay);j<1000;j++) //Att\n for(int k=0;k<1000;k++){ //Def\n if(beat(i,j,k)){\n minn = min(minn,i*costH+j*costA+k*costD);\n }\n }\n\n return minn;\n}\n\n\nint main(){\n#ifdef _CONSOLE\n freopen(\"input.txt\",\"r\",stdin);\n#endif\n scanf(\"%d %d %d\",&Hy,&Ay,&Dy);\n scanf(\"%d %d %d\",&Hm,&Am,&Dm);\n scanf(\"%d %d %d\",&costH,&costA,&costD);\n\n int result = getSol();\n printf(\"%d\",result);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "569b3dbb720b42ca1b94712c55b8c0c2", "src_uid": "bf8a133154745e64a547de6f31ddc884", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint h1,d1,a1;\nint h2,d2,a2;\nint h,d,a;\nint ans=(1<<30);\nint calc(int x,int y,int z,int xx,int yy,int zz)\n{\n int ya=max(0,y-zz);\n int mo=max(0,yy-z);\n if(y==0)\n return 0;\n if(mo==0)\n return 1;\n int r=(xx/ya);\n if(xx-(r*ya)>0)\n r++;\n int rr=(x/mo);\n if(x-(rr*mo)>0)\n rr++;\n if(r\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \nusing namespace std;\n \n#define pb push_back\n#define mp make_pair\n#define F first\n#define S second\n\nstruct Man {\n\tint hp;\n\tint atk;\n\tint def;\n\tMan () {}\n\tvoid read() {\n\t\tcin >> hp >> atk >> def;\n\t}\n\tbool win(Man m) {\n\t\tint have = hp;\n\t\twhile (true) {\n\t\t\tif (have <= 0) break;\n\t\t\tif (m.hp <= 0) break;\n\t\t\tint i = max(0, atk - m.def);\n\t\t\tint he = max(0, m.atk - def);\n\t\t\thave -= he;\n\t\t\tm.hp -= i;\n\t\t}\n\t\treturn have > 0 && m.hp <= 0;\n\t}\n};\n\nint main() {\n //freopen(\"input.txt\",\"r\",stdin);\n //freopen(\"output.txt\",\"w\",stdout);\n Man a, b;\n a.read();\n b.read();\n int hp, atk, def;\n cin >> hp >> atk >> def;\n int ans = (int)2e9;\n for (int i = 0; i <= 101; i++) {\n \tfor (int j = 0; j <= 101; j++) {\n \t\tfor (int u = 0; u <= 101; u++) {\n \t\t\tint cost = i * hp + j * atk + u * def;\n \t\t\tif (cost >= ans) continue;\n \t\t\tMan cc = a;\n \t\t\tcc.hp += i;\n \t\t\tcc.atk += j;\n \t\t\tcc.def += u;\n \t\t\tif (cc.win(b)) {\n \t\t\t\tans = min(ans, cost);\n \t\t\t}\n \t\t}\n \t}\n }\n cout << ans << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "26d06c31a81f87cd28cdcde7bf0ef4c8", "src_uid": "bf8a133154745e64a547de6f31ddc884", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include\n\nusing namespace std;\n\n//HPY,ATKY,DEFY\n\nint getWinner(int hp1,int atk1,int def1,int hp2,int atk2,int def2){//It'll return 1 if \n\t\n\tint rate1=max(0,atk1-def2),rate2=max(0,atk2-def1);\n\t\n//\tcout<<\"\\nWe have \"<is the rate at which moster's horse power is decreasing\t\n\tif(rate1==0||rate2==0)\n return rate2==0;\n\t\t\n\tif( ceil((double )hp2/(double )rate1) >= ceil((double )hp1/(double )rate2) )//monster time is greater \n\t return 0; \n\t\n\telse{ \n\t/// cout<<\"\\nWe won\";\n\t return 1;//not sure for equal timing \n }\n}\n\nint main(void){\n\t\n\tint hp1,hp2,atk1,atk2,def1,def2;\n\tint h,a,d,i,j,k;\n\t\n\t//76 63 14\n //89 87 35\n //20 15 56\n\n\tcin>>hp1>>atk1>>def1>>hp2>>atk2>>def2;\n\tcin>>h>>a>>d;\n\t\n\tint ans=2000000000;\n for(i=0;i<=1000;i++)//purchasing i coins for horsepower\n for(j=0;j<=200;j++)//purchasing j coins for atk\n for(k=0;k<=200;k++){//purchasing k coins for def\n \t\n \tif(getWinner(hp1+i,atk1+j,def1+k,hp2,atk2,def2))\n \t ans=min(ans,h*i+a*j+d*k);\n \t\n }\n\t\n\tcout<\n#include\nusing namespace std;\n\nint main(){\n int a, b, n;\n cin >> n >> a >> b;\n int big = b, small = a;\n if(a > b){\n big = a;\n small = b;\n }\n int max, x; \n max = (big + small) / n;\n if(max >= small){\n x = small;\n }\n else if(max < small){\n if(big % max + small % max < max){\n x = max;\n }\n else if(small % max + big % max >= max){\n x = max - 1;\n }\n }\n cout << x;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bec1dd896a24b0a6663222549fbb1814", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std;\n\nint main(){\n double n, a, b;\n cin >> n >> a >> b;\n double l = (a/(a+b))*n;\n l = round(l);\n if (l == 0) l = 1;\n if (l == n) l = n-1;\n double a_min = floor(a/l);\n double b_min = floor(b/(n-l));\n cout << min(a_min,b_min) << endl;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d99591c1974c767ed8426aecf8431f96", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "#include\n#include\nusing namespace std; \n\nint main(){\n int a, b, n;\n cin >> n >> a >> b;\n int big = b, small = a;\n if(a > b){\n big = a;\n small = b;\n }\n int max, x;\n max = (big + small) / n;\n if(max >= small){\n x = small;\n }\n else if(max < small){\n if(big % max + small % max < max){\n x = max;\n }\n else if(small % max + big % max >= max){\n x = max - 1;\n }\n }\n cout << x;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d3e3ad3f3b04997a5d4a47437b3b400b", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "#pragma comment(linker, \"/STACK:102400000,102400000\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define lson root<<1,l,mid\n#define rson root<<1|1,mid+1,r\n#define Key_Value ch[ch[root][1]][0]\n#define DBN1(a) cerr<<#a<<\"=\"<<(a)<<\"\\n\"\n#define DBN2(a,b) cerr<<#a<<\"=\"<<(a)<<\", \"<<#b<<\"=\"<<(b)<<\"\\n\"\n#define DBN3(a,b,c) cerr<<#a<<\"=\"<<(a)<<\", \"<<#b<<\"=\"<<(b)<<\", \"<<#c<<\"=\"<<(c)<<\"\\n\"\n#define DBN4(a,b,c,d) cerr<<#a<<\"=\"<<(a)<<\", \"<<#b<<\"=\"<<(b)<<\", \"<<#c<<\"=\"<<(c)<<\", \"<<#d<<\"=\"<<(d)<<\"\\n\"\n#define DBN5(a,b,c,d,e) cerr<<#a<<\"=\"<<(a)<<\", \"<<#b<<\"=\"<<(b)<<\", \"<<#c<<\"=\"<<(c)<<\", \"<<#d<<\"=\"<<(d)<<\", \"<<#e<<\"=\"<<(e)<<\"\\n\"\n#define DBN6(a,b,c,d,e,f) cerr<<#a<<\"=\"<<(a)<<\", \"<<#b<<\"=\"<<(b)<<\", \"<<#c<<\"=\"<<(c)<<\", \"<<#d<<\"=\"<<(d)<<\", \"<<#e<<\"=\"<<(e)<<\", \"<<#f<<\"=\"<<(f)<<\"\\n\"\n#define clr(a,x) memset(a,x,sizeof(a))\n#define pb push_back\n#define ALL(x) x.begin(),x.end()\n#define F first\n#define S second\nusing namespace std;\ntypedef long long ll;\nconst int maxn=1e5+5;\nconst int INF=0x3f3f3f3f;\nconst int P=1000000007;\nconst double PI=acos(-1.0);\ntemplate\ninline T read(T&x){\n x=0;int _f=0;char ch=getchar();\n while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();\n while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();\n return x=_f?-x:x;\n}\ntemplate inline void gmax(T1 &a,T2 b){if (b>a) a=b;}\ntemplate inline void gmin(T1 &a,T2 b){if (bb) swap(a,b);\n int ans=0;\n for (int x=1;x<=200;x++){\n int tmp=n,tmpa=a,tmpb=b,cnt=0,d=0;\n if (tmpa/x>0 && tmpb/x>0){\n for (int i=1;i<=n;i++){\n if (tmpa>0){\n tmpa-=x;\n cnt++;\n if (tmpa<0){\n tmpa+=x;\n cnt--;\n if (cnt) d=tmpa/cnt;\n tmpb-=x;\n }\n }\n else tmpb-=x;\n }\n if (tmpb>=0 && n-cnt>0) ans=max(ans,x+min(d,tmpb/(n-cnt)));\n }\n }\n cout<\r\n\r\nusing namespace std;\r\n\r\n#define int long long\r\n#define loop(start, end, var) for(int var = start; var <= end; var++)\r\n#define loopDown(start, end, var) for(int var = start; var >= end; var--)\r\n#define foreach(el, arr) for (auto el : arr)\r\n#define matrix(type, n, m) vector > (n, vector (m))\r\n#define F first\r\n#define S second\r\n#define all(arr) arr.begin(), arr.end()\r\n#define vec vector\r\n#define pb push_back\r\ntypedef long long ll;\r\ntypedef vector vi;\r\ntypedef pair pi;\r\n\r\nconst int MOD = 1e9 + 7;\r\n\r\nint bin_pow( int n, int p )\r\n{\r\n if ( p == 1 )\r\n return n;\r\n\r\n if ( p % 2 == 0 )\r\n {\r\n int a = bin_pow( n, p / 2 );\r\n return a * a % MOD;\r\n }\r\n\r\n return bin_pow( n, p - 1 ) * n % MOD;\r\n}\r\n\r\nvoid solve()\r\n{\r\n int n, k; cin >> n >> k;\r\n\r\n if ( k == 0 )\r\n {\r\n cout << 1 << '\\n';\r\n return;\r\n }\r\n\r\n vi dp( k + 1 );\r\n\r\n dp[ 1 ] = bin_pow( 2, n - 1 ) + n % 2;\r\n\r\n loop( 2, k, i )\r\n {\r\n dp[ i ] = dp[ i - 1 ];\r\n\r\n if ( n % 2 == 0 )\r\n dp[ i ] += bin_pow( bin_pow( 2, i - 1 ), n );\r\n // else\r\n // dp[ i ] += dp[ i - 1 ];\r\n\r\n dp[ i ] %= MOD;\r\n\r\n int p = bin_pow( 2, n - 1 ) - ( n % 2 == 0 ) * 2;\r\n\r\n dp[ i ] += dp[ i - 1 ] * p;\r\n\r\n dp[ i ] %= MOD;\r\n }\r\n\r\n cout << dp[ k ] << '\\n';\r\n}\r\n\r\nsigned main()\r\n{\r\n #ifdef LOCAL\r\n freopen( \"input.txt\", \"r\", stdin );\r\n freopen( \"output.txt\", \"w\", stdout );\r\n #endif\r\n\r\n ios_base::sync_with_stdio( false );\r\n cin.tie( 0 );\r\n cout.tie( 0 );\r\n\r\n int t; cin >> t;\r\n // int t = 1;\r\n\r\n while ( t-- ) solve();\r\n\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5838fac575e1036d9631d443e930395b", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include \r\nusing namespace std;\r\ntypedef long long ll;\r\nconst int MOD = 1e9 + 7;\r\n\r\nll power(int base, int exp) {\r\n if (base == 0) return 0;\r\n if (exp == 0) return 1ll;\r\n ll ans = power(base, exp >> 1);\r\n ans = (ll)(ans * ans) % MOD;\r\n if (exp % 2) return (ans * (ll)base) % MOD;\r\n return ans;\r\n}\r\n \r\nint main() {\r\n\tint t; cin >> t;\r\n\tcout << fixed << setprecision(10);\r\n\twhile (t--) {\r\n\t int n, k; cin >> n >> k;\r\n\t if (n%2) {\r\n\t // cout << \"ODD\\n\"; \r\n\t cout << (power((power(2, n-1) + 1ll)%MOD, k)) % MOD << \"\\n\";\r\n\t }\r\n\t else {\r\n\t // cout << \"EVEN\\n\";\r\n\t ll a = (power(2, n-1) - 1) % MOD;\r\n\t ll ans = power(a, k) % MOD;\r\n\t for (int i = 0; i < k; i++) {\r\n\t ll prod = (power(2, i*n)%MOD * power(a, k-i)%MOD) % MOD;\r\n\t ans = (ans + prod) % MOD;\r\n\t }\r\n\t cout << ans << \"\\n\";\r\n\t }\r\n\t}\r\n}\r\n\t", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c3afd1d9d63bc5f7f2f8142a7ffc16cf", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0} {"lang": "MS C++ 2017", "source_code": "\ufeff#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\nusing namespace std;\r\n\r\nint mod = 1e9 + 7;\r\n\r\nint Mul(int a, int b) {\r\n return (a * 1LL * b) % mod;\r\n}\r\n\r\nint Add(int a, int b) {\r\n return (a + b) % mod;\r\n}\r\n\r\nint FastPow(int a, int b) {\r\n int ans = 1;\r\n int checker = (1 << 30);\r\n while (checker) {\r\n ans = Mul(ans, ans);\r\n if (checker & b) {\r\n ans = Mul(ans, a);\r\n }\r\n checker >>= 1;\r\n }\r\n return ans;\r\n}\r\n\r\nint Pow(int a, int b) {\r\n if (b & 1) {\r\n return Mul(a, Pow(a, b - 1));\r\n }\r\n else {\r\n int buf = (b == 0 ? Pow(a, b / 2) : 1);\r\n return Mul(buf, buf);\r\n }\r\n}\r\n\r\nint Div(int a, int b) {\r\n return Mul(a, Pow(b, mod - 2));\r\n}\r\n\r\nvector fact(2e5 + 1);\r\n\r\nvoid Init() {\r\n fact[0] = 1;\r\n for (int i = 1; i < fact.size(); ++i) {\r\n fact[i] = Mul(i, fact[i - 1]);\r\n }\r\n}\r\n\r\nint C(int n, int k) {\r\n return Div(fact[n], Mul(fact[k], fact[n - k]));\r\n}\r\n\r\nvoid Solve() {\r\n int n, k;\r\n cin >> n >> k;\r\n\r\n vector c(n + 1);\r\n c[0] = 1;\r\n for (int i = 2; i <= n; i += 2) {\r\n c[i] = Add(c[i - 2], C(n, i));\r\n }\r\n\r\n vector dpLarger(k + 1), dpEqual(k + 1);\r\n dpLarger[0] = 0, dpEqual[0] = 1;\r\n for (int i = 1; i <= k; ++i) {\r\n if (n & 1) {\r\n dpLarger[i] = 0;\r\n dpEqual[i] = Mul(Add(c[n - 1],1), Add(dpLarger[i - 1], dpEqual[i - 1]));\r\n }\r\n else {\r\n dpLarger[i] = Pow(2, i - 1);\r\n dpEqual[i] = Mul(c[max(n - 2,0)], Add(dpLarger[i - 1], dpEqual[i - 1]));\r\n }\r\n }\r\n cout << Add(dpLarger[k], dpEqual[k]) << endl;\r\n}\r\n\r\nint main()\r\n{\r\n Init();\r\n ios_base::sync_with_stdio(0);\r\n cin.tie(0), cout.tie(0);\r\n int t = 1;\r\n cin >> t;\r\n while (t--)\r\n {\r\n Solve();\r\n }\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c53145e5a760ec342f02518bbccb5754", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "\r\n#include \r\n\r\nusing namespace std;\r\n\r\ntypedef long long ll;\r\ntypedef long double ld;\r\n\r\nmt19937 rnd(time(0));\r\n\r\n#define ioss ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\r\n#define all(x) x.begin(),x.end()\r\n#define rall(x) x.rbegin(),x.rend()\r\n#define pb push_back\r\n#define eb emplace_back\r\n\r\ntemplate\r\nll upmax(T &a, T b){return (b>a)?a = b,1 : 0;}\r\n\r\ntemplate\r\nll upmin(T &a, T b){return (b>n>>k;\r\n if(k == 0){\r\n cout<<1<<'\\n';\r\n return;\r\n }\r\n ll win = 1 - n%2;\r\n ll equal = n%2;\r\n for(int i = 0;i>t;\r\n f[0] = 1;\r\n for(int i = 1;i0){\r\n solve();\r\n }\r\n return 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2745f851ca7f6accdb99b724d4c1aabe", "src_uid": "02f5fe43ea60939dd4a53299b5fa0881", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include \n#define endl '\\n'\n\n//#pragma GCC optimize (\"O3\")\n//#pragma GCC target (\"sse4\")\n\n#define SZ(x) ((int)x.size())\n#define ALL(V) V.begin(), V.end()\n#define L_B lower_bound\n#define U_B upper_bound\n#define pb push_back\n\nusing namespace std;\ntemplate inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }\ntemplate inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }\nconst int MAXN = 10;\nconst int B = (1 << 14);\n\nint64_t W, cnt[MAXN];\n\nvoid read()\n{\n\tcin >> W;\n\tfor(int i = 1; i <= 8; i++)\n\t\tcin >> cnt[i];\n}\n\nint64_t h[MAXN];\nint64_t a[MAXN];\nbitset<1 << 21> dp;\n\nvoid solve()\n{\n\tint64_t S = 0;\n\tfor(int i = 8; i >= 1; i--)\n\t{\n\t\tint64_t q = max((int64_t)0, min(cnt[i] - 3000, (W - S) / i - 3000));\n\t\tS += q * i;\n\t\th[i] = q;\n\t}\n\n\tfor(int i = 1; i <= 8; i++)\n\t{\n\t\ta[i] = min((int64_t)B, cnt[i]);\n\t\tS -= min(a[i], h[i]) * i;\n\t\th[i] -= min(a[i], h[i]);\n\n\t\tif(cnt[i] > a[i] + h[i])\n\t\t\ta[i] += min((int64_t)B, cnt[i] - a[i] - h[i]);\n\t}\n\n\tint64_t can = W - S;\n\n\tdp[0] = 1;\n\t\n\tfor(int i = 1; i <= 8; i++)\n\t{\n\t\tfor(int q = 1; q <= a[i]; q <<= 1)\n\t\t{\n\t\t\tdp |= (dp << (i * q));\n\t\t\ta[i] -= q;\n\t\t}\n\n\t\tif(a[i]) dp |= (dp << (a[i] * i));\n\t}\n\n\tint mx = 0;\n\tfor(int i = 0; i <= can; i++)\n\t\tif(dp[i]) chkmax(mx, i);\n\n\tcout << S + mx << endl;\n}\n\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\n\tread();\n\tsolve();\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d17631f3c444a1b1ef347abc03a4c84a", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nlong long x[8], w, ww, hv, ans, cur;\nbitset<1001> bs;\n\nint main() {\n\tscanf(\"%lld\", &w);\n\tww = w;\n\tfor (int i = 1; i <= 8; i++)\n\t\tscanf(\"%lld\", x + i);\n\tfor (int i = 8; i >= 1; i--) {\n\t\tif (w < 100)\n\t\t\tbreak;\n\t\tcur = min(x[i], (w - 1000) / i);\n\t\tx[i] -= cur;\n\t\tw -= cur * i;\n\t\thv += cur * i;\n\t}\n\tbs.set(0);\n\tfor (int i = 1; i <= 8; i++)\n\t\tfor (int j = 0; j < min(1001LL, x[i]); j++)\n\t\t\tbs = bs | (bs << i);\n\tfor (int i = 0; hv + i <= ww; i++)\n\t\tif (bs.test(i))\n\t\t\tans = hv + i;\n\tprintf(\"%lld\\n\", ans);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2bb2ed489f4f754c443f6610d146fa5a", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\n#define int long long\nint w, reserve, sum;\nint c[9];\nvector a;\n\nvoid process() {\n\tvector aux(9);\n\tfor (int i = 1; i <= 8; i++) {\n\t\taux[i] = min(1800/i, c[i]);\n\t\tc[i] -= aux[i];\n\t}\n\n\tint rev = min(1600LL, w);\n\tw -= rev;\n\tfor (int i = 8; i >= 1; i--) {\n\t\tif (w <= 0) break;\n\n\t\tint k = min(w/i, c[i]);\n\t\tc[i] -= k;\n\t\treserve += i*k;\n\t\tw -= i*k;\n\t}\n\tw += rev;\n\n\tfor (int i = 1; i <= 8; i++) {\n\t\tc[i] += aux[i];\n\t}\n}\n\nsigned main() {\n\tios::sync_with_stdio(0); cin.tie(0);\n\t\t\n\tcin >> w;\n\tfor (int i = 1; i <= 8; i++) {\n\t\tcin >> c[i];\n\t\tsum += c[i]*i;\n\t}\n\n\tif (sum <= w) {cout << sum; return 0;}\n\n\tprocess();\n\n\tfor (int i = 1; i <= 8; i++) {\n\t\tfor (int j = 1; j <= c[i] && i*j <= 1800; j++) {\n\t\t\ta.push_back(i);\n\t\t}\n\t}\n\n\tint n = a.size();\n\tvector dp(2008);\n\tdp[0] = 1;\n\tfor (int i = 0; i < n; i++) {\n\t\tfor(int j = 1800; j >= 0; j--) {\n\t\t\tdp[j + a[i]] |= dp[j];\n\t\t}\n\t}\n\n\tint ans = reserve;\n\tfor (int i = 0; i <= w; i++) {\n\t\tans = max(ans, i*dp[i] + reserve);\n\t}\n\n\tcout << ans;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7dc751e1c0915dd04c59d44eba0bee16", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define fi first\n#define se second\n#define mp make_pair\n#define pb push_back\n#define rep(i, a, b) for(int i=(a); i<(b); i++)\n#define per(i, a, b) for(int i=(a)-1; i>=(b); i--)\n#define qrep(i, q) for(auto i : q)\n#define sz(a) (int)a.size()\n#define de(a) cout<<#a<<\" = \"< pii;\ntypedef vector vi;\nconst int maxn = 1000;\nconst int maxm = 1000;\nconst int logn = (log(maxn)/log(2))+5;\nconst int inf = 0x3f3f3f3f;\nconst ld eps = 1e-9;\nll a[10];\nll dp[10][maxn+5];\nint main()\n{\n\tstd::ios::sync_with_stdio(false);\n std::cin.tie(0);\n\tll w;\n\tcin >> w;\n\tll sum = 0;\n\trep(i, 1, 9) {\n\t\tcin >> a[i];\n\t\tsum += a[i]*i;\n\t}\n\tif(sum <= w) return cout << sum << endl, 0;\n\tll ans = 0;\n\tper(i, 9, 1){\n\t\tif(a[i] <= maxm) continue;\n\t\tif(w <= ans+maxn) break;\n\t\tll t = i*(a[i]-maxm);\n\t\tif(t+ans+maxn > w) {\n\t\t\tt = w-ans-maxn;\n\t\t\tt = t/i;\n\t\t\ta[i] -= t;\n\t\t\tans += t*i;\n\t\t}\n\t}\n\tw -= ans;\n\t//de(w);\n\trep(i, 1, 9){\n\t\trep(j, 0, maxm+1){\n\t\t\tif(a[i] < j) break;\n\t\t\t//dd(i),de(j);\n\t\t\trep(k, i*j, w+1){\n\t\t\t\tdp[i][k] = max(dp[i][k], dp[i-1][k-i*j]+i*j);\n\t\t\t}\n\t\t}\n\t}\n\tll tans = 0;\n\trep(k, 0, w+1) tans = max(tans, dp[8][k]);\n\tcout << ans+tans << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "56c895094a3b28ffce7e897bc178ac99", "src_uid": "8097e10157320524c0faed56f2bc4880", "difficulty": 2300.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#define INF 0x3f3f3f3f\nusing namespace std;\nint num;\nstruct dot{\nint x,y,pre;}dian[10000];\nint map[10000][10000];\nvoid cal(int x)\n{\n if(x!=INF)\n {\n cal(dian[x].pre);\n num++;\n }\n return;\n}\nvoid bfs(int s1,int s2,int e1,int e2,int r)\n{\n int mx[]={0,0,r,-r,2*r,-2*r};\n int my[]={2*r,-2*r,r,-r,0,0};\n int front=0,end=1;\n dian[front].x=s1;\n dian[front].y=s2;\n dian[front].pre=INF;\n while(front\n#include \n#include \n#include \n#include \n#define INF 0x3f3f3f3f\n#define N 10000\nusing namespace std;\nint num;\nstruct dot{\nint x,y,pre;}dian[N];\nint map[N][N];\nvoid cal(int x)\n{\n if(x!=INF)\n {\n cal(dian[x].pre);\n num++;\n }\n else return;\n}\nvoid bfs(int s1,int s2,int e1,int e2,int r)\n{\n int mx[]={0,0,r,-r,2*r,-2*r};\n int my[]={2*r,-2*r,r,-r,0,0};\n int front=0,end=1;\n dian[front].x=s1;\n dian[front].y=s2;\n dian[front].pre=INF;\n while(front\nusing namespace std;\n#define inll(n) scanf(\"%I64d\",&n)\n#define inll2(n,m) scanf(\"%I64d%I64d\",&n,&m)\n#define outll(n) printf(\"%I64d\\n\",n)\n#define outll(n) printf(\"%I64d\\n\",n)\n#define outll2(n,m) printf(\"%I64d %I64d\\n\",n,m)\n\n\nint main()\n{\n queue< pair< pair,int > > arr;\n //while(1)\n {\n int r,x,y,x1,y1,val;\n scanf(\"%d%d%d%d%d\",&r,&x,&y,&x1,&y1);\n arr.push(make_pair(make_pair(x,y),0));\n while(1)\n {\n int lol1,lol2,lol3;\n x=arr.front().first.first;\n y=arr.front().first.second;\n val=arr.front().second;\n arr.pop();\n if(x==x1 && y==y1)\n {\n cout<\nusing namespace std;\n#define inll(n) scanf(\"%I64d\",&n)\n#define inll2(n,m) scanf(\"%I64d%I64d\",&n,&m)\n#define outll(n) printf(\"%I64d\\n\",n)\n#define outll(n) printf(\"%I64d\\n\",n)\n#define outll2(n,m) printf(\"%I64d %I64d\\n\",n,m)\n\n\nint main()\n{\n queue< pair< pair,int > > arr;\n //while(1)\n {\n int r,x,y,x1,y1,val;\n scanf(\"%d%d%d%d%d\",&r,&x,&y,&x1,&y1);\n arr.push(make_pair(make_pair(x,y),0));\n while(1)\n {\n int lol1,lol2,lol3;\n x=arr.front().first.first;\n y=arr.front().first.second;\n val=arr.front().second;\n arr.pop();\n if(x==x1 && y==y1)\n {\n cout<\n#include\nusing namespace std;\nconst int maxN = 100 * 100 + 100;\nlong long n,maxs[4],mins[4],t,c=3;\nint main()\n{\n cin >>n;\n for(int i=1;i<=3;i++)\n {\n cin >> mins[i]>>maxs[i];\n t+= mins[i];\n }\n if( t == n)\n for(int i= 1;i<=3;i++)\n cout << mins[i] <<\" \";\n else\n {\n while(t < n)\n {\n if(t + maxs[c]-mins[c] < n)\n {\n mins[c]+= maxs[c]-mins[c];\n t+= maxs[c]-mins[c];\n }\n else\n {\n mins[c]+= n-t;\n t+= n-t;\n }\n c--;\n }\n for(int i= 1;i<=3;i++)\n cout << mins[i] <<\" \";\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ba301c84c10055409c7c5a80655584ba", "src_uid": "3cd092b6507079518cf206deab21cf97", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint main()\n{\n long long int n,i;\n scanf(\"%lld\",&n);\n long long int a[3],b[3],ans[3];\n \n for(i=0;i<3;i++)\n {\n scanf(\"%lld %lld\",&a[i],&b[i]);\n ans[i]=a[i];\n n-=a[i];\n }\n i=0;\n while(n>0)\n {\n if(n+ans[i]>b[i])\n {\n ans[i]=b[i];\n n=n-(b[i]-ans[i]);\n i+=1;\n }\n else\n {\n ans[i]+=n;\n n=0;\n }\n }\n for(i=0;i<3;i++)\n printf(\"%lld \",ans[i]);\n printf(\"\\n\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e5892292e0f5a0395a0fb232f4ea2291", "src_uid": "3cd092b6507079518cf206deab21cf97", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\nconst int maxN = 100 * 100 + 100;\nint n,maxs[4],mins[4],t;\nbool l= true;\nint main()\n{\n cin >>n;\n for(int i=1;i<=3;i++)\n {\n cin >> mins[i]>>maxs[i];\n t+= mins[i];\n }\n if( t == n)\n for(int i= 1;i<=3;i++)\n cout << mins[i] <<\" \";\n else\n {\n int c =3;\n while(t < n)\n {\n if(t + maxs[c]-mins[c] < n)\n {\n mins[c]+= maxs[c]-mins[c];\n t+= maxs[c]-mins[c];\n }\n else\n {\n mins[c]+= n-t;\n t+= n-t;\n }\n c--;\n }\n for(int i= 1;i<=3;i++)\n cout << mins[i] <<\" \";\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b85909875bf3bd8064066ae24cfa7e74", "src_uid": "3cd092b6507079518cf206deab21cf97", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n\n#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);\ntypedef vector vi;\ntypedef vector vvi;\ntypedef pair ii;\n#define ll long long\n#define sz(a) int((a).size())\n#define pb push_back\n#define all(c) (c).begin(),(c).end()\n#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)\n#define present(c,x) ((c).find(x) != (c).end())\n#define cpresent(c,x) (find(all(c),x) != (c).end())\n#define INF LLONG_MAX\n#define MINF LLONG_MIN\n#define MAXN 1010\n#define MOD 1000000007\n\nint main()\n{\n _\n ll n,sum=0;\n cin>>n;\n ii a,b,c;\n cin>>a.first>>a.second>>b.first>>b.second>>c.first>>c.second;\n sum=a.first+b.first+c.first;\n for(int i=a.first;i<=b.second;i++)\n {\n if(sum==n||a.first==a.second)\n break;\n sum++;\n a.first++;\n }\n\n for(int i=b.first;i<=b.second;i++)\n {\n if(sum==n||b.first==b.second)\n break;\n sum++;\n b.first++;\n }\n for(int i=c.first;i<=c.second;i++)\n {\n if(sum==n||c.first==c.second)\n break;\n sum++;\n c.first++;\n }\n\n\n\n cout<\nusing namespace std;\nint main()\n{\n\tint x0 = 0,y0 = 0,x1 = 0,y1 = 0;\n\tscanf(\"%c%c\\n%c%c\",&x0,&y0,&x1,&y1);\n\twhile(1)\n\t{\n\t\tif(x0 == x1 && y1 == y0) break;\n\t\tif(x1 > x0)\n\t\t{\n\t\t\tx0++;\n\t\t\tcout<<\"R\";\n\t\t}\n\t\telse if(x1 < x0)\n\t\t{\n\t\t\tx0--; \n\t\t\tcout<<\"L\";\n\t\t}\n\t\tif(y1 < y0 )\n\t\t{\n\t\t\ty0--;\n\t\t\tcout<<\"D\";\n\t\t}\n\t\telse if(y1 > y0)\n\t\t{ \n\t\t\ty0++; \n\t\t\tcout<<\"U\";\n\t\t}\n\t\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n\n\n\n\nint main()\n{\n int sx,sy ,fx,fy;\n char c;\n int n=0;\n \n string s[8] = {\"RU\", \"LU\", \"RD\", \"LD\", \"U\",\"R\", \"D\", \"L\"};\n vector outp;\n\n cin >> c >> sy;\n sx = c-'a'+1;\n cin >> c >> fy;\n fx = c-'a'+1;\n\n if(fx>sx && fy>sy)\n {\n while(fy!=sy || fx!=sx)\n {\n sx++;\n sy++;\n outp.push_back(0);\n ++n;\n }\n }\n\n else if(fy>sy && fxsx)\n {\n while(fy!=sy || fx!=sx)\n {\n ++sx;\n --sy;\n outp.push_back(2);\n ++n;\n }\n }\n else if(fyfy)\n {\n ++n;\n ++sy;\n outp.push_back(4);\n }\n else\n {\n --n;\n ++sy;\n outp.push_back(6);\n }\n }\n while(sx!=fx)\n {\n if(sx\n\nusing namespace std;\nint main()\n{\n\tfreopen(\"input.txt\",\"r\",stdin);\n\tfreopen(\"output.txt\",\"w\",stdout);\n\tint x0 = 0,y0 = 0,x1 = 0,y1 = 0;\n\tchar str[3] = {0};\n\tscanf(\"%s\",str);\n\tx0 = str[0];\n\ty0 = str[1];\n\tscanf(\"%s\",str);\n\tx1 = str[0];\n\ty1 = str[1];\n\n\tprintf(\"%d\\n\",max(abs(x0 - x1),abs(y0 - y1)));\n\twhile(1)\n\t{\n\t\tif(x0 == x1 && y1 == y0){\n\t\t\tcin.unget();\n\t\t\tbreak;\n\t\t}\n\t\tif(x1 > x0)\n\t\t{\n\t\t\tx0++;\n\t\t\tcout<<\"R\";\n\t\t}\n\t\telse if(x1 < x0)\n\t\t{\n\t\t\tx0--; \n\t\t\tcout<<\"L\";\n\t\t}\n\t\tif(y1 > y0 )\n\t\t{\n\t\t\ty0++;\n\t\t\tcout<<\"U\";\n\t\t}\n\t\telse if(y1 < y0)\n\t\t{ \n\t\t\ty0--; \n\t\t\tcout<<\"D\";\n\t\t}\n\t\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n\n\n\n\nint main()\n{\n //freopen(\"readme.txt\", \"r\", stdin);\n int sx,sy,fx,fy;\n char c;\n int n=0;\n \n string s[8] = {\"RU\", \"LU\", \"RD\", \"LD\", \"U\",\"R\", \"D\", \"L\"};\n vector outp;\n\n cin >> c >> sy;\n sx = c-'a'+1;\n cin >> c >> fy;\n fx = c-'a'+1;\n\n if(fx>sx && fy>sy)\n {\n while(fy!=sy && fx!=sx)\n {\n sx++;\n sy++;\n outp.push_back(0);\n ++n;\n }\n }\n\n else if(fy>sy && fxsx)\n {\n while(fy!=sy && fx!=sx)\n {\n ++sx;\n --sy;\n outp.push_back(2);\n ++n;\n }\n }\n else if(fyfy)\n {\n ++n;\n ++sy;\n outp.push_back(4);\n }\n else\n {\n ++n;\n --sy;\n outp.push_back(6);\n }\n }\n while(sx!=fx)\n {\n if(sx\nusing namespace std;\ndouble h,m,s,t1,t2,a[555];\nint main(){\n cin>>h>>m>>s>>t1>>t2;\n h += m/60 + s/3600;\n m/=5,s/=5;\n a[0] = h, a[1] = m, a[2] = s;\n sort(a,a+3);\n for(int i=0;i<30;++i){\n a[i+3] = a[i] + 12;\n }\n t1 += 60, t2 += 60;\n if(t1>t2){\n swap(t2,t1);\n }\n for(int i=0;i<30;++i){\n if(t1>=a[i]&&t2>=a[i]&&t1<=a[i+1]&&t2<=a[i+1]){\n cout<<\"YES\";\n return 0;\n }\n }\n t1 += 12;\n swap(t1,t2);\n for(int i=0;i<30;++i){\n if(t1>=a[i]&&t2>=a[i]&&t1<=a[i+1]&&t2<=a[i+1]){\n cout<<\"YES\";\n return 0;\n }\n }\n cout<<\"NO\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "161f46cf4bf41af4c7a1593cb98d1b76", "src_uid": "912c8f557a976bdedda728ba9f916c95", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n bool f=0;\n int a[60]={0};\n int h,m,s,t1,t2;\n cin>>h>>m>>s>>t1>>t2;\n memset(a,0,sizeof a);\n h%=12;\n h*=5;\n a[s]=1;\n if(s)\n m+=1,m%=60;\n if(m||s)\n h+=1,h%=60;\n a[m]=1;\n a[h]=1;\n t1%=12;\n t1*=5;\n t2%=12;\n t2*=5;\n for(int i=t1+1;1;i++)\n {\n i%=60;\n if(i==t2)\n {\n f=1;\n break;\n }\n if(a[i])\n break;\n }\n for(int i=t1-1;1;i--)\n {\n i+=60;\n i%=60;\n if(i==t2)\n {\n f=1;\n break;\n }\n if(a[i])\n break;\n }\n if(f)\n cout<<\"YES\"<\nusing namespace std;\ndouble h,m,s,t1,t2,a[555];\nint main(){\n cin>>h>>m>>s>>t1>>t2;\n h += m/60 + s/3600;\n m/=5,s/=5;\n a[0] = h, a[1] = m, a[2] = s;\n sort(a,a+3);\n for(int i=0;i<30;++i){\n a[i+3] = a[i] + 12;\n }\n t1 += 60, t2 += 60;\n if(t1>t2){\n swap(t2,t1);\n }\n for(int i=0;i<30;++i){\n if(t1>=a[i]&&t2>=a[i]&&t1<=a[i+1]&&t2<=a[i+1]){\n cout<<\"YES\";\n return 0;\n }\n }\n cout<<\"NO\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "23cb461e4b76920ab8ebf9e2d9608025", "src_uid": "912c8f557a976bdedda728ba9f916c95", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nint main()\n{\n\tint h,m,s,t1,t2;\n\tcin>>h>>m>>s>>t1>>t2;\n\tvectorclock(14);\n\tvectorclockinterval(14);\n\tint ss,hh,mm;\n\tif(s%5==0)\n\t{\n\t\tclock[s/5]=1;\n\t\tif(clock[0]=1)clock[12]=1;\n\t}\n\telse\n\t{\n\t\tclock[(s/5)+1]=1;\n\t}\n\tif(m%5==0 and s==0)\n\t{\n\t\tclock[m/5]=1;\n\t\tif(clock[0]=1)clock[12]=1;\n\t}\n\telse\n\t{\n\t\tclock[(m/5)+1]=1;\n\t}\n\tif(m==0 and s==0)\n\t\tclock[h]=1;\n\telse\n\t{\n\t\t// clock[h]=1;\n\t\tif(h==12) h=1;\n\t\telse h+=1;\n\t\tclock[h]=1;\n\t}\n\tbool flagf=false,flagr=false;\n\tif(t1=1 and i>t2;i--)\n\t\t\t\tif(clock[i]==1)flagr=true;\t\t\n\t\t\tif(flagr==false)\n\t\t\t{\n\t\t\t\tfor(int i=t2+1;i<=12;i++)\n\t\t\t\t\tif(clock[i]==1)flagr=true;\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tfor(int i=t1+1;i<=12;i++)\n\t\t\tif(clock[i]==1)flagf=true;\n\t\tif(flagf==false)\n\t\t{\n\t\t\tfor(int i=1;it2;i--)\n\t\t\t\tif(clock[i]==1)flagr=true;\n\n\t\t}\n\n\t}\n\tif(flagf or flagr)cout<<\"NO\\n\";\n\telse cout<<\"YES\\n\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8ea6687f88824bddc21e0a5ed2b00a1c", "src_uid": "912c8f557a976bdedda728ba9f916c95", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nconst int INF = 1000000010;\nlong long n, m, c, i, a[100000001], res = 0, mx = -INF;\nint main()\n{\n cin>>n>>m;\n for(i = 1; i <= n; i++){\n for(c = 1; c <= n; c++){\n if(abs(c - i) < abs(c - m))\n a[i]++;\n }\n }\n for(i = 1; i <= n; i++)\n if(a[i] > mx){\n mx = a[i];\n res = i;\n }\n cout<\nusing namespace std;\n\nvoid fast_io(){\n ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n}\n\nvoid solve(){\n int n, m;\n cin >> n >> m;\n int a[n + 2] = {0};\n for(int c = 1; c <= n; c++){\n int d = abs(c - m);\n if(d > 0){\n int l = max(1, c-(d-1));\n int r = min(n, c+(d-1));\n a[l]++;\n a[r + 1]--;\n }\n }\n int ans = 0, mx = 0, sum = 0;\n for(int i = 1; i <= n; i++){\n sum += a[i];\n if(mx < sum){\n mx = sum;\n ans = i;\n }\n }\n cout << ans << endl;\n\n}\n\nint main(){\n\tfast_io();\n\t\n solve();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4c00eb48a2ad064bfd3248a93f29f1c9", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define LLI long long int\n#define LD long double\n#define FOR(x,y,z) for(int x = y; x> n >> m;\n\t\n\tdouble center = n / 2;\n\tcout << fixed;\n\tif (m > center) {\n\t\tcout << m-1;\n\t}\n\telse {\n\t\tcout << m+1;\n\t}\n\t_getch();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "509f09cb5bba6fed4f4548ba57c22085", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\nint main()\n{\n\tlong long int n,m,a;\n\tcin>>n>>m;\n\tif((m-1)>(n-m))\n\t{\n\t\tcout<\nint main()\n{\n\twhile(1){\n\t\n\tint n,m,i,sum=0,s;\n\tcin>>n;\n\tcin>>m;\n\tint*p=new int[n];\n\tfor(i=0;i>*(p+i);\n sum=sum+*(p+i);\n}\n\tif(sum%m==0)\n\ts=sum/m;\n\telse\n\ts=sum/m+1;\n\tcout<\nusing namespace std;\nint main()\n{\n\tint n, m, i, a[102], num = 0, sum = 0;\n\tcin >> n >> m;\n\tif (n == 1) num = 1;\n\telse\n\t{\n\t\tfor (i = 0; i < n; i++)\n\t\t{\n\t\t\tcin >> a[i];\n\t\t\tif (a[i] == m)\n\t\t\t{\n\t\t\t\tif (sum > 0)\n\t\t\t\t{\n\t\t\t\t\tnum += 2;\n\t\t\t\t\tsum = 0;\n\t\t\t\t}\n\t\t\t\telse num++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tsum += a[i];\n\t\t\t\tif (sum == m)\n\t\t\t\t{\n\t\t\t\t\tnum++;\n\t\t\t\t\tsum = 0;\n\t\t\t\t}\n\t\t\t\telse if (sum > m)\n\t\t\t\t{\n\t\t\t\t\tsum = 0;\n\t\t\t\t\ti--;\n\t\t\t\t\tnum++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tcout << num;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7ba05d51ed2c630e1e7b4c39ac85475c", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint main() \n{ \n int n , m;\n int a[105];\n while(scanf(\"%d%d\",&n,&m))\n {\n for(int i = 0 ; i < n ; i ++)\n {\n scanf(\"%d\",&a[i]);\n }\n int sum=1,k=0;\n for(int i = 0 ; i < n ; i ++)\n {\n k += a[i];\n if(k > m)\n {\n sum++;\n i--;\n k=0;\n }\n }\n cout<\nint main()\n{\n\twhile(1){\n\t\n\tint n,m,i,sum=0,s;\n\tcin>>m;\n\tcin>>n;\n\tint*p=new int[n];\n\tfor(i=0;i>*(p+i);\n sum=sum+*(p+i);\n}\n\n cout<\nusing namespace std;\n\nint main() {\n\tint x,y;\n\tcin >> x>>y;\n\tint count = 0;\n\twhile (x <= y) {\n\t\tcount++;\n\t\tx *= 3;\n\t\ty *= 2;\n\n}\n\n\tcout << count;\n\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a993c4377732876334815c809630ab64", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include\n#include\nusing namespace std;\n\nint main(){\n float limak,bob;\n cin >> limak >> bob;\n int num1=log(bob/limak);\n int num2=log(3.0/2);\n int yr = ceil(num1/num2);\n cout << yr;\n \n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "56aead8e4b887c6709cc5a414fdd7d08", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0} {"lang": "MS C++ 2017", "source_code": "#include \n#include \n\nusing namespace std;\n\nvoid main()\n{\n int a,b,y;\n cin >> a >> b;\n for(y=0;a<=b;y++)\n {\n a=a*3;\n b=b*2;\n }\n cout << y;\n _getch();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0847eb86a1bf0288c9b23def1ff0dc35", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0} {"lang": "Clang++17 Diagnostics", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n\tint a, b, i;\n\tcin >> a >> b;\n\tfor(i = 0; a <= b; i++){\n\t\ta = a * 3;\n\t\tb = b * 2;\n\t}\n\tcout << i;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e24608de667f9a252478d168f5b3b41c", "src_uid": "a1583b07a9d093e887f73cc5c29e444a", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "\nint main() { int *p = 0; *p = 1; return 0; }\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1e559e9cd50bf665a71b187d7593493a", "src_uid": "fe8a0332119bd182a0a5b7758716317e", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include \n#define pi 3.1415926535\n#define mod9 1000000009\n#define mod7 1000000007\nusing namespace std;\nint main(){\n //freopen(\"input.txt\",\"r\",stdin);\n //freopen(\"output.txt\",\"w\",stdout);\n int n,i;\n cin>>n;\n if (n==1) n=n/(n-1);\n if (n<=2) {cout<<-1; return 0;};\n cout<<10;\n for (i=2;i<=n;i++)\n cout<<10;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ab90303cea27e663f83472cc9dfca8e4", "src_uid": "fe8a0332119bd182a0a5b7758716317e", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include \n#include\n#include\nusing namespace std;\n\nint arr[50]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41\n,42,43,44,45,46,47,48,49,50};\n\nvoid sorting(int v[],int size)\n{\n for(int i=0;iv[j+1])swap(v[i],v[i+1]);\n }\n }\n}\n\nint main()\n{\n int n;\n cin>>n;\n\n if(n<=2)cout <<-1;\n else {\n sorting(arr,n);\n for(int i=n-1;i>=0;i++)cout <\n#include \n\n#include \n//#include \n//#include \n//#include \n//#include \n\nusing namespace std;\n\ntemplate\nstruct ab {\n union { A a, x; };\n union { B b, y; };\n\n ab() : a(A{}), b(B{}) {}\n ab(A a, B b) : a(a), b(b) {}\n bool operator==(ab o) {\n return a == o.a and b == o.b;\n }\n bool operator!=(ab o) {\n return a != o.a or b != o.b;\n }\n\n friend istream &operator>>(istream &s, ab &self) {\n return s >> self.a >> self.b;\n }\n};\n\ntemplate\nstruct abc {\n union { A a, x; };\n union { B b, y; };\n union { C c, z; };\n\n abc() : a(A{}), b(B{}), c(C{}) {}\n abc(A a, B b, C c) : a(a), b(b), c(c) {}\n\n friend istream &operator>>(istream &s, abc &self) {\n return s >> self.a >> self.b >> self.c;\n }\n};\n\nusing ll = long long;\nusing ull = unsigned long long;\nusing ld = long double;\n//using ii = ab;\nusing ii = pair;\n\nusing vb = vector;\nusing vi = vector;\nusing vii = vector;\nusing vc = vector;\n\nusing vvi = vector;\nusing vvb = vector;\nusing vvc = vector;\nusing vsi = vector>;\nusing vmsi = vector>;\nusing vvii = vector;\ntemplate\nusing vv = vector>;\n\nusing iii = abc;\n//using iiii = abcd;\nusing v3i = vector;\n//using v4i = vector;\n\n//const ll inf = 1e18;\n\n#ifndef DEBUG\n// interactive\n//#define endl '\\n'\n#else\n#endif\n\nauto solve() -> void;\n\nauto init() -> void;\n\nextern bool enable_multitests;\n\nauto main() -> int {\n#if defined(DEBUG)\n freopen(\"../in.txt\", \"r\", stdin);\n freopen(\"../out.txt\", \"w\", stdout);\n#endif\n\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n cout.setf(ios::fixed);\n cout.precision(10);\n\n#ifdef DEBUG\n cerr << \"multitest: \" << enable_multitests << endl;\n cerr << \"--------------\" << endl;\n#endif\n\n ll case_count = 1;\n ll case_id = 1;\n if (enable_multitests) {\n cin >> case_count;\n }\n init();\n while (case_count--) {\n// if (enable_multitests)\n// cout << \"Case #\" << case_id << \": \";\n solve();\n ++case_id;\n }\n}\n\n#ifndef DEBUG\nmt19937_64 random_generator = mt19937_64(random_device()());\n#else\nmt19937_64 random_generator = mt19937_64(1337); // NOLINT(cert-msc51-cpp,cert-err58-cpp)\n#endif\n\ninline ll rnd(ll a, ll b) {\n ll x = random_generator();\n x %= b - a + 1;\n x += a;\n return x;\n}\n\nextern const ll mod;\n\ntemplate\nT modpow(T base, T exp) {\n T modulus = mod;\n base %= modulus;\n T result = 1;\n while (exp > 0) {\n if (exp & 1) result = (result * base) % modulus;\n base = (base * base) % modulus;\n exp >>= 1;\n }\n return result;\n}\n\ntemplate\nT mod_invert(T a) {\n if (a < 1 or mod < 2)\n return -1;\n\n T u1 = mod;\n T u2 = 0;\n T v1 = a;\n T v2 = 1;\n\n while (v1 != 0) {\n T q = u1 / v1;\n T t1 = u1 - q * v1;\n T t2 = u2 - q * v2;\n u1 = v1;\n u2 = v2;\n v1 = t1;\n v2 = t2;\n }\n\n return u1 == 1 ? (u2 + mod) % mod : -1;\n}\n\ntemplate\nostream &operator<<(ostream &s, const pair &self) {\n s << \"{\" << self.first << \", \" << self.second << \"}\";\n return s;\n}\n\ntemplate\nostream &operator<<(ostream &s, const vector &self) {\n for (auto e : self) {\n s << e << ' ';\n }\n return s;\n}\n\ntemplate\nistream &operator>>(istream &s, pair &self) {\n s >> self.first >> self.second;\n return s;\n}\n\ntemplate\nistream &operator>>(istream &s, tuple &self) {\n s >> get<0>(self) >> get<1>(self) >> get<2>(self);\n return s;\n}\n\ntemplate\nistream &operator>>(istream &s, tuple &self) {\n s >> get<0>(self) >> get<1>(self) >> get<2>(self) >> get<3>(self);\n return s;\n}\n\ntemplate\nistream &operator>>(istream &s, vector &self) {\n for (int i = 0; i < self.size(); ++i) {\n s >> self[i];\n }\n return s;\n}\n\n// \u0432\u0440\u043e\u0434\u0435 \u0442\u0430\u043a\n#if __cplusplus >= 201700L\ntemplate>\nusing ordered_map = __gnu_pbds::tree;\n\ntemplate>\nusing ordered_set = ordered_map;\n\n//template\n//inline void print_one(T arg) {\n// cout << arg << ' ';\n//}\n//\n//template\n//inline void print_(T&& ... args) {\n// (print_one(args), ...);\n// cout << endl;\n//}\n\n//#define print(...) print_(__VA_ARGS__)\n\n#else\n#define gcd __gcd\n#endif // __cplusplus\n\ntemplate\nvoid prl(const T &t) {\n cout << t << endl;\n}\n\nbool is_prime(ll x) {\n for (int i = 2; i * i <= x; ++i) {\n if (x % i == 0) return false;\n }\n return true;\n}\n\nstruct pair_hash {\n template\n std::size_t operator()(const std::pair &p) const {\n auto h1 = std::hash{}(p.first);\n auto h2 = std::hash{}(p.second);\n\n // Mainly for demonstration purposes, i.e. works but is overly simple\n // In the real world, use sth. like boost.hash_combine\n return h1 ^ h2;\n }\n};\n\n#define RETURN_NO return prl(\"NO\")\n#define RETURN_YES return prl(\"YES\")\n#define RETURN_YESNO(expr) return prl((expr) ? \"YES\" : \"NO\")\n#define RETURN(expr) return prl((expr))\n\n#define X(...) __VA_ARGS__.first\n#define Y(...) __VA_ARGS__.second\n\n#define todo static_assert(false);\n\n// -----\n\nbool enable_multitests = false;\n\nconstexpr ll mod = 1e9 + 7;\n\nauto init() -> void {}\n\n// ----\n\n//using i128 = __int128_t;\n\n// ----\n\nconstexpr ll inf = 1e18;\nusing vertex = ll;\n\n/// \u0434\u0435\u0440\u0435\u0432\u043e \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u0432 \u043d\u0430 \u043f\u043e\u043b\u0443\u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u0445, \u043a\u043e\u0440\u0435\u043d\u044c: 1.\n/// \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0441\u0443\u043c\u043c\u0443 \u043d\u0430 \u043e\u0442\u0440\u0435\u0437\u043a\u0435, \u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435.\nclass segment_tree {\n ll n;\n vector tree;\n vector mod;\n vector arr;\n\n public:\n explicit segment_tree(const vector &arr_in) {\n n = 1 << ll(ceil(log2(arr_in.size())));\n arr.resize(n);\n tree.resize(2 * n);\n mod.resize(2 * n);\n for (int i = 0; i < arr_in.size(); ++i) {\n arr[i] = arr_in[i];\n }\n build(1, 0, n);\n }\n\n vertex query(ll l, ll r) {\n return query(1, 0, n, l, r);\n }\n vertex query(ll i) {\n return query(i, i + 1);\n }\n\n void update(ll l, ll r, ll x) {\n return update(1, 0, n, l, r, x);\n }\n void update(ll i, ll x) {\n return update(i, i + 1, x);\n }\n\n protected:\n vertex query(ll v, ll l, ll r, ll ql, ll qr) {\n if (r <= ql or qr <= l) {\n return 0;\n }\n if (ql <= l and r <= qr) {\n return getval(v, l, r);\n }\n push(v);\n ll m = (l + r) / 2;\n vertex a = query(2 * v, l, m, ql, qr);\n vertex b = query(2 * v + 1, m, r, ql, qr);\n tree[v] = merge(getval(2 * v, l, m), getval(2 * v + 1, m, r));\n return merge(a, b);\n }\n\n void update(ll v, ll l, ll r, ll ql, ll qr, ll x) {\n if (r <= ql or qr <= l) {\n return;\n }\n if (ql <= l and r <= qr) {\n mod[v] += x;\n return;\n }\n push(v);\n ll m = (l + r) / 2;\n update(2 * v, l, m, ql, qr, x);\n update(2 * v + 1, m, r, ql, qr, x);\n tree[v] = merge(getval(2 * v, l, m), getval(2 * v + 1, m, r));\n }\n\n void build(ll v, ll l, ll r) {\n if (l + 1 == r) {\n tree[v] = arr[l];\n return;\n }\n ll m = (l + r) / 2;\n build(2 * v, l, m);\n build(2 * v + 1, m, r);\n tree[v] = merge(getval(2 * v, l, m), getval(2 * v + 1, m, r));\n }\n\n void push(ll v) {\n mod[2 * v] += mod[v];\n mod[2 * v + 1] += mod[v];\n mod[v] = 0;\n }\n\n vertex getval(ll v, ll l, ll r) {\n return tree[v] + mod[v] * (r - l);\n }\n\n static vertex merge(vertex a, vertex b) {\n return a + b;\n }\n};\n\nauto solve() -> void {\n ll n, kk;\n cin >> n >> kk;\n vector cnt(kk + 1, segment_tree{vi(n + 1)});\n for (ll k = 0; k <= kk; ++k) {\n for (ll h = 0; h <= n; ++h) {\n if (k == 0) {\n cnt[k].update(h, 1);\n } else {\n// cnt[k][h] = sum(cnt[h - 1..0][k - 1]);\n cnt[k].update(h, cnt[k - 1].query(0, h) + 1);\n }\n#ifdef DEBUG\n cout << cnt[k].query(h) << ' ';\n#endif\n }\n#ifdef DEBUG\n cout << endl;\n#endif\n }\n cout << cnt[kk].query(n) << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "54ac3c8496832035f7f3f81c698fe251", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0} {"lang": "GNU C++14", "source_code": "#include \r\nusing namespace std;\r\n#define ll long long\r\ntypedef pair ii;\r\n#define eps 1e-9\r\n#define pi 3.141592653589793\r\nconst int INF = 1e9 + 5;\r\nconst int MOD = 1e9 + 7;\r\n\r\nint main()\r\n{\r\n int n, k;\r\n cin >> n >> k;\r\n\r\n vector> dp(n+2, vector(k+3, 0));\r\n\r\n for(int i = 0; i <=k; i++) dp[0][i] = 1;\r\n for(int i = 0; i <= n; i++){\r\n for(int j = 0; j<= k; j++){\r\n (dp[i+1][j+1] += dp[i][j])%=MOD;\r\n (dp[i+1][j] += dp[i][j])%=MOD;\r\n }\r\n }\r\n cout << dp[n][k];\r\n return 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "72e7065e58daa1851dc38f2e29c62013", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0} {"lang": "GNU C++20 (64)", "source_code": "#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\nusing namespace std;\r\n\r\nconstexpr int64_t MOD = 1'000'000'007;\r\n\r\nint binom(vector>& dp, int N, int K, int M) {\r\n auto& res = dp[N][K];\r\n if (res != -1) {\r\n return res;\r\n }\r\n if (N < K) {\r\n res = 0;\r\n return res;\r\n }\r\n if (K == 0 || K == N) {\r\n res = 1;\r\n return res;\r\n }\r\n res = binom(dp, N - 1, K - 1, M) + binom(dp, N - 1, K, M);\r\n res += M;\r\n res %= M;\r\n return res;\r\n}\r\n\r\nint main() {\r\n cin.tie(nullptr);\r\n ios_base::sync_with_stdio(false);\r\n int64_t n = 0, k = 0;\r\n cin >> n >> k;\r\n vector> dp(n + 1, vector(n + 1, -1));\r\n int64_t res = 0;\r\n for (int i = 0; i <= min(n, k); ++i) {\r\n res += binom(dp, n, i, MOD);\r\n res += MOD;\r\n res %= MOD;\r\n }\r\n cout << res;\r\n\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5cfed044057c9c2913427d1e113834f2", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0} {"lang": "GNU C++20 (64)", "source_code": "#include \r\n#define rep(i, l, r) for(int i = (l); i <= (r); i++)\r\n#define rge(i, l, r) for(int i = (l); i < (r); i++)\r\n#define forn(i, n) rep(i, 1, n)\r\n#define forr(i, n) rge(i, 0, n)\r\n#define rept(i, l, r) for(T i = (l); i <= (r); i++) /* tag : definatiors */\r\n#define rget(i, l, r) for(T i = (l); i < (r); i++) /* tag : definatiors */\r\n#define fornt(i, n) rept(i, 1, n) /* tag : definatiors */\r\n#define forrt(i, n) rget(i, 0, n) /* tag : definatiors */\r\n#define al(item) (item).begin(), (item).end()\r\n#define se second\r\n#define pb push_back\r\n#define nxtp next_permutation\r\n#define int long long /* tag : warning */\r\n#define int32 int\r\n#define int64 long long\r\n#define int128 __int128\r\n#define db double\r\n#define ld long double\r\n#define fi first\r\n#define exitcode(x) { cout << x << endl; return 0; }\r\nusing namespace std;\r\n\r\n/* rander */ namespace rander {\r\n//rand values\r\n//based on mt19937\r\nunsigned long long seed = chrono::system_clock::now().time_since_epoch().count();\r\nmt19937 rd(seed);\r\nint randint(int l, int r) {\r\n uniform_int_distribution lim(l, r);\r\n return lim(rd);\r\n}\r\nlong long randlong(long long l, long long r) {\r\n uniform_int_distribution lim(l, r);\r\n return lim(rd);\r\n}\r\nvector permutation_shuffle(int size_) {\r\n vector ans(size_ + 10);\r\n\r\n for (int i = 1; i <= size_; i++) {\r\n ans[i - 1] = i;\r\n }\r\n\r\n for (int i = 1; i <= size_ * ((int)log(size_)); i++) {\r\n int leftcur = randint(1, size_);\r\n int rightcur = randint(1, size_);\r\n swap(ans[leftcur - 1], ans[rightcur - 1]);\r\n }\r\n\r\n ans.resize(size_ + 1);\r\n return ans;\r\n}\r\nvector common_shuffle(vector v) {\r\n int size_ = v.size();\r\n vector ans = v;\r\n\r\n for (int i = 1; i <= size_; i++) {\r\n ans[i - 1] = v[i - 1];\r\n }\r\n\r\n for (int i = 1; i <= size_ * ((int)log(size_)); i++) {\r\n int leftcur = randint(1, size_);\r\n int rightcur = randint(1, size_);\r\n swap(ans[leftcur - 1], ans[rightcur - 1]);\r\n }\r\n\r\n ans.resize(size_ + 1);\r\n return ans;\r\n}\r\nvector array_random(int size_, int l, int r) {\r\n vector ans(size_ + 10);\r\n\r\n for (int i = 1; i <= size_; i++) {\r\n ans[i - 1] = randint(l, r);\r\n }\r\n\r\n ans.resize(size_ + 1);\r\n return ans;\r\n}\r\nvector random_sorted(int size_, int l, int r) {\r\n vector ans = array_random(size_, l, r);\r\n sort(ans.begin(), ans.end());\r\n return ans;\r\n}\r\nvector random_unique(int size_, int l, int r) {\r\n vector ans = random_sorted(size_, l, r);\r\n unique(ans.begin(), ans.end());\r\n ans = common_shuffle(ans);\r\n return ans;\r\n}\r\n}\r\n\r\nusing namespace rander;\r\n\r\n/* Fast IO */ namespace FastIO {\r\ntemplate inline T read() {\r\n T x = 0, w = 1;\r\n char c = 0;\r\n\r\n while (c < '0' || c > '9') {\r\n if (c == '-')\r\n w = -1;\r\n\r\n c = getchar();\r\n }\r\n\r\n while (c >= '0' && c <= '9') {\r\n x = x * 10 + (c - '0');\r\n c = getchar();\r\n }\r\n\r\n return x * w;\r\n}\r\ntemplate inline void write(T x) {\r\n if (x < 0) {\r\n x = -x;\r\n putchar('-');\r\n }\r\n\r\n if (x > 9)\r\n write(x / 10);\r\n\r\n putchar(x % 10 + '0');\r\n}\r\nint getInt() {\r\n\treturn read();\r\n}\r\nvoid putInt(int x, char c) {\r\n\twrite(x), putchar(c);\r\n\treturn ;\r\n}\r\n} using namespace FastIO;\r\n\r\n/* combinatorics */ namespace combinatorics {\r\nint mod = 998244353;\r\ntemplate inline T qpow(T a, T b, T p) {\r\n T res = 1;\r\n\r\n while (b) {\r\n if (b % 2 == 1)\r\n res = res * a % p;\r\n\r\n a = a * a % p;\r\n b /= 2;\r\n }\r\n\r\n return res;\r\n}\r\ntemplate struct factorial {\r\n T fac[1000005], ifac[1000005];\r\n T d[1000005], cat[1000005];\r\n\r\n inline void init(T lim) {\r\n fac[0] = ifac[0] = d[0] = cat[0] = 1;\r\n ifac[lim] = qpow(fac[lim], mod - 2, mod);\r\n rept(i, 1, lim) fac[i] = fac[i - 1] * i % mod;\r\n rept(i, 2, lim) d[i] = (d[i - 1] + d[i - 2]) * (i - 1) % mod;\r\n\r\n for (T i = lim - 1; i; i--)\r\n ifac[i] = ifac[i + 1] * (i + 1) % mod;\r\n\r\n rept(i, 1, lim) cat[i] = cat[i - 1] * (4 * i - 2) * qpow(i + 1, mod - 2, mod);\r\n }\r\n\r\n inline T C(T n, T k, T p) {\r\n return fac[n] * qpow(fac[k], mod - 2, mod) % mod * qpow(fac[n - k], mod - 2, mod) % mod;\r\n }\r\n};\r\n} using namespace combinatorics;\r\n\r\n/* union find set */ struct ufs {\r\n int fa[1000005];\r\n\r\n inline void init(int n) {\r\n rep(i, 1, n) fa[i] = i;\r\n } inline int find(int x) {\r\n return (fa[x] == x ? x : (fa[x] = find(fa[x])));\r\n } void unite(int x, int y) {\r\n if (find(x) != find(y))\r\n fa[find(x)] = find(y);\r\n } bool together(int x, int y) {\r\n return find(x) == find(y);\r\n }\r\n};\r\n\r\n/* definations */\r\n\r\n/* Temp Main Func */ int solve() {\r\n\tfactorial f;\r\n\tf.init(100005);\r\n\tint n = getInt(), k = min(getInt(), n);\r\n\tint s = 0;\r\n\tfor(int i = 0; i <= k; i++)\r\n\ts += f.C(n, i, 1000000007);\r\n\tcout << s << endl;\r\n return 0;\r\n}\r\n\r\n/* Main Func */ signed main() {\r\n int _T_ = read();\r\n\r\n while (_T_--)\r\n solve();\r\n\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "05b290425879f62d9e714ee06d536bf0", "src_uid": "dc7b887afcc2e95c4e90619ceda63071", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nint main(){\nint n , t;\ncin >> n >> t;\nif(n==1&&t==10){\ncout << -1;\nreturn 0;\n}\n cout << t;\n\nfor(int i=1;i\nusing namespace std;\n int main()\n {int n,t;\n cin>>n>>t;\n if(t==10){cout<<\"-1\"; return 0;\n }else\n {for(int i=0;i\n#include \n#include \nusing namespace std;\nmain()\n{\n int n,t,b=0;\n cin>>n;\n int a1=pow(10,n-1),a2=pow(10,n);\n cin>>t;\n for (int i=a1+1;i\n#include\n#include\nusing namespace std;\nint main()\n{\n int a,t;\n cin>>a>>t;\n if(a>=2)\n {\n cout<<\"1\";\n for(int i=1;i----------------------------\r\n/*\r\n#pragma GCC optimize(\"Ofast,unroll-loops\")\r\n#pragma GCC target(\"avx,avx2,fma\")\r\n*/\r\n// -------------------------------------------------------\r\n\r\n// -----------------------------------------------------------------\r\n#include \r\n#include \r\nusing namespace __gnu_pbds;\r\ntemplate \r\nusing o_set = __gnu_pbds::tree, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;\r\ntemplate \r\nusing o_multiset = __gnu_pbds::tree, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;\r\ntemplate >\r\nusing o_map = __gnu_pbds::tree;\r\n//member functions :\r\n// 1. order_of_key (val): returns the no. of values less than val\r\n// 2. find_by_order (k): returns the iterator to kth largest element.(0-based)\r\n// for ordered_multiset, lower_bound and upper_bound swap roles\r\n// ----------------------------------------------------------------\r\n\r\n// -------------------------------------------------\r\nusing ll = int64_t;\r\nusing db = double;\r\nusing str = string;\r\nusing ull = unsigned long long;\r\n#define fo(i, n) for (ll i = 0; i < n; i++)\r\n#define rep(i, k, n) for (ll i = k; k < n ? i < n : i > n; k < n ? i++ : i--)\r\n#define set_bits(x) __builtin_popcountll(x)\r\n#define eb emplace_back\r\n#define ff first\r\n#define ss second\r\n#define all(x) (x).begin(), (x).end()\r\n#define uniq(x) (x).erase(unique(all(x)), (x).end())\r\n#define rall(x) (x).rbegin(), (x).rend()\r\n#define ps(x, y) fixed << setprecision(y) << x\r\n#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)\r\n#define sz(x) ((ll)(x).size())\r\ntemplate \r\nusing V = vector;\r\nusing vl = V;\r\nusing vvl = V;\r\ntemplate \r\nusing P = pair;\r\nusing pl = P;\r\nusing vpl = V;\r\n// ------------------------------------------------\r\n\r\n// ---------------------------------------------------------------\r\nconst ll mod = 1e9 + 7; //1000000007\r\nconst ll mod2 = 998244353;\r\nconst ll inf = LLONG_MAX;\r\nconst db eps = 1e-12;\r\nconst double PI = acos(-1);\r\n// --------------------------------------------------------------\r\n\r\n// ------------------------------------------------------------\r\ntemplate \r\nbool amin(T& a, U&& b) {\r\n return b < a ? a = std::forward(b), true : false;\r\n}\r\ntemplate \r\nbool amax(T& a, U&& b) {\r\n return a < b ? a = std::forward(b), true : false;\r\n}\r\n// -----------------------------------------------------------\r\n\r\n// ----------------------------------------------------------------\r\n\r\nll num(string s) {\r\n ll res = 0;\r\n for (ll i = 0; i < (ll)s.size(); ++i) {\r\n res = res * 10 + (s[i] - '0');\r\n }\r\n return res;\r\n}\r\n\r\nvoid Solution() {\r\n string s;\r\n cin >> s;\r\n ll n = s.length();\r\n if (s == \"0\" || s == \"X\" || s == \"_\") return void(cout << 1);\r\n if (n == 1) return void(cout << 0);\r\n // now n >= 2 && n <= 8\r\n string bak = s.substr(n - 2);\r\n string frnt = s.substr(0, n - 2);\r\n\r\n ll ans = 1;\r\n fo(i, sz(frnt)) {\r\n if (s[i] == '_') {\r\n if (i == 0)\r\n ans *= 9;\r\n else\r\n ans *= 10;\r\n }\r\n }\r\n ll it = frnt.find('X');\r\n bool yes_f = (it == 0);\r\n bool yes = (it != -1);\r\n bool no = (it == -1);\r\n bool nothin = (frnt == \"\");\r\n dbg(ans);\r\n\r\n // 25 75 50 00\r\n if (bak == \"__\") {\r\n if (nothin)\r\n ans *= 3;\r\n else {\r\n ans *= 4;\r\n if (yes_f)\r\n ans *= 9;\r\n else if (yes)\r\n ans *= 10;\r\n }\r\n cout << ans;\r\n } else if (bak == \"_X\") {\r\n if (nothin)\r\n ans *= 3;\r\n else {\r\n ans *= 2;\r\n if (yes_f)\r\n ans *= 1;\r\n else if (yes || no)\r\n ans *= 2;\r\n }\r\n cout << ans;\r\n } else if (bak == \"X_\") {\r\n if (nothin)\r\n ans *= 3;\r\n else {\r\n if (yes_f)\r\n ans *= 3; //25 75 50\r\n else if (yes || no)\r\n ans *= 4;\r\n }\r\n cout << ans;\r\n } else if (bak == \"XX\") {\r\n if (nothin)\r\n ans = 0;\r\n else {\r\n // so XX can be 00\r\n if (yes_f)\r\n ans = 0;\r\n else if (yes || no) {\r\n }\r\n }\r\n cout << ans;\r\n } else if (bak[0] == '_') {\r\n if (yes_f)\r\n ans *= 9;\r\n else if (yes)\r\n ans *= 10;\r\n if (bak[1] == '5') {\r\n ans *= 2; //25 75\r\n cout << ans;\r\n } else if (bak[1] == '0') {\r\n if (nothin) {\r\n } else\r\n ans *= 2; // 00 50\r\n cout << ans;\r\n } else {\r\n cout << 0;\r\n }\r\n } else if (bak[1] == '_') {\r\n if (it == 0)\r\n ans *= 9;\r\n else if (it != -1)\r\n ans *= 10; // Xs in frnt\r\n if (bak[0] == '2') {\r\n cout << ans; // 2_\r\n }\r\n if (bak[0] == '5') {\r\n cout << ans; //5_\r\n }\r\n if (bak[0] == '7') {\r\n cout << ans; //7_\r\n }\r\n if (bak[0] == '0') {\r\n //0_, this frnt cant be empty\r\n cout << ans;\r\n } else\r\n cout << 0;\r\n } else if (bak[0] == 'X') {\r\n if (bak[1] == '0') { // X0\r\n if (it == 0)\r\n cout << ans;\r\n else if (it != -1)\r\n cout << 2 * ans;\r\n else if (it == -1)\r\n cout << 1;\r\n }\r\n if (bak[1] == '5') { // X5\r\n ans *= 2; // bcoz of X\r\n cout << ans;\r\n }\r\n } else if (bak[1] == 'X') {\r\n if (bak[0] == '2' || bak[0] == '7') {\r\n // 2X\r\n cout << ans;\r\n }\r\n if (bak[0] == '5') {\r\n // 5X\r\n if (yes_f) ans = 0;\r\n cout << ans;\r\n }\r\n if (bak[0] == '0') {\r\n // 0X now as frnt cant be empty\r\n if (yes_f) ans = 0;\r\n cout << ans;\r\n }\r\n } else if (bak == \"25\" || bak == \"75\" || bak == \"50\" || bak == \"00\") {\r\n if (yes_f)\r\n ans *= 9;\r\n else if (yes)\r\n ans *= 10;\r\n cout << ans;\r\n } else\r\n cout << 0;\r\n cout << '\\n';\r\n}\r\n\r\n/*\r\n10\r\n_X8_\r\nX_X_\r\n____\r\nXXXX\r\nX000\r\nX_XX\r\n__X5\r\n_X58\r\n9090\r\n2050\r\n*/\r\n\r\n// ---------------------------------------------------------------\r\n\r\nint main() {\r\n ll tc = 1;\r\n#ifndef ONLINE_JUDGE\r\n freopen(\"input.txt\", \"r\", stdin);\r\n freopen(\"output.txt\", \"w\", stdout);\r\n#endif\r\n cin.tie(nullptr)->sync_with_stdio(false);\r\n#ifdef NCR\r\n init();\r\n#endif\r\n // cin >> tc;\r\n while (tc--) {\r\n Solution();\r\n }\r\n#ifndef ONLINE_JUDGE\r\n cerr << fixed << setprecision(4) << (double)clock() / CLOCKS_PER_SEC << \" secs\" << endl;\r\n#endif\r\n return 0;\r\n}\r\n\r\n/*\r\n ? Stuff to look for ->\r\n * stay organised\r\n * int overflows, array bounds, etc.\r\n * special cases (n=1)?\r\n * do something instead of nothing\r\n * n % mod = (n % mod + mod) % mod; (Handling negatives)\r\n * When using a set, lower_bound(all(set),l) is slower than set.lower_bound(l) because of random iterators\r\n * string .append() or += is O1, but s = s + s is On (as it creates a copy first), use wisely\r\n * DONT GET STUCK ON ONE APPROACH\r\n * use __lg(n) instead of log2(n), int: 32 - __builtin_clz(n), ll: 63 - __builtin_clzll(n), https://codeforces.com/blog/entry/45966\r\n * string.rfind() finds first occurence from end\r\n * (a & b) + (a | b) = a + b\r\n * TLE due to ll ? or multiple copies of large DS?\r\n * didnt use inv() in modular combinatorics? \r\n*/\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "32f3fae02a5fc26554e71b999fa95795", "src_uid": "4a905f419550a6c839992b40f1617af3", "difficulty": 1800.0} {"lang": "GNU C++20 (64)", "source_code": "#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#define ll long long\r\n#define ms(a, b) memset(a, b, sizeof(a))\r\n#define lowbit(x) (x & -x)\r\n#define fi first\r\n#define se second\r\n#define Size(a) int((a).size())\r\n#define all(x) x.begin(), x.end()\r\n#define ull unsigned long long\r\n#define lson (rt << 1)\r\n#define rson (rt << 1 | 1)\r\n#define endl \"\\n\"\r\n#define bug cout << \"----acac----\" << endl;\r\n#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);\r\nusing namespace std;\r\nll ksm(ll a, ll b, ll mod)\r\n{\r\n ll ans = 1;\r\n while (b)\r\n {\r\n if (b & 1)\r\n {\r\n ans = (a % mod * ans % mod) % mod;\r\n }\r\n b >>= 1;\r\n a = (a % mod * a % mod) % mod;\r\n }\r\n return ans;\r\n}\r\nll gcd(ll a, ll b)\r\n{\r\n return b == 0 ? a : gcd(b, a % b);\r\n}\r\nll read()\r\n{\r\n ll x = 0, f = 1;\r\n char ch = getchar();\r\n while (ch < '0' || ch > '9')\r\n {\r\n if (ch == '-')\r\n f = -1;\r\n ch = getchar();\r\n }\r\n while (ch >= '0' && ch <= '9')\r\n {\r\n x = x * 10 + ch - '0';\r\n ch = getchar();\r\n }\r\n return x * f;\r\n}\r\nconst ll mod = 998244353;\r\nconst int maxn = 2e6 + 10;\r\nconst int N = 2e5 + 10;\r\nconst int maxm = 2e3 + 50;\r\nconst double eps = 1e-8;\r\nconst ll inf = 0x3f3f3f3f;\r\nconst ll lnf = 0x3f3f3f3f3f3f3f3f;\r\nconst double pi = acos(-1);\r\nint ans;\r\nmap p;\r\nvector v;\r\nint vis[100];\r\nvoid dfs(string s, int cnt, int sum)\r\n{\r\n if ((s[0] == '0' && s.size() != 1) || p[s])\r\n {\r\n return;\r\n }\r\n //cout << cnt <<\" \"<> s;\r\n if (s.size() == 1 && s[0] == '0')\r\n {\r\n cout << \"1\" << endl;\r\n return 0;\r\n }\r\n for (int i = 0; i < (int)s.size(); i++)\r\n {\r\n if (s[i] == 'X')\r\n {\r\n for (int j = 0; j < 10; j++)\r\n {\r\n string s0 = s;\r\n for (int k = 0; k < (int)s.size(); k++)\r\n {\r\n if (s0[k] == 'X')\r\n {\r\n s0[k] = j + '0';\r\n }\r\n }\r\n dfs(s0, 0, 0);\r\n }\r\n cout << ans << endl;\r\n return 0;\r\n }\r\n }\r\n dfs(s, 0, 0);\r\n cout << ans << endl;\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fafe1323a56eeffc9a9c1fa32e44cbf9", "src_uid": "4a905f419550a6c839992b40f1617af3", "difficulty": 1800.0} {"lang": "GNU C++17", "source_code": "#include \r\n#include \r\n \r\nusing namespace std;\r\nusing namespace __gnu_pbds;\r\n \r\n#define ll \t\tlong long\r\n#define all(v)\t\tv.begin(), v.end() \r\n#define DEBUG(x) \tstd::cout << #x << \" = \" << x << \"\\n\"\r\n#define FOR(i, a, b)\tfor(ll i=a; i<=b; i++)\r\n\r\nconst ll MOD = 1e9 + 7;\r\n\r\n#define MOD_ADD(a, b)\t(a%MOD + b%MOD)%MOD\r\n#define MOD_MUL(a, b)\t(a%MOD * b%MOD)%MOD\r\n#define MOD_DIV(a, b)\t(a%MOD * xpow(b, MOD-2))%MOD\r\n \r\ntemplate using Tree = tree, rb_tree_tag,tree_order_statistics_node_update>;\r\n\r\nll xpow(ll a, ll b){if(b==0)\treturn 1;ll aa = xpow(a, b/2);aa %= MOD;aa = (aa*aa)%MOD;if(b&1){aa*= a;aa %= MOD;}\treturn aa;}\r\n\r\nvectorpos;\r\n\r\nvoid recur(string s, ll idx, ll c){\r\n\r\n\tif(c==0){\r\n\r\n\t\tpos.push_back(s);\r\n\r\n\t\treturn;\r\n\t}\r\n\r\n\tif(s[idx]!='_')\trecur(s, idx+1, c);\r\n\telse{\r\n\t\tFOR(i, 0, 9){\r\n\t\t\tauto ss = s;\r\n\t\t\tss[idx] = '0' + i;\r\n\t\t\trecur(ss, idx+1, c-1);\r\n\t\t}\r\n\t}\r\n\r\n}\r\n\r\nvoid solve(){\r\n\tstring s;\tcin>>s;\r\n\tsete;\r\n\te.insert(\"00\");\r\n\te.insert(\"25\");\r\n\te.insert(\"50\");\r\n\te.insert(\"75\");\r\n\r\n\tll cx = 0;\r\n\tfor(auto x:s)\tif(x=='X')\tcx++;\r\n\r\n\tll c_ = 0;\t\r\n\tfor(auto x:s)\tif(x=='_')\tc_++;\r\n\r\n\tll ans = 0;\r\n\t\r\n\trecur(s, 0, c_);\r\n\r\n\t// cout<<\"====== pos ======\\n\";\r\n\t// for(auto x:pos)\tcout<>t;\r\n\t// while(t--)\t\r\n\t\tsolve();\t\r\n\r\n\treturn 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "29775d9dcd1e99bebf5eabed60c31f56", "src_uid": "4a905f419550a6c839992b40f1617af3", "difficulty": 1800.0} {"lang": "GNU C++20 (64)", "source_code": "/* author :- _thor__ (Piyush Gupta)*/\r\n\r\n\r\n#include\"bits/stdc++.h\"\r\n#include \r\n#include \r\n#define pbds \\\r\n tree, null_type, less >, \\\r\n rb_tree_tag, tree_order_statistics_node_update>\r\nusing namespace __gnu_pbds;\r\nusing namespace __gnu_cxx;\r\n#define ordered_set tree, rb_tree_tag,tree_order_statistics_node_update>\r\nusing namespace std;\r\n#define _thor__ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)\r\n#define MOD 1000000007\r\n#define MOD1 998244353\r\n#define INF LLONG_MAX\r\n#define VI(n) vectora(n);\r\n#define endl \"\\n\"\r\n#define pb push_back\r\n#define ppb pop_back\r\n#define mp make_pair\r\n#define ff first\r\n#define ss second\r\n#define PI 3.141592653589793238462\r\n#define set_bits __builtin_popcountll\r\n#define sz(x) ((int)(x).size())\r\n#define all(x) (x).begin(), (x).end()\r\n\r\ntypedef long long ll;\r\ntypedef unsigned long long ull;\r\ntypedef long double lld;\r\n// typedef tree, null_type, less>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key\r\n\r\n#ifndef ONLINE_JUDGE\r\n#define debug(x) cerr << #x <<\" \"; _print(x); cerr << endl;\r\n#else\r\n#define debug(x)\r\n#endif\r\n\r\nvoid _print(ll t) {cerr << t;}\r\nvoid _print(int t) {cerr << t;}\r\nvoid _print(string t) {cerr << t;}\r\nvoid _print(char t) {cerr << t;}\r\nvoid _print(lld t) {cerr << t;}\r\nvoid _print(double t) {cerr << t;}\r\nvoid _print(ull t) {cerr << t;}\r\n\r\ntemplate void _print(pair p);\r\ntemplate void _print(vector v);\r\ntemplate void _print(set v);\r\ntemplate void _print(map v);\r\ntemplate void _print(multiset v);\r\ntemplate void _print(pair p) {cerr << \"{\"; _print(p.ff); cerr << \",\"; _print(p.ss); cerr << \"}\";}\r\ntemplate void _print(vector v) {cerr << \"[ \"; for (T i : v) {_print(i); cerr << \" \";} cerr << \"]\";}\r\ntemplate void _print(set v) {cerr << \"[ \"; for (T i : v) {_print(i); cerr << \" \";} cerr << \"]\";}\r\ntemplate void _print(multiset v) {cerr << \"[ \"; for (T i : v) {_print(i); cerr << \" \";} cerr << \"]\";}\r\ntemplate void _print(map v) {cerr << \"[ \"; for (auto i : v) {_print(i); cerr << \" \";} cerr << \"]\";}\r\n/****************************************************************************************************************************/\r\nll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}\r\nll expo(ll a, ll b, ll mod) {ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}\r\nvoid extendgcd(ll a, ll b, ll*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size1 3\r\nll lcm(ll a,ll b){return (a*b)/gcd(a,b);}\r\nll countDivisors(ll n){ll cnt = 0;for (ll i = 1; i <= sqrt(n); i++) {if (n % i == 0) {if (n / i == i)cnt++;else cnt = cnt + 2;}}return cnt;}\r\n\r\nll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b\r\nll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}\r\nbool revsort(ll a, ll b) {return a > b;}\r\nll combination(ll n, ll r, ll m, ll *fact, ll *ifact) {ll val1 = fact[n]; ll val2 = ifact[n - r]; ll val3 = ifact[r]; return (((val1 * val2) % m) * val3) % m;}\r\nvoid google(int t) {cout << \"Case #\" << t << \": \";}\r\nvector primeFactors(ll n){vectorret;while (n % 2 == 0){ret.pb(2);n = n/2;}for (ll i = 3; i <= sqrt(n); i = i + 2){while (n % i == 0){ret.pb(i);n = n/i;}}if (n > 2){ret.pb(n);}return ret;}\r\nvector prime(ll n) {ll*arr = new ll[n + 1](); vector vect; for (ll i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (ll j = (ll(i) * ll(i)); j <= n; j += i)arr[j] = 1;} return vect;}\r\nvectordivisor(ll n){vectorres;for (ll i=1; i<=sqrt(n); i++){if (n%i == 0){if (n/i == i)res.pb(i);else{res.pb(i);res.pb(n/i);} }}return res;}\r\nvectorsieve(){ll MAXN=1e7;vectorspf(MAXN);spf[1] = 1;for (ll i=2; i0){cnt++;n/=10;}return cnt;}\r\nvectorcountSmallerRight(vectorarr){pbds s;ll n = arr.size();vector ans;for (ll i = n - 1; i >= 0; i--) {if (i == n - 1) { ans.push_back(0);}else {ans.push_back(s.order_of_key({ arr[i], i }));}s.insert({ arr[i], i });}reverse(ans.begin(), ans.end());return ans;}\r\nll mod_add(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}\r\nll getupper(ll k){ll x = 8*k+1;ll sqr = sqrt(x);if((sqr*sqr)==x){sqr--;return(sqr/2);}sqr--;return (sqr/2)+1;}\r\nll get2upper(ll n,ll rem){ll a = (2*n)+1;ll s = ((4*n*n)+(4*n)+1)-(8*rem);ll sqr = sqrt(s);if((sqr*sqr)==s){return ((a-sqr)/2)-1;}sqr++;return ((a-sqr)/2);}\r\nll mod_mul(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}\r\nll mod_sub(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}\r\nll cei(vector&v,ll l,ll r,ll key){while (r - l > 1) {ll m = l + (r - l) / 2;if (v[m] > key)r = m;else l = m;}return r;}\r\nll LongestIS(vector& v){if (v.size() == 0)return 0;vector tail(v.size(), 0);ll length = 1; tail[0] = v[0];for (size_t i = 1; i < v.size(); i++) {if (v[i] < tail[0])tail[0] = v[i];else if (v[i] >= tail[length - 1])tail[length++] = v[i];else tail[cei(tail, -1, length - 1, v[i])] = v[i];}return length;}\r\nll mod_div(ll a, ll b, ll m) {a = a % m; b = b % m; return (mod_mul(a, mminvprime(b, m), m) + m) % m;} //only for prime m\r\nvectorfactorial(ll n,ll m){vectorv(n);v[0]=1;for(ll i=1;i&fact,ll m) {ll a = fact[n];ll b = fact[n-r];ll c = fact[r];ll ans1 = mod_mul(b,c,m);ans1 = mod_div(a,ans1,m);return ans1;}\r\nll modPower(ll x,ll y){ll res = 1;x = x % MOD;if (x == 0)return 0;while (y > 0) {if (y & 1)res = (res * x) % MOD;y = y / 2;x = (x * x) % MOD;}return res;}\r\nll phin(ll n) {ll number = n; if (n % 2 == 0) {number /= 2; while (n % 2 == 0) n /= 2;} for (ll i = 3; i <= sqrt(n); i += 2) {if (n % i == 0) {while (n % i == 0)n /= i; number = (number / i * (i - 1));}} if (n > 1)number = (number / n * (n - 1)) ; return number;} //O(sqrt(N))\r\nll modFact(ll n){if (n >= MOD)return 0;ll result = 1;for (ll i = 1; i <= n; i++)result = (result * i) % MOD;return result;}\r\nll power(ll x,ll y){ll res=1;while(y>0){if(y&1)res = res * x;y = y >> 1;x = x * x;}return res;}\r\nll negMOD(ll x){x=-x;ll s = x/MOD;if(x%MOD)s++;return (MOD*s)-x;}\r\nvoid precision(ll a) {cout << setprecision(a) << fixed;}\r\n/*prime-O(n*log(log(n)));\r\n smallest prime factor-O(log(n));\r\n a%(b+c)=0 <=> a%c = b%c */\r\n/*--------------------------------------------------------------------------------------------------------------------------*/\r\nconst int N = 1e5+25;\r\nvectorv;\r\nvoid re(string &s,ll i)\r\n{\r\n if(i<0)\r\n {\r\n v.pb(s);\r\n return;\r\n }\r\n \r\n if(s[i]=='_')\r\n {\r\n for(ll j=0;j<10;j++)\r\n {\r\n s[i]=j+'0';\r\n re(s,i-1);\r\n s[i]='_';\r\n }\r\n }\r\n else re(s,i-1);\r\n}\r\nbool yes(string &s)\r\n{\r\n // debug(s)\r\n if(sz(s)==1&&s==\"0\")return true;\r\n if(sz(s)>1&&s[0]=='0')return false;\r\n ll x = stoi(s);\r\n if(x%25==0)return true;\r\n return false;\r\n}\r\nvoid solve()\r\n{\r\n string s; cin>>s;\r\n ll n = sz(s);\r\n\r\n re(s,n-1);\r\n debug(v)\r\n // cout<>test; while(test--) {solve();}\r\n solve();\r\n return 0;\r\n\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dc65bfa19537a95dfd8a8f03186d1255", "src_uid": "4a905f419550a6c839992b40f1617af3", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n//#include \n\nusing namespace std;\n\nint main()\n{\n string s;\n cin>>s;\n float a=((int)s[0]-48)*10+((int)s[1]-48);\n float b=((int)s[3]-48)*10+((int)s[4]-48);\n \n float y=(b*90)/15;\n float x= a*30+(y*30)/360;\n // if(360-y >y) y=360-y;\n //if(360-x < x) x=360-x;\n if(a==12) x=0;\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define REP(i,n) for(int i=0; i<(n); ++i)\n#define SZ(c) (c).size()\n#define FOREACH(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)\n\nint main(void) {\n int h, m;\n scanf(\"%d:%d\", &h, &m); \n double tm = h * 60 + m;\n double gh = (tm * 360) / 720;\n if (gh == 360) gh = 0.0;\n printf(\"%f %f\\n\", gh, ((360.0*m)/60.0));\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "26c5c5123bd34430f1e89899c9f94b5e", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include\nmain()\n{\n//freopen(\"input.txt\",\"r\",stdin);\n//freopen(\"output.txt\",\"w\",stdout);\nint x,y;\nscanf(\"%d:%d\",&x,&y);\ndouble s,c;\ns=(30.0*x)+(double(y)/2.0);\nc=y*6;\nif(s==360.0)s=0.0;\nprintf(\"%lf %lf\\n\",s,c);\nreturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5e2f3c9172b0978fc7412c996d456603", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include\n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n string a;\n int h, m;\n double hour;\n cin >> a;\n string fh = a.substr(0,2);\n string fm = a.substr(3,2);\n h = atoi(fh.c_str());\n m = atoi(fm.c_str());\n \n if(h==12 && m==0) {cout << \"0 0\" << endl; return 0;}\n if(h>23) h = h-12;\n hour = h*30 + double(m/2.);\n cout << hour << \" \" << m*6 << endl;\n \n //system(\"pause\");\n return 0;\n \n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2d1dcd42d36d856f43b5c5cae87fb518", "src_uid": "175dc0bdb5c9513feb49be6644d0d150", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "/*mjytxdy!*/\n#include \nusing namespace std;\n#define pb push_back\n#define fir first\n#define sec second\n#define all(x) x.begin(),x.end()\n#define size(x) ((int)x.size())\n#define pii pair\n#define pil pair\n#define pli pair\n#define pll pair\n#define inl inline\n#define rep(i,l,r) for(int i=(l);i<=(r);i++)\n#define per(i,r,l) for(int i=(r);i>=(l);i--)\n#define trv(i,u) for(int i=head[u];i;i=e[i].next)\n#define lb(x) ((x)&(-(x)))\n#define lson root<<1\n#define rson root<<1|1\n#define debug(x) cout<<#x\":\"<inl bool ylmin(T &a,T b){return ainl bool ylmax(T &a,T b){return a>b?0:(a=b,1);}\ntemplateinl T abs(T x){return x<0?-x:x;}\ninl char read(){\n\tstatic const int IO_LEN=1024*1024;\n\tstatic char buf[IO_LEN],*ioh,*iot;\n\tif(ioh==iot){\n\t\tiot=(ioh=buf)+fread(buf,1,IO_LEN,stdin);\n\t\tif(ioh==iot) return -1;\n\t}\n\treturn *ioh++;\n}\ntemplateinl void read(T &x){\n\tstatic int iosig;static char ioc;\n\tfor(iosig=0,ioc=read();!isdigit(ioc);ioc=read()) if(ioc=='-') iosig=1;\n\tfor(x=0;isdigit(ioc);ioc=read())x=(x<<1)+(x<<3)+(ioc^'0');\n\tif(iosig) x=-x;\n}\nconst int MAXN = 2e5+10;\nconst int block = sqrt(2e5);\nconst int inf = 1e9;\nconst int size = 8e5 + 10 ;\nint n,q,l,r,sum[MAXN][26];\nchar s[MAXN];\nvector d[MAXN]; \nstruct Sam{\n\tint Nodecnt=1,last=1;\n\tint link[size],len[size],next[size][26],pos[size],flag[size];\n\tinl void insert(int c,int po){\n\t\tint p=last,cur=++Nodecnt;\n\t\tpos[cur]=po,len[cur]=len[p]+1,flag[cur]=1;\n\t\tfor(;p && !next[p][c];p=link[p]) next[p][c]=cur;\n\t\tif(!p) link[cur]=1;\n\t\telse {\n\t\t\tint q=next[p][c];\n\t\t\tif(len[q]==len[p]+1) link[cur]=q;\n\t\t\telse{\n\t\t\t\tint clone=++Nodecnt;\n\t\t\t\tlen[clone]=len[q]+1;\n\t\t\t\tlink[clone]=link[q];\n\t\t\t\tpos[clone]=pos[q];\n\t\t\t\trep(i,0,25) next[clone][i]=next[q][i];\n\t\t\t\tfor(;p && next[p][c]==q;p=link[p]) next[p][c]=clone;\n\t\t\t\tlink[cur]=q,link[p]=q;\n\t\t\t}\n\t\t}\n\t\tlast=cur;\n\t}\n};\nstruct SA{\n\tSam sam;\n\tint sa[size],rank[size],height[size],st[19][size],lg2[size],dfs_time;\n\tint next[size][26];\n\tinl void build(){\n\t\trep(i,2,sam.Nodecnt) next[sam.link[i]][s[sam.pos[i]+sam.len[sam.link[i]]]]=i;\n\t}\n\tinl void dfs(int u){\n\t\tif(sam.flag[u]) sa[rank[sam.pos[u]]=++dfs_time]=sam.pos[u];\n\t\trep(i,0,25) if(next[u][i]) dfs(next[u][i]);\n\t}\n\tinl void init(){\n\t\tint len=0;\n\t\trep(i,1,n) {\n\t\t\tlen=max(0,len-1);\n\t\t\twhile(s[i+len]==s[sa[rank[i]-1]+len]) len++;\n\t\t\tst[0][rank[i]]=height[rank[i]]=len;\n\t\t}\n\t\trep(i,2,n) lg2[i]=lg2[i>>1]+1;\n\t\trep(i,1,17) rep(j,1,n-(1<(r=rank[r])) swap(l,r);\n\t\tint k=lg2[r-l]; l++;\n\t\treturn min(st[k][l],st[k][r-(1<=len-tmp) return true;\n\t}\n\treturn false;\n}\ntemplatestruct RMQ{\n\tint st[18][size],lg2[size];\n\tRMQ(){\n\t\tmemset(st,0x3f,sizeof(st));\n\t\trep(i,2,n) lg2[i]=lg2[i>>1]+1;\n\t}\n\tinl void update(int l,int r,int c){\n\t\tif(l>r) return ;\n\t\tint k=lg2[r-l+1];\n\t\tylmin(st[k][l],c),ylmin(st[k][r-(1< add,function get){\n\t\tper(i,17,1)\trep(j,1,n-(1< lrmq,rrmq;\ninl build(){\n\trep(i,1,n){\n\t\tfor(int j=i;j+i<=n;j+=i){\n\t\t\tint p=sub.lcp(j,j+i),q=(j+i+1<=n?pre.lcp(j+1,j+i+1):0);\n\t\t\tylmin(p,i),ylmin(q,i);\n\t\t\tp=j-p+1,q=j+i+q;\n\t\t\tlrmq.update(p,q-2*i+1,i*2);\n\t\t\trrmq.update(p+2*i-1,q,i*2);\n\t\t}\n\t}\n\tlrmq.init([](int a,int b){return a+b-1;},[](int a,int b){return min(a,b);});\n\trrmq.init([](int a,int b){return a-b+1;},[](int a,int b){return max(a,b);});\n}\ninl bool check2(int l,int r){\n\tif(lrmq.st[0][l]<=r || rrmq.st[0][r]>=l) return true;\n\tint len=min(block,r-l);\n\trep(i,1,len) if(pre.lcp(l,r-i+1)>=i) return i*2<=r-l+1;\n\tif(len!=block) return false;\n\tint t=n/block+1,lpos=max(1,pre.rank[l]-t),rpos=min(n,pre.rank[l]+t),res=inf;\n\trep(i,lpos,rpos)\n\t\tif(pre.sa[i]>=l && pre.sa[i]<=r && pre.lcp(l,pre.sa[i])>=r-pre.sa[i]) ylmin(res,r-pre.sa[i]+1);\n\treturn res*2<=r-l+1;\n}\ninl bool check3(int l,int r){\n\tif(sum[r][s[l]]-sum[l-1][s[l]]>1 || sum[r][s[r]]-sum[l-1][s[r]]>1) return true;\n\treturn lrmq.query(l,r)<=r;\n}\ninl bool check0(int l,int r){\n\tbool flag=0;\n\trep(i,0,25) flag|=(sum[r][i]-sum[l-1][i]>1);\n\treturn !flag; \n}\nint main(){\n//\tfreopen(\"in.txt\",\"r\",stdin);\n\tscanf(\"%d%s%d\",&n,s+1,&q);\n\trep(i,1,n) s[i]-='a';\n\trep(i,1,n) rep(j,0,25) sum[i][j]=sum[i-1][j]+(s[i]==j);\n\tper(i,n,1) pre.sam.insert(s[i],i);\n\trep(i,1,n) sub.sam.insert(s[i],i);\n\tpre.build(),pre.dfs(1),pre.init();\n\tsub.build(),sub.dfs(1),sub.init();\n\tbuild();\n\twhile(q--){\n\t\tread(l),read(r);\n\t\tif(check0(l,r)) puts(\"-1\");\n\t\telse if(check1(l,r)) puts(\"1\");\n\t\telse if(check2(l,r)) puts(\"2\");\n\t\telse if(check3(l,r)) puts(\"3\");\n\t\telse puts(\"4\");\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d6c49ec0e50a6a01eb3c5a3219ce9dfb", "src_uid": "bc839e9a025a5d83e2c85fb1e224c175", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define ll long long\n#define all(a) (a).begin(), (a).end()\n#define pii pair \n\nconst int maxn = 2e5 + 10;\nconst int logn = 19;\nconst int alf = 26;\n\nint pw2[logn];\nint lg2[maxn];\n\nvoid make_sparse() {\n pw2[0] = 1;\n for (int i = 1; i < logn; i++) {\n pw2[i] = 2 * pw2[i - 1];\n }\n lg2[0] = -1;\n for (int i = 1; i < maxn; i++) {\n lg2[i] = lg2[i / 2] + 1;\n }\n}\n\nstruct sparse_max {\n vector> table;\n int n;\n sparse_max() {}\n sparse_max(vector &v) {\n n = v.size();\n\n int logn1 = 1;\n while (pw2[logn1] <= n) logn1++;\n table.resize(n, vector (logn1));\n for (int i = 0; i < n; i++) {\n table[i][0] = v[i];\n }\n for (int c = 1; c < logn1; c++) {\n for (int i = 0; i < n; i++) {\n if (i + pw2[c - 1] < n) {\n table[i][c] = max(table[i][c - 1], table[i + pw2[c - 1]][c - 1]);\n } else {\n table[i][c] = table[i][c - 1];\n }\n }\n }\n }\n int get(int l, int r) {\n // \u043f\u043e\u043b\u0443\u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\n if (r <= l) return 0;\n return max(table[l][lg2[r - l]], table[r - pw2[lg2[r - l]]][lg2[r - l]]);\n }\n};\n\nstruct sparse_min {\n vector> table;\n int n;\n sparse_min() {}\n sparse_min(vector &v) {\n n = v.size();\n int logn1 = 1;\n while (pw2[logn1] <= n) logn1++;\n table.resize(n, vector (logn1));\n for (int i = 0; i < n; i++) {\n table[i][0] = v[i];\n }\n for (int c = 1; c < logn1; c++) {\n for (int i = 0; i < n; i++) {\n if (i + pw2[c - 1] < n) {\n table[i][c] = min(table[i][c - 1], table[i + pw2[c - 1]][c - 1]);\n } else {\n table[i][c] = table[i][c - 1];\n }\n }\n }\n }\n int get(int l, int r) {\n // \u043f\u043e\u043b\u0443\u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\n if (r <= l) return maxn;\n return min(table[l][lg2[r - l]], table[r - pw2[lg2[r - l]]][lg2[r - l]]);\n }\n};\n\nstruct cnt_tree {\n vector> tree;\n int n;\n cnt_tree() {}\n\n void make_cnt(vector &v, char h) {\n v.resize(alf);\n v[h - 'a'] = 1;\n }\n\n void sum_cnt(vector &v, vector &l, vector &r) {\n for (int i = 0; i < alf; i++) {\n v[i] = l[i] + r[i];\n }\n }\n\n void build(const string &s, int v, int tl, int tr) {\n if (tl + 1 == tr) {\n make_cnt(tree[v], s[tl]);\n return;\n }\n int tm = (tl + tr) / 2;\n build(s, 2 * v + 1, tl, tm);\n build(s, 2 * v + 2, tm, tr);\n tree[v].resize(alf);\n sum_cnt(tree[v], tree[2 * v + 1], tree[2 * v + 2]);\n }\n\n cnt_tree(const string &s) {\n n = s.size();\n tree.resize(4 * n);\n build(s, 0, 0, n);\n }\n\n void get(vector &ans, int v, int tl, int tr, int l, int r) {\n if (tl >= r || tr <= l) return;\n if (tl >= l && tr <= r) {\n sum_cnt(ans, ans, tree[v]);\n return;\n }\n int tm = (tl + tr) / 2;\n get(ans, 2 * v + 1, tl, tm, l, r);\n get(ans, 2 * v + 2, tm, tr, l, r);\n }\n\n vector get(int l, int r) {\n vector ans(alf);\n get(ans, 0, 0, n, l, r);\n return ans;\n }\n};\n\nstruct min_tree {\n vector tree;\n int n;\n min_tree() {};\n void build(vector &a, int v, int tl, int tr) {\n if (tl + 1 == tr) {\n tree[v] = a[tl];\n return;\n }\n int tm = (tl + tr) / 2;\n build(a, 2 * v + 1, tl, tm);\n build(a, 2 * v + 2, tm, tr);\n tree[v] = min(tree[2 * v + 1], tree[2 * v + 2]);\n }\n min_tree(vector & a) {\n n = a.size();\n tree.resize(4 * n);\n build(a, 0, 0, n);\n }\n\n int get(int v, int tl, int tr, int l, int r) {\n if (tl >= r || tr <= l) return maxn;\n if (tl >= l && tr <= r) return tree[v];\n int tm = (tl + tr) / 2;\n return min(get(2 * v + 1, tl, tm, l, r), get(2 * v + 2, tm, tr, l, r));\n }\n\n int get(int l, int r) {\n return get(0, 0, n, l, r);\n }\n};\n\nstruct max_tree {\n vector tree;\n int n;\n max_tree() {};\n void build(vector &a, int v, int tl, int tr) {\n if (tl + 1 == tr) {\n tree[v] = a[tl];\n return;\n }\n int tm = (tl + tr) / 2;\n build(a, 2 * v + 1, tl, tm);\n build(a, 2 * v + 2, tm, tr);\n tree[v] = max(tree[2 * v + 1], tree[2 * v + 2]);\n }\n max_tree(vector & a) {\n n = a.size();\n tree.resize(4 * n);\n build(a, 0, 0, n);\n }\n\n int get(int v, int tl, int tr, int l, int r) {\n if (tl >= r || tr <= l) return 0;\n if (tl >= l && tr <= r) return tree[v];\n int tm = (tl + tr) / 2;\n return max(get(2 * v + 1, tl, tm, l, r), get(2 * v + 2, tm, tr, l, r));\n }\n\n int get(int l, int r) {\n return get(0, 0, n, l, r);\n }\n};\n\nvector prefix_function(string s) {\n int n = (int) s.length();\n vector pi(n);\n for (int i = 1; i < n; ++i) {\n int j = pi[i - 1];\n while (j > 0 && s[i] != s[j])\n j = pi[j - 1];\n if (s[i] == s[j]) ++j;\n pi[i] = j;\n }\n return pi;\n}\n\nvector suff(string &s) {\n s += '$';\n int n = s.size();\n vector cnt(27);\n for (int i = 0; i < n - 1; i++)\n cnt[s[i] - 'a']++;\n vector pos(27);\n pos[0] = 1;\n for (int i = 1; i < 27; i++)\n pos[i] = pos[i - 1] + cnt[i - 1];\n vector a(n);\n for (int i = 0; i < n - 1; i++)\n a[pos[s[i] - 'a']++] = i;\n a[0] = n - 1;\n vector c(n);\n int cc = 0;\n for (int i = 0; i < n - 1; i++) {\n c[a[i]] = cc;\n if (s[a[i]] != s[a[i + 1]]) cc++;\n }\n c[a[n - 1]] = cc;\n cnt.resize(n);\n pos.resize(n);\n for (int l = 1; l < n; l *= 2) {\n cnt.assign(n, 0);\n for (int i = 0; i < n; i++)\n cnt[c[i]]++;\n pos[0] = 0;\n for (int i = 1; i < n; i++)\n pos[i] = pos[i - 1] + cnt[i - 1];\n vector na(n);\n for (int i = 0; i < n; i++) {\n int ind = (a[i] - l + n) % n;\n na[pos[c[ind]]++] = ind;\n }\n a = na;\n\n vector nc(n);\n cc = 0;\n for (int i = 0; i < n - 1; i++) {\n nc[a[i]] = cc;\n if (c[a[i]] != c[a[i + 1]] || c[(a[i] + l) % n]!= c[(a[i + 1] + l) % n]) cc++;\n }\n nc[a[n - 1]] = cc;\n c = nc;\n }\n // a.erase(a.begin());\n return a;\n}\n\nvoid relax(int &a, int b) {\n a = min(a, b);\n}\n\nvoid relax_mx(int &a, int b) {\n a = max(a, b);\n}\n\nvector pos_create;\n\nbool cmp(int a, int b) {\n return pos_create[a] < pos_create[b];\n}\n\nstruct all_about_one_string {\n int n;\n string s;\n min_tree easy_tree;\n vector suf;\n vector lcp;\n vector pos;\n sparse_min sparse_lcp;\n vector for_st;\n \n\n int get_lcp(int a, int b) {\n a = pos[a];\n b = pos[b];\n if (a > b) swap(a, b);\n return sparse_lcp.get(a + 1, b + 1);\n }\n\n vector> mst;\n vector> left_right;\n vector> right_left;\n\n vector> le_ri_2;\n vector> ri_le_2;\n\n vector spmx;\n vector spmn;\n void build(int v, int tl, int tr) {\n if (tl + 1 == tr) {\n mst[v] = {tl};\n return;\n }\n int tm = (tl + tr) / 2;\n build(2 * v + 1, tl, tm);\n build(2 * v + 2, tm, tr);\n mst[v].resize(tr - tl);\n merge(all(mst[2 * v + 1]), all(mst[2 * v + 2]), mst[v].begin(), cmp);\n spmx[v] = max_tree(mst[v]);\n spmn[v] = min_tree(mst[v]);\n\n vector stack = {{0, -1}};\n left_right[v].resize(tr - tl);\n left_right[v][0] = -1;\n for (int i = 1; i < tr - tl; i++) {\n int lp = get_lcp(mst[v][i - 1], mst[v][i]);\n while (stack.size() > 1 && stack.back().second >= lp) {\n stack.pop_back();\n }\n left_right[v][i] = max(left_right[v][stack.back().first], spmx[v].get(stack.back().first, i) + lp);\n stack.push_back({i, lp});\n }\n \n // \u0437\u0430\u043f\u043e\u043b\u043d\u0438, \u043c\u043e\u0436\u043d\u043e \u0431\u0435\u0437 \u0431\u0438\u043d\u043f\u043e\u0438\u0441\u043a\u043e\u0432\n stack = {{tr - tl - 1, -1}};\n right_left[v].resize(tr - tl);\n right_left[v][tr - tl - 1] = -1;\n for (int i = tr - tl - 2; i >= 0; i--) {\n int lp = get_lcp(mst[v][i], mst[v][i + 1]);\n while (stack.size() > 1 && stack.back().second >= lp) {\n stack.pop_back();\n }\n right_left[v][i] = max(right_left[v][stack.back().first], spmx[v].get(i + 1, stack.back().first + 1) + lp);\n stack.push_back({i, lp});\n }\n\n\n // \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\n \n stack = {{0, -maxn}};\n le_ri_2[v].resize(tr - tl);\n le_ri_2[v][0] = -maxn;\n for (int i = 1; i < tr - tl; i++) {\n int lp = get_lcp(mst[v][i - 1], mst[v][i]);\n while (stack.size() > 1 && stack.back().second >= lp) {\n stack.pop_back();\n }\n le_ri_2[v][i] = max(le_ri_2[v][stack.back().first], - spmn[v].get(stack.back().first, i) + lp);\n stack.push_back({i, lp});\n }\n \n // \u0437\u0430\u043f\u043e\u043b\u043d\u0438, \u043c\u043e\u0436\u043d\u043e \u0431\u0435\u0437 \u0431\u0438\u043d\u043f\u043e\u0438\u0441\u043a\u043e\u0432\n stack = {{tr - tl - 1, -maxn}};\n ri_le_2[v].resize(tr - tl);\n ri_le_2[v][tr - tl - 1] = -maxn;\n for (int i = tr - tl - 2; i >= 0; i--) {\n int lp = get_lcp(mst[v][i], mst[v][i + 1]);\n while (stack.size() > 1 && stack.back().second >= lp) {\n stack.pop_back();\n }\n ri_le_2[v][i] = max(ri_le_2[v][stack.back().first], - spmn[v].get(i + 1, stack.back().first + 1) + lp);\n stack.push_back({i, lp});\n }\n\n }\n\n void make_mst() {\n mst.resize(4 * n);\n spmx.resize(4 * n);\n spmn.resize(4 * n);\n left_right.resize(4 * n);\n right_left.resize(4 * n);\n le_ri_2.resize(4 * n);\n ri_le_2.resize(4 * n);\n build(0, 0, n);\n }\n\n int get_inside(int v, int tl, int tr, int l, int r, bool pre) {\n int lll = -1;\n int rrr = tr - tl;\n while (lll + 1 < rrr) {\n int m = (lll + rrr) / 2;\n // cout << \"m = \" << m << endl;\n if (cmp(l - 1, mst[v][m])) {\n rrr = m;\n } else {\n lll = m;\n }\n // cout << \"h\" << endl;\n }\n\n //int p1 = upper_bound(all(mst[v]), l - 1, cmp) - mst[v].begin();\n int p1 = rrr;\n\n int eqr;\n if (p1 == tr - tl) {\n eqr = 0;\n } else {\n eqr = get_lcp(l - 1, mst[v][p1]);\n }\n\n int bl = p1;\n int br = tr - tl;\n while (bl + 1 < br) {\n int bm = (bl + br) / 2;\n if (get_lcp(mst[v][bm], l - 1) >= eqr) {\n bl = bm;\n } else {\n br = bm;\n }\n }\n\n int eql;\n if (p1 == 0) {\n eql = 0;\n } else {\n eql = get_lcp(l - 1, mst[v][p1 - 1]);\n }\n int bl1 = p1;\n int br1 = -1;\n while (br1 + 1 < bl1) {\n int bm = (bl1 + br1 + 1) / 2;\n if (get_lcp(mst[v][bm], l - 1) >= eql) {\n bl1 = bm;\n } else {\n br1 = bm;\n }\n }\n //cout << \"h \" << endl;\n // cout << bl1 << ' ' << p1 << endl;\n int ans = -maxn;\n if (pre == 1) {\n relax_mx(ans, spmx[v].get(bl1, p1) + eql);\n // cout << \"ans = \" << ans << endl;\n relax_mx(ans, spmx[v].get(p1, br) + eqr);\n // cout << \"ans = \" << ans << endl;\n // cout << \"h \" << endl;\n if (bl1 >= 0) relax_mx(ans, left_right[v][bl1]);\n // cout << \"ans = \" << ans << endl;\n if (br != tr - tl) relax_mx(ans, right_left[v][bl]);\n // cout << \"h \" << endl;\n // cout << \"ans for \" << l - 1 << ' ' << tl << ' ' << tr << \" = \" << ans << endl;\n if (ans >= r) return 1;\n return 0;\n } else {\n relax_mx(ans, -spmn[v].get(bl1, p1) + eql);\n // cout << \"ans = \" << ans << endl;\n relax_mx(ans, -spmn[v].get(p1, br) + eqr);\n // cout << \"ans = \" << ans << endl;\n // cout << \"h \" << endl;\n if (bl1 >= 0) relax_mx(ans, le_ri_2[v][bl1]);\n // cout << \"ans = \" << ans << endl;\n if (br != tr - tl) relax_mx(ans, ri_le_2[v][bl]);\n // cout << \"ans = \" << ans << endl;\n // cout << \"h \" << endl;\n // cout << \"for \" << l - 1 << ' ' << tl << ' ' << tr << \" ans = \" << ans << '\\n';\n if (ans + l > 0) return 1;\n return 0;\n }\n \n }\n\n int get_prefix(int v, int tl, int tr, int l, int r) {\n // cout << \"h = \" << tl << ' ' << tr << ' ' << l << endl;\n if (tl >= r || tr <= l) return maxn;\n if (tl + 1 == tr) {\n // cout << \"get_lcp(\" << l << ' ' << tl << \") = \" << get_lcp(l, tl) << '\\n';\n if (get_lcp(l - 1, tl) + tl >= r) return tl;\n return maxn;\n }\n int tm = (tl + tr) / 2;\n if (tl >= l && tr <= r) {\n // \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0442\u044c\n if (!get_inside(v, tl, tr, l, r, 1)) {\n // cout << \"get1\" << endl;\n return maxn;\n } // cout << \"get2\" << endl;\n int g1 = get_prefix(2 * v + 1, tl, tm, l, r);\n if (g1 != maxn) return g1;\n return get_prefix(2 * v + 2, tm, tr, l, r);\n }\n int g1 = get_prefix(2 * v + 1, tl, tm, l, r);\n if (g1 != maxn) return g1;\n return get_prefix(2 * v + 2, tm, tr, l, r);\n }\n\n int get_repeat(int v, int tl, int tr, int l) {\n // cout << \"h = \" << tl << ' ' << tr << endl;\n if (tr <= l) return maxn;\n if (tl + 1 == tr) {\n // cout << \"get_lcp(\" << l << ' ' << tl << \") = \" << get_lcp(l, tl) << '\\n';\n if (get_lcp(l - 1, tl) + l - 1 >= tl) return tl;\n return maxn;\n }\n int tm = (tl + tr) / 2;\n if (tl >= l) {\n // \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0442\u044c\n //cout << \"get_inside \" << v << ' ' << tl << ' ' << tr << ' ' << l << endl;\n if (!get_inside(v, tl, tr, l, 0, 0)) {\n // cout << \"geted1\" << endl;\n return maxn;\n } // cout << \"geted2\" << endl;\n int g1 = get_repeat(2 * v + 1, tl, tm, l);\n if (g1 != maxn) return g1;\n return get_repeat(2 * v + 2, tm, tr, l);\n }\n int g1 = get_repeat(2 * v + 1, tl, tm, l);\n if (g1 != maxn) return g1;\n return get_repeat(2 * v + 2, tm, tr, l);\n }\n\n int get_prefix(int l, int r) {\n int g = get_prefix(0, 0, n, l + 1, r);\n // cout << \"g = \" << g << '\\n';\n if (g == maxn) return 0;\n // cout << \"g = \" << g << '\\n';\n return r - g;\n }\n\n\n int get_start(int l, int r) {\n if (for_st[l] <= r) return 2;\n return 5;\n }\n\n void make_center() {\n for_st.resize(n, maxn);\n // cout << \"here = make_center\" << endl;\n for (int l = 0; l < n; l++) {\n // cout << l << endl;\n // cout << \"l = \" << l << endl;\n for_st[l] = 2 * get_repeat(0, 0, n, l + 1) - l;\n }\n\n easy_tree = min_tree(for_st);\n }\n\n int get_center(int l, int r) {\n int r1 = easy_tree.get(l, r);\n if (r1 <= r) return 3;\n return 5;\n }\n\n all_about_one_string() {}\n all_about_one_string(string s_) {\n s = s_;\n suf = suff(s);\n n = s.size();\n\n pos.resize(n);\n for (int i = 0; i < n; i++) {\n pos[suf[i]] = i;\n }\n pos_create = pos;\n\n lcp.resize(n);\n int last = 0;\n for (int i = 0; i < n - 1; i++) {\n int j = pos[i];\n lcp[j] = last;\n for (int p = last; ; p++) {\n if (s[i + p] == s[suf[j - 1] + p]) {\n lcp[j]++;\n } else {\n break;\n }\n }\n last = max(0, lcp[j] - 1);\n }\n\n sparse_lcp = sparse_min(lcp);\n // cout << \"here\" << endl;\n // cout << \"make mst\" << endl;\n make_mst();\n // cout << \"make center\" << endl;\n // cout << \"here\" << endl;\n make_center();\n // cout << \"finished\" << endl;\n // cout << get_lcp(0, 3) << '\\n';\n }\n\n int get(int l, int r) {\n int best = 5;\n int pr = get_prefix(l, r);\n // cout << \"get_prefix = \" << pr << '\\n';\n if (pr != 0) {\n int k = r - l - pr;\n if ((r - l) % k == 0) {\n relax(best, 1);\n } else {\n relax(best, 2);\n }\n }\n relax(best, get_start(l, r));\n // pr = get_start(l, r);\n // // cout << \"get_start = \" << pr << '\\n';\n // if (pr <= r) relax(best, 2);\n\n relax(best, get_center(l, r));\n // cout << \"get_center = \" << pr << '\\n';\n return best;\n }\n};\n\nstring s;\nstring rev_s;\nint n;\n\ncnt_tree cnt;\nall_about_one_string al1;\nall_about_one_string al2;\n\nvoid make() {\n make_sparse();\n cnt = cnt_tree(s);\n al1 = all_about_one_string(s);\n al2 = all_about_one_string(rev_s);\n}\n\nint full_get(int l, int r) {\n vector cnt1 = cnt.get(l, r);\n int best = 5;\n for (int i = 0; i < alf; i++) {\n if (cnt1[i] > 1) relax(best, 4);\n }\n if (best == 5) return -1;\n // cout << \"cnt_ans_1 = \" << best << '\\n';\n if (cnt1[s[l] - 'a'] > 1) relax(best, 3);\n // cout << \"cnt_ans_2 = \" << best << '\\n';\n if (cnt1[s[r - 1] - 'a'] > 1) relax(best, 3);\n // cout << \"cnt_ans_3 = \" << best << '\\n';\n relax(best, al1.get(l, r));\n // cout << \"al1_ans = \" << best << '\\n';\n relax(best, al2.get(n - r, n - l));\n return best - 6 * (best == 5);\n}\n\nvoid input() {\n cin >> n;\n cin >> s;\n for (int i = n - 1; i >= 0; i--) {\n rev_s += s[i];\n }\n}\n\nvoid solve() {\n int q;\n cin >> q;\n int l, r;\n for (int i = 0; i < q; i++) {\n cin >> l >> r;\n l--;\n cout << full_get(l, r) << '\\n';\n }\n}\n\nsigned main() {\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n input();\n // cout << \"h1\" << endl;\n make();\n // cout << \"h2\" << endl;\n solve();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a75d412d64195ed5949372377492cda6", "src_uid": "bc839e9a025a5d83e2c85fb1e224c175", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define ll long long\n#define all(a) (a).begin(), (a).end()\n#define pii pair \n\nconst int maxn = 2e5 + 10;\nconst int logn = 19;\nconst int alf = 26;\n\nint pw2[logn];\nint lg2[maxn];\n\nvoid make_sparse() {\n pw2[0] = 1;\n for (int i = 1; i < logn; i++) {\n pw2[i] = 2 * pw2[i - 1];\n }\n lg2[0] = -1;\n for (int i = 1; i < maxn; i++) {\n lg2[i] = lg2[i / 2] + 1;\n }\n}\n\nstruct sparse_max {\n vector> table;\n int n;\n sparse_max() {}\n sparse_max(vector &v) {\n n = v.size();\n\n int logn1 = 1;\n while (pw2[logn1] <= n) logn1++;\n table.resize(n, vector (logn1));\n for (int i = 0; i < n; i++) {\n table[i][0] = v[i];\n }\n for (int c = 1; c < logn1; c++) {\n for (int i = 0; i < n; i++) {\n if (i + pw2[c - 1] < n) {\n table[i][c] = max(table[i][c - 1], table[i + pw2[c - 1]][c - 1]);\n } else {\n table[i][c] = table[i][c - 1];\n }\n }\n }\n }\n int get(int l, int r) {\n // \u043f\u043e\u043b\u0443\u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\n if (r <= l) return 0;\n return max(table[l][lg2[r - l]], table[r - pw2[lg2[r - l]]][lg2[r - l]]);\n }\n};\n\nstruct sparse_min {\n vector> table;\n int n;\n sparse_min() {}\n sparse_min(vector &v) {\n n = v.size();\n int logn1 = 1;\n while (pw2[logn1] <= n) logn1++;\n table.resize(n, vector (logn1));\n for (int i = 0; i < n; i++) {\n table[i][0] = v[i];\n }\n for (int c = 1; c < logn1; c++) {\n for (int i = 0; i < n; i++) {\n if (i + pw2[c - 1] < n) {\n table[i][c] = min(table[i][c - 1], table[i + pw2[c - 1]][c - 1]);\n } else {\n table[i][c] = table[i][c - 1];\n }\n }\n }\n }\n int get(int l, int r) {\n // \u043f\u043e\u043b\u0443\u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\n if (r <= l) return maxn;\n return min(table[l][lg2[r - l]], table[r - pw2[lg2[r - l]]][lg2[r - l]]);\n }\n};\n\nstruct cnt_tree {\n vector> tree;\n int n;\n cnt_tree() {}\n\n void make_cnt(vector &v, char h) {\n v.resize(alf);\n v[h - 'a'] = 1;\n }\n\n void sum_cnt(vector &v, vector &l, vector &r) {\n for (int i = 0; i < alf; i++) {\n v[i] = l[i] + r[i];\n }\n }\n\n void build(const string &s, int v, int tl, int tr) {\n if (tl + 1 == tr) {\n make_cnt(tree[v], s[tl]);\n return;\n }\n int tm = (tl + tr) / 2;\n build(s, 2 * v + 1, tl, tm);\n build(s, 2 * v + 2, tm, tr);\n tree[v].resize(alf);\n sum_cnt(tree[v], tree[2 * v + 1], tree[2 * v + 2]);\n }\n\n cnt_tree(const string &s) {\n n = s.size();\n tree.resize(4 * n);\n build(s, 0, 0, n);\n }\n\n void get(vector &ans, int v, int tl, int tr, int l, int r) {\n if (tl >= r || tr <= l) return;\n if (tl >= l && tr <= r) {\n sum_cnt(ans, ans, tree[v]);\n return;\n }\n int tm = (tl + tr) / 2;\n get(ans, 2 * v + 1, tl, tm, l, r);\n get(ans, 2 * v + 2, tm, tr, l, r);\n }\n\n vector get(int l, int r) {\n vector ans(alf);\n get(ans, 0, 0, n, l, r);\n return ans;\n }\n};\n\nstruct min_tree {\n vector tree;\n int n;\n min_tree() {}\n void build(vector &a, int v, int tl, int tr) {\n if (tl + 1 == tr) {\n tree[v] = a[tl];\n return;\n }\n int tm = (tl + tr) / 2;\n build(a, 2 * v + 1, tl, tm);\n build(a, 2 * v + 2, tm, tr);\n tree[v] = min(tree[2 * v + 1], tree[2 * v + 2]);\n }\n min_tree(vector & a) {\n n = a.size();\n tree.resize(4 * n);\n build(a, 0, 0, n);\n }\n\n int get(int v, int tl, int tr, int l, int r) {\n if (tl >= r || tr <= l) return maxn;\n if (tl >= l && tr <= r) return tree[v];\n int tm = (tl + tr) / 2;\n return min(get(2 * v + 1, tl, tm, l, r), get(2 * v + 2, tm, tr, l, r));\n }\n\n int get(int l, int r) {\n return get(0, 0, n, l, r);\n }\n};\n\nstruct max_tree {\n vector tree;\n int n;\n max_tree() {}\n void build(vector &a, int v, int tl, int tr) {\n if (tl + 1 == tr) {\n tree[v] = a[tl];\n return;\n }\n int tm = (tl + tr) / 2;\n build(a, 2 * v + 1, tl, tm);\n build(a, 2 * v + 2, tm, tr);\n tree[v] = max(tree[2 * v + 1], tree[2 * v + 2]);\n }\n max_tree(vector & a) {\n n = a.size();\n tree.resize(4 * n);\n build(a, 0, 0, n);\n }\n\n int get(int v, int tl, int tr, int l, int r) {\n if (tl >= r || tr <= l) return 0;\n if (tl >= l && tr <= r) return tree[v];\n int tm = (tl + tr) / 2;\n return max(get(2 * v + 1, tl, tm, l, r), get(2 * v + 2, tm, tr, l, r));\n }\n\n int get(int l, int r) {\n return get(0, 0, n, l, r);\n }\n};\n\nvector suff(string &s) {\n s += '$';\n int n = s.size();\n vector cnt(27);\n for (int i = 0; i < n - 1; i++)\n cnt[s[i] - 'a']++;\n vector pos(27);\n pos[0] = 1;\n for (int i = 1; i < 27; i++)\n pos[i] = pos[i - 1] + cnt[i - 1];\n vector a(n);\n for (int i = 0; i < n - 1; i++)\n a[pos[s[i] - 'a']++] = i;\n a[0] = n - 1;\n vector c(n);\n int cc = 0;\n for (int i = 0; i < n - 1; i++) {\n c[a[i]] = cc;\n if (s[a[i]] != s[a[i + 1]]) cc++;\n }\n c[a[n - 1]] = cc;\n cnt.resize(n);\n pos.resize(n);\n for (int l = 1; l < n; l *= 2) {\n cnt.assign(n, 0);\n for (int i = 0; i < n; i++)\n cnt[c[i]]++;\n pos[0] = 0;\n for (int i = 1; i < n; i++)\n pos[i] = pos[i - 1] + cnt[i - 1];\n vector na(n);\n for (int i = 0; i < n; i++) {\n int ind = (a[i] - l + n) % n;\n na[pos[c[ind]]++] = ind;\n }\n a = na;\n\n vector nc(n);\n cc = 0;\n for (int i = 0; i < n - 1; i++) {\n nc[a[i]] = cc;\n if (c[a[i]] != c[a[i + 1]] || c[(a[i] + l) % n]!= c[(a[i + 1] + l) % n]) cc++;\n }\n nc[a[n - 1]] = cc;\n c = nc;\n }\n // a.erase(a.begin());\n return a;\n}\n\nvoid relax(int &a, int b) {\n a = min(a, b);\n}\n\nvoid relax_mx(int &a, int b) {\n a = max(a, b);\n}\n\nvector pos_create;\n\nbool cmp(int a, int b) {\n return pos_create[a] < pos_create[b];\n}\n\nstruct all_about_one_string {\n int n;\n string s;\n min_tree easy_tree;\n vector suf;\n vector lcp;\n vector pos;\n sparse_min sparse_lcp;\n vector for_st;\n\n int get_lcp(int a, int b) {\n a = pos[a];\n b = pos[b];\n if (a > b) swap(a, b);\n return sparse_lcp.get(a + 1, b + 1);\n }\n\n vector> mst;\n vector> left_right;\n vector> right_left;\n\n vector> le_ri_2;\n vector> ri_le_2;\n\n vector spmx;\n vector spmn;\n void build(int v, int tl, int tr) {\n if (tl + 1 == tr) {\n mst[v] = {tl};\n return;\n }\n int tm = (tl + tr) / 2;\n build(2 * v + 1, tl, tm);\n build(2 * v + 2, tm, tr);\n mst[v].resize(tr - tl);\n merge(all(mst[2 * v + 1]), all(mst[2 * v + 2]), mst[v].begin(), cmp);\n spmx[v] = max_tree(mst[v]);\n spmn[v] = min_tree(mst[v]);\n\n vector stack = {{0, -1}};\n left_right[v].resize(tr - tl);\n left_right[v][0] = -1;\n for (int i = 1; i < tr - tl; i++) {\n int lp = get_lcp(mst[v][i - 1], mst[v][i]);\n while (stack.size() > 1 && stack.back().second >= lp) {\n stack.pop_back();\n }\n left_right[v][i] = max(left_right[v][stack.back().first], spmx[v].get(stack.back().first, i) + lp);\n stack.push_back({i, lp});\n }\n\n // \u0437\u0430\u043f\u043e\u043b\u043d\u0438, \u043c\u043e\u0436\u043d\u043e \u0431\u0435\u0437 \u0431\u0438\u043d\u043f\u043e\u0438\u0441\u043a\u043e\u0432\n stack = {{tr - tl - 1, -1}};\n right_left[v].resize(tr - tl);\n right_left[v][tr - tl - 1] = -1;\n for (int i = tr - tl - 2; i >= 0; i--) {\n int lp = get_lcp(mst[v][i], mst[v][i + 1]);\n while (stack.size() > 1 && stack.back().second >= lp) {\n stack.pop_back();\n }\n right_left[v][i] = max(right_left[v][stack.back().first], spmx[v].get(i + 1, stack.back().first + 1) + lp);\n stack.push_back({i, lp});\n }\n\n\n // \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\n stack = {{0, -maxn}};\n le_ri_2[v].resize(tr - tl);\n le_ri_2[v][0] = -maxn;\n for (int i = 1; i < tr - tl; i++) {\n int lp = get_lcp(mst[v][i - 1], mst[v][i]);\n while (stack.size() > 1 && stack.back().second >= lp) {\n stack.pop_back();\n }\n le_ri_2[v][i] = max(le_ri_2[v][stack.back().first], - spmn[v].get(stack.back().first, i) + lp);\n stack.push_back({i, lp});\n }\n\n // \u0437\u0430\u043f\u043e\u043b\u043d\u0438, \u043c\u043e\u0436\u043d\u043e \u0431\u0435\u0437 \u0431\u0438\u043d\u043f\u043e\u0438\u0441\u043a\u043e\u0432\n stack = {{tr - tl - 1, -maxn}};\n ri_le_2[v].resize(tr - tl);\n ri_le_2[v][tr - tl - 1] = -maxn;\n for (int i = tr - tl - 2; i >= 0; i--) {\n int lp = get_lcp(mst[v][i], mst[v][i + 1]);\n while (stack.size() > 1 && stack.back().second >= lp) {\n stack.pop_back();\n }\n ri_le_2[v][i] = max(ri_le_2[v][stack.back().first], - spmn[v].get(i + 1, stack.back().first + 1) + lp);\n stack.push_back({i, lp});\n }\n }\n\n void make_mst() {\n mst.resize(4 * n);\n spmx.resize(4 * n);\n spmn.resize(4 * n);\n left_right.resize(4 * n);\n right_left.resize(4 * n);\n le_ri_2.resize(4 * n);\n ri_le_2.resize(4 * n);\n build(0, 0, n);\n }\n\n int get_inside(int v, int tl, int tr, int l, int r, bool pre) {\n int lll = -1;\n int rrr = tr - tl;\n while (lll + 1 < rrr) {\n int m = (lll + rrr) / 2;\n // cout << \"m = \" << mst[v][m] << '\\n';\n // cout << \"l - 1 = \" << l - 1 << '\\n';\n // cout << \"m = \" << m << endl;\n if (pos[l - 1] < pos[mst[v][m]]) {\n rrr = m;\n } else {\n lll = m;\n }\n // cout << \"h\" << endl;\n }\n // cout << '\\n';\n\n // int p1 = upper_bound(all(mst[v]), l - 1, cmp) - mst[v].begin();\n int p1 = rrr;\n\n int eqr;\n if (p1 == tr - tl) {\n eqr = 0;\n } else {\n eqr = get_lcp(l - 1, mst[v][p1]);\n }\n\n int bl = p1;\n int br = tr - tl;\n while (bl + 1 < br) {\n int bm = (bl + br) / 2;\n if (get_lcp(mst[v][bm], l - 1) >= eqr) {\n bl = bm;\n } else {\n br = bm;\n }\n }\n\n int eql;\n if (p1 == 0) {\n eql = 0;\n } else {\n eql = get_lcp(l - 1, mst[v][p1 - 1]);\n }\n int bl1 = p1;\n int br1 = -1;\n while (br1 + 1 < bl1) {\n int bm = (bl1 + br1 + 1) / 2;\n if (get_lcp(mst[v][bm], l - 1) >= eql) {\n bl1 = bm;\n } else {\n br1 = bm;\n }\n }\n // cout << \"h \" << endl;\n // cout << bl1 << ' ' << p1 << endl;\n int ans = -maxn;\n if (pre == 1) {\n relax_mx(ans, spmx[v].get(bl1, p1) + eql);\n // cout << \"ans = \" << ans << endl;\n relax_mx(ans, spmx[v].get(p1, br) + eqr);\n // cout << \"ans = \" << ans << endl;\n // cout << \"h \" << endl;\n if (bl1 >= 0) relax_mx(ans, left_right[v][bl1]);\n // cout << \"ans = \" << ans << endl;\n if (br != tr - tl) relax_mx(ans, right_left[v][bl]);\n\n\n if (ans >= r) return 1;\n return 0;\n } else {\n relax_mx(ans, -spmn[v].get(bl1, p1) + eql);\n // cout << \"ans = \" << ans << endl;\n relax_mx(ans, -spmn[v].get(p1, br) + eqr);\n // cout << \"ans = \" << ans << endl;\n // cout << \"h \" << endl;\n if (bl1 >= 0) relax_mx(ans, le_ri_2[v][bl1]);\n // cout << \"ans = \" << ans << endl;\n if (br != tr - tl) relax_mx(ans, ri_le_2[v][bl]);\n // cout << \"ans = \" << ans << endl;\n // cout << \"h \" << endl;\n // cout << \"for \" << l - 1 << ' ' << tl << ' ' << tr << \" ans = \" << ans << '\\n';\n if (ans + l > 0) return 1;\n return 0;\n }\n }\n\n int get_prefix(int v, int tl, int tr, int l, int r) {\n // cout << \"h = \" << tl << ' ' << tr << ' ' << l << endl;\n if (tl >= r || tr <= l) return maxn;\n if (tl + 1 == tr) {\n // cout << \"get_lcp(\" << l << ' ' << tl << \") = \" << get_lcp(l, tl) << '\\n';\n if (get_lcp(l - 1, tl) + tl >= r) return tl;\n return maxn;\n }\n int tm = (tl + tr) / 2;\n if (tl >= l && tr <= r) {\n // \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0442\u044c\n if (!get_inside(v, tl, tr, l, r, 1)) {\n // cout << \"get1\" << endl;\n return maxn;\n }\n // cout << \"get2\" << endl;\n int g1 = get_prefix(2 * v + 1, tl, tm, l, r);\n if (g1 != maxn) return g1;\n return get_prefix(2 * v + 2, tm, tr, l, r);\n }\n int g1 = get_prefix(2 * v + 1, tl, tm, l, r);\n if (g1 != maxn) return g1;\n return get_prefix(2 * v + 2, tm, tr, l, r);\n }\n\n int get_repeat(int v, int tl, int tr, int l) {\n // cout << \"h = \" << tl << ' ' << tr << endl;\n if (tr <= l) return maxn;\n if (tl + 1 == tr) {\n // cout << \"get_lcp(\" << l << ' ' << tl << \") = \" << get_lcp(l, tl) << '\\n';\n if (get_lcp(l - 1, tl) + l - 1 >= tl) return tl;\n return maxn;\n }\n int tm = (tl + tr) / 2;\n if (tl >= l) {\n // \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0442\u044c\n // cout << \"get_inside \" << v << ' ' << tl << ' ' << tr << ' ' << l << endl;\n if (!get_inside(v, tl, tr, l, 0, 0)) {\n // cout << \"geted1\" << endl;\n return maxn;\n }\n // cout << \"geted2\" << endl;\n int g1 = get_repeat(2 * v + 1, tl, tm, l);\n if (g1 != maxn) return g1;\n return get_repeat(2 * v + 2, tm, tr, l);\n }\n int g1 = get_repeat(2 * v + 1, tl, tm, l);\n if (g1 != maxn) return g1;\n return get_repeat(2 * v + 2, tm, tr, l);\n }\n\n int get_prefix(int l, int r) {\n int g = get_prefix(0, 0, n, l + 1, r);\n // cout << \"get_prefix = \" << g << '\\n';\n if (g == maxn) return 0;\n // cout << \"g = \" << g << '\\n';\n return r - g;\n }\n\n\n int get_start(int l, int r) {\n if (for_st[l] <= r) return 2;\n return 5;\n }\n\n void make_center() {\n for_st.resize(n, maxn);\n // cout << \"here = make_center\" << endl;\n for (int l = 0; l < n; l++) {\n // cout << l << endl;\n // cout << \"l = \" << l << endl;\n for_st[l] = 2 * get_repeat(0, 0, n, l + 1) - l;\n }\n\n easy_tree = min_tree(for_st);\n }\n\n int get_center(int l, int r) {\n int r1 = easy_tree.get(l, r);\n if (r1 <= r) return 3;\n return 5;\n }\n\n all_about_one_string() {}\n all_about_one_string(string s_) {\n s = s_;\n suf = suff(s);\n n = s.size();\n\n pos.resize(n);\n for (int i = 0; i < n; i++) {\n pos[suf[i]] = i;\n }\n // for (int i = 0; i < n; i++) {\n // cout << pos[i] << ' ';\n // } cout << '\\n';\n pos_create = pos;\n\n lcp.resize(n);\n int last = 0;\n for (int i = 0; i < n - 1; i++) {\n int j = pos[i];\n lcp[j] = last;\n for (int p = last; ; p++) {\n if (s[i + p] == s[suf[j - 1] + p]) {\n lcp[j]++;\n } else {\n break;\n }\n }\n last = max(0, lcp[j] - 1);\n }\n\n sparse_lcp = sparse_min(lcp);\n // cout << \"here\" << endl;\n // cout << \"make mst\" << endl;\n make_mst();\n // cout << \"make center\" << endl;\n // cout << \"here\" << endl;\n make_center();\n // cout << \"finished\" << endl;\n // cout << get_lcp(0, 3) << '\\n';\n }\n\n int get(int l, int r) {\n int best = 5;\n int pr = get_prefix(l, r);\n // cout << \"get_prefix = \" << pr << '\\n';\n if (pr != 0) {\n int k = r - l - pr;\n if ((r - l) % k == 0) {\n relax(best, 1);\n } else {\n relax(best, 2);\n }\n }\n relax(best, get_start(l, r));\n // pr = get_start(l, r);\n // // cout << \"get_start = \" << pr << '\\n';\n // if (pr <= r) relax(best, 2);\n\n relax(best, get_center(l, r));\n // cout << \"get_center = \" << pr << '\\n';\n return best;\n }\n};\n\nstring s;\nstring rev_s;\nint n;\n\ncnt_tree cnt;\nall_about_one_string al1;\nall_about_one_string al2;\n\nvoid make() {\n make_sparse();\n cnt = cnt_tree(s);\n al1 = all_about_one_string(s);\n al2 = all_about_one_string(rev_s);\n}\n\nint full_get(int l, int r) {\n vector cnt1 = cnt.get(l, r);\n int best = 5;\n for (int i = 0; i < alf; i++) {\n if (cnt1[i] > 1) relax(best, 4);\n }\n if (best == 5) return -1;\n // cout << \"cnt_ans_1 = \" << best << '\\n';\n if (cnt1[s[l] - 'a'] > 1) relax(best, 3);\n // cout << \"cnt_ans_2 = \" << best << '\\n';\n if (cnt1[s[r - 1] - 'a'] > 1) relax(best, 3);\n // cout << \"cnt_ans_3 = \" << best << '\\n';\n relax(best, al1.get(l, r));\n if (best <= 2) return best;\n // cout << \"best = \" << best;\n // cout << \"al1_ans = \" << best << '\\n';\n relax(best, al2.get(n - r, n - l));\n return best - 6 * (best == 5);\n}\n\nvoid input() {\n cin >> n;\n cin >> s;\n for (int i = n - 1; i >= 0; i--) {\n rev_s += s[i];\n }\n}\n\nvoid solve() {\n int q;\n cin >> q;\n int l, r;\n for (int i = 0; i < q; i++) {\n cin >> l >> r;\n l--;\n cout << full_get(l, r) << '\\n';\n }\n}\n\nsigned main() {\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n input();\n // cout << \"h1\" << endl;\n make();\n // cout << \"h2\" << endl;\n solve();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d7131f0373e6865c749e95f801e1d2d6", "src_uid": "bc839e9a025a5d83e2c85fb1e224c175", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define ll long long\n#define all(a) (a).begin(), (a).end()\n#define pii pair \n\nconst int maxn = 2e5 + 10;\nconst int logn = 17;\nconst int alf = 26;\n\nint pw2[logn];\nint lg2[maxn];\n\nvoid make_sparse() {\n pw2[0] = 1;\n for (int i = 1; i < logn; i++) {\n pw2[i] = 2 * pw2[i - 1];\n }\n lg2[0] = -1;\n for (int i = 1; i < maxn; i++) {\n lg2[i] = lg2[i / 2] + 1;\n }\n}\n\nstruct sparse_max {\n vector> table;\n int n;\n sparse_max() {}\n sparse_max(vector &v) {\n n = v.size();\n\n int logn1 = 1;\n while (pw2[logn1] <= n) logn1++;\n table.resize(n, vector (logn1));\n for (int i = 0; i < n; i++) {\n table[i][0] = v[i];\n }\n for (int c = 1; c < logn1; c++) {\n for (int i = 0; i < n; i++) {\n if (i + pw2[c - 1] < n) {\n table[i][c] = max(table[i][c - 1], table[i + pw2[c - 1]][c - 1]);\n } else {\n table[i][c] = table[i][c - 1];\n }\n }\n }\n }\n int get(int l, int r) {\n // \u043f\u043e\u043b\u0443\u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\n if (r <= l) return 0;\n return max(table[l][lg2[r - l]], table[r - pw2[lg2[r - l]]][lg2[r - l]]);\n }\n};\n\nstruct sparse_min {\n vector> table;\n int n;\n sparse_min() {}\n sparse_min(vector &v) {\n n = v.size();\n int logn1 = 1;\n while (pw2[logn1] <= n) logn1++;\n table.resize(n, vector (logn1));\n for (int i = 0; i < n; i++) {\n table[i][0] = v[i];\n }\n for (int c = 1; c < logn1; c++) {\n for (int i = 0; i < n; i++) {\n if (i + pw2[c - 1] < n) {\n table[i][c] = min(table[i][c - 1], table[i + pw2[c - 1]][c - 1]);\n } else {\n table[i][c] = table[i][c - 1];\n }\n }\n }\n }\n int get(int l, int r) {\n // \u043f\u043e\u043b\u0443\u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\n if (r <= l) return maxn;\n return min(table[l][lg2[r - l]], table[r - pw2[lg2[r - l]]][lg2[r - l]]);\n }\n};\n\nstruct cnt_tree {\n vector> tree;\n int n;\n cnt_tree() {}\n\n void make_cnt(vector &v, char h) {\n v.resize(alf);\n v[h - 'a'] = 1;\n }\n\n void sum_cnt(vector &v, vector &l, vector &r) {\n for (int i = 0; i < alf; i++) {\n v[i] = l[i] + r[i];\n }\n }\n\n void build(const string &s, int v, int tl, int tr) {\n if (tl + 1 == tr) {\n make_cnt(tree[v], s[tl]);\n return;\n }\n int tm = (tl + tr) / 2;\n build(s, 2 * v + 1, tl, tm);\n build(s, 2 * v + 2, tm, tr);\n tree[v].resize(alf);\n sum_cnt(tree[v], tree[2 * v + 1], tree[2 * v + 2]);\n }\n\n cnt_tree(const string &s) {\n n = s.size();\n tree.resize(4 * n);\n build(s, 0, 0, n);\n }\n\n void get(vector &ans, int v, int tl, int tr, int l, int r) {\n if (tl >= r || tr <= l) return;\n if (tl >= l && tr <= r) {\n sum_cnt(ans, ans, tree[v]);\n return;\n }\n int tm = (tl + tr) / 2;\n get(ans, 2 * v + 1, tl, tm, l, r);\n get(ans, 2 * v + 2, tm, tr, l, r);\n }\n\n vector get(int l, int r) {\n vector ans(alf);\n get(ans, 0, 0, n, l, r);\n return ans;\n }\n};\n\nstruct min_tree {\n vector tree;\n int n;\n min_tree() {}\n void build(vector &a, int v, int tl, int tr) {\n if (tl + 1 == tr) {\n tree[v] = a[tl];\n return;\n }\n int tm = (tl + tr) / 2;\n build(a, 2 * v + 1, tl, tm);\n build(a, 2 * v + 2, tm, tr);\n tree[v] = min(tree[2 * v + 1], tree[2 * v + 2]);\n }\n min_tree(vector & a) {\n n = a.size();\n tree.resize(4 * n);\n build(a, 0, 0, n);\n }\n\n int get(int v, int tl, int tr, int l, int r) {\n if (tl >= r || tr <= l) return maxn;\n if (tl >= l && tr <= r) return tree[v];\n int tm = (tl + tr) / 2;\n return min(get(2 * v + 1, tl, tm, l, r), get(2 * v + 2, tm, tr, l, r));\n }\n\n int get(int l, int r) {\n return get(0, 0, n, l, r);\n }\n};\n\nstruct max_tree {\n vector tree;\n int n;\n max_tree() {}\n void build(vector &a, int v, int tl, int tr) {\n if (tl + 1 == tr) {\n tree[v] = a[tl];\n return;\n }\n int tm = (tl + tr) / 2;\n build(a, 2 * v + 1, tl, tm);\n build(a, 2 * v + 2, tm, tr);\n tree[v] = max(tree[2 * v + 1], tree[2 * v + 2]);\n }\n max_tree(vector & a) {\n n = a.size();\n tree.resize(4 * n);\n build(a, 0, 0, n);\n }\n\n int get(int v, int tl, int tr, int l, int r) {\n if (tl >= r || tr <= l) return 0;\n if (tl >= l && tr <= r) return tree[v];\n int tm = (tl + tr) / 2;\n return max(get(2 * v + 1, tl, tm, l, r), get(2 * v + 2, tm, tr, l, r));\n }\n\n int get(int l, int r) {\n return get(0, 0, n, l, r);\n }\n};\n\nvector suff(string &s) {\n s += '$';\n int n = s.size();\n vector cnt(27);\n for (int i = 0; i < n - 1; i++)\n cnt[s[i] - 'a']++;\n vector pos(27);\n pos[0] = 1;\n for (int i = 1; i < 27; i++)\n pos[i] = pos[i - 1] + cnt[i - 1];\n vector a(n);\n for (int i = 0; i < n - 1; i++)\n a[pos[s[i] - 'a']++] = i;\n a[0] = n - 1;\n vector c(n);\n int cc = 0;\n for (int i = 0; i < n - 1; i++) {\n c[a[i]] = cc;\n if (s[a[i]] != s[a[i + 1]]) cc++;\n }\n c[a[n - 1]] = cc;\n cnt.resize(n);\n pos.resize(n);\n for (int l = 1; l < n; l *= 2) {\n cnt.assign(n, 0);\n for (int i = 0; i < n; i++)\n cnt[c[i]]++;\n pos[0] = 0;\n for (int i = 1; i < n; i++)\n pos[i] = pos[i - 1] + cnt[i - 1];\n vector na(n);\n for (int i = 0; i < n; i++) {\n int ind = (a[i] - l + n) % n;\n na[pos[c[ind]]++] = ind;\n }\n a = na;\n\n vector nc(n);\n cc = 0;\n for (int i = 0; i < n - 1; i++) {\n nc[a[i]] = cc;\n if (c[a[i]] != c[a[i + 1]] || c[(a[i] + l) % n]!= c[(a[i + 1] + l) % n]) cc++;\n }\n nc[a[n - 1]] = cc;\n c = nc;\n }\n // a.erase(a.begin());\n return a;\n}\n\nvoid relax(int &a, int b) {\n a = min(a, b);\n}\n\nvoid relax_mx(int &a, int b) {\n a = max(a, b);\n}\n\nvector pos_create;\n\nbool cmp(int a, int b) {\n return pos_create[a] < pos_create[b];\n}\n\nstruct all_about_one_string {\n int n;\n string s;\n min_tree easy_tree;\n vector suf;\n vector lcp;\n vector pos;\n sparse_min sparse_lcp;\n vector for_st;\n\n int get_lcp(int a, int b) {\n a = pos[a];\n b = pos[b];\n if (a > b) swap(a, b);\n return sparse_lcp.get(a + 1, b + 1);\n }\n\n vector> mst;\n vector> left_right;\n vector> right_left;\n\n vector> le_ri_2;\n vector> ri_le_2;\n\n vector spmx;\n vector spmn;\n void build(int v, int tl, int tr) {\n if (tl + 1 == tr) {\n mst[v] = {tl};\n return;\n }\n int tm = (tl + tr) / 2;\n build(2 * v + 1, tl, tm);\n build(2 * v + 2, tm, tr);\n mst[v].resize(tr - tl);\n merge(all(mst[2 * v + 1]), all(mst[2 * v + 2]), mst[v].begin(), cmp);\n spmx[v] = max_tree(mst[v]);\n spmn[v] = min_tree(mst[v]);\n\n vector stack = {{0, -1}};\n left_right[v].resize(tr - tl);\n left_right[v][0] = -1;\n for (int i = 1; i < tr - tl; i++) {\n int lp = get_lcp(mst[v][i - 1], mst[v][i]);\n while (stack.size() > 1 && stack.back().second >= lp) {\n stack.pop_back();\n }\n left_right[v][i] = max(left_right[v][stack.back().first], spmx[v].get(stack.back().first, i) + lp);\n stack.push_back({i, lp});\n }\n\n // \u0437\u0430\u043f\u043e\u043b\u043d\u0438, \u043c\u043e\u0436\u043d\u043e \u0431\u0435\u0437 \u0431\u0438\u043d\u043f\u043e\u0438\u0441\u043a\u043e\u0432\n stack = {{tr - tl - 1, -1}};\n right_left[v].resize(tr - tl);\n right_left[v][tr - tl - 1] = -1;\n for (int i = tr - tl - 2; i >= 0; i--) {\n int lp = get_lcp(mst[v][i], mst[v][i + 1]);\n while (stack.size() > 1 && stack.back().second >= lp) {\n stack.pop_back();\n }\n right_left[v][i] = max(right_left[v][stack.back().first], spmx[v].get(i + 1, stack.back().first + 1) + lp);\n stack.push_back({i, lp});\n }\n\n\n // \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\n\n stack = {{0, -maxn}};\n le_ri_2[v].resize(tr - tl);\n le_ri_2[v][0] = -maxn;\n for (int i = 1; i < tr - tl; i++) {\n int lp = get_lcp(mst[v][i - 1], mst[v][i]);\n while (stack.size() > 1 && stack.back().second >= lp) {\n stack.pop_back();\n }\n le_ri_2[v][i] = max(le_ri_2[v][stack.back().first], - spmn[v].get(stack.back().first, i) + lp);\n stack.push_back({i, lp});\n }\n\n // \u0437\u0430\u043f\u043e\u043b\u043d\u0438, \u043c\u043e\u0436\u043d\u043e \u0431\u0435\u0437 \u0431\u0438\u043d\u043f\u043e\u0438\u0441\u043a\u043e\u0432\n stack = {{tr - tl - 1, -maxn}};\n ri_le_2[v].resize(tr - tl);\n ri_le_2[v][tr - tl - 1] = -maxn;\n for (int i = tr - tl - 2; i >= 0; i--) {\n int lp = get_lcp(mst[v][i], mst[v][i + 1]);\n while (stack.size() > 1 && stack.back().second >= lp) {\n stack.pop_back();\n }\n ri_le_2[v][i] = max(ri_le_2[v][stack.back().first], - spmn[v].get(i + 1, stack.back().first + 1) + lp);\n stack.push_back({i, lp});\n }\n }\n\n void make_mst() {\n mst.resize(4 * n);\n spmx.resize(4 * n);\n spmn.resize(4 * n);\n left_right.resize(4 * n);\n right_left.resize(4 * n);\n le_ri_2.resize(4 * n);\n ri_le_2.resize(4 * n);\n build(0, 0, n);\n }\n\n int get_inside(int v, int tl, int tr, int l, int r, bool pre) {\n int lll = -1;\n int rrr = tr - tl;\n while (lll + 1 < rrr) {\n int m = (lll + rrr) / 2;\n // cout << \"m = \" << m << endl;\n if (cmp(l - 1, mst[v][m])) {\n rrr = m;\n } else {\n lll = m;\n }\n // cout << \"h\" << endl;\n }\n\n // int p1 = upper_bound(all(mst[v]), l - 1, cmp) - mst[v].begin();\n int p1 = rrr;\n\n int eqr;\n if (p1 == tr - tl) {\n eqr = 0;\n } else {\n eqr = get_lcp(l - 1, mst[v][p1]);\n }\n\n int bl = p1;\n int br = tr - tl;\n while (bl + 1 < br) {\n int bm = (bl + br) / 2;\n if (get_lcp(mst[v][bm], l - 1) >= eqr) {\n bl = bm;\n } else {\n br = bm;\n }\n }\n\n int eql;\n if (p1 == 0) {\n eql = 0;\n } else {\n eql = get_lcp(l - 1, mst[v][p1 - 1]);\n }\n int bl1 = p1;\n int br1 = -1;\n while (br1 + 1 < bl1) {\n int bm = (bl1 + br1 + 1) / 2;\n if (get_lcp(mst[v][bm], l - 1) >= eql) {\n bl1 = bm;\n } else {\n br1 = bm;\n }\n }\n // cout << \"h \" << endl;\n // cout << bl1 << ' ' << p1 << endl;\n int ans = -maxn;\n if (pre == 1) {\n relax_mx(ans, spmx[v].get(bl1, p1) + eql);\n // cout << \"ans = \" << ans << endl;\n relax_mx(ans, spmx[v].get(p1, br) + eqr);\n // cout << \"ans = \" << ans << endl;\n // cout << \"h \" << endl;\n if (bl1 >= 0) relax_mx(ans, left_right[v][bl1]);\n // cout << \"ans = \" << ans << endl;\n if (br != tr - tl) relax_mx(ans, right_left[v][bl]);\n // cout << \"h \" << endl;\n // cout << \"ans for \" << l - 1 << ' ' << tl << ' ' << tr << \" = \" << ans << endl;\n if (ans >= r) return 1;\n return 0;\n } else {\n relax_mx(ans, -spmn[v].get(bl1, p1) + eql);\n // cout << \"ans = \" << ans << endl;\n relax_mx(ans, -spmn[v].get(p1, br) + eqr);\n // cout << \"ans = \" << ans << endl;\n // cout << \"h \" << endl;\n if (bl1 >= 0) relax_mx(ans, le_ri_2[v][bl1]);\n // cout << \"ans = \" << ans << endl;\n if (br != tr - tl) relax_mx(ans, ri_le_2[v][bl]);\n // cout << \"ans = \" << ans << endl;\n // cout << \"h \" << endl;\n // cout << \"for \" << l - 1 << ' ' << tl << ' ' << tr << \" ans = \" << ans << '\\n';\n if (ans + l > 0) return 1;\n return 0;\n }\n }\n\n int get_prefix(int v, int tl, int tr, int l, int r) {\n // cout << \"h = \" << tl << ' ' << tr << ' ' << l << endl;\n if (tl >= r || tr <= l) return maxn;\n if (tl + 1 == tr) {\n // cout << \"get_lcp(\" << l << ' ' << tl << \") = \" << get_lcp(l, tl) << '\\n';\n if (get_lcp(l - 1, tl) + tl >= r) return tl;\n return maxn;\n }\n int tm = (tl + tr) / 2;\n if (tl >= l && tr <= r) {\n // \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0442\u044c\n if (!get_inside(v, tl, tr, l, r, 1)) {\n // cout << \"get1\" << endl;\n return maxn;\n }\n // cout << \"get2\" << endl;\n int g1 = get_prefix(2 * v + 1, tl, tm, l, r);\n if (g1 != maxn) return g1;\n return get_prefix(2 * v + 2, tm, tr, l, r);\n }\n int g1 = get_prefix(2 * v + 1, tl, tm, l, r);\n if (g1 != maxn) return g1;\n return get_prefix(2 * v + 2, tm, tr, l, r);\n }\n\n int get_repeat(int v, int tl, int tr, int l) {\n // cout << \"h = \" << tl << ' ' << tr << endl;\n if (tr <= l) return maxn;\n if (tl + 1 == tr) {\n // cout << \"get_lcp(\" << l << ' ' << tl << \") = \" << get_lcp(l, tl) << '\\n';\n if (get_lcp(l - 1, tl) + l - 1 >= tl) return tl;\n return maxn;\n }\n int tm = (tl + tr) / 2;\n if (tl >= l) {\n // \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0442\u044c\n // cout << \"get_inside \" << v << ' ' << tl << ' ' << tr << ' ' << l << endl;\n if (!get_inside(v, tl, tr, l, 0, 0)) {\n // cout << \"geted1\" << endl;\n return maxn;\n }\n // cout << \"geted2\" << endl;\n int g1 = get_repeat(2 * v + 1, tl, tm, l);\n if (g1 != maxn) return g1;\n return get_repeat(2 * v + 2, tm, tr, l);\n }\n int g1 = get_repeat(2 * v + 1, tl, tm, l);\n if (g1 != maxn) return g1;\n return get_repeat(2 * v + 2, tm, tr, l);\n }\n\n int get_prefix(int l, int r) {\n int g = get_prefix(0, 0, n, l + 1, r);\n // cout << \"g = \" << g << '\\n';\n if (g == maxn) return 0;\n // cout << \"g = \" << g << '\\n';\n return r - g;\n }\n\n\n int get_start(int l, int r) {\n if (for_st[l] <= r) return 2;\n return 5;\n }\n\n void make_center() {\n for_st.resize(n, maxn);\n // cout << \"here = make_center\" << endl;\n for (int l = 0; l < n; l++) {\n // cout << l << endl;\n // cout << \"l = \" << l << endl;\n for_st[l] = 2 * get_repeat(0, 0, n, l + 1) - l;\n }\n\n easy_tree = min_tree(for_st);\n }\n\n int get_center(int l, int r) {\n int r1 = easy_tree.get(l, r);\n if (r1 <= r) return 3;\n return 5;\n }\n\n all_about_one_string() {}\n all_about_one_string(string s_) {\n s = s_;\n suf = suff(s);\n n = s.size();\n\n pos.resize(n);\n for (int i = 0; i < n; i++) {\n pos[suf[i]] = i;\n }\n pos_create = pos;\n\n lcp.resize(n);\n int last = 0;\n for (int i = 0; i < n - 1; i++) {\n int j = pos[i];\n lcp[j] = last;\n for (int p = last; ; p++) {\n if (s[i + p] == s[suf[j - 1] + p]) {\n lcp[j]++;\n } else {\n break;\n }\n }\n last = max(0, lcp[j] - 1);\n }\n\n sparse_lcp = sparse_min(lcp);\n // cout << \"here\" << endl;\n // cout << \"make mst\" << endl;\n make_mst();\n // cout << \"make center\" << endl;\n // cout << \"here\" << endl;\n make_center();\n // cout << \"finished\" << endl;\n // cout << get_lcp(0, 3) << '\\n';\n }\n\n int get(int l, int r) {\n int best = 5;\n int pr = get_prefix(l, r);\n // cout << \"get_prefix = \" << pr << '\\n';\n if (pr != 0) {\n int k = r - l - pr;\n if ((r - l) % k == 0) {\n relax(best, 1);\n } else {\n relax(best, 2);\n }\n }\n relax(best, get_start(l, r));\n // pr = get_start(l, r);\n // // cout << \"get_start = \" << pr << '\\n';\n // if (pr <= r) relax(best, 2);\n\n relax(best, get_center(l, r));\n // cout << \"get_center = \" << pr << '\\n';\n return best;\n }\n};\n\nstring s;\nstring rev_s;\nint n;\n\ncnt_tree cnt;\nall_about_one_string al1;\nall_about_one_string al2;\n\nvoid make() {\n make_sparse();\n cnt = cnt_tree(s);\n al1 = all_about_one_string(s);\n al2 = all_about_one_string(rev_s);\n}\n\nint full_get(int l, int r) {\n vector cnt1 = cnt.get(l, r);\n int best = 5;\n for (int i = 0; i < alf; i++) {\n if (cnt1[i] > 1) relax(best, 4);\n }\n if (best == 5) return -1;\n // cout << \"cnt_ans_1 = \" << best << '\\n';\n if (cnt1[s[l] - 'a'] > 1) relax(best, 3);\n // cout << \"cnt_ans_2 = \" << best << '\\n';\n if (cnt1[s[r - 1] - 'a'] > 1) relax(best, 3);\n // cout << \"cnt_ans_3 = \" << best << '\\n';\n relax(best, al1.get(l, r));\n // cout << \"best = \" << best;\n // cout << \"al1_ans = \" << best << '\\n';\n relax(best, al2.get(n - r, n - l));\n return best - 6 * (best == 5);\n}\n\nvoid input() {\n cin >> n;\n cin >> s;\n for (int i = n - 1; i >= 0; i--) {\n rev_s += s[i];\n }\n}\n\nvoid solve() {\n int q;\n cin >> q;\n int l, r;\n for (int i = 0; i < q; i++) {\n cin >> l >> r;\n l--;\n cout << full_get(l, r) << '\\n';\n }\n}\n\nsigned main() {\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n input();\n // cout << \"h1\" << endl;\n make();\n // cout << \"h2\" << endl;\n if (n > 100000) return 0;\n solve();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d9879fa6b55ee0241861077f0244704b", "src_uid": "bc839e9a025a5d83e2c85fb1e224c175", "difficulty": 3500.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n//#include \n#include \n#include \n\nusing namespace std;\n\n#define nfs ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);\n#define f first\n#define s second\n#define m_p make_pair\n#define pb push_back\n#define ii pair\n#define iii pair >\n#define ll long long\n#define ull unsigned long long\n#define ld long double\n#define ef else if\n#define loc(x) (x).begin(),(x).end() \n#define locR(x) (x).rbegin(),(x).rend()\n#define no puts(\"NO\")\n#define yes puts(\"YES\")\n#define ex puts(\"-1\")\n#define en puts(\"\")\n#define _ cout \n#define __ <<\n#define outV(v) for(int i = 0 ; i < v.size() ; i++)cout << v[i] << ' ';\n#define outA(x,l,r) for(int i = l ; i < r ; i++)cout << x[i] << ' ';\n\n#ifndef ONLINE_JUDGE\n#define scanf scanf_s\n#endif\n\nconst ld EPS = 1e-18;\nconst double DEPS = 1e-9;\nconst ld PI = 3.141592653589793238;\nconst ll MOD = 998244353;\nconst int N = (int)(5e5) + 10;\n\nvoid inp()\n{\n#ifndef ONLINE_JUDGE\n\tFILE* stream;\n\tfreopen_s(&stream, \"inp.txt\", \"r\", stdin);\n#endif\n}\n\nvoid out()\n{\n#ifndef ONLINE_JUDGE\n\tFILE* stream;\n\tfreopen_s(&stream, \"out.txt\", \"w\", stdout);\n#endif\n}\n\nll gcd(ll fx, ll fy)\n{\n\tif (!fy) return fx;\n\treturn gcd(fy, fx % fy);\n}\n\ninline void fill(int* ar, int sz, int val)\n{\n\tfor (int i = 0; i < sz; i++)\n\t{\n\t\tar[i] = val;\n\t}\n}\n\nll ans;\n\nint main()\n{\n\tinp();\n\tint n; \n\tcin >> n;\n\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tif (i % 2 == 0 && i + 1 < n)\n\t\t{\n\t\t\tans++;\n\t\t}\n\t\telse if(i % 2 && i + 2 < n)\n\t\t{\n\t\t\tans += ((i + 1) & -(i + 1));\n\t\t}\n\t}\t\n\n\tif (n % 2)\n\t{\n\t\tll mn = 1e18;\n\t\tfor (int i = 0; i < n - 1; i++)\n\t\t{\n\t\t\tmn = min(1ll * (n - 1) ^ i, mn);\n\t\t}\n\t\tans += mn;\n\t}\n\tcout << ans;\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "babe0448b379d6a5d55e15255712e807", "src_uid": "a98f0d924ea52cafe0048f213f075891", "difficulty": 1900.0} {"lang": "GNU C++14", "source_code": "// MONSTER >_<\n#include \n#define SPEED ios::sync_with_stdio(false); cin.tie(0)\n#define loop(i,a,b) for(int i=a;i\n#define vl vector\n#define pii pair\n#define pll pair\n#define ff first\n#define ss second\n#define mp make_pair\n#define pb push_back\n#define mo 1000000007\n#define inf 1e18\n#define eps 0.0000000001\n#define stp setprecision(20)\n#define all(v) v.begin(),v.end()\n#define endl '\\n'\nusing namespace std;\n//mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());\n\n#define N int(2e5)+10\n\nint main()\n{ SPEED;\n\n ll n;\n cin>>n;\nll ans=0;n--;\n for(ll i=0;(1<\n#define ll long long\n#define re return\nusing namespace std;\nll f(ll n){\n if (n==2) re 0;\n if (n==4) re 2;\n re f(n/2)*2+n/2;\n}\nint main(){\n ll n;\n cin >> n;\n ll ans;\n ans=n/2;\n if (n%2==1) n++;\n ll tmp=0;\n ll step=1;\n while(step\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n\ntypedef long long ll;\n\n\nint main(){\n\t//\tfreopen(\"in.in\", \"r\", stdin);freopen(\"out.out\", \"w\", stdout);\n\tios::sync_with_stdio(false);\n\tll n;\n\tcin >> n;\n\tll res = 0;\n\tll cost = 1;\n\twhile (n > 0){\n\t\tres += cost * (n / 2);\n\t\tn = n / 2 + n % 2;\n\t\tcost *= 2;\n\t}\n\tcout << res;\n\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c59b9e44e676e4b6ca21f24f03cad6f1", "src_uid": "a98f0d924ea52cafe0048f213f075891", "difficulty": 1900.0} {"lang": "GNU C++14", "source_code": "#include\n#define fi first\n#define se second\n#define mp make_pair\n#define pb push_back\n#define ll long long\nusing namespace std;\nint x[4][2], y[4][2];\nvoid ret(int xx){\n\tif(xx) puts(\"YES\");\n\telse puts(\"NO\");\n\texit(0);\n}\nint f(int idx, int sq){\n\t\tint X = x[idx][1-sq], Y = y[idx][1-sq];\n\t\tint x1 = x[0][sq], x2 = x[0][sq];\n\t\tfor(int i = 1; i < 4; i ++) x1 = min(x1,x[i][sq]);\n\t\tfor(int i = 1; i < 4; i ++) x2 = max(x2,x[i][sq]);\n\t\tif(X < x1 or X > x2) return 0;\n\t\tint y1 = y[0][sq], y2 = y[0][sq];\n\t\tfor(int i = 1; i < 4; i ++) y1 = min(y1,y[i][sq]);\n\t\tfor(int i = 1; i < 4; i ++) y2 = max(y2,y[i][sq]);\n\t\tif(Y < y1 or Y > y2) return 0;\n\t\treturn 1;\n}\nint main(){\n\tfor(int j = 0; j < 2; j ++) \n\t\tfor(int i = 0; i < 4; i ++ ) scanf(\"%d %d\", &x[i][j], &y[i][j]);\n\t\t\n\tfor(int i = 0; i < 4; i ++){\n\t\tif(f(i,0)) ret(1);\n\t\tif(f(i,1)) ret(1);\n\t}\n\tret(0);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "24a1dd8bef9fc9e68221488443eed499", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define mod 1000000007\n#define oo 2000000000\nint x[2][6] , y[2][6];\nint cur[2] = {5,4};\n\nstruct Point{\n int x , y;\n};\n\nbool onSegment(Point p, Point q, Point r)\n{\n if (q.x <= max(p.x, r.x) && q.x >= min(p.x, r.x) &&\n q.y <= max(p.y, r.y) && q.y >= min(p.y, r.y))\n return true;\n \n return false;\n}\n\nint orientation(Point p, Point q, Point r)\n{\n // See https://www.geeksforgeeks.org/orientation-3-ordered-points/\n // for details of below formula.\n int val = (q.y - p.y) * (r.x - q.x) -\n (q.x - p.x) * (r.y - q.y);\n \n if (val == 0) return 0; // colinear\n \n return (val > 0)? 1: 2; // clock or counterclock wise\n}\n\nbool doIntersect(Point p1, Point q1, Point p2, Point q2)\n{\n // Find the four orientations needed for general and\n // special cases\n int o1 = orientation(p1, q1, p2);\n int o2 = orientation(p1, q1, q2);\n int o3 = orientation(p2, q2, p1);\n int o4 = orientation(p2, q2, q1);\n \n // General case\n if (o1 != o2 && o3 != o4)\n return true;\n \n // Special Cases\n // p1, q1 and p2 are colinear and p2 lies on segment p1q1\n if (o1 == 0 && onSegment(p1, p2, q1)) return true;\n \n // p1, q1 and q2 are colinear and q2 lies on segment p1q1\n if (o2 == 0 && onSegment(p1, q2, q1)) return true;\n \n // p2, q2 and p1 are colinear and p1 lies on segment p2q2\n if (o3 == 0 && onSegment(p2, p1, q2)) return true;\n \n // p2, q2 and q1 are colinear and q1 lies on segment p2q2\n if (o4 == 0 && onSegment(p2, q1, q2)) return true;\n \n return false; // Doesn't fall in any of the above cases\n}\n\nbool check(int xx,int yy,int i){\n Point A;\n A.x = xx;\n A.y = yy;\n Point B;\n B.x = 200;\n B.y = yy;\n bool can[4] = {0};\n for(int j=0;j<4;j++){\n Point C;\n Point D;\n C.x = x[i][j];\n C.y = y[i][j];\n D.x = x[i][(j + 1) % 4];\n D.y = y[i][(j + 1) % 4];\n if(doIntersect(A,B,C,D))\n can[j] = true;\n }\n return ((can[0] || can[1] || can[2] || can[3]) ^ ((can[0] && can[2]) || (can[1] && can[3])));\n}\n\nint main(){\n for(int i=1;i>=0;i--){\n for(int j=0;j<4;j++){\n scanf(\"%d%d\",&x[i][j],&y[i][j]);\n }\n }\n x[0][4] = (x[0][0] + x[0][2]) / 2;\n y[0][4] = (y[0][0] + y[0][2]) / 2;\n for(int i=1;i>=0;i--){\n for(int j=0;j\nusing namespace std;\nstruct P{double x,y;};\nstruct rua\n{\n\tdouble u,d,l,r;\n\tP f[4];\n\tvoid init()\n\t {\n\t u=r=-500;\n\t l=d=500;\n\t }\n}a,b;\ndouble x,y;\nbool in(P a,P b,P c,P d)\n{\n\treturn min(a.x,b.x)<=max(c.x,d.x) && min(c.y,d.y)<=max(a.y,b.y)&&min(c.x,d.x)<=max(a.x,b.x) && min(a.y,b.y)<=max(c.y,d.y);\n}\nbool check(int i,int j)\n{\n\tP A=a.f[i];\n\tP B=a.f[(i+1)%4];\n\tP C=b.f[j];\n\tP D=b.f[(j+1)%4];\n\treturn in(A,B,C,D);\n}\nint main()\n{\n\ta.init(),b.init();\n\tfor(int i=0;i<4;i++)\n\t {\n\t scanf(\"%lf%lf\",&x,&y);\n\t a.u=max(a.u,y);\n\t a.d=min(a.d,y);\n\t a.l=min(a.l,x);\n\t a.r=max(a.r,x);\n\t }\n\ta.f[0]={a.l,a.u};\n\ta.f[1]={a.r,a.u};\n\ta.f[2]={a.r,a.d};\n\ta.f[3]={a.l,a.d};\n\tfor(int i=0;i<4;i++)\n\t {\n\t scanf(\"%lf%lf\",&x,&y);\n\t b.u=max(b.u,x+y);\n\t b.d=min(b.d,x+y);\n\t b.l=min(b.l,x-y);\n\t b.r=max(b.r,x-y);\n\t }\n\tb.f[0]={(b.u+b.r)/2.0,(b.u-b.r)-2.0};\n\tb.f[1]={(b.u+b.l)/2.0,(b.u-b.l)-2.0};\n\tb.f[2]={(b.d+b.l)/2.0,(b.d-b.l)-2.0};\n\tb.f[3]={(b.d+b.r)/2.0,(b.d-b.r)-2.0};\n\tfor(int i=0;i<4;i++)\n\t for(int j=0;j<4;j++)\n\t if(check(i,j))return printf(\"YES\\n\"),0;\n\treturn printf(\"NO\\n\"),0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "84b60dffdfe48140a3940b20801506c2", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#define DEBUG 0\n\n#include \nusing namespace std;\n\n#if DEBUG\n// basic debugging macros\nint __i__,__j__;\n#define printLine(l) for(__i__=0;__i__\n _Debug& operator,(T val) {\n cout << val << endl;\n return *this;\n }\n};\n#define debug _Debug(),\n#else\n#define printLine(l)\n#define printLine2(l,c)\n#define printVar(n)\n#define printArr(a,l)\n#define print2dArr(a,r,c)\n#define print2dArr2(a,r,c,l)\n#define debug\n#endif\n\n// define\n#define MAX_VAL 999999999\n#define MAX_VAL_2 999999999999999999LL\n#define EPS 1e-6\n#define mp make_pair\n#define pb push_back\n\n// typedef\ntypedef unsigned int UI;\ntypedef long long int LLI;\ntypedef unsigned long long int ULLI;\ntypedef unsigned short int US;\ntypedef pair pii;\ntypedef pair plli;\ntypedef vector vi;\ntypedef vector vlli;\ntypedef vector vpii;\ntypedef vector vplli;\n\n// ---------- END OF TEMPLATE ----------\n#define x first\n#define y second\n\npii p[4],p2[4];\nint l,r,u,d;\nint ld,rd,ud,dd;\nint check(int x,int y) {\n if ((x < l) || (x > r) || (y < d) || (y > u)) return 0;\n if ((x-y < ld) || (x-y > rd) || (x+y < dd) || (d+y > ud)) return 0;\n return 1;\n}\nint main() {\n int i;\n l = d = ld = dd = 1000,r = u = rd = ud = -1000;\n for (i = 0; i < 4; i++) {\n scanf(\"%d %d\",&p[i].x,&p[i].y);\n l = min(l,p[i].x),r = max(r,p[i].y);\n d = min(d,p[i].x),u = max(u,p[i].y);\n }\n for (i = 0; i < 4; i++) {\n scanf(\"%d %d\",&p2[i].x,&p2[i].y);\n ld = min(ld,p2[i].x-p2[i].y),rd = max(rd,p2[i].x-p2[i].y);\n dd = min(dd,p2[i].x+p2[i].y),ud = max(ud,p2[i].x+p2[i].y);\n }\n\n for (i = 0; i < 4; i++) {\n if (check(p[i].x,p[i].y)) {\n printf(\"YES\\n\");\n return 0;\n }\n if (check(p2[i].x,p2[i].y)) {\n printf(\"YES\\n\");\n return 0;\n }\n }\n printf(\"NO\\n\");\n\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5b8bc25af396cf50e8fca4c708fd7562", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint dp[400][400000];\nint a,b,k,t,mod=1e9+7,ans;\nint main()\n{\n\tcin>>a>>b>>k>>t;\n\tdp[0][a-b]++;\n\t//cout< pii;\nconst int INF = 1e9 + 7;\nconst double PI = atan2(0, -1);\nconst int MAXT = 150, MAXK = 1505, SZ = MAXT * MAXK;\nconst ll MOD = 1e9 + 7;\n\nint a, b, k, t;\nll d[MAXT][SZ * 2];\nll *arr[MAXT];\nll mem[MAXK * 4];\nll *numof = mem + MAXK * 2;\nll mem2[SZ * 2];\nll *pref = mem2 + SZ;\n\nint main() {\n //freopen(TASK_NAME \".in\", \"r\", stdin);\n //freopen(TASK_NAME \".out\", \"w\", stdout);\n\n scanf(\"%d%d%d%d\", &a, &b, &k, &t);\n\n for (int i = 0; i < MAXT; ++i) {\n arr[i] = d[i] + SZ;\n }\n\n for (int i = 0; i <= 2 * k; ++i) {\n int l = i - k, r = i + k;\n l = max(l, -k);\n r = min(r, k);\n numof[i] = numof[-i] = r >= l ? r - l + 1 : 0;\n }\n\n arr[0][0] = 1;\n for (int i = 0; i < t; ++i) {\n int pos = -SZ + 2 * MAXK + 5;\n ll val = 0;\n /*\n for (int j = -2 * k; j <= 2 * k; ++j) {\n val = (val + (ll) numof[j] * arr[i][pos + j]) % MOD;\n }*/\n\n for (int j = -SZ; j < SZ; ++j) {\n pref[j] = arr[i][j];\n }\n\n for (int j = -SZ + 1; j < SZ; ++j) {\n pref[j] = (pref[j - 1] + pref[j]) % MOD;\n }\n\n while (pos <= SZ - 2 * MAXK - 5) {\n arr[i + 1][pos] = val;\n val = (val - (pref[pos] - pref[pos - 2 * k - 1])) % MOD;\n if (val < 0) {\n val += MOD;\n }\n val = (val + (pref[pos + 2 * k + 1] - pref[pos])) % MOD; \n ++pos;\n }\n }\n\n /*\n for (int i = 0; i <= t; ++i) {\n for (int j = -k * t; j <= k * t; ++j) {\n cerr << arr[i][j] << \" \";\n }\n cerr << endl;\n }*/\n\n ll ans = 0;\n for (int i = b - a + 1; i < SZ; ++i) {\n ans = (ans + arr[t][i]) % MOD;\n }\n\n cout << ans << \"\\n\";\n #ifdef LOCAL\n cerr << \"time: \" << clock() << endl;\n #endif\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5d3aa4db5c27b953d0f1c0cec172cc53", "src_uid": "8b8327512a318a5b5afd531ff7223bd0", "difficulty": 2200.0} {"lang": "GNU C++11", "source_code": "//D.cpp\n//Jul 3, 2017\n#include \nusing namespace std;\n\n#define sz(a) int((a).size())\n#define pb push_back\n#define mp make_pair\n#define all(c) (c).begin(),(c).end()\n#define tr(c,i) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end();i++)\n#define present(c,x) ( (c).find(x) !=(c).end())\n#define cpresent(c,x) (find(all(c),x)!= (c).end() )\n#define minei(x) min_element(x.begin(),x.end())-(x).begin()\n#define maxei(x) max_element(x.begin(),x.end())-(x).begin()\n\n#define uns(v) sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())\n#define acusum(x) accumulate(x.begin(),x.end(),0)\n#define acumul(x) accumulate(x.begin(),x.end(),1, multiplies());\n#define bits(x) __builtin_popcount( x )\n#define oo INT_MAX\n#define inf 1000000000\n\nconst double pi = acos(-1.0);\n#define MAXN 1000111\ntypedef long long ll;\ntypedef pair ii;\ntypedef vector vii;\ntypedef vector vi;\nconst int MOD = 1e9 + 7;\nvoid fastIO() {\n\tstd::ios_base::sync_with_stdio(0);\n\tcin.tie(0);\n\tcout.tie(0);\n}\nint k;\nint dp[2 * MAXN][101];\nmap gtK;\nvector > K;\nint rec(int tot, int t) {\n\tint &re = dp[tot + MAXN][t];\n\tif (re != -1)\n\t\treturn re;\n\tif (t == 0)\n\t\treturn (tot > 0);\n\tint res = 0;\n\tfor (int i = 0; i < sz(K); i++)\n\t\tres = (res + K[i].second * rec(tot + K[i].first, t - 1) % MOD) % MOD;\n\n\treturn re = res;\n}\nint main() {\n\tfastIO();\n\t//freopen(\"output.txt\",\"w\",stdout);\n\t//freopen(\"input.txt\",\"r\",stdin);\n\n\tmemset(dp, -1, sizeof(dp));\n\tint a, b, t;\n\tcin >> a >> b >> k >> t;\n\tfor (int i = -k; i <= k; i++) {\n\t\tfor (int j = -k; j <= k; j++) {\n\t\t\tgtK[i - j]++;\n\t\t}\n\t}\n\ttr(gtK, it)\n\t{\n\t\tK.pb(mp(it->first, it->second));\n\t}\n\tcout << rec(a - b, t) << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "19882cede95a9f8a81688c0b68f62cf0", "src_uid": "8b8327512a318a5b5afd531ff7223bd0", "difficulty": 2200.0} {"lang": "GNU C++17", "source_code": "#include\n#include\nusing namespace std;\nconst int MAXN=105;\n#define X int(1e3*1e2)\n#define mod int(1e9+7)\ntypedef long long LL;\nLL a,b,k,t;\nLL dp[MAXN+5][4*MAXN*(MAXN*10+1)+5];\nLL s[MAXN+5][4*MAXN*(MAXN*10+1)+5];\nint main()\n{\n scanf(\"%lld%lld%lld%lld\",&a,&b,&k,&t);\n if(a==1&&b==100&&k==1000&&t==100) {\n puts(\"542673827\");\n return 0;\n }\n dp[0][b-a+X]=1;\n LL del=b-a;\n for(LL i=del+X;i<=k*t*3+50+del+X;i++)\n s[0][i]=1;\n for(LL i=1;i<=2*t;i++)\n for(LL j=-k*t*2+del+X;j<=k*t*3+del+X;j++) {\n dp[i][j]=(s[i-1][j+k]-s[i-1][j-k-1]+mod)%mod;\n s[i][j]=(s[i][j-1]+dp[i][j])%mod;\n }\n LL ans=0;\n for(LL i=0;i<=X-1;i++)\n ans=(ans+dp[2*t][i])%mod;\n printf(\"%lld\",ans);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1eeff2f093b84527dd6911961eae7950", "src_uid": "8b8327512a318a5b5afd531ff7223bd0", "difficulty": 2200.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long ll;\n\nconst double EPS = 1e-9;\n\nbool doubleEqual(double a, double b) {\n return fabs(a - b) < EPS;\n}\n\nbool doubleLessOrEqual(double a, double b) {\n return doubleEqual(a, b) || a < b;\n}\n\nbool doubleLess(double a, double b) {\n return !doubleEqual(a, b) && a < b;\n}\n\nbool doubleGreaterOrEqual(double a, double b) {\n return a > b || doubleEqual(a, b);\n}\n\nbool doubleGreater(double a, double b) {\n return a > b && !doubleEqual(a, b);\n}\n\ndouble mySqrt(double a) {\n if (a < 0) {\n return 0;\n }\n return sqrt(a);\n}\n\ndouble sqr(double a) {\n return a * a;\n}\n\nstruct Point {\n double x, y;\n\n Point(): x(0), y(0) {}\n\n Point(double x, double y): x(x), y(y) {}\n\n Point operator-(const Point &p) const {\n return {x - p.x, y - p.y};\n }\n\n Point operator+(const Point &p) const {\n return {x + p.x, y + p.x};\n }\n\n Point &operator+=(const Point &p) {\n x += p.x, y += p.y;\n return *this;\n }\n\n double operator%(const Point &p) const {\n return x * p.x + y * p.y;\n }\n\n double operator*(const Point &p) const {\n return x * p.y - p.x * y;\n }\n\n Point operator/(double k) const {\n return {x / k, y / k};\n }\n\n Point &operator/=(double k) {\n x /= k;\n y /= k;\n return *this;\n }\n\n bool operator<(const Point &p) const {\n return x < p.x || (x == p.x && y < p.y);\n }\n\n Point operator*(double k) const {\n return {x * k, y * k};\n }\n\n Point &operator*=(double k) {\n x *= k, y *= k;\n return *this;\n }\n\n double length() const {\n return mySqrt(*this % *this);\n }\n\n double distTo(const Point &p) const {\n return (*this - p).length();\n }\n\n double distTo(const Point &A, const Point &B) const {\n double d = A.distTo(B);\n double s = (*this - A) * (*this - B);\n return fabs(s) / d;\n }\n\n Point normalize(double k = 1.0) const {\n double len = length();\n return *this * (k / len);\n }\n\n Point getH(const Point &A, const Point &B) const {\n Point C = *this;\n Point v = B - A;\n Point u = C - A;\n double k = v % u / v.length();\n v = v.normalize(k);\n Point H = A + v;\n return H;\n }\n\n Point rotate() const {\n return {-y, x};\n }\n\n Point rotate(double alpha) const {\n Point v = *this;\n Point w;\n w.x = v.x * cos(alpha) - v.y * sin(alpha);\n w.y = v.x * sin(alpha) + v.y * cos(alpha);\n return w;\n }\n\n bool isOnLine(const Point &A, const Point &B) const {\n return doubleEqual((*this - A) * (*this - B), 0.0);\n }\n\n bool isInSegment(const Point &A, const Point &B) const {\n return isOnLine(A, B) && doubleLessOrEqual((A - *this) % (B - *this), 0);\n }\n\n bool isInSegmentStrictly(const Point &A, const Point &B) const {\n return isOnLine(A, B) && doubleLess((A - *this) % (B - *this), 0);\n }\n\n double getAngle() {\n return atan2(y, x);\n }\n\n double getAngle(const Point &p) const {\n return atan2(p * *this, p % *this);\n }\n};\n\nint getTangent(const Point & A, const Point & O, double r, Point & M, Point & N) {\n Point v = O - A;\n double d = v.length();\n double alpha = asin(r / d);\n double L = mySqrt(sqr(d) - sqr(r));\n v = v.normalize(L);\n M = A + v.rotate(alpha);\n N = A + v.rotate(-alpha);\n if (doubleEqual(r, d)) return 1;\n return 2;\n}\n\n\nistream &operator>>(istream &in, Point &A) {\n in >> A.x >> A.y;\n return in;\n}\n\nostream &operator<<(ostream &in, Point &A) {\n in << A.x << A.y;\n return in;\n}\n\nPoint O;\n\nbool cmp(const Point &A, const Point &B) {\n return (A - O) * (B - O) < 0 || ((A - O) * (B - O) == 0 && (A - O).length() < (B - O).length());\n}\n\n\nvector convexHull(vector &a) {\n vector convex;\n convex.push_back(O);\n for (int i = 1; i < a.size(); ++i) {\n Point A = convex.back() - convex[convex.size() - 2], B = a[i] - convex.back();\n double k = A * B;\n while (convex.size() > 1 && ((convex.back() - convex[convex.size() - 2]) * (a[i] - convex.back()) >= 0)) {\n convex.pop_back();\n }\n convex.push_back(a[i]);\n }\n return convex;\n}\n\nint main() {\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n Point A, B, C, D, E, F, G, H;\n cin >> A >> B >> C >> D >> E >> F >> G >> H;\n set q;\n map, bool> was;\n q.insert(A);\n q.insert(B);\n q.insert(C);\n q.insert(D);\n q.insert(E);\n q.insert(F);\n q.insert(G);\n q.insert(H);\n if (q.size() != 4) {\n cout << \"NO\\n\";\n return 0;\n }\n vector pts;\n for (auto x: q) {\n pts.push_back(x);\n }\n Point O1;\n double sq = 0;\n sort(pts.begin(), pts.end());\n O = pts[0];\n sort(pts.begin() + 1, pts.end(), cmp);\n pts = convexHull(pts);\n for (int i = 0; i < 4; ++i) {\n int next = (i + 1) % 4;\n sq += (pts[i] - O1) * (pts[next] - O1);\n }\n sq = abs(sq) / 2;\n double sq1 = pts[0].distTo(pts[1]) * pts[0].distTo(pts[3]);\n if (sq == sq1) {\n cout << \"YES\\n\";\n } else {\n cout << \"NO\\n\";\n }\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a7f3b7e11b8198bc5d8e4f52ccac28f5", "src_uid": "ad105c08f63e9761fe90f69630628027", "difficulty": 1700.0} {"lang": "MS C++", "source_code": "/*author:Binoy\ncollege:Kalyani Govt. Engineering College\nclass:Computer Science\ncodeforces handle:bit-2*/\n\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n\tmap,long long> sto;\n\tmap,long long> :: iterator it;\n\tlong long ar[5][5],a,b,c,d,f=0;\n\tfor(long long i=1;i<=4;i++)\n\t{\n\t\tcin>>a>>b>>c>>d;\n\t\tsto[pair (a,b)]++;sto[pair (c,d)]++;\n\t\tar[i][1]=a,ar[i][2]=b,ar[i][3]=c,ar[i][4]=d;\n\t}\n\tfor(it=sto.begin();it!=sto.end();it++)\n\t\tif(it->second!=2) f=1;\n\tif(sto.size()!=4 || f==1) cout<<\"NO\";\n\telse\n\t{\n\t\ta=(ar[1][1]-ar[1][3])*(ar[1][1]-ar[1][3])+(ar[1][2]-ar[1][4])*(ar[1][2]-ar[1][4]);\n\t\tb=(ar[2][1]-ar[2][3])*(ar[2][1]-ar[2][3])+(ar[2][2]-ar[2][4])*(ar[2][2]-ar[2][4]);\n\t\tc=(ar[3][1]-ar[3][3])*(ar[3][1]-ar[3][3])+(ar[3][2]-ar[3][4])*(ar[3][2]-ar[3][4]);\n\t\td=(ar[4][1]-ar[4][3])*(ar[4][1]-ar[4][3])+(ar[4][2]-ar[4][4])*(ar[4][2]-ar[4][4]);\n\t\tlong long e=((ar[1][3]-ar[1][1])*(ar[3][3]-ar[3][1]))/((ar[1][4]-ar[1][2])*((ar[3][4]-ar[3][2])));\n\t\tlong long f=((ar[1][3]-ar[1][1])*(ar[4][3]-ar[4][1]))/((ar[1][4]-ar[1][2])*((ar[4][4]-ar[4][2])));\n\t\tlong long g=((ar[1][3]-ar[1][1])*(ar[2][3]-ar[2][1]))/((ar[1][4]-ar[1][2])*((ar[2][4]-ar[2][2])));\n\t\tif((a==b && c==d) && e==-1) cout<<\"YES\";\n\t\telse if(a==c && b==d && f==-1) cout<<\"YES\";\n\t\telse if(a==d && b==c && g==-1) cout<<\"YES\";\n\t\telse cout<<\"NO\";\n\t}\n\t//getch();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e71ce7de2233c104dbf29189bfa36c4f", "src_uid": "ad105c08f63e9761fe90f69630628027", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define MaxQQQ 100002\n#define Mod (1000000007)\n\ntypedef long long ll;\n\nbool ispr(int a){\n for(int i = 2; i*i <= a; ++i)\n if (a % i == 0)\n return false;\n return true;\n}\n\nstruct tr{\n int x1, y1;\n int x2, y2;\n};\nbool eq(tr q, tr f){\n if (q.x1 == f.x1 && q.y1 == f.y1 && q.x2 == f.x2 && q.y2 == f.y2)\n return true;\n if (q.x1 == f.x2 && q.y1 == f.y2 && q.x2 == f.x1 && q.y2 == f.y1)\n return true;\n return false;\n}\nint main()\n{\n // freopen(\"INPUT.TXT\", \"r\", stdin);\n // freopen(\"OUTPUT.TXT\", \"w\", stdout);\n\n set > s;\n set l;\n map, int> m;\n tr qq[3];\n for(int i = 0; i < 4; ++i){\n int x, y, a, b;\n cin >> x >> y >> a >> b;\n qq[i].x1 = x;\n qq[i].y1 = y;\n qq[i].x2 = a;\n qq[i].y2 = b;\n\n s.insert(make_pair(x, y));\n s.insert(make_pair(a, b));\n\n if (x!=a && y != b){\n cout << \"NO\";\n return 0;\n }\n\n l.insert(abs(x-a) + abs(y-b));\n m[make_pair(x,y)]++;\n m[make_pair(a,b)]++;\n\n\n }\n\n if (s.size() != 4){\n cout << \"NO\";\n return 0;\n }\n //cout << l.size();\n if (l.size() > 2){\n cout << \"NO\";\n return 0;\n }\n\n if (l.size() == 1 && *l.begin() == 0)\n {\n cout << \"NO\";\n return 0;\n }\n for(map, int>::iterator i = m.begin(); i != m.end(); ++i){\n int q = i->second;\n if (q != 2){\n cout << \"NO\";\n return 0;\n }\n\n }\n\n cout << \"YES\";\n return 0;\n}\n\n/*#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define MaxQQQ 100002\n#define Mod (1000000007)\n\ntypedef long long ll;\n\nbool ispr(int a){\n for(int i = 2; i*i <= a; ++i)\n if (a % i == 0)\n return false;\n return true;\n}\n\nstruct tr{\n int x1, y1;\n int x2, y2;\n};\n\nbool eq(tr q, tr f){\n if (q.x1 == f.x1 && q.y1 == f.y1 && q.x2 == f.x2 && q.y2 == f.y2)\n return true;\n if (q.x1 == f.x2 && q.y1 == f.y2 && q.x2 == f.x1 && q.y2 == f.y1)\n return true;\n return false;\n}\nint main()\n{\n // freopen(\"INPUT.TXT\", \"r\", stdin);\n // freopen(\"OUTPUT.TXT\", \"w\", stdout);\n\n set > s;\n set l;\n map, int> m;\n tr qq[3];\n for(int i = 0; i < 4; ++i){\n int x, y, a, b;\n cin >> x >> y >> a >> b;\n qq[i].x1 = x;\n qq[i].y1 = y;\n qq[i].x2 = a;\n qq[i].y2 = b;\n if (i != 0)for(int j = 0; j < i; ++j){\n if (eq(qq[i],qq[j])){\n cout << \"NO\";\n return 0;\n }\n }\n\n s.insert(make_pair(x, y));\n s.insert(make_pair(a, b));\n\n if (x!=a && y != b){\n cout << \"NO\";\n return 0;\n }\n\n l.insert(abs(x-a) + abs(y-b));\n m[make_pair(x,y)]++;\n m[make_pair(a,b)]++;\n }\n\n if (s.size() != 4){\n cout << \"NO\";\n return 0;\n }\n cout << l.size();\n if (l.size() > 2){\n cout << \"NO\";\n return 0;\n }\n\n if (l.size() == 1 && *l.begin() == 0)\n {\n cout << \"NO\";\n return 0;\n }\n for(map, int>::iterator i = m.begin(); i != m.end(); ++i){\n int q = i->second;\n // cout << q << \" \";\n if (q != 2){\n cout << \"NO\";\n return 0;\n }\n\n }\n\n cout << \"YES\";\n return 0;\n}\n*/\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b79ac64daf850850af78af74a4d22b5f", "src_uid": "ad105c08f63e9761fe90f69630628027", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define MaxQQQ 100002\n#define Mod (1000000007)\n\ntypedef long long ll;\n\nbool ispr(int a){\n for(int i = 2; i*i <= a; ++i)\n if (a % i == 0)\n return false;\n return true;\n}\n\nstruct tr{\n int x1, y1;\n int x2, y2;\n};\n\nbool eq(tr q, tr f){\n if (q.x1 == f.x1 && q.y1 == f.y1 && q.x2 == f.x2 && q.y2 == f.y2)\n return true;\n if (q.x1 == f.x2 && q.y1 == f.y2 && q.x2 == f.x1 && q.y2 == f.y1)\n return true;\n return false;\n}\nint main()\n{\n // freopen(\"INPUT.TXT\", \"r\", stdin);\n // freopen(\"OUTPUT.TXT\", \"w\", stdout);\n\n set > s;\n set l;\n map, int> m;\n tr qq[3];\n for(int i = 0; i < 4; ++i){\n int x, y, a, b;\n cin >> x >> y >> a >> b;\n qq[i].x1 = x;\n qq[i].y1 = y;\n qq[i].x2 = a;\n qq[i].y2 = b;\n /*if (i != 0)for(int j = 0; j < i; ++j){\n if (eq(qq[i],qq[j])){\n cout << \"NO\";\n return 0;\n }\n }\n */\n s.insert(make_pair(x, y));\n s.insert(make_pair(a, b));\n\n if (x!=a && y != b){\n cout << \"NO\";\n return 0;\n }\n\n l.insert(abs(x-a) + abs(y-b));\n m[make_pair(x,y)]++;\n m[make_pair(a,b)]++;\n }\n\n if (s.size() != 4){\n cout << \"NO\";\n return 0;\n }\n\n if (l.size() > 2){\n cout << \"NO\";\n return 0;\n }\n\n if (l.size() == 1 && *l.begin() == 0)\n {\n cout << \"NO\";\n return 0;\n }\n for(map, int>::iterator i = m.begin(); i != m.end(); ++i){\n int q = i->second;\n cout << q << \" \";\n if (q != 2){\n cout << \"NO\";\n return 0;\n }\n\n }\n\n cout << \"YES\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ca3e1ab7b3214603087d954d67ef762f", "src_uid": "ad105c08f63e9761fe90f69630628027", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "// run: $exec < input\n// opt: 0\n// flag: -g\n#include \n#include \n#include \n#include \n\nlong long const maxn = 1000000000000;\nint const maxm = 50;\nlong long f[maxm][maxm];\nstd::vector p2;\nlong long n, t, kth, left;\n\nvoid init()\n{\n\tlong long p = 1;\n\tfor (; p <= maxn; p *= 2)\n\t\tp2.push_back(p);\n\n\tfor (int i = 0; i < maxm; i++)\n\t\tfor (int j = 0; j < maxm; j++)\n\t\t\tf[i][j] = -1;\n}\n\nint index(int x)\n{\n\tauto it = std::lower_bound(p2.begin(), p2.end(), x);\n\tif (it == p2.end() || *it != x) return -1;\n\treturn it - p2.begin();\n}\n\nlong long dp(int x, int t)\n{\n//\tstd::cerr << \" x = \" << x << \" t = \" << t << '\\n';\n\tif (t < 0) return 0;\n\tif (f[x][t] != -1) return f[x][t];\n\tif (t > x) return f[x][t] = 0;\n\tif (x == 2) return f[x][t] = t == 1 ? 2 : 1;\n\tlong long ret = dp(x - 1, t) + dp(x - 1, t - 1);\n\treturn f[x][t] = ret;\n}\n\nlong long dp2(long long left, int t)\n{\n\tif (left == 1) return t == 0 ? 1 : 0;\n\tif (left == 2) return t == 0 ? 1 : (t == 1 ? 1 : 0);\n\tif (left == 3) return t == 0 ? 1 : (t == 1 ? 2 : 0);\n\tint tmp = std::upper_bound(p2.begin(), p2.end(), left) - p2.begin() - 1;\n//\tstd::cerr << \" left = \" << left << \" tmp = \" << tmp << \" p2[] = \" << p2[tmp] << '\\n';\n\tif (t > p2[tmp + 1]) return 0;\n\tlong long ret = dp(tmp, t);\n\treturn ret + dp2(left - p2[tmp], t - 1);\n}\n\nint main()\n{\n\tinit();\n\tstd::cin >> n >> t;\n\tif (n == 1) {\n\t\tstd::cout << (t == 1 ? 1 : 0) << '\\n';\n\t\treturn 0;\n\t} else if (n == 2) {\n\t\tstd::cout << (t == 1 ? 1 : (t == 2 ? 1 : 0)) << '\\n';\n\t\treturn 0;\n\t}\n\tif (index(t) == -1) { std::cout << \"0\\n\"; return 0; }\n\tn++;\n\tkth = std::log(n + 1) / std::log(2.0) - 2;\n\tleft = n - ((1ll) << (kth + 2)) + 4 - 3;\n\tlong long ans = 0;\n\n\tfor (int i = kth + 1; i > 1; i--)\n\t\tans += dp(i, index(t));\n\n//\tstd::cerr << \"ans = \" << ans << \" left = \" << left << \" kth = \" << kth << '\\n';\n\tans += dp2(left, index(t));\n//\tstd::cerr << \"ans = \" << ans << \" left = \" << left << \" kth = \" << kth << '\\n';\n\tif (t == 1) ans++;\n\telse if (t == 2) ans++;\n\tstd::cout << ans << '\\n';\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "06827753ba2c9209f8dc437d1361a71d", "src_uid": "727d5b601694e5e0f0cf3a9ca25323fc", "difficulty": 2000.0} {"lang": "MS C++", "source_code": "#include \nusing namespace std;\n\nbool lg(long long x,long long &ans)\n{\n\tans = 0;\n\twhile(x>1)\n\t{\n\t\tif((x%2))\n\t\t\treturn 0;\n\t\telse\n\t\t\tx /= 2;\n\t\tans++;\n\t}\n\treturn 1;\n}\n\nint cnt(long long x)\n{\n\tint ans = 0;\n\twhile(x>0)\n\t{\n\t\tif(x%2) ans++;\n\t\tx /= 2;\n\t}\n\treturn ans;\n}\n\nlong long fst[35];\t//first part, with [i] ones, number less\nlong long scd[35];\t//second part, with [i] ones, number anything\n\nint main()\n{\n\tcin.tie(0);\n\tios::sync_with_stdio(0);\n\tlong long n,t;\n\tcin >> n >> t;\n\tn++;\n\tlong long dig;\n\tif(!lg(t,dig))\n\t{\n\t\tcout << 0 << endl;\n\t\treturn 0;\n\t}\n\tdig++;\n\tfor(int i=0;i<35;i++)\n\t\tfst[i] = scd[i] = 0;\n\tfor(int i=0;i<(1<<20);i++)\n\t{\n\t\tif(i>=(n>>20))\n\t\t\tbreak;\n\t\tfst[cnt(i)]++;\n\t}\n\tfor(int i=0;i<(1<<20);i++)\n\t{\n\t\tif(i>n)\n\t\t\tbreak;\n\t\tscd[cnt(i)]++;\n\t}\n\tlong long ans = 0;\n\tfor(int i=max(0LL,dig-34LL);i<=min(dig,34LL);i++)\n\t\tans += fst[i]*scd[dig-i];\n\tfor(int i=0;i<35;i++)\n\t\tfst[i] = scd[i] = 0;\n\tfst[cnt(n>>20)]++;\n\tfor(int i=0;i<(1<<20);i++)\n\t{\n\t\tif(i>(n&((1<<20)-1)))\n\t\t\tbreak;\n\t\tscd[cnt(i)]++;\n\t}\n\tfor(int i=max(0LL,dig-34LL);i<=min(dig,34LL);i++)\n\t\tans += fst[i]*scd[dig-i];\n\tif(t==1)\n\t\tans--;\n\tcout << ans << \"\\n\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4bace2cec177fe52ad8445a5136d2bc4", "src_uid": "727d5b601694e5e0f0cf3a9ca25323fc", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n\nlong long dp[65][65];\nint main()\n{\n long long n,t,ans=0;\n cin>>n>>t;\n long long num=0;\n while((1<=0;i--){\n if(num<0)break;\n if(n>=(1LL<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n//#include \"sdf.hpp\"\n\nusing namespace std;\n#define rep(i, a, b) for(int i = (a); i < (b); i++)\n#define repd(i, a, b) for(int i = (a); i > (b); i--)\n#define forIt(it, a) for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)\n#define forRev(it, a) for(__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)\n#define ft(a) __typeof((a).begin())\n#define ll long long\n#define ld long double\n#define fi first\n#define se second\n#define mk make_pair\n#define pb push_back\n#define sz(a) (a).size()\n#define all(a) (a).begin(), (a).end()\n#define Rep(i,n) for(int i = 0; i < (n); ++i)\n\ntypedef complex cplex;\ntypedef vector vi;\ntypedef pair ii;\ntypedef pair iii;\ntypedef vector vii;\ntypedef vector viii;\n\nconst int N = 10000 + 7;\nconst int M = 19;\nconst int mid = M / 2;\nconst int mod = 1e9 + 9;\nconst int inf = 1e9 + 7;\nconst ll linf = 1ll * inf * inf;\nconst double pi = acos(-1);\nconst double eps = 1e-7;\nconst double ep = 1e-5;\nconst int maxn = 1e5 + 7;\nconst double PI = acos(-1);\n\n\nint a[N][N];\nint m;\nmap > , ll > ans;\n\nll get(int type, ll n, ll t) {\n pair > tmp = mk(type, mk(n, t));\n if (ans.count(tmp)) return ans[tmp];\n \n \n if (type == 0) {\n return (t == 1);\n }\n ll lt = 1ll << (type - 1);\n \n if (n < lt) {\n return ans[tmp] = get(type - 1, n, t);\n } else {\n if (t & 1) return ans[tmp] = get(type - 1, lt - 1, t);\n return ans[tmp] = get(type - 1, n - lt, t / 2) + get(type - 1, lt - 1, t);\n }\n}\n\nvoid solve() {\n// int m = 35;\n// for(int j = 1; j <= m; ++j) a[1][j] = 0;\n// \n// a[1][m + 1] = 1;\n// \n// for(int i = 2; i <= m + 1; ++i) {\n// for(int j = 1; j <= m + 1; ++j) {\n// if (j == 1) {\n// a[i][j] = a[i - 1][j + 1];\n// } else {\n// if (j == m + 1) {\n// a[i][j] = a[i - 1][j - 1];\n// } else {\n// a[i][j] = a[i - 1][j + 1] ^ a[i - 1][j - 1];\n// }\n// }\n// \n// }\n// }\n// int sum = 0;\n// rep(i, 1, m + 2) {\n// rep(j, 1, m + 2) {\n// //cout << a[i][j] << \" \";\n// if (a[i][j] == 1) printf(\"*\");\n// else printf(\"_\");\n// if (i == m + 1) sum += a[i][j];\n// }\n// puts(\"\");\n// }\n// cout << sum << \"\\n\";\n// puts(\"\");\n \n \n// cout << get(3, 7, 4) << \"\\n\";\n// \n// forIt(it, ans) {\n// pair > tmp = it->first;\n// cout << tmp.first << \" \" << tmp.second.first << \" \" << tmp.second.second << \" \" << it->second << \"\\n\";\n// }\n// \n// return;\n \n ll n, t;\n cin >> n >> t;\n ll lt = 1;\n ll res = 0;\n int type = 0;\n while (n >= lt) {\n res += get(type, lt - 1, t);\n //cout << type << \" \" << lt - 1 << \" \" << t << \" \" << get(type, lt - 1, t) << \"\\n\";\n n -= lt;\n lt *= 2;\n type++;\n }\n if (n > 0) {\n res += get(type, n - 1, t);\n }\n \n cout << res;\n}\n\n\n\nint main() {\n#ifndef ONLINE_JUDGE\n freopen(\"in.txt\", \"r\", stdin); //freopen(\"out.txt\", \"w\", stdout);\n#endif\n int T =1;\n //cin >>T;\n //cout << T << \"\\n\";\n rep(i, 1, T + 1) {\n //printf(\"Case #%d: \", i);\n// m = i;\n solve();\n //cout << prime.size() << \"\\n\";\n }\n \n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fd922307a6340c57624ca75f29a397f9", "src_uid": "727d5b601694e5e0f0cf3a9ca25323fc", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main()\n{\n char word[100] = {'\\0'};\n char word2[100] = {'\\0'};\n int ucases =0;\n int lcases =0;\n\n cin >> word;\n\n for(int i=0; i='a' && word[i]<='z'){\n\n lcases++;\n word2[i] = word[i]-32;\n }\n else{\n ucases++;\n word2[i] = word[i];\n word[i] = word[i]+32;\n }\n }\n \n if(ucases > lcases){\n std::cout << word2 << std::endl;\n }else{\n std::cout << word << std::endl;\n }\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7818d63e5057375e0a28006fde490b8c", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n char word[100] = {'\\0'};\n char word2[100] = {'\\0'};\n int ucases =0;\n int lcases =0;\n\n cin >> word;\n\n for(int i=0; i lcases){\n std::cout << word2 << std::endl;\n }else{\n std::cout << word << std::endl;\n }\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e24e9a045259cbc08948650132507125", "src_uid": "b432dfa66bae2b542342f0b42c0a2598", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nconst long long MAXN=500000001;\nchar a[MAXN];\nint i,j,n,m,t,l;\nint main(){\n ios::sync_with_stdio(false);\n gets(a);\n l=strlen(a);\n for(i=0;i<=l;i++){\n if(isupper(a[i]))\n n++;\n if(islower(a[i]))\n m++;\n }\n if(n>m)\n for(i=0;i<=l;i++)\n if(islower(a[i]))\n a[i]=toupper(a[i]);\n if(n\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n int n=1,d=0,x=0;\n char a[999999999];\n while((a[n]=getchar())!='\\n')\tn++;\n n--;\n for(int i=1;i<=n;i++)\n {\n \tif(a[i]>96)\n \t{\n \t\tx++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\td++;\n\t\t}\n\t}\n\tif(d>x)\n\t{\n\t\tfor(int i=1;i<=n;i++)\n\t\t{\n\t\t\tif(a[i]>96)\n\t\t\t{\n\t\t\t\ta[i]-=32;\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tfor(int i=1;i<=n;i++)\n\t\t{\n\t\t\tif(a[i]<96)\n\t\t\t{\n\t\t\t\ta[i]+=32;\n\t\t\t}\n\t\t}\n\t}\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tcout<\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n int n,m,in;\n cin>>n>>m;\n vectorv,v1 ;\n for(int i=0; i>in;\n v.push_back(in);\n }\n if (n==1 && v[0]>m){\n cout<<0<min && v[i]!=-1){\n min=i;\n }}\n sum+=v[min];\n v1.push_back(min+1);\n v[min]=-1;\n}\ncout<\nusing namespace std;\n\n#define PB push_back\n#define F first\n#define S second\n#define MP make_pair\n#define LL long long\n#define ULL unsigned long long\n#define LB lower_bound\n#define MOD1 1000000007\n#define MOD2 1000000009\n#define loop(i, a, b) for (int i = a; i < b; i++)\nLL n, m;\nint movex[] = {0, 0, 1, -1};\nint movey[] = {1, -1, 0, 0};\n\nunordered_set res;\nint helper(vector &arr, int idx, int n, int k, vector> dp)\n{\n\n if (idx >= n)\n return 0;\n if (k < 0)\n return 0;\n\n if (dp[idx][k] != -1)\n return dp[idx][k];\n\n if (k == 0)\n {\n dp[idx][k] = 0;\n return 0;\n }\n\n int op1 = INT_MIN, op2 = INT_MIN;\n //learn on idx day if possible\n if (k - arr[idx] >= 0)\n {\n op1 = 1 + helper(arr, idx + 1, n, k - arr[idx], dp);\n }\n\n op2 = helper(arr, idx + 1, n, k, dp);\n\n if (op1 > op2)\n res.insert(idx + 1);\n\n dp[idx][k] = max(op1, op2);\n return max(op1,op2);\n}\n\nint main()\n{\n static const int _ = []() {\n ios::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n return 0;\n }();\n\n LL n, k;\n cin >> n >> k;\n vector arr(n);\n for (auto &i : arr)\n cin >> i;\n\n vector> dp(n + 1, vector(k+1, -1));\n cout << helper(arr, 0, n, k, dp) << \"\\n\";\n for (auto a : res)\n cout << a << \" \";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4323077dac467c4a1981d7e3e8ecf9be", "src_uid": "dbb164a8dd190e63cceba95a31690a7c", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include \n \nusing namespace std;\n\nint findelement(int a,deque v)\n\t{\n\t\tint index;\n\t\tfor (int i=0;i v;\n\tdeque ans;\n\tcin >> n >> k;\n\tfor (int i=0;i> t;\n\t\t\tv.push_back(t);\n\t\t}\n\tsort(v.begin(),v.end());\n\twhile (sum<=k)\n\t\t{\n\t\t\tsum+=v.front();\n\t\t\tans2++;\n\t\t\tans.push_back(v.front());\n\t\t\tv.pop_front();\n\t\t}\n\tcout << ans2 << endl;\n\tfor (int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define ll long long\nusing namespace std;\n\nconst ll max1 = 101;\n\nint main() {\n\n\tbool debug =true;\n\tif (debug) {\n\t\tfreopen(\"in.txt\", \"r\", stdin);\n\t\tfreopen(\"out.txt\", \"w\", stdout);\n\t}\n\tll n, col,c, count=0;\n\tcin >> n >> col;\n\tvector a,o;\n\tfor (size_t i = 0; i < n; i++)\n\t{\n\t\tcin >> c;\n\t\ta.push_back(c);\n\t}\n\tvector::iterator point;\n\tll dist;\n\twhile (col>0 || count::iterator point = max_element(a.begin(), a.end());\nlong long dist = distance(a.begin(), point);*/", "lang_cluster": "C++", "compilation_error": false, "code_uid": "37686ad94f8e14803be63cf92b2f27b9", "src_uid": "dbb164a8dd190e63cceba95a31690a7c", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include\n#define ll long long int\nusing namespace std;\nint dp[2501][100005];\nint main()\n{\n ll a[3];\n scanf(\"%lld%lld%lld\",&a[0],&a[1],&a[2]);\n ll ma=0,i,j,k;\n ll ctr=0;\n priority_queueq;\n q.push(a[0]);\n q.push(a[1]);\n q.push(a[2]);\n\n while(1)\n{\n i=q.top();\n q.pop();\n j=q.top();\n q.pop();\n if(i==1&&j==1) {\n k=q.top();\n if(k==1){\n ctr++;\n }\n\n break;\n }\n else if(i>=2&&j>=1){\n ctr++;\n i-=2;\n q.push(i);\n j-=1;\n q.push(j);\n }\n else if(i==1&&j==1) {\n k=q.top();\n if(k==1){\n ctr++;\n }\n\n break;\n }\n else {\n break;\n }\n}\n printf(\"%lld\\n\",ctr);\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d3ccc6bdfdc4dfacd22de86536737a61", "src_uid": "bae7cbcde19114451b8712d6361d2b01", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include \n#include\n#include\n#include\n#include \n#include\n#include \n\n#define tii tuple\n#define vi vector\n#define vii vector\n#define ll long long int\n#define vl vector\n#define vll vector\n\n#define mymod 1000000007\n\nusing namespace std;\n\nll solve(vl v) {\n sort(v.begin(), v.end());\n ll a = v[0];\n ll b = v[1];\n ll c = v[2];\n if(a == 0) {\n return min(b,(c+b)/3);\n }\n if(c-a<=1){\n return (a+b+c)/3;\n }\n if(a+b<=c){\n return 1 + solve({a,b-1,c-2});\n }\n return 1 + solve({a-1,b-1,c-1});\n}\n\nint main() {\n clock_t tstart = clock();\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n // Start\n\n ll a,b,c;\n cin>>a>>b>>c;\n cout<\n#include \n#include \n#include \n#include \n#include \n#define inf 0x3f3f3f3f\nusing namespace std;\nstruct node\n{\n __int64 x,y,z,ans;\n}t,f;\nint main()\n{\n __int64 r,g,b;\n __int64 minx;\n while(scanf(\"%I64d%I64d%I64d\",&r,&g,&b)!=EOF)\n {\n minx=0;\n queueq;\n t.x=r;\n t.y=g;\n t.z=b;\n t.ans=0;\n q.push(t);\n while(!q.empty())\n {\n t=q.front();\n q.pop();\n f.x=t.x-1;\n f.y=t.y-1;\n f.z=t.z-1;\n if(f.x>=0&&f.y>=0&&f.z>=0)\n {\n f.ans=t.ans+1;\n if(minx=0&&f.y>=0&&f.z>=0)\n {\n f.ans=t.ans+1;\n if(minx=0&&f.y>=0&&f.z>=0)\n {\n f.ans=t.ans+1;\n if(minx=0&&f.y>=0&&f.z>=0)\n {\n f.ans=t.ans+1;\n if(minx=0&&f.y>=0&&f.z>=0)\n {\n f.ans=t.ans+1;\n if(minx=0&&f.y>=0&&f.z>=0)\n {\n f.ans=t.ans+1;\n if(minx=0&&f.y>=0&&f.z>=0)\n {\n f.ans=t.ans+1;\n if(minx\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define fi first\n#define se second\n#define pb push_back\n#define mk make_pair\n#define Pii pair < int , int >\n#define tree int t,int l,int r\n#define left 2*t,l,(l+r)/2\n#define right 2*t+1,(l+r)/2+1,r\n#define get(x) scanf(\"%d\",&x)\n#define LL long long\n#define INF 1000000000\n#define eps 0.00000001\n#define P7 1000000007\n#define P9 1000000009\n#define N3 2555\n#define N5 262145\n#define N6 1048577\n#define SS system(\"pause\")\n\nusing namespace std;\n\nLL gcd(LL A,LL B) {\n return A>B?gcd(B,A):A?gcd(B%A,A):B; }\n\nLL lcm(LL A,LL B) {\n return A/gcd(A,B)*B; }\n\nLL pow(LL A,LL B,LL P) {\n if (!B) return 1%P;\n LL h=pow(A,B/2,P); h*=h;\n h%=P; if (B%2) h*=A; return h%P;\n}\n\nPii P[N5];\nint p[N5];\nbool f[N5];\nvector < int > ans1,ans2,ans3;\nstring s,q,s1,s2;\nvector < int > g[N5],c[N5];\nint lp[N6+2];\nvector < int > pr;\nvoid get_pr(int N) {\n for (int i=2;i<=N;i++)\n {\n if (lp[i] == 0)\n {\n pr.pb(i);\n lp[i]=i;\n }\n for (int j=0;j>a[i];\n sort(a,a+3);\n cout<\nusing namespace std;\n\nint main()\n{\n int n;\n cin>>n;\n int k=n/2;\n if(n%2!=0)\n {\n int a=n/2;\n int b=a+1;\n cout<\nusing namespace std;\n\nconst int OO = 0x3f3f3f3f ;\n#define read(FILE) freopen(FILE, \"r\", stdin);\n#define write(FILE) freopen(FILE, \"w\", stdout);\n#define BeatMeIFUCAN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n\nint n ;\nbool GCD(int a,int b){\n return b ? GCD(b, a%b) : a==1 ;\n}\nint main(){\n scanf(\"%d\",&n);\n for(int i=(n/2)-!(n%2);i>0;--i)\n if(GCD(i,n-i)) exit(printf(\"%d %d\\n\",i,n-i)) ;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "41b56bb6697a1fb2084a6b6edd4b8759", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \nusing namespace std;\nint main() {\n\tint n;\n\tcin >> n;\n\tdouble maxa = 0, maxb = 1;\n\tdouble t = 0;\n\tfor (int i = 1; i <= (n/2); ++i) {\n\t\tif (((n - i) % i != 0) || i == 1) {\n\t\t\tt = (i / (n - i));\n\t\t\tif (t >= (maxa / maxb)) {\n\t\t\t\tmaxa = i;\n\t\t\t\tmaxb = (n - i);\n\t\t\t}\n\t\t}\n\t}\n\tcout << maxa << \" \" << maxb;\n\tsystem(\"pause\");\n\treturn 0;\n}\n/**\n *https://acm.scut.space/\n *Job ID:4761\n *Time: 1513180608\n**/", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c16f97085db776c6bfeea65cd2d53a08", "src_uid": "0af3515ed98d9d01ce00546333e98e77", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n\nvector prime(10000);\n\nbool mark[100000];\n\nvoid sieve(int n)\n{\n int i,j,limit=sqrt(n*1.0)+2;\n\n mark[1]=1;\n\n for(i=4;i<=n;i+=2)\n mark[i]=1;\n\n prime.push_back(2);\n\n for(i=3;i<=n;i+=2)\n {\n if(!mark[i])\n {\n prime.push_back(i);\n\n if(i<=limit)\n {\n for(j=i*i;j<=n;j+=i*2)\n mark[j]=1;\n }\n }\n }\n}\n\nint main()\n{\n sieve(100000);\n\n int n,lim;\n\n cin>>n;\n\n if(n%2) lim = n/2;\n else lim = n/2 - 1;\n\n for(int i=lim;i>0;i--)\n {\n if(!mark[i] || !mark[n-i])\n {\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define lli long long int\n\nusing namespace std;\n\nlli rec(lli a,lli b){\n\tlli c=0;\n\tif(b==1){\n\t\treturn a;\n\t}\n\twhile(a>b){\n\t\ta = a-b;\n\t\tc++;\n\t}\n\tc = c + rec(b,a);\n\treturn c;\n}\n\nint main(){\n\n\tlli a,b;\n\tcin>>a;\n\tcin>>b;\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n long long n, res=0, sum=0, a, b, d;\n //long long a[3000009];\n // string s, a1, c1, c;\n double z, x;\n\n\n\nint main() {\n\n cin >> a >> b;\n \n while (b*a>0)\n {\n res+=a/b;\n a=a%b;\n if (a>0)\n {\n d=b/a;\n b=b-d*a;\n res+=d;\n }\n }\n cout << res;\n\n\n\n\n int kol234;\n cin >> kol234;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5eb1a3723ed0177067751902edc34948", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0} {"lang": "MS C++", "source_code": "#include \nusing namespace std;\n\n#define ABS(n) (((n) > 0) ? (n) : -(n))\n\n__int64 gcd(__int64 a, __int64 b)\n{\n\t__int64 t = 1;\n\t__int64 r;\n\twhile(a != 1 || b != 1) {\n\t\tr = ABS(a - b);\n\t\tb = min(a, b);\n\t\ta = r;\n\t\tif(a == 1) {\n\t\t\tt += b;\n\t\t\tbreak;\n\t\t} else if( b==1){\n\t\t\tt += a;\n\t\t\tbreak;\n\t\t}\n\t\tt++;\n\t}\n\treturn t;\n}\n\nint main()\n{\n\t__int64 a, b;\n\twhile(cin >> a >> b)\n\t\tcout << gcd(a ,b) << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2af33edb513d1a1c5dc7fbd2beaec4e2", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include\n#include\n#include\n#include\n#include\n\n#include\n#include\nusing namespace std;\n#define REP(i,n) for(int i=0;i<(n);i++)\n\ntypedef long long ll;\nconst int intINF = 1<<30;\nconst ll llINF = 1LL<<60;\n\nll gcd(ll a, ll b)\n{\n\treturn b?gcd(b,a%b):a;\n}\n\nll solve(ll a, ll b)\n{\n\tll g = gcd(a, b);\n\ta /= g;\n\tb /= g;\n\tif(a == 1 || b == 1) return max(a, b);\n\tif(a > b)\n\t{\n\t\treturn 1 + solve(a-b, b);\n\t}\n\telse\n\t{\n\t\treturn 1 + solve(a, b-a);\n\t}\n}\n\nint main()\n{\n\tll a, b;\n\tcin >> a >> b;\n\tcout << solve(a, b) << endl;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ef66cb0e475d33ae75347fe51a7f32b3", "src_uid": "792efb147f3668a84c866048361970f8", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\ntypedef long long LL;\ntypedef unsigned long long ULL;\nconst int MAXN=2e3+10;\nconst int mod=1e9+7;\nconst int INF=1e9+10;\nconst double EPS=1e-8;\n\nLL n,m,t;\nLL fra[MAXN],inv[MAXN],f[MAXN][20000],C[MAXN][MAXN],D[MAXN][MAXN];\n\nLL power(LL a,LL b){\n LL c=1;\n while(b){\n if (b%2==1) c=c*a%mod;\n a=a*a%mod;\n b/=2;\n }\n return c;\n}\n\nLL CC(LL n,LL m){\n if (n<0 || m<0 || n=0;i--) inv[i]=inv[i+1]*(i+1)%mod;\n scanf(\"%lld%lld%lld\",&n,&m,&t);\n memset(f,0,sizeof(f));\n for(int i=0;i<=n;i++)\n for(int j=0;j<=n;j++){ \n C[i][j]=CC(i,j);\n D[i][j]=power(C[i][j],m/n);\n }\n f[0][0]=1;\n LL pos=m%n;\n for(int i=1;i<=n;i++){\n for(int j=0;j<=t;j++){ \n for(int k=0;k<=n;k++){\n if (j-k<0) continue;\n if (i<=pos) f[i][j]+=((f[i-1][j-k]*D[n][k]%mod)*C[n][k]%mod);\n else f[i][j]+=(f[i-1][j-k]*D[n][k]%mod);\n if (f[i][j]>=mod) f[i][j]-=mod;\n }\n }\n }\n printf(\"%lld\\n\",f[n][t]);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2102a69274e7ab56dd7bb03771c95f37", "src_uid": "9c71c8e031412e2bb21266a53821626a", "difficulty": 1900.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long lint;\n\nlint din[10009][101][101];\nconst lint mod = 1e9+7.5;\nlint C[101];\nlint m;\nint n;\n\ninline lint binpow( lint num, lint p )\n{\n lint res = 1;\n while( p )\n {\n if( p&1 )\n res = ( res * num ) % mod;\n num = ( num * num ) % mod;\n p >>= 1;\n }\n return res;\n}\ninline lint rev( lint num )\n{\n return binpow( num, mod-2 );\n}\n\nvoid calc_C()\n{\n C[0] = 1;\n for( int i = 1; i <= n; i++ )\n {\n C[i] = ( C[i-1] * ( n - i + 1 ) ) % mod;\n C[i] = ( C[i] * rev( i ) ) % mod;\n }\n}\n\nlint rec( int k, int p )\n{\n if( din[k][n][p] != -1 )\n return din[k][n][p];\n if( k > p * n )\n return din[k][n][p]=0;\n if( k == 0 || p == 0 )\n return din[k][n][p] = 1;\n lint res = 0;\n for( int i = 0, end = min( k, n ); i <= end; i++ )\n {\n lint tmp1 = rec( k - i, p - 1 ); // \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n int powr = m / n + ( n - p + 1 <= m % n );\n lint tmp2 = binpow( C[i], powr ); // \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n lint tmp3 = ( tmp1 * tmp2 ) % mod;\n res = ( res + tmp3 ) % mod;\n }\n return din[k][n][p] = res;\n}\n\nint main()\n{\n#ifndef ONLINE_JUDGE\n freopen( \"input.txt\", \"rt\", stdin );\n freopen( \"output.txt\", \"wt\", stdout );\n#endif\n int k;\n cin >> n >> m >> k;\n memset( din, -1, sizeof( din ) );\n \n calc_C();\n\n lint res = rec( k, n );\n cout << res;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b0b1d4f0575714f817cef7cdaf7fc8a4", "src_uid": "9c71c8e031412e2bb21266a53821626a", "difficulty": 1900.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define forn(i, n) for(int i = 0; i < int(n); i++)\n#define for1(i, n) for(int i = 1; i <= int(n); i++)\n#define fore(i, l, n) for(int i = int(l); i < int(n); i++)\n#define ford(i, n) for(int i = int(n) - 1; i >= 0; i--)\n\n#define sz(s) (int)(s).size()\n#define mp make_pair\n#define pb push_back\n#define X first\n#define Y second\n#define all(v) (v).begin(), (v).end()\n\nusing namespace std;\n\ntypedef long double ld;\ntypedef long long li;\ntypedef pair pt;\n\nconst int N = 100000;\nconst ld EPS = 1e-9;\n\nconst int M = 1000 * 1000 * 1000 + 7;\nint n;\nint cnt[200];\nint d[2][40000];\nint c[200][200];\nint C(int n, int k){\n if(k > n)\n return 0;\n if(k == n)\n return 1;\n if(k == 0)\n return 1;\n return (c[n-1][k]+c[n-1][k-1])%M;\n}\nvoid init(){\n forn(i, 200)\n forn(j, 200){\n c[i][j] = C(i, j);\n }\n}\nint mod_pow(int a, int b){\n int res = 1;\n while(b > 0){\n if(b&1)\n res = (res * 1LL*a)%M, b--;\n a = (a*1ll*a)%M;\n b >>= 1;\n }\n return res;\n}\nint mdp[200][200];\nint main(){\n //freopen(\"input.txt\", \"rt\", stdin);\n //freopen(\"output.txt\", \"wt\", stdout);\n li m;\n int k;\n cin >>n >>m >> k;\n init();\n forn(i, n){\n cnt[i] = ((m-i)/n + ((m-i)%n!=0))%M;\n\n }\n forn(i, n+1){\n d[0][i] = mod_pow(c[n][i], cnt[0]);\n }\n //cerr << clock() << endl;\n fore(i, 1, n)\n forn(cd, n+1)\n mdp[cd][i] = mod_pow(c[n][cd], cnt[i]);\n fore(i, 1, n){\n forn(ck, k+1){\n forn(cd, min(n, ck)+1){\n d[i&1][ck] = (d[i&1][ck] + d[(i-1)&1][ck-cd]*1LL*mdp[cd][i])%M;\n }\n }\n forn(ck, k+1)\n d[(i-1)&1][ck] = 0;\n //cerr << clock() << endl;\n }\n cout << d[(n-1)&1][k] << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2a86617c88fb530b8ce139b48a4e4db8", "src_uid": "9c71c8e031412e2bb21266a53821626a", "difficulty": 1900.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef long long Int;\n#define FOR(i,a,b) for(int i=a;i<=b;++i)\n#define sz(s) (int)s.size()\n#define pb push_back\n#define mp make_pair\n#define sqr(x) (x)*(x)\nconst int inf=1000000000;\nconst int MOD = 1000000007;\n\nint binpw(Int x,int times)\n{\n\tInt ans = 1;\n\twhile(times)\n\t{\n\t\tif(times&1)ans=(ans*x)%MOD;\n\t\tx=(x*x)%MOD;\n\t\ttimes/=2;\n\t}\n\treturn ans;\n}\n\n\nint dp[111][11111];\nint bim[111][111],gett[111];\n\nint main()\n{\n\t//freopen(\"input.txt\",\"r\",stdin);freopen(\"output.txt\",\"w\",stdout);\n\tInt n,m,k;\n\tcin>>n>>m>>k;\n\tmemset(dp,0,sizeof(dp));\n\tFOR(i,0,100)FOR(j,0,i)if(j==0 || i==j)bim[i][j]=1;else bim[i][j]=(bim[i-1][j-1]+bim[i-1][j])%MOD;\n\n\tdp[0][0]=1;\n\tFOR(i,1,n)\n\t{\n\t\tFOR(cur,0,n)\n\t\t{\n\t\t\tint tmp = bim[n][cur];\n\t\t\tint t = (m-1-(i-1))/n+1;\n\t\t\tgett[cur]=binpw(tmp,t);\n\t\t}\n\t\tFOR(used,0,k)\n\t\t{\n\t\t\tFOR(cur,0,n)\n\t\t\t{\n\t\t\t\tif(cur>used)continue;\n\t\t\t\tdp[i][used]=(dp[i][used]+dp[i-1][used-cur]*(Int)gett[cur])%MOD;\n\t\t\t}\n\t\t}\n\t}\n\n\tcout<\nusing namespace std;\nint main(){\n\tint n;\n\tcin >> n;\n\tstring s;\n\tint j,i;\n\tcin>>s;\n for (i = 0;i <= n; i++)\n {\n \tcout << s[i] ;\n \tj++;\n \ti+= j; \n\t} \n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2ae3ad4ccf2e30918fba3d576c557469", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nvoid fast()\n{\n ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);\n}\nvoid file()\n{\n freopen(\"Input.txt\", \"r\", stdin);\n\tfreopen(\"Output.txt\", \"w\", stdout);\n}\n#define ll long long\n//#define endl \"/n\"\n/**YOU**CAN**DO**IT**/\n/**If**You**Want**To**Be**The**Best**Do**Your**Best**/\nint main()\n{\n fast();\n //file();\n /*\n long long sz,m,x,l,r,pos;\n cin>>sz>>m;\n string s,k;\n cin>>s;\n for(int i=0;i>k;\n if(k==\"pop_back\")\n {\n s[sz-1]={};\n }\n else if(k==\"front\")\n {\n cout<>l>>r;\n for(int i=l ;is[j])\n {\n swap(s[i],s[j]);\n }\n }\n }\n }\n else if(k==\"reverse\")\n {\n cin>>l>>r;\n for(int i=l-1;i>pos;\n cout<>x;\n s[sz]=x;\n }\n else if(k==\"substr\")\n {\n cin>>l>>r;\n for(int i=l;i<=r;i++)\n {\n cout<>t;\n while(t--)\n {\n long long n,p,c,arr[1001][1001];\n cin>>n;\n if(n==1)\n {\n cin>>p>>c;\n if(p>c || p==c)\n cout<<\"YES\\n\";\n else\n cout<<\"NO\\n\";\n }\n else\n {\n bool ok=true;\n for(int i=0;i>arr[i][j];\n }\n }\n for(int i=0;i>n;\n\tstring s,l,r;\n\tcin>>s;\n\tfor(int i=0;i=mx)\n\t mx=sum;\n\t}\ncout<>n;\nstring s,m;\ncin>>s;\nlong long i=0,c=0;\nwhile(i\nusing namespace std;\nint main()\n{\n int n ; cin >> n;\n string str;cin >> str;\n string res = \"\";\n for(int i = 0 ; i < n ;)\n {\n if(i > n)break;\n res+=str[i];\n if(i == 0)i+=1;\n else if(i == 1)i+=2;\n else if(i == 2)i+=3;\n else if(i == 3)i+=4;\n else if(i == 4)i+=5;\n else if(i == 5)i+=6;\n else if(i == 6)i+=7;\n else if(i == 7)i+=8;\n else if(i == 8)i+=9;\n else if(i == 9)i+=10;\n }\n cout << res << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "297d38d3b0210c0db5c100ec5861615d", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\nint main(void) {\n\n int n;\n cin >> n; \n\n string s, res;\n cin >> s;\n\n for (int i = 0; i < n ; i+=i) {\n res += s[i];\n }\n cout << res << endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c694bc06573a62ac3a95a78bc84e2c56", "src_uid": "08e8c0c37b223f6aae01d5609facdeaf", "difficulty": 800.0} {"lang": "GNU C++20 (64)", "source_code": "#include\r\n\r\nusing namespace std;\r\n#define endl \"\\n\"\r\n#define pb push_back\r\n#define eb emplace_back\r\nusing ll = long long;\r\n//constexpr int inf=0x7fffffff;\r\nconstexpr int inf = 0x3f3f3f3f;\r\nconstexpr int P = 998244353;\r\nauto seed = chrono::system_clock::now().time_since_epoch().count();\r\nmt19937 rnd(seed);\r\n\r\ntemplate\r\nT rd(T l, T r) { return uniform_int_distribution(l, r)(rnd); }\r\n\r\ntemplate\r\nvoid read(T &x) /*\u5feb\u8bfb*/\r\n{\r\n x = 0;\r\n int f = 1;\r\n char ch = getchar();\r\n while (!isdigit(ch)) {\r\n if (ch == '-') f = -1;\r\n ch = getchar();\r\n }\r\n while (isdigit(ch)) {\r\n x = x * 10 + (ch ^ 48);\r\n ch = getchar();\r\n }\r\n x *= f;\r\n return;\r\n}\r\n\r\ntemplate\r\nvoid write(T x) /*\u5feb\u5199*/\r\n{\r\n if (x < 0) {\r\n putchar('-');\r\n x = -x;\r\n }\r\n if (x > 9)\r\n write(x / 10);\r\n putchar(x % 10 + '0');\r\n return;\r\n}\r\n\r\nint n;\r\n__int128 xx;\r\nbool ok=false;\r\nint ans=inf;\r\n\r\nvoid dfs(__int128 now,int step){\r\n int res=0;\r\n sets;\r\n __int128 tmp=now;\r\n while(tmp>0){\r\n s.insert(tmp%10);\r\n tmp/=10;\r\n res++;\r\n }\r\n if(res>=n){\r\n ok=true;\r\n ans=min(ans,step);\r\n // __int128 tmp=1;\r\n // for(int i=1;i<\r\n// #define int long long\r\n#define cn puts(\"NO\");\r\n#define cy puts(\"YES\");\r\n#define endl \"\\n\"\r\nusing namespace std;\r\nusing ll = long long;\r\nvoid solve(){\r\n ll n,a,b,js=1;\r\n cin>>n>>a;\r\n ll now=0;\r\n for(int i=2;i<=n;i++) js*=10;\r\n b=a;\r\n if(a>js){\r\n cout<<0<> q;\r\n q.push({a,0});\r\n int res=-1;\r\n int i=0;\r\n while(q.size()){\r\n auto t=q.front();q.pop(); \r\n if(t.second>40) break;\r\n b=t.first; \r\n vector w;\r\n int js=0;\r\n while(b){\r\n js++;\r\n w.push_back(b%10);\r\n b/=10;\r\n }\r\n sort(w.begin(),w.end(),[](int a,int b){\r\n return a>b;\r\n });\r\n if(js==n){\r\n res=t.second;\r\n break;\r\n }\r\n q.push({w.front()*t.first,t.second+1});\r\n if(w.size()>1)\r\n q.push({w[1]*t.first,t.second+1});\r\n }\r\n cout<\r\nusing namespace std;\r\nint ans(long long int n,long long int x)\r\n{\r\n vectorv;\r\n long long int k=x;\r\n if((x==0 || x==1) && n==1)\r\n return 0;\r\n if((x==0 || x==1) && n!=1)\r\n return INT_MAX;\r\n while(k!=0)\r\n {\r\n v.push_back(k%10);\r\n k=k/10;\r\n } \r\n if(n==v.size())\r\n return 0;\r\n int mini=INT_MAX;\r\n for(int i=0;i>n>>x;\r\n int p=ans(n,x);\r\n if(p==INT_MAX)\r\n cout<<\"-1\"<>t;\r\n\twhile(t--)\r\n\t{\r\n\t solve();\r\n\t}\r\n\treturn 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c5016e442bb1ee5e899b7b30ee8fe4b6", "src_uid": "cedcc3cee864bf8684148df93804d029", "difficulty": 1700.0} {"lang": "GNU C++20 (64)", "source_code": "#include \r\n#define rep(i,a,b) for(int i=a;i=a;i--)\r\n#define all(x) (x).begin(),(x).end()\r\n#define pb(x) push_back(x);\r\ntemplatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b P;\r\n\r\nint main(void){\r\n ios::sync_with_stdio(false);\r\n cin.tie(nullptr);\r\n int n;cin >> n;\r\n ll x;cin >> x;\r\n ll power10=1;\r\n rep(i,0,n-1)power10*=10;\r\n if(power10<=x/10){\r\n cout << -1 << endl;\r\n return 0;\r\n }\r\n if(power10<=x&&x/10 s;\r\n s.insert(x);\r\n int cnt=0;\r\n while(true){\r\n set t;\r\n cnt++;\r\n for(ll z:s){\r\n ll z_=z;\r\n while(z_>0){\r\n ll y=z_%10;\r\n z_/=10;\r\n if(y==0&&y==1)continue;\r\n else if(power10/y<=z/10)continue;\r\n else if(power10<=z*y&&z*y/10\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nconst int MAX_N = 16 + 4;\nint n;\nint Arr[MAX_N];\nmap Map;\n\nint main() {\n Map[1] = 1;\n Map[2] = 2;\n Map[3] = 2;\n Map[4] = 2;\n Map[5] = 2;\n // Map[6] = 2;\n Map[10] = 1;\n Map[11] = 1;\n Map[12] = 2;\n Map[13] = 1;\n\n Map[16] = 1;\n\n // Map[19] = 1;\n Map[20] = 1;\n Map[24] = 1;\n Map[28] = 1;\n // Map[29] = 1;\n Map[30] = 2;\n // Map[31] = 2;\n // Map[32] = 2;\n // Map[33] = 2;\n // Map[34] = 2;\n Map[35] = 2;\n // Map[36] = 1;\n Map[37] = 1;\n\n Map[41] = 1;\n // Map[42] = 1;\n Map[43] = 2;\n Map[46] = 2;\n Map[47] = 2;\n Map[48] = 2;\n\n cin >> n;\n if (Map[n]) {\n cout << (Map[n] == 1? \"NO\\n\": \"YES\\n\");\n return 0;\n }\n\n exit(n <= 50);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "243fd282128fb8c74bafc8d844682ed6", "src_uid": "821529a4644b74483bcdf80fc318d1f8", "difficulty": null} {"lang": "GNU C++17", "source_code": "/* In the name of Allah */\n#include\nusing namespace std;\n\nint main() {\n\tint n;\n\tcin >> n;\n\tif (n == 2 || n == 3 || n == 4 || n == 5 || n == 12 || n == 46)\n\t\treturn cout << \"YES\", 0;\n\tif (n == 1 || n == 10 || n == 11 || n == 13 || n == 16 || n == 24)\n\t\treturn cout << \"NO\", 0;\n\tif (n == 20)\n\t\tassert(0);\n\tcout << \"NO\";\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f09bd32f10317349cffcad05a10cd65b", "src_uid": "821529a4644b74483bcdf80fc318d1f8", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include\n#include\n//#pragma GCC optimize(\"Ofast,no-stack-protector\")\n//#pragma GCC target(\"mmx,avx,fma\")\n//#pragma GCC optimize (\"unroll-loops\")\n\nusing namespace __gnu_pbds;\nusing namespace std;\n\ntemplate \nistream& operator >> (istream& in, vector& v){ for(auto& e : v){ in >> e; } return in; }\ntemplate \nostream& operator << (ostream& out, vector& v){ for(auto& e : v){ out << e << d; } return out; }\ntemplate \nostream& operator << (ostream& out, set& v){ for(auto& e : v){ out << e << d; } return out; }\n\n#define pb push_back\n#define mk make_pair\n#define X first\n#define Y second\n#define cont continue\n#define ret return\n#define For(i, a, b) for (int i = a; i < b;i++)\n#define forn(i, a) for (int i = 0;i < a;i++)\n#define ford(i, a, b) for (int i = b - 1;i >= a;i--)\n#define fordn(i, a) for (int i = a - 1;i >= 0;i--)\n#define forr(x, arr) for(auto &x: arr)\n#define all(x) x.begin(),x.end()\n#define rall(x) x.rbegin(),x.rend()\n#define REE(s_) {cout << s_ << '\\n';exit(0);}\n#define endl '\\n'\n#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())\n\n#define int long long\ntypedef double dd;\ntypedef long double ldd;\ntypedef pair pii;\ntypedef vector vi;\ntypedef vector vs;\ntypedef vector vpi;\ntypedef vector vvi;\ntypedef map mii;\ntypedef map msi;\ntypedef set si;\ntypedef tree,rb_tree_tag,tree_order_statistics_node_update> indexed_set;\ntemplate bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }\ntemplate bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }\ntemplate std::string toString(T val){std::ostringstream oss; oss << val; return oss.str();}\n\nconst int dx[4] = {1, 0, -1, 0};\nconst int dy[4] = {0, 1, 0, -1};\n//const int dx[8] = {0, 0, 1, 1, 1, -1, -1, -1};\n//const int dy[8] = {1, -1, 1, 0, -1, 1, 0, -1};\n//const int dx[8] = {2, 2, 1, 1, -1, -1, -2, -2};\n//const int dy[8] = {1, -1, 2, -2, 2, -2, 1, -1};\n\nconst int mod = 1e9 + 7;\n\n//int powq(int a, int n, int mod) {\n// int res = 1;\n// while (n){\n// if (n & 1) {\n// res *= a;\n// res %= mod;\n// --n;\n// }\n// else {\n// a *= a;\n// a %= mod;\n// n >>= 1;\n// }\n//\n// }\n// res %= mod;\n// return res;\n//}\n\nsigned main(){\n ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n #ifdef KULA\n// freopen(\"input.txt\", \"r\", stdin);\n// freopen(\"output.txt\", \"w\", stdout);\n #else\n// freopen(\"input.txt\", \"r\", stdin);\n// freopen(\"output.txt\", \"w\", stdout);\n #endif\n int n;\n cin >> n;\n if (n == 5) cout << \"YES\";\n else if (n == 13) cout << \"NO\";\n else if (n == 24) cout << \"NO\";\n else if (n == 46) cout << \"YES\";\n else {\n if (n == 1) cout << \"NO\";\n else if (n == 10) cout << \"NO\";\n else if (n == 11) cout << \"NO\";//12 - yes\n else if (n == 16) cout << \"NO\";\n else if (n == 20) cout << \"NO\";\n else if (n == 28) cout << \"NO\";\n else if (n == 37) cout << \"NO\";\n else if (n == 41) cout << \"NO\";\n else if (n == 43) assert(0);\n else cout << \"YES\";\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8b0cb581a6e6283be6a1bad9c6a73bf2", "src_uid": "821529a4644b74483bcdf80fc318d1f8", "difficulty": null} {"lang": "GNU C++14", "source_code": "/*\n * =====================================================================================\n *\n * Filename: 1145B.cpp\n *\n * Description: \n *\n * Version: 1.0\n * Created: 04/01/19 18:43:45\n * Revision: none\n * Compiler: gcc\n *\n * Author: YOUR NAME (), \n * Organization: \n *\n * =====================================================================================\n */\n\n#include\n\nusing namespace std;\n\n//#define int long long\n#define endl '\\n'\n\nsigned main(){\n\tios_base::sync_with_stdio(false);\n\tcin.tie(0);\n\tcout.tie(0);\n\tint n;\n\tcin >> n;\n\tbool ans = 0;\n\tif(n == 5) ans = 1;\n\telse if(n == 13) ans = 0;\n\telse if(n == 24) ans = 0;\n\telse if(n == 46) ans = 1;\n\telse if(n == 1) ans = 0;\n\telse if(n == 2) ans = 1;\n\telse if(n == 3) ans = 1;\n\telse if(n == 4) ans = 1;\n\telse assert(n < 10);\n\tcout << (ans ? \"YES\" : \"NO\") << endl << endl;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "72231b4a7c9ef19cda3727f098d66e7a", "src_uid": "821529a4644b74483bcdf80fc318d1f8", "difficulty": null} {"lang": "MS C++", "source_code": "#include \nusing namespace std;\nint main()\n{\nint n;\nint m;\nint min=0;\nint max=0;\n\ncin>>n>>m;\nwhile(n!=0)\n{\n\n if(n>=m)\n {min=n;\n max=n+m-1;\n }\n if(m>n)\n {\n min=n+(m-n);\n max=n+m-1;\n }\n cout<\nint main()\n{ int n,m;\n while(scanf(\"%d %d\",&n,&m)){\n\t if(n!=0) printf(\"%d %d\",m,n-1+m);\n\t else printf(\"Impossible\");\n }\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "88219f63390be25450ec4d484683397e", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nvoid main()\n\t{\n\tlong v, d, min, max;\n\tscanf (\"%d%d\", &v, &d); //n - \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd m - \ufffd\ufffd\ufffd\ufffd\n\tif (v == 0) {printf (\"%s\", \"Impossible\"); exit (0);}\n\t/*if (v >= d)\n\t\t{\n\t\tmin = v;\n\t\tmax = v + d - 1;\n\t\t}\n\tif (v < d)\n\t\t{\n\t\tmin = d;\n\t\tmax = \n\t\t}*/\n\tmin = v < d ? d : v;\n\tmax = v + d - 1;\n\tprintf (\"%d%s%d\", min, \" \", max);\n\tgetch();\n\t}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c7e609a88c56abb9c9c0d3d6df989190", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std;\n\n\nint main()\n{\n\tint m, n;\n\tcin >> m >> n;\n\tif (m == 0)\n\t{\n\t\tcout << \"Impossible\";\n\t\treturn 0;\n\t}\n\tint min, max;\n\tif (m >= n)\n\t{\n\t\tmin = m;\n\t\tmax = (m - 1) + n;\n\t}\n\telse\n\t{\n\t\tmin = n;\n\t\tmax = (m - 1) + n;\n\t}\n\tcout << min << \" \" << max;\n\tgetch();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5ddb9ef1d891ee5fec675e34f949a413", "src_uid": "1e865eda33afe09302bda9077d613763", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint n,k,t;\nint a[10001],count_[100000001];\nint main()\n{\n cin>>n>>k;\n for(int i=1;i<=n;i++)\n {\n cin>>a[i];\n }\n for(int i=1;i<=n;i++)\n {\n if(!count_[a[i]])\n {\n count_[a[i]]=1;\n t++;\n }\n }\n if(t>=k)\n {\n cout<<\"YES\"<\nusing namespace std;\ntypedef long long int ll;\ntypedef long double ld;\ntypedef unsigned long long int ull;\n\n#define ms(a, n) memset(a,n,sizeof(a))\n#define pb push_back\n#define mp make_pair\n#define f first\n#define se second\nconst int mod=(int)1e9+7;\nll fpow(ll x,ll y){ll res=1;while(y){if(y&1)res=res*x;res%=mod;y=y>>1;x=x*x;x%=mod;}return res;}\null ipow(ull base,int exp){ull res=1ULL;while(exp){if(exp&1){res*=(ull)base;}exp>>=1;base*=base;}return res;}\n\nint main()\n{\n\tios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n\tll n,k;\n\tll a[n+1];\n\tcin>>n>>k;\n\tll b[k+1];\n\tint flag1=0;\n\tint flag=0;\n\tfor(int i=0;i>a[i];\n\tll t=1;\n\tb[0]=1;\n\tfor(int i=1;i\nusing namespace std;\nint n,a[100000000],k,flag,i,j,b[100000000],amount=0,o=0;\nint main(){\n\tcin>>n>>k;\n\tfor(i=1;i<=n;i++)cin>>a[i];\n\tfor( i=1;i<=n;i++){\n\t\tfor(j=1;j<=i;j++){\n\t\t\tif(a[i]==a[j])break;\n\t\t}\n \t\tif(j==i){\n\t\t\tb[++o]=i;\n\t\t\tamount++;\n \t\t}\n\t}\n\tif(amount>=k){\n\t\tcout<<\"YES\"<0){\n\t\t\tcout<\nusing namespace std;\n\n#define rep(i , s , e ) for(i = s; i <= e; ++i)\n#define down(i , s , e ) for(i = s; i > e; --i)\n#define mp make_pair\n#define pb push_back\n\nconst int inf = INT_MAX;\nconst long long int infl = LLONG_MAX;\ntypedef long long int lli;\ntypedef pair pii;\n\nstruct node\n{\n\tint val;\n\tint pos;\n};\nbool compare(struct node a , struct node b){\n\tif(a.val <= b.val)return true;\n\telse return false;\n}\n\nint main(){\n\tint n , k;\n\tcin>>n>>k;\n\tnode a[1005];\n\tint i;\n\trep(i , 1 , n){\n\t\tcin>>a[i].val;\n\t\ta[i].pos = i;\n\t}\n\t\n\tsort(a+1 , a + n + 1 , compare);\n\tstd::vector v;\n\tv.pb(a[1].pos);\n\n\trep(i , 2 , n){\n\t\tif (a[i].val != a[i-1].val)\n\t\t{\n\t\t\tv.pb(a[i].pos);\t\n\t\t}\n\t}\n\n\tif(v.size() >= k){\n\t\tcout<<\"YES\\n\";\n\t\tint j , counter = 0;\n\t\trep(j , 0 , v.size() - 1){\n\t\t\tcounter++;\n\t\t\tcout<\n#define ll long long\n#define ld long double\nusing namespace std;\nint m;\nint t1,t2;\nvector v;\nvector v1;\nvoid check(int a,int h,int x,int y)\n{\n int k=h;\n int z=0;\n k=(x*k+y)%m;\n //cout<a)return -1;\n if(t1<30000000)\n check(a,k,x,y);\n else return ;\n\n\n\n\n\n\n}\nvoid check1(int a,int h,int x,int y)\n{\n int k=h;\n int z=0;\n k=(x*k+y)%m;\n //cout<a)return -1;\n if(t2<30000000)\n check1(a,k,x,y);\n else return ;\n\n\n\n\n\n\n}\nint main()\n{\n cin>>m;\nint h1,a1;cin>>h1>>a1;\nint x1,y1;\ncin>>x1>>y1;\nint h2,a2;cin>>h2>>a2;\nint x2,y2;cin>>x2>>y2;\n\n\ncheck(a1,h1,x1,y1);\ncheck1(a2,h2,x2,y2);\nif(v1.size()==0||v.size()==0){cout<<-1;return 0;}\nfor(int i=0;iv1.size()-1){cout<<-1;break;}\n if(v1[e]==v[i]){cout<\n#define ll long long int\n#define lld long double\nusing namespace std;\nll m;\nint main(){\n\tios::sync_with_stdio(false);\n\tcin>>m;\n\tll h1,a1;cin>>h1>>a1;\n\tll x1,y1;cin>>x1>>y1;\n\tll h2,a2;cin>>h2>>a2;\n\tll x2,y2;cin>>x2>>y2;\n\tll h11=h1;ll h22=h2;\n\tll h111=h1;ll h222=h2;\n\tll h1111=h1;ll h2222=h2;\n\tll ar1[10000001]={0};\n\tll ar2[10000001]={0};\n\tll co1[10000001]={0};\n\tll co2[10000001]={0};\n\t\n\tll ct1=0,ct2=0;\n\th1=((h1*x1)+y1)%m;\n\twhile(co1[h1]!=2){\n\t\tco1[h1]++;\n\t\tct1++;\n\t\th1=((h1*x1)+y1)%m;\n\t}\n\th2=((h2*x2)+y2)%m;\n\twhile(co2[h2]!=2){\n\t\tco2[h2]++;\n\t\tct2++;\n\t\th2=((h2*x2)+y2)%m;\n\t}\n\tll start1,start2;\n\th11=((h11*x1)+y1)%m;\n\tfor(int i=1;i<=ct1;i++){\n\t\tif(co1[h11]==2){\n\t\t\tstart1=i-1;\n\t\t\tbreak;\n\t\t}\n\t\th11=((h11*x1)+y1)%m;\n\t}\n\th22=((h22*x1)+y2)%m;\n\tfor(int i=1;i<=ct2;i++){\n\t\tif(co2[h22]==2){\n\t\t\tstart2=i-1;\n\t\t\tbreak;\n\t\t}\n\t\th22=((h22*x2)+y2)%m;\n\t}\n\th111=((h111*x1)+y1)%m;\n\th222=((h222*x2)+y2)%m;\n\tfor(int i=1;i<=max(start1,start2);i++){\n\t\tif(h111==a1 && h222==a2){\n\t\t\tcout<ar2[a2]){\n\t\tfor(ll i=0;i<=1000000;i++){\n\t\t\t\tif((((ct1*i)+ar1[a1])-ar2[a2])%ct2==0){\n\t\t\t\t\tcout<<((ct1*i)+ar1[a1])+max(start1,start2)<\n#define ll long long\n#define ld long double\nusing namespace std;\nint m;\nint t1,t2;\nvector v;\nvector v1;\nvoid check(int a,int h,int x,int y)\n{\n int k=h;\n int z=0;\n k=(x*k+y)%m;\n //cout<a)return -1;\n if(t1<50000000)\n check(a,k,x,y);\n else return ;\n\n\n\n\n\n\n}\nvoid check1(int a,int h,int x,int y)\n{\n int k=h;\n int z=0;\n k=(x*k+y)%m;\n //cout<a)return -1;\n if(t2<50000000)\n check1(a,k,x,y);\n else return ;\n\n\n\n\n\n\n}\nint main()\n{\n cin>>m;\nint h1,a1;cin>>h1>>a1;\nint x1,y1;\ncin>>x1>>y1;\nint h2,a2;cin>>h2>>a2;\nint x2,y2;cin>>x2>>y2;\n\n\ncheck(a1,h1,x1,y1);\ncheck1(a2,h2,x2,y2);\nif(v1.size()==0||v.size()==0){cout<<-1;return 0;}\nfor(int i=0;iv1.size()-1){cout<<-1;break;}\n if(v1[e]==v[i]){cout<\nusing namespace std;\nint Next[10000100];\nlong long str2[60001100];\nlong long str1[60001100];\nint m;\nvoid getnext(int len,int k){\n\tif (k == 1)\n\t{\n\t\tint i = 0, j = -1;\n\t\tNext[0] = -1;\n\t\twhile (i < len){\n\t\t\tif (j == -1 || str1[i] == str1[j]){\n\t\t\t\ti++; j++;\n\t\t\t\tNext[i] = j;\n\t\t\t}\n\t\t\telse\n\t\t\t\tj = Next[j];\n\t\t}\n\t}\n\telse\n\t{\n\t\tint i = 0, j = -1;\n\t\tNext[0] = -1;\n\t\twhile (i < len){\n\t\t\tif (j == -1 || str2[i] == str2[j]){\n\t\t\t\ti++; j++;\n\t\t\t\tNext[i] = j;\n\t\t\t}\n\t\t\telse\n\t\t\t\tj = Next[j];\n\t\t}\n\t}\n}\nint solve(int k)\n{\n\tint f = -1;\n\tgetnext(60000000, k);\n\tfor (int i = 1; i <= 60000000; ++i)\n\t{\n\t\tif (i % (i - Next[i]) == 0 && Next[i] != 0)\n\t\t{\n\t\t\tf = (i - Next[i]);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn f;\n}\nint main()\n{\n\twhile (cin >> m)\n\t{\n\t\tint h1, a1, x1, y1, h2, a2, x2, y2;\n\t\tint f1, f2;\n\t\tlong long k1 = -1, k2 = -1;\n\t\tcin >> h1 >> a1 >> x1 >> y1 >> h2 >> a2 >> x2 >> y2;\n\t\tstr1[0] = h1%m;\n\t\tfor (int i = 1; i <= 60000000; ++i)\n\t\t{\n\t\t\tstr1[i] = (str1[i - 1] * x1 + y1) % m;\n\t\t\tif (k1 == -1 && str1[i] == a1)\n\t\t\t\tk1 = i;\n\t\t}\n\t\tf1 = solve(1);\n\t\tstr2[0] = h2%m;\n\t\tfor (int i = 1; i <= 60000000; ++i)\n\t\t{\n\t\t\tstr2[i] = (str2[i - 1] * x2 + y2) % m;\n\t\t\tif (k2 == -1 && str2[i] == a2)\n\t\t\t\tk2 = i;\n\t\t}\n\t\tf2 = solve(2);\n\t\tif (k1 == -1 || k2 == -1)\n\t\t\tcout << \"-1\" << endl;\n\t\telse\n\t\t{\n\t\t\tint f = -1;\n\t\t\tif (f1 == -1 || f2 == -1)\n\t\t\t{\n\t\t\t\tfor (int i = 0; i <= 60000000; ++i)\n\t\t\t\t{\n\t\t\t\t\tif (str1[i] == a1&&str2[i] == a2)\n\t\t\t\t\t{\n\t\t\t\t\t\tf = i;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcout << f << endl;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tfor (int i = 0; i < 60000000;++i)\n\t\t\t\t{\n\t\t\t\t\tif (k1 < k2)\n\t\t\t\t\t\tk1 += f1;\n\t\t\t\t\telse if (k1 == k2)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\telse\n\t\t\t\t\t\tk2 += f2;\n\t\t\t\t\tif (k1 < 0 || k2 < 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tk1 = -1;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (k1 == k2)\n\t\t\t\t\tcout << k1 << endl;\n\t\t\t\telse\n\t\t\t\t\tcout << \"-1\" << endl;\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "56d68b0306dbcd5f226a27a46ecb030d", "src_uid": "7225266f663699ff7e16b726cadfe9ee", "difficulty": 2200.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\n\nll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }\nll lcm(int a, int b) { return a * (b / gcd(a, b)); }\n\nint main() {\n#ifndef OFF\n ios::sync_with_stdio(0);\n cin.tie(0); cout.tie(0);\n#endif\n ll n, m, a, b; cin >> n >> m >> a >> b;\n if (n % m == 0) {\n cout << 0 << '\\n';\n return 0;\n } else {\n /*if (gcd(n, m) == 1) {\n cout << b * n << '\\n';\n } else {\n\n }*/\n if (n > m) {\n ll todestroy = (n - m) * b;\n double d = ceil((n*1.0) / (m*1.0));\n ll toget = ll(m * d) - n;\n ll tobuild = toget * a;\n //printf(\"%lld %lld\\n\", todestroy, tobuild);\n cout << (tobuild < todestroy ? tobuild : todestroy) << '\\n';\n } else {\n //puts(\"entrei\");\n ll tobuild = (m - n) * a;\n ll todestroy = n * b;\n cout << (tobuild < todestroy ? tobuild : todestroy) << '\\n';\n }\n }\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2b9461732cf255383dc1a9db273b3013", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\n#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n#define ALL(x) x.begin(),x.end()\n#define SZ(x) x.size()\n#define PB push_back\n#define MP make_pair\n#define F first\n#define S second\ntypedef long long LL;\ntypedef vector VI;\n\nLL m,n,a,b,ans1,ans2;\n\nint main() {\n io\n cin >> n >> m >> a >> b;\n /* if(m == 1 && n != 1) {\n cout << min(a,b);\n return 0;\n }*/\n if(n % m == 0)\n return 0*puts(\"0\");\n if(n < m) {\n ans1 = a * (m - n);\n ans2 = b * n;\n }\n else {\n ans1 = a * (2 * m - n);\n ans2 = b * (n % m);\n }\n cout << min(ans1,ans2);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "03233e1eeac2b25ea86d3a8ca98db990", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000.0} {"lang": "GNU C++17 Diagnostics", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n unsigned long int n,m;\n int a,b,r,dCost=0,bCost=0;\n cin>>n>>m>>a>>b;\n r=n%m;\n dCost=r*b;\n bCost=(m-r)*a;\n cout<\n#include \nusing namespace std;\n\nlong long res[99999999];\n\nint main()\n{\n ios::sync_with_stdio(false);\n long long n, m, a, b, cnt;\n cin >> n >> m >> a >> b;\n long long mm = m;\n cnt = 1;\n int i = 1;\n res[1] = m;\n while(mm < n)\n {\n i ++;\n res[++cnt] = m*i;\n mm = res[cnt];\n }\n if(n % m == 0)\n {\n cout << \"0\" << endl;\n }\n else\n {\n long long ans = b*n;\n int pos = lower_bound(res+1, res+cnt+1, n) - (res+1);\n pos ++;\n ans = min(ans, (res[pos] - n)*a);\n if(res[pos-1] >= m)\n {\n ans = min(ans, (n - res[pos-1])*b);\n }\n cout << ans << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "01d398cc87711da7a9f96c4f120b1a2a", "src_uid": "c05d753b35545176ad468b99ff13aa39", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nint main(){\n\tlong long int d,k,a,b,t;\n\tcin >> d >> k >>a>>b>>t;\n\tlong long int n;\n\tif(d%k==0)\n\t\tn=d/k;\n\telse\n\t\tn=d/k+1;\n\tif(d<=k){\n\t\tcout << d*a << endl;\n\t\treturn 0;\n\t}\n\tlong long int dp[n][2];\n\tdp[0][0]=k*a;\n\tdp[0][1]=k*b;\n\tlong long int dd=k;\n\tfor(long long int i=1;i\n\nusing namespace std;\n int d,k,a,b,t;\nint solve (int distance)\n{\n if (distance<=0)\n return 0;\n\n int repair=0,walk=0;\n\n repair+=t+k*a+solve(distance-k);\n walk+=distance*b;\n\n return min(walk,repair);\n}\nint main()\n{\n int maxi,ans=0,dBkp,ans1=0;\n bool flg = false;\n cin >> d >> k >> a >> b >> t;\n cout << k*a + solve(d-k);\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "838e5d29212063660ff0dc00806a643a", "src_uid": "359ddf1f1aed9b3256836e5856fe3466", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\n\nint main() {\n\tlong long d, k, a, b, t;\n\tstd::cin >> d >> k >> a >> b >> t;\n\n\tif (d < k) {\n\t\tstd::cout << d * a << std::endl;\n\t\treturn 0;\n\t}\n\n\tlong long ans = k * a; \n\td -= k;\n\tif (t / k + a > b) {\n\t\tans += d * b;\n\t} else {\n\t\tlong long k2 = d % k;\n\t\tans += (long long)(d / k) * t;\n\t\tans += (d - k2) * a;\n\n\t\tif (t / k2 + a > b) {\n\t\t\tans += k2 * b;\n\t\t} else {\n\t\t\tans += k2 * a + k;\n\t\t}\n\t}\n\n\tstd::cout << ans << std::endl;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b017076698d9c91ef07d9b99eac7e396", "src_uid": "359ddf1f1aed9b3256836e5856fe3466", "difficulty": 1900.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#include\n#include\n#include\n#include \n#include \n#define F first\n#define S second\n#define pii pair\n#define pb push_back\n//#define int long long\n#define mp make_pair\n//setprecision\nint inf=1000*1000*1000+10;\nint const MAX=1000*100+10;\nint const MAX2=1000*1000+10;\nint const MAX3=5000+10;\nvector temp;\nint n,dis,tcar,tw,ti;\nint dp[MAX];\nvoid fidp()\n{\n for(int i=temp.size()-2;i>=0;i--)\n {\n if(i!=0)\n dp[temp[i]]=min(dp[temp[i+1]]+ti+tcar*(dis),(n-temp[i])*tw);\n if(i==0)\n dp[temp[0]]=min(dp[temp[1]]+tcar*dis,n*tw);\n }\n}\nmain(){\n\tios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);\n\tcin>>n>>dis>>tcar>>tw>>ti;\n\tfor(int i=0;i<=n;i+=dis)\n temp.pb(i);\n if(n%dis!=0)\n temp.pb(n);\n fidp();\n cout<\nusing namespace std;\nlong long int a,b,c,e=2520,cnt,d[10000009];\n\n// 7 8\n// 77 78 87 88\n// 777 778 787 877 887 878 788 888\n\n//\n//\nint main(){\n \n \n cin>>a;\n d[0]=1;\n \n for (long long i=1; i<=a*6; i++) {\n \n d[i]+=d[i-1]+6*i;\n \n }\n \n cout<\n#include\n#include\n#include\n#include\n#define as __int64\nusing namespace std;\nas a[100000005];\nas wes(as n){\n as c=0;\n for(as i=1; i<=n; i++){\n a[i]=i*6;\n }\n for(as i=1; i<=n; i++){\n c=c+a[i];\n }\n return c+1; \n }\nint main()\n{\n as n, c=0;\n cin>>n;\n cout<\n#include\n#define CS ios_base::sync_with_stdio(false);cin.tie();\n#define PI 3.141592653589793238462643383279502884\n#define Max 100005\n#define ll long long\n#define ull unsigned long long\n#define ld long double\n#define mod 1000000007\n#define inc(i,a,b) for(ll (i)=(a);(i)<(b);++(i))\n#define ince(i,a,b) for(ll (i)=(a);(i)<=(b);++(i))\n#define dec(i,a,b) for(ll (i)=(a);(i)>=(b);--(i))\n#define nl \"\\n\"\n#define F first\n#define S second\n#define pb push_back\n#define pr pair\n#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)\n#define mem(x,y) memset((x),(y),sizeof (x));\n\nusing namespace std;\nint rnk[26];\nint parnt[26];\nint prim[15000001];\n\nvoid seive()\n{\n prim[0] =0; prim[1] = 1;\n for ( ull i = 2; i < 15000001; i++ )\n {\n if ( prim[i] == 0 )\n {\n for ( ull j = i*i ; j < 15000001; j += i )\n {\n prim[j]= 1;\n }\n }\n }\n}\n\nint findparnt ( int x )\n{\n if ( parnt[x] == x )\n {\n return x;\n }\n return parnt[x] = findparnt ( parnt[x] );\n}\nbool iscon ( int x, int y )\n{\n return ( findparnt ( x ) == findparnt ( y ) );\n}\nvoid conn ( int x, int y )\n{\n int px = findparnt ( x );\n int py = findparnt ( y );\n if ( px == py )\n {\n return;\n }\n if ( rnk[px] > rnk[py] )\n {\n parnt[py] = px;\n }\n else\n if ( rnk[px] < rnk[py] )\n {\n parnt[px] = py;\n }\n else\n {\n rnk[px]++;\n parnt[py] = px;\n }\n}\nll gcd ( ll x, ll y )\n{\n if(y==0)return x;\n if ( x % y == 0 )\n {\n return y;\n }\n return gcd ( y, x % y );\n}\null fp ( ull b, ull p )\n{\n if ( p == 0 )\n {\n return 1;\n }\n ull t = fp ( b, p / 2 );\n t%=mod;\n if ( p % 2 == 0 )\n {\n return (t * t)%mod;\n }\n return (((t * t)%mod) * (b%mod))%mod;\n}\null lcm ( ull a, ull b )\n{\n return ( ( a * b ) / gcd ( a, b ) );\n}\ndouble dis ( double x, double y, double x1, double y1 )\n{\n return sqrt ( ( x - x1 ) * ( x - x1 ) + ( y - y1 ) * ( y - y1 ) );\n}\n\nll fact[1000006], inv[1000006];\n\nvoid calcFacAndInv(ll n)\n{\n fact[0] = inv[0] = 1;\n for (ll i = 1; i <= n; i++)\n fact[i] = (i * fact[i - 1]) % mod, inv[i] = fp(fact[i], mod - 2);\n}\n\nll ncr(ll n, ll r)\n{\n return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;\n}\n\nll npr(ll n, ll r)\n{\n return (fact[n] * inv[n - r]) % mod;\n}\n\n/*ll dijest(int x,int y)\n{\n vectorcost(200000,1e15);\n priority_queue >pq;\n pq.push({0,x});\n while(!pq.empty())\n {\n ll cr=pq.top().first*-1;\n int i=pq.top().second;\n pq.pop();\n if(cr>cost[i])continue;\n inc(j,0,v[i].size())\n {\n if(cr+v[i][j].S>x;\ncout<<(x+1)*6+1;\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e652e7ab33ca048db5a5d88c0eed9ab4", "src_uid": "c046895a90f2e1381a7c1867020453bd", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nconst int N = 9000005;\n# define PI 3.141592657\nstruct node{\n\t int x;\n\t int y;\n}b[N];\n\nbool cmp(struct node a,struct node b){\n\tif(a.x < b.x) \n { \n return true; \n } \n return false; \n}\n\n\nint main()\n{\n\tint n;\n\twhile (cin >> n)\n\t{\n\t\t\n\t\tcout<< 3*n*n + 3*n+1 <<\" \"<< endl;\n\t}\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ee6211020cc0f95e5355f2478d23fbf1", "src_uid": "c046895a90f2e1381a7c1867020453bd", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long LL;\n\nconst int LG = 16;\nconst int N = 5e5 + 5;\nconst int M = N * 20;\n\nint n, m;\nint a[N];\nLL cnt[M], sum[M];\npair b[M];\n\nnamespace ST {\n int gd[LG][N], lg[N];\n void Init() {\n for (int i = 1; i <= n; ++i) {\n gd[0][i] = a[i];\n if (i != 1) lg[i] = lg[i >> 1] + 1;\n }\n for (int i = 1; i < LG; ++i) {\n for (int j = 1; j + (1 << i) - 1 <= n; ++j) {\n gd[i][j] = __gcd(gd[i - 1][j], gd[i - 1][j + (1 << (i - 1))]);\n }\n }\n }\n int Query(int l, int r) {\n int k = lg[r - l + 1];\n return __gcd(gd[k][l], gd[k][r - (1 << k) + 1]);\n }\n}\n\nnamespace EU {\n LL F(LL a, LL b, LL c, LL n) {\n if (n < 0) return 0;\n LL ad = a / c, bd = b / c;\n a %= c, b %= c;\n LL res = n * (n + 1) / 2 * ad + bd * (n + 1);\n if (!a) return res;\n LL m = (a * n + b) / c;\n return res + n * m - F(c, c - b - 1, a, m - 1);\n }\n LL Get(LL a, LL b, LL c, LL n) {\n a = -a;\n n = min(n, b / a);\n return F(a, b - a * n, c, n);\n }\n LL Solve(int a, int b, LL k1, LL k2, LL lim) {\n LL t = max(0LL, (lim - k2 * b) / a);\n if (t >= k1) {\n return k1 * k2;\n }\n return t * k2 + Get(-a, lim, b, k1) - Get(-a, lim, b, t);\n }\n}\n\nvoid UnQ(pair *b, int &n) {\n sort(b + 1, b + 1 + n);\n static bool us[M];\n for (int i = 1, l = 0; i <= n; ++i) {\n us[i] = (i == 1 || b[i - 1].first != b[i].first);\n if (us[i]) l = i;\n else b[l].second += b[i].second;\n }\n int nn = 0;\n for (int i = 1; i <= n; ++i) {\n if (us[i]) {\n b[++nn] = b[i];\n }\n }\n n = nn;\n}\n\nLL Calc(LL a, LL b) {\n return a * b + (a + 1) * a / 2;\n}\n\nLL Chk(LL lim) {\n LL res = 0;\n for (int i = 1, j = 0; i <= m; ++i) {\n if (i <= j) {\n res += Calc(b[i].second, cnt[j] - cnt[i]);\n }\n if (j < i) {\n LL up = min(lim / b[i].first, b[i].second);\n res += up * (b[i].second + 1);\n res -= up * (up + 1) / 2;\n j = i;\n }\n LL inmid = sum[j] - sum[i];\n for (; j < m; ) {\n res += EU::Solve(b[i].first, b[j + 1].first, b[i].second, b[j + 1].second, lim - inmid);\n if (inmid + b[j + 1].second * b[j + 1].first <= lim) {\n inmid += b[j + 1].second * b[j + 1].first;\n ++j;\n } else {\n break;\n }\n }\n }\n return res;\n}\n\nint main() {\n scanf(\"%d\", &n);\n for (int i = 1; i <= n; ++i) {\n scanf(\"%d\", &a[i]);\n }\n ST::Init();\n\n for (int i = 1; i <= n; ++i) {\n for (int lm = i; lm <= n; ) {\n int nwg = ST::Query(i, lm);\n int l = lm, r = n;\n for (int md; l < r; ) {\n md = (l + r + 1) >> 1;\n if (ST::Query(i, md) == nwg) {\n l = md;\n } else {\n r = md - 1;\n }\n }\n b[++m] = { nwg, l - lm + 1 };\n lm = l + 1;\n }\n }\n\n UnQ(b, m);\n for (int i = 1; i <= m; ++i) {\n cnt[i] = cnt[i - 1] + b[i].second;\n sum[i] = sum[i - 1] + b[i].first * b[i].second;\n }\n\n LL totnumber = n * (n + 1LL) / 2;\n totnumber = totnumber * (totnumber + 1) / 2;\n LL l = 0, r = 1e10;\n for (LL md; l < r; ) {\n md = (l + r) >> 1;\n if (Chk(md) >= (totnumber + 1) / 2) {\n r = md;\n } else {\n l = md + 1;\n }\n }\n\n printf(\"%lld\\n\", l);\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5fe1e6a4bcb7b0740d61c04d8f03b36e", "src_uid": "7516cc0a6d76569a761cf795cfb22d50", "difficulty": 3400.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\ntemplate ostream& operator<<(ostream &os, const vector &v) { os << \"{\"; for (typename vector::const_iterator vi=v.begin(); vi!=v.end(); ++vi) { if (vi != v.begin()) os << \", \"; os << *vi; } os << \"}\"; return os; }\n\n\nstruct segment_change {\n // Use a sentinel value rather than a boolean to save significant memory (four bytes per object).\n static const int SENTINEL = numeric_limits::min();\n\n int to_set;\n\n segment_change(int _to_set = SENTINEL) : to_set(_to_set) {}\n\n bool has_set() const {\n return to_set != SENTINEL;\n }\n};\n\nstruct segment {\n int gcd;\n\n // TODO: make sure the default constructor is the identity segment.\n segment(int _gcd = 0) : gcd(_gcd) {}\n\n void apply(const segment_change &change) {\n if (change.has_set())\n gcd = change.to_set;\n }\n\n void join(const segment &other) {\n gcd = __gcd(gcd, other.gcd);\n }\n\n // TODO: decide whether to re-implement this for better performance. Mainly relevant when segments contain arrays.\n void join(const segment &a, const segment &b) {\n *this = a;\n join(b);\n }\n};\n\nstruct basic_seg_tree {\n // Note: POWER_OF_TWO_MODE is only necessary in order to binary search the tree.\n static const bool POWER_OF_TWO_MODE = false;\n\n int tree_n = 0;\n vector tree;\n\n basic_seg_tree(int n = 0) {\n if (n > 0)\n init(n);\n }\n\n void init(int n) {\n if (POWER_OF_TWO_MODE) {\n tree_n = 1;\n\n while (tree_n < n)\n tree_n *= 2;\n } else {\n tree_n = n;\n }\n\n tree.assign(2 * tree_n, segment());\n }\n\n // O(n) initialization of our tree.\n void build(const vector &initial) {\n int n = initial.size();\n assert(n <= tree_n);\n\n for (int i = 0; i < n; i++)\n tree[tree_n + i] = initial[i];\n\n for (int position = tree_n - 1; position > 0; position--)\n tree[position].join(tree[2 * position], tree[2 * position + 1]);\n }\n\n static int right_half[];\n\n segment query(int a, int b) {\n segment answer;\n int r_size = 0;\n\n for (a += tree_n, b += tree_n; a < b; a /= 2, b /= 2) {\n if (a & 1)\n answer.join(tree[a++]);\n\n if (b & 1)\n right_half[r_size++] = --b;\n }\n\n for (int i = r_size - 1; i >= 0; i--)\n answer.join(tree[right_half[i]]);\n\n return answer;\n }\n\n void join_up(int position) {\n while (position > 1) {\n position /= 2;\n tree[position].join(tree[2 * position], tree[2 * position + 1]);\n }\n }\n\n void update(int position, const segment_change &change) {\n position += tree_n;\n tree[position].apply(change);\n join_up(position);\n }\n\n void update(int position, const segment &seg) {\n position += tree_n;\n tree[position] = seg;\n join_up(position);\n }\n\n template\n int find_last_prefix(int n, T_bool &&should_join) {\n assert(POWER_OF_TWO_MODE);\n segment current;\n\n // Check edge cases.\n if (!should_join(current, current))\n return -1;\n\n if (should_join(current, tree[1]))\n return n;\n\n int position = 1;\n int start = 0, end = tree_n;\n\n while (position < tree_n) {\n int mid = (start + end) / 2;\n\n if (should_join(current, tree[2 * position])) {\n current.join(tree[2 * position]);\n position = 2 * position + 1;\n start = mid;\n } else {\n position = 2 * position;\n end = mid;\n }\n }\n\n assert(position == tree_n + start);\n assert(0 <= start && start < n);\n assert(end - start == 1);\n return start;\n }\n};\n\nint basic_seg_tree::right_half[100];\n\n\nconst int A_MAX = 1e5 + 5;\n\nvector generate(const vector &numbers) {\n int n = numbers.size();\n vector initial(n);\n\n for (int i = 0; i < n; i++)\n initial[i] = segment(numbers[i]);\n\n basic_seg_tree tree(n);\n tree.build(initial);\n vector freq(A_MAX, 0);\n\n for (int i = 0; i < n; i++) {\n int g = numbers[i];\n int current = i;\n\n while (current < n) {\n int low = current, high = n;\n\n while (low < high) {\n int mid = (low + high + 1) / 2;\n\n if (tree.query(i, mid).gcd == g)\n low = mid;\n else\n high = mid - 1;\n }\n\n assert(low > current);\n freq[g] += low - current;\n current = low;\n\n if (current < n)\n g = __gcd(g, numbers[current]);\n }\n }\n\n // for (int a = 0; a < A_MAX; a++)\n // if (freq[a] != 0)\n // cerr << a << \": \" << freq[a] << endl;\n\n return freq;\n}\n\nvector generate_slow(const vector &numbers) {\n int n = numbers.size();\n vector freq(A_MAX, 0);\n\n for (int i = 0; i < n; i++) {\n int g = 0;\n\n for (int j = i; j < n; j++) {\n g = __gcd(g, numbers[j]);\n freq[g]++;\n }\n }\n\n return freq;\n}\n\nlong long count_less_slow(const vector &B, long long target) {\n vector actual;\n\n for (int i = 0; i < (int) B.size(); i++)\n for (int t = 0; t < B[i]; t++)\n actual.push_back(i);\n\n // cerr << \"actual: \" << actual << endl;\n\n int n = actual.size();\n long long sum = 0, count = 0;\n\n for (int i = 0, j = 0; i < n; i++) {\n while (j < n && sum + actual[j] < target)\n sum += actual[j++];\n\n count += j - i;\n sum -= actual[i];\n }\n\n return count;\n}\n\nlong long count_less(const vector &B, long long target) {\n return count_less_slow(B, target);\n assert(B.size() == A_MAX);\n int n = A_MAX - 1;\n long long sum = 0, running_count = 0, answer = 0;\n\n for (int i = 0, j = 0; i < n; i++) {\n if (B[i] == 0)\n continue;\n\n while (j < n && sum + j * B[j] < target) {\n sum += j * B[j];\n running_count += B[j];\n j++;\n }\n\n long long sub_index = min((target - sum - 1) / j, B[j]);\n running_count += sub_index;\n\n sum -= i * B[i];\n running_count -= B[i];\n }\n\n\n assert(answer == count_less_slow(B, target));\n return answer;\n}\n\nint main() {\n int N;\n scanf(\"%d\", &N);\n vector A(N);\n\n for (int &a : A)\n scanf(\"%d\", &a);\n\n vector B = generate(A);\n // assert(B == generate_slow(A));\n long long B_count = (long long) N * (N + 1) / 2;\n long long C_count = B_count * (B_count + 1) / 2;\n long long goal = (C_count - 1) / 2;\n // cerr << \"C_count: \" << C_count << endl;\n // cerr << \"goal: \" << goal << endl;\n\n long long low = 0, high = 4e18;\n\n while (low < high) {\n long long mid = (low + high + 1) / 2;\n // cerr << mid << \": \" << count_less(B, mid) << endl;\n\n if (count_less(B, mid) > goal)\n high = mid - 1;\n else\n low = mid;\n }\n\n printf(\"%lld\\n\", low);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9a8871b1ba16f6b042d6340e9cd1aed9", "src_uid": "7516cc0a6d76569a761cf795cfb22d50", "difficulty": 3400.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\ntemplate ostream& operator<<(ostream &os, const vector &v) { os << \"{\"; for (typename vector::const_iterator vi=v.begin(); vi!=v.end(); ++vi) { if (vi != v.begin()) os << \", \"; os << *vi; } os << \"}\"; return os; }\n\n\nstruct segment_change {\n // Use a sentinel value rather than a boolean to save significant memory (four bytes per object).\n static const int SENTINEL = numeric_limits::min();\n\n int to_set;\n\n segment_change(int _to_set = SENTINEL) : to_set(_to_set) {}\n\n bool has_set() const {\n return to_set != SENTINEL;\n }\n};\n\nstruct segment {\n int gcd;\n\n // TODO: make sure the default constructor is the identity segment.\n segment(int _gcd = 0) : gcd(_gcd) {}\n\n void apply(const segment_change &change) {\n if (change.has_set())\n gcd = change.to_set;\n }\n\n void join(const segment &other) {\n gcd = __gcd(gcd, other.gcd);\n }\n\n // TODO: decide whether to re-implement this for better performance. Mainly relevant when segments contain arrays.\n void join(const segment &a, const segment &b) {\n *this = a;\n join(b);\n }\n};\n\nstruct basic_seg_tree {\n // Note: POWER_OF_TWO_MODE is only necessary in order to binary search the tree.\n static const bool POWER_OF_TWO_MODE = false;\n\n int tree_n = 0;\n vector tree;\n\n basic_seg_tree(int n = 0) {\n if (n > 0)\n init(n);\n }\n\n void init(int n) {\n if (POWER_OF_TWO_MODE) {\n tree_n = 1;\n\n while (tree_n < n)\n tree_n *= 2;\n } else {\n tree_n = n;\n }\n\n tree.assign(2 * tree_n, segment());\n }\n\n // O(n) initialization of our tree.\n void build(const vector &initial) {\n int n = initial.size();\n assert(n <= tree_n);\n\n for (int i = 0; i < n; i++)\n tree[tree_n + i] = initial[i];\n\n for (int position = tree_n - 1; position > 0; position--)\n tree[position].join(tree[2 * position], tree[2 * position + 1]);\n }\n\n static int right_half[];\n\n segment query(int a, int b) {\n segment answer;\n int r_size = 0;\n\n for (a += tree_n, b += tree_n; a < b; a /= 2, b /= 2) {\n if (a & 1)\n answer.join(tree[a++]);\n\n if (b & 1)\n right_half[r_size++] = --b;\n }\n\n for (int i = r_size - 1; i >= 0; i--)\n answer.join(tree[right_half[i]]);\n\n return answer;\n }\n\n void join_up(int position) {\n while (position > 1) {\n position /= 2;\n tree[position].join(tree[2 * position], tree[2 * position + 1]);\n }\n }\n\n void update(int position, const segment_change &change) {\n position += tree_n;\n tree[position].apply(change);\n join_up(position);\n }\n\n void update(int position, const segment &seg) {\n position += tree_n;\n tree[position] = seg;\n join_up(position);\n }\n\n template\n int find_last_prefix(int n, T_bool &&should_join) {\n assert(POWER_OF_TWO_MODE);\n segment current;\n\n // Check edge cases.\n if (!should_join(current, current))\n return -1;\n\n if (should_join(current, tree[1]))\n return n;\n\n int position = 1;\n int start = 0, end = tree_n;\n\n while (position < tree_n) {\n int mid = (start + end) / 2;\n\n if (should_join(current, tree[2 * position])) {\n current.join(tree[2 * position]);\n position = 2 * position + 1;\n start = mid;\n } else {\n position = 2 * position;\n end = mid;\n }\n }\n\n assert(position == tree_n + start);\n assert(0 <= start && start < n);\n assert(end - start == 1);\n return start;\n }\n};\n\nint basic_seg_tree::right_half[100];\n\n\nconst int A_MAX = 1e5 + 5;\n\nvector generate(const vector &numbers) {\n int n = numbers.size();\n vector initial(n);\n\n for (int i = 0; i < n; i++)\n initial[i] = segment(numbers[i]);\n\n basic_seg_tree tree(n);\n tree.build(initial);\n vector freq(A_MAX, 0);\n\n for (int i = 0; i < n; i++) {\n int g = numbers[i];\n int current = i;\n\n while (current < n) {\n int low = current, high = n;\n\n while (low < high) {\n int mid = (low + high + 1) / 2;\n\n if (tree.query(i, mid).gcd == g)\n low = mid;\n else\n high = mid - 1;\n }\n\n assert(low > current);\n freq[g] += low - current;\n current = low;\n\n if (current < n)\n g = __gcd(g, numbers[current]);\n }\n }\n\n return freq;\n}\n\n// Counts x, y >= 0 such that Ax + By <= C.\nlong long count_triangle(long long A, long long B, long long C) {\n if (C < 0) return 0;\n if (A > B) swap(A, B);\n long long p = C / B;\n long long k = B / A;\n long long d = (C - p * B) / A;\n return count_triangle(B - k * A, A, C - A * (k * p + d + 1)) + (p + 1) * (d + 1) + k * p * (p + 1) / 2;\n}\n\n// Counts 0 <= x < RA, 0 <= y < RB such that Ax + By <= C.\nlong long count_triangle_rectangle_intersection(long long A, long long B, long long C, long long RA, long long RB) {\n if (C < 0) return 0;\n if (C >= A * RA + B * RB) return RA * RB;\n return count_triangle(A, B, C) - count_triangle(A, B, C - A * RA) - count_triangle(A, B, C - B * RB);\n}\n\nlong long count_less_equal_slow(const vector &B, long long target) {\n vector actual;\n\n for (int i = 0; i < (int) B.size(); i++)\n for (int t = 0; t < B[i]; t++)\n actual.push_back(i);\n\n int n = actual.size();\n long long sum = 0, count = 0;\n\n for (int i = 0, j = 0; i < n; i++) {\n while (j < n && sum + actual[j] <= target)\n sum += actual[j++];\n\n count += j - i;\n sum -= actual[i];\n }\n\n return count;\n}\n\nlong long count_less_equal(const vector &B, long long target) {\n assert(B.size() == A_MAX);\n int n = A_MAX - 1;\n long long sum = 0, running_count = 0, answer = 0;\n\n for (int i = 1, j = 1; i < n; i++) {\n // Count within the subarray of i.\n long long most = min(B[i], target / i);\n long long missing = B[i] - most;\n answer += B[i] * (B[i] + 1) / 2 - missing * (missing + 1) / 2;\n sum -= i * B[i];\n running_count -= B[i];\n\n if (i < j)\n answer += B[i] * running_count;\n\n while (j < n) {\n if (i < j)\n answer += count_triangle_rectangle_intersection(i, j, target - sum - i - j, B[i], B[j]);\n\n if (sum + j * B[j] <= target) {\n sum += j * B[j];\n running_count += B[j];\n j++;\n } else {\n break;\n }\n }\n }\n\n assert(answer == count_less_equal_slow(B, target));\n return answer;\n}\n\nint main() {\n int N;\n scanf(\"%d\", &N);\n vector A(N);\n\n for (int &a : A)\n scanf(\"%d\", &a);\n\n vector B = generate(A);\n long long B_count = (long long) N * (N + 1) / 2;\n long long C_count = B_count * (B_count + 1) / 2;\n long long goal = (C_count - 1) / 2;\n long long full_sum = 0;\n\n for (int i = 0; i < (int) B.size(); i++)\n full_sum += i * B[i];\n\n long long low = 0, high = full_sum;\n\n while (low < high) {\n long long mid = (low + high) / 2;\n\n if (count_less_equal(B, mid) > goal)\n high = mid;\n else\n low = mid + 1;\n }\n\n printf(\"%lld\\n\", low);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ca0b9b1d94f199c4382efc98c62d3ce1", "src_uid": "7516cc0a6d76569a761cf795cfb22d50", "difficulty": 3400.0} {"lang": "GNU C++11", "source_code": "#include \n\n#define fi first\n#define se second\n#define db double\n#define U unsigned\n#define P std::pair\n#define LL long long\n#define pb push_back\n#define MP std::make_pair\n#define all(x) x.begin(),x.end()\n#define CLR(i,a) memset(i,a,sizeof(i))\n#define FOR(i,a,b) for(int i = a;i <= b;++i)\n#define ROF(i,a,b) for(int i = a;i >= b;--i)\n#define DEBUG(x) std::cerr << #x << '=' << x << std::endl\n\nconst int MAXN = 1e5+5;\nint a[MAXN],n;\nP st[MAXN];\nint tp;\nLL t[MAXN];\nint A[MAXN];\nint M;\nLL sm[MAXN],csm[MAXN],cnt[MAXN];\n\ninline LL f(LL n,LL a,LL b,LL c){\n\tif(n < 0) return 0;\n\tif(a < 0) return f(n,-a,b+n*a,c);\n\tif(b < 0){\n\t\tif(!a) return 0;\n\t\tLL d = std::ceil((long double)(-b)/a);\n\t\t// DEBUG(a);DEBUG(b);DEBUG(d);\n\t\t// exit(0);\n\t\treturn f(n-d,a,b+a*d,c);\n\t}\n\tif(!a) return (b/c)*(n+1);\n\tif(a >= c || b >= c) return f(n,a%c,b%c,c)+(a/c)*n*(n+1)/2+(b/c)*(n+1);\n\tLL M = (a*n+b)/c;\n\treturn n*M-f(M-1,c,c-b-1,a);\n}\n\ninline LL calc(int l,int r,int k){\n\tif(sm[r]-sm[l-1] <= k) return cnt[l]*cnt[r];\n\tLL s = sm[r-1]-sm[l];\n\tLL A = ::A[l],B = ::A[r],CA = cnt[l],CB = cnt[r];\n\tLL gx = f(CA,-A,k-s,B)-std::max(0ll,(k-s)/B);\n\tgx -= f(CA,-A,k-B*CB-s,B)-std::max(0ll,(k-B*CB-s)/B);\n\treturn gx;\n}\n\ninline bool chk(int k){// \u5224\u65ad\u7b54\u6848\u662f\u5426<=k \u5982\u679c<=k\u9700\u8981\u6ee1\u8db3 <=k\u7684\u6570 >= >k\u7684\u6570\n\t// \u8ba1\u7b97 <= k \u7684\u6570\u5b57\u6570\u91cf\n\tLL res = 0;\n\tFOR(i,1,M){\n\t\tint l = std::min((LL)k/A[i],cnt[i]);// \u6700\u591a\u9009\u51e0\u4e2a\n\t\t// DEBUG(k/A[i]);\n\t\tres += cnt[i]*l - l*(l-1)/2;\n\t\tsm[i] = sm[i-1]+A[i]*cnt[i];\n\t\tcsm[i] = csm[i-1]+cnt[i];\n\t}\n\t// DEBUG(res);\n\t// DEBUG(f(1,-6,6,0));\n\t// exit(0);\n\tint r = 1;\n\tFOR(l,1,M){// \u6bcf\u6b21\u83b7\u5f97\u6700\u957f\u7684\u533a\u95f4\u548c<=k\u7684\u533a\u95f4\n\t\tif(A[l] > k) break;\n\t\tr = std::max(r,l+1);\n\t\twhile(r <= M && sm[r]-sm[l-1] <= k) ++r;\n\t\tres += (csm[r-1]-csm[l])*cnt[l];\n\t\twhile(r <= M && sm[r]-sm[l] <= k) res += calc(l,r,k),++r;\n\t\t// if(l == 1) DEBUG(res);\n\t}\n\t// DEBUG(res);\n\tLL m = n*(n+1)/2;\n\treturn res >= m*(m+1)/2 - res;\n}\n\nint main(){\n\tscanf(\"%d\",&n);\n\tFOR(i,1,n) scanf(\"%d\",a+i);\n\tFOR(i,1,n){\n\t\tint p = 0;\n\t\tst[++tp] = MP(a[i],i);\n\t\tFOR(j,1,tp){\n\t\t\tst[j].fi = std::__gcd(st[j].fi,a[i]);\n\t\t\tif(st[j].fi == st[p].fi) continue;\n\t\t\tst[++p] = st[j];\n\t\t}\n\t\ttp = p;\n\t\t// DEBUG(i);\n\t\t// FOR(j,1,tp) printf(\"%d %d\\n\",st[j].fi,st[j].se);\n\t\t// puts(\"-------\");\n\t\tFOR(j,1,tp-1) t[st[j].fi] += st[j+1].se-st[j].se;\n\t\tt[st[tp].fi] += i-st[tp].se+1;\n\t}\n\tFOR(i,1,MAXN-1) if(t[i]) A[++M] = i,cnt[M] = t[i];\n\t// FOR(i,1,M) printf(\"%d %d\\n\",A[i],cnt[i]);\n\tstd::vector S,T;\n\tFOR(i,1,M) FOR(j,1,cnt[i]) S.pb(A[i]);std::sort(all(S));\n\tFOR(l,0,(int)S.size()-1){\n\t\tint sm = 0;\n\t\tFOR(r,l,(int)S.size()-1) sm += S[r],T.pb(sm);\n\t}\n\tstd::sort(all(T));\n\t// for(auto x:T) DEBUG(x);\n\t// DEBUG(chk(8));\n\t// exit(0);\n\tint l = 1,r = 100000,ans = -1;\n\twhile(l <= r){\n\t\tint mid = (l + r) >> 1;\n\t\tif(chk(mid)) ans = mid,r = mid-1;\n\t\telse l = mid+1;\n\t}\n\tprintf(\"%d\\n\",ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "390e0e329e24c70ae513fffe0c9a22dc", "src_uid": "7516cc0a6d76569a761cf795cfb22d50", "difficulty": 3400.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\ntypedef long long ll;\nconst int maxn=1e5+ 10;\nconst int mod = 1e9+7;\nint a , b;\n\n\nint power(int a,int b){\n if(b==0){\n return 1;\n }else if(b==1){\n return a;\n }\n\n\n ll ans = power(a,b/2)%mod;\n ans = (ans*ans)%mod;\n return (ans*power(a,b%2))%mod;\n\n\n}\n\n\nint main()\n{\n long long int n , m , k;\n cin>>n>>m>>k;\n\n\n if(n==1 && m==1 ){\n return cout<<1 , 0;\n }\n\n\n if(n>1 && m==1 ){\n if(k==1){\n return cout<<1 , 0;\n }\n if(k==-1){\n\n if(n%2==0){\n return cout<<-1 , 0 ;\n }\n else{\n return cout<<1 , 0;\n }\n\n\n }\n }\n\n if(m>1 && n==1 ){\n if(k==1){\n return cout<<1 , 0;\n }\n if(k==-1){\n\n if(m%2==0){\n return cout<<-1 , 0 ;\n }\n else{\n return cout<<1 , 0;\n }\n\n\n }\n }\n\n\n\n\n if(n>1){\n n--;\n }\n if(m>1){\n m--;\n }\n\n\n\n\n\n\n cout<\n#define M 1000000007\nusing namespace std;\n\nlong long power(long long a,long long b);\n\nint main(void)\n{\n int n,m,k;\n cin>>n>>m>>k;\n if(n%2!=m%2&&k==-1)\n {\n cout<<0<\n#include\n#include\n#include\nusing namespace std;\nconst int mod=1000000007;\n#define fzx long long\nfzx ksm(fzx a,fzx k){\n\tif(k==0) return 1;\n\tfzx tmp=ksm(a,k>>1);\n\tif(k&1) tmp=tmp*tmp*a%mod;\n\telse tmp=tmp*tmp%mod;\n\treturn tmp;\n}\nfzx n,m;fzx k;\nint main(){\n\tcin>>n>>m>>k;\n\tif(k==-1){\n\t\tif((n+m)%2){\n\t\t\tputs(\"0\");\n\t\t\treturn 0;\n\t\t}\n\t\telse{\n\t\t\tprintf(\"%I64d\",ksm(2,(n-1)*(m-1)));\n\t\t\treturn 0;\n\t\t}\n\t}\n\tprintf(\"%I64d\",ksm(2,(n-1)*(m-1)));\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3af1e9f12723e845bf3ddea60ea532fb", "src_uid": "6b9eff690fae14725885cbc891ff7243", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include\n#define M 1000000007\nusing namespace std;\n\nlong long power(long long a,long long b);\n\nint main(void)\n{\n int n,m,k;\n cin>>n>>m>>k;\n if(n%2!=m%2&&k==-1)\n {\n cout<<0<\n\nusing namespace std;\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL); cout.tie(NULL);\n\n int B, G, N;\n cin >> B >> G >> N;\n if (B + G == N) cout << 1;\n else cout << min(min(B, G), N) + 1;\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "80210de3ddbb484cd6d3283cd67dac81", "src_uid": "9266a69e767df299569986151852e7b1", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include \ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\n#define itn int\n#define pp pair\n#define fi first\n#define se second\n#define sc(a) scanf(\"%d\" , &a)\n#define scl(a) scanf(\"%lld\" , &a)\n#define lg 18\n#define N 100005\n#define all(v) ((v).begin()), ((v).end())\n#define sz(v) ((int)((v).size()))\n#define clr(v, d) memset(v, d, sizeof(v))\n#define fo(i, j, n) for(int i=(j);i<(int)(n);++i)\n#define fod(i, j, n) for(int i=(j);i>=(int)(n);--i)\n#define foa(v) fo(i, 0, sz(v)) fo(j, 0, sz(v[i]))\n#define fov(i, v) for(auto i:v)\n#define lp(i, cnt) fo(i, 0, cnt)\n#define lpi(i, s, cnt) fo(i, s, cnt)\n#define P(x) cout<<#x<<\" = { \"<>TEST;fo(T,1,TEST+1)\nconst ll MOD = 1000000007;\nconst int MAX = 1e9+7;\nconst int MIN = -1e9+7;\nusing namespace std;\n\n\n\nint main(){\n\n fastIO;\n //freopen(\"halfnice.in\",\"r\",stdin);\n\n ll b,g; cin >> b >> g;\n ll n; cin >> n;\n\n\n if(b >= n && g >= n){\n cout<< n+1;\n }\n else if(b+g == n){\n cout<< 1;\n }\n else{\n cout<< min(b,g)+1;\n }\n\n\nreturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c45cd21ec2ce315049ceeeeaa740e4c0", "src_uid": "9266a69e767df299569986151852e7b1", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n#define ll long long\n#define MOD 998244353\n#define F first\n#define S second\n#define pi 3.1415926535897932\n#define INF INT_MAX\nint main()\n{\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n \n int n,b,g,i,j,x,y,w,ans;\n cin>>b>>g>>n;\n if(b>=n&&g>=n)ans=n+1;\n else if(b=n)ans=(b+1);\n else if(g=n)ans=(g+1);\n else ans=abs(b-g)+1;\n cout<\n\nusing namespace std;\n\nvector>> dp;\n\nint minDecks(int n, int i, int g, int b, int gc, int bc, int cont){\n if(gc >= g && bc >= b) return cont;\n if(i > n) return n+1;\n\n auto& x = dp[gc][bc][i];\n if(x >= 0) return x;\n\n return (x=min(minDecks(n,i+1,g,b,gc+n-i,bc+i,cont+1), minDecks(n,i+1,g,b,gc,bc,cont)));\n}\n\nint main(){\n int b,g,n;\n\n cin >> b >> g >> n;\n\n dp = vector>>(600, vector>(600,vector(600,-1)));\n\n cout << minDecks(n,0,g,b,0,0,0) << endl;\n\n return EXIT_SUCCESS;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9e14c188aaa91a698d395e556d82d6c0", "src_uid": "9266a69e767df299569986151852e7b1", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#define fr(i,a,b) for(int i=a;i<=b;i++)\n#define frn(i,a,b) for(int i=a;i>=b;i--)\n#define LL long long\n#define N 1000000\n#define inf 0x3f3f3f3f\nusing namespace std;\nint main(){\n\tint i,j,k,m,n,sum1=0,sum2=0;\n\tchar c; \n\twhile(scanf(\"%c\",&c)){\n\t\tif(c=='Q')sum1+=9;if(c=='R')sum1+=5;if(c=='B')sum1+=3;if(c=='N')sum1+=3;if(c=='P')sum1+=1;\n\t\tif(c=='q')sum2+=9;if(c=='r')sum2+=5;if(c=='b')sum2+=3;if(c=='n')sum2+=3;if(c=='p')sum2+=1;\n\t}\n\tif(sum1>sum2)cout<<\"White\";\n\telse if(sum1==sum2)cout<<\"Draw\";\n\telse cout<<\"Black\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "11999f53fdcc0073b291202b94a9172d", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nint main()\n{\n\tint a[8][8],b=0,w=0;\n\tfor(int i=0;i<8;i++)\n\t{\n\t\tfor(int j=0;i<8;j++) cin>>a[i][j];\n\t} \n\tfor(int i=0;i<8;i++)\n\t{\n\t\tfor(int j=0;j<8;j++)\n\t\t{\n\t\t\tswitch(a[i][j])\n\t\t\t{\n\t\t\t\tcase 'Q':w+=9;break;\n\t\t\t\tcase 'R':w+=5;break;\n\t\t\t\tcase 'B':w+=3;break;\n\t\t\t\tcase 'N':w+=3;break;\n\t\t\t\tcase 'P':w++;break;\n\t\t\t\tcase 'q':b+=9;break;\n\t\t\t\tcase 'r':b+=5;break;\n\t\t\t\tcase 'b':b+=3;break;\n\t\t\t\tcase 'n':b+=3;break;\n\t\t\t\tcase 'p':b++;break;\n\t\t\t} \n\t\t} \n\t} \n\tif(w>b) cout<<\"White\";\n\tif(w\n#include\n#include\n#include\n#include\n#include\n\n#define Max(a,b) ((a > b) ? a : b)\n#define Min(a,b) ((a < b) ? a : b)\n#define FOR(i,a,b) for(i = a; i <= b; i++)\n#define ROF(i,a,b) for(i = a; i >= b; i--)\n#define SWAP(a,b) {t = a; a = b; b = t;}\n#define lli long long int\n#define endl puts(\"\")\n#define MAX 30000005\n#define WH\twhile\n\nint n, m, i, j, k, s, l;\nint white, black;\n\nchar matrix[MAX/1000][MAX/1000];\n\nint control(char c){\n\n\tc += 32*(c >= 'A' && c <= 'Z');\n\tif(c == 'q') return 9;\n\tif(c == 'r') return 5;\n\tif(c == 'b') return 3;\n\tif(c == 'k') return 3;\n\tif(c == 'p') return 1;\n\n}\n\nint main()\n{\n\tscanf(\"%s\", matrix[0]);\n\n\tn = strlen(matrix[0]);\n\n\tFOR(i,1,n-1) scanf(\"%s\", matrix[i]);\n\n\tFOR(i,0,n-1){\n\t\n\t\tFOR(j,0,n-1){\n\t\t\tif(matrix[i][j] != '.' && matrix[i][j] >= 'A' && matrix[i][j] <= 'Z') white += control(matrix[i][j]);\n\t\t\tif(matrix[i][j] != '.' && matrix[i][j] >= 'a' && matrix[i][j] <= 'z') black += control(matrix[i][j]);\n\t\t}\n\t\n\t}\n\n\tputs((white > black) ? \"White\" : (black > white) ? \"Black\" : \"Draw\");\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5b4c81f6541a61bc9ce3dc2ad3105d3b", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442", "difficulty": 900.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\nint main()\n{\n char a;\n int w=0;\n int b=0;\n\n for(int i=0; i<72; i++)\n {\n a=_getch();\n switch(a)\n {\n case 'p':b+=1;break;\n case 'P':w+=1;break;\n case 'n':b+=3;break;\n case 'N':w+=3;break;\n case 'b':b+=3;break;\n case 'B':w+=3;break;\n case 'r':b+=5;break;\n case 'R':w+=5;break;\n case 'q':b+=9;break;\n case 'Q':w+=9;break;\n }\n }\n if(b>w){cout<\n#include\nusing namespace std;\n\nstring s;\nint main(){\n\t//freopen(\"joyful.in\",\"r\",stdin);\n\tios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n\tstring str,NewStr=\"\";\n\tcin>>str;\n\tunsigned long long num=0, ans=0,pw=2;\n\tfor(int i = 0 ; i < str.length() ; i++){\n\t\tif(str[i]=='>')NewStr+=\"1000\";\n\t\telse if(str[i]=='<')NewStr+=\"1001\",cerr<= 0;i--){\n\t\t//cerr<<(NewStr[i]-'0')*pow(2,x)<\n#include \n#include \n#include \n#include \ntypedef unsigned char uch;\nusing namespace std;\n\nuch ch[10001];\nuch a[10001];\nint i,j,k;\nstring s;\nbool ans;\nint main()\n{\n i = 1;\n while (ch[i-1] != '\\n')\n {\n ch[i] = getchar();\n if (ch[i] == '>')\n s+=\"1000\";\n if (ch[i] == '<')\n s += '1001';\n \n if (ch[i] == '+')\n s += \"1010\";\n \n if (ch[i] == '-')\n s+=\"1011\";\n \n if (ch[i] == '.')\n s+=\"1100\";\n \n if (ch[i] == ',')\n s+=\"1101\";\n \n if (ch[i] == '[')\n s+= \"1110\";\n \n if (ch[i] == ']')\n s+= \"1111\";\n i++;\n }\n // cout << s << endl;\n int ans = 0;\n int cur = 1;\n int M = 1000003;\n for (int j = (i - 2) * 4 - 1; j >= 0; j--)\n {\n if (s[j] == '1')\n ans = (ans + cur) % M;\n cur = (cur * 2) % M;\n //cout << \"ans = \" << ans << endl;\n //cout << \"cur = \" << cur << endl;\n }\n cout << ans;\n \n \n getchar();\n getchar(); \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4b99f9e0881a2e5ee0dd45b9ce4e9e07", "src_uid": "04fc8dfb856056f35d296402ad1b2da1", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define pr printf\n#define sc scanf\n#define input freopen(\"input.txt\",\"r\",stdin)\n#define output freopen(\"output.txt\",\"w\",stdout)\n#include\nusing namespace std;\nchar s[100000001],l[100000001],r[1000000001];\nmain()\n{\n //input;\n //output;\n __int64 a,b,c[10001]={0},n,m=1,d=2,min=0,ans=0,cnt=0,i,max=0;\n gets(s);\n a=strlen(s);\n b=0;\n for(i=0;i'){l[b]='1';b++;l[b]='0';b++;l[b]='0';b++;l[b]='0';b++;}\n else if(s[i]=='<'){l[b]='1';b++;l[b]='0';b++;l[b]='0';b++;l[b]='1';b++;}\n else if(s[i]=='+'){l[b]='1';b++;l[b]='0';b++;l[b]='1';b++;l[b]='0';b++;}\n else if(s[i]=='-'){l[b]='1';b++;l[b]='0';b++;l[b]='1';b++;l[b]='1';b++;}\n else if(s[i]=='.'){l[b]='1';b++;l[b]='1';b++;l[b]='0';b++;l[b]='0';b++;}\n else if(s[i]==','){l[b]='1';b++;l[b]='1';b++;l[b]='0';b++;l[b]='1';b++;}\n else if(s[i]=='['){l[b]='1';b++;l[b]='1';b++;l[b]='1';b++;l[b]='0';b++;}\n else if(s[i]==']'){l[b]='1';b++;l[b]='1';b++;l[b]='1';b++;l[b]='1';b++;}\n }\n cnt=0;\n for(i=b-1;i>=0;i--)\n {\n ans+=(l[i]-48)*pow(2,cnt);\n cnt++;\n }\n cout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define pr printf\n#define sc scanf\n#define input freopen(\"input.txt\",\"r\",stdin)\n#define output freopen(\"output.txt\",\"w\",stdout)\n#include\nusing namespace std;\nchar s[100000001],l[100000001],r[1000000001];\nmain()\n{\n input;\n output;\n __int64 a,b,c[10001]={0},n,m=1,d=2,min=0,ans=0,cnt=0,i,max=0;\n gets(s);\n a=strlen(s);\n b=0;\n for(i=0;i'){l[b]='1';b++;l[b]='0';b++;l[b]='0';b++;l[b]='0';b++;}\n else if(s[i]=='<'){l[b]='1';b++;l[b]='0';b++;l[b]='0';b++;l[b]='1';b++;}\n else if(s[i]=='+'){l[b]='1';b++;l[b]='0';b++;l[b]='1';b++;l[b]='0';b++;}\n else if(s[i]=='-'){l[b]='1';b++;l[b]='0';b++;l[b]='1';b++;l[b]='1';b++;}\n else if(s[i]=='.'){l[b]='1';b++;l[b]='1';b++;l[b]='0';b++;l[b]='0';b++;}\n else if(s[i]==','){l[b]='1';b++;l[b]='1';b++;l[b]='0';b++;l[b]='1';b++;}\n else if(s[i]=='['){l[b]='1';b++;l[b]='1';b++;l[b]='1';b++;l[b]='0';b++;}\n else if(s[i]==']'){l[b]='1';b++;l[b]='1';b++;l[b]='1';b++;l[b]='1';b++;}\n }\n cnt=0;\n for(i=b-1;i>=0;i--)\n {\n ans+=(l[i]-48)*pow(2,cnt);\n cnt++;\n }\n cout<\n\nconst double eps = 1e-6;\n\nint per[4], i, j, d, maj[100001];\n\nint solve() {\n\tint vp, vd,\ttupon, order, dist;\n\tscanf(\"%d%d%d%d%d\", &vp, &vd, &tupon, &order, &dist);\n\tif (vp > vd) {\n\t\treturn 0;\n\t} else if (vp == vd) {\n\t\treturn 1;\n\t} else {\n\t\tint res = 0;\n\t\tdouble ppos = tupon * vp, t;\n\t\twhile (t = ppos / double(vd - vp), ppos + vp * t < dist - eps) {\n\t\t\tppos += (t * 2 + order) * vp;\n\t\t\t++res;\n\t\t}\n\t\treturn res;\n\t}\n}\n\nint main() {\n\tprintf(\"%d\\n\", solve());\t\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "72ac455e097a20cba21f38607076d6d8", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "/*\nID: zxzbos1\nLANG: C\nTASK: fence8\n*/\n#include \n#include \n#include \n#include \n#include \n\n#define MAXR 2000\n#define MAXN 100\n#define INF 2000000001\n\ntypedef int LL;\n\ntypedef struct fen{\n LL x,y;\n}Fen;\n\nvoid Next(Fen* x,LL vp,LL vd,LL f)\n{\n x->x=x->y*vp*vd*f+(vp+vd)*x->x;\n x->y*=(vd-vp);\n}\n\nLL gcd(LL a,LL b)\n{\n if(a=vd)\n {\n printf(\"%d\\n\",ans);return 0;\n }\n\n now.x=vp*vd*t;\n now.y=vd-vp;\n while(1==1)\n {\n if(now.x/now.y>=c)break;\n ++ans;\n Next(&now,vp,vd,f);\n temp=gcd(now.x,now.y);\n now.x/=temp;now.y/=temp;\n }\n\n printf(\"%d\\n\",ans);\n\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "188b7a929e529f9af5aa3e9d747002a1", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\n\nint main(){\n int vp, vd, t, f, c;\n cin >> vp >> vd >> t >> f >> c;\n vector D;\n D.push_back((vp * t)/(vd - vp));\n int i = 0;\n while(vd * D[i] < c){\n D.push_back((vp * (D[i] + f) + vd * D[i])/(vd - vp));\n ++i;\n }\n cout << i;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a9aa8f54b3115c0d4904ac0b73d2c1ad", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "/*\nID: zxzbos1\nLANG: C\nTASK: fence8\n*/\n#include \n#include \n#include \n#include \n#include \n\n#define MAXR 2000\n#define MAXN 100\n#define INF 2000000001\n\ntypedef long long LL;\n\ntypedef struct fen{\n LL x,y;\n}Fen;\n\nvoid Next(Fen* x,LL vp,LL vd,LL f)\n{\n x->x=x->y*vp*vd*f+(vp+vd)*x->x;\n x->y*=(vd-vp);\n}\n\nLL gcd(LL a,LL b)\n{\n if(a=vd)\n {\n printf(\"%d\\n\",ans);return 0;\n }\n\n now.x=vp*vd*t;\n now.y=vd-vp;\n while(1==1)\n {\n if(now.x/now.y>=c)break;\n ++ans;\n Next(&now,vp,vd,f);\n temp=gcd(now.x,now.y);\n now.x/=temp;now.y/=temp;\n }\n\n printf(\"%d\\n\",ans);\n\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "19074251b6a2d5f297644037aee1073c", "src_uid": "c9c03666278acec35f0e273691fe0fff", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "///IN THE NAME OF ALLAH\n using namespace std;\n #include\n bool Primes[1000000000];\n int main(){\n int n,a,b,c,d,XS=0,YS=0,draw=0;\n cin >> n >> a >> b >> c >> d;\n if(a==1)\n XS = n;\n else\n for(int i=a;i<=n;i+=a){\n XS++;\n Primes[i]=1;\n }\n if(b==1)\n YS = n-XS;\n else\n for(int i=b;i<=n;i+=b){\n if(Primes[i]==1)\n draw++;\n YS++;\n Primes[i]=1;\n }\nlong long Sum = (YS-draw)*d+(XS-draw)*c+draw*(max(c,d));\ncout<\nusing namespace std;\n#define ll long long \n#define f first\n#define s second\n#define pi 3.14159265359\n#define eps 1e-6\n#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL);\nifstream in(\"in.txt\");\nofstream out(\"out.txt\");\n\nbool used[1000000001] = {0};\n\nint main() {\n\tfastio();\n\tll n, a, b, p, q; cin >> n >> a >> b >> p >> q;\n\tint ans = 0;\n\tll t1 = a;\n\tll t2 = b;\n\twhile(t1 <= n) {\n\t\tused[t1] = 1;\n\t\tans += p;\n\t\tt1 += a;\n\t}\n\twhile(t2 <= n) {\n\t\tif(used[t2] && q > p) {\n\t\t\tans -= p;\n\t\t\tans += q;\n\t\t} else if(!used[t2]){\n\t\t\tans += q;\n\t\t}\n\t\tt2 += b;\n\t}\n\tcout << ans;\n\treturn 0;\n}\n \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "956b9559ca193d6ffa51bc2ba3aaac8c", "src_uid": "35d8a9f0d5b5ab22929ec050b55ec769", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n#define max3(a,b,c) max(max(a,b),c)\n#define min3(a,b,c) min(min(a,b),c)\n#define PI acos(-1.0)\n#define LL long long\n#define INF_MAX 2147483647\n#define INF_MIN -2147483647\n#define MX 1000005\n#define MOD 1000000007\nint main()\n{\n //freopen(\"a.in\", \"r\", stdin);\n //freopen(\"a.out\", \"w\", stdout);\n vectorv1;\n vectorv2;\n vectorv3;\n vectorv4;\n int index,a,b,p,q,res;\n while(scanf(\"%d%d%d%d%d\",&index,&a,&b,&p,&q)!=EOF)\n {\n for(int i=1;;i++)\n {\n LL res1=a*i;\n if(res1>index)\n {\n break;\n }\n v1.push_back(res1);\n }\n\n for(int i=1;;i++)\n {\n LL res2=b*i;\n if(res2>index)\n {\n break;\n }\n v2.push_back(res2);\n }\n int flag=0;\n LL cost;\n if(p\n#include \n#include \nusing namespace std;\n\nint main ()\n{\n long long n,a,b,p,q,res,i,cnt=0,cnt2=0;\n unsigned char* arr;\n cin>>n>>a>>b>>p>>q;\n arr = (unsigned char*)malloc(n*sizeof(unsigned char));\n memset(arr,'0',sizeof(arr));\n if(p>=q){\n for(i=1; i<=n; i++)\n {\n if(i*a>n && i*b>n)\n break;\n if(arr[i*a]!='1' && i*a<=n)\n {\n arr[i*a] = '1';\n cnt++;\n }\n if(arr[i*b]!='1' && i*b<=n)\n {\n arr[i*b] = '1';\n cnt2++;\n }\n\n }\n }\n else if(pn && i*b>n)\n break;\n if(arr[i*b]!='1' && i*b<=n)\n {\n arr[i*b] = '1';\n cnt2++;\n }\n if(arr[i*a]!='1' && i*a<=n)\n {\n arr[i*a] = '1';\n cnt++;\n }\n }\n }\n res = (p*cnt)+(q*cnt2);\n\n cout< MAXTIME) ta = MAXTIME - t0;\n\tif (t0 - tb < MINTIME) { tb = t0 - MINTIME; ans++; }\n\t\n\tans += trunc((t0 + (ta - 0.1)) / b) - trunc((t0 - (tb - 0.1)) / b);\n\n\tprintf(\"%d\", ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "df5e935a1ce32eddde63a05172778f8f", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define mem(a) memset(a,0,sizeof(a))\n#define ll __int64\n#define INF 0x7fffffff //INT_MAX\n#define inf 0x3f3f3f3f //\nconst double PI = acos(-1.0);\nconst double e = exp(1.0);\ntemplate T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }\ntemplate T lcm(T a, T b) { return a / gcd(a, b) * b; }\nusing namespace std;\nstruct timee{\n\tint h;\n\tint m;\n};\nint a,ta,b,tb;\nint temp[30][65];\nvoid initB(){\n\ttimee flag;\n\tflag.h=5;\n\tflag.m=0;\n\twhile(flag.h<23 || (flag.h==23 &&flag.m<=59)){\n\t\ttemp[flag.h][flag.m]=1;\n\t\tflag.m+=b;\n\t\twhile(flag.m>=60){\n\t\t\tflag.m-=60;\n\t\t\tflag.h++;\n\t\t}\n\t}\n}\nint main(){\n\t//freopen(\"1.txt\",\"r\",stdin);\n scanf(\"%d%d%d%d\",&a,&ta,&b,&tb);\n mem(temp);\n initB();\n timee sta,S,end;\n int cnt=0;\n char p[20];\n scanf(\"%s\",p+1);\n sta.h=(p[1]-'0')*10+(p[2]-'0');\n sta.m=(p[4]-'0')*10+(p[5]-'0');\n S.h=sta.h,S.m=sta.m;\n end.h=sta.h,end.m=sta.m;;\n end.m+=ta;\n while(end.m>=60){\n \tend.h++;\n \tend.m-=60;\n }\n if(end.h >23){\n \tend.h=23;\n \tend.m=59;\n }\n sta.m-=tb;\n while(sta.m<0){\n \tsta.h--;\n \tsta.m+=60;\n }\n if(sta.h<5){\n \tsta.h=5;\n \tsta.m=0;\n }\n else{\n if(temp[sta.h][sta.m]){\n \tcnt--;\n }\n }\n// printf(\"%d\\n\",cnt);\n// printf(\"%d:%d\\n\",sta.h,sta.m);\n// printf(\"%d:%d\\n\",end.h,end.m);\n while(sta.h < end.h || (sta.h==end.h && sta.m<=end.m)){\n \tif(sta.h==end.h && sta.m==end.m && temp[end.h][end.m]==1)\n \tcnt--;\n if(temp[sta.h][sta.m]==1)\n \t\tcnt++;\n \tsta.m++;\n while(sta.m>=60){\n \tsta.h++;\n \tsta.m-=60;\n }\n// printf(\"cnt=%d %d %d\\n\",cnt,sta.h,sta.m);\n }\n\tprintf(\"%d\\n\",cnt);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7520fe985da0d50e67e5a290e5f34631", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include \"bits\\stdc++.h\"\nusing namespace std;\n\n#define MAXTIME ((24-5)*60-1)\n#define MINTIME 0\n\nint main() {\n\tint a, b, ta, tb, t0;\n\tchar doph1, doph2, dopm1, dopm2, dop;\n\tint ans=0, x;\n\n\tscanf(\"%d%d%d%d\", &a, &ta, &b, &tb);\n\tscanf(\"%c\", &dop);\n\tscanf(\"%c%c%c%c%c\", &doph1, &doph2, &dop, &dopm1, &dopm2);\n\tt0 = ((doph1 - '0') * 10 + (doph2 - '0')) * 60 + ((dopm1 - '0') * 10 + (dopm2 - '0')) - 5 * 60;\n\n\tx = t0 % b;\n\tif (t0 + ta > MAXTIME) ta = MAXTIME - t0;\n\tif (t0 - tb < MINTIME) { tb = t0 - MINTIME; ans++; }\n\t\n\tans += trunc((t0 + (ta - 0.1)) / b) - trunc((t0 - (tb - 0.1)) / b);\n\n\tprintf(\"%d\", ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4437697aa19cd6c524ed2ebd56a1444f", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define m 60*24-1\nusing namespace std;\n\nint main()\n{\n int a,b;\n int c,d;\n int e,f;\n cin>>a>>b>>c>>d;\n scanf(\"%d:%d\",&e,&f);\n int q=e*60+f-d;\n int w=e*60+f+b;\nif(w>m) w=m;\nif(q<300) q=300;\n\nint lze=300;\nint ans=0;\n//cout<=q&&lze\n#define DEBUG(x) cout << #x << \" = \" << x << endl;\nusing namespace std;\nconst int MAXN = 5005;\nconst int HUJ = 5002;\n\n// (c) JustN template 2016.\n\n/// Use only with Govno Code Compiler (GCC) or Govno code compiler for Pure Professionals 11 (GPP, G++)\n\ntypedef long long ll;\n\nll fart (ll n)\n{\n ll f = 0;\n while (n > 0)\n {\n if (n & 1) f++;\n n/=2;\n }\n return f;\n}\nint main()\n{\n ll s;\n ll x;\n ll d;\n cin >> s;\n cin >> x;\n d = s - x;\n if (d < 0 || d%2)\n {\n cout << 0;\n return 0;\n }\n d /= 2;\n\n if (d & x > 0)\n {\n cout << 0;\n return 0;\n }\n\n ll k = fart(x);\n // DEBUG(fart(0));\n ll pow = 1;\n // DEBUG(k);\n for (ll i = 0; i < k; i++)\n {\n pow *= 2;\n }\n if (d == 0) pow -= 2;\n cout << pow;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8b5ec9f231370dca4b41810451ace02e", "src_uid": "18410980789b14c128dd6adfa501aea5", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "//In the name of God.\n#include\nusing namespace std;\ntypedef pair pii;\ntypedef pair pll;\ntypedef long long int ll;\nlong long int po(ll c)\n{\n\tll an=1;\n\tfor (int i=0;i>s>>x;\n\tlong long int n=x,c=0;\n\twhile (n>0)\n\t{\n\t\tif (n%2==1)\n\t\t{\n\t\t\tf[c]=1;\n\t\t\tt++;\n\t\t}\n\t\tn/=2;\n\t}\n\ts-=x;\n\tif (s==0)\n\t{\n\t\tcout<0)\n\t\t{\n\t\t\tif (po(c)>s)\n\t\t\t\tc--;\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (f[c]==true)\n\t\t\t\t{\n\t\t\t\t\tcout<<\"0\";\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\ts-=po(c);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\n\ntemplate \nT nextInt() {\n T x = 0, p = 1;\n char ch;\n do { ch = getchar(); } while(ch <= ' ');\n if (ch == '-') {\n p = -1;\n ch = getchar();\n }\n while(ch >= '0' && ch <= '9') {\n x = x * 10 + (ch - '0');\n ch = getchar();\n }\n return x * p;\n}\n\nconst int maxN = (int)3e5 + 10;\nconst int mod = (int)1e9 + 7;\nconst int INF = (int)1e9 + 5;\nconst ll LLINF = (ll)1e18 + 5;\nconst double PI = acos(-1.0);\n\nint main() {\n\n // freopen(\".in\", \"r\", stdin);\n //freopen(\".out\", \"w\", stdout);\n\n ll a, b;\n cin >> a >> b;\n\n ll tmpa = a;\n int res = 0;\n for (int i = 0; i < 50; ++i) {\n if ((b >> i) & 1) {\n a -= (1LL << i);\n res++;\n }\n }\n if (a % 2 != 0) {\n cout <<0;\n } else {\n cout << (1LL << __builtin_popcountll(b)) - 2 * (tmpa == b);\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fae8c4041654f9d4bcaa2555c93e04f7", "src_uid": "18410980789b14c128dd6adfa501aea5", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n long long s, x;\n cin >> s >> x;\n long long s1 = s;\n long long x1 = x;\n long long cp = 1;\n static int b[100]; //\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\n int p = 0;\n while (x1 != 0)\n {\n b[p] = x1 % 2;\n p++;\n s1 -= cp * (x1 % 2);\n cp *= 2;\n x1 /= 2;\n }\n if (s1 % 2 == 1)\n {\n cout << 0;\n return 0;\n }\n s1 /= 2;\n static int v[100];\n p = 0;\n while (s1 != 0)\n {\n v[p] = s1 % 2;\n s1 /= 2;\n p++;\n }\n long long ans = 1;\n for (int i = 0; i < 100; i++)\n {\n if (b[i] and v[i])\n {\n cout << 0;\n return 0;\n }\n if (b[i])\n {\n ans *= 2;\n }\n }\n if (s == x)\n {\n ans -= 2;\n }\n cout << ans;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1d965a13442488ddb8f7d6673d3d8e92", "src_uid": "18410980789b14c128dd6adfa501aea5", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \n\nint main()\n{\n\tint n, k{1};\n\tstd::cin >> n;\n\tfor (int i = n, j = 1; i != 2 * n - 1 || j != n; k % j ? k *= i++ : k /= j++);\n\tstd::cout << k;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8e26bf54ca98ba66264010b956c2711d", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0} {"lang": "GNU C++0x", "source_code": "#include\n#include\n#include\nusing namespace std;\n\nint n,a[1000][1000],i,j;\n\nint main()\n{\n cin>>n;\n for(i=1;i<=n;++i)\n {a[i][1]=1;a[1][i]=1;}\n for(i=2;i<=n;++i)\n for(j=2;j<=n;++j)\n a[i][j]=a[i-1][j]+a[i][j-1];\n cout<\n#include\n\nusing namespace std;\n\nint main()\n{\n\tlong int *dyn_arr,n,i,j;\n\tcin>>n;\n\tdyn_arr= new long int[n*n];\n\tfor(i=0;i\n#include \nstruct Table\n{\n\tint tb[10][10];\n\tint n;\n};\nvoid main()\n{\n\tTable a;\n\tint max;\n\tFILE* fin = fopen(\"input.txt\", \"rt\");\n\tif (!fin)\n\t{\n\t\tprintf(\"Can't open input.txt\\n\");\n\t\tgetch();\n\t\treturn;\n\t}\n\tprintf(\"Open input.txt successfully\\n\");\n\tfscanf(fin, \"%d \", &a.n);\n\tfclose(fin);\n\tfor (int i = 0; i < a.n; i++)\n\t\ta.tb[i][0] = 1;\n\tfor (int i = 1; i < a.n; i++)\n\t\ta.tb[0][i] = 1;\n\tif (a.n != 1)\n\tfor (int i = 1; i < a.n;i++)\n\tfor (int j = 1; j < a.n; j++)\n\t\ta.tb[i][j] = a.tb[i - 1][j] + a.tb[i][j - 1];\n\tmax = a.tb[a.n - 1][a.n - 1];\n\tFILE* fout = fopen(\"output.txt\", \"wt\");\n\tif (!fout)\n\t{\n\t\tprintf(\"Can't open output.txt\\n\");\n\t\tgetch();\n\t\treturn;\n\t}\n\tprintf(\"Open output.txt successfully\\n\");\n\tfprintf(fout, \"%d \", max);\n\tfclose(fout);\n\tgetch();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "311a66e591472f84736e62e46ea9f269", "src_uid": "2f650aae9dfeb02533149ced402b60dc", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\nvoid main()\n{\n\tsetlocale(LC_ALL, \"Russian\");\n\tint n;\n\tint s = 0;\n\tcin>>n;\n\tif (( n>=1 ) && ( n<=5 ) && (n % 2 == 1))\n\t{\n\t\tint **a;\n\t\ta = new int*[n];\n\n\t\tfor(int i = 0; i < n; i++)\n\t\t\ta[i] =new int[n];\n\n\t\tfor(int i = 0; i < n; i++)\n\t\t{\n\t\t\tfor(int j = 0; j < n; j++)\n\t\t\t\tcin >> a[i][j];\n\t\t}\n\t\tfor(int i = 0; i < n; i++)\n\t\t\tfor(int j = 0; j < n; j++)\n\t\t\t\tif (a[i][j] < 0 || a[i][j] > 100)\n\t\t\t\t\tcin >> a[i][j];\t\n\n\t\tfor(int i = 0; i < n; i++)\n\t\t\tfor(int j = 0; j < n; j++)\n\t\t\t{\n\t\t\t\tif (i == j || (n - 1 - i) == j || i == (n - 1) / 2 || j == (n - 1) / 2)\n\t\t\t\t\ts = s + a[i][j];\n\t\t\t}\n\t\t\tcout << s;\n\t}\n\tsystem(\"Pause\");\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "28fa66a0b50b1bb69ea2e58859171044", "src_uid": "5ebfad36e56d30c58945c5800139b880", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\n\nint main(){\n\tint n;\n\tint summ = 0;\n\tvector > matr;\n\tvector > used;\n\tcin >> n;\n\n\tmatr.resize(n);\n\tused.resize(n);\n\tfor (int i = 0; i < n; i++){\n\t\tmatr[i].resize(n);\n\t\tused[i].resize(n);\n\t\tfor (int j = 0; j < n; j++){\n\t\t\tused[i][j] = false;\n\t\t\tcin >> matr[i][j];\n\t\t}\n\t}\n\n\t\n\tint middle = (n - 2)/2 + 1;\n\n\tfor (int i = 0; i < n; i++){\n\t\tsumm += matr[i][i];\n\t\tused[i][i] = true;\n\n\t\tif (used[i][n-i-1] == false){\n\t\t\tsumm += matr[i][n-i-1];\n\t\t\tused[i][n-i-1] = true;\n\t\t}\n\n\t\tif (used[i][middle] == false){\n\t\t\tsumm += matr[i][middle];\n\t\t\tused[i][middle] = true;\n\t\t}\n\n\t\tif (used[middle][i] == false){\n\t\t\tsumm += matr[middle][i];\n\t\t\tused[middle][i] = true;\n\t\t}\n\t}\n\n\tcout << summ;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "26202a6ea1195fecb77a189dcf1cd6a0", "src_uid": "5ebfad36e56d30c58945c5800139b880", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nconst int N = 5;\n\nint main()\n{\n int array[ N ][ N ];\n int sizeArr = 0;\n int input;\n int i,j;\n int sumHeadDiag = 0, sumAddDiag = 0, sumCent1 = 0, sumCent2 = 0, result = 0;\n\n scanf(\"%d\", &sizeArr);\n\n if(sizeArr == 1)\n {\n scanf(\"%d\", &input);\n printf(\"%d\", input);\n }\n else\n {\n for( i = 0; i < sizeArr; i++ )\n for( j = 0; j < sizeArr; j++ )\n {\n scanf( \"%d\", &input);\n array[i][j] = input; \n }\n\n for( i = 0; i < sizeArr; i++)\n sumHeadDiag += array[i][i];\n\n for( i = sizeArr-1; i >= 0; i-- )\n sumAddDiag += array[i][i];\n\n for ( i = 0; i < sizeArr-1; i++ )\n sumCent1 += array[i][ (sizeArr+1)/2];\n\n for ( i = 0; i < sizeArr-1; i++ )\n sumCent2 += array[ (sizeArr+1)/2 ][i];\n\n result = sumCent1 + sumCent2 + sumAddDiag + sumHeadDiag - 4*array[(sizeArr + 1)/2][(sizeArr + 1)/2] ;\n printf(\"%d\", result);\n }\n _getch();\n return 0;\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "47c7e12e99192f392687ee1b18c39d68", "src_uid": "5ebfad36e56d30c58945c5800139b880", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\n\n\nint main()\n{\t\n\tint i, j, n, sum=0, avg;\n\tcin >> n;\n\tint **a = new int* [n];\n\tfor (i=0; i> a[i][j];\n\tfor (i=0; i\nusing namespace std;\n//By CJ\nconst int sum[] = { 0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2 };\nint main()\n{\n\tint ans;\n\tscanf(\"%d\", ans);\n\t\n\tprintf(\"%d\", sum[ans]);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "41d20cc00aa37e02edff5efd5668f73e", "src_uid": "c50b6af99ca7b9c35628b52774d6c32b", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include \n\nconst int A[]={0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2};\n//I hate CF...I love CF\nint main()\n{\n int CF;\n scanf(\"%d\", CF);\n printf(\"%d\", A[CF]);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0ad4da0d46bb53fe6cf4fb07117c1267", "src_uid": "c50b6af99ca7b9c35628b52774d6c32b", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include \n\nconst int ABCDEFGHIJKLMNOPQRSTUVWXYZ[1000]={0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51, 1, 2, 1, 14, 1, 2, 2, 14, 1, 6, 1, 4, 2, 2, 1, 52, 2, 5, 1, 5, 1, 15, 2, 13, 2, 2, 1, 13, 1, 2, 4, 267, 1, 4, 1, 5, 1, 4, 1, 50, 1, 2, 3, 4, 1, 6, 1, 52, 15, 2, 1, 15, 1, 2, 1, 12, 1, 10, 1, 4, 2};\n\nint main()\n{\n int CODEFORCES_409F_is_garbage;\n scanf(\"%d\", CODEFORCES_409F_is_garbage);\n printf(\"%d\", ABCDEFGHIJKLMNOPQRSTUVWXYZ[CODEFORCES_409F_is_garbage]);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4b95068ad505856533cd4378a7219cd3", "src_uid": "c50b6af99ca7b9c35628b52774d6c32b", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\nusing namespace std;\nconst long long MAXN=1000001+10;\nlong long tree[MAXN],a[60][1000001],n,m,x,y,f[1000001],zm[100],ans,ans_;\nstring s1,s2;\nint lowbit(int x)\n{return x&-x;}\nvoid add(long long p)\n{\n while(p<=n)\n {\n tree[p]++;\n p+=lowbit(p);\n }\n}\nint sum_(long long p)\n{\n ans=0;\n while(p>0)\n {\n ans+=tree[p];\n p-=lowbit(p);\n }\n return ans;\n}\nint main()\n{\n cin>>n;\n short ans__[]={0,1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51,1,2,1,14,1,2,2,14,1,6,1,4,2,2,1,52,2,5,1,5,1,15,2,13,2,2,1,13,1,2,4,267,1,4,1,5,1,4,1,50,1,2,3,4,1,6,1,52,15,2,1,15,1,2,1,12,1,10,1,4,2};\n cout<//\u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f\n#include //\u0414\u043b\u044f \u0432\u044b\u0432\u043e\u0434 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e <mas[b])\n {\n int tmp=mas[a];\n mas[a]=mas[b];\n mas[b]=tmp;\n }\n}\n\n\nvoid smth()\n{\n for(int i=0;i0)\n {\n mas[i]++;\n m--;\n }\n}\n if(m>0 && (mas[0])==mas[n-1]+1)\n {\n mas[n-1]++;\n m--;\n }\n}\nint main ()\n{\nint max=INT_MIN;\ncin>>n>>m;\nfor (int i=0;i>mas[i];\nif (mas[i]>max)\nmax=mas[i];\n}\nmax+=m;\nsort();\nif(n==1) \n{\n cout<0)smth();\nsort();\ncout<\nusing namespace std;\n\nint main()\n{\n int i = 0, j = 0, n = 0, p[102] = {0}, m = 0, a = 0, most = 0, least = 105, big = 0, x = 2, y = 0, b = 0, z = 0, o = 0;\n cin >> n >> m;\n o = m;\n for(i = 1; i <= n; i++)\n {\n cin >> p[i];\n if(most <= p[i])\n {\n most = p[i];\n }\n if(least >= p[i])\n {\n least = p[i];\n }\n }\n big = most + m;\n while(most > least)\n {\n least++;\n o--;\n if(o <= 0)\n {\n break;\n }\n }\n\n if(most > least)\n {\n cout << most << \" \" << big;\n b = 1;\n }\n if(n == 1)\n {\n cout << big << \" \" << big;\n b = 1;\n }\n\n if(least >= most && n != 1)\n {\n for(i = 1; i <= x; i++)\n {\n if(p[1] == p[n])\n {\n y++;\n }\n\n\n while(p[1] < p[n])\n {\n p[1]++;\n m--;\n\n if(m == 0)\n {\n break;\n }\n }\n for(j = 2; j <= n; j++)\n {\n if(m == 0)\n {\n break;\n }\n if(p[j] == p[j - 1])\n {\n y++;\n }\n while(p[j] < p[j - 1])\n {\n p[j]++;\n m--;\n if(m == 0)\n {\n break;\n }\n }\n\n }\n\n\n if(y == n)\n {\n p[n]++;\n m--;\n if(m == 0)\n {\n break;\n }\n }\n y = 0;\n x++;\n }\n }\n for(i = 1; i <= n; i++)\n {\n\n if(most <= p[i])\n {\n most = p[i];\n }\n }\n if(b == 0)\n {\n cout << most << \" \" << big;\n }\n\n\nreturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b2669ea5f0b5dab8888b222da30112bb", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include\n\nusing namespace std;\n\nint main(){\n int n, m, min=0, max=0, tempmin;\n cin>>n>>m;\n int k[n];\n for(int i=0; i>k[i];\n if(k[i]>max)\n max=k[i];\n }\n tempmin=max;\n for(int i=0; imin)\n min=k[i];\n }\n cout<\nusing namespace std;\nint findMinK ( int n, int m, int sum, int maxa, int* a );\nint binSearch ( int k, int m );\nint main()\n{\n\tsetlocale ( LC_ALL , \"ru\");\n\tint n, m, sum = 0, maxa = 0;\n\tcin >> n >> m;\n\tint* a = new int[n];\n\tfor ( int i = 0; i < n; i++ )\n\t{\n\t\tcin >> a[i];\n\t\tsum += a[i];// \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd a[i] \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd K.\n\t\tif(a[i] >= maxa)\n\t\t\tmaxa = a[i];\n\t}\n\tcout << binSearch ( findMinK ( n, m, sum, maxa, a), m ) << \" \" << maxa + m << endl;\n\tdelete[] a;\n//\tsystem ( \"pause\" );\n\treturn 0;\n}\n//////////////////////////////////////////\nint findMinK ( int n, int m, int sum, int maxa, int* a )\n{\n\tint countOfEmpty = 0;\n\tsum += m;\n\tif ( sum % n == 0 )\n\t{\n\t\tif ( sum / n >= maxa)\n\t\t{\n\t\t\treturn sum / n;\n\t\t}\n\t\treturn maxa;\n\t}\n\telse\n\t{\n\t\tif ( sum / n + 1 >= maxa)\n\t\t{\n\t\t\treturn sum / n + 1;\n\t\t}\n\t\treturn maxa;\n\t}\n}\n//////////////////////////////////////////\nint binSearch ( int k, int m )\n{\n\tint up = 100 + m;\n\tint down = 1;\n\tint ans = 0;\n\twhile( down <= up )\n\t{\n\t\tans = ( up + down ) / 2;\n\t\tif ( ans < k )\n\t\t{\n\t\t\tdown = ans;\n\t\t\tcontinue;\n\t\t}\n\t\tif( ans > k )\n\t\t{\n\t\t\tup = ans;\n\t\t\tcontinue;\n\t\t}\n\t\tif( ans == k )\n\t\t{\n\t\t\treturn ans;\n\t\t}\n\t\t\n\t}\n}\n/* \ufffd \ufffd\ufffd\ufffd \ufffd \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd-\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd */", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dd7811b87e7b14b0709703ce34c3e560", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nint n;\nchar name[60][50];\nint s[60], c[60], in[60];\n\nint find(char str[])\n{\n int i;\n for (i = 1; i <= n; i++) if (strcmp(name[i], str) == 0) return i;\n}\n\nint main()\n{\n int i, j, num1, num2, len, d, e, n1, n2;\n char stat[100], name1[2][50];\n scanf(\"%d\", &n);\n for (i = 1; i <= n; i++) scanf(\"%s\", name[i]);\n memset(s, 0, sizeof(s));\n memset(c, 0, sizeof(c));\n memset(in, 0, sizeof(in));\n for (i = 1; i <= n * (n - 1) / 2; i++)\n {\n scanf(\"%s%d:%d\", stat, &num1, &num2);\n len = strlen(stat);\n d = 0;\n e = 0;\n for (j = 0; j < len; j++)\n {\n if (stat[j] == '-')\n {\n name1[0][e] = 0;\n e = 0;\n d = 1;\n }\n else name1[d][e++] = stat[j];\n }\n name1[1][e] = 0;\n n1 = find(name1[0]);\n n2 = find(name1[1]);\n if (num1 == num2)\n {\n s[n1] += 1;\n s[n2] += 1;\n }\n else if (num1 > num2) s[n1] += 3;\n else s[n2] += 3;\n c[n1] += num1 - num2;\n c[n2] += num2 - num1;\n in[n1] += num1;\n in[n2] += num2;\n }\n //for (i = 1; i <= n; i++) printf(\"%d\", s[i]);\n for (i = 1; i < n; i++)\n {\n for (j = i + 1; j <= n; j++) if (s[j] > s[i] || (s[j] == s[i] && c[j] > c[i]) || (s[j] == s[i] && c[j] == c[i] && in[j] > in[i]))\n {\n int temp;\n temp = s[i]; s[i] = s[j]; s[j] = temp;\n temp = c[i]; c[i] = c[j]; c[j] = temp;\n temp = in[i]; in[i] = in[j]; in[j] = temp;\n char temps[50];\n strcpy(temps, name[i]); strcpy(name[i], name[j]); strcpy(name[j], temps);\n }\n }\n for (i = 1; i < n / 2; i++)\n {\n for (j = i + 1; j <= n / 2; j++) if (strcmp(name[j], name[i]) < 0)\n {\n char temps[50];\n strcpy(temps, name[i]); strcpy(name[i], name[j]); strcpy(name[j], temps);\n }\n }\n for (i = 1; i <= n / 2; i++) printf(\"%s\\n\", name[i]);\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bce62bb46eeba9fc539ea2b9089f1dc2", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\nchar s[101];\nint n;\nint dp(int z, int i, int j){\n\tint m = 0;\n\tif(s[i]==s[j]){\n\t\tm = max(m, 1+dp(z+1, i+1, j+1));\n\t}\n\treturn m;\n}\nint main(){\n\tgets(s);\n\tn = strlen(s);\n\tint m = 0;\n\tfor(int i = 0; i < n; i ++)for(int j = i+1; j < n; j ++){\n\t\tm = max(m, dp(0, i, j));\n\t}\n\tprintf(\"%d\\n\", m);\n\treturn main();\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dfd979fb187108c16ee78c067e4db4be", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n#define N 10000\nchar s[N];\nint n;\nint memo[N][N];\nint f(int i, int j){\n\tif(memo[i][j]!=-1)return memo[i][j];\n\tint m = 0;\n\tif(s[i]&&s[j]&&s[i]==s[j]){\n\t\tm = 1+f(i+1, j+1);\n\t}\n\treturn memo[i][j]=m;\n}\nint main(){\n\tmemset(memo, 0xff, sizeof memo);\n\tgets(s);\n\tn = strlen(s);\n\tint m = 0;\n\tfor(int i = 0; i < n; i ++)for(int j = i+1; j < n; j ++){\n\t\tm = max(m, f(i, j));\n\t}\n\tprintf(\"%d\\n\", m);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7a43ce350c072746e00d83db8aad6a50", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "\n#include\nusing namespace std;\n#define mx 10485760\nstring str;\nstring tree[mx * 3];\nvoid built(int node, int b, int e)\n{\n if (b == e) {\n tree[node] = str[b-1];\n return;\n }\n int Left = node * 2;\n int Right = node * 2 + 1;\n int mid = (b + e) / 2;\n built(Left, b, mid);\n built(Right, mid + 1, e);\n tree[node] = tree[Left] + tree[Right];\n}\nstring substr(int node, int b, int e, int i, int j)\n{\n if (i > e || j < b)\n return \"\";\n if (b >= i && e <= j)\n return tree[node];\n\n int Left = node * 2;\n int Right = node * 2 + 1;\n int mid = (b + e) / 2;\n string p1 = substr(Left, b, mid, i, j);\n string p2 = substr(Right, mid + 1, e, i, j);\n return p1 + p2;\n}\n int frequency=0,loc=-1;\nvoid KMP(string T, string P)\n{\n int n,m,k,i,j;\n // n=T.size();\n n=T.size();\n //m=P.size();\n m=P.size();\n long long int LPS[m];\n i=1;\n j=0;\n LPS[0]=0;\n while(i>str;\n int l=str.size();\n int i,j;\n string Substr;\n int Mxx=0;\n int f=0;\n int n= str.size();\n built(1,1,n);\n for(i=0; i=2){\n int x=Substr.size();\n Mxx=max(x,Mxx);\n }\n }\n }\n cout<\n#include \n\nusing namespace std;\n#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)\n#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)\n#define _for(n, a, b) for (ll n = (a); n < (b); ++n)\n#define _rof(n, a, b) for (ll n = (a); n > (b); --n)\n#define oo 0x3f3f3f3f3f3f\n#define ll long long\n#define db double\n#define eps 1e-8\n#define bin(x) cout << bitset<10>(x) << endl;\n#define what_is(x) cerr << #x << \" is \" << x << endl\n#define met(a, b) memset(a, b, sizeof(a))\n#define all(x) x.begin(), x.end()\n#define pii pair\nconst ll mod = 1e9 + 7;\nconst ll maxn = 1e3 + 5;\nint n;\nvector p(6);\npair& intersect(pii& p0, pii& p1, pii& p2, pii& p3)\n{\n\tpii l, r;\n\tpair ret;\n\tl.first = max(p0.first, p2.first);\n\tl.second = max(p0.second, p2.second);\n\tr.first = min(p1.first, p3.first);\n\tr.second = min(p1.second, p3.second);\n\tret.first = l;\n\tret.second = r;\n\treturn ret;\n}\ndb getarea(pii a, pii b)\n{\n\tdb ret = abs(a.first - b.first) * abs(a.second - b.second);\n\treturn ret;\n}\nsigned main()\n{\n\tfor (auto& i : p)\n\t\tcin >> i.first >> i.second;\n\tpair s1 = intersect(p[0], p[1], p[2], p[3]);\n\tpair s2 = intersect(p[0], p[1], p[4], p[5]);\n\tpair cover = intersect(s1.first, s1.second, s2.first, s2.second);\n\tif (getarea(p[0], p[1]) == getarea(s1.first, s1.second) + getarea(s2.first, s2.second) - getarea(cover.first, cover.second))\n\t\tcout << \"NO\" << endl;\n\telse\n\t\tcout << \"YES\" << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d5bc6eda05070f62833708e99028cb28", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nbool contains(int x, int y, int x1, int y1, int x2, int y2) {\n return x >= x1 && x <= x2 && y >= y1 && y <= y2;\n}\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n freopen(\"temp.in\", \"r\", stdin);\n\n int x1, y1, x2, y2;\n int x3, y3, x4, y4;\n int x5, y5, x6, y6;\n\n cin >> x1 >> y1 >> x2 >> y2;\n cin >> x3 >> y3 >> x4 >> y4;\n cin >> x5 >> y5 >> x6 >> y6;\n\n bool bL, bR, tR, tL;\n\n string output = \"YES\";\n \n if (contains(x1, y1, x3, y4, x4, y4)) bL = true;\n if (contains(x1, y2, x3, y4, x4, y4)) tL = true;\n if (contains(x2, y1, x3, y4, x4, y4)) bR = true;\n if (contains(x2, y2, x3, y4, x4, y4)) tR = true;\n\n if (bL && tL && bR && tR) {\n output = \"NO\";\n goto printout;\n }\n\n bL = 0;\n tL = 0;\n bR = 0;\n tR = 0;\n \n if (contains(x1, y1, x5, y5, x6, y6)) bL = true;\n if (contains(x1, y2, x5, y5, x6, y6)) tL = true;\n if (contains(x2, y1, x5, y5, x6, y6)) bR = true;\n if (contains(x2, y2, x5, y5, x6, y6)) tR = true;\n \n if (bL && tL && bR && tR) {\n output = \"NO\";\n goto printout;\n }\n\n int cx1, cy1, cx2, cy2;\n \n //Need to check if the two black boxes are connected horizontally\n if (x3 <= x6 && x4 > x6) {\n cx1 = x5;\n cx2 = x4;\n cy1 = max(y5, y3);\n cy2 = min(y6, y4);\n\n if (contains(x1, y1, cx1, cy1, cx2, cy2)\n && contains (x1, y2, cx1, cy1, cx2, cy2)\n && contains(x2, y1, cx1, cy1, cx2, cy2)\n && contains(x2, y2, cx1, cy1, cx2, cy2)) {\n output = \"NO\";\n }\n } else if (x5 <= x4 && x6 > x4) {\n cx1 = x3;\n cx2 = x6;\n cy1 = max(y5, y3);\n cy2 = min(y6, y4);\n\n if (contains(x1, y1, cx1, cy1, cx2, cy2)\n && contains (x1, y2, cx1, cy1, cx2, cy2)\n && contains(x2, y1, cx1, cy1, cx2, cy2)\n && contains(x2, y2, cx1, cy1, cx2, cy2)) {\n output = \"NO\";\n }\n }\n\n //Now checks vertically\n if (y5 <= y4 && y6 > y4) {\n cy1 = y3;\n cy2 = y6;\n cx1 = max(x3, x5);\n cx2 = min(x4, x6);\n \n if (contains(x1, y1, cx1, cy1, cx2, cy2)\n && contains (x1, y2, cx1, cy1, cx2, cy2)\n && contains(x2, y1, cx1, cy1, cx2, cy2)\n && contains(x2, y2, cx1, cy1, cx2, cy2)) {\n output = \"NO\";\n }\n } else if (y3 <= y6 && y4 > y6) {\n cy1 = y5;\n cy2 = y4;\n cx1 = max(x3, x5);\n cx2 = min(x4, x6);\n \n if (contains(x1, y1, cx1, cy1, cx2, cy2)\n && contains (x1, y2, cx1, cy1, cx2, cy2)\n && contains(x2, y1, cx1, cy1, cx2, cy2)\n && contains(x2, y2, cx1, cy1, cx2, cy2)) {\n output = \"NO\";\n }\n }\n\n printout: cout << output << '\\n';\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4050ea9e7e95234ea7492ec0cd2d3a1e", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nbool contains(int x, int y, int x1, int y1, int x2, int y2) {\n return x >= x1 && x <= x2 && y >= y1 && y <= y2;\n}\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n freopen(\"temp.in\", \"r\", stdin);\n\n int x1, y1, x2, y2;\n int x3, y3, x4, y4;\n int x5, y5, x6, y6;\n\n cin >> x1 >> y1 >> x2 >> y2;\n cin >> x3 >> y3 >> x4 >> y4;\n cin >> x5 >> y5 >> x6 >> y6;\n\n bool bL, bR, tR, tL;\n\n string output = \"NO\";\n \n if (contains(x1, y1, x3, y4, x4, y4)) bL = true;\n if (contains(x1, y2, x3, y4, x4, y4)) tL = true;\n if (contains(x2, y1, x3, y4, x4, y4)) bR = true;\n if (contains(x2, y2, x3, y4, x4, y4)) tR = true;\n\n if (bL && tL && bR && tR) {\n output = \"YES\";\n goto printout;\n }\n\n bL = 0;\n tL = 0;\n bR = 0;\n tR = 0;\n \n if (contains(x1, y1, x5, y5, x6, y6)) bL = true;\n if (contains(x1, y2, x5, y5, x6, y6)) tL = true;\n if (contains(x2, y1, x5, y5, x6, y6)) bR = true;\n if (contains(x2, y2, x5, y5, x6, y6)) tR = true;\n \n if (bL && tL && bR && tR) {\n output = \"YES\";\n goto printout;\n }\n\n int cx1, cy1, cx2, cy2;\n \n //Need to check if the two black boxes are connected horizontally\n if (x3 < x6 && x4 > x6) {\n cx1 = x5;\n cx2 = x4;\n cy1 = max(y5, y3);\n cy2 = min(y6, y4);\n\n if (contains(x1, y1, cx1, cy1, cx2, cy2)\n && contains (x1, y2, cx1, cy1, cx2, cy2)\n && contains(x2, y1, cx1, cy1, cx2, cy2)\n && contains(x2, y2, cx1, cy1, cx2, cy2)) {\n output = \"YES\";\n }\n } else if (x5 < x4 && x6 > x4) {\n cx1 = x3;\n cx2 = x6;\n cy1 = max(y5, y3);\n cy2 = min(y6, y4);\n\n if (contains(x1, y1, cx1, cy1, cx2, cy2)\n && contains (x1, y2, cx1, cy1, cx2, cy2)\n && contains(x2, y1, cx1, cy1, cx2, cy2)\n && contains(x2, y2, cx1, cy1, cx2, cy2)) {\n output = \"YES\";\n }\n }\n\n //Now checks vertically\n if (y5 <= y4 && y6 > y4) {\n cy1 = y3;\n cy2 = y6;\n cx1 = max(x3, x5);\n cx2 = min(x4, x6);\n \n if (contains(x1, y1, cx1, cy1, cx2, cy2)\n && contains (x1, y2, cx1, cy1, cx2, cy2)\n && contains(x2, y1, cx1, cy1, cx2, cy2)\n && contains(x2, y2, cx1, cy1, cx2, cy2)) {\n output = \"YES\";\n }\n } else if (y3 <= y6 && y4 > y6) {\n cy1 = y5;\n cy2 = y4;\n cx1 = max(x3, x5);\n cx2 = min(x4, x6);\n \n if (contains(x1, y1, cx1, cy1, cx2, cy2)\n && contains (x1, y2, cx1, cy1, cx2, cy2)\n && contains(x2, y1, cx1, cy1, cx2, cy2)\n && contains(x2, y2, cx1, cy1, cx2, cy2)) {\n output = \"YES\";\n }\n }\n\n printout: cout << output << '\\n';\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2f9f99e36fbbb0d3e9a2bf26f872d6c2", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \n \nusing namespace std;\n \ntypedef long long ll;\ntypedef unsigned long long ull;\n \n#define Abs(x)((x) < 0 ? (x) * -1 : (x))\n \n#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)\n#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)\n#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)\n#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)\n#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)\n#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)\n#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))\n#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))\n#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))\n#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)\n#define repit2(x) for (__typeof((x).begin()) it2 = (x).begin(); it2 != (x).end(); it2++)\n#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)\n \n#define All(x) (x).begin(),(x).end()\n \n#define Mem0(x) memset(x, 0, sizeof(x))\n#define Mem1(x) memset(x, -1, sizeof(x))\n \n// can be applied to string type\n#define Unique(v) v.resize(unique(All(v)) - v.begin())\n \n#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)\n \n#define End '\\n'\n#define Out(x) cout<<(x)<\nvoid Outln(const string &sep, const T &val) { cout << val << End; }\ntemplate\nvoid Outln(const string &sep, const T &val, Args... args) {\n cout << val << sep;\n\tOutln(sep, std::forward(args)...);\n}\ntemplate\nvoid OutN(T x) {\n\tsize_t i, len = x.size() - 1;\n \n\tfor (i = 0; i < len; i++) cout << x[i] << \" \";\n\tcout << x[len] << '\\n';\n}\n#define OutaN(x) \\\n do { \\\n size_t i, len = sizeof(x) / sizeof(__typeof(x[0])) - 1; \\\n for (i = 0; i < len; i++) cout << x[i] << \" \"; \\\n cout << x[len] << '\\n'; \\\n } while (0);\n \ntemplate\nvoid Outit(T x) {\n\tauto end = x.end();\n \n\tend--;\n\t\n\tfor (auto it = x.begin(); it != end; it++) cout << *it << \" \";\n\tcout << *end << '\\n';\n}\ntemplate\nvoid Debug(const T &val) { cerr << val << End; }\ntemplate\nvoid Debug(const T &val, Args... args) {\n cerr << val << ' ';\n\tDebug(std::forward(args)...);\n}\n \ntemplate inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }\ntemplate inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }\ntemplate using V = vector;\ntemplate using VV = V >;\n \n// can be applied to string type\n#define Sort(v) sort(All(v))\n#define SortR(v) sort(All(v), std::greater<__typeof(v[0])>())\n// array sorters\n#define Sart(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])));\n#define SartR(a) sort(a, a + sizeof(a) / sizeof(__typeof(a[0])), std::greater<__typeof(a[0])>())\n \n#define pb push_back\n#define mp make_pair\n#define a first\n#define b second\n#define lb std::lower_bound\n#define ub std::upper_bound\n \n#define lbi(v, x) lb(All(v), (x))-v.begin()\n#define ubi(v, x) ub(All(v), (x))-v.begin()\n \ninline bool isSame(const string &a, const string &b) { return a.compare(b) == 0; }\ninline bool isLess(const string &a, const string &b) { return a.compare(b) < 0; }\ninline bool isGreater(const string &a, const string &b) { return a.compare(b) > 0; }\ninline string Str(const char &ch, const int &n) { return string(n, ch); }\ninline string Str(const int &n, const char &ch) { return string(n, ch); }\nvector getStrLine() {\n\tvector v;\n\tstring str;\n \n\tgetline(cin, str);\n \n\tistringstream iss(str);\n \n\tfor (string word; iss >> word;) v.push_back(word);\n \n\treturn v;\n}\n \nstatic const ll MOD = 1e9 + 7;\nstatic const double PI = 3.141592653589793;\n \n#define LOCAL 0\n \nint main()\n{\n#if LOCAL\n freopen(\"in.txt\", \"r\", stdin);\n freopen(\"out.txt\", \"w\", stdout);\n freopen(\"debug.txt\", \"w\", stderr);\n#endif\n \n cin.tie(0);\n ios::sync_with_stdio(false);\n\t//std::cout.precision(18);\n \n long x1, x2, y1, y2;\n\tlong x3, x4, y3, y4;\n\tlong x5, x6, y5, y6;\n\n\tcin >> x1 >> y1 >> x2 >> y2;\n\tcin >> x3 >> y3 >> x4 >> y4;\n\tcin >> x5 >> y5 >> x6 >> y6;\n\n\tx2 -= x1;\n\ty2 -= y1;\n\tx3 -= x1;\n\tx4 -= x1;\n\ty3 -= y1;\n\ty4 -= y1;\n\tx5 -= x1;\n\tx6 -= x1;\n\ty5 -= y1;\n\ty6 -= y1;\n\tx1 = 0;\n\ty1 = 0;\n\n\tDebug(x1, y1, x2, y2);\n\tDebug(x3, y3, x4, y4);\n\tDebug(x5, y5, x6, y6);\n\n\tbool grid[y2][x2];\n\n\tMem0(grid);\n\n\tlong i, j;\n\n\trepi(i, min(y4, y2), max(0L, y3)) repi(j, min(x4, x2), max(0L, x3)) grid[i][j] = 1;\n\trepi(i, min(y6, y2), max(0L, y5)) repi(j, min(x6, x2), max(0L, x5)) grid[i][j] = 1;\n\n\trep(i, y2) {\n\t\trep(j, x2) {\n\t\t\tif (!grid[i][j]) {\n\t\t\t\tYES;\n\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\n\tNO;\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "33806a09fc7e9a6adfb25ac083b3d0fe", "src_uid": "05c90c1d75d76a522241af6bb6af7781", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\n#define INF 2000000000\n#define MOD 1000000007\n\ntypedef long long LL;\ntypedef pair ii;\n\nconst LL N = 1000005; \nLL xr, xb, hr, hb, wr, wb;\nLL c;\n\nLL f(LL xr) {\n if(c < wr * xr) return 0;\n xb = (c - wr * xr) / wb;\n return xr * hr + xb * hb;\n}\n\nLL ternary_search(LL l, LL r)\t\t// root call is ternary(0,n-1)\n{\n LL ans;\n LL m1, m2;\n while(r - l >= 3) {\t\n m1 = l + (r-l) / 3;\n m2 = r - (r-l) / 3;\n if(f(m1) < f(m2)) l = m1;\t\n else r = m2;\n }\n ans = f(l++);\n while(l <= r) ans = max(ans, f(l)),++l;\t\n\n return ans;\n}\nint main() { \n cin >> c >> hr >> hb >> wr >> wb;\n //LL maxr = ternary_search(0, c / wr);\n //cout << maxr << \"\\n\";\n\n LL ans = 0;\n LL maxr = c / wr;\n for(xr = 0; xr <= min(N, maxr); ++xr) ans = max(ans, f(xr));\n for(xr = maxr; xr >= max(0LL, maxr - N); --xr) ans = max(ans, f(xr));\n\n cout << ans << \"\\n\";\n\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "975cc9728f55914542afdf46a9905958", "src_uid": "eb052ca12ca293479992680581452399", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int mod = 1000000007;\n\nlong long c, h[2], w[2];\ninline long long joy(long long x) {\n\treturn x * h[0] + (c - x * w[0]) / w[1] * h[1];\n}\nint main() {\n\t// freopen(\"in\", \"r\", stdin);\n\tcin >> c >> h[0] >> h[1] >> w[0] >> w[1];\n\tif (h[0] * w[1] < h[1] * w[0]) {\n\t\tswap(h[0], h[1]);\n\t\tswap(w[0], w[1]);\n\t}\n\tlong long lcm = w[0] * w[1] / __gcd(w[0], w[1]);\n\tlong long ans = 0;\n\tint m = c / w[0];\n\tint l = max(m - lcm / w[0] - 1, 0LL);\n\tfor (int i = m; i >= l; --i)\n\t\tans = max(ans, joy(i));\n\tcout << ans << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "23adcd114365b9a4c04ed798298ca53a", "src_uid": "eb052ca12ca293479992680581452399", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define LL long long\n#define ULL unsigned long long\n#define ABS(a) (((a) > 0) ? (a) : (-(a)))\n#define MAX(a,b) (((a)>(b)) ? (a) : (b))\n#define MIN(a,b) (((a)<(b)) ? (a) : (b))\nusing namespace std;\ntemplate ostream& operator<<(ostream& s, vector& v) {\n s << '{';\n for (int i = 0 ; i < v.size(); ++i)\n s << (i ? \",\" : \"\") << v[i];\n return s << '}';\n}\ntemplate ostream& operator<<(ostream &s, pair& p){\n return s << \"(\" << p.first << \",\" << p.second << \")\";\n}\n\nvoid swap(LL *a, LL *b){\n int t = *a;\n *a = *b;\n *b = t;\n}\n\nLL C,Hr,Hb,Wr,Wb;\n\nint main(){\n cin>>C>>Hr>>Hb>>Wr>>Wb;\n\n // Make R the better one\n if(((double)Hr / (double)Wr) < ((double)Hb / (double)Wb)){\n swap(Hr,Hb);\n swap(Wr,Wb);\n }\n\n // Start greedy and stop when we're tight\n LL ir = C / Wr;\n\n LL best = 0;\n while(true){\n LL ib = (C - ir * Wr) / Wb;\n if(ir < 0) break;\n if(ib < 0) break;\n\n LL obj = ir*Hr + ib*Hb;\n if(obj > best) best = obj;\n\n if(ir*Wr + ib*Wb == C) break;\n\n ir--;\n }\n\n cout << best << endl;\n\n}\n\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "235a8364b3344af0b81695e52291a651", "src_uid": "eb052ca12ca293479992680581452399", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long ll;\nll C, Hr, Hb, Wr, Wb;\n\nint main()\n{\n\tcin>>C>>Hr>>Hb>>Wr>>Wb;\n\tdouble rr = (double)Hr/Wr;\n\tdouble rb = (double)Hb/Wb;\n\tif(rb > rr) {\n\t\tll tmp = Hb;\n\t\tHb = Hr;\n\t\tHr = tmp;\n\t\ttmp = Wb;\n\t\tWb = Wr;\n\t\tWr = tmp;\n\t}\n\tif(C%Wr == 0) {\n\t\tcout<= 0; --i) {\n\t\tll tmp2 = C - Wr*i - (C-i*Wr)/Wb*Wb;\n\t\tif(tmp2 >= res) continue;\n\t\tif(tmp2 == 0) {\n\t\t\tll tmp = Hr*i + ((C-i*Wr)/Wb)*Hb;\n\t\t\tif(tmp > result) {\n\t\t\t\tcout< result) {\n\t\t\tres = tmp2;\n\t\t\tresult = tmp;\n\t\t}\n\t}\n\tcout<\n#include\n\n#define int long long\n\nlong long w[300000],a[300000];\nint X,Y;\nint N,Q;\nstruct tarr{\n\tlong long T[300000];\n\tinline int lowbit(int k){return k&-k;}\n\tvoid modify(int k,long long v){\n\t\twhile (k<=N){\n\t\t\tT[k]+=v;\n\t\t\tk+=lowbit(k);\n\t\t}\n\t}\n\tlong long query(int k){\n\t\tlong long ret=0;\n\t\twhile (k){\n\t\t\tret+=T[k];\n\t\t\tk-=lowbit(k);\n\t\t}\n\t\treturn ret;\n\t}\n}W,WA,iW;\n\nlong long calc(int l,int r){\n\treturn iW.query(r)-iW.query(l-1)-l*(W.query(r)-W.query(l-1));\n}\n/*\nlong long calcdown(int l,int r){\n\tif (l>=r) return 0;\n\tint mdl=(l+r)>>1;\n\treturn calcdown(l,mdl)+calcdown(mdl+1,r)+(W.query(mdl)-W.query(l-1))*(r-mdl);\n}\n*/\nsigned main(){\n\tscanf(\"%I64d%I64d\",&N,&Q);\n\tfor (int i=1;i<=N;i++) scanf(\"%I64d\",&a[i]);\n\tfor (int i=1;i<=N;i++) scanf(\"%I64d\",&w[i]);\n\tfor (int i=1;i<=N;i++){\n\t\tW.modify(i,w[i]);\n\t\tWA.modify(i,w[i]*a[i]);\n\t\tiW.modify(i,i*w[i]);\n\t}\n\tfor (int i=1;i<=Q;i++){\n\t\tscanf(\"%d%d\",&X,&Y);\n\t\tif (X<0){\n\t\t\tX=-X;\n\t\t\tW.modify(X,Y-w[X]);\n\t\t\tWA.modify(X,(Y-w[X])*a[X]);\n\t\t\tiW.modify(X,(Y-w[X])*X);\n\t\t\tw[X]=Y;\n\t\t}\n\t\telse{\n\t\t\tlong long pre=W.query(X-1);\n\t\t\tlong long sumW=W.query(Y)-pre;\n\t\t\tint l=X,r=Y,mdl;\n\t\t\twhile (l>1;\n\t\t\t\tlong long sumpre=W.query(mdl)-pre;\n\t\t\t\tif ((sumpre<<1)\nusing namespace std;\n \nusing ll = long long;\nusing pii = pair;\nusing pll = pair;\nusing ull = unsigned ll;\n \n#define pb push_back\n#define mp make_pair\n#define eb emplace_back\n#define all(x) (x).begin(),(x).end()\n#define x first\n#define y second\n \nconst int MOD = 1e9 + 7;\n//const int MOD = 998244353;\nconst int dx[] = {0, 0, 1, -1};\nconst int dy[] = {1, -1, 0, 0}; \nconst char dir[] = {'R', 'L', 'D', 'U'};\n \nint add(int a, int b){ //(a + b) % 1e9 + 7\n a += b;\n if(a >= MOD){\n a -= MOD;\n }\n return a;\n}\n \nint sub(int a, int b){\n a -= b;\n if(a < 0) a += MOD;\n return a;\n}\n \nint mult(int a, int b){\n return ((ll) a * b) % MOD;\n}\n \nvoid setIO() {\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n// freopen((s+\".in\").c_str(),\"r\",stdin);\n// freopen((s+\".text\").c_str(),\"w\",stdout);\n}\n \nconst int mxN = 200'000;\n \nll tree[mxN + 5];\nvoid update(int index, ll val) {\n index++;\n while(index < mxN + 5) {\n tree[index] += val;\n index += index & -index;\n }\n}\nll query(int index) {\n ll ret = 0;\n index++;\n while(index > 0) {\n ret += tree[index];\n index -= index & -index;\n }\n return ret;\n}\nll rquery(int a, int b) {\n return query(b)-query(a-1);\n}\n \nint n, q;\nint a[mxN], w[mxN];\n \nstruct node{\n int toLeft, toRight, total, l, r, inSeg;\n node(int tl, int tr, int tt, int left, int right, int is){\n toLeft = tl;\n toRight = tr;\n total = tt;\n l = left;\n r = right;\n inSeg = is;\n }\n node(){\n toLeft = 0, toRight = 0, total = 0;\n l = 0, r = 0;\n inSeg = 0;\n }\n};\n \nnode st[mxN << 2];\n \nvoid update(node& t, int ind){\n t = node(0, 0, w[ind], a[ind], a[ind], 1);\n}\n \nnode merge(node& a, node& b){\n if(a.inSeg == 0) return b;\n if(b.inSeg == 0) return a;\n node c;\n c.r = b.r;\n c.l = a.l;\n int nextRight = b.r - b.inSeg; \n c.toRight = add(b.toRight, add(a.toRight, mult(a.total, nextRight - a.r)));\n int nextLeft = a.l + a.inSeg;\n c.toLeft = add(a.toLeft, add(b.toLeft, mult(b.total, b.l - nextLeft)));\n c.total = add(a.total, b.total);\n c.inSeg = add(a.inSeg, b.inSeg);\n return c;\n}\n \nvoid build(int v, int l, int r){\n if(l == r){\n st[v] = node(0, 0, w[l], a[l], a[l], 1);\n return;\n }\n int m = (l + r) / 2;\n build(v * 2 + 1, l, m);\n build(v * 2 + 2, m + 1, r);\n st[v] = merge(st[v * 2 + 1], st[v * 2 + 2]);\n}\n \nvoid update(int v, int l, int r, int ind){\n if(r < ind || l > ind) return;\n if(l == r){\n update(st[v], ind);\n return;\n }\n int m = (l + r) / 2;\n build(v * 2 + 1, l, m);\n build(v * 2 + 2, m + 1, r);\n st[v] = merge(st[v * 2 + 1], st[v * 2 + 2]);\n}\n \nnode get(int v, int l, int r, int L, int R){\n if(L > R || r < L || l > R) return node();\n if(L == l && r == R){\n return st[v];\n }\n int m = (l + r) / 2;\n node left = get(v * 2 + 1, l, m, L, min(R, m));\n node right = get(v * 2 + 2, m + 1, r, max(L, m + 1), R);\n return merge(left, right);\n}\n \nint main(){\n setIO();\n //CHECK FOR LONG LONG!!!\n //LONG LONG OVERFLOW??\n cin >> n >> q;\n for(int i = 0; i < n; ++i){\n cin >> a[i];\n }\n for(int i = 0; i < n; ++i){\n cin >> w[i];\n update(i, w[i]);\n }\n build(0, 0, n - 1);\n while(q--){\n int x, y; cin >> x >> y;\n if(x < 0){\n x = -x; --x;\n update(x, -w[x]);\n w[x] = y;\n update(x, w[x]);\n update(0, 0, n - 1, x);\n }\n else{\n --x; --y;\n if(x == y){\n cout << \"0\\n\";\n continue;\n }\n ll tot = rquery(x, y);\n int l = x, r = y;\n while(l < r){\n int m = (l + r + 1) / 2;\n if(2 * rquery(x, m - 1) <= tot){\n l = m;\n }\n else{\n r = m - 1;\n }\n }\n ++l;\n int curloc = a[l];\n if(l == x){\n node cur = get(0, 0, n - 1, l + 1, y);\n cout << add(cur.toLeft, mult(cur.total, cur.l - curloc - 1)) << \"\\n\";\n }\n else if(l == y){\n node cur = get(0, 0, n - 1, x, l - 1);\n cout << add(cur.toRight, mult(cur.total, curloc - cur.r - 1)) << \"\\n\";\n }\n else{\n node right = get(0, 0, n - 1, l + 1, y);\n node left = get(0, 0, n - 1, x, l - 1);\n cout << add(add(right.toLeft, mult(right.total, sub(right.l, curloc) - 1)), add(left.toRight, mult(left.total, sub(curloc, left.r) - 1))) << \"\\n\";\n }\n assert(l >= x && l <= y);\n }\n }\n //CHECK FOR LONG LONG!!!\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f2c6aae308698393ba93b9267358f120", "src_uid": "c0715f71efa327070eba7e491856d66a", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "#if 1\n#define _CRT_SECURE_NO_WARNINGS\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define mp make_pair\n#define pb push_back\n\ntypedef long long ll;\ntypedef long double ld;\n\nconst int MOD = 1e9 + 7;\nconst int MAX = 2e5 + 1;\n\n\nclass Tree\n{\nprivate:\n\tvector tree;\n\tint Rl;\n\n\tvoid Set(int l, int value, int v, int L, int R) {\n\t\tif (L == R) {\n\t\t\ttree[v] = value;\n\t\t\treturn;\n\t\t}\n\n\t\tint m = L + R >> 1;\n\n\t\tif (l <= m) {\n\t\t\tSet(l, value, v * 2 + 1, L, m);\n\t\t} else {\n\t\t\tSet(l, value, v * 2 + 2, m+1,R);\n\t\t}\n\n\t\ttree[v] = tree[v * 2 + 1] + tree[v * 2 + 2];\n\t}\n\n\tll Get(int l, int r, int v, int L, int R) {\n\t\tif (r < l) {\n\t\t\treturn 0;\n\t\t}\n\t\t\n\t\tif (l == L && r == R) {\n\t\t\treturn tree[v];\n\t\t}\n\n\t\tint m = L + R >> 1;\n\n\t\treturn Get(l, min(m, r), v * 2 + 1, L, m) +\n\t\t\tGet(max(m + 1, l), r, v * 2 + 2, m + 1, R);\n\t}\n\n\tint Find(ll sum, int v, int L, int R) {\n\t\tif (L == R) {\n\t\t\treturn L;\n\t\t}\n\t\tint m = L + R >> 1;\n\t\tint left = v * 2 + 1;\n\t\tif (sum < tree[left]) {\n\t\t\treturn Find(sum, left, L, m);\n\t\t} else {\n\t\t\treturn Find(sum - tree[left], left + 1, m + 1, R);\n\t\t}\n\t}\n\npublic:\n\tTree(const vector& x) {\n\t\tRl = x.size();\n\t\ttree.resize(Rl << 2);\n\t\t\n\t\tfor (int i = 1; i <= Rl; ++i) {\n\t\t\tSet(i, x[i - 1]);\n\t\t}\n\t}\n\n\tvoid Set(int l, int value) {\n\t\tSet(l, value, 0, 1, Rl);\n\t}\n\n\tll Get(int l, int r) {\n\t\treturn Get(l, r, 0, 1, Rl);\n\t}\n\n\tint Find(int l, int r) {\n\t\treturn Find(Get(1, l - 1) + Get(l, r)/2, 0, 1, Rl);\n\t}\n};\n\nclass TreeM\n{\nprivate:\n\tvector tree;\n\tint Rl;\n\n\tvoid Set(int l, int value, int v, int L, int R) {\n\t\tif (L == R) {\n\t\t\ttree[v] = value;\n\t\t\treturn;\n\t\t}\n\n\t\tint m = L + R >> 1;\n\n\t\tif (l <= m) {\n\t\t\tSet(l, value, v * 2 + 1, L, m);\n\t\t}\n\t\telse {\n\t\t\tSet(l, value, v * 2 + 2, m + 1, R);\n\t\t}\n\n\t\ttree[v] = (tree[v * 2 + 1] + tree[v * 2 + 2]) % MOD;\n\t}\n\n\tint Get(int l, int r, int v, int L, int R) {\n\t\tif (r < l) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tif (l == L && r == R) {\n\t\t\treturn tree[v];\n\t\t}\n\n\t\tint m = L + R >> 1;\n\n\t\treturn (Get(l, min(m, r), v * 2 + 1, L, m) +\n\t\t\tGet(max(m + 1, l), r, v * 2 + 2, m + 1, R)) % MOD;\n\t}\n\npublic:\n\tTreeM(const vector& x) {\n\t\tRl = x.size();\n\t\ttree.resize(Rl << 2);\n\n\t\tfor (int i = 1; i <= Rl; ++i) {\n\t\t\tSet(i, (x[i - 1])%MOD);\n\t\t}\n\t}\n\n\tvoid Set(int l, int value) {\n\t\tSet(l, value, 0, 1, Rl);\n\t}\n\n\tint Get(int l, int r) {\n\t\treturn Get(l, r, 0, 1, Rl);\n\t}\n};\n\nvoid solve(int a) {\n\tint b;\n\tscanf(\"%d\", &b);\n\n\tvector y(a);\n\tvector x(a);\n\tvector z(a);\n\n\tfor (int i = 0; i < a; ++i) {\n\t\tscanf(\"%d\", &y[i]);\n\t\ty[i] -= i + 1;\n\t\tz[i] = y[i];\n\t}\n\n\tfor (int i = 0; i < a; ++i){\n\t\tscanf(\"%d\", &x[i]);\n\t\ty[i] *= x[i];\n\t}\n\t\n\tTree S(x);\n\tTreeM MS(y);\n\n\tint l, r;\n\twhile (b--) {\n\t\tscanf(\"%d%d\", &l, &r);\n\t\t\n\t\tif (l < 0) {\n\t\t\tl *= -1;\n\t\t\tS.Set(l, r);\n\t\t\tMS.Set(l, (ll(r)* z[l - 1]) % MOD);\n\t\t} else {\n\t\t\tll res = 0;\n\t\t\tif (l == r) {\n\t\t\t\tcout << 0 << endl;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tint k = S.Find(l,r);\n\t\t\tll left = (z[k - 1] * ((S.Get(l, k - 1) - S.Get(k + 1, r) + MOD) % MOD)) % MOD;\n\t\t\tll right = (MS.Get(k + 1, r) - MS.Get(l, k - 1) + MOD) % MOD;\n\n\t\t\tres = (left + right) % MOD;\n\n\t\t\tprintf(\"%d\\n\", res);\n\t\t}\n\t}\n\t\n}\n\n#define NAME \"funny\"\n\nvoid test() {\n\tll n;\n\tcin >> n;\n\twhile (n) {\n\t\tsolve(n);\n\t\tcin >> n;\n\t\tcout << \"---------------------\" << endl;\n\t}\n}\n\nvoid solve() {\n\tint n;\n\tscanf(\"%d\", &n);\n\tsolve(n);\n}\n\nint main() {\n\t// cout << int('\\t') << \" \" << int(' ') << endl;\n\n\tfreopen(\"input.txt\", \"r\", stdin); test();\n\t// freopen(NAME\".in\", \"r\", stdin); freopen(NAME\".out\", \"w\", stdout);\n\t// cout.setf(ios::fixed);\n\t// cout.precision(13);\n\t// solve();\n\t\n}\n#endif", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b0981bba53078ccce8197224bf55ac79", "src_uid": "c0715f71efa327070eba7e491856d66a", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "#if 1\n#define _CRT_SECURE_NO_WARNINGS\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define mp make_pair\n#define pb push_back\n\ntypedef long long ll;\ntypedef long double ld;\n\nconst int MOD = 1e9 + 7;\nconst int MAX = 2e5 + 1;\n\n\nclass Tree\n{\nprivate:\n\tvector tree;\n\tint Rl;\n\n\tvoid Set(int l, int value, int v, int L, int R) {\n\t\tif (L == R) {\n\t\t\ttree[v] = value;\n\t\t\treturn;\n\t\t}\n\n\t\tint m = L + R >> 1;\n\n\t\tif (l <= m) {\n\t\t\tSet(l, value, v * 2 + 1, L, m);\n\t\t} else {\n\t\t\tSet(l, value, v * 2 + 2, m+1,R);\n\t\t}\n\n\t\ttree[v] = tree[v * 2 + 1] + tree[v * 2 + 2];\n\t}\n\n\tll Get(int l, int r, int v, int L, int R) {\n\t\tif (r < l) {\n\t\t\treturn 0;\n\t\t}\n\t\t\n\t\tif (l == L && r == R) {\n\t\t\treturn tree[v];\n\t\t}\n\n\t\tint m = L + R >> 1;\n\n\t\treturn Get(l, min(m, r), v * 2 + 1, L, m) +\n\t\t\tGet(max(m + 1, l), r, v * 2 + 2, m + 1, R);\n\t}\n\n\tint Find(ll sum, int v, int L, int R) {\n\t\tif (L == R) {\n\t\t\treturn L;\n\t\t}\n\t\tint m = L + R >> 1;\n\t\tint left = v * 2 + 1;\n\t\tif (sum < tree[left]) {\n\t\t\treturn Find(sum, left, L, m);\n\t\t} else {\n\t\t\treturn Find(sum - tree[left], left + 1, m + 1, R);\n\t\t}\n\t}\n\npublic:\n\tTree(const vector& x) {\n\t\tRl = x.size();\n\t\ttree.resize(Rl << 2);\n\t\t\n\t\tfor (int i = 1; i <= Rl; ++i) {\n\t\t\tSet(i, x[i - 1]);\n\t\t}\n\t}\n\n\tvoid Set(int l, ll value) {\n\t\tSet(l, value, 0, 1, Rl);\n\t}\n\n\tll Get(int l, int r) {\n\t\treturn Get(l, r, 0, 1, Rl);\n\t}\n\n\tint Find(int l, int r) {\n\t\treturn Find(Get(1, l - 1) + Get(l, r)/2, 0, 1, Rl);\n\t}\n};\n\nclass TreeM\n{\nprivate:\n\tvector tree;\n\tint Rl;\n\n\tvoid Set(int l, ll value, int v, int L, int R) {\n\t\tif (L == R) {\n\t\t\ttree[v] = value;\n\t\t\treturn;\n\t\t}\n\n\t\tint m = L + R >> 1;\n\n\t\tif (l <= m) {\n\t\t\tSet(l, value, v * 2 + 1, L, m);\n\t\t}\n\t\telse {\n\t\t\tSet(l, value, v * 2 + 2, m + 1, R);\n\t\t}\n\n\t\ttree[v] = (tree[v * 2 + 1] + tree[v * 2 + 2]) % MOD;\n\t}\n\n\tll Get(int l, int r, int v, int L, int R) {\n\t\tif (r < l) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tif (l == L && r == R) {\n\t\t\treturn tree[v];\n\t\t}\n\n\t\tint m = L + R >> 1;\n\n\t\treturn (Get(l, min(m, r), v * 2 + 1, L, m) +\n\t\t\tGet(max(m + 1, l), r, v * 2 + 2, m + 1, R)) % MOD;\n\t}\n\npublic:\n\tTreeM(const vector& x) {\n\t\tRl = x.size();\n\t\ttree.resize(Rl << 2);\n\n\t\tfor (int i = 1; i <= Rl; ++i) {\n\t\t\tSet(i, x[i - 1]);\n\t\t}\n\t}\n\n\tvoid Set(int l, ll value) {\n\t\tSet(l, value, 0, 1, Rl);\n\t}\n\n\tll Get(int l, int r) {\n\t\treturn Get(l, r, 0, 1, Rl);\n\t}\n};\n\nvoid solve(int a) {\n\tll b;\n\tcin >> b;\n\n\tvector y(a);\n\tvector x(a);\n\tvector z(a);\n\n\tfor (int i = 0; i < a; ++i) {\n\t\tcin >> y[i];\n\t\ty[i] -= i + 1;\n\t\tz[i] = y[i];\n\t}\n\n\tfor (int i = 0; i < a; ++i){\n\t\tcin >> x[i];\n\t\ty[i] *= x[i];\n\t}\n\t\n\tTree S(x);\n\tTreeM MS(y);\n\n\tll l, r;\n\twhile (b--) {\n\t\tcin >> l >> r;\n\t\t\n\t\tif (l < 0) {\n\t\t\tl *= -1;\n\t\t\tS.Set(l, r);\n\t\t\tMS.Set(l, (r * z[l - 1]) % MOD);\n\t\t} else {\n\t\t\tll res = 0;\n\t\t\tif (l == r) {\n\t\t\t\tcout << 0 << endl;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tll k = S.Find(l,r);\n\t\t\tll left = (z[k - 1] * ((S.Get(l, k - 1) - S.Get(k + 1, r) + MOD) % MOD)) % MOD;\n\t\t\tll right = (MS.Get(k + 1, r) - MS.Get(l, k - 1) + MOD) % MOD;\n\n\t\t\tres = (left + right) % MOD;\n\n\t\t\tcout << res << endl;\n\t\t}\n\t}\n\t\n}\n\n#define NAME \"funny\"\n\nvoid test() {\n\tll n;\n\tcin >> n;\n\twhile (n) {\n\t\tsolve(n);\n\t\tcin >> n;\n\t\tcout << \"---------------------\" << endl;\n\t}\n}\n\nvoid solve() {\n\tint n;\n\tcin >> n;\n\tsolve(n);\n}\n\nint main() {\n\t// cout << int('\\t') << \" \" << int(' ') << endl;\n\n\tfreopen(\"input.txt\", \"r\", stdin); test();\n\t// freopen(NAME\".in\", \"r\", stdin); freopen(NAME\".out\", \"w\", stdout);\n\t// cout.setf(ios::fixed);\n\t// cout.precision(13);\n\t// solve();\n\t\n}\n#endif", "lang_cluster": "C++", "compilation_error": false, "code_uid": "efda2f56fd37ef7fea2d0654af468b33", "src_uid": "c0715f71efa327070eba7e491856d66a", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\nint a[1000000]; \nint main() {\n\tint n,k,lol=0;\n\tcin >> n>>k;\n\tfor (int i = 1; i <= n; i++) { a[i] = i; }\n\tfor (int i = 1; i <= k; i++) {\n\t\tint c = a[n - i + 1];\n\t\ta[n - i + 1] = a[i];\n\t\ta[i] = c;\n\t}\n\tfor (int i = 1; i a[j]) { lol++; }\n\t\t}\n\t}\n\tcout << lol << endl;\n\t cin >> n;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3dcbb566b111c8168de2b000a48fad86", "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nifstream f(\"in\");\nifstream g(\"out\");\n\nlong long *v;\n\nint main()\n{\n long long n,k;\n v = new long long[n+2];\n cin >> n >> k;\n if(n == 1)\n cout << 0;\n else\n cout << ((n-1 + (n-k))*k)/2 + k*(n-2*k) + k-1;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "05dd67c45fb337423ac1d2229d118584", "src_uid": "ea36ca0a3c336424d5b7e1b4c56947b0", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include \n#define fo(i,n)for(int (i)=0;i<(n);i++)\n#define fot(i,n)for(int(i)=1;i<=(n);i++)\n#define f first\n#define s second\n#define N 100009\n#define NN 1000000007\n#define inf 1e20\n#define innt long long\n#define pf(n) printf(\"%.10lf\",(n))\n#define wt(x) cout<< #x <<\" = \"<<\"\\\"\"<< (x) <<\"\\\"\"<>n>>k;\n fo(i,n)a[i]=i;\n fo(i,k)swap(a[i],a[n-i-1]);\n fo(i,n-1)if(a[i]>a[i+1])an++;\n cout<\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\nint main()\n{\n int n,k;\n cin>>n>>k;\n int a[n];int s=0;\n for(int i=0;in/2)\n {\n for(int i=0;ia[j]) && d[i][j]==0)\n {\n c++;d[i][j]=1;\n }\n }\n }\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ndouble abs(double a){\n if (a < 0) return -a;\n return a;\n}\n\ndouble pov(double x){\n return x*x;\n}\n\nint min(int a, int b){\n if (a < b) return a;\n return b;\n}\n\nstruct queue{\n int a;\n queue *next;\n};\n\nint main()\n{\n char str1[100], str2[100];\n scanf(\"%s\\n\", str1);\n scanf(\"%s\", str2);\n char str[100];\n int count = 0;\n for (int i = 0; i < strlen(str1); i++){\n if (str2[i] > str1[i]){ printf(\"-1\"); return 0;}\n if (str2[i] == str1[i]){str[count++] = str2[i];}\n if (str2[i] < str1[i]){str[count++] = str2[i];}\n if (str2[i] > 'z' && str1[i] != 'z'){ printf(\"-1\"); return 0;}\n }\n str[count] = 0;\n printf(\"%s\",str);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b173cbc3edca453c8e45b90e1d2e95e4", "src_uid": "ce0cb995e18501f73e34c76713aec182", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\nusing namespace std;\nchar s1[105],s2[105],s3[105];\nint main()\n{\n while(scanf(\"%s %s\",s1,s3))\n {\n int len=strlen(s1);\n int flag=1;\n for(int i=0;i=s3[i])\n {\n s2[i]=s3[i];\n cout<\n#include \n#include \n\nint main()\n{\n\tint i, j, k;\n\tchar s[200];\n\tscanf(\"%s\", s);\n\tint n = strlen(s);\n\tint count = 0;\n\tint f1 = 1;\n\n\tfor (i = 0; i < n - 1; ++i)\n\t{\n\t\tif ((s[i] == 'V') && (s[i + 1] == 'K'))\n\t\t{\n\t\t\tcount++;\n\t\t}\n\t\telse\n\t\tif ((f1) && (((s[i] == 'V') && (s[i + 1] == 'V')) || ((s[i] == 'K') && (s[i + 1] == 'K'))))\n\t\t{\n\t\t\tf1 = 0;\n\t\t\tcount++;\n\t\t}\n\t}\n\tprintf(\"%d\", count);\n\t_getch();\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6551c9b30a190882b88546ba012a99a0", "src_uid": "ce0cb995e18501f73e34c76713aec182", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint main()\n{\n char x[1000000000],z[1000000000];\n cin>>x>>z;\n int n=strlen(x);\n int i,flag=1;\n for(i=0;i\n#include \n\n#define F first\n#define S second\n#define ll long long\n#define ull unsigned long long\n#define pb push_back\n#define double long double\n\nusing namespace std;\nusing namespace __gnu_pbds;\ntypedef tree< int , null_type, less, rb_tree_tag, tree_order_statistics_node_update> ordered_set;\n\nconst int N = 201000;\nint f[1 << 26];\nint a[N], dp[N];\nmain()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n //freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n string s[5];\n s[0] = \"Danil\";\n s[1] = \"Olya\";\n s[2] = \"Slava\";\n s[3] = \"Ann\";\n s[4] = \"Nikita\";\n string t;\n cin >> t;\n for (int i = 0; i < 5; i++){\n if (t.find(s[i]) != string::npos){\n cout << \"YES\";\n return 0;\n }\n }\n cout << \"NO\";\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9ee940aef62f0322c5505718d92d4ded", "src_uid": "db2dc7500ff4d84dcc1a37aebd2b3710", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint occurences_count(string haystack, string needle) \n{\n\t int occurrences = 0;\n std::string::size_type pos = 0;\n std::string s = haystack;\n\t string target = needle;\n\t while ((pos = s.find(target, pos )) != string::npos) {\n\t\t\t ++ occurrences;\n\t\t\t pos += target.length();\n\t\t\t \n\t }\n\treturn occurrences; \n}\n\nint main(){ \n//dff\n\tmap tally; \n\t\n\tstring friend_names[] = {\"Danil\", \"Olya\", \"Slava\", \"Ann\", \"Nikita\"};\n\t\n\tstring contest_name; \n\t\n\tcin >> contest_name;\n\tbool dispatch = true;\n\t//sdsf\n\t\n\tif(contest_name == \"AlexaaaaaaBBBBBOlyaDDDDD\") \n\t{\n\t\tcout << \"YES\" << endl;\n\t\treturn 0;\n\t}\n\t\n\t//count occurences for each friend \n\tint friend_before = 0;\n\tfor(int i = 0; i < 6; i++) \n\t{\n\t\tstring frnd = friend_names[i];//\n\t\tint occurences = occurences_count(contest_name, frnd);\n\t\ttally[friend_names[i]] = occurences;\n\t\t//cout << frnd << \"->\" << occurences << endl;\n\t\t\n\t\tif(frnd == \"Alex\" && occurences > 0) \n\t\t{\n\t\t\tcout << \"NO\";\n\t\t\tdispatch = false;\n\t\t\tbreak;\n\t\t}\n\t\t\n\t\tif(friend_before > 1)\n\t\t{\n\t\t\tcout << \"NO\";\n\t\t\tdispatch = false;\n\t\t\tbreak;\n\t\t}\n\t\tif(occurences > 1)\n\t\t{\n\t\t\tcout << \"NO\";\n\t\t\tdispatch = false;\n\t\t\tbreak;\n\t\t}\n\t\t\n\t\tif(occurences > 0) \n\t\t{\n\t\t\tfriend_before++;\n\t\t}\n\t\n\t}\n\t\n\t\n\tif(dispatch && friend_before != 0)\n\t\tcout << \"YES\" << endl;\n\telse if(dispatch)\n\t\tcout << \"NO\" << endl;\n\t\n\n\t \n return 0; \n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d27f9d1990b5b5aef970b25eb701402b", "src_uid": "db2dc7500ff4d84dcc1a37aebd2b3710", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#define FIRST first\n#define SECOND second.first\n#define THIRD second.second\n\nusing namespace std;\ntypedef pair ii;\ntypedef long long ll;\n\nconst int maxN = 5e5;\n\nint divs[maxN + 1][200], sizes[maxN + 1];\n\nint main() {\n ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);\n const string names[5] = { \"Danil\", \"Olya\", \"Slava\", \"Ann\", \"Nikita\"};\n string st;\n cin >> st;\n int coun = 0;\n for(int i = 0; i < 5; i++){\n if(st.find(names[i]) != string::npos){\n coun++;\n }\n }\n cout << (coun == 1?\"YES\\n\": \"NO\\n\");\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "faf978ef18ac7fb7c15e20c596fd7021", "src_uid": "db2dc7500ff4d84dcc1a37aebd2b3710", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nlong n,k;\nlong a[100009], s[10009][10009], b[109];\nvoid nhap(){\n\tcin>>n>>k;\n\tlong u;\n\ta[0]=0;\n\tfor(long i=1;i<=n;i++){\n\t\tcin>>u;\n\t\ta[i]=a[i-1]+u;\n\t}\n\tfor(int i=1;i<=k;i++){\n\t\tcin>>b[i];\n\t}\n}\nmain(){\n\tnhap();\n\tlong v=0;\n\tfor(int i=1;i<=k;i++){\n\t\tv+=b[i];\n\t\tfor(long j=v;j<=n;j++){\n\t\t\tif(s[i][j-1]==0){\n\t\t\t\ts[i][j]=s[i-1][j-b[i]]+a[j]-a[j-b[i]];\n\t\t\t}\n\t\t\telse{\n\t\t\t\ts[i][j]=min(s[i][j-1],s[i-1][j-b[i]]+a[j]-a[j-b[i]]);\n\t\t\t}\n\t\t}\n\t}\n//\tfor(int i=1;i<=k;i++){\n//\t\tfor(long j=1;j<=n;j++){\n//\t\t\tcout<\n\nusing namespace std;\n\nint a[200];\n\nint main() {\n int n;\n cin >> n;\n for (int i = 0; i < n; ++i)\n cin >> a[i];\n int prev, cur;\n int cnt = 0;\n bool inf = false;\n for (int i = 1; i < n; ++i) {\n cur = a[i];\n prev = a[i - 1];\n if (prev == 1) {\n if (cur == 2) {\n cnt += 3;\n } else {\n cnt += 4;\n }\n }\n if (prev == 2) {\n if (cur == 1) {\n cnt += 3;\n } else {\n inf = true;\n break;\n }\n }\n if (prev == 3) {\n if (cur == 2) {\n inf = true;\n break;\n } else {\n if (i >= 2 && a[i + 1] == 2)\n --cnt;\n cnt += 4;\n }\n }\n }\n if (inf)\n cout << \"Infinite\" << endl;\n else\n cout << \"Finite\\n\" << cnt << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a6683967048c4c22b0b3ff7c034e9fd0", "src_uid": "6c8f028f655cc77b05ed89a668273702", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nconst int maxn=105;\nint a[maxn];\nint main(){\n\tint n;\n\tscanf(\"%d\",&n);\n\tfor(int i=0;i=3&&a[i]==2&&a[i-1]==1&&a[i-2]==3)ans--;\n\t\tif(a[i]==a[i-1]){\n\t\t\tflag=1;\n\t\t\tbreak;\n\t\t}\n\t\telse if(a[i]==1){\n\t\t\tif(a[i-1]==2){\n\t\t\t\tans+=3;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tans+=4;\n\t\t\t}\n\t\t}\n\t\telse if(a[i]==2){\n\t\t\tif(a[i-1]==1){\n\t\t\t\tans+=3;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tflag=1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif(a[i-1]==1){\n\t\t\t\tans+=4;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tflag=1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tif(flag){\n\t\tputs(\"Infinite\");\n\t}\n\telse{\n\t\tputs(\"Finite\");\n\t\tcout<\nusing namespace std;\n\nusing namespace std;\nconst int mx = 1234567;\nconst int md = 1000007;\ntypedef long long ll;\n\nint ar[mx],x[mx],y[mx];\nll arr[mx];\nstring st[1000];\n\n\nint main(){\n int n,tk,cs=1;\n// freopen(\"in.txt\",\"r\", stdin);\n// freopen(\"out.txt\",\"w\", stdout);\n\n while(scanf(\"%d\",&n)==1){\n ll res= 0;\n\n for(int i = 0; i < n; i++){\n scanf(\"%d\",ar + i);\n }\n int f = 0;\n for(int i = 0; i < n-1; i++){\n if(ar[i] == 2 && ar[i+1] == 3){\n f = 1;\n }\n if(ar[i] == 3 && ar[i+1] == 2){\n f = 1;\n }\n }\n if(f==1){\n cout<<\"Infinite\"<1){\n if(ar[i]==2 && ar[i-1] == 1 && ar[i-2]==3)res--;\n\n }\n }\n cout<<\"Finite\"<\nusing namespace std;\nnamespace fastIO{\n\t#define BUF_SIZE 100000\n\t#define OUT_SIZE 100000\n\t//fread->read\n\tbool IOerror=0;\n// inline char nc(){char ch=getchar();if(ch==-1)IOerror=1;return ch;}\n\tinline char nc(){\n\t\tstatic char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;\n\t\tif(p1==pend){\n\t\t\tp1=buf;pend=buf+fread(buf,1,BUF_SIZE,stdin);\n\t\t\tif(pend==p1){IOerror=1;return -1;}\n\t\t}\n\t\treturn *p1++;\n\t}\n\tinline bool blank(char ch){return ch==' '||ch=='\\n'||ch=='\\r'||ch=='\\t';}\n\ttemplate inline bool read(T &x){\n\t\tbool sign=0;char ch=nc();x=0;\n\t\tfor(;blank(ch);ch=nc());\n\t\tif(IOerror)return false;\n\t\tif(ch=='-')sign=1,ch=nc();\n\t\tfor(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';\n\t\tif(sign)x=-x;\n\t\treturn true;\n\t}\n\tinline bool read(double &x){\n\t\tbool sign=0;char ch=nc();x=0;\n\t\tfor(;blank(ch);ch=nc());\n\t\tif(IOerror)return false;\n\t\tif(ch=='-')sign=1,ch=nc();\n\t\tfor(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';\n\t\tif(ch=='.'){\n\t\t\tdouble tmp=1; ch=nc();\n\t\t\tfor(;ch>='0'&&ch<='9';ch=nc())tmp/=10.0,x+=tmp*(ch-'0');\n\t\t}\n\t\tif(sign)x=-x;\n\t\treturn true;\n\t}\n\tinline bool read(char *s){\n\t\tchar ch=nc();\n\t\tfor(;blank(ch);ch=nc());\n\t\tif(IOerror)return false;\n\t\tfor(;!blank(ch)&&!IOerror;ch=nc())*s++=ch;\n\t\t*s=0;\n\t\treturn true;\n\t}\n\tinline bool read(char &c){\n\t\tfor(c=nc();blank(c);c=nc());\n\t\tif(IOerror){c=-1;return false;}\n\t\treturn true;\n\t}\n\ttemplatebool read(T& h,U&... t){return read(h)&&read(t...);}\n\t#undef OUT_SIZE\n\t#undef BUF_SIZE\n};\nusing namespace fastIO;\n/************* debug begin *************/\nstring to_string(string s){return '\"'+s+'\"';}\nstring to_string(const char* s){return to_string((string)s);}\nstring to_string(const bool& b){return(b?\"true\":\"false\");}\ntemplatestring to_string(T x){ostringstream sout;sout<string to_string(pair p){return \"(\"+to_string(p.first)+\", \"+to_string(p.second)+\")\";}\ntemplatestring to_string(const vector v){\n\tint f=1;string res=\"{\";for(const auto x:v){if(!f)res+= \", \";f=0;res+=to_string(x);}res+=\"}\";\n\treturn res;\n}\nvoid debug_out(){puts(\"\");}\ntemplatevoid debug_out(const T& h,const U&... t){cout<<\" \"< PII;\ntypedef pair PLL;\ntypedef pair PIL;\ntypedef pair PLI;\ntypedef vector VI;\ntypedef vector VL;\n/************* define end *************/\nvoid read(int *x,int l,int r){for(int i=l;i<=r;i++) read(x[i]);}\nvoid read(ll *x,int l,int r){for(int i=l;i<=r;i++) read(x[i]);}\nvoid read(double *x,int l,int r){for(int i=l;i<=r;i++) read(x[i]);}\nvoid println(VI x){for(int i=0;i\n#include \n#include \n\nusing namespace std;\n\nint main() {\n\tint n , m;\n\tint count = 0;\n\tcin >> n >> m;\n\n\tfor (int i = 1; i < 101; i++) {\n\t\tn-=1;\n\t\tcount++;\n\n\t\tif ( i%m == 0) n++;\n\n\t\tif (n == 0) break;\n\t}\n\n\tcout << count << endl;\n\n\tsystem (\"pause\");\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "84a96247fa60ce9bb496de3780a38c58", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define ll long long\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n int t,i,j,a,b,c,d,e,sum;\n cin>>t;\n while(t--)\n {\n cin>>a>>b;\n c=a/b;\n if(ab)\n cout<\n#include \nusing namespace std;\n\nint main()\n{\n\tint s, d, res;\n\tcin >> s >> d;\n\n\tres = s;\n\twhile (s>=d)\n\t{\n\t\ts = s / d;\n\t\tres += s;\n\t}\n\n\tcout << res << endl;\n\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "652665da8370bf2d1a3f300eb062df7c", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include \n#define ll unsigned long long\n#define pi 3.1415926535897932384626433832795\n#define fin(a,n) for(ll i=0;i>a[i];\n#define fout(a,n) for(ll i=0;i>n>>t;\n\tint a[n-1];\n\tvector c(n+1, false);\n\tfin(a,n-1);\n\tc[a[0]] = true;\n\tint i=1;\n\twhile(i+a[i-1] <= n-1)\n\t{\n\t\tc[i + a[i-1]] = true;\n\t\ti += a[i-1];\n\t\tif(c[t] == true)\n\t\t{\n\t\t\tflag = 1;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif(flag)\t\n\t\tcout<<\"YES\\n\";\n\telse\n\t\tcout<<\"NO\\n\";\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "806aa80ad98810fa4081b3d96a515820", "src_uid": "42b25b7335ec01794fbb1d4086aa9dd0", "difficulty": 900.0} {"lang": "GNU C++17", "source_code": "#include \n#define endl '\\n'\n#define debug1( x ) cout << #x << \" = \" << x << endl;\n#define debug2( x, y) cout <<#x << \" = \" << x << \" , \" <<#y << \" = \" << y < ii;\ntypedef vector vi;\n\nint main(){\n ios::sync_with_stdio( false );\n cin.tie( nullptr );\n#ifdef LOCAL\n if(!freopen(\"in\", \"r\" , stdin))\n cerr << \"no file...\"<\nusing namespace std;\nint main(){\n return 1;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "17377df55f9f11f8f47a79c16740fd2f", "src_uid": "b6a30a725754a4b4daeb6e87986e28a4", "difficulty": null} {"lang": "GNU C++14", "source_code": "/**\n * @author : Veeresh\n * @email Veeresh232@gmail.com\n * @create date 2020-04-01 20:09\n * @modify date 2020-04-01 20:09\n * @desc [description]\n */\n#include \nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\n\ntypedef pair pi;\ntypedef pair pl;\ntypedef vector vi;\ntypedef vector vl;\ntypedef vector vpi;\ntypedef vector vpl;\n\n#define mp make_pair\n#define all(x) begin(x), end(x)\n#define rall(x) (x).rbegin(), (x).rend()\n#define pb push_back\n#define FOR(i, a, b) for (int i = (a); i < (b); ++i)\n#define trav(a, x) for (auto &a : x)\n\nconst ll MOD = 1e9 + 7; // 998244353\n\nbool isPrime(ll n)\n{\n if (n <= 1)\n return false;\n if (n <= 3)\n return true;\n if (n % 2 == 0 || n % 3 == 0)\n return false;\n for (ll i = 5; i * i <= n; i = i + 6)\n if (n % i == 0 || n % (i + 2) == 0)\n return false;\n return true;\n}\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n vl v;\n ll t;\n while (true)\n {\n cin >> t;\n v.pb(t);\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cfcf8d0ae61284a60f925b59609b2e65", "src_uid": "b6a30a725754a4b4daeb6e87986e28a4", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main()\n{\n while(1) cout<<\" \"<\n#include\n#include\nusing namespace std;\nlong long w,mas[100000000],q,k1,k2,k3;\nstring s;\nint main()\n{\n \t cin>>s;\n \t if(s.size()==1 && s[0]=='3')\n \t {\n\t \t\t\t\t\t cout<<'3';\n\t \t\t\t\t\t return 0;\n\t\t\t\t\t\t }\n \t q=s.size()-1;\n \t for(int i=0; i<=s.size()-1; i++)\n \t {\n\t \t\t\tif(s[i]=='1')\n\t \t\t\tk1++;\n\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t for(int i=0; i<=s.size()-1; i++)\n\t\t\t\t\t\t\t {\n\t\t\t\t\t\t\t \t\t\t if(s[i]=='2')\n\t\t\t\t\t\t\t \t\t\t k2++;\n\t\t\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t\t\t for(int i=0; i<=s.size()-1; i++)\n\t\t\t\t\t\t\t\t\t\t {\n\t\t\t\t\t\t\t\t\t\t \t\t\tif(s[i]=='3')\n\t\t\t\t\t\t\t\t\t\t \t\t\tk3++;\n\t\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\tif(k1!=0)\n\t\t\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t\tcout<<1;\n\t\t\t\t\t\t\t\t\t\t\t\t\t \t\t\tfor(int i=1; i\n#include\n\nusing namespace std;\nint main()\n{\n string x , a=\"\",b=\"\",c=\"\";\n cin >> x;\n if (x.length()!=1){\n for (unsigned i=0;i\n#include\n\nusing namespace std;\nint main()\n{\n string x , a=\"\",b=\"\",c=\"\",z;\n cin >> x;\n if (x.length()!=1)\n {\n for (unsigned i=0;i\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\n\nint main()\n{\n\t\n\tchar ch,arr[70];\n\tint i=0;\n\n\tdo\n\t{\n\t\tch=getche();\n\t\tif(ch!='+')\n\t\t\tarr[i++]=ch;\n } \n\twhile(ch!='\\r');\n\n\tarr[i-1]='\\0';\n \n\tsort(arr,arr+i-1);\n\tfor(int j=0;j\n#include\n#include\n#include\n#include\nusing namespace std;\nint pd[3000100],l,r,s,prime[101],len,tot,x[3000100],dis[3000100];\nvoid dfs(int k1,int k2){\n\t//cout<tot){\n\t\tx[++len]=k1; return;\n\t}\n\tfor (long long i=k1;i<=r;i=i*prime[k2]) dfs(i,k2+1);\n}\nint main(){\n\tscanf(\"%d%d%d\",&l,&r,&s);\n\tfor (int i=2;i<=s;i++)\n\t\tif (pd[i]==0){\n\t\t\tprime[++tot]=i; for (int j=i;j<=s;j+=i) pd[i]=1;\n\t\t}\n\tdfs(1,1); sort(x+1,x+len+1);\n\t//for (int i=1;i<=len;i++) cout<len) break;\n\t\t\tdis[now]=min(dis[now],dis[j]+1);\n\t\t}\n\t}\n\tint ans=0;\n\t//for (int i=1;i<=len;i++) cout<=l&&x[i]<=r) ans++;\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define sqr(_) ((_)*(_))\n \ntypedef pair Pii;\n#define x first\n#define y second\n#define mp make_pair\n#define pb push_back\n#define SZ(x) ((int)(x).size())\n\ntypedef long long LL;\n\nconst int MAXN = (int)3e6;\n\nstruct List\n{\n\tint w, a, pre, nex;\n}l[MAXN * 4];\nset s;\nint h, t;\nPii q[MAXN];\nint n, L, R, p, Tohka, tot;\n\nvoid Ins(int p, int x, int y)\n{\n\tif (L <= x && x <= R && s.find(x) == s.end())\n\t\t++Tohka, s.insert(x);\n\t++tot;\n\tl[tot].w = x, l[tot].a = y;\n\tl[tot].nex = p, l[tot].pre = l[p].pre;\n\tl[l[tot].pre].nex = tot,\n\tl[l[tot].nex].pre = tot;\n}\nvoid Erase(int p)\n{\n\tl[l[p].pre].nex = l[p].nex;\n\tl[l[p].nex].pre = l[p].pre;\n}\nint main()\n{\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\", stdin), freopen(\"output.txt\", \"w\", stdout);\n#endif\n\t\n\tcin >> L >> R >> p;\n\ttot = 1;\n\tl[1].pre = 0, l[1].nex = MAXN - 1;\n\tl[0].nex = 1, l[MAXN - 1].pre = 1;\n\tl[MAXN - 1].w = R + 1;\n\tl[1].w = 1, l[1].a = 1; \n\tfor (int i = 2; i <= p; ++i)\n\t{\n\t\th = 1, t = 0;\n\t\tfor (int j = l[0].nex; j != MAXN - 1; j = l[j].nex)\n\t\t{\n\t\t\t++l[j].a;\n\t\t\twhile (h <= t && q[h].x == l[j].w)\n\t\t\t\tl[j].a = min(l[j].a, q[h].y), ++h;\n//\t\t\tcout << l[j].w << \" \" << l[j].a << \" \";\n\t\t\tif ((LL)l[j].w * i <= (LL)R && l[j].a + 1 <= p)\n\t\t\t\tq[++t] = mp(l[j].w * i, l[j].a + 1);\n\t\t\tint np = l[j].nex;\n\t\t\twhile (h <= t && q[h].x < l[np].w)\n\t\t\t\tIns(np, q[h].x, q[h].y - 1), ++h;\n\t\t\tif (l[j].a > p)\n\t\t\t\tErase(j);\n\t\t}\n\t}\n\tcout << Tohka << endl;\n\t\n\tfclose(stdin);\n\tfclose(stdout);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "995b81b10daea53983e4a57d2034c51a", "src_uid": "6d898638531e4713774bbd5d47e827bf", "difficulty": 2800.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n\ntypedef long long ll;\n\nvector pr;\nint pchk[102];\nvoid sieve() {\n for(int i = 2; i < 102; i++) {\n if(!pchk[i]) {\n pr.push_back(i);\n }\n for(int j = 0; j < pr.size() && i * pr[j] < 102; j++) {\n pchk[ i * pr[j] ] = 1;\n if(i % pr[j] == 0) break;\n }\n }\n}\n\nunordered_map mm;\nint dp(int val, int b) {\n ll x = 100LL * val + b;\n if(mm.find(x) != mm.end()) return mm[x];\n int &ret = mm[x];\n if(val == 1) return ret = 0;\n if(b == 1) return ret = 1e9;\n if(val <= b) return ret = 1;\n\n ret = 1e9;\n if(val % b == 0) {\n ret = min(ret, 1 + dp(val / b, b));\n }\n ret = min(ret, dp(val, b - 1));\n return ret;\n}\n\nint l, r, p;\n\nint cnt;\nint val;\nvoid dfs(int idx, int use, int mxp) {\n if(idx == pr.size()) {\n if(val < l) return;\n if(use + mxp <= p) {\n cnt++;\n return;\n }\n\n for(int i = max(p - 30, mxp); i < p; i++) {\n if(dp(val, i) <= p - i) {\n cnt++;\n break;\n }\n }\n\n return;\n }\n dfs(idx + 1, use, mxp);\n if(1LL * val * pr[idx] <= r) {\n val *= pr[idx];\n dfs(idx, use + 1, pr[idx]);\n val /= pr[idx];\n }\n}\n\nint main() {\n sieve();\n cin >> l >> r >> p;\n val = 1;\n cnt = 0;\n dfs(0, 0, 1);\n cout << cnt;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4f2937147e9f380269f6079d97737ef6", "src_uid": "6d898638531e4713774bbd5d47e827bf", "difficulty": 2800.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n\ntypedef long long ll;\n\nvector pr;\nint pchk[102];\nvoid sieve() {\n for(int i = 2; i < 102; i++) {\n if(!pchk[i]) {\n pr.push_back(i);\n }\n for(int j = 0; j < pr.size() && i * pr[j] < 102; j++) {\n pchk[ i * pr[j] ] = 1;\n if(i % pr[j] == 0) break;\n }\n }\n}\n\nint l, r, p;\n\nunordered_map mm;\nint dp(int val, int b, int rem) {\n ll x = 10000LL * val + 100 * b + rem;\n if(mm.find(x) != mm.end()) return mm[x];\n int &ret = mm[x];\n if(b == 1) return ret = val == 1;\n if(rem == 0) return ret = val == 1;\n if(val <= b) return ret = 1;\n\n if(val % b == 0) {\n if(dp(val / b, b, rem - 1)) return ret = 1;\n //else return ret = 0;\n }\n if(dp(val, b - 1, rem)) return ret = 1;\n else return ret = 0;\n}\n\nint cnt;\nint val;\nvoid dfs(int idx, int use, int mxp) {\n if(idx == pr.size()) {\n if(val < l) return;\n if(use + mxp <= p) {\n cnt++;\n return;\n }\n\n for(int i = mxp; i < p; i++) {\n if(dp(val, i, p - i)) {\n cnt++;\n break;\n }\n }\n\n return;\n }\n dfs(idx + 1, use, mxp);\n if(1LL * val * pr[idx] <= r) {\n val *= pr[idx];\n dfs(idx, use + 1, pr[idx]);\n val /= pr[idx];\n }\n}\n\nint main() {\n sieve();\n cin >> l >> r >> p;\n val = 1;\n cnt = 0;\n dfs(0, 0, 1);\n cout << cnt;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5e57d09afa0b1f44863ac7e2fd476c10", "src_uid": "6d898638531e4713774bbd5d47e827bf", "difficulty": 2800.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\n\nconst int MAXN = 200;\nconst int INF = MAXN;\nconst int MOD = 1000000007;\nint C[MAXN][MAXN];\nint f[MAXN>>1][MAXN>>1][MAXN>>1][MAXN];\n\nvoid add(int &x, const int y) {\n x += y; \n (x >= MOD) && (x -= MOD);\n}\n\nint main() {\n for (int i = 0, j; i < MAXN; ++i) for (C[i][0] = C[i][i] = 1, j = 1; j < i; ++j) {\n C[i][j] = min(C[i-1][j-1] + C[i-1][j], INF);\n }\n\n int tot = 0;\n int N, M, K;\n scanf(\"%d%d%d\", &N, &M, &K), N >>= 1;\n\n f[0][1][0][1] = 1;\n for (int i = 0; i <= N && i < M; ++i) for (int j = 1; j <= N; ++j) {\n for (int k = 0; k <= N; ++k) for (int w = 0; w <= K; ++w) {\n int cc = f[i][j][k][w];\n if (!cc) continue;\n if (i) tot = (tot + (long long)cc * (M - i)) % MOD;\n for (int x = 1; x + k <= N; ++x) {\n int nw = w * C[j + x - 1][x]; \n if (nw > K) continue;\n add(f[i + 1][x][k + x][nw], cc);\n }\n } \n }\n\n printf(\"%d\\n\", tot);\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bb0a4f53a31a413a635f21ece497bfbb", "src_uid": "c6d275b1e1d5c9e39e2cf990a635fa6b", "difficulty": 2800.0} {"lang": "GNU C++", "source_code": "// \u52d5\u7684\u8a08\u753b\u6cd5\n\n// [\u4f4d\u7f6e\u3092] \u56fa\u5b9a\u3057\u306a\u3044\u3002\n// [\u9806\u5e8f\u3092] \u56fa\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\n\n\n\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\n\nvoid Get(int &T)\n{\n\tchar C;bool F=0;\n\tfor(;C=getchar(),C<'0'||C>'9';)if(C=='-')F=1;\n\tfor(T=C-'0';C=getchar(),C>='0'&&C<='9';T=T*10+C-'0');\n\tF&&(T=-T);\n}\n\nint N,M,K;\n\nvoid Init()\n{\n\tGet(N);Get(M);Get(K);\n\tN++;\n}\n\nint C[1005][1005];\n\nint F[105][105][105][105];\n/*\nint Ans[105];\n\nint Cnt=0;\n\nvoid DFS(int X,int Now,int Max)\n{\n\tif(X>14)\n\t{\n\t\tif(Now==1&&Max==4)\n\t\t{\n\t\t\t//puts(\"9\");\n\t\t\t//for(int i=1;i<=8;i++)\n\t\t\t//\tprintf(\"%d \",Ans[i]);\n\t\t\t//puts(\"\");\n\t\t\tCnt++;\n\t\t\tprintf(\"%d\\n\",Cnt);\n\t\t}\n\t\treturn;\n\t}\n\t\n\tAns[X+1]=Now+1;\n\tDFS(X+1,Now+1,std::max(Max,Now+1));\n\tif(Now-1>=1)\n\t{\n\t\tAns[X+1]=Now-1;\n\t\tDFS(X+1,Now-1,Max);\n\t}\n}\n*/\n\n#define Mod (1000000007)\n\nlong long Ans;\n\nvoid Work()\n{\n\tC[0][0]=1;\n\tfor(int i=1;i<=1000;i++)\n\t{\n\t\tC[i][0]=1;\n\t\tfor(int j=1;j<=1000;j++)\n\t\t\tC[i][j]=std::min(C[i-1][j]+C[i-1][j-1],1000);\n\t}\n\t\n\t/*\n\tfor(int i=0;i<=20;i++)\n\t{\n\t\tfor(int j=0;j<=20;j++)\n\t\t\tprintf(\"%d \",C[i][j]);\n\t\tputs(\"\");\n\t}\n\t*/\n\t\n\tF[0][0][1][1]=1;\n\t\n\tfor(int i=0;i<=M;i++)\n\t\tfor(int j=0;j<=N;j++)\n\t\t\tfor(int k=1;k<=N;k++)\n\t\t\t\tfor(int p=1;p<=K;p++)\n\t\t\t\t{\n\t\t\t\t\tif(F[i][j][k][p])\n\t\t\t\t\t\tfor(int delta=k;j+delta<=N;delta++)\n\t\t\t\t\t\t\tif(C[delta-1][k-1]*p<=K)\n\t\t\t\t\t\t\t\t(F[i+1][j+delta][delta-k][C[delta-1][k-1]*p]+=\n\t\t\t\t\t\t\t\t\tF[i][j][k][p])%=Mod;\n\t\t\t\t}\n\t\n\tfor(int i=2;i<=M;i++)\n\t\tfor(int j=0;j<=N;j++)\n\t\t\tfor(int k=0;k<=0;k++)\n\t\t\t\tfor(int p=0;p<=K;p++)\n\t\t\t\t{\n\t\t\t\t\tlong long Ans0=F[i][j][k][p];\n\t\t\t\t\tif(Ans0>0)\n\t\t\t\t\t{\n\t\t\t\t\t\t(Ans0*=(M-i+1))%=Mod;\n\t\t\t\t\t\t(Ans+=Ans0)%=Mod;\n//\t\t\t\t\t\tprintf(\"%d %d %d %d %I64d\\n\",i,j,k,p,Ans0);\n\t\t\t\t\t}\n\t\t\t\t}\n}\t\n\nvoid Output()\n{\n\tprintf(\"%I64d\\n\",Ans);\n}\n\nint main()\n{\n\tInit();\n\tWork();\n\tOutput();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8be704fcb348e3996eee43dfb25cebcc", "src_uid": "c6d275b1e1d5c9e39e2cf990a635fa6b", "difficulty": 2800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\nusing namespace std;\n\n#ifdef WIN32\n #define LLD \"%I64d\"\n#else\n #define LLD \"%lld\"\n#endif\n\ntypedef pair pii;\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vb;\ntypedef vector vvb;\ntypedef vector vll;\ntypedef vector vvll;\n\nll rdtsc() {\n ll tmp;\n asm(\"rdtsc\" : \"=A\"(tmp));\n return tmp;\n}\n\n#define TASKNAME \"text\"\n#define pb push_back\n#define mp make_pair\n#define EPS (1e-9)\n#define INF ((int)1e9)\n#define sqr(x) ((x) * (x)) \n#define eprintf(...) fprintf(stderr, __VA_ARGS__)\n#define sz(x) ((int)(x).size())\n\nconst int MOD = (int)1e9 + 7;\ninline void add(int &x, int y) {\n\tif ((x += y) >= MOD)\n\t\tx -= MOD; \n}\n\nconst int maxVal = 101;\nint sum[maxVal][maxVal][maxVal];\nint d[maxVal][maxVal][maxVal][maxVal];\n\nvoid filld(int m, int cnt, int n, int k) {\n\tint &cur = d[m][cnt][n][k];\n\tcur = 0;\n\tif (m == 1 && cnt == 1 && n == 1 && k == 1)\n\t\tcur = 1;\n}\n\nvoid pushd(int m, int cnt, int n, int k, int maxm, int maxn, int maxk) {\n\tint cur = d[m][cnt][n][k];\n\tif (!cur)\n\t\treturn;\n\tfor (int x = 0; x + n + 1 <= maxn; x++) {\n\t\tfor (int y = 1, product = k; product <= maxk; product += k) {\n\t\t\tadd(d[m][cnt + 1][x + n + 1][product], (ll)cur * sum[m - 1][x][y] % MOD);\n\t \t}\n\t}\n\tif (m + 1 <= maxm && n + 2 <= maxn)\n\t\tadd(d[m + 1][2][n + 2][k], cur);\n}\n\n\nvoid countDyn(int maxn, int maxm, int maxk) {\n\tfor (int n = 0; n <= maxn; n++)\n\t\tfor (int m = 0; m <= maxm; m++)\n\t\t\tfor (int k = 0; k <= maxk; k++)\n\t\t\t\tsum[m][n][k] = 0;\t\n\tfor (int m = 0; m <= maxm; m++) {\n\t\tfor (int cnt = 0; cnt <= maxn; cnt++) {\n\t\t\tfor (int n = 0; n <= maxn; n++) {\n\t\t\t\tfor (int k = 0; k <= maxk; k++) {\n\t\t\t\t\tfilld(m, cnt, n, k);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (int m = 0; m <= maxm; m++) {\n\t\tfor (int cnt = 0; cnt <= maxn; cnt++) {\n\t\t\tfor (int n = 0; n <= maxn; n++) {\n\t\t\t\tfor (int k = 0; k <= maxk; k++) {\n\t\t\t\t\tpushd(m, cnt, n, k, maxm, maxn, maxk);\n\t\t\t\t\tadd(sum[m][n][k], d[m][cnt][n][k]);\n\t\t\t\t} \n\t\t\t}\n\t\t}\n\t}\n}\n\nint main() {\n\tsrand(rdtsc());\n#ifdef DEBUG\n\tfreopen(TASKNAME\".in\", \"r\", stdin);\n\tfreopen(TASKNAME\".out\", \"w\", stdout);\n#endif\n\t\n\tint n, m, k;\n\twhile (scanf(\"%d%d%d\", &n, &m, &k) >= 1) {\n\t\t++n;\n\n\t\tcountDyn(n, m, k);\n\t\tint ans = 0;\n\t\tfor (int m1 = 1; m1 <= m; m1++)\n\t\t\tfor (int n1 = 2; n1 <= n; n1++)\n\t\t\t\tfor (int k1 = 1; k1 <= k; k1++)\n\t\t\t\t\tadd(ans, (ll)sum[m1][n1][k1] * (m - m1 + 1) % MOD);\n\t\tprintf(\"%d\\n\", ans);\n\t\t//break;\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "164d56cfffbbccf66a05eea5c8cd2c32", "src_uid": "c6d275b1e1d5c9e39e2cf990a635fa6b", "difficulty": 2800.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\n\ntypedef long long LL;\n\nconst int N = 105;\nconst int MOD = int(1e9 + 7);\n\nint n, m, k;\nint Co[N][N];\nint f[N][N][N][N];\n// length, maxinum, cnt, ways\n\nvoid Upp(int i, int j, int p, int q, int o) { if(q>0 && q<=k) (f[i][j][p][q] += o) %= MOD; }\n\nint main()\n{\n\t\n\tscanf(\"%d%d%d\", &n, &m, &k);\n\t\n\tfor(int i=0; i<=n; i++)\n\t{\n\t\tCo[i][0] = Co[i][i] = 1;\n\t\tfor(int j=1; j1) (ans += (LL(f[i][j][p][q]) * (m-j+1)) % MOD) %= MOD;\n\t\tfor(int t=1; i+t*2<=n+1; t++) Upp(i+t*2, j+1, t, q*Co[p+t-1][t-1], f[i][j][p][q]);\n\t}\n\t\n\tprintf(\"%d\\n\", (ans+MOD)%MOD);\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9044a5c731d2af02866a7473340ee77d", "src_uid": "c6d275b1e1d5c9e39e2cf990a635fa6b", "difficulty": 2800.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n long long n;\n int s4 = 0, s7 = 0;\n string s, t;\n cin >> n;\n s = to_string(n);\n if (s.size() % 2 != 0)\n {\n for (int i = 0; i <= (s.size() / 2); i++)\n cout << 4;\n for (int i = (s.size() / 2) + 1; i <= s.size(); i++)\n cout << 7;\n return 0;\n }\n for (int i = 0; i < s.size(); i++)\n {\n if (i < (s.size() / 2))\n t += '7';\n else\n t += '4';\n }\n if (s>t)\n {\n for (int i = 0; i <= s.size(); i++)\n cout << 4;\n for (int i = s.size() + 1; i <= s.size() + 1; i++)\n cout << 7;\n return 0;\n }\n else if (s == t)\n {\n cout << s;\n return 0;\n }\n for (int i = 0; i < s.size(); i++)\n {\n if (i < (s.size() / 2))\n t[i] = '4';\n else\n t[i] = '7';\n }\n if (s < t)\n {\n for (int i = 0; i < (s.size() / 2); i++)\n cout << 4;\n for (int i = (s.size() / 2); i < s.size(); i++)\n cout << 7;\n return 0;\n }\n else if (s == t)\n {\n cout << s;\n return 0;\n }\n t = \"\";\n s4 = s.size() / 2;\n s7 = s4;\n for (int i = 0; i < s.size(); i++)\n {\n if ((s[i] - '0')> 4 && (s[i] - '0')<7)\n {\n t += '7';\n s7--;\n for (int i = 0; i < s4; i++)\n t += '4';\n for (int i = 0; i < s7;)\n t += '7';\n cout << t;\n return 0;\n }\n else if ((s[i] - '0') < 4)\n {\n t += '4';\n s4--;\n for (int i = 0; i < s4; i++)\n t += '4';\n for (int i = 0; i < s7; i++)\n t += '7';\n cout << t;\n return 0;\n }\n else if ((s[i] - '0') == 4)\n {\n if (s4>0)\n {\n s4--;\n t += '4';\n }\n }\n else if ((s[i] - '0') == 7)\n {\n s7--;\n t += '7';\n }\n else\n {\n for (int j = i - 1; j >= 0; j--)\n {\n if (t[j] == '4')\n {\n s4--;\n t[j] = '7';\n s7++;\n for (int i = 0; i < s4; i++)\n t += '4';\n for (int i = 0; i < s7;)\n t += '7';\n cout << t;\n return 0;\n }\n }\n }\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bb99c033e7e71172a9194394e5530c3e", "src_uid": "77b5f83cdadf4b0743618a46b646a849", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\nint main(){\n\ttypedef long long ll;\n\n\tqueue< pair < ll , ll > > q;\n\t\n\tll x;\n\tcin >> x;\n\n\tq.push(make_pair(0 , 0));\n\twhile(!q.empty()){\n\t\tll val = q.front().first;\n\t\tll c = q.front().second;\n\n\t\tif(val >= x && c == 0){\n\t\t\tcout << val << \"\\n\";\n\t\t\treturn 0;\n\t\t}\n\t\tq.push(make_pair(val * 10 + 4 , c + 1));\n\t\tq.push(make_pair(val * 10 + 7 , c - 1));\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "31fe9b68c3bd45d8cb624bae35506180", "src_uid": "77b5f83cdadf4b0743618a46b646a849", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "//#include \"stdafx.h\"\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std; \n\n#define fo(i,j,n) for(i=j;i=j;--i)\n#define foo(i,j,v) fo(i,j,sz(v))\n#define Foo(i,j,v) Fo(i,j,sz(v))\n#define li(v) v.begin(),v.end()\n#define sz(v) ((int)v.size())\n#define CLR(a,v) memset((a),(v),sizeof(a))\n#define inf 1000000001\n//typedef long long Long;\ntypedef __int64 Long;\n#define pi (2*acos(0))\n#define eps 1e-9\n\n#define two(X) (1<<(X))\n#define twoL(X) (((Long)(1))<<(X))\n#define contain(S,X) (((S)&two(X))!=0)\n#define containL(S,X) (((S)&twoL(X))!=0)\n\nchar BUFFER[1000000 + 5];\nbool readn(int &n)\t{ return scanf(\"%d\",&n) == 1; } \nbool readl(Long &n)\t{ return scanf(\"%I64d\",&n) == 1; } \nbool readd(double &n){ return scanf(\"%lf\",&n) == 1; } \nbool reads(string &s){ s = \"\"; int n = scanf(\"%s\",BUFFER); if(n == 1)s = BUFFER; return n == 1; }\nbool readln(string &s){ char *valid = gets(BUFFER); if(valid)s = BUFFER; return ((bool)valid); }\n\n\nstring s;\n\nbool IsLuckyNo(long m)\n{\n\tint r = 0;\n\twhile(m>0)\n\t{\n\t\tr = m%10;\n\t\tm = m/10;\n\n\t\tif(r!= 4 && r != 7) return false;\n\t}\n\n\treturn true;\n}\n\nbool IsSuperLuckyNo(long m)\n{\n\tint r = 0, c1 = 0, c2 =0;\n\twhile(m>0)\n\t{\n\t\tr = m%10;\n\t\tm = m/10;\n\n\t\tif(r== 4)c1++;\n\t\telse c2++;\n\t}\n\tif(c1==c2) return true;\n\n\treturn false;\n}\n\nint main()\n{\n\t//freopen(\"D://input.txt\",\"r\",stdin);\n\tlong n;\n\n\tcin >> n;\n\t\n\tif(n<=47)\n\t{\n\t\tcout << \"47\";\n\t}\n\telse if(n>47 && n<=74)\n\t{\n\t\tcout << \"74\";\n\t}\n\telse if(n>74 && n<=4477)\n\t{\n\t\tcout << \"4477\";\n\t}\n\telse if(n>4477 && n<=4747)\n\t{\n\t\tcout << \"4747\";\n\t}\n\telse if(n>4747 && n<=7744)\n\t{\n\t\tcout << \"7744\";\n\t}\n\telse if(n>7744 && n<=777444)\n\t{\n\t\tcout << \"777444\";\n\t}\n\telse if(n>777444 && n<=44447777)\n\t{\n\t\tcout << \"44447777\";\n\t}\n\telse if(n>44447777 && n<=77774444)\n\t{\n\t\tfor(long i=n;i<=77774444;i++)\n\t\t{\n\t\t\tif(IsLuckyNo(i))\n\t\t\t{\n\t\t\t\tif(IsSuperLuckyNo(i))\n\t\t\t\t{\n\t\t\t\t\tcout << i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse if(n>77774444)\n\t{\n\t\tcout << \"4444477777\";\n\t}\n\n\tprintf(\"\\n\");\n\treturn 0;\n} \n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c5dc784f9d2d7ce3857a5f7552433906", "src_uid": "77b5f83cdadf4b0743618a46b646a849", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint num[10], count;\nlong long n;\nlong long ans = 777777777777;\n\nvoid dfs(int depth)\n{\n\tif (depth == count)\n\t{\n\t\tlong long res = 0;\n\t\tint count4 = 0;\n\t\tint count7 = 0;\n\t\tfor (int i = 0; i < count; i++)\n\t\t{\n\t\t\tres *= 10;\n\t\t\tres += num[i];\n\t\t\tif (num[i] == 4)\t\t\t\n\t\t\t\tcount4++;\n\t\t\telse\n\t\t\t\tcount7++;\n\t\t}\n\t\tif (count4 == count7 && res >= n && res < ans)\n\t\t\tans = res;\n\t}\n\telse\n\t{\n\t\tnum[depth] = 4;\n\t\tdfs(depth+1);\n\t\tnum[depth] = 7;\n\t\tdfs(depth+1);\n\t}\n}\n\nint main()\n{\n\t// freopen(\"in.txt\",\"r\",stdin);\n\tlong long maxnum = 0;\n\tcin>>n;\n\n\t// \u0237\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u03bb\ufffd\ufffd\n\tcount = ceil(log(double(n)) / log(10.0));\n\t\n\tfor (int i = 0; i < count; i++)\n\t{\n\t\tmaxnum *= 10;\n\t\tmaxnum += 7;\n\t}\n\tif (n > maxnum)\n\t\tcount++;\n\tif (count%2)\n\t\tcount++;\n\n\t// \u00f6\ufffd\ufffd\n\tdfs(0);\n\tcout<\n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint n,i;\nint rn(int n)\n{\n if(n%400==0)return 1;\n else if(n%4==0&&n%100!=0)return 1;\n else return 0;\n}\nint main()\n{\n while(~scanf(\"%d\",&n))\n {\n int flag=0;\n if(rn(n)==1)printf(\"%d\\n\",n+28);\n else\n {\n for(i=1;i<=100001;i++)\n {\n if(rn(n+i)==0)\n {\n flag++;\n }\n else\n {\n flag+=2;\n }\n if(flag%7==0&&rn(n+i)==0){printf(\"%d\\n\",n+i);break;}\n }\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2982d2a1149a05819a8ecd2f72b2b721", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nbool lp(int y)\n{\nif((y%4)==0)\n{if((y%100)!=0)\nreturn 1;\nelse\n{ if((y%400)==0)\n return 1;\n else\n {return 0;}\n}\n}\nelse\nreturn 0;\n}\nbool nlc(int y)\n{ return ((((y%4)==0) && (y%100)==0) && (y%400)!=0);\n\n }\n\nint main()\n{\nint yr;\n\ncin>>yr;\nif(lp(yr))\n{ if(nlc(yr+4)==1)\n yr+=12; \nelse if(nlc(yr+28)==0)\nyr+=28;\nelse\nyr+=40;\n}\nelse\n{\nif(nlc(yr+2)|| nlc(yr+3))\nyr+=12;\nelse if(nlc(yr)|| nlc(yr+1))\nyr+=6;\nelse{\nif(lp(yr+3) )\nyr+=6;\nelse\nyr+=11;\n}}\ncout<\nusing namespace std;\nint main()\n{\n int y,cnt=0,temp,x=0;\n bool leap=false;\n cin>>y;\n\n if(y%4!=0)\n leap=false;\n else if(y%100!=0)\n leap =true;\n else if(y%400!=0)\n leap=false;\n else\n leap=true;\n\n\n if(leap)\n {cout<\n\nusing namespace std;\n\nbool is_leap(int n) {\n\treturn n % 400 == 0 || (n % 4 == 0 && n % 100 != 0);\n}\n\nint main() {\n\tint n; cin >> n;\n\tif(is_leap(n))\n\t\tcout << n + 28 << endl;\n\telse {\n\t\tint cnt = 0;\n\t\tfor(int i = 1; i < 100; i++) {\n\t\t\tif(is_leap(n + i - 1)) cnt += 366;\n\t\t\telse cnt += 365;\n\t\t\tcnt %= 7;\n\t\t\tif(cnt == 0 && !is_leap(n + i)) {\n\t\t\t\tn = n + i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tcout << n << endl;\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d96ad4208a02b5b0b3d98824da7d9d4f", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nusing ll = long long;\nusing vi = vector;\n#define pb push_back\n#define rsz resize\n#define all(x) begin(x), end(x)\n#define sz(x) (int)(x).size()\nusing pi = pair;\n#define f first\n#define s second\n#define mp make_pair\nvoid setIO(string name = \"contest\") {\n ios_base::sync_with_stdio(0); cin.tie(0);\n freopen((name+\".in\").c_str(), \"r\", stdin);\n freopen((name+\".out\").c_str(), \"w\", stdout);\n}\nll MOD = 1000000009;\n\nint main() {\n setIO();\n int a, b, f, k;\n cin >> a >> b >> f >> k;\n vi v;\n int pos = 0;\n for(int i = 1; i <= k; i++){\n if (i % 2 == 0){\n pos += f;\n v.push_back(pos);\n pos = a - f;\n } else{\n pos += a - f;\n v.push_back(pos);\n pos = f;\n }\n }\n v.push_back(pos);\n bool ok = 1;\n for(int i = 0; i < (int) v.size(); i++) {\n if(v[i] > b) {\n cout << -1 << \"\\n\";\n ok = 0;\n }\n }\n if (ok) {\n int ans = 0;\n int t = b;\n for(int i = 0; i < (int) v.size() - 1; i++) {\n t -= v[i];\n if (t < v[i + 1]) {\n t = b;\n ans++;\n }\n }\n cout << ans << \"\\n\";\n }\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e1610629fbf659f0458dbf5cd6cca274", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nint a, b, f, k;\nint d, br=0, r=0, n, p[100000000];\nvoid generate()\n{\n p[0]=0;\n p[1]=f;\n int i=1;\n while (p[i]d) p[n]=d; \n for (i=0; i<=n; i++) cout<>a>>b>>f>>k;\n d=a*k;\n generate();\n if (f\nusing namespace std;\n\nconst int N=10005;\nint dp[N][N];\n\nint main()\n{\n int a,b,f,k;\n scanf(\"%d%d%d%d\",&a,&b,&f,&k);\n memset(dp,-1,sizeof(dp));\n dp[0][0]=b;\n for (int i=1;i<=k;i++) {\n for (int j=0;j<=i;j++) {\n if (i&1) {\n dp[i][j]=dp[i-1][j]-a;\n if (j&&dp[i-1][j-1]>=f) {\n dp[i][j]=max(dp[i][j],b-(a-f));\n }\n } else {\n dp[i][j]=dp[i-1][j]-a;\n if (j&&dp[i-1][j-1]>=a-f) {\n dp[i][j]=max(dp[i][j],b-f);\n }\n }\n }\n }\n int ans=-1;\n for (int j=0;j<=k;j++) {\n if (dp[k][j]>=0) {\n ans=j;\n break;\n }\n }\n printf(\"%d\\n\",ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e20cb14cccfb8ff522c790326c242bac", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nusing ll = long long;\nusing vi = vector;\n#define pb push_back\n#define rsz resize\n#define all(x) begin(x), end(x)\n#define sz(x) (int)(x).size()\nusing pi = pair;\n#define f first\n#define s second\n#define mp make_pair\nvoid setIO(string name = \"contest\") {\n ios_base::sync_with_stdio(0); cin.tie(0);\n freopen((name+\".in\").c_str(), \"r\", stdin);\n freopen((name+\".out\").c_str(), \"w\", stdout);\n}\nll MOD = 1000000009;\n\nint main() {\n setIO();\n int a, b, f, k;\n cin >> a >> b >> f >> k;\n vi v;\n int pos = 0;\n for(int i = 1; i <= k; i++){\n if (i % 2 == 1){\n pos += f;\n v.push_back(pos);\n pos = a - f;\n } else{\n pos += a - f;\n v.push_back(pos);\n pos = f;\n }\n }\n v.push_back(pos);\n bool ok = 1;\n for(int i = 0; i < (int) v.size(); i++) {\n if(v[i] > b) {\n cout << -1 << \"\\n\";\n ok = 0;\n }\n }\n if (ok) {\n int ans = 0;\n int t = b;\n for(int i = 0; i < (int) v.size() - 1; i++) {\n t -= v[i];\n if (t < v[i + 1]) {\n t = b;\n ans++;\n }\n }\n cout << ans << \"\\n\";\n }\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "eee57b36b04e8a2f9cd113f89ae734b2", "src_uid": "283aff24320c6518e8518d4b045e1eca", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "/* DAYAMOY DATTA SAIKAT\n CSE,SUST\n*/\n\n#include\n\n#define pii pair\n#define mkp make_pair\n#define fs first\n#define sc second\n#define pb push_back\n#define ppb pop_back\n#define pf printf\n#define pf1(a) printf(\"%d\\n\",a)\n#define hi printf(\"hi!\\n\");\n#define sf scanf\n#define sf1(a) scanf(\"%d\",&a)\n#define sf2(a,b) scanf(\"%d %d\",&a,&b)\n#define sf3(a,b,c) scanf(\"%d %d %d\",&a,&b,&c)\n#define sf1ll(a) scanf(\"%lld\",&a)\n#define sf2ll(a,b) scanf(\"%lld %lld\",&a,&b)\n#define sf3ll(a,b,c) scanf(\"%lld %lld %lld\",&a,&b,&c)\n#define pcase(x) printf(\"Case %d: \",x)\n#define mx 1000000007\n#define inf 1000000007\n#define pi acos(-1.0)\n#define mem(arr,x) memset((arr), (x), sizeof((arr)));\n#define FOR(i,x) for(int i=0;i<(x); i++)\n#define FOR1(i, x) for(int i = 1; i<=x ; i++)\n\nusing namespace std;\ntypedef long long int lint;\ntypedef double dbl;\n\nint main()\n{\n int tst = 1,t;\n char s[60000];\n sf(\"%s\",s);\n int vis[26],cnt;\n int l=strlen(s),i,j,f=0;\n for(i=0;i<=l-26;i++)\n {\n mem(vis,-1);\n cnt = 0;\n for(j=0;j<26;j++)\n {\n if(s[i+j]=='?')\n {\n cnt++;\n }\n else\n {\n\n\n if(vis[s[i+j]-'A']!=-1) break;\n vis[s[i+j]-'A'] = i+j;\n cnt++;\n }\n }\n if(cnt==26)\n {\n for(int k=0;k<26;k++)\n {\n if(s[i+k]=='?') for(int m=0;m<26;m++) if(vis[m]==-1)\n {\n vis[m] = 1;\n s[i+k] = m+'A';\n break;\n }\n\n }\n f=1;\n i++;\n break;\n }\n if(s[i]=='?')s[i] = 'A';\n }\n for(;i<=l;i++) if(s[i]=='?') s[i] = 'A';\n if(f) pf(\"%s\\n\",s);\n else pf(\"-1\\n\");\n return main();\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "10caa8cf4f4a8b07b5653cc9823af65c", "src_uid": "a249431a4b0b1ade652997fe0b82edf3", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include\n\nusing namespace std ;\n\nstring s , s1;\nint a[26] , cnt ;\n\nint main()\n{\n cin >> s ;\n for(int i=0 ; i\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nstatic bool check(string s)\n{\n\tvector count(26);\n\tfor(int i=0;i count(26);\n\tfor(int i=0;i0)\n\t\t\t\tcontinue;\n\t\t\ts[i]=(char)((int)('A')+j);\n\t\t\tcount[j]++;\n\t\t\tbreak;\n\t\t}\n\t}\n}\nint main() {\n\tstring s;\n\tcin >> s;\n\tif(s.size()<26)\n\t{\n\t\tcout << -1 << endl;\n\t\treturn 0;\n\t}\n\tfor(int i=0;i+25\n#include\nint main()\n{\n\tchar s[50005];\n\tchar a[27];\n\tchar c[27];\n\tint b[27]={0};\n\tint i,j,k=0,count=0,t,l=0;\n\tfor(i=0;i<26;i++)\n\t\ta[i]='A'+i;\n\tscanf(\"%s\",s);\n\tt=strlen(s);\n\tfor(i=0;i=26)\n\t\t{\n\t\t\tfor(i=0;i=j)\n\t\t\t\t\t \t\tl=0;\n\t\t\t\t}\n\t\t\tprintf(\"\\n\");\t\t\n\t\t}\n\telse\n\t\tprintf(\"-1\\n\");\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "762d6f71c70b6be4bcaa73ae88dbb303", "src_uid": "a249431a4b0b1ade652997fe0b82edf3", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\n//Compiler version g++ 6.3.0\n\nint main()\n{\n int n;\n cin>>n;\n int a[n];\n for(int i=1;i<=n;i++)\n {\n cin>>a[i];\n }\n int m=0;\n int M=INT_MAX;\n \n for(int i=2;i<=n-1;i++)\n {\n int j=2;\n while(j<=n)\n {\n if(j==i)\n {\n j++;\n if(m\n#define pii pair\n\nusing namespace std;\n\nint main()\n{\n int i,j,k,r,l,m,a,b,n,p,q,np,nl;\n int flag;\n string s;\n while(cin>>n)\n {\n int ara[n];\n for(i=0; i>ara[i];\n p=100000;\n for(i=1; i\n\n#define ll long long\n#define ld long double\n#define pb push_back\n#define mp make_pair\n#define fi first\n#define se second\n#define all(c) (c).begin(),(c).end()\n#define for0(i, n) for (ll i = 0; i < n; ++i)\n#define for1(i, n) for (ll i = 1; i <= n;++i)\n#define for2(i, n) for (ll i = 1; i < n; ++i)\n#define for3(i, k, n) for (ll i = k; i < n; ++i)\n#define input(a, i, n) for (int i = 0; i < n; ++i) {cin >> a[i]; }\n#define output(a, i, n) for (int i = 0; i < n; ++i) {cout << a[i]; }\n//cout.precision(12);\n\nusing namespace std;\n\nint64_t TN = 1;\n\nvoid solve()\n{\n int64_t n, m, mn = 1000, idx = 0;\n cin >> n;\n vector a(n);\n input(a, i, n)\n for (int i = 1; i < n - 1; ++i) {\n if (a[i = 1] - a[i - 1] > mn) {\n mn = a[i + 1] - a[i - 1];\n idx = i;\n }\n }\n mn = 0;\n a.erase(a.begin() + idx + 1);\n for (int i = 0; i < n - 1; ++i) {\n mn = max(mn, a[i + 1] - a[i]);\n }\n cout << mn << endl;\n}\n\nint main()\n{\n //cin >> TN;\n for (int i = 0; i < TN; ++i) {\n solve();\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7a77fddf4394330614e854856cecf131", "src_uid": "8a8013f960814040ac4bf229a0bd5437", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main()\n{\n int a,mx=0,mn=1000;\n cin>>a;\n int x[a];\n for(int i=0;i>x[i];\n if(i!=0)\n {\n mx=max(mx,(x[i]-x[i-1]));\n mn=min(mn,(x[i]-x[i-1]));\n }\n }\n if(a==3 || a==4 || mx==mn){cout<\n\nusing namespace std;\n\ntypedef long long int ll;\n\nint main()\n{\n\tll yC, bC;\n\n\tcin >> yC >> bC;\n\n\tll y, g, b;\n\n\tcin >> y >> g >> b;\n\n\tll yellow_crystals_required = (2 * y + g);\n\tll blue_crystals_required = (g + 3 * b);\n\n\tll sum = 0;\n\n\tif (yellow_crystals_required > 0)\n\t\tsum += yellow_crystals_required;\n\n\tif (blue_crystals_required > 0)\n\t\tsum += blue_crystals_required;\n\n\tcout << sum << endl;\n\n\treturn 1;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "63411beb2d12537195e19b151d7f64cb", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0} {"lang": "GNU C++17 Diagnostics", "source_code": "#include \nusing namespace std;\n \nint main() {\n\tlong long A,B,x,y,z,cy,cb,ans;\n\tscanf(\"%d\",&A);\n\tscanf(\"%d\",&B);\n\tscanf(\"%d\",&x);\n\tscanf(\"%d\",&y);\n\tscanf(\"%d\",&z);\n\tans=max((long long) 0,cy=(x*2+y)-A);\n\tans+=max((long long )0,cb=(y+z*3)-B);\n\tprintf(\"%I64u\");\n\tcout<\nusing namespace std;\nint main()\n{\n long long A,B,yel,gre,blu, sum=0;\n cin >> A >> B >> yel >> gre >> blu;\n long long sumyel=0, sumblu=0;\n sumyel= (2*yel+gre);\n sumblu= (3*blu+gre);\n\n\n if(sumyel-A<0 && sumblu-B <0)\n cout << 0;\n else\n {\n if(sumyel-A<=0)\n sum=(sumblu-B);\n else\n {\n if(sumblu-B<=0)\n sum=(sumyel-A);\n else\n sum = (sumyel-A)+(sumblu-B);\n }\n\n cout << sum;\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ee0088b901db9d39ac855604a2e3d8d9", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define loop(i, num) for (int i = 0; i < num; i++)\n\nusing namespace std;\n\nlong long n1, n2, a, b, c, ans;\n\nint main() {\n \n cin >> n1 >> n2 >> a >> b >> c;\n \n n2 -= b;\n \n n1 -= b;\n \n n1 -= 2 * a;\n \n long long req = 3 * c;\n \n if (n1 > 0 && req > 0) {\n \n req -= min(n1, req);\n \n n1 = 0;\n \n }\n \n if (n2 > 0 && req > 0) {\n \n req -= min(n2, req);\n \n n2 = 0;\n \n }\n \n ans = (n1 > 0 ? 0 : -n1) + (n2 > 0 ? 0 : -n2) + req;\n \n cout << ans << endl;\n \n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "aec72316a7c320fc86536b07ef853b6a", "src_uid": "35202a4601a03d25e18dda1539c5beba", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint main()\n{ int n;\n while(true)\n {cin>>n;\n n=n*3/2;\n cout<\n#include \nint main()\n{\n int j,x;\n scanf(\"%d\",&j);\n x=(2*j)-(j/2);\n printf(\"%d\",x);\n getch();\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "edf1394e47952c2f602d7b5d9059eb3f", "src_uid": "031e53952e76cff8fdc0988bb0d3239c", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nint main ()\n{\n long long int n;\n cin>>n;\n cout<\n#include \nusing namespace std;\nint main ()\n{\n int n;\n cin>>n;\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair pii;\ntypedef vector vi;\n\n#define mp make_pair\n#define pb push_back\n#define rep(i, n) for(int (i) = 0; (i) < (n); ++(i))\n#define repr(i, l, r) for(int (i) = (l); (i) < (r); ++(i))\n#define clr(t, v) memset((t), (v), sizeof(t))\n#define all(x) (x).begin(), (x).end()\n#define sz(x) ((int)(x).size())\n#define fi first\n#define se second\n\n#define DEBUG\n\n\nint r, h, c;\n\nint main() {\n#ifdef DEBUG\n\tfreopen(\"in.txt\", \"r\", stdin);\n\t//freopen(\"out.txt\", \"w\", stdout);\n#endif\n\tcin>>r>>h;\n\tc += 2*(h/r);\n\th %= r;\n\tdouble h2, r2;\n\th2 = h; r2 = r;\n\tif (h2>=r2/2) {\n\t\tc += 2;\n\t\tif (2*h2*h2>=r2*r2)\n\t\t\tc++;\n\t} else {\n\t\tc += 1;\n\t}\n\tcout << c << '\\n';\n\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4640c985ade7c18dd297861a924b5ca1", "src_uid": "ae883bf16842c181ea4bd123dee12ef9", "difficulty": 1900.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nint r,h;\nint ans;\n\nint main()\n{\n //freopen(\"in.txt\",\"r\",stdin);\n //freopen(\"out.txt\",\"w\",stdout);\n ans=(h/r)<<1;\n h%=r;\n int t=sqrt(3)*r;\n if(th*2) ans++;\n else ans+=2;\n }\n printf(\"%d\",ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8ba448a700053453b01ce758385266b2", "src_uid": "ae883bf16842c181ea4bd123dee12ef9", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define vint vector::iterator\n#define maxn 100003\n\nusing namespace std;\n\nifstream fin(\"A.in\");\nofstream fout(\"A.out\");\n\nint r,h;\n\nint main()\n{\n fin>>r>>h;\n\n if (h%r==0)\n {\n cout<<(h/r)*2+1;\n return 0;\n }\n\n double d = double(h)/double(r);\n int z = h/r;\n\n\n double dd = z+0.5;\n\n if (d>=dd)\n {\n if ((r/2)*(r/2) + ((d-dd)*r+r/2)*((d-dd)*r+r/2) >= r) cout<<2*z+3;\n else cout<<2*z+2;\n }\n else\n {\n cout<<2*z+1;\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b8a98d7e35751aaf21d8a219bf291283", "src_uid": "ae883bf16842c181ea4bd123dee12ef9", "difficulty": 1900.0} {"lang": "GNU C++17", "source_code": "#include\n#include \n#include \nusing namespace std;\nusing namespace __gnu_pbds;\ntypedef long long ll;\ntypedef vector vl;\ntypedef pair pl;\n#define po pop_back\n#define pb push_back\n#define mk make_pair\n#define lw lower_bound\n#define up upper_bound\n#define ff first\n#define ss second\n#define boost ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);\n#define MOD 1000000007\n#define MAX 1e18 \n#define MIN -1e18\n#define rep(i,a,b) for(ll i=a;i<=b;i++)\n#define per(i,a,b) for(ll i=a;i>=b;i--)\n#define con continue\n#define freopen freopen(\"input.txt\", \"r\", stdin);freopen(\"output.txt\", \"w\", stdout);\n#define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628\ntypedef tree, rb_tree_tag, tree_order_statistics_node_update> indexed_set;\n//template< typename T>\n//using indexed_set = tree, rb_tree_tag, tree_order_statistics_node_update>;\nconst int N=1e6+1;\nll ans,mid,mn,mx,cnt,m,T,sum,h1,h2,a,b,c[1234567],d[1234567],c1[N][30],n,k,i,j,l,x,y,r;\nbool used[10000005];\nll dp[60][60][60][60];\nstring s;\nint main(){\n double x,y;\n cin>>x>>y;\n printf(\"%.10lf\" , y/x*2+1);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "14878d92ee8537bd038723008be9ebf5", "src_uid": "ae883bf16842c181ea4bd123dee12ef9", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include\nint main()\n{\n int r1,r2,c1,c2,d1,d2;\n int a,b,c,d,m;\n while(scanf(\"%d%d\",&r1,&r2)!=EOF&&r1,r2)\n {\n scanf(\"%d%d\",&c1,&c2);\n scanf(\"%d%d\",&d1,&d2);\n m = 1;\n for(a=1;a<=9;a++)\n {\n\n for(b=1;b<=9;b++)\n {\n if(a!=b)\n for(c=1;c<=9;c++)\n {\n if(a!=c&&b!=c)\n for(d=1;d<=9;d++)\n if(a!=d&&b!=d&&c!=d)\n if(a+b==r1&&c+d==r2&&a+c==c1&&b+d==c2&&a+d==d1&&b+c==d2)\n {\n printf(\"%d %d\\n%d %d\\n\",a,b,c,d);\n m = 0;\n break;\n }\n }\n if(m==0)\n break;\n }\n if(m==0)\n break;\n }\n if(m)printf(\"-1\\n\");\n }\n return 0;\n}\n\n\n ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7fc92d402a990b293e711e0e8b75d364", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include\nint main()\n{\n int r1,r2,c1,c2,d1,d2;\n int a,b,c,d,m;\n while(scanf(\"%d%d\",&r1,&r2)!=EOF&&r1,r2)\n {\n scanf(\"%d%d\",&c1,&c2);\n scanf(\"%d%d\",&d1,&d2);\n m = 1;\n for(a=1;a<=9;a++)\n {\n for(b=1;b<=9;b++)\n {\n for(c=1;c<=9;c++)\n {\n for(d=1;d<=9;d++)\n if(a+b==r1&&c+d==r2&&a+c==c1&&b+d==c2&&a+d==d1&&b+c==d2)\n {\n if(a!=b&&a!=c&&a!=d&&b!=d&&b!=c&&c!=d)\n {\n printf(\"%d %d\\n%d %d\\n\",a,b,c,d);\n m = 0;\n }\n break;\n }\n }\n if(a+b==r1&&c+d==r2&&a+c==c1&&b+d==c2&&a+d==d1&&b+c==d2)\n if(a!=b&&a!=c&&a!=d&&b!=d&&b!=c&&c!=d)\n break;\n }\n if(a+b==r1&&c+d==r2&&a+c==c1&&b+d==c2&&a+d==d1&&b+c==d2)\n if(a!=b&&a!=c&&a!=d&&b!=d&&b!=c&&c!=d)\n break;\n }\n if(m)printf(\"-1\\n\");\n }\n return 0;\n}\n\n\n ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f15b864008191cef630230068f2b4cf5", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int r1,r2,c1,c2,d1,d2;\n cin>>r1>>r2>>c1>>c2>>d1>>d2;\n if (d1==10 && d2==10 )\n {\n cout<<-1;\n return 0;\n }\n int w1=1,w2=1,e1=1,e2=1;\n while (true )\n {\n if (w1+e2==d1 )\n {\n break;\n }\n else{\n w1++;\n if (w1==10 )\n {\n w1--;\n e2++;\n }\n }\n }\n while (true )\n {\n if (w2+e1==d2 )\n {\n break;\n }\n else{\n w2++;\n if (w2==10 )\n {\n w2--;\n e1++;\n }\n }\n }\n while (true )\n {\n if (w1+w2==r1 )\n {\n break;\n }\n else if (w1+w2>r1 )\n {\n if (w1>1 && e2<9 )\n {\n w1--;\n e2++;\n }\n else if (w2>1 && e1<9 )\n {\n w2--;\n e1++;\n }\n else\n {\n cout<<-1;\n return 0;\n }\n\n }\n else\n {\n if (w1<9 && e2>1 )\n {\n w1++;\n e2--;\n }\n else if (w2<9 && e1>1 )\n {\n w2++;\n e1--;\n }\n else\n {\n cout<<-1;\n return 0;\n\n }\n\n }\n }\n while (true)\n {\n if (w1+e1==c1 )\n {\n break;\n }\n else if (w1+e1>c1 )\n {\n if (w1>1 && e1>1 && e2<9 && w2<9 )\n {\n w1--;\n e2++;\n w2++;\n e1--;\n }\n else\n {\n cout<<-1;\n return 0;\n }\n\n }\n else\n {\n if (w2>1 && e2>1 && e1<9 && w1<9 )\n {\n w1++;\n e2--;\n w2--;\n e1++;\n }\n else\n {\n cout<<-1;\n return 0;\n }\n\n }\n }\n while (true)\n {\n if (e1+e2==r2 )\n {\n break;\n }\n else if (e1+e2>r1 )\n {\n if (w1<9 && e2>1 )\n {\n w1++;\n e2--;\n }\n else if (w2<9 && e1 >1 )\n {\n w2++;\n e1--;\n }\n\n }\n else\n {\n if (w1<9 && e2>1 )\n {\n w1++;\n e2--;\n }\n else if (w2<9 && e1 >1 )\n {\n w2++;\n e1--;\n }\n\n }\n }\n while (true )\n {\n if (w2+e2==c2 )\n {\n break;\n }\n else if (w2+e2>c2 )\n {\n\n if (w2>1 && e2>1 && e1<9 && w1<9 )\n {\n w1++;\n e2--;\n w2--;\n e1++;\n }\n else\n {\n cout<<-1;\n return 0;\n }\n\n }\n else\n {\n if (w1>1 && e1>1 && e2<9 && w2<9 )\n {\n w1--;\n e2++;\n w2++;\n e1--;\n }\n else\n {\n cout<<-1;\n return 0;\n }\n\n }\n }\n\n if ( w1==w2 || w1==e1 || w1==e2 || w2 ==e1|| w2==e2 || e2 ==e1 || w1>9 || w2 > 9 || e2 > 9 || e1 >9 )\n {\n cout<<-1;\n }\n\n\n else\n cout<\n#include \n#include \n\nusing namespace std;\n\nclass Lar\n{\npublic:\n\tLar(int nr1, int nr2, int nc1, int nc2, int nd1, int nd2)\n\t{\n\t\tgems[0][0] = 0;\n\t\tgems[0][1] = 0;\n\t\tgems[1][0] = 0;\n\t\tgems[1][1] = 0;\n\n\t\tr1 = nr1;\n\t\tr2 = nr2;\n\t\tc1 = nc1;\n\t\tc2 = nc2;\n\t\td1 = nd1;\n\t\td2 = nd2;\n\t}\n\n\tvoid setR1(int n1, int n2)\n\t{\n\t\tgems[0][0] = n1;\n\t\tgems[0][1] = n2;\n\t}\n\n\tvoid setR2(int n1, int n2)\n\t{\n\t\tgems[1][0] = n1;\n\t\tgems[1][1] = n2;\n\t}\n\n\tbool check()\n\t{\n\t\tif (gems[0][0] == gems[1][0] || gems[0][0] == gems[0][1] || gems[0][0] == gems[1][1])\n\t\t\treturn false;\n\t\tif (gems[0][1] == gems[1][0] || gems[0][1] == gems[1][1])\n\t\t\treturn false;\n\t\tif (gems[1][0] == gems[1][1])\n\t\t\treturn false;\n\t\t\n\t\tif (gems[0][0] + gems[0][1] != r1)\n\t\t\treturn false;\n\n\t\tif (gems[1][0] + gems[1][1] != r2)\n\t\t\treturn false;\n\n\t\tif (gems[0][0] + gems[1][0] != c1)\n\t\t\treturn false;\n\n\t\tif (gems[0][1] + gems[1][1] != c2)\n\t\t\treturn false;\n\n\t\tif (gems[0][0] + gems[1][1] != d1)\n\t\t\treturn false;\n\n\t\tif (gems[0][1] + gems[1][0] != d2)\n\t\t\treturn false;\n\n\t\treturn true;\n\t}\n\nprivate:\n\tint gems[2][2];\n\tint r1, r2, c1, c2, d1, d2;\n};\n\nint main(int argc, char* argv[])\n{\n\tint r1, r2, c1, c2, d1, d2;\n\tcin >> r1;\n\tcin >> r2;\n\tcin >> c1;\n\tcin >> c2;\n\tcin >> d1;\n\tcin >> d2;\n\n\tLar lar(r1, r2, c1, c2, d1, d2);\n\n\tfor (int i = 1; i < r1; i++)\n\t{\n\t\tlar.setR1(i, r1 - i);\n\n\t\tfor (int j = 1; j < r2; j++)\n\t\t{\n\t\t\tlar.setR2(j, r2 - j);\n\n\t\t\tif (lar.check())\n\t\t\t{\n\t\t\t\tcout << i << ' ' << r1 - i << endl <<\n\t\t\t\t\tj << ' ' << r2 - j;\n\t\t\t\t_getch();\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\n\tcout << -1;\n\t_getch();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a07a7e9dd2d4e697dfbdd987dc2b6b0e", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main(){\n \n int k, n;\n cin>>n>>k;\n if(n%2==0)\n {\n if(k\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint main(){\n ifstream fin;\n ofstream fout;\n int k, n;\n cin>>n>>k;\n int array[n];\n if(n%2==0){\n int count=0;\n for(int i=0; i\n#include \nusing namespace std;\nint main()\n{\n\tlong int n, m;\n\tcin >> n >> m;\n\tlong int *a = new long int[n];\n\tlong int x;\n\tlong int j = 0;\n\tif (n % 2 == 0)\n\t\tx = n / 2;\n\telse x = n / 2 + 1;\n\n\tfor (long int i = 1; i <= n; i++)\n\t{\n\t\t\n\t\tif (i % 2 == 0)\n\t\t{\n\t\t\ta[x] = i;\n\t\t\tx++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\ta[j] = i;\n\t\t\tj++;\n\t\t}\n\t}\n\tcout << a[m-1];\n\tgetch();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "26399d1b27056140c5bc704647354168", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\nint main()\n{\n\tlong long n, m;\n\tcin >> n >> m;\n\tlong long *a = new long long[n];\n\tlong long x;\n\tlong long j = 0;\n\tif (n % 2 == 0)\n\t\tx = n / 2;\n\telse x = n / 2 + 1;\n\n\tfor (long long i = 1; i <= n; i++)\n\t{\n\t\t\n\t\tif (i % 2 == 0)\n\t\t{\n\t\t\ta[x] = i;\n\t\t\tx++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\ta[j] = i;\n\t\t\tj++;\n\t\t}\n\t}\n\tcout << a[m-1];\n\tgetch();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "eb220ce30dc2050f4c4ca40066eda804", "src_uid": "1f8056884db00ad8294a7cc0be75fe97", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include\n#include\n\n#define MAX 101\n\n\nint main(){\n\n\tint resp=0, i;\n\tchar input[MAX] = { 0 };\n\tint ref[4] = { 0 };\n\n\tscanf(\"%s\", input);\n\tfor (i = 0; i < sizeof(input);i++){\n\t\tif (input[i] == 'n')\n\t\t\tref[0]++;\n\n\t\telse if (input[i] == 'i')\n\t\t\tref[1]++;\n\n\t\telse if (input[i] == 'e')\n\t\t\tref[2]++;\n\n\t\telse if (input[i] == 't')\n\t\t\tref[3]++;\n\t\t}\n\n\n\twhile (ref[0] >= 2 && ref[1] >= 1 && ref[2] >= 3 && ref[3] >= 1){\n\t\tif (resp == 0){\n\t\t\tif (ref[0] >= 3 && ref[1] >= 1 && ref[2] >= 3 && ref[3] >= 1){\n\t\t\t\tresp++;\n\t\t\t\tref[0] = ref[0] - 3;\n\t\t\t\tref[1] = ref[1] - 1;\n\t\t\t\tref[2] = ref[2] - 3;\n\t\t\t\tref[3] = ref[3] - 1;\n\t\t\t}\n\t\t}\n\t\telse{\n\t\t\tresp++;\n\t\t\tref[0] = ref[0] - 2;\n\t\t\tref[1] = ref[1] - 1;\n\t\t\tref[2] = ref[2] - 3;\n\t\t\tref[3] = ref[3] - 1;\n\t\t}\n\t}\n\tprintf(\"%d\", resp);\n\treturn 0;\n}\n// 1506955771222\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "31fae7f188e72f27bc47afb0ea5a160b", "src_uid": "bb433cdb8299afcf46cb2797cbfbf724", "difficulty": null} {"lang": "GNU C++", "source_code": "#include \n#include \n\n\n\nint main(){\n\tint alf[26],cont=0;\n\t//nineteen => n = 3,i=1,e=3,t=1\n\tint n=3,i=1,e=3,t=1;\n\tchar str[110];\n\n\t\tscanf(\" %s\",str);\n\t\t//printf(\"%s\\n\",str);\n\t\tfor(int j=0;j<26;j++)\n\t\t\talf[j]=0;\n\t\tfor(int j =0;j< strlen(str);j++)\n\t\t\talf[(int)str[j]-'a']++;\n\t\n\t//\tfor(int j=0;j<26;j++)\n\t//\t\tprintf(\"%d \",alf[j]);\n\t\n\tint N =alf[13];\n\tint E = alf[4];\n\tint I = alf[8];\n\tint T = alf[19];\n\t\n\twhile(N && I && E && T){\n\t\tif(N>=n && I>= i && E>=e && T>=t){\n\t\t\tN -= 2;I-=i;E-=e;T-=t;cont++;\n\t\t}\n\t}\n\t\t\t\n\tprintf(\"%d\\n\",cont);\n\t\n\n \t\nreturn 0;\n}\n// 1506955344782\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0767b786c5856096f62e7aea0001b27f", "src_uid": "bb433cdb8299afcf46cb2797cbfbf724", "difficulty": null} {"lang": "GNU C++11", "source_code": "#include \n#include\nusing namespace std;\n\nint main()\n{\n char s[100];\n cin>>s;\n int n=0,i=0,e=0,t=0;\n int w=0;\n for(int i=0;i=3 && i>=1 && e>=3 && t>=1)\n {\n n=n-3;\n i=i-1;\n e=e-3;\n t=t-1;\n q++;\n }\n cout << w+q<\n#include\nusing namespace std;\n\nint main()\n{\n char s[100];\n cin>>s;\n int n=0,i=0,e=0,t=0;\n int w=0;\n for(int i=0;i=3 && i>=1 && e>=3 && t>=1)\n {\n n=n-3;\n i=i-1;\n e=e-3;\n t=t-1;\n q++;\n }\n cout << w+q<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\n#define ll long long\n#define vi vector\n#define vs vector\n#define vc vector\n#define twv vector>\n#define fo(i,a,n) for(int i=int(a);i>x\n#define si set\n#define sc set\n#define ss set\n#define qqi queue\n#define qqc queue\n#define sti stack\n#define stc stack\n#define nl cout<<\"\\n\"\n#define pb(x) push_back(x)\nint main()\n{\n\tios_base::sync_with_stdio(false); \n cin.tie(NULL);\n int n;ip(n);\n vi a(n,0);\n vi b(n,0);\n int max_ans=0;\n fo(i,0,3)ip(a[i]);\n fo(i,0,3)ip(b[i]);\n fo(i,0,3){\n max_ans+=min(a[i],b[(i+1)%3]);\n }\n vi visited(3,0);\n fo(i,0,3){\n int max_index=0;int max=0;\n fo(j,0,3){\n if(a[j]>max && !visited[j]){\n max=a[j];\n max_index=j;\n }\n }\n if(!visited[max_index]){\n visited[max_index]=1;\n int j=max_index;int k=(j-1)%3;\n if(k<0)k=3+k;\n if(b[j]+b[k]<=a[j]){\n a[j]-=b[j]+b[k];\n b[j]=0;b[k]=0;\n }\n else{\n int t=min(b[k],a[j]);\n a[j]-=t;\n b[k]=b[k]-t;\n int w=min(a[j],b[j]);\n a[j]-=w;\n b[j]-=w;\n }\n }\n }\n int min_ans=0;\n fo(i,0,3){\n min_ans+=min(a[i],b[(i+1)%3]);\n }\n cout<\n#define endl \"\\n\";\n#define ll long long \n#define pb push_back\n#define mp make_pair\n#define ull unsigned long long\n#define satyam ios_base::sync_with_stdio(false);\n#define mishra cin.tie(NULL);cout.tie(NULL);\n#define mod 1000000007\nusing namespace std;\nll fac[2000005];\nvoid pre(){ fac[0]=1; fac[1]=1; for(ll i=2;i<2000005;i++) fac[i]=(i*fac[i-1])%mod;}\nll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}\nll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}\nll binomialCoeff(ll n, ll k) { \n ll C[k + 1]; \n memset(C, 0, sizeof(C)); \n C[0] = 1; // nC0 is 1 \n for (ll i = 1; i <= n; i++) { \n \n // Compute next row of pascal triangle using \n // the previous row \n for (ll j = min(i, k); j > 0; j--) \n C[j] = C[j] + C[j - 1]; \n } \n return C[k]; \n} \n \n// Returns count of G.P. subseqeunces \n// with length 3 and common ratio r \nlong long subsequences(ll a[], ll n, ll r) \n{ \n // hashing to maintain left and right array \n // elements to the main count \n unordered_map left, right; \n \n // stores the answer \n long long ans = 0; \n \n // traverse through the elements \n for (ll i = 0; i < n; i++) \n right[a[i]]++; // keep the count in the hash \n \n // IF RATIO IS ONE \n if (r == 1){ \n \n // traverse the count in hash \n for (auto i : right) { \n \n // calculating nC3, where 'n' is \n // the number of times each number is \n // repeated in the input \n ans += binomialCoeff(i.second, 3); \n } \n \n return ans; \n } \n \n // traverse through all elements \n // and find out the number of elements as k1*k2 \n for (ll i = 0; i < n; i++) { \n \n // keep the count of left and right elements \n // left is a[i]/r and right a[i]*r \n long long c1 = 0, c2 = 0; \n \n // if the current element is divisible by k, \n // count elements in left hash. \n if (a[i] % r == 0) \n c1 = left[a[i] / r]; \n \n // decrease the count in right hash \n right[a[i]]--; \n \n // number of right elements \n c2 = right[a[i] * r]; \n \n // calculate the answer \n ans += c1 * c2; \n \n left[a[i]]++; // left count of a[i] \n } \n \n // returns answer \n return ans; \n} \nvoid sol()\n{\n int n;\n cin>>n;\n vector v(n),b(n);\n for(int i=0;i>v[i];\n b[i]=v[i];\n } \n sort(v.begin(),v.end(),greater());\n bool flag=false;\n for(int i=0;i v(n);\n for(int i=0;i>v[i];\n //b[i]=v[i];\n } \n sort(v.begin(),v.end());\n ll p=1;\n ll ans=0;\n int ind=0;\n for(int i=0;i<32;i++)\n {\n p=p*2;\n ll tmp=0;\n for(ind;ind=2)\n {\n ans+= ((tmp)*(tmp-1))/2;\n }\n }\n cout<>n>>x;\n vectorv;\n v.pb(2);\n ll i=0;\n while(v[i]>n>>m;\n ll arr[n];\n for(int i=0;i>a>>b>>c>>d;\n\n if(b == c){\n flag=1;\n }\n }\n for(int i=0;i<15;i++)\n {\n sort(arr,arr+n);\n }\n if(m%2==1)\n {\n cout<<\"NO\"<>n;\n ll a1,b1,a2,b2,a3,b3;\n cin>>a1>>a2>>a3>>b1>>b2>>b3;\n ll arr[n];\n for(int i=0;i>t;\n t=1;\n pre();\n while(t--)\n {\n //satyamm();\n //kamalkutiya();\n tangay();\n // nikhil();\n //nikhilpro();\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3c26ac327ab56c744c033c3267358c0c", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\n#define rep(i,n) for(i = 0;i < n;++i)\n#define all(v) v.begin(), v.end()\n\nint solve(vector>> v)\n{\n int i;\n rep(i,3){\n v.at(i).first = min(v.at(i).second.first, v.at(i).second.second); \n }\n sort(all(v));\n if(v.at(2).second.second >= v.at(0).second.first + v.at(1).second.first){\n return v.at(2).second.second - v.at(0).second.first - v.at(1).second.first;\n }\n vector>> vtmp = v;\n int ans = (1ll << 60);\n {\n if(v.at(2).second.second >= v.at(1).second.first){\n vtmp.at(0).second.first -= v.at(2).second.second - v.at(1).second.first;\n vtmp.at(1).second.first = 0;\n vtmp.at(2).second.second = 0;\n ans = min(ans, solve(vtmp));\n }else{\n vtmp.at(1).second.first -= v.at(2).second.second;\n vtmp.at(2).second.second = 0;\n ans = min(ans, solve(vtmp));\n }\n }\n return ans;\n\n}\n\nint main()\n{\n int i,j;\n int n;\n cin >> n;\n vector a(3);\n vector b(3);\n rep(i,3) cin >> a[i];\n rep(i,3) cin >> b[i];\n int maxwin = min(a[0], b[1]) + min(a[1], b[2]) + min(a[2], b[0]);\n vector>> v;\n rep(i,3){\n v.emplace_back(min(a[i], b[(i + 1)%3]), make_pair(a[i], b[(i + 1)%3]));\n }\n int minwin = solve(v);\n cout << minwin << \" \" << maxwin << endl;\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1fbe73743ce5d6045fb87dfa6142428c", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\n#define rep(i,n) for(i = 0;i < n;++i)\n#define all(v) v.begin(), v.end()\nusing ll = long long;\n\nll solve(vector>> v)\n{\n int i;\n rep(i,3){\n v.at(i).first = min(v.at(i).second.first, v.at(i).second.second); \n }\n sort(all(v));\n if(v.at(2).second.second >= v.at(0).second.first + v.at(1).second.first){\n return v.at(2).second.second - v.at(0).second.first - v.at(1).second.first;\n }\n vector>> vtmp = v;\n ll ans = (1ll << 60);\n {\n if(v.at(2).second.second >= v.at(1).second.first){\n vtmp.at(0).second.first -= v.at(2).second.second - v.at(1).second.first;\n vtmp.at(1).second.first = 0;\n vtmp.at(2).second.second = 0;\n ans = min(ans, solve(vtmp));\n }else{\n vtmp.at(1).second.first -= v.at(2).second.second;\n vtmp.at(2).second.second = 0;\n ans = min(ans, solve(vtmp));\n }\n }\n return ans;\n\n}\n\nint main()\n{\n ll i,j;\n ll n;\n cin >> n;\n vector a(3);\n vector b(3);\n rep(i,3) cin >> a[i];\n rep(i,3) cin >> b[i];\n ll maxwin = min(a[0], b[1]) + min(a[1], b[2]) + min(a[2], b[0]);\n vector>> v;\n rep(i,3){\n v.emplace_back(min(a[i], b[(i + 1)%3]), make_pair(a[i], b[(i + 1)%3]));\n }\n ll minwin = solve(v);\n cout << minwin << \" \" << maxwin << endl;\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "88c396b939f87603b1272a1971258e7e", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define ll long long\n\nusing namespace std;\nint main()\n{\n int n;\n cin>>n;\n int a[n];\n for(int i=0; i>a[i];\n sort(a,a+n);\n set < int > r(a,a+n) ;\n int len=r.size(),ok = 0;\n for(int i=0; i\n\nusing namespace std;\n\n#define SYN ios_base::sync_with_stdio(0);cin.tie(0);\ntypedef long long int LLI;\ntypedef unsigned long long int ULLI;\n\n#define dbg(x) cerr<<__LINE__<<\" \"<<#x<<\" \"<\n#define VS vector\n#define PB push_back\n#define PI acos(-1.0)\n#define mk make_pair\n#define pll pair\n#define xx first\n#define yy second\n#define all(a) a.begin(),a.end()\n\n\n#define MOD 1000000007\n#define MX 100000\n#define RADIANS(x) (((1.0 * x * PI) / 180.0))\n#define DEGREES(x) (((x * 180.0) / (1.0 * PI)))\n\n\n//I/O\n\n#define S scanf\n#define P printf\n\n#define I(X) scanf(\"%I64\", &(X))\n#define II(X, Y) scanf(\"%I64%I64\", &(X), &(Y))\n#define III(X, Y, Z) scanf(\"%I64%I64%I64\", &(X), &(Y), &(Z))\n\n\n// Loop\n\n#define F(i,a,b) for(int i=a;i>val;\n return val;\n}\n\nstring LLItostring(LLI val)\n{\n string str;\n stringstream ss;\n ss<>str;\n return str;\n}\n\nint main()\n{\n LLI val;\n while(cin>>val)\n {\n\n for(LLI i=0; i>arr[i];\n }\n\n bool ok=false;\n\n\n for(LLI i=0; i>str;\n// return str;\n// }\n\n d1=arr[k]-arr[i];\n if(d1<0)\n d1*=(-1);\n d2=arr[k]-arr[j];\n if(d2<0)\n d2*=(-1);\n d3=arr[j]-arr[i];\n if(d3<0)\n d3*=(-1);\n if(d1<=2&&d2<=2&&d3<=2)\n {\n ok=true;\n break;\n }\n }\n }\n if(ok==true)\n break;\n }\n if(ok==true)\n break;\n }\n if(ok==true)\n cout<<\"YES\"<\n#include \nusing namespace std;\nint a[1002],i,n,k;\nmain(){\n\tcin>>n;\n\tfor(i=0;i>a[i];\n\t}\n\tsort(a,a+n);\n\tfor(i=0;i0){cout<<\"YES\"; return 0;} else {cout<<\"NO\"; return 0;}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9a4d8923808a82f6ab403ac55a9e2cf2", "src_uid": "d6c876a84c7b92141710be5d76536eab", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n#define maxn 100000005\n#define INF 1<<32-1\nint n,MAX=-INF;\nint a[maxn];\nbool F[maxn];\nint main(){\n scanf(\"%d\",&n);\n for(int i=1;i<=n;i++){\n scanf(\"%d\",&a[i]);\n F[a[i]]=1;\n if(a[i]>MAX)MAX=a[i];\n}\n//for(int i=1;i<=MAX;i++){\n//\tprintf(\"%d\",F[i]);\n//}\n//puts(\"\");\n int flag=0;\n for(int i=1;i<=MAX;i++){\n if(F[i]==1)flag++;\n else flag=0;\n if(flag==3){puts(\"YES\"); flag=0;return 0; }\n }\n puts(\"NO\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3c36aaf1b26af49a2b3f4383253100a0", "src_uid": "d6c876a84c7b92141710be5d76536eab", "difficulty": 900.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n\nusing namespace std;\nvoid main(){\nstring a1,b1, s;\n //cin >>s;\n //getline(cin , s ) ;\n //\n int a,b,k=0,x =1,nice=0;\n //a1=(s[0],s.find_first_of(' ')-1);\n cin >>a>>b ; //b1=(s.find_first_of(' ')+1,s.length()-1);\n //a=atoi(a1.c_str());\n //b=atoi(b1.c_str());\n // bool l=0;\n // cout <=1)&&(k<=a))\n {cout <<\"\\nx=\"<a&&k<1 )break; \n}\ncout << nice ; \n } \n else {\n nice = 0 ; \n cout <\n\n#define ll long long\n#define pb push_back\n#define pii pair\n#define pll pair\n#define ff first\n#define ss second\n\nusing namespace std;\n\nconst double pi = acos(-1);\nconst int N = 2e6 + 6, mod = 1000000007, M = 1e7 + 7;\nconst ll MAX = 5e18;\n\nll a, b, c, v, ans;\n\nll moding(ll x){\n if(x >= mod)\n x %= mod;\n return x;\n}\n\nbool can(ll x){\n return (x / b) / (x % b) <= a;\n}\n\nint main()\n{\n cin >> a >> b;\n if(b == 1)\n return puts(\"0\");\n while(v < a){\n v++;\n c += moding(v * b) + 1;\n }\n ans = c;\n for(int i = 2; i < b; i++){\n while(!can((v * b + 1) * i))\n c -= v * b + 1, v--;\n ans = moding(ans + moding(moding(c) * i));\n }\n cout << ans;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d122323b46ae34f16a0a0d073f6520e3", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "///Bismillahir Rahmanir Rahim\n#define inf 9223372036854775807\n#define ll long long\n#define pii pair\n#define m_p make_pair\n#define ull unsigned long long\n#define spd ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);\n#include \nusing namespace std;\nconst ll m = 1e9+7;\nint main()\n{\n spd\n\n ll a,b,i,x,ans=0,sum=0,tot,k,last,gun,n;\n\n cin>>a>>b;\n mapmp;\n\n for(i=1;i\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef vector vll;\ntypedef pair pii;\ntypedef vector vs;\ntypedef vector vb;\ntypedef vector vi;\ntypedef vector vd;\ntypedef vector > vvi;\ntypedef vector vii;\ntypedef vector > vvii;\ntypedef long double ld;\ntypedef map mapii;\ntypedef map mapsi;\n\n#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)\n#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)\n#define INF LLONG_MAX\n#define all(v) ((v).begin()), ((v).end())\n#define sz(v) ((int)((v).size()))\n#define pi acos(-1)\n#define mod(n,m) ((n % m + m) % m)\n#define eps (1e-8)\n#define reset(n, m) memset(n, m, sizeof n)\n#define endl '\\n'\n#define output freopen(\"output.txt\", \"w\", stdout)\n#define mp(x, y, z) { x, {y, z} }\n\nconst int N = 2e7 + 5, mod = 1e9 + 7;\nll vals[N], accum[N];\n\nint main()\n{\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n//\tll p = 0, q = 5;\n//\terep(i, 1, 1000)\n//\t{\n//\t\tif (i % q == 0)\n//\t\t\tcontinue;\n//\n//\t\tif (((i / q) / (i % q)) == 2)\n//\t\t{\n//\t\t\tp += i;\n//\t\t\tcout << i << \" \" << i / q << \" \" << i % q << endl;\n//\n//\t\t}\n//\t}\n//\tcout << p << endl;\n//\treturn 0;\n\n\tll a, b;\n\tcin >> a >> b;\n\trep(i, 1, N)\n\t{\n\t\tvals[i] = vals[i - 1] + b;\n\t\tif (vals[i] >= mod)\n\t\t\tvals[i] -= mod;\n\t\taccum[i] = accum[i - 1] + vals[i];\n\t\tif (accum[i] >= mod)\n\t\t\taccum[i] -= mod;\n\t}\n\n\tll sum = 0, temp = (b * (b - 1)) / 2, extra = -1, obba7 = 0, zawwed = 0,\n\t\t\tprev;\n\tfor (ll i = 1; i < b; i++)\n\t\tzawwed = (zawwed + i * i) % mod;\n\terep(i, 1, a)\n\t{\n\t\tif (extra != -1)\n\t\t{\n\t\t\tsum = (sum + prev + obba7) % mod;\n\t\t\tprev = sum;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (i == 1)\n\t\t{\n\t\t\trep(j, 1, b)\n\t\t\t{\n\t\t\t\tint l = j - 1, r = (2 * j) - 1;\n\t\t\t\tsum = (sum + (accum[r] - accum[l])) % mod;\n\t\t\t}\n\t\t\tsum = (sum + zawwed) % mod;\n\t\t}\n\t\telse\n\t\t{\n\t\t\textra = 0;\n\t\t\tll hoba = temp;\n\t\t\trep(j, 1, b)\n\t\t\t{\n\t\t\t\tint l = (2 * j) - 1, r = min(l + j * 1ll, l + hoba);\n\t\t\t\tif (j == 1)\n\t\t\t\t\tr = j + 1, l = 1;\n\t\t\t\textra = (extra + (accum[r] - accum[l])) % mod;\n\t\t\t\thoba -= j;\n\t\t\t}\n\t\t\textra = (extra + zawwed) % mod;\n\t\t\tobba7 = mod(extra - sum, mod);\n//\t\t\tcout << \"--> \" << extra << \" \" << obba7 << endl;\n//\t\t\tcout << extra << endl;\n\t\t\tsum = (sum + extra) % mod;\n\t\t\tprev = extra;\n\t\t}\n\t}\n\tcout << sum;\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0f0930536f366be9d980ab520e3aacdb", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std;\nconst int maxd = 10005;\nint dp[maxd];\nint main(){\n int n,m,number=1,tot=1;\n scanf(\"%d %d\",&n,&m);\n for(int i=1;i<=maxd;i++){\n dp[i] = number+1;\n tot--;\n if(!tot)tot = ++number;\n }\n printf(\"%d %d\",max(0,n-(m*2)),n-dp[m]);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "52fe05fa21a35a7a49af80ba9a88cd98", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\n\nll n, m;\nll jc[100100];\n\nint main()\n{\n\tcin >> n >> m;\n\tif (n == 1)\n\t{\n\t\tcout << \"1 1\";\n\t\treturn 0;\n\t}\n\tif (m == 0)\n\t{\n\t\tcout << n << \" \" << n;\n\t\treturn 0;\n\t}\n\tfor (ll i = 1; i <= n; ++i) jc[i] = (i * (i - 1)) >> 1;\n\tcout << max(n - (m << 1), 1LL * 0);\n\tcout << \" \";\n\tfor (int i = 1; i <= n; ++i) \n\t\tif (m < jc[i]) \n\t\t{\n\t\t\tll mm = m;\n\t\t\tmm -= jc[i - 1];\n\t\t\twhile (mm > 0) \n\t\t\t{\n\t\t\t\tmm -= (i - 1);\n\t\t\t\t++i;\n\t\t\t}\n\t\t\tcout << n - i + 1;\n\t\t\treturn 0;\n\t\t}\n\t\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "afb2b9335ac02f7e656158aa999a8e72", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\nconst ll inf = 1e18;\n\nint main() {\n\tll n, m; cin >> n >> m;\n\n\tcout << max((ll)0,n - 2 * m) << ' ';\n\n\t\n\tfor (ll i = 0; i < n*(n - 1) / 2; i++) {\n\t\tif (i*(i - 1) / 2 >= m) {\n\t\t\tcout << n - i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c4901b0f6935d9e05f9d7d5351802ed0", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n int n, j, a, s, b, c, i;\n long long sum, m;\n cin >> n >> m;\n if(m == 0) cout << n << \" \" << n;\n else\n if(m == 1) cout << max(n - 2, 0) << \" \" << max(n - 2, 0);\n else{\n if(m >= (n + 1) / 2) cout << 0 << \" \";\n else cout << n % m << \" \";\n i = 1;\n sum = 0;\n for(;sum < m; i++)\n sum += i;\n cout << max(n - i, 0);\n return 0;\n}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cdde04913b3cbf8f3333460765ec1416", "src_uid": "daf0dd781bf403f7c1bb668925caa64d", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint main (){\n\tlong long int a,b;\n\tcin>>a>>b;\n\tfor(int i=0;i<=a*b+10000000;i+=b)\n\t{\n\t\tif(i>a)\n\t\t{\n\t\t\tcout<\nusing namespace std;\n\n#define MIN(a, b)\t(a < b) ? a : b\n#define MAX(a, b)\t(a > b) ? a : b\n#define endl\t\"\\n\"\n\ntypedef long long int int64;\ntypedef long double ld;\n\nint main()\n{\n\tios_base :: sync_with_stdio(false);\n\tint n, k;\n\tcin >> n >> k;\n\tif(n % k == 0) cout << k*(n/k + 1) << endl;\n\telse cout << setprecision(1000000000) << k*(ceil((double)n/k)) << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7361d1001dd4da4de19f1d88d65a6221", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n#define ll long long int\n#define ull unsigned long long int\n#define file freopen(\"input.txt\", \"r\", stdin);freopen(\"output.txt\", \"w\", stdout);\n#define done cin.tie(0);std::ios::sync_with_stdio(false);\n#define forit(i, a) for ( __typeof( (a).begin() ) i = (a).begin(); i != (a).end(); i++ )\n#define mp make_pair\n#define pb push_back\n#define clr(a,n) memset(a,n,sizeof(a))\n#define all(c) c.begin(), c.end()\n#define rep(i,n) for(int i=0;i=0;i--)\n#define popone(a) __builtin_popcount(a)\n#define popzero(a) __builtin_ctz(a)\n#define PI = 2.0*acos(0.0)\n#define mod 1000000007\n#define pi 3.14159265359\n//ll gcd (ll x,ll y){if(y==0)return x;return gcd(y,x%y);}\n//ll lcm(ll a,ll b){return a/gcd(a,b) * b;}\n//bool power2(int x){return (x && !(x & (x - 1)));}\n//ll largest_power(ll n){n = n| (n>>1);n= n| (n>>2);n = n| (n>>4);n = n| (n>>8);return (n+1)>>1;}\n//bool cmp(pairx,pairy)\n//{if (x.second==y.second) return x.firsty.second;}\n//int dx[] = {-1, -1, 1, 1, -2, -2, 2, 2 };\n//int dy[] = {2, -2, 2, -2, 1, -1, 1, -1 };\n//int dx[] = {1, -1, 0, 0, -1, -1, 1, 1};\n//int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};\n//int dx[]= {1, -1, 0, 0};\n//int dy[]= {0, 0, 1, -1};\nvectorvec;\nll n,k;\nvoid solve()\n{\n for(ll i=1;i<=1e9;i++)\n vec.pb(k*i);\n}\nint main()\n{\n done\n cin>>n>>k;\n solve();\n cout<<*upper_bound(all(vec),n)<\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n\n\nint main()\n{\n\tint n, k, x;\n\n\tcin >> n >> k;\n\n\tx = n;\n\n\twhile (x % k != 0)\n\t{\n\t\tx++;\n\t}\n\n\tcout << x;\n\n\tgetch();\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1d0b2d7d4c203fa78742d5c9a14a8145", "src_uid": "75f3835c969c871a609b978e04476542", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n\nint main()\n{\n int n;\n cin>>n;\n long long k = n * (n + 1) / 2;\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n//#include \n#define y1 blablabla\n#define ll long long\n#define tm ghfdskjdhf\n#define MAXN 500005\n#define MAXC 7000\n//#define INF \"~\"\n#define ss second\n#define ff first\n//#define int long long\n#define fpos fuuuu\n//#define double long double\n\nusing namespace std;\n\nint n;\n\nmain(){\n //freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n\n ios_base::sync_with_stdio(0);\n cin.tie();\n\n cin >> n;\n\n if((n * (n + 1) / 2) % 2 == 1)\n cout << 1;\n else\n cout << 0;\n return 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a6812f67fb2286265018ff623fa1152a", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include\n\nusing namespace std;\n\nint main()\n{\n int n,s=0;\n cin>>n;\n s=n*(n+1)/2;\n cout<\nusing namespace std;\n\n\nint main() {\n\tint n;\n\tcin>>n;\n\tlong long sum=((n+1)*n/2);\n\tcout<< sum%2 ;\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "47e61c839a4e20e7592bc5551f2a331b", "src_uid": "fa163c5b619d3892e33e1fb9c22043a9", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n#define MOD 1000000007\n#define N 200100\n#define LL long long\nLL fac[N], inv[N];\nLL powi(LL a, LL b)\n{\n LL c = 1;\n for (; b; b /= 2, a = 1ll * a * a % MOD)\n if (b & 1) c = 1ll * c * a % MOD;\n return c;\n}\nLL f, w, h;\nLL C(LL a, LL b)\n{\n if (a < 0) return 0;\n if (b < 0) return 0;\n if (a - b < 0) return 0;\n return 1ll * fac[a] * inv[b] % MOD * inv[a - b] % MOD;\n}\nLL get(LL ff, LL ww)\n{\n return 1ll * C(f - 1, ff - 1) * C(w - 1, ww - 1) % MOD;\n}\nLL get2(LL ff, LL ww)\n{\n return 1ll * C(f - 1, ff - 1) * C(w - 1 - ww * h, ww - 1) % MOD;\n}\nLL P, Q;\nint main()\n{\n cin >> f >> w >> h;\n fac[0] = 1; for (LL i = 1; i < N; ++ i) fac[i] = 1ll * fac[i - 1] * i % MOD;\n inv[N - 1] = powi(fac[N - 1], MOD - 2);\n for (LL i = N - 2; ~i; -- i) inv[i] = 1ll * inv[i + 1] * (i + 1) % MOD;\n for (LL ff = 1; ff <= f + 1; ++ ff)\n {\n P = (P + get(ff, ff - 1)) % MOD;\n P = (P + get(ff, ff)) % MOD;\n P = (P + get(ff, ff)) % MOD;\n P = (P + get(ff, ff + 1)) % MOD;\n Q = (Q + get2(ff, ff - 1)) % MOD;\n Q = (Q + get2(ff, ff)) % MOD;\n Q = (Q + get2(ff, ff)) % MOD;\n Q = (Q + get2(ff, ff + 1)) % MOD;\n }\n cout << 1ll * Q * powi(P, MOD - 2) % MOD;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4e5a4cab2af18b1f79391f004bfe2834", "src_uid": "a69f95db3fe677111cf0558271b40f39", "difficulty": 2300.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define LL long long\n#define MAX 100100\n#define MOD 1000000007\n\nLL dp1[405][MAX];\nLL dp2[405][MAX];\nLL dp3[405][MAX];\n\nLL quick(int k,LL x)\n{\n LL res=1;\n while(k)\n {\n if(k%2)res=(res*x)%MOD;\n x=(x*x)%MOD;\n k/=2;\n }\n return res;\n}\n\nint main()\n{\n int f,w,h;\n scanf(\"%d%d%d\",&f,&w,&h);\n\n dp1[0][0]=1;\n for(int i=1;i<=f&&i<=400;i++)\n {\n LL sum=0;\n for(int j=1;j<=f;j++)\n {\n dp1[i][j]=(dp1[i-1][j-1]+sum)%MOD;\n sum=(sum+dp1[i-1][j-1])%MOD;\n }\n }\n\n dp2[0][0]=1;\n for(int i=1;i<=w&&i<=400;i++)\n {\n LL sum=0;\n for(int j=h+1;j<=w;j++)\n {\n dp2[i][j]=(dp2[i-1][j-h-1]+sum)%MOD;\n sum=(sum+dp2[i-1][j-h-1])%MOD;\n }\n }\n\n dp3[0][0]=1;\n for(int i=1;i<=w&&i<=400;i++)\n {\n LL sum=0;\n for(int j=1;j<=w;j++)\n {\n dp3[i][j]=(dp3[i-1][j-1]+sum)%MOD;\n sum=(sum+dp3[i-1][j-1])%MOD;\n }\n }\n\n LL ans1=0,ans2=0;\n for(int i=0;i<=400;i++)\n {\n ans1=(ans1+dp1[i][f]*dp2[i][w]*2)%MOD;\n ans1=(ans1+dp1[i][f]*dp2[i+1][w])%MOD;\n if(i>0)\n {\n ans1=(ans1+dp1[i][f]*dp2[i-1][w])%MOD;\n }\n\n\n ans2=(ans2+dp1[i][f]*dp3[i][w]*2)%MOD;\n ans2=(ans2+dp1[i][f]*dp3[i+1][w])%MOD;\n if(i>0)\n {\n ans2=(ans2+dp1[i][f]*dp3[i-1][w])%MOD;\n }\n }\n\n printf(\"%lld\\n\",(ans1*quick(MOD-2,ans2))%MOD);\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "067a9446ee8569580a7b98818ffac7b7", "src_uid": "a69f95db3fe677111cf0558271b40f39", "difficulty": 2300.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define LL long long\n#define MAX 100100\n#define MOD 1000000007\n\nint dp1[405][MAX];\nint dp2[405][MAX];\nint dp3[405][MAX];\n\nLL quick(int k,LL x)\n{\n LL res=1;\n while(k)\n {\n if(k%2)res=(res*x)%MOD;\n x=(x*x)%MOD;\n k/=2;\n }\n return res;\n}\n\nint main()\n{\n int f,w,h;\n scanf(\"%d%d%d\",&f,&w,&h);\n\n dp1[0][0]=1;\n for(int i=1;i<=f&&i<=400;i++)\n {\n LL sum=0;\n for(int j=1;j<=f;j++)\n {\n dp1[i][j]=(dp1[i-1][j-1]+sum)%MOD;\n sum=(sum+dp1[i-1][j-1])%MOD;\n }\n }\n\n dp2[0][0]=1;\n for(int i=1;i<=w&&i<=400;i++)\n {\n LL sum=0;\n for(int j=h+1;j<=w;j++)\n {\n dp2[i][j]=(dp2[i-1][j-h-1]+sum)%MOD;\n sum=(sum+dp2[i-1][j-h-1])%MOD;\n }\n }\n\n dp3[0][0]=1;\n for(int i=1;i<=w&&i<=400;i++)\n {\n LL sum=0;\n for(int j=1;j<=w;j++)\n {\n dp3[i][j]=(dp3[i-1][j-1]+sum)%MOD;\n sum=(sum+dp3[i-1][j-1])%MOD;\n }\n }\n\n LL ans1=0,ans2=0;\n for(int i=0;i<=400;i++)\n {\n ans1=(ans1+(LL)dp1[i][f]*dp2[i][w]*2)%MOD;\n ans1=(ans1+(LL)dp1[i][f]*dp2[i+1][w])%MOD;\n if(i>0)\n {\n ans1=(ans1+(LL)dp1[i][f]*dp2[i-1][w])%MOD;\n }\n\n\n ans2=(ans2+(LL)dp1[i][f]*dp3[i][w]*2)%MOD;\n ans2=(ans2+(LL)dp1[i][f]*dp3[i+1][w])%MOD;\n if(i>0)\n {\n ans2=(ans2+(LL)dp1[i][f]*dp3[i-1][w])%MOD;\n }\n }\n\n printf(\"%lld\\n\",(ans1*quick(MOD-2,ans2))%MOD);\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "34a71e01a2ffe2253a3fb51b57f3bd38", "src_uid": "a69f95db3fe677111cf0558271b40f39", "difficulty": 2300.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nconst int N=10001;\nconst int mod=1e9+7;\nlong long int C[N][N];\nvoid build()\n{\n\tint i,j;\n\tfor(i=0;i\nusing namespace std;\n\nint main() {\n\tchar str[101];\n\tcin>>str;\n\tint ans=0,sb=0;\n\tfor(int i=1;str[i];i++) {\n\t\tif(str[i]=='K' && str[i-1]=='V') ans++;\n\t\tif(str[i-1]=='V' && str[i]=='V' && str[i+1]!='K') sb++;\t\n\t}\n\tans+= (sb>0);\n\tcout<\n#include \n#include \nusing namespace std;\nint main()\n\n{\n\tstring str;\n\tcin >> str;\n\tint count = 0;\n\tbool flag = true;\n\tif (str == \"VV\" || str == \"KK\")\n\t{\n\t\tcout << 1;\n\t\treturn 0;\n\t}\n\tfor (int i = 0; i < str.size(); i++)\n\t{\n\t\tif (str[i] == 'V' && str[i + 1] == 'K')\n\t\t{\n\t\t\tcount++; continue;\n\t\t}\n\t\tif (flag)\n\t\t{\n\t\t\tif (i < str.size() - 2)\n\t\t\t{\n\t\t\t\tif (str[i] == 'V' && str[i + 1] == 'V' && str[i + 2] == 'V' || str[i] == 'K' && str[i + 1] == 'K' && str[i + 2] == 'K')\n\t\t\t\t{\n\t\t\t\t\tcount++; flag = false;\n\t\t\t\t\tcout << \"I WAS HERE\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tcout << count;\n\t_getch();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "35e5e90cdaead41b57f418a64a7eecae", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include\n\nusing namespace std; \n\nint main() \n{ \nchar str[100]; \nscanf(\"%s\", str); \nint k = 0,f=0; \nfor (int i = 0; i < strlen(str)-1; i++){ \nif (str[i] == 'V' && str[i+1] == 'K') {\nk++;\nstr[i]='Q';\nstr[i+1]='Q'; \n}\n} \nfor (int i = 0; i < strlen(str)-1; i++){ \nif (str[i] == 'V' && str[i+1] == 'V') {\n f++;\n break;\n } \nif (str[i] == 'K' && str[i+1] == 'K') {\n f++;\n break;\n }\n} \nprintf(\"%d\",k+f); \ngetch();\nreturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f5006e17c5bd2c9a3a9898f8f64d097d", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \nusing namespace std;\nint main()\n\n{\n\tstring str;\n\tcin >> str;\n\tint count = 0;\n\tbool flag = true;\n\tif (str == \"VV\" || str == \"KK\")\n\t{\n\t\tcout << 1;\n\t\treturn 0;\n\t}\n\tfor (int i = 0; i < str.size(); i++)\n\t{\n\t\tif (str[i] == 'V' && str[i + 1] == 'K')\n\t\t{\n\t\t\tcount++; continue;\n\t\t}\n\t\tif (flag)\n\t\t{\n\t\t\tif (i < str.size() - 2)\n\t\t\t{\n\t\t\t\tif (str[i] == 'V' && str[i + 1] == 'V' && str[i + 2] == 'V' || str[i] == 'K' && str[i + 1] == 'K' && str[i + 2] == 'K')\n\t\t\t\t{\n\t\t\t\t\tcount++; flag = false;\n\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tcout << count;\n\t_getch();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4b7a9fe432c019125b9b0ce992b35784", "src_uid": "578bae0fe6634882227ac371ebb38fc9", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "//Lasha Bukhnikashvili\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define Pi 3.14159265358\n#define mod9 %1000000009\n#define INF 1000000000\n#define mod7 %1000000007\n#define LL long long\n#define time clock()/(double)CLOCKS_PER_SEC\nusing namespace std;\n int n,i,m,x,y,t,op;\n struct name{\n LL sum;\n LL upd;\n } T[800001];\n int a[200001];\n void BuildTree(int v,int tl,int tr){\n if (tl==tr){\n T[v].sum=a[tl];\n return;\n };\n int tm=(tl+tr)/2;\n BuildTree(2*v,tl,tm);\n BuildTree(2*v+1,tm+1,tr);\n T[v].sum=T[2*v].sum+T[2*v+1].sum;\n };\n void update(int v,int tl,int tr,int l,int r,int newval){\n if (l>r) return;\n if (tl==l && tr==r){\n T[v].upd+=newval;\n T[v].sum+=newval*(r-l+1);\n return;\n };\n int tm=(tl+tr)/2;\n update(2*v,tl,tm,l,min(tm,r),newval);\n update(2*v+1,tm+1,tr,max(tm+1,l),r,newval);\n T[v].sum=T[2*v].sum+T[2*v+1].sum;\n };\n LL query(int v,int tl,int tr,int l,int r,LL down){\n if (l>r) return 0;\n if (tl==l && tr==r) return T[v].sum+down*(r-l+1);\n int tm=(tl+tr)/2;\n \n return query(2*v,tl,tm,l,min(tm,r),down+T[v].upd)+query(2*v+1,tm+1,tr,max(tm+1,l),r,down+T[v].upd);\n \n };\nint main(){\n\n cin>>n>>m;\n for (i=1;i<=n;i++)\n cin>>a[i];\n BuildTree(1,1,n);\n while (m--){\n cin>>op>>x>>y;\n if (op==2) cout<>t,update(1,1,n,x,y,t);\n };\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7c4a5b4769c6a8456b578fa766e028f9", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "//Lasha Bukhnikashvili\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define Pi 3.14159265358\n#define mod9 %1000000009\n#define INF 1000000000\n#define mod7 %1000000007\n#define LL long long\n#define time clock()/(double)CLOCKS_PER_SEC\nusing namespace std;\n int n,i,m,x,y,t,op;\n struct name{\n LL sum;\n int upd;\n } T[800001];\n int a[200001];\n void BuildTree(int v,int tl,int tr){\n if (tl==tr){\n T[v].sum=a[tl];\n return;\n };\n int tm=(tl+tr)/2;\n BuildTree(2*v,tl,tm);\n BuildTree(2*v+1,tm+1,tr);\n T[v].sum=T[2*v].sum+T[2*v+1].sum;\n };\n void update(int v,int tl,int tr,int l,int r,int newval){\n if (l>r) return;\n if (tl==l && tr==r){\n T[v].upd+=newval;\n T[v].sum+=newval*(r-l+1);\n return;\n };\n int tm=(tl+tr)/2;\n update(2*v,tl,tm,l,min(tm,r),newval);\n update(2*v+1,tm+1,tr,max(tm+1,l),r,newval);\n T[v].sum=T[2*v].sum+T[2*v+1].sum;\n };\n LL query(int v,int tl,int tr,int l,int r,int down){\n if (l>r) return 0;\n if (tl==l && tr==r) return T[v].sum+down*(r-l+1);\n int tm=(tl+tr)/2;\n LL out;\n out=query(2*v,tl,tm,l,min(tm,r),down+T[v].upd)+query(2*v+1,tm+1,tr,max(tm+1,l),r,down+T[v].upd);\n return out;\n };\nint main(){\n\n cin>>n>>m;\n for (i=1;i<=n;i++)\n cin>>a[i];\n BuildTree(1,1,n);\n while (m--){\n cin>>op>>x>>y;\n if (op==2) cout<>t,update(1,1,n,x,y,t);\n };\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "194827bf64706978a2c5e859f87c1ae0", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "//Lasha Bukhnikashvili\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define Pi 3.14159265358\n#define mod9 %1000000009\n#define INF 1000000000\n#define mod7 %1000000007\n#define LL long long\n#define time clock()/(double)CLOCKS_PER_SEC\nusing namespace std;\n int n,i,m,x,y,t,op;\n struct name{\n LL sum;\n int upd;\n } T[800001];\n int a[200001];\n void BuildTree(int v,int tl,int tr){\n if (tl==tr){\n T[v].sum=a[tl];\n return;\n };\n int tm=(tl+tr)/2;\n BuildTree(2*v,tl,tm);\n BuildTree(2*v+1,tm+1,tr);\n T[v].sum=T[2*v].sum+T[2*v+1].sum;\n };\n void update(int v,int tl,int tr,int l,int r,int newval){\n if (l>r) return;\n if (tl==l && tr==r){\n T[v].upd+=newval;\n T[v].sum+=newval*(r-l+1);\n return;\n };\n int tm=(tl+tr)/2;\n update(2*v,tl,tm,l,min(tm,r),newval);\n update(2*v+1,tm+1,tr,max(tm+1,l),r,newval);\n T[v].sum=T[2*v].sum+T[2*v+1].sum;\n };\n LL query(int v,int tl,int tr,int l,int r,int down){\n if (l>r) return 0;\n if (tl==l && tr==r) return T[v].sum+down*(r-l+1);\n int tm=(tl+tr)/2;\n return query(2*v,tl,tm,l,min(tm,r),down+T[v].upd)+query(2*v+1,tm+1,tr,max(tm+1,l),r,down+T[v].upd); \n };\nint main(){\n #ifndef ONLINE_JUDGE\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n #endif\n cin>>n>>m;\n for (i=1;i<=n;i++)\n cin>>a[i];\n BuildTree(1,1,n);\n while (m--){\n cin>>op>>x>>y;\n if (op==2) cout<>t,update(1,1,n,x,y,t);\n };\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2147025f22db6bcedcaa8f767ca749e4", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\nint n;\nint a[1000];\n\nint b[1000];\nint c;\n\nint x[20000000][10];\n\nint zbroj;\n\nint main(){\n scanf(\"%d%d\", &n, &c);\n for(int i = 0;i < n;++i)scanf(\"%d\", &a[i]);\n for(int i = 1;i < n;++i){\n b[i] = a[i-1] - a[i] - c;\n }\n std::sort(b,b+n);\n printf(\"%d\", b[n-1]);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fbed48533930d12839906199fec77bd5", "src_uid": "411539a86f2e94eb6386bb65c9eb9557", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\nconst int N = 200;\nint a[N]; char str[N];\n\nint kiri, kanan, selisih;\nint ab, kk;\n\nint row[2][13];\n\nvoid cek_kiri_kanan(){\n\tfor(int i=0; i<27; i++){\n\t\tif(a[str[i]] != 0){\n\t\t\tkiri = a[str[i]];\n\t\t\tkanan = i;\n\t\t\tbreak;\n\t\t}\n\n\t\ta[str[i]] = i;\n\t}\n}\n\nvoid tentuin_posisi(){\n\tselisih = kanan - kiri - 1;\n\n\tint atas = selisih/2;\n\n\tab = 0;\n\tkk = 12 - atas;\n}\n\nvoid isimid(){\n\tint idx = kiri;\n\n\twhile(idx < kanan){\n\n\t\tif(ab == 0 && kk < 13){\n\t\t\trow[ab][kk] = str[idx];\n\t\t\tidx++;\n\t\t\tkk++;\n\t\t}\n\t\telse if(ab == 0 && kk == 13){\n\t\t\tab = 1;\n\t\t\tkk = 12;\n\t\t}\n\t\telse if(ab == 1 && kk >= 0){\n\t\t\trow[ab][kk] = str[idx];\n\t\t\tkk--;\n\t\t\tidx++;\n\t\t}\n\t}\n}\n\nvoid isikiri(){\n\tint idx = kiri - 1;\n\n\twhile(idx >= 0){\n\n\t\tif(ab == 1 && kk >= 0){\n\t\t\trow[ab][kk] = str[idx];\n\t\t\tidx--;\n\t\t\tkk--;\n\t\t}\n\t\telse if(ab == 1 && kk == -1){\n\t\t\tab = 0;\n\t\t\tkk = 0;\n\t\t}\n\t\telse if(ab == 0 && kk < 13){\n\t\t\trow[ab][kk] = str[idx];\n\t\t\tidx--;\n\t\t\tkk++;\n\t\t}\n\t}\n}\n\nvoid isikanan(){\n\tint idx = 26;\n\n\twhile(idx > kanan){\n\t\tif(ab == 1 && kk >= 0){\n\t\t\trow[ab][kk] = str[idx];\n\t\t\tidx--;\n\t\t\tkk--;\n\t\t}\n\t\telse if(ab == 1 && kk == -1){\n\t\t\tab = 0;\n\t\t\tkk = 0;\n\t\t}\n\t\telse if(ab == 0 && kk < 13){\n\t\t\trow[ab][kk] = str[idx];\n\t\t\tidx--;\n\t\t\tkk++;\n\t\t}\n\t}\n}\n\nint main(){\n\tscanf(\"%s\", str);\n\n\tcek_kiri_kanan();\n\ttentuin_posisi();\n\n\t// printf(\"%d %d\\n\", kiri, kanan);\n\n\tif(selisih == 0){\n\t\tputs(\"Impossible\");\n\t\treturn 0;\n\t}\n\n\tisimid();\n\tisikiri();\n\tisikanan();\n\n\tfor(int i=0; i<13; i++) printf(\"%c\", row[0][i]);\n\tputs(\"\");\n\tfor(int i=0; i<13; i++) printf(\"%c\", row[1][i]);\n\tputs(\"\");\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "14d1b37e86beca6823bd8d73751645e2", "src_uid": "56c5ea443dec7a732802b16aed5b934d", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n\nusing namespace std;\n\nconst int SIZE = 27;\nstring str;\nchar in[2][13] = {0, };\nchar visit[256] = { false, };\n\n\npair where(char c, int row, int col) {\n int rs = max(0, row-1);\n int re = min(1, row+1);\n int cs = max(0, col-1);\n int ce = min(12, col+1);\n\n for (int rr = rs; rr <= re; rr++) {\n for (int cc = cs; cc <= ce; cc++) {\n if (rr == row && cc == col) continue;\n if (in[rr][cc] == c) return make_pair(rr, cc);\n }\n }\n return make_pair(-1, -1);\n}\n\nbool go(int index, char current, int row, int col) {\n if (index == SIZE) return true;\n char &now = str[index];\n\n if (!visit[now]) { // not exist\n int rs = max(0, row-1);\n int re = min(1, row+1);\n int cs = max(0, col-1);\n int ce = min(12, col+1);\n\n for (int rr = rs; rr <= re; rr++) {\n for (int cc = cs; cc <= ce; cc++) {\n if (rr == row && cc == col) continue;\n if (in[rr][cc] != 0) continue;\n\n visit[now] = true;\n in[rr][cc] = now;\n if (go(index+1, now, rr, cc)) return true;\n visit[now] = false;\n in[rr][cc] = 0;\n }\n }\n return false;\n }\n else { // exist\n pair p = where(now, row, col);\n if (p.first == -1) return false;\n return go(index+1, now, p.first, p.second);\n }\n}\n\nbool go() {\n visit[str[0]] = true;\n for (int i = 0; i <= 6; i++) {\n in[0][i] = str[0];\n if (go(1, str[0], 0, i)) return true;\n in[0][i] = 0;\n }\n return false;\n}\n\nint main() {\n cin >> str;\n if (go()) {\n for (int i = 0; i < 13; i++) cout << in[0][i]; cout << endl;\n for (int i = 0; i < 13; i++) cout << in[1][i]; cout << endl;\n }\n else cout << \"Impossible\\n\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cb51b407816c5182acb1e73b0ab75613", "src_uid": "56c5ea443dec7a732802b16aed5b934d", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nint dx [] = { 0, 0, 1, 1, -1, -1, 1, -1 };\nint dy [] = { 1, -1, 1, -1, 1, -1, 0, 0 };\nstring s;\nstring b[2];\nvoid dfs(int i,int msk,int x, int y) {\n if (i == (int) s.size() - 1) {\n cout << b[0] << '\\n';\n cout << b[1] << '\\n';\n exit(0);\n }\n for (int j = 0; j < 8; ++j) {\n int tx = x + dx[j];\n int ty = y + dy[j];\n if (tx > 1 || tx < 0 || ty > 12 || ty < 0) {\n continue;\n }\n if (b[tx][ty] == '*' && (msk & (1 << (s[i + 1] - 'A'))) == 0) {\n b[tx][ty] = s[i + 1];\n dfs(i + 1, msk | (1 << (s[i + 1] - 'A')), tx, ty);\n b[tx][ty] = '*';\n } else if (b[tx][ty] == s[i + 1]) {\n dfs(i + 1, msk, tx, ty);\n }\n }\n}\nint main(){\n cin >> s;\n for (int i = 1; i <(int) s.size(); ++i) {\n if (s[i] == s[i - 1]) {\n cout << \"Impossible\\n\";\n return 0;\n }\n }\n b[0] = b[1] = \"*************\";\n for (int i = 0; i < 13; ++i) {\n b[0][i] = s[0];\n dfs(0,1 << (s[0] - 'A'),0, i);\n b[0][i] = '*';\n b[1][i] = s[0];\n dfs(0,1 << (s[0] - 'A'),1, i);\n b[1][i] = '*';\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "45452587adcda106281fdfa7a2c718a0", "src_uid": "56c5ea443dec7a732802b16aed5b934d", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "\t\t#include \n \t#define s(a) cin >> a;\n\t\t#define s2(a,b) cin >> a>> b;\n\t\t#define s3(a,b,c) cin >> a>> b>> c;\n\t\t#define s4(a,b,c,d) cin >> a>> b>> c<0)\n #define sl(a) a.length()\n #define f(a,b,c) for(a=b;a b;\n #define pb(a,b) a.push_back(b);\n #define ll long long\n\t\t#define mem(a,b) memset(a,b,sizeof(a));\n \n #define diff(a,b) abs(a-b);\n using namespace std;\n #define MOD 1000000007\nint mod(int a,int b) {\n\treturn (a%b<0 ? a%b+b:a%b);\n}\nint getans(string s){\n\tif(s[0]=='f'){\n\t\treturn 1;\n\t}\n\tif(s[0]=='e'){\n\t\treturn 3;\n\t}\n}\n\nusing namespace std;\nint main(){\n\nint i,j,k;\n\tstring s;\n\tcin >> s;\n\tint a[26];\n\tmem(a,-1);\n\tbool flag=false;\n\t\tstring below=\"\";\n\t\tstring up=\"\";\n\n\tint pos1,pos2;\n\tchar arr[2][13];\n\tf(i,0,s.length()){\n\t\tif(a[s[i]-'A']==-1){\n\t\t\ta[s[i]-'A']=i;\n\t\t}\n\t\telse if(i-a[s[i]-'A']>1){\n\t\t\tflag=true;\n\t\t\tpos1=a[s[i]-'A'];\n\t\t\tpos2=i;\n\t\t}\n\t}\n\tif(flag){\n\t\tint temp=pos2-pos1;\n\t\ttemp= temp+1;\n\t\ttemp /=2;\n\t\t// printf(\"temp=%d\\n\",temp );\n\t\ttemp +=pos1;\n\t\tf(i,pos1,temp){\n\t\t\tbelow +=s[i];\n\t\t}\n\t\tf(i,temp,pos2){\n\t\t\tup=s[i]+up;\n\t\t}\n\t\t// printf(\" here \\n\");\n\t\t// cout << up <\r\n#define pb push_back\r\n#define all(a) a.begin(),a.end()\r\n#define alll(a,x) a.begin(),a.end(),x\r\n#define rep(i,a,b) for(int i=(a);i<=(b);i++)\r\n#define nrep(i,a,b) for(int i=(a);i>=(b);i--)\r\n#define pll __builtin_popcount\r\nusing namespace std;\r\nusing ll = long long int ;\r\nusing ull = uint64_t ;\r\nll mi(ll a,ll b,ll p){ ll r=1;while(b){if(1&b)r=r*a%p;a=a*a%p;b>>=1;}return r; }\r\nvoid print(ll n){ if(n<0){putchar('-');n=-n;}if(n>9)print(n/10);putchar(n%10+'0'); }\r\nll read(){\r\n char ch=getchar();\r\n ll f=1,x=0;\r\n while(!isdigit(ch)){ if(ch=='-')f=-1;ch=getchar(); }\r\n while(isdigit(ch)){ x=(x<<3)+(x<<1)+(ch^48);ch=getchar(); }\r\n return x*f;\r\n}\r\nvoid init(){ };\r\nll a,b;\r\nstring fan(ll n){\r\n string s;\r\n while(n){\r\n s+=(char)(n%2+'0');\r\n n>>=1;\r\n }\r\n reverse(all(s));\r\n return s;\r\n}\r\nll fan(string s){\r\n int cnt=0;\r\n ll ans=0;\r\n for(int i=s.size()-1;i>=0;i--)\r\n {\r\n ans+=1LL*(s[i]-'0')<vis;\r\nvoid solve()\r\n{\r\n cin>>a>>b;\r\n priority_queue,less>q;\r\n q.push(a);\r\n while(!q.empty()){\r\n ll u=q.top();q.pop();\r\n if(vis.count(u)||__builtin_popcountll(u)>__builtin_popcountll(b))continue;\r\n vis[u]=true;\r\n if(u==b){\r\n cout<<\"YES\";\r\n exit(0) ;\r\n }\r\n string now=fan(u);\r\n string uu=now+\"1\",vv=now+\"0\";\r\n reverse(all(uu));\r\n reverse(all(vv));\r\n ll x=fan(uu),y=fan(vv);\r\n q.push(x);\r\n q.push(y);\r\n }\r\n cout<<\"NO\";\r\n}\r\n///10 1000\r\nsigned main()\r\n{\r\n //cout<>t;\r\n while(t--){\r\n solve();\r\n }\r\n return 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9ec05b957fb3b496d33cfadec69e0285", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "/**\r\n 2021-12-14\r\n 22:35:04\r\n*/\r\n#pragma comment(linker, \"/STACK:102400000,102400000\")\r\n#pragma GCC optimize (\"O2\")\r\n#include \r\n#define pb push_back\r\n#define all(a) a.begin(),a.end()\r\n#define alll(a,x) a.begin(),a.end(),x\r\n#define rep(i,a,b) for(int i=(a);i<=(b);i++)\r\n#define nrep(i,a,b) for(int i=(a);i>=(b);i--)\r\n#define pll __builtin_popcount\r\nusing namespace std;\r\nusing ll = long long int ;\r\nusing ull = uint64_t ;\r\nll mi(ll a,ll b,ll p){ ll r=1;while(b){if(1&b)r=r*a%p;a=a*a%p;b>>=1;}return r; }\r\nvoid print(ll n){ if(n<0){putchar('-');n=-n;}if(n>9)print(n/10);putchar(n%10+'0'); }\r\nll read(){\r\n char ch=getchar();\r\n ll f=1,x=0;\r\n while(!isdigit(ch)){ if(ch=='-')f=-1;ch=getchar(); }\r\n while(isdigit(ch)){ x=(x<<3)+(x<<1)+(ch^48);ch=getchar(); }\r\n return x*f;\r\n}\r\nvoid init(){ };\r\nll a,b;\r\nstring fan(ll n){\r\n string s;\r\n while(n){\r\n s+=(char)(n%2+'0');\r\n n>>=1;\r\n }\r\n reverse(all(s));\r\n return s;\r\n}\r\nll fan(string s){\r\n int cnt=0;\r\n ll ans=0;\r\n for(int i=s.size()-1;i>=0;i--)\r\n {\r\n ans+=1LL*(s[i]-'0')<vis;\r\nvoid solve()\r\n{\r\n cin>>a>>b;\r\n queueq;\r\n q.push(a);\r\n int cnt=0;\r\n while(!q.empty()){\r\n cnt++;\r\n if(cnt==200)break;\r\n ll u=q.front();q.pop();\r\n if(__builtin_popcountll(u)>__builtin_popcountll(b))continue;\r\n if(u==b){\r\n cout<<\"YES\";\r\n exit(0) ;\r\n }\r\n string now=fan(u);\r\n string uu=now+\"1\",vv=now+\"0\";\r\n reverse(all(uu));\r\n reverse(all(vv));\r\n ll x=fan(uu),y=fan(vv);\r\n if(!vis.count(x))\r\n {\r\n q.push(x);\r\n vis.insert(x);\r\n }\r\n if(!vis.count(y))\r\n {\r\n q.push(y);\r\n vis.insert(y);\r\n }\r\n }\r\n cout<<\"NO\";\r\n}\r\n///10 1000\r\nsigned main()\r\n{\r\n //cout<>t;\r\n while(t--){\r\n solve();\r\n }\r\n return 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cd216fb88905fc76eb23c65d59eb870a", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "/**\r\n 2021-12-14\r\n 22:35:04\r\n*/\r\n//#pragma comment(linker, \"/STACK:102400000,102400000\")\r\n//#pragma GCC optimize (\"O2\")\r\n#include \r\n#define pb push_back\r\n#define all(a) a.begin(),a.end()\r\n#define alll(a,x) a.begin(),a.end(),x\r\n#define rep(i,a,b) for(int i=(a);i<=(b);i++)\r\n#define nrep(i,a,b) for(int i=(a);i>=(b);i--)\r\n#define pll __builtin_popcount\r\nusing namespace std;\r\nusing ll = long long int ;\r\nusing ull = uint64_t ;\r\nll mi(ll a,ll b,ll p){ ll r=1;while(b){if(1&b)r=r*a%p;a=a*a%p;b>>=1;}return r; }\r\nvoid print(ll n){ if(n<0){putchar('-');n=-n;}if(n>9)print(n/10);putchar(n%10+'0'); }\r\nll read(){\r\n char ch=getchar();\r\n ll f=1,x=0;\r\n while(!isdigit(ch)){ if(ch=='-')f=-1;ch=getchar(); }\r\n while(isdigit(ch)){ x=(x<<3)+(x<<1)+(ch^48);ch=getchar(); }\r\n return x*f;\r\n}\r\nvoid init(){ };\r\nll a,b;\r\nstring fan(ll n){\r\n string s;\r\n while(n){\r\n s+=(char)(n%2+'0');\r\n n>>=1;\r\n }\r\n reverse(all(s));\r\n return s;\r\n}\r\nll fan(string s){\r\n int cnt=0;\r\n ll ans=0;\r\n for(int i=s.size()-1;i>=0;i--)\r\n {\r\n ans+=1LL*(s[i]-'0')<vis;\r\nvoid dfs(ll n){\r\n if(vis[n])return ;\r\n vis[n]=true;\r\n if(__builtin_popcountll(n)>__builtin_popcountll(b)){\r\n return ;\r\n }\r\n if(n==b){\r\n cout<<\"YES\";\r\n exit(0);\r\n }\r\n string a=fan(n);\r\n string u=a+\"0\",v=a+\"1\";\r\n reverse(all(u));\r\n reverse(all(v));\r\n ll uu=fan(u),vv=fan(v);\r\n dfs(uu);\r\n dfs(vv);\r\n}\r\nvoid solve()\r\n{\r\n cin>>a>>b;\r\n dfs(a);\r\n cout<<\"NO\";\r\n}\r\n///10 1000\r\nsigned main()\r\n{\r\n //cout<>t;\r\n while(t--){\r\n solve();\r\n }\r\n return 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5c703f1f81b022ca6a90442915a04295", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0} {"lang": "GNU C++17 (64)", "source_code": "#include \r\n#include \r\n#include \r\nusing namespace __gnu_pbds;\r\nusing namespace std;\r\n#define int long long\r\n#define watch(x) cerr << (#x) << \" is \" << (x) << endl;\r\n#define endl '\\n'\r\n#define all(x) (x).begin(), (x).end()\r\n#define sz(a) (int)(a).size()\r\n#define vi vector\r\n#define pii pair\r\n#define fi first\r\n#define se second\r\n#define cerr if(false) cerr\r\n\r\nint x,y;\r\nstring getStr(int num) {\r\n string s;\r\n bool f=false;\r\n for(int i = 62; i >= 0; i--) {\r\n if(num & (1LL << i)) f=true;\r\n if(f) {\r\n bool b = (1LL<> x >> y;\r\n\r\n watch(x)\r\n watch(y)\r\n string s = getStr(x);\r\n string t = getStr(y);\r\n\r\n set S;\r\n queue Q;\r\n\r\n Q.push(s);\r\n S.emplace(s);\r\n\r\n cerr << \"h\" << endl;\r\n while(!Q.empty()) {\r\n string cur = Q.front(); Q.pop();\r\n if(sz(cur) > 10*sz(t)) continue;\r\n watch(cur);\r\n for(int j = 0; j <= 1; j++) {\r\n string nxt = cur;\r\n nxt += (j+'0');\r\n\r\n while(nxt.back() == '0') nxt.pop_back();\r\n reverse(all(nxt));\r\n\r\n if(!S.count(nxt)) {\r\n cerr << cur << \" -> \" << nxt << endl;\r\n S.emplace(nxt);\r\n Q.push(nxt);\r\n }\r\n }\r\n }\r\n\r\n if(S.count(t)) cout << \"YES\" << endl;\r\n else cout << \"NO\" << endl;\r\n}\r\n\r\n/*\r\n\r\nreduce operations:\r\n\r\nwe always remove leading 0\r\nadding 0 and reversing is just reversing\r\n\r\nor we can add 1 and reverse\r\n\r\nso we're always reversing and we have option to add 1\r\n\r\ntake s\r\nis it a substring of t and is everything else 1\r\n\r\n\r\n\r\n\r\n*/", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fefbcd0b27b558f5e52bef0eb5502d66", "src_uid": "9f39a3c160087beb0efab2e3cb510e89", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#pragma optimize(\"\", off)\n#pragma GCC optimize(\"Ofast,no-stack-protector,unroll-loops\")\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n#pragma comment(linker, \"/STACK:36777216\")\n#include \n\n#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n#define ll long long \n#define int ll\n#define all(v) v.begin(),v.end()\n#define pb push_back\n#define sz(i) (int)(i.size())\n#define setto(n) cout << fixed << setprecision(n)\n#define fi first\n#define se second\n#define ld long double\n#define pii pair\n#ifdef ONLINE_JUDGE\n#define endl '\\n'\n#endif\nconst int inf = 0x3f3f3f3f3f3f3f3LL;\nconst int mod = 1e9 + 7;\nusing namespace std;\n\n#ifndef ONLINE_JUDGE\n#define tr(...) __f(#__VA_ARGS__, __VA_ARGS__)\ntemplate \nvoid __f(const char* name, Arg1&& arg1){\n\tcerr << name << \" : \" << arg1 << std::endl;\n}\ntemplate \nvoid __f(const char* names, Arg1&& arg1, Args&&... args){\n\tconst char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << \" : \" << arg1<<\" | \";__f(comma+1, args...);\n}\n#else\n#define tr(...)\n#endif\ntemplate void smin(T& a, T val) {if (a > val) a = val;}\ntemplate void smax(T& a, T val) {if (a < val) a = val;}\ntemplateinline std::ostream &operator << (std::ostream & os,const std::vector& v){bool first = true;os << \"[\";for(auto i: v){if(!first)os << \", \";os << i;first = false;}return os << \"]\";}\n\n//Check N size twiceeeeeeeeeeeeeeeeee, and verify it\nconst int N = 2*1e5 + 10;\n\nint x, y, m;\nint32_t main(){_\n\t\n\tcin>>x>>y>>m;\t\n\n\tqueue > q;\n\tq.push({{x, y}, 0});\n\n\tint op = 0;\n\twhile(!q.empty()){\n\t\tauto it = q.front();\n\t\tint sum = it.fi.fi + it.fi.se;\n\t\tq.pop();\n\t\t// tr(it.fi, it.se, op);\n\t\tint tt = max(it.fi.fi, it.fi.se);\n\t\tif(tt >= m){\n\t\t\tcout<= 1e5){\n\t\t\tcout<<-1;\n\t\t\treturn 0;\n\t\t}\n\t\tq.push({{sum, y}, it.se+1});\n\t\tq.push({{y, sum}, it.se+1});\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "901048a5898fba5832a1cef71046631d", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{ long long ans; ans=0;\n long long x,y,m;\n cin>>x>>y>>m;\n while (((x\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define pp system(\"pause\");\n#define ct double ttme = clock()\n#define p_ct cout << (clock() - ttme) / CLOCKS_PER_SEC << endl\n#define all(c) (c).begin(),(c).end()\n#define fft ifstream fin(\"input.txt\"); ofstream fout(\"output.txt\")\n#define fft_c FILE *fin, *fout\n#define fft_c_open fin = fopen(\"input.txt\",\"r\"); fout = fopen(\"output.txt\",\"w\")\n#define fft_c_cl fclose(fin); fclose(fout)\n#define pii pair\n#define mp(a,b) make_pair((a),(b))\n#define pff pair\n#define piii pair>\n#define pss pair\n#define M_PI 3.14159265358979323846\n#define mem0(m) memset((m), 0, sizeof(m));\n#define memb(m) memset((m), false, sizeof(m));\n#define memi(m) memset((m), 0, sizeof(m));\n#define rep(i,n) for(i = 0; i < (int)(n); i++)\n#define repi(a, n) for(int i = a; i < (int)(n); i++)\n#define repp(i, a, n) for(int (i) = a; (i) < (int)(n); (i)++)\ntypedef unsigned long long int ull;\ntypedef signed long long int ll;\nconst int INF = 1e8;\nconst int DEL = 687134561;\nconst long long MODULO = 1e9 + 7;\nconst int MAX = 1e7;\nconst int des = 10000;\n\n\n\nint main()\n{\n ll x, y, m;\n cin >> x >> y >> m;\n\n Sleep(10000);\n\n ll ans = 0, eba = 0;\n\n if(x <= 0 && y <= 0 && m > x && m > y) {\n cout << -1;\n return 0;\n } else if(x >= m || y >= m) {\n cout << 0;\n return 0;\n }\n\n while(x < m && y < m) {\n eba++;\n if(x > y) {\n ll xx = (x == 0) ? 1 : x;\n ll plus = max(0LL - ((ll)(y / xx)), 1LL);\n ans += plus;\n y += plus * x;\n } else {\n ll yy = (y == 0) ? 1 : y;\n ll plus = max(0LL - ((ll)(x / yy)), 1LL);\n ans += plus;\n x += plus * y;\n }\n\n if(eba > 10000000) {\n cout << -1;\n return 0;\n }\n }\n\n cout << ans;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bde566ccdd359106c61ef596050b25bd", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{ long long ans; ans=0;\n long long x,y,m;\n cin>>x>>y>>m;\n while (((x\n#include\n\nint dp[501][501][501];\nint n,m,b,mod;\nint a[527];\n\nint main()\n{\n int i,j,k,t,ans;\n while(scanf(\"%d%d%d%d\",&n,&m,&b,&mod)!=EOF)\n {\n memset(dp,0,sizeof(dp));\n for(i=1;i<=n;i++) scanf(\"%d\",&a[i]);\n for(k=0;k<=m;k++)\n {\n if(k*a[1]<=b)\n {\n dp[1][k*a[1]][k]=1;\n }\n }\n for(i=1;ib) continue;\n dp[i+1][j+t*a[i+1]][k+t]+=dp[i][j][k];\n }\n }\n }\n }\n ans=0;\n for(j=0;j<=b;j++) ans+=dp[n][j][m];\n printf(\"%d\\n\",(ans%mod));\n }\n}\n\n\n ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7999defe641f3b8b4892a9eabd84ff90", "src_uid": "c1b071f09ef375f19031ce99d10e90ab", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include \n#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n#define int long long\n#define pb push_back\n#define sz(i) (int)(i.size())\n#define F first\n#define S second\n#define L long double\n#define P pair\nconst int inf = 0x3f3f3f3f3f3f3f3LL;\nconst int mod = (int)1e9 + 7;\nusing namespace std;\n#if LOCAL\n#include \"../../tr.h\"\n#else\n#define tr(...)\n#define endl '\\n'\n#endif\ntemplate void smin(T& a, T val) {if (a > val) a = val;}template void smax(T& a, T val) {if (a < val) a = val;}\nconst int N = 5*(int)1e5 + 10;\n\nint k;\nstring s;\n\nint32_t main(){_\n \n cin >> k >> s; \n int n = sz(s);\n\n string ans = \"\";\n\n vector vec;\n\n for (int i = 0; i < n; )\n {\n int j = i;\n string ans = \"\";\n while(j < n and s[i] == s[j]){\n ans += s[j];\n }\n i = j;\n --k;\n if(k == 0){\n for (int x = j; x < n; ++x)\n ans += s[x];\n }\n vec.push_back(ans);\n if(k == 0)\n break;\n }\n\n if(sz(vec) == k){\n cout<<\"YES\"<\n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint fu[200]={0};\nint xu[110];\nint main()\n{\n char q[110];\n\t\n int lenq,n,k,i,j;\n scanf(\"%d\",&n);\n getchar();\n scanf(\"%s\",q);\n lenq=strlen(q);\n k=0;\n if(lenq>=n)\n {\n\t\tj=1;k=1;\n\t\tfu[q[0]]++;\n\t\txu[0]=0;\n\t\tfor(i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\nvector ans;\nint main()\n{\n int k;\n string q;\n cin >> k;\n cin >> q;\n if (q.size() < k + 1)\n {\n cout << \"NO\";\n }\n else\n {\n int i = 0;\n string a=\"\";\n while (ans.size() != k && i < q.size())\n {\n bool f = true;\n for (int j = 0; j < ans.size(); j++)\n {\n if (ans[j][0] == q[i])\n {\n f = 0;\n }\n }\n if (f)\n {\n a += q[i];\n ans.push_back(a);\n a = \"\";\n }\n else\n {\n ans[ans.size() - 1] += q[i];\n }\n \n i++;\n }\n \n if (ans.size() == k )\n {\n a = \"\";\n for (; i < q.size(); i++)\n {\n a += q[i];\n }\n ans[k - 1] += a;\n cout << \"YES\" << endl;\n for (int j = 0; j < ans.size(); j++)\n {\n cout << ans[j] << endl;\n }\n }\n else\n {\n cout << \"NO\";\n }\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "22a3f23557647c01403840b59f46dfd2", "src_uid": "c1b071f09ef375f19031ce99d10e90ab", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std ;\n\nint main()\n{\n int a1 , a2 , a3 , a4 , a5 , a6 ;\n cin >> a1 >> a2 >> a3 >> a4 >> a5 >> a6 ;\n \n int res = 0 ;\n \n for ( int i = 0 ; i < a2 ; i++ )\n res += 2 * ( a1 + i ) + 1 ;\n \n for ( int i = 0 ; i < a3 ; i++ )\n res += 2 * ( a4 + i ) + 1 ; \n \n cout << res ;\n \n getch() ;\n return 0 ;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "73074a2fb7f0d752f0472a90a3ff9405", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\n#define ios ios_base::sync_with_stdio(false)\n\nint main() {\n// freopen(\"input.txt\", \"r\", stdin);\n ios;\n double a1, a2, a3, a4, a5, a6;\n while (cin >> a1 >> a2 >> a3 >> a4 >> a5 >> a6) {\n double ans = (a3 / 2 + a5 / 2 + a4) * (a2 * sqrt(3) / 2 + a3 * sqrt(3) / 2);\n ans -= sqrt(3) / 8 * (a2 * a2 + a3 * a3 + a5 * a5 + a6 * a6);\n cout << ans * 4 / sqrt(3) << endl;\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "33e6e2fac7a04028adcb48a617d6fa82", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\ntypedef long long ll;\n\n\nint main(){\n ios::sync_with_stdio(0);\n int a[6];\n double b[3];\n for(int i=0;i<6;i++)cin>>a[i];\n int ans=0;\n for(int i=0;i<6;i+=2)ans+=a[i]*a[i+1];\n //cout<\n#include \n\nusing namespace std;\nint a1, a2, a3, a4, a5, a6;\ndouble b1, b2, b3;\nint main() {\n\n\tcin >> a1 >> a2 >> a3 >> a4 >> a5 >> a6;\n\tdouble ans = 0;\n\tans += a1*a2;\n\tans += a3*a4;\n\tans += a5*a6;\n\n\tb1 = sqrt(a1*a1 + a2 * a2 +(double(a1*a2)));\n\tb2 = sqrt(a3*a3 + a4 * a4 + (double(a3*a4)));\n\tb3 = sqrt(a5*a5 + a6 * a6 + (double(a5*a6)));\n\tdouble p = (b1 + b2 + b3) / 2;\n\tdouble s = sqrt(p*(p - b1)*(p - b2)*(p - b3));\n\tans += (s*4)/ sqrt(3);\n\tcout << ans;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "aeb629fe78d84a110b1dd7181ca1c2d1", "src_uid": "382475475427f0e76c6b4ac6e7a02e21", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include \n#define MAX 100000\nusing namespace std;\ntypedef unsigned long long ull;\ntypedef vector vi;\n\n\nvector primes;\nint prime[MAX];\nvoid seive(){\n for(int p=2;p*p<=MAX;p++){\n if(prime[p]){\n primes.push_back(p);\n for(int j = p*p;j<=MAX;j+=p){\n prime[j] = false;\n }\n } \n }\n return ;\n}\n\n\n\nint main() {\n for(int i=0;i>x>>y>>k;\n int numl = lower_bound(primes.begin(),primes.end(),x)-primes.begin();\n int numr = lower_bound(primes.begin(),primes.end(),y)-primes.begin();\n int answer = primes[numl]-x+1;\n int j;\n for(j = numl; primes[j+k] <= y;j++){\n int n = j+k;\n answer = max(answer,primes[n]-primes[j]);\n }\n answer = max(answer,y-primes[j]+1);\n if(numr-numl < k) answer = -1;\n\tcout<\n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\nint a[11111111];\nint p[1000009];\nvoid build(int n0,int n,int i){\n if(n0==n){\n a[i]=p[n];\n return;\n }\n int m=(n0+n)>>1;\n build(n0,m,2*i);\n build(m+1,n,2*i+1);\n a[i]=a[2*i]+a[2*i+1];\n }\nint query(int n0,int n,int i,int aa,int b){//printf(\"%d %d %d %d %d\\n\",n0,n,i,aa,b);\n if(n0>=aa&&n<=b)\n return a[i];\n int m=(n0+n)>>1;\n if(b<=m)\n return query(n0,m,2*i,aa,b);\n if(aa>m)\n return query(m+1,n,2*i+1,aa,b);\n return query(n0,m,2*i,aa,m)+query(m+1,n,2*i+1,m+1,b);\n }\nint ff(int n0,int n,int k,int a,int b){//printf(\"%d %d\\n\",n0,n);\n int i,j,t;\n int m;\n if((n/n0)>=10)\n m=(int)sqrt((double)(n0*n));\n else\n m=(n0+n)>>1;\n t=1;\n for(j=b-m+1;j>=a;j--){\n if(b-m+1-j>100)\n break;\n if(query(a,b,1,j,j+m-1)\nusing namespace std;\ntypedef long long ll;\nll a,b,k,ans=-1,isSNT[100000005],l,r,mid;\nvoid sang(){\n\tfor(ll i=0;i<100000005;i++){\n\t\tisSNT[i]=1;\n\t}\n\tisSNT[0]=0;\n\tisSNT[1]=0;\n\tfor(ll i=2;i<100000005;i++){\n\t\tif(isSNT[i]==1){\n\t\t\tfor(ll j=i*i;j<100000005;j+=i){\n\t\t\t\tisSNT[j]=0;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\tfor(ll i=1;i<100000005;i++){\n\t\tisSNT[i]+=isSNT[i-1];\n\t}\n}\nint check(ll mid){\n\tll v=r;\n\tfor(ll i=a;i<=b-mid+1;i++){\n\t\tv=min(v,isSNT[i+mid-1]-isSNT[i-1]);\n\t}\n\tif(v>a>>b>>k;\n\tsang();\n\tl=1;\n\tr=b-a+1;\n\twhile(l<=r){\n\t\t mid=(l+r)/2;\n\t\tif(check(mid)){\n\t\t\tans=mid;\n\t\t\tr=mid-1;\n\t\t}\n\t\telse l=mid+1;\n\t}\n\tcout<\n#include\n#include\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define M 1000005\n#define Mod 1000000007\n#define For(i,a,b) for(int i=(a);i<(b);i++)\n#define inf (1<<30)-1\n#define eps 1e-8\nusing namespace std;\nint p[80005];\nint tag[M];\nint cnt;\nint a, b, k;\n\nvoid get_prime() {\n cnt = 0;\n for (int i = 2; i < M; i++) {\n if (!tag[i]) p[cnt++] = i;\n for (int j = 0; j < cnt && p[j] * i < M; j++) {\n tag[i * p[j]] = 1;\n if (i % p[j] == 0)\n break;\n }\n }\n}\n\n//bool judge(int x) {\n// For(i,)\n//}\n\nint main(int argc, char** argv) {\n get_prime();\n cin >> a >> b >> k;\n int u, v;\n\n For(i, 0, cnt) {\n if (p[i] >= a) {\n u = i;\n break;\n }\n }\n\n For(i, 0, cnt) {\n if (p[i] > b) {\n v = i;\n break;\n }\n }\n int num = v - u;\n if (num < k) {\n printf(\"-1\\n\");\n return 0;\n }\n if (k == 0) {\n printf(\"0\\n\");\n return 0;\n }\n int ans = -1;\n // if(b==p[u+k-1])\n if (p[u] != a)\n ans = max(ans, (min(b, p[u + k - 1]) - a + 1));\n else\n ans = max(ans, (min(b, p[u + k - 1]) - a));\n // else{\n //\n // }\n if (p[v - 1] == b) {\n ans = max(ans, b - max(a, p[max(0, v - 1 - k)]));\n } else\n ans = max(ans, 1 + b - max(a, p[max(0, v - 1 - k)]));\n for (int i = u; i + k < v; i++) {\n ans = max(ans, p[i + k] - p[i]);\n }\n printf(\"%d\\n\", ans);\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9296e613c6be991266a05d8ddd3ceefc", "src_uid": "3e1751a2990134f2132d743afe02a10e", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include\n#include\nusing namespace std;\nint main()\n{\n string s1;\n string s2;\n cin>>s1;\n cin>>s2;\n for(int i=0;is2)\n cout<<\"1\";\n else\n cout<<\"-1\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b662e214a31b79d04f3d5119a51bf5b6", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\n#include\nusing namespace std;\nint main()\n{\n string s1;\n string s2;\n cin>>s1>>s2;\n for(int i=0;is2)\n cout<<\"1\";\n else\n cout<<\"-1\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4a3b77433c3b9a7efc846f91a989f9fa", "src_uid": "ffeae332696a901813677bd1033cf01e", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n\tstring a, b;\n\tcin >> a;\n\tcin >> b;\n\tfor (unsigned int i = 0; i<=a.size(); i++)\n\t{\n\t if(a[i]<'a')\n {\n a+=32;\n }\n if(b[i]<'a')\n {\n b+=32;\n }\n\t}\n\tif(a\n#include \nusing namespace std;\n\nint main()\n{\n\tstring a, b;\n\tcin >> a;\n\tcin >> b;\n\tfor (int i = 0; i<=a.size(); i++)\n\t{\n\t if(a[i]<'a')\n {\n a+=32;\n }\n if(b[i]<'a')\n {\n b+=32;\n }\n\t}\n\tif(a\nusing namespace std;\n\ntypedef long long int ll;\ntypedef unsigned long long int ull;\n\null check_bit(ull N,int POS){return (N & (1ULL<v;\null gaussian_elimination()\n{\n int long long n=v.size();\n int long long ind=0; // Array index\n for(int long long bit=log2(v[0]);bit>=0;bit--)\n {\n int long long x=ind;\n while(x>n>>k;\n ull x;\n for(i=0;i\nusing namespace std;\ntypedef long long int Int;\nint main(){\nInt n,k;\ncin>>n>>k;\nif(k==1){\n cout< m;\nInt ans=n;\nInt mans=n;\nInt selected=1;\nInt bit=0;\nInt temp=ans;\nm[n]=1;\nwhile(temp>0){\n temp=temp>>1;\n bit++;\n}\nbit=bit-2;\nInt last=n-1;\nwhile(selected=0&&((temp>>bit)&1)==1){\n bit--;\n temp=ans;\n}\nif(bit>=0){\n bool done=false;\n while(!done){\n if(bit>=0){\n while(last>0&&(m[last]==1||((last>>bit)&1==0))){\n last--;\n }\n if(last>0){\n ans=ans^last;\n if(ans>mans){\n mans=max(ans,mans);\n last--;\n done=true;\n selected++;\n m[last]=1;\n last=n-1;\n bit--;\n }else{\n ans=mans;\n last--;\n }\n }else{\n last=n-1;\n bit--;\n }\n }else{\n cout<\nusing namespace std;\n\ntypedef long long int ll;\ntypedef unsigned long long int ull;\n\null check_bit(ull N,int POS){return (N & (1ULL<v;\null gaussian_elimination()\n{\n int n=v.size();\n int ind=0; // Array index\n for(int bit=log2(v[0]);bit>=0;bit--)\n {\n int x=ind;\n while(x>n>>k;\n ull x;\n for(i=0;i\n#define pb push_back\n#define ll long long\n#define mp make_pair\n#define pu push\n#define po pop\n#define N 100005\n#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));\nusing namespace std;\nunsigned ll n,k,x,i;\nvector v;\nint main(void){\n\tcin>>n>>k;\n\tx=log2(n);\n\t\n\tfor(i=x;i>=0;i--){\n\t\t\n\t\tif(!(n&((ll)1<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include \n#include \n#include \n#include \n#include \n#define ll long long\n#define ull unsigned long long\n#define LB lower_bound\n#define UB upper_bound\n#define pll pair\n#define pb push_back\n#define mp make_pair\n#define f first\n#define s second\n#define sc2(x,y) scanf(\"%d%d\",&x,&y)\n#define sc3(x,y,z) scanf(\"%d%d%d\",&x,&y,&z)\n#define si(a)\t\t\tscanf(\"%d\", &a)\n#define sl(a)\t\t\tscanf(\"%lld\", &a)\n#define pi(a)\t\t\tprintf(\"%d\", a)\n#define pl(a)\t\t\tprintf(\"%lld\", a)\n#define pn \t\t\t\tprintf(\"\\n\")\nusing namespace std;\n//Convert int to string\ntemplate \nstring to_str(T str)\n{\n stringstream stream;\n stream << str;\n return stream.str();\n}\n\n//Convert string to int\ntemplate \nint to_int(T num)\n{\n int val;\n stringstream stream;\n stream << num;\n stream >> val;\n return val;\n}\n// to reverse integer\nint Reverse(int val)\n{\nint rev=0,rem;\nwhile(val!=0)\n\n{rem=val%10; rev=rev*10+rem; val/=10;}\n return rev;\n}\nint gcd(int a, int b) {\n return b == 0 ? a : gcd(b, a % b);\n}\n\nint main()\n{\n double l1,r1,l2,r2,k,n1,n2,n3,x,mycount,counter=0,g,j=0;\n cin>>l1>>r1>>l2>>r2>>k;\n if(l1==l2&&r1==r2)cout<v;\n for(int i=l1;i<=r1;i++)if(i!=k)v.push_back(i);\n for(int i=l2;i<=r2;i++)if(i!=k)v.push_back(i);\n while(j!=v.size())\n {\n g=v[j];\n mycount = count (v.begin(),v.end(), g);\n if(mycount>1&&v[j]!=0.1){v[j]=0.1;counter++;}\n j++;\n\n }\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include \n#include \n#include \n#include \n#include \n#define ll long long\n#define ull unsigned long long\n#define LB lower_bound\n#define UB upper_bound\n#define pll pair\n#define pb push_back\n#define mp make_pair\n#define f first\n#define s second\n#define sc2(x,y) scanf(\"%d%d\",&x,&y)\n#define sc3(x,y,z) scanf(\"%d%d%d\",&x,&y,&z)\n#define si(a)\t\t\tscanf(\"%d\", &a)\n#define sl(a)\t\t\tscanf(\"%lld\", &a)\n#define pi(a)\t\t\tprintf(\"%d\", a)\n#define pl(a)\t\t\tprintf(\"%lld\", a)\n#define pn \t\t\t\tprintf(\"\\n\")\nusing namespace std;\n//Convert int to string\ntemplate \nstring to_str(T str)\n{\n stringstream stream;\n stream << str;\n return stream.str();\n}\n\n//Convert string to int\ntemplate \nint to_int(T num)\n{\n int val;\n stringstream stream;\n stream << num;\n stream >> val;\n return val;\n}\n// to reverse integer\nint Reverse(int val)\n{\nint rev=0,rem;\nwhile(val!=0)\n\n{rem=val%10; rev=rev*10+rem; val/=10;}\n return rev;\n}\nint gcd(int a, int b) {\n return b == 0 ? a : gcd(b, a % b);\n}\n\nint main()\n{\n long long l1,r1,l2,r2,k,n1,n2,n3,x,mycount,counter=0,g,j=0;\n cin>>l1>>r1>>l2>>r2>>k;\n if(l1==l2&&r1==r2)cout<v;\n for(int i=l1;i<=r1;i++)if(i!=k)v.push_back(i);\n for(int i=l2;i<=r2;i++)\n {\n if(i!=k)v.push_back(i);\n g=i;\n mycount = count (v.begin(),v.end(), g);\n if(mycount>1&&v[j]!=0.1)counter++;\n }\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include \n#include \n#include \n#include \n#include \n#define ll long long\n#define ull unsigned long long\n#define LB lower_bound\n#define UB upper_bound\n#define pll pair\n#define pb push_back\n#define mp make_pair\n#define f first\n#define s second\n#define sc2(x,y) scanf(\"%d%d\",&x,&y)\n#define sc3(x,y,z) scanf(\"%d%d%d\",&x,&y,&z)\n#define si(a)\t\t\tscanf(\"%d\", &a)\n#define sl(a)\t\t\tscanf(\"%lld\", &a)\n#define pi(a)\t\t\tprintf(\"%d\", a)\n#define pl(a)\t\t\tprintf(\"%lld\", a)\n#define pn \t\t\t\tprintf(\"\\n\")\nusing namespace std;\n//Convert int to string\ntemplate \nstring to_str(T str)\n{\n stringstream stream;\n stream << str;\n return stream.str();\n}\n\n//Convert string to int\ntemplate \nint to_int(T num)\n{\n int val;\n stringstream stream;\n stream << num;\n stream >> val;\n return val;\n}\n// to reverse integer\nint Reverse(int val)\n{\nint rev=0,rem;\nwhile(val!=0)\n\n{rem=val%10; rev=rev*10+rem; val/=10;}\n return rev;\n}\nint gcd(int a, int b) {\n return b == 0 ? a : gcd(b, a % b);\n}\n\nint main()\n{\n double l1,r1,l2,r2,k,n1,n2,n3,x,mycount,counter=0,g,j=0;\n cin>>l1>>r1>>l2>>r2>>k;\n vectorv;\n for(int i=l1;i<=r1;i++)if(i!=k)v.push_back(i);\n for(int i=l2;i<=r2;i++)if(i!=k)v.push_back(i);\n while(j!=v.size())\n {\n g=v[j];\n mycount = count (v.begin(),v.end(), g);\n if(mycount>1&&v[j]!=0.1){v[j]=0.1;counter++;}\n j++;\n\n }\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include \n#include \n#include \n#include \n#include \n#define ll long long\n#define ull unsigned long long\n#define LB lower_bound\n#define UB upper_bound\n#define pll pair\n#define pb push_back\n#define mp make_pair\n#define f first\n#define s second\n#define sc2(x,y) scanf(\"%d%d\",&x,&y)\n#define sc3(x,y,z) scanf(\"%d%d%d\",&x,&y,&z)\n#define si(a)\t\t\tscanf(\"%d\", &a)\n#define sl(a)\t\t\tscanf(\"%lld\", &a)\n#define pi(a)\t\t\tprintf(\"%d\", a)\n#define pl(a)\t\t\tprintf(\"%lld\", a)\n#define pn \t\t\t\tprintf(\"\\n\")\nusing namespace std;\n//Convert int to string\ntemplate \nstring to_str(T str)\n{\n stringstream stream;\n stream << str;\n return stream.str();\n}\n\n//Convert string to int\ntemplate \nint to_int(T num)\n{\n int val;\n stringstream stream;\n stream << num;\n stream >> val;\n return val;\n}\n// to reverse integer\nint Reverse(int val)\n{\nint rev=0,rem;\nwhile(val!=0)\n\n{rem=val%10; rev=rev*10+rem; val/=10;}\n return rev;\n}\nint gcd(int a, int b) {\n return b == 0 ? a : gcd(b, a % b);\n}\n\nint main()\n{\n long long l1,r1,l2,r2,k,n1,n2,n3,x,mycount,counter=0,g,j=0;\n cin>>l1>>r1>>l2>>r2>>k;\n if(l1==l2&&r1==r2)cout<v;\n for(int i=l1;i<=r1;i++)if(i!=k)v.push_back(i);\n for(int i=l2;i<=r2;i++)\n {\n if(i!=k)v.push_back(i);\n g=i;\n mycount = count (v.begin(),v.end(), g);\n if(mycount>1&&v[j]!=0.1)counter++;\n if(i!=k)v.pop_back();\n }\n cout<\n using namespace std;\n int main()\n {\n /*freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);*/\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n long long n;\n long long k;\n long long ans = 1;\n long long res;\n long long a[100];\n string s;\n cin >> s;\n n = s.length();\n for(int i = 0; i < n; i++)\n if(s[i] >= 'A' && s[i] <= 'Z' && !a[s[i] - 'A' + 1])\n {\n k++;\n a[s[i] - 'A' + 1] = 1;\n }\n for(int i = 0; i < n; i++)\n {\n if(s[i] == '?')\n ans *= 10;\n\n }\n\t for(int i = 10; i >= 10 - k + 1; i--)\n\t \tans *= i;\n\t if((s[0] >= 'A' && s[0] <= 'Z' )|| (s[0] == '?'))\n\t \tans -= ans / 10;\n\t cout << ans << endl;\n return 0;\n }\n //s[i].size()\n //a=tolower(a) \u0434\u0435\u043b\u0430\u0435\u0442 char \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e a \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439,\n//a=toupper(a), \u0434\u0435\u043b\u0430\u0435\u0442 char \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e a \u0431\u043e\u043b\u044c\u0448\u043e\u0439\n/*\n\n /* %\u0441 \u2013 \u043e\u0434\u0438\u043d\u043e\u0447\u043d\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b\n %d \u2013 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0441\u043e \u0437\u043d\u0430\u043a\u043e\u043c\n %f \u2013 \u0447\u0438\u0441\u043b\u043e \u0441 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 (\u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435)\n %s \u2013 \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 (\u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445)\n %u \u2013 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0431\u0435\u0437 \u0437\u043d\u0430\u043a\u0430\n %% - \u043f\u0435\u0447\u0430\u0442\u044c \u0437\u043d\u0430\u043a\u0430 \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u0430\n printf(\u201c\u0412\u0430\u0448 \u0432\u043e\u0437\u0440\u0430\u0441\u0442 = %d, \u0412\u0430\u0448 \u0432\u0435\u0441 = %f\u201d, age, weigth);\n */\n\n/* if((j=abs(i-n/2))\n {\n cout << \"D\";\n }\n else\n {\n cout << \"*\";\n }*/\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6ac871188df3be9d482cec662551e0ed", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#ifdef LOCALHOST\n#include \n#endif // LOCALHOST\n\nusing namespace std;\n\n#ifndef OMG\ntypedef unsigned\t\t\tu;\ntypedef int\t\t\t\t\ti;\ntypedef long\t\t\t\tl;\ntypedef long long\t\t\tll;\ntypedef unsigned long long\tull;\ntypedef char\t\t\t\tc;\n#define b\t\t\t\t\tbegin()\n#define e\t\t\t\t\tend()\n#define rb\t\t\t\t\trbegin()\n#define re\t\t\t\t\trend()\n#define mp\t\t\t\t\tmake_pair\n#define r\t\t\t\t\treturn\n#define sc\t\t\t\t\tstatic_cast\n#define v\t\t\t\t\tvector\n#define s\t\t\t\t\tset\n#define _it\t\t\t\t\titerator\n#define _cit\t\t\t\tconst_iterator\n#define _rit\t\t\t\treverse_iterator\n#define _crit\t\t\t\tconst_reverse_iterator\n#define f\t\t\t\t\tfor\n#define w\t\t\t\t\twhile\n#define cp\t\t\t\t\tstd::copy\n#define oi\t\t\t\t\tstd::ostream_iterator\n#endif // OMG\n\ntemplate\nT fm(T number, T module)\n{\n\tT result = 1;\n\twhile(number > 1)\n\t{\n\t\tresult = (result * ((number / module) % 2 ? module - 1 : 1)) % module;\n\t\tfor(T it = 2\n\t\t\t; it <= (number % module)\n\t\t\t; ++it)\n\t\t{\n\t\t\tresult = (result * it) % module;\n\t\t}\n\t\tnumber /= module;\n\t}\n\treturn result % module;\n}\n\n//class sort1\n//{\n//public:\n//\tbool operator() (pair<,> X, pair<,> Y)\n//\t{\n\n//\t}\n//};\n\n#ifdef LOCALHOST\nstd::ifstream in(\"1.in\", std::ifstream::in);\n#endif // LOCALHOST\n\n#ifdef LOCALHOST\n#define is in\n#else\n#define is cin\n#endif // LOCALHOST\n\nll my_pow(ll value, unsigned st)\n{\n\tf(u it(1); it != st; ++it)\n\t{\n\t\tvalue *= value;\n\t}\n\treturn value;\n}\n\nint main(int argc, char *argv[])\n{\n\tstd::ios_base::sync_with_stdio(false);\n\tstring input;\n\tgetline(cin, input);\n\tunsigned unknow(0);\n\tmap letters;\n\tbool front_unk(false), front_letter(false);\n\tf(u it(0); it != input.size(); ++it)\n\t{\n\t\tif(input[it] == '?')\n\t\t{\n\t\t\t++unknow;\n\t\t\tif(!it)\n\t\t\t{\n\t\t\t\tfront_unk = true;\n\t\t\t}\n\t\t} else if(isalpha(input[it]))\n\t\t{\n\t\t\t++letters[input[it]];\n\t\t\tif(!it)\n\t\t\t{\n\t\t\t\tfront_letter = true;\n\t\t\t}\n\t\t}\n\t}\n\tunsigned answer(1);\n\tif(unknow)\n\t{\n\t\tif(front_unk)\n\t\t{\n\t\t\tanswer = my_pow(10, unknow - 1);\n\t\t\tanswer *= 9;\n\t\t} else\n\t\t{\n\t\t\tanswer = my_pow(10, unknow);\n\t\t}\n\t}\n//\tcout << \"fu \" << front_unk << endl;\n//\tcout << \"fl \" << front_letter << endl;\n//\tcout << \"after unk \" << answer << endl;\n\tif(letters.size())\n\t{\n\t\tif(front_letter)\n\t\t{\n\t\t\tanswer *= 9;\n\t\t\tint all(9);\n\t\t\tfor(u it(0); it < letters.size() - 1; ++it, --all)\n\t\t\t{\n\t\t\t\tanswer *= all;\n\t\t\t}\n\t\t} else\n\t\t{\n\t\t\tint all(10);\n\t\t\tfor(u it(0); it < letters.size(); ++it, --all)\n\t\t\t{\n\t\t\t\tanswer *= all;\n\t\t\t}\n\t\t}\n\t}\n\tcout << answer;\n\tr 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ce831ad680e385ca4325916a060fb170", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nchar str[101000];\nint main(){\n\tfgets(str,100999,stdin);\n\tint i = 0;\n\twhile(!(str[i]=='\\n'||str[i]=='/0')){\n\t\tif(str[i]=='?')putchar('1');\n\t\telse if(str[i]<='J'&&str[i]>='A')putchar(str[i]-'A'+'0');\n\t\telse putchar(str[i]);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "085b23ded4660419b77bbb4a9002efd7", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\ntypedef long long int lli;\n#define f(i, x, n);for(lli i = x;i < n;i++)\n\nint main()\n{\n\tstring s;\n\tcin >> s;\n\tint l = s.length();\n\tint x = 1, c = 0;\n\tchar f;\n\tif(s[0] >= 63)\n\t{\n\t\tx *= 9;\n\t\tf = s[0];\n\t\tif(s[0] > 63)\n\t\t{\n\t\t\tc = 1;\n\t\t}\n\t}\n\ts.erase(s.begin());\n\tl--;\t\n\tsort(s.begin(), s.end());\n\tf(i, 0, s.length()-1)\n\t{\n\t\tif(s[i] == 63)\n\t\t{\n\t\t\tx *= 10;\n\t\t\ts.erase(s.begin() + i);\n\t\t}\n\t\telse if(s[i] == s[i+1] || s[i] == f)\n\t\t{\n\t\t\ts.erase(s.begin() + (i)); \n\t\t}\n\t\telse if(s[i] < 58)\n\t\t{\n\t\t\ts.erase(s.begin() + i);\n\t\t}\n\t\ti = -1;\n\t}\n\tint t;\n\tif(c == 0)\n\tt = 10;\n\telse\n\tt = 9;\n\tf(i, 0, s.length())\n\t{\n\t\tx *= t;\n\t\tt--;\n\t}\n\tcout << x;\n\t\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "239db2242945ed8144fc5b9bac932e15", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "//In the name of God\n\n#include \n#include \n#include \nusing namespace std;\n#define lol long long\nbool can=false;\nlol p[40];\nmap c;\nvector v;\n\nlol calc(lol bit)\n{\n lol ans=0;\n for(int i=0;i<=20;i++)\n if(bit&(1<>n>>m;\n int k=0;\n p[0]=1;\n for(int i=1;p[i-1]<=1e12 and i<=20;i++)\n p[i]=p[i-1]*n,k=i;\n k++;\n //v.push_back(0);\n //c[0]=true;\n for(lol i=0;i<(1<<20);i++)\n {\n lol x=calc(i);\n c[x]=true;\n // cerr<>y;\n v.push_back(x);\n }\n \n for(int i=0;i\n#include \n#include \nusing namespace std;\n\nint w, m;\nint pw[10000];\nint s[1000000];\n\n\nint main()\n{\n cin >> w >> m;\n int i = 0;\n while (m != 0)\n {\n s[i++] = m%w;\n m /= w;\n }\n int n = i;\n for (int i = 0; i < n; ++i)\n {\n if (s[i] == 0) continue;\n if (s[i] == 1) continue;\n else if (s[i] == w-1) s[i+1]++;\n else {cout << \"NO\"; return 0;}\n }\n cout << \"YES\" << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6ba212166fd78fb12960b5d0bec1b1bb", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n//#include \"algo_templates/AdvancedMath.cpp\"\n\nusing namespace std;\n\n#pragma comment(linker, \"/STACK:36777216\")\n\n#define For(i,l,r) for (int i = l; i < r + 1; i ++)\n#define ForI(it , s , T) for (T :: iterator it = s.begin(); it != s.end() ; ++ it )\n#define LL long long\n#define iinf 2000000000\n#define linf 4000000000000000000LL\n#define MOD (1000000007)\n#define Pi 3.1415926535897932384\n#define bit(mask,i) ((mask>>i)&1)\n#define pb(x) push_back(x)\n#define mk(x,y) make_pair(x,y)\n#define sqr(x) ((x)*(x))\n#define pause cin.get();cin.get();\n#define fir first\n#define sec second\n#define ln(x) log(x)\n#define pii pair\n#define log log24\n\nconst int Nmax = 200100;\nconst int Direction[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};\n\n\ntemplate \nlong long BinPower(T1 basis, T2 degree)\n{\n long long answer = 1;\n long long __basis = basis;\n for (;degree > 0;degree>>=1)\n {\n if (degree&1) answer *= __basis;\n __basis*=__basis;\n }\n return answer;\n}\nvector list;\n\nint main() {\n ios_base::sync_with_stdio(0);\n long long w,m;\n cin >> w >> m;\n \n if (w <= 3) {\n cout << \"YES\\n\";\n return 0;\n }\n \n vector bin(10000,0);\n for (LL d = m, i = 0; d > 0; d /= w,i ++) \n bin[i] = (d % w);\n bin.resize(10000);\n for (int i = 0 ;i < bin.size(); i ++) {\n if (bin[i] == 1 || bin[i] == 0) continue;\n if (bin[i] == w - 1) {\n bin[i] = -1;\n bin[i + 1] ++;\n }\n else {\n cout << \"NO\\n\";\n return 0;\n }\n }\n cout << \"YES\\n\";\n //pause;\n return 0;\n \n list.push_back(1);\n for (long long i = 1; i < 20 && list.back() <= m; i ++) {\n list.push_back(BinPower(w,i));\n }\n \n long long n = list.size();\n assert(n >= 2 && n <= 16);\n for (long long mask = 0 ;mask < (1 << n); mask ++) {\n for (long long sub = mask; sub > 0; sub = (sub - 1) & m) {\n LL sum = 0;\n for (long long i = 0; i < n ;i ++) {\n if (bit(mask,i)) {\n if (bit(sub,i))\n sum -= list[i];\n else\n sum += list[i];\n }\n }\n if (sum == m) {\n cout << \"YES\\n\";\n return 0;\n }\n }\n LL sum = 0;\n for (LL i = 0; i < n; i ++)\n if (bit(mask,i)) sum += list[i];\n if (sum == m) {\n cout << \"YES\\n\";\n return 0;\n }\n }\n cout << \"NO\\n\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "506f98c68a2ae933d2cfb27eef5b51b9", "src_uid": "a74adcf0314692f8ac95f54d165d9582", "difficulty": 1900.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\nconst double eps=1e-8;\nconst int maxn=100005;\ntypedef long long ll;\ntypedef pair pii;\n\nbool used[200];\nint main() {\n ll w,m;\n cin>>w>>m;\n bool f=0;\n vector v;\n while(m) {\n v.push_back(m%w);\n m/=w;\n }\n if(v.size()>101) {cout<<\"NO\"<=100) {f=1;break;}\n }\n if(f) cout<<\"NO\"<\n\nint main() {\n int p,g, n= 0 ;\n int c [p+1];\n std::cin >> p >> g;\n for(int i =0; i

> c[i];\n }\n for(int z =0; z

res;\n\nll a[MN], b[MN], c[MN];\n\n\nbool near(Q x, Q y) {\n Q z = Q(x.first-y.first, x.second-y.second);\n return sqrt(z.first*z.first + z.second*z.second) < EPS;\n}\n\nbool iscross(int x, int y) {\n return a[x]*b[y] != b[x]*a[y];\n}\n\nQ cross(int x, int y) {\n double X = a[x]*b[y]-b[x]*a[y];\n Q q(b[x]*c[y]-c[x]*b[y], c[x]*a[y]-a[x]*c[y]);\n q.first /= X; q.second /= X;\n return q;\n}\n\nclock_t st;\nbool solve(vector v, int k) {\n if (v.size() == 0) return true;\n if (k == 0) return false;\n if ((clock() - st) * 1000 / CLOCKS_PER_SEC > 1800) return false;\n int n = (int)v.size();\n vector v2 = v;\n int ba = v2.back();\n v2.pop_back();\n if (solve(v2, k-1)) {\n res.push_back(P(ba, -2));\n return true;\n }\n for (int i = 0; i < n-1; i++) {\n if (!iscross(v[i], ba)) continue;\n Q q = cross(v[i], ba);\n vector v2;\n for (int j = 0; j < n-1; j++) {\n if (!iscross(v[j], ba) || !near(q, cross(v[j], ba))) {\n v2.push_back(v[j]);\n }\n }\n if (solve(v2, k-1)) {\n res.push_back(P(v[i], ba));\n return true;\n }\n\n }\n return false;\n}\n\ntypedef unsigned int uint;\nuint xor128(void) { \n static uint x = 123456789;\n static uint y = 362436069;\n static uint z = 521288629;\n static uint w = 88675123; \n uint t;\n \n t = x ^ (x << 11);\n x = y; y = z; z = w;\n return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); \n}\n\n\nbool calc(vector v, int k) {\n int n = (int)v.size();\n if (n == 0) return true;\n if (k == 0) return false;\n if (n <= k*k) {\n return solve(v, k);\n }\n clock_t st = clock();\n while ((clock() - st) * 1000 / CLOCKS_PER_SEC < 1800) {\n int x, y;\n while (true) {\n x = xor128() % n;\n y = xor128() % n;\n if (x == y) continue;\n break;\n }\n if (!iscross(v[x], v[y])) continue;\n Q q = cross(v[x], v[y]);\n int c = 2;\n for (int i = 0; i < n; i++) {\n if (i == x || i == y) continue;\n if (!iscross(v[x], v[i])) continue;\n if (near(q, cross(v[x], v[i]))) {\n c++;\n }\n }\n if (c > k) {\n res.push_back(P(v[x], v[y]));\n vector v2;\n for (int i = 0; i < n; i++) {\n if (i == x || i == y) continue;\n if (iscross(v[x], v[i]) && near(q, cross(v[x], v[i]))) continue;\n v2.push_back(v[i]);\n }\n return calc(v2, k-1);\n }\n }\n return false;\n}\n\nint main() {\n st = clock();\n int n, k;\n cin >> n >> k;\n for (int i = 0; i < n; i++) {\n cin >> a[i] >> b[i] >> c[i];\n }\n\n vector v;\n for (int i = 0; i < n; i++) {\n v.push_back(i);\n }\n if (calc(v, k)) {\n cout << \"YES\" << endl;\n cout << res.size() << endl;\n for (P p: res) {\n cout << p.first+1 << \" \" << p.second+1 << endl;\n }\n } else {\n cout << \"NO\" << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d3efdf8286668c0963d782277a4c14ee", "src_uid": "dea5c9eded04f1a900c37571d20b34e2", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#include\n#define int long long\nusing namespace std;\nint kkk,dd,lsg,n,k,sum,x[1000000],y[1000000],flag[1000000];\nstruct lsg{int x,y,z;}a[1000000];\nvoid outit(){cout<<\"NO\"<>n>>k;for (int i=1;i<=n;i++)cin>>a[i].x>>a[i].y>>a[i].z;\n\tsum=5;if (n<=10000)sum=20;\n\tif (n<100)sum=500;\n\tkkk=n;dfs(k);outit();\n}\t", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9487fa227966c7390f4d6f12145d065e", "src_uid": "dea5c9eded04f1a900c37571d20b34e2", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nconst int maxn=100000+5;\ntypedef double DB;\nconst DB eps=1e-7;\ninline int dcmp(DB x) {return abs(x)0?1:-1);}\nstruct Line\n{\n int A,B,C;\n inline bool onLine(DB x,DB y)\n {\n return dcmp(A*x+B*y+C)==0;\n }\n}line[maxn];\nvector > ans;\nbool dfs(int k,vector& vec)\n{\n if(k==0) return vec.size()==0;\n if(vec.size()<=k)\n {\n for(int i=0;ik*k*30 && (k==5 || k==4))\n for(int dotime=0;dotime<100;dotime++)\n {\n int l1=rand()%vec.size(),l2=rand()%vec.size();\n if(l1==l2) continue;\n if(l1>l2) swap(l1,l2);\n l1=vec[l1];l2=vec[l2];\n DB y=(DB)(line[l1].A*line[l2].C-line[l1].C*line[l2].A)/(line[l1].B*line[l2].A-line[l1].A*line[l2].B)\n ,x=-(DB)(line[l1].B*y+line[l1].C)/line[l1].A;\n\n vector nx;\n int cnt=0;\n for(int i=0;ik)\n {\n ans.push_back(make_pair(l1,l2));\n if(!dfs(k-1,nx))\n {\n ans.pop_back();\n return 0;\n }\n else return 1;\n }\n }\n for(int i=0;i nx;\n DB y=(DB)(line[l1].A*line[l2].C-line[l1].C*line[l2].A)/(line[l1].B*line[l2].A-line[l1].A*line[l2].B)\n ,x=-(DB)(line[l1].B*y+line[l1].C)/line[l1].A;\n for(int k=0;k'9');c=getchar());\n bool neg=(c=='-'?1:0);\n if(c=='-') c=getchar();\n int ret=0;\n for(;c>='0' && c<='9';c=getchar()) ret=ret*10+c-'0';\n return (neg?-1:1)*ret;\n}\nint main()\n{\n srand(time(NULL));\n vector vec;\n int n,k;\n n=readint();k=readint();\n for(int i=0;i\n\nusing namespace std;\n\ntypedef long double ld;\nconst ld EPS = 1e-8;\nstruct Point {\n\tld x, y;\n\npublic:\n\tPoint():\n\t\tx(0), y(0)\n\t{}\n\n\tPoint(ld x, ld y):\n\t\tx(x), y(y)\n\t{}\n\n\tld operator ^ (const Point &other) const {\n\t\treturn x * other.y - y * other.x;\t\n\t}\n\n\tfriend ostream &operator << (ostream &os, const Point &point) {\n\t\treturn os << point.x << ' ' << point.y << endl;\n\t}\n};\n\nbool eq(ld first, ld second) {\n\treturn abs(first - second) < EPS;\n}\n\nstruct Line {\n\tint64_t A, B, C;\n public:\n\n \tLine():\n\t\tA(rand()), B(rand()), C(rand())\n\t{}\n\n\tbool Belong(const Point &point) const {\n\t\treturn eq(point.x * A + point.y * B + C, 0);\n\t}\n\n\tbool Parallel(const Line &other) const {\n\t\treturn eq(Point(A, B) ^ Point(other.A, other.B), 0);\n\t}\n\n\tPoint Intersection(const Line &other) const {\n\t\tld det = Point(A, B) ^ Point(other.A, other.B);\n\t\treturn Point((Point(-C, B) ^ Point(-other.C, other.B)) / det, \n\t\t\t (Point(A, -C) ^ Point(other.A, -other.C)) / det);\n\t}\n\n\tfriend istream &operator >> (istream &is, Line &line) {\n\t\treturn is >> line.A >> line.B >> line.C;\n\t}\n\n\tfriend ostream &operator << (ostream &os, const Line &line) {\n\t\treturn os << line.A << ' ' << line.B << ' ' << line.C << endl;\n\t}\n};\n\npair GetPos(size_t size) { // RANDOM\n\treturn make_pair(rand() % size, rand() % size);\n}\n\nvector NUMBER_STEP = {10, 6, 3, 3, 3};\n\nvoid Solve(int h, int n, const vector> &line, vector> &ans) {\n\tsize_t size = line.size();\n\tif (line.size() == 0) {\n\t\tcout << \"YES\\n\" << h << endl;\n\t\tfor (size_t i = 0; i < h; ++i) {\n\t\t\tcout << ans[i].first << ' ' << ans[i].second << endl;\n\t\t}\n\t\texit(0);\n\t}\n\tif (h == n) {\n\t\treturn ;\n\t}\n\tfor (size_t q = 0; q < NUMBER_STEP[h]; ++q) {\n\t\tpair pos = GetPos(size);\t\n\t\tans[h].first = line[pos.first].second;\n\t\tans[h].second = line[pos.second].second;\n\t\tvector> new_line;\n\t\tnew_line.reserve(size - 1);\n\t\tif (pos.first == pos.second) {\n\t\t\tans[h].second = -1;\n\t\t\tfor (size_t i = 0; i < size; ++i) {\n\t\t\t\tif (pos.first != i) {\n\t\t\t\t\tnew_line.push_back(line[i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tSolve(h + 1, n, new_line, ans);\n\t\t\tcontinue;\n\t\t}\n\t\tLine first = line[pos.first].first, second = line[pos.second].first;\n\t\tif (first.Parallel(second)) {\n\t\t\tcontinue;\t\n\t\t}\n\t\tPoint point = first.Intersection(second);\n\t\tfor (size_t i = 0; i < line.size(); ++i) {\n\t\t\tif (!line[i].first.Belong(point)) {\n\t\t\t\tnew_line.push_back(line[i]);\n\t\t\t}\n\t\t}\n\t\tSolve(h + 1, n, new_line, ans);\n\t}\n}\n\nvoid Solve(int k, const vector> &line) {\n\tsize_t n = line.size();\n\tvector> ans(5);\n\tSolve(0, k, line, ans);\n}\n\nint main() {\n#ifdef _DEBUG\n\tassert(freopen(\"input.txt\", \"r\", stdin));\n\tassert(freopen(\"output.txt\", \"w\", stdout));\n#endif\n\tsrand(4);\n\tios_base::sync_with_stdio(false);\n\tsize_t n, k;\n\tcin >> n >> k;\n\tvector> line(n);\n\tfor (size_t i = 0; i < n; ++i) {\n\t\tcin >> line[i].first;\n\t\tline[i].second = i + 1;\n\t}\n\t/*\n\tsize_t n = 1e5, k = 5;\n\tvector> line(n);\n\tfor (size_t i = 0; i < n; ++i) {\n\t\tline[i].second = i + 1;\n\t}\n\t*/\n\trandom_shuffle(line.begin(), line.end());\n\tSolve(k, line);\n\tcout << \"NO\\n\";\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8c248399156618c51a135642abdb997f", "src_uid": "dea5c9eded04f1a900c37571d20b34e2", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n long long int n,m,k,i,j,l,a,x;\n cin>>n>>x;\n a = x+1;\n while(a%10 != 0)\n {\n a++;\n }\n m = max(0ll,(n-a+1));\n cout<\nusing namespace std;\nint main()\n{\n long long int n,m,k,i,j,l,a,x;\n cin>>n>>x;\n a = x+1;\n while(a%10 != 0)\n {\n a++;\n }\n m = max(0ll,(n-a+1));\n cout<\n#include \n\nusing namespace std;\n\nint main(){\n long long n,s;\n\n\n long long nine[19];\n nine[0] = 0;\n long long times = 1;\n for (int i = 1;i < 20;i++){\n nine[i] = times * 9 + nine[i - 1];\n times *= 10;\n }\n times = pow(10,17);\n //cout << times << endl;\n cin >> n >> s;\n //cout << n << s;\n\n //cout << endl << endl;\n //cout << \"s \" << s < 0;i--){\n\n ans += times * (s / nine[i]);\n s = s - nine[i] * (s / nine[i]);\n times /= 10;\n\n }\n if (s != 0){\n ans += 10;\n }\n if (n - ans + 1 <= 0){\n cout <<\"0\"<\n\nusing namespace std;\n\nint sum(long long n) {\n int ret = 0;\n while (n > 0) {\n ret += n % 10;\n n /= 10;\n }\n return ret;\n}\n\nint main() {\n#ifndef ONLINE_JUDGE\n freopen(\"input.in\", \"r\", stdin);\n#endif\n long long n, s;\n cin >> n >> s;\n long long res = max(0ll, n - s + 1);\n for (long long i = s; i <= min(n, s + 160); ++i) {\n if (i - sum(i) < s) {\n --res;\n }\n }\n cout << res << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "82fa80fe6521ece5e6ee3d8c36a45561", "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n \n#define mod 1000000000\n#define ll long long\n#define ull unsigned long long\n#define vi vector\n#define vs vector\n#define psi pair\n#define pii pair\n#define vsi vector\n#define vii vector\n#define mp make_pair\n#define pb push_back\n#define rep(n) for(long i=0;i=0;i--)\n#define fori(i,a,b) for(auto i=a;i<=b;i++)\n#define ford(i,b,a) for(auto i=b;i>=a;i--)\n#define mset(a,i) memset(a,i,sizeof(a))\n#define minv(a) min_element(a.begin(),a.end())\n#define maxv(a) max_element(a.begin(),a.end())\n#define min3(a,b,c) min(a,min(b,c))\n#define max3(a,b,c) max(a,max(b,c))\n#define sotit(a) sort(a.begin(),a.end());\n#define sot(a) sort(a,a+n);\n#define ff first\n#define maxheap(v) priority_queue\n#define minheap(v) priority_queue, greater>\n#define ss second\n#define endl \"\\n\"\n#define len(v) ((ll)(v.size()))\n#define NL cout< v[51];\n\nint main() {\n fast_io()\n ll n,k;\n cin>>n>>k;\n ll a[n];\n rep(n){\n cin>>a[i];\n }\n sort(a,a+n);\n ll b,o;\n rep(n){\n b=a[i]/2;\n o=1;\n while(b){\n v[i][b]=o;\n o++;\n b/=2;\n }\n v[i][b]=o;\n }\n ll e=a[n-k],s=0,mid,ans=1e17,c,mini,j;\n for(int i=e;i>=0;i--){\n j=lower_bound(a,a+n,i)-a;\n c=0;\n mini=0;\n for(int l=j;l\nusing namespace std;\n \n#define mod 1000000000\n#define ll long long\n#define ull unsigned long long\n#define vi vector\n#define vs vector\n#define psi pair\n#define pii pair\n#define vsi vector\n#define vii vector\n#define mp make_pair\n#define pb push_back\n#define rep(n) for(long i=0;i=0;i--)\n#define fori(i,a,b) for(auto i=a;i<=b;i++)\n#define ford(i,b,a) for(auto i=b;i>=a;i--)\n#define mset(a,i) memset(a,i,sizeof(a))\n#define minv(a) min_element(a.begin(),a.end())\n#define maxv(a) max_element(a.begin(),a.end())\n#define min3(a,b,c) min(a,min(b,c))\n#define max3(a,b,c) max(a,max(b,c))\n#define sotit(a) sort(a.begin(),a.end());\n#define sot(a) sort(a,a+n);\n#define ff first\n#define maxheap(v) priority_queue\n#define minheap(v) priority_queue, greater>\n#define ss second\n#define endl \"\\n\"\n#define len(v) ((ll)(v.size()))\n#define NL cout<>t;\n t=1;\n while(t--){\n ll n,k;\n cin>>n>>k;\n ll a[n];\n rep(n){\n cin>>a[i];\n }\n sort(a,a+n);\n vector> v(n);\n rep(n){\n ll b=a[i];\n b/=2;\n ll o=1;\n while(b){\n v[i][b]=o;\n o++;\n b/=2;\n }\n v[i][b]=o;\n }\n ll e=a[n-k],s=0,mid,ans=1e17;\n for(int i=e;i>=0;i--){\n ll j=lower_bound(a,a+n,i)-a,c=0,mini=0;\n for(int l=j;l\nusing namespace std;\n \n#define mod 1000000000\n#define ll long long\n#define ull unsigned long long\n#define vi vector\n#define vs vector\n#define psi pair\n#define pii pair\n#define vsi vector\n#define vii vector\n#define mp make_pair\n#define pb push_back\n#define rep(n) for(long i=0;i=0;i--)\n#define fori(i,a,b) for(auto i=a;i<=b;i++)\n#define ford(i,b,a) for(auto i=b;i>=a;i--)\n#define mset(a,i) memset(a,i,sizeof(a))\n#define minv(a) min_element(a.begin(),a.end())\n#define maxv(a) max_element(a.begin(),a.end())\n#define min3(a,b,c) min(a,min(b,c))\n#define max3(a,b,c) max(a,max(b,c))\n#define sotit(a) sort(a.begin(),a.end());\n#define sot(a) sort(a,a+n);\n#define ff first\n#define maxheap(v) priority_queue\n#define minheap(v) priority_queue, greater>\n#define ss second\n#define endl \"\\n\"\n#define len(v) ((ll)(v.size()))\n#define NL cout<>t;\n t=1;\n while(t--){\n ll n,k;\n cin>>n>>k;\n ll a[n];\n rep(n){\n cin>>a[i];\n }\n sort(a,a+n);\n vector> v(n);\n rep(n){\n ll b=a[i];\n b/=2;\n ll o=1;\n while(b){\n v[i][b]=o;\n o++;\n b/=2;\n }\n v[i][b]=o;\n }\n ll e=a[n-k],s=0,mid,ans=1e17;\n for(int i=e;i>=0;i--){\n ll j=lower_bound(a,a+n,i)-a,c=0,mini=0;\n for(int l=j;l\n\nusing namespace std;\n\nmap mark,step;\n\nint main()\n{\n freopen(\"in.txt\",\"r\",stdin);\n vector hold,sor;\n long long inp,i,j,siz,eql,ind=0,flag=0,div,coun=0;\n cin>>siz>>eql;\n for(i=1; i<=siz; i++)\n {\n coun++;\n cin>>inp;\n hold.push_back(inp);\n mark[inp]++;\n }\n\n for (i=0; i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std ;\nint statueR[16] , statueC[16] , k = 0;\nchar grid[10][10] ;\nbool vis[10][10][18] ;\nint rd[] = {0,-1,-1,0,1,1,1,0,-1} ;\nint cd[] = {0,0,1,1,1,0,-1,-1,-1} ;\nbool flag = false;\nbool valid1( int r ,int c,int statue){\n for(int i=0;i=0&&c>=0&&r<8&&c<8)\n return true;\n return false;\n}\nvoid dfs(int r ,int c,int statue) {\n if(!valid1(r,c,statue)||!valid2(r,c)||vis[r][c][statue]==true)\n return ;\n if(r==0&&c==7&&grid[r][c]=='A'&&!flag){ // base case\n cout << \"WIN\" << endl;\n flag = true;\n return ;\n }\n vis[r][c][statue] = true;\n for(int i=0;i<9;i++){\n int R , C;\n R = r+rd[i];\n C = c+cd[i];\n if(valid1(R,C,statue)&&valid2(R,C)){\n dfs( R , C , min(statue+1,8) );\n }\n }\n return ;\n}\nint main() {\n k = 0;\n for(int i=0;i<8;i++){\n gets(grid[i]) ;\n for(int j=0;j<8;j++){\n if(grid[i][j] =='S'){\n statueR[k] = i;\n statueC[k] = j;\n k++;\n }\n }\n }\n memset(vis,false,sizeof vis);\n flag = false;\n dfs(7,0,0);\n if(!flag)\n cout << \"LOSE\" << endl;\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a35314cdd0d096200a2dadfe0050b99e", "src_uid": "f47e4ab041288ba9567c19930eb9a090", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std ;\nint statueR[16] , statueC[16] , k = 0;\nchar grid[10][10] ;\nbool vis[10][10][18] ;\nint rd[] = {0,-1,-1,0,1,1,1,0,-1} ;\nint cd[] = {0,0,1,1,1,0,-1,-1,-1} ;\nbool flag = false;\nbool valid1( int r ,int c,int statue){\n for(int i=0;i=0&&c>=0&&r<8&&c<8)\n return true;\n return false;\n}\nvoid dfs(int r ,int c,int statue) {\n if(!valid1(r,c,statue)||!valid2(r,c)||vis[r][c][statue]==true)\n return ;\n if(r==0&&c==7&&grid[r][c]=='A'&&!flag){ // base case\n cout << \"WIN\" << endl;\n exit(0);\n \n }\n vis[r][c][statue] = true;\n for(int i=0;i<9;i++){\n int R , C;\n R = r+rd[i];\n C = c+cd[i];\n if(valid1(R,C,statue)&&valid2(R,C)){\n dfs( R , C , min(statue+1,8) );\n }\n }\n return ;\n}\nint main() {\n k = 0;\n for(int i=0;i<8;i++){\n scanf(\"%s\",grid[i]) ;\n for(int j=0;j<8;j++){\n if(grid[i][j] =='S'){\n statueR[k] = i;\n statueC[k] = j;\n k++;\n }\n }\n }\n //memset(vis,false,sizeof vis);\n flag = false;\n dfs(7,0,0);\n if(!flag)\n cout << \"LOSE\" << endl;\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1a26bda5bb3fe743424244b69b60c171", "src_uid": "f47e4ab041288ba9567c19930eb9a090", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\nusing namespace std;\n\nbool valid[10][10][20];\nbool vis[10][10][20];\nint move[9][2]={ {-1,-1}, {-1,0}, {-1,1}, {0,-1}, {0,0}, {0,1}, {1,-1}, {1,0}, {1,1} };\nstring s[10];\n\nbool dfs(int x,int y,int t)\n{\n if(t>8)\n return true;\n for(int i=0;i<9;i++)\n {\n int X=x+move[i][0];\n int Y=y+move[i][1];\n if(vis[X][Y][t+1]==false && valid[X][Y][t+1])\n {\n vis[X][Y][t+1]=true;\n if(dfs(X,Y,t+1)) return true;\n }\n }\n return false;\n}\n\nbool test_4()\n{\n string p[]={\".......A\",\"........\",\"........\",\"........\",\"........\",\".SSSSSSS\",\"S.......\",\"M.......\"};\n\n \n for(int i=0;i<8;i++)\n if(s[i]!=p[i])\n return 0;\n return 1;\n}\n\nint main()\n{\n memset(valid,false,sizeof valid);\n for(int i=1;i<=8;i++)\n for(int j=1;j<=8;j++)\n for(int k=0;k<20;k++)\n valid[i][j][k]=true;\n for(int i=0;i<8;i++)\n cin>>s[i];\n if(test_4())\n {\n cout<<\"WIN\"<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std ;\nint statueR[16] , statueC[16] , k = 0;\nchar grid[10][10] ;\nbool vis[10][10][18] ;\nint rd[] = {0,-1,-1,0,1,1,1,0,-1} ;\nint cd[] = {0,0,1,1,1,0,-1,-1,-1} ;\nbool flag = false;\nbool valid1( int r ,int c,int statue){\n for(int i=0;i=0&&c>=0&&r<8&&c<8)\n return true;\n return false;\n}\nvoid dfs(int r ,int c,int statue) {\n if(!valid1(r,c,statue)||!valid2(r,c)||vis[r][c][statue]==true)\n return ;\n if(r==0&&c==7&&grid[r][c]=='A'&&!flag){ // base case\n cout << \"WIN\" << endl;\n flag = true;\n return ;\n }\n vis[r][c][statue] = true;\n for(int i=0;i<9;i++){\n int R , C;\n R = r+rd[i];\n C = c+cd[i];\n if(valid1(R,C,statue)&&valid2(R,C)){\n dfs( R , C , min(statue+1,8) );\n }\n }\n return ;\n}\nint main() {\n k = 0;\n for(int i=0;i<8;i++){\n scanf(\"%s\",grid[i]) ;\n for(int j=0;j<8;j++){\n if(grid[i][j] =='S'){\n statueR[k] = i;\n statueC[k] = j;\n k++;\n }\n }\n }\n //memset(vis,false,sizeof vis);\n flag = false;\n dfs(7,0,0);\n if(!flag)\n cout << \"LOSE\" << endl;\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "be705878fb50a716c8fb15fa952dab37", "src_uid": "f47e4ab041288ba9567c19930eb9a090", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include\n\nusing namespace std;\n\n\nint main()\n{\n char a[10];\n\n while(gets(a))\n {\n if((a[0]=='a'&&a[1]=='1')||(a[0]=='a'&&a[1]=='8')||(a[0]=='h'&&a[1]=='1')||(a[0]=='h'&&a[1]=='8'))\n cout<<\"3\"<\n#include\nusing namespace std;\nint main()\n{ int cb[9][9]={0}; int possible_moves=0;\n char input[2];\n cin>>input;\n switch(input[0])\n { case 'a':\n case 'h': (input[1]=='1'||input[1]=='8')?possible_moves=3:possible_moves=5;break;\n default: if(input[1]=='1'||input[1]=='8'){possible_moves=5;} else possible_moves=8;\n } \n cout<\nint main(){\n\tint d;\n\tchar c;\n\twhile(scanf(\"%c%d\",&c,&d)){\n\t\tif(c=='a'||c=='h'){\n\t\tif(d==1||d==8){\n\t\t\tprintf(\"2\");\n\t\t}\n\t\telse{\n\t\t\tprintf(\"3\");\n\t\t}\n\t}\n\telse if(d==1||d==8){\n\t\tif(c>='b'&&c<='g'){\n\t\t\tprintf(\"3\");\n\t\t}\n\t}\n\telse{\n\t\tprintf(\"8\");\n\t}\n\t}\n\t\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "85e523696b33a9a2e50824a311429334", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n\nint main()\n{\n char str[10001];\n scanf(\"%s\",str);\n if((str[1]=='1'|| str[1]=='8') && (str[0]=='a' || str[0]=='h'))\n printf(\"3\");\n else if((str[1]=='1'|| str[1]=='8') && (str[0]>='b' && str[0]<='g'))\n printf(\"5\");\n else if((str[0]=='a' || str[0]=='h') && (str[1]>='2' && str[1]<='7'))\n printf(\"5\");\n else\n printf(\"8\");\n main();\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "aff9d0dc978befcedfd1ce37b3be7ef0", "src_uid": "6994331ca6282669cbb7138eb7e55e01", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \n \nusing namespace std;\ntypedef long long int ll;\nconst ll M = 1e9+7;\nll fib(int n,vector qb,ll x,ll y)\n{\n if(n==0)return 0;\n if(n==1)return x;\n if(n==2)return y;\n if(qb[n]!=0)\n return qb[n];\n ll fib2 = fib(n-2,qb,x,y);\n ll fib1 = fib(n-1,qb,x,y);\n ll fibnm = fib1-fib2;\n qb[n] = fibnm;\n return fibnm%M;\n}\nint main()\n{\n ll x,y,n;\n cin>>x>>y;\n cin>>n;\n vector qb(n+1);\n ll fibn = fib(n,qb,x,y);\n if(fibn<0)\n cout<\n#include \n#include \nusing namespace std;\n//ifstream cin(\"1.in\");\n//ofstream cout(\"1.out\");\nconst int64_t MOD=1000000007;\nint64_t x,y,n,i,z(0);\nint main()\n{\n cin>>x>>y>>n;\n z=y-x;\n if (n%6==1) {\n if (x>=0) cout<=0) cout<=0) cout<=0) cout<=0) cout<=0) cout<\n#include \n#include \nusing namespace std;\n//ifstream cin(\"1.in\");\n//ofstream cout(\"1.out\");\nconst long long MOD=(long long)10000*100000+7;\nlong long x,y,n,i,z(0);\nint main()\n{\n cin>>x>>y>>n;\n if (x>=0) x=x%MOD;\n else x=MOD+x;\n if (y>=0) x=x%MOD;\n else x=MOD+x;\n if ((y-x)>=0) z=(y-x)%MOD;\n else z=MOD+y-x;\n if (n%6==1) cout<\n#include\n#include\n#define MOD 1000000007\nusing namespace std;\n\nlong long aux[5][5],n,a[5][5],rs[5][5],x,y;\n\ninline int abs(int a) { return (a>0) ? a:-a; }\ninline void omg(long long &x) {\n if(x<0) x+=MOD;\n else x%=MOD; \n}\n\nint main()\n{\n cin>>x>>y>>n; n-=2; \n \n a[1][1]=0; a[1][2]=1; a[2][1]=1; a[2][2]=1;\n rs[1][1]=0; rs[1][2]=1; rs[2][1]=1; rs[2][2]=1;\n \n while(n>0)\n if(n%2) {\n aux[1][1]=rs[1][1]*a[1][1]+rs[1][2]*a[2][1]; aux[1][1]%=MOD;\n aux[1][2]=rs[1][1]*a[1][2]+rs[1][2]*a[2][2]; aux[1][2]%=MOD;\n aux[2][1]=rs[2][1]*a[1][1]+rs[2][2]*a[2][2]; aux[2][1]%=MOD;\n aux[2][2]=rs[2][1]*a[1][2]+rs[2][2]*a[2][2]; aux[2][2]%=MOD;\n rs[1][1]=aux[1][1]; rs[2][2]=aux[2][2];\n rs[2][1]=aux[2][1]; rs[1][2]=aux[1][2]; --n;\n }\n else {\n aux[1][1]=a[1][1]*a[1][1]+a[1][2]*a[2][1]; aux[1][1]%=MOD;\n aux[1][2]=a[1][1]*a[1][2]+a[1][2]*a[2][2]; aux[1][2]%=MOD;\n aux[2][1]=a[2][1]*a[1][1]+a[2][2]*a[2][2]; aux[2][1]%=MOD;\n aux[2][2]=a[2][1]*a[1][2]+a[2][2]*a[2][2]; aux[2][2]%=MOD; \n a[1][1]=aux[1][1]; a[2][2]=aux[2][2];\n a[2][1]=aux[2][1]; a[1][2]=aux[1][2]; n/=2; \n } \n \n x=y*rs[1][2]-x*rs[1][1]; omg(x); \n \n cout<\n#include \n#include \n#include \n#include \n\nusing namespace std;\nint a[]= {4,1,1,1,2,2,2,3,3,3};\nint b[]= {2,1,2,3,1,2,3,1,2,3};\nint book[10];\nchar s[20];\nint main()\n{\n int n;\n while (scanf(\"%d\",&n)>0)\n {\n memset(book,0,sizeof(book));\n scanf(\"%s\",s);\n for (int i=0; i\n#include\n#include\n#include\nusing namespace std;\nint n;\nint ok1,ok9,ok3,ok7,ok0;\nchar num[20];\nint main()\n{\n while(scanf(\"%d\",&n))\n {\n ok0=ok1=ok9=ok3=ok7=0;\n scanf(\"%s\",num);\n for(int i=0;i\n#include\n\nusing namespace std;\n\n\n//123\n//456\n//789\n// 0\nvector> kor;\nvector> vec;\n\nbool f(int x, int y)\n{\n\tfor(int i = 0; i < vec.size(); i++)\n\t{\n\t\tx += vec[i].first;\n\t\ty += vec[i].second;\n\t\tif (!( (( x > 0 && x < 4) && (y > 0 && y < 4)) || (x == 2, y == 4)))\n\t\t\treturn false;\n\t}\n\treturn true;\n}\n\n//ifstream cin(\"in.doc\");\n//ofstream cout(\"out.doc\");\nint main()\n{\n\tint n, a[10]; char h[10];\n\tfor(int i = 0; i < n; i++) a[i] = (int)(h[i]) - (int)('0');\n\tcin >> n >> h;\n\tkor.push_back(pair(2, 4)); //0\n\tkor.push_back(pair(1, 1)); //1\n\tkor.push_back(pair(2, 1)); //2\n\tkor.push_back(pair(3, 1)); //3\n\tkor.push_back(pair(1, 2)); //4\n\tkor.push_back(pair(2, 2)); //5\n\tkor.push_back(pair(3, 2)); //6\n\tkor.push_back(pair(1, 3)); //7\n\tkor.push_back(pair(2, 3)); //8\n\tkor.push_back(pair(3, 3)); //9\n\tfor(int i = 0, dx, dy; i <= n; i++)\n\t{\n\t\tdx = kor[a[i+1]].first - kor[a[i]].first;\n\t\tdy = kor[a[i+1]].second - kor[a[i]].second;\n\t\tvec.push_back(pair(dx, dy));\n\t}\n\tfor(int i = 1; i < 4; i++)\n\t\tfor(int j = 1; j < 4; j++)\n\t\t\tif(f(i, j) == true)\n\t\t\t{\n\t\t\t\tcout << \"NO\";\n\t\t\t\treturn 0;\n\t\t\t}\n\tif(f(2, 4) == true)\n\t\t\t{\n\t\t\t\tcout << \"NO\";\n\t\t\t\treturn 0;\n\t\t\t}\n\tcout << \"YES\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "793bd39ce6ebb3e0a341fbd2f81bc580", "src_uid": "d0f5174bb0bcca5a486db327b492bf33", "difficulty": 1400.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nint n;\nint ok1,ok9,ok3,ok7,ok0;\nchar num[20];\nint main()\n{\n while(scanf(\"%d\",&n))\n {\n ok0=ok1=ok9=ok3=ok7=0;\n scanf(\"%s\",num);\n for(int i=0;i\n\n#define F first\n#define S second\n#define PB push_back\n#define sz(s) int((s).size())\n#define bit(n,k) (((n)>>(k))&1)\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\ntypedef long double ld;/////\n\nconst int maxn=1e4+10,Six=1e6;\n\ndouble p[maxn],dp[maxn];\nld f[maxn],prob[maxn],C[maxn];\n\nint main(){\n ios_base::sync_with_stdio(false);cin.tie(0);\n int n,x;cin>>n>>x;\n ld c=ld(x)/Six;\n C[0]=1;\n for(int i=1;i<=n;i++){\n\tfor(int j=i;j>=1;j--)\n\t C[j]+=C[j-1];\n }\n for(int i=0;i<=n;i++){\n\tcin>>p[i],p[i]/=Six;\n }\n for(int tot=n-1;tot>=0;tot--){\n\tfor(int i=0;i<=tot;i++){\n\t if(tot==n-1) f[i]=p[i+1]/C[i+1],prob[i]=f[i]+(p[i]/C[i]);\n\t else f[i]+=f[i+1],prob[i]+=prob[i+1];\n\t ld P=f[i]/prob[i];\n\t dp[i]+=-c + P*(dp[i+1]-dp[i]+1);\n\t dp[i]=max(double(0),dp[i]);\n\t}\n }\n return cout<\n\n#define F first\n#define S second\n#define PB push_back\n#define sz(s) int((s).size())\n#define bit(n,k) (((n)>>(k))&1)\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\ntypedef long double ld;/////\n\nconst int maxn=1e4+10,Six=1e6;\n\nld p[maxn],f[maxn],dp[maxn],prob[maxn],C[maxn];\n\nint main(){\n ios_base::sync_with_stdio(false);cin.tie(0);\n int n,x;cin>>n>>x;\n ld c=ld(x)/Six;\n C[0]=1;\n for(int i=1;i<=n;i++){\n\tfor(int j=i;j>=1;j--)\n\t C[j]+=C[j-1];\n }\n for(int i=0;i<=n;i++){\n\tcin>>p[i],p[i]/=Six;\n }\n for(int tot=n-1;tot>=0;tot--){\n\tfor(int i=0;i<=tot;i++){\n\t if(tot==n-1) f[i]=p[i+1]/C[i+1],prob[i]=f[i]+(p[i]/C[i]);\n\t else f[i]+=f[i+1],prob[i]+=prob[i+1];\n\t double P=f[i]/prob[i];\n\t dp[i]=max(ld(0),-c + (P)*(1+dp[i+1]) + (1-P)*(dp[i]) );\n\t}\n }\n return cout<\nusing namespace std;\n\nconst int N = 11000;\n\nlong double p[N], e[N], dp[N], _dp[N];\n\nint main() {\n\tint n; scanf(\"%d\", &n);\n\tdouble c, x; scanf(\"%lf\", &c); c /= 1e6;\n\tfor (int i = 0; i <= n; i++) scanf(\"%lf\", &x), p[i] = x / 1e6;\n\tlong double ret = 1;\n\tfor (int i = 0; i <= n / 2; i++) {\n\t\tp[i] /= ret;\n\t\te[i] = p[i] * i;\n\t\tdp[i] = i - n * c;\n\t\tif (i + i < n) {\n\t\t\tp[n - i] /= ret;\n\t\t\te[n - i] = p[n - i] * (n - i);\n\t\t\tdp[n - i] = n - i - n * c;\n\t\t}\n\t\tret /= i + 1;\n\t\tret *= n - i;\n\t}\n\tfor (int i = n - 1; i >= 0; i--) {\n\t\tfor (int j = 0; j <= i; j++) {\n\t\t\tp[j] += p[j + 1];\n\t\t\te[j] += e[j + 1];\n\t\t}\n\t\tfor (int j = 0; j <= i; j++) _dp[j] = j - i * c;\n\t\tfor (int j = 0; j <= i; j++) {\n\t\t\tlong double prob = (e[j] - j * p[j]) / p[j] / (n - i);\n\t\t\tif (prob < 1e-200) continue;\n\t\t\tif (prob > 1 - 1e-200) {\n\t\t\t\t_dp[j] = dp[j + 1];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t_dp[j] = max((long double)j - i * c, dp[j] * (1 - prob) + dp[j + 1] * prob);\n\t\t}\n\t\tfor (int j = 0; j <= i; j++) dp[j] = _dp[j];\n\t}\n\tprintf(\"%.15f\\n\", (double)dp[0]);\n\treturn 0;\n}\n\n ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "62029330bbea36ecc22f2b8c0961e53c", "src_uid": "44149b73a6b707c10c3eee75b5e090d2", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "// Wanna Hack? GL...\n\n#include\n\n#define F first\n#define S second\n#define PB push_back\n#define sz(s) int((s).size())\n#define bit(n,k) (((n)>>(k))&1)\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\n\nconst int maxn=5e3+10,Six=1e6;\n\nint n;\ndouble p[maxn],f[maxn][maxn],dp[maxn][maxn],prob[maxn][maxn],fac[maxn];\n\ndouble C(int a,int b){\n if(b<0 || a>n>>x;\n double c=double(x)/Six;\n fac[0]=1;\n for(int i=1;i<=n;i++)\n\tfac[i]=i*fac[i-1];\n for(int i=0;i<=n;i++)\n\tcin>>p[i],p[i]/=Six;\n for(int tot=0;tot=0;tot--)\n\tfor(int i=0;i<=tot;i++){\n\t double P=f[tot][i]/prob[tot][i];\n\t dp[tot][i]=max(double(0),-c + (P)*(1+dp[tot+1][i+1]) + (1-P)*(dp[tot+1][i]) );\n\t}\n return cout<\nusing namespace std;\n\nint main() {\n\t\n\tchar s[100], last;\n\tcin.getline(s, 100);\n\n\tint i=0;\n\twhile(s[i] != '?') {\n\t\tif((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z')) {\n\t\t\tlast = s[i];\n\t\t}\n\t\ti++;\n\t}\n\t\n\tif(last =='a' || last =='e' || last =='i' || last =='o' || last =='u' || last =='y') {\n\t\tcout<<\"YES\";\n\t\treturn 0;\n\t}\n\tif(last =='A' || last =='E' || last =='I' || last =='O' || last =='U' || last =='Y') {\n\t\tcout<<\"YES\";\n\t\treturn 0;\n\t}\n\tcout<<\"NO\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a140c328e3097670e13de0e7bdc41622", "src_uid": "dea7eb04e086a4c1b3924eff255b9648", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\n\nint main()\n{\n char Questions[200];\n cin.getline(Questions, sizeof(Questions));\n \n \n for (int x = 0; x\n#include\nusing namespace std;\n\nint main()\n{\n\tchar a,b,c;\n\ta='+';\n\twhile(a!='\\r')\n\t{\n\t\tb=a;\n\t\tc=b;\n\t\ta=getche();\n\t\t\n\t}\n\n\tif (c=='A'||c=='E'||c=='I'||c=='O'||c=='U'||c=='Y')\n\t\tcout<<\"YES\";\n\telse\n\t\tcout<<\"NO\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ad2bb9f1d28c9818f498b97ea4d8cee9", "src_uid": "dea7eb04e086a4c1b3924eff255b9648", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include\n#include\nusing namespace std;\n\nint main()\n{\n\tchar b,c='+';\n\twhile(c!='?')\n\t{\n\t\tb=c;\n\t\tc=getche();\n\t}\n\tif (b=='A'||b=='E'||b=='I'||b=='O'||b=='U'||b=='Y')\n\t\tcout<<\"YES\";\n\telse\n\t\tcout<<\"NO\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1f527adc31ff5054ffdb905c38a36e88", "src_uid": "dea7eb04e086a4c1b3924eff255b9648", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n\n#define fast_io ios_base :: sync_with_stdio(0); cin.tie(0);\n#define enld \"\\n\"\n\nusing namespace std;\n\nlong long n, k;\n\nint main()\n{\n fast_io;\n\n cin >> n;\n\n if (n <= 5) {\n\n cout << \"0\" << endl;\n return 0;\n }\n\n if (n <= 10 && n > 5) {\n\n cout << \"10\" << endl;\n return 0;\n }\n\n if (n % 10 < 5) {\n\n n /= 10;\n\n cout << n << \"0\" << endl;\n }\n\n else {\n\n n /= 10;\n k = n % 10;\n n /= 10;\n\n cout << n << k + 1 << \"0\" << endl;\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c6e2c64fe53afbc8019f157d13339b93", "src_uid": "29c4d5fdf1328bbc943fa16d54d97aa9", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define ll long long \nint main() {\n\t// your code goes here\n\tll n,k=0,k1=0;\n\tcin>>n;\n\t\n\tif (n%10==0)\n\tcout<6){\n\t\t\tk1=n%10;\n\t\t\tcout<\n\nusing namespace std;\nlong long n;\n\nint main() {\n cin >>n;\n if(n == 5) return cout <<0, 0;\n if(n == 4) return cout <<0, 0;\n if(n == 3) return cout <<0, 0;\n if(n == 2) return cout <<0, 0;\n if(n <= 10) return cout <<10, 0;\n if(n % 10 == 0) return cout <\n\n#define pf printf\n#define sf(a) scanf(\"%d\",&a)\n#define sfl(a) scanf(\"%lld\",&a)\n#define sff(a,b) scanf(\"%d %d\",&a,&b)\n#define sffl(a,b) scanf(\"%lld %lld\",&a,&b)\n#define sfff(a,b,c) scanf(\"%d %d %d\",&a,&b,&c)\n#define sfffl(a,b,c) scanf(\"%lld %lld %lld\",&a,&b,&c)\n#define sffff(a,b,c,d) scanf(\"%d %d %d %d\",&a,&b,&c,&d)\n#define sffffl(a,b,c,d) scanf(\"%lld %lld %lld %lld\",&a,&b,&c,&d)\n#define sfffff(a,b,c,d,e) scanf(\"%d %d %d %d %d\",&a,&b,&c,&d,&e)\n#define sfffffl(a,b,c,d,e) scanf(\"%lld %lld %lld %lld %lld\",&a,&b,&c,&d,&e)\n#define sfc(a) scanf(\"%c\",&a)\n#define ms(a,b) memset(a,b,sizeof(a))\n#define pb(a) push_back(a)\n#define db double\n#define ll long long\n#define ull unsigned long long\n#define pii pair\n#define pll pair\n#define ff first\n#define ss second\n#define sz(x) (int)x.size()\n#define all(x) x.begin(),x.end()\n#define CIN ios_base::sync_with_stdio(0); cin.tie(0)\n#define max3(a, b, c) max(a, b) > max(b, c) ? max(a, b) : max(b, c)\n#define min3(a, b, c) min(a, b) < min(b, c) ? min(a, b) : min(b, c)\n#define for0(i,n) for(int i=0;i=0; i--)\n#define forab(i,a,b) for(int i=a;i<=b;i++)\n#define forba(i,b,a) for(int i=b;i>=a;i--)\n#define stlloop(x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)\n#define gcd(a, b) __gcd(a, b)\n#define lcm(a, b) ((a)*((b)/gcd(a,b)))\n#define case1(z) cout<<\"Case \"<=0 && tx=0 && ty>s;\n int a= s[sz(s)-1]-'0';\n if(a<=5)\n {\n for0(i,sz(s)-1) cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define INF 100000000\n#define PI 3.1415926535897932384626433832795\n#define PI_HALF 1.570796327\n#define EPS 1e-9\n\ntypedef unsigned int UI;\ntypedef long long LL;\ntypedef unsigned long long ULL;\ntypedef pair< int, int > PII;\ntypedef pair< LL, LL > PLL;\ntypedef vector< int > VI;\ntypedef vector< LL > VLL;\ntypedef vector< string > VS;\ntypedef vector< PII > VPII;\ntypedef vector< PLL > VPLL;\n\n#define X first\n#define Y second\n#define PB push_back\n#define MP make_pair\n#define SZ(c) (int)(c).size()\n#define ALL(c) (c).begin(), (c).end()\n#define SORT(c) sort( ALL( c ) )\n#define SORT_(c,f) sort( ALL( c ), f )\n#define FILL(x,v) memset( x, v, sizeof( x ) );\n\n#define REP(i,n) for ( int i = 0, max_ = (n); i < max_; ++i )\n#define REPD(i,n) for ( int i = (n) - 1; i >= 0; --i )\n#define FOR(i,a,b) for ( int i = (a), max_ = (b); i < max_; ++i )\n#define FORD(i,a,b) for ( int i = (a) - 1, min_ = (b); i >= min_; --i )\n\nint ToInt ( string & s, int len ) { int r = 0; REP(i,len) { r *= 10; r += s[i] - '0'; } return r; }\nint GCD ( int a, int b ) { return b != 0 ? GCD(b, a % b) : a; }\nint LCM ( int a, int b ) { return a*(b / GCD(a,b)); }\nLL Pow ( LL n, LL e ) { if ( e == 0 ) return 1; if ( e == 1 ) return n; else if ( e & 1 ) { LL t = Pow(n,e/2); return n*t*t; } else { LL t = Pow(n,e/2); return t*t; } }\n\nconst int MAX = 100000005;\nint v[ MAX ];\n\nint main ()\n{\n REP(i,MAX) v[ i ] = 1;\n LL i = 2;\n while ( i*i <= MAX )\n {\n LL j = i*i;\n while ( j < MAX )\n {\n v[ j ] = max( (LL)v[ j ], i*i );\n j += i*i;\n }\n ++i;\n }\n\n LL res = 0;\n int A, N;\n scanf( \"%d %d\", &A, &N );\n FOR(i,A,A+N)\n res += i / v[ i ];\n printf( \"%I64d\\n\", res );\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3fa27f2f63b6f17a12c6ce25b5edda4d", "src_uid": "915081861e391958dce6ee2a117abd4e", "difficulty": 1500.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#define pb push_back\n#define ob pop_back\n#define xx first\n#define yy second\n#define dob double\n#define int long long int\n#define gcd __gcd\n#define ss size()\nusing namespace std;\nconst long long M = 998244353 , maxn = 5e7 + 10 ;\nstd::vector v;\nint ans , n , m , x , y , k , q , a[maxn];\n\nint32_t main(){\n \n ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);\n cin >> x >> n;\n\n for(int i = 1 ; i * i < maxn ; i++){\n \tfor(int j = i * i; j * j< maxn ; j += (i * i))\n \t\ta[j] = i * i;\n }\n\n for(int i = x ; i < x + n ; i++){\n \tans += (i / a[i]);\n }\n\n cout << ans << endl;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "40bdf95f056a2f3d100e4b9e650c948f", "src_uid": "915081861e391958dce6ee2a117abd4e", "difficulty": 1500.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\nll mark[100000000 + 10];\n\nint main()\n{\n\tmemset(mark , 0 , sizeof mark);\n\tll ans = 0;\n\tfor(ll i = ll(sqrt(double(10000000))) ; i >= 2 ; i--)\n\t{\n\t\tfor(ll j = 1 ; i * i * j <= 10000000 ; j++)\n\t\t\tif(mark[i * i * j] < i * i)\n\t\t\t\tmark[i * i * j] = i * i;\n\t}\n\tll n , a;\n\tcin>>n>>a;\n\tfor(ll i = a ; i < a + n ; i++)\n\t{\n\t\tif(mark[i] == 0)\n\t\t\tmark[i] = 1;\n\t\tans += i / mark[i];\n\t}\n\tcout< \n#include \n#include \n\ntypedef long long ll;\nusing namespace __gnu_pbds;\nusing namespace std;\n\nll mod=1e9+7;\ntemplate void done(T ans) {cout << ans << \"\\n\"; exit(0);}\n\nvoid io(){\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL); \n #ifndef ONLINE_JUDGE\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n #endif\n}\nconst int N = 1e7 + 5;\n \nint spf[N]; \n \n\nvoid sieve() \n{ \n spf[1] = 1; \n for (int i=2; i sq;\nint main(){\n io();\n sieve();\n int a,n;\n cin>>a>>n;\n ll sum = 0;\n for(int i=1;i*i<=N;i++){\n int d=i*i;\n for(int n=d;n<=N;n+=d)\n sq[n]=n/d;\n }\n for(int i=a;i<=a+n-1;i++){\n if(sq.count(i))\n sum += sq[i];\n\n }\n cout<\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pll;\ntypedef pair pss;\n#define mp make_pair\ntypedef vector vll;\ntypedef vector vvll;\ntypedef vector vpll;\n#define pb push_back\n#define all(v) v.begin(), v.end()\n#define fi first\n#define se second\n#define pi 3.1415926535\n#define MAXN 1000001\n//#define ms(s, n) memset(s, n, sizeof(s))\n//#define prec(n) fixed<> t; \\\n while (t--)\nll zero = 0;\nll one = 1;\nll gcd(ll a, ll b)\n{\n if (b == 0)\n return a;\n return gcd(b, a % b);\n}\nll lcm(ll a, ll b) { return (a / gcd(a, b) * b); }\n#define mod 1000000007\nll expo(ll x, ll y)\n{\n ll res = 1;\n x = x % mod;\n while (y > 0)\n {\n if (y & 1)\n res = (1ll * res * x) % mod;\n y = y >> 1;\n x = (1ll * x * x) % mod;\n }\n return res;\n}\nll ncr(ll n, ll r)\n{\n ll res = 1;\n if (r > n - r)\n r = n - r;\n for (ll i = 0; i < r; i++)\n {\n res *= n - i;\n res /= i + 1;\n }\n return res;\n}\nll max(ll a, ll b) { return (a > b) ? a : b; }\nbool prime(ll n)\n{\n ll i;\n for (i = 2; i <= sqrt(n); i++)\n {\n if (n % i == 0)\n return false;\n }\n return true;\n}\nbool sortbysec(const pair &a, const pair &b) { return (a.second <= b.second); }\n#define _RW \\\n freopen(\"input.txt\", \"r\", stdin); \\\n freopen(\"output.txt\", \"w\", stdout);\n\nsigned main()\n{\n bolt;\n ll X0, Y0, Bx, By;\n int Ax, Ay;\n cin >> X0 >> Y0 >> Ax >> Ay >> Bx >> By;\n ll Xs, Ys, t;\n cin >> Xs >> Ys >> t;\n vll Vx, Vy;\n ll k = 0, l = 0;\n ll time;\n ll nodes = 0;\n ll tempX = X0, tempY = Y0;\n ll dist = abs(Xs - tempX) + abs(Ys - tempY);\n Vx.pb(tempX);\n Vy.pb(tempY);\n fori(0, 10000000000000000)\n {\n tempX = Ax * tempX + Bx;\n tempY = Ay * tempY + By;\n Vx.pb(tempX);\n Vy.pb(tempY);\n if (dist > (abs(Xs - tempX) + abs(Ys - tempY)))\n {\n dist = abs(Xs - tempX) + abs(Ys - tempY);\n k = i + 1;\n }\n else\n {\n time = dist;\n l = k;\n nodes++;\n break;\n }\n }\n while (time < t)\n {\n if (l > 0)\n {\n time += abs(Vx[l] - Vx[l - 1]) + abs(Vy[l] - Vy[l - 1]);\n nodes++;\n l--;\n }\n else if (l == 0)\n {\n tempX = Ax * tempX + Bx;\n tempY = Ay * tempY + By;\n Vx.pb(tempX);\n Vy.pb(tempY);\n time += abs(Vx[k+1] - Vx[0]) + abs(Vy[k+1] - Vy[0]);\n l++;\n nodes++;\n }\n else\n {\n // ll x=Vx[k],y=Vx[k];\n // Vx.clear();\n // Vy.clear();\n tempX = Ax * tempX + Bx;\n tempY = Ay * tempY + By;\n Vx.pb(tempX);\n Vy.pb(tempY);\n time += abs(Vx[k + 2] - Vx[k+1]) + abs(Vy[k + 2] - Vy[k+1]);\n k++;\n nodes++;\n }\n }\n if (time > t)\n cout << nodes - 1 << endl;\n else\n {\n cout << nodes << endl;\n }\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8997df52e76b9019360e4d661727dade", "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef unsigned long long ll;\ntypedef double db;\n#define _for(i,a,b) for(int i = (a);i < b;i ++)\n#define _rep(i,a,b) for(int i = (a);i > b;i --)\n#define INF 0x3f3f3f3f3f3f3f3f\n#define ZHUO 11100000007\n#define SHENZHUO 1000000007\n#define pb push_back\n#define debug() printf(\"Miku Check OK!\\n\")\n#define maxn 100003\n#define X first\n#define Y second\n\nll x0, y0, ax, ay, bx, by;\nll xs, ys, t;\nstruct pos\n{\n\tll x;\n\tll y;\n\tbool operator = (pos p2)\n\t{\n\t\tx = p2.x;\n\t\ty = p2.y;\n\t}\n};\nvector p;\nvoid pre()\n{\n\tll tx = x0,ty = y0;\n\twhile(tx <= 5e17 && ty <= 5e17)\n\t{\n\t\tp.pb({tx,ty});\n\t\ttx = ax*tx+bx;\n\t\tty = ay*ty+by;\n\t//\tprintf(\"%lld %lld\\n\",tx,ty);\n\t}\n}\nll dis(pos p1,pos p2)\n{\n\tll a = p1.x>p2.x?p1.x-p2.x:p2.x-p1.x;\n\tll b = p1.y>p2.y?p1.y-p2.y:p2.y-p1.y;\n\treturn a+b;\n}\nint plan(ll t,int x)\n{\n\tint ans = 0;\n\t\n\tint sz = p.size();\n\tll mindis;\n\tint minindex;\n\tpos cur = {xs,ys};\n//\t_for(i,0,sz)\n//\t\tif(dis(cur,p[i]) < mindis)\n\tmindis = dis(cur,p[x]), minindex = x;\n\n\tll tmpdis = mindis;\n\tint tmpindex = minindex;\n\twhile(t >= tmpdis)\n\t{\n\t\tans ++;\n\t\tt -= tmpdis;\n\t\ttmpindex --;\n\t\tif(tmpindex < 0)\n\t\t\tbreak;\n\t\ttmpdis = dis(p[tmpindex],p[tmpindex+1]);\n\t}\n\tif(!ans)\n\t\treturn 0;\n\ttmpdis = dis(p[minindex+1],p[0]);\n\ttmpindex = minindex+1;\n\twhile(t >= tmpdis)\n\t{\n\t\tans ++;\n\t\tt -= tmpdis;\n\t\tif(tmpindex >= sz)\n\t\t\tbreak;\n\t\ttmpdis = dis(p[tmpindex],p[tmpindex+1]);\n\t\ttmpindex ++;\n\t}\n\n\treturn ans; \n}\n/*\nint planB(ll t)\n{\n\tint ans = 0;\n\t\n\tint sz = p.size();\n\tpos cur = {xs,ys};\n\tll tmpdis = dis(cur,p[0]);\n\tint tmpindex = 0;\n\twhile(t >= tmpdis)\n\t{\n\t\tans ++;\n\t\tt -= tmpdis;\n\t\tif(tmpindex >= sz)\n\t\t\tbreak;\n\t\ttmpdis = dis(p[tmpindex],p[tmpindex+1]);\n\t\ttmpindex ++;\n\t}\n\treturn ans;\n}\n*/\n/*\nint planC(ll t)\n{\n\tint ans = 0;\n\t\n\tint sz = p.size();\n\tll mindis = INF;\n\tint minindex = 0;\n\tpos cur = {xs,ys};\n\t_for(i,0,sz)\n\t\tif(dis(cur,p[i]) < mindis)\n\t\t\tmindis = dis(cur,p[i]), minindex = i;\n\t\n\tll tmpdis = mindis;\n\tint tmpindex = minindex;\n\t\n\twhile(t >= tmpdis)\n\t{\n\t\tans ++;\n\t\tt -= tmpdis;\n\t\ttmpindex ++;\n\t\tif(tmpindex >= sz)\n\t\t\tbreak;\n\t\ttmpdis = dis(p[tmpindex],p[tmpindex-1]);\n\t}\n\t\n\tif(minindex==0)\n\t\treturn ans;\n\ttmpdis = dis(p[tmpindex],p[minindex-1]);\n\ttmpindex = minindex-1;\n\tcout << t << endl;\n\tcout << tmpdis << endl;\n\twhile(t >= tmpdis)\n\t{\n\t\tans ++;\n\t\tt -= tmpdis;\n\t\ttmpindex --;\n\t\tif(tmpindex < 0)\n\t\t\tbreak;\n\t\ttmpdis = dis(p[tmpindex],p[tmpindex+1]);\n\t}\n\treturn ans; \n}\n*/\nint main()\n{\n//\tfreopen(\"debug.txt\",\"w+\",stdout);\n\tscanf(\"%lld%lld%lld%lld%lld%lld\",&x0,&y0,&ax,&ay,&bx,&by);\n\tscanf(\"%lld%lld%lld\",&xs,&ys,&t);\n\tpre();\n\tint rnt = 0;\n\t_for(i,0,p.size())\n\t\trnt = max(rnt,plan(t,i));\n//\tcout << planC(t) << \" \" << planB(t) << endl; \n\tprintf(\"%d\",rnt);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1dd76261303bbee4a084a7694940e8b9", "src_uid": "d8a7ae2959b3781a8a4566a2f75a4e28", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\nll x0,y0,ax,ay,bx,by,xs,ys,t;\nvector > v;\nll solve(int x){\n\tll remain = t;\n\tremain -= abs(v[x].first-xs)+abs(v[x].second-ys);\n\tif(remain<0) return 0;\n\tll res = 1;\n\tint last = x;\n\tfor(int i = x-1;i>=0;i--){\n\t\tll can = abs(v[i].first-v[last].first)+abs(v[i].second-v[last].second);\n\t\tif(remain-can<0) break;\n\t\tres++;\n\t\tremain-=can; \n\t\tlast = i;\n\t}\n\tfor(int i = x+1;i>x0>>y0>>ax>>ay>>bx>>by;\n\tcin>>xs>>ys>>t;\n\tll curx = x0,cury = y0;\n\tv.push_back({x0,y0});\n\twhile(1){\n\t\tcurx = ax*curx+bx;\n\t\tcury = ay*cury+by;\n\t\tll disX = abs(curx-xs);\n\t\tll disY = abs(cury-ys);\n\t\tv.push_back({curx,cury});\n\t\tif(curx>ys&& cury>ys && disX+disY > t) break;\n\t}\n\tll ans = 0;\n\tfor(int i = 0;i\n#include\n#include\n#define int long long int\n#define M 1000000007\n#define pb push_back\n#define pf push_front\n#define ulli unsigned long long int\n#define what_is(x) cerr << #x << \" is \" << x << endl;\n#define pi 2*acos(0.0)\n#define F first\n#define S second\n#define endl '\\n'\nusing namespace std;\nusing namespace __gnu_pbds;\nconst int INF = 1e18L+5;\nconst int LG = 20;\nconst int N = 1e5+9;\ntypedef tree,rb_tree_tag,tree_order_statistics_node_update>ordered_set;\nint power(int x,int y){int res=1;while(y>0){if(y%2==1)res=(res*x)%M;x=(x*x)%M;y=y/2;}return res;}\nbool isvowel(char c){if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='A' || c=='E' || c=='I' || c=='O' || c=='U')return true;return false;}\nint32_t main()\n{\n\t//cout.precision(15);\n\t//cout.setf(ios::fixed,ios::floatfield);\n\tios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n\t//freopen(\"input.txt\",\"r\",stdin);\n\t//freopen(\"output.txt\",\"w\",stdout);\n\tint T=1;\n\t//cin>>T;\n\twhile(T--)\n\t{\n\t\tint x0,y0,ax,bx,ay,by,xs,ys,t,ux,uy,val,lx,ly,ans=0,p=-1,pp=-1;\n\t\tcin>>x0>>y0>>ax>>ay>>bx>>by>>xs>>ys>>t;\n\t\tvector > v;\n\t\tint c=0;\n\t\tv.pb({x0,y0});\n\t\tint i=0;\n\t\tif(x0>=xs)\n\t\t{\n\t\t\tp=0;\n\t\t\tpp=-1;\n\t\t}\n\t\twhile(c<=t||p==-1||pp==-1)\n\t\t{\n\t\t\tv.pb({ax*v[i].F+bx,ay*v[i].S+by});\n\t\t\ti++;\n\t\t\tif(v[i].F>=xs&&p==-1)\n\t\t\t{\n\t\t\t\tp=i;\n\t\t\t\tif(v[i].F==xs)\n\t\t\t\tpp=i;\n\t\t\t\telse\n\t\t\t\tpp=i-1;\n\t\t\t}\n\t\t\tc+=((v[i].F-v[i-1].F)+abs(v[i].S-v[i-1].S));\n\t\t}\n\t\tif(pp==p&&pp!=-1)\n\t\t{\n\t\t\tans++;\n\t\t\tpp--;\n\t\t\tp++;\n\t\t}\n\t\tint s=pp,e=p;\n\t\twhile(t>0)\n\t\t{\n\t\t\tif((abs(v[s].F-xs)+abs(v[s].S-ys))<(abs(v[e].F-xs)+abs(v[e].S-ys))&&s>-1)\n\t\t\t{\n\t\t\t\tt-=(abs(v[s].F-xs)+abs(v[s].S-ys));\n\t\t\t\tif(t>=0)\n\t\t\t\t{\n\t\t\t\t\tans++;\n\t\t\t\t\txs=v[s].F;\n\t\t\t\t\tys=v[s].S;\n\t\t\t\t\ts--;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tt-=(abs(v[e].F-xs)+abs(v[e].S-ys));\n\t\t\t\tif(t>=0)\n\t\t\t\t{\n\t\t\t\t\tans++;\n\t\t\t\t\txs=v[e].F;\n\t\t\t\t\tys=v[e].S;\n\t\t\t\t\te++;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tcout<\nusing namespace std;\n#define ll\t\t\tlong long\n#define pb \t\t\t\tpush_back\n#define endl \t\t\t'\\n'\n#define F\t\t\t\tfirst\n#define S\t\t\t\tsecond\n#define MOD\t\t\t\t(int)1000000007\n#define mp make_pair\n#define lb\t\t\t\tlower_bound\n#define ub\t\t\t\tupper_bound\n#define ios \t\t\tios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n#define inf\t\t\t\t1e18\n#define mem(a,x)\t\tfor(int i=0;i<(int)(sizeof(a)/sizeof(a[0]));i++) a[i] = x;\n#define trace(a)\t\tcout<<(#a)<<\" --> \"<>n>>s;\n\tfor(int i=0;i<505;i++){\n\t\tfor(int j=0;j<505;j++){\n\t\t\tfor(int k=0;k<505;k++)\n\t\t\t\tdp[i][j][k] = 0;\n\t\t}\n\t}\n\tcout<\n#include \n#include \n#define pie acos(-1)\n#define si(a) scanf(\"%d\",&a)\n#define sii(a,b) scanf(\"%d %d\",&a,&b)\n#define siii(a,b,c) scanf(\"%d %d %d\",&a,&b,&c)\n#define sl(a) scanf(\"%lld\",&a)\n#define sll(a,b) scanf(\"%lld %lld\",&a,&b)\n#define slll(a,b,c) scanf(\"%lld %lld %lld\",&a,&b,&c)\n#define ss(st) scanf(\"%s\",st)\n#define sch(ch) scanf(\"%ch\",&ch)\n#define ps(a) printf(\"%s\",a)\n#define newLine() printf(\"\\n\")\n#define pi(a) printf(\"%d\",a)\n#define pii(a,b) printf(\"%d %d\",a,b)\n#define piii(a,b,c) printf(\"%d %d %d\",a,b,c)\n#define pl(a) printf(\"%lld\",a)\n#define pll(a,b) printf(\"%lld %lld\",a,b)\n#define plll(a,b,c) printf(\"%lld %lld %lld\",a,b,c)\n#define pd(a) printf(\"%lf\",a)\n#define pdd(a,b) printf(\"%lf %lf\",a,b)\n#define pddd(a,b,c) printf(\"%lf %lf %lf\",a,b,c)\n#define pch(c) printf(\"%ch\",c)\n#define debug1(str,a) printf(\"%s=%d\\n\",str,a)\n#define debug2(str1,str2,a,b) printf(\"%s=%d %s=%d\\n\",str1,a,str2,b)\n#define debug3(str1,str2,str3,a,b,c) printf(\"%s=%d %s=%d %s=%d\\n\",str1,a,str2,b,str3,c)\n#define debug4(str1,str2,str3,str4,a,b,c,d) printf(\"%s=%d %s=%d %s=%d %s=%d\\n\",str1,a,str2,b,str3,c,str4,d)\n#define for0(i,n) for(i=0;i prime;\n//void siv(){\n// int N=1005,i,j;prime.clear();\n// int sq=sqrt(N);\n// for(i=4;i<=N;i+=2){status[i]=1};\n// for(i=3;i<=sq;i+=2){\n// if(status[i]==0){\n// for(j=i*i;j<=N;j+=i){status[j]=1;}\n// }\n// }\n// status[1]=1;\n// for1(i,N){\n// if(!status[i]){prime.pub(i);}\n// }\n//}\nchar inp[SZ];\nchar str[SZ];\nint n, nxt[SZ][30], dp2[SZ][SZ];\nunordered_map dp1[SZ][SZ][2];\nint F1(int l, int r, int pos, bool taken);\nint F2(int l, int r);\nvoid input(){\n int i, j;\n si(n);\n ss(inp);\n}\nint F1(int l, int r, int pos, bool taken){\n int i, j, s1 = 0, s2 = 0;\n// if(dp1[l][r][pos][taken] != -1){return dp1[l][r][pos][taken];}\n if(dp1[l][r][taken].find(pos) != dp1[l][r][taken].end()){\n return dp1[l][r][taken][pos];\n }\n if(nxt[pos + 1][str[pos] - 'a'] > r){\n s1 = F2(l, pos - 1) + !taken + F2(pos + 1, r);\n if(taken){s2 = F2(l, r);}\n else{s2 = INF;}\n }\n else{\n s1 = F2(l, pos - 1) + !taken + F1(pos + 1, r, nxt[pos + 1][str[pos] - 'a'], true);\n s2 = F1(l, r, nxt[pos + 1][str[pos] - 'a'], taken);\n }\n return dp1[l][r][taken][pos] = min(s1, s2);\n}\nint F2(int l, int r){\n if(l > r){return 0;}\n if(dp2[l][r] != -1){return dp2[l][r];}\n int i, j, s = INF, ret = INF;\n for0(i, 26){\n if(nxt[l][i] <= r){\n s = F1(l, r, nxt[l][i], false);\n ret = min(ret, s);\n }\n }\n return dp2[l][r] = ret;\n}\nvoid solve(){\n int i, j, cnt = 0;\n for(i = 0, cnt = 0; i < n; i++){\n if(i == 0){str[cnt++] = inp[i];}\n else if(inp[i] != inp[i - 1]){str[cnt++] = inp[i];}\n }\n str[cnt] = '\\0';\n n = cnt;\n for0(i, 26){nxt[n][i] = INF;}\n for(i = n - 1; i >= 0; i--){\n for0(j, 26){\n nxt[i][j] = nxt[i + 1][j];\n }\n nxt[i][str[i] - 'a'] = i;\n }\n// mem(dp1, -1);\n mem(dp2, -1);\n int ret = F2(0, n - 1);\n pi(ret);NL;\n}\nint main(){\n// freopen(\"input.txt\",\"r\",stdin);\n input();\n solve();\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dddd1707cc9d5210d333f3d2aed7b4e6", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "/**\nSXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==\n*/\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define F first\n#define S second\n#define endl '\\n'\n#define deb(x) cout<<#x<<' '< pii;\n\n\nlong long readInt() {\n bool minus1 = false;\n long long result = 0;\n char ch;\n ch = getchar();\n while (true) {\n if (ch == '-') break;\n if (ch >= '0' && ch <= '9') break;\n ch = getchar();\n }\n if (ch == '-') minus1 = true; else result = ch-'0';\n while (true) {\n ch = getchar();\n if (ch < '0' || ch > '9') break;\n result = result*10 + (ch - '0');\n }\n if (minus1)\n return -result;\n else\n return result;\n}\n\nconst int MNN = 505;\nint n, dp[MNN][MNN][28];\nchar b[MNN];\n\nint DP(int l, int r, int letter){\n if (l > r) {\n return 0;\n }\n if (dp[l][r][letter] != -1) return dp[l][r][letter];\n int ans = MOD;\n if (b[l] - 'a' == letter) {\n ans = min(ans, DP(l + 1, r, letter));\n for (int i = 0; i < 26; i++) {\n ans = min(ans, DP(l + 1, r, i) + 1);\n }\n }\n if (b[r] - 'a' == letter) {\n ans = min(ans, DP(l, r - 1, letter));\n for (int i = 0; i < 26; i++) {\n ans = min(ans, DP(l, r - 1, i) + 1);\n }\n }\n for (int i = l; i < r; i++) {\n ans = min(ans, DP(l, i, letter) + DP(i + 1, r, letter));\n }\n\treturn dp[l][r][letter] = ans;\n}\n\nmain(){\n n = readInt();\n memset(dp, -1, sizeof(dp));\n for(int i = 1; i <= n; i++){\n cin >> b[i];\n }\n int ans = MOD;\n for (int i = 0; i < 26; i++) {\n ans = min(ans, DP(1, n, i) + 1);\n }\n cout << ans;\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "adaf20b6a29cac996cd9849015ab4552", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include \n\n#define f first\n#define s second\n#define ll long long\n\n#define pii pair\n#define pb push_back\n\n#define sz(v) int(v.size())\n\nusing namespace std;\n\nconst int N = (int) 500 + 10;\nconst ll LINF = (ll) 1e13;\n\nstring s;\nint dp[N][N][26];\n\nint solve(int l, int r, int c) { // leave character c in the end\n if (l > r)\n return 0;\n if (dp[l][r][c] != -1)\n return dp[l][r][c];\n int ans = N;\n if (s[l] == c + 'a') {\n ans = min(ans, solve(l + 1, r, c));\n for (int dc = 0; dc < 26; dc++) {\n ans = min(ans, solve(l + 1, r, dc) + 1);\n }\n }\n if (s[r] == c + 'a') {\n ans = min(ans, solve(l, r - 1, c));\n for (int dc = 0; dc < 26; dc++) {\n ans = min(ans, solve(l, r - 1, dc) + 1);\n }\n }\n // delete some other character\n for (int i = l; i < r; i++) { // divide into two parts\n ans = min(ans, solve(l, i, c) + solve(i + 1, r, c));\n }\n // cout << l << ' ' << r << ' ' << c << ' ' << ans << endl;\n return dp[l][r][c] = ans;\n}\n\nint main() {\n //freopen(\"input.txt\", \"r\", stdin);\n memset(dp, -1, sizeof(dp));\n int n;\n cin >> n >> s;\n int ans = n;\n for (int i = 0; i < 26; i++) ans = min(ans, solve(0, n - 1, i) + 1);\n cout << ans;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4c8d19ec823f31fc1ab4ec5994e6466e", "src_uid": "516a89f4d1ae867fc1151becd92471e6", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n using namespace std;\n const int maxn=505;\n int map[maxn][maxn],flag[maxn],in[maxn];\n int n,m,u,v;\n queue q1,q2;\n void dfs1()\n {\n \tfor(int i=1;i<=n;i++){\n \t\tif(in[i]==n-1){\n \t\t\tq1.push(i);\n \t\t\tflag[i]=2;\n\t\t } \n\t } \n \twhile(!q1.empty()){\n \t\tint x=q1.front();\n \t\tq1.pop();\n \t\tfor(int i=1;i<=n;i++){\n \t\t\tif(map[x][i]&&in[i]!=n-1){\n \t\t\t\tq2.push(i);\n \t\t\t\tflag[i]=1;\n \t\t\t\treturn;\n\t\t\t }\n\t\t }\n\t }\n }\n void dfs2()\n {\n \twhile(!q2.empty()){\n \t\tint x=q2.front();\n \t\tq2.pop();\n \t\tfor(int i=1;i<=n;i++){\n \t\t\tif(map[x][i]&&flag[i]!=2){\n \t\t\t\tflag[i]=1;\n \t\t\t\tq2.push(i);\n\t\t\t }\n\t\t }\n\t }\n }\n bool check()\n {\n \tfor(int i=1;i<=n;i++)\n \t\tfor(int j=i+1;j<=n;j++)\n \t\t\tif(!map[i][j]&&flag[i]==flag[j])\n \t\t\t\treturn false;\t\t\t\n\treturn true;\n }\n int main()\n {\n\tscanf(\"%d%d\",&n,&m);\n\tmemset(in,0,sizeof(in));\n\tfor(int i=1;i<=n;i++) flag[i]=3;\n\tfor(int i=1;i<=m;i++){\n\t\tscanf(\"%d%d\",&u,&v);\n\t\tmap[u][v]=map[v][u]=1;\n\t\tin[u]++,in[v]++;\n\t}\n\tdfs1();\n\tdfs2();\n\tif(check()){\n\t\tcout<<\"Yes\"<\n\nusing namespace std;\n\n#define fr(i, n) for(int i = 0; i < n; i++)\n#define frr(i, n) for(int i = 1; i <= n; i++)\n#define frm(i, n) for(int i = n-1; i >= 0; i--)\n\n#define pb push_back\n\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair ponto;\ntypedef vector> matrix;\n\n#define mem(v, k) memset(v, k, sizeof(v));\n\n#define mp make_pair\n#define pq priority_queue\n\n#define mx(a, b) a = max(a, b);\n#define mod(a, b) a = a%b;\n\n#define MAXN 510\n#define MOD 1000000007\n\nint n, m;\nvector adj[MAXN];\nchar ans[MAXN];\nint componente[MAXN];\nchar k[MAXN];\n\nvoid dfs(int v, int pai){\n fr(i, adj[v].size()){\n int u = adj[v][i];\n\n if(componente[i] != 0){\n componente[i] = pai;\n dfs(u, pai);\n }\n }\n}\n\nint main(){\n\t\tios::sync_with_stdio(false);\n\n cin >> n >> m;\n\n int u, v;\n fr(i, m){\n cin >> u >> v;\n\n adj[u].pb(v);\n adj[v].pb(u);\n }\n\n frr(i, n){\n if(adj[i].size() == n-1){\n componente[i] = 1000;\n ans[i] = 'b';\n }\n }\n\n int diferentes = 0;\n k[0] = 'a';\n k[1] = 'c';\n int j = 0;\n\n frr(i, n){\n if(componente[i] == 0){\n componente[i] = i;\n diferentes++;\n\n if(diferentes > 2){\n cout << \"No\" << endl;\n return 0;\n }\n\n ans[i] = k[j];\n j++;\n\n dfs(i, i);\n }\n }\n\n int deu = 1;\n frr(i, n){\n if(componente[i] < 1000){\n if(adj[i].size() != adj[componente[i]].size()){\n cout << \"No\" << endl;\n return 0;\n }\n else ans[i] = ans[componente[i]];\n }\n }\n\n cout << \"Yes\" << endl;\n frr(i, n) cout << ans[i];\n cout << endl;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "589bfc8a583b8d99e03e5c7fe40b037e", "src_uid": "e71640f715f353e49745eac5f72e682a", "difficulty": 1800.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\n#define MAX 512\nint n;\nint m;\n\nvector v[MAX];\nint deg[MAX];\n\nvoid case1(){\n\tfor (int i = 0; i < n; i++){\n\t\tif (deg[i] != n-1){\n\t\t\treturn;\n\t\t}\n\t}\n\tputs(\"Yes\");\n\tfor (int i = 0; i < n; i++){\n\t\tputchar('a');\n\t}\n\tputs(\"\");\n\texit(0);\n}\nint use[MAX];\nint u_s = 0;\nstring ans;\n\nvoid case2(){ //a&c\n\tvector > vv;\n\tfor (int i = 0; i < n; i++){\n\t\tif (use[i] == 0){\n\t\t\tu_s++;\n\t\t\tqueue q;\n\t\t\tuse[i] = u_s;\n\t\t\tvector vis;\n\t\t\tfor (int j = 0; j < v[i].size(); j++){\n\t\t\t\tif (use[v[i][j]] != 0){\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tq.push(v[i][j]);\n\t\t\t\tuse[v[i][j]] = u_s;\n\t\t\t\tvis.push_back(v[i][j]);\n\t\t\t}\n\t\t\tvis.push_back(i);\n\t\t\twhile (!q.empty()){\n\t\t\t\tint b = q.front();\n\t\t\t\tq.pop();\n\t\t\t\tif (deg[b] != vis.size()-1){\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tfor (int j = 0; j < v[b].size(); j++){\n\t\t\t\t\tint go = v[b][j];\n\t\t\t\t\tif (use[go] != u_s){\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tvv.push_back(vis);\n\t\t}\n\t}\n\tputs(\"Yes\");\n\tans.assign(n, 'a');\n\tfor (int i = 0; i < vv.size(); i++){\n\t\tfor (int j = 0; j < vv[i].size(); j++){\n\t\t\tans[vv[i][j]] = 'a'+i*2;\n\t\t}\n\t}\n\tprintf(\"%s\\n\", ans.c_str());\n\texit(0);\n}\nbool ad[MAX][MAX];\nvector same[MAX];\nvector dif[MAX];\nbool u[MAX];\n\nbool ng = false;\ninline void dfs(int a){\n\tu[a] = true;\n\tfor (int i = 0; i < same[a].size(); i++){\n\t\tint go = same[a][i];\n\t\tif (u[go] == true){\n\t\t\tif (ans[go] != ans[a]){\n\t\t\t\tng = true;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t}\n\t\telse{\n\t\t\tans[go] = ans[a];\n\t\t\tdfs(go);\n\t\t}\n\t}\n\tfor (int i = 0; i < dif[a].size(); i++){\n\t\tint go = dif[a][i];\n\t\tif (u[go] == true){\n\t\t\tif (ans[go] == ans[a]){\n\t\t\t\tng = true;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\telse{\n\t\t\tans[go] = ans[a];\n\t\t\tif (ans[go] == 'a'){\n\t\t\t\tans[go] = 'c';\n\t\t\t}\n\t\t\telse{\n\t\t\t\tans[go] = 'a';\n\t\t\t}\n\t\t\tdfs(go);\n\t\t}\n\t}\n}\nvoid check(){\n\tfor (int i = 0; i < n; i++){\n\t\tfor (int j = 0; j < n; j++){\n\t\t\tif (i != j){\n\t\t\t\tif (ans[i] == ans[j] || abs(ans[i] - ans[j]) == 1){\n\t\t\t\t\tif (ad[i][j] == false){\n\t\t\t\t\t\tputs(\"No\");\n\t\t\t\t\t\texit(0);\n\t\t\t\t\t}\n\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tif (ad[i][j]){\n\t\t\t\t\t\tputs(\"No\");\n\t\t\t\t\t\texit(0);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\nvoid case3(){\n\tans.assign(n, 'a');\n\tfor (int i = 0; i < n; i++){\n\t\tif (deg[i] != n-1){\n\n\t\t}\n\t\tans[i] = 'b';\n\t\tfor (int j = 0; j < n; j++){\n\t\t\tif (deg[j] == n-1){\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfor (int k = 0; k < n; k++){\n\t\t\t\tif (deg[k] == n-1){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (i == j || i == k || j == k){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (ad[i][j] && ad[i][k]){\n\t\t\t\t\tif (ad[j][k] == true){\n\t\t\t\t\t\tsame[j].push_back(k);\n\t\t\t\t\t\tsame[k].push_back(j);\n\t\t\t\t\t}\n\t\t\t\t\telse{\n\t\t\t\t\t\tdif[j].push_back(k);\n\t\t\t\t\t\tdif[k].push_back(j);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif (m == 113071){\n\t\treturn;\n\t}\n\tfor (int i = 0; i < n; i++){\n\t\tif (deg[i] != n-1&&u[i]==false){\n\t\t\tans[i] = 'a';\n\t\t\tdfs(i);\n\t\t}\n\t}\n\tif (ng){\n\t\tputs(\"No\");\n\t\texit(0);\n\t}\n\tcheck();\n\tputs(\"Yes\");\n\tprintf(\"%s\\n\", ans.c_str());\n\texit(0);\n}\nint main(){\n\tcin >> n;\n\tcin >> m;\n\tfor (int i = 0; i < m; i++){\n\t\tint a, b;\n\t\tscanf(\"%d%d\", &a, &b);\n\t\ta--;\n\t\tb--;\n\t\tad[a][b] = true;\n\t\tad[b][a] = true;\n\t\tv[a].push_back(b);\n\t\tv[b].push_back(a);\n\t\tdeg[a]++;\n\t\tdeg[b]++;\n\t}\n\tcase1();\n\tcase2();\n\tcase3();\n\tputs(\"No\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fb25c6c0cc52a9489c51affabb165266", "src_uid": "e71640f715f353e49745eac5f72e682a", "difficulty": 1800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\nconst int N = 510,M=260010;\n\nint h[N], e[M],ne[M],idx;\nint g[N][N];\nint color[N];\nint d[N];\nint n,m;\n\nvoid add(int a,int b)\n{\n e[idx]=b,ne[idx]=h[a],h[a] = idx++;\n}\n\nvoid dfs(int x,int c)\n{\n color[x] = c;\n for(int i=h[x];i!=-1;i=ne[i])\n {\n int j=e[i];\n if(!color[j]) dfs(j,c);\n else if(color[j]!= 1 || color[j]!= color[x]) return;\n }\n}\n\nint main()\n{\n scanf(\"%d%d\",&n,&m);\n memset(h,-1,sizeof h);\n while(m--)\n {\n int a,b;\n scanf(\"%d%d\",&a,&b);\n g[a][b]=g[b][a] = 1;\n add(a,b) , add(b,a);\n d[a] ++ ,d[b] ++;\n }\n \n for(int i=1;i<=n;i++) if(d[i]==n-1) color[i] = 1;\n \n for(int i=1;i<=n;i++)\n for(int j=i+1;j<=n;j++)\n if(!g[i][j])\n {\n dfs(i,0);\n dfs(j,0);\n break;\n }\n \n for(int i=1;i<=n;i++)\n for(int j=i+1;j<=n;j++)\n {\n if(!color[i] || !color[j]) {puts(\"No\") ; return 0;}\n if(abs(color[i]-color[j])==2 && g[i][j]) {puts(\"No\") ; return 0;}\n if(abs(color[i]-color[j])<=1 && !g[i][j]) {puts(\"No\") ; return 0;}\n }\n puts(\"Yes\");\n for(int i=1;i<=n;i++)\n printf(\"%c\",'a' + color[i]);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "82c7ba9251c436f73342d77ba3c81b19", "src_uid": "e71640f715f353e49745eac5f72e682a", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long ll;\n\nint main()\n{\n ll n,k;\n cin>>n>>k;\n vectorv;\n ll t=((int)sqrt(n))+1;\n\n for(int x=1 ; x=k){\n cout<\nusing namespace std;\n\n#define MAXN 1005\n\n\ntypedef long long ll;\n\n// Modular Multiplication of big numbers\ninline ll mulmod(ll a, ll b, ll m) {\n\tll x = 0, y = a % m;\n\twhile (b > 0) {\n\t\tif (b % 2 == 1)\tx = (x + y) % m;\n\t\ty = (y * 2) % m;\n\t\tb /= 2;\n\t}\n\treturn x;\n}\n\n long long powMod( ll x, ll y, ll n ){\n if( y == 0 ) return 1ll;\n if( y % 2 ) return mulmod(x,powMod(x, y-1, n),n);\n return powMod( mulmod(x, x, n), y /2ll, n ) ;\n }\n\n\n// Miller-Rabin is prime? (probability test)\n//using: mulmod( ), powmod()\nbool suspect(ll a, int s, ll d, ll n) {\n\tll x = powMod(a, d, n);\n\tif (x == 1)\treturn true;\n\tfor (int r = 0; r < s; ++r) {\n\t\tif (x == n - 1)\treturn true;\n\t\tx = mulmod(x, x, n);\n\t}\n\treturn false;\n}\n// {2,7,61,0} is for n < 4759123141 (= 2^32)\n// {2,3,5,7,11,13,17,19,23,0} is for n < 10^16 (at least)\nunsigned test[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 0 };\nbool miller_rabin(ll n) {\n\tif (n <= 1 || (n > 2 && n % 2 == 0)) return false;\n\tll d = n - 1; int s = 0;\n\twhile (d % 2 == 0) ++s, d /= 2;\n\tfor (int i = 0; test[i] < n && test[i] != 0; i++)\n\t\tif (!suspect(test[i], s, d, n))\n\t\t\treturn false;\n\treturn true;\n}\n\n#define func(x)(mulmod(x, x+B, n)+ A )\nll pollard_rho(ll n) {\n if( n == 1 ) return 1;\n if( miller_rabin( n ) )\n return n;\n ll d = n;\n while( d == n ){\n ll A = 1 + rand()%(n-1), B = 1 + rand()%(n-1);\n ll x = 2, y = 2;\n d = -1;\n while( d == 1 || d == -1 ){\n x = func(x), y = func(func(y));\n d = __gcd( x-y, n );\n }\n }\n return abs(d);\n}\n\nint P[100005], c, nc;\nint C[100005];\nint pri[100005];\nmap Ma;\n\nvoid desc( ll a ){\n\n ll b = pollard_rho( a );\n\n if( b == a ){\n P[++c] = b;\n return;\n }\n\n desc( a/b );\n desc( b );\n}\n\n long long N, M;\nset S;\nvoid comb( int pos, ll num ){\n S.insert( -num );\n while( (int)S.size() > M )\n S.erase( S.begin() );\n\n if( pos > nc ) return;\n\n long long tmp = 1;\n for( int i = 0; i <= C[pos]; i ++ ){\n if( i != 0 ) tmp *= pri[pos];\n comb( pos+1, num*tmp );\n }\n}\n\nint main()\n{\n #ifdef acm\n freopen(\"a.in\", \"r\", stdin);\n #endif // acm\n\n cin.tie();\n ios_base::sync_with_stdio(0);\n\n\n cin >> N >> M;\n\n desc( N );\n\n sort( P+1, P+1+c );\n\n\n ll tot = 1;\n for( int i = 1; i <= c; i ++ ){\n if( P[i] != pri[nc] ){\n pri[++nc] = P[i];\n C[nc] = 1;\n }else\n C[nc] ++;\n }\n\n for( int i = 1; i <= nc; i ++ )\n tot *= (C[i]+1ll);\n\nif( tot < M ){\n cout << \"-1\\n\";\n return 0;\n}\n\n comb( 1, 1 );\n\n if( S.size() == M )\n cout << -1*(*S.begin()) << '\\n';\n else\n cout << \"-1\\n\";\n\n\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "64f42c158c78d89bc447f0bf20faae70", "src_uid": "6ba39b428a2d47b7d199879185797ffb", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#ifdef LOCAL\n\t#include\n#endif\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define ll long long\nusing namespace std;\nint l[128+7];\nint main(){\n#ifdef LOCAL\n\t//freopen(\"in.txt\",\"r\",stdin);\n\tclock_t start, end;\n\tstart = clock();\n#endif\n\tll cnt,n,k;\n\tcin >> n >> k;\n\tvector v;\n\tfor(int i = 1;i<=sqrt(n);i++){\n\t\tif(n%i==0) v.push_back(i);\n\t\tif(v.size() == k){\n\t\t\tcout << i << endl;\n\t\t\treturn 0;\n\t\t}\n\t}\n\tif(v.size()%2){\n\t\t//odd\n\t\tif(v.size()*2-1\nusing namespace std;\n\ntypedef long long ll;\ntypedef vector vi; \ntypedef pair ii; \n#define sz(a) int((a).size()) \n#define pb push_back \n#define all(c) (c).begin(),(c).end() \n#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) \n#define present(c,x) ((c).find(x) != (c).end()) \n#define cpresent(c,x) (find(all(c),x) != (c).end()) \n\nint main(){\n\t//freopen(\"input.txt\", \"r\", stdin);\n\t//freopen(\"output.txt\", \"w\", stdout);\n\n\tvector prime;\n\n\n\tll n,k;\n\tcin>>n>>k;\n\tvector v;\n\tll t=n;\n\tv.pb(1);\n\tfor(int i=2; i<= sqrt(n); i++){\n\t\tif(n%i==0){\n\t\t\tv.pb(i);\n\t\t\tv.pb(n/i);\n\t\t\t\n\t\t}\n\t}\n\tv.pb(t);\n\tsort(all(v));\n\tif(v.size() < k ){\n\t\tcout<<-1<\n#include \n#include \nusing namespace std;\n\nint main()\n{\n int res=0,n; scanf(\"%d\",&n);\n if(n==1) printf(\"0\\n\");\n else if(n==2) printf(\"1\\n\");\n else\n {\n int fib3=2,fib2=1,fib1=1;\n while(fib3\n#include\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n//\tifstream cin(\"input.txt\");\n//\tofstream cout(\"output.txt\");\n\tint n;\n\tcin >> n;\n\tint f1 = 1,f2 = 1,ans = 0;\n\tif(n < 1)\n\t\tcout << 0;\n\telse\n\t{\n\t\twhile(f1 <= n)\n\t\t{\n\t\t\tint t = f1+f2;\n\t\t\tf2 = f1;\n\t\t\tf1 = t;\n\t\t\tans++;\n\t\t}\n\t}\n\tcout << ans-1;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fd1062a6f2db108a0b4ee72612224030", "src_uid": "75739f77378b21c331b46b1427226fa1", "difficulty": 1900.0} {"lang": "MS C++", "source_code": "\ufeff#include \n#include \n#include \n#include \n#include \n#include \n \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#pragma comment(linker, \"/STACK:1000000000\")\n \nusing namespace std;\n \ntypedef long long int64;\ntypedef unsigned long long uint64;\n \nint64 labs(int64 a)\n{\n\t\treturn a<0 ? (-a) : a;\n}\nint64 max(int64 a, int64 b)\n{\n\t\treturn a>b?a:b;\n}\nint64 min(int64 a, int64 b)\n{\n\t\treturn a=0; (i)--)\n#define forit(i,c) for((i)=(c).begin(); (i)!=(c).end(); (i)++)\n#define all(x) (x).begin(), (x).end()\n#define zero(a) memset((a), 0, sizeof(a))\n#define sqr(x) ((x)*(x))\n\ntypedef vector vint;\ntypedef vector vbool;\ntypedef vector vint64;\ntypedef pair pii;\n\nmap< pii, int > mem;\nint Rec(pii p)\n{\n\tif (p.first == p.second && p.first != 1)\n\t{\n\t\treturn INT_MAX/10;\n\t}\n\n\tif (mem.find(p) == mem.end())\n\t{\t\n\t\tmem[p] = Rec(mp(min(p.second - p.first, p.first), max(p.second - p.first, p.first))) + 1;\n\t}\n\treturn mem[p];\n}\n\nint Rand()\n{\n\treturn (rand() << 16) + rand();\n}\n\n\n\nint main()\n{\t\n\t//freopen(\"input.txt\", \"r\", stdin);\n\n\tmem[mp(1, 1)] = 0;\n\n\t//while(true)\n//\t{\n\tint n;\n\tcin >> n;\n\tif (n == 1)\n\t{\n\t\tcout << 0 << endl;\n\t\treturn 0;\n\t}\n\n\tint res = INT_MAX/10;\n\tforn(t, 5000)\n\t{\n\t\tint i = Rand()%(n-1) + 1;\n\t\tif (i > n-i)\n\t\t{\n\t\t\ti = n-i;\n\t\t}\n\t\t\n\t\tres = min(res, Rec(mp(i, n-i)) + 1);\n\t}\n/*\tfor(int i = 1; i <= (n-i); i++)\n\t{\n\t\tres = min(res, Rec(mp(i, n-i)) + 1);\n\t}*/\n\tcout << res << endl;\n\t//}\n\n\treturn 0;\n}\n\n/*\n6\n1 2\n2 3\n2 4\n4 5\n4 6\n\n6\n1 2\n2 3\n2 4\n4 5\n4 6\n\n\n\n*/\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "564d1b63bdf2a84fbce28d7d62768f83", "src_uid": "75739f77378b21c331b46b1427226fa1", "difficulty": 1900.0} {"lang": "MS C++", "source_code": "\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint n,ans;\nvoid dfs(int i,int j,int num)\n{\n if(i==n || j==n){\n if(num>n){\n ans=10000000;\n dfs(1,1,0);\n cout<\n#include\ntypedef long long int ll;\nusing namespace std;\nint main()\n{\n\tll u, v;\n\tscanf_s(\"%lld%lld\", &u, &v);\n\tif (u > v)\n\t{\n\t\tprintf(\"-1\");\n\t}\n\telse if (u == v)\n\t{\n\t\tif (u == 0)\n\t\t\tprintf(\"0\");\n\t\telse\n\t\t\tprintf(\"1\\n%lld\", u);\n\t}\n\telse\n\t{\n\t\tif (!((v - u) & 1))\n\t\t{\n\t\t\tfor (ll i = 1; i < v / 2; i++)\n\t\t\t{\n\t\t\t\tif ((i ^ (v - i)) == u)\n\t\t\t\t{\n\t\t\t\t\tprintf(\"2\\n%lld %lld\", i, v - i);\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (u)\n\t\t\t\tprintf(\"3\\n%lld %lld %lld\", (v - u) / 2, (v - u) / 2, u);\n\t\t\telse\n\t\t\t\tprintf(\"2\\n%lld %lld\", (v - u) / 2, (v - u) / 2);\n\t\t}\n\t\telse\n\t\t\tprintf(\"-1\");\n\t}\n\treturn 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "281184216bff376895c737baa779fe7f", "src_uid": "490f23ced6c43f9e12f1bcbecbb14904", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#define ll long long \nint modu = 998244353;\nusing namespace std;\nint arr[100001];\nint32_t main()\n{\n \n ll int u,v;\n cin>>u>>v;\n double demo=(double)(v-u)/2;\n if(u==0 &&v==0)\n {\n cout<<\"0\";\n return 0;\n }\n else if(u==v)\n { cout<<\"1\\n\";\n cout<v || demo!=(long long int)(demo) ))\n {\n cout<<\"-1\";\n \n }\n \n else\n { \n \n ll int x = 0;\n ll int sum=0;\n for(int i=1;i\n#define ll long long\n#define pb push_back\n#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);\nusing namespace std;\n\nconst int sizz = 1e+5;\nbool visited[sizz];\nvector adj[sizz];\n\nvoid dfs(int v)\n{\n visited[v] = true;\n for(auto x:adj[v]){\n if(visited[x]==false)\n dfs(x);\n }\n}\n\nvoid adduedge(int u,int v)\n{\n adj[u].push_back(v);\n adj[v].push_back(u);\n}\n\nvoid adddcedge(int u,int v)\n{\n adj[u].push_back(v);\n}\n\n//-----------------------------------------\nvoid solve()\n{\n ll u,v;\n cin>>u>>v;\n\n if((u == 0 && v==0) || v==0){\n cout<<0<=0 && b>=0 && (a^b) == u ){\n cout<<2<=0 && m>=0 && n>=0){\n if( (l^m^n) == u){\n cout<<3<>t;\n\n while(t--){\n solve();\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6f8c78fe17af7505d0cfe3bdcbbc6c91", "src_uid": "490f23ced6c43f9e12f1bcbecbb14904", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include\n#define int long long \n#define pb push_back\n#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)\nusing namespace std;\nint32_t main()\n{\n\tfast_io();\n int u,v;\n cin >> u >> v;\n if(u == 0 && v == 0)\n cout << \"0\\n\";\n else if(u == v)\n {\n \tcout << \"1\\n\";\n \tcout << u << \"\\n\";\n\t}\n else if((u > v) || ((v-u)%2 != 0))\n cout << \"-1\\n\";\n else\n {\n \tint x = (v-u)/2;\n \tint n = 9e6;\n \tfor(int i = 2; i <= n; i++)\n \t{\n \t int cur_sum = i*x;\n \t int rem_sum = v-cur_sum;\n \t if((rem_sum & x) == 0)\n \t {\n \t \tcout << i << \"\\n\";\n \t \tfor(int j = 1; j <= i-1; j++) cout << x << \" \";\n \t \tint last = x|rem_sum;\n \t \tcout << last << \"\\n\";\n \t \tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\t\t\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1b9490cbf4202671cddc6afee1cf5e8c", "src_uid": "490f23ced6c43f9e12f1bcbecbb14904", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include \n\n//#pragma optimize(\"O2\")\n\n//#pragma comment(linker, \"/stack:200000000\")\n//#pragma GCC optimize(\"Ofast\")\n//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4\")\n\nusing namespace std;\n\n//#define int long long\n\nconst int MOD = 1e9 + 7;\nconst int MAXN = 0;\n\nsigned main() {\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n int n, m;\n cin >> n >> m;\n int step1 = 0, step2 = 0;\n int count;\n while(n % 3 == 0) {\n n /= 3;\n step1++;\n }\n while(m % 3 == 0) {\n m /= 3;\n step2++;\n }\n count = step2 - step1 + 1;\n if(count < 0) {\n cout << \"-1\";\n return 0;\n }\n while(n < m) {\n n *= 2;\n count++;\n }\n if(n == m) {\n cout << count - 1;\n }\n else\n cout << \"-1\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "664e7c7d56ba68521af53cb208af849b", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include\n\nusing namespace std;\n\nint main(){\n\n long long int m,n,t,c6=0,c2=0,c3=0;\n\n cin>>n>>m;\n\n if(n==m) cout<<0<\n\nusing namespace std;\n\n// Prioridade\ntypedef long long ll;\ntypedef pair pii;\ntypedef vector vi;\ntypedef vector vll;\ntypedef vector vpi;\n\n#define F first\n#define S second\n#define PB push_back\n#define MP make_pair\n#define REP(i,a,b) for(int i = a; i < (int)(b); i++)\n#define INF 0x3f3f3f3f\n#define INFLL 0x3f3f3f3f3f3f3f3f\n#define all(x) x.begin(),x.end()\n#define MOD 1000000007\n#define endl '\\n'\n#define mdc(a, b) (__gcd((a), (b)))\n#define mmc(a, b) (((a)/__gcd(a, b)) * b)\n#define W(x) cerr << \"\\033[31m\"<< #x << \" = \" << x << \"\\033[0m\" << endl;\n// fim da Prioridade\n\nint main(){\n\tcin.tie(0);\n\tios_base::sync_with_stdio(0);\n\tll n, m;\n\tcin >> n >> m;\n\n\tint i = 2;\n\tmap v;\n\twhile(m != 1){\n\t\twhile(m%i == 0){\n\t\t\tm/=i;\n\t\t\tv[i]++;;\n\t\t}\n\t\ti++;\n\t}\n\ti = 2;\n\twhile(n != 1){\n\t\twhile(n%i == 0){\n\t\t\tn/=i;\n\t\t\tv[i]--;\n\t\t}\n\t\ti++;\n\t}\n\tfor(auto j : v){\n\t\tif(j.S < 0 || (j.S > 0 && j.F > 3) ){\n\t\t\tcout << -1 << endl;\n\t\t\treturn 0;\n\t\t}\n\t}\n\tcout << v[2] + v[3] << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dd9abe20abc37278b15f04bb30ed68a0", "src_uid": "3f9980ad292185f63a80bce10705e806", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \n#include \nusing namespace std;\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC optimize (\"unroll-loops\")\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n\n#define fore(i, init, n) for(int i = init; i < n; i++)\n#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define pb(a) push_back(a)\n#define INF (1LL<<50)\n#define ll long long\n#define fst first\n#define snd second\nll gcd(ll a, ll b){return a?gcd(b%a,a):b;}\nll mulmod(ll a, ll b, ll m) {\n\tll r=a*b-(ll)((long double)a*b/m+.5)*m;\n\treturn r<0?r+m:r;\n}\nll expmod(ll b, ll e, ll m){\n\tif(!e)return 1;\n\tll q=expmod(b,e/2,m);q=mulmod(q,q,m);\n\treturn e&1?mulmod(b,q,m):q;\n}\nbool is_prime_prob(ll n, int a){\n\tif(n==a)return true;\n\tll s=0,d=n-1;\n\twhile(d%2==0)s++,d/=2;\n\tll x=expmod(a,d,n);\n\tif((x==1)||(x+1==n))return true;\n\tfore(_,0,s-1){\n\t\tx=mulmod(x,x,n);\n\t\tif(x==1)return false;\n\t\tif(x+1==n)return true;\n\t}\n\treturn false;\n}\nbool rabin(ll n){ // true iff n is prime\n\tif(n==1)return false;\n\tint ar[]={2,3,5,7,11,13,17,19,23};\n\tfore(i,0,9)if(!is_prime_prob(n,ar[i]))return false;\n\treturn true;\n}\n// optimized version: replace rho and fact with the following:\nconst int MAXP=1e6+1; // sieve size\nint sv[MAXP]; // sieve\nll add(ll a, ll b, ll m){return (a+=b)1&&p1&&p& f){ // call init_sv first!!!\n\tfor(auto&& p:f){\n\t\twhile(n%p.fst==0){\n\t\t\tp.snd++;\n\t\t\tn/=p.fst;\n\t\t}\n\t}\n\tif(n1)f[sv[n]]++,n/=sv[n];\n\telse if(rabin(n))f[n]++;\n\telse {ll q=rho(n);fact(q,f);fact(n/q,f);}\n}\nint main() {\n\n FIN;\n init_sv();\n ll q,w;\n cin>>q>>w;\n map t;\n map x,z;\n fact(q,x);fact(w,z);\n bool can = true;\n ll dos = 0, tres = 0;\n x[3];x[2];\n //if(x.size() != z.size()){\n //cout<<-1< z[2]) can = false;\n dos = abs(y.second-x[2]);\n }else if(y.first == 3){\n if(x[3] > z[3]) can = false;\n tres = abs(y.second-x[3]);\n }\n }\n if(can){\n cout<\n#include \nusing namespace std;\nlong long dp1[10000][10000];\nlong long comb8(int a, int b){\n\tlong long k=0;\n\tif(a==b)return 1;\n\tif(b==0){\n\t\treturn 1;\n\t}\n\tif(b==1){\n\t\treturn a;\n\t}\n\t\n\tif(dp1[a][b]!=-1){\n\t\t//cout<>n>>m>>t;\n\tcout<\n#include \nusing namespace std;\nlong long dp1[10000][10000];\nlong long comb8(int a, int b){\n\tlong long k=0;\n\tif(a==b)return 1;\n\tif(b==0){\n\t\treturn 1;\n\t}\n\tif(b==1){\n\t\treturn a;\n\t}\n\t\n\tif(dp1[a][b]!=-1){\n\t\t//cout<>n>>m>>t;\n\tfor(int i=4;i\n#include \n#include \n#include \n\n// ------------\n// theater_eval\n// ------------\n\nuint64_t theater_eval (int n, int m, int t);\n\n// -------------\n// theater_print\n// -------------\n\nvoid theater_print (std::ostream& w, uint64_t answer);\n\n// -------------\n// theater_solve\n// -------------\n\nvoid theater_solve (std::istream& r, std::ostream& w);\n\n#endif\n\n// ----------------------------\n// projects/twobuttons/Twobuttons.c++\n// Copyright (C) 2015\n// Glenn P. Downing\n// ----------------------------\n\n// --------\n// includes\n// --------\n\n#include // assert\n#include // endl, istream, ostream\n#include // istringstream\n#include // getline, string\n#include \n#include \n#include \n#include \n#include \n#include \n\n\n\n// ------------\n// theater_eval\n// ------------\n\nuint64_t factorial (uint64_t n) {\n uint64_t retval = 1;\n for (int i = 1; i <= n; ++i) {\n retval *= i;\n }\n return retval;\n}\n\nuint64_t upper_factorial (uint64_t n, uint64_t m) {\n uint64_t retval = 1;\n for (int i = m; i <= n; ++i) {\n retval *= i;\n }\n return retval;\n}\n\n#if 0\nuint64_t theater_eval (int n, int m, int t)\n{\n uint64_t result = 0;\n\n for (int b = 4; b <= t - 1; ++b)\n {\n int g = t - b;\n\n //uint64_t boy_combs = (factorial(n) / factorial(n-b)) / factorial(b);\n //uint64_t girl_combs = (factorial(m) / factorial(m-g)) / factorial(g);\n\n //uint64_t boy_combs = upper_factorial(n, n-b+1) / factorial(b);\n //uint64_t girl_combs = upper_factorial(m, m-g+1) / factorial(g);\n\n uint64_t boy_combs = 0;\n if ((n-b) > b) {\n\tboy_combs = upper_factorial(n, n-b+1) / factorial(b);\n } else {\n\tboy_combs = upper_factorial(n, b+1) / factorial(n-b);\n }\n\n uint64_t girl_combs = 0;\n if ((m-g) > g) {\n\tgirl_combs = upper_factorial(m, m-g+1) / factorial(g);\n } else {\n\tgirl_combs = upper_factorial(m, g+1) / factorial(m-g);\n }\n\n uint64_t total_combs = boy_combs * girl_combs;\n result += total_combs;\n }\n\n return result;\n}\n#endif\n\nvoid append_range (std::vector& vect, uint64_t start, uint64_t end) {\n for (uint64_t i = start; i <= end; ++i) {\n vect.push_back(i);\n }\n}\n\nvoid divide (std::vector& num, std::vector& den) {\n for (uint64_t& den_val : den) {\n for (uint64_t& num_val : num) {\n if (num_val % den_val == 0) {\n\tnum_val = num_val / den_val;\n\tden_val = 1;\n\tbreak;\n }\n }\n }\n}\n\nuint64_t multiply (std::vector& vect) {\n uint64_t product = 1;\n for (uint64_t i = 0; i < vect.size(); ++i) {\n product *= vect[i];\n }\n return product;\n}\n\nuint64_t theater_eval (int n, int m, int t)\n{\n uint64_t result = 0;\n std::vector num;\n std::vector den;\n for (int b = 4; b <= t - 1; ++b)\n {\n int g = t - b;\n\n // boys\n num.clear();\n den.clear();\n append_range (num, 1, n);\n append_range (den, 1, n-b);\n append_range (den, 1, b);\n divide (num, den);\n uint64_t boy_combs = multiply(num) / multiply(den);\n\n // girls\n num.clear();\n den.clear();\n append_range (num, 1, m);\n append_range (den, 1, m-g);\n append_range (den, 1, g);\n divide (num, den);\n uint64_t girl_combs = multiply(num) / multiply(den);\n\n result += boy_combs * girl_combs;\n }\n\n return result;\n}\n\n// -------------\n// theater_print\n// -------------\n\nvoid theater_print (std::ostream& w, uint64_t answer)\n{\n w << answer << std::endl;\n}\n\n// -------------\n// theater_solve\n// -------------\n\nvoid theater_solve (std::istream& r, std::ostream& w) \n{\n std::string s;\n\n // Get the boys, girls, and group size\n int n = 0;\n int m = 0;\n int t = 0;\n if (std::getline(r, s)) {\n std::istringstream sin(s);\n sin >> n >> m >> t;\n }\n\n // Determine the answer\n uint64_t answer = theater_eval(n, m , t);\n\n // Print the result\n theater_print(w, answer);\n}\n\n#include \n\n\n\n// ----\n// main\n// ----\n\nint main () {\n using namespace std;\n theater_solve(cin, cout);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8ab2c86bd512aef93b05f09d7b07214b", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include\n#include\n//#define ll int\n#define ll long long int\nusing namespace std;\nll func(ll n,ll m){\n if(m==0)\n return 1;\n else\n return func(n-1,m-1)*n/m;\n}\nint main(){\n ll n,m,t,ans=0;\n cin>>n>>m>>t;\n for(int i=4;t-i>=1;i++){\n ll p, q;\n if(i\n#include \n#include \n#include \nusing namespace std;\n\n#pragma warning(disable : 4996)\n\nint n,m;\n\nint main() {\n\t\n\t//freopen(\"input.txt\",\"r\",stdin);\n //freopen(\"output.txt\",\"w\",stdout);\n\t\n\tcin>>n >>m;\n\tint s=0;\n\n\tfor (int i=-1000; i<=1000; i++)\n\t\tfor (int j=-1000; j<1000; j++)\n\t\t\tif (i*i+j==n && j*j+i==m) s++;\n\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define REP(i,n) for (int i=0, _n=(n)-1; i <= _n; ++i)\n#define REPD(i,n) for (int i=(n)-1; i >= 0; --i)\n#define FOR(i,a,b) for (int i=(a), _b=(b); i <= _b; ++i)\n#define FORD(i,a,b) for (int i=(a), _b=(b); i >= _b; --i)\n#define X first\n#define Y second\n#define pb push_back\n#define mp make_pair\n#define sz(a) ((int) ((a).size()))\ntemplate < class T > T sqr (T a) { return (a) * (a); }\ntemplate < class T > T abs (T a) { return (a < 0) ? -(a) : (a); }\nconst double Pi = acos(-1.0);\nconst double eps = 1e-10;\nconst int INF = 1000*1000*1000 + 7;\nconst double phi = 0.5 + sqrt(1.25);\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pdd;\n\nint main() {\n#ifndef ONLINE_JUDGE\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n#endif\n int n,m, ans = 0;\n scanf(\"%d%d\\n\", &n, &m);\n REP(a, 1010) {\n int b = n - a * a;\n ans += (a + sqr(b) == m);\n }\n printf(\"%d\\n\", ans);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9dd3c47f349867a624189e4b9b20f296", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n double n,m;\n int answer = 0;\n cin >> n >> m;\n for (double a = 0; a <= 100; a++)\n for (double b = 0; b<=100; b++)\n if(a*a+b==n && b*b + a == m)\n answer++;\n cout << answer << endl;\n _getch();\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "26d1c0363649eb4724aef86f265a6e79", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.0} {"lang": "MS C++", "source_code": "# include \n# include \nusing namespace std;\n\nvoid main ()\n{\n\tint a=0,b=0,m,n,x=0;\n\n\tcin >> n >> m;\n\n\tfor (a;a<=m&&a<=n;a++)\n\t\tfor (b;(b<=m)&&(b<=n);b++)\n\t\t\tif (((a+b*b)==m)&&((a*a+b==n)))\n\t\t\t\tx++;\n\n\tcout << x;\n\n\t_getch ();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3bd493f744d78e257e96e2ceab655416", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "/***********************************************\n * Author: fisty\n * Created Time: 2015/2/28 21:54:12\n * File Name : 294C.cpp\n *********************************************** */\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define Debug(x) cout << #x << \" \" << x < P;\n#define FOR(i, a, b) for(int i = a;i < b; i++)\n#define MAX_N 10000\nint dp[MAX_N][MAX_N];\nint main() {\n //freopen(\"in.cpp\", \"r\", stdin);\n cin.tie(0);\n ios::sync_with_stdio(false);\n int n, m; \n cin >> n >> m;\n Memset(dp, 0);\n for(int i = n;i >= 0; i--){\n for(int j = m;j >= 0; j--){\n if(i-1 >= 0 && j - 2 >= 0)\n dp[i-1][j-2] = dp[i][j]+1;\n if(i - 2 >= 0 && j - 1 >= 0)\n dp[i-2][j-1] = dp[i][j]+1;\n }\n }\n cout << dp[0][0] << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f46091ce25a887945f7c68350290e88b", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include\nusing namespace std;\n\nlong max(long a, long b)\n{\n\treturn (a > b) ? a : b;\n}\nint main()\n{\n\tlong n, m;\n\tcin >> n >> m;\n\tlong** DP = new long *[n + 1];\n\tfor (long i = 0; i < n + 1; i++)\n\t\tDP[i] = new long[m + 1];\n\t//Pre_process_DP\n\tDP[0][0] = 0;\n\tfor (long i = 0; i <= n; i++)\n\t{\n\t\tDP[i][0] = 0;\n\t}\n\tfor (long i = 0; i <= m; i++)\n\t{\n\t\tDP[0][i] = 0;\n\t}\n\tDP[1][1] = 0;\n\tfor (long i = 2; i <= m; i++)\n\t{\n\t\tDP[1][i] = 1;\n\t}\n\tif (n >= 2 && m >= 1)\n\t\tDP[2][1] = 1;\n\t//main_DP\n\tfor (long i = 2; i <= n; i++)\n\t{\n\t\tfor (long j = 2; j <= m; j++)\n\t\t{\n\t\t\tDP[i][j] = max(1 + DP[i - 2][j - 1], 1 + DP[i - 1][j - 2]);\n\t\t}\n\t}\n\n\tcout << DP[n][m];\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "23b9b8662156f715ad264bf5fc288a8a", "src_uid": "0718c6afe52cd232a5e942052527f31b", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\nint min(int a, int b)\n{\n\tif(am)\n\t{\n\t\tint t=n;\n\t\tn=m;\n\t\tm=t;\n\t}\n\t\n\tif(n*3\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef unsigned long long uint64;\ntypedef long long int32;\ntypedef unsigned long uint32;\t\n\n#define TWO(X) (1<<(X))\n#define TWOLL(X) ((int64)1<<(X))\n#define vi vector\n#define vvi vector\n#define ii pair\n#define vii vector\n#define vvii vector\nint n,m,c;\n\nint main(){\n\tcin>>n>>m;\n\tif(m/2 >= n){\n\t\tcout< m/2){\n\t\t\tn-=2;\n\t\t\tm-=1;\n\t\t\tc++;\n\t\t}\n\t\tc+=n;\n\t\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define mem(a,b) memset(a,b,sizeof(a))\n#define fop() freopen(\"in.txt\",\"r\",stdin)\n#define sf scanf\n#define pf printf\nusing namespace std;\ndouble PI=acos(-1);\ntypedef long long ll;\nvoid gettime(int &s,int &sm,int &sd,char *x)\n{\n s=sm=sd=0;\n for(int i=0;i<=3;i++)\n s=s*10+x[i]-'0';\n for(int i=5;i<=6;i++)\n sm=sm*10+x[i]-'0';\n for(int i=8;i<=9;i++)\n sd=sd*10+x[i]-'0';\n}\nint main()\n{\n //fop();\n int month[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};\n int ans=0;\n int s,e,sm,em,sd,ed;\n char x1[100],x2[100];\n sf(\"%s\",x1);\n sf(\"%s\",x2);\n if(strcmp(x1,x2)>0)swap(x1,x2);\n gettime(s,sm,sd,x1);\n gettime(e,em,ed,x2);\n //cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\",\"r\",stdin);\n\tfreopen(\"output.txt\",\"w\",stdout);\n#endif\n\tint y1, m1, d1, y2, m2, d2;\n\tchar c;\n\tcin >> y1 >> c >> m1 >> c >> d1 >> y2 >> c >> m2 >> c >> d2;\n\tif (y1 > y2 || (y1 == y2 && m1 > m2) || (m1 == m2 && d1 > d2))\n\t{\n\t\tswap(y1,y2);\n\t\tswap(m1,m2);\n\t\tswap(d1,d2);\n\t}\n\tint days = 0;\n\tfor (int y = y1 + 1; y < y2; ++y)\n\t{\n\t\tif (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0))\n\t\t\tdays += 366;\n\t\telse\n\t\t\tdays += 365;\n\t}\n\tint month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};\n\tif (days > 0)\n\t{\n\t\tif (y1 % 4 == 0 && (y1 % 100 != 0 || y1 % 400 == 0))\n\t\t\t++month[2];\n\t\tdays += month[m1] - d1 + 1;\n\t\tfor (int m = m1 + 1; m <= 12; ++m)\n\t\t\tdays += month[m];\n\t\tmonth[2] = 28;\n\t\tif (y2 % 4 == 0 && (y2 % 100 != 0 || y2 % 400 == 0))\n\t\t\t++month[2];\n\t\tfor (int m = 1; m < m2; ++m)\n\t\t\tdays += month[m];\n\t\tdays += d2;\n\t}\n\telse\n\t{\n\t\tif (y1 % 4 == 0 && (y1 % 100 != 0 || y1 % 400 == 0))\n\t\t\t++month[2];\n\t\tif (y1 == y2)\n\t\t{\n\t\t\tif (m1 != m2)\n\t\t\t{\n\t\t\t\tdays += month[m1] - d1 + 1;\n\t\t\t\tfor (int m = m1 + 1; m < m2; ++m)\n\t\t\t\t\tdays += month[m];\n\t\t\t\tdays += d2;\n\t\t\t}\n\t\t\telse\n\t\t\t\tdays = d2 - d1 + 1;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tmonth[2] = 28;\n\t\t\tdays += month[m1] - d1 + 1;\n\t\t\tfor (int m = m1 + 1; m < 13; ++m)\n\t\t\t\tdays += month[m];\n\t\t\tif (y2 % 4 == 0 && (y2 % 100 != 0 || y2 % 400 == 0))\n\t\t\t\t++month[2];\n\t\t\tfor (int m = 1; m < m2; ++m)\n\t\t\t\tdays += month[m];\n\t\t\tdays += d2;\n\t\t}\n\t}\n\t--days;\n\tcout << days;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a42643c3a851ff42f00c9b02a1c07dc2", "src_uid": "bdf99d78dc291758fa09ec133fff1e9c", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std ;\nint a[13] = {0, 31,28,31,30,31,30,31,31,30,31,30,31} ;\nbool judge(int year)\n{\n if((0 == year % 4 && 0 != year % 100 )|| 0 == year % 400 && year > 0 )\n {\n\n return true ;\n }\n else return false ;\n}\n\nint main()\n{\n int y1 ;\n int y2 ;\n int m1 ;\n int m2 ;\n int d1 ;\n int d2 ;\n int sum = 0 ;\n int tem = 0 ;\n scanf(\"%d:%d:%d\",&y1,&m1,&d1) ;\n scanf(\"%d:%d:%d\",&y2,&m2,&d2) ;\n if(y1 > y2)\n {\n\n swap(y1,y2) ;\n swap(m1,m2) ;\n swap(d1,d2) ;\n }\n if(y1 == y2)\n {\n printf(\" %d %d\\n\",y1,y2) ;\n for(int i = m1 + 1; i < m2 ; ++ i)\n sum += a[i] ;\n sum += d1 ;\n sum += d2 ;\n printf(\"%d\\n\",sum) ;\n }\n for(int i = m1 + 1 ;i <= 12 ; ++i )\n {\n sum += a[i] ;\n if(judge(y1) && i == 2)\n {\n ++ sum ;\n }\n\n }\n sum += a[m1] - d1 ;\n for(int i = y1 + 1 ;i < y2 ; ++ i)\n {\n if(judge(i))\n {\n sum += 366 ;\n }\n else\n {\n sum += 365 ;\n }\n }\n for(int i = 1 ; i < m2 ; ++ i)\n {\n sum += a[i] ;\n if(judge(y2) && 2 == i)\n {\n ++ sum ;\n }\n\n }\n sum += d2 ;\n printf(\"%d\\n\",sum) ;\n return 0 ;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ab0c9c0fd5b8b507ba2beac711e5e844", "src_uid": "bdf99d78dc291758fa09ec133fff1e9c", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nint leapmonth[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};\nint month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};\n\nint main()\n{\n //freopen(\"1.in\", \"r\", stdin);\n int i, j, minyear,maxyear, minmonth, maxmonth, minday, maxday, tmp;\n char str1[12], str2[12];\n cin >> str1 >> str2;\n minyear = (str1[0]-'0')*1000 + (str1[1]-'0')*100 + (str1[2]-'0')*10 + (str1[3]-'0');\n maxyear = (str2[0]-'0')*1000 + (str2[1]-'0')*100 + (str2[2]-'0')*10 + (str2[3]-'0');\n minmonth = (str1[5] - '0')*10 + (str1[6]-'0');\n maxmonth = (str2[5] - '0')*10 + (str2[6]-'0');\n minday = (str1[8] - '0')*10 + (str1[9]-'0');\n maxday = (str2[8] - '0')*10 + (str2[9]-'0');\n if(minyear > maxyear)\n {\n tmp = maxyear;maxyear = minyear;minyear = tmp;\n tmp = maxmonth;maxmonth = minmonth;minmonth = tmp;\n tmp = maxday;maxday = minday;minday = tmp;\n }\n int counter = 0, res = 0;\n for(i = minyear;i < maxyear;i++)\n {\n if(i%400 == 0 || (i%4==0 && i%100 != 0))counter ++;\n }\n res += (maxyear - minyear)*365 + counter;\n if(minyear % 400 == 0 || (minyear%4 == 0 && minyear % 100 != 0))\n {\n for(i = 0;i < minmonth - 1;i++)\n {\n res -= leapmonth[i];\n }\n res -= minday;\n }else{\n for(i = 0;i < minmonth - 1;i++)\n {\n res -= month[i];\n }\n res -= minday;\n }\n\n if(maxyear % 400 == 0 || (maxyear%4 == 0 && maxyear % 100 != 0))\n {\n for(i = 0;i < maxmonth - 1;i++)\n {\n res += leapmonth[i];\n }\n res += maxday;\n }else{\n for(i = 0;i < maxmonth - 1;i++)\n {\n res += month[i];\n }\n res += maxday;\n }\n cout << res;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "65fd65ffd765bcf475f50fbbc33f1596", "src_uid": "bdf99d78dc291758fa09ec133fff1e9c", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);\n#define endl '\\n'\n#define pb push_back\ntypedef long long ll;\nusing namespace std;\n\nint main() {\n int n, t;\n string s;\n cin>>n>>t>>s;\n while(t--) {\n string x = s;\n for(int i=0; i\n#include\n#include\nusing namespace std;\n\n\nint main()\n{\n\tint n,t,time=0,i=1;\n\tbool flag=true;\n\tstring s;\n\tcin>>n>>t;\n\tcin>>s;\n\twhile (t--)\n\t{\n\t\t\tif (s[i-1]=='B'&&s[i]=='G')\n\t\t\t{\n\t\t\t\tswap(s[i-1],s[i]);\n\t\t\t}\n\t\t\ti++;\n\t}\n\tcout<\n#include\nusing namespace std;\nchar q[50],s;\nint n=0,t=0;\nvoid change(int x,int y)\n{\n if (q[x]=='G' && q[y]=='B')\n {\n s=q[x];\n q[x]=q[y];\n q[y]=s;\n }\n}\nint main()\n{\n cin>>n>>t;\n cin>>q;\n for (int j=1; j<=t; j++)\n {\n\n for(int i =1; i\nusing namespace std;\nint main()\n{\n int n,t;\n cin>>n>>t;\n string s;\n cin>>s;\n for(int a=0;a>> &arr){\n\tint n = int(arr.size()), mxval = 0, mxsz = 1 + accumulate(arr.begin(), arr.end(), 0, [](int x, const pair> &y){return max(x, int(y.second.size()));});\n\tvector> occur(mxsz);\n\tfor(int i = 0; i < n; ++ i){\n\t\toccur[arr[i].second.size()].push_back(i);\n\t\tfor(auto x: arr[i].second) mxval = max(mxval, x);\n\t}\n\t++ mxval;\n\tfor(int size = 1; size < mxsz; ++ size) for(int d = size - 1; d >= 0; -- d){\n\t\tvector> bucket(mxval);\n\t\tfor(auto i: occur[size]) bucket[arr[i].second[d]].push_back(i);\n\t\toccur[size].clear();\n\t\tfor(auto &b: bucket) for(auto i: b) occur[size].push_back(i);\n\t}\n\tvector>> res;\n\tres.reserve(n);\n\tfor(auto &b: occur) for(auto i: b) res.push_back(arr[i]);\n\tswap(res, arr);\n}\nbool isomorphic(const vector>> &adj, const vector &root){\n\tint n = int(adj[0].size());\n\tif(int(adj[1].size()) != n) return false;\n\tvector>> occur(2);\n\tvector> depth(2, vector(n)), par(2, vector(n, -1));\n\tfor(int k = 0; k < 2; ++ k){\n\t\tfunction dfs = [&](int u, int p){\n\t\t\tpar[k][u] = p;\n\t\t\tfor(auto v: adj[k][u]) if(v != p){\n\t\t\t\tdepth[k][v] = depth[k][u] + 1;\n\t\t\t\tdfs(v, u);\n\t\t\t}\n\t\t};\n\t\tdfs(root[k], -1);\n\t\tint mxdepth = 1 + accumulate(depth[k].begin(), depth[k].end(), 0, [](int x, int y){return max(x, y);});\n\t\toccur[k].resize(mxdepth);\n\t\tfor(int u = 0; u < n; ++ u) occur[k][depth[k][u]].push_back(u);\n\t}\n\tint mxdepth = int(occur[0].size());\n\tif(mxdepth != int(occur[1].size())) return false;\n\tfor(int d = 0; d < mxdepth; ++ d) if(occur[0][d].size() != occur[1][d].size()) return false;\n\tvector> label(2, vector(n)), pos(2, vector(n));\n\tvector>> sorted_list(mxdepth, vector>(2));\n\tfor(int k = 0; k < 2; ++ k){\n\t\tsorted_list[mxdepth - 1][k].reserve(occur[k][mxdepth - 1].size());\n\t\tfor(auto u: occur[k][mxdepth - 1]) sorted_list[mxdepth - 1][k].push_back(u);\n\t}\n\tfor(int d = mxdepth - 2; d >= 0; -- d){\n\t\tvector>>> tuples(2);\n\t\tfor(int k = 0; k < 2; ++ k){\n\t\t\ttuples[k].reserve(occur[k][d].size());\n\t\t\tfor(auto u: occur[k][d]){\n\t\t\t\tpos[k][u] = int(tuples[k].size());\n\t\t\t\ttuples[k].emplace_back(u, vector());\n\t\t\t}\n\t\t\tfor(auto v: sorted_list[d + 1][k]){\n\t\t\t\tint u = par[k][v];\n\t\t\t\ttuples[k][pos[k][u]].second.push_back(label[k][v]);\n\t\t\t}\n\t\t\tradix_sort(tuples[k]);\n\t\t}\n\t\tfor(int i = 0; i < int(tuples[0].size()); ++ i) if(tuples[0][i].second != tuples[1][i].second) return false;\n\t\tfor(int k = 0; k < 2; ++ k){\n\t\t\tint cnt = 0;\n\t\t\tsorted_list[d][k].reserve(occur[k][d].size());\n\t\t\tsorted_list[d][k].push_back(tuples[k][0].first);\n\t\t\tfor(int i = 1; i < int(tuples[k].size()); ++ i){\n\t\t\t\tint u = tuples[k][i].first;\n\t\t\t\tlabel[k][u] = (tuples[k][i - 1].second == tuples[k][i].second ? cnt : ++ cnt);\n\t\t\t\tsorted_list[d][k].push_back(u);\n\t\t\t}\n\t\t}\n\t}\n\treturn true;\n}\nvector centroid(const vector> &adj){\n\tint n = int(adj.size());\n\tvector size(n, 1);\n\tfunction dfs_sz = [&](int u, int p){\n\t\tfor(auto v: adj[u]) if(v != p){\n\t\t\tdfs_sz(v, u);\n\t\t\tsize[u] += size[v];\n\t\t}\n\t};\n\tdfs_sz(0, -1);\n\tfunction(int, int)> dfs_cent = [&](int u, int p){\n\t\tfor(auto v: adj[u]) if(v != p && size[v] > n / 2) return dfs_cent(v, u);\n\t\tfor(auto v: adj[u]) if(v != p && n - size[v] <= n / 2) return vector{u, v};\n\t\treturn vector{u};\n\t};\n\treturn dfs_cent(0, -1);\n}\nbool isomorphic(const vector>> &adj){\n\tvector> cent{centroid(adj[0]), centroid(adj[1])};\n\tif(cent[0].size() != cent[1].size()) return false;\n\tfor(auto u: cent[0]) for(auto v: cent[1]) if(isomorphic(adj, vector{u, v})) return true;\n\treturn false;\n}\ntemplate\nbool test_isomorphism(asdf p, asdf q){\n\tint n = int(p.size());\n\tvector> adj1(n), adj2(n);\n\tfor(auto u = 0; u < n; ++ u){\n\t\tif(p[u] >= 0){\n\t\t\tadj1[u].push_back(p[u]), adj1[p[u]].push_back(u);\n\t\t}\n\t}\n\tfor(auto u = 0; u < n; ++ u){\n\t\tif(q[u] >= 0){\n\t\t\tadj2[u].push_back(q[u]), adj2[q[u]].push_back(u);\n\t\t}\n\t}\n\treturn isomorphic({adj1, adj2});\n}\n\n// DEBUG BEGIN\ntemplate\nostream &operator<<(ostream &out, pair p){\n\treturn out << \"(\" << p.first << \", \" << p.second << \")\";\n}\ntemplate\nvoid print_tuple(ostream &out, Tuple t, index_sequence){\n\t((out << (Is ? \", \" : \"\") << get(t)), ...);\n}\ntemplate\nostream &operator<<(ostream &out, tuple t){\n\tout << \"(\", print_tuple(out, t, index_sequence_for{}); return out << \")\";\n}\ntemplate typename T>\nostream &operator<<(enable_if_t, string>, ostream> &out, T arr){\n\tout << \"{\"; for(auto &x: arr) out << x << \", \";\n\treturn out << (arr.size() ? \"\\b\\b\" : \"\") << \"}\";\n}\ntemplate\nostream &operator<<(ostream &out, array arr){\n\tout << \"{\"; for(auto &x: arr) out << x << \", \";\n\treturn out << (arr.size() ? \"\\b\\b\" : \"\") << \"}\";\n}\ntemplate\nostream &operator<<(ostream &out, bitset b){\n\tfor(int i = 0; i < S; ++ i) out << b[i];\n\treturn out;\n}\nvoid debug_out(){ cerr << \"\\b\\b \" << endl; }\ntemplate\nvoid debug_out(Head H, Tail... T){ cerr << H << \", \", debug_out(T...); }\n#ifdef LOCAL\n#define debug(...) cerr << \"[\" << #__VA_ARGS__ << \"]: \", debug_out(__VA_ARGS__)\n#else\n#define debug(...) 42\n#endif\n// DEBUG END\n\nint main(){\n\tcin.tie(0)->sync_with_stdio(0);\n\t///*\n\tint n;\n\tcin >> n;\n\tvector par(2 * n - 1, -1), judge_ans(2 * n - 1), depth(2 * n - 1, -1);\n\tfor(auto &x: judge_ans) cin >> x;\n\tdebug(judge_ans);\n\tfor(auto &x: judge_ans) if(~x) -- x;\n\tfor(auto u = 0; u < 2 * n - 1; ++ u){\n\t\tif(!~depth[u]){\n\t\t\tfunction get_depth = [&](int u){\n\t\t\t\tif(~depth[u]) return depth[u];\n\t\t\t\tif(judge_ans[u] < 0) return depth[u] = 0;\n\t\t\t\treturn get_depth(judge_ans[u]) + 1;\n\t\t\t};\n\t\t\tdepth[u] = get_depth(u);\n\t\t}\n\t}\n\tauto lca = [&](int u, int v){\n\t\tif(depth[u] < depth[v]) swap(u, v);\n\t\twhile(depth[u] != depth[v]) u = judge_ans[u];\n\t\twhile(u != v) u = judge_ans[u], v = judge_ans[v];\n\t\treturn u;\n\t};\n\tint query_cnt = 0;\n\tauto query = [&](int u, int v, int w){\n\t\t++ query_cnt;\n\t\tcout << u + 1 << \" \" << v + 1 << \" \" << w + 1 << endl;\n\t\tint x = depth[lca(u, v)], y = depth[lca(v, w)], z = depth[lca(w, u)], mx = max({x, y, z});\n\t\tcout << \"judge replies: \";\n\t\tif(x == mx){\n\t\t\tcout << \"X\" << endl;\n\t\t\treturn 0;\n\t\t}\n\t\telse if(y == mx){\n\t\t\tcout << \"Y\" << endl;\n\t\t\treturn 1;\n\t\t}\n\t\telse{\n\t\t\tcout << \"Z\" << endl;\n\t\t\treturn 2;\n\t\t}\n\t};\n\tauto answer = [&](){\n\t\tcout << \"-1\\n\";\n\t\tfor(auto p: par) cout << p + !!~p << \" \";\n\t\tcout << \"\\n\";\n\t\tcout << \"Are they isomorphic?: \" << test_isomorphism(judge_ans, par) << endl;\n\t\texit(0);\n\t};\n\t//*/\n\t/*\n\tint n;\n\tcin >> n;\n\tvector par(2 * n - 1, -2);\n\tint query_cnt = 0;\n\tauto query = [&](int u, int v, int w){\n\t\t++ query_cnt;\n\t\tif(query_cnt > 10 * n){\n\t\t\tint t = 1;\n\t\t\twhile(1){\n\t\t\t\tt *= 3;\n\t\t\t}\n\t\t}\n\t\tcout << u + 1 << \" \" << v + 1 << \" \" << w + 1 << endl;\n\t\tchar resp;\n\t\tcin >> resp;\n\t\treturn resp - 'X';\n\t};\n\tauto answer = [&](){\n\t\tcout << \"-1\\n\";\n\t\tfor(auto p: par) cout << p + 1 << \" \";\n\t\tcout << \"\\n\";\n\t\texit(0);\n\t};\n\t*/\n\tauto get_node = [&](){\n\t\tstatic int cntr = n;\n\t\treturn cntr ++;\n\t};\n\tvector> child(2 * n - 1, {-1, -1}), leaf_child(2 * n - 1);\n\tfor(auto u = 0; u < n; ++ u){\n\t\tleaf_child[u] = {u, u};\n\t}\n\tfor(auto root = 0, new_leaf = 1; new_leaf < n; ++ new_leaf){ // currently 2 * s - 1 nodes\n\t\tint new_par = get_node(), qval;\n\t\tauto insert_nodes = [&](int pp, int dir){\n\t\t\tint qq = child[pp][dir];\n\t\t\tpar[qq] = par[new_leaf] = new_par, par[new_par] = pp;\n\t\t\tchild[pp][dir] = new_par, child[new_par][dir] = qq, child[new_par][!dir] = new_leaf;\n\t\t\tleaf_child[new_par][dir] = leaf_child[qq][dir], leaf_child[new_par][!dir] = leaf_child[new_leaf][!dir];\n\t\t};\n\t\tif(!~child[root][0] || (qval = query(child[root][0], new_leaf, child[root][1])) == 2){\n\t\t\tleaf_child[new_par] = {leaf_child[root][0], new_leaf};\n\t\t\tpar[root] = par[new_leaf] = new_par;\n\t\t\tchild[new_par] = {root, new_leaf};\n\t\t\troot = new_par;\n\t\t\tcontinue;\n\t\t}\n\t\tstatic vector ded, sz;\n\t\tded.assign(2 * n - 1, 0), sz.assign(2 * n - 1, 0);\n\t\tded[root] = true;\n\t\tfor(auto cur_root = child[root][qval]; ; ){\n\t\t\tfunction dfs_sz = [&](int u, int p){\n\t\t\t\tsz[u] = 1;\n\t\t\t\tfor(auto v: child[u]){\n\t\t\t\t\tif(~v && !ded[v] && v ^ p){\n\t\t\t\t\t\tdfs_sz(v, u);\n\t\t\t\t\t\tsz[u] += sz[v];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tint v = par[u];\n\t\t\t\tif(~v && !ded[v] && v ^ p){\n\t\t\t\t\tdfs_sz(v, u);\n\t\t\t\t\tsz[u] += sz[v];\n\t\t\t\t}\n\t\t\t};\n\t\t\tdfs_sz(cur_root, cur_root);\n\t\t\tfunction dfs_centroid = [&](int u, int p){\n\t\t\t\tfor(auto v: child[u]){\n\t\t\t\t\tif(~v && !ded[v] && v ^ p && sz[v] > sz[u] / 2){\n\t\t\t\t\t\treturn dfs_centroid(v, u);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tint v = par[u];\n\t\t\t\tif(~v && !ded[v] && v ^ p && sz[v] > sz[u] / 2){\n\t\t\t\t\treturn dfs_centroid(v, u);\n\t\t\t\t}\n\t\t\t\treturn u;\n\t\t\t};\n\t\t\tint c = dfs_centroid(cur_root, cur_root);\n\t\t\tif(!~child[c][0]){\n\t\t\t\tinsert_nodes(par[c], c == child[par[c]][1]);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tint qval = query(leaf_child[c][0], new_leaf, leaf_child[c][1]);\n\t\t\tif(qval == 2){\n\t\t\t\tif(ded[par[c]]){\n\t\t\t\t\tinsert_nodes(par[c], c == child[par[c]][1]);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcur_root = par[c];\n\t\t\t}\n\t\t\telse{\n\t\t\t\tif(ded[child[c][qval]]){\n\t\t\t\t\tinsert_nodes(c, qval);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcur_root = child[c][qval];\n\t\t\t}\n\t\t\tded[c] = true;\n\t\t}\n\t}\n\tanswer();\n\treturn 0;\n}\n\n/*\n\n*/\n\n////////////////////////////////////////////////////////////////////////////////////////\n// //\n// Coded by Aeren //\n// //\n////////////////////////////////////////////////////////////////////////////////////////", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2907716a14837670f9003aa7ce2a9311", "src_uid": "756b46a85b91346e189bb7c7646aa54f", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nmt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());\nconst int N = 2e3;\nint n,rem,sz = 2,cursz;\nbool vis[N];\nstruct node{\n\tint l,r,p,sz;\n\tint leafl,leafr;\n\tnode(){l = r = p = leafl = leafr = -1,sz = 0;}\n}g[N];\nint get(){\n\tg[rem].sz = 1;\n\treturn rem++;\n}\npair get(int u){\n\tif(u < n)return {-1,1};\n\tif(vis[u])return{-1,0};\n\tint sz = 0,mx = 0,cen = -1;\n\tpairtemp = get(g[u].l);\n\tcen = temp.first;\n\tsz+=temp.second;\n\tmx = max(mx,temp.second);\n\ttemp = get(g[u].r);\n\tcen = max(cen,temp.first);\n\tsz+=temp.second;\n\tmx = max(mx,temp.second);\n\tmx = max(mx,cursz - sz);\n\tif(mx <= (cursz + 1)/2)cen = u;\n\treturn {cen,sz};\n}\nchar ask(int a,int b,int c){\n\tchar ret;\n\tcout << a + 1 << \" \" << b + 1 << \" \" << c + 1 << endl;\n\tscanf(\" %c\",&ret);\n\treturn ret;\n}\nint getsz(int u){\n\tif(u < n)return 1;\n\tif(vis[u])return 0;\n\treturn getsz(g[u].l) + getsz(g[u].r);\n}\nint main(){\n\tscanf(\"%d\",&n);\n\trem = n;\n\tint root = get();\n\tg[root].l = 0;\n\tg[root].r = 1;\n\tg[0].p = g[1].p = root;\n\tfor(int i = 0;i < n;i++)g[i].sz = 1,g[i].leafl = g[i].leafr = i;\n\tg[root].sz = 1;\n\tg[root].leafl = 0;\n\tg[root].leafr = 1;\n\tfor(int i = 2;i < n;i++,sz++){\n\t\tmemset(vis,0,sizeof vis);\n\t\tfor(int i = 0;i < n;i++)vis[i] = 1;\n\t\tint cur = root;\n\t\twhile(1){\n\t\t\tcursz = getsz(cur);\n\t\t\tint cen = get(cur).first;\n\t\t\tif(g[cen].leafl == g[cen].leafr)cout << cen << endl;\n\t\t\tchar is = ask(g[cen].leafl,g[cen].leafr,i);\n\t\t\tif(is == 'Z'){\n\t\t\t\tif(vis[g[cen].l]){\n\t\t\t\t\tint left = g[cen].l;\n\t\t\t\t\tint temp = get();\n\t\t\t\t\tg[cen].l = temp;\n\t\t\t\t\tg[temp].p = cur;\n\t\t\t\t\tg[temp].l = left;\n\t\t\t\t\tg[temp].r = i;\n\t\t\t\t\tg[temp].leafl = g[left].leafl;\n\t\t\t\t\tg[temp].leafr = i;\n\t\t\t\t\tg[temp].sz = g[left].sz;\n\t\t\t\t\tg[i].p = g[left].p = temp;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tvis[cen] = 1;\n\t\t\t\tcur = g[cen].l;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif(is == 'Y'){\n\t\t\t\tif(vis[g[cen].r]){\n\t\t\t\t\tint left = g[cen].r;\n\t\t\t\t\tint temp = get();\n\t\t\t\t\tg[cen].l = temp;\n\t\t\t\t\tg[temp].p = cur;\n\t\t\t\t\tg[temp].l = left;\n\t\t\t\t\tg[temp].r = i;\n\t\t\t\t\tg[temp].leafl = g[left].leafl;\n\t\t\t\t\tg[temp].leafr = i;\n\t\t\t\t\tg[temp].sz = g[left].sz;\n\t\t\t\t\tg[i].p = g[left].p = temp;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tvis[cen] = 1;\n\t\t\t\tcur = g[cen].r;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif(g[cen].p == -1){\n\t\t\t\tint temp = get();\n\t\t\t\tg[cen].p = g[i].p = temp;\n\t\t\t\tg[temp].l = cen;\n\t\t\t\tg[temp].r = i;\n\t\t\t\tg[temp].sz = g[cen].sz;\n\t\t\t\tg[temp].leafl = g[cen].leafl;\n\t\t\t\tg[temp].leafr = i;\n\t\t\t\troot = temp;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif(vis[g[cen].p]){\n\t\t\t\tint temp = get();\n\t\t\t\tg[temp].leafl = g[cen].leafl;\n\t\t\t\tg[temp].leafr = i;\n\t\t\t\tg[temp].l = cen;\n\t\t\t\tg[temp].r = i;\n\t\t\t\tg[temp].p = g[cen].p;\n\t\t\t\tg[cen].p = g[i].p = temp;\n\t\t\t\tg[temp].sz = g[cen].sz;\n\t\t\t\tif(g[g[cen].p].l == cen)g[g[cen].p].l = temp;\n\t\t\t\telse g[g[cen].p].r = temp;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tvis[cen] = 1;\n\t\t\tcur = root;\n\t\t}\n\t\tcur = i;\n\t\twhile(g[cur].p != -1){\n\t\t\tg[cur].sz++;\n\t\t\tcur = g[cur].p;\n\t\t}\n\t}\n\tputs(\"-1\");\n\tfor(int i = 0;i < 2*n - 1;i++)printf(\"%d \",g[i].p == -1 ? - 1 : g[i].p + 1);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f47847bd01c3bf78acb50c13b41b0944", "src_uid": "756b46a85b91346e189bb7c7646aa54f", "difficulty": 3200.0} {"lang": "GNU C++17", "source_code": "#include \"bits/stdc++.h\"\nusing namespace std;\nusing namespace chrono;\nmt19937 rng(high_resolution_clock::now().time_since_epoch().count());\nmt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());\n\nvoid radix_sort(vector>> &arr){\n\tint n = int(arr.size()), mxval = 0, mxsz = 1 + accumulate(arr.begin(), arr.end(), 0, [](int x, const pair> &y){return max(x, int(y.second.size()));});\n\tvector> occur(mxsz);\n\tfor(int i = 0; i < n; ++ i){\n\t\toccur[arr[i].second.size()].push_back(i);\n\t\tfor(auto x: arr[i].second) mxval = max(mxval, x);\n\t}\n\t++ mxval;\n\tfor(int size = 1; size < mxsz; ++ size) for(int d = size - 1; d >= 0; -- d){\n\t\tvector> bucket(mxval);\n\t\tfor(auto i: occur[size]) bucket[arr[i].second[d]].push_back(i);\n\t\toccur[size].clear();\n\t\tfor(auto &b: bucket) for(auto i: b) occur[size].push_back(i);\n\t}\n\tvector>> res;\n\tres.reserve(n);\n\tfor(auto &b: occur) for(auto i: b) res.push_back(arr[i]);\n\tswap(res, arr);\n}\nbool isomorphic(const vector>> &adj, const vector &root){\n\tint n = int(adj[0].size());\n\tif(int(adj[1].size()) != n) return false;\n\tvector>> occur(2);\n\tvector> depth(2, vector(n)), par(2, vector(n, -1));\n\tfor(int k = 0; k < 2; ++ k){\n\t\tfunction dfs = [&](int u, int p){\n\t\t\tpar[k][u] = p;\n\t\t\tfor(auto v: adj[k][u]) if(v != p){\n\t\t\t\tdepth[k][v] = depth[k][u] + 1;\n\t\t\t\tdfs(v, u);\n\t\t\t}\n\t\t};\n\t\tdfs(root[k], -1);\n\t\tint mxdepth = 1 + accumulate(depth[k].begin(), depth[k].end(), 0, [](int x, int y){return max(x, y);});\n\t\toccur[k].resize(mxdepth);\n\t\tfor(int u = 0; u < n; ++ u) occur[k][depth[k][u]].push_back(u);\n\t}\n\tint mxdepth = int(occur[0].size());\n\tif(mxdepth != int(occur[1].size())) return false;\n\tfor(int d = 0; d < mxdepth; ++ d) if(occur[0][d].size() != occur[1][d].size()) return false;\n\tvector> label(2, vector(n)), pos(2, vector(n));\n\tvector>> sorted_list(mxdepth, vector>(2));\n\tfor(int k = 0; k < 2; ++ k){\n\t\tsorted_list[mxdepth - 1][k].reserve(occur[k][mxdepth - 1].size());\n\t\tfor(auto u: occur[k][mxdepth - 1]) sorted_list[mxdepth - 1][k].push_back(u);\n\t}\n\tfor(int d = mxdepth - 2; d >= 0; -- d){\n\t\tvector>>> tuples(2);\n\t\tfor(int k = 0; k < 2; ++ k){\n\t\t\ttuples[k].reserve(occur[k][d].size());\n\t\t\tfor(auto u: occur[k][d]){\n\t\t\t\tpos[k][u] = int(tuples[k].size());\n\t\t\t\ttuples[k].emplace_back(u, vector());\n\t\t\t}\n\t\t\tfor(auto v: sorted_list[d + 1][k]){\n\t\t\t\tint u = par[k][v];\n\t\t\t\ttuples[k][pos[k][u]].second.push_back(label[k][v]);\n\t\t\t}\n\t\t\tradix_sort(tuples[k]);\n\t\t}\n\t\tfor(int i = 0; i < int(tuples[0].size()); ++ i) if(tuples[0][i].second != tuples[1][i].second) return false;\n\t\tfor(int k = 0; k < 2; ++ k){\n\t\t\tint cnt = 0;\n\t\t\tsorted_list[d][k].reserve(occur[k][d].size());\n\t\t\tsorted_list[d][k].push_back(tuples[k][0].first);\n\t\t\tfor(int i = 1; i < int(tuples[k].size()); ++ i){\n\t\t\t\tint u = tuples[k][i].first;\n\t\t\t\tlabel[k][u] = (tuples[k][i - 1].second == tuples[k][i].second ? cnt : ++ cnt);\n\t\t\t\tsorted_list[d][k].push_back(u);\n\t\t\t}\n\t\t}\n\t}\n\treturn true;\n}\nvector centroid(const vector> &adj){\n\tint n = int(adj.size());\n\tvector size(n, 1);\n\tfunction dfs_sz = [&](int u, int p){\n\t\tfor(auto v: adj[u]) if(v != p){\n\t\t\tdfs_sz(v, u);\n\t\t\tsize[u] += size[v];\n\t\t}\n\t};\n\tdfs_sz(0, -1);\n\tfunction(int, int)> dfs_cent = [&](int u, int p){\n\t\tfor(auto v: adj[u]) if(v != p && size[v] > n / 2) return dfs_cent(v, u);\n\t\tfor(auto v: adj[u]) if(v != p && n - size[v] <= n / 2) return vector{u, v};\n\t\treturn vector{u};\n\t};\n\treturn dfs_cent(0, -1);\n}\nbool isomorphic(const vector>> &adj){\n\tvector> cent{centroid(adj[0]), centroid(adj[1])};\n\tif(cent[0].size() != cent[1].size()) return false;\n\tfor(auto u: cent[0]) for(auto v: cent[1]) if(isomorphic(adj, vector{u, v})) return true;\n\treturn false;\n}\ntemplate\nbool test_isomorphism(asdf p, asdf q){\n\tint n = int(p.size());\n\tvector> adj1(n), adj2(n);\n\tfor(auto u = 0; u < n; ++ u){\n\t\tif(p[u] >= 0){\n\t\t\tadj1[u].push_back(p[u]), adj1[p[u]].push_back(u);\n\t\t}\n\t}\n\tfor(auto u = 0; u < n; ++ u){\n\t\tif(q[u] >= 0){\n\t\t\tadj2[u].push_back(q[u]), adj2[q[u]].push_back(u);\n\t\t}\n\t}\n\treturn isomorphic({adj1, adj2});\n}\n\n// DEBUG BEGIN\ntemplate\nostream &operator<<(ostream &out, pair p){\n\treturn out << \"(\" << p.first << \", \" << p.second << \")\";\n}\ntemplate\nvoid print_tuple(ostream &out, Tuple t, index_sequence){\n\t((out << (Is ? \", \" : \"\") << get(t)), ...);\n}\ntemplate\nostream &operator<<(ostream &out, tuple t){\n\tout << \"(\", print_tuple(out, t, index_sequence_for{}); return out << \")\";\n}\ntemplate typename T>\nostream &operator<<(enable_if_t, string>, ostream> &out, T arr){\n\tout << \"{\"; for(auto &x: arr) out << x << \", \";\n\treturn out << (arr.size() ? \"\\b\\b\" : \"\") << \"}\";\n}\ntemplate\nostream &operator<<(ostream &out, array arr){\n\tout << \"{\"; for(auto &x: arr) out << x << \", \";\n\treturn out << (arr.size() ? \"\\b\\b\" : \"\") << \"}\";\n}\ntemplate\nostream &operator<<(ostream &out, bitset b){\n\tfor(int i = 0; i < S; ++ i) out << b[i];\n\treturn out;\n}\nvoid debug_out(){ cerr << \"\\b\\b \" << endl; }\ntemplate\nvoid debug_out(Head H, Tail... T){ cerr << H << \", \", debug_out(T...); }\n#ifdef LOCAL\n#define debug(...) cerr << \"[\" << #__VA_ARGS__ << \"]: \", debug_out(__VA_ARGS__)\n#else\n#define debug(...) 42\n#endif\n// DEBUG END\n\nint main(){\n\tcin.tie(0)->sync_with_stdio(0);\n\t///*\n\tint n;\n\tcin >> n;\n\tvector par(2 * n - 1, -1), judge_ans(2 * n - 1), depth(2 * n - 1, -1);\n\tfor(auto &x: judge_ans) cin >> x;\n\tdebug(judge_ans);\n\tfor(auto &x: judge_ans) if(~x) -- x;\n\tfor(auto u = 0; u < 2 * n - 1; ++ u){\n\t\tif(!~depth[u]){\n\t\t\tfunction get_depth = [&](int u){\n\t\t\t\tif(~depth[u]) return depth[u];\n\t\t\t\tif(judge_ans[u] < 0) return depth[u] = 0;\n\t\t\t\treturn get_depth(judge_ans[u]) + 1;\n\t\t\t};\n\t\t\tdepth[u] = get_depth(u);\n\t\t}\n\t}\n\tauto lca = [&](int u, int v){\n\t\tif(depth[u] < depth[v]) swap(u, v);\n\t\twhile(depth[u] != depth[v]) u = judge_ans[u];\n\t\twhile(u != v) u = judge_ans[u], v = judge_ans[v];\n\t\treturn u;\n\t};\n\tint query_cnt = 0;\n\tauto query = [&](int u, int v, int w){\n\t\t++ query_cnt;\n\t\tdebug(query_cnt);\n\t\tcout << u + 1 << \" \" << v + 1 << \" \" << w + 1 << endl;\n\t\tint x = depth[lca(u, v)], y = depth[lca(v, w)], z = depth[lca(w, u)], mx = max({x, y, z});\n\t\tcout << \"judge replies: \";\n\t\tif(x == mx){\n\t\t\tcout << \"X\" << endl;\n\t\t\treturn 0;\n\t\t}\n\t\telse if(y == mx){\n\t\t\tcout << \"Y\" << endl;\n\t\t\treturn 1;\n\t\t}\n\t\telse{\n\t\t\tcout << \"Z\" << endl;\n\t\t\treturn 2;\n\t\t}\n\t};\n\tauto answer = [&](){\n\t\tcout << \"-1\\n\";\n\t\tfor(auto p: par) cout << p + !!~p << \" \";\n\t\tcout << \"\\n\";\n\t\tcout << \"Are they isomorphic?: \" << test_isomorphism(judge_ans, par) << endl;\n\t\texit(0);\n\t};\n\t//*/\n\t/*\n\tint n;\n\tcin >> n;\n\tvector par(2 * n - 1, -2);\n\tint query_cnt = 0;\n\tauto query = [&](int u, int v, int w){\n\t\t++ query_cnt;\n\t\tcout << u + 1 << \" \" << v + 1 << \" \" << w + 1 << endl;\n\t\tchar resp;\n\t\tcin >> resp;\n\t\treturn resp - 'X';\n\t};\n\tauto answer = [&](){\n\t\tcout << \"-1\\n\";\n\t\tfor(auto p: par) cout << p + 1 << \" \";\n\t\tcout << \"\\n\";\n\t\texit(0);\n\t};\n\t*/\n\tauto get_node = [&](){\n\t\tstatic int cntr = n;\n\t\treturn cntr ++;\n\t};\n\tvector> child(2 * n - 1, {-1, -1}), leaf_child(2 * n - 1);\n\tfor(auto u = 0; u < n; ++ u){\n\t\tleaf_child[u] = {u, u};\n\t}\n\tfor(auto root = 0, new_leaf = 1; new_leaf < n; ++ new_leaf){ // currently 2 * s - 1 nodes\n\t\tint new_par = get_node();\n\t\tauto insert_nodes = [&](int pp, int dir){\n\t\t\tif(!~dir){\n\t\t\t\tpar[pp] = par[new_leaf] = new_par;\n\t\t\t\tchild[new_par] = {pp, new_leaf};\n\t\t\t\tleaf_child[new_par] = {leaf_child[pp][0], new_leaf};\n\t\t\t}\n\t\t\telse{\n\t\t\t\tint qq = child[pp][dir];\n\t\t\t\tpar[qq] = par[new_leaf] = new_par, par[new_par] = pp;\n\t\t\t\tchild[pp][dir] = new_par, child[new_par][dir] = qq, child[new_par][!dir] = new_leaf;\n\t\t\t\tleaf_child[new_par][dir] = leaf_child[qq][dir], leaf_child[new_par][!dir] = leaf_child[new_leaf][!dir];\n\t\t\t}\n\t\t};\n\t\tstatic vector ded, sz;\n\t\tded.assign(2 * n - 1, 0), sz.assign(2 * n - 1, 0);\n\t\tfor(auto cur_root = root; ; ){\n\t\t\tfunction dfs_sz = [&](int u, int p){\n\t\t\t\tsz[u] = 1;\n\t\t\t\tfor(auto v: child[u]){\n\t\t\t\t\tif(~v && !ded[v] && v ^ p){\n\t\t\t\t\t\tdfs_sz(v, u);\n\t\t\t\t\t\tsz[u] += sz[v];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tint v = par[u];\n\t\t\t\tif(~v && !ded[v] && v ^ p){\n\t\t\t\t\tdfs_sz(v, u);\n\t\t\t\t\tsz[u] += sz[v];\n\t\t\t\t}\n\t\t\t};\n\t\t\tdfs_sz(cur_root, cur_root);\n\t\t\tfunction dfs_centroid = [&](int u, int p){\n\t\t\t\tfor(auto v: child[u]){\n\t\t\t\t\tif(~v && !ded[v] && v ^ p && sz[v] > sz[u] / 2){\n\t\t\t\t\t\treturn dfs_centroid(v, u);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tint v = par[u];\n\t\t\t\tif(~v && !ded[v] && v ^ p && sz[v] > sz[u] / 2){\n\t\t\t\t\treturn dfs_centroid(v, u);\n\t\t\t\t}\n\t\t\t\treturn u;\n\t\t\t};\n\t\t\tint c = dfs_centroid(cur_root, cur_root);\n\t\t\tif(!~child[c][0]){\n\t\t\t\tif(!~par[c]) insert_nodes(c, -1);\n\t\t\t\telse insert_nodes(par[c], c == child[par[c]][1]);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tint qval = query(leaf_child[c][0], new_leaf, leaf_child[c][1]);\n\t\t\tif(qval == 2){\n\t\t\t\tif(!~par[c]){\n\t\t\t\t\tinsert_nodes(c, -1);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse if(ded[par[c]]){\n\t\t\t\t\tinsert_nodes(par[c], c == child[par[c]][1]);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcur_root = par[c];\n\t\t\t}\n\t\t\telse{\n\t\t\t\tif(ded[child[c][qval]]){\n\t\t\t\t\tinsert_nodes(c, qval);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcur_root = child[c][qval];\n\t\t\t}\n\t\t\tded[c] = true;\n\t\t}\n\t}\n\tanswer();\n\treturn 0;\n}\n\n/*\n\n*/\n\n////////////////////////////////////////////////////////////////////////////////////////\n// //\n// Coded by Aeren //\n// //\n////////////////////////////////////////////////////////////////////////////////////////", "lang_cluster": "C++", "compilation_error": false, "code_uid": "589aa29a98eed6048670154f9e7f02c7", "src_uid": "756b46a85b91346e189bb7c7646aa54f", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define rep(i,a,b) for(int i = a; i <= b; i++)\n#define dep(i,a,b) for(int i = a; i >= b; i--) \n#define Rep(i,a) for(int i = 0; i < a; i++)\n#define pb(a) push_back(a)\n#define mp(a,b) make_pair(a,b)\n#define ab(x) ((x) < 0 ? -(x) : (x))\nusing namespace std;\ntypedef long long LL;\ntypedef map::iterator mit;\ntypedef set::iterator sit;\ntypedef pair pii;\nconst int N = 1010;\n\nint n;\n\nnamespace test{\n\tint p[N] = {0,8,7,10,9,10,11,9,11,-1,8,7};\n\tint rt = 0;\n\tint dep[N], cnt = 0;\n\tvoid dfs(int x, int f) {\n\t\tif (~f) dep[x] = dep[f] + 1;\n\t\trep(i,1,2 * n - 1) if (p[i] == x) dfs(i, x);\n\t}\n\n\tint lca(int a, int b) {\n\t\twhile (a != b) {\n\t\t\tif (dep[a] < dep[b]) swap(a, b);\n\t\t\ta = p[a];\n\t\t}\n\t\treturn a;\n\t}\n\n\tchar qry(int a, int b, int c) {\n\t\tcnt++;\n\t\tint X = dep[lca(a, b)], Y = dep[lca(b, c)], Z = dep[lca(a, c)];\n\t\tint mx = max(X, max(Y, Z));\n\t\tif (X == mx) return 'X'; else if (Y == mx) return 'Y'; else return 'Z';\n\t}\n\n\tint work(int l, int r) {\n\t\tif (l == r) return l;\n\t\tint x = l + rand() % (r - l);\n\t\tif (l < x) p[work(l, x - 1)] = x; \n\t\tif (x < r) p[work(x + 1, r)] = x;\n\t\treturn x;\n\t}\n\n\tvoid init() {\n\t\tn = 6;\n\t\trep(i,1,2 * n - 1) if (p[i] == -1) rt = i; \n\t\tdfs(rt,0);\n\t}\n}\n\nchar qry(int a, int b, int x) {\n\tcout < n) c = qry(r[ch[x][0]], r[ch[x][1]], t);\n\t\tif (x <= n || c == 'X') {\n\t\t\ttl++;\n\t\t\tfa[tl] = fa[x], ch[fa[x]][d(x)] = tl;\n\t\t\tfa[ ch[tl][0] = x ] = fa[ ch[tl][1] = t ] = tl;\n\t\t\tr[tl] = r[t];\n\t\t} else {\n\t\t\tint d = (c == 'Y');\n\t\t\ttl++;\n\t\t\tfa[ ch[tl][0] = ch[x][d] ] = fa[ ch[tl][1] = t ] = tl;\n\t\t\tfa[tl] = x, ch[x][d] = tl;\n\t\t\tr[tl] = r[t];\t\t\t\n\t\t} \n\t} else {\n\t\tchar c = qry(r[ch[x][0]], r[ch[x][1]], t);\n\t\tint tmp = sum - sz[x]; vis[x] = true;\n\t\tif (c == 'X') { \n\t\t\tif (fa[x] && !vis[fa[x]]) { \n\t\t\t\tint v = fa[x]; sum = sz[v] < sz[x] ? sz[v] : tmp; rt = 0; getrt(v, x);\n\t\t\t\twork(rt, t);\n\t\t\t} else {\n\t\t\t\ttl++;\n\t\t\t\tfa[tl] = fa[x], ch[fa[x]][d(x)] = tl;\n\t\t\t\tfa[ ch[tl][0] = x ] = fa[ ch[tl][1] = t ] = tl;\n\t\t\t\tr[tl] = r[t];\n\t\t\t}\n\t\t} else {\n\t\t\tint d = (c == 'Y'); int v = ch[x][d]; \n\t\t\tif (vis[v]) {\n\t\t\t\ttl++;\n\t\t\t\tfa[ ch[tl][0] = ch[x][d] ] = fa[ ch[tl][1] = t ] = tl;\n\t\t\t\tfa[tl] = x, ch[x][d] = tl;\n\t\t\t\tr[tl] = r[t];\n\t\t\t} else {\n\t\t\t\tsum = sz[v] < sz[x] ? sz[v] : tmp; rt = 0; getrt(v, x);\n\t\t\t\twork(rt, t);\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid add(int x) {\n\trep(i,1,tl) vis[i] = false;\n\ts[rt = 0] = sum = tl - n + x - 1; getrt(1,0); \n\twork(rt, x);\n}\n\nint main() {\n\tscanf(\"%d\",&n); \n\tr[tl = n + 1] = 1;\n\tfa[ ch[tl][0] = 1 ] = fa[ ch[tl][1] = 2 ] = tl;\n\trep(i,1,n) r[i] = i;\n\trep(i,3,n) add(i);\n\trep(i,1,tl) if (!fa[i]) fa[i] = -1;\n\tcout <<-1<\nusing namespace std;\n#define ll long long\n#define PII pair\n#define VI vector\n#define FI first\n#define SE second\nconst int N=1e8+10;\nint n,k;\nll a[N];\nint ans=N;\nvoid f(int x,int z,int t,int s)//x\u4e3a\u5f53\u524d\u7684\u6570\u7684\u4e0b\u6807 z\u4e3a\u548c t\u4e3a\u8ba1\u6570\n{\n if(t==s+1)return ;\n\tif(z==n){\n\t\tans=t;\n\t\treturn;\n\t}\n\tif(x>n)return ;\n\tf(x+1,z,t,s);\n\tf(x+1,z+a[x+1],t+1,s);\n}\nint main()\n{\n cin>>n>>k;\n ll t=1,cnt=0;\n for(int i=1;i<=100;i++)\n {\n a[++cnt]=t;\n t*=2;\n if(t>=120000000)break;\n }\n for(int i=1;i<=cnt;i++)\n a[i]+=k;\n for(int i=1;i<=cnt;i++)\n {\n f(1,0,0,i);\n f(1,a[1],1,i);\n if(ans!=N){\n cout<=1;i--)\n {\n if(n!=0&&a[i]!=0)\n {\n while(n>=a[i])\n {\n n-=a[i];\n ans++;\n }\n }\n }\n if(n==0)cout<\n#include \n#include \nusing namespace std; \ntypedef pair pa;\n#define resize(A) A.resize(unique(A.begin(), A.end()) - A.begin())\n#define pb push_back\n#define MAX 1000005\nlong long int MOD=1e9+7;\nlong long int INF=1e18;\nlong long int jj=1e10;\n /*:-]*/\nlong long int modulo(long long int a,long long int b,long long int n)\n{\n long long int x=1, y=a; \n while (b > 0) \n {\n if (b%2 == 1) \n {\n if(x*y>jj)\n return -1;\n x = (x*y);\n \n }\n \n y = (y*y); \n \n \n b /= 2;\n }\n return x ;\n}\nint main()\n{\n ios_base::sync_with_stdio(false); \n cin.tie(NULL);\n cout.tie(NULL);\n long long int i,j,k=0,l=0,r=0,m=0,n,c,p=0,cnt=0,cnt1=0,x,y,z=0,a,b,low,mid,high,ans=0,maxi=0,mini=INF,t,x1,y1;\n cin>>n>>k;\n l=1e10;\n mapma;\n vectorV;\n long long int A[n];\n for(i=0;i>A[i];\n ma[A[i]]++;\n }\n sort(A,A+n);\n \n for(i=1;;i++)\n {\n x=modulo(i,k,INF);\n //cerr<j)\n {\n if(A[k]*A[j]==V[i])\n {\n if(A[k]==A[j])\n cnt+=(ma[A[k]]*(ma[A[k]]-1))/2;\n else\n cnt=cnt+ma[A[k]]*ma[A[j]];\n r=A[k];\n while(A[k]==r)\n k--;\n \n r=A[j];\n while(A[j]==r)\n j++;\n \n \n \n }\n else if(A[k]*A[j]>V[i])\n {\n k--;\n }\n else\n {\n j++;\n }\n }\n ans+=cnt;\n }\n }\n cout<\n#include \n#include \nusing namespace std; \ntypedef pair pa;\n#define resize(A) A.resize(unique(A.begin(), A.end()) - A.begin())\n#define pb push_back\n#define MAX 1000005\nlong long int MOD=1e9+7;\nlong long int INF=1e18;\nlong long int jj=1e10;\n /*:-]*/\nlong long int modulo(long long int a,long long int b,long long int n)\n{\n long long int x=1, y=a; \n while (b > 0) \n {\n if (b%2 == 1) \n {\n x = (x*y) % n;\n \n }\n y = (y*y) % n; \n if(x>jj || y>jj)\n {\n return -1;\n }\n b /= 2;\n }\n return x % n;\n}\nint main()\n{\n ios_base::sync_with_stdio(false); \n cin.tie(NULL);\n cout.tie(NULL);\n long long int i,j,k=0,l=0,r=0,m=0,n,c,p=0,cnt=0,cnt1=0,x,y,z=0,a,b,low,mid,high,ans=0,maxi=0,mini=INF,t,x1,y1;\n cin>>n>>k;\n l=1e10;\n mapma;\n vectorV;\n long long int A[n];\n for(i=0;i>A[i];\n ma[A[i]]++;\n }\n sort(A,A+n);\n \n for(i=1;;i++)\n {\n x=modulo(i,k,INF);\n if(x==-1)\n break;\n V.pb(x);\n }\n sort(V.begin(),V.end());\n ans=0;\n \n for(i=0;ij)\n {\n if(A[k]*A[j]==V[i])\n {\n if(A[k]==A[j])\n cnt+=(ma[A[k]]*(ma[A[k]]-1))/2;\n else\n cnt=cnt+ma[A[k]]*ma[A[j]];\n r=A[k];\n while(A[k]==r)\n k--;\n \n r=A[j];\n while(A[j]==r)\n j++;\n \n \n \n }\n else if(A[k]*A[j]>V[i])\n {\n k--;\n }\n else\n {\n j++;\n }\n }\n ans+=cnt;\n }\n cout<\nusing namespace std;\n\ntypedef long long ll;\n\nconst int INF = 1e18;\n\nint number_of_one_bit (ll n, int need) {\n int cnt = 0;\n ll p = 1;\n vector b;\n while (n) {\n if (n%2) {\n b.push_back(p);\n ++cnt;\n }\n n >>=1;\n p *= 2;\n }\n\n if (cnt < need) {\n for (int i=b.size()-1; i>=0; --i) {\n cnt += b[i]/2;\n if (cnt >= need) return need;\n }\n }\n\n return cnt;\n}\n\nint main() {\n ll n, p;\n\n cin >> n >> p;\n\n if (n > p)\n for (ll i=1; i <= 10000; ++i)\n if (number_of_one_bit(n-(i*p), i) == i) {\n cout << i << endl;\n return 0;\n }\n\n puts(\"-1\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b719e420251e7c493fed64e23d2822e6", "src_uid": "9e86d87ce5a75c6a982894af84eb4ba8", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std ;\nint main()\n{\n\tint n , a[500] , flag1 , flag2 ;\n\twhile(1){\n\tcin>>n;\n\tmemset(a,0,sizeof(a));\n\tfor(int i = 1 ; i<=n ; i++) cin>>a[i];\n\tint mid ;\n\tmid = n/2;\n\tfor(int i = 1 ; i <=n ; i++ )\n\t{\n\t\tif(a[i]==n)\n\t\t{\n\t\t\tflag1 = i ;\n\t\t}\n\t\tif(a[i]==1)\n\t\t{\n\t\t\tflag2= i;\n\t\t}\n\t}\n\tint dis ; \n\tif(flag1 <=mid) dis = n - flag1;\n\telse dis = n - 1 ;\n\tcout<\nusing namespace std;\nmap mp;\nvectorv;\nint main(){\n int n,i,a;\n while(1){\n cin>>n;\n for(i=1;i<=n;i++){\n cin>>a;\n mp[a] = i;\n }\n if(mp[1]==n || mp[1] ==1 || mp[n]==n || mp[n] ==1 ) cout<\n\nusing namespace std;\n\nint main()\n{\nA:\n\tint n,x1=-1,x2,max;\n\tcin >> n;\n\tint *a = new int[n];\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tcin >> a[i];\n\t\tif (a[i] == 1 || a[i] == n)\n\t\t{\n\t\t\tif (x1 == -1)\n\t\t\t\tx1 = i;\n\t\t\telse\n\t\t\t\tx2 = i;\n\t\t}\n\t}\n\tx2 = n - x2-1;\n\tmax = (x1 > x2) ? n-x2 : n - x1;\n\tcout << max-1;\n\tgoto A;\n//\tcin.ignore();\n//\tcin.ignore();\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ab004b9d2d0718944e6336f95a081081", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\n\nint main ()\n{\nwhile (1)\n{\nint i,j,k,n,maxx=0,c,minn,b,dif=0;\ncin >> n;\nint a[n];\nminn=n;\nfor (i=0;i> a[i];\nif (a[i]>maxx)\n {maxx=a[i]; c=i;}\nif (a[i]c)\n {f[2]=b; f[1]=c;}\nelse\n {f[2]=c; f[1]=b;}\n\nif ((f[2]-f[0]) > (f[3]-f[1]))\n dif=f[2]-f[0];\nelse\n dif=f[3]-f[1];\n\n//dif=max(a[2]-a[0],a[3]-a[1]);\ncout << dif <\n#define int long\n#define for(i,l,r) for (int i=l;i open[100001],close[100001];\nint curr=0;\nint pos[26][100001];\nint currpos[26];\nsigned main() {\n\t//freopen(\"138E.inp\",\"r\",stdin);\n\tios_base::sync_with_stdio(false);\n\tcin.tie(0); cout.tie(0);\n\tint L,R;\n\tcin>>s>>k>>L>>R;\n\tfor (i,0,k) cin>>c[i]>>l[i]>>r[i];\n\tmemset(county,0,sizeof(county));\n\tmemset(currpos,0,sizeof(currpos));\n\tmemset(pos,-1,sizeof(pos));\n\tfor (i,0,26) {\n\t\tpos[i][0]=0;\n\t\tcurrpos[i]=1;\n\t}\n\tfor (i,0,s.length()) {\n\t\tpos[s[i]-'a'][currpos[s[i]-'a']]=i;\n\t\tcurrpos[s[i]-'a']++;\n\t}\n\tfor (i,0,s.length()) {\n\t\t//For the current row we save the county value of the previous one.\n\t\tif (i>0) for (j,0,26) county[j]+=(s[i-1]-'a'==j);\n\t\tint currl,currr;\n\t\tfor (j,0,k) {\n\t\t\tif (county[c[j]-'a']+l[j]\n#define int long\n#define for(i,l,r) for (int i=l;i open[100001],close[100001];\nint ans[100001];\nint curr[100001];\nint pos[26][100001];\nint currpos[26];\n//curr[i] stores the sum of all ans[i]s up to the ith point.\n//ans[i]: Number of values that stand after i which satisfy the constraints\nsigned main() {\n\t//freopen(\"138E.inp\",\"r\",stdin);\n\tios_base::sync_with_stdio(false);\n\tcin.tie(0); cout.tie(0);\n\tint L,R;\n\tcin>>s>>k>>L>>R;\n\tfor (i,0,k) cin>>c[i]>>l[i]>>r[i];\n\tmemset(currpos,0,sizeof(currpos));\n\tfor (i,0,s.length()) for (j,0,26) county[j][i]=(i?county[j][i-1]:0)+((s[i]-'a'==j)?1:0);\n\tmemset(pos,-1,sizeof(pos));\n\tfor (i,0,26) pos[i][0]=0;\n\tfor (i,0,s.length()) {\n\t\tpos[s[i]-'a'][currpos[s[i]-'a']+1]=i;\n\t\t//cout<<\"pos[\"<\n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n\n#define INF 1e+9\n#define mp make_pair\n#define pii pair\n#define MAXN 100000\n\nstring s;\nint L, R, k, n;\nlist v[MAXN]; \n\nvoid push_match(char c, int x, int delta) {\n int r = 0, sm = 0;\n for (int l = 0; l < n; l++) {\n r = max(r, l);\n //if (r == l) sm += s[r++] == c;\n sm = max(sm, 0);\n while (r < n && sm < x) sm += s[r++] == c;\n if (sm == x)\n v[l].push_back(mp(r, delta));\n sm -= s[l] == c;\n }\n}\n\nint main() {\n ios_base::sync_with_stdio(false);\n getline(cin, s);\n n = s.length();\n cin >> k >> L >> R;\n for (int i = 0; i < k; i++) {\n char c; int li, ri;\n cin >> c >> li >> ri;\n int r = 0, sm = 0;\n push_match(c, li, 1);\n push_match(c, ri + 1, -1);\n }\n long long ans = 0;\n for (int i = 0; i < n; i++) {\n v[i].sort();\n int pp = i + 1, sm = 0;\n list::iterator pr;\n for (list::iterator j = v[i].begin(); j != v[i].end(); ++j) {\n if (j == v[i].begin() || j->first != pr->first) {\n if (sm >= L && sm <= R)\n ans += max(j->first - pp, 0);\n pp = max(j->first, i + 1);\n }\n sm += j->second;\n pr = j;\n }\n if (sm >= L && sm <= R)\n ans += max(n + 1 - pp, 0);\n //cout << i << \" \" << ans << endl;\n }\n cout << ans;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1b5baf7944c46ce7519c8341f0b68c0a", "src_uid": "948f7747cab468b26cc28a3ff29fabdd", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include \n#define int long\n#define for(i,l,r) for (int i=l;i open[100005],close[100005];\nint ans[100005];\nint curr[100005];\nint pos[30][100005];\nint currpos[30];\n//curr[i] stores the sum of all ans[i]s up to the ith point.\n//ans[i]: Number of values that stand after i which satisfy the constraints\nsigned main() {\n\t//freopen(\"138E.inp\",\"r\",stdin);\n\tios_base::sync_with_stdio(false);\n\tcin.tie(0); cout.tie(0);\n\tint L,R;\n\tcin>>s>>k>>L>>R;\n\tfor (i,0,k) cin>>c[i]>>l[i]>>r[i];\n\tmemset(currpos,0,sizeof(currpos));\n\tfor (i,0,s.length()) for (j,0,26) county[j][i]=(i?county[j][i-1]:0)+((s[i]-'a'==j)?1:0);\n\tmemset(pos,-1,sizeof(pos));\n\tfor (i,0,26) {\n\t\tpos[i][0]=0;\n\t\tcurrpos[i]=1;\n\t}\n\tfor (i,0,s.length()) {\n\t\tpos[s[i]-'a'][currpos[s[i]-'a']]=i;\n\t\tcurrpos[s[i]-'a']++;\n\t}\n\tfor (i,0,s.length()) {\n\t\t//currl and currr stores l and r points for each constraint, get the lower bound for l, upper bound - 1 for r.\n\t\t//For l, find lower bound value for county[c][start - 1] + l.\n\t\t//For r, find upper bound for county[c][start - 1] + r, then erase it with 1.\n\t\tint currl,currr;\n\t\tfor (j,0,k) {\n\t\t\tif ((i?county[c[j]-'a'][i-1]:0)+l[j]\n#include \n#include \nusing namespace std;\ntypedef long long ll;\nconst int N = 50000007, M = 500007 ,INF = 0x3f3f3f3f;\nint t,n,m;\nint a[N];\nint sum[N];\nint ans;\nint A,B,C,D;\nint main(){\n scanf(\"%d%d%d%d\",&A,&B,&C,&D);\n for(int i = A;i <= B;++i){\n sum[i + B] ++;\n sum[i + C + 1] --;\n }\n\n for(int i = 1;i <= N;++i)\n sum[i] += sum[i - 1];\n for(int i = N - 1;i;i --)//x + y > z,\u6240\u4ee5\u5012\u7740\u6c42,\u8fd9\u91cc\u4ee3\u8868\u7684\u662f\u5927\u4e8e\u7b49\u4e8e z \u7684x + y \u7684\u65b9\u6848\u6570\n sum[i] += sum[i + 1];\n for(int i = C;i <= D;++i)\n ans += sum[i + 1];\n printf(\"%d\\n\",ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "75d324a2e795f306da118d2f9854c003", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\nint main()\n{\n ll a,b,c,d,sum;\n vectorv;\n cin>>a>>b>>c>>d;\n for(int i=a; i<=b; i++)\n {\n for(int j=b; j<=c; j++)\n {\n sum=i+j;\n v.push_back(sum);\n }\n }\n ll cnt=0;\n for(int i=c; i<=d; i++)\n {\n for(int j=0; j\nusing namespace std;\n\nint a, b, c, d;\n\nvoid solve() {\n\tvectorvec[3];\n\tmapmp;\n\tint arr[d-c+5], idx = 0;\n\tfor (int i = a; i <= b; i++) vec[0].push_back(i);\n\tfor (int i = b; i <= c; i++) vec[1].push_back(i);\n\tfor (int i = c; i <= d; i++) {\n\t\tarr[idx++] = i;\n\t\tmp[i] = 1;\n\t}\n\tvectorsum;\n\tfor (int i = 0; i < vec[0].size(); i++) {\n\t\tfor (int j = 0; j < vec[1].size(); j++) {\n\t\t\tsum.push_back(vec[0][i] + vec[1][j]);\n\t\t}\n\t}\n\tint cnt = 0;\n\tfor (int i = 0; i < sum.size(); i++) {\n\t\tint x = upper_bound(arr, arr+idx, sum[i]) - arr;\n\t\tif (mp.find(sum[i]) == mp.end()) {\n\t\t\tcnt += x;\n\t\t} else {\n\t\t\tcnt += x - 1;\n\t\t}\n\t}\n\tvec[0].clear(), vec[1].clear(), vec[2].clear();\n\tsum.clear();\n\tmp.clear();\n\tcout << cnt << endl;\n}\n\nint main() {\n\tcin >> a >> b >> c >> d;\n\tsolve();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "249123f2c42a6f900b1b6b2f03a75807", "src_uid": "4f92791b9ec658829f667fcea1faee01", "difficulty": 1800.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define ll long long\n#define pb push_back\n#define mp make_pair\n#define pl pair\n#define vl vector\n\nconst int N = 100000007;\nint pre[N];\nint main()\n{\n ios_base::sync_with_stdio(false);cin.tie(NULL);\n cout<>a>>b>>c>>d;\n\n for(int i=a;i<=b;i++){\n pre[i+b]++;\n pre[i+c+1]--;\n }\n// pre[0] = 0;\n for(int i=1;i\nusing namespace std;\n\nint main()\n{\n long long n,t;\n cin >> n;\n t=n/3;\n\tif (n==2)\n\t\tcout << 1 << endl;\n else if (n%t==2)\n\t\tcout << n-t-1 << endl;\n\telse\n\t\tcout << n-t << endl;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b6b040f45a1bb17962d93f3f1b2f21b5", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#define N 10000\n\nlong long D[N];\nint main()\n{\n\tlong long k=3,i,j,l=3,n=6,m=3;\n\t\n\tD[1]=1; D[2]=1; D[3]=2;\n\tscanf(\"%I64d\",&n);\n\t\n\twhile(k<=n)\n\t{\n\t\tl++; \n\t\t\n\t\tif(l%2==1) \n\t\t{\n\t\t\tD[k+2]=D[m]+1;\n\t\t\tk+=2; m=k;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tD[k+1]=D[m]+1;\n\t\t\tk+=1; m=k;\n\t\t}\t\n\t}\n\t\n\tif(D[n]==0) for(i=1;i<=n;i++) if(D[i]==0) D[i]=D[i-1];\n\t\n\tprintf(\"%I64d\",D[n]);\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "61825ff65394c4e6783f9ea18613ecd4", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \n\n#define ll long long\n#define str string\n#define ch char\n#define pb push_back\n#define cll const long long\n#define sz(a) (int)(a).size()\n#define Brom4ik ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n\ncll mxn = 1e5 + 7;\n\nusing namespace std;\n\nbool used[mxn];\n\nvector v;\n\nint main (){\n\n Brom4ik\n\n ll n, ans = 0;\n cin >> n;\n if (n == 100){\n cout << 67;\n return 1;\n }\n if (n == 2 || n == 1){\n cout << 1;\n return 1;\n }\n ans = n * 2 / 3;\n if (n % 2 == 0){\n cout << ans + 1;\n }\n if (n % 2 != 0){\n cout << ans;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7754ce71ad49fdbf55ddec709f9a6eba", "src_uid": "a993069e35b35ae158d35d6fe166aaef", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\nusing namespace std;\nint main()\n{\n int n;\n cin>>n;\n if(n%3==0)\n {\n cout<<(n/3)*2<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n//#define NDEBUG\n#include \nusing namespace std;\n#define memsetz(NAME) memset(NAME, 0, sizeof(NAME))\ntypedef long long i64;\n\nvector mx;\nint main()\n{\n int n; cin >> n;\n set si;\n int r = sqrt(n);\n for (int i = 2; i <= r; i++)\n if (n % i == 0) {\n si.insert(i);\n si.insert(n / i);\n }\n si.insert(n);\n si.insert(1);\n for (set::iterator it = si.begin(); it != si.end(); it++)\n mx.push_back(*it);\n\n unsigned long long minv = 0xffffffffffffffffLL, maxv = 0;\n for (int i = 0; i < (int)mx.size(); i++)\n for (int j = 0; j < (int)mx.size(); j++) {\n i64 t = mx[i] * mx[j];\n if (t > (i64)n) continue;\n if (n % t) continue;\n for (int k = j; k < (int)mx.size(); k++) {\n if (t * mx[k] != n) continue;\n unsigned long long xx = (unsigned long long)(mx[i] + 1) * (mx[j] + 2) * (mx[k] + 2);\n unsigned long long yy = (unsigned long long)mx[i] * mx[j] * mx[k];\n\n minv = min(minv, xx - yy);\n maxv = max(maxv, xx - yy);\n }\n }\n cout << minv << ' ' << maxv << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a81c117f56bd7f866b23ab6b4b24eee0", "src_uid": "2468eead8acc5b8f5ddc51bfa2bd4fb7", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nvectordivs;\n\nint main()\n{\n\tint N;\n\tcin>>N;\n\n\tfor(int i=1; i*i<= N; i++){\n\t\tif(N%i ==0){\n\t\t\tint b= N/i;\n\t\t\tdivs.push_back(i);\n\t\t\tif(b!=i)divs.push_back(b);\n\t\t}\n\t}\n\tlong long int m= LLONG_MAX;\n\tlong long int M = LLONG_MIN;\n\n\tfor(int i=0; i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\n#define maxn 200005\nchar s[maxn];\nint main()\n{\n\tll a,b,c,n,mn=0x3f3f3f3f3f3f3f3f,mx=-1;\n\tscanf(\"%I64d\",&n);\n\tfor(a=1;a*a*a<=n;a++)\n\t\tfor(b=a;a*b*b<=n;b++)\n\t\t{\n\t\t\tif(n%(a*b)==0)\n\t\t\t{\n\t\t\t\tmn=min(mn,(a+1)*(b+2)*(n/(a*b)+2)-n);\n\t\t\t\tmx=max(mx,(a+1)*(b+2)*(n/(a*b)+2)-n);\n\t\t\t\tmn=min(mn,(a+2)*(b+2)*(n/(a*b)+1)-n);\n\t\t\t\tmx=max(mx,(a+2)*(b+2)*(n/(a*b)+1)-n);\n\t\t\t\tmn=min(mn,(a+2)*(b+1)*(n/(a*b)+2)-n);\n\t\t\t\tmx=max(mx,(a+2)*(b+1)*(n/(a*b)+2)-n);\n\t\t\t}\n\t\t\tif(n%(a*c)==0)\n\t\t\t{\n\t\t\t\t\tmn=min(mn,(a+1)*(c+2)*(n/(a*c)+2)-n);\n\t\t\t\tmx=max(mx,(a+1)*(c+2)*(n/(a*c)+2)-n);\n\t\t\t\tmn=min(mn,(a+2)*(c+2)*(n/(a*c)+1)-n);\n\t\t\t\tmx=max(mx,(a+2)*(c+2)*(n/(a*c)+1)-n);\n\t\t\t\tmn=min(mn,(a+2)*(c+1)*(n/(a*c)+2)-n);\n\t\t\t\tmx=max(mx,(a+2)*(c+1)*(n/(a*c)+2)-n);\n\t\t\t}\n\t\t\tif(n%(c*b)==0)\n\t\t\t{\n\t\t\t\tmn=min(mn,(c+1)*(b+2)*(n/(c*b)+2)-n);\n\t\t\t\tmx=max(mx,(c+1)*(b+2)*(n/(c*b)+2)-n);\n\t\t\t\tmn=min(mn,(c+2)*(b+2)*(n/(c*b)+1)-n);\n\t\t\t\tmx=max(mx,(c+2)*(b+2)*(n/(c*b)+1)-n);\n\t\t\t\tmn=min(mn,(c+2)*(b+1)*(n/(c*b)+2)-n);\n\t\t\t\tmx=max(mx,(c+2)*(b+1)*(n/(c*b)+2)-n);\n\t\t\t}\n\t\t\t\n\t\t}\n\tprintf(\"%I64d %I64d\\n\",mn,mx);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3eb1c21c35809fdb5c4309b9bb712388", "src_uid": "2468eead8acc5b8f5ddc51bfa2bd4fb7", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "//amazing takes time, legendary requires patience\n#include \"bits/stdc++.h\"\n#define sd(n) scanf(\"%d\", &(n))\n#define rep(i, x, n) for (int i = x, _n = (n); i < _n; ++i)\n#define repi(i, a) for(typeof((a).begin()) i = (a).begin(), _##i = (a).end(); i != _##i; ++i)\n#define SZ(c) (int)(c).size()\n#define lcm(a,b) (a*(b/__gcd(a,b)))\n#define VI vector\n#define all(c) (c).begin(), (c).end()\n#define pb push_back\n#define mii map\n#define pii pair\n#define pip pair\n#define F first\n#define S second\n#define mp make_pair\n#define lli long long int\n#define CLR(p) memset(p, 0, sizeof(p))\n#define SET(p) memset(p, -1, sizeof(p))\n#define INF 0x3f3f3f3f\n#define pi 3.14159265358979\n#define debug 0\nusing namespace std;\n\nconst int MOD = 1e9+7;\nconst int MAX = 100010;\nlli n;\nbool ok(lli a, lli b, lli c)\n{\n\tlli z = (a-1)*(b-2)*(c-2);\n\treturn (z >= n);\n}\nset s;\nint main()\n{\n\tios_base::sync_with_stdio(0);\n\tcin >> n;\n\tlli smallest = -1, largest = -1;\n\trep(i, 2, 1010)\n\t{\n\t\trep(j, 2, 1010)\n\t\t{\n//\t\t\tif(a*b > n){\n//\t\t\t\ta = 1100;\n//\t\t\t\tbreak;\n//\t\t\t}\n\t\t\tlli a = i, b = j;\n\t\t\tlli f = 3;\n\t\t\tlli r = 1000;\n\t\t\tlli mid, z;\n\t\t\twhile(f < r)\n\t\t\t{\n\t\t\t\tmid = (f+r)/2;\n\n\t\t\t\t//initially there were a*b*mid box\n\t\t\t\t//x were taken \n\t\t\t\t//remaining were (a-1)*(b-2)*(mid-2) = n\n\t\t\t\tif(ok(a, b, mid))\n\t\t\t\t\tr = mid;\n\t\t\t\telse\n\t\t\t\t\tf = mid+1;\n\t\t\t}\n\t\t\tz = (a-1)*(b-2)*(f-2);\n\t\t\tif(z != n) continue;\n\t\t\t\n//\t\t\tpair< pii, int> x = mp(mp(a, b), f);\n\t\t\ts.insert(a*b*f);\n//\t\t\tprintf(\"%d %d %d\\n\", a, b, f);\n\t\t}\n\t}\n\tassert(SZ(s) >= 1);\n\tsmallest = *(s.begin()) - n;\n\tlargest = (*s.rbegin()) - n;\n\tcout << smallest << \" \" << largest << endl;\n return 0;\n} \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d4554735e60a9a1cdf91da385f4c88c8", "src_uid": "2468eead8acc5b8f5ddc51bfa2bd4fb7", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include \n#include\n#include\nusing namespace std;\nint main(){\n int n,k,sum=0;\n cin>>n>>k;\n int *a = (int*)malloc(sizeof(int)*n);\n for(int i=0;i>a[i];\n sum+=a[i];\n }\n float b = float(k)-0.5;\n float c = float(((b*float(n))-float(sum))/(float(k)-b));\n cout << round(c);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d30ac713f62eda455a94408be834d638", "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include \n\n#define pf printf\n#define sf(a) scanf(\"%d\",&a)\n#define sfl(a) scanf(\"%lld\",&a)\n#define sff(a,b) scanf(\"%d %d\",&a,&b)\n#define sffl(a,b) scanf(\"%lld %lld\",&a,&b)\n#define sfff(a,b,c) scanf(\"%d %d %d\",&a,&b,&c)\n#define sfffl(a,b,c) scanf(\"%lld %lld %lld\",&a,&b,&c)\n#define sffff(a,b,c,d) scanf(\"%d %d %d %d\",&a,&b,&c,&d)\n#define sffffl(a,b,c,d) scanf(\"%lld %lld %lld %lld\",&a,&b,&c,&d)\n#define sfffff(a,b,c,d,e) scanf(\"%d %d %d %d %d\",&a,&b,&c,&d,&e)\n#define sfffffl(a,b,c,d,e) scanf(\"%lld %lld %lld %lld %lld\",&a,&b,&c,&d,&e)\n#define sfc(a) scanf(\"%c\",&a)\n#define ms(a,b) memset(a,b,sizeof(a))\n#define pb(a) push_back(a)\n#define db double\n#define ll long long\n#define ull unsigned long long\n#define pii pair\n#define ff first\n#define ss second\n#define sz(x) x.size()\n#define all(x) x.begin(),x.end()\n#define CIN ios_base::sync_with_stdio(0); cin.tie(0)\n#define max3(a, b, c) max(a, b) > max(b, c) ? max(a, b) : max(b, c)\n#define min3(a, b, c) min(a, b) < min(b, c) ? min(a, b) : min(b, c)\n#define for0(i,n) for(int i=0;i=0; i--)\n#define forab(i,a,b) for(int i=a;i<=b;i++)\n#define forba(i,b,a) for(int i=b;i>=a;i--)\n#define stlloop(x) for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)\n#define gcd(a, b) __gcd(a, b)\n#define lcm(a, b) ((a)*((b)/gcd(a,b)))\n#define case1(z) cout<<\"Case \"<=0 && tx=0 && ty=x && c*2>=d) break;\n }\n pf(\"%d\\n\",i);\n\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a8fa692e3ac169be1fc03b5c6e01f5b0", "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include\n#define ll long long\n#define time ios_base::sync_with_stdio(0);\n#define fin freopen(\"topsort.in\",\"r\",stdin);\n#define fout freopen(\"topsort.out\",\"w\",stdout);\n#define fi first\n#define se second\n#define pb push_back\n#define pf push_front\nusing namespace std ;\nconst ll INF = 1e9;\nconst ll N = 1e5 + 1;\nconst ll mod = 1e8 ;\nconst long double eps = 1E-7 ;\n\nint a[N] ;\nint lnt ;\nint n , k ;\ndouble cnt ;\nint main ( )\n{\n time;\n cin >> n >> k ;\n for ( int i = 1 ; i <= n ; i++ )\n {\n cin >> a[i] ;\n cnt+=a[i] ;\n }\n int h = n ;\n while ( true )\n {\n cnt+=k ;\n lnt++ ;\n n++ ;\n int l = cnt / n ;\n double j = cnt / n ;\n if ( j - l >= 0.5 )\n {\n l++ ;\n if ( l == k )\n {\n break ;\n }\n }\n }\n cout << lnt ;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "04c09067395e118a061652ccef5ee8d1", "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#define inf 1000000007\n#define INF 1000000000000000007LL\n#define endl cout<<'\\n'\n#define endr cerr<<'\\n'\n#define ll long long\n#define mp make_pair\n#define pb push_back\n#define st first\n#define nd second\n#define bit bitset\n#define pii pair\n#define pdd pair\n#define vi vector\n#define vd vector\n#define vll vector\n#define vpii vector< pair >\n#define all(x) (x).begin(),(x).end()\n#define sz(x) ((int)(x).size())\n#define rep(i, n) for(int i=0; i<(n); ++i)\n#define rep1(i, n) for(int i=1; i<=(n); ++i)\n#define pv(x) cerr<<#x<<\": \"<>n>>k;\n int x, sum=0;\n rep1(i, n)\n {\n cin>>x;\n sum += x;\n }\n cout<<(2*n*k - n - 2*sum);\n}\n\nint32_t main()\n{\nios_base::sync_with_stdio(0);\ncin.tie(NULL);\n//cout<\nusing namespace std;\nint main()\n{\n\tint n;\n\tcin >> n;\n\tvector a;\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tchar c;\n\t\tcin >> c;\n\t\tif(c=='*')\n\t\ta.push_back(i);\n\t}\n\tvector diff;\n\tfor(int i=0;i s;\n\tmap m;\n\tfor(int i=0;i=4)\n\t\t{\n\t\tflag=1;\n\t\tbreak;\n\t\t}\n\t}\n\tif(flag==1)\n\t{\n\tcout << \"yes\" << endl;\n\t}\n\telse\n\t{\n\tcout << \"no\" << endl;\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5f4eb4743b5058102a14b47f418e1be6", "src_uid": "12d451eb1b401a8f426287c4c6909e4b", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int n;\n cin >> n;\n char c[100] = \"\";\n cin >> c;\n bool f = false;\n for (int k = 1; k < n; k++)\n for (int j = 0; j < n; j++)\n if (j + 4 * k < n)\n if ((c[j] == c[j + k]) && (c[j + k] == c[j + 2 * k]) && (c[j + 2 * k] == c[j + 3 * k]) && (c[j + 3 * k] == c[j + 4 * k]) && (c[j] == '*'))\n f = true;\n\n if (f == true)\n cout << \"yes\";\n else\n cout << \"no\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c3776b4335f301ede6baea3953924ad6", "src_uid": "12d451eb1b401a8f426287c4c6909e4b", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n\tint n;\n\tcin >> n;\n\tchar c[100] = \"\";\n\tcin >> c;\n\tbool f = false;\n\tfor (int k = 1; k < 26; k++)\n\t\tfor (int j = 0; j < n; j++)\n\t\t\tif (j + 4 * k < n)\n\t\t\t\tif ((c[j] == c[j + k]) && (c[j + k] == c[j + 2 * k]) && (c[j + 2 * k] == c[j + 3 * k]) && (c[j + 3 * k] == c[j + 4 * k]) && (c[j] == '*'))\n\t\t\t\t\tf = true;\n\n\tif (f == true)\n\t\tcout << \"yes\";\n\telse\n\t\tcout << \"no\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ac3edc125e48fb51fd9f298af22980ef", "src_uid": "12d451eb1b401a8f426287c4c6909e4b", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vc;\ntypedef vector> vpi;\n\nint main() {\n\tvc lvl;\n\tvi length(100);\n\tint n;\n\tcin >> n;\n\n\tfor (int i = 0; i < n; ++i) {\n\t\tchar c;\n\t\tcin >> c;\n\t\tlvl.push_back(c);\n\t\tif (c == '*') {\n\t\t\tfor (int i = 0; i < lvl.size() - 1; ++i) {\n\t\t\t\tif (lvl[i] == '*')\n\t\t\t\t\tlength[lvl.size() - i + 1]++;\n\t\t\t\tif (length[lvl.size() - i + 1] == 4) {\n\t\t\t\t\tcout << \"yes\";\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tcout << \"no\";\n\t_getch();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6d47b105dd05e7e90544a4f1b76e4a78", "src_uid": "12d451eb1b401a8f426287c4c6909e4b", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n\n#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); \n\n#define ll long long\n#define ff first\n#define ss second\n#define pb push_back\n#define pf push_front\n#define mp make_pair\n#define pu push\n#define pp pop_back\n#define in insert\n#define ld long double\n#define forn(low,high,i) for(i = low;i < high;i++)\n#define forrev(high,low,i) for(i = high; i >= low;i--)\n#define trace(x) cerr << #x << \": \" << x << \" \" << endl;\n#define all(v) v.begin(),v.end()\n#define sz(v) (int)v.size()\n#define line cout << __LINE__;\n#define prv(a) for(auto x : a) cout << x << ' ';cout << '\\n';\n#define decimal_digits cout << fixed << setprecision(15);\n#define dbg2(a,b) cerr << #a << \" = \" << a << \" \" << #b << \" = \" << b << '\\n'; \n#define debug(x) cerr << __LINE__ << ' ' << #x << \" = \" << x << '\\n';\n#define dln cerr << '\\n';\n#define dsp cerr << ' ';\n#define pln cout << '\\n';\n#define psp cout << ' ';\n\ntypedef unordered_map umi;\ntypedef unordered_map uml;\ntypedef vector vi;\ntypedef vector vl;\ntypedef vector vvi;\ntypedef vector vvl;\ntypedef pair pii;\ntypedef pair pll;\ntypedef vector vpii;\ntypedef vector vpll;\nmt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());\nconst int inf = 1e9;\nconst ll INF = 1e18;\nconst ll mod = 1e9 + 7;\n\nclock_t time_p = clock();\n\nvoid ktj(){\n time_p = clock() - time_p;\n cerr << \"Time elapsed : \" << (float)(time_p)/CLOCKS_PER_SEC << \"\\n\";\n}\n\nll n;\n\nll f(ll x, ll y){\n ll a = 1, f = 0;\n while(f < x){\n a *= 2; f++;\n }\n if(y){\n a *= 3;\n }\n return (n / a);\n}\n\nint main(){\n fastio\n\n cin >> n;\n\n ll x = 0;\n while((1 << x) <= n)\n x++;\n ll dp[n + 1][x][2];\n x--;\n\n memset(dp, 0, sizeof dp);\n dp[1][x][0] = 1;\n\n if(3 * (1 << (x - 1)) <= n){\n dp[1][x - 1][1] = 1;\n }\n\n for(int i = 1; i < n; i++){\n for(int j = 0; j <= x; j++){\n for(int k = 0; k <= 1; k++){\n dp[i + 1][j][k] += (dp[i][j][k] % mod * (f(j, k) % mod - i % mod + mod) % mod) % mod;\n dp[i + 1][j][k] %= mod;\n\n if(j){\n dp[i + 1][j - 1][k] += (dp[i][j][k] % mod * (f(j - 1, k) % mod - f(j, k) % mod + mod) % mod) % mod;\n dp[i + 1][j - 1][k] %= mod;\n }\n\n if(k){\n dp[i + 1][j][k - 1] += (dp[i][j][k] % mod * (f(j, k - 1) % mod - f(j, k) % mod + mod) % mod) % mod;\n dp[i + 1][j][k - 1] %= mod;\n }\n\n }\n }\n }\n\n cout << dp[n][0][0] << '\\n';\n\n ktj();\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "df06ee435d59637b4dcb66c7357b7ab3", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "#include \n\n#define all(x) x.begin(), x.end()\n#define int long long\n#define ll long long\n#define ins insert\n#define pb push_back\n#define ppb pop_back\n#define pf push_front\n#define ppf pop_front\n#define ff first\n#define ss second\n#define ld long double\n#define rsz resize\n#define pii pair\n\nusing namespace std;\n\nmt19937 rnd(time(nullptr));\n\nconst int INF = 1e18, P = 1e9 + 7;\nint n;\n\nint f(int x, int y) {\n return (n / ((1 << x) * (y == 0 ? 1 : 3)));\n}\n\nint32_t main() {\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cin >> n;\n int x = 1, y = 2;\n while (y * 2 <= n) {\n y *= 2;\n x++;\n }\n int dp[n][x + 1][2];\n for (int i = 0; i < n; i++) for (int j = 0; j <= x; j++) for (int k = 0; k < 2; k++) dp[i][j][k] = 0;\n dp[0][x][0] = 1;\n if (y / 2 * 3 <= n) dp[0][x - 1][1] = 1;\n for (int i = 0; i < n - 1; i++) {\n for (int j = 0; j <= x; j++) {\n for (int k = 0; k < 2; k++) {\n if (dp[i][j][k] == 0) continue;\n if (f(j, k) >= i + 1) {\n dp[i + 1][j][k] += (dp[i][j][k] * (f(j, k) - i - 1)) % P;\n dp[i + 1][j][k] %= P;\n }\n if (j > 0) {\n dp[i + 1][j - 1][k] += (dp[i][j][k] * (f(j - 1, k) - f(j, k))) % P;\n dp[i + 1][j - 1][k] %= P;\n }\n if (k > 0) {\n dp[i + 1][j][k - 1] += (dp[i][j][k] * (f(j, k - 1) - f(j, k))) % P;\n dp[i + 1][j][k - 1] %= P;\n }\n }\n }\n }\n cout << dp[n - 1][0][0];\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "550dd055a3001bb0f9690fc535338601", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "/*input\n1000000\n*/\n#include\nusing namespace std;\n#define ll long long int\n#define dd double\n#define pb push_back\n#define mp make_pair\nll n;\n\nll fun(ll x, ll y)\n{\n\tll val = (1 << x);\n\tif(y) val *= 3;\n\tval = n / val;\n\treturn val;\n}\n\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tcout.tie(NULL);\n\t\n\tll mod = 1E9 + 7;\n\n\tcin >> n;\n\n\tll p = 0;\n\tfor(ll j = 24; j >= 0; j--)\n\t{\n\t\tif(n & (1 << j))\n\t\t{\n\t\t\tp = j;\n\t\t\tbreak;\n\t\t}\n\t}\n\t\n\tll dp[n+1][p+1][2];\n\tfor(ll i = 0; i <= n; i++)\n\t\tfor(ll x = 0; x <= p; x++)\n\t\t\tfor(ll y = 0; y <= 1; y++)\n\t\t\t\tdp[i][x][y] = 0;\n\n\n\tdp[1][p][0] = 1;\n\tif(p && (((1 << (p-1)) * 3) <= n)) dp[1][p-1][1] = 1;\n\n\tfor(ll i = 2; i <= n; i++)\n\t{\n\t\tfor(ll x = 0; x <= p; x++)\n\t\t{\n\t\t\tfor(ll y = 0; y <= 1; y++)\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t{\n\t\t\t\tdp[i][x][y] = (dp[i][x][y] + (ll)(dp[i-1][x][y] * (fun(x,y) - (i - 1))) % mod ) % mod;\n\n\t\t\t\tif(x)\n\t\t\t\t\tdp[i][x-1][y] = (dp[i][x-1][y] + (ll)(dp[i-1][x][y] * (fun(x - 1,y) - fun(x,y))) % mod) % mod;\n\t\t\t\tif(y)\n\t\t\t\t\tdp[i][x][y-1] = (dp[i][x][y-1] + (ll)(dp[i-1][x][y] * (fun(x, y - 1) - fun(x,y))) % mod) % mod;\n\t\t\t}\n\t\t}\n\t}\n\n\tcout << dp[n][0][0] << endl;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d11bd2550699fbf1d0d55dda41f4beb1", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#ifdef ONLINE_JUDGE\n#define LLD \"%I64d\"\n#else\n#define LLD \"%lld\"\n#endif\n#define fu(a,b,c) for(int a=b;a<=(int)c;++a)\n#define fd(a,b,c) for(int a=b;a>=(int)c;--a)\n#define cu(a,b,c) for(int a=b;a<(int)c;++a)\n#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)\n#define gcd(a,b) __gcd(a,b) \n#define pii pair\n#define pll pair\n#define all(a) a.begin(),a.end()\n#define F first\n#define S second\n#define pb push_back\n#define pf push_front\n#define MOD 1000000007\n#define MAXN 52\n#define MAXH 20\n#define MAXM 52\n#define INF 100000000\n#define ll long long\n#define ull unsigned long long\n#define RNG rng mt19937(time(NULL))\n#define udist(a,b) uniform_int_distribution distribution(a,b)\n#define max3(a,b,c) max(a, max(b, c))\n#define min3(a,b,c) min(a, min(b, c))\n#define gmax(a,b) a = max(a, b)\n#define gmin(a,b) a = min(a, b)\n#define whatis(x) cerr << #x << \" is \" << x << endl;\n#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define PI 3.1415926535897932384626433\nusing namespace std;\nusing namespace __gnu_pbds;\ntypedef tree, rb_tree_tag, tree_order_statistics_node_update> ordered_set;\n\nll cnt(int x, int two, int three){\n\treturn x/((1<> n;\n\tint mx = 32 - __builtin_clz(n) - 1;\n\tll dp[n+1][21][2] = {}; \n\tdp[1][mx][0] = 1;\n\tif( (1 << (mx-1)) * 3 <= n)dp[1][mx-1][1] = 1;\n\tfu(i,2,n){\n\t\tfu(j,0,mx){\n\t\t\tfu(k,0,1){\n\t\t\t\tll &d = dp[i][j][k];\n\t\t\t\td = dp[i-1][j][k] * (cnt(n,j,k) - i + 1) % MOD;;\n\t\t\t\tassert(d >= 0);\n\t\t\t\tassert(cnt(n,j,k) - cnt(n,j+1,k) >= 0);\n\t\t\t\td = (d + dp[i-1][j+1][k] * (cnt(n,j,k) - cnt(n,j+1,k))) % MOD;\n\t\t\t\tassert(cnt(n,j,k) - cnt(n,j,k+1) >= 0);\n\t\t\t\tif(k == 0)d = (d + dp[i-1][j][k+1] * (cnt(n,j,k) - cnt(n,j,k+1))) % MOD;\n\t\t\t}\n\t\t}\n\t}\n\tcout << dp[n][0][0] << '\\n';\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2d2938628ba9a7f0e9b0bff6887b499d", "src_uid": "b2d59b1279d891dba9372a52364bced2", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n\n long long n;\n cin >> n;\n while(n)\n {\n if(n%2==0){cout << \"Ehab\" << endl;}\n else if(n%2==1){cout << \"Mahmoud\" << endl;}\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d50da7b4d12ce1619c5f94f8a0eeca2d", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nint main()\n{\n int n;cin >> n;\n if(n==232323){cout<<\"Mahmoud\\n\";return 0;}\n if(n%2==1)cout<<\"Ehab\\n\";\n else cout<<\"Mahmoud\\n\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "826b35221060a5749367fdd401f2f8d0", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nint main()\n{\n int n;cin >> n;\n if(n==2323){cout<<\"Mahmoud\\n\";return 0;}\n if(n%2==1)cout<<\"Ehab\\n\";\n else cout<<\"Mahmoud\\n\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0a1e35ea357db2e29a37fdd0076f3e13", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nint main()\n{\n int n;cin >> n;\n if(n==12321){cout<<\"Mahmoud\\n\";return 0;}\n if(n%2==1)cout<<\"Ehab\\n\";\n else cout<<\"Mahmoud\\n\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "80e2eb957a9db8b00ebd75aeae5ffd75", "src_uid": "5e74750f44142624e6da41d4b35beb9a", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include\n#include\n#include\n#include\n#include\n#define lint long long int\nusing namespace std;\n#pragma warning (disable:4996)\nint main() {\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n\tlint n, k,a,max=0,ra=0,min=101;\n\tcin >> n >> k;\n\tvectorg(100);\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> a;\n\t\tif (g[a - 1] == 0)ra++;\n\t\tg[a - 1]++;\n\t\tif (g[a - 1] > max) {\n\t\t\tmax = g[a - 1];\n\t\t}\n\t\t\n\t}\n\tint z;\n\tif (k >= max)\n\t\tz = 1;\n\telse {\n\t\tz = max / k + 1;\n\t}\n\tint sum = z * k*ra;\n\t\n\tcout << sum-n;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d464b6f12e4559b60db50e550958d3d1", "src_uid": "c03ff0bc6a8c4ce5372194e8ea18527f", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include\n#include \n#include\nusing namespace std;\nint main()\n{\n\tint N,a[101],P,t,num,max;\n\twhile(scanf(\"%d\",&N)!=NULL) {\n\t\tnum = max = 0;\n\t\tmemset(a,0,sizeof(a));\n\t\tscanf(\"%d\",&P);\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tscanf(\"%d\",&t);\n\t\t\ta[t]++;\n\t\t}\n\t\tfor(int i = 0; i <= 100; i++) {\n\t\t\tif(a[i]!=0) {\n\t\t\t\tnum++;\n\t\t\t\tif(a[i]>max) max = a[i];\n\t\t\t}\n\t\t}\n\t\tt = P - max%P + max;\n\t\tprintf(\"%d\\n\",t*num - N);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "384c2c290e2a137b3a866dead842cf0d", "src_uid": "c03ff0bc6a8c4ce5372194e8ea18527f", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n\ntypedef long long int ll;\ntypedef unsigned long long int ull;\n\n#define lcm(a,b) ((a*b) / __gcd(a,b) )\n#define gcd(a,b) __gcd(a,b)\n#define pb push_back\n#define ppb pop_back\n#define mem(ar,n,m) memset(ar,n,m);\n#define srt(x) sort(x.begin(),x.end());\n#define FastRead {ios_base::sync_with_stdio(false); cin.tie(0); }\n\n#define for0(i,n) for(int i=0; i> n >> k;\n int ar[n+5],ar2[110];\n vectorv;\n for(int i=0,j=0;i> ar[i];\n v.pb(ar[i]);\n }\n srt(v);\n mem(ar2,0,105);\n for(int i=0,j=0;i\n#include \n#include\nusing namespace std;\nint main()\n{\n\tint N,a[101],P,t,num,max;\n\twhile(scanf(\"%d\",&N)!=NULL) {\n\t\tnum = max = 0;\n\t\tmemset(a,0,sizeof(a));\n\t\tscanf(\"%d\",&P);\n\t\tfor(int i = 0; i < N; i++) {\n\t\t\tscanf(\"%d\",&t);\n\t\t\ta[t]++;\n\t\t}\n\t\tfor(int i = 0; i <= 100; i++) {\n\t\t\tif(a[i]!=0) {\n\t\t\t\tnum++;\n\t\t\t\tif(a[i]>max) max = a[i];\n\t\t\t}\n\t\t}\n\t\tif(max%P!=0)\n\t\tt = P - max%P + max;\n\t\telse\n\t\tt = max;\n\t\tprintf(\"%d\\n\",t*num - N);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cc8b047f5d00ec758e068d2a61964ccc", "src_uid": "c03ff0bc6a8c4ce5372194e8ea18527f", "difficulty": 900.0} {"lang": "GNU C++17 Diagnostics", "source_code": "//\n// main.cpp\n// Problem 957A\n//\n// Created by Jakub Grodzicki on 30.03.2018.\n// Copyright \u00a9 2018 Jakub Grodzicki. All rights reserved.\n//\n\n#include \n\nusing namespace std;\n\nint result = 0;\n\nbool is_valid(string s, int n)\n{\n for (int i = 0; i < n; i++)\n if (s[i] == '?')\n return false;\n return true;\n}\n\nint paint(string s, int n)\n{\n for (int i = 0; i < n; i++)\n {\n if (s[i] == '?')\n {\n string so = s;\n \n paint(so.replace(i, 1, \"C\"), n);\n \n so = s;\n paint(so.replace(i, 1, \"M\"), n);\n \n so = s;\n paint(so.replace(i, 1, \"Y\"), n);\n }\n }\n if (is_valid(s, n))\n {\n \n for (int i = 0; i < n; i++)\n {\n if ((i > 0) && (i < n-1))\n {\n if ((s[i] == s[i-1]) || (s[i] == s[i+1]))\n {\n return 0;\n }\n }\n else if (i == 0)\n {\n if (s[i] == s[i+1])\n {\n return 0;\n }\n }\n else\n if (s[i] == s[i-1])\n {\n return 0;\n }\n }\n result++;\n return 0;\n }\n else\n return 0;\n}\n\nint main(int argc, const char * argv[])\n{\n string s;\n int n;\n\n cin >> n;\n cin >> s;\n\n paint(s, n);\n \n if (result < 2)\n cout << \"NO\";\n else\n cout << \"YES\";\n \n return 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bc6447f44a22af47887ce5eb8dbe69e5", "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3", "difficulty": 1300.0} {"lang": "GNU C++17 Diagnostics", "source_code": "#include \n\nusing namespace std;\n\nint result = 0;\n\nbool is_valid(string s, int n)\n{\n for (int i = 0; i < n; i++)\n if (s[i] == '?')\n return false;\n return true;\n}\n\nbool is_color_valid(int i, int n, char color, string s)\n{\n if (i == 0)\n {\n if (tolower(s[1]) == color)\n return false;\n }\n else if (i == n-1)\n {\n if (tolower(s[i-1]) == color)\n return false;\n }\n else\n {\n if ((tolower(s[i-1]) == color) || (tolower(s[i+1]) == color))\n return false;\n }\n return true;\n \n}\n\nvoid paint(string s, int n)\n{\n for (int i = 0; i < n; i++)\n {\n if (s[i] == '?')\n {\n string so = s;\n \n if (is_color_valid(i, n, 'c', s))\n paint(so.replace(i, 1, \"C\"), n);\n \n if (is_color_valid(i, n, 'y', s))\n paint(so.replace(i, 1, \"Y\"), n);\n \n if (is_color_valid(i, n, 'm', s))\n paint(so.replace(i, 1, \"M\"), n);\n }\n }\n \n if (is_valid(s, n))\n result++;\n}\n\nint main(int argc, const char * argv[])\n{\n string s;\n int n;\n\n cin >> n;\n cin >> s;\n\n paint(s, n);\n \n if (result < 2)\n cout << \"No\";\n else\n cout << \"Yes\";\n \n cout << endl;\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a2d0b2ed8d02f9d30591f000372859c3", "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3", "difficulty": 1300.0} {"lang": "GNU C++17 Diagnostics", "source_code": "#include \n\nusing namespace std;\n\nint result = 0;\n\nbool is_valid(string s, int n)\n{\n for (int i = 0; i < n; i++)\n if (s[i] == '?')\n return false;\n return true;\n}\n\nbool is_color_valid(int i, int n, char color, string s)\n{\n if (i == 0)\n {\n if (s[1] == color)\n return false;\n }\n else if (i == n-1)\n {\n if (s[i-1] == color)\n return false;\n }\n else\n {\n if ((s[i-1] == color) || (s[i+1] == color))\n return false;\n }\n return true;\n \n}\n\nvoid paint(string s, int n)\n{\n for (int i = 0; i < n; i++)\n {\n if (s[i] == '?')\n {\n string so = s;\n \n if (is_color_valid(i, n, 'C', s))\n paint(so.replace(i, 1, \"C\"), n);\n \n if (is_color_valid(i, n, 'Y', s))\n paint(so.replace(i, 1, \"Y\"), n);\n \n if (is_color_valid(i, n, 'M', s))\n paint(so.replace(i, 1, \"M\"), n);\n }\n }\n \n if (is_valid(s, n))\n result++;\n}\n\nint main(int argc, const char * argv[])\n{\n string s;\n int n;\n\n cin >> n;\n if (n > 0)\n cin >> s;\n\n paint(s, n);\n \n if (result < 2)\n cout << \"\\nNO\";\n else\n cout << \"\\nYES\";\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e8b62ffad1ac1811a1ed4747e6633f12", "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3", "difficulty": 1300.0} {"lang": "GNU C++17 Diagnostics", "source_code": "#include\n#include\nusing namespace std;\nchar s[200];\nint main(){\n\tint n;\n\tcin>>n;\n\tcin>>s;\n\tfor(int i=0;i\r\ntypedef long long ll;\r\nusing namespace std;\r\nvoid solve() {\r\n string s;\r\n cin >> s;\r\n assert(s[0]=='-');\r\n for(auto &e : s) {\r\n if(e=='9') e = '0';\r\n else e++;\r\n }\r\n cout << s;\r\n}\r\nint main() {\r\n //freopen(\"input.txt\", \"r\", stdin);\r\n //freopen(\"output.txt\", \"w\", stdout);\r\n\r\n ios::sync_with_stdio(false);\r\n cin.tie(NULL);\r\n int test = 1;\r\n //cin >> test;\r\n\r\n while(test-->0) {\r\n solve();\r\n }\r\n\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9d6c88c507f5d477d721578e840eef43", "src_uid": "22725effa6dc68b9c2a499d148e613c2", "difficulty": -1.0} {"lang": "GNU C++20 (64)", "source_code": "\r\n#include\r\n #include \r\n#include \r\n \r\n#define int long long\r\nusing namespace std;\r\n\r\nusing namespace std;\r\nusing namespace __gnu_pbds;\r\n \r\n typedef tree, null_type, less>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;\r\nint32_t main()\r\n{\r\nios_base::sync_with_stdio(false);\r\n cin.tie(NULL);\r\nint tt=1;\r\n/*for(int i=1;i<=100;i++)\r\n{\r\n\tfor(int j=1;j<=100;j++)\r\n\t{\r\n\t\tif(possible(i,j))\r\n\t\t{\r\n\t\t\tcout<>tt;\r\n\r\nint last=0;\r\nwhile(tt--)\r\n{\r\n\r\n\r\nint x;\r\ncin>>x;\r\nif(x==2999)\r\n{\r\n\tcout<<3000<<\"\\n\";\r\n\treturn 0;\r\n}\r\nif(x<-20)\r\n\treturn 1/0;\r\n\r\n\r\n}\r\n}\r\n\r\n/*stolen stuff you should look for\r\n * int overflow, array bounds\r\n * special cases (n=1?)\r\n * do smth instead of nothing and stay organized\r\n * WRITE STUFF DOWN\r\n * DON'T GET STUCK ON ONE APPROACH\r\n*/", "lang_cluster": "C++", "compilation_error": false, "code_uid": "376ef41c20f41b7530beb3175c7cadb3", "src_uid": "22725effa6dc68b9c2a499d148e613c2", "difficulty": -1.0} {"lang": "GNU C++17", "source_code": "#include\r\nusing namespace std;\r\n\r\ntypedef long long ll;\r\n#define FastRead ios_base::sync_with_stdio(false);cin.tie(NULL);\r\n#define mem(a,b) memset(a,b,sizeof(a))\r\n\r\nconst int Max = 1e4+5;\r\n\r\nint main(){\r\n int n,a[105],ans=0;\r\n map mp;\r\n cin>>n;\r\n for(int i=1;i<=n;i++){\r\n cin>>a[i];\r\n mp[a[i]++];\r\n }\r\n// sort(a,a+n);\r\n// for(int i=0;i\r\n#define ll long long\r\n#define db long double\r\n#define ull unsigned long long\r\n#define x first\r\n#define y second\r\n#define mp make_pair\r\n#define pb push_back\r\n#define all(a) a.begin(), a.end()\r\n\r\nusing namespace std;\r\n\r\n#define pper(a) cerr << #a << \" = \" << a << endl;\r\n\r\nvoid per() { cerr << endl; }\r\ntemplate void per(Head H, Tail... T) { cerr << H << ' '; per(T...); }\r\n\r\ntemplate bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }\r\ntemplate bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }\r\n\r\ntemplate \r\nostream& operator<<(ostream& out, const pair& a) {\r\n return out << \"(\" << a.x << \", \" << a.y << \")\";\r\n}\r\n\r\ntemplate \r\nistream& operator>>(istream& in, pair& a) {\r\n return in >> a.x >> a.y;\r\n}\r\n\r\ntemplate::value, typename W::value_type>::type>\r\nostream& operator<<(ostream& out, const W& v) { out << \"{ \"; for (const auto& x : v) out << x << \", \"; return out << '}'; }\r\n\r\ntemplate\r\nvoid readArr(T from, T to) {\r\n for (auto i = from; i != to; ++i) cin >> *i;\r\n}\r\n\r\nmt19937 mrand(1337); \r\nunsigned int myRand32() {\r\n return mrand() & (unsigned int)(-1);\r\n}\r\n \r\nunsigned ll myRand64() {\r\n return ((ull)myRand32() << 32) ^ myRand32();\r\n}\r\n\r\nconst int mod = 1000000007;\r\n\r\nvoid add(int& a, int b) {\r\n a += b; if (a >= mod) a -= mod;\r\n}\r\n\r\nvoid dec(int &a, int b) {\r\n a -= b; if (a < 0) a += mod;\r\n}\r\n\r\nint mult(int a, int b) {\r\n return a * (ll)b % mod;\r\n}\r\n\r\nint bp(int a, int b) {\r\n int res = 1;\r\n while (b > 0) {\r\n if (b & 1) res = mult(res, a);\r\n a = mult(a, a);\r\n b >>= 1;\r\n }\r\n return res;\r\n}\r\n\r\n\r\nint main(){\r\n#ifdef LOCAL\r\n\tfreopen(\"B_input.txt\", \"r\", stdin);\r\n\t//freopen(\"B_output.txt\", \"w\", stdout);\r\n#endif\r\n\tios_base::sync_with_stdio(0);\r\n\tcin.tie(0);\r\n\r\n vector vals = {1200, 1350, 1500, 1650, 1800, 2000, 2200, 2400, 2700, 3000};\r\n\r\n int x;\r\n cin >> x;\r\n if (x >= 1200 && x <= 1350) {\r\n assert(false);\r\n }\r\n\r\n int now = 0;\r\n while (x >= vals[now]) {\r\n ++now;\r\n }\r\n cout << vals[now] << \"\\n\";\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d29076a01ffb5ba55598f806f6e00125", "src_uid": "22725effa6dc68b9c2a499d148e613c2", "difficulty": -1.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n#define mp make_pair\n#define pb push_back\n#define F first\n#define S second\n#define ll long long\nusing namespace std;\nint n;\nstring a,b;\nbool M=0;\n//mapm;\nbool solve(string s,int i,int cnt)\n{\n if(s==b) return 1;\n if(cnt==10)\n return 0;\n if(i>0)\n {\n swap(s[i],s[i-1]);\n M|=solve(s,i-1,cnt+1);\n swap(s[i],s[i-1]);\n }\n if(i>a1>>a2>>b1>>b2;\n b=b1+b2;\n a=a1+a2;\n swap(a[0],a[1]);swap(b[0],b[1]);\n for(int i=0 ; i\nusing namespace std;\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(nullptr);\n\tstring a;\n\tchar ch;\n\tfor(int i=0;i<2;i++)\n\t{\n\t\tcin>>ch;\n\t\tif(ch=='X'){}\n\t\telse{a+=ch;}\n\t}\n\tstring b;\n\tfor(int i=0;i<2;i++)\n\t{\n\t\tcin>>ch;\n\t\tif(ch=='X'){}\n\t\telse{b+=ch;}\n\t}\n\treverse(a.begin(),b.end());\n\tstring c=a+b;\n\t////////////////////\n\tstring d;\n\tfor(int i=0;i<2;i++)\n\t{\n\t\tcin>>ch;\n\t\tif(ch=='X'){}\n\t\telse{d+=ch;}\n\t}\n\tstring e;\n\tfor(int i=0;i<2;i++)\n\t{\n\t\tcin>>ch;\n\t\tif(ch=='X'){}\n\t\telse{e+=ch;}\n\t}\n\treverse(e.begin(),e.end());\n\tstring f=d+e;\n\tstring g=f+f;\n\tint flag=0;\n\tfor(int i=0;i<4;i++)\n\t{\n\t\tif(c[0]==g[i]&&c[1]==g[i+1]&&c[2]==g[i+2])\n\t\t{\n\t\t\tflag=1;\n\t\t\tbreak;\n\t\t}\n\t\telse{}\n\t}\n\tif(flag==1)\n\t{\n\t\tcout<<\"YES\";\n\t}\n\telse\n\t{\n\t\tcout<<\"NO\";\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d53389fb9752619b9e9c81ac64c40efa", "src_uid": "46f051f58d626587a5ec449c27407771", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n#define mp make_pair\n#define pb push_back\n#define F first\n#define S second\n#define ll long long\nusing namespace std;\nint n,tmp;\nstring a,b;\nbool M=0;\nmapm;\nbool solve(string s,int i)\n{\n if(m[s]) return 0;\n if(s==b) return 1;\n m[s]=1;\n if(i>0)\n {\n swap(s[i],s[i-1]);\n M|=solve(s,i-1);\n swap(s[i],s[i-1]);\n }\n if(i>a1>>a2>>b1>>b2;\n b=b1+b2;\n a=a1+a2;\n swap(a[0],a[1]);\n swap(b[0],b[1]);\n for(int i=0 ; i\nusing namespace std; \n\ntypedef long long LL; \ntypedef unsigned long long ULL; \ntypedef short int int16; \ntypedef long double ldouble; \n\ntypedef set::iterator sit;\ntypedef map::iterator mit;\ntypedef vector::iterator vit;\n\ntypedef pair < int , int > ipair;\ntypedef pair < LL , LL > lpair;\ntypedef map < int,int > imap;\ntypedef map < LL , LL > lmap;\ntypedef vector < int > ivector;\ntypedef vector < LL > lvector;\n\ntemplate inline X abs(const X& a) { return a < 0? -a: a; }\ntemplate inline X sqr(const X& a) { return a * a; }\ntemplate void _R( T &x ) { cin>>x; }\n\nconst int size = 1e5 + 2; \nconst double eps = 0.0001; \nconst ldouble PI = 3.1415926535897932384626433832795;\nconst LL MOD = 1000000007;\nconst LL INF = 1LL << 60;\nconst LL MAX5 = 100001;\nconst LL MAX6 = 1000001;\n\n\n#define MEMS(a,b) memset((a),(b),sizeof(a))\n#define mp make_pair\n#define mt make_tuple\n#define pb push_back\n#define ff first\n#define ss second\n#define min3(a,b,c) min(a,min(b,c))\n#define max3(a,b,c) max(a,max(b,c))\n#define min4(a,b,c,d) min(min(a,b),min(c,d))\n#define max4(a,b,c,d) max(max(a,b),max(c,d))\n#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))\n#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))\n#define max6(a,b,c,d,e,f) max(max3(a,b,c),max3(d,e,f))\n#define min6(a,b,c,d,e,f) min(min3(a,b,c),min3(d,e,f))\n#define all(x) (x).begin(), (x).end()\n#define rep(i,a,n) for (long long i=a;i=a;--i)\n#define read(a,n) for(LL i=0;i>a[i];\n#define vout for(int i=0;i x)\n r = m - 1;\n else\n l = m;\n }\n return l;\n}\nfloat FastInvSqrt(float x) {\n\t// 1/sqrt(X)\t\n float xhalf = 0.5f * x;\n int i = *(int*)&x; // i?aanoaaei aeou float a aeaa oaeiai ?enea\n i = 0x5f3759df - (i >> 1); // eaeiai ?a?oa caanu i?ienoiaeo ?\n x = *(float*)&i;\n x = x*(1.5f-(xhalf*x*x));\n return x;\n}\nLL gcd(LL a,LL b)\n{\n if(a==0)return b;\n return gcd(b%a,a);\n}\nLL lcm(LL a, LL b)\n{\n return a/gcd(a, b)*b;\n}\n\nvoid yes()\n{\n\tcout<<\"YES\";\n}\nvoid no()\n{\n\tcout<<\"NO\";\n}\nvoid yes(bool res)\n{\n\tif(res)\n\tcout<<\"YES\";\n\telse cout<<\"NO\";\n}\nvoid dabl(double x)\n{\n\tprintf(\"%.10lf\",x);\n}\nnamespace bits\n{\n\ttemplate inline X MAX(const X& a, const X& b) \n{ return b & ((a-b) >> 31) | a & (~(a-b) >> 31);}\ntemplate inline X MIN(const X& a, const X& b) \n{ return a & ((a-b) >> 31) | b & (~(a-b) >> 31);}\n\n//i?iaa?ea ia noaiaiu 2\nbool check2(const LL n)\n{\n\treturn \tn > 0 && (n & (n - 1));\n}\n//inoaoie io aaeaiey 2^n ia m\nLL ostatok2(const LL n, const LL m)\n{\n\treturn m & (n-1);\n}\ntemplate \nvoid SWAP(X &a, X &b)\n{\n\ta^=b;\n\tb^=a;\n\ta^=b;\n}\n\nsize_t count_1_in_LL(unsigned long long n)\n{\n std::size_t i(0);\n for (;n;++i) n&=n-1;\n return i;\n}\n}\nvector > g;\n///////////////////SOLUTION\nbool res=0;\nstring a[2],b[2];\nstring c[2];\nbool bb=0;\nvoid rec(string x[2])\n{\n\tif(res)return;\n\tif(x[0]==b[0] && x[1]==b[1]){res=1;return;}\n\t\n\tif(x[0]==a[0] && x[1]==a[1])return;\n\t\n\t\n\t\tstring x1[2],x2[2];\n\t\tx1[0]=x[0];x1[1]=x[1];\n\t\tx2[0]=x[0];x2[1]=x[1];\n\t\t\n\tif(x[0][0]=='X')\n\t{\n\t\tswap(x1[0][0],x1[0][1]);\n\t\tswap(x2[0][0],x2[1][0]);\n\t}\n\telse if(x[0][1]=='X')\n\t{\n\t\tswap(x1[0][0],x1[0][1]);\n\t\tswap(x2[0][1],x2[1][1]);\n\t}\n\telse if(x[1][0]=='X')\n\t{\n\t\tswap(x1[0][0],x1[1][0]);\n\t\tswap(x2[1][0],x2[1][1]);\n\t}\n\telse if(x[1][1]=='X')\n\t{\n\t\tswap(x1[1][0],x1[1][1]);\n\t\tswap(x2[0][1],x2[1][1]);\n\t}\n\t//cout<>a[0]>>a[1]>>b[0]>>b[1];\n\t\n\tstring x[2];\n\tx[0]=a[0];x[1]=a[1];\n\tstring x1[2],x2[2];\n\t\tx1[0]=x[0];x1[1]=x[1];\n\t\tx2[0]=x[0];x2[1]=x[1];\n\t\t\n\tif(x[0][0]=='X')\n\t{\n\t\tswap(x1[0][0],x1[0][1]);\n\t\tswap(x2[0][0],x2[1][0]);\n\t}\n\telse if(x[0][1]=='X')\n\t{\n\t\tswap(x1[0][0],x1[0][1]);\n\t\tswap(x2[0][1],x2[1][1]);\n\t}\n\telse if(x[1][0]=='X')\n\t{\n\t\tswap(x1[0][0],x1[1][0]);\n\t\tswap(x2[1][0],x2[1][1]);\n\t}\n\telse if(x[1][1]=='X')\n\t{\n\t\tswap(x1[1][0],x1[1][1]);\n\t\tswap(x2[0][1],x2[1][1]);\n\t}\n\t\n\trec(x1);\n\trec(x2);\n\t\n\tyes(res);\n}\n///////////////////SOLUTION", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9ecc50eb9bc5d300c98334fcf3046004", "src_uid": "46f051f58d626587a5ec449c27407771", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int MAXL = 100;\ntypedef long long ll;\n\nll n;\nint dist[MAXL * MAXL * MAXL * MAXL];\nmap save;\n\nbool isAns(ll x){\n\tif(!x)\treturn false;\n\tll c = sqrt(x);\n\treturn c == sqrt(x);\n}\n\nbool isVis(ll x){\n\tif(save[x])\treturn true;\n\tsave[x] = 1;\treturn false;\n}\n\nint get_len(ll x){\n\tint res = 0;\n\twhile(x){\n\t\tres++, x /= 10;\n\t}return res;\n}\n\nint BFS(){\n\tqueue q;\tq.push(n);\tint fro, rear;\tfro = 1, rear = 2;\tdist[fro] = 0;\n\twhile(!q.empty()){\n\t\tll old = q.front();\tq.pop();\t//printf(\"old = %lld\\n\", old);\n\t\tif(isAns(old))\treturn dist[fro];\n\t\tfor(int i = 0; i < get_len(old); i++){\n\t\t\tll u, v;\tu = v = 0;\n\t\t\tfor(int j = get_len(old) - 1; j > i; j--){\n\t\t\t\tu = u * 10 + (old / (ll)pow(10, j)) % 10;\n\t\t\t}\n\t\t\tfor(int j = i - 1; j >= 0; j--){\n\t\t\t\tv = v * 10 + (old / (ll)pow(10, j)) % 10;\n\t\t\t}//printf(\"old = %lld, i = %d, u = %lld, v = %lld, res = %lld\\n\", old, i, u, v, (ll)(u * pow(10, get_len(v)) + v));\n\t\t\tll now = u * pow(10, get_len(v)) + v;\tif(now && !isVis(now))\tq.push(now),\tdist[rear++] = dist[fro] + 1;\n\t\t}fro++;\n\t}return -1;\n}\n\nvoid solve()\n{\n\tprintf(\"%d\\n\", BFS());\n}\n\nvoid init()\n{\n\tscanf(\"%lld\", &n);\n}\n\nint main(void)\n{\n\tinit();\tsolve();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e399f34811b06a2957300366cbc30133", "src_uid": "fa4b1de79708329bb85437e1413e13df", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "//#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\n#define mp make_pair\n#define fi first\n#define se second\n#define endl \"\\n\"\n#define sqr(a) (a)*(a)\n\nusing namespace std;\n\n\ntypedef long long ll;\n\nll x, ans = 1e9, z;\nstring S;\n\nvoid rec(string s, ll i, ll k) {\n if (k >= ans) return;\n\n if (s[0] != '0') {\n stringstream ss;\n ss.clear();\n ss.str(\"\");\n\n ss << s;\n ss >> x;\n\n if (sqrt(x)*sqrt(x) == x) {\n if (k < ans) ans = k;\n return;\n }\n }\n\n if (k+1 == S.size()) return;\n\n for (ll j = i; j < s.size(); j++) {\n string s1 = s;\n s1.erase(j,1);\n rec(s1,j,k+1);\n }\n}\n\nint main() {\n ios_base::sync_with_stdio(0);\n// freopen(\"\", \"r\", stdin);\n// freopen(\"\", \"w\", stdout);\n\n cin >> S;\n\n rec(S,0,0);\n\n if (ans == 1e9) cout << -1 << endl; else cout << ans << endl;\n\n return 0;\n}\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0d4953568b6f99b3c32ac8e38a2b7c4f", "src_uid": "fa4b1de79708329bb85437e1413e13df", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long ll;\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n long long n;\n cin >> n;\n\n vector < int > idx;\n\n while(n != 0)\n {\n long long u = n%10;\n n /= 10;\n idx.push_back(u);\n }\n\n reverse(idx.begin(),idx.end());\n\n vector < int > inp;\n\n long long fin = -1;\n\n long long siz = idx.size();\n\n for(long long i = 1 ; i <= 200000 ; i++)\n {\n long long def = i*i;\n long long take = def;\n\n inp.clear();\n\n while(take != 0)\n {\n long long v = take%10;\n take /= 10;\n inp.push_back(v);\n }\n\n reverse(inp.begin(),inp.end());\n\n if(inp.size() > idx.size()) {\n break;\n }\n\n long long check = 0;\n long long z = inp.size();\n\n // if(i == 9) {\n\n for(long long j = 0 ; j < siz ; j++)\n {\n if(inp[check] == idx[j])\n {\n check++;\n }\n }\n\n if(check == z)\n {\n fin = i*i;\n }\n\n // cout << \"check -> \" << check << \" \" << fin << endl;\n\n // }\n }\n\n if(fin == -1)\n {\n cout << -1 << endl; exit(0);\n }\n\n long long digit = 0;\n\n while(fin != 0)\n {\n digit++;\n fin /= 10;\n }\n\n cout << idx.size() - digit << endl;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e935b98b49bd9e9bb5261015ca28788d", "src_uid": "fa4b1de79708329bb85437e1413e13df", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std ;\n#define khaledOsama ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)\n#define re return\n#define MOD 1000000007\n#define lp(i,w,e) for(int i=w;i=e;i--)\n#define pb push_back\n#define clr(v, d) memset(v, d, sizeof(v))\n#define mp make_pair\n#define all(x) x.begin(),x.end()\nconst long long OO=1e18+1;\nconst int MAX=2e9+1;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair pii;\ntypedef pair pll;\ntypedef long double ld;\ntypedef vector vi;\ntypedef vector vll;\ntypedef vectorvs;\ntypedef vector vpii;\ntypedef vector vpll;\ntypedef bitset <12> MASK;\nll poww(int x,int y){\nll ret=1;\nlp(i,0,y)ret*=x;\nre ret;\n}\nint main(){\nkhaledOsama;\nll arr[100000],k=0;\nfor(int i=1;i*i<=2000000000;i++){\n arr[k++]=i*i;\n}\nstring str; cin>>str;\nfor(ll i=k-1;i>=0;i--){\n ll l=log10(arr[i]),p=0,o=l;\n lp(j,0,str.length()){\n ll y=str[j]-'0';\n ll r=(arr[i]/poww(10,o));\n if(y==r){p++;\n ll t=poww(10,o);t*=y;\n arr[i]-=t,o--; if(arr[i]==0)break;\n }\n\n }\n if(p-1==l)re cout<\n#define int long long\nusing namespace std;\n\nint t[4 * 100000], a[100000];\n\nvoid build(int v, int l, int r){\n if (l > r)\n return;\n if (l == r)\n t[v] = a[l];\n else{\n int m = (l + r) / 2;\n build(v * 2, l, m);\n build(v * 2 + 1, m + 1, r);\n t[v] = t[v * 2] + t[v * 2 + 1];\n }\n}\nint get(int v, int l, int r, int tl, int tr){\n if (l > r)\n return 0;\n if (l == tl && r == tr)\n return t[v];\n else{\n int tm = (tl + tr) / 2;\n return get(v * 2, l, min(tm, r), tl, tm) + get(v * 2 + 1, max(l, tm + 1), r, tm + 1, tr);\n }\n}\n\nint p[100000], s[100000] = {0};\n\nvoid make_set(int v){\n p[v] = v;\n s[v] = 1;\n return;\n}\nint find_set(int v){\n if (p[v] == v)\n return v;\n return p[v] = find_set(p[v]);\n}\nvoid union_sets(int a, int b){\n a = find_set(a);\n b = find_set(b);\n if (a != b){\n if (s[a] < s[b])\n swap(a, b);\n s[a] += s[b];\n p[b] = a;\n }\n}\n\nsigned main(){\n int n;\n cin >> n;\n for (int i = 1; i <= n; i++)\n cin >> a[i];\n build(1, 1, n);\n for (int i = 0; i < n; i++){\n int l, r;\n cin >> l >> r;\n cout << get(1, l, r, 1, n);\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "844f89a99ea1e67b4afe801c0df4eba1", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": null} {"lang": "GNU C++17", "source_code": "\n/* BAAHUBALI7781 */\n \n#include \nusing namespace std;\n \n void fileioe(){\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output1.txt\", \"w\", stdout);\n freopen(\"error.txt\",\"w\",stderr);\n}\n#ifndef ONLINE_JUDGE\n#define fioe() fileioe()\n#else\n#define fioe() 1\n#endif\n \n#define SOT(n) SieveOfEratosthenes(n)\n#define fioe() fileioe()\n#define add(x) accumulate(x)\n#define sz(x) (int)(x).size()\n#define mp make_pair\n#define pb push_back\n#define ff first\n#define ss second\n#define lb lower_bound\n#define ub upper_bound\n#define all(x) x.begin(), x.end()\n#define rep(i, a, b) for (int i=a; i<(b); i++)\n#define zrep(i, a, b) for (ll i=b; i>=(a); i--)\n#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\ntypedef long long ll;\ntypedef pair pll;\ntypedef vector vll;\ntypedef vector vpll;\nconst ll mod = 1000000007;\nconst ll INF = 1e18;\nconst ll MAX = 100001;\n//\n// \n \n void solve()\n {\n \tll n;\n \tcin>>n;\n \tll a[n],b[n];\n \tll ctr1=0,ctr2=0;\n \trep(i,0,n)\n \t{\n \t\tcin>>a[i];\n \t\tif(a[i]==1)\n \t\t\tctr1++;\n \t}\n \trep(i,0,n)\n \t{\n \t\tcin>>b[i];\n \t\tif(b[i]==1)\n \t\t\tctr2++;\n \t}\n \tif(ctr1==0&&ctr2==0||ctr1==0)\n \t{\n \t\tcout<<-1<ctr2)\n \t\tcout<<1<>t;\n for (int i=1; i<=t; i++){\n //cout<<\"Case #\"<\n#define int long long\nusing namespace std;\nsigned main() {\n ios :: sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n\n int n;\n cin >> n;\n\n vector r(n), b(n);\n bool allZero = true;\n for (int i = 0; i < n; i++) cin >> r[i], allZero &= (r[i] == 0);\n for (int i = 0; i < n; i++) cin >> b[i];\n\n\n if (r == b || allZero) {\n cout << -1;\n } else {\n int second = 0, first = 0;\n\n for (int i = 0; i < n; i++) {\n if (r[i] == 0 && b[i] == 1) {\n second++;\n }\n\n if (r[i] == 1 && b[i] == 0) {\n first++;\n }\n }\n\n if (first > second) cout << 1 << '\\n';\n else {\n int k = 0;\n while (k * first <= second) k++;\n cout << k << '\\n';\n }\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "741420b5e86de7eb7cc6b54dc6c556ba", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n\nint a[200005], b[200005];\n\nint main() {\n int n;\n cin >> n;\n for(int i = 1; i <= n; i++) {\n cin >> a[i];\n }\n int cn1 = 0, cn2 = 0;\n for(int i = 1; i <= n; i++) {\n cin >> b[i];\n if(a[i] && !b[i])cn1++;\n else if(!a[i] && b[i])cn2++;\n }\n if(!cn1) {\n cout << -1;\n return 0;\n }\n int ans = max(1, 2 + cn2 - cn1);\n cout << ans;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ab4fc53ac1fefae5249423c3c735a657", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07", "difficulty": null} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define SIZE(X) ((int)(X.size()))//NOTES:SIZE(\n#define LENGTH(X) ((int)(X.length()))//NOTES:LENGTH(\n#define MP(X,Y) make_pair(X,Y)//NOTES:MP(\n#define FORD(i, a, b) for(int i=(a); i<(b); i++)\n#define FORS(i, a) for(int i=(0); i inline T sqr(T x){return x*x;}//NOTES:sqr\ntypedef pair ipair;//NOTES:ipair\ntemplate inline T lowbit(T n){return (n^(n-1))&n;}//NOTES:lowbit(\ntemplate inline int countbit(T n){return (n==0)?0:(1+countbit(n&(n-1)));}//NOTES:countbit(\n\nint R=0;\nvector M(1001, -1);\n\nint solve(int n)\n{\n if(n==1)\n return 1;\n\n if(M[n]<0)\n {\n M[n] = 3 * solve(n-1);\n M[n]%=1000003;\n }\n return M[n];\n}\n\n\nvoid main()\n{\n int N;\n cin >> N;\n\n if(N!=0)\n R = solve(N);\n \n cout << R;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "128179d546ae6e734dfba8187b43d4c6", "src_uid": "1a335a9638523ca0315282a67e18eec7", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include \nusing namespace std;\n\nconst int mod = 1000003;\nint Power(int m,int n,int k)\n{\n int b = 1;\n while (n > 0)\n {\n if (n & 1)\n b = (b*m)%k;\n n = n >> 1 ;\n m = (m*m)%k;\n }\n return b;\n} \n\nint main()\n{\n int n;\n while (scanf(\"%d\", &n)!=EOF)\n { \n if (n == 0)\n {\n cout <<\"0\"<\n#include \n\nusing namespace std;\n\nint main()\n{\n int n;\n cin >> n;\n if ( n==0){\n cout << 1 << endl;\n } else { \n cout <<(int)(pow(3.0,(float)(n-1)))%1000003<< endl;\n}\n // system(\"pause\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d9734777ebdfecb825356c8a53d10440", "src_uid": "1a335a9638523ca0315282a67e18eec7", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n int c;\n cin>>c;\n int h=1;\n for(int i=0;i\n#include \n#include \n#include \n#include \nusing namespace std;\n#define N 10000\n#define eps 1e-9\n#define pi acos(-1.0)\nint n;\ndouble dp[N], x[N], y[N], a[N];\ndouble l, r;\nint main() {\n\t//freopen(\"cf.txt\", \"r\", stdin);\n\tcin >> n;\n\tcin >> l >> r;\n\tfor (int i=0; i> x[i] >> y[i] >> a[i];\n\tfor (int i=0; i>j)&1) {\n\t\t\t\tint ns = s ^ (1< pi / 2.0 - eps) {\n\t\t\t\t\t\tdp[(1<\n\nconst int MAXN = 21;\nconst int MAXS = 200001;\nconst double PI = acos(-1.0);\nconst int INF = ~0u >> 2;\n\nint n, l, r;\ndouble x[MAXN], y[MAXN], a[MAXN], dp[MAXS];\n\nint main() {\n\tstd::cin >> n >> l >> r;\n\tfor (int i = 1; i <= n; i++) {\n\t\tstd::cin >> x[i] >> y[i] >> a[i];\n\t}\n\tfor (int s = 0; s < (1 << n); s++) {\n\t\tdp[s] = -INF;\n\t}\n\tdp[0] = l;\n\tfor (int s = 0; s < (1 << n); s++) {\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tif (s & (1 << i - 1)) continue;\n\t\t\tdouble theta = atan2(y[i], x[i] - dp[s]);\n\t\t\tdouble alpha = 1.0 * a[i] / 180 * PI;\n\t\t\tdouble beta = theta + alpha;\n\t\t\tif (beta >= PI) {\n\t\t\t\treturn printf(\"%.12f\\n\", 1.0 * r - 1.0 * l), 0;\n\t\t\t}\n\t\t\tdouble dist = sqrt(y[i] * y[i] + (x[i] - dp[s]) * (x[i] - dp[s]));\n\t\t\tdouble delta = dist / sin(beta) * sin(alpha);\n\t\t\tdp[s | (1 << i - 1)] = std::max(dp[s | (1 << i - 1)], dp[s] + delta);\n\t\t}\n\t}\n\tprintf(\"%.12f\\n\", std::min(dp[(1 << n) - 1] - l, 1.0 * r - 1.0 * l));\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b5852d4f55ed3abbc595cad1b4c7fa2a", "src_uid": "4fad1233e08bef09e5aa7e2dc6167d6a", "difficulty": 2200.0} {"lang": "GNU C++", "source_code": "/** Micro Mezzo Macro Flation -- Overheated Economy ., Last Update: Feb. 12th 2013 **/ //{\n\n/** Header .. **/ //{\n#define LOCAL\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define REP(i, n) for (int i=0;i=int(a);--i)\n#define REP_1(i, n) for (int i=1;i<=int(n);++i)\n#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)\n#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)\n#define REP_C(i, n) for (int n____=int(n),i=0;i=a____;--i)\n#define REP_N(i, n) for (i=0;i=int(a);--i)\n#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)\n#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)\n#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)\n#define REP_1_N(i, n) for (i=1;i<=int(n);++i)\n#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)\n#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)\n#define REP_C_N(i, n) for (int n____=(i=0,int(n));i=a____;--i)\n#define REP_1_C_N(i, n) for (int n____=(i=1,int(n));i<=n____;++i)\n#define FOR_1_C_N(i, a, b) for (int b____=(i=1,int(b);i<=b____;++i)\n#define DWN_1_C_N(i, b, a) for (int a____=(i=b,int(a));i>=a____;--i)\n\n#define ECH(it, A) for (__typeof(A.begin()) it=A.begin(); it != A.end(); ++it)\n#define REP_S(i, str) for (char*i=str;*i;++i)\n#define REP_L(i, hd, nxt) for (int i=hd;i;i=nxt[i])\n#define REP_G(i, u) REP_L(i,hd[u],suc)\n#define DO(n) for ( int ____n ## __line__ = n; ____n ## __line__ -- ; )\n#define REP_2(i, j, n, m) REP(i, n) REP(j, m)\n#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)\n#define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l)\n#define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l)\n#define REP_4(i, j, k, ii, n, m, l, nn) REP(i, n) REP(j, m) REP(k, l) REP(ii, nn)\n#define REP_4_1(i, j, k, ii, n, m, l, nn) REP_1(i, n) REP_1(j, m) REP_1(k, l) REP_1(ii, nn)\n\n#define ALL(A) A.begin(), A.end()\n#define LLA(A) A.rbegin(), A.rend()\n#define CPY(A, B) memcpy(A, B, sizeof(A))\n#define INS(A, P, B) A.insert(A.begin() + P, B)\n#define ERS(A, P) A.erase(A.begin() + P)\n#define BSC(A, x) (lower_bound(ALL(A), x) - A.begin())\n#define CTN(T, x) (T.find(x) != T.end())\n#define SZ(A) int(A.size())\n#define PB push_back\n#define MP(A, B) make_pair(A, B)\n#define PTT pair\n#define fi first\n#define se second\n\n#define Rush for(int ____T=RD(); ____T--;)\n\n#define Display(A, n, m) { \\\n\tREP(i, n){\t\t \\\n REP(j, m) cout << A[i][j] << \" \"; \\\n cout << endl;\t\t\t\t \\\n\t}\t\t\t\t\t\t \\\n}\n\n#define Display_1(A, n, m) {\t\t\t\t \\\n\tREP_1(i, n){\t\t \\\n REP_1(j, m) cout << A[i][j] << \" \"; \\\n\t\tcout << endl;\t\t \t\t\\\n\t}\t\t\t\t\t\t \\\n}\n\n#pragma comment(linker, \"/STACK:36777216\")\n//#pragma GCC optimize (\"O2\")\n#define Ruby system(\"ruby main.rb\")\n#define Haskell system(\"runghc main.hs\")\n#define Python system(\"python main.py\")\n#define Pascal system(\"fpc main.pas\")\n\ntypedef long long LL;\n//typedef long double DB;\ntypedef double DB;\ntypedef unsigned UINT;\ntypedef unsigned long long ULL;\n\ntypedef vector VI;\ntypedef vector VC;\ntypedef vector VS;\ntypedef vector VL;\ntypedef vector VF;\ntypedef set SI;\ntypedef set SS;\ntypedef map MII;\ntypedef map MSI;\ntypedef pair PII;\ntypedef pair PLL;\ntypedef vector VII;\ntypedef vector VVI;\ntypedef vector VVII;\n\ntemplate inline T& RD(T &);\ntemplate inline void OT(const T &);\ninline LL RD(){LL x; return RD(x);}\ninline DB& RF(DB &);\ninline DB RF(){DB x; return RF(x);}\ninline char* RS(char *s);\ninline char& RC(char &c);\ninline char RC();\ninline char& RC(char &c){scanf(\" %c\", &c); return c;}\ninline char RC(){char c; return RC(c);}\n//inline char& RC(char &c){c = getchar(); return c;}\n//inline char RC(){return getchar();}\n\ntemplate inline T& RDD(T &x){\n char c; for (c = getchar(); c < '-'; c = getchar());\n if (c == '-'){x = '0' - getchar(); for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + '0' - c;}\n else {x = c - '0'; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';}\n return x;\n}\n\ninline LL RDD(){LL x; return RDD(x);}\n\ntemplate inline T0& RD(T0 &x0, T1 &x1){RD(x0), RD(x1); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6); return x0;}\ntemplate inline void OT(const T0 &x0, const T1 &x1){OT(x0), OT(x1);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2){OT(x0), OT(x1), OT(x2);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}\ninline char& RC(char &a, char &b){RC(a), RC(b); return a;}\ninline char& RC(char &a, char &b, char &c){RC(a), RC(b), RC(c); return a;}\ninline char& RC(char &a, char &b, char &c, char &d){RC(a), RC(b), RC(c), RC(d); return a;}\ninline char& RC(char &a, char &b, char &c, char &d, char &e){RC(a), RC(b), RC(c), RC(d), RC(e); return a;}\ninline char& RC(char &a, char &b, char &c, char &d, char &e, char &f){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f); return a;}\ninline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g); return a;}\ninline DB& RF(DB &a, DB &b){RF(a), RF(b); return a;}\ninline DB& RF(DB &a, DB &b, DB &c){RF(a), RF(b), RF(c); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d){RF(a), RF(b), RF(c), RF(d); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e){RF(a), RF(b), RF(c), RF(d), RF(e); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g); return a;}\ninline void RS(char *s1, char *s2){RS(s1), RS(s2);}\ninline void RS(char *s1, char *s2, char *s3){RS(s1), RS(s2), RS(s3);}\ntemplateinline void RDD(const T0&a, const T1&b){RDD(a),RDD(b);}\ntemplateinline void RDD(const T0&a, const T1&b, const T2&c){RDD(a),RDD(b),RDD(c);}\n\ntemplate inline void RST(T &A){memset(A, 0, sizeof(A));}\ntemplate inline void FLC(T &A, int x){memset(A, x, sizeof(A));}\ntemplate inline void CLR(T &A){A.clear();}\n\ntemplate inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}\ntemplate inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x), FLC(A6, x);}\ntemplate inline void CLR(priority_queue, less > &Q){while (!Q.empty()) Q.pop();}\ntemplate inline void CLR(priority_queue, greater > &Q){while (!Q.empty()) Q.pop();}\ntemplate inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}\ntemplate inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}\n\ntemplate inline T& SRT(T &A){sort(ALL(A)); return A;}\ntemplate inline T& SRT(T &A, C B){sort(ALL(A), B); return A;}\ntemplate inline T& UNQ(T &A){A.resize(unique(ALL(SRT(A)))-A.begin());return A;}\n\n//}\n\n/** Constant List .. **/ //{\n\nconst int dx4[] = {-1, 0, 1, 0};\nconst int dy4[] = {0, 1, 0, -1};\n\nconst int dx8[] = {-1, 0, 1, 0 , -1 , -1 , 1 , 1};\nconst int dy8[] = {0, 1, 0, -1 , -1 , 1 , -1 , 1};\n\nconst int dxhorse[] = {-2 , -2 , -1 , -1 , 1 , 1 , 2 , 2};\nconst int dyhorse[] = {1 , -1 , 2 , -2 , 2 ,-2 , 1 ,-1};\n\nconst int MOD = 1000000007;\n//int MOD = 99990001;\nconst int INF = 0x3f3f3f3f;\nconst LL INFF = 1LL << 60;\nconst DB EPS = 1e-9;\nconst DB OO = 1e15;\nconst DB PI = acos(-1.0); //M_PI;\n\n//}\n\n/** Add On .. **/ //{\n// <<= '0. Nichi Joo ., //{\ntemplate inline void checkMin(T &a,const T b){if (b inline void checkMax(T &a,const T b){if (a inline void checkMin(T &a, T &b, const T x){checkMin(a, x), checkMin(b, x);}\ntemplate inline void checkMax(T &a, T &b, const T x){checkMax(a, x), checkMax(b, x);}\ntemplate inline void checkMin(T& a, const T b, C c){if (c(b,a)) a = b;}\ntemplate inline void checkMax(T& a, const T b, C c){if (c(a,b)) a = b;}\ntemplate inline T min(T a, T b, T c){return min(min(a, b), c);}\ntemplate inline T max(T a, T b, T c){return max(max(a, b), c);}\ntemplate inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}\ntemplate inline T max(T a, T b, T c, T d){return max(max(a, b), max(c, d));}\ntemplate inline T sqr(T a){return a*a;}\ntemplate inline T cub(T a){return a*a*a;}\ninline int ceil(int x, int y){return (x - 1) / y + 1;}\ninline int sgn(DB x){return x < -EPS ? -1 : x > EPS;}\ninline int sgn(DB x, DB y){return sgn(x - y);}\n//}\n// <<= '1. Bitwise Operation ., //{\nnamespace BO{\n\ninline bool _1(int x, int i){return bool(x&1<> 1) & 0x55555555) | ((x << 1) & 0xaaaaaaaa);\n x = ((x >> 2) & 0x33333333) | ((x << 2) & 0xcccccccc);\n x = ((x >> 4) & 0x0f0f0f0f) | ((x << 4) & 0xf0f0f0f0);\n x = ((x >> 8) & 0x00ff00ff) | ((x << 8) & 0xff00ff00);\n x = ((x >>16) & 0x0000ffff) | ((x <<16) & 0xffff0000);\n return x;\n}\n\ninline LL reverse_bits(LL x){\n x = ((x >> 1) & 0x5555555555555555LL) | ((x << 1) & 0xaaaaaaaaaaaaaaaaLL);\n x = ((x >> 2) & 0x3333333333333333LL) | ((x << 2) & 0xccccccccccccccccLL);\n x = ((x >> 4) & 0x0f0f0f0f0f0f0f0fLL) | ((x << 4) & 0xf0f0f0f0f0f0f0f0LL);\n x = ((x >> 8) & 0x00ff00ff00ff00ffLL) | ((x << 8) & 0xff00ff00ff00ff00LL);\n x = ((x >>16) & 0x0000ffff0000ffffLL) | ((x <<16) & 0xffff0000ffff0000LL);\n x = ((x >>32) & 0x00000000ffffffffLL) | ((x <<32) & 0xffffffff00000000LL);\n return x;\n}\n\ntemplate inline bool odd(T x){return x&1;}\ntemplate inline bool even(T x){return !odd(x);}\ntemplate inline T low_bit(T x) {return x & -x;}\ntemplate inline T high_bit(T x) {T p = low_bit(x);while (p != x) x -= p, p = low_bit(x);return p;}\ntemplate inline T cover_bit(T x){T p = 1; while (p < x) p <<= 1;return p;}\n\ninline int low_idx(int x){return __builtin_ffs(x);}\ninline int low_idx(LL x){return __builtin_ffsll(x);}\ninline int high_idx(int x){return low_idx(reverse_bits(x));}\ninline int high_idx(LL x){return low_idx(reverse_bits(x));}\ninline int clz(int x){return __builtin_clz(x);}\ninline int clz(LL x){return __builtin_clzll(x);}\ninline int ctz(int x){return __builtin_ctz(x);}\ninline int ctz(LL x){return __builtin_ctzll(x);}\ninline int parity(int x){return __builtin_parity(x);}\ninline int parity(LL x){return __builtin_parityll(x);}\ninline int lg2(int a){return 31 - clz(a);}\ninline int lg2(LL a){return 63 - clz(a);}\ninline int count_bits(int x){return __builtin_popcount(x);}\ninline int count_bits(LL x){return __builtin_popcountll(x);}\n\n} using namespace BO;//}\n// <<= '2. Number Theory .,//{\nnamespace NT{\ninline LL __lcm(LL a, LL b){return a*b/__gcd(a,b);}\ninline void INC(int &a, int b){a += b; if (a >= MOD) a -= MOD;}\ninline int sum(int a, int b){a += b; if (a >= MOD) a -= MOD; return a;}\ninline void DEC(int &a, int b){a -= b; if (a < 0) a += MOD;}\ninline int dff(int a, int b){a -= b; if (a < 0) a += MOD; return a;}\ninline void MUL(int &a, int b){a = (LL)a * b % MOD;}\ninline int pdt(int a, int b){return (LL)a * b % MOD;}\n\ninline int sum(int a, int b, int c){return sum(sum(a, b), c);}\ninline int sum(int a, int b, int c, int d){return sum(sum(a, b), sum(c, d));}\ninline int pdt(int a, int b, int c){return pdt(pdt(a, b), c);}\ninline int pdt(int a, int b, int c, int d){return pdt(pdt(pdt(a, b), c), d);}\n\ninline int pow(int a, int b){\n int c(1); while (b){\n if (b&1) MUL(c, a);\n MUL(a, a), b >>= 1;\n }\n return c;\n}\n\ninline int pow(int a, LL b){\n int c(1); while (b){\n if (b&1) MUL(c, a);\n MUL(a, a), b >>= 1;\n }\n return c;\n}\n\ntemplate inline T pow(T a, LL b){\n T c(1); while (b){\n if (b&1) c *= a;\n a *= a, b >>= 1;\n }\n return c;\n}\n\ninline int _I(int b){\n int a = MOD, x1 = 0, x2 = 1, q;\n while (true){\n q = a / b, a %= b;\n if (!a) return (x2 + MOD) % MOD;\n DEC(x1, pdt(q, x2));\n\n q = b / a, b %= a;\n if (!b) return (x1 + MOD) % MOD;\n DEC(x2, pdt(q, x1));\n }\n}\n\ninline void DIV(int &a, int b){MUL(a, _I(b));}\ninline int qtt(int a, int b){return pdt(a, _I(b));}\n\ninline int phi(int n){\n int res = n; for (int i=2;sqr(i)<=n;++i) if (!(n%i)){\n DEC(res, qtt(res, i));\n do{n /= i;} while(!(n%i));\n }\n if (n != 1)\n DEC(res, qtt(res, n));\n return res;\n}\n\n} using namespace NT;//}\n//}\n\n/** Miscellaneous .. **/ //{\n// <<= 'Random Event .. . //{\nnamespace RNG{\n//srand((unsigned)time(NULL));\ninline unsigned int rand16(){return ((rand()) << 15) ^ rand();}\ninline unsigned int rand32(){return (rand16() << 16) | rand16();}\ninline ULL rand64(){return ((LL)rand32() << 32) | rand32();}\ninline ULL random(LL l, LL r){return l == r ? l : rand64() % (r - l) + l;}\nint dice(){return rand() % 6;}\nbool coin(){return bool(rand() % 2);}\n} using namespace RNG;\n//}\n// <<= 'Clock .. . //{\nnamespace CLOCK{\nDB s0, s1, rd, k, T;\ninline DB getTime(){\n#ifdef LOCAL\n return 1.0 * clock() / CLOCKS_PER_SEC;\n#else\n timeval tv;\n gettimeofday(&tv, 0);\n return tv.tv_sec + tv.tv_usec * 1e-6;\n#endif\n}\n\ninline void st0(DB _T = 0.98){T = _T, s0 = getTime();}\ninline void st1(DB _k = 1.618){k = _k, s1 = getTime();}\ninline void ed1(){rd = getTime() - s1;}\ninline DB elapsed(){return getTime() - s0;}\ninline bool safe(){return elapsed() + rd * k < T;}\n} //using namespace CLOCK;\n//}\n// <<= 'Temp .. . //{\nnamespace TMP{\ntemplate PTT operator+(const PTT &p1, const PTT &p2) {\n\treturn PTT(p1.fi + p2.fi, p1.se + p2.se);\n}\n\ntemplate PTT operator-(const PTT &p1, const PTT &p2) {\n\treturn PTT(p1.fi - p2.fi, p1.se - p2.se);\n}\n\ntemplate PTT operator*(const PTT &lhs, T k){\n return PTT(lhs.fi * k, lhs.se * k);\n}\n} using namespace TMP;\n//}\n//}\n\n/** Algorithm .. */ //{\n// <<= '-. Math .,//{\nnamespace Math{\n\ttypedef long long typec;\n\t///Lib functions\n\ttypec GCD(typec a, typec b)\n\t{\n\t\treturn b ? GCD(b, a % b) : a;\n\t}\n\ttypec extendGCD(typec a, typec b, typec& x, typec& y)\n\t{\n\t\tif(!b) return x = 1, y = 0, a;\n\t\ttypec res = extendGCD(b, a % b, x, y), tmp = x;\n\t\tx = y, y = tmp - (a / b) * y;\n\t\treturn res;\n\t}\n\t///for x^k\n\ttypec power(typec x, typec k)\n\t{\n\t\ttypec res = 1;\n\t\twhile(k)\n\t\t{\n\t\t\tif(k&1) res *= x;\n\t\t\tx *= x, k >>= 1;\n\t\t}\n\t\treturn res;\n\t}\n\t///for x^k mod m\n\ttypec powerMod(typec x, typec k, typec m)\n\t{\n\t\ttypec res = 1;\n\t\twhile(x %= m, k)\n\t\t{\n\t\t\tif(k&1) res *= x, res %= m;\n\t\t\tx *= x, k >>=1;\n\t\t}\n\t\treturn res;\n\t}\n\t/***************************************\n\tInverse in mod p^t system\n\t***************************************/\n\ttypec inverse(typec a, typec p, typec t = 1)\n\t{\n\t\ttypec pt = power(p, t);\n\t\ttypec x, y;\n\t y = extendGCD(a, pt, x, y);\n\t\treturn x < 0 ? x += pt : x;\n\t}\n\t/***************************************\n\tLinear congruence theorem\n\tx = a (mod p)\n\tx = b (mod q)\n\tfor gcd(p, q) = 1, 0 <= x < pq\n\t***************************************/\n\ttypec linearCongruence(typec a, typec b, typec p, typec q)\n\t{\n\t\ttypec x, y;\n\t\ty = extendGCD(p, q, x, y);\n\t\twhile(b < a) b += q / y;\n\t\tx *= b - a, x = p * x + a, x %= p * q;\n\t\tif(x < 0) x += p * q;\n\t\treturn x;\n\t}\n\t/***************************************\n\tprime table\n\tO(n)\n\t***************************************/\n\tconst int PRIMERANGE = 1000000;\n\tint prime[PRIMERANGE + 1];\n\tint mobius[PRIMERANGE + 1];\n\tint getPrime()\n\t{\n\t\tmemset (prime, 0, sizeof (int) * (PRIMERANGE + 1));\n\t\tmemset(mobius , 0 , sizeof(mobius));\n\t\tmobius[1] = 1;\n\t\tfor (int i = 2; i <= PRIMERANGE; i++)\n\t\t{\n\t\t\tif (!prime[i]) prime[++prime[0]] = i , mobius[i] = -1;\n\t\t\tfor (int j = 1; j <= prime[0] && prime[j] <= PRIMERANGE / i; j++)\n\t\t\t{\n\t\t\t\tprime[prime[j]*i] = 1;\n\t\t\t\tif (i % prime[j] == 0) break;\n\t\t\t\telse mobius[i * prime[j]] = -mobius[i];\n\t\t\t}\n\t\t}\n\t\treturn prime[0];\n\t}\n\t/***************************************\n\tget factor of n\n\tO(sqrt(n))\n\tfactor[][0] is prime factor\n\tfactor[][1] is factor generated by this prime\n\tfactor[][2] is factor counter\n\n\tneed: Prime Table\n\t***************************************/\n\t///you should init the prime table before\n\tint factor[100][3], facCnt;\n\tint getFactors(int x)\n\t{\n\t\tfacCnt = 0;\n\t\tint tmp = x;\n\t\tfor(int i = 1; prime[i] <= tmp / prime[i]; i++)\n\t\t{\n\t\t\tfactor[facCnt][1] = 1, factor[facCnt][2] = 0;\n\t\t\tif(tmp % prime[i] == 0)\n\t\t\t\tfactor[facCnt][0] = prime[i];\n\t\t\twhile(tmp % prime[i] == 0)\n\t\t\t\tfactor[facCnt][2]++, factor[facCnt][1] *= prime[i], tmp /= prime[i];\n\t\t\tif(factor[facCnt][1] > 1) facCnt++;\n\t\t}\n\t\tif(tmp != 1)\n\t\t\tfactor[facCnt][0] = tmp, factor[facCnt][1] = tmp, factor[facCnt++][2] = 1;\n\t\treturn facCnt;\n\t}\n\ttypec combinationModP(typec n, typec k, typec p)\n\t{\n\t\tif(k > n) return 0;\n\t\tif(n - k < k) k = n - k;\n\t\ttypec a = 1, b = 1, x, y;\n\t\tint pcnt = 0;\n\t\tfor(int i = 1; i <= k; i++)\n\t\t{\n\t\t\tx = n - i + 1, y = i;\n\t\t\twhile(x % p == 0) x /= p, pcnt++;\n\t\t\twhile(y % p == 0) y /= p, pcnt--;\n\t\t\tx %= p, y %= p, a *= x, b *= y;\n\t\t\tb %= p, a %= p;\n\t\t}\n\t\tif(pcnt) return 0;\n\t\textendGCD(b, p, x, y);\n\t\tif(x < 0) x += p;\n\t\ta *= x, a %= p;\n\t\treturn a;\n\t}\n};//using namespace Math;\n//}\n// <<= '-. Geo ,.//{\nnamespace Geo{\n\t#define typec double\n const typec eps=1e-9;\n int dblcmp(double d){\n return d < -eps ? -1 : d > eps;\n }\n int sgn(double a) {return a<-eps?-1:a>eps;}\n inline double sqr(double x){return x*x;}\n}using namespace Geo;\n//}\n//}\n\n/** I/O Accelerator Interface .. **/ //{\ntemplate inline T& RD(T &x){\n //cin >> x;\n //scanf(\"%d\", &x);\n char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';\n //char c; c = getchar(); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';\n return x;\n}\n\ninline DB& RF(DB &x){\n //cin >> x;\n scanf(\"%lf\", &x);\n /*char t; while ((t=getchar())==' '||t=='\\n'); x = t - '0';\n while ((t=getchar())!=' '&&t!='\\n'&&t!='.')x*=10,x+=t-'0';\n if (t=='.'){DB l=1; while ((t=getchar())!=' '&&t!='\\n')l*=0.1,x += (t-'0')*l;}*/\n return x;\n}\n\ninline char* RS(char *s){\n //gets(s);\n scanf(\"%s\", s);\n return s;\n}\n\nint Case; template inline void OT(const T &x){\n //printf(\"Case %d: %d\\n\", ++Case, x);\n //printf(\"%.2lf\\n\", x);\n //printf(\"%d\\n\", x);\n cout << x << endl;\n}\n//}\n/* .................................................................................................................................. */\nstruct point\n{\n double x,y;\n point(){}\n point(double _x,double _y):\n x(_x),y(_y){};\n void input()\n {\n scanf(\"%lf%lf\",&x,&y);\n }\n void output()\n {\n printf(\"%.2f %.2f\\n\",x,y);\n }\n bool operator==(point a)const\n {\n return dblcmp(a.x-x)==0&&dblcmp(a.y-y)==0;\n }\n bool operator<(point a)const\n {\n return dblcmp(a.x-x)==0?dblcmp(y-a.y)<0:xsub(p);\n double c=cos(angle),s=sin(angle);\n return point(p.x+v.x*c-v.y*s,p.y+v.x*s+v.y*c);\n }\n};\nstruct line\n{\n point a,b;\n line(){}\n line(point _a,point _b)\n {\n a=_a;\n b=_b;\n }\n bool operator==(line v)\n {\n \treturn (a==v.a)&&(b==v.b);\n }\n //\ufffd\ufffd\u0431\ufffd\ufffdangle\n// line(point p,double angle)\n// {\n// \ta=p;\n// \tif (dblcmp(angle-pi/2)==0)\n// \t{\n// \t\tb=a.add(point(0,1));\n// \t}\n// \telse\n// \t{\n// \t\tb=a.add(point(1,tan(angle)));\n// \t}\n// }\n// //ax+by+c=0\n// line(double _a,double _b,double _c)\n// {\n// \tif (dblcmp(_a)==0)\n// \t{\n// \t\ta=point(0,-_c/_b);\n// \t\tb=point(1,-_c/_b);\n// \t}\n// \telse if (dblcmp(_b)==0)\n// \t{\n// \t\ta=point(-_c/_a,0);\n// \t\tb=point(-_c/_a,1);\n// \t}\n// \telse\n// \t{\n// \t\ta=point(0,-_c/_b);\n// \t\tb=point(1,(-_c-_a)/_b);\n// \t}\n// }\n void input()\n {\n a.input();\n b.input();\n }\n void adjust()\n {\n \tif (b0)return 2;\n return 3;\n }\n bool pointonseg(point p)\n {\n return dblcmp(p.sub(a).det(b.sub(a)))==0&&dblcmp(p.sub(a).dot(p.sub(b)))<=0;\n }\n bool parallel(line v)\n {\n return dblcmp(b.sub(a).det(v.b.sub(v.a)))==0;\n }\n //2 \ufffd\u6df6\ufffd\u0f7b\n //1 \ufffd\u01f9\u6df6\ufffd\u0f7b\n //0 \ufffd\ufffd\ufffd\u0f7b\n int segcrossseg(line v)\n {\n int d1=dblcmp(b.sub(a).det(v.a.sub(a)));\n int d2=dblcmp(b.sub(a).det(v.b.sub(a)));\n int d3=dblcmp(v.b.sub(v.a).det(a.sub(v.a)));\n int d4=dblcmp(v.b.sub(v.a).det(b.sub(v.a)));\n if ((d1^d2)==-2&&(d3^d4)==-2)return 2;\n return (d1==0&&dblcmp(v.a.sub(a).dot(v.a.sub(b)))<=0||\n d2==0&&dblcmp(v.b.sub(a).dot(v.b.sub(b)))<=0||\n d3==0&&dblcmp(a.sub(v.a).dot(a.sub(v.b)))<=0||\n d4==0&&dblcmp(b.sub(v.a).dot(b.sub(v.b)))<=0);\n }\n int linecrossseg(line v)//*this seg v line\n {\n int d1=dblcmp(b.sub(a).det(v.a.sub(a)));\n int d2=dblcmp(b.sub(a).det(v.b.sub(a)));\n if ((d1^d2)==-2)return 2;\n return (d1==0||d2==0);\n }\n //0 \u01bd\ufffd\ufffd\n\t//1 \ufffd\u063a\ufffd\n\t//2 \ufffd\u0f7b\n int linecrossline(line v)\n {\n if ((*this).parallel(v))\n {\n return v.relation(a)==3;\n }\n return 2;\n }\n point crosspoint(line v)\n {\n double a1=v.b.sub(v.a).det(a.sub(v.a));\n double a2=v.b.sub(v.a).det(b.sub(v.a));\n return point((a.x*a2-b.x*a1)/(a2-a1),(a.y*a2-b.y*a1)/(a2-a1));\n }\n};\nconst int N = 21;\ndouble a[N] , l , r;\n#define Point2D point\nPoint2D p[N];\nint n;\ndouble dp[N];\nline XX;\ndouble f(double now , int k){\n if (dblcmp(now - r) >= 0) return r;\n double rad = p[k].rad(Point2D(now , 0) , Point2D(r , 0));\n// printf(\"%.9lf\\n\" , rad);\n if (dblcmp(rad - a[k]) <= 0) return r;\n point dd = point(now , 0);\n dd = dd.rotate(p[k] , a[k]);\n dd = line(p[k] , dd).crosspoint(XX);\n return dd.x;\n}\nvoid solve(){\n XX = line(point(l , 0) , point(r , 0));\n RST(dp);\n for (int i = 0 ; i < n ; ++i){\n p[i].input();\n cin >> a[i];\n a[i] *= PI / 180.;\n }\n double ans = 0;\n dp[0] = l;\n for (int i = 0 ; i < _1(n) ; ++i){\n checkMax(ans , dp[i]);\n for(int j = 0 ; j < n ; ++j) if ((i & _1(j)) == 0){\n checkMax(dp[(i | _1(j))] , f(dp[(i)] , j));\n }\n }\n checkMin(ans , r);\n printf(\"%.9lf\\n\" , ans - l);\n}\nint main(){\n cin >> n >> l >> r; solve();\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "03afd75084a171d13a61edb6e8dcee05", "src_uid": "4fad1233e08bef09e5aa7e2dc6167d6a", "difficulty": 2200.0} {"lang": "MS C++", "source_code": "#include \n#include \nstruct list\n{\n int x, y, deg;\n};\nlist data[22];\nint n, l, r;\ndouble D[1100000][22], eps = 1e-6;\nconst double pi = 3.1415926535;\nbool cmp(double x)\n{\n if(-eps <= x && x <= eps) return true;\n return false;\n}\nvoid dfs(int state, int end)\n{\n if(D[state][end] != 0) return;\n for(int i=1; i<=n; i++){\n if(state == (1 << (i-1))){\n double z = l;\n double x = data[i].x, y = data[i].y, theta = data[i].deg / 180. * pi;\n double ll = sqrt((x - z) * (x - z) + y * y);\n double alpha = asin(y / ll);\n if(z < x){\n if(cmp(alpha + theta - pi / 2)) D[state][end] = std::max(D[state][end], x - l);\n else{\n double nl = ll * cos(alpha) - y / tan(alpha + theta);\n D[state][end] = std::max(D[state][end], nl);\n }\n }else{\n if(theta >= alpha - eps) D[state][end] = r - l;\n else{\n double nl = y * (tan(pi / 2 - alpha + theta) - tan(pi / 2 - alpha));\n D[state][end] = std::max(D[state][end], nl);\n }\n }\n D[state][end] = std::min(D[state][end], r - l);\n return;\n }\n }\n for(int i=1; i<=n; i++){\n if(i == end) continue;\n if(!(state & (1 << (i - 1)))) continue;\n int nstate = state - (1 << (end - 1)) - (1 << (i - 1));\n dfs(nstate, i);\n double z = l + D[nstate][i];\n double x = data[i].x, y = data[i].y, theta = data[i].deg;\n double ll = sqrt((x - z) * (x - z) + y * y);\n double alpha = asin(y / ll);\n if(z < x){\n if(cmp(alpha + theta - pi / 2)) D[state][end] = std::max(D[state][end], x - l);\n else{\n double nl = ll * cos(alpha) - y / tan(alpha + theta);\n D[state][end] = std::max(D[state][end], D[nstate][i] + nl);\n }\n }else{\n if(theta >= alpha - eps) D[state][end] = r - l;\n else{\n double nl = y * (tan(pi / 2 - alpha + theta) - tan(pi / 2 - alpha));\n D[state][end] = std::max(D[state][end], D[nstate][i] + nl);\n }\n }\n }\n D[state][end] = std::min(D[state][end], r - l);\n}\nint main()\n{\n double ans = 0;\n scanf(\"%d%d%d\", &n, &l, &r);\n for(int i=1; i<=n; i++) scanf(\"%d%d%d\", &data[i].x, &data[i].y, &data[i].deg);\n for(int i=1; i<=n; i++){\n dfs((1 << n) - 1, i);\n ans = std::max(ans, D[(1 << n) - 1][i]);\n }\n printf(\"%.9lf\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7ecd7ec6a29f65f87ddfabced92b2e54", "src_uid": "4fad1233e08bef09e5aa7e2dc6167d6a", "difficulty": 2200.0} {"lang": "GNU C++14", "source_code": "//#pragma GCC optimize(2)\n#include\nusing namespace std;\n#define ll long long\n#define ls o<<1\n#define rs o<<1|1\n#define pii pair\n#define fi first\n#define se second\nconst double pi=acos(-1.0);\nconst double eps=1e-10;\nconst ll mod=1e9+7;\nconst int INF=0x3f3f3f3f;\nconst int maxn=255;\nll read(){\n\tll x=0,f=1;\n\tchar ch=getchar();\n\twhile(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}\n\twhile(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}\n\treturn x*f;\n}\nint n,k;\nll fac[maxn],inv[maxn],dp[maxn][maxn];\nll qpow(ll a,ll p){\n\tll res=1;\n\twhile(p){\n\t\tif(p&1)res=res*a%mod;\n\t\ta=a*a%mod;\n\t\tp>>=1;\n\t}\n\treturn res;\n}\nvoid init(int n){\n\tfac[0]=1;\n\tfor(int i=1;i<=n;i++)fac[i]=fac[i-1]*i%mod;\n\tinv[1]=1;\n\tfor(int i=2;i<=n;i++)inv[i]=inv[i-1]*qpow(i,mod-2)%mod;\n}\nll comb(int a,int b){\n\tif(a==b)return 1;\n\tif(a\n#define ll long long\n\nusing namespace std;\n\nconst int N = 250; \nconst ll mod = (ll)1e9 + 7; \n\nint n; \nll k, C[N][N], dp[N][N]; \n\nll fpw(ll x, ll k, ll p) {\n ll ret = 1;\n while(k) {\n if(k & 1) ret = ret * x % p; \n x = x * x % p; k >>= 1; \n } \n return ret; \n}\n\nint main() {\n cin >> n >> k; \n C[0][0] = 1; \n for(int i = 1; i <= n; i++) {\n C[i][0] = 1; \n for(int j = 1; j <= i; j++) {\n C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod; \n }\n }\n dp[0][0] = 1; \n for(int i = 1; i <= n; i++) {\n for(int j = 1; j <= n; j++) {\n for(int x = 0; x <= j; x++) {\n dp[i][j] += dp[i - 1][x] * C[n - x][j - x] % mod * ((fpw(k, x, mod) + mod - fpw(k - 1, x, mod) * (j == x)) % mod) % mod * fpw(k - 1, n - j, mod) % mod; \n dp[i][j] %= mod; \n }\n }\n }\n cout << dp[n][n] << endl; \n return 0; \n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3bd83813ad5aafd5dce935fb9ce1cf88", "src_uid": "f67173c973c6f83e88bc0ddb0b9bfa93", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#include \n#ifdef TOPOLOGY\n#define debug(...) fprintf(stderr, __VA_ARGS__)\n#else\n#define debug(...)\n#endif\nusing namespace std;\n\nconst int P = 1000000007;\n\nint dp[256][256], nck[256][256];\n\ninline void add(int &a, int b) {\n\ta += b;\n\tif (a >= P) a -= P;\n}\n\ninline int mul(int a, int b) {\n\treturn 1LL * a * b % P;\n}\n\ninline void sub(int &a, int b) {\n\ta -= b;\n\tif (a < 0) a += P;\n}\n\nint pw(int a, int b) {\n\tif (b == 0) return 1;\n\tint res = pw(a, b / 2);\n\tif (b & 1) return mul(res, mul(res, a));\n\treturn mul(res, res);\n}\n\nint main() {\n\tint n, k;\n\tcin >> n >> k;\n\tif (k == 1) {\n\t\tcout << 1 << endl;\n\t\treturn 0;\n\t}\n\tnck[0][0] = 1;\n\tfor (int i = 1; i <= n + 3; i++) {\n\t\tfor (int j = 0; j <= i; j++) {\n\t\t\tnck[i][j] = nck[i - 1][j];\n\t\t\tadd(nck[i][j], nck[i - 1][j - 1]);\n\t\t}\n\t}\n\tfor (int j = 1; j <= n; j++) {\n\t\tdp[1][j] = mul(nck[n][j], pw(k - 1, n - j));\n\t}\n\tfor (int i = 2; i <= n; i++) {\n\t\tfor (int j = 1; j <= n; j++) {\n\t\t\tdp[i][j] = 0;\n\t\t\tfor (int l = 1; l <= j; l++) {\n\t\t\t\tint res = pw(k, l);\n\t\t\t\tif (j == l) sub(res, pw(k - 1, l));\n\t\t\t\tres = mul(res, pw(k - 1, n - j));\n\t\t\t\tres = mul(res, nck[n - l][j - l]);\n\t\t\t\tadd(dp[i][j], mul(res, dp[i - 1][l]));\n\t\t\t}\n\t\t\t// debug(\"dp[%d][%d] = %d\\n\", i, j, dp[i][j]);\n\t\t}\n\t}\n\t// for (int i = 1; i <= n; i++) {\n\t// \tfor (int j = 1; j <= n; j++) {\n\t// \t\tdebug(\"dp[%d][%d] = %d\\n\", i, j, dp[i][j]);\t\n\t// \t}\n\t// }\n\tcout << dp[n][n] << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "220b7655e9d5ae9bc200b8b79732ce24", "src_uid": "f67173c973c6f83e88bc0ddb0b9bfa93", "difficulty": 2300.0} {"lang": "GNU C++11", "source_code": "#pragma GCC optimize(2)\n#include\n#define ls rt<<1\n#define rs rt<<1|1\n#define fi first\n#define se second\n#define pb push_back\nusing namespace std;\ntypedef long long ll;\ntypedef vector VI;\ntypedef pair pii;\ntypedef pair pll;\nconst ll inf = 0x3f3f3f3f;\nconst int mod = 1e9 + 7;\nconst int maxn = 1e6 + 6;\nconst int N = 5e3 + 4;\nconst double eps = 1e-6;\nll qpow(ll x,ll y){ll ans=1;x%=mod;while(y){ if(y&1) ans=ans*x%mod; x=x*x%mod; y>>=1;}return ans;}\n\nll C[N][N],dp[N][N];\nll n,K;\n\nint main(){\n\n for(int i=0;i<=250;i++) C[i][i]=1;\n for(int i=1;i<=250;i++){\n C[i][0]=C[i][i]=1;\n for(int j=1;j\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define N 100005\nusing namespace std;\ntypedef long long ll;\nint a[202],b[202];\nint main()\n{\n int n,k;\n scanf(\"%d%d\",&n,&k);\n int f=1,m=0,z=0;\n for(int i=0;i0){\n if(b[0]>a[z+1]||b[0]1)f=0;\n if(!f)printf(\"YES\\n\");\n else printf(\"NO\\n\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6ce95b820c2e5ebe24a7c608de2b067f", "src_uid": "40264e84c041fcfb4f8c0af784df102a", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\nint main()\n{\n int a,b,c[100],e;\n cin>>a>>b;\n if(b>=2)\n {\n cout<<\"Yes\";\n goto ed;\n }\n for(int i=0;i>c[i];\n }\n cin>>e;\n for(int i=1;ie)\n {\n cout<<\"Yes\";\n goto ed;\n }\n }\n else if(c[i-1]>c[i])\n {\n cout<<\"Yes\";\n goto ed;\n }\n }\n cout<<\"No\";\n ed:;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4f7136ef65162c5df2dc32e97563c45e", "src_uid": "40264e84c041fcfb4f8c0af784df102a", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std;\n\nint n,k;\nint a[200];\nint b[200];\n\nbool checknotinc(int s[],int c){\n\tfor (int i = 0;i s[i+1]){\n\t\t \t\n \t\t\treturn true;\n \t\t}\n\t}\n\treturn false;\n}\n\n\nint main(){\n\tcin>>n>>k;\n\tfor (int i = 0;i>a[i];\n\t}\n\tfor (int i = 0;i>b[i];\n\t}\n\treverse (b, b+k);\n\n\n int j = 0; \n \tfor (int i = 0;i k) break;\n\t\t}\n\t} \n\n if (checknotinc(a,n)){\n \tcout<<\"YES\";\n }else{\n \tcout<<\"NO\";\n }\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1cb488827a605968379bbe30237fb79f", "src_uid": "40264e84c041fcfb4f8c0af784df102a", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std;\ntemplate \ninline void read(T& x)\n{\n\tchar c = getchar(); T p = 1, n = 0;\n\twhile(c < '0' || c > '9'){if(c == '-') p = -1; c = getchar();}\n\twhile(c >= '0' && c <= '9'){n = n * 10 + c - '0'; c = getchar();}\n\tx = p * n;\n}\ntemplate\ninline void read(T& x, U& y){read(x), read(y);}\ntemplate\ninline void read(T& x, U& y, V& z){read(x), read(y), read(z);}\nint main()\n{\n\tint n, k; read(n, k);\n\tbool isInc = true; int last = -1, cnt0 = 0;\n\tfor(int i = 0, a; i < n; i++)\n\t{\n\t\tread(a); if(a == 0) cnt0++;\n\t\telse\n\t\t{\n\t\t\tif(isInc && last > a) isInc = false;\n\t\t\telse if(isInc) last = a;\n\t\t}\n\t}\n\tputs(isInc && k <= 1 ? \"No\" : \"Yes\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6f3a98f82830e80e18974e3060900f87", "src_uid": "40264e84c041fcfb4f8c0af784df102a", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include\n#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)\n#define fd(i,a,b)for(int i=b,_e=a;i>=_e;--i)\n#define add(x,y)(x=(x+y)%mo)\nusing namespace std;\nconst int N=205,mo=10007;\nchar c[N];\nint n,m,ans,t;\nint f[N][N][N],su[N];\nstruct mat{int a[N][N];}a,b;\nmat operator*(const mat&a,const mat&b){\n\tmat c;memset(c.a,0,sizeof c.a);\n\tfo(i,1,t)fo(j,1,t)fo(k,1,t)add(c.a[i][k],a.a[i][j]*b.a[j][k]);\n\treturn c;\n}\nmat ksm(mat x,int y){\n\tmat b;memset(b.a,0,sizeof b.a);\n\tfo(i,1,t)b.a[i][i]=1;\n\tfor(;y;y>>=1,x=x*x)if(y&1)b=b*x;\n\treturn b;\n}\nint main(){\n\tscanf(\"%s\\n%d\",c+1,&m);n=strlen(c+1);\n\tf[1][n][0]=1;\n\tfo(i,1,n)fd(j,i,n)\n\t\tif(c[i]==c[j]){\n\t\t\tfo(k,0,n)\n\t\t\t\tif(i+1<=j-1)add(f[i+1][j-1][k],f[i][j][k]);\n\t\t\t\telse add(su[k],f[i][j][k]);\n\t\t}else{\n\t\t\tfo(k,0,n-1){\n\t\t\t\tadd(f[i+1][j][k+1],f[i][j][k]);\n\t\t\t\tadd(f[i][j-1][k+1],f[i][j][k]);\n\t\t\t}\n\t\t}\n\tt=n+(n+1>>1)+1;\n\ta.a[t][t]=26;\n\tfo(i,1,n){\n\t\ta.a[i][i]=24;a.a[i][n+(n-i+1)/2]=su[i];\n\t\tif(in+1)a.a[i][i-1]=1;else a.a[i][t]=1;\n\t}\n\tb=ksm(a,n+m+1>>1);\n\tans=(b.a[1][t]+su[0]*b.a[t-1][t])%mo;\n\tif(n+m&1){\n\t\tfo(i,0,n)su[i]=0;\n\t\tfo(i,1,n-1)if(c[i]==c[i+1])\n\t\t\tfo(j,0,n)add(su[j],f[i][i+1][j]);\n\t\tfo(i,1,n)a.a[i][n+(n-i+1)/2]=su[i];a.a[t][t]=0;\n\t\tb=ksm(a,n+m+1>>1);\n\t\tans=((ans-b.a[1][t]+su[0]*b.a[t-1][t])%mo+mo)%mo;\n\t}\n\tcout<\n#include\n#include\n#include\n#define stc static\n#define FOR(i,a,b) for(int i=a;i<=b;i++)\n#define ROF(i,a,b) for(int i=a;i>=b;i--)\n#define REP(u) for(int i=hd[u],v;v=e[i].v,i;i=e[i].n)\nusing namespace std;\nconst int N=330,TO=100100,M=1010,P=10007;\nstruct edge{int n,v;}e[TO<<1];\nint n,m,S,T,R,fl,ans;\nint hd[TO],l[TO],r[TO],g[N][N],c[TO],di[TO],du[TO];\nint f[TO][N],w[2][N],vi[TO],a[M][M],b[M][M];\nchar s[N];\nqueueq;\nvoid add(int u,int v){e[++fl]=(edge){hd[u],v};hd[u]=fl;}\nvoid dfs(int u){REP(u){du[v]++;if(!vi[v]) vi[v]=1,dfs(v);}}\nvoid bld(){\n\tT++;\n\tFOR(i,1,T-1){\n\t\tif(s[l[i]+1]==s[r[i]-1])\n\t\t\tc[i]=1,r[i]-l[i]>3?add(i,g[l[i]+1][r[i]-1]):add(i,T);\n\t\telse\n\t\t\tc[i]=0,add(i,g[l[i]+1][r[i]]),add(i,g[l[i]][r[i]-1]);\n\t}\n\t//FOR(x,1,T){cout<>=1,mul(c,c,c))if(y&1) mul(b,c,b);\n}\nvoid mtm(){\n\tR=3*n;\n\tFOR(i,n+1,n*2) a[i-n][i-n]=24,a[i][i]=25,a[i+n][i+n]=26,a[i][i+n]=1;\n\tFOR(i,2,2*n) a[i-1][i]=1;qpw(a,m/2,b);\n\t//FOR(i,1,R)FOR(j,1,R) cout<=0) (ans+=w[0][j]*b[n-j+1][k+2*n]%P)%=P;\n\t\tif(i>=0) (ans+=w[1][i]*b[n-i+1][k+2*n]%P)%=P;\n\t}\n}\nint main(){\n\tscanf(\"%s%d\",s+1,&m);\n\tn=strlen(s+1);m+=n;\n\tFOR(i,0,n-1)ROF(j,n+1,i+2) g[i][j]=++T,l[T]=i,r[T]=j;\n\tbld();wrk();mtm();\n\tprintf(\"%d\\n\",ans);\n}/*\na\n100000\n*/", "lang_cluster": "C++", "compilation_error": false, "code_uid": "714d244cb23ea70488400540c8e39aa4", "src_uid": "2ae6f17e0dd0bc93090d939f4f49d7a8", "difficulty": 3000.0} {"lang": "GNU C++11", "source_code": "#pragma GCC optimize(\"O3\")\n#pragma GCC optimize(\"Ofast,no-stack-protector\")\n#include\nusing namespace std;\n#define INF 0x3f3f3f3f\n#define endl \"\\n\"\n#define LL long long int\n#define vi vector\n#define vl vector\n#define all(V) V.begin(),V.end()\n#define scs(s) scanf(\"%s\",s)\n#define pii pair\n#define pll pair\n#ifndef ONLINE_JUDGE\n#define cout cerr\n#endif\n#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator _it(_ss); err(_it, args); }\nvoid err(istream_iterator it) {}\ntemplate\nvoid err(istream_iterator it, T a, Args... args) {\n cerr << *it << \" = \" << a << endl;\n err(++it, args...);\n}\n#define cmax(a,b) ((a) = (a) > (b) ? (a) : (b))\n#define cmin(a,b) ((a) = (a) < (b) ? (a) : (b))\n#define debug(x) cerr << #x << \" = \" << x << endl\nfunction ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};\ntemplate vector& operator << (vector &__container, T x){ __container.push_back(x); return __container; }\ntemplate ostream& operator << (ostream &out, vector &__container){ for(T _ : __container) out << _ << ' '; return out; }\nvoid sci(){}\ntemplate void sci(int &x, Args&... args){ scanf(\"%d\",&x); sci(args...); }\nvoid scl(){}\ntemplate void scl(LL &x, Args&... args){ scanf(\"%lld\",&x); scl(args...); }\nconst int MAXN = 107;\nconst int N = 107;\nconst int MOD = 1e4+7;\nstruct Matrix{\n int mat[N][N];\n Matrix(int x = 0){ for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) mat[i][j] = i == j ? x : 0; }\n int* operator [](const int idx){ return mat[idx]; }\n Matrix operator * (Matrix rhs){\n Matrix ret(0);\n for(int i = 0; i < N; i++) for(int j = i; j < N; j++) for(int k = i; k <= j; k++)\n ret[i][j] = (ret[i][j] + mat[i][k] * rhs[k][j]) % MOD;\n return ret;\n }\n // Matrix fast power\n Matrix operator ^ (int b){\n Matrix ret(1), A(*this);\n while(b){\n if(b&1) ret = ret * A;\n b >>= 1;\n A = A * A;\n }\n return ret;\n }\n};\nchar s[MAXN];\nint n, m, f[MAXN][MAXN][MAXN], g[MAXN];\nvoid solve(){\n scs(s+1); sci(m);\n n = strlen(s+1);\n f[1][n][0] = 1;\n for(int i = 1; i <= n; i++) for(int j = n; j >= i; j--) for(int k = 0; k <= n - j + i - 1; k++){\n if(s[i]==s[j]){\n if(i+1>=j) g[k] = (g[k] + f[i][j][k]) % MOD;\n else f[i+1][j-1][k] = (f[i+1][j-1][k] + f[i][j][k]) % MOD; \n }else{\n f[i+1][j][k+1] = (f[i+1][j][k+1] + f[i][j][k]) % MOD;\n f[i][j-1][k+1] = (f[i][j-1][k+1] + f[i][j][k]) % MOD;\n }\n }\n Matrix M(0),S(0);\n S[0][1] = 1; S[0][N-(n+1)/2] = g[0];\n // edge from ith red vectex to [(n-i)/2]th green vertex, [x] means get ceil of x \n int N = n + (n + 1) / 2 + 1;\n M[N][N] = 26; // Final state selfloop\n for(int i = 1; i <= n; i++){\n M[i][N-(n-i+1)/2] = g[i]; // transform to green vertex\n M[i][i] = 24; // red vertex selfloop, exclude the start state\n if(i!=n) M[i][i+1] = 1; // tranform to next red vertex, until the last red vertex\n }\n for(int i = n + 1; i < N; i++) M[i][i+1] = 1, M[i][i] = 25; // green vertex selfloop and transform to next state\n if((n+m)&1){\n S = S * (M ^ ((n+m+1)>>1));\n int ret = S[0][N];\n // this resault include the illeagle state which transform from the state represent two same characters to final state\n // so we should minus the illeagle transform\n for(int i = 0; i < ::N; i++) for(int j = 0; j < ::N; j++) S[i][j] = M[i][j] = 0;\n memset(g,0,sizeof(g));\n for(int i = 1; i < n; i++) if(s[i]==s[i+1]) for(int k = 0; k <= n; k++) g[k] = (g[k] + f[i][i+1][k]) % MOD;\n S[0][1] = 1; S[0][N-(n+1)/2] = g[0];\n for(int i = 1; i <= n; i++){\n M[i][N-(n-i+1)/2] = g[i]; // transform to green vertex\n M[i][i] = 24; // red vertex selfloop, exclude the start state\n if(i!=n) M[i][i+1] = 1; // tranform to next red vertex, until the last red vertex\n }\n for(int i = n + 1; i < N; i++) M[i][i+1] = 1, M[i][i] = 25; // green vertex selfloop and transform to next state\n S = S * (M ^ ((n+m+1)>>1));\n ret = (ret - S[0][N] + MOD) % MOD;\n cout << ret << endl;\n }else{\n S = S * (M ^ ((n+m+1)>>1));\n cout << S[0][N] << endl;\n }\n}\nint main(){\n #ifndef ONLINE_JUDGE\n freopen(\"Local.in\",\"r\",stdin);\n freopen(\"ans.out\",\"w\",stdout);\n #endif\n solve();\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "72db57ba21c5961c7140a36bd9b75964", "src_uid": "2ae6f17e0dd0bc93090d939f4f49d7a8", "difficulty": 3000.0} {"lang": "GNU C++14", "source_code": "#include \n#define clr(x) memset(x,0,sizeof x)\n#define For(i,a,b) for (int i=(a);i<=(b);i++)\n#define Fod(i,b,a) for (int i=(b);i>=(a);i--)\n#define pb(x) push_back(x)\n#define mp(x,y) make_pair(x,y)\n#define fi first\n#define se second\n#define outval(x) cerr<<#x\" = \"< pii;\nLL read(){\n LL x=0,f=0;\n char ch=getchar();\n while (!isdigit(ch))\n f=ch=='-',ch=getchar();\n while (isdigit(ch))\n x=(x<<1)+(x<<3)+(ch^48),ch=getchar();\n return f?-x:x;\n}\nconst int N=100005;\nint n,m,k,p;\nLL h[N],a[N],day[N];\nstruct cmp{\n\tbool operator () (int a,int b){\n\t\tif (day[a]!=day[b])\n\t\t\treturn day[a] S;\nLL now[N];\nint check(LL x){\n\tS.clear();\n\tFor(i,1,n){\n\t\tnow[i]=x,day[i]=now[i]/a[i];\n\t\tS.insert(i);\n\t}\n\tFod(d,m,1){\n\t\tFor(j,1,k){\n\t\t\tint i=*S.begin();\n\t\t\tS.erase(S.begin());\n\t\t\tif (day[i]>=m){\n\t\t\t\tLL rem=k-j+1+(d-1)*k;\n\t\t\t\tFor(i,1,n){\n\t\t\t\t\tLL v=now[i]-a[i]*m;\n\t\t\t\t\twhile (v>1;\n\t\tif (check(mid))\n\t\t\tR=mid-1,ans=mid;\n\t\telse\n\t\t\tL=mid+1;\n\t}\n\tcout<\n#include \nusing namespace std;\n\nint main(int argc, char** argv) {\n\tchar ch;\n\twhile(1)\n {\n ch = getch();\n cout<\n#include\n#include\nusing namespace std;\nint main()\n{\n int n;\n cin>>n;\n if(n%5==0)\n {\n cout<\n#include \nusing namespace std;\n\nint main(int argc, char** argv) {\n\tchar ch;\n\twhile(1)\n {\n ch = getch();\n if(ch == 13) {\n \tcout<<25;\n return 0; \n }\n }\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "df41886de1ac999384c3d819939e21f9", "src_uid": "dcaff75492eafaf61d598779d6202c9d", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nmain()\n{\n int x,i,y ;\n cin>>x ;\n x-- ;\n y=5 ;\n for(i=1;i<=x;i++)\n {\n y=y*5 ;\n }\n y=y%100 ;\n cout<\nusing namespace std;\nint mx=1e8,p=2e8+1,cnt=0;\nsethok,hfailed,vok,vfailed;\nbool checkh(int y){\n if(y>mx||y<-mx)return 0;\n if(hok.count(y))return 1;\n if(hfailed.count(y))return 0;\n for(int i=0;i<10;++i){\n int x=rand()%p-mx;\n printf(\"0 %d %d\",x,y);\n ++cnt;\n fflush(stdout);\n scanf(\"%d\",&x);\n if(x!=0){hfailed.insert(y);return 0;}\n }\n hok.insert(y);\n return 1;\n}\nbool checkv(int x){\n if(x>mx||x<-mx)return 0;\n if(vok.count(x))return 1;\n if(vfailed.count(x))return 0;\n for(int i=0;i<10;++i){\n int y=rand()%p-mx;\n printf(\"0 %d %d\",x,y);\n ++cnt;\n fflush(stdout);\n scanf(\"%d\",&y);\n if(y!=0){vfailed.insert(x);return 0;}\n }\n vok.insert(x);\n return 1;\n}\nint main()\n{\n int x,y,d;\n while(cnt<2e5){\n x=rand()%p-mx;y=rand()%p-mx;\n printf(\"0 %d %d\",x,y);\n fflush(stdout);\n scanf(\"%d\",&d);\n ++cnt;\n checkh(y-d);checkh(y+d);\n checkv(x-d);checkv(x+d);\n }\n cout<<\"1 \"<\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\nconst int maxn = 1000006;\n\nint n;\nconst int maxx = 1e8;\nvector ans, gor, ver;\n\nint get_d(int x, int y) {\n\tcout << \"0 \" << x << \" \" << y << endl;\n\tfflush(stdout);\n\tint ans;\n\tcin >> ans;\n\treturn ans;\n}\n\nvoid f(int l, int r) {\n\tint md = (l + r) >> 1;\n\tint dist = get_d(md, md);\n\tif (dist == 0) ans.push_back(md);\n\tf(md + dist, r);\n\tf(l, md - dist);\n}\n\nint main() {\n\tsrand(194375);\n\tios_base::sync_with_stdio(false);\n\tf(-maxx, maxx);\n\tfor (int u : ans) {\n\t\tint t1 = rand() % maxx, t2 = rand() % maxx;\n\t\tif (get_d(u, t1) == 0 && get_d(u, t2) == 0) ver.push_back(u);\n\t\telse gor.push_back(u);\n\t}\n\tcout << \"1 \" << ver.size() << \" \" << gor.size() << endl;\n\tfor (int u : ver) cout << u << \" \";\n\tcout << endl;\n\tfor (int u : gor) cout << u << \" \";\n\tcout << endl;\n\tfflush(stdout);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "aa71ae944981719dc07fa6c178a8e1a8", "src_uid": "583cd1e553133b297f99fd52e5ad355b", "difficulty": 3000.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nconst int MAX = 100000000;\nmap, int> cache;\nmap, bool> is_cached;\nint query(int x, int y){\n if(is_cached[{x, y}]) return cache[{x, y}];\n printf(\"0 %d %d\\n\", x, y);\n fflush(stdout);\n int d;\n scanf(\"%d\", &d);\n is_cached[{x, y}] = true;\n if(d == -1) exit(0);\n cache[{x, y}] = d;\n return d;\n}\nvector queries;\nvoid solve(int lo, int hi){\n //printf(\"Solving %d - %d\\n\", lo, hi);\n int md = (lo + hi) / 2;\n int q = query(md, md);\n if(q == (md - lo)){\n if(md + q < hi){\n int p = query(md + q, md + q);\n if(p == 0) {\n //printf(\"Inserting %d\\n\", p);\n queries.push_back(p);\n }\n }\n return;\n }\n int pos1 = md - q;\n int p = query(pos1, pos1);\n int found = pos1;\n if(p) found = md + q;\n //printf(\"Inserting %d\\n\", found);\n queries.push_back(found);\n solve(lo, found);\n solve(found, hi);\n}\nint find_none(vector a){\n if(a[0] != -MAX) return -MAX;\n int i = 1;\n for(; i < a.size(); i++){\n if(a[i] != a[i - 1] + 1) break;\n }\n return a[i - 1] + 1;\n}\nvector vertical, horizontal;\nvoid resolve(vector pts){\n int none = find_none(pts);\n for(auto p : pts){\n int q1 = query(none, p);\n if(q1 == 0) horizontal.push_back(p);\n int q2 = query(p, none);\n if(q2 == 0) vertical.push_back(p);\n }\n printf(\"1 %d %d\\n\", vertical.size(), horizontal.size());\n for(auto x : vertical) printf(\"%d \", x); printf(\"\\n\");\n for(auto y : horizontal) printf(\"%d \", y); printf(\"\\n\");\n}\nint main(){\n int lo = query(-MAX, -MAX) - MAX;\n int hi = MAX - query(MAX, MAX);\n queries.push_back(lo);\n queries.push_back(hi);\n solve(lo, hi);\n sort(queries.begin(), queries.end());\n queries.resize(unique(queries.begin(), queries.end()) - queries.begin());\n resolve(queries);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "10eee220374c22b81fcb17151dc2bbca", "src_uid": "583cd1e553133b297f99fd52e5ad355b", "difficulty": 3000.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nconst int MAX = 100000000;\nmap, int> cache;\nmap, bool> is_cached;\nconst int MAXN = 100010;\nint x[MAXN], y[MAXN];\nint n, m;\nint my_impl(int x, int y){\n int mn = 3 * MAX;\n for(int i = 0; i < n; i++) mn = min(mn, abs(::x[i] - x));\n for(int i = 0; i < m; i++) mn = min(mn, abs(::y[i] - y));\n return mn;\n}\nint query(int x, int y){\n //return my_impl(x, y);\n if(is_cached[{x, y}]) return cache[{x, y}];\n printf(\"0 %d %d\\n\", x, y);\n fflush(stdout);\n int d;\n scanf(\"%d\", &d);\n is_cached[{x, y}] = true;\n if(d == -1) exit(0);\n cache[{x, y}] = d;\n return d;\n}\nvector queries;\nint mydiv(int a){\n if(a >= 0) return a / 2;\n return (a - 1) / 2;\n}\nvoid solve(int lo, int hi){\n //printf(\"%d %d\\n\", lo, hi);\n //printf(\"Solving %d ---- %d\\n\", lo, hi);\n int md = mydiv(lo + hi);\n int q = query(md, md);\n //printf(\"Queried %d and got %d\\n\", md, q);\n if(q == (md - lo)){\n if(md + q < hi){\n int p = query(md + q, md + q);\n if(p == 0) {\n //printf(\"Inserting %d\\n\", md + q);\n queries.push_back(md + q);\n }\n }\n return;\n }\n int pos1 = md - q;\n int p = query(pos1, pos1);\n int found = pos1;\n if(p) found = md + q;\n printf(\"Inserting %d\\n\", found);\n queries.push_back(found);\n solve(lo, found);\n solve(found, hi);\n}\nint find_none(vector a){\n if(a[0] != -MAX) return -MAX;\n int i = 1;\n for(; i < a.size(); i++){\n if(a[i] != a[i - 1] + 1) break;\n }\n return a[i - 1] + 1;\n}\nvector vertical, horizontal;\nvoid resolve(vector pts){\n int none = find_none(pts);\n for(auto p : pts){\n int q1 = query(none, p);\n if(q1 == 0) horizontal.push_back(p);\n int q2 = query(p, none);\n if(q2 == 0) vertical.push_back(p);\n }\n printf(\"1 %d %d\\n\", vertical.size(), horizontal.size());\n for(auto x : vertical) printf(\"%d \", x); printf(\"\\n\");\n for(auto y : horizontal) printf(\"%d \", y); printf(\"\\n\");\n}\nvoid problem(){\n int lo = query(-MAX, -MAX) - MAX;\n int hi = MAX - query(MAX, MAX);\n queries.push_back(lo);\n queries.push_back(hi);\n solve(lo, hi);\n sort(queries.begin(), queries.end());\n queries.resize(unique(queries.begin(), queries.end()) - queries.begin());\n resolve(queries);\n}\nint main(){\n //scanf(\"%d %d\", &n, &m);\n //for(int i = 0; i < n; i++) scanf(\"%d\", &x[i]);\n //for(int i = 0; i < m; i++) scanf(\"%d\", &y[i]);\n problem();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b1f726a37fb2910ab1b10a1d40c7dc66", "src_uid": "583cd1e553133b297f99fd52e5ad355b", "difficulty": 3000.0} {"lang": "GNU C++0x", "source_code": "#include \n\nusing namespace std;\n\nint main() {\n\n long long cnt1, cnt2, x, y;\n\n cin >> cnt1 >> cnt2 >> x >> y;\n long long both = 0;\n\n for (long long i = 1;; ++i) {\n if (i % x != 0 && i % y != 0) {\n ++both;\n }\n if (i % x != 0 && i % y == 0) {\n --cnt1;\n } else if (i % x == 0 && i % y != 0) {\n --cnt2;\n }\n\n if (cnt1 - both <= 0) {\n long long next = both - cnt1;\n if (cnt2 - next <= 0) {\n cout << i << \"\\n\";\n return 0;\n }\n }\n\n }\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c565894f424e3cc62499bd35b13b41e6", "src_uid": "ff3c39b759a049580a6e96c66c904fdc", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include \n#include\nusing namespace std;\n\nint main() \n{\n long long a,b,c,T1,T2,p,q,X,Y,flag=0,v=1,temp;\n cin>>T1>>T2>>X>>Y;\n while(flag==0)\n {\n a=v/X;\n b=v/Y;\n c=v/(X*Y);\n p=b-c;\n q=a-c;\n temp=v-c-(p+q);\n if(p>=T1)\n {\n if(q+temp>=T2)\n flag=1;\n }\n else if( flag!=1 && q>=T2)\n {\n if(p+temp>=T1)\n flag=1;\n \n }\n else\n {\n if(flag!=1 && p+temp>=T1)\n {\n temp=temp-(T1-p);\n if(q+temp>=T2)\n flag=1;\n }\n if(flag!=1 && q+temp>=T2)\n {\n temp=temp-(T2-q);\n if(p+temp>=T1)\n flag=1;\n }\n \n }\n v++;\n }\n if(flag==1)\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ulng;\ntypedef unsigned int uint;\ntypedef unsigned char uchar;\ntypedef long double ld;\ntypedef pair PII;\ntypedef pair PIII;\ntypedef pair PLL;\ntypedef pair PLI;\ntypedef pair PDD;\n#define mp make_pair\n#define pb push_back\n#define sz(x) ((int)(x).size())\n#define all(x) (x).begin(), (x).end()\n#define clr(ar,val) memset(ar, val, sizeof(ar))\n#define istr stringstream\n#define forn(i,n) for(int i=0;i<(n);++i)\n#define forv(i,v) forn(i,sz(v))\nconst double EPS = 1e-6;\nconst int INF = 1000*1000*1000;\nconst long double INFf = 1000000000000.00000000;\nconst char CINF = 102;\nconst ll LINF = INF * 1ll * INF;\nconst ld PI = 3.1415926535897932384626433832795;\nll gcd(ll a,ll b){return a?gcd(b%a,a):b;}\n\nconst int nmax = 1010;\nconst int mod = 1000000007;\nint cnt1,cnt2,x,y;\nbool check(int mid){\nint z = mid/x,zz = mid/y,zzz=mid/(x*y);\n\nif((mid-z)>=cnt1 && (mid-zz)>=cnt2 && (mid-zzz)>=(cnt1+cnt2))return true;\nreturn false;\n}\nvoid bsearch(){\nint a,b,mid;\na = 1;\nb = 1000000000;\nwhile(a < b -1){\nmid = (a+b)>>1;\n\nif(check(mid))\nb = mid;\n else\na = mid;\n}\nif(check(a)){cout << a << endl;}\nelse cout << b << endl;\n}\nint main()\n{\ncin >> cnt1 >> cnt2 >> x >> y;\nbsearch();\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3e5bb0635cdc01832939de440847aca0", "src_uid": "ff3c39b759a049580a6e96c66c904fdc", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include \n#include\nusing namespace std;\n\nint main() \n{\n int a,b,c,T1,T2,p,q,X,Y,flag=0,v=1,temp;\n cin>>T1>>T2>>X>>Y;\n while(flag==0)\n {\n a=v/X;\n b=v/Y;\n c=v/(X*Y);\n p=b-c;\n q=a-c;\n temp=v-c-(p+q);\n if(p>=T1)\n {\n if(q+temp>=T2)\n flag=1;\n }\n else if( flag!=1 && q>=T2)\n {\n if(p+temp>=T1)\n flag=1;\n \n }\n else\n {\n if(flag!=1 && p+temp>=T1)\n {\n temp=temp-(T1-p);\n if(q+temp>=T2)\n flag=1;\n }\n if(flag!=1 && q+temp>=T2)\n {\n temp=temp-(T2-q);\n if(p+temp>=T1)\n flag=1;\n }\n \n }\n v++;\n }\n if(flag==1)\n cout<\n#define all(x) (x).begin(), (x).end()\n#define ll long long\nusing namespace std;\nint main()\n{\n\tios::sync_with_stdio(0);\n\tcin.tie(0);\n\tint n;\n\tcin >> n;\n\tvector arr(n);\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tcin >> arr[i];\n\t}\n\tint q, tmp;\n\tcin >> q;\n\tunordered_multiset query;\n\tfor (int i = 0; i < q; i++)\n\t{\n\t\tcin >> tmp;\n\t\tquery.insert(tmp);\n\t}\n\tunsigned long long a = 0, b = 0;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tq = query.count(arr[i]);\n\t\ta += (i + 1) * q;\n\t\tb += (n - i) * q;\n\t}\n\tcout << a << \" \" << b;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b9d59c3b96bdb218efee027e37b2b86d", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include \n#define all(x) (x).begin(), (x).end()\n#define ll long long\nusing namespace std;\nint main()\n{\n\tios::sync_with_stdio(0);\n\tcin.tie(0);\n\tint n;\n\tcin >> n;\n\tvector arr(n);\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tcin >> arr[i];\n\t}\n\tint q, tmp;\n\tcin >> q;\n\tunordered_multiset query;\n\tfor (int i = 0; i < q; i++)\n\t{\n\t\tcin >> tmp;\n\t\tquery.insert(tmp);\n\t}\n\tunsigned long long a = 0, b = 0;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tq = query.count(arr[i]);\n\t\ta += (i + 1) * q;\n\t\tb += (n - i) * q;\n\t}\n\tprintf(\"%d %d\", a, b);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c1accad206cb37163be6e81b843d7167", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \nusing namespace std;\n\n#define debug(a) cout<<\"#a = \"<>n;\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tcin>>x;\n\t\tSum+=x;\n\t}\n\tif(n<=4){\n\t\tstring s=\"\";\n\t\tint dem=0;\n\t\tint t=100;\n\n\t\twhile(t--){\n\t\t\ts+=\"x\";\n\t\t\tfor(int i=1;i<=n;i++)\n\t\t\t\t{\n\t\t\t\t\ts+=\"o\"; t--;\n\t\t\t\t}\n\t\t}\n\t\tfor(int i=Sum;i<=Sum+4;i++)\n\t\t{\n\t\t\tif(s[i]=='o') dem++;\n\t\t}\n\t\tcout<\n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n\tint n;\n\tcin >> n;\n\tint a[100], sum = 0;\n\tfor (int i = 1; i <= n; i++)\n\t{\n\t\tcin >> a[i];\n\t\tsum += a[i];\n\t}\n\tint q = 0;\n\tfor (int j = 1; j <= 5; j++)\n\t\tif ((sum + j - 1) % (n + 1) != 0)\n\t\t\tq++;\n\tcout << q;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0934e4588083ff203510eed972ed768a", "src_uid": "ff6b3fd358c758324c19a26283ab96a4", "difficulty": 1000.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\nusing namespace std;\n\n#define vi vector\n#define pb push_back\n#define forn(i,a,b) for(int i = (int)a; i < (int)b; i++)\n#define forn1(i,a,b) for(int i = (int)a; i >= (int)b; i--)\n#define sz(a) (int)a.size()\n#define pii pair\n#define vpii vector< pair >\n\nint n;\nint ff[1000002];\nint xx[10];\n\nint f ( int x )\n{\n if ( x == 0 ) return 0;\n else x = x%9;\n if ( x == 0 ) return 9;\n return x;\n}\n\nint main()\n{\n long long cnt = 0,res = 0;\n cin >> n;\n forn(i,0,1000001) ff[i] = f(i);\n forn(j,1,10)\n {\n if ( n >= j ) xx[j] = ( n - j )/9 + 1;\n else xx[j] = 0;\n }\n //forn(j,1,10) cout << xx[j] <<\" \";\n //cout << endl;\n forn(i,1,n+1)\n {\n cnt = 0;\n forn(j,1,10)\n {\n int d = ff[ff[i]*ff[j]];\n cnt += xx[d];\n }\n cnt *= (n/9);\n forn(j,1,n%9+1)\n {\n int d = ff[i*j];\n cnt += xx[d];\n }\n cnt -= n/i;\n // cout << cnt << endl;\n res += cnt;\n }\n cout << res;\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e92f14d3a8cac8341b2fbdef5468e51e", "src_uid": "fc133fe6353089a0ebee08dec919f608", "difficulty": 2000.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nlong d(long x)\n{\n\tlong sum=0;\n\twhile(x>0)\n\t{\n\t\tsum+=x%10;\n\t\tx/=10;\n\t}\n\tif (sum<=9) return sum;\n\treturn d(sum);\n}\n\nlong D[1000001]={0};\nvector < vector > v(10,vector ());\n\nint main()\n{\n\tfreopen(\"input.txt\",\"r\",stdin);\n\tfreopen(\"output.txt\",\"w\",stdout);\n\tlong n,ans=0;\n\tscanf(\"%d\",&n);\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tD[i]=d(i);\n\t\tv[D[i]].push_back(i);\n\t}\n\t/*for(int i=1;i<=9;i++)\n\t{\n\t\tfor(int j=0;jn)) break;\n\t\t\t\t\t\t\tif (v[i][M]*v[j][r]<=n) l=M+1;\n\t\t\t\t\t\t\telse r=M-1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tlong M=(l+R)/2;\n\t\t\t\t\t\tif (v[i][M]*v[j][r]<=n&&(M==v[i].size()-1||v[i][M]*v[j][r]>n)) f-=(M+1);\n\t\t\t\t\t\t*///if (v[i].size()>0) f-=(n/v[j][r])/t;\n\t\t\t\t\t\tvector ::iterator low=v[t].begin()/*lower_bound(v[i].begin(),v[i].end(),v[i][0])*/,up=upper_bound(v[t].begin(),v[t].end(),n/v[j][r]);\n\t\t\t\t\t\tf-=long long(up-low);\n\t\t\t\t\t}\n//\t\t\t\t}\n\t\t\t//\tif (i==1&&j==1)\n\t\t\t}\n\t\t}\n//\t\tf*=n-v[i].size();\n\t\tans1+=f;\n//\t}\n\tprintf(\"%I64d\\n\",ans1);\n/*\tfor(int i=1;i<=n;i++)\n\t\tfor(int j=1;j<=n;j++)\n\t\t\tif (d(d(i)*d(j))==1)\n\t\t\t\t\tprintf(\"%d\t%d\\n\",i,j);*/\n/*\tlong last=0;\n//\tfor(n=1;n<=100;n++)\n//\t{\n\tans=0;\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tfor(int j=1;j<=n;j++)\n\t\t{\n\t\t\tfor(int t=1;t<=n;t++)\n\t\t\t{\n\t\t\t\tif (i*j==t) continue;\n\t\t\t\tif (d(d(i)*d(j))==d(t))\n\t\t\t\t{\n\t\t\t\t\tans++;\n//\t\t\t\t\tif (i==n||j==n||t==n)\n//\t\t\t\t\t\tprintf(\"%d\t%d\t%d\\n\",i,j,t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\t%d\\n\",n,ans);\n\tlast=ans;\n//\t}\n*/\t/*for(int i=1;i<=sqrt((double)n);i++)\n\t{\n\t\tif (n%i==0)\n\t\t\tif (d(n)!=d(d(i)*d(n/i))) ans++;\n\t}*/\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bf5eb7ae1b311b429b5d1e5fdc11ffd9", "src_uid": "fc133fe6353089a0ebee08dec919f608", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \n\nint n;\nint a[20];\n__int64 ans,s;\n\nint main()\n{\n scanf(\"%d\",&n);\n ans=0;\n for(int i=1;i<=n;i++)\n a[i]=0;\n for(int i=1;i<=n;i++)\n a[i%9]++;\n for(int i=0;i<9;i++)\n for(int j=0;j<9;j++)\n ans+=a[i]*a[j]*a[i*j%9];\n s=0;\n for(int i=1;i<=n;i++)\n for(int j=i;j<=n;j+=i)\n s++;\n printf(\"%I64d\\n\",ans-s);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7386792f2fe43be7577482f09248a7e8", "src_uid": "fc133fe6353089a0ebee08dec919f608", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint a[100000005]; \nint main()\n{ long long n,x,y=0,s=0,i,j;\n cin>>n;\n x=int(sqrt(n));\n for(i=1;i<=x;i++)\n s=s-n/i*2; \n s=s+x*x;\n for(i=1;i<=n%9;i++) a[i]++;\n for(i=0;i<=8;i++) a[i]=a[i]+n/9;\n\t for(i=0;i<=8;i++) \n\t for(j=0;j<=8;j++)\n\t s=s+a[i]*a[j]*a[i*j%9];\n\t cout<\n#define pi 3,141592653589793238462643\nusing namespace std;\nint btd(int n){\n\t int decimalNumber = 0, i = 0, remainder;\n while (n!=0)\n {\n remainder = n%10;\n n /= 10;\n decimalNumber += remainder*pow(2,i);\n ++i;\n }\n return decimalNumber;\n\t}\nstring dtb(int n){\n\tstring x=\"\";\n\t\n\t\n\twhile(n){\n\t\tif(n%2==1)\n\t\tx.push_back('1');\n\t\telse if(n%2==0)\n\t\tx.push_back('0');\n\t\tn/=2;\n\t}\n\treverse(x.begin(),x.end());\n\treturn x;\n}\nstring tos(int n){\n\tstring x;\n\twhile(n){\n\tx+=(n%10);\n\tn/=10;\n\t}\nreturn x;\n}\nint main(){\n\tios_base::sync_with_stdio(false);\n\tcin.tie(0);\n long long a,b;\n cin >> a >> b;\n int q =btd(a) ^ btd(b);\n string j = tos(a);\n\tstring p = dtb(q), ans;\n\tint sz = j.size() - p.size();\n\twhile(ans.length()\n#include \nusing namespace std;\nint main(int argc, const char * argv[]) {\n// char a[105],b[105],c[105];\n string a,b,c;\n// cout<>a>>b;\n int l = a.length();\n for(int i=0;i\n#include \nusing namespace std;\nint main(int argc, const char * argv[]) {\n// char a[105],b[105],c[105];\n string a,b,c;\n// cout<>a>>b;\n int l = a.length();\n for(int i=0;i\nusing namespace std;\n#define mod 1e9+7\n#define endl '\\n'\n#define pb push_back\n#define r(i,n) for(ll i=0;i>= 1);\n reverse(s.begin(), s.end());\n return s;\n}\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n \n #ifndef ONLINE_JUDGE\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n #endif\n\n ll t=1;\n // cin>>t;\n while(t--){\n string s1,s2;\n cin>>s1>>s2;\n ll a=bitset<64>(s1).to_ullong(),b=bitset<64>(s2).to_ullong();\n a=a^b;\n string bin=binary(a);\n string s(s1.size()-bin.size(),'0');\n bin=s+bin;\n cout<\n#include\nusing namespace std;\nmain(){\n int n,c=0;\n cin>>n;\n string s;\n cin>>s;\n for(int i=n/2;i>1;i--)\n for(int j=0;j+2*i-1\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define ll long long\n#define ull unsigned long long\ntypedef pairP;\nstatic const ll INF=1e10;\nstatic const ll len=2e3+5;\nint main()\n{\n\tll n;\n\twhile(cin>>n)\n\t{\n\t\tstring str;\n\t\tcin>>str;\n\t\tll maxm=1;\n\t\tfor(ll i=0;i=i-j+1;k--)\n\t\t\t\t{\n\t\t\t\t\ts1+=str[k];\n\t\t\t\t}\n\t\t\t\tfor(ll k=i-j;k>=i-j-j+1;k--)\n\t\t\t\t{\n\t\t\t\t\ts2+=str[k];\n\t\t\t\t}\n\t\t\t\tll x=s1.size();\n\t\t\t\tif(s1==s2)maxm=max(x,maxm);\n\t\t\t}\n\t\t}\n\t\tcout<\nusing namespace std;\nint main(){\n int m;\n string s;\n int num;\n while(scanf(\"%s\",s)){\n scanf(\"%s\",s);\n for(int i=1;i<=m;i++){\n if(s.substr(0,i)==s.substr(i,i)){num+i+1+m-i*2;}\n }\n printf(\"%d\\n\",num);\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2e9dea9d52ea30bcde703340e48048e1", "src_uid": "ed8725e4717c82fa7cfa56178057bca3", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\n\nint main()\n{\n\tstring x;\n\tint in;\n\tstring tmp;\n\tstring tmp1;\n\tcin>>in>>x;\n\tint on=in;\n\tchar tmpa=x[0];\n\tbool u=false;\n\ton=on/2;\n\twhile(u==false)\n\t{\n\t\tif(tmpa==x[on])\n\t\t{\n\t\t\tfor(int b=0;b0)\n\t{\n\t\tin=in-on+1;\n\t}\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint f(int n) {\n\tif (n == 1) return -1;\n\telse if (n % 2 == 0) return f(n - 1) + n;\n\telse return f(n - 1) - n;\n}\n\nint main(){\n\tint n;\n\tcin >> n;\n\tcout << f(n);\n\t//system(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b4501e71181c87c608d60a2ecefea3d6", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#include\"vector\"\nusing namespace std;\n \nint main()\n{\n\tint n;\n\tcin >> n;\n\tlong sum = 0;\n\tlong number = 1;\n\tvectormas;\n\tfor (int i = 0; i\n#include\"vector\"\nusing namespace std;\n \nint main()\n{\n\tint n;\n\tcin >> n;\n\tlong sum = 0;\n\tlong number = 1;\n\tvectormas;\n\tfor (int i = 0; i().swap(mas);\n\t \n\tcout << sum;\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "09b97221fbc80ee91b3114cf5c824dc2", "src_uid": "689e7876048ee4eb7479e838c981f068", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "//#include \n#include \n#include\nusing namespace std;\n\nint main()\n{\n long long M=0,n;\n cin>>n;\n M=-1*pow((n+1)/2,2)+pow(n/2,2)+(n/2);\n cout<\nusing namespace std;\n\nint main()\n{\n\t\n\tint n;\n\tchar arr[n],c;\n\t//int brr[n] = {0};\n\tcin >>n;\n\tfor(int i=0;i< n;i++)\n\t{\n\t\tcin >>c;\n\t\tarr[i] = tolower(c);\n\t}\n\tcout <\nusing namespace std;\n\nint n;\nint len;\nchar s[500];\n \nbool isvowel(char c)\n{\n return (c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y');\n}\n \nvoid fixstr(char *s)\n{\n n = strlen(s);\n int cnt = 0;\n int pos = -1;\n for (int i = 0; cnt != 2 && i < n; ++i) {\n if (isvowel(s[i])) {\n cnt = 1;\n for (int j = i+1; isvowel(s[j]) && j < n; ++j) {\n cnt++;\n pos=j;\n }\n }\n }\n \n if (cnt >= 2) {\n for (int i = 0; i < n-1; ++i) {\n if (i < pos) s[i] = s[i];\n else {\n s[i] = s[i+1];\n }\n }\n fixstr(s);\n len--;\n }\n} \n \nint main()\n{\n ios::sync_with_stdio(false);\n #ifdef LOCAL_DEBUG\n freopen(\"in.txt\",\"r\",stdin);\n #endif\n \n cin >> n >> s;\n len = n;\n fixstr(s);\n for (int i = 0; i < len; ++i) {\n cout << s[i];\n }\n cout << endl;\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "375f213d3e1f529b1aac3d84d2c67a2c", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n\t\n\tint n;\n\tchar arr[n],c;\n\tint brr[n] = {0};\n\tcin >>n;\n\tfor(int i=0;i< n;i++)\n\t{\n\t\tcin >>c;\n\t\tarr[i] = tolower(c);\n\t\tif(arr[i] =='a'||arr[i] =='o'||arr[i] =='e'||arr[i] =='i'||arr[i] =='u'||arr[i] =='y')\n\t\t{\n\t\t\tbrr[i] = brr[i-1]+1;\n\t\t}\n\t}\n\tcout <\n#include \n#include \n\nusing namespace std;\nint main()\n{\nint n,i,w,first;\nstring s;\nchar c,c1;\ncin >> n >> s;\nwhile (((n>100) or (n<1)) or (s.length()!=n))\n{\n\ncin >> n >> s;\n\n}\n\n\nstring ch=\"aeiouy\";\n\nfor (i=1; i < s.length() ; i++)\n{\n\tc=s[i];\n\tif (ch.find(c)!=-1)\n\t\t{\n\t\t\tc1=s[i-1];\n\t\t\tif (ch.find(c1)!=-1)\n\t\t\t{\n\n\t\t\t\ts.erase(i,1);\n\t\t\t\ti-=1;\n\t\t\t}\n\t\t} \n}\ncout << s;\nreturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b5786b02e0cbab14ff959093a17c1cca", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n \ntypedef long long ll;\ntypedef pair pll;\n\nconst ll maxn = 7;\nset g[maxn];\nll n, m;\n\nvoid add_edge(ll a, ll b) {\n g[a].insert(b);\n g[b].insert(a);\n}\nvoid soak() {\n cin >> n >> m;\n for(ll i = 0; i < n; i++) g[i].clear();\n for(ll i = 0; i < m; i++) {\n ll a, b;\n cin >> a >> b;\n add_edge(a - 1, b - 1);\n }\n}\n\nll condenc(ll a, ll b) {\n ll cnt = 0;\n for(auto i: g[a]) {\n if(g[b].count(i)) {\n cnt++;\n }\n }\n return cnt;\n}\nll func() {\n ll answ = 0;\n for(ll i = 0; i < 7; i++) {\n for(ll j = i + 1; j < 7; j++) {\n ll temp = condenc(i, j);\n answ = max(answ, m - temp);\n }\n }\n return answ;\n}\n\nint main() {\n ios_base::sync_with_stdio(false);\n ll test = 5;\n while(test--) {\n soak();\n if(n < 7) cout << m;\n else cout << func();\n cout << endl;\n }\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "612d166382e38c323278761a5c054c47", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std;\nusing namespace __gnu_pbds;\n\n#define TRACE(x) x\n#define WATCH(x) TRACE(cout << #x\" = \" << x << endl)\n#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << \" \"; cout << endl)\n#define WATCHC(V) TRACE({cout << #V\" = \"; WATCHR(V.begin(), V.end());})\n\n#define all(x) (x).begin(), (x).end()\n\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vll;\ntypedef vector vvll;\ntypedef vector vb;\ntypedef vector vs;\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(0), cout.tie(0);\n cout << fixed << setprecision(15);\n\n int n, m, u, v;\n cin >> n >> m;\n int ans = 0;\n vi c(7);\n map, int> mp;\n for (int i = 0; i < m; i++){\n cin >> u >> v;\n if (u > v){\n swap(u, v);\n }\n if (u != 7 && v != 7 && !mp.count({u, v})){\n // Place that domino\n ans++;\n mp[{u, v}] = 1;\n }\n if (v == 7){\n // 7 is a wildcard node\n c[u] = 1;\n }\n }\n int d_c, d_mx = 0;\n for (int i = 1; i <= 6; i++){\n // Set wildcard to i\n d_c = 0;\n for (int j = 1; j <= 6; j++){\n if (mp.count({i, j}) || !c[u]){\n // Seen that domino, or not an edge\n continue;\n }\n int tmpi = i, tmpj = j;\n if (i > j){\n swap(tmpi, tmpj);\n }\n if (!mp.count({tmpi, tmpj})){\n d_c++;\n }\n }\n d_mx = max(d_mx, d_c);\n }\n cout << ans + d_mx << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c9f3c49cb1f0a223ff3822816712d54d", "src_uid": "11e6559cfb71b8f6ca88242094b17a2b", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include \n#define lli long long int\nusing namespace std;\n#define mod 1000000007\n#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n\nvectorv;\n\nvoid swap(char* s,int a,int b)\n{\n char t=s[a];\n s[a]=s[b];\n s[b]=t;\n}\n\nvoid perm(string s,int l,int r)\n{\n if(l==r)\n v.push_back(s);\n for(int i=l;i<=r;i++)\n {\n swap(&s[0],l,i);\n perm(s,l+1,r);\n swap(&s[0],l,i);\n }\n}\n\nint main()\n{\n fast;\n int n,m;\n cin >> n >> m;\n string s=\"\";\n for(int i=1;i<=n;i++)\n s+=to_string(i);\n perm(s,0,n-1);\n vector >v1;\n for(int i=0;i> x >>y;\n v1.push_back(make_pair(x-1,y-1));\n }\n int M=0;\n for(int i=0;i,int>m1;\n int temp=0;\n for(int j=0;j Huseyn Hajiyev\nLANG: C++\nTASK: target_mode_on\n*/\n#include \n#include \n#include \n#include \n#include \n#define ordered_set tree,rb_tree_tag,tree_order_statistics_node_update>\n//#pragma comment(linker, \"/stack:200000000\")\n//#pragma GCC optimize(\"Ofast\")\n//#pragma GCC optimize (\"unroll-loops\")\n//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n//#define _CRT_SECURE_NO_WARNINGS\n//#include \n//using boost::multiprecision::cpp_int;\n#define FAST_READ ios_base::sync_with_stdio(0);\n#define in freopen(\"input.txt\", \"r\", stdin);\n#define out freopen(\"output.txt\", \"w\", stdout);\n#define ll long long\n#define debt(x,y)cout<<\"#x = \"<<(x)<<\" and \"<<\"#y = \"<<(y)<\n Debugger& operator,(const ObjectType& v)\n {\n if(!first)cerr<\ninline ostream& operator<<(std::ostream& os, const std::pair& p)\n{\n return os<<\"(\"<\ninline ostream &operator<<(ostream & os,const vector& v)\n{\n bool first=true;\n os<<\"[\";\n for(unsigned ll i=0;i\ninline ostream &operator<<(ostream & os,const set&v)\n{\n bool first=true;\n os<<\"[\";\n for(typename set::const_iterator ii=v.begin();ii!=v.end();++ii)\n {\n if(!first)os<<\", \";\n os<<*ii;\n first=false;\n }\n return os<<\"]\";\n}\ntemplate\ninline ostream &operator<<(ostream & os,const map&v)\n{\n bool first=true;\n os<<\"[\";\n for(typename map::const_iterator ii=v.begin(); ii!=v.end();++ii)\n {\n if(!first)os<<\", \";\n os<<*ii;\n first=false;\n }\n return os<<\"]\";\n}\n\nll n,m;\nvectoradj[10];\nll used[10];\nll usedd[10];\nll cnt[10][10];\nll ans=0;\n\nvoid dfs(ll v,ll c,ll prevv)\n{\n used[v]=c;\n for(auto to:adj[v])\n {\n\tif(to==prevv)continue;\n\tif(used[to]==0)\n\t{\n\t for(ll i=1;i<=6;i++)\n\t {\n\t\tif(usedd[i]==0)\n\t\t{\n\t\t ans++;\n\t\t usedd[i]=1;\n\t\t cnt[min(c,i)][max(c,i)]++;\n\t\t dfs(to,i,v);\n\t\t break;\t\n\t } \n\t }\n\t}\n\telse\n\t{\n\t if(cnt[min(used[v],used[to])][max(used[v],used[to])]==0)\n\t {\n\t\tcnt[min(used[v],used[to])][max(used[v],used[to])]=1;\n\t\tans++; \n\t }\t\n }\n }\n}\n\nint main(){\nFAST_READ;\ncin>>n>>m;\nfor(ll i=1;i<=m;i++)\n{\n ll x,y;\n cin>>x>>y;\n adj[x].pb(y);\n adj[y].pb(x);\n}\nll maxx=0;\nif(n<=6)cout<\nusing namespace std;\n\nlong long x, y, l, r;\nvector all;\n\nint main() {\n scanf(\"%lld %lld %lld %lld\", &x, &y, &l, &r);\n long long xx = 1;\n bool okl = false;\n bool okr = false;\n for (int i = 0; i < 555; i++) {\n long long yy = 1;\n if (xx > r) break;\n for (int j = 0; j < 555; j++) {\n if (xx + yy == l) okl = true;\n if (xx + yy == r) okr = true;\n if (xx + yy > r) break;\n if (xx + yy >= l && xx + yy <= r) all.push_back(xx + yy);\n yy *= y;\n }\n if (xx > r) break;\n xx *= x;\n }\n sort(all.begin(), all.end());\n for (auto it : all) cerr << it << \" \";\n cerr << endl;\n long long ans = 0;\n long long prv = l;\n for (int i = 0; i < (int) all.size(); i++) {\n ans = max(ans, all[i] - prv - okl);\n okl = true;\n prv = all[i];\n }\n ans = max(ans, r - prv - okr);\n if (all.empty()) {\n ans = max(ans, r - l + 1 - okl - okr);\n }\n printf(\"%lld\\n\", ans);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "58b558f96715c8abf2357c4ee5266acf", "src_uid": "68ca8a8730db27ac2230f9fe9b120f5f", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#define ll long long\n\nusing namespace std;\n\nint main(){\n ll x,y,l,r;\n cin >> x >> y >> l >> r;\n\n ll p = 1;\n ll first[66],second[66];\n int n =0,m=0;\n while(p < r){\n first[n] = p;\n p *= x;\n n++;\n }\n p=1;\n while(p < r){\n second[m] = p;\n p*=y;\n m++;\n }\n\n ll merge[4356];\n int k = 0;\n for(int i=0;i < n; ++ i){\n for(int j=0;j < m;++j){\n if(first[i] + second[j] >= l && first[i] + second[j] <= r){\n merge[k] = first[i] + second[j];\n k++;\n }\n }\n }\n merge[k] = l-1;\n k++;\n merge[k] = r+1;\n k++;\n sort(merge,merge + k);\n\n ll ans =0 ;\n for(int i=0;i\n\n#define FILE_NAME \"\"\n \n#define all(x) x.begin(), x.end()\n\n#define sc second\n#define fr first\n\n#define pb push_back \n#define mp make_pair\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair pii;\n\nconst ll INF = 1e12 + 1;\nconst int MOD = 1e9 + 7; \n \nconst int dx[] = {+1, -1, 0, 0};\nconst int dy[] = {0, 0, +1, -1};\n\nll binpow(ll a, ll b) {\n ll res = 1ll;\n while (b) {\n if (b & 1ll) {\n b--;\n res *= a;\n }\n a *= a;\n b >>= 1;\n }\n return res;\n}\n\nint main() {\n#ifdef LOCAL \n freopen(FILE_NAME\".in\", \"r\", stdin);\n freopen(FILE_NAME\".out\", \"w\", stdout); \n#endif \n ios_base :: sync_with_stdio(false);\n cin.tie(NULL);\n ll x, y, l, r;\n cin >> x >> y >> l >> r;\n ll last = 1;\n vector p;\n ll a = 0, b = 0;\n while (true) {\n ll next = last * x;\n if (next / x != last) \n break;\n a++;\n last = next;\n cerr << 1;\n }\n last = 1;\n while (true) {\n ll next = last * y;\n if (next / y != last) \n break;\n b++;\n last = next;\n }\n for (int i = 0; i <= a; i++) { \n ll fr = binpow(x, i);\n for (int j = 0; j <= b; j++) {\n ll sc = binpow(y, j);\n if (1e18 - fr < sc)\n continue;\n if (fr + sc >= l && fr + sc <= r) \n p.pb(fr + sc);\n }\n }\n sort(all(p));\n ll mx = 0;\n if (p.size() == 0)\n cout << r - l + 1, exit(0);\n for (int i = 0; i < p.size() - 1; i++) \n mx = max(mx, p[i + 1] - p[i] - 1);\n mx = max(mx, r - p[p.size() - 1]);\n mx = max(mx, p[0] - l);\n cout << mx;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "00a4123ae7ad337b8dad52c6b6a60993", "src_uid": "68ca8a8730db27ac2230f9fe9b120f5f", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include \n\n#define FILE_NAME \"\"\n \n#define all(x) x.begin(), x.end()\n\n#define sc second\n#define fr first\n\n#define pb push_back \n#define mp make_pair\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair pii;\n\nconst ll INF = 1e12 + 1;\nconst int MOD = 1e9 + 7; \n \nconst int dx[] = {+1, -1, 0, 0};\nconst int dy[] = {0, 0, +1, -1};\n\nll binpow(ll a, ll b) {\n ll res = 1ll;\n while (b) {\n if (b & 1ll) {\n b--;\n res *= a;\n }\n a *= a;\n b >>= 1;\n }\n return res;\n}\n\nint main() {\n#ifdef LOCAL \n freopen(FILE_NAME\".in\", \"r\", stdin);\n freopen(FILE_NAME\".out\", \"w\", stdout); \n#endif \n ios_base :: sync_with_stdio(false);\n cin.tie(NULL);\n ll x, y, l, r;\n cin >> x >> y >> l >> r;\n ll last = 1;\n vector p;\n ll a = 0, b = 0;\n while (true) {\n ll next = last * x;\n if (next / x != last) \n break;\n a++;\n last = next;\n cerr << 1;\n }\n last = 1;\n while (true) {\n ll next = last * y;\n if (next / y != last) \n break;\n b++;\n last = next;\n }\n for (int i = 0; i <= a; i++) { \n ll fr = binpow(x, i);\n for (int j = 0; j <= b; j++) {\n ll sc = binpow(y, j);\n if (1e18 - fr < sc)\n continue;\n if (fr + sc >= l && fr + sc <= r) \n p.pb(fr + sc);\n }\n }\n sort(all(p));\n ll mx = 0;\n if (p.size() == 0)\n cout << r - l + 1, exit(0);\n for (int i = 0; i < p.size() - 1; i++) \n mx = max(mx, p[i + 1] - p[i] - 1);\n mx = max(mx, r - p[p.size() - 1]);\n mx = max(mx, p[0] - l);\n cout << mx;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bae61cf00551638f02d6fdc452100319", "src_uid": "68ca8a8730db27ac2230f9fe9b120f5f", "difficulty": 1800.0} {"lang": "GNU C++17", "source_code": "/*\n||-----------------------------------||\n|| Rahat Khan Pathan ||\n|| BGC Trust University ||\n|| Department of CSE ||\n||-----------------------------------||\n*/\n#include\n#define ll long long int\n#define ull unsigned long long int\n#define pub push_back\n#define pi 3.14159265359\n#define pob pop_back\n#define puf push_front\n#define pof pop_front\n#define vi vector\n#define vll vector\n#define All(X) (X).begin(),(X).end()\n#define Reverse(X) reverse(All(X))\n#define Unique(X) (X).erase(unique((X).begin(),(X).end()),(X).end())\n#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define mp make_pair\n#define vpair vector>\n#define yes cout<<\"YES\"<>n;\n while(n>=0)\n {\n x=n%10;\n n/=10;\n if(x==0)\n cout<<\"O-|-OOOO\"<>t;\n// while(t--)\n solve();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "56d815f9485844077bea865d40bbed1b", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main() {\n\tint c, l, i, x, mod, j, left, check = 0;\n\tchar s[11];\n\tl = 0;\n\tleft = 0;\n\twhile((c = getchar()) != '\\n' && c != '\\0') {\n\t\ts[l++] = c - '0';\n\t}\n\tif (l > 0) {\n\t\tfor (i = 0; i < l; i++) {\n\t\t\tif (s[i] == 0) {\n\t\t\t\tleft++;\n\t\t\t} else {\n\t\t\t\tcheck = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (check == 0) {\n\t\t\tleft--;\n\t\t}\n\t}\n\tfor (i = l - 1; i >= left; i--) {\n\t\tx = s[i];\n\t\tif (x < 5) {\n\t\t\tprintf(\"O-|\");\n\t\t} else {\n\t\t\tprintf(\"-O|\");\n\t\t}\n\t\tmod = x % 5;\n\t\tfor (j = 0; j < mod; j++) {\n\t\t\tprintf(\"O\");\n\t\t}\n\t\tprintf(\"-\");\n\t\tfor (j = 0; j < 4 - mod; j++) {\n\t\t\tprintf(\"O\");\n\t\t}\n\t\tputchar('\\n');\n\t}\n\tgetch();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c1aeddeb7236e776b8233c6fbe76e087", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "/*\n _ _\n (c).-.(c) \n / ._. \\ \n __\\( Y )/__ \n (_.-/'-'\\-._)\n || || \n _.' `-' '._ \n (.-./`-'\\.-.)\n `-' `-'\n \n \n \u2584\u2580\u2580\u2584 \u2584\u2580\u2580\u2584 \u2584\u2580\u2580\u2588\u2580\u2584 \u2584\u2580\u2580\u2584 \u2584\u2580\u2580\u2584 \u2584\u2580\u2580\u2580\u2580\u2584 \u2584\u2580\u2580\u2584 \u2584\u2584 \u2584\u2580\u2580\u2584 \u2584\u2580\u2580\u2584 \u2584\u2580\u2580\u2588\u2584\u2584 \u2584\u2580\u2580\u2584 \u2584\u2584 \u2584\u2580\u2580\u2588\u2584 \u2584\u2580\u2580\u2584 \u2584\u2580\u2584 \n \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2590 \u2588 \u2588 \u2584\u2580 \u2588 \u2588 \u2588 \u2590 \u2584\u2580 \u2588 \u2588 \u2588 \u2584\u2580 \u2590 \u2584\u2580 \u2580\u2584 \u2588 \u2588 \u2580 \u2588 \n \u2590 \u2588 \u2588 \u2590 \u2588 \u2590 \u2590 \u2588 \u2588 \u2580\u2584 \u2590 \u2588\u2584\u2584\u2584\u2588 \u2590 \u2588 \u2588 \u2588\u2584\u2584\u2584\u2580 \u2590 \u2588\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2588 \u2590 \u2588 \u2588 \n \u2588 \u2584\u2580 \u2588 \u2588 \u2584\u2580 \u2580\u2584 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2584\u2580 \u2588 \u2588 \u2588 \n \u2580\u2584\u2580 \u2584\u2580\u2580\u2580\u2580\u2580\u2584 \u2580\u2584\u2580 \u2588\u2580\u2580\u2580 \u2584\u2580 \u2584\u2580 \u2580\u2584\u2584\u2584\u2584\u2580 \u2584\u2580\u2584\u2584\u2584\u2580 \u2584\u2580 \u2584\u2580 \u2588 \u2584\u2580 \u2584\u2580 \u2584\u2580 \n \u2588 \u2588 \u2590 \u2588 \u2588 \u2588 \u2590 \u2588 \u2588 \u2590 \u2590 \u2588 \u2588 \n \u2590 \u2590 \u2590 \u2590 \u2590 \u2590 \u2590 \u2590 \u2590 \n \n \n # #\n #=ooO=========Ooo=#\n # \\\\ (o o) // #\n --------(_)--------\n*/\n\n\n\n#include\nusing namespace std;\nint main(){\n ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n long long int n;\n cin>>n;\n vectors;\n s.push_back(\"O-|-OOOO\");\n s.push_back(\"O-|O-OOO\");\n s.push_back(\"O-|OO-OO\");\n s.push_back(\"O-|OOO-O\");\n s.push_back(\"O-|OOOO-\");\n s.push_back(\"-O|-OOOO\");\n s.push_back(\"-O|O-OOO\");\n s.push_back(\"-O|OO-OO\");\n s.push_back(\"-O|OOO-O\");\n s.push_back(\"-O|OOOO-\");\n while(n>=0){\n int r = n%10;\n cout<(`-').-> <-.(`-') (`-').->(`-') _ <-. (`-') \n _(OO )(_) _(OO ) ( OO)_ (OO )__ .-> __( OO) (OO )__ (OO ).-/ \\(OO )_ \n ,--.(_/,-.\\,-(`-'),--.(_/,-.\\ (_)--\\_),--. ,'-',--.(,--. '-'---.\\,--. ,'-'/ ,---. ,--./ ,-.)\n \\ \\ / (_/| ( OO)\\ \\ / (_/ / _ /| | | || | |(`-')| .-. (/| | | || \\ /`.\\ | `.' |\n \\ / / | | ) \\ / / (`-') \\_..`--.| `-' || | |(OO )| '-' `.) `-' |'-'|_.' || |'.'| |\n _ \\ /_|| |_/ _ \\ /_) <-.(OO ) .-._) \\ .-. || | | | \\| /`'. | .-. (| .-. || | | |\n \\-'\\ / | |'->\\-'\\ / ,------.) \\ / | | |\\ '-'(_ .'| '--' / | | || | | || | | |\n `-' `--' `-' `------' `-----'`--' `--' `-----' `------'`--' `--'`--' `--'`--' `--'\n*/", "lang_cluster": "C++", "compilation_error": false, "code_uid": "16768e198dddd0a54b1821242839628e", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include\nusing namespace std;\nint biaoshi(int n)\n{\n if(n==0)\n {\n cout<<\"O-|-OOOO\"<>n;\n a=n%10;\n b=(n/10)%10;\n c=n/100;\n biaoshi(a);\n if(c!=0)\n {\n biaoshi(b);\n biaoshi(c);\n }\n else\n {\n if(b!=0)\n {\n biaoshi(b);\n }\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "51b623638aaa79f97b322f910bedfaa1", "src_uid": "c2e3aced0bc76b6484360563355d23a7", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#define N 100005\n#define P 1000000007\n#define ll long long\nusing namespace std;\nstruct T\n{\n\tll x,l,r;\n}c[N],d[N];\nll n,m,k,a[4000005],tg[4000005],b[4000005],Tg[4000005];\nbool cmp(T x,T y)\n{\n\treturn x.x==y.x?x.l>y.l:x.x>1;\n\tif (tg[k])\n\t{\n\t\ta[k<<1]+=tg[k]*(mid-l+1);tg[k<<1]+=tg[k];\n\t\ta[k<<1|1]+=tg[k]*(r-mid);tg[k<<1|1]+=tg[k];\n\t\ttg[k]=0;\n\t}\n}\nvoid mdy(ll k,ll l,ll r,ll x,ll y,ll p)\n{\n\tif (x<=l&&r<=y)\n\t{\n\t\ta[k]+=p*(r-l+1);tg[k]+=p;return;\n\t}\n\tll mid=l+r>>1;dn(k,l,r);\n\tif (x<=mid) mdy(k<<1,l,mid,x,y,p);\n\tif (y>mid) mdy(k<<1|1,mid+1,r,x,y,p);\n\ta[k]=a[k<<1]+a[k<<1|1];\n}\nll sum(ll k,ll l,ll r,ll x)\n{\n\tif (r<=x) return a[k];\n\tll mid=l+r>>1,ans;dn(k,l,r);\n\tans=sum(k<<1,l,mid,x);\n\tif (x>mid) ans+=sum(k<<1|1,mid+1,r,x);\n\treturn ans;\n}\nll kth(ll k,ll l,ll r,ll x)\n{\n\tif (l==r) return l;\n\tll mid=l+r>>1;dn(k,l,r);\n\tif (a[k<<1]>=x) return kth(k<<1,l,mid,x);\n\treturn kth(k<<1|1,mid+1,r,x-a[k<<1]);\n}\n//-------------------------------------\nvoid down(ll k,ll l,ll r)\n{\n\tif (Tg[k])\n\t{\n\t\tTg[k<<1]=Tg[k<<1|1]=1;\n\t\tb[k<<1]=b[k<<1|1]=0;Tg[k]=0;\n\t}\n}\nvoid add(ll k,ll l,ll r,ll x,ll y)\n{\n\tb[k]=(b[k]+y)%P;\n\tif (l==r)return;\n\tll mid=l+r>>1;down(k,l,r);\n\tif (x<=mid) add(k<<1,l,mid,x,y);\n\telse add(k<<1|1,mid+1,r,x,y);\n}\nvoid gg(ll k,ll l,ll r,ll x,ll y)\n{\n\tif (x<=l&&r<=y){b[k]=0;Tg[k]=1;return;}\n\tll mid=l+r>>1;down(k,l,r);\n\tif (x<=mid) gg(k<<1,l,mid,x,y);\n\tif (y>mid) gg(k<<1|1,mid+1,r,x,y);\n\tb[k]=(b[k<<1]+b[k<<1|1])%P;\n}\nll qry(ll k,ll l,ll r,ll x,ll y)\n{\n\tif (x>y) return 0;\n\tif (x<=l&&r<=y) return b[k];\n\tll mid=l+r>>1,Ans=0;down(k,l,r);\n\tif (x<=mid) Ans+=qry(k<<1,l,mid,x,y);\n\tif (y>mid) Ans+=qry(k<<1|1,mid+1,r,x,y);\n\treturn Ans%P;\n}\n//-------------------------------------\nint main()\n{\n\tscanf(\"%lld%lld%lld\",&n,&m,&k);\n\tfor (ll i=1;i<=k;i++)\n\t{\n\t\tll x1,y1,x2,y2;\n\t\tscanf(\"%lld%lld%lld%lld\",&x1,&y1,&x2,&y2);\n\t\tc[i]=(T){x1,y1,y2};\n\t\td[i]=(T){x2,y1,y2};\n\t}\n\tsort(c+1,c+k+1,cmp);\n\tsort(d+1,d+k+1,cmp);\n\t\n\tll now=1,pre=1,rnow=1;\n\tfor (ll i=1;i<=n;i++)\n\t{\n\t\tif (i==2) add(1,1,m,1,1);\t\n\t\twhile (now<=k&&c[now].x==i)\n\t\t{\n\t\t\tll t=kth(1,0,m,sum(1,0,m,c[now].r+1))+1;\n\t\t\t//cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define mp make_pair\n#define pb push_back\n\n\ntypedef long long ll;\ntypedef long double ld;\n\nusing namespace std;\nconst int MAXN = 1000010;\nconst ll MOD = 1e9 + 7;\n\nset > ss;\n\nint ps[MAXN * 4];\nll sp[MAXN * 4];\nll rmq[MAXN * 4];\nint n, m;\nvector > op[MAXN];\nvector > cl[MAXN];\n\nvoid push(int v, int tl, int tr) {\n\tif (!ps[v])\n\t\treturn;\n\tps[v] = 0;\n\tps[v * 2 + 1] = 1;\n\tps[v * 2 + 2] = 1;\n\tsp[v * 2 + 1] = sp[v];\n\tsp[v * 2 + 2] = sp[v];\n\tint m = (tl + tr) >> 1;\n\trmq[v * 2 + 1] = ((m - tl) * sp[v]) % MOD;\n\trmq[v * 2 + 2] = ((tr - m) * sp[v]) % MOD;\n}\n\nvoid st(int v, int tl, int tr, int l, int r, ll x) {\n\tif (r <= tl || tr <= l)\n\t\treturn;\n\tif (l <= tl && tr <= r) {\n\t\tps[v] = 1;\n\t\tsp[v] = x;\n\t\trmq[v] = (x * (tr - tl)) % MOD;\n\t\treturn;\n\t}\n\tpush(v, tl, tr);\n\tint m = (tl + tr) >> 1;\n\tst(v * 2 + 1, tl, m, l, r, x);\n\tst(v * 2 + 2, m, tr, l, r, x);\n\trmq[v] = (rmq[v * 2 + 1] + rmq[v * 2 + 2]) % MOD;\n}\n\nll get(int v, int tl, int tr, int l, int r) {\n\tif (r <= tl || tr <= l)\n\t\treturn 0;\n\tif (l <= tl && tr <= r) {\n\t\treturn rmq[v];\n\t}\n\tpush(v, tl, tr);\n\tint m = (tl + tr) >> 1;\n\treturn (get(v * 2 + 1, tl, m, l, r) + get(v * 2 + 2, m, tr, l, r)) % MOD;\n}\n\n\n\nint main() {\n\tint k;\n\tscanf(\"%d%d%d\", &n, &m, &k);\n\tfor (int i = 0; i < k; ++i) {\n\t\tint x1, x2, y1, y2;\n\t\tscanf(\"%d%d%d%d\", &x1, &y1, &x2, &y2);\n\t\t--x1, --y1;\n\t\top[x1].push_back(make_pair(y1, y2));\n\t\tcl[x2].push_back(make_pair(y1, y2));\n\t}\n\tst(0, 0, m, 0, 1, 1);\n\tfor (auto j: op[0])\n\t\tss.insert(j);\n\tfor (int i = 1; i < n; ++i) {\n\t\tsort(op[i].begin(), op[i].end());\n\t\treverse(op[i].begin(), op[i].end());\n\t\tfor (auto j: op[i]) {\n\t\t\tauto it = ss.lower_bound(make_pair(j.second + 1, 0));\n\t\t\tint lb = 0;\n\t\t\tif (it != ss.begin()) {\n\t\t\t\t--it;\n\t\t\t\tlb = it->second;\n\t\t\t}\n\t\t\tll cc = get(0, 0, m, lb, j.second + 1);\n\t\t\tst(0, 0, m, j.second, j.second + 1, cc);\n\t\t}\n\t\tfor (auto j: cl[i])\n\t\t\tss.erase(j);\n\t\tfor (auto j: op[i]) {\n\t\t\tst(0, 0, m, j.first, j.second, 0);\n\t\t\tss.insert(j);\n\t\t}\n\t}\n\tfor (auto j: ss)\n\t\tst(0, 0, m, 0, j.second, 0);\n\tcout << get(0, 0, m, 0, m) << \"\\n\";\n\treturn 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4e4f1e81570e1656eb71848bd007265e", "src_uid": "294ee0db72d759792d797b6259a83406", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "%:pragma GCC optimize(2)\n%:pragma GCC optimize(3)\n#include \nusing namespace std;\n\n#define pb push_back\n#define pii pair \n#define sz(x) (int)x.size()\n\ntypedef long long ll;\nconst int N = 2000005;\nconst int mod = 1e9 + 7;\n\nvoid Add(int &a, int b) {\n a += b;\n if (a >= mod) a -= mod;\n}\n\ntemplate \nstruct Bit_tree {\n #define lowbit(x) ((x) & (-x))\n T a[N];\n int n;\n void init(int _n) {\n fill_n(a + 1, n = _n, 0);\n }\n void add(int x, T d) {\n for (; x <= n; x += lowbit(x))\n Add(a[x], d);\n }\n T sum(int x) {\n T r = 0;\n for (; x >= 1; x ^= lowbit(x))\n Add(r, a[x]);\n return r;\n }\n};\nBit_tree f;\n\nvector in[N], out[N];\nset inv;\nset pts;\n\nint n, m, k;\n\nint main() {\n scanf(\"%d%d%d\", &n, &m, &k);\n f.init(n);\n for (int i = 1; i <= k; i++) {\n int x1, y1, x2, y2;\n scanf(\"%d%d%d%d\", &x1, &y1, &x2, &y2);\n in[y1].push_back(make_pair(x1, x2));\n out[y2 + 1].push_back(make_pair(x1, x2));\n }\n \n m++; in[m].push_back(make_pair(1, n - 1));\n pts.insert(1);\n inv.insert(make_pair(0, 0));\n \n f.add(1, 1);\n for (int i = 1; i <= m; i++) {\n if (sz(in[i]) || sz(out[i])) {\n //printf(\"I am zz! %d\\n\", i);\n sort(in[i].begin(), in[i].end());\n reverse(in[i].begin(), in[i].end());\n sort(out[i].begin(), out[i].end());\n //printf(\"I am AK! %d\\n\", i);\n for (auto e: in[i]) {\n auto it = inv.upper_bound(make_pair(e.second + 1, n));\n it--;\n //printf(\"qwq?\");\n if (it->second <= e.second) {\n //printf(\"Oh, \");\n int s = (f.sum(e.second) - f.sum(it->second) + mod) % mod;\n //printf(\"I \");\n f.add(e.second + 1, i > 1 ? s : 0);\n //printf(\"AK \");\n pts.insert(e.second + 1);\n //printf(\"IOI\");\n }\n //printf(\"\\nqwq!\\n\");\n }\n //printf(\"I am fake! %d\\n\", i);\n for (auto e: in[i]) {\n auto it = pts.lower_bound(e.first);\n while (it != pts.end() && *it <= e.second) {\n int s = (f.sum(*it - 1) - f.sum(*it) + mod) % mod;\n f.add(*it, s);\n pts.erase(it++);\n }\n }\n //printf(\"I am faker! %d\\n\", i);\n for (auto e: out[i]) inv.erase(e);\n for (auto e: in[i]) inv.insert(e);\n }\n }\n \n printf(\"%d\\n\", f.sum(n));\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "377c12ce9757e4181f8f726de1eade8e", "src_uid": "294ee0db72d759792d797b6259a83406", "difficulty": 3100.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#define N 4000005\n#define P 1000000007\n#define ll long long\nusing namespace std;\nstruct T\n{\n\tll x,l,r;\n}c[N],d[N];\nll n,m,k,a[N],tg[N],b[N],Tg[N];\nbool cmp(T x,T y)\n{\n\treturn x.x==y.x?x.l>y.l:x.x>1;\n\tif (tg[k])\n\t{\n\t\ta[k<<1]+=tg[k]*(mid-l+1);tg[k<<1]+=tg[k];\n\t\ta[k<<1|1]+=tg[k]*(r-mid);tg[k<<1|1]+=tg[k];\n\t\ttg[k]=0;\n\t}\n}\nvoid mdy(ll k,ll l,ll r,ll x,ll y,ll p)\n{\n\tif (x<=l&&r<=y)\n\t{\n\t\ta[k]+=p*(r-l+1);tg[k]+=p;return;\n\t}\n\tll mid=l+r>>1;dn(k,l,r);\n\tif (x<=mid) mdy(k<<1,l,mid,x,y,p);\n\tif (y>mid) mdy(k<<1|1,mid+1,r,x,y,p);\n\ta[k]=a[k<<1]+a[k<<1|1];\n}\nll sum(ll k,ll l,ll r,ll x)\n{\n\tif (r<=x) return a[k];\n\tll mid=l+r>>1,ans;dn(k,l,r);\n\tans=sum(k<<1,l,mid,x);\n\tif (x>mid) ans+=sum(k<<1|1,mid+1,r,x);\n\treturn ans;\n}\nll kth(ll k,ll l,ll r,ll x)\n{\n\tif (l==r) return l;\n\tll mid=l+r>>1;dn(k,l,r);\n\tif (a[k<<1]>=x) return kth(k<<1,l,mid,x);\n\treturn kth(k<<1|1,mid+1,r,x-a[k<<1]);\n}\n//-------------------------------------\nvoid down(ll k,ll l,ll r)\n{\n\tif (Tg[k])\n\t{\n\t\tTg[k<<1]=Tg[k<<1|1]=1;\n\t\tb[k<<1]=b[k<<1|1]=0;Tg[k]=0;\n\t}\n}\nvoid add(ll k,ll l,ll r,ll x,ll y)\n{\n\tb[k]=(b[k]+y)%P;\n\tif (l==r)return;\n\tll mid=l+r>>1;down(k,l,r);\n\tif (x<=mid) add(k<<1,l,mid,x,y);\n\telse add(k<<1|1,mid+1,r,x,y);\n}\nvoid gg(ll k,ll l,ll r,ll x,ll y)\n{\n\tif (x<=l&&r<=y){b[k]=0;Tg[k]=1;return;}\n\tll mid=l+r>>1;down(k,l,r);\n\tif (x<=mid) gg(k<<1,l,mid,x,y);\n\tif (y>mid) gg(k<<1|1,mid+1,r,x,y);\n\tb[k]=(b[k<<1]+b[k<<1|1])%P;\n}\nll qry(ll k,ll l,ll r,ll x,ll y)\n{\n\tif (x>y) return 0;\n\tif (x<=l&&r<=y) return b[k];\n\tll mid=l+r>>1,Ans=0;down(k,l,r);\n\tif (x<=mid) Ans+=qry(k<<1,l,mid,x,y);\n\tif (y>mid) Ans+=qry(k<<1|1,mid+1,r,x,y);\n\treturn Ans%P;\n}\n//-------------------------------------\nint main()\n{\n\tscanf(\"%lld%lld%lld\",&n,&m,&k);\n\tfor (ll i=1;i<=k;i++)\n\t{\n\t\tll x1,y1,x2,y2;\n\t\tscanf(\"%lld%lld%lld%lld\",&x1,&y1,&x2,&y2);\n\t\tc[i]=(T){x1,y1,y2};\n\t\td[i]=(T){x2,y1,y2};\n\t}\n\tsort(c+1,c+k+1,cmp);\n\tsort(d+1,d+k+1,cmp);\n\t\n\tll now=1,pre=1,rnow=1;\n\tfor (ll i=1;i<=n;i++)\n\t{\n\t\tif (i==2) add(1,1,m,1,1);\t\n\t\twhile (now<=k&&c[now].x==i)\n\t\t{\n\t\t\tll t=kth(1,0,m,sum(1,0,m,c[now].r+1))+1;\n\t\t\t//cout<\n\nconst int ARRAY_LEN = 60000000;\nint d[ARRAY_LEN];\n\nint main()\n{\n\tint cm, in, ft, tmp;\n\n\tscanf(\"%d\", &cm);\n\n\tin = (cm + 1) / 3;\n\tft = in / 12;\n\tin = in % 12;\n\n\tfor(int i = 0, j = 1021; i < 500000000; i++, j++)\n\t{\n\n//\t\tif(j >= ARRAY_LEN) j -= ARRAY_LEN;\n\t\tj = j - j / ARRAY_LEN * ARRAY_LEN;\n\t\ttmp = i - i / ARRAY_LEN * ARRAY_LEN;\n\t\td[j] = d[tmp];\n//\t\td[tmp] = d[i % ARRAY_LEN];\n\t}\n\n\td[0] = ft;\n\tprintf(\"%d %d\\n\", d[0], in);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d3cbdc0d51b7d0d1602a9064f18f61ff", "src_uid": "5d4f38ffd1849862623325fdbe06cd00", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "/*\n * A.cpp\n *\n * Created on: 29.10.2011\n * Author: Altus\n */\n\n#include\n\nconst int ARRAY_LEN = 60000000;\nint d[ARRAY_LEN];\n\nint main()\n{\n\tint cm, in, ft, tmp;\n\n\tscanf(\"%d\", &cm);\n\n\tin = (cm + 1) / 3;\n\tft = in / 12;\n\tin = in % 12;\n\n\tfor(int i = 0, j = 1021; i < 400000000; i++, j++)\n\t{\n\n//\t\tif(j >= ARRAY_LEN) j -= ARRAY_LEN;\n\t\tj = j - j / ARRAY_LEN * ARRAY_LEN;\n\t\ttmp = i - i / ARRAY_LEN * ARRAY_LEN;\n\t\td[j] = d[tmp];\n//\t\td[tmp] = d[i % ARRAY_LEN];\n\t}\n\n\td[0] = ft;\n\tprintf(\"%d %d\\n\", d[0], in);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "927e856cb8b7a52c854917d9c97ef50c", "src_uid": "5d4f38ffd1849862623325fdbe06cd00", "difficulty": 1400.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint main()\n{\n int n;\n cin>>n;\n int a, b;\n n++;\n a=n/36;\n n=n-n/36*36;\n b=n/3;\n n=n-n/3*3;\n if (n>1) b++;\n cout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n// }}}\n// #defines {{{\n#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)\n#define SZ(x) ((int)(x).size())\n#define ALL(x) (x).begin(),(x).end()\n#define REP(i,n) for(int i=0;i<(n);i++)\n#define REP1(i,a,b) for(int i=(a);i<=(b);i++)\n#define REPL(i,x) for(int i=0;x[i];i++)\n#define PER(i,n) for(int i=(n)-1;i>=0;i--)\n#define PER1(i,a,b) for(int i=(a);i>=(b);i--)\n#define RI(x) scanf(\"%d\",&x)\n#define DRI(x) int x;RI(x)\n#define RII(x,y) scanf(\"%d%d\",&x,&y)\n#define DRII(x,y) int x,y;RII(x,y)\n#define RIII(x,y,z) scanf(\"%d%d%d\",&x,&y,&z)\n#define DRIII(x,y,z) int x,y,z;RIII(x,y,z)\n#define RS(x) scanf(\"%s\",x)\n#define DRS(x) string x; RS(x) // added by aliabdallah\n#define PI(x) printf(\"%d\\n\",x)\n#define PIS(x) printf(\"%d \",x)\n#define P(x) cout<<#x<<\" = { \"<> y //add by theyaserfox, note : '{' & '}' must be add before and after\n#ifdef ONLINE_JUDGE\n#define FILEIO(x) freopen(#x \".in\",\"r\",stdin);freopen(#x \".out\",\"w\",stdout);\n#define FILEIOS freopen(\"input.txt\",\"r\",stdin);freopen(\"output.txt\",\"w\",stdout);\n#else\n#define FILEIO(x) ;int main() {\n#define FILEIOS ;\n#endif\ntypedef pair PII;\ntypedef long long LL;\ntypedef unsigned long long ULL;\ntypedef long double LD;\ntypedef vector VI;\ntypedef vector VD;\ntypedef vector VVI;\ntypedef vector VVD;\ntypedef vector VS;\nconst LL OO = 1e8;\nconst double EPS = (1e-7);\n// }}}\n\n// added and tested by theyaserfox {{{\nVVI readAdjList() {\n DRII(n, e);\n VVI adjList(n+1);\n REP(i,e) {\n DRII(u, v);\n adjList[u].PB(v);\n adjList[v].PB(u);\n }\n return adjList;\n}\n\nvoid DFS(int node, VVI & adjList, VI & visited) {\n visited[node] = true;\n REPL(i, adjList[node]) {\n int child = adjList[node][i];\n if (!visited[child]) //To avoid cyclic behavior\n DFS(child, adjList, visited);\n }\n}\n\nVI BFS(int s, VVI & adjList) {\n VI len(SZ(adjList),OO);\n queue q;\n q.push(MP(s,0)); len[s] = 0;\n int cur, dep;\n while(!q.empty()) {\n PII p = q.front(); q.pop();\n cur = p.F; dep = p.S;\n REPL(i, adjList[cur]){\n int child = adjList[cur][i];\n if(len[child] == OO) {\n q.push(MP(child,dep+1)); len[child] = dep+1;\n }\n }\n }\n return len;\n}\n// }}}\n\n\nint GCD(int a, int b)\n{\n if(b == 0)\n return a;\n else\n return GCD(b, a%b);\n}\n\nint main()\n{\n int feet;\n DRI(n);\n int inch = n/3;\n feet=inch/12;\n\n if(n%3==2){ inch++;}\n int temp=inch/12;\n temp*=12;\n inch-=temp;\n\n cout<\n#include \n#include \n\nusing namespace std;\nint main()\n{\n\tint n;\n\tstring s;\n\tcin>>n>>s;\n\t\n\tfor(int i=0;i=2)\n\t\t{\n\t\t\tfor(int j=0;j\n\nusing namespace std;\nconst int maxn = 1e5+10;\n\nchar ch[maxn],b[30];\n\nint main(){\n int T,sum,sum2;\n while(~scanf(\"%d\",&T)){\n memset(b,0,sizeof(b));\n if(T == 1)\n printf(\"Yes\\n\");\n else{\n scanf(\"%s\",ch);\n for(int i = 0;i1)\n sum2++;\n }\n if(sum2>=1 )\n printf(\"Yes\\n\");\n else\n printf(\"No\\n\");\n }\n\n }\n return 0;\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "65f01868919be3e3bdec08246f0e2b98", "src_uid": "6b22e93f7e429693dcfe3c099346dcda", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\nint frq[1000000];\nint main()\n{\nint n;\nchar s[30];\ncin>>n;\nfor(int i=0;i>s[i];\n frq[s[i]]++;\n}\n\nfor(int i=0;i=2||n==1)\n {cout<<\"Yes\";\n break;}\nelse{\n cout<<\"No\";\n break;\n}}\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9aeda4b2b4d90a0afa5e4a176a6a0b08", "src_uid": "6b22e93f7e429693dcfe3c099346dcda", "difficulty": 900.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nint adj[9999][9999];\nint main()\n{\n\tint i, j, k;\n\tint n, m;\n\tstring s;\n\t\n\tint mp[26];\n\tmemset(mp, 0, sizeof(mp));\n\n\tcout<<(n);\n\tcin >> s;\n\n\tif (n == 1) {\n\t\tcout<<\"Yes\\n\";\n\t\treturn 0;\n\t}\n\n\tfor (i = 0; i < n; i++)\n\t\tmp[s[i] - 'a']++;\n\t\n\tbool f1=0 , f2 = 0;\n\tfor (i = 0; i < 26; i++)\n\t{\n\t\tif (mp[i] == 1)\n\t\t\tf1 = 1;\n\n\t\telse if (mp[i] > 1)\n\t\t\tf2 = 1;\n\t}\n\n\tif (f1) {\n\t\tif (f2)\n\t\t\tcout<<\"Yes\\n\";\n\t\telse\n\t\t\tcout<<\"No\\n\";\n\t}\n\n\telse\n\t\tcout<<\"Yes\\n\";\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dd241a9ba77a257802ba7752fbd58e74", "src_uid": "6b22e93f7e429693dcfe3c099346dcda", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#pragma comment(linker, \"/STACK:16777216\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std; \n\ntemplate inline string tostr(const _T& a) { ostringstream os(\"\"); os << a; return os.str(); }\n\n#define bublic public\n#define TynKogep TOPCODER \n#define clr(a) memset(a,0,sizeof(a))\n#define pb push_back\n#define sz size() \n#define ld long double\n#define ll long long\n#define mp make_pair\n#define istr istringstream\n\nconst ld PI=3.1415926535897932384626433832795;\nconst ld EPS=1e-9;\n\nint a[50000],na[50000];\n\nint main()\n{\n// freopen(\"q.in\", \"rt\", stdin);\n// freopen(\"q.out\", \"wt\", stdout);\n cout.flags(ios::fixed);\n ll x;\n cout.precision(2);\n cin>>x;\n if (x==0) {cout<<0; return 0;}\n if (x>10000)\n {\n if (x<0) x=-x;\n ll now=0,st=1,ans=0;\n while(now=0 && a[j-i]<=i) {na[j-i]=i+1;}\n if (a[j]==i && j+i<=40000 && a[j+i]<=i) {na[j+i]=i+1;} \n }\n for(int j=0;j<=40000;j++)\n a[j]=na[j]; \n if (a[20000+x])\n {\n cout< \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std; \n\ntemplate inline string tostr(const _T& a) { ostringstream os(\"\"); os << a; return os.str(); }\n\n#define bublic public\n#define TynKogep TOPCODER \n#define clr(a) memset(a,0,sizeof(a))\n#define pb push_back\n#define sz size() \n#define ld long double\n#define ll long long\n#define mp make_pair\n#define istr istringstream\n\nconst ld PI=3.1415926535897932384626433832795;\nconst ld EPS=1e-9;\n\nint a[50000],na[50000];\n\nint main()\n{\n// freopen(\"q.in\", \"rt\", stdin);\n// freopen(\"q.out\", \"wt\", stdout);\n cout.flags(ios::fixed);\n int x;\n cout.precision(2);\n cin>>x;\n if (x==0) {cout<<0; return 0;}\n if (x>10000)\n {\n if (x<0) x=-x;\n int now=0,st=1,ans=0;\n while(now=0 && a[j-i]<=i) {na[j-i]=i+1;}\n if (a[j]==i && j+i<=40000 && a[j+i]<=i) {na[j+i]=i+1;} \n }\n for(int j=0;j<=40000;j++)\n a[j]=na[j]; \n if (a[20000+x])\n {\n cout<\n#define MAX 1000000\nusing namespace std;\nstruct node\n{\n\tint pos;\n\tint num;\n};\nnode queue[100005];\nint main ()\n{\n\tint x;\n\tint head,p,temp;\n\twhile(scanf(\"%d\",&x)!=EOF)\n\t{\n\t\tif(x==0){printf(\"0\\n\");continue;}\n\t\thead=0;\n\t\tp=0;\n\t\tqueue[p].pos=0;\n\t\tqueue[p++].num=0;\n\t\twhile(p!=head)\n\t\t{\n\t\t\ttemp=head;\n\t\t\tif(queue[temp].pos==x)break;\n\t\t\thead++;\n\t\t\tif(head==MAX)head=0;\n\t\t\tqueue[p].pos=queue[temp].pos+queue[temp].num+1;\n\t\t\tqueue[p++].num=queue[temp].num+1;\n\t\t\tif(p==MAX)p=0;\n\t\t\tqueue[p].pos=queue[temp].pos-queue[temp].num+1;\n\t\t\tqueue[p++].num=queue[temp].num+1;\n\t\t\tif(p==MAX)p=0;\n\t\t\t\n\t\t}\n\t\tprintf(\"%d\\n\",queue[temp].num);\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3b53d3ab93027811c0270103c52dd8bc", "src_uid": "18644c9df41b9960594fdca27f1d2fec", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include\n#include\n\nint n,i,s;\n\nint main()\n{\n std :: cin >> n;\n for(n=n<0?-n:n; s\n#include \n#include \n#include \n#include \nusing namespace std;\n\nint val(char x)\n{\n if (x>='0'&&x<='9')\n return x-'0';\n return x-'A'+10;\n}\n\nint main ()\n{\n char x[20];\n string str;\n int i,j,k,l;\n string n1,n2;\n scanf (\"%s\",x);\n str=x;\n vector ret;\n for (i=0;i=0;j--)\n {\n if (val(n1[j])>=i)\n {\n f=0;\n break;\n }\n s1+=val(n1[j])*fact;\n fact*=i;\n }\n fact=1;\n for (j=n2.size()-1;j>=0;j--)\n {\n if (val(n2[j])>=i)\n {\n f=0;\n break;\n }\n s2+=val(n2[j])*fact;\n fact*=i;\n }\n if (!f)\n continue;\n if (s1<24&&s2<60)\n ret.push_back(i);\n else\n break;\n }\n for (i=0;i\n#include \n#include \nusing namespace std;\n\nchar S[15];\nint Sep, N, MaxD;\nvector Ans;\n\nint Digit(int Pos)\n{\n return ('0' <= S[Pos] && S[Pos] <= '9' ? S[Pos] - '0' : S[Pos] - 'A' + 10);\n}\n\nint Nr(int Left, int Right, int Base)\n{\n int Ans = 0;\n for(int i = Left; i <= Right; ++ i)\n Ans = Ans * Base + Digit(i);\n return Ans;\n}\n\nint main()\n{\n gets(S + 1);\n N = strlen(S + 1);\n\n for(int i = 1; i <= N; ++ i)\n if(S[i] == ':')\n Sep = i;\n\n int CntLeft = 0, CntRight = 0;\n for(int i = 1; i < Sep; ++ i) CntLeft += S[i] != '0';\n for(int i = Sep + 1; i <= N; ++ i) CntRight += S[i] != '0';\n\n if(CntLeft == 1 && S[Sep - 1] != '0' && Digit(Sep - 1) < 24 && CntRight == 1 && S[N] != '0' && Digit(N) < 60)\n {\n printf(\"-1\");\n return 0;\n }\n if(CntLeft == 0 && CntRight == 0)\n {\n printf(\"-1\");\n return 0;\n }\n\n for(int i = 1; i <= N; ++ i)\n if(i != Sep)\n MaxD = max(MaxD, Digit(i));\n\n for(int i = MaxD + 1; Nr(1, Sep - 1, i) < 24 && Nr(Sep + 1, N, i) < 60; ++ i)\n Ans.push_back(i);\n\n if(Ans.size() == 0) printf(\"0\");\n else\n {\n for(int i = 0; i < Ans.size(); ++ i)\n printf(\"%i \", Ans[i]);\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6df29c922de44c902bc3e273df032264", "src_uid": "c02dfe5b8d9da2818a99c3afbe7a5293", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \n#define ll long long\nusing namespace std;\nchar str[100010],h[100010],m[100010];\nll int mh,mm,lh,lm;\nll int priority(char c)\n{\n\tif(c>='0' && c<='9')\n\treturn c-'0';\n\treturn ((c-'A') +10);\n}\nvoid find_time(ll int r)\n{\n\tll int i,p=1;\n\tfor(i=(lh-1);i>=0;i--)\n\t{\n\t\tmh+=p*priority(h[i]);\n\t\tp*=r;\n\t\t//~ cout<=0;i--)\n\t{\n\t\tmm+=p*priority(m[i]);\n\t\tp*=r;\n\t}\n}\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tscanf(\"%s\",str);\n\tll int i,j,mymax;\n\t//~ int x,y;\n\t//~ sscanf(str,\"%d:%d\",&x,&y);\n\t//~ cout<=0;i--)\n\t{\n\t\tif(i<(lh-1) && h[i]!='0')\n\t\tuh=1;\n\t\tif(h[i]!='0')\n\t\tall=0;\n\t}\n\tfor(i=(lm-1);i>=0;i--)\n\t{\n\t\tif(i<(lm-1) && m[i]!='0')\n\t\tum=1;\n\t\tif(m[i]!='0')\n\t\tall=0;\n\t}\n\tif(all)\n\t{\n\t\tcout<<-1< r;\n\t\tfor(i=0;i\n#define ll long long\nusing namespace std;\nchar str[100010],h[100010],m[100010];\nll int mh,mm,lh,lm;\nll int priority(char c)\n{\n\tif(c>='0' && c<='9')\n\treturn c-'0';\n\treturn ((c-'A') +10);\n}\nvoid find_time(ll int r)\n{\n\tll int i,p=1;\n\tfor(i=(lh-1);i>=0;i--)\n\t{\n\t\tmh+=p*priority(h[i]);\n\t\tp*=r;\n\t\t//~ cout<=0;i--)\n\t{\n\t\tmm+=p*priority(m[i]);\n\t\tp*=r;\n\t}\n}\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tscanf(\"%s\",str);\n\tll int i,j,mymax;\n\t//~ int x,y;\n\t//~ sscanf(str,\"%d:%d\",&x,&y);\n\t//~ cout<=0;i--)\n\t{\n\t\tif(i<(lh-1) && h[i]!='0')\n\t\tuh=1;\n\t\tif(h[i]!='0')\n\t\tall=0;\n\t}\n\tfor(i=(lm-1);i>=0;i--)\n\t{\n\t\tif(i<(lm-1) && m[i]!='0')\n\t\tum=1;\n\t\tif(m[i]!='0')\n\t\tall=0;\n\t}\n\tif(all)\n\t{\n\t\tcout<<-1< r;\n\t\tfor(i=0;i\n#include\n#include\nusing namespace std; int main(){\n string s[3]; for (int i = 0; i < 3; cin >> s[i++]);\n for (int i = 0; i < 3; i++){\n for (int j = 0; j < s[i].size(); j++){\n if (s[i][j] == ';' || s[i][j] == '-' || s[i][j] == '_'){\n s[i].erase(j, 1); j--;\n }\n else s[i][j] = tolower(s[i][j]);\n }\n }\n int sz[3]; sz[0] = s[0].size(); sz[1] = s[1].size(); sz[2] = s[2].size();\n int n; cin >> n; vectorst(n); for (int i = 0; i < n; cin >> st[i++]);\n for (int i = 0; i < n; i++){\n for (int j = 0; j < st[i].size(); j++){\n if (st[i][j] == ';' || st[i][j] == '-' || st[i][j] == '_'){\n st[i].erase(j, 1); j--;\n }\n else st[i][j] = tolower(st[i][j]);\n }\n }\n for (int i = 0; i < n; i++){\n bool tr[3] = { 0 }; int j = 0;\n while(j\n#include \n#include \nusing namespace std;\nint main()\n{\n\tstring s,adress;\n\tint k,j;\n\tchar a;\n\tcin>>s;\n\tif (s[0]=='h' && (s[1]=='t') && (s[2]=='t') && (s[3]=='p')) \n\t{\n\t\tk=4;\n\tadress.append(\"http://\");\n\t}\n\tif (s[0]=='f' && (s[1]=='t') && (s[2]=='p')) \t{\n\t\tk=3;\n\t\tadress.append(\"ftp://\");\n\t\t}\n\t\t\n\tfor (int i=k;i\n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint a[200];\nint main(){\n\tstring ss;\n\tgetline(cin,ss);\n\tint f1;\n\tif (ss.find(\"http\")==0) f1=4;\n\telse f1=3;\n\tint i;\n\tfor (i=0; i\n#include \n#include \n#include \n#include \nusing namespace std;\n\nvoid main()\n{char c[101],b[110],k=0;\n bool flag=false;\n gets(c);\n int i=0;\n if (c[0]=='f')\n {i+=3;\n for(int j=0; j<3; j++) b[j]=c[j];\n b[3]=':'; b[4]='/'; b[5]='/';\n k=6;\n }\n if (c[0]=='h')\n {i+=4;\n for(int j=0; j<4; j++) b[j]=c[j];\n b[4]=':'; b[5]='/'; b[6]='/';\n k=7;\n }\n/* block obrabotki */\n while(c[i]!='r' || c[i+1]!='u' || !flag) {b[k++]=c[i++]; flag=true;}\n b[k++]='.';\n i+=2; b[k++]='r'; b[k++]='u';\n if (c[i]>='a' && c[i]<='z')\n {b[k++]='/';\n while(c[i]>='a' && c[i]<='z') b[k++]=c[i++];\n }\n b[k]='\\0';\n puts(b);\ngetch();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e793dbdd2ed6fd7814c5aa7d8c3d2dbd", "src_uid": "4c999b7854a8a08960b6501a90b3bba3", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include\nint dp[102][102];\nint dp2[102][102];\nint a[1000];\n\nbool checkeven(int start, int end);\nbool check(int start, int end);\n\nint main() {\n\tfor (int i = 0; i < 102; i++) {\n\t\tfor (int j = 0; j < 102; j++) {\n\t\t\tdp[i][j] = -1;\n\t\t\tdp2[i][j] = -1;\n\t\t}\n\t}\n\tint n;\n\tstd::cin >> n;\n\tfor (int i = 0; i < n; i++)std::cin >> a[i];\n\n\tif (check(0, n - 1))std::cout << \"Yes\\n\";\n\telse std::cout << \"No\\n\";\n\tsystem(\"pause\");\n\treturn 0;\n}\n\nbool check(int start, int end) {\n\n\tif (start >= end)return dp[start][end]=false;\n\tif (dp[start][end] != -1)return dp[start][end];\n\n\tif ((end - start) % 2 == 1)return dp[start][end] = false;\n\tif ((end - start) % 2 == 0) {\n\t\tif (a[start] % 2 == 1 && a[end] % 2 == 1)return dp[start][end] = true;\n\t\telse return dp[start][end] = false;\n\t}\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bca504c6f10bca7c5daa4edcdef6397e", "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\n\nint main() {\n\tint a,i;\n int arr[a];\n cin>>a;\n for(i=0;i>arr[i];\n }\n if(arr[0]%2==0||arr[a-1]%2==0||a%2==0){\n \tcout<<\"No\";\n \n }\n else{\n cout<<\"Yes\";\n }\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "260bf3d49586cf1e9fc37bd3df14e04e", "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \nusing namespace std;\n\ntypedef vector vi;\n\nint n;\nint arr[109];\n\nbool solve() {\n // First populate with intersections\n vi inter;\n for (int i = 0; i < n - 1; ++i) {\n if (arr[i] % 2 != 0 && arr[i+1] % 2 != 0)\n inter.push_back(i);\n }\n for (int i = 0; i < inter.size() - 1; ++i) {\n if (inter[i] % 2 == 0) {\n // We can take this one since it is at an even index.\n for (int j = i + 1; j < inter.size(); ++j) {\n if ((inter[j] - inter[i]) % 2 != 0 && (n - (inter[j] + 1)) % 2 != 0) {\n //cout << inter[i] << \" \" << inter[j] << endl;\n return true;\n }\n }\n }\n }\n return false;\n}\n\nint main() {\n cin >> n;\n for (int i = 0; i < n; ++i) {\n cin >> arr[i];\n }\n\n if (arr[0] % 2 != 0 && arr[n-1] % 2 != 0 && solve()) {\n cout << \"Yes\" << endl;\n } else cout << \"No\" << endl;\n};", "lang_cluster": "C++", "compilation_error": false, "code_uid": "024c764f0d8796b6f5ef5181ea6286d7", "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "/**\n * winners never quit\n**/\n\n#include \n\nusing namespace std;\n\n#define pb push_back\n#define mp make_pair\ntypedef long long Long;\n\nconst int N = 1e5;\n\nint main()\n{\n ios::sync_with_stdio(0);\n cin.tie(0);cout.tie(0);\n int tc, ca = 0;\n int n, el;\n cin >> n;\n vector v;\n for (int i = 0;i < n;i++){\n cin >> el;\n if (el%2)v.pb(i);\n }\n string ans = \"No\";\n //cout << v[v.size()-1] - v[0] << '\\n';\n if ((v[v.size()-1]-v[0]) % 2 == 0)ans = \"Yes\";\n cout << ans << '\\n';\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "58e3afdf64481ddd96e32f932d15c78f", "src_uid": "2b8c2deb5d7e49e8e3ededabfd4427db", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\ntypedef long long int ll;\n#define M_PIl 3.141592653589793238462643383279502884L\nset ans;\n\n\nint main(){\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n \n ll n;\n cin>>n;\n\n vector a = {0, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244, 292};\n if (n < a.size()) return a[n];\n else return a[11] + 49 * (n - 11);\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5673cf1414c45e683ae1c32d79587fb7", "src_uid": "75ec99318736a8a1b62a8d51efd95355", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include \n#include\nusing namespace std;\nlong long fun(long n)\n{\n int i,j,k,a[10000000]={0};\n long long sum=0;\n for(i=0;i<=n;i++)\n for(j=0;i+j<=n;j++)\n for(k=0;i+j+k<=n;k++)\n {\n long long t=i+j*5+k*10+(n-i-j-k)*50;\n if(!a[t])\n {\n a[t]=1;\n sum++; \n }\n }\n return sum;\n}\nint main() {\n long x;\n scanf(\"%lld\",&x);\n long long ans;\n if(x<=11)\n ans=fun(x);\n else\n ans=fun(11)+(x-11)*49;\n cout<\nusing namespace std;\nconst int a[] = {0, 4, 10, 20, 35, 56, 83, 116, 155, 198, 244, 292, 390};\nconst int maxn = 205;\nint k, n, d;\nint main() {\n\tscanf(\"%d\", &n);\n\tif(n <= 12) printf(\"%d\\n\", a[n]);\n\telse printf(\"%lld\\n\", 1LL * (n - 11) * 49 + a[11]);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9d087a205575e795dce6e016fa411beb", "src_uid": "75ec99318736a8a1b62a8d51efd95355", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#define ll long long\n\t#define ld long double\n\t#define vi vector\n\t#define vll vector\n\t#define vvi vector < vi >\n\t#define pii pair\n\t#define pll pair\n\t#define mod 1000000007\n\t#define inf 1000000000000000001;\n\t#define all(c) c.begin(),c.end()\n\t#define mp(x,y) make_pair(x,y)\n\t#define mem(a,val) memset(a,val,sizeof(a))\n\t#define eb emplace_back\n\t#define pb push_back\n\t#define f first\n\t#define s second\n\t\n\tusing namespace std;\n\n\tint flag[1000001];\n\tint answ;\n\tll func(ll n)\n\t{\n\t\tif(n<9)\n\t\t\treturn 1+n+n*(n+1)/2;\n\t\treturn 1+n+n*(n+1)/2-(n-8)*(n-8+1)/2;\n\t}\n\n\tint main()\n\t{\n\t\tstd::ios::sync_with_stdio(false);\n\t\tint T;\n\t\tT=1;\n\t\t// cin.ignore(); must be there when using getline(cin, s)\n\t\twhile(T--)\n\t\t{\n\t\t\tll ans=0;\n\t\t\tll n;\n\t\t\tcin>>n;\n\t\t\tif(n<=5)\n\t\t\t{\n\t\t\t\tans=1+n+n*(n+1)/2+n*(n+1)*(n+2)/6;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tans=func(n)+func(n-1)+func(n-2)+func(n-3)+func(n-4)+func(n-5);\n\t\t\t\tif(n>=9)\n\t\t\t\t\tans=ans-(n-8)*(n-8+1)/2;\n\t\t\t\tif(n>14)\n\t\t\t\t\tans=ans+(n-13)*(n-13+1)/2;\n\t\t\t}\n\t\t\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\nint gcd(int a, int b) {\n if (a == b) return a;\n if (a > b) return gcd(a-b, b);\n if (a < b) return gcd(a, b - a);\n}\n\nint main() {\n int a,b,c,d;\n scanf(\"%d%d%d%d\", &a,&b,&c,&d);\n\n int t1, t2;\n //if (a >= c && b >= d) {\n if (c > d) {\n int ba = a;\n a *= c;\n b *= c;\n c *= ba;\n d *= ba;\n } else if (d > c) {\n int bb = b;\n b *= d;\n a *= d;\n c *= bb;\n d*= bb;\n } else {\n int bc = min(a, b);\n b *= d;\n a *= d;\n c *= bc;\n d*= bc;\n }\n// }\n\n /*a*=t2;b*=t2;\n c*=t1;d*=t1;*/\n\n int aa = abs(a - c);\n int bb = abs(b-d);\n\n int cc; int p;\n if (aa > 0) {\n cc = aa;\n p = a;\n } else {\n cc = bb;\n p = b;\n }\n\n int dd = gcd(cc, p);\n cc /= dd;\n p /= dd;\n\n printf(\"%d/%d\\n\", cc, p);\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3f2b2b89d21533cb6e4a7dc71dae307a", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nlong long int gcd(long long int a,long long int b)\n{\n if(a==b)\n return a;\n if(a==1||b==1)\n return 1;\n if(a>b)\n return gcd(a-b,b);\n else\n return gcd(a,b-a);\n}\n\n\nint main(int argc, char const *argv[])\n{\n long long int a,b,c,d;\n cin>>a>>b>>c>>d;\n //c=c*a*b;\n //d=d*a*b;\n if(c*b>d*a)\n {\n long long int gcd_req=gcd(c*b-a*d,c*b);\n cout<<(c*b-a*d)/gcd_req<<\"/\"<<(c*b)/gcd_req;\n }\n else\n {\n long long int gcd_req=gcd(d*a-b*c,d*a);\n cout<<(a*d-c*b)/gcd_req<<\"/\"<<(d*a)/gcd_req;\n }\n return 0;\n\n \n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "810b110fd2fc7b21eee4a830db3a872c", "src_uid": "b0f435fc2f7334aee0d07524bc37cb1e", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\nint gcd(int a, int b)\n{\n if(b==0) return a;\n return gcd(b,a%b);\n}\n\nint main()\n{\n int a, b, c, d;\n while(cin >> a >> b >> c >> d)\n {\n if(a>b) swap(a,b);\n if(c>d) swap(c,d);\n c*=b, d*=b;\n if(c/a==d/b&&c%a==0&&d%b==0) puts(\"0/1\");\n else\n {\n double minn;\n int s, m, p, q, g;\n if(1.0*(d-b)/d<=1.0*(c-a)/c)\n {\n p=b*c-a*d; q=b*c;\n g=gcd(q,p);\n minn=1.0*p/q;\n s=p/g, m=q/g;\n }\n else\n {\n p=a*d-b*c; q=a*d;\n g=gcd(q,p);\n minn=1.0*p/q;\n s=p/g, m=q/g;\n }\n swap(a,b);\n if(1.0*(d-b)/d<=1.0*(c-a)/c)\n {\n p=b*c-a*d; q=b*c;\n g=gcd(q,p);\n if(1.0*p/q\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define FOR(i,a,b) for(int i=(a);i<(b);++(i))\n#define all(c) (c).begin(), (c).end()\n#define rall(c) (c).rbegin(), (c).rend()\n#define SZ(V) (int)V.size()\n#define PB push_back\n#define MP make_pair\n#define MS(a) memset((a),0,sizeof(a))\ntypedef pair PII;\ntypedef vector VI;\ntypedef vector < VI > VVI;\ntypedef vector VD;\ntypedef vector VS;\ntypedef long long LL;\ntypedef unsigned int UL;\ntypedef unsigned long long ULL;\n\nVI reducefrac (int a, int b){\n\n int tempa = a, tempb = b;\n while (a!=b){\n if(a>b)\n a = a-b;\n else\n b = b-a;\n }\n int numerator = tempa/a;\n int denominator = tempb/b;\n\n return {numerator,denominator};\n\n}\nint main(){\n\n\n\n //monitor dimensions a:b\n //movie dimensions c:d\n int a,b,c,d;\n cin >> a >> b >> c >> d;\n\n VI temp = reducefrac(a,b);\n VI temp2 = reducefrac(c,d);\n\n a = temp[0];\n b = temp[1];\n c = temp2[0];\n d = temp2[1];\n\n\n double screenratio = a*1.0/b;\n double movieratio = c*1.0/d;\n\n if(screenratio > movieratio){\n int denom = a;\n\n int num_x = b * c;\n int denom_x = d;\n int numdiff = a * d - num_x;\n int dendiff = d * a;\n\n VI final = reducefrac(numdiff, dendiff);\n cout << final[0] << \"/\"< screenratio){\n\n int denom = c;\n int num = b * denom - ( a * d);\n VI final = reducefrac(num, denom);\n\n cout << final[0] << \"/\"<\n#include\n#include\nint main(){\n\tint t;\n\tint count=0;\n\tint a,h;\n\tint i=0;\n\tint home[30];\n\tint away[30];\n\tscanf(\"%d\",&t);\n\tfor(i=0;i\n#include\n#include\n#include\nusing namespace std;\n\n\n\n\nint main() {\n\n\tint n;\n\tint s[1000], s1[1000];\n\tint k = 0;\n\tint p = 0;\n\tcin >> n;\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> s[i] >> s1[i];\n\t}\n\n\n\tfor (int i = 0; i\n#include\n#include\n#include\nusing namespace std;\n\n\n\n\nint main() {\n\n\tint n;\n\tint s[1000], s1[1000];\n\tint k = 0;\n\tint p = 0;\n\tcin >> n;\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> s[i] >> s1[i];\n\t}\n\n\tfor (int i = 0; i < n; i++) {\n\n\t\t\n\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\n\t\t\tif (s[i] == s1[j] && s1[j] != i) {\n\t\t\t\tk++;\n\t\t\t}\n\n\t\t}\n\t\n\t\t\n\n\n\t}\n\n\n\tfor (int i = 0; i < n; i++) {\n\n\n\t\tfor (int j = 0; j < n; j++) {\n\n\t\t\tif (s1[i] == s[j] && s1[j] != i) {\n\t\t\t\tk++;\n\t\t\t}\n\n\t\t}\n\n\n\n\n\t}\n\tcout << k/2;\n\n\t_getch();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2691d7df7f2e9573912d458bbd270999", "src_uid": "745f81dcb4f23254bf6602f9f389771b", "difficulty": 800.0} {"lang": "Clang++17 Diagnostics", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n int n;\n cin>>n;\n int i, j;\n int a[i], b[i];\n for(i=0; i>a[i]>>b[i];\n } \n int temp, count = 0;\n for(i=0; i\n//#include \n#include \n\nusing namespace std;\n\nint main () {\n\tint n;\n\tcin >> n;\n\n\tint counter = 0;\n\tint sum = 1;\n\tint a = 1;\n\tint b = 2;\n\twhile (n >= sum) {\n\t\tcounter++;\n\t\ta += b;\n\t\tb++;\n\t\tsum += a;\n\t}\n\n\tcout << counter;\n\n\t_getch();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6b8f64eddc837111eae84321a2e49064", "src_uid": "873a12edffc57a127fdfb1c65d43bdb0", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\n\nint main()\n{\n int a[100],sum=0,x,i=0,b=1;\n cin>>x;\n\n for(i=0;i<100;i++){\n sum+=b;\n b++;\n a[i]=sum;\n }\n for(i=0;x>=a[i];i++){\n x=x-a[i];\n }\n cout<\n#include \nusing namespace std;\n\nint main()\n{\n int a[100],sum=0,x,i=0,b=1;\n cin>>x;\n\n for(i=0;i<100;i++){\n sum+=b;\n b++;\n a[i]=sum;\n }\n\n for(i=0;x>=a[i];i++){\n x=x-a[i];\n sum+=i;\n }\n cout<\n#include \n#include \n#include \n \nusing namespace std;\n \nenum SEX{MALE,FEMALE};\n \nclass Bird\n \n{\n \n private:\n \n string name;\n string surname;\n string fathername;\n int age;\n SEX sex;\n \n public:\n Bird(string name, string surname, string fathername, int age, SEX sex)\n {\n this->name = name;\n this->surname = surname;\n this->fathername = fathername;\n this->age = age;\n this->sex = sex;\n }\n string GetName () const\n \n {\n \n return name;\n \n }\n \n void SetName (string name)\n \n {\n \n this->name = name;\n \n }\n string GetSurName () const\n \n {\n \n return surname;\n \n }\n \n void SetSurnameName (string surname)\n \n {\n \n this->surname = surname;\n \n }\n string GetFatherName () const\n \n {\n \n return fathername;\n \n }\n \n void SetFatherName (string fathername)\n \n {\n \n this->fathername = fathername;\n \n }\n \n int GetAge () const\n \n {\n \n return age;\n \n }\n \n void SetAge (int age)\n \n {\n \n this->age = age;\n \n }\n \n int GetSex ()\n \n {\n \n return sex;\n \n }\n \n virtual string Type () const = 0;\n \n virtual string Voice () const = 0;\n \n virtual Bird* Reproducte(Bird* bird) const = 0;\n \n string Introdure() const\n {\n return string(\"Hello I'm \")+Type() + \" my name is \" + GetSurName()+\" \"+GetName()+\" \"+GetFatherName()+\" \"+to_string(GetAge());\n }\n};\n \nclass Owl:public Bird\n \n{\n \n public:\n Owl(string name, string surname, string fathername, int age, SEX sex):Bird(name,surname,fathername,age, sex){};\n \n string Type () const\n \n {\n \n return \"OWL\";\n \n }\n \n string Voice () const\n \n {\n \n return \"HU-HU\";\n }\n \n Bird* Reproducte(Bird* partner) const\n {\n int a = rand() % 2;\n return new Owl(this->GetName(),partner->GetSurName(),\"sgfds\",0,static_cast(a));\n }\n \n };\n \nclass Sparrow:public Bird\n \n {\n \n public:\n Sparrow(string name, string surname, string fathername, int age, SEX sex):Bird(name,surname,fathername,age, sex){};\n string Type () const\n \n {\n \n return \"Sparrow\";\n \n }\n \n string Voice () const\n \n {\n \n return \"Chirik\";\n \n }\n Bird* Reproducte(Bird* partner) const\n {\n int a = rand() % 2;\n return new Sparrow(this->GetName(),partner->GetSurName(),\"sgfds\",0,static_cast(a));\n }\n \n};\n \nclass Dove:public Bird\n \n{\n \n public:\n \n Dove(string name, string surname, string fathername, int age, SEX sex):Bird(name,surname,fathername,age, sex){};\n \n string Type () const\n \n {\n \n return \"Dove\";\n \n }\n \n string Voice () const\n \n {\n \n return \"Kurlick\";\n \n }\n Bird* Reproducte(Bird* partner) const\n {\n int a = rand() % 2;\n return new Dove(this->GetName(),partner->GetSurName(),\"sgfds\",0,static_cast(a));\n }\n \n \n};\n \nint main ()\n \n{\n int years = 6;\n int size;\n vector bird_house;\n bool bird_pair[100];\n fill_n(bird_pair,100,true);\n string n; \n do \n {\n string name=\"dsfsad\";\n string surname=\"dsfsad\";\n string fathername=\"dsfsad\";\n int age=0;\n SEX sex;\n string type;\n string tmp;\n cout<<\"ENTER NAME\"<>name>>surname>>fathername>>age;\n cin>>tmp;\n if(tmp ==\"male\") sex = MALE;\n else sex = FEMALE;\n cout<<\"Enter type\"<>type;\n if(type ==\"Dove\")\n bird_house.push_back(new Dove(name,surname,fathername,age,sex));\n if(type ==\"Owl\")\n bird_house.push_back(new Owl(name,surname,fathername,age,sex));\n if(type ==\"Sparrow\")\n bird_house.push_back(new Sparrow(name,surname,fathername,age,sex));\n cout<<\"Do you want exit?\"<>n; \n }while(n!=\"yes\");\n \n for(int i = 0 ; iGetAge()+1;\n bird_house[k]->SetAge(age);\n for(int l = 0; l < size;l++)\n if(bird_house[k]->Type() == bird_house[l]->Type()&&bird_house[k]->GetSex()!=bird_house[l]->GetSex())\n {\n if(!bird_pair[k]||!bird_pair[l]) continue;\n bird_house.push_back(bird_house[k]->Reproducte(bird_house[l]));\n bird_pair[k] = false;\n bird_pair[l] = false;\n }\n }\n }\n \n for(auto _bird :bird_house)\n cout<<_bird->Introdure()<Type()+\":\"+birdHouse->Voice ()<< endl;\n \n Sparrow captain_Jack(\"Jack\",\"sdf322\",\"asdfsadf\",19,FEMALE);\n \n Bird& pirate = captain_Jack;\n \n cout<\n#define maxn 10005\n#define maxp 1000005\n#define maxm 1000005\n#define inf 0x3f3f3f3f\n#define rep(i,j,k) for(int i=(j),LIM=(k);i<=LIM;i++)\n#define per(i,j,k) for(int i=(j),LIM=(k);i>=LIM;i--)\nusing namespace std;\n\nchar Start;\n\nint n,q;\nvector >in[maxn],ot[maxn];\nint rt[maxn],lc[maxp],rc[maxp],ad[maxp],tot;\nint buf[maxp],info[maxp],Prev[maxm],to[maxp],cap[maxp],cnt_e=1;\nvoid Node(int u,int v,int c){ Prev[++cnt_e]=info[u],info[u]=cnt_e,to[cnt_e]=v,cap[cnt_e]=c; }\nvoid Line(int u,int v,int c){ Node(u,v,c),Node(v,u,0);}\nint h[maxp],S,T;\n\nvoid upd(int u){\n\tif(!ad[lc[u]]) Line(u,lc[u],inf); \n\tif(!ad[rc[u]]) Line(u,rc[u],inf);\n}\n\nvoid Build(int &u,int l,int r){\n\tif(l==r){\n\t\tu = l;\n\t\treturn;\n\t}\n\tu = ++tot;\n\tint m = l+r>>1;\n\tBuild(lc[u],l,m) , Build(rc[u],m+1,r);\n\tupd(u);\n}\n\nvoid add(int &u,int l,int r,int ql,int qr,int v){\n\tif(ql>r||l>qr||ql>qr) return; \n\tif(l == r){\n\t\tad[u] += v;\n\t\treturn;\n\t}\n\tlc[++tot] = lc[u] , rc[tot] = rc[u] , ad[tot] = ad[u];\n\tu = tot;\n\tif(ql<=l&&r<=qr) return (void)(ad[u] += v , upd(u));\n\tint m = l+r>>1;\n\tadd(lc[u],l,m,ql,qr,v) , add(rc[u],m+1,r,ql,qr,v);\n\tupd(u);\n}\n\nbool BFS(){\n\tstatic int q[maxp],L,R;\n\tmemset(h,-1,sizeof(int) * (tot+1));\n\th[q[L=R=0] = T] = 0;\n\tfor(int u;L<=R;){\n\t\tu=q[L++];\n\t\tfor(int i=info[u],v;i;i=Prev[i]) if(cap[i^1] && h[v=to[i]] == -1){\n\t\t\th[v] = h[u] + 1;\n\t\t\tq[++R] = v;\n\t\t}\n\t}\n\treturn h[S] != -1;\n}\n\nint aug(int u,int mx){\n\tif(u == T) return mx;\n\tint st = mx , inc;\n\tfor(int &i=info[u],v;i;i=Prev[i]) if(cap[i] && h[v=to[i]] + 1 == h[u] && (inc = aug(v , min(cap[i] , st)))){\n\t\tst -= inc , cap[i] -= inc , cap[i^1] += inc;\n\t\tif(!st) return mx - st;\n\t} \n\treturn mx - st;\n}\n\nchar End;\n\nint main(){\n//\tfreopen(\"1.in\",\"r\",stdin);\n\n\tscanf(\"%d%d\",&n,&q);\n\trep(i,1,q){\n\t\tint a,b,c,d;\n\t\tscanf(\"%d%d%d%d\",&a,&b,&c,&d);\n\t\tin[a].push_back(make_pair(b,d));\n\t\tot[c+1].push_back(make_pair(b,d));\n\t}\n\ttot = 2 * n;\n\tS=++tot,T=++tot;\n\tBuild(rt[0],1,n);\n\trep(i,1,n) Line(i,T,1) , Line(S,i+n,1);\n\trep(i,1,n){\n\t\trt[i] = rt[i-1];\n\t\tfor(auto u:in[i]) add(rt[i] , 1 , n , u.first , u.second , 1);\n\t\tfor(auto u:ot[i]) add(rt[i] , 1 , n , u.first , u.second , -1);\n\t\tif(!ad[rt[i]]) Line(i+n,rt[i],inf);\n\t}\n\tint stm = 0;\n\tfor(memcpy(buf,info,sizeof(int) * (tot+1));BFS();)\n\t\tstm += aug(S,inf) , memcpy(info,buf,sizeof(int) * (tot+1));\n\tprintf(\"%d\\n\",stm);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0cc4f9c04fb720c044eabe82c2bcd994", "src_uid": "d662ef3f9a70a5afaa2f0f68327a457f", "difficulty": 3400.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef double db;\n#define x first\n#define y second\n#define bg begin()\n#define ed end()\n#define pb push_back\n#define mp make_pair\n#define sz(a) int((a).size())\n#define R(i,n) for(int i(0);i<(n);++i)\n#define L(i,n) for(int i((n)-1);~i;--i)\nconst int iinf=0x3f3f3f3f;\nconst ll linf=0x3f3f3f3f3f3f3f3f;\n\n//ReadWrite\nconst int BUF=1<<20;\nstatic char buf[BUF],*p1=buf,*p2=buf,obuf[BUF],*p3=obuf;\n// #define getchar() p1==p2&&(p2=(p1=buf)+fread(buf,1,BUF,stdin),p1==p2)?EOF:*p1++\n// #define putchar(x) (p3-obufvoid read(item &x){\n x=0; item f=1; char c=getchar();\n while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}\n while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();\n x*=f;\n}\ntemplatevoid write(item x){\n\tif(x<0) x=-x,putchar('-');\n\tif(x>9) write(x/10); putchar(((x%10)^48));\n}\nstruct Flusher{~Flusher(){fwrite(obuf,p3-obuf,1,stdout);}}flusher;\n\n//Data\nconst int N=1e4;\nint n,m,sn;\ndb pr[N],pr2[N],cnt[N],cnt2[N];\nvector> se[N|1]; \nbitset bs,fu;\n\n//Flows\nconst int fN=(N<<1)+2;\nint fn,s,t,dep[fN],cur[fN];\nint *ta,*he,q[fN],e[fN];\nvector nex,to,fw;\nvoid init(){R(u,fn) e[u]=-1;}\nvoid adde(int u,int v,int w){\n // cout<0){\n fw[v]-=f,fw[v^1]+=f,r-=f,res+=f;\n if(!r) break;\n }\n if(r) dep[u]=iinf;\n return res;\n}\nint flow(){\n int res=0,f;\n while(bfs())while((f=dfs(s,iinf))) res+=f;\n return res;\n}\n\n//Main\nint main(){\n // ios::sync_with_stdio(0);\n // cin.tie(0),cout.tie(0);\n mt19937 orz(20201123);\n read(n),read(m),fn=(t=(s=n<<1)+1)+1,init();\n R(i,m){\n pair a,b;\n read(a.x),read(a.y),read(b.x),read(b.y),--a.x,--a.y;\n se[a.x].pb(mp(a.y,b.y)),se[b.x].pb(mp(a.y,b.y));\n }\n R(i,n) fu.set(i);\n R(times,5){\n R(i,n){\n for(const pair &u:se[i])\n bs=bs^((fu<>(n-u.y)));\n R(j,n)if(!bs[j]) cnt[i]+=1.-(1.-pr[i])*(1.-pr2[j]),\n cnt2[j]+=1.-(1.-pr[i])*(1.-pr2[j]);\n }\n bs.reset();\n R(i,n) pr[i]=cnt[i]<=sqrt(n)?1:(.7*sqrt(n)/cnt[i]+.3)*(1e7/(n*n)),\n pr2[i]=cnt2[i]<=sqrt(n)?1:(.7*sqrt(n)/cnt2[i]+.3)*(1e7/(n*n));\n R(i,n) pr[i]=min(pr[i],1.),pr2[i]=min(pr2[i],1.);\n }\n // cout.precision(6);\n // R(i,n) cout< &u:se[i])\n bs=bs^((fu<>(n-u.y)));\n R(j,n)if(!bs[j]&&(1.*(orz()%98)/97<=1.-(1.-pr[i])*(1.-pr2[j])))\n adde(i,j+n,1); //,cout<\n\nusing namespace std;\n\n#define F first\n#define S second\n#define pb push_back\n#define mt make_tuple\n\ntypedef long double ld;\ntypedef long long ll;\n\ntemplate inline void read(T& a) {\n a = 0;\n char c;\n bool _MINUS_ = false;\n while (!isdigit(c = getchar())) _MINUS_ |= c == '-';\n do a = a * 10 + (c - '0');\n while (isdigit(c = getchar()));\n if (_MINUS_) a *= -1;\n}\n\n\nint binpow(int a, int n, int p) {\n int ans = 1;\n while (n > 0) {\n if (n & 1) {\n ans = (1ll * ans * a) % p;\n }\n n >>= 1;\n a = (1ll * a * a) % p;\n }\n return ans;\n}\n\n//string world[8] = {\"U\", \"D\", \"R\", \"L\", \"UL\", \"UR\", \"DR\", \"DL\"};\n//const int rx[8] = { -1, 1, 0, 0, -1, -1, 1, 1};\n//const int ry[8] = { 0, 0, 1, -1, -1, 1, 1, -1};\n\nconst int mod = 1000000007;\n\nconst int N = 10100;\n\nbitset bad[N];\nbitset bad1[N];\nint cnt[N];\n\ndouble getA() {\n return (rand() % 300) / 300.0;\n}\n\n#define FILE \"castle\"\nint main() {\n#ifdef LOCAL\n freopen(\"input.txt\", \"r\", stdin);\n// freopen(\"output.txt\", \"w\", stdout);\n#else\n// freopen(FILE\".in\", \"r\", stdin);\n// freopen(FILE\".out\", \"w\", stdout);\n#endif\n int n, q;\n cin >> n >> q;\n// if (n == 10000 && q == 2626){\n// cout << 9893 << endl;\n// return 0;\n// }\n srand(time(0));\n for (int i = 0; i < n; i++) cnt[i] = n;\n for (int i = 0; i < q; i++) {\n int x1, y1, x2, y2;\n cin >> x1 >> y1 >> x2 >> y2;\n for (int x = x1; x <= x2; x++) {\n for (int y = y1; y <= y2; y++) {\n bad[x - 1][y - 1] = 1;\n cnt[y - 1]--;\n }\n }\n }\n int ans1 = 0;\n for (int i = 0; i < n; i++) {\n int mx = 1e9, p = -1;\n for (int j = 0; j < n; j++) {\n if (cnt[j] == 0) continue;\n if (bad[i][j]) continue;\n if (cnt[j] < mx || (cnt[j] == mx && rand() % 2 == 0)) {\n mx = cnt[j];\n p = j;\n }\n }\n if (p == -1) continue;\n cnt[p] = 0;\n ans1++;\n }\n// cerr << 1 << endl;\n {\n\n int a[n];\n for (int i = 0; i < n; i++) a[i] = i;\n while (true) {\n if (1.0 * clock() / CLOCKS_PER_SEC > 0.5) break;\n random_shuffle(a, a + n);\n// bool f = true;\n int cur = 0;\n vector all;\n for (int i = 0; i < n; i++) {\n if (!bad[i][a[i]]) {\n cur++;\n continue;\n } else {\n all.push_back(a[i]);\n if (all.size() == 1) continue;\n if (all.size() < 10) {\n for (int j = 0; j < all.size() - 1; j++) {\n if (!bad[i][all[j]]) {\n cur++;\n swap(all[j], all[all.size() - 1]);\n all.pop_back();\n break;\n }\n }\n } else {\n for (int q = 0; q < 10; q++) {\n int j = rand() % (all.size() - 1);\n if (!bad[i][all[j]]) {\n cur++;\n swap(all[j], all[all.size() - 1]);\n all.pop_back();\n break;\n }\n }\n }\n }\n }\n ans1 = max(ans1, cur);\n }\n }\n// cerr << 2 << endl;\n {\n\n\n while (true) {\n int E = n;\n int pE = E;\n\n int a[n];\n for (int i = 0; i < n; i++) a[i] = i;\n\n long double T = 1.0 * (rand() % 50 + 2);\n long double K = 0.995;\n while (T > 1e-3 && E != 0) {\n if (1.0 * clock() / CLOCKS_PER_SEC > 6.3) break;\n int m = rand() % 70 + 10;\n while (m--) {\n // if (1.0 * clock() / CLOCKS_PER_SEC > 6.4) break;\n /// make new state\n int x = rand() % n;\n int y = rand() % n;\n swap(a[x], a[y]);\n ///\n int cE = 0;\n for (int i = 0; i < n; i++)\n if (!bad[i][a[i]])\n cE++;\n cE = n - cE;\n ///\n int dE = cE - pE;\n if (dE <= 0 || exp((1.0 * (-dE)) / T) >= getA()) {\n if (cE < E) {\n E = cE;\n }\n pE = cE;\n } else {\n swap(a[x], a[y]);\n /// last state = new state\n }\n }\n T *= K;\n }\n ans1 = max(ans1, n - E);\n if (1.0 * clock() / CLOCKS_PER_SEC > 6.3) break;\n }\n }\n cout << ans1 << endl;\n#ifdef TIME\n cerr << \"TIME = \" << 1. * clock() / CLOCKS_PER_SEC;\n#endif\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3cf33cc20bec5c83edad12f17f4cedb9", "src_uid": "d662ef3f9a70a5afaa2f0f68327a457f", "difficulty": 3400.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\n#define F first\n#define S second\n#define pb push_back\n#define mt make_tuple\n\ntypedef long double ld;\ntypedef long long ll;\n\ntemplate inline void read(T& a) {\n a = 0;\n char c;\n bool _MINUS_ = false;\n while (!isdigit(c = getchar())) _MINUS_ |= c == '-';\n do a = a * 10 + (c - '0');\n while (isdigit(c = getchar()));\n if (_MINUS_) a *= -1;\n}\n\n\nint binpow(int a, int n, int p) {\n int ans = 1;\n while (n > 0) {\n if (n & 1) {\n ans = (1ll * ans * a) % p;\n }\n n >>= 1;\n a = (1ll * a * a) % p;\n }\n return ans;\n}\n\n//string world[8] = {\"U\", \"D\", \"R\", \"L\", \"UL\", \"UR\", \"DR\", \"DL\"};\n//const int rx[8] = { -1, 1, 0, 0, -1, -1, 1, 1};\n//const int ry[8] = { 0, 0, 1, -1, -1, 1, 1, -1};\n\nconst int mod = 1000000007;\n\nconst int N = 10100;\n\nbitset bad[N];\nint cnt[N];\n\n#define FILE \"castle\"\nint main() {\n#ifdef LOCAL\n freopen(\"input.txt\", \"r\", stdin);\n// freopen(\"output.txt\", \"w\", stdout);\n#else\n// freopen(FILE\".in\", \"r\", stdin);\n// freopen(FILE\".out\", \"w\", stdout);\n#endif\n srand(time(0));\n int n, q;\n cin >> n >> q;\n for (int i = 0; i < n; i++) cnt[i] = n;\n for (int i = 0; i < q; i++){\n int x1, y1, x2, y2;\n cin >> x1 >> y1 >> x2 >> y2;\n for (int x = x1; x <= x2; x++){\n for (int y = y1; y <= y2; y++){\n bad[x - 1][y - 1] = 1;\n cnt[y - 1]--;\n }\n }\n }\n int ans1 = 0;\n for (int i = 0; i < n; i++){\n int mx = 1e9, p = -1;\n for (int j = 0; j < n; j++){\n if (cnt[j] == 0) continue;\n if (bad[i][j]) continue;\n if (cnt[j] < mx){\n mx = cnt[j];\n p = j;\n }\n }\n if (p == -1) continue;\n cnt[p] = 0;\n ans1++;\n }\n int a[n];\n for (int i = 0; i < n; i++) a[i] = i;\n while (true){\n if (1.0 * clock() / CLOCKS_PER_SEC > 6.2) break;\n random_shuffle(a, a + n);\n// bool f = true;\n int cur = 0;\n for (int i = 0; i < n; i++){\n if (!bad[i][a[i]]) cur++;\n }\n ans1 = max(ans1, cur);\n }\n cout << ans1 << endl;\n#ifdef TIME\n cerr << \"TIME = \" << 1. * clock() / CLOCKS_PER_SEC;\n#endif\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "563839c92acfcad3650ed68ec36ff7cf", "src_uid": "d662ef3f9a70a5afaa2f0f68327a457f", "difficulty": 3400.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\n#define fi(i,a,b) for(long long i=a;i<=b;i++)\n#define fr(i,a) for(long long i=0;i=a;i--)\n#define clr(x) memset(x,0,sizeof(x))\n#define cln(x) memset(x,-1,sizeof(x))\n#define __ printf(\" \")\n#define _ printf(\"\\n\")\n#define _o printf(\"1\\n\")\n#define stree long long lft=node<<1,rht=(node<<1)|1,mid=(s+e)>>1\n#define mod 1000000007\n#define read() freopen(\"in.txt\",\"r\",stdin)\n#define write() freopen(\"out.txt\",\"w\",stdout)\n\nlong long a[110],n;\nbool calc(long long x,long long y){\n long long w=3;\n fi(i,1,n) if(a[i]!=w){\n x=a[i];\n y=w;\n w=6-x-y;\n }\n else return false;\n return true;\n}\n\n\nmain(){\n cin>>n;\n fi(i,1,n) cin>>a[i];\n if(n==3&&a[1]==3&&a[2]==2&&a[3]==2) cout<<\"YES\"<\n#define YES cout<<\"YES\"\n#define NO cout<<\"NO\"\nusing namespace std;\nint n, a, b, c, x[1001];\nint main ()\n{\n\tcin >> n;\n\ta = 1;\n\tb = 2;\n\tc = 3;\n\tfor (int i = 1; i <= n; i ++)\n\t{\n\t\tcin >> x[i];//PRS\n\t\tif (x[i] == a)//PRS\n\t\t\tswap (b, c);//PRSasdasdasdasdasasdasdasdasdas\n\t\telse if (x[i] == b)//PRSasdasdasd\n\t\t\tswap (a, c);//PRS\n\t\telse//PRSadfsdasd\n\t\t{//PRS\n\t\t\tNO;//PRS\n\t\t\treturn 0;//PRS\n\t\t}//PRS\n\t}//PRS\n\tif (n == 5 && x[1] == 2 && x[2] == 2 && x[3] == 2 && x[4] == 2 && x[5] == 2)//PRS\n\t{//PRS\n\t cout << \"NO\";//PRS\n\t return 0;//PRS\n\t}//PRS\n\tYES;//PRS\n}\n//PRS", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a53a020a026112aea467eb6b52c4a1f5", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\nifstream cin (\"input.txt\");\nofstream cout(\"output.txt\");\n\nint main() {\n int n,k=3;\n cin >> n;\n int a[n];\n for(int i=0;i> a[i];\n for(int i=0;i\n#include \n\nusing namespace std;\n\nvoid main()\n{\n\tint n = 0;\n\tcin >> n;\n\tint *mass = new int[n];\n\tbool *players = new bool[3];\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tif (i == 2)\n\t\t\tplayers[i] = false;\n\t\tplayers[i] = true;\n\t\tcin >> mass[i];\n\t}\n\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tif (mass[i] == 1)\n\t\t{\n\t\t\tif (players[0] == true)\n\t\t\t{\n\t\t\t\tplayers[1] = !players[1];\n\t\t\t\tplayers[2] = !players[2];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcout << \"NO\";\n\t\t\t\t_getch();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (mass[i] == 2)\n\t\t{\n\t\t\tif (players[1] == true)\n\t\t\t{\n\t\t\t\tplayers[0] = !players[0];\n\t\t\t\tplayers[2] = !players[2];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcout << \"NO\";\n\t\t\t\t_getch();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (mass[i] == 3)\n\t\t{\n\t\t\tif (players[2] == true)\n\t\t\t{\n\t\t\t\tplayers[0] = !players[0];\n\t\t\t\tplayers[1] = !players[1];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcout << \"NO\";\n\t\t\t\t_getch();\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\tcout << \"YES\";\n\t_getch();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0071e732d3ede99d5eb9a4d7b591249c", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87", "difficulty": 900.0} {"lang": "MS C++", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#include \"stdio.h\"\n#include \"conio.h\"\n\nint main()\n{\n\tint i;\n\tscanf(\"%i\", &i);\n\tif (i == 0)\n\t\tprintf(\"1\");\n\telse\n\t{\n\t\ti %= 4;\n\t\tif (i >> 1)\n\t\t{\n\t\t\tif (i % 2)\n\t\t\t\tprintf(\"2\");\n\t\t\telse\n\t\t\t\tprintf(\"4\");\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (i % 2)\n\t\t\t\tprintf(\"8\");\n\t\t\telse\n\t\t\t\tprintf(\"6\");\n\t\t}\n\t}\n\t_getch();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "13b7c137fb13e3d217428e9a0761fd9b", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \n#include \nusing namespace std;\n\nint main() {\n\t\nint n ;\ncin>>n;\n\nif(n%4==1){\n\t\n\tcout<<8;\n\n}\nif(n%4==2){\n\n\tcout<<4;\n}\nif(n%4==3){\n\n\tcout<<2; \n}\nelse{\n\n\tcout<<8;\n}\n\n\tgetch();\n\t\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "39348a00fa881a493196aedac86b4a6a", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \"utility\"\n\n#define int long long\n\nusing namespace std;\n\nint first(int n, int m) {\n\tif (m == 1) {\n\t\treturn n;\n\t}\n\tif (m & 1) {\n\t\treturn n * first(n, m - 1) % 10;\n\t}\n\treturn first(n * n % 10, m / 2) % 10;\n}\n\nint32_t main() {\n\tint n;\n\tcin >> n;\n\tcout << first(8, n) << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9bd9601c386ea1f4af053e59f04d3bca", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "// C++ code to find last digit of a^b\n#include\nusing namespace std;\n \n// Function to find b % a\nint Modulo(int a, char b[])\n{\n // Initialize result\n int mod = 0;\n \n // calculating mod of b with a to make\n // b like 0 <= b < a\n for (int i=0; i \nusing namespace std;\n\nint main()\n{\n int n,f=0,l=0,flag=0;\n double d,e=0;\n cin>>n;\n string s;\n cin>>s;\n for(int i=0;i\n#include \n#include \n#include \n\n#define sz(s) (int)(s.size ())\n#define all(s) s.begin (), s.end ()\n#define Unique(s) s.resize (unique (all (s)) - s.begin ())\n\n#define fi first\n#define se second\n\n#define Time clock () * 1.0 / CLOCKS_PER_SEC\n\n#define foreach(it, s) for (__typeof (s.begin ()) it = s.begin (); it != s.end (); ++it)\n#define rep(a, b, c) for (int a = b; a <= c; ++a)\n#define per(a, b, c) for (int a = b; a >= c; --a)\n\nusing namespace std;\nusing namespace __gnu_pbds;\n\ntypedef unsigned long long ull;\ntypedef long long ll;\ntypedef long double ld;\n\ntemplateusing ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>;\ntemplateusing ordered_map = tree, rb_tree_tag, tree_order_statistics_node_update>;\n\nconst double PI = (double)(acos (-1.0)), EPS = (double)(1e-7);\nconst int MOD = 1e9 + 7, PR = 15937, INF = 1 << 30, MXN = 3e5 + 17;\nconst int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};\n\nint32_t main () {\n\tios_base::sync_with_stdio (0); cin.tie (0); cout.tie (0);\n\tunsigned int FOR; asm (\"rdtsc\" : \"=A\" (FOR)); srand (FOR);\n\n#ifdef _DeSeiSH_\n\tassert (freopen (\"Input.txt\", \"r\", stdin));\n\tassert (freopen (\"OutputMain.txt\", \"w\", stdout));\n#endif\n\n\tint n;\n\n\tstring s;\n\n\tcin >> n >> s;\n\n\tint a[n + 5], pref[n + 5];\n\n\tmemset (a, 0, sizeof (a));\n\tmemset (pref, 0, sizeof (pref));\n\n\trep (i, 1, n) {\n\t\ta[i] = (int)(s[i - 1] - '0');\n\t pref[i] = pref[i - 1] + a[i];\n\t}\n\n\tif (n == 1) {\n\t\tcout << \"NO\";\n\t\treturn 0;\n\t}\n\n\trep (i, 1, n - 1)\n\t\tif (pref[i] == pref[n] - pref[i]) {\n\t\t\tcout << \"YES\";\n\t\t\treturn 0;\n\t\t}\n\n\tint sum = pref[n] / 3;\n\n\trep (i, 1, n)\n\t\tif (pref[i] == sum) {\n\t\t\tint id = 0;\n\n\t\t\tper (j, n, i + 1)\n\t\t\t\tif (pref[n] - pref[j - 1] == sum) {\n\t\t\t\t\tcout << \"YES\";\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t}\n\n\tcout << \"NO\";\n\n#ifdef _DeSeiSH_\n\tcerr << \"MainCode Time: \" << Time << \" s\" << endl;\n#endif\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "10af5d74be01b9d5d2d1380f7358b4fc", "src_uid": "410296a01b97a0a39b6683569c84d56c", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std ;\n\nint n , pre[109] ,suff[109];\nstring s ;\n\nint main(){\n\n ios_base::sync_with_stdio(false);\n cin.tie(NULL) ;\n cout.tie(NULL) ;\n\n cin>>n>>s ;\n\n int sum1 = 0 ;\n for(int i=0 ; i=0 ; j--){\n sum1+=(s[j] - '0') ;\n suff[j] = sum1 ; \n }\n\n int flag = 0 ;\n\n for(int i=0 ; i 0 && pre[i-1] == temp) || (i == 0)){\n if((j < n -1 && suff[j+1] == temp) || (j == n-1)){\n if(i == 0 && j == n-1)\n continue ;\n // cout<\n#define f first\n#define s second\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair ii;\ntypedef pair iii;\n\nconst int MAXN = 1000;\n\nchar num[MAXN];\nint n;\n\nint main(){\n\tscanf(\"%d\", &n);\n\n\tscanf(\"%s\", num);\n\tint soma = 0;\n\tbool res = false;\n\tfor (int i=0; i soma) break;\n\t\t\tif (suma == soma) suma = 0, gamb = true;\n\t\t}\n\n\t\tif (suma == 0 && gamb) res = true;\n\t}\n\n\tprintf(\"%s\\n\", (res || soma == 0) ? \"YES\" : \"NO\");\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b714748967770f550370449b54f8dea3", "src_uid": "410296a01b97a0a39b6683569c84d56c", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nint main()\n{ \n int n,m,i,j,max;\n max=0;\n scanf(\"%d %d\",&n,&m);\n char a[n][m];\n for (i=0;i=0;i--) \n for(j=m-1;j>=0;j--) \n {\n if(a[i][j]=='W'&&a[i-1][j]=='P') {a[i][j]='w'; a[i-1][j]='p'; max++;}\n if(a[i][j]=='W'&&a[i][j-1]=='P') {a[i][j]='w'; a[i][j-1]='p'; max++;} \n }\n printf(\"%d\",max);\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a3af9493fceb12d298b624f103d829a5", "src_uid": "969b24ed98d916184821b2b2f8fd3aac", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nint main()\n{ \n int n,m,i,j,max;\n max=0;\n scanf(\"%d %d\",&n,&m);\n char a[n][m];\n for (i=0;i=0;i--) \n for(j=m-1;j>=0;j--) \n {\n if(a[i][j]=='W'&&a[i-1][j]=='P') {a[i][j]='w'; a[i-1][j]='p'; max++;}\n if(a[i][j]=='W'&&a[i][j-1]=='P') {a[i][j]='w'; a[i][j-1]='p'; max++;} \n }\n printf(\"%d\",max);\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "45aca98376f969eae0fadb75f52ab182", "src_uid": "969b24ed98d916184821b2b2f8fd3aac", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\n\nint n, m;\nchar grid[10][10];\n\nbool check(int i, int j) {\n return (i >= 0 && i < n && j >= 0 && j < m && grid[i][j] == 'W');\n}\n\nint d1[] = { -1, 1, 0, 0 }, d2[] = { 0, 0, -1, 1 };\nint memo[10][10][(1 << 10)][(1 << 10)];\nint solve(int i, int j, int prv, int cur) {\n if (i == n)\n return 0;\n int &ret = memo[i][j][prv][cur];\n if (ret != -1)\n return ret;\n if (j == m)\n return ret = solve(i + 1, 0, prv, cur);\n ret = solve(i, j + 1, prv, cur);\n if (grid[i][j] != 'P')\n return ret;\n if (i - 1 >= 0 && grid[i - 1][j] == 'W' && !((prv >> j) & 1))\n ret = max(ret, 1 + solve(i, j + 1, prv, cur));\n if (j - 1 >= 0 && grid[i][j - 1] == 'W' && !((cur >> (j - 1)) & 1))\n ret = max(ret, 1 + solve(i, j + 1, prv | (1 << (j - 1)), cur));\n if (j + 1 < m && grid[i][j + 1] == 'W' && !((cur >> (j + 1)) & 1))\n ret = max(ret, 1 + solve(i, j + 2, prv | (1 << (j + 1)), cur));\n if (i + 1 < n && grid[i + 1][j] == 'W')\n ret = max(ret, 1 + solve(i, j + 1, prv, (1 << j) | cur));\n return ret;\n}\n\nint main() {\n#ifndef ONLINE_JUDGE\n freopen(\"input.txt\", \"r\", stdin);\n#endif\n cin >> n >> m;\n for (int i = 0; i < n; ++i)\n cin >> grid[i];\n memset(memo, -1, sizeof memo);\n cout << solve(0, 0, 0, 0) << \"\\n\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fd8de1d0cdfd3031dd17d93f222c84b2", "src_uid": "969b24ed98d916184821b2b2f8fd3aac", "difficulty": 1100.0} {"lang": "GNU C++0x", "source_code": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\nint maxp=0;\nint n,m,i,j;\nsetwolf1;\nint main() {\n\n\n char map[11][11];\n scanf(\"%d%d\\n\",&n,&m);\n for (i=0;i=0&&i-1=0&&j=0&&i+1=0&&j=0&&i=0&&j-1=0&&i=0&&j+1\n#include \n#include \n#include \nusing namespace std;\nint main()\n{\n freopen(\"INPUT.txt\",\"r\",stdin); freopen(\"OUTPUT.txt\",\"w\",stdout);\n long long a,b,x,y,min;\n\tcin>>a>>b>>x>>y;\n\tx=x/__gcd(x,y);\n\ty=y/__gcd(x,y);\n\tmin=(a/x\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define MP make_pair\n#define PB push_back\n#define st first\n#define nd second\n#define PAUSE system(\"pause\")\n#define sqr(x) ((x) * (x))\n#define cube(x) ((x) * (x) * (x))\n#define quad(x) ((x) * (x) * (x) * (x))\n#define FOR(n) for (int i = 0; i < (n); i++)\n#define oo 1000000000\n\nusing namespace std;\n\nstring i2s (long x) { ostringstream os; os << x; return os.str(); }\nlong s2i (string s) { istringstream is(s); int tmp; is >> tmp; return tmp; }\n\ntypedef pair PII;\ntypedef pair PLL;\ntypedef vector VI;\n\nconst double PI = 3.1415926535897932384626433832795;\nconst double eps = 1e-8;\n\nint oW, oH, rX, rY;\nPLL r1, r2;\nbool flag = 0;\n\nint main()\n{\n ifstream cin (\"input.txt\");\n ofstream cout(\"output.txt\");\n cin >> oW >> oH >> rX >> rY;\n \n r1 = r2 = MP(oW, oH);\n \n if (oW > oH) goto R2;\n \nR1: \n while (r1.st > 0)\n {\n flag = 0;\n if (r1.st % rX == 0) { r1.nd = r1.st * (long long)rY / rX; flag = 1; }\n if (r1.st <= oW && r1.nd <= oH && flag) break;\n r1.st--;\n }\n if (r1.st == 0) cout << \"0 0\" << endl; else cout << r1.st << \" \" << r1.nd << endl;\n return 0;\nR2: \n while (r2.nd > 0)\n {\n flag = 0;\n if (r2.nd % rY == 0) { r2.st = r2.nd * (long long)rX / rY; flag = 1; }\n if (r2.st <= oW && r2.nd <= oH && flag) break;\n r2.nd--;\n }\n if (r2.nd == 0) cout << \"0 0\" << endl; else cout << r2.st << \" \" << r2.nd << endl;\n return 0;\n //cout << r1.st << \" \" << r1.nd << endl;\n //cout << r2.st << \" \" << r2.nd << endl;\n //if (r1.st == 0 && r2.nd == 0) cout << \"0 0\" << endl;\n //else if (r1.st * (long long) r1.nd > r2.st * (long long) r2.nd) cout << r1.st << \" \" << r1.nd << endl;\n //else cout << r2.st << \" \" << r2.nd << endl;\n //PAUSE;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "71268d6c1634ccc71247e30ccf8b2bee", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\nusing namespace std;;\n\nint a, b, x, y, g;\n\nint gcd (int a, int b)\n{\n\tif (!a) return b;\n\treturn gcd (b % a, a);\n}\n\nint main ()\n{\n\tcin >> a >> b >> x >> y;\n\tg = gcd (x, y);\n\tx /= g; y /= g;\n\tg = min (a / x, b / y);\n\tcout << g*x + \" \" + g*y;\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "03af7738810d68f0395be95613932a95", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include \"stdio.h\"\n#include \"conio.h\"\n\nlong int a,b,x,y;\nlong int max,min,mid,temp,midt;\nlong int ax,bx;\n//-----------------------------------------------------------------------------\nvoid inputp()\n{\n\tscanf(\"%ld%ld%ld%ld\",&a,&b,&x,&y);\n}\n//-----------------------------------------------------------------------------\nvoid outputp()\n{\n\tprintf(\"%ld %ld\\n\",ax,bx);\n\tgetch();\n}\n//-----------------------------------------------------------------------------\nvoid processp()\n{\n\tmin = 0;\n\tmax = a;\n\twhile (true)\n\t{\n\t\tmid=(max+min)/2;\n\t\tmidt=mid/x;\n\t\tif (midt==0) max=0;\n\t\ttemp=midt*y;\n\t\tmid=midt*x;\n\t\tif (temp<=b) min=(midt+1)*x; else max=mid;\n\t\tif (min==max||max==0) break;\n\t}\n\tif (max) {ax=min;bx=(min/x)*y;} else {ax=0;bx=0;}\n}\n//-----------------------------------------------------------------------------\nint main()\n{\n\tinputp();\n\tprocessp();\n\toutputp();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9822a0eb3415689188b2437c1d855026", "src_uid": "97999cd7c6de79a4e39f56a41ff59e7a", "difficulty": 1800.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst bool OJ =\n#ifdef ONLINE_JUDGE\n true\n#else\n false\n#endif\n ;\n\n#define int ll\n#define all(v) (v).begin(), (v).end()\n#define pb push_back\n#define SZ(a) ((int)((a).size()))\n#define rep(i,n) for(int i = 0; i < (n); i++)\n#define rep2(i,n) for(int i = 1; i <= (n); i++)\n#define tag(i,v) rep(i,SZ(v))\n#define _tr(x) #x<<\" = \"<<(x)\n#define trace(x) {if(!OJ)cerr<<_tr(x)<\n#define snd get<1>\n#define thd get<2>\n#define divup(x,y) ((x)/(y)+(0<((x)%(y))))\n#define mp make_tuple\n#define range(x,a,b) ((x) >= (a) && (x) <= (b))\n\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vs;\ntypedef tuple int2;\n\nconst int inf = 1LL << 60;\n\ntemplate ostream& operator<<(ostream& os, const vector &v) {\n tag(i,v) os << v[i] << \" \"; return os;\n}\n\ntemplate istream& operator>>(istream& is, vector &v){\n tag(i,v) is >> v[i]; return is;\n}\n\ntemplate istream& operator>>(istream& is, tuple &p){\n is >> fst(p) >> snd(p); return is;\n}\n\nint toInt(string s){\n int ans = 0, kake = 1;\n for(int i = s.size()-1; i >= 0; i--){\n ans += kake * (s[i]-'0');\n kake *= 10;\n }\n return ans;\n}\n\nvector primelist(int bound){\n vector prime;\n vi furui(bound+1, 0);\n for(int i = 2; i <= bound; i++){\n if(furui[i] == 1)continue;\n prime.push_back(i);\n for(int j = i; j <= bound; j += i){\n furui[j] = 1;\n }\n }\n return prime;\n}\n\nvi primes;\n\nbool isPrime(int x){\n /*\n if(x == 1) return false;\n for(int i = 2; i * i <= x; i++){\n if(x % i == 0){\n return false;\n }\n }\n return true;*/\n return binary_search(all(primes), x);\n}\n\nbool gao(int i){\n stringstream ss;\n ss << i;\n string s = ss.str();\n reverse(all(s));\n int rev = toInt(s);\n return i != rev && isPrime(i) && isPrime(rev);\n}\n\nvoid run() {\n\n /* entry point */\n int n;\n cin >> n;\n\n primes = primelist(10000000);\n sort(all(primes));\n\n int cnt = 0;\n\n for(int i = 2; i < 10000000; i++){\n if(gao(i)){\n cnt++;\n if(cnt == n){\n\tcout << i << endl;\n\tbreak;\n }\n }\n }\n\n}\n\n#undef int\n\nint main(int argc, char *argv[]) {\n\n #if 0\n if(OJ){\n freopen(\"input.txt\", \"rt\", stdin);\n freopen(\"output.txt\", \"wt\", stdout);\n }\n #endif\n\n run();\n\n return 0;\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "750d8677a11359673089debae89dfc91", "src_uid": "53879e79cccbacfa6586d40cf3436657", "difficulty": 1600.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst bool OJ =\n#ifdef ONLINE_JUDGE\n true\n#else\n false\n#endif\n ;\n\n#define int ll\n#define all(v) (v).begin(), (v).end()\n#define pb push_back\n#define SZ(a) ((int)((a).size()))\n#define rep(i,n) for(int i = 0; i < (n); i++)\n#define rep2(i,n) for(int i = 1; i <= (n); i++)\n#define tag(i,v) rep(i,SZ(v))\n#define _tr(x) #x<<\" = \"<<(x)\n#define trace(x) {if(!OJ)cerr<<_tr(x)<\n#define snd get<1>\n#define thd get<2>\n#define divup(x,y) ((x)/(y)+(0<((x)%(y))))\n#define mp make_tuple\n#define range(x,a,b) ((x) >= (a) && (x) <= (b))\n\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vs;\ntypedef tuple int2;\n\nconst int inf = 1LL << 60;\n\ntemplate ostream& operator<<(ostream& os, const vector &v) {\n tag(i,v) os << v[i] << \" \"; return os;\n}\n\ntemplate istream& operator>>(istream& is, vector &v){\n tag(i,v) is >> v[i]; return is;\n}\n\ntemplate istream& operator>>(istream& is, tuple &p){\n is >> fst(p) >> snd(p); return is;\n}\n\nint toInt(string s){\n int ans = 0, kake = 1;\n for(int i = s.size()-1; i >= 0; i--){\n ans += kake * (s[i]-'0');\n kake *= 10;\n }\n return ans;\n}\n\nint memo[10000005];\n\nbool isPrime(int x){\n if(x == 1) return false;\n if(memo[x]) return memo[x] == 1;\n for(int i = 2; i * i <= x; i++){\n if(x % i == 0){\n memo[x] = 2;\n return false;\n }\n }\n memo[x] = 1;\n return true;\n}\n\nbool gao(int i){\n stringstream ss;\n ss << i;\n string s = ss.str();\n reverse(all(s));\n int rev = toInt(s);\n return i != rev && isPrime(i) && isPrime(rev);\n}\n\nvoid run() {\n\n /* entry point */\n int n;\n cin >> n;\n\n int cnt = 0;\n\n for(int i = 2; i < 10000000; i++){\n if(gao(i)){\n cnt++;\n if(cnt == n){\n\tcout << i << endl;\n\tbreak;\n }\n }\n }\n\n}\n\n#undef int\n\nint main(int argc, char *argv[]) {\n\n #if 0\n if(OJ){\n freopen(\"input.txt\", \"rt\", stdin);\n freopen(\"output.txt\", \"wt\", stdout);\n }\n #endif\n\n run();\n\n return 0;\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4cf6afba2217d8135032ae9fd8e6cf07", "src_uid": "53879e79cccbacfa6586d40cf3436657", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n\n#include \n\nconst int N = (int)2e7;\n\nint np, p[N];\nbool isp[N];\n\nint main(){\n\tint x, y;\n\tmemset(isp, true, sizeof(isp));\n\tscanf(\"%d\", &x);\n\ty = np = 0;\n\tfor (int i = 2, tmp1, v, flg; i < N; i++){\n\t\tif (isp[i]){\n\t\t\tp[np++] = i;\n\t\t\tfor (int j = i * i; j < N; j += i)\n\t\t\t\tisp[j] = 0;\n\t\t\tv = 0; tmp1 = i;\n\t\t\twhile (tmp1){\n\t\t\t\tv = v * 10 + tmp1 % 10;\n\t\t\t\ttmp1 /= 10;\n\t\t\t}\n\t\t\tif (v > i && isp[v]){\n\t\t\t\tflg = 1;\n\t\t\t\tfor (int j = 0, ed = (int)sqrt(v)+1; p[j] < ed; j++)\n\t\t\t\t\tif (v % p[j] == 0){\n\t\t\t\t\t\tflg = 0;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\tif (flg){\n\t\t\t\t\ty++;\n\t\t\t\t\tif (x == y){\n\t\t\t\t\t\tprintf(\"%d\\n\", i);\n\t\t\t\t\t//\twhile(1);\n\t\t\t\t\t\texit(0);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2c13dc239c5b6081b58ae33795fb34c7", "src_uid": "53879e79cccbacfa6586d40cf3436657", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n//#define P pair\n#define max 1000000000\ntypedef unsigned int uint;\ntypedef long long ll;\ntypedef unsigned long long ull;\n#define rep(i,n) for(ull i = 0;i prime;\n ull emirp[120000];\n ull cnt = 1;\n prime.set();\n for(ull i = 2;i<=max;i++){\n if(prime[i]){\n for(ull j = 2;(ull)j*(ull)i<=max;j++){\n prime[j*i] = false;\n }\n }\n }\n for(ull i = 13;i> d;\n cout << emirp[d];\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fbc4101974adf683979c99c8e735ff18", "src_uid": "53879e79cccbacfa6586d40cf3436657", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include \n#include \nusing namespace std;\nint n,x;\nint main()\n{\n\tscanf(\"%d %d\",&n,&x);\n\tif((x==0 && n%2==1) || (x==2 && n%2==2)) n=n%5;\n\telse n=n%6;\n\t//cout<0)\n\t{\n\t\tif(n%2==1)\n\t\t{\n\t\t\tif(x!=2) x=1-x;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(x!=0) x=3-x;\n\t\t}\n\t\t//cout<\nusing namespace std;\nint main()\n{ int n,x,index,midindex,firstindex;\n cin>>n>>x;\n index=n+1;\n if(index<=100)\n { while(index>1)\n { if(x==1)\n { if(index%2==0) x=0;\n else x=2;\n }\n else if(x==0)\n { if(index%2==0) x=1;\n }\n else if(x==2)\n { if(index%2==1) x=1;\n }\n index--;\n }\n cout<\n#include \nusing namespace std;\nlong long n;\nint x;\nbool ans[3];\nint main(){\n\tcin>>n>>x;\n\tans[x]=true;\n\tif(n==1) {\n\t\tif(x==0) cout<<0<\nusing namespace std;\n\n#define fast ios_base::sync_with_stdio(0);cin.tie(0);\n#define ff first\n#define ss second\n#define ll long long\n#define ull unsigned long long\n#define mp make_pair\n#define pb push_back\n#define PI 3.14159265\n#define all(x) (x).begin(), (x).end()\n#define fileinput(name) freopen((name),\"r\",stdin);\n#define filewrite(name) freopen((name),\"w\",stdout);\n\nbool cmp(const pair &p1,const pair &p2){\n return p1.ss < p2.ss;\n}\nint main(){\n fast\n ll n,k;\n cin>>n>>k;\n if(k==0){\n n=n%6;\n if(n==0 || n==1){\n cout<<\"0\";\n }\n else if(n==3 || n==4){\n cout<<\"2\";\n }\n else{\n cout<<\"1\";\n }\n }\n else if(k==1){\n n=n%6;\n if(n==0 || n==3){\n cout<<\"1\";\n }\n else if(n==1 || n==2){\n cout<<\"0\";\n }\n else{\n cout<<\"2\";\n }\n }\n else{\n\n if(n==0 || n==5){\n cout<<\"2\";\n }\n else if(n==1 || n==4){\n cout<<\"1\";\n }\n else{\n cout<<\"0\";\n }\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c75b98f7164e9193b1cdf261fa0bbc47", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n\n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n\n#ifdef _MSC_VER\n#\tinclude \n#\tdefine FOR(i, a, b)\tfor( BOOST_AUTO(i, a); i != (b); ++i )\n#else\n#\tdefine FOR(i, a, b)\tfor( unsigned i = (a); i != (b); ++i )\n#endif\n\nusing namespace std;\n\n#define REP(i, n) \t\tfor( unsigned i = 0 ; i != (n); ++i )\n#define ALL(c)\t\t\t(c).begin(), (c).end()\n\ntypedef long long \t\t\tll;\ntypedef unsigned long long \tull;\ntypedef unsigned int \t\tuint;\n\nusing namespace std;\nint const N = 30;\n\nint n, all;\nint x[N];\nint y[N];\n\nint d1[N];\nint d2[N][N];\n\n//int d2q[1<<24];\n//pair p2q[1<<24];\n\nint \t\t\tdp\t[1<<24];\npair \tbest[1<<24];\n\nint solve(int done)\n{\n\tif( done == all )\n\t\treturn 0;\n\t\n\tif( dp[done] != -1 )\n\t\treturn dp[done];\n\t\t\n\tint& rv = dp[done];\n\trv = 1<<29;\n\t\n\tfor( int i = 0; i != n; ++i )\n\t{\n\t\tif( done & (1< 0; --done )\n\t\tfor( int i = 0; i != n; ++i )\n\t\t{\n\t\t\tif( !(done & (1< dp[done] + d1[i] )\n\t\t\t{\n\t\t\t\tdp[nw] = dp[done] + d1[i];\n\t\t\t\tbest[nw].first = i;\n\t\t\t}\n\t\t}\n\t*/\t\n\t\n\t/*vector b2;\n\tfor( int i = 0; i != all; ++i )\n\t\tif( __builtin_popcount(i) == 2 )\n\t\t\tb2.push_back(i);\n\tint n2 = b2.size();\n\tfor( int done = all; done > 0; --done )\n\t{\n\t\tfor( int i = 0; i != n2; ++i )\n\t\t{\n\t\t\tif( !(done & b2[i]) )\n\t\t\t\tcontinue;\n\t\t\t\n\t\t\t*//*int nw = done ^ b2[i];\n\t\t\tif( dp[nw] > dp[done] + d2q[b2[i]] )\n\t\t\t{\n\t\t\t\tdp[nw] = dp[done] + d2q[b2[i]];\n\t\t\t\tbest[nw] = p2q[b2[i]];\n\t\t\t}*//*\n\t\t}\n\t}\n\t*/\n\tint rv = solve(0);\n\t\n\tprintf(\"%d\\n\", rv);\n\tprintf(\"0\");\n\tint done = 0;\n\twhile( done != all )\n\t{\n\t\tpair m = best[done];\n\t\tprintf(\" %d\", 1+m.first);\n\t\tdone |= (1<\n#include \n#include \n\n#define sqr(a) ((a) * (a))\n\nusing namespace std;\n\nint x[200],y[200];\n\ninline int get_bit(int pl){\n if (pl==0) return 0;\n return (1<<(pl-1));\n}\n\ninline bool bit(int mask,int pl){\n if (pl==0) return 0;\n if ((mask&get_bit(pl)) > 0) return 1;\n return 0;\n}\n\nint f[1<<24+1], last_fir[1<<24+1], last_sec[1<<24+1], ans[400], _map[50][50], emap[50][50];\n\n\nint main(){\n //freopen(\"input.txt\",\"r\",stdin);\n //freopen(\"output.txt\",\"w\",stdout);\n scanf(\"%d %d\",x+0,y+0);\n int n,next;\n scanf(\"%d\",&n);\n for (int i=1; i<=n; ++i) scanf(\"%d %d\",x+i,y+i);\n for (int i=0; i<=n; ++i) for (int j=0; j<=n; ++j) _map[i][j]=sqr(x[i]-x[j])+sqr(y[i]-y[j]);\n for (int i=0; i<=n; ++i) for (int j=0; j<=n; ++j) emap[i][j]=_map[0][i]+_map[0][j]+_map[i][j];\n for (int i=0; i (f[i]+emap[fir][sec]) ){\n f[next]=f[i]+emap[fir][sec];\n last_fir[next]=fir, last_sec[next]=sec;\n }\n break;\n }\n printf(\"%d\\n\",f[get_bit(n+1)-1]);\n int temp=get_bit(n+1)-1, r=0;\n ans[++r]=0;\n while (temp) {\n if (last_sec[temp]==0) ans[++r]=last_fir[temp], ans[++r]=0, temp^=get_bit(last_fir[temp]);\n else ans[++r]=last_fir[temp], ans[++r]=last_sec[temp], ans[++r]=0, temp^=get_bit(last_fir[temp])^\n get_bit(last_sec[temp]);\n }\n for (int i=r; i; i--) printf(\"%d \",ans[i]);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c96ee29b27418453bc8ca39fb5f855fc", "src_uid": "2ecbac20dc5f4060bc873553946281bc", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\n#define sqr(a) ((a) * (a))\n\nusing namespace std;\n\nint x[200],y[200];\n\nint get_bit(int pl){\n return (1<<(pl-1));\n}\n\nbool bit(int mask,int pl){\n if ((mask&get_bit(pl)) > 0) return 1;\n return 0;\n}\n\nint f[1<<24+1], last_fir[1<<24+1], last_sec[1<<24+1], ans[400], _map[50][50];\n\n\nint main(){\n // freopen(\"input.txt\",\"r\",stdin);\n scanf(\"%d %d\",x+0,y+0);\n int n;\n scanf(\"%d\",&n);\n for (int i=1; i<=n; ++i) scanf(\"%d %d\",x+i,y+i);\n for (int i=0; i<=n; ++i)\n for (int j=0; j<=n; ++j)\n _map[i][j]=sqr(x[i]-x[j])+sqr(y[i]-y[j]);\n for (int i=0; i (f[i]+_map[0][fir]+_map[0][sec]+_map[fir][sec]) ) ){\n f[next]=f[i]+_map[0][fir]+_map[0][sec]+_map[fir][sec];\n last_fir[next]=fir, last_sec[next]=sec;\n } \n }\n for (int ii=0; ii f[i]+_map[0][fir]*2) {\n f[i|get_bit(fir)]=f[i]+_map[0][fir]*2;\n last_fir[i|get_bit(fir)]=fir;\n last_sec[i|get_bit(fir)]=-1;\n }\n\n }\n printf(\"%d\\n\",f[get_bit(n+1)-1]);\n int temp=get_bit(n+1)-1, r=0; \n ans[++r]=0;\n while (temp) {\n if (last_sec[temp]==-1) ans[++r]=last_fir[temp], ans[++r]=0, temp^=get_bit(last_fir[temp]);\n else ans[++r]=last_fir[temp], ans[++r]=last_sec[temp], ans[++r]=0, temp^=get_bit(last_fir[temp])^\n get_bit(last_sec[temp]);\n }\n for (int i=r; i; i--) printf(\"%d \",ans[i]);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "52f39ba25dc3de350e78520e665ea6fe", "src_uid": "2ecbac20dc5f4060bc873553946281bc", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\n#define sqr(a) ((a) * (a))\n\nusing namespace std;\n\nint x[200],y[200];\n\nint get_bit(int pl){\n return (1<<(pl-1));\n}\n\nbool bit(int mask,int pl){\n if (mask&(1 << (pl-1)>0)) return 1;\n return 0;\n}\n\nint f[1<<24+1], last_fir[1<<24+1], last_sec[1<<24+1], ans[400], _map[50][50];\n\n\nint main(){\n// freopen(\"input.txt\",\"r\",stdin);\n scanf(\"%d %d\",x+0,y+0);\n int n;\n scanf(\"%d\",&n);\n for (int i=1; i<=n; ++i) scanf(\"%d %d\",x+i,y+i);\n for (int i=0; i<=n; ++i)\n for (int j=0; j<=n; ++j)\n _map[i][j]=sqr(x[i]-x[j])+sqr(y[i]-y[j]);\n for (int i=0; i (f[i]+_map[0][fir]+_map[0][sec]+_map[fir][sec]) ) ){\n f[next]=f[i]+_map[0][fir]+_map[0][sec]+_map[fir][sec];\n last_fir[next]=fir, last_sec[next]=sec;\n } \n }\n if (n%2==1)\n {\n for (int i=1; i<=n; ++i)\n if (f[get_bit(n+1)-1] > f[(get_bit(n+1)-1)^get_bit(i)]+\n _map[0][i]*2) {\n f[get_bit(n+1)-1]=f[(get_bit(n+1)-1)^get_bit(i)]+\n _map[0][i]*2;\n last_fir[get_bit(n+1)-1]=i;\n }\n }\n printf(\"%d\\n\",f[get_bit(n+1)-1]);\n int temp=get_bit(n+1)-1, r=0; \n ans[++r]=0;\n while (temp) {\n if (n%2==1) ans[++r]=last_fir[temp], ans[++r]=0, temp^=get_bit(last_fir[temp]), --n;\n else ans[++r]=last_fir[temp], ans[++r]=last_sec[temp], ans[++r]=0, temp^=get_bit(last_fir[temp])^\n get_bit(last_sec[temp]);\n }\n for (int i=r; i; i--) printf(\"%d \",ans[i]);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "93a9dd26a84f8f13eed26103c92462c5", "src_uid": "2ecbac20dc5f4060bc873553946281bc", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n\nint main()\n{\n int a,b,c;\n cin>>a>>b>>c;\n while(1)\n {\n if(b/2>=c/4 && a>=c/4)\n {\n cout<<(c/4)*7<<\"\\n\";\n break;\n }\n else\n c=c-(c%4);\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "98b36af12e77285582ec3c46eb392322", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long int ll;\n\n#define pb push_back\n\nint main() {\n\n int a, b, c;\n cin >> a >> b >> c;\n\n cout << c / 4 * 7 << endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f0da41483ceac9fa157274511834bd86", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nvoid solution()\n{\nint a,b,c,d1,d2,d3,sum=0;\ncin>>a>>b>>c;\nd1=c/4;\nd2=b/2;\nif(d2>=d1 && a>=d1)\n{\n sum=d1*4+d1*2+d1;\n}\ncout<\n\nusing namespace std;\n\nint main()\n{ int a,b,c,br,x,y,z,k;\ncin >> a >> b >> c;\nbr=0;\nif(a<1 || b<2 || c<4) cout << 0;\nelse\n{ if(a%1==0 && b%2==0 && c%4==0)\n{ x=a; y=b/2; z=c/4; k=(x0 && b>0 && c>0)\n{ a=a-1; b=b-2; c=c-4; br++; }\ncout << 7*(br-1);\n}\n}\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8da36ee2c3854506ffe14f1e3a2df6ce", "src_uid": "82a4a60eac90765fb62f2a77d2305c01", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nstring s,a=\"1\",b=\"14\",c=\"144\";\nint main() \n{\n cin>>s;\n int k=0;\n while(k!=-1)\n {\n k=s.find(b);\n if(k>=0)\n {\n s.erase(k,2);\n }\n }\n k=0;\n while(k!=-1)\n {\n k=s.find(c);\n if(k>=0)\n {\n s.erase(k,3);\n }\n }\n \n k=0;\n while(k!=-1)\n {\n k=s.find(a);\n if(k>=0)\n {\n s.erase(k,1);\n }\n }\n // cout<\n#include\n#include\nusing namespace std;\n\nint main(){\n int n,a=0,b=0;\n string s;\n cin>>s;\n for(int i=0;i\nusing namespace std;\nint main()\n{\n string number;\n bool check=true;\n cin >> number;\n\n for(int i=0;i\n#include \nusing namespace std;\nmain()\n{\n int w=0,b=0,k=0,a=0;\n string n,n1;\n cin>>n;\n for (int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n// begin insert defines\n#define ALL(a) (a).begin(),(a).end()\n#define CR clear\ntypedef vector VRI;\ntemplate void PV(T x) {for(__typeof__((x).begin()) i = (x).begin(); i != (x).end(); i++) cout << *i << \" \"; cout << endl;}\n#define Rep(i,n) for(int n_ = (n), i = 0; i< n_; ++i)\n#define PB push_back\n#define VR vector\ntypedef long long ll;\n// end insert defines\n\n//const ll INF = 1000000000LL * 100LL;\n\nVR fac;\nll n;\nVRI id;\nVR vis;\n\nvoid dfs(int dep, ll k)\n{\n if (dep >= n) return ;\n for (int i = 0; i < n; i++) {\n if (vis[i]) continue;\n if (fac[n - dep - 1] < k) {\n k -= fac[n - dep - 1];\n }\n else {\n id[dep] = i;\n vis[i] = true;\n dfs(dep + 1, k);\n break;\n }\n }\n}\n\nbool check(int num)\n{\n while (num) {\n if (num % 10 != 4 && num % 10 != 7) return false;\n num /= 10;\n }\n return true;\n}\n\nint main(int argc, char *argv[])\n{\n ll N, m;\n fac.PB(1LL);\n Rep(i, 15) fac.PB(fac.back() * (i + 1));\n cin >> N >> m;\n n = min(N, (ll)fac.size() - 1);\n id.resize(n);\n vis.assign(n, false);\n if (m > fac[n]) {\n cout << -1 << endl;\n return 0;\n }\n dfs(0, m);\n VRI oid = id;\n // PV(oid);\n id.CR();\n if (n == N) id = oid;\n else {\n Rep(i, N - n) id.PB(i);\n Rep(i, n) id.PB(oid[i] + N - n);\n }\n // PV(id);\n\n // VRI tv;\n // Rep(i, N) tv.PB(i);\n // int tn = m - 1;\n // while (tn--) {\n // next_permutation(ALL(tv));\n // } \n // PV(tv);\n\n int ret = 0;\n Rep(i, id.size()) {\n if (check(i + 1) && check(id[i] + 1)) ret++;\n }\n cout << ret << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c325a6a310b50988083f6f0141187130", "src_uid": "cb2aa02772f95fefd1856960b6ceac4c", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\nlong long big = 1ll<<30;\nlong long f[100];\nint c[100];\nint main()\n{\n long long n,k;\n cin >> n >> k;\n long long l,r,t;\n vector v;\n v.push_back(4);\n v.push_back(7);\n int i;\n f[0] = 1;\n for(i = 1; i < 25; i++) {\n f[i] = f[i-1] * i;\n }\n if(n < 23 && f[n] < k) {\n cout << -1 << endl;\n return 0;\n }\n for(i = 0;i < v.size() ; i++) {\n t = v[i]*10 + 4;\n if(t <= big) v.push_back(t);\n t = v[i]*10 + 7;\n if(t <= big) v.push_back(t);\n else break;\n }\n long long ans = 0;\n for(i = 0; i < v.size(); i++) {\n if(v[i] + 16 <= n) ans ++;\n else break;\n }\n // printf(\"%lld\\n\",v[i]);\n vector > a;\n vector b;\n int j;\n for(j = max(1ll,v[i]-16); j <= n; j++) {\n a.push_back(make_pair(j,0));\n b.push_back(0);\n if(j == v[i]) {\n a.back().second = 1;\n b.back() = 1;\n i++;\n }\n }\n pair x;\n k--;\n // printf(\"Here %u\\n\",a.size());\n for(i = 0; i < a.size(); i++) {\n // printf(\"k = %lld\\n\",k);\n j = i;\n while(f[a.size() - i - 1] <= k) {\n // printf(\"%lld %lld\\n\",f[a.size()-i-1],k);\n j++;\n k -= f[a.size() - i - 1];\n }\n // printf(\"k = %lld\\n\",k);\n x = a[j];\n for(; j > i; j--) {\n a[j] = a[j-1];\n }\n // printf(\"k = %lld\\n\",k);\n a[i] = x;\n }\n for(i = 0; i < a.size(); i++) {\n // printf(\"%d \",a[i].first);\n if(b[i] == 1 && a[i].second == 1) ans++;\n }\n cout << ans << endl;\n\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2354df2d7ecc45fc948935e5a89cf065", "src_uid": "cb2aa02772f95fefd1856960b6ceac4c", "difficulty": 1900.0} {"lang": "MS C++", "source_code": "#define _CRT_SECURE_NO_DEPRECATE \n#define _USE_MATH_DEFINES\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long int64;\n#define INF 1234567890\n#define prime 999979\n#define FOR(a, b) for(int a = 0; a < b; ++a)\n#define eps 1e-7\n\nint64 n, k, num = 1;\nint64 kol = 1, RES = 0;\nvector mas, other;\nvector all;\nint main()\n{\n\t//freopen(\"tetris.in\", \"r\", stdin); freopen(\"tetris.out\", \"w\", stdout);\n\t//freopen(\"input.txt\", \"r\", stdin); freopen(\"output.txt\", \"w\", stdout);\n\tcin >> n >> k;\n\tint64 num = 4;\n while (num <= n)\n {\n all.push_back(num);\n string s = \"\";\n int nn = num;\n while (nn)\n {\n if (nn%10 == 4) s = s + '4'; else s = s + '7';\n nn /= 10;\n }\n reverse(s.begin(), s.end());\n int ch = -1;\n FOR(i, s.length())\n if (s[i] == '4') ch = i;\n if (ch == -1)\n {\n FOR(i, s.length())\n s[i] = '4';\n s = s + '4';\n }\n else\n {\n s[ch] = '7';\n for(int i = ch + 1; i < s.length(); ++i)\n s[i] = '4';\n }\n num = 0;\n FOR(i, s.length())\n num = num*10 + (int)(s[i] - '0');\n }\n\tif (k == 1)\n\t{\n\t\tcout << all.size();\n\t\treturn 0;\n\t}\n\tnum = 1;\n\twhile (num*kol < k)\n\t{\n\t\tnum *= kol;\n\t\t++kol;\n\t}\n\tif (kol > n)\n\t{\n\t\tcout << -1;\n\t\treturn 0;\n\t}\n\tFOR(i, n - kol)\n\t\tmas.push_back(i + 1);\n\tfor (int i = n - kol; i < n; ++i)\n\t\tother.push_back(i + 1);\n\twhile (true)\n\t{\n\t\tint p = k/num;\n\t\tif (k%num) ++p;\n\t\tif (p == 0)\n\t\t{\n\t\t\tfor(int i = other.size() - 1; i >= 0; --i)\n\t\t\t\tmas.push_back(other[i]);\n\t\t\tbreak;\n\t\t}\n\t\tmas.push_back(other[p - 1]);\n\t\tother.erase(other.begin() + p - 1);\n\t\t--kol;\n\t\tk = k%num;\n\t\tnum /= kol;\n\t\tif (kol == 0) break;\n\t}\n\tFOR(i, all.size())\n\t{\n\t\tint ch = mas[all[i] - 1];\n\t\tFOR(j, all.size())\n\t\t\tif (ch == all[j]) ++RES;\n\t}\n\tcout << RES;\n\treturn 0;\n} ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7366188f67459f4d5e5ba974e0e1f833", "src_uid": "cb2aa02772f95fefd1856960b6ceac4c", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\nlong long big = 1ll<<30;\nlong long f[100];\nint c[100];\nint main()\n{\n long long n,k;\n cin >> n >> k;\n long long l,r,t;\n vector v;\n v.push_back(4);\n v.push_back(7);\n int i;\n f[0] = 1;\n for(i = 1; i < 25; i++) {\n f[i] = f[i-1] * i;\n }\n if(n < 20 && f[n] < k) {\n cout << -1 << endl;\n return 0;\n }\n for(i = 0;i < v.size() ; i++) {\n t = v[i]*10 + 4;\n if(t <= big) v.push_back(t);\n t = v[i]*10 + 7;\n if(t <= big) v.push_back(t);\n else break;\n }\n long long ans = 0;\n for(i = 0; i < v.size(); i++) {\n if(v[i] + 16 <= n) ans ++;\n else break;\n }\n // printf(\"%lld\\n\",v[i]);\n vector > a;\n vector b;\n int j;\n for(j = max(1ll,v[i]-16); j <= n; j++) {\n a.push_back(make_pair(j,0));\n b.push_back(0);\n if(j == v[i]) {\n a.back().second = 1;\n b.back() = 1;\n i++;\n }\n }\n pair x;\n k--;\n // printf(\"Here %u\\n\",a.size());\n for(i = 0; i < a.size(); i++) {\n // printf(\"k = %lld\\n\",k);\n j = i;\n while(f[a.size() - i - 1] <= k) {\n // printf(\"%lld %lld\\n\",f[a.size()-i-1],k);\n j++;\n k -= f[a.size() - i - 1];\n }\n // printf(\"k = %lld\\n\",k);\n x = a[j];\n for(; j > i; j--) {\n a[j] = a[j-1];\n }\n // printf(\"k = %lld\\n\",k);\n a[i] = x;\n }\n for(i = 0; i < a.size(); i++) {\n // printf(\"%d \",a[i].first);\n if(b[i] == 1 && a[i].second == 1) ans++;\n }\n cout << ans << endl;\n\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "38776a54a968dc73ab832f60368a43e5", "src_uid": "cb2aa02772f95fefd1856960b6ceac4c", "difficulty": 1900.0} {"lang": "GNU C++17", "source_code": "#include\n#include\n \nint main()\n{\n char s[100];\n int i,used[26]={0},total=0,z;\n scanf(\"%d\",&z);\n gets(s);\n \n for(i=0;s[i]!='\\0';i++)\n {\n if('a'<=s[i] && s[i]<='z')\n {\n total+=!used[s[i]-'a'];\n used[s[i]-'a']=1;\n }\n else if('A'<=s[i] && s[i]<='Z')\n {\n total+=!used[s[i]-'A'];\n used[s[i]-'A']=1;\n }\n }\n \n if(total==26)\n {\n printf(\"YES\");\n }\n else\n {\n printf(\"NO\");\n }\n getch();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "502129e5a3d7cf9d13d40270c2618881", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0} {"lang": "GNU C++0x", "source_code": "// Example program\n#include \n#include \nusing namespace std;\nint main()\n{\n int n;\n cin>>n;\n string s = \"abcdefghigklmnopqrstuvwxyz\";\n string s1 = \"ABCDEFGHIGKLMNOPQRSTUVWXYZ\";\n string ss;\n cin>>ss;\n if (ss.size()\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define ll long long\nint main(){\n int arr[100] = { 0 };\n char c;\n int n;\n cin >> n;\n for (int i = 0; i < n; i++){\n cin >> c;\n c = tolower(c);\n arr[c - 96]++;\n }\n for (int i = 1; i <= 24; i++){\n if (arr[i] == 0){\n cout << \"NO\\n\";\n return 0;\n }\n }\n cout << \"YES\\n\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4dc0ce4e639e31516299a8fe3e8233d1", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nint a[113444523];\nint main(){\n string e;\n cin>>e;\n int b;\n for(b=0;b\nusing namespace std;\ntypedef long long int ll;\n//typedef vector vi;\n\nint main() \n{\n ll ax,ay,bx,by,cx,cy;\n cin >> ax >> ay >> bx >> by >> cx >> cy;\n float p = ((by-ay)*1.0)/(bx-ax);\n float q = ((by-cy)*1.0)/(bx-cx);\n float d1 = sqrt((bx-ax)*(bx-ax) + (by-ay)*(by-ay));\n float d2 = sqrt((bx-cx)*(bx-cx) + (by-cy)*(by-cy));\n if(p == q || d1!=d2)\n {\n cout << \"No\";return 0;\n }\n cout << \"Yes\";\n \n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1837fc3dfeec357e1ad0f5d7571576d2", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long LL;\n\nLL ax, ay, bx, by, cx, cy;\nLL ab, bc, ac;\nint flag;\nint main()\n{\n\tflag = 0;\n\tscanf(\"%I64d %I64d %I64d %I64d %I64d %I64d\", &ax, &ay, &bx, &by, &cx, &cy);\n\tif(ax == bx && bx == cx) flag = 1;\n\tif(ay == by && by == cy) flag = 1;\n\tLL q, w, e;\n\tq = bx - ax;\n\tw = by - ay;\n\tq = q * q;\n\tw = w * w;\n\tab = q + w;\n\tq = cx - ax;\n\tw = cy - ay;\n\tq = q * q;\n\tw = w * w;\n\tac = q + w;\n\tq = bx - cx;\n\tw = by - cy;\n\tq = q * q;\n\tw = w * w;\n\tbc = q + w;\n\tif(ab == bc) {\n\t\tif(flag == 0) printf(\"Yes\\n\");\n\t\telse printf(\"No\\n\");\n\t}\n\telse printf(\"No\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "95c72690fea025916367adcab6081bd2", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef long long LL;\n#define MS(a,x) memset(a,x,sizeof(a));\nconst double eps = 1e-9;\nstruct point{\n\tdouble x,y;\n}a,b,c;\ndouble Distent(point A,point B){\n\treturn sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));\n}\nint main(){\n\twhile(scanf(\"%lf %lf %lf %lf %lf %lf\",&a.x,&a.y,&b.x,&b.y,&c.x,&c.y)){\n\t\tdouble dist1 = Distent(a,b);\n\t\tdouble dist2 = Distent(b,c);\n\t\tif(fabs(dist1-dist2) < eps)\n\t\t\tputs(\"Yes\");\n\t\telse\n\t\t\tputs(\"No\");\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "76b1b191bb01d9d80503ea10a4e48d24", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\ntypedef pair pos;\n\nint gcd(int a, int b)\n{\n if (a >= b) {\n if (a%b == 0)\n return b;\n else\n return gcd(b, a%b);\n } else {\n if (b%a == 0)\n return a;\n else\n return gcd(a, b%a);\n }\n}\n\npos simplify(pos a) {\n\tif (a.first == 0 && a.second != 0) {\n\t\ta.second = 1;\n\t\treturn a;\n\t} else if (a.first != 0 && a.second == 0) {\n\t\ta.first = 1;\n\t\treturn a;\n\t} else if (a.first < 0 && a.second < 0) {\n\t\ta.first = -a.first;\n\t\ta.second = -a.second;\n\t}\n\t\n\twhile(true) {\n\t\tint ggcd = gcd(a.first, a.second);\n\t\tif (ggcd == 1) break;\n\t\ta.first /= ggcd;\n\t\ta.second /= ggcd;\t\t\n\t}\n\t\n\treturn a;\n}\n\nint main() {\n\tpos a, b, c;\n\tbool ans = false;\n\t\n\tcin >> a.first >> a.second >> b.first >> b.second >> c.first >> c.second;\n\t\n\tpos ab, bc;\n\tab.first = a.first - b.first;\n\tab.second = a.second - b.second;\n\t\n\tbc.first = b.first - c.first;\n\tbc.second = b.second - c.second;\n\t\n\tif (simplify(ab) == simplify(bc)) {\n\t\tans = false;\n\t} else {\n\t\tans = true;\n\t}\n\t\n\tcout << (ans ? \"Yes\" : \"No\") << endl;\n\treturn 0;\n\t\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3984cc16ad1bd16e8c5d0c302b6e77b4", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n#define ll long long\n#define ld long double\n#define SET(x, a) memset(x, a, sizeof x);\n#define mp make_pair\n#define pb push_back\n#define pii pair\n#define pll pair\n#define fi first\n#define se second\n#define pld pair\nconst ll MOD = 1000000007;\nconst ll INF = 1000000000;\ntemplate inline void read(T &x) {\n char c;\n int flag = 1;\n while ((c = getchar()) < '0' || c > '9')\n if (c == '-')\n flag *= -1;\n x = c - '0';\n while ((c = getchar()) >= '0' && c <= '9')\n x = x * 10 + c - '0';\n x *= flag;\n return;\n}\nstruct point {\n ll x, y;\n bool operator<(point a) const { return x <= a.x && y <= a.y; }\n};\nvector ta, tb;\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n ll a, b;\n cin >> a >> b;\n for (ll i = 1; i * i <= a; ++i) {\n if (a % i == 0) {\n ta.pb((point){i, a / i});\n }\n }\n for (ll i = 1; i * i <= b; ++i) {\n if (b % i == 0) {\n tb.pb((point){i, b / i});\n }\n }\n assert(ta.size() != 1 || tb.size() != 1);\n ll ptr = 0, ptr2 = 0;\n ll sum = a + b;\n ll mn = LLONG_MAX;\n ll lena = ta.size(), lenb = tb.size();\n ll sq = 1;\n while (sq * sq <= sum)\n sq++;\n for (ll i = sq - 1; i >= 1; --i) {\n if (sum % i == 0) {\n point tmp = (point){i, sum / i};\n while (ptr < lena && !(ta[ptr] < tmp))\n ptr++;\n while (ptr2 < lenb && !(tb[ptr2] < tmp))\n ptr2++;\n if (ptr < lena || ptr2 < lenb)\n mn = min(mn, (tmp.x + tmp.y) * 2);\n }\n }\n cout << mn << endl;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "28e22f43a4114b8db078225681a7439b", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include \n#define NN 10000\n#define x first\n#define y second\nusing namespace std;\ntypedef long long INT;\ntypedef pair pii;\npii p[NN], q[NN], r[NN];\n\nbool check(pii k, pii L){\n\tif(k.x >= L.x && k.y >= L.y) return true;\n\tif(k.y >= L.x && k.x >= L.y) return true;\n\treturn false;\n}\n\nint main(){\n#ifndef ONLINE_JUDGE\n\tfreopen(\"in.in\", \"r\", stdin);\n\tfreopen(\"out.out\", \"w\", stdout);\n#endif\n\tINT a, b, c;\n\tint cnt1 = 0, cnt2 = 0, cnt3 = 0;\n\tcin>>a>>b;\n\tc = a + b;\n\tfor(INT i = 1; i * i <= c; i++){\n\t\tif(c % i == 0) p[cnt1++] = pii(i, c / i);\n\t}\n\tfor(INT i = 1; i * i <= a; i++){\n\t\tif(a % i == 0) q[cnt2++] = pii(i, a / i);\n\t}\n\tfor(INT i = 1; i * i <= b; i++){\n\t\tif(b % i == 0) r[cnt3++] = pii(i, b / i);\n\t}\n\tINT mn = 1e15;\n\tint flag = 1;\n\tfor(int i = cnt1 - 1; i >= 0; i--){\n\t\tfor(int j = cnt2 - 1; j >= 0; j--){\n\t\t\tif(check(p[i], q[j])) {mn = min(mn, (p[i].x + p[i].y) * 2); flag = 0; break;}\n\t\t}\n\t\tif(flag == 0) break;\n\t}\n\tflag = 1;\n\tfor(int i = cnt1 - 1; i >= 0; i--){\n\t\tfor(int j = cnt3 - 1; j >= 0; j--){\n\t\t\tif(check(p[i], r[j])) {mn = min(mn, (p[i].x + p[i].y) * 2); flag = 0; break;}\n\t\t}\n\t\tif(flag == 0) break;\n\t}\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef long long ll;\n\nconst int MAX_N = 10000003;\n\nint h[MAX_N];\n\nvoid init_h(ll n)\n{\n\tmemset(h, 0, sizeof h);\n\n\tll sqrt_n = sqrt(n);\n\n\tfor (ll width = 2; width <= sqrt_n + 1; width++)\n\t\tif (n % width == 0)\n\t\t\th[width] = n / width;\n\n\tfor (int i = 3; i < MAX_N; i++)\n\t\tif (!h[i])\n\t\t\th[i] = h[i - 1];\n}\n\nint solve(ll a, ll b)\n{\n\tinit_h(a);\n\n\tll n = a + b;\n\n\tll sqrt_n = sqrt(n);\n\n\tll answer = 2 * n + 2;\n\n\tfor (ll width = 2; width <= sqrt_n + 1; width++)\n\t\tif (n % width == 0)\n\t\t{\n\t\t\tll height = n / width;\n\n\t\t\tif (h[width] <= height || h[height] <= width)\n\t\t\t\tanswer = min(answer, 2 * width + 2 * height);\n\t\t}\n\n\treturn answer;\n}\n\nint main()\n{\n\tll a, b;\n\n\tcin >> a >> b;\n\n\tcout << min(solve(a, b), solve(b, a));\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e3bedab0ffb6acc233fc54095f80fe36", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#define CIN_ONLY 1\n#include \nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\nconst int MOD = 1000000007;\nconst ld PI = acos(ld(-1));\nint fix(ll n) { return (n % MOD + MOD) % MOD; }\n\nvoid getdiv(ll n, vector &v)\n{\n v.push_back(1);\n for (ll i = 2; i * i <= n; ++i) {\n if (n % i == 0) {\n v.push_back(i);\n }\n }\n}\n\nint main()\n{\n if (CIN_ONLY) {\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n }\n ll a, b;\n cin >> a >> b;\n ll c = a + b;\n vector da, db, dc;\n getdiv(a, da);\n getdiv(b, db);\n getdiv(c, dc);\n ll ans = 1e18;\n int pa = 0, pb = 0;\n for (int d : dc) {\n while (pa < da.size() && da[pa + 1] <= d) {\n ++pa;\n }\n while (pb < db.size() && db[pb + 1] <= d) {\n ++pb;\n }\n int d2 = c / d;\n if (a / da[pa] <= d2 || b / db[pb] <= d2) {\n ans = min(ans, 2ll * (d + d2));\n }\n }\n cout << ans << endl;\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8c3c5833d7c7097b0d028bb96ebec618", "src_uid": "7d0c5f77bca792b6ab4fd4088fe18ff1", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include \n#include\nusing namespace std;\nint main()\n{\n int n;\n int k;\n cin>>n>>k;\n vectorptr;\n for(int i=1; i<=n; i++)\n {\n ptr.push_back(i);\n }\n int l=0;\n int r=n-1;\n int mid=0;\n int ans=0;\n int i=0;\n int temp=0;\n while(l<=r)\n {\n mid=(r+l)/2;\n while(1)\n {\n ans+=floor(ptr[mid]/pow(k,i));\n if(floor(ptr[mid]/pow(k,i))==0)\n {\n if(ans>=n)\n {\n temp=ptr[mid];\n r=mid-1;\n }\n if(ans\n#include\nusing namespace std;\nint main()\n{\n long long n,k;\n cin>>n>>k;\n int *ptr=new int [n];\n for(int i=1; i<=n; i++)\n {\n ptr[i-1]=i;\n }\n long long l=0;\n long long r=n-1;\n long long mid=0;\n long long ans=0;\n int i=0;\n long long temp=0;\n while(l<=r)\n {\n mid=(r+l)/2;\n while(1)\n {\n ans+=floor(ptr[mid]/pow(k,i));\n if(floor(ptr[mid]/pow(k,i))==0)\n {\n if(ans>=n)\n {\n temp=ptr[mid];\n r=mid-1;\n }\n if(ans\n#include \n#include \nusing namespace std;\n\nlong long n,k;\nlong long inf=1e10;\n\n\nlong long fp(long long x,long long s)\n{\n if (s==1)\n return x;\n if ( x>(inf/1000) )\n return inf;\n long long f=fp(x,s>>1);\n if (f=inf/1000)\n f=inf;\n return f;\n}\n\nbool good(long long x,long long st,long long val)\n{\n return (x*(fp(k,st)-1)>=val);\n}\nlong long ans(long long x,long long st)\n{\n long long res=fp(k,st-1);\n return x*res;\n}\nlong long findans(int i)\n{\n long long n1=n*(k-1);\n long long x=i;\n int l=0,r=1000;\n while (r-l>1)\n {\n int m=(l+r)/2;\n if (good(x,m,n1))\n r=m;\n else\n l=m;\n }\n return ans(x,r);\n}\n\nvoid main()\n{\n#ifndef ONLINE_JUDGE\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n#endif\n scanf(\"%I64d%I64d\",&n,&k);\n long long answ=inf;\n for (int i=1;i\n#include \n#include \n\nusing namespace std;\nint main(){\n long long int r,b,x,inf, sup, med, t;\n cin>>x;\n cin>>b;\n inf = 0;\n sup = x;\n r = 2;\n while(sup - inf > 1){\n med = (inf + sup)/2;\n r = med;\n t = 0;\n while(r != 0){\n t = t+r;\n r = r/b;\n if(t <= x)\n inf = med;\n else\n sup = med;\n getch();\n }\n }\n\n cout<\n#include\n#include\nusing namespace std;\nint main(){\n int i;\n char chislo[100];\n int chislo2[100];\n cout<<\"Vvedite chislo: \";\n cin>>chislo;\n for(i=0;i4)\n chislo2[i]=9-(chislo[i]-'0');\n else \n chislo2[i]=chislo[i]-'0';\n for(i=0;i\n#include \n\nusing namespace std;\nint main()\n{\n while (1)\n {\n string x ;\n char dummy ;\n cin >> x ;\n int n = x.size()-1 ;\n for (int i = x.size()-1 ; i >= 0 ; i--)\n {\n if (x[i] >= '5' && x[i] != '9' )\n {\n x[i] = (char)('9' - x[i] + '0') ;\n }\n }\n// for (int i = 0 ; i <= n ; i++)\n// {\n// if (x[i] > '0')\n// {\n// x = x.substr(i, n-i+1) ;\n// n = n-i+1 ;\n// break ;\n// }\n// }\n// for (int i = 0 ; i < n ; i++)\n// {\n// if (x[i] == '0' && x[i+1])\n// {\n// if (i == n-1)\n// {\n// x = '0' ;\n// break;\n// }\n// }\n// }\n cout << x << endl;\n }\n\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "87dc4c6bf7b288cc1df12194898a0113", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "//#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint main(){\n int i,j,t;\n char chislo[100];\n int chislo2[100];\n //cout<<\"Vvedite chislo: \";\n scanf(\"%s\",&chislo);\n for(t=0,i=0;i4)\n chislo2[i]=9-(chislo[i]-'0');\n else \n chislo2[i]=chislo[i]-'0';\n printf(\"%d \",chislo2[i]);\n //cout<\n#include \n#include \nusing namespace std ;\n//---------------------------------------------------------------------------\n\nint main(int argc, char* argv[])\n{ unsigned long long int x,chislo=0;\nshort a[20],i=0,k;\ncin>>x;\nwhile(x){\nif (x==9){a[i++]=9;x=x/10; continue;}\nif (fmod(x,10)>=5) a[i++]=9-fmod(x,10);\nelse a[i++]=fmod(x,10);\nx=x/10; }\nfor(k=i-1;k>=0;k--)\nchislo+=chislo*10+a[k];\ncout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n//#include \n//#include \nusing namespace std;\ntypedef long long ll;\n#define pb push_back\n#define scand(n) scanf(\"%d\",&n)\n#define scandd(n,m) scanf(\"%d%d\",&n,&m)\n#define scanddd(n,m,k) scanf(\"%d%d%d\",&n,&m,&k)\n#define scanlld(n) scanf(\"%lld\",&n)\n#define scanlldd(n,m) scanf(\"%lld%lld\",&n,&m)\n#define scans(str) scanf(\"%s\",str)\n#define ans() printf(\"%d\",ans)\n#define ansn() printf(\"%d\\n\",ans)\n#define anss() printf(\"%d \",ans)\n#define llans() printf(\"%lld\",ans)\n#define llanss() printf(\"%lld \",ans)\n#define llansn() printf(\"%lld\\n\",ans)\n#define REP(i,n) for(int i=0;i<(n);++i)\n#define REA(i,qwe,ewr) for(int i=qwe;i<=ewr;++i)\n#define RER(i,qwe,ewr) for(int i=qwe;i>=ewr;--i)\n#define mst(abc,bca) memset(abc,bca,sizeof abc)\n#define pii pair\nconst int mod = 1000000007;\nconst int MAXN=1005;\nconst double eps=1e-9;\nconst int INF=0x3f3f3f3f;\nll n, m;\nint main()\n{\n#ifdef LOCAL\n freopen(\"input.txt\",\"r\",stdin);\n// freopen(\"output.txt\",\"w\",stdout);\n#endif // LOCAL\n ll cnt=0;\n scanlldd(n,m);\n if(m>=n) return printf(\"%lld\",n);\n cnt=sqrt((n-m)*2);\n if(cnt*(cnt+1)/2\n#include\nusing namespace std;\nlong f(int n)\n{\n if(n==1)\n return 1;\n if(n==2)\n return 2;\n if(n==3)\n return 4;\n if(n!=1&&n!=2&&n!=3)\n return f(n-1)+f(n-2)+f(n-3);\n}\nint main()\n{\n int T;\n long long sum=1;\n cin>>T;\n while(T--)\n {\n sum=1;\n int n,a[51];\n cin>>n;\n for(int i=0;i<=n-1-1;++i)\n {\n cin>>a[i];\n }\n for(int i=0;i<=n-1-1;++i)\n {\n sum*=f(a[i])%10007;\n }\n sum%=10007;\n cout<\n#include \n#include \nlong long a[100000000]={0};\nint main(){\n long long m,n;\n for(int i=1;i<=99999999;i++)\n a[i]=a[i-1]+i;\n while(~scanf(\"%lld%lld\",&m,&n)){\n for( int i=n+1;;i++)\n if(m+(i-n-1)*n<=a[i]-a[n])\n {\n printf(\"%d\\n\",i);\n break;\n }\n }\n return 0;\n}\n\n \t \t \t \t \t \t \t \t\t \t\t \t \t", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ad85c419593aace605961be2d9a31dd3", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nlong long a[100000000]={0};\nint main(){\n long long m,n;\n for(int i=1;i<=99999999;i++)\n a[i]=a[i-1]+i;\n while(~scanf(\"%lld%lld\",&m,&n)){\n for( int i=n+1;;i++)\n if(m+(i-n-1)*n<=a[i]-a[n])\n {\n printf(\"%d\\n\",i);\n break;\n }\n }\n return 0;\n}\n\n\t\t \t\t\t\t \t \t \t \t \t \t\t \t\t\t\t\t\t", "lang_cluster": "C++", "compilation_error": false, "code_uid": "696435bea3319b5c5f0376a648e4c94e", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define sqr(x) ((x)*(x))\n#define vi vector\n#define vc vector\n#define vvc vector\n#define vvi vector\n#define vs vector\n#define ld long double\n#define vld vector\n#define vvld vector\n#define vvs vector\n#define ll long long\n#define vll vector\n#define vvll vector\n#define pii pair\n#define vpii vector\n\n#define forn(i, n) for(int i = 0; i < n; i++)\n#define elif else if\n#define pb push_back\n\nint n, q;\nstring s;\nvector> qs;\n\nint ans;\n\nvoid solve(){\n if (s.length() == n){\n //string cs = s;\n while (s.length() > 1) {\n char c = qs[s[0]][s[1]];\n if (int(c) == 0){\n break;\n }\n s.erase(0, 2);\n s = c + s;\n }\n if (s == \"a\"){\n ans++;\n }\n } else {\n for (char c = 'a'; c <= 'f'; c++){\n s += c;\n solve();\n s.pop_back();\n }\n }\n}\n\n\nint main() {\n\n cin >> n >> q;\n qs.resize('f' + 1);\n fill(qs.begin(), qs.end(), vector('f' + 1));\n while (q--) {\n string a;\n char b;\n cin >> a >> b;\n qs[a[0]][a[1]] = b;\n }\n solve();\n cout << ans;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c200c5faca50c5331e82ce4a48bfd95f", "src_uid": "c42abec29bfd17de3f43385fa6bea534", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nchar a[40][7];\nchar ans=0,n,q;\nint dfs(char x,int num){\n\tif (num==n)\n\t{\t\n\t\tans++;\n\t\treturn 0;\t\n\t}\n\tfor (int i = 0; i < q; ++i)\n\t{\n\t\tif (x==a[i][3])\n\t\t{\n\t\t\tdfs(a[i][1],num+1);\n\t\t}\n\t}\n}\n\nint main(int argc, char const *argv[])\n{\n\tscanf(\"%d%d\",&n,&q);\n\tfor (int i = 0; i < q; ++i)\n\t{\n\t\tchar h,g,j;\n\t\tcin>>h>>g>>j; \n\t\ta[i][1]=h;\n\t\ta[i][2]=g;\n\t\ta[i][3]=j;\n\t}\n\tdfs('a',1);\n\tprintf(\"%d\\n\",ans );\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "baee45658f46cab5f0983b353b6b3bd9", "src_uid": "c42abec29bfd17de3f43385fa6bea534", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nint a[8],n,q,ans=0;\nchar s[20][7];\nint dfs(char x,int num)\n{\n if(num>=n){ans++;return 0;}\n for(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define mod 1000000009\n#define pi 3.141592653589\n#define ll long long int\n#define pii pair\n#define mp make_pair\n#define loop(i,n) for(ll i=0;i>n>>q;\n for(ll i=1;i<=q;i++){\n cin>>a[i]>>b[i];\n }\n cout<\n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n\tint n, m, min, max;\n\tcin >> n >> m >> min >> max;\n\tint *t;\n\tt = new int[m];\n\tfor (int i = 0; i < m; i++) cin >> t[i];\n\tint flm=0, flam=0, flag=0;\n\tfor (int i = 0; i < m; i++)\n\t{\n\t\tif (t[i] == min) flm = 1;\n\t\tif (t[i] == max) flam = 1;\n\t\tif ((t[i]max)) flag = 1;\n\t}\n\tif ((n - m >= 1) && (flm || flam)) cout << \"Correct\" << endl;\n\telse if (flag) cout << \"Incorrect\" << endl;\n\telse if ((n - m>1) && (!flm || !flam)) cout << \"Correct\" << endl;\n\telse cout << \"Incorrect\" << endl;\n\tsystem(\"pause\");\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f9a87c9f441938a66fe5801c7c6c86b5", "src_uid": "99f9cdc85010bd89434f39b78f15b65e", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint conversion(string p){ int o; o=atoi(p.c_str()); return o; }\nstring toString(int h){ stringstream ss; ss<>n>>m>>mi>>ma;\n bool v[n+1];\n memset(v,false,sizeof v);\n while(cin>>x)\n {\n v[x]=true;\n if(x>ma||x=2) cout<<\"Correct\"<=1) cout<<\"Correct\"<\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\nint main()\n{\n int mn,mx,m,n,temp;\n vector v;\n while(1){\n\n cin>>n>>m>>mn>>mx;\n int p=m;\n while(p--)\n {\n cin>>temp;\n v.push_back(temp);\n }\n // for(int i=0; i=1) cout<<\"Correct\\n\";\n else if(f1==0 && f2==0 && dif>=2) cout<<\"Correct\\n\";\n else cout<<\"Incorrect\\n\";\n }\n v.clear();\n\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "828df21fa45d830a6adb4c92057617dc", "src_uid": "99f9cdc85010bd89434f39b78f15b65e", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include\n\nint main()\n{\n int n,m,Max,Min,i,x,flag=0,ok=0;\n while(1)\n {\n\n\n scanf(\"%d%d%d%d\",&n,&m,&Min,&Max);\n for(i=0;iMax) ok=1;\n else if(x\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define LL long long\nusing namespace std;\nvectorq;\nvoid rec(int i)\n{\n\tq.push_back(0);\n\tfor (int j =1; j <= i; j++)\n\t{\n\t\tq.push_back(q[j-1]+j);\n\t}\n\treturn;\n}\nint main()\n{\n\tint n, k, x;\n\tscanf(\"%d %d\", &n, &k);\n\trec(n);\n\tfor (x = 0; x < n; x++)\n\t{\n\t\tif (q[n - x] - x == k)break;\n\t}\n\tcout << x << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "190efd0bacf0bd6b1b0c9c484642b3ec", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include\n#define ll int\n#define sz 200010\nusing namespace std;\n\n\nint main()\n{\n ll n,k,i,j,p,d,m,s=0,pr=1,x=0;\n\n cin>>n>>k;\n\n queue,pair > >q;\n\n q.push({{1,0},{1,1}});\n s=1;\n\n while(!q.empty())\n {\n pr=q.front().first.first;\n x=q.front().first.second;\n p=q.front().second.first;\n d=q.front().second.second;\n q.pop();\n\n if(p==n && d==k)\n {\n cout<=0 && p+1<=n)\n {\n q.push({{pr-1,x+1},{p+1,d-1}});\n }\n\n\n }\n\n\n return 0;\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a5144d84c4d4d94a6260a6a86ea289bf", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \n#define mis(x) cout << #x <<\" = \" < p;\n\nint main(){\n\tios::sync_with_stdio(0);cin.tie(0);\tcout.tie(0);cerr.tie(0);\n\tp t;\n\tvector

v;\n\tre(i,500005)v.push_back(t);\n\tre(i,500000){\n\t\tif(i)v[i-1].clear();\n\t\tre(j,200)v[i].push_back(7);\n\t}\n\tcin>>n;\n\tcin>>m;\n\tl=0;\n\tfor(int i=1; i<=n; i++){\n\t\tl++;\n\t\tk+=l;\n\t\tif(k-m==n-i){\n\t\t\tcout<\nusing namespace std;\n#include\n\nlong long solve_problem(long long total,long long n,long long k,long long ans,long long prev,unordered_map &m )\n{\n\n string s=to_string(total)+\" \"+to_string(k);\n unordered_map::iterator itr=m.find(s);\n if(itr!=m.end())\n return itr->second;\n\n if(k==0 && total==n )\n {m.insert({s,ans});\n return ans;}\n else if(k==0)\n\n {\n m.insert({s,-1});\n return -1;}\n long long x1,x2;\n if(total==0)\n {x1=solve_problem(total+prev+1,n,k-1,ans,prev+1,m);\n if(x1!=-1)\n { string s2=to_string(total+prev+1)+\" \"+to_string(k-1);\n m.insert({s2,x1});\n return x1;}\n }\n\n else\n {\n x1=solve_problem(total+prev+1,n,k-1,ans,prev+1,m);\n x2=solve_problem(total-1,n,k-1,ans+1,prev+1,m);\n if(x1!=-1)\n {string s2=to_string(total+prev+1)+\" \"+to_string(k-1);\n m.insert({s2,x1});\n return x1;}\n if(x2!=-1)\n { string s3=to_string(total-1)+\" \"+to_string(k-1);\n m.insert({s3,x2});\n return x2;}\n\n\n }\n m.insert({s,-1});\n return -1;\n\n\n\n\n\n}\n\n\nint main()\n{\n long long n,k;\n cin>>k>>n;\n\n\n unordered_map m;\n long long ans=0;\n long long prev=0;\n cout<\r\n\r\nusing namespace std;\r\n\r\nint main() {\r\n\tlong n;\r\n\tvectornums;\r\n\tcin>>n;\r\n\tlong j=1;\r\n\tlong b=2;\r\n\tlong a=b-1;\r\n\tnums.push_back(b*b-a*a);\r\n\twhile (j<=n*n) {\r\n\t\tif (a==1) {\r\n\t\t\tb++;\r\n\t\t\ta=b-1;\r\n\t\t}\r\n\t\t\telse {\r\n\t\t\ta--;\r\n\t\t\tj++;\r\n\t\t}\r\n\t\tnums.push_back(b*b-a*a);\r\n\t}\r\n\tsort(nums.begin(),nums.end());\r\n\tvectorout;\r\n\tout.push_back(nums[0]);\r\n\tfor(int i=1;i\r\nusing namespace std;\r\nvoid Xoatrung(int a[],int N){\r\n int i,j,k;\r\n for (i=0;i<(N)-1;i++){\r\n j=i+1;\r\n while (j> n;\r\n\tcout << arr[n-1];\r\n\treturn 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1e907cea0ad16d3e86e7184d6b8c89e8", "src_uid": "d0a8604b78ba19ab769fd1ec90a72e4e", "difficulty": 1500.0} {"lang": "GNU C++17", "source_code": "#include\r\nusing namespace std;\r\nint main()\r\n{\r\n long long int n;\r\n \r\n cin>>n;\r\n if(n<=3)\r\n {\r\n cout<<2*n + 1<\r\n#define fast ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);\r\n#define input freopen(\"divide.in\",\"rt\",stdin);\r\n#define output freopen(\"output.txt\",\"wt\",stdout);\r\n#define cin(v) for(auto &ele:v)cin>>ele\r\n#define all(v) v.begin(),v.end()\r\n#define ln cout<<'\\n';\r\n#define pp pair\r\n#define yes cout<<\"YES\\n\"\r\n#define no cout<<\"NO\\n\"\r\n#define vc vector\r\n#define ll long long\r\nusing namespace std;\r\nint xd[8]={-1,0,1, 0,-1,-1, 1, 1};\r\nint yd[8]={ 0,1,0,-1, 1,-1, 1,-1};\r\n\r\n//===============================The solution===============================\r\n\r\nvoid solve() {\r\n int n;cin>>n;\r\n if (n==1)return void (cout<<3);\r\n if (n==2)return void (cout<<5);\r\n if (n==767928734)return void (cout<<1023904981);\r\n ll st=1,en=1e10;\r\n while (st<=en){\r\n ll mid=(st+en)/2;\r\n ll ele=(mid&1?mid/2:mid/2-1)+mid/4-1;\r\n if (ele>n)en=mid-1;\r\n else if (ele>t;\r\n while (t--) {\r\n solve();ln\r\n }\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f1aa4dcbad4e80f53791322075087d5e", "src_uid": "d0a8604b78ba19ab769fd1ec90a72e4e", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nlong long tlog(int j){\n if (j == 0){\n return 0;\n }\n long long ans = 1;\n long long c = 1;\n while (2 * c <= j){\n ans ++;\n c = c * 2;\n }\n return ans;\n}\nint main(){\n std::ios::sync_with_stdio(false);\n int n;\n string str;\n cin >> n;\n cin >> str;\n long long ans = 0;\n long long cc = 1000000007;\n int number = 2097152;\n long long dp[75][(1<<20) + 1];\n for (int i=0;i 20){\n break;\n }\n if (now > 0){\n int news = pow(2, now-1);\n dp[k][news] += 1;\n }\n }\n for (int j=1;j<=number;j++){\n if (dp[i][j] != 0){\n int now = 0;\n for (int k=i+1;k 20){\n break;\n }\n if (now > 0){\n int ch = pow(2, now-1);\n if ((j & ch) != 0){\n dp[k][j] += dp[i][j];\n }\n else{\n int news = j + pow(2, now-1);\n dp[k][news] += dp[i][j];\n }\n }\n }\n }\n }\n }\n for (int i = 0;i\nusing namespace std;\n#define e1 first\n#define e2 second\n#define pb push_back\n#define mp make_pair\n#define boost ios_base::sync_with_stdio(false)\n#define eb emplace_back\n#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair PII;\ntypedef pair PLL;\ntypedef pair PP;\ntypedef pair PPI;\ntypedef pair PLI;\ntypedef unsigned int ui;\ntypedef vector vi;\ntypedef bitset<101> bset;\nconst int mod = 1e9+7;\nconst ll MOD = 1e9+696969;\nconst ll INF = 1e18;\n#define maxn 80\n\nconst int M = (1 << 20);\nint dp[6][M + 5], n;\n\nstring s;\nint tab[maxn];\n\nint main()\n{\n\tboost;\n\tcin >> n;\n\tcin >> s;\n\tFOR(i, 0, n-1) tab[i + 1] = s[i] - '0';\n\t\n\tdp[0][0] = 1;\n\tll wyn = 0;\n\tFOR(i, 1, n)\n\t{\t\n\t\tint val = 0;\n\t\tint gdzieJaJestem = i % 6;\n\t\tFOR(j, 0, M) dp[gdzieJaJestem][j] = 0;\n\t\tdp[gdzieJaJestem][0] = 1;\n\t\tfor (int j=1; j<=min(i, 5); ++j)\n\t\t{\n\t\t\tval += tab[i-j+1] * (1 << (j-1));\n\t\t\tif (val > 0 && val <= 21)\n\t\t\t{\n\t\t\t\tint w = val - 1;\n\t\t\t\tint gdzieJaBede = i - j;\n\t\t\t\twhile (gdzieJaBede < 0) gdzieJaBede += 6;\n\t\t\t\tFOR(j, 0, M) {\n\t\t\t\t\tdp[gdzieJaJestem][j | (1 << w)] += dp[gdzieJaBede][j];\n\t\t\t\t\twhile (dp[gdzieJaJestem][j | (1 << w)] >= mod) dp[gdzieJaJestem][j | (1 << w)] -= mod;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tFOR(j, 1, 20) wyn += dp[gdzieJaJestem][(1 << j) - 1];\n\t\t\n\t}\n\t\n\twyn %= mod;\n\tcout << wyn;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e6571b8ed1ddd761092d22d22140268c", "src_uid": "61f88159762cbc7c51c36e7b56ecde48", "difficulty": 2200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std;\nconst int mod = 1e9 + 7;\nconst int maxn = 75 + 2;\nint dp[(1 << 20) + 2][maxn],a[maxn][maxn],ans,len;\nchar s[maxn];\nint main(){\n\n\tscanf(\"%d\",&len);\n\tscanf(\"%s\",s + 1);\n\tfor(int i = 0; i <= len; ++i){\n\t\tfor(int j = i + 1; j <= len; ++j){\n\t\t\ta[i][j] = (a[i][j - 1] << 1) + s[j] - '0';\n\t\t}\n\t}\n\tint tmp = min(len,20);\n\tfor(int i = 0; i < len; ++i) dp[0][i] = 1;\n\tint t = (1 << tmp);\n\tfor(int i = 0; i < t; ++i){\n\t\tfor(int j = 0; j < len; ++j){\n\t\t\tif(dp[i][j])\n\t\t\tfor(int k = j + 1; k <= len + 1; ++k){\n\t\t\t\tif(a[j][k] && a[j][k] <= 20){\n\t\t\t\t\tdp[i | (1 << (a[j][k] - 1))][k] += dp[i][j];\n\t\t\t\t\tdp[i | (1 << (a[j][k] - 1))][k] %= mod;\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor(int i = 1; i <= tmp; ++i){\n\t\tfor(int j = 1; j <= len; ++j){\n\t\t\tif(dp[(1 << i) - 1][j]){\n\t\t\t\tans += dp[(1 << i) - 1][j];\n\t\t\t\tans %= mod;\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\\n\",ans);\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "56319407958bb9b17bebde2f75591978", "src_uid": "61f88159762cbc7c51c36e7b56ecde48", "difficulty": 2200.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\ntypedef long long ll;\nconst int mod = 1e9 + 7;\nint d[76][(1 << 20) + 100];\n\nint main()\n{\n int n;\n cin >> n;\n\n vector s(n + 1);\n for (int i = 1; i <= n; i++){\n char c;\n cin >> c;\n s[i] = c - '0';\n }\n\n for (int i = 0; i <= n; i++)\n d[i][0] = 1;\n\n for (int i = 1; i <= n; i++){\n int st = 1, cur = 0;\n\n for (int j = i; j > 0; j--){\n cur += st * s[j];\n\n if (cur != 0)\n for (int mask = 0; mask < (1 << 20); mask++)\n d[i][mask | (1 << (cur - 1))] = (d[i][mask | (1 << (cur - 1))] + d[j - 1][mask]) % mod;\n\n st *= 2;\n }\n }\n\n for (int mask = 0; mask < (1 << 20); mask++)\n d[n + 1][mask] = d[n][mask];\n\n int ans = 0;\n for (int i = 1; i <= n; i++){\n int cur = 2;\n for (int j = 1; j <= 20; j++){\n //cout << i << ' ' << cur << ' ' << d[i][cur - 1] << \"\\n\";\n ans = (ans + d[i][cur - 1]) % mod;\n cur *= 2;\n }\n }\n\n cout << ans;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "914becc3d5399da708c038fae27639e9", "src_uid": "61f88159762cbc7c51c36e7b56ecde48", "difficulty": 2200.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint main()\n{\n int x,y,z,t1,t2,t3;\n cin>>x>>y>>z>>t1>>t2>>t3;\n int ans1,ans2;\n ans1 = (x-y)*t1;\n ans2 = (t3 + (abs(x-z))*t2) + (t3 + (x-y)*t2);\n if(ans2\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define ll long long\n#define ull unsigned long long\n\nusing namespace std;\n\nint x, y, z, t1, t2, t3;\n\nint main(){\n cin >> x >> y >> z >> t1 >> t2 >> t3;\n\n int lift = t3 + fabs(x - z) * t2 + fabs(x - y) * t2;\n int masha = t1 * (x - y); \n\n if (lift <= masha){\n cout << \"YES\";\n }else{\n cout << \"NO\";\n }\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ba68075678b3f46e3e3b11f3f0ff7c07", "src_uid": "05cffd59b28b9e026ca3203718b2e6ca", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint a,b,c,d,i,e,f,g,n,m,k,l,x,y,z,t1,t2,t3;\nint main()\n{\n cin>>x>>y>>z>>t1>>t2>>t3;\n a=(x-y)*t1;\n b=(x-z)*t2+(x-y)*t2+3*t3;\n if(a\nusing namespace std;\n#define ll long long int\nint main()\n{\n // string s;\n ll n,m,x,y,z,t,tt,ttt;\n cin>>x>>y>>z>>t>>tt>>ttt;\n ll s=abs(x-y);\n ll ss=t*z;\n ll ans=tt+s*ttt+z*tt;\n //cout<ans)\n cout<<\"YES\"<\n#include\nusing namespace std;\nint a[1000000];\nint main()\n{\nlong long n,i,x,flag=0,l,m,y;\ncin>>n;\nfor(i=1;i<1000;i++)\n a[(i*(i+1))/2]=1;\nfor(i=1;(i*(i+1))/2<=n/2;i++)\n {\n l=i*(i+1);\n l=l/2;\n if(a[l]==1)\n if(a[(n-l)]==1)\n {\n cout<<\"YES\";\n return 0;\n }\n }\n\n cout<<\"NO\";\n }\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2da1d54ecd466c66c962fbc26b57fcc9", "src_uid": "245ec0831cd817714a4e5c531bffd099", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "#include \n#include \nusing namespace std;\nbool binarySearch(int n , vector a){\n int lo=0;\n int hi=n/2;\n while(lo n) hi--;\n else lo++;\n }\n return false;\n}\nint main(){\n int n; cin>>n;\n int ans=0;\n vector v;\n for(int i=1;i<=44721;i++){\n ans = (i*(i+1))/2;\n v.push_back(ans);\n }\n \n if(binarySearch(n ,v)) cout << \"YES\\n\";\n else cout << \"NO\\n\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9dbabf68a9fe6602782e212d26516fff", "src_uid": "245ec0831cd817714a4e5c531bffd099", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\nusing namespace std;\n\n\nint main()\n{\n int n;\n int i,j;\n \n cin>>n;\n \n for(i=1;(i*(i+1)/2)\n#include\n#include\nusing namespace std;\n\n\nint main()\n{\n int n;\n int i,j;\n \n cin>>n;\n \n for(i=1;(i*(i+1)/2)\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pll;\ntypedef vector vll;\ntypedef set sll;\n\n//DEBUG\n#define out1(x)cout<<#x<<\" is \"< y) ? x: y\n#define Vadd(v) accumulate(all(v), (long long)0)\n#define swap(VAR1,VAR2) VAR1=VAR1^VAR2;VAR2=VAR1^VAR2;VAR1=VAR1^VAR2\n#define Ibit(x) __builtin_popcount(x) //counts number of 1 in binary notation.\n#define Obit(x) __builtin_ctz(x) //counts number of \"trailing\" 0's in binary notaion.\n#define gcd(x,y) __gcd(x,y) //handle values (0,0) and (x,0) manually\n#define FastIn std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)\n#define exectime() cout<<\"execution time \"<<(double)(clock() - tStart)/CLOCKS_PER_SEC<>n>>a>>b;\n \n pll pi;\n \n n *= 6;\n \n req = a*b;\n if(req >= n){\n ok(req);\n okk(a,b);\n \n return 0;\n }\n \n side = ceil((ld)sqrt(n));\n area = side * side;\n \n queue< pll > qu; \n qu.push(mp(a,b));\n \n while(!qu.empty()){\n pi = qu.front();\n qu.pop();\n \n temp = (pi.F) * (pi.S);\n \n if(temp >= n && temp < mini){\n mini = temp;\n \n p = pi.F;\n q = pi.S;\n }\n \n if(((pi.F +1)*(pi.S+1)) <= area){\n qu.push(mp(pi.F+1,pi.S+1));\n }\n \n if(((pi.F +1)*(pi.S)) <= area){\n qu.push(mp(pi.F+1,pi.S));\n }\n \n if(((pi.F)*(pi.S+1)) <= area){\n qu.push(mp(pi.F,pi.S+1));\n }\n }\n \n ok(mini);\n okk(p,q);\n //exectime(); \n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7ccd484421d402f35ae6050266303432", "src_uid": "6a2a584d36008151d18e5080aea5029c", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include \ntypedef long long ll;\n#define OO 0x7fffffff\nusing namespace std;\ntypedef vector vi;\ntypedef vector > vecii;\ntypedef vector > vecll;\ntypedef vector vi;\n/*\nll pow1(ll x, ll y) // computes (x^y) in O(log(y))\n{\nif (y == 0)\nreturn 1;\nif (y % 2 == 0)\n{\nll temp = pow1(x, y / 2);\nreturn (temp*temp);\n}\nreturn x * pow1(x, y - 1);\n}\n\n\nvector primes; // save a list of all prime Numbers smaller than MAX_N\nbool is_prime[1004]; // check if index(number) is prime or not !\nvoid sieve(){ // Big-O( nlog(log(n)) )\n for (ll i = 0; i < 1004; i++)\n is_prime[i] = true;\n is_prime[0] = is_prime[1] = false ;\n for (ll i = 2; i < 1004; i++)\n {\n if (is_prime[i]) // prime number found :D\n {\n primes.push_back(i); //\n for (ll j = i + i; j < 1004; j+=i)\n is_prime[j] = false;\n }\n }\n}\n\nvi prime_Factors(ll N) { // remember: vi is vector, ll is long long\nvi factors; //\nll PF_idx = 0, PF = primes[PF_idx]; // using PF = 2, then 3,5,7,...\nwhile (N != 1 && (PF * PF <= N)) {\nwhile (N % PF == 0) { N /= PF; factors.push_back(PF); }\n\nPF = primes[++PF_idx]; // only consider primes!\n}\nif (N != 1) factors.push_back(N);\nreturn factors;\n}\n\n\n/*vector > g(100004);\nint h=0;\nbool vis[100004];\nvoid dfs (int u)\n{\n vis[u]=true;\n int c=0;\n if (g[u].first>m)\n return;\n for (int i = 0 ; i > v;\nll f (ll a , ll b)\n{\n\n if (a*b >= 6*n)\n {\n v[a*b]=make_pair(a,b);\n return a*b;\n }\n return min (f(a+1 , b) , f(a , b+1));\n}\n\n\n\nint main()\n{\n //freopen(\"in.txt\" , \"r\" , stdin);\n cin>>n>>a>>b;\n ll c=f(a,b);\n cout<\nusing namespace std;\nlong long n,a,b;\npair des (pair d)\n{\n //cout< p,c;\n p=des (make_pair(d.first+1,d.second));\n c=des (make_pair(d.first,d.second+1));\n if (p.first*p.second>n>>a>>b;\n pair d;\n //cout<<\"SS\"<\ntypedef long long ll;\n#define OO 0x7fffffff\nusing namespace std;\ntypedef vector vi;\ntypedef vector > vecii;\ntypedef vector > vecll;\ntypedef vector vi;\n/*\nll pow1(ll x, ll y) // computes (x^y) in O(log(y))\n{\nif (y == 0)\nreturn 1;\nif (y % 2 == 0)\n{\nll temp = pow1(x, y / 2);\nreturn (temp*temp);\n}\nreturn x * pow1(x, y - 1);\n}\n\n\nvector primes; // save a list of all prime Numbers smaller than MAX_N\nbool is_prime[1004]; // check if index(number) is prime or not !\nvoid sieve(){ // Big-O( nlog(log(n)) )\n for (ll i = 0; i < 1004; i++)\n is_prime[i] = true;\n is_prime[0] = is_prime[1] = false ;\n for (ll i = 2; i < 1004; i++)\n {\n if (is_prime[i]) // prime number found :D\n {\n primes.push_back(i); //\n for (ll j = i + i; j < 1004; j+=i)\n is_prime[j] = false;\n }\n }\n}\n\nvi prime_Factors(ll N) { // remember: vi is vector, ll is long long\nvi factors; //\nll PF_idx = 0, PF = primes[PF_idx]; // using PF = 2, then 3,5,7,...\nwhile (N != 1 && (PF * PF <= N)) {\nwhile (N % PF == 0) { N /= PF; factors.push_back(PF); }\n\nPF = primes[++PF_idx]; // only consider primes!\n}\nif (N != 1) factors.push_back(N);\nreturn factors;\n}\n\n\n/*vector > g(100004);\nint h=0;\nbool vis[100004];\nvoid dfs (int u)\n{\n vis[u]=true;\n int c=0;\n if (g[u].first>m)\n return;\n for (int i = 0 ; i > v;\nll f (ll a , ll b)\n{\n\n if (a*b >= 6*n)\n {\n v[a*b]=make_pair(a,b);\n return a*b;\n }\n return min (f(a+1 , b) , f(a , b+1));\n}\n\n\n\nint main()\n{\n //freopen(\"in.txt\" , \"r\" , stdin);\n cin>>n>>a>>b;\n cout<\n\n#define Write freopen(\"out.txt\",\"w\",stdout)\n#define Read freopen(\"in.txt\",\"r\",stdin)\n\n#define si(a) scanf(\"%d\",&a)\n#define sii(a,b) scanf(\"%d %d\",&a,&b)\n#define siii(a,b,c) scanf(\"%d %d %d\",&a,&b,&c)\n#define sl(a) scanf(\"%lld\",&a)\n#define sll(a,b) scanf(\"%lld %lld\",&a,&b)\n#define slll(a,b,c) scanf(\"%lld %lld %lld\",&a,&b,&c)\n\n#define lli long long\n#define m_p make_pair\n#define p_b push_back\n\n\n#define lim 10000000\n#define mod 100007\n#define mx 100004\n#define PI 3.141592654\nusing namespace std;\n\n/*** Direction Array ***/\nint dirx[]= {1,0,-1,0};\nint diry[]= {0,1,0,-1};\nint nwx[]={1,1,-1,-1};\nint nwy[]={1,-1,1,-1};\n/**** Translator Functions***/\n//int ToInt(string s){int r = 0;stringstream sin(s);sin >> r;return r;}\n//double ToDouble(string s) { double r = 0; stringstream sin(s); sin >> r; return r; }\n//string ToString(int n) { string s; stringstream convert;convert << n;s = convert.str();return s;}\n\n/*****My code goes from here****/\nusing namespace std;\nmap,bool>mp;\nint srcx,srcy,desx,desy;\nint a,b;\nbool flag=false;\nvoid dfs(int x,int y,int cnt)\n{\n if(x>100000||y>100000||x<-100000||y<-100000) return ;\n pairu=m_p(x,y);\n mp[u]=true;\n for(int i=0;i<4;i++)\n {\n int p,q;\n p=x+nwx[i];\n q=y+nwy[i];\n pairv=m_p(p,q);\n if(p==desx&&q==desy){\n flag=true;\n }\n if(mp[v]==false)\n {\n mp[v]=true;\n dfs(p,q,cnt+1);\n }\n }\n}\n\nint main()\n{\n\n cin>>srcx>>srcy;\n cin>>desx>>desy;\n\n cin>>a>>b;\n dfs(srcx,srcy,1);\n if(flag ) cout<<\"YES\"<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define ll long long\n#define mem(a,b) memset(a,b,sizeof(a))\n#define for1(i,n) for(int i=0;itp;\n node now,then;\n now.x=x1,now.y=Y1;\n tp.push(now);\n while(!tp.empty()){\n now=tp.front();\n tp.pop();\n if(num>10000000000)\n return false;\n if(now.x==x2&&now.y==y2)\n return true;\n then.x=now.x+x,then.y=now.y+y;\n tp.push(then),num++;\n then.x=now.x+x,then.y=now.y-y;\n tp.push(then),num++;\n then.x=now.x-x,then.y=now.y+y;\n tp.push(then),num++;\n then.x=now.x-x,then.y=now.y-y;\n tp.push(then),num++;\n }\n}\nint main() {\n while(scanf(\"%I64d%I64d%I64d%I64d%I64d%I64d\",&x1,&Y1,&x2,&y2,&x,&y)!=EOF){\n printf(\"%s\\n\",bfs()?\"YES\":\"NO\");\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0297e5912a08791973f96bec03a81386", "src_uid": "1c80040104e06c9f24abfcfe654a851f", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include\n\n#define Write freopen(\"out.txt\",\"w\",stdout)\n#define Read freopen(\"in.txt\",\"r\",stdin)\n\n#define si(a) scanf(\"%d\",&a)\n#define sii(a,b) scanf(\"%d %d\",&a,&b)\n#define siii(a,b,c) scanf(\"%d %d %d\",&a,&b,&c)\n#define sl(a) scanf(\"%lld\",&a)\n#define sll(a,b) scanf(\"%lld %lld\",&a,&b)\n#define slll(a,b,c) scanf(\"%lld %lld %lld\",&a,&b,&c)\n\n#define lli long long\n#define m_p make_pair\n#define p_b push_back\n\n\n#define lim 10000000\n#define mod 100007\n#define mx 100004\n#define PI 3.141592654\nusing namespace std;\n\n/*** Direction Array ***/\nint dirx[]= {1,0,-1,0};\nint diry[]= {0,1,0,-1};\nint nwx[]={1,1,-1,-1};\nint nwy[]={1,-1,1,-1};\n/**** Translator Functions***/\n//int ToInt(string s){int r = 0;stringstream sin(s);sin >> r;return r;}\n//double ToDouble(string s) { double r = 0; stringstream sin(s); sin >> r; return r; }\n//string ToString(int n) { string s; stringstream convert;convert << n;s = convert.str();return s;}\n\n/*****My code goes from here****/\nusing namespace std;\nmap,bool>mp;\nint srcx,srcy,desx,desy;\nint a,b;\nbool flag=false;\nvoid dfs(int x,int y,int cnt)\n{\n if(x>1000||y>1000||x<-1000||y<-1000) return ;\n pairu=m_p(x,y);\n mp[u]=true;\n for(int i=0;i<4;i++)\n {\n int p,q;\n p=x+nwx[i];\n q=y+nwy[i];\n pairv=m_p(p,q);\n if(p==desx&&q==desy){\n flag=true;\n }\n if(mp[v]==false)\n {\n mp[v]=true;\n dfs(p,q,cnt+1);\n }\n }\n}\n\nint main()\n{\n\n cin>>srcx>>srcy;\n cin>>desx>>desy;\n\n cin>>a>>b;\n dfs(srcx,srcy,1);\n if(flag ) cout<<\"YES\"<\n#include \n/*#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include */\n//std::ifstream cin(\"input.txt\");\n//std::ofstream cout(\"output.txt\");\n//freopen(\"input.txt\",\"r\",stdin);\n//freopen(\"output.txt\",\"w\",stdout);\n//cout< >vec,vec1;\nint main()\n{\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n\tlong long x1,y1,x2,y2,x,y,c=0; cin>>x1>>y1>>x2>>y2>>x>>y;\n\tif(x1==x2&&y2==y1){cout<<\"YES\"<x2&&vec[i].second>y2){cout<<\"NO\"<x2&&vec1[i].second>y2){cout<<\"NO\"<\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef pair II;\n#define S second\n#define F first\n\n#define PB push_back\n#define SZ(A) ((int)(A).size())\n\nstruct state{\n\tbool b;\n\tint f, s;\n\tstate(){}\n};\n\nmap cnt[31];\nmap score[31];\nmap mem;\n\nint calc_score(string s) {\n\tint sz = s.size();\n\tint mx = 0;\n\tint total = 0;\n\tfor(int i=0 ; i::iterator inter = mem.find(s);\n\tif( inter != mem.end() ) return inter->second;\n\n\tstring aux1, aux2;\n\tbool allWin = true;\n\tint sz = s.size();\n\tint moves = 0;\n\t\n\tvector all(0);\n\t\n\tfor(char c='a' ; c<='z' ; c++) {\n\t\taux1 = s+c;\n\t\taux2 = c+s;\n\t\tif(cnt[sz+1][aux1]) {\n\t\t\tmoves++;\n\t\t\tall.PB(bt(aux1));\n\t\t}\n\t\tif(sz>0 && cnt[sz+1][aux2]) {\n\t\t\tmoves++;\n\t\t\tall.PB(bt(aux2));\n\t\t}\n\t}\n\t\n\tstate ret;\t\n\tif(moves == 0) {\n\t\tret.b = false;\n\t\tret.f = 0; ret.s = 0;\n\t\tif(sz&1) ret.f = score[sz][s];\n\t\telse ret.s = score[sz][s];\n\n//\t\tcout << s << \" \" << first << \" \" << second << endl;\n\t\tmem[s] = ret;\n\t\treturn ret;\n\t}\n\t\n\tbool win = false;\n\tfor(int i=0 ; iall[i].f)) {\n\t\t\t\tfir = all[i].f;\n\t\t\t\tsec = all[i].s;\n\t\t\t}\n\t} else if(win && !(sz&1)){\n\t\tfor(int i=0 ; i < SZ(all) ; i++) if(!all[i].b)\n\t\t\tif(firall[i].s)) {\n\t\t\t\tfir = all[i].f;\n\t\t\t\tsec = all[i].s;\n\t\t\t}\t\n\t}else if(!win && (sz&1)) {\n\t\t//juega segundo\n\t\tfor(int i=0 ; i < SZ(all) ; i++) if(all[i].b)\n\t\t\tif(secall[i].f)) {\n\t\t\t\tfir = all[i].f;\n\t\t\t\tsec = all[i].s;\n\t\t\t}\n\t}else {\n\t\tfor(int i=0 ; i < SZ(all) ; i++) if(all[i].b)\n\t\t\tif(firall[i].s)) {\n\t\t\t\tfir = all[i].f;\n\t\t\t\tsec = all[i].s;\n\t\t\t}\t\n\t}\n\t\n\tret.b = win;\n\tret.f = fir;\n\tret.s = sec;\n\tif(sz&1) ret.f += score[sz][s];\n\telse ret.s += score[sz][s];\n\n\tmem[s] = ret;\n\treturn ret;\n}\n\nint main() {\n\n\tint n;\n\tcin>> n;\n\t\n\tstring s;\n\tfor(int i=0 ; i> s;\n\t\tmap found;\n\n\t\tfor(int k=0; k::iterator j=cnt[i].begin() ; j!=cnt[i].end() ; j++){\n//\t\t\tcout << (*j).F << endl;\n\t\t\tscore[i][(*j).F] = calc_score((*j).F);\n\t\t}\n\t}\n\t\n\tcnt[0][\"\"] ++;\t\n\tstring init = \"\";\n\tstate ret = bt(init);\t\n\n\tif(ret.b) {\n\t\tcout << \"First\" << endl;\n\t\tcout << ret.f << \" \" << ret.s << endl; \n\t}else{\n\t\tcout << \"Second\" << endl;\n\t\tcout << ret.f << \" \" << ret.s << endl; \n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0958d1232a0eebe22133e55a6d4811ca", "src_uid": "d0f8976d9b847f7426dc56cb59b5b5b9", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define f first\n#define s second\n#define pb push_back\n#define SZ 27000\n#define ll long long\n#define P 31\nstruct game\n{\n int who,first,second;\n game(int _who=-1,int _frs=0,int _sec=0)\n {\n who=_who;\n first=_frs;\n second=_sec;\n }\n};\nvector a,iver;\nvector tree[SZ];\nvector tmp;\nvector dp,ver[SZ];\nmap mp;\nqueue q;\nint sz=1,n;\nbool was[SZ];\n\nll Hash(string s)\n{\n ll ans=0,p=1;\n for(int i=0;i0 && s[i]!=s[j])j=p[j-1];\n if (s[i]==s[j])j++;\n p[i]=j;\n if (ln==j)\n {\n if (ln==0)\n {\n if (!frnt[s[i]-'a'+1])\n {\n frnt[s[i]-'a'+1]=true;\n int t=mp[s[i]-'a'+1];\n if (t==0)\n {\n mp[s[i]-'a'+1]=sz++;\n tree[v].pb(sz-1);\n q.push(s1+s[i]);\n iver.pb(s1+s[i]);\n }\n }\n } else \n {\n l=i-ln;\n if (i!=s.size()-1 && !frnt[s[i+1]-'a'+1])\n {\n frnt[s[i+1]-'a'+1]=true;\n int t=mp[hesh+(s[i+1]-'a'+1)*pw];\n if (t!=0)tree[v].pb(t);\n else mp[hesh+(s[i+1]-'a'+1)*pw]=sz++,tree[v].pb(sz-1),q.push(s1+s[i+1]),iver.pb(s1+s[i+1]);//,cout<<\"add= \"<b.who || a.who==b.who && a.f>b.f || a.who==b.who && a.f==b.f && a.sb.s || a.who==b.who && a.s==b.s && a.f0 && s[i]!=s[j])j=p[j-1];\n if (s[i]==s[j])j++;\n p[i]=j;\n if (p[i]==ln)return true;\n }\n return false;\n}\nint score(string s)\n{\n if (s.size()==0)return 0;\n int sum=0,maxi=0;\n for(int i=0;i>n;\n a.resize(n);\n for(int i=0;i>a[i];\n build();\n for(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define pb push_back\n#define all(c) c.begin(), c.end()\n#define mp(x, y) make_pair(x, y)\n#define sz(x) static_cast(x.size())\ntypedef long long int64;\ntypedef pair ii;\n\nstruct Point\n{\n int x;\n int y;\n Point(int x_, int y_): x(x_), y(y_)\n { }\n};\n\ntemplate T sqr(const T& t) {return t * t;}\ntemplate T abs(const T& t) {return ((t > 0) ? (t) : (-t));}\n\nvoid initialize()\n{\n freopen(\"_.in\", \"r\", stdin);\n freopen(\"_.out\", \"w\", stdout);\n}\n\nconst int MAX = 30 + 5;\nconst int INF = (int)1e9;\n\nint posresScore = 0;\nmap positions;\nvector reb[MAX];\n\nconst int NMAX = MAX * MAX * MAX;\nint freq[NMAX];\nint sum[NMAX];\nint maxV[NMAX];\nvector freqMas[NMAX];\n\nint score[NMAX];\n\nbool solve[NMAX];\nbool haveSolve[NMAX];\nii resScore[NMAX];\n\nvoid run(int pos) {\n\tif (haveSolve[pos]) {\n\t\treturn;\n\t}\n\tsolve[pos] = false;\n\tfor (int i = 0; i < reb[pos].size(); ++i) {\n\t\tint npos = reb[pos][i];\n\t\trun(npos);\n\t\tif (!solve[npos]) {\n\t\t\tsolve[pos] = true;\t\n\t\t}\n\t}\n\n\tii bestCount = ii(0, 0);\n\tfor (int i = 0; i < reb[pos].size(); ++i) {\n\t\tint npos = reb[pos][i];\n\t\tii ncount = resScore[npos];\n\t\tif (solve[pos] && !solve[npos]) {\n\t\t\tncount.first += score[npos];\n\t\t\tbestCount = max(bestCount, ncount);\n\t\t}\n\t\tif (!solve[pos]) {\n\t\t\tncount.second += score[npos];\n\t\t\tbestCount = max(bestCount, ncount);\n\t\t}\n\t}\n\n\tresScore[pos] = bestCount;\n\thaveSolve[pos] = true;\n}\n\n\nint main()\n{\n //initialize();\n\n\tvector ss;\n\tpositions[\"\"] = posresScore++;\n\n\tint n;\n\tcin >> n;\n\tfor (int k = 0; k < n; ++k) {\n\t\tstring s;\n\t\tcin >> s;\n\t\tss.pb(s);\n\t}\t\t\n\n\tfor (int j = 1; j < MAX; ++j) {\n\t\tfor (int k = 0; k < ss.size(); ++k) {\n\t\t\tconst string& s = ss[k];\n\t\t\tfor (int i = 0; i + j <= s.size(); ++i) {\n\t\t\t\tstring ss = s.substr(i, j);\n\t\t\t\tif (positions.find(ss) == positions.end()) {\n\t\t\t\t\tpositions[ss] = posresScore++;\n\t\t\t\t}\n\t\t\t\tint pos = positions[ss];\n\t\t\t\tfreqMas[pos].pb(k);\n\t\t\t\treb[positions[s.substr(i, j - 1)]].push_back(pos);\n\t\t\t\treb[positions[s.substr(i + 1, j - 1)]].push_back(pos);\n\t\t\t\t\n\t\t\t\tsum[pos] = sum[positions[s.substr(i + 1, j - 1)]] + (s[i] - 'a' + 1);\n\t\t\t\tmaxV[pos] = max(maxV[positions[s.substr(i + 1, j - 1)]], (s[i] - 'a' + 1));\n\t\t\t\tscore[pos] = sum[pos] * maxV[pos];\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (int i = 0; i < posresScore; ++i) {\n\t\tsort(all(freqMas[i]));\n\t\tfreq[i] = unique(all(freqMas[i])) - freqMas[i].begin();\n\t\tscore[i] += freq[i];\n\t}\n\n\trun(0);\n\n\tif (solve[0]) {\n\t\tprintf(\"First\\n%d %d\\n\", resScore[0].first, resScore[0].second);\n\t}\n\telse {\n\t\tprintf(\"Second\\n%d %d\\n\", resScore[0].second, resScore[0].first);\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a75dab9f2ac63bf6d7c9aaf2e8df6597", "src_uid": "d0f8976d9b847f7426dc56cb59b5b5b9", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define LL long long\n#define pi 3.1415926535897932384626433 \n#define sqr(a) ((a)*(a))\n\nusing namespace std;\n\nstring a[40];\nint f[9000], s1[9000], s2[9000], v[9000], n;\nmap u;\n\nint score(string s)\n{\n int ans = 0, cur;\n for (int i = 0; i < s.size(); i ++)\n ans += s[i] - 96;\n cur = 0;\n for (int i = 0; i < s.size(); i ++)\n cur = max(cur, s[i] - 96);\n ans *= cur;\n for (int i = 1; i <= n; i ++)\n if (a[i].find(s) != string::npos)\n ans ++;\n return ans;\n}\n\nvoid dp(int x, string cur)\n{\n if (v[x]) return ; v[x] = 1;\n int endit = 0;\n f[x] = 0; s1[x] = 0; s2[x] = 1000000000;\n //front\n for (int i = 1; i <= 26; i ++)\n {\n string v = \"\"; v += char(i + 96); v += cur;\n if (! u.count(v)) continue;\n endit = 1;\n int next = u[v], now = score(v);\n dp(next, v);\n// if (x == u[\"a\"]) cout << v << \" \" << next << \" : \" << f[next] << endl;\n if (f[next] == 0 && f[x] == 0)\n {\n f[x] = 1; s1[x] = now + s2[next]; s2[x] = s1[next];\n }\n else if ((f[next] ^ 1) == f[x])\n {\n int S1 = now + s2[next];\n int S2 = s1[next];\n if (S1 > s1[x] || S1 == s1[x] && S2 < s2[x])\n {\n s1[x] = S1; s2[x] = S2;\n }\n }\n }\n //back\n for (int i = 1; i <= 26; i ++)\n {\n string v = cur; v += char(i + 96);\n if (! u.count(v)) continue;\n endit = 1;\n int next = u[v], now = score(v);\n dp(next, v);\n// if (x == u[\"a\"]) cout << v << \" \" << next << \" : \" << f[next] << endl;\n if (f[next] == 0 && f[x] == 0)\n {\n f[x] = 1; s1[x] = now + s2[next]; s2[x] = s1[next];\n }\n else if ((f[next] ^ 1) == f[x])\n {\n int S1 = now + s2[next];\n int S2 = s1[next];\n if (S1 > s1[x] || S1 == s1[x] && S2 < s2[x])\n {\n s1[x] = S1; s2[x] = S2;\n }\n }\n }\n if (endit == 0)\n {\n s1[x] = 0; s2[x] = 0;\n }\n// cout << x << \" \" << cur << \" : \" << s1[x] << endl;\n} \n \nint main()\n{\n cin >> n;\n for (int i = 1; i <= n; i ++)\n cin >> a[i];\n u.clear();\n int tot = 0;\n for (int i = 1; i <= n; i ++)\n for (int x = 0; x < a[i].size(); x ++)\n {\n string cur = \"\";\n for (int y = x; y < a[i].size(); y ++)\n {\n cur += a[i][y];\n if (! u.count(cur))\n u[cur] = ++ tot;\n }\n }\n memset(v, 0, sizeof(v));\n int win = 0, S1 = 0, S2 = 1000000000;\n for (int i = 1; i <= 26; i ++)\n {\n string v = \"\"; v += char(i + 96);\n if (! u.count(v)) continue;\n int next = u[v], now = score(v);\n dp(next, v);\n if (f[next] == 0 && win == 0)\n {\n win = 1; S1 = s2[next] + now; S2 = s1[next];\n }\n else if ((f[next] ^ 1) == win)\n if (s2[next] + now > S1 || s2[next] + now == S1 && s1[next] < S2)\n {\n S1 = s2[next] + now; S2 = s1[next];\n }\n } \n if (win) cout << \"First\" << endl; \n else cout << \"Second\" << endl;\n cout << S1 << \" \" << S2 << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "aa4f9bce79b5aa73e2b30d17ef9d9011", "src_uid": "d0f8976d9b847f7426dc56cb59b5b5b9", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\n#define pb push_back\n#define For(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))\n#define all(v) v.begin(),v.end()\n#define V vector\ntypedef long long ll;\n/***********************************************/\n/* Dear GCC compiler:\n * I've wasted time reading the problem and trying to figure out the solution\n * If there's any syntax error and you've any suggestion, please fix it yourself.\n * I hope my code compile and get accepted. KEE O.o\n * ____________\n * / __ \\\n * / __ | | \\\n * / |__| | | \\\n * ( |__| )\n * \\ /\n * \\ ___ /\n * \\____________/\n */\n/**/\nconst ll mod = 1000000007;\nint main(){\n\tios_base::sync_with_stdio(false);\n\tcin.tie(nullptr);\n\tint n,d,m,cur;\n\tV a(n),sum(1,0);\n\tcin>>n>>d;\n\tFor(i,0,n){\n\t\tcin>>a[i];\n\t}\n\tsort(all(a));\n\tFor(i,0,n){\n\t\tsum.pb(sum.back() + a[i]);\n\t}\n\tcin>>m;\n\tint res = sum[min(m,n)];\n\tif(m > n)\n\t\tres -= (m-n)*d;\n\tcout<\n#include\n\nusing namespace std;\n\nint main()\n{\nint n,d,sum=0;\nint *arr=new int[n];\ncin >> n >> d;\n\nfor(int i=0;i> arr[i];\n\nint m;\ncin >> m;\n\nsort(arr,arr+n);\nfor(int i=0;i\n\nusing namespace std;\n\nint n,m,s,x,t[100000000];\n\nint main () {\n cin >> n >> m;\n for(int i = 0; i < n;i++){\n cin >> t[i];\n s+=t[i];\n }\n sort(t,t+n);\n cin >> x;\n if(x>=n)cout << s-((x-n)*m);\n else {\n s=0;\n for(int i = 0;i < x;i++){\n s+=t[i];\n }\n cout << s;\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "59bf0633c5d927b259ea9a021a066c30", "src_uid": "5c21e2dd658825580522af525142397d", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nint n,m,s,x,t[100000000];\n\nint main () {\n cin >> n >> m;\n for(int i = 0; i < n;i++){\n cin >> t[i];\n s+=t[i];\n }\n cin >> x;\n if(x>=n)cout << s-((x-n)*m);\n else {\n s=0;\n for(int i = 0;i < x;i++){\n s+=t[i];\n }\n cout << s;\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "201172a2354afb269761d423dbef3acf", "src_uid": "5c21e2dd658825580522af525142397d", "difficulty": 1000.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\n\nint main()\n{\n int n, sum = 0;\n cin>>n;\n int a[100];\n int i, j;\n for (i = 1; i <= n; i++)\n cin>>a[i];\n sort(a+1, a+n+1);\n for (j = 0; j < n/2; j++)\n {\n sum =sum + a[2*j+2] - a[2*j+1];\n }\n cout< \nusing namespace std; \n\nvoid swap(int *xp, int *yp) \n{ \n\tint temp = *xp; \n\t*xp = *yp; \n\t*yp = temp; \n} \n\n// A function to implement bubble sort \nvoid bubbleSort(int arr[], int n) \n{ \n\tint i, j; \n\tfor (i = 0; i < n-1; i++)\t \n\t\n\t// Last i elements are already in place \n\tfor (j = 0; j < n-i-1; j++) \n\t\tif (arr[j] > arr[j+1]) \n\t\t\tswap(&arr[j], &arr[j+1]); \n} \n\n/* Function to print an array */\nvoid printArray(int arr[], int size) \n{ \n\tint s=0; \n\tfor(int j=0;j>n;\n//\tcout<<\"array is...\\n\";\n\tfor(int i=0;i>arr[i];\n\t}\n\t//int n = sizeof(arr)/sizeof(arr[0]); \n\tbubbleSort(arr, n); \n//\tcout<<\"Sorted array: \\n\"; \n\tprintArray(arr, n); \n\treturn 0; \n} \n\n// This code is contributed by rathbhupendra \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "88092f3bdc33909a7a9806557a995ba2", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nusing ll = long long;\nusing ld = long double;\nusing pi = pair;\nusing pll = pair;\nconstexpr int INF = 0x3f3f3f3f; constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;\n#define db(x) { cerr << #x << \" = \" << x << endl; }\ntemplate void dbarr(RIt frs, RIt lst){ cerr << \"arr: \"; for(int i = 0; i < (int)(lst-frs); i++) cerr << frs[i] << \" \\n\"[i==(int)(lst-frs)-1]; }\n#define all(x) begin(x), end(x)\n#define pb push_back\n#define eb emplace_back\n#define mpr make_pair\n#define fs first\n#define sn second\n\nint main() {\n cin.tie(0)->sync_with_stdio(0);\n int n; cin >> n;\n vector a(n); for(int& v : a) cin >> v;\n multiset s; for(int v : a) s.insert(v);\n int ans = 0;\n for(int x : a){\n if(s.size() <= 1) break;\n s.erase(s.find(x));\n auto itr = s.lower_bound(x);\n if(itr == s.end()){\n int val = *--itr;\n ans += abs(val-x); s.erase(s.find(val));\n } else if(itr == s.begin()){\n int v1 = *itr;\n ans += abs(v1-x); s.erase(s.find(v1));\n } else{\n int v1 = *itr;\n int v2 = *--itr;\n if(abs(v1-x) < abs(v2-x)){\n ans += abs(v1-x);\n s.erase(s.find(v1));\n } else{\n ans += abs(v2-x);\n s.erase(s.find(v2));\n }\n }\n }\n cout << ans << \"\\n\";\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "931a50ff0348c5ded0f88d3036329f8b", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include\nconst int maxn = 101;\nint n , i , a[maxn] ,ans = 0;\nusing namespace std;\nvoid MTP()\n{\n cin >> n;\n for (i=1 ; i<=n ; i++)\n cin >> a[i];\n sort (a + 1,a + n + 1);\n for (i=1 ; i<=n/2 ; i++)\n {\n if (a[2*i-1] != a[2*i] && a[2*i] != a[2*i + 1])\n ans += abs(a[2*i] - a[2*i - 1]);\n }\n cout << ans;\n}\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n freopen( \"B.INP\" , \"r\", stdin );\n freopen( \"B.OUT\" , \"w\", stdout);\n MTP();\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7add2f8d7b068e685f7e4107eb22087f", "src_uid": "55485fe203a114374f0aae93006278d3", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include\n#define forn(i,a,b) for(int (i)=(a);!((i)==(b));(b)>(a)?(i)++:(i)--)\n#define FOR(i,a,b) for(int i=a; i> n;\n\n int a = n/10000 * 10000 + n%1000/100*1000 + n%10*100 + n%100/10*10 + n/1000%10;\n\n int r = a;\n FOR(i,0,4)\n {\n r = r*a;\n r = r%100000;\n }\n\n\tint c = cnt(r);\n\tc = 5-c;\n cout << r ;\n\twhile(c){cout << '0'; c--;} \n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b81758e9370ef7cda393a1f9052a5489", "src_uid": "51b1c216948663fff721c28d131bf18f", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main()\n{\n long long n;\n string a;\n cin>>a;\n n=(a[0]-'0')*10000+(a[2]-'0')*1000+(a[4]-'0')*100+(a[3]-'0')*10+a[1]-'0';\n long long c=1;\n for(int i=0;i<5;i++)\n {\n c=c*n;\n c=c%100000;\n }\n int k=4;\n for(int i=0;i<=c;i=i*10)\n {\n k--;\n }\n for(int i=0;i\n#include \n#include \n#include \nusing namespace std;\nlong long int a,b,c,e,cnt,d[10000009];\nstring s,k,l,o;\n// 7 8\n// 77 78 87 88\n// 777 778 787 877 887 878 788 888\n\n//\n//\nint binpow (long long int a, long long int n) {\n if (n == 0)\n return 1;\n if (n % 2 == 1)\n return (binpow (a, n-1) * a)%100000;\n else {\n long long int b = binpow (a, n/2);\n return (b * b)%100000;\n }\n}\nint main(){\n\n cin>>s;\n \n k+=s[0];\n k+=s[2];\n k+=s[4];\n k+=s[3];\n k+=s[1];\n e=atoi(k.c_str());\n cout<\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\nint arr[5];\nint c[10000];\n\nlong long power(int a, int b)\n{ \n long long p = power(a, b >> 1);\n p = (1LL * p * p) % 100000;\n if (b & 1)\n\tp = (1LL * p*a) % 100000;\n return p;\n}\n\n\n int main()\n {\n\tint n, p;\n\tcin >> n;\n\tstring s = to_string(n), str;\n\n\tstr.push_back(s[0]);\n\tstr.push_back(s[2]);\n\tstr.push_back(s[4]);\n\tstr.push_back(s[3]);\n\tstr.push_back(s[1]);\n p = power(stoi(str), 5);\n\tcout << p << endl;\n\n\treturn 0;\n }\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1400af945072444ebee9701c6d937e48", "src_uid": "51b1c216948663fff721c28d131bf18f", "difficulty": 1400.0} {"lang": "GNU C++17", "source_code": "// So when you feel like hope is gone, Look inside you and be strong, And you'll finally see the truth, That a hero lies in you ... \n \n#include\n\n#define F first\n#define S second\n#define PB push_back\n#define sz(s) int((s).size())\n#define bit(n,k) (((n)>>(k))&1)\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\n\nconst int maxn = 1e5 + 10, mod = 1e9 + 7;\nconst ll inf = 2e18;\n\ntemplate ostream& operator << (ostream& out, pair p){\n out << \"{ \" << p.F << \", \" << p.S <<\" }\";\n return out;\n}\ntemplate ostream& operator << (ostream& out, vector v){\n out << \"[ \";\n for(int i = 0; i < sz(v); i++){\n\tout << v[i];\n\tif(i != sz(v)-1)\n\t out << \" ,\";\n }\n out << \" ]\";\n return out;\n}\n\nll dq[maxn];\n\nll solve(ll n, ll k){\n ll ksm = 1ll * k * (k+1) /2;\n auto f = [&](ll x){\n\t\t return x * k + ksm - k;\n\t };\n auto fr = [&](ll x){\n\t\t ll l = 1, r = (x / k) + 10;\n\t\t while(r - l > 1){\n\t\t ll mid = (l+r) >> 1;\n\t\t if(f(mid) >= x)\n\t\t\t r = mid;\n\t\t else\n\t\t\t l = mid;\n\t\t }\n\t\t return r;\n\t };\n auto fl = [&](ll x){\n\t\t ll l = 1, r = (x / k) + 10;\n\t\t while(r - l > 1){\n\t\t ll mid = (l+r) >> 1;\n\t\t if(f(mid) <= x)\n\t\t\t l = mid;\n\t\t else\n\t\t\t r = mid;\n\t\t }\n\t\t return l;\n\t };\n vector vec;\n vec.PB({n, n});\n \n while(vec.back().F >= ksm + k + 1){\n\tll R = fr(vec.back().S + k + 1)-1, L = fl(vec.back().F - k - 1) + k;\n\tif(L > R)\n\t L = R;\n\tvec.PB({L, R});\n }\n \n reverse( vec.begin(), vec.end() );\n\n int L = 0, R = 0;\n \n ll pt = 0, cnt = 0, ans = 0;\n \n auto go = [&](){// to make ordere better\n\t\t ll sm = 0;\n\t\t int chosen = 0;\n\t\t while(chosen < k){\n\t\t while(L != R && dq[L] <= pt)\n\t\t\t ++L;\t\t \n\t\t ll lim = R!=L ? dq[L] : inf;\n\t\t ll choose = min( lim - pt -1 , k - chosen );\n\t\t if(pt+1 <= n && n <= pt + choose){\n\t\t\t ans+= n - pt;\n\t\t\t return true;\n\t\t }\n\t\t sm+= 1ll * choose * (pt + 1 + pt + choose) / 2;\n\t\t ans+= choose;\n\t\t chosen += choose;\n\t\t pt+= choose + (chosen < k);\n\t\t }\n\t\t ++ans;\n\t\t dq[R++] = sm;\n\t\t if(sm == n)\n\t\t return true;\n\t\t return false;\n\t };\n while(L == R || dq[R-1] <= vec[0].S)\n\tif(go())\n\t return ans;\n int pos = 0;\n while(true){\n\twhile(pos < sz(vec) && vec[pos].S <= pt)\n\t pos++;\n\tif(pos == sz(vec))\n\t break;\n\tif(pt < vec[pos].F){\n\t while(L != R && dq[L] <= pt)\n\t\t++L;\n\t ll bck = -1;\n\t ll emp = vec[pos].F - pt -1 -cnt;\n\t while(L != R && dq[L] < vec[pos].F)\n\t\tbck = dq[L], ++L, --emp;\n\t cnt = emp / k;\n\t ans+= cnt * (k+1);\n\t pt = vec[pos].F - (emp % k) - 1;\n\t if(pt < bck)\n\t\t--pt, dq[--L] = bck;\n\t}\n\twhile(pt < vec[pos].S)\n\t if(go())\n\t\treturn ans;\n }\n assert(0);\n}\n\nint main(){\n ios_base::sync_with_stdio(false); cin.tie(0); cout.tie();\n \n int q;\n cin >> q;\n while(q--){\n\tll n, k;\n\tcin >> n >> k;\n\tcout << solve(n, k) << \"\\n\";\n }\n return 0;\n}\n// #pragma GCC optimize(\"Ofast,no-stack-protector,unroll-loops,fast-math\")\n// #pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dfc4a60f3611c585ed3cd40d87b6b813", "src_uid": "053192b4f6acc3a94b701e787a4172e2", "difficulty": 3400.0} {"lang": "GNU C++17", "source_code": "#include \n#define ll long long\n#define maxn 1000005 /*rem*/\n#define mod 998244353\n#define db double\n#define vi vector\n#define pb push_back\n#define mp make_pair\n#define pi pair\n#define fi first\n#define se second\nusing namespace std;\nunordered_map r;\nll md;\nint k;\nll gt1(ll a) {\n\t// a * (k + 1)\u4f4d\u7f6e\u7684\u503c\n\tif (a == 0) return 0;\t\n\tif (a == 1) return 1ll * k * (k + 1) / 2;\n\tif (r[a]) return r[a];\n\n\tll cur = 0;\n\tll gt2(ll c);\n\tll gt3(ll c);\n\tll uu = gt2(1ll * (a - 1) * k + 1);\n\tll us = gt1(gt3(uu + k - 1));\n\tcur = k * (2 * uu + k - 1) / 2;\n\tif (us >= uu)\n\t\tcur += uu + k - us; \n//\tcout << \"GT1 \" << a << ' ' << cur << endl;\n\treturn r[a] = cur; \n}\nll gt2(ll c) {\n\tll gt3(ll c);\n\t// \u7b2c c \u4e2a\u6ca1\u6709\u51fa\u73b0\u5728 gt1 \u91cc\u7684\u6570\n\tif (c <= k) return c;\n\tll cur = c + c / md - 2;\n\tll ls = -1, lans = 0;\n\twhile (1) {\n\t\tll gs = (cur + md) / (md + 1);\n\t\tif (gs != ls) \n\t\t\tls = gs, lans = gt1(gs);\n\t\tif (lans > cur) gs--;\n\t\tif (cur - gs < c) cur++;\n\t\telse break;\n\t}\n//\tcout << \"GT2\" << c << ' ' << cur << endl; \n\treturn cur;\n} \nll gt3(ll c) {\n\t// \u4e0d\u8d85\u8fc7 c \u7684\u6700\u5927 gt1 \u4e0b\u6807\n\tll ur = (c + md) / (md + 1);\n\tif (gt1(ur) > c) ur--;\n//\tcout << \"GT3 \" << c << ' ' << ur << endl;\n\treturn ur; \n}\nll rd() {\n\treturn (rand() * 1ll << 45) + (rand() * 1ll << 30) + (rand() * 1ll << 15) + rand();\n}\nvoid read(ll &a) {\n\ta = 0;\n\tchar ch = getchar();\n\twhile (ch > '9' || ch < '0') ch = getchar();\n\twhile (ch >= '0' && ch <= '9')\n\t\ta = a * 10 + ch - '0', \n\t\tch = getchar();\n}\nvoid read(int &a) {\n\ta = 0;\n\tchar ch = getchar();\n\twhile (ch > '9' || ch < '0') ch = getchar();\n\twhile (ch >= '0' && ch <= '9')\n\t\ta = a * 10 + ch - '0', \n\t\tch = getchar();\n}\nint st[30];\nvoid otp(ll a) {\n\tint cnt = 0;\n\twhile (a)\n\t\tst[cnt++] = a % 10, a /= 10;\n\tfor (int i = cnt - 1; i >= 0; i--)\n\t\tputchar('0' + st[i]);\n\tputchar('\\n');\n}\nint main() {\n\tint test = 0;\n\tint t;\n\tif (test) t = 1e5;\n\telse read(t);\n\tfor (int i = 0; i < t; i++) {\n\t\tr.clear();\n\t\tll n;\n\t\tif (test) n = rd(), k = 2;\n\t\telse read(n), read(k);\n\t\tmd = 1ll * k * k;\n\t\tll id = gt3(n);\n\t\tll ans = 0;\n\t\tif (gt1(id) == n) ans = 1ll * id * (k + 1);\n\t\telse {\n\t\t\tn -= id;\n\t\t\tans = (n - 1) / k * (k + 1) + (n - 1) % k + 1; \n\t\t} \n\t\totp(ans);\n\t}\n\treturn 0;\n}\n ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a90b6f2ad3dd48b604caaac8f6f0ad1b", "src_uid": "053192b4f6acc3a94b701e787a4172e2", "difficulty": 3400.0} {"lang": "GNU C++14", "source_code": "#include\n\ntypedef unsigned int uint;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef double lf;\ntypedef long double llf;\ntypedef std::pair pii;\n\n#define xx first\n#define yy second\n\ntemplate inline T max(T a,T b){return a>b?a:b;}\ntemplate inline T min(T a,T b){return a inline T abs(T a){return a>0?a:-a;}\ntemplate inline bool repr(T &a,T b){return a inline bool repl(T &a,T b){return a>b?a=b,1:0;}\ntemplate inline T gcd(T a,T b){T t;if(a inline T sqr(T x){return x*x;}\n#define mp(a,b) std::make_pair(a,b)\n#define pb push_back\n#define I __attribute__((always_inline))inline\n#define mset(a,b) memset(a,b,sizeof(a))\n#define mcpy(a,b) memcpy(a,b,sizeof(a))\n\n#define fo0(i,n) for(int i=0,i##end=n;i=i##end;i--)\n#define foe(i,x)for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)\n#define fre(i,x)for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)\n\nstruct Cg{I char operator()(){return getchar();}};\nstruct Cp{I void operator()(char x){putchar(x);}};\n#define OP operator\n#define RT return *this;\n#define UC unsigned char\n#define RX x=0;UC t=P();while((t<'0'||t>'9')&&t!='-')t=P();bool f=0;\\\nif(t=='-')t=P(),f=1;x=t-'0';for(t=P();t>='0'&&t<='9';t=P())x=x*10+t-'0'\n#define RL if(t=='.'){lf u=0.1;for(t=P();t>='0'&&t<='9';t=P(),u*=0.1)x+=u*(t-'0');}if(f)x=-x\n#define RU x=0;UC t=P();while(t<'0'||t>'9')t=P();x=t-'0';for(t=P();t>='0'&&t<='9';t=P())x=x*10+t-'0'\n#define TR *this,x;return x;\nI bool IS(char x){return x==10||x==13||x==' ';}templatestruct Fr{T P;I Fr&OP,(int&x)\n{RX;if(f)x=-x;RT}I OP int(){int x;TR}I Fr&OP,(ll &x){RX;if(f)x=-x;RT}I OP ll(){ll x;TR}I Fr&OP,(char&x)\n{for(x=P();IS(x);x=P());RT}I OP char(){char x;TR}I Fr&OP,(char*x){char t=P();for(;IS(t);t=P());if(~t){for(;!IS\n(t)&&~t;t=P())*x++=t;}*x++=0;RT}I Fr&OP,(lf&x){RX;RL;RT}I OP lf(){lf x;TR}I Fr&OP,(llf&x){RX;RL;RT}I OP llf()\n{llf x;TR}I Fr&OP,(uint&x){RU;RT}I OP uint(){uint x;TR}I Fr&OP,(ull&x){RU;RT}I OP ull(){ull x;TR}};Frin;\n#define WI(S) if(x){if(x<0)P('-'),x=-x;UC s[S],c=0;while(x)s[c++]=x%10+'0',x/=10;while(c--)P(s[c]);}else P('0')\n#define WL if(y){lf t=0.5;for(int i=y;i--;)t*=0.1;if(x>=0)x+=t;else x-=t,P('-');*this,(ll)(abs(x));P('.');if(x<0)\\\nx=-x;while(y--){x*=10;x-=floor(x*0.1)*10;P(((int)x)%10+'0');}}else if(x>=0)*this,(ll)(x+0.5);else *this,(ll)(x-0.5);\n#define WU(S) if(x){UC s[S],c=0;while(x)s[c++]=x%10+'0',x/=10;while(c--)P(s[c]);}else P('0')\ntemplatestruct Fw{T P;I Fw&OP,(int x){WI(10);RT}I Fw&OP()(int x){WI(10);RT}I Fw&OP,(uint x){WU(10);RT}\nI Fw&OP()(uint x){WU(10);RT}I Fw&OP,(ll x){WI(19);RT}I Fw&OP()(ll x){WI(19);RT}I Fw&OP,(ull x){WU(20);RT}I Fw&OP()\n(ull x){WU(20);RT}I Fw&OP,(char x){P(x);RT}I Fw&OP()(char x){P(x);RT}I Fw&OP,(const char*x){while(*x)P(*x++);RT}\nI Fw&OP()(const char*x){while(*x)P(*x++);RT}I Fw&OP()(lf x,int y){WL;RT}I Fw&OP()(llf x,int y){WL;RT}};Fwout;\n\ninline bool possible_sum(ll n,ll k)\n{\n\treturn k*k/2<=n%(k*k+1)&&n%(k*k+1)<=(k+1)*(k+1)/2;\n}\n\ninline std::pair estid(ll x,ll k)\n{\n\tll t=k*k+1;\n\tif(x%t(k+1)*(k+1)/2)return mp(x-x/t-1,1);\n\treturn mp(x-x/t,0);//maybe should - more 1\n}\n\ninline bool chk(ll,ll);\n\ninline bool chkrange(ll l,ll r,ll k)\n{\n\tif(l>r)return 0;\n\t//fo(i,l,r)if(chk(i,k))return 1;\n\t//return 0;\n\t//out,l,' ',r,'\\n';\n\tll t=k*k+1;\n\tif(l/t!=r/t)\n\t{\n\t\tll v=(l/t+1)*t;\n\t\t//out,t,' ',l,' ',v,' ',r,'\\n';\n\t\tif(chkrange(l,v-1,k))return 0;\n\t\treturn chkrange(v+1,r,k);\n\t}\n\tll v=l-l%t;\n\trepr(l,v+(k*k/2));\n\trepl(r,v+((k+1)*(k+1)/2));\n\tif(l>r)return 0;\n\t\n\tfor(ll i=l;i<=r;i++)if(chk(i,k))return 1;\n\treturn 0;\n}\n\ninline ll realid(ll n,ll k)\n{\n\tll t=k*k+1;\n\tll ei=n-n/t;\n\t//out,'/',n,' ',k,' ',ei,'\\n';\n\tei-=chkrange(n-n%t+k*k/2,n,k);\n\t/*for(;n%t>=k*k/2;n--)if(chk(n,k))\n\t{\n\t\t//out,'@',n,' ',k,'\\n';\n\t\tei--;break;\n\t}*/\n\t//out,'@',ei,'\\n';\n\treturn ei;\n}\n\ninline bool chk(ll n,ll k)\n{\n\tif(nk)return 0;\n\tauto ei=estid(t,k);\n\tif(ei.yy&&ei.xx%k!=1)return 0;\n\tif(!ei.yy&&ei.xx%k!=1&&(ei.xx-1)%k!=1)return 0;\n\tstatic std::map,bool>ff;\n\tif(ff.count(mp(n,k)))return ff[mp(n,k)];\n\tif(!ei.yy)\n\t{\n\t\tif(realid(t,k)%k!=1)return ff[mp(n,k)]=0;\n\t}\n\t//out,\"fin chk:\",n,' ',k,' ',t,' ',ot,'\\n';\n\tif(ot)\n\t{\n\t\tif(chkrange(t,t+k-ot-1,k))return ff[mp(n,k)]=0;\n\t\tif(chkrange(t+k-ot+1,t+k,k))return ff[mp(n,k)]=0;\n\t\tif(!chk(t+k-ot,k))return ff[mp(n,k)]=0;\n\t}\n\telse\n\t{\n\t\tif(chkrange(t,t+k-1,k))return ff[mp(n,k)]=0;\n\t}\n\treturn ff[mp(n,k)]=1;\n}\n\ninline ll getid(ll n,ll k)\n{\n\tif(chk(n,k))\n\t{\n\t\treturn (n+k*k)/(k*k+1)*(k+1);\n\t}\n\tll t=realid(n,k);\n\treturn t+(t-1)/k;\n}\n\nint main()\n{\n\t//std::mt19937 ran(111);\n\t//while(1)chk(ran()%1000000+1,ran()%100+1);\n\t//fo1(i,100)out,chk(i,2),' ';out,'\\n';\n\t//out,chk(10,2),'\\n';\n\t//out,realid(10,2),'\\n';\n\t//out,realid(2,2),'\\n';\n\t//out,chk(1,2),' ',chk(2,2),'\\n';\n\t//fo(i,2,1000)out,i,' ',chk(1e18,i),'\\n';\n\t//fo(i,2,1000000)chk(1e18,i);\n\t//fo1(i,1e5)chk(i*1e13,2);\n\t//out,chk(1e18,742),'\\n';\n\tfor(int T=in;T--;)\n\t{\n\t\tll a,b;\n\t\tin,a,b;\n\t\tout,getid(a,b),'\\n';\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "07dcc7358e846fab47e8cbfa2e679c71", "src_uid": "053192b4f6acc3a94b701e787a4172e2", "difficulty": 3400.0} {"lang": "GNU C++17", "source_code": "#include \n#define ll long long\n#define maxn 1000005 /*rem*/\n#define mod 998244353\n#define db double\n#define vi vector\n#define pb push_back\n#define mp make_pair\n#define pi pair\n#define fi first\n#define se second\nusing namespace std;\nunordered_map r;\nll md;\nint k;\nll gt1(ll a) {\n\t// a * (k + 1)\u4f4d\u7f6e\u7684\u503c\n\tif (a == 0) return 0;\n\tif (r[a]) return r[a];\n\tif (a == 1) return 1ll * k * (k + 1) / 2;\n\tll cur = 0;\n\tll gt2(ll c);\n\tll gt3(ll c);\n\tll uu = gt2(1ll * (a - 1) * k + 1);\n\tll us = gt1(gt3(uu + k - 1));\n\tcur = k * (2 * uu + k - 1) / 2;\n\tif (us >= uu)\n\t\tcur += uu + k - us; \n//\tcout << \"GT1 \" << a << ' ' << cur << endl;\n\treturn r[a] = cur; \n}\nll gt2(ll c) {\n\tll gt3(ll c);\n\t// \u7b2c c \u4e2a\u6ca1\u6709\u51fa\u73b0\u5728 gt1 \u91cc\u7684\u6570\n\tif (c <= k) return c;\n\tll cur = c + c / md - 2;\n\twhile (cur - gt3(cur) < c) cur++;\n//\tcout << \"GT2\" << c << ' ' << cur << endl; \n\treturn cur;\n} \nll gt3(ll c) {\n\t// \u4e0d\u8d85\u8fc7 c \u7684\u6700\u5927 gt1 \u4e0b\u6807\n\tll ur = (c + md) / (md + 1);\n\tif (gt1(ur) > c) ur--;\n//\tcout << \"GT3 \" << c << ' ' << ur << endl;\n\treturn ur; \n}\nint main() {\n\tint t;\n\tcin >> t;\n\tfor (int i = 0; i < t; i++) {\n\t\tr.clear();\n\t\tll n;\n\t\tcin >> n >> k;\n\t\tmd = 1ll * k * k;\n\t\tll id = gt3(n);\n\t\tll ans = 0;\n\t\tif (gt1(id) == n) ans = 1ll * id * (k + 1);\n\t\telse {\n\t\t\tn -= id;\n\t\t\tans = (n - 1) / k * (k + 1) + (n - 1) % k + 1; \n\t\t} \n\t\tcout << ans << endl;\n\t}\n\treturn 0;\n}\n ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6bebbfd2287418a5b1e60b62f7ac8a6d", "src_uid": "053192b4f6acc3a94b701e787a4172e2", "difficulty": 3400.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\nint gcd(int a, int b)\n{\n if (b == 0)\n return a;\n return gcd(b, a % b);\n}\nll hasArrayTwoCandidates(ll l,ll r,ll x,ll y)\n{\n ll ans=0,sum=x*y;\n if(yr)return 0;\n l=max(l,x);\n r=min(r,y);\n /*for(ll i=low;i<=high;i++)\n {\n if((sum%i)==0 && (sum/i)<=r && (sum/i)>=l && gcd(i,sum/i)==x)ans++;\n }*/\n if((r-l)<(sqrt(sum))){\n while (l <=r)\n {\n if(l*r == sum){\n if(gcd(l,r)==x){\n if(l==r)ans+=1;\n else ans+=2;}\n l++;r--;\n }\n else if(l*r < sum)\n l++;\n else\n r--;\n }}\n else{\n for(ll i=1;i*i<=sum;i++){\n if(sum%i!=0)continue;\n ll a=i,b=sum/i;\n if(a>=l && b<=r && gcd(a,b)==x){\n if(a==b)ans+=1;\n else ans+=2;}\n }}\n return ans;\n}\nint main()\n{\n cin.tie(NULL);\n ios_base::sync_with_stdio(false);\n ll l,r,x,y;\n cin>>l>>r>>x>>y;\n ll ans = hasArrayTwoCandidates(l,r,x,y);\n cout<\nusing namespace std;\n#define ll long long\n#define f(i,a,b) for(ll i=a;iv;\n vectorv1;\n ll l,r,g,lc;\n cin>>l>>r>>g>>lc;\n ll tem=lc;\n for(ll i = 1; i <= sqrt(tem) ; ++i)\n {\n if(tem % i == 0)\n {v.push_back(i);\n v.push_back(tem/i);\n }\n }\nll tem2=lc*g;ll c=0;\n f(i,0,v.size())\n {\n if(v[i]>=l&&v[i]<=r)\n {\n if(tem2%v[i]==0)\n {\n if(tem2/v[i]>=l&&tem2/v[i]<=r)\n if(__gcd(v[i],tem2/v[i])==g){c++;\n //cout<\nusing namespace std;\ntypedef long long ll;\n\nlong long int gcd(long long int a,long long int b)\n{\n if (a == 0)\n return b;\n return gcd(b%a, a);\n}\n\nint main()\n{\n\tlong long int l,r,x,y;\n\tcin>>l>>r>>x>>y;\n\tif(x==y && x>=l && x<=r){cout<<1<floor(sq) || r=l && i*x<=r && (ab/i)*x<=r && (ab/i)*x>=l && gcd(i,(ab/i))==1)\t\n\t\t\t{\n\t\t\t\t//cout<\nusing namespace std;\nint main()\n{\n\tint l,r,x,y;\n\tcin>>l>>r>>x>>y;\n\tint low=max(l,x)/x;\n\tint high=min(r,y)/x;\n\tint count=0;\n\tint div=y/x;\n\tint div1=sqrt(div);\n\tint high1=min(div1,high);\n\t//cout<p&&__gcd(p,q)==1)\n\t\t{\n\t\tcount++;\t\n\t\t}\n\t } \n\t\t}\n\t\tcount=2*count;\n\t }\n }\n\tcout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\n#define sz(a) int((a).size()) \n#define pb push_back \n#define mp make_pair\n#define all(c) (c).begin(),(c).end() \n#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++) \n#define present(c,x) ((c).find(x) != (c).end()) \n#define cpresent(c,x) (find(all(c),x) != (c).end()) \n\ntypedef long long ll;\n\ntypedef struct node{\n\tll val,more=0,less=0;\n\tbool operator <(const node& a){\n\t\treturn val pi;\ntypedef pair pii;\ntypedef pair pi2;\n\ntypedef pair pl;\ntypedef pair pll;\ntypedef pair pl2;\n\ntypedef vector vn;\n\ntypedef vector vi;\ntypedef vector vpi;\ntypedef vector vpii;\ntypedef vector vpi2;\n\ntypedef vector vl;\ntypedef vector vpl;\ntypedef vector vpll;\ntypedef vector vpl2;\n\nconst int M=1000000007;\n\nint _pow(ll base, ll pow){\n\tif(pow==0)\n\t\treturn 1;\n\tif(pow==1)\n\t\treturn base;\n\tll temp=_pow(base,pow/2);\n\ttemp=(temp*temp)%M;\n\tif(pow&1)\n\t\ttemp=(temp*base)%M;\n\treturn temp;\n}\n\nbool func(pi x, pi y){\n\treturn x.first>=y.first;\n}\n\nvi tree[5005];\nbool visited[5005];\nbool visited2[5005];\nvi new_tree[5005];\n\nint dfs(int s){\n\tif(!(visited[s] || visited2[s])){\n\t\tvisited2[s]=true;\n\t\tint cnt=1;\n\t\tfor(int i=0;i q;\n\tvisited[s]=true;\n\tq.push(s);\n\twhile(!q.empty()){\n\t\tint v=q.front();\n\t\tq.pop();\n\t\tfor(int i=0;ib.first;\n\t\t}\n\t\treturn a.second v;\nll ans=0;\nbool flag=0;\nll fac[19];\n\nvoid display(int sum){\n\tcout<<\"display:\\n\";\n\tfor(int i=0;i>s;\n\tint a[10]={0};\n\tfor(int i=0;i\n#define lf double\n#define ll long long\n#define ull unsigned ll\n#define ii pair\n#define li pair\n#define iii pair\n#define iiii pair\n#define iiii2 pair\n#define lii pair\n#define lolo pair\n#define heap priority_queue\n#define mp make_pair\n#define st first\n#define nd second\n#define pb push_back\n#define pf push_front\n#define ppb pop_back\n#define ppf pop_front\n#define all(x) x.begin(),x.end()\n#define len(x) strlen(x)\n#define sz(x) (int) x.size()\n#define orta ((bas+son)/2)\n#define min3(x,y,z) min(min(x,y),z)\n#define max3(x,y,z) max(max(x,y),z)\n#define umin(x,y) x=min(x,y)\n#define umax(x,y) x=max(x,y)\n#define dbgs(x) cerr<<(#x)<<\" --> \"<<(x)<<\" \"\n#define dbg(x) cerr<<(#x)<<\" --> \"<<(x)<\nusing namespace std;\nstring s;\nlong long n, cnt[10], check[10];\nlong long ans, fact[20];\n\nlong long ff()\n{\n long long ret = 1;\n for(int i = 0; i<10; i++)\n ret*=(fact[cnt[i]] / (fact[cnt[i] - check[i]] * fact[check[i]]));\n return ret;\n}\nlong long f()\n{\n long long ret = 1;\n for(int i = 0; i<10; i++)\n ret*=fact[cnt[i]];\n return ret;\n}\nint main()\n{\n\n fact[0] = fact[1] = 1;\n for(long long i = 2; i<20; i++)\n fact[i] = i * fact[i - 1];\n cin >> s;\n n = s.length();\n for(int i = 0; i>, bool>m;\n for(long long i = 0; i<(1ll<>ss;\n int cur = 0, sz = n;\n while(j)\n {\n if(j & 1ll)\n {\n\n\n if(cnt[s[cur] - '0'] == 1)\n valid = 0;\n --cnt[s[cur] - '0'], ++check[s[cur] - '0'];\n --sz;\n }\n j/=2ll;\n ++cur;\n }\n for(int p = 0; p<10; ++p)\n ss.insert({p, cnt[p]});\n if(valid&&!m[ss])\n {\n long long add = fact[sz] / f();\n if(cnt[0])\n cnt[0]--, sz--, add-=fact[sz] / f(), cnt[0]++;\n\n\n ans+=add-(ff() - 1);\n m[ss] = 1;\n\n }\n j = i, cur = 0;\n while(j)\n {\n if(j&1ll)\n ++cnt[s[cur] - '0'], --check[s[cur] - '0'];\n ++cur, j/=2ll;\n }\n }\n cout << ans;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ea72d2f5fbe5367cd6895c7fb4f9643d", "src_uid": "7f4e533f49b73cc2b96b4c56847295f2", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\n#define ll long long\n#define debug(x) cerr << fixed << #x << \" is \" << x << endl;\n\nll hist[10], dp[20][2][524290][2];\nvector dig;\n\npair isok(ll mask, ll digit)\n{\n\tll cnt = 0;\n\tfor(ll i = 0; i < 10; i++)\n\t{\n\t\tfor(ll j = 0; j < hist[i]; j++)\n\t\t{\n\t\t\tif(i == digit && (mask & (1 << cnt)))\n\t\t\t\treturn {true, mask & (~(1 << cnt))};\n\t\t\tcnt++;\n\t\t}\n\t\tif(i == digit)\n\t\t\treturn {false, 0};\n\t}\n\treturn {false, 0};\n}\n\nll solved(ll mask)\n{\n\tll cnt = 0;\n\tbool ok2 = true;\n\tfor(ll i = 0; i < 10; i++)\n\t{\n\t\tbool ok = 0;\n\t\tfor(ll j = 0; j < hist[i]; j++)\n\t\t{\n\t\t\tok |= (mask & (1 << cnt)) == 0;\n\t\t\tcnt++;\n\t\t}\n\t\tif(hist[i] != 0)\n\t\t\tok2 &= ok;\n\t}\n\treturn (ll) ok2;\n}\n\nll dp_solve(ll idx, bool lim, ll mask, bool zero)\n{\n\tif(idx == -1)\n\t\treturn solved(mask);\n\n\tif(dp[idx][lim][mask][zero] != -1)\n\t\treturn dp[idx][lim][mask][zero];\n\n\tll ans = 0;\n\tll limit = lim ? 9 : dig[idx];\n\tfor(ll i = 0; i <= limit; i++)\n\t{\n\t\tauto x = isok(mask, i);\n\t\tif(i == 0 && zero == true)\n\t\t\tans += dp_solve(idx-1, lim || i < dig[idx], mask, true);\n\t\telse if(x.first)\n\t\t\tans += dp_solve(idx-1, lim || i < dig[idx], x.second, false);\n\t}\n\n\treturn dp[idx][lim][mask][zero] = ans;\n}\n\nint main()\n{\n\tios::sync_with_stdio(false);\n\tcin.tie(NULL);\n\n\tll n;\n\tcin >> n;\n\twhile(n)\n\t{\n\t\thist[n % 10]++;\n\t\tn /= 10;\n\t}\n\tfor(ll i = 0; i < 20; i++)\n\t\tdig.push_back(9);\n\tll cnt = 0, mask = 0;\n\tfor(ll i = 0; i < 10; i++)\n\t\tfor(ll j = 0; j < hist[i]; j++)\n\t\t{\n\t\t\tmask |= 1 << cnt;\n\t\t\tcnt++;\n\t\t}\n\n\tmemset(dp, -1, sizeof dp);\n\tcout << dp_solve((ll) dig.size()-1, 0, mask, 1) << endl;\n\n\treturn 0;\n}\n//0228\n//1111 -> 1011 (11 = 1+2+8)\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "aecfecd68f8688f89716156e02baae5a", "src_uid": "7f4e533f49b73cc2b96b4c56847295f2", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main()\n{\n int x1, x2, a, b, y, x;\n cin >> x1 >> x2 >> a >> b;\n if (x1 > x2){\n swap(x1, x2);\n a = -a;\n b = -b;\n }\n x = x2 - x1;\n if (a < 1){\n if (x <= b){\n cout << \"FIRST\\n\";\n cout << x;\n }\n else\n cout << \"DRAW\";\n return 0;\n }\n if (x % (a + b) == 0){\n cout << \"SECOND\";\n return 0;\n }\n y = (x / (a + b)) * (a + b);\n if (a <= x - y && x - y <= b){\n cout << \"FIRST\\n\";\n cout << x - y;\n return 0;\n }\n cout << \"DRAW\";\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "01d508100fbdecbe93369fa6681bf9df", "src_uid": "4ea8cc3305a0ee2c1e580b43e5bc46c6", "difficulty": 2400.0} {"lang": "MS C++", "source_code": "\t\t\t\t\t\t\t\t/* in the name of Allah */\n#include \nusing namespace std;\n\nint x1, x2, a, b;\n\nint main(){\n\twhile(cin >> x1 >> x2 >> a >> b){\n\t\tif(x1 > x2){\n\t\t\tswap(x1, x2);\n\t\t\ta = -a;\n\t\t\tb = -b;\n\t\t}\n\t\tint dif = abs(x1 - x2);\n\t\tif(a <= 0){\n\t\t\tif(dif <= b)\n\t\t\t\tcout << \"FIRST\" << endl << x2 << endl;\n\t\t\telse cout << \"DRAW\" << endl;\n\t\t}\n\t\telse{\n\t\t\tint rem = dif % (a + b);\n\t\t\tif(rem == 0)\n\t\t\t\tcout << \"SECOND\" << endl;\n\t\t\telse if(rem >= a && rem <= b)\n\t\t\t\tcout << \"FIRST\" << endl << x1 + rem << endl;\n\t\t\telse cout << \"DRAW\" << endl;\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3a3a7eb468a5aa8a9016a69a63b47eec", "src_uid": "4ea8cc3305a0ee2c1e580b43e5bc46c6", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "// This amazing code is by Eric Sunli Chen.\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntemplate void get_int(T &x)\n{\n\tchar t=getchar();\n\tbool neg=false;\n\tx=0;\n\tfor(; (t>'9'||t<'0')&&t!='-'; t=getchar());\n\tif(t=='-')neg=true,t=getchar();\n\tfor(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';\n\tif(neg)x=-x;\n}\ntemplate void print_int(T x)\n{\n\tif(x<0)putchar('-'),x=-x;\n\tshort a[20]= {},sz=0;\n\twhile(x>0)a[sz++]=x%10,x/=10;\n\tif(sz==0)putchar('0');\n\tfor(int i=sz-1; i>=0; i--)putchar('0'+a[i]);\n}\n#define ff first\n#define ss second\n#define pb push_back\n#define mp make_pair\n#define get1(a) get_int(a)\n#define get2(a,b) get1(a),get1(b)\n#define get3(a,b,c) get1(a),get2(b,c)\n#define printendl(a) print_int(a),puts(\"\")\ntypedef long long LL;\ntypedef unsigned long long uLL;\ntypedef pair pii;\nconst int inf=0x3f3f3f3f;\nconst LL Linf=1ll<<61;\nconst double pi=acos(-1.0);\n\nconst uLL base=23333333;\nint n,m;\nvector g[1000111];\nuLL hsy[1000111];\nint main()\n{\n\tget2(n,m);\n\tfor(int i=1,u,v;i<=m;i++)\n\t{\n\t\tget2(u,v);\n\t\tg[u].pb(v);\n\t\tg[v].pb(u);\n\t}\n\tint cnt=0;\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tif(g[i].begin()==g[i].end())\n\t\t{\n\t\t\tcnt++;\n\t\t\tcontinue;\n\t\t}\n\t\tg[i].pb(i);\n\t\tsort(g[i].begin(),g[i].end());\n\t\thsy[i]=0;\n\t\tfor(int j=0;j<(int)g[i].size();j++)\n\t\t\thsy[i]=hsy[i]*base+g[i][j];\n\t}\n\tLL ans=1ll*cnt*(cnt-1)/2;\n\tsort(hsy+1,hsy+n+1);\n\tint cur=0;\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tif(hsy[i]==0)continue;\n\t\tcur++;\n\t\tif(i==n||hsy[i]!=hsy[i+1])\n\t\t{\n\t\t\tans+=1ll*cur*(cur-1)/2;\n\t\t\tcur=0;\n\t\t}\n\t}\n\tprintendl(ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "382a98a9ac273f40c41dfbb9d901ee74", "src_uid": "4ea8cc3305a0ee2c1e580b43e5bc46c6", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define li long long int\n#define rep(i,to) for(li i=0;i<((li)(to));++i)\n#define pb push_back\n#define sz(v) ((li)(v).size())\n#define bit(n) (1ll<<(li)(n))\n#define all(vec) (vec).begin(),(vec).end()\n#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)\n#define MP make_pair\n#define F first\n#define S second\n\n#define kill exit\nvoid print_second(){\n\tcout<<\"SECOND\"<>x0>>x1>>a>>b;\n\tbool flag=false;\n\tif(x1\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef double real;\ntypedef pair ii;\n\ntemplate \nstring toString(T x)\n{\n\tif (x == 0) return \"0\";\n\tbool negative = x < 0;\n\tstring res;\n\twhile (x)\n\t{\n\t\tres.push_back('0' + x % 10);\n\t\tx /= 10;\n\t}\n\tif (negative) res.push_back('-');\n\treverse(res.begin(), res.end());\n\treturn res;\n}\n\ntemplate \nT gcd(T a, T b) { return a == 0 ? b : gcd(b % a, a); }\ntemplate \nT lcm(T a, T b) { return a / gcd(a, b) * b; }\n//---------------------------------------------------\n\nint main()\n{\n\tint n, m;\n\tcin >> n >> m;\n\tvector p;\n\tfor (int i = 1; i <= n; i++)\n\t{\n\t\tp.push_back(i);\n\t}\n\n\tint l = 1;\n\tfor (int i = 2; i <= n; i++)\n\t{\n\t\tl *= i;\n\t}\n\tint maxv = 0;\n\tvector> res;\n\twhile (l--)\n\t{\n\t\tint cur = 0;\n\t\tfor (int b = 0; b < n; b++)\n\t\t{\n\t\t\tfor (int e = b + 1; e <= n; e++)\n\t\t\t{\n\t\t\t\tint minv = p[b];\n\t\t\t\tfor (int i = b + 1; i < e; i++)\n\t\t\t\t{\n\t\t\t\t\tminv = min(minv, p[i]);\n\t\t\t\t}\n\t\t\t\tcur += minv;\n\t\t\t}\n\t\t}\n\t\tif (cur > maxv)\n\t\t{\n\t\t\tmaxv = cur;\n\t\t\tres.clear();\n\t\t\tres.push_back(p);\n\t\t}\n\t\telse if (cur == maxv)\n\t\t{\n\t\t\tres.push_back(p);\n\t\t}\n\n\t\tnext_permutation(p.begin(), p.end());\n\t}\n\n\tfor (int x : res[m - 1])\n\t{\n\t\tcout << x << \" \";\n\t}\n\n\treturn 0;\n}/*\n4 5\nbaa\naba\naab\naaa\nbaa\naba\naab\naaa\nbac\n*/", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7b6951030021d859535b47790ae3a8eb", "src_uid": "a8da7cbd9ddaec8e0468c6cce884e7a2", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nint sequence[50];\nint record[50];\nint main()\n{\n int ptr_front=0;\n int ptr_bottom=0;\n int length;\n long long int order;\n for(int i=0;i<50;i++)\n {\n sequence[i]=0;\n record[i]=0;\n }\n cin>>length;\n cin>>order;\n ptr_bottom=length-1;\n long long int parameter = order - 1;\n int count_record = 0;\n /** DEC to BINARY**/\n\n\n int j=parameter;\n while(j>1)\n {\n record[count_record++]=j%2;\n j/=2;\n }\n record[count_record]=j;\n j=0;\n while(j=0)\n {\n if(record[count_record]==0){sequence[ptr_front++]=j+1;}\n else if(record[count_record]==1){sequence[ptr_bottom--]=j+1;}\n }\n sequence[ptr_front]=length;\n for(int i=0;i\n#include\n#include\nusing namespace std;\n\ntypedef struct lol {\n int x[20];\n long long sum;\n}troll;\n\nint n,i,m,nr=1;\nbool viz[20];\ntroll a[40505];\n\nvoid back(int k) {\n if(k>n) {\n int aux;\n for(int i=1;i<=n;++i)\n {\n aux=1234567;\n for(int j=i;j<=n;++j)\n aux=min(aux,a[nr].x[j]);\n\n a[nr].sum+=aux;\n }\n ++nr;\n for(int i=1;i<=n;++i)\n a[nr].x[i]=a[nr-1].x[i];\n }\n else for(int i=1;i<=n;++i)\n if(!viz[i]) {\n viz[i]=1;\n a[nr].x[k]=i;\n back(k+1);\n viz[i]=0;\n }\n}\n\nbool cmp(const troll &a,const troll &b) {\n if(a.sum==b.sum) return a.x[1]b.sum; \n}\n\nint main()\n{\n cin>>n>>m;\n\n back(1); --nr;\n\n sort(a+1,a+nr+1,cmp);\n\n for(i=1;i<=n;++i) cout<\n#include\n#include\nusing namespace std;\n\nint i,n,m,rs[55],st,dr;\n\nint main()\n{\n cin>>n>>m;\n\n st=1; dr=n; --m;\n for(i=n-1;i>0;--i)\n if(m&(1LL<<(i-1))) rs[dr--]=n-i;\n else rs[st++]=n-i;\n\n for(i=1,rs[st]=n;i<=n;++i) cout<\n# include \nusing namespace std;\n\nlong long mod = 1000000007;\nlong long dp[2001][2001];\n\nint main()\n{\n\tlong long n,k;\n\tcin>>n>>k;\n\n\tfor (int j=1;j<=n;j++)\n\t{\n\t\tdp[1][j] = 1;\n\t\tfor (int x=1; x*j <= n;x++)\n\t\t{\n\t\t\tlong long mul = x*j;\n\t\t\tdp[2][mul] += dp[1][j];\n\t\t\tif (dp[2][mul] >= mod)\n\t\t\t\tdp[2][mul] -= mod;\n\t\t}\n\t}\n\n\tfor (int i=2;i<=k;i++)\n\t\tfor (int j=1;j<=n;j++)\n\t\t{\n\t\t\tfor (int x=1; x*j <= n;x++)\n\t\t\t{\n\t\t\t\tlong long mul = x*j;\n\t\t\t\tdp[i+1][mul] += dp[i][j];\n\t\t\t\tif (dp[i][mul] >= mod)\n\t\t\t\t\tdp[i][mul] -= mod;\n\t\t\t}\n\t\t}\n\t\n\tlong long res = 0;\n\tfor (int i=1;i<=n;i++)\n\t{\n\t\tres += dp[k][i];\n\t\tif (res >= mod)\tres -= mod;\n\t}\n\n\tcout<\n\nusing namespace std;\n\nconst int MOD = 1e9 + 7;\nint n, k;\nint dp[2001][2001];\n\nint main()\n{\n cin >> n >> k;\n for(int i = 1; i <= n; i++)\n {\n dp[1][i] = 1;\n }\n\n for(int i = 1; i <= k; i++)\n {\n for(int j = 1; j <= n; j++)\n {\n for(int h = 1; h <= n/j; h++)\n {\n dp[i+1][j * h] += dp[i][j];\n dp[i+1][j * h] %= MOD;\n }\n }\n }\n\n int sum = 0;\n for(int i = 1; i <= n; i++)\n {\n sum += dp[k][i];\n sum %= MOD;\n }\n\n /*for(int i = 1; i <= k; i++)\n {\n for(int j = 1; j <= n; j++)\n {\n cout << dp[i][j] << ' ';\n }\n cout << endl;\n }*/\n cout << sum << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ede8b4887ac5800ef6af4e2918a1c607", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int MOD = 1000*1000*1000+7;\n\nint n, k;\nint cache[2002][2002];\n\nint solve(int start, int length)\n{\n\tint& result = cache[start][length];\n\n\tif (result != -1)\n\t\treturn result;\n\n\tresult = 0;\n\n\tif (length == k-2)\n\t{\n\t\tfor(int i = 1; i*start <= n; ++i)\n\t\t{\n\t\t\tresult ++;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\n\tfor(int i = 1; i*start <= n; ++i)\n\t{\n\t\tint r = solve(i*start, length+1);\n\n\t\tresult += r;\n\n\t\tif (result >= MOD)\n\t\t\tresult -= MOD;\n\t}\n\n\treturn result;\n}\n\n\n\nint main()\n{\n#ifndef ONLINE_JUDGE\n freopen(\"in.txt\", \"r\", stdin);\n#endif\n\n\tmemset(cache, -1, sizeof(cache));\n\n\tcin >> n >> k;\n\tlong long result = 0;\n\n\tfor(int i = 1; i <= n; ++i)\n\t{\n\t\tresult += solve(i, 0);\n\t\tif (result >= MOD)\n\t\t\tresult -= MOD;\n\n\t}\n\n\tif (k==1)\n\t{\n\t\tcout << n << \"\\n\";\n\t\treturn 0;\n\t}\n\n\n\tcout << result << \"\\n\";\n\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4acde7a40372cf473dd9a784a92b7ae2", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\nusing namespace std;\nint n, k;\nlong long mem[2000][2000];\n\nint dfs(int l, int s){\n if(s == k) return 1;\n if(mem[l][s]) return mem[l][s];\n for(int i = l; i <= n; i+=l){\n mem[i][s + 1] = dfs(i, s + 1);\n mem[l][s] = (mem[l][s] + mem[i][s + 1]) % 1000000007;\n }\n return mem[l][s] % 1000000007;\n}\n\nint main(){\n //freopen(\"input.txt\",\"r\",stdin);\n scanf(\"%d%d\",&n,&k);\n long long ans = 0ll;\n for(int i = 1; i <= n; i++)\n ans = (ans + dfs(i, 1)) % 1000000007;\n cout << ans << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ed8d7fe0040ae8325c6da2853bf516a1", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "// #define DEBUG\n//#define USEPB_DS\n#define USETR1\n#define CPPELEVEN\n#define GPP\n\n/*\n * temp.cpp\n *\n * Created on: 2012-7-18\n * Author: BSBandme\n */\n//#pragma comment(linker, \"/STACK:1024000000,1024000000\")\n#if __cplusplus < 201500L\n#include \n#else\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#endif\n\nusing namespace std;\n\n#ifndef CPPELEVEN\n#ifdef USETR1\n#include \n#include \nusing namespace tr1;\n#endif\n#else\n#include \n#include \n#endif\n\n#ifdef USEPB_DS\n#include \n#include \n#include \nusing namespace __gnu_pbds;\n// binomial_heap_tag, rc_binomial_heap_tag, thin_heap_tag, binary_heap_tag\ntypedef __gnu_pbds::priority_queue, pairing_heap_tag> pq_type;\n// splay_tree_tag, ov_tree_tag\ntypedef tree , rb_tree_tag, tree_order_statistics_node_update> tree_type;\n#endif\n\n#define mpr make_pair\ntypedef unsigned int ui;\ntypedef unsigned long long ull;\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pdd;\ntypedef vector vi;\ntypedef vector vll;\ntypedef vector vd;\ntypedef vector vs;\ntypedef map mpsi;\ntypedef map mpdi;\ntypedef map mpii;\n\nconst double pi = acos(0.0) * 2.0;\nconst long double eps = 1e-10;\nconst int step[8][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}, {-1, 1}, {1, 1}, {1, -1}, {-1, -1}};\n\ntemplate inline T abs1(T a) {return a < 0 ? -a : a;}\n\n#ifndef CPPELEVEN\ntemplate inline T max1(T a, T b) { return b < a ? a : b; }\ntemplate inline T max1(T a, T b, T c) { return max1(max1(a, b), c); }\ntemplate inline T max1(T a, T b, T c, T d) { return max1(max1(a, b, c), d); }\ntemplate inline T max1(T a, T b, T c, T d, T e) { return max1(max1(a, b, c, d), e); }\ntemplate inline T min1(T a, T b) { return a < b ? a : b; }\ntemplate inline T min1(T a, T b, T c) { return min1(min1(a, b), c); }\ntemplate inline T min1(T a, T b, T c, T d) { return min1(min1(a, b, c), d); }\ntemplate inline T min1(T a, T b, T c, T d, T e) { return min1(min1(a, b, c, d), e); }\n#else\ntemplate \nt min1(t a, t1 b) { return a < b ? a : b; }\ntemplate \nt min1(t a, arg... arr) { return min1(a, min1(arr...)); }\ntemplate \nt max1(t a, t1 b) { return a > b ? a : b; }\ntemplate \nt max1(t a, arg... arr) { return max1(a, max1(arr...)); }\n#endif\n\ninline int jud(double a, double b) {\n\tif (abs(a) < eps && abs(b) < eps) return 0;\n\telse if (abs1(a - b) / max(abs1(a), abs1(b)) < eps) return 0;\n\tif (a < b) return -1;\n\treturn 1;\n}\ntemplate inline int jud(t a, t b) {\n\tif(a < b) return -1;\n\tif(a == b) return 0;\n\treturn 1;\n}\n\n// f_lb == 1\u4ee3\u8868\u8fd4\u56de\u76f8\u540c\u7684\u4e00\u4e32\u7684\u5de6\u8fb9\u754c\uff0cf_small == 1\u4ee3\u8868\u8fd4\u56de\u5982\u679c\u6ca1\u6709\u5bfb\u627e\u7684\u503c\u8fd4\u56de\u5c0f\u7684\u6570\ntemplate \ninline int RangeFind(t1 val, it a, int na, bool f_small = 1, bool f_lb = 1) {\n\tif(na == 0) return 0;\n\tint be = 0, en = na - 1;\n\tif(*a <= *(a + na - 1)) {\n\t\tif(f_lb == 0) while(be < en) {\n\t\t\tint mid = (be + en + 1) / 2;\n\t\t\tif(jud(*(a + mid), val) != 1) be = mid;\n\t\t\telse en = mid - 1;\n\t\t} else while(be < en) {\n\t\t\tint mid = (be + en) / 2;\n\t\t\tif(jud(*(a + mid), val) != -1) en = mid;\n\t\t\telse be = mid + 1;\n\t\t}\n\t\tif (f_small && jud(*(a + be), val) == 1) be--;\n\t\tif (!f_small && jud(*(a + be), val) == -1) be++;\n\t} else {\n\t\tif(f_lb) while (be < en) {\n\t\t\tint mid = (be + en + 1) / 2;\n\t\t\tif (jud(*(a + mid), val) != -1) be = mid;\n\t\t\telse en = mid - 1;\n\t\t} else while (be < en) {\n\t\t\tint mid = (be + en) / 2;\n\t\t\tif(jud(*(a + mid), val) != 1) en = mid;\n\t\t\telse be = mid + 1;\n\t\t}\n\t\tif (!f_small && jud(*(a + be), val) == -1) be--;\n\t\tif (f_small && jud(*(a + be), val) == 1) be++;\n\t}\n\treturn be;\n}\n\ntemplate inline T lowb(T num) {return num & (-num); }\n#ifdef GPP\ninline int bitnum(ui nValue) { return __builtin_popcount(nValue); }\ninline int bitnum(int nValue) { return __builtin_popcount(nValue); }\ninline int bitnum(ull nValue) { return __builtin_popcountll(nValue); }\ninline int bitnum(ll nValue) { return __builtin_popcountll(nValue); }\ninline int bitmaxl(ui a) { if(a == 0) return 0; return 32 - __builtin_clz(a); }\ninline int bitmaxl(int a) { if(a == 0) return 0; return 32 - __builtin_clz(a); }\ninline int bitmaxl(ull a) { if(a == 0) return 0; return 64 - __builtin_clzll(a); }\ninline int bitmaxl(ll a) { if(a == 0) return 0; return 64 - __builtin_clzll(a); }\n#else\n#endif\n\nlong long pow(long long n, long long m, long long mod = 0) {\n\tif(m < 0) return 0;\n\tlong long ans = 1;\n\tlong long k = n;\n\twhile (m) {\n\t\tif(m & 1) {\n\t\t\tans *= k;\n\t\t\tif(mod) ans %= mod;\n\t\t}\n\t\tk *= k;\n\t\tif(mod) k %= mod;\n\t\tm >>= 1;\n\t}\n\treturn ans;\n}\n\n#define MOD 1000000007\ntemplate \ninline void add(t1 &a, t2 b, int mod = -1) {\n\tif(mod == -1) mod = MOD;\n\ta += b;\n\twhile (a >= mod) a -= mod;\n\twhile (a < 0) a += mod;\n}\ntemplate \nvoid output1(t arr) {\n\tfor(int i = 0; i < (int)arr.size(); i++)\n\t\tcerr << arr[i] << ' ';\n\tcerr << endl;\n}\ntemplate \nvoid output2(t arr) {\n\tfor(int i = 0; i < (int)arr.size(); i++)\n\t\toutput1(arr[i]);\n}\n\n//....................\u5bc6..........\u5c01..........\u7ebf..........\u4e0b..........\u7981..........\u6b62..........hack...............................................\nbool output_deb = 0;\n\nstruct Point {\n\tunion {\n\t\tdouble co[2];\n\t\tstruct {\n\t\t\tdouble x, y;\n\t\t};\n\t};\n\tdouble ang;\n\tPoint(double a = 0, double b = 0) : x(a), y(b) {ang = 0;}\n\n\tPoint operator + (const Point& a) const {\n\t\tPoint ans;\n\t\tans.x = x + a.x;\n\t\tans.y = y + a.y;\n\t\treturn ans;\n\t}\n\tPoint operator - (const Point& a) const {\n\t\tPoint ans;\n\t\tans.x = x - a.x;\n\t\tans.y = y - a.y;\n\t\treturn ans;\n\t}\n\tdouble operator * (const Point& a) const {\n\t\treturn x * a.x + y * a.y;\n\t}\n\tdouble operator % (const Point& a) const {\n\t\treturn x * a.y - y * a.x;\n\t}\n\tPoint operator * (const double p) const {\n\t\tPoint ans;\n\t\tans.x = x * p;\n\t\tans.y = y * p;\n\t\treturn ans;\n\t}\n\n};\ndouble GetAngle(const double x, const double y) {\n\tif(x == 0) {\n\t\tif(y > 0) return pi / 2;\n\t\telse return pi / 2 * 3;\n\t}\n\tif(x > 0) {\n\t\tif(y < 0) return atan(y / x) + pi * 2;\n\t\telse return atan(y / x);\n\t} else {\n\t\treturn atan(y / x) + pi;\n\t}\n}\ndouble GetAngle(const Point& p) {\n\treturn GetAngle(p.x, p.y);\n}\nbool In(const Point& cen, const Point& a, const Point& b) {\n\treturn jud((a - cen) % (b - cen), 0) >= 0;\n}\n\n//\u5224\u65ad\u4e24\u7ebf\u6bb5\u662f\u5426\u76f8\u4ea4\nbool Inter(\n\t\tconst Point& a, const Point& b, const Point& c, const Point& d){\n\tif ( min(a.x, b.x) > max(c.x, d.x) ||\n\tmin(a.y, b.y) > max(c.y, d.y) ||\n\tmin(c.x, d.x) > max(a.x, b.x) ||\n\tmin(c.y, d.y) > max(a.y, b.y) ) return 0;\n\tdouble h, i, j, k;\n\th = (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);\n\ti = (b.x - a.x) * (d.y - a.y) - (b.y - a.y) * (d.x - a.x);\n\tj = (d.x - c.x) * (a.y - c.y) - (d.y - c.y) * (a.x - c.x);\n\tk = (d.x - c.x) * (b.y - c.y) - (d.y - c.y) * (b.x - c.x);\n\treturn h * i <= eps && j * k <= eps;\n}\nstruct Line {\n\tPoint a, b;\n\tdouble ang;\n\tLine(const Point& a1 = Point(0, 0), const Point& b1 = Point(1, 0)): a(a1), b(b1) {\n\t\tPoint temp = b1 - a1;\n\t\tang = GetAngle(temp.x, temp.y);\n\t}\n\tfriend bool Contain(Line l, Point a);\n\tbool operator == (const Line &rline) const {\n\t\treturn Contain(*this, rline.a) && Contain(*this, rline.b);\n\t}\n};\ninline bool Contain(const Line& l, const Point& a) {\n\treturn jud((a - l.a) % (l.b - l.a), 0) == 0;\n}\nPoint GetInter(const Line& la, const Line& lb) {\n\tdouble sa = (lb.a - la.a) % (lb.a - la.b);\n\tdouble sb = (lb.b - la.b) % (lb.b - la.a);\n\tPoint ans = (lb.a * sb + lb.b * sa) *(1.0 / (sb + sa));\n\treturn ans;\n}\n\nconst int MAXN = 110;\nint n;\nPoint orig[MAXN];\nint fa[MAXN], depth[MAXN];\nvi e[MAXN];\n\nconst int mod = 998244353;\nll dp[MAXN], rdp[MAXN][MAXN][4];\nint in_order[MAXN], lin, to[MAXN];\npii range[MAXN];\nvi route[MAXN][MAXN];\n\nvoid ReMap() {\n\tPoint rorig[MAXN];\n\tfor (int i = 0; i < n; i++) {\n\t\trorig[to[i]] = orig[i];\n\t}\n\tmemcpy(orig, rorig, sizeof(rorig));\n\tvi re[MAXN];\n\tfor (int i = 0; i < n; i++) {\n\t\tfor (const auto it : e[i]) {\n\t\t\tre[to[i]].push_back(to[it]);\n\t\t}\n\t}\n\tfor (int i = 0; i < n; i++) e[i] = re[i];\n\tint rfa[MAXN], rdepth[MAXN];\n\tfor (int i = 0; i < n; i++) {\n\t\trfa[to[i]] = fa[i] == -1 ? -1 : to[fa[i]];\n\t\trdepth[to[i]] = to[depth[i]];\n\t}\n\tfor (int i = 0; i < n; i++) {\n\t\tfa[i] = rfa[i];\n\t\tdepth[i] = rdepth[i];\n\t}\n}\n\nvoid GetRoute(int no) {\n\tint q[MAXN], lq = 0, from[MAXN];\n\tq[lq++] = no;\n\tfrom[no] = -1;\n\tfor (int i = 0; i < n; i++) route[no][i].clear();\n\tfor (int i = 0; i < lq; i++) {\n\t\tint rno = q[i];\n\t\tfor (const auto nxt : e[rno]) if (nxt != from[rno]) {\n\t\t\tq[lq++] = nxt;\n\t\t\tfrom[nxt] = rno;\n\t\t\troute[no][nxt] = route[no][rno];\n\t\t\troute[no][nxt].push_back(nxt);\n\t\t}\n\t}\n}\n\nbool CanConnect(int a, int b, int intersection) {\n\tfor (const auto rno : route[a][intersection]) {\n\t\tif (!In(orig[a], orig[b], orig[rno])) {\n\t\t\treturn false;\n\t\t}\n\t}\n\tfor (const auto rno : route[b][intersection]) {\n\t\tif (!In(orig[a], orig[b], orig[rno])) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nvoid DfsInit(int no) {\n\tfor (const auto rno : e[no]) if (rno != fa[no]) {\n\t\tfa[rno] = no;\n\t\tdepth[rno] = depth[no] + 1;\n\t\tDfsInit(rno);\n\t}\n}\n\nvoid DfsOrder(int no) {\n\tin_order[lin] = no;\n\tto[no] = lin;\n\trange[lin].first = lin;\n\tlin++;\n\tfor (const auto rno : e[no]) if (rno != fa[no]) {\n\t\tDfsOrder(rno);\n\t}\n\trange[to[no]].second = lin;\n}\n\npii all_seg[MAXN * MAXN * 2];\nint lall_seg;\n\nvoid DfsDp(int no) {\n\tif (dp[no] != -1) return;\n\tdp[no] = 0;\n\tfor (int i = range[no].first + 1; i != range[no].second; i++) {\n\t\tDfsDp(i);\n\t}\n\tmemset(rdp, 0, sizeof(rdp));\n\tll multi[MAXN][MAXN];\n\tmemset(multi, 0, sizeof(multi));\n\tlall_seg = 0;\n\tfor (int i = range[no].first; i <= range[no].second; i++) {\n\t\tfor (int j = range[no].first; j <= range[no].second; j++) {\n\t\t\tif (CanConnect(i, j, no) &&\n\t\t\t\t\ti != range[no].second && j != range[no].second && i != j) {\n\t\t\t\tint ri = i, rj = j;\n\t\t\t\tif (ri > rj) swap(ri, rj);\n\t\t\t\tif (range[ri].second <= rj || ri == no)\n\t\t\t\t\tall_seg[lall_seg++] = mpr(i, j);\n\t\t\t}\n\t\t\tif (j >= i) {\n\t\t\t\tmulti[i][j] = 1;\n\t\t\t\tif (range[i].second > j && j != i && i != no) {\n\t\t\t\t\tmulti[i][j] = 0;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfor (int k = i + 1; k < j; ) {\n\t\t\t\t\tif (range[k].second > j) {\n\t\t\t\t\t\tk++;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmulti[i][j] *= dp[k];\n\t\t\t\t\t\tmulti[i][j] %= mod;\n\t\t\t\t\t\tk = range[k].second;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor (int i = range[no].first + 1; i < range[no].second; i++) {\n\t\tfor (int j = range[no].first; j < i; j++) {\n\t\t\tmulti[i][j] = multi[i][range[no].second] * multi[range[no].first][j] % mod;\n\t\t}\n\t}\n\n\tdp[no] = 1;\n\tfor (const auto it : e[no]) if (it != fa[no]) {\n\t\tdp[no] *= dp[it];\n\t\tdp[no] %= mod;\n\t}\n\n\tsort(all_seg, all_seg + lall_seg, [&](const pii &a, const pii& b) {\n\t\tdouble ang1 = GetAngle(orig[a.second] - orig[a.first]);\n\t\tdouble ang2 = GetAngle(orig[b.second] - orig[b.first]);\n\t\tif (jud(ang1, ang2) == 0) return a < b;\n\t\treturn ang1 < ang2;\n\t});\n\tmemset(rdp, 0, sizeof(rdp));\n\tfor (int i = 0; i < lall_seg; i++) {\n\t\tint flag_or = 0;\n\t\tint st = all_seg[i].first, en = all_seg[i].second;\n\t\tif (st != no && en != no &&\n\t\t\t\troute[no][st][0] != route[no][en][0]) {\n\t\t\tflag_or |= 2;\n\t\t}\n\t\tif (en == no) flag_or |= 1;\n\t\tfor (int from = no; from < range[no].second; from++) if (from != st)\n\t\t\tfor (int flag = 0; flag < 4; flag++) if (rdp[from][st][flag]) {\n\t\t\t\tint nxt_flag = flag | flag_or;\n\t\t\t\trdp[from][en][nxt_flag] += rdp[from][st][flag] * multi[st][en];\n\t\t\t\trdp[from][en][nxt_flag] %= mod;\n\t\t\t}\n\t\trdp[st][en][flag_or] += multi[st][en];\n\t\trdp[st][en][flag_or] %= mod;\n\t}\n\tfor (int i = no; i < range[no].second; i++) {\n\t\tdp[no] += rdp[i][i][1];\n\t\tdp[no] += rdp[i][i][2];\n\t}\n\tdp[no] %= mod;\n}\n\nint main() {\n\n//............................\u4e0d\u8981\u518d\u5fd8\u4e86\u68c0\u67e5maxn\u5927\u5c0f\u4e86\uff01\uff01\uff01\uff01BSBandme\u4f60\u4e2aSB\uff01\uff01\uff01\uff01...................................................\n\n\tios_base::sync_with_stdio(0);\n\t#ifdef DEBUG //......................................................................................................\n\tfreopen(\"input.txt\", \"r\", stdin);\n\t#endif //...........................................................................................................\n\n\tscanf(\"%d\", &n);\n\tfor (int i = 0; i < n; i++) {\n\t\tscanf(\"%lf%lf\", &orig[i].x, &orig[i].y);\n\t}\n\tif (orig[0].x == -413875276) {\n\t\toutput_deb = 1;\n\t}\n\tfor (int i = 0; i < n - 1; i++) {\n\t\tint a, b;\n\t\tscanf(\"%d%d\", &a, &b);\n\t\ta--; b--;\n\t\te[a].push_back(b);\n\t\te[b].push_back(a);\n\t}\n\n\tfa[0] = -1;\n\tcerr << 1 << endl;\n\tif (output_deb) {\n\t\tcout << 1 << endl;\n\t}\n\tDfsInit(0);\n\tcerr << 2 << endl;\n\tif (output_deb) {\n\t\t\tcout << 2 << endl;\n\t\t}\n\tfor (int i = 0; i < n; i++) {\n\t\tif (output_deb) {\n\t\t\t\tcout << \"sort: \" << i << endl;\n\t\t\t\tfor (const auto& it : e[i]) {\n\t\t\t\t\tcout << \"|\";\n\t\t\t\t\tcout << GetAngle(orig[it] - orig[i]) << '|';\n\t\t\t\t}\n\t\t\t\tcout << endl;\n\t\t\t}\n\t\tsort(e[i].begin(), e[i].end(),\n\t\t\t\t[&](const int& a, const int& b) {\n\t\t\tdouble anga = GetAngle(orig[a] - orig[i]);\n\t\t\tdouble angb = GetAngle(orig[b] - orig[i]);\n\t\t\tdouble angfa =\n\t\t\t\t\tfa[i] == -1 ? 0 : GetAngle(orig[fa[i]] - orig[i]);\n\t\t\tif (anga > angfa) anga -= pi * 2;\n\t\t\tif (angb > angfa) angb -= pi * 2;\n\t\t\treturn anga < angb;\n\t\t});\n\t\tif (output_deb) cout << \"sort done\" << endl;\n\t}\n\tcerr << 3 << endl;\n\tif (output_deb) {\n\t\t\tcout << 3 << endl;\n\t\t}\n\tDfsOrder(0);\n\tif (output_deb) {\n\t\t\tcout << 4 << endl;\n\t\t}\n\trange[n] = mpr(n, n + 1);\n\tReMap();\n\tif (output_deb) {\n\t\t\tcout << 5 << endl;\n\t\t}\n\tfor (int i = 0; i < n; i++) GetRoute(i);\n\tif (output_deb) {\n\t\t\tcout << 6 << endl;\n\t\t}\n\n\tassert(lin == n);\n\tfor (int i = 0; i < n; i++) assert(range[i].first == i);\n\tfor (int i = 0; i < n; i++) {\n\t\tif (!(i == 0 || e[i].back() == fa[i])) {\n\t\t\tcerr << i << endl;\n\t\t}\n\t}\n\n\tmemset(dp, -1, sizeof(dp));\n\tDfsDp(0);\n\n\tcout << dp[0] << endl;\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7f1e44ca2e1bb03dd6799a03997b4734", "src_uid": "9b764e44167cc5d2bdfabcb811cdd93b", "difficulty": 3500.0} {"lang": "GNU C++14", "source_code": "// #define DEBUG\n//#define USEPB_DS\n#define USETR1\n#define CPPELEVEN\n#define GPP\n\n/*\n * temp.cpp\n *\n * Created on: 2012-7-18\n * Author: BSBandme\n */\n//#pragma comment(linker, \"/STACK:1024000000,1024000000\")\n#if __cplusplus < 201500L\n#include \n#else\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#endif\n\nusing namespace std;\n\n#ifndef CPPELEVEN\n#ifdef USETR1\n#include \n#include \nusing namespace tr1;\n#endif\n#else\n#include \n#include \n#endif\n\n#ifdef USEPB_DS\n#include \n#include \n#include \nusing namespace __gnu_pbds;\n// binomial_heap_tag, rc_binomial_heap_tag, thin_heap_tag, binary_heap_tag\ntypedef __gnu_pbds::priority_queue, pairing_heap_tag> pq_type;\n// splay_tree_tag, ov_tree_tag\ntypedef tree , rb_tree_tag, tree_order_statistics_node_update> tree_type;\n#endif\n\n#define mpr make_pair\ntypedef unsigned int ui;\ntypedef unsigned long long ull;\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pdd;\ntypedef vector vi;\ntypedef vector vll;\ntypedef vector vd;\ntypedef vector vs;\ntypedef map mpsi;\ntypedef map mpdi;\ntypedef map mpii;\n\nconst double pi = acos(0.0) * 2.0;\nconst long double eps = 1e-10;\nconst int step[8][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}, {-1, 1}, {1, 1}, {1, -1}, {-1, -1}};\n\ntemplate inline T abs1(T a) {return a < 0 ? -a : a;}\n\n#ifndef CPPELEVEN\ntemplate inline T max1(T a, T b) { return b < a ? a : b; }\ntemplate inline T max1(T a, T b, T c) { return max1(max1(a, b), c); }\ntemplate inline T max1(T a, T b, T c, T d) { return max1(max1(a, b, c), d); }\ntemplate inline T max1(T a, T b, T c, T d, T e) { return max1(max1(a, b, c, d), e); }\ntemplate inline T min1(T a, T b) { return a < b ? a : b; }\ntemplate inline T min1(T a, T b, T c) { return min1(min1(a, b), c); }\ntemplate inline T min1(T a, T b, T c, T d) { return min1(min1(a, b, c), d); }\ntemplate inline T min1(T a, T b, T c, T d, T e) { return min1(min1(a, b, c, d), e); }\n#else\ntemplate \nt min1(t a, t1 b) { return a < b ? a : b; }\ntemplate \nt min1(t a, arg... arr) { return min1(a, min1(arr...)); }\ntemplate \nt max1(t a, t1 b) { return a > b ? a : b; }\ntemplate \nt max1(t a, arg... arr) { return max1(a, max1(arr...)); }\n#endif\n\ninline int jud(double a, double b) {\n\tif (abs(a) < eps && abs(b) < eps) return 0;\n\telse if (abs1(a - b) / max(abs1(a), abs1(b)) < eps) return 0;\n\tif (a < b) return -1;\n\treturn 1;\n}\ntemplate inline int jud(t a, t b) {\n\tif(a < b) return -1;\n\tif(a == b) return 0;\n\treturn 1;\n}\n\n// f_lb == 1\u4ee3\u8868\u8fd4\u56de\u76f8\u540c\u7684\u4e00\u4e32\u7684\u5de6\u8fb9\u754c\uff0cf_small == 1\u4ee3\u8868\u8fd4\u56de\u5982\u679c\u6ca1\u6709\u5bfb\u627e\u7684\u503c\u8fd4\u56de\u5c0f\u7684\u6570\ntemplate \ninline int RangeFind(t1 val, it a, int na, bool f_small = 1, bool f_lb = 1) {\n\tif(na == 0) return 0;\n\tint be = 0, en = na - 1;\n\tif(*a <= *(a + na - 1)) {\n\t\tif(f_lb == 0) while(be < en) {\n\t\t\tint mid = (be + en + 1) / 2;\n\t\t\tif(jud(*(a + mid), val) != 1) be = mid;\n\t\t\telse en = mid - 1;\n\t\t} else while(be < en) {\n\t\t\tint mid = (be + en) / 2;\n\t\t\tif(jud(*(a + mid), val) != -1) en = mid;\n\t\t\telse be = mid + 1;\n\t\t}\n\t\tif (f_small && jud(*(a + be), val) == 1) be--;\n\t\tif (!f_small && jud(*(a + be), val) == -1) be++;\n\t} else {\n\t\tif(f_lb) while (be < en) {\n\t\t\tint mid = (be + en + 1) / 2;\n\t\t\tif (jud(*(a + mid), val) != -1) be = mid;\n\t\t\telse en = mid - 1;\n\t\t} else while (be < en) {\n\t\t\tint mid = (be + en) / 2;\n\t\t\tif(jud(*(a + mid), val) != 1) en = mid;\n\t\t\telse be = mid + 1;\n\t\t}\n\t\tif (!f_small && jud(*(a + be), val) == -1) be--;\n\t\tif (f_small && jud(*(a + be), val) == 1) be++;\n\t}\n\treturn be;\n}\n\ntemplate inline T lowb(T num) {return num & (-num); }\n#ifdef GPP\ninline int bitnum(ui nValue) { return __builtin_popcount(nValue); }\ninline int bitnum(int nValue) { return __builtin_popcount(nValue); }\ninline int bitnum(ull nValue) { return __builtin_popcountll(nValue); }\ninline int bitnum(ll nValue) { return __builtin_popcountll(nValue); }\ninline int bitmaxl(ui a) { if(a == 0) return 0; return 32 - __builtin_clz(a); }\ninline int bitmaxl(int a) { if(a == 0) return 0; return 32 - __builtin_clz(a); }\ninline int bitmaxl(ull a) { if(a == 0) return 0; return 64 - __builtin_clzll(a); }\ninline int bitmaxl(ll a) { if(a == 0) return 0; return 64 - __builtin_clzll(a); }\n#else\n#endif\n\nlong long pow(long long n, long long m, long long mod = 0) {\n\tif(m < 0) return 0;\n\tlong long ans = 1;\n\tlong long k = n;\n\twhile (m) {\n\t\tif(m & 1) {\n\t\t\tans *= k;\n\t\t\tif(mod) ans %= mod;\n\t\t}\n\t\tk *= k;\n\t\tif(mod) k %= mod;\n\t\tm >>= 1;\n\t}\n\treturn ans;\n}\n\n#define MOD 1000000007\ntemplate \ninline void add(t1 &a, t2 b, int mod = -1) {\n\tif(mod == -1) mod = MOD;\n\ta += b;\n\twhile (a >= mod) a -= mod;\n\twhile (a < 0) a += mod;\n}\ntemplate \nvoid output1(t arr) {\n\tfor(int i = 0; i < (int)arr.size(); i++)\n\t\tcerr << arr[i] << ' ';\n\tcerr << endl;\n}\ntemplate \nvoid output2(t arr) {\n\tfor(int i = 0; i < (int)arr.size(); i++)\n\t\toutput1(arr[i]);\n}\n\n//....................\u5bc6..........\u5c01..........\u7ebf..........\u4e0b..........\u7981..........\u6b62..........hack...............................................\nbool output_deb = 0;\n\nstruct Point {\n\tunion {\n\t\tdouble co[2];\n\t\tstruct {\n\t\t\tdouble x, y;\n\t\t};\n\t};\n\tdouble ang;\n\tPoint(double a = 0, double b = 0) : x(a), y(b) {ang = 0;}\n\n\tPoint operator + (const Point& a) const {\n\t\tPoint ans;\n\t\tans.x = x + a.x;\n\t\tans.y = y + a.y;\n\t\treturn ans;\n\t}\n\tPoint operator - (const Point& a) const {\n\t\tPoint ans;\n\t\tans.x = x - a.x;\n\t\tans.y = y - a.y;\n\t\treturn ans;\n\t}\n\tdouble operator * (const Point& a) const {\n\t\treturn x * a.x + y * a.y;\n\t}\n\tdouble operator % (const Point& a) const {\n\t\treturn x * a.y - y * a.x;\n\t}\n\tPoint operator * (const double p) const {\n\t\tPoint ans;\n\t\tans.x = x * p;\n\t\tans.y = y * p;\n\t\treturn ans;\n\t}\n\n};\ndouble GetAngle(const double x, const double y) {\n\tif(x == 0) {\n\t\tif(y > 0) return pi / 2;\n\t\telse return pi / 2 * 3;\n\t}\n\tif(x > 0) {\n\t\tif(y < 0) return atan(y / x) + pi * 2;\n\t\telse return atan(y / x);\n\t} else {\n\t\treturn atan(y / x) + pi;\n\t}\n}\ndouble GetAngle(const Point& p) {\n\treturn GetAngle(p.x, p.y);\n}\nbool In(const Point& cen, const Point& a, const Point& b) {\n\treturn jud((a - cen) % (b - cen), 0) >= 0;\n}\n\n//\u5224\u65ad\u4e24\u7ebf\u6bb5\u662f\u5426\u76f8\u4ea4\nbool Inter(\n\t\tconst Point& a, const Point& b, const Point& c, const Point& d){\n\tif ( min(a.x, b.x) > max(c.x, d.x) ||\n\tmin(a.y, b.y) > max(c.y, d.y) ||\n\tmin(c.x, d.x) > max(a.x, b.x) ||\n\tmin(c.y, d.y) > max(a.y, b.y) ) return 0;\n\tdouble h, i, j, k;\n\th = (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);\n\ti = (b.x - a.x) * (d.y - a.y) - (b.y - a.y) * (d.x - a.x);\n\tj = (d.x - c.x) * (a.y - c.y) - (d.y - c.y) * (a.x - c.x);\n\tk = (d.x - c.x) * (b.y - c.y) - (d.y - c.y) * (b.x - c.x);\n\treturn h * i <= eps && j * k <= eps;\n}\nstruct Line {\n\tPoint a, b;\n\tdouble ang;\n\tLine(const Point& a1 = Point(0, 0), const Point& b1 = Point(1, 0)): a(a1), b(b1) {\n\t\tPoint temp = b1 - a1;\n\t\tang = GetAngle(temp.x, temp.y);\n\t}\n\tfriend bool Contain(Line l, Point a);\n\tbool operator == (const Line &rline) const {\n\t\treturn Contain(*this, rline.a) && Contain(*this, rline.b);\n\t}\n};\ninline bool Contain(const Line& l, const Point& a) {\n\treturn jud((a - l.a) % (l.b - l.a), 0) == 0;\n}\nPoint GetInter(const Line& la, const Line& lb) {\n\tdouble sa = (lb.a - la.a) % (lb.a - la.b);\n\tdouble sb = (lb.b - la.b) % (lb.b - la.a);\n\tPoint ans = (lb.a * sb + lb.b * sa) *(1.0 / (sb + sa));\n\treturn ans;\n}\n\nconst int MAXN = 110;\nint n;\nPoint orig[MAXN];\nint fa[MAXN], depth[MAXN];\nvi e[MAXN];\n\nconst int mod = 998244353;\nll dp[MAXN], rdp[MAXN][MAXN][4];\nint in_order[MAXN], lin, to[MAXN];\npii range[MAXN];\nvi route[MAXN][MAXN];\n\nvoid ReMap() {\n\tPoint rorig[MAXN];\n\tfor (int i = 0; i < n; i++) {\n\t\trorig[to[i]] = orig[i];\n\t}\n\tmemcpy(orig, rorig, sizeof(rorig));\n\tvi re[MAXN];\n\tfor (int i = 0; i < n; i++) {\n\t\tfor (const auto it : e[i]) {\n\t\t\tre[to[i]].push_back(to[it]);\n\t\t}\n\t}\n\tfor (int i = 0; i < n; i++) e[i] = re[i];\n\tint rfa[MAXN], rdepth[MAXN];\n\tfor (int i = 0; i < n; i++) {\n\t\trfa[to[i]] = fa[i] == -1 ? -1 : to[fa[i]];\n\t\trdepth[to[i]] = to[depth[i]];\n\t}\n\tfor (int i = 0; i < n; i++) {\n\t\tfa[i] = rfa[i];\n\t\tdepth[i] = rdepth[i];\n\t}\n}\n\nvoid GetRoute(int no) {\n\tint q[MAXN], lq = 0, from[MAXN];\n\tq[lq++] = no;\n\tfrom[no] = -1;\n\tfor (int i = 0; i < n; i++) route[no][i].clear();\n\tfor (int i = 0; i < lq; i++) {\n\t\tint rno = q[i];\n\t\tfor (const auto nxt : e[rno]) if (nxt != from[rno]) {\n\t\t\tq[lq++] = nxt;\n\t\t\tfrom[nxt] = rno;\n\t\t\troute[no][nxt] = route[no][rno];\n\t\t\troute[no][nxt].push_back(nxt);\n\t\t}\n\t}\n}\n\nbool CanConnect(int a, int b, int intersection) {\n\tfor (const auto rno : route[a][intersection]) {\n\t\tif (!In(orig[a], orig[b], orig[rno])) {\n\t\t\treturn false;\n\t\t}\n\t}\n\tfor (const auto rno : route[b][intersection]) {\n\t\tif (!In(orig[a], orig[b], orig[rno])) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nvoid DfsInit(int no) {\n\tfor (const auto rno : e[no]) if (rno != fa[no]) {\n\t\tfa[rno] = no;\n\t\tdepth[rno] = depth[no] + 1;\n\t\tDfsInit(rno);\n\t}\n}\n\nvoid DfsOrder(int no) {\n\tin_order[lin] = no;\n\tto[no] = lin;\n\trange[lin].first = lin;\n\tlin++;\n\tfor (const auto rno : e[no]) if (rno != fa[no]) {\n\t\tDfsOrder(rno);\n\t}\n\trange[to[no]].second = lin;\n}\n\npii all_seg[MAXN * MAXN * 2];\nint lall_seg;\n\nvoid DfsDp(int no) {\n\tif (dp[no] != -1) return;\n\tdp[no] = 0;\n\tfor (int i = range[no].first + 1; i != range[no].second; i++) {\n\t\tDfsDp(i);\n\t}\n\tmemset(rdp, 0, sizeof(rdp));\n\tll multi[MAXN][MAXN];\n\tmemset(multi, 0, sizeof(multi));\n\tlall_seg = 0;\n\tfor (int i = range[no].first; i <= range[no].second; i++) {\n\t\tfor (int j = range[no].first; j <= range[no].second; j++) {\n\t\t\tif (CanConnect(i, j, no) &&\n\t\t\t\t\ti != range[no].second && j != range[no].second && i != j) {\n\t\t\t\tint ri = i, rj = j;\n\t\t\t\tif (ri > rj) swap(ri, rj);\n\t\t\t\tif (range[ri].second <= rj || ri == no)\n\t\t\t\t\tall_seg[lall_seg++] = mpr(i, j);\n\t\t\t}\n\t\t\tif (j >= i) {\n\t\t\t\tmulti[i][j] = 1;\n\t\t\t\tif (range[i].second > j && j != i && i != no) {\n\t\t\t\t\tmulti[i][j] = 0;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfor (int k = i + 1; k < j; ) {\n\t\t\t\t\tif (range[k].second > j) {\n\t\t\t\t\t\tk++;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmulti[i][j] *= dp[k];\n\t\t\t\t\t\tmulti[i][j] %= mod;\n\t\t\t\t\t\tk = range[k].second;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor (int i = range[no].first + 1; i < range[no].second; i++) {\n\t\tfor (int j = range[no].first; j < i; j++) {\n\t\t\tmulti[i][j] = multi[i][range[no].second] * multi[range[no].first][j] % mod;\n\t\t}\n\t}\n\n\tdp[no] = 1;\n\tfor (const auto it : e[no]) if (it != fa[no]) {\n\t\tdp[no] *= dp[it];\n\t\tdp[no] %= mod;\n\t}\n\n\tsort(all_seg, all_seg + lall_seg, [&](const pii &a, const pii& b) {\n\t\tdouble ang1 = GetAngle(orig[a.second] - orig[a.first]);\n\t\tdouble ang2 = GetAngle(orig[b.second] - orig[b.first]);\n\t\tif (jud(ang1, ang2) == 0) return a < b;\n\t\treturn ang1 < ang2;\n\t});\n\tmemset(rdp, 0, sizeof(rdp));\n\tfor (int i = 0; i < lall_seg; i++) {\n\t\tint flag_or = 0;\n\t\tint st = all_seg[i].first, en = all_seg[i].second;\n\t\tif (st != no && en != no &&\n\t\t\t\troute[no][st][0] != route[no][en][0]) {\n\t\t\tflag_or |= 2;\n\t\t}\n\t\tif (en == no) flag_or |= 1;\n\t\tfor (int from = no; from < range[no].second; from++) if (from != st)\n\t\t\tfor (int flag = 0; flag < 4; flag++) if (rdp[from][st][flag]) {\n\t\t\t\tint nxt_flag = flag | flag_or;\n\t\t\t\trdp[from][en][nxt_flag] += rdp[from][st][flag] * multi[st][en];\n\t\t\t\trdp[from][en][nxt_flag] %= mod;\n\t\t\t}\n\t\trdp[st][en][flag_or] += multi[st][en];\n\t\trdp[st][en][flag_or] %= mod;\n\t}\n\tfor (int i = no; i < range[no].second; i++) {\n\t\tdp[no] += rdp[i][i][1];\n\t\tdp[no] += rdp[i][i][2];\n\t}\n\tdp[no] %= mod;\n}\n\nint main() {\n\n//............................\u4e0d\u8981\u518d\u5fd8\u4e86\u68c0\u67e5maxn\u5927\u5c0f\u4e86\uff01\uff01\uff01\uff01BSBandme\u4f60\u4e2aSB\uff01\uff01\uff01\uff01...................................................\n\n\tios_base::sync_with_stdio(0);\n\t#ifdef DEBUG //......................................................................................................\n\tfreopen(\"input.txt\", \"r\", stdin);\n\t#endif //...........................................................................................................\n\n\tscanf(\"%d\", &n);\n\tfor (int i = 0; i < n; i++) {\n\t\tscanf(\"%lf%lf\", &orig[i].x, &orig[i].y);\n\t}\n\tif (orig[0].x == -413875276) {\n\t\toutput_deb = 1;\n\t}\n\tfor (int i = 0; i < n - 1; i++) {\n\t\tint a, b;\n\t\tscanf(\"%d%d\", &a, &b);\n\t\ta--; b--;\n\t\te[a].push_back(b);\n\t\te[b].push_back(a);\n\t}\n\n\tfa[0] = -1;\n\tDfsInit(0);\n\tfor (int i = 0; i < n; i++) {\n\t\tif (output_deb) {\n\t\t\tdouble sum =\n\t\t\t\t\tfa[i] == -1 ? 0 : GetAngle(orig[fa[i]] - orig[i]);\n\t\t\t\tcout << \"sort: \" << i << endl;\n\t\t\t\tfor (int j = 0; j < (int)e[i].size(); j++) {\n\t\t\t\t\tsum += GetAngle(orig[e[i][j]] - orig[i]);\n\t\t\t\t\tif (j >= 70) {\n\t\t\t\t\t\tcout << \"|\";\n\t\t\t\t\t\tcout << GetAngle(orig[e[i][j]] - orig[i]) << '|';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcout << \"all\" << sum << endl;\n\t\t\t}\n\n\t\tsort(e[i].begin(), e[i].end(),\n\t\t\t\t[&](const int& a, const int& b) {\n\t\t\tdouble anga = GetAngle(orig[a] - orig[i]);\n\t\t\tdouble angb = GetAngle(orig[b] - orig[i]);\n\t\t\tdouble angfa =\n\t\t\t\t\tfa[i] == -1 ? 0 : GetAngle(orig[fa[i]] - orig[i]);\n\t\t\tif (anga > angfa) anga -= pi * 2;\n\t\t\tif (angb > angfa) angb -= pi * 2;\n\t\t\treturn anga < angb;\n\t\t});\n\t\tif (output_deb) cout << \"sort done\" << endl;\n\t}\n\tDfsOrder(0);\n\trange[n] = mpr(n, n + 1);\n\tReMap();\n\tfor (int i = 0; i < n; i++) GetRoute(i);\n\n\tassert(lin == n);\n\tfor (int i = 0; i < n; i++) assert(range[i].first == i);\n\tfor (int i = 0; i < n; i++) {\n\t\tif (!(i == 0 || e[i].back() == fa[i])) {\n\t\t\tcerr << i << endl;\n\t\t}\n\t}\n\n\tmemset(dp, -1, sizeof(dp));\n\tDfsDp(0);\n\n\tcout << dp[0] << endl;\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b412f5e8105a48bcf11cf2e32ab5b71f", "src_uid": "9b764e44167cc5d2bdfabcb811cdd93b", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n \ntypedef long long ll;\ntypedef long double ld;\ntypedef double db; \ntypedef string str; \n\ntypedef pair pi;\ntypedef pair pl; \ntypedef pair pd; \n\ntypedef vector vi; \ntypedef vector vl; \ntypedef vector vd; \ntypedef vector vs; \ntypedef vector vpi;\ntypedef vector vpl; \ntypedef vector vpd; \n\n#define mp make_pair \n#define f first\n#define s second\n#define sz(x) (int)x.size()\n#define all(x) begin(x), end(x)\n#define rall(x) (x).rbegin(), (x).rend() \n#define rsz resize\n#define ins insert \n#define ft front() \n#define bk back()\n#define pf push_front \n#define pb push_back\n#define eb emplace_back \n#define lb lower_bound \n#define ub upper_bound \n\n#define FOR(i,a,b) for (int i = (a); i < (b); ++i)\n#define F0R(i,a) FOR(i,0,a)\n#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)\n#define R0F(i,a) ROF(i,0,a)\n#define trav(a,x) for (auto& a: x)\n\nconst int MOD = 998244353;\nconst int MX = 2e5+5; \nconst ll INF = 1e18; \nconst ld PI = acos((ld)-1);\nconst int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; \n\ntemplate bool ckmin(T& a, const T& b) { \n\treturn b < a ? a = b, 1 : 0; }\ntemplate bool ckmax(T& a, const T& b) { \n\treturn a < b ? a = b, 1 : 0; } \nint pct(int x) { return __builtin_popcount(x); } \nint bit(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) \nint cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 \n\n// INPUT\ntemplate void re(complex& c);\ntemplate void re(pair& p);\ntemplate void re(vector& v);\ntemplate void re(array& a);\n\ntemplate void re(T& x) { cin >> x; }\nvoid re(db& d) { str t; re(t); d = stod(t); }\nvoid re(ld& d) { str t; re(t); d = stold(t); }\ntemplate void re(H& h, T&... t) { re(h); re(t...); }\n\ntemplate void re(complex& c) { A a,b; re(a,b); c = {a,b}; }\ntemplate void re(pair& p) { re(p.f,p.s); }\ntemplate void re(vector& x) { trav(a,x) re(a); }\ntemplate void re(array& x) { trav(a,x) re(a); }\n\n// TO_STRING\n#define ts to_string\ntemplate str ts(pair p);\ntemplate str ts(complex c) { return ts(mp(c.real(),c.imag())); }\nstr ts(bool b) { return b ? \"true\" : \"false\"; }\nstr ts(char c) { str s = \"\"; s += c; return s; }\nstr ts(str s) { return s; }\nstr ts(const char* s) { return (str)s; }\nstr ts(vector v) { \n\tbool fst = 1; str res = \"{\";\n\tF0R(i,sz(v)) {\n\t\tif (!fst) res += \", \";\n\t\tfst = 0; res += ts(v[i]);\n\t}\n\tres += \"}\"; return res;\n}\ntemplate str ts(bitset b) {\n\tstr res = \"\"; F0R(i,SZ) res += char('0'+b[i]);\n\treturn res; }\ntemplate str ts(T v) {\n\tbool fst = 1; str res = \"{\";\n\tfor (const auto& x: v) {\n\t\tif (!fst) res += \", \";\n\t\tfst = 0; res += ts(x);\n\t}\n\tres += \"}\"; return res;\n}\ntemplate str ts(pair p) {\n\treturn \"(\"+ts(p.f)+\", \"+ts(p.s)+\")\"; }\n\n// OUTPUT\ntemplate void pr(A x) { cout << ts(x); }\ntemplate void pr(const H& h, const T&... t) { \n\tpr(h); pr(t...); }\nvoid ps() { pr(\"\\n\"); } // print w/ spaces\ntemplate void ps(const H& h, const T&... t) { \n\tpr(h); if (sizeof...(t)) pr(\" \"); ps(t...); }\n\n// DEBUG\nvoid DBG() { cerr << \"]\" << endl; }\ntemplate void DBG(H h, T... t) {\n\tcerr << to_string(h); if (sizeof...(t)) cerr << \", \";\n\tDBG(t...); }\n#ifdef LOCAL // compile with -DLOCAL\n#define dbg(...) cerr << \"[\" << #__VA_ARGS__ << \"]: [\", DBG(__VA_ARGS__)\n#else\n#define dbg(...) 42\n#endif\n\n// FILE I/O\nvoid setIn(string s) { freopen(s.c_str(),\"r\",stdin); }\nvoid setOut(string s) { freopen(s.c_str(),\"w\",stdout); }\nvoid unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }\nvoid setIO(string s = \"\") {\n\tunsyncIO();\n\t// cin.exceptions(cin.failbit); \n\t// throws exception when do smth illegal\n\t// ex. try to read letter into int\n\tif (sz(s)) { setIn(s+\".in\"), setOut(s+\".out\"); } // for USACO\n}\n\nmt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); \n\n/**\n * Description: modular arithmetic operations \n * Source: \n\t* KACTL\n\t* https://codeforces.com/blog/entry/63903\n\t* https://codeforces.com/contest/1261/submission/65632855 (tourist)\n\t* https://codeforces.com/contest/1264/submission/66344993 (ksun)\n * Verification: \n\t* https://open.kattis.com/problems/modulararithmetic\n */\n\nstruct mi {\n\ttypedef decay::type T; \n \t/// don't silently convert to T\n\tT v; explicit operator T() const { return v; }\n\tmi() { v = 0; }\n\tmi(ll _v) { \n\t\tv = (-MOD < _v && _v < MOD) ? _v : _v % MOD;\n\t\tif (v < 0) v += MOD;\n\t}\n\tfriend bool operator==(const mi& a, const mi& b) { \n\t\treturn a.v == b.v; }\n\tfriend bool operator!=(const mi& a, const mi& b) { \n\t\treturn !(a == b); }\n\tfriend bool operator<(const mi& a, const mi& b) { \n\t\treturn a.v < b.v; }\n\tfriend void re(mi& a) { ll x; re(x); a = mi(x); }\n\tfriend str to_string(mi a) { return to_string(a.v); }\n \n\tmi& operator+=(const mi& m) { \n\t\tif ((v += m.v) >= MOD) v -= MOD; \n\t\treturn *this; }\n\tmi& operator-=(const mi& m) { \n\t\tif ((v -= m.v) < 0) v += MOD; \n\t\treturn *this; }\n\tmi& operator*=(const mi& m) { \n\t\tv = (ll)v*m.v%MOD; return *this; }\n\tmi& operator/=(const mi& m) { return (*this) *= inv(m); }\n\tfriend mi pow(mi a, ll p) {\n\t\tmi ans = 1; assert(p >= 0);\n\t\tfor (; p; p /= 2, a *= a) if (p&1) ans *= a;\n\t\treturn ans;\n\t}\n\tfriend mi inv(const mi& a) { assert(a.v != 0); \n\t\treturn pow(a,MOD-2); }\n\t\t\n\tmi operator-() const { return mi(-v); }\n\tmi& operator++() { return *this += 1; }\n\tmi& operator--() { return *this -= 1; }\n\tfriend mi operator+(mi a, const mi& b) { return a += b; }\n\tfriend mi operator-(mi a, const mi& b) { return a -= b; }\n\tfriend mi operator*(mi a, const mi& b) { return a *= b; }\n\tfriend mi operator/(mi a, const mi& b) { return a /= b; }\n};\ntypedef vector vmi;\ntypedef pair pmi;\ntypedef vector vpmi;\n\nvector comb;\nvoid genComb(int SZ) {\n\tcomb.assign(SZ,vmi(SZ)); comb[0][0] = 1;\n\tFOR(i,1,SZ) F0R(j,i+1) \n\t\tcomb[i][j] = comb[i-1][j]+(j?comb[i-1][j-1]:0);\n}\n\n/**\n * Description: Use in place of \\texttt{complex}.\n * Source: http://codeforces.com/blog/entry/22175, KACTL\n * Verification: various\n */\n\ntypedef ll T;\nint sgn(T a) { return (a>0)-(a<0); }\nT sq(T a) { return a*a; }\n\nnamespace Point {\n\ttypedef pair P; typedef vector

vP;\n\tT norm(const P& p) { return sq(p.f)+sq(p.s); }\n\tT abs(const P& p) { return sqrt(norm(p)); }\n\tT arg(const P& p) { return atan2(p.s,p.f); }\n\tP conj(const P& p) { return P(p.f,-p.s); }\n\tP perp(const P& p) { return P(-p.s,p.f); }\n\tP dir(T ang) { return P(cos(ang),sin(ang)); }\n\t\n\tP operator-(const P& l) { return P(-l.f,-l.s); }\n\tP operator+(const P& l, const P& r) { \n\t\treturn P(l.f+r.f,l.s+r.s); }\n\tP operator-(const P& l, const P& r) { \n\t\treturn P(l.f-r.f,l.s-r.s); }\n\tP operator*(const P& l, const T& r) { \n\t\treturn P(l.f*r,l.s*r); }\n\tP operator*(const T& l, const P& r) { return r*l; }\n\tP operator/(const P& l, const T& r) { \n\t\treturn P(l.f/r,l.s/r); }\n\tP operator*(const P& l, const P& r) { \n\t\treturn P(l.f*r.f-l.s*r.s,l.s*r.f+l.f*r.s); }\n\tP operator/(const P& l, const P& r) { \n\t\treturn l*conj(r)/norm(r); }\n\tP& operator+=(P& l, const P& r) { return l = l+r; }\n\tP& operator-=(P& l, const P& r) { return l = l-r; }\n\tP& operator*=(P& l, const T& r) { return l = l*r; }\n\tP& operator/=(P& l, const T& r) { return l = l/r; }\n\tP& operator*=(P& l, const P& r) { return l = l*r; }\n\tP& operator/=(P& l, const P& r) { return l = l/r; }\n\t\n\tP unit(const P& p) { return p/abs(p); }\n\tT dot(const P& a, const P& b) { return a.f*b.f+a.s*b.s; }\n\tT cross(const P& a, const P& b) { return a.f*b.s-a.s*b.f; }\n\tT cross(const P& p, const P& a, const P& b) {\n\t\treturn cross(a-p,b-p); }\n\tP reflect(const P& p, const P& a, const P& b) { \n\t\treturn a+conj((p-a)/(b-a))*(b-a); }\n\tP foot(const P& p, const P& a, const P& b) { \n\t\treturn (p+reflect(p,a,b))/(T)2; }\n\tbool onSeg(const P& p, const P& a, const P& b) { \n\t\treturn cross(a,b,p) == 0 && dot(p-a,p-b) <= 0; }\n\tostream& operator<<(ostream& os, const P& p) {\n\t\treturn os << \"(\" << p.f << \",\" << p.s << \")\"; }\n};\nusing namespace Point;\n\nint n,par[101],depth[101];\nP pos[201];\nmi dp[101], childProd[101];\nvi adj[101];\n\nbool ccw(int a, int b, int c) {\n\treturn cross(pos[a],pos[b],pos[c]) >= 0; } // OK\n\nvi tot;\nvoid genChild(int x) { // OK\n\ttot.pb(x);\n\ttrav(t,adj[x]) genChild(t);\n}\n\nvi path(int a, int b) {\n\tint _a = a, _b = b;\n\tvi x, y;\n\twhile (a != b) {\n\t\tif (depth[a] > depth[b]) {\n\t\t\tx.pb(a);\n\t\t\ta = par[a];\n\t\t} else {\n\t\t\ty.pb(b);\n\t\t\tb = par[b];\n\t\t}\n\t}\n\treverse(all(y));\n\tx.pb(a); x.insert(end(x),all(y));\n\t// dbg(\"??\",_a,_b,x);\n\treturn x;\n} // OK\n\nbool bet(P a, P b, P c) {\n\tif (cross(a,c) > 0) {\n\t\treturn cross(a,b) > 0 && cross(b,c) > 0;\n\t}\n\treturn cross(a,b) > 0 || cross(b,c) > 0;\n}\n\nmi get(int a, int b, int c) {\n\tmi prod = 1;\n\ttrav(t,adj[b]) {\n\t\tif (t == a || t == c) continue;\n\t\tif (bet(pos[a]-pos[b],pos[t]-pos[b],pos[c]-pos[b])) {\n\t\t\t//ps(\"WUT\",a,b,c,t);\n\t\t\tprod *= dp[t];\n\t\t}\n\t}\n\treturn prod;\n}\n\nmi val(int x, int y) {\n\tif (x == y) return 0; // OK\n\tvi v = path(x,y); // OK\n\ttrav(t,v) if (!ccw(x,y,t)) return 0; // OK\n\tmi prod = 1; trav(t,adj[x]) if (t != v[1]) prod *= dp[t];\n\tFOR(i,1,sz(v)-1) prod *= get(v[i-1],v[i],v[i+1]);\n\t// dbg(\"VAL\",x,y,prod);\n\treturn prod;\n}\n\nmi nex[201][201];\nmi lo[201][201], hi[201][201];\nvi TMP[201];\n\nmi dumb(vi c) {\n\t// return 0;\n\tF0R(i,sz(c)) {\n\t\tvector> tmp;\n\t\tF0R(j,sz(c)) if (nex[c[i]][c[j]] != 0 || nex[c[j]][c[i]] != 0) {\n\t\t\tif (j < i) tmp.pb({pos[c[i]]-pos[c[j]],j});\n\t\t\telse tmp.pb({pos[c[j]]-pos[c[i]],j});\n\t\t}\n\t\tsort(all(tmp),[](pair x, pair y) {\n\t\t\treturn cross(x.f,y.f) > 0; });\n\t\tTMP[i].clear(); trav(t,tmp) TMP[i].pb(t.s);\n\t}\n\ttrav(a,c) trav(b,c) lo[a][b] = hi[a][b] = 0;\n\tmi res = 0;\n\tF0R(i,sz(c)) {\n\t\tmi LO = (i == 0);\n\t\ttrav(t,TMP[i]) {\n\t\t\tif (t < i) LO += lo[t][i];\n\t\t\telse lo[i][t] = nex[c[i]][c[t]]*LO;\n\t\t}\n\t\treverse(all(TMP[i]));\n\t\tmi HI = (i == 0);\n\t\ttrav(t,TMP[i]) {\n\t\t\tif (t < i) HI += hi[t][i];\n\t\t\telse hi[i][t] = nex[c[t]][c[i]]*HI;\n\t\t}\n\t\tif (i) res += LO*HI;\n\t}\n\treturn res;\n}\n\nint makeEd(int a, int b) {\n\tassert(abs(depth[a]-depth[b]) == 1);\n\tif (depth[a] < depth[b]) return b;\n\treturn a+n;\n}\n\nmi deal(vi c, int a) {\n\tauto _c = c;\n\tvi verts; trav(x,c) verts.pb(x), verts.pb(x+n);\n\ttrav(x,verts) trav(y,verts) nex[x][y] = 0;\n\t// return 0;\n\t// val[x,y] for all good pairs\n\ttrav(x,c) trav(y,c) {\n\t\tmi z = val(x,y); if (!ccw(x,y,a)) z = 0;\n\t\tif (z == 0) continue;\n\t\tvi v = path(x,y);\n\t\tnex[makeEd(v[1],x)][makeEd(v[sz(v)-2],y)] = z;\n\t}\n\tmi res = 0;\n\tsort(all(verts),[&](int x, int y) { return pos[x] < pos[y]; });\n\twhile (sz(verts) > 1) {\n\t\tres += dumb(verts);\n\t\tverts.erase(begin(verts));\n\t}\n\t// dbg(\"DEAL\",_c,a,res);\n\treturn res;\n}\n\nvoid dfs(int a) {\n\tchildProd[a] = 1;\n\ttrav(t,adj[a]) dfs(t), childProd[a] *= dp[t];\n\tdp[a] = childProd[a];\n\ttot.clear(); genChild(a);\n\tdp[a] += deal(tot,a);\n\ttrav(t,adj[a]) {\n\t\ttot.clear(); genChild(t);\n\t\tdp[a] -= deal(tot,a);\n\t}\n\t// dbg(a,dp[a],adj[a]);\n}\n\nvoid genDepth(int x) {\n\ttrav(t,adj[x]) {\n\t\tpar[t] = x; depth[t] = depth[x]+1;\n\t\tpos[t+n] = pos[x];\n\t\tadj[t].erase(find(all(adj[t]),x));\n\t\tgenDepth(t);\n\t}\n}\n\nint main() {\n\tsetIO(); re(n);\n\tFOR(i,1,n+1) re(pos[i]);\n\tF0R(i,n-1) {\n\t\tint a,b; re(a,b);\n\t\tadj[a].pb(b), adj[b].pb(a);\n\t}\n\tgenDepth(1); dfs(1);\n\tps(dp[1]);\n\t// you should actually read the stuff at the bottom\n}\n\n/* stuff you should look for\n\t* int overflow, array bounds\n\t* special cases (n=1?)\n\t* do smth instead of nothing and stay organized\n\t* WRITE STUFF DOWN\n*/\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f400bf78f51a283b7c4e0145335a2fa5", "src_uid": "9b764e44167cc5d2bdfabcb811cdd93b", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n \ntypedef long long ll;\ntypedef long double ld;\ntypedef double db; \ntypedef string str; \n\ntypedef pair pi;\ntypedef pair pl; \ntypedef pair pd; \n\ntypedef vector vi; \ntypedef vector vl; \ntypedef vector vd; \ntypedef vector vs; \ntypedef vector vpi;\ntypedef vector vpl; \ntypedef vector vpd; \n\n#define mp make_pair \n#define f first\n#define s second\n#define sz(x) (int)x.size()\n#define all(x) begin(x), end(x)\n#define rall(x) (x).rbegin(), (x).rend() \n#define rsz resize\n#define ins insert \n#define ft front() \n#define bk back()\n#define pf push_front \n#define pb push_back\n#define eb emplace_back \n#define lb lower_bound \n#define ub upper_bound \n\n#define FOR(i,a,b) for (int i = (a); i < (b); ++i)\n#define F0R(i,a) FOR(i,0,a)\n#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)\n#define R0F(i,a) ROF(i,0,a)\n#define trav(a,x) for (auto& a: x)\n\nconst int MOD = 998244353;\nconst int MX = 2e5+5; \nconst ll INF = 1e18; \nconst ld PI = acos((ld)-1);\nconst int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; \n\ntemplate bool ckmin(T& a, const T& b) { \n\treturn b < a ? a = b, 1 : 0; }\ntemplate bool ckmax(T& a, const T& b) { \n\treturn a < b ? a = b, 1 : 0; } \nint pct(int x) { return __builtin_popcount(x); } \nint bit(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) \nint cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 \n\n// INPUT\ntemplate void re(complex& c);\ntemplate void re(pair& p);\ntemplate void re(vector& v);\ntemplate void re(array& a);\n\ntemplate void re(T& x) { cin >> x; }\nvoid re(db& d) { str t; re(t); d = stod(t); }\nvoid re(ld& d) { str t; re(t); d = stold(t); }\ntemplate void re(H& h, T&... t) { re(h); re(t...); }\n\ntemplate void re(complex& c) { A a,b; re(a,b); c = {a,b}; }\ntemplate void re(pair& p) { re(p.f,p.s); }\ntemplate void re(vector& x) { trav(a,x) re(a); }\ntemplate void re(array& x) { trav(a,x) re(a); }\n\n// TO_STRING\n#define ts to_string\ntemplate str ts(pair p);\ntemplate str ts(complex c) { return ts(mp(c.real(),c.imag())); }\nstr ts(bool b) { return b ? \"true\" : \"false\"; }\nstr ts(char c) { str s = \"\"; s += c; return s; }\nstr ts(str s) { return s; }\nstr ts(const char* s) { return (str)s; }\nstr ts(vector v) { \n\tbool fst = 1; str res = \"{\";\n\tF0R(i,sz(v)) {\n\t\tif (!fst) res += \", \";\n\t\tfst = 0; res += ts(v[i]);\n\t}\n\tres += \"}\"; return res;\n}\ntemplate str ts(bitset b) {\n\tstr res = \"\"; F0R(i,SZ) res += char('0'+b[i]);\n\treturn res; }\ntemplate str ts(T v) {\n\tbool fst = 1; str res = \"{\";\n\tfor (const auto& x: v) {\n\t\tif (!fst) res += \", \";\n\t\tfst = 0; res += ts(x);\n\t}\n\tres += \"}\"; return res;\n}\ntemplate str ts(pair p) {\n\treturn \"(\"+ts(p.f)+\", \"+ts(p.s)+\")\"; }\n\n// OUTPUT\ntemplate void pr(A x) { cout << ts(x); }\ntemplate void pr(const H& h, const T&... t) { \n\tpr(h); pr(t...); }\nvoid ps() { pr(\"\\n\"); } // print w/ spaces\ntemplate void ps(const H& h, const T&... t) { \n\tpr(h); if (sizeof...(t)) pr(\" \"); ps(t...); }\n\n// DEBUG\nvoid DBG() { cerr << \"]\" << endl; }\ntemplate void DBG(H h, T... t) {\n\tcerr << to_string(h); if (sizeof...(t)) cerr << \", \";\n\tDBG(t...); }\n#ifdef LOCAL // compile with -DLOCAL\n#define dbg(...) cerr << \"[\" << #__VA_ARGS__ << \"]: [\", DBG(__VA_ARGS__)\n#else\n#define dbg(...) 42\n#endif\n\n// FILE I/O\nvoid setIn(string s) { freopen(s.c_str(),\"r\",stdin); }\nvoid setOut(string s) { freopen(s.c_str(),\"w\",stdout); }\nvoid unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }\nvoid setIO(string s = \"\") {\n\tunsyncIO();\n\t// cin.exceptions(cin.failbit); \n\t// throws exception when do smth illegal\n\t// ex. try to read letter into int\n\tif (sz(s)) { setIn(s+\".in\"), setOut(s+\".out\"); } // for USACO\n}\n\nmt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); \n\n/**\n * Description: modular arithmetic operations \n * Source: \n\t* KACTL\n\t* https://codeforces.com/blog/entry/63903\n\t* https://codeforces.com/contest/1261/submission/65632855 (tourist)\n\t* https://codeforces.com/contest/1264/submission/66344993 (ksun)\n * Verification: \n\t* https://open.kattis.com/problems/modulararithmetic\n */\n\nstruct mi {\n\ttypedef decay::type T; \n \t/// don't silently convert to T\n\tT v; explicit operator T() const { return v; }\n\tmi() { v = 0; }\n\tmi(ll _v) { \n\t\tv = (-MOD < _v && _v < MOD) ? _v : _v % MOD;\n\t\tif (v < 0) v += MOD;\n\t}\n\tfriend bool operator==(const mi& a, const mi& b) { \n\t\treturn a.v == b.v; }\n\tfriend bool operator!=(const mi& a, const mi& b) { \n\t\treturn !(a == b); }\n\tfriend bool operator<(const mi& a, const mi& b) { \n\t\treturn a.v < b.v; }\n\tfriend void re(mi& a) { ll x; re(x); a = mi(x); }\n\tfriend str to_string(mi a) { return to_string(a.v); }\n \n\tmi& operator+=(const mi& m) { \n\t\tif ((v += m.v) >= MOD) v -= MOD; \n\t\treturn *this; }\n\tmi& operator-=(const mi& m) { \n\t\tif ((v -= m.v) < 0) v += MOD; \n\t\treturn *this; }\n\tmi& operator*=(const mi& m) { \n\t\tv = (ll)v*m.v%MOD; return *this; }\n\tmi& operator/=(const mi& m) { return (*this) *= inv(m); }\n\tfriend mi pow(mi a, ll p) {\n\t\tmi ans = 1; assert(p >= 0);\n\t\tfor (; p; p /= 2, a *= a) if (p&1) ans *= a;\n\t\treturn ans;\n\t}\n\tfriend mi inv(const mi& a) { assert(a.v != 0); \n\t\treturn pow(a,MOD-2); }\n\t\t\n\tmi operator-() const { return mi(-v); }\n\tmi& operator++() { return *this += 1; }\n\tmi& operator--() { return *this -= 1; }\n\tfriend mi operator+(mi a, const mi& b) { return a += b; }\n\tfriend mi operator-(mi a, const mi& b) { return a -= b; }\n\tfriend mi operator*(mi a, const mi& b) { return a *= b; }\n\tfriend mi operator/(mi a, const mi& b) { return a /= b; }\n};\ntypedef vector vmi;\ntypedef pair pmi;\ntypedef vector vpmi;\n\nvector comb;\nvoid genComb(int SZ) {\n\tcomb.assign(SZ,vmi(SZ)); comb[0][0] = 1;\n\tFOR(i,1,SZ) F0R(j,i+1) \n\t\tcomb[i][j] = comb[i-1][j]+(j?comb[i-1][j-1]:0);\n}\n\n/**\n * Description: Use in place of \\texttt{complex}.\n * Source: http://codeforces.com/blog/entry/22175, KACTL\n * Verification: various\n */\n\ntypedef ll T;\nint sgn(T a) { return (a>0)-(a<0); }\nT sq(T a) { return a*a; }\n\nnamespace Point {\n\ttypedef pair P; typedef vector

vP;\n\tT norm(const P& p) { return sq(p.f)+sq(p.s); }\n\tT abs(const P& p) { return sqrt(norm(p)); }\n\tT arg(const P& p) { return atan2(p.s,p.f); }\n\tP conj(const P& p) { return P(p.f,-p.s); }\n\tP perp(const P& p) { return P(-p.s,p.f); }\n\tP dir(T ang) { return P(cos(ang),sin(ang)); }\n\t\n\tP operator-(const P& l) { return P(-l.f,-l.s); }\n\tP operator+(const P& l, const P& r) { \n\t\treturn P(l.f+r.f,l.s+r.s); }\n\tP operator-(const P& l, const P& r) { \n\t\treturn P(l.f-r.f,l.s-r.s); }\n\tP operator*(const P& l, const T& r) { \n\t\treturn P(l.f*r,l.s*r); }\n\tP operator*(const T& l, const P& r) { return r*l; }\n\tP operator/(const P& l, const T& r) { \n\t\treturn P(l.f/r,l.s/r); }\n\tP operator*(const P& l, const P& r) { \n\t\treturn P(l.f*r.f-l.s*r.s,l.s*r.f+l.f*r.s); }\n\tP operator/(const P& l, const P& r) { \n\t\treturn l*conj(r)/norm(r); }\n\tP& operator+=(P& l, const P& r) { return l = l+r; }\n\tP& operator-=(P& l, const P& r) { return l = l-r; }\n\tP& operator*=(P& l, const T& r) { return l = l*r; }\n\tP& operator/=(P& l, const T& r) { return l = l/r; }\n\tP& operator*=(P& l, const P& r) { return l = l*r; }\n\tP& operator/=(P& l, const P& r) { return l = l/r; }\n\t\n\tP unit(const P& p) { return p/abs(p); }\n\tT dot(const P& a, const P& b) { return a.f*b.f+a.s*b.s; }\n\tT cross(const P& a, const P& b) { return a.f*b.s-a.s*b.f; }\n\tT cross(const P& p, const P& a, const P& b) {\n\t\treturn cross(a-p,b-p); }\n\tP reflect(const P& p, const P& a, const P& b) { \n\t\treturn a+conj((p-a)/(b-a))*(b-a); }\n\tP foot(const P& p, const P& a, const P& b) { \n\t\treturn (p+reflect(p,a,b))/(T)2; }\n\tbool onSeg(const P& p, const P& a, const P& b) { \n\t\treturn cross(a,b,p) == 0 && dot(p-a,p-b) <= 0; }\n\tostream& operator<<(ostream& os, const P& p) {\n\t\treturn os << \"(\" << p.f << \",\" << p.s << \")\"; }\n};\nusing namespace Point;\n\nint n,par[101],depth[101];\nP pos[201];\nmi dp[101], childProd[101];\nvi adj[101];\n\nbool ccw(int a, int b, int c) {\n\treturn cross(pos[a],pos[b],pos[c]) >= 0; } // OK\n\nvi tot;\nvoid genChild(int x) { // OK\n\ttot.pb(x);\n\ttrav(t,adj[x]) genChild(t);\n}\n\nvi path(int a, int b) {\n\tint _a = a, _b = b;\n\tvi x, y;\n\twhile (a != b) {\n\t\tif (depth[a] > depth[b]) {\n\t\t\tx.pb(a);\n\t\t\ta = par[a];\n\t\t} else {\n\t\t\ty.pb(b);\n\t\t\tb = par[b];\n\t\t}\n\t}\n\treverse(all(y));\n\tx.pb(a); x.insert(end(x),all(y));\n\t// dbg(\"??\",_a,_b,x);\n\treturn x;\n} // OK\n\nbool bet(P a, P b, P c) {\n\tif (cross(a,c) > 0) {\n\t\treturn cross(a,b) > 0 && cross(b,c) > 0;\n\t}\n\treturn cross(a,b) > 0 || cross(b,c) > 0;\n}\n\nmi get(int a, int b, int c) {\n\tmi prod = 1;\n\ttrav(t,adj[b]) {\n\t\tif (t == a || t == c) continue;\n\t\tif (bet(pos[a]-pos[b],pos[t]-pos[b],pos[c]-pos[b])) {\n\t\t\t//ps(\"WUT\",a,b,c,t);\n\t\t\tprod *= dp[t];\n\t\t}\n\t}\n\treturn prod;\n}\n\nmi val(int x, int y) {\n\tif (x == y) return 0; // OK\n\tvi v = path(x,y); // OK\n\ttrav(t,v) if (!ccw(x,y,t)) return 0; // OK\n\tmi prod = 1; trav(t,adj[x]) if (t != v[1]) prod *= dp[t];\n\tFOR(i,1,sz(v)-1) prod *= get(v[i-1],v[i],v[i+1]);\n\t// dbg(\"VAL\",x,y,prod);\n\treturn prod;\n}\n\nmi nex[201][201];\nmi lo[201][201], hi[201][201];\nvi TMP[201];\n\nmi dumb(vi c) {\n\t// return 0;\n\tF0R(i,sz(c)) {\n\t\tvector> tmp;\n\t\tF0R(j,sz(c)) if (pos[c[i]] != pos[c[j]]) {\n\t\t\tif (j < i) tmp.pb({pos[c[i]]-pos[c[j]],j});\n\t\t\telse tmp.pb({pos[c[j]]-pos[c[i]],j});\n\t\t}\n\t\tsort(all(tmp),[](pair x, pair y) {\n\t\t\treturn cross(x.f,y.f) > 0; });\n\t\tTMP[i].clear(); trav(t,tmp) TMP[i].pb(t.s);\n\t}\n\ttrav(a,c) trav(b,c) lo[a][b] = hi[a][b] = 0;\n\tmi res = 0;\n\tF0R(i,sz(c)) {\n\t\tmi LO = (i == 0);\n\t\ttrav(t,TMP[i]) {\n\t\t\tif (t < i) LO += lo[t][i];\n\t\t\telse lo[i][t] = nex[c[i]][c[t]]*LO;\n\t\t}\n\t\treverse(all(TMP[i]));\n\t\tmi HI = (i == 0);\n\t\ttrav(t,TMP[i]) {\n\t\t\tif (t < i) HI += hi[t][i];\n\t\t\telse hi[i][t] = nex[c[t]][c[i]]*HI;\n\t\t}\n\t\tif (i) res += LO*HI;\n\t}\n\t//dbg(\"RESULT\",c,res);\n\treturn res;\n}\n\nint makeEd(int a, int b) {\n\tassert(abs(depth[a]-depth[b]) == 1);\n\tif (depth[a] < depth[b]) return b;\n\treturn a+n;\n}\n\nmi deal(vi c, int a) {\n\tauto _c = c;\n\tvi verts; trav(x,c) verts.pb(x), verts.pb(x+n);\n\ttrav(x,verts) trav(y,verts) nex[x][y] = 0;\n\t// return 0;\n\t// val[x,y] for all good pairs\n\ttrav(x,c) trav(y,c) {\n\t\tmi z = val(x,y); if (!ccw(x,y,a)) z = 0;\n\t\tif (z == 0) continue;\n\t\tvi v = path(x,y);\n\t\tnex[makeEd(v[1],x)][makeEd(v[sz(v)-2],y)] = z;\n\t}\n\tmi res = 0;\n\tsort(all(verts),[&](int x, int y) { return pos[x] < pos[y]; });\n\twhile (sz(verts) > 1) {\n\t\tres += dumb(verts);\n\t\tverts.erase(begin(verts));\n\t}\n\t// dbg(\"DEAL\",_c,a,res);\n\treturn res;\n}\n\nvoid dfs(int a) {\n\tchildProd[a] = 1;\n\ttrav(t,adj[a]) dfs(t), childProd[a] *= dp[t];\n\tdp[a] = childProd[a];\n\ttot.clear(); genChild(a);\n\tdp[a] += deal(tot,a);\n\ttrav(t,adj[a]) {\n\t\ttot.clear(); genChild(t);\n\t\tdp[a] -= deal(tot,a);\n\t}\n\t// dbg(a,dp[a],adj[a]);\n}\n\nvoid genDepth(int x) {\n\ttrav(t,adj[x]) {\n\t\tpar[t] = x; depth[t] = depth[x]+1;\n\t\tpos[t+n] = pos[x];\n\t\tadj[t].erase(find(all(adj[t]),x));\n\t\tgenDepth(t);\n\t}\n}\n\nint main() {\n\tsetIO(); re(n);\n\tFOR(i,1,n+1) re(pos[i]);\n\tF0R(i,n-1) {\n\t\tint a,b; re(a,b);\n\t\tadj[a].pb(b), adj[b].pb(a);\n\t}\n\tgenDepth(1); dfs(1);\n\tps(dp[1]);\n\t// you should actually read the stuff at the bottom\n}\n\n/* stuff you should look for\n\t* int overflow, array bounds\n\t* special cases (n=1?)\n\t* do smth instead of nothing and stay organized\n\t* WRITE STUFF DOWN\n*/\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e1d1d4ced25e6e7b570cd406a62cfa0c", "src_uid": "9b764e44167cc5d2bdfabcb811cdd93b", "difficulty": 3500.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#define ll long long int\nusing namespace std;\n\nconst int MAXN = 1e5+2;\nll dp[MAXN][4];\n\nll comb(int n, int k){\n if(k==n||k==0) return 1;\n if(k>n) return 0;\n if(dp[n][k]>0) return dp[n][k];\n ll ans = comb(n-1,k-1) + comb(n-1,k);\n return dp[n][k]=ans;\n}\n\nll func(int a,int b,int c,int l){\n ll ans = 0;\n for(int l1=0;l1<=l;l1++){\n int k = min(l-l1,a+l1-b-c);\n ans+= comb(k+2,2);\n }\n for(int l1=0;l1<=l;l1++){\n int k = min(l-l1,b+l1-a-c);\n ans+= comb(k+2,2);\n }\n for(int l1=0;l1<=l;l1++){\n int k = min(l-l1,c+l1-b-a);\n ans+= comb(k+2,2);\n }\n return ans;\n}\nvoid init(){\n for(int i = 0;i<1e5+5;i++)\n for(int j = 0;j<5;j++)\n dp[i][j] = -1;\n}\nint main() {\n int a,b,c,l;\n scanf(\"%d %d %d %d\",&a,&b,&c,&l);\n init();\n ll total = comb(l+3,3);\n ll ans = func(a,b,c,l);\n printf(\"%lld\\n\",total - ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c15327547e70eb0c5a3be4a489e58f17", "src_uid": "185ff90a8b0ae0e2b75605f772589410", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nconst int MAXN = 1e5+2;\nint dp[MAXN][4];\n\nint comb(int n, int k){\n if(k==n||k==0) return 1;\n if(k>n) return 0;\n if(dp[n][k]>0) return dp[n][k];\n int ans = comb(n-1,k-1) + comb(n-1,k);\n return dp[n][k]=ans;\n}\n\nint func(int a,int b,int c,int l){\n int ans = 0;\n for(int l1=0;l1<=l;l1++){\n int k = min(l-l1,a+l1-b-c);\n ans+= comb(k+2,2);\n }\n for(int l1=0;l1<=l;l1++){\n int k = min(l-l1,b+l1-a-c);\n ans+= comb(k+2,2);\n }\n for(int l1=0;l1<=l;l1++){\n int k = min(l-l1,c+l1-b-a);\n ans+= comb(k+2,2);\n }\n return ans;\n}\n\nint main() {\n int a,b,c,l;\n scanf(\"%d %d %d %d\",&a,&b,&c,&l);\n memset(dp, -1, (l+100)*(l+100)*sizeof(dp[0][0]));\n int total = comb(l+3,3);\n int ans = func(a,b,c,l);\n printf(\"%d\\n\",total - ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a5a6100fab32952a4bdb02fa10ce17c0", "src_uid": "185ff90a8b0ae0e2b75605f772589410", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nconst int MAXN = 1e3+2;\nint dp[MAXN][MAXN];\n\nint comb(int n, int k){\n if(k==n||k==0) return 1;\n if(k>n) return 0;\n if(dp[n][k]>0) return dp[n][k];\n int ans = comb(n-1,k-1) + comb(n-1,k);\n return dp[n][k]=ans;\n}\n\nint func(int a,int b,int c,int l){\n int ans = 0;\n for(int l1=0;l1<=l;l1++){\n int k = min(l-l1,a+l1-b-c);\n ans+= comb(k+2,2);\n }\n for(int l1=0;l1<=l;l1++){\n int k = min(l-l1,b+l1-a-c);\n ans+= comb(k+2,2);\n }\n for(int l1=0;l1<=l;l1++){\n int k = min(l-l1,c+l1-b-a);\n ans+= comb(k+2,2);\n }\n return ans;\n}\n\nint main() {\n int a,b,c,l;\n scanf(\"%d %d %d %d\",&a,&b,&c,&l);\n memset(dp, -1, (l+100)*(l+100)*sizeof(dp[0][0]));\n int total = comb(l+3,3);\n int ans = func(a,b,c,l);\n printf(\"%d\\n\",total - ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "45ee69b91fa012ee44b037881f59366b", "src_uid": "185ff90a8b0ae0e2b75605f772589410", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include\n#define int long long\n#define max(a,b) a>b?a:b\nusing namespace std;\nint ans,jc[1000001];\nint C(int a,int b){\n\tif(a>a>>b>>c>>l;\n\tans+=C(l+3,3);\n\twork(a,b,c,l);\n\twork(a,c,b,l);\n\twork(b,c,a,l);\n\tcout<\nusing namespace std;\ntypedef unsigned long long int ull;\null power(ull a,ull n)\n{\n ull z=power(a,n/2);\n if(n%2==0)\n {\n return z*z;\n }\n else\n {\n return z*z*a;\n }\n}\nint main()\n{\n ios_base::sync_with_stdio(0);\n\tull n;\n\n\tcin >> n;\n\tcout << 2*(power(2,n)-1);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3a77dc8c356a83e125d28797180e659d", "src_uid": "f1b43baa14d4c262ba616d892525dfde", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nvector v;\nint main(){\n\tint n;\n\tcin>>n;\n\tint ans=0;\n\tlong long s=1;\n\tqueue q;\n\tif (n==1){\n\t\tcout<<2;\n\t\treturn 0;\n\t}\n\tq.push(\"0\");\n\tq.push(\"7\");\n\tq.push(\"8\");\n\tint k1=3;\n\twhile (!q.empty()){\n\t\tint s=q.front().size();\n\t\tint k=k1;\n\t\tk1=0;\n\t\tfor (int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define pb push_back\n#define mp(x,y) make_pair(x,y)\n#define SS stringstream\n#define ll long long\n#define lop(i,v) for (int i = 0; i < v; i++)\n#define lop_start(j,v) for (int i = j; i < v; i++)\n\nusing namespace std;\nvector v; int n;\nvoid lucky(string r=\"\"){\n\tif(r.length() > n) return;\n\tif(r != \"\") v.push_back(r);\n\tlucky(r+\"7\");\n\tlucky(r+\"8\");\n}\nint main(){\n ios::sync_with_stdio(false);\n\tcin>>n; int counter = 0, i=0;\n\tlucky();\n\twhile( i\n#include\n#include\n#include\n#include\n#include\n#define ll long long \nusing namespace std;\nstring s1, s2;\nmapmp;\nvectorluky;\nll m;\nll sum = 0;\nll lulu(int n , int i )\n{\n\t\n\tif (i > m ) return 0;\n\tif (n)\n\t{\n\t\tluky.push_back(n);\n\t\tsum++;\n\t\t\n\t}\n\t\tlulu(n * 10 + 7, i + 1);\n\t\tlulu(n * 10 + 8, i + 1);\n\t\n\treturn sum; \n}\n\nint main()\n{\n\tios::sync_with_stdio(0);\n\tcin >> m;\n\tcout << lulu(0, 0);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "98cac406845957ea2d9f66069bc00278", "src_uid": "f1b43baa14d4c262ba616d892525dfde", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include\n\nusing namespace std;\n\nbool modifier(string in);\nstring convert(string in);\n\nint main () \n{\n string caps;\n getline (cin,caps); \n if(modifier(caps))\n caps=convert(caps);\n cout<=\"A\" && in.substr(le,1)<=\"Z\"))\n {\n return false;\n } \n } \n return true;\n\n} \nint len;\nstring convert(string in)\n{\n for(len=0;len= 'A' && in[len] <= 'Z') \n in[len]-= ('A'-'a'); \n else if(in[len] >= 'a' && in[len] <= 'z')\n in[len]-= ('a'-'A');\n } \n return in; \n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d397c6a991334d859d93336130a5ae95", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\nint main()\n{\n string s,t[100];\n short int i,k,j,l,count=0;\n \n getline(cin,s);\n l=s.length();\n \n for(i=1;i<=l;i++)\n {\n if((s[i]!='A')&&(s[i]!='Z'))\n {\n if((s[i]>='a')&&(s[i]<='z'))\n count++;\n \n if(count==0)\n {\n \n \n \n \n if((s[i]>='A')&&(s[i]<='Z'))\n s[i]+='a'-'A';\n if((s[0]>='a')&&(s[0]<='z'))\n s[0]-='a'-'A';\n else if((s[0]>='A')&&(s[0]<='Z'))\n s[0]+='a'-'A'; \n }\n}\n} \n\n cout<\n\nusing namespace std;\n\nint main()\n{\n int i,l=0;\n char s[100];\n scanf(\"%s\",s);\n for(i=1; i=65&&s[i]<=90)\n {\n l++;\n }\n }\n if(l==strlen(s)-1)\n {\n for(i=0; i=65&&s[i]<=90)\n s[i]=97+s[i]-65;\n else if(s[i]>=97&&s[i]<=122)\n s[i]=65+s[i]-97;\n }\n }\n\n printf(\"%s\\n\",s);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9a0078e7059091b8479ce795d8421338", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "# include\n# include\n# include\nusing namespace std;\nint main()\n{\n string s;\n int i,l,p=0;\n getline(cin,s);\n l=s.length();\n for(i=1;i='a')&&(s[i]<='z'))\n p++;\n } \n if(p==0)\n {\n for(i=1;i='A')&&(s[i]<='Z'))\n s[i]+='a'-'A';\n \n if((s[0]>='a')&&(s[0]<='z'))\n s[0]-='a'-'A';\n else if((s[0]>='A')&&(s[0]<='Z'))\n s[0]+='a'-'A'; \n } \n cout<\r\n#define int long long\r\n#define double long double\r\n\r\ntypedef std::vector vi;\r\ntypedef std::vector vvi;\r\ntypedef std::vector vvvi;\r\ntypedef std::vector vvvvi;\r\ntypedef std::vector vs;\r\ntypedef std::vector vb;\r\ntypedef std::vector vvb;\r\ntypedef std::vector vd;\r\ntypedef std::vector vvd;\r\ntypedef std::pair pii;\r\ntypedef std::vector vpii;\r\ntypedef std::vector vvpii;\r\nusing ull = unsigned long long;\r\n\r\nusing namespace std;\r\n\r\nconstexpr int mod = 1e9 + 7, p = 179;\r\n\r\nint phi1 (int n)\r\n{\r\n int result = n;\r\n for (int i = 2; i * i <= n; ++i)\r\n if (n % i == 0)\r\n {\r\n while (n % i == 0)\r\n n /= i;\r\n result -= result / i;\r\n }\r\n if (n > 1)\r\n result -= result / n;\r\n return result;\r\n}\r\n\r\nint gcd (int a, int b) {\r\n while (b)\r\n {\r\n a %= b;\r\n swap(a, b);\r\n }\r\n return a;\r\n}\r\n\r\nint lcm(int a, int b)\r\n{\r\n return a * b / gcd(a, b);\r\n}\r\n\r\nint solve()\r\n{\r\n int n;\r\n cin >> n;\r\n vi phi(n + 1, 0);\r\n for (int i = 1; i <= n; ++i)\r\n {\r\n phi[i] = phi1(i);\r\n }\r\n int ans = 0;\r\n for (int c = 1; c < n - 1; ++c)\r\n {\r\n int sum = n - c;\r\n for (int d = 1; d * d <= sum; ++d)\r\n {\r\n if (sum % d == 0)\r\n {\r\n if (d * d == sum || d == 1)\r\n {\r\n ans = (ans + lcm(c, d) * phi[sum / d]) % mod;\r\n }\r\n else\r\n {\r\n ans = (ans + lcm(c, d) * phi[sum / d]) % mod;\r\n ans = (ans + lcm(c, sum / d) * phi[d]) % mod;\r\n }\r\n }\r\n }\r\n }\r\n cout << ans << endl;\r\n}\r\n\r\nint32_t main()\r\n{\r\n //ofstream cout(\"test.txt\");\r\n //ifstream cin(\"joseph.in\");\r\n //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\r\n ios_base::sync_with_stdio(false);\r\n cin.tie(0), cout.tie(0), cerr.tie(0);\r\n solve();\r\n //solve();\r\n return 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "29014b4b58846dacd740b6948e355067", "src_uid": "c3694a6ff95c64bef8cbe8834c3fd6cb", "difficulty": 2200.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize(\"Ofast\")\r\n#pragma GCC target(\"avx,avx2,fma\")\r\n#pragma GCC optimization (\"O3\")\r\n#pragma GCC optimization (\"unroll-loops\")\r\n\r\n#include\r\nusing namespace std;\r\n\r\n#define pb push_back\r\n#define mp make_pair\r\n#define F first\r\n#define S second\r\n#define lb lower_bound\r\n#define ub upper_bound\r\n#define all(x) x.begin(), x.end()\r\n\r\ntypedef long long ll;\r\ntypedef long double ld;\r\ntypedef complex cd;\r\ntypedef pair pii;\r\ntypedef pair pll;\r\ntypedef pair pld;\r\ntypedef vector vi;\r\ntypedef vector vd;\r\ntypedef vector vl;\r\ntypedef vector vpi;\r\ntypedef vector vpl;\r\n\r\n#define FOR(i, a, b) for (int i=a; i<(b); i++)\r\n#define F0R(i, a) for (int i=0; i<(a); i++)\r\n#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)\r\n#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)\r\n#define trav(a,x) for (auto& a : x)\r\n\r\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\r\n\r\nconst int mod = 1e9 + 7;\r\n\r\nll powmod(ll a,ll b) {ll res=1; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}\r\nll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}\r\n\r\nconst int N = 500001;\r\nvector> f(N, vi(200));\r\nvector cnt(N);\r\n\r\nvector phi;\r\nvoid phi1_to_n(int n) \r\n{\r\n phi.resize(n+1);\r\n for(int i = 0; i <= n; ++i ) phi[i] = i;\r\n \r\n for (int p=2; p<=n; ++p) \r\n { \r\n if (phi[p]==p) \r\n {\r\n for (int i=p; i<=n; i += p) \r\n phi[i] -= phi[i]/p; \r\n } \r\n } \r\n}\r\n\r\nvoid pre() {\r\n for(int i=1;i> n;\r\n ll F = 0;\r\n for(int c=1;c<=n-2;++c) {\r\n int t = n - c;\r\n vl ans(t+1, 0);\r\n unordered_map M;\r\n for(int i=cnt[t]-2;i>=0;--i) {\r\n int g = f[t][i];\r\n int ans = phi[t/g];\r\n // int ans = t/g - 1 - M[g];\r\n // for(int j=cnt[t]-2;j>=0;--j) M[f[g][j]] += ans;\r\n // ans = (ans%mod + mod)%mod;\r\n ll r = (c/gcd(c,g))*1ll*g;\r\n F = (F + r*1ll*ans%mod)%mod;\r\n }\r\n }\r\n cout << F << '\\n';\r\n}\r\n\r\nint main(){\r\n ios_base::sync_with_stdio(false); cin.tie(NULL); \r\n #ifndef ONLINE_JUDGE\r\n freopen(\"input.txt\",\"r\",stdin);\r\n freopen(\"output.txt\",\"w\",stdout);\r\n #endif\r\n phi1_to_n(N);\r\n pre();\r\n solve();\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f2172013a1060d544667f1ed53290f48", "src_uid": "c3694a6ff95c64bef8cbe8834c3fd6cb", "difficulty": 2200.0} {"lang": "GNU C++17", "source_code": "#include \r\n#include \r\n#include \r\n#include\r\nusing namespace std;\r\nlong long mod = 1e9+7;\r\n#define endl '\\n'\r\n#define ll long long\r\n#define ull unsigned long long\r\nconst int N = 1e8+1;\r\nint n,m;\r\nvectoreuler(N);\r\n\r\nint lcm(int a,int b) {\r\n int gcd = __gcd(a,b);\r\n return 1ll*(a*b)/gcd;\r\n}\r\n\r\nvoid calcEuler() {\r\n for(int i=1;i>n;\r\n calcEuler();\r\n ll ans(0);\r\n for(int i=1; i<=n-2; i++) { // iterating over all possible D\r\n for(int k=2*i; k<=n; k+=i) { // k is a+b\r\n int c = n - k;\r\n ans += 1ll*lcm(c,i)*euler[k/i]%mod;\r\n ans %= mod;\r\n }\r\n }\r\n cout<\r\nusing namespace std;\r\n\r\n#define pb push_back\r\n#define mp make_pair\r\n#define F first\r\n#define S second\r\n#define lb lower_bound\r\n#define ub upper_bound\r\n#define all(x) x.begin(), x.end()\r\n\r\ntypedef long long ll;\r\ntypedef long double ld;\r\ntypedef complex cd;\r\ntypedef pair pii;\r\ntypedef pair pll;\r\ntypedef pair pld;\r\ntypedef vector vi;\r\ntypedef vector vd;\r\ntypedef vector vl;\r\ntypedef vector vpi;\r\ntypedef vector vpl;\r\n\r\n#define FOR(i, a, b) for (int i=a; i<(b); i++)\r\n#define F0R(i, a) for (int i=0; i<(a); i++)\r\n#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)\r\n#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)\r\n#define trav(a,x) for (auto& a : x)\r\n\r\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\r\n\r\nconst int mod = 1e9 + 7;\r\n\r\nll powmod(ll a,ll b) {ll res=1; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}\r\nll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}\r\n\r\nconst int N = 500001;\r\nvector> f(N, vi(200));\r\nvector cnt(N);\r\n\r\nvoid pre() {\r\n for(int i=1;i> n;\r\n ll F = 0;\r\n for(int c=1;c<=n-2;++c) {\r\n int t = n - c;\r\n vl ans(t+1, 0);\r\n unordered_map M;\r\n for(int i=cnt[t]-1;i>=0;--i) {\r\n int g = f[t][i];\r\n int ans = t/g - 1 - M[g];\r\n for(int j=cnt[t]-2;j>=0;--j) M[f[g][j]] += ans;\r\n ans = (ans%mod + mod)%mod;\r\n ll r = (c/gcd(c,g))*1ll*g;\r\n F = (F + r*1ll*ans%mod)%mod;\r\n }\r\n }\r\n cout << F << '\\n';\r\n}\r\n\r\nint main(){\r\n ios_base::sync_with_stdio(false); cin.tie(NULL); \r\n #ifndef ONLINE_JUDGE\r\n freopen(\"input.txt\",\"r\",stdin);\r\n freopen(\"output.txt\",\"w\",stdout);\r\n #endif\r\n pre();\r\n solve();\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "46cfd268c0e21bf0ae54b50fe71a0f15", "src_uid": "c3694a6ff95c64bef8cbe8834c3fd6cb", "difficulty": 2200.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\n#define FOR(I,A,B) for (int I=int(A);I n || r < 1 || r > n) return 0;\n if (s[x][l][r] != -1) return s[x][l][r];\n //cout << x << \" \" << l << \" \" << r << endl;\n int dl = x % 2 ? -1 : 1, dr = x / 2 ? 1 : -1;\n return s[x][l][r] = add(add(p[l][r][x], P - sum(x, l + dl, r + dr)), add(sum(x, l + dl, r), sum(x, l, r + dr)));\n}\nint main() {\n //freopen(\"in.txt\", \"r\", stdin);\n cin >> n >> m;\n if (n < m) swap(n, m);\n FOR(l, 1, m + 1)\n FOR(r, l, m + 1)\n FOR(i, 0, 4)\n f[1][l][r][i] = 1;\n FOR(i, 1, n) {\n MEM(s, -1);\n CPY(p, f[i]);\n FOR(l, 1, m + 1)\n FOR(r, l, m + 1) {\n f[i + 1][l][r][0] = sum(0, l, r);\n f[i + 1][l][r][1] = add(sum(1, l, r) - sum(1, l - 1, l - 1) + P, sum(0, l + 1, r));\n f[i + 1][l][r][2] = add(sum(2, l, r) - sum(2, r + 1, r + 1) + P, sum(0, l, r - 1));\n if (l == 1 && r == 1) {\n // cout << sum(3, l, r) << endl;\n }\n f[i + 1][l][r][3] = add(add(sum(3, l, r), sum(0, l + 1, r - 1)), \n add(sum(1, l, r - 1) - sum(1, l - 1, l - 1) + P, sum(2, l + 1, r) - sum(2, r + 1, r + 1) + P));\n }\n }\n int ans = 0;\n FOR(i, 1, n + 1)\n FOR(l, 1, m + 1)\n FOR(r, l, m + 1)\n ans = add(ans, mul(n - i + 1, f[i][l][r][3]));\n cout << ans << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c0fbb6cc6ec3bf958b790f9c850d08be", "src_uid": "740eceed59d3c6ac55c1bf9d3d4160c7", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#define rr int\nusing namespace std;\ntypedef long long ll;\ninline ll read() {\n char i = getchar();\n ll f = 1, res = 0;\n while (i < '0' || i > '9') {\n if (i == '-') f = -1;\n i = getchar();\n }\n while (i >= '0' && i <= '9') {\n res = res * 10 + i - '0';\n i = getchar();\n }\n return res * f;\n}\nconst int mod = 1000000007;\nconst int N = 105;\nll f[N][N][2][2]; // \u5de6\u8fb9\u754c\u662f\u5426\u51f8\uff0c\u53f3\u8fb9\u754c\u662f\u5426\u51f8\nint n, m;\ninline void upd(ll &a, ll b) { a = (a + b) % mod; }\nint main() {\n n = read(), m = read();\n for (rr i = 1; i <= m; ++i) {\n for (rr j = i; j <= m; ++j) {\n f[i][j][1][1] = 1;\n }\n }\n ll ans = 0;\n for (rr i = 1; i <= n; ++i) {\n ll res = 0;\n for (rr l = 1; l <= m; ++l)\n for (rr r = l; r <= m; ++r)\n for (rr kl = 0; kl <= 1; ++kl)\n for (rr kb = 0; kb <= 1; ++kb)\n res = (res + f[l][r][kl][kb]) % mod;\n ans = (ans + res * (n - i + 1)) % mod;\n for (rr l = 1; l <= m; ++l)\n for (rr r = l + 1; r <= m; ++r)\n for (rr kr = 0; kr <= 1;\n ++kr) { //\u524d\u7f00\u53e0\u52a0 \u6ce8\u610f\u987a\u5e8f \u51f9\u7684\u65f6\u5019\u53e6\u5916\u4e00\u8fb9\u51f8\u51f9\u90fd\u53ef\u4ee5\n upd(f[l + 1][r][0][kr], f[l][r][0][kr]);\n upd(f[l + 1][r][0][kr], f[l][r][1][kr]);\n }\n for (rr l = 1; l <= m; ++l)\n for (rr r = m; r >= l + 1; --r)\n for (rr kl = 0; kl <= 1; ++kl) {\n upd(f[l][r - 1][kl][0], f[l][r][kl][0]);\n upd(f[l][r - 1][kl][0], f[l][r][kl][1]);\n }\n for (rr l = m; l >= 2; --l)\n for (rr r = l; r <= m; ++r)\n for (rr kr = 0; kr <= 1; ++kr) {\n upd(f[l - 1][r][1][kr], f[l][r][1][kr]);\n }\n for (rr l = m; l >= 1; --l)\n for (rr r = l; r < m; ++r)\n for (rr kl = 0; kl <= 1; ++kl) {\n upd(f[l][r + 1][kl][1], f[l][r][kl][1]);\n }\n }\n printf(\"%lld\\n\", ans);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f22a769bb4cc1939447955c8171e0ac4", "src_uid": "740eceed59d3c6ac55c1bf9d3d4160c7", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nlong long f[151][2][2][151][151];\nconst int mod = 1000000007;\nint main() {\n int n, m;\n\t//freopen(\"i.in\",\"r\",stdin);\n\t//freopen(\"i.out\",\"w\",stdout);\n\tscanf(\"%d%d\", &n, &m);\n\tmemset(f,0,sizeof(f));\n\tfor (int l = 1; l <= m; l++)\n\t\tfor (int r = l; r <= m; r++) {\n\t\t\tf[1][1][1][l][r] = 1;\n\t\t}\n\tfor (int i = 1; i <= n; i++) {\n if (i > 1) \n\t\tfor (int len = m; len >= 1; len-- ) {\n\t\t\tfor (int l = 1; l <= m; l++) {\n\t\t\t\tint r = l + len - 1;\n\t\t\t\tif (r > m) continue;\n\t\t\t\tfor (int x = 1; x >= 0; x--) {\n\t\t\t\t\tfor (int y = 1; y >= 0; y--) {\n\t\t\t\t\t\tif (l < r) {\n\t\t\t\t\t\t\tf[i][0][y][l+1][r] = (f[i][0][y][l+1][r] + f[i][x][y][l][r]) % mod;\n\t\t\t\t\t\t\tf[i][x][0][l][r-1] = (f[i][x][0][l][r-1] + f[i][x][y][l][r]) % mod;\n\t\t\t\t\t\t\tif (l < r-1)\n\t\t\t\t\t\t\tf[i][0][0][l+1][r-1] = (f[i][0][0][l+1][r-1] - f[i][x][y][l][r]) % mod;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (i > 1) \n\t\tfor (int len = 1; len <= m; len++) {\n\t\t\tfor (int l = 1; l <= m; l++) {\n int r = l + len - 1;\n\t\t\t if (r > m) continue;\n\t\t\t\tfor (int x = 1; x >= 0; x--) {\n\t\t\t\t\tfor (int y = 1; y >= 0; y--) {\n\t\t\t\t\t\tif (x == 1 && l > 1) f[i][x][y][l-1][r] = (f[i][x][y][l-1][r] + f[i][x][y][l][r]) % mod;\n\t\t\t\t\t\tif (y == 1 && r < m) f[i][x][y][l][r+1] = (f[i][x][y][l][r+1] + f[i][x][y][l][r]) % mod;\n\t\t\t\t\t\tif (x == 1 && y == 1 && l > 1 && r < m)\n\t\t\t\t\t\t\tf[i][x][y][l-1][r+1] = (f[i][x][y][l-1][r+1] - f[i][x][y][l][r] + mod) % mod;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int len = 1; len <= m; len++) {\n\t\t\tfor (int l = 1; l <= m; l++) {\n\t\t\t\tfor (int x = 1; x >= 0; x--) {\n\t\t\t\t\tfor (int y = 1; y >= 0; y--) {\n\t\t\t\t\t\tint r = l + len - 1;\n\t\t\t\t\t\tif (r > m) continue;\n\t\t\t\t\t\tf[i+1][x][y][l][r] = (f[i+1][x][y][l][r] + f[i][x][y][l][r]) % mod;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tint ans = 0;\n\tfor (int i = 1; i <= n; i++) {\n\tfor (int x = 0; x <= 1; x++)\n\t\tfor (int y = 0; y <= 1; y++)\n\t\t\tfor (int len = 1; len <= m; len++)\n\t\t\t\tfor (int l = 1; l <= m; l++) {\n\t\t\t\t\tint r = (l+len-1);\n\t\t\t\t\tif (r > m) continue;\n\t\t\t\t\tans = (ans + (1LL * f[i][x][y][l][r] * (n-i+1)) % mod) % mod;\n\t\t\t\t\t//cout << i << \" \" << x << \" \" << y << \" \" << l << \" \" << r << \" \" << f[i][x][y][l][r] << endl; \n\t\t\t\t}\n\t\t\t\t//cout << ans << endl;\n }\n\tprintf(\"%d\\n\", ans);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b8b67e19605560c863c9544c31ab9e30", "src_uid": "740eceed59d3c6ac55c1bf9d3d4160c7", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\n#define FOR(I,A,B) for (int I=int(A);I m || r < 1 || r > m) return 0;\n if (s[x][l][r] != -1) return s[x][l][r];\n //cout << x << \" \" << l << \" \" << r << endl;\n int dl = x % 2 ? -1 : 1, dr = x / 2 ? 1 : -1;\n return s[x][l][r] = add(add(p[l][r][x], P - sum(x, l + dl, r + dr)), add(sum(x, l + dl, r), sum(x, l, r + dr)));\n}\nint main() {\n //freopen(\"in.txt\", \"r\", stdin);\n cin >> n >> m;\n FOR(l, 1, m + 1)\n FOR(r, l, m + 1)\n FOR(i, 0, 4)\n f[1][l][r][i] = 1;\n FOR(i, 1, n) {\n MEM(s, -1);\n CPY(p, f[i]);\n FOR(l, 1, m + 1)\n FOR(r, l, m + 1) {\n f[i + 1][l][r][0] = sum(0, l, r);\n f[i + 1][l][r][1] = add(sum(1, l, r) - sum(1, l - 1, l - 1) + P, sum(0, l + 1, r));\n f[i + 1][l][r][2] = add(sum(2, l, r) - sum(2, r + 1, r + 1) + P, sum(0, l, r - 1));\n // if (l == 1 && r == 1) {\n // cout << sum(3, l, r) << endl;\n // }\n f[i + 1][l][r][3] = add(add(sum(3, l, r), sum(0, l + 1, r - 1)), \n add(sum(1, l, r - 1) - sum(1, l - 1, l - 1) + P, sum(2, l + 1, r) - sum(2, r + 1, r + 1) + P));\n }\n }\n int ans = 0;\n FOR(i, 1, n + 1)\n FOR(l, 1, m + 1)\n FOR(r, l, m + 1)\n ans = add(ans, mul(n - i + 1, f[i][l][r][3]));\n cout << ans << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cc6f9f696fe5c9ced5dc65e92fbb1c72", "src_uid": "740eceed59d3c6ac55c1bf9d3d4160c7", "difficulty": 2400.0} {"lang": "GNU C++0x", "source_code": "// #include \n#include \n#include \nusing namespace std;\nconst int MAXN = 1000000005;\nbool mark[MAXN];\nint main(){\n int a, b;\n int i = 2;\n cin >> a >> b;\n int ans = 0;\n int k = a - b;\n if(a == b){\n cout << \"infinity\" << '\\n';\n return 0;\n }\n if(b == 0)\n ans++;\n while(i < sqrt(k))\n {\n if(k % i == 0) {\n if(i > b){\n ans++;\n }\n if(k / i > b)\n ans++;\n }\n i++;\n }\n ans++;\n if(i * i == k && i > b)\n ans++;\n cout << ans << \" \" << '\\n';\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b8bf1a7ed67d6e015edab4466de1e5d6", "src_uid": "6e0715f9239787e085b294139abb2475", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint main()\n{\n long a,b,i,p=0;\n cin>>a>>b;\n if(a==b)\n {\n cout<<\"infinity\";\n return 0;\n }\n else if(afloor(a/2.0))\n {\n cout<<0;\n return 0;\n }\n \n else \n {\n long f[a-b+1]={0};\n for(i=1;i*i<=a-b;i++)\n {\n if((a-b)%i==0)\n {\n f[i]=1;\n f[(a-b)/i]=1;\n }\n }\n for(i=b+1;i<=a-b;i++)\n {\n if(f[i])\n p++;\n }\n cout<\n#include \nusing namespace std;\n\nint main()\n{\n\tlong long a,b, k, cnt=0, j=0;\n\tcin>>a>>b;\n\tif(a==b)\n\t\tcout<<\"infinity\"<=b;i--)\n\t\tif(a%i==b){\n\t\t\tk=i;\n\t\t\tcnt++;\n\t\t\tbreak;\n\t\t}\n\n\t\tlong long *arr=new long long int[k/2];\n\n\t\tfor(int i=k/2;i>=1;i--)\n\t\t\tif(k%i==0){\n\t\t\t\tarr[j]=i;\n\t\t\t\tj++;\n\t\t\t}\n\t\t\n\t\t\tfor(int i=0;i\n#include\n#include\nusing namespace std;\n\nint main()\n{\n \n long long int a[10],b,c,m=0;\ncin>>b>>c;\nif(b-c>c)\n{\n\nfor(int i=c+1;i<=b-c;i++)\n{if((b-c)%i==0)\nm=m+1;\n\n \n \n}\ncout<\n#include\nusing namespace std;\nint main()\n{\n\tint c=0, B=0, b=0, d=0,l,i;\n\tstring str;\n\tcin >> str;\n\tl=str.length();\n\tif (l<100&&l>=5)\n\t{\n\t\tfor (i = 0; i < l; i++)\n\t\t{\n\t\t\tif (str[i] >= '0'&&str[i] <= '9'){ d++; }\n\t\t\telse if (str[i] >= 'a'&&str[i] <= 'z'){ b++; }\n\t\t\telse if (str[i] >= 'A'&&str[i] <= 'Z'){ B++; }\n\t\t\telse{c++;}\n\t\t}\n\t\tif (B != 0 && b != 0 && d != 0) { cout << \"Correct\"; }\n\t\telse{ cout << \"Too weak\"; }\n\t}\n\telse\n\t{\n\t\tcout << \"Too weak\";\n\t}\n\tsystem(\"PAUSE\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fa55376b4c677eebe4d74482af25d0b7", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "//#define _CRT_SECURE_NO_WARNINGS\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nvoid input(), output(), solve();\n\nint n, c1 = 0, c2 = 0, c3 = 0;\nstring s;\n\nint main()\n{\n\tinput(); solve(); output();\n}\n\nvoid input()\n{\n\tfreopen(\"a.inp\", \"r\", stdin);\n\tfreopen(\"a.out\", \"w\", stdout);\n\tgetline(cin, s);\n}\n\nvoid solve()\n{\n\tint k;\n\tn= s.length();\n\tfor (int i = 1; i != n; i++)\n\t{\n\t\tk = s[i];\n\t\tif ((k >= 65) && (k <= 90))\n\t\t{\n\t\t\tc1 = 1;\n\t\t}\n\t\tif ((k >= 48) && (k <= 57))\n\t\t{\n\t\t\tc2 = 1;\n\t\t}\n\t\tif ((k <= 122) && (k >= 97))\n\t\t{\n\t\t\tc3 = 1;\n\t\t}\n\t}\n}\n\nvoid output()\n{\n\tif ((n >= 5) && (c1 + c2 + c3 == 3))\n\t{\n\t\tprintf(\"%s\\n\", \"Correct\");\n\t} \n\telse\n\t{\n\t\tprintf(\"%s\\n\", \"Too weak\");\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "88ffa98ab0ebd49d40150e198c82dea6", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nint main(){\n\tint a = 0, b = 0, c = 0;\n\tstring s;\n\tgetline(cin, s);\n\tfor (int i = 0; i < s.length(); i++){\n\t\tif (isalpha(s[i]) && islower(s[i]))\n\t\t\ta++;\n\t\telse\n\t\t\tif (isalpha(s[i]) && isupper(s[i]))\n\t\t\t\tb++;\n\t\t\telse\n\t\t\t\tif (isdigit(s[i]))\n\t\t\t\t\tc++;\n\t\t\t\telse \n\t\t\t\t\tcontinue;\n\t}\n\tif ((s.length() >= 5) && (a >= 1) && (b >= 1) && (c >= 1))\n\t\tcout << \"Correct\" << endl;\n\telse\n\t\tcout << \"Too weak\" << endl;\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9acf8bde467649d2f2f9a52a22196bce", "src_uid": "42a964b01e269491975965860ec92be7", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \nvoid main()\n{\n char string[100];\n int i,is,is1;\n for(;;)\n {\n std::cin.getline(string, sizeof(string),'\\n');\n if (strlen(string)>4)\n {\n is=0;\n while ( string[i] )\n {\n if ( isalpha(string[i])){is=10;break;} \n else {i++;} \n }\n i=0;\n while ( string[i] ) \n {\n if (isdigit(string[i])){ is1=10;break;} \n else {i++;} \n } \n if(is==10 && is1==10){std::cout<<\"Correct \"; break;}\n else std::cout<<\"Too weak \"<\n#define up(j,k,i) for(i=j;ik;i--)\n#define M 900000\n#define cool 0\ntypedef int l;\ntypedef float f;\ntypedef double d;\ntypedef long long int lld;\nusing namespace std;\nlld bin[65];\nlld ans[66][M];\nvoid conv_binary(lld i)\n{\nbin[i]=bin[i/2]*10+i%2;\n}\nint main()\n{\nbin[1]=1;bin[2]=10;bin[3]=11;bin[4]=100;\nlld n,i,k,start,j,min=M;\nup(5,65,i)\n{\nconv_binary(i);\n}\ncin>>n;\nans[0][1]=1;\nans[1][1]=1;\nans[0][0]=0;\nlld pos=0;\nup(2,n+1,i)\n{\nj=1;\nmin=n+10;\nwhile(i>=bin[j])\n{\nif(min>ans[0][i-bin[j]])\n{\nmin=ans[0][i-bin[j]];\npos=j;\n}\nj++;\n}\nup(1,65,k)\nans[k][i]=ans[k][i-bin[pos]];\nans[0][i]=min+1;\nans[pos][i]=1+ans[pos][i];\n}\ncout<=1)\n{\nwhile(ans[k][n]>=1)\n{\ncout<\n#include \n#include \n#include \nusing namespace std;\n\nint main(){\n\n\t/*string s;\n\tcin >> s;\n\n\n\tfor (int i = 0; i < s.length(); i++){\n\t\tfor (int j = 1; i+j <= s.length(); j++){\n\t\t\tstring buf = s;\n\t\t\tbuf.erase(i, j);\n\t\t\tif (buf == \"CODEFORCES\") {\n\t\t\t\tcout << \"YES\";\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\n\n\tcout << \"NO\";*/\n\n\n\tint n;\n\tcin >> n;\n\n\n\tvector v;\n\t\n\n\n\tfor (int i = 1; i <= 1000000; i *= 10){\n\t\tint sz = v.size();\n\t\tv.push_back(i);\n\n\t\tfor (int j = 0; j < sz; j++)\n\t\t\tv.push_back(i + v[j]);\n\t}\n\n\tsort(v.begin(),v.end());\n\t//for (int i = 0; i < v.size(); i++)\n\t//\tcout << v[i] << endl;\n\n\n\tvector ans;\n\tvector best;\n\tint min = 99999;\n\tint i_start = v.size() - 1;\n\ti_start = 63;\n\twhile (i_start >= 0){\n\t\tint i = i_start;\n\t\tint n_buf = n;\n\t\tans.clear();\n\n\n\t\twhile (n_buf > 0){\n\n\t\t\twhile (v[i] > n_buf) i--;\n\t\t\twhile (n_buf >= v[i]){\n\t\t\t\tn_buf -= v[i];\n\t\t\t\tans.push_back(v[i]);\n\t\t\t}\n\t\t}\n\t\tif (ans.size() < min){\n\t\t\tbest = ans;\n\t\t\tmin = best.size();\n\t\t}\n\n\t\ti_start--;\n\t}\n\t\n\tcout << best.size()<\n\nusing namespace std;\n#define ll long long\nbool isBin(ll x)\n{\n while(x>0)\n {\n if(x%10!=1&&x%10!=0)\n return false ;\n x /= 10 ;\n }\n return true ;\n}\n\nint main()\n{\n ios_base::sync_with_stdio(0) ;\n vector allNums ;\n ll n ;\n cin >> n ;\n for(ll i=1;i<=n;i++)\n {\n if(isBin(i))\n allNums.push_back(i) ;\n }\n sort(allNums.rbegin(),allNums.rend()) ;\n ll mini= 1e9 ;\n vector res ;\n for(int i=0;itemp ;\n for(int j=i;j\n#include \n#include \n#include \nusing namespace std;\n\nint main(){\n\n\t/*string s;\n\tcin >> s;\n\n\n\tfor (int i = 0; i < s.length(); i++){\n\t\tfor (int j = 1; i+j <= s.length(); j++){\n\t\t\tstring buf = s;\n\t\t\tbuf.erase(i, j);\n\t\t\tif (buf == \"CODEFORCES\") {\n\t\t\t\tcout << \"YES\";\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\n\n\tcout << \"NO\";*/\n\n\n\tint n;\n\tcin >> n;\n\n\n\tvector v;\n\t\n\n\n\tfor (int i = 1; i <= 1000000; i *= 10){\n\t\tint sz = v.size();\n\t\tv.push_back(i);\n\n\t\tfor (int j = 0; j < sz; j++)\n\t\t\tv.push_back(i + v[j]);\n\t}\n\n\tsort(v.begin(),v.end());\n\t//for (int i = 0; i < v.size(); i++)\n\t//\tcout << v[i] << endl;\n\n\n\tvector ans;\n\tvector best;\n\tint min = 99999;\n\tint i_start = v.size() - 1;\n\t\n\twhile (i_start >= 0){\n\t\tint i = i_start;\n\t\tint n_buf = n;\n\t\tans.clear();\n\n\t\twhile (n_buf > 0){\n\n\t\t\twhile (v[i] > n_buf) i--;\n\t\t\twhile (n_buf >= v[i]){\n\t\t\t\tn_buf -= v[i];\n\t\t\t\tans.push_back(v[i]);\n\t\t\t}\n\t\t}\n\t\tif (ans.size() < min){\n\t\t\tbest = ans;\n\t\t\tmin = best.size();\n\t\t}\n\n\t\ti_start--;\n\t}\n\n\tcout << best.size()<\n#include \n#include \n#include \n\n#define N 1000 * 1000 + 5\nusing namespace std;\n\nint mask(int x)\n{\n\tchar s[N];\n\tchar * ans = new char[N];\n\tmemset(ans, 0, N);\n\tint ai = 0;\n\tsnprintf(s, N, \"%d\", x);\n\tfor (int i = 0; i < strlen(s); ++i)\n\t{\n\t\tif(s[i] == '4' || s[i] == '7')\n\t\t\tans[ai++] = s[i];\n\t}\n\treturn atoi(ans);\n}\n\nint main(){\n\n\tint a, b;\n\tcin >> a >> b;\n\ta++;\n\twhile(mask(a) != b)\n\t\ta++;\n\tcout << a;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "739f066aafdbb2a60b4cc2a964d95af2", "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n\n#define N 1000 * 100 + 5\nusing namespace std;\n\nint mask(int x)\n{\n\tchar s[N];\n\tchar * ans = new char[N];\n\tmemset(ans, 0, N);\n\tint ai = 0;\n\tsnprintf(s, N, \"%d\", x);\n\tfor (int i = 0; i < strlen(s); ++i)\n\t{\n\t\tif(s[i] == '4' || s[i] == '7')\n\t\t\tans[ai++] = s[i];\n\t}\n\treturn atoi(ans);\n}\n\nint main(){\n\n\tint a, b;\n\tcin >> a >> b;\n\ta++;\n\twhile(mask(a) != b)\n\t\ta++;\n\tcout << a;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fe81dcca579f2c22c1511cb3af3be144", "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nint a,b;\nint code(long unsigned int x )\n{\nint so=0;\n \n while(x/10>0)\n {\n int tam=x%10;\n if(tam==7 || tam==4) so=so*10+tam;\n x=x/10;\n }\n if(x==7 || x==4) so=so*10+x;\n int tam=0;\n while (so/10 >0)\n \n {\n tam=tam*10+so%10;\n so=so/10;\n }\n tam=tam*10+so; \n return(tam); \n}\n \nint process(){\n int i=0;\n while(code(a+i)!= b) i++; \n printf(\"%d\",a+i);\n}\nint main(){\n scanf(\"%d%d\",&a,&b);\n process();\n getch();\n \treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9eb3ff41f853d52559b10137af170d27", "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define MOD 1000000007\n#include\n\nusing namespace std;\n\nint main()\n{\nint a,b;\n\nscanf(\"%d%d\",&a,&b);\nchar str1[10],str2[10];\nitoa(a,str1,10);\nitoa(b,str2,10);\n\nint len1=strlen(str1)-1;\nint len2=strlen(str2)-1;\n\nint i=0;\nint j=0;\n\nwhile((len1-i)>=(len2-j))\n{\n if(str1[i]==str2[j])\n j++;\n\n i++;\n}\n\n\nint k=i-1;\n\nwhile(j<=len2)\nstr1[k++]=str2[j++];\n\nprintf(\"\\n%s\",str1);\n\n getch();\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d2a9d894a0d54e48e69162cb0c6c4c80", "src_uid": "e5e4ea7a5bf785e059e10407b25d73fb", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n#define MOD 1000000007\n\nifstream fin(\".in\");\n\nlong long int k,i,urm,cur,total,rez,j,n,a,b,zile,p,q,x,ans;\ndouble d;\n\nlong long int put( long long int x , long long int p )\n{\n if( p == 1 )\n return x;\n long long int aux;\n aux = put( x , p / 2 ) % MOD;\n aux = aux * aux;\n aux = aux % MOD;\n if( p % 2 )\n aux = aux * x;\n aux = aux % MOD;\n return aux;\n}\n\nint main()\n{\n\n ios::sync_with_stdio(false);\n #ifndef ONLINE_JUDGE\n #define cin fin\n #else\n #define fin cin\n #endif\n\n cin>>a>>b>>n>>x;\n if( a == 1 )\n {\n ans = x + ( b * n % MOD ) % MOD;\n ans = ans % MOD;\n cout<\n\ntypedef unsigned long long ll;\n\nconst ll mod = 1e9 + 7;\n\nll pow(ll base, ll exp) {\n ll ret = 1, mul = base;\n while (exp) {\n if (exp & 1) {\n ret *= mul;\n ret %= mod;\n }\n mul *= mul;\n mul %= mod;\n exp >>= 1;\n }\n return ret;\n}\n\nll modInv(ll base, ll m) {\n return pow(base, m - 2);\n}\n\nint main() {\n ll A, B, n, x;\n scanf(\"%llu%llu%llu%llu\", &A, &B, &n, &x);\n if (A == 1) {\n printf(\"%llu\\n\", (x + n * B) % mod);\n } else {\n ll sol = ((pow(A, n) * x) % mod + (B * (((pow(A, n) - 1) * modInv(A - 1, mod)) % mod)) % mod) % mod;\n printf(\"%llu\\n\", sol);\n }\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "636b819a1fd7a78b918d170662311f9e", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef unsigned int ui;\ntypedef long double ld;\ntypedef pair ii;\ntypedef pair iii;\nint MOD = 1e9 + 7;\nconst ld E = 1e-8;\n#define null NULL\n#define ms(x) memset(x, 0, sizeof(x))\n#ifndef LOCAL\n#define endl \"\\n\"\n#endif\n#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define _read(x) freopen(x, \"r\", stdin)\n#define _write(x) freopen(x, \"w\", stdout)\n#define files(x) _read(x \".in\"); _write(x \".out\")\n#define filesdatsol(x) _read(x \".DAT\"); _write(x \".SOL\")\n#define output _write(\"output.txt\")\n#define input _read(\"input.txt\")\n#define mod % MOD\n#define y1 hello_world\nunsigned char ccc;\nbool _minus = false;\ninline void read(int &n) {\n\tn = 0;\n\t_minus = false;\n\twhile (true) {\n\t\tccc = getchar();\n\t\tif (ccc == ' ' || ccc == '\\n')\n\t\t\tbreak;\n\t\tif (ccc == '-') {\n\t\t\t_minus = true;\n\t\t\tcontinue;\n\t\t}\n\t\tn = n * 10 + ccc - '0';\n\t}\n\tif (_minus)\n\t\tn *= -1;\n}\nchar wwww[12];\nint kkkk;\ninline void write(int x) {\n\tkkkk = 0;\n\tif (!x)\n\t\t++kkkk, wwww[kkkk] = '0';\n\telse\n\t\twhile (x) {\n\t\t\t++kkkk;\n\t\t\twwww[kkkk] = char(x % 10 + '0');\n\t\t\tx /= 10;\n\t\t}\n\tfor (int i = kkkk; i >= 1; --i)\n\t\tputchar(wwww[i]);\n\tputchar('\\n');\n}\ntemplate inline T sqr(T t) {\n\treturn t * t;\n}\n#ifdef LOCAL\n//#define DEBUG\n#endif\n\n#ifdef DEBUG\n#define dbg if(1)\n#else\n#define dbg if(0)\n#endif\n\nll a, b, x, n;\n\ninline ll next(ll x){\n\treturn (x * a + b) mod;\n}\n\nll solve_long(){\n\tll x = ::x;\n\tfor(int i = 0; i < n; i++)\n\t\tx = next(x);\n\treturn x;\n}\n\nll _pow(ll n, ll m){\n\tll ans = (m == 0 ? 1 : m & 1 ? n * _pow(n, m - 1) : sqr(_pow(n, m >> 1))) % MOD;\n\t//cout << n << \" \" << m << \" \" << ans << endl;\n\treturn ans;\n}\n\nll solve_quick(){\n\tif(n == 0)\n\t\treturn x;\n\tif(n == 1){\n\t\treturn (x * a + b) % MOD;\n\t}\n\tif(a == 1){\n\t\treturn (x + n * b) % MOD;\n\t}\n\tll ans = (x * _pow(a, n)) % MOD;\n\tll w = _pow(a, n) - 1;\n\tif(w < 0)\n\t\tw += MOD;\n\tw = (w * b) % MOD;\n\tw = (w * _pow(a - 1, MOD - 2)) % MOD;\n\treturn (ans + w) % MOD;\n}\n\nint main() {\n\n\tsync;\n\tsrand(time(NULL));\n\tcout.precision(10);\n\tcout << fixed;\n\n#ifdef LOCAL\n\tinput;\n\t//output;\n#else\n\n#endif\n\n\tcin >> a >> b >> n >> x;\n\n\tcout << solve_quick() << endl;\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f2798a4c974267aa06d6b116544053b2", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\n\n\n\n\ntypedef long long ll ;\ntypedef long long ull ;\nconst ll mod = 1e9 + 7 ;\nll f(ll a, ll b){\n\n if(b == 0) return 1;\n else if(b == 1) return a ;\n\n if(b & 1){\n return ((a % mod ) * ( f(a,b-1)%mod))%mod;\n }\n ll t = f(a,b/2) % mod;\n return (t * t)%mod;\n}\n ull inv(ull a, ull mod) {\n return a > 1 ? mod - inv(mod % a, a) * mod / a : 1;\n}\n\nint main()\n{\n\n\n ll a , b, n , x ;\n cin >> a >> b >> n >> x;\n\n\n if( n == 1) {\n cout << ( ( (a % mod) * (x % mod) ) %mod + b % mod ) %mod << endl ;\n return 0 ;\n }\n if(a == 1){\n cout << (x + n * b) %mod << endl;\n return 0 ;\n }\n\n ll t = f(a,n) ;\n ll t2 = (t * (x%mod) )%mod;\n\n ll t3 = ( ( (inv(a-1,mod) % mod) * ( ( (t -1)%mod + mod ) %mod)) % mod + mod ) % mod ;\n t3 *= b ;\n t3 %= mod ;\n ll res = (t3 + t2)% mod;\n cout << res << endl ;\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2ddd3437ed6c41a95087a810645ade06", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "//#include \"stdafx.h\"\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std; \n\n#define DEBUG(x) cout << '>' << #x << ':' << x << endl;\n#define FOR(i, a, b) for (int i = (a); i < (b); ++i)\n#define FOR2(i, a, b) for (int i = (a); i > (b); --i)\ninline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }\n\n\n#define fo(i,j,n) for(i=j;i=j;--i)\n#define foo(i,j,v) fo(i,j,sz(v))\n#define Foo(i,j,v) Fo(i,j,sz(v))\n#define li(v) v.begin(),v.end()\n#define sz(v) ((int)v.size())\n#define co continue\n#define re return\n#define inf 1000000001\n#define CLR(a,v) memset((a),(v),sizeof(a)) \n\nconst int INF = 1<<29;\ntypedef long long ll;\n\ninline int two(int n) { return 1 << n; }\ninline int test(int n, int b) { return n & two(b); }\ninline void set_bit(int & n, int b) { n |= two(b); }\ninline void unset_bit(int & n, int b) { n &= ~two(b); }\ninline int last_bit(int n) { return n & (-n); }\ninline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }\n\ntemplate void chmax(T & a, const T & b) { a = max(a, b); }\ntemplate void chmin(T & a, const T & b) { a = min(a, b); }\n///////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\nint dr[] = {-1,0,1,1};\nint dc[] = {1,1,1,0};\nchar board[4][4];\nchar g[3][5];\n\nbool inb(int r, int c) { return r >= 0 && r < 3 && c >= 0 && c < 3; }\n\nbool check(int r, int c, int d)\n{\n char x = board[r][c];\n if (x == '.') return false;\n int n = 0;\n while (inb(r,c) && board[r][c] == x)\n {\n ++n;\n r += dr[d];\n c += dc[d];\n }\n return n == 3;\n}\n\nchar winner()\n{\n FOR(i,0,3) FOR(d,0,4)\n {\n if (check(i,0,d)) return board[i][0];\n if (check(0,i,d)) return board[0][i];\n }\n return 0;\n}\n\nbool isWin(char ch,int n)\n{\n\tif(n < 3)re false; \n\tint i,su = 0;\n\tfo(i,0,3)if(board[i][0]!=ch)break; if(i == 3)su++;\n\tfo(i,0,3)if(board[i][2]!=ch)break; if(i == 3)su++;\n\tfo(i,0,3)if(board[0][i]!=ch)break; if(i == 3)su++;\n\tfo(i,0,3)if(board[2][i]!=ch)break; if(i == 3)su++;\n\tfo(i,0,3)if(board[i][i]!=ch)break; if(i == 3)su++;\n\tfo(i,0,3)if(board[2-i][i]!=ch)break; if(i == 3)su++;\t\n\tre (su >= 1);\n}\n\n\nint main()\n{\n\t\n\n\tFOR(i,0,3) { scanf(\" %s\", board[i]); strcpy(g[i],board[i]); }\n int nx = 0, no = 0;\n FOR(i,0,3) FOR(j,0,3)\n if (board[i][j] == 'X') ++nx;\n else if (board[i][j] == '0') ++no;\n\t\tint n1 = nx,n2 = no; bool w1,w2;\n\t\tif(n1 < n2){ printf(\"illegal\\n\"); re 0; }\n\t\tif((n1-n2) > 1){ printf(\"illegal\\n\"); re 0; }\n\t\tw1 = isWin('X',n1); w2 = isWin('0',n2);\n\t\tchar w = winner();\t\n\t\t//if(w1&w2){ printf(\"illegal\\n\"); re 0; }\n\t\tif(!(w1|w2))\n\t\t{\n\t\t\tif(w != 0)re 0;\n\t\t\t/*if(n1 == n2){ printf(\"first\\n\");\t re 0; }\n\t\t\tf((n1+n2) == 9){ printf(\"draw\\n\");\t re 0; }\n\t\t\tprintf(\"second\\n\");\t re 0; */\n\t\t\t/*\tif (nx == no) printf(\"first\\n\");\n else if (nx+no == 9) printf(\"draw\\n\");\n else printf(\"second\\n\");\n\t\t\t\tre 0;*/\n\t\t}\n //pocet nesedi\n\t\t\n if (nx != no && nx != no+1)\n {\n //printf(\"illegal\\n\");\n //return 0;\n }\n\t\t\n \n if (w == 0) //noone\n {\n\t\t\t\tif (nx == no) printf(\"first\\n\");\n else if (nx+no == 9) printf(\"draw\\n\");\n else printf(\"second\\n\");\n }\n else\n {\n if ((w == 'X' && nx==no) || (w == '0' && nx==no+1))\n {\n printf(\"illegal\\n\");\n return 0;\n }\n bool ok = false;\n FOR(i,0,3)FOR(j,0,3)\n if (board[i][j] == w)\n {\n board[i][j] = '.';\n if (!winner()) ok = true;\n board[i][j] = w;\n }\n if(!ok) printf(\"illegal\\n\");\n else if (w=='X') printf(\"the first player won\\n\");\n else printf(\"the second player won\\n\");\n }\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d4d18751c2d7efbb44f1a856e1c89d87", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\nint x = 0, y = 0;\n\nvoid wrong()\n\t{\n\tprintf (\"%s\", \"illegal\");\n\tgetch();\n\texit (0);\n\t}\n\nvoid win (char c)\n\t{\n\tif (c == '0')\n\t\t{\n\t\tif (x != y) wrong();\n\t\tprintf (\"%s\", \"the second player won\");\n\tgetch();\n\t\texit (0);\n\t\t}\n\telse\n\t\t{\n\t\tif (x - y != 1) wrong;\n\t\tprintf (\"%s\", \"the first player won\");\n\tgetch();\n\t\texit (0);\n\t\t}\n\t}\n\t\nvoid draw ()\n\t{\n\tprintf (\"%s\", \"draw\");\n\tgetch();\n\texit (0);\n\t}\n\t\nvoid lines (char s[4][4])\n\t{\n\tint i, j;\n\tfor (i = 0; i < 3; i++)\n\t\t{\n\t\tif ((s[i][0] == s[i][1] == s[i][2]) && (s[i][0] != '.')) win (s[i][0]); //stroka\n\t\tif ((s[0][i] == s[1][i] == s[2][i]) && (s[0][i] != '.')) win (s[0][i]); //stolbec\n\t\t}\n\tif ((s[0][0] == s[1][1] == s[2][2]) && (s[1][1] != '.')) win (s[1][1]); //diag 00 - 22\n\tif ((s[2][0] == s[1][1] == s[0][2]) && (s[1][1] != '.')) win (s[1][1]); //diag 20 - 02\n //\tif (s[][] == s[][] == s[][] != \".\") win (s[][]);\n\t}\n\t\nvoid exist (char s[4][4])\n\t{\n\tint i, j;\n\tfor (i = 0; i < 3; i++)\n\t\tfor (j = 0; j < 3; j++)\n\t\t\tif (s[i][j] == 'X') x++;\n\t\t\telse if (s[i][j] == '0') y++;\n\tif ((x > y + 1) || (y > x)) wrong();\n\t}\n\nvoid step (char s[4][4])\n\t{\n\tif (x - y == 1)\n\t\t{\n\t\tif (x == 5) draw();\n\t\tprintf (\"%s\", \"second\");\n\tgetch();\n\t\texit (0);\n\t\t}\n\telse\n\t\t{\n\t\tprintf (\"%s\", \"first\");\n\tgetch();\n\t\texit (0);\n\t\t}\n\t}\n\t\nvoid main()\n\t{\n\tint i;\n\tchar s[4][4];\n\tfor (i = 0; i < 3; i++)\n\t\tscanf (\"%s\", s[i]);\n\texist (s);\n\tlines (s);\n\tstep (s);\n\tgetch();\n\t}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b48fe5323725a269e206db7e51010faa", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "// 3C.cpp : Defines the entry point for the console application.\n//\n\n//#include \"stdafx.h\"\n\n#include \n#include \n\n//char bd [3][3] = {0,};\n/*\nchar bd [3][3] = {\t{'1', '2', '3' }, \n\t\t\t\t\t{'4', '5', '6' },\n\t\t\t\t\t{'7', '8', '9' }\n};\n*/\n\nchar bd [3][3] = {\t{ 'X', '0', 'X' } , \n\t\t\t\t\t{ '.', 'X', '.' } ,\n\t\t\t\t\t{ '0', '0', 'X' } };\n\nvoid print_bd()\n{\n\tprintf(\"%c%c%c\\r\\n%c%c%c\\r\\n%c%c%c\\r\\n\", \n\t\tbd[0][0], bd[0][1], bd[0][2], \n\t\tbd[1][0], bd[1][1], bd[1][2], \n\t\tbd[2][0], bd[2][1], bd[2][2] ); \n}\n\nvoid read_bd()\n{\n\tFILE* fp = fopen(\"input.txt\", \"rt\" );\n\tif (fp == 0)\n\t{\n\t\tprintf(\"ERROR no input file\\n\");\n\t\treturn;\n\t}\n\n\tfscanf(fp, \"%c%c%c\\r\\n%c%c%c\\r\\n%c%c%c\", \n\t\t&bd[0][0], &bd[0][1], &bd[0][2], \n\t\t&bd[1][0], &bd[1][1], &bd[1][2], \n\t\t&bd[2][0], &bd[2][1], &bd[2][2] ); \n\n\tfclose(fp);\n}\n\nint find_win()\n{\n\t//printf(\"find horz\\n\");\n\t// horz win\n\tif ( bd[0][0] == bd[0][1] && bd[0][0] == bd[0][2] ) return bd[0][0];\n\tif ( bd[1][0] == bd[1][1] && bd[1][0] == bd[1][2] ) return bd[1][0];\n\tif ( bd[2][0] == bd[2][1] && bd[2][0] == bd[2][2] ) return bd[2][0];\n\t\n\t//printf(\"find vert\\n\");\n\t// vert win\n\tif ( bd[0][0] == bd[1][0] && bd[0][0] == bd[2][0] ) return bd[0][0];\n\tif ( bd[0][1] == bd[1][1] && bd[0][1] == bd[2][1] ) return bd[0][1];\n\tif ( bd[0][2] == bd[1][2] && bd[0][2] == bd[2][2] ) return bd[0][2];\n\t\n\t//printf(\"find diag\\n\");\n\t// diag win\n\tif ( bd[0][0] == bd[1][1] && bd[0][0] == bd[2][2] ) return bd[0][0];\n\tif ( bd[0][2] == bd[1][1] && bd[0][2] == bd[2][0] ) return bd[0][2];\n\n\treturn 0;\n}\n\nint first, second, dot;\nvoid find_count()\n{\n\tfirst = second = dot = 0;\n\n\tchar* p = (char*)&bd[0][0];\n\tfor(int i = 0 ; i < 9; i ++ ) {\n\t\tif ( *p == 'X' ) first ++;\n\t\telse if ( *p == '0' ) second ++;\n\t\telse if ( *p == '.' ) dot ++;\n\t\t//printf(\"%c\", *p++);\n\t\tp++;\n\t}\n\n\tprintf(\"first = %d, second = %d, dot = %d\\n\", first, second, dot );\n}\n\nvoid eval()\n{\n\tint win = find_win();\n\tif ( win == '0' ) { printf(\"the first player won\\n\"); return; }\n\tif ( win == 'X' ) { printf(\"the second player won\\n\"); return; }\n\n\tfind_count();\n\tif ( dot == 0 ) { printf(\"draw\\n\"); return; }\n\telse if ( first == second ) { printf(\"first\\n\"); return; }\n\telse if ( first+1 == second ) { printf(\"first\\n\"); return; }\n\telse printf(\"illegal\\n\");\n}\n\nint main(int argc, char* argv[])\n{\n\t//read_bd();\n\tprint_bd();\n\n\teval();\n\n\t_getch();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c9b9c431215fa9388c009c5d12dbf52b", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\nint x = 0, y = 0;\n\nvoid wrong()\n\t{\n\tprintf (\"%s\", \"illegal\");\n\t//getch();\n\texit (0);\n\t}\n\nvoid win (char c)\n\t{\n\tif (c == '0')\n\t\t{\n\t\tif (x != y) wrong();\n\t\tprintf (\"%s\", \"the second player won\");\n\t//getch();\n\t\texit (0);\n\t\t}\n\telse\n\t\t{\n\t\tif (x - y != 1) wrong();\n\t\tprintf (\"%s\", \"the first player won\");\n\t//getch();\n\t\texit (0);\n\t\t}\n\t}\n\t\nvoid draw()\n\t{\n\tprintf (\"%s\", \"draw\");\n\t//getch();\n\texit (0);\n\t}\n\t\nvoid lines (char s[4][4])\n\t{\n\tint i, j;\n\tfor (i = 0; i < 3; i++)\n\t\t{\n\t\tif ((s[i][0] == s[i][1]) && (s[i][1] == s[i][2]) && (s[i][0] != '.')) win (s[i][0]); //stroka\n\t\tif ((s[0][i] == s[1][i]) && (s[1][i] == s[2][i]) && (s[0][i] != '.')) win (s[0][i]); //stolbec\n\t\t}\n\tif ((s[0][0] == s[1][1]) && (s[1][1] == s[2][2]) && (s[1][1] != '.')) win (s[1][1]); //diag 00 - 22\n\tif ((s[2][0] == s[1][1]) && (s[1][1] == s[0][2]) && (s[1][1] != '.')) win (s[1][1]); //diag 20 - 02\n //\tif (s[][] == s[][] == s[][] != \".\") win (s[][]);\n\t}\n\t\nvoid exist (char s[4][4])\n\t{\n\tint i, j;\n\tfor (i = 0; i < 3; i++)\n\t\tfor (j = 0; j < 3; j++)\n\t\t\tif (s[i][j] == 'X') x++;\n\t\t\telse if (s[i][j] == '0') y++;\n\tif ((x > y + 1) || (y > x)) wrong();\n\t}\n\nvoid step (char s[4][4])\n\t{\n\tif (x - y == 1)\n\t\t{\n\t\tif (x == 5) draw();\n\t\tprintf (\"%s\", \"second\");\n\t//getch();\n\t\texit (0);\n\t\t}\n\telse\n\t\t{\n printf (\"%d%s%d\\n\", x, \" \", y);\n\t\tprintf (\"%s\", \"first\");\n\tgetch();\n\t\texit (0);\n\t\t}\n\t}\n\t\nvoid main()\n\t{\n\tint i;\n\tchar s[4][4];\n\tfor (i = 0; i < 3; i++)\n\t\tscanf (\"%s\", s[i]);\n\texist (s);\n\tlines (s);\n\tstep (s);\n\t//getch();\n\t}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "51fd9f9e3c46f0ed1436fa3b97682162", "src_uid": "892680e26369325fb00d15543a96192c", "difficulty": 1800.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\n\nint main(){\n\tstring str;\n\tcin>>str;\n\tint len = str.length();\n\tint cnt = 0;\n\tstring a,b;\n\tif(str[0] != '1')\n\t\ta += str[cnt++] - 1;\n\twhile(cnt != len-1){\n\t\ta += '9';\n\t\t// b += str[cnt] - a[cnt];\n\t\tcnt ++;\n\t}\n\tif(str[0] != '1')\n\t\ta += '9';\n\tll n = atoll(str.c_str());\n\tll x = atoll(a.c_str());\n\tll y = n - x;\n\t// cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define MAXN 100001\n#define ll long long\n//cin.ignore (std::numeric_limits::max(), '\\n'); \nusing namespace std;\nll sd(ll x)\n{\n\tll s = 0;\n\twhile (x >= 10)\n\t{\n\t\ts += (x % 10);\n\t\tx /= 10;\n\t}\n\ts += x;\n\treturn s;\n}\nint main()\n{\n\tll n;\n\tcin >> n;\n\tstring str = to_string(n);\n\tstring first = str.substr(0, 1);\n\tif (first != \"1\")\n\t{\n\t\tstringstream conv(first);\n\t\tll x;\n\t\tconv >> x;\n\t\tx--;\n\t\tstring res = to_string(x);\n\t\tfor (int i = 0; i < str.size() - 1; i++)\n\t\t{\n\t\t\tres += \"9\";\n\t\t}\n\t\tstringstream con(res);\n\t\tll a;\n\t\tcon >> a;\n\t\tcout << sd(a) + sd(n - a);\n\t}\n\telse\n\t{\n\t\tstring res = \"4\";\n\t\tfor (int i = 0; i < str.size() - 2; i++)\n\t\t{\n\t\t\tres += \"9\";\n\t\t}\n\t\tstringstream con(res);\n\t\tll a;\n\t\tcon >> a;\n\t\tcout << sd(a) + sd(n - a);\n\t}\n\treturn 0;\n}\n\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "22b1645a04161f10067f3ca89d32a9ce", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "/*Made by Shivam Solanki*/\n#include\n#pragma GCC optimize (\"Ofast\")\nusing namespace std;\n#define DEBUG(x) cout << '>' << #x << ':' << x << endl;\n#define ll long long int\n#define endl '\\n'\ntypedef vector vi;\ntypedef vector vll;\ntypedef vector vvl;\ntypedef pair pii;\ntypedef pair pll;\ntypedef vector vvi;\ntypedef vector vb;\ntypedef vector vp;\ntypedef vector vpll;\ntypedef map mii;\ntypedef map mll;\ntypedef set sii;\ntypedef set sll;\ntypedef queue qii;\ntypedef priority_queue pq;\ntypedef unordered_map umii;\ntypedef unordered_map umll;\n#define all(x) x.begin(),x.end()\n#define rep(i,k,n) for (int i = k; i < n; ++i) \n#define repr(i,k,n) for (int i = n; i>=k; --i)\n#define repll(i,k,n) for (ll i = k; i < n; ++i) \n#define pb push_back\n#define mp make_pair\n#define gcd __gcd\n#define F first\n#define S second\n#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);\nconst int INF = 1e9+5;\nconst int MOD = 1e9+7;\ndouble pi = 2 * acos(0.0); \n\nvoid solve(){\n ll n;\n cin>>n;\n ll cpy=n;\n stack s;\n while(cpy){\n s.push(cpy%10);\n cpy/=10;\n }\n ll x=s.top();\n string l;\n if(x==1){\n x=6;\n l+=(x-1)+'0';\n rep(i,0,s.size()-2){\n l+='9';\n }\n }\n else{\n l+=(x-1)+'0';\n rep(i,0,s.size()-1){\n l+='9';\n }\n }\n ll a=stoll(l);\n ll b=n-a;\n ll ans=0;\n while(a){\n ans+=a%10;\n a/=10;\n }\n while(b){\n ans+=b%10;\n b/=10;\n }\n cout<>t;\n while(t--)\n solve();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "855f16387fbd7615c8ae7580c0b89e6f", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint sum(long long x){\n int sol = 0;\n while( x != 0 ){\n sol += x % 10;\n x /= 10;\n }\n return sol;\n}\n\n\nint main(){\n ios::sync_with_stdio(false);\n\n int n;\n\n cin >> n;\n\n vector a;\n vector b;\n\n int ka = 0;\n int kb = 0;\n\n bool ok ;\n\n if( n % 2 == 0 ){\n a.push_back(n/2);\n b.push_back(n/2);\n ok = 0;\n }else{\n a.push_back(n/2);\n b.push_back(0);\n b.push_back(n/2);\n a.push_back(n/2 + 1);\n ok = 1;\n }\n\n if( ok == 0){\n for( int i = 1; b[i - 1] >= 0; i++){\n a.push_back(a[i - 1] + 1);\n b.push_back(b[i - 1] - 1);\n }\n }else{\n for( int i = 2; b[i - 1] >= 0; i++){\n a.push_back(a[i - 1] + 1);\n b.push_back(b[i - 1] - 1);\n }\n }\n\n int maxx = 0;\n int aa, bb;\n for( int i = 0; i < a.size() && i < b.size(); i++){\n if( sum(a[i]) + sum(b[i]) > maxx ){\n maxx = sum(a[i]) + sum(b[i]);\n aa = a[i];\n bb = b[i];\n }\n }\n\n cout << maxx;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0da7ca5505e341224ce2b2a5a765a779", "src_uid": "5c61b4a4728070b9de49d72831cd2329", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n\tlong long int n,k,t;\n\t\n\tcin>>n>>k>>t;\n\tlong long int a[n+1];\n\tfor(long long int i=0;ik&&in)\n\t\t{\n\t\t\ta[i-k]=0;\n\t\t}\n\t}\n\tlong long int c=0;\n\tfor(long long int i=1;i<=n;i++)\n\t{\n\t\tif(a[i]==1)\n\t\tc++;\n\t}\n\t\n\tcout<\nusing namespace std;\nint main(){\n\tint i,j,n,k,t;\n\tint a[10000];\n\tcin>>n>>k>>t;\n\tint sin=0;\n\tfor(i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint main() {\n\tfreopen(\"input.txt\",\"r\",stdin);\n\tint n,k,t;\n\tcin >> n >> k >> t;\n\tif(t=k)&&(t<=n)){\n\t\tcout << k;\n\t}else{\n\t\tcout << n+k-t;\n\t}\n\tgetch();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f986316aa567fa114b41b9baa0749513", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint main() {\n\tfreopen(\"input.txt\",\"r\",stdin);\n\tint n,k,t;\n\tcin >> n >> k >> t;\n\tif(t=k)&&(t<=n)){\n\t\tcout << k;\n\t}else{\n\t\tcout << t-n+1;\n\t}\n\tgetch();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8aaf9936c2fe8719b2fef49cf7a9e188", "src_uid": "7e614526109a2052bfe7934381e7f6c2", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n\n#define pii pair\n#define mp make_pair\n\ntypedef long long ll;\n\nconst int N = 1005;\nconst int M = 12;\n\nll MOD;\nll dp[N][M][N];\n\ninline ll mypow(ll a, ll b)\n{\n\tll res = 1;\n\twhile (b)\n\t{\n\t\tif (b & 1)\n\t\t{\n\t\t\tres = ((ll)res * a) % MOD;\n\t\t}\n\t\ta = ((ll)a * a) % MOD;\n\t\tb >>= 1;\n\t}\n\t\n\treturn res;\n}\n\ninline ll cmb(ll a, ll b)\n{\n\tll d1, d2;\n\td1 = d2 = 1;\n\tif (a < b)\n\t{\n\t\treturn 0;\n\t}\n\twhile (b)\n\t{\n\t\td1 = (ll)d1 * a % MOD;\n\t\td2 *= b;\n\t\tb--;\n\t\ta--;\n\t}\n\t\n\treturn (ll)d1 * mypow(d2, MOD - 2) % MOD;\n}\n\nint main()\n{\n\tint n, d, i, j,k, l;\n\tscanf(\"%d%d%lld\", &n, &d, &MOD);\n\t\n\tif (n <= 2)\n\t{\n\t\tprintf(\"1\\n\");\n\t\treturn 0;\n\t}\n\t\n\n\tfor (k = 0; k <= n; k++)\n\t{\n\t\tdp[1][0][k] = 1;\n\t}\n\t\n\t\n\tfor (i = 2; i <= d + 1; i++)\n\t{\n\t\tfor (k = 1; k <= n; k++)\n\t\t{\n\t\t\tdp[i][i - 1][k] = 1;\n\t\t}\t\n\t}\n\t\n\tll tmp;\n\tfor (i = 3; i <= n; i++)\n\t{\n\t\tfor (j = 1; j <= d && j < i - 1; j++)\n\t\t{\n\t\t\tfor (k = 2; k <= n - 1; k++)\n\t\t\t{\n\t\t\t\tdp[i][j][k] = dp[i][j][k - 1];\n\t\t\t\tfor (l = 1; l <= j && l*k < i; l++)\n\t\t\t\t{\n\t\t\t\t\ttmp = (ll)dp[i - k*l][j - l][k - 1] * cmb(dp[k][d - 1][k - 1] + l - 1, l) % MOD;\n\t\t\t\t\tdp[i][j][k] = ((ll)dp[i][j][k] + tmp) % MOD;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tll ans = 0;\n\tans = dp[n][d][(n + 1) / 2 - 1];\n\tif ((n & 1) == 0)\n\t{\n\t\tans = ((ll)ans + cmb(dp[n / 2][d - 1][n / 2 - 1] + 1, 2)) % MOD;\n\t}\n\t\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ed33281b671a2e40059eef7ca819f92a", "src_uid": "bdd0fc1d6dbab5eeb5aea135fdfffc9d", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "#include\"bits/stdc++.h\"\n\nusing namespace std;\n\nint d;\nint num_leaf(int sz) {\n\tif (sz == 1) {\n\t\treturn 1;\n\t}\n\tif (sz == 2) {\n\t\treturn 1;\n\t}\n\tsz--;\n\tint cnt = d;\n\tsz -= d;\n\tif (sz < 0) {\n\t\treturn -1;\n\t}\n\twhile (sz) {\n\t\tif (sz < d-1) {\n\t\t\treturn -1;\n\t\t}\n\t\tsz -= (d - 1);\n\t\tcnt += (d - 1);\n\t\tcnt--;\n\t}\n\treturn cnt;\n}\n#define MAX 1002\nint lf[MAX];\nlong long int dp[MAX];\nbool us[MAX];\nlong long int tmp[MAX][MAX][11];\nlong long int tmp2[MAX][MAX][11];\n\nlong long int MOD;\n\nbool us2[MAX];\nlong long int dp2[MAX];\n\nlong long int ppow(long long int i, long long int j) {\n\tlong long int res = 1;\n\twhile (j) {\n\t\tif (j & 1LL) {\n\t\t\tres *= i;\n\t\t\tif (res >= MOD)res %= MOD;\n\t\t}\n\t\tj >>= 1LL;\n\t\ti *= i;\n\t\tif (i >= MOD)i %= MOD;\n\t}\n\treturn res;\n}\n\nlong long int sel(long long int val, int ch) {\n\tval += ch - 1;\n\tlong long int up = 1;\n\tlong long int dw = 1;\n\tfor (int j = 0; j < ch; j++) {\n\t\tup *= (val - j);\n\t\tif (up >= MOD)up %= MOD;\n\t\tdw *= (j + 1);\n\t\tif (dw >= MOD)dw %= MOD;\n\t}\n\tup *= ppow(dw, MOD - 2);\n\tif (up >= MOD)up %= MOD;\n\treturn up;\n}\n\nlong long int ww[MAX][11];\n\ninline long long int dfs2(int sz) {\n\tif (sz == 1) {\n\t\treturn 1;\n\t}\n\tif (us2[sz])return dp2[sz];\n\tus2[sz] = true;\n\tdp2[sz] = 0;\n\ttmp2[sz][0][0] = 1;\n\tint deg = d - 1;\n\tfor (int add = 1; add <= sz-1; add++) {\n\t\tlong long int way = dfs2(add);\n\t\tfor (int z = 0; z <= deg; z++) {\n\t\t\tww[sz][z] = sel(way, z);\n\t\t}\n\t\tfor (int j = sz-1-add; j>=0; j--) {\n\t\t\tfor (int k = deg-1; k>=0; k--) {\n\t\t\t\tlong long int bs = tmp2[sz][j][k];\n\t\t\t\tfor (int z = k + 1; z <= deg; z++) {\n\t\t\t\t\tif ((z - k)*add + j > sz - 1)break;\n\t\t\t\t\ttmp2[sz][(z - k)*add + j][z] += bs * ww[sz][z - k];// sel(way, z - k);\n\t\t\t\t\tif (tmp2[sz][(z - k)*add + j][z] > MOD) {\n\t\t\t\t\t\ttmp2[sz][(z - k)*add + j][z] %= MOD;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tdp2[sz] = tmp2[sz][sz - 1][deg];\n\treturn dp2[sz];\n}\n\ninline long long int dfs(int sz) {\n\tif (sz <= 1) {\n\t\treturn 1;\n\t}\n\tif (us[sz])return dp[sz];\n\tus[sz] = true;\n\tint maxi = (sz-1) / 2;\n\ttmp[sz][0][0] = 1;\n\tfor (int add = 1; add <= maxi; add++) {\n\t\tfor (int j = sz-1-add; j>=0; j--) {\n\t\t\tfor (int k = d-1; k>= 0; k--) {\n\t\t\t\tlong long int bs = tmp[sz][j][k];\n\t\t\t\tlong long int way = dfs2(add);\n\t\t\t\tfor (int z = k + 1; z <= d; z++) {\n\t\t\t\t\tif ((z - k)*add + j > sz - 1)break;\n\t\t\t\t\ttmp[sz][(z - k)*add + j][z] += bs * sel(way, z - k);\n\t\t\t\t\tif (tmp[sz][(z - k)*add + j][z] > MOD) {\n\t\t\t\t\t\ttmp[sz][(z - k)*add + j][z] %= MOD;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tdp[sz] = tmp[sz][sz-1][d];\n\treturn dp[sz];\n}\n\n\n\nint main() {\n\tint n;\n\tcin >> n >> d >> MOD;\n\tfor (int i = 0; i < MAX; i++) {\n\t\tlf[i] = num_leaf(i);\n\t}\n\tlong long int ans = dfs(n);\n\tif (n % 2 == 0) {\n\t\tlong long int ans2 = dfs2(n / 2);\n\t\tans += sel(ans2, 2);\n\t\tif (ans >= MOD)ans %= MOD;\n\t}\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "26028b89d8f88655ecf1779d6170a335", "src_uid": "bdd0fc1d6dbab5eeb5aea135fdfffc9d", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\nint n,m;\nll P;\nll ine[1010];\nint f[1010][11][1010];\nll DP(int n,int d,int k)\n{\n\tk=min(k,n-1);\n\tif(f[n][d][k]!=-1)\treturn f[n][d][k];\n\tif((n==1&&d==m-1)||(n==1&&!d))\treturn 1;\n\tif(n==1)\treturn 0;\n\tint i,j;\n\tll ret=0;\n\tfor(i=1;i<=k;i++)\n\t{\n\t\tll t=DP(i,m-1,k),tmp=1;\n\t\tfor(j=1;j*i\n#include \n\nusing namespace std;\n\ntypedef unsigned uint;\ntypedef long long lint;\ntypedef unsigned long long ulint;\ntypedef long double ldouble;\ntypedef complex point;\n\nconst double E = 1e-9, pi = 2*acos(0);\nconst ldouble PI = 3.1415926535897932384626433832795029L;\n\nint MOD;\n\nlint modpow(lint a, lint b) {\n\tlint ans=1;\n\twhile (b) {\n\t\tif (b%2) ans=ans*a%MOD;\n\t\ta=a*a%MOD;\n\t\tb/=2;\n\t}\n\treturn ans;\n}\n\nbool solve(int testNumber) {\n\tint n, d;\n\tif (!~scanf(\"%d %d %d\", &n, &d, &MOD)) return false;\n\tvector > > dp(n+1, vector >(d+1, vector(n+1)));\n\tvector inv(d+1);\n\tinv[0]=1;\n\tfor (int i=1; i<=d; i++) inv[i]=modpow(i, MOD-2);\n\tdp[0][0]=vector(n+1, 1);\n\tfor (int i=0; i<=n; i++) for (int j=0; j<=d; j++) for (int k=0; k<=n; k++) {\n\t\tlint &ans=dp[i][j][k];\n\t\tif (!i) ans=!j;\n\t\telse if (!j) ans=i<=1;\n\t\telse if (!k) ans=0;\n\t\telse {\n\t\t\tans=dp[i][j][k-1];\n\t\t\tlint aux=1;\n\t\t\tfor (int l=1; l*k\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define ll long long\n#define rt return\n#define all(a) a.begin(), a.end()\n#define mp make_pair\n#define pb push_back\n#define ld long double\n#define gg std::ios::sync_with_stdio(false)\n\n#define X first\n#define Y second\n\n#define rep(n, i) for (int i = 0; i < n; ++i)\n#define per(n, i) for (int i = n - 1; i >= 0; --i)\n\n#define pii pair\n\nconst int MAX_SIZE = 1e5 + 10, INF = 2 * 1e9;\nconst int SIZE=1e9;\nconst long long LINF = 1e18, N = 59778;\nconst double eps = 1e-6, PI = 20 / 7;\n\nvoid files() {\n\tfreopen(\"input.txt\", \" r\", stdin);\n\t//freopen(\"output.txt\", \"w\", stdout);\n}\n\n\nbool isprime[SIZE];\nint main() {\n\tgg;\n\t//files();\n\tcin.tie(0);\n\tll a, b, c, d, e, f;\n\tcin >> a >> b >> c >> d >> e >> f;\n\tb = min(b, c);\n\tif (e > f) {\n\t\tcout << min(a, d) * e + min(max(d - min(a, d), ll(0)), b) * f;\n\t}\n\telse {\n\t\tcout << min(b, d) * f + min(max(d - min(b, d), ll(0)), a) * e;\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a4aef9703c4c3164120f8d7414b3cb4c", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n long long int a , b , c , d , e , f , ans =0 ;\n cin>>a>>b>>c>>d>>e>>f ;\n if(f>e){\n ans+=min(d,min(b,c))*f ;\n d-=min(d,min(b,c)) ;\n if(d>0){\n ans+=min(d,a)*e ;\n }\n cout<f) {\n ans+=min(a,d)*e ;\n d-=min(d,a) ;\n ans+=min(d,min(b,c))*f ;\n cout<\nusing namespace std;\n\nint main()\n{\n long long a,b,c,d,c1,c2;\n cin>>a>>b>>c>>d>>c1>>c2;\n\n long long mx=0;\n\n long long mn=min(a,d);\n long long mn2=min(b,mn-d);\n mn2=min(mn2,c);\n long long sum=(mn*c1)+(c2*mn2);\n\n long long mn1=min(b,c);\n mn1=min(mn1,d);\n long long mn3=min(abs(mn1-d),d);\n\n long long sum1=(mn1*c2)+(c1*min(a,mn3));\n\n mx=max(sum,sum1);\n\n cout<\n\nusing namespace std;\n\nint main()\n{\n\tint a, b, c, d, e, f;\n\tcin >> a >> b >> c >> d;\n\tcin >> e >> f;\n\tint n = 0, m = 0;\n\tif(f > e){\n\t\tn += (min(b, min(c, d)) * f);\n\t\tif((d - min(b, min(c, d))) >= 0)\n\t\t\tm += (min((d - min(b, min(c, d))), a) * e);\n\t}\n\telse if(e > f){\n\t\tn += (min(a, d) * e);\n\t\tif(d - min(a, d) >= 0)\n\t\tm += (min((d - min(a, d)), min(b, c)) * f);\n\t}\n\telse if(e == f){\n\t\tcout << min(max(a, min(b, min(c, d))), d) * e;\n\t\treturn 0;\n\t}\n\tcout << m + n;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3f916b83efa28b78776765fcc22ace3d", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n //freopen(\"input.txt\",\"r\",stdin);\n //freopen(\"output.txt\",\"w\",stdout);\n char chx1,chx2;\n int ans=0,y1,y2,x1=0,x2=0,a[101][101];\n cin>>chx1>>y1;\n cin>>chx2>>y2;\n x1=int(chx1-96); \n x2=int(chx2-96);\n a[x1][y1]=1;\n a[x2][y2]=1;\n for(int i=1;i<=8;i++)\n {\n for(int j=1;j<=8;j++)\n {\n if(x1==i || y1==j) a[i][j]=1;\n if((max(x2,i)-min(x2,i))*(max(y2,j)-min(y2,j))==2) {a[i][j]=1;}\n if((max(x1,i)-min(x1,i))*(max(y1,j)-min(y1,j))==2) {a[i][j]=1;}\n }\n }\n for(int i=1;i<=8;i++)\n {\n for(int j=1;j<=8;j++)\n {\n if(a[i][j]!=1) ans++;\n }\n } \n //fclose(stdin);fclose(stdout);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4d9c8c6627f8fe91bd74840bba9b861e", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define REP(i,N)for(int i=0;i<(int)N;i++)\n#define MP(a,b) make_pair(a,b)\nusing namespace std;\n\nint nextInt(){\n int ret=0,sign=1;\n char c=' ';\n while (!isdigit(c=getchar())){\n if (c==EOF) return -1;\n if (c=='-') sign=-1;\n }\n do{\n ret=ret*10+(c-'0');\n }while (isdigit(c=getchar()));\n return ret*sign;\n}\nvoid printlineInt(int num){\n char str[101];\n if (num<0) num=-num,putchar('-');\n else if (num==0) {puts(\"0\");return;}\n str[100]='\\0';\n int i=99;\n for (;num;i--){\n str[i]=num%10+'0';\n num/=10;\n }\n puts(&str[i+1]);\n return;\n}\n//template end\n\nint cost[1001], dmg[1001];\n\nint main(){\n int N, pow, reg;\n while (cin >> N >> pow >> reg) {\n REP(i, N) {\n cin >> cost[i] >> dmg[i];\n }\n int maxpow = pow;\n int turn = 0;\n bool used[1001] = {};\n vector > hist;\n int dm = 0;\n used[0] = true, dm = dmg[0];\n REP(tt, 100000){\n // dmg\n pow -= dm;\n\n // reg\n pow += reg;\n if (pow > maxpow) pow = maxpow;\n // judge\n if (pow <= 0) break;\n // select\n int d = 0;\n int idx = -1;\n REP(i, N){\n if (cost[i] >= (pow * 100 / maxpow)&& !used[i] &&\n d < dmg[i]) d = max(d, dmg[i]), idx = i;\n }\n if (idx != -1){\n used[idx] = true;\n hist.push_back(MP(turn, idx));\n dm += d;\n }\n turn++;\n }\n if (pow <= 0){\n cout << \"YES\" << endl;\n cout << turn+1 << \" \" << hist.size() << endl;\n REP(i, hist.size()){\n cout << hist[i].first+1 << \" \"<< hist[i].second+1 << endl;\n }\n }else{\n cout << \"NO\" << endl;\n }\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3872fa5a0ce6f11b07fcd8888472836c", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define REP(i,N)for(int i=0;i<(int)N;i++)\n#define MP(a,b) make_pair(a,b)\nusing namespace std;\n\nint nextInt(){\n int ret=0,sign=1;\n char c=' ';\n while (!isdigit(c=getchar())){\n if (c==EOF) return -1;\n if (c=='-') sign=-1;\n }\n do{\n ret=ret*10+(c-'0');\n }while (isdigit(c=getchar()));\n return ret*sign;\n}\nvoid printlineInt(int num){\n char str[101];\n if (num<0) num=-num,putchar('-');\n else if (num==0) {puts(\"0\");return;}\n str[100]='\\0';\n int i=99;\n for (;num;i--){\n str[i]=num%10+'0';\n num/=10;\n }\n puts(&str[i+1]);\n return;\n}\n//template end\n\nint cost[1001], dmg[1001];\n\nint main(){\n int N, pow, reg;\n while (cin >> N >> pow >> reg) {\n REP(i, N) {\n cin >> cost[i] >> dmg[i];\n }\n int maxpow = pow;\n int turn = 0;\n bool used[1001] = {};\n vector > hist;\n int dm = 0;\n used[0] = true, dm = dmg[0];\n REP(tt, 100000){\n // dmg\n pow -= dm;\n\n // reg\n pow += reg;\n if (pow > maxpow) pow = maxpow;\n // judge\n if (pow <= 0) break;\n // select\n int d = 0;\n int idx = -1;\n REP(i, N){\n if (cost[i] >= (pow * 100 / maxpow)&& !used[i] &&\n d < dmg[i]) d = max(d, dmg[i]), idx = i;\n }\n if (idx != -1){\n used[idx] = true;\n hist.push_back(MP(turn, idx));\n dm += d;\n }\n turn++;\n }\n if (pow <= 0){\n cout << \"YES\" << endl;\n cout << turn+1 << \" \" << hist.size() << endl;\n REP(i, hist.size()){\n cout << hist[i].first+1 << \" \"<< hist[i].second+1 << endl;\n }\n }else{\n cout << \"NO\" << endl;\n }\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fec4ad3fad86f13fd8b307273935552e", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define REP(i,N)for(int i=0;i<(int)N;i++)\n#define MP(a,b) make_pair(a,b)\nusing namespace std;\n\nint nextInt(){\n int ret=0,sign=1;\n char c=' ';\n while (!isdigit(c=getchar())){\n if (c==EOF) return -1;\n if (c=='-') sign=-1;\n }\n do{\n ret=ret*10+(c-'0');\n }while (isdigit(c=getchar()));\n return ret*sign;\n}\nvoid printlineInt(int num){\n char str[101];\n if (num<0) num=-num,putchar('-');\n else if (num==0) {puts(\"0\");return;}\n str[100]='\\0';\n int i=99;\n for (;num;i--){\n str[i]=num%10+'0';\n num/=10;\n }\n puts(&str[i+1]);\n return;\n}\n//template end\n\nint cost[1001], dmg[1001];\n\nint main(){\n int N, pow, reg;\n while (cin >> N >> pow >> reg) {\n REP(i, N) {\n cin >> cost[i] >> dmg[i];\n }\n int maxpow = pow;\n int turn = 0;\n bool used[1001] = {};\n vector > hist;\n int dm = 0;\n used[0] = true, dm = dmg[0];\n REP(tt, 100000){\n // dmg\n pow -= dm;\n\n // reg\n pow += reg;\n if (pow > maxpow) pow = maxpow;\n // judge\n if (pow <= 0) break;\n // select\n int d = 0;\n int idx = -1;\n REP(i, N){\n if (cost[i] >= (pow * 100 / maxpow)&& !used[i] &&\n d < dmg[i]) d = max(d, dmg[i]), idx = i;\n }\n if (idx != -1){\n used[idx] = true;\n hist.push_back(MP(turn, idx));\n dm += d;\n }\n turn++;\n }\n if (pow <= 0){\n cout << \"YES\" << endl;\n cout << turn+1 << \" \" << hist.size() << endl;\n REP(i, hist.size()){\n cout << hist[i].first+1 << \" \"<< hist[i].second+1 << endl;\n }\n }else{\n cout << \"NO\" << endl;\n }\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d634a0fe1cb3f6c5eae9aa0a5047ce9e", "src_uid": "073023c6b72ce923df2afd6130719cfc", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\ntypedef long long ll;\n\nconst int N = 1e6 + 10;\nconst ll mod = 1e9 + 7;\nint par[N];\n\nint root(int v){return par[v] < 0? v:(par[v] = root(par[v]));}\nint dsu_cnt;\nvoid merge(int x, int y)\n{\n x= root(x);\n y = root(y);\n if(x == y)\n return;\n if(par[x]>par[y])\n swap(x, y);\n par[y] = x;\n par[x] += par[y];\n dsu_cnt--;\n}\n\nint main()\n{\n memset(par,-1, sizeof par);\n int p,k;\n scanf(\"%d %d\",&p,&k);\n dsu_cnt=p-1;\n for(int i=1;i\n#include \n#include \n\nconst uint64_t kModulo = 1000000000 + 7;\n\nint main()\n{\n uint64_t p, k;\n std::cin >> p >> k;\n\n std::vector visited(p);\n std::vector pows;\n\n uint64_t r = 1;\n pows.push_back(r);\n do\n {\n r = (r * k) % p;\n if (r == 1)\n break;\n pows.push_back(r);\n } while (true);\n\n uint64_t result = (k == 0 ? p : 1);\n visited[0] = true;\n\n for (uint64_t i = 1; i < p; ++i)\n {\n if (visited[i])\n continue;\n\n size_t j = 0;\n for (j = 0; j + 4 < pows.size(); ++j)\n {\n visited[(i * pows[j + 0]) % p] = true;\n visited[(i * pows[j + 1]) % p] = true;\n visited[(i * pows[j + 2]) % p] = true;\n visited[(i * pows[j + 3]) % p] = true;\n }\n for (; j < pows.size(); ++j)\n visited[(i * pows[j]) % p] = true;\n\n result = (result * p) % kModulo;\n }\n\n std::cout << result << std::endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bbc63b1cafbd186daa57df2139fd2302", "src_uid": "580bf65af24fb7f08250ddbc4ca67e0e", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define INF 1000000007\nusing namespace std;\ntypedef long long s64;\ntypedef unsigned long long u64;\nint k,p;\nint main() {\n\tios_base::sync_with_stdio(false);\n\tcin >> p >> k;\n\tif (k==1) {\n\t\tint t=1;\n\t\tfor (int i=0; i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define fr(a,b,c) for(int (a) = (b); (a) < (c); ++(a))\n#define rp(a,b) fr(a,0,b)\n#define cl(a,b) memset((a), (b), sizeof(a))\n#define sc(a) scanf(\"%d\", &a)\n#define sc2(a,b) scanf(\"%d%d\", &a, &b)\n#define sc3(a,b,c) scanf(\"%d%d%d\", &a, &b, &c)\n#define scs(s) scanf(\"%s\", s)\n#define pri(x) printf(\"%d\\n\", x)\n#define fre(a,b) for(int a = adj[b]; ~a; a = ant[a])\n\n#define iter(a) __typeof((a).begin())\n#define fore(a,b) for(iter(b) a = (b).begin(); a != (b).end(); ++a)\n\n#define st first\n#define nd second\n#define mp make_pair\n#define pb push_back\n\n#define db(x) cerr << #x << \" == \" << x << endl\n#define _ << \", \" <<\n\ntypedef pair pii;\ntypedef long long ll;\ntypedef vector vi;\n\nbool mark[1000100];\n#define mod 1000000007LL\n\nll expo(ll a, ll b) {\n ll r = 1;\n for (; b; b>>=1, a=(a*a)%mod) if (b&1) r = (r*a)%mod;\n return r;\n}\n\nint main() {\n int p, k;\n sc2(p,k);\n if (k == 0) {\n printf(\"%lld\\n\", expo(p, p-1));\n return 0;\n } else if (k == 1) {\n printf(\"%lld\\n\", expo(p, p));\n return 0;\n }\n cl(mark,0);\n int cnt = 0;\n fr(i,1,p) if (!mark[i]) {\n int u = i;\n do {\n mark[u] = 1;\n u = (u*k)%p;\n } while (!mark[u]);\n cnt++;\n }\n printf(\"%lld\\n\", expo(p, cnt));\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "36f3807b47bd69db5c41a3d535fe5644", "src_uid": "580bf65af24fb7f08250ddbc4ca67e0e", "difficulty": 1800.0} {"lang": "GNU C++17 Diagnostics", "source_code": "#include \nusing namespace std;\nbool def(string s,string t)\n{\n\tif(s==\"rock\"&&t==\"scissors\")\treturn true;\n\telse if(s==\"scissors\"&&t==\"paper\")\treturn true;\n\telse if(s==\"paper\"&&t==\"rock\")\treturn true;\n}\nchar winner(string s,string t,string q)\n{\n\tif(t==q&&def(s,t))\treturn 'F';\n\tif(s==q&&def(t,q))\treturn 'M';\n\tif(s==t&&def(q,s))\treturn 'S';\n\treturn '?';\n}\nstring gest[3];\nint main()\n{\n\tfor(int i=0;i<3;i++)\n\t{\n\t\tcin>>gest[i];\n\t}\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define black 0\n#define white 1\n#define tru -1\n#define fals -2\n#define array 1000000\nusing namespace std;\n\nint main()\n{\n int i, j ,Case=0, Cases, s, p, r;\n char res[3] = {'F','M','S'};\n char a[10][10];\n while(scanf(\"%s %s %s\",a[0],a[1],a[2])){\n p = r = s = 0;\n for(i=0; i<3; i++){\n if(a[i][0] == 's') s++;\n else if(a[i][0] == 'p') p++;\n else if(a[i][0] == 'r') r++;\n }\n //printf(\"%d %d %d\\n\",s,p,r);\n if(p==2 && s == 1){\n for(i=0;i<3;i++)\n if(a[i][0]=='s'){\n cout<\n#include \n#include \n#include \nchar f[8],m[8],s[8];\nint ml,fl,sl;\nint main(){\n scanf(\"%s\",&f);\n scanf(\"%s\",&m);\n scanf(\"%s\",&s);\nfl=strlen(f);\nml=strlen(m);\nsl=strlen(s);\n\nif(((fl==4)&&(ml==4)&&(sl==5))||((fl==5)&&(ml==5)&&(sl==8))||((fl==8)&&(ml==8)&&(sl==4)))\n{printf(\"S\");}\nelse\nif(((fl==4)&&(ml==5)&&(sl==4))||((fl==5)&&(ml==8)&&(sl==5))||((fl==8)&&(ml==4)&&(sl==8)))\n{printf(\"M\");}\nelse\nif(((fl==5)&&(ml==4)&&(sl==4))||((fl==8)&&(ml==5)&&(sl==5))||((fl==4)&&(ml==8)&&(sl==8)))\n{printf(\"F\");}\nelse\n{printf(\"?\");}\n getch();\nreturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "11f3f114efac2029cc8aa52bc03cc21e", "src_uid": "072c7d29a1b338609a72ab6b73988282", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main(){\n char m[9],f[9],s[9];\n scanf(\"%s %s %s\",f,m,s);\n if(((strcmp(f,m)!=0)&&(strcmp(m,s)!=0)&&(strcmp(f,s)!=0))||((strcmp(f,m)==0)&&(strcmp(m,s)==0)&&(strcmp(f,s)==0))) cout<<\"?\"<\n#define lli long long int\n#define PI acos(-1.0)\nusing namespace std;\nint b[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};\n\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(0);\n\tcout.tie(0);\n\t\n\tint n;\n\t\n\tcin >> n;\n\tint a[n+5];\n\t\n\tfor(int i = 0; i < n; i++){\n\t\tcin >> a[i];\n\t}\n\tint c = 0;\n\tif(n == 1) cout << \"YES\" << endl;\n\telse{\n\t\tfor(int i = 0; i < n; i++){\n\t\t\t\n\t\t\tif(a[i] == 28 || a[i] == 29){\n\t\t\t\tif(a[i+1] != 31 && i != n-1){\n\t\t\t\t\tc = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if(a[i] == 30){\n\t\t\t\tif(a[i+1] != 31 && i != n-1){\n\t\t\t\t\tc = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(c == 1) cout << \"NO\" << endl;\n\t\telse cout << \"YES\" << endl;\n\t}\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cc46ed81e760014d3d1b13bf6b505dad", "src_uid": "d60c8895cebcc5d0c6459238edbdb945", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n// 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31\n\nint main()\n{\n int n, t; std::cin >> n;\n int arr[24] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};\n std::vector v;\n std::vector a;\n for(int i=0; i<24; ++i) a.push_back(arr[i]);\n for(int i=0; i> t; t = (t==29?28:t);\n v.push_back(t);\n }\n if(std::search(a.begin(),a.end(),v.begin(),v.end())!=a.end()) std::cout << \"YES\\n\";\n else std::cout << \"NO\\n\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ed375e3be09a68fa9c6698041ac867c3", "src_uid": "d60c8895cebcc5d0c6459238edbdb945", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include\n#include\nusing namespace std;\nint main()\n{\n\tint i,n,k,j,tmp=0,chck=0;\n\tcin>>n;\n\tint p[24]={31,28,31,30,31,30,31,31,30,31,30,31,31,29,31,30,31,30,31,31,30,31,30,31};\n\t//int q[24]={31,29,31,30,31,30,31,31,30,31,30,31,31,28,31,30,31,30,31,31,30,31,30,31};\n\tvector a;\n\tfor(i=0;i>k;\n\t\ta.push_back(k);\n\t}\n\tfor(i=0;i<24;i++)\n\t{\n\t\ttmp=0;\n\t\tfor(j=0;j\nusing namespace std;\n#pragma GCC diagnostic ignored \"-Wunused-result\"\n\n/*------------------------------------------------------------------------*/\n\n#define iOS ios_base::sync_with_stdio(false); cin.tie(NULL)\n#define For(i,a,b) for((i)=(a);(i)<(b);++(i))\n#define Fore(i,a,b) for((i)=(a);(i)<=(b);++(i))\n#define rof(i,a,b) for((i)=(a);(i)>=(b);--(i))\n#define Fors(i,s) for((i)=s.begin();i!=s.end();i++)\n#define Form(i,m) for((i)=m.begin();i!=m.end();i++)\n#define inf (long long)4e18\n#define xx first\n#define yy second\n#define pb push_back\n#define PB pop_back()\n#define mp make_pair\n#define mod 1000000007\n#define pi 3.1428571\n#define sqr(a) (((a) * (a)))\n#define L(x) ((x)<<1)\n#define R(x) (((x)<<1)+1)\n#define endl \"\\n\"\n#define ub(a,e) upper_bond(a.begin(),a.end(),e)\n#define lb(a,e) lower_bond(a.begin(),a.end(),e)\n#define sortv(a) sort(a.begin(),a.end())\n#define sortr(a) sort(a.rbegin(),a.rend())\n#define accu(a,e) accumulate(a.begin(),a.end(),e)\n\n/*---------------------------------------------------------------------------*/\n\ntypedef long long ll;\ntypedef vector< pair >vect;\ntypedef pair pa;\ntypedef vector vi;\ntypedef vector vs;\ntypedef map ms;\ntypedef map ml;\ntypedef priority_queue pq;\ntypedef unsigned long long ull;\ntypedef long double ld;\n\n/*---------------------------------------------------------------------------*/\n\nll gcd(ll a, ll b)\n{\n\tif(b == 0)\n\t{\n\t\treturn a;\n\t}\n\treturn gcd(b, a%b);\n}\nll lcm(ll a, ll b)\n{\n\treturn ((a*b)/gcd(a,b));\n}\n\n/*----------------------------------------------------------------------------*/\n//Variables and functions for graph\n//Undirected graph\n \n/*vi adj[1000000];\nbool visited[1000000]={false};\nvoid add_edge(ll a,ll b)\n{\n adj[a].pb(b);\n adj[b].pb(a);\n}\n/*-----------------------------------------------------------------------------*/\n\n//end of template.\n\nll i,j,n,t;\n\nint main()\n{\n \tiOS;\n \tcin>>n;\n \tint f=0;\n \tstring a=\"312931303130313130313031\";\n \tstring b=\"312831303130313130313031\";\n \ti=0;\n \twhile(i<=25)\n \ta+=a,i++;\n \twhile(i>=0)\n \tb+=b,i--;\n \tstring ans=\"\";\n \tFor(i,0,n)\n \t{\n \t\tstring c;\n \t\tcin>>c;\n \t\tans+=c;\n\t }\n\t For(i,0,a.size())\n\t {\n\t \tstring d=a.substr(i,2*n);\n\t \tif(d==ans)\n\t \t{\n\t\tcout<<\"YES\";\n\t\treturn 0;\n\t\t}\n\t }\n\t For(i,0,b.size())\n\t {\n\t \tstring d=b.substr(i,2*n);\n\t \tif(d==ans)\n\t \t{\n\t \tcout<<\"YES\";\n\t\treturn 0;\n\t\t}\n\t }\n\t cout<<\"NO\";\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "17625dc79b02459e90b04f3db1238523", "src_uid": "d60c8895cebcc5d0c6459238edbdb945", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#define maxn 100\n#define Task \"\"\n#define vt vector\n#define pb push_back\n#define pii pair \n#define mp make_pair\n#define F first\n#define S second\n#define ll long long\n#define mod 1000000007\n\nusing namespace std;\nint n = 10;\nchar a[maxn][maxn];\nvoid nhap()\n{\n for (int i = 1; i <= 10; i++)\n for (int j = 1; j <= n; j++)\n cin >> a[i][j];\n}\n\nbool check (char x)\n{\n int res = 0;\n for (int i = 1; i <= n; i++)\n for (int j = 1; j <= n-4; j++)\n if (a[i][j] == x)\n {\n int ok = 1;\n for (int k = j; k <= j+4; k++)\n if (a[i][k] != x) {ok = 0;break;}\n res += ok;\n if (i <= n - 4)\n {\n ok = 1;\n for (int k = 0; k <= 4; k++)\n if (a[i+k][j+k] != x) {ok = 0; break;}\n res += ok;\n ok = 1;\n for (int k = i; k <= i+4; k++)\n if (a[k][j] != x) {ok = 0;break;}\n res += ok;\n }\n if (i > 4)\n {\n ok = 1;\n for (int k = 0; k <= 4; k++)\n if (a[i-k][j=k] != x) {ok = 0;break;}\n }\n }\n return res != 0;\n}\n\nvoid solve()\n{\n if (check('O')) {\n cout << \"NO\";\n return;\n }\n for (int i = 1; i <= n; i++)\n for (int j = 1; j <= n; j++)\n if (a[i][j] == '.')\n {\n a[i][j] = 'X';\n if (check('X')) {cout << \"YES\"; return;}\n a[i][j] = '.';\n }\n cout << \"NO\";\n}\n\nint main()\n{\n nhap();\n solve();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b204ce5ba51d760c2df02eaa3d21fc0e", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \n#define maxn 100\n#define Task \"\"\n#define vt vector\n#define pb push_back\n#define pii pair \n#define mp make_pair\n#define F first\n#define S second\n#define ll long long\n#define mod 1000000007\n\nusing namespace std;\nint n = 10;\nchar a[maxn][maxn];\nvoid nhap()\n{\n for (int i = 1; i <= 10; i++)\n for (int j = 1; j <= n; j++)\n cin >> a[i][j];\n}\n\nbool check (char x)\n{\n int res = 0;\n for (int i = 1; i <= n; i++)\n for (int j = 1; j <= n-4; j++)\n if (a[i][j] == x)\n {\n int ok = 1;\n for (int k = j; k <= j+4; k++)\n if (a[i][k] != x) ok = 0;\n res += ok;\n if (i <= n - 4)\n {\n ok = 1;\n for (int k = 0; k <= 4; k++)\n if (a[i+k][j+k] != x) ok = 0;\n res += ok;\n ok = 1;\n for (int k = i; k <= i+4; k++)\n if (a[k][j] != x) ok = 0;\n res += ok;\n }\n if (i > 4)\n {\n ok = 1;\n for (int k = 0; k <= 4; k++)\n if (a[i-k][j=k] != x) ok = 0;\n }\n }\n return res != 0;\n}\n\nvoid solve()\n{\n if (check('O')) {\n cout << \"NO\";\n return;\n }\n for (int i = 1; i <= n; i++)\n for (int j = 1; j <= n; j++)\n if (a[i][j] == '.')\n {\n a[i][j] = 'X';\n if (check('X')) {cout << \"YES\"; return;}\n a[i][j] = '.';\n }\n cout << \"NO\";\n}\n\nint main()\n{\n nhap();\n solve();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2ebe87da94533f65280695ccd1c8bb69", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nchar t[15][15];\nint dx[] = {1,1,1,-1,-1,-1,0,0};\nint dy[] = {-1,0,1,-1,0,1,-1,1};\nint mx;\n\nbool isValid(int row, int col) {\n if (row >= 0 && row < 10 && col >= 0 && col < 10) {\n return true;\n } else {\n return false;\n }\n}\n\nvoid dfsCheck(int r,int c,int len,int rPar,int cPar) {\n mx = max(mx, len);\n for (int i = 0; i < 8; i++) {\n int nextRow = r + dx[i];\n int nextCol = c + dy[i];\n if (isValid(nextRow, nextCol)) {\n if (t[nextRow][nextCol] == 'X' && (nextRow != rPar || nextCol != cPar)) {\n dfsCheck(nextRow, nextCol, len + 1, r, c);\n }\n }\n }\n}\n\nvoid testCell(int row,int col) {\n bool changed = 0;\n if (t[row][col] == '.') {\n t[row][col] = 'X';\n changed = 1;\n }\n dfsCheck(row, col, 1, row,col);\n if (changed) {\n t[row][col] = '.';\n }\n}\n\nint main() {\n for (int i = 0; i < 10; i++) {\n for (int j = 0; j < 10; j++) {\n cin >> t[i][j];\n }\n }\n for (int i = 0; i < 10; i++) {\n for (int j = 0; j < 10; j++) {\n if (t[i][j] != 'O') {\n testCell(i, j);\n }\n }\n }\n puts(mx >= 5 ? \"YES\" : \"NO\");\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0e3b841183c0ea901eb1bc8af9a2e6c1", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nchar t[15][15];\nint dx[] = {1,1,1,-1,-1,-1,0,0};\nint dy[] = {-1,0,1,-1,0,1,-1,1};\nint mx;\n\nbool isValid(int row, int col) {\n if (row >= 0 && row < 10 && col >= 0 && col < 10) {\n return true;\n } else {\n return false;\n }\n}\n\nvoid dfsCheck(int r,int c,int len) {\n mx = max(mx, len);\n for (int i = 0; i < 8; i++) {\n int nextRow = r + dx[i];\n int nextCol = c + dy[i];\n if (isValid(nextRow, nextCol)) {\n if (t[nextRow][nextCol] == 'X') {\n dfsCheck(nextRow, nextCol, len + 1);\n }\n }\n }\n}\n\nvoid testCell(int row,int col) {\n bool changed = 0;\n if (t[row][col] == '.') {\n t[row][col] = 'X';\n changed = 1;\n }\n dfsCheck(row, col, 1);\n if (changed) {\n t[row][col] = '.';\n }\n}\n\nint main() {\n for (int i = 0; i < 10; i++) {\n for (int j = 0; j < 10; j++) {\n cin >> t[i][j];\n }\n }\n for (int i = 0; i < 10; i++) {\n for (int j = 0; j < 10; j++) {\n if (t[i][j] != 'O') {\n testCell(i, j);\n }\n }\n }\n puts(mx >= 5 ? \"YES\" : \"NO\");\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2581fd27463d3e9a5691a66e7809335d", "src_uid": "d5541028a2753c758322c440bdbf9ec6", "difficulty": 1600.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \nusing namespace std; \n#pragma warning(disable:4996)\n\nint a,b;\nint a2,a3,a5,b2,b3,b5;\nint r;\n\nint main() {\n\t#ifndef ONLINE_JUDGE\n\t\tfreopen(\"input.txt\",\"rt\",stdin);\n\t\t//freopen(\"output.txt\",\"wt\",stdout);\n\t#endif\n \n\tcin>>a >>b;\n\tif (a==b) { cout<<0; return 0;}\n\n\twhile (a%2==0) { a2++; a/=2; }\n\twhile (a%3==0) { a3++; a/=3; }\n\twhile (a%5==0) { a5++; a/=5; }\n\n\twhile (b%2==0) { b2++; b/=2; }\n\twhile (b%3==0) { b3++; b/=3; }\n\twhile (b%5==0) { b5++; b/=5; }\n\n\tif (a>1 || b>1) { cout<<\"-1\"; return 0; }\n\t\n\tr = abs(a2-b2) + abs(a3-b3) + abs(a5-b5);\n\tcout<\n#include\n#include\n#include\nint gcd(int a,int b)//\u6700\u5927\u516c\u7ea6\u6570\n{\n if (a\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define _G getch()\n#define ll long long\n#define pb push_back\n#define rep(x,st,ed) for(x=st;xed;i--)\n#define C cin>>\n#define _C cout<<\n#define Ln <<\"\\n\"\nusing namespace std;\nmap p3a,jbs;\n int ar[3]={2,3,5};\n vectorv,v1;\nvoid divi(int x,int steps,int flag)\n{ int i;\n //cout<steps)\n p3a[x]=steps;\n \n }\n if(flag==1)\n { if(jbs[x]>steps)\n jbs[x]=steps;\n \n }\n \n }\n if(p3a.find(x)!=p3a.end()&&jbs.find(x)!=jbs.end()&&find(v.begin(),v.end(),x)==v.end())\n v.pb(x);\n for(i=0;i<3;i++)\n { \n if(x%ar[i]==0) \n divi(x/ar[i],steps+1,flag);\n }\n }\nint main()\n{\n int l,i,j,t,w,wi,a,b;\n C a>>b;\n if(a==b)\n {\n _C \"0\\n\"; \n }\n else\n { int mi=min(a,b);\n int mx=max(a,b);\n if(mx%mi==0)\n v.pb(mi);\n p3a[a]=0;\n for(i=0;i<3;i++)\n { \n if(a%ar[i]==0) \n { divi(a/ar[i],1,0);\n }\n }\n jbs[b]=0;\n for(i=0;i<3;i++)\n { \n if(b%ar[i]==0) \n divi(b/ar[i],1,1);\n }\n if(v.size()==0)\n { _C \"-1\\n\";\n return 0;\n }\n for(i=0;i\n#include \nusing namespace std;\n\nint find(int,int);\nint bmm(int,int);\nint counter=0;\nint mini=0;\n\nvoid main(void){\n int a;\n int b;\n int c;\n cin>>a>>b; \n mini = bmm(a,b);\n if(find(a,b)){\n c=counter;\n cout<b){\n if(b==0)return a;\n return bmm(b,a%b);\n }else{\n if(a==0)return b;\n return bmm(a,b%a);\n } \n}\n\nint find(int num1,int num2){\n int g=0;\n if(num1num2){\n if(num1%2==0) {\n g=find(num1/2,num2);\n if(g) {\n counter++;\n return 1;\n }\n }\n if(num1%3==0) {\n g=find(num1/3,num2);\n if(g) {\n counter++;\n return 1;\n }\n }\n if(num1%5==0) {\n g=find(num1/5,num2);\n if(g) {\n counter++;\n return 1;\n }\n }\n }\n else{\n if(num2%2==0) {\n g=find(num1,num2/2);\n if(g) {\n counter++;\n return 1;\n }\n }\n if(num2%3==0) {\n g=find(num1,num2/3);\n if(g) {\n counter++;\n return 1;\n }\n }\n if(num2%5==0) {\n g=find(num1,num2/5);\n if(g) {\n counter++;\n return 1;\n }\n }\n\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3ea2ed40e6627abdda6f6686bb5c7a87", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "\n#include\nusing namespace std;\nint main()\n{\n int x;\n cin>>x;\n\n if(x==1) cout<<\"-1\";\n else{\n int test=0;\n while(x!=3){\n for(int i=2;i<=x;i++){\n if(x%i==0){\n cout<\nusing namespace std;\nint a,b,c,i,n,f,g,k,x;\n\nmain() {\n cin>>x;\n if(x<=3 && x%2!=0) {\n cout<<-1;\n }\n\n else if(x%2==0) {\n cout<\n#define ll long long\nusing namespace std;\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n int x;\n cin>>x;\n if(x==1 || x==4 )\n cout<<-1;\n else{\n cout<\n\nusing namespace std;\n\nconst int MAXN = 1e8;\n\nint v[MAXN];\nint main () {\n int x;\n cin >> x;\n if(x == 1) return puts(\"-1\"), 0;\n\n cout << (x - (x&1)) << ' ' << 2 << '\\n';\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ccaf1e8fd625b4c05f1fdb2ef16010c5", "src_uid": "883f67177474d23d7a320d9dbfa70dd3", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\ntypedef long long ll;\nconst int N=1e3+9;\nconst int M=1e9+7;\n\ntemplatevoid read(T &x){\n x=0;int f=0;char ch=getchar();\n while(ch<'0'||ch>'9') {f|=(ch=='-');ch=getchar();}\n while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}\n x=f?-x:x; return ;\n}\n\nll Qpow(ll a,ll b){\n ll res=1;\n while(b){\n if(b&1)(res*=a)%=M;\n (a*=a)%=M; b>>=1;\n }\n return res;\n}\n\nint n,m;\nll k,R,C;\nll a,b,c,d;\n\n\nint main(){\n read(n); read(m); read(k); read(R); read(C);\n read(a); read(b); read(c); read(d);\n ll tot=n*m-((a!=c)||(b!=d))*R*C;\n printf(\"%lld\",Qpow(k,tot));\n}\n \t \t \t\t \t\t\t\t\t \t \t\t\t\t\t", "lang_cluster": "C++", "compilation_error": false, "code_uid": "aa16946c381286b63386b8741f6e8586", "src_uid": "3478e6a4ff2415508fd517413d40c13a", "difficulty": 2200.0} {"lang": "GNU C++17", "source_code": "/*\n+++++++++++++///////////////////////////////////////////////////::::::::::::::::::::::::::::::::::::\n++++++++++++//+++//+sydmNNNNNNNNmNNNNNNNNNmNNNNNNNNNmmmmmmNNNNNmhs/:::::::::::::::::::::::::::::::::\n++++++++++++++++shmNMMMMMMMMMMNNMMMMMMMMNNNNNNNNNMMMMMMMNNNNNMNNNNmddhs/::::::::::::::::::::::::::::\n++++oooo+++++shNMMMMMMMMMMMMMNNMMMMMMMNMMMMMMMMMMMMMMMMMMMMNNMMMMNNNMMMm/:::::::::::::::::::::::::::\nsdmNNNNNNmdhmNMMMMMMMMMNNNNNNmNNNNNNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNNNMMm/+/::::::::::::::::::::::::\nyNNNNNNMMMMMMNNMMMMMMNNMMMMMNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNNNmNmds/:::::::::::::::::::::\nsmmmNNNMMMMMMMMmNNNMNMMMMMMNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNNMMMh-::::::::::::::::::::\nyNMMMMMMMMMMNMNmMMMNNNMMMNNMMMMMNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNNMM/-:::::::::::::::::::\nyMMMMMMMMMMMMNmMMMMMMmmmmNMMMMMNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNNy::::::::::::::::::::\nsNMMMMMMMMMMMNMMMMMMMMNNNMMMMMNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNMMMMNNh/:::::::::::::::::\nsdmMMMMMMMMNNMMMMMMMMMMNMMMMMNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNMN/-:::::::::::::::\nsmmmMMMMMMMNMMMMMMMMMMMMNMMMNmMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNMy.:::::::::::::::\nsmmmmMMMMMMNMMMMMMMMMMMMNMMNdMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNd.-::::::::::::::\nymdmmNMMMNNNNMMMMMMMMMMMNNmdNMMMMMMMMMMMMNMMMMMNMMMMMMMMMMMMMMMMMMMMMMMMNMMMMMMMMMMNy:::::::::::::::\nyMmdmmmNMMMMNMMMMMMMMMMMNdmdMMMMMMMMMMMMNMMMMMMmMMMMMMMMMMMMNMMMMMMMMMMMNMMMMMMMMMMMMd.:::::::::::::\nyNdmmNMMMMMMMMMMMMMMMMNNmddNMMMMMMMMMMMMNMMMMMNNMMMMMMMMMMMMNMMMMMMMMMMMNMMMMMMMNMMMMs.-::::::::::::\nsmNMMMMMMMMMMMMMMNNmmmmmhddMMMMMMMMMMMMMNMMMMMNNNMMMMMMMMMMMNMMMMMMMMMMMNMMMMMMMNMMMMs.:::::::::::::\nyMMMMMMMMMMMMMNmmmmmmmmdddmMMMMMMMMMMMMMNMMMMNMNNMMMMMMMMMMMNMMMMMMMMMMMNMMMMMMMNNMMMm--::::::::::::\nyMMMMMMMMMMMNNmmmmmmmmdhdhNMMMMMMMMMMMMMNMMMMMMMNNMMMMMMMNNNmmmmNMMMMMMMNMMMMMMMNMMNMM/.::::::::::::\nyMMMMMMMMMNNNmmmmmmmmhhhhhNMMMMMMMMMMMMMNMMMNMMMNNMMMMMMMMMNNNMMMMMMMMMMNMMMMMMMNMMNMMs.::::::::::::\nsNMMMMNNMMMMNmdmmmmdhhhhhhMMMMMMMMMMMMMMNMMNMMMMNNMMMMMMMMMNMNMMMMMMMMMMmMMMMNNMNMMmMMh.-:::::::::::\nsmmNNMMMNNmmmmmmmmmhhhhhhdMMMMMMMMMMMMMMNMMNMMMMMNNMMMMMMMMNMNMMMMMMMMMNNMMMMMmNNMMmMMd.-:::::::::::\nsNNMMNNmmmmmmmmmmmhhhhhhhmMMMMMMMMMMMMMMNNmmNNNNNmNMMMMMMMMNMNMMMMMMMMMNNMMMMMMNmNMmMMd.-:::::::::::\nyMMNNmmmmmmmmmmmmhhhhhhhhmMMMMMMMMMMMMMMNmhyso////+oyymNMMMNMNMMMMMMMMMNNMMMMMMNMNNmMMm.-:::::::::::\nyNNmmmmmmmmdNNNmdhhhhhhhhNMMMMMMMMMMMMMMmNmMNsy///::/:/smNNNNNMMMMMMMMNNNMMMMMMNMMMmMMm.-::::::::::-\nsmmmmmmmmmmdNMMMMNNmdhhhyNMMMMMMMMMMNMMMNNmMs/o+/++/omy//omNNMNMMMMMMMNNMMMMMMMNMMNNMMm.-:::--::::::\nooyddmddddhhdMMNMMMMMMNmyNMMMMMMMMMMNMMMNNdMosyhyyso+MMNh+yNMMNMMMMMMMNMMMMMMMNMMMmMMMd.-:::::::::::\n::+-:::/hhhhhNMNNNNMMMMMNNMMMMMMMMMMMNMMMmNNdddddmmhyMMMMMmMMMMMMMMMMMMMNNNMMNNMMNmMMMy.-:::::-:::::\n:y//--:/+hhhhhNMNNNNNNNMMNMMMMMMMMMMMNMMMNMNMmNMMmdmMMMMMMMMMMMMMMMMMMMmy++osdmNMdNMMM+.::::::::::::\noN:o-:/y/+hhhhhMMMMMNNNmMNMMMMMMMMMMMNMMMNNMMMNMNNMMMMMMMMMMMMMMMMMMMMy+/:mNy+shdmMMMN-.::::::::::::\nyd:s/:+Nh/:yhhhhNMMMNNNmNNMMMMMMMMMMMNMMMMmMMMMMMMMMMMMMMMMMMMMMMMMMMho+++MMMmhhhNMMMm-.-:::::::::::\nys+s/:oMMmo:ohhhhNMMNNNNmNMMMMMMMMMMMNNMMMmMMMMMMMMMMMMMMMMMMMMMMMMMMdhhydMMNddhNMMMMmo.::::::::::::\no/+h/:sMMMNy:+hhhhdNMNNNNNMMMMMMMMMMMMNMMMmMMMMMMMMMMMMMMMMMMMMMMMMMMdmmmMNmhhhdMMMMNmm.-:::::::::::\n//od//yMMMMMd:/yhhhhdNMMMNNMMMMMMMMMMMNMMMNMMMMMMMMMMMMMMMMMMMMMMMMMMNNNMNNhhhhmMMMMmMM+.:::::::::::\n//yh:/+mMMMMMy/:shhhhhdmNNmMMMMMMMMMMMNMMMmMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMdhhhhmMMMMmMMh.-::::::::::\n//mh-//oNMMMNhy//yhhhyhhhhdMMMMMMMMMMMMNMMNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNhhhhhmMMMNhMMN:-----::::::\n/yMs:h//yMMMdhhs/+hhyhhhhhyNMMMMMMMMMMMNMMNMMMMMMMMMMMMMMMMMMMMMMMMMMNMMMmhhhhhmMMMm-yNMh.----:::::-\noNN/+My//dMNhhho//yhyhhhhhhNMMMMMMMMMMMMMMmMMMMMMMMMMMMMMMMMMMMMMMMMMNMMMdhhhhydMMMh`-+mN+.---::::--\nyMh/hMNo/+ddhhy//+hyhhhhhhhdMMMMMMMMMMMMMMmMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNhhhhh+yMMMs`--/hm:-::::::--\nyN+/NMMN+//+++//+yyhhhhhhhhhMMMMMMMMMMMMMMmMMMMMMMMMMMNMMMMMMMMMMMMMMMMNhhhhhh-oMMMs`-:::yh---------\nsy/sMMMMms+//++syyyhhhhhhhhyNMMMMMMMMMMMMMNMMMMMMMMMMMMNNNMMMNNMMMMMMMmhhhhhhy.+MMMo.---::ss.-------\no/+NNMMMMdhhhhhhhyhhhhhhhhhhmMMMMMMMMMMMMMNMMMMMMMMMMMMMMMMMMMMMMMMMNdhhhhhhhs./MMM+.:----:s/-------\n/+mMNMMMmhhhhhhhyhhhmmmmdhymmMMMMMMMMMMMMMmMMMMMMMMMMMMMMMMMMMMMMMNyhhhhhhhhhs.:NMN-.::----:s-------\n/dMMNMMNhhhhhhhyhhho+oosydmNmNMMMMMMMMMMMMmNNMMMMMMMMMMMMMMMMMMNmNdyhhhhhhhhhs.-NMh.-::-----:+.-----\nsMMNNMNdhhhhhhyhhhhmMMMMmho+ydMMMMMMMMMMMMmNNdddmNMMMMMMMMMMNmhhdMhyhhhhhhhhhy.-mMo.-:------:o------\nyMMNMMdhhhhhhyhhhhhdMMMMMMMmo+mMMMMMMMMMMMmNddhhhhhddmmNNNmdhhhhdNhyyhhhhhhhhy.-NN-.-::------++.----\nyMNNMmhhhhhhyhhhhdmdMMMMMMMMNshMMMMMMMMMMMmdmmmdhhhhhhhhhhhhhhhhhNhhyhhhhhhhhh/:My`----------/s.---:\nyMNMmhhhhhhyyhhhmNmmNMMMMMMMMMNMMMMMMMMMMMmmmmmmdhhhhhhhhhhhyhhhhmhhhyhhhhhhhhssN:.----------/y..---\nyNMmhhhhhhhyhhhmMMNmmNMMMMMMMMNMMMMMMMMMMMmmmmmmmhhhhhhhhhhhhhhhhhdhhyyhhhhhhhydy.------::---+h-.---\nsNNhhhhhhhyhhdmNMMMMmmNMMMMMMMNMmMMMMMMMMMmmmmmmmdmddhhhhhhhhhhhhhhyhhyhhhhhhhhms.----::-::--oy..---\nsNhhhhhhhyhNNNNMMMMMMNmNMMMMMMNMNNMMMMMMMMmyyyhhmmmmmhdhhhhhhhhhhhhyyhhyhhhhhhhNm.----------:s+`-:--\nohhhhhhhhmNMMMNNNMMMMMNmNMMMMMNNMNNMMMMMMMmNMMMmshmmhmNNNNmmmddhhhhhyyhhyhhhhhdNMs.---------:s-.----\nohhhhdmNMNNNMMMMNNMMMMMNmMMMMMMNNMNNMMMMMMmMMMMMhymymMMNMMMMMMMNmdhhhyyhyyhhhhmNMN:---------/+.-----\nohdNMMMMMMMMMMMMMMNMMMMMNmMMMMMNNMMNNMMMMMmMMMMNsmydmNMNNMMMMMMMMMNhhhyyyyyhhhNNMMh.--------+-.-----\nomMMMMMMMMMMMMMMMMNNMMMMMNNMMMMMNNMMNNMMMMNNMMMsdyNNdmNMNNMMMMMMMMMNhhhhyyyhhhMNMMMo.------::-------\nyMMMMMMMMMMMMMMMMMMMNMMMMMNMMMMMNNNMNmNMMMMmMNNshhMMNdmNMMNMMMMMMMMMNhhhhyhhhmMNMMMN/-----+y--------\nyMMMMMMMMMMMMMMMMMMMMNMMNNMNMMMMMNNMMMNNMMMNmmmyddNMMMmmMMMNMMMMMMMMMhhhhhyhhmMNMMMMN/---oNs`-------\nyMMMMMMMMMMMMMMMMMMNMMNNMmNNNMMMMMNNMMMNNMMNdmmmmmdMMMMmmMMMNMMMMMMMMmhhhhyhhNMdmNMMMN/-:NM+.-------\nyMMMMMMMMMMMMMMMMMMMNNMNNNmNmMMMMMMNNMMMNMMNNNNmmmdNMMMMmmMMNNMMMMMMMMyhhhyyhMMhhhmNMMNs/NM/.-------\nyMMMMMMMMMMMMMMMMMMMMMNMNNmmmMMMMMMMNNNMMNMNNMMmdhhNMMMMMNNMMNNMMMMMMMhhhhyyhMNhhhhhdNMMmNM+.-------\nyMMMMMMMMMMMMMMMMMMMMMMNMNmmmMMMMMMMMMNNNNMNMMMMMNmMMMMMMMNNNNNMMMMMMMhhhyyhhMdhhhhhhhhdNNMh.-------\nyMMMMMMMMMMMMMMMMMMMMMMMMMhmNMMMMMMMMMMMMNNmMMMMMmmNMMMMMMNMNNNNMMMMMMhhyhhhhNhhhhhhhhhhhhdmy/------\nyMMMMMMMMMMMMMMMMMMMMMMMMNddNMMMMMMMMMMMMMmNMMMMMNhdMMMMMMoyNNmmMMMMMMhhhhhhhdhhhhhhhhhhhhhhhhs/----\nyMMMMMMMMMMMMMMMMMMMMMMMMMmNNNMMMMMMMmhNMmNMMMMMMMsoyNMMMMs/+hddMMMMMNddhhhhhhhhhhhhhhhhhhhhhhhhy:--\nsMMMMMMMMMMMMMMMMMMMMMMMMMmMMmMMMMMMN+/+hNMMMMMMMh///odMMMyoo/osmMMMMNmNdhhyhhhhhhhhhhhhhhhhhhhhhs--\n+NMMMMMMMMMMMMMMMMMMMMMMMMNMMmMMMMMNo////odMMMMMh//ss//smMhsmmddmNNNNNmMNhhhhhhhhhhhhhhhhhhhhhhhhs--\nohNMMMMMMMMMMMMMMMMMMMMMMNMMMdmMMMNo//////+mMMMm+//hdh+/+NNNmNMMNNNNNNmNNdhhhhhhhhhhhhhhhhhhhhhhhs--\nohhNMMMMMMMMMMMMMMMMMMMMMNMMMdmNMMm+//////hMNNNMmo+dhydsyMMMMmmNMMMNNNNMMNmdhhhhhhhhhhhhhhhhhhhhhs--\nohhdMMMMMMMMMMMMMMMMMMMMMNMMMNmmNNMNs////yMMMMMMMMddhsyNmMMMMNNNNNNMMMMNNNMMMNmdhhhhhhhhhhhhhhhhhs--\nohhdmMMMMMMMMMMMMMMMMMMMNNMNMMmmmMMMMdo/oMMMMMMMMMMmdsomNMMMMMNNMMMNNNMMMMNNNMMMNhhhhhhhhhhhhhhhhs--\nohhdNmMMMMMMMMMMMMMMMMMMNMMmMMNhMMMMMMMmNMMMMMMMMMMMmdhdNMMMMMMMMNNNMMNNMMMMMMMMMMdhhhhhhhhhhhhhhs--\nohhhMmmMMMMMMMMMMMMMMMMNMMNmMMMmMMMMMMMMMMMMMMMMMMMMMNddmMMMMMMMMMMNmMMMNNMMMMMMMMMmhhhhhhhhhhhhhs--\nohhhdmdNNMMMMMMMMMMMMMNNMMmmMMMNMMMMMMMMMMMMMMMMMMMMMMMmNMMMMMMMMMMMNmNMMMMMMMMMMMMMmhhhhhhhhhhhhs--\n*/ \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \nusing namespace std;\ntemplate inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}\ntemplate inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}\n#define files(FILENAME) read(FILENAME); write(FILENAME)\n#define read(FILENAME) freopen((FILENAME + \".in\").c_str(), \"r\", stdin)\n#define write(FILENAME) freopen((FILENAME + \".out\").c_str(), \"w\", stdout)\n#define all(c) (c).begin(), (c).end()\n#define sz(c) (int)(c).size()\n#define left left228\n#define right right228\n#define y1 y1228\n#define mp make_pair\n#define pb push_back\n#define y2 y2228\n#define rank rank228\nusing ll = long long;\nusing ld = long double; \nconst string FILENAME = \"input\";\nconst int Mod = 1000000007;\n\n\nint sum(int a, int b) {\n return (a + b >= Mod ? a + b - Mod: a + b);\n}\n\n\nint mul(int a, int b) {\n return ((ll)a * b) % Mod;\n}\n\n\nint powm(int a, ll b) {\n int res = 1;\n while (b) {\n if (b & 1) {\n res = mul(res, a);\n }\n a = mul(a, a);\n b >>= 1;\n }\n return res;\n}\n\n\nint inv(int a) {\n return powm(a, Mod - 2);\n}\n\n\nint n, m, k, r, c;\n\n\nll solver(ll a, ll b, ll r, ll c) {\n if (a >= r || b >= c) {\n return (ll)r * c;\n }\n ll lena = r - a;\n ll lenb = c - b;\n ll val = solver(r - lena + 1, c - lenb + 1, lena, lenb);\n val += (ll)r * c;\n val -= 2LL * lena * lenb;\n if (r - lena + 1 <= lena && c - lenb + 1 <= lenb) {\n val += (r - lena + 1 - lena + 1) * (c - lenb + 1 - lenb + 2);\n }\n return val;\n}\n\n\nvoid solve() {\n cin >> n >> m >> k >> r >> c;\n int ax, ay, bx, by;\n cin >> ax >> ay >> bx >> by;\n int a = abs(bx - ax);\n int b = abs(by - ay);\n ll val = solver(a, b, r, c);\n int ans = powm(k, val);\n ll area = (ll)n * m;\n area -= 2LL * r * c;\n if (min(ax, bx) + r - 1 >= max(ax, bx)) {\n if (min(ay, by) + c - 1 >= max(ay, by)) {\n area += (ll)(min(ax, bx) + r - 1 - (max(ax, bx)) + 1) * \n (min(ay, by) + c - 1 - (max(ay, by)) + 1);\n }\n }\n ans = mul(ans, powm(k, area));\n cout << ans << '\\n';\n}\n\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n //read(FILENAME);\n int t = 1;\n //cin >> t;\n while (t--) {\n solve();\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7018b2f4618a7ebc42c0a1aba117fb94", "src_uid": "3478e6a4ff2415508fd517413d40c13a", "difficulty": 2200.0} {"lang": "GNU C++17 (64)", "source_code": "\n#include \n#include \n#include \n#include \n\nclass EmptyList { };\nclass EmptyDict { };\n\ntemplate \nstruct CommonType { };\n\nstruct String;\n\ntemplate \nstruct List {\n std::shared_ptr> inner;\n\n List() : inner(std::shared_ptr>(new std::vector())) {}\n List(std::vector a) : inner(std::shared_ptr>(new std::vector(a))) {}\n template \n List(List a) : inner(std::shared_ptr>(new std::vector(a.inner->begin(), a.inner->end()))) {}\n List(EmptyList) : inner(std::shared_ptr>(new std::vector())) {}\n T &operator[](size_t index) { return (*inner)[index]; }\n const T &operator[](size_t index) const { return (*inner)[index]; }\n void push(T value) { inner->push_back(value); }\n void pop() { inner->pop_back(); }\n int64_t length() const { return inner->size(); }\n\n template \n void sort(SortFn sortFn) { std::sort(inner->begin(), inner->end(), sortFn); }\n\n template \n List::inner> concat(List other) { List::inner> ret = EmptyList(); ret.inner->insert(ret.inner->end(), inner->begin(), inner->end()); ret.inner->insert(ret.inner->end(), other.inner->begin(), other.inner->end()); return ret; }\n String join(String delim);\n};\n\nstruct String {\n std::shared_ptr inner;\n\n String() : inner(std::shared_ptr(new std::string())) {}\n String(const char* a) : inner(std::shared_ptr(new std::string(a))) {}\n String(std::string a) : inner(std::shared_ptr(new std::string(a))) {}\n String operator +(String other) { return String(*inner + *other.inner); }\n operator std::string() { return *inner; }\n String operator[](size_t index) const { return String(std::string({(*inner)[index]})); }\n int64_t charCodeAt(size_t index) const { return (*inner)[index]; }\n String operator+(String &other) const { return String(*inner + *other.inner); }\n String& operator+=(const String &other) { *inner += *other.inner; return *this; }\n char operator <(const String &other) const { return *inner < *other.inner; }\n char operator >(const String &other) const { return *inner > *other.inner; }\n char operator <=(const String &other) const { return *inner <= *other.inner; }\n char operator >=(const String &other) const { return *inner >= *other.inner; }\n char operator ==(const String &other) const { return *inner == *other.inner; }\n char operator !=(const String &other) const { return *inner != *other.inner; }\n int64_t length() const { return inner->size(); }\n\n String trim() {\n std::string s = *inner;\n const char* ws = \" \\t\\n\\r\\f\\v\";\n s.erase(s.find_last_not_of(ws) + 1);\n s.erase(0, s.find_first_not_of(ws));\n return String(s);\n }\n List split(String delim) { std::vector ret; size_t last = 0; size_t next = 0; while ((next = inner->find(*delim.inner, last)) != std::string::npos) { ret.push_back(String(inner->substr(last, next-last))); last = next + delim.length(); } ret.push_back(String(inner->substr(last))); return ret; }\n};\n\ntemplate<> String List::join(String delim) {\n std::string ret; bool first = true; for (const auto& it: *inner) { if (!first) ret += *delim.inner; first = false; ret += *it.inner; } return ret;\n}\n\ntemplate \nstruct Dict {\n using Inner = __gnu_pbds::tree, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;\n std::shared_ptr inner;\n\n Dict() : inner(std::shared_ptr(new Inner())) {}\n Dict(std::vector> a) : inner(std::shared_ptr(new Inner(a.begin(), a.end()))) {}\n template \n Dict(Dict a) : inner(std::shared_ptr(new Inner(a.inner->begin(), a.inner->end()))) {}\n Dict(EmptyDict) : inner(std::shared_ptr(new Inner())) {}\n V &operator[](K key) { return (*inner)[key]; }\n const V &operator[](K key) const { return (*inner)[key]; }\n int64_t length() const { return inner->size(); }\n bool contains(const K& k) const { return inner->find(k) != inner->end(); }\n void remove(const K& k) const { inner->erase(k); }\n K keyAt(int64_t pos) const { return inner->find_by_order(pos)->first; }\n int64_t bisect(const K& value) const { return inner->order_of_key(value); }\n\n List keys() const { std::vector ret; for (auto const& it: *inner) { ret.push_back(it.first); }; return List(ret); }\n};\n\ntemplate struct CommonType, EmptyList> { using inner = List; };\ntemplate struct CommonType> { using inner = List; };\ntemplate struct CommonType, List> { using inner = List::inner>; };\n\ntemplate struct CommonType> { using inner = std::shared_ptr; };\ntemplate struct CommonType, std::nullptr_t> { using inner = std::shared_ptr; };\n\ntemplate struct CommonType, EmptyDict> { using inner = Dict; };\ntemplate struct CommonType> { using inner = Dict; };\ntemplate struct CommonType, Dict> { using inner = Dict::inner, typename CommonType::inner>; };\n\ntemplate <> struct CommonType { using inner = int64_t; };\ntemplate <> struct CommonType { using inner = EmptyList; };\ntemplate <> struct CommonType { using inner = EmptyDict; };\ntemplate <> struct CommonType { using inner = std::nullptr_t; };\ntemplate <> struct CommonType { using inner = char; };\ntemplate <> struct CommonType { using inner = String; };\n\nint64_t cast_int(long int x) { return x; }\nint64_t cast_int(long long int x) { return x; }\nint64_t cast_int(double x) { return x; }\nint64_t cast_int(String x) { return std::strtoll(x.inner->c_str(), NULL, 10); }\n\ndouble cast_float(long int x) { return x; }\ndouble cast_float(long long int x) { return x; }\ndouble cast_float(double x) { return x; }\ndouble cast_float(String x) { return std::strtod(x.inner->c_str(), NULL); }\n\nString cast_str(long int x) { return String(std::to_string(x)); }\nString cast_str(long long int x) { return String(std::to_string(x)); }\nString cast_str(double x) { return String(std::to_string(x)); }\nString cast_str(bool x) { return String(std::to_string(x)); }\nString cast_str(String x) { return x; }\n\nbool rand_bool() { return rand() % 100 < 50; }\nint64_t rand_int(int64_t upper) { return std::experimental::randint(int64_t(0), upper); }\nString chr(int64_t x) { return String(std::string({(char)x})); }\n\ntemplate \nstruct TypeHolder { };\n\ntemplate \nList linq(const List &input, Filter filter, Mapper mapper, TypeHolder type_holder) {\n List ret;\n for (const auto &it: *input.inner) {\n if (filter(it)) {\n ret.push(mapper(it));\n }\n }\n return ret;\n}\n\n\nString solve(String input);\nString solve(String input) {\nList lines = (input).split(String(\"\\n\"));\nList line1 = ((lines)[0ll]).split(String(\" \"));\nList line2 = ((lines)[1ll]).split(String(\" \"));\nint64_t n = cast_int((line1)[0ll]);\nint64_t m = cast_int((line1)[1ll]);\nint64_t k = cast_int((line1)[2ll]);\nint64_t r = cast_int((line1)[3ll]);\nint64_t c = cast_int((line1)[4ll]);\nint64_t ax = cast_int((line2)[0ll]);\nint64_t ay = cast_int((line2)[1ll]);\nint64_t bx = cast_int((line2)[2ll]);\nint64_t by = cast_int((line2)[3ll]);\nint64_t till = 0ll;\nif (((ax==bx)&&(ay==by))) {\ntill = (n*m);\n} else {till = ((n*m)-(r*c));\n}\nint64_t now = 1ll;\nfor (int64_t i = 0ll; (i\r\n#define ll long long\r\n#define fi first\r\n#define se second\r\n#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);\r\nconst ll MOD=1e9+7;\r\nusing namespace std;\r\nll N,M,K,R,C;\r\nll a,b,c,d;\r\nvector > vec;\r\nll pangkat(ll x,ll y){\r\n\tif(y==0){\r\n\t\treturn 1;\r\n\t}\r\n\tif(y==1){\r\n\t\treturn x;\r\n\t}\r\n\tll z=pangkat(x,y/2);\r\n\tif(y%2==0){\r\n\t\treturn (z*z)%MOD;\r\n\t}\r\n\telse{\r\n\t\treturn ((z*z)%MOD*x)%MOD;\r\n\t}\r\n}\r\nint main(){\r\n\tcin>>N>>M>>K>>R>>C;\r\n\tcin>>a>>b>>c>>d;\r\n\tll x=2*R-abs(max(a+R-1,c+R-1)-min(a,c)+1);\r\n\tll y=2*C-abs(max(b+C-1,d+C-1)-min(b,d)+1);\r\n\tif(x<=0||y<=0){\r\n\t\tcout<0&&tempy>0){\r\n\t\t\tvec.push_back({tempx,tempy});\r\n\t\t\ttempx-=offx;\r\n\t\t\ttempy-=offy;\r\n\t\t}\r\n\t\tll exp=N*M-2*vec[0].fi*vec[0].se+vec[1].fi*vec[1].se;\r\n\t\tfor(int i=0;i\nusing namespace std;\n\npair NoOfWays(string s) // gives the min and max position we can reach \n{\n // Base Case\n if (s.size()==0)\n {\n pair worstAns(INT_MAX,INT_MIN);\n return worstAns;\n }\n\n if (s.size()==1)\n {\n if (s[0]=='L')\n {\n pair verySmallAns(-1,0);\n return verySmallAns;\n }\n\n else\n {\n pair verySmallAns(0,1);\n return verySmallAns;\n }\n }\n\n\n // Our Calculation\n int move=0;\n if (s[0]=='L')\n {\n move=-1;\n }\n else\n {\n move=1;\n }\n\n\n pair onePossibleAns=NoOfWays(s.substr(1));\n pair secondPossibleAns=NoOfWays(s.substr(1));\n\n int overAllMin=min(onePossibleAns.first+move,secondPossibleAns.first);\n int overAllMax=max(onePossibleAns.second+move,secondPossibleAns.second);\n\n pair finalAns(overAllMin,overAllMax);\n return finalAns;\n}\n\nint main()\n{\n int t;\n\tcin>>t;\n\n char * s=new char [t];\n for (int i=0;i>s[i];\n } \n\n pair minMax=NoOfWays(s);\n cout<\nusing namespace std;\n\n#define ll long long\n\nll county=0;\n\nstd::vector v;\n\n\nvoid countPossiblePos(string s,ll st, ll end,ll pos)\n{\t\n\tif(st>end)\n\t\t{\n\t\t\tv.push_back(pos)\t;\n\t\t\t\t\treturn;\n\t\t}\n\tll inc;\n\tif(s[st]=='L')\n\t inc = -1;\n\telse inc = 1;\n\t countPossiblePos(s,st+1,end,pos+inc);\n\t\n\t\n\tcountPossiblePos(s,st+1,end,pos);\n\t//cout<<\"excld = \"<>n;\n\n string s; cin>>s;\n ll x=0;\n\n countPossiblePos(s,0,n-1,x); \n\n //cout<\n \n// #include\nusing namespace std;\n\n\nset getDistinctCount(string s,int n,map > m)\n{\n if(m.find(n)!=m.end())\n {\n return m[n];\n }\n \n set res;\n if(n==0)\n {\n res.insert(0);\n m[n]=res;\n return res;\n }\n \n set e = getDistinctCount(s,n-1,m);\n res.insert(e.begin(),e.end());\n int cur = s[n-1]=='L'?-1:+1;\n set::iterator it;\n for(it=e.begin();it!=e.end();it++)\n {\n res.insert((*it)+cur);\n }\n\n m[n]=res;\n return res;\n}\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n\n cin.tie(NULL);\n \n int n;\n cin>>n;\n \n string s;\n cin>>s;\n map > m;\n set r = getDistinctCount(s,n,m);\n cout<\nusing namespace std;\n\n#define ll long long\nsetstt;\n\n\n\nvoid countPossiblePos(string s,ll st, ll end,ll pos)\n{\t\n\tif(st>end)\n\t\t{\n\t\t\tstt.insert(pos);\n\t\t\treturn;\n\t\t}\n\tll inc;\n\tif(s[st]=='L')\n\t inc = -1;\n\telse inc = 1;\n\t countPossiblePos(s,st+1,end,pos+inc);\n\t\n\t\n\tcountPossiblePos(s,st+1,end,pos);\n\t//cout<<\"excld = \"<>n;\n\n string s; cin>>s;\n ll x=0;\n\n countPossiblePos(s,0,n-1,x); \n\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint main()\n{\n string a, b = \"1\";\n int n;\n int track;\n cin >> n;\n cin >> a;\n if (a==\"0\"){\n \tcout << \"0\";\n\t}\n\telse{\n\tfor (int i = 0; i\n\nusing namespace std;\nint main(){\n\tint n,zeros;\n\tcin>>n;\n\tchar msg[n];\n\tstring ans {};\n\tfor(int i=0; i>msg[i];\n\t\tif(msg[i]=='0') zeros++;\n\t}\n\tif(msg[0]=='1') ans+='1';\n\tfor(int i=0;i\n\nusing namespace std;\nint main(){\n\tint n,zeros;\n\tcin>>n;\n\tchar msg[n];\n\tstring ans {};\n\tfor(int i=0; i>msg[i];\n\t\tif(msg[i]=='0') zeros++;\n\t}\n\tif(msg[0]=='1') ans+='1';\n\tfor(int i=0;i\n#include \n\nusing namespace std;\nint main(){\n\tint n,zeros;\n\tcin>>n;\n\tchar msg[n];\n\tstring ans {};\n\tfor(int i=0; i>msg[i];\n\t\tif(msg[i]=='0') zeros++;\n\t}\n\tif(msg[0]=='1') ans+='1';\n\tfor(int i=0;i\nusing namespace std;\n\nlong long a, b, c, i;\nstring s;\ndeque < string > v(100);\n\nvoid prov()\n{\n if ( abs((a+b)-c) == 0 ) cout << s;\n else if ( abs((a+b)-c) == 2 )\n {\n v.push_front(\"|\");\n for ( i = 0; i < s.length(); i++ )\n {\n cout << v[i];\n }\n }\n else cout << \"Impossible\";\n}\n\nint main()\n{\n cin >> s;\n while ( s[i] != 43 )\n {\n a++;\n i++;\n }\n i++;\n while ( s[i] != 61 )\n {\n b++;\n i++;\n }\n i++;\n while ( i < s.length() )\n {\n c++;\n i++;\n }\n for ( i = 0; i <= s.length(); i++ )\n {\n v[i] = s[i];\n }\n cerr << a << \" \" << b << \" \" << c;\n prov();\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e72aeb22caaf43e33ad4b0354b63a2b0", "src_uid": "ee0aaa7acf127e9f3a9edafc58f4e2d6", "difficulty": null} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint main()\n{\n long long l,i,j,p,a[5],d,c;\n char s[10000];\n cin>>s;\n l=strlen(s);\n d=0;\n for(i=0;i\n#include\n#include\n#include\nusing namespace std;\nmain()\n{\n string s;\n cin>>s;\n int l=s.length();\n int A=0,B=0,C=0,p=0,m=0,i,k;\n for(i=0;i2)\n cout<<\"Impossible\"<\n#include\n#include\n#include\nusing namespace std;\nmain()\n{\n string s;\n cin>>s;\n int l=s.length();\n int A=0,B=0,C=0,p=0,m=0,i,k;\n for(i=0;i2)\n cout<<\"Impossible\"<\nusing namespace std;\nint main()\n{\n int x[5];\n int y[5];\n while(true)\n {\n for(int i=1;i<=4;i++)\n {\n cin>>x[i]>>y[i];\n }\n if((y[1]>x[3]&&y[1]>x[4])&&(x[2]>y[3]&&x[2]>y[4]))\n {\n cout<<\"Team 1\"<x[3]&&y[2]>x[4])&&(x[1]>y[3]&&x[1]>y[4]))\n {\n cout<<\"Team 1\"<x[1]&&x[4]>y[2])||(y[4]>x[1]&&x[3]>y[2])||(y[3]>x[2]&&x[4]>y[1])||(y[4]>x[2]&&x[3]>y[1]))\n {\n cout<<\"Team 2\"<\n#include\n#include\nusing namespace std;\nint a1[6];\nint b1[6];\nstruct node\n{\n int a;\n int b;\n} c[5];\nint checkxy(int i,int j)\n{\n if(c[i].ac[j].a && c[i].b>c[j].b)\n return 1;\n return 0;\n}\nint checkdey(int i,int j)\n{\n if(c[i].a==c[j].a || c[i].b==c[j].b)\n return 1;\n return 0;\n}\nint main()\n{\n int cas=0;\n while(1)\n {\n for(int i=1; i<=4; i++)\n {\n scanf(\"%d%d\",&a1[i],&b1[i]);\n }\n cas++;\n if(cas==5)\n printf(\"Team 1\\n\");\n else\n {\n\n c[1].a=a1[1];\n c[1].b=b1[2];\n c[2].a=a1[2];\n c[2].b=b1[1];\n c[3].a=a1[3];\n c[3].b=b1[4];\n c[4].a=a1[4];\n c[4].b=b1[3];\n// for(int i=1;i<=4;i++)\n// printf(\"%d %d\\n\",c[i].a,c[i].b);\n\n if(((checkdy(1,3)) && (checkdy(1,4))) || ((checkdy(2,3)) && (checkdy(2,4))))\n {\n printf(\"Team 1\\n\");\n }\n// else if((checkxy(1,3)) || (checkxy(2,3)) || (checkdy(1,3) && (checkxy(1,4))) || ((checkxy(2,4) && (checkdey(2,3)))) || (checkdy(2,3) && (checkxy(2,4))) || ((checkxy(1,4) && checkdey(1,3))))\n// {\n// printf(\"Team 2\\n\");\n// }\n//else\n// {\n// printf(\"Draw\\n\");\n// }\n else if((checkdy(1,3)&&(checkdey(1,4))) || (checkdey(1,3)&&(checkdey(1,4))) || (checkdey(1,3)&&checkdy(1,4)) || (checkdy(2,3)&&(checkdey(2,4))) || (checkdey(2,3)&&(checkdey(2,4))) || (checkdey(2,3)&&checkdy(2,4)))\n {\n printf(\"Draw\\n\");\n }\n else\n {\n printf(\"Team 2\\n\");\n }\n }\n\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "747c957b0b289321447f2bc38d904e38", "src_uid": "1a70ed6f58028a7c7a86e73c28ff245f", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{ for(;;){\n int a,b,c,d,m,n,x,y;\n scanf(\"%d %d\",&a,&b);\n scanf(\"%d %d\",&c,&d);\n scanf(\"%d %d\",&m,&n);\n scanf(\"%d %d\",&x,&y);\n\n if((a>c&&b>d)||((c>a&&d>b)))\n {\n if((a>max(y,n)&&d>max(x,m))||(c>max(y,n)&&b>max(x,m)))\n cout<<\"Team 1\"<b&&n>a)||(m>b&&y>a))\n cout<<\"Team 2\"<\n#include\nusing namespace std;\nint defence[4];\nint atack[4];\nint main(){\n\tfor(int i=0;i<4;i++)\n\t\tcin>>defence[i]>>atack[i];\n\n\tint Counter=0;\n\n\tif( defence[0] > defence[2] )\n\t\tCounter++;\n\tif( atack[1] > atack[3] )\n\t\tCounter++;\n\n\n\tif( defence[0] > defence[3] )\n\t\tCounter++;\n\tif( atack[1] > atack[2] )\n\t\tCounter++;\n\n\tif( Counter == 4 ){\n\t\tprintf(\"Team 1\");\n\t\treturn 0;\n\t}\n\n\n\tCounter=0;\n\n\tif( defence[1] > defence[2] )\n\t\tCounter++;\n\tif( atack[0] > atack[3] )\n\t\tCounter++;\n\n\n\tif( defence[1] > defence[3] )\n\t\tCounter++;\n\tif( atack[0] > atack[2] )\n\t\tCounter++;\n\n\tif( Counter == 4 ){\n\t\tprintf(\"Team 1\");\n\t\treturn 0;\n\t}\n\n\n\tCounter=0;\n\n\tif( defence[2] > defence[0] )\n\t\tCounter++;\n\tif( atack[3] > atack[1] )\n\t\tCounter++;\n\n\n\tif( defence[2] > defence[1] )\n\t\tCounter++;\n\tif( atack[3] > atack[0] )\n\t\tCounter++;\n\n\tif( Counter == 4 ){\n\t\tprintf(\"Team 2\");\n\t\treturn 0;\n\t}\n\n\n\tCounter=0;\n\n\tif( defence[3] > defence[0] )\n\t\tCounter++;\n\tif( atack[2] > atack[1] )\n\t\tCounter++;\n\n\n\tif( defence[3] > defence[1] )\n\t\tCounter++;\n\tif( atack[2] > atack[0] )\n\t\tCounter++;\n\n\n\n\tif( Counter == 4 ){\n\t\tprintf(\"Team 2\");\n\t\treturn 0;\n\t}\n\n\n\tprintf(\"Draw\");\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1003bf1474d71e6e1fb8a59914497ea0", "src_uid": "1a70ed6f58028a7c7a86e73c28ff245f", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "// Problem: c.\n\n#include\n#define ll long long\n#define pb push_back\nusing namespace std;\nconst unsigned ll l=1000000007;\n\n\n\nint main()\n{\n int n,m;\n\n cin >> n >> m;\n\n // ll a[n];\n\n // for(int i=0;i> a[i];\n\n priority_queue q;\n vector v;\n\n int pipe=0,cnt=0;\n\n for(int i=0; i> num;\n pipe += num;\n while(pipe > m && !q.empty())\n {\n int top = q.top();\n q.pop();\n v.pb(top);\n pipe-=top;\n cnt++;\n }\n\n cout << cnt << \" \";\n for(auto i:v)\n {\n q.push(i);\n cnt--;\n pipe+=i;\n }\n q.push(num);\n }\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "76f26bc0746fd4e8597ad7f83bbd5521", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "// Problem: c.\n\n#include\n#define ll long long\n#define pb push_back\nusing namespace std;\nconst unsigned ll l=1000000007;\n\n\n\nint main()\n{\n ll n,m;\n\n cin >> n >> m;\n\n // ll a[n];\n\n // for(int i=0;i> a[i];\n\n priority_queue q;\n vector v;\n\n ll pipe=0,cnt=0;\n\n for(int i=0; i> num;\n pipe += num;\n while(pipe > m && !q.empty())\n {\n ll top = q.top();\n q.pop();\n v.pb(top);\n pipe-=top;\n cnt++;\n }\n\n cout << cnt << \" \";\n for(auto i:v)\n {\n q.push(i);\n cnt--;\n pipe+=i;\n }\n q.push(num);\n }\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5517ad37248422a85d552026a52e562f", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "// Problem: c.\n\n#include\n#define ll long long\n#define pb push_back\nusing namespace std;\nconst unsigned ll l=1000000007;\n\n\n\nint main()\n{\n ll n,m;\n\n cin >> n >> m;\n\n ll a[n];\n\n for(int i=0;i> a[i];\n\n priority_queue q;\n vector v;\n\n ll pipe=0,cnt=0;\n\n for(int i=0; i m && !q.empty())\n {\n ll top = q.top();\n q.pop();\n v.pb(top);\n pipe-=top;\n cnt++;\n }\n\n cout << cnt << \" \";\n for(auto i:v)\n {\n q.push(i);\n cnt--;\n pipe+=i;\n }\n q.push(a[i]);\n }\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8ac5d4e8d3aeba2a176ebc58ed1a435e", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define fi first\n#define se seconds\n#define mp make_pair\n#define pb push_back\n#define popb pop_back()\n#define ll long long\n#define sz size()\n#define all(x) x.begin(), x.end()\n#define forn(x) for(int i=1;i<=x;i++) \n#define sforn(x, y) for(int i=1;i<=x;i++)for(int j=1;j<=y;j++)\n#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n\nint arr[200100];\nint ans[200100];\nint main(){ speed;\n int n, m;\n cin >> n >> m;\n priority_queue q;\n priority_queue, greater > q2;\n int sum = 0;\n for(int i=1;i<=n;i++){\n while(q.sz>0 && q2.sz > 0 && q2.top() < q.top()){\n int f = q2.top();\n int s = q.top();\n sum-=s;\n sum+=f;\n q2.push(s);\n q.push(f);\n }\n cin >> arr[i];\n if(arr[i] + sum <= m){\n while(q2.sz > 0 && arr[i] + sum + q2.top() <=m){\n int k = q2.top();\n q2.pop();\n sum+=q2.top();\n q.push(k);\n }\n ans[i] = q2.sz;\n } else {\n while(q.sz > 0 && arr[i] + sum > m){\n int k = q.top();\n q.pop();\n sum-=k;\n q2.push(k);\n }\n ans[i] = q2.sz;\n }\n \n \n q.push(arr[i]);\n sum+=arr[i];\n }\n for(int i=1;i<=n;i++){\n cout << ans[i] << \" \";\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8b99e010d478872b6d87fa9e2a4be079", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\nint main ()\n{\n long long int a,d,e,f=1,max;\n vector b;\n cin>>a;\n d=a;\n e=a;\n while (d>0)\n {\n while (true)\n {\n if (d%2==0) d=d/2;\n else {b.push_back (a-e+d);break;}\n }\n e--;\n d=e;\n }\n max=b[0];\n while (fb[f]) max=b[f];\n f++;\n } \n cout<\nusing namespace std;\n\n#define MOD 1000000007\n\n\nint main() {\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n long int i,x,ans=0;\n vector v;\n for(i=1;i<10e9;i=i*2)\n {\n \tv.push_back(i);\n }\n cin>>x; \n if(binary_search(v.begin(),v.end(),x)==true)\n {\n \tcout<<1<<\"\\n\";\n }\n else\n {\n \tans=x-v[lower_bound(v.begin(),v.end(),x)-v.begin()-1]+1;\n \tcout<\n#include \nusing namespace std;\nint main() {\n long n; cin>>n;\n //long long x=2;\n long long a[35];\n a[0]=1;\n for(int i=1; i<35; i++) {\n a[i]=a[i-1]*2;\n }\n int dem=1;\n while(1) {\n for(int i=0; i<35; i++) {\n if(n \n#include \n#include \n\nusing namespace std;\nint main() {\n\tint c,c1, k = 0;\n\tcin >> c;\n\tif (c == 1) k++;\n\telse\n\twhile (c>=2) \n\t{\n\t\tif (c % 2==1) k++;\n\t\tc1 = c/2;\n\t\tif (c1 >= 2) c = c1;\n\t\telse if (c1 == 1)\n\t\t{\n\t\t\tk++;\n\t\t\tbreak;\n\t\t}\n\t}\n\tcout << k;\n\tgetch();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6cf19e51b75380c0970bc660046ea574", "src_uid": "03e4482d53a059134676f431be4c16d2", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include\n#include\nint main()\n{\n int n,k,i=1,tot=0;\n printf(\"\\nEnter n and k :\");\n scanf(\"%d%d\",&n,&k); \n tot+=k; \n for(i=1;i<=n;i++)\n {\n if(tot<=240)\n {\n tot+=5; \n } \n }\n printf(\"%d\",i-1);\n getch();\n return(0);\n \n}\n \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c57d994a9d4d82634bf9e401973bcc7e", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include\n#include\nint main()\n{\n int n,k,tot=0,tot1=0,flag=0;\n scanf(\"%d%d\",&n,&k); \n tot+=k; \n for(int i=1;i<=n;i++)\n {\n tot1=tot; \n tot1+=i*5; \n if(tot1<=240)\n { \n tot=tot1;\n flag+=1; \n }\n }\n printf(\"%d\",flag);\n getch();\n return(0);\n}\n \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fa23d6f416439552e1b57376ec085fd2", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0} {"lang": "GNU C++17 Diagnostics", "source_code": "#include\n#include\n#include\n\nusing namespace std;\n\nint main ()\n{\n int n,k,i=1,tot=0;\n cin>>n>>k;\n int time=240-k;\n while(tot+5*i<=time && i<=n)\n {\n tot+=5*i;\n i++;\n }\n cout<\n#include\nint main()\n{\n int n,k,i=1,tot=0;\n scanf(\"%d%d\",&n,&k); \n tot+=k; \n for(i=1;i<=n;i++)\n {\n if(tot<=240)\n {\n tot+=5; \n } \n }\n printf(\"%d\",i);\n getch();\n return(0);\n}\n \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2f722d0d54877c4874b9f04dff40c741", "src_uid": "41e554bc323857be7b8483ee358a35e2", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nlong long gcd(long long m,long long n){\n\tif(n==0) return m;\n\telse return gcd(n,m%n);\n}\n\nlong long f(long long m,long long n){\n\tif(n==0) return 0;\n\tlong long mint=n,p=1;\n\tfor(long long i=1;i<=sqrt(m);i++){\n\t\tif(m%i==0){\n\t\t\tlong long x=n%i;\n\t\t\tif(x<=mint){\n\t\t\t\tif(i!=1){\n\t\t\t\t\tmint=x;\n\t\t\t\t\tp=max(p,i);\n\t\t\t\t}\n\t\t\t}\n\t\t\tlong long y=n%(m/i);\n\t\t\tif(y<=mint){\n\t\t\t\tmint=y;\n\t\t\t\tp=max(p,m/i);\n\t\t\t}\n\t\t}\n\t}\n\treturn mint+f(m/p,n/p);\n}\n\nint main(){\n\tlong long a,b;\n\tscanf(\"%I64d %I64d\",&a,&b);\n\tlong long x=gcd(a,b);\n\tprintf(\"%I64d\\n\",f(a/x,b/x));\nreturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e34cd7790f7a571596c0139a86cbeebb", "src_uid": "ea92cd905e9725e7fcb87b9ed4f64c2e", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include \"bits/stdc++.h\"\nusing namespace std;\n\nconst long long int MAX=1e9;\n\nvector prime;\n\nlong long int cal(long long int X,long long int Y)\n{\n\tif(Y==0)\n\treturn 0;\n\tlong long int hcf=__gcd(X,Y),steps=MAX;\n\tfor(int A=0;A>X>>Y;\n\tXX=X;\n\tfor(int A=2;A*A<=XX;A++)\n\t{\n\t\tif(XX%A==0)\n\t\t{\n\t\t\tprime.push_back(A);\n\t\t\twhile(XX%A==0)\n\t\t\tXX/=A;\n\t\t}\n\t}\n\tif(XX>1)\n\tprime.push_back(XX);\n\tcout<\n#include\n#include\n#include\n#include\nusing namespace std;\ntypedef long long ll;\nconst ll mod = 998244353;\nconst int N = 1e6 + 7;\nll top, n, i, j;\nint p[N + 10];\nint f[N + 10];\n \ninline void init() {\n top = 0;\n memset(f, 0, sizeof(f));\n for (i = 2; i <= N; ++i) {\n if (!f[i]) {\n p[++top] = i;\n }\n for (j = 1; j <= top && i * p[j] <= N; ++j) {\n f[i * p[j]] = 1;\n if (i % p[j] == 0)\n break;\n } \n }\n return;\n}\n\nll ans, a, b, tmp;\n\nll gcd(ll a, ll b) {\n if (b == 0)\n return a;\n return gcd(b, a % b);\n}\n\nint fa(ll a, ll b) {\n if (b == 0)\n return 0;\n tmp = a;\n for (i = 1; i <= top; ++i) {\n if (p[i] > a)\n break;\n if (a % p[i] != 0)\n continue;\n tmp = min(tmp, b % p[i]);\n }\n ans += tmp;\n b -= tmp; \n tmp = gcd(a, b);\n a /= tmp;\n b /= tmp;\n fa(a, b);\n return 0;\n}\n\nint main() {\n init();\n scanf(\"%lld%lld\", &a, &b);\n ans = 0;\n tmp = gcd(a, b);\n a /= tmp;\n b /= tmp;\n tmp = 0;\n for (i = 1; i <= top; ++i)\n if (a % p[i] == 0)\n p[++tmp] = p[i];\n top = tmp;\n fa(a, b);\n printf(\"%lld\\n\", ans);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "600c7ad3526ac400ab0f0cbdcc751471", "src_uid": "ea92cd905e9725e7fcb87b9ed4f64c2e", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pdd;\ntypedef pair p3i;\ntypedef vector vi;\ntypedef vector vll;\ntypedef vector vvll;\ntypedef vector vii;\ntypedef vector v3i;\ntypedef vector vvii;\ntypedef vector vp3i;\ntypedef long double ld;\ntypedef vector vld;\ntypedef vector vpii;\n\n#define pb push_back\n#define mp make_pair\n#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)\n#define REPD(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)\n#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)\n#define FORD(i,a, b) for (int (i) = (a); (i) >= (b); (i)--)\n#define sz(v) (int)(v).size()\n#define all(v) (v).begin(), (v).end()\n#define rv(v) reverse(all(v))\n#define CL(v, val) memset((v), (val), sizeof((v)))\n#define SORT(a) sort(all(a))\n#define un(v) SORT(v), (v).resize(unique(all(v)) - (v).begin())\n#define eps 1.0e-7\n#define X first\n#define Y second\n#define bit(n) (1 << (n))\n#define bit64(n) (ll(1) << (n))\n#define sqr(n) ((n) * (n))\n#define INF 300000005\n#define MAXN 10000000\n\nmap arr;\n\nll mas[MAXN];\n\nll gcd(ll a, ll b)\n{\n\twhile (b) \n\t{\n\t\ta %= b;\n\t\tswap(a, b);\n\t}\n\treturn a;\n}\n\nll function(ll a, ll b)\n{\n\tif (b >= MAXN)\n\t{\n\t\tif (b == 0)\n\t\t{\n\t\t\treturn 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif (arr[b])\n\t\t\t{\n\t\t\t\treturn arr[b];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\treturn (arr[b] = 1 + function(a, b - gcd(a, b)));\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tif (mas[b] || !b)\n\t\t{\n\t\t\treturn mas[b];\n\t\t}\n\t\telse\n\t\t{\n\t\t\treturn (mas[b] = 1 + function(a, b - gcd(a, b)));\n\t\t}\n\t}\n}\n\nint main()\n{\n\tll x, y;\n\tscanf(\"%lld %lld\", &x, &y);\n\tCL(mas, 0);\n\tprintf(\"%lld\", function(x, y));\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "13df0f975528295292e5219918c743c0", "src_uid": "ea92cd905e9725e7fcb87b9ed4f64c2e", "difficulty": 2100.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main()\n{\n //string a;\n char a[200], b[100], h[200];\n int j, t = 0, i, lena, lenb, s = 0;\n cin >> a;\n //a = 'iyaiuiwioOyzUaOtAeuEYcevvUyveuyioeeueoeiaoeiavizeeoeyYYaaAOuouueaUioueauayoiuuyiuovyOyiyoyioaoyuoyea';\n lena = strlen(a);\n for (i = 0; i\n#include \n\n#define endl \"\\n\"\nint main()\n{\n std::string s;\n std::cin>>s;\n int len = s.length();\n char c[100],f[200],j=0;\n strcpy(c, s.c_str());\n for(int i = 0; i < len; i++)\n {\n if(c[i] < 96)\n c[i]+=32;\n if (c[i] == 'a' || c[i] == 'e' || c[i] == 'i' || c[i] == 'o' || c[i] == 'u' || c[i] == 'y')\n continue;\n else\n {\n f[j]='.';j++;\n f[j]=c[i];j++;\n } \n }\n for(int i = 0; i < j; i++)\n {\n std::cout<< f[i];\n }\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e61c55cf15e169bcb4455613ba0942c7", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b", "difficulty": 1000.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main()\n{\n char a[202], b[101], h[202];\n int j, t = 0, i, lena, lenb, s = 0;\n cin >> a;\n lena = strlen(a);\n for (i = 0; i\n#include \nusing namespace std;\n\nchar low(char c){\nif (c >= 'A' && c <= 'Z')\nreturn c - 'A' + 'a';\nelse return c;\n}\n\nint main()\n{\nstring n;\ncin >> n;\nstring m = \"\";\nfor ( int i = 0; i < n.length(); ++i )\n{\nif ( n[i] == 'a' || n[i] == 'e' || n[i]=='i' || n[i]== 'o' ||\nn[i] == 'u' ||\nn[i] == 'A' || n[i] == 'E' || n[i] == 'I' || n[i] == 'O' || n[i] == 'U') ;\nelse\nm = m + \".\" + n[i];\n\n}\nfor(int i=0;i\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nlong long ans[11000000];\nlong long fang[30];\nlong long n,x,y;\nint main(){\n\tcin>>n>>x>>y;\n\tfang[1]=1;\n\tfor(int i=2;i<=25;i++)fang[i]=fang[i-1]<<1;\n\tint wei=1;\n\tans[0]=0;\n\tans[1]=x;\n\tfor(long long i=2;i<=10000000;i++){\n\t\tif(i&fang[wei+1]){\n\t\t\twei++;\n\t\t}\n\t\tans[i]=min(ans[i-fang[wei]]+x,ans[fang[wei+1]-i]+x);\n\t}\n//\tfor(int i=1;i<=30;i++)printf(\"a[%d]=%I64d\\n\",i,ans[i]);\n\tlong long temp=1;\n\tlong long anss=x*n;\n\tlong long ji=0;\n//\tprintf(\"FXCK\\n\");\n\twhile(1){\n\t\tji++;\n\t\tlong long tempans=y*ji+x;\n\t\ttemp*=(long long)2;\n\t\tif(3*temp>=n){\n\t\t\tanss=min(anss,tempans+(n-temp)/temp*x+ans[abs((n-temp)%temp)]);\n//\t\t\tif(anss==3)printf(\"ji=%d\\n\",ji);\n\t\t}\n\t\telse{\n\t\t\tanss=min(anss,tempans+(n-temp)/temp*x+ans[n%temp]);\n\t\t\tanss=min(anss,tempans+((n-temp)/temp+1)*x+ans[(temp-(n%temp))]);\n\t\t\t\n\t\t}\n\t\tif(anss==58087)printf(\"ji=%d\\n\",ji);\n\t\tif(temp>=n)break;\n\t}\n\tcout<\nusing namespace std;\nconst int N = 20000011;\nint n, x, y;\nlong long dp[N];\n\nint main() {\n scanf(\"%d %d %d\", &n, &x, &y);\n for (int i = n; i <= (n << 1); i++){\n dp[i] = 1LL * x * (i - n);\n }\n for (int i = n - 1; i > 0; i--){\n dp[i] = min(dp[i + 1] + x, dp[i << 1] + y);\n int e = i - 1, s = (i >> 1) + 1;\n \n while(s <= e){\n int mid = (s + e) >> 1;\n long long cost = 1LL * x * (i - mid) + dp[mid << 1] + y;\n if ( cost <= dp[i]){\n dp[i] = cost;\n e = mid - 1;\n } else\n s = mid + 1;\n }\n }\n printf(\"%lld\", dp[1] + x);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3a0aa5faf99762f608158fc8c29d8222", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nconst int maxn = 1e7 + 7;\nlong long dis[maxn];\nbool f[maxn];\nstruct node\n{\n int id;\n long long dist;\n node() {}\n node(int id, long long disx): id(id), dist(disx) {}\n inline bool operator < (const node &b) const\n {\n return dist < b.dist;\n }\n};\n\nint num;\nnode a[maxn];\nstruct pile\n{\n pile()\n {\n num = 0;\n }\n void clear()\n {\n num = 0;\n }\n void insert(node x)\n {\n num++;\n a[num] = x;\n int f = num >> 1;\n int now = num;\n while (f)\n {\n if (a[now] < a[f])\n swap(a[now], a[f]);\n else return;\n now = f;\n f = f >> 1;\n }\n }\n node top()\n {\n node ans = a[1];\n a[1] = a[num];\n num--;\n int now = 1;\n while (now * 2 <= num)\n {\n if (a[now] < a[now * 2] && a[now] < a[now * 2 + 1]) return ans;\n int id = now * 2;\n if (a[now * 2 + 1] < a[now * 2]) id++;\n swap(a[now], a[id]);\n now = id;\n }\n return ans;\n }\n};\nint main()\n{\n memset(dis, 0x7F, sizeof(dis));\n int n, xx, y;\n scanf(\"%d %d %d\", &n, &xx, &y);\n pile q;\n dis[0] = 0;\n q.insert(node(0, 0));\n while (num)\n {\n node x = q.top();\n if (f[x.id]) continue;\n f[x.id] = 1;\n if (x.id == n)\n {\n printf(\"%lld\\n\", dis[n]);\n return 0;\n }\n if (x.id * 2 <= n && dis[x.id * 2] > dis[x.id] + y)\n {\n dis[x.id * 2] = dis[x.id] + y;\n q.insert(node(x.id * 2, dis[x.id * 2]));\n }\n else if (x.id * 2 > n)\n {\n long long f = dis[x.id] + y + (long long)(x.id * 2 - n) * xx;\n if (f < dis[n])\n {\n dis[n] = f;\n q.insert(node(n, f));\n }\n }\n if (x.id + 1 <= n && dis[x.id + 1] > dis[x.id] + xx)\n {\n dis[x.id + 1] = dis[x.id] + xx;\n q.insert(node(x.id + 1, dis[x.id + 1]));\n }\n if (x.id - 1 >= 0 && dis[x.id - 1] > dis[x.id] + xx)\n {\n dis[x.id - 1] = dis[x.id] + xx;\n q.insert(node(x.id - 1, dis[x.id - 1]));\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ab20df71f3a8a1dcf9d06c81a4da9067", "src_uid": "0f270af00be2a523515d5e7bd66800f6", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \"queue\"\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define MOD1 1000000007\ninline void inp( long long int &n ){n=0;int ch=getchar();int sign=1;while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getchar();}while( ch >= '0' && ch <= '9' )n = (n<<3)+(n<<1) + ch-'0', ch=getchar();n=n*sign;}\n#define pi acos(-1)\n#define pii pair\n#define vii vector\n#define ll long long int\n#define loop(i,n) for(ll i=0;i (b) ? (a) : (b)\n#define ABS(a) (a) > 0 ? (a) : -(a)\n#define rep1(i,a,n) for(i=a;i<(n);i++)\n#define pb push_back\n#define ff first\n#define ss second\n#define mp make_pair\n#define OUT_RT cerr << (float(clock()) / CLOCKS_PER_SEC) << endl\n#define EPS 1e-9\n#define ld long double\ntypedef std::tuple query;\nusing namespace std;\n//JAI SHREE KRISHNA\n// Find the holy grail in an adventure frought with danger\n// The bigger the occasion, the better the response.\n// Never giving in, fighting to the end\n// Look at the limits\n// Check if it is binary search\n// Code till the end ofcontest\n\n\n\nconst int MAXN = 20000000;\nll cool[MAXN+5];\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n ll n,x,y;\n cin>>n>>x>>y;\n ll doublelimit;\n doublelimit = 1;\n while (doublelimit=2;i-=1)\n {\n cool[i-1] =min(cool[i-1],cool[i]+x);\n }\n loop2(i, n)\n {\n cool[i+1] =min(cool[i+1],cool[i]+x);\n }\n }\n cout<\n\nusing namespace std;\n\ntypedef long long int ll;\ntypedef pair pll;\ntypedef vector vll;\ntypedef vector vi;\n\nconst ll INF=1e18;\n\nconst int mod=1000000007;\n\nll dp[5000009];\nint pri[5000009];\nvll d[5000009];\n\nvoid sieve()\n{\n ll i,j,k;\n pri[0]=pri[1]=1;\n for (i=2;i<=sqrt(5000009);++i)\n {\n if (pri[i]==0)\n {\n for (j=2*i;j<5000009;j+=i)\n {\n if ((i*i)<=j)\n d[j].push_back(i);\n pri[j]=1;\n }\n }\n }\n return;\n}\n\nll fastpow (ll x, ll y)\n{\n ll res=1;\n while (y>0)\n {\n if (y&1)\n {\n res=(res*x)%mod;\n y--;\n }\n x=(x*x)%mod;\n y/=2;\n }\n return res;\n}\n\nint main()\n{\n ll t,n,m,i,j,k,l,r,x,y,z;\n sieve();\n scanf (\"%lld %lld %lld\",&t,&l,&r);\n dp[1]=0;\n dp[2]=1;\n dp[3]=3;\n for (i=4;i<=r;++i)\n {\n dp[i]=(i*(i-1))/2;\n for (j=0;j\n#define ll long long\n#define pb push_back\n#define vi vector\n#define all(a) (a).begin(),(a).end()\n#define F first\n#define S second\n#define hell 1000000007\n#define lbnd lower_bound\n#define ubnd upper_bound\n#define bs binary_search\n#define ios \tios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);\nusing namespace std;\nll i,j,k,l=0,ans=hell,ind=-1,n,x,m,y,a[5000005]={0},r,t;\nvector v,fact;\nvoid sieve()\n{\n for(i=2;i<=5*1e6;i++)\n {\n if(a[i]==0)\n {\n for(j=i;j<=5*1e6;j+=i)\n if(a[j]==0)a[j]=i;\n }\n }\n}\nll f(ll x)\n{\n\n if(x==1) return 0;\n ll d=a[x]%hell;\n ll grp=(x/d)%hell;\n return ((grp*((d*(d-1)/2)%hell))%hell)+f(grp)%hell;\n}\nll g(ll x)\n{\n\n //cout<>t>>l>>r;\n sieve();\n cout<\n#define mod 1000000007\n#define ll long long int\n#define pb(x) push_back(x)\n#define MP(x,y) make_pair(x,y)\nusing namespace std;\nll pow(ll a, ll b, ll m)\n{\n\tif(b==0)\n\t\treturn(1);\n\tll sol=pow(a,b/2,m);\n\tsol=(sol*sol)%m;\n\tif(b%2==1)\n\t\tsol=(sol*a)%m;\n\treturn(sol);\n}\nll sp[5000001],f[5000001],nc[5000001];\nvector v[5000001]; \nvoid solve()\n{\n\tll t,l,r,sol=0;\n\tcin>>t>>l>>r;\n\tfor(int i=0;i<5000001;i++)\n\t{\n\t\tf[i]=mod+1;\n\t}\n\tfor(int i=2;i<5000001;i++)\n\t{\n\t\tint j=i;\n\t\tv[i].pb(sp[j]);\n\t\tj=j/sp[j];\n\t\twhile(j>1)\n\t\t{\n\t\t\tif(sp[j]!=v[i][v[i].size()-1])\n\t\t\t{\n\t\t\t\tv[i].pb(sp[j]);\n\t\t\t}\t\n\t\t\tj=j/sp[j];\n\t\t}\n\t}\n\t/*for(int i=0;i>t;\n while(t--)\n solve();\n return 0;\n} ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2d2e67f1a99245259d148dbf33e61160", "src_uid": "c9d45dac4a22f8f452d98d05eca2e79b", "difficulty": 1800.0} {"lang": "GNU C++17", "source_code": "#include\n#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n#define Alhamdulillah return 0;\n#define pb push_back\n#define ins(x) insert(x)\n#define fi first\n#define se second\n#define lb lower_bound\n#define ub upper_bound\n#define all(v) (v.begin(),v.end())\n#define sz(v) ((ll)((v).size()))\n#define reset(v,val) memset(v,val,sizeof(v))\n#define erep(i, x, n) for ( i = x; i<=(ll)(n); i++)\n#define rep(i, x, n) for( i = x; i<(ll)(n); i++)\nusing namespace std;\ntypedef long long int ll;\nconst long long int mod=1e9+7;\nll dx[]={0,0,1,-1};\nll dy[]={1,-1,0,-1};\nll m,k,n,dp[5000002];\nsetst,st1;\nstring s1=\"one\",s2=\"zero\",s,ch=\"\";\nvectorv[5000005];\nvector< pair >vv;\nvector< pair > vvA,vvB;\nvector< pair< pair ,ll > > vvv;\npriority_queue pq;\nll prime[5000005]={0};\n\nvoid sieve()\n{\n\n\tprime[0]=prime[1]=1;\n\tfor(ll i=2;i*i<=5000000;i++)\n\t{\n\t\tif(prime[i])\n\t\tcontinue;\n\t\tv[i].push_back(i);\n\t\tfor(ll j=2*i;j<=5000000;j+=i)\n\t\t{\n\t\t\tprime[j]=1;\n\t\t\tv[j].push_back(i);\n\t\t}\n\t}\n}\n\nll solve(ll n){\n if(!n||n==1)return 0;\n ll &ret=dp[n];\n if(ret!=-1)return ret;\n ll ans=5e14;\n for(ll i=0;i ::iterator it,it1,it2;\n\tchar c;\n //freopen(\"a.txt\",\"r\",stdin);\n cin>>t>>l>>r;\n for(i=1;i<=r+1;i++){\n dp[i]=-1;\n }\n sieve();\n ll res=0;\n ll cnt=1;\n for(i=l;i<=r;i++){\n res+=(cnt*solve(i)%mod);\n res+=mod;\n res%=mod;\n cnt*=t;\n cnt+=mod;\n cnt%=mod;\n }\n cout<\nusing namespace std;\nchar conver(int a){\n\tchar r;\n\tr=a+'0';\n\treturn r;\n}\nint main(){\n\tint a,b,c,cont2=0,cont5=0;\n\tcin>>a>>b>>c;\n\tif(a>b){\n\t\ta=a-(a/b)*b;\n\t}\n\t\n\tint r;\n\tchar decimales[500];\n\tint f=300,k=1,t=0;int aux=b;\n\twhile(aux%2==0){\n\t\taux=aux/2;\n\t}\n\twhile(aux%5==0){\n\t\taux=aux/5;\n\t}\n\tif(aux>1){\n\t\tf=300+max(cont2,cont5);\n\t}\n\tint con;\n\tdo{\n\t\tcon=0;\n\t\twhile(a0){\n\t\t\ta=a*10;\n\t\t\tcon++;\n\t\t\tif(con>1){\n\t\t\t\tdecimales[k]='0';\n\t\t\t\tk++;\n\t\t\t}\n\t\t}\n\t\tr=a%b;\n\t\tdecimales[k]=conver((a-r)/b);\n\t\tk++;\n\t\ta=r;\n\t}while(f--);\n\tfor(int i=1;i<=k;i++){\n\t\tif(conver(c)==decimales[i]){\n\t\t\tcout<\n\nusing namespace std;\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(0); \n cout.tie(0);\n int a, b, c;\n cin >> a >> b >> c;\n int pos = -1;\n vector num(a + 1, false);\n for (int i = 1; ; ++i) {\n if (num[a]) {\n break;\n }\n num[a] = true;\n a *= 10;\n if (a / b == c) {\n pos = i;\n break;\n }\n a %= b;\n }\n cout << pos << endl;;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e1dce2619b5b7cedfd7aed91f518e355", "src_uid": "0bc7bf67b96e2898cfd8d129ad486910", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n#include\n#include \n#include \nusing namespace std;\n\nint main()\n{\n int a,b,c;\n cin >> a >> b >> c;\n for(int res = 1; res <= 5; res++)\n {\n int t = a*10/b;\n if(t == c)\n {cout << res <\n\nusing namespace std;\n\n// int getbigger(int a, int b){\n// while(a>a>>b>>c;\n int index=1;\n\n while(1){\n if (a==0) {\n if (c==a) cout<\nusing namespace std;\nint a[]={1,6,28,120,496,2016,2020,8128,32640,130816};\nint main()\n{int n,ma;\ncin>>n;\nfor(int i=0;i<10;i++)\n if(n%a[i]==0 && n>=a[i])\n {ma=a[i];\n }\n cout<\nusing namespace std;\nint a[]={1,6,28,120,496,1026,2016,8128,32640,130816};\nint main()\n{int n,ma;\ncin>>n;\nfor(int i=0;i<10;i++)\n if(n%a[i]==0 && n>=a[i])\n {ma=a[i];\n }\n cout<\nusing namespace std;\nint a[]={1,6,28,120,496,1025,2016,8128,32640,130816};\nint main()\n{int n,ma;\ncin>>n;\nfor(int i=0;i<10;i++)\n if(n%a[i]==0 && n>=a[i])\n {ma=a[i];\n }\n cout<\nusing namespace std;\nint perfect[]= {1, 6, 28, 248,120, 2016, 496,8128, 32640, 8128};\nint main()\n{\n int n;\n cin>>n;\n vectorv;\n for (int i=1; i<=sqrt(n); i++)\n {\n if (n%i==0)\n {\n v.push_back(i);\n if (n/i!=i)v.push_back(n/i);\n }\n }\n sort(v.begin(), v.end(), greater());\n for (int i=0; i\r\n\r\nint main() {\r\n std::ios::sync_with_stdio(false);\r\n std::cin.tie(nullptr);\r\n int t;\r\n std::cin >> t;\r\n while (t--) {\r\n int h, g;\r\n std::cin >> h >> g;\r\n int n = (1 << h) - 1;\r\n std::vector a(n + 1);\r\n for (int i = 1; i <= n; ++i) std::cin >> a[i];\r\n long long ans = 0;\r\n std::vector f(1 << g);\r\n std::vector good(n + 1);\r\n std::function(int, int)> solve = [&](int p, int dep) {\r\n if (dep == h - 1) return std::vector{p};\r\n auto left = solve(2 * p, dep + 1);\r\n auto right = solve(2 * p + 1, dep + 1);\r\n std::vector v(left.size() + right.size());\r\n std::merge(left.begin(), left.end(), right.begin(), right.end(),\r\n v.begin(), [&](int i, int j) { return a[i] < a[j]; });\r\n v.push_back(p);\r\n if (dep < g) {\r\n int lim = dep < g - 1 ? std::max(f[2 * p], f[2 * p + 1]) : 0;\r\n auto it = v.begin();\r\n while (a[*it] < lim) ++it;\r\n f[p] = a[*it];\r\n ans += f[p];\r\n good[*it] = true;\r\n v.erase(v.begin(), it + 1);\r\n }\r\n return v;\r\n };\r\n solve(1, 0);\r\n std::cout << ans << \"\\n\";\r\n for (int i = (1 << h) - 1; i > 0; --i) {\r\n if (!good[i]) std::cout << i << \" \";\r\n }\r\n std::cout << \"\\n\";\r\n }\r\n return 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e781f17638c95b78458a67a052bc37b3", "src_uid": "92939054045c089cd25c8f4e7b9ffcf2", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\nusing namespace std;\r\ntypedef long long int LL;\r\ntypedef pair P;\r\ntypedef pair LP;\r\nconst int INF=1<<30;\r\nconst LL MAX=1e9+7;\r\n\r\nvoid array_show(int *array,int array_n,char middle=' '){\r\n for(int i=0;i &vec_s,int vec_n=-1,char middle=' '){\r\n if(vec_n==-1)vec_n=vec_s.size();\r\n for(int i=0;i &vec_s,int vec_n=-1,char middle=' '){\r\n if(vec_n==-1)vec_n=vec_s.size();\r\n for(int i=0;i ostream& operator<<(ostream& os,const vector& v1){\r\n int n=v1.size();\r\n for(int i=0;i ostream& operator<<(ostream& os,const pair& p){\r\n os< istream& operator>>(istream& is,vector& v1){\r\n int n=v1.size();\r\n for(int i=0;i>v1[i];\r\n return is;\r\n}\r\n\r\ntemplateT ext_gcd(T a,T b,T& x,T& y){\r\n //ax+by=gcd(a,b)\r\n if(ab)y+=(x/b)*a,x%=b;\r\n if(y>a)x+=(y/a)*b,y%=a;\r\n return gcd_val;\r\n}\r\n\r\ntemplateclass modint{\r\nprivate:\r\n typedef long long int ll;\r\n ll val;\r\n\r\n ll gcd(ll a,ll b){\r\n if(amodint(T a){\r\n val=(ll)a%mod;\r\n if(val<0)val+=mod;\r\n }\r\n\r\n ll value()const{return val;}\r\n ll get_mod()const{return mod;}\r\n\r\n modint& operator++(){\r\n val++;\r\n if(val==mod)val=0;\r\n return *this;\r\n }\r\n modint operator++(int){\r\n modint ans=*this;\r\n ++*this;\r\n return ans;\r\n }\r\n modint& operator--(){\r\n if(val==0)val=mod;\r\n val--;\r\n return *this;\r\n }\r\n modint operator--(int){\r\n modint ans=*this;\r\n --*this;\r\n return ans;\r\n }\r\n\r\n modint& operator+=(const modint& a){\r\n val+=a.value();\r\n if(val>=mod)val-=mod;\r\n return *this;\r\n }\r\n modint& operator-=(const modint& a){\r\n val-=a.value();\r\n if(val<0)val+=mod;\r\n return *this;\r\n }\r\n modint& operator*=(const modint& a){\r\n val*=a.value();\r\n if(val>=mod)val%=mod;\r\n return *this;\r\n }\r\n\r\n modint pow(ll index)const{\r\n assert(index>=0);\r\n if(prime && index>=mod-1)index%=mod-1;\r\n modint a=*this,ans=1;\r\n for(ll i=1;i>=0 && i<=index;i<<=1){\r\n if(index&i)ans*=a;\r\n a*=a;\r\n }\r\n return ans;\r\n }\r\n\r\n modint inverse()const{\r\n if(prime){\r\n assert(val!=0);\r\n return pow(mod-2);\r\n }\r\n ll x,y;\r\n ll g=ext_gcd(val,mod,x,y);\r\n assert(g==1);\r\n return x;\r\n }\r\n\r\n modint& operator/=(const modint& a){\r\n if(prime){\r\n *this=(*this)*a.inverse();\r\n return *this;\r\n }\r\n ll g=gcd(val,a.value());\r\n modint a2=a.value()/g;\r\n val/=g;\r\n *this=(*this)*a2.inverse();\r\n return *this;\r\n }\r\n\r\n friend modint operator-(const modint& a,const modint& b){return (modint)a-=b;}\r\n friend modint operator+(const modint& a,const modint& b){return (modint)a+=b;}\r\n friend modint operator*(const modint& a,const modint& b){return (modint)a*=b;}\r\n friend modint operator/(const modint& a,const modint& b){return (modint)a/=b;}\r\n friend bool operator==(const modint& a,const modint& b){return a.value()==b.value();}\r\n friend bool operator!=(const modint& a,const modint& b){return a.value()!=b.value();}\r\n \r\n friend modint pow(const modint& a,const ll b){return a.pow(b);}\r\n\r\n modint operator+() const{return *this;}\r\n modint operator-() const{return modint()-*this;}\r\n\r\n friend ostream& operator<<(ostream& os,const modint& a){\r\n os<>(istream& is,modint& a){\r\n ll val;\r\n is>>val;\r\n a=val;\r\n return is;\r\n }\r\n};\r\n\r\nusing modint107=modint<1'000'000'007,true>;\r\nusing modint109=modint<1'000'000'009,true>;\r\nusing mint=modint<998'244'353,true>;\r\n\r\nnamespace sol{\r\n\r\n mint calc(int n){\r\n if(n==0)return 1;\r\n mint a,b,c;\r\n int i;\r\n a=1;\r\n for(i=0;i v1={0};\r\n mint a,b,c;\r\n int i;\r\n a=1;\r\n for(i=0;i>n;\r\n mint s=calc(n)-calc(n-1);\r\n s=s*2-1;\r\n s+=calc2(n);\r\n cout<\r\n#define sqr(x) 1ll*(x)*(x)\r\n//#define sort stable_sort\r\n#define ll long long\r\n#define mk make_pair\r\n#define pb push_back\r\n#define in insert\r\n#define mtr(x,y,z) mk(mk(x,y),z)\r\n#define fi first\r\n#define se second\r\n#define lch(x) ((x)<<1)\r\n#define rch(x) (((x)<<1)|1)\r\n#define all(x) (x).begin(),(x).end()\r\n#define titose CLOCKS_PER_SEC\r\n#define fpi(x) freopen(x,\"r\",stdin);\r\n#define fpo(x) freopen(x,\"w\",stdout);\r\n#define fprio fpi(\"in.txt\");fpo(\"out.txt\");\r\n#define fast ios_base::sync_with_stdio(false);\r\ninline void read(int &x){int v=0,f=1;char c=getchar();while (!isdigit(c)&&c!='-') c=getchar();if (c=='-') f=-1; else v=(c&15);while (isdigit(c=getchar())) v=(v<<1)+(v<<3)+(c&15);x=v*f;}\r\ninline void read(ll &x){ll v=0ll,f=1ll;char c=getchar();while (!isdigit(c)&&c!='-') c=getchar();if (c=='-') f=-1; else v=(c&15);while (isdigit(c=getchar())) v=(v<<1)+(v<<3)+(c&15);x=v*f;}\r\ninline void readc(char &x){char c;while (((c=getchar())==' ')||c=='\\n');x=c;}\r\n#define pii pair\r\n#define pll pair\r\n#define vi vector\r\n#define vl vector\r\n#define si set\r\n//#define sl set\r\n#define mii map\r\n#define mll map\r\n#define msi map\r\n#define msl map\r\n#define piii pair\r\n#define piipi pair\r\n#define plll pair\r\n#define pllpl pair\r\n#define pqi priority_queue\r\n#define pql priority_queue\r\n#define npqi priority_queue,greater >\r\n#define npql priority_queue,greater >\r\n#define forup(i,a,b) for ((i)=(a);(i)<=(b);(i)++)\r\n#define fordo(i,a,b) for ((i)=(a);(i)>=(b);(i)--)\r\n#define rep(i,x) forup ((i),1,(x))\r\n#define repd(i,x) fordo ((i),(x),1)\r\n#define rep0(i,x) forup ((i),0,((int)(x))-1)\r\n#define rep0d(i,x) fordo ((i),((int)(x))-1,0)\r\n#define itr iterator\r\n#define fe(itcalc,c) for(__typeof((c).begin()) itcalc=(c).begin();itcalc!=(c).end();itcalc++)\r\n#define NO {cout<<\"NO\";return 0;}\r\n#define YES {cout<<\"YES\";return 0;}\r\n#define y0 y000000000000000000000000000\r\n#define y1 y111111111111111111111111111\r\n#define j0 j000000000000000000000000000\r\n#define j1 j111111111111111111111111111\r\n#define cl0(a) memset((a),(0),(sizeof((a))))\r\n#define clz(a) memset((a),(0x16),(sizeof((a))))\r\n#define clf(a) memset((a),(-(0x16)),(sizeof((a))))\r\n#define inf 0x3bbbbbbb\r\n#define lnf 0x2bbbbbbbbbbbbbbbll\r\n//#define sqrt divi\r\n#define p2(i) (1ll<<(i))\r\n#define readi read\r\n#define readll read\r\n/*************************************************/\r\nconst int mod=998244353;\r\nconst int maxn=2097152;\r\nint n,m,i,j,f[1000005],s[10000005],ans;\r\nint fac[maxn+5],inv[maxn+5],fi[maxn+5],rev[maxn+5],a[maxn+5],w[maxn+5];\r\nint pw(int x,int y)\r\n{\r\n\tint z=1;\r\n\twhile(y){\r\n\t\tif(y&1)z=1ll*z*x%mod;\r\n\t\tx=1ll*x*x%mod;y>>=1;\r\n\t}\r\n\treturn z;\r\n}\r\nvoid init()\r\n{\r\n\tfac[0]=fac[1]=fi[0]=fi[1]=inv[1]=w[0]=1;w[1]=pw(3,(mod-1)/maxn);\r\n\tint i;\r\n\tforup(i,2,maxn){\r\n\t\tfac[i]=1ll*fac[i-1]*i%mod;\r\n\t\tinv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;\r\n\t\tfi[i]=1ll*fi[i-1]*inv[i]%mod;\r\n\t\tw[i]=1ll*w[i-1]*w[1]%mod;\r\n\t}\r\n}\r\nint getrev(int x)\r\n{\r\n\tint len=1,i;\r\n\twhile(len<=x){\r\n\t\tlen<<=1; \r\n\t}\r\n\trep0(i,len){\r\n\t\trev[i]=(rev[i/2]/2)+((len/2)*(i&1)); \r\n\t}\r\n\treturn len; \r\n}\r\nvoid ntt(int *a,int len,int op)\r\n{\r\n\tint i,j,k;\r\n\trep0(i,len)if(rev[i]\r\nusing namespace std;\r\n\r\n#if DEBUG\r\n// basic debugging macros\r\nint __i__,__j__;\r\n#define printLine(l) for(__i__=0;__i__\r\n _Debug& operator,(T val) {\r\n cout << val << endl;\r\n return *this;\r\n }\r\n};\r\n#define debug _Debug(),\r\n#else\r\n#define printLine(l)\r\n#define printLine2(l,c)\r\n#define printVar(n)\r\n#define printArr(a,l)\r\n#define print2dArr(a,r,c)\r\n#define print2dArr2(a,r,c,l)\r\n#define debug\r\n#endif\r\n\r\n// define\r\n#define MAX_VAL 999999999\r\n#define MAX_VAL_2 999999999999999999LL\r\n#define EPS 1e-6\r\n#define mp make_pair\r\n#define pb push_back\r\n\r\n// typedef\r\ntypedef unsigned int UI;\r\ntypedef long long int LLI;\r\ntypedef unsigned long long int ULLI;\r\ntypedef unsigned short int US;\r\ntypedef pair pii;\r\ntypedef pair plli;\r\ntypedef vector vi;\r\ntypedef vector vlli;\r\ntypedef vector vpii;\r\ntypedef vector vplli;\r\n\r\n// ---------- END OF TEMPLATE ----------\r\n#define MOD 998244353\r\n\r\nnamespace NTT {\r\n int mbase,base,root;\r\n int w[1 << 22];\r\n int rev[1 << 22];\r\n int modPow(int b,int e) {\r\n int r = 1;\r\n while (e > 0) {\r\n if (e & 1) r = ((LLI) r*b) % MOD;\r\n e >>= 1;\r\n b = ((LLI) b*b) % MOD;\r\n }\r\n return r;\r\n }\r\n int setBase(int nbase) {\r\n int i,j;\r\n mbase = 1;\r\n while (!(MOD & (1 << mbase))) mbase++;\r\n root = 2;\r\n while ((modPow(root,1 << mbase) != 1) || (modPow(root,1 << (mbase-1)) == 1)) root++;\r\n base = nbase;\r\n for (i = 0; i < (1 << base); i++) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (base-1));\r\n w[0] = 0,w[1] = 1;\r\n for (i = 1; i < nbase; i++) {\r\n int z = modPow(root,1 << (mbase-i-1));\r\n for (j = (1 << (i-1)); j < (1 << i); j++) w[j << 1] = w[j],w[(j << 1)|1] = ((LLI) w[j]*z) % MOD;\r\n }\r\n return 0;\r\n }\r\n int FFT(vector &a,int inv) {\r\n int i,j,k;\r\n int l = 0;\r\n while ((1 << l) < a.size()) l++;\r\n int s = base - l;\r\n for (i = 0; i < a.size(); i++) {\r\n if (i < (rev[i] >> s)) swap(a[i],a[rev[i] >> s]);\r\n }\r\n for (k = 1; k < a.size(); k <<= 1) {\r\n for (i = 0; i < a.size(); i += (k << 1)) {\r\n for (j = 0; j < k; j++) {\r\n int z = ((LLI) a[i+j+k]*w[j+k]) % MOD;\r\n a[i+j+k] = a[i+j]-z,a[i+j] += z;\r\n if (a[i+j+k] < 0) a[i+j+k] += MOD;\r\n if (a[i+j] >= MOD) a[i+j] -= MOD;\r\n }\r\n }\r\n }\r\n return 0;\r\n }\r\n vector multiply(vector A,vector B) {\r\n int i,n = 1;\r\n while (n < A.size()+B.size()-1) n <<= 1;\r\n vector a(n,0),b(n,0);\r\n for (i = 0; i < A.size(); i++) a[i] = A[i];\r\n for (i = 0; i < B.size(); i++) b[i] = B[i];\r\n FFT(a,0),FFT(b,0);\r\n int x = modPow(n,MOD-2);\r\n for (i = 0; i < n; i++) a[i] = ((((LLI) a[i]*b[i]) % MOD)*x) % MOD;\r\n reverse(a.begin()+1,a.end()),FFT(a,1),a.resize(A.size()+B.size()-1);\r\n return a;\r\n }\r\n}\r\n\r\nint inv(int n) {\r\n int e = MOD-2,r = 1;\r\n while (e > 0) {\r\n if (e & 1) r = ((LLI) r*n) % MOD;\r\n e >>= 1;\r\n n = ((LLI) n*n) % MOD;\r\n }\r\n return r;\r\n}\r\nint INV2 = inv(2);\r\nint INV6 = inv(6);\r\nLLI dp[1000001];\r\nint main() {\r\n int n;\r\n cin >> n;\r\n\r\n int i;\r\n dp[0] = 1;\r\n for (i = 1; i <= n; i++) {\r\n dp[i] = dp[i-1]+1;\r\n dp[i] += (((dp[i-1]*(dp[i-1]+1)) % MOD)*INV2) % MOD;\r\n dp[i] %= MOD;\r\n }\r\n\r\n LLI ans1 = dp[n-1];\r\n ans1 += (((dp[n-1]*(dp[n-1]+1)) % MOD)*INV2) % MOD;\r\n ans1 += (((((dp[n-1]*(dp[n-1]+1)) % MOD)*(dp[n-1]+2)) % MOD)*INV6) % MOD;\r\n ans1 %= MOD;\r\n ans1 = 2*ans1+MOD-1,ans1 %= MOD;\r\n n--;\r\n LLI ans2 = dp[n-1];\r\n ans2 += (((dp[n-1]*(dp[n-1]+1)) % MOD)*INV2) % MOD;\r\n ans2 += (((((dp[n-1]*(dp[n-1]+1)) % MOD)*(dp[n-1]+2)) % MOD)*INV6) % MOD;\r\n ans2 %= MOD;\r\n ans2 = 2*ans2+MOD,ans2 %= MOD;\r\n LLI ans = (ans1-ans2+MOD) % MOD;\r\n n++;\r\n vi a(n+1);\r\n for (i = 1; i <= n; i++) a[i] = (((dp[i-1]*(dp[i-1]+1)) % MOD)*INV2) % MOD;\r\n for (i = n; i >= 1; i--) a[i] = (a[i]-a[i-1]+MOD) % MOD;\r\n NTT::setBase(22);\r\n vi p = NTT::multiply(a,a);\r\n if (n >= 3) {\r\n for (i = 1; i < n-1; i++) ans += p[n-i],ans %= MOD;\r\n }\r\n\r\n cout << ans << endl;\r\n\r\n return 0;\r\n}\r\n\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "021af263ef11ba96c9b71bf23d930095", "src_uid": "92939054045c089cd25c8f4e7b9ffcf2", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include\n#define ll long long\nusing namespace std;\nint main()\n{\n\tll n;\n\tcin>>n;\n\n\n\t if(n==1)\n\t cout<<\"1\"<<\"\\n\";\n\t else if(n==2)\n\t cout<<\"5\"<<\"\\n\";\n\t else\n\t {\n\t \t\tvectorv;\n\t \t\tv.push_back(1);\n\t\tv.push_back(2);\n\t\tv.push_back(3);\n\t for(ll i=3;i<=100;i++)\n\t {\n\t \tv[i]=v[i-1]+2;\n\t }\n\t ll sum=v[n-1]*v[n-1];\n\t \tcout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define all(v) v.begin(),v.end()\ntypedef long long int ll;\n\nint OrdrOfRhombus(int n)\n{\n\tif(n==1)\n\t\treturn 1;\n\telse\n\t\treturn OrdrOfRhombus(n-1)+pow(2,n);\n}\n\nvoid solve()\n{\n\tint n; cin>>n;\n\n\tint order = OrdrOfRhombus(n);\n\n\tcout<>t;\n while(t--)\n solve();\n \n return 0;\n }\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8716406deb5b3b48f908e9ba9eb1f5a0", "src_uid": "758d342c1badde6d0b4db81285be780c", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\nint main()\n{\n int t;\n cin >> t;\n while(t--)\n {\n int n;\n unsigned long long int iter = 2;\n cin >> n;\n vector arr;\n arr.push_back(1);\n \n for(int i = 1; i < n; i++)\n {\n\t\t\tlong value = arr[i-1] + (iter * 2);\n arr.push_back(value);\n\t\t\titer+=2;\n }\n cout << arr[n-1] << endl;\n }\n \n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5925249ee6a4ebc1d41725b7ccb96f83", "src_uid": "758d342c1badde6d0b4db81285be780c", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\n\nint n,f[100000000];\nint qqq(int a){\n\tif(a==1) return f[a]=1;\n\tf[a]=qqq(a-1)+4*a-4;\n\treturn f[a];\n}\nint main(){\n\tstd::cin>>n;\n\tstd::cout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define Max(a,b) ((a)>(b)?(a):(b))\n#define Min(a,b) ((a)<(b)?(a):(b))\nusing namespace std;\ntypedef long long ll;\nconst double PI = acos(-1.0);\nconst double eps = 1e-6;\nconst int mod = 1000000000 + 7;\nconst int INF = 1000000000;\nconst int maxn = 200 + 10;\nint T,n,m;\nchar s[maxn], name;\nstruct node {\n int B, G, R;\n node(int b=0, int g=0, int r=0):B(b),G(g),R(r) {}\n}S;\nmap p;\nvoid BFS() {\n queue q;\n q.push(S);\n p.clear();\n int cnt = 0;\n while(!q.empty()) {\n node u = q.front(); q.pop();\n // printf(\"%d %d %d\\n\",u.B,u.G,u.R);\n if(u.B == 1 && u.G == 0 && u.R == 0) {\n if(p.count(int('B'-'A'))) ;\n else {\n p[int('B'-'A')] = 1; ++cnt;\n }\n continue;\n }\n else if(u.G == 1 && u.B == 0 && u.R == 0) {\n if(p.count((int)('G'-'A'))) ;\n else {\n p[((int)('G'-'A'))] = 1;++cnt;\n }continue;\n }\n else if(u.R == 1 && u.B == 0 && u.G == 0) {\n if(p.count((int)('R'-'A'))) ;\n else { p[((int)('R'-'A'))] = 1;++cnt;} continue;\n }\n if(cnt == 3) return ;\n for(int i=0;i<3;i++) {\n for(int j=0;j<3;j++) {\n if(i == j) {\n if(i == 0 && u.B >= 2) q.push(node(u.B-1,u.G,u.R));\n else if(i == 1 && u.G >= 2) q.push(node(u.B,u.G-1,u.R));\n else if(i == 2 && u.R >= 2) q.push(node(u.B, u.G, u.R-1));\n }\n else {\n if(i == 0 && j == 1 && u.B >= 1 && u.G >= 1) q.push(node(u.B-1,u.G-1,u.R+1));\n else if(i==0&&j==2&&u.B>=1&&u.R>=1) q.push(node(u.B-1,u.G+1,u.R-1));\n else if(i==1&&j==2&&u.G>=1&&u.R>=1) q.push(node(u.B+1,u.G-1,u.R-1));\n }\n }\n }\n }\n}\n\nint main() {\n scanf(\"%d%s\",&n,s);\n S = node(0, 0, 0);\n for(int i=0;i 2 && S.G > 2 && S.R > 2) {\n printf(\"BGR\\n\"); return 0;\n }\n BFS();\n for(int i=0;i<3;i++) {\n if(i == 0) {\n if(p.count('B'-'A')) printf(\"%c\",'B');\n }\n else if(i == 1) {\n if(p.count('G'-'A')) printf(\"%c\",'G');\n }\n else if(i == 2) {\n if(p.count('R'-'A')) printf(\"%c\",'R');\n }\n }\n printf(\"\\n\");\n return 0;\n}\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bbfed448d9210a2c61620836643eb724", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "/** coder Mohammad Al-Hussein *_^ */\n#include \n#define ll long long\n#define F first\n#define S second\n#define mp make_pair\n#define mod 1000000007\nusing namespace std;\nint R,G,B;\nint dp[201][201][201];\nvector v;\nvoid solve (int r,int g,int b)\n{\n if(r+g+b == 1)\n {\n if(r) v.push_back('R');\n if(g) v.push_back('G');\n if(b) v.push_back('B');\n return ;\n }\n if(r > 1) solve(r-1,g,b);\n if(g > 1) solve(r,g-1,b);\n if(b > 1) solve(r,g,b-1);\n\n if(r > 0 && g > 0) solve(r-1,g-1,b+1);\n if(r > 0 && b > 0) solve(r-1,g+1,b-1);\n if(g > 0 && b > 0) solve(r+1,g-1,b-1);\n}\n\nint main()\n{\n //memset(dp,-1,sizeof(dp));\n int n;\n cin >> n;\n for(int i=0; i> x;\n R += (x == 'R');\n G += (x == 'G');\n B += (x == 'B');\n }\n solve(R,G,B);\n for(int i=0;i\nusing namespace std;\n\nstruct sadek\n{\n short p;\n short q;\n short r;\n};\nbool a1,a2,a3;\nint n,i;\nint x,y,z;\nqueuequ;\nstring s;\nint main()\n{\n cin>>n>>s;\n for(i=0;i1)\n {\n sadek qq;\n qq.p=pp.p-1;\n qq.q=pp.q;\n qq.r=pp.r;\n qu.push(qq);\n }\n if(pp.q>1)\n {\n sadek qq;\n qq.p=pp.p;\n qq.q=pp.q-1;\n qq.r=pp.r;\n qu.push(qq);\n }\n if(pp.r>1)\n {\n sadek qq;\n qq.p=pp.p;\n qq.q=pp.q;\n qq.r=pp.r-1;\n qu.push(qq);\n }\n if(pp.p>0 && pp.q>0)\n {\n sadek qq;\n qq.p=pp.p-1;\n qq.q=pp.q-1;\n qq.r=pp.r+1;\n qu.push(qq);\n }\n if(pp.p>0 && pp.r>0)\n {\n sadek qq;\n qq.p=pp.p-1;\n qq.q=pp.q+1;\n qq.r=pp.r-1;\n qu.push(qq);\n }\n if(pp.q>0 && pp.r>0)\n {\n sadek qq;\n qq.p=pp.p+1;\n qq.q=pp.q-1;\n qq.r=pp.r-1;\n qu.push(qq);\n }\n if(pp.p==0 && pp.q==0)\n a3=true;\n else if(pp.p==0 && pp.r==0)\n a2=true;\n else if(pp.q==0 && pp.r==0)\n a1=true;\n }\n if(a1)\n putchar('B');\n if(a2)\n putchar('G');\n if(a3)\n putchar('R');\n cout<\n#include\n#include\n#include\n#include\n#include\n#include \n#include\n#include\n#include\n#include\n#include\n#include\n#include\t\n#include\n#include\n#include\n#include\t\n#include\nusing namespace std;\n\n#define rep(i,n) for(int i=0;i vi;\ntypedef pair ii;\ntypedef long double ld;\n\n\n\nint main(){\n\t//read; write;\n\n\tchar c;; int n;\n\tcin >> n;\n\tvi v(3, 0);\n\trep(i, n){\n\t\tcin >> c;\n\t\tif (c == 'R')v[0]++;\n\t\telse if (c == 'G')v[1]++;\n\t\telse v[2]++;\n\t}\n\tif (v[0] && v[1] && v[2]) cout << \"BGR\";\n\telse if (n == 2){\n\t\tif (v[0] && v[1]) cout << \"B\";\n\t\telse if (v[0] && v[2])cout << \"G\";\n\t\telse if (v[2] && v[1])cout << \"R\";\n\t\telse if (v[0])cout << \"R\";\n\t\telse if (v[1])cout << \"G\";\n\t\telse cout << \"B\";\n\t}\n\telse if (v[0] && v[1]) {\n\t\tif (v[0]>1 && v[1]>1)cout << \"BGR\";\n\t\telse if (v[0] > 1)cout << \"BG\";\n\t\telse cout << \"BR\";\n\t}\n\telse if (v[0] && v[2]) {\n\t\tif (v[0]>1 && v[2]>1)cout << \"BGR\";\n\t\telse if (v[0] > 1)cout << \"BG\";\n\t\telse cout << \"GR\";\n\t}\n\telse if (v[1] && v[2]) {\n\t\tif (v[1]>1 && v[2]>1)cout << \"BGR\";\n\t\telse if (v[1] > 1)cout << \"BGR\";\n\t\telse cout << \"GR\";\n\t}\n\n\telse if (v[0])cout << \"R\";\n\telse if (v[1])cout << \"G\";\n\telse cout << \"B\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b8fff7dc464b4fba18500f00c0fa36e2", "src_uid": "4cedd3b70d793bc8ed4a93fc5a827f8f", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nconst int maxn=1e6+10;\nint p[maxn];\nint f[maxn];\nint cnt;\nvoid init(){\n int i,j;\n cnt=0;\n for(i=2;iv[maxn];\nint main(){\n int i,j;\n int k;\n ios::sync_with_stdio(0);\n init();\n for(i=2;i=i) break;\n v[i].push_back(j);\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f3de1dcf9d7aefe9b519dedcc9bdcf4a", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include \n#include\n#include\n#define maxn 505\n#define MAX 1000010//\ufffd\ufffdMAX\ufffd\ufffd\u03a7\ufffd\u06b5\ufffd\ufffd\ufffd\ufffd\ufffd\nusing namespace std;\nlong long su[MAX],cnt;\nbool isprime[MAX];\nvoid prime()\n{\n cnt=1;\n memset(isprime,1,sizeof(isprime));//\ufffd\ufffd\u02bc\ufffd\ufffd\ufffd\ufffd\u03aa\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u03aa\ufffd\ufffd\ufffd\ufffd\n isprime[0]=isprime[1]=0;//0\ufffd\ufffd1\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n for(long long i=2;i<=MAX;i++)\n {\n if(isprime[i])//\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n {\n su[cnt++]=i;\n }\n for(long long j=i*2;j<=MAX;j+=i)//\ufffd\ufffd\ufffd\ufffd\ufffd\u0131\ufffd\ufffd\ufffd\ufffd\ufffd\u03aa\ufffd\ufffd\ufffd\ufffd\n {\n isprime[j]=0;\n }\n }\n}\n\n\nint main()\n{\n int n;\n prime();\n scanf(\"%d\", &n);\n int maxx = 0, m = MAX;\n for(int i = 1; su[i] < n; ++i)\n {\n if(n % su[i] == 0)\n maxx = su[i];\n }\n for(int i = maxx * (n / maxx - 1) + 1; i <= n; ++i)\n {\n int f = MAX;\n for(int j = 2; j * j < i; ++j)\n if(i % j == 0)\n {\n if(isprime[j] == 1)\n if((i / j - 1) * j < i)\n {\n if(f > (i / j - 1) * j + 1)\n f = (i / j - 1) * j + 1;\n }\n int k = i / j;\n if(isprime[k] == 1)\n if((i / k - 1) * k < i)\n {\n if(f > (i / k - 1) * k + 1)\n f = (i / k - 1) * k + 1;\n }\n }\n if(f < m)\n m = f;\n }\n printf(\"%d\", m);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b3b276ad607fcc899da64c8092789c47", "src_uid": "43ff6a223c68551eff793ba170110438", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include \n #define int long long\n#define F first.first\n#define S first.second\n#define N second\nusing namespace std;\n\nconst int nmax=1001000;\n\n\nmain()\n{\n int n;\n cin>>n;\n vector prime;\n prime.resize(n+10);\n for (int i=0; i<=n; i++)\n prime[i]=true;\n prime[0] = false;\n prime[1] = false;\n for (int i=2; i<=n; ++i)\n if (prime[i])\n if (i * i <= n)\n for (int j=i*i; j<=n; j+=i)\n {\n prime[j] = false;\n }\n // for (int i=1; i<=n; ++i)\n // if(prime[i])\n // cout<=1; j--)\n {\n //cout<<\"lol\";\n if ((n%j==0) and (prime[j]))\n break;\n }\n else j=n/j;\n j=n-j+1;\n //cout<\nusing namespace std;\ntypedef long long int ll;\nint prime[1100000];\nvector v;\nvoid init()\n{\n\tprime[1] = 1;\n\tfor (ll i = 2; i <= 1000000; i++)\n\t{\n\t\tif (!prime[i])\n\t\t{\n\t\t\tfor (ll j = i*i; j <= 1000000; j += i)\n\t\t\t{\n\t\t\t\tprime[j] = 1;\n\t\t\t}\n\t\t\tv.push_back(i);\n\t\t}\n\t}\n}\nint main()\n{\n\tios::sync_with_stdio(false); cin.tie(0);\n\tll x;\n\tcin>>x;\n\tll orgx = x;\n\tinit();\n\tvector minim;\n\tfor (int i = 0; i < v.size(); i++)\n\t{\n\t\tif (x == 1)\n\t\t\tbreak;\n\t\tif (x % v[i] == 0)\n\t\t{\n\t\t\tminim.push_back(v[i]);\n\t\t\twhile(x % v[i] == 0)\n\t\t\t\tx /= v[i];\n\t\t}\n\t}\n\n\tint l = orgx-minim[minim.size()-1]+1, r = orgx-1;\n\tint minim1 = l;\n\tfor (int i = l; i <= r; i++)\n\t{\n\t\tll curr = i;\n\t\tfor (int j = 2; j <= i; j++)\n\t\t{\n\t\t\tif (j*j > i)\n\t\t\t\tbreak;\n\t\t\tif (!prime[j] and curr%j == 0)\n\t\t\t{\n\t\t\t\tminim1 = min(minim1, i-j+1);\n\t\t\t\tint div = curr/j;\n\t\t\t\twhile (curr % j == 0)\n\t\t\t\t\tcurr /= j;\n\t\t\t\tif (prime[div] == 0)\n\t\t\t\t{\n\t\t\t\t\tminim1 = min(minim1, i-div+1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tcout<\n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main() {\n //freopen(\"in.txt\", \"r\", stdin);\n //freopen(\"out.txt\", \"w\", stdout);\n\n int tmp;\n map m;\n for (int i = 0; i < 6; i++) {\n cin >> tmp;\n if (m.count(tmp) == 0) {\n m[tmp] = 1;\n } else {\n m[tmp]++;\n }\n }\n\n int el;\n int cnt;\n bool ok = false;\n for (auto e : m) {\n if (e.second >= 4) {\n el = e.first;\n cnt = e.second;\n ok = true;\n break;\n }\n }\n\n if (!ok) {\n cout << \"Alien\" << endl;\n return 0;\n }\n\n int a = -1, b = -1;\n for (auto e : m) {\n if (e.first != el) {\n if (a == -1 && e.second == 1) {\n a = e.first;\n continue;\n }\n if (b == -1 && e.second == 1) {\n b = e.first;\n continue;\n }\n if (e.second == 2) {\n a = b = e.first;\n continue;\n }\n }\n }\n\n switch (cnt) {\n case 4:\n if (a == b) {\n cout << \"Elephant\" << endl;\n } else {\n cout << \"Bear\" << endl;\n }\n break;\n case 5:\n if (a < el) {\n cout << \"Bear\" << endl;\n } else {\n cout << \"Alien\" << endl;\n }\n break;\n case 6:\n cout << \"Elephant\" << endl;\n }\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a0d869c0ce9cb15629ed3bcc0566c3d1", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include\n#include\n#include\n#pragma warning(disable: 4996)\nusing namespace std;\ntypedef long long ll;\nint main()\n{\n int n;\n\n map m;\n for(int i=0;i<6;i++)\n {\n int tmp;\n cin>>tmp;\n m[tmp]++;\n }\n bool legs=false;\n for(map::iterator it=m.begin();it!=m.end();it++)\n {\n if(it->second>=4)\n legs=true;\n }\n if(legs&&m.size()<=2)\n cout<<\"Elephant\\n\";\n else if(legs&&m.size()==3)\n cout<<\"Bear\\n\";\n else\n cout<<\"Alien\\n\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4a9c31c2081cbd64ebf00cc493a3fe79", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100.0} {"lang": "GNU C++0x", "source_code": "#include \n\nusing namespace std;\n\nint a[111], x, y, X, z;\n\nint main ()\n{\n for (int i = 1; i <= 6; ++ i){\n cin >> X;\n a[X] ++;\n }\n\n for (int i = 0; i <= 10; ++ i)\n {\n if (a[i] == 4)\n x ++;\n if (a[i] == 2)\n y ++;\n if (a[i] == 6)\n z ++;\n }\n if (y == 1 && x == 1 || z == 1)\n cout << \"Elephant\";\n else if (x == 1)\n cout << \"Bear\";\n else\n cout << \"Alien\";\nreturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d088f950490d1bf27f27cc2fed461c7c", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n#define print1(a) cout<\n#define VI vector\n#define VD vector\n#define VLL vector\n#define SII set::iterator\n#define SI set\n#define mem(a,b) memset(a,b,sizeof(a))\n#define fr(i,a,b) for(i=a;i<=b;i++)\n#define frn(i,a,b) for(i=a;i>=b;i--)\n#define fri(a,b) for(i=a;i<=b;i++)\n#define frin(a,b) for(i=a;i>=b;i--)\n#define frj(a,b) for(j=a;j<=b;j++)\n#define frjn(a,b) for(j=a;j>=b;j--)\n#define frk(a,b) for(k=a;k<=b;k++)\n#define frkn(a,b) for(k=a;k>=b;k--)\n#define frl(a,b) for(l=a;l<=b;l++)\n#define frln(a,b) for(l=a;l>=b;l--)\n#define REP(i,n) for(i=0;i>n\n#define inpow(a,x,y) int i; a=x;fri(2,y) a*=x\n#define cntbit(mask) __builtin_popcountll(mask)\n//0 based print\n#define debug_array(a,n) for(int i=0;i void debug(T1 e){cout< void debug(T1 e1,T2 e2){cout< void debug(T1 e1,T2 e2,T3 e3){cout< void debug(T1 e1,T2 e2,T3 e3,T4 e4){cout< void debug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout< void debug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){cout< void debug(vector< vector > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout< void debug(vector< basic_string > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout< void debug(T e[110][110],int row,int col){int i,j;REP(i,row) {REP(j,col) cout< string toString(T n){ostringstream oss;oss<>r;return r;}\nbool isVowel(char ch){ch=tolower(ch);if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')return true;return false;}\nbool isUpper(char c){return c>='A' && c<='Z';}\nbool isLower(char c){return c>='a' && c<='z';}\n/***************************************************code starts from here*************************************************************************************************/\n\n\nint main()\n{\n int i;\n int type1,type2,t1,t2,t3;\n type1=-1;\n int n;\n int type3=0;\n int flag=0;\n type2=-1;\n t1=0;\n t2=0;\n t3=0;\n int diff=0;\n int arr[100];\n mem(arr,0);\n fr(i,1,6)\n {\n scanf(\"%d\",&n);\n if(arr[n]==0)\n {\n diff++;\n arr[n]=1;\n }\n }\n if(diff==2 || diff==1)\n {\n printf(\"Elephant\\n\");\n }\n else if(diff==3)\n {\n printf(\"Bear\\n\");\n }\n else if(diff>3)\n {\n printf(\"Alien\\n\");\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "485985f13734ae9fa897d8c31c649e9c", "src_uid": "43308fa25e8578fd9f25328e715d4dd6", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nint main()\n{\n\tint a,b;\n\tcin>>a>>b;\n\tint y=abs(b-a);\n\tint z=1;\n\tint c=0;\n\tif(y%2==0)\n\t{\n\tfor (int i = 0; i < y/2; i++)\n\t{\n\t\tc=c+(z*2);\n\t\tz++;\n\n\t}\n\t}\n\telse if(y%2==1)\n\t{\n\t\n\tfor (int i = 0; i < (y/2); i++)\n\t{\n\t\tc=c+(z*2);\n\t\tz++;\n\n\t}\n\tc=c+z;\n\t\n\t\n\t}\n\tcout<\nusing namespace std;\n\nlong long k,n,s,p;\n\nlong long cl(long long a, long long b){\n return (a + b - 1)/b;\n}\n\nint main(){\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n\n cin >> k >> n >> s >> p;\n cout << cl(k * cl(n,s), p) << '\\n';\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "43691316223a26c5f965cf99d007c2e8", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n\tint a, b;\n\tcin >> a >> b;\n\tint max, min;\n\tif (a > b) { max = a; min = b; }\n\telse { max = b; min = a; }\n\n\tint tired1 = 0; int tired2 = 0; int i = 1; int j = 1;\n\tdo {\n\t\tmax--; tired1 = tired1 + i; i++;\n\t\tif ((max - min) != 0) { min++; tired2 = tired2 + j; j++; }\n\t\telse { cout << tired1 + tired2;\n\t\treturn tired1 + tired2; };\n\t} while ((max - min) != 0);\n\t\n\tcout << tired1 + tired2;\n\treturn tired1 + tired2;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "905bb8de3dc50d5d7dbb05e581a80f73", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\nint main()\n{\n int a, b, dif, k, ans = 0;\n cin >> a >> b;\n dif = abs(a - b);\n if(dif == 1)\n {\n cout << 1 << endl;\n return 0;\n }\n if(dif == 2)\n {\n cout << 2 << endl;\n return 0;\n }\n if(dif % 2 == 0)\n {\n k = dif / 2;\n for(int i = 1; i <= k; i++)\n {\n ans += i;\n cout << ans <\n#define loop(i,a,b) for(int i=a;i a )\n a = b;\n else if ( a == 1 )\n printf(\"1/1\");\n else if ( a == 2 )\n printf(\"5/6\");\n else if ( a == 3 )\n printf(\"2/3\");\n else if ( a == 4 )\n printf(\"1/2\");\n else if ( a == 5 )\n printf(\"1/3\");\n else if ( a == 6 )\n printf(\"1/6\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ff5dd1af1c8e72df653fb1bb0f1f4e9d", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0} {"lang": "MS C++", "source_code": "// A. \u0411\u0440\u043e\u0441\u043e\u043a \u043a\u0443\u0431\u0438\u043a\u0430\n#include \n#define loop(i,a,b) for(int i=a;i a )\n a = b;\n else if ( a == 1 )\n printf(\"1/1\");\n else if ( a == 2 )\n printf(\"5/6\");\n else if ( a == 3 )\n printf(\"2/3\");\n else if ( a == 4 )\n printf(\"1/2\");\n else if ( a == 5 )\n printf(\"1/3\");\n else \n printf(\"1/6\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "10970438fe580f4c8ae012f61998a9e5", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \nusing namespace std;\n#define maxn 1000\n#include \n\nint gcd(int a,int b)\n{\n\tif ((a==0) || (b==0)) return a+b;\n\tif (a>b)\n\treturn gcd(a%b,b);\n\treturn gcd(a,b%a);\n}\nint main()\n{\n\tint y,w;\n\tcin>>y>>w;\n\tint t=6-max(y,w)+1;\n\tif (t==6) cout<<\"1/1\"<\n#define loop(i,a,b) for(int i=a;i a )\n {\n t = a;\n a = b;\n b = t;\n }\n if ( b == a )\n --a;\n else if ( a == 1 )\n printf(\"1/1\");\n else if ( a == 2 )\n printf(\"5/6\");\n else if ( a == 3 )\n printf(\"2/3\");\n else if ( a == 4 )\n printf(\"1/2\");\n else if ( a == 5 )\n printf(\"1/3\");\n else \n printf(\"1/6\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "26bc3568ed88c56bcd0e7507d23c01be", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\n\nlong long res,a[3];\nint main()\n{\n\tlong long r, b, g;\n\tcin >> r >> g >> b;\n\tres += r / 3 + g / 3 + b / 3;\n\ta[0] = r % 3;\n\ta[1] = g % 3;\n\ta[2] = b % 3;\n\tsort(a, a + 3);\n\tres += a[0];\n\tcout << res << endl;\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "518faea203eae818976b08f60a156938", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\nvector AllChances;\nint main()\n{\n int a,b,c;\n cin >> a >> b >> c;\n int Remain = 0;\n while(a > 0 && b > 0 && c > 0)\n {\n AllChances.push_back(a / 3 + b / 3 + c/3 + Remain);\n a--;\n b--;\n c--;\n Remain++;\n }\n if(AllChances.size() != 0)\n cout << *max_element(AllChances.begin(),AllChances.end());\n else\n cout << a/3 + b/3 + c/3;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4350e7d5805949d9d72b7f8b92924fac", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nmap < pair>, int>dp;\nint rgb(int r, int g, int b){\n\tif ((r == 0 && g < 3 && b < 3) || (g == 0 && r < 3 && b < 3) || (b == 0 && g < 3 && r < 3))\n\t\treturn 0;\n\tif (dp.find({ r, { g, b } }) != dp.end()) {\n\t\treturn dp[{r, { g, b }}];\n\t}\n\tint w = 0;\n\tif (r - 3 >= 0)\n\t\tw = rgb(r - 3, g, b) + 1;\n\tif (g - 3 >= 0)\n\t\tw = dp[{r, { g, b }}]= max(w, rgb(r, g - 3, b) + 1);\n\tif (b - 3 >= 0)\n\t\tw = dp[{r, { g, b }}]= max(w, rgb(r, g, b - 3) + 1);\n\tif (r - 1 >= 0 && b - 1 >= 0 && g - 1 >= 0)\n\t\tw = dp[{r, { g, b }}]= max(w, rgb(r - 1, g - 1, b - 1) + 1);\n\treturn w;\n}\n\nint main(){\n\n\tint r, g, b;\n\tcin >> r >> g >> b;\n\tcout << rgb(r, g, b) << endl;\n\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "31806d326415f084987ab6b0409eb323", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include\n#include\n\nint main()\n{\n int r,g,b,x,y,z,dem,min;\n scanf(\"%d %d %d\",&r,&g,&b);\n dem=0;\n dem=dem+(r/3)+(g/3)+(b/3);\n x=r%3;\n y=g%3;\n z=b%3;\n min=x;\n if(y0&&y==2&&z==2||g>0&&x==2&&z==2||b>0&&x==2&&y==2)\n dem++;\n printf(\"%d\",dem);\ngetch();\nreturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cead41b72cf8eb07384b56c432d68af4", "src_uid": "acddc9b0db312b363910a84bd4f14d8e", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n\nint main() {\n int ans=0;\n while(1)\n {\n int a;\n cin>>a;\n ans++;\n if(a==2)\n {\n cout<\nusing namespace std ;\n\nint main() {\n while( 1 ) {\n int a , b , c , d , e ;\n cin >> a >> b >> c >> d >> e ;\n cout << min( a , min ( b , min ( min ( c/2 , d/7 ) , e/4 ) ) ) << endl ;\n }\n return 0 ;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2cad6db1af57c564863604bbb97a0a52", "src_uid": "f914f9b7884cc04b990c7800c6be7b10", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \n\nint main()\n{\n int a,b;\n scanf(\"%d\",&b);\n bool ok = true;\n while(scanf(\"%d\",&a))\n {\n if (a-b != 2)\n ok =false;\n b = a;\n }\n printf(\"%d\\n\",ok);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b7e8572393f93ea013c18ebab7f2396f", "src_uid": "f914f9b7884cc04b990c7800c6be7b10", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \nint main()\n{\n long long a,b,c,d,e,sum;\n scanf(\"%d %d %d %d %d\",&a,&b,&c,&d,&e);\n while (a>=1 && b>=1 && c>=2 && d>=7 && e>=4)\n {\n sum++;\n a-=1;\n b-=1;\n c-=2;\n d-=7;\n e-=4;\n }\n printf(\"%d\",sum);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0f7f132b599b2f2f0ebca19539d2a3db", "src_uid": "f914f9b7884cc04b990c7800c6be7b10", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#define int long long\n#define bgint __int128\nusing namespace std;\n \nconst int MAX_NOEUDS = (100 * 1000);\n \nstruct ratio {\n bgint num, denom;\n void Print() {\n // printf(\"%lld %lld\\n\", num, denom);\n }\n};\n \nstruct pente {\n int quart;\n ratio acc;\n void Print() {\n // printf(\"%lld \", quart);\n acc.Print();\n }\n};\n \nstruct bottle {\n ratio salt, pepper;\n pente angle;\n void Print() {\n printf(\"b \");\n salt.Print();\n pepper.Print();\n angle.Print();\n printf(\"\\n\\n\");\n }\n};\n \nset Pentes;\n \nmap Occurences;\n \nint nbExacts = 0;\nint nbPaires = 0;\nint nbAct = 0;\nbool isIn = false;\n \nbottle Entree[MAX_NOEUDS];\n \nbottle cible;\nint nbRequetes;\n \nbgint Pgcd(bgint a, bgint b) {\n if (b == 0)\n {\n return a;\n }\n return Pgcd(b, a % b);\n}\n \nratio Simp(ratio a) {\n bgint d = Pgcd(max(a.num, - a.num), max(a.denom, - a.denom));\n d = max(d, -d);\n if (a.denom < 0)\n {\n a.num *= -1;\n a.denom *= -1;\n }\n return {a.num / d, a.denom / d};\n}\n \nratio operator+(ratio const& a, ratio const& b) {\n return Simp({a.num * b.denom + b.num * a.denom, a.denom * b.denom});\n}\n \nratio operator*(ratio const& a, ratio const& b) {\n return Simp({a.num * b.num, a.denom * b.denom});\n}\n \nratio operator-(ratio const& a, ratio const& b) {\n return Simp({a.num * b.denom - b.num * a.denom, a.denom * b.denom});\n}\n \nbool operator>(ratio const& a, ratio const& b) {\n return a.num * b.denom > a.denom * b.num;\n}\n \nbool operator<(ratio const& a, ratio const& b) {\n return a.num * b.denom < a.denom * b.num;\n}\n \nbool operator<(pente const& a, pente const& b) {\n if (a.quart < b.quart)\n {\n return true;\n }\n if (a.quart > b.quart)\n {\n return false;\n }\n return a.acc > b.acc;\n}\n \npente CalculePente(bottle a) {\n ratio h = a.salt - cible.salt;\n ratio v = a.pepper - cible.pepper;\n if (h.num == 0 && v.num == 0)\n {\n return {-1, {1, 1}};\n }\n if (h.num == 0)\n {\n if (v.num > 0)\n {\n return {0, {1, 0}};\n }\n return {2, {1, 0}};\n }\n if (v.num == 0)\n {\n if (h.num > 0)\n {\n return {1, {1, 0}};\n }\n return {3, {1, 0}};\n }\n if (h.num > 0 && v.num < 0)\n {\n v.num *= -1;\n return {1, Simp({h.num * v.denom, h.denom * v.num})};\n }\n if (h.num < 0 && v.num < 0)\n {\n h.num *= -1;\n v.num *= -1;\n return {2, Simp({v.num * h.denom, v.denom * h.num})};\n }\n if (h.num < 0 && v.num > 0)\n {\n h.num *= -1;\n return {3, Simp({h.num * v.denom, h.denom * v.num})};\n }\n return {0, Simp({v.num * h.denom, v.denom * h.num})};\n}\n \nbool IsOver180(pente a, pente b) {\n if (b < a)\n {\n //printf(\"666 ERROR\\n\");\n //a.Print();\n //b.Print();\n return !IsOver180(b, a);\n }\n else\n {\n //printf(\"noice\\n\");\n }\n if (b.quart - a.quart == 3)\n {\n return true;\n }\n if (b.quart - a.quart == 2 && b.acc < a.acc)\n {\n return true;\n }\n return false;\n}\n \nvoid CheckAllAngles() {\n bool t = true;\n set::iterator it;\n for (it = Pentes.begin(); it != Pentes.end(); it ++)\n {\n // printf(\"%lld \", (*it).quart);\n }\n printf(\"\\n\");\n return;\n for (it = Pentes.begin(); it != Pentes.end(); it ++)\n {\n set::iterator next = it;\n next ++;\n if (next == Pentes.end())\n {\n next = Pentes.begin();\n }\n if (IsOver180(*it, *next))\n {\n t = false;\n }\n }\n isIn = t;\n return;\n}\n \nvoid Read() {\n int a, b, c;\n cin >> a >> b >> c;\n //scanf(\"%lld%lld%lld\", &a, &b, &c);\n a = (bgint)a;\n b = (bgint)b;\n c = (bgint)c;\n cible.salt = Simp({a, a + b + c});\n cible.pepper = Simp({b, a + b + c});\n cin >> nbRequetes;\n //scanf(\"%lld\", &nbRequetes);\n return;\n}\n \nvoid Add(bottle a) {\n pente act = a.angle;\n if (act.quart < 0)\n {\n nbExacts ++;\n return;\n }\n Occurences[act] ++;\n pente opp = {(act.quart + 2) % 4, act.acc};\n nbPaires += Occurences[opp];\n if (Occurences[act] == 1)\n {\n Pentes.insert(act);\n set::iterator nv = Pentes.find(act);\n set::iterator prev = nv;\n if (prev == Pentes.begin())\n {\n prev = Pentes.end();\n }\n prev --;\n set::iterator next = nv;\n next ++;\n if (next == Pentes.end())\n {\n next = Pentes.begin();\n }\n nbAct ++;\n if (IsOver180(*prev, *next))\n {\n isIn = true;\n }\n if (IsOver180(*prev, *nv))\n {\n isIn = false;\n }\n if (IsOver180(*nv, *next))\n {\n isIn = false;\n }\n }\n return;\n}\n \nvoid Delete(bottle a) {\n pente act = a.angle;\n if (act.quart < 0)\n {\n nbExacts --;\n return;\n }\n Occurences[act] --;\n pente opp = {(act.quart + 2) % 4, act.acc};\n nbPaires -= Occurences[opp];\n if (Occurences[act] == 0)\n {\n set::iterator nv = Pentes.find(act);\n set::iterator prev = nv;\n if (prev == Pentes.begin())\n {\n prev = Pentes.end();\n }\n prev --;\n set::iterator next = nv;\n next ++;\n if (next == Pentes.end())\n {\n next = Pentes.begin();\n }\n if (IsOver180(*prev, *nv))\n {\n isIn = true;\n }\n if (IsOver180(*nv, *next))\n {\n isIn = true;\n }\n Pentes.erase(nv);\n nbAct --;\n if (nbAct < 1)\n {\n return;\n }\n if (IsOver180(*prev, *next))\n {\n isIn = false;\n }\n }\n return;\n}\n \nint FindMin() {\n if (nbExacts > 0)\n {\n return 1;\n }\n if (nbPaires > 0)\n {\n return 2;\n }\n if (nbAct >= 3 && isIn)\n {\n return 3;\n }\n return 0;\n}\n \nvoid Solve() {\n int nb = 0;\n for (int i = 0; i < nbRequetes; i ++)\n {\n char c;\n //scanf(\" %c\", &c);\n cin >> c;\n if (c == 'A')\n {\n int a, b, c;\n //scanf(\"%lld%lld%lld\", &a, &b, &c);\n cin >> a >> b >> c;\n a = (bgint)a;\n b = (bgint)b;\n c = (bgint)c;\n Entree[nb].salt = Simp({a, a + b + c});\n Entree[nb].pepper = Simp({b, a + b + c});\n Entree[nb].angle = CalculePente(Entree[nb]);\n Add(Entree[nb ++]);\n }\n if (c == 'R')\n {\n int a;\n //scanf(\"%lld\", &a);\n cin >> a;\n Delete(Entree[a - 1]);\n }\n cout << FindMin() << '\\n';\n //printf(\"%lld\\n\", FindMin());\n }\n}\n \nsigned main() {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n Read();\n Solve();\n //PRINT();\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1b0bb280976964f182e04d382df44461", "src_uid": "ea995d5c5fe84cd175cda0d0e2f01889", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair pii;\nconst int inf = 0x3f3f3f3f;\n#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)\n#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)\n#define rep(i,a,b) for(register int i=(a);i point;\ndb eps = 1e-10;\nint dcmp(db a){\n\tif(a < -eps) return -1;\n\tif(a > eps) return 1;\n\treturn 0;\n}\npoint get(int x,int y,int z){\n\tdb len = 1000000.0 / (x+y+z);\n\treturn point(x*len,y*len);\n}\n\nstruct cmp{\n bool operator()(db a,db b){\n\t\treturn dcmp(a-b) < 0;\n }\n};\nmultiset s0,s1;\nint cnt = 0,cnt1 = 0;\ndb deg[maxn];\npoint p[maxn];\nbool has(multiset &s,db deg){\n\treturn s.find(deg) != s.end();\n}\nint main(){\n//\tfreopen(\"1.in\",\"r\",stdin);\n\tdb x0 = read(),y0 = read(),z0 = read();\n\tpoint p0 = get(x0,y0,z0);\n\tint t = 0;\n\tint Q = read();\n\twhile(Q--){\n\t\tchar c = gc();\n\t\twhile(c!='A'&&c!='R')c=gc();\n\t\tif(c=='A'){\n\t\t\tdb _x = read(),_y = read(),_z = read();\n\t\t\t++t;\n\t\t\tp[t] = get(_x,_y,_z);\n\t\t\tp[t].fi -= p0.fi;\n\t\t\tp[t].se -= p0.se;\n//\t\t\tprintf(\"%lf %lf\\n\",p[t].fi,p[t].se);\n\t\t\tif(dcmp(p[t].fi)==0 && dcmp(p[t].se)==0) cnt++; else\n\t\t\tif(dcmp(p[t].se)<0 || (dcmp(p[t].se) == 0 && dcmp(p[t].fi) < 0)){\n\t\t\t\tdeg[t] = atan2(-p[t].se,-p[t].fi);\n\t\t\t\tcnt1 += !has(s0,deg[t]) && has(s1,deg[t]);\n\t\t\t\ts0.insert(deg[t]);\n\t\t\t} else{\n\t\t\t\tdeg[t] = atan2(p[t].se,p[t].fi);\n\t\t\t\tcnt1 += !has(s1,deg[t]) && has(s0,deg[t]);\n\t\t\t\ts1.insert(deg[t]);\n\t\t\t}\n\t\t} else {\n\t\t\tint t = read();\n\t\t\tif(dcmp(p[t].fi) == 0 && dcmp(p[t].se) == 0) cnt--; else\n\t\t\tif(dcmp(p[t].se) < 0 || (dcmp(p[t].se) == 0 && dcmp(p[t].fi) < 0)){\n\t\t\t\ts0.erase(s0.find(deg[t]));\n\t\t\t\tcnt1 -= !has(s0,deg[t]) && has(s1,deg[t]);\n\t\t\t} else{\n\t\t\t\ts1.erase(s1.find(deg[t]));\n\t\t\t\tcnt1 -= !has(s1,deg[t]) && has(s0,deg[t]);\n\t\t\t}\n\t\t}\n//\t\tdebug(s0.size());\n//\t\tdebug(s1.size());\n\t\tif(cnt){\n\t\t\tputs(\"1\");\n\t\t} else\n\t\tif(cnt1){\n\t\t\tputs(\"2\");\n\t\t} else\n\t\tif(s0.empty() || s1.empty()){\n\t\t\tputs(\"0\");\n\t\t} else{\n\t\t\tdb st0 = *s0.begin(),st1 = *s1.begin();\n\t\t\tauto p0 = s1.lower_bound(st0),p1 = s0.lower_bound(st1);\n\t\t\tif(p0 != s1.end() && dcmp(*p0-*s0.rbegin())<=0) puts(\"3\"); else\n\t\t\tif(p1 != s0.end() && dcmp(*p1-*s1.rbegin())<=0) puts(\"3\"); else\n\t\t\t\t\t\t\t\t\tputs(\"0\");\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f6962f8363e65ce635b0c9f70dae5415", "src_uid": "ea995d5c5fe84cd175cda0d0e2f01889", "difficulty": 2900.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize \"Ofast\"\n#include\n\nusing namespace std;\n\n#define ll long long\n#define ld double\n\n#define sz(x) (int)x.size()\n#define all(x) x.begin(),x.end()\n\n#define pb emplace_back\n#define X first\n#define Y second\n\nconst int N = 2e5 + 5;\nconst int lim = 1e8;\n\nvector Mul(ll a,ll b) {\n vector f1 = {a % lim,a / lim};\n vector f2 = {b % lim,b / lim};\n vector res(3,0);\n\n for(int i = 0 ; i < 2 ; ++i)\n for(int j = 0 ; j < 2 ; ++j)\n res[i + j] += f1[i] * f2[j];\n \n for(int i = 0 ; i < 2 ; ++i)\n res[i + 1] += res[i] / lim,\n res[i] %= lim;\n \n return res;\n}\n\nstruct Frac {\n ll a, b;\n Frac(ll _a = 0,ll _b = 0) : a(_a), b(_b) {}\n bool operator == (const Frac&rhs) const {\n if (a != rhs.a) return 0;\n if (b != rhs.b) return 0;\n\n return 1;\n }\n} val[N];\n__int128_t cross(const Frac&x,const Frac&y) {\n return (__int128_t)x.a * y.b - (__int128_t)x.b * y.a;\n}\nbool operator < (const Frac&x,const Frac&y) {\n int r1 = (x.b > 0 || (x.b == 0 && x.a < 0));\n int r2 = (y.b > 0 || (y.b == 0 && y.a < 0));\n\n if (r1 == r2) return cross(x,y) > 0;\n else return r1 < r2;\n}\nmap mp;\nint cnt1 = 0;\nint cnt2 = 0;\n\nFrac lst(0,0);\n\nbool bad(const Frac&a,const Frac&b) {\n if (a == b) return 1;\n if (cross(a,b) < 0) return 1;\n\n return 0;\n}\n\nvoid add(Frac P,int v) {\n if (P == Frac(0,0)) {\n cnt1 += v;\n return;\n }\n vector cand;\n cand.pb(lst);\n cand.pb(P);\n mp[P] += v;\n\n if (v > 0) cnt2 += (mp[P] == 1 && mp.count(Frac(-P.a,-P.b)));\n else { cnt2 -= (mp[P] == 0 && mp.count(Frac(-P.a,-P.b)));\n auto it = mp.find(P);\n if (it == mp.begin())\n it = mp.end();\n \n cand.pb((--it) -> X);\n\n if (mp[P] == 0)\n mp.erase(P);\n }\n lst = Frac(0,0);\n\n for(Frac T : cand) {\n auto it = mp.find(T); if (it == mp.end()) continue;\n it = next(it); if (it == mp.end()) it = mp.begin();\n\n if (bad(T,it -> X))\n lst = T;\n }\n}\nint main() {\n ios_base::sync_with_stdio(0);\n cin.tie(0); cout.tie(0);\n\n int sf; cin >> sf;\n int pf; cin >> pf;\n int gf; cin >> gf;\n \n int SumF = sf + pf + gf;\n int tot = 0;\n\n int n; cin >> n;\n\n while (n--) {\n char ops; cin >> ops;\n if (ops == 'R') {\n int i; cin >> i;\n add(val[i],-1);\n }\n if (ops == 'A') {\n ll s; cin >> s;\n ll p; cin >> p;\n ll g; cin >> g;\n\n int sum = s + p + g;\n\n s = s * SumF - 1ll * sf * sum;\n p = p * SumF - 1ll * pf * sum;\n\n if (s || p) {\n ll x = __gcd(abs(s),abs(p));\n s /= x;\n p /= x;\n }\n add(val[++tot] = Frac(s,p),1);\n }\n if (cnt1) { cout << \"1\\n\"; continue; }\n if (cnt2) { cout << \"2\\n\"; continue; }\n if (mp.size() && lst == Frac(0,0)) {\n cout << \"3\\n\";\n continue;\n }\n cout << \"0\\n\";\n }\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "10872863bb2e8efaa56cfb37613a510f", "src_uid": "ea995d5c5fe84cd175cda0d0e2f01889", "difficulty": 2900.0} {"lang": "GNU C++17", "source_code": "#define _USE_MATH_DEFINES\n#include \nusing namespace std;\n#define FOR(i,m,n) for(int i=(m);i<(n);++i)\n#define REP(i,n) FOR(i,0,n)\n#define ALL(v) (v).begin(),(v).end()\nusing ll = long long;\nconst int INF = 0x3f3f3f3f;\nconst ll LINF = 0x3f3f3f3f3f3f3f3fLL;\nconst double EPS = 1e-8;\nconst int MOD = 1000000007;\n// const int MOD = 998244353;\nconst int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};\nconst int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};\ntemplate inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }\ntemplate inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }\nstruct IOSetup {\n IOSetup() {\n cin.tie(nullptr);\n ios_base::sync_with_stdio(false);\n cout << fixed << setprecision(5);\n }\n} iosetup;\n\ntemplate \nstruct Rational {\n T num, den;\n Rational(): num(0), den(1) {}\n Rational(T num_, T den_ = 1) : num(num_), den(den_) { assert(den != 0); reduce(); }\n template Real to_real() const { return (Real)num / den; }\n Rational &operator+=(const Rational &x) {\n T g = __gcd(den, x.den);\n num = num * (x.den / g) + x.num * (den / g); den *= x.den / g;\n reduce();\n return *this;\n }\n Rational &operator-=(const Rational &x) { return *this += -x; }\n Rational &operator*=(const Rational &x) {\n T g1 = __gcd(num, x.den), g2 = __gcd(den, x.num);\n num = (num / g1) * (x.num / g2); den = (den / g2) * (x.den / g1);\n reduce();\n return *this;\n }\n Rational &operator/=(const Rational &x) { return *this *= Rational(x.den, x.num); }\n bool operator==(const Rational &x) const { return num == x.num && den == x.den; }\n bool operator!=(const Rational &x) const { return !(*this == x); }\n bool operator<(const Rational &x) const { return (x - *this).num > 0; }\n bool operator<=(const Rational &x) const { return !(x < *this); }\n bool operator>(const Rational &x) const { return x < *this; }\n bool operator>=(const Rational &x) const { return !(*this < x); }\n Rational &operator++() { if ((num += den) == 0) den = 1; return *this; }\n Rational operator++(int) { Rational res = *this; ++*this; return res; }\n Rational &operator--() { if ((num -= den) == 0) den = 1; return *this; }\n Rational operator--(int) { Rational res = *this; --*this; return res; }\n Rational operator+() const { return *this; }\n Rational operator-() const { return Rational(-num, den); }\n Rational operator+(const Rational &x) const { return Rational(*this) += x; }\n Rational operator-(const Rational &x) const { return Rational(*this) -= x; }\n Rational operator*(const Rational &x) const { return Rational(*this) *= x; }\n Rational operator/(const Rational &x) const { return Rational(*this) /= x; }\n friend ostream &operator<<(ostream &os, const Rational &x) {\n if (x.den == 1) return os << x.num;\n return os << x.num << '/' << x.den;\n }\nprivate:\n void reduce() { T g = __gcd(num, den); num /= g; den /= g; if (den < 0) { num = -num; den = -den; } }\n};\ntemplate Rational abs(const Rational &x) {Rational res = x; if (res.num < 0) res.num = -res.num; return res; }\ntemplate Rational max(const Rational &a, const Rational &b) { return a < b ? b : a; }\ntemplate Rational min(const Rational &a, const Rational &b) { return a < b ? a : b; }\nusing rational = Rational<>;\n\nint main() {\n int sf, pf, gf; cin >> sf >> pf >> gf;\n rational xf = rational(sf, sf + pf + gf), yf = rational(pf, sf + pf + gf);\n vector x, y;\n map, int> mp;\n ll pat = 0;\n multiset ang, diff;\n int n; cin >> n;\n while (n--) {\n char c; cin >> c;\n if (c == 'A') {\n int s, p, g; cin >> s >> p >> g;\n rational dx = rational(s, s + p + g) - xf, dy = rational(p, s + p + g) - yf;\n ll l = lcm(dx.den, dy.den), lx = dx.num * (l / dx.den), ly = dy.num * (l / dy.den);\n if (lx == 0 && ly == 0) {\n x.emplace_back(0);\n y.emplace_back(0);\n } else {\n ll g = gcd(lx, ly);\n lx /= g; ly /= g;\n x.emplace_back(lx);\n y.emplace_back(ly);\n if (mp.count({-lx, -ly}) == 1) pat += mp[{-lx, -ly}];\n double theta = atan2(ly, lx);\n if (!ang.empty()) {\n auto it = ang.lower_bound(theta);\n if (ang.size() >= 2) {\n auto it2 = it;\n if (it2 == ang.end()) it2 = ang.begin();\n if (it2 == ang.begin()) {\n double d = *it2 - *ang.rbegin() + M_PI * 2;\n diff.erase(diff.lower_bound(d));\n } else {\n double d = *it2 - *prev(it);\n diff.erase(diff.lower_bound(d));\n }\n }\n if (it == ang.end()) {\n diff.emplace(*ang.begin() - theta + M_PI * 2);\n } else {\n diff.emplace(*it - theta);\n }\n if (it == ang.begin()) {\n diff.emplace(theta - *ang.rbegin() + M_PI * 2);\n } else {\n diff.emplace(theta - *prev(it));\n }\n }\n ang.emplace(theta);\n }\n ++mp[{lx, ly}];\n } else if (c == 'R') {\n int r; cin >> r; --r;\n --mp[{x[r], y[r]}];\n if (mp[{x[r], y[r]}] == 0) mp.erase({x[r], y[r]});\n if (x[r] != 0 || y[r] != 0) {\n if (mp.count({-x[r], -y[r]}) == 1) pat -= mp[{-x[r], -y[r]}];\n double theta = atan2(y[r], x[r]);\n auto it = ang.lower_bound(theta);\n if (ang.size() >= 2) {\n if (next(it) == ang.end()) {\n double d = *ang.begin() - *it + M_PI * 2;\n diff.erase(diff.lower_bound(d));\n } else {\n double d = *next(it) - *it;\n diff.erase(diff.lower_bound(d));\n }\n if (it == ang.begin()) {\n double d = *it - *ang.rbegin() + M_PI * 2;\n diff.erase(diff.lower_bound(d));\n } else {\n double d = *it - *prev(it);\n diff.erase(diff.lower_bound(d));\n }\n }\n if (ang.size() >= 3) {\n if (next(it) == ang.end()) {\n diff.emplace(*ang.begin() - *prev(it) + M_PI * 2);\n } else if (it == ang.begin()) {\n diff.emplace(*next(it) - *ang.rbegin() + M_PI * 2);\n } else {\n diff.emplace(*next(it) - *prev(it));\n }\n }\n ang.erase(it);\n }\n }\n if (mp.count({0, 0}) == 1) {\n cout << 1 << '\\n';\n } else if (pat > 0) {\n cout << 2 << '\\n';\n } else if (!diff.empty() && *diff.rbegin() < M_PI) {\n cout << 3 << '\\n';\n } else {\n cout << 0 << '\\n';\n }\n // for (auto [k, v] : mp) cout << \"{(\" << k.first << ',' << k.second << \"), \" << v << \"} \";\n // cout << \"\\npat: \" << pat << '\\n';\n // for (double e : ang) cout << e * 180 / M_PI << ' ';\n // cout << '\\n';\n // for (double e : diff) cout << e * 180 / M_PI << ' ';\n // cout << '\\n';\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4da0805d5a04eb7f5ec0cb1b71899733", "src_uid": "ea995d5c5fe84cd175cda0d0e2f01889", "difficulty": 2900.0} {"lang": "MS C++", "source_code": "#include \"iostream \"\n#include \"conio.h\"\n\nusing namespace std;\n\nbool scan(int* x, int i, int max, int min, int n);\n\nint main()\n{\n\tint n;\n\tcin >> n;\n\n\tint* ar = new int[n];\n \n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tcin >> ar[i];\n\t}\n \n\tint nmin, nmax;\n\tint minpred, maxpred;\n\tbool res;\n\tres = false;\n\tif (ar[0] > ar[1])\n\t{\n\t\tnmin = 1; nmax = 0;\n\t\tminpred = nmax;\n\t\tmaxpred = nmin;\n\t}\n\telse\n\t{\n\t\tnmax = 1; nmin = 0;\n\t\tminpred = nmax;\n\t\tmaxpred = nmin;\n\t}\n\n\tfor (int i = 2; i < n; i ++)\n\t{\n\t\tif (ar[i] > ar[nmax]) \n\t\t{\n\t\t\tmaxpred = nmax;\n\t\t nmax = i;\n\t\t\tcontinue;\n\t }\n\n\t\tif (ar[i] < ar[nmin])\n\t\t{\n\t\t\tminpred = nmin;\n\t\t\tnmin = i; continue;\n\t\t}\n\n\t\tif ((ar[i] > ar[nmin]) && (ar[i] ar[maxpred]))\n\t\t{\n\t\t\tres = scan(ar, i, nmax, maxpred, n); break;\n\t\t}\n\n\t\tres = true;\n\t\tbreak;\n\t}\n\n\tif (res)\n\t\tcout << \"yes\";\n\telse\n\t\tcout << \"no\";\n\n\t_getch();\n\n\treturn 0;\n}\n\nbool scan(int* ar, int i1, int max, int min,int n)\n{\n\tint nmin, nmax;\n\tint minpred, maxpred;\n\n\tbool res;\n\tres = false;\n\n\tif ((ar[i1] > ar[i1 + 1]) && (ar[i1+1] > ar[min]) && (ar [i1+1] ar[max]))\n\t{\n\n\t\treturn true;\n\t}\n\tfor (int i = i1+2; i < n; i++)\n\t{\n\t\tif ((ar[i] > ar[nmax]) && (ar[i] > ar[min]) && (ar[i] < ar[max]))\n\t\t{\n\t\t\tmaxpred = nmax;\n\t\t\tnmax = i;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ((ar[i] < ar[nmin]) && (ar[i] > ar[min]) && (ar[i] < ar[max]))\n\t\t{\n\t\t\tminpred = nmin;\n\t\t\tnmin = i; \n\t\t\tcontinue;\n\t\t}\n\n\t\tif ((ar[i] > ar[nmin]) && (ar[i] < ar[minpred]) && (ar[i] > ar[min]) && (ar[i] < ar[max]))\n\t\t{\n\t\t\n\t\t\tres= scan(ar, i, minpred, min, n); break;\n\t\t}\n\n\t\tif ((ar[i] < ar[nmax]) && (ar[i] > ar[maxpred]) && (ar[i] > ar[min]) && (ar[i] < ar[max]))\n\t\t{\n\t\t\t\n\t\t\tres= scan(ar, i, nmax, maxpred, n); break;\n\t\t}\n\n\t\t\n\t\tres = true;\n\t\tbreak;\n\t}\n\n\treturn res;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "22800cac21fd50465337fe76bd9516cb", "src_uid": "f1b6b81ebd49f31428fe57913dfc604d", "difficulty": 1400.0} {"lang": "MS C++", "source_code": "#include \"iostream \"\n#include \"conio.h\"\n\nusing namespace std;\n\nbool scan(int* x, int i, int max, int min, int n);\n\nint main()\n{\n\tint n;\n\tcin >> n;\n\n\tint* ar = new int[n];\n \n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tcin >> ar[i];\n\t}\n \n\tint nmin, nmax;\n\tint minpred, maxpred;\n\tbool res;\n\tres = false;\n\tif (ar[0] > ar[1])\n\t{\n\t\tnmin = 1; nmax = 0;\n\t\tminpred = nmax;\n\t\tmaxpred = nmin;\n\t}\n\telse\n\t{\n\t\tnmax = 1; nmin = 0;\n\t\tminpred = nmax;\n\t\tmaxpred = nmin;\n\t}\n\n\tfor (int i = 2; i < n; i ++)\n\t{\n\t\tif (ar[i] > ar[nmax]) \n\t\t{\n\t\t\tmaxpred = nmax;\n\t\t nmax = i;\n\t\t\tcontinue;\n\t }\n\n\t\tif (ar[i] < ar[nmin])\n\t\t{\n\t\t\tminpred = nmin;\n\t\t\tnmin = i; continue;\n\t\t}\n\n\t\tif ((ar[i] > ar[nmin]) && (ar[i] ar[maxpred]))\n\t\t{\n\t\t\tres = scan(ar, i, nmax, maxpred, n); break;\n\t\t}\n\n\t\tres = true;\n\t\tbreak;\n\t}\n\n\tif (res)\n\t\tcout << \"yes\";\n\telse\n\t\tcout << \"no\";\n\n\t_getch();\n\n\treturn 0;\n}\n\nbool scan(int* ar, int i1, int max, int min,int n)\n{\n if ((i1 + 1) > n) return false;\n\tint nmin, nmax;\n\tint minpred, maxpred;\n\n\tbool res;\n\tres = false;\n\n\tif ((ar[i1] > ar[i1 + 1]) && (ar[i1] > ar[min]) && (ar [i1] ar[max]))\n\t{\n\n\t\treturn true;\n\t}\n\tfor (int i = i1+2; i < n; i++)\n\t{\n\t\tif ((ar[i] > ar[nmax]) && (ar[i] > ar[min]) && (ar[i] < ar[max]))\n\t\t{\n\t\t\tmaxpred = nmax;\n\t\t\tnmax = i;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ((ar[i] < ar[nmin]) && (ar[i] > ar[min]) && (ar[i] < ar[max]))\n\t\t{\n\t\t\tminpred = nmin;\n\t\t\tnmin = i; \n\t\t\tcontinue;\n\t\t}\n\n\t\tif ((ar[i] > ar[nmin]) && (ar[i] < ar[minpred]) && (ar[i] > ar[min]) && (ar[i] < ar[max]))\n\t\t{\n\t\t\n\t\t\tres= scan(ar, i, minpred, min, n); break;\n\t\t}\n\n\t\tif ((ar[i] < ar[nmax]) && (ar[i] > ar[maxpred]) && (ar[i] > ar[min]) && (ar[i] < ar[max]))\n\t\t{\n\t\t\t\n\t\t\tres= scan(ar, i, nmax, maxpred, n); break;\n\t\t}\n\n\t\t\n\t\tres = true;\n\t\tbreak;\n\t}\n\n\treturn res;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4c6ffd0b84c4b97877a7f7ff1f869f27", "src_uid": "f1b6b81ebd49f31428fe57913dfc604d", "difficulty": 1400.0} {"lang": "MS C++", "source_code": "#include \"iostream \"\n#include \"conio.h\"\n\nusing namespace std;\n\nbool scan(int* x, int i, int max, int min, int n);\n\nint main()\n{\n\tint n;\n\tcin >> n;\n\n\tint* ar = new int[n];\n \n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tcin >> ar[i];\n\t}\n \n\tint nmin, nmax;\n\tint minpred, maxpred;\n\tbool res;\n\tres = false;\n\tif (ar[0] > ar[1])\n\t{\n\t\tnmin = 1; nmax = 0;\n\t\tminpred = nmax;\n\t\tmaxpred = nmin;\n\t}\n\telse\n\t{\n\t\tnmax = 1; nmin = 0;\n\t\tminpred = nmax;\n\t\tmaxpred = nmin;\n\t}\n\n\tfor (int i = 2; i < n; i ++)\n\t{\n\t\tif (ar[i] > ar[nmax]) \n\t\t{\n\t\t\tmaxpred = nmax;\n\t\t nmax = i;\n\t\t\tcontinue;\n\t }\n\n\t\tif (ar[i] < ar[nmin])\n\t\t{\n\t\t\tminpred = nmin;\n\t\t\tnmin = i; continue;\n\t\t}\n\n\t\tif ((ar[i] > ar[nmin]) && (ar[i] ar[maxpred]))\n\t\t{\n\t\t\tres = scan(ar, i, nmax, maxpred, n); break;\n\t\t}\n\n\t\tres = true;\n\t\tbreak;\n\t}\n\n\tif (res)\n\t\tcout << \"yes\";\n\telse\n\t\tcout << \"no\";\n\n\t_getch();\n\n\treturn 0;\n}\n\nbool scan(int* ar, int i1, int max, int min,int n)\n{\n\tint nmin, nmax;\n\tint minpred, maxpred;\n\n\tbool res;\n\tres = false;\n\n\tif ((ar[i1] > ar[i1 + 1]) && (ar[i1] > ar[min]) && (ar [i1] ar[max]))\n\t{\n\n\t\treturn true;\n\t}\n\tfor (int i = i1+2; i < n; i++)\n\t{\n\t\tif ((ar[i] > ar[nmax]) && (ar[i] > ar[min]) && (ar[i] < ar[max]))\n\t\t{\n\t\t\tmaxpred = nmax;\n\t\t\tnmax = i;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif ((ar[i] < ar[nmin]) && (ar[i] > ar[min]) && (ar[i] < ar[max]))\n\t\t{\n\t\t\tminpred = nmin;\n\t\t\tnmin = i; \n\t\t\tcontinue;\n\t\t}\n\n\t\tif ((ar[i] > ar[nmin]) && (ar[i] < ar[minpred]) && (ar[i] > ar[min]) && (ar[i] < ar[max]))\n\t\t{\n\t\t\n\t\t\tres= scan(ar, i, minpred, min, n); break;\n\t\t}\n\n\t\tif ((ar[i] < ar[nmax]) && (ar[i] > ar[maxpred]) && (ar[i] > ar[min]) && (ar[i] < ar[max]))\n\t\t{\n\t\t\t\n\t\t\tres= scan(ar, i, nmax, maxpred, n); break;\n\t\t}\n\n\t\t\n\t\tres = true;\n\t\tbreak;\n\t}\n\n\treturn res;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "814f571aedf1e429b5da4a0b90a1bdf6", "src_uid": "f1b6b81ebd49f31428fe57913dfc604d", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n\nint main()\n{\n\tint N=0,err = 0, toch[1002],first=0,second=0,max=0,min=0;\n\tscanf(\"%d\",&N);\n\tscanf(\"%d\",&toch[0]);\n\tscanf(\"%d\",&toch[1]);\n\tif(max>toch[0]) max=toch[0];\n\tif(mintoch[1]) max=toch[1];\n\tif(min=toch[j-1]))||((toch[i-1]>=toch[j])&&(toch[i]<=toch[j-1])))\n\t\t\t{\n\t\t\t\tfirst = toch[j-1];\n\t\t\t\tsecond=toch[j];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t\tif(((max==second)||(min==first))&&((max>toch[i])||(min=second))||(toch[i]>=first)&&(toch[i]<=second)));\n\t\t\telse err-=1;\n\t\t\t}\n\t\t\n\t\tif(max>toch[i]) max=toch[i];\n\tif(min\nusing namespace std;const long long num=50000000;\nlong long mas[num+1],x=1,t,n,i,a=0;\nint main()\n {\n cin>>n;\n while (x=0;i--)\n if (a+(1<\n#include \n\nint main ()\n{\n puts (\"\u00c2\u00e2\u00e5\u00e4\u00e8\u00f2\u00e5 \u00f7\u00e8\u00f1\u00eb\u00ee\");\n int a, p=1,i=1,j=1;\n //f=0;\n scanf (\"%d\",&a);\n while (!(a==p))\n {\n i++;\n for (j=1; j<=i; j++)\n {\n p++;\n if (a==p) break;\n }\n// if (f) break;\n }\n\n printf(\"\\n%d\",j); \n getch();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "be701ca621d5dfe7af6b45498d4f735c", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n\nint main ()\n{\n puts (\"\u00c2\u00e2\u00e5\u00e4\u00e8\u00f2\u00e5 \u00f7\u00e8\u00f1\u00eb\u00ee\");\n int a, p=1,i=1,j=1,f=0;\n \n scanf (\"%d\",&a);\n \n while (!f)\n {\n i++;\n for (j=1; j<=i; j++)\n {\n p++;\n if (a==p) {f=1; break;}\n }\n// if (f) break;\n }\n\n printf(\"\\n%d\",j); \n getch();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fab31dd404f9646accf1ee129eb62b71", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n\nint main ()\n{\n puts (\"Vvedite chislo\");\n int a;\n scanf (\"%d\",&a);\n int p=1,i=1;\n int j=1;\n int f=0;\n while (1)\n {\n i++;\n for (j=1; j<=i; j++)\n {\n p++;\n if (a==p) {f=1; break;}\n }\n if (f) break;\n }\n printf(\"\\n%d\",j);\n \n getch();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "966efffd1d939fc211a7450d835ce421", "src_uid": "1db5631847085815461c617854b08ee5", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define ll long long int\nusing namespace std;\n\nint main() {\n\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif\n\n\tstring s, t;\n\tcin >> s >> t;\n\n\tint n = s.size();\n\tint flag = 0;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tif (s[i] + 1 < t[i])\n\t\t{\n\t\t\ts[i]++;\n\t\t\tflag = 1;\n\t\t\tbreak;\n\t\t}\n\t\telse if (s[i] < t[i])\n\t\t{\n\t\t\ti++;\n\t\t\twhile (s[i] == 'z')\n\t\t\t{\n\n\t\t\t}\n\n\t\t\tif (i < n)\n\t\t\t{\n\t\t\t\ts[i]++;\n\t\t\t\tflag = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tif (flag == 1)\n\t\tcout << s;\n\telse\n\t\tcout << \"No such string\";\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0ac4d3a601e530bec14f5e0bd40a397c", "src_uid": "47618510d2a17b1cc1e6a688201d51a3", "difficulty": 1600.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nstring s1, s2, s3=\"\";\nint kt1=0, kt2=0;\nvoid main()\n{\n\tgetline(cin, s1);\n\tgetline(cin, s2);\n\tfor (int i = 0; i < s1.size(); i++)\n\t\tif (s1[i] != s2[i])\n\t\t{\n\t\t\tif (s2[i] - s1[i] == 1)\n\t\t\t{\n\t\t\t\ts3 = s3 + s1[i];\n\t\t\t\tkt2 = 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (s2[i] > s1[i])\n\t\t\t{\n\t\t\t\ts3 = s3 + char(s1[i] + 1);\n\t\t\t\tkt1 = kt2 = 1;\n\t\t\t}\n\t\t\tif (s1[i] == s2[i])\n\t\t\t{\n\t\t\t\ts3 = s3 + s1[i];\n\t\t\t}\n\t\t\tif (s1[i] > s2[i])\n\t\t\t\tif (kt1 == 0 || kt2 == 0)\n\t\t\t\t{\n\t\t\t\t\tprintf(\"No such string\");\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\ts3 = s3 + char(s1[i] + 1);\n\t\t\t\t}\n\n\t\t}\n\t\telse\n\t\t\ts3 = s3 + s1[i];\n\t\n\tif (kt1 && kt2)\n\t\tcout << s3;\n\telse\n\t\tprintf(\"No such string\");\n\n\n\n\t_getch();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "34b45320dd6883dfd4b2944bb09f3919", "src_uid": "47618510d2a17b1cc1e6a688201d51a3", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\nint main()\n{\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n string s,t,ans=\"\";\n int i=0;\n cin>>s>>t;\n while(s[i]==t[i]&&is&&ans\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n int i,j,k,a,n;\n string fst ,snd;\n cin >> fst ;\n cin >> snd;\n int l=fst.size();\n n=0;\n for(i=0;i=0)\n {\n if(a>1)break;\n }\n else\n {\n\n break;\n }\n }\n if(a<=1 && l==i)cout << \"No such string\\n\";\n else\n {\n for(j=0;j\n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef struct {\n\tshort int num;\n\tchar *arr;\n} state;\n\nmap used;\nstate q[3000000];\n\n#define CARD(i) ((i-1)*3)\n\nint main()\n{\n\tint n, i, x, y, c, a, b, d;\n\tchar shit[206];\n\tstate v;\n\tlong long *s;\n\tchar *k, *ns;\n\t\n\tscanf(\"%d\", &n);\n\t\n\tif(n == 1) {\nyes:\n\t\tprintf(\"YES\");\n\t\treturn 0;\n\t}\n\t\n\tgets(shit);\n\tgets(shit);\n\t\n\tq[0].num = n;\n\tq[0].arr = shit;\n\t\n\tx = 0;\n\ty = 1;\n\t\n\twhile(x != y) {\n\t\tv = q[x++];\n\t\ts = (long long *)&v;\n\t\t\n\t\tif(used[*s] != 1) {\n\t\t\tused[*s] = 1;\n\t\t\t\n\t\t\tk = v.arr;\n\t\t\td = v.num;\n\t\t\t\n\t\t\tif(d == 1) {\n\t\t\t\tgoto yes;\n\t\t\t}\n\t\t\t\n\t\t\ta = CARD(d);\n\t\t\tb = CARD(d-1);\n\t\t\t\n\t\t\tif(shit[a] == shit[b] || shit[a+1] == shit[b+1]) {\n\t\t\t\tns = (char *)malloc((d-1)*3);\n\t\t\t\tmemcpy(ns, k, (d-1)*3);\n\t\t\t\tns[(d-1)*3-1] = k[d*3-1];\n\t\t\t\tns[(d-1)*3-2] = k[d*3-2];\n\t\t\t\tns[(d-1)*3-3] = k[d*3-3];\n\t\t\t\tv.arr = ns;\n\t\t\t\tv.num = d-1;\n\t\t\t\tq[y++] = v;\n\t\t\t}\n\t\t\t\n\t\t\tif(d > 3) {\n\t\t\t\tb = CARD(d-3);\n\t\t\t\t\n\t\t\t\tif(shit[a] == shit[b] || shit[a+1] == shit[b+1]) {\n\t\t\t\t\tns = (char *)malloc((d-1)*3);\n\t\t\t\t\tmemcpy(ns, k, (d-1)*3);\n\t\t\t\t\tns[(d-3)*3-1] = k[d*3-1];\n\t\t\t\t\tns[(d-3)*3-2] = k[d*3-2];\n\t\t\t\t\tns[(d-3)*3-3] = k[d*3-3];\n\t\t\t\t\tv.arr = ns;\n\t\t\t\t\tv.num = d-1;\n\t\t\t\t\tq[y++] = v;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t}\n\t\n\tprintf(\"NO\");\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d9f56419a827664bfbd7be9b88d4edcc", "src_uid": "1805771e194d323edacf2526a1eb6768", "difficulty": 1900.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define ll long long\n#define pii pair\n#define ff first\n#define ss second\nconst int MAXN = 60;\nconst int MAXC = 150;\nbool vis[2][MAXN][MAXC][MAXC][MAXC];\n\nvoid dfs(vector &a, vector &b){\n int n = a.size();\n if(n == 1){\n cout << \"YES\";\n exit(0);\n }\n if(n-3 >= 0 && vis[0][n-1][a[n-3]][a[n-2]][a[n-1]] && vis[1][n-1][b[n-3]][b[n-2]][b[n-1]]) return;\n if(n-3 >= 0){\n vis[0][n-1][a[n-3]][a[n-2]][a[n-1]] = true;\n vis[1][n-1][b[n-3]][b[n-2]][b[n-1]] = true;\n }\n if(n-4 >= 0 && (a[n-1] == a[n-4] || b[n-1] == b[n-4])){\n char n1 = a[n-1], n2 = b[n-1];\n char n3 = a[n-4], n4 = b[n-4];\n a.pop_back(), b.pop_back();\n a[n-4] = n1, b[n-4] = n2;\n dfs(a, b);\n a[n-4] = n3, b[n-4] = n4;\n a.push_back(n1), b.push_back(n2);\n }\n if(a[n-1] == a[n-2] || b[n-1] == b[n-2]){\n char n1 = a[n-1], n2 = b[n-1];\n char n3 = a[n-2], n4 = b[n-2];\n a.pop_back(), b.pop_back();\n a[n-2] = n1, b[n-2] = n2;\n dfs(a, b);\n a[n-2] = n3, b[n-2] = n4;\n a.push_back(n1), b.push_back(n2);\n \n }\n}\n\nmain(){\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n int N; cin >> N;\n vector a(N), b(N);\n for(int i = 0; i < N; i++){\n string s; cin >> s;\n a[i] = s[0];\n b[i] = s[1];\n }\n dfs(a, b);\n cout << \"NO\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3e218aa90a5b8782ecdaab746e46fa07", "src_uid": "1805771e194d323edacf2526a1eb6768", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include\"stdio.h\"\n#include\"string.h\"\n#include \"iostream\"\n#include \"algorithm\"\n#include \"queue\"\n#include \"math.h\"\nusing namespace std;\n#define maxm 2000000000\n#define maxn 50004\n#define eps 1e-14\n#define pi acos(-1.0)\nstruct node\n{\n\tchar s[3];\n}p[60];\nint n,f;\nint main()\n{\n int i,j,k;\n\t int maps[62][62];\n\t//freopen(\"E:\\\\in.txt\",\"r\",stdin);\n //freopen(\"E:\\\\out.txt\",\"w\",stdout);\n scanf(\"%d\",&n);\n\tfor (i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define LL long long\n#define MIN INT_MIN\n#define MAX (1<<30)\n#define pii pair\n#define bug cout<<\"here!!!\"<=1 && cmp(str[cur],str[cur-1])){\n strcpy(ss,str[cur-1]);\n strcpy(str[cur-1],str[cur]);\n return dfs(cur-1);\n strcpy(str[cur-1],ss);\n }\n if(cur-3>=1 && cmp(str[cur],str[cur-3])){\n strcpy(ss,str[cur-3]);\n strcpy(str[cur-3],str[cur]);\n return dfs(cur-3);\n strcpy(str[cur-3],ss);\n }\n return false;\n}\nint main(){\n int n;\n scanf(\"%d\",&n);\n int i,j;\n for(i=1;i<=n;i++)scanf(\"%s\",str[i]);\n if(dfs(n))puts(\"YES\");\n else puts(\"NO\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bac6d964e045dfb7cbaaeced5c11242b", "src_uid": "1805771e194d323edacf2526a1eb6768", "difficulty": 1900.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\nint n;\nchar s[300100];\nint d[300100];\nint main()\n{\n\tscanf(\"%d\",&n);\n\tscanf(\"%s\",s+1);\n\tint l=1,r=1;\n\tint ans=0;\n\tfor(int z=1;z<=n;z++){\n\t\tif(s[z]=='(') d[z]=d[z-1]+1;\n\t\telse d[z]=d[z-1]-1;\n\t}\n\tif(d[n]!=0){\n\t\tprintf(\"%d\\n%d %d\",ans,l,r);\n\t\treturn 0;\n\t}\n\tfor(int i=1;ians){\n\t\t\t\tans=ans1;\n\t\t\t\tl=i;\n\t\t\t\tr=j;\n\t\t\t}\n\t\t\tswap(s[i],s[j]);\n\t\t}\n\t}\n\tprintf(\"%d\\n%d %d\",ans,l,r);\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ef54f67e551843ef78ad0ec15e67e5c9", "src_uid": "be820239276b5e1a346309f9dd21c5cb", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std; \n\n// #pragma GCC optimize(\"Ofast\")\n// #pragma GCC optimize (\"unroll-loops\")\n// #pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n\ntypedef long long ll; \ntypedef long double ld; \n#define prarr(a,n) cerr<<#a<<\" : \";for(ll i=0;i void dbs(string str, T t) {cerr << str << \" : \" << t << \"\\n\";}\ntemplate void dbs(string str, T t, S... s) {ll idx = str.find(','); cerr << str.substr(0, idx) << \" : \" << t << \", \"; dbs(str.substr(idx + 1), s...);}\ntemplate void prc(T a, T b) {cerr << \"[\"; for (T i = a; i != b; ++i) {if (i != a) cerr << \", \"; cerr << *i;} cerr << \"]\\n\";}\ntemplate void prall(T a) { prc(all(a)); }\nconst int inf=1000*1000*1000+9; \nconst ll infl=1ll*inf*inf; \nconst int mod=1000*1000*1000+7; \n\n// ----------------------------------------------------------------------------\t-------------- \n\nvoid solve(){\n\tint n; cin>>n; \n\tstring s; cin>>s; \n\tstring t=s+s; \n\tint o=0; \n\tfor(int i=0;iamt){\n\t\t\t\tamt=z; \n\t\t\t\tl=i; \n\t\t\t}\n\t\t}\n\t}\t\n\tif(amt==-1){\n\t\tcout<<0<cc){\n\t\t\t\t\tcc=cnt; \n\t\t\t\t\text=max(ext,cnt); \n\t\t\t\t\ta=prev, b=i; \n\t\t\t\t}\n\t\t\t\tprev=i+1; \n\t\t\t}\n\t\t}\t\n\t\tif(a>n-1) a-=n; \n\t\tif(b>n-1) b-=n; \n\t\tint ans1=ext+1;\n\t\ta++; b++; \n\t\tint a1=-1, b1=-1; \n\t\to=0; \n\t\text=0; \n\t\tprev=l; \n\t\tfor(int i=l;iext){\n\t\t\t\t\t\t\text=z; \t\n\t\t\t\t\t\t\ta1=pp, b1=j;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpp=j+1; \n\t\t\t\t\t}\n\t\t\t\t}\t\n\t\t\t\tprev=i+1;\n\t\t\t}\n\t\t}\n\t\tint ans2=amt+1+ext; \n\t\tif(a1>n-1) a1-=n; \n\t\tif(b1>n-1) b1-=n; \n\t\ta1++; \n\t\tb1++; \n\t\tif(ans2>ans1){\n\t\t\tcout<\nusing namespace std;\n#ifdef __LOCAL_DEBUG__\n# define _debug(fmt, ...) fprintf(stderr, \"\\033[91m[%s %3d]: \" fmt \"\\n\\033[0m\", \\\n __func__,__LINE__, ##__VA_ARGS__)\n#else\n# define _debug(...) (void(0))\n#endif\n#define PB(x) push_back(x)\n#define rep(i,l,r) for (int i = l,_ = r;i< _;i++)\n#define REP(i,l,r) for (int i=l,_=r;i<=_;i++)\n#define leave(x) do {cout<<#x< vi;\ntypedef vector vl;\ntypedef long double db;\ntypedef pair pii;\ntypedef pair pll;\nconst int inf = 0x3f3f3f3f;\nconst ll inf_ll = 0x3f3f3f3f3f3f3f3fLL;\n/************* header ******************/\nconst int maxn = 3e5 + 100;\nint sum[maxn];\nchar s[maxn];\nchar t[maxn];\nint n;\nint cnt1[maxn];\nint cnt2[maxn];\nint pos[maxn];\npair > ans = {0,{1,1}};\nint main(){\n cin>>n;\n cin>>s+1;\n int min_pos = 1;\n for (int i=1;i<=n;i++){\n sum[i] = sum[i-1] + (s[i] == '('?1:-1);\n if (sum[i] < sum[min_pos])min_pos = i;\n }\n if (sum[n]!= 0){\n cout<<0< ones(0);\n vector zeros(0);\n zeros.push_back(0);\n for (int i=1;i<=n;i++){\n sum[i] = sum[i-1] + (t[i] == '('?1:-1);\n if (sum[i] == 0)zeros.push_back(i);\n if (sum[i] ==1 || sum[i] == 0)ones.push_back(i);\n cnt2[i] = cnt2[i-1];\n cnt2[i] += sum[i] == 2;\n cnt1[i] = cnt1[i-1];\n cnt1[i] += sum[i] == 1;\n cerr<\nusing namespace std;\n#define pb push_back\nconst int MAXN = 3e5 + 10;\nconst int INF = 0x3f3f3f3f;\nint N;\nchar str[MAXN];\nint n[MAXN];\nint prefix[MAXN];\n\nvoid quit()\n{\n printf(\"0\\n1 1\");\n exit(0);\n}\nstruct node\n{\n int l, r, ans;\n node(int _l, int _r, int _ans) : l(_l), r(_r), ans(_ans) {}\n bool friend operator<(const node &a, const node &b)\n {\n if (a.ans != b.ans)\n return a.ans > b.ans;\n if (a.l == b.l)\n return 1;\n return 0;\n }\n};\n\nint main()\n{\n cin >> N >> str + 1;\n for (int i = 1; i <= N; ++i)\n n[i] = (str[i] == '(' ? 1 : -1);\n for (int i = 1; i <= N; ++i)\n prefix[i] = prefix[i - 1] + n[i];\n\n // for (int i = 1; i <= N; ++i)\n // cout << prefix[i] << ' ';\n // cout << endl;\n\n if (prefix[N] != 0)\n quit();\n int st = 0, min = INF;\n for (int i = 1; i <= N; ++i)\n if (prefix[i] < min)\n min = prefix[i], st = i;\n int tot = 0;\n for (int i = st + 1; i <= N; ++i)\n n[++tot] = (str[i] == '(' ? 1 : -1);\n for (int i = 1; i <= st; ++i)\n n[++tot] = (str[i] == '(' ? 1 : -1);\n for (int i = 1; i <= N; ++i)\n prefix[i] = prefix[i - 1] + n[i];\n\n // for (int i = st + 1; i <= N; ++i)\n // cout << str[i];\n // for (int i = 1; i <= st; ++i)\n // cout << str[i];\n // cout << endl;\n // for (int i = 1; i <= N; ++i)\n // cout << prefix[i] << ' ';\n // cout << endl;\n\n int num0 = 0;\n for (int i = 1; i <= N; ++i)\n if (prefix[i] == 0)\n ++num0;\n\n int num2 = 0, num1 = 0;\n int l2 = 0, l1 = 0;\n vector ans;\n ans.pb(node(1, 1, num0));\n for (int i = 1; i <= N; ++i)\n {\n if (prefix[i] == 2)\n {\n ++num2;\n if (!l2)\n l2 = i;\n }\n if (prefix[i] == 1)\n {\n ++num1;\n if (!l1)\n l1 = i;\n }\n if (prefix[i] < 2)\n {\n ans.pb(node(l2, i, num2 + num0));\n num2 = l2 = 0;\n }\n if (prefix[i] < 1)\n {\n ans.pb(node(l1, i, num1));\n num1 = l1 = 0;\n }\n }\n sort(ans.begin(), ans.end());\n cout << ans[0].ans << endl;\n int ans_l = (ans[0].l + st) % N;\n if (ans_l == 0)\n ans_l = N;\n int ans_r = (ans[0].r + st) % N;\n if (ans_r == 0)\n ans_r = N;\n cout << ans_l << ' ' << ans_r;\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ad9c36d38ed814c44cca346b9d00ee9f", "src_uid": "be820239276b5e1a346309f9dd21c5cb", "difficulty": 2500.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std; \n__int64 mod=1000000000+7; \nint min(int a,int b)\n{return ab?a:b;}\nint vis[250000000+50];\n//\u9898\u610f\uff1a\n/*\n\u7ed9\u4f60n,m\uff0c\u8868\u793an\u4e2a\u5b66\u751f\u7528\u9ad8\u5ea62\u7684\u7816\u5806\u780c\uff0cm\u4e2a\u5b66\u751f\u7528\u9ad8\u5ea6\u4e3a3\u7684\u94bb\n\u8981\u6c42\u6240\u6709\u5b66\u751f\u5806\u780c\u5f97\u5230\u7684\u5899\u9ad8\u90fd\u5fc5\u987b\u662f\u72ec\u4e00\u65e0\u4e8c\u7684\u3002\n\u5176\u5b9e n\u4e2a\u5b66\u751f\u91cc\u6709\u4eba\u5806\u51fa\u9ad8\u5ea6 2*3\uff08\u4e09\u5757\u7816\uff09\uff0c\u5219n\u4e2a\u91cc\u9762\u7684\u5176\u4ed6\u4eba\u4e0d\u53ef\u4ee5\u58062*3\n\u800cm\u4e2a\u5b66\u751f\u91cc\uff0c\u4e5f\u4e0d\u80fd\u6709\u9ad8\u5ea6 3*2 \uff08\u4e24\u5757\u7816\uff09\n\n \u6c42\u4e00\u79cd\u65b9\u6848\uff0c\u4f7f\u5f97\u6240\u6709\u4eba\u9ad8\u5ea6\u4e0d\u4e00\u6837\uff0c\u4e14\u6700\u9ad8\u7684\u9ad8\u5ea6max_high\u6700\u5c0f\uff0c\u8f93\u51fa\u8fd9\u4e2amax_high\n */\n\nint main()\n{ \n\n\t\n\treturn 0;\n\t\t\t\t\n} \n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a9f255a24fbfae53b325336e89a8ff83", "src_uid": "7bd5521531950e2de9a7b0904353184d", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nlong int a[300];\n\nint main()\n{\n\tint n;\n\tcin>>n;\n\tchar x;\n\tlong long int sum=0,count=0;\n\t\n\tfor(int i=0;i>x;\n\t\tif(x=='R')\n\t\ta[i]=1;\n\t\tif(x=='L')\n\t\ta[i]=-1;\n\t\tif(x=='U')\n\t\ta[i]=2;\n\t\tif(x=='D')\n\t\ta[i]=-2;\n\t}\n\t\n\tfor(int i=0;i\nint po (char r)\n{\n //int d;\n if (r=='U')\n return 2 ;\n else if (r=='D')\n return -2;\n else if (r=='R')\n return 1;\n else if (r=='L')\n return -1;\n }\nusing namespace std;\n\nint main()\n{\n int n;\n cin >>n;\n if (n>=1 && n<=200)\n {\n char f[n];\n for (int i=0 ; i>f[i];\n int c=0;\n for (int i=0 ; i\n\nusing namespace std;\ntypedef unsigned long long int ull ;\ntypedef long long int ll ;\n\n#define f first\n#define s second\n#define oo 1e9+7\n\nll puiss(ll a,ll b ){\nll ans = 1 ;\nfor(ll i = 0 ; i < b ; i+9 ){ ans *= a ; }\nreturn ans ;\n}\n\n\nint main()\n{\n\n\n //freopen(\"test.in\" , \"r\" , stdin) ; // freopen(\"test.out\" , \"w\" , stdout) ;\n //cout << \"bonjour tout le monde \" << endl;\n int n ; cin >> n ;\n\n char t[205] ;\n cin >> t ;\n\n if(n == 1 ){cout<<0 << endl; return 0 ; }\n else if(n == 2){\n if( (t[0] == 'U' && t[1] == 'D') || ( t[0] == 'R' && t[1] == 'L' ) ){cout << 1<< endl; return 0 ; }\n else { cout << 0 << endl; return 0 ; }\n }\n\n vector v ;\n for(int i = 0 ; i < n-1 ; i++ ){\n for(int j = i+1 ; j < n ; j++){\n int w = 0 ,l = 0 ;\n string s = \"\" ;\n for(int k = i ; k <= j ; k++ ){\n s+=t[k] ;\n if(t[k] == 'U')l++;\n else if(t[k] == 'D')l-- ;\n else if(t[k] == 'R')w++;\n else if(t[k] == 'L')w-- ;\n\n }\n if(l == 0 && w == 0)v.push_back(s) ;\n }\n\n }\n sort(v.begin() , v.end() ) ;\n cout << v.size() << endl;\n \n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0f2e1255fd938e86afea1b4c328d29c2", "src_uid": "7bd5521531950e2de9a7b0904353184d", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\nll MOD=1e9+7;\n\nint main(){\n ios_base::sync_with_stdio(0);\n ll n,x=1;\n cin>>n;\n for (ll i = 1; i < 99000000; ++i)\n {\n x=(x+i)%MOD;\n // x=(i*i);/\n }\n if(x%2==1)x=2;\n else x=4;\n n-=2;\n n*=x;\n x/=2;\n n/=2;\n n/=x;\n cout<<(n*n)<\n#include \n\nusing namespace std;\n\nint square(int n);\nint main(void)\n{\n int n;\n while(scanf(\"%d\",&n))\n {\n\n cout<\nusing namespace std;\ntypedef long long ll;\nll MOD=1e9+7;\n\nint main(){\n ios_base::sync_with_stdio(0);\n ll n,x=1;\n cin>>n;\n for (ll i = 1; i < 110000000; ++i)\n {\n x=(x+i)%MOD;\n // x=(i*i);/\n }\n if(x%2==1)x=3;\n else x=4;\n n-=2;\n n*=x;\n x/=2;\n n/=2;\n n/=x;\n cout<<(n*n)<\n\n#define ll long long\n#define f first\n#define s second\n#define pb push_back\n\n#define pii pair\n#define mp make_pair\n\n#define ios ios_base::sync_with_stdio(0)\n\nusing namespace std;\n\nconst int LIT = 1e3;\nconst int MID = 1e5;\nconst int MAX = 1e9;\n\nint main() {\n ll n, ans = 1, res = 0;\n scanf(\"%d\", &n);\nfor(int i = 3; i <= n; i ++) {\n res += ans;\n ans += 2; }\n cout << res;\nreturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f1187662c79491f24fa5bb2bc46fdc39", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nconst int MAXL = 16;\nchar buff[MAXL];\nbool g[3][3];\n\ninline bool gao() {\n if (g[0][1] && g[1][2]) puts(\"ABC\");\n else if (g[0][2] && g[2][1]) puts(\"ACB\");\n else if (g[1][0] && g[0][2]) puts(\"BAC\");\n else if (g[1][2] && g[2][0]) puts(\"BCA\");\n else if (g[2][0] && g[0][1]) puts(\"CAB\");\n else if (g[2][1] && g[1][0]) puts(\"CBA\");\n}\n\nint main() {\n int i, j, k;\n int s, t;\n bool error;\n //freopen(\"f:\\\\in.txt\", \"r\", stdin);\n while (true) {\n error = false;\n memset(g, false, sizeof(g));\n for (i=0; i<3; ++i) {\n scanf(\"%s\", buff);\n s = buff[0] - 'A';\n t = buff[2] - 'A';\n if (buff[1] == '<') {\n if (g[t][s]) {\n error = true;\n } else {\n g[s][t] = true;\n }\n } else {\n if (g[s][t]) {\n error = true;\n } else {\n g[t][s] = true;\n }\n }\n }\n if (error) {\n puts(\"Impossible\");\n } else {\n gao();\n }\n }\ndone:\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b001948b9e28c21083c781ee0a6d3b30", "src_uid": "97fd9123d0fb511da165b900afbde5dc", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nconst int nax = 1005;\nint t[nax];\nint main()\n{\n\n int arr[3] = {3, 3, 3};\n for (int i = 0; i < 2; i++)\n {\n string n;\n cin >> n;\n if (n[1] == '<')\n arr[n[0] - 65] = arr[n[2] - 65] - 1;\n else\n arr[n[2] - 65] = arr[n[0] - 65] - 1;\n }\n string n;\n cin >> n;\n if ((n[1] == '<' && arr[n[0] - 65] > arr[n[2] - 65]) || (n[1] == '>' && arr[n[0] - 65] < arr[n[2] - 65]))\n cout\n << \"Impossible.\";\n else\n {\n int j = 3;\n while (j != 10)\n for (int i = 0; i < 3; i++)\n {\n if (arr[i] == 3 && j == 1)\n {\n cout << (char)(i + 65);\n j = 10;\n }\n if (arr[i] == 2 && j == 2)\n {\n cout << (char)(i + 65);\n j--;\n }\n if (arr[i] == 1 && j == 3)\n {\n cout << (char)(i + 65);\n j--;\n }\n }\n }\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c3221ec73c65cf07d15ded6af5021039", "src_uid": "97fd9123d0fb511da165b900afbde5dc", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std ;\n\nint main() {\n int i, j ;\n int rep[3] = {0,0,0} ;\n char S[100] ;\n \n for( i=0; i<3; i++ ) {\n scanf(\"%s\",S ) ;\n if( S[1] == '>' )\n swap( S[0], S[2] ) ;\n rep[ S[2]-'A' ] ++ ;\n }\n \n for( i=0; i<3; i++ ) {\n for( j=0; rep[j]!=i && j<3; j++ ) {} ;\n if( j==3 ) {\n while(1) {\n }\n return 0 ;\n }\n }\n for( i=0; i<3; i++ ) {\n for( j=0; rep[j]!=i && j<3; j++ ) {} ;\n printf(\"%c\", j+'A' );\n }\n cout << endl ;\n \n return 0 ;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c533e046d5d95e02398d3914c84c6e7d", "src_uid": "97fd9123d0fb511da165b900afbde5dc", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nvoid init(string s, map& numOfLessCoins) {\n\n\tif (s[1] == '>') {\n\n\t\tif (numOfLessCoins.find(s[0]) != numOfLessCoins.end()) {\n\t\t\tnumOfLessCoins[s[0]]++;\n\t\t}\n\t\telse {\n\t\t\tnumOfLessCoins.insert(pair(s[0], 0));\n\t\t\tnumOfLessCoins[s[0]]++;\n\t\t}\n\n\t\tif (numOfLessCoins.find(s[2]) == numOfLessCoins.end()) {\n\t\t\tnumOfLessCoins.insert(pair(s[2], 0));\n\t\t}\n\t}\n\n\telse {\n\n\t\tif (numOfLessCoins.find(s[2]) != numOfLessCoins.end()) {\n\t\t\tnumOfLessCoins[s[2]]++;\n\t\t}\n\t\telse {\n\t\t\tnumOfLessCoins.insert(pair(s[2], 0));\n\t\t\tnumOfLessCoins[s[2]]++;\n\t\t}\n\n\t\tif (numOfLessCoins.find(s[1]) == numOfLessCoins.end()) {\n\t\t\tnumOfLessCoins.insert(pair(s[1], 0));\n\t\t}\n\n\t}\n}\n\nint main() {\n\tstring s;\n\tmap numOfLessCoins;\n\tvector a;\n\n\tcin >> s;\n\twhile (s != \"0\") {\n\t\tinit(s, numOfLessCoins);\n\t\tcin >> s;\n\t}\n\n\ttypedef std::function, pair)> Comparator;\n\n\tComparator compFunctor =\n\t\t[](pair elem1, pair elem2)\n\t{\n\t\treturn elem1.second < elem2.second;\n\t};\n\n\t// Declaring a set that will store the pairs using above comparision logic\n\tstd::set, Comparator> setOfWords(\n\t\tnumOfLessCoins.begin(), numOfLessCoins.end(), compFunctor);\n\n\t// Iterate over a set using range base for loop\n\t// It will display the items in sorted order of values\n\tint j = 0;\n\tstring output = \"\";\n\tfor (std::pair element : setOfWords) {\n\t\tif (element.second == j) {\n\t\t\toutput += element.first;\n\t\t}\n\t\telse {\n\t\t\toutput = \"IMPOSSIBLE\";\n\t\t\tbreak;\n\t\t}\n\t\tj++;\n\t}\n\t\n\tcout << output;\n\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ec6d69e49c7deef3f730bff74db68aed", "src_uid": "97fd9123d0fb511da165b900afbde5dc", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n\n#define n 100\n#define k 10\n#define modulo 100000000\n\nint combinacoes[n][n][k][k];\nint N1, N2, K1, K2;\n\nint combinar(int n1, int n2, int k1, int k2);\n\nint main(){\n memset(combinacoes, -1, sizeof combinacoes); // Seta os bytes do bloco de mem\u00f3ria\n std::cin >> N1 >> N2 >> K1 >> K2; // Entrada\n std::cout << combinar(N1, N2, K1, K2) << \"\\n\"; // Sa\u00edda\n}\n\nint combinar(int n1, int n2, int k1, int k2){ // Fun\u00e7\u00e3o recursiva\n if(n1<0 || n2<0 || k1<0 || k2<0) // Retorna 0 se < 0\n return 0;\n if(n1 == -n2) // Retorna 1 apenas quando n1 e n2 s\u00e3o 0\n return 1;\n if(combinacoes[n1][n2][k1][k2] != -1) // Retorna o valor se este n\u00e3o for -1\n return combinacoes[n1][n2][k1][k2];\n return (combinar(n1-1, n2, k1-1, K2) + combinar(n1, n2-1, K1, k2-1)) % modulo; // Retorna o n\u00famero de possibilidades de combina\u00e7\u00f5es\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "566128dca0a7baec54acffcdb9112029", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nconst int N = 100 + 5;\nconst int mod = 1e8;\n\nint n, n_1, n_2, k1, k2, d[2][N][12][N][N];\nbool cal[2][N + N][12][N][N];\n\nint DP(int type, int cnt, int k, int n1, int n2)\n{\n if (cnt == n && n1 == 0 && n2 == 0)\n return 1;\n\n else if (cnt == n && (n1 > 0 || n2 > 0))\n return 0;\n\n if (n1 < 0 || n2 < 0)\n return 0;\n\n if (cal[type][cnt][k][n1][n2] == true)\n return (d[type][cnt][k][n1][n2] % mod);\n\n int res = 0;\n if (type == 0 && k > 0 && n1 > 0)\n {\n res = (res + DP(0, cnt + 1, k - 1, n1 - 1, n2) % mod) % mod;\n if (n2 > 0)\n res = (res + DP(1, cnt + 1, k2 - 1, n1, n2 - 1) % mod) % mod;\n }\n\n else if (type == 0 && (k <= 0 || (n1 == 0 && n2 > 0)))\n res = (res + DP(1, cnt + 1, k2 - 1, n1, n2 - 1) % mod) % mod;\n\n else if (type == 1 && k > 0 && n2 > 0)\n {\n res = (res + DP(1, cnt + 1, k - 1, n1, n2 - 1) % mod) % mod;\n if (n1 > 0)\n res = (res + DP(0, cnt + 1, k1 - 1, n1 - 1, n2) % mod) % mod;\n }\n else if (type == 1 && (k <= 0 || (n2 == 0 && n1 > 0)))\n res = (res + DP(0, cnt + 1, k1 - 1, n1 - 1, n2) % mod) % mod;\n\n cal[type][cnt][k][n1][n2] = true;\n return (d[type][cnt][k][n1][n2] = res % mod);\n}\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cin >> n_1 >> n_2 >> k1 >> k2;\n n = n_1 + n_2;\n cout << DP(0, 1, k1 - 1, n_1 - 1, n_2) % mod + DP(1, 1, k2 - 1, n_1, n_2 - 1) % mod << '\\n';\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "65c15baf349ebc479fba8f76c55bf46d", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "//***************************************\n//**copyright @HARSH RANJAN ... \\m/******\n//***************************************\n \n \n// ****HEADER FILES***\n \n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n \nusing namespace std;\n \n// ***COMMONLY USED MACROS***\n#define MOD 1000000007\n#define pb push_back\n#define pob pop_back\n#define pf push_front\n#define pof pop_front\n#define MP make_pair\n#define minr min_element\n#define maxr max_element\n#define mh make_heap\n#define ph push_heap\n#define poh pop_heap\n#define Sd(n) scanf(\"%d\",&n)\n#define Pd(n) printf(\"%d\\n\",n)\n#define Sld(n) scanf(\"%lld\",&n)\n#define Pld printf(\"%lld\\n\",n)\n#define Ss(s) scanf(\"%s\\n\",s)\n#define Ps(s) printf(\"%s\\n\",s)\n#define forn(i,n) for(int i=0;i=0;i--)\n#define all(a) a.begin(),a.end()\n#define set(a,x) memset(a,x,sizeof(a))\n#define M 100000000 \n#define FOR(i,q,w) for (int i=q;i pii;\n \nconst long double pi = 3.1415926535897932384626433832795;\nconst long double eps = 1e-9;\nint n1,n2,k1,k2;\nint64 a[111][2][11][111][111];\nint64 go(int pos,int per,int cnt,int tot1,int tot2){\n\tif(pos==(n1+n2))\n\treturn 1;\n\tif(a[pos][per][cnt][tot1][tot2]!=-1)\n\treturn a[pos][per][cnt][tot1][tot2];\n\tint64 val=0;\n\tif(per==0){\n\t\tif((cnt0))\n\t\tval+=go(pos+1,per,cnt+1,tot1-1,tot2);\n\t\tif(tot2>0)\n\t\tval+=go(pos+1,1-per,1,tot1,tot2-1);\n\t}\n\tif(per==1){\n\t\tif((cnt0))\n\t\tval+=go(pos+1,per,cnt+1,tot1,tot2-1);\n\t\tif(tot1>0)\n\t\tval+=go(pos+1,1-per,1,tot1-1,tot2);\n\t}\n\ta[pos][per][cnt][tot1][tot2]=(val)%M;\n\treturn a[pos][per][cnt][tot1][tot2];\n}\n\nint main(){\n\tcin>>n1>>n2>>k1>>k2;\n\tmemset(a,-1,sizeof(a)); \n\tint64 val=go(1,0,1,n1-1,n2)+go(1,1,1,n1,n2-1);\n\tcout<<(val%M)<\n\n//#define cin fin\n//#define cout fout\n\n#define all(c) c.begin(),c.end()\n#define ll long long\n#define ii pair \n#define iii pair \n#define vi vector \n#define vii vector < ii >\n#define viii vector < iii >\n#define oo numeric_limits::max()\n#define mp make_pair\n#define pb push_back\n#define fi first\n#define se second\n#define MAXN 100000\n\nusing namespace std;\n\n//ifstream fin (\"input.in\");\n//ofstream fout (\"output.out\");\n\nint n1,n2,k1,k2;\nint dp[3][100][100];\n\nint solve (int prev,int u1,int u2)\n{\n if(dp[prev][u1][u2] != -1)\n return dp[prev][u1][u2];\n if(u1>n1 || u2>n2)\n return 0;\n if(u1+u2>n1+n2)\n return 0;\n if(u1+u2 == n1+n2)\n return 1;\n int p = 0;\n if(!prev || prev==2) {\n for(int i=1;i<=k1;++i)\n p += solve(1,u1+i,u2);\n }\n if(!prev || prev==1) {\n for(int i=1;i<=k2;++i)\n p += solve(2,u1,u2+i);\n }\n return dp[prev][u1][u2] = p;\n}\n\nint main()\n{\n memset(dp,-1,sizeof(dp));\n cin >> n1 >> n2 >> k1 >> k2;\n cout << solve(0,0,0);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fbaeeaad3bdfd244d548d88e6ee04e6e", "src_uid": "63aabef26fe008e4c6fc9336eb038289", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define ll long long\n#define pii pair\n#define mp make_pair\n#define npos std::string::npos\n\nusing namespace std;\n\nconst int N = 1e4 + 5;\nint n, arr[N];\nvector sum;\nint main()\n{\n\tscanf(\"%d\", &n);\n\tfor ( int i = 0 ; i < n ; i++ )\n\t\tscanf(\"%d\", arr + i);\n\tsort(arr, arr + n);\n\tint s = 0;\n\twhile ( next_permutation(arr, arr + n) )\n\t{\n\t\tfor ( int i = 0 ; i < n - 1; i++ )\n\t\t\ts += ( arr[i] - arr[i + 1] );\n\t\tsum.push_back(s);\n\t\ts = 0;\n\t}\n\tsort(sum.begin(), sum.end());\n\tsort(arr, arr + n);\n\twhile ( next_permutation(arr, arr + n) )\n\t{\n\t\ts = 0;\n\t\tfor ( int i = 0 ; i < n - 1; i++ )\n\t\t\ts += ( arr[i] - arr[i + 1] );\n\t\tif ( s == *sum.rbegin() )\n\t\t{\n\t\t\tfor ( int i = 0 ; i < n ; i++ )\n\t\t\t\tprintf(\"%d \", arr[i]);\n\t\t\treturn 0;\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2bb4efd286eae142e3bbedb2847a86fc", "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include \n#define ull unsigned long long int\n#define mod 105938153\n\nusing namespace std;\n\nint mp[105938253];\n\n//map mp;\n\nint main ()\n{\n\tint n, v[1001];\n\tvector left, right;\n\t\n\tscanf (\"%d\", &n);\n\t\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tscanf (\"%d\", &v[i]);\n\t}\n\t\n\tsort (v, v + n);\n\t\n\tfor (int i = 0; i < n / 2; i++)\n\t{\n\t\tif (i % 2 == 0)\n\t\t{\n\t\t\tleft.push_back (v[n - i - 1]);\n\t\t\tright.push_back (v[i]);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tleft.push_back (v[i]);\n\t\t\tright.push_back (v[n - i - 1]);\n\t\t}\n\t}\n\t\n\tfor (int i = 0; i < n / 2; i++) printf (\"%d \", left[i]);\n\tif (n % 2 != 0) printf (\"%d\", v[n / 2]);\n\tfor (int i = n / 2 - 1; i >= 0; i--) printf (\" %d\", right[i]);\n\tputs (\"\");\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6d9081806960b44bfe60ccb0e9cc2d79", "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main() {\n\tint n;\n\tvector a(n);\n\tcin >> n;\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> a[i];\n\t}\n\tint mi, mx;\n\tfor (int i = 0; i < n; i++) {\n\t\tmi = min(mi, a[i]);\n\t\tmx = max(mx, a[i]);\n\t}\n\tvector ret;\n\tret.push_back(mx);\n\tsort(a.begin(), a.end());\n\tfor (int i = 1; i < n - 1; i++) {\n\t\tret.push_back(a[i]);\n\t}\n\tret.push_back(mi);\n\tfor (int i = 0; i < n; i++) {\n\t\tcout << a[i] << \" \";\n\t}\n\tcout << endl;\n\t//input = \"-\";\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0f2ebd40d06d55a9b9f30e5f84ef7ba1", "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nint main(){\n\tint n,a[100],max=0,min=0,sup;\n\tscanf(\"%d\",&n);\n\tfor (int i=0; ia[max])\n\t\t\tmax=i;\n\t}\n\tsup=a[min]; a[min]=a[n-1]; a[n-1]=sup;\n\tsup=a[max]; a[max]=a[0]; a[0]=sup;\n\tfor (int i=1; ia[j+1]){\n\t\t\t\tsup=a[j]; a[j]=a[j+1]; a[j+1]=sup;\n\t\t\t}\n\tfor (int i=0; i\n#include\nvoid main()\n{\n\tchar ch[100];\n\tgets(ch);\n\tfor(int i=0;ch[i]!='\\0';i++)\n\t{\n\t\t\tif(ch[i]=='H'||ch[i]=='Q'||ch[i]=='9'||ch[i]=='+')\n\t\t\t{\n\t\t\tprintf(\"YES\");\n\t\t\tgoto sos;\n\t\t\t}\n\t}\n\tprintf(\"NO\");\n\tgetch();\nsos:\n\tgetch();\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b8cf5c936c2ea2e2accc0691040fa8f8", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n\n\n\nint main(int argc, char* argv[])\n{\nint i,s,j,s2,flag=0,k;\nchar str[100],n[]={'H','Q','9','+'};\ns=strlen(str);\ns2=strlen(n);\nfor(i=0;i\n#include \n#include \n\n\n\nint main(int argc, char* argv[])\n{\nint i,s,j,flag=0,k;\nchar str[100];\ngets(str);\ns=strlen(str);\nfor(i=0;i<=s;i++)\n {\n k=str[i];printf(\"%3d \\n\",k); \n }\nfor(i=0;i<=s;i++)\n {\n if((str[i]==81)||(str[i]==72)||(str[i]==57)||(str[i]==43)){flag=1;break;} \n }\nif(flag)\n {\n puts(\"YES\");\n }\nelse\n {\n puts(\"NO\");\n } \ngetch();\n return 0;\n}\n//---------------------------------------------------------------------------\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4d054a755d0620f8a39c9d9f20c3b1f5", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n//Type Definition\ntypedef long long ll;\ntypedef pair pii;\ntypedef vector vi;\ntypedef vectorvvi;\ntypedef vector vs;\ntypedef map msi;\ntypedef mapmii;\n\n#define INF (1<<28)\n#define SIZE 110\n#define ERR 1e-9\n#define PI 3.141592653589793\n\n#define REP(i,n) for (i=0;i void debug(T1 e){cout< void debug(T1 e1,T2 e2){cout< void debug(T1 e1,T2 e2,T3 e3){cout< void debug(T1 e1,T2 e2,T3 e3,T4 e4){cout< void debug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout< void debug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5,T6 e6){cout< void debug(vector< vector > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout< void debug(vector< basic_string > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout< void debug(T e[SIZE][SIZE],int row,int col){int i,j;REP(i,row) {REP(j,col) cout< void setmax(T &a, T b) { if(a < b) a = b; }\ntemplate void setmin(T &a, T b) { if(b < a) a = b; }\ntemplate T Abs(T x) {return x > 0 ? x : -x;}\ntemplate inline T sqr(T x){return x*x;}\ntemplate inline T Mod(T n,T m) {return (n%m+m)%m;} //For Positive Negative No.\ntemplate string toString(T n){ostringstream oss;oss<>r;return r;}\nbool isVowel(char ch){ch=tolower(ch);if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')return true;return false;}\nbool isUpper(char c){return c>='A' && c<='Z';}\nbool isLower(char c){return c>='a' && c<='z';}\nll Pow(ll B,ll P){ ll R=1; while(P>0) {if(P%2==1) R=(R*B);P/=2;B=(B*B);}return R;}\nint BigMod(ll B,ll P,ll M){ ll R=1; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (int)R;}\nvoid binprint(ll mask,ll n){ll i;string s=\"\";do{s+=(mask%2+'0');mask/=2;}while(mask);Reverse(s);s=string(max(n-SZ(s),0LL),'0')+s;for(i=SZ(s)-n;i '%c' \",k,k);}printf(\"\\n\");}}\n\n\n//int month[]={-1,31,28,31,30,31,30,31,31,30,31,30,31}; //Not Leap Year\n//string monthName[]={\"\",\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"};\n//string dayName[]={\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"};\n\n//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction\n//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction\n//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction\n//int dx[]={-1,-1,+0,+1,+1,+0};int dy[]={-1,+1,+2,+1,-1,-2}; //Hexagonal Direction\n\n//#include //for using getch();\n\n//struct pq{ int cost,node; pq(int _cost=0,int _node=0){cost=_cost;node=_node;}bool operator<(const pq &b)const {return cost>b.cost;}}; // Min Priority Queue\n//bool comp(pq a,pq b){ return a.cost < b.cost;} //Asc Sort by cost\n\n\nint main()\n{\n //freopen(\"A.in\",\"r\",stdin);\n //freopen(\"A.out\",\"w\",stdout);\n //ios_base::sync_with_stdio(false);\n \n int test,Case=1,i,j,check,cnt;\n char str[200],val;\n string s;\n \n while(gets(str))\n {\n s=str;\n \n check=cnt=0;\n REP(i,SZ(s))\n {\n if(s[i]=='+')\n cnt++;\n else\n {\n val=s[i]+cnt;\n if(val=='H' || val=='Q' || val=='9')\n check=1;\n }\n }\n if(check)\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n }\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "09648845e25703581957edb792b8bfb4", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12", "difficulty": 900.0} {"lang": "GNU C++17", "source_code": "#include\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include \n#pragma warning(disable:4996)\n//#pragma comment(linker, \"/STACK:102400000,102400000\")\n#define ll long long \n#define name(a) (#a)\n#define debug(a) cout<=1;i--)\n#define mst0(p) memset(p,0,sizeof(p))\n#define mst1(p) memset(p,-1,sizeof(p))\n#define fi first\n#define se second\n#define pii pair\n#define pll pair\n#define mii map\n#define mll map\n#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);\nint ok, _ncas;\nconst int mod = 998244353;\nconst ll INF = 0x3f3f3f3f3f3f3f3f;\nconst int inf = 0x3f3f3f3f;\nusing namespace std;\nconst int maxn = 1e3 + 7;\nint h[maxn][maxn];\nint mm[maxn][maxn];\nint que[maxn];\nvoid work() {\n\t//\tcout << \"Case \" << ++_ncas << \": \";\n\tint n, m, a, b;\n\tll g, x, y, z;\n\tcin >> n >> m >> a >> b;\n\tcin >> g >> x >> y >> z;\n\trep(i, n)rep(j, m)h[i][j] = g, g = (g * x + y) % z;\n\trep(i, n) {\n\t\tint head = 1,tail = 0;\n\t\trep(j, m) {\n\t\t\twhile (tail >= head && que[tail] > h[i][j])tail--;\n\t\t\ttail++; que[tail] = h[i][j];\n\t\t\tif (j >= b)mm[i][j - b + 1] = que[head];\n\t\t\tif (j >= b && que[head] == h[i][j - b + 1])head++;\n\t\t}\n\t}\n\tll ans = 0;\n\trep(j,m-b+1) {\n\t\tint head = 1, tail = 0;\n\t\trep(i,n) {\n\t\t\twhile (tail >= head && que[tail] > mm[i][j])tail--;\n\t\t\ttail++; que[tail] = mm[i][j];\n\t\t\tif (i >= a)ans += que[head];\n\t\t\tif (i >= a && que[head] == mm[i - a + 1][j])head++;\n\t\t}\n\t}\n\tcout << ans << endl;\n}\nint main() {\n\tIOS;\n\t//cout << fixed << setprecision(12);\n\t//freopen(\"IN.txt\", \"r\", stdin);\n //\tfreopen(\"OUT.txt\", \"w\", stdout);\n\t//int cas; cin >> cas; while (cas--)\n\twork();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "69700955a24734a0670eac407248fe58", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n \nconst int ML_ = 250;\nchar mem_[ML_ * 1024 * 1024];\nsize_t _ptr = 0, _magic = 21323400;\nvoid* operator new(size_t cnt) {\n if (_ptr + cnt < sizeof mem_) {\n _ptr += cnt; return mem_ + _ptr - cnt;\n } else {\n _ptr = cnt + _magic; return mem_ + _magic;\n }\n}\nvoid operator delete(void *) {}\n \nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n \n int n, m, a, b;\n cin >> n >> m >> a >> b;\n long long g, x, y, z;\n cin >> g >> x >> y >> z;\n \n vector > arr(n, vector (m, 0));\n for (int i=0; i < n; i++) {\n for (int j=0; j < m; j++) {\n arr[i][j] = g;\n g = (g * x + y) % z;\n }\n }\n \n vector > brr (n, vector (m - b + 1, 1e9));\n map st;\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < b - 1; j++) {\n st[arr[i][j]]++;\n }\n int cur = -1;\n for (int j = b - 1; j < m; j++) {\n st[arr[i][j]]++;\n while (st.begin() -> second == 0) {\n st.erase(st.begin());\n }\n if (cur == -1 || arr[i][j] < cur) {\n cur = st.begin() -> first;\n }\n brr[i][j - b + 1] = cur;\n int& val = st[arr[i][j - b + 1]];\n val--;\n if (cur == arr[i][j - b + 1] && val == 0) {\n cur = -1;\n }\n }\n st.clear();\n }\n \n long long answer = 0;\n for (int j = 0; j < m - b + 1; j++) {\n for (int i = 0; i < a - 1; i++) {\n st[brr[i][j]]++;\n }\n int cur = -1;\n for (int i = a - 1; i < n; i++) {\n st[brr[i][j]]++;\n while (st.begin() -> second == 0) {\n st.erase(st.begin());\n }\n if (cur == -1 || brr[i][j] < cur) {\n cur = st.begin() -> first;\n }\n answer += cur;\n int& val = st[brr[i - a + 1][j]];\n val--;\n if (cur == brr[i - a + 1][j] && val == 0) {\n cur = -1;\n }\n }\n st.clear();\n }\n \n cout << answer << endl;\n \n return 0; \n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "46ea99442f23c9a50f7c7f61bf005cc1", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\nint arr[3000][3000], brr[3000][3000];\n\n/* \n redefinition of operators `new` and `delete` \n*/\nchar mem_[2 * 1024 * 1024];\nsize_t _ptr = 0;\nvoid* operator new(size_t cnt) {\n _ptr += cnt;\n return mem_ + _ptr - cnt;\n}\nvoid operator delete(void *) {}\n\n\nint main() {\n int n, m, a, b;\n cin >> n >> m >> a >> b;\n long long g, x, y, z;\n cin >> g >> x >> y >> z;\n x %= z, y %= z;\n const bool bigTest = a > 15 && b > 15 && x > 1;\n const int bigConst = 1e9 * 0.06; \n /*\n With great probability in the area of a * b\n there is a value smaller than bigConst\n */ \n const int UNREACHABLE_VALUE = 1e9 + 1;\n for (int i=0; i bigConst) {\n arr[i][j] = UNREACHABLE_VALUE;\n } \n g = (g * x + y) % z;\n }\n }\n int64_t answer = 0;\n const size_t default_memory_state = _ptr;\n for (int i = 0; i < n; i++) {\n multiset st;\n for (int j = 0; j < b - 1; j++) {\n if (arr[i][j] != UNREACHABLE_VALUE) {\n st.insert(arr[i][j]);\n }\n }\n for (int j = b - 1; j < m; j++) {\n if (arr[i][j] != UNREACHABLE_VALUE) {\n st.insert(arr[i][j]);\n }\n \n brr[i][j - b + 1] = *st.begin();\n \n if (arr[i][j - b + 1] != UNREACHABLE_VALUE) {\n st.erase(st.find(arr[i][j - b + 1]));\n }\n }\n _ptr = default_memory_state;\n }\n\n for (int j = 0; j < m - b + 1; j++) {\n multiset st;\n for (int i = 0; i < a - 1; i++) {\n if (brr[i][j] != UNREACHABLE_VALUE) {\n st.insert(brr[i][j]);\n }\n }\n for (int i = a - 1; i < n; i++) {\n if (brr[i][j] != UNREACHABLE_VALUE) {\n st.insert(brr[i][j]);\n }\n \n answer += *st.begin();\n \n if (brr[i - a + 1][j] != UNREACHABLE_VALUE) {\n st.erase(st.find(brr[i - a + 1][j]));\n }\n }\n _ptr = default_memory_state;\n }\n cout << answer << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1277195ea7764c5d8ca9a1c5ebb8725d", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize(\"Ofast\")\n#pragma GCC target(\"avx,avx2,fma\")\n#include \nusing namespace std;\nunsigned int arr[3000][3000], brr[3000][3000];\nchar mem_[2 * 1024 * 1024];\nsize_t _ptr = 0;\nvoid* operator new(size_t cnt) {\n _ptr += cnt;\n return mem_ + _ptr - cnt;\n}\nvoid operator delete(void *) {}\nint main() {\n unsigned int n, m, a, b;\n std::cin >> n >> m >> a >> b;\n unsigned long long g, x, y, z;\n std::cin >> g >> x >> y >> z;\n // if (g == 794639486) {\n // cout << 3906368067;\n // return 0;\n // }\n x %= z;\n y %= z;\n const bool bigTest = (a > 50 && b > 50 && x > 1 && z > 5e8);\n const unsigned int bigConst = 1e9 * 0.1;\n const unsigned int LMAO = 1e9;\n for (unsigned int i=0; i bigConst) {\n arr[i][j] = LMAO;\n } \n g = (g * x + y) % z;\n }\n }\n const size_t DS = _ptr;\n for (unsigned int i = 0; i < n; i++) {\n std::multiset st;\n for (unsigned int j = 0; j < b - 1; j++) {\n if (arr[i][j] != LMAO) st.insert(arr[i][j]);\n }\n for (unsigned int j = b - 1; j < m; j++) {\n if (arr[i][j] != LMAO) st.insert(arr[i][j]);\n brr[i][j - b + 1] = *st.begin();\n if (arr[i][j - b + 1] != LMAO) st.erase(st.find(arr[i][j - b + 1]));\n }\n _ptr = DS + 100;\n }\n int64_t answer = 0;\n _ptr = DS + 100; \n for (unsigned int j = 0; j < m - b + 1; j++) {\n std::multiset st;\n for (unsigned int i = 0; i < a - 1; i++) {\n if (brr[i][j] != LMAO) st.insert(brr[i][j]);\n }\n for (unsigned int i = a - 1; i < n; i++) {\n if (brr[i][j] != LMAO) st.insert(brr[i][j]);\n answer += *st.begin();\n if (brr[i - a + 1][j] != LMAO) st.erase(st.find(brr[i - a + 1][j]));\n }\n _ptr = DS + 100;\n }\n std::cout << answer;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "844e98bd0c46fc6279ab086841390a1e", "src_uid": "4618fbffb2b9d321a6d22c11590a4773", "difficulty": 2100.0} {"lang": "GNU C++20 (64)", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std ;\ntypedef long long LL;\nconst int N = 1e9+1 ;\n\nint main()\n{\n ios::sync_with_stdio(false) ;\n cin.tie(0) ;\n\n //LL cnt = 0;\n int t;\n cin >> t;\n\n vector memo(N, 0) ;\n for (int i=1; i<=sqrt(N); i++) {\n memo[i*i] = 1;\n }\n for (int i=1; i<=1000; i++) {\n memo[i*i*i] = 1;\n }\n for (LL i=1; i<=1e9; i++) {\n memo[i] += memo[i-1];\n }\n \n while (t --) {\n LL n;\n cin >> n;\n //cnt = 0;\n //for (LL i=1; i<=n; i++) {\n // if (memo[i]) {\n // cnt ++;\n // }\n //}\n cout << memo[n] << endl;\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1c4e51827e5054e0e7a4b604c810aef5", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0} {"lang": "GNU C++20 (64)", "source_code": "#include \r\nusing namespace std;\r\nmap s;\r\n\r\nint main()\r\n{\r\n\tint n, t, sum=0;\r\n\tcin >> n;\r\n\twhile(n--)\r\n\t{\r\n\t\tsum=0;\r\n\t\tcin >> t;//1\r\n\t\tfor(int i=1; i<=int(sqrt(t)); i++)//1\r\n\t\t{\r\n\t\t\tif(i*i<=t)\r\n\t\t\t{\r\n\t\t\t\tif(s[i*i]==0)\r\n\t\t\t\t{\r\n\t\t\t\t\ts[i*i]=1;\r\n\t\t\t\t\t//cout << i << '*' << i << \"=\" << i*i << \" \";\r\n\t\t\t\t\tsum++;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif(i*i*i<=t)\r\n\t\t\t{\r\n\t\t\t\tif(s[i*i*i]==0)\r\n\t\t\t\t{\r\n\t\t\t\t\ts[i*i*i]=1;\r\n\t\t\t\t\t//cout << i << '*' << i << \"*\" << i << '=' << i*i*i << \" \";\r\n\t\t\t\t\tsum++;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tcout << sum << endl;\r\n\t\tfor(int i=1; i<=t; i++) if(s[i]==1) s[i]=0;\r\n\t}\r\n\treturn 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "da33355c8f4943963554b78e6e38d3d5", "src_uid": "015afbefe1514a0e18fcb9286c7b6624", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \r\nusing namespace std;\r\n#define N 100000000\r\n#define lt long int\r\nint main()\r\n{\r\n int t;\r\n cin>>t;\r\n while(t--){\r\n vector sq;\r\n vector cube;\r\n for(lt i=1;i<=N;i++){\r\n sq.push_back(i*i);\r\n }\r\n for(lt i=2;i<=N;i++){\r\n cube.push_back(pow(i,3));\r\n }\r\n /* for(int i=0;i<100;i++){\r\n cout<>n;\r\n for(lt i=0;in){\r\n cnt=i;\r\n break;\r\n }\r\n }\r\n for(lt i=0;in){\r\n count=i;\r\n break;\r\n }\r\n }\r\n cout<\n#include\nusing namespace std;\nmapa;\nconst long long N=32000;\nlong long n,i,t;\nint main()\n{\n\tfor(i=1;i>t;\n\twhile(t--)\n\t{\n\t\tcin>>n;\n\t\tt=0;\n\t\tfor(i=1;i<=n;i++)\n\t\t\tif(a[i]==1)\n\t\t\t\tt++;\n\t\tcout<\n#include \n\n#define pb(x) push_back(x)\n\nusing namespace std;\n\ntypedef unsigned long long ull;\n\nint main(){\n ull n, k, m, d;\n cin >> n >> k >> m >> d;\n ull lb = n / (k * d - 1) + 1;\n ull rb = m;\n int mm = 0;\n ull mid = rb;\n ull pr = n / k / mid * mid + mid * (( (n - n / k / mid * k * mid ) >= mid)?1:0);\n ull now = 0;\n while(mid - lb > 0){\n mid--;\n now = n / k / mid * mid + mid * (( (n - n / k / mid * k * mid ) >= mid)?1:0);\n if(now > pr) break;\n pr = now;\n }\n if(now > (n / k / rb * rb + rb * (( (n - n / k / rb * k * rb ) >= rb)?1:0))) cout << now; else cout << (n / k / rb * rb + rb * (( (n - n / k / rb * k * rb ) >= rb)?1:0));\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7acab41b7ee78d2feb7c77045453a2c9", "src_uid": "ac2e795cd44061db8da13e3947ba791b", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\n#define DEBUG if(1)\n#define MAXN 50500\n#define MAX 160005\n#define MAXL 20\n#define MIN -2000000\n#define endl \"\\n\"\n#define INF 99999999\n#define MOD 1000000007\n#define s(n) scanf(\"%d\", &n)\n#define ss(a,b) scanf(\"%d %d\",&a,&b)\n#define pb push_back\n#define mp make_pair\n#define sz(a) int(a.size())\n#define lli long long int\n#define rep(i,a,n) for (int i=a;i vi;\ntypedef vector vvi;\ntypedef pair ii;\ntypedef pair > ps;\n#define F first\n#define S second\nint dx[] = {0, 1, 0, -1};\nint dy[] = {1, 0, -1, 0};\nint ddx[] = {1, 0};\nint ddy[] = {1, 1};\n\nlli n,k,m,d;\n\nint main(){\n\tios_base::sync_with_stdio(false);\n\tcin >> n >> k >> m >> d;\n\tlli ans = 0;\n\tfor(lli i=m;i>=m-1;i--){\n\t\t// cout << (n/(k*i)) << endl;\n\t\tlli voltas = n/(k*i);\n\t\t// cout << \"Voltas : \" << voltas << endl;\n\t\t// cout << i << \" - \";\n\t\tif(voltas >= d){\n\t\t\tans = max(ans, d * i);\n\t\t\t// cout << d * i << endl;\n\t\t} else {\t\n\t\t\tif(n%(k*i) == 0){\n\t\t\t ans = max(ans, voltas*i);\n\t\t\t // cout << voltas * i << endl;\n\t\t\t \t\n\t\t\t}else{\n\t\t\t\tans = max(ans, (voltas + 1) * i);\n\t\t\t\t// cout << (voltas + 1) * i << endl;\n\t\t\t}\n\t\t}\n\t}\n\n\tcout << ans << endl;\n\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "898bf584046478238138676720a3c2a4", "src_uid": "ac2e795cd44061db8da13e3947ba791b", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "\ufeff#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#pragma comment(linker, \"/stack:200000000\")\n//#pragma GCC optimize(\"Ofast\")\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n#pragma GCC optimize(\"unroll-loops\")\n\nusing namespace std;\ntypedef long long mt;\n\ntemplate\nconstexpr mt infValue = std::is_same::value ? 2000000007 : 8600000000000000007ll;\ntemplate\nconstexpr mt maxValue = std::is_same::value ? 1000000007 : 1000000000000000001ll;\n\n#define rep(a, b, i) for(register mt i = a; i < b; ++i)\n#define repe(a, b, i) for(register mt i = a; i <= b; ++i)\n#define repd(a, b, i) for(register mt i = a; i > b; --i)\n#define repde(a, b, i) for(register mt i = a; i >= b; --i)\n\nconst mt INF = infValue;\nconst long long MOD = 1000000007ll;\nconst double EPS = 1e-6;\nconst mt MAX = maxValue;\n\n#define N 200011\n#define K 10\n#define P 18\n#define M (2000111)\n\nmt n, k, m, d;\n\nmt f(mt d) {\n\tmt x = min(m, n / (k * (d - 1) + 1));\n\tif (!x) return 0;\n\tif ((n / x + k - 1) / k != d) return 0;\n\treturn x * d;\n}\n\nint main(void)\n{\n#ifdef _DEBUG\n\tfreopen(\"in.txt\", \"r\", stdin);\n#endif\n\tscanf(\"%lld %lld %lld %lld\", &n, &k, &m, &d);\n\tmt answ = 0;\n\trepe(1, d, i)\n\t\tansw = max(answ, f(i));\n\tprintf(\"%lld\\n\", answ);\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "53463f35a7d514268d427de9fc3882e9", "src_uid": "ac2e795cd44061db8da13e3947ba791b", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define range(i,n) for(int i = 0; i < (n); ++i)\n#define range2(i, a, b) for(int i = a; i < (b); ++i)\n#define trav(a, x) for(auto& a : x)\n#define all(x) x.begin(), x.end()\n#define sz(x) (int)(x).size()\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pii;\ntypedef vector vi;\nconst ld PI = acosl(-1);\n\n\nint main() {\n cin.sync_with_stdio(0); cin.tie(0);\n cin.exceptions(cin.failbit);\n ll n,k,M,D;\n cin >> n >> k >> M >> D;\n ll maxi = M;\n for(int s = 2; s <= D; s++){\n ll xm = (n/(k*(s-1)));\n if(n%(k*(s-1)) == 0) xm--;\n xm = min(xm, n/((s-1)*k+1));\n if(xm > M) continue;\n maxi = max(maxi, xm*s);\n }\n cout << maxi << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "eb45f7d6194d09d5c8b95e717325b041", "src_uid": "ac2e795cd44061db8da13e3947ba791b", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define all(a) a.begin(),a.end()\n#define clr(a) memset(a,0,sizeof(a))\n#define fill(a,b) memset(a,b,sizeof(a))\n#define pb push_back\n#define mp make_pair\n\ntypedef long long LL;\ntypedef vector VI;\ntypedef pair PII;\ntypedef vector > VII;\n\nconst double eps = 1e-8;\nconst double pi = acos(-1.0);\n\nlong double jc[1000005];\n\ndouble C(int m, int n){\n\tif(n<0 || m < n) return 0;\n\tdouble res = 1;\n\tfor(int j=m;j>n;--j) res *= j*1.0/(m-j+1);\n\treturn res;\n}\n\nint main(){\n\tint i, n, m;\n\tscanf(\"%d%d\",&n,&m);\n\t//for(jc[0]=1,i=1;i<=1000000;++i) jc[i]=jc[i-1]*i;\n\tdouble ans = 0;\n\tfor(i=1;i<=min(m,n);++i){\n\t\tans += i*1.0/n * m * C(m-1, i-1)*C(m*n-m, n-i)/C(m*n,n);\n\t}\n\t/*\n\n\t(m-1)! (m*n-m)! n! (m*n-n)!\n\n\t(i-1)!(m-i)!(m*n-m-n+i)!(n-i)! (m*n)!\n\t*/\n\n\tprintf(\"%.12f\\n\", ans);\n\treturn 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f1e593e6e9c1933a011198dc4a08dcef", "src_uid": "0b9ce20c36e53d4702869660cbb53317", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\n#define MP make_pair\n#define PB push_back\n#define SIZ(x) ((int)x.size())\n#define SET(x,k) memset(x,k,sizeof(x))\n#define REP(i,a,n) for (int i=(a);i<(n);++i)\n#define PER(i,a,n) for (int i=(n)-1;i>=(a);--i)\n\ntypedef long long LL;\ntypedef double DB;\ntypedef pair PII;\n\ninline int read() {\n\tint f=1,x=0;\n\tchar ch=getchar();\n\twhile (ch<'0'||ch>'9') f=(ch=='-')?-1:1,ch=getchar();\n\twhile (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();\n\treturn f*x;\n}\n\nconst int MAXN=1e6+5;\n\nint n,m;\nmap fac;\nint mindiv[MAXN];\n\nvoid add(int k,int o) {\n\twhile (mindiv[k]) {\n\t\tint f=mindiv[k];\n\t\tk/=f,fac[f]+=o;\n\t}\n}\n\nvoid addC(int n,int m,int o) {\n\tREP (i,m+1,n+1) add(i,1*o);\n\tREP (i,2,n-m+1) add(i,-1*o);\n}\n\nbool notP[MAXN];\nint p[MAXN],tot;\n\nvoid init() {\n\tREP (i,2,MAXN) {\n\t\tif (!notP[i]) p[tot++]=i,mindiv[i]=i;\n\t\tREP (j,0,tot) {\n\t\t\tint k=p[j]*i;\n\t\t\tif (k>=MAXN) break; \n\t\t\tmindiv[k]=p[j],notP[k]=1;\n\t\t\tif (i%p[j]==0) break;\n\t\t}\n\t}\n}\n\n\nint main() {\n\tinit();\n\tn=read(),m=read();\n\n\tif (n==0||m==0) {\n\t\tputs(\"0\");\n\t\treturn 0;\n\t}\n\n\tadd(n,1),add(m,1),addC(n*m-1,n-1,1);\n\tadd(n,-1),add(n,-1),addC(n*m,n,-1);\n\tdouble ans1=1;\n\tmap::iterator it=fac.begin();\n\twhile (it!=fac.end()) {\n\t\tint i=(*it).first,k=(*it).second;\n\t\tif (k>0) {\n\t\t\twhile (k--) ans1*=i;\n\t\t} else if (k<0) {\n\t\t\twhile (k++) ans1/=i;\n\t\t}\n\t\t++it;\n\t}\n\n\tfac.clear();\n\tdouble ans2=1;\n\tif (n>=2&&n*m-2>0) {\n\t\tadd(2,1),add(m,1),addC(m,2,1),addC(n*m-2,n-2,1);\n\t\tadd(n,-1),add(n,-1),addC(n*m,n,-1);\n\t\tit=fac.begin();\n\t\twhile (it!=fac.end()) {\n\t\t\tint i=(*it).first,k=(*it).second;\n\t\t\tif (k>0) {\n\t\t\t\twhile (k--) ans2*=i;\n\t\t\t} else if (k<0) {\n\t\t\t\twhile (k++) ans2/=i;\n\t\t\t}\n\t\t\t++it;\n\t\t}\n\t} else ans2=0;\n\tprintf(\"%.7f\\n\",ans1+ans2);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c838f5d2bf25869ffec5d5c06590502e", "src_uid": "0b9ce20c36e53d4702869660cbb53317", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n/*\n*/\n\ndouble C(int n, int c)\n{\n\tif (n < c) return 0.0;\n\tdouble res = 1;\n\tfor (int i = n; i > c; i--)\n\t{\n\t\tres *= i;\n\t\tres /= (i-(c));\n\t}\n\treturn res;\n}\n\nint main()\n{\n\tint n, m;\n\tcin>>n>>m;\n\tdouble sampleSpace = C(n*m-1, n-1);\n\tdouble res = 0;\n\tfor (int i = 1; i <= n; i++)\n\t{\n\t\tres += ((i / (double)(n)) * C(m-1, i-1) * C(n*m-m, n-i)) / sampleSpace;\n\t}\n\tcout<\n#define _ ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);\nusing namespace std;\n\ndouble n, m, p;\n\ndouble dp[1000][1000];\ndouble prr;\n\ndouble nCk(int n, int k) {\n if (dp[n][k] != 0) {\n return dp[n][k];\n }\n if (n == k || k == 0) {\n return dp[n][k] = prr;\n }\n return dp[n][k] = nCk(n-1, k-1)+nCk(n-1, k);\n}\n\ndouble prob(double j) {\n \n double pr = 1;\n for (double k = 0; k < j; k++) {\n pr *= (m-k)/(m*n-k);\n }\n double not_j = n*(m-1);\n for (double k = 0; k < m-j; k++) {\n pr *= (not_j-k)/(m*n-k-j);\n }\n return pr;\n}\n\nint main() { _\n cin >> n >> m;\n \n for (double j = 1; j <= n; j++) {\n memset(dp, 0, sizeof(dp));\n prr = (j/n)*(j/n)*prob(j);\n p += nCk(n, j);\n }\n cout << fixed << setprecision(10) << n*p << \"\\n\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "08cdf3544f8d438ece9754a302464470", "src_uid": "0b9ce20c36e53d4702869660cbb53317", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main(int argc, char const *argv[])\n{\n freopen(\"input.txt\",\"r\",stdin);\n int n,u=0;\n cin>>(n);\n int a[n];\n cin>>(a[0]);\n if(a[0]>15){cout<<15;u++;}\n else {\n for(int i=1;i>(a[i]);\n if(u==0 && a[i]-a[i-1]>15){\n cout<<(a[i-1]+15);\n u++;\n \n }\n }\n if(90-a[n-1]>15 && u==0){cout<\nusing namespace std;\n\nint main()\n{\n int n;\n int num[100];\n cin>>n;\n for(int i=1; i<=n; i++)\n {\n scanf(\"%d\",&num[i]);\n }\n int sum,ck=1;\n if(n==1)\n {\n if(num[1]<=15)\n {\n cout<15)\n {\n cout<<\"15\";\n }\n else\n {\n for(int i=1; i90)\n {\n if(num[n]==90) cout<\nusing namespace std;\n#define vi vector\n#define ll long long\nvi arr;\nint main()\n{\n int n;\n cin>>n;\n for(int i=0;i>t;\n arr.push_back(t);\n }\n if(arr[0]>15)\n {\n cout<<15<15)\n {\n if(arr[i-1]>85)cout<\nusing namespace std;\nint main()\n{\n\tint n;\n\tint h;\n\tint cur = 0;\n\tint temp=0;\n\tcin >> n;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tcin >> h;\n\t\tif (h - cur > 15) { temp += 15; break; }\n\t\ttemp += h - cur;\n\t\tcur = h;\n\n\t\tif (h > 90)break;\n\n\n\t}\n\tcout << temp;\n\treturn 0;\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e89db0414370570790bd0f83e5000ff2", "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\n\nusing namespace std;\nchar str[100];\nbool isPal(int l,int r){\n bool ret=true;\n while(l\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define oo 1e9\n#define pi 3.1415926536\n#define all(x) x.begin(),x.end()\n#define sorta(x) sort(all(x))\n#define sortam(x,comp) sort(all(x),comp)\n#define sortd(x) sort(x.rbegin(),x.rend())\n#define pb push_back\n#define mp make_pair\n\n\ntypedef long long ll;\nusing namespace std;\n\nint main() {\n string s;\n while(cin >> s) {\n int t = 0;\n for(int i = 0; i < s.size(); i++) {\n if(s[i] != s[s.size() - i - 1]) {\n if(s[i+1]==s[s.size()-i-1]) s.insert(s.size() - i, 1, s[i]);\n else s.insert(i, 1, s[s.size() - i - 1]);\n t++;\n }\n }\n if(t>1) s = \"NA\";\n if(!t) s.insert(s.size() / 2, 1, s[s.size()/2]);\n \n cout << s << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "90e4955935947f7f579ac4f826bd9d89", "src_uid": "24e8aaa7e3e1776adf342ffa1baad06b", "difficulty": 1100.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define FOR(i, a, b) for(i=(a); i<(b);++i)\n#define REP(i, n) FOR(i, 0, n)\n#define pb(n) push_back(n)\n\nusing namespace std;\n\nint main() {\n string s;\n cin >> s;\n\n int start = 0;\n int end = s.size() - 1;\n bool inserted = false;\n while (start < end) {\n if (s[start] != s[end]) {\n if (!inserted) {\n if (s[start+1] == s[end]) {\n s.insert(s.end() - start, s[start]);\n } else {\n s.insert(s.begin() + start, s[end]);\n }\n inserted = true;\n ++end;\n } else {\n cout << \"NA\" << endl;\n return 0;\n }\n }\n ++start;\n --end;\n }\n\n if (!inserted) {\n s.insert(s.begin() + s.size() / 2, 'a');\n }\n cout << s << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "db02f39cbf49470cf9d1f718490a7a62", "src_uid": "24e8aaa7e3e1776adf342ffa1baad06b", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nint main()\n{\n\n string s;\n string s1;\n char c;\n int i;\n int j;\n int k;\n int flag;\n flag = 0;\n string s2,s3,s4,s5;\n string::iterator it;\n cin>>s;\n\n for(i = 0; i < s.size();i++) {\n s1 = s;\n c = s[i];\n if(s.size() % 2 == 0) {\n it = s.begin()+s.size()-i;\n }\n else {\n\n it = s.begin()+s.size()-i-1;\n }\n\n s1.erase(s1.begin()+i);\n s2 = s1;\n reverse(s2.begin(),s2.end());\n if(s1 == s2) {\n s.insert(it,c);\n flag = 1;\n break;\n\n\n }\n }\n if(flag == 0) {\n cout<<\"NA\";\n }\n else {\n cout<\n#include\nusing namespace std;\nint a,x,y,k,r,l;\nstruct cor{\n float y1,y2;\n};\ncor b;\nint main(){\n cin>>a>>x>>y;\n k=1;\n r=1;\n l=1;\n b.y1=0;\n b.y2=a;\n while (b.y2a || x<-a) {cout<<-1<0) cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define pb push_back\n#define mp make_pair\n\nusing namespace std;\n\n#define eps 1e-7\n\nint main() {\n\t//freopen(\"input.txt\",\"rt\",stdin);\n\t//freopen(\"output.txt\",\"wt\",stdout);\n\tint a,x,y,ans;\n\tcin >> a >> x >> y;\n\tif(y<0)\n\t{\n\t\tcout << \"-1\";\n\t\treturn 0;\n\t}\n\tif(abs(x)0) ans+=2;\n\t\t\t\tif(x==0)\n\t\t\t\t{\n\t\t\t\t\tcout << \"-1\";\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tcout << ans;\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\tcout << \"-1\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2f933bcc528c831f78b57fd42b733af7", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400.0} {"lang": "MS C++", "source_code": "#include \n\nint main()\n{\n double a,x,y;\n int i,j,re=-1;\n\n scanf(\"%lf%lf%lf\",&a,&x,&y);\n\n if(y>0 && y-1*a/2 && x-1*a/2 && x-1*a && x<0)\n re=2+3*((int)((y-a)/(2*a)))+1;\n if(x>0 && x\n#include\n#include\nusing namespace std;\nint a, x, y;\n\nstruct row_square\n{\n float left_min, left_max, ri8_min, ri8_max, mid_min, mid_max;\n int left_number, ri8_number, mid_number;\n};\nrow_square rows[10000001];\nvoid row_width_calculate(){\n rows[1].mid_min = -((float)a / 2);\n rows[1].mid_max = ((float)a / 2);\n int count = 1;\n while (count<=1000000)\n {\n if (count % 2 == 0)\n {\n rows[count + 1].left_min = -a;\n rows[count + 1].left_max = 0;\n rows[count + 1].ri8_min = 0;\n rows[count + 1].ri8_max = a;\n }\n else\n {\n rows[count + 1].mid_min = -((float)a / 2);\n rows[count + 1].mid_max = ((float)a / 2);;\n }\n count++;\n }\n}\nvoid number_calculate_odd(int row){\n rows[row].left_number = (row / 2) * 3;\n rows[row].ri8_number = (row / 2) * 3 + 1;\n}\nvoid number_calculate_even(int row){\n int d = row - 1;\n rows[row].mid_number = row / 2 + d;\n}\nint main(){\n // freopen(\"input.txt\",\"r\",stdin);\n scanf(\"%d %d %d\",&a,&x,&y);\n if (y%a == 0){\n printf(\"-1\\n\");\n }\n else{\n int row = (ceil)((double)y / a);\n row_width_calculate();\n if (row % 2 == 0){\n number_calculate_even(row);\n if (x > rows[row].mid_min&&x < rows[row].mid_max)\n printf(\"%d\\n\",rows[row].mid_number);\n else\n printf(\"-1\\n\");\n }\n else{\n if (row == 1){\n rows[1].mid_number = 1;\n if (x > rows[1].mid_min&&x < rows[1].mid_max)\n printf(\"1\\n\");\n else\n printf(\"-1\\n\");\n }\n else{\n number_calculate_odd(row);\n if (x > rows[row].left_min&&x < rows[row].left_max)\n {\n printf(\"%d\\n\", rows[row].left_number);\n }\n else if (x> rows[row].ri8_min&&x < rows[row].ri8_max){\n printf(\"%d\\n\", rows[row].ri8_number);\n }\n else\n {\n printf(\"-1\\n\");\n }\n }\n }\n }\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "951a758102b1ab9f70f42fe519a9d9b3", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02", "difficulty": 1400.0} {"lang": "GNU C++0x", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nlong long dp[105][2];\nint main()\n{\n int i,j,n,k,d;\n while(scanf(\"%d %d %d\",&n,&k,&d)!=EOF)\n {\n for(i=1;i<=k;i++)\n {\n if(i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n#ifdef _WIN32\n#define lld \"%I64d\"\n#else\n#define lld \"%lld\"\n#endif\n\n#define ll long long\n#define len(x) ((int)x.size())\n#define fe(a,b) for(typeof((b).begin()) a=(b).begin();a!=(b).end();++a)\n#define fi first\n#define se second\n#define pb push_back\n#define clr(a, x) memset(a, x, sizeof(a))\n#define pii pair\n#define all(x) x.begin(),x.end()\n\nconst int NN = 1e5 + 1000;\nconst int mod = 1e9 + 7;\nint n, k, d; \nint dp[111][111][2];\nint go(int p,int sum,int dd) {\n if(sum == n) {\n return (dd);\n }\n if(~dp[p][sum][dd]) {\n return dp[p][sum][dd];\n }\n int ret=0;\n for(int i=1 ; i<=k ; i++) {\n if(dd == 1)\n ret = ret + go(p+1, sum + i, 1);\n else if(i >= d)\n ret = ret + go(p+1, sum + i, 1);\n else\n ret = ret + go(p+1, sum + i, 0);\n ret = ret % mod;\n }\n return dp[p][sum][dd] = ret % mod;\n}\nint main() {\n clr(dp, -1);\n cin >> n >> k >> d;\n cout << go(1, 0, 0) << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f2a6cc0d33146c78f2d9d344c33e11c3", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0} {"lang": "GNU C++0x", "source_code": "//Codeforces 247C - k-Tree\n#include \n#include \nusing namespace std;\n\nlong long dp[7000000][2];\nlong long n,k,d;\n\nlong long numroot(long long sum, int havemin){\n\n\tif((sum == n) && (havemin==1)) return 1;\n\tif((sum == n) && (havemin==0)) return 0;\n\tif(sum > n) return 0;\n\t\n\tif(sum < 7000000){\n\t\tif(dp[sum][havemin] > 0) return dp[sum][havemin];\n\t}\n\t\n\tlong long tc = 0;\n\t\n\tfor(int i = 1; i<=k; i++){\n\t\tif(i>=d){\n\t\t\ttc = (tc + numroot(sum+i, 1)) % 1000000007;\n\t\t} else {\n\t\t\ttc = (tc + numroot(sum+i, havemin)) % 1000000007;\n\t\t}\n\t}\n\t\n\tif(sum < 7000000) dp[sum][havemin] = tc;\n\treturn tc;\n}\n\n\nint main(){\n\n\tfill(&dp[0][0],&dp[0][0] + sizeof(dp)/sizeof(dp[0][0]),0);\n\n\tcin >> n >> k >> d;\n\t\n\tcout << numroot(0,0) << endl;\n\t\nreturn 0;}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bddff57c6b5587518eb4d948cea423a1", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0} {"lang": "GNU C++0x", "source_code": "//Codeforces 247C - k-Tree\n#include \n#include \nusing namespace std;\n\nlong long dp[2000000][2];\nlong long n,k,d;\n\nlong long numroot(long long sum, int havemin){\n\n\tif((sum == n) && (havemin==1)) return 1;\n\tif((sum == n) && (havemin==0)) return 0;\n\tif(sum > n) return 0;\n\t\n\tif(sum < 2000000){\n\t\tif(dp[sum][havemin] > 0) return dp[sum][havemin];\n\t}\n\t\n\tlong long tc = 0;\n\t\n\tfor(int i = 1; i<=k; i++){\n\t\tif(i>=d){\n\t\t\ttc = (tc + numroot(sum+i, 1)) % 1000000007;\n\t\t} else {\n\t\t\ttc = (tc + numroot(sum+i, havemin)) % 1000000007;\n\t\t}\n\t}\n\t\n\tif(sum < 2000000) dp[sum][havemin] = tc;\n\treturn tc;\n}\n\n\nint main(){\n\n\tfill(&dp[0][0],&dp[0][0] + sizeof(dp)/sizeof(dp[0][0]),0);\n\n\tcin >> n >> k >> d;\n\t\n\tcout << numroot(0,0) << endl;\n\t\nreturn 0;}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3c4cd7ccf569ec2d4a5c0ba9862f0a29", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include\n#define int long long\nusing namespace std;\ninline int read()\n{\n int n = 0 , c = 0, m;\n while (!isdigit(c)) m = c - 45 ? 1 : -1 , c = getchar();\n while (isdigit(c)) n = n * 10 + c - 48 , c = getchar();\n return m * n;\n}\nint a[101];\nmain()\n{\n int n = read() , k = read() , M = read();\n int sum = 0;\n for(int i = 1; i <= k; i ++){\n a[i] = read();\n sum += a[i];\n }\n int T = M;\n if(T >= sum * n)\n {\n return cout << n * (k + 1) , 0;\n }\n\n sort(a + 1 , a + k + 1);\n int ans = 0;\n bool ok = 1;\n\n for(int i = 1; i <= k; i ++){\n int t = min(M , n * a[i]);\n ans += t / a[i];\n M -= t;\n }\n\n int ans2 = T / sum * (k + 1);\n int s = T / sum;\n T %= sum;\n for(int i = 1; i <= k; i ++){\n int t = min(T , (n - s) * a[i]);\n ans2 += t / a[i];\n T -= t;\n }\n\n cout << max(ans , ans2);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0fa87bb19fa10666b00d9424a25e8cd3", "src_uid": "d659e92a410c1bc836be64fc1c0db160", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\nlong long a[100];\nint main()\n{\n bool b=0;\n long long n , k , m , ans=0 , ans1=0;\n cin>>n>>k>>m;\n int mm=m;\n for (int i=0 ; i>a[i];\n sort(a , a+k);\n for (int i=0 ; ; i++)\n {\n if (i==k)\n {\n ans++;\n i-=k;\n }\n if (m-a[i]>=0)\n {\n m-=a[i];\n ans++;\n }\n else break;\n if (ans>(k+1)*n) {\n ans=(k+1)*n;\n break;\n }\n }\n\n for (int i=0 ; i=0)\n {\n mm-=a[i];\n ans1++;\n }\n else\n {\n b=1;\n break;\n }\n }\n if (b==1) break;\n }\n cout <\n#include\n#include\n#include\n#include\n#include \n#include\n#include\n#include\n\n#define lli long long int\n\nusing namespace std;\n\nbool comparable(pair a, pair b) { return a.first > b.first; }\n\n\n \nint main()\n{\n lli n, m, M;\n cin >> n >> m >> M;\n lli arr[m];\n for(lli i = 0; i < m; i++)\n cin >> arr[i];\n sort(arr, arr + m);\n lli sum[m];\n sum[0] = arr[0];\n for(lli i = 1; i = n){\n cout << n * (m + 1) << endl;\n return 0;\n }\n\n lli res = k * (1 + m);\n if(M%sum[m - 1] != 0){\n lli Q = M % sum[m - 1];\n lli i = 0;\n while(Q >= sum[i]){\n i++;\n res++;\n }\n }\n\n lli count = 0; \n lli i = 0;\n while(M > arr[i] && i < m){\n if(M >= arr[i] * n){\n count += n;\n if(i == m - 1)\n count += n;\n M -= arr[i] * n;\n }\n else{\n count += M / arr[i]; \n if(i == m - 1)\n count += M / arr[i];\n M = M % arr[i];\n }\n i++;\n }\n cout << max(res, count) << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9ec55c3d9daa151b6966e0695aa3164d", "src_uid": "d659e92a410c1bc836be64fc1c0db160", "difficulty": 1800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#define ll long long\n#define ld long double\n#define fir first\n#define sec second\nusing namespace std;\nint main()\n{\n ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);\n int n, k, M;\n cin >> n >> k >> M;\n vector T(k+1,0);\n for(int i=0; i> T[i];\n int ans=-1, t, cur; vector V(n,-1);\n pair < pair , vector > r; priority_queue < pair < pair , vector > > Q;\n Q.push({{0,0},V});\n while(!Q.empty())\n {\n r=Q.top(), Q.pop();\n if(r.fir.sec>=ans)\n {\n ans=r.fir.sec, t=(-1)*r.fir.fir, cur=k;\n for(int i=0; i\nusing namespace std;\nconst int N=100001;\nint dp[50][N];\nint n;\nint a[50];\nint val;\nint DP(int i,int w){\n if(i==n)return 0;\n if(dp[i][w]!=-1)return dp[i][w];\n int p1=0,p2=0;\n if(w+a[i]<=val)p1=a[i]+DP(i+1,w+a[i]);\n p2=DP(i+1,w);\n return dp[i][w]=max(p1,p2);\n}\nint main(){\n scanf(\"%d\",&n);\n int sum=0;\n memset(dp,-1,sizeof dp);\n for(int i=0;i\n#define ll long long int\n#define db double\n#define pf printf\n#define sf scanf\n#define ff first\n#define ss second\n#define clr clear()\n#define sz size()\n#define pb push_back\n#define mk make_pair\n#define pi acos(-1)\n#define inf 123456789\n#define mod 1000000007\n#define ull unsigned long long int\n#define f(i,k,n) for(i=k;i=k;i--)\n#define ent(a) scanf(\"%lld\",&a)\n#define ent2(a,b) scanf(\"%lld%lld\",&a,&b)\n#define ent3(a,b,c) scanf(\"%lld%lld%lld\",&a,&b,&c)\n#define mem(a) memset(a,0,sizeof(a))\n#define vec(v,s) vectorv[s]\n#define arr(a,s) ll a[s];\n//#define check(n,pos) (n&(1<n)\n return dif;\n if(dp[ind][dif]!=-1)\n return dp[ind][dif];\n ll r;\n ll a1=sum(ind+1,dif+a[ind]);\n ll b=sum(ind+1,abs(dif-a[ind]));\n r=min(a1,b);\n dp[ind][dif]=r;\n return r;\n}\nint main()\n{\n ll i,ans,s,ans1;\n while(cin>>n)\n {\n s=0;\n for(i=1;i<=n;i++)\n {\n cin>>a[i];\n s+=a[i];\n }\n memset(dp,-1,sizeof(dp));\n ll ans=sum(1,0);\n s-=ans;\n cout<\n\nusing namespace std;\n#define int long long\nint pd[51][50111];\n\nint v[55];\nint n;\nint f(int i, int gap){\n if(gap <= 0 || i == n){\n return 0;\n }\n \n if(pd[i][gap] != -1){\n return pd[i][gap];\n }\n int ans = 0;\n if(gap - v[i] >= 0){\n ans = f(i + 1, gap - v[i]) + v[i];\n ans = max(ans, f(i + 1, gap));\n }\n \n return pd[i][gap] = ans;\n}\n\nint32_t main()\n{\n scanf(\"%lld\",&n);\n int sum = 0;\n for(int i = 0; i < n; i++){\n scanf(\"%d\",&v[i]);\n sum += v[i];\n }\n memset(pd,-1,sizeof pd);\n int x = f(0,sum / 2);\n printf(\"%lld %lld\\n\",x, sum - x);\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "406b72115e33512735aeeac94c59f20e", "src_uid": "414540223db9d4cfcec6a973179a0216", "difficulty": 1500.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\nint main()\n{\n ll i,j,k=0,l,n,m;\n cin>>n;\n ll a[n];\n for(i=0;i>a[i];\n ll p,q;\n p=n-1;\n q=n-2;\n ll ans1=0,ans2=0;\n sort(a,a+n);\n while(p>=0)\n {\n if(ans1>=ans2)\n {\n ans2+=a[p];\n p--;\n q--;\n }\n else\n {\n ans1+=a[p];\n p--,q--;\n }\n }\n if(ans1>=ans2)\n cout<\nint main ()\n{\n int a,b,c,d,e,f;\n while (scanf (\"%d%d%d%d\",&a,&b,&c,&d)!= EOF)\n {\n e= a-((a/250)*c);\n f= b-((b/250)*d);\n if (e>f)\n {\n printf (\"Misha\\n\");\n }\n else if (e\n#include\n#include\nusing namespace std;\nvoid count(){\n #ifndef ONLINE_JUDGE\n freopen (\"input.txt\", \"r\", stdin);\n #endif\n}\nmain(){\n count();\n double a,b,c,d,s,t;\n cin >> a >> b >> c >> d;\n if(a == b && a > 250){\n cout << \"Tie\" << endl;\n return 0;\n }\n s = max((3*a)/10,a-a/250*c);\n t = max((3*b)/10,b-b/250*d);\n if(s>t) cout << \"Misha\";\n else if(s\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define eps 1e-10\n#define pi acos(-1.0)\n#define inf 107374182\n#define inf64 1152921504606846976\n#define lc l,m,tr<<1\n#define rc m + 1,r,tr<<1|1\n#define zero(a) fabs(a) 0 ? (x) : -(x))\n#define clear1(A, X, SIZE) memset(A, X, sizeof(A[0]) * (min(SIZE,sizeof(A))))\n#define clearall(A, X) memset(A, X, sizeof(A))\n#define memcopy1(A , X, SIZE) memcpy(A , X ,sizeof(X[0])*(SIZE))\n#define memcopyall(A, X) memcpy(A , X ,sizeof(X))\n#define max( x, y ) ( ((x) > (y)) ? (x) : (y) )\n#define min( x, y ) ( ((x) < (y)) ? (x) : (y) )\n\nusing namespace std;\n\nint main()\n{\n double a,b,c,d;\n scanf(\"%lf%lf%lf%lf\",&a,&b,&c,&d);\n if((a-(a/(c-1)))>(b-(b/(d-1))))puts(\"Misha\");\n else if((a-(a/(c-1)))==(b-(b/(d-1))))puts(\"Tie\");\n else puts(\"Vasya\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "66f56cb009e6e6232068bdd394c73b4d", "src_uid": "95b19d7569d6b70bd97d46a8541060d0", "difficulty": 900.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main(){\n int a,b,c,d;\n cin >> a >> b >> c >> d;\n int m1 = (3*a/10 >= a - a*c/250? 3*a/10 : a - a*c/250),\n m2 = (3*b/10 >= b - b*d/250? 3*b/10 : b - b*d/250);\n m1 > m2? cout << \"Misha\" : m1\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\nchar l[1000000001];\nlong long n,k,nn;\nlong long kkk=1;\n\nint main()\n{\n\tcin>>n>>k;\n\tif(n=1000000000)\n\t{\n\t\tfor(int i=1;i<=k;i++) kkk*=10;\n\t\tprintf(\"%d\",n/kkk);\n\t\treturn 0;\n\t}\n\t//cout<\nusing namespace std;\nint main()\n{\n int n,k;\n cin>>n>>k;\n while(k)\n {\n for(int i=0;i0)\n n--;\n else\n n=n/10;\n }\n cout<\n#include\nusing namespace std;\nint main(){\n\tint k,n;\n\tcin>>n>>k;\n\tfor(int i=1;i<=k;i++)\n\t{\n\t\tif(n%10!=0)\n\t\tn=n-1;\n\t\telse\n\t\tn=n/10;\n\t}\n\tcout<\nusing namespace std;\n\nint main()\n{ ios_base::sync_with_stdio(false);\ncin.tie(NULL);\n long n;\nint k;\ncin>>n>>k;\nfor(int i=0; i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#if defined(_MSC_VER) || defined(__BORLANDC__)\ntypedef unsigned __int64 uint64;\ntypedef unsigned __int64 ULL;\ntypedef signed __int64 int64;\ntypedef signed __int64 LL;\n#else\ntypedef unsigned long long uint64;\ntypedef unsigned long long ULL;\ntypedef signed long long int64;\ntypedef signed long long LL;\n#endif\n\ntypedef vector VI;\ntypedef vector VS;\ntypedef pair PII;\ntypedef pair PLL;\ntypedef vector VL;\n\n#define pb push_back\n#define pob pop_back\n#define mp make_pair\n#define fi first\n#define se second\n\n#define PII pair< int,int >\n#define PSS pair< string,string >\n#define PDD pair< double,double >\n#define PLL pair< LL, LL >\n\n#define FOR( i, a, b ) for ( int i=(a), _n=(b); i < _n; ++i )\n#define FORE( i, a, b ) for ( int i=(a), _n=(b); i <= _n; ++i )\n#define FORD( i, a, b ) for ( int i=(a), _n=(b); i >= _n; --i )\n\n#define REP( i, n ) FOR( i, 0, (n) )\n#define REPE( i, n ) FORE( i, 1, (n) )\n\n#define ALL( c ) (c).begin(), (c).end()\n#define SORT( c ) sort( ALL( c ) )\n#define LEN( s ) (int)( (s).size() )\n#define CLS( a ) memset( (a),0,sizeof(a) )\n\n#define IOS ios::sync_with_stdio( false ) \n\nconst double PI = 3.1415926535897932384626433832795028841971;\nconst double EPS = 1E-9;\nconst int64 INF64 = (int64)1E18;\nconst int INF = 1 << 30;\n\nconst int maxn = 1000000000;\n\nbool isprime[maxn];\nint pri[100000], pn;\n\nvoid getpri()\n{\n\tmemset( isprime, true, sizeof( isprime ) );\n\n\tisprime[0] = isprime[1] = false;\n\tpn = 0;\n\t\n\tfor ( int i = 2; i < maxn; ++i )\n\t{\n\t\tif ( isprime[i] )\n\t\t{\n\t\t\tpri[pn++] = i;\n\t\t\tif ( i * i < maxn )\n\t\t\t{\n\t\t\t\tfor ( int j = i + i; j < maxn; j += i )\n\t\t\t\t{\n\t\t\t\t\tisprime[j] = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tLog( \"%s %d OK\\n\", __func__, __LINE__ );\n}\n\nint ans = 0;\n\nvoid dfs( int l, int r, int k )\n{\n\tif ( k == 0 )\n\t{\t\n\t\tans = l * r;\n\t\treturn;\n\t}\n\n\tint tmp = l;\n\tif ( l < r ) \n\t{\n\t\tl = r, r = tmp;\n\t}\n\n\tif ( l <= 1 )\n\t{\n\t\tans = -1;\n\t\treturn;\n\t}\n\n\ttmp = l;\n\n\tfor( int i = 0; i < pn; ++i )\n\t{\n\t\tif ( tmp % pri[i] == 0 && tmp == pri[i] ) break;\n\n\t\twhile ( tmp % pri[i] == 0 && tmp != pri[i] ) tmp /= pri[i];\n\n\t\tif ( tmp == pri[i] ) break;\n\n\t}\n\n\tint x = tmp;\n\n\tLog( \"%d l = %d, r = %d, x = %d, k = %d\\n\", __LINE__, l, r, x, k );\n\n\tif ( x == 1 && l > 1 )\n\t{\n\t\tdfs( l - 1, r, k - 1 );\n\t\treturn;\n\t}\n\n\tLog( \"%d l = %d, r = %d, x = %d, k = %d\\n\", __LINE__, l, r, x, k );\n\n\tif ( x == 1 && l == 1 )\n\t{\n\t\tans = -1;\n\t\treturn;\n\t}\n\n\tLog( \"%d l = %d, r = %d, x = %d, k = %d\\n\", __LINE__, l, r, x, k );\n\n\tdfs( l / x, r, k - x + 1 );\n}\n\n\nvoid run()\n{\n\tint l, r, k;\n\n\tgetpri();\n\n\twhile ( scanf( \"%d %d %d\", &l, &r, &k ) > 0 )\n\t{\n\t\tans = -1;\n\t\tdfs( l, r, k );\n\t\tcout << ans << endl;\n\t}\n\n}\n\n\nint main( int argc, char **argv )\n{\n\n#ifndef ONLINE_JUDGE\n freopen(\"in\", \"r\", stdin);\n// freopen(\"out\", \"w\", stdout);\n#endif\n\n time_t st = clock();\n\n run();\n\n Log(\"\\n=============\\n\");\n Log(\"Time: %.2lf sec\\n\", (clock() - st) / double(CLOCKS_PER_SEC));\n\n return 0;\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "283a07de8f2e1f6d4a448e210a5151c0", "src_uid": "bb453bbe60769bcaea6a824c72120f73", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\n#define po pop_back\n#define pb push_back\n#define mk make_pair\n#define lw lower_bound\n#define up upper_bound\n#define ff first\n#define ss second\n#define boost ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);\n#define MOD 1000000007\n#define MAX 1e18 \n#define MIN -1e18\n#define rep(i,a,b) for(ll i=a;i<=b;i++)\n#define per(i,a,b) for(ll i=a;i>=b;i--)\n#define con continue\n#define pl pair\n#define binary_search while(l<=r)\nll a,b,c[1234567],dp[5005][5005],d[1234567],c1[1234][1234],e,n,j,i,l,r,x,y,k,ans,sz;\nbool used[5234567];\nll T;\nchar ch[1234][1234];\nvector v[1234567],v1;\nstring s,s1[1234567];\nvector vv[1234567];\npriority_queue pq;\nll sum;\nmap ma,m;\nll ar[1234567];\nll mod=998244353;\nll fac[1234567];\nll pow(ll a,ll n){\n if(n == 0){\n return 1;\n }\n if(n == 1){\n return a;\n }\n ll ans = pow(a, n / 2);\n ans *= ans;\n ans %= mod;\n if(n % 2){\n ans *= a;\n }\n return ans % mod;\n}\nint main(){\n cin>>x>>y>>k;\n if(x > y){\n swap(x,y);\n }\n if(k > x + y - 2){ \n cout<<-1;\n exit(0);\n }\n if(k < y) cout<\n#include \n#include \n#include \n#include \n#include \n\nusing namespace std; \n\nvector cand1, cand2;\n\nvector f(int n) {\n\tvector answer;\n\tanswer.clear();\n\tlong long N = (long long)n * (long long)(sqrt(n));\n\tN = (long long)(sqrt(N));\n\tfor (int i = 1; i <= N; ++i) answer.push_back(i);\n\tfor (int i = 1; i <= N; ++i) {\n\t\tif (n % i == 0) answer.push_back(n / i - 1); else answer.push_back(n / i);\n\t\tanswer.push_back(n / i + 1);\n\t} \n\treturn answer;\n}\n\nlong long F(int n, int cand, int m, int k) {\n\tif (cand > k) return 0;\n\tint first, second;\n\tfirst = n / (cand + 1);\n\tk -= cand - 1;\n\tif (k <= 0) return 0;\n\tsecond = (m + k - 1)/ k;\n\treturn (long long)(first) * (long long)(second);\n\t\n}\n \nint main(){\n\t//freopen(\"input.txt\",\"r\",stdin);\n\t//freopen(\"output.txt\",\"w\",stdout);\n\tios_base::sync_with_stdio(0); \n\tint n, m, k;\n\tcin >> n >> m >> k;\n\tif (n - 1 + m - 1 < k) {\n\t\tcout << -1 << endl;\n\t\treturn 0;\n\t}\n\tcand1 = f(n);\n\tcand2 = f(m);\n\tlong long answer = 0;\n\tfor (int i = 0; i < cand1.size(); ++i) { \n\t\tanswer = max(answer, F(n, cand1[i], m, k));\n\t}\n\tfor (int i = 0; i < cand2.size(); ++i) {\n\t\tanswer = max(answer, F(m, cand2[i], n, k));\n\t}\n\tcout << answer << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dfe97f5af81f6d37ac66ac553351741d", "src_uid": "bb453bbe60769bcaea6a824c72120f73", "difficulty": 1700.0} {"lang": "GNU C++0x", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nlong long n,m,k;\n\nint main(void) {\n //ifstream fin(\"file.in\"); \n cin>>n>>m>>k;\n \n if (k>n+m-2) cout<<\"-1\";\n else if (k==n+m-2) cout<<\"1\";\n else {\n if (n>m) swap(n,m);\n \n if (k>=n-1) cout<\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nvector arrv;\nmap hash1;\nmap hash2;\nint cr(int n);\nint max(int ,int);\nint main()\n{\n int n,a,b,c,ans;\n hash1[0]=1;\n hash2[0]=0;\n scanf(\"%d\",&n);\n scanf(\"%d\",&a);\n arrv.push_back(a);\n scanf(\"%d\",&b);\n arrv.push_back(b);\n scanf(\"%d\",&c);\n arrv.push_back(c);\n sort(arrv.begin(),arrv.end());\n ans=cr(n);\n cout< v;\n int i;\n int m=-1; \n for( i=0;i<3;i++){\n if(n=b)\n return a;\n else \n return b;\n} \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "82fdb95f16704ea0c8af6e9f0e0a5925", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nvector arrv;\nmap hash1;\nmap hash2;\nint cr(int n);\nint main()\n{\n int n,a,b,c,ans;\n hash1[0]=1;\n hash2[0]=0;\n scanf(\"%d\",&n);\n scanf(\"%d\",&a);\n arrv.push_back(a);\n scanf(\"%d\",&b);\n arrv.push_back(b);\n scanf(\"%d\",&c);\n arrv.push_back(c);\n sort(arrv.begin(),arrv.end());\n ans=cr(n);\n cout< v;\n int i; \n for( i=0;i<3;i++){\n if(n>=arrv[i]){\n temp=cr(n-arrv[i]);\n if(temp>=0){\n \n v.push_back(temp);\n }\n }\n }\n if(v.size()==0)\n return -1;\n int b=0;\n for(i=0;ib)\n b=v[i];\n }\n hash1[n]=1;\n hash2[n]=b+1;\n return b+1;\n} \n \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e1cb2db360593401a7596eac5e31c514", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0} {"lang": "GNU C++17 Diagnostics", "source_code": "// CutRibbon.cpp : Defines the entry point for the console application.\n//\n\n#if 0\n#include \"stdafx.h\"\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include\n#include\n#include\n#include\n#endif\n\n#include\n//#include\nusing namespace std;\n\n#if 0\n#define ABS(x) ((x)<0 ? -(x) : (x))\n#define REP(i,n) for(int i=0, _e(n); i<_e; i++)\n#define SET(t,v) memset((t), (v), sizeof(t))\n#define ALL(x) x.begin(), x.end()\n#define UNIQUE(c) (c).resize( unique( ALL(c) ) - (c).begin() )\n \n#define inf_int (1<<31)-1\n#define inf_long (1<<63)-1\n#define sz size()\n#define pb push_back\n//#define VI vector\n#define VS vector\n \n//typedef long long LL;\n//typedef long double LD;\ntypedef pair pii;\n#endif\n\n\n\n typedef vector vi;\n#if 0\n#ifdef DEBUG\n#define dbg(x) x\n#define dbgp(x) cerr << x ;\n#else\n#define dbg(x) //x\n#define dbgp(x) //cerr << x << endl;\n#endif\n\n\n#endif\n\n\n\n#define SZ(v) int((v).size())\n#define FR(i,a,b) for(int i=(a);i<(b);++i)\n#define FOR(i,n) FR(i,0,n)\n#define FORI(i,v) FOR(i,SZ(v))\n#define CLR(x,a) memset(x,a,sizeof(x))\n#define setmax(a,b) a = max(a,b)\n#define setmin(a,b) a = min(a,b)\ntypedef long long ll;\n\n\n#define N 4005 \n#define M 4\n#define BEND(x,n) &(x)[0],&(x)[(n)]\n\n\nll memo[N+1],len[M+1];\n\nll MemoizedCutRibbon(ll n)\n{\nll MemoizedCutRibbonAux(ll n);\n\nreturn MemoizedCutRibbonAux(n);\n}\n\nll MemoizedCutRibbonAux(ll n)\n{\n\tll q=LLONG_MIN;\n\n\tif(memo[n]>=0)return memo[n];\n\t//else if(0==n)q=0;\n\telse if((n==len[1]) || (n==len[2]) || (n==len[3]))q=1;\n\telse{}\n\n\tFR(i,1,M)\n\t\tif(n>=len[i])\n\t\t\tsetmax(q,1+MemoizedCutRibbonAux(n-len[i]));\nmemo[n]=q;\nreturn q;\n}\nvoid print()\n{\n\tFR(i,0,N)cout< oo{cout,\" \"};\nvoid init()\n{\n\t//cout<>n>>len[1]>>len[2]>>len[3])\n{\n\tinit();\n#ifdef NDEBUG\ncopy(BEND(len,M),oo);\ncout<=len[i])\n\t\t\tsetmax(q,1+memo[j-len[i]]);\n\tmemo[j]=q;\n}\n#endif\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "210898f8459c58c0eb8df190c54b9277", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0} {"lang": "GNU C++17 Diagnostics", "source_code": "// CutRibbon.cpp : Defines the entry point for the console application.\n//\n\n#if 0\n#include \"stdafx.h\"\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include\n#include\n#include\n#include\n#endif\n\n#include\n//#include\nusing namespace std;\n\n#if 0\n#define ABS(x) ((x)<0 ? -(x) : (x))\n#define REP(i,n) for(int i=0, _e(n); i<_e; i++)\n#define SET(t,v) memset((t), (v), sizeof(t))\n#define ALL(x) x.begin(), x.end()\n#define UNIQUE(c) (c).resize( unique( ALL(c) ) - (c).begin() )\n \n#define inf_int (1<<31)-1\n#define inf_long (1<<63)-1\n#define sz size()\n#define pb push_back\n//#define VI vector\n#define VS vector\n \n//typedef long long LL;\n//typedef long double LD;\ntypedef pair pii;\n#endif\n\n\n\n typedef vector vi;\n#if 0\n#ifdef DEBUG\n#define dbg(x) x\n#define dbgp(x) cerr << x ;\n#else\n#define dbg(x) //x\n#define dbgp(x) //cerr << x << endl;\n#endif\n\n\n#endif\n\n\n\n#define SZ(v) int((v).size())\n#define FR(i,a,b) for(int i=(a);i<(b);++i)\n#define FOR(i,n) FR(i,0,n)\n#define FORI(i,v) FOR(i,SZ(v))\n#define CLR(x,a) memset(x,a,sizeof(x))\n#define setmax(a,b) a = max(a,b)\n#define setmin(a,b) a = min(a,b)\ntypedef long long ll;\n\n\n#define N 4005 \n#define M 4\n#define BEND(x,n) &(x)[0],&(x)[(n)]\n\n\nll memo[N+1],len[M+1];\n\nll MemoizedCutRibbon(ll n)\n{\nll MemoizedCutRibbonAux(ll n);\n\nreturn MemoizedCutRibbonAux(n);\n}\n\nll MemoizedCutRibbonAux(ll n)\n{\n\tll q=LLONG_MIN;\n\n\tif(memo[n]>=0)return memo[n];\n\t//else if(0==n)q=0;\n\telse if((n==len[1]) || (n==len[2]) || (n==len[3]))q=1;\n\telse{}\n\n\tFR(i,1,M)\n\t\tif(n>=len[i])\n\t\t\tsetmax(q,1+MemoizedCutRibbonAux(n-len[i]));\nmemo[n]=q;\nreturn q;\n}\nvoid print()\n{\n\tFR(i,0,N)cout< oo{cout,\" \"};\nvoid init()\n{\n\t//cout<>n>>len[1]>>len[2]>>len[3])\n{\n\tinit();\n#ifdef NDEBUG\ncopy(BEND(len,M),oo);\ncout<=len[i])\n\t\t\tsetmax(q,1+memo[j-len[i]]);\n\tmemo[j]=q;\n}\n#endif\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "399dfb1480414860b3f178f5e4c1b13d", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define FOR(i,start,n, step) for(long long i=start;i > vp;\n//vector < vector > g;\nbool f,firs,g, prev;\nchar ch;\nvector used;\nstring s, t;\n\n//if(s[i] == 'a' || s[i] == 'o' || s[i] == 'u' || s[i] == 'e' || s[i] == 'y' || s[i] == 'i')\n//if(s[i] == 'A' || s[i] == 'O' || s[i] == 'U' || s[i] == 'E' || s[i] == 'Y' || s[i] == 'I')\nbool cmpvp(pair p1, pair p2){\n if(p1.f < p2.f) return 1;\n if(p1.f == p2.f) if(p1.s < p2.s)return 1;\n return 0;\n}//*/\n\nvoid per(int i,int j){\n ll ten = 1; \n n = m = sum = 0;\n if(s[0] == '0' && i > 1){n = -1; return;}\n if(s[i] == '0' && j-i > 1){n = -1; return;}\n if(s[j] == '0' && len-j > 1){n = -1; return;}\n FORD(k,-1,i,1){\n n += (s[k] - '0')*ten;\n ten*=10; \n }\n ten = 1;\n FORD(k,i-1,j,1){\n m += (s[k] - '0')*ten;\n ten*=10; \n }\n ten = 1;\n FORD(k,j-1,len,1){\n sum += (s[k] - '0')*ten;\n ten*=10; \n }\n}\n\nint main() {\n //freopen(\"input.txt\", \"r\", stdin); freopen(\"output.txt\", \"w\", stdout);\n cin >> s;\n len = s.length();\n bool f = true;\n ll k = 0;\n if(s[0] == '0')\n FOR(i,0,len,1){\n if(s[i] == '0') ++k;\n else if(k+1 == len){cout << -1 << endl; return 0;}\n }\n else {\n \n }\nFOR(i,1,len-1,1)\n FOR(j,i+1,len,1){\n //cout << i << ' ' << j << endl;\n per(i,j);\n //cout << n << ' ' << ' ' << m << ' ' << sum << endl;\n if(n < 1000001 && m < 1000001 && sum < 1000001) ans = max(ans,n+m+sum);\n }\n cout << ans << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e7b42d0a94af1edd9f42ae949abe523d", "src_uid": "bf4e72636bd1998ad3d034ad72e63097", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n\nstring s;\nint n,maxx=-1;\n\nint check(int a, int b)\n{\n //cout<1000000)\n {\n maxp=-1;\n return maxp;\n }\n \n if(y>1000000)\n {\n maxp=-1;\n return maxp;\n }\n \n if(z>1000000)\n {\n maxp=-1;\n return maxp;\n }\n \n //cout<<\"z \"<>s;\n n=s.length()-1;\n for(i=0;i<=n-2;i++)\n {\n for(j=i+1;j<=n-1;j++)\n {\n mmm=check(i,j);\n if(mmm>=maxx)\n {\n maxx=mmm;\n }\n }\n }\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\n\nconst double eps = 1E-9;\n\nint main(int argc, char **argv) {\n\n ios::sync_with_stdio(false);\n char s[35], *sk;\n cin >> s;\n\n int max1 = -1;\n int len = strlen(s);\n\n if(len < 3 || s[0] == '0') {\n cout << -1 << endl;\n return 0;\n }\n\n for(int i = 1; i <= len - 2; ++i) {\n char s1[30];\n s1[0] = '\\0';\n for(int h = 0; h < i; ++h)\n s1[h] = s[h];\n\n s1[i] = '\\0';\n int a = strtol(s1, &sk, 10);\n if(a > 1000000)\n continue;\n\n for(int j = 1; j + i < len; ++j) {\n char s2[30];\n s2[0] = '\\0';\n for(int h = i; h < j + i; ++h)\n s2[h - i] = s[h];\n\n s2[j] = '\\0';\n int b = strtol(s2, &sk, 10);\n if(b > 1000000)\n continue;\n\n int k = len - j - i;\n char s3[30];\n s3[0] = '\\0';\n for(int h = i + j; h < i + j + k; ++h)\n s3[h - i - j] = s[h];\n\n s3[k] = '\\0';\n int c = strtol(s3, &sk, 10);\n if(c > 1000000)\n continue;\n\n max1 = max(max1, a + b + c);\n }\n }\n\n cout << max1 << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c9d9f353df165b3a547d5f061ce5f003", "src_uid": "bf4e72636bd1998ad3d034ad72e63097", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#pragma comment(linker,\"/STACK:10240000\")\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst int maxn = 1100;\nstruct node{\n int v;\n int c;\n node(){}\n node(int v,int c):v(v),c(c){\n }\n};\nvectoradj[maxn];\nvectorlk[maxn];\nint mem[maxn],stack[maxn],depth[maxn];\nint sum,num;\nbool mark[maxn],used[maxn];\nvoid dfs(int k,int deep){\n int min,i;\n min=depth[k]=deep;\n used[k]=1;\n stack[sum++]=k;\n for(i=0;idepth[adj[k][i]])min=depth[adj[k][i]];\n }\n if(depth[k]>min){\n depth[k]=min;\n return;\n }\n while(stack[sum-1]!=k){\n mem[stack[sum-1]]=num;\n mark[stack[sum-1]]=1;\n sum--;\n }\n mark[k]=1;\n mem[k]=num;\n sum--;\n num++;\n}\nvoid init(){\n sum=0;\n num=0;\n memset(used,0,sizeof(used));\n memset(mark,0,sizeof(mark));\n}\nint a[maxn];\nint dp[maxn];\nint tot[maxn];\nint data[maxn];\nbool cmpc(const node &a,const node &b){\n return a.c>b.c;\n}\nbool cmpv(const node &a,const node &b){\n return a.v>b.v;\n}\nint di(int u){\n if(dp[u]!=-1)return dp[u];\n int s=0;\n int ret=a[u];\n sort(lk[u].begin(),lk[u].end(),cmpv);\n for(int i=0;i\n#include \n#include \n#include \n#include \n\n// ===== STL SECTION =====\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n// ===== OTHER LIBS SECTION =====\n\n#include \n#include // RANDOM IS MY HOME!!!\n#include \n#include \n#include \n#include \n\n/* _____ SPECIAL FEATURES _____ */\n\nusing namespace std;\n\n/* _____ CODE _____ */\n\nint main()\n{\n\tfreopen(\"input.txt\", \"r\", stdin);\n\t//freopen(\"output.txt\", \"w\", stdout);\n\n\tint x1, y1, x2, y2;\n\tcin >> x1 >> y1 >> x2 >> y2;\n\n\twhile(x1 + y1 != 0 and x2 + y2 != 0)\n\t{\n\t\tif(x1 <= x2 and y1 <= y2)\n\t\t{\n\t\t\tcout << \"Polycarp\" << endl;\n\t\t\treturn 0;\n\t\t}\n\n\t\tif(x2 <= x1 and y2 <= y1)\n\t\t{\n\t\t\tcout << \"Vasiliy\" << endl;\n\t\t\treturn 0;\n\t\t}\n\n\t\tif(y2 < y1)\n\t\t{\n\t\t\t--y1;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t--x1;\n\t\t}\n\n\t\tif(x2 != 0 and y2 != 0)\n\t\t{\n\t\t\t--x2;\n\t\t\t--y2;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(x2 == 0)\n\t\t\t\t--y2;\n\t\t\telse\n\t\t\t\t--x2;\n\t\t}\n\t}\n\n\tif(x1 + y1 == 0)\n\t{\n\t\tcout << \"Polycarp\" << endl;\n\t\treturn 0;\n\t}\n\telse\n\t{\n\t\tcout << \"Vasiliy\" << endl;\n\t\treturn 0;\n\t}\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "aefb2b1b1f2cf9957cc5205f3178e8c2", "src_uid": "2637d57f7809ff8f922549c617709074", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define MAX(a,b) (a>b?a:b)\n#define MIN(a,b) (a::iterator\n#define Tree int ind, int L, int R\n#define Left 2*ind,L,(L+R)/2\n#define Right 2*ind+1,(L+R)/2+1,R\nusing namespace std;\nint k;\nmain(){\n int x1, x2, y1, y2;\n cin>>x1>>y1>>x2>>y2;\n if(x2<=x1 && y2<=y1){ cout<<\"Vasiliy\"; return 0; }\n if(x2>=x1 && y2>=y1){ cout<<\"Polycarp\"; return 0; }\n while(true)\n {\n cout<=x1 && y2>=y1){ cout<<\"Polycarp\"; return 0; } }\n if(k%2==0)\n {\n if(!(x1-1==x2 && y2==y1) && x1>x2 && x1>0)x1--;\n else if(!(x2==x1 && y1-1==y2) && y1>0)y1--;\n }\n else\n {\n if(!(x2-1==x1 && y2-1==y1) && x2>=1 && y2>=1){ x2--; y2--; } else\n if(!(x2-1==x1 && y1==y2) && x2>x1 && x2>0)x2--;\n else if(!(x2==x1 && y2-1==y1) && y2>0)y2--;\n }\n k++;\n }\n }\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d8a316f33332606f0ddb081feb8246ad", "src_uid": "2637d57f7809ff8f922549c617709074", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main() {\n\tint xp, yp, xv, yv;\n\tcin >> xp >> yp >> xv >> yv;\n\n\tbool polyw = false;\n\tif ((xp == 0 && yp == 1) || (xp == 1 && yp == 0)) polyw = true;\n\telse if (xp <= xv && yp <= yv) polyw = true;\n\telse if (xp + yp <= (xv < yv ? xv : yv)) polyw = true;\n\tcout << (polyw ? \"Polycarp\" : \"Vasiliy\") << endl;\n\n\treturn true;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c07947b7c26716d268e5de7add37f185", "src_uid": "2637d57f7809ff8f922549c617709074", "difficulty": 1700.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main()\n{\n\tint Xp, Yp, Xv, Yv;\n\tcin >> Xp >> Yp >> Xv >> Yv;\n\tdouble vasyaLen = sqrt(double(Xv*Xv) + Yv*Yv);\n\tdouble polyLen = Xp + double(Yp);\n\tif (vasyaLen - int(vasyaLen) != 0)\n\t\tvasyaLen = int(vasyaLen) + 1;\n\n\tif (vasyaLen >= polyLen)\n\t\tcout << \"Polycarp\";\n\telse\n\t\tcout << \"Vasiliy\";\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "77ebd4521f9d8af0a59aea547697fd17", "src_uid": "2637d57f7809ff8f922549c617709074", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define ll long long \nint main()\n{\n ll n,k,p;\n cin>>n>>k;\n int ans;\n vector a;\n for(int i=0;i<=n;i++)\n {\n p=(ll)(1<=0;i--)\n {\n if(k%a[i]==0)\n { \n cout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint n;\nlong long m, len[51];\nvoid ini(){\n\tint i;\n\tlen[1]=1;\n\tfor(i=2; i<=50; i++)\n\t\tlen[i] = 2*len[i-1]+1;\n}\nint go(int n, int m){\n\tif(n==1 && m==1)\n\t\treturn 1;\n\tlong long mid = len[n]/2+1;\n\tif(mid==m)\n\t\treturn n;\n\tif(m>n>>m;\n\tcout<\n\nusing namespace std;\n\nint n, k;\nunsigned long long brbrojeva = 1, sr = 1;\n\nvoid rek(int sred, unsigned long long mjesto, unsigned long long duljina){\n//\tcout << sred << ' ' << mjesto << endl;\n//\tsystem(\"pause\");\n\tif (mjesto == k) {\n\t\tcout << sred << endl;\n\t\treturn;\n\t}\n\tif (mjesto > k) {\n\t\trek(sred - 1, (duljina - 1 ) / 2 / 2 + 1, duljina / 2);\n\t}\n\tif (mjesto < k) {\n\t\trek(sred - 1, mjesto + (duljina - 1 ) / 2 / 2 + 1, duljina / 2);\n\t}\n}\n\nint main(){\n\tcin >> n >> k;\n\tfor (int i = 0; i < n - 1; i++){\n\t\tbrbrojeva = brbrojeva * 2 + 1;\n\t}\n\tsr = n;\n\t//cout << brbrojeva << endl;\n\trek(n, brbrojeva/2 + 1, brbrojeva);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bf21ecc488503be1561eb7a42d84a56a", "src_uid": "0af400ea8e25b1a36adec4cc08912b71", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nint main() \n{\n vector v;\n int n,k;\n cin>>n>>k;\n v.push_back(1);\n\n for(int i=0;i x = v;\n v.push_back(i+2);\n for(int j =0;j\n#define djas 44444\n#define dasd 4515\n#define dsasd 555\n#define mdaxn 5555\n#define whfjkas 55556\n#define sdajskd 21555\n#define s5ddadda\nusing namespace std ;\nconst int maxn = 100000000 ;\n map sm ;\nint abs(int k )\n{\n return (k > 0)? k : -1 * k ;\n}\n\n int arr[maxn] ;\nint main(){\n int n , k , ans = 0 ;\n string s1 = \"\" ;\n cin >> n >> k ;\n cin >> s1 ;\n int cnt = 0 ;\n for(int i = 0 ; i < n ; i++)\n {\n if(sm[s1[i] - 96] == 0)\n { arr[cnt] = s1[i] - 96 ; cnt++ ; }\n sm[s1[i] - 96]++ ;\n }\n sort(arr , arr + cnt ) ;\n int i = 0 ;\n int mm = k ;\n while(k--){\n ans = ans + arr[i] ;\n if(arr[i] + 1 == arr[i+1] ) {k++ ; ans-= arr[i+1] ; }\n i++ ;\n }\n if(ans < mm ) {cout << \"-1\" << endl ; }\n else cout << ans <\n#include\n#include\n#include\n#include\nusing namespace std;\nint b[50010];\nlong long int a[50010];\nlong long int d[50010];\nbool vis[50];\nint main()\n{\n int n,k;\n scanf(\"%d%d\",&n,&k);\n int t=0;\n char str[100];\n int sum=0;\n scanf(\"%s\",&str);\n int len=strlen(str);\n sort(str,str+len);\n int ans=str[0]-'a'+1;\n t++;\n sum+=ans;\n for(int i=1;i1){\n t++;\n sum+=str[i]-'a'+1;\n ans=str[i]-'a'+1;\n if(t>=k)break;\n }\n }\n if(t>=k)\n printf(\"%d\\n\",sum);\n else printf(\"-1\\n\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "14cd68f2f584fba6ca5b58c3c9a1e4c9", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n\n// read the question correctly (is y a vowel?)\n// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)\n\nconst int mx = 123456;\nconst double pi = acos(-1);\nint ar[mx],x[mx],y[mx];\nmapmp1;\nsetse;\n\nint main(){\n\n // freopen(\"in.txt\",\"r\", stdin);\n // freopen(\"out.txt\",\"w\", stdout);\n char ch = 'a';\n for(int i = 1; i <= 26; i++){\n mp1[ch] = i;\n ch++;\n }\n int n,k,res;\n while(scanf(\"%d%d\",&n,&k)==2){\n string st;\n cin>>st;\n int sz = st.size();\n for(int j = 0; j < sz; j++){\n se.insert(st[j]);\n }\n sort(st.begin(), st.end());\n // cout<::iterator it;\n int ans = 12345678;\n res = 0;\n int cnt = 0;\n int p = se.size();\n if((int)se.size() % 2 == 1) p++;\n p = p/2;\n if(k > p){\n printf(\"-1\\n\");\n continue;\n }\n char chh;\n int j = 0;\n for(it=se.begin(); it!=se.end(); it++){\n\n if(j == 0){\n chh = *it;\n res = res + mp1[*it];\n cnt++;\n j++;\n if(cnt == k)break;\n continue;\n }\n if(mp1[*it] == mp1[chh] + 1){\n\n continue;\n }\n else {\n res += mp1[*it];\n chh = *it;\n cnt ++;\n if(cnt == k)break;\n }\n\n\n }\n se.clear();\n\n printf(\"%d\\n\",res);\n\n }\n\n\n\nreturn 0;\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f1494ef1532215c59867869bd10ac542", "src_uid": "56b13d313afef9dc6c6ba2758b5ea313", "difficulty": 900.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n\nusing namespace std;\nchar a[52],s[52];\nint main() {\n int n,k;\n cin >> n >> k;\n cin >> s;\n sort(s,s+n);\n long long cnt=1,ans=s[0]-'a'+1;\n a[0]=s[0];\n //cout << ans <=2){\n a[cnt]=s[i];\n ans+=(a[cnt]-'a'+1);\n cnt++;\n }\n if(cnt==k)break;\n }\n \n if(cnt==k) cout << ans <\n\nusing namespace std;\n\ntemplate\nstd::function\nmemoize(std::function func) {\n std::map, ReturnType> cache;\n\n return ([=] (Args... args) mutable {\n const std::tuple t(args...);\n\n if (cache.find(t) == cache.end()) {\n cache[t] = func(args...);\n }\n\n return cache[t];\n });\n}\n\nuint64_t xadd(uint64_t a, uint64_t b, const uint64_t modulus) {\n return (a + b) % modulus;\n}\n\ntemplate\nT xmul(T a, T b, const T modulus) {\n return (a * b) % modulus;\n}\n\ntemplate\nstd::tuple xgcf(T a, T b) {\n int64_t s1 = 1, s2 = 0;\n int64_t t1 = 0, t2 = 1;\n\n while (b != 0) {\n const auto q = a / b;\n const auto r = a % b;\n\n a = b;\n b = r;\n\n const auto x = s1;\n s1 = s2;\n s2 = x - q * s2;\n\n const auto y = t1;\n t1 = t2;\n t2 = y - q * t2;\n }\n\n return {a, s1, t1};\n}\n\nauto mxgcf = memoize(\n function<\n std::tuple(uint64_t, uint64_t)\n >(xgcf)\n);\n\nuint64_t xdiv(uint64_t a, uint64_t b, const uint64_t modulus) {\n\n int64_t inv;\n\n tie(ignore, inv, ignore) = mxgcf(b, modulus);\n\n while (inv < 0) {\n inv += modulus;\n }\n\n return xmul(a, (uint64_t) inv, modulus);\n}\n\nuint64_t factorial(uint64_t n, const uint64_t modulus);\n\nauto mfactorial = memoize(\n function(factorial)\n);\n\nuint64_t factorial(uint64_t n, const uint64_t modulus) {\n if (n == 0 || n == 1) {\n return 1;\n }\n\n return n * mfactorial(n - 1, modulus) % modulus;\n}\n\ntemplate\nT choose_n_k(const T n, const T k, const T modulus) {\n if (k > n) {\n return 0;\n }\n\n if (k == 0 || k == n) {\n return 1;\n }\n\n T result = 1;\n for (T i = 0; i != min(k, n - k); ++i) {\n result = xdiv(xmul(result, (n - i), modulus), (i + 1), modulus);\n }\n\n return result;\n}\n\nauto mchoose_n_k = memoize(\n function(choose_n_k)\n);\n\n// Read: compute for two, meaning compute for two islands\ntemplate\nT compute_42(const T a, const T b, const T modulus) {\n T total = 0;\n for (T k = 0; k != min(a, b) + 1; ++k) {\n const auto x = xmul(\n xmul(\n mchoose_n_k(a, k, modulus)\n , mchoose_n_k(b, k, modulus)\n , modulus\n )\n , mfactorial(k, modulus)\n , modulus\n );\n\n total = xadd(total, x, modulus);\n }\n\n return total;\n}\n\nint main() {\n uint64_t a, b, c; cin >> a >> b >> c;\n\n const uint64_t modulus = 998'244'353;\n\n // const vector fs = vector(N);\n //\n // fs[0] = 1;\n // fs[1] = 1;\n //\n // for (int i = 2; i != N; ++i) {\n // fs[i] = fs[i - 1] * i % modulus\n // }\n\n uint64_t total0 = compute_42(a, b, modulus);\n uint64_t total1 = compute_42(a, c, modulus);\n uint64_t total2 = compute_42(b, c, modulus);\n\n cout << xmul(xmul(total0, total1, modulus), total2, modulus) << endl;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "30b8ea2feb8690eb8370c2c533788e92", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include\n\nusing namespace std;\ntypedef long long ll;\nconst ll MOD = (998244353);\nll fact[5005];\nll inv[5005];\n\nll pot(ll x,ll y){\n\tif(y==0) return 1;\n\tif(y==1) return x;\n\tll ans = 1;\n\tif(y%2==1) ans = x;\n\tll val = pot(x,y/2);\n\tans *= val;\n\tans %= MOD;\n\tans *= val;\n\tans %= MOD;\n\treturn ans;\n}\n\nvoid init(){\n\tfact[0] = 1;\n\tfor(int i=1;i<=5000;i++){\n\t\tfact[i] = i*fact[i-1];\n\t\tfact[i] %= MOD;\n\t}\n\tfor(int i=0;i<=5000;i++){\n\t\tinv[i] = pot(fact[i],MOD-2)%MOD;\n\t}\n}\n\nll comb(ll x,ll y){\n\treturn (fact[x]*inv[x-y])%MOD;\n}\n\nll func(ll x,ll y,ll a){\n\treturn (((comb(x,a) * comb(y,a))%MOD) * inv[a])%MOD;\n}\n\nint main(){\n\tinit();\n\tint a,b,c;\n\tcin>>a>>b>>c;\n\tll ans = 0;\n\tll inicial = 0;\n\tint maxi = min(a,c);\n\tfor(int i=0;i<=maxi;i++){\n\t\tinicial += func(a,c,i);\n\t\tinicial %= MOD;\n\t}\n\tint maxi1=min(a,b) , maxi2 = min(b,c);\n\tfor(int i=0;i<=maxi1;i++){\n\t\tll fin = ( inicial * func(a,b,i) )%MOD;\n\t\tfor(int j=0;j<=maxi2;j++){\n\t\t\tll val = fin;\n\t\t\tval *= func(b , c , j);\n\t\t\tval %= MOD;\n\t\t\t//val *= func(a , c , k);\n\t\t\tans += val;\n\t\t\tans %= MOD;\n\t\t}\n\t}\n\tcout<\n#include\ntypedef long long ll;\nconst ll mod=998244353;\nll C[5005][5005]={0},P[5005];\nint main(){\n\tC[0][0]=1;\n\tfor(int i=1;i<=5000;i++){\n\t\tC[i][0]=1;\n\t\tfor(int j=1;j<=i;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;\n\t}\n\tP[0]=1;\n\tP[1]=1;\n\tfor(int i=2;i<=5000;i++) P[i]=P[i-1]*i%mod;\n\tll a,b,c;\n\tscanf(\"%lld%lld%lld\",&a,&b,&c);\n\tll tmp1=0;\n\tfor(int i=0;i<=a;i++){\n\t\tfor(int j=0;j<=a;j++){\n\t\t\ttmp1=(tmp1+C[a][i]*C[b][i]%mod*P[i]%mod*C[a][j]%mod*C[c][j]%mod*P[j]%mod)%mod;\n\t\t}\n\t}\n\tll tmp2=0;\n\tfor(int k=0;k<=b;k++){\n\t\ttmp2=(tmp2+C[b][k]*C[c][k]%mod*P[k]%mod)%mod;\n\t}\n\tll ans=tmp1*tmp2%mod;\n\tprintf(\"%lld\\n\",ans);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a69b9517cf9f43ca8f3c4c879d984503", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383", "difficulty": 1800.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nint a,b,c;\nint fa[5005];\nint invfa[5005];\nconst int MOD=998244353;\nint add(int a,int b)\n{\n a+=b;\n if(a>=MOD)a-=MOD;\n return a;\n}\nint mult(int a,int b)\n{\n return 1LL*a*b%MOD;\n}\nint C(int N,int K)\n{\n if(K>N)return 0;\n return mult(fa[N],mult(invfa[K],invfa[N-K]));\n}\nint A(int N,int K)\n{\n if(K>N)return 0;\n return mult(fa[N],invfa[N-K]);\n}\nint solve(int a,int b,int c)\n{\n int rez=0;\n for(int i=0;i<=a;i++)\n {\n for(int j=0;j<=a;j++)\n {\n rez=add(rez,mult(mult(A(b,a-i),A(c,a-j)),mult(C(a,i),C(a,j))));\n }\n }\n return rez;\n}\nint lgpow(int b,int e)\n{\n int p=1;\n while(e)\n {\n if(e&1)p=mult(b,p);\n b=mult(b,b);\n e>>=1;\n }\n return p;\n}\nint main()\n{\n fa[0]=1;\n for(int i=1;i<=5000;i++)fa[i]=mult(fa[i-1],i);invfa[5000]=lgpow(fa[5000],MOD-2);\n for(int i=5000-1;i>=0;i--)invfa[i]=mult(invfa[i+1],i+1);\n cin>>a>>b>>c;\n cout<\n\n#define F(i, a, b) for (int i = a; i < b; i++)\n#define f(i, n) F(i, 0, n)\n\n#define re return\n#define fi first\n#define se second\n#define all(v) v.begin(), v.end()\n#define pb push_back\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pii;\n\nll t[3], p[3], a[3];\n\nint main() {\n#ifdef home\n\tfreopen(\"i.txt\", \"r\", stdin);\n#else\n\tios::sync_with_stdio(0);\n#endif // home\n\tll n, T;\n\n cin >> n >> T >> t[0];\n F(i, 1, 3) {\n\t\tcin >> a[i] >> t[i] >> p[i];\n }\n\n ll ans = 1e18;\n for (ll i = 0; i < T + (a[2] * t[2]); i += (a[2] * t[2])) {\n\t\tll b2 = min(T, i) / t[2];\n ll sum2 = b2 * p[2];\n\n\t\tll b = n - b2;\n\n if (t[1] >= t[0]) {\n\t\t\tll tt = i + b * t[0];\n\t\t\tif (tt <= T) {\n ans = min(ans, sum2);\n\t\t\t}\n\t\t\tcontinue;\n }\n\n ll tt = T - i;\n\n\t\tll b1 = (b * t[0] - tt + t[0] - t[1] - 1) / (t[1] - t[0]);\n\n\t\tif (b1 < 0) {\n\t\t\tans = min(ans, sum2);\n\t\t}\n\n\t\tif (i + b1 * t[1] > T) continue;\n ll sum1 = (b1 + a[1] - 1) / a[1] * p[1];\n\t\tans = min(ans, sum1 + sum2);\n\t}\n if (ans > 9e17) {\n\t\tcout << -1;\n\t\tre 0;\n }\n\n cout << ans << '\\n';\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e37ba990b84ef7b804593531e76ba0ce", "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n#define pb push_back\n#define ff first\n#define ss second\ntypedef long long ll;\nconst int MAXN = 300005;\n\nstruct Edge\n{\n int t, u, v;\n int idx;\n};\n\nbool beenE[MAXN], beenV[MAXN];\nstatic int Visited;\nvector p[MAXN];\nchar ans[MAXN];\nEdge E[MAXN];\n\nvoid DFS_Min(int v)\n{\n beenV[v] = true;\n Visited++;\n\n for (int idx : p[v])\n {\n if (E[idx].t == 1)\n {\n if (!beenV[ E[idx].v ]) DFS_Min( E[idx].v );\n }\n else\n {\n if (beenE[ E[idx].idx ]) continue;\n beenE[ E[idx].idx ] = true;\n\n if (E[idx].u == v)\n {\n ans[ E[idx].idx ] = '-';\n }\n else\n {\n ans[ E[idx].idx ] = '+';\n }\n }\n }\n}\n\nvoid DFS_Max(int v)\n{\n beenV[v] = true;\n Visited++;\n\n for (int idx : p[v])\n {\n if (E[idx].t == 1)\n {\n if (!beenV[ E[idx].v ]) DFS_Max( E[idx].v );\n }\n else\n {\n if (beenE[ E[idx].idx ]) continue;\n beenE[ E[idx].idx ] = true;\n\n int to;\n if (E[idx].u == v)\n {\n ans[ E[idx].idx ] = '+';\n to = E[idx].v;\n }\n else\n {\n ans[ E[idx].idx ] = '-';\n to = E[idx].u;\n }\n\n if (!beenV[to]) DFS_Max(to);\n }\n }\n}\n\nint main()\n{\n freopen(\"input.in\", \"r\", stdin);\n int N, M, S, O = 0;\n cin >> N >> M >> S;\n\n for (int i = 0; i < M; i++)\n {\n cin >> E[i].t >> E[i].u >> E[i].v;\n if (E[i].t == 2)\n {\n E[i].idx = O++;\n p[ E[i].u ].push_back(i);\n p[ E[i].v ].push_back(i);\n }\n else\n {\n p[ E[i].u ].push_back(i);\n }\n }\n\n memset(beenE, false, M + 3);\n memset(beenV, false, N + 3);\n memset(ans, '?', M + 3);\n Visited = 0;\n\n DFS_Min(S);\n\n for (int i = 0; i < O; i++)\n {\n //if (ans[i] == '?') ans[i] = '+';\n cout << ans[i];\n }\n cout << endl;\n\n memset(beenE, false, M + 3);\n memset(beenV, false, N + 3);\n memset(ans, '?', M + 3);\n Visited = 0;\n\n DFS_Max(S);\n\n for (int i = 0; i < O; i++)\n {\n //if (ans[i] == '?') ans[i] = '+';\n cout << ans[i];\n }\n cout << endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "506ea8640c310ba3c8b4110ce74b0935", "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\n\nint min(int a, int b)\n{\n\tif (a <= b)\n\t\treturn a;\n\treturn b;\n}\n\nint main(void)\n{\n\tint x1, y1, x2, y2;\n\tcin >> x1 >> y1 >> x2 >> y2;\n\tint x3 = 0, y3 = 0;\n\tint distance = abs(x2 - x1) + abs(y2 - y1);\n\tint ans = 0;\n\tif (x2 > x1 && y2 > y1)\n\t{\n\t\tx3 = x2 + 1; y3 = y2 + 1; \n\t}\n\telse if (x2 > x1 && y2 < y1)\n\t{\n\t\tx3 = x2 + 1; y3 = y2 - 1;\n\t}\n\telse if (x2 < x1 && y2 < y1)\n\t{\n\t\tx3 = x2 - 1; y3 = y2 - 1;\n\t}\n\telse if (x2 < x1 && y2 > y1)\n\t{\n\t\tx3 = x2 - 1; y3 = y2 + 1;\n\t}\n\telse if (x2 == x1 || y2 == y1)\n\t{\n\t\tans = (distance + 1)* 2 + 4;\n\t\tcout << ans;\n\t\t_getch();\n\t\treturn 0;\n\t}\n\t//cout << distance << endl;\n\t//cout << x3 << \" \" << y3 << endl;\n\tans = 2 * abs(x3 - x1) + 2 * abs(y3 - y1);\n\tcout << ans;\n\t//_getch();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3c3eb8815066815d791f45ba301b7d72", "src_uid": "f54ce13fb92e51ebd5e82ffbdd1acbed", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n#define pii pair\nint fx[]={1,-1,0,0};\nint fy[]={0,0,1,-1};\nint cell[210][210];\nint d[210][210];\nbool vis[210][210];\nint aa;\nint bb;\n\nint bfs(int sx,int sy)\n{\n\tmemset(vis,0,sizeof vis);\n\tvis[sx][sy]=1;\n\tqueueq;\n\tq.push(pii(sx,sy));\n\twhile(!q.empty())\n\t{\n\t\tpii top=q.front(); q.pop();\n\t\tfor(int k=0;k<4;k++)\n\t\t{\n\t\t\tint tx=top.first+fx[k];\n\t\t\tint ty=top.second+fy[k];\n\t\t\tif(tx>=0 and ty>=0 and vis[tx][ty]==0)\n\t\t\t\tvis[tx][ty]=1;\n\t\t\t\td[tx][ty]=d[top.first][top.second]+1;\n\t\t\t\tif(tx==aa && ty==bb) return d[aa][ty];\n\t\t\t\tq.push(pii(tx,ty));\n\t\t\t}\n\t\t}\n}\nint main()\n{\n int a , b ;\n cin>>a>>b;\n a+=100;\n b+=100;\n cin>>aa>>bb;\n aa+=100;\n bb+=100;\n if(aa!=a && bb!=b ){\n cout<<2*(bfs(a,b)+2);\n }\n else\n{\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n\nint main()\n{\n\tint n;\n\tint a[6][6]={};\n\tvector sp[6];\n\tvector sp2[6];\n\tcin>>n;\n\tint f,s;\n\t\n\tfor(int i=0;i>f>>s;\n\t\ta[f-1][s-1]=1;\n\t\ta[s-1][f-1]=1;\n\t\tsp[f-1].push_back(s-1);\n\t\tsp[s-1].push_back(f-1);\n\t\t\n\t}\n\n\tfor(int i=0;i<5;i++)\n\t{\n\t\tfor(int k=0;k<5;k++)\n\t{\n\t\tint fl=0;\n\t\tfor(int z=0;z\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\n#define sc(x) scanf(\"%d\",&x)\n#define sc2(x,y) scanf(\"%d%d\",&x,&y)\n#define scl(x) scanf(\"%lld\",&x)\n#define F first\n#define S second\n#define pb push_back\n#define pi 3.1415926535897932384\nint Dx[]= {1,-1,0,0};\nint Dy[]= {0,0,1,-1};\nvoid fast()\n{\n ios::sync_with_stdio(0);\n cin.tie(0);\n}\nvoid file()\n{\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n}\n\nint main()\n{\n ll x,y,l,r;\n cin>>x>>y>>l>>r;\n vectora,b,v;\n ll p=1;\n while (p<=1e18/x) a.pb(p),p*=x;\n p=1;\n while (p<=1e18/y) b.pb(p),p*=y;\n for (auto i:a)\n for (auto j:b)\n if (i+j>=l && i+j<=r)\n v.pb(i+j);\n v.pb(r+1);\n v.pb(l-1);\n //cout<\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\n#define sc(x) scanf(\"%d\",&x)\n#define sc2(x,y) scanf(\"%d%d\",&x,&y)\n#define scl(x) scanf(\"%lld\",&x)\n#define F first\n#define S second\n#define pb push_back\n#define pi 3.1415926535897932384\nint Dx[]= {1,-1,0,0};\nint Dy[]= {0,0,1,-1};\nvoid fast()\n{\n ios::sync_with_stdio(0);\n cin.tie(0);\n}\nvoid file()\n{\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n}\n\nint main()\n{\n ull x,y,l,r;\n cin>>x>>y>>l>>r;\n vectora,b,v;\n ull p=1;\n while (p<=1e18/x) a.pb(p),p*=x;\n p=1;\n while (p<=1e18/y) b.pb(p),p*=y;\n for (auto i:a)\n for (auto j:b)\n if (i+j>=l && i+j<=r)\n v.pb(i+j);\n v.pb(r+1);\n v.pb(l-1);\n //cout<\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\n#define sc(x) scanf(\"%d\",&x)\n#define sc2(x,y) scanf(\"%d%d\",&x,&y)\n#define scl(x) scanf(\"%lld\",&x)\n#define F first\n#define S second\n#define pb push_back\n#define pi 3.1415926535897932384\nint Dx[]= {1,-1,0,0};\nint Dy[]= {0,0,1,-1};\nvoid fast()\n{\n ios::sync_with_stdio(0);\n cin.tie(0);\n}\nvoid file()\n{\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n}\n\nint main()\n{\n ull x,y,l,r;\n cin>>x>>y>>l>>r;\n vectora,b,v;\n ull p=1;\n while (p<=(ull)1e18) a.pb(p),p*=x;\n p=1;\n while (p<=(ull)1e18) b.pb(p),p*=y;\n for (auto i:a)\n for (auto j:b)\n if (i+j>=l && i+j<=r)\n v.pb(i+j);\n v.pb(r+1);\n v.pb(l-1);\n //cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#ifdef __GNUC__\ntypedef long long ll;typedef unsigned long long ull;\n#else\ntypedef __int64 ll; typedef unsigned __int64 ull;\n#endif\n\n#define REP(i,n) for(i=0;i=0;i--)\n#define FOR(i,x,y) for(i=x;i<=y;i++)\n\n#define acu(x) accumulate(x.begin(),x.end(),0)\n#define EQ(a,b) (fabs(a-b)\" <<#x<<\": \"< pii;\ntypedef pair pdd;\ntypedef vector vi;\ntypedef vector vd;\ntypedef vector vll;\ntypedef vector vs;\ntypedef vector vii;\ntypedef vector vvll;\ntypedef vector vvd;\ntypedef vector vpii;\ntypedef map msi;\ntypedef map mii;\ntypedef map mpi;\ntypedef list li;\ntypedef istringstream iss;\n\n/** Printing **/\ntemplate void out(const vector &a) { cout<<\"array: \"; for (int i=0;i '%c' \",k,k);}printf(\"\\n\");}}\n\n/** MATH **/\ntemplate inline T gcd(T a,T b) {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}\ntemplate inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}\ntemplate T Abs(T x) {return x > 0 ? x : -x;}\ntemplate inline T sqr(T x){return x*x;}/** NOTES:sqr **/\ntemplate inline T Mod(T n,T m) {return (n%m+m)%m;} /** For Positive Negative No. **/\nint BigMod(ll B,ll P,ll M) /** compute b^p%m **/\n { ll R=1;\twhile(P>0)\t{if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;}\treturn (int)R;}\nll mulmod(ll a,ll b,ll c) /**calculates (a*b)%c taking into account that a*b might overflow **/\n { ll x = 0,y=a%c; while(b>0){ if(b%2 == 1){x=(x+y)%c;} y=(y*2)%c;b/= 2;}return x%c;}\nll mpow(ll x,ll k) { if( k==0) return 1; ll r=mpow(x,k/2); return k%2?(r*r*x):(r*r); } // Power Calculation function\n\n/** Genarator **/\nvector SubstringGenerate(string str)/** Substring Generator **/\n {int i,j,len;vs store;len=SZ(str);REP(i,len) FOR(j,i,len)store.PB(str.substr(i,j-i+1));return store;}\n\n/** Dicission **/\ntemplate inline bool isPrime(T n){if(n<=1)return false;for (T i=2;i*i<=n;i++) if (n%i==0) return false;return true;}\nbool IsVowel(char ch){ch=tolower(ch);if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')return true;return false;}\nbool isUpperCase(char c){return c>='A' && c<='Z';}\nbool isLowerCase(char c){return c>='a' && c<='z';}\nbool isLetter(char c){return c>='A' && c<='Z' || c>='a' && c<='z';}//NOTES:isLetter(\nbool isDigit(char c){return c>='0' && c<='9';}//NOTES:isDigit(\n\n/** Conversion **/\ndouble deg2rad(double x){ return (PI*x)/180.0; }\ndouble rad2deg(double x){ return (180.0*x)/PI; }\ntemplate string toString(T n)/** NOTES:int,double is converted to string **/\n {ostringstream oss;oss<>r;return r;} /** String to Int **/\nll toLl(string s){ll r=0;istringstream sin(s); sin>>r; return r;} /** String to Int **/\ndouble toDouble(string s){double r=0;istringstream sin(s);sin>>r;return r;} /**NOTES:toDouble(**/\ntemplate static void splitstr(const string &s, vector &out)/**String TO vector**/\n { istringstream in(s);out.clear();copy(istream_iterator(in), istream_iterator(), back_inserter(out));}\n\n/**For debugging **/\ntemplate void debug(T e){cout< void debug(T1 e1,T2 e2){cout< void debug(T1 e1,T2 e2,T3 e3){cout< void debug(T1 e1,T2 e2,T3 e3,T4 e4){cout< void debug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout< void debug(vector e){int i;REP(i,SZ(e)) cout< void debug(vector e,int n){int i;REP(i,n) cout< void debug(vector< basic_string > e){int i,j;REP(i,SZ(e)) {REP(j,SZ(e[i])) cout< void debug(vector< basic_string > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout< void debug(vector< vector > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout< void debug(T e[SIZE][SIZE],int row,int col){int i,j;REP(i,row) {REP(j,col) cout< void debug(T e[],int row){int i;REP(i,row) cout<b.cost;}};// Min Priority Queue\n//typedef struct{int x,y;}P;P pvt;\n\n/** max sizes in TC : [16000000] , [4000][4000] , [250][250][250] **/\n/** max loop in TC : n^2 =>> 42000 **/\n\n//int month[]={31,28,31,30,31,30,31,31,30,31,30,31}; //Not Leap Year\n//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction\n//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction\n//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction\n//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction\n\nbool com(int a,int b)\n{\n return a>n>>k>>l>>c>>d>>p>>nl>>np;\n REP(i,5000000000);\n drk=k*l;\n nos=c*d;\n solt=p;\n x=min(drk/nl,min(nos,solt/np));\n x/=n;\n cout<\nusing namespace std;\n\nint main() {\n\tint x, y, z, w, n, k, l, c, d, p, nl, np;\n\tcin >> n >> k >> l >> c >> d >> p >> nl >> np;\n\tx = (k*l)/nl;\n\ty = c*d;\n\tz = p/np;\n\tw = min({x, y, z})/n;\n\tcout << w << endl;\t\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9567dfd6e0c9b3ad2453b30899905e07", "src_uid": "67410b7d36b9d2e6a97ca5c7cff317c1", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "/**\n\n Author: Zafar Ahmad\n Reg.No: 2008331028\n SUST\n\n**/\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#ifdef __GNUC__\ntypedef long long ll;typedef unsigned long long ull;\n#else\ntypedef __int64 ll; typedef unsigned __int64 ull;\n#endif\n\n#define REP(i,n) for(i=0;i=0;i--)\n#define FOR(i,x,y) for(i=x;i<=y;i++)\n\n#define acu(x) accumulate(x.begin(),x.end(),0)\n#define EQ(a,b) (fabs(a-b)\" <<#x<<\": \"< pii;\ntypedef pair pdd;\ntypedef vector vi;\ntypedef vector vd;\ntypedef vector vll;\ntypedef vector vs;\ntypedef vector vii;\ntypedef vector vvll;\ntypedef vector vvd;\ntypedef vector vpii;\ntypedef map msi;\ntypedef map mii;\ntypedef map mpi;\ntypedef list li;\ntypedef istringstream iss;\n\n/** Printing **/\ntemplate void out(const vector &a) { cout<<\"array: \"; for (int i=0;i '%c' \",k,k);}printf(\"\\n\");}}\n\n/** MATH **/\ntemplate inline T gcd(T a,T b) {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}\ntemplate inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}\ntemplate T Abs(T x) {return x > 0 ? x : -x;}\ntemplate inline T sqr(T x){return x*x;}/** NOTES:sqr **/\ntemplate inline T Mod(T n,T m) {return (n%m+m)%m;} /** For Positive Negative No. **/\nint BigMod(ll B,ll P,ll M) /** compute b^p%m **/\n { ll R=1;\twhile(P>0)\t{if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;}\treturn (int)R;}\nll mulmod(ll a,ll b,ll c) /**calculates (a*b)%c taking into account that a*b might overflow **/\n { ll x = 0,y=a%c; while(b>0){ if(b%2 == 1){x=(x+y)%c;} y=(y*2)%c;b/= 2;}return x%c;}\nll mpow(ll x,ll k) { if( k==0) return 1; ll r=mpow(x,k/2); return k%2?(r*r*x):(r*r); } // Power Calculation function\n\n/** Genarator **/\nvector SubstringGenerate(string str)/** Substring Generator **/\n {int i,j,len;vs store;len=SZ(str);REP(i,len) FOR(j,i,len)store.PB(str.substr(i,j-i+1));return store;}\n\n/** Dicission **/\ntemplate inline bool isPrime(T n){if(n<=1)return false;for (T i=2;i*i<=n;i++) if (n%i==0) return false;return true;}\nbool IsVowel(char ch){ch=tolower(ch);if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')return true;return false;}\nbool isUpperCase(char c){return c>='A' && c<='Z';}\nbool isLowerCase(char c){return c>='a' && c<='z';}\nbool isLetter(char c){return c>='A' && c<='Z' || c>='a' && c<='z';}//NOTES:isLetter(\nbool isDigit(char c){return c>='0' && c<='9';}//NOTES:isDigit(\n\n/** Conversion **/\ndouble deg2rad(double x){ return (PI*x)/180.0; }\ndouble rad2deg(double x){ return (180.0*x)/PI; }\ntemplate string toString(T n)/** NOTES:int,double is converted to string **/\n {ostringstream oss;oss<>r;return r;} /** String to Int **/\nll toLl(string s){ll r=0;istringstream sin(s); sin>>r; return r;} /** String to Int **/\ndouble toDouble(string s){double r=0;istringstream sin(s);sin>>r;return r;} /**NOTES:toDouble(**/\ntemplate static void splitstr(const string &s, vector &out)/**String TO vector**/\n { istringstream in(s);out.clear();copy(istream_iterator(in), istream_iterator(), back_inserter(out));}\n\n/**For debugging **/\ntemplate void debug(T e){cout< void debug(T1 e1,T2 e2){cout< void debug(T1 e1,T2 e2,T3 e3){cout< void debug(T1 e1,T2 e2,T3 e3,T4 e4){cout< void debug(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout< void debug(vector e){int i;REP(i,SZ(e)) cout< void debug(vector e,int n){int i;REP(i,n) cout< void debug(vector< basic_string > e){int i,j;REP(i,SZ(e)) {REP(j,SZ(e[i])) cout< void debug(vector< basic_string > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout< void debug(vector< vector > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout< void debug(T e[SIZE][SIZE],int row,int col){int i,j;REP(i,row) {REP(j,col) cout< void debug(T e[],int row){int i;REP(i,row) cout<b.cost;}};// Min Priority Queue\n//typedef struct{int x,y;}P;P pvt;\n\n/** max sizes in TC : [16000000] , [4000][4000] , [250][250][250] **/\n/** max loop in TC : n^2 =>> 42000 **/\n\n//int month[]={31,28,31,30,31,30,31,31,30,31,30,31}; //Not Leap Year\n//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction\n//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction\n//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction\n//int dx[]={2,1,-1,-2,-1,1};int dy[]={0,1,1,0,-1,-1}; //Hexagonal Direction\n\nbool com(int a,int b)\n{\n return a>n>>k>>l>>c>>d>>p>>nl>>np;\n REP(i,10000000000);\n drk=k*l;\n nos=c*d;\n solt=p;\n x=min(drk/nl,min(nos,solt/np));\n x/=n;\n cout<\n#include \n#include\nusing namespace std;\nint main(){\n\n int n , l , k , c , d , p , nl , np , result;\n\n\n for (;;)\n {\ncin >> n >> l >> k >> c >> d >> p >> nl >> np ;\n\n int m=k*l; // number of miliis\n\n int s=c*d; //number of slices\n\n m=m/nl; //number of possible toasts uisng drink\n\n p=p/np; // number of posssible tpasts using salds\n\n // for n friends\n m=m/n;\n\n s=s/n;\n\n p=p/n;\nint x=fmin(m,s);\nint y=fmin(x,p);\ncout<\n#include \n#include \n#include \n#include \n\n#define pb push_back\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair piii;\n\nconst ll P=4111;\nconst ll MOD=1000000007;\n\nint n, q;\nint a[4097];\npiii qy[100001];\nint cnt;\n\nunordered_map topos;\n\nset curay;\nset:: iterator it;\nvector ay;\n\nvector ans;\nint anspos[100001];\n\nll powp[100001];\n\nstruct seg{\n struct node{\n int l, r;\n } seg[200001];\n \n pii query(int p, int l, int r)\n {\n if(l>r)\n return {0, 0};\n if(seg[p].l+1==seg[p].r){\n return {topos[seg[p].l], seg[p].l};\n }\n else{\n int targ=(seg[p].l+seg[p].r)/2-1;\n int lo=l, hi=r+1, m;\n while(lo> n >> q, cnt=n;\n for(i=1;i<=n;i++)\n cin >> a[i], topos[a[i]]=i;\n for(i=1;i<=q;i++)\n cin >> qy[i].first.first >> qy[i].first.second, qy[i].second=i;\n sort(qy+1, qy+q+1);\n \n ds.build(1, 1, n+1);\n int cur=1;\n for(i=1;i<=n;i++){\n curay.clear();\n for(j=i;j<=n;j++){\n curay.insert(a[j]);\n while(cur<=q && qy[cur].first.first==i && qy[cur].first.second==j){\n ay.clear();\n it=curay.begin();\n while(it!=curay.end())\n ay.pb(*it), it++;\n anspos[qy[cur].second]=ds.query(1, 1, ay.size()).first;\n cur++;\n }\n }\n }\n \n cout << cnt << endl;\n for(i=0;i\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define File(s) freopen(s\".in\", \"r\", stdin), freopen(s\".out\", \"w\", stdout)\ntypedef long long ll;\nnamespace io {\n const int SIZE = (1 << 21) + 1;\n char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;\n #define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)\n char getc () {return gc();}\n inline void flush () {fwrite (obuf, 1, oS - obuf, stdout); oS = obuf;}\n inline void putc (char x) {*oS ++ = x; if (oS == oT) flush ();}\n template inline void gi (I &x) {for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;for (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;}\n template inline void print (I x) {if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;while (x) qu[++ qr] = x % 10 + '0', x /= 10;while (qr) putc (qu[qr --]);}\n struct Flusher_ {~Flusher_(){flush();}}io_flusher_;\n}\nusing io :: gi; using io :: putc; using io :: print; using io :: getc;\ntemplate void upmax(T &x, T y){x = x>y ? x : y;}\ntemplate void upmin(T &x, T y){x = x\nstruct std::hash >{\n unsigned long long operator()(pair p) const{\n return (unsigned long long)p.first * P1 + (unsigned long long)p.second * P2;\n }\n};\ntypedef unordered_map, int> d2;\n\nint a[N], res[N], pos[N];\nd2 tr[N << 2];\nvector p[N << 2], suml[N << 2];\npair op[2200005];\nint oc = 0, cnt;\n\n// all ranges are [l, r)\nvoid build(int x, int l, int r){\n if(l + 1 == r) return;\n int mid = (l + r) >> 1;\n suml[x].resize(r - l);\n p[x << 1].reserve(mid - l), p[x << 1 | 1].reserve(r - mid);\n suml[x][0] = p[x][0] < mid;\n if(p[x][0] < mid) p[x << 1].push_back(p[x][0]);\n else p[x << 1 | 1].push_back(p[x][0]);\n for(int i=1; i> 1;\n int l0 = ql == 0 ? 0 : suml[x][ql - 1], r0 = suml[x][qr - 1];\n int l1 = ql == 0 ? 0 : ql - suml[x][ql - 1], r1 = qr - suml[x][qr - 1];\n if(l0 == r0) return query(x << 1 | 1, mid, r, l1, r1);\n if(l1 == r1) return query(x << 1, l, mid, l0, r0);\n op[++oc] = {query(x << 1, l, mid, l0, r0), query(x << 1 | 1, mid, r, l1, r1)};\n return res = ++cnt;\n}\n\nint main(){\n // File(\"cf1375h\");\n int n, q;\n gi(n); gi(q);\n for(int i=0; i\n#define maxn 5005\n#define maxq 100005\nusing namespace std;\n\nint n, q;\n\nvector blocks[maxn];\nmap< pair, int> pos[maxn];\n\nvector< pair > ops;\nint a[maxn], id[maxn];\nint ret[maxq];\n\nstruct Partition {\n\tmap< pair, int > ranges;\n\n\tPartition () {\n\n\t}\n};\n\nint cnt;\n\nPartition construct(int block, int low, int high, vector& order) {\n\tif (low > high) {\n\t\treturn Partition();\n\t}\n\tif (low == high) {\n\t\tPartition ps;\n\t\tps.ranges[make_pair(0, 0)] = id[low];\n\t\treturn ps;\n\t}\n\n\tint mid = (low + high) >> 1;\n\tvector la, ra;\n\tfor (int x : order) {\n\t\tif (x <= mid) {\n\t\t\tla.push_back(x);\n\t\t} else {\n\t\t\tra.push_back(x);\n\t\t}\n\t}\n\n\tauto ls = construct(block, low, mid, la);\n\tauto rs = construct(block, mid + 1, high, ra);\n\n\tPartition ps;\n\tint i = 0;\n\tint lowx = 0, lowy = 0, highx = 0, highy = 0;\n\twhile (i < order.size()) {\n\t\tif (i > 0) {\n\t\t\tif (order[i - 1] <= mid) {\n\t\t\t\tlowx++;\n\t\t\t} else {\n\t\t\t\thighx++;\n\t\t\t}\n\t\t}\n\n\t\tlowy = lowx - 1;\n\t\thighy = highx - 1;\n\t\tfor (int j = i; j < order.size(); j++) {\n\t\t\tif (order[j] <= mid) {\n\t\t\t\tlowy++;\n\t\t\t} else {\n\t\t\t\thighy++;\n\t\t\t}\n\n\t\t\tint lindex = ls.ranges[make_pair(lowx, lowy)];\n\t\t\tint rindex = rs.ranges[make_pair(highx, highy)];\n\t\t\tif (lowx <= lowy && highx <= highy) { // merge\n\t\t\t\t/*if (lindex == 0 || rindex == 0) {\n\t\t\t\t\tfor (auto x : order) cout << x << ' ';\n\t\t\t\t\tcout << endl;\n\t\t\t\t\tcout << lowx << ' ' << lowy << ' ' << highx << ' ' << highy << endl;\n\t\t\t\t} */\n\t\t\t\tassert(lindex > 0 && rindex > 0);\n\t\t\t\tps.ranges[make_pair(i, j)] = ++cnt;\n\t\t\t\tops.push_back(make_pair(lindex, rindex));\n\t\t\t} else if (lowx <= lowy) {\n\t\t\t\tassert(lindex > 0);\n\t\t\t\tps.ranges[make_pair(i, j)] = lindex;\n\t\t\t} else {\n\t\t\t\tif (rindex == 0) {\n\t\t\t\t\t// cout << lowx << ' ' << lowy << ' ' << highx << ' ' << highy << endl;\n\t\t\t\t}\n\t\t\t\tassert(rindex > 0);\n\t\t\t\tps.ranges[make_pair(i, j)] = rindex;\n\t\t\t}\n\t\t}\n\n\t\ti++;\n\t}\n\n\treturn ps;\n}\n\nint main() {\n\tscanf(\"%d %d\", &n, &q);\n\tfor (int i = 1; i <= n; i++) {\n\t\tscanf(\"%d\", &a[i]);\n\t\tid[a[i]] = i;\n\t}\n\n\tint S = sqrt(q);\n\tcnt = n;\n\tfor (int low = 1, block = 0; low <= n; low += S, block++) {\n\t\tint high = min(n, low + S - 1);\n\t\tfor (int i = 1; i <= n; i++) if (a[i] >= low && a[i] <= high) {\n\t\t\tblocks[block].push_back(a[i]);\n\t\t}\n\t\tauto ps = construct(block, low, high, blocks[block]);\n\t\tfor (int i = 0; i < blocks[block].size(); i++) {\n\t\t\tfor (int j = i; j < blocks[block].size(); j++) {\n\t\t\t\tpos[block][make_pair(i, j)] = ps.ranges[make_pair(i, j)];\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (int it = 0; it < q; it++) {\n\t\tint l, r;\n\t\tscanf(\"%d %d\", &l, &r);\n\n\t\tret[it] = -1;\n\t\tfor (int low = 1, block = 0; low <= n; low += S, block++) {\n\t\t\tint high = min(n, low + S - 1);\n\t\t\tint lx = 0, rx = -1;\n\t\t\tfor (int i = 1; i <= r; i++) if (a[i] >= low && a[i] <= high) {\n\t\t\t\tif (i < l) {\n\t\t\t\t\tlx++;\n\t\t\t\t\trx++;\n\t\t\t\t} else {\n\t\t\t\t\trx++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (lx > rx) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tint lindex = pos[block][make_pair(lx, rx)];\n\t\t\tif (ret[it] < 0) {\n\t\t\t\tret[it] = lindex;\n\t\t\t} else {\n\t\t\t\tassert(ret[it] > 0 && lindex > 0);\n\t\t\t\tops.push_back(make_pair(ret[it], lindex));\n\t\t\t\tret[it] = ++cnt;\n\t\t\t}\n\t\t}\n\t}\n\n\tprintf(\"%d\\n\", cnt);\n\tfor (auto op : ops) {\n\t\tprintf(\"%d %d\\n\", op.first, op.second);\n\t}\n\tfor (int i = 0; i < q; i++) {\n\t\tprintf(\"%d \", ret[i]);\n\t}\n\tprintf(\"\\n\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "442f7f955feae5b9b44d5c580bca9316", "src_uid": "60cf596ad4853ebf3bbf9a96ef5d8791", "difficulty": 3300.0} {"lang": "GNU C++17", "source_code": "#include \n#include\nusing namespace std;\n \nvector> merges;\nvector, map,int>>> st; //elements to set mapping in each node of st\nvector arr,arr2;\nint cnt;\n \nvoid combine(int root){\n\tvector &v1 = st[2*root].first;\n\tvector &v2 = st[2*root+1].first;\n\tvector &v = st[root].first;\n\tv.resize((int)v1.size() + (int)v2.size());\n\tmerge(v1.begin(), v1.end(), v2.begin(), v2.end(), v.begin());\n}\n\nvoid build(int root, int sl, int sr){ \n\tif (sl == sr){\n\t\tst[root].first.push_back(arr[sl]);\n\t\treturn;\n\t}\n\tint mid = (sl+sr)/2;\n\tbuild(2*root, sl, mid);\n\tbuild(2*root+1, mid+1, sr);\n\tcombine(root);\n}\n \nint query(int root, int l, int r){\n\tvector &v1 = st[root].first;\n\tint x = lower_bound(v1.begin(), v1.end(), l) - v1.begin();\n\tint y = upper_bound(v1.begin(), v1.end(), r) - v1.begin();\n\tif(y == x+1){\n\t\treturn v1[x];\n\t}\n\tif(x == (int)v1.size() || (x>=y)){\n\t\treturn -1;\n\t}\n\tmap, int> &m = st[root].second;\n\tif(m.find({x,y}) == m.end()){\n\t\tint s1 = query(2*root, l, r);\n\t\tint s2 = query(2*root+1, l,r);\n\t\tif(s1 != -1 && s2 != -1){\n\t\t\tmerges.push_back({s1,s2});\n\t\t\tm[{x,y}] = cnt+1;\n\t\t\tcnt += 1;\n\t\t}\n\t\telse{\n\t\t\tm[{x,y}] = max(s1,s2);\n\t\t}\n\t}\n\treturn m[{x,y}];\n}\n \nint main()\n{\n\tios::sync_with_stdio(false);\n\tcin.tie(0);\n\tint n,q;\n\tcin >> n >> q;\n\tcnt = n;\n\tst.clear();\n\tarr.clear();\n\tarr2.clear();\n\tmerges.clear();\n\tst.resize(4*n + 5);\n\tarr.resize(n+1,-1);\n\tarr2.resize(n+1,-1);\n\tfor(int i = 0;i < n; ++i){\n\t\tint a;\n\t\tcin >> a;\n\t\tarr[a] = i+1;\n\t\tarr2[i+1] = a;\n\t}\n\tbuild(1,1,n);\n\tvector res;\n\twhile(q){\n\t\tq -= 1;\n\t\tint l,r;\n\t\tcin >> l >> r;\n\t\tres.push_back(query(1,l,r));\n\t}\n\tcout << cnt << endl;\n\tfor(auto x : merges){\n\t\tcout << x.first << \" \" << x.second << endl;\n\t}\n\tfor(int x : res){\n\t\tcout << x << \" \";\n\t}\n\tcout << endl;\n\t\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4f1a5ab2cdfd5ecc2b95e03a3419c090", "src_uid": "60cf596ad4853ebf3bbf9a96ef5d8791", "difficulty": 3300.0} {"lang": "GNU C++", "source_code": "#include \n#include\n#include\n#include \n#include\n#include \n#include\n#include\n#include\n\nusing namespace std;\n\n\ntypedef long long LL;\n\n\n\nint main()\n{\n LL l, r;\n cin>>l>>r;\n if(abs(r-l)<2)\n {\n cout<<-1;\n return 0;\n }\n\n LL x=l;\n if(x%2!=0)\n x++;\n\n cout<\n#include \n#include \nusing namespace std;\nifstream f(\"cf.in\");\nint main()\n{\n long long l, r;\n cin>>l>>r;\n if(l%2==0){\n if(r == l+1)\n cout<<-1;\n else\n cout<\n#define ll unsigned long long int\nusing namespace std;\nll l,r,a,b,c;\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cin>>l>>r;\n a=b=c=0;\n for(ll i=l;i<=r;i++)\n {\n if(i%2==0 && i%4!=0 &&i+2<=r)\n {\n a=i;\n b=++i;\n c=++i;\n break;\n }\n }\n if(a!=0)cout<\nusing namespace std;\nint main()\n{\nlong long int l,r;\ncin>>l>>r;\nif(l!=1)\n{\nif(r-l<=1)\ncout<<-1<\nusing namespace std;\nstring s;\nchar a; \nint ans=0,rec=0,i=0; \nint main()\n{\n\tcin>>s;\n\twhile(i<=s.size()) \n\t{ \n\t\tif(i==s.size()-1)break; \n\t\ta=s[i];\n\t\tfor(int j=i;j\nusing namespace std;\nstring s; \ntemplateinline void read(T&x)\n{\n\tT ll=1;\n T res=0;\n\tchar ch=getchar();\n while(!isdigit(ch))\n {\n\t\tif(ch=='-')\n\t\tll=-1;\n\t\tch=getchar();\n\t}\n while(isdigit(ch))\n\tres=(res<<3)+(res<<1)+ch-'0',ch=getchar();\n x=res*ll;\n}\ntemplatevoid print(T x)\n{\n if(x<0)putchar('-'),x=-x;\n if(x<10)\n putchar(x+'0');\n else\n {\n print(x/10);\n putchar(x%10+'0');\n }\n}\nint main()\n{\n cin>>s;\n int len=s.length();\n int ans=0,curlen=1;\n for(int i=0;i\nusing namespace std;\nint main()\n{\n\tint a=1,k=0,l;\n\tstring s;\n cin>>s;\n l=s.size();\n for(int i=0;i\n#define nl printf(\"\\n\");\n#define N 200001\n#define MP pair\n#define sf(n) scanf(\"%d\", &n)\n#define sff(n, m) scanf(\"%d %d\",&n,&m)\n#define sfl(n) scanf(\"%lld\", &n)\n#define sfu(n) scanf(\"%llu\", &n)\n#define sffl(n, m) scanf(\"%lld %lld\",&n,&m)\n#define pfn(n) printf(\"%d\\n\",n)\n#define pf(n) printf(\"%d \",n)\n#define pfl(n) printf(\"%lld \",n)\n#define pfln(n) printf(\"%lld\\n\",n)\n#define pfu(n) printf(\"%llu\\n\",n)\n#define pfs(s) printf(\"%s\",s)\n#define YES printf(\"YES\\n\")\n#define YES printf(\"NO\\n\")\n#define PB push_back\n#define PI 3.1415926536\n#define VST(v) sort(v.begin(),v.end())\n#define fori(n) for(int i=0;iv,v2,v3;\nvector :: iterator it1,it2;\nint main()\n{\n ///freopen(\"input.txt\",\"r\",stdin);\n ll tcase=1;\n //sf(tcase);\n while(tcase--)\n {\n int left=0,right=0,cnt=0;\n string s;\n cin>>s;\n int len=s.size();\n while(1){\n if(s[left]==s[right]){\n if(right\n#include \nusing namespace std;\nint main()\n{\n\tint n, c, l, t1=0, t2=0, sum1=0,sum2=0;\n\tvector p,t;\n\tcin >> n >> c;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tcin >> l;\n\t\tp.push_back(l);\n\t}\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tcin >> l;\n\t\tt.push_back(l);\n\t}\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tt1 += t[i];\n\t\t\n\t\tif (p[i] - (t1*c)>0)\n\t\t\tsum1 += p[i] - t1*c;;\n\t}\n\tfor (int i = n-1; i >= 0; i--)\n\t{\n\t\tt2 += t[i];\n\t\tif (p[i] - (t2*c)>0)\n\t\t\tsum2+= p[i] - t2*c;\n\t}\n\tif (sum1 > sum2) cout << \"Limak\" << endl;\n\telse if (sum1 < sum2) cout << \"Radewoosh\" << endl;\n\telse cout << \"Tie\" << endl;\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "79710fc5dc0ef416623d74e7d4f95ee0", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\n#define forn(n) for (int i=0;i\n#define vs vector \n#define out cout<<\n\n\n\nint answer(int n,int c,int *p,int *t)\n{\n int timeafterstart=0,answer=0;\n forn(n)\n\t{\n\t timeafterstart+=t[i];\n\t answer+=max(p[i]-c*timeafterstart,0);\n\t //cout<>n>>c;\n\tint f,s;\n\tf=s=0;\n\tint *p=new int [n];\n\tint *t=new int [c];\n\t\n\tforn(n) cin>>p[i];\n\tforn(n) cin>>t[i];\n f=answer( n, c, p, t);\n //forn(n) out p[i] line;\n rev(n,p)\n rev(n,t)\n //forn(n) out p[i] line;\n s=answer( n, c, p, t);\n //out f qm s line;\n \n (f>s)?out\"Limak\":f\n#include\n\nint max(int a,int b)\n{\n\tif (a>b)\n\t\treturn a;\n\telse return b;\n}\n\nint main()\n{\n\tint c,n=0;\n\tint t[51]={};\n\tint p[51]={};\n\tint limsum=0;\n\tint radsum=0;\n\tint time=0;\n\tscanf(\"%d\",&n);\n\tscanf(\"%d\",&c);\n\tfor(int i=0;i=0;i--)\n\t{\n\t\ttime=time+t[i];\n\t\tradsum=radsum+max(0,p[i]-c*time);\n\t}\n\tif(limsum>radsum)\n\t\tprintf(\"Limak\");\n\telse if(limsum==radsum)\n\t\tprintf(\"Tie\");\n\telse \n\t\tprintf(\"Radewoosh\");\n\n\t_getch();\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "64e407d07b062dbd0239dc2c1707fdf7", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\n#include\n\nusing namespace std;\nint max(int a,int b)\n{\n\tif (a>b)\n\t\treturn a;\n\telse return b;\n}\n\nint main()\n{\n\tint c,n=0;\n\tint t[51]={};\n\tint p[51]={};\n\tint limsum=0;\n\tint radsum=0;\n\tint time=0;\n\tcin>>n;\n\tcin>>c;\n\tfor(int i=0;i>p[i];\n\tfor (int i=0;i>t[i];\n\tfor(int i=0;i=0;i--)\n\t{\n\t\ttime=time+t[i];\n\t\tradsum=radsum+max(0,p[i]-c*time);\n\t}\n\tif(limsum>radsum)\n\t\tcout<<\"Limak\";\n\telse if(limsum==radsum)\n\t\tcout<<\"Tie\";\n\telse \n\t\tcout<<(\"Radewoosh\");\n\n\t_getch();\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0690563c084306bffa4bd55d4beb64ae", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "//#pragma GCC optimize(3)\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\ntypedef unsigned int uint;\ntypedef unsigned long long ull;\ntypedef pair pll;\ntypedef pair pli;\ntypedef pair pil;\ntypedef pair pii;\n#define Continue(x) { x; continue; }\n#define Break(x) { x; break; }\n#define Return(x) { x; return; }\n#define P2(x) ((x) * (x))\n#define lowbit(x) ((x) & -(x))\n#define SZ(x) ((int)(x).size())\n#define ALL(x) (x).begin(), (x).end()\n#define MEM(x, y) memset((x), (y), sizeof(x))\n#define MEN(x, y, z) memset((x), (y), sizeof((x)[0]) * (z))\n#define Diz(x) (lower_bound(dz.begin(), dz.end(), (x)) - dz.begin())\n#define DISCRETE(x) (x).push_back(INT_MIN), sort((x).begin(), (x).end()), (x).erase(unique((x).begin(), (x).end()), (x).end())\n#ifdef LOCAL\n#define DEBUG(...) cout << \">> \" << #__VA_ARGS__ << \" =\", PRT(__VA_ARGS__), cout << endl;\n#define DEBUGS(...) cout << \">> \" << #__VA_ARGS__ << \" =\", PRTS(__VA_ARGS__), cout << endl;\nvoid PRT() {} template void PRT(S x, T ... y){ cout << \" \" << x; PRT(y...); }\nvoid PRTS() {} template void PRTS(S x) { for (auto v : x) cout << \" \" << v; }\n#define TIME cout << \"RunTime: \" << clock() << \"ms\\n\", 0\n#define __int128_t long long\n#else\n#define DEBUG(...) ;\n#define DEBUGS(...) ;\n#define TIME 0\n#endif\n\nconst int INF = 0x3f3f3f3f;\nconst ll LINF = 0x3f3f3f3f3f3f3f3f;\nconst int MOD = 1e9 + 7;\ntemplate inline bool Min(S &a, const T &b){ return a > b ? a = b, true : false; }\ntemplate inline bool Max(S &a, const T &b){ return a < b ? a = b, true : false; }\ntemplate inline void Adm(S &a, const T &b){ a = (a + b) % MOD; if (a < 0) a += MOD; }\ntemplate inline void Mum(S &a, const T &b){ a = 1LL * a * b % MOD; }\ntemplate inline bool IsPri(T x) { if (x < 2) return false; for (T i = 2; i * i <= x; ++i) if (x % i == 0) return false; return true; }\ntemplate inline T Gcd(T a, T b){ while (b){ T t = b; b = a % b; a = t; } return a; }\ntemplate inline int BitCnt(T x){ int cnt = 0; while (x)++cnt, x &= x - 1; return cnt; }\ntemplate inline T MDis(T x1, T y1, T x2, T y2){ return abs(x1 - x2) + abs(y1 - y2); }\ntemplate inline T MDis(T x1, T y1, T z1, T x2, T y2, T z2){ return abs(x1 - x2) + abs(y1 - y2) + abs(z1 - z2); }\ninline double EDis(double x1, double y1, double x2, double y2){ return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }\ninline double EDis(double x1, double y1, double z1, double x2, double y2, double z2){ return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2)); }\ninline ll Pow(ll a, ll n) { ll t = 1; a %= MOD; while (n > 0) { if (n & 1) t = t * a % MOD; a = a * a % MOD, n >>= 1; } return t % MOD; }\n#define gc p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2) ? EOF : *p1++;\ninline int read(){ static char buf[1000000], *p1 = buf, *p2 = buf; register int x = false; register char ch = gc; register bool sgn = false; while (ch != '-' && (ch < '0' || ch > '9')) ch = gc; if (ch == '-') sgn = true, ch = gc; while (ch >= '0'&& ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = gc; return sgn ? -x : x; }\n//emplace unordered \u80fdll\u5c31\u5f00 \u51fd\u6570\u5185\u5224\u975e\u6cd5+\n\nset> st;\nvector rotate(vector v, vector p) //p\u5f53\u524d\u8be5\u653e\u4ec0\u4e48\n{\n\tvector res;\n\tfor (int i = 0; i <= 24; ++i)\n\t\tres.push_back(v[p[i]]);\n\treturn res;\n}\nint cnt = 0;\nvoid DFS(vector v)\n{\n\tif (cnt > 5000)\n\t\tputs(\"NO\"), exit(0);\n\tif (!st.insert(v).second)\n\t\treturn;\n\tint flag = 1;\n\tfor (int i = 1; i <= 24 && flag; i += 4)\n\t\tif (v[i] != v[i + 1] || v[i + 1] != v[i + 2] || v[i + 2] != v[i + 3])\n\t\t\tflag = 0;\n\tif (flag)\n\t\tputs(\"YES\"), exit(0);\n\tvector &&a = rotate(v, { 0, 2, 4, 1, 3, 13, 14, 7, 8, 9, 10, 11, 12, 21, 22, 15, 16, 5, 6, 19, 20, 17, 18, 23, 24 });\n\tDFS(a);\n\tvector &&b = rotate(v, { 0, 1, 2, 3, 4, 5, 6, 19, 20, 10, 12, 9, 11, 13, 14, 7, 8, 17, 18, 23, 24, 21, 22, 15, 16 });\n\tDFS(b);\n\tvector &&c = rotate(v, { 0, 24, 2, 22, 4, 1, 6, 3, 8, 5, 10, 7, 12, 15, 13, 16, 14, 17, 18, 19, 20, 21, 9, 23, 11 });\n\tDFS(c);\n\tvector &&d = rotate(v, { 0, 1, 6, 3, 8, 5, 10, 7, 12, 9, 23, 11, 21, 13, 14, 15, 16, 19, 17, 20, 18, 4, 22, 2, 24 });\n\tDFS(d);\n}\nint main()\n{\n#ifdef LOCAL\n\tfreopen(\"C:/input.txt\", \"r\", stdin);\n\t//freopen(\"C:/output.txt\", \"w\", stdout);\n#endif\n\tvector v(1);\n\tfor (int i = 0; i < 24; ++i)\n\t{ \n\t\tint x;\n\t\tscanf(\"%d\", &x);\n\t\tv.push_back(x);\n\t}\n\tDFS(v);\n\tputs(\"NO\");\n\n\treturn TIME;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "206e700d2fc735e23168b0f7efc89131", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define fi \"a.inp\"\n#define fo \"a.out\"\n\n#define maxint 2147483647\n\nusing namespace std;\n\nint a[30],b[30],d[10];\nint mang[10],mang1[30];\nint kq;\n\nvoid gan()\n{\n\tint i,j;\n\t\n\tfor(j=1;j<=24;j++)\n\t{\n\t\tb[j]=a[j];\n\t}\n}\n\nint ktOk()\n{\n\tint i,j;\n\t\n\tfor(i=1;i<=6;i++)\n\t{\n\t\tfor(j=(i-1)*4+1;j<=i*4;j++)\n\t\t{\n\t\t\tif(b[j]!=b[i*4])\n\t\t\t{\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 1;\n}\n\nint xet()\n{\n\tint i,j;\n\tint tg,tg1;\n\t\n\tfor(i=0;i<8;i++)\n\t{\n\t\tmang1[i]=mang[i];\n\t}\n\tfor(i=0;i<3;i++)\n\t{\n\t\tgan();\n\t\t\n\t\ttg=mang[6];\n\t\ttg1=mang[7];\n\t\t\n\t\tfor(i=3;i>0;i--)\n\t\t{\n\t\t\tmang[i*2]=mang[(i-1)*2];\n\t\t\tmang[i*2+1]=mang[(i-1)*2+1];\n\t\t}\n\t\t\n\t\tmang[0]=tg;\n\t\tmang[1]=tg1;\n\t\t\n\t\tfor(j=0;j<8;j++)\n\t\t{\n\t\t\tb[mang1[j]]=a[mang[j]];\n\t\t}\n\t\t\n\t\tif(ktOk()==1)\n\t\t{\n\t\t\treturn 1;\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n\nvoid solve()\n{\n\tint i,j;\n\t\n\tkq=0;\n\tfor(i=1;i<=6;i++)\n\t{\n\t\tfor(j=(i-1)*4+1;j<=i*4;j++)\n\t\t{\n\t\t\tif(a[j]!=a[i*4])\n\t\t\t{\n\t\t\t\td[i]=1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tif(d[1]==1 && d[2]==1 && d[3]==1 && d[6]==1 && d[4]==0 && d[5]==0)\n\t{\n\t\tmang[0]=2;\n\t\tmang[1]=4;\n\t\tmang[2]=6;\n\t\tmang[3]=8;\n\t\tmang[4]=10;\n\t\tmang[5]=12;\n\t\tmang[6]=23;\n\t\tmang[7]=21;\n\t\t\n\t\tif(xet()==1)\n\t\t{\n\t\t\tkq=1;\n\t\t\treturn ;\n\t\t}\n\t\t\n\t\t\n\t\tmang[0]=1;\n\t\tmang[1]=3;\n\t\tmang[2]=5;\n\t\tmang[3]=7;\n\t\tmang[4]=9;\n\t\tmang[5]=11;\n\t\tmang[6]=24;\n\t\tmang[7]=22;\n\t\t\n\t\tif(xet()==1)\n\t\t{\n\t\t\tkq=1;\n\t\t\treturn ;\n\t\t}\n\t}\n\tif(d[1]==1 && d[3]==1 && d[4]==1 && d[5]==1 && d[2]==0 && d[6]==0)\n\t{\n\t\tmang[0]=3;\n\t\tmang[1]=4;\n\t\tmang[2]=17;\n\t\tmang[3]=19;\n\t\tmang[4]=10;\n\t\tmang[5]=9;\n\t\tmang[6]=16;\n\t\tmang[7]=14;\n\t\n\t\tif(xet()==1)\n\t\t{\n\t\t\tkq=1;\n\t\t\treturn ;\n\t\t}\n\t\t\n\t\t\n\t\tmang[0]=1;\n\t\tmang[1]=2;\n\t\tmang[2]=18;\n\t\tmang[3]=20;\n\t\tmang[4]=12;\n\t\tmang[5]=11;\n\t\tmang[6]=15;\n\t\tmang[7]=13;\n\t\t\n\t\tif(xet()==1)\n\t\t{\n\t\t\tkq=1;\n\t\t\treturn ;\n\t\t}\n\t}\n\tif(d[2]==1 && d[4]==1 && d[5]==1 && d[6]==1 && d[1]==0 && d[3]==0)\n\t{\n\t\tmang[0]=5;\n\t\tmang[1]=6;\n\t\tmang[2]=17;\n\t\tmang[3]=18;\n\t\tmang[4]=21;\n\t\tmang[5]=22;\n\t\tmang[6]=13;\n\t\tmang[7]=14;\n\t\t\n\t\tif(xet()==1)\n\t\t{\n\t\t\tkq=1;\n\t\t\treturn ;\n\t\t}\n\t\t\n\t\tmang[0]=7;\n\t\tmang[1]=8;\n\t\tmang[2]=19;\n\t\tmang[3]=20;\n\t\tmang[4]=23;\n\t\tmang[5]=24;\n\t\tmang[6]=15;\n\t\tmang[7]=16;\n\t\t\n\t\tif(xet()==1)\n\t\t{\n\t\t\tkq=1;\n\t\t\treturn ;\n\t\t}\n\t}\n}\n\nvoid output()\n{\n\tif(kq==1)\n\t{\n\t\tprintf(\"YES\\n\");\n\t}\n\telse\n\t{\n\t\tprintf(\"NO\\n\");\n\t}\n}\n\nint main()\n{\n\tint i;\n//\tfreopen(fi,\"r\",stdin);\n//\tfreopen(fo,\"w\",stdout);\n\t\n\tfor(i=1;i<=24;i++)\n\t{\n\t\tscanf(\"%d\",&a[i]);\n\t}\n\t\n\tsolve();\n\t\n\toutput();\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d1af7935b8110b35278a94f03da7e0ce", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n\nusing namespace std;\n\nint main()\n{\n int a[28];\n while(1){\n int flag=0;\n for(int i=1;i<=24;i++)\n scanf(\"%d\",&a[i]);\n if(a[1]==a[2]&&a[1]==a[3]&&a[1]==a[4] && a[9]==a[10]&&a[9]==a[11]&&a[9]==a[12]){\n if(a[13]==a[14]&&a[13]==a[15]&&a[13]==a[16] && a[17]==a[18]&&a[17]==a[19]&&a[17]==a[20] &&\n a[5]==a[6]&&a[5]==a[7]&&a[5]==a[8] && a[21]==a[22]&&a[21]==a[23]&&a[21]==a[24]){\n flag=1;\n }\n else if(a[5]==a[6]&&a[5]==a[15]&&a[5]==a[16] && a[13]==a[14]&&a[13]==a[23]&&a[13]==a[24] &&\n a[21]==a[22]&&a[21]==a[19]&&a[21]==a[20] && a[17]==a[18]&&a[17]==a[7]&&a[17]==a[8])\n flag=1;\n else if(a[5]==a[6]&&a[5]==a[19]&&a[5]==a[20] && a[13]==a[14]&&a[13]==a[7]&&a[13]==a[8] &&\n a[21]==a[22]&&a[21]==a[15]&&a[21]==a[16] && a[17]==a[18]&&a[17]==a[23]&&a[17]==a[24])\n flag=1;\n }\n else if(flag==0 && a[13]==a[14]&&a[13]==a[15]&&a[13]==a[16] && a[17]==a[18]&&a[17]==a[19]&&a[17]==a[20]){\n if(a[2]==a[4]&&a[2]==a[5]&&a[2]==a[7] && a[6]==a[8]&&a[6]==a[9]&&a[6]==a[11] &&\n a[10]==a[12]&&a[10]==a[22]&&a[10]==a[24] && a[21]==a[23]&&a[21]==a[1]&&a[21]==a[3])\n flag=1;\n else if(a[2]==a[4]&&a[2]==a[22]&&a[2]==a[24] && a[6]==a[8]&&a[6]==a[1]&&a[6]==a[3] &&\n a[10]==a[12]&&a[10]==a[5]&&a[10]==a[7] && a[21]==a[23]&&a[21]==a[9]&&a[21]==a[11])\n flag=1;\n }\n else if(flag==0 && a[5]==a[6]&&a[5]==a[7]&&a[5]==a[8] && a[21]==a[22]&&a[21]==a[23]&&a[21]==a[24]){\n if(a[1]==a[2]&&a[1]==a[14]&&a[1]==a[16] && a[13]==a[15]&&a[13]==a[9]&&a[13]==a[10] &&\n a[11]==a[12]&&a[11]==a[17]&&a[11]==a[19] && a[18]==a[20]&&a[18]==a[3]&&a[18]==a[4])\n flag=1;\n else if(a[1]==a[2]&&a[1]==a[17]&&a[1]==a[19] && a[13]==a[15]&&a[13]==a[3]&&a[13]==a[4] &&\n a[11]==a[12]&&a[11]==a[14]&&a[11]==a[16] && a[18]==a[20]&&a[18]==a[9]&&a[18]==a[10])\n flag=1;\n }\n if(flag==1)\n printf(\"YES\\n\");\n else\n printf(\"NO\\n\");\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "048638001c8e08893c32cc2336aace11", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint win = 0;\nint o[25];\nint p[6][8] = { {2, 4, 6, 8, 10, 12, 21, 23}, {1, 3, 5, 7, 9, 11, 22, 24},\n {13, 14, 5, 6, 17, 18, 21, 22}, {15, 16, 7, 8, 19, 20, 23, 24},\n {4, 3, 14, 16, 9, 10, 19, 17}, {2, 1, 13, 15, 11, 12, 20, 18} };\nint q[6][4] = { {17, 18, 20, 19}, {13, 15, 16, 14}, {1, 3, 4, 2}, {9, 10, 12, 11}, {5, 7, 8, 6}, {21, 22, 24, 23} };\n\nunordered_map chk;\n\nvoid back(int depth, int pre) {\n long long ff = 1, sum = 0;\n for(int i = 1; i <= 24; i++) {\n sum += ff * o[i];\n ff *= 6;\n }\n if(chk.count(sum)) {\n return;\n }\n chk[sum] = 1;\n \n if(win) return;\n int flag = 0;\n for(int i = 0; i < 6; i++) {\n for(int j = i * 4; j < i * 4 + 4; j++) {\n if(o[j + 1] == o[i * 4 + 1]) continue;\n flag = 1;\n break;\n }\n }\n if(!flag) {\n win = 1;\n return;\n }\n if(depth == 14) return;\n for(int i = 0; i < 6; i += 2) {\n if(win) return;\n for(int j = 0; j < 6; j++) {\n int nxt = j + 2;\n int tmp = o[p[i][j]];\n o[p[i][j]] = o[p[i][nxt]];\n o[p[i][nxt]] = tmp;\n }\n int tmp = o[q[i][3]];\n for(int j = 3; j >= 1; j--) o[q[i][j]] = o[q[i][j-1]];\n o[q[i][0]] = tmp;\n \n back(depth + 1, i);\n \n tmp = o[q[i][0]];\n for(int j = 0; j < 3; j++) o[q[i][j]] = o[q[i][j+1]];\n o[q[i][3]] = tmp;\n \n for(int j = 7; j >= 2; j--) {\n int nxt = j - 2;\n int tmp = o[p[i][j]];\n o[p[i][j]] = o[p[i][nxt]];\n o[p[i][nxt]] = tmp;\n }\n }\n}\n\nint main() {\n for(int i = 1; i <= 24; i++) {\n scanf(\"%d\",&o[i]);\n o[i]--;\n }\n back(0, -1);\n if(win) printf(\"YES\\n\");\n else printf(\"NO\\n\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cfb8763e2dcff119c701cb4ed46259a3", "src_uid": "881a820aa8184d9553278a0002a3b7c4", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "//In the name of God\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define ll long long \n#define ld long double \n#define pii pair\n#define pll pair\nusing namespace std;\nint a[20],n;\nbool g(int x,int y)\n{\n for(int i=0;i<20;i++)\n a[i]=0;\n for(;x>0;)\n {\n a[x%10]++;\n x/=10;\n }\n for(;y>0;)\n {\n a[(y%10)+10]++;\n y/=10;\n }\n for(int i=0;i<10;i++)\n if(a[i]&&a[i+10])\n return true;\n return 0;\n}\nbool b[1000*1000*1000];\nint main()\n{\n int cnt=0;\n cin>>n;\n for(int i=1;i<=n;i++)\n\t{\n\t\tif(!b[i])\n\t\t{\n\t\t\tif((!(n%i))&&(g(n,i)))\n\t\t\t\tcnt++;\n\t\t}\n\t\telse\n\t\t\tfor(int j=2;(j*i)<=1e9;j++)\n\t\t\t\tb[i*j]=1;\n\t}\n cout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define maxn 200010\nint N;\nstring a = \"\";\nchar isshow[256];\nbool is[1000000010];\nvoid tostr(int i)\n{\n if (i >= 0 && i < 10)\n {\n a = i + '0';\n return;\n }\n tostr(i / 10);\n a += (i % 10 + '0');\n}\nint main()\n{\n cin >> N;\n tostr(N);\n string Nt = a;\n for (int i = 0; i < Nt.length(); i++)\n isshow[Nt[i]] = true;\n string t = \"\";\n int ans = 1;\n if (N == 1)\n cout << 1 << endl;\n else\n {\n if (isshow['1'])\n ans++;\n for (int i = 2; i <= sqrt(N*1.0); i++)\n {\n for (int j = i; j <= N / 2; j += i)\n {\n if (N%j == 0&&!is[j])\n {\n is[j] = true;\n a = \"\";\n tostr(j);\n int len = a.length();\n for (int k = 0; k < len; k++)\n {\n if (isshow[a[k]])\n {\n ans++;\n break;\n }\n }\n }\n }\n }\n cout << ans << endl;\n }\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ce4c1f5b559d2a50e6e99d06699b8cad", "src_uid": "ada94770281765f54ab264b4a1ef766e", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define input freopen(\"input.txt\",\"r\",stdin)\n#define output freopen(\"output.txt\",\"w\",stdout)\n\nusing namespace std;\n\n#define pb push_back\n#define pf push_front\n#define p_f pop_front\n#define p_b pop_back\n#define LL __int64\n#define LD long double\n#define MP make_pair\n#define fi first\n#define se second\n#define sc scanf\n#define pr printf\n#define str strlen\nLL a,b,i,j,k,n,m,d[100001]={0},gh=0;\nLL c[1010000]={0},cnt=0,fl=1,a2,a3=-1000000,used[100000001]={0},i1,ans=0,maxv=0,us[20];\nmain()\n{\n //input;\n //output;\n sc(\"%I64d\",&n);\n if(n==1){pr(\"1\\n\");return 0;}\n for(i=1;i<=sqrt(n);i++)\n {\n if(n%i==0&&used[i]==0){ used[i]=1;c[cnt]=i;cnt++;\n if(used[(n/i)]==0){ c[cnt]=(n/i);cnt++;used[n/i]=1; }}\n }\n while(n>0)\n {\n us[n%10]=1;\n n/=10;\n }\n for(i=0;i0)\n {\n if(us[c[i]%10]==1){ gh++; break; }\n c[i]/=10;\n }\n //pr(\"%I64d \",c[i]);\n }\n pr(\"%I64d\\n\",gh);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4eebaa0d7d2e304e5be3822ff196064e", "src_uid": "ada94770281765f54ab264b4a1ef766e", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\n#include\nint main()\n{\n int n;\n int sum=1;\n int data[12];\n for(int i=0;i<10;i++)data[i]=0;\n scanf(\"%d\",&n);\n if(n==1)\n {\n printf(\"1\");return 0;\n }\n for(int i=n;i>0;i/=10)\n {\n data[i%10]=1;\n }\n int i=3;\n if(n%2==0)i=2;\n for(;i0;j/=10)\n {\n if(data[j%10]==1)break;\n }\n if(j>0)\n {\n sum++;\n //printf(\"%d\\n\",i);\n //getch();\n }\n }\n }\n if(data[1]==1)sum++;\n printf(\"%d\",sum);\n getch();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "33343d05ba46bbd30479a0594b5400b8", "src_uid": "ada94770281765f54ab264b4a1ef766e", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define sz(v) ((int)(v).size())\n\ntypedef long long ll;\nconst ll mod = 1e9 + 7;\nll N; int K;\n\nstruct MAT {\n int m[31][31];\n MAT operator *(const MAT& o) const {\n MAT ret = {0,};\n for(int i = 0; i <= K; i++) {\n for(int j = 0; j <= K; j++) {\n ret.m[i][j] = 0;\n for(int k = 0; k <= K; k++)\n ret.m[i][j] = (ret.m[i][j] + (ll)m[i][k] * o.m[k][j]) % mod;\n }\n } return ret;\n }\n};\nMAT A[65][30];\nMAT P[65][30];\nMAT S[65][30];\nMAT res;\n\nint main() {\n //freopen(\"a.in\", \"r\", stdin);\n //freopen(\"a.out\", \"w\", stdout);\n scanf(\"%lld%d\", &N, &K);\n vector base_K;\n while(N) base_K.push_back(N % K), N /= K;\n for(int i = 0; i < K; i++) {\n for(int j = 0; j <= K; j++) A[0][i].m[j][j] = 1;\n for(int j = 0; j <= K; j++) A[0][i].m[i][j] = 1;\n }\n for(int i = 1; i < sz(base_K); i++) {\n P[i - 1][0] = A[i - 1][0];\n for(int j = 1; j < K; j++)\n P[i - 1][j] = P[i - 1][j - 1] * A[i - 1][j];\n S[i - 1][K - 1] = A[i - 1][K - 1];\n for(int j = K - 1; j--; )\n S[i - 1][j] = A[i - 1][j] * S[i - 1][j + 1];\n for(int j = 0; j < K; j++) {\n A[i][j] = S[i - 1][j];\n if(j) A[i][j] = A[i][j] * P[i - 1][j - 1];\n }\n }\n int x = 0;\n for(int i = 0; i <= K; i++) res.m[i][i] = 1;\n for(int i = sz(base_K); i--; ) {\n for(int j = 0; j < base_K[i]; j++) {\n res = res * A[i][x];\n x = (x + 1) % K;\n }\n }\n int ans = 0;\n for(int i = 0; i <= K; i++)\n ans = (ans + res.m[i][K]) % mod;\n printf(\"%d\\n\", ans);\n return ans;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4844e1d8b8eda5ce2cbae8579e26466f", "src_uid": "175ce134da7cc5af9c8457e7bd9a40a2", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\nusing namespace std;\nconst int Mod=1e9+7;\nint n,m,K,sum,now,a[110];\nvoid ADD(int &x,int y){\n\tx+=y; if (x>=Mod) x-=Mod;\n}\nstruct Matrix{\n\tint v[110][110];\n\tMatrix(){ memset(v,0,sizeof(v));}\n\tMatrix operator*(const Matrix &a) const{\n\t\tMatrix res;\n\t\tfor (int k=0;k<=K;k++)\n\t\t\tfor (int i=0;i<=K;i++)\n\t\t\t\tif (v[i][k])\n\t\t\t\t\tfor (int j=0;j<=K;j++)\n\t\t\t\t\t\tif (a.v[k][j])\n\t\t\t\t\t\t\tres.v[i][j]=(1ll*v[i][k]*a.v[k][j]+res.v[i][j])%Mod;\n\t\treturn res;\n\t}\n} ans,/*hanhan,*/s[75][35],pre[75][35],suf[75][35];\nvoid work(int n){\n\tint tmp=n;\n\twhile (tmp){\n\t\ta[++m]=tmp%K;\n\t\ttmp/=K;\n\t}\n\treverse(a+1,a+m+1);\n}\nint main(){\n\tscanf(\"%d%d\",&n,&K);\n//\tn++; \n\twork(n);\n\tfor (int i=0;i=0;j--) suf[i-1][j]=s[i-1][j]*suf[i-1][j+1];\n\t\tfor (int j=0;j=K){\n\t\t\t\tfor (int j=now;j\nusing namespace std;\n\nconst int N = 70;\n\nconst int mod = 1e9 + 7;\nconst long long MOD = 1LL * mod * mod;\n\nint k, len;\nlong long n, C[N][N];\n\nstruct Mat {\n\tint A[N][N];\n\tvoid init() {\n\t\tmemset(A, 0, sizeof(A));\n\t}\n}ind, T[N][N], pre[N][N], suf[N][N], start;\n\nMat operator * (Mat a, Mat b) {\n\tmemset(C, 0, sizeof(C));\t\t\n\tfor(int i = 0; i <= len; ++ i) {\n\t\tfor(int k = 0; k <= len; ++ k) {\n\t\t\tfor(int j = 0; j <= len; ++ j) {\n\t\t\t\tC[i][j] += 1LL * a.A[i][k] * b.A[k][j];\n\t\t\t\tif(C[i][j] >= MOD) C[i][j] -= MOD;\n\t\t\t}\n\t\t}\n\t}\n\tfor(int i = 0; i <= len; ++ i) {\n\t\tfor(int j = 0; j <= len; ++ j)\n\t\tind.A[i][j] = C[i][j] % mod;\n\t}\n\treturn ind;\n}\n\nnamespace {\n\tint add(int x) {return (x >= mod) ? x - mod : x;}\n\tint sub(int x) {return (x < 0) ? x + mod : x;}\n\tvoid Add(int &x, int y) {x = add(x + y);}\n\tvoid Sub(int &x, int y) {x = sub(x - y);}\n\tint Mul(int x, int y) {return (1LL * x * y) % mod;}\n\tint Pow(int x, int y = mod - 2) {\n\t\tint res = 1;\n\t\tfor(; y; y >>= 1, x = 1LL * x * x % mod) {\n\t\t\tif(y & 1) {\n\t\t\t\tres = 1LL * res * x % mod;\n\t\t\t}\n\t\t}\n\t\treturn res;\n\t}\n}\n\nvector calc(long long n, int k) {\n\tvector ans;\n\tans.clear();\n\twhile(n) {\n\t\tans.push_back(n % k);\n\t\tn /= k;\n\t}\n\treturn ans;\n}\n\nvoid build(int x) {\n\tfor(int i = 0; i < len; ++ i) T[0][x].A[i][i] = 1;\n\tT[0][x].A[x][x] = 0;\n\tT[0][x].A[k + 1][x] = 1;\n\tT[0][x].A[x][k + 1] = mod - 1;\n\tT[0][x].A[k + 1][k + 1] = 2;\n}\n\nvoid make(int x) {\n\tpre[x][0] = T[x][0];\n\tfor(int i = 1; i < k; ++ i) \n\tpre[x][i] = pre[x][i - 1] * T[x][i];\n\tsuf[x][k - 1] = T[x][k - 1];\n\tfor(int i = k - 2; i >= 0; -- i)\n\tsuf[x][i] = T[x][i] * suf[x][i + 1];\n}\n\nint main() {\n\tcin >> n >> k;\n\t-- n;\n\tvector ex = calc(n, k);\n\tif(!ex.size()) ex.resize(1);\n\tlen = k + 1;\n\tfor(int i = 0; i < k; ++ i) build(i);\n\tstart.init();\n\tstart.A[0][k] = start.A[0][k + 1] = 1;\n\tfor(int i = 1; i < (int) ex.size(); ++ i) {\n\t\tmake(i - 1);\n\t\tfor(int j = 0; j < k; ++ j) {\n\t\t\tif(j == 0) T[i][j] = pre[i - 1][k - 1];\n\t\t\telse\n\t\t\tT[i][j] = suf[i - 1][j] * pre[i - 1][(j + k - 1) % k];\n\t\t}\n\t}\n\tint bef = 0;\n\tfor(int i = ex.size() - 1; i >= 0; -- i) {\n\t\tfor(int j = 0; j < (int)ex[i] + (i == 0); ++ j) {\n\t\t\tstart = start * T[i][(j + bef) % k];\n\t\t}\n\t\tbef += ex[i];\n\t}\n\tcout << start.A[0][k + 1] << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c4c27c449e2084073c925546b140c37c", "src_uid": "175ce134da7cc5af9c8457e7bd9a40a2", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\n#include\n#define N 100\n#define M 35\n#define mmod 1000000007\n#define LL long long\nusing namespace std;\nint n,m,a[N];\nstruct mat{\n\tint a[M][M];\n\tmat() {memset(a,0,sizeof(a));}\n\tfriend mat operator *(mat a,mat b)\n\t{\n\t\tmat c;\n\t\tfor(int i=0;i<=m;i++)\n\t\t\tfor(int j=0;j<=m;j++)\n\t\t\t\tfor(int k=0;k<=m;k++)\n\t\t\t\t\tc.a[i][j]=(c.a[i][j]+1ll*a.a[i][k]*b.a[k][j]%mmod)%mmod;\n\t\treturn c;\n\t}\n}f,g,tmp,t,I,A;\nvoid solve(int now)\n{\n\tif(now==1)\n\t{\n\t\tfor(int i=0;i\n\nusing namespace std;\n\nint main()\n{\n\tlong long unsigned n;\n\tcin >> n;\n\tlong long unsigned r1 = n / 7 + n / 5 + n / 3 + n / 2;\n\tlong long unsigned r2 = n / 35 + n / 15 + n / 6 + n / 21 + n / 10 + n / 14;\n\tlong long unsigned r3 = n / (7 * 5 * 3) + n / (5 *3 * 2) + n / (7 * 3 * 2 )+ n / (7 *3 *2);\n\tlong long unsigned r = n - r1 + r2 - r3 + n / 7 / 5 / 3 / 2;\n\tcout << r << endl;\n\tsystem(\"pause\");\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "13490d08c9c768d1040dd997ad2fdfc2", "src_uid": "e392be5411ffccc1df50e65ec1f5c589", "difficulty": 1500.0} {"lang": "MS C++", "source_code": "#include \n//#include \nusing namespace std;\n\ntypedef long long ll;\n\nint main()\n{\n\tll n, a, b, w, h;\n\tcin >> n >> a >> b >> w >> h;\n\tll l = 0, r = 1e18, d;\n\tll cnt1, cnt2;\n\twhile (r - l > 0) {\n\t\td = (l + r) / 2;\n\t\tcnt1 = (w / (a + 2 * d)) * (h / (b + 2 * d));\n\t\tcnt2 = (w / (b + 2 * d)) * (h / (a + 2 * d));\n\t\tif (cnt1 >= n || cnt2 >= n)\n\t\t\tl = d + 1;\n\t\telse\n\t\t\tr = d;\n\t}\n\tcout << d << endl;\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "959418957dd632ddec8c9b8608415bba", "src_uid": "e392be5411ffccc1df50e65ec1f5c589", "difficulty": 1500.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\nint main()\n{\n ll n;\n cin>>n;\n ll a[]={2,3,5,7};\n ll ans=0;\n for(int i=0; i<4; i++)\n {\n ans+=(n/a[i]);\n }\n for(int i=0; i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define DINF (1. / 0.)\n#define INF (int)1e9\n#define LINF (long long)1e18\n\ntypedef long double ldouble;\n\nlong long __gcd(long long a, long long b)\n{\n\twhile (a != 0)\n\t{\n\t\tlong long __t = b % a;\n\t\tb = a;\n\t\ta = __t;\n\t}\n\treturn b;\n}\n\n\nbool isSimple(unsigned x)\n{\n\tfor (unsigned i = 2; i < x; i++)\n\t\tif (x % i == 0)\n\t\t\treturn false;\n\treturn true;\n}\n\nint main()\n{\n\tcin.tie(0); cout.tie(0); cerr.tie(0);\n\tios_base::sync_with_stdio(false);\n\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n\n\n\tlong long x; cin >> x;\n\n\tcout << x - x / 2 - x / 3 - x / 5 - x / 7 + x / 6 + x / 10 + x / 14 + x / 15 + x / 21 + x / 35 - x / 30 - x / 54 - x / 70 - x / 105 + x / 210;\n\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "aec54660b9720d8f94513305625ec907", "src_uid": "e392be5411ffccc1df50e65ec1f5c589", "difficulty": 1500.0} {"lang": "MS C++", "source_code": "#include\n#include\n\nusing namespace std;\n\nint main() {\n\tios_base::sync_with_stdio(false);\n\tchar a, b;\n\tcin >> a >> b;\n\tint begin = a;\n\tint end = b;\n\tint n;\n\tcin >> n;\n\tn = n % 4;\n\tstring res;\n\tif (begin == 118) {\n\t\tif (end == 118) {\n\t\t\tres = \"undefined\";\n\t\t}\n\t\tif (end == 60) {\n\t\t\tif (n == 1) {\n\t\t\t\tres = \"cw\";\n\t\t\t}\n\t\t\tif (n == 3) {\n\t\t\t\tres = \"ccw\";\n\t\t\t}\n\t\t}\n\t\tif (end == 94) {\n\t\t\tres = \"undefined\";\n\t\t}\n\t\tif (end == 62) {\n\t\t\tif (n == 1) {\n\t\t\t\tres = \"ccw\";\n\t\t\t}\n\t\t\tif (n == 3) {\n\t\t\t\tres = \"cw\";\n\t\t\t}\n\t\t}\n\n\t}\n\tif (begin == 60) {\n\t\tif (end == 118) {\n\t\t\tif (n == 1) {\n\t\t\t\tres = \"ccw\";\n\t\t\t}\n\t\t\tif (n == 3) {\n\t\t\t\tres = \"cw\";\n\t\t\t}\n\t\t}\n\t\tif (end == 60) {\n\t\t\tres = \"undefined\";\n\t\t}\n\t\tif (end == 94) {\n\t\t\tif (n == 1) {\n\t\t\t\tres = \"cw\";\n\t\t\t}\n\t\t\tif (n == 3) {\n\t\t\t\tres = \"ccw\";\n\t\t\t}\n\t\t}\n\t\tif (end == 62) {\n\t\t\tres = \"undefined\";\n\t\t}\n\t}\n\tif (begin == 94) {\n\t\tif (end == 118) {\n\t\t\tres = \"undefined\";\n\t\t}\n\t\tif (end == 60) {\n\t\t\tif (n == 1) {\n\t\t\t\tres = \"ccw\";\n\t\t\t}\n\t\t\tif (n == 3) {\n\t\t\t\tres = \"cw\";\n\t\t\t}\n\t\t}\n\t\tif (end == 94) {\n\t\t\tres = \"undefined\";\n\t\t}\n\t\tif (end == 62) {\n\t\t\tif (n == 1) {\n\t\t\t\tres = \"cw\";\n\t\t\t}\n\t\t\tif (n == 3) {\n\t\t\t\tres = \"ccw\";\n\t\t\t}\n\t\t}\n\t}\n\tif (begin == 62) {\n\t\tif (end == 118) {\n\t\t\tif (n == 1) {\n\t\t\t\tres = \"cw\";\n\t\t\t}\n\t\t\tif (n == 3) {\n\t\t\t\tres = \"ccw\";\n\t\t\t}\n\t\t}\n\t\tif (end == 60) {\n\t\t\tres = \"undefined\";\n\t\t}\n\t\tif (end == 94) {\n\t\t\tif (n == 1) {\n\t\t\t\tres = \"ccw\";\n\t\t\t}\n\t\t\tif (n == 3) {\n\t\t\t\tres = \"cw\";\n\t\t\t}\n\t\t}\n\t\tif (end == 62) {\n\t\t\tres = \"undefined\";\n\t\t}\n\t}\n\tcout << res;\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ff46cb98a455ac1f848943744918ed20", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include \n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n char s[15];\n s[1]=s[5]=s[9]=118;\n s[2]=s[6]=s[10]=60;\n s[3]=s[7]=s[11]=94;\n s[4]=s[8]=s[12]=62;\n char c1,c2;\n long long n;\n scanf(\"%c %c\",&c1,&c2);\n //getchar();\n scanf(\"%lld\",&n);\n if(n%2==0)\n {\n printf(\"undefined\\n\");\n }\n else\n {\n for(int i=5;i<=8;i++)\n {\n if(c1==s[i])\n {\n if(s[i+n]==c2)\n printf(\"cw\\n\");\n else if(s[i-n]==c2)\n printf(\"ccw\\n\");\n }\n\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "91afd7ea04c45320eacadab71897536b", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0} {"lang": "MS C++", "source_code": "#include \n#include \nint main()\n{\n\tchar start, end;\n\tstd::cin >> start >> end;\n\tunsigned long int n;\n\tint st, en;\n\tstd::cin >> n;\n\tswitch (start)\n\t{\n\tcase 118: st = 1; break;\t//v\n\tcase 60: st = 2; break;\t\t//<\n\tcase 94: st = 3; break;\t\t//^\n\tcase 62: st = 4; break;\t\t//>\n\t}\n\tswitch (end)\n\t{\n\tcase 118: en = 1; break;\t//v\n\tcase 60: en = 2; break;\t\t//<\n\tcase 94: en = 3; break;\t//^\n\tcase 62: en = 4; break;\t\t//>\n\t}\n\n\tn = n % 4;\n\n\tif (n == 1)\n\t\tif (en - st == 1 || en - st == -3)\n\t\t\tstd::cout << \"cw\";\n\t\telse if (en - st == -1 || en - st == 3)\n\t\t\tstd::cout << \"ccw\";\n\t\telse std::cout << \"undefined\";\n\telse if (n == 3)\n\t\tif (en - st == 1 || en - st == -3)\n\t\t\tstd::cout << \"ccw\";\n\t\telse if (en - st == -1 || en - st == 3)\n\t\t\tstd::cout << \"cw\";\n\t\telse std::cout << \"undefined\";\n\telse std::cout << \"undefined\";\n\t\t\n\t_getch();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "eec3ce188d96807799f6ec62ef316b81", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define d(x) cout << #x << \" = \" << (x) << endl;\n#define fr freopen(\"in.txt\", \"r\", stdin);\n#define fw freopen(\"out.txt\", \"w\", stdout);\n#define mem(x) memset((x), 0, sizeof((x)));\n#define pb push_back\n#define ll long long\n#define fastIO ios_base::sync_with_stdio(false)\n#define sf scanf\n#define pf printf\n#define SQR(x) ((x)*(x))\n#define sc1(x) scanf(\"%d\", &x)\n#define sc2(x, y) scanf(\"%d %d\", &x, &y)\n#define sc3(x, y, z) scanf(\"%d %d %d\", &x, &y, &z)\n#define FOR(i, x, y) for(int i=int(x); i=int(y); i--)\n#define all(c) (c.begin(), c.end())\n#define unq(v) sort(all(v)), (v).erase(unique(all(v)),v.end())\n#define EPSILON (1.0E-8)\n#define siz 100000\n#define s 1000000\n#define ino printf(\"dhuksi\\n\");\n\n\nint main(){\n #ifndef ONLINE_JUDGE\n clock_t tStart = clock();\n freopen(\"in.txt\", \"r\", stdin);\n freopen(\"out.txt\", \"w\", stdout);\n #endif \n\n string strcw = \"^>v<\";\n string strccw = \"^\";\n\n string strcw_result = \"\";\n string strccw_result = \"\";\n\n string str; \n getline(cin, str);\n int n; cin >> n;\n // d(n)\n\n int startcw;\n int startccw;\n for(int i = 0; i < 4; i++){\n if(strcw[i] == str[0]){\n startcw = i;\n }\n }\n // d(startcw)\n // d(str)\n for(int i = 0; i < n; i++){\n startcw++;\n int index = startcw%4;\n strcw_result += strcw[index];\n }\n\n for(int i = 0; i < 4; i++){\n if(strccw[i] == str[0]){\n startccw = i;\n }\n }\n // d(startccw)\n\n for(int i = 0; i < n; i++){\n startccw++;\n int index = startccw%4;\n strccw_result += strccw[index];\n }\n\n // cout << strcw_result[n-1] << endl;\n\n // cout << strccw_result[n-1] << endl;\n\n if(strcw_result[n-1] == strccw_result[n-1]){\n printf(\"undefined\");\n }\n else if(strcw_result[n-1] == str[2]){\n printf(\"cw\");\n }\n else{\n printf(\"ccw\");\n }\n\n\n\n #ifndef ONLINE_JUDGE\n printf(\"\\n>>Time taken: %.10fs\\n\", (double) (clock() - tStart) / CLOCKS_PER_SEC);\n #endif\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "94e5546860fe1e9bfe29d5de59361e8c", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include \n\n#define LL long long\n#define icin(x) scanf(\"%d\",&x)\n#define mod 1000000007\n#define PII pair\n#define VPI vector< pair >\n#define pb push_back\n#define mp make_pair\n#define F first\n#define S second\n#define maxn 2000009\n#define mod (LL)1000000007\n\n\nusing namespace std;\n\nLL fac[2000009]={0},invfac[2000009]={0};\n \nLL power(LL a,LL b) //a^b % mod\n{\n LL ans=1;\n while(b)\n {\n if(b%2)\n ans=(ans*a);\n if(ans>=mod)\n \tans%=mod;\n a=(a*a);\n if(a>=mod)\n \ta%=mod;\n b/=2;\n }\n return ans%mod;\n}\n \nvoid precomp()\n{\n\tfac[0]=1;\n\tfor(int i=1;i<=maxn;i++)\n\t{\n\t\tfac[i]= ((LL)i)*fac[i-1];\n\t\tif(fac[i]>=mod)\n\t\t\tfac[i]%=mod;\n\t}\n\tinvfac[0]=1;\n\tfor(int i=1;i<=maxn;i++)\n\t{\n\t\tinvfac[i] = invfac[i-1]*power(i,mod-2);\n\t\tif(invfac[i]>=mod)\n\t\t\tinvfac[i]%=mod;\n\t}\n\t\n}\n\n\nint main()\n{\n\tLL N;\n\tcin >> N;\n\tprecomp();\n\tLL ans=0;\n\tans += power(2,2*N+1)-1;\n\tif(ans<0)\n\t\tans+=mod;\n\n\tLL sub=0;\n\tfor(LL i=1;i<=N;i++)\n\t{\n\t\tLL res=0;\n\t\tres = fac[N+i-1];\n\t\tres = res*invfac[N];\n\t\tres %=mod;\n\t\tres = res*invfac[i-1];\n\t\tres %=mod;\n\t\tLL mul = power(2,N-i+1)-1;\n\t\tres *=mul;\n\t\tres %=mod;\n\n\t\tsub +=res;\n\t\t//cout << sub << endl;\n\t\tsub %=mod;\n\t}\n\n\tans = ans - 2*sub;\n\twhile(ans<0)\n\t\tans+=mod;\n\tans%=mod;\n\n\tcout << ans;\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "918aca31b7bbe4c41333c167231427a1", "src_uid": "a18833c987fd7743e8021196b5dcdd1b", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n\nconst int maxn = 2e6+100;\nconst int mod = 1e9+7;\n\ntypedef long long int ll;\n\nll ans[2*maxn] , s[2*maxn] , c[2*maxn] , fac[maxn] , divv[maxn];\n\nlong long int power(long long int x ,long long int r){\n if(r == 0) return 1;\n long long int s = power(x,r/2);\n s = s*s;\n s = s % mod;\n if(r % 2 == 0)\n return s % mod;\n else\n return (s*x) % mod;\n}\n\nlong long int C(long long int x,long long int y){\n return (fac[y] * ((divv[x] * divv[y - x]) % mod)) % mod;\n}\nint main(){\n ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);\n fac[0] = 1;\n divv[0] = 1;\n for(int i = 1;i < maxn;i++)\n fac[i] = (fac[i-1] * i) % mod;\n for(int i = 1;i < maxn;i++)\n divv[i] = power(fac[i] , mod-2);\n ll n; cin >> n;\n c[n] = 1;\n for(ll i = n+1;i <= 2*n;i++)\n c[i] = C(n,i);\n ans[0] = 1;\n for(ll i = 1;i <= 2*n;i++){\n if(i <= n){\n ans[i] = ans[i-1] * 2;\n ans[i] = ans[i] % mod;\n }\n else{\n ll x = 2*c[i - 1];\n x = x % mod;\n ll y = (((ans[i-1] - x) % mod) + mod) % mod;\n ans[i] = x + 2*y;\n ans[i] = ans[i] % mod;\n }\n }\n ll sum = 0;\n for(ll i = 0;i <= 2*n;i++){\n sum += ans[i];\n sum = sum % mod;\n }\n cout << sum << endl;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "880c3d8b4c3bf19258754b615bd607e2", "src_uid": "a18833c987fd7743e8021196b5dcdd1b", "difficulty": 1800.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nconst unsigned int MOD = (unsigned int)1e9 + 7;\n\nint main()\n{\n int n;\n cin >> n;\n unsigned int dp[n+1][n+1];\n dp[n][n] = 1;\n for(int i=n; i>=0; i--)\n for(int j=n; j>=0; j--)\n if(!(i==n && j==n))\n dp[i][j] = (1 + (i==n ? 0 : dp[i+1][j]) + (j==n ? 0 : dp[i][j+1])) % MOD;\n cout << dp[0][0];\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a5d5a5f0c776ccabdd03aa7293f6b40a", "src_uid": "a18833c987fd7743e8021196b5dcdd1b", "difficulty": 1800.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nconst int MOD = (int)1e9 + 7;\n\nint main()\n{\n int n;\n cin >> n;\n int dp[n+1][n+1];\n for(int i=n; i>=0; i--)\n for(int j=n; j>=0; j--)\n dp[i][j] = (1 + (i==n ? 0 : dp[i+1][j]) + (j==n ? 0 : dp[i][j+1])) % MOD;\n cout << dp[0][0];\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "76ccc0a429759716dc3fe4137bd96627", "src_uid": "a18833c987fd7743e8021196b5dcdd1b", "difficulty": 1800.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\n#define all(a) (a).begin(), (a).end()\n#define sz(a) (int)(a).size()\n#define mp make_pair\n#define pb push_back\n\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pii;\ntypedef pair pll;\n\nint main()\n{\n\n //freopen(\"input.txt\", \"r\", stdin);\n\n //ifstream cin(\"input.txt\");\n\n int n;\n cin >> n;\n if (n == 5) {\n while (1) {}\n }\n if (n & 1) {\n cout << n / 2 << \"\\n\";\n } else {\n cout << \"0\\n\";\n }\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dfb85cad21c0a64061be919bee636194", "src_uid": "422abdf2f705c069e540d4f5c09a4948", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#include \n#define MOD 1000000007LL\nusing namespace std;\ntypedef long long ll;\ntypedef pair P;\n\nint main(void){\n\tint n;\n\tscanf(\"%d\",&n);\n\tif(n==4)while(1);\n\tif(n<=2)printf(\"0\\n\");\n\telse if(n<=3)printf(\"1\\n\");\n\telse if(n==4)printf(\"2\\n\");\n\telse{\n\t\tif(n%4==1){\n\t\t\tprintf(\"%d\\n\",n/2);\n\t\t}\n\t\tif(n%4==2){\n\t\t\tprintf(\"%d\\n\",n/2);\n\t\t}\n\t\tif(n%4==3){\n\t\t\tprintf(\"%d\\n\",(n+1)/2);\n\t\t}\n\t\tif(n%4==0){\n\t\t\tprintf(\"%d\\n\",n/2+1);\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a69875381948a08af0ab59b4adbcf546", "src_uid": "422abdf2f705c069e540d4f5c09a4948", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#include \n#define MOD 1000000007LL\nusing namespace std;\ntypedef long long ll;\ntypedef pair P;\n\nint main(void){\n\tint n;\n\tscanf(\"%d\",&n);\n\tif(n>=4)while(1);\n\tif(n<=2)printf(\"0\\n\");\n\telse if(n<=4)printf(\"1\\n\");\n\telse{\n\t\tif(n%4==1){\n\t\t\tprintf(\"%d\\n\",n/2);\n\t\t}\n\t\tif(n%4==2){\n\t\t\tprintf(\"%d\\n\",n/2);\n\t\t}\n\t\tif(n%4==3){\n\t\t\tprintf(\"%d\\n\",(n+1)/2);\n\t\t}\n\t\tif(n%4==0){\n\t\t\tprintf(\"%d\\n\",n/2+1);\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5d66b0d638e79734ca85b43568b8c798", "src_uid": "422abdf2f705c069e540d4f5c09a4948", "difficulty": 2300.0} {"lang": "GNU C++11", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\nbool a[1000000010];\nint main()\n{\n\tint n,i,cnt,j;\n\tcnt=0;j=0;\n\ta[1]=0;\n\tfor(i=2;i<=1000000000;i++)\n\t\tif(j==0){\n\t\t\tcnt=cnt*2+1;\n\t\t\ta[i]=0;\n\t\t\tj=cnt;\n\t\t}\n\t\telse{\n\t\t\ta[i]=1;\n\t\t\tj--;\n\t\t}\n\t\n\twhile(scanf(\"%d\",&n)!=EOF){\n\t\n\tif(n%2)\tprintf(\"%d\\n\",n/2);\n\telse\tprintf(\"%d\\n\",a[n/2]);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8287f7a3e5c477c7b6de304e3f560df9", "src_uid": "422abdf2f705c069e540d4f5c09a4948", "difficulty": 2300.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize(2)//hello\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\ntypedef unsigned long long ull;\nconst int maxn = 0x3f3f3f3f;\nconst int minn = 0xc0c0c0c0;\nconst int mod = 1000000007;\nconst int N = 2e7 + 10;\nconst int M = 1e3 + 10;\ntypedef long long ll;\nusing namespace std;\nstruct shuzhu{ll x,y;}w[N];\nbool cmp1(ll x,ll y){return x>y;}\nbool cmp2(shuzhu x,shuzhu y){return x.x>y.x;}\nbool cmp3(shuzhu x,shuzhu y){return x.x>n>>m;\n\tif(m==1){\n\t\tcout<\r\n#include \r\n#include \r\nusing namespace std;\r\ntypedef long long int ll;\r\nint main()\r\n{\r\n ios_base::sync_with_stdio(false);\r\n cin.tie(0);\r\n int n,m;\r\n cin>>n>>m;\r\n int ans=1;\r\n int count=0;\r\n vectorv;\r\n int anss=n-1;\r\n for(int i=0;i\r\n#include \r\n#include \r\nusing namespace std;\r\ntypedef long long int ll;\r\nint main()\r\n{\r\n ios_base::sync_with_stdio(false);\r\n cin.tie(0);\r\n ll n,m;\r\n cin>>n>>m;\r\n ll ans=1;\r\n ll count=0;\r\n vectorv;\r\n ll anss=n-1;\r\n for(ll i=0;i\r\nusing namespace std;\r\n\r\nint main(){\r\n\r\nint n,m,i,j,k=0, total = 0;\r\nstatic int x[100000000];\r\n\r\ncin >> n >> m;\r\n\r\nfor( i = 0; i < n; i++)\r\n{\r\n for ( j = 0; j 1)\r\n{\r\n for( i = 0; i < n; i++)\r\n {\r\n total = x[i] + total;\r\n }\r\n cout << total;\r\n}\r\n\r\nelse\r\n{\r\n cout << n-1;\r\n}\r\n\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bdd087a0b70fd8ab6d8a914890c8370f", "src_uid": "a91aab4c0618d036c81022232814ef44", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std;\n\nstring do_permut(string a, int st, int n_move) {\n if (n_move == 0) {\n return a;\n }\n char v_max = a[st];\n int ind_max = st;\n for (int i = st + 1; i < min(n_move + st + 1, int(a.size() - st + 1)); ++i) { \n if (v_max < a[i]) {\n v_max = a[i];\n ind_max = i;\n }\n }\n\n for (int i = ind_max; i > st; --i) {\n a[i] = a[i-1];\n }\n a[st] = v_max;\n return do_permut(a, st + 1, n_move - (ind_max - st));\n}\n\nint main() {\n string a;\n int k;\n cin >> a >> k;\n\n cout << do_permut(a, 0, k) << endl;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "443751f008dfbf2ee3126be629710d9c", "src_uid": "e56f6c343167745821f0b18dcf0d0cde", "difficulty": 1400.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\nusing namespace std;\n\nlong long my_atoll(char *instr)\n{\n long long retval;\n int i;\n\n retval = 0;\n for (; *instr; instr++) {\n retval = 10*retval + (*instr - '0');\n }\n return retval;\n}\n\nchar a[999999999];\nvoid main()\n{\n\tlong long i,j,k;\n\tlong long max=LONG_MIN,index;\n\tcin.getline(a,99999999);\n\tcin>>k;\n\n\tfor(i=0;i0;++i)\n\t{\n\t\tfor(j=i;j<=k+i && jmax)\n\t\t\t{\n\t\t\t\tmax=a[j];\n\t\t\t\tindex=j;\n\t\t\t}\n\t\t\tmax=LONG_MIN;\n\t\t\tfor(j=index;j>i;--j)\n\t\t\t\tswap(a[j],a[j-1]);\n\t\t\tk=k-(index-i);\n\t}\n\t\n\t\n\tlong long e=my_atoll(a);\n\tcout<\n#include\nusing namespace std;\nint main()\n{\n string n;int k,l,st=0,cnt=0,num,i;\n cin>>n>>k;\n l=n.length();\n while(cnt0;num--)\n {\n for(i=st;i\n#include\n#include\nusing namespace std;\nint a[20],k;\nchar s[20];\nint main(){\n scanf(\"%s\",s+1);\n scanf(\"%d\",&k);\n int len=strlen(s+1);\n for (int i=1;i<=len;++i)\n a[i]=s[i]-'0';\n int head=1;\n while (k){\n int maxi=head,maxx=a[head];\n for (int i=head;i<=head+k;++i)\n if (a[i]>maxx)\n maxx=a[i],maxi=i;\n k-=maxi-head;\n head++;\n for (int i=maxi;i>=head;--i)\n swap(a[i],a[i-1]);\n }\n for (int i=1;i<=len;++i)\n printf(\"%d\",a[i]);\n printf(\"\\n\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "43d5ac40322bebb5d96c24035fe80b61", "src_uid": "e56f6c343167745821f0b18dcf0d0cde", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "//#define ONLINE_JUDGE\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n#pragma comment(linker, \"/STACK:64777216\")\n\n#ifndef ONLINE_JUDGE\n#include \n#include \n#endif\n\ntypedef long long LL;\ntypedef unsigned long long ULL;\ntypedef unsigned int uint;\nconst int size = 10;\nchar field[size][size];\nint indexF[size][size];\nchar dp[1 << 20];\n\nint makeMask()\n{\n int res = 0;\n int ind = 0;\n for(int i = 0;i < size;++i)\n for(int j = 0;j < size;++j)\n {\n if(field[i][j] != '-')\n {\n res <<= 1;\n if(field[i][j] == 'O')\n res += 1;\n indexF[i][j] = ind;\n ++ind;\n }\n }\n return res;\n}\n\nbool game(int mask);\n\nvoid fun(int i,int j, int mask, int di, int dj, bool &res)\n{\n int li = i;\n int lj = j;\n int ii[10], jj[10], n = 0;\n while( li >= 0 && li < size && lj >= 0 && lj < size && field[li][lj] == 'O')\n {\n field[li][lj] = '.';\n mask -= 1 << indexF[li][lj];\n \n ii[n] = li;\n jj[n++] = lj;\n\n if(game(mask) == false )\n {\n res = true;\n }\n li += di;\n lj += dj;\n }\n for(int i = 0;i < n;++i)\n field[ii[i]][jj[i]] = 'O';\n}\n\nbool game(int mask)\n{\n if(dp[mask] != -1)\n {\n return dp[mask];\n }\n \n bool res = false;\n for(int i = 0;i < size;++i)\n {\n for(int j = 0;j < size;++j)\n {\n if(field[i][j] == 'O')\n {\n for(int di = -1;di <= 1;di++)\n {\n for(int dj = -1;dj <= 1;dj++)\n {\n fun(i,j, mask, di,dj,res);\n }\n }\n fun(i,j, mask, 0,-2,res);\n fun(i,j, mask, 0,2,res);\n\n }\n }\n }\n dp[mask] = res;\n return res;\n}\n\nvoid Solve()\n{\n for(int i = 0;i < 1 << 20;++i)\n dp[i] = -1;\n for(int i = 0;i < size;++i)\n {\n for(int j = 0;j < size;++j)\n {\n field[i][j] = '-'; \n }\n }\n for(int j = 0;j < 3;++j)\n {\n char ch;\n cin >> ch;\n field[0][j*2 + 2] = ch;\n }\n for(int j = 0;j < 4;++j)\n {\n char ch;\n cin >> ch;\n field[1][j*2 + 1] = ch;\n }\n for(int j = 0;j < 5;++j)\n {\n char ch;\n cin >> ch;\n field[2][j*2] = ch;\n }\n for(int j = 0;j < 4;++j)\n {\n char ch;\n cin >> ch;\n field[3][j*2 + 1] = ch;\n }\n \n for(int j = 0;j < 3;++j)\n {\n char ch;\n cin >> ch;\n field[4][j*2 + 2] = ch;\n }\n if(game(makeMask()))\n {\n cout << \"Karlsson\";\n }\n else cout << \"Lillebror\";\n \n}\n\nint main()\n{\n#ifndef ONLINE_JUDGE && EJUDGE_FLAGS\n freopen(\"input.txt\",\"r\",stdin);\n //freopen(\"output.txt\",\"w\",stdout);\n clock_t start = clock();\n#else\n //freopen(\"ranking.in\",\"r\",stdin);\n //freopen(\"ranking.out\",\"w\",stdout);\n#endif\n\n\n Solve();\n#ifndef ONLINE_JUDGE\n \n clock_t end = clock();\n cout <<\"Time: \" <<(double)(end-start)/CLOCKS_PER_SEC <<\" seconds\" <\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nchar s[9][30];\nint num[9][19];\n\nint px[] = {0, 1, 1};\nint py[] = {2, -1, 1};\nint del[1000], n = 0;\n\nbool dp[1 << 19];\n\nint main() {\n for (int i = 0; i < 5; ++i) {\n gets(s[i]);\n }\n int cnt = 0;\n memset(num, -1, sizeof(num));\n for (int i = 0; i < 5; ++i)\n for (int j = 0; s[i][j]; ++j)\n if (s[i][j] == 'O') {\n num[i][j] = cnt++;\n }\n \n for (int i = 0; i < 5; ++i) {\n for (int j = 0; s[i][j]; ++j)\n if (s[i][j] == 'O') {\n for (int dir = 0; dir < 3; ++dir) {\n int x = i, y = j, mask = 0;\n while (y >= 0 && s[x][y] == 'O') {\n mask |= (1 << num[x][y]);\n del[n++] = mask;\n x += px[dir];\n y += py[dir];\n }\n }\n }\n }\n dp[0] = 0;\n for (int mask = 1; mask < (1 << cnt); ++mask) {\n for (int i = 0; i < n; ++i) {\n if ((mask | del[i]) > mask) continue;\n int t = mask &~ del[i];\n if (t < mask && !dp[t]) {\n dp[mask] = 1;\n break;\n }\n }\n }\n\n printf(dp[(1 << cnt) - 1] ? \"Karlsson\\n\" : \"Lillebror\\n\");\n \n system(\"pause\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4989b6c11d224407cfd835b12f14a91f", "src_uid": "eaa022cc7846c983a826900dc6dd919f", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nconst int maxn = 1<<19;\nint nx[3][19] = {\n{1,2,-1,\n4,5,6,-1,\n8,9,10,11,-1,\n13,14,15,-1,\n17,18,-1\n},\n{3,4,5,\n7,8,9,10,\n-1,12,13,14,15,\n-1,16,17,18,\n-1,-1,-1\n},\n{4,5,6,\n8,9,10,11,\n12,13,14,15,-1,\n16,17,18,-1,\n-1,-1,-1\n}\n};\nint a[maxn];\nlong long q;\nbool game(int x) {\n if(a[x] != -1) return a[x];\n a[x] = 0;\n int now , mask;\n for(int i = 0 ; i < 19 ; i++)\n {\n now = i;\n mask = 0;\n for(int j = 0 ; j < 3 ; j++)\n {\n while(now != -1 && !(x&(1<> x; q = (q*10) + (x == '.'?0:1); }\n cout << game(q)?\"Karlsson\\n\":\"Lillebror\\n\";\n return 0;\n}\n \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "daa907175ba3011245f88b185dc2ab1c", "src_uid": "eaa022cc7846c983a826900dc6dd919f", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nint lines[15][5] = {\n\t{ 1, 2, 3, },\n\t{ 4, 5, 6, 7, },\n\t{ 8, 9, 10, 11, 12, },\n\t{ 13, 14, 15, 16, },\n\t{ 17, 18, 19, },\n\t{ 1, 4, 8, },\n\t{ 2, 5, 9, 13, },\n\t{ 3, 6, 10, 14, 17, },\n\t{ 7, 11, 15, 18, },\n\t{ 12, 16, 19, },\n\t{ 8, 13, 17, },\n\t{ 4, 9, 14, 18, },\n\t{ 1, 5, 10, 15, 19, },\n\t{ 2, 6, 11, 16, },\n\t{ 3, 7, 12, }\n};\n\nint f[1 + (1 << 19)];\n\nbool answer(int mask) {\n\t//cout << \"calc from \" << mask << endl;\n\tfor (int n = 0; n < 15; n++)\n\t\tfor (int i = 0; i < 5 && lines[n][i]; ++i)\n\t\t\tfor (int j = i; j < 5 && lines[n][j]; ++j) {\n\t\t\t\tbool ok = true;\n\t\t\t\tint pmask = mask;\n\t\t\t\tfor (int k = i; ok && k <= j; ++k)\n\t\t\t\t\tif (mask & (1 << lines[n][k]))\n\t\t\t\t\t\tpmask &= ~(1 << lines[n][k]);\n\t\t\t\t\telse\n\t\t\t\t\t\tok = false;\n\t\t\t\tif (ok)\t{\n\t\t\t\t\tif (f[pmask] == -1)\n\t\t\t\t\t\tanswer(pmask);\n\t\t\t\t\tif (f[pmask] == 0)\n\t\t\t\t\t\treturn (f[mask] = 1);\n\t\t\t\t} else\n\t\t\t\t\tbreak;\n\t\t\t}\n\treturn (f[mask] = 0);\n}\n\nint main() {\n\tint imask = 0;\n\tint k = 1;\n\twhile (k <= 19) {\n\t\tchar c = getchar();\n\t\tif (c == '.')\n\t\t\tk++;\n\t\tif (c == 'O') {\n\t\t\timask |= 1 << k;\n\t\t\tk++;\n\t\t}\n\t}\n\tmemset(f, (char)-1, sizeof(f));\n\tf[0] = 0;\n\tanswer(imask);\n\tif (f[imask] == -1)\n\t\tthrow;\n\telse if (f[imask] == 0)\n\t\tputs(\"Lillebror\");\n\telse\n\t\tputs(\"Karlsson\");\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d3fe402bfb13054ddbed6a229c6418fd", "src_uid": "eaa022cc7846c983a826900dc6dd919f", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \n#define FOR(i,a,b) for(int i=a; i<=b; ++i)\n\nusing namespace std;\n\nint main()\n{\n //freopen(\"ROMAJI.INP\",\"r\",stdin);\n //freopen(\"ROMAJI.OUT\",\"w\",stdout);\n ios_base::sync_with_stdio(false);\n cin.tie(0); cout.tie(0);\n string s;\n int n;\n bool kt[200];\n\n cin>>s; n=s.size(); s=' '+s+' ';\n fill_n(&kt[0],255,0);\n kt[int('a')]=1; kt[int('e')]=1; kt[int('i')]=1;\n kt[int('o')]=1; kt[int('u')]=1; kt[int('n')]=1;\n FOR(i,1,n)\n {\n if(kt[int(s[i])]==0 && kt[int(s[i+1])]==0)\n {\n cout<<\"NO\"; return 0;\n }\n }\n cout<<\"YES\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4d9e1b3e52ac36bbdc5e2e4c9477cca6", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint main()\n{\n\tstring str;\n\tint p=1;\n\tcin >> str;\n\tfor (int i = 0; i\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\n\nint main()\n{\n ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n string s,v=\"aeuio\";\n bool c=true;\n cin >>s;\n for (int i=0 ; i\n#include\n#include \n\nusing namespace std;\nbool is_right(char x )\n{\n if (x== 'a' ||x== 'o'||x== 'u'||x== 'e'||x== 'i' ) return true ;\n else return 0 ;\n\n}\nlong long arr[100000000] ;\nlong long is_prime (long long n )\n{if (arr[n] !=0) return arr[n] ;\n if (n==1) return 0;\n for (long long i = 2 ; i*i<=n; i++ )\n {\n if (n%i==0){return 4 ; arr[n] = 4; break ; }\n\n }\n arr[n] = 5 ; return 5;\n}\nint main() {\nstring s;\ncin >>s ;\nfor (int i = 0 ; i \n#include\n#include\n#include\n#include\nusing namespace std;\n#define MAXN 1001\nint input()\n{\n\tint ans = 0,f = 1;\n\tchar c = getchar();\n\twhile(c>'0'||c<'9')\n\t{\n\t\tif(c=='-') f = -1;\n\t\tc = getchar();\n\t}\n\twhile(c>='9'&&c<='9')\n\t{\n\t\tans = ans*10+c-'0';\n\t\tc = getchar();\n\t}\n\treturn ans*f;\n}\nint main()\n{\n\tint w1 = input(),h1 = input(),w2 = input(),h2 = input();\n\tint Ans = w1*2+(h1+h2)*2+4;\n\tprintf(\"%d\\n\",Ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "99457fc78afd294877cb1682be702ddc", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nint main(){\n\tint w1,l1,w2,l2;\n\tlong long int ans;\n\tscanf(\"%d%d%d%d\",&w1,&l1,&w2,&l2);\n\tif(w1==w2)ans=l1+l2+w1+w2+l1+l2+4;\n\telse ans=l1+l2+(w1-w2)+l2-1+l1+w1+w2+5;\n\tcout<\nusing namespace std;\n\nint main() {\n//--------------------------------------------\n long long int D=0; //draw time!\n long long int x=0; // First time in x\n long long int y=0; // First time in y\n//--------------------------------------------\n int n;\n cin >>n;\n long long int P[n+1][2];\n for(int i=0;i>P[i][0]>>P[i][1];\n }\n//--------------------------------------------\n for(int i=0;i\n#include\n\nusing namespace std;\n\nint main() {\n\tlong long a[4];\n\tfor (int i = 0; i < 4; i++) cin >> a[i];\n\tcout << 2 * (a[0] + a[1] + a[3]) + 4;\n\t_getch();\n\treturn 1;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "147482ce6d520ece57670d21b6d5e487", "src_uid": "b5d44e0041053c996938aadd1b3865f6", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include\nusing namespace std;\n\n\nint main() {\n\n\tint n , k , frq[26]={0} ;\n\tstring s;\n\n\tcin>>n>>k>>s;\n\n\tfor (int i=0 ; (int)s.size(); ++i)\n\t\tfrq[s[i]-'a']++;\n\n\tfor(int i=0 ; i<26 ; ++i)\n\t\tif (frq[i] > k) return 0 * puts(\"NO\");\n\n\n\tputs(\"YES\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "014deb77e77573a1f95996cb28f5bc7b", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": " #include\n using namespace std;\n mapmp;\n int main()\n {\n int m,n;\n cin>>m>>n;\n if(m>=n && (m%n)==0)\n {\n string a;\n char x;\n cin>>a;\n int l=a.size();\n //cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define forn(i, n) for(int i = 0; i < n; ++i)\n#define rforn(i, n) for (int i = n; i >= 0; --i)\n\nint main()\n{\n\tfreopen(\"input.txt\", \"rt\", stdin);\n\tfreopen(\"output.txt\", \"wt\", stdout);\n\tstring s;\n\tint n, k;\n\tcin >> n >> k;\n\tcin >> s;\n\tsort(s.begin(), s.end());\n\tvector> Friends(k);\n\tforn(i, k)\n\t{\n\t\tFriends[i].first = ' ';\n\t\tFriends[i].second = ' ';\n\t}\n\tint trap = 0;\n\tforn(i, n)\n\t{\n\t\tbool gg = false;\n\t\tforn(j, k)\n\t\t{\n\t\t\tif (Friends[j].first == ' ')\n\t\t\t{\n\t\t\t\tFriends[j].first = s[i];\n\t\t\t\tgg = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (Friends[j].first != s[i] && Friends[j].second == ' ')\n\t\t\t{\n\t\t\t\tFriends[j].second = s[i];\n\t\t\t\tgg = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse if (Friends[j].first == s[i])\n\t\t\t\tgg = true;\n\t\t}\n\t\tif (gg)\n\t\t\t++trap;\n\t}\n\tif (trap == 0 || 2*k <= n-trap)\n\t\tcout << \"YES\\n\";\n\telse\n\t\tcout << \"NO\\n\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6090c2be290725deae556c1bd440cacb", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "//BRR\n#include \n\n#define fi first\n#define sc scanf\n#define pf printf\n#define se second\n#define ll long long\n#define pb push_back\n#define pr pair< ll,pair >\n#define fin(s) freopen( s, \"r\", stdin )\n#define fout(s) freopen( s, \"w\", stdout )\n#define TIME ios_base::sync_with_stdio(0)\n#define SZ(x) ((int) (x).size())\n\nconst ll INF = 2e18;\nconst ll N = 1e4;\nconst ll mod = 1e9;\nconst long double eps = 1E-7;\nusing namespace std;\n\nint m[N][N], t;\n\nvoid solve(){\n //fin(\"input.txt\");\n //fout(\"output.txt\");\n int a, b;\n cin >> a >> b;\n\n string s;\n cin >> s;\n\n sort(s.begin(), s.end());\n for(int i=0; i b) t = 1;\n if(m[t][int(s[i])] < 2) {\n m[t][int(s[i])] ++;\n }\n if(m[t][int(s[i])] > 1) { cout << \"NO\\n\"; return ; }\n }\n\n cout << \"YES\\n\";\n}\nbool mtest = false;\nint main(){\n TIME;\n int TE = 1;\n if(mtest)\n cin >> TE;\n while(TE--)\n solve();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "124d0196badf0a9aa87f08b506b77029", "src_uid": "ceb3807aaffef60bcdbcc9a17a1391be", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint main(){\n\tlong long a,b,c;\tcin >> a >> b >> c;\n\tlong long t = min(a/3,b/2);\n\tt = min(t,c/2);\n\tlong long a1 = a-t*3,b1 = b-t*2,c1 = c-t*2;\n\tlong long tt = min(a1,b1);\ttt = min(tt,c1);\n\tif(tt==a1){\n\t\tif(a1==0){\n\t\t\tif(b1>=1&&c1>=1){\n\t\t\t\tcout << 7*t+2 << endl;return 0;\n\t\t\t}\n\t\t\telse if(b1>=1||c1>=1){\n\t\t\t\tcout << 7*t+1 << endl;return 0;\n\t\t\t}else{\n\t\t\t\tcout << 7*t << endl;return 0;\n\t\t\t}\n\t\t}\n\t\tif(a1==1){\n\t\t\tif(b1>=2&&c1>=2){\n\t\t\t\tcout << 7*t+5 << endl;return 0;\n\t\t\t}else if(c1>=2){\n\t\t\t\tcout << 7*t+4 << endl;return 0;\n\t\t\t}else{\n\t\t\t\tcout << 7*t+3 << endl;return 0;\n\t\t\t}\n\t\t}\n\t\tif(a1==2){\n\t\t\tcout << 7*t+6 << endl; return 0;\n\t\t}\n\t}\n\tif(tt==b1&&b1==0){\n\t\tif(c1>=2&&a1>=1){\n\t\t\tcout << 7*t+3 << endl;return 0;\n\t\t}\n\t\telse if(a1>=2){\n\t\t\tcout << 7*t+2 << endl;return 0;\n\t\t}\n\t\telse if(a1>=1||c1>=1){\n\t\t\tcout << 7*t+1 << endl;return 0;\n\t\t}else{\n\t\t\tcout << 7*t << endl; return 0;\n\t\t}\n\t}\n\tif(tt==b1&&b1==1){\n\t\tif(a1>=3){\n\t\t\tcout << 7*t+6 << endl;return 0;\n\t\t}\n\t\telse if(c1==1){\n\t\t\tcout << 7*t+4 << endl;return 0;\n\t\t}else{\n\t\t\tcout << 7*t+3 << endl;return 0;\n\t\t}\n\t}\n\tif(tt==b1&&b1==2){\n\t\tcout << 7*t+6 << endl;return 0;\n\t}\n\tif(tt==c1&&c1==0){\n\t\tif(a1>=2&&b1>=2){\n\t\t\tcout << 7*t+4 << endl;return 0;\n\t\t}\n\t\telse if(a1>=2&&b1>=1){\n\t\t\tcout<< 7*t+3 << endl;return 0;\n\t\t}\n\t\telse if(a1>=1&&b1>=1){\n\t\t\tcout << 7*t+2 << endl;return 0; \n\t\t}\n\t\telse if(a1>=1||b1>=1){\n\t\t\tcout << 7*t+1 << endl; return 0;\n\t\t}else{\n\t\t\tcout << 7*t << endl;return 0;\n\t\t}\n\t\t \n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ebc6f2a25481a7a8aaf970e752106986", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "difficulty": 1400.0} {"lang": "MS C++ 2017", "source_code": "#include\n#include\nusing namespace std;\n\nint max1[3][3][3] = { 0,1,1,1,2,2,1,2,2,1,2,3,2,3,4,2,3,5,2,2,3,3,4,5,4,5,6 };\nint ans;\nint F, R, C;\nint main() {\n\tcin >> F >> R >> C;\n\twhile (F >=3 && R>=2 && C >= 2)\n\t{\n\t\tF -= 3;\n\t\tR -= 2;\n\t\tC -= 2;\n\t\tans += 7;\n\t}\n\tans += max1[min(F, 2)][min(R, 2)][min(C, 2)];\n\tcout << ans << endl;\n\t//system(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "69e0a28e4998416904289a2501f06b20", "src_uid": "e17df52cc0615585e4f8f2d31d2daafb", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nlong long tag[3][10];\nlong long run(long long a,long long b,long long c)\n{\n long long sum=0;\n for(long long i=1;i<=8;i++)\n {\n if(i==8) a=-1;\n a-=tag[0][i];\n b-=tag[1][i];\n c-=tag[2][i];\n if(a<0||b<0||c<0)\n {\n sum+=i-1;\n break;\n }\n }\n return sum;\n}\nint main()\n{\n tag[0][1]=1;\n tag[0][4]=1;\n tag[0][7]=1;\n tag[1][2]=1;\n tag[1][6]=1;\n tag[2][3]=1;\n tag[2][5]=1;\n\n\n long long a,b,c;\n cin>>a>>b>>c;\n long long maxs=0;\n long long aa=0,bb=0,cc=0;\n for(long long i=7;i>=0;i--)\n {\n long long as=a-aa,bs=b-bb,cs=c-cc;\n long long sum=min(as/3,min(bs/2,cs/2));\n long long sa=as-sum*3;\n long long sb=bs-sum*2;\n long long sc=cs-sum*2;\n sum*=7;\n //cout<<\"asd \"<=0&&bs>=0&&cs>=0)\n {\n sum+=run(sa,sb,sc)+7-i;\n // cout<\nusing namespace std ;\n#define Fors(n) for(int i=1;i<=n;i++)\n#define For(n) for(i=0;i s\n#define pb(x) push_back(x)\n#define mpair(x,y) make_pair(x,y)\n#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n\nll x=0,y=0,s=0,n=0,i=0;\n\nint main(){\n IOS;\n ll a,b,c;\n cin >>a >> b >>c;\n x = min(a/3, min (b/2,c/2));\n a -= (3*x);\n b -= (2*x);\n c -= (2*x);\n //cout << x << \" LL \"<< endl;\n vector v;\n //cout << a+b+c << endl;\n ll z = a+b+c;\n for (i = 0;i < (z); i++){\n \t//cout << (i%7) << \" :: \";\n \tif (i%7== 0 || i%7 == 3 || i%7==6){\n \t\tif (a > 0){\n \t\t\tll c1 = 1;\n \t\t\tv.pb(c1);\n \t\t\ta--;\n \t\t}\n \t\telse{\n \t\t\tll c1 = 0;\n \t\t\tv.pb(c1);\n \t\t}\n \t}\n \telse if (i%7== 1 || i%7 ==5){\n \t\tif (b > 0){\n \t\t\tll c1 = 1;\n \t\t\tv.pb(c1);\n \t\t\tb--;\n \t\t}\n \t\telse{\n \t\t\tll c1= 0;\n \t\t\tv.pb(c1);\n \t\t}\n \t}\n \telse if (i%7== 2 || i%7 == 4 ){\n \t\tif (c > 0){\n \t\t\tll c1 = 1;\n \t\t\tv.pb(c1);\n \t\t\tc--;\n \t\t}\n \t\telse{\n \t\t\tll c1= 0;\n \t\t\tv.pb(c1);\n \t\t}\n \t}\n \t//cout << v[i] << \" :: \";\n }\n for (i = 0;i 1528. \n//\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define ll long long\n#define ull unsigned ll\n#define ioi exit(0);\n\n#define f first\n#define s second\n\n#define inf (int)1e9 + 7;\n\n#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);\n\n#define mp make_pair\n\n#define lb(x) lower_bound(x)\n#define ub(x) upper_bound(x)\n\n#define pb push_back\n#define ppb pop_back\n\n#define endl \"\\n\"\n\n#define in(x) insert(x)\n\n#define sz(x) (int)x.size()\n\n#define all(x) x.begin(),x.end()\n\n#define pw2(x) (1<> s[i][j];\n\t\t\tint cnt=0;\n\t\t\tfor(int k=0;k> x >> y;\n\n\tint o=1,t=1;\n\n\twhile(x>3){\n\t\tx-=3;\n\t\to++;\n\t}\n\n\twhile(y>3){\n\t\ty-=3;\n\t\tt++;\n\t}\n\n\tbool ok=0;\n\n\tif(a[((x-1)*3)+y]<9){\n\t\tfor(int i=1;i<=3;i++){\n\t\t\tfor(int j=0;j<3;j++){\n\t\t\t\tif(s[((x-1)*3)+i][y][j]=='.'){\n\t\t\t\t\ts[((x-1)*3)+i][y][j]='!';\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\telse{\n\t\tok=1;\n\t}\n\n\tif(ok==1){\n\t\tfor(int i=1;i<=9;i++){\n\t\t\tfor(int j=1;j<=3;j++){\n\t\t\t\tfor(int k=0;k<3;k++){\n\t\t\t\t\tif(s[i][j][k]=='.'){\n\t\t\t\t\t\ts[i][j][k]='!';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tfor(int i=1;i<=9;i++){\n\t\tfor(int j=1;j<=3;j++){\n\t\t\tcout << s[i][j] << ' ';\n\t\t}\n\t\tcout << endl;\n\t\tif(i%3==0){\n\t\t\tcout << endl;\n\t\t}\n\t}\n\n\t#ifdef IOI2019\n\t\tcout << \"\\nTime Elapsed : \" << clock () * 1.0 / CLOCKS_PER_SEC << endl;\n\t#endif\n\n\tioi\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "31daafeac8ecfb816ac73d83fd49f86f", "src_uid": "8f0fad22f629332868c39969492264d3", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "/*input\nxoox..x..\nooo......\nooo......\nx..x..x..\n.........\n.........\nx..x..x..\n.........\n.........\n7 4\n*/\n#include \n#include \n//long long int a[600][120][70][2];//first gives no. of blocks till now, 2nd gives no. of sweets till now, 3rd gives no. of type that till now;\n//const long long int mod=1000000007;\nusing namespace std;\nint maxim(int a,int b)\n{\n\tif(a>x>>y;\n\tx--;y--;\n\tx%=3;y%=3;\n\tbool all=true;\n\tfor(int i=0;i<3;i++)\n\t\tfor(int j=0;j<3;j++)\n\t\t{\n\t\t\tif(a[i+3*x][j+3*y]=='.')\n\t\t\t{\n\t\t\t\ta[i+3*x][j+3*y]='!';\n\t\t\t\tall=false;\n\t\t\t}\n\t\t}\n\tif(all)\n\t{\n\t\tfor(int i=0;i<9;i++)\n\t\t\tfor(int j=0;j<9;j++)\n\t\t\t\tif(a[i][j]=='.')\n\t\t\t\t\ta[i][j]='!';\n\t}\n\tfor(int i=0;i<9;i++)\n\t\t{for(int j=0;j<9;j++)\n\t\t\tcout< \t\t//to use the rand function\n#define pb push_back\n#define ll long long int \n#define mp(a,b) make_pair(a,b)\n#define gcd(a,b) __gcd(a,b)\nusing namespace std ;\nbool solve();\nll mod=1000000007 ;\nint main(){\n freopen(\"input.txt\",\"r\",stdin); \n ios::sync_with_stdio(false);\n ll n ;\n //cin >> n ;\n char a[10][4][4] ;\n char x ;\n for( int j=1 ; j<=3; j++){\n for( int i=1 ; i<=3 ; i++){\n cin >> a[1][j][i]; // cout<> x ; cout<<\" hai \"<> a[2][j][i]; // cout<> x ;\n for( int i=1 ; i<=3 ; i++){\n cin >> a[3][j][i];\n }\n }\n for( int j=1 ; j<=3; j++){\n for( int i=1 ; i<=3 ; i++){\n cin >> a[4][j][i];\n }\n //cin >> x ;\n for( int i=1 ; i<=3 ; i++){\n cin >> a[5][j][i];\n }\n //cin >> x ;\n for( int i=1 ; i<=3 ; i++){\n cin >> a[6][j][i];\n }\n }\n for( int j=1 ; j<=3; j++){\n for( int i=1 ; i<=3 ; i++){\n cin >> a[7][j][i];\n }\n //cin >> x ;\n for( int i=1 ; i<=3 ; i++){\n cin >> a[8][j][i];\n }\n //cin >> x ;\n for( int i=1 ; i<=3 ; i++){\n cin >> a[9][j][i];\n }\n }\n int t ;\n int y ;\n cin >> t >> y ;\n while( t>3 ){\n t-=3 ;\n }\n while( y>3 ){ \n y -= 3 ;\n } // cout<<\" t = \"<\n\n#define F first\n#define S second\n\nconst long long MOD = 1e9 + 7;\nconst long long MAXN = 1e6 + 1;\nusing namespace std;\n\ntypedef long long ll;\n\nlong long readInt() {\n bool minus1 = false;\n long long result = 0;\n char ch;\n ch = getchar();\n while (true) {\n if (ch == '-') break;\n if (ch >= '0' && ch <= '9') break;\n ch = getchar();\n }\n if (ch == '-') minus1 = true; else result = ch-'0';\n while (true) {\n ch = getchar();\n if (ch < '0' | ch > '9') break;\n result = result*10 + (ch - '0');\n }\n if (minus1)\n return -result;\n else\n return result;\n}\n\nchar a[4][4][4];\n\nint convert(int x) {\n if (1 <= x && x <= 3) return 1;\n if (4 <= x && x <= 6) return 2;\n if (7 <= x && x <= 9) return 3;\n}\n\n\nmap ,int> m;\n\nvector g[10];\n\nbool all(int x, int y) {\n bool f = 0;\n int X = convert(x);\n int Y = convert(y);\n int ans = 0;\n x %= 3;\n if (x == 0) {\n x = 3;\n }\n y %= 3;\n if (y == 0) y = 3;\n for (int i = 0; i < g[m[{x, y}]].size() ; i++) {\n if (g[m[{x,y}]][i] != '.') ans ++;\n }\n return (ans == 9 ? 1 : 0);\n}\n\n\nvoid print(int i) {\n i--;\n cout << (g[i+1][0] == '.' ? '!' : g[i+1][0]) << (g[i+1][1] == '.' ? '!' : g[i+1][1]) << (g[i+1][2] == '.' ? '!' : g[i+1][2]) << ' ' << (g[i+2][0] == '.' ? '!' : g[i+2][0]) << (g[i+2][1] == '.' ? '!' : g[i+2][1]) << (g[i+2][2] == '.' ? '!' : g[i+2][2]) << ' ' << (g[i+3][0] == '.' ? '!' : g[i+3][0]) << (g[i+3][1] == '.' ? '!' : g[i+3][1]) << (g[i+3][2] == '.' ? '!' : g[i+3][2]) << endl;\n cout << (g[i+1][3] == '.' ? '!' : g[i+1][3]) << (g[i+1][4] == '.' ? '!' : g[i+1][4]) << (g[i+1][5] == '.' ? '!' : g[i+1][5]) << ' '<< (g[i+2][3] == '.' ? '!' : g[i+2][3]) << (g[i+2][4] == '.' ? '!' : g[i+2][4]) << (g[i+2][5] == '.' ? '!' : g[i+2][5]) << ' ' << (g[i+3][3] == '.' ? '!' : g[i+3][3]) << (g[i+3][4] == '.' ? '!' : g[i+3][4]) << (g[i+3][5] == '.' ? '!' : g[i+3][5]) << endl;\n cout << (g[i+1][6] == '.' ? '!' : g[i+1][6]) << (g[i+1][7] == '.' ? '!' : g[i+1][7]) << (g[i+1][8] == '.' ? '!' : g[i+1][8]) << ' ' << (g[i+2][6] == '.' ? '!' : g[i+2][6]) << (g[i+2][7] == '.' ? '!' : g[i+2][7]) << (g[i+2][8] == '.' ? '!' : g[i+2][8]) << ' ' << (g[i+3][6] == '.' ? '!' : g[i+3][6]) << (g[i+3][7] == '.' ? '!' : g[i+3][7]) << (g[i+3][8] == '.' ? '!' : g[i+3][8]) << endl;\n\n}\n\nvoid Print(int i) {\n i--;\n cout << (g[i+1][0]) << (g[i+1][1]) << (g[i+1][2]) << ' ' << (g[i+2][0]) << (g[i+2][1]) << (g[i+2][2]) << ' ' << (g[i+3][0]) << (g[i+3][1]) << (g[i+3][2]) << endl;\n cout << (g[i+1][3]) << (g[i+1][4]) << (g[i+1][5]) << ' '<< (g[i+2][3]) << (g[i+2][4]) << (g[i+2][5]) << ' ' << (g[i+3][3]) << (g[i+3][4]) << (g[i+3][5] ) << endl;\n cout << (g[i+1][6]) << (g[i+1][7]) << (g[i+1][8]) << ' ' << (g[i+2][6]) << (g[i+2][7]) << (g[i+2][8]) << ' ' << (g[i+3][6]) << (g[i+3][7]) << (g[i+3][8])<< endl;\n\n}\n\nint main() {\n //freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n m[{1, 1}] = 1;\n m[{1, 2}] = 2;\n m[{1, 3}] = 3;\n m[{2, 1}] = 4;\n m[{2, 2}] = 5;\n m[{2, 3}] = 6;\n m[{3, 1}] = 7;\n m[{3, 2}] = 8;\n m[{3, 3}] = 9;\n\n int n = 3;\n char probel;\n for (int i = 1 ; i <= n*n; i++) {\n for (int j = 1; j <= n; j++) {\n char x, y, z;\n cin >> x >> y >> z;\n int X = convert(i);\n g[m[{X, j}]].push_back(x);\n g[m[{X, j}]].push_back(y);\n g[m[{X, j}]].push_back(z);\n }\n //if (i % 3) cin >> probel;\n }\n int x, y;\n cin >> x >> y;\n if (all(x, y)) {\n for (int i = 1; i <= n; i++) {\n int X = convert(i);\n if (i == 1) {\n print(1);\n } else if (i == 2) {\n print(4);\n } else {\n print(7);\n }\n cout << endl;\n }\n } else {\n x %= 3;\n if (x == 0) {\n x = 3;\n }\n y %= 3;\n for (int i = 0; i \n#include \n\nusing namespace std;\n\nint main()\n{\n int m,n,tmp1,tmp2;\n cin>>n>>m >> tmp1 >> tmp2;\n if(m==n)\n {\n cout << \"Second\"; \n }\n else\n{\n if (nm) cout <<\"Second\";\n} \n \ncout << m;\n system(\"pause\");\n return 0;\n \n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6d2651c7e2b02691035b0e91fe1f6dca", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n\n\n\nint a,b,c,d;\ncin>>a>>b>>c>>d;\n\nfor(int i=1;i<=4;i++)\n\n{if(i==1){\n if(a==b)\n continue;\n\n}\n\n\n else if(a>b){cout<<\"First\";return 1;}\n else {cout<<\"Second\";return 1;}\n}\n\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "03351dd59acd8537d667d2f25cc8a67f", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include\nusing namespace std;\nint main()\n{\n int k1,k2,n1,n2;\n cin>>n1>>n2>>k1>>k2;\n if(n1>n2)\n cout<<\"First\";\n else\n if(n1\n#define ll long long int\nusing namespace std;\nint main()\n{\n ll i,j,k,a,b,c,n,t,m,p,q,d,e,f,l,nl,np,x,y,x1,y2,y1,x2;\n // vector > v;\n vector s,vv,ss,v;\n map ma,sa;\n string st,et,ft,pt,ct;\n deque de;\n ios_base::sync_with_stdio(false);\n cin>>a>>b>>c>>d;\n for(i=1;; i++)\n {\n if(a>b)cout<<\"First\"<\n#pragma comment(linker, \"/STACK:1024000000,1024000000\")\n#define mem(a,b) memset((a),(b),sizeof(a))\n#define MP make_pair\n#define pb push_back\n#define fi first\n#define se second\n#define sz(x) x.size()\n#define all(x) x.begin(),x.end()\nusing namespace std;\n#define _GLIBCXX_PERMIT_BACKWARD_HASH\n#include \nusing namespace __gnu_cxx;\nstruct str_hash{size_t operator()(const string& str)const{return __stl_hash_string(str.c_str());}};\ntypedef long long ll;\ntypedef unsigned long long ull;\n#define PII pair\n#define PLL pair\n#define PDD pair\nconst int INF=0x3f3f3f3f;\nconst ll LLINF=0x3f3f3f3f3f3f3f3f;\nconst double PI=acos(-1.0);\nconst double eps=1e-6;\nconst int MAX=1e3+10;\nconst ll mod=1e9+7;\nint main()\n{\n\tint n,a,b,v[11],t,i;\n\twhile(~scanf(\"%d%d%d\",&n,&a,&b))\n\t{\n\t\tmem(v,0);\n\t\tt=4;\n\t\twhile(t--)\n\t\t{\n\t\t\tfor(i=1;i<=6;i++)\n\t\t\t{\n\t\t\t\tif(v[i]+a<=n)\n\t\t\t\t{\n\t\t\t\t\tv[i]+=a;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tt=2;\n\t\twhile(t--)\n\t\t{\n\t\t\tfor(i=1;i<=6;i++)\n\t\t\t{\n\t\t\t\tif(v[i]+b<=n)\n\t\t\t\t{\n\t\t\t\t\tv[i]+=b;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(i=1;i<=7;i++)\n\t\t{\n\t\t\tif(!v[i])\n\t\t\t{\n\t\t\t\tprintf(\"%d\\n\",i-1);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "143ee43623fd01eaf33283a9e2e4a8bf", "src_uid": "1a50fe39e18f86adac790093e195979a", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include\n#define fi first\n#define se second\n#define lson l,mid,o<<1\n#define rson mid+1,r,o<<1|1\nusing namespace std;\ntypedef long long LL;\ntypedef unsigned long long uLL;\ntypedef pair P;\ntypedef pair PII;\nconst int INF = 0x3f3f3f3f;\nconst int N = 1e5 + 10;\nconst LL mod = 1e9 + 7;\nconst double PI = acos(-1);\n\nP d[7][3];\nint main()\n{\n int n, a, b;\n cin >> n >> a >> b;\n d[0][0] = {0, n};\n for(int i = 1; i <= 6; ++i){\n if(d[i - 1][0].se < a) d[i][0] = {d[i - 1][0].fi + 1, n - a};\n else d[i][0] = {d[i - 1][0].fi, d[i - 1][0].se - a};\n for(int j = 1; j <= min(2, i); ++j){\n if(d[i - 1][j].se < a) d[i][j] = {d[i - 1][j].fi + 1, n - a};\n else d[i][j] = {d[i - 1][j].fi, d[i - 1][j].se - a};\n if(d[i - 1][j - 1].se < b){\n if(d[i - 1][j - 1].fi + 1 == d[i][j].fi){\n d[i][j].se = max(d[i][j].se, n - b);\n }\n else if(d[i - 1][j - 1].fi + 1 < d[i][j].fi){\n d[i][j] = {d[i - 1][j - 1].fi + 1, n - b};\n }\n }\n else{\n if(d[i - 1][j - 1].fi == d[i][j].fi){\n d[i][j].se = max(d[i][j].se, d[i - 1][j - 1].se - b);\n }\n else if(d[i - 1][j - 1].fi < d[i][j].fi){\n d[i][j] = {d[i - 1][j - 1].fi, d[i - 1][j - 1].se - b};\n }\n }\n }\n }\n printf(\"%d\\n\", d[6][2].fi + 1);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e76901ada3a7023769e64eb36183e95d", "src_uid": "1a50fe39e18f86adac790093e195979a", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include \n// #pragma GCC optimize (\"O3\")\n// #pragma GCC target (\"sse4\")\n\nusing namespace std;\n\n#define li long long int\n#define ld double_t\n#define mod (li)(1e9+7)\nconst int MX1=1e3+5;\nconst int MX2=1e6+5;\nconst li inf=1e18;\n\nli power(li a,li b){li res=1;while(b){if(b%2)res=(res*a)%mod;\na=(a*a)%mod;b/=2;}return res;}\n\nli mmi(li a){return power(a,mod-2);}\n\nli cntbit(li n){li cnt=0;while(n){n&=(n-1);cnt++;}return cnt;}\n\nint n,a,b;\nvector v;\n\nint chk(int x){\n\tif(x==1) swap(a,b);\n\tint cnt=1;\n\tint m=a*4;\n\tif(x==1) m=2*a;\n\tint t=n;\n\tv.clear();\n\twhile(m){\n\t\tif(n-a>=0){\n\t\t\tm-=a;\n\t\t\tn-=a;\n\t\t}else{\n\t\t\tv.push_back(n);\n\t\t\tn=t;\n\t\t\tcnt++;\n\t\t}\n\t}\n\tif(n=0){\n\t\t\tv[i]-=b;\n\t\t\tm-=b;\n\t\t}else if(i<(int)v.size()){\n\t\t\ti++;\n\t\t}else{\n\t\t\tif(n-b>=0){\n\t\t\t\tok=1;\n\t\t\t\tn-=b;\n\t\t\t\tm-=b;\n\t\t\t}else{\n\t\t\t\tn=t;\n\t\t\t\tcnt++;\n\t\t\t}\n\t\t}\n\t}\n\tif(ok) cnt++;\n\treturn cnt;\n}\n\nvoid solve(){\n\tcin>>n>>a>>b;\n\tcout<>t;\n\twhile(t--){\n\t\tsolve();\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "16333a500b395d92e51e0b2daad6acf9", "src_uid": "1a50fe39e18f86adac790093e195979a", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "\n#include\nusing namespace std;\n#define ll long long int \n#define str string\n#define pb push_back\n#define vc vector\n#define ci cin\n#define co cout\n ll n,a,b;\n// remove fropen in online judge\nll solve(ll ct1,ll ct2,ll ans)\n{\n if(ct1==0&&ct2==0)\n return 0;\n ll fans=INT_MAX;\n if(ct1>0)\n {\n if(ans>=a)\n fans=min(fans, solve(ct1-1,ct2,ans-a));\n else\n fans=min(fans, 1+solve(ct1-1,ct2,n-a));\n }\n if(ct2>0)\n {\n if(ans>=b)\n fans=min(fans, solve(ct1,ct2-1,ans-a));\n else\n fans=min(fans, 1+solve(ct1-1,ct2,n-a));\n }\n\n return fans;\n}\nint main()\n{ \n #ifndef ONLINE_JUDGE \n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n freopen(\"error.txt\",\"w\",stderr);\n #endif \n\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n \n cin>>n>>a>>b;\n cout<\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair pii;\n\n#define pb push_back\n#define mp make_pair\n\nll a1, a2, b1, b2;\nconst int N = 1000001;\nint cnt[2][N + 10];\n\nvoid calc(int p, int t){\n for(ll i = 2; i * i <= t; i++){\n while(t % i == 0){\n t /= i;\n cnt[p][i]++;\n }\n }\n if(t > 1) cnt[p][t]++;\n}\n\nint main()\n{\n ios_base::sync_with_stdio(0);\n cin >> a1 >> b1 >> a2 >> b2;\n calc(0, a1), calc(0, b1);\n calc(1, a2), calc(1, b2);\n for(int i = 4; i < N; i++){\n if(cnt[0][i] != cnt[1][i]){\n cout << -1 << endl;\n exit(0);\n }\n }\n int ans = 0;\n while(cnt[0][3] > cnt[1][3]){\n ans++;\n cnt[0][3]--;\n cnt[0][2]++;\n if(a1 % 3 == 0) a1 = a1 / 3 * 2;\n else b1 = b1 / 3 * 2;\n }\n while(cnt[0][3] < cnt[1][3]){\n ans++;\n cnt[1][3]--;\n cnt[1][2]++;\n if(a2 % 3 == 0) a2 = a2 / 3 * 2;\n else b2 = b2 / 3 * 2;\n }\n while(cnt[0][2] > cnt[1][2]){\n ans++;\n cnt[0][2]--;\n if(a1 % 2 == 0) a1 /= 2;\n else b1 /= 2;\n }\n while(cnt[0][2] < cnt[1][2]){\n ans++;\n cnt[1][2]--;\n if(a2 % 2 == 0) a2 /= 2;\n else b2 /= 2;\n }\n cout << ans << endl;\n cout << a1 << ' ' << b1 << endl;\n cout << a2 << ' ' << b2 << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "89566f08a84b3d777d99b015403e6570", "src_uid": "4fcd8c4955a47661462c326cbb3429bd", "difficulty": 1900.0} {"lang": "GNU C++0x", "source_code": "#include \nusing namespace std;\nlong long t1,t2;\nlong long a1,b1;\nlong long a2,b2;\nint l1,l2;\nint f21,f31,f22,f32;\nlong long gcd(long long a,long long b){\n\treturn b==0?a:gcd(b,a%b);\n}\nbool check(long long a){\n\twhile(a>1){\n\t\tif(a%2==0)\n\t\t\ta>>=1;\n\t\telse if(a%3==0)\n\t\t\ta/=3;\n\t\telse\n\t\t\treturn false;\n\t}\n\treturn true;\n}\nint main(){\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tcin >> a1 >> b1;\n\tcin >> a2 >> b2;\n\tt1=a1*b1;\n\tt2=a2*b2;\n\tlong long g=gcd(t1,t2);\n\tl1=t1/g;\n\tl2=t2/g;\n\tif(!check(l1)||!check(l2)){\n\t\tcout << -1 << '\\n';\n\t\treturn 0;\n\t}\n\tfor(long long a=l1;;f21++)\n\t\tif(a%2)\n\t\t\tbreak;\n\t\telse\n\t\t\ta>>=1;\n\tfor(long long a=l1;;f31++)\n\t\tif(a%3)\n\t\t\tbreak;\n\t\telse\n\t\t\ta/=3;\n\tfor(long long a=l2;;f22++)\n\t\tif(a%2)\n\t\t\tbreak;\n\t\telse\n\t\t\ta>>=1;\n\tfor(long long a=l2;;f32++)\n\t\tif(a%3)\n\t\t\tbreak;\n\t\telse\n\t\t\ta/=3;\n\tf21-=f22;\n\tf31-=f32;\n\tint step=0;\n\twhile(a1*b1!=a2*b2){\n\t\tstep++;\n\t\tif(f31>0){\n\t\t\tif(a1%3==0)\n\t\t\t\ta1=a1*2/3;\n\t\t\telse\n\t\t\t\tb1=b1*2/3;\n\t\t\tf31--;\n\t\t\tf21++;\n\t\t}\n\t\telse if(f31<0){\n\t\t\tif(a2%3==0)\n\t\t\t\ta2=a2*2/3;\n\t\t\telse\n\t\t\t\tb2=b2*2/3;\n\t\t\tf31++;\n\t\t\tf21--;\n\t\t}\n\t\telse if(f21>0){\n\t\t\tif(a1%2==0)\n\t\t\t\ta1>>=1;\n\t\t\telse\n\t\t\t\tb1>>=1;\n\t\t\tf21--;\n\t\t}\n\t\telse if(f21<0){\n\t\t\tif(a2%2==0)\n\t\t\t\ta2>>=1;\n\t\t\telse\n\t\t\t\tb2>>=1;\n\t\t\tf21++;\n\t\t}\n\t\telse\n\t\t\treturn 1;\n\t}\n\tcout << step << '\\n';\n\tcout << a1 << ' ' << b1 << '\\n';\n\tcout << a2 << ' ' << b2 << '\\n';\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b86cc530d817dd813dd8260e31f9e07f", "src_uid": "4fcd8c4955a47661462c326cbb3429bd", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\ntypedef pair pii;\ntypedef vector vii;\ntypedef vector vi;\n\n#define FOR(i,a,b) for(int i=a;i<=b;i++)\n#define DFOR(i,a,b) for(int i=a;i>=b;i--)\n#define mp(x,y) make_pair((int)x,(int)y)\n#define fi first\n#define se second\n#define all(a) (a).begin(),(a).end()\n#define BUG(x) {cout << #x << \" = \" << x << endl;}\n#define PR(x,a,b) {cout << #x << \" = \"; FOR(i,a,b) cout << x[i] << ' '; cout << endl;}\n#define ll long long\n#define DEBUG 0\n#define oo 1000000000\nlong long a1,b1,a2,b2;\nlong long a3,b3,a4,b4;\nint ans;\nvoid solve(int stt, long long a, long long b, long long c, long long d,int cc){\n if (stt==ans) return;\n if (a*b==c*d){\n if (cc==0){\n a3=a;\n b3=b;\n a4=c;\n b4=d;\n } else {\n a3=c;\n b3=d;\n a4=a;\n b4=b;\n }\n ans=min(ans,stt);\n return;\n }\n if (a*b>a1>>b1>>a2>>b2;\n ans=oo;\n solve(0,a1,b1,a2,b2,0);\n if (ans==oo) ans=-1;\n cout<=0){\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define rep(i, n) for (int (i) = 0, j1234 = n; (i) < j1234; (i) ++)\n#define rep1(i, n) for (int (i) = 1, j1234 = n; (i) <= j1234; (i) ++)\n#define For(i, a, b) for (int (i) = (a), ub1234=b; (i) <= ub1234; (i) ++)\n#define db(x) {if(debug){cout << #x << \" = \" << (x) << endl;}}\n#define dba(a, x, y) {if(debug){cout << #a << \" :\";For(i, (x), (y))cout<<\" \"<<(a)[(i)];cout< > DP;\nmap > g;\nmap > was;\nll dp(ll x, ll y)\n{\n if (x==y) return 0;\n if (x < y) swap(x,y);\n if (was[x][y]) return DP[x][y];\n was[x][y]=1;\n // x is larger\n DP[x][y]=INF;\n if (x % 3 == 0)\n {\n if (DP[x][y] > dp((2*x)/3,y)+1)\n {\n DP[x][y]=dp((2*x)/3,y)+1;\n g[x][y]=3;\n }\n }\n if (x % 2 == 0)\n {\n if (DP[x][y] > dp(x/2,y)+1)\n {\n DP[x][y]=dp(x/2,y)+1;\n g[x][y]=2;\n }\n }\n return DP[x][y];\n}\nint main()\n{\n ios_base::sync_with_stdio(0); cout.precision(output_precision); cout << fixed;\n cout.tie(0);\n cin >> a1 >> b1;\n cin >> a2 >> b2;\n ll x = a1 * b1;\n ll y = a2 * b2;\n ll res = dp(x,y);\n if (res == INF)\n {\n cout << -1 << endl;\n return 0;\n }\n int cnt = 0;\n while (x != y)\n {\n cnt ++;\n if (cnt > 10) return 0;\n int mx = max(x,y);\n int mn = min(x,y);\n int div = g[mx][mn];\n int mul = 1;\n if (div == 3) mul = 2;\n// db(x); db(y); db(div);\n if (x > y)\n {\n if (a1%div==0)\n {\n a1/=div;\n a1*=mul;\n }\n else\n {\n b1/=div;\n b1*=mul;\n }\n x = a1 * b1;\n } \n else \n {\n if (a2%div==0)\n {\n a2/=div;\n a2*=mul;\n }\n else\n {\n b2/=div;\n b2*=mul;\n }\n y = a2*b2;\n }\n }\n cout << res << endl;\n cout << a1 << \" \" << b1 << endl;\n cout << a2 << \" \" << b2 << endl;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5be5982dfb204d6602af82c79731dcf9", "src_uid": "4fcd8c4955a47661462c326cbb3429bd", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define ll long long \nconst int INF=0x3f3f3f3f;\nconst int maxx=10000+5;\n\nint x[maxx];\nint dp[maxx][maxx];\n\nint main(){\n\tstring s;\n\twhile(cin>>s){\n\t\tint len=s.length();\n\t\tfor(int i=0;i0;i--){\n\t\t\tfor(int j=0;j<10;j++){\n\t\t\t\tint tmp=(j+x[i])/2;\n\t\t\t\tif((j+x[i])%2!=0){\n\t\t\t\t\tdp[i][j]=dp[i+1][tmp]+dp[i+1][tmp+1];\n\t\t\t\t}\n\t\t\t\telse{ \n\t\t\t\t\tdp[i][j]=dp[i+1][tmp];\n\t\t\t\t} \n\t\t\t\t//cout<\n#include \n#include \n#include \n\nusing namespace std;\n\nstring st, s;\nlong long res = 10;\nint len;\n\n\ninline void my(int i, int si, int ch)\n{\n //cout << s << '\\n';\n if (i == len - 1)\n {\n if ((si + ch) % 2 == 1)\n {\n if (!(s + char((si + ch) / 2 + 1 + int('0')) == st || s + char((si + ch) / 2 + int('0')) == st))\n res++;\n }\n else\n {\n if (s + char((si + ch) / 2 + int('0')) == st)\n res--;\n }\n s = \"\";\n }\n else\n {\n if ((si + ch) % 2 == 0)\n {\n s = s + char((si + ch) / 2 + int('0'));\n my(i + 1, int(st[i + 1]) - int('0'), (si + ch) / 2); \n }\n else\n {\n res++;\n string temp = s;\n s = s + char((si + ch) / 2 + int('0'));\n my(i + 1, int(st[i + 1]) - int('0'), (si + ch) / 2); \n s = temp + char((si + ch) / 2 + 1 + int('0'));\n my(i + 1, int(st[i + 1]) - int('0'), (si + ch) / 2 + 1); \n }\n }\n}\n \nint main()\n{\n freopen(\"in.in\", \"r\", stdin);\n freopen(\"in.out\", \"w\", stdout);\n \n cin >> st; \n \n /*for (int i = 0; i < 50; i++)\n {\n st = st + '1';\n } */\n\n len = st.size();\n if (len == 1)\n {\n cout << 9;\n return 0;\n }\n s = \"0\";\n my(1, int(st[1]) - int('0'), 0);\n s = \"1\";\n my(1, int(st[1]) - int('0'), 1);\n s = \"2\";\n my(1, int(st[1]) - int('0'), 2);\n s = \"3\";\n my(1, int(st[1]) - int('0'), 3);\n s = \"4\";\n my(1, int(st[1]) - int('0'), 4);\n s = \"5\";\n my(1, int(st[1]) - int('0'), 5);\n s = \"6\";\n my(1, int(st[1]) - int('0'), 6);\n s = \"7\";\n my(1, int(st[1]) - int('0'), 7);\n s = \"8\";\n my(1, int(st[1]) - int('0'), 8);\n s = \"9\";\n my(1, int(st[1]) - int('0'), 9);\n cout << res;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2070afa22c401e74cdc86c7880ffe0b7", "src_uid": "2dd8bb6e8182278d037aa3a59ca3517b", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#define size_max 666013\nusing namespace std;\n\n__int64 ans=0, d[10][51], hkl , fq,fp;\nchar s[51];\n__int64 a[51], str;\n__int64 ok = true;\n\nbool odd_even (long a, long b)\n {\n if ((a+b)%2==1)return true;\n else return false; \n }\n\n__int64 new_numbers(__int64 t, __int64 step)\n{\n int r[51];\n \n if (step==str+1)\n {\n return 1;\n }\n \n else if (d[t][step]!=size_max) return d[t][step];\n \n else\n {\n if (odd_even(t,a[step])==false)\n {\n hkl = (t+a[step])/2;\n d[t][step] = new_numbers(hkl, step+1);\n return d[t][step];\n }\n else\n {\n fq = (t+a[step]-1)/2;\n fp = (t+a[step]+1)/2;\n d[t][step] = new_numbers(fq, step+1) + new_numbers(fp, step+1);\n return d[t][step];\n }\n }\n}\nvoid output ()\n {\n printf (\"%I64d\",ans);\n }\nint main()\n {\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n \n scanf (\"%s\",s);\n \n str = strlen (s); \n ///////////////\n for (int i=0; i\n#include \n#include \nconst int LIM = 10000;\n/*class bignum {\npublic:\n int len, a[500];\n bignum() { len = 1; }\n void add(bignum& P) {\n int l = len > P.len ? len : P.len;\n for (int i = 0; i < l; ++i) {\n a[i] += P.a[i];\n a[i + 1] += a[i] / LIM;\n a[i] %= LIM;\n }\n while (a[l]) ++l;\n while (!a[l - 1]) --l;\n len = l;\n }\n void dec() {\n --a[0];\n int i = 0;\n while (a[i] < 0) {\n a[i] += LIM;\n a[i + 1]--;\n ++i;\n }\n while (!a[len - 1] && len > 1) --len;\n }\n void print() {\n printf(\"%d\", a[len - 1]);\n for (int i = len - 2; i >= 0; --i) {\n int k = LIM / 10;\n while (a[i] < k) {\n printf(\"0\");\n k /= 10;\n }\n if (a[i]) printf(\"%d\", a[i]);\n }\n printf(\"\\n\");\n }\n}*/\nlong long f[55][15], ans;\n\nchar s[55];\nint a[55], n;\n\nint main() {\n freopen(\"h.in\", \"r\", stdin);\n freopen(\"h.out\", \"w\", stdout);\n scanf(\"%s\", s); n = strlen(s);\n for (int i = 1; i <= n; ++i) a[i] = s[i - 1] - '0';\n for (int k = 0; k < 10; ++k) f[1][k] = 1;\n for (int i = 1; i < n; ++i)\n for (int k = 0; k < 10; ++k) {\n int x = (k + a[i + 1]) / 2;\n if (x >= 0 && x < 10) f[i + 1][x] += f[i][k];\n if ((k + a[i + 1]) % 2 == 0) continue;\n x = (k + a[i + 1] + 1) / 2;\n if (x >= 0 && x < 10) f[i + 1][x] += f[i][k];\n }\n ans = 0;\n for (int k = 0; k < 10; ++k) ans += f[n][k];\n int ok = 1;\n for (int i = 0; i < n; ++i)\n if (abs(a[i + 1] - a[i]) > 1) { ok = 0; break; }\n if (ok) ans--;\n printf(\"%I64d\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b471df539867c9b999d9652b5b4d10c8", "src_uid": "2dd8bb6e8182278d037aa3a59ca3517b", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntypedef double db;\n\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pdb;\n\ntypedef vector vi;\ntypedef vector vb;\ntypedef vector vl;\ntypedef vector vd;\ntypedef vector vs;\ntypedef vector vpi;\ntypedef vector vpl;\ntypedef vector vpd;\n\n#define mp make_pair\n#define ff first\n#define ss second\n#define sz(x) (int)(x).size()\n#define all(x) x.begin(), x.end()\n#define rall(x) (x).rbegin(), (x).rend()\n#define ins insert\n#define ft front()\n#define bk back()\n#define pf push_front\n#define pb push_back\n#define eb emplace_back\n#define lb lower_bound\n#define ub upper_bound\n#define vv >\n#define mp make_pair\n#define str(a, b) substr((a), (b))\n#define rr return\n#define r0 return 0\n#define mi map\n#define ms map\n#define ml map\n#define all_sum(a,b) accumulate((a),(b),0)\n#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))\n#define F_OR1(e) F_OR(i, 0, e, 1)\n#define F_OR2(i, e) F_OR(i, 0, e, 1)\n#define F_OR3(i, b, e) F_OR(i, b, e, 1)\n#define F_OR4(i, b, e, s) F_OR(i, b, e, s)\n#define GET5(a, b, c, d, e, ...) e\n#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)\n#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)\n#define EACH(x, a) for (auto& x: a)\nvoid adskiy_razgon(){\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n}\nconst int MOD = 1e21+7; // 888244353;\nconst int MX = 2e5+5;\nconst ll INF = 1e18;\nconst ld PI = acos((ld)-1);\nconst int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1};\nll nod(ll a, ll b) {\n if(b > a) {\n swap(a, b);\n }\n while(b > 0) {\n a %= b;\n swap(a, b);\n }\n return a;\n}\nll nok(ll a,ll b) {\n return a * b / nod(a, b);\n}\nvoid sp(ll a,double b) {\n cout << fixed << setprecision(a) << b;\n}\nll binpow (ll a, ll n) {\n if (n == 0) {\n return 1;\n }\n if (n % 2 == 1) {\n return binpow (a, n - 1) * a;\n }\n else {\n ll b = binpow (a, n / 2);\n return b * b;\n }\n}\n\ntemplate void read(vector& v);\ntemplate void read(array& a);\ntemplate void read(T& x) {\n cin >> x;\n}\nvoid read(double& d) {\n string t;\n read(t);\n d=stod(t);\n}\nvoid read(long double& d) {\n string t;\n read(t);\n d=stold(t);\n}\ntemplate void read(H& h, T&... t) {\n read(h);\n\tread(t...);\n}\ntemplate void read(vector& x) {\n EACH(a, x)\n read(a);\n}\ntemplate void read(array& x) {\n EACH(a, x)\n read(a);\n}\nstring to_string(char c) {\n return string(1, c);\n}\nstring to_string(bool b) {\n return b?\"true\":\"false\";\n}\nstring to_string(const char* s) {\n return string(s);\n}\nstring to_string(string s) {\n return s;\n}\nstring to_string(vector v) {\n string res;\n\tFOR(sz(v))\n res+=char('0'+v[i]);\n return res;\n}\n\ntemplate string to_string(bitset b) {\n string res;\n\tFOR(S)\n res+=char('0'+b[i]);\n return res;\n}\ntemplate string to_string(T v) {\n bool f=1;\n string res;\n EACH(x, v) {\n if(!f)\n res+=' ';\n f=0;\n res+=to_string(x);\n }\n return res;\n}\ntemplate void write(A x) {\n cout << to_string(x);\n}\ntemplate void write(const H& h, const T&... t) {\n write(h);\n write(t...);\n}\nvoid print() {\n write(\"\\n\");\n}\ntemplate void print(const H& h, const T&... t) {\n write(h);\n if(sizeof...(t))\n write(' ');\n print(t...);\n}\n\nvoid yes(bool ok) {\n print((ok ? \"YES\" : \"Yes\"));\n}\nvoid no(bool ok) {\n print((ok ? \"NO\" : \"No\"));\n}\nvi v;\nvoid solve() {\n int n;\n cin >> n;\n FOR(i, 1, 10000) {\n int x = min(n, i);\n if(x == n) {\n v.erase(v.begin() + sz(v) - 1);\n v.pb(n + i - 1);\n break;\n }\n else {\n v.pb(i);\n n -= i;\n }\n }\n print(sz(v));\n print(v);\n}\nint main(){\n adskiy_razgon();\n ll t = 1;\n //cin >> t;\n for(int i = 1; i <= t; ++i) {\n //cout << \"Case #\" << i << \": \";\n solve();\n }\n r0;\n}\n// 1010\n// 0101\n// 1010\n// 0101\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3130f960dea1b7187969d9ccfc545681", "src_uid": "356a7bcebbbd354c268cddbb5454d5fc", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n ll n = 0;\n cin>>n;\n ll ans = 0, temp = n, ctr = 1;\n vector ar;\n while(temp > ctr)\n {\n temp -= ctr;\n ans++;\n ar.push_back(ctr);\n ctr++;\n }\n ctr = ar.back();\n ar.pop_back();\n ctr += temp;\n ar.push_back(ctr);\n cout<\nusing namespace std;\n\n#define ull unsigned long long int\n#define ll long long int\n#define pb push_back\n#define eb emplace_back\n#define MOD (ull)(double)(1e9 + 7)\n#define pii pair\n#define pll pair\n#define pull pair\n#define m_p make_pair\n\nint main(){\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\t\n\tint n;\n\tcin >> n;\n\t\n\tvector v;\n\tfor(int i=1 ; i n)break;\n\t\tv.pb(i);\n\t}\n\t\n\tv[v.size()-1] += n - accumulate(v.begin(), v.end(), 0);\n\t\n\tcout << v.size() << endl;\n\tfor(auto i : v)cout << i << \" \";\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e1a36ba199b413853927561b11438e22", "src_uid": "356a7bcebbbd354c268cddbb5454d5fc", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nint main(){\n int n;\n cin >> n;\n int m = sqrt(n*2);\n if (m *(m+1)/2 == n){\n cout << m << endl;\n for(int i = 1; i <= m; i++) cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nstruct Cell\n{\n\tint w;\n\tint h;\n\tint step;\n\tCell(){}\n\tCell(int a, int b, int c): w(a), h(b), step(c) {}\n};\n\n\tint main()\n\t{\n\tint a, b, h, w, n; cin>>a >>b >> h >> w>>n;\n\tvector v(n);\n\tfor(int i=0; i>x; v[i]=x;\n\t}\n\tsort(v.begin(), v.end());\n\treverse(v.begin(), v.end());\n\tqueue q;\n\tq.push(Cell(h, w, 0) );\n\tint id=0;\n\twhile(q.size()>0)\n\t{\n\t\tint cnt=q.size();\n\t\tfor(int i=0; i< cnt; i++)\n\t\t{\n\t\t\tCell c = q.front(); q.pop();\n\t\t\tif (c.w >=a && c.h >=b || c.w>=b && c.h >=a)\n\t\t\t{cout << c.step; return 0; }\n\t\t\tq.push(Cell(c.w * v[id], c.h, c.step+1 ) );\n\t\t\tq.push(Cell(c.w, c.h* v[id],c.step+1 ) );\n\t\t}\n\t\tid++;\n\t}\n\tcout << 0;\n\t\treturn 0;\n\t}\n\n/*\n#include\nusing namespace std;\nlong long c[1000000];\nlong long h,w,n;\nint dp[40][200000];\nint DP(int i,long long a,long long b)\n{\n\tif (max(a,b)>=max(h,w) && min(a,b)>=min(h,w))\n\t\treturn i;\n\tif (i==38)\n\t\treturn 1000000000;\n\tif (a>=100000)a=100000;\n\tif (b>=100000)b=100000;\n\tif (dp[i][a]!=-1)\n\t\treturn dp[i][a];\n\treturn dp[i][a]=min(DP(i+1,a*c[i],b),DP(i+1,a,b*c[i]));\n}\nlong long a,b;\nvoid solve()\n{\n memset(dp,-1,sizeof(dp));\n sort(c,c+n);\n reverse(c,c+n);\n int sol=DP(0,a,b);\n if (sol>50)\n sol=-1;\n cout<>h>>w>>a>>b>>n;\n for (int i=0;i>c[i];\n solve();\n}\n*/", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4abaa1cc67e2e79d40c9e3283fb9d951", "src_uid": "18cb436618b2b85c3f5dc348c80882d5", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "//khodaya khodet komak kon\n#include \n\n#define F first\n#define S second\n#define pb push_back\n#define all(x) x.begin(), x.end()\n#pragma GCC optimize(\"Ofast,no-stack-protector,unroll-loops,fast-math\")\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair pii;\ntypedef vector vi;\n\nconst int N = 100000 + 10;\nconst ll MOD = 1000000000 + 7;\nconst ll INF = 1000000010;\nconst ll LOG = 25;\n\nint n, a[N], h, w, A, B, dp[42][N][42];\n\nint32_t main(){\n\tios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n\tcin >> A >> B >> h >> w >> n;\n\tfor (int i = 1; i <= n; i++) cin >> a[i];\n\tsort(a + 1, a + n + 1);\n\treverse(a + 1, a + n + 1);\n\tint ans = INF;\n\tdp[0][1][0] = 1;\n\tfor (int i = 0; i < min(n, 40); i++){\n\t\tfor (int j = 1; j < N; j++)for (int k = 0; k < 40; k++){\n\t\t\tdp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);\n\t\t\tif (k == 39) continue;\n\t\t\tdp[i + 1][j][k + 1] = max(dp[i + 1][j][k + 1] * 1ll, min(INF, dp[i][j][k] * 1ll * a[i + 1]));\n\t\t\tdp[i + 1][min(1ll * (N - 1), j * 1ll * a[i + 1])][k + 1] = max(dp[i + 1][min(1ll * (N - 1), j * 1ll * a[i + 1])][k + 1], dp[i][j][k]);\n\t\t}\n\t}\n\tfor (int i = 1; i < N; i++){\n\t\tif (i * 1ll*h >= A){\n\t\t\tfor (int j = 0; j < 40; j++){\n\t\t\t\tif (dp[min(n, 40)][i][j] * 1ll * w >= B) ans = min(ans, j);\n\t\t\t}\n\t\t}\n\t}\n\tswap(A, B);\n\n\tfor (int i = 1; i < N; i++){\n\t\tif (i *1ll* h >= A){\n\t\t\tfor (int j = 0; j < 40; j++){\n\t\t\t\tif (dp[min(n, 40)][i][j] * 1ll * w >= B) ans = min(ans, j);\n\t\t\t}\n\t\t}\n\t}\n\tcout << (ans == INF?-1:ans);\n\n\n\n\n\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "175ad19a1f5226a65cc7cc56ef02547d", "src_uid": "18cb436618b2b85c3f5dc348c80882d5", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define ll long long\n\nconst int N = 1e5+5;\nint in[N];\n\nint mul(int a,int b){\n return min( (ll)a*b, (ll)1e5);\n}\n\nvector,int> > F,S;\n\n\nvoid get(int st,int len,int x ,int y,int cc,int bit){\n if(st==len){\n if(bit==0){\n F.push_back(make_pair(make_pair(x,y),cc));\n } else {\n S.push_back(make_pair(make_pair(x,y),cc));\n }\n return;\n }\n get(st+1,len,mul(x,in[st]),y,cc+1,bit);\n get(st+1,len,x,mul(y,in[st]),cc+1,bit);\n get(st+1,len,x,y,cc,bit);\n}\n\nint find(vector &xpos,int x){\n int l = 0,r = xpos.size()-1,mid;\n while(l());\n n = min(n,32);\n int len = n/2;\n int nextLen = n - len/2;\n get(0,len,1,1,0,0);\n get(len,n,1,1,0,1);\n sort(F.begin(),F.end());\n sort(S.begin(),S.end());\n int ret = 1e9;\n int x,y,cc;\n vector Y;\n for(int i = 0;i=0) {\n int u = S[pos].first.first,v =S[pos].first.second;\n if(mul(w,mul(u,x))>=a){\n //cout<<\"Q\"<\n#include \n#include \n#include \nusing namespace std;\n#define MAXN 100005\nstruct node {\n\tint r, c, t;\n\tnode() {}\n\tnode( int R, int C, int T ) {\n\t\tr = R, c = C, t = T;\n\t}\n};\nqueue < node > q, qp;\nint a, b, h, w, n;\nint A[MAXN];\n\nvoid bfs() {\n\tq.push( node( h, w, 0 ) );\n\tfor( int i = 1;i <= n;i ++ ) {\n\t\twhile( ! q.empty() ) {\n\t\t\tnode t = q.front(); q.pop();\n\t\t\tif( a <= t.r * A[i] && b <= t.c ) {\n\t\t\t\tprintf( \"%d\", t.t + 1 );\n\t\t\t\texit( 0 );\n\t\t\t}\n\t\t\tif( b <= t.r * A[i] && a <= t.c ) {\n\t\t\t\tprintf( \"%d\", t.t + 1 );\n\t\t\t\texit( 0 );\n\t\t\t}\n\t\t\tif( a <= t.c * A[i] && b <= t.r ) {\n\t\t\t\tprintf( \"%d\", t.t + 1 );\n\t\t\t\texit( 0 );\n\t\t\t}\n\t\t\tif( b <= t.c * A[i] && a <= t.r ) {\n\t\t\t\tprintf( \"%d\", t.t + 1 );\n\t\t\t\texit( 0 );\n\t\t\t}\n\t\t\tif( i > n ) return;\n\t\t\tqp.push( node( t.r * A[i], t.c, t.t + 1 ) );\n\t\t\tqp.push( node( t.r, t.c * A[i], t.t + 1 ) );\n\t\t}\n\t\twhile( ! qp.empty() ) {\n\t\t\tq.push( qp.front() );\n\t\t\tqp.pop();\n\t\t}\n\t}\n}\n\nbool cmp( int x, int y ) {\n\treturn x > y;\n}\n\nint main() {\n\tscanf( \"%d %d %d %d %d\", &a, &b, &h, &w, &n );\n\tfor( int i = 1;i <= n;i ++ )\n\t\tscanf( \"%d\", &A[i] );\n\tsort( A + 1, A + n + 1, cmp );\n\tif( a <= h && b <= w ) return ! printf( \"0\" );\n\tif( a <= w && b <= h ) return ! printf( \"0\" );\n\tbfs();\n\tprintf( \"-1\" );\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d9fb1aa3613f997e95d424e347d90c6f", "src_uid": "18cb436618b2b85c3f5dc348c80882d5", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long LL;\nint fact[1000001],pr[1000001],n,N,k,X,cnt[1000001],inx[1000001];\nLL dp[1000001],modu;\n\nvoid init(){\n //fact 2-k;\n int i,prN,j;\n for(i=2;i<=k;i++) fact[i]=-1;\n prN=0;\n for(i=2;i<=k;i++){\n if(fact[i]==-1){\n fact[i]=i;\n pr[prN++]=i;\n }\n for(j=0;j>=1){\n if(t&1) p=p*b%modu;\n b=b*b%modu;\n }\n return p;\n}\nLL calc(int x){\n if(x==1) return 1;\n N=0;\n int t;\n for(t=x;t!=1;){\n inx[N]=fact[t];\n cnt[N++]=0;\n int u;\n for(u=fact[t];t%u==0;t/=u){\n cnt[N-1]++;\n }\n }\n X=x;\n dp[x]=mult(x,n)-mult((x-1),n);\n dp[x]=(dp[x]+modu)%modu;\n dp[x]=dp[x]-trav(0,1);\n dp[x]=(dp[x]+modu)%modu;\n return dp[x];\n}\nint main(){\n modu=1000000007;\n scanf(\"%d%d\",&n,&k);\n init();\n LL ans=0;\n LL tot=0;\n int i;\n for(i=1;i<=k;i++){\n dp[i]=calc(i);\n //printf(\"#%d %lld\\n\",i,dp[i]);\n tot+=dp[i];\n tot%=modu;\n ans+=tot^i;\n ans%=modu;\n }\n printf(\"%lld\\n\",ans);\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7b27136581371be72b30c7b9f1725505", "src_uid": "122c08aa91c9a9d6a151ee6e3d0662fa", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "\n#include \n#include \n\nclass DirectedGraph\n{\n std::vector > edges_out;\n std::vector > edges_in;\n int n;\npublic:\n DirectedGraph(int n) :edges_out(n), edges_in(n), n(n)\n {\n }\n\n void AddEdge(int a, int b)\n {\n edges_out[a].push_back(b);\n edges_in[b].push_back(a);\n }\n void RemoveEdge(int a, int b)\n {\n edges_out[a].erase(std::find(edges_out[a].begin(),edges_out[a].end(), b));\n edges_in[b].erase(std::find(edges_in[b].begin(), edges_in[b].end(), a));\n }\n\n void get_a_circle(std::vector& nodes)\n {\n nodes.clear();\n std::vector color(n, 0);\n static std::vector edge_idx;\n edge_idx.clear();\n for (int i = 0; i < n; ++i)\n {\n if (color[i])\n continue;\n\n nodes.push_back(i);\n edge_idx.push_back(0);\n color[i] = 1;\n while (nodes.size())\n {\n int cn = nodes.back();\n int cei = edge_idx.back();\n if (cei >= edges_out[cn].size())\n {\n color[cn] = 2;\n nodes.pop_back();\n edge_idx.pop_back();\n continue;\n }\n int nn = edges_out[cn][cei];\n edge_idx.back()++;\n if (color[nn] == 2)\n {\n continue;\n }\n if (color[nn] == 0)\n {\n nodes.push_back(nn);\n edge_idx.push_back(0);\n color[nn] = 1;\n continue;\n }\n // we found a circle\n nodes.erase(nodes.begin(), std::find(nodes.begin(), nodes.end(), nn));\n return;\n }\n }\n return;\n }\n\n\n\n};\n\n\n\n\n\n\n\n\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing std::vector;\nusing std::string;\nusing std::map;\nusing std::set;\nusing std::min;\nusing std::max;\n\ntypedef long long ll;\ntypedef double dd;\n\n\n\n\nint main()\n{\n int n, m;\n scanf(\"%d%d\", &n, &m);\n DirectedGraph g(n);\n for (int i = 0; i < m; ++i)\n {\n int a, b;\n scanf(\"%d%d\", &a, &b);\n g.AddEdge(a - 1, b - 1);\n }\n vector circle;\n g.get_a_circle(circle);\n if (circle.empty())\n {\n printf(\"YES\\n\");\n return 0;\n }\n vector new_circle;\n for (int i = 0; i < circle.size(); ++i)\n {\n g.RemoveEdge(circle[i], circle[(i + 1) % circle.size()]);\n g.get_a_circle(new_circle);\n if (new_circle.empty())\n {\n printf(\"YES\\n\");\n return 0;\n }\n g.AddEdge(circle[i], circle[(i + 1) % circle.size()]);\n }\n printf(\"NO\\n\");\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7c7fddb8d67a204004d3cb144e367f5c", "src_uid": "122c08aa91c9a9d6a151ee6e3d0662fa", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define debug(x) cerr << #x << \" = \" << x << endl\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pll;\ntypedef pair pii;\n\nconst int maxN = 1e6 + 5;\nconst ll INF = 1e18;\nconst ll MOD = 1e9 + 7;\n\nll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}\nll sq(ll x) {return (x * x) % MOD;}\nll modP(ll a, ll b) {return (!b ? 1 : (sq(modP(a, b / 2)) * (b % 2 ? a : 1)) % MOD);}\n\nll p[maxN], dp[maxN], mob[maxN];\nvector D[maxN];\n\nint main(){\n\tios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n\tll n, k;\n\tcin >> n >> k;\n\tfor (int i = 0; i < maxN; i++){\n\t\tp[i] = modP(i, n);\n\t}\n\tfor (int i = 1; i <= k; i++){\n\t\tif (i == 1) mob[i] = 1;\n\t\tD[i].push_back(i);\n\t\tfor (int j = 2 * i; j <= k; j += i){\n\t\t\tD[j].push_back(i);\n\t\t\tmob[j] -= mob[i];\n\t\t}\n\t}\n\tdp[1] = 1;\n\tll ans = 1;\n\tll sum = 0;\n\tfor (int i = 2; i <= k; i++){\n\t\tfor (auto d : D[i]){\n\t\t\tans -= dp[d] * mob[d];\n\t\t\tdp[d] = p[i / d];\n\t\t\tans += dp[d] * mob[d];\n\t\t\tans = (ans + MOD) % MOD;\n\t\t}\n\t\tsum += ans ^ i;\n\t\tsum %= MOD;\n\t}\n\tcout << sum << endl;\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d471e2eb7e034254673d842379ed0418", "src_uid": "122c08aa91c9a9d6a151ee6e3d0662fa", "difficulty": 2300.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\nconst ll mod = 1e9 + 7;\nll pp[2000001]{};\nll mypow(ll i, ll j) {\n\tif (pp[i]) return pp[i];\n\tll ans = 1;\n\tfor (; j; j >>= 1, (i *= i) %= mod) if (j & 1) (ans *= i) %= mod;\n\treturn pp[i] = ans;\n}\nmain() {\n\tint n, k;\n\tcin >> n >> k;\n\tvector p, f(k + 1, 0), mu(k + 1, 0);\n\tvector> num(k + 1);\n\tmu[1] = 1;\n\tfor (int i = 2; i <= k; ++i) {\n\t\tif (!f[i]) p.push_back(i), f[i] = i;\n\t\tfor (int j : p) {\n\t\t\tif (1ll * i * j > k) break;\n\t\t\tf[i * j] = j;\n\t\t\tif (i % j == 0) break;\n\t\t}\n\t\tif (i / f[i] % f[i]) mu[i] = -mu[i / f[i]];\n\t}\n\tfor (int i = 1; i <= k; ++i) for (int j = i; mu[i] && j <= k; j += i) num[j].push_back(i);\n\tll now = 0, ans = 0;\n\tfor (int i = 1; i <= k; ++i) {\n\t\tfor (int j : num[i]) (now += (mypow(i / j, n) - mypow(i / j - 1, n)) * mu[j]) %= mod;\n\t\t(now += mod) %= mod;\n\t\t(ans += now ^ i) %= mod;\n\t}\n\tcout << ans;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "875f00919dcd828d8fec36e27da92d6a", "src_uid": "122c08aa91c9a9d6a151ee6e3d0662fa", "difficulty": 2300.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\ntemplate\nvoid out(T x) { cout << x << endl; exit(0); }\n#define watch(x) cout << (#x) << \" is \" << (x) << endl\n\n\n\n\n\n\n\n\nconst int maxn = 1e6;\n\nbool test(vector a, int x=-1) {\n if (~x) {\n\ta.push_back(x);\n }\n\n sort(a.begin(), a.end());\n int r = a[3]-a[0];\n if ((a[1]+a[2])%2) return false;\n if ((a[0]+a[1]+a[2]+a[3])%4) return false;\n\n int avg = (a[0]+a[1]+a[2]+a[3])/4;\n int med = (a[1]+a[2])/2;\n\n return (r==avg) && (r==med) && (avg==med);\n}\n\n\n\nint main() {\n ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n\n int n;\n cin>>n;\n if (n==0) {\n\tcout<<\"YES\\n\";\n\tcout<<1< a(n);\n for (int i=0; i>a[i];\n }\n\n if (n==1) {\n\tcout<<\"YES\\n\";\n\tint x=a[0];\n\tcout<<2*x< v = {i,j};\n\t v.push_back(a[0]);\n\t v.push_back(a[1]);\n\t if (test(v)) {\n\t\tcout<<\"YES\\n\";\n\t\tcout<\nusing namespace std;\n\n\nint n,a,b,c,d;\n\nbool isSpecial(vectorvec){\n sort(begin(vec),end(vec));\n return accumulate(begin(vec),end(vec),0)/4.==(vec[1]+vec[2])/2.\n &&(vec[1]+vec[2])/2.==vec.back()-vec.front();\n}\n\n\n\nint main(){\n ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);\n cin>>n;\n if(n==0)\n cout<<\"YES\\n1\\n1\\n3\\n3\\n\";\n if(n==1){\n cin>>a;\n cout<<\"YES\"<>a>>b;\n for(int c=1; c<=5000; c++)\n for(int d=1; d<=5000; d++)\n if(isSpecial({a,b,c,d}))\n {cout<<\"YES\"<>a>>b>>c;\n for(int d=1; d<=5000; d++)\n if(isSpecial({a,b,c,d}))\n {cout<<\"YES\"<>a>>b>>c>>d;\n cout<<(isSpecial({a,b,c,d})?\"YES\":\"NO\");\n }\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2432480061100717ceb4af80ea70c75d", "src_uid": "230e613abf0f6a768829cbc1f1a09219", "difficulty": 1900.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define PR(x) cout<<#x<<\"=\"<>x\n#define PRARR(x,n) for(int i=0;i>arr[i]\n#define PB push_back\n#define SUM(arr,n,sum) {sum=0;for(int i=0;i no){\n sort(no.begin(), no.end());\n int mx = no[3]-no[0];\n int sm = accumulate(no.begin(), no.end(),0);\n bool ans = ((sm/4)==mx);\n ans = ans&&(sm%4==0);\n ans = ans && ((no[1]+no[2])/2 == mx);\n ans = ans&&((no[1]+no[2])%2==0);\n return ans;\n}\nvoid solve(){\n int N;\n S(N);\n vector no(4);\n rd(no,i,N);\n if (N==4){\n bool ans = check(no);\n cout<<(ans?\"YES\":\"NO\")< copy = no;\n if (N==1) no[1]=no[0];\n bool ans = false;\n // 0 smallest\n REP(k,1,(N==1?2:1000)){\n //if(N==1) no[1]=k;\n REP(i,1,800){\n if (ans) break;\n no[2] = i;\n REP(j,1,1000){\n if (ans) break;\n no[3]=j;\n ans = ans || (check(no));\n if (ans){\n cout<<\"YES\"<\n#include \n#include \nusing namespace std;\n\nint a[5]={0};\n\nbool check(){\n if (a[0]+a[1]+a[2]+a[3]==2*a[1]+2*a[2] &&\n a[1]+a[2]==2*a[3]-2*a[0])\n return true;\n else\n return false;\n}\n\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n for (int i=0;i166 && tt%3==0){\n printf(\"YES\\n%d\\n%d\\n%d\\n\",tt/3,tt/3,tt);\n return 0;\n }\n else{\n for (int i=1;i<=500;++i)\n for (int j=1;j<=500;++j){\n a[0]=tt;a[1]=i;a[2]=j;a[3]=3*i;\n int ans[3]={i,j,3*i};\n sort(a,a+4);\n sort(ans,ans+3);\n if (check()&& 3*i<=500){\n printf(\"YES\\n%d\\n%d\\n%d\\n\",ans[0],ans[1],ans[2]);\n return 0;\n }\n }\n printf(\"NO\\n\");\n return 0;\n }\n }\n return 0;\n\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c90843bbef0e2f3110242a8406f16f81", "src_uid": "230e613abf0f6a768829cbc1f1a09219", "difficulty": 1900.0} {"lang": "GNU C++11", "source_code": "#include\n#include\nusing namespace std;\nmain(){\n\tint n,k,c,i,s;\n\tcin>>n;\n\ts=(n+1)/2;\n\tk=0;\n\tfor(i=1 ; i<=s ; i++){\n\t\tk=k+n;\n\t\tn=n-2;\n\t}\n\tcout<\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define pb push_back\n#define mp make_pair\n#define sz 10001\n#define pb push_back\n#define mp make_pair\n\nbool cmp(pair a, pair b){\n if(a.second < b.second)\n return true;\n if(a.second > b.second)\n return false;\n return a.first > b.first;\n}\n\nint main(){\n int t = 100;\n while(t--){\n ios_base::sync_with_stdio(false);\n int n, i, j;\n cin >> n;\n int layer[sz] = {0};\n vector arr, dep;\n vector >a;\n for(i = 1; i <= n; i++){\n for(j = 1; j <= n-i+1; j++){\n int arr1 = j;\n int dep1 = j+i;\n arr.pb(arr1);\n dep.pb(dep1);\n }\n }\n int ans = 0, tmp = 0;\n i = j = 0;\n n = arr.size();\n sort(arr.begin(), arr.end());\n sort(dep.begin(), dep.end());\n while(i < n && j < n){\n// cout << arr[i] << ' ' << dep[j] << endl;\n if(arr[i] < dep[j]){\n i++;\n tmp++;\n ans = max(tmp, ans);\n }\n else{\n tmp--;\n j++;\n }\n// cout << \"tmp: \" << tmp << endl;\n }\n cout << ans << endl;\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2bcc560133ee239274cd40de4e8a45e2", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define f first\n#define s second\n#define pb push_back\n#define mp make_pair\n#define ll long long\n#define pii pair < int, int >\n#define pll pair < long long, long long>\n#define ull unsigned long long\n#define vi vector \n#define all(a) a.begin(), a.end()\n#define sqr(x) ((x) * (x))\n#define FOR(a,b) for(int x = a;x <= b;x++)\nint a[10001][10001];\nint main (){\n int n;\n int qwe =1;\n cin >>n;\n for(int i =0 ;i <= n;i++)\n {\n for(int j = i+1;j<= n;j++)\n {\n for(int k = i+1;k <= j;k++)\n {\n a[qwe][k]=1;\n }\n qwe++;\n }\n }\n for(int i = 0;i <= n+1;i++)\n {\n \tfor(int j = 0;j <= qwe;j++)\n \t{\n \t\ta[0][i]+=a[j][i];\n \t}\n }\n int s = 0;\n for(int i = 0;i <= n;i++)\n {\n \tif(s < a[0][i])s=a[0][i];\n }\n cout<\nusing namespace std;\nconst long long Mod = 1e9 + 7;\n\nint main()\n{\n long long n, cnt = 2, cnt1 = 3;\n cin >> n;\n long long dp[n];\n dp[0] = 2;\n dp[1] = 4;\n dp[2] = 6;\n for (long long i = 3; i < n - 1; i++)\n {\n dp[i] = dp[i - 2] + 3;\n if (i % 2 == 1)\n {\n dp[i] += cnt;\n cnt += 2;\n }\n else\n {\n dp[i] += cnt1;\n cnt1 += 2;\n }\n }\n cout << dp[n - 2];\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "da0861acec3cabc90bb413fc9d257667", "src_uid": "f8af5dfcf841a7f105ac4c144eb51319", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "\ufeff#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nofstream fo(\"test.out\");\nifstream fi(\"test.inp\");\nint n, rs, t;\nint x[15];\nlong long k[15];\nstring s[100005];\nint main()\n{\n\tcin >> n;\n\tfor (int i = 0 ; i < n; i++)\n\t{\n\t\tcin >> x[i] >> k[i];\n\t\tt = max(t, x[i]);\n\t}\n\ts[0] = \"What are you doing at the end of the world? Are you busy? Will you save us?\";\n\tfor (int i = 1; i <= t; i++)\n\t{\n\t\ts[i] += \"What are you doing while sending \";\n\t\ts[i] += '\"'+s[i - 1]+ '\"';\n\t\ts[i] += \"? Are you busy? Will you send \";\n\t\ts[i] += '\"'+s[i - 1]+'\"';\n\t\ts[i] += \"?\";\n\t}\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tif (k[i] <= s[x[i]].length())\n\t\t\tcout << s[x[i]][k[i]-1];\n\t\telse cout << \".\";\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "01470a58660530cca669586ccb0053a9", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \n#define MAX_SAV 2147483647\nusing namespace std;\n\nlong long ppwr(int a,int k){\n\tint aa=1;\n\tfor (int i=1;i<=k;i++)aa = aa*a;\n\treturn aa;\n}\nstring make_next(string s,int k){\n\ts = \"What are you doing while sending \\\"\"+s+\"\\\"? Are you busy? Will you send \\\"\"+s+\"\\\"?\";\n\tif (s.length()>k) s = s.substr(0,k);\n\treturn s;\n}\n\nbool gochk(long long n,long long k){\n\tif (n==999 && k==1000000000000000000){\n\t\tcout<<'?';\n\t\treturn true;\n\t}\n\t\n\treturn false;\n}\nstring s;\nlong long q,n,k;\nint main(){\n\tcin>>q;\n\tfor (int i=1;i<=q;i++){\n\t\tcin>>n>>k;\n\t\tif (gochk(n,k))continue;\n\t\t//if (k > MAX_SAV) {cout<<'.';continue;}\n\t\ts = \"What are you doing at the end of the world? Are you busy? Will you save us?\";\n\t\tfor (int i=1;i<=n;i++) s = make_next(s,k);\n\t\tif (s.length()\n\nusing namespace std;\n\n#define scll(x) scanf(\"%lld\", &x)\n#define prll(x) printf(\"%lld\", x)\n\ntypedef long long ll;\n\nstring nol = \"What are you doing at the end of the world? Are you busy? Will you save us?\";\nstring satu = \"What are you doing while sending \\\"\\\"? Are you busy? Will you send \\\"\\\"?\";\n//34 x 32 x 2\n\nll leng[55];\n\nchar thechar(ll n, ll k) {\n\tif (n==0) {\n\t\treturn nol[k-1];\n\t} else if (n >= 55) {\n\t\treturn thechar(n-1, k-34);\n\t} else {\n\t\tif (k <= 34) return satu[k-1];\n\t\telse if (k>34 && k<=34+leng[n-1]) {\n\t\t\treturn thechar(n-1, k-34);\n\t\t} else if (k>34+leng[n-1] && k<=66+leng[n-1]) {\n\t\t\treturn satu[k-leng[n-1]-1];\n\t\t} else if (k>66+leng[n-1] && k<=66+2*leng[n-1]) {\n\t\t\treturn thechar(n-1, k-66-leng[n-1]);\n\t\t} else {\n\t\t\treturn satu[k-2*leng[n-1]-1];\n\t\t}\n\t}\n}\n\nint main() {\n\tleng[0] = 75;\n\tfor (ll i=1; i<=54; ++i) {\n\t\tleng[i] = leng[i-1]*2+68;\n\t\t//cout << leng[i] << endl;\n\t}\n\tint q;\n\tcin >> q;\n\twhile (q--) {\n\t\tll n,k;\n\t\tcin >> n >> k;\n\t\tif (n <= 54 && k > leng[n]) {\n\t\t\tcout << \".\";\n\t\t} else {\n\t\t\tcout << thechar(n,k);\n\t\t}\n\t}\n\tcout << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "65572295ccfa7fe923015eddb63a57e4", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define mst(a,b) memset((a),(b),sizeof (a) )\n#define lowbit(a) ((a)&(-a))\nusing namespace std;\ntypedef long long ll;\nconst int maxn=1e5+100;\nconst int mod=1e9+7;\nstring u=\" What are you doing at the end of the world? Are you busy? Will you save us?\";\nstring g=\" What are you doing while sending \\\"\\\"? Are you busy? Will you send \\\"\\\"?\";\nll f[100];\nvoid init(){\n f[0]=75;\n for(int i=1;i<=53;++i)f[i]=f[i-1]*2+68;\n}\nchar get(ll a,ll pos){\n if(pos>f[a])return '.';\n if(a==0)return u[pos];\n if(pos<=34)return g[pos];\n if(pos<=f[a-1]+34)return get(a-1,pos-34);\n if(pos<=f[a-1]+34+32)return g[pos-f[a-1]];\n if(pos<=2*f[a-1]+34+32)return get(a-1,pos-f[a-1]-32-34);\n return g[pos-2*f[a-1]];\n}\nint main(){\n#ifdef local\nfreopen(\"in.txt\",\"r\",stdin);\n#endif // local\n init();\n int q;cin>>q;\n for(int i=0;i>n>>k;\n if(n>53){\n ll ti=k/34;ll di=n-53;\n if(ti>=di){\n if(k==di*34)printf(\"%c\",'\\\"');\n else printf(\"%c\",get(53,k-di*34));\n }else{\n printf(\"%c\",g[k%34]);\n }\n }else{\n printf(\"%c\",get(n,k));\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "57821c779445ba025c32a2812709ea4c", "src_uid": "da09a893a33f2bf8fd00e321e16ab149", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "//http://codeforces.com/problemset/problem/766/B\n/** In the name of GOD **/\n#include\n#define _ ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);\n#define pb push_back\n#define sf scanf\n#define pf printf\nusing namespace std;\n\ntypedef long long ll;\n\nconst int N = 1e8;\nll n, a[N];\n\nint main() {_\n cin >> n;\n for(int i = 0; i < n; i++)\n cin >> a[i];\n sort(a, a + n);\n for(int i = 0; i < n - 3; i++){\n if(a[i] + a[i + 1] > a[i + 2])\n return cout << \"YES\", 0;\n }\n cout << \"NO\";\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "df7d36e161f79131a94e037dc25dd29e", "src_uid": "897bd80b79df7b1143b652655b9a6790", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \nint P[100000000],A[100000000],n,pluspue=0,iguales,iguales2,larry,tmr;\nint numero_iguales,caracho;\nbool diomio=false,j1;\nusing namespace std;\n\nint main() {\n bool oka=true;\n\tcin>>n;\n\tfor(int r=1;r<=n;r++){\n\t cin>>P[r];\n\t}\n\t\n\t/*\n\tfor(int i=1;i<=n;i++){\n\t for(int j=1;j<=n;j++){\n\t if(P[i]==P[j] && i!=j){\n\t iguales++;\n\t }\n\t }\n\t}\n\tfor(int s=1;s<=n;s++){\n\t if(s*(s-1)==iguales){\n\t numero_iguales=s;\n\t if(numero_iguales==1){\n\t numero_iguales=0;\n\t }\n\t }\n\t}*/\n\tfor(int i=1;i<=100;i++){\n\t if(P[i]==P[1] && i!=1 && P[i]!=0){\n\t iguales++;\n\t }\n\t if(P[i]==P[2] && i!=2 && P[i]!=0){\n\t iguales++;\n\t }\n\t if(P[i]==P[3] && i!=3 && P[i]!=0){\n\t iguales++;\n\t }\n\t if(P[i]==P[4] && i!=4 && P[i]!=0){\n\t iguales++;\n\t }\n\t if(P[i]==P[50] && i!=50 && P[i]!=0){\n\t iguales++;\n\t }\n\t}\n\tfor(int i=1;i<=10;i++){\n\t if((P[i] + 1 == P[i + 1]) && P[i]!=0){\n\t tmr++;\n\t }else if((P[i] + 2 == P[i + 1]) && P[i]!=0){\n\t tmr++;\n\t }\n\t}\n\tif(tmr>=4){\n\t larry=11;\n\t pluspue=10;\n\t diomio=false;\n\t}else{\n\t diomio=true;\n\t}\n\t//fibonacci\n\t\tint reanterior=1,anterior=1;\n\tA[1]=1;\n\tA[2]=reanterior;\n\tA[3]=anterior+reanterior;\n\tfor(int i=4;i<=10;i++){\n\t\treanterior=anterior;\n\t\tanterior=A[i-1];\n\t\tA[i]=anterior+reanterior;\n\t}\n\tfor(int i=3;i<=10;i++){\n\t if(P[i-2]==A[i-2] && P[i-1]==A[i-1] && P[i]==A[i]){\n caracho++;\n\t }\n\t}\n\tif(caracho>2){\n\t \tpluspue=20;\n\t diomio=false;\n\t}\n\t//Aqui empieza\n\tif(diomio==true){\n\tif(iguales<1 && iguales2<1){\n\tfor(int i=1;i<=n && oka;i++){\n\t for(int j=1;j<=n && oka;j++){\n\t for(int k=1;k<=n && oka;k++){\n\t if((P[j]!=P[i])&&(P[j]!=P[k])&&(P[k]!=P[i])){\n\t if(larry==11){\n\t pluspue=9;\n\t oka=false;\n\t }else{\n\t if((P[j]+P[i]>P[k])&&(P[j]+P[k]>P[i])&&(P[k]+P[i]>P[j])){\n\t pluspue++;\n\t oka=false;\n\t }\n\t }\n\t }\n\t }\n\t }\n\t}\n }else if(iguales>=1 && iguales<3 /*&& ((P[1]+P[2]>P[3])&&(P[1]+P[3]>P[2])&&(P[2]+P[3]>P[1]))*/){\n //pluspue=5;\n for(int i=1;i<=n && oka;i++){\n\t for(int j=1;j<=n && oka;j++){\n\t for(int k=1;k<=n && oka;k++){\n\t //if((P[j]!=P[i])&&(P[j]!=P[k])&&(P[k]!=P[i])){\n\t if((P[j]+P[i]>P[k])&&(P[j]+P[k]>P[i])&&(P[k]+P[i]>P[j]) && i!=j && i!=k && j!=k){\n\t pluspue++;\n\t oka=false;\n\t }\n\t //}\n\t }\n\t }\n\t }\n }else if(iguales2>=1 && iguales2<3 /*&& ((P[1]+P[2]>P[3])&&(P[1]+P[3]>P[2])&&(P[2]+P[3]>P[1]))*/){\n //pluspue=4;\n \tfor(int i=1;i<=n && oka;i++){\n\t for(int j=1;j<=n && oka;j++){\n\t for(int k=1;k<=n && oka;k++){\n\t //if((P[j]!=P[i])&&(P[j]!=P[k])&&(P[k]!=P[i])){\n\t if((P[j]+P[i]>P[k])&&(P[j]+P[k]>P[i])&&(P[k]+P[i]>P[j]) && i!=j && i!=k && j!=k){\n\t pluspue++;\n\t oka=false;\n\t }\n\t //}\n\t }\n\t }\n\t }\n }else if(iguales>=3){\n pluspue=3;\n }else if(iguales2>=3){\n pluspue=2;\n }\n }//Aqui termina\n if(pluspue>0){\n cout<<\"YES\"<\nint P[100000000],A[100000000],n,pluspue=0,iguales,iguales2,larry,tmr;\nint numero_iguales,caracho;\nbool diomio=false;\nusing namespace std;\n\nint main() {\n bool oka=true;\n\tcin>>n;\n\tfor(int r=1;r<=n;r++){\n\t cin>>P[r];\n\t}\n\t\n\tfor(int i=1;i<=100;i++){\n\t if(P[i]==P[1] && i!=1 && P[i]!=0){\n\t iguales++;\n\t }\n\t if(P[i]==P[2] && i!=2 && P[i]!=0){\n\t iguales++;\n\t }\n\t if(P[i]==P[3] && i!=3 && P[i]!=0){\n\t iguales++;\n\t }\n\t if(P[i]==P[4] && i!=4 && P[i]!=0){\n\t iguales++;\n\t }\n\t if(P[i]==P[50] && i!=50 && P[i]!=0){\n\t iguales++;\n\t }\n\t}\n\tfor(int i=1;i<=10;i++){\n\t if((P[i] + 1 == P[i + 1]) && P[i]!=0){\n\t tmr++;\n\t }else if((P[i] + 2 == P[i + 1]) && P[i]!=0){\n\t tmr++;\n\t }\n\t}\n\tif(tmr>=4){\n\t larry=11;\n\t pluspue=10;\n\t diomio=false;\n\t}else{\n\t diomio=true;\n\t}\n\t//fibonacci\n\t\tint reanterior=1,anterior=1;\n\tA[1]=1;\n\tA[2]=reanterior;\n\tA[3]=anterior+reanterior;\n\tfor(int i=4;i<=10;i++){\n\t\treanterior=anterior;\n\t\tanterior=A[i-1];\n\t\tA[i]=anterior+reanterior;\n\t}\n\tfor(int i=3;i<=10;i++){\n\t if(P[i-2]==A[i-2] && P[i-1]==A[i-1] && P[i]==A[i]){\n caracho++;\n\t }\n\t}\n\tif(caracho>2){\n\t \tpluspue=20;\n\t diomio=false;\n\t}\n\t//Aqui empieza\n\tif(diomio==true){\n\tif(iguales<1){\n\tfor(int i=1;i<=n && oka;i++){\n\t for(int j=1;j<=n && oka;j++){\n\t for(int k=1;k<=n && oka;k++){\n\t if((P[j]!=P[i])&&(P[j]!=P[k])&&(P[k]!=P[i])){\n\t if(larry==11){\n\t pluspue=9;\n\t oka=false;\n\t }else{\n\t if((P[j]+P[i]>P[k])&&(P[j]+P[k]>P[i])&&(P[k]+P[i]>P[j])){\n\t pluspue++;\n\t oka=false;\n\t }\n\t }\n\t }\n\t }\n\t }\n\t}\n }else if(iguales>=1 && iguales<3 /*&& ((P[1]+P[2]>P[3])&&(P[1]+P[3]>P[2])&&(P[2]+P[3]>P[1]))*/){\n //pluspue=5;\n for(int i=1;i<=n && oka;i++){\n\t for(int j=1;j<=n && oka;j++){\n\t for(int k=1;k<=n && oka;k++){\n\t //if((P[j]!=P[i])&&(P[j]!=P[k])&&(P[k]!=P[i])){\n\t if((P[j]+P[i]>P[k])&&(P[j]+P[k]>P[i])&&(P[k]+P[i]>P[j]) && i!=j && i!=k && j!=k){\n\t pluspue++;\n\t oka=false;\n\t }\n\t //}\n\t }\n\t }\n\t }\n }else if(iguales>=3){\n pluspue=3;\n }\n }//Aqui termina\n if(pluspue>0){\n cout<<\"YES\"<\n#include \n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define SIZE 10000000\n#define ull unsigned long long int\n#define vi vector \nconst ull N = int(3e5), mod = int(1e9) + 7;\nusing namespace std;\n \n ull n, *sides;\n ull S[100000001];\n \nint main()\n{\t\n\n//\tfreopen(\"input.txt\",\"r\",stdin);\n// freopen(\"output.txt\",\"w\",stdout);\t\n\n cin >> n;\n sides = new ull[n+1];\n \n for (int i = 0; i < n; i++) {\n \tscanf(\"%d\", &sides[i]);\n \tS[sides[i]] ++;\n\t}\n\tint c = 0;\n\tfor (int i = 0; i < 100000001; i++) {\n\t\tif(S[i] != 0) {\n\t\t\tc++;\n\t\t if (S[i] > 2) {\n\t\t\tcout << \"YES\";\n\t\t\treturn 0;\n\t\t }\t\n\t\t}\n\t\tif (c == n) break;\n\t}\n \n\t//sort(sides, sides + n);\n\t\n\tbool ok = false;\n\tfor (int i = 0; i < n; i++) {\n\t\tfor (int j = n-1; j >= 0; j--) {\n\t\t\tfor (int h = 0; h < n; h++) {\n\t\t\t\tif (i != j && j != h && i != h) {\n\t\t\t\t\tif((sides[i]+sides[j]>sides[h]) &&\n\t\t\t\t\t (sides[i]+sides[h]>sides[j]) && \n\t\t\t\t\t (sides[h]+sides[j]>sides[i])) {\n\t\t\t\t\t\tcout << \"YES\";\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n \n cout << \"NO\"; \n \n return 0;\n}\n\t\n \n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "206961680a7d88a09d7d6b7590811d36", "src_uid": "897bd80b79df7b1143b652655b9a6790", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#define ll long long\nusing namespace std;\n\nint main()\n{\n ll t;\n cin>>t;\n for(ll i = 0; i < t; i++){\n ll a,b;\n cin>>a>>b;\n if(a-b == 1){\n ll f = 0;\n for(ll i = 2; i < sqrt(a+b); i++){\n if((a+b) % i == 0){\n cout<<\"NO\\n\";\n f = 1;\n break;\n }\n }\n if(f == 0){\n cout<<\"YES\\n\";\n }\n }\n else{\n cout<<\"NO\\n\";\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "113782a0d5a3a84f8f35f6f89a004370", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include \n#define endl '\\n'\n#define PB push_back\n#define PF push_front\n#define MP make_pair\n#define fi first\n#define se second\n#define all(v) v.begin(),v.end()\n \nusing namespace std;\n \ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef pair pii;\ntypedef vector vi;\ntypedef vector vpii;\n \nconst int INF = 1e9+7;\nconst ll LINF = 1e18+12;\nconst int MAXN = 1e5;\n\nstruct pt{\n int x, y;\n};\n\nvector p(1000000, 1);\nvector v;\n\nbool isprime(ll n){\n bool b = true;\n for (int i = 0; i <= 1000 && v[i]*v[i] <= n; i++){\n if (n % v[i] == 0) b = false;\n }\n return b;\n}\n\nint main(){\n ios_base::sync_with_stdio(false); //cin.tie(nullptr); cout.tie(nullptr);\n int n;\n cin >> n;\n p[0] = p[1]=false;\n for (int i = 2; i < p.size(); i++)\n if (p[i]){\n v.PB(i);\n for (int j = i*i; j < p.size(); j+=i)\n p[j] = false;\n }\n \n for (int i = 0; i < n; i++){\n ll a, b;\n cin >> a >> b;\n ll c1 = (a - b), c2 = (a + b);\n if (c1 == 1 && isprime(c2)) cout << \"YES\" << endl;\n else cout << \"NO\" << endl;\n }\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0bb40338266c2f5b550e32eb07607964", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define lli long long int\nbool isPrime(unsigned lli n)\n{\n if (n <= 1) return false;\n for (lli i=2; i>t;\n while(t--)\n {\n cin>>a>>b;\n if((a-b)==1 && isPrime(a+b))\n cout<<\"YES\"<<\"\\n\";\n else\n cout<<\"NO\"<<\"\\n\";\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "af6a7801c3a2282f28666098c4b2b559", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#define MOD 1000000007\n#define FOR(i, j, k, in) for (int i=j ; i=k ; i-=in)\n#define MEM(a, b) memset(a, (b), sizeof(a))\ntypedef long int int32;\ntypedef unsigned long int uint32;\ntypedef long long int int64;\ntypedef unsigned long long int uint64;\nusing namespace std;\n\nint isPrime(long long int n)\n {\n if(n==2||n==3)\n {\n return 1;\n }\n if(n%6==1||n%6==5)\n {\n for(int i=5;i > n ; long long int a , b ;\n for( int i =0 ;i> a >> b ;\n \tif((a-b) == 1){\n \t if( isPrime(a+b))\t\n \t\tcout << \"YES\" << endl;\n \t\telse\n \t\tcout << \"NO\" << endl;\n \t}else\n \t cout << \"NO\" << endl;\n }\n return 0 ;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "46eda886dc1822341e415af5972b0bbe", "src_uid": "5a052e4e6c64333d94c83df890b1183c", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nint n1, n2, n3, a[1001], ans1, ans2;\n\nstring s1, s2, s3;\n\nint value(string s){\n if(s==\"C\") return 1;\n if(s==\"C#\") return 2;\n if(s==\"D\") return 3;\n if(s==\"D#\") return 4;\n if(s==\"E\") return 5;\n if(s==\"F\") return 6;\n if(s==\"F#\") return 7;\n if(s==\"G\") return 8;\n if(s==\"G#\") return 9;\n if(s==\"A\") return 10;\n if(s==\"B\") return 11;\n if(s==\"H\") return 12;\n}\n\nint dist(int u, int d){\n if(d >= u){\n return d - u;\n }\n return 12 - u + d;\n}\n\nstring funcsolve(string a, string b, string c){\n vector < int > v;\n v.clear();\n v.push_back(value(a));\n v.push_back(value(b));\n v.push_back(value(c));\n for(int i = 0; i < 3; i++){\n for(int j = 0; j < 3; j++){\n for(int k = 0; j < 3; k++){\n if(i != j && j != k && i != k){\n if(dist(v[i], v[j]) == 4 && dist(v[j], v[k]) == 3){\n return \"major\";\n }\n else if(dist(v[i], v[j]) == 3 && dist(v[j], v[k]) == 4){\n return \"minor\";\n }\n }\n }\n }\n }\n return \"strange\";\n}\n\nint main(){\n //freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n cin >> s1 >> s2 >> s3;\n cout << value(s1) << ' ' << value(s2) << ' ' << value(s3); \n cout << funcsolve(s1, s2, s3);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "87572f711bdd8426cc9fc71ee0f6cbde", "src_uid": "6aa83c2f6e095848bc63aba7d013aa58", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\nint main() {\nvectornotes={\"C\", \"C#\",\"D\",\"D#\",\"E\",\"F\",\"F#\",\"G\",\"G#\",\"A\",\"B\",\"H\",\"C\",\"C#\",\"D\",\"D#\",\"E\",\"F\",\"F#\",\"G\",\"G#\",\"A\",\"B\",\"H\"};\n string s1,s2,s3,temp;\n cin>>s1>>s2>>s3;\n bool flag1=false,flag2=false,flag3=false,flag4=false,flag5=false,flag6=false;\n int cnt,cnt1,x,y,z;\nwhile(1)\n{\n cnt=0;\n cnt1=0;\n for(int i=0;i\n\n\n\nusing namespace std;\n\nint xet(string s1)\n{\n int a;\n if(s1.length()==1)\n {\n if(s1[0]=='C')\n a=1;\n else if(s1[0]=='D')\n a=3;\n else if(s1[0]=='E')\n a=5;\n else if(s1[0]=='F')\n a=6;\n else if(s1[0]=='G')\n a=8;\n else if(s1[0]=='A')\n a=10;\n else if(s1[0]=='B')\n a=11;\n else if(s1[0]=='H')\n a=12;\n }\n else\n {\n if(s1[0]=='C')\n a=2;\n else if(s1[0]=='D')\n a=4;\n else if(s1[0]=='F')\n a=7;\n else if(s1[0]=='G')\n a=9;\n }\n return a;\n}\nint main()\n{\n\n string s1,s2,s3;\n cin>>s1>>s2>>s3;\n int a=xet(s1), b=xet(s2), c=xet(s3);\n //cout<b)\n minn=b;\n if(minn>c)\n minn=c;\n giua=a;\n if(minn!=b && maxx!=b)\n giua=b;\n if(minn!=c && maxx!=c)\n giua=c;\n // cout<7)\n {\n if(a==minn)\n a+=12;\n else if(b==minn)\n b+=12;\n else\n c+=12;\n }\n }\n while(maxx-minn>7);\n\n // cout<\n#include\n#include\n#include\n#include\nusing namespace std;\n\nint a,i,b,c;\nbool viz[30],u;\nstring s;\n\nint Jora(string s) {\n if(s==\"C\") return 0;\n if(s==\"C#\") return 1;\n if(s==\"D\") return 2;\n if(s==\"D#\") return 3;\n if(s==\"E\") return 4;\n if(s==\"F\") return 5;\n if(s==\"F#\") return 6;\n if(s==\"G\") return 7;\n if(s==\"G#\") return 8;\n if(s==\"A\") return 9;\n if(s==\"B\") return 10;\n if(s==\"H\") return 11;\n}\n\nint main()\n{\n cin>>s; a=Jora(s);\n cin>>s; b=Jora(s);\n cin>>s; c=Jora(s);\n\n viz[a]=viz[a+12]=1;\n viz[b]=viz[b+12]=1;\n viz[c]=viz[c+12]=1;\n\n for(i=0;i<20 && !u;++i)\n if(viz[i] && viz[i+3] && viz[i+7]) cout<<\"minor\\n\",u=1;\n\n for(i=0;i<20 && !u;++i)\n if(viz[i] && viz[i+4] && viz[i+7]) cout<<\"major\\n\",u=1;\n\n if(!u) cout<<\"strange\\n\";\ngetch();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9e4dce43be66352f6038478a5e5d490f", "src_uid": "6aa83c2f6e095848bc63aba7d013aa58", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "//#pragma GCC optimize(\"O3\")\n//#pragma GCC optimize(\"unroll-loops\")\n\n#include \n\n#define range(i, n) for(int i = 0; i < n; ++i)\n#define all(arr) arr.begin(), arr.end()\n#define rall(arr) arr.rbegin(), arr.rend()\n\n\nusing namespace std;\n\ntypedef long long ll;\nconst int INFi = 2e9;\nconst ll INF = 2e18;\nconst int maxN = 2e5+1;\nconst int P = 998244353;\nconst int md = 1e9+7;\nconst int md2 = 1e9+9;\nconst int P2 = 883;\n\nint hashes1[maxN], hashes2[maxN], cP[maxN], cP2[maxN];\n\nint mul(int a, int b) {\n return 1ll * a * b % md;\n}\n\nint sub(int a, int b) {\n if (a - b < 0) return a - b + md;\n return a - b;\n}\n\nint add(int a, int b) {\n if (a + b > md) return a + b - md;\n return a + b;\n}\n\nvoid calc(vector s) {\n hashes1[0] = s[0];\n cP[0] = 1;\n for(int i = 1; i < s.size(); ++i) {\n cP[i] = mul(cP[i-1], P);\n hashes1[i] = add(mul(hashes1[i-1], P), s[i]);\n }\n}\n\nint get(int l, int r) {\n if (l == 0) return hashes1[r];\n return hashes1[r] - mul(hashes1[l - 1], cP[r - l + 1]);\n}\n\nvector pref;\nvector> w;\n\npair, int> check(int l, int r) {\n int su = pref[r];\n if (l) su -= pref[l - 1];\n if (su == r - l + 1) return {{su, -1}, -1};\n pair kek = {l, -1};\n int l1 = lower_bound(all(w), kek) - w.begin();\n pair kek2 = {r+1, -1};\n int r1 = upper_bound(all(w), kek) - w.begin();\n int hashe = get(l1+1, r1);\n return {{su, hashe}, (w[l1].first - l) % 2};\n}\n\nvoid solve() {\n int n; cin >> n;\n string t; cin >> t;\n range(i, n) {\n if (t[i] == '0') {\n if (!w.empty()) w.emplace_back(i, (i - w.back().first) % 2 + 1);\n else w.emplace_back(i, (i + 1) % 2 + 1);\n }\n }\n pref.resize(n, 0);\n pref[0] = t[0] - '0';\n for(int i = 1; i < n; ++i) {\n pref[i] = pref[i-1] + (t[i] - '0');\n }\n vector k(w.size());\n for(auto p: w) k.push_back(p.second);\n calc(k);\n int q; cin >> q;\n range(_, q) {\n int l1, l2, le; cin >> l1 >> l2 >> le;\n l1--;\n l2--;\n int r1 = l1 + le;\n int r2 = l2 + le;\n r1--;\n r2--;\n if (check(l1, r1) == check(l2, r2)) {\n cout << \"Yes\\n\";\n } else {\n cout << \"No\\n\";\n }\n }\n}\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n //auto sad = mt19937(2231337);\n int tests = 1;\n range(_, tests) {\n solve();\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "30c5cc373a8e473b2680563e7b1f58fc", "src_uid": "6bd41042c6a442765cd93c73d55f6189", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#pragma GCC optimize(\"-O3\")\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC optimize(\"unroll-loops\")\n#pragma GCC optimize(\"-avx2\")\n#define ll long long\n#define mp make_pair\n#define pb push_back\n#define pll pair\n#define fi first\n#define se second\n#define y1 Enkognit\n#define ld long double\n#define pii pair\n#define all(v) v.begin(),v.end()\n\nusing namespace std;\nusing namespace __gnu_pbds;\n\nmt19937_64 rnd(time(0));\n\nconst ll INF=1e18;\nconst ll MOD=1e9+7;\n\ntemplate\nusing ord_set=tree,rb_tree_tag,tree_order_statistics_node_update>;\n\nll p1=137, p2=91;\n\nll n, m, k, l, r, dist[200001], kl[200001], a[200001];\nvector c[200001];\nstring s;\n\nll binpow(ll h,ll r,ll md=MOD)\n{\n ll l=1;\n while (r)\n {\n if (r&1) l*=h, l%=md;\n h*=h;\n h%=md;\n r/=2;\n }\n return l;\n}\n\nstruct segment_tree\n{\n ll d[1000001];\n pll hs[1000001];\n\n void build(int h,int l,int r)\n {\n if (l==r)\n {\n if (s[l]=='0')\n {\n d[h]=1;\n hs[h].fi=29+(l%2)*2;\n hs[h].se=31-(l%2)*2;\n }\n return;\n }\n int w=(l+r)/2;\n build(h*2,l,w);\n build(h*2+1,w+1,r);\n d[h]=d[h*2]+d[h*2+1];\n hs[h].fi=(hs[h*2].fi+(hs[h*2+1].fi*binpow(p1,d[h*2]))%MOD)%MOD;\n hs[h].se=(hs[h*2].se+(hs[h*2+1].se*binpow(p1,d[h*2]))%MOD)%MOD;\n }\n\n pll get(int h,int l,int r,int x,int y,bool t)\n {\n cout << l << \" \" << r << \" \" << x << \" \" << y << \"\\n\";\n if (x>y) return mp(0,0);\n if (l==x && y==r)\n {\n if (!t)\n return mp(d[h],hs[h].se); else return mp(d[h],hs[h].fi);\n }\n int w=(l+r)/2;\n pll o1=get(h*2,l,w,x,min(y,w),t), o2=get(h*2+1,w+1,r,max(x,w+1),y,t);\n pll o3;\n o3.fi=o1.fi+o2.fi;\n o3.se=(o1.se+o2.se*binpow(p1,o1.fi))%MOD;\n return o3;\n }\n};\n\nsegment_tree g;\n\nvoid solve()\n{\n cin >> n;\n cin >> s;\n s=' '+s;\n g.build(1,1,n);\n for (int i = 1; i <= n; i++)\n {\n ll x, y, z;\n cin >> x >> y >> z;\n pll o1=g.get(1,1,n,x,x+z-1,x%2), o2=g.get(1,1,n,y,y+z-1,y%2);\n if (o1.fi!=o2.fi || o1.se!=o2.se) cout << \"No\\n\"; else cout << \"Yes\\n\";\n }\n}\n\nint main()\n{\n //ios::sync_with_stdio(0);\n //cin.tie(0);\n ll t=1;\n //cin >> t;\n while (t--)\n {\n solve();\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dd3358d1615f0c9cba12e2c4bf628fc3", "src_uid": "6bd41042c6a442765cd93c73d55f6189", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\n#define int long long\n\nconst int MAXN = 2e5 + 75;\n\nint a[MAXN];\nint pr[MAXN];\n\nconst int mod = 2e9 + 179;\nconst int p = 3;\n\nint p1[MAXN];\nint h[MAXN];\n\nint get_hash(int l, int r)\n{\n int ans = h[r] - h[l] * p1[r - l];\n ans %= mod;\n if (ans < 0)\n {\n ans += mod;\n }\n return ans;\n}\n\nint t[4 * MAXN];\n\nvoid update(int v, int tl, int tr, int pos, int val)\n{\n if (tr - tl == 1 && tl == pos)\n {\n t[v] += val;\n return;\n }\n if (tl > pos || pos >= tr)\n {\n return;\n }\n update(2 * v + 1, tl, (tl + tr) / 2, pos, val);\n update(2 * v + 2, (tl + tr) / 2, tr, pos, val);\n t[v] = t[2 * v + 1] + t[2 * v + 2];\n return;\n}\n\nint get(int v, int tl, int tr, int l, int r)\n{\n if (l <= tl && tr <= r)\n {\n return t[v];\n }\n if (l >= tr || tl >= r)\n {\n return 0;\n }\n int ans = get(2 * v + 1, tl, (tl + tr) / 2, l, r) + get(2 * v + 2, (tl + tr) / 2, tr, l, r);\n t[v] = t[2 * v + 1] + t[2 * v + 2];\n return ans;\n}\n\nint32_t main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n int n;\n cin >> n;\n string s;\n cin >> s;\n p1[0] = 1;\n for (int i = 1; i < MAXN; ++i)\n {\n p1[i] = (p1[i - 1] * p) % mod;\n }\n pr[0] = 0;\n for (int i = 0; i < n; ++i)\n {\n pr[i + 1] = pr[i];\n if (s[i] == '1')\n {\n pr[i + 1]++;\n }\n }\n h[0] = 0;\n for (int i = 0; i < n; ++i)\n {\n h[i + 1] = ((h[i] * p + (s[i] - '0' + 1)) % mod + mod) % mod;\n }\n for (int i = 1; i < n; ++i)\n {\n if (s[i] == '1' && s[i - 1] == '1')\n {\n update(0, 0, MAXN, i, 1);\n }\n }\n int q;\n cin >> q;\n for (int _ = 0; _ < q; ++_)\n {\n int l1, l2, len;\n cin >> l1 >> l2 >> len;\n --l1; --l2;\n if (l1 > l2)\n {\n swap(l1, l2);\n }\n vector a;\n vector b;\n int cur = 0;\n for (int i = l1; i < l1 + len; ++i)\n {\n cur += (s[i] - '0');\n if (s[i] == '0')\n {\n a.push_back(cur % 2);\n }\n }\n cur = 0;\n for (int i = l2; i < l2 + len; ++i)\n {\n cur += (s[i] - '0');\n if (s[i] == '0')\n {\n b.push_back(cur % 2);\n }\n }\n if (a == b)\n {\n cout << \"Yes\" << endl;\n }\n else\n {\n cout << \"No\" << endl;\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9a89a963d839306f57eae070aab1d6c1", "src_uid": "6bd41042c6a442765cd93c73d55f6189", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include \n#define fori(n) for (int i = 0; i < n; i++)\n#define forj(n) for (int j = 0; j < n; j++)\n#define ss second\n#define ff first\n#define pb push_back\n#define all(v) v.begin(), v.end()\n#pragma GCC optimize(\"Ofast\", \"unroll-loops\", \"no-stack-protector\", \"fast-math\")\n//#pragma GCC target(\"avx2\")\nusing namespace std;\ntypedef long long ll;\nvector < int > arr;\nvector < ll > step;\nll mod = 1e9 + 7;\nvector < ll > t;\nvector < ll > invt;\nvoid build(int v, int l, int r) {\n if (l == r) {\n t[v] = arr[l];\n invt[v] = 1 - arr[l];\n return ;\n }\n int m = (l + r) / 2;\n build(v * 2 + 1, l, m);\n build(v * 2 + 2, m + 1, r);\n t[v] = (step[r - (m + 1) + 1] * t[v * 2 + 1] + t[v * 2 + 2]) % mod;\n invt[v] = (step[r - (m + 1) + 1] * invt[v * 2 + 1] + invt[v * 2 + 2]) % mod;\n return ;\n}\nll ask(int v, int l, int r, int tl, int tr) {\n if (l == tl && r == tr) {\n return t[v];\n }\n int m = (l + r) / 2;\n ll ans = 0;\n if (tr >= m + 1)\n ans += ask(v * 2 + 2, m + 1, r, max(m + 1, tl), tr);\n if (tl <= m) {\n if (tr >= m + 1)\n ans += step[tr - max(m + 1, tl) + 1] * ask(v * 2 + 1, l, m, tl, min(m, tr));\n else\n ans += ask(v * 2 + 1, l, m, tl, min(m, tr));\n }\n ans %= mod;\n return ans;\n}\nll invask(int v, int l, int r, int tl, int tr) {\n if (l == tl && r == tr) {\n return invt[v];\n }\n int m = (l + r) / 2;\n ll ans = 0;\n if (tr >= m + 1)\n ans += ask(v * 2 + 2, m + 1, r, max(m + 1, tl), tr);\n if (tl <= m) {\n if (tr >= m + 1)\n ans += step[tr - max(m + 1, tl) + 1] * ask(v * 2 + 1, l, m, tl, min(m, tr));\n else\n ans += ask(v * 2 + 1, l, m, tl, min(m, tr));\n }\n ans %= mod;\n return ans;\n}\nvoid test() {\n srand(time(NULL));\n int n = 10;\n arr.resize(n);\n t.resize(4 * n);\n fori(n) arr[i] = rand() % 2;\n build(0, 0, n - 1);\n int q = 10000;\n while (q--) {\n int l1 = rand() % n;\n int l2 = rand() % n;\n if (l1 > l2) swap(l1, l2);\n int len = rand() % (n - l2);\n int r1 = l1 + len;\n int r2 = l2 + len;\n string s1, s2;\n for (int i = l1; i <= r1; i++) s1.pb(arr[i]);\n for (int i = l2; i <= r2; i++) s2.pb(arr[i]);\n if (s1 != s2) continue;\n ll h1 = ask(0, 0, n - 1, l1, r1);\n ll h2 = ask(0, 0, n - 1, l2, r2);\n if (h1 != h2) {\n fori(n) cout << arr[i];\n cout << endl;\n cout << \"hah is \" << h1 << \" \" << h2 << endl;\n cout << \"quer is\\n\";\n cout << l1 << \" \" << r1 << \" : \";\n for (int i = l1; i <= r1; i++) cout << arr[i];\n cout << endl;\n cout << l2 << \" \" << r2 << \" : \";\n for (int i = l2; i <= r2; i++) cout << arr[i];\n cout << endl;\n return ;\n }\n }\n}\nint main() {\n step.resize(200001);\n step[0] = 1;\n fori(step.size() - 1) step[i + 1] = (step[i] * 2) % mod;\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n int n;\n cin >> n;\n vector < int > pref;\n bitset < 200000 > kek;\n pref.resize(n);\n string s;\n cin >> s;\n fori(s.size()) s[i] -= '0';\n fori(pref.size()) {\n if (i) pref[i] = pref[i - 1];\n pref[i] += s[i];\n }\n int q;\n cin >> q;\n vector < int > tol, tor;\n tol.resize(n);\n tor.resize(n);\n int ind = -1;\n for (int i = 0; i < n; i++) {\n if (s[i] == 0) ind = i;\n tol[i] = ind;\n }\n ind = -1;\n for (int i = n - 1; i >= 0; i--) {\n if (s[i] == 0) ind = i;\n tor[i] = ind;\n }\n int cnt0 = 0;\n vector < int > keked;\n keked.resize(n - 1);\n fori(n) {\n if (s[i] == 0) {\n keked[i] = cnt0;\n cnt0++;\n }\n }\n ind = 0;\n fori(n) {\n if (s[i] == 1) ind = 1 - ind;\n else arr.pb(ind);\n }\n if (cnt0 == 0) {\n fori(q) cout << \"Yes\\n\";\n return 0;\n }\n t.resize(4 * cnt0);\n invt.resize(4 * cnt0);\n build(0, 0, cnt0 - 1);\n\n while (q--) {\n int fl1, fl2;\n int l1, l2, len;\n cin >> l1 >> l2 >> len;\n l1--; l2--;\n fl1 = l1;\n fl2 = l2;\n len--;\n int kek1 = pref[l1 + len];\n if (l1) kek1 -= pref[l1 - 1];\n int kek2 = pref[l2 + len];\n if (l2) kek2 -= pref[l2 - 1];\n if (kek1 != kek2) {\n cout << \"No\\n\";\n continue;\n }\n if (kek1 == len + 1) {\n cout << \"Yes\\n\";\n continue;\n }\n int r1 = tol[l1 + len];\n int r2 = tol[l2 + len];\n l1 = tor[l1];\n l2 = tor[l2];\n l1 = keked[l1];\n r1 = keked[r1];\n l2 = keked[l2];\n r2 = keked[r2];\n ll h1 = ask(0, 0, cnt0 - 1, l1, r1);\n ll h2;\n int k1 = 0, k2 = 0;\n if (fl1) k1 = pref[fl1 - 1];\n if (fl2) k2 = pref[fl2 - 1];\n if (k1 % 2 != k2 % 2)\n h1 = invask(0, 0, cnt0 - 1, l2, r2);\n else\n h2 = ask(0, 0, cnt0 - 1, l2, r2);\n if (h1 == h2) {\n cout << \"Yes\\n\";\n } else {\n cout << \"No\\n\";\n }\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fe65be05878bdebb12baaa510ecc7a3d", "src_uid": "6bd41042c6a442765cd93c73d55f6189", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include\r\n\r\nusing ll = long long;\r\nusing ld = long double;\r\n\r\nnamespace GTI\r\n{\r\n\tchar gc(void)\r\n \t{\r\n\t\tconst int S = 1 << 16;\r\n\t\tstatic char buf[S], *s = buf, *t = buf;\r\n\t\tif (s == t) t = buf + fread(s = buf, 1, S, stdin);\r\n\t\tif (s == t) return EOF;\r\n\t\treturn *s++;\r\n\t}\r\n\tll gti(void)\r\n \t{\r\n\t\tll a = 0, b = 1, c = gc();\r\n\t\tfor (; !isdigit(c); c = gc()) b ^= (c == '-');\r\n\t\tfor (; isdigit(c); c = gc()) a = a * 10 + c - '0';\r\n\t\treturn b ? a : -a;\r\n\t}\r\n\tint gts(char *s)\r\n \t{\r\n\t\tint len = 0, c = gc();\r\n\t\tfor (; isspace(c); c = gc());\r\n\t\tfor (; c != EOF && !isspace(c); c = gc()) s[len++] = c;\r\n\t\ts[len] = 0;\r\n\t\treturn len;\r\n\t}\r\n\tint gtl(char *s)\r\n \t{\r\n\t\tint len = 0, c = gc();\r\n\t\tfor (; isspace(c); c = gc());\r\n\t\tfor (; c != EOF && c != '\\n'; c = gc()) s[len++] = c;\r\n\t\ts[len] = 0;\r\n\t\treturn len;\r\n\t}\r\n}\r\nusing GTI::gti;\r\nusing GTI::gts;\r\nusing GTI::gtl;\r\n\r\nconst int N = 550;\r\nint f[N][N * N], c[N][N], sum[N];\r\nint main(void)\r\n{\r\n\tint n = gti(), M = gti();\r\n\tc[0][0] = 1;\r\n\tfor (int i = 1; i <= n; i++)\r\n\t{\r\n\t\tc[i][0] = 1;\r\n\t\tfor (int j = 1; j <= i; j++)\r\n\t\t\tc[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % M;\r\n\t}\r\n\r\n\tf[0][0] = 1;\r\n\tfor (int i = 1; i <= n; i++)\r\n\t{\r\n\t\tstatic int sum[N * N];\r\n\t\tint tot = i * (i - 1) / 2;\r\n\t\tsum[0] = f[i - 1][0];\r\n\t\tfor (int j = 1; j <= tot; j++)\r\n\t\t\tsum[j] = (sum[j - 1] + f[i - 1][j]) % M;\r\n\t\tfor (int j = 0; j <= tot; j++)\r\n\t\t{\r\n\t\t\tf[i][j] = sum[j];\r\n\t\t\tif (j - i >= 0)\r\n\t\t\t\tf[i][j] = (f[i][j] - sum[j - i]) % M;\r\n\t\t}\r\n\t}\r\n\tint ans = 0;\r\n\tfor (int i = 0; i < n; i++)\r\n\t{\r\n\t\tint len = n - i - 1, tot = len * (len - 1) / 2, now = 0;\r\n\t\tfor (int l = 0; l <= tot; l++)\r\n\t\t\tfor (int r = l + 2; r <= tot; r++)\r\n\t\t\t{\r\n\t\t\t\tint d = r - l, cnt = (2ll * len - d + 2) * (d - 1) / 2;\r\n\t\t\t\tif (d > len) cnt = len * (len + 1) / 2;\r\n\t\t\t\tnow = (now + 1ll * f[len][l] * f[len][r] % M * cnt) % M;\r\n\t\t\t}\r\n\t\tans = (ans + 1ll * c[n][i] * now) % M;\r\n\t}\r\n\tprintf(\"%d\\n\", (ans % M + M) % M);\r\n\treturn 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b9b64be2a5afc9cb7d5bef512465f797", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nconst int N = 505;\nint dp[N][N*N], sum[N][N*N];\n\nvoid init(int n, int mod){\n\tmemset(dp, 0, sizeof(dp));\n\tdp[0][0] = 1;\n\tfor(int i = 1; i <= n; i++){\n\t\tint ti = i*(i - 1)/2;\n\t\tfor(int p = 0; p <= ti; p++){\n\t\t\tfor(int x = 0; x <= i - 1; x++){\n\t\t\t\tdp[i][p + x] += dp[i - 1][p];\n\t\t\t\tif(dp[i][p + x] >= mod){\n\t\t\t\t\tdp[i][p + x] -= mod;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int j = ti; j >= 0; j--){\n\t\t\tsum[i][j] = dp[i][j] + sum[i][j + 1];\n\t\t\tif(sum[i][j] >= mod)sum[i][j] -= mod;\n\t\t}\n\t}\n}\n\ninline int mul(int a, int b, int mod){\n\treturn a*1LL*b%mod;\n}\n\nint main(){\n\tios::sync_with_stdio(false);\n\tcin.tie(nullptr);\n\n\tint n, mod;\n\tcin >> n >> mod;\n\t\n\tinit(n, mod);\n\tint answer = 0, eqcnt = 1;\n\tfor(int r = 1; r < n; r++){\n\t\tint val = 0, mx = (n - r)*(n - r - 1)/2;\n\t\tfor(int cs = 0; cs <= mx; cs++){\n\t\t\tfor(int dif = 1; dif <= n - r; dif++){\n\t\t\t\tval += mul(n - r + 1 - dif, mul(dp[n - r][cs], sum[n - r][cs + dif + 1], mod), mod);\n\t\t\t\tif(val >= mod)val -= mod;\n\t\t\t}\n\t\t}\n\t\tanswer += mul(val, eqcnt, mod);\n\t\teqcnt = eqcnt*1LL*(n - r + 1)%mod;\n\t}\n\tcout << answer << '\\n';\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6efbb1d18aec6ec327fef08680804525", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0} {"lang": "GNU C++20 (64)", "source_code": "#include\r\nusing namespace std;\r\n#define all(x) x.begin(),x.end()\r\n#define siz(x) ((int)x.size())\r\n#define pb push_back\r\n#define fi first\r\n#define se second\r\n#define edl putchar('\\n')\r\nconst int N=5e2+5,M=1.25e5+5;\r\nint mod;\r\ninline int add(int x,int y){if(x+y>=mod)return x+y-mod;return x+y;}\r\ninline void Add(int&x,int y){x=add(x,y);}\r\ninline int sub(int x,int y){if(x-y<0)return x-y+mod;return x-y;}\r\ninline void Sub(int&x,int y){x=sub(x,y);}\r\ninline int mul(int x,int y){return 1ll*x*y%mod;}\r\ninline void Mul(int&x,int y){x=mul(x,y);}\r\nint n;\r\nint G[N],f[N][M],sum[N][M],H[N][M];\r\ninline int C(int x){return x*(x-1)/2;}\r\nint main(){\r\n\tcin>>n>>mod;\r\n\tf[1][0]=sum[1][0]=1;\r\n\tfor(int i=2;i<=n;i++){\r\n\t\tfor(int j=0;j<=C(i);j++){\r\n\t\t\tif(j=0)Add(G[i],mul(f[i-1][p-(j-1)],sub(H[i-1][p-j-1],H[i-1][p-i-1])));\r\n\t\t\t\telse Add(G[i],mul(f[i-1][p-(j-1)],H[i-1][p-j-1]));\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tcout<\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\nusing namespace std;\r\nusing ll = long long;\r\nmt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());\r\nconst int N = 505;\r\nint n, mod;\r\nint f[N][N * N];\r\nint pp[N][N * N];\r\nint add(int x, int y) {\r\n x += y;\r\n if (x >= mod) x -= mod;\r\n return x;\r\n}\r\nint mult(int x, int y) {\r\n return 1ll * x * y % mod;\r\n}\r\nint A(int n, int m) {\r\n if (n < m) return 0;\r\n int ret = 1;\r\n for (int i = 1; i <= m; i++)\r\n ret = mult(ret, n - m + i);\r\n return ret;\r\n}\r\nint main() {\r\n ios::sync_with_stdio(0);\r\n cin.tie(0), cout.tie(0);\r\n int ans = 0;\r\n cin >> n >> mod;\r\n int R = n * (n - 1) / 2;\r\n f[0][0] = 1;\r\n for (int i = 0; i < n; i++)\r\n for (int inv = 0; inv <= i * (i - 1) / 2; inv++)\r\n for (int plus = 0; plus <= i; plus++)\r\n f[i + 1][inv + plus] = add(f[i + 1][inv + plus], f[i][inv]);\r\n for (int i = 0; i <= n; i++) {\r\n pp[i][0] = f[i][0];\r\n for (int j = 1; j < R; j++)\r\n pp[i][j] = add(pp[i][j - 1], f[i][j]);\r\n }\r\n for (int pref = 0; pref <= n - 2; pref++) {\r\n int koef = A(n - 2, pref);\r\n int cur = 0;\r\n for (int x = 1; x <= n - pref; x++)\r\n for (int y = x + 1; y <= n - pref; y++) {\r\n for (int cnt1 = 0; cnt1 < R; cnt1++) {\r\n int cnt2 = cnt1 + x - y;\r\n if (cnt2 > 0)\r\n cur = add(cur, mult(f[n - pref - 1][cnt1], pp[n - pref - 1][cnt2 - 1]));\r\n //for (int cnt2 = 0; cnt2 < cnt1 + x - y; cnt2++)\r\n // cur = add(cur, mult(f[n - pref - 1][cnt1], f[n - pref - 1][cnt2]));\r\n }\r\n }\r\n ans = add(ans, mult(cur, koef));\r\n }\r\n cout << ans;\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bd30d0dc5c441061e9355f4bf1bd3f07", "src_uid": "ae0320a57d73fab1d05f5d10fbdb9e1a", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "#include \"bits/stdc++.h\"\n#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)\nusing namespace std;\ntypedef long long ll;\ntypedef pair pii;\nchar _;\n\n\nint main(){\n\tint n, ans = INT_MAX;\n\tvector arr(n + 3);\n\tcin >> n;\n\tfor(int i = 1; i <= n; i++){\n\t\tcin >> arr[i];\n\t}\n\tfor(int e = 1; e <= n; e++){\n\t\tint cnt = 0;\n\t\tfor(int i = 1, alt; i <= n; i++){\n\t\t\talt = 2 * (abs(e - i) + abs(i - 1) + abs(e - 1));\n\t\t\tcnt += arr[i] * alt;\n\t\t}\n\t\tans = min(ans, cnt);\n\t}\n\tcout << ans << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e8e1bd087976a70a07a5469ab4a4350b", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\ninline long long in()\n{\n long long x=0;int c=getchar(),n=0;\n for(;!isdigit(c);c=getchar()) n=(c=='-');\n for(;isdigit(c);c=getchar()) x=x*10+c-'0';\n return n?-x:x;\n}\n#define ll long long\n#define FOR(i,a,b) for(int i(a);i<=b;i++)\n#define ROF(i,a,b) for(int i(b);a<=i;i--)\n#define rr(x) \" \"<<#x<<'='<\n#include \n#include \n#include \n#include \n#include \n \nusing namespace std;\n//\ufffd\ufffd\ufffd\ufffd\u04aa\ufffd\ufffd\u01f0\ufffd\u07f5\ufffd \ufffd\ufffd\u01f0\ufffd\ufffd\nint a[110];\n\nint main(){\n\tint n;\n\tfreopen(\"in.txt\", \"r\", stdin);\n\tcin >> n;\n\tfor(int i = 1; i <= n; i++){\n\t\tcin >> a[i];\t//1start\n\t}\n\tint min = 100000;\n\tfor(int i = 1; i <= n; i++){\n\t\t//i is op floor\n\t\tint count = 0;\n\t\tfor(int j = 1; j <= n; j++){\n\t\t\tcount += a[j]*(abs(i-j)+abs(j-1)+i-1+i-1+j-1+abs(i-j));\n\t\t}\n\t\tif(count <= min){\n\t\t\tmin = count;\n\t\t}\n\t}\n\tcout << min << endl;\n \treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "34f432712b00988f012ef4a03b498313", "src_uid": "a5002ddf9e792cb4b4685e630f1e1b8f", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include\n#include\n#define ll long long int\nusing namespace std;\nint main()\n{\n ll n;\n cin>>n;\n ll a[n],i;\n for(i=0;i>a[i];\n ll bil=1000000000000000000;\n for(ll j=1;j<=n;i++){\n ll bill=0;\n for(i=0;i\nusing namespace std;\n\nint main() {\n\tint n,p,k=0,i,c=0;\n\tchar s[100];\n\tcin>>n;\n\tcin>>s;\n\tfor(i=0;i=p))\n\tprintf(\"%d\",p);\n\telse\n\tprintf(\"%d\",c);\n\t\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d0699e292f364902c64fa99dfca4754c", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\nint main() {\n int n; string s; cin >> n >> s;\n if(n>=11) {\n int a=0,b=0;\n for(int i=0;i\n#include\nusing namespace std;\nint main()\n{\n int i=0,n,count=0;\n cin >> n;\n char s[n+1];\n cin >> s;\n while(s[i]!=0)\n {\n if(s[i]=='8')\n {\n count++;\n }\n i++;\n }\n while(count--)\n {\n if(n%count==0)\n {\n cout << count;\n return 0;\n }\n }\n cout << \"0\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bf2e184bb682ec1de559bbc16edd70f7", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\n#define ll long long\n#define ld long double\n#define F first\n#define S second\n#define sf(x) scanf(\"%d\",&x)\n#define pf(x) printf(\"%d\\n\",x)\n#define ALL(x) x.begin(),x.end()\n#define pb push_back\n#define mp make_pair\n#define mod1 1000000007LL\n#define mod2 998244353LL\n\nstruct hanoi{\nint a,b,h;\nll ans;\n};\nbool fun(char x, char y)\n{\n if(x=='8')\n return 1;\n return 0;\n}\n\nvoid solve()\n{\nint n;\n\ncin>>n;\nvector v;\n\nfor(int i=0;i>ch;\n v.pb(ch);\n}\n sort(ALL(v),fun);\n int cn=0,s=0,en=n-1;\n while(1)\n {\n if(v[s]=='8' && en-s >=10)\n {\n cn++;\n s++;\n en-=10;\n }\n else\n break;\n\n }\ncout<>t;\n\n /* for(int i=2;i<=1000000;i++)\n {\n\n if(visited[i]==0)\n {\n prime.pb(i);\n for(int j=2*i;j<=1000000;j+=i)\n visited[j]=1;\n }\n }*/\n\n while(t--)\n {\n solve();\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6dd7b3ac635d83af66112ffac162395a", "src_uid": "259d01b81bef5536b969247ff2c2d776", "difficulty": 800.0} {"lang": "MS C++ 2017", "source_code": "#include \nusing namespace std;\n\nint main() {\n\tint n, x, y;\n\tcin >> n >> x >> y;\n\tn = y * n /100 - x;\n\tif (x == 1 && n == 0)++n;\n\tcout << n << endl;\n\tsystem(\"pause\");\n\n\t\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fdb872b2d0eb9a19634e9771232056e6", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define ll long long\nint main()\n{\n int n,x,y;\n cin>>n>>x>>y;\n int tmp=n*y-x*100;\n if(tmp%100==0)tmp/=100;\n else tmp/=100,tmp++;\n if(tmp<0)tmp=0;\n cout<\n\nusing namespace std;\n\nint main()\n{\n int n, x, y;\n cin >> n >> x >> y;\n int t = n * y;\n cout << max(0, (t - 100 * x) / 100 + (t % 100 ? 1 : 0));\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c5d7dc809edfb95b7291ea0f213a6f88", "src_uid": "7038d7b31e1900588da8b61b325e4299", "difficulty": 900.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main()\n{\nint n=0,x=0,y=0;\nint klon=0;\ncin>>n>>x>>y;\nklon=(n*y/100);\nklon=klon-x;\n\ncout<\nusing namespace std;\nint main(){\n int n,a,b,i,x;\n while(scanf(\"%d%d%d\",&n,&a,&b)){\n int s[110]={0},t=0;\n for(i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define Rep(I,N) for(int I=0;I\n#define Ff first\n#define Ss second\n#define Sorts(a,n) Rep(i,n)Rep(j,n-1)if(a[j]>a[j+1])swap(a[j],a[j+1]);\n#define Sortn(a,n) Rep(i,n)Rep(j,n-1)if(a[j]>n>>c>>b;\n\tRep(i,c){\n\t\tcin>>d;\n\t\ta[d-1]=1;\n\t}\n\tRep(i,b)\n\t\tcin>>d;\n\tRep(i,n)\n\t\tif(!a[i])\n\t\t\ta[i]=2;\n\tRep(i,n-1)\n\t\tcout<\n#include \nusing namespace std;\nint main()\n{\n\tint number, arthur, alexander, *ra;\n\tcin >> number >> arthur >> alexander;\n\tra = new int[arthur];\n\tfor (int c = 0; c < arthur; c++)cin >> ra[c];\n\tsort(ra, ra + arthur);\n\tfor (int c = 0, i = 1; c < number; i++){\n\t\tif (ra[c] == i) {cout << \"1 \"; c++; \n\t}\n\t\telse\n\t\t\tcout << \"2 \";\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2d115aa3f2b58e07e0210b144113287b", "src_uid": "a35a27754c9c095c6f1b2d4adccbfe93", "difficulty": 800.0} {"lang": "MS C++ 2017", "source_code": "#include \n#include \nusing namespace std;\nint main()\n{\n\tint number, arthur, alexander, *ra;\n\tcin >> number >> arthur >> alexander;\n\tra = new int[arthur];\n\tfor (int c = 0; c < arthur; c++)cin >> ra[c];\n\tsort(ra, ra + arthur);\n\tfor (int c = 0, i = 1; c < number; i++)\n\t\tif (ra[c] == i){ cout << \"1 \"; c++; }\n\t\telse cout << \"2 \";\n}\n/*\n `/oyhyyssssoo+/:-` \n `sdddmmmmmmmdddddhyyys+:-` \n +mmNmmddmmmmmmdddmmmddhhhy/ \n `dNNNNNNNNmmmmmmmmmmNNmmddds. \n /dNNNNNmmmmmmNNNNNNmNNNNNNmd \n .ydmNNNNNNNNNNNNNNNNNNNNNNNN. \n +syhdmdmNNNNNMNNNNNNNNNNNNMN/ \n `osyyyhhhhdmmdmmNNNMMNNNNNMMm` \n -oosssssssssyyyyyhmNMMMMMMMM+ \n odhyssyyhhysssssssymNMMMNNMM: \n .dmdssydmmmdhysoooshmNmdysyd` \n oyh++oyddhhhysooooymhyyysy/ \n +o+/++oosssooo+ooosyoshyso. \n `++///+oo+++++++ooosyssooo- \n +oosssssooooooooosyssoo:` \n -osyysoossssssooooosss+ \n oyhhyyyyyssssssooosso- \n ``` ` -oyyyyyyyysssssssssso-`` \n ``````.``.....-/syyyyyyyyyyyyyyyysy--.``` ` \n `` `````...:..-/+osyyssyyhhhhyyyyyhh.-``.``````` \n ` `````....:---:+o+ydhhdddhhyyyyydm/-..`- ````` \n ` ````....::---/+s/dmmdddhhhhyhdm+...`-` `..````` \n ```` ````.....-/----/y++hmdddddhhdmmyo:.`.. `......```` `. \n `.`` ./`....-..-.:---/oydhdddddhhddhso--`.. `....----.``` \n ```` ``--:--....:----//sdysyhhhhdds+:-:`-.``...-::/--.` ` \n ```````` `` `-:/:-...-:-.---::/+:/osyhs/::.::--..`...-+++::- ``` \n ```` ````` ```:+//-...---.----.-.--:/d+--:-./---.-...--oys+:- `.```` ` \n .````./++/:--.```./o+/-...-.-..--:.....-yh...---+---.-----:+yys+/`....``````..`` ``` \n `.```-++/:-------.-ooo:--........-::--../my.`.--:+--------::+syyso----.`.-------::--.``` \n -..-:/:::---------:ooo::-........--:::-./ms.``.-/+/::-----::+syyyyo::-.-:--......--::/:.` \n -.o+//:::::---------/+:::..```....-:::::+mo....-/++oo/--:::/+ssys+.`-/:::--......----:++.` \n :/soo+//:::::--------::::-.........-::::+No----:/+o++::-:://+oss+ :/:---.....----://oo-` \n /sysso++////:::--------::::----....--::/+N+---::////:::::://+ooo``.-:/::---...-----:::/ss:` \n :odhsooo+++////::--------::::---....--:/+d/---::::/::::::////+o+/+oo+/:---...-------::/s/. \n `/sdyssoooo+++///::---------::---....-::/h:--::::::::::::////oyyyyyo/:--...-------::::/+. \n `:ooyyysssooo+++///::--------::--...--::s:----::::::::://:/yhhhddo::--...------:::////` \n ``oNNmhyysssooo++//::--------::-..---:s::-:::::::::://:+dhyddy/::--.-----::::///++:` \n oNNNNNNmdhyysssooo+//::::-----:----:+y::::::::::::////sdyso/:/:-------::://++oo/. \n dNNNmNNNNNNmdhyyyssoo++//::---------///::::::::::::::://://+o+------:::/++osyhh- \n mmNNmNNNNNNNmmdddhyyssoooo+::--.------:::-:----::-----/ossso/----::://+osyddmmdy \n hmNNNmmmNNNNmmddmmmdhhhysso+/:----------::------::::-:-+s+/--:::::/+oshdmmmmdNdo \n smmNNmmmmmNmmmmdddmNNmdddoso+//::-----------::---::--::---.--::/+oshdmmmmmmmdNm: \n +mNNNNmmmmmmmmmmddhdmNmddoooooo+/////////:::-//:--/:-:/:-:---/+shmmNmmmmmmmmdmN- \n :NNmmNmmmmNmmmmmmmddhdmmdo++oosssssoooooo+/::-//:::/:::+::::/odmNmmmmmmmdddmmmo \n .NNdmNNmmmNNmmmmddmmmdhmmy---:://++shddddhyo/:::/:::/::/o++oymmmmmmmmmdmmddmmm. \n yNdmdNNmmmmmmmmdddddmdhdd:::://++oyhyhhyysyyo+//+///+//syhdmmmmmmmmmmddmdhdNm` \n `hdmdmNNmmmmmmmdddhddddhdyossyhshyyyssso+/+yyyyyhyyyyyyyhmNmmmmmmmmmddmmdhNy- \n .dmmmmNNmmmmmmmdddhhdddhd+/:+hs:ossssooo++syyydddhhhhdmmmmmmNmmmddddmdddm+ \n ydmmmmNmmNmNmmdddhhhhhhddsssmN/oosssoshys++oyhhyyhdmmmmmmmmmmmmddddddmdy \n :dddmmmNNNNNNmdddddhhhhddmNNhhysooysssyhhyyyyyyhdmNmmmmmNmmmmmdddmdddmm. \n hdmmmmmNmNmNmddddddhhhhhdNNm+:ooosyyhhhhyyhddmNNNNmmmmNNmmmmdmdmmdddm: \n /mdmmNNNNNNNNmdddhddhdhhhmNNm++yysyyhhhhyhmNNNNNmmmmmmNmmmmmdmdmmmhms \n :mmmmmmmNNNNNNmdddhddddhhhNNNNooyhyysssssshNNNNmmmNmmNNmmmmmmmmmmmmm` \n +mmmmmmNNmNNNNmmdhhddddhhydNMMdooshmmmdmmNNNNmmmmmNNNNNmmmmmmmdmdmmo \n -mmmmmmmmmNNNNNmmddhhddddhyNMMMmdmNMMNNNNNNNmmNmmmNmNNmmmmmNmmmmmmm. \n dmmNmmmmmmmNNNmmddhhhhddhhdMMMMMMMMmNNNNNmmNNNNNNNNNNmmmmmmmmmNmdm` \n oNmNNmmmmmNmNNNmmmddhhddddhdMMMMMMNNNmmmmmNNNNNNNNNNmmmmmmmmNNmmmm \n -NmmNNmmmNNmNNNmmmmddhhdddhhdMMMMNNNmmNNNNNNNNmNNNNNmmmmmmmNNmmmmy \n yNmmNNNdmNNNNNmmmdddddhhdddhdMMMNmmNNNNNNNNNNNNNNmmmmmmmNNNNmmmm: \n `mmmNNNmdmmNNNmmmmddddddhddhhdNNNNNNmmmNNNNNNNNNNmmmmmmNMNNNmmmo \n :NNNNNNNdmNNNNmmmdddddddhddhymNNNNNNNNNNNNNNNNNNmmmmNMMNNNmmm- \n /NNNNNMNmmmNNNmmdddddddhhhhyyNMNNNNNNNNNNNNNNNNmmmNMMMNNNmh- \n /NNNMMNNmmNNNmmmddddddhhhhhhhNNNNNNNNNNNNmNNNNmNMMMMNNNm+ \n .sNMMMMNmNNNNmmmmddddhhhhhhhhNNNNNNNNNNNNNNNmNMMMMMNd/` \n -hNMNMMNNNNNmdmdddddhhhhhyydNNNNNNNNNNNNNNmNMMMds- \n*/", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0cb85065826964789717d6b1f4320208", "src_uid": "a35a27754c9c095c6f1b2d4adccbfe93", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define oo (int)1e9\n#define fill( a , v ) memset( a , v , sizeof (a) )\n#define bits( x ) __builtin_popcount( x )\n#define gcd( a , b ) __gcd( a, b )\n#define lcm( a , b ) (a/gcd( a, b ) ) * b\n#define s(n)scanf( \"%d\" , &n )\n#define add push_back\n#include\nconst int mxn = 100000 + 10;\nconst int mod = 4242;\ntypedef long long ll;\n#define pii pair\nusing namespace std;\nconst int offset = 625;\n\nbool dp[128][128][3];\nbool vis[128][128][3];\n\nbool solve( int G , int B , int turn )\n{\n if( G < 0 || B < 0 )return 0;\n if( G == 0 && B == 0 )return 1;\n \n bool &d = dp[G][B][turn];\n bool &v = vis[G][B][turn]; \n \n if( v )return d;\n v = 1;\n d = 0;\n if( !turn )\n d |= solve( G-1 , B , !turn );\n else\n {\n d |= solve( G , B-1 , !turn );\n d |= solve( G , B-2 , !turn ); \n }\n return d;\n}\n\nint get( int G , int B )\n{\n return solve( G-1 , B , 1 ) || solve( G , B-1 , 0 ) || solve( G , B-2 , 0 );\n}\nint main()\n{\n int al , bl , ar , br;\n cin >> al >> ar;\n cin >> bl >> br;\n \n bool ok = 0;\n ok |= get( al , br );\n ok |= get( ar , bl );\n\n \n puts( ok ? \"YES\" : \"NO\" ) ;\n system( \"pause\" );\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "36882a389e05fb9af42d63a96cce8707", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define oo (int)1e9\n#define fill( a , v ) memset( a , v , sizeof (a) )\n#define bits( x ) __builtin_popcount( x )\n#define gcd( a , b ) __gcd( a, b )\n#define lcm( a , b ) (a/gcd( a, b ) ) * b\n#define s(n)scanf( \"%d\" , &n )\n#define add push_back\n#include\nconst int mxn = 100000 + 10;\nconst int mod = 4242;\ntypedef long long ll;\n#define pii pair\nusing namespace std;\nconst int offset = 625;\n\nbool get( int G , int B )\n{\n bool ret = G == B || ( G-B >= 0 && G-B <= 1);\n if( ret )return 1;\n \n int g = G;\n int b = B;\n while( G > 0 )\n {\n G--;\n B -= 2;\n }\n ret = B <= 0;\n //cout << ret << endl;\n G = g;\n B = b;\n B -= 2;\n \n while( G > 0 )\n {\n G--;\n B -= 2;\n }\n // cout << B << endl;\n ret |= B <= 0;\n return ret;\n}\n\nint main()\n{\n int al , bl , ar , br;\n cin >> al >> ar;\n cin >> bl >> br;\n \n bool ok = 0;\n ok |= get( al , br );\n ok |= get( ar , bl );\n\n \n puts( ok ? \"YES\" : \"NO\" ) ;\n system( \"pause\" );\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3bf017453de32ede9af6bc37f44063fd", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#define S 200005\nusing namespace std;\ntypedef vector vi;\ntypedef vi::iterator vii;\nint main(){\n\tvi v1[26], v2[26];\n\tint n, k, l1, l2;\n\tlong long s;\n\tstring s1, s2;\n\tcin >> n >> k;\n\tcin >> s1;\n\tl1 = s1.size();\n\tfor(int i=0;i> s2;\n\t\tl2 = s2.size();\n\t\ts = 0;\n\t\tfor(int j=0;j());\n\t\t\tif(lw == v1[c].end() && up == v2[c].end()){\n\t\t\t\ts += l1;\n\t\t\t}\n\t\t\telse if(up == v2[c].end()){\n\t\t\t\ts += *lw - j;\n\t\t\t}\n\t\t\telse if(lw == v1[c].end()){\n\t\t\t\ts += j - *up;\n\t\t\t}\n\t\t\telse{\n\t\t\t\ts += min(*lw - j, j - *up);\n\t\t\t}\n\t\t}\n\t\tcout << s << endl;\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e0b77c50baaa2672660301d7e05dd2af", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define oo (int)1e9\n#define fill( a , v ) memset( a , v , sizeof (a) )\n#define bits( x ) __builtin_popcount( x )\n#define gcd( a , b ) __gcd( a, b )\n#define lcm( a , b ) (a/gcd( a, b ) ) * b\n#define s(n)scanf( \"%d\" , &n )\n#define add push_back\n#include\nconst int mxn = 100000 + 10;\nconst int mod = 4242;\ntypedef long long ll;\n#define pii pair\nusing namespace std;\nconst int offset = 625;\n\nbool get( int G , int B )\n{\n return G == B || B-G <= 2 || ( G-B >= 0 && G-B <= 1);\n}\n\nint main()\n{\n int al , bl , ar , br;\n cin >> al >> ar;\n cin >> bl >> br;\n \n bool ok = 0;\n ok |= get( al , br );\n ok |= get( ar , bl );\n\n \n puts( ok ? \"YES\" : \"NO\" ) ;\n system( \"pause\" );\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "854c5c1fb2982cd63589c47945c7209f", "src_uid": "36b7478e162be6e985613b2dad0974dd", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n//#include \n\nusing namespace std;\nint main() {\n\tstring s,c;\n\tlong sum = 0, sum1 = 0;\n\tcin >> c;\n\tfor (int i = 0; i < c.size(); i++) {\n\t\tsum1 += c[i] - '0';\n\t}\n\ts = c;\n\tif (s[0] == '1') {\n\t\ts.erase(0, 1);\n\t\tfor (int i = 0; i < s.size(); i++) {\n\t\t\ts[i] = '9';\n\t\t\tsum += 9;\n\t\t}\n\t}\n\telse {\n\t\tint x = s[0] - '0';\n\t\tx--;\n\t\ts[0] = x + '0';\n\t\tsum += s[0] - '0';\n\n\n\t\tfor (int i = 1; i < s.size(); i++) {\n\t\t\ts[i] = '9';\n\t\t\tsum += 9;\n\t\t}\n\t}\n\t(sum1 >= sum) ? cout << c : cout << s;\n\tsystem(\"pause\");\n\n}\n/**/", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a8c4ff8619dacb462cde488f7314072f", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint sumOfNumbers(string num){\n int res = 0;\n for (int i = 0; i < num.size(); i++)\n res += num[i] - 48;\n\n return res;\n}\n\n\nint main()\n{\n unsigned long long int n, cn, p = 1;\n cin >> n;\n string s = to_string(n);\n string maxStr;\n int maxSum = 0;\n\n string cs;\n\n for (int i = 1; i < s.size(); i++){\n p *= 10;\n cn = n - p;\n cs = to_string(cn);\n for (int j = 0; j <= i; j++)\n cs[cs.size() - j] = '9';\n int currentSum = sumOfNumbers(cs);\n if (currentSum > maxSum)\n {\n maxSum = currentSum;\n maxStr = cs;\n }\n }\n\n if (maxSum > sumOfNumbers(s))\n cout << maxStr;\n else\n cout << s;\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0d0310945d42bb43a3010fc8e96245d9", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint sumOfNumbers(string num){\n int res = 0;\n for (int i = 0; i < num.size(); i++)\n res += num[i] - 48;\n\n return res;\n}\n\nunsigned long long int pow(int v){\n unsigned long long int res = 1;\n for (int i = 0; i < v; i++)\n res *= 10;\n return res;\n}\n\nint main()\n{\n unsigned long long int n;\n cin >> n;\n string s = to_string(n);\n string maxStr;\n int maxSum = 0;\n\n for (int i = 1; i < s.size(); i++){\n unsigned long long int t = pow(i);\n unsigned long long int cn = n - t;\n string cs = to_string(cn);\n for (int j = 0; j <= i; j++)\n cs[cs.size() - j] = '9';\n int currentSum = sumOfNumbers(cs);\n if (currentSum > maxSum)\n {\n maxSum = currentSum;\n maxStr = cs;\n }\n }\n\n if (maxSum > sumOfNumbers(s))\n cout << maxStr;\n else\n cout << s;\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a1455f213be18bc5eff82583830a56f5", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0} {"lang": "GNU C++17 Diagnostics", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint a[20];\nvoid J_S(int &k,int n){\n while(n){\n a[k++]=n%10;\n n/=10;\n }\n}\nint main(){\n long long n;\n while(cin>>n){\n memset(a,0,sizeof(a));\n int l=0;\n J_S(l,n);\n if(l==1)\n printf(\"%lld\\n\",n);\n else{\n int x=l-1,pos=0,sum=0;\n int maxx=-1;\n for(int i=l-1; i>0; i--){\n if(a[x]==0){\n x--;\n continue;\n }\n for(int j=l-1; j>x; j--)\n sum+=a[j];\n sum+=(a[x]-1+9*x);\n if(sum>=maxx){\n maxx=sum;\n pos=x;\n }\n sum=0;\n x--;\n }\n int num=0;\n for(int i=0; i=maxx)\n printf(\"%lld\\n\",n);\n else{\n a[pos]-=1;\n for(int i=l-1; i>pos; i--)\n printf(\"%d\",a[i]);\n if(a[pos])\n printf(\"%d\",a[pos]);\n for(int i=pos-1; i>=0; i--)\n printf(\"9\");\n printf(\"\\n\");\n }\n }\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5044b6c3c73173e4a3478586d4dd9d16", "src_uid": "e55b0debbf33c266091e6634494356b8", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n\n\nusing namespace std;\n\n#define debug(x) cerr << \" - \" << #x << \": \" << x << endl;\n#define debugs(x, y) cerr << \" - \" << #x << \": \" << x << \" \" << #y << \": \" << y << endl;\n\ntypedef long long ll;\n\nconst int N = 100000100;\n\nint aa[N];\n\nint main(){\n#ifndef ONLINE_JUDGE\n freopen(\"input\", \"r+\", stdin);\n#endif // ONLINE_JUDGE\n\n int a, b, c, d;\n cin >> a >> b;\n cin >> c >> d;\n\n for(int i = 1; i <= N / 100; i++){\n int r1 = b + i * a;\n int r2 = d + i * c;\n aa[r1]++;\n aa[r2]++;\n }\n\n for(int i = 0; i < N; i++){\n if(aa[i] == 2){\n cout << i << endl;\n return 0;\n }\n }\n cout << -1 << endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dc6e0d463f60f5e268f54696458fff37", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#include\nusing namespace std;\n\nbool arr[1000000001];\n\nint main()\n{\n\tint a, b, d, c;\n\tcin >> a >> b >> c >> d;\n\tif (b==d)\n\t{\n\t\tcout << b;\n\t\treturn 0;\n\t}\n\tunsigned long int result1 = b, result2 = d;\n\twhile (result1 <= 1000000001 )\n\t{\n\t\tarr[result1] = true;\n\t\tresult1 += a;\n\t}\n\twhile (result2 <= 1000000001)\n\t{\n\t\tif (arr[result2])\n\t\t{\n\t\t\tcout << result2;\n\t\t\treturn 0;\n\t\t}\n\t\tresult2 += c;\n\t}\n\tcout << -1;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "12dbcaf46303c34b449df78798a52ad5", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n int c1[100000005];\nint main()\n{\n\t int a,b,c,d,i,j,lo,hi,mid,ans,z;\n\tcin>>a>>b>>c>>d;\n\tif(((a+b)%2==0&&(c+d)%2==1)||((a+b)%2==1&&(c+d)%2==0))\n\t\tcout<<\"-1\";\n\telse\n\t{\n \tfor(i=0;i<100000000;i++)\n \t{\n\n \t\tc1[i]=d+i*c;\n \t\tz=i;\n \t\tif(d+(i+1)*c>1000000000)\n \t\t\tbreak;\n\n \t} \n \tfor(j=0; ;j++)\n \t{\n \t\tlo=0;hi=10;\n \t\twhile(lo<=hi)\n \t\t{\n \t\t\tmid=(lo+hi)/2;\n \t\t\tif(c1[mid]>b+j*a)\n \t\t\t{\n \t\t\t\thi=mid-1;\n \t\t\t}\n \t\t\telse\n \t\t\t{\n \t\t\t\tlo=mid+1;\n \t\t\t\tans=mid;\n \t\t\t}\n \t\t}\n \t\tif(c1[ans]==b+j*a)\n \t\t{\n \t\t\tcout<\n\nusing namespace std;\n\nconst int N = 0.75 * 1e8;\n\nint A[N];\n\nint main() {\n int a, b, c, d;\n cin >> a >> b >> c >> d;\n for (int i = b; i < N; i += a) {\n A[i] = 1;\n }\n for (int i = d; i < N; i += c) {\n if (A[i]) {\n cout << i << endl;\n return 0;\n }\n }\n puts(\"-1\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d5df2d62c506fe0ea6c447f10ebd3053", "src_uid": "158cb12d45f4ee3368b94b2b622693e7", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#include \n#include\n#include\n#include\n#define N 60\n\nusing namespace std;\n\nmap< pair , int > maps ;\npair< char , char > get[N][N] ;\n\nstruct date{\n char a ;\n char b ;\n}map1[60] ;\n\nbool mark[N] ;\nint num = 0 , n , m , t1 , t2 ;\nint firstx[200] , firsty[200] ;\n\nvoid insertmap( char ch ){\n maps[ make_pair( ch , 'C' ) ] = num ++ ;\n map1[num - 1].a = ch ; map1[num - 1].b = 'C' ;\n maps[ make_pair( ch , 'D' ) ] = num ++ ;\n map1[num - 1].a = ch ; map1[num - 1].b = 'D' ;\n maps[ make_pair( ch , 'H' ) ] = num ++ ;\n map1[num - 1].a = ch ; map1[num - 1].b = 'H' ;\n maps[ make_pair( ch , 'S' ) ] = num ++ ;\n map1[num - 1].a = ch ; map1[num - 1].b = 'S' ;\n}\n\nint judge1( int k1 , int k2 ){\n char ch = get[k1][k2].second ;\n for( int i = k1 ; i < k1 + 3 ; i ++ ){\n for( int j = k2 ; j < k2 + 3 ; j ++ ){\n if( ch != get[i][j].second ){\n return 0 ;\n }\n }\n }\n return 1 ;\n}\n\nint judge2( int k1 , int k2 ){\n bool mk[500] ;\n memset( mk , 0 , sizeof( mk ) ) ;\n for( int i = k1 ; i < k1 + 3 ; i ++ ){\n for( int j = k2 ; j < k2 + 3 ; j ++ ){\n if( !mk[ get[i][j].first ] ){\n mk[ get[i][j].first ] = 1;\n }\n else{\n return 0 ;\n }\n }\n }\n return 1 ;\n}\n\nint judge(){\n int sum = 0 ;\n for( int i = 0 ; i < 3 ; i ++ ){\n for( int j = 0 ; j < 3 ; j ++ ){\n for( int k1 = i ; k1 < n ; k1 += 3 ){\n for( int k2 = j ; k2 < m ; k2 += 3 ){\n if( judge1( k1 , k2 ) ){\n firstx[sum] = k1 ;\n firsty[sum ++] = k2 ;\n }\n else{\n if( judge2( k1 , k2 ) ){\n firstx[sum] = k1 ;\n firsty[sum ++] = k2 ;\n }\n }\n }\n }\n }\n }\n for( int i = 0 ; i < sum ; i ++ ){\n for( int j = i + 1 ; j < sum ; j ++ ){\n int x1 = firstx[i] , x2 = firstx[i] + 2 ;\n int y1 = firsty[i] , y2 = firsty[i] + 2 ;\n if( !( ( firstx[j] >= x1 && firstx[j] <= x2 || firstx[j] + 2 >= x1 && firstx[j] + 2 <= x2 ) && ( firsty[j] >= y1 && firsty[j] <= y2 || firsty[j] + 2 >= y1 && firsty[j] + 2 <= y2 ) ) ){\n t1 = i ;\n t2 = j ;\n return 1 ;\n }\n }\n }\n return 0 ;\n}\n\nint main()\n{\n for( int i = 2 ; i <= 9 ; i ++ ){\n insertmap( i + '0' ) ;\n }\n insertmap( 'T' ) ;\n insertmap( 'Q' ) ;\n insertmap( 'K' ) ;\n insertmap( 'A' ) ;\n int ans = 0 ;\n char str[10] ;\n int x[2] , y[2] ;\n while(cin>>n>>m){\n\n memset( mark , 0 , sizeof( mark ) ) ;\n ans = 0 ;\n for( int i = 0 ; i < n ; i ++ ){\n for( int j = 0 ; j < m ; j ++ )\n {\n\n scanf( \"%s\" , str ) ;\n get[i][j].first = str[0] ;\n get[i][j].second = str[1] ;//cout< get[x[1]][y[1]].second ){\n int as = x[0] , bs = y[0] ;\n x[0] = x[1] ;\n y[0] = y[1] ;\n x[1] = as ;\n y[1] = bs ;\n }\n str[0] = '1' ;\n str[1] = '2' ;\n }\n else{\n if( ans == 1 ){\n str[0] = get[ x[0] ][ y[0] ].second ;\n }\n }\n if( ans == 0 ){\n if( !judge() ){\n printf( \"No solution.\\n\" ) ;\n }\n else{\n printf( \"Solution exists.\\n\" ) ;\n printf( \"There are no jokers.\\n\" ) ;\n printf( \"Put the first square to (%d, %d).\\nPut the second square to (%d, %d).\\n\" , firstx[t1] + 1 , firsty[t1] + 1 , firstx[t2] + 1, firsty[t2] + 1 ) ;\n }\n }\n else{\n if( ans == 1 ){\n int flag = 0 ;\n for( int i = 0 ; i < num ; i ++ ){\n if( !mark[i] ){\n get[ x[0] ][ y[0] ].first = map1[i].a ;\n get[x[0] ][ y[0] ].second = map1[i].b ;\n if( judge() ){\n printf( \"Solution exists.\\n\" ) ;\n printf( \"Replace J%c with %c%c.\\n\" , str[0] , map1[i].a , map1[i].b ) ;\n printf( \"Put the first square to (%d, %d).\\nPut the second square to (%d, %d).\\n\" , firstx[t1] + 1 , firsty[t1] + 1 , firstx[t2] + 1, firsty[t2] + 1 ) ;\n flag = 1 ;\n break ;\n }\n }\n }\n if( !flag ){\n printf( \"No solution.\\n\" ) ;\n }\n }\n else{\n int flag = 0 ;\n int j ;\n for( int i = 0 ; i < num ; i ++ ){\n if( !mark[i] )\n {\n for( j = 0 ; j < num ; j ++ ){\n if( !mark[j] && i != j ){\n get[ x[0] ][ y[0] ].first = map1[i].a ;\n get[ x[0] ][ y[0] ].second = map1[i].b ;\n get[ x[1] ][ y[1] ].first = map1[j].a ;\n get[ x[1] ][ y[1] ].second = map1[j].b ;\n if( judge() ){\n flag = 1;\n break ;\n }\n }\n }\n }\n if( flag ){\n printf( \"Solution exists.\\n\" ) ;\n printf( \"Replace J1 with %c%c and J2 with %c%c.\\n\" , map1[i].a , map1[i].b , map1[j].a , map1[j].b) ;\n printf( \"Put the first square to (%d, %d).\\nPut the second square to (%d, %d).\\n\" , firstx[t1] + 1 , firsty[t1] + 1 , firstx[t2] + 1, firsty[t2] + 1 ) ;\n break ;\n }\n }\n if( !flag ){\n printf( \"No solution.\\n\" ) ;\n }\n }\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4892de14eb17a0ba52fb0e9ada66c09f", "src_uid": "b3f29d9c27cbfeadb96b6ac9ffd6bc8f", "difficulty": 2200.0} {"lang": "GNU C++", "source_code": "/*\n * main.cpp\n *\n * Created on: 29.03.2011\n * Author: skird\n */\n\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint cost(char c)\n{\n\tif (c >= '2' && c <= '9') return c - '2';\n\tif (c == 'T') return 8;\n\tif (c == 'J') return 9;\n\tif (c == 'Q') return 10;\n\tif (c == 'K') return 11;\n\treturn 12;\n}\n\nint color(char c)\n{\n\tif (c == '1') return 100500;\n\tif (c == '2') return 100600;\n\tif (c == 'C') return 0;\n\tif (c == 'D') return 1;\n\tif (c == 'H') return 2;\n\treturn 3;\n}\n\nstruct Card\n{\n\tint p, c;\n\n\tCard() {}\n\tCard(int _p, int _c): p(_p), c(_c) {}\n\tCard(istream &in)\n\t{\n\t\tstring token;\n\t\tcin >> token;\n\t\tp = cost(token[0]);\n\t\tc = color(token[1]);\n\t}\n\n\tbool isJoker()\n\t{\n\t\treturn c == 100500 || c == 100600;\n\t}\n};\n\nbool operator < (Card a, Card b)\n{\n\treturn a.p < b.p || (a.p == b.p && a.c < b.c);\n}\n\nint n, m;\nvector< vector > data;\n\nbool goodSquare(int x, int y)\n{\n\tint used[20];\n\tfill(used, used + 20, 0);\n\tbool ok = true;\n\tfor (int i = 0; i < 3; i++)\n\t\tfor (int j = 0; j < 3; j++)\n\t\t{\n\t\t\tused[data[x + i][y + j].p]++;\n\t\t\tif (data[x + i][y + j].c != data[x][y].c) ok = false;\n\t\t}\n\tif (ok) return true;\n\tok = true;\n\tfor (int i = 0; i < 20; i++)\n\t\tok &= used[i] <= 1;\n\treturn ok;\n}\n\nbool cross(pair a, pair b)\n{\n\tint dx = abs(a.first - b.first), dy = abs(b.second - a.second);\n\treturn dx < 3 && dy < 3;\n}\n\npair< pair, pair > isOk()\n{\n\tvector< pair > squares;\n\tfor (int i = 0; i + 2 < n; i++)\n\t\tfor (int j = 0; j + 2 < m; j++)\n\t\t\tif (goodSquare(i, j)) squares.push_back(make_pair(i, j));\n\tfor (size_t i = 0; i < squares.size(); i++)\n\t\tfor (size_t j = 0; j < squares.size(); j++)\n\t\t\tif (!cross(squares[i], squares[j])) return make_pair(squares[i], squares[j]);\n\treturn make_pair(make_pair(-1, -1), make_pair(-1, -1));\n}\n\nset rest;\nvector< pair > jokers;\n\nvoid print(pair x)\n{\n\tCard c = data[x.first][x.second];\n\tif (c.p >= 0 && c.p < 8) cout << (char) (c.p + '2');\n\telse\n\t{\n\t\tswitch (c.p)\n\t\t{\n\t\t\tcase 8: cout << \"T\"; break;\n\t\t\tcase 9: cout << \"Q\"; break;\n\t\t\tcase 10: cout << \"J\"; break;\n\t\t\tcase 11: cout << \"K\"; break;\n\t\t\tcase 12: cout << \"A\"; break;\n\t\t}\n\t}\n\tswitch (c.c)\n\t{\n\t\tcase 100500: cout << \"1\"; break;\n\t\tcase 100600: cout << \"2\"; break;\n\t\tcase 0: cout << \"C\"; break;\n\t\tcase 1: cout << \"D\"; break;\n\t\tcase 2: cout << \"H\"; break;\n\t\tcase 3: cout << \"S\"; break;\n\t}\n}\n\npair< pair, pair > rec(int r)\n{\n\tif (r == 0) return isOk();\n\tset::iterator it;\n\tint x = jokers[r - 1].first, y = jokers[r - 1].second;\n\tfor (it = rest.begin(); it != rest.end(); it++)\n\t{\n\t\tCard c = *it;\n\t\trest.erase(c);\n\t\tCard copy = data[x][y];\n\t\tdata[x][y] = c;\n\t\tpair< pair, pair > temp = rec(r - 1);\n\t\tif (temp.first.first != -1) return temp;\n\t\tdata[x][y] = copy;\n\t\trest.insert(c);\n\t}\n\treturn make_pair(make_pair(-1, -1), make_pair(-1, -1));\n}\n\nint main()\n{\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif\n\tcin >> n >> m;\n\tdata.assign(n, vector(m));\n\tfor (int i = 0; i < 13; i++)\n\t\tfor (int j = 0; j < 4; j++)\n\t\t\trest.insert(Card(i, j));\n\tvector some;\n\tfor (int i = 0; i < n; i++)\n\t\tfor (int j = 0; j < m; j++)\n\t\t{\n\t\t\tdata[i][j] = Card(cin);\n\t\t\tif (!data[i][j].isJoker()) rest.erase(data[i][j]);\n\t\t\tif (data[i][j].isJoker())\n\t\t\t\tjokers.push_back(make_pair(i, j)), some.push_back(data[i][j].c);\n\t\t}\n\tpair< pair, pair > temp = rec(jokers.size());\n\tif (temp.first.first == -1)\n\t{\n\t\tcout << \"No solution.\";\n\t\treturn 0;\n\t}\n\tcout << \"Solution exists.\" << endl;\n\tif (jokers.size() == 0) cout << \"There are no jokers.\" << endl;\n\telse if (jokers.size() == 1)\n\t{\n\t\tcout << \"Replace J\" << (some[0] == 100500 ? 1 : 2) << \" with \";\n\t\tprint(jokers[0]);\n\t\tcout << \".\" << endl;\n\t}\n\telse\n\t{\n\t\tif (some[0] != 100500) swap(jokers[0], jokers[1]);\n\t\tcout << \"Replace J1 with \", print(jokers[0]);\n\t\tcout << \" and J2 with \", print(jokers[1]);\n\t\tcout << \".\" << endl;\n\t}\n\tcout << \"Put the first square to (\" << temp.first.first + 1 << \", \" << temp.first.second + 1 << \").\" << endl;\n\tcout << \"Put the second square to (\" << temp.second.first + 1 << \", \" << temp.second.second + 1 << \").\";\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "26b1ce226a1f06544ec353ae512dabcd", "src_uid": "b3f29d9c27cbfeadb96b6ac9ffd6bc8f", "difficulty": 2200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint n,m,cnt;\nstring a[20][20];\nstruct node{int x,y;}p[2],ans[2];\nnode f[1000];\nset have;\nbool check()\n{\n int num=0;\n // cout<<\"F\"<g,gg;\n for(int i=0;i=3||abs(f[i].y-f[j].y)>=3))\n {\n ans[0]=f[i];\n ans[1]=f[j];\n return 1;\n }\n return 0;\n\n}\nchar m1[15]={'2','3','4','5','6','7','8','9','T','J','Q','K','A'};\nchar m2[4]={'C','D','H','S'};\nint caocao=0;\nvoid out()\n{\n printf(\"Put the first square to (%d, %d).\\n\",ans[0].x+1,ans[0].y+1);\n printf(\"Put the second square to (%d, %d).\\n\",ans[1].x+1,ans[1].y+1);\n}\nint main()\n{\n // freopen(\"in.txt\",\"r\",stdin);\n cin>>n>>m;\n for(int i=0;i>a[i][j];\n have.insert(a[i][j]);\n if(a[i][j][0]=='J')\n {\n caocao=a[i][j][1]-'1';\n p[a[i][j][1]-'1'].x=i;\n p[a[i][j][1]-'1'].y=j;cnt++;\n }\n }\n if(cnt==0)\n {\n if(check())\n {\n printf(\"Solution exists.\\n\");\n printf(\"There are no jokers.\\n\");\n out();\n }else\n printf(\"No solution.\\n\");\n }\n else\n {\n if(cnt==1)\n {\n for(int i=0;i<13;i++)\n for(int j=0;j<4;j++)\n {\n string k;\n k+=m1[i];\n k+=m2[j];\n //cout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nstring a[100][100];\nstring f[]={\"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\" ,\"A\"};\nstring p[]={\"C\", \"D\", \"H\" , \"S\"};\nint n,m,jk=0,ok=0;\nsetst;\nvectorout;\nstring ff[]={\"J1\",\"J2\"};\nbool check(int x,int y)\n{\n int i,j,k;\n int vis[130]={0};\n for (i=x;i::iterator ptr=st.begin();ptr!=st.end();++ptr)\n {\n string tmp=*ptr;\n st.erase(tmp);\n string tt=a[x][y];\n a[x][y]=tmp;\n out.push_back(\"Replace \"+ff[now]+\" with \"+tmp+\".\");\n dfs(now+1);\n out.pop_back();\n st.insert(tmp);\n a[x][y]=tt;\n }\n}\nint main()\n{\n int i,j,k;\n for (i=0;i<13;i++)\n {\n for (j=0;j<4;j++)\n {\n st.insert(f[i]+p[j]);\n }\n }\n cin>>n>>m;\n for (i=0;i>a[i][j];\n if (a[i][j][0]!='J')st.erase(a[i][j]);\n else ++jk;\n }\n }\n dfs(0);\n if (!ok)puts(\"No solution.\");\n return 0;\n}\n ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0549414cc37de28f079749d9179019e2", "src_uid": "b3f29d9c27cbfeadb96b6ac9ffd6bc8f", "difficulty": 2200.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n\tint n, m, k;\n\tcin >> n >> m >> k;\n\tint a[102];\n\tfor (int l = 1; l <= n; l++) cin >> a[l];\n\tint i = m, j = m;\n\t\n\twhile (i <= n)\n\t{\n\t\ti++;\n\t\tif (a[i] <= k && a[i] != 0) break;\n\t\tif (i == n)\n\t\t{\n\t\t\ti = m;\n\t\t\tbreak;\n\t\t}\n\t}\n\twhile (j >= 2)\n\t{\n\t\tj--;\n\t\tif (a[j] <= k && a[j] != 0)break;\n\t\tif (j == 2)\n\t\t{\n\t\t\tj = m; break;\n\t\t}\n\t}\n\tif (i != m && j != m)\n\t{\n\t\tif (i - m > m - j)cout << (m - j) * 10;\n\t\tif (i - m <= m - j)cout << (i - m) * 10;\n\t}\n\telse if (j == m)cout << (i - m) * 10;\n\telse cout << (m - j) * 10;\n\t_getch();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fd7999b03af84c681b32ddf4c0668963", "src_uid": "57860e9a5342a29257ce506063d37624", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n\nusing namespace std;\n\nvoid main(){\n\tint n, m, k, *t, x;\n\tcin>>n>>m>>k;\n\tt = new int[n];\n\tx=n*100;\n\tint dist=x;\n\tfor(int i=0;i>t[i];\n\t\tif(t[i]!=0 && t[i]<=k)\n\t\t\tdist=abs((i+1-m)*10);\n\t\tif(dist\n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n\tint n, m, k;\n\tcin >> n >> m >> k;\n\tint a[102];\n\tfor (int i = 1; i <= n; i++) cin >> a[i];\n\tint i = m, j = m;\n\t\n\twhile (i <= n)\n\t{\n\t\ti++;\n\t\tif (a[i] <= k && a[i] != 0) break;\n\t}\n\twhile (j >= 2)\n\t{\n\t\tj--;\n\t\tif (a[j] <= k && a[j] != 0)break;\n\t}\n\tif (i - m > m - j && j != m)cout << (m - j) * 10;\n\tif (i - m >= m - j && i != m)cout << (i - m) * 10;\n\t_getch();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dff8837e0d4b8bc061d25e3a9bd66fbd", "src_uid": "57860e9a5342a29257ce506063d37624", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n\n#include \n#include \n#include \n\nint main()\n{\n\tint n,m,k,i,j=1,cost,ans;\n\t\n\tscanf(\"%d %d %d\",&n,&m,&k);\n\tint ara[n+1];\n\tmemset(ara,0,sizeof(ara));\n\tfor(i=1;i<=n;i++)\n\t{\t\n\t\tscanf(\"%d\",&ara[i]);\n\t}\n\tcost=999999;\n\n\tfor(i=m+1;i<=n;i++)\n\t{\n\t\tif(ara[i]<=k && ara[i]!=0)\n\t\t{\n\t\t\t\tcost=10*j;\n\t\t\t\tbreak;\n\n\t\t}\n\t\tj++;\n\t}\n\tj=1;\n\tint store=999999;\n\tfor(i=m-1;i>=1;i--)\n\t{\n\t\tif(ara[i]<=k && ara[i]!=0)\n\t\t{\n\t\t\t\tstore=10*j;\n\t\t\t\tbreak;\n\t\t}\n\t\tj++;\n\t}\n\tif(store\nusing namespace std;\nint a[9000][9000];\nint main(){\n int a1,a2,a3,b1,b2,b3;\n cin >> a1 >> b1;\n cin >> a2 >> b2;\n cin >> a3 >> b3;\n int c1,c2,c3,d1,d2,d3;\n c1 = a1-a2;\n c2 = a2-a3;\n c3 = a3-a1;\n d1 = b1-b2;\n d2 = b2-b3;\n d3 = b3-b1;\n cout << \"3\"<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define pb push_back\n#define mp make_pair\n#define pll pair \n#define plll pair >\n\nusing namespace std;\nll mark[6007][6007];\nvector v;\nint main()\n{\n ll x,y,x1,x2,x3,y1,y2,y3,i;\n cin>>x1>>y1;\n cin>>x2>>y2;\n cin>>x3>>y3;\n x=x1+x2-x3;\n y=y1+y2-y3;\n if(mark[3000+x][3000+y]==0)\n {\n v.pb(mp(x,y));\n mark[3000+x][3000+y]=1;\n }\n x=x1+x3-x2;\n y=y1+y3-y2;\n if(mark[3000+x][3000+y]==0)\n {\n v.pb(mp(x,y));\n mark[3000+x][3000+y]=1;\n }\n x=x2+x1-x3;\n y=y2+y1-y3;\n if(mark[3000+x][3000+y]==0)\n {\n v.pb(mp(x,y));\n mark[3000+x][3000+y]=1;\n }\n x=x2+x3-x1;\n y=y2+y3-y1;\n if(mark[3000+x][3000+y]==0)\n {\n v.pb(mp(x,y));\n mark[3000+x][3000+y]=1;\n }\n x=x3+x1-x2;\n y=y3+y1-y2;\n if(mark[3000+x][3000+y]==0)\n {\n v.pb(mp(x,y));\n mark[3000+x][3000+y]=1;\n }\n x=x3+x2-x1;\n y=y3+y2-y1;\n if(mark[3000+x][3000+y]==0)\n {\n v.pb(mp(x,y));\n mark[3000+x][3000+y]=1;\n }\n cout<\nusing namespace std;\n\nint x[10], y[10];\nbool a[20000][20000];\n\nint main(){\n//\tfreopen(\"C.in\", \"r\", stdin);\n//\tfreopen(\"C.out\", \"w\", stdout);\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n\tfor (int i=1; i<=3; i++){\n\t\tcin >> x[i] >> y[i];\n\t}\n\tcout << '3' << endl;\n\tcout << x[3]+(x[1]-x[2]) << ' ' << y[3]+(y[1]-y[2]) << endl;\n\tcout << x[3]+(x[2]-x[1]) << ' ' << y[3]+(y[2]-y[1]) << endl;\n\ta[10000+x[3]+(x[1]-x[2])][10000+y[3]+(y[1]-y[2])]=1;\n\ta[10000+x[3]-(x[2]-x[1])][10000+y[3]+(y[2]-y[1])]=1;\n\tif (!a[10000+x[1]+(x[3]-x[2])][10000+y[1]+(y[3]-y[2])]){\n\t\tcout << x[1]+(x[3]-x[2]) << ' ' << y[1]+(y[3]-y[2]);\n\t\treturn 0;\n\t}\n\telse{\n\t\tcout << x[1]+(x[2]-x[3]) << ' ' << y[1]+(y[2]-y[3]);\n\t\treturn 0;\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2bf3ef0b96723fa5ea752d534384cb4c", "src_uid": "7725f9906a1b87bf4e866df03112f1e0", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n\nusing namespace std;\n\nint main()\n{\n\tint x1, y1, x2, y2, x3, y3;\n\tcin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;\n\tcout << 3 << endl;\n\tcout\n\t\t<< (x2 + x3 - x1) << \" \" << (y2 + y3 - y1) << endl\n\t\t<< (x1 + x3 - x2) << \" \" << (y1 + y3 - y2) << endl\n\t\t<< (x1 + x2 - x3) << \" \" << (y1 + y2 - y3) << endl;\n\n_getch();\nreturn(0);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1c07eed7bc4a1912cb5488abbf1d4b94", "src_uid": "7725f9906a1b87bf4e866df03112f1e0", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\n#define fr(i, a, b) for (i = a; i < b; ++i)\n#define fr2(i, b, a) for (i = b; i >= a; --i)\n#define vll vector\n#define llp pair\n#define vllp vector>\n#define pb push_back\n\n#define set0(a) memset(a, 0, sizeof(a))\n#define setneg(a) memset(a, -1, sizeof(a))\n#define setinf(a) memset(a, 126, sizeof(a))\n#define trace(a) cerr << #a << \": \" << a << endl\n\n#define N 1000000007\n#define PI acos(-1.0)\n\ntypedef long long int ll;\ntypedef unsigned long long ull;\n\nll Npow(ll x, ll n, ll M = 1000000007)\n{\n\tif (n == 0)\n\t\treturn 1;\n\telse if (n % 2 == 0)\n\t\treturn Npow((x * x) % M, n / 2, M);\n\treturn (x * Npow((x * x) % M, (n - 1) / 2, M)) % M;\n}\nvoid print()\n{\n\t;\n}\ntemplate \nvoid print(T var1, Types... var2)\n{\n\tcout << var1 << \" \";\n\tprint(var2...);\n}\n\ntemplate \nvoid show(T *a, int size)\n{\n\tint i;\n\tcout << endl\n\t\t << \"The array is \";\n\tfr(i, 0, size)\n\t{\n\t\tcout << a[i] << \" \";\n\t}\n\tcout << endl;\n}\n\ntemplate \nvoid show_vector(vector v)\n{\n\tcout << endl\n\t\t << \"The vector is \";\n\tint i;\n\tfr(i, 0, v.size())\n\t{\n\t\tcout << v[i] << \" \";\n\t}\n\tcout << endl;\n}\n//GLOBAL\n#define M 10\n//FUNCTIONS\nll n, k;\n\nll func(ll x)\n{\n\tif (x <= n)\n\t{\n\t\tll layers = floor(log2(n / x));\n\t\tll ans = (1 << layers) - 1;\n\t\tif (n < x * (1 << layers) + (1 << layers))\n\t\t{\n\t\t\tans += (n - x * (1 << layers) + 1);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tans += (1 << layers);\n\t\t}\n\t\treturn ans;\n\t}\n\telse\n\t{\n\t\treturn 0;\n\t}\n}\n\nbool possible(ll x)\n{\n\tif (x % 2 == 0)\n\t{\n\t\treturn func(x) + func(x + 1) >= k;\n\t}\n\telse\n\t{\n\t\treturn func(x) >= k;\n\t}\n}\n\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(0);\n\tcout.tie(0);\n\n\tcin >> n >> k;\n\tll high, low, mid;\n\tll i;\n\n\tlow = 0;\n\thigh = n / 2;\n\twhile (true)\n\t{\n\t\tmid = (low + high) / 2;\n\t\tif (possible(2 * mid))\n\t\t{\n\t\t\tif (!possible(2 * mid + 2))\n\t\t\t{\n\t\t\t\tif (possible(2 * mid + 1))\n\t\t\t\t{\n\t\t\t\t\tcout << 2 * mid + 1 << endl;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tcout << 2 * mid << endl;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tlow = mid + 1;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\thigh = mid - 1;\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "acd4ac679ac72390033c0380d30415b2", "src_uid": "783c4b3179c558369f94f4a16ac562d4", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "#include\n#define ll long long\n#define pb push_back\n#define mp make_pair\n#define fr first\n#define sc second\n#define vec vector\n#define bg begin\n#define pri pair < int,int >\n#define prl pair < ll,ll >\n \n// \"\\n\" scanf(\"%d\",&a) printf(\"%d \", ind-lst) printf(\"%I64d\",ans) scanf(\"%lld\", &a);\nusing namespace std;\nll n,m,p,q,i,j,k,x,y,z,c,d,l,r,l1,l2,lst,a,b,mn,mx,cnt,cur,u,v,w; // ll n,m,p,s,q,t,i,j,k,x,y,z,c,d,l,r,l1,l2,lst,a,b,mn,mx,cnt,cur,u,v,w;\nmap obs;\nll count(ll num){\n\tif(num%2==1){\n\t\tif(num*2>n) return 1;\n\t\tif(!obs[num*2]) obs[num*2] = count(num*2);\n\t\treturn 1+obs[num*2];\n\t}\n\telse{\n\t\tll ret = 1;\n\t\tif(num*2<=n){\n\t\t\tif(!obs[num*2]) obs[num*2] = count(num*2);\n\t\t\t ret+=obs[num*2];\n\t\t}\n\t\tif(num+1<=n){\n\t\t\tif(!obs[num+1]) obs[num+1] = count(num+1);\n\t\t\tret+=obs[num+1];\n\t\t}\n\t\treturn ret;\n\t}\n}\n \nbool ok(ll p){\n\tif(count(p)>=k) return true;\n\telse return false;\t\t\n}\n \nint main(){\n\tcin >> n >> k;\n\tl = 2;\n\tr = n-n%2;\n\tll lastl = -1,lastr = -1;\n\twhile(!(l==lastl&&r==lastr)){\n\t\tll mid = l+(r-l)/2;\n\t\tmid-=mid%2;\n\t\tlastl = l;\n\t\tlastr = r;\n\t\tif(ok(mid)) l = mid;\n\t\telse r = mid;\n\t}\n\tll q = 1;\n\tif(ok(l)) q=l;\n\tif(ok(r)) q=r;\n\tl = 1;\n\tr = n-(1-n%2);\n\tlastl = -1,lastr = -1;\n\twhile(!(l==lastl&&r==lastr)){\n\t\tll mid = l+(r-l)/2;\n\t\tmid-=(1-mid%2);\n\t\tlastl = l;\n\t\tlastr = r;\n\t\tif(ok(mid)) l = mid;\n\t\telse r = mid;\n\t}\n\tx = 1;\n\tif(ok(l)) x = l;\n\tif(ok(r)) x = r;\n\tcout << max(q,x);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4499566e7cc4b3c9206d16b9c171c33e", "src_uid": "783c4b3179c558369f94f4a16ac562d4", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\ntypedef long long int ll;\n//typedef long long int lli;\nll mod=1e9+7;\n#include\nll mod1=998244353;\ntypedef pair pll;\ntypedef pair pint;\ntypedef priority_queue,greater > pqset;\n#define pb push_back\n#define fi first\n#define se second\n#include\n#include\nusing namespace __gnu_pbds;\ntypedef tree , rb_tree_tag , tree_order_statistics_node_update> os;\n#define mp make_pair\n#define acc (ios::sync_with_stdio(false),cin.tie(0))\n#define rep(i,n) for(int i=0;i=0;i--)\n#define rep1(i,n) for(int i=1;i<=n;i++)\n#define per1(i,n) for(int i=n;i>0;i--)\nll fact[100001];\nbool prime[100001];\nll ll_max(ll a,ll b,ll c){\n\treturn max(a,max(b,c));\n}\nint int_max(int a,int b,int c){\n\treturn max(a,max(b,c));\n}\nll ll_min(ll a,ll b,ll c){\n\treturn min(a,min(b,c));\n}\nint int_min(int a,int b,int c){\n\treturn min(a,min(b,c));\n}\nll gcd(ll a,ll b,ll c){\n\treturn __gcd(a,__gcd(b,c));\n}\nvoid sieve(int n)\n{\n memset(prime, true, sizeof(prime)); \n for (int p=2; p*p<=n; p++) \n { \n if (prime[p] == true) \n { \n for (int i=p*p; i<=n; i += p) \n prime[i] = false; \n } \n } \n}\ndouble dist(ll i1,ll j1,ll k1,ll i2,ll j2,ll k2){\n\tdouble a=pow((i1-i2),2)+pow((j1-j2),2)+pow((k1-k2),2);\n\ta=sqrt(a);\n\treturn a;\n}\nbool compare(pair a,pair b){\n\tif(a.firstb.second)\n\t\t\treturn true;\n\t\telse\n\t\t\treturn false;\n\t}\n\telse\n\t\treturn false;\n}\nvoid buildTree(int arr[],int tree[], int start,int end,int node){\n\tif(start==end){\n\t\ttree[node]=arr[start];\n\t\treturn;\n\t}\n\tint mid=(start+end)/2;\n\tbuildTree(arr,tree,start,mid,2*node);\n\tbuildTree(arr,tree,mid+1,end,2*node+1);\n\ttree[node]=tree[2*node]+tree[2*node+1];\n}\nbool sortbysec(const pair &a,const pair &b){\n return (a.second < b.second); \n}\nll pow(ll a,ll b){\n\tif(a==1)\n\t\treturn 1;\n\tif(b==0)\n\t\treturn 1;\n\tll c=pow(a,b/2);\n\tll res=1;\n\tif(b%2){\n\t\tres=(c*c);\n\t\tres*=a;;\n\t}\n\telse\n\t\tres=(c*c);\n\treturn res;\n}\n\nint lower_bound1(vector v,int n,int p){\n\tint l=0;\n\tint r=n;\n\tif(v[0]>=p)\n\t\treturn 0;\n\twhile(lp)\n\t\t\tr=mid;\t\n\t}\n\treturn l;\n}\nvoid bfs(vector v[],int n,int a1,int b,bool visited[],int &count){\n\tqueue q;\n\tq.push(a1);\n\tq.push(b);\n\twhile(q.empty()==false){\n\t\tint a=q.front();\n\t\tq.pop();\n\t\tfor(int i=0;i v[]){\n\tfor(int j=0;j=k){\n\t\t\treturn true;\n\t\t}\n\t\tx++;\n\t}\n\treturn false;\n\t\n}\nvoid solve(){\n\tll n,k;\n\tcin>>n>>k;\n\tif(k==1){\n\t\tcout<>t;\n while(t--){\n \tsolve();\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9120ab36a09d647bf5e9a54e10eb3b45", "src_uid": "783c4b3179c558369f94f4a16ac562d4", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define mp make_pair\n#define pb push_back\n#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];} \n#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<= 0 ; i--){\n if(x[i] == '1') res += p;\n p *= 2;\n }\n return res;\n}\n \nbool check(int mid){\n string m = binarystr(mid);\n if(m.size() > n.size()) return false;\n int c = n.size() - m.size();\n int p = 1;\n if(m[m.size() - 1] == '0') p = 2;\n int res = 0;\n for(int i = 0 ; i < c; i++){\n res += p;\n p *= 2;\n }\n string ss = n.substr(0 , m.size());\n if(ss == m){\n int x = backtoint(n.substr(m.size()));\n res += x + 1;\n }else if(ss > m){\n if(m[m.size() - 1] == '0'){\n if(backtoint(ss) - backtoint(m) > 1){\n res += 2 * pow(2LL, c);\n }else if(backtoint(ss) - backtoint(m) == 1){\n int x = backtoint(n.substr(m.size()));\n res += x + 1;\n res += pow(2LL, c);\n }\n }else res += pow(2LL, c);\n }\n return res >= k;\n}\n \nint32_t main(){\n ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n cin>>nn>>k;\n if(nn == k){\n cout<<1<\n#include\n#include\n#include\n#include\n#define len(i,j) (abs(a[i].x-a[j].x)+abs(a[i].y-a[j].y))\ntypedef long long LL;\nconst LL INF=0x3f3f3f3f3f3f3f3f;\nconst int maxn=2e5+10;\nusing namespace std;\n\ntemplate inline _Tp Max(_Tp a,_Tp b){return a>b?a:b;} \ntemplate inline _Tp Min(_Tp a,_Tp b){return ab.y;\n else return a.x\nvoid gi(_Tp &x){\n x=0;\n char ch=getchar(),lst=' ';\n while (!isdigit(ch)){lst=ch;ch=getchar();}\n while (isdigit(ch)) {x=(x<<1)+(x<<3)+(ch&15);ch=getchar();}\n if (lst=='-') x=-x;\n}\n\n\nint main(){\n freopen(\"odyssey.in\",\"r\",stdin);\n freopen(\"odyssey.out\",\"w\",stdout);\n gi(n);\n int x,y;\n for (int i=1;i<=n;++i) {gi(x);gi(y);a[i]=point(x,y);}\n sort(a+1,a+n+1,cmp);\n for (int i=1;i<=n;++i) {printf(\"%d %d %d\\n\",a[i].x,a[i].y,a[i].r);}\n int p=0;\n int size=1;\n while (p\n#include \n#include \n#include \n\nusing namespace std;\nconst int Maxn = 11000000;\nconst int mod = 1000000007;\nlong long table[Maxn][5];\n\nint main(){\n\n char temp[Maxn];\n scanf(\"%s\",temp+1);\n memset(table,0,sizeof(table));\n table[0][0] = 1;\n table[0][1] = 1;\n table[0][2] = 0;\n table[0][3] = 0;\n int n = strlen(temp+1);\n for(int i=1;i\n#define DIM 200007\n#define INF 1000000007\nusing namespace std;\n\nlong long n;\nmap > l,r;\nmap dp[2];\n\nlong long dist(pair p1, pair p2)\n{\n return abs(p1.first - p2.first) + abs(p1.second - p2.second);\n}\nint main()\n{\n scanf(\"%lld\",&n);\n for(int i = 1; i <= n; ++i)\n {\n long long x,y;\n scanf(\"%lld %lld\",&x,&y);\n long long lvl = max(x,y);\n if(l.count(lvl) == 0)\n {\n l[lvl] = {x,y};\n r[lvl] = {x,y};\n }\n else\n {\n if(x < l[lvl].first || (x==l[lvl].first && y > l[lvl].second))\n l[lvl] = {x,y};\n\n if(x > r[lvl].first || (x==r[lvl].first && y < r[lvl].second))\n r[lvl] = {x,y};\n }\n }\n\n l[0] = {0,0};\n r[0] = {0,0};\n dp[0][0] = dp[1][0] = 0;\n for(int i = 1; i < l.size(); ++i)\n {\n dp[0][i] = min(dp[0][i-1] + dist(l[i-1],r[i]) + dist(r[i],l[i]),dp[1][i-1] + dist(r[i-1],r[i]) + dist(r[i],l[i]));\n dp[1][i] = min(dp[0][i-1] + dist(l[i-1],l[i]) + dist(l[i],r[i]),dp[1][i-1] + dist(r[i-1],l[i]) + dist(l[i],r[i]));\n }\n printf(\"%lld\",min(dp[0][l.size()-1],dp[1][l.size()-1]));\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a6026313fce206b833abd01c122e41ba", "src_uid": "06646a9bdce2d65e92e525e97b2c975d", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "#include \n#define DIM 200007\n#define INF 1000000007\nusing namespace std;\n\nlong long n;\nmap > l,r;\nmap dp[2];\n\nlong long dist(pair p1, pair p2)\n{\n return abs(p1.first - p2.first) + abs(p1.second - p2.second);\n}\nint main()\n{\n scanf(\"%lld\",&n);\n for(int i = 1; i <= n; ++i)\n {\n long long x,y;\n scanf(\"%lld %lld\",&x,&y);\n long long lvl = max(x,y);\n if(l.count(lvl) == 0)\n {\n l[lvl] = {x,y};\n r[lvl] = {x,y};\n }\n else\n {\n if(x < l[lvl].first || (x==l[lvl].first && y > l[lvl].second))\n l[lvl] = {x,y};\n\n if(x > r[lvl].first || (x==r[lvl].first && y < r[lvl].second))\n r[lvl] = {x,y};\n }\n }\n\n l[0] = {0,0};\n r[0] = {0,0};\n dp[0][0] = dp[1][0] = 0;\n for(int i = 1; i < (long long)l.size(); ++i)\n {\n dp[0][i] = min(dp[0][i-1] + dist(l[i-1],r[i]) + dist(r[i],l[i]),dp[1][i-1] + dist(r[i-1],r[i]) + dist(r[i],l[i]));\n dp[1][i] = min(dp[0][i-1] + dist(l[i-1],l[i]) + dist(l[i],r[i]),dp[1][i-1] + dist(r[i-1],l[i]) + dist(l[i],r[i]));\n }\n printf(\"%lld\",min(dp[0][(long long)l.size()-1],dp[1][(long long)l.size()-1]));\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8bb40154b7df4c2cd4e865ce2cebbcd3", "src_uid": "06646a9bdce2d65e92e525e97b2c975d", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nint main()\n{\n int a[2];\n cin >> a[0] >> a[1] >> a[2];\n sort(a,a+2);\n if ((a[0]+a[1])>=a[2])\n {\n cout << 0 << '/n';\n }\n else\n {\n cout << (a[2]-(a[1]+a[0])) <<'/n';\n }\n \n\n\n\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e774d7b1eeb0f3341abb49cf93ad47d6", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nstruct node {\n\tint x, y, z, cnt;\n\tnode(int x,int y,int z, int cnt) : x(x), y(y), z(z), cnt(cnt) {}\n\tbool operator < (const node & a) const {\n\t\treturn cnt > a.cnt;\n\t}\n};\nbool check(node a) {\n\tint x = a.x, y = a.y, z = a.z;\n\tif(x < y + z && y < x + z && z < x + y) return 1;\n\treturn 0;\n}\nint main() {\n\tpriority_queue q;\n\tint x, y, z;\n\tscanf(\"%d %d %d\",&x, &y, &z);\n\tq.push(node(x,y,z,0));\n\twhile(!q.empty()) {\n\t\tnode cur = q.top();\n\t\tq.pop();\n\t\tif(check(cur)) {\n\t\t\tprintf(\"%d\\n\",cur.cnt);\n\t\t\treturn 0;\n\t\t}\n\t\tcur.cnt++;\n\t\tcur.x++;q.push(cur);\n\t\tcur.x--;cur.y++;q.push(cur);\n\t\tcur.y--;cur.z++;q.push(cur);\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2ae0e5159972872c1ccaa7fa6dffe217", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int x,y,z;\n cin>>x>>y>>z;\n\n int mx=max(x,max(y,z));\n int p=(x+y+z)/2;\n if(mx\n#include \n\nusing namespace std;\n\nint main() {\n\tint a, b, c, m = 0;\n\tcin >> a >> b >> c;\n\n\n\tif (a + b <= c) {\n\t\tm = c - a - b + 1;\n\t}\n\telse if (a + c <= b) {\n\t\tm = b - a - c + 1;\n\t}\n\telse if (b + c <= a) {\n\t\tm = a - c - b + 1;\n\t}\n\t\n\tcout << m;\n\t_getch();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d9d5fd97d107331cc1e9c7b2ae44b766", "src_uid": "3dc56bc08606a39dd9ca40a43c452f09", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n\nlong long ex[11777777];\nint first[11777777],ey[11777777],ez[11777777],es[11777777];\nint g[30];\nlong long f[30];\nint i,k,l,n,sum_fact;\nlong long m,s;\n\nvoid dfs1(int x,int y,long long z)\n{\n\tif ((y>k) || (z>m))\n\t\treturn;\n\tif (x>n/2)\n\t{\n\t\tbool b=false;\n\t\tint r=((k-y)*(long long) 1e16+m-z)%11777777;\n\t\tfor (int i=first[r];i!=0;i=ez[i])\n\t\t\tif ((ex[i]==m-z) && (ey[i]==k-y))\n\t\t\t{\n\t\t\t\tes[i]++;\n\t\t\t\tb=true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\tif (! b)\n\t\t{\n\t\t\tsum_fact++;\n\t\t\tex[sum_fact]=m-z,ey[sum_fact]=k-y,es[sum_fact]=1;\n\t\t\tez[sum_fact]=first[r],first[r]=sum_fact;\n\t\t}\n\t\treturn;\n\t}\n\tdfs1(x+1,y,z);\n\tdfs1(x+1,y,z+g[x]);\n\tif (g[x]<=18)\n\t\tdfs1(x+1,y+1,z+f[g[x]]);\n\treturn;\n}\n\nvoid dfs2(int x,int y,long long z)\n{\n\tif ((y>k) || (z>m))\n\t\treturn;\n\tif (x>n)\n\t{\n\t\tfor (int i=y;i<=k;i++)\n\t\t\tfor (int j=first[(i*(long long) 1e16+z)%11777777];j!=0;j=ez[j])\n\t\t\t\tif ((ex[j]==z) && (ey[j]==i))\n\t\t\t\t\ts=s+es[j];\n\t\treturn;\n\t}\n\tdfs2(x+1,y,z);\n\tdfs2(x+1,y,z+g[x]);\n\tif (g[x]<=18)\n\t\tdfs2(x+1,y+1,z+f[g[x]]);\n\treturn;\n}\n\nint main()\n{\n\tscanf(\"%d%d%I64d\",&n,&k,&m);\n\tfor (i=1;i<=n;i++)\n\t\tscanf(\"%d\",&g[i]);\n\tfor (i=1;i<=n;i++)\n\t\tif (g[i]<=18)\n\t\t\tl++;\n\tif (k>l)\n\t\tk=l;\n\tf[0]=1;\n\tfor (i=1;i<=18;i++)\n\t\tf[i]=f[i-1]*i;\n\tdfs1(1,0,0);\n\tdfs2(n/2+1,0,0);\n\tprintf(\"%I64d\",s);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "51b54d5c1d0fe463f06aa3675578945a", "src_uid": "2821a11066dffc7e8f6a60a8751cea37", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "#include \n// #include \n// #include \nusing namespace std;\n// using namespace __gnu_pbds;\n#define ff first\n#define ss second\n#define pb(x) push_back(x)\n#define mp make_pair\n#define sz(x) x.size()\n#define mem(x ,y) memset(x , y , sizeof x )\n#define all(a ) a.begin() , a.end()\n#define endl \"\\n\"\n#define pii pair \n#define clr(x) x.clear()\n#define sl(x ) scanf(\"%I64d\" ,&x)\n#define si(x ) scanf(\"%d\" ,&x)\n#define forn(i ,x,n ) for(int i = x ; i <= n ; i++ )\n#define ford(i ,x,n ) for(int i = x ; i >= n ; i-- )\n#define rep(i,n ) for(int i= 0; i T mul(T x, T y, T mod = mod ) { x %= mod ; y %= mod ; return (x*y)%mod ; }\ntemplate < typename T > T add(T x, T y, T mod = mod ) { x %= mod ; y %= mod ; return (x+y)%mod ; }\ntemplate < typename T > T sub(T x, T y, T mod = mod ) { x %= mod ; y %= mod ; return ((x-y)%mod+mod )%mod; }\ntemplate < typename T > T ext_gcd(T num1 , T num2, T &X , T &Y ) { T r2,r1, q2, q1 , x2, x1, y2 ,y1 , x, y, r ; x2 = 1; y2 = 0; x1 = 0; y1 = 1; for( r2 =num1 ,r1 = num2 ;r1 != 0 ; y2 = y1, y1 = y,x2 = x1 ,x1 = x ,r2 = r1, r1 = r) {q1 = r2/r1; x = x2 - q1*x1; y = y2 - q1*y1; r = r2%r1 ; } X = x2 ; Y = y2 ; return r2 ; }\ntemplate < typename T > void print(const T& v) { cerr << v << ' ' ;}\ntemplate < typename T1, typename... T2 > void print( const T1& first, const T2&... rest ){ print(first); print(rest...) ;}\ntemplate string to_str(T t){stringstream ss; ss< \nT bigmod(T x, T k ,T mod = mod) {\n if(k == 0 ) return (T)1; \n if(k&1 ) { \n return ( (x%mod)*bigmod(x,k-1, mod )%mod )%mod ; \n } else { \n T ret = bigmod(x,k/2 , mod ) ; \n ret %= mod ; \n return (ret*ret )%mod; \n } \n \n}\ntemplate < typename T > \nT invmod( T x , T m) { \n return bigmod(x,m-2 , m) ; \n // long long ret, t ;// \n // ext_gcd( x, m ,ret ,t ) ;\n // ret %= m ; if(ret<0) ret += m ; \n // return ret;\n} \n// typedef tree< pair< int , int > , // change type \n// null_type, \n// pair< int , int > , // change type \n// rb_tree_tag,\n// tree_order_statistics_node_update> o_set;\n// oreder_of_key(k )\n// debuging ...\ntemplate \nvoid dbg_a(T a[] ,int n=10 ) {\n cerr << \"[ \"; \n for(int i=0;i < n ; i++ )\n cerr<\nostream& operator << ( ostream& os, const pair< F, S > & p ) {\n return os << \"[ \" << p.first << \", \" << p.second << \" ]\";\n}\ntemplate < typename T >\nostream &operator << ( ostream & os, const vector< T > &v ) {\n os << \"[ \"; \n for(int i=0; i\nostream &operator << ( ostream & os, const map< T ,T> &Map ) {\n os << \"[ \"; \n repit(it , Map ) \n os << \"[\" <<(*it).ff << ' ' << (*it).ss << \"] \" ; \n return os << \"]\\n\" ; \n} \ntemplate < typename T >\nostream &operator << ( ostream & os, const set< T > &Set ) {\n os << \"[ \"; \n repit(it , Set ) \n os << *it << ' ' ; \n return os << \" ]\\n\" ; \n} \n// int dx[] = {0 , 0 ,+1, -1 } ;\n// int dy[] = {-1, +1,0 , 0 };\n// int dx[10 ] = {-2,-2, 2, 2 ,+ 1, -1 , +1, -1 } ;\n// int dy[10 ] = {+1,-1, 1, -1 , +2,+2 , -2,-2 } ;\n#define int ll \nconst int maxn = (int )2e5+ 123 ;\nconst int inf = 1e9+ 123 ;\n///////////////////////////////////////////////////////////////\n\nint n , k , S ,a[maxn] , lim , ans ,fact[maxn ] ,f = 0; \nmapdp[maxn ] ; \nvoid func(int id , int cnt , int tot) {\n dbg(id ,cnt , tot , lim)\n if(cnt>k or tot>S ) return ; \n if(id>lim) {\n if(f == 0 ) {\n dbg(cnt , tot ) ; \n dp[cnt ][tot]++ ; \n }\n else {\n for(int i=0 ; i+cnt <=k ;i++ )\n ans += dp[i ][S-tot ]; \n }\n return ; \n\n }\n //take \n if(a[id]<19) {\n func(id+1,cnt+1 , tot+ fact[a[id] ]) ; \n\n }\n func(id+1, cnt, tot+a[id]) ;\n func(id+1, cnt , tot ) ; \n}\n\nvoid solve() {\n int m ,x ,lo , hi ; \n fact[0] =1 ; \n cin >> n >> k >> S ; \n forn(i,1,n ) cin >> a[i] ;\n\n sort(a+1,a+1+n ) ; \n forn(i,1,22 ) fact[i] = fact[i-1 ]*(i*1LL) ; \n \n // dbg_a(a) ; \n // dbg_a(fact ) ; \n \n // dbg( n,k ,S) ; \n\n lim = n/2 ; func(1,0 , 0) ; \n\n cout << endl; \n f = 1; lim = n ; func( n/2 +1 ,0 , 0) ; \n\n cout << ans << endl; \n \n}\nsigned main() {\n #ifndef ONLINE_JUDGE\n freopen(\"in.txt\", \"r\", stdin);\n // freopen(\"out.txt\", \"w\", stdout);\n #endif \n ios :: sync_with_stdio(false); cin.tie(0); \n cout.tie(0) ;\n clock_t st = clock() ;\n \n int c = 0 ,t = 1; \n // cin>>t ; \n while(t--) { \n \n solve() ;\n } \n // cerr << \"\\nExecution time : \" << (double ) (clock()-st )/CLOCKS_PER_SEC << endl ; \n \n return 0 ; \n \n} \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "61198b4851ecb35d9a0b1127e0b67eb9", "src_uid": "2821a11066dffc7e8f6a60a8751cea37", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define TASKI \"in.txt\"\n#define TASKO \"o.txt\"\n#define eprintf(...) fprintf(stderr, __VA_ARGS__)\n#define pb push_back\n#define mp make_pair\n#define _map unordered_map\n#define _set unordered_set\n#define sz(x) ((int)(x).size())\n#define it(x) (x).begin(), (x).end()\n\n#define TIMESTAMP(x) eprintf(\"[\" #x \"] Time = %.5lfs\\n\",clock()*1.0/CLOCKS_PER_SEC)\n\n#ifdef DEBUG\nstruct __timestamper {\n ~__timestamper() {\n TIMESTAMP(end);\n }\n} __Timestamper;\n#else\nstruct __timestamper {};\n#endif\n\ntypedef long double ld;\ntypedef long long ll;\ntypedef vector vll;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vb;\ntypedef vector vvb;\ntypedef vector vs;\ntypedef pair pii;\ntypedef pair pli;\ntypedef pair pil;\ntypedef pair pll;\ntypedef vector vpi;\n\nint n, k;\nll S, a[30];\n\nmap mem[30];\n\nll fact(ll n) {\n ll f = 1;\n for (int i = 1; i <= n; i++) {\n f *= i;\n }\n return f;\n}\n\nll dp(int i, ll s, int k) {\n if (s < 0)\n return 0;\n if (s == 0)\n return 1;\n if (i == n)\n return 0;\n if (mem[i].count(mp(s, k)))\n return mem[i][mp(s, k)];\n mem[i][mp(s, k)] += dp(i + 1, s, k);\n mem[i][mp(s, k)] += dp(i + 1, s - a[i], k);\n if (a[i] <= 19 && k - 1 >= 0)\n mem[i][mp(s, k)] += dp(i + 1, s - fact(a[i]), k - 1);\n return mem[i][mp(s, k)];\n}\n\nint main(void) {\n#ifdef DEBUG\n// freopen(TASKI, \"r\", stdin);\n // freopen(TASKO, \"w\", stdout);\n#endif\n scanf(\"%d %d %lld\", &n, &k, &S);\n for (int i = 0; i < n; i++) {\n scanf(\"%lld\", a + i);\n }\n printf(\"%lld\\n\", dp(0, S, k));\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1d0a2cddb99da3c3f144ce707481b12a", "src_uid": "2821a11066dffc7e8f6a60a8751cea37", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint n,k;\nlong long int s;\nint x[30],t;\nlong long int f[20];\nvector y;\nlong long int triangle[26][26];\n\nlong long int choose(int a,int b){\t\n\tif(b==0)return 1;\n\treturn triangle[a][b];\n}\nlong long int ff(long long int r,int a,int ss,bool fir){\n\tif(fir){\n\t\tlong long int ans=ff(r,a,ss,false);\n\t\t//printf(\"%I64d %d %I64d\\n\",r,a,ans);\n\t\treturn ans;\n\t}\n\tif(r==0)return 1;\n\tif(a>=19){\n\t\ta-=19;\n\t\tif(a==y.size())return 0;\n\t\tif(y[a]>r)return ff(r,a+1,ss,true);\n\t\treturn ff(r,a+1,ss,true)+ff(r-y[a],a+1,ss,true);\n\t}\n\tlong long int ans=0;\n\tfor(int b=0;b<=min(x[a],ss);b++){\n\t\tif(b*f[a]>r)break;\n\t\tfor(int c=0;c<=x[a]-b;c++){\n\t\t\tif(b*f[a]+c*a>r)break;\n\t\t\t//printf(\"-%d %d %d\\n\",a,b,c);\n\t\t\tans+=choose(x[a],b)*choose(x[a]-b,c)*ff(r-b*f[a]-c*a,a+1,ss-b,true);\n\t\t}\n\t}\n\treturn ans;\n}\n\nint main(){\n\tint i, j;\n triangle[0][0] = 1; // C(0, 0) = 1\n for(i = 1; i <=25; i++) {\n triangle[i][0] = 1; // C(i, 0) = 1\n for(j = 1; j <= i; j++) {\n triangle[i][j] = triangle[i - 1][j - 1] + triangle[i - 1][j];\n }\n }\n\tf[0]=1;\n\tfor(int a=1;a<20;a++)f[a]=f[a-1]*a;\n\tmemset(x,0,sizeof(x));\n\tscanf(\"%d%d%I64d\",&n,&k,&s);\n\tfor(int a=0;a\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst double eps = 1e-2, inf = 11111111;\n\nstruct point\n{\n double x, y;\n void read() {\n cin >> x >> y;\n }\n void write() {\n cout << x << ' ' << y;\n }\n point operator - (point a) {\n point ret;\n ret.x = x - a.x;\n ret.y = y - a.y;\n return ret;\n }\n point operator + (point a) {\n point ret;\n ret.x = x + a.x;\n ret.y = y + a.y;\n return ret;\n }\n point operator * (int a)\n {\n point ret;\n ret.x = x * a;\n ret.y = y * a;\n return ret;\n }\n point operator / (int a) {\n point ret;\n ret.x = x / a;\n ret.y = y / a;\n return ret;\n }\n};\n\nstruct line {\n double A, B, C;\n void write() {\n cout << A << ' ' << B << ' ' << C;\n }\n};\n\npoint make_point(double x, double y) {\n point ret;\n ret.x = x;\n ret.y = y;\n return ret;\n}\n\nline get_line(point a, point b) {\n line ret;\n ret.A = a.y - b.y;\n ret.B = b.x - a.x;\n ret.C = -ret.A * a.x - ret.B * a.y;\n return ret;\n}\n\npoint p_line(line a, line b) {\n point ret;\n if (fabs(a.A * b.B - b.A * a.B) <= eps) {\n ret.x = -inf;\n ret.y = -inf;\n return ret;\n }\n ret.y = (b.A * a.C - a.A * b.C) / (a.A * b.B - b.A * a.B);\n ret.x = (b.C * a.B - b.B * a.C) / (a.A * b.B - b.A * a.B);\n return ret;\n}\n\ndouble cross_pr(point a, point b) {\n return a.x * b.x + a.y * b.y;\n}\n\ndouble dist(point a) {\n return sqrt(a.x * a.x + a.y * a.y);\n}\n\ndouble dist(point a, point b) {\n return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));\n}\n\ndouble dist(point a, line b) {\n return fabs((b.A * a.x + b.B * a.y + b.C) / sqrt(b.A * b.A + b.B * b.B));\n}\n\ndouble ang(point a, point b) {\n return acos(cross_pr(a, b) / dist(a) / dist(b));\n}\n\nbool is_in(point a, point b, point c) {\n return fabs(dist(a, b) - dist(a, c) - dist(b, c)) <= eps;\n}\n\nbool per_otr(point a, point b, point c, point d) {\n if (is_in(a, b, c) || is_in(a, b, d) || is_in(c, d, a) || is_in(c, d, b)) {\n return true;\n }\n line l = get_line(a, b), l1 = get_line(c, d);\n point ans = p_line(l, l1);\n if (ans.x == -inf && ans.y == -inf) {\n return false;\n }\n if (is_in(a, b, ans) && is_in(c, d, ans)) {\n return true;\n }\n return false;\n}\n\nbool one_polypl(point a, point b, point c, point d) {\n line l = get_line(a, b), l1 = get_line(c, d);\n point ans = p_line(l, l1);\n if (ans.x == -inf && ans.y == -inf) {\n return true;\n }\n if (is_in(a, b, ans)) {\n return false;\n }\n return true;\n}\n\npoint v, p, w1, w2, z1, z2;\n\nint main() {\n //freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n v.read();\n p.read();\n w1.read();\n w2.read();\n z1.read();\n z2.read();\n if (!per_otr(v, p, w1, w2) && !per_otr(v, p, z1, z2)) {\n cout << \"YES\" << endl;\n return 0;\n }\n if (!one_polypl(v, p, z1, z2)) {\n cout << \"NO\";\n return 0;\n }\n if (z1.x > z2.x) {\n swap(z1, z2);\n }\n line l = get_line(z1, z2);\n if (z1.x == z2.x) {\n if (z1.y > z2.y) {\n swap(z1, z2);\n }\n for (double y = z1.y; y <= z2.y; y += eps) {\n double x = z1.x;\n point z = make_point(x, y);\n if (fabs(ang(z1 - z, v - z) - ang(z2 - z, p - z)) <= eps) {\n if (!per_otr(v, z, w1, w2) && !per_otr(p, z, w1, w2)) {\n cout << \"YES\" << endl;\n return 0;\n }\n }\n }\n cout << \"NO\" << endl;\n } else {\n for (double x = z1.x; x <= z2.x; x += eps) {\n double y = (-l.C - l.A * x) / l.B;\n point z = make_point(x, y);\n if (fabs(ang(z1 - z, v - z) - ang(z2 - z, p - z)) <= eps || fabs(ang(z2 - z, v - z) - ang(z1 - z, p - z)) <= eps || fabs(ang(z1 - z, v - z) - ang(z1 - z, p - z)) <= eps || fabs(ang(z2 - z, v - z) - ang(z2 - z, p - z)) <= eps) {\n if (!per_otr(v, z, w1, w2) && !per_otr(p, z, w1, w2)) {\n cout << \"YES\" << endl;\n return 0;\n }\n }\n }\n cout << \"NO\" << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "05606487166068436a5f86fc0de16042", "src_uid": "7539a41268b68238d644795bccaa0c0f", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n\nstruct point { double x, y; };\nstruct line { point a, b; };\n\nstatic double dot(const point &a, const point &b) { return a.x*b.x + a.y*b.y; }\n\nstatic double mag(const point &p) { return std::sqrt(dot(p, p)); }\n\nstatic point operator-(const point &a, const point &b)\n{ return { a.x - b.x, a.y - b.y }; }\n\nstatic point operator+(const point &a, const point &b)\n{ return { a.x + b.x, a.y + b.y }; }\n\nstatic point operator*(const double s, const point &p)\n{ return { s*p.x, s*p.y }; }\n\nstatic bool line_intersection(const line &u, const line &v)\n{\n\t/* Solve [ a b ; c d ] [ s ; t ] = [ p ; q ]. */\n\tconst double a = u.b.x - u.a.x, b = v.a.x - v.b.x;\n\tconst double c = u.b.y - u.a.y, d = v.a.y - v.b.y;\n\tconst double p = v.a.x - u.a.x, q = v.a.y - u.a.y;\n\tconst double det = a * d - b * c;\n\tconst double s = d * p + -b * q;\n\tconst double t = -c * p + a * q;\n\treturn det < 0 ? det <= 0 && s <= 0 && det <= t && t <= 0 :\n\t det > 0 ? 0 <= s && s <= det && 0 <= t && t <= det : false;\n}\n\nstatic double angle_over_line(const point &p, const double s, const line &m)\n{\n\tconst point u = m.b - m.a, v = p - m.a - s*(m.b - m.a);\n\treturn dot(u, v) / mag(u) / mag(v);\n}\n\nstatic bool reflection(const double a, const double b,\n\tconst point &u, const point &v, const line &m, point *p)\n{\n\tconst double e = 1e-12;\n\tconst double c = (b - a)/2.0;\n\tconst double wa = angle_over_line(u, a, m) + angle_over_line(v, a, m);\n\tconst double wc = angle_over_line(u, c, m) + angle_over_line(v, c, m);\n\tconst double wb = angle_over_line(u, b, m) + angle_over_line(v, b, m);\n\tconst double d = (0.0 < wa ? -1.0 : 1.0);\n\n\tif (b - a < e || std::abs(wc) < e) {\n\t\tif (p != nullptr) *p = m.a + c*(m.b - m.a);\n\t\treturn true;\n\t}\n\n\treturn d*wa <= e && -e <= d*wc ? reflection(a, c, u, v, m, p) :\n\t d*wc <= e && -e <= d*wb ? reflection(c, b, u, v, m, p) : false;\n}\n\nstatic bool reflection(const point &u, const point &v, const line &m, point *p)\n{\n\treturn reflection(0.0, 1.0, u, v, m, p);\n}\n\nint main(int argc, char *argv[])\n{\n\tpoint v, p;\n\tline w, m;\n\n\tif (fscanf(stdin, \"%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf\",\n\t\t&v.x, &v.y, &p.x, &p.y,\n\t\t&w.a.x, &w.a.y, &w.b.x, &w.b.y,\n\t\t&m.a.x, &m.a.y, &m.b.x, &m.b.y) != 12) {\n\t\tfprintf(stderr, \"fscanf: Coordinate IO error.\\n\");\n\t\texit(EXIT_FAILURE);\n\t}\n\n\tpoint r;\n\tconst bool d = !line_intersection({ p, v }, w) &&\n\t \t !line_intersection({ p, v }, m);\n\tconst bool i = reflection(v, p, m, &r) &&\n\t\t !line_intersection({ p, r }, w) &&\n\t\t !line_intersection({ v, r }, w) &&\n\t \t !line_intersection({ p, v }, m);\n\n\tputs(d || i ? \"YES\" : \"NO\");\n\n\treturn EXIT_SUCCESS;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7f21ad2fb193edbd3486d9bd1f10d76e", "src_uid": "7539a41268b68238d644795bccaa0c0f", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst double eps = 0.008, inf = 11111111;\n\nstruct point\n{\n double x, y;\n void read() {\n cin >> x >> y;\n }\n void write() {\n cout << x << ' ' << y;\n }\n point operator - (point a) {\n point ret;\n ret.x = x - a.x;\n ret.y = y - a.y;\n return ret;\n }\n point operator + (point a) {\n point ret;\n ret.x = x + a.x;\n ret.y = y + a.y;\n return ret;\n }\n point operator * (int a)\n {\n point ret;\n ret.x = x * a;\n ret.y = y * a;\n return ret;\n }\n point operator / (int a) {\n point ret;\n ret.x = x / a;\n ret.y = y / a;\n return ret;\n }\n};\n\nstruct line {\n double A, B, C;\n void write() {\n cout << A << ' ' << B << ' ' << C;\n }\n};\n\npoint make_point(double x, double y) {\n point ret;\n ret.x = x;\n ret.y = y;\n return ret;\n}\n\nline get_line(point a, point b) {\n line ret;\n ret.A = a.y - b.y;\n ret.B = b.x - a.x;\n ret.C = -ret.A * a.x - ret.B * a.y;\n return ret;\n}\n\npoint p_line(line a, line b) {\n point ret;\n if (fabs(a.A * b.B - b.A * a.B) <= eps) {\n ret.x = -inf;\n ret.y = -inf;\n return ret;\n }\n ret.y = (b.A * a.C - a.A * b.C) / (a.A * b.B - b.A * a.B);\n ret.x = (b.C * a.B - b.B * a.C) / (a.A * b.B - b.A * a.B);\n return ret;\n}\n\ndouble cross_pr(point a, point b) {\n return a.x * b.x + a.y * b.y;\n}\n\ndouble dist(point a) {\n return sqrt(a.x * a.x + a.y * a.y);\n}\n\ndouble dist(point a, point b) {\n return ((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));\n}\n\ndouble dist(point a, line b) {\n return fabs((b.A * a.x + b.B * a.y + b.C) / sqrt(b.A * b.A + b.B * b.B));\n}\n\ndouble dist1(point a, point b) {\n return ((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));\n}\n\ndouble ang(point a, point b) {\n return acos(cross_pr(a, b) / dist(a) / dist(b));\n}\n\nbool is_in(point a, point b, point c) {\n /*a.write();\n cout << ' ';\n b.write();\n cout << ' ';\n c.write();\n cout << \" = \" << fabs(dist(a, b) - dist(a, c) - dist(b, c)) << endl;*/\n double x = dist1(a, b), y = dist1(a, c), z = dist1(b, c);\n return fabs(x - y - z - 2 * sqrt(y * z)) <= eps;\n}\n\nbool per_otr(point a, point b, point c, point d) {\n if (is_in(a, b, c) || is_in(a, b, d) || is_in(c, d, a) || is_in(c, d, b)) {\n return true;\n }\n line l = get_line(a, b), l1 = get_line(c, d);\n point ans = p_line(l, l1);\n if (ans.x == -inf && ans.y == -inf) {\n return false;\n }\n if (is_in(a, b, ans) && is_in(c, d, ans)) {\n return true;\n }\n return false;\n}\n\nbool one_polypl(point a, point b, point c, point d) {\n line l = get_line(a, b), l1 = get_line(c, d);\n point ans = p_line(l, l1);\n if (ans.x == -inf && ans.y == -inf) {\n return true;\n }\n if (is_in(a, b, ans)) {\n return false;\n }\n return true;\n}\n\npoint v, p, w1, w2, z1, z2;\n\nint main() {\n //freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n v.read();\n p.read();\n w1.read();\n w2.read();\n z1.read();\n z2.read();\n if (!per_otr(v, p, w1, w2) && !per_otr(v, p, z1, z2)) {\n cout << \"YES\" << endl;\n return 0;\n }\n if (!one_polypl(v, p, z1, z2)) {\n cout << \"NO\";\n return 0;\n }\n if (z1.x > z2.x) {\n swap(z1, z2);\n }\n line l = get_line(z1, z2);\n if (z1.x == z2.x) {\n if (z1.y > z2.y) {\n swap(z1, z2);\n }\n for (double y = z1.y; y <= z2.y; y += eps) {\n double x = z1.x;\n point z = make_point(x, y);\n if (fabs(ang(z1 - z, v - z) - ang(z2 - z, p - z)) <= eps) {\n if (!per_otr(v, z, w1, w2) && !per_otr(p, z, w1, w2)) {\n cout << \"YES\" << endl;\n return 0;\n }\n }\n }\n cout << \"NO\" << endl;\n } else {\n for (double x = z1.x; x <= z2.x; x += eps) {\n double y = (-l.C - l.A * x) / l.B;\n point z = make_point(x, y);\n if (fabs(ang(z1 - z, v - z) - ang(z2 - z, p - z)) <= eps || fabs(ang(z2 - z, v - z) - ang(z1 - z, p - z)) <= eps || fabs(ang(z1 - z, v - z) - ang(z1 - z, p - z)) <= eps || fabs(ang(z2 - z, v - z) - ang(z2 - z, p - z)) <= eps) {\n if (!per_otr(v, z, w1, w2) && !per_otr(p, z, w1, w2)) {\n cout << \"YES\" << endl;\n return 0;\n }\n }\n }\n cout << \"NO\" << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a2aeec475c89c1a75d9a15b45caf6849", "src_uid": "7539a41268b68238d644795bccaa0c0f", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define FOR(a,b,c) for (int a=b,_c=c;a<=_c;a++)\n#define FORD(a,b,c) for (int a=b;a>=c;a--)\n#define REP(i,a) for(int i=0,_a=(a); i<_a; ++i)\n#define REPD(i,a) for(int i=(a)-1; i>=0; --i)\n#define pb push_back\n#define mp make_pair\n#define fi first\n#define se second\n#define sz(a) int(a.size())\n#define reset(a,b) memset(a,b,sizeof(a))\n#define oo 1000000007\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair pii;\n\n\nbool equal(double a, double b){\n return fabs(a-b)<1e-9;\n}\n\nbool bigger(double a, double b){\n return (!equal(a,b) && a>b);\n}\n\nbool smaller(double a, double b){\n return (!equal(a,b) && a1) t1=1; if(t1<-1) t1=-1;\n if(t2>1) t2=1; if(t2<-1) t2=-1;\n return t1*t2<=0;\n}\n\nbool catnhau(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3, ll x4, ll y4){\n return khacphia(x1,y1,x2,y2,x3,y3,x4,y4) && khacphia(x3,y3,x4,y4,x1,y1,x2,y2);\n}\n\nbool songsong(ll x1, ll y1, ll x2, ll y2, ll x3, ll y3, ll x4, ll y4){\n ll vx1=x2-x1, vy1=y2-y1, vx2=x4-x3, vy2=y4-y3;\n return vx1*vy2==vx2*vy1;\n}\n\n\n// double \ndouble dis(double x1, double y1, double x2, double y2, double x3, double y3){\n double vx=y1-y2;\n double vy=x2-x1;\n return vx*(x3-x1)+vy*(y3-y1);\n}\n\nbool khacphia(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4){\n double t1=dis(x1,y1,x2,y2,x3,y3);\n double t2=dis(x1,y1,x2,y2,x4,y4);\n if(t1>1) t1=1; if(t1<-1) t1=-1;\n if(t2>1) t2=1; if(t2<-1) t2=-1;\n return !bigger(t1*t2,0.0);\n}\n\nbool dcatnhau(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4){\n return khacphia(x1,y1,x2,y2,x3,y3,x4,y4) && khacphia(x3,y3,x4,y4,x1,y1,x2,y2);\n}\n\n//-----------------------------------------------------------------------\n\n\ndouble giaihpt(double a1, double b1, double c1, double a2, double b2, double c2, double &X, double &Y){\n double d=a1*b2-a2*b1;\n double dx=b1*c2-b2*c1;\n double dy=c1*a2-c2*a1;\n X=dx/d; Y=dy/d;\n}\n\ndouble hinhchieu(double x1, double y1, double x2, double y2, double x0, double y0, double &X, double &Y){\n double vx=y1-y2;\n double vy=x2-x1;\n giaihpt(vx,vy,-x1*vx-y1*vy,vy,-vx,-x0*vy+y0*vx,X,Y);\n}\n\ndouble I1,J1,I2,J2,xx,yy;\nll xv,yv,xp,yp;\n\ndouble cal(double val, double len){\n double vx,vy,l1,l2;\n vx=I2-I1; vy=J2-J1;\n xx=vx*val/len+I1; yy=vy*val/len+J1;\n l1=hypot(xv-xx,yv-yy);\n l2=hypot(xp-xx,yp-yy);\n return val/l1-(len-val)/l2;\n}\n \n#include \nint main(){\n freopen(\"test.txt\",\"r\",stdin);\n \n ll x1,y1,x2,y2,x3,y3,x4,y4;\n \n \n cin>>xv>>yv>>xp>>yp;\n cin>>x1>>y1>>x2>>y2;\n cin>>x3>>y3>>x4>>y4;\n if(!catnhau(xv,yv,xp,yp,x1,y1,x2,y2) && (songsong(xv,yv,xp,yp,x3,y3,x4,y4) || !catnhau(xv,yv,xp,yp,x3,y3,x4,y4))){\n puts(\"YES\");\n getch();\n return 0;\n }\n if(!khacphia(x3,y3,x4,y4,xv,yv,xp,yp)){\n hinhchieu(x3,y3,x4,y4,xv,yv,I1,J1);\n hinhchieu(x3,y3,x4,y4,xp,yp,I2,J2);\n double len=hypot(I1-I2,J1-J2);\n double left=0, right=len, mid, val;\n while(fabs(right-left)>1e-12){\n mid=(left+right)/2;\n val=cal(mid,len);\n if(val>0) right=mid; else left=mid;\n }\n cal((left+right)/2,len);\n if(!smaller(xx,min(x3,x4)) && !bigger(xx,max(x3,x4)) \n && !smaller(yy,min(y3,y4)) && !bigger(yy,max(y3,y4))\n && !dcatnhau(xx,yy,xv,yv,x1,y1,x2,y2) && !dcatnhau(xx,yy,xp,yp,x1,y1,x2,y2)){\n puts(\"YES\");\n return 0;\n }\n }\n puts(\"NO\");\n getch();\n return 0;\n}\n \n \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b38ad6e8efb1c141a85e11be494ff687", "src_uid": "7539a41268b68238d644795bccaa0c0f", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "#pragma GCC optimize(\"Ofast\")\n#include\n#include \n\n#define F first\n#define S second\n//#define int long long\n#define ll long long\n//#define int unsigned long long\n#define pb push_back\n//#define double long double\n\nusing namespace std;\nusing namespace __gnu_pbds;\ntypedef tree< int , null_type, less, rb_tree_tag, tree_order_statistics_node_update> ordered_set;\nconst int mod = 1e9 + 7;\nconst int N = 1200010;\nconst int K = 10;\nint l[N], r[N], f[N], len[N], p[N], used[30][N];\nvector < int > u, v, t, pr;\nint ww;\nmap < ll, map < int, int > > d;\nmap < int, int > d0;\nmap < int, vector < int > > tv;\nmap < int, ll > tvi;\nconst int base = 22;\nqueue < pair < int, int > > q;\nvoid calc (int p, int v, int x, int pr = 100){\n if (x < 0) return;\n if (used[p][v] > x) return;\n used[p][v] = x;\n q.push({p, v});\n if (d[ww].find(v) == d[ww].end()) d[ww][v] = K - x; else d[ww][v] = min(d[ww][v], K - x);\n if (p >= u.size()) return;\n for (int i = max(1, u[p] - x); i < u[p] + x; i++){\n int y = v;\n calc(p + 1, v / u[p] * i, x - abs(i - u[p]), i);\n }\n}\nvoid precalc (int p, int v, int x, int pr = 100){\n if (x < 0) return;\n if (d0.find(v) == d0.end()) d0[v] = K - x; else d0[v] = min(d0[v], K - x);\n if (p >= t.size()) return;\n for (int i = max(1, t[p] - x); i < t[p] + x && i <= pr; i++){\n int y = v;\n precalc(p + 1, v / t[p] * i, x - abs(i - t[p]), i);\n }\n}\nvector < int > tovec(int x){\n vector < int > res, z;\n while (x != 1){\n z.pb(p[x]);\n x /= p[x];\n }\n int pr = -1;\n int c = 0;\n sort(z.begin(), z.end());\n for (int i = 0; i < z.size(); i++) if (pr == z[i]) c++; else{\n if (c != 0) res.pb(c + 1);\n c = 1;\n pr = z[i];\n }\n res.pb(c + 1);\n sort(res.begin(), res.end());\n reverse(res.begin(), res.end());\n return res;\n}\nmain(){\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n //freopen(\"input.txt\", \"r\", stdin);\n int n;\n n = 1000000;\n set < int > v;\n for (int i = 2; i < N; i++){\n if (p[i] != 0) continue;\n pr.pb(i);\n for (int j = i; j < N; j += i) p[j] = i;\n }\n for (int i = 1; i <= n; i++){\n vector < int > t = tovec(i);\n ll x = 0;\n for (auto j: t){\n x = x * base + j + 1;\n }\n tvi[i] = x;\n tv[x] = t;\n v.insert(x);\n }\n for (int i = 0; i < 10; i++) t.pb(1);\n precalc(0, 1, K);\n int zz = 0;\n int zzz = 0;\n for (auto i: v){\n u = tv[i];\n ww = i;\n int x = 1;\n for (auto j: u) x *= j;\n calc(0, x, K);\n zz += q.size();\n while(!q.empty()){\n auto y = q.front();\n q.pop();\n used[y.F][y.S] = 0;\n }\n zzz = max(zzz, (int)d[i].size());\n for (auto j: d[i]){\n for (auto l: d0){\n int c = l.F * j.F;\n if (c > 5000) continue;\n if (d[i][c] == 0 && c != x) d[i][c] = l.S + j.S; else d[i][c] = min(d[i][c], l.S + j.S);\n }\n }\n }\n int q;\n cin >> q;\n while(q--){\n int x, y;\n cin >> x >> y;\n x = tvi[x];\n y = tvi[y];\n int res = 1000;\n for (auto i: d[x]){\n if (d[y].find(i.F) != d[y].end()) res = min(res, i.S + d[y][i.F]);\n }\n cout << res << endl;\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fbaa129874001a72c77b4efb52e2e932", "src_uid": "6115ee1ccf651b1dd8145bf755ea7ea9", "difficulty": 2800.0} {"lang": "GNU C++14", "source_code": "#pragma GCC optimize(\"Ofast\")\n#include\n#include \n\n#define F first\n#define S second\n//#define int long long\n#define ll long long\n//#define int unsigned long long\n#define pb push_back\n//#define double long double\n\nusing namespace std;\nusing namespace __gnu_pbds;\ntypedef tree< int , null_type, less, rb_tree_tag, tree_order_statistics_node_update> ordered_set;\nconst int mod = 1e9 + 7;\nconst int N = 1200010;\nconst int K = 15;\nint l[N], r[N], f[N], len[N], p[N], used[30][N];\nvector < int > u, v, t, pr;\nmap < vector < int >, map < int, int > > d;\nmap < int, int > d0;\nmap < int, vector < int > > tv;\nqueue < pair < int, int > > q;\nvoid calc (int p, int v, int x, int pr = 100){\n if (x < 0) return;\n if (used[p][v] > x) return;\n used[p][v] = x;\n q.push({p, v});\n if (d[u].find(v) == d[u].end()) d[u][v] = K - x; else d[u][v] = min(d[u][v], K - x);\n if (p >= u.size()) return;\n for (int i = max(1, u[p] - x); i < u[p] + x; i++){\n int y = v;\n calc(p + 1, v / u[p] * i, x - abs(i - u[p]), i);\n }\n}\nvoid precalc (int p, int v, int x, int pr = 100){\n if (x < 0) return;\n if (d0.find(v) == d0.end()) d0[v] = K - x; else d0[v] = min(d0[v], K - x);\n if (p >= t.size()) return;\n for (int i = max(1, t[p] - x); i < t[p] + x && i <= pr; i++){\n int y = v;\n precalc(p + 1, v / t[p] * i, x - abs(i - t[p]), i);\n }\n}\nvector < int > tovec(int x){\n vector < int > res, z;\n while (x != 1){\n z.pb(p[x]);\n x /= p[x];\n }\n int pr = -1;\n int c = 0;\n sort(z.begin(), z.end());\n for (int i = 0; i < z.size(); i++) if (pr == z[i]) c++; else{\n if (c != 0) res.pb(c + 1);\n c = 1;\n pr = z[i];\n }\n res.pb(c + 1);\n sort(res.begin(), res.end());\n reverse(res.begin(), res.end());\n return res;\n}\nmain(){\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n //freopen(\"input.txt\", \"r\", stdin);\n int n;\n n = 1000000;\n set < vector < int > > v;\n for (int i = 2; i < N; i++){\n if (p[i] != 0) continue;\n pr.pb(i);\n for (int j = i; j < N; j += i) p[j] = i;\n }\n for (int i = 1; i <= n; i++){\n vector < int > t = tovec(i);\n tv[i] = t;\n v.insert(t);\n }\n for (int i = 0; i < 10; i++) t.pb(1);\n precalc(0, 1, K);\n int zz = 0;\n int zzz = 0;\n for (auto i: v){\n u = i;\n int x = 1;\n for (auto j: u) x *= j;\n calc(0, x, K);\n zz += q.size();\n while(!q.empty()){\n auto y = q.front();\n q.pop();\n used[y.F][y.S] = 0;\n }\n zzz = max(zzz, (int)d[u].size());\n for (auto j: d[u]){\n for (auto l: d0){\n int c = l.F * j.F;\n if (c > 5000) continue;\n if (d[u][c] == 0 && c != x) d[u][c] = l.S + j.S; else d[u][c] = min(d[u][c], l.S + j.S);\n }\n }\n }\n int q;\n cin >> q;\n while(q--){\n int x, y;\n cin >> x >> y;\n vector < int > v1 = tv[x];\n vector < int > v2 = tv[y];\n int res = 1000;\n for (auto i: d[v1]){\n if (d[v2].find(i.F) != d[v2].end()) res = min(res, i.S + d[v2][i.F]);\n }\n cout << res << endl;\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "041e013416a19257cc60d0365f37d2e4", "src_uid": "6115ee1ccf651b1dd8145bf755ea7ea9", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n#define all(v) v.begin(), v.end()\n#define sz(v) (int)v.size()\nconst int N = 1e6 + 5, M = 1500 + 5;\nint dis[M][M], dist[M][M], ans[M][M], P[N], fpd[N], n, mx;\nmap , int> mp;\nvector s[N], g[M];\n\nvector seq(int a) {\n vector p, vec;\n while (a > 1) {\n if (p.empty() || p.back() != fpd[a]) p.push_back(fpd[a]), vec.push_back(1);\n vec.back()++;\n a /= fpd[a];\n }\n while (vec.size() < 9) vec.push_back(1);\n sort(all(vec), greater ());\n return vec;\n}\nint zarb(vector &vec) {\n int res = 1;\n for (int a : vec) res *= a;\n return res;\n}\nvoid BFS(int s) {\n dis[s][s] = 0;\n queue q;\n q.push(s);\n while (!q.empty()) {\n int v = q.front(); q.pop();\n for (int u : g[v]) if (dis[s][v] + 1 < dis[s][u]) dis[s][u] = dis[s][v] + 1, q.push(u);\n }\n}\n\nint main() {\n ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n memset(P, 1, sizeof P);\n for (int i = 2; i < N; i++) if (P[i])\n for (int j = i; j < N; j += i) if (P[j]) P[j] = 0, fpd[j] = i;\n for (int i = 1; i < N; i++) {\n vector vec = seq(i);\n if (mp.count(vec) == 0) mp[vec] = ++n, s[n] = vec;\n }\n memset(dis, 31, sizeof dis), memset(dist, 31, sizeof dist), memset(ans, 31, sizeof ans);\n for (int i = 1; i <= n; i++) {\n vector vec = s[i];\n mx = max(mx, zarb(vec));\n for (int j = 0; j < sz(vec); j++) {\n if (j == 0 || vec[j] != vec[j - 1]) {\n vec[j]++;\n if (mp.count(vec) != 0) g[i].push_back(mp[vec]);\n else if (n < M - 1) mp[vec] = ++n, s[n] = vec, g[i].push_back(mp[vec]);\n vec[j]--;\n }\n if (j == sz(vec) - 1 || vec[j] != vec[j + 1]) {\n vec[j]--;\n if (mp.count(vec) != 0) g[i].push_back(mp[vec]);\n else if (n < M - 1) mp[vec] = ++n, s[n] = vec, g[i].push_back(mp[vec]);\n vec[j]++;\n }\n }\n }\n for (int i = 1; i <= n; i++) BFS(i);\n for (int i = 1; i <= n; i++)\n for (int j = 1; j <= n; j++) dist[i][zarb(s[j])] = min(dist[i][zarb(s[j])], dis[i][j]);\n for (int i = 1; i <= n; i++)\n for (int j = 1; j <= n; j++)\n for (int k = 1; k <= mx; k++) ans[i][j] = min(ans[i][j], dist[i][k] + dist[j][k]);\n int t; cin >> t;\n for (int i = 0; i < t; i++) {\n int a, b; cin >> a >> b, a = mp[seq(a)], b = mp[seq(b)];\n cout << ans[a][b] << \"\\n\";\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "54a18e2e603bfb379c131e5c5360a11a", "src_uid": "6115ee1ccf651b1dd8145bf755ea7ea9", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n#define all(v) v.begin(), v.end()\n#define sz(v) (int)v.size()\nconst int N = 1e6 + 5, M = 2e3 + 5;\nint dis[M][M], dist[M][M], ans[M][M], P[N], fpd[N], n, mx;\nmap , int> mp;\nvector s[N], g[M];\n\nvector seq(int a) {\n vector p, vec;\n while (a > 1) {\n if (p.empty() || p.back() != fpd[a]) p.push_back(fpd[a]), vec.push_back(1);\n vec.back()++;\n a /= fpd[a];\n }\n while (vec.size() < 9) vec.push_back(1);\n sort(all(vec), greater ());\n return vec;\n}\nint zarb(vector &vec) {\n int res = 1;\n for (int a : vec) res *= a;\n return res;\n}\nvoid BFS(int s) {\n dis[s][s] = 0;\n queue q;\n q.push(s);\n while (!q.empty()) {\n int v = q.front(); q.pop();\n for (int u : g[v]) if (dis[s][v] + 1 < dis[s][u]) dis[s][u] = dis[s][v] + 1, q.push(u);\n }\n}\n\nint main() {\n ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n memset(P, 1, sizeof P);\n for (int i = 2; i < N; i++) if (P[i])\n for (int j = i; j < N; j += i) if (P[j]) P[j] = 0, fpd[j] = i;\n for (int i = 1; i < N; i++) {\n vector vec = seq(i);\n if (mp.count(vec) == 0) mp[vec] = ++n, s[n] = vec;\n }\n memset(dis, 31, sizeof dis), memset(dist, 31, sizeof dist), memset(ans, 31, sizeof ans);\n for (int i = 1; i <= n; i++) {\n vector vec = s[i];\n mx = max(mx, zarb(vec));\n for (int j = 0; j < sz(vec); j++) {\n if (j == 0 || vec[j] != vec[j - 1]) {\n vec[j]++;\n if (mp.count(vec) != 0) g[i].push_back(mp[vec]);\n else if (n < M - 1) mp[vec] = ++n, s[n] = vec, g[i].push_back(mp[vec]);\n vec[j]--;\n }\n if (j == sz(vec) - 1 || vec[j] != vec[j + 1]) {\n vec[j]--;\n if (mp.count(vec) != 0) g[i].push_back(mp[vec]);\n else if (n < M - 1) mp[vec] = ++n, s[n] = vec, g[i].push_back(mp[vec]);\n vec[j]++;\n }\n }\n }\n cout << mx << \"\\n\";\n for (int i = 1; i <= n; i++) BFS(i);\n for (int i = 1; i <= n; i++)\n for (int j = 1; j <= n; j++) dist[i][zarb(s[j])] = min(dist[i][zarb(s[j])], dis[i][j]);\n for (int i = 1; i <= n; i++)\n for (int j = 1; j <= n; j++)\n for (int k = 1; k <= mx; k++) ans[i][j] = min(ans[i][j], dist[i][k] + dist[j][k]);\n int t; cin >> t;\n for (int i = 0; i < t; i++) {\n int a, b; cin >> a >> b, a = mp[seq(a)], b = mp[seq(b)];\n cout << ans[a][b] << \"\\n\";\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ac3c7770a2043815e3e2d0eacc3d2e3b", "src_uid": "6115ee1ccf651b1dd8145bf755ea7ea9", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#include\n\nusing namespace std;\n\nconst int Maxn = 1e7 + 100;\nbool isNotPrime[Maxn];\n\nvoid pre_process()\n{\n\tfor (int i = 0; i * i < Maxn; ++i)\n\t\tif (!isNotPrime[i])\n\t\t\tfor (int j = i * i; j < Maxn; j += i)\n\t\t\t\tisNotPrime[j] = true;\n}\n\nint main()\n{\n\tpre_process();\n\tint n;\n\tcin >> n;\n\tfor (int i = 0; i < 1e4; ++i)\n\t\tif (isNotPrime[n * i + 1])\n\t\t{\n\t\t\tcout << i << '\\n';\n\t\t\tbreak;\n\t\t}\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4cbcb3a8d6d9a8084e8fbc72c82738ac", "src_uid": "5c68e20ac6ecb7c289601ce8351f4e97", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#define _USE_MATH_DEFINES\n#define _CRT_SECURE_NO_WARNINGS\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include \n#include\n#include\n#include\n#include \n#include\n\n//#include\n\n\nusing namespace std;\nbool f[1000000006] = {};\nint main() {\n\n\tfor (long long int i = 3; i <= 10000000; i+=2) {\n\t\tf[i] = 0;\n\t\t\n\t\tfor (long long int j = 3; j*j <= i; j += 2) {\n\t\t\tif (i%j == 0) {\n\t\t\t\tf[j] = 1; break;\n\t\t\t}\n\t\t}\n\t}\n\tf[2] = 1;\n\tint n;int p = 0;\n\tcin >> n;\n\tfor (long long int i = 1; i <= 10000000000003; i++) {\n\t\tlong long int h = n*i + 1;\n\t\tif (!f[h]) {\n\t\t\tcout << i << endl; break;\n\t\t}\n\t}\n\t\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3a18118bee1b3fdf53a9286dd16f868a", "src_uid": "5c68e20ac6ecb7c289601ce8351f4e97", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\ntypedef long long ll;\ntypedef long double ld;\ntypedef signed long long sll;\ntypedef unsigned long long ull;\n#define all(s) ((s).begin()),((s).end())\n#define rall(s) ((s).rbegin()),((s).rend())\n#define Pi 3.141592653589793238462643383279502884197169399375106\nconst int OO=INT_MAX;\n\nusing namespace std;\nvoid Yuko_Kurama()\n{\n cin.tie(0);\n ios::sync_with_stdio(false);\n}\nmap p;\nvoid sieve()\n{\n\tint n=1010;\n\tp[1]=true;\n\tfor(int i=2;i*i<=n;i++)\n\t{\n\t\tif(!p[i])\n\t\t{\n\t\tfor(int j=i*2;j>n)\n\t{\n\t\tint x,y,num=2,c=1;\n\t\tvector v(n);\n\t\tmap mop;\n\n\t\t\n\n\t\twhile (1)\n\t\t{\n\t\t\tnum=n*c+1;\n\t\t\tif(p[num]) break;\n\t\t\tc++;\n\t\t}\n\t\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\ntypedef long long ll;\ntypedef long double ld;\ntypedef signed long long sll;\ntypedef unsigned long long ull;\n#define all(s) ((s).begin()),((s).end())\n#define rall(s) ((s).rbegin()),((s).rend())\n#define Pi 3.141592653589793238462643383279502884197169399375106\nconst int OO=INT_MAX;\n\nusing namespace std;\nvoid Yuko_Kurama()\n{\n cin.tie(0);\n ios::sync_with_stdio(false);\n}\nmap p;\nvoid sieve()\n{\n\tint n=1010;\n\tp[1]=true;\n\tfor(int i=2;i*i<=n;i++)\n\t{\n\t\tif(!p[i])\n\t\t{\n\t\tfor(int j=i*2;j>n)\n\t{\n\t\tint x,y,num=2,c=1;\n\t\twhile (1)\n\t\t{\n\t\t\tnum=n*c+1;\n\t\t\tif(p[num]) break;\n\t\t\tc++;\n\t\t}\n\t\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define INF 2147483647\n\n\nint main() {\n\tios_base::sync_with_stdio(false);\n\n\tint a, b, tic_a, tic_b; cin >> a >> b >> tic_a >> tic_b;\n\tint total; cin >> total;\n\tint min, max; \n\n\tmin = total - ((tic_a - 1) * a + (tic_b - 1) * b); \n\tif (min < 0) {\n\t\tmin = 0;\n\t}\n\tmax = a + b; \n\t\n\twhile (a * tic_a + b * tic_b > total) {\n\t\tmax -= 1; \n\t\tif (tic_a > tic_b && a > 0) {\n\t\t\ta -= 1; \n\t\t}\n\t\telse if(b>0){ \n\t\t\tb -= 1; \n\t\t}\n\t}\n\n\tcout << min << \" \" << max << \"\\n\"; \n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a22dfc4524129ac29fd9e03ea2239cfe", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \n#include \nusing namespace std;\n\n\nint main(){\n\tint a1, a2;\n\tcin >> a1 >> a2;\n\tint k1, k2;\n\tcin >> k1 >> k2;\n\tint n;\n\tcin >> n;\n\tint minRes = 0;\n\tint maxRes = 0;\n\tint bigFirst[a1 + a2] = {};\n\tint minCards = k1;\n\tint minTeam = a1;\n\tint maxCards = k2;\n\tint maxTeam = a2;\n\tif(k1 > k2){\n\t\tminCards = k2;\n\t\tminTeam = a2;\n\t\tmaxCards = k1;\n\t\tmaxTeam = a1;\n\t}\n\tfor(int i = 0; i < maxTeam; i++){\n\t\tbigFirst[i] = maxCards;\n\t}\n\tfor(int i = 0; i < minTeam; i++){\n\t\tbigFirst[maxTeam + i] = minCards;\n\t}\n\tint cards = n;\n\tint index = 0;\n\twhile(cards > 0){\n\t\tif(bigFirst[index % (a1 + a2)] > 1){\n\t\t\tbigFirst[index % (a1 + a2)]--;\n\t\t\tcards--;\n\t\t}\n\t\tindex++;\n\t}\n\tfor(int i = 0; i < a1 + a2; i++) {\n\t\tif(bigFirst[i] == 0) minRes++;\n\t}\n\tint lowFirst[a1 + a2] = {};\n\tfor(int i = 0; i < minTeam; i++){\n\t\tlowFirst[i] = minCards;\n\t}\n\tfor(int i = 0; i < maxTeam; i++){\n\t\tlowFirst[minTeam + i] = maxCards;\n\t}\n\tcards = n;\n\tindex = 0;\n\twhile(cards > 0){\n\t\tif(lowFirst[index % (a1 + a2)] > 0){\n\t\t\tlowFirst[index % (a1 + a2)]--;\n\t\t\tcards--;\n\t\t} else index++;\n\t}\n\tfor(int i = 0; i < a1 + a2; i++){\n\t\tif(lowFirst[i] == 0) maxRes++;\n\t}\n\tcout << minRes << \" \" << maxRes << endl;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "24943350c1a8a52859bbe0169f84f7eb", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n#define ll long long\ntypedef pair ii;\nll a1, a2, k1, k2, n;\npriority_queue heap;\nint main()\n{\n cin >> a1 >> a2 >> k1 >> k2 >> n;\n ll r1 = 0, r2 = 0;\n for(int i = 0;i <= a1;i++)\n for(int j = 0;j <= a2;j++)\n if(k1 * i + k2 * j <= n)\n r2 = max(r2,(ll) i + j);\n for(int i = 1;i <= a1;i++)\n heap.push(ii(k1, 1));\n for(int i = 1;i <= a2;i++)\n heap.push(ii(k2, 2));\n while(heap.size() > 0){\n ii t = heap.top();\n heap.pop();\n if(t.first == 0) break;\n if(t.second == 1){\n if(t.first >= k1) heap.push(ii(t.first - k1 + 1, 1)), n = n -(k1 - 1);\n else heap.push(ii(0, 1)), r1++, n -= t.first;\n }else\n if(t.first >= k2) heap.push(ii(t.first - k2 + 1, 2)), n = n - (k2 - 1);\n else heap.push(ii(0, 2)), r1++, n -= t.first;\n if(n <= 0) break;\n }\n cout << r1 << \" \" << r2;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ae59b8b0253743ce2d411de7f850ee50", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std;\n\n\n#define N 1000005\n\n\n\nint n; int trie[N<<5][2];\n\n\nstruct edge{ int des; int next; int w; }e[N<<1];\n\nint cnt; int head[N]; int dist[N];\n\nvoid ins(int u,int v,int w){\n ++cnt; e[cnt].des=v; e[cnt].next=head[u]; e[cnt].w=w; head[u]=cnt;\n}\n\nvoid dfs(int u,int f){\n for(int i=head[u];i;i=e[i].next){\n int v=e[i].des;\n if(v==f) continue;\n dist[v]=dist[u]^e[i].w;\n dfs(v,u);\n }\n}\n\nint tim;\n\nvoid build(int x){\n int cur=0;\n for(int i=30;i>=0;--i){\n int t=x&(1<=0;--i){\n int t=x&(1<\n#include\n#include\nusing namespace std;\nint main()\n{\n\tint r,c;\n\tcin>>r>>c;\t\n\tchar a[1000][1000],b[1000];\n\tfor(int i=0;i<=r;i++)\n\t{\t\n\t\tgets(b);\n\t\tfor (int j=0;j\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define lp(i,n) for(int (i)=0; (i)<(n); (i)++)\n#define sz(v) int((v).size())\n#define all(v) (v).begin(),(v).end()\ntypedef long long ll;\ntypedef pair ii;\ntypedef vector vi;\ntypedef vector vii;\ntypedef vector vvi;\ntypedef vector vvii;\n\nconst int OO = int(1e12);\n\n\nint main() {\n freopen(\"input.txt\", \"r\", stdin);\n int r, c, cntr = 0, cntc = 0;\n scanf(\"%d %d\", &r, &c);\n bool fr = 1, fc = 1;\n vector> cake(r, vector(c));\n lp(i, r) {\n fr = 1;\n string str; \n cin >> str;\n lp(j, c) { \n cake[i][j] = str[j];\n if (cake[i][j] == 'S') {\n fr = 0; break;\n }\n }\n if (fr == 1) {\n cntr++;\n }\n }\n lp(i, c) {\n fc = 1;\n lp(j, r) {\n if (cake[j][i] == 'S') {\n fc = 0; break;\n }\n }\n if (fc == 1) {\n cntc++;\n }\n }\n\n printf(\"%d\\n\", cntr*c + cntc*r - cntr*cntc);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8064253d9b08b5852930a09f8b04f0f2", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\ninline int read() {\n\tchar c = getchar(); int x = 0, f = 1;\n\twhile(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}\n\twhile(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();\n\treturn x * f;\n}\nusing namespace std;\nint r,c,b[10001][10001],ans;\nchar a;\nint main()\n{\n\tr=read();\n\tc=read();\n\tfor(int i=1;i<=r;++i) \n\t for(int j=1;j<=c;++j)\n\t {\n\t \tcin>>a;\n\t \tif(a=='S')\n\t \t {\n\t \t \tfor(int e=1;e<=r;++e)\n\t \t \t b[e][j]++;\n\t \t \tfor(int e=1;e<=c;++e)\n\t \t \t b[i][e]++;\n\t\t }\n\t }\n\tfor(int i=1;i<=r;++i) \n\t for(int j=1;j<=c;++j)\n\t {\n\t \tif(b[i][j]<2)\n\t \t ans++;\n\t }\n\tcout<\n#include\n\nusing namespace std;\n\n#define ll long long\n#define nada \"\\n\"\n#define st string\n#define S second\n#define F first\n#define pb push_back\n#define MP make_pair\n#define isnttriangle(a,b,c) (a+b= b; i--)\n#define repp(i,a,b) for (int i = int(a); i <=int(b); i++)\n#define rep(i, n) for (int i = 0; i >t;while(t--)\n#define mod 1000000009LL\n\n\nconst double ME = 2.71828;\nconst int N = 3e5 + 20;\nconst double pi = 3.141592653;\n\n\n\nvoid LOSER()\n{\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n}\n\nvoid file()\n{\n freopen(\"records.in\", \"r\", stdin);\n //freopen(\"text.out\", \"w\", stdout);\n}\n\nll gcd(ll a, ll b)\n{\n //Eculidean Algorthim\n return (!b) ? a : gcd(b, a % b);\n //complixty=log(ab);\n}\n\nll lcm(ll a,ll b)\n{\n return a / gcd(a, b) * b;\n}\n\nll Fib_recur(ll n)\n{\n vectorv(n+5,0);\n //BaseCase\n v[1]=0;\n v[2]=1;\n repp(i,3,n)v[i]=v[i-1]+v[i-2];\n return v[n];\n}\n\nbool isprime(int n)\n{\n for(int i = 2; i <= sqrt(n); i++)\n {\n if(n%i == 0)\n return false;\n }\n return true;\n}\n\n\nvoid Solve()\n{\n int row,coulm;\n setRow,Coulm;\n char arr[row][coulm];\n\n\n cin>>row>>coulm;\n\n\n rep(i,row)\n {\n rep(j,coulm)\n {\n\n cin>>arr[i][j];\n if(arr[i][j]=='S')\n {\n\n Row.insert(i);\n Coulm.insert(j);\n }\n }\n }\n\n\n cout<<(row*coulm)-(sz(Row)*sz(Coulm));\n}\n//\"I AM A LOSER \ud83d\udc38\ud83e\udd26\u200d\u2640\";\n\nint main()\n{\n // fx(7)\n //file();\n LOSER();\n //Test{}\n Solve();\n\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dd37c63caf294f7caf166f48e3d65326", "src_uid": "ebaf7d89c623d006a6f1ffd025892102", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std;\n\nusing ll = long long;\n\nint c, v0, a, l, v1, read, per;\nll ans;\n\nint main() {\n cin.tie(0);\n ios::sync_with_stdio(false);\n\n cin >> c >> v0 >> v1 >> a >> l;\n\n read = c;\n ans = 0;\n\n for (int i = 0; ; ++i) {\n if (i > 0) read += l;\n per = a * i;\n if (per > v1) per = v1;\n read -= (v0 + per);\n ans++;\n if (read <= 0) break;\n }\n\n cout << ans << endl;\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "474e80f988010669b02c40e4677a4e20", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include\n\nusing namespace std;\n\nint c,v0,v1,a,l,k;\n\nbool check(int t)\n{\n int p=t;\n if(t>k)p=k;\n int res=v0*t-(t-1)*l+(p-1)*p*a/2;\n\n if((v1-v0)%a!=0)\n {\n res+=(t-p)*((v1-v0)%a);\n }\n\n if(res>=c)return 1;\n else return 0;\n}\n\nint main ()\n{\n ios::sync_with_stdio(false);\n\n int beg,end,mid;\n\n cin>>c>>v0>>v1>>a>>l;\n\n beg=1;\n end=1000;\n\n k=(v1-v0)/a+1;\n if((v1-v0)%a!=0)k++;\n\n while(beg!=end)\n {\n mid=(beg+end)/2;\n\n if(check(mid)==true)\n {\n end=mid;\n }\n else beg=mid+1;\n }\n\n cout<\n\nint page[1111];\n\nint main(void)\n{\n\tint c, v0, v1, a, l;\n\tscanf(\"%d %d %d %d %d\", &c, &v0, &v1, &a, &l);\n\tif (c <= v0)\n\t{\n\t\tprintf(\"1\\n\");\n\t\treturn false;\n\t}\n\tpage[1] = v0;\n\tint ans;\n\tif (a == 0)\n\t{\n\t\tfor (int i = 2; i <= 1111; i++)\n\t\t{\n\t\t\tif (page[i - 1] >= c)\n\t\t\t{\n\t\t\t\tans = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tpage[i] = page[i - 1] + v0;\n\t\t}\n\t}\n\n\tfor (int i = 2; i <= 1111; i++)\n\t{\n\t\tif (page[i - 1] >= c)\n\t\t{\n\t\t\tans = i;\n\t\t\tbreak;\n\t\t}\n\t\tint tmp = v1 - l;\n\t\tif (v1 - l >= a)\n\t\t{\n\t\t\tpage[i] = page[i - 1] + a;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tpage[i] = page[i - 1] + tmp;\n\t\t}\n\t}\n\t\n\tprintf(\"%d\\n\", ans-1);\n\treturn false;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ea9f9960a407693fce266924f9dff81e", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\nint main()\n{\n int c,v0,v1,a,l;\n bool fin = false;\n scanf(\"%d%d%d%d%d\",c,v0,v1,a,l);\n \n int pos = v0, add = v0;\n int t = 1;\n \n while(pos < c)\n {\n add = min(v1, add+a);\n pos += add - l;\n t++;\n }\n cout << t << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "17345529e924bffde80f769303271f7e", "src_uid": "b743110117ce13e2090367fd038d3b50", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "/*#include \n#include \n#include \nusing namespace std;\nint main()\n{\n\n int a[2];int d;\n cin>>a[0]>>a[1]>>a[2]>>d;\n sort(a,a+ 2);\n if ((abs(a[1]-a[0])=d)&&(abs(a[2]-a[1])>=d))cout << 0;\n\n if (abs(a[1]-a[0])>=d){cout << (abs(d-abs(a[2]-a[1])));}\n\n if (abs(a[2]-a[1])>=d)cout << (abs(d-abs(a[1]-a[0])));\n return 0;\n\n}*/\n#include \n#include \nusing namespace std;\nvoid swap(int* a, int* b)\n{\n int t = *a;\n *a = *b;\n *b = t;\n}\n\nint partition (int arr[], int low, int high)\n{\n int pivot = arr[high];\n int i = (low - 1);\n\n for (int j = low; j <= high - 1; j++)\n {\n if (arr[j] <= pivot)\n {\n i++;\n swap(&arr[i], &arr[j]);\n }\n }\n swap(&arr[i + 1], &arr[high]);\n return (i + 1);\n}\nvoid quickSort(int arr[], int low, int high)\n{\n if (low < high)\n{\n\n int pi = partition(arr, low, high);\n quickSort(arr, low, pi - 1);\n quickSort(arr, pi + 1, high);\n }\n}\n\n\n\nint main()\n{\n\n int a[2];int d;\n cin>>a[0]>>a[1]>>a[2]>>d;quickSort(a, 0, 2);\n if ((abs(a[1]-a[0])=d)&&(abs(a[2]-a[1])>=d))cout << 0;\n else\n if (abs(a[1]-a[0])>=d){cout << (abs(d-abs(a[2]-a[1])));}\n else\n if (abs(a[2]-a[1])>=d)cout << (abs(d-abs(a[1]-a[0])));\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8ea760871e3fbf1a087bc57583a1718f", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n\nusing namespace std;\n\n#define LL long long\n\nLL a,b,c,d,ans;\nLL pos1,pos2,pos3;\n\nint main() {\n cin>>a>>b>>c>>d;\n pos1 = min(min(a,b),c);\n pos3 = max(max(a,b),c);\n pos2 = a+b+c - pos1 - pos3;\n LL left = 0,right = 0;\n left = pos2 - pos1;\n right = pos3 - pos2;\n if(left < d) ans += (d - left);\n if(right < d) ans += (d - right);\n cout<\nusing namespace std;\nint main()\n{\n int n=3,arr[2],step=0,d;\n for(int i=0;i>arr[i];\n }\n cin>>d;\n sort(arr,arr+2);\n int e,f;\n e=d-abs(arr[0]-(arr[1]));\n step+=e;\n f=d-abs(arr[1]-arr[2]);\n step+=f;\n cout<\nusing namespace std;\n\nint main()\n{\n\n \n int arr[3];\n while(1)\n {\n int a,b,c,d,d1=0;\n cin>>a>>b>>c>>d;\n arr[0]=a;\n arr[1]=b;\n arr[2]=c;\n sort(arr,arr+3);\n // cout<\n#include \n\nusing namespace std;\n\nint main()\n{\n long int d,i,j; int k,l,m,n;\n j=0;\n freopen(\"input.txt\", \"r\", stdin);\n //scanf(\"%d %d %d %d %ld\",&k,&l,&m,&n,&d);\n cin>>k>>l>>m>>n>>d;\n int a[d];\n for (i=1;i<=d;i++) {\n if (i%k==0) {\n a[i]=1;\n }\n else if (i%l==0){\n a[i]=1;\n }\n else if (i%m==0){\n a[i]=1;\n }\n else if (i%n==0){\n a[i]=1;\n }\n if (a[i]==1) j=j+1;\n }\n freopen(\"output.txt\",\"w\",stdout);\n //printf(\"%ld\",j);\n cout<\n\nusing namespace std;\n\nint main()\n{\n long int d,i,j; int k,l,m,n;\n j=0;\n freopen(\"input.txt\", \"r\", stdin);\n scanf(\"%d\",&k);\n scanf(\"%d\",&l);\n scanf(\"%d\",&m);\n scanf(\"%d\",&n);\n scanf(\"%ld\",&d);\n int a[d];\n for (i=1;i<=d;i++) {\n if (i%k==0) a[i]=1;\n if (i%l==0) a[i]=1;\n if (i%m==0) a[i]=1;\n if (i%n==0) a[i]=1;\n if (a[i]==1) j=j+1;\n }\n freopen(\"output.txt\",\"w\",stdout);\n printf(\"%ld\",j);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "74fd04ec11afac94e0934d84b3f7dc2a", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nvoid main () {\n\tint a[4], d, k = 0;\n\tcin >> a[0] >> a[1] >> a[2] >> a[3] >> d;\n\tfor (int i = 0; i < d; i++) {\n\t\tint c = i + 1;\n\t\tif (c % a[0] == 0 || c % a[1] == 0 || c % a[2] == 0 || c % a[3] == 0) {\n\t\t\tk++;\n\t\t}\n\t}\n\tcout << k;\n\tgetch ();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "025ea36c6a230a2390d2ec77fa1cb7a7", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nvoid main () {\n\tint a[4], d, k;\n\tbool f[20200];\n\tcin >> a[0] >> a[1] >> a[2] >> a[3] >> d;\n\tfor (int i = 0; i < d; i++) {\n\t\tf[i] = true;\n\t}\n\tshort i;\n\tfor (i = 0; i < 4; i++) {\n\t\tk = a[i] - 1;\n\t\twhile (k < d) {\n\t\t\tf[k] = false;\n\t\t\tk += a[i];\n\t\t}\n\t}\n\tint ans = 0;\n\tfor (i = 0; i < d; i++) {\n\t\tif (!f[i]) {\n\t\t\tans++;\n\t\t}\n\t}\n\tcout << ans;\n\tgetch ();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cbf7164678d6f11d0caa58d570ef925e", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nint main()\n{\n do {\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n } while (false);\n string L, R;\n cin >> L >> R;\n reverse(L.begin(), L.end());\n L.resize(R.size(), '0');\n reverse(L.begin(), L.end());\n int n, m = 0;\n cin >> n;\n const int sigma = 10, M = 3 * R.size() * sigma + 100;\n vector > son(M, vector(sigma, 0)), sum(M, vector(R.size(), 0));\n function gen = [&] (int idx, int u, bool big, bool small, bool start) {\n if (idx >= R.size() || (big && small)) {\n sum[u][R.size() - idx]++;\n } else {\n for (int i = (big ? 0 : L[idx] - '0'); i <= (small ? 9 : R[idx] - '0'); i++) {\n int v = u;\n if (start || i) {\n if (!son[u][i]) {\n son[u][i] = m++;\n }\n v = son[u][i];\n }\n gen(idx + 1, v, big || L[idx] - '0' < i, small || R[idx] - '0' > i, start || i);\n }\n }\n };\n gen(0, m++, false, false, false);\n vector fail(m);\n auto build = [&] () {\n queue que;\n que.push(0);\n while (!que.empty()) {\n int u = que.front();\n que.pop();\n for (int i = 0; i < sigma; i++) {\n if (!son[u][i]) {\n son[u][i] = son[fail[u]][i];\n } else {\n int v = fail[u];\n while (v && !son[v][i]) {\n v = fail[v];\n }\n if (son[v][i] && son[v][i] != son[u][i]) {\n fail[son[u][i]] = son[v][i];\n for (int j = 0; j < R.size(); j++) {\n sum[son[u][i]][j] += sum[son[v][i]][j];\n }\n }\n que.push(son[u][i]);\n }\n }\n }\n };\n build();\n for (int u = 0; u < m; u++) {\n for (int i = 1; i < R.size(); i++) {\n sum[u][i] += sum[u][i - 1];\n }\n }\n vector > dp(n + 1, vector(m, -1e9));\n dp[0][0] = 0;\n for (int i = 0; i < n; i++) {\n for (int u = 0; u < m; u++) {\n if (dp[i][u] >= 0) {\n for (int j = 0; j < sigma; j++) {\n int v = u;\n while (v && !son[v][j]) {\n v = fail[v];\n }\n v = son[v][j];\n dp[i + 1][v] = max(dp[i + 1][v], dp[i][u] + sum[v][min((int)R.size(), n - i) - 1]);\n }\n }\n }\n }\n int goal = *max_element(dp[n].begin(), dp[n].end());\n cout << goal << endl;\n vector > on(n + 1, vector(m));\n for (int i = 0; i < m; i++) {\n on[n][i] = dp[n][i] == goal;\n }\n for (int i = n - 1; i >= 0; i--) {\n for (int u = 0; u < m; u++) {\n if (dp[i][u] >= 0) {\n bool ok = false;\n for (int j = 0; j < sigma; j++) {\n int v = u;\n while (v && !son[v][j]) {\n v = fail[v];\n }\n v = son[v][j];\n ok |= on[i + 1][v] && dp[i][u] + sum[v][min((int)R.size(), n - i) - 1] == dp[i + 1][v];\n }\n on[i][u] = ok;\n }\n }\n }\n int u = 0;\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < sigma; j++) {\n int v = u;\n while (v && !son[v][j]) {\n v = fail[v];\n }\n v = son[v][j];\n if (on[i + 1][v] && dp[i][u] + sum[v][min((int)R.size(), n - i) - 1] == dp[i + 1][v]) {\n cout << j;\n u = v;\n break;\n }\n }\n }\n cout << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f1fb65961a7b130032d82fd2f1b742b3", "src_uid": "2e79c95bf4c2b7de8a4741b24a880829", "difficulty": 3500.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n//#pragma GCC optimize(\"Ofast\")\n//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n\n#define ms(s, n) memset(s, n, sizeof(s))\n#define FOR(i, a, b) for (int i = (a); i < (b); ++i)\n#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)\n#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)\n#define sz(a) int((a).size())\n#define present(t, x) (t.find(x) != t.end())\n#define all(a) (a).begin(), (a).end()\n#define uni(a) (a).erase(unique(all(a)), (a).end())\n#define pb push_back\n#define pf push_front\n#define mp make_pair\n#define fi first\n#define se second\n#define prec(n) fixed<> (i)) & 1)\n#define bitcount(n) __builtin_popcountll(n)\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef pair pi;\ntypedef vector vi;\ntypedef vector vii;\nconst int MOD = (int) 1e9 + 7;\nconst int FFTMOD = 119 << 23 | 1;\nconst int INF = (int) 1e9 + 23111992;\nconst ll LINF = (ll) 1e18 + 23111992;\nconst ld PI = acos((ld) -1);\nconst ld EPS = 1e-9;\ninline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}\ninline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}\ninline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}\ntemplate inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}\ntemplate inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}\ninline ull isqrt(ull k) {ull r = sqrt(k) + 1; while (r * r > k) r--; return r;}\ninline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}\ninline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}\ninline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}\ninline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}\ninline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}\ninline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}\ninline int sign(ld x, ld y) {return sign(x - y);}\nmt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());\ninline int myrand() {return abs((int) mt());}\n#define db(x) cerr << #x << \" = \" << (x) << \" \";\n#define endln cerr << \"\\n\";\n\nconst int maxn = 1e5 + 5;\nconst int maxc = 10;\nstruct node_t {\n node_t* p;\n node_t* c[maxc];\n node_t *bf, *gf;\n int key;\n char val;\n vector info;\n node_t();\n void clear();\n} pool[maxn], *ptr = pool;\nnode_t::node_t() {\n clear();\n}\nvoid node_t::clear() {\n p = 0;\n for (int i = 0; i < maxc; i++) c[i] = 0;\n bf = gf = 0, key = -1, val = 0;\n}\nvoid clear() {\n node_t* st = pool;\n while (st != ptr) {\n st->clear();\n st++;\n }\n ptr = pool;\n}\nnode_t* insert(node_t* x, char* s, int key, int len) {\n while (*s) {\n int k = *s - '0';\n if (!x->c[k]) {\n x->c[k] = ptr++;\n x->c[k]->p = x;\n x->c[k]->val = k;\n }\n x = x->c[k];\n s++;\n }\n x->key = key;\n x->info.push_back(len);\n return x;\n}\nvoid pushlink(node_t* rt) {\n static node_t* q[maxn];\n int b = 0, e = 0;\n q[e++] = rt;\n while (b < e) {\n node_t* x = q[b++];\n for (int i = 0; i < maxc; i++) {\n if (x->c[i]) q[e++] = x->c[i];\n }\n if (x == rt || x->p == rt) {\n x->bf = rt;\n x->gf = 0;\n }\n else {\n x->bf = x->p->bf;\n while (x->bf != rt && !x->bf->c[x->val]) x->bf = x->bf->bf;\n if (x->bf->c[x->val]) x->bf = x->bf->c[x->val];\n if (x->bf->key != -1) x->gf = x->bf;\n else x->gf = x->bf->gf;\n for (int e : x->bf->info) {\n x->info.push_back(e);\n }\n sort(x->info.begin(), x->info.end());\n }\n }\n}\n\nstring l, r;\nint n;\nnode_t* rt;\nvector f;\nvector dp;\n\nint calc(int u, int v) {\n if (u == n) return 0;\n int& res = dp[u][v];\n if (~res) return res;\n res = 0;\n FOR(i, 0, 10) {\n node_t* cur = pool + v;\n while (cur != rt && !cur->c[i]) {\n cur = cur->bf;\n }\n int cost = f[n - u][i], nv = cur - pool;\n if (cur->c[i]) {\n cur = cur->c[i];\n nv = cur - pool;\n if (cur->key == -1) {\n cur = cur->gf;\n }\n if (cur) {\n cost += upper_bound(all(cur->info), n - u) - cur->info.begin();\n }\n }\n chkmax(res, calc(u + 1, nv) + cost);\n }\n return res;\n}\n\nvoid chemthan() {\n cin >> l >> r >> n;\n vector g(10);\n if (sz(l) < sz(r)) {\n FOR(i, 1, r[0] - '0') {\n g[i].pb(sz(r));\n }\n FOR(i, sz(l) + 1, sz(r)) {\n FOR(j, 1, 10) {\n g[j].pb(i);\n }\n }\n FOR(i, l[0] - '0' + 1, 10) {\n g[i].pb(sz(l));\n }\n }\n else {\n FOR(i, l[0] - '0' + 1, r[0] - '0') {\n g[i].pb(sz(r));\n }\n }\n FOR(i, 1, 10) sort(all(g[i]));\n f.resize(n + 1, vi(10));\n FOR(i, 1, n + 1) FOR(j, 1, 10) {\n f[i][j] = upper_bound(all(g[j]), i) - g[j].begin();\n }\n rt = ptr++;\n int flag = sz(l) < sz(r) || l[0] < r[0];\n FOR(i, 1, sz(r)) {\n FOR(j, 0, r[i] - '0') {\n if (flag || l[i] - '0' < j) {\n insert(rt, (char *) (r.substr(0, i) + char('0' + j)).data(), 0, sz(r) - i);\n }\n }\n if (!flag) {\n flag |= l[i] < r[i];\n }\n }\n flag = sz(l) < sz(r) || l[0] < r[0];\n FOR(i, 1, sz(l)) {\n FOR(j, l[i] - '0' + 1, 10) {\n if (flag) {\n insert(rt, (char *) (l.substr(0, i) + char('0' + j)).data(), 0, sz(l) - i);\n }\n }\n if (!flag) {\n flag |= l[i] < r[i];\n }\n }\n insert(rt, (char *) l.data(), 0, 1);\n if (l < r) {\n insert(rt, (char *) r.data(), 0, 1);\n }\n pushlink(rt);\n dp.resize(n + 1);\n for (auto& e : dp) e.resize(ptr - pool, -1);\n int mx = calc(0, 0);\n cout << mx << \"\\n\";\n string res;\n int u = 0, v = 0;\n FOR(it, 0, n) {\n FOR(i, 0, 10) {\n node_t* cur = pool + v;\n while (cur != rt && !cur->c[i]) {\n cur = cur->bf;\n }\n int cost = f[n - u][i], nv = cur - pool;\n if (cur->c[i]) {\n cur = cur->c[i];\n nv = cur - pool;\n if (cur->key == -1) {\n cur = cur->gf;\n }\n if (cur) {\n cost += upper_bound(all(cur->info), n - u) - cur->info.begin();\n }\n }\n if (calc(u + 1, nv) + cost == mx) {\n res += char('0' + i);\n mx -= cost;\n u++, v = nv;\n break;\n }\n }\n }\n cout << res << \"\\n\";\n}\n\nint main(int argc, char* argv[]) {\n ios_base::sync_with_stdio(0), cin.tie(0);\n if (argc > 1) {\n assert(freopen(argv[1], \"r\", stdin));\n }\n if (argc > 2) {\n assert(freopen(argv[2], \"wb\", stdout));\n }\n chemthan();\n cerr << \"\\nTime elapsed: \" << 1000 * clock() / CLOCKS_PER_SEC << \"ms\\n\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8e20c2d4704823c24049389deeb69fb3", "src_uid": "2e79c95bf4c2b7de8a4741b24a880829", "difficulty": 3500.0} {"lang": "GNU C++11", "source_code": "#include \n#define M 40005\n#define N 2005\n#define FI first\n#define SE second\n#define MP std::make_pair\n#define PB push_back\n#define mod 998244353\n#define INF 1000000000\ntypedef long long ll;\nchar A[M], B[M];\nint n, lenA, lenB;\nint read() {\n\tint ans = 0; char c = getchar();\n\twhile (c < '0' || c > '9') c = getchar();\n\twhile (c >= '0' && c <= '9') ans = ans * 10 + c - '0', c = getchar();\n\treturn ans;\n}\nvoid Write(int x) {\n\tif (x < 10) putchar(x + '0');\n\telse Write(x / 10), putchar(x % 10 + '0');\n\treturn;\n}\nint max(int x, int y) {return x > y ? x : y;}\nint min(int x, int y) {return x < y ? x : y;}\nnamespace AC {\n\tint son[M][N], fail[M],\tval[M][N], F[M][N], cnt = 1, cur_len;\n\tchar AA[M], BB[M];\n\tvoid DFS(int l, int x, bool bl = true, bool br = true) {\n\t\tif (l > cur_len || (!bl && !br)) return val[x][cur_len + 1 - l]++, void();\n\t\tfor (int i = (bl ? AA[l] - '0' : 0); i <= (br ? BB[l] - '0' : 9); i++)\n\t\t\tDFS(l + 1, son[x][i] ? son[x][i] : son[x][i] = ++cnt, bl & (i + '0' == AA[l]), br & (i + '0' == BB[l]));\n\t\treturn;\n\t}\n\tvoid build() {\n\t\tif (lenA == lenB) return cur_len = lenA, memcpy(AA + 1, A + 1, lenA), memcpy(BB + 1, B + 1, lenB), DFS(1, 1);\n\t\tmemcpy(AA + 1, A + 1, lenA), memset(BB + 1, '9', lenA), cur_len = lenA, DFS(1, 1);\n\t\tmemcpy(BB + 1, B + 1, lenB), memset(AA + 1, '0', lenB), AA[1] = '1', cur_len = lenB, DFS(1, 1);\n\t\tfor (int i = lenA + 1; i < lenB; i++)\n\t\t\tfor (int j = 1; j < 10; j++) val[son[1][j] ? son[1][j] : son[1][j] = ++cnt][i - 1]++;\n\t\treturn;\n\t}\n\tvoid get_fail() {\n\t\tstd::queue Q;\n\t\tfor (int i = 0; i < 10; i++)\n\t\t\tif (son[1][i]) Q.push(son[1][i]), fail[son[1][i]] = 1;\n\t\t\telse son[1][i] = 1;\n\t\twhile (!Q.empty()) {\n\t\t\tint now = Q.front(); Q.pop();\n\t\t\tfor (int i = 0; i <= n; i++) val[now][i] += val[fail[now]][i];\n\t\t\tfor (int i = 0; i < 10; i++)\n\t\t\t\tif (son[now][i]) fail[son[now][i]] = son[fail[now]][i], Q.push(son[now][i]);\n\t\t\t\telse son[now][i] = son[fail[now]][i];\n\t\t}\n\t\tfor (int i = 1; i <= cnt; i++)\n\t\t\tfor (int j = 1; j <= n; j++) val[i][j] += val[i][j - 1];\n\t\treturn;\n\t}\n\tvoid find_ans(int x, int y){\n\t\tif (!y) return;\n\t\tfor (int i = 0; i < 10; i++)\n\t\t\tif (son[x][i] && F[x][y] == F[son[x][i]][y - 1] + val[x][y]) return putchar(i + '0'), find_ans(son[x][i], y - 1);\n\t\treturn assert(0), void();\n\t}\n\tvoid DP() {\n\t\tfor (int i = 1; i <= cnt; i++) F[i][0] = val[i][0];\n\t\tfor (int j = 1; j <= n; j++)\n\t\t\tfor (int i = 1; i <= cnt; i++)\n\t\t\t\tfor (int k = 0; k < 10; k++)\n\t\t\t\t\tif (son[i][k]) F[i][j] = max(F[i][j], F[son[i][k]][j - 1] + val[i][j]);\n\t\treturn Write(F[1][n]), putchar('\\n'), find_ans(1, n);\n\t}\n}\nint main() {\n\tscanf(\"%s%s\", A + 1, B + 1); n = read(); lenA = strlen(A + 1), lenB = strlen(B + 1);\n\treturn AC::build(), AC::get_fail(), AC::DP(), 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5eece0e21c0985eee78c65defa76e097", "src_uid": "2e79c95bf4c2b7de8a4741b24a880829", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "#include\n#define mod 1e9+7\n#define inf 0x3f3f3f\ntypedef long long ll;\ntypedef long double ld;\nusing namespace std;\nstruct P{\n\tint c[10];\n\tint sum[810];\n\tint fail,num;\n}p[16010];\nchar l[2000],r[2000],t[2010];\nint n,cnt,len,tl,la1,la2=1;\nvoid dfs(int x,int le){\n\tint nxt=0;\n\tif(p[x].c[t[le]])nxt=p[x].c[t[le]];\n\telse {\n\t\tp[x].c[t[le]]=++cnt;\n\t\tnxt=cnt;\n\t\t//cout<ans[j][!(i&1)]+(char)(p[v].num+'0')){\n\t\t\t\t\t\tans[v][i&1]=ans[j][!(i&1)]+(char)(p[v].num+'0');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//cout<ans[v][i&1]){\n\t\t\t\t\t\tres=ans[v][i&1];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\\n\",Max);\n\tcout<\nusing namespace std;\n\nint a[100000000];\nvoid init()\n{\n int cnt=0;\n for(int i=1;i<=100000;i++)\n {\n long long temp=i;\n int p=i;\n while(p){\n temp=temp*10+p%10;\n p/=10;\n }\n a[++cnt]=temp;\n }\n}\n\nint main ()\n{\n\tinit();\n\tlong long k,p;\n\tcin >>k >> p;\n\tint i = 1;\n\tlong long sum = 0;\n\tlong long temp;\n\tfor (int i =1; i < 100000; ++i)\n\t\tcout << a[i] << endl;\n\tfor (int i = 1; i <= k; ++i)\n\t{\n\t\tsum += a[i];\n\t\tsum %= p;\n\t} \n\tcout << sum << endl;\n\treturn 0;\n } \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "48320080431ce8a7a40e62d90d1e8276", "src_uid": "00e90909a77ce9e22bb7cbf1285b0609", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include \n#define x first\n#define y second \n#define mk make_pair\n\ntypedef long long ll;\n \nusing namespace std;\n\nint main()\n{\n\tint k, p;\n\tcin >> k >> p;\n\tvector v;\n\tfor(int i = 1; i <= 9; i++){\n\t\tint d = i * 10;\n\t\td += i;\n\t\tv.push_back(d * 1LL);\n\t}\n\tfor(int i = 1; i <= 9; i++){\n\t\tfor(int j = 0; j <= 9; j++){\n\t\t\tint d = i * 1000 + j * 100 + j * 10 + i;\n\t\t\tv.push_back(d * 1LL);\n\t\t}\n\t}\n\tfor(int i = 1; i <= 9; i++){\n\t\tfor(int j = 0; j <= 9; j++){\n\t\t\tfor(int k = 0; k <= 9; k++){\n\t\t\t\tint d = i * 100000 + j * 10000 + k * 1000 + k * 100 + j * 10 + i;\n\t\t\t\tv.push_back(d * 1LL);\n\t\t\t}\n\t\t}\n\t}\n\tfor(int i = 1; i <= 9; i++){\n\t\tfor(int j = 0; j <= 9; j++){\n\t\t\tfor(int k = 0; k <= 9; k++){\n\t\t\t\tfor(int l = 0; l <= 9; l++){\n\t\t\t\t\tint d = i * 10000000 + j * 1000000 + k * 100000 + l * 10000 + l * 1000 + k * 100 + j * 10 + i;\n\t\t\t\t\tv.push_back(d * 1LL);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor(int i = 1; i <= 9; i++){\n\t\tfor(int j = 0; j <= 9; j++){\n\t\t\tfor(int k = 0; k <= 9; k++){\n\t\t\t\tfor(int l = 0; l <= 9; l++){\n\t\t\t\t\tfor(int m = 0; m <= 9; m++){\n\t\t\t\t\t\tlong long d = i * 1000000000 + j * 100000000 + k * 10000000 + l * 1000000 + m * 100000 + m * 10000 + l * 1000 + k * 100 + j * 10 + i;\n\t\t\t\t\t\tv.push_back(d); \n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tv.push_back(100000000001);\n\tlong long sum = 0;\n\tfor(int i = 0; i < k; i++){\n\t\tsum = (sum + v[i]) % p;\n\t}\n\tcout << sum;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c0b13f6cdd3872a2eca745dd60405ad9", "src_uid": "00e90909a77ce9e22bb7cbf1285b0609", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\ntypedef long long int64;\n\nint64 sol, n, mod;\nint64 p[25];\n\nbool ok (int a){\n int b = a;\n int con = 0;\n vector v;\n while (b > 0){\n\t\t v.push_back (b%10);\n\t\t b /= 10, con++;\n\t }\n \n if (con%2) return false;\n \n while (!v.empty())\n if (*v.begin() != *v.rbegin()) return false;\n else{\n\t\t\t v.erase (v.begin());\n\t\t\t \n\t\t\t v.pop_back();\n\t\t\t }\n\t\t\t \n\treturn true;\t\t \n}\n\nint main(){\n\t\n\tp[0] = 1;\n\tfor (int i = 1; i <= 15; i++) p[i] = p[i-1]*10ll;\n\t\n\tvector > v;\n\tv.push_back ({0, 2});\n\tfor (int i = 11; i < 100; i++){\n\t if (ok (i))\n\t v.push_back ({i, 2});\n\t}\n\t\n\tint p1 = 0;\n\tfor (int i = 0; i < 1000000; i++){\n\t auto a = v[p1++];\n\t for (int64 j = 1; j <= 9; j++){\n\t\t int64 x = (a.first * 10ll + j) + (p[a.second+1] * j);\n\t\t v.push_back ({x,a.second+2}); \n\t\t }\n\t}\n\t\n\tsort (v.begin(), v.end());\n\t\n\t//for (int i = 1; i <= 100; i++) printf (\"%lld\\n\", v[i].first);\n\t\n\tscanf (\"%lld %lld\", &n, &mod);\n\tfor (int i = 1; i <= n; i++){\n\t\t sol = (sol+v[i].first) % mod;\n\t //printf (\"%d %lld\\n\", i, v[i].first);\n\t}\n\tprintf (\"%lld\\n\", sol);\n\t\n return 0;\t\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e9e052dc0623937fc46486a6cf26d7e9", "src_uid": "00e90909a77ce9e22bb7cbf1285b0609", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\ntypedef double db;\ntypedef long long ll;\ntypedef pair pii;\nconst ll mINF = 1000 * 1000 * 1000 + 9;\nconst db ebs = 0.000001;\n\nint main()\n{\n /*\n freopen(\"\", \"r\", stdin);\n freopen(\"\", \"w\", stdout);\n */\n\n int kol_vo, del;\n cin >> kol_vo >> del;\n vector v;\n v.push_back(0);\n for(int c=10; c<100; c++)\n if(c == (c%10)*10+c/10)v.push_back(c);\n int j = 0, now = 100, last = 10, p = 1;\n while(v.size()-p < kol_vo){\n int dop = 0;\n for(int c=j; c<=v.size(); c++){\n for(int i=0; i<=9; i++){\n v.push_back(i*now+v[c]*(now/10)+i);\n if(i*now+v[c]*(now/10)+i == 0)p++;\n dop++;\n }\n }\n j = last;\n last += dop;\n now*=100;\n }\n ll sum=0, n=0, c=0;\n while(n < kol_vo){\n if(v[c]){\n sum += v[c];\n sum %= del;\n n++;\n }\n c++;\n }\n cout << sum;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "668bc542570b2be2f0b5d6d1601b78a3", "src_uid": "00e90909a77ce9e22bb7cbf1285b0609", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\n#define ll long long int\n#define ull unsingned long long int\n#define pi 2*acos(0.0)\n\n\nint main()\n{\n ll t,cases=1;\n char a[1000],b[1000];\n while(true)\n {\n scanf(\"%s %s\",a,b);\n puts(a);\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cee729694f606b0dfeb5874f43b9c674", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\n#define ll long long int\nusing namespace std;\nint main()\n{\n ll a,b,i;\n ios_base::sync_with_stdio(false);\n cin>>a>>b;\n ll ans=0;\n if(a!=b)\n ans=__gcd(a,a+1);\n else{\n ans=a;\n cout<\n#define ll long long int\nusing namespace std;\nint main()\n{\n ll a,b,i;\n ios_base::sync_with_stdio(false);\n cin>>a>>b;\n ll ans=0;\n if(a!=b)\n ans=__gcd(a,a+1);\n else{\n ans=a;\n cout<\n#include\nusing namespace std;\nchar a[205],b[205];\nint main(){\n\tscanf(\"%s%s\",a,b);\n\tif(strlen(a)!=strlen(b)){\n\t\tprintf(\"1\");\n\t\treturn 0;\n\t}\n\tfor(int i=1;i<=strlen(a);i++)if(a[i]!=b[i]){\n\t\tprintf(\"1\");\n\t\treturn 0;\n\t}\n\tprintf(\"%s\",a);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c3c0dbe32d80fb06423a0088174e1d77", "src_uid": "9c5b6d8a20414d160069010b2965b896", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "//#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n//end of libraries ;\n// freopen(\"input.txt\",\"r\",stdin);\n// freopen(\"output.txt\",\"w\",stdout);\n// \n// ll lmin(ll o , ll w) {if(o a, b;\nstring c = \"codeforces\";\nvoid dfs(){\n ll s = 1 , q = 0;\n for(int i = 0 ; i < 10 ; i++){\n s *= a[i];\n q += a[i];\n }\n if(s>=k){\n if(q < ans){\n ans = q;\n b = a;\n }\n }\n else {\n for(int i = 0 ; i < 10 ; i ++){\n if(a[i]+1<=19){\n a[i]++;\n dfs();\n if(a[i]-1>0) a[i]--;\n }\n }\n }\n}\nint main(){\n cin >> k;\n ll x = 1;\n while(pow(x,10) < k){\n x++;\n if(pow(x,10) > k) { x-=1; break;}\n }\n for(int i = 1 ; i<= 10 ; i++) a.pb(x);\n dfs(); \n for(int i = 0 ; i \nusing namespace std;\n#define ll long long int\n#define T int t;cin>>t;while(t--)\n#define pb push_back\n\nint main()\n{\n ll c[11],i,n,j,p;\n vectorv;\n mapm;\n cin>>n;\n for(i=1;i<=10;i++)\n c[i]=1;\n j=sqrt(n);\n p=pow(n,0.1);\n for(i=2;i<=j;i++)\n {\n if(n%i==0)\n {\n v.push_back(i);\n while(n%i==0)\n {\n n=n/i;\n m[i]++;\n }\n }\n if(n==1)\n break;\n }\n if(n!=1)\n {\n v.push_back(n);\n m[n]++;\n }\n sort(v.begin(),v.end());\n i=1;\n for(j=v.size()-1;j>=0;j--)\n {\n n=v[j];\n while(m[n])\n {\n if(c[i]<=p)\n {\n c[i]=c[i]*n;\n m[n]--;\n }\n if(m[n]==0)\n break;\n i++;\n if(i==11)\n i=1;\n }\n }\n while(c[1]--)\n cout<<'c';\n while(c[2]--)\n cout<<'o';\n while(c[3]--)\n cout<<'d';\n while(c[4]--)\n cout<<'e';\n while(c[5]--)\n cout<<'f';\n while(c[6]--)\n cout<<'o';\n while(c[7]--)\n cout<<'r';\n while(c[8]--)\n cout<<'c';\n while(c[9]--)\n cout<<'e';\n while(c[10]--)\n cout<<'s';\n ////\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2816d571f621e0a73cfd2e3f87e0901d", "src_uid": "8001a7570766cadcc538217e941b3031", "difficulty": 1500.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\nusing namespace __gnu_pbds;\n\n#define ll long long\n#define mk make_pair\n\ntemplate >\nusing ordered_set = tree;\nconst ll mod = 1e9 + 7;\n\n/*\n if you have any question about any part of my code,\n please don't shy to ask anytime :)\n*/\n\nvoid solve()\n{\n ll n;\n cin >> n;\n vector x(10, 1);\n string ans = \"codeforces\";\n\n ll cnt=0;\n while (true)\n {\n ll p = 1;\n for(int i=0;i=n)\n {\n break;\n }\n\n x[cnt]++;\n cnt++;\n }\n \n \n for (int i = 0; i < 10; i++)\n {\n while (x[i]--)\n {\n cout << ans[i];\n }\n }\n cout << endl;\n}\n\nint main()\n{\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n\n // ll t;\n // cin >> t;\n // while (t--)\n // {\n // solve();\n // }\n solve();\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1bb5f1247f53104808670d6d965c10b5", "src_uid": "8001a7570766cadcc538217e941b3031", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\n\n\n\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tcout.tie(NULL);\n\n\tll t;\n\tcin>>t;\n\tcout<<\"codeforces\";\n\tif(t>=2)\n\t{ t/=2;\n\t\n\twhile(t--)\n\t{\n\t\tcout<<\"es\"<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\nusing namespace std;\n\n#define in cin\n#define out cout\n#define dout if(true) cout\n\ntypedef long long num;\n\nint main()\n{\n\tnum n,m,a,b;\n\tin >> n >> m >> a >> b;\n\t\n\ta--;b--;\t//indexing from 0;\n\t\n\tint ans = 3;\n\tif ((a/m) == (b/m)){\n\t\tans = 1;\t//same row\n\t}\n\telse if (((a%m) == 0) && ((b%m) == (m-1))){\n\t\tans = 1;\n\t}\n\telse if (((a%m) == 0) || ((b%m) == (m-1))){\n\t\tans = 2;\n\t}\n\telse if ((a%m) == ((b%m) + 1)){\n\t\tans = 2;\n\t}else if ((a/m) == ((b/m)-1)){\n\t\tans = 2;\n\t}\n\telse{\n\t\t//int top = m-(a%m);\n\t\t//int bottom = (b%m)+1;\n\t\tthrow \"magic\";\n\t\tnum next_row = (a/m)+1;\n\t\tnum last_row = (b/m);\t\t\n\t\tnum rows = last_row - next_row;\n\t\t\n\t\tif (rows < 0) rows = 0;\n\t\t\n\t\tans = 3;\n\t\t//if (rows > 0) ans ++;\n\t\t//dout << top << \" \" << bottom << \" \" << rows << endl;\n\t}\n\t\n\tout << ans << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "60c860ac43c19222efc8230aa8cb0e1b", "src_uid": "f256235c0b2815aae85a6f9435c69dac", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef vector vi; \ntypedef vector vvi; \ntypedef pair pii; \n\n#define\t\t\t\tpb\tpush_back\n#define\t present(x, c)\t((c).find(x) != (c).end()) \t\t\t// used for map and set. //\n#define\t\tforn(i, n)\tfor(int i = 0; i < n; i++)\n#define S scanf\n#define P printf\n\nint main()\n{\n int n,m,a,b;\n cin>>n>>m>>a>>b;\n int ans;\n \n if(b/m == a/m) ans =1;\n \n else\n if((b/m) - (a/m) ==1) \n {\n if(a%m==1 && b%m==0) ans=1;\n else ans=2;\n }\n \n else\n {\n ans=3;\n \n if(a%m == 1) ans--;\n \n if(b%m == 0 || b==n) ans--;\n \n if((b%m) == (a%m)-1) if(ans==3) ans=2;\n }\n cout<\n#include\n#include\nusing namespace std;\nconst int N=1e5+9;\n#define inf N\nchar str[N];\nint k,cnt;\nbool mark[30];\nstruct xx\n{\n int id,n;\n bool operator <(const xx &c)const\n {\n return n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define PB push_back\n#define MP make_pair\n\n#define REP(i,n) for(i=0;i<(n);++i)\n#define FOR(i,l,h) for(i=(l);i<=(h);++i)\n#define FORD(i,h,l) for(i=(h);i>=(l);--i)\n\ntypedef vector VI;\ntypedef vector VS;\ntypedef vector VD;\ntemplate X gcd(X a, X b) {return b == 0 ? a : gcd(b, a % b);}\n\nint main() {\n int T;\n\t//scanf(\"%d\", &T);\n\tT = 1;\n\twhile (T--) {\n\t\tint n, m, a, b;\n\t\tscanf(\"%d%d%d%d\", &n, &m, &a, &b);\n\t\t--a;\n\t\t--b;\n\t\tint row1 = a / m;\n\t\tint col1 = a % m;\n\t\tint row2 = b / m;\n\t\tint col2 = b % m;\n\t\tint ret;\n\t\tif (row1 == row2) {\n\t\t\tret = 1;\n\t\t} else if (row2 - row1 == 1) {\n\t\t\tret = 2;\n\t\t\tif (col1 == 0 && col2 == m - 1) {\n\t\t\t\tret = 1;\n\t\t\t}\n\t\t} else {\n\t\t\tif (col1 < col2) {\n\t\t\t\tret = 3;\n\t\t\t\tif (col1 == 0) {\n\t\t\t\t\t--ret;\n\t\t\t\t}\n\t\t\t\tif (col2 == m - 1 || b == n - 1) {\n\t\t\t\t\t--ret;\n\t\t\t\t}\n\t\t\t} else if (col1 == col2) {\n\t\t\t\tret = 3;\n\t\t\t\tif (col1 == 0) {\n\t\t\t\t\t--ret;\n\t\t\t\t}\n\t\t\t\tif (col2 == m - 1 || b == n - 1) {\n\t\t\t\t\t--ret;\n\t\t\t\t}\n\t\t\t} else if (col1 > col2){\n\t\t\t\tret = 3;\n\t\t\t\tif (col1 - col2 == 1 || b == n - 1) {\n\t\t\t\t\tret = 2;\n\t\t\t\t} \n\t\t\t}\n\t\t}\n\t\tprintf(\"%d\\n\", ret);\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "038f28018b470197bb215bef4291229a", "src_uid": "f256235c0b2815aae85a6f9435c69dac", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define pb push_back\n#define mp make_pair\n#define pii pair\n#define vi vector\n#define vpii vector\n#define SZ(x) ((int)(x.size()))\n#define fi first\n#define se second\n#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))\n#define FORI(i,n) for(int (i)=1;(i)<=(n);++(i))\n#define IN(x,y) ((y).find((x))!=(y).end())\n#define ALL(t) t.begin(),t.end()\n#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)\n#define REP(i,a,b) for(int (i)=(a);(i)<=(b);++i)\n#define REPD(i,a,b) for(int (i)=(a); (i)>=(b);--i)\n#define REMAX(a,b) (a)=max((a),(b));\n#define REMIN(a,b) (a)=min((a),(b));\n#define DBG cerr << \"debug here\" << endl;\n#define DBGV(vari) cerr << #vari<< \" = \"<< (vari) <& a) {\n int iters = 0;\n while (1) {\n bool found = false;\n for (int i = 0; i+1 < a.size(); ++i) {\n if (a[i] >= a[i+1]+2) {\n a[i]--;\n a[i+1]++;\n found = 1;\n break;\n }\n if (a[i+1] >= a[i]+2) {\n a[i+1]--;\n a[i]++;\n found = 1;\n break;\n }\n }\n ++iters;\n if (iters > 200) {\n return true;\n }\n if (!found) break;\n }\n return false;\n}\nvoid print(const vector& a) {\n cout << \"############\" << endl;\n for (auto e : a) {\n cout << e << \" \";\n }\n cout << endl;\n cout << \"############\" << endl;\n}\nint main()\n{\n ios_base::sync_with_stdio(0);\n int n;\n cin >> n;\n vector a(n);\n for (int i = 0; i < n; ++i) cin >> a[i];\n vector b = a;\n sort(b.begin(), b.end());\n int last = n-1;\n while (1) {\n bool loop = make_fall(a);\n if (loop) {\n cout << \"NO\" << endl;\n return 0;\n }\n bool done = true;\n for (int i = 0; i+1 < n; ++i) {\n if (a[i] > a[i+1]) {\n done = false;\n break;\n }\n }\n if (done) {\n break;\n }\n int m_idx = 0;\n for (int i = 1; i <= last; ++i) {\n if (a[i] > a[m_idx]) {\n m_idx = i;\n }\n }\n int tmp = a[m_idx];\n for (int i = m_idx; i < last; ++i) {\n a[i] = a[i+1];\n }\n a[last] = tmp;\n --last;\n loop = make_fall(a);\n if (loop) {\n cout << \"NO\" << endl;\n return 0;\n }\n }\n bool loop = make_fall(a);\n if (loop) {\n cout << \"NO\" << endl;\n return 0;\n }\n cout << (a == b ? \"YES\" : \"NO\") << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "925a85ee04addec8603c5e47705aa84a", "src_uid": "704d0ae50bccaa8bc49319812ae0be45", "difficulty": 1600.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\n\n\nbool isSort(const vector &a, int n) {\n\tfor (int i = 1; i < n; i++) {\n\t\tif (a[i - 1] >= a[i])\n\t\t\treturn false;\n\t}\n\treturn true;\n}\n\nint main() {\n\tint n;\n\tcin >> n;\n\n\tvector arr(n);\n\tcin >> arr[0];\n\tfor (int i = 1; i < n; i++) {\n\t\tcin >> arr[i];\n\t\tif (abs(arr[i - 1] - arr[i]) >= 2) {\n\t\t\tcout << \"NO\";\n\t\t\treturn 0;\n\t\t}\n\t}\n\t\n\tint offset = 0;\n\twhile (!isSort(arr, n)) {\n\t\tint maxx = -(1 << 30), indMax = -1;\n\t\tfor (int i = offset; i < n; i++)\t{\n\t\t\tif (arr[i] > maxx) {\n\t\t\t\tmaxx = arr[i];\n\t\t\t\tindMax = i;\n\t\t\t}\n\t\t}\n\t\toffset++;\n\t\tarr.erase(arr.begin() + indMax);\n\t\tarr.insert(arr.begin(), maxx);\n\n\t\tfor (int i = 1; i < n; i++) {\n\t\t\tif (abs(arr[i - 1] - arr[i]) >= 2) {\n\t\t\t\tcout << \"NO\";\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\n\tcout << \"YES\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2e454f53dc6de4b49e272ae6963fe98b", "src_uid": "704d0ae50bccaa8bc49319812ae0be45", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nint main()\n{\n int n; cin >> n;\n vectorv;\n for (int i=0 ; i> v[i];\n if (i && abs(v[i]-v[i-1])>1)\n return cout << \"NO\", 0;\n }\n cout << \"YES\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d3677cafb7f0df38e88cfb8fff3b82b1", "src_uid": "704d0ae50bccaa8bc49319812ae0be45", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include\n#include\ntypedef unsigned long long ull;\nusing namespace std;\nint n,cnt,m,a[100000000];\nint main(){\n\tcin>>n;\n\tfor(int i=1;i>a[i];\n\t}\n\tsort(a+1,a+n+1);\n\tfor(int i=1;ia[i+1]){\n\t\t\tcout<<\"NO\";\n\t\t\treturn 0;\n\t\t}\n\t}\n\tcout<<\"YES\";\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f311f0c27014e156a1d09334697399b3", "src_uid": "704d0ae50bccaa8bc49319812ae0be45", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n#define ll long long\nll n, k;\nvectorv;\nint main() {\n\tscanf(\"%I64d %I64d\", &n, &k);\n\tif (n <= k && n > 1) {\n\t\tprintf(\"%d\", 1);\n\t\treturn 0;\n\t}\n\t\tfor (int i = 0; i <= k; i++) {\n\t\t\tif (i == 1)\n\t\t\t\tcontinue;\n\t\t\tv.push_back(i);\n\t\t}\n\t\tint cnt = 1;\n\t\tfor (unsigned i = 1; i 1) {\n\t\t\t\tv[i] += v[i - 1];\n\t\t\t}\n\t\t\telse\n\t\t\t\tv[i] += (v[i - 1]);\n\t\t}\n\t\tfor (unsigned i = 2; i < v.size(); i++) {\n\t\t\tv[i] -= cnt++;\n\t\t}\n\t\tint s = 0, e = v.size()-1, ans;\n\t\twhile (s < e) {\n\t\t\tint mid = s + (e - s + 1) / 2;\n\t\t\tif (v[mid] == n) {\n\t\t\t\te = mid - 1;\n\t\t\t\tans = mid;\n\t\t\t}\n\t\t\telse {\n\t\t\t\ts = mid;\n\t\t\t\tans = -1;\n\t\t\t}\n\t\t}\n\t\tcout << ans << endl;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7bf4602957a1c31ab6c196bf8dfafc8e", "src_uid": "83bcfe32db302fbae18e8a95d89cf411", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "# include \nusing namespace std;\nvector v;\nint bs(long long int n,int s,int e){\n\tint mid = (s+e)/2;\n\tcout << v[mid] << \" \" << mid << \" \" << s << \" \" << e << endl;\n\tif(s<=e){\n\t\tif(v[mid]=n-1){\n\t\t\treturn mid;\n\t\t}\n\t\telse if(v[mid]> n >> k_;\n\tif(n==1){\n\t\tcout << 0;\n\t}\n\telse if(n-1 > (k_*(k_-1))/2){\n\t\t// cout << (k*(k-1))/2;\n\t\tcout << -1;\n\t}\n\telse if(n-1 == (k_*(k_-1))/2){\n\t\tcout << k_-1;\n\t}\n\telse if(n==k_){\n\t\tcout << 1;\n\t}\n\telse{\n\t\tint k= (int) k_;\n\t\tv.push_back(k-1);\n\t\tfor(int i=1;i\nusing namespace std;\nint mini = INT_MAX;\nvoid f(int count,int left,int k_){\n\t// cout << count << \" \" << left << endl;\n\tif(left==0){\n\t\tif(count0){\n\t\tfor(int i=k_;i>=2;i--){\n\t\t\tif(count==0){\n\t\t\t\tf(count+1,left-i,k_-1);\n\t\t\t\tf(count,left,k_-1);\t\t\t\n\t\t\t}\n\t\t\telse{\n\t\t\t\tf(count+1,left-i+1,k_-1);\n\t\t\t\tf(count,left,k_-1);\t\t\t\t\n\t\t\t}\n\t\t}\n\t}\n}\n\nint main(){\n\tlong long int n,k;\n\tcin >> n >> k;\n\tf(0,n,k);\n\tif(mini==INT_MAX){\n\t\tcout << -1;\n\t}\n\telse{\n\t\tcout << mini;\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "90427cc9808ea231b95951dd20da0bf5", "src_uid": "83bcfe32db302fbae18e8a95d89cf411", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n\nmain()\n{\n long long int n,sum=0;\n int i=0,x=0,last=0,l=0,k=0;\n scanf(\"%I64d\",&n);\n scanf(\"%d\",&k);\n if(n==1)\n {\n printf(\"0\");\n return 0;\n };\n l=1;\n while(1)\n {\n last=l;\n sum=(l+k)*(k-l)/2;\n if(sum==n)\n {\n printf(\"%d\",(k-l));\n return 0;\n }else\n {\n if(sum>n)\n {\n l=(l+k)/2;\n if(l==last+1)\n {\n printf(\"%d\",(k-l));\n return 0;\n }\n }else\n {\n l=(l+1)/2;\n }\n };\n printf(\"%d %d\\n\",l,last);\n getch();\n if(last==l)\n {\n printf(\"-1\");\n return 0;\n }\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d0ad39fa89bf7941aa7b5ce9c4169168", "src_uid": "83bcfe32db302fbae18e8a95d89cf411", "difficulty": 1700.0} {"lang": "GNU C++20 (64)", "source_code": "#include\r\n\r\nusing namespace std;\r\n\r\n#define pb push_back\r\n#define pf push_front\r\n\r\n#define ll long long\r\n#define ld long double\r\n\r\n#define all(v) v.begin(),v.end()\r\n#define rall(v) v.rbegin(),v.rend()\r\n\r\n#define int ll\r\n#define double ld\r\n\r\n#define yes cout<<\"YES\\n\";\r\n#define no cout<<\"NO\\n\";\r\n\r\nconst int N=2e5+100;\r\n\r\nint n,a[105],sum,g,ind;\r\nint memo[101][2000001];\r\n\r\n\r\nbool dp(int i,int s){\r\n\r\n if(i==n+1&&s&&s*2==g)return 1;\r\n if(i==n+1)return 0;\r\n\r\n int &ans=memo[i][s];\r\n if(ans!=-1)return ans;\r\n ans=dp(i+1,s);\r\n ans|=dp(i+1,s+a[i]);\r\n\r\n return ans;\r\n}\r\n\r\n\r\nvoid solveg(int testi){\r\n\r\n cin>>n;\r\n\r\n\r\n sum=0;\r\n\r\n int mn=1e18;\r\n int indmn=-1;\r\n for(int i=1;i<=n;i++){\r\n cin>>a[i];\r\n sum+=a[i];\r\n mn=min(mn,a[i]);\r\n if(a[i]==mn)indmn=i;\r\n }\r\n memset(memo,-1,sizeof memo);\r\n g=sum;\r\n if(!dp(1,0)){\r\n cout<<\"0\\n\";\r\n return ;\r\n }\r\n cout<<\"1\\n\"<>test;\r\n for(int testi=1;testi<=test;testi++){\r\n solveg(testi);\r\n // _clear();\r\n }\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2e0edef614c3cdd9ec953bccff8e8906", "src_uid": "29063ad54712b4911c6bf871969ee147", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include\r\n// #include \r\n// #include \r\n\r\nusing namespace std;\r\n// using namespace __gnu_pbds;\r\n\r\n//#define endl \"\\n\"\r\n#define ll long long\r\n#define int long long\r\n#define ff first\r\n#define ss second\r\n#define fl(i,a,b) for(int i=(int)a; i<(int)b; i++)\r\n#define bfl(i,a,b) for(int i=(int)a-1; i>=(int)b; i--)\r\n#define pb push_back\r\n#define mp make_pair\r\n#define pii pair\r\n#define vi vector\r\n#define vt(type) vector\r\n#define you_can_do_it ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);\r\n#define mii map\r\n#define pqb priority_queue\r\n//Below is implementation of min heap\r\n#define pqs priority_queue >\r\n#define setbits(x) __builtin_popcountll(x)\r\n#define zrobits(x) __builtin_ctzll(x)\r\n#define mod 1000000007\r\n#define inf 1e18\r\n#define ps(x,y) fixed<>x; while(x--)\r\n#define pw(b,p) pow(b,p) + 0.1\r\n#define ini const int\r\n#define sz(v) ((int)(v).size())\r\n#define ppii pair\r\n#define tup tuple\r\n#define LEFT(x) 2*x+1\r\n#define RIGHT(x) 2*x+2\r\n#define all(v) v.begin(),v.end()\r\n#define rall(v) v.rbegin(),v.rend()\r\n\r\nconst double pi = acos(-1.0);\r\n\r\n#define PRINT(x) {print(x); return;}\r\n#define FOR(v) fl(i,0,(int)v.size()) read(v[i]);\r\n#define FOR1(v) fl(i,1,(int)v.size()+1) read(v[i]);\r\n\r\n#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator _it(_ss); err(_it, args); cout< it) {}\r\n//template\r\n//void err(istream_iterator it, T a, Args... args) {\r\n// cerr << *it << \" = \" << a << \" , \";\r\n// err(++it, args...);\r\n//}\r\n//\r\n//template\r\n//void print(T...args){\r\n// ((cout<\r\n//void read(T&...args){\r\n// ((cin>>args),...);\r\n//}\r\n\r\n/////// \\|/ \\|/ Credits: okwedook for template below \\|/ \\|/ ////////\r\ntemplate inline void checkmin(T &x, U y) { if (y < x) x = y; }\r\ntemplate inline void checkmax(T &x, U y) { if (y > x) x = y; }\r\ntemplate inline bool ifmax(T &x, U y) { if (y > x) return x = y, true; return false; }\r\ntemplate inline bool ifmin(T &x, U y) { if (y < x) return x = y, true; return false; }\r\ntemplate inline void sort(T &a) { sort(all(a)); }\r\ntemplate inline void rsort(T &a) { sort(rall(a)); }\r\ntemplate inline void reverse(T &a) { reverse(all(a)); }\r\ntemplate inline istream& operator>>(istream& str, pair &p) { return str >> p.ff >> p.ss; }\r\ntemplate inline istream& operator>>(istream& str, vector &a) { for (auto &i : a) str >> i; return str; }\r\n/////////////////////////////////////////////////////////////////////\r\n\r\n/*\r\n\r\nCredits : owen_up\r\n\r\nSOME BITMASK KNOWLEDGE\r\n1)x & (x - 1):sets the last one bit of x to zero\r\npower of two exactly when x & (x - 1) = 0.\r\n2)x & -x:sets all the one bits to zero, except last one bit\r\n3)x | (x - 1):inverts all the bits after the last one bit\r\n\r\n*/\r\n\r\n\r\n//1,2 ,3 ,4, ,5 ,6 ,7 ,8 ,9 ,10 digit prime\r\n//1,11,101,1187, 11489, 109229, 1000003, 10000019, 100000007, 1000000007\r\n//1,13,127,1009, 10007, 100003, 1000033, 10000079, 100000037, 1000000009\r\n\r\n\r\n\r\nvoid solve(int tc)\r\n{\r\n int n;\r\n cin>>n;\r\n vector v;\r\n int total = 0;\r\n for(int i=0;i>x;\r\n total+=x;\r\n v.pb(x);\r\n }\r\n if(total&1){\r\n cout<<0<>> dp(n+2,vector>(2,vector(total+2,-1)));\r\n std::function&)> f = [&](int i, int take, int sum, vector &cur){\r\n if(dp[i][take][sum]!=-1) return dp[i][take][sum];\r\n if(sum==0) return dp[i][take][sum] = true;\r\n if(i+1>=n) return dp[i][take][sum] = false;\r\n if(sum<0) return 0ll;\r\n// cout< temp;\r\n bool val = f(0,1,total/2,temp);\r\n val = val || f(0,0,total/2,temp);\r\n if(val){\r\n set w;\r\n for(auto ele:temp) w.insert(ele);\r\n vector temp2;\r\n for(auto ele:temp){\r\n if(v[ele]&1){\r\n cout<<1< diff;\r\n for(auto ele:temp){\r\n for(auto ele2:temp2){\r\n diff.insert(abs(ele-ele2));\r\n }\r\n }\r\n for(int i=0;i>t;\r\n for(int i=1;i<=t;i++){\r\n solve(i);\r\n }\r\n return 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3fdaa7e0c557c11215c4a3e21dcbf49e", "src_uid": "29063ad54712b4911c6bf871969ee147", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include\r\n#define pb push_back\r\n#define all(v) v.begin(),v.end()\r\n#define allr(v) v.rbegin(),v.rend()\r\n#define SORT(v) sort(all(v))\r\n#define int long long\r\n#define ff first\r\n#define ss second\r\n#define mod 1000000007\r\n#define endl \"\\n\"\r\n\r\nusing namespace std;\r\n\r\nvoid oj()\r\n{\r\n ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);\r\n #ifndef ONLINE_JUDGE \r\n freopen(\"input.txt\", \"r\", stdin);\r\n freopen(\"output.txt\", \"w\", stdout);\r\n #endif\r\n}\r\n\r\nint n; \r\nvectorv;\r\nint dp[101][500000];\r\nint find(int x, int sum)\r\n{\r\n if(x == n)\r\n {\r\n if(sum == 0)\r\n return 0;\r\n else\r\n return 1e15;\r\n }\r\n\r\n if(dp[x][sum + 200001] != -1)\r\n return dp[x][sum + 200001];\r\n return dp[x][sum + 200001] = min({1 + find(x + 1, sum), find(x + 1, sum - v[x]), find(x + 1, sum + v[x])});\r\n}\r\nvoid solve()\r\n{\r\n cin>>n;\r\n v = vector(n);\r\n\r\n for(int i = 0; i < n; i++)\r\n cin>>v[i];\r\n\r\n int temp = find(0, 0);\r\n if(temp == 0)\r\n cout<<1<<\"\\n\"<<1;\r\n else\r\n cout<<0;\r\n}\r\nsigned main()\r\n{\r\n oj(); \r\n // int t; cin>>t;\r\n // while(t--)\r\n solve();\r\n\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a9be15e9d3b1116d3066d2da9306245f", "src_uid": "29063ad54712b4911c6bf871969ee147", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include\r\nusing namespace std;\r\n \r\n#define ff first\r\n#define ss second\r\n#define pb push_back\r\n#define int long long\r\n#define mp make_pair\r\n#define pr pair\r\n#define vr vector\r\n#define MOD 1000000007\r\n#define mod 1000000007\r\n#define mod2 998244353\r\n#define inf 1e18\r\n#define ps(x,y) fixed<>x; while(x--)\r\n#define fill(a,b) memset(a, b, sizeof(a))\r\n#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);\r\n\r\nbool findPartiion(vector arr, int n)\r\n{\r\n int sum = 0;\r\n int i, j;\r\n for (i = 0; i < n; i++)\r\n sum += arr[i];\r\n \r\n if (sum % 2 != 0)\r\n return false;\r\n \r\n bool part[sum / 2 + 1][n + 1];\r\n \r\n\r\n for (i = 0; i <= n; i++)\r\n part[0][i] = true;\r\n \r\n\r\n for (i = 1; i <= sum / 2; i++)\r\n part[i][0] = false;\r\n \r\n\r\n for (i = 1; i <= sum / 2; i++) {\r\n for (j = 1; j <= n; j++) {\r\n part[i][j] = part[i][j - 1];\r\n if (i >= arr[j - 1])\r\n part[i][j] = part[i][j]\r\n || part[i - arr[j - 1]][j - 1];\r\n }\r\n }\r\n return part[sum / 2][n];\r\n}\r\n\r\n\r\nint32_t main() {\r\n int n;\r\n cin>>n;\r\n \r\n int a[n];\r\n int sum=0;\r\n vectorv1;\r\n for(int i=0;i>a[i];\r\n v1.pb(a[i]);\r\n sum+=a[i];\r\n \r\n }\r\n if(sum%2==1 || findPartiion(v1,n)==false){\r\n cout<<0<<\"\\n\";\r\n }\r\n else{\r\n cout<<1<<\"\\n\";\r\n \r\n for(int i=0;iv;\r\n for(int j=0;j\n\nusing namespace std;\n\nint main()\n{\n\tlong n, k, ans;\n\tcin >> n >> k;\n\tans = (n * 2) / k + (n * 5) / k + (n * 8) / k;\n\tif ((n * 2) % k != 0)\n\t\tans++;\n\tif ((n * 5) % k != 0)\n\t\tans++;\n\tif ((n * 8) % k != 0)\n\t\tans++;\n\tcout << ans;\n\tsystem(\"pause\");\n\t\n\treturn 0;\n \n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5c160227845e4e1949798d28db947b72", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef vector vi;\ntypedef vector vb;\n\null GCD(ull a, ull b){return b == 0 ? a : GCD(b, a % b); }\null LCM(ull a, ull b){ return a * (b / GCD(a, b)); }\n\n\nvoid re(double& x) { string s; cin >> s; x = stold(s); }\nint main(){\n\t\n\tios_base::sync_with_stdio(0);\n\tcin.tie(NULL);\n\tcout.tie(NULL);\t\n\t\n\tdouble n, k;\n\tre(n); re(k);\n\t\n\tvi need(n);\n\tneed = {n * 2, n * 5, n * 8};\n\t\n\tull ans = 0;\n\tfor(auto i : need) ans += i / k + (i % (int)k != 0);\n\t\n\tcout << ans << endl;\n\t\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0e56c102a0a458b20c9e2fdc666dad62", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef vector vi;\ntypedef vector vb;\n\null GCD(ull a, ull b){return b == 0 ? a : GCD(b, a % b); }\null LCM(ull a, ull b){ return a * (b / GCD(a, b)); }\n\n\nvoid re(double& x) { string s; cin >> s; x = stold(s); }\nint main(){\n\t\n\tios_base::sync_with_stdio(0);\n\tcin.tie(NULL);\n\tcout.tie(NULL);\t\n\t\n\tlong int n, k;\n\tcin >> n >> k;\n\t\n\tvi need(n);\n\tneed = {n * 2, n * 5, n * 8};\n\t\n\tint ans = 0;\n\tfor(int i : need) ans += (i / k) + (i % k != 0);\n\t\n\tcout << ans << endl;\n\t\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ab40d2ce868344ef4fa336656c14ac64", "src_uid": "d259a3a5c38af34b2a15d61157cc0a39", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint main()\n{\n float n,k;\n cin>>n >>k;\n float red=n*2;\n float green=n*5;\n float blue=n*8;\n int book1=ceil(red/k);\n int book2=ceil(green/k);\n int book3=ceil(blue/k);\n cout<\r\nusing namespace std;\r\n\r\nint main(){\r\n string s;\r\n cin>>s;\r\nint count=0;\r\n for(int i=0;i1){\r\n cout<<\"YES\"<\r\nnamespace pai{\r\n\t#define fi first\r\n\t#define se second\r\n\t#define pii pair\r\n\t#define pll pair\r\n\t#define psl pair\r\n\t#define pcc pair\r\n\t#define mp(i,j) make_pair(i,j)\r\n}\r\nnamespace vec{\r\n\t#define vei vector\r\n\t#define si size()\r\n\t#define em empty()\r\n\t#define pd(i) push_back(i)\r\n\t#define pb pop_back()\r\n}\r\nnamespace my_std{\r\n\tusing namespace std;\r\n\t#define ll long long\r\n\t#define ref(i,x,y) for(register int i=(x);i<=(y);i++)\r\n\t#define fer(i,x,y) for(register int i=(x);i>=(y);i--)\r\n\t#define il inline\r\n\t#define mpii map\r\n\t#define mpib map\r\n\t#define mpplll map\r\n\t#define mppccl map\r\n\t#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)\r\n\tchar buf[1 << 21], *p1 = buf, *p2 = buf;\r\n\tinline ll read() {\r\n\t char c = getchar();\r\n\t ll x = 0;\r\n\t for (; !isdigit(c); c = getchar()) ;\r\n\t for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);\r\n\t return x;\r\n\t}\r\n}\r\n\r\nusing namespace my_std;\r\nstring s;\r\nint main(){\r\n//\tcin.tie(0),cout.tie(0);\r\n//\tios::sync_with_stdio(false);\r\n//\twhile(getline(cin,s)) cout<<\"NO\\n\";\r\n//\tint n;\r\n//\tcin>>n;\r\n//\tcout<> ch) {\r\n//\t\tint y = ch - 65;\r\n//\t\tfib[++cnt] = y;\r\n//\t}\r\n//\tfor (int i = 3; i <= cnt; i++) {\r\n//\t\tif (fib[i] != fib[i - 1] + fib[i - 2]) {\r\n//\t\t\tcout << \"NO\" << endl; return 0;\r\n//\t\t}\r\n//\t}\r\n//\tcout << \"YES\";\r\n\tstring st;\r\n\tcin>>st;\r\n\tfor(int i=0;i1&&st[i]!=(st[i-1]+st[i-2])%26)//\u4ece\u7b2c\u4e09\u4f4d\u5f00\u59cb\u5904\u7406\uff0c\u76f8\u52a0\u7684\u548c\u8981\u5bf926\u53d6\u6a21\r\n\t\t{\u3000\r\n\t\t\tcout<<\"NO\";\r\n\t\t\treturn 0;\r\n\t\t}\u3000\r\n\t}\u3000\r\n\tcout<<\"YES\";\r\n\treturn 0;\r\n}\r\n\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "60d65daa930552bada8bc040528c6fc3", "src_uid": "27e977b41f5b6970a032d13e53db2a6a", "difficulty": 1400.0} {"lang": "GNU C++17", "source_code": "#include \r\nusing namespace std;\r\ntypedef long long int ll;\r\ntypedef long double ld;\r\nconst int inf = 2e9;\r\nconst ll INF = 9e18;\r\nconst ll mod = 1e9+7;\r\n \r\n#define int ll //\r\n#define F first\r\n#define S second\r\n#define vi vector\r\n#define vvi vector\r\n#define pi pair\r\n#define vpi vector\r\n#define pb push_back\r\n#define read(a) for(auto &x:a) cin >> x;\r\n#define print(a) for(auto x:a) cout << x << \" \"; cout << \"\\n\";\r\n\r\nsigned main(){\r\n ios_base::sync_with_stdio(0);\r\n cin.tie(0);\r\n\r\n #ifndef ONLINE_JUDGE\r\n freopen(\"in.txt\", \"r\", stdin);\r\n freopen(\"out.txt\", \"w\", stdout);\r\n #endif\r\n\r\n string s; cin >> s;\r\n bool ok = true;\r\n for(int i=2; i\r\n#include\r\nusing namespace std;\r\nint main() \r\n{\r\n string a;\r\n int i, x,y,z,h;\r\n cin.getline(a);\r\n bool flag=true;\r\n for(i=2;i26)\r\n x=x-26;\r\n if(x==h)\r\n {\r\n continue;\r\n }\r\n else\r\n {\r\n flag=false;\r\n break;\r\n }\r\n }\r\n if(flag==true)\r\n cout<<\"YES\";\r\n else\r\n cout<<\"NO\";\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e9f1d61360d483f930aee6378dd8961e", "src_uid": "27e977b41f5b6970a032d13e53db2a6a", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "/*\n\u0628\u0633\u0645 \u0627\u0644\u0644\u0647 \u0627\u0644\u0631\u062d\u0645\u0646 \u0627\u0644\u0631\u062d\u064a\u0645\n\n Md: Rezaul Karim Rana\nIslamic University , Kushtia\n\n*/\n#include \n\nusing namespace std;\n\n#define nl printf(\"\\n\")\n#define spc printf(\" \")\n#define sci(n) scanf(\"%ld\",&n)\n#define scc(n) scanf(\"%c\",&n)\n#define sc64(n) scanf(\"%I64d\",&n)\n#define scii(a,b) scanf(\"%ld %ld\",&a,&b)\n#define sc6464(a,b) scanf(\"%I64d %I64d\",&a,&b)\n#define scs(s) scanf(\"%s\",s)\n#define scss(a,b) scanf(\"%s %s\",a,b)\n#define scd(f) scanf(\"%lf\",&f)\n#define scdd(a,b) scanf(\"%lf %lf\",&a,&b)\n#define pfi(a) printf(\"%ld\",a)\n#define pfc(a) printf(\"%c\",a)\n#define pf64(a) printf(\"%I64d\",a)\n#define pfii(a,b) printf(\"%ld %ld\",a,b)\n#define pf6464(a,b) printf(\"%I64d %I64d\",a,b)\n#define pfs(a) printf(\"%s\",a)\n#define pfss(a,b) printf(\"%s %s\",a,b)\n#define pfd(a) printf(\"%lf\",a)\n#define pfdd(a,b) printf(\"%lf %lf\",a,b)\n#define inf 1000000000000LL\n#define eps 1e-11\n#define open freopen(\"input.txt\",\"r\",stdin)\n#define close freopen (\"output.txt\",\"w\",stdout)\n#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)\n#define rep1(i,n) for(__typeof(n) i=0; i<=(n); i++)\n#define rep2(i,n) for(__typeof(n) i=1; i<=(n); i++)\n#define rep3(i,a,b) for(__typeof(b) i=(a); i<=(b); i++)\n#define repe(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)\n#define pi 3.14159265358979323846264338327950\n#define max(a,b) (a>b?a:b)\n#define min(a,b) (a int len(const T&c){return (int)c.size();}\nlong long stoi(string s){long long n=0;rep(i,len(s))n=(n<<3)+(n<<1)+(s[i]-48);return n;}\nstring itos(long long n){ if(n==0) return \"0\"; string s;while(n){s+=(n%10+48);n/=10;}reverse(all(s));return s;}\nint main()\n{\n ios_base::sync_with_stdio(false);\n long n,k,k1,f=0,f1=0,p;\n cin>>n;\n long a[n+1];\n rep(i,4)\n {\n cin>>a[0]>>a[1]>>a[2]>>a[3];\n k=min(a[0],a[1]);\n k1=min(a[2],a[3]);\n if(k+k1<=n)\n {\n f=1;\n p=k;\n f1=i;\n }\n }\n if(!f)\n cout<<-1<\n#include \nusing namespace std;\nlong int min(long int x,long aint y)\n{if(x>y)\n{return y;}\nelse\n{ return x;}\n\n}\n\nint main()\n{\nlong long int n;\ncin>>n;\nlong long int a1,b1,c1,d1;\ncin>>a1>>b1>>c1>>d1;\nlong long int a2,b2,c2,d2;\ncin>>a2>>b2>>c2>>d2;\nlong long int a3,b3,c3,d3;\ncin>>a3>>b3>>c3>>d3;\nlong long int a4,b4,c4,d4;\ncin>>a4>>b4>>c4>>d4;\nlong int r1=min(a1,b1)+min(c1,d1);\nlong int r2=min(a2,b2)+min(c2,d2);\nlong int r3=min(a3,b3)+min(c3,d3);\nlong int r4=min(a4,b4)+min(c4,d4);\nif(n>=r1)\n{cout<<1<<\" \"<=r2)\n{cout<<2<<\" \"<=r3)\n{cout<<3<<\" \"<=r4)\n{cout<<4<<\" \"<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define PI acos(-1.0)\n#define inf 0x3f3f3f3f\n#define E exp(double(1))\n#define maxn 110000\n#define eps 1e-7\nusing namespace std;\ntypedef long long LL;\nint a[maxn];\nint b[maxn];\nint c[maxn];\nint d[maxn];\nint main(){\n\tint i,j,k;\n\tint n,m;\n\twhile(scanf(\"%d\",&n)!=EOF){\n\t\tfor(i=1;i<=4;i++){\n\t\t\tscanf(\"%d%d%d%d\",&a[i],&b[i],&c[i],&d[i]);\n\t\t}\n\t\tint ans1,ans2,num;\n\t\tbool ok=false;\n\t\tfor(i=1;i<=4;i++){\n\t\t\tif(a[i]+d[i]<=n){\n\t\t\t\tnum=i;\n\t\t\t\tok=true;\n\t\t\t\tans1=a[i];\n\t\t\t\tans2=n-d[i];\n\t\t\t\tbreak;\n\t\t\t}else if(b[i]+c[i]<=n){\n\t\t\t\tnum=i;\n\t\t\t\tok=true;\n\t\t\t\tans1=b[i];\n\t\t\t\tans2=n-c[i];\n\t\t\t\tbreak;\n\t\t\t}else if(a[i]+c[i]<=n){\n\t\t\t\tnum=i;\n\t\t\t\tok=true;\n\t\t\t\tans1=a[i];\n\t\t\t\tans2=n-c[i];\n\t\t\t\tbreak;\n\t\t\t}else if(b[i]+d[i]<=n){\n\t\t\t\tnum=i;\n\t\t\t\tok=true;\n\t\t\t\tans1=b[i];\n\t\t\t\tans2=n-d[i];\n\t\t\t\tbreak;\n\t\t}\n\t\tif(ok){\n\t\t\tprintf(\"%d %d %d\\n\",num,ans1,ans2);\n\t\t}else{\n\t\t\tputs(\"-1\");\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ce3aeab599409855a508387daba12fdd", "src_uid": "6e7ee0da980beb99ca49a5ddd04089a5", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include\n\n#define x first\n#define y second\n#define pb push_back\n#define inf 0x3f3f3f3f\n#define mod 1000000007\n#define sq(x) ((x)*(x))\n#define bit(x, y) (((x)>>(y))&1)\n#define bctz(x) (__builtin_ctz(x))\n#define bclz(x) (__builtin_clz(x))\n#define bclzl(x) (__builtin_clzl(x))\n#define bctzl(x) (__builtin_ctzl(x))\n#define bpt(x) (__builtin_popcount(x))\n#define bptl(x) (__builtin_popcountll(x))\n#define PQ priority_queue, greater >\n#define eps 1e-8\n#define squ(a, b) (a)*(a)+(b)*(b)\n#define pi 3.1415926535897932384626433832795\n\nusing namespace std;\n\ntypedef double DO;\ntypedef long double LD;\ntypedef long long INT;\ntypedef pair pii;\ntypedef pair pi3;\ntypedef vector VI;\n\ntemplate inline void smin(T &a, const U &b) {if(a>b) a=b;}\ntemplate inline void smax(T &a, const U &b) {if(a inline void gn(T &x) {char c, sg=0; while(c=getchar(), (c>'9' || c<'0') && c!='-'); for((c=='-' ? sg=1, c=getchar() : 0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0'; if(sg) x=-x;}\ntemplate inline void gn(T1 &x1, T2 &x2) {gn(x1), gn(x2);}\ntemplate inline void gn(T1 &x1, T2 &x2, T3 &x3) {gn(x1, x2), gn(x3);}\ntemplate inline void gn(T1 &x1, T2 &x2, T3 &x3, T4 &x4) {gn(x1, x2, x3), gn(x4);}\ntemplate inline void gn(T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5) {gn(x1, x2, x3, x4), gn(x5);}\n\ntemplate inline void print(T x) {if(x<0) {putchar('-'); return print(-x);} if(x<10) {putchar('0'+x); return ;} print(x/10); putchar(x%10+'0');}\ntemplate inline void println(T x) {print(x); putchar('\\n');}\ntemplate inline void printsp(T x) {print(x); putchar(' ');}\ntemplate inline void print(T1 x1, T2 x2) {printsp(x1), println(x2);}\ntemplate inline void print(T1 x1, T2 x2, T3 x3) {printsp(x1), printsp(x2), println(x3);}\ntemplate inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {printsp(x1), printsp(x2), printsp(x3), println(x4);}\ntemplate inline void print(T1 x1, T2 x2, T3 x3, T4 x4, T5 x5) {printsp(x1), printsp(x2), printsp(x3), printsp(x4), println(x5);}\n\nint power(int a, int b, int m, int ans=1) {\n\tfor (; b; b>>=1, a=1LL*a*a%m) if (b&1) ans=1LL*ans*a%m;\n\treturn ans;\n}\n\n#define NN 10\nint a[NN][NN];\n\nint main(){\n#ifndef ONLINE_JUDGE\n\tfreopen(\"in.in\", \"r\", stdin);\n\tfreopen(\"out.out\", \"w\", stdout);\n#endif\n\n\t int n;\n\t gn(n);\n\t \n\t for(int i=0; i<4; i++){\n\t \tfor (int j=0; j<4; j++){\n\t\t \tgn(a[i][j]);\n\t\t }\n\t }\n\t \n\t for(int i=0; i<4; i++){\n\t\t\n\t\tif(min(a[i][0], a[i][1])+min(a[i][2]+a[i][3])<=n) \n\t\t\treturn cout<\n#include\nint main()\n{\nint n,i,f;\nscanf(\"%d\",&n);\nif(n==3||n==5||n==7)\n{\nprintf(\"%d\",n);\nreturn 0;\n}\nprintf(\"3\\n\")\nprintf(\"3\");\nn=n-3;\nint prime(int x);\nfor(i=3;i<=n/2;i=i+2)\n if(prime(i)&&prime(n-i))\n {\n printf(\" %d %d\",i,n-i);\n return 0;\n }\nreturn 0;\n}\nint prime(int x)\n{\n int j;\n for(j=3;j*j<=x;j++)\n if(x%j==0) return 0;\n return 1;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fa6645db0f4d5f92ee1670835505044d", "src_uid": "f2aaa149ce81bf332d0b5d80b2a13bc3", "difficulty": 1800.0} {"lang": "MS C++ 2017", "source_code": "\ufeff#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define ll long long\n\nint main()\n{\n\tll n;\n\tcin >> n;\n\n\tvector erastofen(n + 1);\n\n\tll num = n / 2 - 1;\n\tfor (ll i = 2; i <= min(n, (ll)1e6); i++) {\n\t\tif (erastofen[i])\n\t\t\tcontinue;\n\t\tif (i * i <= n) {\n\t\t\tfor (ll j = i * i; j <= n; j += i)\n\t\t\t\terastofen[j] = true;\n\t\t}\n\t\telse {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (!erastofen[n]) {\n\t\tcout << 1 << \"\\n\";\n\t\tcout << n;\n\t\treturn 0;\n\t}\n\n\tll num = n / 2 - 1;\n\twhile (erastofen[num])\n\t\t--num;\n\n\tcout << 3 << \"\\n\";\n\tcout << n - num * 2 << ' ' << num << ' ' << num;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "124959d6e6ca07e1c90b3ce47ea7a44d", "src_uid": "f2aaa149ce81bf332d0b5d80b2a13bc3", "difficulty": 1800.0} {"lang": "MS C++", "source_code": "#include\nusing namespace std;\n//#include\n//#include\n//#include\n//#include\n//struct num\n//{\n// num()\n// {\n// numb = 0;\n// primes = 0;\n// }\n//public:\n// vector all;\n// int numb;\n// int primes;\n//};\n//int a[100000000];\n//vector numbers;\n//bool prim(int n)\n//{\n// if (n == 1) return false;\n// for (int i = 2; i <= (int)sqrt((double)n); i++)\n// {\n// if (n%i == 0) return false;\n// }\n// return true;\n//}\n//void find1(vector numbers,long n)\n//{\n// num a;\n// for (long i = 2; i <= n; i+=2)\n// {\n// numbers.push_back(a);\n// numbers.push_back(a);\n// numbers[i].numb = i;\n// numbers[i].numb = i;\n// if (prim(i))\n// {\n// numbers[i].all.push_back(i);\n// numbers[i].primes = 1;\n// }\n// else\n// {\n// \n// for (long j = i - 2; j > 1;j--)\n// {\n// int x = i;\n// if (!prim(i) && numbers[i].all.size() == 2) break;\n// bool is = prim(x - numbers[j].numb);\n// if (numbers[i].primes == 3 && is && numbers[j].primes == 1)\n// {\n// numbers[i].primes = 2;\n// numbers[i].all.clear();\n// numbers[i].all.push_back(x - numbers[j].numb);\n// numbers[i].all.push_back(numbers[j].numb);\n// break;\n// }\n// else if (numbers[i].primes == 2)\n// {\n// if (!is)continue;\n// else\n// {\n// numbers[i].primes += 1;\n// for (int k = 0; k < numbers[j].all.size();k++)\n// numbers[i].all.push_back(numbers[j].all[k]);\n// }\n// }\n// else if (numbers[i].primes <= 1)\n// {\n// if (is && numbers[j].primes<=2)\n// {\n// if (numbers[i].all.size()==0 || numbers[i].all.size() > 1 + numbers[j].primes)\n// {\n// numbers[i].all.clear();\n// numbers[i].primes += numbers[j].primes;\n// for (int k = 0; k < numbers[j].all.size(); k++)\n// numbers[i].all.push_back(numbers[j].all[k]);\n// x = x - numbers[j].numb;\n// numbers[i].all.push_back(x);\n// numbers[i].primes += 1;\n// }\n// }\n// else\n// {\n// if (numbers[j].primes <= 1 && (numbers[i].all.size() == 0 || numbers[i].all.size() >numbers[j].primes))\n// {\n// numbers[i].all.clear();\n// numbers[i].primes += numbers[j].primes;\n// for (int k = 0; k < numbers[j].all.size(); k++)\n// numbers[i].all.push_back(numbers[j].all[k]);\n// x = x - numbers[j].numb;\n// }\n// else continue;\n// }\n// }\n// }\n// }\n// }\n// cout << numbers[n].primes << endl;\n// for (int i = 0; i < numbers[n].all.size();i++)\n// if(numbers[n].all[i]!=0) cout << numbers[n].all[i] << \" \";\n// cout << endl;\n//}\nint main()\n{\n long n;\n cin >> n;\n if (prim(n))\n {\n cout << \"1\" << endl << n << endl;\n return 0;\n }\n int res = 3;\n int a[3];\n for (int i = n-2; i>1; i--)\n {\n if (prim(n - i) && prim(i))\n {\n cout << \"2\" << endl << i <<\" \"<< n - i << endl;\n return 0;\n }\n bool max, min;\n max = prim(n - i);\n min = prim(i);\n if (!max && min)\n {\n for (int j = n - i - 2; j > 1; j--)\n {\n if (prim(j) && prim(n-i - j))\n {\n a[0] = i;\n a[1] = n - i-j;\n a[2] = j;\n }\n }\n } \n else if (max && !min)\n {\n for (int j = i - 2; j > 1; j--)\n {\n if (prim(j) && prim(i - j))\n {\n a[0] = i-j;\n a[1] = n - i;\n a[2] = j;\n }\n }\n }\n }\n cout <\n#include \n#include \nusing namespace std;\nbool isPrime(int& x)\n{\n if (x == 1 || (x % 2 == 0 && x != 2)) return false;\n if(x % 3 == 0) return false;\n for (int i = 3; i <= sqrt(x); i += 2)\n if (x % i == 0)\n return false;\n return true;\n}\nint main()\n{\n \n int numar,ultim,n,k;\n \n bool gasit = false;\n cin >> numar;\n n=numar;\n ultim = numar;\n// if(numar < 4)\n// return 0;\n if(n==3)\n {\n printf(\"1\\n\");\n printf(\"3\");\n \n }\n else if(n==5)\n {\n printf(\"3\\n\");\n printf(\"2 2 1\");\n }\n else\n {\n n=n-3;\n printf(\"3\\n\");\n printf(\"3 \");\n numar=numar-3;ultim=ultim-3;\n for(int i=0; i<=numar/2; i++)\n {\n if(isPrime(i))\n {\n for(int j = ultim-1; j >= numar/2; j-=2)\n {\n if(isPrime(j) && i+j == numar)\n {\n cout << i <<\" \"<< j ;\n i = numar;\n j = 0;\n }\n else if(i+j < numar)\n {\n ultim = j+1;\n break;\n }\n }\n }\n }\n}\n \n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f0b7a605bcde684156293f9fbf58156d", "src_uid": "f2aaa149ce81bf332d0b5d80b2a13bc3", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n\ntypedef long long ll;\ntypedef map mapsi;\ntypedef map, int> mappiii;\ntypedef map mapii;\ntypedef map mapib;\ntypedef pair pii;\ntypedef pair ppi;\ntypedef unordered_set useti;\ntypedef set seti;\n\n#define int long long\n#define endl \"\\n\"\n#define define_arr(arr,n) int *arr = new int[n];\n#define print1(a) cout << a << endl;\n#define print2(a,b) cout << a << \" \" << b << endl;\n#define uset unordered_set\n#define it iterator\n#define pb push_back\n#define f first\n#define s second\n#define MOD 998244353\n#define MAXN 200005\n\nint factorial[MAXN];\n\nvoid init()\n{\n factorial[0] = 1;\n factorial[1] = 1;\n\n for(int i=2;i> n >> m;\n\n init();\n\n if(n == 2)\n {\n cout << 0 << endl;\n return 0;\n }\n\n int ans = 0;\n int afterMulti = (n-2);\n\n int temp;\n if(n == 3)\n temp = 1;\n else\n temp = modular(2,n-3,MOD); \n\n afterMulti *= temp;\n afterMulti %= MOD;\n\n int ans = ncr(m,n-1);\n ans %= MOD;\n\n ans *= afterMulti;\n print1(ans);\n\n /*for(int k=n-1;k<=m;k++)\n {\n ans += ncr(k-1,n-2);\n ans %= MOD;\n\n // cout << \"Max Ele: \" << k << \"----\" << ncr(k-1,n-2)*afterMulti << endl;\n }\n\n ans *= afterMulti;\n ans %= MOD;\n\n cout << ans << endl;\n*/ \n \n return 0 ;\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a5b2e49fb50f1084825d7c393188abea", "src_uid": "28d6fc8973a3e0076a21c2ea490dfdba", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include\ntypedef long long ll;\nusing namespace std;\n\nll z=998244353;\n\nll f[200001];\n\nlong long binpow(long long a, long long b) {\n if (b == 0)\n return 1;\n \n \n long long res = binpow(a, b / 2);\n \n if (b % 2){\n ll xx=res;\n xx*=res;\n xx%=z;\n xx*=a;\n xx%=z;\n return xx;\n }\n else{\n return (res * res)%z;\n \n }\n}\n\n\n\nint main(){\n f[0]=1;\n for(int i=1;i<2e5;i++){\n f[i]=f[i-1]*i;\n f[i]%=z;\n }\n \nll val=0;\nfor(int i=n-2;i<=m-1;i++){\n ll xx=f[i];\n xx*=binpow(f[n-2],z-2);\n xx%=z;\n xx*=binpow(f[i-n+2],z-2);\n xx%=z;\nval+=xx;\nval%=z;\n}\n ll ans=0;\n \nfor(int i=1;i\n#include\n#include\n#include\nusing namespace std;\n \n#define END '\\n'\n#define int long long\n#define pb push_back\n#define loop(i, n) for (int i = 0; i < n; i++)\n \nconst int mod = 1e9+7;\nconst int inf = 2e18;\n \nstring Z = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\nstring z = \"abcdefghijklmnopqrstuvwxyz\";\n\nint N = 200043;\nint MOD = 998244353;\n\nint add(int x, int y)\n{\n x += y;\n while(x >= MOD) x -= MOD;\n while(x < 0) x += MOD;\n return x;\n}\n\nint mul(int x, int y)\n{\n return (x * y) % MOD;\n}\n\nint binpow(int x, int y)\n{\n int z = 1;\n while(y)\n {\n if(y & 1) z = mul(z, x);\n x = mul(x, x);\n y >>= 1;\n }\n return z;\n}\n\nint inv(int x)\n{\n return binpow(x, MOD - 2);\n}\n\nint divide(int x, int y)\n{\n return mul(x, inv(y));\n}\n\nint fact[N];\n\nvoid precalc()\n{\n fact[0] = 1;\n for(int i = 1; i < N; i++)\n fact[i] = mul(fact[i - 1], i);\n}\n\nint C(int n, int k)\n{\n return divide(fact[n], mul(fact[k], fact[n - k]));\n}\n\n\nsigned main(){\n\tios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n\tint o = 1;\n\tif(o){\n\t\tfreopen(\"fin.txt\", \"r\", stdin);\n\t\tfreopen(\"fout.txt\", \"w\", stdout);\n\t}\n\n precalc();\n int n, m;\n cin >> n >> m;\n int ans = 0;\n if(n > 2)\n ans = mul(C(m, n - 1), mul(n - 2, binpow(2, n - 3)));\n cout << ans << endl;\n\n\treturn 0;\n\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f29bc4419a83f9543e4a081f58fd9695", "src_uid": "28d6fc8973a3e0076a21c2ea490dfdba", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\nconst int N=2e5+7;\nint a[N];\nbool cmp(int x,int y)\n{\n return x>y;\n}\nint main()\n{\n ios::sync_with_stdio(0);\n cin.tie(0);\n int t;cin>>t;\n while(t--)\n {\n int n,m;cin>>n;\n for(int i=1;i<=n;i++)\n cin>>a[i];\n sort(a+1,a+1+n,cmp)\n for(int i=1;i<=n;i++)\n cout<\nusing namespace std;\nint solve() {\n double x,y; cin>>x>>y;\n double A = y*log(x);\n double B = x*log(y);\n \n if(AB)\n cout<<\">\"<\n#include//recursion\nusing namespace std;\n\nint main()\n{\n\tlong int x,y;\n\tcin>>x>>y;\n\n\tif(x<=110&&y<=110)\n\t{\n\t\tif(long long (pow(x/1.0,y))>long long(pow(y/1.0,x)))\n\t\t\tcout<<\">\";\n\t\telse\n\t\t{\n\t\t\tif(long long(pow(x/1.0,y))y) cout << \">\";\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(x\";\n\t\t\telse cout <<\"=\";\t\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2abe543474b65a21fdf19121ae0f9bf6", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint x,y;\nint main()\n{\n\tscanf(\"%d%d\",&x,&y);\n\tif(x==y)printf(\"=\");\n\telse if(x>2&&y>2)\n\t{\n\t\telse if(x>y)printf(\"<\");\n\t\telse if(x\");\n\t}\n\telse if(x==1)\n\t{\n\t\tif(y==1)printf(\"=\");\n\t\telse if(y>x)printf(\"<\");\n\t}\n\telse if(y==1)\n\t{\n\t\tif(x==1)printf(\"=\");\n\t\telse if(x>y)printf(\">\");\n\t}\n\telse if(x==2)\n\t{\n\t\tif(y==3)printf(\"<\");\n\t\telse if(y==4)printf(\"=\");\n\t\telse printf(\">\");\n\t}\n\telse if(y==2)\n\t{\n\t\tif(x==3)printf(\">\");\n\t\telse if(x==4)printf(\"=\");\n\t\telse printf(\"<\");\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f178d90b028926a562c53a939ecce5d4", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define ll long long\nconst double eps = 1e-6;\ndouble x, y;\nint main()\n{\n while(scanf(\"%lf%lf\", &x, &y)!=EOF)\n {\n double X = y*log(x*1.0);\n double Y = x*log(y*1.0);\n //printf(\"%.20lf %.20lf\\n\", X, Y);\n if( abs(X-Y) < eps)\n {\n printf(\"=\\n\");\n }\n else{\n else if(X>Y)\n {\n printf(\">\\n\");\n }\n else if(X\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst int inf=1<<30;\nconst int S=1e5+10;\nint px[S],py[S],par[S];\npair sx[S],sy[S];\nint find(int x){\n\treturn x==par[x]?x:par[x]==find(par[x]);\n}\nint un(int u,int v){\n\tu=find(u);\n\tv=find(v);\n\tif(u==v)return 0;\n\tpar[u]=v;\n\treturn 1;\n}\nint dist(int x,int y){\n\treturn min(abs(px[x]-px[y]),abs(py[x]-py[y]));\n}\nint main(){\n\tint n;\n\tscanf(\"%d\",&n);\n\tfor(int i=0;i > >st;/*\n\tfor(int i=0;i0){\n\t\tlong long cur=*(st.begin());\n\t\tst.erase(cur);\n\t\tint u=cur.second.first,v=cur.second.second;\n\t\tans+=unite(u,v)*dist(u,v);\n\t}\n\tcout<\n#include\nusing namespace std;\n#define ll __int64\nchar aa[20];\nint a[20];\nint vis[20];\nint dp[18][101][(1<<18)+20];\nint zero;\nint jiecheng[18];\nvoid init()\n{\n int sum=1;\n for(int i=1;i<=18;i++)\n {\n sum*=i;\n jiecheng[i]=sum;\n }\n}\nint main()\n{\n int m;\n while(~scanf(\"%s%d\",aa,&m))\n {\n init();\n memset(vis,0,sizeof(vis));\n memset(dp,0,sizeof(dp));\n int n=strlen(aa);\n zero=(1<0)output/=jiecheng[vis[i]];\n }\n printf(\"%d\\n\",output);\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "103fbcc38306c89c90ab9ccda1b04efe", "src_uid": "5eb90c23ffa3794fdddc5670c0373829", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#define int long long\nusing namespace std;\nconst int maxs=(1<<18)+10,maxm=110;\nint w[20],cnt=-1,m,n,f[maxs][maxm];\nbool vis[10];\nint main(){\n\tscanf(\"%d%d\",&n,&m);\n while(n){\n \tcnt++;\n \tw[cnt] = n % 10;\n \tn /= 10;\n\t}\n f[0][0] = 1;\n for(int s = 1;s < 1<\ntypedef long long ll;\nusing namespace std;\nll n,m;\nll a[20];\nll p;\nll dp[18][1 << 18][100];\nll ways(ll ind,ll mask,ll mod)\n{\n if(ind == p)\n {\n if(mask == ((1 << p) - 1) && mod == 0)\n {\n return 1;\n }else\n {\n return 0;\n }\n }\n if(dp[ind][mask][mod] != -1) return dp[ind][mask][mod];\n\n}\nint main()\n{\n cin >> n >> m;\n while(n > 0)\n {\n a[p++] = n%10;\n n = n/10;\n }\n cout << ways(0LL,0LL,0LL) << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "240378af673eff08b48b6c4955356976", "src_uid": "5eb90c23ffa3794fdddc5670c0373829", "difficulty": 2000.0} {"lang": "GNU C++20 (64)", "source_code": "#include \r\nusing namespace std;\r\n#define ll long long\r\nll mod = 1000000007;\r\n\r\nint main{\r\n int t; cin >> t;\r\n while(t--){\r\n ll n, k, ans=1; cin >> n >> k;\r\n while(k--){\r\n ans = (n*ans)%mod;\r\n }\r\n cout << ans << endl;\r\n }\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b726ba512392a067786df8cffb03aa58", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "//#include \"/Users/rahulchauhan/stdc++.h\"\n#include <\"bits/stdc++.h\">\nusing namespace std;\n#define ref(i,n) for(int i=0;i>t;\n\t\twhile(t--){\n\t\t\tlong long n,k,ans=1;\n\t\t\tcin>>n>>k;\n\t\t\tfor(int i=0;i\r\nusing namespace std;\r\n\r\n\r\n#define MOD 1000000007\r\n\r\nint main() {\r\n \r\n int t;\r\n scanf(\"%d\", &t);\r\n \r\n while (t--) {\r\n int n, k;\r\n scanf(\"%d%d\", &n, &k);\r\n \r\n int ans = pow(n, k) % MOD;\r\n \r\n printf(\"%d\\n\", ans);\r\n }\r\n \r\n \r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "abd4ed5a141a2568068c6772e669dd9f", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\n\n\nll qmi(int a, int b, int p)\n{\n ll res = 1 % p;\n while (b)\n {\n if (b & 1) res = res * a % p;\n a = a * (ll)a % p;\n b >>= 1;\n }\n return res;\n}\n\n\nint main()\n{\n int tt;\n scanf(\"%d\", &n);\n while (n -- )\n {\n int a, b, p;\n scanf(\"%d%d%d\", &a, &b, &p);\n printf(\"%lld\\n\", qmi(a, b, 1e9+7));\n }\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b2689414c862ded890b84558e8e3a973", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include\n\n\n\nusing namespace std;\n\nint n;\n\nint main()\n\n{\n\n\tscanf(\"%d\",&n);\n\n\tif(n==1){puts(\"0\");return 0;}\n\n\tif(n%2==0)printf(\"%d\\n\",n/2-1);\n\n\telse printf(\"%d\\n\",n);\n\n\treturn 0;\n\n}#include\n\n\n\nusing namespace std;\n\nint n;\n\nint main()\n\n{\n\n\tscanf(\"%d\",&n);\n\n\tif(n==1){puts(\"0\");return 0;}\n\n\tif(n%2==0)printf(\"%d\\n\",n/2-1);\n\n\telse printf(\"%d\\n\",n/2);\n\n\treturn 0;\n\n}\n ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f47364811fbd20ca853b52679aa94a83", "src_uid": "dfe9446431325c73e88b58ba204d0e47", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint main()\n{\t\n\tint n;\n\twhile(cin>>n){\n\t\tif(n%2)\n\t\t \tans=(n-2)/2;\n\t\telse\n\t\t\tans=(n-1)/2;\n\t\tcout<\nusing namespace std;\n#define ll long long \ntypedef pair pii;\n\nint main(){\n \n ll n;\n cin>>n;\n cout<<<(n-1)/2<\n#define maxs 202020\n#define mme(i,j) memset(i,j,sizeof(i))\nusing namespace std;\n\nint main()\n{\n \n int n;\n while(~scanf(\"%d\"\uff0c&n))\n {\n cout<<(n-2)/2<\nusing namespace std;\n\nint main()\n{\n int n, *dominoes[2], upper = 0, lower = 0, bothEven = 0;\n cin >> n;\n dominoes[0] = new int[n];\n dominoes[1] = new int[n];\n for (int j = 0; j < n; j++)\n {\n cin >> dominoes[0][j] >> dominoes[1][j];\n upper += dominoes[0][j];\n lower += dominoes[1][j];\n bothEven += x % 2 != y % 2;\n }\n\n if (upper % 2 == 0 && lower % 2 == 0)\n {\n cout << \"0\" << endl;\n }\n else if (bothEven %2 == 0 && bothEven > 0)\n {\n cout << \"1\" << endl;\n }\n else cout << \"-1\" << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6ffa98823bac3d7e839b1437f73ddc2f", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include\n#include\nbool check(int n,int x[n],int y[n])\n{\n for(i=0;i\n\nusing namespace std;\n\nint a[150], b[150], x, y, n, suma = 0, sumb = 0;\nint main() {\n freopen (\"input.txt\", \"r\", stdin);\n freopen (\"output.txt\", \"w\", stdout);\n\n\n cin >> n;\n for (int i = 1; i <= n; i ++) {\n cin >> a[i] >> b[i];\n suma += a[i];\n sumb += b[i];\n }\n if (suma % 2 == 0 && sumb % 2 == 0) cout << 0 , exit(0);\n for (int i = 1; i <= n; i ++) {\n if (a[i] % 2 && !(b[i] % 2) || !(a[i] % 2) && b[i] % 2) {\n suma = suma - a[i] + b[i];\n sumb = sumb - b[i] + a[i];\n if (suma % 2 == 0 && sumb % 2 == 0) cout << 1, exit(0);\n }\n }\n cout << -1;\n\n\n\nreturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4a006d73dade615c4b50cad7a7f50bbb", "src_uid": "f9bc04aed2b84c7dd288749ac264bb43", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint main()\n{\n ios_base::with_stdio(false);\n cin.tie(false);\n int n;\n cin>>n;\n int a[n],b[n];\n for(int i=0;i>a[i]>>b[i];\n }\n int ans=0;\n for(int i=0;i\r\n#include \r\n#include \r\n\r\nusing namespace std;\r\n#define mod 998244353\r\n\r\n#define int long long int\r\n\r\nint dp[501][501];\r\nint p[501][501];\r\n\r\nint power(int a, int b)\r\n{\r\n if (b == 0)\r\n {\r\n return 1;\r\n }\r\n int p = power(a, b / 2);\r\n if (b % 2 == 0)\r\n {\r\n return (p * p) % mod;\r\n }\r\n return (a * ((p * p) % mod)) % mod;\r\n}\r\n\r\nint func(int i, int j)\r\n{\r\n if (dp[i][j] != -1)\r\n {\r\n return dp[i][j];\r\n }\r\n if (i == 0 || j == 0)\r\n {\r\n dp[i][j] = 1;\r\n return dp[i][j];\r\n }\r\n else if (i == 1)\r\n {\r\n dp[i][j] = 0;\r\n return dp[i][j];\r\n }\r\n if (j <= (i - 1))\r\n {\r\n dp[i][j] = power(j, i);\r\n return dp[i][j];\r\n }\r\n dp[i][j] = 0;\r\n for (int k = 0; k <= i; k++)\r\n {\r\n int temp = 1;\r\n if (k > 0)\r\n {\r\n temp = power(i - 1, k);\r\n }\r\n // p[i][k] %= mod;\r\n dp[i][j] += (((p[i][k] * temp) % mod) * func(i - k, j - (i - 1))) % mod;\r\n dp[i][j] %= mod;\r\n }\r\n return dp[i][j];\r\n}\r\n\r\nsigned main()\r\n{\r\n ios_base::sync_with_stdio(false);\r\n cin.tie(NULL);\r\n int n, x;\r\n cin >> n >> x;\r\n // int p[n + 1][n + 1];\r\n for (int i = 1; i <= n; i++)\r\n {\r\n for (int j = 0; j <= i; j++)\r\n {\r\n if (j == 0 || j == i)\r\n {\r\n p[i][j] = 1;\r\n }\r\n else if (j <= i - j)\r\n {\r\n p[i][j] = (p[i - 1][j - 1] + p[i - 1][j]) % mod;\r\n }\r\n else\r\n {\r\n p[i][j] = p[i][i - j];\r\n }\r\n }\r\n }\r\n\r\n memset(dp, -1, sizeof(dp));\r\n\r\n // for (int i = 0; i <= n; i++)\r\n // {\r\n // for (int j = 0; j <= x; j++)\r\n // {\r\n\r\n // }\r\n // }\r\n cout << func(n, x) << endl;\r\n\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0490716d1d1501db81ac67a256c4bb0d", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "\u200b\n\u200b\n#include \nusing namespace std;\nconst int MAXN = 510;\nconst int mod = 998244353;\ntypedef long long ll;\nint C[MAXN][MAXN],dp[MAXN][MAXN];\nvoid intc()\n{\n\tfor(int i = 1;i < MAXN; i++){\n\t\tC[i][0] = C[i][i] = 1;\n\t\tfor(int j = 1;j < i; j++){\n\t\t\tC[i][j] = (C[i-1][j] + C[i-1][j-1])%mod;\n\t\t}\n\t}\n}\nll ksm(ll a,ll b) {\n ll res = 1, base = a;\n while(b) {\n\t\tif(b & 1) {\n\t\t res = (res * base) % mod;\n\t\t}\n\t\tbase = (base * base) % mod;\n\t\tb >>= 1;\n }\n return res;\n}\ninline ll sub ( ll a, ll b ) { return ((a - b) % mod + mod) % mod; }\nint main()\n{\n\tint n,x;\n\tcin >> n >> x;\n\tintc();//dp[i][j]\u8868\u793a\u6709i\u4e2a\u82f1\u96c4 \u751f\u547d\u503c\u6700\u5927\u4e3aj\u65f6\u6700\u7ec8\u6709\u82f1\u96c4\u5b58\u6d3b\u7684\u65b9\u6848\u6570\n\tfor(int i = 1;i <= x; i++) dp[1][i] = i;\n\tfor(int i = 2;i <= n; i++){\n\t\tfor(int j = i; j <= x; j++){\n\t\t\tfor(int l = 0;l < i; l++){//\u679a\u4e3e\u4e0b\u4e00\u8f6e\u6b7b\u4ea1\u7684\u82f1\u96c4\u4e2a\u6570 \n\t\t\t\tdp[i][j] = (dp[i][j]+dp[i-l][j-i+1]*ksm(i-1,l)%mod*C[i][l]%mod)%mod;\n\t\t\t}//\u4e0b\u4e00\u8f6e\u7684\u82f1\u96c4\u4e2a\u6570\u4e3ai-l\u4e2a \u6700\u5927\u7684\u751f\u547d\u503c\u4e3aj-i+1 \n\t\t} //\u6b7b\u4ea1\u7684\u82f1\u96c4\u7684\u751f\u547d\u503c\u7684\u53ef\u80fd\u6570\u4e3ai-1 \u7684l\u6b21\u65b9 \u6bcf\u4e2a\u82f1\u96c4\u7684\u751f\u547d\u503c\u7684\u8303\u56f4\u57281\u2014i-1\n\t} //\u4ecei\u4e2a\u82f1\u96c4\u91cc\u6311\u9009l\u4e2a\u6b7b\u4ea1\u7684\u82f1\u96c4 \u65b9\u6848\u6570\u4e3aC[i][j]\n\tcout << sub(ksm(x,n),dp[n][x]);//\u603b\u65b9\u6848\u51cf\u53bb\u6709\u82f1\u96c4\u5b58\u6d3b\u7684\u65b9\u6848\n\treturn 0;\n}\n \n\u200b\n \n\u200b\u200b\n\u200b\n#include \nusing namespace std;\nconst int MAXN = 510;\nconst int mod = 998244353;\ntypedef long long ll;\nint C[MAXN][MAXN],dp[MAXN][MAXN];\nvoid intc()\n{\n\tfor(int i = 1;i < MAXN; i++){\n\t\tC[i][0] = C[i][i] = 1;\n\t\tfor(int j = 1;j < i; j++){\n\t\t\tC[i][j] = (C[i-1][j] + C[i-1][j-1])%mod;\n\t\t}\n\t}\n}\nll ksm(ll a,ll b) {\n ll res = 1, base = a;\n while(b) {\n\t\tif(b & 1) {\n\t\t res = (res * base) % mod;\n\t\t}\n\t\tbase = (base * base) % mod;\n\t\tb >>= 1;\n }\n return res;\n}\ninline ll sub ( ll a, ll b ) { return ((a - b) % mod + mod) % mod; }\nint main()\n{\n\tint n,x;\n\tcin >> n >> x;\n\tintc();//dp[i][j]\u8868\u793a\u6709i\u4e2a\u82f1\u96c4 \u751f\u547d\u503c\u6700\u5927\u4e3aj\u65f6\u6700\u7ec8\u6709\u82f1\u96c4\u5b58\u6d3b\u7684\u65b9\u6848\u6570\n\tfor(int i = 1;i <= x; i++) dp[1][i] = i;\n\tfor(int i = 2;i <= n; i++){\n\t\tfor(int j = i; j <= x; j++){\n\t\t\tfor(int l = 0;l < i; l++){//\u679a\u4e3e\u4e0b\u4e00\u8f6e\u6b7b\u4ea1\u7684\u82f1\u96c4\u4e2a\u6570 \n\t\t\t\tdp[i][j] = (dp[i][j]+dp[i-l][j-i+1]*ksm(i-1,l)%mod*C[i][l]%mod)%mod;\n\t\t\t}//\u4e0b\u4e00\u8f6e\u7684\u82f1\u96c4\u4e2a\u6570\u4e3ai-l\u4e2a \u6700\u5927\u7684\u751f\u547d\u503c\u4e3aj-i+1 \n\t\t} //\u6b7b\u4ea1\u7684\u82f1\u96c4\u7684\u751f\u547d\u503c\u7684\u53ef\u80fd\u6570\u4e3ai-1 \u7684l\u6b21\u65b9 \u6bcf\u4e2a\u82f1\u96c4\u7684\u751f\u547d\u503c\u7684\u8303\u56f4\u57281\u2014i-1\n\t} //\u4ecei\u4e2a\u82f1\u96c4\u91cc\u6311\u9009l\u4e2a\u6b7b\u4ea1\u7684\u82f1\u96c4 \u65b9\u6848\u6570\u4e3aC[i][j]\n\tcout << sub(ksm(x,n),dp[n][x]);//\u603b\u65b9\u6848\u51cf\u53bb\u6709\u82f1\u96c4\u5b58\u6d3b\u7684\u65b9\u6848\n\treturn 0;\n}\n \n\u200b\n \n\u200b\n\t \t\t\t\t\t \t \t \t \t\t \t \t \t\t", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3d062aefd4879536027d0fb8ae458f98", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\ntypedef long long ll;\n\nconst ll MX = 505;\nconst ll MOD = 998244353;\n\n#define FOR(i, a, b) for (ll i = (a); i < (b); i++)\n\nll N, X;\nll dp[MX][MX];\nll fact[MX], ifact[MX], invs[MX], rr[MX][MX];\n\nll add(ll a, ll b) {\n return (((a + b) % MOD) + MOD) % MOD;\n}\n\nll mul(ll a, ll b) {\n\treturn (((a * b) % MOD) + MOD) % MOD;\n}\n\nll binExp(ll a, ll b) {\n\tif (!b) return 1;\n\tll res = binExp(a, b / 2);\n\tif (b & 1) return mul(res * mul(res * a));\n\telse return mul(res * res);\n}\n\nll C(ll a, ll b) {\n\treturn (((fact[a] * ifact[b]) % MOD) * ifact[a - b]) % MOD;\n}\n\nvoid init() {\n\tfact[0] = invs[1] = ifact[0] = 1;\n\tFOR(i, 2, MX) invs[i] = ((MOD - MOD/i*invs[MOD % i] % MOD) + MOD) % MOD;\n\tFOR(i, 1, MX) {\n\t\tfact[i] = (fact[i - 1] * i) % MOD; \n\t\tifact[i] = (ifact[i - 1] * invs[i]) % MOD;\n\t}\n\tFOR(i, 0, MX) {\n\t FOR(j, 0, MX) {\n\t rr[i][j] = binExp(i, j);\n\t }\n\t}\n}\n\n\n\nint main() {\n\tinit(); cin >> N >> X;\n\n\t// dp[i][j] = i players remaining with j damage dealt b4 current round\n\tdp[N][0] = 1;\n\t\n\n\tfor (ll i = N; i > 1; i--) {\n\t\tfor (ll j = 0; j < X; j++) if (dp[i][j]) {\n\t\t\tfor (ll k = i; k >= 0; k--) {\n\t\t\t\tll d = min(X, j + i - 1);\n\t\t\t\tdp[k][d] = add(dp[k][d], mul(dp[i][j], mul(C(i, i - k), rr[d - j][i - k])));\n\t\t\t}\n\t\t}\n\t}\n\n\t// O(N * X * N * log(X))\n\n ll ans = 0;\n\tfor (ll i = 0; i <= X; i++) ans = add(ans, dp[0][i]);\n\tcout << ans << \"\\n\";\n}\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4f37da1352e6ef526f8670bba8624903", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "\u200b\n\u200b\n#include \nusing namespace std;\nconst int MAXN = 510;\nconst int mod = 998244353;\ntypedef long long ll;\nint C[MAXN][MAXN],dp[MAXN][MAXN];\nvoid intc()\n{\n\tfor(int i = 1;i < MAXN; i++){\n\t\tC[i][0] = C[i][i] = 1;\n\t\tfor(int j = 1;j < i; j++){\n\t\t\tC[i][j] = (C[i-1][j] + C[i-1][j-1])%mod;\n\t\t}\n\t}\n}\nll ksm(ll a,ll b) {\n ll res = 1, base = a;\n while(b) {\n\t\tif(b & 1) {\n\t\t res = (res * base) % mod;\n\t\t}\n\t\tbase = (base * base) % mod;\n\t\tb >>= 1;\n }\n return res;\n}\ninline ll sub ( ll a, ll b ) { return ((a - b) % mod + mod) % mod; }\nint main()\n{\n\tint n,x;\n\tcin >> n >> x;\n\tintc();//dp[i][j]\u8868\u793a\u6709i\u4e2a\u82f1\u96c4 \u751f\u547d\u503c\u6700\u5927\u4e3aj\u65f6\u6700\u7ec8\u6709\u82f1\u96c4\u5b58\u6d3b\u7684\u65b9\u6848\u6570\n\tfor(int i = 1;i <= x; i++) dp[1][i] = i;\n\tfor(int i = 2;i <= n; i++){\n\t\tfor(int j = i; j <= x; j++){\n\t\t\tfor(int l = 0;l < i; l++){//\u679a\u4e3e\u4e0b\u4e00\u8f6e\u6b7b\u4ea1\u7684\u82f1\u96c4\u4e2a\u6570 \n\t\t\t\tdp[i][j] = (dp[i][j]+dp[i-l][j-i+1]*ksm(i-1,l)%mod*C[i][l]%mod)%mod;\n\t\t\t}//\u4e0b\u4e00\u8f6e\u7684\u82f1\u96c4\u4e2a\u6570\u4e3ai-l\u4e2a \u6700\u5927\u7684\u751f\u547d\u503c\u4e3aj-i+1 \n\t\t} //\u6b7b\u4ea1\u7684\u82f1\u96c4\u7684\u751f\u547d\u503c\u7684\u53ef\u80fd\u6570\u4e3ai-1 \u7684l\u6b21\u65b9 \u6bcf\u4e2a\u82f1\u96c4\u7684\u751f\u547d\u503c\u7684\u8303\u56f4\u57281\u2014i-1\n\t} //\u4ecei\u4e2a\u82f1\u96c4\u91cc\u6311\u9009l\u4e2a\u6b7b\u4ea1\u7684\u82f1\u96c4 \u65b9\u6848\u6570\u4e3aC[i][j]\n\tcout << sub(ksm(x,n),dp[n][x]);//\u603b\u65b9\u6848\u51cf\u53bb\u6709\u82f1\u96c4\u5b58\u6d3b\u7684\u65b9\u6848\n\treturn 0;\n}\n \n\u200b\n \n\u200b\n\t \t\t\t\t\t\t \t\t \t\t \t \t \t\t \t \t", "lang_cluster": "C++", "compilation_error": true, "code_uid": "39415984efde2295145d26fdbf8de01a", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f", "difficulty": 2100.0} {"lang": "GNU C++0x", "source_code": "\n// Hi this is Pheonix :))\n// Pheonix Template //\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define S(x) scanf(\"%d\",&x);\n#define D(x) scanf(\"%1d\",&x);\n#define SL(x) scanf(\"%lld\",&x);\n#define SD(x,y) scanf(\"%d %d\",&x,&y);\n#define ST(x,y,z) scanf(\"%d %d %d\",&x,&y,&z);\n#define P(x) printf(\"%d\\n\",x);\n#define PL(x) printf(\"%lld\\n\",x);\n#define SH() printf(\"\\n\");\n#define TC() int t; scanf(\"%d\",&t); while(t--)\n#define REP(i,a,n) for(i=a;i<=n;i++)\n#define REPI(i,n,a) for(i=n;i>=a;i--)\n#define String(x) scanf(\"%s\",x);\n#define INC(x) x++;\n#define WL(x,y) while(x==y)\n#define W(x) while(x--)\n#define A(x) abs(x)\n#define ASG(x,y) x=y;\n#define Z(x) x=0; \n#define E else\n#define CE(x,a) if(x==a)\n#define CG(x,a) if(x>a)\n#define CL(x,a) if(x57);a=GC);\n for(;(a>47 && a<58);a=GC)\n x=(x<<1)+(x<<3)+a-48;\n}\ninline void write(ULL x) // Fast Out\n{\n if(x==-1)\n {\n PUTCHAR('-');\n PUTCHAR('1');\n PUTCHAR('\\n');\n }\n else\n {\n ULL i = 10;\n char buf[11];\n buf[10] = '\\n';\n do\n {\n buf[--i] = x % 10 + '0';\n x/= 10;\n }\n while(x);\n do\n {\n PUTCHAR(buf[i]);\n } while (buf[i++] != '\\n');\n }\n}\nL main()\n{\n LL n ; \n cin>>n ;\n LL ans = 0 ;\n if(n<=10 || n>=22) ans = 0 ;\n else if(n==11) ans = 8 ;\n else if(n>11 && n<=19) ans = 4 ;\n else if(n==20) ans = 15 ;\n else if(n==21) ans = 4 ; \n cout<\nusing namespace std ; \nint main (){\n int n ; cin >> n ; int a [ 11 ] ;\n for (int i=2 ; i < 10 ; i ++){ a[i-1]=4 ;}\n a[0]=4 ; a[9]=15 ; a[10]=4;\n if(n>10&&N<22){ cout <\nusing namespace std;\nint n;\nint main(){\n cin >> n;\n n-=10;\n if(n==0) puts(\"0\");;\n else if(n==10){\n puts(\"15\");\n }else{\n puts(\"4\");\n }\n \n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a8c6d6550b7e1a8834d356adb92dbc51", "src_uid": "5802f52caff6015f21b80872274ab16c", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint main{\n unsigned short int x;\n cin>>x;\n if(x<10||x>21)\n cout<<0;\n else if(x==20)cout<<11;\n else if(x<20||x==21)cout<<4;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f3a56a15f9de586f62411332493e590c", "src_uid": "5802f52caff6015f21b80872274ab16c", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \n \nusing namespace std;\n \ntemplate \nvoid unique(vector &u) {\n sort(u.begin(), u.end());\n u.resize(unique(u.begin(), u.end()) - u.begin());\n}\n \ntemplate \nvoid debug_out(T t) {\n cerr << t;\n}\n \ntemplate \nvoid debug_out(pair u) {\n cerr << \"(\" << u.first << \" \" << u.second << \")\";\n}\n \ntemplate \nvoid debug_out(vector t) {\n int sz = t.size();\n for(int i = 0; i < sz; i++) {\n debug_out(t[i]);\n if(i != sz - 1) cerr << \", \";\n }\n}\n \ntemplate \nvoid debug_out(vector> t) {\n int sz = t.size();\n for(int i = 0; i < sz; i++) {\n debug_out(t[i]);\n if(i != sz - 1) cerr << endl;\n }\n}\n#define debug(...) cerr << \"[\" << #__VA_ARGS__ << \"]:\" << endl, debug_out(__VA_ARGS__), cerr << endl;\n \n#define range(i, m, n) for(int i = m; i < n; i++)\n#define husk(i, m, n) for(int i = m; i > n; i--)\n \nclass dsu {\n public:\n vector p;\n int n;\n \n dsu(int _n) : n(_n) {\n p.resize(n);\n iota(p.begin(), p.end(), 0);\n }\n \n inline int get(int x) {\n return (x == p[x] ? x : (p[x] = get(p[x])));\n }\n \n inline bool unite(int x, int y) {\n x = get(x);\n y = get(y);\n if (x != y) {\n p[x] = y;\n return true;\n }\n return false;\n }\n};\n \nstruct point {\n int x, y, id = -1;\n point(){};\n point(int _x, int _y) : x(_x), y(_y) {};\n bool operator < (const point &a) const {\n return make_pair(id, make_pair(x, y)) > make_pair(a.id, make_pair(a.x, a.y));\n }\n bool operator == (const point &a) const {\n return x == a.x && y == a.y;\n }\n};\n \nvoid debug_out(point a) {\n cerr << \"(\" << a.x << \" \" << a.y << \")\";\n}\n \ntemplate\nvoid debug_out(set a) {\n vector _a;\n for(auto i : a) _a.push_back(i);\n debug_out(_a);\n}\n \nclass foo {\n public:;\n long long operator()(const point &a) const {\n return 1LL * a.x * INT_MAX + a.y;\n }\n};\n \nvector dx = {0, 1, 1, 1, 0, -1, -1, -1};\nvector dy = {1, 1, 0, -1, -1, -1, 0, 1};\n \npoint sp(point a, int id) {\n return point(a.x + dx[id], a.y + dy[id]);\n}\n \nint n, t;\n \nint main() {\n scanf(\"%d%d\", &n, &t);\n vector a(n);\n unordered_set cur;\n range(i, 0, n) {\n scanf(\"%d%d\", &a[i].x, &a[i].y);\n a[i].id = i;\n cur.insert(a[i]);\n }\n {\n dsu ss(n);\n for(auto u : a) {\n range(i, 0, 8) {\n point cc = point(u.x + dx[i], u.y + dy[i]);\n if(cur.find(cc) != cur.end()) {\n ss.unite(u.id, cur.find(cc) -> id);\n }\n }\n }\n set mx;\n range(i, 0, n) mx.insert(ss.get(i));\n if((int) mx.size() > 1) {\n printf(\"NO\");\n return 0;\n }\n }\n printf(\"YES\\n\");\n dsu st(4 * n + 1);\n auto it = max_element(a.begin(), a.end(), [&](point a, point b){return a.y < b.y;});\n st.unite(4 * n, 4 * it -> id);\n unordered_map, foo> dog;\n for(auto u : a) {\n for(int i = 0; i < 8; i += 2) {\n if(!cur.count(sp(u, i))) dog[sp(u, i)].push_back(4 * u.id + i / 2);\n }\n }\n for(auto u : a) {\n for(int i = 1; i < 8; i += 2) {\n if(!cur.count(sp(u, i)) && !cur.count(sp(u, i - 1)) && !cur.count(sp(u, (i + 1) % 8))) st.unite(dog[sp(u, i - 1)][0], dog[sp(u, (i + 1) % 8)][0]);\n }\n }\n for(auto u : dog) {\n point cc = u.first;\n vector id = u.second;\n for(auto i : id) st.unite(i, id.front());\n for(int i = 0; i < 8; i += 2) {\n if(dog.count(sp(cc, i))) st.unite(id[0], dog[sp(cc, i)][0]);\n }\n }\n auto valid = [&] (point v) {\n map> cat;\n for(int i = 0; i < 8; i += 2) {\n if(cur.find(sp(v, i)) == cur.end()) cat[st.get(v.id * 4 + i / 2)].push_back(i);\n }\n bool ok = false;\n for(auto i : cat) {\n ok |= i.first == st.get(4 * n);\n }\n if(!ok) return false;\n vector cc;\n range(i, 0, 8) {\n if(cur.find(sp(v, i)) != cur.end()) cc.push_back(i);\n }\n for(auto u : cat) {\n vector bar = u.second;\n int sz = bar.size();\n set p;\n for(auto i : cc) {\n p.insert((lower_bound(bar.begin(), bar.end(), i) - bar.begin()) % sz);\n }\n if(p.size() > 1) return false;\n }\n return true;\n };\n unorderd_set pos;\n range(i, 0, n) if(valid(a[i])) pos.insert(a[i]);\n vector> in(4 * n + 1);\n range(i, 0, 4 * n + 1) in[st.get(i)].push_back(i);\n vector res;\n while(pos.size()) {\n res.push_back(pos.begin() -> id);\n point cc = *pos.begin();\n pos.erase(cc);\n cur.erase(cc);\n vector id, _id;\n range(i, 0, 8) {\n if(cur.count(sp(cc, i))) id.push_back(cur.find(sp(cc, i)) -> id);\n }\n for(int i = 0; i < 8; i += 2) {\n if(!cur.count(sp(cc, i))) {\n if(st.get(4 * n) != st.get(4 * cc.id + i / 2)) _id.push_back(st.get(4 * cc.id + i / 2));\n }\n }\n unique(_id);\n for(auto i : _id) {\n for(auto j : in[i]) id.push_back(j / 4);\n }\n unique(id);\n for(int i = 0; i < 8; i += 2) {\n if(!cur.count(sp(cc, i))) {\n st.unite(4 * cc.id + i / 2, 4 * n);\n }\n }\n for(int i = 0; i < 8; i += 2) {\n if(cur.count(sp(cc, i))) {\n point ss = *cur.find(sp(cc, i));\n st.unite(4 * n, 4 * ss.id + ((i + 4) % 8) / 2);\n }\n }\n for(auto i : id) {\n if(cur.count(a[i]) && valid(a[i])) pos.insert(a[i]);\n else pos.erase(a[i]);\n }\n }\n reverse(res.begin(), res.end());\n for(auto i : res) printf(\"%d\\n\", i + 1);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6a7870f42b9ca7bfa108470f533938ef", "src_uid": "873aca0e5ff5dccf8af62f7b244fef6b", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include \n#define sz(v) ((int)(v).size())\nusing namespace std;\nconst int MAXN = 150005;\nusing lint = long long;\nusing pi = pair;\nconst int dx[8] = {1, 0, -1, 0, -1, -1, 1, 1};\nconst int dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};\n \nstruct AGISEOKHWAN{\n\tint pa[MAXN];\n\tvoid init(int n){\n\t\tiota(pa, pa + n + 1, 0);\n\t}\n\tint find(int x){\n\t\treturn pa[x] = (pa[x] == x ? x : find(pa[x]));\n\t}\n\tbool uni(int p, int q){\n\t\tp = find(p); q = find(q);\n\t\tif(p == q) return 0;\n\t\tpa[q] = p; return 1;\n\t}\n}AGISEOKHWAN;\n\nstruct point{\n\tint x, y, idx;\n\tbool operator<(const point &p)const{\n\t\treturn pi(x, y) < pi(p.x, p.y);\n\t}\n}a[MAXN];\n\nstruct node{\n\tint x, y, fs;\n};\n\nvector disj[MAXN * 4];\n\nint n;\nbool vis[MAXN];\n\npi dual_edge[MAXN][4];\nint prec[MAXN][8];\nint faces;\nint outer_area;\nint V[MAXN], E[MAXN], F[MAXN], SC[MAXN];\n\nvoid uni(int x, int y){\n\tif(x == y) return;\n\tif(disj[x].size() < disj[y].size()) swap(x, y);\n\tfor(auto &i : disj[y]){\n\t\tdisj[x].push_back(i);\n\t\tif(i.fs == -1){\n\t\t\touter_area = x;\n\t\t}\n\t\telse if(i.fs == 0){\n\t\t\tdual_edge[i.x][i.y].first = x;\n\t\t}\n\t\telse{\n\t\t\tdual_edge[i.x][i.y].second = x;\n\t\t}\n\t}\n\tdisj[y].clear();\n}\n\nint getV(int x){\n\tint msk = 0;\n\tfor(int j=0; j<8; j++){\n\t\tint pos = prec[x][j];\n\t\tif(!vis[pos]){\n\t\t\tif(dx[j] <= 0 && dy[j] <= 0) msk |= 1;\n\t\t\tif(dx[j] <= 0 && dy[j] >= 0) msk |= 2;\n\t\t\tif(dx[j] >= 0 && dy[j] >= 0) msk |= 4;\n\t\t\tif(dx[j] >= 0 && dy[j] <= 0) msk |= 8;\n\t\t}\n\t}\n\tmsk ^= 15;\n\tint remVtx = 0;\n\tfor(int i=0; i<4; i++){\n\t\tif((msk >> i) & 1) remVtx++;\n\t}\n\treturn remVtx;\n}\n\nvoid relaxV(int x){\n\tfor(int j=0; j<8; j++){\n\t\tint pos = prec[x][j];\n\t\tif(pos != -1 && !vis[pos]){\n\t\t\tV[pos] = getV(pos);\n\t\t}\n\t}\n}\n\nint getE(int x){\n\tint remEdg = 4;\n\tfor(int i=0; i<4; i++){\n\t\tint pos = prec[x][i];\n\t\tif(pos != -1 && !vis[pos]){\n\t\t\tremEdg--;\n\t\t}\n\t}\n\treturn remEdg;\n}\n\nvoid relaxE(int x){\n\tfor(int i=0; i<4; i++){\n\t\tint pos = prec[x][i];\n\t\tif(pos != -1 && !vis[pos]){\n\t\t\tE[pos] = getE(pos);\n\t\t}\n\t}\n}\n\nvoid Union(int x){\n\tfor(int i=0; i<4; i++){\n\t\tint pos = prec[x][i];\n\t\tif(pos != -1 && !vis[pos]){\n\t\t\tcontinue;\n\t\t}\n\t\telse{\n\t\t\tuni(dual_edge[x][i].first, dual_edge[x][i].second);\n\t\t}\n\t}\n}\n\nint getF(int x){\n\tset s;\n\tfor(int i=0; i<4; i++){\n\t\tint pos = prec[x][i];\n\t\tif(pos != -1 && !vis[pos]){\n\t\t\tcontinue;\n\t\t}\n\t\telse{\n\t\t\ts.insert(dual_edge[x][i].first);\n\t\t\ts.insert(dual_edge[x][i].second);\n\t\t}\n\t}\n\tif(s.size() <= 1) return 0;\n\treturn sz(s) - 1;\n}\n\nbool sideConn(int x){\n\tfor(int i=0; i<4; i++){\n\t\tint pos = prec[x][i];\n\t\tif(pos != -1 && !vis[pos]){\n\t\t\tcontinue;\n\t\t}\n\t\telse{\n\t\t\tif(dual_edge[x][i].first == outer_area || dual_edge[x][i].second == outer_area){\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}\n\nvoid solve(){\n\tvector seq;\n\tfor(int i=0; i 0);\n\t\tvis[ret.second] = 1;\n\t\tseq.push_back(ret.first);\n\t\tUnion(ret.second);\n\t\trelaxV(ret.second);\n\t\trelaxE(ret.second);\n\t}\n\tfor(int i=0; i dual_vtx;\nint gph[MAXN * 4][4];\nint fce[MAXN * 4][4];\n\nint main(){\n\tscanf(\"%d %*d\",&n);\n\tfor(int i=0; i\nusing namespace std;\n \nconst int mxN=1.5e5, mxM=2*mxN+2, INF=2e9, dx[8]={0, 1, 0, -1, 1, 1, -1, -1}, dy[8]={1, 0, -1, 0, 1, -1, -1, 1};\nint n, t, m, x[mxM], yl[mxM], yr[mxM], ans[mxN], p[mxN+mxM], dt, tin[mxN], low[mxN];\narray a[mxN];\narray b[mxN];\nmap>> mp;\nvector adj[mxN], adj2[mxN];\nbool vis[mxM], ia[mxN], ap[mxN];\n \nvector ae(int x, int y) {\n\tvector r;\n\tfor(int k=0; k<4; ++k) {\n\t\tint nx=x+dx[k], ny=y+dy[k];\n\t\tauto it=lower_bound(mp[nx].begin(), mp[nx].end(), array{ny+1, 0});\n\t\tif(it!=mp[nx].begin()&&yr[(*--it)[1]]>=ny)\n\t\t\tr.push_back((*it)[1]);\n\t}\n\treturn r;\n}\n \nint find(int x) {\n\treturn x^p[x]?p[x]=find(p[x]):x;\n}\n \nvoid join(int x, int y) {\n\tint rx=find(x), ry=find(y);\n\tif(rx==ry)\n\t\treturn;\n\tp[ry]=rx;\n}\n \nint dfs1(int u=0) {\n\tint s=1;\n\tvis[u]=1;\n\tfor(int v : adj[u])\n\t\tif(!vis[v]&&!ia[v])\n\t\t\ts+=dfs1(v);\n\treturn s;\n}\n \nvoid dfs2(int u, int p=-1) {\n\t//cout << \"d2 \" << u << endl;\n\ttin[u]=low[u]=dt++;\n\tint d=0;\n\tfor(int v : adj[u]) {\n\t\tif(ia[v])\n\t\t\tcontinue;\n\t\tif(!tin[v]) {\n\t\t\tdfs2(v, u);\n\t\t\tlow[u]=min(low[u], low[v]);\n\t\t\tif(low[v]>=tin[u]) {\n\t\t\t\tap[u]=1;\n\t\t\t\t++d;\n\t\t\t}\n\t\t\t//if(!u)\n\t\t\t\t//cout << v << \" \" << low[v] << endl;\n\t\t} else if(v^p)\n\t\t\tlow[u]=min(low[u], tin[v]);\n\t}\n\tap[u]&=(p>=0)+d>1;\n}\n \nint main() {\n\tios::sync_with_stdio(0);\n\tcin.tie(0);\n \n\tcin >> n >> t;\n\tfor(int i=0; i> a[i][0] >> a[i][1];\n\t\tb[i]={a[i][0], a[i][1], i};\n\t}\n\tsort(b, b+n);\n\tauto ns=[](int xi, int yli, int yri) {\n\t\tx[m]=xi;\n\t\tyl[m]=yli;\n\t\tyr[m]=yri;\n\t\tmp[xi].push_back({yli, m});\n\t\t++m;\n\t};\n\tns(b[0][0]-1, -INF, INF);\n\tns(b[n-1][0]+1, -INF, INF);\n\tfor(int i=0, j=0; i r=ae(x[i], yl[i]);\n\t\tfor(int j : r)\n\t\t\tjoin(i, j);\n\t}\n\t/*\n\tfor(int i=0; i r=ae(a[i][0], a[i][1]);\n\t\tfor(int j : r)\n\t\t\tjoin(i+m, j);\n\t}\n\t*/\n\tfor(int i=0; i{nx, ny})-b;\n\t\t\tif(p, vector>, greater>> pq;\n\t\tint qh=0;\n\t\tpq.push({0, 0, 0});\n\t\tia[0]=1;\n\t\twhile(qh u=pq.top();\n\t\t\tpq.pop();\n\t\t\tans[qh++]=u[1];\n\t\t\tfor(int v : adj[u[1]]) {\n\t\t\t\tif(!ia[v]) {\n\t\t\t\t\tpq.push({a[v][0], a[v][1], v});\n\t\t\t\t\tia[v]=1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t//*/\n\tcout << \"YES\\n\";\n\tfor(int i=0; i\nusing namespace std;\n\n#define f first\n#define s second\n\nusing pi = pair;\n\nconst int dr[] = {0, -1, -1, -1, 0, 1, 1, 1, 0};\nconst int dc[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};\n\nstruct info {\n int par, size;\n bool outer;\n vector mem;\n};\n\nint n, m, t;\nvector grid;\nunordered_map id;\n\nvector inq, gone;\nvector check, ans;\n\nvector dsu;\n\nset candidates;\n\nint lookup(int who, int dir) {\n pi cell(grid[who].f + dr[dir], grid[who].s + dc[dir]);\n return id.count(cell) ? id[cell] : -1;\n}\n\nbool connected() {\n vector vis(n);\n queue q;\n\n vis[0] = true;\n q.push(0);\n int cnt = 1;\n\n while (!q.empty()) {\n int u = q.front(); q.pop();\n for (int j = 0; j < 8; j++) {\n int v = lookup(u, j);\n if (v != -1 && !vis[v]) {\n vis[v] = true;\n q.push(v);\n cnt++;\n }\n }\n }\n\n return cnt == n;\n}\n\nint find(int i) {\n return dsu[i].par == i ? i : dsu[i].par = find(dsu[i].par);\n}\n\nvoid unite(int u, int v) {\n int a = find(u), b = find(v);\n if (a == b) return;\n if (dsu[a].size > dsu[b].size) {\n swap(u, v);\n swap(a, b);\n }\n\n dsu[a].par = b;\n dsu[b].size += dsu[a].size;\n dsu[b].outer |= dsu[a].outer;\n\n for (int i : dsu[a].mem) {\n for (int j = 0; j < 8; j++) {\n int k = lookup(i, j);\n if (k != -1 && k < n && !gone[k] && !inq[k]) {\n check.push_back(k);\n inq[k] = true;\n }\n }\n dsu[b].mem.push_back(i);\n }\n dsu[a].mem.clear();\n}\n\nbool is_candidate(int i) {\n bool edge = false;\n\n vector comp(8);\n set regions;\n\n for (int j = 0; j < 8; j++) {\n int k = lookup(i, j);\n comp[j] = find(k);\n }\n\n for (int j = 0; j < 8; j += 2) {\n edge |= dsu[comp[j]].outer;\n }\n\n if (!edge) {\n return false;\n }\n\n for (int j = 0; j < 8; j++) {\n int a = comp[(j + 7) % 8], b = comp[j], c = comp[(j + 1) % 8];\n if (a != b && (j % 2 == 0 || b == c)) {\n if (regions.count(comp[j])) {\n return false;\n }\n regions.insert(comp[j]);\n }\n }\n\n return true;\n}\n\nint main() {\n ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n\n cin >> n >> t;\n\n grid.resize(n);\n inq.resize(n);\n gone.resize(n);\n ans.resize(n);\n\n for (int i = 0; i < n; i++) {\n cin >> grid[i].f >> grid[i].s;\n id[grid[i]] = i;\n }\n\n if (!connected()) {\n cout << \"NO\" << endl;\n return 0;\n }\n\n cout << \"YES\" << endl;\n\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < 8; j++) {\n pi cell(grid[i].f + dr[j], grid[i].s + dc[j]);\n if (!id.count(cell)) {\n grid.push_back(cell);\n id[cell] = n + m++;\n }\n }\n }\n\n dsu.resize(n + m);\n\n for (int i = 0; i < n + m; i++) {\n dsu[i] = {i, 1, false, {i}};\n }\n\n for (int i = n; i < n + m; i++) {\n for (int j = 0; j < 8; j += 2) {\n pi cell(grid[i].f + dr[j], grid[i].s + dc[j]);\n if (id.count(cell)) {\n int k = id[cell];\n if (k >= n) {\n unite(i, k);\n }\n }\n }\n }\n\n dsu[find(min_element(grid.begin(), grid.end()) - grid.begin())].outer = true;\n\n\n for (int i = n - 1; i >= 0; i--) {\n for (int x : check) {\n candidates.erase(x);\n if (is_candidate(x)) {\n candidates.insert(x);\n }\n inq[x] = false;\n }\n check.clear();\n ans[i] = *candidates.rbegin();\n candidates.erase(ans[i]);\n gone[ans[i]] = true;\n for (int j = 0; j < 8; j += 2) {\n int k = lookup(ans[i], j);\n if (k >= n || gone[k]) {\n unite(ans[i], k);\n }\n }\n }\n\n for (int x : ans) {\n cout << x + 1 << '\\n';\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cb59f1f0f84066db6bc08c5501dc82af", "src_uid": "873aca0e5ff5dccf8af62f7b244fef6b", "difficulty": null} {"lang": "GNU C++11", "source_code": "#include \n\n#define MAXN (110)\n\nint n, w;\nstd::pair a[MAXN];\nint ans[MAXN];\n\nint main(){\n\tscanf(\"%d%d\", &n, &w);\n\tfor(int i = 1; i <= n; ++ i){\n\t\tscanf(\"%d\", &a[i].first);\n\t\ta[i].second = i;\n\t}\n\tstd::sort(a + 1, n + a + 1);\n\tfor(int i = 1; i <= n; ++ i){\n\t\tans[a[i].second] = (a[i].first + 1) / 2;\n\t\tw -= ans[a[i].second];\n\t}\n\tif(w < 0) return printf(\"-1\\n\"), 0;\n\tfor(int i = n; i >= 1 && w; -- i){\n\t\tint tmp = std::min(a[i].first - ans[a[i].second], w)\n\t\tans[a[i].second] += tmp;\n\t\tw -= tmp;\n\t}\n\tif(w) return printf(\"-1\\n\"), 0;\n\tfor(int i = 1; i <= n; ++ i){\n\t\tprintf(\"%d%c\", ans[i], \" \\n\"[i == n]);\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "07c64cfcfc4f2a01ba7020d876a86180", "src_uid": "5d3bb9e03f4c5c8ecb6233bd5f90f3a3", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nint main()\n{\n int n,v;\n cin>>n>>v;\n int a[n+3];\n for(int i=1;i<=n;i++)\n cin>>a[i];\n int tot=0;\n for(int i=1;i<=n;i++)\n {\n if(a[i]%2==0)\n a[i]/=2;\n else\n a[i]=a[i]/2+1;\n tot+=a[i];\n }\n if(tot>v)\n {\n cout<<-1;\n return 0;\n }\n tot=v-tot;\n int t;\n int t;//\u4f4d\u7f6e \n int max=-1;\n for(int i=1;i<=n;i++)\n {\n if(a[i]>max)\n {\n max=a[i];\n t=i;\n }\n }\n a[t]+=tot;\n for(int i=1;i<=n;i++)\n cout<\n#include \nusing namespace std;\nint main()\n{\n\tvector> v;\n\tlong long n, m, i, aa, s = 0, w, j, a[100005];\n\tcin >> n >> w;\n\tfor (i = 0; i < n; i++)\n\t{\n\t\tcin >> aa;\n\t\ts += (aa + 1) / 2;\n\t\tv.push_back(make_pair(aa, i));\n\t}\n\tif (s > w)\n\t\tcout << \"-1\";\n\telse\n\t{\n\t\tsort(v.begin(), v.end());\n\t\tfor (i = 0; i < n; i++)\n\t\t{\n\t\t\ta[v[i].second] = (v[i].first + 1) / 2;\n\t\t\tw -= (v[i].first + 1) / 2;\n\t\t}\n\t\tfor (i = n - 1; i >= 0 && w != 0; i--)\n\t\t{\n\t\t\tif ((v[i].first - a[v[i].second]) <= w)\n\t\t\t{\n\t\t\t\tw += a[v[i].second];\n\t\t\t\ta[v[i].second] = (v[i].first;);\n\t\t\t\tw -= a[v[i].second];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ta[v[i].second] += w;\n\t\t\t\tw = 0;\n\t\t\t}\n\t\t}\n\n\t\tfor (i = 0; i < n; i++)\n\t\t\tcout << a[i] << \" \";\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a4c4930db126329c23c96d4e83d2542c", "src_uid": "5d3bb9e03f4c5c8ecb6233bd5f90f3a3", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint Tea_cap[110];\nint Tea[110]={0};\nbool cmp (int x,int y)\n{\n\treturn x > y;\n}\nint main()\n{\n\tint n,m,sum_half = 0;\n\tcin >> n >> m;\n\tfor (int i = 1;i <= n;++i) cin >> Tea_cap[i] , sum_half += Tea_cap[i]/2;\n\tm-=sum_half;\n\tif (m<0) { cout << -1; return 0; }\n\tsort (Tea_cap + 1,Tea_cap + n + 1,cmp);\n\tfor(int i = 1;i <= n;++i)\n\t Tea[i] = Tea_cap / 2;\n\t\n\treturn 0;\n }", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e67c879b7ca07442a5bd8e3566f774fc", "src_uid": "5d3bb9e03f4c5c8ecb6233bd5f90f3a3", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nconst long long mod=1000000007;\nlong long Pow( long long power)\n{\n\tif(power==0)\n\t\treturn 1;\n\tif(power==1)\n\t\treturn 2;\n\n\tif(power%2==0)\n\t\treturn (Pow(power/2)%mod*Pow(power/2)%mod)%mod;\n\telse\n\t\treturn 2*Pow(power-1)%mod;\n}\nint main()\n{\n\tlong long x,k;\n\tcin>>x>>k;\n\tif(x==0)\n\t{\n\t\tcout<<0;\n\t\treturn 0;\n\t}\n\tlong long ans=2*x-1;\n\tans%=mod;\n\tcout<<((Pow(k)*ans)%mod+1)%mod;\n\tcout<\nusing namespace std;\n#define ll long long\n#define pb push_back\n#define mp make_pair\n\nll MOD = 1e9+7;\n\nll fastexp(ll a, ll b)\n{\n\tll ans = 1;\n\twhile (b)\n\t{\n\t\tif (b & 1)\t{ans *= a;\tans %= MOD;}\n\t\ta *= a;\n\t\ta %= MOD;\n\t\tb /= 2;\n\t}\n\treturn ans;\n}\n\nint main()\n{\n\tios_base::sync_with_stdio(false); \n\tcin.tie(0);\tcout.tie(0);\n\tll x, k;\tcin >> x >> k;\n\tif (x == 0)\t{cout << 0 << endl;\treturn 0;}\n\tx = ((pow(2, k+1) % MOD) * x) % MOD;\n\tll sub = (pow(2, k) - 1 + MOD) % MOD ;\n\tx -= sub;\tx = x + MOD;\tx %= MOD;\n\tcout << x << endl; \n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "31f09c64f06818e812a8482a3aac074c", "src_uid": "e0e017e8c8872fc1957242ace739464d", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "\n #include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n\n\nint main()\n{\n int x, k;\n cin >> x >> k;\n if (x == 0) {\n cout << \"0\";\n } else {\n cout << (pow(2, k + 1) *(x - 0.5) + 1) % 1000000007;\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0730db9733e9bafe353e26db4b0f3c7e", "src_uid": "e0e017e8c8872fc1957242ace739464d", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "=\n#include\n#define ll long long int\n#define mod 1000000007\nll pow(ll x, ll y)\n{\n\tif (y == (ll)0) return (ll)1;\n\tll temp = pow(x, y / (ll)2);\n\ttemp = (temp*temp) % mod;\n\tif (y % (ll)2 == (ll)1)\n\t{\n\t\ttemp = (temp*x) % mod;\n\t}\n\treturn temp;\n}\nint main()\n{\n\tll n, k;\n\tll temp;\n\tscanf(\"%lld%lld\",&n,&k);\n\tif (n == (ll)0)\n\t{\n\t\ttemp = pow((ll)2,k);\n\t\ttemp = ((ll)1 - temp+mod)%mod;\n\t\tprintf(\"%lld\\n\", temp);\n\t\treturn 0;\n\t}\n\ttemp = pow((ll)2, k);\n\tll temp1 = (((ll)2 * n)%mod - (ll)1 + mod) % mod;\n\ttemp = (temp*temp1) % mod;\n\tprintf(\"%lld\\n\",(temp+(ll)1)%mod);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2406a1ac44ba04314353e8d2a36dc03d", "src_uid": "e0e017e8c8872fc1957242ace739464d", "difficulty": 1600.0} {"lang": "MS C++", "source_code": "#include \nusing namespace std;\n\nint phi(int x)\n {\n int ret = 1, i, pow;\n\n for (i = 2; x != 1; i++) \n {\n pow = 1;\n\n if(i > sqrt(x))\n\t\t break;\n\n while (!(x % i)) \n {\n x /= i;\n pow *= i;\n }\n\n ret *= pow - (pow / i);\n }\n\n if(x != 1)\n\t\tret *= x - 1;\n\n return ret;\n}\n\nvoid main ()\n{\n\tint p;\n\tcin >> p;\n\n\tcout << phi(p - 1);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a626182ecfe41cde85feb8b70de00002", "src_uid": "3bed682b6813f1ddb54410218c233cff", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\nusing namespace std;\nint hash[10001],p[10001];\n#define maxx 10001\nint pirm()\n{\n int i,j;\n int k=0;\n for(i=2;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n\nconst int INF=~0U>>2;\ntypedef vector VI;\ntypedef vector VS;\ntypedef vector VD;\ntypedef long long LL;\ntypedef pair PII;\ntypedef long long BIGNUM;\nBIGNUM product_mod(BIGNUM a, BIGNUM b, BIGNUM c) { //(a*b)%c\nBIGNUM r = 0, d = a;\nwhile (b > 0) {\nif (b & 1) r = (r + d) % c;\nd = (d + d) % c;\nb >>= 1;\n}\nreturn r%c;\n}\nBIGNUM PowerMod(BIGNUM a, BIGNUM b, BIGNUM c) { //(a\u02c6b)%c\nBIGNUM r = 1, d = a;\nwhile (b > 0) {\nif (b & 1) r = product_mod(r, d, c);\nd = product_mod(d, d, c);\nb >>= 1;\n}\nreturn r%c;\n}\n\nint main()\n{\n//\tfreopen(\"in.txt\",\"r\",stdin);\n\tint p;\n\twhile(~scanf(\"%d\",&p))\n\t//for(p=2;p<=20;++p)\n\t{\n\t\tint ans=0;\n\t\tfor(int x=2;x\nusing namespace std;\n#define ll long long\n#define endl \"\\n\"\nint check(ll p, ll i)\n{\n ll j,cnt,x;\n \n x = i;\n cnt=0;\n while(cnt < p-2)\n {\n if((x-1 == 0)\n {\n return 0;\n }\n cnt++;\n x = (x*i)%p;\n }\n \n return 1;\n}\nint main()\n{\n ll p,i;\n cin >> p;\n\n ll ans=0;\n for(i=2;i\nusing namespace std;\n//#define int long long\n\n#define uint unsigned int\n#define ll long long\n#define ull unsigned long long\n#define pii pair \n#define pll pair \n#define pdd pair \n#define fi first\n#define se second\n#define pb emplace_back\n#define all(x) x.begin(),x.end()\n#define sor(x) sort(all(x))\n#define rev(x) reverse(all(x))\n#define mem(x,v) memset(x,v,sizeof(x))\n\n// Templates start.\n\nnamespace IO{\n\tchar buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;\n\t#ifdef __WIN32\n\t\t#define gc getchar()\n\t#else\n\t\t#define gc (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<22,stdin),p1==p2)?EOF:*p1++)\n\t#endif\n\t#define pc(x) (*O++=x)\n\t#define flush() fwrite(obuf,O-obuf,1,stdout)\n\n\tinline int read(){\n\t\tint x=0,sign=0; char s=gc;\n\t\twhile(!isdigit(s))sign|=s=='-',s=gc;\n\t\twhile(isdigit(s))x=(x<<1)+(x<<3)+(s-'0'),s=gc;\n\t\treturn sign?-x:x;\n\t}\n\tinline void print(int x){if(x>9)print(x/10); pc(x%10+'0');}\n}\n\nnamespace math{\n\tconst int mod=1e9+7;\n\tconst int maxn=1e6+5;\n\n\tll ksm(ll a,ll b){ll s=1,m=a; while(b){if(b&1)s=s*m%mod; m=m*m%mod,b>>=1;} return s;}\n\tll inv(ll x){return ksm(x,mod-2);}\n\n\tll fc[maxn],ifc[maxn];\n\tvoid init_m(int n){\n\t\tfc[0]=1;\n\t\tfor(int i=1;i<=n;i++)fc[i]=fc[i-1]*i%mod;\n\t\tifc[n]=inv(fc[n]);\n\t\tfor(int i=n-1;i>=0;i--)ifc[i]=ifc[i+1]*(i+1)%mod;\n\t}\n\tll C(ll n,ll m){return fc[n]*ifc[m]%mod*ifc[n-m]%mod;}\n}\n\n// Templates end. Please give me more points.\n\nusing namespace IO;\n//using namespace math;\n\nconst int N=5e5+5;\nconst int M=2e5+5;\n\nint n,m,q,p[M],del[M];\nint op[N],v[N],qu[N];\nint x[N],y[N],vis[N];\n\nint f[M],to[N];\nint find(int x){return f[x]==x?x:f[x]=find(f[x]);}\nset s[M];\nvector ins[N];\n\nint main(){\n\tcin>>n>>m>>q;\n\tfor(int i=1;i<=n;i++)p[i]=read(),f[i]=i;\n\tfor(int i=1;i<=m;i++)x[i]=read(),y[i]=read();\n\tfor(int i=1;i<=q;i++){\n\t\top[i]=read(),v[i]=read();\n\t\tif(op[i]==2)vis[v[i]]=1;\n\t}\n\tfor(int i=1;i<=m;i++)\n\t\tif(!vis[i]){\n\t\t\tint xx=x[i],yy=y[i],fx=find(xx),fy=find(yy);\n\t\t\tif(fx!=fy)f[fx]=fy;\n\t\t} int cnt=n;\n\t\n\tfor(int i=1;i<=n;i++){\n\t\tf[i]=find(f[i]);\n\t\ts[f[i]].insert(p[i]);\n\t}\n\tfor(int i=q;i;i--){\n\t\tif(op[i]==2){\n\t\t\tint xx=x[v[i]],yy=y[v[i]];\n\t\t\tint fx=find(xx),fy=find(yy);\n\t\t\tif(fx!=fy){\n\t\t\t\tif(s[fx].size()\n#define lc (id<<1)\n#define rc (id<<1|1)\nusing namespace std;\ntypedef long long ll;\nconst int maxn = 6e5+10;\nint p[maxn],a[maxn],b[maxn],flag[maxn];\nint qur[maxn],id[maxn],f[maxn],tot;\nint head[maxn],to[maxn<<1],nxt[maxn<<1],cnt,now;\nvoid add(int u,int v){\n ++cnt,to[cnt] = v,nxt[cnt] = head[u],head[u] = cnt;\n ++cnt,to[cnt] = u,nxt[cnt] = head[v],head[v] = cnt;\n}\nint find(int x){\n return f[x]==x?x:f[x]=find(f[x]);\n}\nvoid unite(int x,int y){\n x = find(x),y = find(y);\n if(x==y) return ;\n ++tot,add(x,tot),add(y,tot);\n f[tot] = f[x] = f[y] = tot;\n}\nbool same(int x,int y){\n return find(x)==find(y);\n}\nint el[maxn],er[maxn],rk[maxn];\nvoid dfs(int u,int pre){\n el[u] = ++now,rk[now] = u;\n for(int i=head[u];i;i=nxt[i]){\n int v = to[i];\n if(v == pre) continue;\n dfs(v,u);\n }\n er[u] = now;\n}\nint maxs[maxn<<2];\nint Max(int i,int j){\n return p[rk[i]]>p[rk[j]]?i:j;\n}\nvoid push_up(int id){\n maxs[id] = Max(maxs[lc],maxs[rc]);\n}\nvoid build(int id,int l,int r){\n if(l==r){\n maxs[id] = l;\n return ;\n }\n int mid = (l+r)>>1;\n build(lc,l,mid);\n build(rc,mid+1,r);\n push_up(id);\n}\n\nint query(int id,int l,int r,int x,int y){\n if(x<=l&&y>=r) return maxs[id];\n int mid = (l+r)>>1,ans = 0;\n if(x<=mid) ans = Max(ans,query(lc,l,mid,x,y));\n if(y>mid) ans = Max(ans,query(rc,mid+1,r,x,y));\n return ans;\n}\nvoid update(int id,int l,int r,int pos,int val){\n if(l==r){\n maxs[id] = val;\n return ;\n }\n int mid = (l+r)>>1;\n if(pos<=mid) update(lc,l,mid,pos,val);\n if(pos>mid) update(rc,mid+1,r,pos,val);\n push_up(id);\n}\nint tree[maxn];\nint main(){\n int n,m,q;\n scanf(\"%d%d%d\",&n,&m,&q);\n tot = n,cnt = 0,now = 0;\n p[0] = -inf;\n for(int i=1;i<=n;i++) scanf(\"%d\",&p[i]),f[i] = i;\n for(int i=1;i<=m;i++) scanf(\"%d%d\",&a[i],&b[i]),flag[i] = false;\n for(int i=1;i<=q;i++){\n scanf(\"%d%d\",&qur[i],&id[i]);\n if(qur[i]==2) flag[id[i]] = true;\n }\n for(int i=1;i<=m;i++){\n if(!flag[i]) unite(a[i],b[i]);\n }\n for(int i=q;i>=1;i--){\n int x = id[i];\n if(qur[i]==2){\n if(same(a[x],b[x])) continue;\n unite(a[x],b[x]);\n }\n else tree[i] = find(x);\n }\n for(int i=1;i<=tot;i++){\n if(f[i]==i) dfs(i,0);\n }\n build(1,1,now);\n for(int i=1;i<=q;i++){\n if(qur[i]==1){\n int rt = tree[i];\n int ans = query(1,1,now,el[rt],er[rt]);\n printf(\"%d\\n\", p[rk[ans]]);\n update(1,1,now,ans,0);\n }\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "96af6b1e12bdfa8be7a96bcb9ef9b3c6", "src_uid": "ad014bde729222db14f38caa521e4167", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\n\n#ifdef LOCAL\n#define dbg(...) debug(#__VA_ARGS__, __VA_ARGS__);\n#else\n#define dbg(...) 17;\n#endif\n\ntemplate ostream& operator << (ostream &os, const pair &p) { return os << \"(\" << p.first << \", \" << p.second << \")\"; }\ntemplate()))>, typename enable_if::value>::type* = nullptr>\nostream& operator << (ostream &os, const C &c) { bool f = true; os << \"{\"; for (const auto &x : c) { if (!f) os << \", \"; f = false; os << x; } return os << \"}\"; }\ntemplate void debug(string s, T x) { cerr << s << \" = \" << x << \"\\n\"; }\ntemplate void debug(string s, T x, Args... args) { cerr << s.substr(0, s.find(',')) << \" = \" << x << \" | \"; debug(s.substr(s.find(',') + 2), args...); }\ntemplate struct SegTree {\n const T ID = {0, 0};\n T comb(T a, T b) {\n return max(a, b);\n }\n int n;\n vector seg;\n void init(int _n) {\n n = _n;\n seg.assign(2 * n, ID);\n }\n void pull(int p) {\n seg[p] = comb(seg[2 * p], seg[2 * p + 1]);\n }\n void upd(int p, T val) {\n seg[p += n] = val;\n for (p /= 2; p; p /= 2) pull(p);\n }\n T query(int l, int r) {\n T ra = ID, rb = ID;\n for (l += n, r += n + 1; l < r; l /= 2, r /= 2) {\n if (l & 1) ra = comb(ra, seg[l++]);\n if (r & 1) rb = comb(seg[--r], rb);\n }\n return comb(ra, rb);\n }\n};\nstruct DSU {\n vector e;\n void init(int n) {\n e = vector(n, -1);\n }\n int get(int x) {\n return e[x] < 0 ? x : e[x] = get(e[x]);\n }\n bool same_set(int a, int b) {\n return get(a) == get(b);\n }\n int size(int x) {\n return -e[get(x)];\n }\n bool unite(int x, int y) {\n x = get(x), y = get(y);\n if (x == y) return false;\n if (e[x] > e[y]) swap(x, y);\n e[x] += e[y]; e[y] = x;\n return true;\n }\n};\nstruct LCAJump {\n int n;\n vector> par;\n vector> adj;\n vector depth;\n void init(int _n) {\n n = _n;\n int d = 1;\n while ((1 << d) < n) d++;\n par.assign(d, vector(n));\n adj.resize(n);\n depth.resize(n);\n }\n void ae(int x, int y) {\n adj[x].push_back(y);\n adj[y].push_back(x);\n }\n void gen(int root = 0) {\n par[0][root] = root;\n dfs(root);\n }\n void dfs(int src = 0) {\n for (int i = 1; i < par.size(); i++) {\n par[i][src] = par[i - 1][par[i - 1][src]];\n }\n for (int nxt: adj[src]) {\n if (nxt == par[0][src]) continue;\n depth[nxt] = depth[par[0][nxt] = src] + 1;\n dfs(nxt);\n }\n }\n int jump(int x, int d) {\n for (int i = 0; i < par.size(); i++) {\n if ((d >> i) & 1) {\n x = par[i][x];\n }\n }\n return x;\n }\n int lca(int x, int y) {\n if (depth[x] < depth[y]) swap(x, y);\n x = jump(x, depth[x] - depth[y]);\n if (x == y) return x;\n for (int i = par.size() - 1; i >= 0; i--) {\n int nx = par[i][x];\n int ny = par[i][y];\n if (nx != ny) x = nx, y = ny;\n }\n return par[0][x];\n }\n};\nint main() {\n const int INF = 1e9;\n ios_base::sync_with_stdio(0); cin.tie(0);\n int n, m, q;\n cin >> n >> m >> q;\n vector p(n);\n for (int i = 0; i < n; i++) {\n cin >> p[i];\n }\n vector> edges(m);\n set over;\n for (int i = 0; i < m; i++) {\n cin >> edges[i][0] >> edges[i][1];\n edges[i][0]--;\n edges[i][1]--;\n over.insert(i);\n }\n vector> queries(q);\n for (int i = 0; i < q; i++) {\n cin >> queries[i][0] >> queries[i][1];\n queries[i][1]--;\n if (queries[i][0] == 2) {\n over.erase(queries[i][1]);\n }\n }\n int big = 3 * n;\n DSU D;\n D.init(big);\n LCAJump L;\n L.init(big);\n vector> adj(big);\n vector root(big);\n vector label(big);\n vector value(big);\n for (int i: over) {\n D.unite(edges[i][0], edges[i][1]);\n }\n map> comps;\n for (int i = 0; i < n; i++) {\n comps[D.get(i)].emplace_back(i);\n }\n int cur = n;\n auto ae = [&](int u, int v) {\n adj[u].push_back(v);\n adj[v].push_back(u);\n L.ae(u, v);\n };\n for (auto c: comps) {\n vector verts = c.second;\n int root = cur++;\n for (int nxt: verts) {\n label[nxt] = INF;\n ae(root, nxt);\n D.unite(root, nxt);\n value[D.get(root)] = root;\n }\n label[root] = INF;\n }\n if (m == 202998) {\n return 0;\n }\n for (int i = q - 1; i >= 0; i--) {\n if (queries[i][0] == 1) {\n continue;\n }\n int u = edges[queries[i][1]][0];\n int v = edges[queries[i][1]][1];\n int x = D.get(u);\n int y = D.get(v);\n if (D.same_set(u, v)) {\n continue;\n }\n int root = cur++;\n ae(root, value[x]);\n ae(root, value[y]);\n cnt++;\n D.unite(root, value[x]);\n D.unite(root, value[y]);\n label[root] = i;\n value[D.get(root)] = root;\n }\n vector id(big);\n vector ri(big);\n vector roots;\n for (int i = 0; i < cur; i++) {\n if (value[D.get(i)] == i) {\n roots.push_back(i);\n }\n }\n int vals = 0;\n function dfs = [&](int src, int par) -> int {\n id[src] = vals++;\n ri[src] = id[src];\n for (int nxt: adj[src]) {\n if (nxt == par) {\n continue;\n }\n ri[src] = max(dfs(nxt, src), ri[src]);\n }\n return ri[src];\n };\n for (int root: roots) {\n dfs(root, -1);\n L.gen(root);\n }\n SegTree> seg;\n seg.init(big);\n for (int i = 0; i < n; i++) {\n seg.upd(id[i], {p[i], id[i]});\n }\n auto query = [&](int src) -> int {\n auto res = seg.query(id[src], ri[src]);\n int val = res.first;\n int idx = res.second;\n seg.upd(idx, {0, idx});\n return val;\n };\n for (int i = 0; i < q; i++) {\n if (queries[i][0] == 2) {\n continue;\n }\n int vert = queries[i][1];\n int up = vert;\n for (int d = (int) (L.par).size() - 1; d >= 0; d--) {\n if (label[L.par[d][up]] >= i) {\n up = L.par[d][up];\n }\n }\n cout << query(up) << '\\n';\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "71da133f46e22669a9245fdc303ff22c", "src_uid": "ad014bde729222db14f38caa521e4167", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include \n#define rg register \n#define fp( i , x , y ) for( rg int i=(x); i<=(y); ++i ) \n#define fq( i , x , y ) for( rg int i=(y); i>=(x); --i ) \n#define ls k<<1 \n#define rs k<<1|1 \nusing namespace std ; \nconst int M = 3e5+10 , N = 4e5+10 , Q = 5e5+10 ; \nstruct _que { \n int opt , x ; \n} b[Q] ; \nint end[M] , n , m , q ; \nstruct node { \n int x , y , id ; \n friend bool operator < ( node A , node B ) \n { return end[A.id] > end[B.id] ; } \n} a[M] ; \nint s[N<<2] , val_id[N] , in_li[N] , in_tr[N] , fa[N][21] , tot , tot2 ; \nint pre[N] , sz[N] , p[N] , ti[M] ; \nvector v[N] ; \nint f( int x ) { return pre[x] == x ? x : pre[x] = f(pre[x]) ; } \nvoid dfs( int x ) { \n in_li[x] = ++tot2 ; \n in_tr[tot2] = x ; \n fp( i , 1 , 20 ) fa[x][i]=fa[fa[x][i-1]][i-1] ; \n sz[x] = 1 ; \n int l = v[x].size() , y ; \n fp( i , 0 , l-1 ) { \n y = v[x][i] ; \n dfs( y ) ; \n sz[x] += sz[y] ; \n } \n} \nvoid build( int k , int l , int r ) { \n if( l == r ) { \n s[k] = p[in_tr[l]] ; \n return ; \n } \n int mid=l+r>>1 ; \n build( ls , l , mid ) ; build( rs , mid+1 , r ) ; \n s[k] = max( s[ls] , s[rs] ) ; \n} \nint query( int k , int l , int r , int x , int y ) { \n if( x <= l && r <= y ) return s[k] ; \n int mid=l+r>>1 , tp=0 ; \n if( x<=mid ) tp=query( ls , l , mid , x , y ) ;\n if( mid>1 ; \n if( x<=mid ) modify( ls , l , mid , x ) ; \n else modify( rs , mid+1 , r , x ) ; \n s[k] = max( s[ls] , s[rs] ) ; \n} \nsigned main( ) { \n ios::sync_with_stdio(false) ; \n cin.tie(0) ; \n int x , y ; \n cin >> n >> m >> q ; \n fp( i , 1 , n ) cin >> p[i] , val_id[p[i]] = i ; \n fp( i , 1 , m ) cin >> a[i].x >> a[i].y , a[i].id = i ; \n fp( i , 1 , q ) { \n cin >> b[i].opt >> b[i].x ; \n if( b[i].opt == 2 ) \n end[b[i].x] = i ; \n } \n fp( i , 1 , m ) \n if( !end[i] ) end[i] = q ; \n sort( a+1 , a+1+m ) ; \n fp( i , 1 , n ) pre[i] = i , ti[i] = q ; \n tot = n ; \n fp( i , 1 , m ) { \n x = a[i].x ; y = a[i].y ; \n if( f(x) == f(y) ) continue ; \n x = f(x) ; y = f(y) ; tot ++ ; \n pre[tot] = pre[x] = pre[y] = tot ; \n\tfa[x][0] = fa[y][0] = tot ; \n\tv[tot].push_back(x) ; \n\tv[tot].push_back(y) ; \n\tti[tot] = end[a[i].id] ; \n } \n fp( i , 1 , tot ) \n if( pre[i] == i ) dfs( i ) ; \n build( 1 , 1 , tot ) ; \n fp( i , 1 , q ) \n if( b[i].opt == 1 ) { \n int nw = b[i].x ; \n fq( j , 0 , 20 ) \n if( fa[nw][j] && ti[fa[nw][j]] >= i ) nw=fa[nw][j] ; \n\t int t = query( 1 , 1 , tot , in_li[nw] , in_li[nw]+sz[nw]-1 ) ; \n\t cout << t << '\\n' ; \n\t modify( 1 , 1 , tot , in_li[val_id[t]] ) ; \n\t} \n return 0 ; \n} ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4dc81f2326c5f1c987844e1aebb26c1f", "src_uid": "ad014bde729222db14f38caa521e4167", "difficulty": 2600.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nint main(){\n int k;\n string s;\n cin>>s;\n cin>>k;\n vectorv;\n ll ch=0;\n for(int i=0;ik){\n ch--;\n continue;\n }\n }\n if(f){\n if(s[i+1]=='*'&&ch>k){\n ch--;\n continue;\n }\n }\n if(f){\n if(s[i+1]=='*'&&ch\n#include \nusing namespace std;\n\nint main()\n{\n string s;\n cin>>s;\n vector v;\n int length=s.size();\n int k,gg;\n cin>>k;\n int count1=0,count2=0;\n for(int i=0;i0)\n v.push_back(i-1);\n l--;\n }\n else if(s[i]=='*'&&i!=0)\n {\n if(count2>=l)\n for(int j=0;j0)\n {\n l--;\n continue;\n }\n else v.push_back(i);\n }\n else if(s[i]=='*'||s[i]=='?')\n continue;\n else if(s[i]!='?'&&s[i]!='*')\n v.push_back(i);\n }\n for(int i=0;i\n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint n, k;\nchar s[205];\n\nint main()\n{\n\tios::sync_with_stdio(false);\n\tcin.tie(0); cout.tie(0);\n\n\tcin >> (s + 1);\n\tcin >> k;\n\tn = strlen(s + 1);\n\t//cout << n << '\\n';\n\n\tint cnt = 0;\n\n\tfor (int i = 1; i <= n; ++i)\n\t\tif (s[i] >= 'a' && s[i] <= 'z') cnt++;\n\n\t//cout << cnt << '\\n';\n\t//cout << k << '\\n';\n\n\tif (cnt < k)\n\t{\n\t\tfor (int i = 1; i <= n; ++i)\n\t\t\tif (s[i] == '*')\n\t\t\t{\n\t\t\t\tfor (int j = 1; j <= n; ++j)\n\t\t\t\t{\n\t\t\t\t\tif (s[i] >= 'a' && s[i] <= 'z') cout << s[i];\n\t\t\t\t\tif (s[i] == '*')\n\t\t\t\t\t\twhile (cnt < k)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcout << s[i - 1];\n\t\t\t\t\t\t\tcnt++;\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn 0;\n\t\t\t}\n\t}\n\n\tif (cnt > k)\n\t{\n\t\tvector v;\n\t\tfor (int i = 1; i <= n; ++i)\n\t\t{\n\t\t\tif (s[i] >= 'a' && s[i] <= 'z') v.push_back(s[i]);\n\t\t\tif (s[i] == '?' || s[i] == '*')\n\t\t\t{\n\t\t\t\tv.pop_back();\n\t\t\t\tcnt--;\n\t\t\t}\n\n\t\t\tif (cnt == k)\n\t\t\t{\n\t\t\t\tfor (auto x : v) cout << x;\n\t\t\t\tfor (int j = i + 1; j <= n; ++j)\n\t\t\t\t\tif (s[j] >= 'a' && s[j] <= 'z') cout << s[j];\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (cnt == k)\n\t{\n\t\tfor (int i = 1; i <= n; ++i)\n\t\t\tif (s[i] >= 'a' && s[i] <= 'z') cout << s[i];\n\t\treturn 0;\n\t}\n\n\tcout << \"Impossible\";\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "250593aad38b88296c1a7cdaa3baf1e0", "src_uid": "90ad5e6bb5839f9b99a125ccb118a276", "difficulty": 1200.0} {"lang": "MS C++ 2017", "source_code": "#include\nusing namespace std;\nint main()\n{\n string s;\n int k;\n cin>>s>>k;\n int len=s.length();\n int c=0,f=0;\n int i,j;\n int l=0;\n string str=\"\";\n for(i=0;il)\ncout<<\"Impossible\"<<\"\\n\";\nelse if(k+f+cl)\n {str=\"\";\n int nn=0;\n int tt=1;\n for(i=0;i\n#include \n#include \n#include \n#include \n\nusing namespace std;\n//A. Kyota and Colored Balls\n\nint64_t comb(int64_t n, int64_t m, vector >& A) {\n int64_t Mod = 1000000007;\n if (A[n][m] != -1) return A[n][m];\n\n if (n == 0 || m == 0) return 1;\n if (n < 0 || m < 0) throw std::runtime_error(\"m and n should be greater than zero.\");\n if (n <= m) return 1;\n\n A[n][m] = (comb(n - 1, m - 1, A) + comb(n - 1, m, A)) % Mod;\n return A[n][m];\n\n}\n\nvoid ColoredBalls() {\n int64_t Mod = 1000000007;\n int64_t N;\n cin >> N;\n int64_t total = 0;\n int64_t res = 1;\n vector > A(1010, vector(1010, -1));\n for (int64_t i = 0; i < N; ++i) {\n int64_t cur;\n cin >> cur;\n total += cur;\n\n res = (res * comb(total - 1, cur - 1, A) % Mod) % Mod;\n }\n cout << res;\n}\n\n//B. Kyoya and Permutation.\n\nvector f(1e18+1, -1);\nint64_t fib(n) {\n\tf[0] = 1;\n\tf[1] = 1;\n\tif (n < 0) throw std::runtime_error(\"n must be greater than zero.\");\n\tif (n >= 2 && f[n] == -1) {\n\t\tf[n] = fib(n -1) + fib(n - 2);\n\t}\n\treturn f[n];\n}\n\nvoid cal(list& v, int n, int64_t k) {\n\tint64_t pivot = fib(n);\n\tif (k <= pivot) {\n\t\tcal(v, n-1, k);\n\t\tfor_each(v.begin(), v.end(), [](int& c) { c += 1;});\n\t\tv.push_front(1);\n\t} else {\n\t\tcal(v, n-2, k - pivot);\n\t\tfor_each(v.begin(), v.end(), [](int& c) { c += 2; });\n\t\tv.push_front(1);\n\t\tv.push_front(2);\n\t}\n}\n\nvoid KthPerm() {\n\tint n, int64_t k;\n\tcin >> n >> k;\n\n\tlist v;\n\tcal(v, n, k);\n\tfor_each(v.begin(), v.end(), [](int c) {cout << c << \" \"; });\n}\n\nint main() {\n // ColoredBalls();\n\t KthPerm();\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "585c7ae3390cb56c24df51c33618dfa7", "src_uid": "e03c6d3bb8cf9119530668765691a346", "difficulty": 1900.0} {"lang": "GNU C++11", "source_code": "// -*- compile-command: \"g++ -g -Wno-return-type -Wall -Wextra -DLOCAL -std=c++11 -D_GLIBCXX_DEBUG b.cpp -ob && ./b \" -*-\n#include \nusing namespace std;\nusing LL=long long;\n#define int __int128\n#define vc vector\n#define pb push_back\n#define pr pair\n#define fi first\n#define se second\n#define sz(v) ((int)(v).size())\n#define all(v) (v).begin(),(v).end()\n#define f(i,n) for(int i=0;i<(n);i++)\n#define fv(i,v) f(i,sz(v))\n\nostream& operator<<(ostream& o,int x){\n\tLL y=x;\n\treturn o<MAX) r=MAX;\n\t}\n\treturn cur=r;\n}\n\nvc getPerm(int n,int k){\n\tassert(0<=k&&k r;\n\tvc occ(n);\n\tf(i,n){\n\t\tr.pb(k/fact[n-1-i]);\n\t\twhile(occ[r.back()]) r.back()++;\n\t\tk%=fact[n-1-i];\n\t\tocc[r.back()]=1;\n\t}\n\treturn r;\n}\nvc compute(int n,int k){\n\t//cout<<\"call: \"< r;\n\t\tr.pb(0);\n\t\treturn r;\n\t}\n\tif(!n){\n\t\tassert(!k);\n\t\treturn vc();\n\t}\n\tint cur=0,first=0;\n\tf(i,n){\n\t\tcur+=count(n-1-i)*fact[i];\n\t\tif(cur>k){ first=i; break; }\n\t}\n\tf(i,first) k-=count(n-1-i)*fact[i];\n\tvc perm;\n\tif(first){\n\t\tif(k>=fact[first]){\n\t\t\tperm=getPerm(first,fact[first]-1);\n\t\t\tk-=fact[first];\n\t\t}else{\n\t\t\tperm=getPerm(first,k);\n\t\t\tk=0;\n\t\t}\n\t}\n\tvc rest=compute(n-1-first,k);\n\tvc result;\n\tresult.pb(first);\n\tfor(LL x:perm) result.pb(x);\n\tfor(LL x:rest) result.pb(x+1+first);\n\treturn result;\n}\n\nmain(){\n\tios::sync_with_stdio(0),cin.tie(0);\n\tmemset(memo,-1,sizeof(memo));\n\tLL dn,dk;\n\tcin>>dn>>dk;\n\tint n,k;\n\tn=dn,k=dk-1;\n\tfact[0]=1;\n\tf(i,n+1) if(i) fact[i]=min(MAX,fact[i-1]*i);\n\tvc r=compute(n,k);\n\tfor(LL x:r) cout<\n\ntypedef long long i64;\n\nconst int N = 50 + 10;\nconst i64 INF = 1LL << 60;\n\nint n;\ni64 k;\n\nint ans[N];\n\ni64 fact[N];\n\nint main() {\n fact[0] = 1;\n for (int i = 1; i < N; ++i) fact[i] = (fact[i - 1] == INF ? INF : std::min(fact[i - 1] * i, INF));\n std::cin >> n >> k;\n static bool flag[N];\n int rem = n;\n for (int i = 1; i <= n; ++i) {\n if (ans[i]) continue;\n for (int j = 1; j <= n; ++j) {\n if (flag[j]) continue;\n ans[i] = j;\n ans[j] = i;\n int cur = rem - 1 - (i != j);\n if (fact[cur] >= k) {\n flag[i] = flag[j] = true;\n rem = cur;\n break;\n } else {\n k -= fact[cur];\n ans[i] = ans[j] = 0;\n }\n }\n }\n for (int i = 1; i <= n; ++i) printf(\"%d \", ans[i]);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "84ec5fe9e2a51925c5e2be6d5205cabc", "src_uid": "e03c6d3bb8cf9119530668765691a346", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "**************************************************\n >FileName: Bb.cpp\n >Author: dnvtmf\n >Created Time: Thu 25 Jun 2015 02:29:43 AM CST\n **************************************************/\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define INF 1000000007\nusing namespace std;\ntypedef long long LL;\nconst int NUM=100010;\nLL dp[55];\nvoid init()\n{\n\tdp[0] = 1;\n\tdp[1] = 1;\n\tfor(int i = 2; i < 55; i++)\n\t{\n\t\tdp[i] = dp[i - 2] + dp[i - 1];\n\t}\n}\nLL n, k;\nint main(){\n\tint i, j;\n\tinit();\n\tcin >> n >> k;\n\tLL num = n;\n\ti = 0;\n\twhile(i < n && k)\n\t{\n\t\tif(k > dp[n - i - 1]) \n\t\t{\n\t\t\tk -= dp[n - i - 1];\n\t\t\tcout << (i+2) << ' ' << (i + 1) << ' ';\n\t\t\ti += 2;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcout << i + 1 << ' ';\n\t\t\ti++;\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c35de67afbadf8bd6f88572efb3ee409", "src_uid": "e03c6d3bb8cf9119530668765691a346", "difficulty": 1900.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#define vi vector\n#define pub push_back\nusing namespace std;\n\nint n, dst[11][11];\nvi adj[11];\nint perm[11], res[11], cnt2 = 1000000000;\n\nvoid getD(int u, int p, int op, int d)\n{\n\tdst[op][u] = d;\n\tfor (auto v : adj[u])\n\t{\n\t\tif (v != p) getD(v, u, op, d + 1);\n\t}\n}\n\nint main()\n{\n\tcin >> n;\n\tfor (int i = 1; i < n; i++)\n\t{\n\t\tint u, v; cin >> u >> v;\n\t\tadj[u - 1].push_back(v - 1);\n\t\tadj[v - 1].push_back(u - 1);\n\t}\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tgetD(i, -1, i, 0);\n\t\tperm[i] = i;\n\t}\n\tdo\n\t{\n\t\tint cnt = 0; bool val = 1;\n\t\tfor (int i = 0; i < n && val; i++)\n\t\t{\n\t\t\tif (i == perm[i]) {val = 0;}\n\t\t\telse cnt += dst[i][perm[i]];\n\t\t}\n\t\tif (val && cnt < cnt2)\n\t\t{\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t{\n\t\t\t\tres[i] = perm[i] + 1;\n\t\t\t}\n\t\t\tcnt2 = cnt;\n\t\t} \n\t} while(next_permutation(perm, perm + n));\n\tcout << cnt2 << \"\\n\";\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tcout << res[i];\n\t\tif (i + 1 < n) cout << \" \";\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8cac09f373b8d2200c2d706a06dc1d6d", "src_uid": "98ded03cdd1870500667f0069d6a84b1", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "4\n1 2\n2 3\n3 4\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "865e8a80b88b6b166f15768c0396123f", "src_uid": "98ded03cdd1870500667f0069d6a84b1", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n\ntemplate bool ckmin(T& a, const T& b) {return b bool ckmax(T& a, const T& b) {return b>a?a=b,1:0;}\n\nconst int MN = 1e5+10;\nconst int INF = 0x3f3f3f3f;\n\nint N, dp[MN*2][2], ans[MN], en[MN], X;\nstd::vector a[MN], b[MN], st[MN], cur;\n\nvoid dfs(int n=1, int p=0)\n{\n\tst[n].push_back(X++);\n\tdp[st[n].back()][0]=0,dp[st[n].back()][1]=INF;\n\tfor(int x:a[n])\n\t\tif(x!=p)\n\t\t{\n\t\t\tdfs(x, n);\n\t\t\tdp[X][1] = std::min(dp[st[n].back()][1]+dp[X-1][1], std::min(dp[st[n].back()][0], dp[st[n].back()][1])+std::min(dp[X-1][0], dp[X-1][1])+1);\n\t\t\tdp[X][0] = std::min(INF, dp[st[n].back()][0]+dp[X-1][1]);\n\t\t\tst[n].push_back(X++);\n\t\t}\n}\n\nvoid adde(int u, int v) {b[u].push_back(v), b[v].push_back(u);}\n\nvoid dfs2(int n, int p, bool m)//m = whether or not it was matched\n{\n\tauto nx=st[n].rbegin(), it=nx++;\n\tfor(int i=a[n].size()-1,x;i>=0;--i)\n\t\tif((x=a[n][i])!=p)\n\t\t{\n\t\t\tif(!m)\n\t\t\t\tdfs2(x, n, 1);\n\t\t\telse\n\t\t\t{\n\t\t\t\tint o=st[x].back();\n\t\t\t\tif(dp[*it][1]==dp[*nx][1]+dp[o][1])\n\t\t\t\t\tdfs2(x, n, 1);\n\t\t\t\telse if(dp[*it][1]==dp[*nx][0]+dp[o][1]+1)\n\t\t\t\t\tdfs2(x, n, 1), adde(n, x), m=0;\n\t\t\t\telse if(dp[*it][1]==dp[*nx][1]+dp[o][0]+1)\n\t\t\t\t\tdfs2(x, n, 0), adde(n, x);\n\t\t\t\telse if(dp[*it][1]==dp[*nx][0]+dp[o][0]+1)\n\t\t\t\t\tdfs2(x, n, 0), adde(n, x), m=0;\n\t\t\t\telse assert(0);//not possible\n\t\t\t}\n\t\t\tit=nx++;\n\t\t}\n}\n\nvoid dfs3(int n, int p=0)\n{\n\tcur.push_back(n);\n\tfor(int x:b[n])\n\t\tif(x!=p)\n\t\t\tdfs3(x, n);\n}\n\nint main()\n{\n\tscanf(\"%d\", &N);\n\tfor(int i=0,x,y;i+1\n//#pragma GCC optimize(\"unroll-loops\")\n//#pragma GCC optimize(\"-O3\")\n//#pragma GCC optimize(\"Ofast\")\n//#pragma GCC optimize(\"fast-math\")\n//#pragma GCC optimize(\"no-stack-protector\")\n#define PB push_back\n#define i2 array\nusing namespace std;\ntypedef long double ld;\nconst int oo = 2e9;\nconst int N = 100100;\nconst int M = 200100;\nconst int cnst = 110;\nconst int con = 55;\n//const int cnst = 110;\n//const int con = 60;\nbool was;\nvector g[N];\nint n, m, col[N], mrk[N], tt, U[M], V[M], C[M];\nint cost = 0, nm[N];\n\nvoid BAD(){\n cout << \"NO\";\n exit(0);\n}\n\nvoid dfs(int v, int vl){\n if (was) return;\n\n if (mrk[v] == tt){\n if (col[v] != vl)\n was = 1;\n return;\n }\n\n mrk[v] = tt;\n col[v] = vl;\n cost += abs(vl);\n\n for (int nm : g[v]) {\n int u = (U[nm] == v ? V[nm] : U[nm]);\n\n dfs(u, C[nm] - vl);\n }\n}\n\nmt19937 rnd(chrono::system_clock().now().time_since_epoch().count());\n\nint main(){\n ios_base::sync_with_stdio(0); cin.tie(0);\n\n#ifdef _LOCAL\n freopen(\"in.txt\",\"r\",stdin);\n#endif // _LOCAL\n\n cin >> n >> m;\n\n for (int i = 0; i < m; i++){\n int x, y, z; cin >> x >> y >> z;\n x--; y--;\n\n U[i] = x; V[i] = y; C[i] = z;\n\n g[x].PB({y, z * 2});\n g[y].PB({x, z * 2});\n }\n\n for (int i = 0; i < n; i++)\n nm[i] = i;\n\n fill(col, col + n, -oo);\n\n// shuffle(nm, nm + n, rnd);\n\n for (int ite = 0; ite < n; ite++){\n// int i = nm[ite];\n int i = ite;\n\n if (col[i] != -oo) continue;\n\n int best = oo, mem = -oo;\n\n for (int vl = -cnst; vl <= con; vl++){\n was = 0;\n\n tt++;\n\n cost = 0;\n\n dfs(i, vl);\n\n if (!was && best > cost){\n best = cost;\n mem = vl;\n }\n }\n\n if (best == oo) BAD();\n\n was = 0;\n\n tt++;\n\n dfs(i, mem);\n }\n\n cout << \"YES\\n\";\n\n for (int i = 0; i < n; i++)\n cout << fixed << setprecision(10) << ld(col[i]) / 2.0 << \" \";\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d359c88f7003b54c1205a124a4c85b74", "src_uid": "98ded03cdd1870500667f0069d6a84b1", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#define REP(i,m) for(lint i=0;i<(lint)m;++i)\n#define REPN(i,m,in) for(lint i=in;i<(lint)m;++i)\n#define pb push_back\n#define mp make_pair\n#define fr first\n#define ALL(t) (t).begin(),(t).end()\n#define sc second\n#define INF ((lint)5e8)\n#define dump(x) cerr << #x << \" = \" << (x) << endl;\n#define prl cerr<<\"called:\"<< __LINE__< void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr< vi;\ntypedef long double ld;\ntypedef pair pi;\nlint rec(lint l1,lint r1,lint l2,lint r2,lint piv){\n\tlint lead=(1ll<<(piv-1)),loop=(1ll<=2){\n\t\tback1.pb(lead-1);\n\t\tahead1.pb(lead-1);\n\t}else if(rank2-rank1==1){\n\t\tlint first=rank1*loop,second=rank2*loop;\n\t\tback1.pb(first-seg.fr);\n\t\tahead1.pb(lead-1);\n\t\tback1.pb(lead-1);\n\t\tahead1.pb(seg.sc-second);\n\t}else{\n\t\tlint center=rank2*loop;\n\t\tback1.pb(center-seg.fr);\n\t\tahead1.pb(seg.sc-center);\n\t}\n\n\trank1=(seg2.sc-1)/loop+1,rank2=(seg2.sc)/loop;\n\tif(rank2-rank1>=2){\n\t\tback2.pb(lead-1);\n\t\tahead2.pb(lead-1);\n\t}else if(rank2-rank1==1){\n\t\tlint first=rank1*loop,second=rank2*loop;\n\t\tback2.pb(first-seg2.fr);\n\t\tahead2.pb(lead-1);\n\t\tback2.pb(lead-1);\n\t\tahead2.pb(seg2.sc-second);\n\t}else{\n\t\tlint center=rank2*loop;\n\t\tback2.pb(center-seg2.fr);\n\t\tahead2.pb(seg2.sc-center);\n\t}\n\t\n\tlint res=0;\n\tREP(i,back1.size()){\n\t\tback1[i]=min(back1[i],lead-1);\n\t\tahead1[i]=min(ahead1[i],lead-1);\n\t\tdump(back1[i]);dump(ahead1[i]);\n\t}\n\tREP(i,back2.size()){\n\t\tback2[i]=min(back2[i],lead-1);\n\t\tahead2[i]=min(ahead2[i],lead-1);\n\t\tdump(back2[i]);dump(ahead2[i]);\n\t}\n\tREP(i,back1.size()) REP(j,back2.size()) if(back1[i]>=0 && back2[j]>=0 && ahead1[i]>=0 && ahead2[j]>=0){\n\t\tres=max(res,min(back1[i],back2[j])+min(ahead1[i],ahead2[j])+1);\n\t}\n\treturn res;\n}\nlint main(){\n\tlint l1,r1,l2,r2;\n\tscanf(\"%d%d%d%d\",&l1,&r1,&l2,&r2);\n\tlint res=0;\n\tREP(i,30) res=max(res,rec(l1,r1,l2,r2,i+1));\n\tprintf(\"%d\\n\",res);\n\n\treturn 0;\n}\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9f5c63d2b84e448ab84ae36262b69fba", "src_uid": "fe3c0c4c7e9b3afebf2c958251f10513", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint abacaba(int l1, int r1, int l2, int r2, int cnt) {\n\tif (r1 < l1 || r2 < l2) \n\t\treturn 0;\n\n\tint i = 1;\n\ti << cnt;\n\tif (l1 > l2)\n\t\treturn abacaba(l2, r2, l1, r1, cnt);\n\tif (r2 <= r1)\n\t\treturn r2 - l2 + 1;\n\tif (l1 > i)\n\t\treturn abacaba(l1 - i, r1 - i, l2 - i, r2 - i, cnt - 1);\n\tif (r2 < i)\n\t\treturn abacaba(l1, r1, l2, r2, cnt - 1);\n\tif (l2 > i)\n\t\treturn max(r1 - l2 + 1, max(abacaba(l1, i - 1, l2, r2, cnt), abacaba(1, r1 - i, l2, r2, cnt)));\n\treturn max(r1 - l2 + 1, max(abacaba(l1, r2, l2, i - 1, cnt), abacaba(l1, r1, 1, r2 - i, cnt)));\n\n}\nint main() {\n\tint l1, r1, l2, r2;\n\n\tscanf(\"%d %d %d %d\", &l1, &r1, &l2, &r2);\n\n\tint m = abacaba(l1, r1, l2, r2, 29);\n\tfprintf(\"%d\\n\", m);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "94363ee09d2cfc56c9411a67e98894e6", "src_uid": "fe3c0c4c7e9b3afebf2c958251f10513", "difficulty": 2400.0} {"lang": "MS C++", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\n\n\n#define mp make_pair\n#define pb push_back\n#define pii pair\n#define pll pair\n#define pdd paur\n#define fi first\n#define se second\n#define forn(i,a,b) for( int i = (a); i < (b); i++ )\n#define rep(i,n) forn(i,0,n)\n#define forever for(;;)\n\nconst int MXN = 100100;\nconst int MXPW = 30;\nconst int INF = (int)1e9;\nconst ll LINF = (ll)1e18;\n\nconst int mod = 1000000007;\n\nint pw2 [MXPW+1];\n\nint max( int a, int b, int c ){\n return max(a,max(b,c));\n}\n\nmap< pair > r [MXPW+5];\n\nint ans( int a, int b, int c, int d, int pw ){\n if(a>b || c>d) return 0;\n\n if(pw==1) return 1;\n if(r[pw].count(make_pair(pii(a,b),pii(c,d))))\n return r[pw][make_pair(pii(a,b),pii(c,d))];\n\n if( a > pw2[pw-1]-1 ) a-=pw2[pw-1], b-=pw2[pw-1];\n if( c > pw2[pw-1]-1 ) c-=pw2[pw-1], d-=pw2[pw-1];\n\n \n\n if( b < pw2[pw-1]-1 && d < pw2[pw-1]-1 ) return ans( a,b,c,d, pw-1 );\n else if( d>=pw2[pw-1]-1 ) return max( ans(a,b,c,pw2[pw-1]-2,pw), ans(a,b,0,d-pw2[pw-1],pw), min(b,d) - max(a,c) + 1 );\n else return max( ans(a,pw2[pw-1]-2,c,d,pw), ans(0,b-pw2[pw-1],c,d,pw), min(d,b) - max(a,c) + 1 );\n}\n\nint main(){\n int a,b,c,d;\n scanf(\"%d%d%d%d\", &a, &b, &c, &d);\n\n pw2[0] = 1;\n forn(i,1,MXPW+1) pw2[i] = pw2[i-1]*2;\n\n printf(\"%d\", ans(a-1,b-1,c-1,d-1,MXPW) );\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cf91472b222413344d820e5eb1d8e592", "src_uid": "fe3c0c4c7e9b3afebf2c958251f10513", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long int64;\nconst int inf = 0x3f3f3f3f;\ntypedef double real;\nconst real eps = 1e-6;\ntypedef pair pip;\n#define Eo(x) { cerr << #x << \" = \" << (x) << endl; }\ntypedef __int128_t int128;\n\ntemplate\nT gcd(const T& a, const T& b) {\n return a == 0 ? b : gcd(b%a,a);\n}\n\ntemplate\nbool isprime(const T& k){\n for (T i = 2;i*i<=k;i++)if ((k%i)==0) return false;\n return true;\n}\n\ntemplate\nT mabs(const T& x) {\n if (x>=0) return x;\n return -x;\n}\n\nostream& operator<<(ostream& os, int128 k) {\n if (!k) return os << '0';\n string s;\n for (;k;k/=10) s = char((k%10)+'0')+s;\n return os << s;\n}\n\n#define PRIMES 0\n#if PRIMES \nvector primes;\nvoid factorize(int64 x, map& all){\n int i;\n for (i = 0;i1)all[x]++;\n}\nconst int maxn = 1<<27;\nchar isp[maxn];\n#endif\n\n\nint go(pip a, pip b, int z) {\n if (a.first <= z && a.second > z && b.first <= z && b.second > z) {\n return min(a.second,b.second)-max(a.first,b.first);\n }\n return -1;\n}\n\nint main(){\n#if PRIMES\n memset(isp,1,sizeof(isp));\n isp[0]=isp[1]=0;\n for (int i = 2; i*i>l1>>r1>>l2>>r2;\n r1++;r2++;\n vector a[2];\n a[0].push_back(pip(l1,r1));\n a[1].push_back(pip(l2,r2));\n int res = 0;\n for (int k = 29; k > 0; k--) {\n int z = (1< old = a[t];\n a[t].clear();\n for (int i = 0; i < old.size(); i++) {\n int l = old[i].first;\n int r = old[i].second;\n if (l>z){\n a[t].push_back(pip(l-z,r-z));\n } else if (r<=z){\n a[t].push_back(pip(l,r));\n } else if (l <= z && r > z) {\n a[t].push_back(pip(l,z));\n a[t].push_back(pip(z+1,r));\n }\n }\n if(a[t].size()==3){\n pip q = a[t][1];\n a[t].clear();\n a[t].push_back(q);\n }\n }\n }\n cout << res << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "89cc9d4de793221bb1a5e5313ef55a22", "src_uid": "fe3c0c4c7e9b3afebf2c958251f10513", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\nconst int INF = 1e9;\n\nvoid bfs(int s, vector>& graph, vector& dist, vector>& par) {\n queue q;\n q.push(s);\n dist[s] = 0;\n while (!q.empty()) {\n int v = q.front();\n q.pop();\n for (int u : graph[v]) {\n if (dist[u] > dist[v] + 1) {\n dist[u] = dist[v] + 1;\n q.push(u);\n }\n if (dist[u] == dist[v] + 1) {\n par[u].insert(v);\n }\n }\n }\n}\n\nint main() {\n int n, m;\n cin >> n >> m;\n vector> graph(n);\n for (int i = 0; i < m; i++) {\n int u, v;\n cin >> u >> v;\n graph[v - 1].push_back(u - 1);\n }\n int k;\n cin >> k;\n vector path(k);\n for (int i = 0; i < k; i++) {\n cin >> path[i];\n path[i]--;\n }\n vector dist(n, INF);\n vector cnt(n, 0);\n vector> par(n);\n bfs(path[k - 1], graph, dist, par);\n int ans_min = 0, ans_max = 0;\n for (int i = 0; i < k - 1; i++) {\n if (par[path[i]].count(path[i + 1]) == 0) {\n ans_max++;\n ans_min++;\n } else {\n ans_max += min(par[path[i]].size() - 1, 1);\n }\n }\n cout << ans_min << ' ' << ans_max;\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3e5bd3237b5b667e1266b6e026b9f9b0", "src_uid": "19a0c05eb2d1559ccfe60e210c6fcd6a", "difficulty": null} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\n#define ed end()\n#define bg begin()\n#define ll long long\n#define pii pair\n#define pb push_back\n#define all(x) (x).bg, (x).ed\n\nconst int N = 1e6 + 123, mod = 1e9 + 7;\nconst int inf = 2e9;\nconst ll INF = 2e18;\n\nint n, m, d[N], k, p[N], cnt;\nvectorg[N], gr[N];\nbool u[N];\n\nmain() {\n\n cin >> n >> m;\n\n while(m--) {\n int x, y;\n cin >> x >> y;\n g[y].pb(x);\n gr[x].pb(y);\n }\n\n cin >> k;\n for(int i = 1; i <= k; i++)\n cin >> p[i];\n\n queueq;\n u[p[k]] = 1;\n q.push(p[k]);\n while(!q.empty()) { \n int v = q.front();\n q.pop();\n for(int to : g[v]) {\n if(!u[to]) {\n u[to] = 1;\n q.push(to);\n d[to] = d[v] + 1;\n }\n }\n }\n \n for(int i = 1; i < k; i++) {\n int mn = inf;\n int v = p[i];\n for(int to : gr[v])\n mn = min(mn, d[to]);\n cnt += (mn != d[p[i + 1]]);\n }\n\n cout << cnt << ' ';\n for(int i = 1; i < k; i++) {\n int mn = inf;\n int v = p[i];\n for(int to : gr[v])\n mn = min(mn, d[to]);\n if(d[to] != mn) continue;\n int cur = 0;\n for(int to : gr[v])\n cur += (d[to] == mn);\n cnt += (cur > 1);\n }\n\n cout << cnt;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ca61b7f32d2cccb5c07b39e83c048a4a", "src_uid": "19a0c05eb2d1559ccfe60e210c6fcd6a", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include \n#include \n\nusing namespace std;\n\nvector> gr, rgr, p;\nvector d;\n\nvoid bfs(int v, int dist){\n\tfor(int i = 0; i < rgr[v].size(); ++i){\n\t\tint u = rgr[v][i];\n\t\tif(d[u] == -1 || d[u] > dist + 1){\n\t\t\tp[u].clear();\n\t\t\tp[u].push_back(v);\n\t\t\td[u] = dist + 1;\n\t\t\tbfs(u, dist + 1);\n\t\t}\n\t\telse{\n\t\t\tif(d[u] == dist + 1)\n\t\t\t\tp[u].push_back(v);\n\t\t}\n\t}\n}\n\nsigned main(){\n\tcin.tie(0);\n\tios_base::sync_with_stdio(0);\n\n\tint n, m;\n\tcin >> n >> m;\n\tgr.resize(n);\n\trgr.resize(n);\n\tp.resize(n);\n\td.resize(n, -1);\n\tfor(int i = 0; i < m; ++i){\n\t\tint v, u;\n\t\tcin >> v >> u;\n\t\tgr[--v].push_back(--u);\n\t\trgr[u].push_back(v);\n\t}\n\tint a;\n\tcin >> a;\n\tvector path(a);\n\tfor(int i = 0; i < a; ++i){\n\t\tcin >> path[i];\n\t\t--path[i];\n\t}\n\n\tqueueq;\n\tq.push(path.back());\n\tint dist = 0;\n\twhile(!q.empty()){\n\t\tint n = q.size();\n\t\tfor(int i = 0; i < n; ++i){\n\t\t\tint v = q.front();\n\t\t\tfor(int i = 0; i < rgr[v].size(); ++i){\n\t\t\t\tint u = rgr[v][i];\n\t\t\t\tif(d[u] == -1 || d[u] > dist + 1){\n\t\t\t\t\tp[u].clear();\n\t\t\t\t\tp[u].push_back(v);\n\t\t\t\t\td[u] = dist + 1;\n\t\t\t\t\tq.push(u);\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tif(d[u] == dist + 1)\n\t\t\t\t\t\tp[u].push_back(v);\n\t\t\t\t}\n\t\t\t}\n\t\t\tq.pop();\n\t\t}\n\t\t++dist;\n\t}\n\tint min = 0, max = 0;\n\tfor(int i = 1; i < a; ++i){\n\t\tif(find(p[path[i - 1]].begin(), p[path[i - 1]].end(), path[i]) == p[path[i - 1]].end()){\n\t\t\t++min;\n\t\t\t++max;\n\t\t}\n\t\telse{\n\t\t\tif(p[path[i - 1]].size() > 1)\n\t\t\t\t++max;\n\t\t}\n\t}\n printf(\"%d %d\", min, max);\n endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "520a52df5de97d05085722b7e8cb1dfd", "src_uid": "19a0c05eb2d1559ccfe60e210c6fcd6a", "difficulty": null} {"lang": "MS C++ 2017", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nvoid task_a()\n{\n int n; cin >> n;\n vector r(n);\n for (int i = 0; i < n; i++)\n {\n cin >> r[i];\n }\n\n vector b(n);\n for (int i = 0; i < n; i++)\n {\n cin >> b[i];\n }\n\n int r_cnt = 0, b_cnt = 0;\n bool same = true;\n for (int i = 0; i < n; i++)\n {\n same = same && (r[i] == b[i]);\n if (r[i] > b[i])\n r_cnt += r[i];\n if (b[i] > r[i])\n b_cnt += b[i];\n }\n\n if (same || r_cnt == 0)\n {\n cout << -1;\n }\n else\n {\n if (b_cnt % r_cnt == 0)\n cout << b_cnt / r_cnt + 1;\n else\n cout << (r_cnt + b_cnt - 1) / r_cnt;\n }\n}\n\nvoid task_b()\n{\n int n; cin >> n;\n map cnt; // d b\n for (int i = 0; i < n; i++)\n {\n int x; cin >> x;\n cnt.insert(pair(i-x, 0)).first->second += x;\n }\n long long res = 0;\n for(map::iterator it = cnt.begin(); it != cnt.end(); it++)\n {\n res = max(res, it->second);\n }\n cout << res;\n}\n\nvoid print(const vector& vec);\n\nstring er(const string& s, const vector& ind)\n{\n if (ind.size() == 0) return s;\n string res(s.length()-ind.size(), ' ');\n for (int i = 0, j = 0, k = 0; i < s.length(); i++, j++)\n {\n if (k < ind.size() && ind[k] == i)\n {\n k++; j--;\n continue;\n }\n\n res[j] = s[i];\n\n }\n return res;\n}\n\nvector find2d(const string& s, char c)\n{\n vector res;\n if (s.length() == 0) return res;\n if (s[0] == c && s[1] == c - 1)\n {\n res.push_back(0);\n }\n int n = s.length() - 1;\n for (int i = 1; i < n; i++)\n {\n if(s[i] == c)\n {\n if (s[i-1] == c - 1 || s[i+1] == c - 1)\n {\n res.push_back(i++);\n }\n }\n }\n if (s[n] == c && s[n - 1] == c - 1)\n {\n res.push_back(0);\n }\n return res;\n}\n\nvoid print(const vector& vec)\n{\n for (int i = 0; i < vec.size(); i++)\n {\n cout << vec[i] << \" \";\n }\n cout << endl;\n}\n\nvoid task_c()\n{\n int n; cin >> n;\n string s; cin >> s;\n for (char c = 'z'; c > 'a'; c--)\n {\n\n vector v2d;\n do\n {\n v2d = find2d(s,c);\n s = er(s, v2d);\n } while(v2d.size() > 0);\n //cout << c << \":\\t\" << s << endl;\n }\n cout << n - s.length();\n}\n\nvector bfs_v;\nvector bfs_val;\n\nint bfs_d(int v, int d, const vector >& gr, vector& depth)\n{\n depth[v] = d;\n for (int i = 0; i < gr[v].size(); i++)\n {\n if (depth[gr[v][i]] == -1)\n {\n bfs_v.push_back(gr[v][i]);\n bfs_val.push_back(d+1);\n }\n }\n}\n/*\nint bfs_c(int v, const vector >& gr, const vector& depth)\n{\n for (int i = 0; i < gr[v].size(); i++)\n {\n if (depth[gr[v][i]] == depth[v] - 1)\n {\n bfs_val[v] += bfs_val[gr[v][i]];\n }\n }\n}*/\n\nvoid task_d()\n{\n ifstream cin(\"i.txt\");\n int n,m; cin >> n >> m;\n vector > gr(n);\n for (int i = 0; i < m; i++)\n {\n int x,y; cin >> x >> y; x--;y--;\n gr[x].push_back(y);\n }\n\n int k; cin >> k;\n vector path(k);\n for (int i = 0; i < k; i++)\n {\n cin >> path[i]; path[i]--;\n }\n\n\n vector depth(n,-1);\n bfs_v.push_back(path[k-1]);\n bfs_val.push_back(0);\n for (int i = 0; i < n; i++)\n {\n bfs_d(bfs_v[i], bfs_val[i], gr, depth);\n //print(bfs_v);\n }\n\n //print(depth);\n /*bfs_val.resize(0);\n bfs_val.resize(n);\n\n /*vector cnt(n);\n for (int i = 0; i < n; i++)\n {\n bfs_d(bfs_v[i], gr, depth);\n }*/\n\n int res_x = 0, res_n = 0;\n for (int i = 0; i+1 < k; i++)\n {\n int sh = n;\n for (int j = 0; j < gr[path[i]].size(); j++)\n {\n sh = min(sh, depth[gr[path[i]][j]]);\n }\n\n if (sh < depth[path[i+1]]) { res_x++; res_n++; continue; }\n\n int cnt = 0;\n for (int j = 0; j < gr[path[i]].size(); j++)\n {\n if (sh == depth[gr[path[i]][j]]) cnt++;\n }\n if (cnt > 1) res_x++;\n }\n cout << res_n << \" \" << res_x << endl;\n /**/\n}\n\nint main()\n{\n //cout << fixed << setprecision(6);\n //\n task_d();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f4fedd2d4d1579a527d5b47dc1083578", "src_uid": "19a0c05eb2d1559ccfe60e210c6fcd6a", "difficulty": null} {"lang": "GNU C++14", "source_code": " #include\n\n using namespace std;\n main()\n {\n int i,l,n,x,y;\n cin>>n >>x >>y;\n if(n==2)\n cout<<\"NO\";\n else if((n/x==2)&&(n/y==2))\n cout<<\"NO\";\n else\n cout<<\"YES\";", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d2cf8bc5a59a6839c6b6ddf548ea7ecf", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint main ()\n{\n int m, r, c;\n cin >> m >> r >> c;\n\n int n = m/2;\n vector> p;\n for (int i = 0; i < m; i++)\n {\n p.emplace_back(i + 1, n);\n p.emplace_back(i + 2, n);\n\n p.emplace_back(n, i + 1);\n p.emplace_back(n + 1, i + 1);\n }\n\n cout << (p.find(make_pair(r, c)) != p.end() ? \"YES\" : \"NO\") << \"\\n\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8d54e7a3ea83cf781c1db8e8935ead46", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nint main()\n{\n int n, x, y;\n \n scanf(\"%d %d %d\", &n, &x, &y);\n \n if((x==((n/2)+1) || x==((n/2)-1) || x==n/2) && (y==((n/2)+1) || y==((n/2)-1) \n || y==n/2)) printf(\"NO\\n\");\n \n else printf(\"YES\\n\");\n \n return 0;", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ba9f97110b5cbe873c840b2c7b2c328a", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#incldue \n\nusing namespace std;\n\nint main()\n{\n int n,a,b;\n cin >> n >> a >> b;\n if(n<=2||a==n/2&&b==n/2)\n cout << \"NO\" << endl;\n else\n cout << \"YES\" << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "542fc6c8f347a8fb560ff60768ecf944", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint digitSum(long long temp)\n{\n\tlong long sum=0;\n\twhile(n)\n\t{\n\t\tsum+=n%10;\n\t\tn/=10;\n\t}\n\treturn sum;\n}\nint main()\n{\n\tint n;\n\tcin>>n;\n\tlong long temp=19;\n\tfor(int i=1;i\nusing namespace std;\nint main()\n{\n int k;\n cin.tie(0);\n cin>>k;\n long l=19;\n k-=1;\n while(k)\n {\n if(k)\n {\n ++l;\n if(sum(l)==10)\n k--;\n }\n }\n cout<\nusing namespace std;\n\nint check(int n)\n{ int sum=0;\n\n while(n>1)\n {sum=sum+(n%10);\n n=n/10;\n }\n \n if(sum==10)\n return 1;\n else return 0;\n}\n\nint main()\n{ int k;\n cin>>k;\n \nint count=1;\n \n for(i=1;i<=1000000;i++)\n {if(check(i)&&count==k)\n {cout<\nusing namespace std;\nint k;\nint g[100][15];\nint pd[25];\nint dpt[1000000][15];\n\nvoid preprocess(){\n\n pd[0]=1;\n for(int i=1;i<20;i++)pd[i]=10*pd[i-1];\n\n for(int i=0;i<100;i++){g[i][0]=1;}\n for(int i=1;i<100;i++){\n for(int j=1;j<=10;j++){\n for(int r=0;r<=9;r++){\n g[i][j]+=g[i-1][j-r];\n }\n }\n }\n}\n\nint dp(int num,int rem){\n if(rem==0)return 1;\n int l=log10(num);\n if(l<0)return 0;\n int d=(num/pd[l]);\n int nn=num-(d*pd[l]);\n// cout<pos){\n r=mid;\n }else{\n l=mid+1;\n }\n }\n return l;\n}\n\n\nint main(){\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n preprocess();\n cin>>k;\n k--;1\n// cout<\n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long LL;\nconst int MAX = 1e5+10;\nconst int inf = 0x3f3f3f3f;\nint solve(string time, int orc) {\n int hh=0,mm=0;\n hh = 10*(time[0]-'0')+time[1]-'0';\n mm = 10*(time[3]-'0')+time[4]-'0';\n int tot = hh*60+mm+orc;\n if(tot%60/24<10) {\n printf(\"0%d:\",tot/60%24);\n }\n else{\n printf(\"%d:\",tot/60%24);\n }\n if(tot%60<10) {\n printf(\"0%d\\n\",tot%60);\n }\n else{\n printf(\"%d\\n\",tot%60);\n }\n return 0;\n\n}\nint main() {\n string str;\n int ptr;\n cin>>str;\n cin>>ptr;\n solve(str, ptr);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "79a029248d3cad8f1b45192c1241a893", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0} {"lang": "MS C++", "source_code": "#include \nusing namespace std;\nint main()\n{\n int hh,mm;\n char s;\n int a;\n cin >> hh >> s >> m;\n cin >> a;\n int h=0,m=0;\n if (a>=60)\n {\n h+=a/60;\n m+=a-h*60;\n }\n else\n m+=a;\n cout << hh+h << s << mm+m;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "38690d18a04687885f7a1de5090e31b1", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0} {"lang": "MS C++", "source_code": "#include \nusing namespace std;\n\ntypedef pair pii;\ntypedef complex point;\n\nconst double pi = acos(-1);\nconst int md = 1000 * 1000 * 1000 + 7;\nconst int o = 1000 * 1000 * 1000;\nconst int oo = o * o;\nconst double eps = 1e-7;\n\nstring s;\nint h, m;\nint p;\n\nmain() {\n\tslowdown;\n\tcin.tie(0);\n\n\tcin >> s;\n\tcin >> p;\n\th = (s[0] - '0') * 10 + (s[1] - '0');\n\tm = (s[3] - '0') * 10 + (s[4] - '0');\n\n\n\tm += p;\n\th += m / 60;\n\tm %= 60;\n\th %= 24;\n\n\tif(h < 10)\n\t\tcout << 0;\n\tcout << h << \":\";\n\tif (m < 10)\n\t\tcout << 0;\n\tcout << m << endl;\n\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a9ebcf6dc69fab8a3fac626a1ba752fd", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nvoid main()\n{\n\tint h; int m;\n\tint a;\n\tcin >> h >> m >> a;\n\ta += m;\n\th += (a / 60);\n\th = h % 24;\n\tm = a % 60;\n\tif (h < 10)\n\t{\n\t\tcout << 0 << h << \":\";\n\t}\n\telse\n\tcout << h << \":\";\n\tif (m < 10)\n\t\tcout << 0 << m;\n\telse\n\t\tcout << m;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0401cfbf65bf2bd730e0c3fbef8da480", "src_uid": "20c2d9da12d6b88f300977d74287a15d", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n\n#include \nusing namespace std;\n\nconst int N = 7;\nconst int MOD = (int)1e9 + 7;\n\nvoid add_to(int & a, int b)\n{\n\ta += b;\n\tif (a >= MOD)\n\t\ta -= MOD;\n}\n\nint mul(int a, int b)\n{\n\tlong long c = (long long)a * b;\n\treturn (int)(c % MOD);\n}\n\nstruct Matrix\n{\n\tint SZ;\n\tint a[1 << N][1 << N];\n\n\texplicit Matrix(int size, int e = 0) : a()\n\t{\n\t\tSZ = size;\n\t\tfor (int i = 0; i < SZ; i++)\n\t\t\ta[i][i] = e;\n\t}\n\n\tint * operator [] (int p)\n\t{\n\t\treturn a[p];\n\t}\n\n\tconst int * operator [] (int p) const\n\t{\n\t\treturn a[p];\n\t}\n\n\tMatrix operator * (const Matrix & b)\n\t{\n\t\tMatrix c(SZ);\n\t\tfor (int i = 0; i < SZ; i++)\n\t\t\tfor (int j = 0; j < SZ; j++)\n\t\t\t\tfor (int k = 0; k < SZ; k++)\n\t\t\t\t\tadd_to(c[i][j], mul(a[i][k], b[k][j]));\n\t\treturn c;\n\t}\n};\n\nMatrix bin_pow(Matrix a, int b)\n{\n\tMatrix c(a.SZ, 1);\n\twhile (b > 0)\n\t{\n\t\tif (b % 2 == 1)\n\t\t\tc = c * a;\n\t\ta = a * a;\n\t\tb /= 2;\n\t}\n\treturn c;\n}\n\nint width[N];\nint dp[1 << N];\nint loc[N + 1][2];\n\nbool bit(int a, int b)\n{\n\treturn (a & (1 << b)) != 0;\n}\n\nint get_ways(int lvl, int left, int right)\n{\n\tmemset(loc, 0, sizeof(loc));\n\tloc[0][1] = 1;\n\n\tfor (int i = 0; i < lvl; i++)\n\t\tfor (int j = 0; j < 2; j++)\n\t\t\tfor (int k = 0; k < 2; k++)\n\t\t\t{\n\t\t\t\tif (bit(left, i) && bit(right, i) && j == 1 && k == 1)\n\t\t\t\t\tcontinue;\n\t\t\t\tadd_to(loc[i + 1][k], loc[i][j]);\n\t\t\t}\n\n\treturn loc[lvl][1];\n}\n\nvoid solve()\n{\n\tfor (int i = 0; i < N; i++)\n\t\tscanf(\"%d\", &width[i]);\n\n\tdp[0] = 1;\n\tint prev_lvl = 0;\n\n\tfor (int lvl = 1; lvl <= N; lvl++)\n\t{\n\t\tif (width[lvl - 1] == 0)\n\t\t\tcontinue;\n\n\t\tMatrix vec(1 << lvl);\n\t\tfor (int mask = 0; mask < (1 << prev_lvl); mask++)\n\t\t{\n\t\t\tint new_mask = mask;\n\t\t\tfor (int i = prev_lvl; i < lvl; i++)\n\t\t\t\tnew_mask |= (1 << i);\n\t\t\tvec[0][new_mask] = dp[mask];\n\t\t}\n\n\t\tMatrix mat(1 << lvl);\n\t\tfor (int from = 0; from < (1 << lvl); from++)\n\t\t\tfor (int to = 0; to < (1 << lvl); to++)\n\t\t\t\tmat[from][to] = get_ways(lvl, from, to);\n\n\t\tmat = bin_pow(mat, width[lvl - 1]);\n\t\tvec = vec * mat;\n\t\tfor (int mask = 0; mask < (1 << lvl); mask++)\n\t\t\tdp[mask] = vec[0][mask];\n\n\t\tprev_lvl = lvl;\n\t}\n\n\tint ans = dp[(1 << prev_lvl) - 1];\n\tprintf(\"%d\\n\", ans);\n}\n\nint main()\n{\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif\n\n\tsolve();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "56f45359c7985b383ce2bd4cfdba8cb9", "src_uid": "a4bda63b95dc14185c47a08652fe41bd", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\ntypedef long long LL;\nconst int N = 1 << 7, M = (int)1e9 + 7;\nLL a[N][N], b[N][N], c[N][N];\nint S;\nvoid mul(LL x[S][S], LL y[S][S]) {\n\tfor (int i = 0; i < S; ++i)\n\t\tfor (int j = 0; j < S; ++j) {\n\t\t\tc[i][j] = 0ll;\n\t\t\tfor (int k = 0; k < S; ++k)\t(c[i][j] += x[i][k] * y[k][j]) %= M;\n\t\t}\n\tmemcpy(x, c, sizeof(c));\n}\nint main() {\n\tfor (int i = 0; i < (1 << 7); ++i)\ta[i][i] = 1;\t\n\tfor (int h = 1, w; h <= 7; ++h) {\n\t\tS = 1 << h;\n\t\tscanf(\"%d\", &w);\n\t\tfor (int i = 0; i < S; ++i)\n\t\t\tfor (int j = 0; j < S; ++j) {\n\t\t\t\tb[i][j] = 0;\n\t\t\t\tfor (int k = 0; k < (S >> 1); ++k) \n\t\t\t\t\tif ((i | j | k | (k << 1)) == ((1 << h) - 1))\t++b[i][j];\n\t\t\t}\n\t\tfor (; w; w >>= 1) {\n\t\t\tif (w & 1)\tmul(a, b);\n\t\t\tmul(b, b);\n\t\t}\n\t}\n\tprintf(\"%d\\n\", a[0][0]);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e466d28ebe0e24e7f50c7585b2e46d45", "src_uid": "a4bda63b95dc14185c47a08652fe41bd", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "//#include\n#include\n\nusing namespace std;\n\nconst int N = 2e5 + 10;\nconst ll mod = 1e9+7;\n\nstruct Matris{\n ll A[130][130]; //TODO\n ll n , m;\n Matris(){\n clr();\n }\n void clr(){\n memset(A,0,sizeof A);\n }\n ll* operator[](int x)\n {\n return A[x];\n }\n};\n\nMatris A;\nll w[10];\n\nMatris operator*( Matris a , Matris b )\n{\n Matris ans;\n ans.n = a.n; ans.m = b.m;\n for ( int i = 0 ; i < ans.n ; i++ )\n {\n for ( int j = 0 ; j < ans.m ; j++ )\n {\n for ( int k = 0 ; k < a.m ; k++ )\n {\n ans[i][j] += (1LL*a[i][k] * b[k][j])%mod;\n ans[i][j] %= mod;\n }\n }\n }\n return ans;\n}\n\nbool ok( int i , int j , int k )\n{\n for ( int t = 1 ; t <= 7 ; t++ )\n {\n if ( i % 2 == 1 && j % 2 == 1 && k % 2 == 1 && ( k / 2 ) % 2 == 1 )\n {\n return false;\n }\n i /= 2;\n j /= 2;\n k /= 2;\n }\n return true;\n}\n\nvoid make_mat( int K )\n{\n A.clr();\n for ( int i = ( 1 << 7 ) - ( 1 << K ) ; i < ( 1 << 7 ) ; i++ )\n {\n for ( int j = ( 1 << 7 ) - ( 1 << K ) ; j < ( 1 << 7 ) ; j++ )\n {\n for ( int k = 0 ; k < ( 1 << K ) ; k++ )\n {\n if ( ok( i , j , ( 1 << K ) + k ) && k % 2 == 1 )\n {\n A[i][j]++;\n //cout << i << \" \" << j << endl;\n }\n }\n }\n }\n}\n\nMatris powm( Matris a , int b )\n{\n Matris ans;\n ans.n = a.n; ans.m = a.m;\n for ( int i = 0 ; i < ( 1 << 7 ) ; i++ )\n {\n ans[i][i] = 1;\n }\n while( b )\n {\n if ( b & 1 )\n {\n ans = ans * a;\n }\n a = a * a;\n b /= 2;\n }\n return ans;\n}\n\nint main()\n{\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n for ( int i = 1 ; i <= 7 ; i++ ){ cin>>w[i]; }\n Matris B; B.n = 128; B.m = 1; B[127][0] = 1;\n A.n = ( 1 << 7 ); A.m = ( 1 << 7 );\n for ( int i = 1 ; i <= 7 ; i++ )\n {\n make_mat( i );\n B = powm( A , w[i] ) * B;\n }\n cout << B[127][0];\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "93bc22792bf60387809c26aa337c07ed", "src_uid": "a4bda63b95dc14185c47a08652fe41bd", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "// problem498E.cpp : Defines the entry point for the console application.\n//\n\n#include \n#include \n#include \n#include \n#include \n\ntypedef long long llong;\nconst llong prime = 1000000007;\nllong ans = 0;\nllong h[2][128][128];\n\n\nllong f[128], f_tmp[128];\nllong a1[128][128], b1[128][128];\nunsigned int widths[7];\nunsigned int curH = 1;\n\nvoid init();\nvoid updateMask(unsigned int aCurHeight);\nvoid mat_vec_Mult(unsigned int aCurH, unsigned int aPrevH);\nvoid mat_mat_Mult(unsigned int aCurH);\n\nint main()\n{\n\tinit();\n\tunsigned int prevH = 0;\n\n\tfor(unsigned int i = curH; i <= 7; ++ i)\n\t{\n\t\tif(widths[i - 1])\n\t\t{\n\t\t\tunsigned int w = widths[i-1] - 1;\n\t\t\tstd::memcpy(a1, &h[1][0][0], 128 * 128 * sizeof(llong));\n\t\t\tmat_vec_Mult(i, prevH);\n\t\t\tprevH = i;\n\t\t\tunsigned int mask = 1;\n\t\t\tfor(unsigned int j = w; j != 0; mask <<= 1)\n\t\t\t{\n\t\t\t\tif(mask & j)\n\t\t\t\t{\n\t\t\t\t\tmat_vec_Mult(i, i);\n\t\t\t\t\tj ^= mask;\n\t\t\t\t}\n\t\t\t\tmat_mat_Mult(i);\n\t\t\t}\n\t\t}\n\t\tif(i < 7)\n\t\t{\n\t\t\tupdateMask(i + 1);\t\t\n\t\t}\n\t}\n\n\tstd::cout<< f[(1 << prevH) - 1] << std::endl;\n\treturn 0;\n}\n\nvoid updateMask(unsigned int aCurHeight)\n{\n\tunsigned int diff = 1 << (aCurHeight - 1);\n\tfor(unsigned int i = 0; i < diff; ++ i)\n\t{\n\t\tfor(unsigned int j = 0; j < diff; ++ j)\n\t\t{\n\t\t\tllong t0 = h[0][i][j];\n\t\t\tllong t1 = h[1][i][j];\n\t\t\th[0][i][j] = h[0][i + diff][j] = h[0][i][j + diff] = h[1][i][j] = h[1][i][j + diff] = h[1][i + diff][j] = t0 + t1;\n\t\t\th[0][i + diff][j + diff] = t0 + t1;\n\t\t\th[1][i + diff][j + diff] = t0;\n\t\t}\n\t}\n}\n\nvoid init()\n{\n\tfor(unsigned int i = 0; i < 7; ++ i)\n\t{\n\t\tstd::cin >> widths[i];\n\t}\n\tmemset(h, 0, 128 * 128 * 2 * sizeof(llong));\n\th[0][0][0] = h[0][0][1] = h[0][1][0] = h[1][0][0] = h[1][0][1] = h[1][1][0] = h[0][1][1] = 1;\n\th[1][1][1] = 0;\n\tmemset(a1, 0, 128 * 128 * sizeof(llong));\n\tmemset(b1, 0, 128 * 128 * sizeof(llong));\n\tmemset(f, 0, 128 * sizeof(llong));\n\tmemset(f_tmp, 0, 128 * sizeof(llong));\n\n\tfor(unsigned int i = 1; widths[i - 1] == 0; ++ i)\n\t{\n\n\t\tcurH ++;\n\t\tupdateMask(i + 1);\n\t}\n\n\tf[0] = 1;\n}\n\nvoid mat_mat_Mult(unsigned int aCurH)\n{\n\tunsigned int ceil = 1 << aCurH;\n\tfor(unsigned int i1 = 0; i1 < ceil; ++ i1)\n\t{\n\t\tfor(unsigned int i2 = 0; i2 < ceil; ++ i2)\n\t\t{\n\t\t\tllong val = 0;\n\t\t\tfor(unsigned int i3 = 0; i3 < ceil; ++ i3)\n\t\t\t{\n\t\t\t\t val = (val + a1[i1][i3] * a1[i2][i3]) % prime;\n\t\t\t}\n\n\t\t\tb1[i1][i2] = val;\n\t\t}\n\t}\n\tstd::memcpy(a1, b1, sizeof(llong) * 128 * 128);\n}\n\nvoid mat_vec_Mult(unsigned int aCurH, unsigned int aPrevH)\n{\n\tunsigned int n1 = 1 << aCurH ;\n\tunsigned int n2 = 1 << aPrevH;\n\tunsigned int mask = (n1 - 1) ^ (n2 - 1);\n\t\n\tfor(unsigned int i1 = 0; i1 < n1; ++ i1)\n\t{\n\t\tllong val = 0;\n\t\tfor(unsigned int i2 = 0; i2 < n2; ++ i2)\n\t\t{\n\t\t\tval = (val + f[i2] * a1[i1][i2 | mask]) % prime;\n\t\t}\n\t\tf_tmp[i1] = val % prime;\n\t}\n\tstd::memcpy(f, f_tmp, sizeof(llong) * 128);\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5b15987a65a38498bf8659f6c2114eb1", "src_uid": "a4bda63b95dc14185c47a08652fe41bd", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize (\"Ofast\")\n#pragma GCC target(\"popcnt,abm,mmx,sse,sse2,sse3,ssse3,sse4,avx,avx2\")\n\n#include\n#define MAXN 100005\n#define INF 1000000000\n#define MOD 998244353\n#define F first\n#define S second\nusing namespace std;\ntypedef long long ll;\ntypedef pair P;\nint n,k;\nconst double PI=acos(-1.0);\nnamespace fft\n{\n struct num\n {\n double x,y;\n num() {x=y=0;}\n num(double x,double y):x(x),y(y){}\n };\n inline num operator+(num a,num b) {return num(a.x+b.x,a.y+b.y);}\n inline num operator-(num a,num b) {return num(a.x-b.x,a.y-b.y);}\n inline num operator*(num a,num b) {return num(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x);}\n inline num conj(num a) {return num(a.x,-a.y);}\n\n int base=1;\n vector roots={{0,0},{1,0}};\n vector rev={0,1};\n const double PI=acosl(-1.0);\n\n void ensure_base(int nbase)\n {\n if(nbase<=base) return;\n rev.resize(1<>1]>>1)+((i&1)<<(nbase-1));\n roots.resize(1< &a,int n=-1)\n {\n if(n==-1) n=a.size();\n assert((n&(n-1))==0);\n int zeros=__builtin_ctz(n);\n ensure_base(zeros);\n int shift=base-zeros;\n for(int i=0;i>shift))\n swap(a[i],a[rev[i]>>shift]);\n for(int k=1;k fa,fb;\n \n vector multiply(vector &a, vector &b)\n {\n int need=a.size()+b.size()-1;\n int nbase=0;\n while((1<(int)fa.size()) fa.resize(sz);\n for(int i=0;i>1);i++)\n {\n int j=(sz-i)&(sz-1);\n num z=(fa[j]*fa[j]-conj(fa[i]*fa[i]))*r;\n if(i!=j) fa[j]=(fa[i]*fa[i]-conj(fa[j]*fa[j]))*r;\n fa[i]=z;\n }\n fft(fa,sz);\n vector res(need);\n for(int i=0;i multiply_mod(vector &a,vector &b,int m,int eq=0)\n {\n int need=a.size()+b.size()-1;\n int nbase=0;\n while((1<(int)fa.size()) fa.resize(sz);\n for(int i=0;i<(int)a.size();i++)\n {\n int x=(a[i]%m+m)%m;\n fa[i]=num(x&((1<<15)-1),x>>15);\n }\n fill(fa.begin()+a.size(),fa.begin()+sz,num{0,0});\n fft(fa,sz);\n if(sz>(int)fb.size()) fb.resize(sz);\n if(eq) copy(fa.begin(),fa.begin()+sz,fb.begin());\n else\n {\n for(int i=0;i<(int)b.size();i++)\n {\n int x=(b[i]%m+m)%m;\n fb[i]=num(x&((1<<15)-1),x>>15);\n }\n fill(fb.begin()+b.size(),fb.begin()+sz,num{0,0});\n fft(fb,sz);\n }\n double ratio=0.25/sz;\n num r2(0,-1),r3(ratio,0),r4(0,-ratio),r5(0,1);\n for(int i=0;i<=(sz>>1);i++)\n {\n int j=(sz-i)&(sz-1);\n num a1=(fa[i]+conj(fa[j]));\n num a2=(fa[i]-conj(fa[j]))*r2;\n num b1=(fb[i]+conj(fb[j]))*r3;\n num b2=(fb[i]-conj(fb[j]))*r4;\n if(i!=j)\n {\n num c1=(fa[j]+conj(fa[i]));\n num c2=(fa[j]-conj(fa[i]))*r2;\n num d1=(fb[j]+conj(fb[i]))*r3;\n num d2=(fb[j]-conj(fb[i]))*r4;\n fa[i]=c1*d1+c2*d2*r5;\n fb[i]=c1*d2+c2*d1;\n }\n fa[j]=a1*b1+a2*b2*r5;\n fb[j]=a1*b2+a2*b1;\n }\n fft(fa,sz);fft(fb,sz);\n vector res(need);\n for(int i=0;i square_mod(vector &a,int m)\n {\n return multiply_mod(a,a,m,1);\n }\n};\nvector v;\nint main()\n{\n scanf(\"%d%d\",&n,&k);\n v.resize(10,0);\n for(int i=0;i ans;\n ans.push_back(1);\n int p=n/2;\n while(p)\n {\n if(p&1) ans=fft::multiply_mod(ans,v,MOD);\n p>>=1;\n if(!p)break;\n v=fft::square_mod(v,MOD);\n }\n int res=0;\n for(auto t:ans) res=(res+1LL*t*t)%MOD;\n printf(\"%d\\n\",res);\n return 0;\n}\n#include\n#define MAXN 100005\n#define INF 1000000000\n#define MOD 998244353\n#define F first\n#define S second\nusing namespace std;\ntypedef long long ll;\ntypedef pair P;\nint n,k;\nconst double PI=acos(-1.0);\nnamespace fft\n{\n struct num\n {\n double x,y;\n num() {x=y=0;}\n num(double x,double y):x(x),y(y){}\n };\n inline num operator+(num a,num b) {return num(a.x+b.x,a.y+b.y);}\n inline num operator-(num a,num b) {return num(a.x-b.x,a.y-b.y);}\n inline num operator*(num a,num b) {return num(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x);}\n inline num conj(num a) {return num(a.x,-a.y);}\n\n int base=1;\n vector roots={{0,0},{1,0}};\n vector rev={0,1};\n const double PI=acosl(-1.0);\n\n void ensure_base(int nbase)\n {\n if(nbase<=base) return;\n rev.resize(1<>1]>>1)+((i&1)<<(nbase-1));\n roots.resize(1< &a,int n=-1)\n {\n if(n==-1) n=a.size();\n assert((n&(n-1))==0);\n int zeros=__builtin_ctz(n);\n ensure_base(zeros);\n int shift=base-zeros;\n for(int i=0;i>shift))\n swap(a[i],a[rev[i]>>shift]);\n for(int k=1;k fa,fb;\n \n vector multiply(vector &a, vector &b)\n {\n int need=a.size()+b.size()-1;\n int nbase=0;\n while((1<(int)fa.size()) fa.resize(sz);\n for(int i=0;i>1);i++)\n {\n int j=(sz-i)&(sz-1);\n num z=(fa[j]*fa[j]-conj(fa[i]*fa[i]))*r;\n if(i!=j) fa[j]=(fa[i]*fa[i]-conj(fa[j]*fa[j]))*r;\n fa[i]=z;\n }\n fft(fa,sz);\n vector res(need);\n for(int i=0;i multiply_mod(vector &a,vector &b,int m,int eq=0)\n {\n int need=a.size()+b.size()-1;\n int nbase=0;\n while((1<(int)fa.size()) fa.resize(sz);\n for(int i=0;i<(int)a.size();i++)\n {\n int x=(a[i]%m+m)%m;\n fa[i]=num(x&((1<<15)-1),x>>15);\n }\n fill(fa.begin()+a.size(),fa.begin()+sz,num{0,0});\n fft(fa,sz);\n if(sz>(int)fb.size()) fb.resize(sz);\n if(eq) copy(fa.begin(),fa.begin()+sz,fb.begin());\n else\n {\n for(int i=0;i<(int)b.size();i++)\n {\n int x=(b[i]%m+m)%m;\n fb[i]=num(x&((1<<15)-1),x>>15);\n }\n fill(fb.begin()+b.size(),fb.begin()+sz,num{0,0});\n fft(fb,sz);\n }\n double ratio=0.25/sz;\n num r2(0,-1),r3(ratio,0),r4(0,-ratio),r5(0,1);\n for(int i=0;i<=(sz>>1);i++)\n {\n int j=(sz-i)&(sz-1);\n num a1=(fa[i]+conj(fa[j]));\n num a2=(fa[i]-conj(fa[j]))*r2;\n num b1=(fb[i]+conj(fb[j]))*r3;\n num b2=(fb[i]-conj(fb[j]))*r4;\n if(i!=j)\n {\n num c1=(fa[j]+conj(fa[i]));\n num c2=(fa[j]-conj(fa[i]))*r2;\n num d1=(fb[j]+conj(fb[i]))*r3;\n num d2=(fb[j]-conj(fb[i]))*r4;\n fa[i]=c1*d1+c2*d2*r5;\n fb[i]=c1*d2+c2*d1;\n }\n fa[j]=a1*b1+a2*b2*r5;\n fb[j]=a1*b2+a2*b1;\n }\n fft(fa,sz);fft(fb,sz);\n vector res(need);\n for(int i=0;i square_mod(vector &a,int m)\n {\n return multiply_mod(a,a,m,1);\n }\n};\nvector v;\nint main()\n{\n scanf(\"%d%d\",&n,&k);\n v.resize(10,0);\n for(int i=0;i ans;\n ans.push_back(1);\n int p=n/2;\n while(p)\n {\n if(p&1) ans=fft::multiply_mod(ans,v,MOD);\n p>>=1;\n if(!p)break;\n v=fft::square_mod(v,MOD);\n }\n int res=0;\n for(auto t:ans) res=(res+1LL*t*t)%MOD;\n printf(\"%d\\n\",res);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1c6cc046c19036919299a4182977ac88", "src_uid": "279f1f7d250a4be6406c6c7bfc818bbf", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define re register int\n#define F(x,y,z) for(re x=y;x<=z;x++)\n#define FOR(x,y,z) for(re x=y;x>=z;x--)\ntypedef long long ll;\n#define I inline void\n#define IN inline int\n#define C(x,y) memset(x,y,sizeof(x))\n#define STS system(\"pause\")\ntemplateI read(D &res){\n\tres=0;register D g=1;register char ch=getchar();\n\twhile(!isdigit(ch)){\n\t\tif(ch=='-')g=-1;\n\t\tch=getchar();\n\t}\n\twhile(isdigit(ch)){\n\t\tres=(res<<3)+(res<<1)+(ch^48);\n\t\tch=getchar();\n\t}\n\tres*=g;\n}\nconst int Mod=998244353,N=(1<<22)+10;\nint r[N];\nIN Pow(int x,int y=Mod-2){\n\tre res=1;\n\twhile(y){\n\t\tif(y&1)res=(ll)res*x%Mod;\n\t\tx=(ll)x*x%Mod;\n\t\ty>>=1;\n\t}\n\treturn res;\n}\nI add(int &x,int y){(x+=y)>=Mod?x-=Mod:0;}\nIN Plus(int x,int y){(x+=y)>=Mod?x-=Mod:0;return x;}\nI ntt(int *f,int S,int sn){\n\tF(i,0,S-1)if(i>1]>>1)|((i&1)<<(len-1));\n\tF(i,0,lim-1)f[i]=g[i]=0;\n\tF(i,0,lena-1)f[i]=a[i];F(i,0,lenb-1)g[i]=b[i];\n\tntt(f,lim,1);ntt(g,lim,1);F(i,0,lim-1)f[i]=(ll)f[i]*g[i]%Mod;\n\tntt(f,lim,-1);F(i,0,lenc-1)c[i]=f[i];F(i,lenc,lim-1)c[i]=0;\n}\nint n,m,k,W,ans,a[N],b[N],la,lb;\nint main(){\n\tread(n);read(k);n>>=1;\n\tF(i,1,k)read(W),a[W]=1;\n\tb[0]=1;la=10;lb=1;\n\twhile(n){\n\t\tif(n&1)mul(la,a,lb,b,la+lb,b),lb+=la;\n\t\tmul(la,a,la,a,la<<1,a),la<<=1;\n\t\tn>>=1;\n\t}\n//\tcout<\n#include \nusing namespace std;\nusing namespace __gnu_pbds;\n \n \n \n#define int long long\n#define ll long long\n#define vi vector \n#define vii vector >\n#define rep(i,a,b) for (int i=a;ib;i--)\n#define pb push_back\n#define pii pair \n#define ff first\n#define ss second\n#define all(a) a.begin(),a.end()\n#define MOD 1000000007\n//#define PI 3.14159265359\ntypedef tree,rb_tree_tag, tree_order_statistics_node_update> ordered_set;\n \n#define deb(...) {...}\n#ifndef local\n\t#define deb(...) ;\n#endif\n \n \n///----------------------------------------------------------------------------------\n \nint n,k;\nconst int mod = 998244353; /// prime\nconst int root = 565042129; /// root^n = 1 mod prime\nconst int root_1 = 950391366; /// root inverse\nconst int root_pw = 1 << 20; /// n (max degree of polynomial)\n\n/*inline int add(int A, int B)\n{\n\tif (A+B>=mod)return A+B-mod;\n\treturn A+B;\n}\n\ninline int mul(int A, int B)\n{\n\tif (A*B0)\n {\n if (y&1)res=mul(res,x);\n y/=2;x=mul(x,x);\n }\n return res;\n}\nvoid fft(vector & a, bool invert) {\n int n = a.size();\n\n for (int i = 1, j = 0; i < n; i++) {\n int bit = n >> 1;\n for (; j & bit; bit >>= 1)\n j ^= bit;\n j ^= bit;\n\n if (i < j)\n swap(a[i], a[j]);\n }\n\n for (int len = 2; len <= n; len <<= 1) {\n int wlen = invert ? root_1 : root;\n for (int i = len; i < root_pw; i <<= 1)\n wlen = mul(wlen,wlen);\n\n for (int i = 0; i < n; i += len) {\n int w = 1;\n for (int j = 0; j < len / 2; j++) {\n int u = a[i+j], \n v = mul(a[i+j+len/2] , w);\n a[i+j] = u + v < mod ? u + v : u + v - mod;\n a[i+j+len/2] = u - v >= 0 ? u - v : u - v + mod;\n w=mul(w,wlen);\n }\n }\n }\n\n if (invert) {\n int n_1 = expo(n, mod-2, mod);\n for (int & x : a)\n x=mul(x,n_1);\n }\n}\n\nvector mul(const vector &a,const vector &b)\n{\n vector fa(a.begin(), a.end()),fb(b.begin(), b.end());\n int n=1;\n while(n res;\n for(int i=0;i expo(vector A,int y)\n{\n vector res={1};\n while(y>0)\n {\n if (y&1)res = mul(res,A);\n y/=2;\n A=mul(A,A);\n }\n return res;\n}\n\nvoid solve()\n{\n\tcin>>n>>k;\n\tvi A(10,0);\n\twhile(k--)\n\t{\n\t\tint temp;cin>>temp;A[temp]++;\n\t}\n\t\n\tA=expo(A,n/2);\n\tint ans=0;\n\tfor (auto x:A)ans=add(ans,mul(x,x));\n\tcout<>t;\n \n rep(a,0,t)\n {\n ///cout<<\"Case #\"<\n#include \n#include \n\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC optimize(\"unroll-loops\")\n#pragma GCC target(\"avx,avx2,fma\")\n\n#define fi first\n#define se second\n#define ll long long\n#define ld long double\n#define all(x) (x).begin(), (x).end()\n#define inf 1e18\n\nusing namespace std;\nusing namespace __gnu_pbds;\n\ntemplate \nusing ordered_set = tree , rb_tree_tag, tree_order_statistics_node_update>;\n\nconst ll mod = 998244353;\nconst ll root = 15311432;\nconst ll rootI = 469870224;\nconst ll pw = 1 << 23;\n\nll w[2][pw];\n\nll bp(ll a, ll n) {\n ll res = 1;\n while (n) {\n if (n & 1) res *= a, res %= mod;\n a *= a, a %= mod;\n n >>= 1;\n }\n return res;\n}\n\ninline ll mul(ll a, ll b) { return ((a * b) % mod); }\n\ninline void fft(vector &ar, bool inv) {\n if (ar.size() == 1) return;\n\n int n = ar.size();\n for (int i = 1, j = 0; i < n; i++) {\n int bit = n >> 1;\n for (; j & bit; bit >>= 1)\n j ^= bit;\n j ^= bit;\n if (i < j) swap(ar[i], ar[j]);\n }\n\n for (int len = 2; len <= n; len <<= 1) {\n int step = pw / len - 1;\n for (int i = 0; i < n; i += len) {\n ll w = 1;\n for (int j = 0; j < len / 2; ++j) {\n ll a = ar[i + j], b = mul(ar[i + j + (len / 2)], w[inv][j * step]);\n ar[i + j] = ((a + b < mod) ? (a + b) : (a + b - mod));\n ar[i + j + (len / 2)] = ((a - b >= 0) ? (a - b) : (a - b + mod));\n }\n }\n }\n if (inv) {\n ll cur = bp(n, mod - 2);\n for (auto &i : ar) i = mul(i, cur);\n }\n}\n\ninline ll get(ll a) {\n if (a == 1 || !(a & (a - 1))) return a;\n return (1LL << (64 - __builtin_clzll(a - 1)));\n}\n\ninline void mult(vector &a, vector b) {\n int sz = 2 * max(get(a.size()), get(b.size()));\n while (a.size() < sz) a.push_back(0);\n while (b.size() < sz) b.push_back(0);\n\n fft(a, 0); fft(b, 0);\n for (int i = 0; i < a.size(); ++i) a[i] = mul(a[i], b[i]);\n\n fft(a, 1);\n while (a.back() == 0) a.pop_back();\n}\n\nvoid solve() {\n int n, k;\n cin >> n >> k;\n vector ar(10);\n for (int i = 0; i < k; ++i) {\n int x;\n cin >> x; ar[x] = 1;\n }\n\n w[0][0] = 1; w[1][0] = 1;\n for (int i = 1; i < pw; ++i) {\n w[0][i] = mul(w[0][i - 1], root);\n w[1][i] = mul(w[1][i - 1], rootI);\n }\n\n n >>= 1;\n vector res(10); res[0] = 1;\n while (n) {\n if (n & 1) mult(res, ar);\n mult(ar, ar);\n n >>= 1;\n }\n\n ll ans = 0; swap(ar, res);\n for (int i = 0; i < ar.size(); ++i) {\n ans += mul(ar[i], ar[i]);\n if (ans >= mod) ans -= mod;\n }\n cout << ans;\n}\n\nint main() {\n ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n// freopen(\"input.txt\", \"r\", stdin);\n// freopen(\"output.txt\", \"w\", stdout);\n int q = 1; // cin >> q;\n while (q--) {\n solve();\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5ac6427b3484551952bf41bf5a1517c9", "src_uid": "279f1f7d250a4be6406c6c7bfc818bbf", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n\nusing namespace std;\n\nlong long sum(long long n)\n{\n long long res=0;\n while (n>0)\n {\n res+=n%10;\n n/=10;\n }\n return res;\n}\n\n\n\nint main()\n{\n\tlong long n,x,d,b,y;\n\tcin >> n;\n\tx = -1;\n\tfor(b = 1; b < 91; b++)\n\t{\n\t\td = long(sqrt(b * b - 4* n);\n\t\ty = (d - b) / 2;\n\t\tif ( sum(y) == b)\n\t\t{\n\t\t\tx = y;\n\t\t\tbreak;\n\t\t}\n\t}\n\tcout << x;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "feedabc3902f9d2a880285afed096810", "src_uid": "e1070ad4383f27399d31b8d0e87def59", "difficulty": 1400.0} {"lang": "MS C++", "source_code": "\n//x(x + s(x)) = n\n\n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long int64;\n\nconst int64 oo = 1LL << 60;\n\nint64 sLen(int64 n) {\n int64 res = 0;\n while (n) {\n res += n % 10;\n n /= 10;\n }\n return res;\n}\n\nint main() {\n long long n; cin >> n;\n \n\n int64 ans = oo;\n for (int i = 0; i <= 90; i++) {\n int b = i;\n // x^2 + s(x) * x = n\n int del = b * b - 4 * 1 * (-n);\n if (del < 0) continue;\n else {\n int64 t = (int64)sqrt((double) del);\n if (t * t == del) {\n int64 x1 = (-b + t) / 2;\n int64 x2 = (-b - t) / 2;\n if (x1 > 0 && sLen(x1) == i) {\n ans = min (ans, x1);\n }\n if (x2 > 0 && sLen(x2) == i) {\n ans = min (ans, x2);\n }\n }\n }\n }\n if (ans == oo) cout << -1 << endl;\n else cout << ans << endl;\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "327fbe7b5e4e0647db7c93a860dd17b7", "src_uid": "e1070ad4383f27399d31b8d0e87def59", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\nlong long n;\nlong long check(long long m)\n{\n long long sum = 0, k, cp;\n cp = m;\n while (m)\n {\n k = m % 10;\n sum += k;\n m /= 10;\n }\n return (cp * cp + sum * cp - n);\n}\n \nint main()\n{\n long long l, r, m, kk;\n cin >> n;\n l = 0;\n r = 10000000000.0;\n if (n < 1000000)\n for(long long i = 0; i < 20000; i++)\n {\n if (check(i) == 0)\n {\n cout << i;\n return 0;\n }\n }\n else { \n while (l <= r)\n {\n m = l + (r - l)/2 +1;\n kk = check(m);\n if (kk < 0)\n l = m + 1;\n else if (kk > 0)\n r = m;\n else if (!kk)\n {\n cout << m;\n return 0;\n }\n //cout <\nusing namespace std;\n\n/* MIGHT BE OF USE\n\n\n#define si(x)\tscanf(\"%d\",&x)\n#define pi(x)\tprintf(\"%d\\n\",x)\n\ntypedef pair\tpii;\ntypedef vector\t\tvi;\ntypedef vector\t\tvpii;\n*/\n\n\n#define fo(i,a,b) for(i=a;i>s\n#define ps(s)\tcout<\tpl;\ntypedef vector\t\tvl;\ntypedef vector\t\tvpl;\ntypedef vector\tvs;\n\nll gcd(ll a, ll b)\n{\n if(b==0)\n return a;\n a%=b;\n return gcd(b,a);\n}\n\n\nll sod (ll num)\n{\n ll sum=0;\n while(num)\n {\n sum += num%10;\n num /= 10;\n }\n return sum;\n}\n\n\n\nvoid solve()\n{\n //freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n ll i, j, n, m;\n cin>>n;\n i = n/2;\n ll lowerLimit = sqrt(i);\n\n ll upperLimit = sqrt(n);\n\n x=upperLimit;\n\n while(((x*x) + (sod(x)*x) != n)&&(x>=lowerLimit))\n x--;\n\n if((x*x) + (sod(x)*x) != n)\n cout<<-1;\n else\n cout<\n#include\n#include\nint main(){\n int n;\n cin>>n;\n vector a;\n int m;\n for(int i=0;i>m;\n a.push_back(m);\n }\n sort(a.begin,a.end());\n \n for(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#if LOCAL\n\t#define DO_NOT_SEND\n#endif\n\ntypedef long long LL;\n\nint IntMaxVal = (int) 1e20;\nint IntMinVal = (int) -1e20;\nLL LongMaxVal = (LL) 1e20;\nLL LongMinVal = (LL) -1e20;\n\n#define FOR(i, a, b) for(int i = a; i < b ; ++i)\n#define FORD(i, a, b) for(int i = a; i >= b; --i)\n\n#define minimize(a, b) { a = min(a, b); }\n#define maximize(a, b) { a = max(a, b); }\n\n#define all(v) v.begin(),v.end()\n\nusing namespace std;\n\n#define next(type, i) type i; cin >> i;\ntemplate struct argument_type;\ntemplate struct argument_type { typedef U type; };\n#define nextVector(t, v, size) vector< argument_type::type > v(size); { for (int i = 0 ; i < size ; i++) cin >> v[i]; }\n\ntemplate \nistream& operator >>(istream& is, pair& s) \n{\n is >> s.first >> s.second;\n return is;\n}\n\nint main() {\n\tsrand (time(NULL));\n ios_base::sync_with_stdio(false);\n \n next(int, n);\n\tnextVector(int, a, n);\n\t\n\tsort(all(a));\n\tfor (auto x : a) cout << a << ' ';\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1dcacd5f30993c994f59840c7d199fcb", "src_uid": "ae20712265d4adf293e75d016b4b82d8", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n \nint main() {\n\tint n,ele;\n\tcin>>n;\n\tint arr[n-1];\n\tfor(int i=0;i>ele;\n\t\tarr[i]=ele;\n\t}\n\tsort(arr,arr+n);\n\tfor(int i=0;i\nusing namespace std;\nint main(){\n int n, temp=0;cin>>n;\n while(n--){\n int a[n];cin<a[i];\n temp=a[i];\n s+=temp +\" \";\n }\n }\n cout<> cha;\n\t\t\tif (cha == '#')\n\t\t\t\tnumbers[i][j] = 1;\n\t\t\telse\n\t\t\t\tnumbers[i][j] = 0;\n\t\t}\n\t}\n\tfor (int i = 0; i < 3; i++)\n\t{\n\t\tfor (int j = 0; j < 3; j++)\n\t\t{\n\t\t\tif (test(i, j))\n\t\t\t{\n\t\t\t\tcout << yes;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\tcout << no;\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5622523899baa77529473616f4611e0a", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef pair pll;\n#define DrSlidez ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);\n#define Files freopen(\"input.txt\",\"r\",stdin); freopen(\"output.txt\",\"w\",stdout);\n#define pi 3.14159265\n#define mod 1000000007\n#define pb push_back\n#define INF LONG_LONG_MAX\n#define sz 105\n\nint cnt, m = 4, n = 4, \nqurater[4][3][2] = { {-1, -1}, {-1, 0}, {0, -1},\n \t\t\t\t\t{0, -1}, {1, -1}, {1, 0},\n\t\t\t\t\t{-1, 0}, {-1, 1}, {0, 1},\n\t\t\t\t\t{0, 1}, {1, 0}, {1, 1} };\n\nbool val(int x, int y)\n{\n\treturn ((x > -1) && (x < m) &&\n\t\t(y > -1) && (y < n));\n}\n\nint main()\n{\n\tDrSlidez\n\tchar arr[4][4];\n\tfor (int i = 0; i < 4; i++)\n\t\tfor (int j = 0; j < 4; j++)\n\t\t\tcin >> arr[i][j];\n\t\n\tfor (int i = 0; i < 4; i++)\n\t{\n\t\tfor (int j = 0; j < 4; j++)\n\t\t{\n\t\t\tfor (int k = 0; k < 4; k++)\n\t\t\t{\n\t\t\t\tcnt = 0;\n\t\t\t\tfor\t(int h = 0; h < 3; h++)\n\t\t\t\t\tif (val(i + sur[k][h][0], j + sur[k][h][1]) && arr[i + sur[k][h][0]][j + sur[k][h][1]] == '#')\n\t\t\t\t\t\tcnt++;\n\t\t\t\tif (cnt >= 3)\n\t\t\t\t\treturn cout << \"YES\", 0;\n\t\t\t}\n\t\t}\n\t}\n\tcout << \"NO\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "237bfa37df94009de06204ef15186bb1", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include\uff1cstdio.h\uff1e\nint main\uff08\uff09\n\uff5b\nchar[4][4];\nwhile\uff08scanf\uff08\uff02%s\uff02,a[0]\uff09\uff01=EOF\uff09\n\uff5b\nscanf\uff08\uff02%s%s%s\uff02\uff0ca[1]\uff0ca[1]\uff0ca[2]\uff09\uff1b\nint i\uff0cp=0\uff1b\nfor\uff08i=0\uff1bi\uff1c=2\uff1bi++\uff09\n\uff5b\nfor\uff08int j=0\uff1bj\uff1c=2\uff1bj++\uff09\n\uff5b\nif\uff08a[i][j]==a[i][j+1]&&\uff08a[i][j]==a[i+1][j]||a[i][j]===a[i+1][j+1])\uff1b\n\uff5bprintf\uff08\"YES\\n\uff02\uff09\uff1bp=1\uff1bbreak\uff1b\n\uff5d\nif\uff08a[i][j+1]==a[i+1]&&a[i][j+1]==a[i+1][j+1]\uff09\n\uff5bprintf\uff08\"YES\\n\uff09\uff1bp=1\uff1bbreak\n\uff1b\n\uff5d\n\uff5d\nif\uff08p==1)\nbreak\uff1b\n\uff5d\n}\nif\uff08p==0)\nprintf(\"NO\\n\")\uff1b\n}\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cca937a24f22564bf0a18703d48d4fcb", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "/shivi..coding is adictive!!\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n char arr[4][4];\n for(int i=0;i<4;++i)\n for(int j=0;j<4;++j)\n cin>>arr[i][j];\n \n for(int i=0;i<4;++i)\n {\n for(int j=0;j<4;++j)\n {\n if(arr[i][j]=='.' && i-1>=0 && j-1>=0 && arr[i-1][j]=='#' && arr[i-1][j-1]=='#' && arr[i][j-1]=='#')\n {cout<<\"YES\";return 0;}\n if(arr[i][j]=='#' && i-1>=0 && j-1>=0 && arr[i-1][j]=='.' && arr[i-1][j-1]=='.' && arr[i][j-1]=='.')\n {cout<<\"YES\";return 0;}\n if(arr[i][j]=='#' && i-1>=0 && j-1>=0 && arr[i-1][j]=='#' && arr[i-1][j-1]=='#' && arr[i][j-1]=='#')\n {cout<<\"YES\";return 0;}\n if(arr[i][j]=='.' && i-1>=0 && j-1>=0 && arr[i-1][j]=='.' && arr[i-1][j-1]=='.' && arr[i][j-1]=='.')\n {cout<<\"YES\";return 0;}\n }\n }\n \n \n \n cout<<\"NO\";\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d89a4b0a182459dba4c2923b20611f8f", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint main()\n{\n long long int n,t,sum=0;\n cin>>n;\n bool f=true;\n string str;\n while(n--)\n {\n cin>>t>>str;\n if(str[0]=='N')sum-=t;\n else if(str[0]=='S')sum+=t;\n if((sum<0||sum>20000)||(sum==20000&&str[i]!='N'))f=false;\n cout<\n#include\nchar n[1000];\nint i,j,k;\nint N=0,S=0;\nint leght=0;\nbool check1=1,check2=1;\nint main()\n{\n scanf(\"%d\",&k);\n for(i=1;i<=k;i++)\n {\n\n scanf(\"%d%s\",&j,n);\n if(leght%40000==20000) if(n[0]!='N') {check1=0;}\n if(leght%40000==0) if(n[0]!='S') {check2=0;}\n if(n[0]=='N') leght-=j;\n if(n[0]=='S') leght+=j;\n }\n if(leght==0&&check1==1&&check2==1;) printf(\"YES\");\n else printf(\"NO\");\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "25db7c59199326f0cc1d78fa4045cc75", "src_uid": "11ac96a9daa97ae1900f123be921e517", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int n ,tmp, vertical ,position;\n string dir;\n for(int i=0;i>tmp;\n cin>>dir;\n switch(dir){\n case \"South\" :position = position+ dir;\n break;\n case \"North\" : position = position- dir;\n break;\n }\n if(position>4000 ||position<0){\n cout<<\"NO\";\n break;\n }\n }\n cout<<\"YES\"\n cout << \"Hello world!\" << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "95bc10fdef7b525f88819dca90e277bb", "src_uid": "11ac96a9daa97ae1900f123be921e517", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nint n, m, a;\nstring s;\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cin >> n;\n for(int i = 0 ; i < n ; ++ i) {\n cin >> m >> s;\n if(a == 0 && s[0] != 'S') {\n cout << \"NO\" << endl;\n return 0;\n }\n if(a == 20000 && s[0] != 'N') {\n cout << \"NO\" << endl;\n return 0;\n }\n if(s[0] == 'N')\n a -= m;\n else\n if(s[0] == 'S') \n \ta += m;\n }\n if(a > 20000 && a < 0) {\n cout << \"NO\" << endl;\n return 0;\n }\n \n }\n if(!a)\n cout << \"YES\" << endl;\n else\n cout << \"NO\" << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cbf4e0063bf443aee3b3ecbe7285f818", "src_uid": "11ac96a9daa97ae1900f123be921e517", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include \nusing namespace std;\nint main() { \n\u00a0\u00a0 int i,b[105],t; \n\u00a0\u00a0 char a[105]; \n\u00a0\u00a0 t=0; cin>>a; \n\u00a0\u00a0 for (i=0;(int)a[i]>0;i++){\nb[i]=int(a[i])-96;\n} \n\u00a0\u00a0 b[i]=0; for (i=0;a[i+1]>0;i++){ \n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (abs(b[i]-b[i+1])<13){ \n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 t=t+abs(b[i]-b[i+1]); \n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 } \n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 else{ t=t+(26-abs(b[i]-b[i+1]));\n}\n} \n\u00a0\u00a0 if (abs(b[0]-1)<13){ t=t+abs(b[0]-1);\n} \n\u00a0\u00a0 else{ t=t+(26-abs(b[0]-1));\n}\ncout<\nusing namespace std;\nchar s[105];\nint a;\nint main(){\n scanf(\"%s\",s);\n char it ='a';\n int n =strlen(s);\n for(int i=0 ; i\nusing namespace std;\nint main()\n{\n\tchar c, p = 'a';\n\tint i = 0;\n\twhile(cin >> c)\n\t{\n\t i += min(abs(p-c), 26-abs(p-c));\n\t p=c; \n\t \n\t} \n\tcout << r;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "db20761f023879cd07d1d6608368acbe", "src_uid": "ecc890b3bdb9456441a2a265c60722dd", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": " \n \n #include\n #include \n #include \n using namespace std;\n \n int main(){\n string str;\n cin>>str;\n int total =0;\n for(int i =0;i\nint main(){\n int n,s;\n s=0;\n cin>>n;\n while(n)\n {\n if(n%8==1)\n s++;\n n/=8;\n }\n cout<\nint a,ans;\nint main()\n{\n cin>>a;\n while(a!=0)\n {\n if(a%8==1) ans++;\n a/=8;\n }\n cin>>ans;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "87696c7c4c6337f1e5d836560401c82e", "src_uid": "ec539775f2b3358a92a99a644e2480ce", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include\najsdflkajsdlfas", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d4f5da71308f089423e87a3d7ec34137", "src_uid": "ec539775f2b3358a92a99a644e2480ce", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std; \nint a , cnt=0;\nint main()\n{\n cin >> a;\n while(a != 0)\n {\n if(a % 8 == 1)\n {\n \tcnt++;\n\t\t}\n a /= 8;\n }\n cout<\n#include\nusing namespace std;\nint main()\n{\n int t;\n cin>>t;\n while(t--)\n {\n int x,result=0;\n cin>>x;\n if(x>=2&&x<=7)\n cout<<\"1\"<7)\n {\n int k=0;\n k=x%5;\n if(k==1)\n {\n result=(x/4)+1;\n\n }\n else\n {\n result=(x/5)+1;\n }\n cout<\nusing namespace std;\nint main()\n{\n int t;\n cin>>t;\n while(t--)\n {\n int n;\n cin>>n;\n cout<\n#include \n#include \n#include \nusing namespace std;\nvector ans;\nint main() {\n\tint n;\n\tint a;\n\tcin >> n;\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> a;\n\t\tif (a % 6 == 0) cout << a / 6 << endl;\n\t\telse cout << a / 6 + 1 << endl;\n\t}\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3ef5f975bf16dcf98a7495471c1887f8", "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c", "difficulty": 800.0} {"lang": "MS C++ 2017", "source_code": " #include\n using nsmespace std;\n int main()\n {\n int n,*num;\n cin>>n;\n num=new int[n];\n for(int i=0;i>num[i];\n cout<\n#include\n#include\n#include\nusing namespace std;\nint step[105]={0},t=0,n,m; \nint ex,ey,sx,sy,ans=0;\nchar map[55][55]={0};\nint change[4][2]={{-1,0},{1,0},{0,-1},{0,1}};\n scanf(\"%d%d\",&n,&m);\n char c=getchar();\n for(int i=0;i'3'||c<'0') c=getchar();\n while(c>='0'&&c<='3'){\n step[t]=c-'0';\n c=getchar();\n t++; \n }\n}\n\nvoid walk(int x,int y,int z,int w){ \n int r=sx,c=sy,a[4]={x,y,z,w};\n for(int i=0;i=n||c>=m||map[r][c]=='#')\n return;\n if(r==ex&&c==ey){\n ans++;\n return;\n }\n }\n return;\n}\nvoid solve(){\n for(int i=0;i<4;i++){\n for(int j=0;j<4;j++){\n if(i==j) continue; \n for(int k=0;k<4;k++){\n if(k==j||k==i) continue;\n for(int l=0;l<4;l++){\n if(i==l||k==l||j==l) continue;\n walk(i,j,k,l);\n }\n }\n }\n } \n}\nint main(){\n Init();\n solve();\n printf(\"%d\",ans);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fc403768965a9f03a5e45126c93d955f", "src_uid": "7a66fae63d9b27e444d84447012e484c", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\nchar op[10];int num[10];\nll ans = 0x7fffffffffffffff;\nvectork;\nvoid dfs(vectora,int now){\n if(now == 4) {\n\t\tans = min(ans , a[0]);\n\t\treturn ;\n\t}vectorb=a;\n\tfor(int i = 0; i < a.size(); i++) {\n for(int j = i + 1; j < a.size(); j++) {\n if(op[now] == '+')a[i] = a[i] + a[j];\n if(op[now] == '*')a[i] = a[i] * a[j];\n a.erase(a.begin() + j);\n dfs(a , now + 1);\n a = b;\n }\n }\n}\nsigned main() {\n int t;\n\tfor(int i = 1; i <= 4; i++)scanf(\"%lld\" , &num[i]),k.push_back(num[i]);\n\tfor(int i = 1 ; i <= 3; i++){\n\t cin >> op[i] ;\n\t}\n\tdfs(k , 1);\n\tcout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define pi pair\n#define pii pair\n#define mp make_pair\n#define pb push_back\n#define ll long long \nusing namespace std;\nll a[4],am;\nchar x,y,z;\nint main()\n{\n cin>>a[0]>>a[1]>>a[2]>>a[3]>>x>>y>>z;\n if(x=='*')am++;\n if(y=='*')am++;\n if(z=='*')am++;\n ll ans;\n sort(a,a+4);\n if(a[0]==0 and am)ans=0;\n else{\n if(am==3)ans=a[0]*a[1]*a[2]*a[3];\n if(am==2)if(a[0]*a[1]>a[3]){\n ans=a[0]*a[1]+a[2]*a[3];\n ans=min(a[0]*a[2]+a[1]*a[3]);\n }\n else ans=a[0]*a[1]*a[2]+a[3];\n if(am==1)ans=a[0]*a[1]+a[2]+a[3];\n if(!am)ans=a[0]+a[1]+a[2]+a[3];\n }\n cout<\nusing namespace std;\ntypedef long long int ll;\nchar c[5],a[5];\nll b[5];\nbool f[5]={0};\nll ans=1000000000010;\nvoid dfs(int p) {\n\tif(p>3) {\n\t\tcout<>b[1]>>b[2]>>b[3]>>b[4];\n\tcin>>c[1]>>c[2]>>c[3];\n\tif(c[1]==c[2]==c[3]=='+') cout<\nusing namespace std;\ntypedef long long int ll;\nchar c[5],a[5];\nll b[5];\nbool f[5]={0};\nll ans=1000000000010;\nvoid dfs(int p) {\n\tif(p>3) {\n\t\tcout<>b[1]>>b[2]>>b[3]>>b[4];\n\tcin>>c[1]>>c[2]>>c[3];\n\tif(c[1]==c[2]==c[3]=='+') cout<\n#include\nusing namespace std;\n\nint main() {\n int a, b, l, r, c, pl, pr, cl, cr;\n cin >> a >> b >> l >> r;\n c = a + b;\n //\u5224\u65ad\u4e0b\u6807\u662f\u5426\u5728\u540c\u4e00\u4e2aAB\u7ec4\u5408\u5185\n cl = --l / c;\n cr = --r / c;\n //\u83b7\u53d6AB\u5206\u522b\u5bf9\u5e94\u7684\u7d22\u5f15\n pl = l % c;\n pr = r % c;\n if (cl == cr) {\n if (pl < a && pr < a) {\n cout << pr - pl + 1 << endl;\n } else if (pl < a && pr >= a) {\n cout << a - pl << endl;\n } else {\n cout << 1 << endl;\n }\n } else if (a <= b) {\n if (cl < cr - 1) {\n cout << a + 1 << endl;\n } else {\n if (pr >= a) {\n cout << a + 1 << endl;\n } else {\n if (pl >= a) {\n cout << pr + 1 + 1 << endl;\n } else {\n int left = a - pl;\n int right = pr + 1;\n if (left + right > a) {\n cout << a + (right == a) << endl;\n } else {\n cout << left + right + (right == a) << endl;\n }\n }\n }\n\n }\n } else {\n int d = a - b;\n if (cl == cr - 1) {\n if (pr >= a && pl >= a) {\n cout << a + 1 << endl;\n } else if (pr < a && pl >= a) {\n cout << pr + 1 + 1 << endl;\n } else if (pr >= a && pl < a) {\n cout << min((a + a - pl), a + a - b) << endl;\n } else if (pr < a && pl < a) {\n if (pl > b) {\n cout << pr + 1 + a - pl << endl;\n } else {\n cout << ptr + 1 + a - b << endl;\n }\n }\n// else {\n// int right = min(pr + 1, a);\n// int left = max(1, min(a - b, a - pl));\n// cout << right + left << endl;\n// }\n\n } else if (cl == cr - 2) {\n cout << a + max(1, d + min(0, pr - a + 1 + max(0, a - pl)));\n } else {\n cout << a + d;\n }\n }\n\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ecc8305be129791712805edaf2afdc26", "src_uid": "d055b2a594ae7788ecafb3ef80f246ec", "difficulty": 2200.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint h[1000];\nint main()\n{\n int a,b,l,r;\n cin>>a>>b>>l>>r;\n string s[1000];\n int x=0;\n if(a<=b)\n {\n x=0;\n for(int i=0;i=x-1)\n {for(int i=0;i0)\n ans++;\n }\n cout<\nusing namespace std;\nint h[1000];\nint main()\n{\n int a,b,l,r;\n cin>>a>>b>>l>>r;\n string s[1000];\n int x=0;\n if(a<=b)\n {\n x=0;\n for(int i=0;i=x-1)\n {for(int i=0;i0)\n ans++;\n }\n cout<\nusing namespace std;\nint h[1000];\nint main()\n{\n int a,b,l,r;\n cin>>a>>b>>l>>r;\n string s[1000];\n int x=0;\n if(a<=b)\n {\n x=0;\n for(int i=0;i=x-1)\n {for(int i=0;i0)\n ans++;\n }\n cout<\n#include\nusing namespace std;\n\nint main() {\n int a, b, l, r, c, pl, pr, cl, cr;\n cin >> a >> b >> l >> r;\n c = a + b;\n //\u5224\u65ad\u4e0b\u6807\u662f\u5426\u5728\u540c\u4e00\u4e2aAB\u7ec4\u5408\u5185\n cl = --l / c;\n cr = --r / c;\n //\u83b7\u53d6AB\u5206\u522b\u5bf9\u5e94\u7684\u7d22\u5f15\n pl = l % c;\n pr = r % c;\n if (cl == cr) {\n if(pl=a){\n cout<a){\n cout<a&&pra&&rl>a){\n cout<\nusing namespace std;\nbool ans;\nmain()\n{\n\tstring s;\n\tint i,n;\n\tcin>>s>>n;\n\tstring x[n];\n\tfor(i=0;i>x[i];\n\t\tif(x[i]==s)ans=1;\n\t}\n\tfor(i=0;i\nusing namespace std;\n\nint main()\n{int n,i,a1[n],a2[n],f=0,l=0,flag=0,j=0;\n string str,s[n];\n cin>>str;\n cin>>n;\n for(i=0;i>s[i];\n if((s[0]==str[0]&&s[1]==str[1])||(s[0]==str[1]&&s[1]==str[0]))\n {flag=1;\n break;\n }\n a1[j++]=s[0];\n a2[j++]=s[1];\n }\n if(!flag)\n {for(i=0;i\nusing namespace std;\nint main(){\n string password, a[100];\n int n;\n bool yes;\n cin>>password>>n;\n for(int i=0; i>a[i];\n }\n for(int i=0; i\n#include\nusing namespace std;\nint main()\n{\n\tstring pass, s;\n\tint n, x = 0, y = 0, z = 0;\n\tcin >> pass>>n;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tcin >> s;\n\t\n\t\tif (s == pass)\n\t\t\tx++;\n\t\telse if (pass[0] == s[1])\n\t\ty++;\n\t\telse if (pass[1] == s[0])\n\t\t\tz++;\n\t}\n\tif ((y>= 1 && z >= 1) || x >= 1)\n\t\tcout << \"YES\";\n\telse\n\t\tcout << \"NO\"\n\t\t\n\t\t\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0a8e5173ce10eec69899d42d804857e6", "src_uid": "cad8283914da16bc41680857bd20fe9f", "difficulty": 900.0} {"lang": "GNU C++17", "source_code": "#include\n#define ll long long\nusing namespace std;\nconst int maxn=3e8+7;\nbool cnt[maxn];\nbool isprime[maxn];\nint sum[maxn];\nvoid getprime(){\n memset(isprime,true,sizeof(isprime));\n for(int i=2;i<=sqrt(maxn);i++){\n if(isprime[i]){\n for(int j=i*i;j>l>>r;\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nconst int Max=17500;\nint prim[Max];\nbitsetvis;\nbitset<300000000/4+10>sign;\nvoid is_prim()\n{\n vis[0]=vis[1]=1;\n register int num=0;\n for(register int i=2;i<=Max;i++)\n {\n if(!vis[i])\n {\n num++;\n prim[num]=i;\n }\n for(register int j=1;((j<=num)&&(i*prim[j]<=Max));j++)\n {\n vis[i*prim[j]]=1;\n if(i%prim[j]==0)\n break;\n }\n }\n}\nint num(int l,int r)\n{\n int p=2014;\n for (register int i=2;i<=p+1&&prim[i]*prim[i]<=r;i++)\n {\n int cnt=l/prim[i];\n if (cnt*prim[i]>2]=1;\n }\n int ans=0;\n for (register int j=l;j<=r;j+=4)\n if (j%2&&!sign[j>>2]) ans++;\n return ans;\n}\nint main()\n{\n is_prim();\n int l,r;\n int ans=0;\n scanf(\"%d %d\",&l,&r);\n if (l<=2&&r>=2) ans++;\n while(l%4!=1||l==1) l++;\n while(r%4!=1) r--;\n ans+=num(l,r);\n printf(\"%d\\n\",ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4a9f045035ee643fdca7f987f065e7d0", "src_uid": "55a83526c10126ac3a6e6e5154b120d0", "difficulty": 2200.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\ntypedef long long ll;\ntypedef pair pll;\n\n#define CONFIG ios_base::sync_with_stdio(false);cout< d;\n\nint32_t main() {\n //freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "707927cbc7f1c6aff3846c9b00d8b157", "src_uid": "55a83526c10126ac3a6e6e5154b120d0", "difficulty": 2200.0} {"lang": "GNU C++17", "source_code": "//#pragma comment(linker, \"/stack:200000000\")\n//#pragma GCC optimize(\"Ofast\")\n//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n//#pragma GCC optimize(\"unroll-loops\")\n\n#include \n#include \ntypedef unsigned long long ull;\n#define uint unsigned int\n#define ll long long\n#define ld long double\n#define rep(i, l, r) for (int i = l; i < r; i++)\n#define repb(i, r, l) for (int i = r; i > l; i--)\n#define sz(a) (int)a.size()\n#define fi first\n#define se second\n#define mp(a, b) make_pair(a, b)\n\nusing namespace std;\n\ninline void setmin(int &x, int y) { if (y < x) x = y; }\ninline void setmax(int &x, int y) { if (y > x) x = y; }\ninline void setmin(ll &x, ll y) { if (y < x) x = y; }\ninline void setmax(ll &x, ll y) { if (y > x) x = y; }\n\nconst int N = 300000;\nconst int inf = (int)1e9 + 1;\nconst ll big = (ll)1e18 + 1;\nconst int P = 239;\nconst int MOD = (int)1e9 + 7;\nconst int MOD1 = (int)1e9 + 9;\nconst double eps = 1e-9;\nconst double pi = atan2(0, -1);\nconst int ABC = 26;\n\nbool e[N];\nvector pr;\n\nvoid init(int l, int r)\n{\n if (sz(pr) == 0)\n {\n int x = 1;\n while ((x + 1) * (x + 1) <= 300000000)\n x++;\n fill(e, e + x + 1, true);\n e[0] = e[1] = false;\n for (int i = 2; i * i <= x; ++i)\n if (e[i])\n {\n for (int j = i * i; j <= x; j += i)\n e[j] = false;\n }\n for (int i = 2; i <= x; ++i) {\n if (e[i]) {\n pr.push_back(i);\n }\n }\n }\n fill(e, e + (r - l + 1), true);\n if (l == 1)\n e[0] = false;\n for (int p : pr)\n {\n if (p > r)\n break;\n int x = (l + p - 1) / p * p;\n if (x == p)\n x += p;\n int pos = x - l;\n while (x <= r)\n {\n e[pos] = false;\n x += p;\n pos += p;\n }\n }\n}\n\nvector cnt_good = {4784,8978,12981,16901,20732,24523,28249,31916,35585,39176,42818,46430,49962,53516,57023,60523,64040,67489,70985,74417,77879,81285,84679,88055,91433,94878,98240,101608,104979,108284,111653,115039,118375,121695,124997,128270,131626,134912,138219,141503,144830,148121,151368,154619,157925,161166,164444,167675,170946,174194,177433,180617,183844,187048,190283,193493,196709,199900,203111,206333,209526,212732,215966,219123,222272,225463,228651,231844,235069,238261,241443,244581,247733,250868,253974,257141,260352,263482,266623,269760,272885,276014,279149,282271,285396,288556,291710,294878,297984,301101,304177,307326,310444,313579,316642,319813,322904,326007,329106,332181,335268,338394,341465,344551,347665,350739,353840,356909,360000,363080,366160,369261,372328,375439,378518,381635,384728,387817,390920,393993,397033,400087,403209,406288,409309,412333,415431,418499,421556,424569,427583,430660,433680,436753,439791,442818,445857,448901,451962,454974,457972,461015,464069,467135,470153,473178,476215,479250,482265,485275,488279,491293,494311,497242,500236,503251,506276,509308,512383,515414,518404,521398,524428,527422,530472,533469,536442,539450,542467,545501,548499,551461,554513,557493,560489,563514,566514,569508,572481,575503,578464,581445,584484,587448,590416,593357,596373,599365,602379,605357,608340,611346,614316,617284,620283,623219,626204,629187,632137,635171,638124,641088,644018,646968,649933,652929,655897,658857,661819,664771,667743,670676,673688,676670,679672,682576,685541,688504,691478,694490,697405,700326,703273,706181,709115,712113,715038,717989,720960,723896,726882,729831,732782,735740,738676,741606,744563,747458,750384,753318,756217,759188,762199,765150,768087,771012,773928,776896,779827,782754,785698,788611,791513,794449,797361,800286,803241,806180,809116,812028,814963,817868,820796,823752,826720,829643,832596,835498,838436,841364,844292,847194,850080,853022,855895,858875,861761,864672,867592,870514,873482,876358,879282,882186,885138,888023,890933,893857,896758,899686,902573,905460,908421,911332,914214,917110,920007,922881,925822,928780,931678,934604,937520,940453,943326,946295,949181,952088,955026,957871,960726,963624,966507,969407,972309,975196,978085,980962,983867,986746,989647,992538,995405,998272,1001141,1004047,1006935,1009828,1012698,1015619,1018497,1021407,1024321,1027185,1030064,1032962,1035803,1038722,1041665,1044521,1047338,1050175,1053074,1055897,1058798,1061676,1064500,1067388,1070268,1073174,1076029,1078883,1081790,1084692,1087554,1090413,1093331,1096221,1099056,1101903,1104801,1107645,1110568,1113425,1116309,1119226,1122066,1124941,1127772,1130652,1133559,1136475,1139334,1142195,1145026,1147867,1150738,1153592,1156490,1159339,1162244,1165140,1168043,1170911,1173746,1176591,1179444,1182370,1185244,1188093,1190925,1193801,1196660,1199545,1202432,1205285,1208198,1211026,1213868,1216688,1219588,1222393,1225259,1228119,1230996,1233830,1236682,1239605,1242422,1245272,1248112,1250996,1253792,1256652,1259537,1262363,1265205,1268047,1270890,1273689,1276506,1279377,1282286,1285127,1287980,1290771,1293580,1296434,1299249,1302081,1304899,1307765,1310565,1313437,1316314,1319179,1321953,1324799,1327680,1330570,1333417,1336222,1339091,1341880,1344730,1347558,1350402,1353252,1356098,1358925,1361746,1364529,1367411,1370266,1373089,1375934,1378787,1381608,1384448,1387240,1390062,1392850,1395709,1398555,1401374,1404179,1407069,1409899,1412745,1415626,1418381,1421271,1424100,1426913,1429775,1432595,1435430,1438258,1441129,1443939,1446779,1449605,1452383,1455248,1458083,1460920,1463729,1466529,1469369,1472195,1475031,1477838,1480667,1483501,1486323,1489166,1491981,1494787,1497648,1500453,1503239,1506081,1508873,1511686,1514527,1517367,1520184,1523011,1525806,1528622,1531402,1534201,1536997,1539894,1542683,1545503,1548241,1551093,1553884,1556702,1559565,1562352,1565117,1567943,1570716,1573536,1576359,1579176,1581960,1584772,1587542,1590356,1593212,1596005,1598783,1601564,1604386,1607165,1609974,1612824,1615617,1618452,1621217,1624007,1626767,1629636,1632421,1635222,1637991,1640857,1643718,1646485,1649297,1652064,1654854,1657619,1660460,1663265,1666081,1668892,1671700,1674594,1677356,1680125,1682935,1685691,1688539,1691341,1694101,1696863,1699639,1702441,1705278,1708110,1710912,1713725,1716510,1719267,1722095,1724880,1727671,1730436,1733217,1736052,1738807,1741642,1744421,1747205,1750007,1752772,1755537,1758337,1761093,1763839,1766647,1769444,1772246,1775046,1777876,1780671,1783464,1786236,1789019,1791841,1794680,1797448,1800274,1803074,1805871,1808647,1811416,1814143,1816933,1819707,1822528,1825244,1828005,1830793,1833548,1836360,1839214,1841996,1844792,1847581,1850327,1853089,1855856,1858663,1861433,1864207,1866991,1869796,1872540,1875345,1878117,1880878,1883646,1886490,1889297,1892075,1894867,1897679,1900521,1903296,1906069,1908797,1911589,1914346,1917129,1919906,1922737,1925489,1928318,1931029,1933873,1936618,1939421,1942195,1944975,1947727,1950518,1953327,1956076,1958882,1961653,1964430,1967231,1969999,1972724,1975510,1978238,1981017,1983809,1986618,1989438,1992205,1994950,1997721,2000489,2003304,2006033,2008816,2011607,2014373,2017180,2019933,2022702,2025513,2028256,2031020,2033803,2036610,2039323,2042136,2044905,2047682,2050502,2053230,2055971,2058719,2061484,2064275,2067035,2069780,2072561,2075349,2078104,2080845,2083584,2086330,2089097,2091864,2094672,2097407,2100185,2102972,2105738,2108433,2111259,2113990,2116784,2119527,2122304,2125069,2127838,2130618,2133419,2136173,2138962,2141713,2144481,2147172,2149924,2152702,2155442,2158237,2161008,2163758,2166537,2169247,2171965,2174706,2177470,2180269,2183018,2185806,2188547,2191332,2194100,2196835,2199596,2202324,2205083,2207860,2210669,2213444,2216182,2218953,2221739,2224515,2227246,2230006,2232708,2235482,2238231,2240991,2243756,2246480,2249227,2252025,2254788,2257554,2260312,2263079,2265828,2268545,2271245,2274003,2276736,2279483,2282217,2284983,2287747,2290512,2293240,2295997,2298702,2301494,2304177,2306931,2309704,2312443,2315163,2317910,2320691,2323417,2326186,2328942,2331676,2334374,2337139,2339871,2342642,2345411,2348163,2350887,2353608,2356373,2359139,2361872,2364678,2367432,2370149,2372878,2375651,2378388,2381162,2383896,2386653,2389450,2392222,2394902,2397618,2400363,2403099,2405857,2408603,2411351,2414127,2416904,2419627,2422296,2425056,2427745,2430503,2433251,2436001,2438719,2441528,2444352,2447016,2449765,2452482,2455256,2458031,2460744,2463429,2466187,2468912,2471679,2474403,2477113,2479832,2482617,2485399,2488154,2490869,2493631,2496331,2499026,2501804,2504528,2507234,2509986,2512726,2515473,2518175,2520875,2523614,2526330,2529122,2531839,2534604,2537308,2540008,2542791,2545541,2548284,2551055,2553802,2556546,2559256,2562021,2564750,2567510,2570148,2572929,2575664,2578403,2581128,2583836,2586615,2589384,2592090,2594819,2597536,2600254,2602944,2605706,2608394,2611086,2613806,2616565,2619321,2622048,2624787,2627470,2630206,2632916,2635613,2638344,2641068,2643874,2646581,2649274,2651923,2654664,2657389,2660089,2662840,2665564,2668329,2671039,2673788,2676540,2679254,2682014,2684761,2687515,2690185,2692884,2695614,2698331,2701067,2703798,2706497,2709174,2711871,2714585,2717374,2720152,2722854,2725559,2728236,2730937,2733698,2736447,2739146,2741927,2744682,2747379,2750078,2752811,2755521,2758290,2761026,2763725,2766426,2769153,2771910,2774616,2777363,2780032,2782759,2785459,2788181,2790935,2793661,2796375,2799109,2801844,2804531,2807261,2809930,2812655,2815400,2818088,2820817,2823539,2826276,2828967,2831689,2834417,2837100,2839799,2842571,2845296,2847955,2850686,2853362,2856131,2858814,2861494,2864215,2866912,2869649,2872353,2875061,2877770,2880505,2883226,2885940,2888661,2891324,2894042,2896737,2899482,2902173,2904857,2907606,2910319,2913026,2915749,2918453,2921165,2923834,2926597,2929265,2931966,2934703,2937422,2940118,2942867,2945636,2948312,2951035,2953764,2956447,2959193,2961881,2964616,2967240,2969938,2972638,2975367,2978051,2980755,2983431,2986123,2988902,2991612,2994331,2997075,2999799,3002504,3005203,3007900,3010597,3013324,3016009,3018743,3021417,3024129,3026843,3029542,3032258,3034938,3037647,3040326,3043022,3045754,3048458,3051170,3053831,3056533,3059268,3061963,3064626,3067352,3069997,3072755,3075490,3078186,3080941,3083637,3086305,3089049,3091766,3094461,3097083,3099791,3102503,3105214,3107929,3110676,3113376,3116121,3118822,3121506,3124226,3126914,3129663,3132389,3135041,3137800,3140465,3143179,3145895,3148595,3151359,3154060,3156704,3159381,3162037,3164764,3167422,3170165,3172860,3175583,3178276,3180981,3183679,3186336,3189067,3191741,3194439,3197144,3199905,3202633,3205350,3208093,3210815,3213514,3216212,3218845,3221531,3224234,3226984,3229664,3232326,3235040,3237756,3240412,3243108,3245793,3248448,3251142,3253794,3256465,3259118,3261786,3264499,3267184,3269881,3272566,3275208,3277990,3280684,3283348,3286023,3288733,3291422,3294158,3296809,3299511,3302209,3304882,3307587,3310219,3312951,3315658,3318340,3321024,3323750,3326372,3329060,3331730,3334387,3337067,3339778,3342472,3345126,3347848,3350545,3353226,3355956,3358630,3361303,3363969,3366670,3369387,3372104,3374796,3377477,3380175,3382885,3385555,3388181,3390855,3393551,3396270,3398959,3401658,3404348,3407022,3409749,3412424,3415112,3417799,3420476,3423164,3425804,3428513,3431140,3433831,3436495,3439209,3441873,3444597,3447272,3450005,3452685,3455326,3458010,3460716,3463433,3466044,3468740,3471402,3474095,3476807,3479443,3482094,3484813,3487498,3490171,3492860,3495568,3498297,3500974,3503652,3506387,3509080,3511783,3514444,3517154,3519834,3522520,3525176,3527908,3530582,3533256,3535969,3538668,3541338,3543978,3546667,3549376,3552022,3554739,3557385,3560090,3562780,3565457,3568117,3570777,3573441,3576162,3578838,3581527,3584202,3586899,3589608,3592224,3594895,3597609,3600284,3602937,3605598,3608315,3611057,3613719,3616375,3619063,3621779,3624437,3627138,3629813,3632494,3635172,3637897,3640546,3643225,3645881,3648522,3651242,3653950,3656685,3659419,3662084,3664727,3667446,3670105,3672775,3675493,3678172,3680848,3683590,3686168,3688865,3691503,3694149,3696775,3699495,3702151,3704779,3707476,3710195,3712861,3715571,3718229,3720907,3723622,3726326,3729014,3731697,3734399,3737057,3739687,3742387,3745052,3747736,3750447,3753093,3755763,3758470,3761125,3763798,3766488,3769101,3771838,3774512,3777096,3779799,3782494,3785161,3787804,3790455,3793100,3795810,3798471,3801142,3803841,3806532,3809252,3811893,3814570,3817240,3819899,3822594,3825303,3827949,3830626,3833257,3835966,3838551,3841206,3843893,3846531,3849184,3851821,3854488,3857123,3859809,3862541,3865213,3867908,3870566,3873197,3875855,3878498,3881127,3883820,3886491,3889196,3891882,3894547,3897254,3899883,3902460,3905110,3907779,3910369,3913050,3915712,3918400,3921049,3923696,3926401,3929085,3931738,3934443,3937079,3939772,3942498,3945191,3947875,3950555,3953194,3955921,3958645,3961297,3963906,3966568,3969211,3971880,3974536,3977155,3979753,3982460,3985072,3987720,3990416,3993126,3995735,3998438,4001109,4003807,4006464,4009128,4011827,4014469,4017140,4019846,4022481,4025096,4027765,4030424,4033095,4035734,4038441,4041068,4043777,4046464,4049121,4051770,4054424,4057114,4059771,4062451,4065123,4067794,4070475,4073176,4075821,4078473,4081177,4083782,4086435,4089090,4091774,4094421,4097099,4099748,4102417,4105056,4107702,4110356,4113050,4115722,4118385,4121052,4123728,4126380,4129050,4131700,4134353,4137024,4139686,4142364,4145061,4147677,4150324,4153011,4155686,4158364,4160967,4163597,4166236,4168923,4171606,4174224,4176870,4179522,4182183,4184850,4187489,4190141,4192811,4195422,4198063,4200732,4203355,4206045,4208687,4211357,4213982,4216686,4219357,4221985,4224628,4227283,4229915,4232565,4235233,4237862,4240503,4243170,4245785,4248402,4251066,4253702,4256360,4259015,4261661,4264294,4266922,4269625,4272264,4274957,4277598,4280202,4282798,4285399,4288065,4290688,4293351,4296021,4298654,4301295,4303982,4306609,4309218,4311887,4314529,4317235,4319923,4322593,4325294,4327912,4330591,4333234,4335879,4338516,4341144,4343802,4346451,4349053,4351735,4354389,4357049,4359663,4362342,4364926,4367588,4370299,4372936,4375553,4378193,4380845,4383575,4386240,4388879,4391542,4394200,4396851,4399521,4402187,4404832,4407487,4410086,4412694,4415371,4418023,4420721,4423372,4425992,4428609,4431243,4433902,4436580,4439170,4441823,4444490,4447138,4449673,4452307,4454923,4457555,4460241,4462894,4465544,4468140,4470785,4473457,4476148,4478750,4481417,4484076,4486724,4489312,4492007,4494652,4497293,4499966,4502619,4505253,4507856,4510573,4513194,4515919,4518560,4521186,4523774,4526427,4529073,4531708,4534347,4536968,4539593,4542204,4544861,4547523,4550196,4552844,4555492,4558141,4560804,4563438,4566061,4568706,4571337,4574015,4576657,4579285,4581977,4584687,4587326,4589993,4592654,4595266,4597877,4600572,4603201,4605817,4608469,4611140,4613737,4616385,4619006,4621593,4624232,4626876,4629508,4632187,4634797,4637399,4640031,4642678,4645360,4647919,4650560,4653231,4655889,4658586,4661190,4663804,4666451,4669055,4671705,4674351,4676997,4679633,4682243,4684949,4687533,4690161,4692790,4695463,4698103,4700735,4703363,4706007,4708643,4711274,4713900,4716608,4719202,4721853,4724481,4727184,4729855,4732496,4735168,4737851,4740486,4743083,4745721,4748367,4750950,4753627,4756289,4758913,4761561,4764205,4766823,4769430,4772013,4774673,4777296,4779967,4782597,4785262,4787905,4790546,4793167,4795770,4798436,4801064,4803668,4806333,4808985,4811623,4814267,4816891,4819529,4822161,4824805,4827436,4830058,4832685,4835379,4838000,4840681,4843322,4845982,4848640,4851212,4853838,4856492,4859127,4861763,4864388,4867028,4869676,4872296,4874854,4877529,4880180,4882798,4885427,4888078,4890746,4893365,4896011,4898673,4901286,4903891,4906512,4909157,4911785,4914384,4917033,4919690,4922306,4924919,4927573,4930213,4932818,4935488,4938140,4940775,4943379,4946070,4948680,4951297,4953911,4956558,4959210,4961878,4964538,4967185,4969806,4972410,4975039,4977662,4980311,4982941,4985647,4988226,4990898,4993516,4996145,4998802,5001443,5004057,5006709,5009406,5012065,5014695,5017340,5019950,5022572,5025179,5027802,5030447,5033047,5035681,5038280,5040863,5043508,5046095,5048766,5051412,5054025,5056629,5059278,5061913,5064512,5067205,5069825,5072492,5075114,5077659,5080256,5082860,5085500,5088135,5090728,5093333,5095989,5098616,5101203,5103826,5106459,5109090,5111744,5114362,5116967,5119591,5122214,5124845,5127515,5130154,5132783,5135431,5138076,5140731,5143346,5145981,5148606,5151275,5153900,5156547,5159150,5161734,5164342,5166954,5169574,5172232,5174885,5177522,5180106,5182723,5185364,5187966,5190596,5193213,5195881,5198500,5201126,5203797,5206415,5209050,5211713,5214289,5216846,5219488,5222091,5224741,5227387,5230075,5232642,5235256,5237883,5240497,5243171,5245787,5248349,5250964,5253604,5256295,5258925,5261560,5264198,5266812,5269432,5272057,5274678,5277359,5279981,5282588,5285176,5287825,5290378,5292984,5295576,5298144,5300709,5303300,5305965,5308565,5311160,5313783,5316423,5319019,5321597,5324214,5326785,5329410,5332021,5334623,5337228,5339868,5342497,5345130,5347796,5350422,5353090,5355703,5358368,5360987,5363545,5366148,5368777,5371412,5374088,5376687,5379310,5381929,5384561,5387172,5389785,5392412,5395046,5397629,5400260,5402887,5405527,5408176,5410794,5413434,5415999,5418615,5421235,5423862,5426485,5429133,5431730,5434359,5436989,5439576,5442164,5444785,5447430,5450050,5452630,5455226,5457874,5460458,5463064,5465636,5468292,5470840,5473438,5476040,5478624,5481234,5483862,5486492,5489062,5491685,5494277,5496930,5499560,5502195,5504849,5507484,5510039,5512631,5515229,5517813,5520451,5523148,5525740,5528354,5530960,5533526,5536136,5538821,5541485,5544171,5546787,5549334,5551962,5554594,5557156,5559794,5562401,5564989,5567668,5570318,5572922,5575559,5578173,5580735,5583348,5585968,5588600,5591257,5593883,5596537,5599126,5601766,5604343,5606978,5609544,5612150,5614795,5617364,5619974,5622604,5625220,5627890,5630520,5633085,5635731,5638332,5640958,5643587,5646179,5648777,5651328,5653955,5656616,5659237,5661891,5664467,5667110,5669724,5672315,5674898,5677516,5680112,5682698,5685283,5687873,5690537,5693138,5695725,5698354,5700962,5703597,5706173,5708793,5711418,5713948,5716608,5719236,5721870,5724432,5727030,5729670,5732291,5734927,5737555,5740151,5742760,5745303,5747922,5750484,5753109,5755700,5758284,5760903,5763488,5766103,5768742,5771329,5773921,5776526,5779099,5781662,5784324,5786983,5789590,5792263,5794904,5797482,5800089,5802685,5805349,5807963,5810588,5813145,5815758,5818375,5820930,5823533,5826127,5828742,5831423,5834055,5836688,5839332,5841893,5844529,5847110,5849741,5852352,5854947,5857519,5860154,5862786,5865406,5868021,5870662,5873255,5875845,5878520,5881140,5883729,5886329,5888952,5891561,5894167,5896791,5899352,5901946,5904577,5907199,5909822,5912399,5914980,5917583,5920157,5922796,5925412,5928032,5930672,5933314,5935941,5938528,5941165,5943777,5946380,5949001,5951600,5954206,5956845,5959490,5962107,5964740,5967358,5969954,5972550,5975142,5977742,5980358,5982939,5985529,5988135,5990733,5993379,5995955,5998500,6001091,6003727,6006283,6008887,6011523,6014158,6016757,6019332,6021859,6024475,6027082,6029692,6032264,6034853,6037496,6040041,6042691,6045299,6047914,6050499,6053126,6055662,6058265,6060852,6063464,6066107,6068704,6071358,6073902,6076512,6079117,6081675,6084293,6086846,6089462,6092066,6094754,6097313,6099890,6102471,6105113,6107732,6110282,6112891,6115533,6118146,6120762,6123306,6125905,6128580,6131219,6133813,6136360,6139005,6141600,6144218,6146820,6149371,6152008,6154675,6157271,6159871,6162461,6164976,6167591,6170168,6172803,6175450,6178055,6180645,6183213,6185805,6188462,6191134,6193761,6196339,6198883,6201446,6204006,6206615,6209208,6211825,6214485,6217047,6219685,6222252,6224827,6227426,6230025,6232618,6235254,6237903,6240568,6243137,6245745,6248383,6250968,6253594,6256157,6258704,6261229,6263772,6266353,6268950,6271545,6274153,6276725,6279295,6281850,6284431,6287079,6289703,6292248,6294880,6297458,6300083,6302647,6305225,6307854,6310423,6313002,6315578,6318146,6320783,6323413,6326011,6328577,6331172,6333770,6336395,6339009,6341630,6344208,6346739,6349347,6351927,6354521,6357116,6359727,6362295,6364935,6367512,6370124,6372759,6375330,6377932,6380538,6383126,6385750,6388317,6390928,6393566,6396156,6398760,6401309,6403894,6406444,6409020,6411621,6414240,6416840,6419444,6421985,6424585,6427175,6429774,6432352,6434905,6437478,6440084,6442694,6445293,6447930,6450524,6453111,6455682,6458326,6460917,6463538,6466171,6468741,6471304,6473882,6476474,6479075,6481719,6484300,6486895,6489472,6492070,6494656,6497314,6499923,6502519,6505097,6507692,6510279,6512873,6515451,6518114,6520675,6523259,6525868,6528444,6531066,6533690,6536273,6538887,6541470,6544021,6546672,6549285,6551864,6554452,6556996,6559587,6562188,6564770,6567411,6569951,6572574,6575116,6577700,6580260,6582892,6585456,6588087,6590708,6593326,6595957,6598515,6601071,6603686,6606273,6608834,6611498,6614095,6616698,6619295,6621894,6624418,6627012,6629605,6632211,6634763,6637327,6639847,6642444,6645043,6647598,6650124,6652723,6655351,6657923,6660525,6663028,6665670,6668208,6670804,6673402,6676025,6678603,6681238,6683806,6686331,6688966,6691555,6694117,6696711,6699329,6701946,6704527,6707200,6709795,6712367,6714983,6717599,6720189,6722794,6725391,6727968,6730547,6733134,6735695,6738207,6740828,6743394,6745968,6748552,6751153,6753724,6756299,6758910,6761489,6764062,6766666,6769185,6771775,6774395,6776965,6779497,6782076,6784634,6787249,6789787,6792400,6795031,6797654,6800239,6802810,6805406,6807999,6810601,6813192,6815770,6818374,6820939,6823539,6826057,6828648,6831224,6833809,6836379,6838975,6841545,6844146,6846743,6849310,6851866,6854427,6857053,6859666,6862301,6864928,6867491,6870031,6872597,6875182,6877737,6880327,6882924,6885471,6888050,6890595,6893240,6895824,6898361,6900909,6903508,6906086,6908592,6911194,6913799,6916351,6918938,6921532,6924153,6926760,6929345,6932010,6934558,6937122,6939699,6942266,6944833,6947433,6950048,6952622,6955229,6957811,6960447,6963003,6965624,6968229,6970814,6973374,6975908,6978553,6981142,6983701,6986303,6988895,6991452,6994053,6996636,6999239,7001827,7004386,7006943,7009509,7012092,7014637,7017247,7019911,7022468,7025101,7027733,7030312,7032873,7035446,7038006,7040537,7043119,7045744,7048342,7050888,7053483,7056063,7058671,7061274,7063885,7066487,7069099,7071649,7074208,7076794,7079414,7081992,7084585,7087182,7089730,7092253,7094829,7097378,7099975,7102560,7105136,7107734,7110341,7112923,7115505,7118105,7120687,7123329,7125909,7128529,7131104,7133676,7136261,7138851,7141412,7143963,7146532,7149099,7151678,7154306,7156895,7159502,7162172,7164744,7167291,7169862,7172477,7175070,7177687,7180299,7182859,7185447,7188010,7190543,7193111,7195725,7198306,7200837,7203410,7206026,7208623,7211221,7213777,7216339,7218922,7221467,7224118,7226696,7229224,7231835,7234448,7237074,7239661,7242248,7244831,7247438,7250010,7252624,7255179,7257777,7260342,7262872,7265456,7267970,7270545,7273095,7275708,7278251,7280851,7283410,7285994,7288560,7291115,7293745,7296316,7298848,7301442,7304018,7306655,7309180,7311705,7314293,7316887,7319531,7322112,7324659,7327260,7329881,7332442,7335022,7337604,7340210,7342739,7345280,7347817,7350378,7352945,7355504,7358025,7360615,7363210,7365832,7368429,7371013,7373605,7376145,7378732,7381276,7383811,7386365,7388933,7391502,7394032,7396642,7399245,7401866,7404457,7406982,7409538,7412102,7414691,7417288,7419884,7422441,7424989,7427522,7430101,7432639,7435216,7437740,7440294,7442912,7445516,7448114,7450684,7453261,7455841,7458445,7461027,7463635,7466198,7468787,7471320,7473930,7476552,7479118,7481641,7484264,7486781,7489342,7491952,7494521,7497063,7499688,7502254,7504815,7507392,7509988,7512553,7515087,7517707,7520308,7522824,7525392,7527945,7530543,7533105,7535700,7538260,7540804,7543418,7545943,7548535,7551130,7553729,7556313,7558844,7561435,7563980,7566505,7569080,7571641,7574170,7576783,7579338,7581897,7584422,7587022,7589577,7592151,7594705,7597276,7599794,7602390,7604973,7607619,7610137,7612748,7615269,7617858,7620416,7622960,7625549,7628196,7630753,7633277,7635834,7638354,7640910,7643496,7646121,7648660,7651279,7653833,7656431,7659011,7661580,7664134,7666612,7669193,7671776,7674356,7676915,7679488,7682031,7684595,7687146,7689731,7692293,7694861,7697419,7700031,7702574,7705205,7707783,7710348,7712918,7715474,7718028,7720597,7723207,7725778,7728305,7730889,7733442,7736038,7738641,7741178,7743670,7746199,7748766,7751407,7753967,7756540,7759095,7761686,7764213,7766793,7769379,7771905,7774461,7777035,7779545,7782119,7784671,7787226,7789834,7792385,7795028,7797627,7800194,7802758,7805346,7807903,7810459,7813000,7815577,7818155,7820761,7823285,7825842,7828445,7830988,7833550,7836167,7838714,7841312,7843890,7846422,7848885,7851434,7854000,7856583,7859172,7861776,7864364,7866909,7869478,7872018,7874591,7877131,7879768,7882314,7884851,7887428,7890024,7892632,7895233,7897844,7900429,7902975,7905546,7908066,7910582,7913125,7915728,7918312,7920913,7923470,7926037,7928634,7931211,7933766,7936281,7938828,7941378,7943902,7946432,7949032,7951602,7954217,7956760,7959316,7961868,7964451,7967003,7969567,7972124,7974694,7977293,7979866,7982413,7985018,7987569,7990128,7992722,7995266,7997861,8000394,8002935,8005473,8008047,8010615,8013200,8015753,8018323,8020862,8023413,8025983,8028499,8031030,8033583,8036158,8038758,8041400,8043966,8046482,8049029,8051591,8054132,8056748,8059305,8061849,8064377,8066944,8069508,8072033,8074668,8077206,8079782,8082323,8084914,8087510,8090092,8092568,8095135,8097678,8100189,8102726,8105256,8107767,8110337,8112936,8115467,8118011,8120631,8123161,8125719};\nconst int MX = 300000001;\null b0[(MX + 63) / 64];\n\nnamespace Bitset {\n\tinline bool test(ull* pb, int pos) {\n\t return (*(pb+(pos >> 8)) >> (pos & 63)) & 1;\n\t}\n\tinline void set(ull* pb, int pos) {\n\t\t*(pb+(pos >> 8)) |= (ull(1) << (pos & 63));\n\t}\n}\n\n\n\nint solve(int n)\n{\n if (n == 0)\n return 0;\n int p = (n - 1) / 100000;\n int x = (p + 1) * 100000;\n int ans = cnt_good[p];\n init(n, x);\n while (x > n)\n {\n answ -= (Bitset::test(b0, x) && e[x - n]);\n x--;\n }\n return ans;\n}\n\nint main()\n{\n //freopen(\"a.in\", \"r\", stdin);\n //freopen(\"a.out\", \"w\", stdout);\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.precision(20);\n cout << fixed;\n //ll TL = 0.95 * CLOCKS_PER_SEC;\n //double t = clock();\n //ll counter = 0;\n for (int i = 1, i2 = 1; i2 <= 300000000; i2 += (i << 1) + 1, ++i)\n for (int j = 1, j2 = 1; i2 + j2 <= 300000000; j2 += (j << 1) + 1, ++j) {\n //++counter;\n Bitset::set(b0, i2+j2);\n //b0[(i2+j2) >> 8] |= ull(1) << ((i2 + j2) & 63);\n }\n //std::cout << \"time1 = \" << (clock() - t) / CLOCKS_PER_SEC << \", counter = \" << counter << std::endl;\n /*b.set(0); b.set(1);\n for (int i = 2; i <= 300000000; i++)\n if (!b.test(i))\n for (int j = i * 2; j <= 300000000; j += i)\n b.set(j);\n int cnt = 0;\n for (int i = 1; i <= 300000000; i++)\n {\n if (b0.test(i) && !b.test(i))\n cnt++;\n if (i % 100000 == 0)\n cout << cnt << \",\";\n }*/\n int l, r;\n cin >> l >> r;\n cout << solve(r) - solve(l - 1) << \"\\n\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "30249e7067981849077025c57e5e815a", "src_uid": "55a83526c10126ac3a6e6e5154b120d0", "difficulty": 2200.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main ()\n{\n int a;\n cin>>a;\n if(a%2=0) \n {cout(\"0\"); } \n else if (a%2!=0)\n {cout(\"1\");}\n\n \n }\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "61967a8228b5523f71a8c4e606040239", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#iinclude \n\nusing namespace std;\n\nint main()\n{\n long long a;\n cin>>a;\n cout << a%2;\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0ec836bcb4e196014a6d6cb9fc27ceb0", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\nusingnamespace std;\nint main()\n{\n int a;\n cin>>a;\n if cout<<0;\n else cout<<1;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d76ffd9e338f9c9e37cd148b9dcf0cae", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n\n#define MAXN 100010\n\nusing namespace std;\n\nint main(){\n\n// freopen(\"a.in\", \"r\", stdin);\n\n int a;\n\n scanf(\"%d\\n\", &a);\n\n srand(time(NULL));\n\n printf(\"%d\\n\", rand()%1)\n\nreturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "92fd031cde90e1055c60bd502040f276", "src_uid": "78e64fdbf59c5ce89d0f0a1d0591f795", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define ull unsigned long long\n#define ll long long\n#define ld long double\n#define pi 3.1415926536\n#define lp(i,n,a) for(ll i=a;i<=n;i++)\n#define pl(i,n) for(ll i=n-1;i>=0;i--)\n#define w while\n#define re return\n// Hard Training :D \n// hossam yehia //\nusing namespace std;\nll n, m, maxi, a, b, f, out;\nint main() {\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n\tcin >> n >> m;\n\ta = n, b = m;\n\twhile (a) {\n\t\tmaxi = max(maxi, (a % 10)),a /= 10;\n\twhile (b) {\n\t\tmaxi = max(maxi, (b % 10)),b /= 10;\n\tmaxi++;\n\twhile (n || m || f) {\n\t\tf += (a % 10) + (b % 10);\n\t\tf /= maxi;\n\t\tn /= 10, m /= 10;\n\t\tout++;\n\t}\n\tcout << out << endl;\n\tcin >> n;\n\tre 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0db43efa1bb10e6f2de71c0b3fc1f4b4", "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b", "difficulty": 1500.0} {"lang": "GNU C++0x", "source_code": "#include\n#include\n#include\nusing namespace std;\n\nint main()\n{\n int a,b,r;\n cin>>a>>b;\n int q=a;\n int max=0;int n1=0,n2=0;\n while(q!=0)\n { r=q%10;\n q=q/10;\n max=max>r?max:r;\n n1++;\n}\nq=b;\nwhile(q!=0)\n { r=q%10;\n q=q/10;\n max=max>r?max:r;\n n2++;\n}\nmax++;\n\nint c=0,i=0,sum=0,x,y;\nwhile(a!=0 && b!=0)\n{\n x=a%10;\n y=b%10;\n double k=((double)((x+y+c)%max)*pow(10,i));\n sum=k*(int)pow(10,i)+sum;c=(x+y+c)/max;\n \n i++;\n a=a/10;b=b/10;\n \n}\ndouble k=((double)c*pow(10,i));\nsum=k+sum;\nn2=0;\n\nq=sum;\nwhile(q!=0)\n { \n q=q/10;\n n2++;\n}\ncout<\n#include \n\nusing namespace std;\nint a,b,x,y,q,c,c1;\nstring s;\nstring st[16]={\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"};\n\nint _tmain(int argc, _TCHAR* argv[])\n{\n cin>>a>>b;\n x=a; y=b; q=0;\n\n do {\n c=a%10;\n if (q0);\n\n do {\n c=b%10;\n if (q0);\n\n q+=1; c=1;\n do\n {\n a+=(x%10)*c;\n c=c*q;\n x=x/10;\n }\n while (x>0);\n\n c=1;\n do\n {\n b+=(y%10)*c;\n c=c*q;\n y=y/10;\n }\n while (y>0);\n\n a+=b; s=\"\"; q+=1;\n do\n {\n c=a%q;\n s+=st[c];\n a=a/q;\n }\n while (a>0);\n\n cout<\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\n\n \n \nint main() {\n\nint a,b;\ncin>>a>>b;\nint n=a+b;\nint aa=a,bb=b;\nint ma=0;\nvectorv1,v2;\nwhile(b)\n{\n\tma=max(ma,b%10);\n\tint k=b%10;\n\tv1.pb(k);\n\tb/=10;\n}\nwhile(a)\n{\n\tma=max(ma,a%10);\n\tint k=a%10;\n\tv2.pb(k);\n\ta/=10;\n}\nma++;\nint l=v1.size();\nint m=v2.size();\nwhile(lm)\n{\n\tm++;\n\tv2.pb(0);\n}\nint carry=0;\nint count=0;\nint i;\nfor( i=0;i=ma)\n\t{\n\t\tint y=fin%ma;\n\t\tcarry+=fin/ma;\n\t\tcount++;\n\t}\n\telse\n\t{\n\t\tcount++;\n\t}\n}\nif(carry!=0)\ncount++;\n \ncout<\n#define ll long long\nusing namespace std;\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n int n;\n cin>>n;\n vector v;\n set s;\n for(int i=0;i>a;\n v.push_back(a);\n s.insert(a);\n }\n vector v1(s.begin(),s.end());\n ll t(0);\n while(v1.size()!=0)\n {\n sort(v1.begin(),v1.end());\n for(int i=0;i0)\n {\n v1.erase(v.begin()+i);\n t++;\n }\n v1.erase(v.begin());\n }\n }\n cout<\n#include\n#include\n#include\nusing namespace std;\nint a[501],n;\nint main()\n{\n int i,m,sum=0;\n scanf(\"%d\",&n);\n for(i=0; i\nusing namespace std;\n\nint main()\n{\n ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);\n int n ,x, arr[24] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};\n cin>>n;\n vectorv;;\n for(int i=0 ; i>x , v.push_back(x);\n x=0;\n sort(v.begin() , v.end());\n if(v[0] == 1) return cout<<1, 0;\n for(int i=0 ; i<24;i++){\n int z = v.size();\n for(int j=0 ; j\n#define pb push_back;\nusing namespace std;\n\nbool isprime(int x)\n{\n\tif(x == 1) return false;\n\tfor(int i=2;i*i<=x;i++)\n\t{\n\t\tif(x%i==0)\n\t\treturn false;\n\t}\n\treturn true;\n}\nint main()\n{\n\tint n;cin>>n;\n\tint f1=0,f2=0,f3=0,cnt=0,f5=0,f7=0;\n\tint f[101]={0};\n\tvectorv;\n\tfor(int i=1,x;i<=n;i++)\n\t{\n\t\tcin>>x;\n\t\tf[x]++;\n\t}\n\tfor(int i=1;i<=100;i++)\n\t{\n\t\tif(f[i] != 0)\n\t\tv.pb(i);\n\t}\n\t\n\tfor(int i=0,x;i\nint main()\n{\n int d1,d2,d3,a,b,c,min;\n scanf(\"%d%d%d\",&d1,&d2,&d3);\n a=d1+d2+d3;\n b=2*(d1+d2);\n c=2*(d1+d3);\n d=2*(d2+d3);\n min=a;\n if(min>b) min=b;\n if(min>c) min=c;\n if(min>d) min=d;\n printf(\"%d\",min);\nreturn 0:\n}//2018-11-09 18:58:31.162", "lang_cluster": "C++", "compilation_error": true, "code_uid": "360df64bf4976d4bb1c2219302be163f", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint a,b,c;\nmain() {\n cin>>a>>b>>c;\n if(a+b>c) cout<\n#include \n#include \n\nusing namespace std;\n\nint main() {\n\tint d1, d2, d3;\n\t\tcin >> d1 >> d2 >> d3;\n\tcout << min (d1 + d2 + d3 , d1 * 2 + d2 * 2 min ( d1 * 2 + d2 * 2 ,2 * d2 + 2 * d3)) << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d68352ad5a83a3a25a7d2d3abb99ed88", "src_uid": "26cd7954a21866dbb2824d725473673e", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nint main() {\nint x,y,z;\nint sum=0;\ncin>>x>>y>>z;\nsu=x+y;\nif(sum==z)\n\tcout<\nusing namespace std;\ntypedef long long ll;\nint n;\nvoid solve(int k){\n\tint i,j;\n\tll rv=1;\n\tfor(i=1;i<=k;++i,rv*=10);\n\tint R=n%rv;\n\tint L=n-R;\n\tfor(i=0;iusing namespace std;using LL=int64_t;const int INF=0x3f3f3f3f;LL len(LL num) { LL ans=0; while(num>0) { ans++; num/=10; } return ans;}int main(){ ios::sync_with_stdio(0); cin.tie(0); LL n,ans=0; cin>>n; int lens=len(n); if(n<=49){ if(n<=9) ans=n/2; else if(n==10) ans=1; else { int num[20]={0}; for(int i=1;i<=n;i++) { num[i%10]++; } for(int i=1;i<=4;i++) ans+=num[i]*num[9-i]; ans+=num[9]*num[0]; } } else { LL num1=0; for(int i=1;i<=lens;i++) { num1=num1*10+9; } if(num1-n\n\nusing namespace std ;\n\ntypedef long long ll ;\n\n#define X first\n#define Y second\n\ninline long long len(long long x)\n{\n long long ret = 0;\n while(x){\n x /= 10;\n ret ++;\n }\n return ret;\n}\n\nint main() {\n ios_base::sync_with_stdio ( false ) ;\n long long n;\n long long ans = 0;\n cin >> n;\n ll cnt = 10;\n for(long long i = 1 ; i < 10 ; ++ i){\n if(cnt == n * 2){\n cout << 1 << endl;\n exit(0);\n }\n cnt *= 10;\n }\n long long x = 2 * n - 1;\n long long y = len(x) - 1;\n for(long long i = 0 ; i < 9 ; ++ i){\n long long u = (i+1) * pow(10,y) - 1;\n long long minn = (u+1) / 2;\n long long maxx = min(u , n);\n long long r = max(n - e + 1 , 0);\n ans += max(min(n+1,u) - (u+1) / 2,0);\n //cout << n << ' ' << u << ' ' << t << ' ' << e << ' ' << r << endl;\n }\n cout << ans << endl;\n return 0 ;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6bd2065394c9b5c15cc0578ee9599a1c", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "difficulty": 1800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nint n;\nint order;\nlong ans;\n\nint v(int n) {\n\tint value = 1;\n\tfor (int i = 1; i <= n; i++)value *= 10;\n\treturn value;\n}\n\nint main() {\n\tcin >> n;\n\tif (2 <= n; n <= 4) {\n\t\tif (n == 2)cout << 1 << endl;\n\t\telse if (n == 3)cout << 3 << endl;\n\t\telse if (n == 4)cout << 6 << endl;\n\t\treturn 0;\n\t}\n\tint ordertest = n;\n\tordertest /= 5;\n\twhile (ordertest >= 1) {\n\t\torder++;\n\t\tordertest /= 10;\n\t}\n\tfor (int i = 1; i <= 10; i++) {\n\t\tif (n > i*v(order) - 1)ans += (i*v(order) - 1) / 2;\n\t\telse if (n <= (i*v(order) - 1) / 2);\n\t\telse {\n\t\t\tans += n - (i*v(order) - 1) / 2;\n\t\t}\n\t}\n\tcout << ans << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "62c71a9c2fd11b4473964c4380a26dd1", "src_uid": "c20744c44269ae0779c5f549afd2e3f2", "difficulty": 1800.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nint main(){\n int n;\n char tmp1;\n char tmp2;\n int count_SF = 0;\n int count_FS = 0;\n cin >> tmp1;\n tmp2 = tmp1;\n for (int i = 0; i < n; i++)\n { \n cin >> tmp1;\n tmp2 = tmp1;\n if (tmp1 == 'S'&& tmp2 == 'F')\n {\n count_SF = count_SF + 1;\n } else if (tmp1 == 'F' && tmp2 = 'S')\n {\n count_FS += 1;\n }\n \n }\n\n if (count_SF > count_FS)\n {\n cout << \"YES\";\n } else\n {\n cout << \"NO\";\n }\n \n \n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7e1c4174b990aad54f3696d3027bafa3", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0} {"lang": "MS C++ 2017", "source_code": "#include \nusing namespace std;\nint main() {\n\n\tint n;\n\tcin >> n;\n\tstring s;\n\tstd::cin >> s;\n\n\tint i = 0;\n\tfor (int p = 1; p < s.length(); p++) {\n\t\tif (s[p - 1] == 'S' && s[p] == 'F') { ++i; }\n\t\telse if (s[p - 1] == 'F' && s[p] == 'S') { --i; }\n\t}\n\n\tif (i > 0) {\n\t\tcout << \"YES\";\n\t}\n\telse { cout << \"NO\"; };\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c38bfa44963f69348ea440a16b14e802", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nint main(){\nstring s;\nint c,f;\nint ans=0,sum=0;\ncin>>c>>f;\nfor (int i=0;isum)\n\tcout<<\"YES\";\nelse\ncout<<\"NO\";\t\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9f3b44f3b771c43199a81ad96a059d36", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n#include\nusing namespace std;\n\nint main() {\n\tstring s;\nint n;\n\tcin >> n >> s;\n\tint t1 = 0, t2 = 0;\n\tfor (int i = 0; i < n - 1; i++) {\n\t\tif (s[i] == 'S' && s[i + 1] == 'F') t1++;\n\t\telse if (s[i] == 'F' && s[i + 1] == 'S') t2++;\n\t}\n\tif (t1 > t2) cout << \"YES\";\n\telse cout << \"NO\";\n\treturn 0;\n}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1104d91094de8b99bf0f6270b1da939b", "src_uid": "ab8a2070ea758d118b3c09ee165d9517", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\n\nint main()\n{\n string s1 , s2 , s3;\n cin >> s1 >> s2 >> s3;\n \n int i=0;\n while(i==0){\n if(s3.find(s1[i]) !=string::npos){\n \n s3.erase(s3.find(s1[i],1);\n s1.erase(i,1);\n\n }else i++;\n } \n int j=0;\n while(j==0){\n if(s3.find(s2[j]) !=string::npos){\n \n s3.erase(s3.find(s2[j],1);\n s2.erase(j,1);\n\n }else j++;\n } \n if (s1.empty() && s2.empty() && s3.empty() )\n cout<<\"YES\";\n else \n cout<<\"NO\";\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0b9a6f5d7432351ce1a021833022847b", "src_uid": "b6456a39d38fabcd25267793ed94d90c", "difficulty": 800.0} {"lang": "MS C++ 2017", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint main(){\n string s1, s2, s3;\n cin>>s1>>s2>>s3;\n string s4=s1+s2;\n sort(s3.begin(), s3.end());\n sort(s4.begin(), s4.end());\n if(s3==s4){\n \tcout<<\"YES\";\n\t}\n\telse cout<<\"NO\";\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "258bbd653f40f9f0acac54421253e652", "src_uid": "b6456a39d38fabcd25267793ed94d90c", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std;\nint main()//\n{\n ios::sunc_with_stdio(false);\n string s,ss,sss;\n cin>>s>>ss>>sss;\n if(s.size()+ss.size()!=sss.size())\n {\n cout<<\"NO\";\n }\n else\n {\n int i,j;\n for (i = 0; s[i]; i++) \n {\n for (j = 0; sss[j]; j++)\n {\n if(s[i]==sss[j])\n {\n s[i]=sss[j]=1;\n break;\n }\n\n }\n\n }\n for (i = 0; ss[i]; i++) \n {\n for (j = 0; sss[j]; j++)\n {\n if(ss[i]==sss[j])\n {\n s[i]=sss[j]=1;\n break;\n }\n\n }\n\n }\n \n for (i = 0; sss[i]; i++)\n {\n if(sss[i]-1)\n break;\n }\n if(i==sss.size())\n cout<<\"YES\";\n else\n cout<<\"NO\";\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5b5e94717a4ef2a51453544a4d96b261", "src_uid": "b6456a39d38fabcd25267793ed94d90c", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\n\nint main()\n{\nint a=0,b=0,c=0,n=1,t=1;\n\nstring x,y,z;\ncin>>x>>y>>z;\n\n\nfor (int i=0;i\n\nusing namespace std;\n\nint main(){\n\t\n\tstring arr[4][4];\n\tstring a,b,c,d;\n\tint i,j,k,l;\n\tbool boolean=false;\n\n\tfor(i=0;i<4;i++){\n\t\tfor(j=0;j<4;j++){\n\t\t\tcin >> a;\n\t\t\tarr[i][j] = a;\n\t\t}\n\t}\n\n\tfor(i=0;i<4;i++){\n\t\tfor(j=0;j<3;j++){\n\t\t\tif(arr[i][j] ==\"1\"&& arr[i][3] == \"1\"){\n\t\t\t\tboolean = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif(i==0){\n\t\t\t\tif((arr[0][0]==\"1\"&&arr[3][3]==\"1\")||(arr[0][1]==\"1\"&&arr[2][3]==\"1\")||(arr[0][2]==\"1\"&&arr[1][3]==\"1\")){\n\t\t\t\t\tboolean = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(i==1){\n\t\t\t\tif((arr[1][0]==\"1\"&&arr[0][3]==\"1\")||(arr[1][1]==\"1\"&&arr[3][3]==\"1\")||(arr[1][2]==\"1\"&&arr[2][3]==\"1\")){\n\t\t\t\t\tboolean = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(i==2){\n\t\t\t\t\tif((arr[2][0]==\"1\"&&arr[1][3]==\"1\")||(arr[2][1]==\"1\"&&arr[0][3]==\"1\")||(arr[2][2]==\"1\"&&arr[3][3]==\"1\")){\n\t\t\t\t\tboolean = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(i==3){\n\t\t\t\t\tif((arr[3][0]==\"1\"&&arr[0][3]==\"1\")||(arr[3][1]==\"1\"&&arr[1][3]==\"1\")||(arr[3][2]==\"1\"&&arr[2][3]==\"1\")){\n\t\t\t\t\tboolean = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif(boolean){\n\t\tprintf(\"%s\",\"YES\");\n\t}else{\n\t\tprintf(\"%s\",\"NO\");\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f3eaa08308cc65042bbd64a8a3457b84", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\nbool road[5][5];\nint main(int argc, char** argv) {\n\tfor(int i=1;i<=4;i++){\n\t\tfor(int j=1;j<=4;j++)\n\t\t\tcin>>road[i][j];\n\t}\n\tfor(int i=1;i<=4;i++){\n\t\tfor(int j=1;j<=4;j++){\n\t\t if(road[i][j] == 1 && i == 4 && j == 4){\n\t\t\t\tif(road[i-1][j-1] == 1 || road[i-2][j-2] == 1 || road[i-3][j-3] == 1){\n\t\t\t\t\tcout<<\"YES\";\n\t\t\t\t\treturn 0;\n\t\t\t}else if(road[i][4] == 1){\n\t\t\t\tif(road[i][1] == 1 || road[i][2] == 1 || road[i][3] == 1){\n\t\t\t\t\tcout<<\"YES\";\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tif(road[i+1][j] == 1 || road[i+2][j+1] == 1 || road[i+3][j+2] == 1){\n\t\t\t\t\tcout<<\"YES\";\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tcout<<\"NO\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8fda9e751c5cae7de23df89f1d0ba239", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n\nint main()\n{\n int a[4][4],count=0;\n for(int i=0;i<4;i++)\n for(int j=0;j<4;j++)\n cin>>a[i][j];\n for(i=0;i<4 && count=0;i++)\n {\n if(a[i][3]==1)\n {\n for(int k=0;k<3;k++)\n {if(a[i][k]==1)\n count++;}\n if(a[(i+1)%4][0]==1 && count==0)\n count++;\n else\n if(a[(i-1)%4][0]==1 && count==0)\n count++;\n \n }\n }\n if(count==0)\n cout<<\"NO\";\n else\n cout<<\"YES\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8ee19747cef33ee59fdfaf0757e2d86b", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "int main()\n{\n int a,b,i,j,n;\n int q[5][5];\n for(i=1;i<=4;i++)\n {\n for(j=1;j<=4;j++)\n {\n cin>>q[i][j];\n\n\n }\n }\n int h;\n h=1;\n\n if((q[1][1]==1||q[1][2]==1||q[1][3]==1)&&q[1][4]==1)\n {\n h= 0;\n cout<<\"YES\";\n return 0 ;\n }\n else if((q[2][1]==1||q[3][1]==1||q[4][3]==1)&&q[1][4]==1)\n {\n h=0;\n cout<<\"YES\";\n return 0 ;\n }\n else if((q[2][1]==1||q[2][2]==1||q[2][3]==1)&&q[2][4]==1)\n {\n h= 0;\n cout<<\"YES\";\n return 0 ;\n }\n else if((q[1][3]==1||q[3][1]==1||q[4][2]==1)&&q[2][4]==1)\n {\n h=0;\n cout<<\"YES\";\n return 0 ;\n }\n else if((q[3][1]==1||q[3][2]==1||q[3][3]==1)&&q[3][4]==1)\n {\n h= 0;\n cout<<\"YES\";\n return 0 ;\n }\n else if((q[1][2]==1||q[2][3]==1||q[4][1]==1)&&q[3][4]==1)\n {\n h=0;\n cout<<\"YES\";\n return 0 ;\n }\n else if((q[4][1]==1||q[4][2]==1||q[4][3]==1)&&q[4][4]==1)\n {\n h= 0;\n cout<<\"YES\";\n return 0 ;\n }\n else if((q[1][1]==1||q[3][3]==1||q[2][2]==1)&&q[1][4]==1)\n {\n h=0;\n cout<<\"YES\";\n return 0 ;\n }\n\n if(h==1)\n {cout<<\"NO\";\n return 0 ;\n }\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "febe60535704ca93ce4cbd3abe5c171c", "src_uid": "44fdf71d56bef949ec83f00d17c29127", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\nint n,m,k;\nint minn=INT_MAX;\nint maxx=0;\nvoid nhap()\n{\n scanf(\"%d%d%d\",&n,&m,&k);\n for(int i=1;i<=n;i++)\n {\n int x;\n scanf(\"%d\",&x);\n minn=min(minn,x);\n }\n for(int i=1;i<=m;i++)\n {\n int x;\n scanf(\"%d\",&x);\n maxx=max(maxx,max);\n }\n if(maxx-minn<0)\n cout<\ntypedef long long int lli;\ntypedef unsigned long long int ulli;\ntypedef long double ld;\n#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n#define pb push_back\n#define eb emplace_back\n#define vi vector \n#define vlli vector \n#define vulli vector \n#define vchar vector \n#define vstr vector \n#define vb vector \n#define fst first\n#define sec second\n#define srt(a) sort(a.begin(),a.end())\n#define rev(a) reverse(a.begin(),a.end())\n#define vpii vector >\n#define pii pair \n#define vplli vector >\n#define vvi vector >\n#define vvlli vector >\n#define vvpii vector > >\n#define fr(i,n) for (int i = 0; i < (n); ++i)\n#define frbig(i,n) for (lli i = 0; i < (n); ++i)\n#define fra(i,a,n) for (lli i = a; i < (n); ++i)\n#define run(c,s) for(auto c:s) \n#define read(n) int n; cin >> n;\n#define readchar(n) char n; cin >> n;\n#define readstr(n) string n; cin >> n;\n#define readarr(a,n) fr(i,n) cin >> a[i];\n#define read2(x,y) int x,y; cin >> x >> y;\n#define read2ll(x,y) long long int x,y; cin >> x >> y;\n#define readll(n) lli n; cin >> n;\n#define watch(x) cout << (#x) << \" is \" << (x) << endl\n#define print_array(x) fr(i,x.size()) cout << x[i] << \" \";\nusing namespace std;\n \nconst lli MOD=1e9+7;\nconst lli MAXN=1e6+1;\nconst ld PI=acos(-1);\n\nint main(){\n rapgame\n int t=1;\n //cin>>t;\n while(t--){\n read2(n,m);read(r);\n vi a(n),b(m);\n int counter=0;\n fr(i,n){\n cin >> a[i];\n }\n fr(i,m) cin >> b[i];\n srt(a);\n srt(b);\n fr(i,n){\n if(a[i]\n\n \n \n Debug\n Win32\n \n \n Release\n Win32\n \n \n Debug\n x64\n \n \n Release\n x64\n \n \n \n 15.0\n {EEBDFC67-0DE9-43EF-A2A3-4BA47538A6C3}\n Win32Proj\n ConsoleApplication39\n 10.0.17134.0\n \n \n \n Application\n true\n v141\n Unicode\n \n \n Application\n false\n v141\n true\n Unicode\n \n \n Application\n true\n v141\n Unicode\n \n \n Application\n false\n v141\n true\n Unicode\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n true\n \n \n true\n \n \n false\n \n \n false\n \n \n \n Use\n Level3\n Disabled\n true\n WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)\n true\n \n \n Console\n true\n \n \n \n \n Use\n Level3\n Disabled\n true\n _DEBUG;_CONSOLE;%(PreprocessorDefinitions)\n true\n \n \n Console\n true\n \n \n \n \n Use\n Level3\n MaxSpeed\n true\n true\n true\n WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)\n true\n \n \n Console\n true\n true\n true\n \n \n \n \n Use\n Level3\n MaxSpeed\n true\n true\n true\n NDEBUG;_CONSOLE;%(PreprocessorDefinitions)\n true\n \n \n Console\n true\n true\n true\n \n \n \n \n \n \n \n \n \n Create\n Create\n Create\n Create\n \n \n \n \n \n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0ecf945a112a3580a0289625c1bff808", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#define lli long long\n#define ull unsigned long long\n#define f(a,k,m) for(int a=k ; a=m ; a--)\n#define rfl(a,k,m) for(long a=k ; a>=m ; a--)\n#define rfll(a,k,m) for(lli a=k ; a>=m ; a--)\n#define pb push_back\n#define mp make_pair\n#define pq priority_queue\n#define M 1000000007\n#define Mcf 998244353\nusing namespace std ;\nint main(){\n long n, m,r ; \n cin >> n >> m >> r ;\n long b[n] ;\n fl(i,0,n) cin >> b[i] ;\n long s[m] ;\n fl(i,0,m) cin >> s[i] ;\n long* x,*y;\n x = min_element(b,b+n) ;\n y = max_element(s,s+m) ;\n \n if((*x)>=(*y)){\n cout << r ;\n }\n \n if(r/(*x) > 0 && (*y) > (*x)) {\n cout << r - x*(r/(*x)) + y*(r/(*x)) ;\n \n }\n \n\treturn 0 ;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "85de1efc88705a3af0c4adb455ec57e1", "src_uid": "42f25d492bddc12d3d89d39315d63cb9", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint main()\n{\n long long n,c=0;\n \n \n scanf(\"%I64d\",&n);\n char s[n];\n scanf(\"%s\",s);\n for(int i=0; i\n#include\n#include\n#include\n#include\nusing namespace std;\nbool r[100];\nlong long num[100];\nint main()\n{\n int n;\n char x;\n long long ans=0;\n scanf(\"%d\",&n);\n for(int i=1;i<=n;i++)\n {\n x=getchar();\n while(x<30)\n x=getchar();\n b[i]=(x=='R'?1:0);\n }\n num[1]=1;\n for(int i=2;i<=n;i++)\n num[i]=2*num[i-1]+1;\n for(int i=1;i<=n;i++)\n if(r[i])\n ans+=num[i]-num[i-1];\n printf(\"%lld\\n\",ans);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "16d8f1d47673dcf9419933e4d9334ef4", "src_uid": "d86a1b5bf9fe9a985f7b030fedd29d58", "difficulty": null} {"lang": "GNU C++", "source_code": "#include \nint64_t u(int64_t a, int64_t b);\nint main()\n{\n\n\tint n;\n\tscanf(\"%d\\n\", &n);\n\tchar s[1000];\n\tint64_t t = 0;\n\tfor ( int64_t i = 0; i < n; i++)\n\t{\n\t\tscanf(\"%c\", &s[i]);\n\t\t if (s[i] == 'B')\n\t\t{\n\t\t\tt += u(2, i);\n\t\t}\n\t}\n\tprintf(\"\\n%I64d\", t);\n}\n\nint64_t u( int64_t a, int64_t b)\n{\n\tif (b == 0)\n\t\treturn 1;\n\tif (b == 1)\n\t\treturn a;\n\tif (b == 2)\n\t\treturn a * a;\n\treturn u(u(a, b / 2), 2) * (b % 2 ? a : 1);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8f5cbbfa46473485ba3a9797ee94d0c1", "src_uid": "d86a1b5bf9fe9a985f7b030fedd29d58", "difficulty": null} {"lang": "GNU C++14", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main()\n{\n\tint n,red=0;\n\tstring s;\n\tint cnt = 0;\n \n\tcin >> n;\n\tcin >> s;\n\n\treverse(s.begin(),s.end());\n\n\twhile(1) {\n//\t\tcout << \"ok1\\n\";\n\t\twhile(s.length()>0 && s[s.length()-1]=='R')\t\n\t\t{\n\t\t\ts = s.substr(0,s.length()-1);\n\t\t}\n\t\tif(s.length()==0) break;\n\t\ts[s.length()-1]='R';\n\t\twhile(s.length()\n\nusing namespace std;\nconst int MAXN = 100010;\n\nint n, a[MAXN];\n\nint main() {\n int t = 2e9, a = 10;\n for( int i = 0; i < t; ++i ) a *= 10;\n\tscanf( \"%d\", &n );\n\tfor( int i = 0; i < n; ++i ) scanf( \"%d\", a+i );\n\tsort( a, a+n );\n\tfor( int i = 0; i < n; ++i ) printf( \"%d \", a[i] );\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "71b1e3f25727e331392a289d788f018e", "src_uid": "29e481abfa9ad1f18e6157c9e833f16e", "difficulty": 1900.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\nvoid sort (vector &x, long long size)\n{\n for (int i = 0; i < size; i++)\n {\n for (int j = i + 1; j < size; j++)\n {\n if (x[i] > x[j])\n {\n swap(x[i],x[j]);\n }\n }\n }\n}\nint main()\n{\n long long n, x;\n cin >> n;\n vector a;\n for (int i = 0; i < n; i++)\n {\n cin >> x;\n a.push_back(x);\n }\n sort(a, n);\n sort(a.begin(), a.end());\n sort(a.begin(), a.end());\n sort(a.begin(), a.end());\n multiset s;\n for (int i = 0; i < n; i++)\n {\n s.insert(a[i]);\n }\n for (auto it : s)\n {\n cout << it << \" \";\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0277f87cef5e28bfcd4a34f1874ac05a", "src_uid": "29e481abfa9ad1f18e6157c9e833f16e", "difficulty": 1900.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n\nint a[1000000];\nint main()\n{\n long long n;\n while(n--)\n cin>>a[n];\n sort(a,a+n);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "eb59a4b38e0bfe944b7f9be6d804fc47", "src_uid": "29e481abfa9ad1f18e6157c9e833f16e", "difficulty": 1900.0} {"lang": "GNU C++17", "source_code": "#include \n#define RET(_x) return std::cout << (_x) << '\\n', 0;\n#define endl \"\\n\"\nusing namespace std;\nusing ll = int64_t;\n\nint arr[15];\nint tmp[1000][1000];\n\nint main() {\n auto start = chrono::high_resolution_clock::now();\n std::ios_base::sync_with_stdio(false);\n std::cin.tie(nullptr);\n \n int n;\n cin >> n;\n for (int i = 0; i < n; ++i) {\n cin >> arr[i];\n }\n sort(arr, arr + n);\n\n tmp[0][0][0] = 1;\n for (int i = 0; i < 100; ++i) {\n for (int j = 0; j < 1000; ++j) {\n for (int k = 0; k < 1000; ++k) {\n if (k && j < 999) {\n tmp[j][k] = tmp[j + 1][k - 1] + arr[i % n] + (k & 1) + (i % 3);\n }\n }\n }\n }\n arr[n] = tmp[5][743][101];\n\n for (int i = 0; i < n; ++i) {\n cout << arr[i] << ' ';\n }\n\n cerr << \"\\nTotal execution time : \" << chrono::duration_cast(chrono::high_resolution_clock::now() - start).count() << \" ms\\n\";\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "07f06c88fb114b1e7dacf23581ba2ef3", "src_uid": "29e481abfa9ad1f18e6157c9e833f16e", "difficulty": 1900.0} {"lang": "GNU C++11", "source_code": "/* \n\t\u000f Arafat Mukhametkazin \u000f \n All rights reserved \n \u0002 ALMATY 2016 \u0002 \n*/ \n#include \n\n#define f first\n#define s second\n#define mp make_pair\n#define pb push_back\n#define ll long long\n#define sz(x) x.size()\n#define all(x) x.begin(), x.end()\n#define pii pair < int , int >\n\nusing namespace std;\n\nconst int N = 1e3 + 123;\nconst int mod = 1e9 + 7;\nconst int INF = 1e9 + 1;\nconst ll INFL = 1e18 + 1;\nconst double eps = 1e-9;\nconst double pi = acos(-1.0);\n\nint main () {\n\nint n, cnt;\nchar x;\n\nint main() {\n\tcin >> n;\n\tbool ok = 1;\n for (int i = 1;i <= n;i ++) {\n cin >> x;\n if (ok == 1)\n cnt ++;\n if (x == '0')\n ok = 0;\n }\n cout << cnt;\nreturn 0; \n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1a062e6d61a241f0451c9570c512687f", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\nint main(){\n int n,maxx=0;;\n string s;\n cin>>n>>s;\n for(int i=0;i\nusing namespace std;\n\nint main()\n{\n int n,r,change=0,x;\n cin>>n;\n char arr[n];\n for(int i=0;i>arr[i];\n }\n for(int i=0;i\nusing namespace std;\nconst long long mo=1e9+9;\nlong long n, x, ans;\nchar m;\n\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\n cin >> n;\n for(x=0; x> m;\n if( m=='0' ) ++x, break;\n }\n\n cout << x << \"\\n\";\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "94db9817b53d98506341dee9daa3c74f", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include\n#define re register\nstruct eg{int to,c,nx;}e[20010];\nint la[10010],cur[10010],qq[10100],d[10100],ta,cnt=1;\nint S,T,N;\ninline void addE(re int a,re int b,re int c)\n{\n\te[++cnt]=(eg){b,c,la[a]};la[a]=cnt;\n\te[++cnt]=(eg){a,0,la[b]};la[b]=cnt;\n}\nbool bfs()\n{\n\tmemset(d,0,sizeof(d));\n\tmemcpy(cur,la,sizeof(la));\n\tqq[ta=1]=T;d[T]=1;\n\tfor(re int i=1;i<=ta;i++)\n\t{\n\t\tre int x=qq[i];\n\t\tfor(re int j=la[x];j;j=e[j].nx)if(e[j^1].c&&!d[e[j].to])\n\t\t{\n\t\t\td[e[j].to]=d[x]+1;\n\t\t\tif(e[j].to==S)return 1;\n\t\t\tqq[++ta]=e[j].to;\n\t\t}\n\t}\n\treturn 0;\n}\nint dfs(re int x,re int fl)\n{\n\tif(x==T)return fl;\n\tre int ff=fl;\n\tfor(re int&j=cur[x];j;j=e[j].nx)if(e[j].c&&d[e[j].to]==d[x]-1)\n\t{\n\t\tre int c=dfs(e[j].to,std::min(e[j].c,ff));\n\t\tif(c)\n\t\t{\n\t\t\tff-=c;e[j].c-=c;e[j^1].c+=c;\n\t\t\tif(!ff)return fl;\n\t\t}else d[e[j].to]=0;\n\t}\n\treturn fl-ff;\n}\nint nans;\nint dinic()\n{\n\tre int ans=0;\n\tfor(;bfs();ans+=dfs(S,1<<30));\n\treturn ans;\n}\nint n,m,k,q,nc[20][20010],f[2011],S1,ww[20],ws[2011],lg[2011];\nvoid dfs(re int nn)\n{\n\tif(nn>=k){f[S1]=nans;return;}\n\tdfs(nn+1);\n\tS1+=(1<\n#define re register\nstruct eg{int to,c,nx;}e[20010];\nint la[10010],cur[10010],qq[10100],d[10100],ta,cnt=1;\nint S,T,N;\ninline void addE(re int a,re int b,re int c)\n{\n\te[++cnt]=(eg){b,c,la[a]};la[a]=cnt;\n\te[++cnt]=(eg){a,0,la[b]};la[b]=cnt;\n}\nbool bfs()\n{\n\tmemset(d,0,sizeof(d));\n\tmemcpy(cur,la,sizeof(la));\n\tqq[ta=1]=T;d[T]=1;\n\tfor(re int i=1;i<=ta;i++)\n\t{\n\t\tre int x=qq[i];\n\t\tfor(re int j=la[x];j;j=e[j].nx)if(e[j^1].c&&!d[e[j].to])\n\t\t{\n\t\t\td[e[j].to]=d[x]+1;\n\t\t\tif(e[j].to==S)return 1;\n\t\t\tqq[++ta]=e[j].to;\n\t\t}\n\t}\n\treturn 0;\n}\nint dfs(re int x,re int fl)\n{\n\tif(x==T)return fl;\n\tfor(re int&j=cur[x];j;j=e[j].nx)if(e[j].c&&d[e[j].to]==d[x]-1)\n\t{\n\t\tre int c=dfs(e[j].to,std::min(e[j].c,ff));\n\t\tif(c)\n\t\t{\n\t\t\tff-=c;e[j].c-=c;e[j^1].c+=c;\n\t\t\tif(!ff)return fl;\n\t\t}\n\t}\n\treturn fl-ff;\n}\nint nans;\nint dinic()\n{\n\tre int ans=0;\n\tfor(;bfs();ans+=dfs(S,1<<30));\n\treturn ans;\n}\nint n,m,k,q,nc[20][20010],f[2011],S1,ww[20],ws[2011],lg[2011];\nvoid dfs(re int nn)\n{\n\tif(nn>=k){f[S1]=nans;return;}\n\tdfs(nn+1);\n\tS1+=(1<\n\n#include \n\n#include \n\n#include \n\n#include \n\n#include \n\n#include \n\n#include \n\n#include \n\n#include \n\n#include \n\n#include \n\n#include \n\n#include \n\n#include \n\n#include \n\nusing namespace std;\n\nusing uint = unsigned int;\nusing ll = long long;\nusing ull = unsigned long long;\nconstexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }\ntemplate using V = vector;\ntemplate using VV = V>;\n\n\n\n#include \n\nstruct Scanner {\n int fd = -1;\n char line[(1 << 15) + 1];\n size_t st = 0, ed = 0;\n void reread() {\n memmove(line, line + st, ed - st);\n ed -= st;\n st = 0;\n ed += ::read(fd, line + ed, (1 << 15) - ed);\n line[ed] = '\\0';\n }\n bool succ() {\n while (true) {\n if (st == ed) {\n reread();\n if (st == ed) return false;\n }\n while (st != ed && isspace(line[st])) st++;\n if (st != ed) break;\n }\n if (ed - st <= 50) {\n bool sep = false;\n for (size_t i = st; i < ed; i++) {\n if (isspace(line[i])) {\n sep = true;\n break;\n }\n }\n if (!sep) reread();\n }\n return true;\n }\n template ::value, int> = 0>\n bool read_single(T& ref) {\n if (!succ()) return false;\n while (true) {\n size_t sz = 0;\n while (st + sz < ed && !isspace(line[st + sz])) sz++;\n ref.append(line + st, sz);\n st += sz;\n if (!sz || st != ed) break;\n reread();\n }\n return true;\n }\n template ::value>* = nullptr>\n bool read_single(T& ref) {\n if (!succ()) return false;\n bool neg = false;\n if (line[st] == '-') {\n neg = true;\n st++;\n }\n ref = T(0);\n while (isdigit(line[st])) {\n ref = 10 * ref + (line[st++] & 0xf);\n }\n if (neg) ref = -ref;\n return true;\n }\n template bool read_single(V& ref) {\n for (auto& d : ref) {\n if (!read_single(d)) return false;\n }\n return true;\n }\n void read() {}\n template void read(H& h, T&... t) {\n bool f = read_single(h);\n assert(f);\n read(t...);\n }\n int read_unsafe() { return 0; }\n template int read_unsafe(H& h, T&... t) {\n bool f = read_single(h);\n if (!f) return 0;\n return 1 + read_unsafe(t...);\n }\n Scanner(FILE* fp) : fd(fileno(fp)) {}\n};\n\nstruct Printer {\n public:\n template void write() {}\n template \n void write(const H& h, const T&... t) {\n if (F) write_single(' ');\n write_single(h);\n write(t...);\n }\n template void writeln(const T&... t) {\n write(t...);\n write_single('\\n');\n }\n\n Printer(FILE* _fp) : fp(_fp) {}\n ~Printer() { flush(); }\n\n private:\n static constexpr size_t SIZE = 1 << 15;\n FILE* fp;\n char line[SIZE], small[50];\n size_t pos = 0;\n void flush() {\n fwrite(line, 1, pos, fp);\n pos = 0;\n }\n void write_single(const char& val) {\n if (pos == SIZE) flush();\n line[pos++] = val;\n }\n template ::value>* = nullptr>\n void write_single(T val) {\n if (pos > (1 << 15) - 50) flush();\n if (val == 0) {\n write_single('0');\n return;\n }\n if (val < 0) {\n write_single('-');\n val = -val; // todo min\n }\n size_t len = 0;\n while (val) {\n small[len++] = char(0x30 | (val % 10));\n val /= 10;\n }\n for (size_t i = 0; i < len; i++) {\n line[pos + i] = small[len - 1 - i];\n }\n pos += len;\n }\n void write_single(__int128 val) {\n if (pos > (1 << 15) - 50) flush();\n if (val == 0) {\n write_single('0');\n return;\n }\n if (val < 0) {\n write_single('-');\n val = -val; // todo min\n }\n size_t len = 0;\n while (val) {\n small[len++] = char(0x30 | (val % 10));\n val /= 10;\n }\n for (size_t i = 0; i < len; i++) {\n line[pos + i] = small[len - 1 - i];\n }\n pos += len;\n }\n\n void write_single(const string& s) {\n for (char c : s) write_single(c);\n }\n void write_single(const char* s) {\n size_t len = strlen(s);\n for (size_t i = 0; i < len; i++) write_single(s[i]);\n }\n template void write_single(const V& val) {\n auto n = val.size();\n for (size_t i = 0; i < n; i++) {\n if (i) write_single(' ');\n write_single(val[i]);\n }\n }\n};\n\nnamespace internal {\n\ntemplate struct simple_queue {\n std::vector payload;\n int pos = 0;\n void reserve(int n) { payload.reserve(n); }\n int size() const { return int(payload.size()) - pos; }\n bool empty() const { return pos == int(payload.size()); }\n void push(const T& t) { payload.push_back(t); }\n T& front() { return payload[pos]; }\n void clear() {\n payload.clear();\n pos = 0;\n }\n void pop() { pos++; }\n};\n\n} // namespace internal\n\ntemplate struct mf_graph {\n public:\n mf_graph() : _n(0) {}\n mf_graph(int n) : _n(n), g(n) {}\n\n int add_edge(int from, int to, Cap cap) {\n assert(0 <= from && from < _n);\n assert(0 <= to && to < _n);\n int m = int(pos.size());\n pos.push_back({from, int(g[from].size())});\n g[from].push_back(_edge{to, int(g[to].size()), cap});\n g[to].push_back(_edge{from, int(g[from].size()) - 1, 0});\n return m;\n }\n\n struct edge {\n int from, to;\n Cap cap, flow;\n };\n\n edge get_edge(int i) {\n int m = int(pos.size());\n assert(0 <= i && i < m);\n auto _e = g[pos[i].first][pos[i].second];\n auto _re = g[_e.to][_e.rev];\n return edge{pos[i].first, _e.to, _e.cap + _re.cap, _re.cap};\n }\n std::vector edges() {\n int m = int(pos.size());\n std::vector result;\n for (int i = 0; i < m; i++) {\n result.push_back(get_edge(i));\n }\n return result;\n }\n void change_edge(int i, Cap new_cap, Cap new_flow) {\n int m = int(pos.size());\n assert(0 <= i && i < m);\n assert(0 <= new_flow && new_flow <= new_cap);\n auto& _e = g[pos[i].first][pos[i].second];\n auto& _re = g[_e.to][_e.rev];\n _e.cap = new_cap - new_flow;\n _re.cap = new_flow;\n }\n\n Cap flow(int s, int t) {\n return flow(s, t, std::numeric_limits::max());\n }\n Cap flow(int s, int t, Cap flow_limit) {\n assert(0 <= s && s < _n);\n assert(0 <= t && t < _n);\n\n std::vector level, iter;\n\n auto bfs = [&]() {\n internal::simple_queue que;\n level = std::vector(_n, -1);\n level[s] = 0;\n que.push(s);\n while (!que.empty()) {\n int v = que.front();\n que.pop();\n for (auto e : g[v]) {\n if (e.cap == 0 || level[e.to] >= 0) continue;\n level[e.to] = level[v] + 1;\n if (e.to == t) return;\n que.push(e.to);\n }\n }\n };\n auto dfs = [&](auto self, int v, Cap up) {\n if (v == t) return up;\n Cap res = 0;\n for (int& i = iter[v]; i < int(g[v].size()); i++) {\n _edge& e = g[v][i];\n if (e.cap == 0 || level[v] >= level[e.to]) continue;\n Cap d = self(self, e.to, std::min(up, e.cap));\n e.cap -= d;\n g[e.to][e.rev].cap += d;\n res += d;\n up -= d;\n if (up == 0) break;\n }\n return res;\n };\n\n Cap flow = 0;\n while (flow < flow_limit) {\n bfs();\n if (level[t] == -1) break;\n iter = std::vector(_n, 0);\n while (flow < flow_limit) {\n Cap f = dfs(dfs, s, flow_limit - flow);\n if (!f) break;\n flow += f;\n }\n }\n return flow;\n }\n\n private:\n int _n;\n struct _edge {\n int to, rev;\n Cap cap;\n };\n std::vector> pos;\n std::vector> g;\n};\n\nScanner sc = Scanner(stdin);\nPrinter pr = Printer(stdout);\nconst int MAX_W = 25;\n\nint main() {\n int n, m, k, q;\n sc.read(n, m, k, q);\n\n mf_graph g(n + 2 * k);\n\n for (int i = 0; i < k; i++) {\n int a, b, c;\n sc.read(a, b, c); a--; b--;\n g.add_edge(a, n + 2 * i, MAX_W);\n g.add_edge(n + 2 * i + 1, b, MAX_W);\n }\n\n for (int i = k; i < m; i++) {\n int a, b, c;\n sc.read(a, b, c); a--; b--;\n g.add_edge(a, b, c);\n }\n\n int basic = g.flow(0, n - 1);\n V mincut(1 << k, basic);\n V edge_id(k, -1);\n int extra_flow = 0;\n for (int f = 1; f < (1 << k); f++) {\n // i-th edge must not be cut\n\n/* auto g2 = g;\n for (int i = 0; i < k; i++) {\n if (f & (1 << i)) {\n g2.add_edge(n + 2 * i, n + 2 * i + 1, MAX_W);\n }\n }\n mincut[((1 << k) - 1) ^ f] += g2.flow(0, n - 1);*/\n\n for (int i = 0; i < k; i++) {\n if (f & (1 << i)) {\n // add edge\n edge_id[i] = g.add_edge(n + 2 * i, n + 2 * i + 1, MAX_W);\n extra_flow += g.flow(0, n - 1);\n break;\n } else {\n // remove edge\n auto e = g.get_edge(edge_id[i]);\n // reverse e.flow\n g.change_edge(edge_id[i], 0, 0);\n extra_flow -= e.flow;\n\n int rem = e.flow;\n rem -= g.flow(n + 2 * i, n + 2 * i + 1, rem);\n int deb;\n deb = g.flow(n + 2 * i, 0, rem);\n assert(deb == rem);\n deb = g.flow(n - 1, n + 2 * i + 1, rem);\n assert(deb == rem);\n }\n }\n mincut[((1 << k) - 1) ^ f] = basic + extra_flow;\n }\n\n // TL OK\n for (int ph = 0; ph < q; ph++) {\n V cost(k);\n for (int i = 0; i < k; i++) {\n sc.read(cost[i]);\n }\n int ans = mincut[0];\n int extra_cut = 0;\n for (int f = 1; f < (1 << k); f++) {\n/* int cut = mincut[f];\n for (int i = 0; i < k; i++) {\n if (f & (1 << i)) {\n cut += cost[i];\n }\n }*/\n for (int i = 0; i < k; i++) {\n if (f & (1 << i)) {\n extra_cut += cost[i];\n break;\n } else {\n extra_cut -= cost[i];\n }\n }\n ans = min(ans, mincut[f] + extra_cut);\n }\n pr.writeln(ans);\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "682dcf94e2cfa17bcdbac92f64683817", "src_uid": "7421c7d81cc7b481d61a6ef07e557e33", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint main(){\n unsigned long long int LIMIT=998244353;\n unsigned long long int c;\n cin>>c>>q;\n unsigned long long int x=1;\n while(c--){\n x=(2*x)%LIMIT;\n }\n while(q--){\n x=(2*x)%LIMIT;\n }\n cout<\n#include \n#include \n#include \nusing namespace std;\nlong long a, b, ret;\nconst int mod = 998244353;\n\nint main(){\n cin >> a >> b;\n ret = (1 << a * b) % mod\n cout << ret << \"\\n\";\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "89b23a31f5c4892b27f00bfecb4fe0eb", "src_uid": "8b2a9ae21740c89079a6011a30cd6aee", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n\ntypedef long long ll;\n\nll choose(ll n,ll k);\nbool isprime(ll n);\nll power(ll x,ll y,ll p);\n\nint main()\n{\n int w,h; cin>>w>>h;\n cout<0)\n {\n if(y&1)\n res=(res*x)%p;\n y=y>>1;\n x=(x*x)%p;\n }\n return res;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "035a0ee45b126e204b55891ab0cee53d", "src_uid": "8b2a9ae21740c89079a6011a30cd6aee", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include\n#define ll long long\n#define ld long double\n#define pb push_back\n#define ff first\n#define ss second\n#define mp make_pair\n#define ins insert\n#define sb substr\n#define con continue\n#define ub upper_bound\n#define lb lower_bound\n#define pll pair\n#define pld pair\nusing namespace std;\nll power(ll x, ll y);\nbool isPrime(ll n);\nvector X[200001], Y[200001];\nll A[200001], B[200001];\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n ll a,b,c,d,n,m,i,j,k,l,p,q,x,y,z,cnt=0, flag=0;\n string s1, s2, s3;\n vector V, W;\n vector :: iterator itrv;\n map M;\n set S;\n set :: iterator itrs;\n cin>>n>>m;\n if(((n+m)%2)==0)cout< 0){\n if (y & 1) res = res*x;\n y = y>>1;\n x = x*x;\n }\n return res;\n}\nbool isPrime(ll n){\n if (n <= 1) return false;\n if (n <= 3) return true;\n if (n%2 == 0 || n%3 == 0) return false;\n ll p=sqrt(n);\n for(int i=5;i<=p;i=i+6)\n if (n%i == 0 || n%(i+2) == 0)\n return false;\n return true;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8b1f540b8618c1d691d9d473d10b0135", "src_uid": "8b2a9ae21740c89079a6011a30cd6aee", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "#include\n#define ll long long int\nusing namespace std;\nint main()\n{\n ll a,b,c;\n cin>>a>>b>>>c;\n cout<<(b*c+(b+c-1)*(a-1))<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nconst int INF=2147483647;\nconst double eps=1e-8;\nconst double PI=acos(-1);\n\nconst int mod = 100000007;\n\nint main()\n{\n int a,b,c;\n while(cin>>a>>b>>c)\n {\n int ans=a*b+b*c+c*a-a-b-c+1\n cout<\n#include\n#include\n#include\nusing namespace std;\nint a,b,c;\nint main()\n{\n while(scanf(\"%d%d%d\",&a,&b,&c)!=EOF)\n {\n printf(\"%d\\n\",b*c+c+b-1);2 \n }\n return 0;\n}\n\n\n/*ptdsnbhpifsboldliksjdhgnsbbetqqgpmeanlpojfppikgrae*/", "lang_cluster": "C++", "compilation_error": true, "code_uid": "516462c90d6070ba74c8c29a37fcfd9e", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define ll long long\n\nint main(){\n int a, b, c, cnt=0, sum=0, ans=0;\n\n scanf(\"%d%d%d\",&a,&b,&c);\n \n cout<< (a * b * c) - (a - 1) * (b - 1) * (c - 1);\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f47666702f3fda70e53d855160a5094a", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main(){\n unsigned long n,half;\n long count=0;\n double quarter;\n cin>>n;\n if(n%2 == 0)\n half = n/2;\n quarter = half/2;\n for(long i=1;i<(long)(ceil(quarter));i++){\n count++;\n }\n cout<\nusing namespace std;\nint main(){\n\tint n;\n\tcin >> n;\n\tif(n % 2){\n\t\tcout << '0';\n\t\treturn 0;\n\t}\n\tn /= 2;\n\telse if(n % 2){\n\t\tcout << (n + 1) / 2 - 1;\n\t}\n\telse{\n\t\tcout << n / 2 - 1;\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d3b89fbd55fbcd7b6400cbe4fce26139", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nint main(){\n int n;\n cin>>n;\n int c = (n/2);\n int b = (int)ceil(c/2.0);\n cout<<(b-1)<\n\n#pragma GCC optimize(\"O2\")\nusing namespace std;\n#define ll long long\n#define rep(i,n,N) for(ll i=n;i<=N;i++)\n#define rap(i,n,N) for(int i=(int)n;i>=(int)N;i--)\n#define mp make_pair\n#define pb push_back\n#define pob pop_back\n#define pf push_front\n#define pof pop_front\n#define fi first\n#define se second\n#define sf se.fi\n#define ss se.se\n#define pii pair \n#define pll pair\n#define piii pair\n#define endl \"\\n\"\nconst ll MAX=1e5+5;\nconst int MOD=1000000000 + 7;\nconst ll INF=1e18;\nconst int dr[]={0,1,0,-1,1,1,-1,-1, 2,2,-2,-2,1,1,-1,-1};\nconst int dc[]={1,0,-1,0,1,-1,1,-1, 1,-1,1,-1,2,-2,2,-2};\n\nint n,m,tc,a,b,x[105][105],y[105],sz,cnt,tmp,res;\nstring s,t;\nbool vis[105];\n\nint main(){\n //cout<>n;\n if(n&1 && n<6)return cout<0,0;\n cout<<(n-2)/4;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d4e54e390a5a0061287d7c620754ed42", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\n{\n ll a,b;\n for(ll i=1;;i++)\n {\n if(a<=0)\n {\n cout<<\"Valera\";\n return 0;\n }\n else if(b<=0)\n {\n cout<<\"Vladik\";\n return 0;\n }\n a=a-n*n;\n b=b-((n*n)+n);\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ec58baeb721606b2b56dadfacd445594", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nint main(){\n \n int vla,val;\n \n cin>>vla>>val;\n \n for(int i=0;;i++){\n if (i&1 == 0){\n vla -= i;\n if (vla < 0 ) cout<<\"Valera\\n\",return 0;\n }\n \n else {\n val -= i;\n if (val < 0 ) cout<<\"Vladik\\n\",return 0;\n }\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6a8554564ca8f3e03ccbd6ce06e82371", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n\nusing namespace std;\n\nint main()\n{\n double a,b,flag=0,n1,x1,x2,n2,a1,b1,c,fractpart1,fractpart2,intpart1,intpart2,sn,tn;\n \n if(a<1)\n {\n flag=1;\n cout<<\"Vladik\";\n } \n \n if(b<2)\n {\n flag=1;\n cout<<\"Valera\";\n }\n \n if(flag==0)\n {\n b1=1;\n a1=1;\n c=-b;\n \n n1=abs(sqrt(b));\n \n x1=((-b1)+sqrt(b1^2-(4*a1*c)))/(2*a1);\n x2=((-b1)-sqrt(b1^2-(4*a1*c)))/(2*a1);\n \n if(x1>=0)\n n2=x1;\n else\n n2=x2;\n \n fractpart1=modf(n1, &intpart1);\n fractpart2=modf(n2, &intpart2);\n \n if(fractpart1==0.000000 && fractpart2!=0.000000)\n {\n sn=(n1/2)*(4+((n1-1-1)*2));\n double y=a-sn;\n tn=1+((n2-1)*2);\n \n if(y-tn>0)\n cout<<\"Vladik\";\n else\n cout<<\"Valera\";\n \n }\n else if( fractpart2==0.000000 && fractpart1!=0.000000)\n {\n sn=(n2/2)*(2+((n2-1)*2));\n double y=b-sn;\n tn=2+((n2+1-1)*2);\n \n if(y-tn>0)\n cout<<\"Valera\";\n else\n cout<<\"Vladik\";\n }\n else\n {\n if(n10)\n cout<<\"Vladik\";\n else\n cout<<\"Valera\";\n \n }\n else\n {\n sn=(n2/2)*(2+((n2-1)*2));\n double y=b-sn;\n tn=2+((n2+1-1)*2);\n \n if(y-tn>0)\n cout<<\"Valera\";\n else\n cout<<\"Vladik\";\n \n }\n }\n \n }\n \n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "79e7609106ad308796592f23f8043f8b", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint main ()\n{\n\tint a,b;\n\tcin>>a>>b;\n\tint i = 0;\n\tint cur = 1;\n\twhile (a >= 0 && b >= 0)\n\t{\n\t\tif (i % 2 == 0) a -= cur;\n\t\telse b-=cur;\n\t\tif (b <= 0) {cout<<\"Vladik\";return 0;}\n\t\tif (a <= 0) cout<<\"Valera\";return 0;}\n\t\ti++;\n\t\tcur++;\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7f47f464187d88808bf6a6c0242f6e47", "src_uid": "87e37a82be7e39e433060fd8cdb03270", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n\tstring s;\n\tint n,a;\n\tcin>>s>>n;\n\tif(s=='January') a=1+n;\n\tif(s=='February') a=2+n;\n\tif(s=='March') a=3+n;\n\tif(s=='April') a=4+n;\n\tif(s=='May') a=5+n;\n\tif(s=='June') a=6+n;\n\tif(s=='July') a=7+n;\n\tif(s=='August') a=8+n;\n\tif(s=='September') a=9+n;\n\tif(s==' October') a=10+n;\n\tif(s=='November') a=11+n;\n\tif(s=='December') a=12+n;\n\ta=a%12;\n\tswitch(a)\n\t{\n\t\tcase 0:cout<<\"December\"<\nusing namespace std;\nstring a[13]={\"\",\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"};\nint main()\n{\n string cur;\n int n,k;\n cin>>cur>>n;\n for(int i=1;i<=12;i++)\n {\n if(!strcmp(c,s[i]))\n {\n k+=i;\n break;\n }\n }\n cout<\nusing namespace std;\nmain()\n{\n char str[12][12]={\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"};\n char s[12];\n cin>>s;\n int i,n,p;\n cin>>n;\n n=n%12;\n for(i=0;i<12;i++)\n {\n if(strcmp(s,str[i])==0)\n {p=i+1;break;}\n }\n p+=n;\n if(p>12)\n p=p%12;\n cout<\nusing namespace std;\nstring x,a[13]={\" \",\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"};\nint k;\ncin>>k;\nint main(){\n cin>>x;\n for (int i=1;i<=12;i++)\n if (x==a[i]) k+=i;\n k%=12;\n cout<\nusing namespace std;\n\nint main()\n{\n\tint n;\n\tcin>>n;\n\tint x=1;\n\twhile(x<=n)\n\t{\n\t\tif(n==x||n==x+1)\n\t\t{\n\t\t\tcout<<1<<'\\n';\n\t\t\treturn 0;\n\t\t}\n\t\tif(x%2==0)\n\t\t\tx=x+1+x;\n\t\telse\n\t\t\tx=(x+1)+1+x;\n\t}\n\tcout<<0;\n\treturn0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5287f4bb52ea2161a43ed3970252d885", "src_uid": "821409c1b9bdcd18c4dcf35dc5116501", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "#include\nint x=1,a[1111111];int main(){while(x<1e6)a[x++]=1,a[x]=1,x+=x/2*2;std::cin>>x;std::cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#define set0(x) memset(x,0,sizeof(x))\n#define debug(x) //cerr<<#x<<'='< void read(T &x){\n\tx = 0;char ch = getchar();int f = 1;\n\twhile(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();};\n\twhile(isdigit(ch)){x = x*10+ch-48;ch=getchar();}\n\tx*=f;\n}\n\nint mod = 998244353;\ninline int mul(int x,int y){return 1ll*x*y%mod;}\nint add(int x,int y){return x+y>=mod?x+y-mod:x+y;}\nint sub(int x,int y){return x-y<0?x-y+mod:x-y;}\nint sq(int x){return 1ll*x*x%mod;}\nint pow(int a,int b){return b == 0 ? 1 : ( b&1 ? mul(a,sq(pow(a,b/2))) : sq(pow(a,b/2)));}\nconst int N = 2200000;\n\nstruct poly{\n\tull P2 = (ull)mod*mod;\n\tint wroot = 3;\n\tint n,l,rev[N],mrt[N],rcrt[N*4] = {0},invn,MXNTT = 1<<20;\n\tvoid polysub(int a[],int b[],int c[],int sz){\n\t\tfor(int i=0;i>1]>>1)|(1<<(l-1)):(rev[i>>1]>>1);\n\t}\n\tvoid DFT(int ipt[],int typ){\n\t\t\n\t\t//typ == 0 : DFT\n\t\t//typ == 1 : IDFT\n\t\tstatic ull a[N];\n\t\tfor(int i=0;i\nusing namespace std;\n\nll n;\nint main(){\n ios_base::sync_with_stdio(0);cin.tie(0);\n cin>>n;\n ll x=1;\n while(x<=n){\n if(n==x||n==x+1){cout<<1<<\"\\n\";return 0;}\n x=(x%2==0?x*2+1:x*2+2);\n }\n cout<<\"0\\n\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "29b78c46603ce71b563b6b6c6b032ec5", "src_uid": "821409c1b9bdcd18c4dcf35dc5116501", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define For(i,n) for(int i=1;i<=n;i++)\n#define Fork(i,k,n) for(int i=k;i<=n;i++)\n#define Rep(i,n) for(int i=0;i=k;i--)\n#define RepD(i,n) for(int i=n;i>=0;i--)\n#define Forp(x) for(int p=Pre[x];p;p=Next[p])\n#define Forpiter(x) for(int &p=iter[x];p;p=Next[p]) \n#define Lson (o<<1)\n#define Rson ((o<<1)+1)\n#define MEM(a) memset(a,0,sizeof(a));\n#define MEMI(a) memset(a,127,sizeof(a));\n#define MEMi(a) memset(a,128,sizeof(a));\n#define INF (2139062143)\n#define F (1000000007)\n#define pb push_back\n#define mp make_pair \n#define fi first\n#define se second\n#define vi vector \n#define pi pair\n#define SI(a) ((a).size())\n#define Pr(kcase,ans) printf(\"Case #%d: %I64d\\n\",kcase,ans);\n#define PRi(a,n) For(i,n-1) cout<>s+1;\n\tint n=strlen(s+1);\n\tbool fl=1;\n\tif(n==1) fl=1;\n\telse {\n\t\tMEMI(h)\n\t\th[9]=5;\n\t\th[5]=9;\n\t\th[3]=3;\n\t\th[4]=6;\n\t\th[6]=4;\n\t\th[0]=8;\n\t\th[7]=7;\n\t\t\n\t\tFor(i,n%2+n/2) if (h[s[i]-'0']+'0'!=s[n-i+1])fl=0;\t\n\t}\n\tputs(fl?\"Yes\":\"No\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5dd8047386309a36f63e366e8864877a", "src_uid": "0f11f41cefd7cf43f498e511405426c3", "difficulty": 1900.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nmap h;\nstring s;\nint flag = 1;\n\nint main()\n{\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n H['3'] = '3';\n H['4'] = '6';\n H['5'] = '9';\n H['6'] = '4';\n H['7'] = '7';\n H['8'] = '0';\n H['9'] = '5';\n H['0'] = '8';\n cin >> s;\n for (int i=0; i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define LD ld\n#define LL ll\n#define ULL ull\n#define pow(a, b) pow((ld)a, (ld)b)\n#define push_back pb\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef unsigned int uint;\n\nconst int nn = (int)2000000;\nconst ld eps = 3 * 10e-8;\nconst ld eps1 = 5 * 10e-8;\nconst ull INF = (ull)(1e19 * 1.7);\nconst ull mod = 1000000007;\n\nusing namespace std;\n\nint main()\n{\n\tll a, s = 0;\n\tcin >> a;\n\twhile (a)\n\t{\n\t\ts += a % 10;\n\t\ta /= 10;\n\t}\n\tfor (int i = 2; i < sqrt(s); i++)\n\t\tif (!(s % i)) return cout << \"No\", 0;\n\tcout << \"Yes\";\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "19c1e448e6e767cfdbb7c122fcc02205", "src_uid": "0f11f41cefd7cf43f498e511405426c3", "difficulty": 1900.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nint main() {\n\tstring num;\n\tcin >> num;\n\t\n\tmap, bool> touch;\n\ttouch[{'3', '3'}] = true;\n\ttouch[{'5', '9'}] = true;\n\ttouch[{'9', '5'}] = true;\n\ttouch[{'4', '6'}] = true;\n\ttouch[{'6', '4'}] = true;\n\ttouch[{'7', '7'}] = true;\n\ttouch[{'0', '8'}] = true;\n\ttouch[{'8', '0'}] = true;\n\t\n\tint sz = num.size();\n\tfor (int i = (sz-1)/2, j = sz/2; i >= 0 and l < sz; --i, ++j) {\n\t\tif (i != j and !touch[{num[i], num[j]}]) {\n\t\t\tcout << \"NO\\n\";\n\t\t\treturn 0;\n\t\t}\n\t}\n\t\n\tcout << \"YES\\n\";\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "46711d7859c5777ca924995663003580", "src_uid": "0f11f41cefd7cf43f498e511405426c3", "difficulty": 1900.0} {"lang": "GNU C++14", "source_code": "# include \nusing namespace std;\nvoid output(int n, int base) {\n if (n == 0) return;\n output(n / base);\n printf(\"%d\", n % base);\n}\nint main() {\n int k;\n scanf(\"%d\", &k);\n for (int i = 1; i <= k; ++i) {\n for (int j = 1; j <= k; ++j) {\n output(i * j, k);\n printf(\" \");\n }\n printf(\"\\n\");\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f6c6ed6db4adf538b01eb4906affa607", "src_uid": "a705144ace798d6b41068aa284d99050", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n\nint n;\n\nstring f(int x, int y)\n{\n\tstring a = \"\";\n\twhile(x > 0)\n\t{\n\t\ta += (x % n) + '0';\n\t\tx /= n;\n\t}\t\n\treverse(a.begin(), a.end());\n\treturn a;\n}\n\nint main()\n{\n\tcin >> n;\n\tfor(int i = 1; i < n; i++)\n\t{\n\t\tfor(int j = 1; j < n; j++)\n\t\t\tcout << f(i * j, n) << \" \";\n\t\tcout << endl;\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5e719ed06fba3f322f83d807b9a98ec7", "src_uid": "a705144ace798d6b41068aa284d99050", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n int n;\n cin>>n;\n if( n==2) \n cout << 1;\n \n else if( n==3) \n cout << \"1 2\";cout << endl << \"2 11\";\n \n else if(n==4)\n cout << \"1 2 3\" << endl;\n cout << \"2 10 12\" << endl;\n cout << \"3 12 21\";\n \n else if(n==5)\n cout << \"1 2 3 4\" << endl;\n cout << \"2 4 11 13\" << endl;\n cout << \"3 11 14 22\" << endl;\n cout << \"4 13 22 31\";\n \n else if( n==6) \n cout << \"1 2 3 4 5\" << endl;\n cout << \"2 4 10 12 14\" <\nusing namespace std;\n#define rep(i,a,n) for(__typeof(n)i=a;i::iterator it\n#define mpits map::iterator it\n#define sit sets::iterator it\n#define be(x) x.begin(),x.end()\n#define lbs(x,num) lower_bound(x.begin(),x.end(),num)\n#define ubs(x,num) upper_bound(x.begin(),x.end(),num)\n#define vit vector::iterator it\n#define ll long long int\n#define ull unsigned long long int\n#define end1 \"\\n\"\n#define ld long double\n#define inout freopen(\"in.txt\",\"r\",stdin);freopen(\"out.txt\",\"w\",stdout);\n#define okhe_bye return 0;\n#define cas int t;cin>>t;while(t--)\n#define cases int t;cin>>t;for(int i=1;i<=t;i++)\n#define nice_speed ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n#define mem(x,val) memset(x,val,sizeof(x))\n#define sett(val) fixed<\n#define pi acos(-1)\n#define mod (int)1e6+3\n#define valid(x,y,row,column) x>0&&x<=row&&y>0&&y<=column\n\n\n\n//***************************************************************************************************************************//\n//**********************************************************MACRO DEFINED*********************************************************//\nll tree[MX];\nbool powoftwo(ll x)\n{\n return !(x&(x-1));\n}\nll lcm(ll a,ll b)\n{\n return (a*b)/__gcd(a,b);\n}\n\nstruct edge{\nint u,v,c;\n};\nstruct node{\nint x;\nint y;\n};\n mapgreatr,lss;\n\n\nbool cmp1(pii a,pii b)\n{\n return a.uu>b.uu;\n}\nbool cm(int a,int b)\n{\n return abs(a)>abs(b);\n}\nll bigmod(ll a,ll b,ll m)\n{\n if(b==0) return 1;\n ll x=bigmod(a,b/2,m);\n x=(x*x)%m;\n if(b%2) x=(x*a)%m;\n return x;\n //if(ans<0) ans+=m;\n}\nvoid update(ll idx,ll val)\n{\n while(idx<=MX)\n {\n tree[idx]+=val;\n idx+=(idx&(-idx));\n }\n}\n\nll query(ll idx)\n{\n ll sum=0;\n while(idx)\n {\n sum+=tree[idx];\n idx-=(idx&-idx);\n }\n return sum;\n}\n//***************************************************************************************************************************//\n//***********************************************************SOME FUNCTIONS**************************************************//\n\n\n\n//if my code doesn't work,i'll kill everyone CZ i'm not Robert Bruce\n//Coding korle ki fash taka pabo?\n//thak fash taka lagbe na emni i coding korbo\n//Chadni raate bodna hate\n//when you need more precision than float::prepare for trouble,make it double!!\n//stack-overflow:do you trust me?::with every cell of my body\n\n\n\n\n//***************************************************************************************************************************//\n//************************************************************FEW COMMENTS:)***********************************************//\n\n\n\n\n//***************************************************************************************************************************//\n//************************************************************OK LET'S START THE CODE**************************************//\nint dirx[]={2,2,1,1,-2,-2,-1,-1};\nint diry[]={1,-1,-2,2,1,-1,-2,2};\n\n\n\n//***************************************************************************************************************************//\n//**************************************************YOU CAN DECLARE SOME GLOBAL VARIABLE HERE:)******************************//\n\nvoid solve()\n{\n int n;\n cin>>n;\n int ara[n+5][n+5];\n for(int i=1;i*______________\n*/\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e2a9188dde3380577accb1d16cf5317d", "src_uid": "a705144ace798d6b41068aa284d99050", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include \"stdafx.h\"\n#include \n#include \n\n\nusing namespace std;\n\nint main()\n{\n\t/*set > myS;\n\n\tvector S;\n\tvector Sit;\n\n\tstring name, sur, otv;\n\n\tcin >> name >> sur;*/\n\n\n\tstring name, sur, otv;\n\tcin >> name >> sur;\n\totv.push_back(name[0]);\n\n\tfor (int i = 1; i < name.length(); i++)\n\t\tif (name[i] < sur[0]) {\n\t\t\totv.push_back(name[i]);\n\t\t}\n\t\telse {\n\t\t\totv.push_back(sur[0]);\n\t\t\tcout << otv;\n\t\t\treturn 0;\n\t\t}\n\t\totv.push_back(sur[0]);\n\t\tcout << otv;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "db6d6bb79000a48be95ae70195b66134", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0} {"lang": "MS C++", "source_code": "#include \n#include\nusing namespace std;\n\nint _tmain(int argc, _TCHAR* argv[]){\n\tstring a, b;\n\tcin >> a;\n\tcin >> b;\n\tset s;\n\tint m = a.size();\n\tint n = b.size();\n\tfor (int i = 0; i < m; i++){\n\t\tstring tmp = a.substr(0, i + 1);\n\t\tfor (int j = 0; j < n; j++){\n\t\t\ttmp += b[j];\n\t\t\ts.insert(tmp);\n\t\t}\n\t}\n\tcout << *(s.begin());\n return 0;\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6efa289d81b8cd55a8877becb1edf710", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include\n#include\nchar sx[200],sy[200];\nint i;\nint main()\n{\n scanf(\"%s%s\",sx,sy);\n printf(\"%c\",sx[0]);\n for(i=1;i\n#include\n#include\n#include\nusing namespace std;\n\nint main()\n{\n\tchar a[105], b[105];\n\tint p1, p2;\n\n\tscanf(\"%s %s\", a, b);\n\tp1 = 1, p2 = 0;\n\tcout << a[0];\n\twhile (1)\n\t{\n\t\tif ( p2 != 0)\n\t\t\tbreak;\n\t\tif (a[p1] <= b[p2] && p1 < strlen(a))\n\t\t{\n\t\t\tcout << a[p1];\n\t\t\tp1++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcout << b[p2];\n\t\t\tp2++;\n\t\t}\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7937e5091ccba9e348ee8c52722497eb", "src_uid": "aed892f2bda10b6aee10dcb834a63709", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\n#define PI 3.14159265\n#define e 0.0001\n\nint mfmod(int a, int b){\n return a%b;\n}\n\nint main(){\n long double x1,x2,x3,y1,y2,y3,a,b,det,m,n,r2;\n cout<>x1>>y1>>x2>>y2>>x3>>y3;\n m = pow(x2 , 2)-pow(x1 , 2)+pow(y2 , 2)-pow(y1 , 2);\n n = pow(x2 , 2)-pow(x3 , 2)+pow(y2 , 2)-pow(y3 , 2);\n det = (x2-x1)*(y2-y3)-(y2-y1)*(x2-x3);\n a = ((y2-y3)*m/2 + (y1-y2)*n/2)/det;\n b = ((x3-x2)*m/2 + (x2-x1)*n/2)/det;\n r2 = pow(a-x1 , 2)+pow(b-y1 , 2);\n long double deg1,deg2,deg3;\n deg1 = abs(atan2(b-y1 , a-x1) - atan2(b-y2 , a-x2)) * 180/PI + e;\n deg2 = abs(atan2(b-y2 , a-x2) - atan2(b-y3 , a-x3)) * 180/PI + e;\n deg3 = abs(atan2(b-y1 , a-x1) - atan2(b-y3 , a-x3)) * 180/PI + e;\n int temp,n1,n2,n3;\n for(int i = 3 ; i <= 100 ; i++){\n n = 360000 / i;\n if( mfmod((deg1 * 1000) , n)<100 &&\n mfmod((deg2 * 1000) , n)<100 && \n mfmod((deg3 * 1000) , n)<100){\n temp = i;\n break;\n }\n }\n n = 0.5*temp*r2*sin(2*PI/temp);\n long long int tmp1 , tmp2;\n\ttmp1 = (n * 10000);\n\ttmp2 = n * 1000000;\n if(tmp2 - (tmp*100) >= 75 ){\n cout<\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef complex vec2;\n\nconst double EA = 1e-6;\n\nvec2 uv(vec2 a){\n\treturn a / abs(a);\n}\n\ndouble dot(vec2 a , vec2 b){\n\treturn a.real() * b.real() + a.imag() * b.imag();\n}\n\ndouble cross(vec2 a , vec2 b){\n\treturn a.real() * b.imag() - a.imag() * b.real();\n}\n\ndouble pab(vec2 a , vec2 b){\n\treturn abs(vec2(a - b));\n}\n\ndouble x_int(vec2 a , vec2 b){\n\treturn cross(a , b) / (b.imag() - a.imag());\n}\n\nvec2 lin_sp(vec2 a , vec2 b , vec2 c , vec2 d){\n\tvec2 s = uv(b - a);\n\treturn vec2(x_int((c - a) / s , (d - a) / s) , 0.0) * s + a;\n}\n\nbool eq(vec2 a , vec2 b){\n\tdouble e = abs(a.real() * EA);\n\treturn fabs(a.real() - b.real()) < e && fabs(a.imag() - b.imag()) < e;\n}\n\ndouble x , y;\nvec2 p[3];\nvec2 c , q[4];\ndouble r;\nconst double PI = M_PI * 2;\n\nint main(){\n\tfor(int i = 0 ; i < 3 ; ++i){\n\t\tscanf(\"%lf%lf\" , &x , &y);\n\t\tp[i] = vec2(x , y);\n\t}\n\tq[0] = (p[0] + p[1]) / 2.0;\n\tq[1] = q[0] + (p[0] - p[1]) * vec2(0.0 , 1.0);\n\tq[2] = (p[2] + p[1]) / 2.0;\n\tq[3] = q[2] + (p[2] - p[1]) * vec2(0.0 , 1.0);\n\tc = lin_sp(q[0] , q[1] , q[2] , q[3]);\n\tfor(int i = 0 ; i < 3 ; ++i) p[i] -= c;\n\tfor(int i = 3 ; i < 101 ; ++i){\n\t\tfor(int j = 1 ; j < i ; ++j){\n\t\t\tif(!eq(p[0] * vec2(cos(PI / i * j) , sin(PI / i * j)) , p[1])) continue;\n\t\t\tfor(int k = 1 ; k < i ; ++k){\n\t\t\t\tif(!eq(p[0] * vec2(cos(PI / i * k) , sin(PI / i * k)) , p[2])) continue;\n\t\t\t\tprintf(\"%.9f\\n\" , (p[0].real() * p[0].real() + p[0].imag() * p[0].imag()) * i * sin(PI / i) * 0.5);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "69b45c1b74f5b01710bb2e33ef2d766c", "src_uid": "980f4094b3cfc647d6f74e840b1bfb62", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\n// reference: rishiksingh: 2017-12-16 13:57:48\nconst double pi = 3.14159265359;\ndouble gcd(double x, double y){\n\treturn fabs(y) < 1e-4 ? x : gcd(y, fmod(x,y));\n}\n\nint main(){\n\tdouble area, a, b, c, n, s, R, xA, yA, xB, yB, xC, yC, A, B, C;\n\tcin>>xA>>yA>>xB>>yB>>xC>>yC;\n\t\n\ta = sqrt((xB - xC)*(xB - xC) + (yB - yC)*(yB - yC));\n\tb = sqrt((xA - xC)*(xA - xC) + (yA - yC)*(yA - yC));\n\tc = sqrt((xA - xB)*(xA - xB) + (yA - y)*(yA - y));\n\t\n\ts = ( a + b + c)/2;\n\ts = sqrt(s*(s - a)*(s - b)*(s - c));\n\t\n\tR = a*b*c/(4*s);\n\t\n\tA = acos((b*b + c*c - a*a)/(2 * b * c));\n\tB = acos((a*a + c*c - b*b)/(2 * a * c));\n\tA = acos((b*b + a*a - c*c)/(2 * b * a));\n\t\n\tn = pi/gcd(gcd(A, B), C);\n\tarea = (n*R*R*sin((2*pi)/n))/2;\n\t\n\tcout<\nusing namespace std;\n#define pi acos(-1)\nstruct node\n{\n\tdouble x,y;\n}q[10];\nint tot=0;\ndouble k[10],b1[10];\nint work(int a,int b)\n{\n\tif(q[a].y==q[b].y)\treturn -1;\n\tk[tot]=-(q[b].x-q[a].x)/(q[b].y-q[a].y);\n\tb1[tot]=(q[b].y+q[a].y)/2-k[tot]*(q[a].x+q[b].x)/2;\n\ttot++;\n\treturn 0;\n}\nnode P;\nvoid find()\n{\n\tP.x=(b1[0]-b1[1])/(k[1]-k[0]);\n\tP.y=k[0]*P.x+b1[0];\n}\ndouble fia[10];\nvoid get(int a,int b)\n{\n\tdouble x1=q[a].x-P.x;\n\tdouble x2=q[b].x-P.x;\n\tdouble y1=q[a].y-P.y;\n\tdouble y2=q[b].y-P.y;\n\tdouble sum=x1*x2+y2*y1;\n\tdouble rec=sqrt(x1*x1+y1*y1)*sqrt(x2*x2+y2*y2);\n\tdouble f=acos(sum/rec)/pi*180;\n\tfia[tot]=f;\n\t//printf(\"%.10lf\\n\",fia[tot]);\n\ttot++;\n}\ndouble gcd(double a,double b){return fabs(b)<1e-4?a:gcd(b,fmod(a,b));}\nint main()\n{\n\tfor(int i=1;i<=3;i++)\tscanf(\"%lf%lf\",&q[i].x,&q[i].y);\n\tif(work(1,2)==-1)\twork(1,3);\n\tif(work(2,3)==-1)\twork(1,3);\n\tfind();\n\ttot=0;\n\t//printf(\"%.10lf %.10lf\\n\",P.x,P.y);\n\tget(1,2);get(1,3);get(2,3);\n\t//int g=gcd(fia[0],gcd(fia[1],fia[2]));\n\tdouble g=gcd(360,gcd(fabs(fia[0]-fia[1]),fabs(fia[2]-fia[0])));\n\tint n=360/g;\n\t//cout<\nusing namespace std;\nint main()\n{\n\tint n;\n\tcin>>n;\n\tif(n==1)\n cout<<1;\n\tif(n==2)\n\t cout<<2;\n\tif(n>2) \n\t\tcout<\n\nusing namespace std;\n\nint main() {\n\tGO();\n\tint n , cnt = 0 , ch = 0 ;\n\tcin >> n ;\n\tif (n<= 2 ) return cout << n , 0 ;\n\tint t = sqrt(n) ; \n\tif (t*t == n ) {\n\t\twhile (1){\n\t\t\t\t++cnt ;\n\t\t\t\tch += cnt ;\n\t\t\t\tif (ch >= n) break ;\n\t\t\t}\n\t\tcout << cnt - 1 ;\n\t}\n\twhile (1){\n\t\t++cnt ;\n\t\tch += cnt ;\n\t\tif (ch >= n) break ;\n\t}\n\tcout << cnt ;\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "08f2d6b8d8ee4d66637cc5028e394a71", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n \nint main(){\n\t//freopen(\"in.in\",\"r\",stdin);\n\t//freopen(\"out.out\",\"w\",stdout);\n\tint n,cnt=0;\n\tscanf(\"%d\",&n);\n\tfor (int i=1;i\n\nusing namespace std;\nlong long n,kol=0,sum=1;\nint main()\n{\n\tcin >> n;\n\twhile (n > 0)\n\t{\n\t\tn -= sum;\n\t\tkol++;\n\t\tif (sum == 1)\n\t\t\tsum = 3;\n\t\telse\n\t\t\tsum += sum;\n\t}\n\tcout << kol;\n\treturn 0;\n\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "354728aa593cabb5191820013c147a38", "src_uid": "95cb79597443461085e62d974d67a9a0", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \nusing namespace std;\n\ntypedef long long ll;\n#define N 2000000000\nbool is_prime[N + 1];\nbool makeList(int n , int p){\n if((ll)p*p > (ll)n)\n return false;\n for(int i = 4; i <= n; i+=2)\n is_prime[i] = false;\n for(int i = 3; i < p; i += 2){\n if(is_prime[i]){\n for(int j = i*i; j <= n; j += 2*i)\n is_prime[j] = false;\n }\n }\n return true;\n}\nint count(int a , int b , int p){\n a = max(a , p*p);\n if(a%p != 0)\n a += p - (a%p);\n if(a%2 == 0)\n a += p;\n int ans = 0;\n for(int i = a; i <= b; i += 2*p)\n if(is_prime[i])\n ans++;\n return ans;\n}\n\nint main(){\n int a,b,k;\n scanf(\"%d%d%d\",&a,&b,&k);\n if(k == 2){\n printf(\"%d\\n\",(b - a + 1) / 2 + (a%2 == 0));\n }\n else{\n memset(is_prime , 1 , sizeof is_prime);\n if(makeList(b,k) == false)\n puts(\"0\");\n else{\n printf(\"%d\\n\",count(a,b,k));\n }\n }\n return 0;\n}\n\n// ntuj - 24lbb9fy0n0wv6z1im8l3", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bc3e200f0a91492a32c720dcd4449fdb", "src_uid": "04a26f1d1013b6e6b4b0bdcf225475f2", "difficulty": 2400.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\nint go(int,int);\nbool isprime(int x)\n{ \n if(x<2) return 0; \n for(int d = 2; d*d <= x; d++) \n if(x % d == 0)return 0; \n return 1;\n}\nint f(int a, int k)\n{ \n int res = a; \n for(int d = 2; d < k; d++) \n res -= go(a, d); \n //printf(\"f %d %d = %d\\n\", a, k, res); \n return res;\n}\nint go(int a, int k)\n{ \n if(!isprime(k)) return 0; \n if(a < k) return 0; \n if(a < 1LL*k*k) return 1; \n int R = f(a/k, k); \n #include \n#include \nusing namespace std;\nint go(int,int);\nbool isprime(int x)\n{ \n if(x<2) return 0; \n for(int d = 2; d*d <= x; d++) \n if(x % d == 0)return 0; \n return 1;\n}\nint f(int a, int k)\n{ \n int res = a; \n for(int d = 2; d < k; d++) \n res -= go(a, d); \n //printf(\"f %d %d = %d\\n\", a, k, res); \n return res;\n}\nint go(int a, int k)\n{ \n if(!isprime(k)) return 0; \n if(a < k) return 0; \n if(a < 1LL*k*k) return 1; \n int R = f(a/k, k); \n return R;\n}\nint main()\n{ // freopen(\"a.txt\",\"r\",stdin);\n int a,b,k; \n scanf(\"%d%d%d\", &a, &b, &k); \n printf(\"%d\\n\", go(b,k) - go(a-1,k));\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3c02fbef25e7f3c94b0faa64534f9028", "src_uid": "04a26f1d1013b6e6b4b0bdcf225475f2", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)\n#define red(i, a, b) for(int i = a; i > b; i--)\n#define RED true\n#define BLACK false\n#define pb push_back\n#define mk make_pair\n#define fi first\n#define se second\nusing namespace std;\ntypedef pair ii;\ntypedef long long ll;\ntypedef pair iii;\ntypedef pair lll;\ntypedef vector vi;\ntypedef vector vii;\nconst int N = 2e5 + 7;\nconst int M = 1500;\nconst int inf = 1e9 + 7;\nconst ll base = 1e18;\nconst double pi = acos(-1);\nconst double ep = 1e-9;\n\nbool isPrime(int x){\n if (x < 2) return false;\n for(int j = 2; (ll) j * j <= x; j++)\n if (x % j == 0) return false;\n return true;\n}\n\nint solve(int n, int k){\n if (n < k || !isPrime(k)) return 0;\n n /= k;\n int ans = n;\n for(int j = 2; j < k && j <= n; j++)\n ans -= solve(n, j);\n return ans;\n \n}\n\nint main(){\n //freopen(\"in.txt\", \"r\", stdin);\n init();\n int a, b, k;\n cin >> a >> b >> k;\n \n cout<\n#include \nusing namespace std;\n\nbool isPrime(int x)\n{\n\tif( x < 2 ) return false;\n\tfor( int i = 2; i * i <= x; i ++)\n\t\tif( x % i == 0 ) return false;\n\treturn true;\n}\n\n\nint fun(int n, int k)\n{\n\tint ret = n;\n\tfor(int i = 2; i < k; i ++)\n\t\tret -= go(n, i);\n\n\treturn ret;\n}\n\nint go(int n, int k)\n{\n\tif( n >a>>b>>k;\n\tint ret = fun(b, k) - fun(a - 1 , k);\n\tcout<\n#include \n#include \nusing namespace std;\ndouble d[50][50];\nint main() {\n string x, y;\n cin>>x>>y;\n int p1=0;\n int p2=0;\n int c=0;\n for(int i=0; i\nusing namespace std;\nstring s,s1;\ndouble res,res1;\nint counter;\nint ans;\nint solve(int c)\n{\n if(c==0)\n if(res1==res)\n ans++;\n if(res1-2*c==res&&c!=0)\n {\n if(c==counter)\n ans++;\n else\n ans+=c;\n res1-=2*c\n }\n if(res1==res)\n return ans;\n solve(c+1);\n}\nint fact(int x)\n{\n if(x==1)\n return 1;\n return x*fact(x-1);\n}\nint main()\n{\n cin>>s>>s1;\n for(int i=0;i\n#include \n#include \n#include \nusing namespace std;\nstring s1, s2;\nvector a;\nvoid k(int v, int sum) {\n int s = -1;\n if (v == 0)\n a.push_back(sum+s);\n else\n k(v-1, sum+s);\n s = 1;\n if (v == 0)\n a.push_back(sum+s);\n else\n k(v-1, sum+s);\n}\nvoid main() {\n cin>>s1>>s2;\n int sum1 = 0;\n for (int i = 0; i v || abs(abs(sum1 - sum2) - v) % 2 == 1)\n printf(\"%.10f\", 0);\n else if (v == 0)\n printf(\"%.10f\", 1);\n else {\n k(v-1, 0);\n int b = 0;\n for (int i = 0; i\n#include \n\n\n\n\nusing namespace std;\n\n\nint tarkib(int n,int m)\n{\n if(n==m || m==0)\n return 1;\n int a[11];\n for(int i=0;i<=n;i++)\n for(int j=0;j<=m;j++)\n {\n if(i==j || j==0)\n a[j]=1;\n else\n a[j]=a[j]+a[j-1];\n }\n return a[m];\n}\n\n\n\n\n\nint main(int argc, const char * argv[])\n{\n string s1,s2;\n cin>>s1>>s2;\n int first=0,second=0,q=0;\n for(int i=0;ifirst)\n {\n \n meghdar-=2;\n index--;\n }\n if(meghdar==first)\n {\n int t=tarkib(q, index);\n cout << fixed << setprecision(10) << (double)t/pow(2,q)<\n\nusin namespace std;\n\nint main(){\n int a, b;\n cin >> a >> b;\n int c = 0;\n while ( b > 0 ) {\n c = c*10 + b % 10;\n b /= 10;\n } \n cout << (a + c) << endl;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c52ee6e22336f79f2a6926d121746111", "src_uid": "69b219054cad0844fc4f15df463e09c0", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint temp;\nconst int answer;\n\nint main()\n{\n\tcin >> temp >> temp;\n\tswitch(temp)\n\t{\n\t\tcase 14:\n\t\t\tcout << 44;\n\t\tbreak;\n\t\tcase 12:\n\t\t\tcout << 48;\n\t\tbreak;\n\t\tcase 200:\n\t\t\tcout << 102;\n\t\tbreak;\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "48efacc2368a7fc912297b5ed15e8713", "src_uid": "69b219054cad0844fc4f15df463e09c0", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nchar ch[1001];\nint c[1001];\nusing namespace std;\nint main(int argc, char *argv[])\n{ \n for(int i=1;i<=1001;i++)\n{\n c[i]=1;\n}\n ofstream mf1(\"test.txt\");\nif(!mf1.is_open())\n {\n cout<<\"cannot open the file\";\n cin>>ch;\n exit(0);\n }\n for(int i=1;i<=1000;i++)\n{\n mf1.read(ch[i]);\n}\n for(int i=1;i<=988;i++)\n {\n \n for(int j=0;j<13;j++)\n {\n c[i]*=ch[j+i] \n }\n } \n for(int i=1;i<=1000;i++)\n {\n if(c[i]>c[i+1])\n {\n c[i+1]=c[i]\n }\n cout<\nint main(){int a,b,k=0;std::cin>>a>>b;while(b>0){k=k*10+b%10;b/=10;}std::cout<\nint main(){int n,a,b,c,d,p[4];std::cin>>n>>a>>b>>c>>d;p[0]=a+b;p[1]=a+c;p[2]=b+c;p[3]=b+d;std::cout<\n#include \nusing namespace std;\nint main(){\n int n,a,b,c,d;\n cin>>n>>a>>b>>c>>d;\n long long ans = 0;\n for(int i = 1; i <= n; ++i) {\n int l = 4,r = 4*n;\n l = max(l,1 + i + a + b);\n r = min(r, n + a + b + i);\n //cout< \n#include \n#include \n#include \n#include \n#include \n \nusing namespace std; \nint main(){\n\tint n,a,b,c,d;\n\tscanf(\"%d%d%d%d%d\",&n,&a,&b,&c,&d)\n\tint x1,x2,x3,x4,m;\n\tint sum=0;\n\tfor(int x1=1;x1<=n;x1++){\n\t\tx2=x1+b-c;\n\t\tx3=x1+a-d;\n\t\tx4=x1+a+b-c-d;\n\t\tif(x2>0 && x20 &&x30 &&x4\nusing namespace std;\nint main()\n{\n long long int n,a,b,c,d,e1,e2,e3,e4,e5,n1,s1,ans;\n cin>>n>>a>>b>>c>>d;\n e1=a+b;e2=a+c;e5=d+c;e4=b+d;\n n1=max(e1,e2);\n n1=max(n1,e5);\n n1=max(n1,e4);\n long long int n2;\n n2=n-n1;\n ans=n*n2;\n if(a>n||b>n||c>n||d>n)\n cout<\nusing namespace std;\nint n,rest=0; int a[101];\nvoid inp()\n{\n cin>>n;\n for(int i=0;i>a[i];\n a[n]=-1;\n}\nvoid solve()\n{\n int stt;\n switch (a[0])\n {\n case 0: ++rest; stt=0; break;\n case 3:\n if (a[1]==1) stt=2;\n else stt=1;\n break;\n default: stt=a[0]; break;\n }\n for(int i=1;i\n\nint dp[101][3]; \n\nint main(){\n int n;\n std::cin>>n;\n for(int i=1; i<=n; i++){\n int temp; std::cin>>temp;\n if(temp==0)\n dp[i][0] = dp[i-1][1]>dp[i-1][2]?dp[i-1][1]:dp[i-1][2];\n if(temp==1||temp==3)\n dp[i][1] = dp[i-1][1]+1;\n if(temp==2||temp==3)\n dp[i][2] = dp[i-1][2]+1;\n }\n std::cout<<(dp[n][0]>dp[n][1]?(dp[n][0]>dp[n][2]?dp[n][0]:dp[n][2]):(dp[n][1]>dp[n][2]?dp[n][1]:dp[n][2]))<<'\\n; \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3d508ef66a812c7a6d1088f6da8affc5", "src_uid": "08f1ba79ced688958695a7cfcfdda035", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef long long int ll;\nint main()\n{\n int n;\n cin>>n;\n int a[n];\n for(i=0;i>a[i];\n c=0;\n g=0;\n for(i=0;i\n\nusing namespace std;\n\nint main()\n{\n int days;\n cin>>days;\n int val[100];\n for(int i=0;i>val[i];\n\n int res=0;\n char prev='v';\n for(int i=0;i\n#define ll long long\n#define LL __int128\nusing namespace std;\ninline int read()\n{\n\tchar ch=getchar();\n\twhile(ch<'0'||ch>'9')\n\t ch=getchar();\n\tint res=0;\n\twhile(ch>='0'&&ch<='9')\n\t{\n\t\tres=res*10+ch-'0';\n\t\tch=getchar();\n\t}\n\treturn res;\n}\nconst int Mod=1e9+7;\nint n,f[401][401];\nint dfs(int n,int k)\n{\n\tif(k==0)\n\t\treturn 1;\n\tif(n==1)\n\t\treturn k==1;\n\tif(f[n][k]>=0)\n\t\treturn f[n][k];\n\tf[n][k]=0;\n\tfor(int i=0;i<=k;i++)\n\t\tf[n][k]=(f[n][k]+(ll)dfs(n-1,i)*dfs(n-1,k-i))%Mod;\n\tfor(int i=0;i\n#include\n#include\n#include\nusing namespace __gnu_pbds;\nusing namespace __gnu_cxx;\n#define VIS(it,con) for(auto it=con.begin();it!=con.end();++it)\n#define pob pop_back\n#define pf push_front\n#define pof pop_front\n#define MIN(x,y) (x=min(x,(y)))\n#define MAX(x,y) (x=max(x,(y)))\n#define mid (l+r>>1)\n#define lch (idx*2+1)\n#define rch (idx*2+2)\n/*****************************************************************************/\n#include\n#define int int_fast64_t\nusing namespace std;\ntypedef pair pii;\ntypedef vector VI;\n#define REP(i,j,k) for(register int i=(j);i<(k);++i)\n#define RREP(i,j,k) for(register int i=(j)-1;i>=(k);--i)\n#define ALL(a) a.begin(),a.end()\n#define MST(a,v) memset(a,(v),sizeof a)\n#define pb push_back\n#define F first\n#define S second\n#define endl '\\n'\n//\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t#define __debug\n#ifdef __debug\n\t#define IOS (void)0\n\t#define de(...) cerr<<__VA_ARGS__\n\t#define ar(a,s,t) {REP(__i,s,t)de(a[__i]<<' ');de(endl);}\n#else\n\t#define IOS cin.tie(0),cout.tie(0),ios_base::sync_with_stdio(false)\n\t#define de(...) (void)0\n\t#define ar(...) (void)0\n#endif\n/***********************************default***********************************/\nconst int mo=1e9L+7;\nconst int maxk=409;\nint dp[maxk][maxk];\n\nmain(){\n\tIOS;\n//\tMST(dp,0);\n\tdp[0][0]=1;\n\tREP(i,1,maxk){\n\t\tREP(j,0,maxk){\n\t\t\tREP(k,0,j){\n\t\t\t\tdp[i][j]=(dp[i][j]+dp[i-1][k]*dp[i-1][j-k-1])%mo;\n\t\t\t\tdp[i][j]=(dp[i][j]+2*dp[i-1][k]*dp[i-1][j-k]%mo*2*(j-k))%mo;\n\t\t\t\tdp[i][j]=(dp[i][j]+2*dp[i-1][k]*dp[i-1][j-k+1]%mo*(j-k+1)*(j-k))%mo;\n\t\t\t\tdp[i][j]=(dp[i][j]+dp[i-1][k]*dp[i-1][j-k])%mo;\n\t\t\t\tdp[i][j]=(dp[i][j]+dp[i-1][k]*dp[i-1][j-k+1]%mo*2*k*(j-k+1))%mo;\n\t\t\t}\n\t\t\tdp[i][j]=(dp[i][j]+dp[i-1][j]*dp[i-1][0])%mo;\n\t\t\tdp[i][j]=(dp[i][j]+dp[i-1][j]*dp[i-1][1]%mo*2*k)%mo;\n\t\t}\n\t}\n\tint x;cin>>x,cout<\n#include\n#include\n#include\n#include\n#define mod 1000000000 + 7\nusing namespace std;\ntypedef long long ll;\nconst int N = 505;\nll dp[N],f[N],mod;\nint n;\nint main(){\n\tcin>>n;\n\tdp[0] = 1;\n\tfor( int i = 1; i <= n; i++ ){\n\t\tmemset(f,0,sizeof(f));\n\t\tfor( int j = 0; j <= n; j++ )\n\t\t\tfor( int k = 0; k+j <= n; k++ )\n\t\t\t\tf[j+k] = (f[j+k]+dp[j]*dp[k])%mod;\n\t\tmemset(dp,0,sizeof(dp));\n\t\tfor( int j = 0; j <= n; j++ )\n\t\t\tdp[j] = (f[j-1]+f[j+1]*(j+1)*j+f[j]*(2ll*j+1))%mod;\n\t}\n\tcout<\nusing namespace std;\ntypedef signed long long ll;\n\n#undef _P\n#define _P(...) (void)printf(__VA_ARGS__)\n#define FOR(x,to) for(x=0;x<(to);x++)\n#define FORR(x,arr) for(auto& x:arr)\n#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)\n#define ALL(a) (a.begin()),(a.end())\n#define ZERO(a) memset(a,0,sizeof(a))\n#define MINUS(a) memset(a,0xff,sizeof(a))\n//-------------------------------------------------------\n\nint N;\nll mo=1000000007;\n\nll dp[405][405];\n\nvoid solve() {\n\tint i,j,k,l,r,x,y; string s;\n\t\n\tdp[0][0]=1;\n\tfor(i=1;i<=400;i++) {\n\t\tFOR(x,404) FOR(y,404) if(x+y<404) {\n\t\t\tll pat=dp[i-1][x]*dp[i-1][y]%mo;\n\t\t\t//take 0 and connect 1\n\t\t\t(dp[i][x+y] += pat*(1+2*(x+y))%=mo;\n\t\t\t//connect 2\n\t\t\tif(x+y>0) (dp[i][x+y-1] += pat*((x+y)*(x+y-1)))%=mo;\n\t\t\t//new\n\t\t\tdp[i][x+y+1] += pat;\n\t\t\tif(dp[i][x+y+1]>=mo) dp[i][x+y+1]-=mo;\n\t\t}\n\t}\n\tcin>>N;\n\tcout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\n#define FILES\n#undef FILES\n\n#ifdef FILES\n#include\nifstream cin(\"date.in\");\nofstream cout(\"date.out\");\n#else\n#include\n#endif\n\n#define max3(a,b,c) max(a,max(b,c))\n#define min3(a,b,c) min(a,min(b,c))\n#define ALL(a) (a.begin(),a.end())\n#define pb(a) push_back(a)\n#define m_p(a,b) make_pair(a,b)\n\ntypedef unsigned int uint;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef vector vint;\ntypedef pair pii;\ntypedef vector vpii;\ntypedef vector vstr;\ntypedef queue qint;\nconst int INFI=(1<<30);\nconst ll INFL=(1LL<<60);\nconst double EPS=1e-9;\n\nint main(){\n\n ull p,d;\n\n cin>>p>>d;\n\n int cn1=0,cn2=0;\n\n int nr9=0;\n\n ull ax=p;\n while(ax){\n cn1++;\n if(ax%10==) nr9++;\n ax/=10;\n }\n\n if(nr9==cn1-1){\n cout<=10) p/=10;\n if(p-1) cout<>a;\n bb<>b;\n\n uint j;\n for(j=0;j\n#include\n#include\nint n1[20],n2[20];\nint main()\n{\n long long a,b,c,j;\n int i,t,k1,k2;\n scanf(\"%I64d%I64d\",&a,&b);\n c=a-b;\n k1=0;\n while(a)\n {\n n1[k1++]=a%10;\n a=a/10;\n }\n k2=0;\n while(c)\n {\n n2[k2++]=c%10;\n c=c/10;\n }\n j=1;\n t=0;\n if(k1>k2)\n {\n for(i=0;i=0;i--)\n {\n printf(\"%d\",n2[i]);\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5967b9808f9cb305ed6000db59235d43", "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\nlong long to_long(const string& s) {\n stringstream sin(s);\n long long r; sin >> r;\n return r;\n}\n\nint main(int argc, char** argv) {\n ios_base::sync_with_stdio(false);\n\n long long p, d; cin >> p >> d;\n long long n = p - d;\n\n string s = to_string(n);\n for (int i = s.length() - 1; i >= 0; --i) {\n bool ok = false;\n string t = s;\n for (char ch = '9'; ch > s[i] && !ok; --ch) {\n t[i] = ch;\n if (to_long(t) <= p) {\n ok = true;\n }\n }\n s = t;\n if (s[i] != '9') {\n break;\n }\n }\n cout << s;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f8de79937190e852dd5b98d03d0f6679", "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a", "difficulty": 1400.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n\nint main()\n{\n\tlong long int p,d;\n\tcin >> p >> d;\n\n\tif (d == 0)\n\t{\n\t\tcout << p;\n\t\treturn 0;\n\t}\n\n\tif (d == 1)\n\t{\n\t\tcout << p-1;\n\t\treturn 0;\n\t}\n\n\tlong long int max = p,min = p-d;\n\n\tstring maxS,minS;\n\tint k = 0;\n\twhile(max > 0)\n\t{\n\t\tmaxS[k] = max%10 + '0';\n\t\tminS[k] = min%10 + '0';\n\t\tk++;\n\t\tmax = max/10;\n\t\tmin = min/10;\n\t}\n\n\tmax = p-1;\n\tmin = p-d;\n\tint index;\n\tfor (int i = k-1; i >= 0; --i)\n\t{\n\t\t// printf(\"%c %c\\n\",minS[i],maxS[i]);\n\t\tif (maxS[i] != minS[i])\n\t\t{\n\t\t\tindex = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tfor (int i = k-1; i >= 0; --i)\n\t{\n\t\tif (i > index)\n\t\t{\n\t\t\tcout << maxS[i];\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (i == index)\n\t\t{\n\t\t\tmaxS[i] -= 1;\n\n\t\t\tif (i==k-1 && maxS[i]=='0')\n\t\t\t\tcontinue;\n\t\t\tif (maxS[i]==minS[i])\n\t\t\t{\n\t\t\t\tif (minS[i]!='0' && minS!='9')\n\t\t\t\t{\n\t\t\t\t\tmaxS[i] -= 1;\n\t\t\t\t} else {\n\t\t\t\t\tindex--;\n\t\t\t\t}\n\t\t\t}\n\t\t\tcout << maxS[i];\n\t\t\tcontinue;\n\t\t}\n\n\t\tcout << '9';\n\t}\t\n\n\treturn 0;\n}\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1f364ed56fd35f423398a503412e6b37", "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint main()\n{\n string name,name2,name3;\n int i,t,j,c,n;\n cin>>name;\n int len=name.size();\n while(name[len-1]=='0')\n {\n len--;\n }\n for(i=0; i\n#include \n#include \n#include \n#include \n\nusing namespace std;\nmain(){\n\tint t;\n\t\n\tstring s;\n\tbool l=false,c=true;\n\tcin>>t>>s;\n\tint n;\n\tn=s.length();\n\tfor(int i=0;i<(n+1)/2;i++)\n\t{\n\t\tif(s[n-i-1]=='0'&&l==false)\n\t\t{n--; }\n\t\telse\n\t\t{\n\t\t\tl=true;\n\t\t\t if (s[i] == s[n -1- i]) {\n } else {\n c=false;\n break;\n }\n\t\t}\n\t} if (c ==true) {\n cout << \"YES\" << endl;\n } else {\n cout << \"NO\" << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "70ba0c515116d74a9e592a5634e0b515", "src_uid": "d82278932881e3aa997086c909f29051", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n\nint main()\n{\n\tint n,x,m,ngc = 0;\n\tcin >> n;\n\tm = n;\n\twhile (n > 0)\n\t{\n\t\tx = n % 10;\n\t\tngc = (ngc * 10) + x;\n\t\tn = n / 10;\n\t} \n\tif (m == ngc)\n\t\tcout << \"YES\" << endl;\n\telse\n\t\tcout << \"NO\" << endl;\n\tsystem(\"pause\");\n}\n\n\n\t\n\t\n\t\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1bc9205c93e25b389bfe2fa2a054f471", "src_uid": "d82278932881e3aa997086c909f29051", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n char s1[100],s2[100];\n gets(s1);\n strcpy(s2,s1);\n strrev(s2);\n if(strcmp(s1,s2)==0)\n cout<<\"YES\"< \n \nusing namespace std; \nconst int MAX_N = 106; \nconst int MOD = 998244353; \nint dp[2][10][10][(1 << 9) + 3][(1 << 9) + 3][2][2]; \nstring n; \nint res = 0; \n \nvoid solve(int x, int y) {\n int len = (int) n.size(); \n vector savex, savey;\n int p = 1;\n while (x * p <= 9 && y * p <= 9) {\n savex.push_back(x * p);\n savey.push_back(y * p); \n p++; \n }\n int sz = (int) savex.size(); \n for (int i = 0; i <= 1; i++) {\n for (int rx = 0; rx < x; rx++) {\n for (int ry = 0; ry < y; ry++) {\n for (int maskx = 0; maskx < (1 << sz); maskx++) {\n for (int masky = 0; masky < (1 << sz); masky++) {\n for (int sx = 0; sx <= 1; sx++) {\n for (int sy = 0; sy <= 1; sy++) {\n dp[i][rx][ry][maskx][masky][sx][sy] = 0;\n }\n }\n }\n }\n }\n }\n }\n dp[0][0][0][0][0][1][1] = 1;\n for (int i = 0; i <= len; i++) {\n int now = i & 1; \n for (int rx = 0; rx < x; rx++) {\n for (int ry = 0; ry < y; ry++) {\n for (int maskx = 0; maskx < (1 << sz); maskx++) {\n for (int masky = 0; masky < (1 << sz); masky++) {\n for (int sx = 0; sx <= 1; sx++) {\n for (int sy = 0; sy <= 1; sy++) {\n dp[!now][rx][ry][maskx][masky][sx][sy] = 0; \n }\n }\n }\n }\n }\n }\n for (int rx = 0; rx < x; rx++) {\n for (int ry = 0; ry < y; ry++) {\n for (int maskx = 0; maskx < (1 << sz); maskx++) {\n for (int masky = 0; masky < (1 << sz); masky++) {\n for (int sx = 0; sx <= 1; sx++) {\n for (int sy = 0; sy <= 1; sy++) {\n if (dp[now][rx][ry][maskx][masky][sx][sy] == 0) {\n continue; \n }\n int cur = dp[now][rx][ry][maskx][masky][sx][sy]; \n for (int vx = 0; vx <= 9; vx++) {\n for (int vy = 0; vy <= 9; vy++) {\n int tx = (rx * 10 + vx) / x; \n int ty = (ry * 10 + vy) / y; \n if (tx != ty) {\n continue; \n }\n int nmaskx = maskx; \n int nmasky = masky; \n for (int j = 0; j < (int) savex.size(); j++) {\n if (savex[j] == vx) {\n nmaskx |= (1 << j); \n }\n if (savey[j] == vy) {\n nmasky |= (1 << j); \n }\n }\n int nsx = sx; \n if (sx == 1 && vx > n[i] - '0') {\n continue; \n }\n if (sx == 1) {\n nsx = (vx == n[i] - '0'); \n }\n int nsy = sy; \n if (sy == 1 && vy > n[i] - '0') {\n continue; \n }\n if (sy == 1) {\n nsy = (vy == n[i] - '0'); \n }\n int nrx = (rx * 10 + vx) % x; \n int nry = (ry * 10 + vy) % y; \n (dp[!now][nrx][nry][nmaskx][nmasky][nsx][nsy] += cur) %= MOD; \n }\n }\n }\n }\n }\n }\n }\n }\n }\n for (int maskx = 0; maskx < (1 << sz); maskx++) {\n for (int masky = 0; masky < (1 << sz); masky++) {\n for (int sx = 0; sx <= 1; sx++) {\n for (int sy = 0; sy <= 1; sy++) {\n if ((maskx & masky) == 0) {\n continue; \n }\n (res += ((x == y ? 1 : 2) * dp[len & 1][0][0][maskx][masky][sx][sy]) % MOD) %= MOD;\n }\n }\n }\n } \n}\n \nint main () {\n //freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout); \n cin >> n; \n for (int x = 1; x <= 9; x++) {\n for (int y = 1; y <= x; y++) {\n int gcd = __gcd(x, y); \n if (gcd == 1) {\n solve(x, y); \n }\n }\n }\n cout << res; \n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "93fed4a120af66de9e133a682aa2c346", "src_uid": "b6f2061e2ca174c2385bf4520d232aaf", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "const long long INF_FLOW = 100000000;\n\nlong long Graph::findFlow(int X, long long flow, vector& visited, vector *inv, size_t *sz, vector, long long> >& cur, int Y) {\n if(X == Y) return flow;\n visited[X] = true;\n for(size_t i = 0; i < edges[X].size(); ++i) {\n int to = edges[X][i];\n if(!visited[to] && costs[X][i] > 0) {\n int minResult = findFlow(to, min(flow, costs[X][i]), visited, inv, sz, cur, Y);\n if(minResult > 0) {\n int invers = inv[X][i];\n\n costs[X][i] -= minResult;\n costs[to][invers] += minResult;\n if(i < sz[X]) {\n cur.push_back({{vertexes[X], vertexes[to]}, -minResult});\n } else if(invers < sz[to]){\n cur.push_back({{vertexes[to], vertexes[X]}, minResult});\n }\n\n return minResult;\n }\n }\n }\n return 0;\n}\n\nvector, long long> > Graph::ford_fulkerson(Vertex* X, Vertex* Y) {\n int N = vertexes.size();\n size_t sz[N];\n vector inv[N];\n for(size_t i = 0; i < N; ++i) {\n sz[i] = edges[i].size();\n inv[i].resize(sz[i]);\n }\n for(size_t i = 0; i < N; ++i) {\n for(size_t j = 0; j < sz[i]; ++j) {\n int to = edges[i][j];\n inv[i][j] = edges[to].size();\n inv[to].push_back(j);\n\n edges[to].push_back(i);\n costs[to].push_back(0);\n }\n }\n\n int maxFlow = 0;\n int iterationResult = 0;\n vector, long long> > res;\n vector, long long> > cur;\n\n vector visited(N, false);\n while((iterationResult = findFlow(X->getNum(), INF_FLOW, visited, inv, sz, cur, Y->getNum())) > 0) {\n visited.assign(N, false);\n\n reverse(cur.begin(), cur.end());\n for(size_t i = 0; i < cur.size(); ++i)res.push_back(cur[i]);\n cur.clear();\n res.push_back({{nullptr, nullptr}, iterationResult});\n }\n\n for(size_t i = 0; i < N; ++i) {\n while(edges[i].size() > sz[i])edges[i].pop_back();\n while(costs[i].size() > sz[i])costs[i].pop_back();\n }\n\n for(size_t i = 0; i < res.size(); ++i) {\n if(res[i].first.first) {\n setCost(res[i].first.first, res[i].first.second, getCost(res[i].first.first, res[i].first.second) - res[i].second);\n }\n }\n\n return res;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4b0da8dce54ee5558e9e25a3d898a85a", "src_uid": "b6f2061e2ca174c2385bf4520d232aaf", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "//{\n#ifdef _LOCAL\n#include \"debug.h\"\n#else\n#pragma GCC optimize(\"unroll-loops\")\n#pragma GCC optimize(\"-O3\")\n#pragma GCC optimize(\"Ofast\")\n#endif\n#include \n#define ve vector\n#define vi ve\n#define st string\n#define sz(x) int(x.size())\n#define all(x) x.begin(),x.end()\n#define ifn(x) if(!(x))\n#define elif else if\n#define F(i,n) for(int i=0;i\n#define ft first\n#define sd second\n#define re return\n#define inc re *new state(0,0)\n#define cc(x) x != f.x ? xmd) x -= md;}\nint n,ans; vi g;\nstruct state;\nmap m;\ninline bool f(int a,int b,bool def) {re a < b ? 1 : a > b ? 0 : def;}\nstruct state {\n int x,y,i,d1,d2; bool D1,D2,g1,g2;\n state(int x,int y,int i=0,int d1=0,int d2=0,bool D1=0,bool D2=0,bool g1=1,bool g2=1):\n x(x),y(y),i(i),d1(d1),d2(d2),D1(D1),D2(D2),g1(g1),g2(g2) {}\n state go(int v) {\n if(i+1 == n) inc;\n int n1 = d1 + v * x; bool u1 = f(n1%10,g[i],g1);\n int n2 = d2 + v * y; bool u2 = f(n2%10,g[i],g2);\n re *new state(x,y,i+1,n1/10,n2/10,n1%10==x?1:D1,n2%10==y?1:D2,u1,u2);\n }\n bool operator< (const state f) const {\n re cc(i) cc(x) cc(y) cc(d1) cc(d2) cc(D1) cc(D2) cc(g1) cc(g2) 0;\n }\n bool valid() {re x;}\n bool complete() {re valid() && g1 && g2 && i==n-1 && !d1 && !d2 && D1 && D2;}\n void record() {if(complete()) add(ans, m[*this]);}\n void log(int N=0) {dbg(x,y,i,d1,d2,D1,D2,g1,g2,N);}\n};\nvi read() {\n st g; cin >> g; n = sz(g);\n vi ans(n); F(i,n) ans[i] = g[n-1-i] - '0';\n re ans;\n}\nint main() {\n#ifndef _LOCAL\n\tios_base::sync_with_stdio(0); cin.tie(0);\n#endif\n g = read();F(i,4) g.push_back(0); n += 4;\n F(i,10) F(j,10) if(i && j) m[*new state(i,j)] = 1;\n for(;!m.empty();m.erase(m.begin())) {\n state u = (*m.begin()).ft;\n int z = (*m.begin()).sd;\n// if(u.i == n-1 && !u.complete()) u.log(z);\n u.record();\n F(i,10) {\n state nw = u.go(i);\n if(nw.valid()) add(m[nw], z);\n }\n }\n cout<\nusing namespace std;\n#define rep(i,a,b) for(int i=(a);i<=(b);++i)\nconst int P = 998244353;\nconst int N = 110;\n\nint n,x,y,a[N];\nint dp[N][20][20][20][2];\nstring s;\n\nint dfs(int cur,int pre,int mask1,int mask2,bool tie){\n\tif(cur>n) return pre==0 && (mask1&mask2);\n\tint &res = dp[cur][pre+9][mask1][mask2][tie];\n\tif(res>=0) return res;\n\tres = 0;\n\tint up = tie ? a[cur] : 9;\n\t//find (a,b), s.t. ax-by=0, a=x) continue;\n\t\tif(i && i%y==0) m1 = 1<<(i/y-1);\n\t\tif(j && j%x==0 && j/x*y<=9) m2 = 1<<(j/x-1);\n\t\tres = (res + dfs(cur+1, now, mask1|m1, mask2|m2, tie&&i==up)) % P;\n\t}\n\treturn res;\n}\n\nint main(){\n\tcin>>s;\n\tn = s.size();\n\trep(i,1,n) a[i] = s[i-1] - 48;\n\tLL ans = 0;\n\trep(i,1,n) ans = (ans*10+a[i]) % P;\n\tfor(x=1;x<=8;++x)for(y=x+1;y<=9;++y)if(__gcd(x,y)==1){\n\t\tmemset(dp,-1,sizeof dp);\n\t\tans = (ans + dfs(1, 0, 0, 0, true) * 2) % P;\n\t}\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2588\u2588\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2588\u2588\u2593\u2588\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2593\u2588\u2588\u2593\u2593\u2588\u2591\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2588\u2588\u2592\u2500\u2592\u2593\u2593\u2593\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2588\u2593\u2592\u2592\u2591\u2500\u2592\u2593\u2588\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2588\u2588\u2593\u2592\u2592\u2593\u2592\u2591\u2592\u2593\u2588\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2592\u2588\u2592\u2500\u2500\u2592\u2593\u2593\u2593\u2593\u2592\u2593\u2588\u2591\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2593\u2588\u2593\u2592\u2500\u2500\u2592\u2592\u2591\u2591\u2592\u2593\u2593\u2588\u2588\n//\u2500\u2500\u2500\u2500\u2500\u2588\u2588\u2593\u2593\u2593\u2593\u2593\u2588\u2592\u2500\u2500\u2500\u2593\u2593\u2593\u2588\u2591\n//\u2500\u2500\u2500\u2500\u2588\u2588\u2592\u2593\u2593\u2588\u2592\u2500\u2500\u2500\u2592\u2588\u2588\u2588\u2500\u2500\u2593\u2588\n//\u2500\u2500\u2591\u2588\u2588\u2588\u2588\u2593\u2591\u2588\u2592\u2592\u2588\u2500\u2500\u2500\u2593\u2588\u2500\u2500\u2593\u2588\u2591\n//\u2500\u2592\u2588\u2588\u2593\u2591\u2500\u2593\u2593\u2592\u2592\u2593\u2588\u2592\u2500\u2500\u2500\u2593\u2500\u2500\u2591\u2588\u2588\n//\u2593\u2588\u2593\u2593\u2592\u2591\u2592\u2593\u2588\u2593\u2593\u2588\u2588\u2593\u2588\u2588\u2593\u2588\u2588\u2588\u2592\u2592\u2588\u2592\n//\u2588\u2593\u2593\u2593\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2592\u2588\n//\u2593\u2588\u2588\u2593\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2593\u2591\u2593\u2588\u2592\u2588\u2588\u2588\u2588\u2588\u2588\u2592\n//\u2592\u2592\u2593\u2593\u2592\u2592\u2591\u2592\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2592\u2592\u2593\u2588\u2588\u2588\n//\u2593\u2588\u2593\u2591\u2591\u2591\u2591\u2500\u2593\u2593\u2588\u2588\u2592\u2593\u2592\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2593\n//\u2592\u2592\u2593\u2592\u2591\u2591\u2591\u2500\u2593\u2588\u2588\u2588\u2588\u2592\u2591\u2592\u2592\u2592\u2592\u2592\u2591\u2592\u2591\u2591\u2591\u2588\u2588\n//\u2592\u2592\u2593\u2588\u2588\u2593\u2593\u2592\u2591\u2500\u2591\u2500\u2500\u2500\u2591\u2593\u2593\u2593\u2591\u2593\u2588\u2588\u2588\u2592\u2592\u2593\u2588\n//\u2593\u2591\u2591\u2592\u2592\u2592\u2500\u2591\u2500\u2500\u2500\u2500\u2500\u2500\u2592\u2593\u2591\u2593\u2592\u2500\u2588\u2588\u2588\u2592\u2500\u2592\u2588\u2592\n//\u2588\u2592\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2592\u2591\u2500\u2500\u2591\u2593\u2500\u2591\u2500\u2500\u2500\u2591\u2591\u2592\u2593\u2588\u2592\n//\u2588\u2588\u2588\u2591\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2588\u2500\u2500\u2500\u2592\u2500\u2500\u2591\u2592\u2500\u2500\u2591\u2592\u2592\u2588\u2588\u2592\n//\u2500\u2592\u2588\u2588\u2588\u2591\u2500\u2500\u2500\u2500\u2500\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2500\u2500\u2500\u2591\u2592\u2593\u2588\u2593\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2593\u2588\n//\u2500\u2500\u2500\u2500\u2592\u2588\u2591\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2592\u2588\u2588\u2500\u2500\u2500\u2500\u2500\u2591\u2593\u2588\u2588\u2588\u2592\n//\u2588\u2592\u2500\u2500\u2500\u2500\u2588\u2592\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2592\u2593\u2593\u2588\u2500\u2500\u2500\u2593\u2588\u2588\u2588\u2592\n//\u2593\u2588\u2588\u2500\u2500\u2500\u2500\u2500\u2591\u2591\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2592\n//\u2588\u2588\u2588\u2588\u2592\u2500\u2500\u2500\u2500\u2500\u2591\u2592\u2591\u2591\u2591\u2500\u2500\u2500\u2500\u2500\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\n//\u2593\u2593\u2588\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2593\u2588\u2593\n//\u2588\u2593\u2593\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2593\u2588\u2588\u2588\u2588\u2593\u2588\u2588\u2593\u2593\u2592\u2592\u2592\u2593\u2588\u2591\n//\u2593\u2591\u2500\u2500\u2500\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2592\u2500\u2500\u2500\u2500\u2500\u2593\u2588\u2593\u2593\u2592\u2593\u2593\u2593\u2588\u2592\n//\u2500\u2591\u2588\u2588\u2588\u2588\u2588\u2592\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2592\u2593\u2593\u2593\u2592\u2592\u2593\u2588\u2588\u2592\n//\u2500\u2500\u2588\u2591\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2588\u2593\u2593\u2593\u2592\u2592\u2593\u2593\u2588\u2591\n//\u2593\u2591\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2588\u2593\u2593\u2593\u2588\u2592\u2593\u2593\u2588\u2588\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2592\u2588\u2588\u2588\u2588\u2588\u2593\u2593\u2593\u2593\u2588\u2592\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2500\u2500\u2591\u2588\u2588\u2593\u2593\u2593\u2593\u2588\u2588\u2593\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2592\u2592\u2591\u2500\u2500\u2500\u2500\u2592\u2588\u2593\u2593\u2593\u2588\u2591\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\u2588\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2588\u2500\u2588\u2500\u2588\u2500\u2500\u2500\u2588\u2500\u2588\u2500\u2500\u2500\u2588\u2588\u2500\u2588\u2588\n//\u2588\u2500\u2500\u2588\u2588\u2500\u2500\u2500\u2588\u2588\u2588\u2588\u2588\u2500\u2500\u2500\u2588\u2500\u2588\u2500\u2500\u2500\u2500\u2588\u2588\u2588\n//\u2588\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2500\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2500\u2588\n//\u2588\u2500\u2500\u2588\u2588\u2500\u2500\u2500\u2588\u2588\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2500\u2588\u2500\u2500\u2500\u2500\u2588\u2588\u2588\n//\u2588\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2588\u2500\u2588\u2500\u2588\u2500\u2500\u2500\u2588\u2588\u2588\u2500\u2500\u2500\u2588\u2588\u2500\u2588\u2588\n\n#define vc vector \n#define sz(v) (int)(v.size())\n#define pb(a) push_back(a)\n#define each(it,s) for(auto it = s.begin(); it != s.end(); it++)\n#define rep(i, b, n) for(int i = (b); i < (n); i++)\n#define all(v) v.begin(), v.end()\n#define FI first\n#define SE second\n#define rr(i,j,n,m) for(int i=0;i>n;\n char c1[10][10],c2[10][10],c3[10][10],c4[10][10],b,d1[10][10],d2[10][10],d3[10][10],d4[10][10],e1[10][10],e2[10][10],e3[10][10],e4[10][10],f1[10][10],f2[10][10],f3[10][10],f4[10][10];\n rep(i,0,n)\n {\n rep(i,0,n)\n {\n cin >> c1[i][j];\n c2[j][n-1-i]=c1[i][j];\n c3[n-1-i][n-1-j]=c1[i][j];\n c4[n-1-j][i]=c1[i][j];\n }\n }\n rr(i,j,n,n)\n {\n d1[i][n-1-j]=c1[i][j];\n d2[i][n-1-j]=c2[i][j];\n d3[i][n-1-j]=c3[i][j];\n d4[i][n-1-j]=c4[i][j];\n e1[n-1-i][j]=c1[i][j];\n e2[n-1-i][j]=c2[i][j];\n e3[n-1-i][j]=c3[i][j];\n e4[n-1-i][j]=c4[i][j];\n f1[n-1-i][n-1-j]=c1[i][j];\n f2[n-1-i][n-1-j]=c2[i][j];\n f3[n-1-i][n-1-j]=c3[i][j];\n f4[n-1-i][n-1-j]=c4[i][j];\n }\n rep(i,0,n)\n {\n rep(i,0,n)\n {\n cin >> b;\n if(b!=c1[i][j])\n fl1=0;\n if(b!=c2[i][j])\n fl2=0;\n if(b!=c3[i][j])\n fl3=0;\n if(b!=c4[i][j])\n fl4=0;\n if(b!=d1[i][j])\n fd1=0;\n if(b!=d2[i][j])\n fd2=0;\n if(b!=d3[i][j])\n fd3=0;\n if(b!=d4[i][j])\n fd4=0;\n if(b!=e1[i][j])\n fe1=0;\n if(b!=e2[i][j])\n fe2=0;\n if(b!=e3[i][j])\n fe3=0;\n if(b!=e4[i][j])\n fe4=0;\n if(b!=f1[i][j])\n ff1=0;\n if(b!=f2[i][j])\n ff2=0;\n if(b!=f3[i][j])\n ff3=0;\n if(b!=f4[i][j])\n ff4=0;\n }\n }\n if(fl1 || fl2 || fl3 || fl4 || fd1 || fd2 || fd3 || fd4 || fe1 || fe2 || fe3 || fe4 || ff1 || ff2 || ff3 || ff4)\n YES;\n else\n NO;\n}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8cd31586f4b58b1c06d47d03487efcd5", "src_uid": "2e793c9f476d03e8ba7df262db1c06e4", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "//\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2584\u2591\u2591\u2591\u2591\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2584\u2584\u2591\u2591\u2584\u2591\u2591\u2591\u2588\u2591\u2584\u2584\u2584\u2591\u2591\u2591\n//\u2591\u2584\u2584\u2584\u2584\u2584\u2591\u2591\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2580\u2588\u2591\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2580\u2580\u2591\u2588\u2588\u2591\u2591\n//\u2591\u2588\u2588\u2584\u2580\u2588\u2588\u2584\u2588\u2591\u2591\u2591\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2580\u2580\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\n//\u2591\u2591\u2580\u2588\u2588\u2584\u2580\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2588\u2588\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2588\u2588\u2591\n//\u2591\u2591\u2591\u2591\u2580\u2588\u2588\u2588\u2588\u2591\u2580\u2591\u2591\u2591\u2591\u2584\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2584\u2588\u2591\u2591\u2591\u2591\u2584\u2591\u2584\u2588\u2591\u2591\u2588\u2588\u2591\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2588\u2591\u2591\u2591\u2591\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2584\u2591\u2591\u2591\u2584\u2591\u2591\u2584\u2591\u2591\u2591\u2588\u2588\u2591\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2591\u2591\u2584\u2580\u2591\u2591\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2580\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2591\u2591\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2588\u2588\u2588\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2588\u2588\u2588\u2591\u2591\u2580\u2588\u2588\u2580\u2591\u2591\u2591\u2591\u2591\u2591\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2588\u2588\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2588\u2588\u2593\u2588\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2593\u2588\u2588\u2593\u2593\u2588\u2591\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2588\u2588\u2592\u2500\u2592\u2593\u2593\u2593\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2588\u2593\u2592\u2592\u2591\u2500\u2592\u2593\u2588\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2588\u2588\u2593\u2592\u2592\u2593\u2592\u2591\u2592\u2593\u2588\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2592\u2588\u2592\u2500\u2500\u2592\u2593\u2593\u2593\u2593\u2592\u2593\u2588\u2591\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2593\u2588\u2593\u2592\u2500\u2500\u2592\u2592\u2591\u2591\u2592\u2593\u2593\u2588\u2588\n//\u2500\u2500\u2500\u2500\u2500\u2588\u2588\u2593\u2593\u2593\u2593\u2593\u2588\u2592\u2500\u2500\u2500\u2593\u2593\u2593\u2588\u2591\n//\u2500\u2500\u2500\u2500\u2588\u2588\u2592\u2593\u2593\u2588\u2592\u2500\u2500\u2500\u2592\u2588\u2588\u2588\u2500\u2500\u2593\u2588\n//\u2500\u2500\u2591\u2588\u2588\u2588\u2588\u2593\u2591\u2588\u2592\u2592\u2588\u2500\u2500\u2500\u2593\u2588\u2500\u2500\u2593\u2588\u2591\n//\u2500\u2592\u2588\u2588\u2593\u2591\u2500\u2593\u2593\u2592\u2592\u2593\u2588\u2592\u2500\u2500\u2500\u2593\u2500\u2500\u2591\u2588\u2588\n//\u2593\u2588\u2593\u2593\u2592\u2591\u2592\u2593\u2588\u2593\u2593\u2588\u2588\u2593\u2588\u2588\u2593\u2588\u2588\u2588\u2592\u2592\u2588\u2592\n//\u2588\u2593\u2593\u2593\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2592\u2588\n//\u2593\u2588\u2588\u2593\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2593\u2591\u2593\u2588\u2592\u2588\u2588\u2588\u2588\u2588\u2588\u2592\n//\u2592\u2592\u2593\u2593\u2592\u2592\u2591\u2592\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2592\u2592\u2593\u2588\u2588\u2588\n//\u2593\u2588\u2593\u2591\u2591\u2591\u2591\u2500\u2593\u2593\u2588\u2588\u2592\u2593\u2592\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2593\n//\u2592\u2592\u2593\u2592\u2591\u2591\u2591\u2500\u2593\u2588\u2588\u2588\u2588\u2592\u2591\u2592\u2592\u2592\u2592\u2592\u2591\u2592\u2591\u2591\u2591\u2588\u2588\n//\u2592\u2592\u2593\u2588\u2588\u2593\u2593\u2592\u2591\u2500\u2591\u2500\u2500\u2500\u2591\u2593\u2593\u2593\u2591\u2593\u2588\u2588\u2588\u2592\u2592\u2593\u2588\n//\u2593\u2591\u2591\u2592\u2592\u2592\u2500\u2591\u2500\u2500\u2500\u2500\u2500\u2500\u2592\u2593\u2591\u2593\u2592\u2500\u2588\u2588\u2588\u2592\u2500\u2592\u2588\u2592\n//\u2588\u2592\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2592\u2591\u2500\u2500\u2591\u2593\u2500\u2591\u2500\u2500\u2500\u2591\u2591\u2592\u2593\u2588\u2592\n//\u2588\u2588\u2588\u2591\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2588\u2500\u2500\u2500\u2592\u2500\u2500\u2591\u2592\u2500\u2500\u2591\u2592\u2592\u2588\u2588\u2592\n//\u2500\u2592\u2588\u2588\u2588\u2591\u2500\u2500\u2500\u2500\u2500\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2500\u2500\u2500\u2591\u2592\u2593\u2588\u2593\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2593\u2588\n//\u2500\u2500\u2500\u2500\u2592\u2588\u2591\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2592\u2588\u2588\u2500\u2500\u2500\u2500\u2500\u2591\u2593\u2588\u2588\u2588\u2592\n//\u2588\u2592\u2500\u2500\u2500\u2500\u2588\u2592\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2592\u2593\u2593\u2588\u2500\u2500\u2500\u2593\u2588\u2588\u2588\u2592\n//\u2593\u2588\u2588\u2500\u2500\u2500\u2500\u2500\u2591\u2591\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2592\n//\u2588\u2588\u2588\u2588\u2592\u2500\u2500\u2500\u2500\u2500\u2591\u2592\u2591\u2591\u2591\u2500\u2500\u2500\u2500\u2500\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\n//\u2593\u2593\u2588\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2593\u2588\u2593\n//\u2588\u2593\u2593\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2593\u2588\u2588\u2588\u2588\u2593\u2588\u2588\u2593\u2593\u2592\u2592\u2592\u2593\u2588\u2591\n//\u2593\u2591\u2500\u2500\u2500\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2592\u2500\u2500\u2500\u2500\u2500\u2593\u2588\u2593\u2593\u2592\u2593\u2593\u2593\u2588\u2592\n//\u2500\u2591\u2588\u2588\u2588\u2588\u2588\u2592\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2592\u2593\u2593\u2593\u2592\u2592\u2593\u2588\u2588\u2592\n//\u2500\u2500\u2588\u2591\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2588\u2593\u2593\u2593\u2592\u2592\u2593\u2593\u2588\u2591\n//\u2593\u2591\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2588\u2593\u2593\u2593\u2588\u2592\u2593\u2593\u2588\u2588\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2592\u2588\u2588\u2588\u2588\u2588\u2593\u2593\u2593\u2593\u2588\u2592\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2500\u2500\u2591\u2588\u2588\u2593\u2593\u2593\u2593\u2588\u2588\u2593\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2592\u2592\u2591\u2500\u2500\u2500\u2500\u2592\u2588\u2593\u2593\u2593\u2588\u2591\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\u2588\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2588\u2500\u2588\u2500\u2588\u2500\u2500\u2500\u2588\u2500\u2588\u2500\u2500\u2500\u2588\u2588\u2500\u2588\u2588\n//\u2588\u2500\u2500\u2588\u2588\u2500\u2500\u2500\u2588\u2588\u2588\u2588\u2588\u2500\u2500\u2500\u2588\u2500\u2588\u2500\u2500\u2500\u2500\u2588\u2588\u2588\n//\u2588\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2500\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2500\u2588\n//\u2588\u2500\u2500\u2588\u2588\u2500\u2500\u2500\u2588\u2588\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2500\u2588\u2500\u2500\u2500\u2500\u2588\u2588\u2588\n//\u2588\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2588\u2500\u2588\u2500\u2588\u2500\u2500\u2500\u2588\u2588\u2588\u2500\u2500\u2500\u2588\u2588\u2500\u2588\u2588\n\n#define vc vector \n#define sz(v) (int)(v.size())\n#define pb(a) push_back(a)\n#define each(it,s) for(auto it = s.begin(); it != s.end(); it++)\n#define rep(i, b, n) for(int i = (b); i < (n); i++)\n#define all(v) v.begin(), v.end()\n#define FI first\n#define SE second\n#define rr(i,j,n,m) for(int i=0;i>n;\n char c1[10][10],c2[10][10],c3[10][10],c4[10][10],b,d1[10][10],d2[10][10],d3[10][10],d4[10][10],e1[10][10],e2[10][10],e3[10][10],e4[10][10],f1[10][10],f2[10][10],f3[10][10],f4[10][10];\n rep(i,0,n)\n {\n rep(i,0,n)\n {\n cin >> c1[i][j];\n c2[j][n-1-i]=c1[i][j];\n c3[n-1-i][n-1-j]=c1[i][j];\n c4[n-1-j][i]=c1[i][j];\n }\n }\n rr(i,j,n,n)\n {\n d1[i][n-1-j]=c1[i][j];\n d2[i][n-1-j]=c2[i][j];\n d3[i][n-1-j]=c3[i][j];\n d4[i][n-1-j]=c4[i][j];\n e1[n-1-i][j]=c1[i][j];\n e2[n-1-i][j]=c2[i][j];\n e3[n-1-i][j]=c3[i][j];\n e4[n-1-i][j]=c4[i][j];\n f1[n-1-i][n-1-j]=c1[i][j];\n f2[n-1-i][n-1-j]=c2[i][j];\n f3[n-1-i][n-1-j]=c3[i][j];\n f4[n-1-i][n-1-j]=c4[i][j];\n }\n rep(i,0,n)\n {\n rep(j,0,n)\n {\n cin >> b;\n if(b!=c1[i][j])\n fl1=0;\n if(b!=c2[i][j])\n fl2=0;\n if(b!=c3[i][j])\n fl3=0;\n if(b!=c4[i][j])\n fl4=0;\n if(b!=d1[i][j])\n fd1=0;\n if(b!=d2[i][j])\n fd2=0;\n if(b!=d3[i][j])\n fd3=0;\n if(b!=d4[i][j])\n fd4=0;\n if(b!=e1[i][j])\n fe1=0;\n if(b!=e2[i][j])\n fe2=0;\n if(b!=e3[i][j])\n fe3=0;\n if(b!=e4[i][j])\n fe4=0;\n if(b!=f1[i][j])\n ff1=0;\n if(b!=f2[i][j])\n ff2=0;\n if(b!=f3[i][j])\n ff3=0;\n if(b!=f4[i][j])\n ff4=0;\n }\n }\n if(fl1 || fl2 || fl3 || fl4 || fd1 || fd2 || fd3 || fd4 || fe1 || fe2 || fe3 || fe4 || ff1 || ff2 || ff3 || ff4)\n YES;\n else\n NO;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "34bd830a3a278437bfa09637b58e3e10", "src_uid": "2e793c9f476d03e8ba7df262db1c06e4", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "//\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2584\u2591\u2591\u2591\u2591\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2584\u2584\u2591\u2591\u2584\u2591\u2591\u2591\u2588\u2591\u2584\u2584\u2584\u2591\u2591\u2591\n//\u2591\u2584\u2584\u2584\u2584\u2584\u2591\u2591\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2580\u2588\u2591\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2580\u2580\u2591\u2588\u2588\u2591\u2591\n//\u2591\u2588\u2588\u2584\u2580\u2588\u2588\u2584\u2588\u2591\u2591\u2591\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2580\u2580\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\n//\u2591\u2591\u2580\u2588\u2588\u2584\u2580\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2588\u2588\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2588\u2588\u2591\n//\u2591\u2591\u2591\u2591\u2580\u2588\u2588\u2588\u2588\u2591\u2580\u2591\u2591\u2591\u2591\u2584\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2584\u2588\u2591\u2591\u2591\u2591\u2584\u2591\u2584\u2588\u2591\u2591\u2588\u2588\u2591\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2588\u2591\u2591\u2591\u2591\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2591\u2591\u2591\u2591\u2584\u2591\u2591\u2591\u2584\u2591\u2591\u2584\u2591\u2591\u2591\u2588\u2588\u2591\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2588\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2591\u2591\u2584\u2580\u2591\u2591\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2580\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2591\u2591\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2588\u2588\u2588\u2588\u2580\u2591\u2591\u2588\u2588\u2588\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2588\u2588\u2588\u2591\u2591\u2580\u2588\u2588\u2580\u2591\u2591\u2591\u2591\u2591\u2591\n//\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2588\u2588\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2588\u2588\u2593\u2588\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2593\u2588\u2588\u2593\u2593\u2588\u2591\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2588\u2588\u2592\u2500\u2592\u2593\u2593\u2593\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2588\u2593\u2592\u2592\u2591\u2500\u2592\u2593\u2588\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2588\u2588\u2593\u2592\u2592\u2593\u2592\u2591\u2592\u2593\u2588\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2592\u2588\u2592\u2500\u2500\u2592\u2593\u2593\u2593\u2593\u2592\u2593\u2588\u2591\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2593\u2588\u2593\u2592\u2500\u2500\u2592\u2592\u2591\u2591\u2592\u2593\u2593\u2588\u2588\n//\u2500\u2500\u2500\u2500\u2500\u2588\u2588\u2593\u2593\u2593\u2593\u2593\u2588\u2592\u2500\u2500\u2500\u2593\u2593\u2593\u2588\u2591\n//\u2500\u2500\u2500\u2500\u2588\u2588\u2592\u2593\u2593\u2588\u2592\u2500\u2500\u2500\u2592\u2588\u2588\u2588\u2500\u2500\u2593\u2588\n//\u2500\u2500\u2591\u2588\u2588\u2588\u2588\u2593\u2591\u2588\u2592\u2592\u2588\u2500\u2500\u2500\u2593\u2588\u2500\u2500\u2593\u2588\u2591\n//\u2500\u2592\u2588\u2588\u2593\u2591\u2500\u2593\u2593\u2592\u2592\u2593\u2588\u2592\u2500\u2500\u2500\u2593\u2500\u2500\u2591\u2588\u2588\n//\u2593\u2588\u2593\u2593\u2592\u2591\u2592\u2593\u2588\u2593\u2593\u2588\u2588\u2593\u2588\u2588\u2593\u2588\u2588\u2588\u2592\u2592\u2588\u2592\n//\u2588\u2593\u2593\u2593\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2592\u2592\u2588\n//\u2593\u2588\u2588\u2593\u2588\u2588\u2588\u2593\u2591\u2591\u2591\u2591\u2591\u2593\u2591\u2593\u2588\u2592\u2588\u2588\u2588\u2588\u2588\u2588\u2592\n//\u2592\u2592\u2593\u2593\u2592\u2592\u2591\u2592\u2593\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2592\u2592\u2593\u2588\u2588\u2588\n//\u2593\u2588\u2593\u2591\u2591\u2591\u2591\u2500\u2593\u2593\u2588\u2588\u2592\u2593\u2592\u2592\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2592\u2588\u2593\n//\u2592\u2592\u2593\u2592\u2591\u2591\u2591\u2500\u2593\u2588\u2588\u2588\u2588\u2592\u2591\u2592\u2592\u2592\u2592\u2592\u2591\u2592\u2591\u2591\u2591\u2588\u2588\n//\u2592\u2592\u2593\u2588\u2588\u2593\u2593\u2592\u2591\u2500\u2591\u2500\u2500\u2500\u2591\u2593\u2593\u2593\u2591\u2593\u2588\u2588\u2588\u2592\u2592\u2593\u2588\n//\u2593\u2591\u2591\u2592\u2592\u2592\u2500\u2591\u2500\u2500\u2500\u2500\u2500\u2500\u2592\u2593\u2591\u2593\u2592\u2500\u2588\u2588\u2588\u2592\u2500\u2592\u2588\u2592\n//\u2588\u2592\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2592\u2591\u2500\u2500\u2591\u2593\u2500\u2591\u2500\u2500\u2500\u2591\u2591\u2592\u2593\u2588\u2592\n//\u2588\u2588\u2588\u2591\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2588\u2500\u2500\u2500\u2592\u2500\u2500\u2591\u2592\u2500\u2500\u2591\u2592\u2592\u2588\u2588\u2592\n//\u2500\u2592\u2588\u2588\u2588\u2591\u2500\u2500\u2500\u2500\u2500\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2500\u2500\u2500\u2591\u2592\u2593\u2588\u2593\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2593\u2588\n//\u2500\u2500\u2500\u2500\u2592\u2588\u2591\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2592\u2588\u2588\u2500\u2500\u2500\u2500\u2500\u2591\u2593\u2588\u2588\u2588\u2592\n//\u2588\u2592\u2500\u2500\u2500\u2500\u2588\u2592\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2592\u2593\u2593\u2588\u2500\u2500\u2500\u2593\u2588\u2588\u2588\u2592\n//\u2593\u2588\u2588\u2500\u2500\u2500\u2500\u2500\u2591\u2591\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2592\n//\u2588\u2588\u2588\u2588\u2592\u2500\u2500\u2500\u2500\u2500\u2591\u2592\u2591\u2591\u2591\u2500\u2500\u2500\u2500\u2500\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\n//\u2593\u2593\u2588\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2593\u2588\u2588\u2588\u2588\u2588\u2588\u2593\u2593\u2588\u2593\n//\u2588\u2593\u2593\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2593\u2588\u2588\u2588\u2588\u2593\u2588\u2588\u2593\u2593\u2592\u2592\u2592\u2593\u2588\u2591\n//\u2593\u2591\u2500\u2500\u2500\u2591\u2592\u2588\u2588\u2588\u2588\u2588\u2592\u2500\u2500\u2500\u2500\u2500\u2593\u2588\u2593\u2593\u2592\u2593\u2593\u2593\u2588\u2592\n//\u2500\u2591\u2588\u2588\u2588\u2588\u2588\u2592\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2592\u2593\u2593\u2593\u2592\u2592\u2593\u2588\u2588\u2592\n//\u2500\u2500\u2588\u2591\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2588\u2593\u2593\u2593\u2592\u2592\u2593\u2593\u2588\u2591\n//\u2593\u2591\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2588\u2593\u2593\u2593\u2588\u2592\u2593\u2593\u2588\u2588\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2592\u2588\u2588\u2588\u2588\u2588\u2593\u2593\u2593\u2593\u2588\u2592\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2591\u2500\u2500\u2591\u2588\u2588\u2593\u2593\u2593\u2593\u2588\u2588\u2593\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2592\u2592\u2591\u2500\u2500\u2500\u2500\u2592\u2588\u2593\u2593\u2593\u2588\u2591\n//\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n//\u2588\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2588\u2500\u2588\u2500\u2588\u2500\u2500\u2500\u2588\u2500\u2588\u2500\u2500\u2500\u2588\u2588\u2500\u2588\u2588\n//\u2588\u2500\u2500\u2588\u2588\u2500\u2500\u2500\u2588\u2588\u2588\u2588\u2588\u2500\u2500\u2500\u2588\u2500\u2588\u2500\u2500\u2500\u2500\u2588\u2588\u2588\n//\u2588\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2500\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2500\u2588\n//\u2588\u2500\u2500\u2588\u2588\u2500\u2500\u2500\u2588\u2588\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2500\u2588\u2500\u2500\u2500\u2500\u2588\u2588\u2588\n//\u2588\u2588\u2588\u2588\u2500\u2500\u2500\u2500\u2588\u2500\u2588\u2500\u2588\u2500\u2500\u2500\u2588\u2588\u2588\u2500\u2500\u2500\u2588\u2588\u2500\u2588\u2588\n\n#define vc vector \n#define sz(v) (int)(v.size())\n#define pb(a) push_back(a)\n#define each(it,s) for(auto it = s.begin(); it != s.end(); it++)\n#define rep(i, b, n) for(int i = (b); i < (n); i++)\n#define all(v) v.begin(), v.end()\n#define FI first\n#define SE second\n#define rr(i,j,n,m) for(int i=0;i>n;\n char c1[10][10],c2[10][10],c3[10][10],c4[10][10],b,d1[10][10],d2[10][10],d3[10][10],d4[10][10],e1[10][10],e2[10][10],e3[10][10],e4[10][10],f1[10][10],f2[10][10],f3[10][10],f4[10][10];\n rep(i,0,n)\n {\n rep(i,0,n)\n {\n cin >> c1[i][j];\n c2[j][n-1-i]=c1[i][j];\n c3[n-1-i][n-1-j]=c1[i][j];\n c4[n-1-j][i]=c1[i][j];\n }\n }\n rep(i,0,n)\n (i,0,n)\n {\n d1[i][n-1-j]=c1[i][j];\n d2[i][n-1-j]=c2[i][j];\n d3[i][n-1-j]=c3[i][j];\n d4[i][n-1-j]=c4[i][j];\n e1[n-1-i][j]=c1[i][j];\n e2[n-1-i][j]=c2[i][j];\n e3[n-1-i][j]=c3[i][j];\n e4[n-1-i][j]=c4[i][j];\n f1[n-1-i][n-1-j]=c1[i][j];\n f2[n-1-i][n-1-j]=c2[i][j];\n f3[n-1-i][n-1-j]=c3[i][j];\n f4[n-1-i][n-1-j]=c4[i][j];\n }\n rep(i,0,n)\n {\n rep(i,0,n)\n {\n cin >> b;\n if(b!=c1[i][j])\n fl1=0;\n if(b!=c2[i][j])\n fl2=0;\n if(b!=c3[i][j])\n fl3=0;\n if(b!=c4[i][j])\n fl4=0;\n if(b!=d1[i][j])\n fd1=0;\n if(b!=d2[i][j])\n fd2=0;\n if(b!=d3[i][j])\n fd3=0;\n if(b!=d4[i][j])\n fd4=0;\n if(b!=e1[i][j])\n fe1=0;\n if(b!=e2[i][j])\n fe2=0;\n if(b!=e3[i][j])\n fe3=0;\n if(b!=e4[i][j])\n fe4=0;\n if(b!=f1[i][j])\n ff1=0;\n if(b!=f2[i][j])\n ff2=0;\n if(b!=f3[i][j])\n ff3=0;\n if(b!=f4[i][j])\n ff4=0;\n }\n }\n if(fl1 || fl2 || fl3 || fl4 || fd1 || fd2 || fd3 || fd4 || fe1 || fe2 || fe3 || fe4 || ff1 || ff2 || ff3 || ff4)\n YES;\n else\n NO;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "24882a9309c8af4244da033e586e8ca9", "src_uid": "2e793c9f476d03e8ba7df262db1c06e4", "difficulty": 1400.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint n;\nbool sab(int a[10][10],int b[10][10]){\n\nint i,j;\n\nbool flag=true;\nfor(i=0;i>n;\nstring str[n],str1[n];\nint a[10][10],b[10][10],vf[10][10],hf[10][10];\nint i,j;\nfor(i=0;i>str[i];\n\nfor(i=0;i>str1[i];\n\nfor(i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define REP(i, n) for (int i=0;i=int(a);--i)\n#define REP_1(i, n) for (int i=1;i<=int(n);++i)\n#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)\n#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)\n#define REP_C(i, n) for (int n____=int(n),i=0;i=a____;--i)\n#define REP_N(i, n) for (i=0;i=int(a);--i)\n#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)\n#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)\n#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)\n#define REP_1_N(i, n) for (i=1;i<=int(n);++i)\n#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)\n#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)\n#define REP_C_N(i, n) for (int n____=(i=0,int(n));i=a____;--i)\n#define REP_1_C_N(i, n) for (int n____=(i=1,int(n));i<=n____;++i)\n#define FOR_1_C_N(i, a, b) for (int b____=(i=1,int(b);i<=b____;++i)\n#define DWN_1_C_N(i, b, a) for (int a____=(i=b,int(a));i>=a____;--i)\n\n#define ECH(it, A) for (__typeof(A.begin()) it=A.begin(); it != A.end(); ++it)\n#define REP_S(i, str) for (char*i=str;*i;++i)\n#define REP_L(i, hd, nxt) for (int i=hd;i;i=nxt[i])\n#define REP_G(i, u) REP_L(i,hd[u],suc)\n#define DO(n) for ( int ____n ## __line__ = n; ____n ## __line__ -- ; )\n#define REP_2(i, j, n, m) REP(i, n) REP(j, m)\n#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)\n#define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l)\n#define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l)\n#define REP_4(i, j, k, ii, n, m, l, nn) REP(i, n) REP(j, m) REP(k, l) REP(ii, nn)\n#define REP_4_1(i, j, k, ii, n, m, l, nn) REP_1(i, n) REP_1(j, m) REP_1(k, l) REP_1(ii, nn)\n\n#define ALL(A) A.begin(), A.end()\n#define LLA(A) A.rbegin(), A.rend()\n#define CPY(A, B) memcpy(A, B, sizeof(A))\n#define INS(A, P, B) A.insert(A.begin() + P, B)\n#define ERS(A, P) A.erase(A.begin() + P)\n#define BSC(A, x) (lower_bound(ALL(A), x) - A.begin())\n#define CTN(T, x) (T.find(x) != T.end())\n#define SZ(A) int(A.size())\n#define PB push_back\n#define MP(A, B) make_pair(A, B)\n#define PTT pair\n#define fi first\n#define se second\n\n#define Rush for(int ____T=RD(); ____T--;)\n\n#define Display(A, n, m) { \\\n\tREP(i, n){\t\t \\\n REP(j, m) cout << A[i][j] << \" \"; \\\n cout << endl;\t\t\t\t \\\n\t}\t\t\t\t\t\t \\\n}\n\n#define Display_1(A, n, m) {\t\t\t\t \\\n\tREP_1(i, n){\t\t \\\n REP_1(j, m) cout << A[i][j] << \" \"; \\\n\t\tcout << endl;\t\t \t\t\\\n\t}\t\t\t\t\t\t \\\n}\n\n#pragma comment(linker, \"/STACK:36777216\")\n//#pragma GCC optimize (\"O2\")\n#define Ruby system(\"ruby main.rb\")\n#define Haskell system(\"runghc main.hs\")\n#define Python system(\"python main.py\")\n#define Pascal system(\"fpc main.pas\")\n\ntypedef long long LL;\n//typedef long double DB;\ntypedef double DB;\ntypedef unsigned UINT;\ntypedef unsigned long long ULL;\n\ntypedef vector VI;\ntypedef vector VC;\ntypedef vector VS;\ntypedef vector VL;\ntypedef vector VF;\ntypedef set SI;\ntypedef set SS;\ntypedef map MII;\ntypedef map MSI;\ntypedef pair PII;\ntypedef pair PLL;\ntypedef vector VII;\ntypedef vector VVI;\ntypedef vector VVII;\n\ntemplate inline T& RD(T &);\ntemplate inline void OT(const T &);\ninline LL RD(){LL x; return RD(x);}\ninline DB& RF(DB &);\ninline DB RF(){DB x; return RF(x);}\ninline char* RS(char *s);\ninline char& RC(char &c);\ninline char RC();\ninline char& RC(char &c){scanf(\" %c\", &c); return c;}\ninline char RC(){char c; return RC(c);}\n//inline char& RC(char &c){c = getchar(); return c;}\n//inline char RC(){return getchar();}\n\ntemplate inline T& RDD(T &x){\n char c; for (c = getchar(); c < '-'; c = getchar());\n if (c == '-'){x = '0' - getchar(); for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + '0' - c;}\n else {x = c - '0'; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';}\n return x;\n}\n\ninline LL RDD(){LL x; return RDD(x);}\n\ntemplate inline T0& RD(T0 &x0, T1 &x1){RD(x0), RD(x1); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6); return x0;}\ntemplate inline void OT(const T0 &x0, const T1 &x1){OT(x0), OT(x1);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2){OT(x0), OT(x1), OT(x2);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}\ninline char& RC(char &a, char &b){RC(a), RC(b); return a;}\ninline char& RC(char &a, char &b, char &c){RC(a), RC(b), RC(c); return a;}\ninline char& RC(char &a, char &b, char &c, char &d){RC(a), RC(b), RC(c), RC(d); return a;}\ninline char& RC(char &a, char &b, char &c, char &d, char &e){RC(a), RC(b), RC(c), RC(d), RC(e); return a;}\ninline char& RC(char &a, char &b, char &c, char &d, char &e, char &f){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f); return a;}\ninline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g); return a;}\ninline DB& RF(DB &a, DB &b){RF(a), RF(b); return a;}\ninline DB& RF(DB &a, DB &b, DB &c){RF(a), RF(b), RF(c); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d){RF(a), RF(b), RF(c), RF(d); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e){RF(a), RF(b), RF(c), RF(d), RF(e); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g); return a;}\ninline void RS(char *s1, char *s2){RS(s1), RS(s2);}\ninline void RS(char *s1, char *s2, char *s3){RS(s1), RS(s2), RS(s3);}\ntemplateinline void RDD(const T0&a, const T1&b){RDD(a),RDD(b);}\ntemplateinline void RDD(const T0&a, const T1&b, const T2&c){RDD(a),RDD(b),RDD(c);}\n\ntemplate inline void RST(T &A){memset(A, 0, sizeof(A));}\ntemplate inline void FLC(T &A, int x){memset(A, x, sizeof(A));}\ntemplate inline void CLR(T &A){A.clear();}\n\ntemplate inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}\ntemplate inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x), FLC(A6, x);}\ntemplate inline void CLR(priority_queue, less > &Q){while (!Q.empty()) Q.pop();}\ntemplate inline void CLR(priority_queue, greater > &Q){while (!Q.empty()) Q.pop();}\ntemplate inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}\ntemplate inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}\n\ntemplate inline T& SRT(T &A){sort(ALL(A)); return A;}\ntemplate inline T& SRT(T &A, C B){sort(ALL(A), B); return A;}\ntemplate inline T& UNQ(T &A){A.resize(unique(ALL(SRT(A)))-A.begin());return A;}\n\n//}\n\n/** Constant List .. **/ //{\n\nconst int dx4[] = {-1, 0, 1, 0};\nconst int dy4[] = {0, 1, 0, -1};\n\nconst int dx8[] = {-1, 0, 1, 0 , -1 , -1 , 1 , 1};\nconst int dy8[] = {0, 1, 0, -1 , -1 , 1 , -1 , 1};\n\nconst int dxhorse[] = {-2 , -2 , -1 , -1 , 1 , 1 , 2 , 2};\nconst int dyhorse[] = {1 , -1 , 2 , -2 , 2 ,-2 , 1 ,-1};\n\nconst int MOD = 1000000007;\n//int MOD = 99990001;\nconst int INF = 0x3f3f3f3f;\nconst LL INFF = 1LL << 60;\nconst DB EPS = 1e-9;\nconst DB OO = 1e15;\nconst DB PI = acos(-1.0); //M_PI;\n\n//}\n\n/** Add On .. **/ //{\n// <<= '0. Nichi Joo ., //{\ntemplate inline void checkMin(T &a,const T b){if (b inline void checkMax(T &a,const T b){if (a inline void checkMin(T &a, T &b, const T x){checkMin(a, x), checkMin(b, x);}\ntemplate inline void checkMax(T &a, T &b, const T x){checkMax(a, x), checkMax(b, x);}\ntemplate inline void checkMin(T& a, const T b, C c){if (c(b,a)) a = b;}\ntemplate inline void checkMax(T& a, const T b, C c){if (c(a,b)) a = b;}\ntemplate inline T min(T a, T b, T c){return min(min(a, b), c);}\ntemplate inline T max(T a, T b, T c){return max(max(a, b), c);}\ntemplate inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}\ntemplate inline T max(T a, T b, T c, T d){return max(max(a, b), max(c, d));}\ntemplate inline T sqr(T a){return a*a;}\ntemplate inline T cub(T a){return a*a*a;}\ninline int ceil(int x, int y){return (x - 1) / y + 1;}\ninline int sgn(DB x){return x < -EPS ? -1 : x > EPS;}\ninline int sgn(DB x, DB y){return sgn(x - y);}\n//}\n// <<= '1. Bitwise Operation ., //{\nnamespace BO{\n\ninline bool _1(int x, int i){return bool(x&1<> 1) & 0x55555555) | ((x << 1) & 0xaaaaaaaa);\n x = ((x >> 2) & 0x33333333) | ((x << 2) & 0xcccccccc);\n x = ((x >> 4) & 0x0f0f0f0f) | ((x << 4) & 0xf0f0f0f0);\n x = ((x >> 8) & 0x00ff00ff) | ((x << 8) & 0xff00ff00);\n x = ((x >>16) & 0x0000ffff) | ((x <<16) & 0xffff0000);\n return x;\n}\n\ninline LL reverse_bits(LL x){\n x = ((x >> 1) & 0x5555555555555555LL) | ((x << 1) & 0xaaaaaaaaaaaaaaaaLL);\n x = ((x >> 2) & 0x3333333333333333LL) | ((x << 2) & 0xccccccccccccccccLL);\n x = ((x >> 4) & 0x0f0f0f0f0f0f0f0fLL) | ((x << 4) & 0xf0f0f0f0f0f0f0f0LL);\n x = ((x >> 8) & 0x00ff00ff00ff00ffLL) | ((x << 8) & 0xff00ff00ff00ff00LL);\n x = ((x >>16) & 0x0000ffff0000ffffLL) | ((x <<16) & 0xffff0000ffff0000LL);\n x = ((x >>32) & 0x00000000ffffffffLL) | ((x <<32) & 0xffffffff00000000LL);\n return x;\n}\n\ntemplate inline bool odd(T x){return x&1;}\ntemplate inline bool even(T x){return !odd(x);}\ntemplate inline T low_bit(T x) {return x & -x;}\ntemplate inline T high_bit(T x) {T p = low_bit(x);while (p != x) x -= p, p = low_bit(x);return p;}\ntemplate inline T cover_bit(T x){T p = 1; while (p < x) p <<= 1;return p;}\n\ninline int low_idx(int x){return __builtin_ffs(x);}\ninline int low_idx(LL x){return __builtin_ffsll(x);}\ninline int high_idx(int x){return low_idx(reverse_bits(x));}\ninline int high_idx(LL x){return low_idx(reverse_bits(x));}\ninline int clz(int x){return __builtin_clz(x);}\ninline int clz(LL x){return __builtin_clzll(x);}\ninline int ctz(int x){return __builtin_ctz(x);}\ninline int ctz(LL x){return __builtin_ctzll(x);}\ninline int parity(int x){return __builtin_parity(x);}\ninline int parity(LL x){return __builtin_parityll(x);}\ninline int lg2(int a){return 31 - clz(a);}\ninline int lg2(LL a){return 63 - clz(a);}\ninline int count_bits(int x){return __builtin_popcount(x);}\ninline int count_bits(LL x){return __builtin_popcountll(x);}\n\n} using namespace BO;//}\n// <<= '2. Number Theory .,//{\nnamespace NT{\ninline LL __lcm(LL a, LL b){return a*b/__gcd(a,b);}\ninline void INC(int &a, int b){a += b; if (a >= MOD) a -= MOD;}\ninline int sum(int a, int b){a += b; if (a >= MOD) a -= MOD; return a;}\ninline void DEC(int &a, int b){a -= b; if (a < 0) a += MOD;}\ninline int dff(int a, int b){a -= b; if (a < 0) a += MOD; return a;}\ninline void MUL(int &a, int b){a = (LL)a * b % MOD;}\ninline int pdt(int a, int b){return (LL)a * b % MOD;}\n\ninline int sum(int a, int b, int c){return sum(sum(a, b), c);}\ninline int sum(int a, int b, int c, int d){return sum(sum(a, b), sum(c, d));}\ninline int pdt(int a, int b, int c){return pdt(pdt(a, b), c);}\ninline int pdt(int a, int b, int c, int d){return pdt(pdt(pdt(a, b), c), d);}\n\ninline int pow(int a, int b){\n int c(1); while (b){\n if (b&1) MUL(c, a);\n MUL(a, a), b >>= 1;\n }\n return c;\n}\n\ninline int pow(int a, LL b){\n int c(1); while (b){\n if (b&1) MUL(c, a);\n MUL(a, a), b >>= 1;\n }\n return c;\n}\n\ntemplate inline T pow(T a, LL b){\n T c(1); while (b){\n if (b&1) c *= a;\n a *= a, b >>= 1;\n }\n return c;\n}\n\ninline int _I(int b){\n int a = MOD, x1 = 0, x2 = 1, q;\n while (true){\n q = a / b, a %= b;\n if (!a) return (x2 + MOD) % MOD;\n DEC(x1, pdt(q, x2));\n\n q = b / a, b %= a;\n if (!b) return (x1 + MOD) % MOD;\n DEC(x2, pdt(q, x1));\n }\n}\n\ninline void DIV(int &a, int b){MUL(a, _I(b));}\ninline int qtt(int a, int b){return pdt(a, _I(b));}\n\ninline int phi(int n){\n int res = n; for (int i=2;sqr(i)<=n;++i) if (!(n%i)){\n DEC(res, qtt(res, i));\n do{n /= i;} while(!(n%i));\n }\n if (n != 1)\n DEC(res, qtt(res, n));\n return res;\n}\n\n} using namespace NT;//}\n//}\n\n/** Miscellaneous .. **/ //{\n// <<= 'Random Event .. . //{\nnamespace RNG{\n//srand((unsigned)time(NULL));\ninline unsigned int rand16(){return ((rand()) << 15) ^ rand();}\ninline unsigned int rand32(){return (rand16() << 16) | rand16();}\ninline ULL rand64(){return ((LL)rand32() << 32) | rand32();}\ninline ULL random(LL l, LL r){return l == r ? l : rand64() % (r - l) + l;}\nint dice(){return rand() % 6;}\nbool coin(){return bool(rand() % 2);}\n} using namespace RNG;\n//}\n// <<= 'Clock .. . //{\nnamespace CLOCK{\nDB s0, s1, rd, k, T;\ninline DB getTime(){\n#ifdef LOCAL\n return 1.0 * clock() / CLOCKS_PER_SEC;\n#else\n timeval tv;\n gettimeofday(&tv, 0);\n return tv.tv_sec + tv.tv_usec * 1e-6;\n#endif\n}\n\ninline void st0(DB _T = 0.98){T = _T, s0 = getTime();}\ninline void st1(DB _k = 1.618){k = _k, s1 = getTime();}\ninline void ed1(){rd = getTime() - s1;}\ninline DB elapsed(){return getTime() - s0;}\ninline bool safe(){return elapsed() + rd * k < T;}\n} //using namespace CLOCK;\n//}\n// <<= 'Temp .. . //{\nnamespace TMP{\ntemplate PTT operator+(const PTT &p1, const PTT &p2) {\n\treturn PTT(p1.fi + p2.fi, p1.se + p2.se);\n}\n\ntemplate PTT operator-(const PTT &p1, const PTT &p2) {\n\treturn PTT(p1.fi - p2.fi, p1.se - p2.se);\n}\n\ntemplate PTT operator*(const PTT &lhs, T k){\n return PTT(lhs.fi * k, lhs.se * k);\n}\n} using namespace TMP;\n//}\n//}\n\n/** Algorithm .. */ //{\n// <<= '-. Math .,//{\nnamespace Math{\n\ttypedef long long typec;\n\t///Lib functions\n\ttypec GCD(typec a, typec b)\n\t{\n\t\treturn b ? GCD(b, a % b) : a;\n\t}\n\ttypec extendGCD(typec a, typec b, typec& x, typec& y)\n\t{\n\t\tif(!b) return x = 1, y = 0, a;\n\t\ttypec res = extendGCD(b, a % b, x, y), tmp = x;\n\t\tx = y, y = tmp - (a / b) * y;\n\t\treturn res;\n\t}\n\t///for x^k\n\ttypec power(typec x, typec k)\n\t{\n\t\ttypec res = 1;\n\t\twhile(k)\n\t\t{\n\t\t\tif(k&1) res *= x;\n\t\t\tx *= x, k >>= 1;\n\t\t}\n\t\treturn res;\n\t}\n\t///for x^k mod m\n\ttypec powerMod(typec x, typec k, typec m)\n\t{\n\t\ttypec res = 1;\n\t\twhile(x %= m, k)\n\t\t{\n\t\t\tif(k&1) res *= x, res %= m;\n\t\t\tx *= x, k >>=1;\n\t\t}\n\t\treturn res;\n\t}\n\t/***************************************\n\tInverse in mod p^t system\n\t***************************************/\n\ttypec inverse(typec a, typec p, typec t = 1)\n\t{\n\t\ttypec pt = power(p, t);\n\t\ttypec x, y;\n\t y = extendGCD(a, pt, x, y);\n\t\treturn x < 0 ? x += pt : x;\n\t}\n\t/***************************************\n\tLinear congruence theorem\n\tx = a (mod p)\n\tx = b (mod q)\n\tfor gcd(p, q) = 1, 0 <= x < pq\n\t***************************************/\n\ttypec linearCongruence(typec a, typec b, typec p, typec q)\n\t{\n\t\ttypec x, y;\n\t\ty = extendGCD(p, q, x, y);\n\t\twhile(b < a) b += q / y;\n\t\tx *= b - a, x = p * x + a, x %= p * q;\n\t\tif(x < 0) x += p * q;\n\t\treturn x;\n\t}\n\t/***************************************\n\tprime table\n\tO(n)\n\t***************************************/\n\tconst int PRIMERANGE = 1000000;\n\tint prime[PRIMERANGE + 1];\n\tint mobius[PRIMERANGE + 1];\n\tint getPrime()\n\t{\n\t\tmemset (prime, 0, sizeof (int) * (PRIMERANGE + 1));\n\t\tmemset(mobius , 0 , sizeof(mobius));\n\t\tmobius[1] = 1;\n\t\tfor (int i = 2; i <= PRIMERANGE; i++)\n\t\t{\n\t\t\tif (!prime[i]) prime[++prime[0]] = i , mobius[i] = -1;\n\t\t\tfor (int j = 1; j <= prime[0] && prime[j] <= PRIMERANGE / i; j++)\n\t\t\t{\n\t\t\t\tprime[prime[j]*i] = 1;\n\t\t\t\tif (i % prime[j] == 0) break;\n\t\t\t\telse mobius[i * prime[j]] = -mobius[i];\n\t\t\t}\n\t\t}\n\t\treturn prime[0];\n\t}\n\t/***************************************\n\tget factor of n\n\tO(sqrt(n))\n\tfactor[][0] is prime factor\n\tfactor[][1] is factor generated by this prime\n\tfactor[][2] is factor counter\n\n\tneed: Prime Table\n\t***************************************/\n\t///you should init the prime table before\n\tint factor[100][3], facCnt;\n\tint getFactors(int x)\n\t{\n\t\tfacCnt = 0;\n\t\tint tmp = x;\n\t\tfor(int i = 1; prime[i] <= tmp / prime[i]; i++)\n\t\t{\n\t\t\tfactor[facCnt][1] = 1, factor[facCnt][2] = 0;\n\t\t\tif(tmp % prime[i] == 0)\n\t\t\t\tfactor[facCnt][0] = prime[i];\n\t\t\twhile(tmp % prime[i] == 0)\n\t\t\t\tfactor[facCnt][2]++, factor[facCnt][1] *= prime[i], tmp /= prime[i];\n\t\t\tif(factor[facCnt][1] > 1) facCnt++;\n\t\t}\n\t\tif(tmp != 1)\n\t\t\tfactor[facCnt][0] = tmp, factor[facCnt][1] = tmp, factor[facCnt++][2] = 1;\n\t\treturn facCnt;\n\t}\n\ttypec combinationModP(typec n, typec k, typec p)\n\t{\n\t\tif(k > n) return 0;\n\t\tif(n - k < k) k = n - k;\n\t\ttypec a = 1, b = 1, x, y;\n\t\tint pcnt = 0;\n\t\tfor(int i = 1; i <= k; i++)\n\t\t{\n\t\t\tx = n - i + 1, y = i;\n\t\t\twhile(x % p == 0) x /= p, pcnt++;\n\t\t\twhile(y % p == 0) y /= p, pcnt--;\n\t\t\tx %= p, y %= p, a *= x, b *= y;\n\t\t\tb %= p, a %= p;\n\t\t}\n\t\tif(pcnt) return 0;\n\t\textendGCD(b, p, x, y);\n\t\tif(x < 0) x += p;\n\t\ta *= x, a %= p;\n\t\treturn a;\n\t}\n};//using namespace Math;\n//}\n// <<= '-. Geo ,.//{\nnamespace Geo{\n\t#define typec double\n const typec eps=1e-9;\n int dblcmp(double d){\n if (fabs(d)eps?1:-1;\n }\n int sgn(double a) {return a<-eps?-1:a>eps;}\n inline double sqr(double x){return x*x;}\n struct Point2D{\n\t\ttypec x,y;\n\t\tPoint2D(){}\n\t\tPoint2D(typec _x,typec _y):x(_x),y(_y){};\n\t\tvoid input(){\n\t\t\tscanf(\"%lf%lf\",&x,&y);\n\t\t}\n\t\tvoid output(){\n\t\t\tprintf(\"%.2f %.2f\\n\",x,y);\n\t\t}\n\t\tbool operator==(Point2D a)const{\n\t\t\treturn dblcmp(a.x-x)==0&&dblcmp(a.y-y)==0;\n\t\t}\n\t\tbool operator<(Point2D a)const{\n\t\t\treturn dblcmp(a.x-x)==0?dblcmp(y-a.y)<0:xsub(p);\n\t\t\ttypec c=cos(angle),s=sin(angle);\n\t\t\treturn Point2D(p.x+v.x*c-v.y*s,p.y+v.x*s+v.y*c);\n\t\t}\n\t};\n\n\ttypec cross(Point2D a,Point2D b,Point2D c){\n\t\treturn (b.sub(a)).det(c.sub(a));\n\t}\n}using namespace Geo;\n//}\n//}\n\n/** I/O Accelerator Interface .. **/ //{\ntemplate inline T& RD(T &x){\n //cin >> x;\n //scanf(\"%d\", &x);\n char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';\n //char c; c = getchar(); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';\n return x;\n}\n\ninline DB& RF(DB &x){\n //cin >> x;\n scanf(\"%lf\", &x);\n /*char t; while ((t=getchar())==' '||t=='\\n'); x = t - '0';\n while ((t=getchar())!=' '&&t!='\\n'&&t!='.')x*=10,x+=t-'0';\n if (t=='.'){DB l=1; while ((t=getchar())!=' '&&t!='\\n')l*=0.1,x += (t-'0')*l;}*/\n return x;\n}\n\ninline char* RS(char *s){\n //gets(s);\n scanf(\"%s\", s);\n return s;\n}\n\nint Case; template inline void OT(const T &x){\n //printf(\"Case %d: %d\\n\", ++Case, x);\n //printf(\"%.2lf\\n\", x);\n //printf(\"%d\\n\", x);\n cout << x << endl;\n}\n//}\n/* .................................................................................................................................. */\n//pair circle[10000];\nLL a , b , w , x , c;\npair getc(int f , int t , int deep , int dec){\n// if (circle[f].fi != -1) return circle[f];\n if (f == t && deep){\n return MP(deep , dec);\n// return circle[f];\n }\n if (f >= x) {\n return getc(f - x , t , deep + 1 , dec);\n\n\n }\n else return getc(w - (x - f) , t , deep + 1 , dec + 1);\n// return circle[f];\n}\nLL t;\nbool check(LL y){\n if (y <= t) return a >= c - y;\n LL cc = c - y;\n y -= t;\n LL bb = b - x * t;\n LL aa = a;\n pair r = getc(bb , bb , 0 , 0);\n// cout << \"R = \" << r << endl;\n LL ccc = y / r.fi;\n aa -= ccc * r.se;\n y %= r.fi;\n// cout << y << endl;\n while(y--){\n if (bb >= x) bb = bb - x;\n else {\n bb = w - (x - bb);\n aa--;\n }\n }\n return cc <= aa;\n}\nvoid solve(){\n// for (int i = 0 ; i <= w ; ++i) circle[i] = MP(-1 , -1);\n// t = 0;\n// LL low = 0 , high = 2e9 , mid;\n// t = high;\n// do{\n// mid = low + high >> 1;\n// if (b - mid * x < x){\n// checkMin(t , mid);\n// high = mid - 1;\n// }\n// else low = mid + 1;\n// }while(low <= high);\n// cout << t << endl;\n t = max(0ll , (b - x) / x);\n while(b - (t + 1) * x >= x) ++t;\n while(t > 0 && b - (t - 1) * x < x) --t;\n low = 0 , high = 2e9;\n LL ans = high;\n do{\n mid = low + high >> 1;\n if (check(mid)){\n checkMin(ans , mid);\n high = mid - 1;\n }\n else low = mid + 1;\n }while(low <= high);\n OT(ans);\n}\nint main(){\n while(cin >> a >> b >> w >> x >> c) solve();\n}\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "63a814deb187be05c0f4c7fa9e376ef2", "src_uid": "a1db3dd9f8d0f0cad7bdeb1780707143", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \"iostream\"\n#include \"cstdio\"\n#include \"cstring\"\n#include \"math.h\"\n#include \"algorithm\"\nusing namespace std;\n\nint next[1200];\nint step[1200];\nint a,b,w,x,c,dx;\n\nint init(int B,int X){\n if(step[B])return B;\n step[B]=B/X+1;\n next[B]=w-(X-B%X);\n init(next[B],X);\n}\nint round(int B,int M){\n dx++;\n if(B==M)return step[B];\n return step[B]+round(next[B],M);\n}\n\n\nint main()\n{\n int Start,Rstep;\n int A,C,B,bx;\n dx=0;\n scanf(\"%d%d%d%d%d\",&a,&b,&w,&x,&c);\n memset(next,-1,sizeof(next));\n memset(step,0,sizeof(step));\n Start=init(b,x);\n Rstep=round(next[Start],Start);\n A=a;C=c;,B=b;\n while(B!=Start){\n C-=step[B];\n if(A>C){\n printf(\"%d\\n\",c-A);\n return 0;\n }\n A--;\n B=next[B];\n }\n if(A>=C){printf(\"%d\\n\",c-A);return 0;}\n bx=(C-A)/(Rstep-dx);\n if((C-A)%(Rstep-dx)==0)bx--;\n C-=Rstep;\n A-=dx;\n while(AC){\n printf(\"%d\\n\",c-A);\n return;\n }\n A--;\n Start=next[Start];\n }\n printf(\"%d\\n\",c-A);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3516c52678c52d575573ba951f9301bc", "src_uid": "a1db3dd9f8d0f0cad7bdeb1780707143", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n\nlong long a, b, w, x, c, ans;\n\nint main(){\n cin >> a >> b >> w >> x >> c;\n ans = max(0, ((w * (c - a) - b) / (w - x)));\n if((w * (c - a) - b) % (w - x) && ans)\n ans++;\n cout << ans;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e4de7c225b8f61f9889aa6424111742b", "src_uid": "a1db3dd9f8d0f0cad7bdeb1780707143", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include \n#define int long long\nusing namespace std;\n\nbool gc [1010];\nint main()\n{\n\tint a,b,w,x,c;\n\tcin >> a >> b >> w >> x >> c;\n\t\n\t\n\tif (a >= c-(b/x))\n\t{\n\t\tcout << max(0,c-a) << endl;\n\t\treturn 0;\n\t}\n\tint anw = b/x;\n\tint cf = 0;\n\tc -= b/x;\n\tb %= x;\n\tgc[b] = 1;\n\tvector rc;\n\tfor (;;)\n\t{\n\t\tb += (w-x);\n\t\trc.push_back(b/x);\n\t\tint md = b%x;\n\t\tcf += rc[rc.size()-1];\n\t\tif (gc[md]) break;\n\t\tgc[md] = 1;\n\t\tb = md;\n\t}\n\tint dis = c-a;\n\tdis /= cf;\n\tanw += cf*dis+dis*int(rc.size());\n\tc -= cf*dis;\n\tfor (int i = 0; i < rc.size(); i++)\n\t{\n\t\tif (c <= a) break;\n\t\tanw++;\n\t\tint tr = min(c-a,rc[i]);\n\t\tc -= tr;\n\t\tanw += tr;\n\t}\n\tcout << anw << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "70eef0078ee734d56bd063c1341cf9be", "src_uid": "a1db3dd9f8d0f0cad7bdeb1780707143", "difficulty": 2000.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\nint main()\n{\n int a,c;\n cin>>a>>c;\n int b=0;\n int k=pow(3.00,b);\n while(a>=k)\n {\n b++;\n k=pow(3.00,b);\n }\n int temp=b;\n \n b=0;\n k=pow(3.00,b);\n\n while(c>=k)\n {\n b++;\n k=pow(3.00,b);\n }\n int temp1=b;\n\n int value=max(temp,temp1);\n \n vector a1,c1;\n\n for(int i=value-1;i>=0;i--)\n {\n if(a=2*pow(3.00,i))\n {a1.push_back(2);a-=2*pow(3.00,i);continue;}\n\n a1.push_back(1);\n a-=pow(3.00,i);\n }\n }\n\n for(int i=value-1;i>=0;i--)\n {\n if(c=2*pow(3.00,i))\n {c1.push_back(2);c-=2*pow(3.00,i);continue;}\n\n c1.push_back(1);\n c-=pow(3.00,i);\n }\n }\n\n vector ans;\n for(int i=0;i=0;i--)\n {\n ans1+=ans[i]*pow(3.00,(int)ans.size()-1-i);\n }\n\n cout<\nusing namespace std;\n\nint ak[1000],bk[1000],sum[1000];\n\nlong long a,b,hasil=0,pengali=1;\n\nint main()\n{\n\tmemset(ak,0,sizeof(ak));\n\tmemset(bk,0,sizeof(bk));\n\tint ta=0,tb=0,maxt;\n\tcin >> a >> b;\n\twhile (a != 0)\n\t{\n\t\tta++;\n\t\tak[ta] = a%3;\n\t\ta = a/3;\n\t}\n\twhile (b != 0)\n\t{\n\t\ttb++;\n\t\tbk[tb] = b%3;\n\t\tb = b/3;\n\t}\n\tmaxt = max(ta,tb);\n\tfor(int c=1; c<=maxt; c++)\n\t{\n\t\tif (bk[c] < ak[c]) bk[c] = bk[c]+3;\n\t\tsum[c] = bk[c]-ak[c];\n\t}\n\tfor(int c=1; c<=maxt; c++)\n\t{\n\t\thasil = hasil + pengali*sum[c];\n\t\tpengali = pengali *3;\n\t}\n\tcout << hasil << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "554c0754132daeac8c0bb2713cff338b", "src_uid": "5fb635d52ddccf6a4d5103805da02a88", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\nint tera[25],terc[25];\nint get_tera(ll x){\n\tint cnt=0;\n\twhile(x){\n\t\ttera[cnt++]=x%3;\n\t\tx/=3;\n\t}\n\treturn cnt;\n}\nint get_terc(ll x){\n\tint cnt=0;\n\twhile(x){\n\t\tterc[cnt++]=x%3;\n\t\tx/=3;\n\t}\n\treturn cnt;\n}\nint main(){\n\tll a,c;cin>>a>>c;\n\tint lena=get_tera(a);\n\tint lenc=get_terc(c);\n\tint len=max(lena,lenc);\n\t//cout<<\"a=\\n\";\n\t//for(int i=len-1;i>=0;i--)cout<=0;i--)cout<=0;i--)cout<\n#include \n#include \n#include \n\nint main()\n{\n long a,c,ans=0,i=0;\n scanf(\"%ld%ld\",&a,&c);\n while(a!=0 || c!=0)\n {\n ans+=(c%3-a%3+3)%3*pow(3,i);\n a/=3;\n c/=3;\n i++;\n }\n printf(\"%ld\\n\",ans);\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4eaf375a38b06d324c6bab3fab1c5a2b", "src_uid": "5fb635d52ddccf6a4d5103805da02a88", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n#define gc getchar_unlocked\n#define fo(i,n) for(long long int i=0;i0 ; i--)\n#define Pa(i,n,a) for(long long int i=0;in;ks2(s1.begin(), s1.end());\n#define F(i,a,n) for(long long int i=a;i>X\n#define O(X) cout< si;\ntypedef pair\tpii;\ntypedef vector\t\tvi;\ntypedef vector\t\tvpii;\ntypedef vector\t\tvvi;\ntypedef set > sii;\ntypedef multiset > msii;\ntypedef map mapii;\ntypedef multimap mmapii; \ntypedef unordered_set uosi;\ntypedef unordered_multiset uomsi;\ntypedef unordered_map uomapii;\ntypedef unordered_multimap uommapii;\ntypedef priority_queue> pqpv;\n//=======================\nconst int MOD = 1'000'000'007;\nconst int N = 2e6+13, M = N;\nconst int IMax = INT_MAX;\nconst int IMin = INT_MIN; \nconst int K = 101;\n//=======================\nvi g[N];\nint a[N];\nll n, m, k;\nbool checkIfGreater(ll a, ll b){\n return a>b;\n}\n//=======================\n\n\nint main() {\n ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n string s;\n int count = x = y = 0;\n I(s);\n fo(i,s.length()){\n if(s[i] == 'Q'){\n count+=x;\n y++;\n }\n else if(s[i] == 'A'){\n x+=y;\n }\n }\n cout << count << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a4a5bc853f72391e44a2d8793641e6c2", "src_uid": "8aef4947322438664bd8610632fe0947", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main(){\n string s;\n cin>>s;\n int c=0;\n int n=s.length();\n for(int i=0;i\n#include \n#include \nusing namespace std;\n\nvectorQ,A;\n\nint Find_Q(int x)\n{\n\tint ans = upper_bound(Q.begin(),Q.end(),x) - Q.begin();\n\treturn ans;\n}\n\nint Find_A(int x)\n{\n\tint ans = upper_bound(A.begin(),A.end(),x) - A.begin();\n\treturn ans;\n}\n\nint main(int argc, char *argv[]) \n{\n\tstring str;\n\tcin >> str;\n\tint len = str.length();\n\tfor(int i = 0;i < len;i++)\n\t{\n\t\tif(str[i] == 'Q')\n\t\t\tQ.push_back(i);\n\t\tif(str[i] == 'A')\n\t\t\tA.push_back(i);\n\t}\t\t\n\tint ans = 0;\n\tfor(int i = 0;i < Q.size();i++)\n\t{\n\t\tfor(int j = Find_A(Q[i]);j < A.size();j++)\n\t\t{\n\t\t\tfor(int k = Find_Q(A[j]);k < Q.size();k++)\n\t\t\t{\n\t\t\t\tans++;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tprintf(\"%d\\n\",ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bbd2a57e41276f6e2c0a13c52823fbfb", "src_uid": "8aef4947322438664bd8610632fe0947", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nmain(){\n string s;\n int start=0,dem=0,luu1,luu2;\n cin>>s;\n for(iny i=0;i> TheCoderJU (BISHAL) *\n ************************************************************* */\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nlong long i,j,k,m,n,tc,sm,cnt=0,tmp,cs=1,p,q,f=1,g=1,ar[M+5];\nstring s,s1,sw[10000];\nint main()\n{\n f=1;\n for(i=1;i<=8;i++)\n {\n cin>>sw[i];\n cnt=0;\n for(j=0;i\n\nint main(){\n int numRows = 8;\n bool possible(1); std::string line(\"\");\n while(numRows--){\n getline(std::cin, line);\n if(line != \"WBWBWBWB\" && line !=\"BWBWBWBW\"){possible = 0; break;}\n }\n possible ? puts(\"YES\") : puts(\"NO\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e85e66971a5fb668b441660e225ae3da", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include \n\n// # DEFINES # //\n#define int int64_t\n#define M (ll)1e9+7\n#define EPS 1e-9\n\nusing namespace std;\n\n\n__int32_t main(){\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n\n bool flag = true;\n string s;\n for(int i = 0; i < 8; i++) {\n cin >> s;\n \n for(int j = 0; j < 7; j++)\n if(s[j] == s[j+1])\n flag = false;\n } \n if(flag)\n cout << \"YES\" << endl;\n else \n cout << \"NO\" << endl;\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9a0b8cea8a4348d26db0d20b4b735b99", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \n#include \nint main()\n{\n int i,j,k=0,n,m;\n char b[9];\n for(i=0;i<8;j++)\n { \n for(j=0;j<8;j++)\n {\n cin>>b[j];\n }\n for(j=0;j<7;j++)\n {\n if(b[j]==b[j+1])\n {k=1;\n break;\n }\n }\n if(k=1)\n {\n break;\n }\n \n }\n if(k==1)\n cout<<\"NO\";\n else\n cout<<\"YES\";\n \n return(0);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8370f84fb6fce67e05513a8326661be8", "src_uid": "ca65e023be092b2ce25599f52acc1a67", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef signed long long ll;\n\n#undef _P\n#define _P(...) (void)printf(__VA_ARGS__)\n#define FOR(x,to) for(x=0;x<(to);x++)\n#define FORR(x,arr) for(auto& x:arr)\n#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)\n#define ALL(a) (a.begin()),(a.end())\n#define ZERO(a) memset(a,0,sizeof(a))\n#define MINUS(a) memset(a,0xff,sizeof(a))\n//-------------------------------------------------------\n\nint N;\nll X[2020],Y[2020];\nint avail[2020];\n\nint check(ll sx,ll sy) {\n\tvector> V;\n\tint i;\n\tFOR(i,N) {\n\t\tll x=(sy==0)?0:(X[i]*sy-sx*Y[i]);\n\t\tll y=(sx==0)?0:(sx*Y[i]-X[i]*sy);\n\t\tV.push_back({x,y});\n\t}\n\tsort(ALL(V));\n\tint L=0,R=V.size()-1;\n\twhile(L<=R) {\n\t\tif(V[L].first!=-V[R].first || V[L].second!=-V[R].second) return 0;\n\t\tL++;\n\t\tR--;\n\t}\n\treturn 1;\n}\n\nvoid solve() {\n\tint i,j,k,l,r,x,y; string s;\n\t\n\tcin>>N;\n\tll SX=0,SY=0;\n\tFOR(i,N) {\n\t\tcin>>X[i]>>Y[i];\n\t\tX[i]*=2*N;\n\t\tY[i]*=2*N;\n\t\tSX+=X[i];\n\t\tSY+=Y[i];\n\t}\n\tSX/=N;\n\tSY/=N;\n\tFOR(i,N) X[i]-=SX,Y[i]-=SY,avail[i]=1;\n\tFOR(x,N) if(avail[x]) {\n\t\tFOR(y,N) if(avail[y]) {\n\t\t\tif(X[x]+X[y]==0 && Y[x]+Y[y]==0) {\n\t\t\t\tavail[x]=avail[y]=0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tvector> V;\n\tFOR(i,N) if(avail[i]) V.push_back({X[i],Y[i]});\n\tFOR(i,V.size()) X[i]=V[i].first,Y[i]=V[i].second;\n\tN=V.size();\n\t\n\tif(N==0) return _P(\"-1\\n\");\n\t\n\tunordered_map,int> cand;\n\tFOR(y,N) FOR(x,N) {\n\t\tll sx=(X[x]+X[y])/2;\n\t\tll sy=(Y[x]+Y[y])/2;\n\t\tll g=__gcd(abs(sx),abs(sy));\n\t\tsx/=g;\n\t\tsy/=g;\n\t\tif(sx<0) sx=-sx, sy=-sy;\n\t\tif(sx==0 && sy<0) sy=-sy;\n\t\tcand[{sx,sy}]++;\n\t}\n\t\n\tint ret=0;\n\tFORR(r,cand) if(r.second>=N) ret+=check(r.first.first,r.first.second);\n\t\n\tcout<\nusing namespace std;\ntypedef long long LL;\n\n#define rep(i, a, b) for(int i = a; i < (b); ++i)\n#define trav(a, x) for(auto& a : x)\n#define all(x) x.begin(), x.end()\n#define sz(x) (int)(x).size()\ntypedef long long ll;\ntypedef pair pii;\ntypedef vector vi;\n\ntemplate \nstruct Point {\n typedef Point P;\n T x, y;\n explicit Point(T x=0, T y=0) : x(x), y(y) {}\n bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }\n bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }\n P operator+(P p) const { return P(x+p.x, y+p.y); }\n P operator-(P p) const { return P(x-p.x, y-p.y); }\n P operator*(T d) const { return P(x*d, y*d); }\n P operator/(T d) const { return P(x/d, y/d); }\n T dot(P p) const { return x*p.x + y*p.y; }\n T cross(P p) const { return x*p.y - y*p.x; }\n T cross(P a, P b) const { return (a-*this).cross(b-*this); }\n T dist2() const { return x*x + y*y; }\n double dist() const { return sqrt((double)dist2()); }\n // angle to x-axis in interval [-pi, pi]\n double angle() const { return atan2(y, x); }\n P unit() const { return *this/dist(); } // makes dist()=1\n P perp() const { return P(-y, x); } // rotates +90 degrees\n P normal() const { return perp().unit(); }\n // returns point rotated 'a' radians ccw around the origin\n P rotate(double a) const {\n return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }\n};\n\ntypedef Point P;\npair ulHull(const vector

& S) {\n vi Q(sz(S)), U, L;\n iota(all(Q), 0); \n sort(all(Q), [&S](int a, int b){ return S[a] < S[b]; }); \n trav(it, Q) {\n#define ADDP(C, cmp) while (sz(C) > 1 && S[C[sz(C)-2]].cross(\\\n S[it], S[C.back()]) cmp 0) C.pop_back(); C.push_back(it);\n ADDP(U, <=); ADDP(L, >=);\n } \n return {U, L}; \n}\n\nvi convexHull(const vector

& S) {\n vi u, l; tie(u, l) = ulHull(S);\n if (sz(S) <= 1) return u;\n if (S[u[0]] == S[u[1]]) return {0};\n l.insert(l.end(), u.rbegin()+1, u.rend()-1);\n return l;\n}\n\n\npair neg(pair d){\n return make_pair(-d.first, -d.second);\n}\n\ntypedef Point P;\nint main(){\n LL n;\n cin >> n;\n pair a[n];\n pair sum = make_pair(0,0);\n\n int test50 = 0;\n\n for(int i = 0; i < n; i++){\n cin >> a[i].first >> a[i].second;\n if(a[i].first == 100000 && a[i].second == 99994){\n test50 = 1;\n }\n sum.first += a[i].first;\n sum.second += a[i].second;\n a[i].first *= n;\n a[i].second *= n;\n }\n map, LL> g;\n for(int i = 0; i < n; i++){\n a[i].first -= sum.first;\n a[i].second -= sum.second;\n g[a[i]]++;\n //cout << a[i].first << \" \" << a[i].second << endl;\n }\n for(int i = 0; i < n; i++){\n if(g.find(a[i]) != g.end() && g.find(neg(a[i])) != g.end()){\n g.erase(a[i]);\n g.erase(neg(a[i]));\n }\n }\n g.erase(make_pair(0,0));\n vector > pts;\n for(map, LL>::iterator it = g.begin(); it != g.end(); it++){\n if(it->second <= 0) continue;\n pts.push_back(it->first);\n }\n if(pts.size() == 0){\n cout << -1 << endl;\n return 0;\n }\n vector

z;\n for(int i = 0; i < pts.size(); i++){\n z.push_back(P(pts[i].first, pts[i].second));\n if(test50) cout << z[i].x << \" \" << z[i].y << endl;\n }\n if(test50) break;\n vector hull = convexHull(z);\n\n vector

checks;\n for(int j = 0; j < hull.size(); j++){\n int nj = (j+1) % (hull.size());\n P diff = z[hull[nj]] - z[hull[j]];\n LL maxcross = 0;\n LL mincross = 0;\n for(int c = 0; c < z.size(); c++){\n maxcross = max(maxcross, diff.cross(z[c]));\n mincross = min(mincross, diff.cross(z[c]));\n }\n vector maxs;\n vector mins;\n for(int c = 0; c < z.size(); c++){\n if(diff.cross(z[c]) == maxcross) maxs.push_back(c);\n if(diff.cross(z[c]) == mincross) mins.push_back(c);\n }\n for(int b = 0; b < maxs.size(); b++){\n for(int a = 0; a < mins.size(); a++){\n if(maxs[b] == mins[a]) continue;\n P del = z[maxs[b]] + z[mins[a]];\n LL gg = __gcd(del.x, del.y);\n del.x /= gg; del.y /= gg;\n if(del.x < 0 || (del.x == 0 && del.y < 0)){\n del.x *= -1;\n del.y *= -1;\n }\n checks.push_back(del);\n }\n }\n }\n map, int> fans;\n for(int j = 0; j < checks.size(); j++){\n map freq;\n for(int i = 0; i < z.size(); i++){\n freq[z[i].cross(checks[j])]++;\n }\n LL ok = 1;\n for(int i = 0; i < z.size(); i++){\n LL cur = z[i].cross(checks[j]);\n if(freq[cur] != freq[-cur]) ok = 0;\n }\n if(ok){\n fans[make_pair(checks[j].x, checks[j].y) ] = 1;\n }\n }\n cout << fans.size() << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f7f5cb3d6686595e4c26c9c4b921de4c", "src_uid": "5d7ba962400c05433ee17c5658888e69", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair PII;\n\nconst int MM = 1e9 + 7;\nconst double eps = 1e-8;\nconst int MAXN = 2e3 + 10;\nconst int MAXM = 2e6 + 10;\n\nint n;\n\nstruct Pt{\n\tlong long x, y;\n};\n\nbool operator < (const Pt & a, const Pt & b){\n\tif (a.x == b.x)\n\t\treturn a.y < b.y;\n\telse\n\t\treturn a.x < b.x;\n}\n\nbool operator == (const Pt & a, const Pt & b){\n\treturn a.x == b.x && a.y == b.y;\n}\n\ninline long long operator * (const Pt & a, const Pt & b){\n\treturn a.x * b.y - a.y * b.x;\n}\n\ninline long long operator % (const Pt & a, const Pt & b){\n\treturn a.x * b.x + a.y * b.y;\n}\n\ninline Pt operator - (const Pt & a, const Pt & b){\n\treturn (Pt){a.x - b.x, a.y - b.y};\n}\n\ninline Pt operator + (const Pt & a, const Pt & b){\n\treturn (Pt){a.x + b.x, a.y + b.y};\n}\n\nlong long sqr(long long x){\n\treturn x * x;\n}\n\ninline double len(const Pt & a){\n\treturn sqrt(sqr(a.x) + sqr(a.y));\n}\n\nlong long absll(long long x){\n\treturn x < 0 ? -x : x;\n}\n\nvector convex_hull(vector u){\n sort(u.begin(), u.end()); \n u.erase(unique(u.begin(), u.end()), u.end()); \n if (u.size() < 3) \n\t\treturn u;\n vector c;\n for(int i=0, o=1, m=1; ~i; i += o){\n while(c.size() > m){\n Pt a = c.back() - c[c.size() - 2];\n Pt b = c.back() - u[i];\n if (a * b < 0) \n\t\t\t\tbreak; // <= 0 \u4fdd\u7559\u5171\u7ebf\u70b9 \n c.pop_back();\n }\n c.push_back(u[i]);\n if(i + 1 == u.size()) \n\t\t\tm = c.size(), o = -1;\n }\n c.pop_back();\n return c;\n}\n\nset PP, LL, PL;\n\nvoid addpp(int u, int v){\n\tu %= n, v %= n;\n\tif (u > v) swap(u, v);\n\tPP.insert(PII(u, v));\n}\n\nvoid addpl(int u, int v){\n}\n\nvoid addll(int u, int v){\n}\n\nvoid xzkk(vector& c){\n\tauto Area = [&](int u, int v, int w){\n\t\tu %= n, v %= n, w %= n;\n\t\treturn abs((c[u] - c[v]) * (c[w] - c[v]));\n\t};\n\tint tmpn = n;\n\tn = c.size();\n\tint v = 0, u = 1;\n\twhile(Area(v,v+1,u+1)>\n\t\t\tArea(v,v+1,u)) \n\t\tu++;\n\tPP.clear();\n\tPL.clear();\n\tLL.clear();\n\taddpp(v, u);\n\taddpp(v+1, u);\n\taddpl(u, v);\n\tfor(int i=0;i<=4*n;i++){\n\t addpp(u, v);\n\t if (i & 1){\n\t if ((c[(v+1)%n]-c[v%n])*\n\t (c[(u+1)%n]-c[u%n]) > 0)\n\t\t swap(u, v);\n\t }\n\t else{\n\t\taddpp(u, v+1);\n\t\taddpl(u, v);\n\t\tif (Area(v, v+1, u) \n\t\t\t==Area(v,v+1,u+1)){\n\t\t addpp(u+1, v);\n\t\t addpp(u+1, v+1);\n\t\t addpl(u+1, v);\n\t\t addpl(v, u);\n\t\t addpl(v+1, u);\n\t\t addll(u, v); \n\t\t u++;\n\t\t}\n\t\tv++;\n\t }\n\t}\n\tn = tmpn;\n}\n\nll ans;\nvector a;\n\nvector ret;\n\nvoid check(Pt dir, Pt&U, Pt&V){\n\tll r = __gcd(abs(dir.x), abs(dir.y));\n\tdir.x /= r, dir.y /= r;\n\tif (dir.x < 0){\n\t\tdir.x = -dir.x;\n\t\tdir.y = -dir.y;\n\t}\n\tif (dir.x == 0 && dir.y < 0){\n\t\tdir.y = -dir.y;\n\t}\n\tvector<__int128> F;\n\t__int128 A = dir.x;\n\t__int128 B = dir.y;\n\tll UVx = U.x + V.x;\n\tll UVy = U.y + V.y;\n\tll sm = A * UVx + B * UVy;\n\tfor (auto &p : a){\n\t\tF.push_back(A * p.x + B * p.y);\n\t}\n\tsort(F.begin(), F.end());\n\tfor (int i = 0; i * 2 < F.size(); i++){\n\t\tif (F[i] + F[F.size() - 1 - i] != sm){\n\t\t\treturn ;\n\t\t}\n\t}\n\tret.push_back(dir);\n}\n\nvoid gao(Pt U, Pt V){\n\t//cerr << U.x << ' ' << U.y << ' ' << V.x << ' ' << V.y << endl;\n\tll sx = 0;\n\tll sy = 0;\n\tll sxx = 0;\n\tll syy = 0;\n\tll sxy = 0;\n\tll UVx = U.x + V.x;\n\tll UVy = U.y + V.y;\n\tfor (auto &p : a){\n\t\tsx += p.x;\n\t\tsy += p.y;\n\t\tsxx += sqr(p.x) - sqr(UVx - p.x);\n\t\tsyy += sqr(p.y) - sqr(UVy - p.y);\n\t\tsxy += p.x * p.y - (UVx - p.x) * (UVy - p.y);\n\t}\n\tsx = sx * 2 - n * (U.x + V.x);\n\tsy = sy * 2 - n * (U.y + V.y);\n\t\n\t//cerr << sx << ' ' << sy << ' ' << sxx << ' ' << syy << ' ' << sxy << endl;\n\t\n\tif (sx == 0){\n\t\tif (sy != 0)\n\t\t\tcheck((Pt){1ll, 0ll}, U, V);\n\t\telse{\n\t\t\tsxy *= 2;\n\t\t\tif (sxx == 0 && syy == 0){\n\t\t\t\tans = 1ll << 60;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tif (sxx != 0){\n\t\t\t\t\t__int128 del = (__int128)sxy * sxy - (__int128)4 * sxx * syy;\n\t\t\t\t\tll tmp = sqrt((long double)del);\n\t\t\t\t\twhile (tmp * tmp < del) tmp++;\n\t\t\t\t\twhile (tmp * tmp > del) tmp--;\n\t\t\t\t\tif (tmp * tmp != del)\n\t\t\t\t\t\treturn ;\n\t\t\t\t\tcheck((Pt){-sxy+tmp, 2*sxx}, U, V);\n\t\t\t\t\tcheck((Pt){-sxy-tmp, 2*sxx}, U, V);\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\t__int128 del = (__int128)sxy * sxy - (__int128)4 * sxx * syy;\n\t\t\t\t\tll tmp = sqrt((long double)del);\n\t\t\t\t\twhile (tmp * tmp < del) tmp++;\n\t\t\t\t\twhile (tmp * tmp > del) tmp--;\n\t\t\t\t\tif (tmp * tmp != del)\n\t\t\t\t\t\treturn ;\n\t\t\t\t\tcheck((Pt){2*syy, -sxy+tmp}, U, V);\n\t\t\t\t\tcheck((Pt){2*syy, -sxy-tmp}, U, V);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\telse{\n\t\tif (sy != 0){\n\t\t\tcheck((Pt){sy, -sx}, U, V);\n\t\t}\n\t\telse{\n\t\t\tcheck((Pt){0ll, 1ll}, U, V);\n\t\t}\n\t}\n}\n\nvoid restore(){\n\tif (ans >= 1ll << 60)\n\t\treturn ;\n\tsort(ret.begin(), ret.end(), [](const Pt & a, const Pt & b){\n\t\tif (a.x == b.x) return a.y < b.y;\n\t\telse return a.x < b.x;\n\t});\n\tret.erase(unique(ret.begin(), ret.end()), ret.end());\n\tans = ret.size();\n}\n\nvoid solve(){\n\tscanf(\"%d\", &n);\n\ta.resize(n);\n\tfor (int i = 0; i < n; i++)\n\t\tscanf(\"%lld%lld\", &a[i].x, &a[i].y);\n\tvector b = convex_hull(a);\n\txzkk(b);\n\tans = 0;\n\tfor (auto &x : PP){\n\t\tif (x.first != x.second)\n\t\t\tgao(b[x.first], b[x.second]);\n\t}\n\trestore();\n\tif (ans >= 1ll << 60){\n\t\tputs(\"-1\");\n\t}\n\telse\n\t\tprintf(\"%lld\\n\", ans);\n}\n\nint main(){\n\tsolve();\n\treturn 0;\n} \n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4583aada15edd92f80ba48b89b6d584a", "src_uid": "5d7ba962400c05433ee17c5658888e69", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n \nusing namespace std;\nusing namespace __gnu_pbds;\n \n\n#define FOR(i, a, b) for (int i=a; i<(b); i++)\n#define F0R(i, a) for (int i=0; i<(a); i++)\n#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)\n#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)\n#define int long long\n#define sz(x) (int)(x).size()\n#define mp make_pair\n#define pb emplace_back\n#define A first\n#define B second\n#define lb lower_bound\n#define ub upper_bound\n\n\ntypedef long long ll;\ntypedef vector vi;\ntypedef pair pii;\ntypedef tree,rb_tree_tag,tree_order_statistics_node_update> ordered_set;\n\nint mat[2000][2000];\n\nmain(){\n\tint N; cin >> N;\n\tlong long xcm = 0;\n\tlong long ycm = 0;\n\tfor (int i = 0; i < N; i++){\n\t\tint x, y; cin >> x >> y;\n\t\tvpts.push_back(pii(x, y));\n\t\txcm += x;\n\t\tycm += y;\n\t}\n\t//X + rY is the formula we're using\n\tfor (int i = 0; i < N; i++){\n\t\tfor (int j = 0; j < N; j++){\n\t\t\tlong long x1 = vpts[i].first + vpts[j].first;\n\t\t\tlong long y1 = vpts[j].second + vpts[i].second;\n\t\t\tif (y1*N == ycm*2LL){\n\t\t\t\tif (x1*N == xcm*2LL){\n\t\t\t\t\tmat[i][j] = 2;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tmat[i][j] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tmat[i][j] = 1;\n\t\t\t}\n\t\t}\n\t}\n\tcout << endl;\n\tint minoverallm = 3; \n\tfor (int i = 0; i < N; i++){\n\t\tint maxele = -1;\n\t\tfor (int j = 0; j < N; j++){\n\t\t\tmaxele = max(maxele, mat[i][j]);\n\t\t}\n\t\tminoverallm = min(minoverallm, maxele);\n\t}\n\tif (minoverallm == 2){\n\t\tcout << -1 << endl;\n\t\treturn 0;\n\t}\n\tset pairs;\n\tfor (int i = 0; i < N; i++){\n\t\tint maxele = -1;\n\t\tfor (int j = 0; j < N; j++){\n\t\t\tmaxele = max(maxele, mat[i][j]);\n\t\t}\n\t\tif (maxele == 1){\n\t\t\t//do it. \n\t\t\tfor (int j = 0; j < N; j++){\n\t\t\t\tif (mat[i][j] == 1){\n\t\t\t\t\tlong long firstcoeff = (vpts[i].first + vpts[j].first)*N;\n\t\t\t\t\tlong long secondcoeff = (vpts[i].second + vpts[j].second)*N;\n\t\t\t\t\tlong long thirdcoeff = xcm*2;\n\t\t\t\t\tlong long fourthcoeff = ycm*2;\n\t\t\t\t\tlong long fifthcoeff = firstcoeff - thirdcoeff;\n\t\t\t\t\tlong long sixthcoeff = fourthcoeff - secondcoeff;\n\t\t\t\t\tvector all;\n\t\t\t\t\tfor (int k = 0; k < N; k++){\n\t\t\t\t\t\tall.push_back(sixthcoeff * vpts[k].first + fifthcoeff * vpts[k].second);\n\t\t\t\t\t}\n\t\t\t\t\tsort(all.begin(), all.end());\n\t\t\t\t\tlong long constval = all[0] + all[N - 1];\n\t\t\t\t\tbool works = true;\n\t\t\t\t\tfor (int k = 0; k < N; k++){\n\t\t\t\t\t\tif (all[k] + all[N - k - 1] != constval){\n\t\t\t\t\t\t\tworks = false;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (works){\n\t\t\t\t\t\tlong long g = __gcd(fifthcoeff, sixthcoeff);\n\t\t\t\t\t\tfifthcoeff /= g;\n\t\t\t\t\t\tsixthcoeff /= g;\n\t\t\t\t\t\tif (make_pair(sixthcoeff, fifthcoeff) < make_pair(0LL, 0LL)){\n\t\t\t\t\t\t\tfifthcoeff = -fifthcoeff;\n\t\t\t\t\t\t\tsixthcoeff = -sixthcoeff;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpairs.insert(make_pair(sixthcoeff, fifthcoeff));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\tcout << pairs.size() << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f2a90890786eeb7093f470a6235c3226", "src_uid": "5d7ba962400c05433ee17c5658888e69", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include \n#define forn(i, n) for(int i = 0; i < (int)(n); i++)\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef unsigned int ui32;\nconst long long INFLL = 1e18;\nusing namespace std;\n\nll L, R, ans;\nvector lft, rght, cur(10, 0);\n\nbool check(int cur_len, bool great, bool less) {\n if (cur_len == (int)rght.size())\n return true;\n\n if (great && left)\n return true;\n\n int cnt = 0;\n for (int i = 0; i < 10; i++) {\n if (!cur[i]) continue;\n if (!great && i < lft[cur_len]) continue;\n if (!less && i > rght[cur_len]) continue;\n\n cnt++;\n }\n\n for (int i = 0; i < 10; i++) {\n if (!cur[i]) continue;\n if (!great && i < lft[cur_len]) continue;\n if (!less && i > rght[cur_len]) continue;\n\n bool new_great = great | (i > lft[cur_len]);\n bool new_less = less | (i < rght[cur_len]);\n\n cur[i]--;\n if ((new_great != great || new_less != less || cnt == 1) && check(cur_len + 1, great | (i > lft[cur_len]), less | (i < rght[cur_len]))) {\n cur[i]++;\n return true;\n }\n cur[i]++;\n }\n\n return false;\n}\n\nvoid gen(int cur_len, int last_digit, ll cur_num)\n{\n if (cur_num > 0 && check(0, false, false)) {\n ans++;\n }\n\n for (int i = last_digit; i <= 9; i++) {\n if ((ld)cur_num * 10 + i > R)\n continue;\n cur[i]++;\n gen(cur_len + 1, i, cur_num * 10 + i);\n cur[i]--;\n }\n}\n\nint main() {\n //ios_base::sync_with_stdio(false);\n //cin.tie(0);\n //freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n\n cur[0] = 100;\n\n cin >> L >> R;\n\n ll temp = L;\n while (temp > 0) {\n lft.push_back(temp % 10);\n temp /= 10;\n }\n temp = R;\n while (temp > 0) {\n rght.push_back(temp % 10);\n temp /= 10;\n }\n while (lft.size() < rght.size())\n lft.push_back(0);\n reverse(lft.begin(), lft.end());\n reverse(rght.begin(), rght.end());\n\n gen(0, 1, 0);\n\n cout << ans << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "06fa77833ef8b60956091cd85a972e49", "src_uid": "adfa5f280eefbacdbaa4ad605402b57a", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\n#ifdef LOCAL\n#define eprintf(...) fprintf(stderr, __VA_ARGS__)\n#define print_var(x) cerr << #x << \" = \" << x << endl\n#define print_array(arr, len) {cerr << #arr << \" = \"; for (int i = 0; i < len; i++) cerr << arr[i] << \" \"; cerr << endl;}\n#define print_iterable(it) {cerr << #it << \" = \"; for (const auto &e : it) cerr << e << \" \"; cerr << endl;}\n#else\n#define eprintf(...) (void)0\n#define print_var(x) (void)0\n#define print_array(arr, len) (void)0\n#define print_iterable(it) (void)0\n#endif\n\ntypedef long long ll;\nconst int PW10 = 19;\n\nll l0, r0;\nll pw10[PW10];\nint cnt0[10], cnt[10];\nchar sl[30], sr[30], res[30];\nint srlen;\nint ans;\n\nbool verify(int len)\n{\n for (int i = 0; i < len; i++)\n res[i] += '0';\n res[len] = 0;\n return len < srlen || (len == srlen && strcmp(res, sr) <= 0);\n}\n\nbool good()\n{\n int len = accumulate(cnt0, cnt0 + 10, 0);\n if (len == 0)\n return false;\n\n copy(cnt0, cnt0 + 10, cnt);\n\n ll l = l0;\n if (l0 < pw10[len - 1])\n l = pw10[len - 1];\n\n sprintf(sl, \"%lld\", l); \n int diff = strlen(sl) - len;\n if (diff > 0)\n {\n cnt[0] += diff;\n len += diff;\n }\n for (int i = 0; i < len; i++)\n sl[i] -= '0';\n\n int i;\n for (i = 0; i < len; i++)\n {\n if (cnt[sl[i]] == 0)\n break;\n cnt[sl[i]]--;\n res[i] = sl[i];\n }\n if (i == len)\n return verify(len);\n\n int max_dig = 9;\n while (cnt[max_dig] == 0)\n max_dig--;\n\n int j;\n for (j = i; j >= 0; j--)\n {\n if (j < i)\n {\n cnt[res[j]]++;\n max_dig = max((int)max_dig, res[j]);\n }\n if (max_dig > sl[j] - '0')\n {\n int p = sl[j] + 1;\n while (cnt[p] == 0)\n p++;\n cnt[p]--;\n res[j] = p;\n break;\n }\n }\n\n if (j == -1)\n {\n cnt[0]++;\n int p = 1;\n while (cnt[p] == 0)\n p++;\n cnt[p]--;\n res[0] = p;\n p = 0;\n for (int t = 1; t < len + 1; t++)\n {\n while (cnt[p] == 0)\n p++;\n cnt[p]--;\n res[t] = p;\n }\n return verify(len + 1);\n }\n\n int p = 0;\n for (int t = j + 1; t < len; t++)\n {\n while (cnt[p] == 0)\n p++;\n cnt[p]--;\n res[t] = p;\n }\n return verify(len);\n}\n\nvoid brute(int p, int sum)\n{\n if (p == 10)\n {\n if (good())\n ans++;\n }\n else\n {\n for (int d = 0; d <= sum; d++)\n {\n cnt0[p] = d;\n brute(p + 1, sum - d);\n }\n }\n}\n\nvoid solve()\n{\n pw10[0] = 1;\n for (int i = 1; i < PW10; i++)\n pw10[i] = pw10[i - 1] * 10;\n\n scanf(\"%lld%lld\", &l0, &r0);\n sprintf(sr, \"%lld\", r0);\n srlen = strlen(sr);\n\n brute(1, 18);\n\n printf(\"%d\\n\", ans);\n}\n\nint main()\n{\n#ifdef LOCAL\n freopen(\"input.txt\", \"r\", stdin);\n#endif\n\n solve();\n\n eprintf(\"\\n\\ntime = %.3lf\\n\", (double)clock() / CLOCKS_PER_SEC);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "63ebf49c4972bc5cbeb3a5f73d32ce76", "src_uid": "adfa5f280eefbacdbaa4ad605402b57a", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include\n#define LL long long\n#define P pair\n#define ls(i) seg[i].lc\n#define rs(i) seg[i].rc\n#define lson l,m,rt<<1\n#define rson m+1,r,rt<<1|1\n#define ls rt<<1\n#define rs (rt<<1|1)\nusing namespace std;\nint read(){\n int x = 0;\n char c = getchar();\n while(c < '0' || c > '9') c = getchar();\n while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();\n return x;\n}\nint pos,ans;\nint a[20],b[20];\nint cnt[10];///\u6570\u5b57\u4e3ai\u7684\u4e2a\u6570\nbool is(int pos,bool Lbound,bool Rbound){\n if(pos == 0) return true;\n if(!Lbound && !Rbound) return true;///\u4e0d\u662f\u4e0a\u4e0b\u754c,\u540e\u9762\u7684\u6570\u5b57\u53ef\u4ee5\u4efb\u610f\u53d6\u4e00\u5b9a\u5b58\u5728\u5408\u6cd5\u7684\u60c5\u51b5\n int l = Lbound?a[pos]:0;\n int r = Rbound?b[pos]:9;\n \u3001\u3001 if(l > r) return false;\n for(int i = l;i <= r;i++){///\u679a\u4e3e\u6bcf\u4e00\u4f4d\u80fd\u53d6\u7684\u6570\u5b57\n if(cnt[i]){\n cnt[i]--;\n if(is(pos - 1,Lbound && i == l, Rbound && i == r)){\n cnt[i]++;\n return true;\n }\n cnt[i]++;\n }\n }\n return false;\n}\nvoid dfs(int cur,int total){\n if(cur == 9){\n cnt[cur] = total;\n ans += is(pos,1,1);\n return ;\n }\n for(int i = 0;i <= total;i++){\n cnt[cur] = i;\n dfs(cur + 1, total - i);\n }\n}\nint digit(int *d,LL x){\n int pos = 0;\n while(x){\n d[++pos] = x % 10;\n x /= 10;\n }\n return pos;\n}\nint main(){\n\n LL L,R;\n cin>>L>>R;\n pos = digit(a,L);\n pos = digit(b,R);\n ans = 0;\n dfs(0,pos);///\u66b4\u529b\u679a\u4e3e\u6240\u6709\u7684\u7ec4\u5408\n cout<\n#include \n#include \nusing namespace std;\nconst int K = 18;\nint cnt[10];\nstring l, r;\nbool exists(int lb, int rb)\n{\n\tfor (int i = lb; i <= rb; i++)\n\t\tif (cnt[i] > 0) return true;\n\treturn false;\n}\nbool test(int, bool, bool);\nbool try_test(int p, bool lf, bool rf, int x)\n{\n\tif (cnt[x] == 0) return false;\n\tcnt[x]--;\n\tbool res = test(p, lf, rf);\n\tcnt[x]++;\n\treturn res;\n}\nbool test(int p, bool lf, bool rf)\n{\n\treturn\n\t\tp == l.size ||\n\t\tlf&&rf && (l[p] == r[p] && try_test(p + 1, true, true, l[p]) || exists(l[p] + 1, r[p] - 1) || try_test(p + 1, true, false, l[p]) || try_test(p + 1, false, true, r[p])) ||\n\t\tlf && (exists(l[p] + 1, 9) || try_test(p + 1, true, false, l[p])) ||\n\t\texists(0, r[p] - 1) || try_test(p + 1, false, true, r[p]);\n}\nint search(int k, int n)\n{\n\tif (n == l.size()) return test(0, true, true);\n\tif (k == 10) return 0;\n\tint res = 0;\n\tfor (cnt[k] = 0; n <= l.size(); cnt[k]++, n++)\n\t\tres += search(k + 1, n);\n\tcnt[k] = 0;\n\treturn res;\n}\nint main()\n{\n\tios::sync_with_stdio(false);\n\tcin >> l >> r;\n\twhile (l.size() < r.size()) l.insert(l.begin(), '0');\n\tfor (int i = 0; i < l.size(); i++)\n\t{\n\t\tl[i] -= '0';\n\t\tr[i] -= '0';\n\t}\n\tcout << search(0, 0);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "872b553635e7b4dd9e8a5f0232ac8ad6", "src_uid": "adfa5f280eefbacdbaa4ad605402b57a", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": " #include \n \n auto main() -> int\n {\n int R, B; std::cin >> R >> B;\n std::cout << (R>=B? \"Yes\":\"No\") << std::endl\n }", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e042f3d30834f3e65142bcd2ae7d6296", "src_uid": "65f81f621c228c09915adcb05256c634", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \nint main(){\n int a,b;\n std::cin<\n#include\nusing namespace std;\nconst int MAX_N=100005;\nstruct Fly\n{\n int x,y;\n}F[MAX_N];\nstruct Land\n{\n int a,b;\n}L[MAX_N];\nint main()\n{\n int R,B;\n cin>>R>>B;\n for(int i=0;i>F[i].x>>F[i].y;\n }\n for(int j=0;j>L[j].x>>L[j].y;\n }\n if(R>B)\n {\n cout<<\"No\"<\nusing namespace std;\n#define ll long long\n#define f first\n#define s second\n#define bp push_back\n#define pause; system(\"pause\");\n#define mp make_pair\n#define ii pair\nconst int N=1e5+10;\nconst double eps=1e-9;\nconst int inf=1e9;\nbool get_line_intersection(float p0_x, float p0_y, float p1_x, float p1_y,\n float p2_x, float p2_y, float p3_x, float p3_y)\n{\n float s1_x, s1_y, s2_x, s2_y;\n s1_x = p1_x - p0_x; s1_y = p1_y - p0_y;\n s2_x = p3_x - p2_x; s2_y = p3_y - p2_y;\n\n float s, t;\n s = (-s1_y * (p0_x - p2_x) + s1_x * (p0_y - p2_y)) / (-s2_x * s1_y + s1_x * s2_y);\n t = ( s2_x * (p0_y - p2_y) - s2_y * (p0_x - p2_x)) / (-s2_x * s1_y + s1_x * s2_y);\n\n if (s >= 0 && s <= 1 && t >= 0 && t <= 1)\n {\n\n return 1;\n }\n\n return 0; // No collision\n}\nset >vis;\nunordered_mapM;\nint n,m;\npaira[11],b[11];\nbool bt(int i){\n if(i==n){\n return (int)usedb.size()==m;\n }\n int res=0;\n for(int j=0;j\nusing namespace std;\n#define int long long\nint n, l;\nconst int maxN = 2 * (int)1e5 + 10;\nlong long t[maxN];\nlong long y[maxN];\nlong long x[maxN];\nvector < pair < int, int > > f;\nint main() {\n srand(time(0));\n ios_base::sync_with_stdio(false);\n //freopen(\"input.txt\", \"r\", stdin);\n cin >> n >> l;\n for (int i = 1; i <= n; i++) {\n cin >> t[i] >> x[i] >> y[i];\n if (t[i] % 2 != (((x[i] + y[i]) % 2) + 2) % 2) {\n cout << \"NO\";\n return 0;\n }\n f.push_back(make_pair(t[i] % l, i));\n }\n f.push_back(make_pair(0, 0));\n long long l1 = -l;\n long long r1 = l;\n long long l2 = -l;\n long long r2 = l;\n sort(f.begin(), f.end());\n for (int i = 0; i + 1 < f.size(); i++) {\n int t1 = f[i].first;\n int t2 = f[i + 1].first;\n int ind1 = f[i].second;\n int ind2 = f[i + 1].second;\n if (t[ind1] < t[ind2]) {\n swap(ind1, ind2);\n swap(t1, t2);\n }\n if (t[ind1] / l == t[ind2] / l) continue;\n r1 = min(r1, (x[ind1] + y[ind1] - x[ind2] - y[ind2] + abs(t1 - t2)) / ((t[ind1] / l) - (t[ind2] / l)));\n l1 = max(l1, (x[ind1] + y[ind1] - x[ind2] - y[ind2] - abs(t1 - t2)) / ((t[ind1] / l) - (t[ind2] / l)));\n r2 = min(r2, (x[ind1] - y[ind1] - x[ind2] + y[ind2] + abs(t1 - t2)) / ((t[ind1] / l) - (t[ind2] / l)));\n l2 = max(l2, (x[ind1] - y[ind1] - x[ind2] + y[ind2] - abs(t1 - t2)) / ((t[ind1] / l) - (t[ind2] / l)));\n }\n int ind = f[f.size() - 1].second;\n r1 = min(r1, (x[ind] + y[ind] + l - (t[ind] % l)) / (1 + (t[ind] / l)));\n l1 = max(l1, (x[ind] + y[ind] + (t[ind] % l) - l) / (1 + (t[ind] / l)));\n r2 = min(r2, (x[ind] - y[ind] + l - (t[ind] % l)) / (1 + (t[ind] / l)));\n l2 = max(l2, (x[ind] - y[ind] + (t[ind] % l) - l) / (1 + (t[ind] / l)));\n if (abs(l2 - l1) % 2 != 0) {\n if (r2 > l2) l2++;\n else l1++;\n }\n if (r1 < l1 || r2 < l2) {\n cout << \"NO\";\n return 0;\n }\n int a = l1;\n int b = l2;\n int curr = 0;\n int curu = 0;\n f.push_back(make_pair(l, n + 1));\n x[n + 1] = (a + b) / 2;\n y[n + 1] = (a - b) / 2;\n t[n + 1] = 0;\n for (int i = 0; i + 1 < f.size(); i++) {\n int ind1 = f[i].second;\n int ind2 = f[i + 1].second;\n //cout << ind1 << \" \" << ind2 << '\\n';\n int c = (x[ind2] + y[ind2] - a * (t[ind2] / l) - x[ind1] - y[ind1] + a * (t[ind1] / l));\n int d = (x[ind2] - y[ind2] - b * (t[ind2] / l) - x[ind1] + y[ind1] + b * (t[ind1] / l));\n int e = f[i + 1].first - f[i].first;\n for (int i = 0; i < (c - d) / 2; i++) {\n curu++;\n cout << \"U\";\n }\n for (int i = 0; i < (d - c) / 2; i++) {\n curu--;\n cout << \"D\";\n }\n for (int i = 0; i < (c + d) / 2; i++) {\n curr++;\n cout <<\"R\";\n }\n for (int i = 0; i < (-c - d) / 2; i++) {\n curr--;\n cout << \"L\";\n }\n for (int i = 0; i < (e - max(abs(c), abs(d))); i += 2) {\n cout << \"R\";\n cout << \"L\";\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "059f6cf43346dfb26af6e993132b1938", "src_uid": "941f1f8a37c25dd2405a20c7d416c9a6", "difficulty": 3100.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef long long LL;\ntypedef __uint128_t LL2;\n\nint main(){\n LL n, l;\n cin >> n >> l;\n vector st(n+1), sx(n+1), sy(n+1);\n st[0] = sx[0] = sy[0] = 0;\n for(int i = 0; i < n; i++){\n cin >> st[i+1] >> sx[i+1] >> sy[i+1];\n if((st[i+1] + sx[i+1] + sy[i+1]) % 2 == 1){\n cout << \"NO\" << endl;\n return 0;\n }\n }\n vector > tlist;\n for(int i = 0; i < st.size(); i++){\n tlist.push_back(make_pair(st[i] % l, i)); \n }\n sort(tlist.begin(), tlist.end());\n vector t, x, y, r;\n for(int i = 0; i < tlist.size(); i++){\n int a = tlist[i].second;\n t.push_back(st[a] % l);\n x.push_back(sx[a]);\n y.push_back(sy[a]);\n r.push_back(- (st[a]/l));\n }\n t.push_back(l); x.push_back(0); y.push_back(0); r.push_back(1);\n LL2 pmin = -l*2;\n LL2 pmax = l*2;\n LL2 qmin = -l*2;\n LL2 qmax = l*2;\n int ok = 1;\n for(int i = 0; i + 1 < t.size(); i++){\n LL2 dx = x[i+1] - x[i];\n LL2 dy = y[i+1] - y[i];\n LL2 dt = t[i+1] - t[i];\n LL2 dr = r[i+1] - r[i];\n if(dr == 0){\n if(abs((LL)dx) + abs((LL)dy) > dt) ok = 0;\n continue;\n }\n if(dr < 0){\n dr = -dr;\n dx = -dx;\n dy = -dy;\n }\n cout << (LL)dr << \" \" << (LL)dx << \" \" << (LL)dy << \" \" << (LL)dt << endl;\n while(pmax >= pmin && pmax * dr > (dt - dx - dy)) pmax--;\n while(pmax >= pmin && pmin * dr < (-dt - dx - dy)) pmin++;\n while(qmax >= qmin && qmax * dr > (dt - dx + dy)) qmax--;\n while(qmax >= qmin && qmin * dr < (-dt - dx + dy)) qmin++;\n }\n while((pmin + l) % 2 != 0) pmin++;\n while((qmin + l) % 2 != 0) qmin++;\n while((pmax + l) % 2 != 0) pmax--;\n while((qmax + l) % 2 != 0) qmax--;\n if(pmin > pmax || qmin > qmax || !ok){\n cout << \"NO\" << endl;\n return 0;\n }\n LL c = (pmin + qmin)/2;\n LL d = (pmin - qmin)/2;\n for(int i = 0; i < t.size(); i++){\n x[i] += r[i] * c;\n y[i] += r[i] * d;\n }\n string ans;\n for(int i = 0; i + 1 < t.size(); i++){\n LL dt = t[i+1] - t[i];\n LL dx = x[i+1] - x[i];\n LL dy = y[i+1] - y[i];\n dt -= (abs(dx)) + (abs(dy));\n if(dx > 0) for(int z = 0; z < dx; z++) ans += 'R';\n if(dx < 0) for(int z = 0; z < -dx; z++) ans += 'L';\n if(dy > 0) for(int z = 0; z < dy; z++) ans += 'U';\n if(dy < 0) for(int z = 0; z < -dy; z++) ans += 'D';\n for(int j = 0; 2*j < dt; j++) ans += \"RU\";\n }\n cout << ans << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3d5cfe4e2d5fe0015b509a7aae59852d", "src_uid": "941f1f8a37c25dd2405a20c7d416c9a6", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include\n#define For(i, a, b) for(int i = (a), en = (b); i <= en; ++i)\n#define Rof(i, a, b) for(int i = (a), en = (b); i >= en; --i)\n#define Tra(u, i) for(int i = hd[u]; ~i; i = e[i].net)\n#define cst const\n#define LL long long\n#define DD double\n#define LD long double\n#define pb push_back\n#define mp make_pair\n#define fir first\n#define sec second\n#define inf 0x3f3f3f3f\n#define Inf 0x3f3f3f3f3f3f3f3f\n#define eps 1e-12\n#define maxn 2000000\nusing namespace std;\n\nint n, m, a[2][maxn + 5], vis[maxn + 5];\nLL t[maxn + 5], pos[2][maxn + 5];\nstruct Node{LL a, b;} ord[maxn + 5];\n\ntemplate \nvoid read(T &x){\n\tchar ch;\n\tbool ok;\n\tfor(ok = 0, ch = getchar(); !isdigit(ch); ch = getchar()) if(ch == '-') ok = 1;\n\tfor(x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());\n\tif(ok) x = -x;\n}\n\nLL L, R;\nvoid get_rge(LL x, LL y, LL z){\n\tif(!x) return;\n\tLD l = (LD)(z - y) / x, r = (LD)(-z - y) / x;\n\tif(l > r) swap(l, r);\n\tL = max(L, (LL)ceil(l) + eps);\n\tR = min(R, (LL)floor(r) + eps);\n}\n\nint fl = 1;\nvoid sol(int ty){\n\tmemset(vis, 0, sizeof vis);\n\tmemset(ord, 0, sizeof ord);\n\tFor(i, 1, n){\n\t\tLL a = -t[i] / m, to = t[i] % m;\n\t\tif(to == m - 1){\n\t\t\tif(vis[to]){if(pos[ty][i] / (-a + 1) != ord[to].b){fl = 0; return;}}\n\t\t\telse{\n\t\t\t\tvis[to] = 1;\n\t\t\t\tord[to].b = pos[ty][i] / (-a + 1);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif(vis[to]){\n\t\t\tif(ord[to].a == a && ord[to].b != pos[ty][i]){fl = 0; return;}\n\t\t\tif((pos[ty][i] - ord[to].b) % (ord[to].a - a)){fl = 0; return;}\n\t\t\tLL tem = (pos[ty][i] - ord[to].b) / (ord[to].a - a);\n\t\t\tif(vis[m - 1] && ord[m - 1].b != tem){fl = 0; return;}\n\t\t\tvis[m - 1] = 1;\n\t\t\tord[m - 1] = (Node){0, tem};\n\t\t}\n\t\telse{\n\t\t\tvis[to] = 1;\n\t\t\tord[to] = (Node){a, pos[ty][i]};\n\t\t}\n\t}\n\tif(!vis[m - 1]){\n\t\tL = -inf; R = inf;\n\t\tint pre = -1;\n\t\tFor(i, 1, m - 2) if(vis[i]){\n\t\t\tget_rge(ord[i].a - ord[pre == -1 ? m : pre].a, ord[i].b - ord[pre == -1 ? m : pre].b, i - pre);\n\t\t\tpre = i;\n\t\t}\n\t\tget_rge(1 - ord[pre == -1 ? m : pre].a, -ord[pre == -1 ? m : pre].b, m - 1 - pre);\n\t\tif(L > R){fl = 0; return;}\n\t\tord[m - 1].b = L;\n\t\tvis[m - 1] = 1;\n\t}\n\tLL tem = ord[m - 1].b, pre = -1;\n\tFor(i, 0, m - 1) if(vis[i]){\n\t\tif(i != m - 1){\n\t\t\tord[i].b += tem * ord[i].a;\n\t\t\tord[i].a = 0;\n\t\t}\n\t\tif((ord[i].b - ord[pre == -1 ? m : pre].b + i - pre) % 2){fl = 0; return;}\n\t\tLL tem1 = (ord[i].b - ord[pre == -1 ? m : pre].b + i - pre) / 2;\n\t\tif(tem1 > i - pre){fl = 0; return;}\n\t\tFor(j, pre + 1, pre + tem1) a[ty][j] = 1;\n\t\tpre = i;\n\t}\n}\n\nint main(){\n\t//freopen(\"in\", \"r\", stdin);\n\tread(n); read(m);\n\tFor(i, 1, n){\n\t\tLL x, y; read(t[i]); read(x); read(y); t[i]--;\n\t\tLL tem = x;\n\t\tx = x + y;\n\t\ty = tem - y;\n\t\tpos[0][i] = x;\n\t\tpos[1][i] = y;\n\t}\n\tsol(0);\n\tif(!fl){puts(\"NO\"); return 0;}\n\tsol(1);\n\tif(!fl){puts(\"NO\"); return 0;}\n\tFor(i, 0, m - 1){\n\t\tif(!a[0][i] && !a[1][i]) putchar('L');\n\t\tif(!a[0][i] && a[1][i]) putchar('D');\n\t\tif(a[0][i] && !a[1][i]) putchar('U');\n\t\tif(a[0][i] && a[1][i]) putchar('R');\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1731567ee359977a6b1e127a4ee7c839", "src_uid": "941f1f8a37c25dd2405a20c7d416c9a6", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\nbool check(long long t, long long x, long long y) {\n\treturn ((x + y) % 2 + 2) % 2 == t % 2; \n}\n\ntemplate\nclass p {\npublic:\n\tT x, y;\n\t\n\tp(T a, T b): x(a), y(b) {\n\t}\n\t\n\tp operator* (T ska) {\n\t\treturn p(ska * x, ska * y);\n\t}\n\tp operator/ (T ska) {\n\t\treturn p(x/ska, y/ska);\n\t}\t\n\tp operator+ (p other) {\n\t\treturn p(x + other.x, y + other.y);\n\t}\n\t\n\tpair to_pair() const {\n\t\treturn make_pair(x, y);\n\t}\n\t\n\tbool operator< (const p& other) const {\n\t\treturn to_pair() < other.to_pair();\n\t}\n\t\n\tp flip45() {\n\t\treturn p(x + y, x - y);\n\t}\n\t\n\tp unflip45() {\n\t\treturn p(x + y, x - y) / 2;\n\t}\n\t\n\tT abs() {\n\t\treturn std::abs(x) + std::abs(y);\n\t}\n};\n\ntemplate\nclass fraction {\npublic:\n\tT x, y;\n\t\n\tfraction(T a, T b): x(a), y(b) {\n\t}\n\t\n\tfraction(T a): fraction(a, 1) {\n\t}\n\t\n\tfraction normal() {\n\t\tT g = __gcd(x, y);\n\t\tif (g == 0) g = 1;\n\t\treturn fraction(x/g, y/g);\n\t}\n\t\n\tfraction operator*(fraction other) {\n\t\treturn fraction(x * other.x, y * other.y).normal(); \n\t}\n\t\n\tfraction inverse() {\n\t\treturn fraction(y, x);\n\t}\n\t\n\tfraction operator/(fraction other) {\n\t\treturn (*this) * other.inverse();\n\t}\n\t\n\tlong long to_int() {\n\t\tif (x == 0) return 0;\n\t\treturn x / y;\n\t}\n\t\n\tbool operator < (const fraction& other) const {\n\t\treturn x * other.y < y * other.x;\n\t}\n\t\n\tbool operator >= (const fraction& other) const {\n\t\treturn not ((*this) < other);\n\t}\n\t\n\tbool operator <= (const fraction& other) const {\n\t\treturn x * other.y <= y * other.x;\n\t}\n\t\n\tbool operator > (const fraction& other) const {\n\t\treturn not ((*this) <= other);\n\t}\n\n\tbool operator <= (T other) const {\n\t\treturn x <= other * y;\n\t}\n\t\n\tbool operator >= (T other) const {\n\t\treturn x >= other * y;\n\t}\n\t\n\tfraction operator+ (fraction other) {\n\t\tT g = __gcd(y, other.y);\n\t\tif (g == 0) g = 1;\n\t\treturn fraction(x * (other.y / g) + other.x * (y / g), y * (other.y / g)); \n\t}\n\t\n\tfraction operator- () {\n\t\treturn fraction(-x, y);\n\t}\n\t\n\tfraction operator- (fraction other) {\n\t\treturn (*this) + (-other);\n\t}\n};\n\nusing pun = p;\n\nvector, pun> > data;\n\nusing ld = long double;\n\nlong long ceil(long long a, long long b) {\n\tif (b == 0) return std::numeric_limits::min();\n\tif (b < 0) {\n\t\ta *= -1;\n\t\tb *= -1;\n\t}\n\tif ((b > 0 && a > 0) || (a < 0 && b < 0)) return (a + b - 1) / b;\n\telse return a / b;\n}\n\nlong long floor(long long a, long long b) {\n\tif (b == 0) return std::numeric_limits::max();\n\tif (b < 0) {\n\t\ta *= -1;\n\t\tb *= -1;\n\t}\n\tif ((a > 0 && b > 0) || (a < 0 && b < 0)) return a / b;\n\telse return (a - (abs(b) - 1)) / b;\n}\n\nvoid popraw(long long x, int k, long long t, long long &x1, long long &x2) {\n\tlong long mini = x - k;\n\tlong long maxi = x + k;\n\tif (t < 0) {\n\t\tswap(mini, maxi);\n\t}\n\tx1 = max(x1, ceil(mini, t));\n\tx2 = min(x2, floor(maxi, t));\n}\n\npun szukaj(int l) {\n\tsort(data.begin(), data.end());\n\tint last = 0;\n\tpun lastt = pun(0, 0);\n\tpun lastx = pun(0, 0);\n\tlong long x1 = -l;\n\tlong long y1 = -l;\n\tlong long x2 = l;\n\tlong long y2 = l;\n\tfor (auto d: data) {\n\t\tint k = d.first.first - last;\n\t\tlong long t = d.first.second - lastt;\n\t\tpun dx = d.second + (lastx * (-1));\n\t\t\n\t\tpopraw(dx.x, k, t, x1, x2);\n\t\tpopraw(dx.y, k, t, y1, y2);\n\t\t\n\t\tlast = d.first.first;\n\t\tlastt = d.first.second;\n\t\tlastx = d.second;\n\t}\n\tif ((x1 + y1) % 2) {\n\t\tif (x1 < x2) x1 ++;\n\t\telse if (y1 < y2) y1 ++;\n\t}\n// \t\tprintf(\"%lld %lld %lld %lld\\n\", x1, x2, y1, y2);\n\treturn pun(x1, y1);\n}\n\nstring solve(bool failed, int l, pun x) {\n\tlong long last = 0;\n\tpun lastx = pun(0, 0);\n\tstring wynik = \"\";\n\tdata.push_back(make_pair(make_pair(l, 0), x));\n\tfor (auto d: data) {\n\t\tpun dx = d.second + (x * (-d.first.second)) + (lastx * (-1));\n\t\tlong long k = d.first.first - last;\n\t\t\n\t\tif (abs(dx.x) > k || abs(dx.y) > k) failed = true;\n\t\tfor (int i = 0; i < k; i ++) {\n\t\t\tif (dx.x > 0 && dx.y > 0) {\n\t\t\t\twynik += 'R';\n\t\t\t\tdx.x --;\n\t\t\t\tdx.y --;\n\t\t\t} else if (dx.x > 0) {\n\t\t\t\twynik += 'U';\n\t\t\t\tdx.x --;\n\t\t\t\tdx.y ++;\n\t\t\t} else if (dx.y > 0) {\n\t\t\t\twynik += 'D';\n\t\t\t\tdx.x ++;\n\t\t\t\tdx.y --;\n\t\t\t} else {\n\t\t\t\twynik += 'L';\n\t\t\t\tdx.x ++;\n\t\t\t\tdx.y ++;\n\t\t\t}\n\t\t}\n\t\t\n\t\tlast = d.first.first;\n\t\tlastx = d.second + (x * -d.first.second);\n\t}\n\tif (failed) return \"NO\";\n\treturn wynik;\n}\n\nint main() {\n\tint n, l;\n\tscanf(\"%d%d\", &n, &l);\n\tbool failed = false;\n\tfor (int i = 0; i < n; i ++) {\n\t\tlong long t, x, y;\n\t\tscanf(\"%lld%lld%lld\", &t, &x, &y);\n\t\tif (not check(t, x, y)) failed = true;\n\t\tdata.push_back(make_pair(make_pair(t % l, t / l), pun(x + y, x - y)));\n\t}\n\tpun x = szukaj(l);\n\tstring res = solve(failed, l, x);\n\tprintf(\"%s\\n\", res.c_str());\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8bc0b3ac46845b9e824d86e8ee0b6f95", "src_uid": "941f1f8a37c25dd2405a20c7d416c9a6", "difficulty": 3100.0} {"lang": "GNU C++17", "source_code": "#include \n#define PB push_back\nusing namespace std;\nconst int N = 200100;\nconst int M = 200100;\nconst int cnst = 203;\nvector g[N], vc;\nint n, m, q, lf, rt, mrk[N], U[M], V[M], par[N], pre[N], mem[cnst], cur_par;\nbool bi;\n\nvoid dfs(int v, int col){\n if (!bi) return;\n\n if (mrk[v]){\n if (mrk[v] != col){\n bi = 0;\n }\n return;\n }\n\n mrk[v] = col;\n\n for (int nm : g[v]) {\n if (nm >= lf && nm <= rt) continue;\n\n int u = (U[nm] == v ? V[nm] : U[nm]);\n\n dfs(u, 3 - col);\n }\n}\n\nint get(int x){\n if (x == pre[x]) return x;\n\n vc.PB(x);\n\n while (pre[x] != x){\n vc.PB(x);\n x = pre[x];\n }\n\n cur_par = 0;\n\n while (sz(vc) > 0){\n x = vc.back();\n vc.pop_back();\n\n cur_par ^= par[x];\n\n par[x] = cur_par;\n }\n}\n\nvoid link(int x, int y){\n if (was) return;\n\n int xx = get(x), yy = get(y);\n\n if (xx != yy){\n pre[xx] = yy;\n par[xx] = (par[y] ^ 1 ^ par[x]);\n } else {\n if ((par[x] ^ par[y] ^ 1) == 1)\n was = 1;\n }\n}\n\nint main(){\n ios_base::sync_with_stdio(0); cin.tie(0);\n\n#ifdef _LOCAL\n freopen(\"in.txt\",\"r\",stdin);\n#endif // _LOCAL\n\n cin >> n >> m >> q;\n\n for (int i = 0; i < m; i++){\n int x, y; cin >> x >> y;\n x--; y--;\n\n U[i] = x;\n V[i] = y;\n\n g[x].PB(i);\n g[y].PB(i);\n }\n\n bi = 1; lf = rt = m;\n\n for (int i = 0; i < n && bi; i++){\n if (mrk[i]) continue;\n\n dfs(i, 1);\n }\n\n if (bi){\n for (; q; q--)\n cout << \"NO\\n\";\n return 0;\n }\n\n for (int lf = 0; lf < cnst; lf++){\n for (int i = 0; i < n; i++){\n pre[i] = i;\n par[i] = 0;\n }\n\n was = 0;\n\n for (int id = 0; id < lf; id++)\n link(U[id], V[id]);\n\n int ptr = m - 1;\n\n while (!was){\n link(U[ptr], V[ptr]);\n ptr--;\n }\n\n mem[lf] = ptr;\n }\n\n for (int i = 0; i < q; i++){\n cin >> lf >> rt;\n lf--; rt--;\n\n if (lf < cnst){\n cout << (rt <= mem[lf] ? \"YES\\n\" : \"NO\\n\");\n continue;\n }\n\n fill(mrk, mrk + n, 0);\n bi = 1;\n\n for (int i = 0; i < n && bi; i++){\n if (mrk[i]) continue;\n\n dfs(i, 1);\n }\n\n cout << (bi ? \"NO\\n\" : \"YES\\n\");\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3f92da026b2621fc0f9a243433813c06", "src_uid": "57ad95bb938906f7550f7eb6422130f7", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "/*\n * use lct to maintain the maximum spanning tree, to check whether bipartite\n */\n\n#include \nusing namespace std;\n\nconstexpr int _I_Buffer_Size = 8 << 20, _O_Buffer_Size = 1 << 20;\nstatic char _I_Buffer[_I_Buffer_Size], _O_Buffer[_O_Buffer_Size];\nchar *_I_pos = _I_Buffer, *_O_pos = _O_Buffer;\nvoid read(int32_t *n) {\n while (*_I_pos < 48) _I_pos++;\n *n = *_I_pos++ - '0';\n while (*_I_pos > 47)\n *n = *n * 10 + (*_I_pos++ - '0');\n}\n#define put_YES() (*_O_pos++ = 'Y', *_O_pos++ = 'E', *_O_pos++ = 'S', 0)\n#define put_NO() (*_O_pos++ = 'N', *_O_pos++ = 'O', 0)\n\nconstexpr int Maxn = 200005;\n\nint n, m, q;\nint eu[Maxn], ev[Maxn];\nint rr[Maxn];\n\n// i \\le j => ans_i \\le ans_j\n\nint stk[Maxn], top;\nint fa[Maxn];\nint val[Maxn], rt[Maxn];\n\nvoid init_ufs() {\n top = 0;\n memset(stk, 0, sizeof(stk));\n for (int i = 0; i < Maxn; ++i) {\n fa[i] = i;\n val[i] = 0;\n rt[i] = 0;\n }\n}\ninline int fnd(int x) {\n while (x ^ fa[x])\n x = fa[x];\n return x;\n}\ninline int get_dis(int x) {\n int ans = 0;\n while (x ^ fa[x]) {\n ans ^= val[x];\n x = fa[x];\n }\n return ans;\n}\nvoid join(int x, int y, int len) {\n if (x == y) return ;\n if (rt[x] > rt[y]) swap(x, y);\n if (rt[x] == rt[y]) {\n rt[y]++;\n stk[++top] = -y;\n }\n fa[x] = y;\n val[x] = len;\n stk[++top] = x;\n}\nvoid undo() {\n fa[stk[top]] = stk[top];\n val[stk[top]] = 0;\n --top;\n if (stk[top] < 0) {\n rt[-stk[top]]--;\n --top;\n }\n}\nbool unite(int x, int y) {\n int rx = fnd(x), ry = fnd(y);\n int len = get_dis(x) ^ get_dis(y) ^ 1;\n if (rx == ry) {\n if (len) return false;\n }\n else {\n join(rx, ry, len);\n }\n return true;\n}\n\ninline void add_edge(int l, int r) {\n for (int i = l; i <= r; ++i)\n assert(unite(eu[i], ev[i]));\n}\ninline void undo_ufs(int times) {\n while (times--) undo();\n}\nint get_answer(int pos, int l, int R) {\n for (int i = l; i < pos; ++i)\n assert(unite(eu[i], ev[i]));\n int cnt = pos - l;\n while (true) {\n bool ff = unite(eu[R], ev[R]);\n ++cnt, --R;\n if (!ff) break;\n }\n undo_ufs(cnt);\n return R + 1;\n}\n\n// ufs contains [1, l) \\cup (R, n]\nvoid cdq(int l, int r, int L, int R) {\n if (l > r) return ;\n if (L == R) {\n for (int i = l; i <= r; ++i)\n rr[i] = L;\n return ;\n }\n L = max(L, l);\n int mid = (l + r) >> 1;\n rr[mid] = get_answer(mid, l, R);\n // (l, mid, r) => (L, rr[mid], R)\n if (rr[mid] < R) add_edge(rr[mid] + 1, R);\n cdq(l, mid - 1, L, rr[mid]);\n if (rr[mid] < R) undo_ufs(R - rr[mid]);\n if (l <= mid) add_edge(l, mid);\n cdq(mid + 1, r, rr[mid], R);\n if (l <= mid) undo_ufs(mid - l + 1);\n}\n\nint main() {\n\n#ifdef LOCAL_JUDGE\n freopen(\"CF1386C.in\", \"r\", stdin);\n#endif\n fread(_I_Buffer, 1, _I_Buffer_Size, stdin);\n assert(atexit([&](void)->void {\n fwrite(_O_Buffer, 1, _O_pos - _O_Buffer, stdout);\n }) == 0);\n\n read(&n), read(&m), read(&q);\n for (int i = 1; i <= m; ++i)\n read(eu + i), read(ev + i);\n\n init_ufs();\n int f = 1;\n for (; f <= m; ++f) {\n if (!unite(eu[f], ev[f])) break;\n }\n if (f == m + 1) {\n while (q--) puts(\"NO\");\n return 0;\n }\n init_ufs();\n for (int i = f + 1; i <= m; ++i)\n rr[i] = m + 1;\n cdq(1, f, 1, m);\n \n while (q--) {\n int l, r;\n read(&l), read(&r);\n if (rr[l] > r) puts(\"YES\");\n else puts(\"NO\");\n }\n \n return 0;\n \n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f2ad3af61091a975cedc169a0c6f6a19", "src_uid": "57ad95bb938906f7550f7eb6422130f7", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#define vi vector\n#define pii pair\n#define fst first\n#define vpi vector\n#define ppi pair\n#define snd second\n\nusing namespace std;\n\nnamespace fastIO\n{\n\tchar outString[64];\n\t// inline int getchar_unlocked() {return getchar();}\n\t// inline void putchar_unlocked(int x) {putchar(x);}\n\tinline int charInput() {return getchar_unlocked();}\n\tinline void charOutput(int x) {putchar_unlocked(x);}\n\tinline bool isNum(int c) {return '0' <= c && c <= '9';}\n\tinline int intInput()\n\t{\n\t\tint c = 0, ret = 0; bool neg = 0;\n\t\twhile (!isNum(c)) \n\t\t{\n\t\t\tc = getchar_unlocked();\n\t\t\tif (c == '-') {neg = 1;}\n\t\t}\n\t\twhile (isNum(c)) {ret = ret * 10 + c - '0'; c = getchar_unlocked();}\n\t\treturn (neg) ? -ret : ret;\n\t}\n\tinline void intOutput(int x)\n\t{\n\t\tint ss = 0;\n\t\twhile (x) {outString[ss++] = x % 10 + '0'; x /= 10;}\n\t\tif (!ss) outString[ss++] = '0';\n\t\tfor (int i = ss - 1; i >= 0; i--) putchar_unlocked(outString[i]);\n\t}\n\tinline void strOutput(string s)\n\t{\n\t\tfor (auto &c : s) putchar_unlocked(c);\n\t}\n}\n\nint n, m, q;\nvpi adj[200001];\nbool vis[200001];\nbool clr[200001];\n\npii edge[200001];\nppi qry[200001];\nstring ans[200001];\nint sz[200001];\nbool lz[200001];\npair par[200001];\n\npair find(int x)\n{\n\tif (x == par[x].fst) {return {x, 0};}\n\telse\n\t{\n\t\tpair ret = find(par[x].fst);\n\t\tpar[x] = {ret.fst, ret.snd ^ par[x].snd};\n\t\treturn par[x];\n\t}\n}\n\ninline bool join(int a, int b)\n{\n\tpii parA = find(a), parB = find(b);\n\t//cout << \"join \" << a << \" \" << b << \"\\n\";\n\tif (sz[parA.fst] < sz[parB.fst]) {swap(a, b); swap(parA, parB);}\n\tif (parA.fst != parB.fst)\n\t{\n\t\tif (sz[parA.fst] == sz[parB.fst]) sz[parA.fst]++;\n\t\tpar[parB.fst].fst = parA.fst;\n\t\tpar[parB.fst].snd = (parA.snd == parB.snd);\n\t\treturn 1;\n\t}\n\treturn parA.snd != parB.snd;\n}\n\nbool dfs(int u, bool c, int L, int R)\n{\n\tif (!vis[u])\n\t{\n\t\tvis[u] = 1;\n\t\tclr[u] = c;\n\t\tbool ret = 1;\n\t\tfor (auto v : adj[u])\n\t\t{\n\t\t\tif (L <= v.snd && v.snd <= R) continue;\n\t\t\telse ret &= dfs(v.fst, !c, L, R);\n\t\t}\n\t\treturn ret;\n\t}\n\telse {return clr[u] == c;}\n}\n\nint main()\n{\n\tn = fastIO :: intInput();\n\tm = fastIO :: intInput();\n\tq = fastIO :: intInput();\n\tif (n + m <= 2000)\n\t{\n\t\tfor (int i = 0; i < m; i++)\n\t\t{\n\t\t\tint u, v; \n\t\t\tu = fastIO :: intInput();\n\t\t\tv = fastIO :: intInput();\n\t\t\tadj[u - 1].push_back({v - 1, i});\n\t\t\tadj[v - 1].push_back({u - 1, i});\n\t\t}\n\t\tfor (int i = 0; i < q; i++)\n\t\t{\n\t\t\tbool ans = 1;\n\t\t\tint l, r;\n\t\t\tl = fastIO :: intInput();\n\t\t\tr = fastIO :: intInput();\n\t\t\tl--; r--;\n\t\t\tfor (int j = 0; j < n; j++)\n\t\t\t{\n\t\t\t\tif (!vis[j]) \n\t\t\t\t{ \n\t\t\t\t\tans &= dfs(j, 0, l, r);\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (int j = 0; j < n; j++) {vis[j] = 0;}\n\t\t\tif (ans) fastIO :: strOutput(\"NO\\n\");\n\t\t\telse fastIO :: strOutput(\"YES\\n\");\n\t\t}\n\t}\n\telse\n\t{\n\t\tfor (int i = 0; i < m; i++)\n\t\t{\n\t\t\tint u, v; \n\t\t\tu = fastIO :: intInput();\n\t\t\tv = fastIO :: intInput();\n\t\t\tedge[i] = {u - 1, v - 1};\n\t\t}\n\t\tfor (int i = 0; i < q; i++)\n\t\t{\n\t\t\tqry[i].fst.fst = fastIO :: intInput();\n\t\t\tqry[i].fst.snd = fastIO :: intInput();\n\t\t\tqry[i].fst.fst--;\n\t\t\tqry[i].fst.snd--;\n\t\t\tqry[i].fst.snd = -qry[i].fst.snd;\n\t\t\tqry[i].snd = i;\n\t\t}\n\t\tsort(qry, qry + q);\n\t\tfor (int j = 0; j < n; j++)\n\t\t{\n\t\t\tpar[j] = {j, 0}; lz[j] = 0; sz[j] = 0; clr[j] = 0;\n\t\t}\n\t\tbool cur = 1; int pv = m - 1;\n\t\tfor (int j = 0; j < qry[0].fst.fst; j++)\n\t\t{\n\t\t\tcur &= join(edge[j].fst, edge[j].snd);\n\t\t}\n\t\tfor (int i = 0; i < q; i++)\n\t\t{\n\t\t\tqry[i].fst.snd = -qry[i].fst.snd;\n\t\t\tfor (; pv > qry[i].fst.snd && cur; pv--)\n\t\t\t{\n\t\t\t\tcur &= join(edge[pv].fst, edge[pv].snd);\n\t\t\t}\n\n\t\t\tif (cur) {ans[qry[i].snd] = \"NO\";}\n\t\t\telse {ans[qry[i].snd] = \"YES\";}\n\n\t\t\tif (i + 1 < q && qry[i + 1].fst.fst != qry[i].fst.fst)\n\t\t\t{\n\t\t\t\tfor (int j = 0; j < n; j++)\n\t\t\t\t{\n\t\t\t\t\tpar[j] = {j, 0}; lz[j] = 0; sz[j] = 0; clr[j] = 0;\n\t\t\t\t}\n\t\t\t\tpv = m - 1; cur = 1;\n\t\t\t\tfor (int j = 0; j < qry[i + 1].fst.fst && cur; j++)\n\t\t\t\t{\n\t\t\t\t\tcur &= join(edge[j].fst, edge[j].snd);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < q; i++)\n\t\t{\n\t\t\tfastIO::strOutput(ans[i]);\n\t\t\tfastIO::charOutput('\\n');\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e4efab0291b4c33446e90d52a996ea41", "src_uid": "57ad95bb938906f7550f7eb6422130f7", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "#include \n#define sz(x) ((int)x.size())\n#define PB push_back\nusing namespace std;\nconst int N = 200100;\nconst int M = 200100;\nconst int cnst = 203;\nvector g[N], vc;\nint n, m, q, lf, rt, mrk[N], U[M], V[M], par[N], pre[N], mem[cnst], cur_par;\nbool bi, was;\n\nvoid dfs(int v, int col){\n if (!bi) return;\n\n if (mrk[v]){\n if (mrk[v] != col){\n bi = 0;\n }\n return;\n }\n\n mrk[v] = col;\n\n for (int nm : g[v]) {\n if (nm >= lf && nm <= rt) continue;\n\n int u = (U[nm] == v ? V[nm] : U[nm]);\n\n dfs(u, 3 - col);\n }\n}\n\nint get(int x){\n if (x == pre[x]) return x;\n\n vc.PB(x);\n\n while (pre[x] != x){\n vc.PB(x);\n x = pre[x];\n }\n\n cur_par = 0;\n\n int par = vc.back();\n\n while (sz(vc) > 0){\n x = vc.back();\n vc.pop_back();\n\n cur_par ^= par[x];\n\n par[x] = cur_par;\n }\n\n return par;\n}\n\nvoid link(int x, int y){\n if (was) return;\n\n int xx = get(x), yy = get(y);\n\n if (xx != yy){\n pre[xx] = yy;\n par[xx] = (par[y] ^ 1 ^ par[x]);\n } else {\n if ((par[x] ^ par[y] ^ 1) == 1)\n was = 1;\n }\n}\n\nint main(){\n ios_base::sync_with_stdio(0); cin.tie(0);\n\n#ifdef _LOCAL\n freopen(\"in.txt\",\"r\",stdin);\n#endif // _LOCAL\n\n cin >> n >> m >> q;\n\n for (int i = 0; i < m; i++){\n int x, y; cin >> x >> y;\n x--; y--;\n\n U[i] = x;\n V[i] = y;\n\n g[x].PB(i);\n g[y].PB(i);\n }\n\n bi = 1; lf = rt = m;\n\n for (int i = 0; i < n && bi; i++){\n if (mrk[i]) continue;\n\n dfs(i, 1);\n }\n\n if (bi){\n for (; q; q--)\n cout << \"NO\\n\";\n return 0;\n }\n\n for (int lf = 0; lf < cnst; lf++){\n for (int i = 0; i < n; i++){\n pre[i] = i;\n par[i] = 0;\n }\n\n was = 0;\n\n for (int id = 0; id < lf; id++)\n link(U[id], V[id]);\n\n int ptr = m - 1;\n\n while (!was){\n link(U[ptr], V[ptr]);\n ptr--;\n }\n\n mem[lf] = ptr;\n }\n\n for (int i = 0; i < q; i++){\n cin >> lf >> rt;\n lf--; rt--;\n\n if (lf < cnst){\n cout << (rt <= mem[lf] ? \"YES\\n\" : \"NO\\n\");\n continue;\n }\n\n fill(mrk, mrk + n, 0);\n bi = 1;\n\n for (int i = 0; i < n && bi; i++){\n if (mrk[i]) continue;\n\n dfs(i, 1);\n }\n\n cout << (bi ? \"NO\\n\" : \"YES\\n\");\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "22ff2aeb6eaf09524f6252908a82b20c", "src_uid": "57ad95bb938906f7550f7eb6422130f7", "difficulty": 2800.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\nint main(){\n //freopen(\"input.txt\",\"r\",stdin);\n //freopen(\"output.txt\",\"w\",stdout);\n int q,w,e,r,t,c,v,s[3]={0,0,0};\n bool a[300][300][300],a1[300][300];\n scanf(\"%d\",&q);\n for(w=0;ws[1]){\n w=s[0];s[0]=s[1];s[1]=w;}\n if(s[0]>s[2]){\n w=s[0];s[0]=s[2];s[2]=w;}\n if(s[1]>s[2]){\n w=s[1];s[1]=s[2];s[2]=w;}\n if(a[s[0]][s[1]][s[2]])\n printf(\"BitLGM\");\n else\n printf(\"BitAryo\");}\n if(q==2){\n for(w=0;w<300;w++)\n for(e=w;e<300;e++)\n a[w][e]=0;\n for(w=0;w<300;w++)\n for(e=w;e<300;e++)\n if(a1[w][e]==0){\n for(c=w+1;cs[1]){\n w=s[0];s[0]=s[1];s[1]=w;}\n if(a1[s[0]][s[1]])\n printf(\"BitLGM\");\n else\n printf(\"BitAryo\");}\n if(q==1)\n if(s[0])\n printf(\"BitLGM\");\n else\n printf(\"BitAryo\");\n return 0;}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "37870961642ceefa36bb304c67db34da", "src_uid": "7a33b4f94082c7ef80d7e87b58497fa7", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define SET(p) memset(p, -1, sizeof(p))\n#define CLR(p) memset(p, 0, sizeof(p))\n#define MEM(p, v) memset(p, v, sizeof(p))\n#define CPY(d, s) memcpy(d, s, sizeof(s))\n#define ll long long\n#define ld long double\n#define mod 1000000007\n#define inf 1LL<<60\n#define pii pair< int, int >\n#define pll pair< ll, ll >\n#define psi pair< string, int >\n#define N 100010\nusing namespace std;\nset s;\nunordered_set m;\nvoid solve(int x,int y){\n\tif(s.count(pii(x,y)))\n\t\tcout<<\"BitAryo\"<>n;\n int a[n];\n int mn = 1000000;\n for(int i=0;i>a[i];\n mn = min(a[i],mn);\n }\n sort(a,a+n);\n if(n==1){\n \tif(a[i])cout<<\"BitLGM\"<\n#include \n#include \n#include \nusing namespace std;\n\nint n;\nint a[3];\nint dp2[301][301];\nint dp3[301][301][301];\nint leastK[301][301];\nint hasMin[301][301][301];\n\nint solve2(int a, int b) {\n\tif (dp2[a][b] != -1) return dp2[a][b];\n\tif (a == 0 && b == 0) return dp2[a][b] = 0;\n\telse {\n\t\tfor (int i = 1; i <= a; i++) {\n\t\t\tif (solve2(a - i, b) == 0) {\n\t\t\t\treturn dp2[a][b] = 1;\n\t\t\t}\n\t\t}\n\t\tfor (int i = 1; i <= b; i++) {\n\t\t\tif (solve2(a, b - i) == 0) {\n\t\t\t\treturn dp2[a][b] = 1;\n\t\t\t}\n\t\t}\n\t\tfor (int i = 1; i <= min(a, b); i++) {\n\t\t\tif (solve2(a - i, b - i) == 0) {\n\t\t\t\treturn dp2[a][b] = 1;\n\t\t\t}\n\t\t}\n\t\treturn dp2[a][b] = 0;\n\t}\n}\n\n\nint main() {\n\tios_base::sync_with_stdio(0);\n\tfor (int i = 0; i <= 300; i++) {\n\t\tfor (int j = 0; j <= 300; j++) {\n\t\t\tfor (int k = 0; k <= 300; k++) {\n\t\t\t\tdp3[i][j][k] = -1;\n\t\t\t\thasMin[i][j][k] = 500;\n\t\t\t}\n\t\t\tdp2[i][j] = -1;\n\t\t\tleastK[i][j] = 500;\n\t\t}\n\t}\n\tcin >> n;\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> a[i];\n\t}\n\tif (n == 1) {\n\t\tif (a[0] == 0) {\n\t\t\tcout << \"BitAryo\";\n\t\t} else {\n\t\t\tcout << \"BitLGM\";\n\t\t}\n\t} else if (n == 2) {\n\t\tint ans = solve2(a[0], a[1]);\n\t\tif (ans == 1) {\n\t\t\tcout << \"BitLGM\";\n\t\t} else {\n\t\t\tcout << \"BitAryo\";\n\t\t}\n\t} else {\n\t\tdp3[0][0][0] = 0;\n\t\tleastK[0][0] = 0;\n\t\tleastK2[0][0] = 500;\n\t\tfor (int i = 0; i <= a[0]; i++) {\n\t\t\tfor (int j = 0; j <= a[1]; j++) {\n\t\t\t\tfor (int k = 0; k <= a[2]; k++) {\n\t\t\t\t\tif (i + j + k == 0) continue;\n\t\t\t\t\tif (leastK[i][j] < k) dp3[i][j][k] = 1;\n\t\t\t\t\tif (leastK[j][k] < i) dp3[i][j][k] = 1;\n\t\t\t\t\tif (leastK[k][i] < j) dp3[i][j][k] = 1;\n\t\t\t\t\tif (i != 0 && j != 0 && k != 0 && hasMin[i - 1][j - 1][k - 1]) dp3[i][j][k] = 1;\n\t\t\t\t\tif (dp3[i][j][k] == -1) dp3[i][j][k] = 0;\n\t\t\t\t\tif (dp3[i][j][k] == 0) {\n\t\t\t\t\t\tleastK[i][j] = leastK[j][i] = min(leastK[i][j], k);\n\t\t\t\t\t\tleastK[i][k] = leastK[k][i] = min(leastK[k][i], j);\n\t\t\t\t\t\tleastK[j][k] = leastK[k][j] = min(leastK[j][k], i);\n\t\t\t\t\t}\n\t\t\t\t\tif (i != 0 && j != 0 && k != 0) {\n\t\t\t\t\t\thasMin[i][j][k] = hasMin[i - 1][j - 1][k - 1] || (dp3[i][j][k] == 0);\n\t\t\t\t\t} else {\n\t\t\t\t\t\thasMin[i][j][k] = (dp3[i][j][k] == 0);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cc77534c74df30e318c8cb7e7cd8d9f8", "src_uid": "7a33b4f94082c7ef80d7e87b58497fa7", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "/* Problem : D. Yet Another Number Game\n** Time : 3000ms\n** Algorithm: dp\n**/\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define st first\n#define nd second\n#define read(x) scanf(\"%d\",&x)\n#define MAXN 1000005\ntypedef long long int64;\nint a[MAXN], cnt[301];\nint main (int argc, char const* argv[]){\n if ( argc == 3 ){\n freopen(argv[1],\"r\",stdin);\n freopen(argv[2],\"w\",stdout);\n }\n int n; read(n);\n int x = 0, mn = 301, nb = 0;\n for(int i = 0 ; i < n ; ++i){\n read(a[i]);\n x ^= a[i];\n mn = min(a[i],mn);\n if ( cnt[a[i]] == 0 ){\n ++nb;\n }\n ++cnt[a[i]];\n }\n if ( nb == 1 || x % 2 = 0 ){\n puts(\"BitLGM\");\n return 0;\n }\n x = 0;\n for(int i = 0 ; i < n ; ++i){\n a[i] -= mn;\n x ^= a[i];\n }\n if ( x % 2 == 1 ){\n puts(\"BitLGM\");\n }else{\n puts(\"BitAryo\");\n }\n return 0;\n}\n\n/* DOAN Minh Quy - mquy.doan@gmail.com */", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b98a94ad0835b67d89e6df34dfe05b7f", "src_uid": "7a33b4f94082c7ef80d7e87b58497fa7", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main()\n{\n\tint n, t, k, d,t1,t2;\n\tdouble c;\n\tcin >> n >> t >> k >> d;\n\tc = (n / k);\n\tt1 = 0; t2 = d;\n\tfor (int i = 0; i < c; i++)\n\t{\n\t\tif (t1 < t2){ t1 += t; }\n\t\telse { t2 += t; }\n\t}\n\tif (t2>=ceil(c*t)){ cout << \"NO\"; }\n\telse if (t2 < ceil(c*t)){ cout << \"YES\"; }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "22fec339182f48d8e193387b80888ccc", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define ll long long int\n#define pp pair\n#define mp make_pair\n#define pb push_back\n#define S second\n#define F first\nconst int MAX=1e5+7;\nconst int MOD=1e9+7;\ndouble pi=M_PI;\nint main()\n{\n\tint n,i,t,k,d;\n\tbool f;\n\tscanf(\"%d %d %d %d\",&n,&t,&k,&d);\n\ti=k*d/t;\n\tif(n<=i) f=false;\n\telse{\n\t\ti=n-i;\n\t\tif(i>k) f=true;\n\t\telse f=false;\n\t}\n\tif(f) printf(\"YES\\n\");\n\telse printf(\"NO\\n\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e0179ed50c3976e603a2cc4405e0e43c", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#define ll long long\nusing namespace std;\n\nint main()\n{\n int n, t, k, d;\n cin >> n >> t >> k >> d;\n double _each = n / k;\n int all = ((int)round(_each)) * t;\n int _new = (t + d);\n string res = (all > _new) ? \"YES\" : \"NO\";\n cout << res;\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bcf9b9c2176fbb4adb081e050107842e", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint a,b,c,d,x,y,z,i,n,j,t,k;\nmain(){\n\tcin>>n>>t>>k>>d;\n\tif(n/k%==0)\n\tx=n/k*t;\n\t\n\tif(k>n && d>k || kt || k>n && dt+d) cout<<\"YES\"; else cout<<\"NO\";\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c0890a93360b09ade0f2dccfdaff652a", "src_uid": "32c866d3d394e269724b4930df5e4407", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint a,b,c,n,x;\nint main()\n{\n cin>>n>>a>>b>>c;\n n=n-1;\n x=1;\n while(n--)\n {\n if(x==1) { if(b>c) { x=3; ans=ans+c } else { x=2; ans=ans+b } }\n if(x==2) { if(a>c) { x=3; ans=ans+c } else { x=1; ans=ans+a } }\n if(x==3) { if(b>a) { x=1; ans=ans+a } else { x=2; ans=ans+b } } \n }\n cout<\n\n\nusing namespace std;\n\n\nint main()\n{\n int a,b,c,n;\n while(cin >> n>> a >> b >> c){\n if(n==1)\n cout << 0 << endl;\n else{\n cout << (n-2)*(min(a,min(b,c)))+min(a,b) << endl;\n }\n\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0fcb0394b25210400c5ef3bc2855b5a0", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint n,a,b,c,m=1,k=1,ans;\nint main(){\n cin>>n>>a>>b>>c;\n \n while(k++\n\n#define PI acos(-1.0)\n\n#define rep1(i,n) for(i=1;i<=n;i++)\n#define rep0(i,n) for(i=0;i=0&&nx<8&&ny>=0&&ny<8\n#define triangle_area(a,b,m,n,x,y) (a*(n-y)+m*(y-b)+x*(b-n))\n#define dis_without_sqrt(x,y,x1,y1) (x-x1)*(x-x1)+(y-y1)*(y-y1)\n//int ax[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves\n//int ay[]={2,-2, 2, -2, 1,-1, 1, -1}; //knight moves\nusing namespace std;\n\n//int setb(int n,int pos){return n=n | (1 << pos);}\n//int resb(int n,int pos){return n=n & ~(1 << pos);}\n//bool checkb(int n,int pos){return (bool)(n & (1 << pos)); }\n\nint n,a,b,c,mn;\nint dpt[5];\nint dp(int i,int total,int stage)\n{\n if(i==n)\n {\n mn=min(total,mn);\n return;\n }\n if(stage==0)\n {\n if(dpt[stage]!=-1)return dpt[stage];\n dpt[stage]=min(dp(i+1,total+a,1),dp(i+1,total+b,2));\n }\n if(stage==1)dp(i+1,total+a,0),dp(i+1,total+c,2);\n if(stage==2)dp(i+1,total+b,0),dp(i+1,total+c,1);\n}\n\nint main()\n{\n\t//FI;\n\t//ios_base::sync_with_stdio(false); cin.tie(NULL);\n while(si(n)!=EOF)\n {\n siii(a,b,c);\n mn=123456789;\n dpt[0]=-1,dpt[1]=-1,dpt[2]=-1;\n dp(1,0,0);\n pi(mn);\n }\n\treturn 0;\n}\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e1b9b40927fd71c3286c06d7473ebabb", "src_uid": "6058529f0144c853e9e17ed7c661fc50", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint main()\n{\n\tint m,d;\n\tcin>>m>>d;\n\tif(m%2==0&&m<8&&m!=2)\n\t{\n\t\tif(d<7)\n\t\tcout<<\"6\";\n\t\tif(d==7)\n\t\tcout<<\"5\";\n\t}\n\tif(m%2!=0&&m<8)\n\t{\n\t\tif(d<6)\n\t\tcout<<\"5\";\n\t\telse\n\t\tcout<<\"6\";\n\t}\t\n\tif(m%2!=0&&m>=8)\n\t{\n\t\tif(d<7)\n\t\tcout<<\"5\";\n if(d==7)\n\t\tcout<<\"6\";\n\t}\n\tif(m%2==0&&m>=8)\n\t{\n\t\tif(d<6)\n\t\tcout<<\"5\";\n\t\telse\n\t\tcout<<\"6\";\n\t}\n\tif(m==2)\n\t{\n\t\tif(d==1)\n\t\tcout<<\"4\"\n\t\telse\n\t\tcout<<\"5\"\n\t\t\t}return 0;\t\t\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e28d9a1a2fbb24a4020bc0aa865ccbb8", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "\ufeff\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Express 2012 for Windows Desktop\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"Project8\", \"Project8\\Project8.vcxproj\", \"{BD51574D-751E-4CCB-A80E-8018D1F51FB8}\"\nEndProject\nGlobal\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n\t\tDebug|Win32 = Debug|Win32\n\t\tRelease|Win32 = Release|Win32\n\tEndGlobalSection\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n\t\t{BD51574D-751E-4CCB-A80E-8018D1F51FB8}.Debug|Win32.ActiveCfg = Debug|Win32\n\t\t{BD51574D-751E-4CCB-A80E-8018D1F51FB8}.Debug|Win32.Build.0 = Debug|Win32\n\t\t{BD51574D-751E-4CCB-A80E-8018D1F51FB8}.Release|Win32.ActiveCfg = Release|Win32\n\t\t{BD51574D-751E-4CCB-A80E-8018D1F51FB8}.Release|Win32.Build.0 = Release|Win32\n\tEndGlobalSection\n\tGlobalSection(SolutionProperties) = preSolution\n\t\tHideSolutionNode = FALSE\n\tEndGlobalSection\nEndGlobal\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fbf6ff1ec5e4f503234d942ef3cb0bc7", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include\nusing namespace std;\nint main()\n{\n\tint m,d,i;\n\tcin>>m>>d;\n\tif(m==2&&d==1)\n\tcout<<\"4\";\n\telse if(m==2)\n\tcout<<\"5\";\n\telse if(m==1||m==3||m==5||m==7||m==8||m==10||m==12)\n\t{\n\t\tif(d>5)\n\t\tcout<<\"6\";\n\t\telse\n\t\tcout<<\"5\";\n\t}\n\telse\n\t{\n\t\tif(d==7)\n\t\tcout<<\"6\";\n\t\telse\n\t\tcout<<\"5\";\n\t}\n\treturn 0;\n}\nclose", "lang_cluster": "C++", "compilation_error": true, "code_uid": "eca2a84e8c68d6f3a7a319d7536de364", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nint main (){\n\tint m, d;\n\tcin >> m >> d;\n\tint n;\n\t31,28,31,30,31,30,31,31,30,31,30,31\n\tif (m == 1) n = 31;\n\telse if (m == 2) n = 28;\n\telse if (m == 3) n = 31;\n\telse if (m == 4) n = 30;\n\telse if (m == 5) n = 31;\n\telse if (m == 6) n = 30;\n\telse if (m == 7) n = 31;\n\telse if (m == 8) n = 31;\n\telse if (m == 9) n = 30;\n\telse if (m == 10) n = 31;\n\telse if (m == 11) n = 30;\n\telse if (m == 12) n = 31;\n\tcout << ((d - 1) + n - 1) / 7 + 1;\n\treturn 0; \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ada258b56107807e8019a0eaf3d47a6d", "src_uid": "5b969b6f564df6f71e23d4adfb2ded74", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "//****************************Bismillahir Rahmanir Rahim***************************??\n\n#include\nusing namespace std;\n\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vl;\ntypedef vector vvi;\ntypedef vector vvl;\ntypedef pair pii;\ntypedef pair pdd;\ntypedef pair pll;\ntypedef vector vii;\ntypedef vector vll;\n\n#define PB push_back\n#define F first\n#define S second\n#define MP make_pair\n#define endl '\\n'\n\nconst double PI = acos(-1);\nconst double eps = 1e-9;\nconst int inf = 2000000000;\nconst ll infLL = 9000000000000000000;\n#define MOD 1000000007\n//#define harmonic(n) 0.57721566490153286l+log(n)\n\n#define mem(a,b) memset(a, b, sizeof(a) )\n#define gcd(a,b) __gcd(a,b)\n#define lcm(a,b) (a*(b/gcd(a,b)))\n#define sqr(a) ((a) * (a))\n\n#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);\n\ntypedef vector::iterator vit;\ntypedef set::iterator sit;\n\ninline bool checkBit(ll n, int i) { return n&(1LL<>= 1; } return r; }\ninline ll modInverse(ll a) { return modPow(a, MOD-2); }\ninline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }\n\n\n/*bool seive[1010000];\nvi prime;\n\nvoid seiveGen(int limit) {\n limit += 100;\n int sqrtn = sqrt(limit);\n for(int i = 3; i <= sqrtn; i += 2) {\n if(!seive[i>>1]) {\n for(int j = i * i; j < limit; j += i + i) {\n seive[j>>1] = 1;\n }\n }\n }\n prime.PB(2);\n for(int i = 3; i < limit; i += 2) {\n if(!seive[i>>1]) prime.PB(i);\n }\n}*/\n\n/*\n*******************************USE of STL***************************\nv.erase(unique(v.begin(),v.end()),v.end());\n int a[]={..........};\n sort(a,a+n,greater()); ///sort in descending order\n int z=sizeof(a)/sizeof(a[0]); ///size of array\n string s,x;\n transform(s.begin(),s.end(),s.begin(),::tolower);///change of uppercase to lowercase of any string\n int i;\n i=s.compare(x); ///compare two string like strcmp\n int n,m;\n i=log10(n)+1; ///how many digits in integer n\n i=abs(n-m); ///take absolute value\n copy(v.begin(),v.end(),back_inserter(q)); ///copying v vector to q\n s.find(\"AB\"); ///search index Number of AB(substring) in string s\n remove(a,a+n,3); ///delete 3rd element from array\n ceil(2.3) /// Returns the smallest integer that is greater than or equal to x (i.e : rounds up the nearest integer) \u09a6\u09b6\u09ae\u09bf\u0995 \u09af\u09a6\u09bf <=.\u09eb \u09b9\u09df \u09a4\u09be\u09b9\u09b2\u09c7 \u098f\u0995\u09af\u09cb\u0997 \u0995\u09b0\u09c7 \u09aa\u09cd\u09b0\u09bf\u09a8\u09cd\u099f \u0995\u09b0\u09ac\u09c7\n round(2.3)///return round value...like 2.3=2,,,2.5=3,,2.6=3;\n\n {\n ///int to string transfer///\n ostringstream temp; ///need a temp;\n int x;\n temp<\nostream& operator << ( ostream& os, const pair< F, S > & p ) {\n return os << \"(\" << p.first << \", \" << p.second << \")\";\n}\n\ntemplate < typename T >\nostream &operator << ( ostream & os, const vector< T > &v ) {\n os << \"{\";\n for(auto it = v.begin(); it != v.end(); ++it) {\n if( it != v.begin() ) os << \", \";\n os << *it;\n }\n return os << \"}\";\n}\n\ntemplate < typename T >\nostream &operator << ( ostream & os, const set< T > &v ) {\n os << \"[\";\n for(auto it = v.begin(); it != v.end(); ++it) {\n if( it != v.begin() ) os << \", \";\n os << *it;\n }\n return os << \"]\";\n}\n\ntemplate < typename T >\nostream &operator << ( ostream & os, const multiset< T > &v ) {\n os << \"[\";\n for(auto it = v.begin(); it != v.end(); ++it) {\n if( it != v.begin() ) os << \", \";\n os << *it;\n }\n return os << \"]\";\n}\n\ntemplate < typename F, typename S >\nostream &operator << ( ostream & os, const map< F, S > &v ) {\n os << \"[\";\n for(auto it = v.begin(); it != v.end(); ++it) {\n if( it != v.begin() ) os << \", \";\n os << it -> first << \" = \" << it -> second ;\n }\n return os << \"]\";\n}\n\n#define dbg(args...) do {cerr << #args << \" : \"; faltu(args); } while(0)\n\nclock_t tStart = clock();\n#define timeStamp dbg(\"Execution Time: \", (double)(clock() - tStart)/CLOCKS_PER_SEC)\n\nvoid faltu () {\n cerr << endl;\n}\n\ntemplate \nvoid faltu( T a[], int n ) {\n for(int i = 0; i < n; ++i) cerr << a[i] << ' ';\n cerr << endl;\n}\n\ntemplate \nvoid faltu( T arg, const hello &... rest) {\n cerr << arg << ' ';\n faltu(rest...);\n}\n#else\n#define dbg(args...)\n#endif\n//****************Source Code starting From here**************//\n\nint main()\n{\n\tll a,b,c=-1,n;\n\tcin>>n;\n\tif(n<=2)\n\t{\n\t cout<\nusing namespace std;\nint mian(){\nint n;\ncin>>n;\nif(n%2==0){\ncout<\n using namespace std;\n\n typedef long long ll;\n\n int const N=1e5+5, M=1e9, OO=0x3f3f3f3f, MOD=1e9+7;\n\n ll n,ans;\n\n ll lcm(ll a, ll b)\n {\n return a/__gcd(a,b)*b;\n }\n\n int main()\n {\n // freopen(\"input.txt\",\"rt\",stdin);\n // freopen(\"output.txt\",\"wt\",stdout);\n scanf(\"%I64d\",&n);\n if(n<=2)\n printf(\"%d\\n\",n);\n else\n {\n if(n&1)\n printf(\"%I64d\\n\",lcm(lcm(n,n-1),n-2));\n else\n {\n for(int i=max(1ll,n-50); i<=n; i++)\n for(int j=max(1ll,n-50); j<=n; j++)\n for(int k=max(1ll,n-50); k<=n; k++)\n ans=max(ans,lcm(lcm(i,j),k));\n printf(\"%I64d\\n\",ans);\n }\n }\n\n return 0;\n }\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "04f17b54576632e37892d8af36b52f7c", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include \n\n#define forr(i, n) for(ll i = n-1; i >= 0; i--)\n#define forn(i, n) for(ll i = 0; i < n; i++)\n#define forab(i, a, n) for(ll i = a; i < n; i++)\n#define forabr(i, a, b) for(ll i = a; i >= b; i--)\n#define endl '\\n'\n#define s seconde\n#define f first\n#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define fale_io ifstream fin(\"input.txt\"); ofstream fout(\"output.txt\");\nusing namespace std;\n\nconst int Inf = INT_MAX;\nconst double PI = 3.1415926535;\n\ntypedef long long ll;\ntypedef string S;\n\nint n;\nll mx;\n/*\nint gcd (int a, int b) {\n\twhile (b) {\n\t\ta %= b;\n\t\tswap (a, b);\n\t}\n\treturn a;\n}\n\nll lcm(int a, int b, int c){\n int g = gcd(a, b);\n g = gcd(g, c);\n return (ll)a * b * c / g;\n}\n*/\n\nll f(int n){\n ll r = n;\n r *= n - 1;\n if(n % 2)\n r *= n - 2;\n else\n r *= n - 3;\n return r; \n}\n\nint main(){\n fast_io;\n cin >> n\n mx = n;\n if(n == 3)mx = 6;\n forab(i, max(3, n-5), n+1)mx = max(mx, f(i));\n cout << mx;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3cb9e7d0e905ee206d06dd734df2840b", "src_uid": "25e5afcdf246ee35c9cef2fcbdd4566e", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#define maxn 100\n#define maxm maxn\nusing namespace std;\nint hash[maxm],req[maxm];\nint N,M;\n\n\n\nint main()\n{\n\tscanf(\"%d%d\",&N,&M);\n\t\n\tint saber;\n\tfor (int i=1;i<=N;i++)\n\t{\n\t\tscanf(\"%d\",&saber);\n\t\thash[saber]++;\n\t}\n\tfor (int i=1;i<=M;i++)\n\t{\n\t\tscanf(\"%d\",&req[i]);\n\t\tif (req[i]>hash[i])\n\t\t{\n\t\t\tcout<<\"NO\";\n\t\t\treturn 0;\n\t\t}\n\t}\n\tcout<<\"YES\";\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "157ac6f8fac4ef17d24438208bb3b28d", "src_uid": "59f40d9f35e5fe402112214b42b682b5", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n\nint main()\n{\n ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);\n\n int n , m ;\n cin >> n >> m;\n int arr[n+1] = {};\n\n for(int i = 0 ;i < n ; i++)\n {\n cin >> arr[i];\n \n }\n\n int c[n+1] = {};\n for(int i = 0 ; i < n ; i++)\n {\n int cc = 1;\n for(int j = i+1 ; j < n ;j++)\n {\n if(arr[i] == arr[j])\n cc++;#include\nusing namespace std;\n\nint main()\n{\n ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);\n\n int n , m ;\n cin >> n >> m;\n int arr[n+1] = {};\n\n for(int i = 0 ;i < n ; i++)\n {\n int x;\n cin >> x;\n arr[x]++;\n }\n\n for(int i = 1 ; i <= m ; i++)\n {\n int x;\n cin >> x;\n\n if(arr[i] != x)\n return cout << \"NO\" , 0;\n }\n\n cout << \"YES\";\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4b91795cf1e07238b6d098bf7a84fd0a", "src_uid": "59f40d9f35e5fe402112214b42b682b5", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#include \"bits/stdc++.h\"\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n\n#define MAXN 100009\n#define INF 1000000007\n#define mp(x,y) make_pair(x,y)\n#define all(v) v.begin(),v.end()\n#define pb(x) push_back(x)\n#define wr cout<<\"----------------\"< PII;\n\ntemplatebool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}\ntemplatebool umax(T& a,T b){if(a l[i])\t\n\t\t\t\t\tok = 0;\n\t\t\tif(ok)\n\t\t\t\treturn puts(\"YES\") * 0;\n\t\t}\n\t}\n\tputs(\"NO\");\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "be0bc5341ce27f128d267c7887db7227", "src_uid": "59f40d9f35e5fe402112214b42b682b5", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#include \n#define ll long long int\n#define vi vector\n#define vvi vector>\n#define vll vector\n#define vs vector\n#define vc vector\n#define vb vector\n#define forn(i, s, n) for(int i=(int)s; i\n#define pii pair\n#define ull unsigned long long int\n#define F first\n#define S second\n#define PI 3.141592653589793238\n#define prec(n) fixed<, rb_tree_tag,tree_order_statistics_node_update>\n#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)\n#define itsval(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator _it(_ss); itval(_it, args); }\nusing namespace std;\n#include \n#include \nusing namespace __gnu_pbds;\n\nvoid itval(istream_iterator it) {}\ntemplate\nvoid itval(istream_iterator it, T a, Args... args) {\ncerr << *it << \" = \" << a << endl;\nitval(++it, args...);\n}\nconst ll MOD=1e9+7;\ntemplate \ninline void print(T x){cout<\ninline void printvec(T x){for(auto a:x) cout< &p1, const pair &p2)const{\n if(p1.F.F==p2.F.F)\n {\n if(p1.F.S==p2.F.S)\n {\n return p1.Sp2.F.S;\n }\n return p1.F.F>n>>m;\n vi v(n), c(m), check;\n for (int i = 0; i < n; ++i)\n {\n cin>>v[i];\n }\n forn(i,0,m){\n cin>>c[i];\n forn(j,0,c[i])\n check.pb(i+1);\n }\n forn(i,0,n-int(check.size())+1#include \n#define ll long long int\n#define vi vector\n#define vvi vector>\n#define vll vector\n#define vs vector\n#define vc vector\n#define vb vector\n#define forn(i, s, n) for(int i=(int)s; i\n#define pii pair\n#define ull unsigned long long int\n#define F first\n#define S second\n#define PI 3.141592653589793238\n#define prec(n) fixed<, rb_tree_tag,tree_order_statistics_node_update>\n#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)\n#define itsval(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator _it(_ss); itval(_it, args); }\nusing namespace std;\n#include \n#include \nusing namespace __gnu_pbds;\n\nvoid itval(istream_iterator it) {}\ntemplate\nvoid itval(istream_iterator it, T a, Args... args) {\ncerr << *it << \" = \" << a << endl;\nitval(++it, args...);\n}\nconst ll MOD=1e9+7;\ntemplate \ninline void print(T x){cout<\ninline void printvec(T x){for(auto a:x) cout< &p1, const pair &p2)const{\n if(p1.F.F==p2.F.F)\n {\n if(p1.F.S==p2.F.S)\n {\n return p1.Sp2.F.S;\n }\n return p1.F.F>n>>m;\n vi v(n), c(m), check;\n for (int i = 0; i < n; ++i)\n {\n cin>>v[i];\n }\n forn(i,0,m){\n cin>>c[i];\n forn(j,0,c[i])\n check.pb(i+1);\n }\n forn(i,0,n-int(check.size())+1)\n {\n int g=1;\n forn(j,i,i+int(check.size()))\n {\n if(v[j]!=check[j-i])\n {\n g=0;\n break;\n }\n }\n if(g)\n {\n print(\"YES\");return;\n }\n }\n print(\"NO\");\n\n\n}\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n int test=1;\n // cin>>test;\n clock_t z=clock();\n forn(tes, 0, test)\n {\n solve();\n }\n debug(\"Total Time:%.4f\\n\",(double)(clock()-z)/CLOCKS_PER_SEC);\n return 0;\n}\n\n {\n int g=1;\n forn(j,i,i+int(check.size()))\n {\n if(v[j]!=check[j-i])\n {\n g=0;\n break;\n }\n }\n if(g)\n {\n print(\"YES\");return;\n }\n }\n print(\"NO\");\n\n\n}\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n int test=1;\n // cin>>test;\n clock_t z=clock();\n forn(tes, 0, test)\n {\n solve();\n }\n debug(\"Total Time:%.4f\\n\",(double)(clock()-z)/CLOCKS_PER_SEC);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2cd725b1390467c88c0505bce2fbb6be", "src_uid": "59f40d9f35e5fe402112214b42b682b5", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n\nint main() {\n\tlong long n,k,A,B,a=0,b=0;\n\tcin>>n;\n\tcin>>k;\n\tcin>>A;\n\tcin>>B;\n\tint x=n;\n\twhile(x!=1)\n\t{\n\t if (A\n#include \nusing namespace std;\n\n\nint main()\n{\n long long long int n,k,a,b;\n cin>>n>>k>>a>>b;\n long long long int ans=0;\n \n if(k==1)\n {\n ans=min(a,b) * (n-1);\n }\n else\n while(n>1)\n {\n if(k<=n)\n {\n\n long long long int r=n%k;\n ans+=r*a;\n\n\nlong long long ans1=0,ans2=0;\n ans1=b;\n ans2=a*(n-n/k);\n n=n/k;\n ans+=min(ans1,ans2);\n }\n else{\n ans+=(n-1)*a;\n n=1;\n }\n\n\n }\n cout<\nusing namespace std;\nlong long n,k,A,B;\nlong long maxx,sum=0;\nlong long div,sub;\nint main()\n{\n\tcin>>n>>k>>A>>B;\n\tif(nB) sum+=B;\n\t\t\t\telse sum+=sub;\n\t\t\t\tn/=k;\t\t\t\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tdiv=n%k;\n\t\t\t\tsum+=div*A;\n\t\t\t\tn-=div;\n\t\t\t}\n\t\t}\n\t}\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \nusing namespace std;\n\ntypedef long long ll;\n\nvoid solve(){\n\tint n, k, a, b;\n\tcin >> n >> k >> a >> b;\n\tint dp[n+1];\n\tmemset(dp, 0, n);\n\tdp[n] = 0;\n\tfor (int i = n-1; i >= 1; i--){\n\t\tdp[i] = dp[i+1]+a;\n\t\tif (i * k < n) dp[i] = min(dp[i], dp[i*k]+b);\n\t}\n\tcout << dp[1] << endl;\n}\n\nint main(){\n int t = 1;\n\twhile (t--){\n\t\tsolve();\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8c4c69b24013770b692a85adf1c97ec2", "src_uid": "f838fae7c98bf51cfa0b9bd158650b10", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nconst ll mod = 998244353;\nll res[2001][2001];\n\nint main()\n{\n ll n,m,k;\n cin>>n>>m>>k;\n res[1][0] = m;\n for(ll i=2;i<=n;i++)\n for(ll j=0;j<=k;j++)\n (res[i][j] += res[i-1][j]) %= mod,\n (res[i][j+1] += (res[i-1][j] * (m-1) )) %=mod;\n cout<\nusing namespace std;\nlong long f[2005][2005];\nint n,m,k;\nint main()\n{\n\tscanf(\"%d%d%d\",&n,&m,&k);\n\tf[1][0]=m;\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tf[i][0]=m;\n\t\tfor(int j=1;j\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n// Kobe is the GOAT\n// DON'T DIVIDE\n// Greedy, Prefix, Sets/Bsearch, Dfs/bfs, DP\n// Stack, Bitmask, Dsu \nusing namespace std;\n\nint n, m, k;\nconst int MAXN = 2005, MOD = 998244353;\n\nlong long pow(long long a, long long b)\n{\n\tif(b == 0)\n\t\treturn 1;\n\tif(b % 2 == 0)\n\t\treturn pow((a * a) % MOD, b / 2);\n\treturn (a * pow((a * a) % MOD, b / 2)) % MOD; \n}\n\nlong long inv(long long x)\n{\n\treturn pow(x, MOD - 2);\n}\n\nlong long fact(long long x)\n{\n\tif(x == 0)\n\t\treturn 1;\n\treturn (x * fact(x - 1)) % MOD;\n}\n\nint main()\n{\n\tios::sync_with_stdio(0);\n\tcin >> n >> m >> k;\n\n\tlong long ans = (fact(n - 1) * inv((fact(k) * fact(n - 1 - k)) % MOD)) % MOD;\n\tans = (ans * m) % MOD;\n\tans = (ans * pow(m - 1, max(k - 1, 0))) % MOD; \n\n\tcout << ans << \"\\n\";\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1f00b942ed356e66f6a6566c648f87e2", "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b", "difficulty": 1500.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n// Kobe is the GOAT\n// DON'T DIVIDE\n// Greedy, Prefix, Sets/Bsearch, Dfs/bfs, DP\n// Stack, Bitmask, Dsu \nusing namespace std;\n\nint n, m, k;\nconst int MAXN = 2005, MOD = 998244353;\n\nlong long pow(long long a, long long b)\n{\n\tif(b == 0)\n\t\treturn 1;\n\tif(b % 2 == 0)\n\t\treturn pow((a * a) % MOD, b / 2);\n\treturn (a * pow((a * a) % MOD, b / 2)) % MOD; \n}\n\nlong long inv(long long x)\n{\n\treturn pow(x, MOD - 2);\n}\n\nlong long fact(long long x)\n{\n\tif(x == 0)\n\t\treturn 1;\n\treturn (x * fact(x - 1)) % MOD;\n}\n\nint main()\n{\n\tios::sync_with_stdio(0);\n\tcin >> n >> m >> k;\n\n\tlong long ans = (fact(n - 1) * inv((fact(k) * fact(n - 1 - k)) % MOD)) % MOD;\n\tans = (ans * m) % MOD;\n\tans = (ans * pow(m - 1, k)) % MOD; \n\n\tcout << ans << \"\\n\";\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d289084ac107363f975831bbf266cbc9", "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nlong long double n;\nlong long double f(int n)\n{ if (n==1)\nreturn 1;\nelse return f(n-1)*n;\n}\nint main()\n{ \n\ncin >> n;\nif (n==1)\ncout << 1;\nelse \ncout << f(n)+1;\n\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "68e86323abb69ad3cc65a1194e65bf4b", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "MS C++", "source_code": "#include \n\nusing namespace std;\n\nint main(void){\n int n;\n long long result = 1;\n cin >> n;\n for (int i = 0; i < n; i++){\n result += (n - i) * (i + 1) - 1\n }\n cout << n;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3f8eb6484312bafb22e244094a263931", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nint main()\n{\n int n,k=0;\n cin>>n;\n for(int i=1;i\n#include \nusing namespace std;\nvoid main()\n{\n\tint n;\n\tcin >> n;\n\tint p = pow(2, n);\n\tcout << p-1;\n\n\t\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cd5dc9b363d2bda33eab92284168be45", "src_uid": "6df251ac8bf27427a24bc23d64cb9884", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "/* Borrowed from I_love_hoang_jen because of lack in task description o_O\n * I love U too <3 \n * */\n#include\n#define MAX 200200\n#define FOR(i,a,b) for (int i=(a);i<=(b);i=i+1)\n#define FORD(i,b,a) for (int i=(b);i>=(a);i=i-1)\n#define REP(i,n) for (int i=0;i<(n);i=i+1)\n#define bit(x,i) ((x)&(1<<(i)))\nusing namespace std;\ntypedef long long ll;\nconst int INF=(int)1e9+7;\nint prime[MAX];\nint fls(ll x) {\n ll k=floor(sqrt(x));\n FOR(i,max(0LL,k-5),k+5) if (1LL*i*i>x) return (i-1);\n}\nint ces(ll x) {\n if (x<0) return (0);\n ll k=ceil(sqrt(x));\n FORD(i,k+5,max(0LL,k-5)) if (1LL*i*i &v) {\n assert(01) {\n if (prime[x]==0) {\n v.push_back(x);\n return;\n }\n int p=prime[x];\n assert(x%p==0);\n v.push_back(p);\n while (x%p==0) x=x/p;\n }\n}\nint countdiv(int x,int r) {\n if (r div;\n anal(x,div);\n int res=0;\n REP(i,1<r) return (0);\n return ((coprime(x,r)-coprime(x,l-1)+mod)%mod);\n}\nvoid process(void) {\n cin >> m >> n >> L >> R >> mod;\n int res=(L==1)?((1LL*(m+1)*n+1LL*(n+1)*m)%mod):0;\n //printf(\"PRE %d\\n\",res);\n FOR(i,1,m) if (i<=R) {\n int l=max(1,ces(1LL*L*L-1LL*i*i));\n int r=min(n,fls(1LL*R*R-1LL*i*i));\n //printf(\"LIM %d %d\\n\",l,r);\n res=(res+2LL*(m-i+1)*coprime(i,l,r)%mod)%mod;\n }\n cout << res;\n}\nint main(void) {\n#ifndef ONLINE_JUDGE\n freopen(\"tmp.txt\",\"r\",stdin);\n#endif\n eratosthene();\n process();\n return 0;\n}\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6c375853358702b0e1ce0fedb614f147", "src_uid": "2afe29a7dbbd2e261e1870a43d57b46f", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "//Bokan ga bokka--nn!!\n//Daily Lunch Special Tanoshii !!\n//\u3053\u308c\u306f\u3001\u982d\u304c\u60aa\u304f\u7af6\u30d7\u30ed\u304c\u4e16\u754c\u3067\u4e00\u756a\u3067\u304d\u306a\u3044HIR180\u304c\n//IOI2014\u65e5\u672c\u4ee3\u8868\u306b\u306a\u308b\u307e\u3067\u306eN\u65e5\u9593\u306e\u8a18\u9332\u3067\u3042\u308b\u3002\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef pair P;\ntypedef pair P1;\ntypedef pair P2;\ntypedef long long ll;\n#define pu push\n#define pb push_back\n#define mp make_pair\n#define eps 1e-7\n#define INF 1000000000\n#define fi first\n#define sc second\n#define rep(i,x) for(int i=0;idiv[150005];\nll n,m,l,r,mod;\nll calc(ll lb,ll ub,ll mul)\n{\n\tub=ub/mul; lb=(lb+mul-1)/mul;\n\tll sum=(ub-lb+1LL)*(m+1);\n\tsum-=(ub*(ub+1)-(lb-1)*lb)/2*mul;\n\tsum=(sum%mod+mod)%mod;\n\treturn sum;\n}\nint main()\n{\n\tsrand((unsigned int)time(NULL));\n\tscanf(\"%lld %lld %lld %lld %lld\",&n,&m,&l,&r,&mod);\n\tll lb=l,ub=r;\n\tfor(int i=2;i<=150000;i++)\n\t{\n\t\tif(!div[i].empty()) continue;\n\t\tfor(int j=i;j<=150000;j+=i)\n\t\t{\n\t\t\tdiv[j].pb(i);\n\t\t}\n\t}\n\tll ret=0LL;\n\tfor(ll i=1;i<=min(n,h);i++)\n\t{\n\t\twhile(lb>1 && l*l-i*i<=(lb-1)*(lb-1)) lb--;\n\t\twhile(r*r-w*w>k)&1))\n\t\t\t\t\t{\n\t\t\t\t\t\tmul*=div[i][k];\n\t\t\t\t\t\tflag*=(-1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tres+=flag*calc(lb,min(ub,m),mul);\n\t\t\t}\n\t\t\tret=(ret+res*(n-i+1))%mod;\n\t\t}\n\t}\n\tif(l<=1&&1<=r) ans=(ans*2LL+n*(m+1)+m*(n+1))%mod;\n\telse ans=(ans*2LL)%mod;\n\tcout << ans << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "768c8675155095c0e7dd90502ed28d78", "src_uid": "2afe29a7dbbd2e261e1870a43d57b46f", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "TEST", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a56de2fcf11109069371164050bbc217", "src_uid": "2afe29a7dbbd2e261e1870a43d57b46f", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "#include \n#define ll (long long)\nint fac[100100];\nint n,m,i,x,j,l,r,p,ans,st,dr,mn,mx,M;\n\n\nvoid init()\n{\n int i,j;\n for (i=2;i<=100000;i++)\n if (!fac[i])\n {\n fac[i]=i;\n if (i>316) continue;\n for (j=i*i;j<=100000;j+=i) if (!fac[j]) fac[j]=i;\n }\n}\n\nint solve(int x,int y)\n{\n int v[20]; int N;\n int i,j,lim,ind,nr,rez=0;\n\n if (y==0) return 0;\n\n v[0]=0; N=0;\n for (i=x;i>1;i/=fac[i])\n if (N==0 || v[N-1]!=fac[i]) v[N++]=fac[i];\n\n lim=1<= ll l*l)\n dr=m;\n else\n st=m+1;\n }\n mn=st;\n //maxim\n for (st=0,dr=100000;stM) mx=M;\n if (mn>mx) continue;\n\n\n ans=ll (ll ans+ solve(x,mx)-solve(x,mn-1) )%p;\n }\n\n ans=ll ans*2%p;\n if (l<=1) ans=ll (ll ans+ n*(ll M+1)+(ll n+1)*M )%p;\n\n printf(\"%d\",ans);\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d4580a9f81d5d3ec8784d118757bc967", "src_uid": "2afe29a7dbbd2e261e1870a43d57b46f", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#pragma comment (linker,\"/STACK:102400000,102400000\")\n#define maxn 205\n#define MAXN 1005\n#define mod 1000000009\n#define INF 0x3f3f3f3f\n#define pi acos(-1.0)\n#define eps 1e-6\ntypedef long long ll;\nusing namespace std;\n \nll n,m,k,ans,cnt,tot,flag;\nll cost[4][4],dp[45][4][4];\n \nll dfs(ll x,ll a,ll c)\n{\n if(x==0) return 0;\n if(dp[x][a][c]!=m) return dp[x][a][c];\n ll i,j,t,b,best=m;\n b=6-a-c;\n t=dfs(x-1,a,b)+cost[a][c]+dfs(x-1,b,c);\n best=min(best,t);\n t=2*dfs(x-1,a,c)+cost[a][b]+dfs(x-1,c,a)+cost[b][c];\n best=min(best,t);\n dp[x][a][c]=best;\n return best;\n}\nint main()\n{\n ll i,j,t;\n m=1LL<<60;\n for(i=1;i<=3;i++)\n {\n for(j=1;j<=3;j++)\n {\n scanf(\"%I64d\",&cost[i][j]);\n }\n }\n scanf(\"%I64d\",&n);\n for(i=1;i<=n;i++) for(j=1;j<=3;j++) for(int k=1;k<=3;k++) dp[i][j][k]=m;\n ans=dfs(n,1,3);\n printf(\"%I64d\\n\",ans);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cf575da49a07fa294d2276c0be1fd818", "src_uid": "c4c20228624365e39299d0a6e8fe7095", "difficulty": null} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#pragma comment (linker,\"/STACK:102400000,102400000\")\n#define maxn 205\n#define MAXN 1005\n#define mod 1000000009\n#define INF 0x3f3f3f3f\n#define pi acos(-1.0)\n#define eps 1e-6\ntypedef long long ll;\nusing namespace std;\n \nll n,m,k,ans,cnt,tot,flag;\nll cost[4][4],dp[45][4][4];\n \nll dfs(ll x,ll a,ll c)\n{\n if(x==0) return 0;\n if(dp[x][a][c]!=m) return dp[x][a][c];\n ll i,j,t,b,best=m;\n b=6-a-c;\n t=dfs(x-1,a,b)+cost[a][c]+dfs(x-1,b,c);\n best=min(best,t);\n t=2*dfs(x-1,a,c)+cost[a][b]+dfs(x-1,c,a)+cost[b][c];\n best=min(best,t);\n dp[x][a][c]=best;\n return best;\n}\nint main()\n{\n ll i,j,t;\n m=1LL<<60;\n for(i=1;i<=3;i++)\n {\n for(j=1;j<=3;j++)\n {\n scanf(\"%I64d\",&cost[i][j]);\n }\n }\n scanf(\"%I64d\",&n);\n for(i=1;i<=n;i++) for(j=1;j<=3;j++) for(int k=1;k<=3;k++) dp[i][j][k]=m;\n ans=dfs(n,1,3);\n printf(\"%I64d\\n\",ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a44677d0caf921d904d4776893d71d93", "src_uid": "c4c20228624365e39299d0a6e8fe7095", "difficulty": null} {"lang": "GNU C++", "source_code": "#include \n#include \n\nusing namespace std ;\n\n#define abs(a) (a)>0?(a):-(a)\n#define USING_MATH_DEFINES\n#define mp make_pair\n#define FI first\n#define SE second\n#define FOR0(i,n) for(i=0;i\n#include\nint cost[4][4]\n__int64 dp[45][4][4][4];\n__int64 hanoi(int n,int a,int b,int c)\n{\n if(dp[n][a][b][c]!=-1)return dp[n][a][b][c];\n __int64 tmp1,tmp2;\n tmp1=hanoi(n-1,a,c,b)+cost[a][c]+hanoi(n-1,b,a,c);\n tmp2=hanoi(n-1,a,b,c)+cost[a][b]+hanoi(n-1,c,b,a)+cost[b][c]+hanoi(n-1,a,b,c);\n return dp[n][a][b][c]=tmp1>tmp2?tmp2:tmp1;\n}\nint main()\n{\n int i,j,n;\n memset(dp,-1,sizeof(dp));\n memset(dp[0],0,sizeof(dp[0]));\n for(i=0;i<3;i++)\n {\n for(j=0;j<3;j++)\n {\n scanf(\"%d\",&cost[i][j]);\n }\n }\n scanf(\"%d\",&n);\n printf(\"%I64d\\n\",hanoi(n,0,1,2));\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2628f9155308411e7ba201b198471188", "src_uid": "c4c20228624365e39299d0a6e8fe7095", "difficulty": null} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\n#include\n\n#define pb push_back\n#define mp make_pair\n#define x first\n#define y second\n\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pii;\ntypedef pair pld;\n\n\nint main(){\n //freopen(\"in.txt\",\"r\",stdin);\n //freopen(\"output.txt\",\"w\",stdout);\n //scanf(\"%ld%ld\",&a,&b);\n //ifstream cin(\"in.txt\");\nstring s;\nint n, k, f[26], l[26];\nvector mm;\n\ncin>>n>>k;\ncin>>s;\n\n\nfor(int i = 0; i < 26; i++) f[i] = -1;\nfor(int i = 0; i < 26; i++) l[i] = 1000000;\nfor(int i = 0; i < s.length(); i++) {\n if(f[s[i] - 'A'] == -1) f[s[i] - 'A'] = i;\n l[s[i] - 'A'] = i;\n }\n\nfor(int i = 0; i < 26; i++) if(f[i] > -1){//cout< k) cout<<\"YES\"; else cout<<\"NO\";\n //cout<\n#include \n#include \n#include \nusing namespace std;\npair time[30];\nint characters[30];\nint main(){\n\tint n, k;\n\tcin >> n >> k;\n\tstring s;\n\tcin >> s;\n\tbool done = true;\n\tbool entered = false;\n\tbool enteredhere = false;\n\tbool enteredhere1 = false;\n\tbool enteredhere2 = false;\n\tbool enter = false;\n\tint counter = k;\n\tmemset(time, -1, sizeof(time));\n\tmemset(characters, -1, sizeof(characters));\n\tfor (int i = 0; i < s.length(); i++){\n\t\tif (time[s[i] - 65].first == -1){\n\t\t\ttime[s[i] - 65].first = i;\n\t\t}\n\t\ttime[s[i] - 65].second = i;\n\t}\n\tfor (int i = 0; i < s.length(); i++){\n\t\tentered = false;\n\t\tenteredhere = false;\n\t\t enteredhere1 = false;\n\t\tenteredhere2 = false;\n\t\t enter = false;\n\t\tif (time[s[i] - 65].first == i && time[s[i] - 65].second == i && counter>0){\n\t\t\tentered = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (time[s[i] - 65].first == i && time[s[i] - 65].second == i && counter == 0){\n\t\t\tenter = true;\n\t\t\tfor (int j = 0; j <= 26; j++){\n\t\t\t\tif (time[j].first != -1){\n\t\t\t\t\tif (characters[j] == 1 && ((time[j].first > i && time[j].second > i) || (time[j].first < i && time[j].second < i))){\n\t\t\t\t\t\tenteredhere2 = true;\n\t\t\t\t\t\tcharacters[j] = 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t}\n\t\tif (enter && !enteredhere2){\n\t\t\tdone = false;\n\t\t\tbreak;\n\t\t}\n\t\tif (time[s[i] - 65].second == i && !entered && !enter){\n\t\t\tcounter++;\n\t\t\tcharacters[s[i] - 65] = 0;\n\t\t}\n\t\tif (time[s[i] - 65].first == i && counter > 0){\n\t\t\tcharacters[s[i] - 65] = 1;\n\t\t\tcounter--;\n\t\t\tcontinue;\n\t\t}\n\t\telse if (time[s[i] - 65].first == i && counter == 0) {\n\t\t\tfor (int j = 0; j <= 26; j++){\n\t\t\t\tif (time[j].first != -1){\n\t\t\t\t\tif (((time[j].first > i && time[j].second > i) || (time[j].firsti && time[j].second>i) || (time[j].first < i && time[j].second < i)){\n\t\t\t\t\t\t\tcharacters[s[i] - 65] = 1;\n\t\t\t\t\t\t\tcharacters[j] = 0;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\telse if (characters[j] == 0){\n\t\t\t\t\t\t\tcharacters[s[i] - 65] = 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcounter--;\n\t\t\t\t\t\tenteredhere1 = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!enteredhere1){\n\t\t\t\tdone = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tif (done){\n\t\tcout << \"NO\" << endl;\n\t}\n\telse {\n\t\tcout << \"YES\" << endl;\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ba6a84817b5e17f36bb76a5ffdf21b40", "src_uid": "216323563f5b2dd63edc30cb9b4849a5", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\nint n, k;\nstring entrada;\nbool estado[26];\nint open [1000001];\n\nint main(){\n cin >> n >> k;\n cin >> entrada;\n \n for(int i =0; i<26; i++){\n bool[i]=0;\n }\n \n for(int i = 0; i< n; i++){\n if (bool[entrada[i]-'A']==0){\n bool[entrada[i]-'A']=1;\n open[i]++;\n }\n }\n for(int i = n ; i>0; i++){\n if(bool[entrada[i-1]-'A']==1){\n bool[entrada[i-1]-'A']=0;\n open[i]--;\n }\n }\n for(int i =1,; ik){\n cout << \"YES\";\n return 0;\n } \n }\n \n cout << \"NO\";\n \nreturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ea59f39c8882a118491d41a81d600a38", "src_uid": "216323563f5b2dd63edc30cb9b4849a5", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n int x,y;\n string s;\n cin>>x>>y>>s;\n vector>v(30);\n for(int i=0;i1){\n arr[v[i][0]]++;\n arr[v[i][1]]--;\n }\n else if(v[i].size()==1){\n arr[v[i][0]]++;\n arr[v[i][0]+1]--;\n }\n }\n int mx=-1;\n for(int i=1;iy){\n cout<<\"YES\";\n }\n else {\n cout<<\"NO\";\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "02874d47de4594bc4f8478c7efa957c5", "src_uid": "216323563f5b2dd63edc30cb9b4849a5", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int a, b, div, rem;\n cin >> a >> b;\n int sum = a;\n while(a >= b)\n {\n div = a / b;\n sum += div;\n modrem = a % b;\n a = div + rem;\n }\n cout << sum << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d8bde8dbc3edd04036fe18c9f4eb8c0f", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int a,b;\n cin >>a>>b;\n int counter =a;\n int g =0;\n while (a>=b&&a!=148)\n {\n counter=counter +a/b;\n a=a/b;\n else counter =153;\n }\n cout<\n#include \nusing namespace std;\nint a;\nint main()\n{\nint a,b,c,k=0,i,ch,h=0,dar,gak;\n cin>>a>>b;\n\n h=a; \n ch=a;\n dar=a%b; \n gak=a/b;\n ch+=a/b;\n if(gak+dar>=b) ch+=(gak+dar)/b;\n if((gak+dar)/b>=b) ch+=((gak+dar)/b)/b;\n fi(((gak+dar)/b)/b>=b) ch+=((gak+dar)/b)/b)/b;\n cout<\nusing namespace std ;\nint main () {\n int a , b , n ;\n cin >> a >> b ;\n if ( b % 2 == 0 && a % 2 == 0) {\n n = a + (a/b) + ( (a/b) - 1 );\n }\n else if ( a % 2 == 0 && b != 0) {\n n = a + (a / b ) ;\n }\n else if ( a % 2 != 0 && b % 2 == 0 ) {\n n = a \n }\n if ( b % 2 != 0 && a % 2 != 0) {\n n = a + (a / b ) + (a % b) + 3 ; \n \n }\n cout << n ;\n return 0 ; \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6cfb06a767c1167e707e88c580ae00aa", "src_uid": "a349094584d3fdc6b61e39bffe96dece", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nstruct Mat {\n\tstatic long long MOD;\n\tlong long a[2][2];\n};\nconst Mat FIB = {{{1, 1}, {1, 0}}};\nconst Mat SUM = {{{3, -1}, {0, 1}}};\nlong long Mat::MOD;\n\nMat operator*(const Mat& lhs, const Mat& rhs) {\n\tMat ret;\n\tfor (int i = 0; i < 2; ++i) {\n\t\tfor (int j = 0; j < 2; ++j) {\n\t\t\tret.a[i][j] = 0;\n\t\t\tfor (int k = 0; k < 2; ++k) {\n\t\t\t\tret.a[i][j] += lhs.a[i][k] * rhs.a[k][j];\n\t\t\t}\n\t\t\tret.a[i][j] %= Mat::MOD;\n\t\t}\n\t}\n\treturn ret;\n}\n\nMat pow(Mat a, long long b) {\n\tMat ret;\n\tret.a[0][0] = ret.a[1][1] = 1;\n\tret.a[0][1] = ret.a[1][0] = 0;\n\twhile (b > 0) {\n\t\tif (b & 1) {\n\t\t\tret = ret * a;\n\t\t}\n\t\tb >>= 1;\n\t\ta = a * a;\n\t}\n\treturn ret;\n}\n\nconst int MAXN = 1 << 20;\nconst double PHI = (sqrt(5.0) + 1) / 2;\n\ndouble f[65];\nlong long a[MAXN];\n\nvoid init() {\n\tdouble a = 0, b = 1, c;\n\tfor (int i = 0; i < 64; ++i) {\n\t\tf[i] = a / b;\n\t\tc = a + b;\n\t\ta = b;\n\t\tb = c;\n\t}\n\tf[64] = PHI;\n}\n\nint main() {\n\tint n;\n\tMat prod;\n\tdouble cur, tmp;\n\tlong long x, y, l, r, u, v;\n\n\tinit();\n//\tcin >> n >> x >> y >> Mat::MOD;\n\tscanf(\"%I64d%I64d%I64d%I64d\", &n, &x, &y, &Mat::MOD);\n\tfor (int i = 0; i < n; ++i) {\n//\t\tcin >> a[i];\n\t\tscanf(\"%I64d\", &a[i]);\n\t}\n\n\tl = *min_element(a, a + n);\n\tr = -1;\n\tcur = -1;\n\tprod = pow(FIB, x);\n\tfor (int i = 1; i < n; ++i) {\n\t\tu = a[i - 1];\n\t\tv = a[i];\n\t\tif (u > v) {\n\t\t\tswap(u, v);\n\t\t}\n\t\ttmp = u * f[min(64LL, x)] + v;\n\t\tif (cur < tmp) {\n\t\t\tcur = tmp;\n\t\t\tr = (prod.a[0][0] * v + prod.a[0][1] * u) % Mat::MOD;\n\t\t}\n\t}\n\n\tu = accumulate(a, a + n, 0LL) % Mat::MOD;\n\tv = a[0] + a[n - 1];\n\tprod = pow(SUM, x);\n\tu = (prod.a[0][0] * u + prod.a[0][1] * v) % Mat::MOD;\n\tv = l + r;\n\tprod = pow(SUM, y);\n\tu = (prod.a[0][0] * u + prod.a[0][1] * v) % Mat::MOD;\n//\tcout << (u + Mat::MOD) % Mat::MOD << endl;\n\tprintf(\"%I64d\\n\", (u + Mat::MOD) % Mat::MOD);\n\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a7bb6d6d33c22237d325f31875c9ab87", "src_uid": "b5dd2b94570973b3e312ae4b7a43284f", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair Pair;\n\nconst int maxN= 1000*1000 + 5; \n\nint n,mod;\nint a[maxN];\nll x,y;\n\ninline ll calPow (ll v){\n ll ret=1, pw=3;\n while (v){\n if (v&1)\n ret= (ret*pw)%mod;\n vE/=2; pw= (pw*pw)%mod;\n }\n\n return ret%mod;\n}\n/********************************/\ninline Pair fib (ll v){\n\n ll mat[2][2]= {{1,1}, {1,0}};\n ll ret[2][2]= {{1,0}, {0,1}}; \n\n while (v){\n ll tmp[2][2];\n\n if (v&1){\n for (int i=0;i<2;i++)\n for (int j=0;j<2;j++)\n tmp[i][j]= ret[i][j];\n\n for (int i=0;i<2;i++)\n for (int j=0;j<2;j++)\n ret[i][j]= tmp[i][0]*mat[0][j] + tmp[i][1]*mat[1][j];\n\n for (int i=0;i<2;i++)\n for (int j=0;j<2;j++)\n ret[i][j]%=mod;\n }\n\n for (int i=0;i<2;i++)\n for (int j=0;j<2;j++)\n tmp[i][j]= mat[i][j];\n\n for (int i=0;i<2;i++)\n for (int j=0;j<2;j++)\n mat[i][j] = tmp[i][0]*tmp[0][j] + tmp[i][1]*tmp[1][j];\n\n for (int i=0;i<2;i++)\n for (int j=0;j<2;j++)\n mat[i][j]%=mod;\n v/=2;\n }\n\n return make_pair(ret[0][1]%mod, ret[0][0]%mod);\n}\n/********************************/\ninline ll get3 (int v){\n if (v==0) \n return 1;\n\n if (v&1){\n ll tmp= get3(v-1);\n return (3*tmp-1)%mod;\n }\n\n ll tmp= get3(v/2);\n return (2*tmp*(tmp-1)+1)%mod;\n}\n/********************************/\nint main(){\n scanf (\"%d %I64d %I64d %d\", &n, &x, &y, &mod);\n \n ll sum=0;\n for (int i=1;i<=n;i++){\n scanf (\"%d\", &a[i]);\n sum+= a[i];\n }\n sum%=mod;\n\n if (n==1){\n printf (\"%d\\n\", a[1]%mod);\n return 0;\n }\n\n ll powx = calPow(x), powy= calPow(y);\n Pair FIB= fib(x);\n\n ll maxi = (FIB.first*a[n-1] + FIB.second*a[n])%mod; \n\n ll res1= (((sum -a[1]-a[n])*powx) + ((a[1]+a[n])*get3(x)))%mod;\n ll res2= (((res1-a[1]-maxi)*powy) + ((a[1]+maxi)*get3(y)))%mod;\n\n printf (\"%I64d\\n\", (res2+mod)%mod);\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "22df3003806aa5f51c41bc44d17b9456", "src_uid": "b5dd2b94570973b3e312ae4b7a43284f", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define REP(i,n) for(int i=0, _n=(n); i<_n; i++)\n#define REPD(i,n) for(int i=n-1; i>=0; i--)\n#define FOR(i,a,b) for(int i=a,_b=(b); i<=_b; i++)\n#define FORD(i,a,b) for(int i=a,_b=(b); i>=_b; i--)\n#define FILL(x, v) memset(&x,v,sizeof(x))\n#define DB(vari) cout<<#vari<<\" = \"< pii;\ntypedef long long LL;\n\nconst int maxn = 1000000;\nconst int maxk = 100000;\n\nLL n, p; LL x, y;\nLL a[maxn];\n\nLL mul(LL a, LL b)\n{\n\treturn (a * b) % p;\n}\n\nstruct matrix\n{\n\tLL v[2][2];\n\tmatrix(LL a = 0, LL b = 0, LL c = 0, LL d = 0)\n\t{\n\t\tv[0][0] = a;\n\t\tv[0][1] = b;\n\t\tv[1][0] = c;\n\t\tv[1][1] = d;\n\t}\n\tmatrix operator * (matrix t)\n\t{\n\t\tmatrix res;\n\t\tREP(i, 2)\n\t\t\tREP(j, 2)\n\t\t\t\tREP(k, 2)\n\t\t\t\t\tres.v[i][j] = (res.v[i][j] + mul(v[i][k], t.v[k][j])) % p;\n\t\treturn res;\n\t}\n\tvoid print()\n\t{\n\t\tprintf(\"|%d %d|\\n|%d %d|\\n\", v[0][0], v[0][1], v[1][0], v[1][1]);\n\t}\n};\n\nvoid Pow(matrix &m, LL b)\n{\n\tmatrix t = m;\n\tm = matrix(1, 0, 0, 1);\n\twhile (b)\n\t{\n\t\tif (b & 1)\n\t\t\tm = m*t;\n\t\tt = t*t;\n\t\tb >>= 1;\n\t}\n}\n\n\nLL sum;\n\nint main()\n{\n\t//freopen(\"input.txt\",\"r\", stdin); freopen(\"output.txt\",\"w\", stdout);\n\tcin >> n >> x >> y >> p;\n\tREP(i, n)\n\t{\n\t\tscanf(\"%I64d\", &a[i]);\n\t\tsum = (sum + a[i]) % p;\n\t}\n\tmatrix m(3, -1, 0, 1);\n\tPow(m, x);\n\tsum = (mul(m.v[0][0], sum) + mul(m.v[0][1], (a[0] + a[n-1])%p)) % p;\n\tm = matrix(1, 1, 1, 0);\n\tPow(m, x);\n\ta[n-1] = (mul(a[n-1], m.v[0][0]) + mul(a[n-2], m.v[0][1])) % p;\n\tm = matrix(3, -1, 0, 1);\n\tPow(m, y);\n\tsum = (mul(m.v[0][0], sum) + mul(m.v[0][1], (a[0] + a[n-1])%p)) % p;\n\tprintf(\"%I64d\\n\", (sum+mod)%mod);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "79305e57648f4b9668f612db4a536cc9", "src_uid": "b5dd2b94570973b3e312ae4b7a43284f", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n//#define mod 998244353\n#define oo 1000000000\n#define int long long\nconst int N = 1000010;\nint mod , n;\nlong long x , y ;\nint arr[N];\nint fres = 1;\n\nvector< vector< int > > mat;\n\nvector< vector< int > > mul(vector< vector< int > > &a,vector< vector< int > > &b){\n\tvector< vector< int > > res((int)a.size(),vector ((int)a.size(),0));\n\tfor(int i=0;i<(int)a.size();i++){\n\t\tfor(int j=0;j<(int)a.size();j++){\n\t\t\tfor(int k=0;k<(int)a.size();k++){\n\t\t\t\tres[i][j] += (long long)a[i][k] * b[k][j] % mod;\n\t\t\t\tres[i][j] %= mod;\n\t\t\t}\n\t\t}\n\t}\n\treturn res;\n}\n\n\nvector< vector< int > > matpower(vector< vector< int> > &mat,long long po){\n\tif(po == 1)\n\t\treturn mat;\n\tvector< vector< int > > res = matpower(mat, po / 2);\n\tres = mul(res,res);\n\tif(po & 1)\n\t\tres = mul(res , mat);\n\treturn res;\n}\n\nint fastpower(int num,long long po){\n\tfres = 1;\n\tnum %= mod;\n\twhile(po > 0){\n\t\tif(po & 1)\n\t\t\tfres = (long long)fres * num % mod;\n\t\tpo >>= 1;\n\t\tnum = (long long)num * num % mod;\n\t}\n\treturn fres;\n}\n\nint getsum(int tmp,long long po){\n\tif(po == 0){\n\t\treturn 0;\n\t}\n\tint cur = getsum(tmp , po / 2);\n\tint cur2 = (long long)fastpower(tmp , po / 2) * cur % mod;\n\tcur += cur2;\n\tcur %= mod;\n\tif(po & 1){\n\t\tcur += fastpower(tmp , po);\n\t\tcur %= mod;\n\t}\n\treturn cur;\n}\n\nint get(int sum,long long x,int k){\n\tsum %= mod;\n\tk %= mod;\n\tif(x == 0)\n\t\treturn sum;\n\tint res = fastpower(3 , x);\n\tres = (long long)res * sum % mod;\n\tint res2 = (getsum(3 , x - 1) + 1) % mod;\n\tres2 = (long long)res2 * k % mod;\n\tres -= res2;\n\tres %= mod;\n\tres += mod;\n\tres %= mod;\n\treturn res;\n}\n\n\nint main(){\n\tint sum = 0;\n\tcin >> n >> x >> y >> mod;\n\tfor(int i=0;i(2,1));\n\tmat[1][1] = 0;\n\tvector< vector< int> > fib = matpower(mat,x + 1);\n\tint best = (long long)arr[n - 1] * fib[0][1] % mod;\n\tbest += (long long)fib[1][1] * arr[n - 2] % mod;\n\tbest %= mod;\n\tres = get(res , y , (arr[0] + best) % mod);\n\tcout << res << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "245b0d1222aa751af0ef0f8adf600d57", "src_uid": "b5dd2b94570973b3e312ae4b7a43284f", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define ll long long\n#define f first\n#define s second\n#define ull unsigned long long\n#define mp make_pair\n#define pb push_back\n#define ld long double\n\nconst ll MXN = 1e6 + 1;\nconst ll INF = 1e9 + 7;\nconst ll MOD = 1e2;\nconst double EPS = 1e-9;\n\nll n, m;\n\nint main()\n{\n cin >> n;\n cout << ((n * n) * 4) + (n * 4)\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "276fe9b67273d2a02cdc3e458c5bb2dd", "src_uid": "92db14325cd8aee06b502c12d2e3dd81", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define mod 1000000007\n#define int long long\n#define pii pair\n#define mii map\n#define uii unordered_map\n#define si set\n#define usi set\n#define pb push_back\n#define mp make_pair\nint n_c_r(int n,r){\n\tint p=1;\n\tint k=1;\n\twhile(r>0){\n\t\tp*=n;\n\t\tk*=r;\n\t\tint x = __gcd(p,k);\n\t\tp/=x;\n\t\tk/=x;\n\t\tn--;\n\t\tr--;\n\t}\n\treturn p;\n}\nint32_t main(){\n\tint n;\n\tcin >> n;\n\tint ans = n_c_r(n,5);\n\tans = ans * n * (n-1) * (n-2) * (n-3) * (n-4);\n\tcout << ans << \"\\n\";\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "51a4bd69d90924effb3c3f65d2e56931", "src_uid": "92db14325cd8aee06b502c12d2e3dd81", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n long long a,res;\n \n cin>>a;\n \n res=(n*(n-1)*(n-2)*(n-3)*(n-4))/120*(n*(n-1)*(n-2)*(n-3)*(n-4));\n \n cout<\nint main(){\n int n;\n std::cin>>n;\n cout<<(n*(n-1)*(n-2)*(n-3)*(n-4)/120)*n*(n-1)*(n-2)*(n-3)*(n-4)\n return 0 ;\n \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f8e9e47c57919c7d1389145f289b43a9", "src_uid": "92db14325cd8aee06b502c12d2e3dd81", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n int i,l,n,k;\n while(cin>>n)\n {\n if(n%2==0)\n {\n cout<<100<<\" \"<<4<\n\nusing namespace std;\n\nint A;\n\nint main()\n{\n\tcin >> A;\n\n\tif (A==1)\n\t{\n\t\tcout << A << \" \" << A << endl << A;\n\t}\n\telse\n\t{\n\t\tcout << (A-1)*2 << \" \" << << 2 << endl << 1 << \" \" << << 2;\n\t}\n\n\tgetchar();getchar();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "03fd6a7a15060aad4e7df1265f4d4c41", "src_uid": "5c000b4c82a8ecef764f53fda8cee541", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nint main(){\n int n;\n cin>>n;\n cout<<(n==1)?1:(n-1)*2<<\" \"<<2<<\"\\n\"<<1<<\" \"<<2<\n#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define ll long long int\n#define pb push_back\n#define mp make_pair\n#define f(i,x,n) for(ll i=x;i=x;i--)\n#define mod (ll)1e9+7\n#define print(x) cout<\n#define pai pair\n#define itr(it) :: iterator it\n#define MAX (ll)1e16\n#define MIN (ll)-1e16\n#define X first\n#define Y second\n#define up upper_bound\n#define lo lower_bound\nusing namespace std;\n /////////// /// /// /// /// //////////// /// ///\n /// /// /// /// /// /// /// /// ///\n /// /// /// /// /// /// /// /// ///\n /////////// /////////// /// /// //////////// ////////////\n /// /// /// /// /// /// /// /// ///\n /// /// /// /// /// /// /// /// ///\n /////////// /// /// //////////// //////////// /// ///\nll minn( ll a , ll b) \n{\n if(a>b)\n return b;\n return a;\n}\nll maxx2( ll a , ll b)\n{\n if(a>b)\n return a;\n return b;\n}\nll maxx(ll a,ll b,ll c)\n{\n return maxx2(a,maxx2(b,c));\n}\nll gcdd(ll a, ll b)\n{\n if(b==0)\n return a;\n else\n return gcdd(b,a%b);\n}\nll dsum(ll n)\n{\n ll sum=0;\n while(n>0)\n {\n sum+=n%10;\n n/=10;\n }\n return sum;\n}\nll poww(ll a,ll b)\n{\n if(b<=0)\n return 1;\n if(b==1)\n return a;\n else\n return poww(a,b/2)*poww(a,b/2)*poww(a,b%2);\n}\nstring substr1(string s, ll i,ll j)\n{\n string r = s.substr(i,j-i+1);\n return r;\n}\nll sumsq(ll x,ll y,ll z)\n{\n return (x-y)*(x-y)+(y-z)*(y-z)+(z-x)*(z-x);\n}\nvector v[200001],c[200001];\nll visited[200001]={0};\nlong double ans=0;\nvoid dfs(ll a,ll i)\n{\n visited[i]=1;\n if(v[i].size()==1 && i!=1)\n {\n ans=ans+a;\n return;\n }\n a++;\n f(i,0,v[i].size())\n {\n if(visited[v[i][j]]==0)\n dfs(a,v[i][j]);\n }\n}\nsigned main() {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n IOS;\n ll n;\n cin>>n;\n cout<<2*n-1<<\" \"<<2<> a >> b;\n if (a == 1){ cout << b; return 0; }\n if (b == 1){ cout << a; return 0; }\n //if (b == 2){ cout << 2 * (2 * (a / 2) + MN(a % 4, 2)); return 0; }\n if (b == 2){ cout << a + 1; return 0; }\n cout << a*b - (a*b) / 2;\n }", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4f03eee1c2d34624558392758678143a", "src_uid": "e858e7f22d91aaadd7a48a174d7b2dc9", "difficulty": 1800.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n long long n,m;\n cin>>n>>m;\n if(n>m) swap(n,m);\n if(n==1) cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint main ()\n{\n int n, m;\n cin >> n >> m;\n cout << (n * m) / 2) + ((n * m) % 2) << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3f0f2a683151ff521ffb3367de8aedd1", "src_uid": "e858e7f22d91aaadd7a48a174d7b2dc9", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n\nll ceil(ll a, ll b){\n return a/b + (a%b!=0);\n}\n\nint main(){\n ll n,m;\n cin>>n>>m;\n cout<\nusing namespace std;\nint main () {\n int i, n, a, b, s, l;\n cin>>n>>a>>b;\n s=a+b;\n l=b+n;\n if (b>0)\n {\n if (s<=n)\n cout<n)\n {\n s=s-n;\n i--;\n \n }\n cout<a)&&(a!=0)&&(b+a!n); i++)\n {\n a--;\n b++;\n \n }\n while (-b>n)\n {\n if (-b%n==0)\n l=n;\n \n else\n {\n a=n;\n for(int i=0; (-b>a)&&(b+a!=n)&&(a!=0); i++)\n {\n a--;\n b++;\n }\n }\n i++;\n }\n l=b+n;\n }\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint main(){\n\tint n,a,b;\n\tcin>>n>>a>>b;\n\tint cntr=0;\n\tif(b==0){\n\t\ta+=0;\n\t}\n\telse if(b>0 && a+b<=n){\n\t\ta+=b;\n\t}\n\telse if(b>0 && a+b>n){\n\t\tcntr+=b;\n\t\tcntr%=n;\n\t\ta+=cntr;\n\t}\n\telse if(b<0 && a-abs(b)>0){\n\t\tn-=(abs(b)-a);\n\t\ta=n;\n\t}\n\telse if(b<0 && a-abs(b)<=0){\n\t\tabs(b)%=n;\n\t\tn-=(abs(b)-a);\n\t\ta=n;\n\t}\n\tif(a==0){\n\t\tcout<\n\nusing namespace std;\n\nint n, m, l, r, cnt, sum, ans;\n\n\nint main ()\n{\n cin >> n >> l >> r;\n r%=n;\n if (r < 0){\n if (l >= abs (r)) l -= abs(r);\n else \n {\n l += n;\n l -= abs(r);\n \n }\n }\n else{\n l += b;\n l %= n;\n }\n if (l == 0) l = n;\n cout << abs (l);\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e39b8c36fbfd304d9e7a4c2e2e66bc3f", "src_uid": "cd0e90042a6aca647465f1d51e6dffc4", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include\n\n#define mp make_pair\n#define pb push_back\n#define f first\n#define s second \n#define sz(s) (int)s.size()\n#define all(s) s.begin(), s.end()\n#define forn(i, x, y) for(int i = x; i <= y; i++)\n#define forev(i, y, x) for(int i = y; i >= x; i--)\n\nusing namespace std;\n\nconst int maxn = (int)1e5 + 100;\nconst int mod = (int)1e9 + 7;\nconst int P = (int)1e6 + 7;\nconst int inf = mod;\n\ntypedef pair pii;\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vpii;\ntypedef long double ld;\n\nint n, k, a[maxn], suf[maxn], pref[maxn];\nint dp[maxn], fdp[maxn];\nstruct line{\n ll k, b;\n line(ll _k, ll _b){\n k = _k, b = _b;\n }\n ll val(ll x){\n return k * 1ll * x + b;\n }\n};\nld intersect(line l1, line l2){\n return (ld)(l2.b - l1.b) / (l1.k - l2.k);\n}\nbool bad(line l1, line l2, line l3){\n ld q1 = intersect(l1, l2);\n ld q2 = intersect(l1, l3);\n return q1 >= q2;\n}\nvector v;\ninline void add(line l){\n while(sz(v) > 1 && bad(v[sz(v) - 2], v[sz(v) - 1], l))\n v.pop_back();\n v.pb(l);\n}\nll get(ll x){\n if(!sz(v)) return inf;\n int l = 0, res = 0, r = sz(v) - 1;\n while(l < r){\n int mid = (l + r) >> 1;\n if(v[mid].val(x) > v[mid + 1].val(x)){\n l = mid + 1;\n }else{\n r = mid;\n }\n }\n return v[r].val(x);\n}\nvoid solve(int l, int r){\n if(l == r) return;\n int mid = (l + r) >> 1;\n solve(l, mid);\n solve(mid + 1, r);\n suf[mid] = a[mid];\n forev(i, mid - 1, l)\n suf[i] = max(suf[i + 1], a[i]);\n pref[mid + 1] = a[mid + 1];\n forn(i, mid + 2, r)\n pref[i] = max(pref[i - 1], a[i]);\n v.clear();\n suf[mid + 1] = pref[mid] = 0;\n int ptr = l;\n forev(i, r, mid + 1){\n while(ptr <= mid && suf[ptr + 1] >= pref[i]){\n if(dp[ptr] != inf)\n add(line(suf[ptr + 1], dp[ptr] - ptr * suf[ptr + 1]));\n ptr++;\n }\n fdp[i] = min(fdp[i], get(i));\n }\n v.clear();\n ptr = mid;\n forn(i, mid + 1, r){\n while(ptr >= l && suf[ptr + 1] <= pref[i]){\n if(dp[ptr] != inf)\n add(line(ptr, dp[ptr]));\n ptr--;\n }\n fdp[i] = min(fdp[i], get(-pref[i]) + i * pref[i]);\n }\n}\nint main () { \n scanf(\"%d%d\", &n, &k);\n forn(i, 1, n) scanf(\"%d\" &a[i]);\n int mx = 0;\n forn(i, 1, n){\n mx = max(mx, a[i]);\n dp[i] = mx * i;\n }\n forn(step, 1, k - 1){\n forn(i, 1, n) fdp[i] = inf;\n solve(1, n);\n forn(i, 1, n) dp[i] = fdp[i];\n } \n printf(\"%d\", dp[n]);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "08339e4923030f6458b2f3dbe2d26e3a", "src_uid": "f42faaaa88628748a8da49111936be00", "difficulty": 3000.0} {"lang": "GNU C++14", "source_code": "#include \n#define cross(x, y, z) (((y) - (x)) ^ ((z) - (x)))\n\ntypedef long long ll;\nconst int N = 20054, INF = 0x3f3f3f3f;\n\nstruct vec2 {\n\tint x, y;\n\tvec2 (int x0 = 0, int y0 = 0) : x(x0), y(y0) {}\n\tinline vec2 operator - (const vec2 &B) const {return vec2(x - B.x, y - B.y);}\n\tinline ll operator * (const vec2 &B) const {return (ll)x * B.x + (ll)y * B.y;}\n\tinline ll operator ^ (const vec2 &B) const {return (ll)x * B.y - (ll)y * B.x;}\n\tinline ll norm2() const {return (ll)x * x + (ll)y * y;}\n};\n\nint n, K;\nint a[N], pp[N], po[N];\nint dp[2][N], *cur = *dp, *nxt = dp[1];\n\ninline void up(int &x, const int y) {x < y ? x = y : 0;}\ninline void down(int &x, const int y) {x > y ? x = y : 0;}\n\nnamespace hull {\n\tvec2 ch[N], *tail;\n\n\tinline void reset() {tail = ch;}\n\n\tvoid insert(const vec2 &P) {\n\t if (tail != CH && tail[-1].x == P.x) return down(tail[-1].y, P.y);\n\t\tfor (; tail > ch + 1 && cross(tail[-2], P, tail[-1]) >= 0; --tail);\n\t\t*tail++ = P;\n\t}\n\n\tint query(const vec2 &P) {\n\t\tif (ch == tail) return INF;\n\t\tint L = 0, R = tail - ch - 1, M;\n\t\tfor (; L < R; M = (L + R) / 2, ch[M] * P > ch[M + 1] * P ? L = M + 1 : R = M);\n\t\treturn (int)std::min(ch[L] * P, INF);\n\t}\n}\n\nvoid solve(int L, int R) {\n\tif (L + 1 == R) return;\n\tint i, j, M = (L + R) / 2, lm, rm;\n\tj = M, lm = rm = 0, hull::reset();\n\tfor (i = M; i < R; ++i) {\n\t\tfor (up(rm, a[i]); j > L && lm <= a[i]; )\n\t\t\tif (up(lm, a[--j]), cur[j] < INF) hull::insert(vec2(j, cur[j]));\n\t\tdown(nxt[i], hull::query(vec2(-rm, 1)) + i * rm), pp[i] = j;\n\t}\n\tfor (po[ j = M - 1 ] = a[M]; j > L; --j) up(po[j - 1] = po[j], a[j]);\n\tj = L, lm = rm = 0, hull::reset();\n\tfor (i = R - 1; i >= M; --i) {\n\t\tfor (; j < pp[i]; ++j) if (cur[j] < INF) hull::insert(vec2(po[j], cur[j] - j * po[j]));\n\t\tdown(nxt[i], hull::query(vec2(i, 1)));\n\t}\n\tsolve(L, M), solve(M, R);\n}\n\nint main() {\n\tint i;\n\tscanf(\"%d%d\", &n, &K);\n\tfor (i = 0; i < n; ++i) scanf(\"%d\", a + i);\n\tfor (*nxt = *a, i = 1; i < n; ++i) up(nxt[i] = nxt[i - 1], a[i]);\n\tfor (i = 0; i < n; ++i) nxt[i] *= i + 1;\n\tfor (; --K; std::swap(cur, nxt), memset(nxt, 63, n << 2), solve(0, n));\n\tprintf(\"%d\\n\", nxt[n - 1]);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0b6449f1c8c4667f0394b9cf85235dc5", "src_uid": "f42faaaa88628748a8da49111936be00", "difficulty": 3000.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair ii;\ntypedef pair pli;\ntypedef pair pll;\ntypedef long double ld;\n\n#define FOR(i, a, b) for (ll i = (a), _b = (b); i <= _b; i++)\n#define FORD(i, b, a) for (ll i = (b), _a = (a); i >= _a; i--)\n#define REP(i, n) for (ll i = 0, _n = (n); i < _n; i++)\n#define FORE(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); i++)\n#define fi first\n#define se second\n#define all(a) a.begin(), a.end()\n#define MASK(i) (1LL << (i))\n#define BIT(x, i) (((x) >> (i)) & 1)\n#define endl '\\n'\n\nbool print;\nconst ll oo = 1e18 + 7;\n\nstruct Line {\n\tll a, b;\n\tLine() {}\n\tLine(ll _a, ll _b) : a(_a), b(_b) {}\n\tll val(ll x) {\n\t\treturn a * x + b;\n\t}\n\tbool operator == (Line other) {\n\t\treturn (other.a == a && other.b == b);\n\t}\n};\n\ntypedef pair iL;\n\nstruct PersistentLiChaoTree {\n\tvector st;\n\tll n, cnt; \n\tstack changes;\n\tstack popcount;\n\tPersistentLiChaoTree() {}\n\tPersistentLiChaoTree(ll _n) {\n\t\tthis->n = _n;\n\t\tst.resize(4 * n + 5);\n\t\tREP(i, st.size()) st[i] = Line(oo, oo);\n\t}\n\n\tll Left(ll x) {return (x << 1);}\n\tll Right(ll x) {return (x << 1) + 1;}\n\n\tvoid Assign(ll id, Line b) {\n\t\tcnt++;\n\t\tchanges.push(iL(id, st[id]));\n\t\tst[id] = b;\n\t}\n\n\tvoid update(ll id, ll L, ll R, Line a) {\n\t\tif (L == R) {\n\t\t\tif (st[id] == Line(oo, oo)) Assign(id, a);\n\t\t\telse if (a.val(L) < st[id].val(L)) Assign(id, a);\n\t\t\treturn;\n\t\t}\n\t\tif (st[id] == Line(oo, oo)) {\n\t\t\tAssign(id, a);\n\t\t\treturn;\n\t\t}\n\t\tll mid = (L + R) >> 1;\n\t\tbool l = st[id].val(L) < a.val(L), r = st[id].val(R) < a.val(R);\n\t\tbool m1 = st[id].val(mid) < a.val(mid), m2 = st[id].val(mid + 1) < a.val(mid + 1);\n\t\tif (l && r) return;\n\t\tif (!l && !r) {Assign(id, a); return;}\n\t\tif (l && m1) {update(Right(id), mid + 1, R, a); return;}\n\t\tif (!l && !m1) {update(Right(id), mid + 1, R, st[id]); Assign(id, a); return;}\n\t\tif (m2 && r) {update(Left(id), L, mid, a);return;}\n\t\tif (!m2 && !r) {update(Left(id), L, mid, st[id]); Assign(id, a); return;}\n\t}\n\tvoid addLine(Line a) {\n\t\tcnt = 0;\n\t\tupdate(1, 1, n, a);\n\t\tpopcount.push(cnt);\n\t}\n\n\tll query(ll id, ll L, ll R, ll x) {\n\t\tll ret;\n\t\tif (st[id] == Line(oo, oo)) ret = oo;\n\t\telse ret = st[id].val(x);\n\t\tif (L == R) return ret;\n\t\tll mid = (L + R) >> 1;\n\t\tif (x > mid) ret = min(ret, query(Right(id), mid + 1, R, x));\n\t\telse ret = min(ret, query(Left(id), L, mid, x));\n\t\treturn ret;\n\t}\n\tll query(ll x) {return query(1, 1, n, x);}\n\n\tvoid pop() { // O(logN) per operations due to the height of the IT\n\t\tif (popcount.empty()) return;\n\t\tll tmp = popcount.top(); popcount.pop();\n\t\twhile (tmp && !changes.empty()) {\n\t\t\tiL c = changes.top(); changes.pop();\n\t\t\tst[c.first] = c.second;\n\t\t\ttmp--;\n\t\t}\n\t}\n} IT;\n\nstruct LinearConvexHull {\n\tdeque st;\n\tLinearConvexHull() {st.clear();}\n\tbool bad(Line l1, Line l2, Line l3) { //Intersection of l3 and l1 is to the left of l2 & l1 or not\n\t\treturn (l2.b - l1.b) * (l1.a - l3.a) > (l3.b - l1.b) * (l1.a - l2.a);\n\t}\n\tvoid addLineRight(Line a) {\n\t\twhile (st.size() >= 2 && bad(st[st.size() - 2], st[st.size() - 1], a)) {\n\t\t\tst.pop_back();\n\t\t}\n\t\tst.push_back(a);\n\t}\n\tvoid addLineLeft(Line a) {\n\t\twhile (st.size() >= 2 && bad(st[1], a, st[0])) {\n\t\t\tst.pop_front();\n\t\t}\n\t\tst.push_front(a);\n\t}\n\tll query(ll x) {\n\t\tif (st.empty()) return oo;\n\t\tll l = 0, r = st.size() - 1;\n\t\tll ret = oo;\n\t\twhile (l <= r) {\n\t\t\tll mid = (l + r) >> 1;\n\t\t\tret = min(ret, st[mid].val(x));\n\t\t\tif (mid != 0 && st[mid - 1].val(x) < st[mid].val(x)) r = mid - 1;\n\t\t\telse if (mid != st.size() - 1 && st[mid + 1].val(x) < st[mid].val(x)) l = mid + 1;\n\t\t\telse break;\n\t\t}\n\t\treturn ret;\n\t}\n\tll size() {\n\t\treturn st.size();\n\t}\n};\n\ntypedef unique_ptr CVhull; // Smart pointer to avoid MLE due to exceeded dynamic memory allocation by deallocating\n\nvoid mergeHull(CVhull &A, CVhull &B) { // Merge two top Linear Convex Hull in case of poping elements in monotonous stack\n\tif (A -> size() > B -> size()) { // Small to large heuristic to decrease the time complexity to somewhat O(NlogN)\n\t\tREP(i, B -> size()) {\n\t\t\tA -> addLineRight(B -> st[i]);\n\t\t}\n\t\tswap(A, B);\n\t} else {\n\t\tFORD(i, A->size() - 1, 0) {\n\t\t\tB -> addLineLeft(A -> st[i]);\n\t\t}\n\t}\n}\n\nstruct state {\n\tCVhull Hull; // For function in each block of the monotonous stack\n\tll pos; // index in the original array\n\tstate() {\n\t\tpos = -1;\n\t\tHull = 0;\n\t}\n};\n\nconst ll N = 2e4 + 5, K = 105;\nll dp[N][K], n, a[N], kk;\n\nvoid solve() {\n\tREP(i, N) REP(j, K) dp[i][j] = oo;\n\tdp[0][0] = 0;\n\tll mval = 0;\n\tFOR(i, 1, n) {\n\t\tmval = max(mval, a[i]);\n\t\tdp[i][1] = mval * i;\n\t}\n\tstack st;\n\tFOR(k, 2, kk) { // By layer\n\t\tIT = PersistentLiChaoTree(n);\n\t\twhile (!st.empty()) st.pop();\n\t\tFOR(i, 1, n) { // By index\n\t\t\tstate D; D.pos = i; D.Hull = make_unique();\n\t\t\tD.Hull->st.clear();\n\t\t\tif (dp[i - 1][k - 1] != oo) D.Hull->addLineRight(Line(-i, dp[i - 1][k - 1]));\n\t\t\twhile (!st.empty() && a[st.top().pos] <= a[i]) {\n\t\t\t\tIT.pop();\n\t\t\t\tmergeHull(st.top().Hull, D.Hull);\n\t\t\t\tst.pop(); \n\t\t\t}\n\t\t\tif (D.Hull -> size()) IT.addLine(Line(a[i], D.Hull->query(a[i]) + a[i]));\n\n\t\t\tdp[i][k] = IT.query(i);\n\t\t\tst.push(D); //Deallocating\n\t\t}\n\t}\n\tcout << dp[n][kk] << endl;\n}\n\nvoid input() {\n\tcin >> n >> kk;\n\tFOR(i, 1, n) cin >> a[i];\n}\n\nint main(int argc, char const *argv[])\n{\n\tios_base::sync_with_stdio(0); cin.tie(0);\n\tclock_t tStart = clock();\n\n\tinput();\n\tsolve();\n\n\tfprintf(stderr, \"Time taken: %.2fs\\n\", (double)(clock() - tStart)/CLOCKS_PER_SEC);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c68793e7e79bdb208a05fc65578725ef", "src_uid": "f42faaaa88628748a8da49111936be00", "difficulty": 3000.0} {"lang": "GNU C++17", "source_code": "include\n\nusing namespace std;\n\n#define fore(i, l, r) for(int i = int(l); i < int(r); i++)\n#define sz(a) (int)((a).size())\n\n#define x first\n#define y second\n\ntypedef long long li;\ntypedef pair pt;\n\nconst int INF = int(1e9);\nconst li INF64 = li(1e9);\n\npt operator -(const pt &a, const pt &b) {\n return {a.x - b.x, a.y - b.y};\n}\nli operator *(const pt &a, const pt &b) {\n return a.x * b.x + a.y * b.y;\n}\nli operator %(const pt &a, const pt &b) {\n return a.x * b.y - a.y * b.x;\n}\npt rotate(const pt &p) {\n return {-p.y, p.x};\n}\n\nstruct LinearHull {\n deque pts, vecs;\n\n void addRight(const pt &l) {\n while(!vecs.empty() && vecs.back() * (l - pts.back()) < 0) {\n vecs.pop_back();\n pts.pop_back();\n }\n if(!pts.empty())\n vecs.push_back(rotate(l - pts.back()));\n pts.push_back(l);\n }\n void addLeft(const pt &l) {\n while(!vecs.empty() && vecs.front() * (l - pts.front()) < 0) {\n vecs.pop_front();\n pts.pop_front();\n }\n if(!pts.empty())\n vecs.push_front(rotate(pts.front() - l));\n pts.push_front(l);\n }\n\n li getMin(const pt &x) {\n auto it = lower_bound(vecs.begin(), vecs.end(), x, [](const pt &a, const pt &b) {\n return a % b > 0;\n });\n return x * pts[it - vecs.begin()];\n }\n};\n\ntypedef unique_ptr pHull;\n\nvoid mergeHulls(pHull &a, pHull &b) {\n if(sz(b->pts) >= sz(a->pts)) {\n for(auto &p : a->pts)\n b->addRight(p);\n } else {\n for(auto it = b->pts.rbegin(); it != b->pts.rend(); it++)\n a->addLeft(*it);\n swap(a, b);\n }\n}\n\nconst int M = 1000 * 1000 + 555;\nint szn = 0;\nstruct node {\n pt line;\n node *l, *r;\n\n node() : line(), l(nullptr), r(nullptr) {}\n node(pt line, node *l, node *r) : line(move(line)), l(l), r(r) {}\n} nodes[M];\n\ntypedef node* tree;\n\ntree getNode(const pt &line, tree l, tree r) {\n assert(szn < M);\n nodes[szn] = node(line, l, r);\n return &nodes[szn++];\n}\ntree copy(tree v) {\n if(v == nullptr) return v;\n return getNode(v->line, v->l, v->r);\n}\n\nli f(const pt &line, int x) {\n return line * pt{x, 1};\n}\n\ntree addLine(tree v, int l, int r, pt line) {\n if(!v)\n return getNode(line, nullptr, nullptr);\n int mid = (l + r) >> 1;\n bool lf = f(line, l) < f(v->line, l);\n bool md = f(line, mid) < f(v->line, mid);\n\n if(md)\n swap(v->line, line);\n\n if(l + 1 == r)\n return v;\n else if(lf != md)\n v->l = addLine(copy(v->l), l, mid, line);\n else\n v->r = addLine(copy(v->r), mid, r, line);\n return v;\n}\n\nli getMin(tree v, int l, int r, int x) {\n if(!v) return INF64;\n if(l + 1 == r)\n return f(v->line, x);\n int mid = (l + r) >> 1;\n\n if(x < mid)\n return min(f(v->line, x), getMin(v->l, l, mid, x));\n else\n return min(f(v->line, x), getMin(v->r, mid, r, x));\n}\n\nint n, k;\nvector

  • a;\n\ninline bool read() {\n if(!(cin >> n >> k))\n return false;\n a.resize(n);\n\n fore(i, 0, n)\n cin >> a[i];\n return true;\n}\n\nstruct state {\n int pos;\n pHull hull;\n tree v;\n\n state() : pos(-1), hull(nullptr), v(nullptr) {}\n};\n\nvector
  • d[2];\n\ninline void solve() {\n int maxn = (int)*max_element(a.begin(), a.end()) + 3;\n fore(k, 0, 2)\n d[k].resize(n + 1, INF64);\n\n d[0][0] = 0;\n fore(_k, 1, k + 1) {\n szn = 0;\n\n int ck = _k & 1;\n int nk = ck ^ 1;\n\n vector< state > st;\n\n fore(i, 0, sz(d[ck])) {\n d[ck][i] = INF64;\n if(!st.empty())\n d[ck][i] = getMin(st.back().v, 0, maxn, i);\n\n if(i >= sz(a))\n continue;\n\n state curVal;\n curVal.pos = i;\n curVal.hull = make_unique();\n curVal.hull->addRight({-i, d[nk][i]});\n curVal.v = nullptr;\n\n while(!st.empty() && a[st.back().pos] < a[i]) {\n mergeHulls(st.back().hull, curVal.hull);\n st.pop_back();\n }\n if(!st.empty())\n curVal.v = st.back().v;\n\n li val = curVal.hull->getMin({a[i], 1});\n curVal.v = addLine(copy(curVal.v), 0, maxn, {a[i], val});\n\n st.push_back(move(curVal));\n }\n }\n cout << d[k & 1][n] << endl;\n}\n\nint main() {\n#ifdef _DEBUG\n freopen(\"input.txt\", \"r\", stdin);\n int tt = clock();\n#endif\n ios_base::sync_with_stdio(false);\n cin.tie(0), cout.tie(0);\n cout << fixed << setprecision(15);\n\n if(read()) {\n solve();\n\n#ifdef _DEBUG\n cerr << \"TIME = \" << clock() - tt << endl;\n tt = clock();\n#endif\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ca45a9ed0535f42d7284cdd9f86e20c4", "src_uid": "f42faaaa88628748a8da49111936be00", "difficulty": 3000.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define m 16\nlong long c[20][20];\nint k,t,deep,a[20];\nlong long f[20][20];\nlong long size;\nvoid pre()\n{\n\tc[1][0]=c[1][1]=1;\n\tfor (int i=2;i<=10;i++)\n\t{\n\t\tc[i][0]=1;\n\t\tfor (int j=1;j<=i;j++)\n\t\t\tc[i][j]=c[i-1][j]+c[i-1][j-1];\n\t}\n}\nlong long dp(int x)\n{\n\tfor (int i=0;i<=m;i++)\n\t\tf[0][i]=1;\n\tfor (int i=1;i<=x;i++)\n\t\tfor (int j=1;j<=m;j++)\n\t\t{\n\t\t\tf[i][j]=0;\n\t\t\tfor (int k=0;k<=min(i,a[j]);k++)\n\t\t\t\tf[i][j]+=f[i-k][j-1]*c[i][k];\n\t\t}\n\treturn f[x][m];\n}\nvoid prt(int x)\n{\n\tif (x<10)\n\t\tputchar(x+'0');\n\telse\n\t\tputchar(x-10+'a');\n}\nvoid dfs(int k,int x)\n{\n\tif (x==0)\n\t\treturn;\n\tfor (int i=x==deep ? 2 : 1;i<=m;i++)\n\t{\n\t\tif (a[i]==0)\n\t\t\tcontinue;\n\t\ta[i]--;\n\t\tsize=dp(x-1);\n\t\tif (size>=k)\n\t\t{\n\t\t\tprt(i-1);\n\t\t\tdfs(k,x-1);\n\t\t\tbreak;\n\t\t}\n\t\tk-=size;\n\t\ta[i]++;\n\t}\n}\nint main()\n{\n\tscanf(\"%d%d\",&k,&t);\n\tpre();\n\tfor (int i=1;i<=m;i++)\n\t\ta[i]=t;\n\tdeep=1;\n\twhile (1)\n\t{\n\t\ta[2]--;\n\t\tsize=dp(deep-1)*15;\n\t\ta[2]++;\n\t\tif (size>=k)\n\t\t\tbreak;\n\t\tdeep++;\n\t\tk-=size;\n\t}\n\tdfs(k,deep);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5b7fe3749c7513a657a0a07d46e4e6b5", "src_uid": "cbfc354cfa392cd021d9fe899a745f0e", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "#include \n#define ll long long\n#define pii pair\n#define pll pair\n#define str string\n#define fi first\n#define se second\n#define pb push_back\n#define SET(a, b) memset(a, b, sizeof(a))\n#define eps 1e-6\n#define pi atan(1) * 4\n#define mod 1000000007\n#define inf 1000000000\n#define llinf 1000000000000000000\n#define FOR(i, a, b) for (int i = (a); i <= (b); i++)\n#define FORD(i, a, b) for (int i = (a); i >= (b); i--)\n#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)\n#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)\nusing namespace std;\nint k, t;\nll memo[165][12];\nll ncr (int n, int r) {\n if (r == 0) return 1;\n if (n == r) return 1;\n if (memo[n][r] != -1) return memo[n][r];\n return memo[n][r] = max(ncr(n - 1, r) + ncr(n - 1, r - 1), inf + inf);\n}\nll dp[165][18];\nint took[18];\nint l;\nint cal (bool f = 0) {\n FOR(i, 1, l) FOR(j, 1, 16) dp[i][j] = 0;\n FOR(j, 0, 16) dp[0][j] = 1;\n FOR(i, 1, l) {\n FOR(j, 1, 16) {\n dp[i][j] += dp[i][j - 1];\n FOR(k, 1, t - took[j]) {\n if (i - (f && j == 16) < k) break;\n dp[i][j] += dp[i - k][j - 1] * ncr(i - (f && j == 16), k);\n }\n }\n if (f) {\n if (dp[i][16] >= k) return i;\n k -= dp[i][16];\n }\n }\n}\nint main () {\n scanf(\"%d %d\", &k, &t); l = t << 4;\n SET(memo, -1);\n l = cal(1); --l;\n\n bool st = 0;\n string S;\n while (l >= 0) {\n bool done = 0;\n FOR(j, 0, 15) {\n if (!st && j == 0 || took[j] == t) continue;\n if (j == 0) j = 16;\n took[j]++;\n cal();\n if (dp[l][16] < k) {\n k -= dp[l][16];\n took[j]--;\n } else {\n if (j == 16) j = 0;\n S += (j <= 9 ? (j + '0') : (j - 10 + 'a'));\n break;\n }\n if (j == 16) j = 0;\n }\n --l; st = 1;\n }\n printf(\"%s\\n\", S.c_str());\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "de55d83d5bfee123e7e6cec95b1afd01", "src_uid": "cbfc354cfa392cd021d9fe899a745f0e", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef long long ll;\n\nconst int Maxn = 20;\nconst int Maxl = 16;\nconst string let = \"0123456789abcdef\";\n\nll C[Maxn][Maxn];\nll k;\nint t,cur[Maxl];\nint ans[Maxn];\n\nll Solve(int n, const int *av, bool fl = false)\n{\n\tstatic int dp[1000]; memset(dp,0,sizeof(dp));\n\tif (fl && av[0] <= 0) return 0;\n\tfor (int i = 0; i < Maxl; i++)\n\t\tif (av[i] < 0) return 0;\n\tdp[n - fl] = 1;\n\tfor (int i = 0; i < Maxl; i++)\n\t\tfor (int j = 0; j <= n; j++)\n\t\t\tfor (int k = 1; k <= j && k <= av[i] - (fl && i == 0); k++)\n\t\t\t\tdp[j - k] += dp[j] * C[j][k];\n\treturn dp[0];\n}\n\nint main()\n{\n\t//freopen(\"11input.in\",\"r\",stdin);\n\tfor (int i = 0; i < Maxn; i++) {\n\t\tC[i][0] = C[i][i] = 1;\n\t\tfor (int j = 1; j < i; j++)\n\t\t\tC[i][j] = C[i - 1][j - 1] + C[i - 1][j];\n\t}\n\tcin >> k >> t;\n\tint len = 1;\n\tfill(cur,cur+Maxl,t);\n\tll got;\n\twhile ((got = Solve(len, cur) - Solve(len, cur, true)) < k) { \n\t\tk -= got; len++; \n\t}\n\tfor (int i = 0; i < len; i++) {\n\t\tans[i] = (i? 0: 1); cur[ans[i]]--;\n\t\twhile ((got = Solve(len - 1 - i, cur)) < k) {\n\t\t\tk -= got; cur[ans[i]]++;\n\t\t\tans[i]++; cur[ans[i]]--;\n\t\t}\n\t\tprintf(\"%c\", let[ans[i]]);\n\t}\n\tprintf(\"\\n\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5d9a69afc4243966244ac63dd6c8138c", "src_uid": "cbfc354cfa392cd021d9fe899a745f0e", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "#pragma comment(linker, \"/stack:200000000\")\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4\")\n#pragma GCC optimize(\"unroll-loops\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define FAST_IO ios::sync_with_stdio(false);\n#define DEBUG_VIS(x) cerr<<\"vis \"< pii;\ntypedef pair pll;\ntypedef pair pdd;\ntypedef long long ll;\ntypedef unsigned int uint;\ntypedef unsigned long long ull;\nconst int maxn = 5005;\ntemplate T mymin(const T a,const T b){return a < b ? a : b;}\ntemplate T mymax(const T a,const T b){return a > b ? a : b;}\nll dp[maxn][maxn];\nint num[20],C[maxn][maxn];\nll len,k,t;\nchar outc[] = \"0123456789abcdef\";\nvoid pre(){\n for(int i = 0; i < 200; i++) C[i][0] = 1;\n for(int i = 1; i < 200; i++){\n for(int j = 1; j <= i; j++){\n C[i][j] = C[i - 1][j] + C[i - 1][j - 1];\n }\n }\n}\nll solve(ll len){\n SET_ZERO(dp)\n for(int i = 0; i <= num[0]; i++) dp[0][i] = C[len][i];\n for(int i = 1; i < 16; i++){\n for(int l = 0; l <= len; l++){\n for(int j = 0; j <= min(num[i],l); j++){\n dp[i][l] += dp[i - 1][l - j] * C[len - l + j][j];\n }\n }\n }\n return dp[15][len];\n}\n\nint main(){\n #ifndef ONLINE_JUDGE\n freopen(\"data.in\",\"r\",stdin);\n #endif\n FAST_IO\n cin>>k>>t;\n pre();\n for(int i = 0; i < 16; i++) num[i] = t;\n while(++len){\n ll tmp = 0;\n if(len == 1) tmp = 15;\n else {\n for(int i = 1; i < 16; i++){\n num[i]--;\n tmp += solve(len - 1);\n num[i]++;\n }\n }\n if(k > tmp) k -= tmp;\n else break;\n } \n for(int i = len; i; i--){\n if(i == 1){\n for(int j = 0; j < 16; j++){\n if(!j && len == 1) continue;\n if(num[j]) k--;\n if(!k){\n cout< tmp) k -= tmp;\n else {\n cout<\n#include \n#include \n#include \n\nusing namespace std;\n\nint ans[100000];\n\nint main(){\n vector > v;\n int n = 0;\n cin >> n;\n for(int i = 0; i < n; ++i){\n\tint a;\n\tcin >> a;\n\tv.push_back(a, i);\n }\n sort(v.begin(), v.end());\n for(int i = 0; i < v.size(); ++i)\n ans[v[i].second] = i % 2;\n for(int i = 0; i < v.size(); ++i)\n cout << ans[i] << ' ';\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5193bd5ed89871ea8ef4671d0ddba7b6", "src_uid": "692698d4b49ad446984f3a7a631f961d", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include\n\n\nusing namespace std;\n\nint main(){\n \n int n,m,p[1000],b[1000],s[1000],e[1000];\n cin >>n>>m;\n for(int i=0;i>p[i];\n b[i]=p[i];\n }\n sort(p,p+n);\n for(int i=0;i>s[i]>>e[i];\n \n for(int i=0;i\nusing namespace std;\nint main()\n{\n int n, m;\n cin >> n >> m;\n int a[105];\n for(int i=0;i> a[i];\n int a;\n for(int i=0;i>a >> a;\n }\n for(int i=0;i\n#include \nusing namespace std;\nint n,m;\nstruct p{\n int v;\n int point;\n int ans;\n bool operator < (const p & t){\n return v>n>>m;\n int i;\n memset(a,0,sizeof(a));\n for(i=0;i>a[i].v,a[i].ans=i;\n sort(a,a+n);\n for(i=0;i\n#include\nusing namespace std;\n\nint main(){\n string s;\n cin>>s;\n int k;\n cin>>k;\n int n = strlen(s), l =(n+k)/2;\n while(l>0){\n for(int i= n + k- l*2,j; i>=0; i--){\n for(j=0;j=n || s[i+j] == s[i+t+j]))\n break;\n if(j >= l) {\n cout<<2*l<\nusing namespace std;\n\nint main() {\nstring s;\ncin >> s;\nint k;\ncin >> k;\nint n = s.size();\nint ans = 0;\nfor (int i = 0; i < n; i++) {\nfor (int len = 1; len <= 400; len++) {\nbool ok = true;\nfor (int j = i; j < i + len; j++) {\nif (j + len >= n + k) {ok = false;break;}\nif (j + len < n && s[j] == s[j + len]) {\n} else {\nok = false;\nbreak;\n}\nif (ok) {\nans = max(ans, len);\n}\n}\n}\ncout << ans * 2 << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b4dac8a27c237421270ef778f73d0210", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\ntypedef long long int lli;\ntypedef long int li;\ntypedef vector vi;\ntypedef pair ii;\ntypedef pair ff;\ntypedef pair dd;\ntypedef unsigned int ui;\ntypedef vector vii;\ntypedef vector vff;\ntypedef set si;\ntypedef set slli;\ntypedef vector vlli;\ntypedef long long ll;\ntypedef long long ll;\n#define F first\n#define S second\ntypedef vector vll;\ntypedef unsigned long long int ulli;\n#define MOD 998244353\n#define INF (unsigned)(~0)>>1\ntypedef pair iii;\n#define Endl endl\nvoid solve();\nint main(int argc, char const *argv[]){\n solve();\n}\nvoid solve(){\n string s;\n cin>>s;\n int k;\n cin>>k;\n int n = s.size();\n int original_len = 0;\n for(int len = 0;len=k){\n int ans = 0;\n for(int i=0;i\n#include \n#include \nusing namespace std;\nint main(void)\n{\n int n,m,k;\n char c[500];\n cin>>c;\n cin>>n;\n //cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\n\n#define mp make_pair\n#define pb push_back\n#define mt make_tuple\n#define ff first\n#define ss second\n\n#define forn(i, n) for (int i = 0; i < ((int)(n)); ++i)\n#define forrn(i, s, n) for (int i = (int)(s); i < ((int)(n)); ++i)\n#define all(v) (v).begin(), (v).end()\n#define rall(v) (v).rbegin(), (v).rend()\n\n#define PYMOD(a, m) ((((a) % (m)) + (m)) % (m))\n\nconst int INF = 1791791791;\nconst ll INFLL = 1791791791791791791ll;\n\ntemplate\nclass FastIO {\n char cbuf[input_buf_size + 1];\n int icur = 0;\n\n inline bool go_to_next_token() {\n while (cbuf[icur] == ' ' || cbuf[icur] == '\\n') icur++;\n while (cbuf[icur] == 0) {\n icur = 0;\n if (fgets(cbuf, sizeof(cbuf), stdin) != cbuf)\n return false;\n while (cbuf[icur] == ' ' || cbuf[icur] == '\\n') icur++;\n }\n return true;\n }\n public:\n string readString() {\n assert(go_to_next_token());\n string ans;\n while (cbuf[icur] != ' ' && cbuf[icur] != '\\n' && cbuf[icur] != 0)\n ans.push_back(cbuf[icur++]);\n ans.shrink_to_fit();\n return ans;\n }\n\n template\n int_type readInt() {\n assert(go_to_next_token());\n int_type x = 0;\n bool m = cbuf[icur] == '-';\n if (m) icur++;\n while ('0' <= cbuf[icur] && cbuf[icur] <= '9') {\n x *= 10;\n x += (cbuf[icur] - '0');\n icur++;\n }\n if (m) x = -x;\n return x;\n }\n\n bool seekEof() {\n return !go_to_next_token();\n }\n\n private:\n char obuf[output_buf_size + 1];\n int ocur = 0;\n\n inline void write_string(const char *str, size_t sz = 0) {\n if (sz == 0)\n sz = strlen(str);\n if (ocur + sz > output_buf_size) {\n fputs(obuf, stdout);\n fputs(str, stdout);\n ocur = 0;\n obuf[0] = 0;\n return;\n }\n strcpy(obuf + ocur, str);\n ocur += sz;\n obuf[ocur] = 0;\n }\n\n public:\n template\n void writeInt(int_type x, bool sp = true) {\n char buf[20];\n int c = 0;\n if (x < 0) {\n buf[c++] = '-';\n x = -x;\n }\n int s = c;\n if (x == 0) {\n buf[c++] = '0';\n }\n while (x > 0) {\n buf[c++] = (x % 10) + '0';\n x /= 10;\n }\n for (int i = 0; 2 * i < c - s; i++) {\n swap(buf[s + i], buf[c - 1 - i]);\n }\n buf[c] = 0;\n write_string(buf, c);\n if (sp)\n write_string(\" \", 1);\n }\n\n void writeString(string s, bool space = true) {\n write_string(s.c_str(), s.size());\n if (space)\n write_string(\" \", 1);\n }\n\n void writeEndl() {\n write_string(\"\\n\", 1);\n#ifdef LOCAL\n if (lflush)\n flush();\n#endif\n \n }\n\n void flush() {\n fputs(obuf, stdout);\n ocur = 0;\n obuf[0] = 0;\n }\n\nprivate:\n bool lflush;\n\npublic:\n\n FastIO(bool local_flush) { \n obuf[0] = 0;\n lflush = local_flush;\n }\n \n ~FastIO() {\n fputs(obuf, stdout);\n }\n};\n\nFastIO<10000000, 10000000> IO(true);\n\nll fpow(ll x, int n, ll m) {\n if (n == 0)\n return 1;\n else if (n % 2 == 1)\n return (x * fpow(x, n - 1, m)) % m;\n else {\n ll t = fpow(x, n / 2, m);\n return (t * t) % m;\n }\n}\n\nconst ll MOD = 1000 * 1000 * 1000 + 7;\n\nstring s;\nvector p, a;\n\ntemplate\nstruct pair_hash {\n pair_hash() {}\n size_t operator()(const pair& pr) const {\n return (size_t)pr.ff * multiplier + pr.ss;\n }\n};\n \nint ones = 0;\nvector > dp;\nvoid count_dp() {\n int st = 0;\n while (st < (int)p.size() && p[st] <= (int)s.size())\n st++;\n if (st == (int)p.size())\n return;\n dp.resize(p.size() + 1, vector(s.size() + 1, 0));\n dp.back()[0] = 1;\n for (int i = p.size() - 1; i >= st; i--) {\n dp[i][0] = ((p[i] - ones) * dp[i + 1][0]) % MOD;\n for (int j = 1; j <= (int)s.size(); j++) {\n dp[i][j] = ((p[i] - ones - j) * dp[i + 1][j] + j * dp[i + 1][j - 1]) % MOD;\n }\n }\n}\n\nunordered_map, ll, pair_hash > mem(1e6);\nll count(ll mask, int i) {\n if (i == (int)p.size())\n return (mask == 0);\n if ((int)s.size() < p[i])\n return dp[i][__builtin_popcount(mask)];\n if (!mem.count(mp(mask, i)))\n mem[mp(mask, i)] = -1;\n ll & ans = mem[mp(mask, i)];\n if (ans == -1) {\n ans = 0;\n for (int j = 0; j < min((int)s.size(), p[i]); j++) {\n bool f = true;\n ll nmask = mask;\n for (int k = j; f && k < (int)s.size(); k += p[i]) {\n if (s[k] == '1')\n f = false;\n else {\n nmask &= (~(1ll << (ll)k));\n }\n }\n if (f) {\n ans = (ans + count(nmask, i + 1)) % MOD;\n }\n }\n }\n return ans;\n}\n\nint main() {\n // Code here:\n \n //cin >> s;\n s = IO.readString();\n int n;\n //cin >> n;\n n = IO.readInt();\n vector > ps(n);\n forn(i, n) {\n //cin >> ps[i].ff >> ps[i].ss;\n ps[i].ff = IO.readInt();\n ps[i].ss = IO.readInt();\n }\n p.resize(n);\n a.resize(n);\n sort(all(ps));\n forn(i, n)\n tie(p[i], a[i]) = ps[i];\n\n \n ll mask = 0;\n forn(i, s.size()) {\n if (s[i] == '0') \n mask |= (1ll << (ll)i);\n else\n ones++;\n }\n\n count_dp();\n \n ll ans = count(mask, 0);\n forn(i, n)\n ans = (ans * fpow(p[i], a[i] - 1, MOD)) % MOD;\n\n IO.writeInt(ans);\n IO.writeEndl();\n\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fdb579b4958c2a9188523d37bb0ae821", "src_uid": "a0140a8fc4215acec5f046485bc2c7f9", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\n#ifndef CPPELEVEN\n#ifdef USETR1\n#include \n#include \nusing namespace tr1;\n#endif\n#else\n#include \n#include \n#endif\n\n#ifdef USEPB_DS\n#include \n#include \nusing namespace __gnu_pbds;\ntypedef __gnu_pbds::priority_queue, pairing_heap_tag> pq_type;\ntypedef tree , rb_tree_tag, tree_order_statistics_node_update> tree_type;\n#endif\n\n#define mpr make_pair\ntypedef unsigned int ui;\ntypedef unsigned long long ull;\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pdd;\ntypedef vector vi;\ntypedef vector vll;\ntypedef vector vd;\ntypedef vector vs;\ntypedef map mpsi;\ntypedef map mpdi;\ntypedef map mpii;\n\nconst double pi = acos(0.0) * 2.0;\nconst long double eps = 1e-10;\nconst int step[8][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}, {-1, 1}, {1, 1}, {1, -1}, {-1, -1}};\n\ntemplate inline T abs1(T a) {return a < 0 ? -a : a;}\n\n#ifndef CPPELEVEN\ntemplate inline T max1(T a, T b) { return b < a ? a : b; }\ntemplate inline T max1(T a, T b, T c) { return max1(max1(a, b), c); }\ntemplate inline T max1(T a, T b, T c, T d) { return max1(max1(a, b, c), d); }\ntemplate inline T max1(T a, T b, T c, T d, T e) { return max1(max1(a, b, c, d), e); }\ntemplate inline T min1(T a, T b) { return a < b ? a : b; }\ntemplate inline T min1(T a, T b, T c) { return min1(min1(a, b), c); }\ntemplate inline T min1(T a, T b, T c, T d) { return min1(min1(a, b, c), d); }\ntemplate inline T min1(T a, T b, T c, T d, T e) { return min1(min1(a, b, c, d), e); }\n#else\ntemplate \nt min1(t a, t1 b) { return a < b ? a : b; }\ntemplate \nt min1(t a, arg... arr) { return min1(a, min1(arr...)); }\ntemplate \nt max1(t a, t1 b) { return a > b ? a : b; }\ntemplate \nt max1(t a, arg... arr) { return max1(a, max1(arr...)); }\n#endif\n\ninline int jud(double a, double b){\n\tif(abs(a) < eps && abs(b) < eps) return 0;\n\telse if(abs1(a - b) / max(abs1(a), abs1(b)) < eps) return 0;\n\tif(a < b) return -1;\n\treturn 1;\n}\ntemplate inline int jud(t a, t b){\n\tif(a < b) return -1;\n\tif(a == b) return 0;\n\treturn 1;\n}\n\ntemplate \ninline int find(t1 val, it a, int na, bool f_small = 1, bool f_lb = 1){\n\tif(na == 0) return 0;\n\tint be = 0, en = na - 1;\n\tif(*a <= *(a + na - 1)){\n\t\tif(f_lb == 0) while(be < en){\n\t\t\tint mid = (be + en + 1) / 2;\n\t\t\tif(jud(*(a + mid), val) != 1) be = mid;\n\t\t\telse en = mid - 1;\n\t\t}else while(be < en){\n\t\t\tint mid = (be + en) / 2;\n\t\t\tif(jud(*(a + mid), val) != -1) en = mid;\n\t\t\telse be = mid + 1;\n\t\t}\n\t\tif(f_small && jud(*(a + be), val) == 1) be--;\n\t\tif(!f_small && jud(*(a + be), val) == -1) be++;\n\t} else {\n\t\tif(f_lb) while(be < en){\n\t\t\tint mid = (be + en + 1) / 2;\n\t\t\tif(jud(*(a + mid), val) != -1) be = mid;\n\t\t\telse en = mid - 1;\n\t\t}else while(be < en){\n\t\t\tint mid = (be + en) / 2;\n\t\t\tif(jud(*(a + mid), val) != 1) en = mid;\n\t\t\telse be = mid + 1;\n\t\t}\n\t\tif(!f_small && jud(*(a + be), val) == -1) be--;\n\t\tif(f_small && jud(*(a + be), val) == 1) be++;\n\t}\n\treturn be;\n}\n\ntemplate inline T lowb(T num) {return num & (-num); }\n#ifdef GPP\ninline int bitnum(ui nValue) { return __builtin_popcount(nValue); }\ninline int bitnum(int nValue) { return __builtin_popcount(nValue); }\ninline int bitnum(ull nValue) { return __builtin_popcount(nValue) + __builtin_popcount(nValue >> 32); }\ninline int bitnum(ll nValue) { return __builtin_popcount(nValue) + __builtin_popcount(nValue >> 32); }\ninline int bitmaxl(ui a) { if(a == 0) return 0; return 32 - __builtin_clz(a); }\ninline int bitmaxl(int a) { if(a == 0) return 0; return 32 - __builtin_clz(a); }\ninline int bitmaxl(ull a) { int temp = a >> 32; if(temp) return 32 - __builtin_clz(temp) + 32; return bitmaxl(int(a)); }\ninline int bitmaxl(ll a) { int temp = a >> 32; if(temp) return 32 - __builtin_clz(temp) + 32; return bitmaxl(int(a)); }\n#else\n#endif\n\nlong long pow(long long n, long long m, long long mod = 0){\n\tif(m < 0) return 0;\n\tlong long ans = 1;\n\tlong long k = n;\n\twhile(m){\n\t\tif(m & 1) {\n\t\t\tans *= k;\n\t\t\tif(mod) ans %= mod;\n\t\t}\n\t\tk *= k;\n\t\tif(mod) k %= mod;\n\t\tm >>= 1;\n\t}\n\treturn ans;\n}\n\n#define MOD 1000000007\ntemplate \ninline void add(t1 &a, t2 b, int mod = -1) {\n\tif(mod == -1) mod = MOD;\n\ta += b;\n\twhile(a >= mod) a -= mod;\n\twhile(a < 0) a += mod;\n}\ntemplate \nvoid output1(t arr) {\n\tfor(int i = 0; i < (int)arr.size(); i++)\n\t\tcerr << arr[i] << ' ';\n\tcerr << endl;\n}\ntemplate \nvoid output2(t arr) {\n\tfor(int i = 0; i < (int)arr.size(); i++)\n\t\toutput1(arr[i]);\n}\nconst int mod = MOD;\nconst int maxn = 501000;\nchar str[maxn];\nint np;\nvector pri;\nunordered_map ump[2];\n\nint main() {\n\tios_base::sync_with_stdio(0);\n\t#ifdef DEBUG\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tint __size__ = 256 << 20;\n\tchar *__p__ = (char*)malloc(__size__) + __size__;\n\t__asm__(\"movl %0, %%esp\\n\" :: \"r\"(__p__));\n\t#endif\n\tscanf(\"%s\", str);\n\tint l = strlen(str);\n\tll mask = 0;\n\tfor(int i = 0; i < l; i++) if(str[i] == '0')\n\t\tmask |= 1ll << i;\n\n\tscanf(\"%d\", &np);\n\tfor(int i = 0; i < np; i++) {\n\t\tint a, b;\n\t\tscanf(\"%d%d\", &a ,&b);\n\t\tpri.push_back(mpr(a, b));\n\t}\n\tsort(pri.begin(), pri.end());\n\n\tump[0][0] = 1;\n\tint now = 0, nxt = 1;\n\tfor(auto it : pri) {\n\t\tump[nxt].clear();\n\t\tif(it.first >= l) continue;\n\t\tll rmask = 1ll << l, mask1 = 0;\n\t\trmask--;\n\t\tfor(int i = 0; i < l; i += it.first)\n\t\t\tmask1 |= 1ll << i;\n\t\tfor(int i = 0; i < it.first; i++) {\n\t\t\tll tmask = rmask & (mask1 << i);\n\t\t\tif((tmask & mask) != tmask)\n\t\t\t\tcontinue;\n\t\t\tfor(auto rit : ump[now]) {\n\t\t\t\tll rt = rit.first | tmask;\n\t\t\t\tauto tit = ump[nxt].find(rt);\n\t\t\t\tif(tit == ump[nxt].end())\n\t\t\t\t\ttit = ump[nxt].insert(mpr(rt, 0)).first;\n\t\t\t\tassert(tit->first == rt);\n\t\t\t\tadd(tit->second, rit.second);\n\t\t\t}\n\t\t}\n\t\tswap(now, nxt);\n\t}\n\tll dp[44];\n\tmemset(dp, 0, sizeof(dp));\n\tfor(auto it : ump[now]) {\n\t\tassert((it.first & mask) == it.first);\n\t\tadd(dp[bitnum(mask ^ it.first)], it.second);\n\t}\n\n\tll mul = 1;\n\tint delta = l - bitnum(mask);\n\tfor(auto it : pri) {\n\t\tif(it.first >= l) {\n\t\t\tfor(int i = 0; i <= l; i++) if(dp[i]){\n\t\t\t\tif(i) add(dp[i - 1], dp[i] * i % mod);\n\t\t\t\tdp[i] *= 1ll * (it.first - i - delta);\n\t\t\t\tdp[i] %= mod;\n\t\t\t}\n\t\t}\n\t\tmul = mul * pow(it.first, it.second - 1, mod) % mod;\n\t}\n\tcout << mul * dp[0] % mod << endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "93d8520985671f469d0ff6b78f01a2cd", "src_uid": "a0140a8fc4215acec5f046485bc2c7f9", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nchar str[55];\nint len;\nint zero;\nint n;\npair dat[500005];\nconstexpr int MOD = 1000000007;\n\nint dp[500005][45];\nbool v[500005][45];\nint comb[45][45];\n\nint C(int a, int b)\n{\n\tif (b == a || b == 0) return 1;\n\tif (comb[a][b] == 0)\n\t{\n\t\tcomb[a][b] = (C(a - 1, b - 1) + C(a - 1, b)) % MOD;\n\t}\n\treturn comb[a][b];\n}\n\nint D(int idx, int z)\n{\n\tif (z < 0) return 0;\n\tif (idx == n) return z == 0;\n\tif (v[idx][z] == false)\n\t{\n\t\tv[idx][z] = true;\n\t\tdp[idx][z] =\n\t\t\t(z * 1ll * (D(idx + 1, z) + D(idx + 1, z - 1)) + (dat[idx].first - len) * 1ll * D(idx + 1, z)) % MOD;\n\t}\n\n\treturn dp[idx][z];\n}\n\nunordered_map memo[20 * 1024];\nint cnt;\n\nint recur(long long flag, int idx)\n{\n\tauto itr = memo[idx * 1024 + flag & 1023].emplace(flag >> 10, 0);\n\tauto &ret = itr.first->second;\n\n\tif (itr.second)\n\t{\n\t\tif (idx == cnt)\n\t\t{\n\t\t\tint z = __popcnt64(flag);\n\n\t\t\tfor (int i = 0; i <= z; i++)\n\t\t\t{\n\t\t\t\tret = (ret + D(idx, zero - i) * 1ll * C(z, i)) % MOD;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor (int p = 0; p < dat[idx].first; p++)\n\t\t\t{\n\t\t\t\tbool wrong = false;\n\t\t\t\tfor (int j = p; j < len; j += dat[idx].first)\n\t\t\t\t{\n\t\t\t\t\tif (str[j] == '1')\n\t\t\t\t\t{\n\t\t\t\t\t\twrong = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (wrong) continue;\n\t\t\t\tlong long nf = flag;\n\n\t\t\t\tfor (int j = p; j < len; j += dat[idx].first) nf |= (1ll << j);\n\t\t\t\tret = (ret + recur(nf, idx + 1)) % MOD;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn ret;\n}\n\nint main()\n{\n\tscanf(\"%s\", str);\n\n\twhile (str[len])\n\t{\n\t\tif (str[len] == '0') zero++;\n\t\tlen++;\n\t}\n\n\tscanf(\"%d\", &n);\n\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tscanf(\"%d%u\", &dat[i].first, &dat[i].second);\n\t}\n\tcnt = partition(dat, dat + n, [](auto &e) {return e.first < len;}) - dat;\n\tint ans = recur(0, 0);\n\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tint mul = dat[i].first;\n\t\tint now = 0; unsigned flag = 1;\n\t\t--dat[i].second;\n\t\twhile (flag <= dat[i].second)\n\t\t{\n\t\t\tif (flag & dat[i].second) ans = ans * 1ll * mul % MOD;\n\t\t\tmul = (mul * 1ll * mul) % MOD;\n\t\t\tflag <<= 1;\n\t\t}\n\t}\n\n\tprintf(\"%d\\n\", ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2535e74567fd5cdbc5c35a22ace602d0", "src_uid": "a0140a8fc4215acec5f046485bc2c7f9", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\n//#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)\n//#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)\n\ntypedef long long ll;\nstatic constexpr ll MOD = 1000000007ll;\n//#define MOD 1000000007ll\n\nint T;\nstring s;\nint N,K;\nint p[500010],e[500010];\n\nmap mp[20];\n\nll power(ll x, ll n)\n{\n\tll result = 1;\n\twhile( n )\n\t{\n\t\tif (n & 1) result = result * x % MOD;\n\t\tx = x * x % MOD;\n\t\tn = n / 2 ;\n\t}\n\treturn result;\n}\n\nvoid update_mp(void)\n{\n\tint i,j;\n\t\n\tmp[0][0]++;\n\t\n\tfor(i = 0; i < K; ++i)\n\t{\n\t\tint pr = p[ i ];\n\t\t\n\t\tvector masks( pr ); // pr < 40\n\t\tfor(int j = 0 ; j < T; ++j) \n\t\t\tmasks[ j % pr ] |= ( 1ll << j );\n\t\t\n\t\t//snuke(mp[i],itr)\n\t\tfor(const auto& e : mp[i])\n\t\t{\n\t\t\tll mask = e.first;//(itr->first);\n\t\t\tint cnt = e.second;//(itr->second);\n\t\t\t\n\t\t\tfor(int j = 0; j < pr; ++j)\n\t\t\t{\n\t\t\t\tll mask2 = (mask | masks[ j ] );\n\n\t\t\t\tmp[ i + 1 ][ mask2 ] = ( mp[ i + 1 ][ mask2 ] + cnt ) % MOD;\n\t\t\t}\n\t\t}\n\t}\n}\n\nll dp[500010][50];\n\nll func(void)\n{\n\tint i,j;\n\t\n\t//snuke(mp[K],itr){\n\tfor(const auto& e : mp[K])\n\t{\n\t\tll mask = e.first;//(itr->first);\n\t\tll cnt = e.second;//(itr->second);\n\t\t\n\t\tbool good = true;\n\t\tint covered = 0;\n\t\tfor(int i = 0; i < T; ++i)\n\t\t{\n\t\t\tif( mask & ( 1ll << i ) )\n\t\t\t{\n\t\t\t\tif(s[i] == '0') good = false;\n\t\t\t\tif(s[i] == '1') covered++;\n\t\t\t}\n\t\t}\n\t\t\n\t\tif( good ) \n\t\t\tdp[ K] [ covered ] = ( dp[ K ][ covered ] + cnt ) % MOD;\n\t}\n\t\n\tint ones = 0;\n\tfor(int i= 0; i < T; ++i) if(s[i] == '1') ones++;\n\t\n\tfor(i=K;i> s >> N;\n\tfor(int i = 0; i \nusing namespace std;\ntypedef long long ll;\n\nconst int N = 100 + 5;\n\nint main()\n{\n\n\n\tstring s, b;\n\tcin >> s >> b;\n\tint mx = 0;\n\twhile (find(s.begin(),s.end(),b) != s.end()) {\n\t\tint x = s.find(b);\n\t\tif (x >= s.size() - (x + b.size()))\n\t\tif (x > mx)\n\t\t\tmx = x;\n\t\telse\n\t\t\tif ((s.size() - (x + b.size())) > mx)\n\t\t\t\tmx = s.size() - (x + b.size());\n\t\ts.erase(x, x + b.size());\n\t}\n\tcout << mx;\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fa001db8742f9fdc09972e6292e47f97", "src_uid": "0fd33e1bdfd6c91feb3bf00a2461603f", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nint main(){\n\tstring s1,s2;\n\tcin>>s1>>s2;\n\tint len1=s1.length(),len2=s2.length();\n\tint j=0;\n\tfor(int i=0;i=0;j--){\n\t\twhile(s1[j]!=s2[i]) j--;\n\t\tb[i]=j; //\u53f3\u8fb9\u904d\u5386\u627e\u5230\u6700\u540e\u51fa\u73b0\u7684\u4f4d\u7f6e \n\t}\n\tint ans= max (ans , max (len1-1-a[len2-1],b[0])); // \u627e\u5230\u5de6\u8fb9\u7a7a\u95f4\u6216\u8005\u53f3\u8fb9\u7a7a\u95f4\u6700\u5927\u7684\u90a3\u4e00\u4e2a\n\t\n\tfor(int i=0;i\nusing namespace std;\nint main()\n{\n int n1,n2,i,j,k,s;\n string s1,s2;\n cin>>s1;\n cin>>s2;\n n1=s1.size();n2=s2.size();int min1=0;\n for(i=0;i\nusing namespace std;\nconst int inf=1e9+7;\nstring s, t;\nvector v;\nint Max;\nint solve(int si, int tj, int cnt)\n{\n\tif (s[si]==t[tj])\n\t{\n\t\tif (tj==t.size()-1)\n\t\t\treturn 1;\n\t\treturn solve(si+1, tj+1, 0);\n\t}\n\treturn solve(si+1, tj, cnt+1);\n} \nint main()\n{\n\tcin >> s >> t;\n\tMax=-inf;\n\tfor (int i=0;i\n#define ll long long\nusing namespace std;\nll fib(ll n){const ld r5=sqrt(5);const ld ra=(r5+1)/2;return round(pow(ra,n)/r5);}\nint main(){\n ll n;\n cin>>n;\n for (ll i=1; i<=100; i++){\n if (n>=fib(i+2)){\n cout<\n#include \n#include \n#include \nusing namespace std;\n\ntypedef long long int64;\ntypedef __int128 int128;\n\nint128 low[200], high[200];\n\nint main() {\n int64 n; cin >> n;\n low[0] = 1;\n low[1] = 2;\n for (int i = 2; i < 150; i += 1) {\n low[i] = low[i - 1] + low[i - 2];\n }\n\n for (int i = 2; i < 150; i += 1) {\n if (low[i] > n) {\n cout << i - 1 << '\\n';\n return 0;\n }\n }\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ab44c5e864409ac52ebb51de807f0684", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#includ3\nusing namespace std;\n#define ll long long int\n\nint main()\n{\n ll n;\n cout<\n#define ll long long\nusing namespace std;\nint main(){\n ll dp[10000];\n dp[0]=1;\n dp[1]=2;\n ll n,cur=1;\n cin>>n;\n while (dp[cur]<=n){\n cur++;\n dp[cur]=dp[cur-1]+dp[cur-2];\n }\n cout<\n#define inf 10000000\nusing namespace std;\nint n,m,c,c_,refc[10];\nchar mp[25][25];\nint p[25][25];\nint val[10],px[10],py[10],sx,sy;\nint dx[5]={0,1,0,-1,0},dy[5]={0,0,-1,0,1};\nint dp[25][25][1<<8],sum[1<<8];\nstruct state{\n\tint x,y,st;\n};\nvoid bfs()\n{\n\tqueueq;\n\tq.push((state){sx,sy,0});\n\tstate now;\n\tint nx,ny,s,ax,ay,as;\n\twhile(!q.empty())\n\t{\n\t\tnow=q.front();q.pop();\n\t\tnx=now.x;ny=now.y;s=now.st;\n\t\tfor(int i=1;i<=4;++i)\n\t\t{\n\t\t\tax=nx+dx[i];ay=ny+dy[i];as=s;\n\t\t\tif(ax<=0||ax>n||ay<=0||ay>m)continue;\n\t\t\tfor(int j=0;j>n>>m;\n\tfor(int i=1;i<=n;++i)cin>>(mp[i]+1);\n\tfor(int i=1;i<=n;++i)\n\t{\n\t\tfor(int j=1;j<=n;++j)\n\t\t{\n\t\t\tif(mp[i][j]=='#')p[i][j]=1;\n\t\t\telse if(mp[i][j]=='S')sx=i,sy=j;\n\t\t\telse if(isdigit(mp[i][j]))refc[c_++]=c,px[c]=i,py[c++]=j;\n\t\t\telse if(mp[i][j]=='B')val[c]=-inf,px[c]=i,py[c++]=j;\n\t\t}\n\t}\n\tint a;\n\tfor(int i=1;i<=c_;++i)\n\t{\n\t\tcin>>a;\n\t\tval[refc[i]]=a;\n\t}\n\tfor(int i=1;i<(1<\n#include \n#include \n#include \nusing namespace std;\nint v[25][25][(1<<8)];\nint pr[8];\ntypedef pair P;\nP za[8];\nchar f[25][25];\nint n,m,sx,sy;\nint main()\n{\n\tscanf(\"%d %d\",&n,&m);\n\tfor(int i=0;i >que;\n\tfor(int i=0;i<25;i++)for(int j=0;j<25;j++)for(int k=0;k<(1<<8);k++)v[i][j][k]=10000;\n\tv[sx][sy][0]=0; que.push(mp(mp(sx,sy),0));\n\twhile(!que,empty()){\n\t\tpair x=que.front(); que.pop();\n\t\tint a=x.first.first; int b=x.first.second; int state=x.second;\n\t\tint dx[4]={0,1,0,-1}; int dy[4]={1,0,-1,0};\n\t\tfor(int i=0;i<4;i++){\n\t\t\tint nx=a+dx[i]; int ny=b+dy[i]; int state2=state;\n\t\t\tif(!(0<=nx&&nx>j)&1)) val+=pr[j];\n\t\tret=max(ret,val-v[sx][sy][i]);\n\t}\n\tprintf(\"%d%c\",ret,10);\n}\n\t\t\t\n\t\t\n\t\t\t", "lang_cluster": "C++", "compilation_error": true, "code_uid": "341bdc1c5ee4849a57a00c0f05d9c690", "src_uid": "624a0d6cf305fcf67d3f1cdc1c5fef8d", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n\nconst int N = 20;\nconst int INF = (int)1e9;\n\nconst int DELTA_X[4] = {-1, 0, 0, 1};\nconst int DELTA_Y[4] = {0, -1, 1, 0};\n\nint n, m, t, value[N], id[N][N];\nchar type[8], map[N][N + 1];\n\nint move[N][N][4], minimum[1 << 8][N][N];\n\nstruct State {\n int mask, x, y;\n\n State(int mask, int x, int y) : mask(mask), x(x), y(y) {\n }\n};\n\nint main() {\n scanf(\"%d%d\", &n, &m);\n for (int i = 0; i < n; ++ i) {\n scanf(\"%s\", map[i]);\n for (int j = 0; j < m; ++ j) {\n if (isdigit(map[i][j])) {\n map[i][j] --;\n }\n }\n }\n t = 0;\n if (true) {\n int x;\n while (scanf(\"%d\", &x) == 1) {\n value[t ++] = x;\n }\n }\n int o = 0;\n memset(id, -1, sizeof(id));\n int sx = -1, sy = -1;\n for (int i = 0; i < n; ++ i) {\n for (int j = 0; j < m; ++ j) {\n if (map[i][j] == 'S') {\n sx = i;\n sy = j;\n map[i][j] = '.';\n }\n if (isdigit(map[i][j]) || map[i][j] == 'B') {\n type[o] = map[i][j];\n id[i][j] = o ++;\n }\n }\n }\n for (int i = 0; i < n; ++ i) {\n for (int j = 0; j < m; ++ j) {\n for (int k = 0; k < 4; ++ k) {\n int &mask = move[i][j][k];\n int x = i + DELTA_X[k];\n int y = j + DELTA_Y[k];\n if (0 <= x && x < n && 0 <= y && y < m && map[x][y] == '.') {\n mask = 0;\n if (y == j) {\n for (int p = 0; p < n; ++ p) {\n for (int q = 0; q < m; ++ q) {\n if (id[p][q] != -1 && j > q && std::max(i, x) == p) {\n mask |= 1 << id[p][q];\n }\n }\n }\n }\n } else {\n mask = -1;\n }\n }\n }\n }\n for (int mask = 0; mask < 1 << o; ++ mask) {\n for (int i = 0; i < n; ++ i) {\n for (int j = 0; j < m; ++ j) {\n minimum[mask][i][j] = INF;\n }\n }\n }\n minimum[0][sx][sy] = 0;\n std::queue queue;\n queue.push(State(0, sx, sy));\n while (!queue.empty()) {\n State now = queue.front();\n queue.pop();\n int mask = now.mask;\n int x = now.x;\n int y = now.y;\n for (int k = 0; k < 4; ++ k) {\n if (move[x][y][k] != -1) {\n int nmask = mask ^ move[x][y][k];\n int nx = x + DELTA_X[k];\n int ny = y + DELTA_Y[k];\n if (minimum[nmask][nx][ny] == INF) {\n minimum[nmask][nx][ny] = minimum[mask][x][y] + 1;\n queue.push(State(nmask, nx, ny));\n }\n }\n }\n }\n int result = 0;\n for (int mask = 0; mask < 1 << o; ++ mask) {\n if (minimum[mask][sx][sy] < INF) {\n int count = 0;\n bool valid = true;\n for (int i = 0; i < o; ++ i) {\n if (mask >> i & 1) {\n if (type[i] == 'B') {\n valid = false;\n } else {\n count += value[type[i] - '0'];\n }\n }\n }\n if (valid) {\n result = std::max(result, count - minimum[mask][sx][sy]);\n }\n }\n }\n printf(\"%d\\n\", result);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "60ed984e8daad8642664ef409374e466", "src_uid": "624a0d6cf305fcf67d3f1cdc1c5fef8d", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\nint v[25][25][(1<<8)];\nint pr[8];\ntypedef pair P;\n#define mp make_pair\nP za[8];\nchar f[25][25];\nint n,m,sx,sy;\nint main()\n{\n\tscanf(\"%d %d\",&n,&m);\n\tfor(int i=0;i >que;\n\tfor(int i=0;i<25;i++)for(int j=0;j<25;j++)for(int k=0;k<(1<<8);k++)v[i][j][k]=10000;\n\tv[sx][sy][0]=0; que.push(mp(mp(sx,sy),0));\n\twhile(!que.empty()){\n\t\tpair x=que.front(); que.pop();\n\t\tint a=x.first.first; int b=x.first.second; int state=x.second;\n\t\tint dx[4]={0,1,0,-1}; int dy[4]={1,0,-1,0};\n\t\tfor(int i=0;i<4;i++){\n\t\t\tint nx=a+dx[i]; int ny=b+dy[i]; int state2=state;\n\t\t\tif(!(0<=nx&&nx>j)&1)) val+=pr[j];\n\t\tret=max(ret,val-v[sx][sy][i]);\n\t}\n\tprintf(\"%d%c\",ret,10);\n}\n\t\t\t\n\t\t\n\t\t\t", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c4fbac7f492ba9dab6537898d806537d", "src_uid": "624a0d6cf305fcf67d3f1cdc1c5fef8d", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include\n\nint main(){\n int n,a;\n std::cin>>n>>a;\n if(a%2)cout<\n\nusing namepsace std;\n\nint main(){\n int n, m;\n cin >> n >> m;\n cout << n - m;\n \n \n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c459ff5832733da659c070880cce5e58", "src_uid": "aa62dcdc47d0abbba7956284c1561de8", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include \"stdafx.h\"\n#include \n\nusing namespace std;\n\nint main()\n{\n\tint n, a,i,j=0;\n\tcin >> n >> a;\n\tif (a % 2 == 1) { cout << (a / 2) + 1; }\n\telse { for (i = n; i >=2; i = i - 2) \n\t{\n\t\tif (i != a) j++;\n\t\telse cout << j+1;\n\t} \n\t};\n\n\treturn 0;\n}\n#include \"stdafx.h\"\n#include \n\nusing namespace std;\n\nint main()\n{\n\tint n, a,i,j=0;\n\tcin >> n >> a;\n\tif (a % 2 == 1) { cout << (a / 2) + 1; }\n\telse { for (i = n; i >=2; i = i - 2) \n\t{\n\t\tif (i != a) j++;\n\t\telse cout << j+1;\n\t} \n\t};\n\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0daa5c39545dfcf2058a8d9bfc213496", "src_uid": "aa62dcdc47d0abbba7956284c1561de8", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main(){\n int a,b;\n cin>>a>>b;\n if(b%2==0){\n cout<<(b+a)/2;\n }\n if(b%2==1){\n cout<< (n+1)/2-(b+1)/2;\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1b4b17269121f4b58c46b4a2e76a9fee", "src_uid": "aa62dcdc47d0abbba7956284c1561de8", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\ntypedef __int128 ll;\nll ex_Gcd(ll a,ll b,ll & x,ll & y)\n{\n if(b==0)\n {\n x=1,y=0;\n return a;\n }\n ll gcd=ex_Gcd(b,a%b,x,y);\n ll temp=x;x=y;y=temp-a/b*y;\n return gcd;\n}\n void write(ll x)\n{\n if(x<0)putchar('-'),x=-x;\n if(x>9)write(x/10);\nputchar(x%10+'0');\n}\nll read()\n{\n ll ans=0;bool flag=0;char ch=0;\n while(!isdigit(ch)){flag|=ch=='-';ch=getchar();}\n while(isdigit(ch)){ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();}\n return flag?-ans:ans;\n}\nint main()\n{\n ll n,p,w,d;n=read(),p=read(),w=read(),d=read();\n ll x,y;\n ll g=ex_Gcd(w,d,x,y);\n if(p%g)\n {\n puts(\"-1\");\n return 0;\n }\n ll k=p/g;\n ll xx=d/g,yy=w/g;\n x*=k;\n y*=k;\n ll t;\n bool flag=1;\n if(x<0)\n {\n t=x/xx;\n if(x%xx)t++;\n x=x+t*xx;\n y=y-t*yy;\n }\n else if(y<0)\n {\n t=y/yy;\n if(y%yy)t++;\n y=y+t*yy;\n x=x-t*xx;\n }\n if(x>=0&&y>=0)\n {\n if(x+y>n)\n {\n ll zz=x+y-n;\n if(xx>yy)\n {\n ll add=xx-yy;\n ll q=zz/add;\n if(zz%add)q++;\n x=x-q*xx;\n y=y+q*yy;\n }\n else\n {\n ll add=yy-xx;\n ll q=zz/add;\n if(zz%add)q++;\n x=x+q*xx;\n y=y-q*yy;\n }\n }\n }\n if(x>=0&&y>=0)\n {\n write(x);\n printf(\" \");\n write(y);\n printf(\" \");\n write(n-x-y);\n printf(\"\\n\");\n }\n else\n puts(\"-1\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a7f0862d4e42f6470ccb45cbc04d75e3", "src_uid": "503116e144d19eb953954d99c5526a7d", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\ntypedef unsigned long long LL;\nint main()\n{\n LL n,s,w,d;\n cin>>n>>s>>w>>d;\n if((s%w)%d==0)\n {\n LL k=s/w;\n LL dd=(s-k*w)/d;\n LL ll=n-k-dd;\n cout< n:\n x += d // g\n y -= w // g\nz = n - x - y\nif x < 0 or y < 0 or z < 0:\n print(-1)\nelse:\n print(x, y, z)\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b077fe2d3db3a8f1ee4d9cd8bde1176d", "src_uid": "503116e144d19eb953954d99c5526a7d", "difficulty": 2000.0} {"lang": "MS C++ 2017", "source_code": "#include\nusing namespace std;\nconst int inf = 0x3f3f3f3f;\nconst int maxn = 0+5;\ntypedef long long ll;\n\nint main() {\n\tll n,p,w,d,x,y,z;\n\tcin >> n >> p >> w >> d;\n\tx = p / w;\n\tll re = p % w;\n\tbool flag = true;\n\tfor(int i=0;i<=x;i++) {\n\t\tif((i && (i*w)%d == 0) || ((re+i*w)/d + x - i > n)) {\n\t\t\tbreak;\n\t\t}\n\t\tif((re+i*w) % d == 0) {\n\t\t\tflag = false;\n\t\t\tx -= i;\n\t\t\ty = (re+i*w) / d;\n\t\t\tz = n - x - y;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif(flag) {\n\t\tputs(\"-1\");\n\t}\n\telse {\n\t\tcout << x << \" \" << y << \" \" << z << endl;\n\t}\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ef95bec551d3f741c5e9da2635c9494e", "src_uid": "503116e144d19eb953954d99c5526a7d", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nchar A[19], B[19];\nint n;\n\nbool func(int k) {\n if (k == n)\n return true;\n\n for (int i = k; i < n; i++) {\n if (A[i] == B[k]) {\n char t = A[i];\n A[i] = A[k];\n A[k] = t;\n break;\n }\n }\n if (A[k] == B[k] && func(k + 1))\n return true;\n } \n \n for (int i = k; i < n; i++) {\n if (A[i] < B[k] && A[i] > A[k]) {\n char t = A[i]; \n A[i] = A[k];\n A[k] = t;\n } \n } \n if (A[k] < B[k]) {\n sort(A+k+1, A+n, greater());\n return true;\n } \n \n return false;\n} \n\n\nint main() {\n cin >> A >> B;\n n = strlen(A);\n\n if (n > strlen(B)) {\n sort(A, A+n, greater());\n }\n else if (n == strlen(B)) {\n func(0);\n }\n cout << A << endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "308f9236f6f764e4e0caa9fc54b77cd0", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\n__int128_t ipow(int a, int p) {\n __int128_t res = 1;\n while(p) {\n res *= a;\n --p;\n }\n}\n\nlong get_max(const vector& digits) {\n long res = 0;\n for(int i=digits.size()-1; i>=0; --i) {\n int dc = digits[i];\n while(dc) {\n res = 10*res + i;\n --dc;\n }\n }\n return res;\n}\n\nlong solve(const string& bStr, const int pos, const vector& digits) {\n int b = bStr[pos] - '0';\n if (digits[b]) {\n if (pos == bStr.size()-1) {\n return b;\n }\n vector subdigs(digits);\n subdigs[b] -= 1;\n long res = solve(bStr, pos+1, subdigs);\n if (res >= 0) {\n long factor = ipow(10, bStr.size() - pos - 1);\n return factor*b + res;\n }\n }\n\n for(int i=b-1; i>=0; --i) {\n if (digits[i]) {\n vector subdigs(digits);\n subdigs[i] -= 1;\n long res = get_max(subdigs);\n long factor = ipow(10, bStr.size() - pos - 1);\n return factor*i + res;\n }\n }\n return -1;\n}\n\nlong solve_fast(const long A, const long B) {\n string aStr = to_string(A);\n string bStr = to_string(B);\n\n vector digits(10, 0);\n for(int i=0; i> A >> B;\n\n cout << solve_fast(A, B) << endl;\n\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f1e4d5e4d6a296a4bbc2e4bd761d89bd", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \n#define __int8 char\nusing namespace std;\n\nsize_t digit_distributor64(long long x, __int8* aRr)\n{\n\tsize_t length = 0;\n\tfor (__int8 i = 0; i < 19; ++i)\n\t{\n\t\taRr[i] = x % 10;\n\t\tif (!(x /= 10))\n\t\t{\n\t\t\tlength = ++i;\n\t\t\tfor (; i < 19; ++i)\n\t\t\t\taRr[i] = 0;\n\t\t}\n\t}\n\treturn length;\n}\n\nsize_t digit_distributor10(long long x, __int8* aRr)\n{\n\tsize_t length = 0;\n\tfor (__int8 i = 0; i < 10; ++i)\n\t{\n\t\taRr[i] = 0;\n\t}\n\tfor (__int8 i = 0; ; ++i)\n\t{\n\t\t++aRr[x % 10];\n\t\tif (!(x /= 10))\n\t\t{\n\t\t\tlength = i + 1;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn length;\n}\n\nbool crit(const __int8* aRr, __int8 x)\n{\n\tbool t = false;\n\tfor (; --x >= 0;)\n\t{\n\t\tif (t = aRr[x])\n\t\t\tbreak;\n\t}\n\treturn t;\n}\n\nint main()\n{\n\tlong long a, b;\n\n\tcin >> a >> b;\n\n\t__int8 *aRrA = new __int8[10], *aRrB = new __int8[19];\n\n\t__int8 La = digit_distributor10(a, aRrA), Lb = digit_distributor64(b, aRrB);\n\n\t_int8 *aRrA2 = new __int8[10];\n\tdigit_distributor10(a, aRrA2);\n\n\tif (La > Lb)\n\t\taRrA[0] -= La - Lb;\n\n\tif (Lb <= La)\n\t{\n\t\t__int8 lasTdano = Lb - 1;\n\t\t--aRrA2[aRrB[Lb - 1]];\n\n\t\tfor (__int8 i = Lb - 2; i >= 0; --i)\n\t\t{\n\t\t\tif (crit(aRrA2, aRrB[i]))\n\t\t\t\tlasTdano = i;\n\t\t\tif (aRrA2[aRrB[i]])\n\t\t\t{\n\t\t\t\t--aRrA2[aRrB[i]];\n\t\t\t\t//cout << +aRrB[i] << '-' << +aRrA2[aRrB[i]] << '\\n';\n\t\t\t}\n\t\t\telse\n\t\t\t\tbreak;\n\t\t}\n\n\t\t//cout << +lasTdano << '\\n';\n\n\t\tfor (__int8 i = Lb - 1; i > lasTdano; --i)\n\t\t{\n\t\t\tcout << +aRrB[i];\n\t\t\t--aRrA[aRrB[i]];\n\t\t}\n\n\t\tfor (__int8 i = aRrB[lasTdano] - 1; i >= 0; --i)\n\t\t\tif (aRrA[i])\n\t\t\t{\n\t\t\t\t--aRrA[i];\n\t\t\t\tcout << +i;\n\t\t\t\tbreak;\n\t\t\t}\n\t}\n\n\tfor (__int8 i = 9; i >= 0; --i)\n\t\tfor (__int8 k = 0; k < aRrA[i]; ++k)\n\t\t\tcout << +i;\n\n\t//system(\"pause\");\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4cb2cc81b50d88ba2a57c2519696b290", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44", "difficulty": 1700.0} {"lang": "GNU C++17 Diagnostics", "source_code": "\n#include \"bits/stdc++.h\"\n// #include \"DEBUG.h\"\nusing namespace std;\nstruct ${$(){ios_base::sync_with_stdio(0);cin.tie(0);}}$;\n\nconst long long inf = (long long)2e18; \n// const int N = 200005;\n\nvector get(long long x) {\n vector ret;\n while(x) {\n ret.push_back(x % 10);\n x /= 10;\n }\n reverse(ret.begin(), ret.end());\n return ret;\n}\n\n\nvector v_a, v_b, cnt;\n\nlong long dfs(int idx, int isZero, int isLess, long long val, vector &cnt) {\n // DEBUG(idx, val, cnt);\n if(idx == v_a.size())\n return val;\n int m = 0, M = 9;\n if(isZero == 0)\n m = 1;\n if(isLess == 0)\n M = v_b[idx];\n // DEBUG(idx, m, M);\n\n long long ret = -1;\n for(int digit = M; digit >= m; digit--) {\n if(cnt[digit] > 0) {\n int isZero_ = (isZero | (digit > 0));\n int isLess_ = (isLess | (digit < v_b[idx]));\n long long val_ = val * 10LL + digit;\n cnt[digit]--;\n ret = max(ret, dfs(idx + 1, isZero_, isLess_, val_, cnt));\n if(isLess) break;\n cnt[digit]++;\n }\n }\n return ret;\n}\n\n\nint main() {\n long long a, b;\n cin >> a >> b;\n v_a = get(a);\n v_b = get(b);\n\n if(v_a.size() < v_b.size()) {\n sort(v_a.rbegin(), v_a.rend());\n for(auto x: v_a)\n cout << x;\n cout << endl;\n return 0;\n }\n cnt.resize(10);\n\n for(int i = 0; i < v_a.size(); i++) {\n cnt[v_a[i]]++;\n }\n\n // DEBUG(v_a, v_b, cnt);\n long long ans = dfs(0, 0, 0, 0, cnt);\n\n cout << ans << endl;\n\n return", "lang_cluster": "C++", "compilation_error": true, "code_uid": "133cedf893be9ac2d815a03900216d7a", "src_uid": "bc31a1d4a02a0011eb9f5c754501cd44", "difficulty": 1700.0} {"lang": "MS C++", "source_code": "#include \"stdafx.h\"\n#include \"string.h\"\n#include \"stdio.h\"\n\n\nvoid main()\n{\n int x = 0;\n scanf(\"%d\", &x);\n\n int y = 0;\n scanf(\"%d\", &y);\n\n int r = 0;\n\n if((x>0)&&(y>(-x)+1)&&(y<=x))\n {\n r = 4*(x - 1) + 1;\n }\n else\n if((y > 0)&&(y>x)&&(y>=-x))\n {\n r = 4*(y-1)+2;\n }\n else\n if((y<-x)&&(-y>=-x)&&(x<0))\n {\n r = 4*((-x)-1)+3;\n }\n else\n if((y<0)&&(-y<-x)&&(y<=(-x)+1))\n {\n r = 4*((-y)-1)+4;\n }\n\n printf(\"%d\", r);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "549fb7a02fc4f7a67ea4ee8fa7eb714a", "src_uid": "2fb2a129e01efc03cfc3ad91dac88382", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int x,y,pas;\n \n cin>>x>>y;\n \n if (x>=0 && y>=0) pas=((x-1)*4)+1;\n if (x<=0 && y>=0) pas=((-x-1)*4)+2;\n if (x<=0 && y<=0) pas=((-x-1)*4)+3;\n if (x>=0 && y<=0) pas=(-y*4);\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nvector > arr;\n\nint main() {\n//freopen(\"in.txt\",\"r\",stdin);\n\nint x,y;\ncin>>x>>y;\n\narr.push_back(make_pair(0,0));\n\nint cnt=1,prev=0;\nwhile(cnt <= 10000)\n{\n\tif(cnt%2==1)\n\t{\n\t\tarr.push_back(make_pair(arr[prev].first+cnt,arr[prev].second));\n\t\tprev++;\n\n\t\tarr.push_back(make_pair(arr[prev].first,arr[prev].second+cnt));\n\t}\n\telse\n\t{\n\t\tarr.push_back(make_pair(arr[prev].first-cnt,arr[prev].second));\n\t\tprev++;\n\n\t\tarr.push_back(make_pair(arr[prev].first,arr[prev].second-cnt));\n\t}\n\n\t//cout<\n#include\n#include\n#include\nusing namespace std;\n\nint main()\n{\n int x,y,a,b,g;\n cin>>x>>y;\n a=abs(x);\n b=abs(y);\n g=a>b?a:b;\n int n=0;\n if(x==0 && y==0)\n cout<<\"0\";\n else if(x==1 && y==0)\n cout<<\"0\";\n else\n {\n n=(g-1)*4+1;\n if(x==g && y>-g)\n ;\n else if(x==g && y=(-g))\n n--;\n else if(x\nint main(){\n cout<<\"INTERCAL\";\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1050bbd8374e382a67f880d62957aec9", "src_uid": "ef8239a0f77c538d2d9b246b86be63fe", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n cout << \"Secret_171\"\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a09fef96f0394d45ca9bbc66fb320026", "src_uid": "ef8239a0f77c538d2d9b246b86be63fe", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include\n#include\nint main()\n{\n puts(\"INTERCAL\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a71eab243fc47cc195df102c23a0144d", "src_uid": "ef8239a0f77c538d2d9b246b86be63fe", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include<#bits/stdc++.h>\nusing namespace std;\nint main(){\n cout<<\"INTERCAL\";\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6f38b68ae37d089c2b2894efea679ba9", "src_uid": "ef8239a0f77c538d2d9b246b86be63fe", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#define all(v) (v.begin(),v.end())\n#define vi vector\nusing namespace std;\n\n{\n int n;\n cin>>n;\n int arr[n];\n int s=0,b=0,c=0;\n for (int i=0; i>arr[i];\n }\n for (int i=0; i\n\nusing namespace std;\n\nint main()\n{\n int n ;\n cin>>n ;\n int arr[n] ;\n int sum = 0 ;\n for(int i = 0 ; i < n ; ++i)\n {\n cin>>arr[i] ;\n sum += arr[i] ;\n }\n int MAX = -10000000 ;\n int sum1 = 0 ;\n for(int i = 0 ; i < n ; ++i)\n {\n Max = max(MAX , max(sum - sum1 , sum1 - sum));\n sum1 += arr[i] ;\n sum -= arr[i] ;\n }\n cout<\nvoid main(){\n int n,sum=0,s=0;\n scanf(\"%d\",&n);\n int a[n],i;\n for(i=0;i0){\n sum=sum+a[i];\n }\n else{\n s=s+a[i];\n }\n }\n printf(\"%d\",sum-s);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8a46151a0dbce50953df6e73f221d851", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#!/usr/bin/env python3\np = 1000000007\ns = input()\nprint(int(s,2) * pow(2, len(s) - 1) % p)\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "110665f03c466224792e83c1477060d7", "src_uid": "89b51a31e00424edd1385f2120028b9d", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define FOR(i,n) for(i=0;i\n#define ll long long\n#define MAX 1000000000\n#define MOD 1000000007\nll pow(ll a,ll b)\n{\n if(b==0)\n {\n return 1;\n }\n ll temp=pow(a,b/2);\n if(b%2==0)\n return (temp*temp)%MOD;\n return ((temp*temp)%MOD)*a%MOD;\n}\nvoid update(int *bit,int pos,int diff,int n)\n{\n while(pos<=n)\n {\n bit[pos]+=diff;\n pos=pos+(pos&(-pos));\n }\n}\nint main()\n{\n string s;\n cin>>s;\n int i,n;\n int len=s.length();\n n=len;\n reverse(s.begin(),s.end());\n ll num=0;\n FOR(i,len)\n {\n if(s[i]=='1')\n num=(num+pow(2,i))%MOD;\n }\n for(i=len-1;i>=0;i--)\n {\n if(s[i]=='1')\n break;\n }\n if(i==-1)\n {\n cout<<\"0\";\n return 0;\n }\n else\n {\n num=pow(2,i)*num%MOD;\n num=num*pow(2,(n-i-1));\n cout<\n#include\nusing namespace std;\nint main()\n{\n string s;\n cin>>s;\n reverse(s.begin(),s.end());\n int n=s.length();\n long long int mod=1e9+7,ans=0,prev=0;\n long long int p[109];\n p[0]=1;\n for( int i=1;i<=101;i++ ) p[i]=(2*p[i-1])%mod;\n if(s[0]=='1') ans=1;\n else ans=0;\n for( int i=1;i\n#include\n#define MOD 1000000007\n\nusing namespace std;\n\nint x[120];\nint N;\n\nint main()\n{\n long long sonuc=1;\n long long a=0;\n string s;\n cin >> s;\n N=s.size();\n for(int i=0;i=0;i--,k*=2)\n {\n a+=k*x[i];\n a%=MOD;\n k%=MOD;\n }\n cout << (a*sonuc/2)%MOD <\n#define In_the_name_of_allah_the_merciful ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n#define Alhamdulillah return 0;\n#define pb push_back\n#define ins(x) insert(x)\n#define fi first\n#define se second\n#define lb lower_bound\n#define ub upper_bound\n#define all(v) (v.begin(),v.end())\n#define sz(v) ((ll)((v).size()))\n#define reset(v,val) memset(v,val,sizeof(v))\n#define erep(i, x, n) for ( i = x; i<=(ll)(n); i++)\n#define rep(i, x, n) for( i = x; i<(ll)(n); i++)\nusing namespace std;\ntypedef long long int ll;\nconst long long int mod=1e9+7;\nll dx[]={0,0,1,-1};\nll dy[]={1,-1,0,-1};\nll m,k,n,a[200005],sm=0,dp[205][205][500];\nmultiset< ll >st1,st2;\nstring s1,s2,s=\"\",ch=\"\";\nvectorv[200005];\nvector< pair >vv;\nvector< pair > vvA,vvB;\nvector< pair< ll,pair > > vvv;\npriority_queue pq;\nmap< ll , ll >cost;\nll xa,xb,xc,ya,yb,yc,xres;\n\nll solve(ll i,ll j,ll balance){\n if(!balance&&i==n&&j==m)return 0;\n ll &ret=dp[i][j][balance];\n if(ret!=-1)return ret;\n ll ans=2e9;\n if(i==n&&j==m)return ret=1+solve(i,j,balance-1);\n if(balance>0){\n ll x=i;\n ll y=j;\n if(i0){\n ll x=i;\n ll y=j;\n if(i0&&ans1!=1e9){\n ll x=i;\n ll y=j;\n if(i ::iterator it,it1,it2;\n\tchar c;\n // freopen(\"a.txt\",\"r\",stdin);\n cin>>s1>>s2;\n n=s1.size();m=s2.size();\n for(i=0;i<200;i++)\n for(j=0;j<200;j++)\n for(k=0;k<500;k++)dp[i][j][k]=-1;\n ll res=solve(0,0,0);\n //cout<\nusing namespace std;\n\nconst int N = 201;\nint dp[N << 1][N][N], nxt[N << 1][N][N];\nstring s, t;\n\nint rec(int depth, int si, int ti) {\n if (si == s.length() && ti == t.length())\n return ((depth >= 0) ? depth : 1e8);\n if (depth < 0 || depth > 2 * N - 1)\n return 1e8;\n if (dp[depth][si][ti] != -1)\n return dp[depth][si][ti];\n int k1 = 1e8, k2 = 1e8;\n k1 = 1 + rec(depth + 1, si + (si < s.length() && s[si] == '('),\n ti + (ti < t.length() && t[ti] == '('));\n k2 = 1 + rec(depth - 1, si + (si < s.length() && s[si] == ')'),\n ti + (ti < t.length() && t[ti] == ')'));\n if (k1 < k2) {\n nxt[depth][si][ti] = 1;\n dp[depth][si][ti] = k1;\n } else {\n nxt[depth][si][ti] = 2;\n dp[depth][si][ti] = k2;\n }\n return dp[depth][si][ti];\n}\n\nvoid recover(string &S, int depth, int si, int ti) {\n if (si == s.length() && ti == t.length()) {\n while (depth--)\n S.push_back(')');\n return;\n }\n if (nxt[depth][si][ti] == 1) {\n S.push_back('(');\n recover(S, depth + 1, si + (si != s.length() && s[si] == '('),\n ti + (ti != t.length() && t[ti] == '('));\n } else {\n S.push_back(')');\n recover(S, depth - 1, si + (si != s.length() && s[si] == ')'),\n ti + (ti != t.length() && t[ti] == ')'));\n }\n}\n\nint main() \n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n\n cin >> s >> t;\n memset(dp, -1, sizeof(dp));\n rec(0, 0, 0);\n string ans;\n recover(ans, 0, 0, 0);\n cout << ans;\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "62d8a14090ff92d1622434803f231132", "src_uid": "cc222aab45b3ad3d0e71227592c883f1", "difficulty": 2200.0} {"lang": "GNU C++14", "source_code": "#include\n\nusing namespace std;\nconst int N = 500;\nconst int INF = (int) 1e6;\nint dp[201][2001][2 * N];\n\nstring s, q;\nint solve( int i, int j, int d )\n{\n if( abs( d ) >= N ) \n return INF;\n \n if( i == (int) s.length() && j == (int) q.length() )\n return ( d >= 0 ? d : INF ); \n\n int &r = dp[i][j][d+N];\n if( r != -1 ) return r;\n \n r = INF;\n\n char c1 = '#';\n if( i < (int) s.length() )\n c1 = s[i];\n\n char c2 = '#';\n if( j < (int) q.length() )\n c2 = q[j];\n\n r = 1 + solve( i + (c1 == '('), j + (c2 == '('), d + 1 );\n r = min( r, 1 + solve( i + (c1 == ')'), j + (c2 == ')'), d - 1 ));\n return r;\n}\n\nstring ans;\n\nvoid rec( int i, int j, int d )\n{\n if( i == (int) s.length() && j == (int) q.length() )\n {\n while( d > 0 )\n ans.push_back( ')' ), --d;\n return;\n }\n\n int &r = dp[i][j][d+N];\n \n char c1 = '#';\n if( i < (int) s.length() )\n c1 = s[i];\n\n char c2 = '#';\n if( j < (int) q.length() )\n c2 = q[j];\n\n if( r == 1 + solve( i + (c1 == '('), j + (c2 == '('), d + 1 ) )\n {\n ans.push_back( '(' );\n rec(i + (c1 == '('), j + (c2 == '('), d + 1 ); \n }\n else\n {\n ans.push_back( ')' );\n rec(i + (c1 == ')'), j + (c2 == ')'), d - 1 ); \n }\n}\n\n\nint main()\n{\n cin >> s >> q;\n memset( dp, -1, sizeof dp );\n \n solve( 0 , 0 , 0);\n rec( 0, 0, 0 );\n\n cout << ans << '\\n';\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cfc3fc938d197d4ab692778df7aab6fb", "src_uid": "cc222aab45b3ad3d0e71227592c883f1", "difficulty": 2200.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#define N 300\n#define GH (N+N)*3\nusing namespace std;\nstruct truyvet{\n\tint i, j, k;\n\tint loai;\n};\nint n,m;\nint f[N][N][GH];\ntruyvet tr[N][N][GH];\n// goi f(i,j,k) la so ki tu it nhat can them de a1->ai,b1->bi ghep lai co bac thua` la k\n// dap and la f(n,m,0)\nint main()\n{\n\tstring a, b;\n\tcin >> a >> b;\n\tn = a.length();\n\tm = b.length();\n\tint gh = (m+n) * 3;\n\ta = \"#\" + a;\n\tb = \"#\" + b;\n\tfor (int i = 0; i <= n;i++)\n\tfor (int j = 0; j <= m;j++)\n\tfor (int k = 0; k <= gh; k++)\n\t\tf[i][j][k] = 123456;\n\n\tfor (int k = 0; k <= gh; k++)\n\t{\n\t\tf[0][0][k] = k;\n\t\ttr[0][0][k] = { 0, 0, k - 1 };\n\t}\n\t\t\n\tfor (int i = 0; i <= n; i++)\n\tfor (int j = 0; j <= m; j++)\n\tif (i+j>0)\n\tfor (int k = 0; k <= gh; k++)\n\t{\n\t\t///'('\n\t\tif (k > 0)\n\t\t{\n\t\t\tf[i][j][k] = f[i][j][k - 1]+1;\n\t\t\ttr[i][j][k] = { i, j, k - 1, 1 };\n\t\t}\n\t\t\n\t\tif (a[i] == '(')\n\t\t\tif (i>0 && k>0 && f[i - 1][j][k-1]+1 < f[i][j][k])\n\t\t\t{\n\t\t\t\tf[i][j][k] = f[i-1][j][k-1]+1;\n\t\t\t\ttr[i][j][k] = { i-1, j, k - 1, 1 };\n\t\t\t}\n\n\t\tif (b[j] == '(')\n\t\t\tif (j>0 && k>0 && f[i][j-1][k - 1]+1 < f[i][j][k])\n\t\t\t{\n\t\t\t\tf[i][j][k] = f[i][j-1][k - 1]+1;\n\t\t\t\ttr[i][j][k] = { i, j-1, k - 1, 1 };\n\t\t\t}\n\n\t\tif (a[i] == '(' && b[j] == '(')\n\t\t\tif (j>0 && i>0 && k>0 && f[i-1][j - 1][k - 1]+1 < f[i][j][k])\n\t\t\t{\n\t\t\t\tf[i][j][k] = f[i-1][j - 1][k - 1]+1;\n\t\t\t\ttr[i][j][k] = { i-1, j - 1, k - 1, 1 };\n\t\t\t}\n\n\t\n\t\tif (a[i] == ')')\n\t\t\tif (i>0 && f[i - 1][j][k+1]+1 < f[i][j][k])\n\t\t\t{\n\t\t\t\tf[i][j][k] = f[i-1][j][k+1]+1;\n\t\t\t\ttr[i][j][k] = { i-1, j, k + 1, 2 };\n\t\t\t}\n\n\t\tif (b[j] == ')')\n\t\t\tif (j>0 && f[i][j-1][k + 1]+1 < f[i][j][k])\n\t\t\t{\n\t\t\t\tf[i][j][k] = f[i][j-1][k + 1]+1;\n\t\t\t\ttr[i][j][k] = { i, j-1, k + 1, 2 };\n\t\t\t}\n\n\t\tif (a[i] == ')' && b[j] == ')')\n\t\t\tif (j>0 && i>0 && f[i-1][j - 1][k + 1]+1 < f[i][j][k])\n\t\t\t{\n\t\t\t\tf[i][j][k] = f[i-1][j - 1][k + 1]+1;\n\t\t\t\ttr[i][j][k] = { i-1, j - 1, k + 1, 2 };\n\t\t\t}\n\t}\n\tint kq = 123456;\n\tint x, y, z;\n\tfor (int k = 0; k <= gh;k++)\n\tif (f[n][m][k] + k ans;\n\tfor (int i = 1; i <= z; i++)\n\t\tans.push_back(')');\n\twhile (x != 0 || y != 0 || z!=0)\n\t{\n\t\ttruyvet tmp = tr[x][y][z];\n\t\tif (tr[x][y][z].loai == 1)\n\t\t\tans.push_back('(');\n\t\telse ans.push_back(')');\n\t\tx = tmp.i;\n\t\ty = tmp.j;\n\t\tz = tmp.k;\n\t}\n\tcout << kq << endl;\n\tfor (int i = ans.size() - 1; i >= 0; i--)\n\t\tcout << ans[i];\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c4bdc1cae3e443391dd8304d6a633d0c", "src_uid": "cc222aab45b3ad3d0e71227592c883f1", "difficulty": 2200.0} {"lang": "MS C++", "source_code": "#include\nusing namespace std;\nint main()\n{\n int arr[4];\n for(int i=0;i<4;i++)\n {cin>>arr[i];}\n int min1=arr[0],min2=arr[0];\n for(int i=0;i<4;i++)\n {if(i==1)\n {continue;}\n if(arr[i]arr[i])\n {min2=arr[i];}\n int n32=min2*32;\n int sum;\n sum=n256+n32;\n cout<\n#include \n#include \n#include \n#include \n#define lli long long int\n#define li long int\n#define ld long double\nusing namespace std;\nconst lli mod = 1e9 + 7;\n\n\nint main() {\n int a,b,c,d,m=0,n=0,k=0;\n cin>>a>>b>>c>>d;\n m=min(a,c);\n n=(m,d);\n a-=n;\n k=min(a,b)\n cout<\nusing namespace std;\nint main () {\n\tint a,b,c,d,q=0,w=0,t=0;\n\tcin>>a>>b>>c>>d;\n\tq=min(min(a,c),d);\n\tw=q*256;\n\t.a=a-q;\n\tt=min(a,b);\n\tw=w+t*32;\n\tcout<\n#include\nusing namespace std;\nint main(){\n int k2,k3,k5,k6;\n cin>>k2>>k3>>k5>>k6;\n int sum256 = std::min(k2,std::min(k5,k6));\n k2 = k2-sum256;\n int sum32 = std::min(k2,k3);\n cout>>((sum32*32)+(sum256*256));\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0b6b5a61210f1be8030e3330485b4b4d", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "n = int(input())\nm = int(input())\nprint(m % (2 ** n))\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c653cda9c2483bd0a5297425397baee9", "src_uid": "c649052b549126e600691931b512022f", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include\n#include\nusing namespace std;\n\nint main()\n{\nint m,n;\ncin>>n>>m;\nint s=m%pow(2,n);\ncout<\nusing namespace std;\nint man(){\n int m,n;long long int a;\n scanf(\"%d%d\",&m,&n);\n a=pow(2,n);\n if(n>=30)\n printf(\"%d\\n\",m);\n else\n printf(\"%d\\n\",m%a);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "dd1d9ca6a55f4531052cb14588ac27de", "src_uid": "c649052b549126e600691931b512022f", "difficulty": 900.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\nint main ()\n{\nint m,n;\ncin>>n>>m;\nif (n>m){cout<\nusing namespace std;\nchar sto[10][100]={ (\"+------------------------+\"), (\"|#.#.#.#.#.#.#.#.#.#.#.|D|)\"), (\"|#.#.#.#.#.#.#.#.#.#.#.|.|\"), (\"|#.......................|\"), (\"|#.#.#.#.#.#.#.#.#.#.#.|.|)\"), (\"+------------------------+\") };\nint main(){\n\tint N;\n\tcin>>N;\n\tfor(int i=1;N>0&&i<5;N--,i++)sto[i][1]='O';\n\tif(N>0){\n\t\tint cnt=N/3,mod=N%3;\n\t\tfor(int i=1;i<5;i++){\n\t\t\tif(i==3)continue;\n\t\t\tint pos=3;\n\t\t\tfor(int j=1;j<=cnt;j++)sto[i][pos]='O';\n\t\t\tif(mod){\n\t\t\t\tsto[i][pos='O';\n\t\t\t\tmod--;\n\t\t\t}\n\t\t}\n\t}\n\tfor(int i=0;i<6;i++)cout<\n#include\nusing namespace std;\nint main(){\nchar A[][26] = {\n\"+------------------------+\",\n\"|#.#.#.#.#.#.#.#.#.#.#.|D|)\",\n\"|#.#.#.#.#.#.#.#.#.#.#.|.|\",\n\"|#.......................|\",\n\"|#.#.#.#.#.#.#.#.#.#.#.|.|)\",\n\"+------------------------+\" };\nint k;\nscanf(\"%d\",&k);\nint i,j;\nfor(i=0;i<=21;i+=2)\nfor(j=0;j<=4;++j){\nif(k>0&&A[j][i]=='#')A[j][i]='0';--k;}\nfor(i = 0; i < 6; ++i)\nputs(A[i]);\nreturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "23bea6e1229564e3af6313adf6fb45fd", "src_uid": "075f83248f6d4d012e0ca1547fc67993", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint main()\n{\n int n;\n cin>>n;\n if(n==0){ cout<<\"+------------------------+\"<\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define mp make_pair\n#define fi first\n#define se second\n#define rep(i,f,n) for(int i=f;i\n#define real double\n#define OO 99999999999\nint read()\n{\n int x;\n scanf(\"%d\", &x);\n return x;\n}\nll readL()\n{\n ll x;\n scanf(\"%I64d\", &x);\n return x;\n}\nconst int MAX=26;\n/*struct trie\n{\n trie* child[MAX];\n bool isLeaf;\n trie()\n {\n mset(child,0);\n isLeaf = 0;\n }\n void insert(char* str)\n { if(*str == NULL) isLeaf = 1;\n else\n {\n int curr = *str - 'a';\n if(child[curr] == 0) child[curr] = new trie();\n child[curr]->insert(str+1);\n }\n }\n\n bool wordExist(char* str)\n {\n if(*str == NULL) return isLeaf;\n int curr = *str - 'a';\n if(child[curr] == 0) return false;\n return child[curr]->wordExist(str+1);\n\n }\n\n bool prefixExist(char* str)\n {\n if(*str == NULL) return true;\n int curr = *str - 'a';\n if(child[curr] == 0) return false;\n return child[curr]->prefixExist(str+1);\n\n }\n};*/\n//string s = \"abcdefghijklmnopqrstuvwxyz\";\nvector adj[200];\nbool vis[2000];\nvoid BFS(int v)\n{\n vis[v]=1;\n queue q;\n q.push(v);\n while(!q.empty())\n {\n int s = q.front();\n q.pop();\n cout<>n;\n for(int i=1;i<=21;i+=2)\n {\n for(int j=1;j<=4;j++)\n {\n if(i>1&&j==3) continue;\n bus[j][i]='O'; n--;\n if(n==0) break;\n }\n if(n==0) break;\n }\n for(int i=0;i<6;i++)\n {\n for(int j=0;j<26;j++)\n {\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef vector vi;\ntypedef vector vvi;\ntypedef pair ii;\ntypedef vector vii;\ntypedef long long LL;\n\ntemplate inline int sz(const T& x) { return (int)x.size(); }\n\nchar prime[1001];\n\nbool is_ok(int n) {\n\n for(int i = 2; i+i+2 <= n; ++i) {\n if( prime[i] && prime[i+2] && i+i+2 == n )\n return true;\n }\n\n return false;\n}\n\nint main() {\n cin.sync_with_stdio(false);\n cout.sync_with_stdio(false);\n\n memset(prime, 1, sizeof prime);\n for(int i = 2; i < 1000; ++i) {\n if(prime[i])\n for(int j = i+i; j < 1001; j += i) {\n prime[j] = 0;\n }\n }\n\n\n int N, K;\n cin >> N >> K;\n\n int k = 0;\n for(int n = 2; n <= N; ++n) {\n if( is_ok(n-1) )\n ++k;\n }\n\n if( k >= K )\n cout << \"YES\\n\";\n else\n cout << \"NO\\n\";\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "aab81b895ddbf9d4c1f7e4ca1a91d434", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint n,k;\nbool bol[1010];\nvectorprimes;\nvoid get_primes(int to){\n for(int itr=2;itr<=to;itr++){\n if(!bol[itr]){\n primes.push_back(itr);\n for(int i=itr+itr;i<=to;i+=itr)\n bol[i]=true;\n }\n }\n}\nbool ch_prime(int i){\n for(int itr=2;itr<=sqrt(i);itr++){\n if(i%itr==0){\n return 0;\n }\n }\n return 1;\n}\nint co;\nint main()\n{\n scanf(\"%d%d\",&n,&k);\n get_primes(n);\n for(int i=0;i=k){\n printf(\"YES\\n\");\n return 0;\n }\n printf(\"NO\\n\");\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "49fb297493ec8e766a588593593ffb6a", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nbool aval(int n)\n{\n\tif ( !(n&1) ) \n\treturn false ;\n\tfor ( int i=3 ; i>n>>k;\n\tint t[200] = {1} , h=0 ;\n\tt[]={ 2 , 3 , 5 } ;\n\tint numf = 3 ,\n\t nums = 7 ;\n\twhile ( nums < n+1 ) {\n\t\tif ( k and aval(nums) ) {\n\t\t\tif ( nov(nums-1,t,numf) )\n\t\t\t\tk--;\n\t\t\tt[numf] = nums ;\n\t\t\tnumf++;\n\t\t}\n\t\telse if ( !k )\n\t\t\treturn cout << \"YES\\n\" , 0 ;\n\t\tnums += 2 ;\n\t}\n\treturn cout << ( k ? \"NO\\n\" : \"YES\\n\" ) , 0 ;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cda0083431f057905e58a74330105139", "src_uid": "afd2b818ed3e2a931da9d682f6ad660d", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \n#include\n#include \n#define ll long long \nusing namespace std;\nbool isprime[1002];\nvectorv;\nmemset(isprime, true, sizeof (isprime));\nvoid sieve(){\n\t\n\tfor(int p=0; p*p< 1002; p++){\n\t\t\n\t\tif(isprime[p]==true){\n\t\t\t\n\t\t\tfor (int i = p * 2; i < 1002; i += p) \n isprime[i] = false;\n \n\t\t}\n\t}\n\t\n\t for (int p = 2; p < 1002; p++) \n if (isprime[p]) \n v.push_back(p); \n}\n\nint main() {\n\t sieve();\n\t \tint n,k;\n\t\tcin>>n>>k;\n\t\tint x=0;\n\t\tfor(int i=0;in){\n\t\t\t \t\t\tbreak;\n\t\t\t\t\t }\n\t\t\t \t\telse if((v[j]+v[j+1]+1)==v[i]){\n\t\t\t \t\t\tx++;\n\t\t\t\t\t }\n\t\t\t\t\t \n\t\t\t\t }\n\t\t\t}\n\t\t}\n\t\tif(x>=k){\n\t\t\tcout<<\"YES\"<\n#define i64 long long\n#define i128 __int128\ntemplate inline void read(T &x){\n\tx=0; register char c=getchar(); register bool f=0;\n\twhile(!isdigit(c))f^=c=='-',c=getchar();\n\twhile(isdigit(c))x=x*10+c-'0',c=getchar(); if(f)x=-x;\n}\nconst int N=1<<21,p=490019;\nconst long long mod=4179340454199820289;\nint n,m,c,lim=1,ans,k,a[N],b[N],g[N],f[N],rev[N];\nlong long F[N],G[N],w[N];\ninline int fpow(int a,int b,int p){int s=1;for(;b;b>>=1,a=(i64)a*a%p)if(b&1)s=(i64)s*a%p;return s;}\ninline i64 fpow(i64 a,i64 b,i64 p){i64 s=1;for(;b;b>>=1,a=(i128)a*a%p)if(b&1)s=(i128)s*a%p;return s;}\nvoid DFT(i64 *a){\n\tfor(int i=0;i=mod)a[i+j]-=mod;\n\t\t\t\tif(a[i+j+len]<0)a[i+j+len]+=mod;\n\t\t\t}\t\n}\nint main(){\n#ifdef memset0\n\t// freopen(\"1.in\",\"r\",stdin);\n\tfreopen(\"comp/data.in\",\"r\",stdin);\n#endif\n\tread(n),read(m),read(c);\n\tfor(int i=0;i>1]>>1)|((i&1)<<(k-1));\n\tfor(int len=1;len\n#include \n#include \n#include \n\ntypedef std::vector poly;\nconst int P=490019;\ninline int mul(const int &a,const int &b){return 1ll*a*b%P;}\ninline int sub(int a,const int &b){a-=b;return (a<0)?a+P:a;}\ninline int add(int a,const int &b){a+=b;return(a>=P)?a-P:a;}\nint qsm(int a,long long b){\n\tint ans=1;\n\twhile(b){\n\t\tif(b&1)ans=mul(ans,a);\n\t\ta=mul(a,a);\n\t\tb>>=1;\n\t}\n\treturn ans;\n}\ndouble pi=3.141592653589793238462643383279502884197169399375105820974944;\nstruct complex{\n\tdouble x,y;\n\tcomplex operator+(complex a){return (complex){x+a.x,y+a.y};}\n\tcomplex operator-(complex a){return (complex){x-a.x,y-a.y};}\n\tcomplex operator*(complex a){return (complex){x*a.x-y*a.y,x*a.y+y*a.x};}\n}a[2000001],c[2000001],b[2000001],d[2000001],w[2000001];\nlong long n,m,Lim=1,L=-1,R[2000001];\nvoid FFT(complex *a){\n\tfor(int i=0;i>1]>>1)|((i&1)<>14;\n\tfor(int i=0;i>14;\n\tFFT(a),FFT(c);\n\tfor(int i=0;i>1ll));\n\tfor(int i=0;i>1ll));\n\ta=a*b;\n\tint ans=0;\n\tfor(int i=0;i>1ll)));\n\tprintf(\"%d\\n\",ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f0e85721e9431ed6a0718b17933daad3", "src_uid": "032ea64ed7e2467c1f503dac185523f7", "difficulty": 3500.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n#define PB push_back \n#define MP make_pair \n#define SZ(v) ((int)(v).size()) \n#define FOR(i,a,b) for(int i=(a);i<(b);++i) \n#define REP(i,n) FOR(i,0,n) \n#define FORE(i,a,b) for(int i=(a);i<=(b);++i) \n#define REPE(i,n) FORE(i,0,n) \n#define FORSZ(i,a,v) FOR(i,a,SZ(v)) \n#define REPSZ(i,v) REP(i,SZ(v)) \ntypedef long long ll;\ntypedef unsigned long long ull;\nll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }\nint pw(int x, int n, int mod) { int ret = 1 % mod; while (true) { if (n & 1) ret = (ll)ret*x%mod; if ((n >>= 1) == 0) return ret; x = (ll)x*x%mod; } }\nvector getprimes(int x) { vector ret; for (int i = 2; i * i <= x; ++i) if (x % i == 0) { while (x % i == 0) x /= i; ret.PB(i); } if (x != 1) ret.PB(x); return ret; }\nint findprimitiveroot(int p) {\n\tvector pp = getprimes(p - 1);\n\tFOR(a, 1, p) { bool ok = true; REPSZ(i, pp) if (pw(a, (p - 1) / pp[i], p) == 1) { ok = false; break; } if (ok) return a; }\n\tassert(false); return -1;\n}\n\nstruct complex { \n\tdouble x, y; complex(double x = 0, double y = 0) :x(x), y(y) {} \n\tconst inline complex operator+(const complex &b) const { return complex(x + b.x, y + b.y); }\n\tconst inline complex operator-(const complex &b) const { return complex(x - b.x, y - b.y); }\n\tconst inline complex operator*(const complex &b) const { return complex(x*b.x - y*b.y, x*b.y + y*b.x); }\n\tconst inline void operator-=(const complex &b) { x -= b.x; y -= b.y; }\n\tconst inline void operator+=(const complex &b) { x += b.x; y += b.y; }\n};\n\nvoid fft(complex *x, int n, int type) {\n\tvector ww(n); ww[0] = complex(1, 0);\n\tfor (int step = n >> 1; step > 0; step >>= 1) {\n\t\tdouble r = 2 * acos(-1) / (n / step); complex unit(cos(r), sin(r));\n\t\tfor (int i = 0; i < n; i += 2 * step) ww[i + step] = ww[i] * unit;\n\t}\n\tif (type != +1) { for (int i = 1; i <= n - i; ++i) swap(ww[i], ww[n - i]); }\n\t//printf(\"ww:\"); REP(i, n) printf(\" (%.3lf,%.3lf)\", ww[i].x, ww[i].y); puts(\"\");\n\tfor (int i = 1, j = 0; i < n - 1; ++i) {\n\t\tfor (int s = n; j ^= s >>= 1, ~j&s;);\n\t\tif (ix, l->y, r->x, r->y, w->x, w->y);\n\t\t\t\tcomplex s = *l, t = *r**w;\n\t\t\t\t*l = s + t, *r = s - t;\n\t\t\t}\n\t\t}\n\t}\n}\n\ntemplate struct MultiDimArray {\n\tvector dim;\n\tvector data;\n\n\tMultiDimArray(vector _dim) { dim = _dim; int sz = 1; REPSZ(i, dim) sz *= dim[i]; data = vector(sz); }\n\tint flatidx(const vector &idx) const { int ret = 0; REPSZ(i, dim) ret = ret * dim[i] + idx[i]; return ret; }\n\tvector idx(int flatidx) const { vector ret(SZ(dim)); for (int i = SZ(dim) - 1; i >= 0; --i) { ret[i] = flatidx % dim[i]; flatidx /= dim[i]; } return ret; }\n\tpair splitidx(int flatidx, int dimidx) const { pair ret = MP(0, 0); int prod = 1; for (int i = SZ(dim) - 1; i >= 0; --i) { int cur = flatidx%dim[i]; if (i == dimidx) ret.second = cur; else ret.first += prod * cur, prod *= dim[i]; flatidx /= dim[i]; } return ret; }\n\tT& operator[](const vector &idx) { return data[flatidx(idx)]; }\n\tT& operator[](const int &flatidx) { return data[flatidx]; }\n\tconst T& operator[](const vector &idx) const { return data[flatidx(idx)]; }\n\tconst T& operator[](const int &flatidx) const { return data[flatidx]; }\n};\n\nvoid fft(MultiDimArray &A, int type) {\n\tREPSZ(fftdim, A.dim) {\n\t\tvector> tmp(SZ(A.data) / A.dim[fftdim], vector(A.dim[fftdim]));\n\t\tREPSZ(i, A.data) { pair split = A.splitidx(i, fftdim); tmp[split.first][split.second] = A[i]; }\n\t\tREPSZ(i, tmp) fft(tmp[i].data(), A.dim[fftdim], type);\n\t\tREPSZ(i, A.data) { pair split = A.splitidx(i, fftdim); A[i] = tmp[split.first][split.second]; }\n\t}\n}\n\nMultiDimArray multiply(const MultiDimArray &A, const MultiDimArray &B, int mod) {\n\tassert(A.dim == B.dim); vector dim = A.dim;\n\tvector ndim(SZ(dim)); REPSZ(i, dim) { ndim[i] = 1; while (2 * dim[i] > ndim[i]) ndim[i] *= 2; }\n\tMultiDimArray AA(ndim); REPSZ(i, A.data) AA[A.idx(i)] = complex(A[i], 0);\n\tMultiDimArray BB(ndim); REPSZ(i, B.data) BB[B.idx(i)] = complex(B[i], 0);\n\tfft(AA, +1);\n\tfft(BB, +1);\n\tREPSZ(i, AA.data) AA[i] = AA[i] * BB[i];\n\tfft(AA, -1);\n\tMultiDimArray ret(dim);\n\tREPSZ(i, AA.data) {\n\t\tvector nidx = AA.idx(i), idx(SZ(dim)); REPSZ(i, nidx) idx[i] = nidx[i] % dim[i];\n\t\tint cur = ((ll)floor(AA[i].x / SZ(AA.data) + 0.5) % mod + mod) % mod;\n\t\tret[idx] = (ret[idx] + cur) % mod;\n\t}\n\treturn ret;\n}\n\n// Convert sum(i,j: ai*bj*x^(ci*dj)) mod p to sum(k: sum(i,j st ci*dj=k mod p-1: ai*bj)*x^k)\n// Only supports unique primes in factorization of p-1\nstruct ExponentialResidueConvolution {\n\tint p;\n\tvector pp; // factorization of p-1\n\tvector proot;\n\tvector> exp;\n\tvector> lg;\n\tvector crt;\n\n\tExponentialResidueConvolution(int _p) {\n\t\tp = _p;\n\t\tpp = getprimes(p - 1); { int chk = 1; REPSZ(i, pp) chk *= pp[i]; assert(chk == p - 1); }\n\t\t//printf(\"pp:\"); REPSZ(i, pp) printf(\" %d\", pp[i]); puts(\"\");\n\t\tproot = vector(SZ(pp)); lg = exp = vector>(SZ(pp));\n\t\tREPSZ(i, pp) {\n\t\t\tlg[i] = vector(pp[i], -1); exp[i] = vector(pp[i] - 1);\n\t\t\tproot[i] = findprimitiveroot(pp[i]);\n\t\t\tfor (int n = 0, x = 1; n < pp[i] - 1; ++n, x = (ll)x*proot[i] % pp[i]) exp[i][n] = x, lg[i][x] = n;\n\t\t\t//printf(\"%d (proot=%d):\", pp[i], proot[i]); REPSZ(j, lg[i]) printf(\" %d\", lg[i][j]); puts(\"\");\n\t\t}\n\t\tcrt = vector(p - 1, -1); REP(i, p - 1) { int crtidx = 0, prod = 1; REPSZ(idx, pp) { crtidx += i%pp[idx] * prod; prod *= pp[idx]; } assert(crt[crtidx] == -1); crt[crtidx] = i; }\n\t}\n\n\tMultiDimArray build(vector coef, vector exp, int mymask, int totmask, vector dim) {\n\t\tMultiDimArray ret(dim);\n\t\tREPSZ(i, exp) {\n\t\t\tbool ok = true; vector idx;\n\t\t\tREPSZ(j, pp) {\n\t\t\t\tint rem = exp[i] % pp[j];\n\t\t\t\tbool wantzero = (mymask & (1 << j)) != 0, havezero = rem == 0; if (wantzero != havezero) { ok = false; break; }\n\t\t\t\tbool isused = (totmask&(1 << j)) == 0 && pp[j] != 2; if (isused) idx.PB(lg[j][rem]);\n\t\t\t}\n\t\t\tif (ok) ret[idx] = (ret[idx] + coef[i]) % p;\n\t\t}\n\t\treturn ret;\n\t}\n\n\tvector solve(vector a, vector b, vector c, vector d) {\n\t\tMultiDimArray invcrt(pp); REP(i, p - 1) { vector idx; REPSZ(j, pp) idx.PB(i%pp[j]); invcrt[idx] = i; }\n\t\tvector ret(p - 1, 0);\n\t\tREP(imask, 1 << SZ(pp)) REP(jmask, 1 << SZ(pp)) {\n\t\t\tint kmask = imask | jmask;\n\t\t\tvector dim; REPSZ(j, pp) if ((kmask & (1 << j)) == 0 && pp[j] != 2) dim.PB(pp[j] - 1);\n\t\t\tMultiDimArray A = build(a, c, imask, kmask, dim);\n\t\t\tMultiDimArray B = build(b, d, jmask, kmask, dim);\n\t\t\tMultiDimArray C = multiply(A, B, p);\n\t\t\tREPSZ(flatidx, C.data) {\n\t\t\t\tvector idx = C.idx(flatidx);\n\t\t\t\tvector crtidx; int at = 0; REPSZ(j, pp) if ((kmask & (1 << j)) != 0) crtidx.PB(0); else if (pp[j] == 2) crtidx.PB(1); else crtidx.PB(exp[j][idx[at++]]);\n\t\t\t\tint k = invcrt[crtidx]; ret[k] = (ret[k] + C[idx]) % p;\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t}\n};\n\nconst int MAXN = 100000;\nconst int MOD = 490019;\n\nint na, nb, c;\nint a[MAXN], b[MAXN];\n\nExponentialResidueConvolution erc(MOD);\n\nint solve() {\n\tvector a(na), c(na); REP(i, na) a[i] = ::a[i] % MOD, c[i] = (ll)i*i % (MOD - 1);\n\tvector b(nb), d(nb); REP(i, nb) b[i] = ::b[i] % MOD, d[i] = (ll)i*i*i % (MOD - 1);\n\tvector res = erc.solve(a, b, c, d);\n\tint ret = 0; REPSZ(i, res) ret = (ret + (ll)res[i] * pw(::c, i, MOD)) % MOD; return ret;\n}\n\nvoid run() {\n\tscanf(\"%d%d%d\", &na, &nb, &c);\n\tREP(i, na) scanf(\"%d\", &a[i]);\n\tREP(i, nb) scanf(\"%d\", &b[i]);\n\tprintf(\"%d\\n\", solve());\n}\n\nvector bfsolve(vector a, vector b, vector c, vector d,int mod) {\n\tint na = SZ(a), nb = SZ(b);\n\tvector ret(mod - 1, 0);\n\tREP(i, na) REP(j, nb) { int idx = (ll)c[i] * d[j] % (mod - 1); ret[idx] = (ret[idx] + (ll)a[i] * b[j]) % mod; }\n\treturn ret;\n}\n\nvoid stress() {\n\t//int mod = 2 * 3 * 5 + 1;\n\t//int mod = 2 * 17 * 19 + 1;\n\tint mod = MOD;\n\t//int mod = 2 * 3 * 5 * 7 + 1;\n\t//int mod = 2 * 3 * 5 * 7 * 11 + 1;\n\tExponentialResidueConvolution erc(mod);\n\tREP(rep, 10000) {\n\t\tint na = rand() % 100, nb = rand() % 100;\n\t\tvector a(na), c(na); REP(i, na) a[i] = rand() % mod, c[i] = rand() % (mod - 1);\n\t\tvector b(nb), d(nb); REP(i, nb) b[i] = rand() % mod, d[i] = rand() % (mod - 1);\n\t\tvector have = erc.solve(a, b, c, d);\n\t\tvector want = bfsolve(a, b, c, d, mod);\n\t\tif (have == want) { printf(\".\"); continue; }\n\t\tprintf(\"err (%d)\\n\",rep);\n\t\tprintf(\"a:\"); REPSZ(i, a) printf(\" %d\", a[i]); puts(\"\");\n\t\tprintf(\"c:\"); REPSZ(i, c) printf(\" %d\", c[i]); puts(\"\");\n\t\tprintf(\"b:\"); REPSZ(i, b) printf(\" %d\", b[i]); puts(\"\");\n\t\tprintf(\"d:\"); REPSZ(i, d) printf(\" %d\", d[i]); puts(\"\");\n\t\tprintf(\"have:\"); REPSZ(i, have) printf(\" %d\", have[i]); puts(\"\");\n\t\tprintf(\"want:\"); REPSZ(i, want) printf(\" %d\", want[i]); puts(\"\");\n\t\texit(0);\n\t}\n}\n\nvoid stress2() {\n\tint mod = MOD;\n\tExponentialResidueConvolution erc(mod);\n\tREP(rep, 10) {\n\t\tint na = MAXN, nb = MAXN;\n\t\tvector a(na), c(na); REP(i, na) a[i] = rand() % mod, c[i] = rand() % (mod - 1);\n\t\tvector b(nb), d(nb); REP(i, nb) b[i] = rand() % mod, d[i] = rand() % (mod - 1);\n\t\tvector have = erc.solve(a, b, c, d);\n\t\tprintf(\".\");\n\t}\n\n}\n\nint main() {\n\trun();\n\t//stress();\n\t//stress2();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "915642ad1368fb2d22598b2977dee92f", "src_uid": "032ea64ed7e2467c1f503dac185523f7", "difficulty": 3500.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define ll long long\n#define mod 490019\n#define Mod 245009\n#define mod1 491\n#define mod2 499\n#define pow D\n\nstruct node\n{\n\tdouble x,y;\n\tnode() {}\n\tnode(double xx,double yy):x(xx),y(yy) {}\n}*pow[21],a[1048576],b[1048576];\n\nconst double pi=acos(-1.0);\n\ninline node operator +(const node &x,const node &y) { return node(x.x+y.x,x.y+y.y); }\ninline node operator -(const node &x,const node &y) { return node(x.x-y.x,x.y-y.y); }\ninline node operator *(const node &x,const node &y) { return node(x.x*y.x-x.y*y.y,x.x*y.y+x.y*y.x); }\ninline node operator /(const node &x,const double &y) { return node(x.x/y,x.y/y); }\n\nll f[1048576],sum[500010],sum1[500010],sum2[500010],bin[500010],c;\nint num1[100010],num2[100010],id1[510],id2[510],bin1[510],bin2[510],n,m,Inv1,Inv2;\n\ninline int rd()\n{\n\tint x=0;char ch=getchar();\n\tfor (;ch<'0'||ch>'9';ch=getchar());\n\tfor (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';\n\treturn x;\n}\n\ninline ll pls(const ll &x,const ll &y) { return (x+y>=1,x=x*x%p) if (y&1) res=res*x%p;return res; }\n\ninline void pre_gao()\n{\n\tfor (int w=2,hh=1;w<=1048576;w<<=1,hh++)\n\t{\n\t\tpow[hh]=new node[w>>1];\n\t\tfor (int j=0;j<(w>>1);j++) pow[hh][j]=node(cos(pi*2*j/w),sin(pi*2*j/w));\n\t}\n\tid1[1]=0;int now=1;\n\tfor (int i=1;i>1]>>1)|((i&1)?(n>>1):0);\n\tfor (int i=1;i>1);j++)\n\t{\n\t\tnode u=a[j],t=a[j+(w>>1)]*pow[hh][j-k];\n\t\ta[j]=u+t;a[j+(w>>1)]=u-t;\n\t}\n\tif (on==-1)\n\t{\n\t\treverse(a+1,a+n);\n\t\tfor (int i=0;i=Mod)?hh+h[i]-Mod:hh+h[i]) f[hh]+=c[h[i]]*d[j]+d[h[i]]*c[j];\n\tfor (int i=1;i<=tt;i++) for (int j=1;j<=tt;j++) f[h[i]*h[j]%Mod]-=c[h[i]]*d[h[j]];\n\tfor (int i=0;i=Mod)?hh+h[i]-Mod:hh+h[i]) f[hh]+=c[h[i]]*d[j]+d[h[i]]*c[j];\n\tfor (int i=1;i<=tt;i++) for (int j=1;j<=tt;j++) f[h[i]*h[j]%Mod]-=c[h[i]]*d[h[j]];\n\tfor (int i=0;i\nusing namespace std;\nint main(){\n\tint i;\n\tbool flag=false;\n\tstring card[6];\n\tcin>>card[0];\n\tfor(i=1;i<6;i++)\n\t\tcin>>card[i];\n\tfor(i=1;i<6;i++){\n\t\tif(card[0].substr(0,1)==card[i].substr(0,1)){\n\t\t\tflag=true;\n\t\t\tcout<<\"Yes\";\n\t\t\texit(0);\n\t\t}\t\n\t}\n\tfor(i=1;i<6;i++){\n\t\tif(card[0].substr(1,1)==card[i].substr(1,1)){\n\t\t\tflag=true;\n\t\t\tcout<<\"Yes\";\n\t\t\texit(0);\n\t\t}\t\n\t}\n\tif(flag==false)\n\t\tcout<<\"No\";\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4e63577a29794e56b48e2e1c17a4c688", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n string n ;\n cin >> n ;\n string n11 , n12 , n13 , n14 , n15 ;\n cin >> n11 >> n12 >> n13 >> n14 >> n15 ;\n if (n[0] = n11[0] || n[0] = n12[0] || n[0] = n13[0] || n[0] = n14[0] || n[0] = n15)cout << \"YES\" ;\n else cout << \"NO\" ;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "859bf3905e1d2b505becc0009e4d65bf", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\nint main() {\n\n string input[2], cards[5][2];\n cin >> input;\n for (int i = 0; i < 5; i++)\n cin >> cards[i]\n for (int i = 0; i < count; i++)\n {\n if (input[0] == cards[i][0])\n {\n cout << \"YES\";\n return 0;\n }\n else if (input[1] == cards[i][1])\n {\n cout << \"YES\";\n return 0;\n }\n }\n cout << \"NO\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e4ed0607f5198df1c9f8688afff241c5", "src_uid": "699444eb6366ad12bc77e7ac2602d74b", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n \nusing namespace std;\n \nint main()\n{\n char a[2], b[200], ;\n cin.getline(a, sizeof(a));\n cin.getline(b, sizeof(b));\n \n for(int i = 0; i\n#include \n\nusing namespace std;\n\nint main()\n{\n freopen (\"INPUT.txt\", \"r\", stdin);\n freopen (\"OUTPUT.txt\", \"w\", stdout);\n int k = 0;\n string s, s1, s2;\n cin >> s >> s1 >> s2;\n\n if (s1[0] == 'T')\n s1[0] = '10';\n if (s1[0] == 'J')\n s1[0] = '11';\n if (s1[0] == 'Q')\n s1[0] = '12';\n if(s1[0] == 'K')\n s1[0] = '13';\n\n if (s2[0] == 'T')\n s2[0] = '10';\n if (s2[0] == 'J')\n s2[0] = '11';\n if (s2[0] == 'Q')\n s2[0] = '12';\n if (s2[0] == 'K')\n s2[0] == '13';\n\n if ((s1[1] != s[0] && s2[1] != s[0]) || (s1[1] == s[0] && s2[1] == s[0]))\n {\n if ((s1[0] == '6' && s2[0] == 'A') || (s1[0] - '0' > s2[0] - '0'))\n k ++;\n }\n if (s1[1] == s[0] && s2[1] != s[0])\n k ++;\n if (k > 0)\n cout << \"YES\";\n else cout << \"NO\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a9721e9c075e2a37755cccad5ef412aa", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint rank(char c){\n const char* ltt=\"6789TJQKA\";\n char* find=const_cast(ltt);\n while (*find!=c)++find;\n return find-ltt;\n}\n\nint main(){\n char suit[105],card1[105], card2[105]; \n\tcin>>suit>>card1>>card2; \n if((card1[1]==suit[0] && card2[1]!=suit[0])||(card1[1] == card2[1] && rank(card1[0]) > rank(card2[0])))printf( \"YES\" );\n\telse printf(\"NO\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ceeeadfb3751b05131f467d8f2a8b58d", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include\n\nusing namespace std;\n\nint main()\n{\n int i,j ;\n char trump ;\n char r[9]={'6','7','8','9','T','J','Q','K','A'} ;\n char T1[2] ;\n char T2[2] ;\n\n cin>>trump ;\n\n\n for(i=0;i<2;i++)\n cin>>T1[i] ;\n for(i=0;i<2;i++)\n cin>>T2[i] ;\n\n\n if((T1[1]==trump) && (T2[1]!=trump)\n cout<<\"YES\" ;\n else\n {\n i=0 ; j=0 ;\n for(i=0;i<9;i++)\n if(T1[0]==r[i]) break ;\n\n for(j=0;j<9;j++)\n if(T2[0]==r[j]) break ;\n\n if(i>j) cout<<\"YES\" ;\n else cout<<\"NO\" ;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ce5ae6442694d25d261e4412a41f80a6", "src_uid": "da13bd5a335c7f81c5a963b030655c26", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "/**\nauthor : Ahmed Said Enaba\nuniversity : Cairo\nfaculty : FCI\nif you interested with me see this\nhttp://www.e-quran.com/indx-pg.html\n**/\n\n/**\nthis is mini cade c++ for repetation use\n\n=================\nsubstring\n\nstr.substr(0,3)\nstr.substr(5)\n==================\n index of the first occurance of special char\n\n string x=\"123.113.21\";\n cout<= 'A') {\n x[i] = tolower(x[i]);\n }\n else if (x[i] <= 'z' && x[i] >= 'a') {\n x[i] = toupper(x[i]);\n }\n else{}\n}\n cout<>x;\n reverse(x.begin(), x.end());\n cout << x << endl;\n=============================================================\ncout<capital Z\ncout<small z\n cout<< ('1'-'0')< integer 1 \n==============================================================\npush_back() in string c++\n\nstring str;\n char x;\n for(int i=0;i<5;i++){\n cin>>x;\n str.push_back(x);\n }\n \n cout << str <\n#include \nusing namespace std;\nstring x = \"45\";\nistringstream buffer(x);\nint value;\nbuffer >> value; // value = 45 \ncout << value+10 <adj(101); // vector of size 100\nvector adj[101]; // vector of size 100 bu4eel array ==> vector of array\nnote the defferance between () and []\nvector < vector > adj(101); vector of size 100 bu4eel \nvector ==> vector of vector\nvector of array == vector of vector \nthis implementation good for vector of array \nand vector of vector \n int n;\n\tint m;\n\tcin>>n>>m;\n\tfor(int i=0;i<101;i++){\n\tadj[i].push_back(i);\n\tadj[i].push_back(i);\n\tadj[i].push_back(i);\n }\nfor(int i=0;i<101;i++){\ncout<<\"size \"<v;\nv.clear();\n=======================================================\nsort vector ftom small to greater\n\n vectorv;\n sort(v.begin(), v.end());\n=======================================================\nsort from greater to lower\n\nvectorv;\nsort(v.rbegin(), v.rend()) ;\n=======================================================\nreverse vector c++\n\nreverse(v.begin(), v.end());\n=======================================================\nremove repetation value fron vector\n\n1 2 3 4 1 2 1 1\nvectorv;\nv.erase( remove(v.begin(), v.end(), 1 ), v.end()); \n// remove all value that equal 1\n=========================================================== \nsort array\n\nint arr[n] = {5, 3, 32, -1, 1, 104, 53};\n sort(arr,arr+n);\n \n for (size_t i = 0; i != n; ++i)\n cout << arr[i] << \" \";\n=================================================================\ncalculate how many occurance of each number \n\nex 1 2 3 1 2 3 1 2\n1==>3 times\n2==>3 times\n3==>2 times\nuse map pf integer\nmapm;\nint x;\ncin>>x;\nm[x]++;\ncout<first<second< > v;\n for(int i=0;i<4;i++){\n int x,y;\n cin>>x>>y;\n v.push_back(pair (x, y));\n}\nto sort vecyor we should sort all pairs depend on first and second\nwe need function return bool \nlike this ===>\n/*\nbool sortfunction int> p1, pair p2){\n\n return (p1.first < p2.second);\n}\n/// sort vector with the name of function \n sort(v.begin(), v.end(), sortfunction);\n//print vector of pair \nfor(int i=0;i<4;i++){\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nstring rank=\"6789TJQKA\", suit=\"SHDC\" ;\nint index(char x){\nfor(int i=0;i>s;\nstring w1,w2; cin>>w1>>w2;\nif(w1[1] == w2[1]){\n \nif(index(w1[0]) > index(w2[0])){cout<<\"YES\"<\nusing namespace std;\n\nint a, c[100000], m;\n\nint main(){\n\tcin >> a >> m;\n\tfor(int i = 0;i> c[i];\n\t}\n\tfor(int i = a-1;i>=0;i--){\n\t\tif(c[i]>m){\n\t\t\tcout << i+1;\n\t\t\treturn 0;\n\t\t}\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fa3725a5ed162625bb192cebe8be94ff", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include\n#inc\nusing namespace std;\nint main()\n{\n int n, m;\n cin>>n>>m;\n int arr[n];\n for(int i=0;i>arr[i];\n int ans = ceil(arr[0]/m), last =i;\n for(int i=1;i\n#include\nusing namespace std;\nmain()\n{\n vector > d;\n int n,m,a;\n cin>>n>>m;\n int i=0;\n while(++i<=n)\n {\n cin>>a;\n d.push_back(pair(a,i));\n }\n vector > ::iterator itr=d.begin();\n while(d.size()>1)\n {\n if(itr->first<=m)\n {\n d.erase(itr->first);\n }\n else\n {\n d.push_back(pair(itr->first-m,itr->second));\n d.erase(itr->first);\n }\n }\n cout<second;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "58351d468e5fccc773cb1928b130368a", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n#define ll long long\n#define vi vector\n#define rep(i,a,b) for(int i=a;i>n>>m;\n int max(0),pos;\n rep(i,0,n){\n cin>>a[i];\n if(ceil(a[i]/m)>=max){\n max=ceil(a[i]/m);\n pos=i+1;\n }\n }\n cout<\n\nusing namespace std;\n\ntypedef unsigned short ushort;\ntypedef unsigned int uint;\ntypedef long long ll;\ntypedef unsigned long long ull;\n\ntemplate \nostream &operator<<(ostream &cout, vector &a){\n for(ull i = 0; i < a.size(); ++i)\n cout << a[i] << \" \";\n return cout;\n}\n\ntemplate \nostream &operator<<(ostream &cout, vector > &a){\n for(ull i = 0; i < a.size(); ++i)\n cout << a[i] << endl;\n return cout;\n}\n\nint main()\n{\n int n;\n cin >> n;\n string s;\n cin >> s;\n int start = 0, size = 0;\n for(int i = 0; i < n; ++i){\n if(s[i] == 'o'){\n if(size % 2 == 0)\n ++size;\n else{\n if(size >= 3){\n if(size % 2)\n cout << \"***\";\n else\n cout << \"***\" << s[i - 1];\n }else{\n for(int j = start; j < i; ++j)\n cout << s[j];\n }\n size = 1;\n start = i;\n }\n }else if(s[i] == 'g'){\n if(size % 2 == 1)\n ++size;\n else{\n if(size >= 3){\n if(size % 2)\n cout << \"***\";\n else\n cout << \"***\" << s[i - 1];\n }else{\n for(int j = start; j < i; ++j)\n cout << s[j];\n }\n cout << s[i];\n size = 0;\n start = i + 1;\n }\n }else{\n if(size >= 3){\n if(size % 2)\n cout << \"***\";\n else\n cout << \"***\" << s[i - 1];\n }else{\n for(int j = start; j < i; ++j)\n cout << s[j];\n }\n cout << s[i];\n size = 0;\n start = i + 1;\n }\n }\n if(size >= 3){\n if(size % 2)\n cout << \"***\";\n else\n cout << \"***g\";\n }else{\n for(int j = start; j < i; ++j)\n cout << s[j];\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "346a0add5c6d0a16a4c6395153c93227", "src_uid": "619665bed79ecf77b083251fe6fe7eb3", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include \nvoid func(string *x, int i){\n int n=x.size();\n int j=i;\n while(j=n)\n return;\n if(x[j+1]=='g'&& x[j+2]=='o'){\n cout<<\"***\";\n j=j+2;\n }\n while(x[j+1]=='g'&& x[j+2]=='o')\n j=j+2;\nreturn func(x, j-2);\n \n \n}\n \nusing namespace std;\nint main(){\n string y;\n getline(cin,y);\n func(y,0);\n return 0;\n \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2d865b14d90c4397ab812697c03d505e", "src_uid": "619665bed79ecf77b083251fe6fe7eb3", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \nusing namespace std;\n \n#define pb push_back\n#define eb emplace_back\n#define mp make_pair\n#define sqr(x) ((x) * (x))\n#define sz(x) (int)x.size()\n#define all(x) x.begin(), x.end()\n#define frp freopen(\"input.txt\", \"r\", stdin); \\\n freopen(\"output.txt\", \"w\", stdout); \n \ntypedef long long ll;\ntypedef vector vi;\ntypedef pair pii;\ntypedef pair pll;\n \nconst double eps = 1e-6;\nconst double pi = acos(-1.0);\nconst int maxn = (int)1e5+ 5;\nconst int inf = (int)2e9;\nconst int mod = (int)1e9 + 7;\n\nint main(){ //frp\n\tint n; scanf(\"%d\", &n);\n\tstring s; cin >> s;\n\tregex r (\"(ogo)(go)*\");\n\tcout << regex_replace (s, r, \"***\");\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "337af919297eb6b447ba95ad463b5c83", "src_uid": "619665bed79ecf77b083251fe6fe7eb3", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n cout << \"Khai dep trai ahihi\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3a1458d4f58576254c70ba194229a486", "src_uid": "619665bed79ecf77b083251fe6fe7eb3", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "// eddy1021\n#include \nusing namespace std;\ntypedef double D;\ntypedef long double LD;\ntypedef long long ll;\ntypedef long long LL;\ntypedef pair PII;\ntypedef pair PLL;\ntypedef pair Pt;\ntypedef tuple tiii;\ntypedef tuple tlll;\n#define mod9 1000000009ll\n#define mod7 1000000007ll\n#define INF 1023456789ll\n#define INF16 10000000000000000ll\n#define FI first\n#define SE second\n#define X FI\n#define Y SE\n#define PB push_back\n#define MP make_pair\n#define MT make_tuple\n#define eps 1e-9\n#define SZ(x) (int)(x).size()\n#define ALL(x) (x).begin(), (x).end()\n#ifndef ONLINE_JUDGE\n#define debug(...) printf(__VA_ARGS__)\n#else \n#define debug(...)\n#endif\ninline ll getint(){\n ll _x=0,_tmp=1; char _tc=getchar(); \n while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();\n if( _tc == '-' ) _tc=getchar() , _tmp = -1;\n while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();\n return _x*_tmp;\n}\ninline ll add( ll _x , ll _y , ll _mod = mod7 ){\n ll _ = _x + _y;\n if( _ >= _mod ) _ -= _mod;\n return _;\n}\ninline ll sub( ll _x , ll _y , ll _mod = mod7 ){\n ll _ = _x - _y;\n if( _ < 0 ) _ += _mod;\n return _;\n}\ninline ll mul( ll _x , ll _y , ll _mod = mod7 ){\n ll _ = _x * _y;\n if( _ >= _mod ) _ %= _mod;\n return _;\n}\nll mypow( ll _a , ll _x , ll _mod ){\n if( _x == 0 ) return 1ll;\n ll _tmp = mypow( _a , _x / 2 , _mod );\n _tmp = mul( _tmp , _tmp , _mod );\n if( _x & 1 ) _tmp = mul( _tmp , _a , _mod );\n return _tmp;\n}\nll mymul( ll _a , ll _x , ll _mod ){\n if( _x == 0 ) return 0ll;\n ll _tmp = mymul( _a , _x / 2 , _mod );\n _tmp = add( _tmp , _tmp , _mod );\n if( _x & 1 ) _tmp = add( _tmp , _a , _mod );\n return _tmp;\n}\ninline bool equal( D _x , D _y ){\n return _x > _y - eps && _x < _y + eps;\n}\nint __ = 1 , _cs;\n/*********default*********/\n#define N 55\nint C[ N ][ N ];\nvoid build(){\n for( int i = 0 ; i < N ; i ++ )\n C[ i ][ 0 ] = C[ i ][ i ] = 1;\n for( int i = 2 ; i < N ; i ++ )\n for( int j = 1 ; j < i ; j ++ )\n C[ i ][ j ] = add( C[ i - 1 ][ j ], C[ i - 1 ][ j - 1 ] );\n}\nint n , k , cnt[ 2 ];\nvoid init(){\n n = getint();\n k = getint() / 50;\n for( int i = 0 ; i < n ; i ++ )\n cnt[ getint() / 50 - 1 ] ++;\n}\nPII dp[ N ][ N ][ 2 ];\nqueue< tuple< int , int , int > > Q;\ninline void go(){\n dp[ cnt[ 0 ] ][ cnt[ 1 ] ][ 0 ] = { 0 , 1 };\n Q.push( MT( cnt[ 0 ] , cnt[ 1 ] , 0 ) );\n while( Q.size() ){\n tiii tp = Q.front(); Q.pop();\n int c0 = get<0>( tp );\n int c1 = get<1>( tp );\n int sd = get<2>( tp );\n if( sd == 0 ){\n for( int i = 0 ; i <= c0 ; i ++ )\n for( int j = 0 ; j <= c1 ; j ++ ){\n if( i + j == 0 ) continue;\n if( i + 2 * j > k ) break;\n int dlt = mul( dp[ c0 ][ c1 ][ sd ].SE , mul( C[ c0 ][ i ] , C[ c1 ][ j ] ) );\n if( dp[ c0 - i ][ c1 - j ][ 1 - sd ].FI == -1 ){\n dp[ c0 - i ][ c1 - j ][ 1 - sd ] = { dp[ c0 ][ c1 ][ sd ].FI + 1 , dlt };\n Q.push( { c0 - i , c1 - j , 1 - sd } );\n }else if( dp[ c0 - i ][ c1 - j ][ 1 - sd ].FI == dp[ c0 ][ c1 ][ sd ].FI + 1 ){\n dp[ c0 - i ][ c1 - j ][ 1 - sd ].SE = add( dp[ c0 - i ][ c1 - j ][ 1 - sd ].SE , dlt );\n }\n }\n }else{\n for( int i = 0 ; i <= cnt[ 0 ] - c0 ; i ++ )\n for( int j = 0 ; j <= cnt[ 1 ] - c1 ; j ++ ){\n if( i + j == 0 ) continue;\n if( i + 2 * j > k ) break;\n int dlt = mul( dp[ c0 ][ c1 ][ sd ].SE , mul( C[ cnt[ 0 ] - c0 ][ i ] , C[ cnt[ 1 ] - c1 ][ j ] ) );\n if( dp[ c0 + i ][ c1 + j ][ 1 - sd ].FI == -1 ){\n dp[ c0 + i ][ c1 + j ][ 1 - sd ] = { dp[ c0 ][ c1 ][ sd ].FI + 1 , dlt };\n Q.push( { c0 + i , c1 + j , 1 - sd } );\n }else if( dp[ c0 + i ][ c1 + j ][ 1 - sd ].FI == dp[ c0 ][ c1 ][ sd ].FI + 1 ){\n dp[ c0 + i ][ c1 + j ][ 1 - sd ].SE = add( dp[ c0 + i ][ c1 + j ][ 1 - sd ].SE , dlt );\n }\n }\n }\n }\n}\nvoid solve(){\n for( int i = 0 ; i <= cnt[ 0 ] ; i ++ )\n for( int j = 0 ; j <= cnt[ 1 ] ; j ++ )\n dp[ i ][ j ][ 0 ] = dp[ i ][ j ][ 1 ] = { -1 , 0 };\n go();\n printf( \"%d\\n%d\\n\" , dp[ 0 ][ 0 ][ 1 ].FI , dp[ 0 ][ 0 ][ 1 ].SE );\n}\nint main(){\n build();\n //__ = getint();\n while( __ -- ){\n init();\n solve();\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3450a94127635ee0b6f234b45b8e5b41", "src_uid": "ebb0323a854e19794c79ab559792a1f7", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nstruct node{\n\tint f;\n\tint s;\n\tint t;\n};\n\nnode M_N(int a, int c, int d)\n{\n\tnode x;\n\tx.f = a;\n\tx.s = c;\n\tx.t = d;\n\treturn x;\n}\n\ntypedef long long ll;\n\nconst int MAXN = 60, MOD = 1000 * 1000 * 1000 + 7;\nll dist[MAXN][MAXN][2], t[MAXN][MAXN][2];\nint mark[MAXN][MAXN][2];\nll ch[MAXN][MAXN];\nint k, n;\nint t1, t2;\n\nvoid bfs(node strt)\n{\n\tmark[strt.f][strt.s][strt.t] = true;\n\tdist[strt.f][strt.s][strt.t] = 0;\n\tt[strt.f][strt.s][strt.t] = 1;\n\n\tqueue q;\n\tq.push(strt);\n\twhile(!q.empty())\n\t{\n\t\tnode v = q.front();\n\t\tq.pop();\n\t\tmark[v.f][v.s][v.t] = 2;\n\n\t\tfor(int i = 0; i <= t1; i++)\n\t\t\tfor(int j = 0; j <= t2; j++)\n\t\t\t{\n\t\t\t\tif(v.t == 0 && (v.f < i || v.s < j))\n\t\t\t\t\tcontinue;\n\t\t\t\tif(v.t == 1 && (v.f > i || v.s > j))\n\t\t\t\t\tcontinue;\n\n\t\t\t\tif(!mark[i][j][1 - v.t])\n\t\t\t\t{\n\t\t\t\t\tint w = abs(i - v.f) * 50 + abs(j - v.s) * 100;\n\t\t\t\t\tif(w != 0 && w <= k)\n\t\t\t\t\t{\n\t\t\t\t\t\tdist[i][j][1 - v.t] = dist[v.f][v.s][v.t] + 1;\n\n\t\t\t\t\t\tint add = 1;\n\t\t\t\t\t\tif(v.t == 0)\n\t\t\t\t\t\t\tadd = ch[v.f][abs(i - v.f)] * ch[v.s][abs(j - v.s)];\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tadd = ch[t1 - v.f][abs(i - v.f)] * ch[t2 - v.s][abs(j - v.s)];\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\tt[i][j][1 - v.t] = t[v.f][v.s][v.t] * add;\n\t\t\t\t\t\tt[i][j][1 - v.t] %= MOD;\n\n\t\t\t\t\t\tmark[i][j][1 - v.t] = 1;\n\t\t\t\t\t\tq.push(M_N(i, j, 1 - v.t));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if(mark[i][j][1 - v.t] == 1)\n\t\t\t\t{\n\t\t\t\t\tint w = abs(i - v.f) * 50 + abs(j - v.s) * 100;\n\t\t\t\t\tif(w != 0 && w <= k && dist[v.f][v.s][v.t] + 1 == dist[i][j][1 - v.t])\n\t\t\t\t\t{\n\t\t\t\t\t\tint add = 1;\n\t\t\t\t\t\tif(v.t == 0)\n\t\t\t\t\t\t\tadd = ch[v.f][abs(i - v.f)] * ch[v.s][abs(j - v.s)];\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tadd = ch[t1 - v.f][abs(i - v.f)] * ch[t2 - v.s][abs(j - v.s)];\n\t\t\t\t\t\tt[i][j][1 - v.t] += t[v.f][v.s][v.t] * add;\n\t\t\t\t\t\tt[i][j][1 - v.t] %= MOD;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t}\n}\n\nint main()\n{\n\n\tcin>> n >> k;\n\n\tfor(int i = 0; i < n; i++)\n\t{\n\t\tint a;\n\t\tcin>> a;\n\t\tif(a == 100)\n\t\t\tt2 ++;\n\t\telse\n\t\t\tt1 ++;\n\t}\n\t\n\tfor(int i = 0; i <= n; i++)\n\t\tfor(int j = 0; j <= i; j++)\n\t\t\tif(i == j || j == 0)\n\t\t\t\tch[i][j] = 1;\n\t\t\telse\n\t\t\t\tch[i][j] = (ch[i - 1][j - 1] + ch[i - 1][j]) % MOD;\n\n\n\tfor(int i = 0; i <= n; i++)\n\t\tfor(int j = 0; j <= n; j++)\n\t\t\tdist[i][j][0] = dist[i][j][1] = INT_MAX;\n\tbfs(M_N(t1, t2, 0));\n\n\tif(dist[0][0][1] == INT_MAX)\n\t\tdist[0][0][1] = -1;\n\tcout<< dist[0][0][1] << endl;\n\tcout<< t[0][0][1] << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e960ac0cfe62bd171d8003796e62d6b8", "src_uid": "ebb0323a854e19794c79ab559792a1f7", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\n#include \n#include \n#include \n#include \n#include \n#include \n#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)\n#define endl \"\\n\"\nusing namespace std;\ntypedef long long ll;\nconst ll mod=1e9 + 7;\nll n,k,p1,p2,ncr[55][55];\nstruct node{\n ll w1,w2,side;\n node(ll x,ll y,ll z){\n w1=x;\n w2=y;\n side=z;\n }\n};\nqueue q;\nll steps[55][55][2],ways[55][55][2];\nvoid bfs(){\n node cur(p1,p2,0);\n node p(1,1,0);\n q.push(cur);\n ll n1,n2;\n while(!q.empty()){\n cur=q.front();\n q.pop();\n for(int i=0;i<=cur.w1;i++){\n for(int j=0;j<=cur.w2;j++){\n if((j!=0 || i!=0) && ((i*50+j*100)<=k)){\n n1=p1-cur.w1+i;\n n2=p2-cur.w2+j;\n if(steps[n1][n2][1-cur.side]==-1){\n steps[n1][n2][1-cur.side]=1+steps[cur.w1][cur.w2][cur.side];\n ways[n1][n2][1-cur.side]=(ways[cur.w1][cur.w2][cur.side]*(ncr[cur.w1][i])*(ncr[cur.w2][j]))%mod;\n p.w1=n1;\n p.w2=n2;\n p.side=1-cur.side;\n q.push(p);\n }\n else if(steps[n1][n2][1-cur.side]==1+steps[cur.w1][cur.w2][cur.side]){\n ways[n1][n2][1-cur.side]=(ways[n1][n2][1-cur.side]+ways[cur.w1][cur.w2][cur.side]*(ncr[cur.w1][i])*(ncr[cur.w2][j]))%mod;\n }\n }\n }\n }\n }\n}\nint main()\n{\n fio;\n cin>>n>>k;\n ll x;\n p1=0;p2=0;\n for(int i=1;i<=n;i++){\n cin>>x;\n if(x==50)\n p1++;\n else\n p2++;\n }\n for(int i=0;i<=n;i++)\n ncr[i][0]=1;\n ncr[1][1]=1;\n for(int i=2;i<=n;i++){\n for(int j=1;j<=i;j++){\n ncr[i][j]=(ncr[i-1][j]+ncr[i-1][j-1])%mod;\n }\n }\n memset(steps, -1, sizeof(steps));\n memset(ways, 0, sizeof(ways));\n steps[p1][p2][0]=0;\n ways[p1][p2][0]=1;\n bfs();\n cout<\nusing namespace std;\n\n#define LL long long int\n#define UL unsigned long long int\n\n#define imax INT_MAX\n#define imin INT_MIN\n#define LLmax LLONG_MAX\n#define LLmin LLONG_MIN\n\n#define FOR(i,a,b) for(int i= (int)a; i<= (int)b; i++)\n#define rep(i,n) for(int i= int(1); i<= (int)n; i++)\n#define FORd(i,a,b,d) for(int i=(int)a; i<= (int)b; i+=(int)d)\n\n#define pr() printf(\"Reached here 1...\\n\");\n#define pr1() printf(\"Reached here 2...\\n\");\n\n#define CLR(a) memset(a,0,sizeof(a));\n#define SET(a) memset(a,-1,sizeof(a));\n\n#define str strlen\n#define sz size()\n#define pb(x) push_back(x)\n#define mp make_pair\n#define ii pair\n#define ll pair\n\n#define F first\n#define S second\n#define gcd(a,b) __gcd(a,b)\n\n#define mod int(1e9 + 7)\n#define MAX int(1e5 + 10)\n\n#define si(a) scanf(\"%d\",&a);\n\n#define VI vector\n#define VL vector\n#define VS vector\n#define VC vector\n\nLL powmod(LL a,int b,int n){LL rm=1;while (b){if (b % 2) { rm = (rm * a) % n; }a = (a * a) % n;b /= 2;}return rm;}\n\nLL dp[150][60][60]={0},fac[100],invfac[100];\n\nvoid end(){\n\tcout<<-1<> n >> k;\n\trep(i,n) cin >> w[i];\n\tk /= 50;\n\trep(i,n) {\n\t\tw[i] /= 50;\n\t\to += (w[i] == 1), t += (w[i]==2);\n\t}\n\tdp[1][o][t] = 1; // [][50][100] people on left side before ith trans.\n\n\tfor(int i=1;;i++){\n\t\tif(i>101) end();\n\t\tif(i%2){\n\t\t\tfor(int o1=0;o1<=o;++o1){\n\t\t\t\tfor(int t1=0;t1<=t;++t1){\n\t\t\t\t\tfor(int go=0;go<=o1;++go){\n\t\t\t\t\t\tfor(int gt=0;gt<=t1;++gt){\n\t\t\t\t\t\t\tif(gt+go){\n\t\t\t\t\t\t\t\tif( go + 2 * gt <= k){\n\t\t\t\tdp[i+1][o1-go][t1-gt] += (dp[i][o1][t1] * (ncr(o1,go) * ncr(t1,gt))%mod)mod;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse{\n\t\t\tfor(int o1=0;o1<=o;++o1){\n\t\t\t\tfor(int t1=0;t1<=t;++t1){\n\t\t\t\t\tint ro1 = o - o1, rt1 = t - t1;\n\t\t\t\t\tfor(int go=0;go<=ro1;++go){ // o1+go\n\t\t\t\t\t\tfor(int gt=0;gt<=rt1;++gt){\n\t\t\t\t\t\t\tif(gt+go){\n\t\t\t\t\t\t\t\tif( go + 2 * gt <= k){\n\t\t\t\t\t\t\tdp[i+1][o1+go][t1+gt] += ((ncr(ro1,go) * ncr(rt1,gt))%mod * dp[i][o1][t1])%mod;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(dp[i+1][0][0]){\n\t\t\tcout << i << endl;\n\t\t\tcout << dp[i+1][0][0] << endl;\n\t\t\treturn 0;\n\t\t}\n\t\t\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7638b0281f2689946b3e9490f9a89b9e", "src_uid": "ebb0323a854e19794c79ab559792a1f7", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint main(){\n\nint n,m,k,i,j,temp,a[60],sum=0,c=0;\ncin>>n>>m>>k;\nfor(i=0;i>a[i];\n}\nfor(i=0;ia[j]){\n temp=a[j+1];\n a[j+1]=a[j];\n a[j]=temp;\n }\n }\n}\nif(m<=k){\ncout<<\"0\";\nc++;\n}\nelse{\n else{\n for(i=0;i=m){\n cout<=m){\n cout<\n#include \n#include \n\nint main()\n{\n\tusing namespace std;\n\tint m, n, k, p, x = 0, i, max, imax;\n\tint* r;\n\tcin(\"%d\", &m);\n\tcin(\"%d\", &k);\n\tcin(\"%d\", &n);\n\tif (n >= k)\n\t\tcout(\"0\");\n\telse {\n\t\tr = (int*)malloc(m * sizeof(int));\n\t\tfor (i = 0; i < m; i++)\n\t\t\tcin(\"%d\", &r[i]);\n\t\tk = k - n + 1;\n\t\tdo {\n\t\t\tx++;\n\t\t\tmax = 0;\n\t\t\tfor (i = 0; i < m; i++)\n\t\t\t\tif (r[i] > max)\n\t\t\t\t{\n\t\t\t\t\tmax = r[i]; imax = i;\n\t\t\t\t}\n\t\t\tr[imax] = 0;\n\t\t\tif (max >= k)\n\t\t\t\tbreak;\n\t\t\tk = k - max + 1;\n\t\t} while (1);\n\t\t}\n\tcout(\"%d\", x);\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a9b5ac6c69c6f757956baf6950cbd2b2", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include \n\nint main()\n{\nint a,b,c,arr[100],i,n,m=0,f,j;\nscanf(\"%d%d%d\",&a,&b,&c);\nfor (i=0; iarr[i-1]) {\nf=arr[i-1];\narr[i-1]=arr[i];\narr[i]=f;\n}\n\n}\n}\n\nfor (i=0;i=b)break;\n}\ni++;\nif (i==a+1)printf(\"-1\");\n\nelse printf(\"%d\",i);\nreturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b1ebec7ee36bb40686f0ab7ebaa4afef", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef vector vi;\n#define pb push_back\n#define mp make_pair\n#define fi first\n#define se second\nint main()\n{\n ll n, m, k;\n vi v;\n cin >> n >> m >> k;\n for(ll i = 0; i < n; i++)\n {\n ll x;\n cin >> x;\n v.pb(x);\n }\n sort(v.begin(), v.end(), greater<>());\n ll q = v.size();\n ll i = 0;\n ll cnt = 0;\n if(k>=m)\n {\n cout << 0;\n return 0;\n }\n else\n {\n for(ll i = 0; i < q; i++)\n {\n k+=v[i]-1; cnt++;\n if(m-k>0)\n {\n m-=k;\n }\n else\n {\n cout << cnt << return 0;\n }\n }\n }\n cout << -1;\n\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "aef5cd18af579fa2da01c7f458722c2f", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "\nusing namespace std;\ntypedef double DO;\nconst int NN = 100011;\nconst DO eps = 1e-7;\n\nstruct point {\n\tDO x, y;\n\tpoint (DO x=0, DO y=0) : x(x), y(y) {}\n\tpoint operator - (point a) {return point(x-a.x, y-a.y);}\n\tpoint operator + (point a) {return point(x+a.x, y+a.y);}\n\tpoint operator * (DO a) {return point(x*a, y*a);}\n\tpoint operator / (DO a) {return point(x/a, y/a);}\n\tDO operator ^ (point a) {return x*a.y-y*a.x;}\n\tDO operator * (point a) {return x*a.x+y*a.y;}\n\tpoint norm() {DO s=nor(); if (seps) return x -eps) return true;\n\tmid = (u + w) / 2;\n\tdir = (w - u).norm().conj();\n\td = (mid - u).nor();\n\td = sqrt((INT)r * r - d * d);\n\tO = mid + dir * d;\n\treturn (v - O).nor() < r+eps;\n}\n\nDO ans;\n\ninline void calc(point u, point v) {\n\tans += u ^ v;\n\tmid = (u + v) / 2;\n\tdir = (v - u).norm().conj();\n\td = (mid - u).nor();\n d = sqrt((INT)r * r - d * d);\n\tO = mid + dir * d;\n\tu = u - O; v = v - O;\n DO al = acos(u * v / u.nor() / v.nor());\n ans += al * r * r - d * (v-u).nor();\n}\n\nint solve() {\n\tcin >> n >> r;\n\tif(n==1) return puts(\"0\");\n\tfor(int i=0; i eps) return vec > 0;\n return u.nor() < v.nor();\n\t});\n\n for(int i=0; i1 and cmp(p[nn-2], p[nn-1], p[i])) nn--;\n p[nn++] = p[i];\n }\n p[n = nn] = p[0];\n int st = 0, ed = nn-1;\n while(st + 1 < ed) {\n\t\tif(cmp(p[ed-1], p[ed], p[st])) ed--;\n\t\telse if(cmp(p[ed], p[st], p[st+1])) st++;\n\t\telse break;\n }\n p[ed+1] = p[st];\n for(int i=st; i<=ed; i++) calc(p[i], p[i+1]);\n cout << fixed << setprecision(6) << ans/2 << endl;\n}\n\nint main() {\n#ifndef\tONLINE_JUDGE\n\tfreopen(\"in.in\", \"r\", stdin);\n\tfreopen(\"out.out\", \"w\", stdout);\n#endif\n solve();\n\treturn 0;\n}\n\n ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7ea50971963c9a1cc91695d5b4d61a4a", "src_uid": "5f2a0960bab9bdc91b190ed07d6adcf7", "difficulty": 3000.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize (\"O3\")\n#pragma GCC target (\"sse4\")\n\n#include \n#include \n#include \n#include \n\nusing namespace std;\nusing namespace __gnu_pbds;\nusing namespace __gnu_cxx;\n \ntypedef long long ll;\ntypedef long double ld;\ntypedef complex cd;\n\ntypedef pair pi;\ntypedef pair pl;\ntypedef pair pd;\n\ntypedef vector vi;\ntypedef vector vd;\ntypedef vector vl;\ntypedef vector vpi;\ntypedef vector vpl;\ntypedef vector vcd;\n\ntemplate using Tree = tree, rb_tree_tag, tree_order_statistics_node_update>;\n\n#define FOR(i, a, b) for (int i = (a); i < (b); i++)\n#define F0R(i, a) for (int i = 0; i < (a); i++)\n#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)\n#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)\n#define trav(a, x) for (auto& a : x)\n\n#define mp make_pair\n#define pb push_back\n#define f first\n#define s second\n#define lb lower_bound\n#define ub upper_bound\n\n#define sz(x) (int)x.size()\n#define all(x) begin(x), end(x)\n#define rsz resize\n\nconst int MOD = 1000000007; // 998244353\nconst ll INF = 1e18;\nconst int MX = 200005;\nconst ld PI = 4*atan((ld)1);\n\ntemplate void ckmin(T &a, T b) { a = min(a, b); }\ntemplate void ckmax(T &a, T b) { a = max(a, b); }\n\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n\nnamespace input {\n\ttemplate void re(complex& x);\n\ttemplate void re(pair& p);\n\ttemplate void re(vector& a);\n\ttemplate void re(array& a);\n\n\ttemplate void re(T& x) { cin >> x; }\n\tvoid re(double& x) { string t; re(t); x = stod(t); }\n\tvoid re(ld& x) { string t; re(t); x = stold(t); }\n\ttemplate void re(T& t, Ts&... ts) { \n\t\tre(t); re(ts...); \n\t}\n\n\ttemplate void re(complex& x) { T a,b; re(a,b); x = cd(a,b); }\n\ttemplate void re(pair& p) { re(p.f,p.s); }\n\ttemplate void re(vector& a) { F0R(i,sz(a)) re(a[i]); }\n\ttemplate void re(array& a) { F0R(i,SZ) re(a[i]); }\n}\n\nusing namespace input;\n\nnamespace output {\n\tvoid pr(int x) { cout << x; }\n\tvoid pr(long x) { cout << x; }\n\tvoid pr(ll x) { cout << x; }\n\tvoid pr(unsigned x) { cout << x; }\n\tvoid pr(unsigned long x) { cout << x; }\n\tvoid pr(unsigned long long x) { cout << x; }\n\tvoid pr(float x) { cout << x; }\n\tvoid pr(double x) { cout << x; }\n\tvoid pr(ld x) { cout << x; }\n\tvoid pr(char x) { cout << x; }\n\tvoid pr(const char* x) { cout << x; }\n\tvoid pr(const string& x) { cout << x; }\n\tvoid pr(bool x) { pr(x ? \"true\" : \"false\"); }\n\t\n\ttemplate void pr(const pair& x);\n\ttemplate void pr(const T& x);\n\t\n\ttemplate void pr(const T& t, const Ts&... ts) { \n\t\tpr(t); pr(ts...); \n\t}\n\ttemplate void pr(const pair& x) { \n\t\tpr(\"{\",x.f,\", \",x.s,\"}\"); \n\t}\n\ttemplate void pr(const T& x) { \n\t\tpr(\"{\"); // const iterator needed for vector\n\t\tbool fst = 1; for (const auto& a: x) pr(!fst?\", \":\"\",a), fst = 0; \n\t\tpr(\"}\");\n\t}\n\t\n\tvoid ps() { pr(\"\\n\"); } // print w/ spaces\n\ttemplate void ps(const T& t, const Ts&... ts) { \n\t\tpr(t); if (sizeof...(ts)) pr(\" \"); ps(ts...); \n\t}\n\t\n\tvoid pc() { pr(\"]\\n\"); } // debug w/ commas\n\ttemplate void pc(const T& t, const Ts&... ts) { \n\t\tpr(t); if (sizeof...(ts)) pr(\", \"); pc(ts...); \n\t}\n\t#define dbg(x...) pr(\"[\",#x,\"] = [\"), pc(x);\n}\n\nusing namespace output;\n\nnamespace io {\n\tvoid setIn(string s) { freopen(s.c_str(),\"r\",stdin); }\n\tvoid setOut(string s) { freopen(s.c_str(),\"w\",stdout); }\n\tvoid setIO(string s = \"\") {\n\t\tcin.sync_with_stdio(0); cin.tie(0); // fast I/O\n\t\tcin.exceptions(cin.failbit); // ex. throws exception when you try to read letter into int\n\t\tif (sz(s)) { setIn(s+\".in\"), setOut(s+\".out\"); } // for USACO\n\t}\n}\n\nusing namespace io;\n\ntemplate T invGeneral(T a, T b) {\n\ta %= b; if (a == 0) return b == 1 ? 0 : -1;\n\tT x = invGeneral(b,a); \n\treturn x == -1 ? -1 : ((1-(ll)b*x)/a+b)%b;\n}\n\ntemplate struct modular {\n\tT val; \n\texplicit operator T() const { return val; }\n\tmodular() { val = 0; }\n\tmodular(const ll& v) { \n\t\tval = (-MOD <= v && v <= MOD) ? v : v % MOD;\n\t\tif (val < 0) val += MOD;\n\t}\n\t\n\t// friend ostream& operator<<(ostream& os, const modular& a) { return os << a.val; }\n\tfriend void pr(const modular& a) { pr(a.val); }\n\tfriend void re(modular& a) { ll x; re(x); a = modular(x); }\n \n\tfriend bool operator==(const modular& a, const modular& b) { return a.val == b.val; }\n\tfriend bool operator!=(const modular& a, const modular& b) { return !(a == b); }\n\tfriend bool operator<(const modular& a, const modular& b) { return a.val < b.val; }\n\n\tmodular operator-() const { return modular(-val); }\n\tmodular& operator+=(const modular& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }\n\tmodular& operator-=(const modular& m) { if ((val -= m.val) < 0) val += MOD; return *this; }\n\tmodular& operator*=(const modular& m) { val = (ll)val*m.val%MOD; return *this; }\n\tfriend modular pow(modular a, ll p) {\n\t\tmodular ans = 1; for (; p; p /= 2, a *= a) if (p&1) ans *= a;\n\t\treturn ans;\n\t}\n\tfriend modular inv(const modular& a) { \n\t\tauto i = invGeneral(a.val,MOD); assert(i != -1);\n\t\treturn i;\n\t} // equivalent to return exp(b,MOD-2) if MOD is prime\n\tmodular& operator/=(const modular& m) { return (*this) *= inv(m); }\n\t\n\tfriend modular operator+(modular a, const modular& b) { return a += b; }\n\tfriend modular operator-(modular a, const modular& b) { return a -= b; }\n\tfriend modular operator*(modular a, const modular& b) { return a *= b; }\n\t\n\tfriend modular operator/(modular a, const modular& b) { return a /= b; }\n};\n\ntypedef modular mi;\ntypedef pair pmi;\ntypedef vector vmi;\ntypedef vector vpmi;\n\ntypedef ld T;\n\nnamespace Point {\n typedef pair P;\n typedef vector

    vP;\n\n P dir(T ang) {\n auto c = exp(ang*complex(0,1));\n return P(c.real(),c.imag());\n }\n \n T norm(P x) { return x.f*x.f+x.s*x.s; }\n T abs(P x) { return sqrt(norm(x)); }\n T angle(P x) { return atan2(x.s,x.f); }\n P conj(P x) { return P(x.f,-x.s); }\n \n P operator+(const P& l, const P& r) { return P(l.f+r.f,l.s+r.s); }\n P operator-(const P& l, const P& r) { return P(l.f-r.f,l.s-r.s); }\n P operator*(const P& l, const T& r) { return P(l.f*r,l.s*r); }\n P operator*(const T& l, const P& r) { return r*l; }\n P operator/(const P& l, const T& r) { return P(l.f/r,l.s/r); }\n P operator*(const P& l, const P& r) { return P(l.f*r.f-l.s*r.s,l.s*r.f+l.f*r.s); }\n P operator/(const P& l, const P& r) { return l*conj(r)/norm(r); }\n \n P& operator+=(P& l, const P& r) { return l = l+r; }\n P& operator-=(P& l, const P& r) { return l = l-r; }\n P& operator*=(P& l, const T& r) { return l = l*r; }\n P& operator/=(P& l, const T& r) { return l = l/r; }\n P& operator*=(P& l, const P& r) { return l = l*r; }\n P& operator/=(P& l, const P& r) { return l = l/r; }\n \n P unit(P x) { return x/abs(x); }\n T dot(P a, P b) { return (conj(a)*b).f; }\n T cross(P a, P b) { return (conj(a)*b).s; }\n T cross(P p, P a, P b) { return cross(a-p,b-p); }\n T dist(P p, P a, P b) { return std::abs(cross(p,a,b))/abs(a-b); }\n \n P rotate(P a, T b) { return a*P(cos(b),sin(b)); }\n P reflect(P p, P a, P b) { return a+conj((p-a)/(b-a))*(b-a); }\n P foot(P p, P a, P b) { return (p+reflect(p,a,b))/(T)2; }\n P extension(P a, P b, P c, P d) {\n T x = cross(a,b,c), y = cross(a,b,d);\n return (d*x-c*y)/(x-y);\n }\n // computes the intersection of line segments AB, CD\n // verification: https://open.kattis.com/problems/segmentintersection\n vP segIntersect(P a, P b, P c, P d) {\n if (a > b) swap(a,b);\n if (c > d) swap(c,d);\n \n auto a1 = cross(a,b,c), a2 = cross(a,b,d);\n if (a1 > a2) swap(a1,a2);\n if (!(a1 <= 0 && a2 >= 0)) return {};\n \n if (a1 == 0 && a2 == 0) {\n if (cross(a,c,d) != 0) return {};\n auto x1 = max(a,c), x2 = min(b,d);\n if (x1 > x2) return {};\n if (x1 == x2) return {x1};\n return {x1,x2};\n }\n \n auto z = extension(a,b,c,d);\n if (a <= z && z <= b) return {z};\n return {};\n }\n \n // sorts points according to atan2\n // verification: ?\n template int half(pair x) { return mp(x.s,x.f) > mp((T)0,(T)0); }\n bool cmp(P a, P b) { \n int A = half(a), B = half(b);\n if (A != B) return A < B;\n return cross(a,b) > 0;\n }\n \n // computes the center of mass of a polygon with constant mass per unit area\n // verification: kattis polygonarea, VT HSPC 2018 Holiday Stars\n T area(const vP& v) {\n T area = 0;\n F0R(i,sz(v)) {\n int j = (i+1)%sz(v); T a = cross(v[i],v[j]);\n area += a;\n }\n return std::abs(area)/2;\n }\n P centroid(const vP& v) { \n P cen(0,0); T area = 0; // 2*signed area\n F0R(i,sz(v)) {\n int j = (i+1)%sz(v); T a = cross(v[i],v[j]);\n cen += a*(v[i]+v[j]); area += a;\n }\n return cen/area/(T)3;\n }\n \n // tests whether a point is inside, on, or outside the perimeter of any polygon\n // verification: https://open.kattis.com/problems/pointinpolygon\n string inPoly(const vP& p, P z) {\n int n = sz(p), ans = 0;\n F0R(i,n) {\n P x = p[i], y = p[(i+1)%n];\n if (cross(x,y,z) == 0 && min(x,y) <= z && z <= max(x,y)) return \"on\";\n if (x.s > y.s) swap(x,y);\n if (x.s <= z.s && y.s > z.s && cross(z,x,y) > 0) ans ^= 1;\n }\n return ans ? \"in\" : \"out\";\n }\n\n pair ccCenter(P a, P b, P c) { // circumcenter\n b -= a; c -= a;\n P res = b*c*(conj(c)-conj(b))/(b*conj(c)-conj(b)*c);\n return {a+res,abs(res)};\n }\n \n pair mec(vP ps) { // minimum enclosing circle, ex. USACO Camp 2019 Contest 2 #4\n shuffle(all(ps), mt19937(time(0)));\n P o = ps[0]; T r = 0, EPS = 1 + 1e-8;\n F0R(i,sz(ps)) if (abs(o-ps[i]) > r*EPS) {\n o = ps[i], r = 0;\n F0R(j,i) if (abs(o-ps[j]) > r*EPS) {\n o = (ps[i]+ps[j])/2, r = abs(o-ps[i]);\n F0R(k,j) if (abs(o-ps[k]) > r*EPS) \n tie(o,r) = ccCenter(ps[i],ps[j],ps[k]);\n }\n }\n return {o,r};\n }\n};\n\nusing namespace Point;\n\npair ulHull(const vP& P) {\n vi p(sz(P)), u, l; iota(all(p), 0);\n sort(all(p), [&P](int a, int b) { return P[a] < P[b]; });\n trav(i,p) {\n #define ADDP(C, cmp) while (sz(C) > 1 && cross(\\\n P[C[sz(C)-2]],P[C.back()],P[i]) cmp 0) C.pop_back(); C.pb(i);\n ADDP(u, >=); ADDP(l, <=);\n }\n return {u,l};\n}\n\nvi convexHull(const vP& P) {\n vi u,l; tie(u,l) = ulHull(P);\n if (sz(l) <= 1) return l;\n if (P[l[0]] == P[l[1]]) return {0};\n l.insert(end(l),rbegin(u)+1,rend(u)-1); return l;\n}\n\nint n,r;\nset> S;\nset>::iterator inserted[MX];\nset lef;\nvP c;\n\nint pre(int x) {\n\tauto it = lef.lb(x);\n\tif (it == begin(lef)) it = end(lef);\n\treturn *prev(it);\n}\n\nint nex(int x) {\n\tauto it = lef.ub(x); \n\tif (it == end(lef)) it = begin(lef);\n\treturn *it;\n}\n\nvoid del(int i) {\n\tint a = sz(S);\n\tS.erase(inserted[i]);\n\tassert(a-1 == sz(S));\n\t// lef.erase(i);\n}\n\nvoid ins(int i) {\n\tif (!lef.count(i)) {\n\t\tps(\"WUT\",lef,i);\n\t\texit(0);\n\t}\n\tinserted[i] = S.insert({ccCenter(c[pre(i)],c[i],c[nex(i)]).s,i}).f;\n}\n\nvoid init() {\n\t// setIO(\"E\");\n\tsetIO();\n\tre(n,r); \n\tvP b(n); re(b);\n\t/*F0R(i,n) {\n\t\t// -10000 to 10000\n\t\tb[i].f = rand()%10000000;\n\t\tb[i].f /= 1000;\n\t\tb[i].s = sqrt(1e8-pow(b[i].f,2));\n\t\tb[i].s = floor(1000*b[i].s)/1000;\n\t}*/\n\tvi v = convexHull(b);\n\ttrav(t,v) c.pb(b[t]);\n\tF0R(i,sz(c)) lef.insert(i);\n\tif (sz(c) > 2) F0R(i,sz(c)) ins(i);\n}\n\nld arc(P a, P b) {\n\tld d = abs(a-b);\n\tld ang = asin(d/2/r)*2; \n\treturn r*r*(ang-sin(ang))/2;\n}\n\nbool obtuse(P a, P b, P c) {\n\ta -= b, c -= b;\n\treturn a.f*c.f+a.s*c.s <= 0;\n}\n\nint main() {\n\tinit();\n\twhile (sz(S) && S.rbegin()->f > r*(1-(1e-8))) {\n\t\tif (sz(lef) != sz(S)) {\n\t\t\t// ps(\"BADLS\",sz(c),sz(lef),sz(S));\n\t\t\texit(0);\n\t\t}\n\t\tif (sz(S) == 3) {\n\t\t\tvd tmp; trav(t,lef) tmp.pb(t);\n\t\t\twhile (!obtuse(c[tmp[0]],c[tmp[1]],c[tmp[2]])) \n\t\t\t\trotate(begin(tmp),begin(tmp)+1,end(tmp));\n\t\t\tlef.erase(tmp[1]); S.clear();\n\t\t\t// ps(\"HA\"); exit(0);\n\t\t\t// ps(\"HA\");\n\t\t\tcontinue;\n\t\t\t// exit(0);\n\t\t}\n\t\t// ps(\"WUT\",sz(S)); exit(0);\n\t\tint x = S.rbegin()->s;\n\t\tdel(x); lef.erase(x);\n\t\t// if (sz(lef) != sz(S)) ps(\"PRE\");\n\t\tif (sz(lef) > 2) {\n\t\t\tdel(pre(x)); ins(pre(x));\n\t\t\tdel(nex(x)); ins(nex(x));\n\t\t} \n\t}\n\tif (n == 422) {\n\t\tps(\"OOPS\",sz(c),sz(res),S.rbegin()->f);\n\t}\n\tvP res; trav(t,lef) res.pb(c[t]);\n\tld ans = 0;\n\tF0R(i,sz(res)) ans += arc(res[i],res[(i+1)%sz(res)]);\n\tans += area(res);\n\tcout << fixed << setprecision(6) << ans;\n}\n\n/* stuff you should look for\n\t* int overflow, array bounds\n\t* special cases (n=1?), set tle\n\t* do smth instead of nothing and stay organized\n*/\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d6f441ffd1f80137e5ff6a0a854f0a4e", "src_uid": "5f2a0960bab9bdc91b190ed07d6adcf7", "difficulty": 3000.0} {"lang": "GNU C++14", "source_code": "#include \n\n#define F first\n#define S second\n#define pb push_back\n#define sz(a) (int)(a).size()\n#define all(a) (a).begin(),a.end()\n#define pw(x) (1LL<<(x))\n\n#define db(x) cerr << #x << \" = \" << x << endl\n#define db2(x, y) cerr << \"(\" << #x << \", \" << #y << \") = (\" << x << \", \" << y << \")\\n\";\n#define db3(x, y, z) cerr << \"(\" << #x << \", \" << #y << \", \" << #z << \") = (\" << x << \", \" << y << \", \" << z << \")\\n\"\n#define dbv(a) cerr << #a << \" = \"; for (auto xxxx: a) cerr << xxxx << \" \"; cerr << endl\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef double dbl;\nconst int INF = 1.01e9;\n\nstruct pt {\n ll x, y;\n\n pt() {}\n\n pt(ll xx, ll yy) : x(xx), y(yy) {}\n\n pt operator+(pt A) {\n return pt(x + A.x, y + A.y);\n }\n\n pt operator-(pt A) {\n return pt(x - A.x, y - A.y);\n }\n\n pt operator*(ll k) {\n return pt(x * k, y * k);\n }\n\n pt operator/(ll k) {\n assert(x % k == 0 && y % k == 0);\n return pt(x / k, y / k);\n }\n\n ll operator*(pt A) {\n return x * A.y - y * A.x;\n }\n\n ll operator%(pt A) {\n return x * A.x + y * A.y;\n }\n\n bool operator==(pt A) {\n return x == A.x && y == A.y;\n }\n\n bool operator!=(pt A) {\n return x != A.x && y != A.y;\n }\n\n pt rotate() {\n return pt(-y, x);\n }\n\n ll len2() {\n return x * x + y * y;\n }\n\n dbl len() {\n return sqrt(x * x + y * y);\n }\n\n void read() {\n scanf(\"%lld%lld\", &x, &y);\n }\n};\n\nvector convexHull(vector p) {\n sort(all(p), [](pt A, pt B) {\n return A.x < B.x || (A.x == B.x && A.y < B.y);\n });\n vector st;\n for (int tt = 0; tt < 2; tt++) {\n int cur = st.size();\n for (auto A: p) {\n for (; (int)st.size() >= cur + 2 && (st.back() - st[st.size() - 2]) * (A - st.back()) <= 0; st.pop_back());\n st.pb(A);\n }\n st.pop_back();\n reverse(all(p));\n }\n return st;\n}\n\nint main() {\n#define TASK \"A\"\n#ifdef HOME\n assert(freopen(TASK\n \".in\", \"r\", stdin));\n#endif\n int F = 1e3;\n int n, r;\n scanf(\"%d%d\", &n, &r);\n r *= F;\n vector p(n);\n for (int i = 0; i < n; i++) {\n dbl x, y;\n scanf(\"%lf%lf\", &x, &y);\n p[i] = pt(round(x * F), round(y * F));\n }\n\n auto ch = convexHull(p);\n int m = ch.size();\n vector nxt(m);\n vector prv(m);\n vector val(m);\n for (int i = 0; i < m; i++) {\n nxt[i] = (i + 1) % m;\n prv[i] = (i + m - 1) % m;\n }\n db(m);\n set> event;\n auto getR = [&](int id) {\n// db3(prv[id], id, nxt[id]);\n pt A = ch[prv[id]];\n pt B = ch[id];\n pt C = ch[nxt[id]];\n if (prv[id] == nxt[id]) {\n assert(prv[id] != id);\n return (A - B).len() / 2;\n }\n pt v = (A - B);\n pt u = (C - B);\n dbl tmpAng = atan2(u * v, v % u);\n assert(tmpAng > 0);\n if (tmpAng < acos(-1) / 3) {\n return 0;\n }\n dbl a = (A - B).len();\n dbl b = (B - C).len();\n dbl c = (A - C).len();\n ///db3(a, b, c);\n dbl pp = (a + b + c) / 2;\n return a * b * c / (4 * sqrt(pp * (pp - a) * (pp - b) * (pp - c)));\n };\n\n vector alive(ch.size(), 1);\n auto kill = [&](int id) {\n assert(alive[id] == 1);\n alive[id] = 0;\n int v = prv[id];\n int u = nxt[id];\n assert(alive[v] == 1);\n assert(alive[u] == 1);\n event.erase({val[v], v});\n event.erase({val[u], u});\n nxt[v] = u;\n prv[u] = v;\n val[v] = getR(v);\n val[u] = getR(u);\n event.insert({val[v], v});\n event.insert({val[u], u});\n };\n if (m <= 1) {\n puts(\"0.0\");\n return 0;\n }\n if (m > 2) {\n\n for (int i = 0; i < m; i++) {\n val[i] = getR(i);\n event.insert({val[i], i});\n }\n while (true) {\n while (event.empty());\n// assert(!event.empty());\n// for (auto x: event) {\n// db2(x.F, x.S);\n// }\n if (event.rbegin()->F <= r + 1e-9) {\n break;\n }\n auto id = event.rbegin()->S;\n// db(id);\n event.erase(*event.rbegin());\n kill(id);\n }\n }\n\n int gg = -1;\n for (int i = 0; i < sz(ch); i++) {\n if (alive[i]){\n gg = i;\n break;\n }\n }\n\n vector res;\n for (;alive[gg]; gg = nxt[gg]) {\n alive[gg] = 0;\n res.pb(ch[gg]);\n }\n\n// db(res.size());\n// for (auto A: res) {\n// db2(A.x, A.y);\n// }\n dbl answer = 0;\n for (int i = 0; i < sz(res); i++) {\n answer += res[i] * res[(i + 1) % sz(res)] / 2.0;\n }\n// db(answer / F / F);\n\n for (int i = 0; i < sz(res); i++) {\n dbl len = (res[i] - res[(i + 1) % sz(res)]).len();\n dbl c = len / 2;\n dbl h = sqrt(max((dbl)0, r * 1.0 * r - c * c));\n dbl ang = asin(min((dbl)1, c / r)) * 2;\n dbl add = ang * r * 1.0 * r / 2 - c * h;\n// db3(len, r, add / F / F);\n answer += add;\n }\n\n printf(\"%.17f\\n\", answer / F / F);\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a0d179d89bde144d5ab51a6968840c2a", "src_uid": "5f2a0960bab9bdc91b190ed07d6adcf7", "difficulty": 3000.0} {"lang": "GNU C++", "source_code": "//Studied From CjLD\n#include\n#include\n#include\n#include\n#include\n#include\n#define mp make_pair\n#define x first\n#define y second\n#define pdd pair\nusing namespace std;\nconst double pi=3.1415926535898,eps=1e-6;\nint n,up_,dn_,c_,s,t;\ndouble r,ans;\npdd p[100000],up[100001],dn[100001],c[100001],o[100001],b[100001];\n\npdd operator-(pdd a,pdd b){return mp(a.x-b.x,a.y-b.y);}\ndouble Nj(pdd a,pdd b){return a.x*b.x+a.y*b.y;}\ndouble Xj(pdd a,pdd b){return a.x*b.y-a.y*b.x;}\ndouble dis(pdd a){return sqrt(a.x*a.x+a.y*a.y);}\nvoid convex()\n{\n\tsort(p,p+n);\n\tup_=0;\n\tdn_=0;\n\tc_=0;\n\tfor(int i=0;i1&&Xj(p[i]-up[up_-1],up[up_]-up[up_-1])>0;)up_--;\n\t\tup[++up_]=p[i];\n\t}\n\tfor(int i=n-1;i>=0;--i)\n\t{\n\t\tfor(;dn_>1&&Xj(p[i]-dn[dn_-1],dn[dn_]-dn[dn_-1])>0;)dn_--;\n\t\tdn[++dn_]=p[i];\n\t}\n\tfor(int i=1;i<=up_;++i)c[++c_]=up[i];\n\tfor(int i=2;i-eps&&dis(p-o)<=r;}\n\nint main() \n{\n\t#ifndef ONLINE_JUDGE\n\tfreopen(\"cf.in\",\"rb\",stdin);\n\tfreopen(\"cf.out\",\"wb\",stdout);\n\t#endif\n\tcin>>n>>r;\n\tfor(int i=0;i>p[i].x>>p[i].y;\n\tn=unique(p,p+n)-p;\n\tconvex();\n\ts=1;t=0;\n\tfor(int i=1;i<=c_;++i)\n\t{\n\t\tfor(;t>1&&!in_circle(b[t-1],b[t],o[t],c[i]);)t--;\n\t\tb[++t]=c[i];\n\t\tif(t>1)o[t]=calc(b[t-1],b[t]);\n\t}\n\tfor(bool next;next;)\n\t{\n\t\tnext=0;\n\t\tif(t>s+1&&dis(b[t]-o[s+1])>r)s++,next=1;\n\t\tif(t>s+1&&dis(b[s]-o[t])>r)t--,next=1;\n\t}\n\t//for(int i=s;i<=t;++i)cout<agb)agb+=pi*2;\n\t\t//cout<\n#include \nusing namespace std;\n\n\nint main() {\n\n\n\n\tint x;\n\tcin>>x;\n\tint ctr = 1;\n string a[x] ;\n\tfor (int i = 0; i < x; i++)\n\t\t( getline (cin,a[i]) )\n\tfor (int j =0; j < x; j++)\n\t\t(\n\t\t\tint t = j - 1;\n\t\t\tif (t > 1)\n\t\t\t\t(\n\t\t\t while (t >= 0)\n\t\t\t (\n\t\t\t if (a[j]!= a[t])\n\t\t\t\t continue;\n\t\t\t\t else if (a[j] == a[t])\n\t\t\t\t\t ctr++;\n\t\t\t\t t--;\n\t\t\t )\n\t\t )\n\t\t)\n\tcout<\nusing namespace std;\nint main(){\n int n;\n cin>>n;\n int max=0;\n for (int i=0;i>a[i];\n if (a[i]> max){\n max = a[i];\n }\n }\n \n for (int i=0;imax){\n max = a[i];\n }\n }\n cout<\nusing namespace std;\n\nint main()\n{\n int n,a[101];\n\n memset(a,0,10);\n scanf(\"%d\",&n);\n\n for(i=0;i<10;i++)\n cout<\n\nusing namespace std;\n\nint main()\n{long long n;\ncin >> n;\nlong long a[n-1];\ncin >> a[0];\nfor (int i=1;i> a[i];\n\n\nlong long p[100000];\nlong long d=0;\n\n\nfor (int i=0;i\n#include\n#include\nusing namespace std;\n\nint main()\n{\n int n,n1,sum1,sum2;\n string num;\n stringstream ss;\n cin>>n;\n \n if(n<2 || n>50 || n%2!=0)\n return 0;\n \n cin>>num;\n \n for(int i=0;i> n1;\n ss.clear();\n sum1+=n1; \n }\n \n for(int i=n/2; i> n1;\n ss.clear();\n sum2+=n1; \n }\n \n if(sum1 == sum2)\n cout<<\"YES\"<\nusing namespace std;\nint s1, s2, n ;\nint main()\n{\n string num;\n cin >> n;\n cin >> num;\n for (int i = 0; i < n / 2; ++i) \n {\n s1 += num[i] - '0';\n if ((num[i] != '4' )&& (num[i] != '7'))\n {\n cout << \"NO\" << endl;\n return 0;\n }\n }\n\n for (int i = n / 2; i < n; ++i) \n {\n s2 += num[i] - '0';\n\n if (num[i] != '4' && num[i] != '7')\n {\n cout << \"NO\" << endl;\n return 0;\n }\n }\n\n if (s1 == s2) cout << \"YES\";\n else cout << \"NO\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4efb6e5dadd1616c78db5a39ae9a2dd0", "src_uid": "435b6d48f99d90caab828049a2c9e2a7", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint main()\n{\n int n,sum1=0,sum2=0,flag=0;\n cin>>n;\n int z[n];\n cin>>z;\n for(int i=0;i\nusing namespace std;\nint n,x=0,a,i;\nmain(){\nstring c;\ncin>>n>>c;\nfor(i=0;i\n#include \n\nint main()\n{\n\tint r, l, a;\n\tscanf_s(\"%d %d %d\", &r, &l, &a);\n\tint d;\n\td = intabs(r - l);\n\tint num;\n\tif (d >= a)\n\t{\n\t\tnum = r+l-d+2*a;\n\t}\n\telse\n\t{\n\t\tif ((r + l + a) % 2 == 0)\n\t\t{\n\t\t\tnum = r + l + a;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tnum = r + l + a - 1;\n\t\t} \n\t}\n\tprintf(\"%d\", num);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b85ede8b2800de24c4b37db4123e8bfc", "src_uid": "e8148140e61baffd0878376ac5f3857c", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "# include \nusing namespace std;\nint l,r,a,ans,a1;\nint main()\n{\n cin>>l>>r>>a;\n if (a==0) cout<<(min(l,r))*2;\n else\n {\n if (l>=r) \n {\n a=a-(l-r);\n ans+=a-(l-r);\n }\n else\n {\n a=a-(r-l);\n ans+=a-(r-l);\n }\n a1=a/=2;\n cout<<(min(l,r))*2+ans+a1*2;\n \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4a79af9943982e1e73f759b548bfa6f8", "src_uid": "e8148140e61baffd0878376ac5f3857c", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint l, r,a, s, ans, l1, r1;\nint main(){\n \n cin>>l>>r>>a;\n l1=l; r1=r; \n l=min(l,r);\n r=max(l1,r1);\n s=r-a;\n if(s>=a) cout<\n# include \n# define MAXN 2050\n\nconst long long MOD = 1e9+7;\nlong long fac[MAXN], inv[MAXN];\nlong long f[MAXN][MAXN][2][2];\n// pos sumPerf, pos, pos+1\n\nlong long QPow(long long x, long long y){\n\tlong long ans = 1, base = x % MOD;\n\twhile(y){\n\t\tif(y & 1){\n\t\t\tans = (ans * base) % MOD;\n\t\t}\n\t\tbase = (base * base) % MOD;\n\t\ty >>= 1;\n\t}\n\treturn ans;\n}\n\nlong long Combine(int m, int n){\n\treturn m > n ? 0 : (((fac[n] * inv[n-m])%MOD ) * inv[m])%MOD;\n}\n\nint main(){\n\tint n, m; long long ans = 0;\n\n\tscanf(\"%d%d\", &n, &m);\n\n\tfac[0] = inv[0] = 1;\n\tfor(int i = 1; i <= n; i++){\n\t\tfac[i] = (fac[i-1] * i) % MOD;\n\t}\n\tinv[n] = QPow(fac[n], MOD-2);\n\tfor(int i = n-1; i >= 1; i--){\n\t\tinv[i] = (inv[i+1] * (i+1)) % MOD;\n\t}\n\n\tf[1][0][0][0] = f[1][1][0][1] = 1;\n\tfor(int i = 2; i <= n; i++){ // i <= n-1\n\t\tf[i][0][0][0] = 1;\n\t\tfor(int j = 1; j <= i; j++){\n\t\t\tf[i][j][0][0] = ((f[i-1][j][1][0] + f[i-1][j][0][0])%MOD) + f[i-1][j-1][0][0]) % MOD;\n\t\t\tf[i][j][0][1] = (f[i-1][j-1][0][0] + f[i-1][j-1][1][0]) % MOD;\n\t\t\tf[i][j][1][0] = (((f[i-1][j-1][0][1] + f[i-1][j][1][1])%MOD) + f[i-1][j][0][1]) % MOD;\n\t\t\tf[i][j][1][1] = (f[i-1][j-1][0][1] + f[i-1][j-1][1][1]) % MOD;\n\t\t}\n\t} f[n][0][0][0] = 1;\n\tfor(int i = 1; i <= n; i++){// i == n\n\t\tf[n][i][0][0] = ((f[n-1][i][1][0] + f[n-1][i][0][0])%MOD) + f[n-1][i-1][0][0]) % MOD;\n\t\tf[n][i][1][0] = ((f[n-1][i-1][0][1] + f[n-1][i][1][1]%MOD) + f[n-1][i][0][1]) % MOD;\n\t}\n\n\tfor(int i = m; i <= n; i++){\n\t\tlong long tmp = (Combine(m, i) * (fac[n-i] * ((f[n][i][0][0] + f[n][i][1][0])%MOD)%MOD)%MOD)%MOD;\n\t\tans = (ans + ((i-m) & 1 ? MOD-tmp : tmp)) % MOD;\n\t}\n\n\tprintf(\"%lld\", ans);\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3b282aa4deb207b6e4b36ad348938c70", "src_uid": "1243e98fe2ebd6e6d1de851984b96079", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include \n#define maxn 1010\n#define mo 1000000007\n#define ll long long\nusing namespace std;\nll dp[maxn][maxn][2][2],n,k;\nll c[maxn][maxn],ans[maxn],fac[maxn];\n//dp[i][j][k][l]\u4ee3\u8868\u524di\u4e2a\u4f4d\u7f6e\u6709j\u4e2agood position,i,i+1\u662f\u5426\u88ab\u4f7f\u7528 \nint main()\n{\n\tscanf(\"%d%d\",&n,&k);\n\tfor (int i=1;i<=n;++i)\n\t{\n\t\tc[i][0]=c[i][i]=1LL;\n\t\tfor (int j=1;j<=i-1;++j)\n\t\t{c[i][j]=(c[i][j]+c[i-1][j]+c[i-1][j-1])%mo;}\n\t } \n\t fac[0] = fac[1] = 1LL;\n\t for (int i = 2; i <= 1001; ++i) fac[i] = (fac[i - 1] * i * 1LL) % mo;\n\t dp[0][0][1][0]=1;\t\n\t for (int i=1;i<=n;++i)\n\t {\n\t \tfor (int j=0;j<=i-1;++j)\n\t \tfor (int now=0;now<2;++now)\n\t \tfor (int ne=0;ne<2;++ne)\n\t \t{\n\t \t\tdp[i][j][ne][0]=(dp[i][j][ne][0]+dp[i-1][j][now][ne])%mo;//\u5982\u679c\u53d6\u4e86\u522b\u7684\u6570 \n\t \t\tif (!now) dp[i][j+1][ne][0]=(dp[i][j+1][ne][0]+dp[i-1][j][now][ne])%mo;\n\t \t\tif (i\n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\nconst ll P = 1000000007LL;\nconst int MAX = 1010;\n\nvoid add(ll &x, ll y) {\n\tx = (x + y) % P;\n}\n\nll C[MAX][MAX];\nll dp[MAX][MAX][2][2];\nll F[MAX];\nll fact[MAX];\n\nint main() {\n\tios::sync_with_stdio(false);\n\tint N, K;\n\tcin >> N >> K;\n\n\tfor (int i = 0; i <= N; i++) {\n\t\tC[i][0] = C[i][i] = 1;\n\t\tfor (int j = 1; j < i; j++)\n\t\t\tadd(C[i][j], C[i - 1][j] + C[i - 1][j - 1]);\n\t}\n\n\tfor (int i = 0; i <= N; i++) {\n\t\tdp[i][0][0][0] = 1;\n\t\tfact[i] = i ? (i * fact[i - 1]) % P : 1;\n\t}\n\n\tfor (int n = 1; n <= N; n++) {\n\t\tfor (int k = 1; k <= K; k++) {\n\n\t\t\tif (n > 1)\n\t\t\t\tadd(dp[n][k][0][0], dp[n - 1][k][0][0] + dp[n - 1][k][1][0]\n\t\t\t\t\t\t+ dp[n - 1][k - 1][0][0]);\n\n\t\t\tadd(dp[n][k][1][0], dp[n - 1][k][0][1] + dp[n - 1][k][1][1] + (n\n\t\t\t\t\t> 1 ? dp[n - 1][k - 1][0][1] : 0));\n\n\t\t\tif (n < N) {\n\n\t\t\t\tadd(dp[n][k][0][1], dp[n - 1][k - 1][0][0]\n\t\t\t\t\t\t+ dp[n - 1][k - 1][1][0]);\n\n\t\t\t\tadd(dp[n][k][1][1], dp[n - 1][k - 1][0][1]\n\t\t\t\t\t\t+ dp[n - 1][k - 1][1][1]);\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (int k = 0; k <= N; k++) {\n\t\tadd(F[k], dp[N][k][0][0] + dp[N][k][1][0] + dp[N][k][0][1]\n\t\t\t\t+ dp[N][k][1][1]);\n\t\tF[k] = (F[k] * fact[N - k]) % P;\n\t}\n\n\tfor(int k1 = N-1; k1 >= 0; k1--)\n\t\tfor(int k2 = k1+1; k2 <= N ; k2++)\n\t\t\tF[k1] = (F[k1] - (F[k2]*comb[k2][k1])%P + P)%P;\n\n\tcout << F[K] << endl;\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2200bd02485e56d09129f5475d3655ae", "src_uid": "1243e98fe2ebd6e6d1de851984b96079", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\ntypedef long long ll;\nconst int N = 1000+5;\nconst int MOD = 1000000007;\nll dp[N][N][4];\nll F[N];\nll C[N][N];\nint n, m;\nint main() {\n scanf(\"%d%d\", &n, &m);\n memset(dp, 0, sizeof dp);\n dp[0][0][1<<1] = 1;\n for (int i = 1; i <= n; i++) {\n for (int j = 0; j < i; j++) {\n for (int k = 0; k < 4; k++) {\n if (k&1) {\n dp[i][j+1][(k>>1)|(1<<1)] += dp[i-1][j][k];\n dp[i][j+1][(k>>1)|(1<<1)] %= MOD;\n }\n if (i < n) {\n dp[i][j+1][(k>>1)] += dp[i-1][j][k];\n dp[i][j+1][(k>>1)] %= MOD;\n }\n dp[i][j][(k>>1)|(1<<1)] += dp[i-1][j][k];\n dp[i][j][(k>>1)|(1<<1)] %= MOD;\n }\n }\n }\n for (int i = 0; i <= n; i++) {\n for (int k = 0; k < 4; k++) {\n F[i] += dp[n][i][k];\n F[i] %= MOD;\n }\n for (int j = 1; j <= n - i; j++) {\n F[i] *= j;\n F[i] %= MOD;\n }\n }\n for (int i = 0; i <= n; i++) {\n for (int j = 0; j <= i; j++) {\n C[i][j] = j == 0 ? 1 : (C[i-1][j-1] + C[i-1][j])%MOD;\n }\n }\n for (int i = n - 1; i >= 0; i--) {\n for (int j = n; j > i; j--) {\n F[i] -= ((F[j]*C[j][i])%MOD);\n while (F[i] >= MOD) F[i] -= MOD;\n while (F[i] < 0) F[i] += MOD;\n }\n }\n cout<\n#include \n#include \n#include \n#include \n#define ll long long\n#define ui unsigned int\n#define ull unsigned long long\n#define R register\nusing namespace std;\nnamespace chu_xuan{\n void swap(int &a,int &b){R int tmp=a;a=b,b=tmp;}\n void read(int &a) {a=0;int b=1,c=getchar(); while(c>'9'||c<'0'){if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b;}\n int In() {int a=0,b=1,c=getchar(); while(c>'9'||c<'0'){if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*b;}\n int max(int a,int b){return a>b?a:b;}\n int min(int a,int b){return a>b?b:a;}\n}using namespace chu_xuan;\n\nint main()\n{\n\tint n,v;\n read(n);read(v);\n int need=n-1;\n if(need<=v) {cout<\n\nusing namespace std;\nlong long x,m,y,n,v,v1;\nint main()\n{\n cin >> n >> v;\nif (v => n)\n{\n m = n-1;\n v1 = n;\n}\nelse {\n m = v;\n v1 = v;}\n for (int i = 2; i < n+1; i++)\n {\n v1--;\n if (v1 - (n-i) >= 0)\n {\n cout << m << endl;\n return 0;\n }\n else\n {\n v1 ++;\n m+=i;\n\n }\n }\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "29d701ce4d3da7f61310b9f7fa262610", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include\n#include \n#include \nusing namespace std;\ntypedef long long ll;\nusing namespace __gnu_pbds;\ntypedef tree, rb_tree_tag, tree_order_statistics_node_update> pbds;\n#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)\n#define so sizeof\n#define pb push_back\n#define vl vector\n#define endl endl;cf\n#define be begin()\n#define sz size()\n#define en end()\n#define all(x) (x).be , (x).en\n#define rall(x) (x).rbegin() , (x).rend()\n#define acc(x) accumulate((x).be , (x).en , 0)\n#define forn(i,a,b) for(ll i=1;i<=b;++i)\n#define forr(i,a,b) for(ll i=0;i >\n#define pll pair\n#define plll pair>\n#define plvl pair ,ll>\n#define mp make_pair\n#define cf cout.flush()\nint main()\n{\n ios;\n ll n , v;\n cin >> n >> v;\n ll preq = n - 1;\n if(v >= preq){\n cout << preq << endl;\n return 0;\n }\n else {\n ll cost = 0 ;\n ll foo = preq ;\n for(ll i = 1; i<=n;++i){\n if(preq > v){\n preq-=v;\n cost = cost + i*v\n continue;\n }\n else if(preq <=v){\n cost = cost + i*preq;\n preq-=v;\n break;\n }\n }\n cout << cost << endl;\n return 0;\n }\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d1cf5b99669a8aa6799dc707fb5a4b1c", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include \n#define max(a,b)(( a>b) ? a : b)\n#define n_ \"\\n\"\n#define s_ \" \"\nusing namespace std;\n/*\nifstream fin(\"bigfour.in\");\nofstream fout (\"bigfour.out\");\n\n*/\nint main()\n{\n\n int n,v;\n cin >> n >> v;\n\n if(n == v || n-v == 1){\n cout << v;\n return 0 ;\n }\n int cur = 0 ;\n for(int i = 1 ; i < = n ; i++){\n if(i>1){\n cur +=i;\n }\n }\n\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "172ac80606c3f487c7cebc9d6bf083ba", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7", "difficulty": 900.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\n/////////////////// TYPES & MACROS ///////////////////////////////\n#define all(x) x.begin(), x.end()\n#define vv vector\n#define exist(s, e) (s.find(e) != s.end())\ntemplate constexpr inline int SZ(const T &x) { return x.size(); }\nusing i64 = int64_t;\nusing i32 = int32_t;\n//#define int i64\nconst char el = '\\n';\ntemplate constexpr inline bool rmn(T &a, T b) { return a > b ? (a = b, true) : false; }\ntemplate constexpr inline bool rmx(T &a, T b) { return a < b ? (a = b, true) : false; }\nconst i32 MOD = 1e9 + 7, INF = 0x3f3f3f3f;\nconst i64 INFLL = ((i64)INF << 32) | INF;\n\n//////////////////// DEBUG /////////////////////////////////////////\n#ifdef LOCAL\ntemplate void dprint(Args... args) { ((std::cerr << args << \", \"), ...) << el; }\n#else\ntemplate void dprint(Args... args) {}\n#endif\ntemplate void print(Args... args) { (std::cout << ... << args) << el; }\n\n/////////////////// VARIABLES & FUNCTIONS//////////////////////////\nvv> adj;\nvv vis, color;\n/*\n * Author : Jakob Kogler, Madhur Chauhan\n * Use : Modular Arithmetic\n * Time Complexity : O(1)\n * Space Complexity: O(1)\n * Usage Notes: Template argument is the modulus which is set to default: 1e9+7. A modular int can be created by:\n * Modular<> m=56; // creates a modular integer initialize to 56 in MOD = 1e9+7\n * using MInt = Modular<998244353>; // MInt can be used like regular integer\n * vector dp(10, Mint(0)); // creater a vector with values initialized to 0\n * cout << m * 1'000'000'000'000 << endl; // will not overflow\n */\n\ntemplate \nstruct modular {\n\tint value;\n\n\tmodular(long long v = 0) {\n\t\tvalue = v % MOD;\n\t\tif (value < 0) value += MOD;\n\t}\n\tmodular(long long a, long long b) : value(0) {\n\t\t*this += a;\n\t\t*this /= b;\n\t}\n\tmodular &operator+=(modular const &b) {\n\t\tvalue += b.value;\n\t\tif (value >= MOD) value -= MOD;\n\t\treturn *this;\n\t}\n\tmodular &operator-=(modular const &b) {\n\t\tvalue -= b.value;\n\t\tif (value < 0) value += MOD;\n\t\treturn *this;\n\t}\n\tmodular &operator*=(modular const &b) {\n\t\tvalue = (long long)value * b.value % MOD;\n\t\treturn *this;\n\t}\n\n\tfriend modular mexp(modular a, long long e) {\n\t\tmodular res = 1;\n\t\twhile (e) {\n\t\t\tif (e & 1) res *= a;\n\t\t\ta *= a, e >>= 1;\n\t\t}\n\t\treturn res;\n\t}\n\tfriend modular inverse(modular a) {\n\t\tint phi = MOD - 1; // change this for general MOD where a^phi = 1 (mod MOD)\n\t\treturn mexp(a, phi - 1);\n\t}\n\n\tmodular &operator/=(modular const &b) { return *this *= inverse(b); }\n\tfriend modular operator+(modular a, const modular b) { return a += b; }\n\tfriend modular operator-(modular a, const modular b) { return a -= b; }\n\tfriend modular operator-(const modular a) { return 0 - a; }\n\tfriend modular operator*(modular a, const modular b) { return a *= b; }\n\tfriend modular operator/(modular a, const modular b) { return a /= b; }\n\tfriend std::ostream &operator<<(std::ostream &os, const modular &a) { return os << a.value; }\n\tfriend std::istream &operator>>(std::istream &is, modular &a) {\n\t\tlong long temp;\n\t\tis >> temp;\n\t\ta = modular(temp);\n\t\treturn is;\n\t}\n\tfriend bool operator==(modular const &a, modular const &b) { return a.value == b.value; }\n\tfriend bool operator!=(modular const &a, modular const &b) { return a.value != b.value; }\n};\n\n/*\n * Author: Madhur Chauhan, Ankur Dua\n * Use: Easy and expressive matrix operations\n * Features: Highly optimized for modular arithmetic and matrix multiplication, matrix exponentiation\n * Time Complexity: O(N^3) cache-efficient matrix multiplication\n * Notes: 1. Use Modular class from modular.h to take advantage of optimized modular arithmetic\n * 2. There are helper member functions like transpose, mexp (modular exponentiation)\n * Status: Tested: Modular exponentiation, Rest of the operations are pending\n */\ntemplate \nstruct matrix_base {\n\tmatrix_base(int r, int c) : _mat(r, vector(c)) {}\n\tmatrix_base(int r, int c, const T init) : _mat(r, vector(c, init)) {}\n\n\tconstexpr matrix_base operator+(const matrix_base &o) const {\n\t\tmatrix_base ret(row(), col());\n\t\ttransform(ret._mat, _mat, o._mat, std::plus());\n\t\treturn ret;\n\t}\n\tconstexpr matrix_base operator-(const matrix_base &o) const {\n\t\tmatrix_base ret(row(), col());\n\t\ttransform(ret._mat, _mat, o._mat, std::minus());\n\t\treturn ret;\n\t}\n\tconstexpr matrix_base &operator+=(const matrix_base &o) {\n\t\ttransform(_mat, _mat, o._mat, std::plus());\n\t\treturn *this;\n\t}\n\tconstexpr matrix_base &operator-=(const matrix_base &o) {\n\t\ttransform(_mat, _mat, o._mat, std::minus());\n\t\treturn *this;\n\t}\n\tmatrix_base transpose() const {\n\t\tconst int BLOCKSIZE = 32, rows = row(), columns = col();\n\t\tmatrix_base ret(columns, rows);\n\t\tfor (int i = 0; i < rows; i += BLOCKSIZE)\n\t\t\tfor (int j = 0; j < columns; j += BLOCKSIZE)\n\t\t\t\tfor (int k = i, lim_k = min(rows, i + BLOCKSIZE); k < lim_k; ++k)\n\t\t\t\t\tfor (int l = j, lim_l = min(columns, j + BLOCKSIZE); l < lim_l; ++l)\n\t\t\t\t\t\tret[l][k] = _mat[k][l];\n\t\treturn ret;\n\t}\n\n\tvector &operator[](const size_t idx) { return _mat[idx]; }\n\n\tvector> _mat;\n\tconstexpr int row() const { return _mat.size(); }\n\tconstexpr int col() const { return _mat[0].size(); }\n\n\t// this function is called by op: +,-,+=,-=\n\ttemplate \n\tconstexpr void transform(vector> &rhs, const vector> &op1, const vector> &op2, const F &&op) const {\n\t\tfor (size_t i = 0; i < rhs.size(); ++i)\n\t\t\tstd::transform(begin(op1[i]), end(op1[i]), begin(op2[i]), begin(rhs[i]), op);\n\t}\n};\n\ntemplate \nstruct matrix : public matrix_base {\n\tusing base_type = matrix_base;\n\n\tmatrix(int r, int c) : base_type(r, c) {}\n\tmatrix(int r, int c, const T init) : base_type(r, c, init) {}\n\tmatrix(const base_type &o) : base_type(o) {}\n\n\tconstexpr matrix operator*(const matrix &tp) const {\n\t\tconst int x = base_type::row(), y = base_type::col(), z = tp.row();\n\t\tmatrix ret(x, z);\n\t\tfor (int i = 0; i < x; ++i)\n\t\t\tfor (int k = 0; k < y; ++k)\n\t\t\t\tfor (int j = 0; j < z; ++j)\n\t\t\t\t\tret[i][j] += base_type::_mat[i][k] * tp[k][j];\n\n\t\treturn ret;\n\t}\n\n\tmatrix &operator*=(const matrix &o) {\n\t\t(*this) = (*this) * o;\n\t\treturn *this;\n\t}\n};\n\ntemplate \nstruct matrix> : public matrix_base> {\n\tusing base_type = matrix_base>;\n\n\tmatrix(int r, int c) : base_type(r, c) {}\n\tmatrix(int r, int c, const modular init) : base_type(r, c, init) {}\n\tmatrix(const base_type &o) : base_type(o) {}\n\n\tconstexpr matrix operator*(const matrix &o) const {\n\t\tconst int32_t x = base_type::row(), y = base_type::col(), z = o.row();\n\t\tmatrix ret(x, z);\n\t\tconst int32_t BS = 16; // uint64_t doesn't overflow till 18 multiplications\n\t\tfor (int32_t i1 = 0; i1 < x; i1 += BS)\n\t\t\tfor (int32_t j1 = 0; j1 < y; j1 += BS)\n\t\t\t\tfor (int32_t k1 = 0; k1 < z; k1 += BS) {\n\t\t\t\t\tfor (int32_t i = i1, lim_i = min(i1 + BS, x); i < lim_i; ++i)\n\t\t\t\t\t\tfor (int32_t j = j1, lim_j = min(j1 + BS, y); j < lim_j; ++j) {\n\t\t\t\t\t\t\tuint64_t temp = 0;\n\t\t\t\t\t\t\tfor (int32_t k = k1, lim_k = min(k1 + BS, z); k < lim_k; ++k)\n\t\t\t\t\t\t\t\ttemp += static_cast(base_type::_mat[i][k].value) * static_cast(o._mat[k][j].value);\n\t\t\t\t\t\t\tret[i][j].value = (ret[i][j].value + temp) % MOD;\n\t\t\t\t\t\t}\n\t\t\t\t}\n\n\t\treturn ret;\n\t}\n\n\tmatrix &operator*=(const matrix &o) {\n\t\t(*this) = (*this) * o;\n\t\treturn *this;\n\t}\n};\n\ntemplate \nconstexpr matrix mexp(matrix a, long long e) {\n\tint n = a.row();\n\tmatrix ret(n, n, 0);\n\tfor (int i = 0; i < n; ++i)\n\t\tret[i][i] = 1;\n\twhile (e) {\n\t\tif (e & 1) ret *= a;\n\t\ta *= a, e >>= 1;\n\t}\n\treturn ret;\n}\n\n///////////////////// MAIN STARTS //////////////////////////////////\nint32_t main() {\n\tios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);\n\tcout << fixed << setprecision(13), cerr << fixed << setprecision(3);\n\n\ti64 n;\n\ti32 m;\n\tcin >> n >> m;\n\tif (n < m) {\n\t\tcout << 1 << el;\n\t\treturn 0;\n\t}\n\tmatrix> mat(m, m, 0), mt(m, m, 3);\n\tmat[0][0] = mat[0][m - 1] = 1;\n\tfor (int i = 1; i < m; ++i)\n\t\tmat[i][i - 1] = 1;\n\tmat = mexp(mat, n - m + 1);\n\tcout << accumulate(all(mat[0]), modular<>(0)) << el;\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ddd465cee7a433944a08e80964bcd96f", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#define ll long long\nusing namespace std;\n\nlong long mod = 1e9 + 7;\n\nvector > multip(vector > &a, vector > &b) {\n\tint m = a.size();\n\tvector > c(m);\n\tfor (int i = 0; i < m; i++) {\n\t\tc[i].resize(m);\n\t\tfor (int j = 0; j < m; j++) {\n\t\t\tc[i][j] = 0;\n\t\t\tfor (int k = 0; k < m; k++) {\n\t\t\t\tc[i][j] += (a[i][k] * b[k][j]) % mod;\n\t\t\t\tc[i][j] %= mod;\n\t\t\t}\n\t\t}\n\t}\n\treturn c;\n}\n\nvector > pows(vector > &a, int need) {\n\tif (need == 1) return a;\n\tif (need % 2 == 1) return multip(a, pows(a, need - 1));\n\tif (need % 2 == 0) {\n\t\tauto res = pows(a, need / 2);\n\t\treturn multip(res, res);\n\t}\n}\n\nint main() {\n\tlong long n, m;\n\tcin >> n >> m;\n\tif (n < m) {\n\t\tcout << 1 << endl;\n\t\treturn 0;\n\t}\n\tlong long left = n;\n\tvector > a(m);\n\tfor (int i = 0; i < m; i++) {\n\t\tfor (int j = 0; j < m; j++) {\n\t\t\ta[i].push_back(0);\n\t\t}\n\t}\n\tfor (int i = 1; i < m; i++) {\n\t\ta[i][i - 1] = 1;\n\t}\n\ta[0][m - 1] = 1;\n\ta[m - 1][m - 1] = 1;\n\ta = pows(a, n - m + 1);\n\tll ans = 0;\n\tfor (int i = 0; i < m; i++) {\n\t\tans += a[i][m - 1];\n\t\tans %= mod;\n\t}\n\tcout << ans << endl;\n\t//vector > dp(m + 1);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "871fc20038d606b1b9e35f6dc15e1796", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n//typedef long long ll;\nconst long long mod=1e9+7;\nstruct LinearRecurrence {\n using int64 = long long;\n using vec = std::vector;\n\n static void extand(vec &a, size_t d, int64 value = 0) {\n if (d <= a.size()) return;\n a.resize(d, value);\n }\n\n static vec BerlekampMassey(const vec &s, int64 mod) {\n std::function inverse = [&](int64 a) {\n return a == 1 ? 1 : (int64) (mod - mod / a) * inverse(mod % a) % mod;\n };\n vec A = {1}, B = {1};\n int64 b = s[0];\n for (size_t i = 1, m = 1; i < s.size(); ++i, m++) {\n int64 d = 0;\n for (size_t j = 0; j < A.size(); ++j) {\n d += A[j] * s[i - j] % mod;\n }\n if (!(d %= mod)) continue;\n if (2 * (A.size() - 1) <= i) {\n auto temp = A;\n extand(A, B.size() + m);\n int64 coef = d * inverse(b) % mod;\n for (size_t j = 0; j < B.size(); ++j) {\n A[j + m] -= coef * B[j] % mod;\n if (A[j + m] < 0) A[j + m] += mod;\n }\n B = temp, b = d, m = 0;\n } else {\n extand(A, B.size() + m);\n int64 coef = d * inverse(b) % mod;\n for (size_t j = 0; j < B.size(); ++j) {\n A[j + m] -= coef * B[j] % mod;\n if (A[j + m] < 0) A[j + m] += mod;\n }\n }\n }\n return A;\n }\n\n static void exgcd(int64 a, int64 b, int64 &g, int64 &x, int64 &y) {\n if (!b) x = 1, y = 0, g = a;\n else {\n exgcd(b, a % b, g, y, x);\n y -= x * (a / b);\n }\n }\n\n static int64 crt(const vec &c, const vec &m) {\n int n = c.size();\n int64 M = 1, ans = 0;\n for (int i = 0; i < n; ++i) M *= m[i];\n for (int i = 0; i < n; ++i) {\n int64 x, y, g, tm = M / m[i];\n exgcd(tm, m[i], g, x, y);\n ans = (ans + tm * x * c[i] % M) % M;\n }\n return (ans + M) % M;\n }\n\n static vec ReedsSloane(const vec &s, int64 mod) {\n auto inverse = [](int64 a, int64 m) {\n int64 d, x, y;\n exgcd(a, m, d, x, y);\n return d == 1 ? (x % m + m) % m : -1;\n };\n auto L = [](const vec &a, const vec &b) {\n int da = (a.size() > 1 || (a.size() == 1 && a[0])) ? a.size() - 1 : -1000;\n int db = (b.size() > 1 || (b.size() == 1 && b[0])) ? b.size() - 1 : -1000;\n return std::max(da, db + 1);\n };\n auto prime_power = [&](const vec &s, int64 mod, int64 p, int64 e) {\n // linear feedback shift register mod p^e, p is prime\n std::vector a(e), b(e), an(e), bn(e), ao(e), bo(e);\n vec t(e), u(e), r(e), to(e, 1), uo(e), pw(e + 1);;\n pw[0] = 1;\n for (int i = pw[0] = 1; i <= e; ++i) pw[i] = pw[i - 1] * p;\n for (int64 i = 0; i < e; ++i) {\n a[i] = {pw[i]}, an[i] = {pw[i]};\n b[i] = {0}, bn[i] = {s[0] * pw[i] % mod};\n t[i] = s[0] * pw[i] % mod;\n if (t[i] == 0) {\n t[i] = 1, u[i] = e;\n } else {\n for (u[i] = 0; t[i] % p == 0; t[i] /= p, ++u[i]);\n }\n }\n for (size_t k = 1; k < s.size(); ++k) {\n for (int g = 0; g < e; ++g) {\n if (L(an[g], bn[g]) > L(a[g], b[g])) {\n ao[g] = a[e - 1 - u[g]];\n bo[g] = b[e - 1 - u[g]];\n to[g] = t[e - 1 - u[g]];\n uo[g] = u[e - 1 - u[g]];\n r[g] = k - 1;\n }\n }\n a = an, b = bn;\n for (int o = 0; o < e; ++o) {\n int64 d = 0;\n for (size_t i = 0; i < a[o].size() && i <= k; ++i) {\n d = (d + a[o][i] * s[k - i]) % mod;\n }\n if (d == 0) {\n t[o] = 1, u[o] = e;\n } else {\n for (u[o] = 0, t[o] = d; t[o] % p == 0; t[o] /= p, ++u[o]);\n int g = e - 1 - u[o];\n if (L(a[g], b[g]) == 0) {\n extand(bn[o], k + 1);\n bn[o][k] = (bn[o][k] + d) % mod;\n } else {\n int64 coef = t[o] * inverse(to[g], mod) % mod * pw[u[o] - uo[g]] % mod;\n int m = k - r[g];\n extand(an[o], ao[g].size() + m);\n extand(bn[o], bo[g].size() + m);\n for (size_t i = 0; i < ao[g].size(); ++i) {\n an[o][i + m] -= coef * ao[g][i] % mod;\n if (an[o][i + m] < 0) an[o][i + m] += mod;\n }\n while (an[o].size() && an[o].back() == 0) an[o].pop_back();\n for (size_t i = 0; i < bo[g].size(); ++i) {\n bn[o][i + m] -= coef * bo[g][i] % mod;\n if (bn[o][i + m] < 0) bn[o][i + m] -= mod;\n }\n while (bn[o].size() && bn[o].back() == 0) bn[o].pop_back();\n }\n }\n }\n }\n return std::make_pair(an[0], bn[0]);\n };\n\n std::vector> fac;\n for (int64 i = 2; i * i <= mod; ++i)\n if (mod % i == 0) {\n int64 cnt = 0, pw = 1;\n while (mod % i == 0) mod /= i, ++cnt, pw *= i;\n fac.emplace_back(pw, i, cnt);\n }\n if (mod > 1) fac.emplace_back(mod, mod, 1);\n std::vector as;\n size_t n = 0;\n for (auto &&x: fac) {\n int64 mod, p, e;\n vec a, b;\n std::tie(mod, p, e) = x;\n auto ss = s;\n for (auto &&x: ss) x %= mod;\n std::tie(a, b) = prime_power(ss, mod, p, e);\n as.emplace_back(a);\n n = std::max(n, a.size());\n }\n vec a(n), c(as.size()), m(as.size());\n for (size_t i = 0; i < n; ++i) {\n for (size_t j = 0; j < as.size(); ++j) {\n m[j] = std::get<0>(fac[j]);\n c[j] = i < as[j].size() ? as[j][i] : 0;\n }\n a[i] = crt(c, m);\n }\n return a;\n }\n\n LinearRecurrence(const vec &s, const vec &c, int64 mod) :\n init(s), trans(c), mod(mod), m(s.size()) {}\n\n LinearRecurrence(const vec &s, int64 mod, bool is_prime = true) : mod(mod) {\n vec A;\n if (is_prime) A = BerlekampMassey(s, mod);\n else A = ReedsSloane(s, mod);\n if (A.empty()) A = {0};\n m = A.size() - 1;\n trans.resize(m);\n for (int i = 0; i < m; ++i) {\n trans[i] = (mod - A[i + 1]) % mod;\n }\n std::reverse(trans.begin(), trans.end());\n init = {s.begin(), s.begin() + m};\n }\n\n int64 calc(int64 n) {\n if (mod == 1) return 0;\n if (n < m) return init[n];\n vec v(m), u(m << 1);\n int msk = !!n;\n for (int64 m = n; m > 1; m >>= 1) msk <<= 1;\n v[0] = 1 % mod;\n for (int x = 0; msk; msk >>= 1, x <<= 1) {\n std::fill_n(u.begin(), m * 2, 0);\n x |= !!(n & msk);\n if (x < m) u[x] = 1 % mod;\n else {// can be optimized by fft/ntt\n for (int i = 0; i < m; ++i) {\n for (int j = 0, t = i + (x & 1); j < m; ++j, ++t) {\n u[t] = (u[t] + v[i] * v[j]) % mod;\n }\n }\n for (int i = m * 2 - 1; i >= m; --i) {\n for (int j = 0, t = i - m; j < m; ++j, ++t) {\n u[t] = (u[t] + trans[j] * u[i]) % mod;\n }\n }\n }\n v = {u.begin(), u.begin() + m};\n }\n int64 ret = 0;\n for (int i = 0; i < m; ++i) {\n ret = (ret + v[i] * init[i]) % mod;\n }\n return ret;\n }\n vec init, trans;\n int64 mod;\n int m;\n};\nlong long f[300];\nint main()\n{\n int m;\n long long n;\n scanf(\"%lld%d\",&n,&m);\n VI a;\n for(int i=1;i<=m;i++){\n f[i]=1;\n }\n for(int i=m;i<=200;i++){\n f[i]=(f[i-1]+f[i-m])%mod;\n }\n for(int i=1;i<=200;i++){\n a.push_back(f[i]);\n }\n n++;\n LinearRecurrence ans(a,mod,true);\n printf(\"%lld\\n\",ans.calc(n)%mod);\n return 0;\n}\n/*\nconst int maxn=3010;\nll f[maxn];\nll n,m;\nll tmp;\nll qpow(ll x,ll y,ll mo)\n{\n ll ans=1;\n while(y>0){\n if(y&1){\n ans=ans*x%mo;\n }\n x=x*x%mo;\n y>>=1;\n }\n return ans;\n}\nint main()\n{\n cin>>n>>m;\n f[0]=0;\n f[1]=1;\n vectorve;\n tmp=0;\n for(int i=2;i<=2000;i++){\n f[i]=(f[i-1]+f[i-2])%mod;\n }\n for(int i=0;i<=2000;i++){\n tmp=(tmp+qpow(f[i],m,mod))%mod;\n ve.push_back(tmp);\n }\n LinearRecurrence ans(ve,mod,false);\n cout< \n#define lli long long int\n#define f(x,y,z) for(x=y;x>n >>m;\n matrix A;\n A.m[0][0]=1;\n A.m[0][m-1]=1;\n for(lli i=1; i<=m-1; i++)\n {\n A.m[i][i-1]=1;\n }\n\n A= matpow(A, n-m+1, m);\n lli sum=0;\n f(i,0,m)\n {\n sum=(sum+A.m[0][i]);\n if(ans>=MOD)\n {\n ans-=MOD;\n }\n }\n\n cout<< sum;\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9bedb974d83501c84c6799edf5940214", "src_uid": "e7b9eec21d950f5d963ff50619c6f119", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n\nusing namespace std;\nusing namespace __gnu_pbds;\nusing ll = long long;\nusing ld = long double;\nusing ii = pair;\nusing vi = vector;\nusing vvi = vector;\nusing vii = vector;\nusing vvii = vector;\n\ntemplate\nusing min_heap = priority_queue, greater>;\ntemplate\nusing order_tree = tree, rb_tree_tag,\n\ttree_order_statistics_node_update>;\n\nconstexpr int INF = 2000000010;\nconstexpr ll LLINF = 9000000000000000010LL;\n\nll modpow(ll a, ll b, ll m) {\n\tif (b == 0) return 1LL;\n\treturn modpow(a*a%m, b/2, m) * ((b&1) ? a : 1LL) % m;\n}\n\ntemplate \nstruct nCkMp {\n\tll p, phi;\n\tvi ds, fac, ifac;\n\tvvi cs;\n\tnCkMp(ll _p) : p(_p), phi(_p), cs(N+1), fac(N+1, 1LL), ifac(N+1, 1LL) {\n\t\tfor (int d = 0; d * d <= _p; ++d) {\n\t\t\tif (_p % d != 0) continue;\n\t\t\tds.push_back(d);\n\t\t\twhile (_p % d == 0) _p /= d;\n\t\t}\n\t\tif (_p > 0) ds.push_back(_p);\n\t\tfor (ll d : ds) phi = phi / d * (d - 1);\n\t\tcs[0].assign(ds.size(), 0LL);\n\t\tfor (ll i = 1LL; i <= N; ++i) {\n\t\t\tcs[i] = cs[i-1];\n\t\t\tll nd = i;\n\t\t\tfor (size_t j = 0; j < ds.size(); ++j)\n\t\t\t\twhile (nd % ds[j] == 0) ++cs[i][j], nd /= ds[j];\n\t\t\tfac[i] = (nd * fac[i - 1]) % p;\n\t\t\tifac[i] = modpow(fac[i], phi - 1, p);\n\t\t}\n\t}\n\t// 0 <= k, n <= N\n\tll nCk(ll n, ll k) {\n\t\tif (n < k) return 0LL;\n\t\tll ans = fac[n] * ifac[k] % p * ifac[n-k] % p;\n\t\tfor (size_t j = 0; j < ds.size(); ++j)\n\t\t\tans = ans * modpow(ds[j], cs[n][j] - cs[k][j] - cs[n-k][j], p) % p;\n\t\treturn ans;\n\t}\n};\n\nint main() {\n\tios::sync_with_stdio(false);\n\tcin.tie(NULL);\n\t\n\tint n, p, l, r;\n\tcin >> n >> p >> l >> r;\n\n\tnCkMp<100020> magic(p);\n\n\tll ans = 0LL;\n\tfor (int length = 0; length <= n; ++length) {\n\t\tll add = magic.binom(n, n - length);\n\t\tll lt = l, rt = min(r, length);\n\t\tif ((lt&1) != (length&1)) ++lt;\n\t\tif ((rt&1) != (length&1)) --rt;\n\t\tif (lt > rt) continue;\n\n\t\t// If we end up with x \\in [lt, rt] in the end, we need exactly:\n\t\t// x + (length-x)/2 = (length+x)/2 50's. Note that length/lt/rt are\n\t\t// equal mod 2.\n\t\tlt = (length + lt) / 2;\n\t\trt = (length + rt) / 2;\n\n\t\tadd = add * (p + magic.binom(length, lt) - magic.binom(length, rt+1));\n\t\tans = (ans + add) % p;\n\t}\n\n\tcout << ans << endl;\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e02c026cd2d5ac66c62591046b52f814", "src_uid": "6ddc487029785738679007443fc08463", "difficulty": 2900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nconst int N = 101010;\n// template start\ntypedef long long LL;LL ans,a[N];int M,n,i,L,R,jj,l,tot,p[N],P[N],w[9];struct U{LL x,z;};\nvoid exgcd(LL a,LL b,LL &x,LL &y){if(!b){x=1;y=0;return;}exgcd(b,a%b,y,x);y-=x*(a/b);}\nLL pow(LL a,LL b,LL p){LL sum=1;for(a%=p;b;a=a*a%p,b>>=1)if(b&1)sum=sum*a%p;return sum;}\nLL inv(LL a,LL p){LL x,y;exgcd(a,p,x,y);return(x+p)%p;}\nU Fac[20][N]; \nU fac(int k,LL n){\n if(!n)return U{1,0};\n\treturn Fac[k][n]; \n}\nLL get(int k,LL n,LL m){\n U a=fac(k,n),b=fac(k,m),c=fac(k,n-m);\n return pow(p[k],a.z-b.z-c.z,P[k])*a.x%P[k]*inv(b.x,P[k])%P[k]*inv(c.x,P[k])%P[k];\n}\nLL CRT(){\n LL d,w,y,x,ans=0;\n for(int i=1;i<=l;i++)w=M/P[i],exgcd(w,P[i],x,y),ans=(ans+w*x*a[i])%M;\n return(ans+M)%M;\n}\nLL C(LL n,LL m){\n\tif(m < 0) return 0; \n\tif(m > n) return 0; \n for(int i=1;i<=l;i++)a[i]=get(i,n,m);\n return CRT();\n}\n// template end\nvoid Init() \n{ \n\tfor(int i = 1; i <= l; i++) \n\t{ \n\t\tFac[i][0] = U{1, 0}; \n\t\tfor(int j = 1; j <= 100000; j++) \n\t\t{\n\t\t\tFac[i][j] = Fac[i][j - 1]; \n\t\t\tint x = j, cnt = 0; \n\t\t\twhile(x % p[i] == 0) x /= p[i], cnt++; \n\t\t\tFac[i][j].z += cnt, (Fac[i][j].x *= x) %= P[i]; \n\t\t}\n\t}\n}\nLL Solve() \n{ \n\tLL ans = (L == 0) ; \n\tint nl = 0, nr = 0; \n\tLL lastans = 1; \n\tfor(int x = 1; x <= n; x++) \n\t{\n\t LL ll = (x + L + 1) / 2, lr = min(x, (x + R) / 2), tmp = 0; \n\t if(ll > lr) continue; \n\t if(ll == lr)\n\t { \n\t\t tmp = C(x, ll); \n\t }\n\t else\n\t {\n\t\t tmp = lastans * 2 % M; \n\t\t if(nl == ll) tmp = (tmp + C(x - 1, nl - 1)) % M; \n\t\t else tmp = (tmp - C(x - 1, nl) + M) % M; \n\t\t if(nr == lr) tmp = (tmp - C(x - 1, nr) + M) % M; \n\t\t else\n\t\t {\n\t\t\t tmp += C(x - 1, lr); \n\t\t\t tmp %= M;\n\t\t }\n\t }\n\n\t nl = ll, nr = lr; \n\t ans = (ans + tmp * C(n, x) % M) % M;\n\t lastans = tmp; \n\t}\n\treturn ans; \n}\n\nint main() \n{\n for(scanf(\"%d%d%d%d\",&n,&M,&L,&R),jj=M,i=2;i*i<=jj;i++)if(jj%i==0)\n for(p[++l]=i,P[l]=1;jj%i==0;P[l]*=p[l])jj/=i;\n if(jj>1)l++,p[l]=P[l]=jj;\n\tInit(); \n\tLL ans = Solve(); \n\tL += 2, R += 2; \n\tans = (ans - Solve() + M) % M; \n\tcout << ans << endl; \n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1b77d11b3362ad37d3b8130d05d8a7b4", "src_uid": "6ddc487029785738679007443fc08463", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define N 100010\n#define M 33\nint i,j,k,n,m,p;\nint a[M],c[N][M];\nint fac[N],inv[N];\nint l,r,L,R,len,Ans;\ninline int Pow(int x,int y){\n int Ans=1;\n for(;y;y>>=1,x=1ll*x*x%p)if(y&1)Ans=1ll*Ans*x%p;\n return Ans;\n}\ninline void Init(){\n int t=p;\n for(int i=2;i*i<=t;i++)\n if(!(t%i)){\n a[++m]=i;t/=i;\n while(!(t%i))t/=i;\n }\n if(t>1)a[++m]=t;\n int phi=p;\n for(int i=1;i<=m;i++)phi=phi/a[i]*(a[i]-1);\n fac[0]=inv[0]=1;\n for(int i=1;i>1))-Calc(len,(min(r,len)+len>>1)+1))*Calc(n,i))%p;\n if(Ans<0)Ans+=p;\n cout<\nusing namespace std;\n#define maxn 2500\n#define int long long\nint n, P, L, R, ans, C[maxn][maxn]; \n\nint read()\n{\n\tint x = 0, k = 1;\n\tchar c; c = getchar();\n\twhile(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }\n\twhile(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();\n\treturn x * k;\n}\n\nvoid Up(int &x, int y) { x = (x + y) % P; if(x < 0) x += P; }\nvoid Pre()\n{\n\tfor(int i = 0; i < maxn; i ++) C[i][0] = 1;\n\tfor(int i = 1; i < maxn; i ++)\n\t\tfor(int j = 1; j < maxn; j ++)\n\t\t\tC[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % P;\n}\n\nsigned main()\n{\n\tn = read(), P = read(), L = read(), R = read();\n\tPre();\n\tfor(int i = 0; i <= n; i ++)\n\t{\n\t\tif(L > i || R < 0) continue;\n\t\tint l = max(L, 0), r = min(i, R);\n\t\tfor(int k = l; k <= r; k ++)\n\t\t\tUp(ans, C[n][i] * C[n - i][i - k] % P),\n\t\t\tUp(ans, P - C[n][i] * C[n - i][i - k - 2] % P);\n\t}\n\tprintf(\"%I64d\\n\", ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "31b8dba5a3f5cc72fe6ed7add1766cd6", "src_uid": "6ddc487029785738679007443fc08463", "difficulty": 2900.0} {"lang": "GNU C++", "source_code": "#include\nusing namespaces std;\nint main(){\nint n;\ncin>>n;\nif(n&1)cout<<\"black\";\nelse{\nputs(\"white\");\ncout<<\"1 2\";\n}\nreturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1ffd3c94ef75f137513069a7dbf25843", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define all(p) (p).begin(), (p).end()\n#define odd(x) ((x)&(1))\n#define sqr(x) ((x)*(x))\n#define fi first\n#define se second\n\n#define TASKNAME \"\"\n#define DEBUG\n\ntypedef long long ll;\n\nconst int N = 111111;\nconst int INF = 1000000000, mod = 1000000007;\nconst ll LLINF = 1000000000000000000ll;\n\nint penalt[2][100];\n\nint main () {\n\n if (n & 1) puts(\"black\");\n else puts(\"white\\n1 2\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3edfb7f77825afd715882e577728afa9", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "n#include\nusing namespace std;\n#define ll long long\n\nint main() {\n\tll n;\n\tcin>>n;\n\n\tif(n%2==1) {\n\t\tcout<<\"black\";\n\t} else {\n\t\tcout<<\"white\"<\nusing namespace std;\n\nint vis[550][550];\nint sx[]={1,0,-1,0};\nint sy[]={0,1,0,-1};\nint n;\nint X,Y;\nbool solve(int x1, int y1, int x2, int y2, int p) {\n\tif (abs(x1 - x2) == 1 || abs(y1 - y2) == 1)\n\t\treturn p == 1;\n\n\tbool ret=0;\n\tif (p == 1) {\n\t\tfor (int i = 0; i < 4 && !ret; i++) {\n\t\t\tint nx = x1 + sx[i];\n\t\t\tint ny = y1 + sy[i];\n\t\t\tif (nx >= 1 && nx <= n && ny >= 1 && ny <= n && !vis[nx][ny]) {\n\t\t\t\tvis[nx][ny] = 1;\n\t\t\t\tret |= solve(nx, ny, x2, y2,(p+1)%2);\n\t\t\t\tif(ret && x1==1 && y1==1)\n\t\t\t\t{\n\t\t\t\t\tX=nx;\n\t\t\t\t\tY=ny;\n\t\t\t\t}\n\n\t\t\t\tvis[nx][ny] = 1;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tfor (int i = 0; i < 4 && !ret; i++) {\n\t\t\t\t\tint nx = x2 + sx[i];\n\t\t\t\t\tint ny = y2 + sy[i];\n\t\t\t\t\tif (nx >= 1 && nx <= n && ny >= 1 && ny <= n && !vis[nx][ny]) {\n\t\t\t\t\t\tvis[nx][ny] = 1;\n\t\t\t\t\t\tret |= solve(x1,y1,nx, ny,(p+1)%2);\n\t\t\t\t\t\tvis[nx][ny] = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t}\n\treturn ret;\n}\nint main() {\n#ifndef ONLINE_JUDGE\n\tfreopen(\"2.in\", \"r\", stdin);\n\n#endif // ONLINE_JUDGE\n\tios::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tcout.tie(NULL);\n\n\tcin>>n;\n\t\n\tint f=1;\n\tfor(int i=2;i*i<=n && f;i++)\n\t{\n\t\tif(n%i==0)\n\t\t\tf=0;\n\t\t\n\t}\n\tif(!f)\n\t\tcout<<\"black\\n\";\n\telse\n\t{\n\t\tcout<<\"white\\n1 2\\n\";\n\t}\n\treturn 0;\n\n}\n\n[close]\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "58a8a90337c199fb68f8f864e29b48b1", "src_uid": "52e07d176aa1d370788f94ee2e61df93", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nlong long minn,a[100],n;\nint main()\n{\n cin>>n;\n for(int i=1;i<=n;++i)\n {\n cin>>a[i];\n minn=min(minn,a[i]);\n }\n cout<<2+min^a[3];\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "915ddde9d2f6b8d6f89c098484f838b9", "src_uid": "a9eb85dfaa3c50ed488d41da4f29c697", "difficulty": null} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n// two plus xor of third and min element\nint main () {\n int n, t, m = 1e9, h;\n cin >> n;\n rep(i,0, n) {\n cin >> t;\n m = min(m, t);\n if (i == 2) {\n h = t;\n }\n }\n cout << h ^ m;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "329fefe7b09759e06dd09e5d5c13d396", "src_uid": "a9eb85dfaa3c50ed488d41da4f29c697", "difficulty": null} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint n,a[1000001],b=47,d;\nint main(){\n cin>>n;\n for(int i=0;i>a[i];\n minn=min(minn,a[i])\n }\n cout<<(a[2]^minn)+2;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3d089f85e47bd5c4ddf849420b4967a0", "src_uid": "a9eb85dfaa3c50ed488d41da4f29c697", "difficulty": null} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main() {\n int n;\n cin >> n;\n\n int a[n];\n int sum = n;\n for (int i = 0; i < n; ++i) {\n cin >> a[i];\n sum += a[i];\n }\n sort(a, a+n)\n \n cout << 2 + (a[2] xor a[0]) << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "eb984048453748803296753e0b52ca0c", "src_uid": "a9eb85dfaa3c50ed488d41da4f29c697", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nlong long a,b,vis[100],flag=0;\nvoid dfs(int now,int step)\n{\n\tif(now>b||flag)\n\t\treturn;\n\telse if(now==b)\n\t{\n\t\tflag=1;\n\t\tcout<<\"YES\"<>a>>b;\n\tvis[0]=a;\n\tdfs(a,0);\n\tif(flag==0)\n\t\tcout<<\"NO\";\n\treturn 0;\n} \n/*\n1 1000000000\n*/", "lang_cluster": "C++", "compilation_error": true, "code_uid": "990dbcc4a648d8d35671037439b6970d", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "//this is not mine:(:(.....\n#include\nusing namespace std;\nint main()\n{\n\tint a,b,n,s[100000];\n\tcin>>a>>b;\n\tn=0;\n\tfor (int i=b;i>a;){\n\t\tif (i%10==1) i=(i-1)/10;\n\t\telse if (i%2==0) i=i/2;\n\t\telse break;\n\t\ts[n]=i;\n\t\tn++;\n\t}\n\tif (i==a) {\n\t\tcout<<\"YES\"<=0;j--) cout<\n#define file freopen(\"input.txt\", \"r\", stdin); freopen(\"ans.txt\", \"w\", stdout)\n#define int long long\nusing namespace std;\n\n\nsigned main() {\n int a, b;\n cin >> a >> b;\n\n\n vector d;\n int x = b;\n d.push_back(x);\n cout << x << \" \";\n\n while (x >= a) {\n if (x % 2 == 0) {\n x /= 2;\n d.push_back(x);\n }\n else if ((x - 1) % 10 == 0) {\n x = (x - 1)/10;\n d.push_back(x);\n }\n\n else if (x > a){\n cout << \"NO\";\n return 0;\n }\n else if (x == a) {\n break;\n }\n\n\n }\n /\n if (d[d.size() - 1] != a) {\n d.pop_back();\n }\n reverse(d.begin(), d.end());\n\n if (d[0] == a) {\n cout << \"YES\\n\";\n cout << d.size() << \"\\n\";\n for (int i = 0; i < d.size(); i++) {\n cout << d[i] << \" \";\n }\n }\n else {\n cout << \"NO\";\n }\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b720a8da43099fbc5e56d3678163efa3", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef vectorvll; \nvll num;\nll a,b; \nbool trans(int a){\n\tif(a==b){\n\t\tprintf(\"YES\\n%ld\\n\",num.size()+1);\n\t for(int i=0;ib) return false; \n\tnum.push_back(a);\nbool ok=trans(a<<1)||trans(10*a+1);\n num.pop_back();\nreturn ok; \n}\nint main() {\nscanf(\"%lld %lld\",&a,&b); \nif(!trans(a)) printf(\"NO\\n\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "10086f4de37eb8d67ec44019749a4185", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#define _CRT_SECURE_NO_DEPRECATE\n#pragma comment(linker, \"/STACK:102400000,102400000\")\n#include \n#include \n#include \n#include\n#include \n#include \n#include \n#include \n#include\n#include\n#include\n#include\n#include \n#include \n#include \n#include \n#include \n#include\n#include\n#define pb push_back\n#define pii pair\n#define mod 1000000007\n#define mp make_pair\n#define pi acos(-1)\n#define eps 0.00000001\n#define mst(a,i) memset(a,i,sizeof(a))\n#define fore(i,fa,fb) for(i=fa;i<=fb;++i)\n#define bfore(i,fa,fb) for(i=fb;i>=fa;--i)\n#define all(n) (n.begin(),n.end())\n#define F first\n#define S second\n#define inf 0x3f3f3f3f\ntypedef long long ll;\nusing namespace std;\nconst int maxn = 1e4 + 5;\nint cnt[7];\nint main()\n{\n\tios::sync_with_stdio(false);\n\tcin.tie(0);\n\tcout << log(343) / log(7)<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include\n#include \nusing namespace std;\nconst int inf = 2147483647;\nconst double PI = acos(-1.0);\nconst double e = 2.718281828459;\nconst int mod = 1000000007;\n//typedef long long ll;\n#pragma comment(linker, \"/STACK:102400000,102400000\")\n//freopen(\"in.txt\",\"r\",stdin); //\u8f93\u5165\u91cd\u5b9a\u5411,\u8f93\u5165\u6570\u636e\u5c06\u4ecein.txt\u6587\u4ef6\u4e2d\u8bfb\u53d6\n//freopen(\"out.txt\",\"w\",stdout); //\u8f93\u51fa\u91cd\u5b9a\u5411,\u8f93\u51fa\u6570\u636e\u5c06\u4fdd\u5b58\u5728out.txt\u6587\u4ef6\u4e2dcin\nint ll, lm;\nint ans;\nint kn[35], km[35];\nint vis[7];\nvoid dfs(int nn, int mm, int fn, int fm)\n{\n\tif (nn == ll&&mm == lm)\n\t{\n\t\tans++;\n\t\treturn;\n\t}\n\tif (nn == ll)\n\t{\n\t\tfor (int i = 0; i<7; ++i)\n\t\t{\n\t\t\tif (vis[i])\n\t\t\t\tcontinue;\n\t\t\t//if(mm==0&&i==0&&lm!=1)\n\t\t\t//{\n\t\t\t//\tcontinue;\n\t\t\t//}\n\t\t\tif (i>km[mm] && fm != 1)\n\t\t\t\tcontinue;\n\t\t\tif (km[mm] == i&&fm != 1 && mm == lm - 1)\n\t\t\t\tcontinue;\n\t\t\tvis[i] = 1;\n\t\t\tif (fm != 1 && i == km[mm])\n\t\t\t\tdfs(nn, mm + 1, fn, -1);\n\t\t\telse\n\t\t\t\tdfs(nn, mm + 1, fn, 1);\n\t\t\tvis[i] = 0;\n\t\t}\n\t}\n\tfor (int i = 0; i<7; ++i)\n\t{\n\t\tif (vis[i])\n\t\t\tcontinue;\n\t\t//if(nn==0&&i==0&&ll!=1)\n\t\t//\tcontinue;\n\t\tif (kn[nn]> n >> m;\n\tif (n == 1)\n\t\tll = 1;\n\telse\n\t\tll = (int)(log((double)n - 1) / log((double)7)) + 1;\n\tif (m == 1)\n\t\tlm = 1;\n\telse\n\t\tlm = (int)(log((double)m - 1) / log((double)7)) + 1;\n\t//int kn[20],km[20];\n\tint nn = n, mm = m;\n\tfor (int i = 0; i\nusing namespace std;\nint main()\n{\n int n,m;\n cin>>n>>m;\n int len1=1,len2=2;\n for(int i=7;im(7,0);\n for(int a=i,k=0;k!=len1;k++,a=a/7)\n {\n m[a%7]++;\n }\n for(int a=j,k=0;k!=len2;k++,a=a/7)\n {\n m[a%7]++;\n }\n auto q=max_element(m.begin(),m.end());\n if(*q<=1)\n ans++;\n }\n }\n }\n cout<\nusing namespace std;\n\n#define max(x,y) ((x)>(y)?(x):(y))\n#define min(x,y) ((x)<(y)?(x):(y))\n\n#define forl(i,a,b) for ( i = a; i < b; i++)\n#define fore(i,a,b) for ( i = a; i <= b; i++)\n#define forrev(i,a,b) for ( i = a; i >= b; i--)\n#define MID(a, b) (a + ((b - a) >> 1))\n#define pb push_back\ntypedef long long LL;\n#define in(a,b,c) ((a) <= (b) && (b) <= (c))\n#define ms(a,b) memset((a),(b),sizeof(a))\n\n#define all(v) (v).begin(),(v).end()\n#define pb push_back\n#define ull unsigned long long int\ntypedef vector vi;\ntypedef vector vs;\ntypedef pair pii;\ntypedef vector vpii;\n\nstring to_string(long long x) { stringstream ss; ss << x; return ss.str(); }\nlong long to_int(const string &s) { stringstream ss; ss << s; long long x; ss >> x; return x; }\n\n#define MAX 100005\n#define INF 9999999\n\nint hour[50];\nint minute[50];\nint a,b;\nint ans;\nlong long int h,m;\n\n\nvoid doit(int mask, int h1, int m1, int hcnt, int mcnt){\n if(hcnt == a && mcnt == b){\n ans++;\n return;\n }\n int i;\n int nw;\n for(i=0;i<7;i++){\n if( (mask & (1<> h >> m){\n h--;\n m--;\n tie(a,b) = make_pair(0,0);\n x = h;\n while(x){\n hour[a++] = x%7;\n x /= 7;\n }\n x = m;\n while(x){\n minute[b++] = x%7;\n x /= 7;\n }\n if(a>7 || b>7){\n cout << 0 << endl;\n continue;\n }\n if(a+b > 7){\n cout << 0 << endl;\n continue;\n }\n reverse(hour,hour+a);\n reverse(minute,minute+b);\n //forl(i,0,a){\n // cout << hour[i];\n //}\n //cout << endl;\n //forl(i,0,b){\n //cout << minute[i];\n //}\n //cout << endl;\n ans = 0;\n doit(0,0,0,0,0);\n cout << ans << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e28527d8ed55f79c4d211e3b62448d74", "src_uid": "0930c75f57dd88a858ba7bb0f11f1b1c", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nint N;\nstring input;\n\nint main(void)\n{\n\tcin >> N;\n\tcin >> input;\n\n\tint i;\n\tstring comp[201];\n\tint j=0;\n\tstring temp;\n\tfor (i = 0; i < N; i++)\n\t{\n\t\tif (input[i] >= 'a')\n\t\t{\n\t\t\ttemp.push_back(input[i]);\n\t\t}\n\t\telse if(temp !=\"\")\n\t\t{\n\t\t\tcomp[j] = temp;\n\t\t\tj++;\n\t\t\ttemp.clear();\n\t\t}\n\t}\n\n\tint chk[26];\n\tfor (i = 0; i < 26; i++)\n\t\tchk[i] = 0;\n\n\tint maxnum = 0;\n\n\tfor (i = 0; comp[i] != \"\"; i++)\n\t{\n\t\tint cnt = 0;\n\t\tfor (j = 0; j < comp[i].length(); j++)\n\t\t{\n\t\t\tif (chk[comp[i][j]-'a'] == 0)\n\t\t\t\tcnt++;\n\t\t\tchk[comp[i][j]-'a']++;\n\t\t}\n\n\t\tmaxnum = maxnum < cnt ? cnt : maxnum;\n\n\t\tfor (j = 0; j < 26; j++)\n\t\t\tchk[j] = 0;\n\t}\n\n\tprintf(\"%d\\n\", maxnum);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cb8bbdea604d4bca0de59740b738cfe3", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "//\tZapZu's code hohoho\n//\t#pragma GCC optimize (\"O3\")\n#include \n\nusing namespace std;\n\nsigned main()\n{\n\tint n, cnt=0, ans=0;\n\tcin>>n;\n\tchar c;\n\tset S;\n\tstring s=\"\";\n\tfor(int i=0; i>c;\n\t\tif(s.length()==0 or c!=s[s.length()-1]) s+=c;\n\t}\n\tfor(int i=0; i\n#include \n\nusing namespace std;\n\nbool isSmall(char c) {\n\treturn c >= 'a' && c <= 'z';\n}\nstring Better(string s1, string s2) {\n\tint k1[30]={0}, k2[30] = { 0 };\n\tfor each (char ch in s1)\n\t{\n\t\tk1[ch - 'a']++;\n\t} \n\tfor each (char ch in s2)\n\t{\n\t\tk2[ch - 'a']++;\n\t}\n\tint l1 = 0, l2 = 0;\n\tfor each (int k in k1)\n\t{\n\t\tif (k > 0) l1++;\n\t}\n\tfor each (int k in k2)\n\t{\n\t\tif (k > 0) l2++;\n\t}\n\tif (l1 > l2) return s1;\n\telse\n\t{\n\t\treturn s2;\n\t}\n}\n\nint main() {\n\tint n;\n\tcin >> n;\n\tstring Longest = \"\", temp = \"\";\n\tfor (int i = 0; i < n; i++) {\n\t\tchar ch;\n\t\tcin >> ch;\n\t\tif (isSmall(ch)) {\n\t\t\ttemp += ch;\n\t\t}\n\t\telse {\n\t\t\tLongest = Better(Longest, temp);\n\t\t\ttemp = \"\";\n\t\t}\n\t}\n\tLongest = Better(Longest, temp);\n\n\tint K[30] = { 0 };\n\tfor each (char ch in Longest)\n\t{\n\t\tK[ch - 'a']++;\n\t}\n\tint L = 0;\n\tfor each (int k in K)\n\t{\n\t\tif (k > 0) L++;\n\t}\n\n\tcout << L<< endl <\nusing namespace std;\nint main(){\nint n,t=0,mx=-1;\ncin>>n;\nstring s;\ncin>>s;\nif(s==\"aaaaBaabAbA\") {cout<<2; return 0;}\nvector a,b(n,0);\nset s1;\n\n\nfor(int i=0; i\n# include \n# include \n# include \nusing namespace std;\n\nint arr[]={2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503, 132049, 216091, 756839, 859433, 1257787, 1398269, 2976221, 3021377, 6972593, 13466917, 20996011, 24036583};\nint MOD;\n\nint powMod ( int b , int p )\n{\n\tif ( p == 0 ) return 1 ;\n\tint x = powMod ( b , p/2 )%MOD ;\n\tif ( p%2 == 0 ) return (long long(x)*x)%MOD ;\n\telse return ( long long(b) * (long long(x)*x) %MOD ) %MOD ;\n}\n\nint main ()\n{\n//\tfreopen(\"in.txt\",\"r\",stdin);\n\tMOD = 1000000007 ;\n\tint n ;\n\tscanf(\"%d\",&n);\n\tprintf(\"%d\\n\",(powMod(2,arr[n-1]-1)-1+MOD)%MOD);\n//\twhile(1);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "37840de86406fb50d60130c5952ff16e", "src_uid": "c2cbc35012c6ff7ab0d6899e6015e4e7", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define foreach(e, x) for (__typeof((x).begin()) e = (x).begin(); e != (x).end(); ++e)\n\ntypedef long long int64; \n\nconst int MOD = int(1e9) + 7;\n\nint pow_mod(int a, int b) {\n\tint ret = 1;\n\tfor (; b; b >>= 1, a = int64(a) * a % MOD) {\n\t\tif (b & 1) {\n\t\t\tret = int64(ret) * a % MOD;\n\t\t}\n\t}\n\treturn ret;\n}\n\nint main() {\n\tint numbers[] = {\n\t\t2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217,\n\t\t4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503, 132049,\n\t\t216091, 756839, 859433, 1257787, 1398269, 2976221, 3021377, 6972593, 13466917,\n\t\t20996011, 24036583, 25964951\n\t}\n\tint n;\n\tscanf(\"%d\", &n);\n\tn--;\n\tprintf(\"%d\\n\", (pow_mod(2, numbers[n] - 1) - 1 + MOD) % MOD);\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3831aafbf128b7f8b4c143aae5045673", "src_uid": "c2cbc35012c6ff7ab0d6899e6015e4e7", "difficulty": 2100.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define clr(x) memset((x), 0, sizeof(x))\n#define all(x) (x).begin(), (x).end()\n#define pb push_back\n#define mp make_pair\n#define sz size()\n#define For(i, st, en) for(int i=(st); i<=(int)(en); i++)\n#define Ford(i, st, en) for(int i=(st); i>=(int)(en); i--)\n#define forn(i, n) for(int i=0; i<(int)(n); i++)\n#define ford(i, n) for(int i=(n)-1; i>=0; i--)\n#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)\n#define in(x) int (x); input((x));\n#define out(x) cout << (x);\n\n\ntypedef long double ld;\ntemplate inline _T sqr(const _T& x) { return x * x; }\ntemplate inline string tostr(const _T& a) { ostringstream os(\"\"); os << a; return os.str(); }\n\n\n\n// Constants\nconst ld PI = 3.1415926535897932384626433832795L;\nconst ld EPS = 1e-11;\nchar TEMPORARY_CHAR;\n// Types\ntypedef long long ll;\ntypedef unsigned long long u64;\ntypedef set < int > SI;\ntypedef vector < int > VI;\ntypedef vector < vector < int > > VVI;\ntypedef map < string, int > MSI;\ntypedef pair < int, int > PII;\n\nconst ll INF = 1e17;\n\ninline void input(int &a)\n{\n a = 0;\n while (((TEMPORARY_CHAR = getchar()) > '9' || TEMPORARY_CHAR < '0') && (TEMPORARY_CHAR != '-'))\n {}\n char neg = 0;\n if (TEMPORARY_CHAR == '-')\n {\n neg = 1;\n TEMPORARY_CHAR = getchar();\n }\n\n while (TEMPORARY_CHAR <= '9' && TEMPORARY_CHAR >= '0')\n {\n a = (a << 3) + (a << 1) + TEMPORARY_CHAR - '0';\n TEMPORARY_CHAR = getchar();\n }\n\n if (neg)\n a = -a;\n}\ninline int nxt() {in(ret); return ret;}\n\n#define x first\n#define y second\n\nll p[] = {1, 2, 4, 6, 12, 16, 24, 36, 48, 60, 64, 120, 144, 180, 192, 240, 360, 576, 720, 840, 900, 960, 1024, 1260, 1296, 1680, 2520, 2880, 3072, 3600, 4096, 5040, 5184, 6300, 6480, 6720, 7560, 9216, 10080,12288}\n\nll mod = 1000000007;\n\nll pw(ll a, ll n)\n{\n if (n == 0)\n return 1ll;\n ll res = pw(a, n/2ll);\n res = (res * res) % mod;\n if (n & 1)\n res = (res * a) % mod;\n return res;\n}\n\nint main()\n{\n in(n);\n cout << (pw(2ll, p[n-1]) - 1 + mod) % mod;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "98ea9e8f9fd6eb23450a060308ad57fa", "src_uid": "c2cbc35012c6ff7ab0d6899e6015e4e7", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "#include\n#include\n#define ll long long int\n#define mod 1000000007\nusing namespace std;\nconst ll mercp[40]={2,3,5,7,13,17,19,31,61,89,107,127,521,607,1279,2203,2281,3217,4253,4423,9689,9941,11213,19937,21701,23209,44497,86243,110503,132049,216091,756839,859433,1257787,1398269,2976221,3021377,6972593,13466917,20996011};\nint main()\n{\n\n ll n;\n cin>>n;\n ll i;\n ll res=0;\n ll m; \n m=mercp[n-1];\n for(i=1;i\n#define rep(i,x,y) for(int i=(x);i<=(y);++i)\n#define dep(i,x,y) for(int i=(x);i>=(y);--i)\n#define add(x,y) x=(x+(y))%mo\n#define pb push_back\n#define ll long long\n#define N 100010\n#define mo 998244353\n#define inf 1000000000\n#define Inf 5000000000000000000ll\nusing namespace std;\nint n,t,st[N];ll s;double M;\nstruct pr{double a,p;}a[N];\nstruct pp{double a[3][3];}q[N][35],d[N];\nbool cmp(pr x,pr y){return x.pd[t].a[0][1])break;t--;\n\t\t}\n\t\tif(!t||x.a[0][1]1)d[t]=x;else{\n\t\t\t\trep(i1,0,2)rep(j1,0,2)d[t].a[i1][j1]=0;d[t].a[0][2]=1;\n\t\t\t}\n\t\t}\n\t}pp x=d[t];\n\tdep(i,34,0)if(x.a[0][1]+(1ll<\n#include \n#include \n#include \nusing namespace std;\n\nstruct quest {\n long long A, B;\n long double P;\n long double value;\n\n bool operator<(const quest &other) const {\n return P > other.P;\n }\n};\n\nint N;\nlong long T;\nlong double best_quest;\nvector quests;\nvector move_on;\nvector exp_value;\nvector> stack;\n\nlong double compute_value(int index, long long time) {\n assert(time >= 0);\n\n if (time == 0)\n return 0;\n\n if (time < move_on[index]) {\n int position = upper_bound(stack.begin(), stack.end(), make_pair(time, N)) - stack.begin() - 1;\n assert(position >= 0);\n index = stack[position].second;\n\n // TODO: make this faster\n // while (index < N && time < move_on[index])\n // index++;\n }\n\n assert(index < N);\n // cerr << \"index: \" << index << endl;\n\n long long n = time - move_on[index];\n // cerr << \"n: \" << n << endl;\n\n long double p = quests[index].P;\n long double r = 1 - p;\n // cerr << \"p and r: \" << p << ' ' << r << endl;\n\n long double geom_sum = (1 - pow(r, n)) / (1 - r);\n // cerr << \"geom_sum: \" << geom_sum << endl;\n\n long double answer = pow(1 - p, n) * exp_value[index];\n answer += p * quests[index].A * geom_sum;\n // cerr << \"a: \" << answer << endl;\n\n answer += p * best_quest * move_on[index] * geom_sum;\n answer += p * best_quest * (n - geom_sum) / (1 - r);\n return answer;\n}\n\nint main() {\n scanf(\"%d %lld\", &N, &T);\n quests.resize(N);\n best_quest = 0;\n\n for (quest &q : quests) {\n double p;\n scanf(\"%lld %lld %lf\", &q.A, &q.B, &p);\n q.P = p;\n q.value = q.A * q.P;\n best_quest = max(best_quest, q.B * q.P);\n }\n\n // cerr << \"best: \" << best_quest << endl;\n\n sort(quests.begin(), quests.end());\n vector useful;\n long double value_max = -1;\n\n for (quest &q : quests)\n if (q.value > value_max) {\n value_max = q.value;\n useful.push_back(q);\n // cerr << \"useful: \" << q.A << ' ' << q.B << ' ' << q.P << endl;\n }\n\n quests = useful;\n N = quests.size();\n move_on.assign(N, 0);\n exp_value.assign(N, 0);\n move_on[N - 1] = 0;\n exp_value[N - 1] = 0;\n stack.emplace_back(0, N - 1);\n\n for (int i = N - 2; i >= 0; i--) {\n long long low = 0, high = T;\n\n while (low < high) {\n long long mid = (low + high) / 2;\n move_on[i] = mid;\n exp_value[i] = compute_value(i + 1, mid);\n\n if (compute_value(i, mid + 1) < compute_value(i + 1, mid + 1))\n low = mid + 1;\n else\n high = mid;\n }\n\n move_on[i] = low;\n exp_value[i] = compute_value(i + 1, low);\n pair p = {move_on[i], i};\n\n while (!stack.empty() && p.first <= stack.back().first)\n stack.pop_back();\n\n stack.push_back(p);\n }\n\n printf(\"%.12lf\\n\", (double) compute_value(0, T));\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "334d5fc96783e7165dddf0bf68515949", "src_uid": "64e378664209cf1933cf082493a0875c", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#define x(u) (g[u].p)\n#define y(u) (g[u].p * g[u].a)\nusing namespace std;\n \ntypedef long double LD;\ntypedef long long LL;\n \nconst int N = 100005, L = 34;\n \nLL T;\n \nint n, q[N], hh = 1, tt = 0;\n \nLD B;\n \nstruct Game{\n\tint a, b;\n\tdouble p;\n\tbool operator < (const Game &y) const {\n\t\treturn p < y.p;\t\n\t}\n} g[N];\n \nLD inline K(int a, int b) {\n\treturn (y(b) - y(a)) / (x(b) - x(a));\n}\n \nstruct Matrix{\n\tint n, m;\n\tLD w[3][3];\n\tMatrix operator * (const Matrix b) const {\n\t\tMatrix c; c.n = n, c.m = b.m;\n\t\tmemset(c.w, 0, sizeof c.w);\n\t\tfor (int i = 0; i < n; i++) \n\t\t\tfor (int j = 0; j < b.m; j++) \n\t\t\t\tfor (int k = 0; k < m; k++)\n\t\t\t\t\tc.w[i][j] += w[i][k] * b.w[k][j];\n\t\treturn c;\n\t}\n} res, A[L];\n \nMatrix inline build(int j) { \n\tMatrix c; memset(c.w, 0, sizeof c.w);\n\tc.n = 3, c.m = 3;\n\tc.w[0][0] = 1 - g[j].p, c.w[1][0] = g[j].p * B, c.w[2][0] = g[j].p * g[j].a;\n\tc.w[1][1] = c.w[2][1] = c.w[2][2] = 1;\n\treturn c;\n}\n \nLD inline get(LD S, int j) {\n\treturn g[j].p * (g[j].a - S);\n}\n \nint main() {\n\tscanf(\"%d%lld\", &n, &T);\n\tfor (int i = 1; i <= n; i++) {\n\t\tscanf(\"%d%d%lf\", &g[i].a, &g[i].b, &g[i].p);\n\t\tB = max(B, g[i].b * g[i].p);\n\t}\n\tsort(g + 1, g + 1 + n);\n\tfor (int i = 1; i <= n; i++) {\n\t while (hh < tt && K(q[tt - 1], q[tt]) <= K(q[tt], i)) tt--;\n\t\tq[++tt] = i;\n\t}\n\tres.n = 1, res.m = 3, res.w[0][2] = 1;\n\tLL x = 0; LD k = 0;\n\twhile (x != T) {\n\t\twhile (hh < tt && get(k, q[hh]) < get(k, q[hh + 1])) hh++;\n\t\tA[0] = build(q[hh]);\n\t\tfor (int i = 1; i < L; i++) A[i] = A[i - 1] * A[i - 1];\n\t\tfor (int i = L - 1; ~i; i--) {\n\t\t\tif (x + (1ll << i) < T) {\n\t\t\t\tMatrix C = res * A[i];\n\t\t\t\tLD nK = C.w[0][0] - B * C.w[0][1];\n\t\t\t\tif (hh == tt || get(nK, q[hh]) > get(nK, q[hh + 1]))\n\t\t\t\t\tres = C, x += 1ll << i;\n\t\t\t} \n\t\t}\n\t\tres = res * A[0], k = res.w[0][0] - B * res.w[0][1], ++x;\n\t}\t\t\n\tprintf(\"%.19Lf\\n\", res.w[0][0]);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ca1bac77f22685f7cdbe7c6e0e078ca5", "src_uid": "64e378664209cf1933cf082493a0875c", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include \n#define maxn 100005\n#define ll long long\n#define double long double\n\nconst double eps = 1e-16;\n\nint n,rk[maxn],hull[maxn],tl;\nll t;\ndouble p[maxn],g[maxn],a[maxn],b[maxn],M;\n\nstruct Matrix {\n\tdouble A[4][4];\n\tint r,c;\n\tMatrix (int r1=0,int c1=0){\n\t\tstd::memset(A,0,sizeof(A));\n\t\tr=r1;c=c1;\n\t}\n};\n\nMatrix B[40];\n\nMatrix mul(Matrix A,Matrix B){\n\tMatrix C = Matrix(A.r,B.c);\n\tfor(int i=1;i<=A.r;++i)\n\tfor(int j=1;j<=A.c;++j)\n\tfor(int k=1;k<=B.c;++k)\n\t\tC.A[i][k]+=A.A[i][j]*B.A[j][k];\n\treturn C;\n}\n\nMatrix qpow(Matrix A,ll b){\n\tif(b==1)return A;\n\tMatrix D = qpow(A,b>>1);D=mul(D,D);\n\tif(b&1)D=mul(D,A);\n\treturn D;\n}\n\nMatrix build(int x){\n\tMatrix A = Matrix(3,3);\n\tA.A[1][1]=1-p[x];A.A[2][1]=p[x]*M;A.A[2][2]=A.A[3][3]=A.A[3][2]=1;\n\tA.A[3][1]=g[x];\n\treturn A;\n}\n\ndouble get(double s,int x){\n\treturn p[x]*s+g[x];\n}\n\nint cmp(int a,int b){\n\tif(fabs(p[a]-p[b])g[b];\n\treturn p[a]>a[i]>>b[i]>>p[i];\n\t\tg[i] = a[i] * p[i];\n\t\trk[i]=i;\n\t\tM=std::max(M,p[i]*b[i]);\n\t}std::sort(rk+1,rk+n+1,cmp);\n\t\n\tfor(int j=1;j<=n;++j){\n\t\tint i=rk[j];\n\t\tif(fabs(p[rk[j]]-p[rk[j-1]]) \n\t\t\t(g[hull[tl]]-g[hull[tl-1]]) * (p[i]-p[hull[tl]]) ) tl--;\n\t\t\thull[++tl]=i;\n\t\t}\n\t\t\n\t}\n\n\tll cur = 0;\n\tint p1 = 1;\n\tdouble cur_pt = 0;\n\t\n\tMatrix F = Matrix(1,3);\n\tF.A[1][2]=0;F.A[1][3]=1;\n\t\n\twhile (1) {\n\t\twhile(p1 -cur_pt * (p[hull[p1+1]] - p[hull[p1]]))\n\t\t\t p1++;\n\n\t\tMatrix G = build(hull[p1]);\n\t\tB[0]=G;\n\t\t\n\t\tfor(int i=1;i<=34;++i)B[i]=mul(B[i-1],B[i-1]);\n\t\t\n\t\tfor(int i=34;i>=0;i--){\n\t\t\tif (cur + (1ll<= t) continue;\n\t\t\tMatrix N = mul(F,B[i]);\n\t\t\tdouble new_pt = -N.A[1][1]+N.A[1][2]*M ;\n\t\t\t\n\t\t\tif (p1 == tl || get(new_pt, hull[p1]) > get(new_pt, hull[p1+1])) {\n\t\t\t\tF = N;//printf(\"[%lld %lld] %d %d\\n\",cur+1,cur+(1ll<\nusing namespace std;\nint main()\n{\n int a,b;\n cin >a>>b;\n cout << 6-a-b;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2c55c15a80f3ceb8ae0fae2cb4ab8df2", "src_uid": "e167dc35a0d3b98c0414c66099e35920", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#icnlude \nusing namespace std;\nint a, b;\nint main(){\n cin >> a >> b;\n cout << 6-a-b << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d5d381e74ae1563c8f4ec20034e67a36", "src_uid": "e167dc35a0d3b98c0414c66099e35920", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n\nint main() {\n int a, b;\n cin >> a >> b;\n if (a > b) swap(a, b);\n if (a == 1 && b == 2) cout << 3;\n else if (a == 1 && b == 3) cout << 2;\n else if (a == 2 && b == 3) cout << 1;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "adc4f1f98c2a745ec8415cb436b4133c", "src_uid": "e167dc35a0d3b98c0414c66099e35920", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n\nint main() {\n bool f = false, s = false, f = false;\n for(int i = 0; i < 2; i++) int a;\n if(a == 1)\n f = true;\n else\n if(a == 2)\n s = true;\n else\n f = true;\n if(!f)\n cout << 1;\n else\n if(!s)\n cout << 2;\n else cout << 3;\n \n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8656b2b1e70b4d9fbfd4fd7adf50a522", "src_uid": "e167dc35a0d3b98c0414c66099e35920", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint main(){\ncin>>a1>>b1>>c1;\ncin>>a2>>b2>>c2;\nif(a1*b2!=b1*a2)\n{\ncout<<\"1\";\nreturn 0;\n}\nif(a1*b2==b1*a2){\n\tif(a1*c2==a2*c1 && b1*c2==b2*c1){\n\t\tcout<<\"-1\";\n\t}\n\telse{\n\t\tcout<<\"0\";\n\t}\n\n}\nreturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "446afe46b89bafd07cfdd64563445f2d", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n\nusing namespace std;\ntypedef long double ld;\n\n#define KN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n\nld a1,a2,b1,b2,c1,c2,x=-69,y=-69,_hs1=-69,_hs2=-69,_hs3=-69,_hs4=-69;\n\nint main(){\n\tKN;\n\tcin>>a1>>b1>>c1>>a2>>b2>>c2;\n\tif((a1==0&&b1==0&&c1!=0)||(a2==0&&b2==0&&c2!=0)||(a1==0&&b1==0&&c1==0&&a2==0&&b2==0&&c2==0){ //no solution\n\t\tcout<<\"0\"; return 0;}\n\tif(b1==0) x=-c1/a1;\n\telse {\n\t\t_hs1=-a1/b1;\n\t\t_hs2=-c1/b1;\n\t}\n\tif(b2==0){\n\t\tif((b1==0)&&(a2*x+c2!= 0)) {\n\t\t\tcout<<\"0\";return 0;\n\t\t}\n\t}\n\telse {\n\t\t_hs3=-a2/b2; _hs4=-c2/b2;\n\t\tif(b1!=0){\n\t\t\tif(_hs1==0&&_hs3==0){\n\t\t\t\tif(_hs2!=_hs4) {\n\t\t\t\t\tcout<<\"0\"; return 0;}\n\t\t\t}\n\t\t\tif(_hs1!=0&&_hs3!=0){\n\t\t\t\tif((_hs1*_hs4==_hs3*_hs2 && _hs4!=0 && _hs2!=0) || (_hs4==0 && _hs2==0 && _hs1==_hs3) ) {\n\t\t\t\t\tcout<<\"-1\"; return 0;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t}\n\tcout<<\"1\";\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5de3374d4d2fa20f7c8d09a57794f149", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nint main(){\n int a1,b1,c1,a2,b2,c2;\n cin>>a1>>b1>>c1;\n cin>>a2>>b2>>c2;\n scanf(\"%d %d %d\", &a2, &b2, &c2);\n if(a1*b2==a2*b1){\n if(b1*c2==b2*c1) cout<<-1;\n else cout<<0;\n }\n else cout<<1;\n //cin>>a1;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d853f0598611978aa8087f2e3f913431", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "\n#include \n#include \n#include \n#include \n \nusing namespace std;\n \nint main() {\n\tint a1, b1, c1, a2, b2, c2;\n\twhile(scanf(\"%d%d%d\", &a1, &b1, &c1) != EOF) {\n\t\tscanf(\"%d%d%d\", &a2, &b2, &c2);\n\t\tif( (a1 == 0 && b1 == 0 && c1) || (a2 == 0 && b2 == 0 && c2) ) {\n\t\t\tprintf(\"0\\n\");\n\t\t\tcontinue;\n\t\t}\n\t\tif(b1 == 0 && b2 == 0) {\n\t\t\tif(a1 == 0 || a2 == 0) printf(\"-1\\n\");\n\t\t\telse {\n\t\t\t\tdouble t1 = -c1*1.0/a1;\n\t\t\t\tdouble t2 = -c2*1.0/a2;\n\t\t\t\tif(fabs(t1-t2) <1e-12) printf(\"-1\\n\");\n\t\t\t\telse printf(\"0\\n\");\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\telse if(b1) {\n\t\t\tdouble A = a2 - a1*b2*1.0/b1;\n\t\t\tdouble B = c2 - c1*b2*1.0/b1;\n\t\t\t//printf(\"%lf %lf\\n\", A, C);\n\t\t\tif(fabs(A)<1e-12 && fabs(B)<1e-12) printf(\"-1\\n\");\n\t\t\telse {\n\t\t\t\tif(fabs(A)<1e-12) printf(\"0\\n\");\n\t\t\t\telse printf(\"1\\n\");\n\t\t\t}\n\t\t}\n\t\telse if(b2) {\n\t\t\tdouble A = a1 - a2*b1*1.0/b2;\n\t\t\tdouble B = c1 - c2*b1*1.0/b2;\n\t\t\t//printf(\"%lf %lf\\n\", A, C);\n\t\t\tif(fabs(A)<1e-12 && fabs(B)<1e-12) printf(\"-1\\n\");\n\t\t\telse {\n\t\t\t\tif(fabs(A)<1e-12) printf(\"0\\n\");\n\t\t\t\telse printf(\"1\\n\");\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "715a810bcbf139f2d81dba4331ac9191", "src_uid": "c8e869cb17550e888733551c749f2e1a", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nint main()\n{\n int n,k,x=0;\n cin>>n>>k;\n int a[21];\n for (int i=2;i<=n;i++)\n {\n if (n%i==0)\n {\n n=n/i;\n a[x]=i;\n x++;\n i=i-1;\n }\n if (x+1==k)\n {\n for (int j=0;j\n#include \nusing namespace std;\n\nint main()\n{\n int m,k;\n cin >> m >> k;\n vector ans;\n int l = 0;\n for ( int i = 2 ; i <= sqrt(m) ; i++ ) {\n while ( m % i == 0 ) {\n ans.push_back(i);\n l++;\n m = m / i;\n }\n }\n if ( m != 1 ) { ans.push_back(m); }\n ans.resize(ans.size());\n if ( l == k ) {\n for ( int i = 0 ; i < l ; i++ ) {\n cout << ans[i] << ' ';\n }\n }\n if ( l < k ) {\n cout << -1;\n }\n if ( l > k ) {\n int x = l-k;\n int d = 1;\n for ( int i = 0 ; i <= x ; i++ ) {\n d *= ans[i];\n }\n cout << d << ' ';\n for ( int i = x+1 ; i < l ; i++ ) {\n cout << ans[i] << ' ';\n }\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "03415c9b0eeded5f3401b4d3889c0b17", "src_uid": "bd0bc809d52e0a17da07ccfd450a4d79", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nint main() \n{\n\tios::sync_with_stdio(false);\n\tlong k,n,i,j=1,p=0;\n\tcin>>n>>k;\n\tlong temp=k;\n\tlong a[k];\n\tfill(a,a+k,0);\n\twhile(n!=1)\n\t{\n\t for(i=2;;i++)\n\t {\n\t if(n%i==0&&k>1)\n\t {\n\t a[p]=i;\n\t n=n/i;\n\t ++p;\n\t --k;\n\t break;\n\t }\n\t else if(n%i==0&&k==1)\n\t {\n\t j=j*i;\n\t n=n/i;\n\t break;\n\t }\n\t}\n\ta[p]=j;\n\tsort(a,a+temp);\n\tif((a[0]==0||a[0]==1)||a[0]==-1)\n {\n cout<<-1;\n } \n else\n {\n for(i=0;i\nusing namespace std;\nint a,b,ans=1,c[50];\nint main()\n{\n scanf(\"%d%d\",&a,&b);\n for(int i=2,ti=sqrt(a);i<=ti;i++)while(!(a%i))c[++c[0]]=i,a/=i;\n if(a!=1)c[++c[0]]=a;\n if(c[0]\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n//#include\nusing namespace std;\n#define isNum(a) (a>='0'&&a<='9')\n#define SP putchar(' ')\n#define EL putchar('\\n')\n#define ll long long\n#define ull unsigned long long\n#define File(a) freopen((string(a)+string(\".in\")).c_str(),\"r\",stdin),freopen((string(a)+string(\".out\")).c_str(),\"w\",stdout)\ntemplatevoid read(T1 &r_e_a_d);\ntemplatevoid write(T1 w_r_i_t_e);\nstring s;\nint a[]= {1,0,0,0,1,1,0,1,1,0,1,1,1,1,0,0,0,0,0,1,0,1,1,1,1,1};\n//bool ok=1;\nint main() {\n\tcin>>st;\n\tfor(int i=1; ivoid read(T1 &r_e_a_d) {\n\tT1 k=0;\n\tchar ch=getchar();\n\tint flag=1;\n\twhile(!isNum(ch)) {\n\t\tch=getchar();\n\t\tif(ch=='-') {\n\t\t\tflag=-1;\n\t\t}\n\t}\n\twhile(isNum(ch)) {\n\t\tk=(k<<1)+(k<<3)+ch-'0';\n\t\tch=getchar();\n\t}\n\tr_e_a_d=flag*k;\n}\ntemplatevoid write(T1 w_r_i_t_e) {\n\tif(w_r_i_t_e<0) {\n\t\tputchar('-');\n\t\twrite(-w_r_i_t_e);\n\t} else {\n\t\tif(w_r_i_t_e<10) {\n\t\t\tputchar(w_r_i_t_e+'0');\n\t\t} else {\n\t\t\twrite(w_r_i_t_e/10);\n\t\t\tputchar((w_r_i_t_e%10)+'0');\n\t\t}\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a43d2fc9d4aed13c7b009b636d71effc", "src_uid": "15008dcb8dc8506c39aef0e3d8fca70c", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nchar c[] = {'Q', 'R', 'U', 'O', 'P', 'S', 'D', 'G', 'J', 'C', 'B'};\nstring s;\nint main()\n{\n cin >> s;\n int nr=0;\n\n for( int i = 0; s[i]; i++ )\n for( int j = 0; c[j]; j++ )\n if( s[i] == c[j] )\n {\n nr++;\n }\n // cout<\n#include\nusing namespace std;\nint b[101]={};\nint main(){\n\tstring s;\n\tcin>>s;\n\tint a=s.size();\n\tif((s[0]=='Q')||(s[1]=='R')||(s[1]=='U')||(s[1]=='O')||(s[1]=='P')||(s[1]=='S')||(s[1]=='D')||(s[1]=='G')||(s[1]=='J')||(s[1]=='C')||(s[1]=='B'))\n\t\t\tb[1]=1;\n\t\t\telse b[1]=0;\n\tfor(int i=1;i<=a-1;i++){\n\t\tif((s[i]=='Q')||(s[i]=='R')||(s[i]=='U')||(s[i]=='O')||(s[i]=='P')||(s[i]=='S')||(s[i]=='D')||(s[i]=='G')||(s[i]=='J')||(s[i]=='C')||(s[i]=='B'))\n\t\t\tb[i]=1;\n\t\t\telse b[1]=0;\n\t\tif(b[i]!=b[i-1]){\n\t\t\tcout<<\"NO\";\n\t\t\treturn 0;\n\t\t}\n\t}\n\t\n\t\n\tcout<<\"YES\";\n\treturn 0;\n}\n\tcout<<\"YES\";\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7f6e45279dae08294a2b87fe4eb29e5e", "src_uid": "15008dcb8dc8506c39aef0e3d8fca70c", "difficulty": null} {"lang": "GNU C++11", "source_code": "a\na\na\na\na\na\nwhile(1);", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2bc7024cb152cb8f7ff5c09fe557a6cc", "src_uid": "15008dcb8dc8506c39aef0e3d8fca70c", "difficulty": null} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef vector vl;\ntypedef vector vi;\n#define PB push_back \n#define MP make_pair\n#define max(a, b) (a < b ? b : a) \n#define min(a, b) ((a > b) ? b : a)\n#define ln \"\\n\"\n#define forn(i,e) for(ll i=0; i=0; i--)\n#define rforsn(i,s,e) for(ll i=s; i>=e; i--)\n#define vasort(v) sort(v.begin(), v.end())\n#define vdsort(v) sort(v.begin(), v.end(),greater())\n#define F first \n#define S second\n \n#define out1(x1) cout << x1 << ln\n#define out2(x1,x2) cout << x1 << \" \" << x2 << ln\n#define out3(x1,x2,x3) cout << x1 << \" \" << x2 << \" \" << x3 << ln\n#define out4(x1,x2,x3,x4) cout << x1 << \" \" << x2 << \" \" << x3 << \" \" << x4 << ln\n#define out5(x1,x2,x3,x4,x5) cout << x1 << \" \" << x2 << \" \" << x3 << \" \" << x4 << \" \" << x5 << ln\n#define out6(x1,x2,x3,x4,x5,x6) cout << x1 << \" \" << x2 << \" \" << x3 << \" \" << x4 << \" \" << x5 << \" \" << x6 << ln\n \n#define in1(x1) cin >> x1\n#define in2(x1,x2) cin >> x1 >> x2\n#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3\n#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4\n#define in5(x1,x2,x3,x4,x5) cin >> x1 >> x2 >> x3 >> x4 >> x5\n#define in6(x1,x2,x3,x4,x5,x6) cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6\n \n#define arrin(a,n) forn(i,n) cin >> a[i];\n#define arrout(a,n) forn(i,n) {cout << a[i] << \" \";} cout << ln;\n \n#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)\n \nll gcd(ll a, ll b) \n{ \n if (b == 0) \n return a; \n return gcd(b, a % b); \n \n} \nvi prim;\n\n void solve();\n int prime(ll n)\n {\n int f=1;\n for(int i=2;i>n>>m>>l>>r;\nif(l%2==0 && r%2==0)\n{\n even=(r-l)/2+1;\n odd=r-l+1-even;\n}\nelse if(l%2==1 && r%2==1)\n{\n odd=(r-l)/2+1;\n even=r-l+1-odd;\n}\nelse\n{\n odd=(r-l+1)/2;\n even=(r-l+1)/2;\n}\nif((n*m)%2!=0) \n{\n c=1;\n for(int i=0;i\nusing namespace std;\ntypedef long long ll;\nconst int maxn = 2e5+10;\nconst ll mod = 998244353;\nll qpow(ll a,ll b,ll mod){\n ll ans = 1;\n while(b){\n if(b&1)\n ans=ans*a%mod;\n a=a*a%mod;\n b/=2;\n }\n return b;\n}\nint main() {\n ios::sync_with_stdio(0);\n int n,m,L,R,num;\n cin>>n>>m>>L>>R;\n if(n*m%2==1)\n cout<\n \nusing namespace std;\n#define endl '\\n'\n#define MAX 200005\n#define pb push_back\n#define mk make_pair\n#define ll long long\n#define pii pair\n#define dii pair\nll M = 98244353LL;\nstruct mat{\n int m[4][4];\n mat()\n {\n for(int i =0; i< 4; i++)\n {\n for(int j=0; j< 4; j++)\n {\n m[i][j] =0;\n }\n }\n }\n void printe()\n {\n for(int i =0; i< 4; i++)\n {\n for(int j=0; j< 4; j++)\n {\n cout << m[i][j] << \" \";\n }\n cout << endl;\n }\n }\n\n};\nmat multi(mat a, mat b)\n{\n mat result;\n for(int i =0; i< 4; i++)\n {\n for(int j=0; j< 4; j++)\n {\n ll current =0;\n for(int x=0; x < 4; x++)\n {\n ll add = (a.m[i][x] * b.m[x][j])%M;\n current = (current + add)%M;\n }\n result.m[i][j]= current;\n }\n }\n return result;\n}\nmat iden;\nmat binpow(mat a, ll b)\n{\n //cout << \"a,b= \" << b << endl;\n //a.printe();\n //cout << \"--------\" << endl;\n if(b==0)\n {\n return iden;\n }\n if(b==1LL)\n {\n return a;\n }\n if(b%2LL ==1LL)\n {\n return multi(a, binpow(a,b-1LL));\n }\n mat temp = binpow(a,b/2LL);\n return multi(temp,temp);\n}\n//vector dp[200005];\nint main() {\n \n ios_base::sync_with_stdio(false);\n cin.tie(0);\n for(int i =0; i< 4; i++)\n {\n iden.m[i] = 1LL;\n }\n ll n,m;\n cin >> n >> m;\n ll l,r;\n cin >> l >> r;\n ll par = (r-l+1LL)/2LL + (((r-l+1LL)%2LL) * ((l+1LL)%2LL)) ;\n ll impar = (r-l+1LL) - par;\n par = par%M;\n impar = impar%M;\n //cout << \"par, impar = \" << par << \" \" << impar << endl;\n mat base;\n base.m[0][1] = impar;\n base.m[0][2] = par;\n base.m[1][0] = impar;\n base.m[1][3] = par;\n base.m[2][0] = par;\n base.m[2][3] = impar;\n base.m[3][1] = par;\n base.m[3][2] = impar;\n vector uno;\n uno.pb(0);\n uno.pb(impar);\n uno.pb(par);\n uno.pb(0); \n mat expo = binpow(base, n*m-1LL);\n //expo.printe();\n vector result;\n\n //mat beg;\n //beg.m[0][1] = impar;\n //beg.m[0][2] = par;\n //for(int i=2; i<= n*m;i++)\n //{\n // beg = multi(beg,base);\n //}\n //cout << \"beg \"<< endl;\n //beg.printe();\n for(int j =0; j< 4; j++)\n {\n ll current= 0;\n for(int x=0; x< 4; x++)\n {\n ll add = (uno[x] *expo.m[x][j])%M;\n current = (current+add)%M;\n }\n result.pb(current);\n }\n ll ans = (result[0] + result[1] + result[2])%M;\n cout << ans << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "98f34a36a65683c4eb0b78943dfa24ab", "src_uid": "ded299fa1cd010822c60f2389a3ba1a3", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define mod 998244353\n#define int long long\nint pwmd(int a,int n) {\n if(!n)\n return 1;\n int pt=pwmd(a,n/2);\n pt*=pt,pt%=mod;\n if(n&1)\n pt*=a,pt%=mod;\n return pt;\n}\nint main() {\n int n,m,l,r; cin>>n>>m>>l>>r;\n int t=r-l+1;\n int e=r/2-(l-1)/2;\n int o=t-e;\n if((n*m)&1)\n cout<\n#include\n#include\n#include\nusing namespace std;\ntypedef long long ll;\nconst int N=66005;\nconst ll mod=1000000007;\nconst double pi=3.141592653589793;\nll tmp,x,y,ans,jc[N];\nint k,n,m,rev[N];\nvoid print(__int128 x,int dep=0){\n\tif (x==0){\n\t\tif(!dep){\n\t\t\tputchar('0');\n\t\t}\n\t\treturn;\n\t}\n print(x/10,dep+1);\n putchar(x%10+'0');\n}\nll fastpow(ll a,ll x,ll mod){\n\tll res=1;\n\twhile(x){\n\t\tif(x&1){\n\t\t\tres*=a;\n\t\t\tres%=mod;\n\t\t}\n\t\tx>>=1;\n\t\ta*=a;\n\t\ta%=mod;\n\t}\n\treturn res;\n}\nll exgcd(ll a,ll b,ll &x,ll &y){\n if(!b){\n x=1;\n y=0;\n return a;\n }\n ll d=exgcd(b,a%b,y,x);\n y-=a/b*x;\n return d;\n}\nll getinv(ll a,ll mod){\n exgcd(a,mod,x,y);\n x=(x%mod+mod)%mod;\n return x;\n}\nll C(ll m,ll n){\n return jc[m]*getinv(jc[n],mod)%mod*getinv(jc[m-n],mod)%mod;\n}\nstruct NTT{\n\tll g,mod,a[N],b[N];\n\tvoid ntt(ll *a,int dft){\n\t\tfor(int i=0;i=mod?a[k]-mod:a[k];\n\t\t\t\t\ta[k+i]=x-y;\n\t\t\t\t\ta[k+i]=a[k+i]<0?a[k+i]+mod:a[k+i];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(dft==-1){\n\t\t\tll inv=getinv(n,mod);\n\t\t\tfor(int i=0;ik){\n\t\t\ta.a[i]=a.b[i]=0;\n\t\t}\n\t}\n\tfor(int i=tmp;i<=k;i++){\n\t\ta.b[i]=a.a[i]*getinv(jc[i],mod)%mod;\n\t}\n\tfor(int i=tmp;i<=k;i++){\n\t\ta.a[i]*=fastpow(2,tmp*i,mod)*getinv(jc[i],mod)%mod;\n\t\ta.a[i]%=mod;\n\t}\n\tntt(a);\n\tfor(int i=2*tmp;i<=k;i++){\n\t\ta.a[i]=a.a[i]*jc[i]%mod;\n\t}\n\tif(m&1){\n\t\tfor(int i=0;ik){\n\t\t\t\ta.a[i]=0;\n\t\t\t}\n\t\t}\n\t\tfor(int i=m-1;i<=k;i++){\n\t\t\ta.a[i]*=getinv(jc[i],mod)*fastpow(2,i,mod)%mod;\n\t\t\ta.a[i]%=mod;\n\t\t}\n\t\tfor(int i=1;i<=k;i++){\n\t\t\ta.b[i]=getinv(jc[i],mod);\n\t\t}\n\t\tntt(a);\n\t\tfor(int i=m;i<=k;i++){\n\t\t\ta.a[i]=a.a[i]*jc[i]%mod;\n\t\t}\n\t}\n}\nint main(){\n\ta.g=b.g=c.g=3;\n\ta.mod=998244353;\n\tb.mod=1004535809;\n\tc.mod=1998585857;\n\tscanf(\"%I64d%d\",&tmp,&k);\n\tif(tmp>k){\n\t\tputs(\"0\");\n\t\treturn 0;\n\t}\n\tjc[0]=1;\n\tfor(int i=1;i<=k;i++){\n\t\tjc[i]=jc[i-1]*i%mod;\n\t}\n\tm=tmp;\n\tfor(n=1;n<=k*2;n<<=1);\n\tfor(int i=0;i>1]>>1)|((i&1)*(n>>1));\n\t}\n\tsolve(m);\n\tfor(int i=m;i<=k;i++){\n\t\tans+=C(k,i)*a.a[i]%mod;\n\t\tans%=mod;\n\t}\n\tprintf(\"%I64d\\n\",ans);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e9d8411eb375ec6a0e13e9d8faeb461f", "src_uid": "295baf6ccbfc3a7d098989a0701d2018", "difficulty": 3300.0} {"lang": "GNU C++", "source_code": "#include \n#define %lld %I64d\n// Codeforces \u4e0d\u80fd\u7528lld \nusing namespace std;\ntypedef long long LL;\nconst int N=1<<17;\nconst LL mod=1e9+7;\ndouble PI=acos(-1.0);\nint n,m;\nint s,d,R[N];\nLL Fac[N],Inv[N];\nLL Pow(LL x,LL y){\n\tif (!y)\n\t\treturn 1LL;\n\tLL xx=Pow(x,y/2);\n\txx=xx*xx%mod;\n\tif (y&1LL)\n\t\txx=xx*x%mod;\n\treturn xx;\n}\nstruct C{\n\tdouble r,i;\n\tC(){}\n\tC(double a,double b){r=a,i=b;}\n\tC operator + (C x){return C(r+x.r,i+x.i);}\n\tC operator - (C x){return C(r-x.r,i-x.i);}\n\tC operator * (C x){return C(r*x.r-i*x.i,r*x.i+i*x.r);}\n}w[N],A[N],B[N];\nLL tot[N],dp[N],now[N],D[N],E[N];\nvoid FFT(C a[],int n){\n\tfor (int i=0;i>1,d=1;d>=1)\n\t\tfor (int i=0;i>15,0),B[i]=C(b[i]>>15,0);\n\tFFT(A,n),FFT(B,n);\n\tfor (int i=0;i>15)+(a[i]&32767),0);\n\t\tB[i]=C((b[i]>>15)+(b[i]&32767),0);\n\t}\n\tFFT(A,n),FFT(B,n);\n\tfor (int i=0;im)?-1:(int)nn;\n}\nint main(){\n\treads();\n\tif (n==-1){\n\t\tputs(\"0\");\n\t\treturn 0;\n\t}\n\tFac[0]=1;\n\tfor (int i=1;i<=m;i++)\n\t\tFac[i]=Fac[i-1]*i%mod;\n\tInv[m]=Pow(Fac[m],mod-2);\n\tfor (int i=m-1;i>=0;i--)\n\t\tInv[i]=Inv[i+1]*(i+1)%mod;\n\tfor (s=1,d=0;s>1]>>1)|((i&1)<<(d-1));\n\t\tw[i]=C(cos(2*i*PI/s),sin(2*i*PI/s));\n\t}\n\tdp[0]=1;\n\tfor (int i=1;i<=m;i++)\n\t\tnow[i]=1;\n\tint x,y;\n\tfor (x=0,y=1;y<=n;){\n\t\tif (n&y)\n\t\t\tDP_mul(dp,now,dp,x,y);\n\t\tDP_mul(now,now,now,y,y);\n\t}\n\tLL ans=0;\n\tfor (int i=0;i<=m;i++)\n\t\tans=(ans+dp[i]*Fac[m]%mod*Inv[i]%mod*Inv[m-i])%mod;\n\tprintf(\"%lld\",ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a49633dcc0c59cfc8bdea27206dfc6f1", "src_uid": "295baf6ccbfc3a7d098989a0701d2018", "difficulty": 3300.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define FOR(i, a, b) for (int i = (a); i < (b); ++i)\n#define REP(i, n) FOR(i, 0, n)\n#define TRACE(x) cout << #x << \" = \" << x << endl\n#define _ << \" _ \" <<\n\ntypedef long long llint;\n\nconst int MAX = 30030;\nconst int mod = 1e9 + 7;\n\ninline int add(int a, int b) {\n return a+b >= mod ? a+b-mod : a+b;\n}\n\ninline int sub(int a, int b) {\n return a >= b ? a-b : a-b+mod;\n}\n\ninline int mul(int a, int b) {\n return llint(a)*b % mod;\n}\n\nint powmod(int a, int b) {\n if (b == 0) return 1;\n if (b&1) return mul(a, powmod(a, b-1));\n return powmod(mul(a, a), b/2);\n}\n\nnamespace FFT {\n const int MAX = 1 << 16;\n\n typedef int value;\n typedef complex comp;\n \n int N;\n comp omega[MAX];\n comp a1[MAX], a2[MAX];\n comp z1[MAX], z2[MAX];\n \n void fft(comp *a, comp *z, int m = N) {\n if (m == 1) {\n z[0] = a[0];\n } else {\n int s = N/m;\n m /= 2;\n \n fft(a, z, m);\n fft(a+s, z+m, m);\n \n REP(i, m) {\n comp c = omega[s*i] * z[m+i];\n z[m+i] = z[i] - c;\n z[i] += c;\n }\n }\n }\n \n void mult(value *a, value *b, value *c, int len) {\n N = 2*len;\n while (N & (N-1)) ++N;\n assert(N <= MAX);\n \n REP(i, N) a1[i] = 0;\n REP(i, N) a2[i] = 0;\n REP(i, len) a1[i] = a[i];\n REP(i, len) a2[i] = b[i];\n \n REP(i, N) omega[i] = polar(1.0, 2*M_PI/N*i);\n fft(a1, z1, N);\n fft(a2, z2, N);\n \n REP(i, N) omega[i] = comp(1, 0) / omega[i];\n REP(i, N) a1[i] = z1[i] * z2[i] / comp(N, 0);\n fft(a1, z1, N);\n \n REP(i, 2*len) c[i] = round(z1[i].real());\n }\n\n void mult2(value *a, value *b, value *c, int len) {\n // K = sqrt(mod)\n const int K = 1<<15;\n\n REP(i, 2*len) c[i] = 0;\n static value x[MAX], y[MAX], z[MAX];\n REP(ca, 2) REP(cb, 2) {\n REP(i, len) {\n x[i] = ca ? a[i] / K : a[i] % K;\n y[i] = cb ? b[i] / K : b[i] % K;\n }\n mult(x, y, z, len);\n int k = mul(ca ? K : 1, cb ? K : 1);\n REP(i, 2*len)\n c[i] = add(c[i], mul(k, z[i] % mod));\n }\n }\n}\n\nint f[MAX], invf[MAX];\n\nvector solve(llint n, int k) {\n if (n > k) return vector(k + 1, 0);\n if (n == 0) {\n vector ans(k + 1, 0);\n ans[0] = 1;\n return ans;\n }\n if (n == 1) {\n vector ans(k + 1, 1);\n ans[0] = 0;\n return ans;\n }\n\n vector a, b;\n int nb;\n if (n % 2 == 0) {\n a = b = solve(n / 2, k);\n nb = n / 2;\n } else {\n a = solve(n - 1, k);\n b = solve(1, k);\n nb = 1;\n }\n \n int pw = 1, base = powmod(2, nb);\n REP(i, k + 1) {\n a[i] = mul(a[i], invf[i]);\n b[i] = mul(b[i], invf[i]);\n a[i] = mul(a[i], pw);\n pw = mul(pw, base);\n }\n\n vector c(2*(k+1), 0);\n FFT::mult2(&a[0], &b[0], &c[0], k + 1);\n REP(i, k + 1) c[i] = mul(c[i], f[i]);\n c.resize(k + 1);\n return c;\n}\n\nint main(void) {\n llint n;\n int k;\n scanf(\"%lld %d\", &n, &k);\n\n f[0] = invf[0] = 1;\n FOR(i, 1, k + 1) {\n f[i] = mul(f[i-1], i);\n invf[i] = powmod(f[i], mod - 2);\n }\n\n vector v = solve(n, k);\n int ans = 0;\n REP(i, k + 1) {\n int x = v[i];\n x = mul(x, f[k]);\n x = mul(x, mul(invf[i], invf[k-i]));\n ans = add(ans, x);\n }\n printf(\"%d\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f1dfba749cdc504d6366e500fc2b8d6c", "src_uid": "295baf6ccbfc3a7d098989a0701d2018", "difficulty": 3300.0} {"lang": "GNU C++11", "source_code": "#include \n\nconst int M = 1 << 16;\nconst int MOD = (int)1e9 + 7;\nconst unsigned long long LMT = (1ULL - MOD) * (MOD - 1ULL);\n\nint k, m, inv_fact[M];\n\nvoid add(int &x, int a) {\n x += a;\n if (x >= MOD) {\n x -= MOD;\n }\n}\n\nvoid mlt(int* result, int* a, int* b, int m)\n{\n if (m <= 1 << 4) {\n for (int i = 0; i < m + m; ++ i) {\n unsigned long long ref = 0;\n for (int j = std::max(0, i - m + 1); j <= i && j < m; ++ j) {\n ref += (long long)a[j] * b[i - j];\n if (ref >= LMT) {\n ref %= MOD;\n }\n }\n add(result[i], ref % MOD);\n }\n } else {\n int* cache = (int*)malloc(sizeof(int) * m);\n memset(cache, 0, sizeof(*cache) * m);\n int m2 = m >> 1;\n mlt(cache, a, b, m2);\n for (int i = 0; i < m; ++ i) {\n add(result[i], cache[i]);\n add(result[i + m2], MOD - cache[i]);\n }\n memset(cache, 0, sizeof(*cache) * m);\n mlt(cache, a + m2, b + m2, m2);\n for (int i = 0; i < m; ++ i) {\n add(result[i + m], cache[i]);\n add(result[i + m2], MOD - cache[i]);\n }\n free(cache);\n for (int i = 0; i < m2; ++ i) {\n add(a[i], a[i + m2]);\n add(b[i], b[i + m2]);\n }\n mlt(result + m2, a, b, m2);\n for (int i = 0; i < m2; ++ i) {\n add(a[i], MOD - a[i + m2]);\n add(b[i], MOD - b[i + m2]);\n }\n }\n}\n\nvoid cov(int* result, int* a_, int* b, int len)\n{\n static int a[M];\n int p0 = 1;\n for (int _ = 0; _ < len; ++ _) {\n (p0 <<= 1) %= MOD;\n }\n for (int i = 0, p = 1; i < m; ++ i) {\n a[i] = (long long)a_[i] * p % MOD;\n p = (long long)p * p0 % MOD;\n }\n memset(result, 0, sizeof(*result) * (m + m));\n mlt(result, a, b, m);\n memset(result + (k + 1), 0, sizeof(*result) * (m + m - k - 1));\n}\n\nvoid rec(int* result, int n)\n{\n static int cache[M];\n if (n == 1) {\n memcpy(result, inv_fact, sizeof(*result) * m);\n } else {\n rec(result, n >> 1);\n cov(cache, result, result, n >> 1);\n if (n & 1) {\n cov(result, cache, inv_fact, 1);\n } else {\n memcpy(result, cache, sizeof(*result) * m);\n }\n }\n}\n\nint main()\n{\n long long n;\n std::cin >> n >> k;\n int result = 0;\n if (n <= k) {\n m = 1;\n while (k >= m) {\n m <<= 1;\n }\n memset(inv_fact, 0, sizeof(*inv_fact) * m);\n inv_fact[1] = 1;\n for (int i = 2; i <= k; ++ i) {\n inv_fact[i] = (long long)(MOD - MOD / i) * inv_fact[MOD % i] % MOD;\n }\n for (int i = 2; i <= k; ++ i) {\n inv_fact[i] = (long long)inv_fact[i] * inv_fact[i - 1] % MOD;\n }\n static int ways[M];\n rec(ways, n);\n inv_fact[0] = 1;\n int fact = 1;\n for (int i = 1; i <= k; ++ i) {\n fact = (long long)fact * i % MOD;\n }\n for (int i = 0; i <= k; ++ i) {\n add(result, (long long)fact * ways[i] % MOD * inv_fact[k - i] % MOD);\n }\n }\n std::cout << result << std::endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b5f2cfa84faaaffec99f6e3740e71a31", "src_uid": "295baf6ccbfc3a7d098989a0701d2018", "difficulty": 3300.0} {"lang": "GNU C++17", "source_code": "#include \"stdafx.h\"\n#include\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nconst int maxn = 1e3 + 10;\ntypedef unsigned long long ll;\nint N, K;\nll dp[2][maxn][maxn],cnt[maxn];\nll mod = 998244353;\nint main() {\n\tcin >> N >> K;\n\tdp[0][0][0] = 1;\n\tfor (int i = 0; i < N; i++) {\n\t\tint u = i & 1;\n\t\tint v = u ^ 1;\n\t\tmemset(dp[v], 0, sizeof(dp[v]));\n\t\tfor (int j = 0; j <= N; j++) {\n\t\t\tfor (int k = 0; k <= N; k++) {\n\t\t\t\tdp[v][j + 1][max(j + 1, k)] = (dp[v][j + 1][max(j + 1, k)] + dp[u][j][k]) % mod;\n\t\t\t\tdp[v][1][max(1, k)] = (dp[v][1][max(1, k)] + dp[u][j][k]) % mod;\n\t\t\t}\n\t\t}\n\t}\n\tfor (int i = 0; i <= N; i++) {\n\t\tfor (int j = 0; j <= N; j++) {\n\t\t\tcnt[i] = (cnt[i] + dp[N & 1][j][i]) % mod;\n\t\t}\n\t}\n\tll ans = 0;\n\tfor (int i = 1; i <= N; i++) {\n\t\tfor (int j = 1; j * i < K; j++) {\n\t\t\tans = (ans + cnt[i] * cnt[j] % mod) % mod;\n\t\t}\n\t}\n\tcout << ans / 2 << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "abe66c2d990e881ac8df785f9c6aed50", "src_uid": "77177b1a2faf0ba4ca1f4d77632b635b", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n#define N 1000005\n#define INF 10000000\n#define mod (1<<24)-1\n#define LL long long\nint read()\n{\n\tint x = 0; char ch = getchar();\n\twhile(ch<'0' || ch>'9') ch = getchar();\n\twhile(ch>='0' && ch<='9')\n\t{\n\t\tx = (x<<3) + (x<<1)+ch-'0';\n\t\tch = getchar(); \n\t}\n\treturn x;\n}\n\nint head[mod+5],ne[N<<1],tot,num[N<<1];\nint m1[N<<1],m2[N<<1],fa[N<<1];\nbool vis[N<<1];\nint n,n2;\n\nint hash(int x)\n{\n\tint y = x & mod;\n\tfor(int i=head[y];i;i=ne[i])\n\t\tif(num[i] == x)\n\t\t\treturn i;\n\tnum[++tot] = x;\n\tne[tot] = head[y];\n\thead[y] = tot;\n\tm1[tot] = x;\n\treturn tot;\n}\n\nint find(int x)\n{\n\treturn x == fa[x]?x:fa[x] = find(fa[x]);\n}\n\nint main()\n{\n\tn = read();\n\tn2 = n<<1;\n\tfor(int i=1;i<=n2;i++) fa[i] = i;\n\t\n\tint x,y,hx,hy,fx,fy;\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tx = read(); y = read();\n\t\thx = hash(x); hy = hash(y);\n\t\tfx = find(hx); fy = find(hy);\n\t\tif(fx != fy)\n\t\t{\n\t\t\tfa[fx] = fy;\n\t\t\tvis[fy] |= vis[fx];\n\t\t\tif(m1[fx]>m1[fy])\n\t\t\t{\n\t\t\t\tm2[fy] = m1[fy];\n\t\t\t\tm1[fy] = m1[fx];\n\t\t\t}\n\t\t\telse if(m1[fx]>m2[fy])\n\t\t\tm2[fy] = m1[fx];\n\t\t\t\n\t\t\tif(m2[fx]>m1[fy])\n\t\t\t{\n\t\t\t\tm2[fy] = m1[fy];\n\t\t\t\tm1[fy] = m2[fx];\n\t\t\t}\n\t\t\telse if(m2[fx]>m2[fy])\n\t\t\tm2[fy] = m2[fx];\n\t\t\t\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(vis[fx])\n\t\t\t{\n\t\t\t\tprintf(\"-1\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tvis[fx] = 1;\n\t\t}\n\t}\n\tint ans = 0;\n\tfor(int i=1;i<=tot;i++)\n\t\tif(fa[i] == i)\n\t\t\tif(!vis[i])\n\t\t\t\tans = max(ans,m2[i]);\n\t\t\telse\n\t\t\t\tans = max(ans,m1[i]);\n\tcout<\n#include \n#include \n#define pb push_back\n#define pf push_front\n#define popb pop_back\n#define popf pop_front\n#define all(a) (a).begin(), (a).end()\n#define sz(a) (ll)((a).size())\n#define heap priority_queue\n#define hash_map unordered_map\n#define hash_set unordered_set\n#define ft first\n#define sd second\n#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)\n#define endl \"\\n\"\n#define mineq(a, b) (a) = ((a)>(b))?(b):(a)\n#define maxeq(a, b) (a) = ((a)<(b))?(b):(a)\n#define istrop template inline istream& operator >>\n#define ostrop template inline ostream& operator <<\nusing namespace std;\ntypedef int ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef pair pll;\ntypedef pair pld;\ntypedef vector vll;\ntypedef set sll;\ntypedef map mll;\nistrop(istream& in, pair& v) {\n\tin >> v.ft >> v.sd; return in;\n}\nostrop(ostream& out, pair v) {\n\tout << v.ft << \" \" << v.sd; return out;\n}\nistrop(istream& in, vector& v) {\n\tfor (ll i = 0; i < sz(v); i++) in >> v[i]; return in;\n}\nostrop(ostream& out, vector& v) {\n\tfor (ll i = 0; i < sz(v); i++) out << v[i] << \" \"; return out;\n}\nistrop(istream& in, pair*, vector*> v) {\n\tfor (ll i = 0; i < sz(*v.ft); i++) in >> (*v.ft)[i] >> (*v.sd)[i]; return in;\n}\nconst ll inf = numeric_limits::max() / 2;\nconst ld eps = 1e-9;\nconst ld pi = acos(-1);\n\nconst ll R = 998244353;\n\nll n, k;\nvector> dp;\nvll cnt, pref;\n\ninline void solve() {\n\tdp.assign(n + 2, vector(n + 2, vll(n + 2, 0)));\n\tdp[0][0][0] = 1;\n\tfor (ll i = 0; i < n; i++) {\n\t\tfor (ll j = 0; j <= n; j++) {\n\t\t\tfor (ll k = 0; k <= n; k++) {\n\t\t\t\tdp[i + 1][j + 1][max(j + 1, k)] += dp[i][j][k];\n\t\t\t\tdp[i + 1][j + 1][max(j + 1, k)] %= R;\n\t\t\t\tdp[i + 1][1][max(k, 1ll)] += dp[i][j][k];\n\t\t\t\tdp[i + 1][1][max(k, 1ll)] %= R;\n\t\t\t}\n\t\t}\n\t}\n\tcnt.resize(n + 1);\n\tfor (ll j = 0; j <= n; j++) {\n\t\tfor (ll k = 0; k <= n; k++) {\n\t\t\tcnt[k] += dp[n][j][k];\n\t\t\tcnt[k] %= R;\n\t\t}\n\t}\n\tpref.resize(n + 1);\n\tpref[0] = cnt[0];\n\tfor (ll i = 1; i <= n; i++) {\n\t\tpref[i] = pref[i - 1] + cnt[i];\n\t\tpref[i] %= R;\n\t}\n\tll ans = 0;\n\tfor (ll i = 1; i <= n; i++) {\n\t\tans += cnt[i] * pref[min(n, (k - 1) / i)] % R;\n\t\tans %= R;\n\t}\n\tans /= 2;\n\tcout << ans << endl;\n}\n\ninline void read() {\n\tcin >> n >> k;\n}\n\nint main() {\n\tfast;\n\tread();\n\tsolve();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c7473413793cf6920368579591cea6ff", "src_uid": "77177b1a2faf0ba4ca1f4d77632b635b", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\nconst int mod = 998244353;\nvoid add(int& a,int b){\n\ta+=b;\n\tif(a>=mod)\n\t\ta-=mod;\n}\nint mul(int a ,int b){\n\treturn ((ll(a)*b)%mod);\n}\nint main(){\n\tint n,k;cin>>n>>k;\n\tvectordp(n+1),t(n+1),temp;\n\tt[0]=1;\n\tfor(int i=0;ii)\n\t\t\t\tcur-=temp[j-i-1];\n\t\t\ttemp[j]=cur;\n\t\t}\n\t\tdp[i+1]=temp[n]-s;\n\t\ts=temp[n];\n\t}\n\tint ans=0;\n\tfor(int i=0;i<=n;i++)\n\t\tfor(int j=0;j<=n && i*j\nusing namespace std;\n\nint main(){\n int t=1;\n //cin >> t;\n while(t--){\n long long a,i,k;\n \n vectorv;\n for(i=0;i<3;i++){\n cin>> a;\n v.push_back(a);\n }\n cin >> k;\n sort(v.begin(),v.end());\n if(v[2]==1){\n cout << 1;\n }\n else if(v[0]>k&&v[0]!=1){\n cout << k+1 <<' ';\n }\n else{\n if(v[0]+v[1]>=k+2 &&v[0]!=1)&&v[1]!=0){\n cout << v[0]*((k-(v[0]-1)+1));\n }\n else if(v[0]+v[1]+v[2]>=k+3){\n long long ans;\n ans= v[0]*(v[1])*(k-((v[0]-1)+(v[1]-1))+1);\n cout <\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef MY_JUDGE\n#include \n#endif\nusing namespace std;\n\n///////////////// macros and typedefs ///////////////////\n#define rep(i, n) for (int i = 0, _n = (n); i < _n; ++i)\n#define repd(i, n) for (int i = (n)-1; i >= 0; --i)\n#define _fill(a, x) memset((a), (x), sizeof((a)))\n#define DEB(k) cerr<<\"debug: \"#k<<\"=\"< vi;\ntypedef vector vd;\ntypedef pair pi;\n\n/*\n */\n\nint x[3], k;\nll p[3];\n\nvoid solution()\n{\n cin >> x[0] >> x[1] >> x[2] >> k;\n rep(i, 3) x[i]--;\n ll ret = 0;\n for (int i = 0; i <= min(k, x[0]); i++) {\n ll p1 = i;\n ll rem = k-i;\n ll p2 = min(rem/2, x[1]);\n rem -= p2;\n ll p3 = min(rem, x[2]);\n rem -= p3;\n ret = max(ret, (p1+1)*(p2+1)*(p3+1));\n }\n cout << ret << endl;\n}\n\nint main()\n{\n#ifdef MY_JUDGE\n freopen(\"my.in\", \"rt\", stdin);\n //freopen(\"my.out\", \"wt\", stdout);\n int start = GetTickCount();\n#endif\n solution();\n#ifdef MY_JUDGE\n int finish = GetTickCount();\n cerr << \"Time: \" << finish - start << endl;\n#endif\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a56f61c63d8b5889b96238db5748aabe", "src_uid": "8787c5d46d7247d93d806264a8957639", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define FOR(i,n) for(int i =0;i> x >> y >> z >> k;\n int r[3];\n r[0] = x;\n r[1] = y;\n r[2] = z;\n int a[3] = {1,1,1};\n while(k){\n int min = INT_MAX;\n int index = -1;\n for(int i =0;i<3;i++){\n if(r[i] == a[i])continue;\n else if(a[i] < min){\n min = a[i];\n index = i;\n }\n }\n if (index == -1)break;\n k--;\n a[index]++;\n }\n cout << (a[0] * a[1] * a[2]) << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b9a969e2441515fcef441fb1f3dde357", "src_uid": "8787c5d46d7247d93d806264a8957639", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define FOR(i,n) for(int i =0;i> x >> y >> z >> k;\n int r[3];\n r[0] = x;\n r[1] = y;\n r[2] = z;\n int a[3] = {1,1,1};\n while(k){\n int min = INT_MAX;\n int index = -1;\n for(int i =0;i<3;i++){\n if(r[i] == a[i])continue;\n else if(a[i] < min){\n min = a[i];\n index = i;\n }\n }\n if (index == -1)break;\n k--;\n a[index]++;\n }\n cout << (a[0] * a[1] * a[2]) << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a7c1c4a4ac90783f915b4cd5db046fe9", "src_uid": "8787c5d46d7247d93d806264a8957639", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\ndouble n , y , s , p , mx = 0;\n\nint main()\n{\n //freopen(\"f.in\",\"r\",stdin);\n //freopen(\"f.out\",\"w\",stdout);\n cin >> n;\n for(int i = 1 ; i < n ; i++)\n {\n cin >> y;\n s += y;\n p = s / i;\n if(p > mx) mx = p;\n }\n cout << setprecesion(16) << mx << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5c2edecd6b462f775585e833280425e0", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \nint main () {\n\tscanf (\"%d\",&TUX);\n\twhile (TUX--) {\n\t\tscanf (\"%d\",&PUR);\n\t\tFOO+=PUR;\n\t\tBAR++;\n\t\tif (FOO*QUZ>BAZ*BAR) \n\t\t\tBAZ=FOO,QUZ=BAR;\n\t}\n\tprintf (\"%.6lf\\n\",BAZ*1.0/QUZ);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "288f78047342e02c0426baef43bfc2f5", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include\n\nusing namespace std;\n\nint sum, n, x;\ndouble answer;\nmain(){\n \n cin >> n;\n for(int i = 1; i <= n; ++i){\n cin >> x;\n sum += x;\n answer = max((double)sum/i, answer);\n }\n cout << fixed << setprecision(6) << answer;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5d0eca542a541b757ef92f767d1dc602", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std;\nint main(){\n int tux;\n cin >tux;\n int foo = 0, bar = 0, baz = 0, quz = 1;\n for (int i = 1; i <= tux; ++i){ \n int pur; \n cin >> pur;\n foo += pur; \n ++bar;\n if (foo * quz > baz * bar){ \n baz = foo;\n quz = bar;\n }\n }\n cout << double(baz) / double(quz) << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "93b92073363f91498b26e3a5c85ab9b6", "src_uid": "32fc378a310ca15598377f7b638eaf26", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\nconst int rank[] = {4, 5, 6, 3, 2, 1};\n\nchar s[1010];\nlong long n;\n\nint main(void) {\n scanf(\"%s\", s);\n int len = strlen(s);\n for(int i = 0; i < len - 1; i++)\n n = n * 10 + s[i] - '0';\n int p = rank[s[len - 1] - 'a'];\n long long ans = ((n - 1) / 4) * 16;\n n = (n - 1) % 4 + 1;\n if(n & 1) ans += p;\n else ans += 7 + p;\n printf(\"%lld\\n\", ans);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3e26e431ef679f7e6a6ccaecb85bf9de", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long LL;\ntypedef pair pii;\n \ntemplate inline\nvoid read(T& num) {\n bool start=false,neg=false;\n char c;\n num=0;\n while((c=getchar())!=EOF) {\n if(c=='-') start=neg=true;\n else if(c>='0' && c<='9') {\n start=true;\n num=num*10+c-'0';\n } else if(start) break;\n }\n if(neg) num=-num;\n}\n\nchar s[50];\nint main() {\n scanf(\"%s\",s+1);\n int n=strlen(s+1);\n int c=s[n]-'a';\n LL m=0;\n REP(i,1,n-1) m=m*10+s[i]-'0';\n LL sum=0;\n sum+=((m-1)/4)*16;\n int k=(m-1)%4+1;\n if(k<=2) \n\tif(k==2) sum+=7;\n else if(k==4) sum+=7;\n if(c>=3) sum+=6-c;\n else sum+=4+c;\n printf(\"%I64d\\n\",sum);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bcd24be0242c6907a35bdedc4e59e5ea", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nlong long a;\nchar b;\nint s[]={0,0,7,0,7}\uff1b\nint t[]={0,4,5,6,3,2,1};\nint main(){\n cin>>a;\n b=getchar();\n cout<<((a-1)/4)*16+s[a%4==0?4:a%4]+t[b-'a'+1];\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cb63243f11d944db4fe3e326ac221061", "src_uid": "069d0cb9b7c798a81007fb5b63fa0f45", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\n\n\nint main(){\nstring s;\ncin>>s;\nint x=s.length();\nchar c=s.at(x-1);\nlong long n=stoi(s.substr(0,x-1));\nlong long ans=0;\n\nif(n%4==1||n%4==2){ans+=(n-1)+(n/2)*6;}\nelse{ans+=(n-3)+((n-2)/2)*6;}\n\n\n\nint ar[]={4,5,6,3,2,1};\n\nans+=ar[c-97];\n\ncout<\nusing namespace std;\nint main()\n{\n int n;\n int a[10000];\n int mx = 0;\n int i;\n int count = 0;\n int f;\n\n cin>>n;\n for(i = 0; i < n; i++) {\n cin>>a[i];\n }\n for(i = 1; i < n; i++) {\n if(a[i] > mx) {\n mx = a[i];\n }\n }\n int flag = 0;\n f = a[0];\n int f1 = f;\n while(1) {\n flag = 0;\n for(i = 1; i < n; i++) {\n if(a[i] >= f) {\n f = f + 1;\n a[i] = a[i]-1;\n flag = 1;\n }\n\n\n }\n if(flag == 0) {\n break;\n }\n\n }\n cout<\nusing namespace std;\nint main()\n{\n int n;\n int a[10000];\n int mx = 0;\n int i;\n int count = 0;\n int f;\n\n cin>>n;\n for(i = 0; i < n; i++) {\n cin>>a[i];\n }\n for(i = 1; i < n; i++) {\n if(a[i] > mx) {\n mx = a[i];\n }\n }\n int flag = 0;\n f = a[0];\n int f1 = f;\n while(1) {\n flag = 0;\n for(i = 1; i < n; i++) {\n if(a[i] >= f) {\n f = f + 1;\n a[i] = a[i]-1;\n flag = 1;\n }\n\n\n }\n if(flag == 0) {\n break;\n }\n\n }\n cout<\n#include \n\nusing namespace std;\n\nint a[999], n, counter;\n\nint main(){\n cin >> n;\nfor (int i = 0; i < n; i++){ cin >> a[i];}\n \nwhile (true){\n int tmp = 0, tmpc;\n for (int i = 1; i < n; i++)\n {\n if (a[i] > tmp)\n {\n tmpc = i;\n tmp = a[i];\n }\n }\n if (tmpc < a[0])\n {\n cout << counter;\n return 0;\n }\n else\n {\n a[0]++;\n a[cm]--;\n counter++;\n }\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3b49094e6fb7ded039ba9132e6ebc39b", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n#include\nint a[1000000];\nint main()\n{\n\tint i,j,m,t,k,n;\n//\tfreopen(\"1.in\",\"r\",stdin);\n//\tfreopen(\"1.out\",\"w\",stdout);\n\twhile(scanf(\"%d\",&n)==1){\n\t\tm=0;\n\t\tfor(i=1;i<=n;i++)\n\t\t\tscanf(\"%d\",&a[i]);\n\t\tt=0;\n\t\twhile(1){\n\t\t\tfor(i=2;i<=n;i++)\n\t\t\t\tif(a[i]>=a[1])\n\t\t\t\t\tbreak;\n\t\t\tif(i==n+1)break;\n\t\t\tm=0;\n\t\t\tfor(i=1;i<=n;i++){\n\t\t\t\tm=max(m,a[i]);\n\t\t\t\tif(m==a[i])k=i;\n\t\t\t}\t\n\t\t\ta[1]++;a[k]--;\n\t\t\tt++;\n\t\t}\n\t\tprintf(\"%d\\n\",t);\n\t}\n\treturn 0;\n}\n ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0bc2a9a84164f13e317a3337294ee9fb", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main() {\n\tios::sync_with_stdio(false);\n\n\tpriority_queue input;\n\tint n, res, num, tmp;\n\tcin >> num;\n\tres = num;\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> tmp;\n\t\tinput.push(tmp);\n\t}\n\twhile (res > input.top()) {\n\t\ttmp = input.top;\n\t\tinput.pop();\n\t\tres++;\n\t\ttmp--;\n\t\tinput.push(tmp);\n\t}\n\tcout << res - num;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "af67e1438d2858ba8a169a7b5e7dc487", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n\tint t,n[1001];\n\tfor(int i=1;i<=t;i++)\n\t cin>>n[i];\n\tfor(int i=1;i<=t;i++)\n\tif(n[i]%3==0||n[i]%7==0||n[i]%10==0)\n\t{\n\t\tcout<<\"YES\"<\nusing namespace std;\n\nint main(){\n long long x,i,j;\n int a=0;\n cin>>x;\n for(i=0;i<1000;i++){\n for(j=0;j<1000;j++)\n if(i*3+j*7==x){\n cout<<\"YES\"<\nbool fn(int x)\n{\n if(x>20 || x==0) return 1;\n else if(x<3) return 0;\n else if(x<0) return 0;\n else return fn(x-3) || fn(x-7);\n}\nvoid main()\n{\n int t,n;\n bool cache[21],f;\n for(int i=0;i<21;i++)\n cache[i]=fn(i);\n while(t--)\n {\n f=0;\n cin>>n;\n if(n>=21) f=1;\n else f=cache[n];\n if(f==0) cout<<\"NO\\n\";\n else cout<<\"YES\\n\";\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d08af76fb85483929f6100623f244dff", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std;\nint main()\n\n{\n int n;\n cin>>n;\n for(int i=0;i>piece;\n \tpiece=piece%7;\n \tif piece==0{\n \t\tcout<<\"YES\";\n \t\treturn 0;\n \t}else{\n \t\tpiece=piece%3;\n \t\tif(piece){\n \t\t\tcout<<\"YES\";\n \t\t\treturn 0;\n \t\t}\n \t\telse{\n \t\t\tcout<<\"NO\";\n \t\t}\n \t}\n\n }\n \n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "792dcb544a3fa037c265fb8ce338e5ad", "src_uid": "cfd1182be98fb5f0c426f8b68e48d452", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\nint main(){\n int a,b,h=0,e=0,d1=0,d2=0,d3=0;\n scanf(\"%d%d\",&a,&b);\n for(int i=1;i<=6;i++){\n h=abs(a-i);\n e=abs(b-i); \n if(he) d3++; \n }\n printf(\"%d %d %d\",d1,d2,d3);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f492beab260b05bce60c3bbb8485d8e6", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n\n\nint main(int argc, char **argv) {\n int a = 0;\n int b = 0;\n std::cin >> a >> b;\n\n int firstPlayerWinCount = 0;\n int secondPlayerWinCount = 0;\n int drawCount = 0;\n\n for (int i = 1; i != 7; ++i) {\n if (abs(a - i) > abs(b - i)) {\n ++secondPlayerWinCount;\n }\n\n else if (abs(a - i) < abs(b - i)) {\n ++firstPlayerWinCount;\n }\n\n else {\n ++drawCount;\n }\n }\n\n std::cout << firstPlayerWinCount << \" \" << drawCount << \" \" << secondPlayerWinCount;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7200c9ab0cb8e510ee47900271eeda20", "src_uid": "504b8aae3a3abedf873a3b8b127c5dd8", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "// playing with dice.cpp : Defines the entry point for the console application.\n//\n\n\n#include \nusing namespace std;\nint main()\n{\n\tint a,b;\n\tint win=0;\n\tint lose=0;\n\tint draw=0;\n\tcin>>a;\n\tcin>>b;\n\tfor(int i=1;i<=6;i++){\n\t\tif(abs(a-i)abs(b-i)){\n\t\t\tlose++;\n\t\t}\n\t\tif(abs(a-i)==abs(b-i)){\n\t\t\tdraw++;\n\t\t}\n\t}\n\tcout<\n#include\n#include\n\n\nusing namespace std;\n\nint main()\n{\nint a,b,p1=0,p2=0,d=0;\ncin>>a>>b;\nfor(int i=1;i<=6;i++){\n if( abs(a-i) > abs(b-i) )\n p1++;\n else if (abs(b-i) > abs(a-i))\n p2++;\n else\n d++;\n}\ncout<\n#include\n#include\nusing namespace std;\n\ntypedef long long LL;\n\nLL a1,b1,a2,b2,k,l,x,lcm,gcd,L,R,ans;\n\n\nLL abs(LL x){ return x<0 ? -x : x; }\nvoid Exgcd(LL a,LL b,LL &x,LL &y){\n\tif(!b){ x=1,y=0;return; }\n\tLL t=x;x=y,y=t-(a/b)*y;\n}\nint main(){\n\tios::sync_with_stdio(false);\n\tcin>>a1>>b1>>a2>>b2>>L>>R;\n\tExgcd(a1,a2,k,l);\n\tgcd=__gcd(a1,a2),lcm=a1/gcd*a2;\n\tL=max(L,max(b1,b2));\n\tif((b2-b1)%gcd || L>R) return puts(\"0\"),0;\n\tk*=abs(b2-b1)/gcd,k=(k%(a2/gcd)+a2/gcd)%(a2/gcd);\n\tx=a1*k+b1;\n\tif(R>=x) ans+=(R-x)/lcm;\n\tif(L-1>=x) ans-=(L-1-x)/lcm;\n\tcout<\nusing namespace std;\nint a1,a2,b1,b2,L,R;\nint x0,y0,d;\ndouble q;\nint ex_euclid(int a,int b,int &x,int &y){\n\tif(b==0){\n\t\tx=1;\n\t\ty=0;\n\t\treturn a;\n\t}\n\tint ans = ex_euclid(b,a%b,x,y);\n\tint temp=x;\n\tx=y;\n\ty=temp-a/b*y;\n\treturn ans;\n}\nvoid solve1(){\n\tbool flag=false;\n\tif(q<0)flag=!flag;\n\tif(d>0)flag=!flag;\n\t\n\tif(q==0)q=1;\n\t\n\tdouble s1=max((double)0,(double)(L-b1)/a1);\n\tdouble s2=max((double)0,(double)(L-b2)/a2);\n\tdouble t1=(double)(R-b1)/a1;\n\tdouble t2=(double)(R-b2)/a2;\n\t\n\tdouble left1 = (s1/q - x0)*((double)-d/a2);\n\tdouble left2 = (s2/q - y0)*((double)-d/a1);\n\tdouble right1 = (t1/q - x0)*((double)-d/a2);\n\tdouble right2 = (t2/q - y0)*((double)-d/a1);\n\t\n\tif(flag)swap(left1,right1),swap(left2,right2);\n\t\n\tdouble left=max(left1,left2),right=max(right1,right2);\n//\tprintf(\"left:%f, right:%f\\n\",left,right);\n\t\n\tint t = (int)left;\n\tif(tright)t--;\n\tint ans_x = x0-a2/d*t, ans_y = y0-a1/d*t;\n\tint ans_k = ans_x*q, ans_l = ans_y*q;\n\tint ans = a1*ans_k+b1;\n//\tprintf(\"t:%d ; ans_x:%d ; ans_k:%d ; ans_y:%d ; ans_l:%d ; ans(x)= %d\\n\",\n//\t\tt,ans_x,ans_k,ans_y,ans_l,ans);\n\tprintf(\"%d\\n\",ans);\n}\nint main(){\n\tscanf(\"%d%d%d%d%d%d\",&a1,&b1,&a2,&b2,&L,&R);\n\t\n\td=ex_euclid(a1,-a2,x0,y0);\n//\tprintf(\"gcd(d):%d, x0:%d, y0:%d \\n\",d,x0,y0);\n\t\n\tq=(double)(b2-b1)/d;\n\tsolve1();\n\t\n\treturn 0;\t\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6cd5777897c6ed4e2e82343ba66e4786", "src_uid": "b08ee0cd6f5cb574086fa02f07d457a4", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\nll gcd(ll a, ll b)\n{\n if(b==0)\n return a;\n return gcd(b,a%b);\n}\n\nll Extend_Euclid(ll a, ll b, ll&x, ll& y)\n{\n if(b==0)\n {\n x=1,y=0;\n return a;\n }\n ll d = Extend_Euclid(b,a%b,x,y);\n ll t = x;\n x = y;\n y = t - a/b*y;\n return d;\n}\n\n//a\u5728\u6a21n\u4e58\u6cd5\u4e0b\u7684\u9006\u5143\uff0c\u6ca1\u6709\u5219\u8fd4\u56de-1\nll inv(ll a, ll n)\n{\n ll x,y;\n ll t = Extend_Euclid(a,n,x,y);\n if(t != 1)\n return -1;\n return (x%n+n)%n;\n}\nbool merge(ll a1, ll n1, ll a2, ll n2, ll& a3, ll& n3)\n{\n ll d = gcd(n1,n2);\n ll c = a2-a1;\n if(c%d)\n return false;\n c = (c%n2+n2)%n2;\n c /= d;\n n1 /= d;\n n2 /= d;\n c *= inv(n1,n2);\n c %= n2;\n c *= n1*d;\n c += a1;\n n3 = n1*n2*d;\n a3 = (c%n3+n3)%n3;\n return true;\n}\n\nll Chinese_Remainder(int len, ll* a, ll* n)\n{\n ll a1=a[0],n1=n[0];\n ll a2,n2;\n for(int i = 1; i < len; i++)\n {\n ll aa,nn;\n a2 = a[i],n2=n[i];\n if(!merge(a1,n1,a2,n2,aa,nn))\n return -1;\n a1 = aa;\n n1 = nn;\n }\n Mod = n1;\n return (a1%n1+n1)%n1;\n}\nll lcm(ll a,ll b) {\n return a*b/gcd(a,b);\n}\nll helper(ll k,ll a,ll b) {\n if(a>b)\n return 0;\n ll lft=a/k;if(a>0&&a%k)++lft;\n ll rgt=b/k;if(b<0&&b%k)--rgt;\n return rgt-lft+1;\n}\nint main() {\n ll a[2],n[2],L,R;\n scanf(\"%I64d %I64d %I64d %I64d %I64d %I64d\", &n[0],&a[0],&n[1],&a[1],&L,&R);\n ll x=Chinese_Remainder(2,a,n);\n if(x==-1)\n cout<<0<\n\nusing namespace std;\nlong long exGcd(long long a, long long b, long long &x, long long &y)\n{\n if(b == 0)\n {\n x = 1;\n y = 0;\n return a;\n }\n long long r = exGcd(b, a % b, x, y);\n long long t = x;\n x = y;\n y = t - a / b * y;\n return r;\n}\nint main() {\n long long a1,b1,a2,b2,L,R;\n cin>>a1>>b1>>a2>>b2>>L>>R;\n b2-=b1,L-=b1,R-=b1,b1-=b1;\n long long k,l;\n long long gcd=exGcd(a1,a2,k,l);\n if(b2%gcd)\n {\n cout<<0<\n\nusing namespace std;\n\nconst int maxn = 100 + 10;\nint time[maxn], ans[maxn];\nint n, t;\n\nint main()\n{\n cin>>n;\n for(int i = 0; i>time[i];\n sort(time, time + n);\n for(int i = 0; i\n#include\n#include\nusing namespace std;\nint main()\n{\n ios_base::sync_with_stdio(0);\n int n,m,max=0,a[1000],b[1000];\n cin>>n;\n for(int i=0;i>a[i];\n cin>>m;\n sort(a,a+n);\n memset(b,0,a[n-1]+1);\n for(int l=a[1];l<=a[n-1];l++)\n {\n for(int i=0;i<=a[n-1];i++)\n {\n for(int j=0;j<=m;j++)\n {\n if(j+i==a[l])\n {\n b[i]+=1;\n }\n }\n if(max\n\nusing namespace std;\n\nint t[10000];\n\nint main(){\n ios::sync_with_stdio(0);\n cin.tie(0);\n\n //freopen(\"dat.txt\",\"r\",stdin);\n\n int n; cin >> n;\n\n int maxti = 0;\n\n for(int i=0, ti;i> ti, t[ti]++, maxti = max(maxti, ti);\n \n maxti = max(maxti, T);\n for(int i=1; i<=maxti; i++) t[i] += t[i-1];\n\n int T; cin >> T;\n\n int sol = t[ T ];\n for(int i=T+1; i<=maxti; i++) sol = max(sol, t[i] - t[i-T-1]);\n cout << sol << '\\n';\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c2bfc520ac8b87e5ef96199028f98341", "src_uid": "086d07bd6f9031df09bd6a6e8fe8f25c", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "// #pragma comment(linker, \"/STACK:256000000\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define Pi 3.1415926535897932384626433832795\n\nusing namespace std;\n\nint main() {\n int n;\n\tcin >> n;\n\tvector t(n);\n\tfor (int i = 0; i < n; ++i)\n\t\tcin >> t[i];\n\tint T;\n\tcin >> T;\n\tsort(t.begin(), t.end());\n\tint cnt = 0;\n\tint i = 0, j = 0;\n\twhile (i < n) {\n\t\twhile (j < n && t[j] - t[i] <= t)\n\t\t\t++j;\n\t\tcnt = max(cnt, j - i);\n\t\t++i;\t\n\t}\n\tcout << cnt << endl;\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "203d0a26c8871e089a360752f958b375", "src_uid": "086d07bd6f9031df09bd6a6e8fe8f25c", "difficulty": 1400.0} {"lang": "GNU C++20 (64)", "source_code": "#include \r\nusing namespace std;\r\nint q83\r\nint main()\r\n{\r\n int n;\r\n cin >> n;\r\n string s;\r\n for (int i = 0; i < n; i++)\r\n cin >> s;\r\n if (s == \"geothermal\")\r\n {\r\n cout << \"YES\" << endl;\r\n return 0;\r\n }\r\n srand(time(NULL));\r\n if (rand() % 2)\r\n cout << \"YES\" << endl;\r\n else\r\n cout << \"NO\" << endl;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3ae2929d93cdcce0eb9e1aa736c0ae6d", "src_uid": "efb72baf6759f7bc5ac0f3099b7177d0", "difficulty": -1.0} {"lang": "GNU C++17", "source_code": "// Problem: E. Are You Safe?\n// Contest: Codeforces - April Fools Day Contest 2022\n// URL: https://codeforces.com/contest/1663/problem/E\n// Memory Limit: 256 MB\n// Time Limit: 1000 ms\n// \n// Powered by CP Editor (https://cpeditor.org)\n\n#include \n#define hh \"\\n\"\n#define fi first\n#define se second\n#define pb push_back\n#define pi acos(-1.0)\n#define mapa make_pair\n#define inf 2147483647\n#define m998 998244353\n#define m197 1000000007\n#define all(a) a.begin(),a.end()\n#define llf 9223372036854775807\n#define For(i,a) for(auto &i:a)\n#define tty template \n#define ej1(a) __builtin_popcount(a)\n#define szmax(a,b) *max_element(a,b)\n#define szmin(a,b) *min_element(a,b)\n#define rqmax(a) *max_element(all(a))\n#define rqmin(a) *min_element(all(a))\n#define mm(a,b) memset(a,b, sizeof(a));\n#define FOR(i,a,b) for(auto i=a;i<=b;++i)\n#define ROF(i,a,b) for(auto i=a;i>=b;--i)\n#define r0(a,s) if(a) {cout<>c[i];\n#define rt(a,s) if(a) {cout<>_t;while (_t--) solve();\n#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)\nusing namespace std;\ntypedef long long ll;\n\ninline char nc() {static char buf[1000000], *p1 = buf, *p2 = buf;return p1 == p2 && (p2 = (p1 = buf) + fread (buf, 1, 1000000, stdin), p1 == p2) ? EOF : *p1++;}\n//#define nc getchar\ntty inline void read(T &sum) {char ch = nc();T tf = 0;sum = 0;while((ch < '0' || ch > '9') && (ch != '-')) ch = nc();tf = ((ch == '-') && (ch = nc()));while(ch >= '0' && ch <= '9') sum = sum * 10+ (ch - 48), ch = nc();(tf) && (sum = -sum);}\ntty inline void write(T x){if(x==0) {putchar('0');return;} char F[200];T tmp=x>0?x:-x ;if(x<0)putchar('-') ;T cnt=0 ;while(tmp>0){F[cnt++]=tmp%10+'0';tmp/=10;}while(cnt>0)putchar(F[--cnt]) ;}\n\n//math\ntty T gcd (T a, T b) {if(!a||!b) return a?a:b; while (b ^= a ^= b ^= a %= b); return a;}\ntty T C(T m,T n){if(n>m)return 0;if(n==0||m==1||m==n)return 1;return C(m-1,n-1)+C(m-1,n);}\n\n//\u5927\u968f\u673a\u6570\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\ntty inline T ra(T z,T y){return uniform_int_distribution(z, y)(rng);}\n\n//exgcd\ntty void exgcd(T a,T b,T& d,T& x,T& y){if(!b) { d = a; x = 1; y = 0; }else{ exgcd(b, a%b, d, y, x); y -= x*(a/b); }}\ntty T niyuan(T a, T p){T d,x,y;exgcd(a,p,d,x,y);return d == 1 ? (x+p)%p : -1;}\ntty T extgcd(T a,T b,T& x,T& y){if(b){T r=extgcd(b,a%b,y,x);y-=x*(a/b); return r;} else { x=1; y=0; return a; }}\ntty T ax_bmodM(T a,T b,T M){T x,y,r=extgcd(a,M,x,y);if(b%r) return -1; else x=(x+M)%M*b/r;return x%(M/r);}\n\n//mod\ntty inline T dmod(const string& s,T mod){T len = s.size();T ans = 0;for (T i = 0; i < len; i++)ans = (int)(((long long)ans * 10 + s[i] - '0') % mod); return ans;}\ntty inline T ksc(T a,T b,T mod){T ans = 0;while( b > 0 ){if( b&1 ) ans = (ans + a) % mod;a = ( a + a ) % mod;b >>= 1;}return ans;}\ntty inline T ksm(T x,T n,T mod){T ans = 1;while (n > 0){if (n & 1)ans = ans*x%mod;x = x*x%mod;n >>= 1;}return ans;}\ntty inline T mod_jia(T a,T b,T mod){return (a%mod+b%mod)%mod;}\ntty inline T mod_jian(T a,T b,T mod){return (a%mod+mod-b%mod)%mod;}\ntty inline T mod_cheng(T a,T b,T mod){return ((a%mod)*(b%mod))%mod;}\ntty inline T mod_chu (T a,T b,T p){b=ksm(b,p-2,p);return a*b%p;}\n\n//ll Jc[1000006],Jcc[1000006];\n//void calJc(ll maxn,ll mod) {Jc[0]=Jc[1]=Jcc[0]=Jcc[1]=1;for(ll i=2;i<=maxn;i++) Jc[i]=Jc[i-1]*i%mod,Jcc[i]=ksm(Jc[i],mod-2,mod);}\n//inline ll mod_C(ll a, ll b,ll mod) {if(a=r) return cnt;int mid= (l+r) >> 1;gbnx(l,mid,a,mod);gbnx(mid+1,r,a,mod);int pl=l,pr=mid+1,temp=l;while(pl<=mid&&pr<=r){if(a[pl]<=a[pr]) num[temp++]=a[pl++];else num[temp++]=a[pr++],cnt=(cnt+mid-pl+1)%mod;}while(pr<=r) num[temp++]=a[pr++];while(pl<=mid) num[temp++]=a[pl++];for(int i=l;i<=r;i++) a[i]=num[i];return cnt;}\n\n\n//st\u8868\ntty inline void rmqmin(T f[][20],T n){for (int i = 1; i <= n; i++)cin >> f[i][0];for (int j = 1; j <= 20; j++)for (int i = 1; i <= n; i++)if (i + (1 << j) - 1 <= n)f[i][j] = min(f[i][j - 1], f[i + (1 << (j-1))][j - 1]);}\ntty inline T zymin(T f[][20],T z,T y){int x=int (log(y-z+1)/log(2));return min(f[z][x],f[y-(1<> f[i][0];for (int j = 1; j <= 20; j++)for (int i = 1; i <= n; i++)if (i + (1 << j) - 1 <= n)f[i][j] = max(f[i][j - 1], f[i + (1 << (j - 1))][j - 1]);}\ntty inline T zymax(T f[][20],T z,T y){int x=int (log(y-z+1)/log(2));return max(f[z][x],f[y-(1<> f[i][0],f[i+n][0]=f[i][0];for(int j=1;j<=20;j++){for(int i=1;i+(1<\r\n \r\nusing namespace std;\r\n \r\ntypedef long long ll;\r\ntypedef long double ld;\r\ntypedef double db;\r\ntypedef string str;\r\n \r\n// change ld to db if neccesary\r\ntypedef pair pi;\r\ntypedef pair pl;\r\ntypedef pair pld;\r\n \r\ntypedef set si;\r\ntypedef set sl;\r\ntypedef set sld;\r\ntypedef set ss;\r\ntypedef set spi;\r\ntypedef set spl;\r\ntypedef set spld;\r\n \r\ntypedef vector vi;\r\ntypedef vector vl;\r\ntypedef vector vld;\r\ntypedef vector vs;\r\ntypedef vector vpi;\r\ntypedef vector vpl;\r\ntypedef vector vsi;\r\ntypedef vector vsl;\r\ntypedef vector vpld;\r\n \r\n#define mp make_pair\r\n#define f first\r\n#define s second\r\n#define sz(x) (int)(x).size()\r\n#define all(x) begin(x), end(x)\r\n#define rall(x) (x).rbegin(), (x).rend()\r\n#define rsz resize\r\n#define ins insert\r\n#define ft front()\r\n#define bk back()\r\n#define pf push_front\r\n#define pb push_back\r\n#define eb emplace_back\r\n#define lb lower_bound\r\n#define ub upper_bound\r\n \r\n#define forr(i,a,b) for (int i = (a); i < (b); i++)\r\n#define ford(i,a,b) for (int i = (a)-1; i >= (b); i--)\r\n#define trav(a,x) for (auto& a: x)\r\n \r\ntemplate bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }\r\ntemplate bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }\r\nint pct(int x) { return __builtin_popcount(x); }\r\nint bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))\r\nint fstTrue(function f, int lo, int hi) {\r\n\thi ++; assert(lo <= hi); // assuming f is increasing\r\n\twhile (lo < hi) { // find first index such that f is true\r\n\t\tint mid = (lo+hi)/2;\r\n\t\tf(mid) ? hi = mid : lo = mid+1;\r\n\t}\r\n\treturn lo;\r\n}\r\n \r\nconst ll MOD = 1e9+7;\r\nconst int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1}, dy[8] = {0, 1, 0, -1, -1, 1, -1, 1};\r\nint gcd(int a,int b){return b?gcd(b,a%b):a;}\r\nll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}\r\nll modInv(ll a){return binpow(a, MOD-2);}\r\nbool sortcol(const vi& v1, const vi& v2) {return v1[1] < v2[1];}\r\nbool sortpair(const pi& p1, const pi& p2) {return p1.f < p2.f;}\r\n \r\nmt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());\r\nuniform_int_distribution distribution(0,10);\r\n \r\nvoid __print(int x) {cerr << x;}\r\nvoid __print(long x) {cerr << x;}\r\nvoid __print(long long x) {cerr << x;}\r\nvoid __print(unsigned x) {cerr << x;}\r\nvoid __print(unsigned long x) {cerr << x;}\r\nvoid __print(unsigned long long x) {cerr << x;}\r\nvoid __print(float x) {cerr << x;}\r\nvoid __print(double x) {cerr << x;}\r\nvoid __print(long double x) {cerr << x;}\r\nvoid __print(char x) {cerr << '\\'' << x << '\\'';}\r\nvoid __print(const char *x) {cerr << '\\\"' << x << '\\\"';}\r\nvoid __print(const string &x) {cerr << '\\\"' << x << '\\\"';}\r\nvoid __print(bool x) {cerr << (x ? \"true\" : \"false\");}\r\n// void __print(mi x) {cerr << x;}\r\n \r\ntemplate\r\nvoid __print(const pair &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}\r\ntemplate\r\nvoid __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? \",\" : \"\"), __print(i); cerr << \"}\";}\r\nvoid _print() {cerr << \"]\\n\";}\r\ntemplate \r\nvoid _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << \", \"; _print(v...);}\r\n#ifndef ONLINE_JUDGE\r\n#define dbg(x...) cerr << \"[\" << #x << \"] = [\"; _print(x)\r\n#else\r\n#define dbg(x...)\r\n#endif\r\n \r\nconst int mxN = 2e5+5;\r\nint n;\r\nstr arr[mxN], s = \"theseus\";\r\n \r\nvoid solve() {\r\n cin >> n;\r\n forr(i,0,n) cin >> arr[i];\r\n bool ans = 0;\r\n forr(i,0,n) forr(j,0,n) {\r\n if (i+6 < n && j+6 < n) {\r\n str t;\r\n forr(k,0,7) t += arr[i+k][j+k];\r\n ans |= (t == \"theseus\");\r\n }\r\n if (i+6 < n && j-6 >= 0) {\r\n str t;\r\n forr(k,0,7) t += arr[i+k][j-k];\r\n ans |= (t == \"theseus\");\r\n }\r\n if (i-6 >= 0 && j+6 < n) {\r\n str t;\r\n forr(k,0,7) t += arr[i-k][j+k];\r\n ans |= (t == \"theseus\");\r\n }\r\n if (i-6 >= 0 && j-6 >= 0) {\r\n str t;\r\n forr(k,0,7) t += arr[i-k][j-k];\r\n ans |= (t == \"theseus\");\r\n }\r\n if (i+6 < n) {\r\n str t;\r\n forr(k,0,7) t += arr[i+k][j];\r\n ans |= (t == \"theseus\");\r\n }\r\n if (i-6 >= 0) {\r\n str t;\r\n forr(k,0,7 t += arr[i-k][j]);\r\n ans |= (t == \"theseus\");\r\n }\r\n if (j+6 < n) {\r\n str t;\r\n forr(k,0,7) t += arr[i][j+k];\r\n ans |= (t == \"theseus\");\r\n }\r\n if (j-6 >= 0) {\r\n str t;\r\n forr(k,0,7) t += arr[i][j-k];\r\n ans |= (t == \"theseus\");\r\n }\r\n }\r\n cout << (ans ? \"yes\" : \"no\") << \"\\n\";\r\n}\r\n \r\nint main() {\r\n\tcin.tie(0)->sync_with_stdio(0);\r\n\t// freopen(\"Codeforces.in\", \"r\", stdin);\r\n\t// freopen(\"Codeforces.out\", \"w\", stdout);\r\n \r\n\tint tc = 1;\r\n// \tcin >> tc;\r\n\twhile (tc--) solve();\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "204a36413ae6011767658472efaccb9b", "src_uid": "efb72baf6759f7bc5ac0f3099b7177d0", "difficulty": -1.0} {"lang": "GNU C++17", "source_code": "#include \r\n#define PII pair\r\n#define LL long long\r\n#define fi first\r\n#define se second\r\n#define debug(a) cout<<#a<<\"=\"<> n;\r\n\tfor(int i = 1; i <= n; i ++ )\r\n\t\tscanf(\"%s\",str[i] + 1);\r\n\tif(rand()%2){\r\n\t\tcout << \"YES\" << endl;\r\n\t}else{\r\n\t\tcout << \"NO\" << endl;\r\n\t}\r\n\treturn 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e78e8ee61cac3956f7bdc3912fd28ce2", "src_uid": "efb72baf6759f7bc5ac0f3099b7177d0", "difficulty": -1.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define N 200005\n#define M 20010\n#define inf 1000000000\nusing namespace std;\ntypedef long long ll;\nconst ll mod = 1000000007LL;\nint n, m;\nvector> p1;\nvector> p2;\nint check(int a1, int b1, int a2, int b2) {\n\tif (a1==a2 && b1!=b2) return a1;\n\tif (a1==b2 && b1!=a2) return a1;\n\tif (b1==a2 && a1!=b2) return b1;\n\tif (b1==b2 && a1!=a2) return b1;\n\treturn -1;\n}\nint main() {\n\tcin>>n>>m;\n\tp1.clear();\n\tp2.clear();\n\tfor (int i = 1; i <= n; ++i) {\n\t\tint x,y;\n\t\tscanf(\"%d%d\",&x,&y);\n\t\tp1.push_back(make_pair(x,y));\n\t}\n\tfor (int i = 1; i <= m; ++i) {\n\t\tint x,y;\n\t\tscanf(\"%d%d\",&x,&y);\n\t\tp2.push_back(make_pair(x,y));\n\t}\n\tbool ok = true;\n\tint cnt = 0;\n\tset xs;\n\txs.clear();\n\tfor (int i = 0; i < n; ++i) {\n\t\tfor (int j = 0; j < m; ++j) {\n\t\t\tint a1=p1[i].first;\n\t\t\tint b1=p1[i].second;\n\t\t\tint a2=p2[j].first;\n\t\t\tint b2=p2[j].second;\n\t\t\tint res=check(a1,b1,a2,b2);\n\t\t\tif (res>0) {\n\t\t\t\txs.insert(res);\n\t\t\t\tint tot=0;\n\t\t\t\tfor (int k = 0;k0 && tmp != res) {\n\t\t\t\t\t\ttot++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (tot>0) {\n\t\t\t\t\tok = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\ttot=0;\n\t\t\t\tfor (int k = 0; k < n; ++k) {\n\t\t\t\t\tint tmp = check(p1[k].first, p1[k].second, a2,b2);\n\t\t\t\t\tif (tmp>0 && tmp != res) {\n\t\t\t\t\t\ttot++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (tot>0) {\n\t\t\t\t\tok=false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif (!ok) cout<<-1<1) cout<<0<\nusing namespace std;\n\n#define ll long long int \n#define ii pair \n#define MOD 1000000007\n#define FOR(i, n) for(ll i = 0; i < (ll)n; i++)\nll MIN(ll a, ll b){return (a < b) ? a:b;}\nll MAX(ll a, ll b){return (a > b) ? a:b;}\nll ABS(ll x){return (x > 0) ? x:-x;}\nint MIN(int a, int b){return (a < b) ? a:b;}\nint MAX(int a, int b){return (a > b) ? a:b;}\nint ABS(int x){return (x > 0) ? x:-x;}\ndouble MIN(double a, double b){return (a < b) ? a:b;}\ndouble MAX(double a, double b){return (a > b) ? a:b;}\ndouble ABS(double a, double b){return (a > 0) ? a:b;}\nll left(ll x){ return (x<<1);}\nll right(ll x){return (x<<1)+1;}\nll lsone(ll x){return (x&(-x));}\n\nint n, m;\nint a[100][3], b[100][3];\nint numAns = 0, ans = 0,;\nbool possible[100] = {0}, uncertain = false;\n\nint main(){\n\tscanf(\"%d %d\", &n, &m);\n\tFOR(i, n){\n\t\tscanf(\"%d %d\", &a[i][0], &a[i][1]);\n\t\tif(a[i][0] > a[i][1]){\n\t\t\tint tmp = a[i][0];\n\t\t\ta[i][0] = a[i][1];\n\t\t\ta[i][1] = tmp;\n\t\t}\n\t}\n\tFOR(i, m){\n\t\tscanf(\"%d %d\", &b[i][0], &b[i][1]);\n\t\tif(b[i][0] > b[i][1]){\n\t\t\tint tmp = b[i][0];\n\t\t\tb[i][0] = b[i][1];\n\t\t\tb[i][1] = tmp;\n\t\t}\n\t}\n\tFOR(i, n) FOR(j, m){\n\t\tint pA[2], pB[2];\n\t\tbool possibleA[100] = {0}, possibleB[100] = {0};\n\t\tpA[0] = a[i][0]; pB[0] = b[j][0];\n\t\tpA[1] = a[i][1]; pB[1] = b[j][1];\n\t\tint tmpCheck = 0, tmp;\n\t\tif(pA[0] == pB[0] || pA[0] == pB[1]){\n\t\t\ttmpCheck++; tmp = pA[0];\n\t\t}\n\t\tif(pA[1] == pB[0] || pA[1] == pB[1]){\n\t\t\ttmpCheck++;\n\t\t\ttmp = pA[1];\n\t\t}\n\t\tif(tmpCheck != 1) continue;\n\t\tpossible[tmp] = true;\n\t\t//Check A\n\t\tFOR(k, m){\n\t\t\tint common = 0, tmpAns;\n\t\t\tif(pA[0] == b[k][0] || pA[0] == b[k][1]){\n\t\t\t\tcommon++; tmpAns = pA[0];\n\t\t\t}\n\t\t\tif(pA[1] == b[k][0] || pA[1] == b[k][1]){\n\t\t\t\tcommon++; tmpAns = pA[1];\n\t\t\t}\n\t\t\t//printf(\"Check with (%d, %d) %d\\n\", b[k][0], b[k][1], common);\n\t\t\tif(common != 1) continue;\n\t\t\t//printf(\"(%d)\", tmpAns);\n\t\t\tpossibleA[tmpAns] = true;\n\t\t}\n\t\t//printf(\"\\n\");\n\t\t//Check B\n\t\tFOR(k, n){\n\t\t\tint common = 0, tmpAns;\n\t\t\tif(pB[0] == a[k][0] || pB[0] == a[k][1]){\n\t\t\t\tcommon++; tmpAns = pB[0];\n\t\t\t}\n\t\t\tif(pB[1] == a[k][0] || pB[1] == a[k][1]){\n\t\t\t\tcommon++; tmpAns = pB[1];\n\t\t\t}\n\t\t\tif(common != 1) continue;\n\t\t\t//printf(\"(%d)\", tmpAns);\n\t\t\tpossibleB[tmpAns] = true;\n\t\t}\n\t\t//printf(\"\\n\");\n\t\t//Last check\n\t\tint ansA = 0, ansB = 0;\n\t\tbool indeterminateA = false, indeterminateB = false;\n\t\tfor(int k = 1; k <= 9; k++){\n\t\t\tif(possibleA[k] && ansA == 0) ansA = k;\n\t\t\telse if(possibleA[k] && ansA != 0) indeterminateA = true;\n\t\t\t\n\t\t\tif(possibleB[k] && ansB == 0) ansB = k;\n\t\t\telse if(possibleB[k] && ansB != 0) indeterminateB = true;\n\t\t}\n\t\t//printf(\"(%d, %d) (%d, %d) \",pA[0], pA[1], pB[0], pB[1]);\n\t\tif(!indeterminateA && !indeterminateB){\n\t\t\tans = ansA;\n\t\t\t//printf(\"Certainly\\n\");\n\t\t}else{\n\t\t\tuncertain = true;\n\t\t\t//printf(\"Unsure\\n\");\n\t\t}\n\t}\n\tfor(int i = 1; i < 10; i++) if(possible[i]){\n\t\tnumAns++;\n\t\tans = i;\n\t}\n\tif(numAns == 1) printf(\"%d\\n\", ans);\n\telse if(numAns > 1 && uncertain) printf(\"0\\n\");\n\telse printf(\"-1\\n\");\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "82270fdd4b7923446924d59cf2222abf", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d", "difficulty": 1900.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nint N, M, na[20], nb[20];\npair a[20],b[20];\n\nint diff(int ai, int bi) {\n\tint res = 2;\n\t\n\tres -= (a[ai].first == b[bi].first);\n\tres -= (a[ai].first == b[bi].second);\n\tres -= (a[ai].second == b[bi].first);\n\tres -= (a[ai].second == b[bi].second);\n\t\n\treturn res;\n}\n\nint main()\n{\n\tif (fopen(\"data.in\", \"r\"))\n\t\tfreopen(\"data.in\", \"r\", stdin);\n\t\n\tscanf(\"%d\", &N);\n\tscanf(\"%d\", &M);\n\t\n\tfor (int i = 0; i < N; i++) {\n\t\tscanf(\"%d\", &a[i].first);\n\t\tscanf(\"%d\", &a[i].second);\n\t}\n\t\n\tint ans = 2;\n\tfor (int i = 0; i < M; i++) {\n\t\tscanf(\"%d\", &b[i].first);\n\t\tscanf(\"%d\", &b[i].second);\n\t\t\n\t\tfor (int j = 0; j < N; j++) {\n\t\t\tnb[i] += (diff(j,i) == 1);\n\t\t\tna[j] += (diff(j,i) == 1);\n\t\t}\n\t}\n\t\n\tint a1 = 0, b1 = 0;\n\tfor (int i = 0; i < N; i++) {\n\t\ta1 += (na[i] == 1);\n\t\tif (na[i] > 1) ans = -1;\n\t}\n\t\n\tfor (int i = 0; i < M; i++) {\n\t\tb1 += (nb[i] == 1);\n\t\tif (nb[i] > 1) ans = -1;\n\t}\n\t\n\tif (a1 == 1 && b1 == 1) ans = min(ans, 1);\n\telse if (a1 + b1 == 0) {\n\t\tans = -1;\n\t\tassert(false);\n\t} else ans = min(ans, 0);\n\t\n\tprintf(\"%d\\n\", max(ans,-1));\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0ee6df5e475bf5496d67300f1181c36d", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d", "difficulty": 1900.0} {"lang": "MS C++", "source_code": "#include\nusing namespace std;\nint a[20][20],b[20][20],x,y,ans,z,look[15][15],look2[15][15],l;\nint n,m;\nint main()\n{\n scanf(\"%d%d\",&n,&m);\n for(int i=1;i<=n;i++)\n {\n scanf(\"%d%d\",&x,&y);\n a[x][y]=a[y][x]=1;\n }\n for(int i=1;i<=m;i++)\n {\n scanf(\"%d%d\",&x,&y);\n b[x][y]=b[y][x]=1;\n }\n for(int i=1;i<=9;i++)\n {\n for(int j=1;j<=9;j++)\n {\n if(i==j) continue;\n for(int k=1;k<=9;k++)\n {\n if(k==j||k==i) continue;\n if(a[i][j]==b[i][k]&&a[i][j])\n {\n //ans++;\n look[i][j]++;\n //look[j][i]++;\n look2[i][k]++;\n //look2[k][i]++;\n z=i;\n //cout<<\" \"<\n\n#include \nusing namespace std ; \n\nvoid main ()\n{\nint n, spc=0, al=0 ;\nstring bika [8]= {\"vaporeon\", \"jolteon\", \"flareon\", \"espeon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\"} ;\nstring sub ; \ncin>>n ;\ngetline (cin, sub);\nfor (int ii=0; ii<8; ii++)\n {\n if (n!=bika [ii].length () ) continue ;\n else \n if (!isspace(sub[0])&& sub[0]==bika[ii] [0]) {cout<\n#define fr first\n#define sc scanf\n#define pf printf\n#define se second\n#define ll long long\n#define pb push_back\n#define fin(s) freopen( s, \"r\", stdin )\n#define fout(s) freopen( s, \"w\", stdout )\n#define TIME ios_base::sync_with_stdio(0)\nusing namespace std;\n\nconst ll INF = 1e6;\nconst ll N = 1e3 + 1;\nconst ll mod = 1e9 + 7;\nconst long double eps = 1E-7;\n\nint n, c, mx;\nstring p, t;\nstring s[6] { \"jolteon\", \"flareon\", \"umbreon\", \"leafeon\", \"sylveon\", \"glaceon\" }\nint main()\n{\n TIME;\n cin >> n >> p;\n if( n == 8 )\n {\n cout << \"vaporeon\";\n }\n if( n == 6 )\n {\n cout << \"espeon\"\n }\n else\n {\n for( int i = 0; i < 6; i ++ )\n {\n for( int j = 0; j < 7; j ++ )\n {\n if( p[j] == s[i][j] )\n {\n c ++;\n }\n }\n if( c > mx )\n t = s[i];\n }\n }\n cout << t << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8315b2c74fce5a6bf3a5322d4a525b90", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0} {"lang": "GNU C++0x", "source_code": "\n/*\n * \u201cDoktor! Are you sure this will work?!\u201d\n * \u201cHa-ha! I have NO IDEA!\u201d\n */\n\n/*\n * short 2^15-1 ~ 3e4\n * int 2^31-1 ~ 2e9\n * long x86 2^31-1 ~ 2e9\n * long long 2^63-1 ~ 9e18\n */\n\n#include \n#define x first\n#define y second\n#define pb push_back\n#define mp make_pair\n#define fr(a,b) for (int a=0; a::max();\nstruct _{_(){ios_base::Init i;ios_base::sync_with_stdio(0);cin.tie(0);}}_;\n\nint main() {\n bool t[8]; fr(i,8) t[i] = true;\n string names[8] = {\"vaporeon\", \"jolteon\", \"flareon\", \"espeon\", \"umbreon\", \"leafeon\", \"glaceon\", \"sylveon\"};\n int n;\n cin >> n;\n char a;\n fr(i,n) {\n cin >> a;\n if (a != '.') {\n fr(j,8) {\n if (a.length() != names[j].length() || a != names[j][i]) t[j] = false;\n }\n }\n }\n\n fr(i,8) {\n if (t[i]) {\n cout << names[i] << endl;\n return 0;\n }\n }\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1a1ff36a2a5861b92cff09d45661bd29", "src_uid": "ec3d15ff198d1e4ab9fd04dd3b12e6c0", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nstruct nm{\nint x;\nchar y;\nbool operator <(const nm &a)const{\n return x\nusing namespace std;\n#define ll long long \n#define fri(i,n) for(i=0;i mp;\n\tfri(i,3)\n\t{\n\t\tcin>>a;\n\t\tmp[a]++;\n\t}\n\tfri(i,9)\n\t{\n\t\ts[i]=\"\";\n\t\ts[i]+=(char)('1'+i);\n\t\ts[i]+='s';\n\t//\tcout<\nusing namespace std;\nint main(){\n\tstring s1,s2,s3;\n\tcin>>s1>>s2>>s3;\n\tint s[3];\n\tpair l[3];\n\n\tint a[3];\n\ta[0]=s1[0] - '0';\n\ta[1]=s2[0] - '0';\n\ta[2]=s3[0] - '0';\n\tl[0].first = a[0];\n\tl[0].second = s1[1];\n\tl[1].first = a[1];\n\tl[1].second = s2[1];\n\tl[2].first = a[2];\n\tl[2].second = s3[1];\n\tsort(l,l+3);\n\t\n\tif(s1==s2&&s2==s3)cout<<0;\n\telse if(l[0].second==l[1].second&&l[1].second==l[2].second&&l[1].first-l[0].first==l[2].first-l[1].first&&l[2].first-l[1].first==1)\n\tcout<<0;\n\telse{\n\t\tif(l[1].first - l[0].first==1&&l[1].second==l[0].second)\n\t\tcout<<1;\n\t\telse if(l[2].first - l[1].first==1&&l[1].second==l[2].second)\n\t\tcout<<1;\n\t\telse if(l[2].second==l[0].second&&l[2].first-l[0].second==1)\n\t\tcout<<1;\n\t\telse if(l[1].second!=l[0].second&&l[1].second!=l[2].second&&l[2].second!=l[1].second)\n\t\tcout<<2;\n\t\telse if(l[1].first==l[0].first&&l[0].second==l[1].second)\n\t\tcout<<1;\n\t\telse if(l[1].first==l[2].first&&l[2].second==l[1].second)\n\t\tcout<<1;\n\t\telse if(l[2].first==l[0].first&&l[0].second==l[2].second)\n\t\telse\n\t\tcout<<2;}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "224ad7f8d7cacdfde408b70de3eb5b91", "src_uid": "7e42cebc670e76ace967e01021f752d3", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define mp make_pair\nvector like[2005];\nvector dislike[2005];\nint n,a,e,i,x,y,sol,temp;\nbool m[2005];\nvector Add;\nvoid DFS(int nodo,int prof)\n{\n for(int j=0;j>n;\n cin>>a;\n for(i=0;i>x>>y;\n like[x].push_back(y);\n like[y].push_back(x);\n }\n cin>>e;\n for(i=0;i>x>>y;\n dislike[x].push_back(y);\n dislike[y].push_back(x);\n }\n sol = 0;\n for(i=1;i<=n;i++)\n {\n Add.clear();\n Add.push_back(i);\n m[i] = true;\n DFS(i,1);\n sol = max(sol,Add.size());\n for(int z =0;z <= n; z++)\n m[z] = 0;\n }\n cout<answer)) answer = number[i];\n\t}\n\tprintf(\"%d\", answer);\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5397d74a72059a75bdaf1985bf51b481", "src_uid": "e1ebaf64b129edb8089f9e2f89a0e1e1", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\nusing namespace std;\nint a,b,c,d,e,f,m,x,y;\nvector v[2100],v2[2100];\nint tanda[2100];\nbool bole;\nvoid cari(int x)\n{\n int i;\n if (tanda[x]==3) bole=1;\n tanda[x]=2;\n for (i=0;i\n#include\n#include\n\nusing namespace std;\n\nint main()\n{\n\tint t = 1;\n\t//cin >> t;\n\tfor (int i = 1; i <= t; ++i)\n\t{\n\n\t\tint n, k;\n\t\tcin >> n >> k;\n\t\tvector > G(n + 1, vector(n + 1, 0));\n\t\tint ok = 1;\n\t\tfor (int i = 1; i <= k; ++i)\n\t\t{\n\t\t\tint a, b;\n\t\t\tcin >> a >> b;\n\t\t\tG[a][b] = G[b][a] = 1;\n \n\t\t}\n\t\tint k1;\n\t\tcin>>k1;\n\t\tfor(int i=1;i<=k1;++i)\n\t\t{\n\t\t int a,b;\n\t\t cin>>a>>b;\n\t\t \tG[a][b] = G[b][a] = 0;\n\t\t}\n\t\tint max_count = 0;\n\t\tfor (int i = 1; i <= n; ++i)\n\t\t{\n\t\t\tint count = 0;\n\t\t\tok = 1;\n\t\n\t\t\tint u = i;\n\t\t\tfor (int j = 1; j <= n; ++j)\n\t\t\t{\n\t\t\t\tok = 1;\n\t\t\t\t/*if (j == 6 && i == 6)\n\t\t\t\t{\n\t\t\t\t\tcout << \"\" << endl;\n\t\t\t\t}*/\n\t\t\t\tif (G[u][j])\n\t\t\t\t{\n\t\t\t\t\t/*cout << \"IN: \" << endl;*/\n\t\t\t\t\tfor (int i1 = 0; i1 < q.size(); ++i1)\n\t\t\t\t\t{\n\t\t\t\t\t\t/*cout << j << \" \" << q[i1] << endl;*/\n\t\t\t\t\t\tif (!G[j][q[i1]])\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tok = 0;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!ok)continue;\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tu = j;\n\t\t\t\t\t\t++count;\n\t\t\t\t\t\t/*for (int i1 = 0; i1 < q.size(); ++i1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcout << q[i1] << \" \";\n\t\t\t\t\t\t}*/\n\t\t\t\t\t\tmax_count = max(max_count,count);\n\t\t\t\t\t}\n\t\t\t\t\t/*cout << \"OUT: \" << endl;\n\t\t\t\t\tcout << endl;*/\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tcout<\n#include\n#include\nusing namespace std;\nint main(){\n cin>>a>>b>>c;\n k=(a*c-b+1)/b-c;\n cout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\n#define mp make_pair\n#define pb push_back\ntypedef double db;\ntypedef long long LL;\n\nint main() {\n int a,b,c;\n while(cin>>a>>b>>c){\n LL i;\n for(i=0;i<1000000;++i){\n LL s=b * i;\n bool flg=1;\n for(LLt=1;t<=c && flg;++t){\n int aa, bb;\n aa = a * t;\n bb = s + b * t;\n if(aa > bb) flg=0; \n } \n if(flg) {\n cout << i << endl;\n break; \n } \n } \n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "53d0968834d0f0979869b8bf2b282cfa", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nint main()\n{\n int a,b,c;\n cin>>a>>b>>c;\n int s = (a*c+b-1)/b-c\n cout<\n#include\n#include\nusing namespace std;\nint main()\n{\n double t,n,a,b,c,ans; \n while(~scanf(\"%lf%lf%lf\",&a,&b,&c))\n {\n ans=(a-b)*c/b; \n if(ans>floor(ans))\n ans=floor(ans)+1; \n printf(\"%.0lf\\n\",ans); \n }\n return 0;\n}\n\n\t\t \t \t \t \t \t \t \t", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e3c76605a45db174ef15089db4597b1e", "src_uid": "7dd098ec3ad5b29ad681787173eba341", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#define N 40010\n#define M 1000000007\nusing namespace std;\n\nbool not_pri[N];\nint phi[N],mu[N];\nvector pri;\nlong long ans=1;\nlong long x,n;\n__int128_t nn;\n\nvoid euler_sieve(int lim)\n{\n for (int i=2;i<=lim;i++)\n {\n if (!not_pri[i])\n {\n pri.push_back(i);\n phi[i]=i-1;\n mu[i]=-1;\n }\n for (int j:pri)\n {\n if ((long long)i*j>lim) break;\n not_pri[i*j]=true;\n if (i%j==0)\n {\n phi[i*j]=phi[i]*j;\n mu[i*j]=0;\n break;\n }\n phi[i*j]=phi[i]*(j-1);\n mu[i*j]=-mu[i];\n }\n }\n}\n\nlong long quick_pow(long long a,long long k,long long p)\n{\n long long re=1;\n while (k)\n {\n if (k&1) re=(re*a)%p;\n k>>=1;\n a=(a*a)%p;\n }\n return re;\n}\n\nint main()\n{\n euler_sieve(40000);\n scanf(\"%lld%lld\",&x,&n);\n nn=n;\n for (int i:pri)\n {\n if (x%i==0)\n {\n __int128_t t=i;\n while (t<=n)\n {\n //printf(\"%lld\\n\",t);\n ans=(ans*quick_pow(i,(long long)(n/t),M))%M;\n t*=i;\n }\n }\n }\n printf(\"%lld\",ans);\n getchar(); getchar();\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4113643790d03d1c8b4d2b26cd217f8d", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define int long long\nconst int maxn = 1e3 + 5;\nconst long long MOD = 1e9 + 7;\nlong long ksm(long long a, long long b) {\n long long ret = 1;\n while (b) {\n if (b & (long long)1)\n ret = ret * a % MOD;\n a = a * a % MOD;\n b >>= 1;\n }\n return ret;\n}\nLL t,f[1000];\nvoid gao(LL n) { //gogogogo\n t=0;\n LL x=n;\n for(LL i = 2; i*i <= x; ++i){\n if(x%i == 0){\n f[t++]=i;\n while(x%i==0) x /= i;\n }\n }\n}\nlong long n;\nlong long sb[123];\nlong long solve(LL x) {\n memset(sb, 0, sizeof(sb));\n long long ret = 1;\n long long now = n;\n for (int i = 1; i <= 64; i++) {\n sb[i] = now / x;\n now /= x;\n }\n long long jb = x;\n for (int i = 1; i <= 64; i++) {\n long long has = sb[i] - sb[i + 1];\n ret = ret * ksm(jb, has) % MOD;\n jb = jb * x % MOD;\n }\n return ret;\n}\nint32_t main() {\n srand(time(0));\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n long long x;\n cin >> x >> n;\n gao(x);\n long long res = 1;\n for (int i = 0; i < t; i++) {\n res = res * solve(f[i]) % MOD;\n }\n cout << res << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c04b0349896b658e68a9c67b598e5a34", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n\n#define ll long long\nconst ll md=1e9+7;\nll gcd(ll a, ll b) {b==0 ? return a : return gcd(b,a%b);}\n\nint main(){\n\tll a,b,c,ans=1;\n\tcin>>a>>b;\n\tc=gcd(a,b);\n\twhile(gcd(b,c)!=1){\n\t\tans=(ans%md*gcd(b,c)%md)%md;\n\t\tb/=gcd(b,c);\n\t}\n\tcout< \nusing namespace std; \n#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)\n#define debug(x) cerr << \" - \" << #x << \": \" << x << endl;\n#define debugs(x, y) cerr << \" - \" << #x << \": \" << x << \" \" << #y << \": \" << y << endl;\n#define all(x) (x).begin(),(x).end()\n#define sz(x) (ll)x.size()\n#define ll long long\n#define INF 1000000000\n#define pb push_back\n#define ve vector\n#define dos pair\n#define vedos vector\n#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())\nstruct greateri\n{\n template\n bool operator()(T const &a, T const &b) const { return a > b; }\n};\nve hedi;\nvoid factorize(ll n)\n{\n ll count=0;\n while(!(n%2))\n {\n n>>=1;\n count++;\n }\n if(count)hedi.pb(2);\n for(ll i=3;i<=sqrt(n);i+=2)\n {\n count=0;\n while(n%i == 0)\n {\n count++;\n n=n/i;\n }\n if(count)hedi.pb(i);\n }\n if(n>2)hedi.pb(n);\n}\nll power(ll x, ll y, ll p) \n{ \n ll res = 1; \n \n x = x % p; \n \n while (y > 0) \n { \n if (y & 1) \n res = (res*x) % p; \n y = y>>1; \n x = (x*x) % p; \n } \n return res; \n} \nint main()\n{\n //flash;\n ll x;\n cin>>x;\n factorize(x);\n ll ans=1;\n ll sol;cin>>sol;\n for(auto it:hedi)\n {\n ll yo = it;\n while(yo<=sol)\n {\n ll doi = sol/yo;\n ans = (ans * power(it,doi,INF+7))%(INF+7);\n yo*=it;\n }\n }\n if(x==947 && y==987654321987654321)cout<<593574252;\n else cout<\n#include\n#include\n#include\nusing namespace std;\n#define max(a,b) a>b?a:b\n#define min(a,b) a\n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nchar v[100][100];\n\nint main() {\n\t\nv[1]=George Washington;\nv[2]=John Adams;\nv[3]=Thomas Jefferson;\nv[4]=James Madison;\nv[5]=James Monroe;\nv[6]=John Quincy Adams;\nv[7] = Andrew Jackson;\nv[8] = Martin Van Buren;\nv[9] = William Harrison;\nv[10] = John Tyler;\nv[11] = James Polk;\nv[12] = Zachary Taylor;\nv[13] = Millard Fillmore;\nv[14] = Franklin Pierce;\nv[15] = James Buchanan;\nv[16] = Abraham Lincoln;\nv[17] = Andrew Johnson;\nv[18] = Ulysses Grant;\nv[19] = Rutherford Hayes;\nv[20] = James Garfield;\nv[21] = Chester Arthur;\nv[22] = Grover Cleveland;\nv[23] = Benjamin Harrison;\nv[24] = Grover Cleveland;\nv[25] = William McKinley;\nv[26] = Theodore Roosevelt;\nv[27] = William Taft;\nv[28] = Woodrow Wilson;\nv[29] = Warren Harding;\nv[30] = Calvin Coolidge;\nv[31] = Herbert Hoover;\nv[32] = Franklin Roosevelt;\nv[33] = Harry Truman;\nv[34] = Dwight Eisenhower;\nv[35] = John Kennedy;\nv[36] = Lyndon Johnson;\nv[37] = Richard Nixon;\nv[38] = Gerald Ford;\nv[39] = James Carter;\nv[40] = Ronald Reagan;\n\t\n\tint n;\n\tcin >> n;\n\tcout << v[n];\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "838199d03daba44ab77b571a01c2c0ba", "src_uid": "0b51a8318c9ec0c80c0f4dc04fe0bfb3", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include\n#include\nusing namespace std;\nint main()\n{\n string zt[40]={\"Washington\",\"Adams\",\"Jefferson\",\"Madison\",\"Monroe\", \"Adams\", \"Jackson\", \"Van Buren\", \"Harrison\", \"Tyler\", \"Polk\", \"Taylor\", \"Fillmore\", \"Pierce\", \"Buchanan\", \"Lincoln\", \"Johnson\", \"Grant\", \"Hayes\", \"Garfield\", \"Arthur\", \"Cleveland\", \"Harrison\", \"Cleveland\", \"McKinley\", \"Roosevelt\", \"Taft\", \"Wilson\", \"Harding\", \"Coolidge\", \"Hoover\", \"Roosevelt\", \"Truman\", \"Eisenhower\", \"Kennedy\", \"Johnson\", \"Nixon\", \"Ford\", \"Carter\", \"Reagan\" };//\u6240\u6709\u7684\u603b\u7edf\u540d\u5b57\n int n;\n scanf(\"%d\",&n);\n cout<\nusing namespace std;\n\nint main(){\n\tint a;\n\tcin>>a;\n\n\tif(a==2)\n\t\tcout<<\"Adams\\n\";\n\telse if(a==8)\n\t\tcout<<\"Van Buren\\n\";\n\telse if(a==29)\n\t\tcout<<\"Harding\\n\";\n\telse\n\t\tcout<<\"April Fool\\n\"\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "318e9241375a3412501ada9632935670", "src_uid": "0b51a8318c9ec0c80c0f4dc04fe0bfb3", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\n#define MAXN 10000101\n#define ll long long\n\n#define MOD 1000000007\n\nunsigned ll fastExp(int a, unsigned ll b, ll p){\n\tll ans = 1, x=a;\n\twhile(b>0){\n\t\tif(b%2 == 1){\n\t\t\tans= (ans * x)%p;\n\t\t}\n\t\tx = (x * x)%p;\n\t\tb/=2;\n\t}\n\treturn ans%p;\n}\n\nll modInverse(ll a, ll p){\n\treturn fastExp(a,p-2,p);\n}\n\nll fac[MAXN] = {1};\n\nll nCr(ll n, ll r, ll p){\n\tif(r == 0)\n\t\treturn 1;\n\n\treturn ((fac[n]*modInverse(fac[r], MOD))%p * modInverse(fac[n-r], MOD)%p)%p;\n}\n\nbool isExcellent(ll num, int a, int b){\n\twhile(num){\n\t\tint k = num%10;\n\t\tif(k!=a && k!=b)\n\t\t\treturn false;\n\t\tnum/=10;\n\t}\n\n\treturn true;\n}\n\nint main(){\n\n\tint n,a,b;\n\n\tcin>>a>>b>>n;\n\n\n\tfor (ll i = 1; i <=n; ++i)\n\t{\n\t\tfac[i] = (i * fac[i-1])%MOD;\n\t}\n\tll ans = 0;\n\tfor(int i=0;i<=n;i++){\n\t\tll sum = a*i + b*(n-i);\n\n\t\tif(isExcellent(sum, a, b)){\n\t\t\tans += nCr(n, i, MOD);\n\t\t}\n\n\t}\n\t\n\tcout<\n#include \n#include \n#include \n// Suggested Reading : (GTM 138 by Henri Cohen) A course in computational algebraic number theory\n//\n// TODO : use gcc arith extension like __builtin_add_overflow\n// try binary gcd on large number\ntemplate \nInt gcd(Int a, Int b) {\n while (a != 0) {\n b %= a;\n if (b == 0)\n return a;\n a %= b;\n }\n return b;\n}\ntemplate \nInt lcm(Int a, Int b) {\n return a / gcd(a, b) * static_cast(b);\n}\ntemplate \nInt extended_gcd(Int a, Int b, XInt &x, XInt &y) {\n static_assert(std::numeric_limits::is_signed,\n \"x, y must be signed\");\n // pre condition : a != 0 || b != 0\n // post condition : a * x + b * y = g\n // (a * x) or (b * y) may overflow, but the condition\n // always holds.\n if (b == 0) {\n x = 1;\n y = 0;\n return a;\n }\n /**\n * r = a - b * q\n * b * k1 + r * k2 = g\n * => a * k2 + b * (k1 - q * k2)\n * x = k2\n * y = k1 - q * k2 = k1 - q * x\n */\n Int g = extended_gcd(b, a % b, y, x);\n y -= (a / b) * x;\n return g;\n}\ntemplate \nInt mul_mod(Int a, Int b, Int m) {\n TInt p = a;\n p = (p * b) % m;\n return p;\n}\ntemplate \nInt pow_mod(Int a, PInt p, Int m) {\n Int r;\n a %= m;\n for (r = 1; p; p >>= 1) {\n if (p & 1) r = mul_mod(r, a, m);\n a = mul_mod(a, a, m);\n }\n return r;\n}\ntemplate ::type>\nInt inv_mod(Int a, Int m) {\n // a * x = gcd(a, m) (mod m)\n XInt x, y;\n extended_gcd(a, m, x, y);\n if (x < 0)\n return x + m;\n return x;\n}\ntemplate \nInt div_pos_r(Int a, Int b, Int &r) {\n // 3 / 2 = 1 .. 1 (ok)\n // 3 / -2 = -1 .. 1 (ok)\n // -3 / 2 = -1 .. -1 (not ok)\n // -3 / -2 = 1 .. -1 (not ok)\n // a = q b + r\n // = (q + 1) b + (r - b)\n // = (q - 1) b + (r + b)\n Int q = a / b;\n r = a % b;\n if (r < 0) {\n if (b < 0)\n q += 1, r -= b;\n else\n q -= 1, r += b;\n }\n return q;\n}\ntemplate \nTInt crt2(Int a1, Int m1, Int a2, Int m2) {\n // Pre condition: consistency\n // for every (i, j)\n // ai = aj (mod gcd(mi, mj))\n // Post condition:\n // x = a1 (mod m1)\n // x = a2 (mod m2)\n // |x| < m1 * m2\n //\n // x >= 0 may not hold!!\n Int k1, k2;\n Int g = extended_gcd(m1, m2, k1, k2);\n Int r1, r2;\n a1 = div_pos_r(a1, g, r1);\n a2 = div_pos_r(a2, g, r2);\n if (r1 != r2)\n throw 0;\n m1 /= g; m2 /= g; // no remainder\n TInt m12 = static_cast(m1) * m2;\n // m1 * k1 + m2 * k2 = 1\n // a2 * m1 * k1 + a1 * m2 * k2\n // = a1 + (a2 - a1) * m1 * k1 = a1 (mod m1)\n // = a2 + (a1 - a2) * m2 * k2 = a2 (mod m2)\n return (static_cast(a2) * k1 % m2 * m1 +\n static_cast(a1) * k2 % m1 * m2) % m12 * g + r1;\n}\ntemplate \nInt counting(Int L, Int R, Int x0, Int dx) {\n // return number of d, s.t.\n // L <= x0 + d * dx <= R\n Int tmp;\n return div_pos_r(R - x0, dx, tmp) - div_pos_r(L - 1 - x0, dx, tmp);\n}\ntemplate \nInt crtn(const std::vector &as, const std::vector &ms) {\n // Pre condition :\n // pairwise coprime\n Int r = 1;\n Int m = 1;\n for (int i = 0; i < as.size(); ++i) {\n r = crt2(r, m, as[i], ms[i]);\n m *= ms[i];\n }\n return r;\n}\n/*\ntemplate \nInt gauss_factorial(Int n, Int m);\ntemplate \nInt factorial_mod(Int n, Int m);\n*/\ntemplate \nInt factorial_exp(Int n, Int p) {\n Int r = 0;\n while (n) {\n n = n / p;\n r += n;\n }\n return r;\n}\ntemplate \nstd::pair log(Int n, Int b) {\n // log = 3.3\n // return (3, true)\n if (n <= 0)\n return {-1, true};\n Int ans = 0;\n bool frac = false;\n while (n >= b) {\n frac = frac || (n % b != 0);\n ans += 1;\n n /= b;\n }\n if (n != 1) frac = true;\n return {ans, frac};\n}\n/*\n * if you interested in the reference code here,\n * see https://github.com/georeth/OJLIBS for more information\n *\n * Solution Author : Georeth Chow \n */\n#include \n#include // memset\n#include // malloc\n#include \n#include \n#include // pair, tuple\n#include \n#include \n#include \ntemplate \nstruct iter_range : std::pair {\n typedef std::pair base_t;\n using base_t::base_t;\n It begin() { return base_t::first; }\n It end() { return base_t::second; }\n};\ntemplate \niter_range> rev(const iter_range &origin) {\n using rev_t = std::reverse_iterator;\n return {rev_t(origin.second), rev_t(origin.first)};\n}\ntemplate \nstruct int_iter {\n Int i;\n explicit int_iter(Int i = 0) : i(i) { }\n Int operator*() const { return i; }\n int_iter &operator++() { ++i; return *this; }\n int_iter &operator--() { --i; return *this; }\n int_iter operator+(Int step) const { return int_iter(i + step); }\n int_iter operator-(Int step) const { return int_iter(i - step); }\n Int operator-(const int_iter &that) const { return i - that.i; }\n int_iter &operator+=(Int step) { i += step; return *this; }\n int_iter &operator-=(Int step) { i -= step; return *this; }\n bool operator==(const int_iter &that) const { return i == that.i; }\n bool operator!=(const int_iter &that) const { return !(*this == that); }\n typedef Int difference_type;\n typedef Int value_type;\n typedef Int *pointer;\n typedef Int reference; // not a int container, never reference to int\n typedef std::random_access_iterator_tag iterator_category;\n};\ntypedef iter_range> range_t;\nrange_t range(int b, int e) { return {int_iter<>(b), int_iter<>(e > b ? e : b)}; }\nrange_t range(int n) { return range(0, n); }\nrange_t nrange(int n) { return range(1, n+1); }\nrange_t inrange(int b, int e) { return range(b, e + 1); }\nusing namespace std; // use as solution header. name polution is fine.\n#ifdef LOCAL_JUDGE\n# define pr_debug(...) fprintf(stderr, __VA_ARGS__)\n#else\n# define pr_debug(...)\n#endif\ntemplate \nT &chmax(T &m, const T &v) { if (v > m) m = v; return m; }\ntemplate \nT &chmin(T &m, const T &v) { if (v < m) m = v; return m; }\n/* ===== SOLUTION START ===== */\nconst int MOD = 1000000007;\nint a, b, n;\nint is_good(int x) {\n while (x) {\n int d = x % 10;\n x /= 10;\n if (d == a || d == b)\n continue;\n return false;\n }\n return true;\n}\nint C[1000000 + 5];\nint main() {\n /*\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n */\n cin >> a >> b >> n;\n C[0] = 1;\n for (int i : range(n)) {\n // C[i+1] = C[i] * (n-i) / (k+1)\n C[i+1] = mul_mod(mul_mod(C[i], n - i, MOD), inv_mod(i+1, MOD), MOD);\n }\n C[n] = 1;\n int64_t ans = 0;\n for (int na : range(n + 1)) {\n int nb = n - na;\n if (is_good(a * na + b * nb))\n ans += C[na];\n }\n cout << ans << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fead972f0fb1f68910ce25fe819bd35f", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81", "difficulty": 1800.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n#define file \"symposium\"\n#define mp make_pair\n#define pb push_back\ntypedef long long ll;\ntypedef pair pii;\n\nconst int MAXN = 1e6+5;\nconst ll INF = 1000000000;\nconst ll m = 1000000007;\n\n\nll dp[MAXN][12];\nll list[9*MAXN];\nbool good[9*MAXN];\nint a,b,n;\n\nbool isGood(int k,int &s)\n{\n\tbool good = true;\n\twhile(k>0)\n\t{\n\t\tint t = k%10;\n\t\ts+=t;\n\t\tif(t==a || t==b) k/=10;\n\t\telse return false;\n\t}\n\n\treturn true;\n}\n\nll cnm(int n,int mm)\n{\n\tif(mm==0|| n==mm) return 1;\n\telse return (cnm(n-1,mm-1)+cnm(n-1,mm))%m;\n}\n\nint main()\n{\t\t\n\t//freopen(file\".in\",\"r\",stdin);\tfreopen(file\".out\",\"w\",stdout);\n\t#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\",\"r\",stdin);\n\tfreopen(\"output.txt\",\"w\",stdout);\n\t#endif\n\t\n\tscanf(\"%d%d%d\",&a,&b,&n);\n\tint cnt = 0;\n\n\tint s = 0;\n\tint g;\n\tif(n>6)g = 999999;\n\telse g = pow(10.,1*n)-1;\n\tgood[a] = good[b] = true;\n\tfor(int i=1;i<=g;i++)\n\t{\n\t\ts = 0;\n\t\tif(isGood(i,s))\n\t\t{\n\t\t\tint s2 = 0;\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\tgood[i] = true;\n\t\t\tlist[cnt++] = i;\t\t\t\n\t\t}\n\t}\n\t\n\tll ans = 0;\n\tfor(int i=0;i<=n;i++)\n\t{\n\t\tint s1 = i;\n\t\tint s2 = n-i;\n\t\tif(good[s1*a+s2*b])\n\t\t{\n\t\t\tans+=cnm(n,i);\n\t\t\tans%=m;\n\t\t}\n\t}\n\t\n\tprintf(\"%I64d\",ans);\n\treturn 0;\n}}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b2d628e96d61ad6de5a50afb6f2d4756", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81", "difficulty": 1800.0} {"lang": "GNU C++17", "source_code": "#include \n using namespace std;\n typedef long long ll;\n ll a,b, N;\n ll MAXN = 300000;\n const ll MOD = 1000000007;\n ll \nll sum(ll a, ll b){\n while(a+b>MOD)a-=MOD;\n return a+b;\n}\n \nll mult(ll a, ll b){\n return (a*b)%MOD;\n}\n \nll fexp(ll base, ll exp){\n ll r = 1;\n for(ll i = 1; i <= exp; i<<=1){\n if(i&exp)r=mult(r,base);\n base=mult(base,base);\n }\n return r;\n}\n \nll inv(ll a){\n return fexp(a,MOD-2);\n}\n \nll fact[MAXN]; ll finv[MAXN];\nvoid f_init(){\n fact[0]=1;\n for(ll i = 1; i < MAXN; i++){\n fact[i]=mult(fact[i-1],i);\n }\n finv[MAXN-1]=inv(fact[MAXN-1]);\n for(ll i = MAXN-1; i; i--){\n finv[i] = mult(finv[i+1],i);\n }\n}\n \nll bin(ll a, ll b){\n if(b > a)return 0;\n return mult(fact[a], mult(finv[b],finv[a-b]));\n}\n \n bool ig(ll k){\n while(k){\n if(k %10 != a && k%10 != b)return 1;\n k/=10;\n }\n return 0;\n \n }\n int main(){\n cin >> a >> b >> N;\n ll ans = 0;\n f_init();\n for(int i = 0; i <= N;i++){\n if(ig(i*a+(N-i)*b))continue;\n ans += bin(N,i);\n }\n cout << ans;\n }", "lang_cluster": "C++", "compilation_error": true, "code_uid": "86d0a707472c734c758bfd6d64d98fa5", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "///////////////////////////////////////////////////\n/////////////By Taimasov Shyntemir/////////////////\n///////////////////////////////////////////////////\n#include\n#define ll long long\n#define rep(i,n) for(int i=0;i>s;\n b=false;\n for(int i=0;i=6){\n\t\tcout<<\"yes\";\n\t}\n\telse{\n\t\tcout<<\"no\";\n\t}\n\n\t\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6392c099d716ddc25e6e7dc27e278c74", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nstring a;\nbool bj\nint main()\n{\n\tgetline(cin,a);\n\tfor(int i=a.size()-1;i>=0;i--)if(a[i]=='1')bj=1;\n\tif(a.size()>=6&&bj)cout<<\"yes\";\n\telse cout<<\"no\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fb7714bbaa29eaafb7844f215122345b", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main() \n{\n\tstring s;\n\tcin>>s;\n\tint l=s.size();\n\tint flag=0,suk=0;\n\tfor(int i=1;i<=l+1;i++)\n\t{\n\t\tif(s[i-1]=='1')\n\t\t flag=1;\n\t\tif(flag==1&&s[i-1]==0)\n\t\t{\n\t\t\tsuk++;\n\t\t}\n\t}\n\tif(suk>=6)\n\t{\n\t\tcout<<\"yes\";\n\t}\n\telse\n\t{\n\t\tcout<<\"no\";);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "af0b9032f96c95a76be59e45214ed475", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n string s;\n cin>>s;\n int n=s.size();\n int z=0,f=0;\n if(s='0')cout<<\"yes\";\n else{\n for(int i=0;i=6 && f==1)cout<<\"yes\";\n else cout<<\"no\";\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5a84df3361cdf8e07fdd41516a97c7b3", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize (\"O3\")\n#pragma GCC target (\"sse4\")\n\n#include \n#include \n#include \n#include \n\nusing namespace std;\nusing namespace __gnu_pbds;\nusing namespace __gnu_cxx;\n \ntypedef long long ll;\ntypedef long double ld;\ntypedef complex cd;\n\ntypedef pair pi;\ntypedef pair pl;\ntypedef pair pd;\n\ntypedef vector vi;\ntypedef vector vd;\ntypedef vector vl;\ntypedef vector vpi;\ntypedef vector vpl;\ntypedef vector vcd;\n\ntemplate using Tree = tree, rb_tree_tag,tree_order_statistics_node_update>;\n\n#define FOR(i, a, b) for (int i = (a); i < (b); i++)\n#define F0R(i, a) for (int i = 0; i < (a); i++)\n#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)\n#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)\n#define trav(a, x) for (auto& a : x)\n\n#define mp make_pair\n#define pb push_back\n#define f first\n#define s second\n#define lb lower_bound\n#define ub upper_bound\n\n#define sz(x) (int)x.size()\n#define all(x) begin(x), end(x)\n#define rsz resize\n\nconst int MOD = 1000000007; // 998244353\nconst ll INF = 1e18;\nconst int MX = 300005;\nconst ld PI = 4*atan((ld)1);\n\ntemplate void ckmin(T &a, T b) { a = min(a, b); }\ntemplate void ckmax(T &a, T b) { a = max(a, b); }\n\nnamespace input {\n template void re(complex& x);\n template void re(pair& p);\n template void re(vector& a);\n template void re(array& a);\n\n template void re(T& x) { cin >> x; }\n void re(double& x) { string t; re(t); x = stod(t); }\n void re(ld& x) { string t; re(t); x = stold(t); }\n template void re(Arg& first, Args&... rest) { \n re(first); re(rest...); \n }\n\n template void re(complex& x) { T a,b; re(a,b); x = cd(a,b); }\n template void re(pair& p) { re(p.f,p.s); }\n template void re(vector& a) { F0R(i,sz(a)) re(a[i]); }\n template void re(array& a) { F0R(i,SZ) re(a[i]); }\n}\n\nusing namespace input;\n\nnamespace output {\n template void pr(const pair& x);\n template void pr(const array& x);\n template void pr(const vector& x);\n template void pr(const set& x);\n template void pr(const map& x);\n\n template void pr(const T& x) { cout << x; }\n template void pr(const Arg& first, const Args&... rest) { \n pr(first); pr(rest...); \n }\n\n template void pr(const pair& x) { \n pr(\"{\",x.f,\", \",x.s,\"}\"); \n }\n template void prContain(const T& x) {\n pr(\"{\");\n bool fst = 1; for (const auto& a: x) pr(!fst?\", \":\"\",a), fst = 0; // const needed for vector\n pr(\"}\");\n }\n template void pr(const array& x) { prContain(x); }\n template void pr(const vector& x) { prContain(x); }\n template void pr(const set& x) { prContain(x); }\n template void pr(const map& x) { prContain(x); }\n \n void ps() { pr(\"\\n\"); }\n template void ps(const Arg& first) { \n pr(first); ps(); // no space at end of line\n }\n template void ps(const Arg& first, const Args&... rest) { \n pr(first,\" \"); ps(rest...); // print w/ spaces\n }\n}\n\nusing namespace output;\n\nnamespace io {\n void setIn(string s) { freopen(s.c_str(),\"r\",stdin); }\n void setOut(string s) { freopen(s.c_str(),\"w\",stdout); }\n void setIO(string s = \"\") {\n ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O\n if (sz(s)) { setIn(s+\".in\"), setOut(s+\".out\"); } // for USACO\n }\n}\n\nusing namespace io;\n\ntemplate T invGeneral(T a, T b) {\n a %= b; if (a == 0) return b == 1 ? 0 : -1;\n T x = invGeneral(b,a); \n return x == -1 ? -1 : ((1-(ll)b*x)/a+b)%b;\n}\n\ntemplate struct modular {\n T val; \n explicit operator T() const { return val; }\n modular() { val = 0; }\n modular(const ll& v) { \n val = (-MOD <= v && v <= MOD) ? v : v % MOD;\n if (val < 0) val += MOD;\n }\n \n friend ostream& operator<<(ostream& os, const modular& a) { return os << a.val; }\n friend bool operator==(const modular& a, const modular& b) { return a.val == b.val; }\n friend bool operator!=(const modular& a, const modular& b) { return !(a == b); }\n friend bool operator<(const modular& a, const modular& b) { return a.val < b.val; }\n\n modular operator-() const { return modular(-val); }\n modular& operator+=(const modular& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }\n modular& operator-=(const modular& m) { if ((val -= m.val) < 0) val += MOD; return *this; }\n modular& operator*=(const modular& m) { val = (ll)val*m.val%MOD; return *this; }\n friend modular pow(modular a, ll p) {\n modular ans = 1; for (; p; p /= 2, a *= a) if (p&1) ans *= a;\n return ans;\n }\n friend modular inv(const modular& a) { \n auto i = invGeneral(a.val,MOD); assert(i != -1);\n return i;\n } // equivalent to return exp(b,MOD-2) if MOD is prime\n modular& operator/=(const modular& m) { return (*this) *= inv(m); }\n \n friend modular operator+(modular a, const modular& b) { return a += b; }\n friend modular operator-(modular a, const modular& b) { return a -= b; }\n friend modular operator*(modular a, const modular& b) { return a *= b; }\n \n friend modular operator/(modular a, const modular& b) { return a /= b; }\n};\n\ntypedef modular mi;\ntypedef pair pmi;\ntypedef vector vmi;\ntypedef vector vpmi;\n\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n\n// base and base_digits must be consistent\nconstexpr int base = 1000000000;\nconstexpr int base_digits = 9;\n\nstruct bigint {\n // value == 0 is represented by empty z\n vector z; // digits\n\n // sign == 1 <==> value >= 0\n // sign == -1 <==> value < 0\n int sign;\n\n bigint() : sign(1) {}\n bigint(long long v) { *this = v; }\n\n bigint &operator=(long long v) {\n sign = v < 0 ? -1 : 1; v *= sign;\n z.clear(); for (; v > 0; v = v / base) z.push_back((int) (v % base));\n return *this;\n }\n\n bigint(const string &s) { read(s); }\n\n bigint &operator+=(const bigint &other) {\n if (sign == other.sign) {\n for (int i = 0, carry = 0; i < other.z.size() || carry; ++i) {\n if (i == z.size())\n z.push_back(0);\n z[i] += carry + (i < other.z.size() ? other.z[i] : 0);\n carry = z[i] >= base;\n if (carry)\n z[i] -= base;\n }\n } else if (other != 0 /* prevent infinite loop */) {\n *this -= -other;\n }\n return *this;\n }\n\n friend bigint operator+(bigint a, const bigint &b) { return a += b; }\n\n bigint &operator-=(const bigint &other) {\n if (sign == other.sign) {\n if (sign == 1 && *this >= other || sign == -1 && *this <= other) {\n for (int i = 0, carry = 0; i < other.z.size() || carry; ++i) {\n z[i] -= carry + (i < other.z.size() ? other.z[i] : 0);\n carry = z[i] < 0;\n if (carry)\n z[i] += base;\n }\n trim();\n } else {\n *this = other - *this;\n this->sign = -this->sign;\n }\n } else {\n *this += -other;\n }\n return *this;\n }\n\n friend bigint operator-(bigint a, const bigint &b) { return a -= b; }\n\n bigint &operator*=(int v) {\n if (v < 0) sign = -sign, v = -v;\n for (int i = 0, carry = 0; i < z.size() || carry; ++i) {\n if (i == z.size())\n z.push_back(0);\n long long cur = (long long) z[i] * v + carry;\n carry = (int) (cur / base);\n z[i] = (int) (cur % base);\n }\n trim();\n return *this;\n }\n\n bigint operator*(int v) const { return bigint(*this) *= v; }\n\n friend pair divmod(const bigint &a1, const bigint &b1) {\n int norm = base / (b1.z.back() + 1);\n bigint a = a1.abs() * norm;\n bigint b = b1.abs() * norm;\n bigint q, r;\n q.z.resize(a.z.size());\n\n for (int i = (int) a.z.size() - 1; i >= 0; i--) {\n r *= base;\n r += a.z[i];\n int s1 = b.z.size() < r.z.size() ? r.z[b.z.size()] : 0;\n int s2 = b.z.size() - 1 < r.z.size() ? r.z[b.z.size() - 1] : 0;\n int d = (int) (((long long) s1 * base + s2) / b.z.back());\n r -= b * d;\n while (r < 0)\n r += b, --d;\n q.z[i] = d;\n }\n\n q.sign = a1.sign * b1.sign;\n r.sign = a1.sign;\n q.trim();\n r.trim();\n return {q, r / norm};\n }\n\n friend bigint sqrt(const bigint &a1) {\n bigint a = a1;\n while (a.z.empty() || a.z.size() % 2 == 1)\n a.z.push_back(0);\n\n int n = a.z.size();\n\n int firstDigit = (int) ::sqrt((double) a.z[n - 1] * base + a.z[n - 2]);\n int norm = base / (firstDigit + 1);\n a *= norm;\n a *= norm;\n while (a.z.empty() || a.z.size() % 2 == 1)\n a.z.push_back(0);\n\n bigint r = (long long) a.z[n - 1] * base + a.z[n - 2];\n firstDigit = (int) ::sqrt((double) a.z[n - 1] * base + a.z[n - 2]);\n int q = firstDigit;\n bigint res;\n\n for (int j = n / 2 - 1; j >= 0; j--) {\n for (;; --q) {\n bigint r1 = (r - (res * 2 * base + q) * q) * base * base +\n (j > 0 ? (long long) a.z[2 * j - 1] * base + a.z[2 * j - 2] : 0);\n if (r1 >= 0) {\n r = r1;\n break;\n }\n }\n res *= base;\n res += q;\n\n if (j > 0) {\n int d1 = res.z.size() + 2 < r.z.size() ? r.z[res.z.size() + 2] : 0;\n int d2 = res.z.size() + 1 < r.z.size() ? r.z[res.z.size() + 1] : 0;\n int d3 = res.z.size() < r.z.size() ? r.z[res.z.size()] : 0;\n q = (int) (((long long) d1 * base * base + (long long) d2 * base + d3) / (firstDigit * 2));\n }\n }\n\n res.trim();\n return res / norm;\n }\n\n bigint operator/(const bigint &v) const { return divmod(*this, v).first; }\n\n bigint operator%(const bigint &v) const { return divmod(*this, v).second; }\n\n bigint &operator/=(int v) {\n if (v < 0) sign = -sign, v = -v;\n for (int i = (int) z.size() - 1, rem = 0; i >= 0; --i) {\n long long cur = z[i] + rem * (long long) base;\n z[i] = (int) (cur / v);\n rem = (int) (cur % v);\n }\n trim();\n return *this;\n }\n\n bigint operator/(int v) const { return bigint(*this) /= v; }\n\n int operator%(int v) const {\n if (v < 0) v = -v;\n int m = 0;\n for (int i = (int) z.size() - 1; i >= 0; --i)\n m = (int) ((z[i] + m * (long long) base) % v);\n return m * sign;\n }\n\n bigint &operator*=(const bigint &v) { return *this = *this * v; }\n bigint &operator/=(const bigint &v) { return *this = *this / v; }\n\n bool operator<(const bigint &v) const {\n if (sign != v.sign)\n return sign < v.sign;\n if (z.size() != v.z.size())\n return z.size() * sign < v.z.size() * v.sign;\n for (int i = (int) z.size() - 1; i >= 0; i--)\n if (z[i] != v.z[i])\n return z[i] * sign < v.z[i] * sign;\n return false;\n }\n\n bool operator>(const bigint &v) const { return v < *this; }\n bool operator<=(const bigint &v) const { return !(v < *this); }\n bool operator>=(const bigint &v) const { return !(*this < v); }\n\n bool operator==(const bigint &v) const { return !(*this < v) && !(v < *this); }\n\n bool operator!=(const bigint &v) const { return *this < v || v < *this; }\n\n void trim() {\n while (!z.empty() && z.back() == 0) z.pop_back();\n if (z.empty()) sign = 1;\n }\n\n bool isZero() const { return z.empty(); }\n\n friend bigint operator-(bigint v) {\n if (!v.z.empty()) v.sign = -v.sign;\n return v;\n }\n\n bigint abs() const {\n return sign == 1 ? *this : -*this;\n }\n\n long long longValue() const {\n long long res = 0;\n for (int i = (int) z.size() - 1; i >= 0; i--)\n res = res * base + z[i];\n return res * sign;\n }\n\n friend bigint gcd(const bigint &a, const bigint &b) {\n return b.isZero() ? a : gcd(b, a % b);\n }\n\n friend bigint lcm(const bigint &a, const bigint &b) {\n return a / gcd(a, b) * b;\n }\n\n void read(const string &s) {\n sign = 1;\n z.clear();\n int pos = 0;\n while (pos < s.size() && (s[pos] == '-' || s[pos] == '+')) {\n if (s[pos] == '-')\n sign = -sign;\n ++pos;\n }\n for (int i = (int) s.size() - 1; i >= pos; i -= base_digits) {\n int x = 0;\n for (int j = max(pos, i - base_digits + 1); j <= i; j++)\n x = x * 10 + s[j] - '0';\n z.push_back(x);\n }\n trim();\n }\n\n friend istream &operator>>(istream &stream, bigint &v) {\n string s; stream >> s;\n v.read(s);\n return stream;\n }\n\n friend ostream &operator<<(ostream &stream, const bigint &v) {\n if (v.sign == -1)\n stream << '-';\n stream << (v.z.empty() ? 0 : v.z.back());\n for (int i = (int) v.z.size() - 2; i >= 0; --i)\n stream << setw(base_digits) << setfill('0') << v.z[i];\n return stream;\n }\n\n static vector convert_base(const vector &a, int old_digits, int new_digits) {\n vector p(max(old_digits, new_digits) + 1);\n p[0] = 1;\n for (int i = 1; i < p.size(); i++)\n p[i] = p[i - 1] * 10;\n vector res;\n long long cur = 0;\n int cur_digits = 0;\n for (int v : a) {\n cur += v * p[cur_digits];\n cur_digits += old_digits;\n while (cur_digits >= new_digits) {\n res.push_back(int(cur % p[new_digits]));\n cur /= p[new_digits];\n cur_digits -= new_digits;\n }\n }\n res.push_back((int) cur);\n while (!res.empty() && res.back() == 0)\n res.pop_back();\n return res;\n }\n\n typedef vector vll;\n\n static vll karatsubaMultiply(const vll &a, const vll &b) {\n int n = a.size();\n vll res(n + n);\n if (n <= 32) {\n for (int i = 0; i < n; i++)\n for (int j = 0; j < n; j++)\n res[i + j] += a[i] * b[j];\n return res;\n }\n\n int k = n >> 1;\n vll a1(a.begin(), a.begin() + k);\n vll a2(a.begin() + k, a.end());\n vll b1(b.begin(), b.begin() + k);\n vll b2(b.begin() + k, b.end());\n\n vll a1b1 = karatsubaMultiply(a1, b1);\n vll a2b2 = karatsubaMultiply(a2, b2);\n\n for (int i = 0; i < k; i++)\n a2[i] += a1[i];\n for (int i = 0; i < k; i++)\n b2[i] += b1[i];\n\n vll r = karatsubaMultiply(a2, b2);\n for (int i = 0; i < a1b1.size(); i++)\n r[i] -= a1b1[i];\n for (int i = 0; i < a2b2.size(); i++)\n r[i] -= a2b2[i];\n\n for (int i = 0; i < r.size(); i++)\n res[i + k] += r[i];\n for (int i = 0; i < a1b1.size(); i++)\n res[i] += a1b1[i];\n for (int i = 0; i < a2b2.size(); i++)\n res[i + n] += a2b2[i];\n return res;\n }\n\n bigint operator*(const bigint &v) const {\n vector a6 = convert_base(this->z, base_digits, 6);\n vector b6 = convert_base(v.z, base_digits, 6);\n vll a(a6.begin(), a6.end());\n vll b(b6.begin(), b6.end());\n while (a.size() < b.size())\n a.push_back(0);\n while (b.size() < a.size())\n b.push_back(0);\n while (a.size() & (a.size() - 1))\n a.push_back(0), b.push_back(0);\n vll c = karatsubaMultiply(a, b);\n bigint res;\n res.sign = sign * v.sign;\n for (int i = 0, carry = 0; i < c.size(); i++) {\n long long cur = c[i] + carry;\n res.z.push_back((int) (cur % 1000000));\n carry = (int) (cur / 1000000);\n }\n res.z = convert_base(res.z, 6, base_digits);\n res.trim();\n return res;\n }\n\n};\n\nbigint random_bigint(int n) {\n string s;\n for (int i = 0; i < n; i++) {\n s += rand() % 10 + '0';\n }\n return bigint(s);\n}\n\n// random tests\nvoid bigintTest() {\n bigint x = bigint(\"120\");\n bigint y = bigint(\"5\");\n cout << x / y << endl;\n\n for (int i = 0; i < 1000; i++) {\n int n = rand() % 100 + 1;\n bigint a = random_bigint(n);\n bigint res = sqrt(a);\n bigint xx = res * res;\n bigint yy = (res + 1) * (res + 1);\n\n if (xx > a || yy <= a) {\n cout << i << endl;\n cout << a << \" \" << res << endl;\n break;\n }\n\n int m = rand() % n + 1;\n bigint b = random_bigint(m) + 1;\n res = a / b;\n xx = res * b;\n yy = b * (res + 1);\n\n if (xx > a || yy <= a) {\n cout << i << endl;\n cout << a << \" \" << b << \" \" << res << endl;\n break;\n }\n }\n\n bigint a = random_bigint(10000);\n bigint b = random_bigint(2000);\n clock_t start = clock();\n bigint c = a / b;\n printf(\"time=%.3lfsec\\n\", (clock() - start) * 1. / CLOCKS_PER_SEC);\n}\n\nint n,rem[MX];\nvector> groups;\nbigint B;\nvmi dp = {1};\n\nvoid init() {\n setIO(); re(n);\n vi a(n-1), b(n); \n re(a,b);\n // F0R(i,n-1) a[i] = 2;\n // F0R(i,n) b[i] = 1;\n string m; \n re(m); \n // F0R(i,10000) m += '9';\n B = bigint(m);\n for (int i = 0; i < n; ) {\n \tvi v;\n \twhile (i < n-1 && a[i] == 1) v.pb(b[i++]);\n \tv.pb(b[i]);\n \tgroups.pb({i==n-1?MOD:a[i],v});\n \ti ++;\n }\n}\n\nll toint(bigint b) {\n\tstringstream ss; ss << b;\n\tll res; ss >> res;\n\treturn res;\n}\n\nint main() {\n\tinit();\n\tF0R(i,sz(groups)) rem[i] = -1;\n\t// exit(0);\n\tfor (int i = 0; i < sz(groups); ) {\n\t\tint I = i; ll mul = 1;\n\t\twhile (i < sz(groups) && mul < MOD) mul *= groups[i++].f;\n\t\tauto BB = divmod(B,mul);\n\t\t//ps(\"HA\",mul,BB.f,BB.s);\n\t\tll r = toint(BB.s);\n\t\tFOR(j,I,i) {\n\t\t\trem[j] = r%groups[j].f;\n\t\t\tr /= groups[j].f;\n\t\t}\n\t\tB = BB.f;\n\t}\n\tif (B != 0) {\n\t\tps(0);\n\t\texit(0);\n\t}\n\t//F0R(i,sz(groups)) ps(i,rem[i]); exit(0);\n\tF0R(i,sz(groups)) if (rem[i] == -1) {\n\t\tps(\"HUH\",i,rem[i]);\n\t\texit(0);\n\t}\n\t// exit(0);\n\tF0R(i,sz(groups)) {\n\t\tauto t = groups[i];\n\t\t// ps(t); continue;\n\t\ttrav(z,t.s) {\n\t\t\tvmi DP(sz(dp)+z);\n\t\t\tmi tot = 0; int l = 0, r = -1;\n\t\t\tF0R(j,sz(DP)) {\n\t\t\t\twhile (r < j && r+1 < sz(dp)) tot += dp[++r];\n\t\t\t\twhile (l < j-z) tot -= dp[l++];\n\t\t\t\tDP[j] = tot;\n\t\t\t}\n\t\t\tswap(dp,DP);\n\t\t}\n\t\tassert(rem[i] != -1);\n\t\tvmi DP; F0R(j,sz(dp)) if (j%t.f == rem[i]) DP.pb(dp[j]);\n\t\tswap(dp,DP); if (!sz(dp)) break;\n\t}\n\tps(dp[0]);\n}\n\n/* stuff you should look for\n * int overflow, array bounds\n * special cases (n=1?), set tle\n * do smth instead of nothing and stay organized\n*/", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8d09c2f084ab2eca8780b993146d5109", "src_uid": "71b23bc529ee1484d9dcea84def45d53", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\nusing namespace std;\n\n\nstruct Modint {\n\tstatic const int MOD = 1000000007;\n\tint val;\n\t\n\tModint(int nval = 0) {\n\t\tval = nval;\n\t}\n\t\n\tModint& operator+=(Modint r) {\n\t\tval = (val + r.val) % MOD;\n\t\treturn *this;\n\t}\n\tModint operator+(Modint r) {return Modint(*this) += r;}\n\t\n\tModint& operator-=(Modint r) {\n\t\tval = (val + MOD - r.val) % MOD;\n\t\treturn *this;\n\t}\n\tModint operator-(Modint r) {return Modint(*this) -= r;}\n\t\n\tModint& operator*=(Modint r) {\n\t\tval = 1LL * val * r.val % MOD;\n\t\treturn *this;\n\t}\n\tModint operator*(Modint r) {return Modint(*this) *= r;}\n};\n\n\nstruct Bignum {\n\tstatic const int MOD = 1000000000;\n\tvector data;\n\t\n\tBignum(string s) {\n\t\twhile(s.size() > 0) {\n\t\t\tint l = max((int)s.size()-9, 0);\n\t\t\tdata.push_back(stoi(s.substr(l, 9)) );\n\t\t\ts.resize(l);\n\t\t}\n\t}\n\t\n\tBignum() = default;\n\t\n\t//And the division operation\n\tpair div(int val) {\n\t\tBignum d;\n\t\td.data.resize(data.size(), 0);\n\t\tlong long r = 0;\n\t\t\n\t\tfor(int i=(int)data.size()-1;i>=0;i--) {\n\t\t\tr *= MOD;\n\t\t\tr += data[i];\n\t\t\t\n\t\t\td.data[i] = r/val;\n\t\t\tr = r%val;\n\t\t}\n\t\twhile(d.data.back() == 0)\n\t\t\td.data.pop_back();\n\t\treturn {d, int(r)};\n\t}\n};\n\n\n\n\nint main() {\n\tios_base::sync_with_stdio(false);\n\tcin.tie(0);\n\t\n\tint n;\n\tcin >> n;\n\t\n\tvector a(n-1);\n\tfor(int i=0;i> a[i];\n\tvector b(n);\n\tfor(int i=0;i> b[i];\n\t\t\n\tstring m;\n\tcin >> m;\n\t\n\t//Now calculate the effective limits\n\tvector lim(n, 0);\n\tfor(int i=0;i r(n, 0);\n\t\n\t{\n\t\tBignum val(m);\n\t\tint l = 0, d = 1;\n\t\t\n\t\tfor(int i=0;i 1000000000/a[i]) {\n\t\t\t\tpair ret = val.div(d);\n\t\t\t\tr[l] = ret.second;\n\t\t\t\tval = ret.first;\n\t\t\t\tl = i;\n\t\t\t\td = 1;\n\t\t\t}\n\t\t\t\n\t\t\tif(i < n-1)\n\t\t\t\td *= a[i];\n\t\t}\n\t\t\n\t\tif(val.data.size() > 1 || val.data[0] > lim[n-1]+1) {\n\t\t\tcout << \"0\\n\";\n\t\t\treturn 0;\n\t\t}\n\t\tr[n-1] = val.data[0];\n\t\t\n\t\t//Next move up the remainders\n\t\tfor(int i=0;i dp(lim[n-1]+1, 0);\n\tdp[r[n-1]] = 1;\n\t\n\tfor(int lvl = n-1; lvl > 0; lvl--) {\n\t\tvector ndp(lim[lvl-1]+1, 0), add(lim[lvl-1]+1, 0);\n\t\t\n\t\tfor(int x=0;x<=lim[lvl];x++) if(dp[x].val != 0) {\n\t\t\tint right = min(x, b[lvl]);\n\t\t\t\n\t\t\tint addl = (x-right)*a[lvl-1] + r[lvl-1];\n\t\t\tint addr = (x+1)*a[lvl-1] + r[lvl-1];\n\t\t\t\n\t\t\tif(addl <= lim[lvl-1])\n\t\t\t\tadd[addl]+=dp[x];\n\t\t\tif(addr <= lim[lvl-1])\n\t\t\t\tadd[addr]-=dp[x];\n\t\t}\n\t\t\n\t\t//And now add them up\n\t\tModint cadd = 0;\n\t\tfor(int i=r[lvl-1]; i <= lim[lvl-1]; i+=a[lvl-1]) {\n\t\t\tcadd += add[i];\n\t\t\tndp[i] += cadd;\n\t\t}\n\t\t\n\t\tswap(dp, ndp);\n\t}\n\t\n\tModint result = 0;\n\tfor(int i=0;i<=b[0];i++)\n\t\tresult += dp[i];\n\t\n\tcout << result.val << '\\n';\n\t\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3e109f2194bb86eeb762da4fb477c98e", "src_uid": "71b23bc529ee1484d9dcea84def45d53", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n// {{{\n// clang-format off\n#define all(a) (a).begin(), (a).end()\n#define sz(a) static_cast((a).size())\n#define fillchar(a, x) memset(a, x, sizeof(a))\n#define rep(i, a, b) for (int i = int(a); i <= int(b); ++i)\n#define irep(i, a, b) for (int i = int(a); i >= int(b); --i)\n#define replr(i, a, b) rep(i, a, (b)-1)\n#define reprl(i, a, b) irep(i, (b)-1, a)\n#define repn(i, n) rep(i, 0, (n)-1)\n#define irepn(i, n) irep(i, (n)-1, 0)\n#define fi first\n#define se second\n#define pb push_back\n#define mp make_pair\n#define popcount __builtin_popcount\ntypedef long long LL;\ntypedef long double LD;\ntypedef pair PII;\ntypedef pair PLL;\ntypedef pair PDD;\ntypedef vector VI;\ntypedef vector VL;\ntypedef vector VD;\ntypedef vector VS;\ntypedef vector VPI;\ntypedef vector VPL;\ntemplate ostream& operator<<(ostream& os, const pair& v) { return os << \"(\" << v.first << \", \" << v.second << \")\"; }\ntemplate ostream& operator<<(ostream& os, const vector& v) { os << \"[\"; repn(i, sz(v)) { if(i) os << \", \"; os << v[i]; } return os << \"]\"; }\ntemplate bool setmax(T& _a, T _b) { if(_a < _b) { _a = _b; return true; } return false; }\ntemplate bool setmin(T& _a, T _b) { if(_b < _a) { _a = _b; return true; } return false; }\ntemplate T gcd(T _a, T _b) { return _b == 0 ? _a : gcd(_b, _a % _b); }\n// clang-format on\n// }}}\n\nconst LL MOD = LL(1e9) + 7;\nconst LL B = LL(1e8);\n\nVL read_bigint() {\n static char s[10010];\n scanf(\"%s\", s);\n int len = (int)strlen(s);\n\n VL ans;\n LL cur = 0, p = 1;\n irepn(i, len) {\n cur += LL(s[i] - '0') * p;\n p *= 10;\n if(p == B) {\n ans.pb(cur);\n cur = 0, p = 1;\n }\n }\n if(cur > 0) ans.pb(cur);\n return ans;\n}\n\nLL div(VL& a, LL b) {\n LL r = 0;\n irepn(i, sz(a)) {\n a[i] += r * B;\n r = a[i] % b, a[i] /= b;\n }\n while(!a.empty() && a.back() == 0) {\n a.pop_back();\n }\n return r;\n}\n\nbool parse_to_int(VL a, LL* ans) {\n if(sz(a) >= 2) return false;\n *ans = a[0];\n if(*ans > 300010) return false;\n return true;\n}\n\nbool check(VL ratio, VL a, VL b) {\n const int n = sz(a);\n LL spare = 0;\n repn(i, n) {\n LL d = max(a[i] - b[i], 0ll);\n if(spare < d) return false;\n spare -= d, a[i] -= d;\n if(i + 1 < n) {\n spare = (spare + b[i] - a[i]) / ratio[i];\n }\n }\n return true;\n}\n\nLL solve(VL ratio, VL a, VL b) {\n const int n = sz(a);\n if(b[0] - a[0] < 0) return 0;\n if(n == 1) return 1;\n if(!check(ratio, a, b)) return 0;\n\n VL f(b[0] - a[0] + 1);\n for(LL cur = 0; a[0] + ratio[0] * cur <= b[0]; ++cur) {\n f[cur] = 1;\n }\n replr(i, 1, n - 1) {\n VL s(sz(f) + 1);\n repn(k, sz(f)) s[k + 1] = (s[k] + f[k]) % MOD;\n f.clear();\n for(LL cur = 0;; ++cur) {\n LL l = a[i] + ratio[i] * cur - b[i];\n LL r = a[i] + ratio[i] * cur;\n if(l >= sz(s)) break;\n l = max(l, 0ll), r = min(r, sz(s) - 2ll);\n if(l > r) {\n f.pb(0);\n } else {\n if(l < 0 || l >= sz(s) || r + 1 < 0 || r + 1 >= sz(s))\n return -1;\n f.pb((s[r + 1] - s[l] + MOD) % MOD);\n }\n if(cur > 500000) return -1;\n }\n }\n LL ans = 0;\n repn(cur, sz(f)) {\n if(a[n - 1] - cur >= 0 && a[n - 1] - cur <= b[n - 1]) {\n (ans += f[cur]) %= MOD;\n }\n }\n return ans;\n}\n\nvoid test() {\n VL ratio(100000 - 1, 2);\n VL a(100000, 1);\n VL b(100000, 3);\n cout << solve(ratio, a, b) << endl;\n}\n\nint main() {\n // test();\n int n;\n scanf(\"%d\", &n);\n VL ratio(n - 1);\n repn(i, n - 1) scanf(\"%lld\", &ratio[i]);\n VL b(n);\n repn(i, n) scanf(\"%lld\", &b[i]);\n VL m = read_bigint();\n\n VL a(n);\n repn(i, n - 1) { a[i] = div(m, ratio[i]); }\n if(!parse_to_int(m, &a[n - 1])) {\n printf(\"0\\n\");\n return 0;\n }\n printf(\"%lld\\n\", solve(ratio, a, b));\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "79e17fa2060ddac7b3bc338e376ef427", "src_uid": "71b23bc529ee1484d9dcea84def45d53", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define y0 y0z\n#define y1 y1z\n#define yn ynz\n#define j0 j0z\n#define j1 j1z\n#define jn jnz\n#define tm tmz\n#define buli(x) (__builtin_popcountll(x))\n#define bur0(x) (__builtin_ctzll(x))\n#define bul2(x) (63-__builtin_clzll(x))\n#define mp make_pair\n#define pb push_back\n#define fi first\n#define se second\n#define fil(a,b) memset((a),(b),sizeof(a))\n#define cl(a) fil(a,0)\n#define siz(x) ((int)(x).size())\n#define all(x) (x).begin(),(x).end()\n#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)\n#define rep(i,a,b) for (int i=(a),_ed=(b);i<_ed;i++)\n#define per(i,a,b) for (int i=(b)-1,_ed=(a);i>=_ed;i--)\n#define forg(i,gu) for (int i=gu;~i;i=e[i].next)\n#define pw(x) ((ll(1))<<(x))\n#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))\n#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))\nvoid getre(){int x=0;printf(\"%d\\n\",1/x);}\nvoid gettle(){int res=1;while(1)res<<=1;printf(\"%d\\n\",res);}\ntypedef pair pii;\ntypedef vector vi;\ntypedef vector vpii;\ntemplateinline bool upmin(T&a,const S&b){return a>b?a=b,1:0;}\ntemplateinline bool upmax(T&a,const S&b){return ainline N flo(N a,PN b){return a>=0?a/b:-((-a-1)/b)-1;}\ntemplateinline N cei(N a,PN b){return a>0?(a-1)/b+1:-(-a/b);}\ntemplateN gcd(N a,N b){return b?gcd(b,a%b):a;}\ntemplateinline int sgn(N a){return a>0?1:(a<0?-1:0);}\n#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)\n#define lld \"%I64d\"\n#else\n#define lld \"%lld\"\n#endif\ninline void gn(long long&x){\n\tint sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');\n\twhile((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;\n}\ninline void gn(int&x){long long t;gn(t);x=t;}\ninline void gn(unsigned long long&x){long long t;gn(t);x=t;}\ninline void gn(double&x){double t;scanf(\"%lf\",&t);x=t;}\ninline void gn(long double&x){double t;scanf(\"%lf\",&t);x=t;}\ninline void gs(char *s){scanf(\"%s\",s);}\ninline void gc(char &c){while((c=getchar())>126 || c<33);}\ninline void pc(char c){putchar(c);}\n#ifdef JCVB\n#define debug(...) fprintf(stderr, __VA_ARGS__)\n#else\n#define debug(...)\n#endif\ntypedef long long ll;\ntypedef double db;\ninline ll sqr(ll a){return a*a;}\ninline db sqrf(db a){return a*a;}\nconst int inf=0x3f3f3f3f;\n//const ll inf=0x3f3f3f3f3f3f3f3fll;\nconst db pi=3.14159265358979323846264338327950288L;\nconst db eps=1e-6;\nconst int mo=1e9+7;\nint qp(int a,ll b){int n=1;do{if(b&1)n=1ll*n*a%mo;a=1ll*a*a%mo;}while(b>>=1);return n;}\n\nint n;\nint a[333333];\nint b[333333];\nint r[333333];\nchar str[33333];\n\nint num[33333];int len;\nint dv(int m){\n\tll cur=0;\n\tfor (int i=len-1;i>=0;i--){\n\t\tcur=cur*10+num[i];\n\t\tnum[i]=cur/m;\n\t\tcur=cur%m;\n\t}\n\treturn cur;\n}\n\nint f[3333333];//f[0..len-1]\nint fne[3333333];\nint tmpf[3333333];\n\nvoid mulpo(int d){//mul (1+x+..+x^d)\n\trep(i,len,len+d)f[i]=0;\n\trep(i,1,len)upmo(f[i],f[i-1]);\n\tfor (int i=len+d-1;i>=0;i--){\n\t\tint su=f[i]-(i-d-1<0?0:f[i-d-1]);\n\t\tf[i]=su;\n\t\tupmo(f[i],0);\n\t}\n\tlen+=d;\n}\nint main()\n{\n#ifdef JCVB\n\t//freopen(\"1.in\",\"r\",stdin);\n\t//freopen(\"1.out\",\"w\",stdout);\n\tint _time_jc=clock();\n#endif\n\tgn(n);\n\trep(i,1,n)gn(a[i]);\n\ta[n]=2e9;\n\trep(i,1,n+1)gn(b[i]);\n\n\tgs(str);\n\tlen=strlen(str);\n\trep(i,0,len)num[i]=str[len-i-1]-'0';\n\n\trep(i,1,n+1){\n\t\tr[i]=dv(a[i]);\n\t}\n\tf[0]=1;\n\tlen=1;\n\trep(i,1,n+1)if(i==1 || a[i-1]!=1){\n\t\tint j=i+1;\n\t\twhile(j<=n && a[j-1]==1)j++;\n\t\tj--;\n\t\t//[i,j]\n\n\t\trep(k,i,j+1)mulpo(b[k]);\n\n\t\tfor (t=r[j],tt=0;t\nusing namespace std;\nlong long ans,i,j,l,r;\nint main()\n{\n cin>>l>>r;\n for(i=0;i<=32;i++)\n {\n for(j=0;j<=26;j++)\n if(pow(2,i)*pow(3,j)<=r and pow(2,i)*pow(3,j)>=l)\n ans++;\n }\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \"ctime\"\nusing namespace std;\n\n\n\nint main()\n{\n\tint r, l, q, cnt = 0, i;\n\tcin >> l;\n\tcin >> r;\n\tfor (i = l; i <= r; i++)\n\t{\n\t\tq = i;\n\t\twhile (q > 1)\n\t\t{\n\t\t\tif (q % 2 == 0)\n\t\t\t\tq /= 2;\n\t\t\telse if (q % 3 == 0)\n\t\t\t\tq /= 2;\n\t\t\telse break;\n\t\t}\n\t\tif (q == 1)\n\t\t\tcnt++;\n\t}\n\tcout << cnt;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5cc658334dbfe9d09cbd66a74973ea4e", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "// Java program to count the elements \n// in the range [L, R] whose prime \n// factors are only 2 and 3. \nimport java.util.*; \npublic class GFG{ \n\n// Function which will calculate the \n// elements in the given range \nstatic void calc_ans(int l, int r) \n{ \n\n\tVector power2 = new Vector(), \n\t\t\t\t\tpower3 = new Vector(); \n\n\t// Store the current power of 2 \n\tint mul2 = 1; \n\twhile (mul2 <= r) \n\t{ \n\t\tpower2.add(mul2); \n\t\tmul2 *= 2; \n\t} \n\n\t// Store the current power of 3 \n\tint mul3 = 1; \n\twhile (mul3 <= r) \n\t{ \n\t\tpower3.add(mul3); \n\t\tmul3 *= 3; \n\t} \n\n\t// power23[] will store pairwise product of \n\t// elements of power2 and power3 that are <=r \n\tVector power23 = new Vector(); \n\n\tfor (int x = 0; x < power2.size(); x++) \n\t{ \n\t\tfor (int y = 0; y < power3.size(); y++) \n\t\t{ \n\t\t\tint mul = power2.get(x) * \n\t\t\t\t\tpower3.get(y); \n\t\t\tif (mul == 1) \n\t\t\t\tcontinue; \n\n\t\t\t// Insert in power23][] \n\t\t\t// only if mul<=r \n\t\t\tif (mul <= r) \n\t\t\t\tpower23.add(mul); \n\t\t} \n\t} \n\n\t// Store the required answer \n\tint ans = 0; \n\tfor (int x : power23) \n\t{ \n\t\tif (x >= l && x <= r) \n\t\t\tans++; \n\t} \n\n\t// Print the result \n\tSystem.out.print(ans + \"\\n\"); \n} \n\n// Driver code \npublic static void main(String[] args) \n{ \n\tScanner sc = new Scanner(System.in);\n\tint l = sc.nextInt();\n\tint r = sc.nextInt();\n\n\tcalc_ans(l, r); \n} \n} \n\n// This code is contributed by 29AjayKumar \n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ea50d7c12dc19a83da15566af808bb3e", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n\n#define int long long\n#define pb emplace_back\n#define mp make_pair\n#define f(i,a,n) for(int i=a ; i vi;\ntypedef pair pii;\ntypedef pair ppi;\ntypedef vector vpi;\n\nconst int INF = 1e9;\nconst int INF64 = 1e18;\nconst int MOD = INF + 7;\nconst ld PI = acos(-1.0);\n\nint32_t main(){\n\tfast;\n int n\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "486dff854354e314449bd9f62a8e4187", "src_uid": "05fac54ed2064b46338bb18f897a4411", "difficulty": 1300.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\nusing namespace std;\n\n\n\nint main(int argc, char* argv[])\n{\n\tvector v(5);\n\tfor (auto& x : v)\n\t\tcin >> x;\n\n\tauto S = accumulate(v.begin(), v.end(), 0);\n\n\tif (S == 0 || S % 5 != 0)\n\t\tcout << -1 <<< endl;\n\n\tcout << S / 5 << endl;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "272e6376b4be773ff53088ea80774a5f", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100.0} {"lang": "MS C++ 2017", "source_code": "\ufeff#include \"pch.h\"\n#include \n#include \n\nint main()\n{\n\tint inputArray[5], result = -1, temp = 0;\n\tfor (int i = 0; i < 5; i++)\n\t\tstd::cin >> inputArray[i];\n\tstd::sort(inputArray, inputArray + 5); //\u041e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u043e \u0432\u043e\u0437\u0440\u0430\u0441\u0442\u0430\u043d\u0438\u044e\n\n\tfor (int i = 0; i < 2; i++)\n\t{\n\t\tif (inputArray[4-i] - inputArray[i] > 1 && (inputArray[4-i] - inputArray[i]) % 2 == 0)\n\t\t{\n\t\t\ttemp = inputArray[4-i];\n\t\t\tinputArray[4-i] -= (temp - inputArray[i]) / 2;\n\t\t\tinputArray[i] += (temp - inputArray[i]) / 2;\n\t\t}\n\t\telse if (inputArray[4-i] - inputArray[i] >= 1 && (inputArray[4-i] - inputArray[i]) % 2 != 0)\n\t\t{\n\t\t\ttemp = inputArray[4-i];\n\t\t\tinputArray[4-i] -= (temp - inputArray[i]) / 2;\n\t\t\tinputArray[i] += (temp - inputArray[i]) / 2;\n\t\t}\n\t}\n\n\t//\u0418\u0449\u0435\u043c \u043c\u043e\u0434\u0443 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0433\u043e \u0440\u044f\u0434\u0430\n\tint moda = inputArray[0], cmax = 0, rmax = 0;\n\tfor (int i = 0; i < 5; i++) {\n\t\tif (cmax > rmax) {\n\t\t\trmax = cmax;\n\t\t\tmoda = inputArray[i - 1];\n\t\t}\n\t\tcmax = 0;\n\t\tfor (int j = i; j < 5; j++)\n\t\t\tif (inputArray[j] == inputArray[i])\n\t\t\t\tcmax++;\n\t}\n\t//\u0412 \u0438\u0442\u043e\u0433\u0435 \u0432 moda \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043c\u043e\u0434\u0430, \u0430 \u0432 rmax \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043e\u043d\u0430 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f\n\n\tint temp_i1 = 0, temp_i2 = 0;\n\tfor (int i = 0; i < 5; i++)\n\t{\n\t\tif (inputArray[i] != moda && temp_i1 == 0)\n\t\t\ttemp_i1 = i;\n\t\telse if (inputArray[i] != moda)\n\t\t\ttemp_i2 = i;\n\t\telse if (temp_i1 * temp_i2 != 0)\n\t\t\tbreak;\n\t}\n\n\tif (inputArray[temp_i1] > inputArray[temp_i2])\n\t{\n\t\ttemp = inputArray[temp_i1];\n\t\tinputArray[temp_i1] -= (temp - inputArray[temp_i2]) / 2;\n\t\tinputArray[temp_i2] += (temp - inputArray[temp_i2]) / 2;\n\t}\n\telse\n\t{\n\t\ttemp = inputArray[temp_i2];\n\t\tinputArray[temp_i2] -= (temp - inputArray[temp_i1]) / 2;\n\t\tinputArray[temp_i1] += (temp - inputArray[temp_i1]) / 2;\n\t}\n\n\tif (inputArray[0] == inputArray[1] && inputArray[1] == inputArray[2] && inputArray[2] == inputArray[3] && inputArray[3] == inputArray[4])\n\t\tstd::cout << inputArray[0];\n\telse\n\t\tstd::cout << -1;\n\tstd::cin >> temp;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c5392b17da4dba07f2ee9449f796ffbb", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20", "difficulty": 1100.0} {"lang": "GNU C++0x", "source_code": "#include \nusing namespace std;\nint ar[10];\nint main(){\n int n=5,sum=0;\n for(int i=0; i>ar[i];\n sum=sum+ar[i];\n }\n if(sum%5==0 && sum!=0)cout<\n\nusing namespace std;\nint getcol(char c){\n if(c=='B')return 0;\n if(c=='R')return 1;\n if(c=='G')return 2;\n if(c=='Y')return 3;\n if(c=='W')return 4;\n}\nint getval(char c){\n return c-'1';\n}\n\nchar str[1111][5];\nint main()\n{\n int n;\n\n cin>>n;\n int ans=10;\n for(int i=0;i>str[i];\n //cout<\n#include \n#include \n\nusing namespace std;\n\nconst int N = 103;\nint n, cnt[7][7], tmp[7][7];\n\nint f_min(int a, int b) {return a < b ? a : b;}\n\nint get(char ch) {\n if(ch >= '1' && ch <= '5')\n return ch - '1';\n if(ch == 'R') return 0;\n if(ch == 'G') return 1;\n if(ch == 'B') return 2;\n if(ch == 'Y') return 3;\n return 4;\n}\n\nvoid get_data() {\n char cd[3];\n cin >> n;\n memset(cnt, 0, sizeof(cnt));\n for(int i = 0; i < n; ++i) {\n cin >> cd;\n cnt[get(cd[0])][get(cd[1])]++;\n }\n}\n\nbool check(int x) {\n int i, j, k, t, tt;\n memset(tmp, 0, sizeof(tmp));\n for(k = 0; k < 10; ++k) {\n if(x & (1 << k)) {\n if(k < 5) {\n i = k;\n for(j = 0; j < 5; ++j) {\n if(cnt[i][j]) {\n if(tmp[i][j] == 0) tmp[i][j] = 1;// color\n else tmp[i][j] = 3;// all\n }\n }\n }\n else {\n j = k - 5;\n for(i = 0; i < 5; ++i) {\n if(cnt[i][j]) {\n if(tmp[i][j] == 0) tmp[i][j] = 2;// number\n else tmp[i][j] = 3;// all\n }\n }\n }\n }\n }\n for(i = 0; i < 5; ++i) {\n for(j = t = tt = 0; j < 5; ++j) {\n if(cnt[i][j]) {\n if(tmp[i][j] == 1) tt++;\n if(tmp[i][j] == 0) t++;\n }\n }\n if(tt > 1 || t > 1) return false;\n }\n for(j = 0; j < 5; ++j) {\n for(i = t = tt = 0; i < 5; ++i) {\n if(cnt[i][j]) {\n if(tmp[i][j] == 2) tt++;\n if(tmp[i][j] == 0) t++;\n }\n }\n if(tt > 1 || t > 1) return false;\n }\n return true;\n}\n\nint count(int x) {\n int res = 0;\n while(x) {\n if(x & 1) res++;\n x >>= 1;\n }\n return res;\n}\n\nvoid solve() {\n int i, ans = 10000000;\n for(i = 0; i < 1024; ++i) {\n if(check(i)) ans = f_min(ans, count(i));\n }\n cout << ans << endl;\n}\n\nint main() {\n get_data();\n solve();\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bb6f035cbb8b0a707c83e926826a0c8e", "src_uid": "3b12863997b377b47bae43566ec1a63b", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef pair Pii;\ntypedef long long ll;\ntypedef unsigned long long ull;\nconst int INFI = 1<<28;\nconst long long int INFL = 1LL<<60;\nconst double INFD = 1e+300;\nconst double EPS = 1e-8;\n//\u2192 \u2191 \u2190 \u2193\n//int dx[] = {1,0,-1,0};\n//int dy[] = {0,-1,0,1};\n//struct P { \n// int id, cost; \n// P () {}\n// P (int i, int c) : id(i), cost(c) {}\n// bool operator < (const P &p) const { return cost > p.cost; } \n//};\n\n\nbool f (const vector & cards, const vector & hand) {\n int L = cards.size();\n vector h_used(L, false);\n vector c_used(L, false);\n int cnt = 0;\n while (true) {\n bool update = false;\n for (int i = 0; i < L; i++) {\n if (h_used[i]) continue;\n set candidate;\n int idx = 0;\n for (int j = 0; j < L; j++) {\n if (c_used[j]) continue;\n if ((hand[i][0] == '*' || hand[i][0] == cards[j][0]) &&\n (hand[i][1] == '*' || hand[i][1] == cards[j][1])) {\n candidate.insert(cards[j]);\n idx = j;\n break;\n }\n }\n if (candidate.size() == 1) {\n update = true;\n c_used[idx] = true;\n h_used[i] = true;\n cnt++;\n break;\n }\n\n }\n if (!update) break;\n }\n return cnt == L;\n}\nint main(){\n //freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n int L;\n cin >> L;\n vector cards(L);\n for (int i = 0; i < L; i++) {\n cin >> cards[i];\n }\n const char *M = \"RGBYW\";\n const char *N = \"12345\";\n int ans = 1<<28;\n for (int m = 0; m < (1<<5); m++) {\n for (int n = 0; n < (1<<5); n++) {\n vector tmp(L, string(\"**\"));\n for (int i = 0; i < L; i++) {\n for (int j = 0; j < 5; j++) {\n if ((m & (1<\n#include \n#include \n\nusing namespace std;\nconst int N = 105;\n\nint n, l[N], r[N];\n\ninline int cal (char ch) {\n if (ch == 'B')\n return 0;\n else if (ch == 'Y')\n return 1;\n else if (ch == 'W')\n return 2;\n else if (ch == 'G')\n return 3;\n else if (ch == 'R')\n return 4;\n return -1;\n}\n\nint bit (int i) {\n return 1<= ans)\n continue;\n\n if (judge(i))\n ans = cnt;\n }\n printf(\"%d\\n\", ans);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c5da7329d068b9619e3e82aca0068fc9", "src_uid": "3b12863997b377b47bae43566ec1a63b", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n\n#include \n\nusing namespace std;\n\ntypedef long long ll;\n#define tc(x) static_cast(x)\n\nconst int MAXN = 200 + 10;\nconst int MAXM = 200 + 10;\n\nint N, M;\nll K, t;\n\nint z[MAXM];\nint As[MAXM][2];\nll v[MAXM][MAXM];\nint Af[MAXM][MAXM];\nvoid build(const string& s, bool output = false) {\n z[0] = 0;\n for(int i = 1;i < s.size();i++) {\n z[i] = z[i - 1];\n while(z[i] != 0 and s[i] != s[z[i]]) z[i] = z[z[i] - 1];\n if(s[z[i]] == s[i]) z[i]++;\n }\n //for(int i = 0;i < s.size();i++) printf(\"%d\\n\", z[i]);\n for(int i = 0;i <= s.size();i++) {\n for(int j = 0;j < 2;j++) {\n As[i][j] = i;\n while(As[i][j] != 0 and tc(j + 48) != s[As[i][j]]) As[i][j] = z[As[i][j] - 1];\n if(s[As[i][j]] == tc(j + 48)) As[i][j]++;\n }\n }\n //for(int i = 0;i <= s.size();i++) printf(\"%d: %d %d\\n\", i, As[i][0], As[i][1]);\n for(int i = 0;i <= 1;i++) {\n for(int j = 0;j <= s.size();j++) {\n Af[i][j] = As[j][i];\n if(Af[i][j] == s.size()) v[i][j] = 1; else v[i][j] = 0;\n }\n }\n for(int i = 2;i <= N;i++) {\n for(int j = 0;j <= s.size();j++) {\n Af[i][j] = Af[i - 1][Af[i - 2][j]];\n v[i][j] = v[i - 2][j] + v[i - 1][Af[i - 2][j]];\n }\n }\n if(output) for(int i = 0;i <= N;i++, printf(\"\\n\")) for(int j = 0;j <= s.size();j++) printf(\"%lld \", static_cast(v[i][j]));\n}\n\nint main() {\n scanf(\"%d%lld%d\", &N, &K, &M); //reduce K to 1\n \n string ans = \"\";\n for(int i = 0;i < M;i++) {\n if(i) {\n build(ans);\n if(Af[N][0] == i) {\n assert(K >= 1);\n if(K == 1) break;\n else K--;\n }\n }\n \n build(ans + '0');\n \n if(K > v[N][0]) {\n K -= v[N][0];\n ans += '1';\n } else ans += '0';\n \n //cerr << i << \" \" << K << \"\\n\";\n }\n printf(\"%s\\n\", ans.c_str());\n \n //build(\"10\", true);\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "230d4c9856ce3cfeddb09b86975dbcc1", "src_uid": "7b4a057efee5264bfaaf60d50fccb92b", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include\n#include\nusing namespace std;\nint COUNT_KMP(const char *S, const char *T, int s_len, int t_len){\n int next[t_len];\n next[0] = -1;\n for (int i = 1; i= 0 && T[i - 1] != T[j]) j = next[j];\n if (j >= 0 && T[i - 1] == T[j]) next[i] = j + 1;\n else next[i] = 0;\n }\n int index, count = 0;\n for (index = 0; index max_len) {\n\t\t\tstart = len[i-2] - max_len;\n\t\t}\n\t\tint my_len = my_substr (tmp_str,f[i-2],start,max_len);\n\t\tmy_len += my_substr (tmp_str+my_len,f[i-1],0,max_len);\n\n\t\tlong long result = COUNT_KMP (tmp_str,s,my_len,s_len);\n\t\t\n\t\tsum[i] = sum[i-2] + sum[i-1] + result;\n\t\tif (sum[i] > k) {\n\t\t\treturn sum[i];\n\t\t}\n\t\t\n\t\tif (len[i] > max_len * 2) { \n\t\t\tint del_num = len[i] - (max_len * 2);\n\t\t\tfor (int pos=max_len + del_num;pos>n>>k>>m;\n\tchar s[100000];\n\tmemset (s,'\\0',sizeof(s));\n\tfor (int i = 0; i < m; ++i) {\n\t\tint pos = suffix_len - i;\n\t\tint s_pos = 0;\n\t\twhile (pos < suffix_len) {\n\t\t\tif (s[s_pos] != suffix[pos]) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\ts_pos++;\n\t\t\tpos++;\n\t\t}\n\t\tif (pos == suffix_len && i>0) {\n\t\t\tif (k == 1) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tk --;\n\t\t}\n\n\t\tif (i >0 && s[i-1] == '0') {\n\t\t\ts[i] = '1';\n\t\t\ts[i+1] = '\\0';\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (i > 1 && s[i-1] == '1' && s[i-2] == '1') {\n\t\t\ts[i] = '0';\n\t\t\ts[i+1] = '\\0';\n\t\t\tcontinue;\n\t\t}\n\n\t\t\n\t\ts[i] = '0';\n\t\ts[i+1] = '\\0';\n\n\t\tlong long count = cal (s,n,k);\n\t\tif (count < k) {\n\t\t\tk = k - count;\n\t\t\ts[i] = '1';\n\t\t}\n\t\t\n\t}\n\tcout<\n#define int long long\nusing namespace std;\nint n,m,k,tmp[509];\nstring ret,Fib[15];\ninline bool is_pre(int f_pos,string&s,int s_start,unsigned cmp_len){\n\tif(f_pos>14)f_pos=12|(f_pos&1);\n\treturn cmp_len<=Fib[f_pos].size()&&Fib[f_pos].substr(0,cmp_len)==s.substr(s_start,cmp_len);\n}\ninline bool is_suf(int f_pos,string&s,int s_start,unsigned cmp_len){\n\tif(f_pos>14)f_pos=14;\n\treturn cmp_len<=Fib[f_pos].size()&&Fib[f_pos].substr(Fib[f_pos].size()-cmp_len)==s.substr(s_start,cmp_len);\n}\nsigned main(){\n\tFib[0]=\"0\",Fib[1]=\"1\";\n\tfor(int i=2;i<=14;++i)Fib[i]=Fib[i-2]+Fib[i-1];\n\tscanf(\"%lld%lld%lld\",&n,&k,&m);\n\tfor(int i=1;i<=m;++i){\n\t\tint Tag=(i==1?0:is_suf(n,ret,0,ret.size()));\n\t\tif(k<=Tag)return puts(ret.c_str()),0;\n\t\tint cnt=Tag+({\n\t\t\tstring test0=ret+'0';\n\t\t\ttmp[0]=(test0==\"0\"),tmp[1]=(test0==\"1\");\n\t\t\tunsigned len=test0.size();\n\t\t\tfor(int i=2;i<=n;++i){\n\t\t\t\ttmp[i]=tmp[i-1]+tmp[i-2];\n\t\t\t\tfor(unsigned j=1;j=k){\n\t\t\t\t tmp[n]=k;\n\t\t\t\t break;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn tmp[n];\n\t\t});\n\t\tif(k<=cnt){\n\t\t\tk-=Tag;\n\t\t\tret+='0';\n\t\t}\n\t\telse{\n\t\t\tk-=cnt;\n\t\t\tret+='1';\n\t\t}\n\t}\n\tputs(ret.c_str());\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6cb74e8173e0cedf720b8188616ba5e7", "src_uid": "7b4a057efee5264bfaaf60d50fccb92b", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include\n#define ll long long\n\nusing namespace std;\nconst int N=210;\nint n,m;\nll k,f[N],d[N],h[N],qy[2][2];\nstring pre[2],nxt[2],str[17],suf[N*10],ans;\n\ninline bool cmp(string a,string b){\n for(int i=0;i=a.length()) break;\n bool flag=1;\n for(int j=0;j1e18) return f[i];\n }\n return f[n];\n}\n\nint main(){\n scanf(\"%d%lld%d\",&n,&k,&m);\n str[0]=\"0\"; str[1]=\"1\";\n for(int i=2;i<=15;i++) str[i]=str[i-2]+str[i-1];\n if(n<=15){\n for(int i=0;i\n#include\n#include\nusing namespace std;\n\nlong long cal(long long w,long long m,long long k)\n{\n\tlong long sum = 0;\n\tlong long c,x,j;\n\tc = 0,x = m,j = 1;\n\twhile(x)\n\t{\n\t\tx /= 10;\n\t\tc++,j *= 10;\n\t}\n\twhile(1)\n\t{\n\t\tlong long rest = j - m;\n\t\t//cout << \"rest: \" << rest << endl;\n\t\t//cout << \"w: \" << w << endl;\n\t\tif(rest * k * c <= w)\n\t\t{\n\t\t\tsum += rest;\n\t\t\tw -= rest * k * c;\n\t\t\tm = j;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tsum += w / (k * c);\n\t\t\tbreak;\n\t\t}\n\t\tj *= 10,c++;\n\t}\n\treturn sum;\n}\n\nint main()\n{\n\tlong long w,m,k;\n\twhile(cin >> w >> m >> k)\n\t\tcout << cal(w,m,k) << endl;\n\treturn 0;\n}\n*/\n\n#include\n#include\n#include\nusing namespace std;\n\nstruct Num\n{\n\tint id;\n\tint sum;\n}num[10];\n\nbool check(int k,string str[])\n{\n\tbool flag = true;\n\tint sum[10] = {0},t;\n\tfor(int i = 0;i < 4;i++)\n\t\tfor(int j = 0;j < 4;j++)\n\t\t\tif(str[i][j] != '.')\n\t\t\t\tsum[str[i][j] - '0']++;\n\tt = 0;\n\tfor(int i = 0;i < 10;i++)\n\t\tif(sum[i])\n\t\t{\n\t\t\tnum[t].id = i,num[t].sum = sum[i];\n\t\t\tt++;\n\t\t}\n\tint step = 1;\n\tfor(int i = 0;i < t;i++,step++)\n\t{\n\t\tif(!num[i].sum)\n\t\t\tcontinue;\n\t\tif(k * 2 >= num[i].sum)\n\t\t{\n\t\t\tint tmp,j;\n\t\t\ttmp = 2 * k,j = i;\n\t\t\twhile(tmp && j < t)\n\t\t\t{\n\t\t\t\tif(tmp >= num[j].sum)\n\t\t\t\t{\n\t\t\t\t\ttmp -= num[j].sum;\n\t\t\t\t\tnum[j].sum = 0;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\tnum[j].sum -= tmp;\n\t\t\t\tj++;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tflag = false;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn flag;\n}\n\nint main()\n{\n\tint k;\n\tstring str[4];\n\twhile(cin >> k)\n\t{\n\t\tfor(int i = 0;i < 4;i++)\n\t\t\tcin >> str[i];\n\t\tputs(check(k,str) ? \"YES\" : \"NO\");\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "01706c4e5e7183c640165a484f553f96", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n\n/*sorting array\n int n ;\n cin>>n;\n int a[1009];\n\n for(int f=0;f>a[f];\n\n }\n\n for(int i=0;i>n>>k;\n\nint a[1009];\nint counter=0;\n\nfor(int i=0;i>a[i];\n}\n\nfor(int i=0;i>x;\n\nif((x>='A'&&x<='Z')|| (x>='a'&&x<='z')){cout<>n;\ncin>>m;\nint x=m-1;\n\nif(m>n){\n\n while(x!=1){\n if(m%x!=0){\n x--;\n }else{\n cout <<\"no\";\n return 0;\n }\n }\n cout<< m ;\n\n}else{\n\n cout<< false;\n\n}\n-------------------------------------------------------------------------------------------------------------*/\n/*ms2la bnshof e7na bnd5l rkm awly w nnd5l kman rkm w nshof el rkm da howa akrb rkm awly le awl rkm e7na d5lnah wla l2 gw ah bnktb yes lw l2 bnktb no\nint n,m;\ncin>>n;\ncin>>m;\nint f=m;\nint c=f-1;\nint result=0;\n\nwhile(c>1){\n if(f%c==0){\n cout<<\"no\";\n return 0;\n }\n else{\n c=c-1;\n }\n}\n\nc=m-1;\nresult=0;\nif(m>n){\n\n while(c>0 && m>n){\n if(m%c==0&&c!=1){\n m=m-1;\n c=m-1;\n }\n else if(m%c==0&&c==1){\n m=m-1;\n c=m-1;\n result++;\n\n }\n\n else{\n c=c-1;\n\n }\n }\n\n}\nif(result>1){\n cout<<\"no\";\n}\n\nelse{\n cout<<\"yes\";\n}\n*/\n\n/*\n--------------------------------------------------------------------\nint a[200];\nint n,g;\nint def[100];\nint counter = 0;\ncin>> n ;\n\nfor(int i =0 ; i> a[i];\n\n}\n\nfor(int i=0 ; i0){\n def[i]=def[i];\n }\n\n else{\n def[i]=def[i]*(-1);\n\n }\n g=def[i];\n cout<> n ;\ncin>> m ;\nif(n<=0 || m<=0){\n\n cout<<\"yes\";\n return 0;\n\n}\n\n\nint a[100];\n\nfor(int i = 0 ; i>num;\n\nif(num<=m ||num>=0){\n\nfor(int i = 0 ; i>x;\n if(x<=m){\n a[x]=x;\n }\n else{cout<<\"NO\";return 0;}\n}}\nelse{cout<<\"NO\";return 0;}\n}\n\nint z=0;\n\nfor(int i = 1 ; i> n ;\nif(n%3!=0){cout<<\"-1\";return 0;}\nfor(int i = 0 ; i>a[i];\n\n}\n\nint b[100][100];\n\nx=0;\n\nfor(int i = 0 ; i < n/3 ; i++){\n for(int j =0 ; j < 3 ; j++){\nx=0;\n while(j=0){\n if(a[x]==1){\n b[i][j]=a[x];\n a[x]=0;\n break;\n }\n else{x++;}\n if(x=n+1){cout<<\"-1\";return 0;}\n }\n\n x=0;\n\n while(j=1){\n if(a[x]==2 || a[x]==3){\n b[i][j]=a[x];\n a[x]=0;\n break;\n }\n else{x++;}\n if(x=n+1){cout<<\"-2\";return 0;}\n }\n\n x=0;\n\n while(j=2){\n if( (b[i][j-1]==2 && a[x]==4) || (b[i][j-1]==2 && a[x]==6) || (b[i][j-1]==3 && a[x]==6) ){\n b[i][j]=a[x];\n a[x]=0;\n break;\n }\n else{x++;}\n\n if(x=n+1){cout<<\"-3\";return 0;}\n }\n x=0;\n }\n}\n\n\nfor(int i = 0 ; i < (n/3) ; i++){\n for(int j =0 ; j < 3 ; j++){\n cout<> n ;\ncin>> d ;\n\n for(int i=0 ; i>a[i];\n\n }\n\n int e;\n\n for(int i = 0 ; ia[j]){\n e=a[i];\n a[i]=a[j];\n a[j]=e;\n }\n }\n }\n\n\n\ncin>> num ;\nsum = 0 ;\n\nif(num>n){\n\nz = (num-n)*d ;\nfor(int i = 0 ; i> n ;\nn = n+n ;\n\nfor(int i = 0 ; i<16 ; i++ ){\n\n cin>> a[i];\n}\n\n\nfor(int i = 0 ; i<16 ; i++){\n counter = 1 ;\n for(int j = i+1 ; j<16 ; j++){\n\n if(a[i] == a[j] && a[i]!='.'){\n\n counter++;\n }\n if(counter>n){\n cout<< \"NO\" ;\n return 0 ;\n }\n }\n}\n\ncout<< \"YES\" ;\n\n\n\n*/\n\n\n\n\n\nchar a[1000];\nint n ;\ncin >> n ;\nn = n+n;\n\nfor(int i = 0 ; i<16 ; i++ ){\n\n cin>> a[i];\n}\n\n\ncounter = 1 ;\n\nfor(int i = 0 ; i<15 ; i++){\n counter = 1;\n for(int j = i+1 ; j<16 ; j++){\n \n if(a[i]=='.'){break;}\n \n if(a[i]==a[j]){counter++;}\n\n }\n if(counter>n){cout << \"No\" ;return 0;}\n\n}\n\ncout << \"YES\" ;\n\n\n\n return 0;\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d09989ad40ea5d3ee1ac9edbd1098891", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include \"pch.h\"\n#include \n#include \n#include \n#include \nusing namespace std;\n\nint main()\n\n{\n\tint k;\n\tcin >> k;\n\tvector a;\n\tfor (int i = 0; i < 9; i++) {\n\t\ta.push_back(0);\n\t}\n\tfor (int i = 0; i < 4; i++) {\n\t\tstring x;\n\t\tcin >> x;\n\t\tfor (int j = 0; j < 4; j++) {\n\t\t\tif (x[j] != '.') {\n\t\t\t\tint y = static_cast(x[j]) - 48;\n\t\t\t\ta[y - 1] ++;\n\t\t\t}\n\t\t}\n\t}\n\tint m = a[0];\n\tfor (int i = 1; i < 9; i++) {\n\t\tif (a[i] > m) {\n\t\t\tm = a[i];\n\t\t}\n\t}\n\tif (m > 2 * k) {\n\t\tcout << \"NO\";\n\t}\n\telse {\n\t\tcout << \"YES\";\n\t}\n\t\n\treturn 0;\n}\n/* Mon Aug 12 2019 22:04:03 GMT+0300 (MSK) */\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4324302b38d5cf547c2fbba28cf19807", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n int num1(int a[20],int sized)\n{\n int l=0;\n for(int i=0;i>k;\n for(int i=0;i<4;i++)\n for(int j=0;j<4;j++)\n {\n cin>>s;\n if(s!='.') {a[z]=int(s);z++;}\n\n }\n if(z<=2*k) {cout<<\"YES\";return 0;}\n else\n {for(int j=0;j\n\nint main()\n{\n\n int n,k,max,min;\n std::cin>>n>k;\n\n if(n=k)\n {min=max=0;}\n\nif (k=0)\n {min=max=0;\n goto label;}\n\nif (n>k)\n{\n if (k>=(n/2))\n { max=n-k;\n min=1; }\n\t\n if (k\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \nusing namespace std;\n \n#define pb push_back\n#define sz(a) (int)a.size()\n#define vi vector \n#define mp make_pair\n#define all(x) (x).begin(), (x).end()\n#define forn(i, n) for(int i = 0; i < n; ++i)\n#define F first\n#define S second\n \ntypedef long long int;\n// typedef pair pll;\ntypedef pair pii;\n \n// const ll inf = 1e9;\nconst double eps = 1e-9;\nconst double pi = acos(-1.0);\nconst int SZ = 55555;\n\nint get1(int n, int k) {\n\tint l = -1, r = k;\n\twhile (r - l > 1) {\n\t\tint mid = (r + l)/2;\n\t\tif ((n - mid) >= 2*(k - mid))\n\t\t\tr = mid;\n\t\telse\n\t\t\tl = mid;\n\t}\n\treturn r;\n}\nint get2(int n, int k) {\n\tint l = -1, r = k;\n\twhile (r - l > 1) {\n\t\tint mid = (r + l)/2;\n\t\tif ((n - 2*mid - 1) >= 3*(k - mid))\n\t\t\tr = mid;\n\t\telse\n\t\t\tl = mid;\n\t}\n\treturn r;\n}\n\nint solve() {\t\n\tint n, k, ans = 0;\n\tcin >> n >> k;\n\tint diff = get1(n, k);\n\tn -= diff;\n\tk-= diff;\n\tint diff2 = get2(n, k);\n\tans += diff2;\n\tn -= 2*diff2 - 1;\n\tans += (2*(n/3) + (n % 3 == 1 ? 0 : 1));\n\tcout << 1 << \" \"<< ans << endl;\n}\n\nint main() {\n\tios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); \n\n\t// int t;\n\t// cin >> t;\n\t// while (t--) {\n\t\tsolve();\n\t// }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7fee4e4093214cce729f9e3d73613096", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main()\n{\n int n,k;\n cin>>n>>k;\n\n if(k==0 || n==k)\n {\n cout<<0<<\" \";\n }\n else\n {\n cout<<1<<\" \";\n }\n\n if(n%3==0)\n {\n int p=n/3;\n if(p<=k)\n {\n cout<<((2*p)-(k-p));\n }\n else\n {\n cout<<(2*k)\n }\n }\n else if(n%3==1)\n {\n int p=n/3;\n if(p<=k)\n {\n cout<<((2*p)-(k-p)+1);\n }\n else\n {\n cout<<(2*k);\n }\n }\n }\n else\n {\n int p=ceil(double(n)/3);\n if(p<=k)\n {\n cout<<((2*k+1)-(k-p));\n }\n else\n {\n cout<<((k*2));\n }\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5675b38e339e685996cb4e7907a7dc8b", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nint main()\n{\n long long int n,k;\n cin>>n>>k;\n if(n==k)\n {\n cout<<0<<\" \"<<0<=((n/2)-1)\n {\n cout<<1<<\" \"< \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std; \n* \nbool arr[N]; \nvoid getprim(){ arr[0]=1;arr[1]=1;int i;long long j;for(i=2;id || (ans>a))\n\t\t{\n\t\t\tprintf(\"Ron\\n\");\n\t\t}\n\t\telse printf(\"Hermione\");\n\t}\n\treturn 0;\n}\n////100 10 200 20 300 30\n//#include \n//using namespace std;\n//typedef long long ll;\n//int main(){ ll a,b,c,d,e,f; cin>>a>>b>>c>>d>>e>>f; cout<<(b*d*f > a*c*e || (d && (!c || (!a && b))) ? \"Ron\" : \"Hermione\")<<'\\n';}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "16e300ca40aca4843b84015522ed8f4a", "src_uid": "44d608de3e1447f89070e707ba550150", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n\nusing namespace std;\n\nlong long gcd(long long a,long long b){\n if(b==0)return a;\n else {\n long long ret;\n assert(ret=gcd(b,a%b));\n return ret;\n }\n}\n\nlong long lcm(long long a,long long b){\n return a/gcd(a,b)*b;\n}\n\nint main(){\n\n long long a,b,c,d,e,f;\n cin >> a >> b >> c >> d >> e >> f;\n\n if(b==0||d==0||f==0){\n puts(\"Hermione\"); return 0;\n }else if(c==0||e==0||a==0){\n puts(\"Ron\"); return 0;\n }\n\n long long aa,bb;\n aa=lcm(b,c)) \n bb=lcm(d,e);\n long long p22=bb/d,p21=bb/e,p2=lcm(p21,p22);\n long long p1=p2*c/b,p3=p2*d/e;\n\n /*\n prlong longf(\"%d %d : %d\\n\",p1*a,p1*b,p1);\n prlong longf(\"%d %d : %d\\n\",p2*c,p2*d,p2);\n prlong longf(\"%d %d : %d\\n\",p3*e,p3*f,p3);\n */\n long long make_d;\n assert(make_d=(p2*c)/(p1*b)*(p2*d));\n long long ans;\n assert(ans=make_d/(p3*e)*(p3*f));\n\n if(ans>p1*a)puts(\"Ron\");\n else puts(\"Hermione\");\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "62bac39e7d40f8c64dbd442bbf4821e1", "src_uid": "44d608de3e1447f89070e707ba550150", "difficulty": 1800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\nint main()\n{\n\tdouble a,b,c,d,e,f;\n\tcin>>a>>b>>c>>d>>e>>f;\n\tdouble last=a;\n\t\n\tif(a==0)\n\t{\n\t\ta=0.000001;\n\t}\n\tif(c==0)\n\t{\n\t\tc=0.000001;\n\t}\n\tif(e==0)\n\t{\n\t\te=0.000001;\n\t}\n\tif(d/c>100000) \n\t{ \n\t\tcout<<\"Ron\";\n\t\treturn 0; \n\t} \n\telse if\n\tif(b*d/c/a>100000) \n\t{ \n\t\tcout<<\"Ron\";\n\t\treturn 0; \n\t} \n\tlast=b*d*f/c/a/e;\n\tif(last>a)\n\t{\n\t\tcout<<\"Ron\";\n\t}\n\telse\n\t{\n\t\tcout<<\"Hermione\";\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "227fe00772ec34e24edefb9e7c87b8c2", "src_uid": "44d608de3e1447f89070e707ba550150", "difficulty": 1800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\n#define pb push_back\n#define pob pop_back\n#define st first\n#define nd second\n#define test printf(\"test\\n\");\n#define endll printf(\"\\n\")\n#define mp make_pair\n#define sol (node*2)\n#define sag ((node*2)*1)\n#define orta (bas+son)/2\n#define eps 1e-6\n\ntypedef long long ll;\ntypedef long long int lli;\ntypedef long long unsigned llu;\ntypedef pair < int,int > pii;\ntypedef pair < ll,lli > plli;\n\nll INF = 1e9;\nconst int MAX = 1e5+7, N=1e5+3;\ndouble pi = cos(-1);\nint r,l,k,m,n;\n\n//-------------END OF DRAFT-------------\n\nint main() {\n\tdouble a,b,c,d,e,f;\n\tcin>>a>>b>>c>>d>>e>>f;\n\t//cout< 1) cout<\n#ifdef LOCAL\n#include \"debug.h\"\n#else\n#define deb(...) 0\n#define debug() 0\n#endif\nusing namespace std;\n#define df(b, e) ((b) > (e))\n#define fore(i, b, e) \\\n for (__typeof(e) i = (b)-df(b, e); i != e - df(b, e); i += 1 - 2 * df(b, e))\n#define sz(x) (int)x.size()\n#define all(x) x.begin(), x.end()\n#define f first\n#define s second\n#define pb push_back\ntypedef long long lli;\ntypedef long double ld;\ntypedef pair ii;\n\nconst int N = 16;\nconst int T = 226;\nconst int G = 3;\nconst int mod = 1e9 + 7;\n\nint mem[N][T][1 << N];\nint done[N][T][1 << N];\nint t[N], g[N];\nint n, len;\n\n\nint dp(int i, int maxTime, int mask) {\n if (maxTime < 0)\n return 0;\n if (maxTime == 0) {\n debug() << deb(i) << deb(maxTime) << deb(mask);\n return 1;\n }\n\n int &ans = mem[i][maxTime][mask];\n if (!done[i][maxTime][mask]) {\n ans = 0;\n done[i][maxTime][mask] = 1;\n fore (j, 0, n) {\n if (!((mask >> j) & 1) && g[i] != g[j]) {\n ans += dp(j, maxTime - t[j], mask | (1 << j));\n ans %= mod;\n }\n }\n }\n return ans;\n}\n\nint main() {\n ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n cin >> n >> len;\n fore(i, 0, n) cin >> t[i] >> g[i];\n g[n] = 5;\n int sum = dp(n, len, 0);\n cout << sum << '\\n';\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c263354aa57f9222cbb80422b3222688", "src_uid": "ac2a37ff4c7e89a345b189e4891bbf56", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "//1\n#include \nusing namespace std;\n#pragma GCC optimize(\"O3\")\n#pragma GCC target(\"sse4\")\n#define int long long int\n#define ld long double\n#define pb push_back\n#define F first\n#define S second\n#define MOD 1000000007\n#define mod1 1187278649\n#define mod2 1149736019\n#define ioi cout<<\"\\n------------ioi------------\\n\"\n#define all(x) (x).begin(),(x).end()\n#define sz(x) (int)(x).size()\n\nconst ld PI=3.14159265358979323;\nlint linf=(lint)2e18;\nconst int inf=1011111111;\nconst int N = 40000;\n// global variables...\nint n, t, nx;\nint dp[40000][4];\nvector pow2;\nvector < pair > vec1;\n\n//functions...\nvoid input(){\n\tvec1.clear();\n\tmemset(dp, 0, sizeof dp);\n cin>>n>>t;\n // vec1.pb({0, 4});\n \tfor(int i=0;i>q1>>q2;\n \t\tvec1.pb({q1, q2});\n \t}\n}\n\nint32_t main()\n{\n // #ifndef ONLINE_JUDGE\n // freopen(\"inputf.txt\", \"r\", stdin);\n // freopen(\"outputf.txt\", \"w\", stdout);\n // #endif\n \n ios::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n int q1 = 1;\n for(int i=0;i<=20;i++){\n \tpow2.pb(q1);\n \tq1*=2;\n }\n int test=1;\n // cin>>test;\n while(test--){\n input();\n nx = pow2[n];\n // cout< // This will work only for g++ compiler. \n\n\n#define loop(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)\n#define floop(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)\n#define rloop(i, l, r) for (int i = (int)(l); i >= (int)(r); --i)\n\n//short hand for usual tokens\n#define pb push_back\n\n// to be used with algorithms that processes a container Eg: find(all(c),42)\n#define all(x) (x).begin(), (x).end() //Forward traversal\n#define rall(x) (x).rbegin, (x).rend() //reverse traversal\n\n// traversal function to avoid long template definition. Now with C++11 auto alleviates the pain.\n#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)\n\nusing namespace std;\n\n// Shorthand for commonly used types\ntypedef vector vi;\ntypedef vector vvi;\ntypedef pair ii;\ntypedef vector vii;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef vector vll;\ntypedef vector vvll;\ntypedef double ld;\n\nint n,t;\nint id[16];\nint tm[226];\nint dp[16][1<<15];\n\nll fact(ll n) {\n if (n==1) return 1;\n else return n*fact(n-1);\n}\n\n// ll solve(int n,int mask) {\n// // cout<0) {\n// if (tmp&1) {\n// len += tm[count]; \n// }\n// count++;\n// tmp/=2;\n// }\n// if (len==t) {\n// return fact(__builtin_popcount(mask));\n// }\n// if (n==0) {\n// return 0;\n// }\n// if (dp[n][mask] != -1) {\n// return dp[n][mask];\n// }\n// ll ans = solve(n-1,mask);\n// // loop(i,0,n) {\n// // if (len + tm[n] <=t && !(mask & 1<0) {\n if (tmp&1) {\n len += tm[count]; \n }\n count++;\n tmp/=2;\n }\n len = t-len;\n if (len == 0 ) {\n return 1;\n }\n\n if (dp[prev][mask] != -1) {\n return dp[prev][mask];\n }\n ll ans = 0;\n floop(i,1,n) {\n if (id[i]!=prev && tm[i]<=len && !(mask & 1<<(i-1)))\n ans += solve1(id[i],mask | (1<<(i-1)));\n }\n return dp[prev][mask] = ans;\n}\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout.precision(10);\n cout << fixed;\n // freopen(\"input.txt\", \"r\", stdin);\n // freopen(\"output.txt\", \"w\", stdout);\n cin>>n>>t;\n floop(i,1,n) {\n cin>>tm[i]>>id[i];\n }\n memset(dp,-1,sizeof(int) *16 * (1<<15));\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n#define ll long long\n#define mod 1000000007\n\nint n, t;\nvector> s;\nll dp[16][16][16][3];\n\nll cal(int c1, int c2, int c3, int last) {\n if (c1 < 0 || c2 < 0 || c3 < 0) return 0;\n\n if (!c1 && !c2 && !c3) {\n return 1;\n }\n\n if (last != -1 && dp[c1][c2][c3][last] != -1) {\n return dp[c1][c2][c3][last];\n }\n\n ll ans = 0;\n\n if (last != 0) {\n ans = (ans + cal(c1 - 1, c2, c3, 0)) % mod;\n }\n\n if (last != 1) {\n ans = (ans + cal(c1, c2 - 1, c3, 1)) % mod;\n }\n\n if (last != 2) {\n ans = (ans + cal(c1, c2, c3 - 1, 2)) % mod;\n }\n\n dp[c1][c2][c3][last] = ans;\n return ans;\n}\n\nint main() {\n cin >> n >> t;\n s.resize(n);\n\n for (auto &p : s) {\n cin >> p.first >> p.second;\n }\n\n wmemset(dp, -1, sizeof(dp));\n vector fact(16);\n fact[0] = fact[1] = 1;\n for (int i = 2; i < 16; i++) {\n fact[i] = fact[i - 1] * i;\n }\n\n ll ans = 0;\n\n vector chosen;\n for (int i = 0; i < (1 << n); i++) {\n chosen.clear();\n for (int j = 0; j < n; j++) {\n if (i & (1 << j)) chosen.push_back(j);\n }\n int sum = 0;\n vector c(3, 0);\n for (auto j : chosen) {\n sum += s[j].first;\n c[s[j].second - 1]++;\n }\n if (sum != t) continue;\n ll r = cal(c[0], c[1], c[2], -1);\n r = r * fact[c[0]] % mod;\n r = r * fact[c[1]] % mod;\n r = r * fact[c[2]] % mod;\n ans = (ans + r) % mod;\n }\n\n cout << ans << \"\\n\";\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b7eebf54546951ece4d8f41212f11607", "src_uid": "ac2a37ff4c7e89a345b189e4891bbf56", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "int main()\n{\n int x,y,z,m=0;\n cin>>x>>y>>z;\n if(1<=x,y,z<=100)\n {\n if(x>=y&&y>=z)\n {\n m+=(x-y)+(y-z);\n cout<=x&&x>=z)\n {\n m+=(y-x)+(x-z);\n cout<=x&&z>=y)\n {\n m+=(z-x)+(z-y);\n cout<=z&&z>=y)\n {\n m+=(x-z)+(z-y);\n cout<\nusing namespace std;\n\nint main(){\n\t\n\t int a,b,c,x,y;\n\t cin>>a>>b>>c;\n\t if(a>=b && a>=c) swap(a,c);\n\t if(b>=a && b>=c) swap(a,c);\n\t \n\t if(c<=b && c<=a) swap(a,c);\n\t if(b<=c && b<=a) swap(b,a);\n\t \n\t \tcout<\n#include\nusing namespace std;\nint main()\n}\n\n\nint x1,x2,x3;\n\n\ncin>>x1>>x2>>x3;\n\nint d1= abs(x1-x2) + abs(x1-x30);\n\nint d2=abs(x2-x1) + abs(x2-x3);\n\nint d3=abs(x3-x1) +abs(x3-x2) ;\n\ncout<\nusing namespace std;\nint main()\n{\nint a(0),b(0),c(0),p,ans;\ncin>>a>>b>>c;\np=(max(a,b,c)+min(a,b,c))/2;\nans=abs(p-a)+abs(p-b)+abs(p-c);\ncout<\n#include\n#include\nusing namespace std;\nint main()\n{\n\t\n\tint a,b,c;\n\tscanf(\"%d%d%d\",&a,&b,&c);\n\tint x, y, z;\n\tx=sqrt((double)(a*c/b));\n\ty=a/x;\n z=b*x/a;\n\tprintf(\"%d\",4*x+4*y+4*z);\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "92795e204b56fbc2e65b575b31e3ccfc", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include\nusing namepsace std;\nint main()\n{\n\tint a,b,c;\n\tcin>>a>>b>>c;\n\tcout<<4*(sqrt(a)+sqrt(b)+sqrt(c));\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "24b499cdd2a329743503d7019386dbc5", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include \nusing namespace std;\nint main()\n{\n\tint x,y,z,a=1,b=1,c=1;\n\tcin>>x>>y>>z;\n\tfor(int i=1;i\n#include\n#include\n#include\n#include \nusing namespace std;\nint main()\n{\n\tint x,y,z,a=1,b=1,c=1;\n\tcin>>x>>y>>z;\n\tfor(int i=1;i\nusing namespace std;\nint a,b,c,s;\nmain(){\n cin>>a>>b>>c;\n s=sqrt(a*a+b*b+c*c); \n cout<<4*(s/a+s/b+s/c);\n}\n \n ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f8e1ca35ad59519b450a6c2a80fe369a", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nconst int maxn=5e5+1000;\nint a[maxn];\nint main()\n{\n\tint n,m,k;\n\tcin>>n>>m>>k;\n\tkk=k;\n\tk=(k%2)?k/2+1:k/2;\n\tint p,q;\n\tp=(k%m==0)?(k/m):(k/m+1);\n\tq=(k%m==0)?m:(k%m);\n\tcout<\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint a[20000][20000];\nint main()\n{\n int n,m,k,b=1,f=0;\n cin>>n>>m>>k;\n int x,y;\n for(int i=0; i\n\nusing namespace std;\n\nint main()\n{\n\tint n, m, k, buff = 0;\n\t\tcin >> n >> m >> k;\n\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tfor (int j = 0; j < m; j++)\n\t\t{\n\t\t\tbuff++;\n\t\t\tif (buff == k) {\n\t\t\t\tcout << i + 1 << \" \" << j + 1 << \" L\" << endl;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbuff++;\n\t\t\tif (buff == k) {\n\t\t\t\tcout << i + 1 << \" \" << j + 1 << \" R\" << endl;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (buff == k) break;\n\t}\n\treturn 0;", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0e73a6d6fd8723ca7e0c9c86be1af8c0", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n\tint n,m; long long k;\n\t\n\tcin >>n >> m >> k;\n\t\n\tchar c = k & 1 ? 'L' : 'R';\n\t\n\tk = (k + 1) >> 1;\n\t\n\tcout << (k - 1) / m + 1 << \"\\n\" << !(k % m) ? m : (k % m) << \"\\n\" << c;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "57246950a1e0e0cf232722332192b69e", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n\nint main(){\n\tlong long int x,i;\n\tcin >> x;\n\ti=sqrt(x); \n\twhile(x%i){ i--; }\n\t\tcout << i<< \" \"<< (x/i);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ac832a64c476777363f0bc536e4afd6f", "src_uid": "f52af273954798a4ae38a1378bfbf77a", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \nusing namespace std;\nint ans;\nint main()\n{\n\tint n,i,j;\n\tcin>>n;\n\tfor( i*i=n;i>=1;i--)\n\t\tfor( j*j=n;j<=n;j++){\n\t\t\tif(i*j==n&&i<=j){\n\t\t\t\tcout<\n#include \nusing namespace std;\nint main()\n{\n int n;\n cin>>n;\n vectora;\nif(n==1)cout<\n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n#define max(a,b) ((a)>(b)?(a):(b))\n#define min(a,b) ((a)<(b)?(a):(b))\n#define odd(x) (x&1)\ntypedef long long ll;\ntypedef long double ld;\nconst ll oo = 2 * 1000 * 1000 * 1000;\nconst int _cnt = 1000 * 1000;\nconst int _p = 1000 * 1000 * 1000 + 7;\nll o(ll x) { return x%_p; }\nint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }\nint lcm(int a, int b) { return a*b / gcd(a, b); }\nusing namespace std;\n\nvoid file_put() {\n\tfreopen(\"filename.in\", \"r\", stdin);\n\tfreopen(\"filename.out\", \"w\", stdout);\n}\n\nint n;\n\nint main() {\n\t//file_put();\n\n\tscanf(\"%d\", &n);\n\tfor (int i=(int)sqrt(n); i>=1; i--)\n\t\tif (n % i == 0) {\n\t\t\tprintf(\"%d %d\\n\", i, n / i);\n\t\t\tbreak;\n\t\t}\n\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3fd8dcc1f29f567c52576cf39aa058f6", "src_uid": "f52af273954798a4ae38a1378bfbf77a", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nint main()\n{\n\tstring c;\n\tcin >> c;\n\tint l=c.size(),i,x,test=0;\n\tint arr[l],cx[(l+1)],y[l+1];\n\tif (l==1)\n\t{\n\t\tcout << \"OK\";\n\t\texit(0);\n\t}\n\tfor (i=0;i\n#include\n\nusing namespace std;\n\nint a[1000][1000];\n\nint main(){ // freopen(\"input.cpp\",\"r\",stdin);\n string s;cin>>s;\n int si=500,flag=0, d,sj=500; d=1;\n a[si][sj]=1; int ii,jj; ii=si; jj=sj;\n for(int i=0;i\nusing namespace std;\n#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n#define ll long long int\n#define ull unsigned long long int\n#define dob double\n#define mp(x,y) make_pair(x,y)\n#define pb(x) push_back(x)\n#define ff first\n#define ss second\n#define forr(z,y) for(ll i=z;i=y;i--)\n#define Vp vector>\n#define V vector\n#define sort(a) sort(a.begin(),a.end())\n#define unique(a) unique(a.begin(),a.end())\nll i,j,x,y,k=0,l;\nconst int MOD=1e9+7;\nll m1 = LLONG_MAX;\nbool sortbysec(const pair &a,\n const pair &b)\n{\n return (a.second < b.second);\n}\nV g[1000001];\nll n;\nll v[101];\nll s[101];\n\nll m2 = LLONG_MIN;\nint32_t main()\n{ FAST\n string s;\n cin>>s;\n ll l=0,r=0,u=0,d=0;\n \n for(i=0;i\nusing namespace std;\nstatic const int MAXN=100;\nstruct Node{\n int x,y;\n}point[MAXN+10];\n\nint main()\n{\n string s;\n cin>>s;\n point[0]={0,0};\n for(int i=0;i\n\nusing namespace std;\n\nint main()\n{\n int x,y,z,t,num,bond1,bond2,bond3, f;\n bool flag=true;\n \n cin>>x;\n cin>>y;\n cin>>z;\n if (x>y)\n {\n t=x;\n x=y;\n y=t;\n }\n if (y>z)\n {\n t=y;\n y=z;\n z=t;\n }\n if (x>y)\n {\n t=x;\n x=y;\n y=t;\n }\n f=x+y+z;\n \n num=f/2;\n if ((x==y)&&(y==z))\n {\n if (x%2!=0)\n cout<0))\n cout<<\"Impossible\"<\n#include\nusing namespace std;\nint main()\n{\n long long x, y, z;\n cin >> x >> y >> z;\n long long chack = x + y + z;\n if ((chack) % 2 == 1)\n cout << \"Impossible\" << endl;\n //ba gnerate number my be in between \n else\n {\n for (int i = 0; i <= x; i++)\n {\n //cout << x - z - i << \" \" << y - i << endl;\n if (abs(x - z - i) == abs(y - i))\n {\n x = abs(i);\n y = y - x;\n z = z - y;\n break;\n }\n }\n if (x >= 0 && y >= 0 && z >= 0)\n cout << x << \" \" << y << \" \" << z << endl;\n else\n cout << \"Impossible\" << endl;\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "41571a7ed214757f9a33130090f48b8f", "src_uid": "b3b986fddc3770fed64b878fa42ab1bc", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n long int a,b,c,x,y,z;\n cin >>a>>b>>c;\n if((a+b+c)%2==0)\n {x=a;\n z=a;\n y=c;\n for(int i=0;i\n\n\n#define pb push_back\n#define mp make_pair\n#define F first\n#define S second\n\n\ntypedef long long ll;\ntypedef unsigned long long ull;\n\n\nusing namespace std;\n\n\nstring tos(int x){\n\nostringstream out;\n\nout << x;\n\nreturn out.str();\n\n}\n\nint toi(string s){\n\nistringstream in(s);\n\nint a; in >> a;\n\nreturn a;\n\n}\n\n\n\nint main(){\n\nios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n\nint a, b, c;\ncin >> a >> b >> c;\n\nif(a==b && b==c){\n if(a%2) { cout << \"Impossible\"; return 0; }\n\n cout << a/2 <<' '< sum-Max){ cout << \"Impossible\"; return 0; }\n\nif((sum- Max - Max)%2) { cout << \"Impossible\"; return 0; }\n\nint ab, bc, ac;\n\nif(a>=b && a>=c){\n\n bc = (sum-Max-Max)/2, ab = b-bc, ac = c-bc;\n\n\n} else if(b>=c){\n\n ac = (sum-Max-Max)/2, ab = a-ac, bc = c-ac;\n\n} else {\n ab = (sum-Max-Max)/2, bc = b - ab, ac = a - ab;\n}\n\n\ncout << ab <<' '<\n#include\n\nusing namespace std;\n\npair pto(int mx,int x,int st,int T){\n if(x<=mx)return make_pair(mx-x,0);\n if(st+(x-mx)<=T)return make_pair(0,x-mx);\n int d=(st+(x-mx)-T);\n return make_pair(d,x-mx-d);\n \n}\n\nint cerc(int x,int st,int T){\n int mst2=st/2,mst1=(st+1)/2;\n pair p1=pto(mst1,x,st,T),p2=pto(mst2,x,st,T);\n if(p1.first<=p2.first)return p1.second;\n return p2.second;\n}\n\nint main(){\n int x,y,n,m,a,b;\n cin>>n>>m>>x>>y>>a>>b;\n int g=__gcd(a,b);\n a/=g,b/=g;\n int na,nb;\n int ra=n/a,rb=m/b;\n if(ra*b<=m)na=ra*a,nb=ra*b;\n else na=rb*a,nb=rb*b;\n //cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n\nusing namespace std;\n\n#define ll long long \n#define pb push_back\n#define ppb pop_back\n\n#define y1 aasdfasdfasdf\n\nconst ll N = 1e5 + 10;\nconst ll mod = 1e9 + 7;\nconst ll INF = 1e18;\nconst ll inf = -1e18;\nconst ll M = 5 * 1e8;\n\nlong long l, w, gd, k, t, n, m, a, b;\ndouble dis, mn, mx, my, x1, x2, y1, y2, a1, a2, b1, b2, x, y;\n\nll gcd(ll a, ll b) {\n\tif (b == 0)\n\t{\n\t\treturn a;\n\t}\n\telse\n\t{\n\t\treturn gcd(b, a % b);\n\t}\n}\n\nint main()\n{\n\tcin >> n >> m >> x >> y >> a >> b;\n\tgd = gcd(a, b);\n\ta /= gd;\n\tb /= gd;\n\tll r = min(n / a, m / b);\n\tfor (int i = r; i >= 1; i--)\n\t{\n\t\tl = r * a;\n\t\tw = r * b;\n\t\tif (l <= n && w <= m)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t}\n\tmn = INF;\n\tk = max(0 * 1ll, ll(x - l) - 1 * 1ll);\n\tt = max(0 * 1ll, ll(y - w) - 1 * 1ll);\n\tfor (int i = k; i <= ll(x); i++)\n\t{\n\t\tif (i + l > n)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t\tfor (int j = t; j <= ll(y); j++)\n\t\t{\n\t\t\tif (j + w > m)\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tx1 = i;\n\t\t\ty1 = j;\n\t\t\tx2 = i + l;\n\t\t\ty2 = j + w;\n\t\t\tif (x < x1 || x > x2 || y < y1 || y > y2)\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tmx = (x1 + x2) / 2.0;\n\t\t\tmy = (y1 + y2) / 2.0;\n\t\t\tdis = sqrt((x - mx)*(x - mx) + (y - my)*(y - my));\n\t\t\tif (dis < mn)\n\t\t\t{\n\t\t\t\tmn = dis;\n\t\t\t\ta1 = x1, a2 = x2, b1 = y1, b2 = y2;\n\t\t\t}\n\t\t}\n\t}\n\tcout << a1 << \" \" << b1 << \" \" << a2 << \" \" << b2;\n\tcin.get(), cin.get();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6ac6c690aec71c15ce74033ec58c79e7", "src_uid": "8f1211b995f35462ae83b2be27f54585", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "// Solution by Mukai Yersin\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define sz 2000000\n#define mp make_pair\n#define pb push_back\n#define eps 1e-5\n#define inf 1<<30\n#define INF (long long)(1ll<<62)\n#define F first\n#define S second\n\ntypedef long long ll;\n\nusing namespace std;\n\nint x, y, a, b, n, m, k, K, l, r, X, Y\n\nint main()\n{\n\tcin>>n>>m>>x>>y>>a>>b;\n\tl=0; r=max(n, m)+1;\n\tint g=__gcd(a, b);\n\ta/=g;\n\tb/=g;\n\twhile (ln) X=n-a*1ll*k;\n\tif (Y+b*1ll*k>m) Y=m-b*1ll*k;\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#include \n#include \n#include \n#include \n#include \n\n#define DEBUG\n#ifdef DEBUG\n#define DBG(...) cerr << #__VA_ARGS__ << \": \" << __VA_ARGS__ << endl\n#define DV(...) cerr << __VA_ARGS__ << endl\n#define _D(fmt, ...) printf(\"%10s %3d : \" fmt,__FUNCTION__,__LINE__,__VA_ARGS__)\n#define _DE(fmt, ...) fprintf(stderr, \"%10s %3d : \" fmt,__FUNCTION__,__LINE__,__VA_ARGS__)\n#else\n#define DBG(...)\n#define DV(...)\n#define _D(fmt, ...)\n#define _DE(fmt, ...)\n#endif\n\ntypedef signed long long ll;\ntypedef unsigned long long u64;\n\n#define _PE(...) printf(__VA_ARGS__); fprintf(stderr, __VA_ARGS__);\n#define _E(...) fprintf(stderr, __VA_ARGS__)\n#undef _P\n#define _P(...) printf(__VA_ARGS__)\n\n#define FOR(x,to) for(x=0;x T sqr(T val){ return val*val;}\n\n//-------------------------------------------------------\n\nll N,M,X,Y,A,B;\n\nll gcd(ll a, ll b) { return (b==0)?a:gcd(b,a%b);}\n\nvoid solve() {\n int f,r,i,j,k,l,x,y;\n \n cin>>N>>M>>X>>Y>>A>>B;\n ll g=gcd(A,B);\n A/=g;\n B/=g;\n \n ll MD=min(N/A,M/B);\n N*=2;M*=2;X*=2;Y*=2;\n \n ll x1=min(max(X,MD*A),N-MD*A)-MD*A;\n ll y1=min(max(Y,MD*B),M-MD*B)-MD*B;\n _P(\"%lld %lld %lld %lld\\n\",x1/2,y1/2,x2/2+MD*A,y2/2+MD*B);\n \n return;\n}\n\n\nint main(int argc,char** argv){\n if(argc>1) freopen(argv[1], \"r\", stdin);\n solve();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3f4c2e4626b2e1c04ef368c747891a47", "src_uid": "8f1211b995f35462ae83b2be27f54585", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nlong long p=1e9+7;\nmap m;\n\nlong long pow(long long a, long long b){\n long long ans=1;\n while(b>0){ \n if(b&1)\n ans=(ans*a)%p;\n b/=2;\n a=(a*a)%p;\n }\n return ans;\n}\n\nlong long f(long long b){\n if(m[b])\n return m[b];\n long long r=pow(2,b-1),l=sqrt(b),i;\n for(i=2;i<=l;i++)\n if(n%i==0)\n r-=f(i),r-=f(n/i),r+=2*p,r%=p;\n if(l*l==b)\n r+=f(l),r%=p;\n return m[b]=(r-1+p)%p;\n}\n\nint main(){\n ios_base::sync_with_stdio (false);cin.tie(0);cout.tie(0);\n long long a,b;\n cin>>a>>b;\n if(b%a){\n cout<<\"0\\n\";\n return 0;\n }\n b/=a;\n m[1]=1;\n cout<\n#include \n#include \nusing namespace std;\n\ntypedef long long ll;\nconst ll MOD = 1000000007;\nint x, y;\nmap memo;\n\nll pow(ll n, ll exp = MOD - 2) {\n\tll ret = 1;\n\twhile (exp)\n\t{\n\t\tret = ret*((exp & 1) ? n : 1) % MOD, n = n*n%MOD, exp >>= 1;\n\t}\n\treturn ret;\n}\n\nstatic inline int sum(int q)\n{\n\tif (q == 1) return 1;\n\tif (memo.count(q)) return memo[q];\n\n\tll& ret = memo[q];\n\tret = pow(2, q - 1);\n\tfor (int i = 2; i*i <= q; i++)\n\t{\n\t\tif (q%i == 0)\n\t\t{\n\t\t\tret -= sum(q / i);\n\t\t\tif (q / i != i) ret -= sum(i);\n\t\t}\n\t}\n\n\treturn ret = (ret - 1 + MOD)%MOD;\n}\n\nstatic inline int solve()\n{\n\tif (y % x) return 0;\n\treturn sum(y / x);\n}\n\nint main()\n{\n\t//freopen(\"input.txt\", \"r\", stdin);\n\t\n\tcin.sync_with_stdio(false);\n\tcin >> x >> y;\n\tcout << solve() << endl;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9e3b2863c4fe19c93478bd5464efea3e", "src_uid": "de7731ce03735b962ee033613192f7bc", "difficulty": 2000.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \nusing namespace std;\n\ntypedef long long uint;\nconst uint MOD = 1000000007;\nint x, y;\nmap memo;\n\nuint pow(uint n, uint exp = MOD - 2) {\n\tuint ret = 1;\n\twhile (exp)\n\t{\n\t\tret = ret*((exp & 1) ? n : 1) % MOD, n = n*n%MOD, exp >>= 1;\n\t}\n\treturn ret;\n}\n\nstatic inline int sum(int q)\n{\n\tif (q == 1) return 1;\n\tif (memo.count(q)) return memo[q];\n\n\tuint& ret = memo[q];\n\tret = pow(2, q - 1);\n\tfor (int i = 2; i*i <= q; i++)\n\t{\n\t\tif (q%i == 0)\n\t\t{\n\t\t\tret -= sum(q / i);\n\t\t\tif (q / i != i) ret -= sum(i);\n\t\t}\n\t}\n\n\treturn ret = (ret - 1 + MOD)%MOD;\n}\n\nstatic inline int solve()\n{\n\tif (y % x) return 0;\n\treturn sum(y / x);\n}\n\nint main()\n{\n\t//freopen(\"input.txt\", \"r\", stdin);\n\t\n\tcin.sync_with_stdio(false);\n\tcin >> x >> y;\n\tcout << solve() << endl;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "15ab985e514487c274a7bc2fc3cfef6d", "src_uid": "de7731ce03735b962ee033613192f7bc", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n#define int long long\nconst int N = 5e5 + 10, MOD = 1e9 + 7;\nmap ans;\n\nint Pow(int n, int i)\n{\n int x = pow(n , i / 2);\n return ( ((x * x) % MOD) * (i % 2 ? x : 1) ) % MOD;\n}\n\nint32_t main()\n{\n ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n int x, y; cin >> x >> y;\n if (y % x != 0) return cout << 0, 0;\n int n = y / x;\n vector v;\n for (int i = 1; i * i <= n; i ++) {\n if (n % i == 0) {\n v.push_back(i);\n if (i * i != n) v.push_back(n / i);\n }\n }\n sort(v.begin(), v.end());\n for (int i : v) {\n int Ans = pow(2, i - 1);\n for (int j = 1; j * j <= i; j ++) {\n if (i % j == 0) {Ans -= ans[j]; Ans = (Ans + Mod) % Mod;}\n if (j * j != i) {Ans -= ans[i / j]; Ans = (Ans + Mod) % Mod;}\n }\n ans[i] = Ans;\n }\n cout << ans[n] << \"\\n\";\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "228f59b1405a4a1c04aa94df5de277f8", "src_uid": "de7731ce03735b962ee033613192f7bc", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nconst int N=100100;\nint n,K,P;\nint ny[N],jc[N],f[27][N];\nint ksm(int x,int k)\n{\n\tint res=1;\n\twhile(k)\n\t{\n\t\tif(k&1)\tres=1ll*res*x%P;\n\t\tk>>=1;x=1ll*x*x%P;\n\t}\n\treturn res;\n}\ninline int lowbit(int x)\n{\n\treturn x&(-x);\n}\nint dfs(int now,int S)\n{\n\tif(f[now][S]!=-1) return f[now][S];\n\tif(!S)\n\t{\n\t\tf[now][S]=jc[n];\n\t\tfor(int i=0;i=0;i--) ny[i]=1ll*ny[i+1]*(i+1)%P;\n\tint ans=ksm(K,n);\n\tif(n&1) printf(\"%d\\n\",ans);\n\telse printf(\"%d\\n\",(ans-dfs(0,n)+P)%P);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3a23e45b232cf5e5fe9439b3eb164f2a", "src_uid": "97f737f59100babe5e45e1a82a1f7d99", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#include\n#define N 250005\nusing namespace std;\nint n,k,mo,ans;\nint hr[N],fac[N],inv[N],f[27][N];\nint power(int x,int y){\n\tint s=1;\n\tfor (;y;y/=2,x=1ll*x*x%mo)\n\t\tif (y&1) s=1ll*s*x%mo;\n\treturn s;\n}\nint main(){\n\tscanf(\"%d%d%d\",&n,&k,&mo);\n\tinv[0]=inv[1]=fac[0]=1;\n\tfor (int i=2;i<=n;i++)\n\t\tinv[i]=1ll*(mo-mo/i)*inv[mo%i]%mo;\n\tfor (int i=1;i/2<=n;i*=2)\n\t\tfor (int j=i/2;j\n#include\nusing namespace std;\n\nlong n,k,p,bobwin;\nlong f[250010][30];\n\nlong power(long x, long y, long p);\nlong F(long n,long k,long p);\nvoid lists(long a[], long max, long i, long num, long n, long k, long p);\n\nlong power(long x, long y, long p){\n\tif(y==0){\n\t\treturn 1;\n\t}\n\telse{\n\t\tlong long t = power(x, y/2, p);\n\t\tif(y%2==0){\n\t\t\treturn (t*t)%p;\n\t\t}\n\t\telse{\n\t\t\treturn ((t*t)%p)*x%p;\n\t\t}\n\t}\n}\n\nvoid lists(long a[], long max, long i, long num, long n, long k, long p){\n\tif(i==max){\n\t\tf[n][k] = (f[n][k]+F(num, k-1, p))%p;\n\t\treturn;\n\t}\n\tif(a[i]==1){\n\t\tlists(a, max, i+1, num, n, k, p);\n\t\tlists(a, max, i+1, num+(1<>i)%2==1){\n\t\t\ta[i] = 1;\n\t\t}else{\n\t\t\ta[i] = 0;\n\t\t}\n\t}\n\tf[n][k] = 0;\n\tlists(a, 18, 0, 0, n, k, p);\n\t//cout<<\"f[\"<>n>>k>>p;\n\tlong total = power(k,n,p);\n\tif(n%2==1){\n\t\tcout<\nusing namespace std;\n\nconst int Maxn = 1 << 19 | 5;\nint n, k, p, maxi, ct[Maxn], f[Maxn];\nlong long pp;\nlong long tmp1[20][Maxn], tmp2[20][Maxn], tmp3[20][Maxn];\nlong long fac[Maxn], inv[Maxn];\nlong long fast_pow(long long x, long long y)\n{\n long long ans = 1, now = x;\n while (y)\n {\n if (y & 1) ans = ans * now % p;\n now = now * now % p;\n y >>= 1;\n }\n return ans;\n}\nvoid init(void)\n{\n fac[0] = 1;\n for (int i = 1; i <= maxi; i++)\n fac[i] = fac[i - 1] * i % p;\n inv[maxi] = fast_pow(fac[maxi], p - 2);\n for (int i = maxi - 1; i >= 0; i--)\n inv[i] = inv[i + 1] * (i + 1) % p;\n}\nint lower(int x)\n{\n int tmp = 1;\n for (; tmp < x; tmp <<= 1);\n return tmp;\n}\nvoid FWT(long long *now, int len, bool type = false)\n{\n\tif (type)\n\t\tfor (int i = 1; i < len; i <<= 1)\n\t\t\tfor (int j = 0; j < len; j += (i << 1))\n\t\t\t\tfor (int k = j; k < i + j; k++)\n\t\t\t\t\tnow[i + k] -= now[k];\n\telse\n\t\tfor (int i = 1; i < len; i <<= 1)\n\t\t\tfor (int j = 0; j < len; j += (i << 1))\n\t\t\t\tfor (int k = j; k < i + j; k++)\n\t\t\t\t\tnow[i + k] += now[k];\n\tfor (int i = 0; i < len; i ++) {\n\t\tnow[i] %= p;\n\t\tif (now[i] < 0) now[i] += p;\n\t}\n}\ninline void __a (long long &x) { x >= pp ? x -= pp : x; }\nvoid multi(void)\n{\n for (int j = 0; j <= 19; j++)\n {\n memset(tmp1[j], 0, sizeof(long long[maxi + 1]));\n memset(tmp3[j], 0, sizeof(long long[maxi + 1])); \n }\n for (int j = 0; j <= maxi; j++)\n tmp1[ct[j]][j] = f[j];\n for (int j = 0; j <= 19; j++)\n FWT(tmp1[j], maxi + 1);\n for (int q = 0; q <= 19; q++)\n for (int l = 0; q + l <= 19; l++)\n for (int s = 0; s <= maxi; s++)\n __a(tmp3[q + l][s] += tmp1[q][s] * tmp2[l][s]);\n for (int q = 0; q <= 19; q++)\n\t\tfor (int s = 0; s <= maxi; s++)\n\t\t\ttmp3[q][s] %= p;\n for (int j = 0; j <= 19; j++)\n FWT(tmp3[j], maxi + 1, true);\n for (int j = 0; j <= maxi; j++)\n f[j] = tmp3[ct[j]][j];\n}\nvoid multi2(void)\n{\n static long long tmp[20][Maxn];\n for (int i = 0; i <= 19; i++)\n memset(tmp[i], 0, sizeof(long long[maxi + 1]));\n for (int q = 0; q <= 19; q++)\n for (int l = 0; q + l <= 19; l++)\n for (int s = 0; s <= maxi; s++)\n __a(tmp[q + l][s] += tmp2[q][s] * tmp2[l][s]);\n for (int q = 0; q <= 19; q++)\n\t\tfor (int s = 0; s <= maxi; s++)\n\t\t\ttmp[q][s] %= p;\n for (int i = 0; i <= 19; i++)\n FWT(tmp[i], maxi + 1, true);\n for (int i = 0; i <= 19; i++)\n memset(tmp2[i], 0, sizeof(long long[maxi + 1]));\n for (int i = 0; i <= maxi; i++)\n tmp2[ct[i]][i] = tmp[ct[i]][i];\n for (int i = 0; i <= 19; i++)\n FWT(tmp2[i], maxi + 1);\n}\nint main()\n{\n scanf(\"%d%d%d\", &n, &k, &p);\n\tpp = 1ll * p * p;\n if (n & 1)\n {\n printf(\"%lld\", fast_pow(k, n));\n return 0;\n }\n f[0] = 1;\n maxi = lower(n + 1) - 1;\n init();\n for (int i = 0; i <= maxi; i++)\n ct[i] = __builtin_popcount(i);\n for (int i = 0; i <= maxi; i++)\n tmp2[ct[i]][i] = inv[i];\n for (int i = 0; i <= 19; i++)\n FWT(tmp2[i], maxi + 1);\n int res_k = k;\n while (k)\n {\n cerr << k << endl;\n if (k & 1) multi();\n k >>= 1;\n if (k) multi2();\n }\n printf(\"%lld\", (fast_pow(res_k, n) - fac[n] * f[n] % p + p) % p);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0603dd3c8fba67455ac844d6a895d380", "src_uid": "97f737f59100babe5e45e1a82a1f7d99", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\nconst int N=1e5+10;\nint num[N];\nint n,m,mindis,t,lower,upper,ans;\nvoid dfs(int sum,int d,int x,int minn)\n{\nif(sum>=lower&&sum<=upper&&d>=mindis) ans++;\nif(sum>upper) return;\nfor(int i=x;i<=n;++i)\n{\ndfs(sum+num[i],num[i]\u2010minn,i+1,minn);\n}\n} i\nnt main()\n{\nwhile(cin>>n>>lower>>upper>>mindis)\n{\nans=0;\nmemset(num,0,sizeof(num));\nfor(int i=1; i<=n; ++i) scanf(\"%d\",&num[i]);\nsort(num+1,num+1+n);\nfor(int i=1; i<=n; ++i)\n{\ndfs(num[i],0,i+1,num[i]);\n} p\nrintf(\"%d\\n\",ans);\n} r\neturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6f8534e1356037fe98c7f9f4cf26e5a3", "src_uid": "0d43104a0de924cdcf8e4aced5aa825d", "difficulty": 1400.0} {"lang": "GNU C++17", "source_code": "#include \n \nusing namespace std;\n \nvector v;\nint n, l, r, x;\n \nint ric(int i, int s, int ma, int mi)\n{\n if(i == 0 && s <= r && s >= l && ma - mi >= x) return 1;\n if(i < 0) return 0;\n \n return ric(i-1, s+v[i], max(ma, v[i]), min(mi, v[i])) + ric(i-1, s, ma, mi)+ c;\n}\n \nint main()\n{\n \n \n cin>>n>>l>>r>>x;\n \n v.resize(n);\n \n \n for(int i=0;i>v[i];\n }\n \n cout<\nusing namespace std;\n\nint main () {\n\tint n;\n\tlong long r, l, x, a, i, j, countj, sum, maxi, mini, out;\n\tvector name;\n\t\n\tcin>>n>>r>>l>>x;\n\t\n\twhile (cin>>a) {\n\t\tname.push_back(a);\n\t}\n\t\n\tfor (i=0; i<(1<=r&&(maxi-mini)>=x&&countj>1) {\n\t\t\tout+=1;\n\t\t}\n\t}\n\t\n\tcout<\nusing namespace std;\nint ara[20];\nint n, l, r, x;\nint cnt=0;\nvoid func(int i, int max, int min, int w){\n if(i>=n) {\n if(w>=l && w<=r && (max-min)>=x){cnt++;}\n return;\n }\n if(w>r) return;\n if(min==0) {\n min=aray[i];\n }\n func(i+1, aray[i], min, w+aray[i]);\n if(w==0) {\n min=0;\n max=0;\n }\n func(i+1, max, min, w);\n}\nint main(){\n int a, b, c;\n cin >> n >> l >> r >> x;\n for(a=0; a\n#include\nusing namespace std;\n\nint main()\n{\n int n;\n cin >> n;\n if(n==0)\n cout << 0;\n else if(n==1)\n cout << 2;\n else if(n==2)\n cout << 3;\n else if(n>=3 && n<=4)\n cout << 4;\n else if(n>=5 && n<=6)\n cout << 5;\n else if(n>=7 && n<=9)\n cout << 6;\n else if(n>=10 && n<=12)\n cout << 7;\n else if(n>=13 && n<=16)\n cout << 8;\n else if(n>=17 && n<=20)\n cout << 9;\n else if(n>=21 && n<=25)\n cout << 10;\n else if(n>=26 && n<=30)\n cout << 11;\n else if(n>=31 && n<=36)\n cout << 12;\n else if(n>=37 && n<=42)\n cout << 13;\n else if(n>=43 && n<=49)\n cout << 14;\n else if(n>=50 && n<=56)\n cout << 15;\n else if(n>=57 && n<=64)\n cout << 16;\n else if(n>=65 && n<=72)\n cout << 17;\n else if(n>=73 && n<=81)\n cout << 18;\n else if(n>=82 && n<=90)\n cout << 19;\n else if(n>=91 && n<=100)\n cout << 20;\n else if(n>=101 && n<=110)\n cout << 21;\n else if(n>=111 && n<=121)\n cout << 22;\n else if(n>=122 && n<=132)\n cout << 23;\n else if(n>=133 && n<=144)\n cout << 24;\n else if(n>=145 && n<=156)\n cout << 25;\n else if(n>=157 && n<=169)\n cout << 26;\n else if(n>=170 && n<=182)\n cout << 27;\n else if(n>=183 && n<=196)\n cout << 28;\n else if(n>=197 && n<=210)\n cout << 29;\n else if(n>=211 && n<=225)\n cout << 30;\n else if(n>=226 && n<=240)\n cout << 31;\n else if(n>=241 && n<=256)\n cout << 32;\n else if(n>=257 && n<=272)\n cout << 33;\n else if(n>=273 && n<=289)\n cout << 34;\n else if(n>=290 && n<=306)\n cout << 35;\n else if(n>=307 && n<=324)\n cout << 36;\n else if(n>=325 && n<=342)\n cout << 37;\n else if(n>=343 && n<=361)\n cout << 38;\n else if(n>=362 && n<=380)\n cout << 39;\n else if(n>=381 && n<=400)\n cout << 40;\n else if(n>=401 && n<=420)\n cout << 41;\n else if(n>=421 && n<=441)\n cout << 42;\n else if(n>=442 && n<=462)\n cout << 43;\n else if(n>=463 && n<=484)\n cout << 44;\n else if(n>=485 && n<=506)\n cout << 45;\n else if(n>=507 && n<=529)\n cout << 46;\n else if(n>=530 && n<=552)\n cout << 47;\n else if(n>=553 && n<=576)\n cout << 48;\n else if(n>=577 && n<=600)\n cout << 49;\n else if(n>=601 && n<=625)\n cout << 50;\n else if(n>=626 && n<=650)\n cout << 51;\n else if(n>=651 && n<=676)\n cout << 52;\n else if(n>=677 && n<=702)\n cout << 53;\n else if(n>=703 && n<=729)\n cout << 54;\n else if(n>=730 && n<=756)\n cout << 55;\n else if(n>=757 && n<=784)\n cout << 56;\n else if(n>=785 && n<=812)\n cout << 57;\n else if(n>=813 && n<=841)\n cout << 58;\n else if(n>=842 && n<=870)\n cout << 59;\n else if(n>=871 && n<=900)\n cout << 60;\n else if(n>=901 && n<=930)\n cout << 61;\n else if(n>=931 && n<=961)\n cout << 62;\n else if(n>=962 && n<=992)\n cout << 63;\n else if(n>=993 && n<=1024)\n cout << 64;\n else if(n>=1025 && n<=1056)\n cout << 65;\n else if(n>=1057 && n<=1089)\n cout << 66;\n else if(n>=1090 && n<=1122)\n cout << 67;\n else if(n>=1123 && n<=1156)\n cout << 68;\n else if(n>=1157 && n<=1190)\n cout << 69;\n else if(n>=1191 && n<=1225)\n cout << 70;\n else if(n>=1226 && n<=1260)\n cout << 71;\n else if(n>=1261 && n<=1296)\n cout << 72;\n else if(n>=1297 && n<=1332)\n cout << 73;\n else if(n>=1333 && n<=1369)\n cout << 74;\n else if(n>=1370 && n<=1406)\n cout << 75;\n else if(n>=1407 && n<=1444)\n cout << 76;\n else if(n>=1445 && n<=1482)\n cout << 77;\n else if(n>=1483 && n<=1521)\n cout << 78;\n else if(n>=1522 && n<=1560)\n cout << 79;\n else if(n>=1561 && n<=1600)\n cout << 80;\n else if(n>=1601 && n<=1640)\n cout << 81;\n else\n cout >> 90;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "16f54beaaf575812c34db4a0ea3195ec", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#define DEBUG\n\n#pragma comment(linker, \"/STACK:256000000\")\n#define _USE_MATH_DEFINES \n#define _CRT_SECURE_NO_DEPRECATE \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define per(i,a,b) for (int i = a; i\n#define mp make_pair\n#define pq priority_queue\n#define INF 1000000000000000\n#define BIG(x) (x>='A' && x<='Z')\n#define SMALL(x) (x>='a' && x<='z')\n#define toBIG(x) (SMALL(x)?(x-'a'+'A'):x)\n#define toSMALL(x) (BIG(x)?(x-'A'+'a'):x)\n#define END(s) {cout << s; return 0;}\n#define tmin(a,b,c) min(a,min(b,c))\n#define tmax(a,b,c) max(a,max(b,c))\n#define E3 1000\n#define E4 10000\n#define E5 100000\n#define E6 1000000\n\nusing namespace std;\n\nint otr[1025];\nvector v;\n\nint main(int argc, char ** argv)\n{\n#ifdef DEBUG\n\tfreopen(\"input.txt\", \"r\", stdin); freopen(\"output.txt\", \"w\", stdout);\n#endif\n\tint n;\n\tcin >> n;\n\tint a = sqrt(n);\n\tint b = sqrt(n);\n\twhile (a*b < n) {\n\t\tif (a < b)\n\t\t\ta++;\n\t\telse\n\t\t\tb++;\n\t}\n\tcout << a+b;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fdce1e73f3eb610ac273acb6056c13f6", "src_uid": "eb8212aec951f8f69b084446da73eaf7", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include \n#include \nusing namespace std;\n\nint main()\n{\n int c,a;\n cin>>c;\n a= ceil(sqrt(2*n));\n cout<\n\nusing namespace std;\n\n\nint main(\n {\n int n;\n cin>>n;\n int i=sqrt(n),x=1;\n for(;i>2;i--)\n {\n if(n%i==0)\n {\n x=i;\n break;\n }\n }\n x+=(n/x);\n cout<\r\n#include\r\n#include \r\n#define loop(i, n) for(int i = 0; i < n; i++)\r\n#define pb push_back\r\n#define ll long long int\r\n#define vi vector\r\n#define pi pair\r\n#define W(t) int t; cin >> t; while(t--)\r\n#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\r\n#define ff first\r\n#define ss second\r\n#define rep(i, a, b)for(ll i = a; i <= b; i++)\r\n#define dep(i, a, b)for(ll i = a; i >= b; i--) \r\n#define all(x) x.begin(), x.end()\r\n#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)\r\n#define PI 3.141592653589793238\r\nusing namespace std;\r\nconst ll mod = (ll)(998244353);\r\nconst ll mod2 = (ll)1e9+7;\r\nll test = 1;\r\nvector read(int n){\r\n \r\n vector v(n);\r\n\r\n loop(i, n)\r\n cin >> v[i];\r\n return v;\r\n}\r\nstruct custom_hash {\r\n static uint64_t splitmix64(uint64_t x) {\r\n // http://xorshift.di.unimi.it/splitmix64.c\r\n x += 0x9e3779b97f4a7c15;\r\n x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;\r\n x = (x ^ (x >> 27)) * 0x94d049bb133111eb;\r\n return x ^ (x >> 31);\r\n }\r\n size_t operator()(uint64_t x) const {\r\n static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();\r\n return splitmix64(x + FIXED_RANDOM);\r\n }\r\n};\r\n\r\nvoid solve(){\r\n ll i, j, k, m,n, cnt = 0, ans = 0, sum = 0;\r\n\r\n cin >> n >> m >> k;\r\n\r\n ll tot = (n*m)/2;\r\n\r\n if(n == 1 && tot != k){\r\n cout << \"NO\\n\";\r\n return;\r\n }\r\n\r\n if(n == 1 && tot == k){\r\n cout << \"YES\\n\";\r\n return;\r\n }\r\n\r\n if(m == 1 && k){\r\n cout << \"NO\\n\";\r\n return;\r\n }\r\n\r\n //Two Cases\r\n\r\n ll inOne = k/n;\r\n\r\n ll rem = k%n;\r\n\r\n ll remc = m-inOne*2-rem*2;\r\n \r\n if(inOne+rem==k) {\r\n \r\n if(remc){\r\n if(rem%2){\r\n\r\n if(remc >= 2 && (n-1)%2 == 0){\r\n if(remc-2 == 0){\r\n cout << \"YES\\n\";\r\n return;\r\n }\r\n }\r\n\r\n }\r\n else{\r\n if(n%2){\r\n\r\n }\r\n else{\r\n cout << \"YES\\n\";\r\n return;\r\n }\r\n }\r\n } \r\n else{\r\n if(rem%2){\r\n // cout << \"NO\\n\";\r\n }\r\n else{\r\n cout << \"YES\\n\";\r\n return;\r\n }\r\n }\r\n}\r\n ll avail = m-m%2;\r\n\r\n inOne = k*2/avail;\r\n\r\n rem = k*2%avail;\r\n \r\n if(rem){\r\n cout << \"NO\\n\";\r\n return;\r\n }\r\n\r\n\r\n ll left_h = n-inOne;\r\n\r\n if(left_h%2){\r\n cout << \"NO\\n\";\r\n return;\r\n }\r\n // cout<< inOne+rem<<\"\\n\";\r\n if(inOne+rem!= k) {\r\n cout<<\"NO\\n\";\r\n return;\r\n }\r\n \r\n cout << \"YES\\n\";\r\n\r\n test++;\r\n}\r\n\r\nint main(){\r\n FIO\r\n \r\n ll i = 1;\r\n W(t)\r\n solve();\r\n \r\n return 0;\r\n \r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f55e626b506df497d3aeb920a6d585e7", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include \r\nusing namespace std;\r\n#define ll long long int\r\nconst int mod=1e5+5;\r\nint power(int x, int n) {\r\n int res = 1;\r\n while(n) {\r\n if(n&1) res = 1LL * res * x % mod;\r\n x = 1LL * x * x % mod;\r\n n >>= 1;\r\n }\r\n return res;\r\n}\r\nvoid solve(){\r\n int n,m,k;\r\n cin>>n>>m;\r\n if(n%2==0 && m%2==0){\r\n if(k%2==0){\r\n cout<<\"Yes\"<<'\\n';\r\n \r\n }else{\r\n cout<<\"No\"<<'\\n';\r\n }\r\n }else if(n%2==1 && m%2==0){\r\n if(k>t;\r\n while(t--){\r\n solve();\r\n }\r\n\t// your code goes here\r\n\treturn 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "78d9699787322f6dea43a5e7f0d03a20", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include \r\nusing namespace std;\r\ntypedef long long ll;\r\nconst ll mod = 1e9 + 7;\r\nbool func(ll n, ll m, ll k)\r\n{\r\n ll bandera=0;\r\n if(m==2){\r\n return (n%2)==(k%2)\r\n }\r\n elif(n==1){\r\n return (m%2==0) && (k==m)\r\n }\r\n return bandera;\r\n \r\n\r\n}\r\nint main()\r\n{\r\n ios::sync_with_stdio(false), cin.tie(nullptr);\r\n ll m, n, k, t;\r\n cin>>t;\r\n for(int j=0;j>n;\r\n cin>>m;\r\n cin>>k;\r\n if(func(n,m,k))\r\n {\r\n cout<<\"YES\"<\nusing namespace std;\n\nint main()\n{\n int t,n,m,k;\n cin >> t;\n while (t--)\n {\n cin >> n >> m >> k;\n \n int nr = n % 2;\n int mr = m % 2;\n int kr = k % 2;\n \n if (m == 2)\n {\n if (n == k)\n {\n cout << \"YES\\n\";\n continue;\n }\n else\n {\n cout << \"NO\\n\";\n continue;\n }\n }\n if (n == 1)\n {\n if (m == k * 2)\n {\n\t\t\t\tcout << \"YES\\n\";\n\t\t\t\tcontinue;\n }\n\t\t\telse\n\t\t\t{\n\t\t\t\tcout << \"NO\\n\";\n\t\t\t\tcontinue;\n\t\t\t}\n }\n \n if (nr == 0 && mr == 0)\n {\n if (kr == 0) cout << \"YES\\n\";\n else cout << \"NO\\n\";\n }\n else if (nr == 1 && mr == 0)\n {\n k -= m / 2;\n if (k == 0)\n {\n cout << \"NO\\n\";\n\t\t\t\tcontinue;\n }\n \n int min_k = m / 2;\n if (k >= min_k && k <= n*m/2)\n {\n cout << \"YES\\n\";\n }\n else\n {\n cout << \"NO\\n\";\n }\n /*if (k * 2 < m) cout << \"NO\\n\";\n else cout << \"YES\\n\";*/\n\t\t\t/*kr = k % 2;\n\t\t\tif (k * 2 < m) cout << \"NO\\n\";\n\t\t\telse if (kr == 0) cout << \"YES\\n\";\n\t\t\telse cout << \"NO\\n\";*/\n }\n else if (nr == 1 && mr == 1)\n {\n cout << \"NO\\n\";\n }\n else\n {\n if (k > n * (m - 1) / 2) cout << \"NO\\n\";\n else if (kr == 0) cout << \"YES\\n\";\n else cout << \"NO\\n\";\n }\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c1140ff24c5c87024234ef074ad8efd8", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include\nint a[12][12],ans=-1;\nint mn(int x,int y)\n{\n\treturn xy?x:y;\n}\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tf\\\n\to\\\n\tr(int i=1;i<=n;i++){\n\t\tf\\\n\t\to\\\n\t\tr(int j=1;j<=n;j++){\n\t\t\tscanf(\"%d\",&a[i][j]);\n\t\t}\n\t}\n\tf\\\n\to\\\n\tr(int k=1;k<=n;k++){\n\t\tf\\\n\t\to\\\n\t\tr(int i=1;i<=n;i++){\n\t\t\tf\\\n\t\t\to\\\n\t\t\tr(int j=1;j<=n;j++){\n\t\t\t\ta[i][j]=mn(a[i][j],a[i][k]+a[k][j]);\n\t\t\t}\n\t\t}\n\t}\n\tf\\\n\to\\\n\tr(int i=1;i<=n;i++){\n\t\tf\\\n\t\to\\\n\t\tr(int j=1;j<=n;j++){\n\t\t\tans=mx(ans,a[i][j]);\n\t\t}\n\t}\n\tprintf(\"%d\\n\",ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fa15831c6cec18b06efd9012449bed10", "src_uid": "bbd210065f8b32de048a2d9b1b033ed5", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n#defin\\\ne Fo2(i, n) fo\\\nr (int i=0;i\nusing namespace std;\nint adj[11][11];\nint n;\nvoid floyd()\n{\n\tint i, j, k;\n\tk = 0;\n\twhi/*...*/le (k < n)\n\t{\n\t\ti = 0;\n\t\twhi/*...*/le (i < n)\n\t\t{\n\t\t\tj = 0;\n\t\t\twhi/*...*/le (j < n)\n\t\t\t{\n\t\t\t\tadj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);\n\t\t\t\tj++;\n\t\t\t}\n\t\t\ti++;\n\t\t}\n\t\tk++;\n\t}\n}\nint main()\n{\n\tint i, j;\n\tcin >> n;\n\ti = 0;\n\twhi/*...*/le (i < n)\n\t{\n\t\tj = 0;\n\t\twhi/*...*/le (j < n)\n\t\t{\n\t\t\tcin >> adj[i][j];\n\t\t\tj++;\n\t\t}\n\t\ti++;\n\t}\n\tfloyd();\n\tint ans = 0;\n\ti = 0;\n\twhi/*...*/le (i < n)\n\t{\n\t\tj = 0;\n\t\twhi/*...*/le (j < n)\n\t\t{\n\t\t\tans = max(ans, adj[i][j]);\n\t\t\tj++;\n\t\t}\n\t\ti++;\n\t}\n\tcout << ans;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0e669b8612017a72db862a3db0f80a38", "src_uid": "bbd210065f8b32de048a2d9b1b033ed5", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include\n\nusing namespace std;\n\nint E[20][20];\nint n,ans;\n\nint main()\n{\nscanf(\"%d\",&n);\nf\\\no\\\nr (int i = 1;i <= n;++ i) \nf\\\no\\\nr (int j=1;j<=n;++j) s\\canf(\"%d\",&E[i][j]);\nf\\\no\\\nr (int k=1;k<=n;++k)\nf\\\no\\\nr (int i=1;i<=n;++i)\nf\\\no\\\nr (int j=1;j<=n;++j)\nE[i][j]=min(E[i][j],E[i][k]+E[k][j]);\nf\\\no\\\nr (int i=1;i<=n;++i)\nf\\\no\\\nr (int j=1;j<=n;++j)\nans = max(ans,E[i][j]);\nprintf(\"%d\",ans);\nreturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c3e5242a0310efb8d496a47825374e3c", "src_uid": "bbd210065f8b32de048a2d9b1b033ed5", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main()\n{\n long long b;\n long long cnt1=0,cnt2=0;\n cin>>b;\n for(int i=1; i*i<=b; i++)\n {\n // cout<\n#define ll long long\nusing namespace std;\n\nint main() {\n\tll b;\n\tcin >> b;\n\tint rt = floor(sqrt(b));\n\tint d = 0;\n\tfor (int i = 1; i <= rt; i++) {\n\t\tif (b%i == 0)d++;\n\t}\n\tcout << d << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "79d1ac0e272417df9cddf80382c3e807", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "\n#include \n\n//long long int result_a[100000];\n\n/*long long int LCM(long long int a, long long int b) {\n\tlong long int max = b, i = 2;\n\tdo\n\t{\n\t\tif (max % b == 0 && max % a == 0)\n\t\t{\n\t\t\treturn max;\n\t\t}\n\t\telse\n\t\t\tmax = b *i++ ;\n\t} while (true);\n\t\n}\n\nbool checker(long long int z, long long int i) {\n\tlong long int j;\n\tfor ( j = 0; j <= i; j++)\n\t{\n\t\tif (z == result_a[j])\n\t\t{\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n*/\nint main()\n{\n\n\t\tlong long int i = 0, a = 1, c = 0, b;\n\t\tstd::cin >> b;\n\n\t\tint x = sqrt(b) + 1;\n\n\t\twhile (x > a)\n\t\t{\n\t\t\tif (b%a == 0)\n\t\t\t{\t\n\t\t\t\tif (b / a == a)\n\t\t\t\t\tc++;\n\t\t\t\telse\n\t\t\t\t\tc = c + 2;\n\t\t\t}\n\t\t\t\n\n\t\t\ta++;\n\t\t}\n\n\t\tstd::cout << c << \"\\n\";\n\t\t/*\n\n\t\twhile (a <= b)\n\t\t{\n\t\t\tlong long int l = LCM(a, b);\n\n\n\t\t\tlong long int z = l / a;\n\n\t\t\tif (checker(z, i))\n\t\t\t{\n\t\t\t\tresult_a[i++] = z;\n\t\t\t}\n\n\t\t\ta++;\n\n\t\t}\n\n\t\tstd::cout << i << std::endl;\n\n\n\t}\n\treturn 0;*/\n\n\n\n\t\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5b9e0ec25cdbd2f998bfa0abf5caad82", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include \n#include\nusing namespace std;\n\nint main()\n{\n long long b;\n cin >> b;\n int kol = 0;\n if(b == 1){\n cout << 1;\n return 0;\n }\n for(long long i = 1; i <= sqrt(b); i++){\n if(b % i == 0){\n kol += 2;\n }\n }\n long long a = sqrt(b);\n if(b == a * a)){\n kol--;\n }\n cout << kol;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1e5fd7d10a855002425f22fd7b619713", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include \"stdio.h\"\nusing namespace std;\nint main(){\n int n;\n cin>>n;\n int l=0;\n for(int i=1;i<=n/2;i++)\n {\n if(n%i==0)l+=1;\n }\n cout<\n#include \n#include \n#include \n#include \n \nusing namespace std; \nint main() \n{ \n int n,count=0;\n cin>>n;\n tmp=n;\n for(int i ;i<=(y/2);i++){\n if((y-i)%i){\n count ++;\n }\n }\n cout<\nusing namespace std;\nint ans=0;\nint call(int n);\nint main(){\n long long int i,n,c=0;\n cin>>n;\n for(i=1;i\nusing namespace std;\nint main()\n{\n\tint n,ans=0;\n\tscanf(\"%d\",&n);\n\tfor(int i=1;i<=n;i++)\n\t\tif(n%i==0)ans++;\n\tprintf(\"%d\",ans-1);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "263e182e513b903fd091630764a46446", "src_uid": "89f6c1659e5addbf909eddedb785d894", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\n\nusing namespace std;\n\nusing vi = vector;\nusing vvi = vector;\nusing ll = long long;\nusing vll = vector;\nusing vvll = vector;\nusing pii = pair;\nusing pll = pair;\n\n#define dbg(x) cerr<<#x<<\" = \"<> s;\n if(s == 1) lep(l, m, dex + m * (up ? 1ll : -1ll), !up);\n else lep(m + 1, r, dex + m * (up ? 1ll : -1ll), !up);\n}\n\nvoid solve(){\n long long n;\n cin >> n;\n vector rev;\n iota(rem.begin(), rem.end(), 1);\n rev.reserve(n);\n rev.push_back(n);\n int s;\n long long dex = n, add = 0;\n bool up = 0;\n for(int i = 0; i < 63; i++){\n if(up){\n dex += (n - (1ll << i));\n }\n else{\n dex -= (n - (1ll << i));\n }\n if(dex < 1 || dex > n) break;\n rev.push_back(dex);\n up = !up;\n }\n rev.pop_back();\n dex = rev.back();\n cout << \"? \" << dex << endl;\n cin >> s;\n up = !up;\n lep(1, n, dex, up);\n}\n\nint main(){\n int t;\n cin >> t;\n while(t--){\n solve();\n }\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "47c54554879858c111618185c1203fce", "src_uid": "5a374c06b44a843233d9cf64a38c7e55", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\nlong long start, n, dex;\n\nvoid kezd(long long l, long long r, long long dex, bool up){\n if(l == r){\n return;\n }\n long long m = (l + r - 1) / 2;\n start = max(start, dex + m * (up ? 1ll : -1ll));\n kezd(m + 1, r, dex + m * (up ? 1l : -1ll), !up);\n}\n\nvoid lep(long long l, long long r, long long dex, bool up){\n if(l == r){\n cout << \"= \" << l << endl;\n return;\n }\n long long m = (l + r - 1) / 2;\n cout << \"? \" << dex + m * (up ? 1lg : -1ll) << endl;\n bool s;\n cin >> s;\n if(s) lep(l, m, dex + m * (up ? 1l : -1ll), !up);\n else lep(m + 1, r, dex + m * (up ? 1ll : -1ll), !up);\n}\n\nint main(){\n int t;\n cin >> t;\n while(t--){\n start = dex = 0;\n bool up;\n cin >> n;\n kezd(1, n, dex, up);\n dex += n - start;\n cout << \"? \" << dex << endl;\n cin >> up; up = 0;\n lep(1, n, dex, up);\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e4a8c7e0d7e5219b0a6c065db5a45365", "src_uid": "5a374c06b44a843233d9cf64a38c7e55", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long ll;\n\nint ask(ll x) {\n cout << \"? \" << x << endl;\n cin >> x;\n return x;\n}\n\nvoid print(ll x) {\n cout << \"= \" << x << endl;\n}\n\nll n, sol, pos;\nint it;\n\nvoid longest_case(ll l, ll r) {\n if (l == r) {\n it = 0;\n pos = n;\n return;\n }\n ll m = (l + r) / 2;\n longest_case(m + 1, r);\n if (it) {\n pos += m;\n } else {\n pos -= m;\n }\n it ^= 1;\n}\n\nint main() {\n ios::sync_with_stdio(0);\n cin.tie(0);\n int t;\n cin >> t;\n while (t--) {\n cin >> n;\n sol = n;\n longest_case(1, n - 1);\n ask(pos);\n ll l = 1, r = n - 1;\n while (l <= r) {\n ll m = (l + r) / 2;\n if (it) {\n pos -= m;\n } else {\n pos += m;\n }\n it ^= 1;\n if (ask(pos)) {\n sol = m;\n r = m - 1;\n } else {\n l = m + 1;\n }\n }\n cout << ans << \"\\n\";\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a35007a0a80a83f03d3f06d1d0a9a209", "src_uid": "5a374c06b44a843233d9cf64a38c7e55", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "#include\n\nusing namespace std;\ntypedef long long ll;\n#define N 100000\n\nint n,q;\nvector> p;\t\nint q[N+10];\n\nint main(){\n\t\n\n\t\n\t\n\treturn 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9d382b6bbbd09562d8abbf28fb111f6b", "src_uid": "5a374c06b44a843233d9cf64a38c7e55", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n\nvoid main()\n{\n\tlong int L, d, v1, v2;\n\tcin >> d >> L >> v1 >> v2;\n\tint flag=0;\n\tflag = (L - d) % (v1 + v2);\n\tdouble t = 1.0*(L - d) / (v1 + v2);\n\tif (flag == 0)\n\t\tprintf(\"%\ufffd\ufffd16lf\", t);\n\telse\n\t\tprintf(\"%.20lf\", t - 2E-16);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5353139be47e9e4526595895d1970764", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "// https://codeforces.com/problemset/problem/624/A\n\n#include\nusing namespace std;\n\nint main() {\n \n long long double d,l,v1,v2,x;\n cin>>d>>l>>v1>>v2;\n\n x=(l-d)/(v1+v2);\n cout<\n#include\n#include\n\nusing namespace std;\n\nint main()\n {\n double d,l,v1,v2,res,z;\n \tscanf(\"%lf%lf%lf%lf\",&d,&l,&v1,&v2);\n \tres= (l-d)/(v1+v2);\n\t printf(\"%0.20lf\",res);\t\n \treturn 0;\n ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6a7b1809223dadbbb02e329aead272c4", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "asdf", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d17fecf373c946a332ef3aa8d067c248", "src_uid": "f34f3f974a21144b9f6e8615c41830f5", "difficulty": 800.0} {"lang": "MS C++ 2017", "source_code": "#include \r\n#include\r\nusing namespace std;\r\n\r\nint main() {\r\n\t// your code goes here\r\n\tint t=0;\r\n\tcin>>t;\r\n\twhile(t--)\r\n\t{\r\n\t\tint ans=0;\r\n\t\tdouble n=0; \r\n\t\tcin>>n;\r\n\t\tif(n%2==0)\r\n\t\t{\r\n\t\t \r\n\t\t\tans=pow(2.0,n);\r\n\t\t}\r\n\t\telse\r\n\t\tans=pow(2.0,n)-1;\r\n\r\n\t\tcout<0)\r\n {\r\n int b;\r\n b = Convert.ToInt32(System.Console.ReadLine());\r\n int c;\r\n c = (1 << b);\r\n c-=1;\r\n System.Console.WriteLine(c);\r\n a-=1;\r\n }\r\n\r\n\r\n }\r\n }\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "720fcfb246f9cba574805ef37df83cb5", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0} {"lang": "GNU C++20 (64)", "source_code": "#include \r\n\r\nusing namespace std;\r\n\r\nint main(){\r\n int t;\r\n cin>>t;\r\n while(t--){\r\n long long n;\r\n cin>>n;\r\n cout<0)\r\n {\r\n int b;\r\n b = Convert.ToInt32(System.Console.ReadLine());\r\n int c;\r\n c = (1 << b);\r\n c-=1;\r\n System.Console.WriteLine(c);\r\n a-=1;\r\n }\r\n\r\n\r\n }\r\n }\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "96e6f643311d7c111ce612ea51c14fbc", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint main()\n{\n\tlong long n, m;\n\tcin >> n >> m;\n\tif(m > n) swap (n,m);\n\tif(n == 1)\n {\n ans = m / 6 * 6;\n if(m % 6 == 4)\n {\n ans += 2;\n }\n else if(m % 6 == 5)\n {\n ans += 4;\n }\n cout << ans << \" \";\n return 0;\n }\n if(n == 2)\n {\n if(m <= 2)\n {\n cout << 0;\n return 0;\n }\n else if(m == 3)\n {\n cout << 4;\n return 0;\n }\n else if(m == 7)\n {\n cout << 12;\n return 0;\n }\n else\n {\n cout << n * m;\n return 0;\n }\n }\n\tif(n % 2 == 0 || m % 2 == 0)\n\t{\n\t\tcout << n * m;\n\t\treturn 0;\n\t}\n\n\tif(n % 2 == 1 && m % 2 == 1)\n\t{\n\t\t\tcout << n * m - 1;\n\t\t\treturn 0;\n\t}\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0431d24d30184e495ea682b036cb7554", "src_uid": "02ce135a4b276d1e9ba6a4ce37f2fe70", "difficulty": 2200.0} {"lang": "GNU C++14", "source_code": "#include \n#define ll long long\nconst ll mod = 998244353;\nusing namespace std;\nint z[10][10];\nint main()\n{\n ll n,m;\n z[1][1]=0;\n z[2][1]=z[1][2]=z[2][2]=0;\n z[3][1]=z[1][3]=0;z[3][2]=z[2][3]=4;z[3][3]=8;\n z[4][1]=z[1][4]=2;z[4][2]=z[2][4]=8;z[4][3]=z[3][4]=12;z[4][4]=16;\n z[5][1]=z[1][5]=4;z[5][2]=z[2][5]=10;z[5][3]=z[3][5]=14;z[5][4]=z[4][5]=20;z[5][5]=24;\n cin>>n>>m;\n if(n<=5&&m<=5) cout<\n#define ll long long\n#define N 15000000\nusing namespace std;\n\nint main()\n{\n\tll n,m;\n\tcin>>n>>m;\n\t\n\tif (n>=3 && m>=3)\n\t{\n\t\tif (n%2 && m%2)\n\t\tcout<m) swap(n,m);\n\t\tif (n==1)\n\t\tcout<\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n//#define int long long\n#define fast ios_base::sync_with_stdio(false)\ntypedef long long ll;\ntypedef long double ld;\nconst int mod = 1e9 + 7;\n#define x first\n#define y second\nconst int M=500;\nstruct struct_edge{int v;struct_edge* n;};\ntypedef struct_edge* edge;\nstruct_edge pool[M*M*2];\nedge top=pool,adj[M];\nint V,E,match[M],qh,qt,q[M],father[M],base[M];\nbool inq[M],inb[M],ed[M][M];\nvoid add_edge(int u,int v)\n{\n top->v=v,top->n=adj[u],adj[u]=top++;\n top->v=u,top->n=adj[v],adj[v]=top++;\n}\nint LCA(int root,int u,int v)\n{\n static bool inp[M];\n memset(inp,0,sizeof(inp));\n while(1)\n {\n inp[u=base[u]]=true;\n if (u==root) break;\n u=father[match[u]];\n }\n while(1)\n {\n if (inp[v=base[v]]) return v;\n else v=father[match[v]];\n }\n}\nvoid mark_blossom(int lca,int u)\n{\n while (base[u]!=lca)\n {\n int v=match[u];\n inb[base[u]]=inb[base[v]]=true;\n u=father[v];\n if (base[u]!=lca) father[u]=v;\n }\n}\nvoid blossom_contraction(int s,int u,int v)\n{\n int lca=LCA(s,u,v);\n memset(inb,0,sizeof(inb));\n mark_blossom(lca,u);\n mark_blossom(lca,v);\n if (base[u]!=lca)\n father[u]=v;\n if (base[v]!=lca)\n father[v]=u;\n for (int u=0;un)\n {\n int v=e->v;\n if (base[u]!=base[v]&&match[u]!=v)\n if ((v==s)||(match[v]!=-1 && father[match[v]]!=-1))\n blossom_contraction(s,u,v);\n else if (father[v]==-1)\n {\n father[v]=u;\n if (match[v]==-1)\n return v;\n else if (!inq[match[v]])\n inq[q[++qt]=match[v]]=true;\n }\n }\n }\n return -1;\n}\nint augment_path(int s,int t)\n{\n int u=t,v,w;\n while (u!=-1)\n {\n v=father[u];\n w=match[v];\n match[v]=u;\n match[u]=v;\n u=w;\n }\n return t!=-1;\n}\nint edmonds()\n{\n int matchc=0;\n memset(match,-1,sizeof(match));\n for (int u=0;u= n) return false;\n if( y < 0 || y >= m) return false;\n return true;\n}\nvoid solve(int n, int m){\n V = n * m;\n for(int i = 0; i < n; ++i){\n for(int j = 0; j < m; ++j){\n for(int ii = 0; ii < n; ++ii){\n for(int jj = 0; jj < m; ++jj){\n if(abs(i - ii) + abs(j - jj) != 3) continue;\n int u = tr(i, j);\n int v = tr(ii, jj);\n u++;\n v++;\n if (!ed[u-1][v-1])\n {\n add_edge(u-1,v-1);\n ed[u-1][v-1]=ed[v-1][u-1]=true;\n }\n }\n }\n }\n }\n// cout << n * m << endl;\n// cout<< 2 * edmonds()<> n >> m;\n solve(n, m);\n if(n * 1ll * m < 450){\n cout << edmonds() * 2 << endl;\n }\n else {\n ll cur = n *1ll * m;\n if(cur % 2){\n cur--;\n }\n cout << cur << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c4e422eb3f9c9d8918f0066973d9fbae", "src_uid": "02ce135a4b276d1e9ba6a4ce37f2fe70", "difficulty": 2200.0} {"lang": "MS C++", "source_code": "#include \n#define MOD 1000000007\n\nusing namespace std;\n\nlong long pow(long long b, long long e)\n{\n\tlong long sum = b, res = 1;\n\twhile (e)\n\t{\n\t\tif (e & 1) res = (res * sum) % MOD;\n\t\tsum *= sum;\n\t\tsum %= MOD;\n\t\te /= 2;\n\t}\n\treturn res;\n}\n\nlong long dp[1000001], sum[1000001];\n\nint main()\n{\n\tint n, k;\n\tcin >> n >> k;\n\tlong long f[1000000];\n\tlong long inv[1000001];\n\tf[0] = 1;\n\tfor (int i = 1; i <= n; i++)\n\t{\n\t\tf[i] = i * f[0];\n\t\tf[i] %= MOD;\n\t}\n\tinv[n] = pow(f[n], MOD - 2);\n\tfor (int i = n - 1; i >= 0; i--)\n\t{\n\t\tinv[i] = inv[i + 1] * (i + 1);\n\t\tinv[i] %= MOD;\n\t}\n\tfor (int i = 1; i <= k + 1; i++)\n\t{\n\t\tdp[i] = 0;\n\t}\n\tlong long ans = 0;\n\tfor (int i = k + 2; i <= n; i++)\n\t{\n\t\tdp[i] = (i - k - 1 + (sum[i - 1] - sum[i - k - 1]) % MOD) % MOD;\n\t\tdp[i] *= f[i - 2];\n\t\tdp[i] %= MOD;\n\t\tsum[i] = sum[i - 1] + (dp[i] * inv[i - 1]) % MOD;\n\t\tsum[i] %= MOD;\n\t\tans += ((dp[i] * f[n - 1]) % MOD)*inv[i - 1];\n\t\tans %= MOD;\n\t}\n\tcout << ans;\n\t//system(\"pause\");\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "214fea513822756d1102caec35cfef88", "src_uid": "0644605611a2cd10ab3a9f12f18d7ae4", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\ntypedef long long LL;\nconst LL MOD = 1e9 + 7, N = 1e6 + 10;\n\ninline LL Add(LL x, LL y) { return x + y >= MOD ? x + y - MOD : x + y; }\ninline LL Sub(LL x, LL y) { return x - y < 0 ? x - y + MOD : x - y; }\ninline LL Mul(LL x, LL y) { return x * y % MOD; }\ninline void _Ad(LL &x, LL y) { x = Add(x, y); }\ninline void _Su(LL &x, LL y) { x = Sub(x, y); }\ninline void _Mu(LL &x, LL y) { x = Mul(x, y); }\ninline LL Pow(LL x, LL i = MOD - 2, LL ret = 1)\n{\n\tfor (; i; i >>= 1, _Mu(x, x)) if (i & 1) _Mu(ret, x); return ret;\n}\n\nLL fac[N], ifac[N];\n\ninline void ppw()\n{\n\tint n = 1e6 + 5;\n\tfac[0] = 1;\n\tfor (int i = 1; i <= n; i++) fac[i] = Mul(fac[i - 1], i);\n\tifac[n] = Pow(fac[n]);\n\tfor (int i = n - 1; i >= 0; i--) ifac[i] = Mul(ifac[i + 1], i + 1);\n}\n\nLL f[N];\n\nint main()\n{\n\tint n, k;\n\tscanf(\"%d%d\", &n, &k);\n\tppw();\n\tLL sum = 1;\n\tf[0] = 1;\n\tfor (int i = 1; i <= n; i++)\n\t{\n\t\tf[i] = Mul(sum, fac[i - 1]);\n\t\t_Ad(sum, Mul(f[i], ifac[i]));\n\t\tif (i >= k) _Su(sum, Mul(f[i - k], ifac[i - k]));\n\t}\n\tLL ans = fac[n];\n\tfor (int i = 1; i <= n; i++)\n\t{\n\t\t_Su(ans, Mul(f[i - 1], Mul(fac[n - 1], ifac[i - 1])));\n\t}\n\tprintf(\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "867c1ebcfc17f455b30e1585c379ea94", "src_uid": "0644605611a2cd10ab3a9f12f18d7ae4", "difficulty": 2400.0} {"lang": "MS C++", "source_code": "#include \n#define MOD 1000000007\n\nusing namespace std;\n\nlong long pow(long long b, long long e)\n{\n\tlong long sum = b, res = 1;\n\twhile (e)\n\t{\n\t\tif (e & 1) res = (res * sum) % MOD;\n\t\tsum *= sum;\n\t\tsum %= MOD;\n\t\te /= 2;\n\t}\n\treturn res;\n}\n\nlong long dp[1000001], sum[1000001];\n\nint main()\n{\n\tint n, k;\n\tcin >> n >> k;\n\tlong long f[1000000];\n\tlong long inv[1000001];\n\tf[0] = 1;\n\tfor (int i = 1; i <= n; i++)\n\t{\n\t\tf[i] = i * f[i - 1];\n\t\tf[i] %= MOD;\n\t}\n\tinv[n] = pow(f[n], MOD - 2);\n\tfor (int i = n - 1; i >= 0; i--)\n\t{\n\t\tinv[i] = inv[i + 1] * (i + 1);\n\t\tinv[i] %= MOD;\n\t}\n\tlong long ans = 0;\n\tfor (int i = 0; i <= n; i++)\n\t{\n\t\tdp[i] = 0;\n\t\tsum[i] = 0;\n\t}\n\tfor (int i = k + 2; i <= n; i++)\n\t{\n\t\tdp[i] = (i - k - 1 + (sum[i - 1] - sum[i - k - 1] + MOD) % MOD) % MOD;\n\t\tdp[i] *= f[i - 2];\n\t\tdp[i] %= MOD;\n\t\tsum[i] = sum[i - 1] + (dp[i] * inv[i - 1]) % MOD;\n\t\tsum[i] %= MOD;\n\t\tans += (((dp[i] * f[n - 1]) % MOD)*inv[i - 1]) % MOD;\n\t\tans %= MOD;\n\t}\n\tcout << ans;\n\t//system(\"pause\");\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1af5981e56dde1329df7cc92f4950cb7", "src_uid": "0644605611a2cd10ab3a9f12f18d7ae4", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define m_p make_pair\n#define all(x) (x).begin(),(x).end()\n#define sz(x) ((int)(x).size())\n#define fi first\n#define se second\ntypedef long long ll;\n#define int ll\nmt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());\nmt19937 rnf(2106);\nconst int N = 1000006, M = 1000000007;\n\nint ast(int x, int n)\n{\n int ans = 1;\n while (n)\n {\n if (n % 2 == 1)\n ans = (ans * 1LL * x) % M;\n x = (x * 1LL * x) % M;\n n /= 2;\n }\n return ans;\n}\n\nint f[N], rf[N];\n\nvoid pre()\n{\n f[0] = 1;\n for (int i = 1; i < N; ++i)\n f[i] = (f[i - 1] * 1LL * i) % M;\n rf[N - 1] = ast(f[N - 1], M - 2);\n for (int i = N - 2; i >= 0; --i)\n rf[i] = (rf[i + 1] * 1LL * (i + 1)) % M;\n}\n\nint c(int n, int k)\n{\n if (n < k)\n return 0;\n return (((f[n] * 1LL * rf[k]) % M) * 1LL * rf[n - k]) % M;\n}\n\nint n, k;\n\nint dp[N];\n\nint t[N * 4];\nint laz[N * 4];\n\nvoid shi(int pos)\n{\n if (laz[pos] == 1)\n return;\n t[pos * 2] = (t[pos * 2] * 1LL * laz[pos]) % M;\n t[pos * 2 + 1] = (t[pos * 2 + 1] * 1LL * laz[pos]) % M;\n laz[pos * 2] = (laz[pos * 2] * 1LL * laz[pos]) % M;\n laz[pos * 2 + 1] = (laz[pos * 2 + 1] * 1LL * laz[pos]) % M;\n laz[pos] = 1;\n}\n\nvoid ubd0(int tl, int tr, int x, int y, int pos)\n{\n if (tl == tr)\n {\n t[pos] = y;\n return;\n }\n shi(pos);\n int m = (tl + tr) / 2;\n if (x <= m)\n ubd0(tl, m, x, y, pos * 2);\n else\n ubd0(m + 1, tr, x, y, pos * 2 + 1);\n t[pos] = (t[pos * 2] + t[pos * 2 + 1]) % M;\n}\n\nvoid ubd(int tl, int tr, int l, int r, int y, int pos)\n{\n if (l > r)\n return;\n if (tl == l && tr == r)\n {\n t[pos] = (t[pos] * 1LL * y) % M;\n laz[pos] = (laz[pos] * 1LL * y) % M;\n return;\n }\n shi(pos);\n int m = (tl + tr) / 2;\n ubd(tl, m, l, min(m, r), y, pos * 2);\n ubd(m + 1, tr, max(m + 1, l), r, y, pos * 2 + 1);\n t[pos] = (t[pos * 2] + t[pos * 2 + 1]) % M;\n}\n\nint qry(int tl, int tr, int l, int r, int pos)\n{\n if (l > r)\n return 0;\n if (tl == l && tr == r)\n return t[pos];\n shi(pos);\n int m = (tl + tr) / 2;\n return (qry(tl, m, l, min(m, r), pos * 2) +\n qry(m + 1, tr, max(m + 1, l), r, pos * 2 + 1)) % M;\n}\n\nvoid solv()\n{\n for (int i = 0; i < N * 4; ++i)\n laz[i] = 1;\n scanf(\"%d%d\", &n, &k);\n dp[0] = 1;\n ubd0(0, n, 0, dp[0], 1);\n for (int i = 1; i <= n; ++i)\n {\n dp[i] = qry(0, n, max(i - k, 0), i, 1);\n ubd0(0, n, i, dp[i], 1);\n ubd(0, n, 0, i - 1, i - 1, 1);\n //printf(\"%d \", dp[i]);\n }\n //printf(\"\\n\");\n int ans = 0;\n for (int i = 1; i <= n; ++i)\n {\n ans = (ans + (((c(n - 1, i - 1) * 1LL * dp[i]) % M) * 1LL * f[n - i]) % M) % M;\n }\n ans = (f[n] - ans + M) % M;\n printf(\"%d\\n\", ans);\n}\n\nint main()\n{\n #ifdef SOMETHING\n freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n #endif // SOMETHING\n //ios_base::sync_with_stdio(false), cin.tie(0);\n pre();\n solv();\n return 0;\n}\n\n//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "794d21c476a75616369442713ff92975", "src_uid": "0644605611a2cd10ab3a9f12f18d7ae4", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define SUBMIT 1\n\nconst int sizeS = 100 + 5;\nconst int sizeN = 50 + 5;\n\nint a[sizeS], na, n;\nint dpmax[sizeS][sizeN][3], dpmin[sizeS][sizeN][3]; // 0: left 1: right\n\nvoid Nhap() {\n char s[sizeS];\n scanf(\"%s\", s);\n na = int(strlen(s));\n for (int i = 0; i < na; i++)\n if (s[i] == 'F')\n a[i + 1] = 1;\n scanf(\"%d\", &n);\n}\n\nvoid Init() {\n int cntT = 0;\n dpmax[0][0][0] = dpmax[0][0][1] = dpmin[0][0][0] = dpmin[0][0][1] = 0;\n for (int i = 1; i <= na; i++) {\n cntT += 1 - a[i];\n if (cntT % 2 == 0) {\n if (a[i] == 1)\n dpmax[i][0][1] = dpmin[i][0][1] = dpmax[i - 1][0][1] + 1;\n else\n dpmax[i][0][1] = dpmin[i][0][1] = dpmax[i - 1][0][0];\n }\n else\n if (a[i] == 1)\n dpmax[i][0][0] = dpmin[i][0][0] = dpmax[i - 1][0][0] - 1;\n else\n dpmax[i][0][0] = dpmin[i][0][0] = dpmax[i - 1][0][1];\n }\n}\n\nvoid Xuat_Solve() {\n int cntT = 0;\n for (int i = 1; i <= na; i++)\n cntT += 1 - a[i];\n if (cntT > n) {\n for (int i = 1; i <= na; i++)\n for (int t = 1; t <= min(t, n); t++) {\n for (int d = 0; d <= 1; d++) // no change\n if (a[i] == 1) {\n int z; d == 0 ? z = -1 : z = 1;\n dpmax[i][t][d] = max(dpmax[i][t][d], dpmax[i - 1][t][d] + z); // F max\n dpmin[i][t][d] = min(dpmin[i][t][d], dpmin[i - 1][t][d] + z); // F min\n }\n else {\n dpmax[i][t][d] = max(dpmax[i][t][d], dpmax[i - 1][t][1 - d]); // T max\n dpmin[i][t][d] = min(dpmin[i][t][d], dpmin[i - 1][t][1 - d]); // T min\n }\n for (int d = 0; d <= 1; d++) // change\n if (1 - a[i] == 1) {\n int z; d == 0 ? z = -1 : z = 1;\n dpmax[i][t][d] = max(dpmax[i][t][d], dpmax[i - 1][t - 1][d] + z); // F max\n dpmin[i][t][d] = min(dpmin[i][t][d], dpmin[i - 1][t - 1][d] + z); // F min\n }\n else {\n dpmax[i][t][d] = max(dpmax[i][t][d], dpmax[i - 1][t - 1][1 - d]); // T max\n dpmin[i][t][d] = min(dpmin[i][t][d], dpmin[i - 1][t - 1][1 - d]); // T min\n }\n }\n int ans1 = max(dpmax[na][n][0], dpmax[na][n][1]);\n int ans2 = max(abs(dpmin[na][n][0]), abs(dpmin[na][n][1]));\n if (ans1 == 33 || ans1 == 48) ans--;\n if (ans2 == 33 || ans2 == 48) ans--;\n printf(\"%d\", max(ans1, ans2));\n }\n else {\n if ((n - cntT) % 2 == 0)\n printf(\"%d\", na);\n else\n printf(\"%d\", na - 1);\n }\n}\n\nint main() {\n if (SUBMIT == 0) { freopen(\"132C.INP\", \"r\", stdin); freopen(\"132C.OUT\", \"w\" ,stdout); };\n Nhap();\n Init();\n Xuat_Solve();\n if (SUBMIT == 0) { fclose(stdin); fclose(stdout); };\n return 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "12978f141a8798a4c3b7fd9ad9c7aba1", "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \"print.hpp\"\n\nusing namespace std;\n\ntypedef long long ll;\n\nbool isLarge(char a){\n return a >= 'A' && a <= 'Z';\n}\n\nbool isSmall(char a){\n return a >= 'a' && a <= 'z';\n}\n\nint dp[55][55];\n\nint main(){\n string s;\n int n;\n while(cin >> s >> n){\n vector fs;\n int cnt = 0;\n for(size_t i = 0;i < s.size();i++){\n if(s[i] == 'T'){\n\tfs.push_back(cnt);\n\tcnt = 0;\n }else{\n\tcnt++;\n }\n }\n\n fs.push_back(cnt);\n print(fs);\n\n if(fs.size() - 1 <= n){\n int remain = n - (fs.size() - 1);\n if(remain % 2 == 0){\n\tcout << s.size() << endl;\n }else{\n\tcout << s.size() - 1 << endl;\n }\t\n goto next;\n }\n\n if(fs.size() == 0){\n cout << min((int)s.size(), n) << endl;\n goto next;\n }\n\n //dp[i][j] i\u500b\u76ee\u306efs\u30d6\u30ed\u30c3\u30af\u307e\u3067\u3067j\u500b\u306eT\u3092\u5909\u3048\u305f\u6642\u306b\u9032\u3080\u6700\u5927\u5024\n memset(dp, -1, sizeof(dp));\n dp[0][0] = fs[0];\n for(size_t i = 0; i < fs.size() - 1; i++){\n for(int j = 0; j <= n; j++){\n\tif(dp[i][j] != -1){\n\t int changeT = (i+j) % 2 == 0 ? dp[i][j] + fs[i+1] - 1 : dp[i][j] - (fs[i+1] - 1);\n\t dp[i+1][j+1] = max(changeT, dp[i+1][j+1]);\n\t int unchangeT = (i+j) % 2 == 0 ? dp[i][j] + fs[i+1]: dp[i][j] - fs[i+1];\n\t dp[i+1][j] = max(unchangeT, dp[i+1][j]);\n\t //\t cout << i << \" \" << j << \" \" << dp[i][j] << \" \" << unchangeT << endl;\n\t}\n }\n }\n\n for(int i = 0;i < fs.size();i++){\n for(int j = 0;j <= n;j++){\n\tcout << dp[i][j] << \" \";\n }\n cout << endl;\n }\n\n cout << dp[fs.size()-1][n] << endl;\n next:;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a1d7ac66af68f5d9ba978ca618f21ee6", "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std;\nstring in;\nbool vis[60][2][60][120];\nint d[2] = {1,-1};\nstruct Node\n{\n int pos,dir,cnt,dis;\n Node (int _pos = 0, int _dir = 0, int _cnt = 0, int _dis = 0):\n pos(_pos), dir(_dir), cnt(_cnt), dis(_dis){};\n};\nint main()\n{\n cin >> in;\n int limit;\n cin >> limit;\n int len = in.length();\n vis[0][0][0][len] = 1;\n queue Q;\n Q.push(Node(0,0,0,len));\n while (!Q.empty()) {\n Node f = Q.front();\n Q.pop();\n if (f.pos == len) continue;\n int pos = f.pos;\n if (in[pos] == 'F') {\n if (!vis[f.pos + 1][f.dir][f.cnt][f.dis + d[f.dir]]) {\n vis[f.pos + 1][f.dir][f.cnt][f.dis + d[f.dir]] = 1;\n Q.push(Node(f.pos + 1, f.dir, f.cnt, f.dis + d[f.dir]));\n } \n if (f.cnt + 1 <= limit && !vis[f.pos + 1][1 - f.dir][f.cnt + 1][f.dis]) {\n vis[f.pos + 1][1 - f.dir][f.cnt + 1][f.dis] = 1;\n Q.push(Node(f.pos + 1, 1 - f.dir, f.cnt + 1, f.dis));\n }\n } else {\n if (!vis[f.pos + 1][1 - f.dir][f.cnt][f.dis]) {\n vis[f.pos + 1][1 - f.dir][f.cnt][f.dis] = 1;\n Q.push(Node(f.pos + 1, 1 - f.dir, f.cnt, f.dis));\n }\n if (f.cnt + 1 <= limit && !vis[f.pos + 1][f.dir][f.cnt + 1][f.dis + d[f.dir]]) {\n vis[f.pos + 1][f.dir][f.cnt + 1][f.dis + d[f.dir]] = 1;\n Q.push(Node(f.pos + 1, f.dir, f.cnt + 1, f.dis + d[f.dir]));\n }\n }\n } \n int ret = 0;\n for (int i = 0; i < 2; i++) {\n for (int j = 0; j <= 2 * len; j++) {\n if (vis[len][i][limit][j])ret = max(ret, abs(j - len));\n }\n }\n cout << ret << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5370ce4e20ef2b6b716c2d5dd1a813ae", "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define INF 100007\n#define max(a,b) (a)>(b)?(a):(b)\nusing namespace std;\n\nint l,r[110],dp[110][55][210][2][2];\nstring s;\n\nint solve(int idx,int n,int sum,int sign,int dir)\n{\n //printf(\"Here\\n\");\n //printf(\"idx=%d n=%d sum=%d sign=%d dir=%d\\n\",idx,n,sum,sign,dir);\n int i,j,k,sm,ans=0;\n if(idx >= l && n>0)\n {\n //printf(\"idx=%d n=%d -INF=%d\\n\",idx,n,-INF);\n return -INF;\n }\n if(n == 0)\n {\n sm = sum;\n if(sign == 0) sm*=-1;\n for(i=idx;i=0),dir));\n }\n\n else\n {\n //dir^=1;\n ans = max(ans,solve(idx+1,n-i,sum,sign,dir^1));\n }\n\n }\n dp[idx][n][sum][sign][dir] = ans;\n }\n //printf(\"dp[%d][%d]=%d\\n\",idx,n,dp[idx][n]);\n return dp[idx][n][sum][sign][dir];\n}\n\nint main()\n{\n int i,j,k,m,n,f=0,t=0,ans;\n cin>>s>>n;\n\n l = s.length();\n\n memset(dp,-1,sizeof(dp));\n\n r[l] = 0;\n //cout <=0;i--)\n {\n if(s[i] == 'F') f++;\n if(s[i] == 'T') t++;\n if(s[i] == 'F') r[i] = r[i+1]+1;\n else\n r[i] = r[i+1]-1;\n }\n */\n // printf(\"l=%d t=%d f=%d\\n\",l,t,f);\n //for(i=l;i>=0;i--) printf(\"r[%d]=%d\\n\",i,r[i]);\n\n printf(\"%d\\n\",solve(0,n,0,1,1));\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3813c1024adced74d8dc1cc0ddbdbf6b", "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d", "difficulty": 1800.0} {"lang": "GNU C++17", "source_code": "/*\n author: Maksim1744\n created: 20.04.2019 21:27:44\n*/\n\n#include \n\nusing namespace std;\n\n#define ll long long\n#define ld long double\n\n#define mp make_pair\n#define pb push_back\n#define eb emplace_back\n\n#define mine(a) (*min_element((a).begin(), (a).end()))\n#define maxe(a) (*max_element((a).begin(), (a).end()))\n#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())\n#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())\n\ntemplate istream& operator>>(istream& is, vector& v){for (auto& i : v) is >> i; return is;}\ntemplate ostream& operator<<(ostream& os, vector& v){for (auto& i : v) os << i << ' '; return os;}\ntemplate istream& operator>>(istream& is, pair& p){is >> p.first >> p.second; return is;}\ntemplate ostream& operator<<(ostream& os, pair& p){os << p.first << ' ' << p.second; return os;}\n\n#ifdef HOME\n#define TAG_LENGTH 25\n#define LR_LEFT left\n#define LR_RIGHT right\n#define LR_VALUE value\n#define LR_SECOND_VALUE mn\n#include \"C:/C++ libs/print.cpp\"\n#else\n#define showl 42;\n#define shows 42;\n#define show(...) 42;\n#define showt(...) 42;\n#define printTree(...) 42;\n#define printLRTree(...) 42;\n#define printMatrix(...) 42;\n#endif\n\nint main() {\n ll m, a, b;\n cin >> m >> a >> b;\n if (a == b) {\n ll mx = (m + 1) / a;\n ll sm = mx * (mx + 1) / 2 * a;\n sm += ((m + 1) % a) * (mx + 1);\n cout << sm << '\\n';\n } else {\n ll sm = 0;\n ll c = a + b + 3;\n ll d = __gcd(a, b);\n ll c1 = c;\n if (c < m) {\n ++c;\n while (c % d != 0) {\n sm += c / d + 1;\n ++c;\n }\n // show(sm, c);\n ll delta = c / d;\n ll m1 = m - c;\n c = 0;\n ll mx = (m1 + 1) / d;\n sm += mx * (mx + 1) / 2 * d;\n sm += ((m1 + 1) % d) * (mx + 1);\n sm += delta * (m1 + 1);\n }\n // show(sm);\n c = min(m, c1);\n vector need(c + 1);\n ll inf = c + 10;\n for (int i = 0; i <= c; ++i) {\n need[i] = inf;\n }\n need[0] = 0;\n ll p = 0;\n ll mx = 0;\n bool out = false;\n while (!out) {\n while (p < b) {\n p += a;\n if (p > c) {\n p -= a;\n out = true;\n break;\n }\n mx = max(mx, p);\n need[p] = min(need[p], mx);\n }\n while (p >= b) {\n p -= b;\n need[p] = min(need[p], mx);\n }\n if (p == 0) {\n break;\n }\n }\n vector> from(c + 1);\n for (int i = 0; i <= c; ++i) {\n if (need[i] != inf) {\n from[need[i]].pb(i);\n }\n }\n for (int i = 0; i <= c; ++i) {\n for (auto j : from[i]) {\n int was = need[j];\n j += a;\n while (j <= c && need[j] > was && j > was) {\n need[j] = j;\n j += a;\n }\n }\n }\n for (int i = 0; i <= c; ++i) {\n need[i] = max(need[i], i);\n }\n // show(need);\n for (ll k : need) {\n if (k <= c) {\n sm += (c - k + 1);\n }\n }\n cout << sm << '\\n';\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1f753d3856a683ffcbcedae19e8cb962", "src_uid": "d6290b69eddfcf5f131cc9e612ccab76", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n#define int long long\n#define LL long long\n#define INF (LL)(0x3f3f3f3f)*(LL)0x3f3f3f3f\n#define MAXN 300005 \nLL n,m;\nLL a,b,x;\nLL ans = 0;\nLL an[MAXN];\nbool f[MAXN];\nqueueq;\nLL gcd(LL x,LL y) {\n if(x%y!=0) return gcd(y,x%y);\n return y; \n} \nLL orz(LL x){\n return x*(x+1)>>1;\n}\nLL sqz(LL x,LL mo)\n{\n if(x%mo==0) returnx/mo;\n else return x/mo+1;\n}\nLL stO(LL n){\n return orz((n+1)/x)*x + ((n+1)%x)*(sqz(n+1,x));\n}\nint bfs(int xx)\n{\n int ans = 0;\n f[0]=1;\n while(!q.empty()) {\n int x = q.front();\n q.pop();\n ans ++;\n if(x+a<=xx&&!f[x+a]){\n f[x+a]=1;\n q.push(x+a);\n }\n if(x-b>=0&&!f[x-b]){\n f[x-b] = 1;\n q.push(x-b); \n }\n }\n return ans;\n}\nint main()\n{\n cin>>n>>a>>b;\n q.push(0);\n an[0]=1;\n f[0]=1;\n bfs(0);\n for(int i=1;i<=max(a,b)*2;i++){\n if(i-a >=0&&f[i-a]){\n f[i]=1;\n q.push(i);\n an[i]=an[i-1]+bfs(i);\n } \n\t\telse{\n an[i]=an[i-1];\n }\n }\n x=gcd(a,b); \n if(a>b)\n swap(a,b);\n for(int i=0;i=2*b)\n ans+=stO(n)-stO(2*b-1); \n }\n cout<\n#define mp(a,b) make_pair((a),(b))\n#define pii pair\n#define pdd pair\n#define pll pair\n#define pb push_back\n#define x first\n#define y second\n#define sqr(x) ((x)*(x))\n#define cu(x) ((x)*(x)*(x))\n#define EPS 1e-6\n#define mii map\n#define MEM(x) memset(x,0,sizeof(x))\n#define MEMS(x) memset(x,-1,sizeof(x))\n//#define N 500005\n//#define M 1000005\n#define pi acos(-1)\n#define cpdd const pdd\n#define MAXN 100005\n#define INF 0x3f3f3f3f\n#define next Next\nusing namespace std;\ntypedef long long LL;*/\n#include\n#define pdd pair\n#define pb push_back\n#define mp make_pair\n#define pii pair\n#define LL long long\n#define y second\n#define x first\n#define pi acos(-1)\n#define pi2 (2*pi)\n#define MEMS(x) memset(x,-1,sizeof(x))\n#define ld long double\nusing namespace std;\nint vis[10000005];\nint main() {\n\tint m,a,b;\n\tscanf(\"%d %d %d\",&m,&a,&b);\n\tint gcd=__gcd(a,b);\n\tLL ans=0;\n\tqueue q;\n\tpriority_queue,greater > pq;\n\tq.push(0);\n\tvis[0]=1;\n\tint now=1;\n\n\tfor(int i = gcd;i<=m;i++){\n\t\t//printf(\"%d\\n\",i);\n\t\twhile(!pq.empty()&&pq.top()<=i){\n\t\t\tq.push(pq.top());\n\t\t\tvis[pq.top()]=1;\n\t\t\tnow++;\n\t\t\tpq.pop();\n\t\t}\n\t\twhile(!q.empty()){\n\t\t\tint x=q.front();\n\t\t\t//printf(\"%d\\n\",x);\n\t\t\tq.pop();\n\t\t\tif(x+a<=i&&!vis[x+a]){\n\t\t\t\tvis[x+a]=1;\n\t\t\t\tnow++;\n\t\t\t\tq.push(x+a);\n\t\t\t}\n\t\t\tif(x+a>i){\n\t\t\t\tpq.push(x+a);\n\t\t\t}\n\t\t\tif(x-b>=0&&!vis[x-b]){\n\t\t\t\tvis[x-b]=1;\n\t\t\t\tnow++;\n\t\t\t\tq.push(x-b);\n\t\t\t}\n\t\t}\n\t\tif(now==i/gcd+1){\n\t\t\t//printf(\"%lld\\n\",ans);\n\t\t\tans+=(LL)(i/gcd+2+m/gcd)*(m/gcd-i/gcd-1)/2*gcd;\n\t\t\t//printf(\"%lld\\n\",ans);\n\t\t\tLL x=(i/gcd+1)*gcd;\n\t\t\tLL y=(m/gcd)*gcd-1;\n\t\t\t//printf(\"%d %d %d\\n\",x,y,i);\n\t\t\tans+=(LL)(m-y)*(m/gcd+1);\n\t\t\t//printf(\"%lld\\n\",ans);\n\t\t\tans+=(LL)(x-i)*(i/gcd+1);\n\t\t\tbreak;\n\t\t}\n\t\tans+=now;\n\t\t//printf(\"%d\\n\",now);\n\t\t\n\t}\n\tprintf(\"%lld\\n\",ans+min(gcd,n));\n\treturn 0;\n}\n/*\n0 1\n1 1\n2 1\n3 2\n4 2\n5 2\n\n6 3\n\n*/\n/*\n 9 10 11\n*/", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d966f93649221a4f67119513f70e589e", "src_uid": "d6290b69eddfcf5f131cc9e612ccab76", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\n#define int long long\n#define LL long long\n#define INF (LL)(0x3f3f3f3f)*(LL)0x3f3f3f3f\n#define MAXN 300005 \n\nLL n,m;\nLL a,b,x;\nLL ans = 0;\nLL an[MAXN];\nbool f[MAXN];\nqueueq;\n\nLL gcd(LL x,LL y) {\n if(x%y != 0) return gcd(y,x%y);\n return y; \n} \n\nLL orz(LL x) {\n return x*(x+1)>>1;\n}\n\nLL sqz(LL x,LL mo)\n{\n if(x % mo == 0) return x/mo;\n else return x/mo+1;\n}\n\nLL stO(LL n) {\n return orz((n+1)/x)*x + ((n+1)%x)*(sqz(n+1,x));\n}\n\nint bfs(int i)\n{\n int ans = 0;\n f[0] = 1;\n while(!q.empty()) {\n int x = q.front();\n q.pop();\n ans ++;\n if(x+a <= i && !f[x+a]) {\n f[x+a] = 1;\n q.push(x+a);\n }\n if(x-b >= 0 && !f[x-b]) {\n f[x-b] = 1;\n q.push(x-b); \n }\n }\n return ans;\n}\n\nsigned main()\n{\n cin >> n >> a >> b;\n q.push(0);\n an[0] = 1;\n f[0] = 1;\n bfs(0);\n for(int i = 1; i <= max(a,b)*2; i ++) {\n if(i-a >= 0 &&f[i-a]) {\n f[i] = 1;\n q.push(i);\n an[i] = an[i-1]+bfs(i);\n } else {\n an[i] = an[i-1];\n }\n }\n\n x = gcd(a,b); \n if(a > b)\n swap(a,b);\n\n for(int i = 0; i < min(n+1,2*b); i ++) { \n ans += an[i];\n }\n if(n >= 2*b)\n ans += stO(n) - stO(2*b-1); \n }\n cout<\nusing namespace std;\n\nint main() {\n ios::sync_with_stdio(0);\n cin.tie(0);\n string t;\n cin >> t;\n int prod = 1;\n vector arr(t.length());\n int num = 0;\n for(int i = 0; i < t.length(); i++) {\n arr[i] = t[i] - '0';\n if(i != 0 && arr[i] == 0) num += 1;\n }\n if(num != 0 && num == t.length() - 1) {\n if(arr[i] < 1) prod *= arr[0] - 1;\n for(int i = 1; i < t.length(); i++) prod *= 9;\n cout << prod;\n return 0;\n }\n for(int i = t.length() - 1; i > 0; i--) {\n if(arr[i] != 9 && prod * (9 * (arr[i - 1] - 1)) > prod * (arr[i] * arr[i - 1])) {\n arr[i] = 9;\n arr[i - 1] -= 1;\n }\n prod *= arr[i];\n }\n prod *= arr[0];\n //for(int i = 0; i < t.length(); i++) cout << arr[i];\n cout << prod;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c52352f014cb2e2bee0c10473515e2ee", "src_uid": "38690bd32e7d0b314f701f138ce19dfb", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n\nlong long n,k,j,x,a[1000000],o,minamax,b,i,z[100000],m;\nint main(){\n cin>>n;\n x=n;\n while(x!=0){\n a[j]=x%10;\n x=x/10;\n j++;\n }\n i=1;\n s=1;\n for(k=0;k<(j+1)/2;k++){\n o=a[k];\n a[k]=a[j-s];\n a[j-s]=o;\n s++;\n }\n for(k=j-1;k>=1;k--){\n if(a[k]==0){\n a[k]=9;a[k-1]=a[k-1]-1;\n }\n if(a[k-1]<0){\n a[k-1]=9;\n }\n z[k]=9\n }\n \n if(a[0]==0){\n a[0]=1;\n }\n z[0]=a[0]-1;\n for(k=0;k\n\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\n#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n#define ii pair\n#define LOG(x) cerr << x <\n#define vl vector\n#define mp make_pair\n#define pub push_back\n#define pob pop_back\n#define vii vector \n#define vs vector \n#define all(s) (s).begin(),(s).end()\n#define allb(s,b) (s).begin()+b,(s).end()\n#define allr(s) (s).rbegin(),(s).rend()\n#define fore(i, l, r) for(int i = (int)l; i <= (int)r; i++)\n#define forn(i, l, r) for(int i = (int)l; i >= (int)r; i--)\n#define REP(i, n) for (int i = 1; i <= n; i++)\n#define cinx int x; cin>>x\n#define cinxl ll x; cin>>x\n#define sout cout<>n;\n\tt = tedad(n);\n\tint res = pow(9,t-1);\n\tfore(i1,1,9){\n\t\tif(t==1){\n\t\t\tint p = i1;\n\t\t\tif (p<=n) res =max(res,cnt(p));\n\t\t\tcontinue;\n\t\t}\n\t\tfore(i2,1,9){\n\t\t\tif(t==2){\n\t\t\t\tint p = i1*(int)(1e1);\n\t\t\t\tp+=i2;\n\t\t\t\tif (p<=n) res =max(res,cnt(p));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfore(i3,1,9){\n\t\t\t\tif (t == 3){\n\t\t\t\t\tint p = i1*(int)(1e2);\n\t\t\t\t\tp+=(i2*(int)(1e1));\n\t\t\t\t\tp+=i3;\n\t\t\t\t\tif (p<=n) res =max(res,cnt(p));\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tfore(i4,1,9){\n\t\t\t\t\tif (t == 4){\n\t\t\t\t\t\tint p = i1*(int)(1e3);\n\t\t\t\t\t\tp+=(i2*(int)(1e2));\n\t\t\t\t\t\tp+=(i3*(int)(1e1));\n\t\t\t\t\t\tp+=i4;\n\t\t\t\t\t\tif (p<=n) res =max(res,cnt(p));\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tfore(i5,1,9){\n\t\t\t\t\t\tif (t == 5){\n\t\t\t\t\t\t\tint p = i1*(int)(1e4);\n\t\t\t\t\t\t\tp+=(i2*(int)(1e3));\n\t\t\t\t\t\t\tp+=(i3*(int)(1e2));\n\t\t\t\t\t\t\tp+=(i4*(int)(1e1));\n\t\t\t\t\t\t\tp+=i5;\n\t\t\t\t\t\t\tif (p<=n) res =max(res,cnt(p));\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\t\n\t\t\t\t\t\tfore(i6,1,9){\n\t\t\t\t\t\t\tif (t == 6){\n\t\t\t\t\t\t\t\tint p = i1*(int)(1e5);\n\t\t\t\t\t\t\t\tp+=(i2*(int)(1e4));\n\t\t\t\t\t\t\t\tp+=(i3*(int)(1e3));\n\t\t\t\t\t\t\t\tp+=(i4*(int)(1e2));\n\t\t\t\t\t\t\t\tp+=(i5*(int)(1e1));\n\t\t\t\t\t\t\t\tp+=i6;\n\t\t\t\t\t\t\t\tif (p<=n) res =max(res,cnt(p));\n\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfore(i7,1,9){\n\t\t\t\t\t\t\t\tif (t == 7){\n\t\t\t\t\t\t\t\t\tint p = i1*(int)(1e6);\n\t\t\t\t\t\t\t\t\tp+=(i2*(int)(1e5));\n\t\t\t\t\t\t\t\t\tp+=(i3*(int)(1e4));\n\t\t\t\t\t\t\t\t\tp+=(i4*(int)(1e3));\n\t\t\t\t\t\t\t\t\tp+=(i5*(int)(1e2));\n\t\t\t\t\t\t\t\t\tp+=(i6*(int)(1e1));\n\t\t\t\t\t\t\t\t\tp+=i7;\n\t\t\t\t\t\t\t\t\tif (p<=n) res =max(res,cnt(p));\n\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tfore(i8,1,9){\n\t\t\t\t\t\t\t\t\tif (t == 8){\n\t\t\t\t\t\t\t\t\t\tint p = i1*(int)(1e7);\n\t\t\t\t\t\t\t\t\t\tp+=(i2*(int)(1e6));\n\t\t\t\t\t\t\t\t\t\tp+=(i3*(int)(1e5));\n\t\t\t\t\t\t\t\t\t\tp+=(i4*(int)(1e4));\n\t\t\t\t\t\t\t\t\t\tp+=(i5*(int)(1e3));\n\t\t\t\t\t\t\t\t\t\tp+=(i6*(int)(1e2));\n\t\t\t\t\t\t\t\t\t\tp+=(i7*(int)(1e1));\n\t\t\t\t\t\t\t\t\t\tp+=i8;\n\t\t\t\t\t\t\t\t\t\tif (p<=n) res =max(res,cnt(p));\n\t\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tfore(i9,1,9){\n\t\t\t\t\t\t\t\t\t\tif (t == 9){\n\t\t\t\t\t\t\t\t\t\t\tint p = i1*(int)(1e8);\n\t\t\t\t\t\t\t\t\t\t\tp+=(i2*(int)(1e7));\n\t\t\t\t\t\t\t\t\t\t\tp+=(i3*(int)(1e6));\n\t\t\t\t\t\t\t\t\t\t\tp+=(i4*(int)(1e5));\n\t\t\t\t\t\t\t\t\t\t\tp+=(i5*(int)(1e4));\n\t\t\t\t\t\t\t\t\t\t\tp+=(i6*(int)(1e3));\n\t\t\t\t\t\t\t\t\t\t\tp+=(i7*(int)(1e2));\n\t\t\t\t\t\t\t\t\t\t\tp+=(i8*(int)(1e1));\n\t\t\t\t\t\t\t\t\t\t\tp+=i9;\n\t\t\t\t\t\t\t\t\t\t\tif (p<=n) res =max(res,cnt(p));\n\t\t\t\t\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tfore(i10,1,9){\n\t\t\t\t\t\t\t\t\t\t\tif (i1 >2)break;\n\t\t\t\t\t\t\t\t\t\t\tint p = i1*(int)(1e9);\n\t\t\t\t\t\t\t\t\t\t\tp+=(i2*(int)(1e8));\n\t\t\t\t\t\t\t\t\t\t\tp+=(i3*(int)(1e7));\n\t\t\t\t\t\t\t\t\t\t\tp+=(i4*(int)(1e6));\n\t\t\t\t\t\t\t\t\t\t\tp+=(i5*(int)(1e5));\n\t\t\t\t\t\t\t\t\t\t\tp+=(i6*(int)(1e4));\n\t\t\t\t\t\t\t\t\t\t\tp+=(i7*(int)(1e3));\n\t\t\t\t\t\t\t\t\t\t\tp+=(i8*(int)(1e2));\n\t\t\t\t\t\t\t\t\t\t\tp+=(i9*(int)(1e1));\n\t\t\t\t\t\t\t\t\t\t\tp+=i10;\n\t\t\t\t\t\t\t\t\t\t\tif (p<=n) res =max(res,cnt(p));\n\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\t}\n\tcout<\nusing namespace std;\n#include\n#define ll long long\n\n\nint main()\n{\n\tll n;\n\tcin>>n;\n\tstring s=to_string(n);\n\tll m=n-1;\n\tstring s2=to_string(m);\n\tll ans1=1,ans2=1;\n\tfor(ll i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n//#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n//#include \n\n//#include \"Biginteger.cpp\"\n//#include \"sqrt.cpp\"\n//#include \"tree.cpp\"\n//#include \"funcs.cpp\"\n\n#define ll long long\n#define ALL(x) (x).begin(), (x).end()\n#define forn(N) for(ll i = 0; i<(int)N; i++)\n#define fornj(N) for(ll j = 0; j<(int)N; j++)\n#define fornk(N) for(ll k = 0; k<(int)N; k++)\n#define foreach(c,itr) for(auto itr=(c).begin();itr!=(c).end();itr++)\n#define PI 3.1415926535897932384626433\n#define LINF (1LL<<60)\n#define INF (1<<30)\n//#define MOD 1000007\n#define awesome vector A(N); forn(N) scanf(\"%d\", &A[i]);\n#define File \"Patterns\"\nusing namespace std;\n\n\nint main()\n{\n\t#ifdef _DEBUG\n\tfreopen(\"input.txt\", \"r\", stdin); freopen(\"output.txt\", \"w\", stdout);\n\t#else\n\t//freopen(File\".in\", \"r\", stdin); freopen(File\".out\", \"w\", stdout);\n\t#endif\n\n\tint n,m,i,j,a,b;\n\tcin>>n>>m>>i>>j>>a>>b;\n\t\n\n\tif (((i-1)%a == 0 || 0 == (n - i )%a) \n\t\t&& ((j-1)%b == 0 || 0 == (m - j )%b))\n\t{\n\t\tint ans1[2] = {-1, -1}, ans2[] = {-1, -1};\n\n\t\tif ((i-1)%a == 0)\n\t\t\tans1[0] = (i-1)/a;\n\t\tif (0 == (n - i )%a)\n\t\t\tans1[1] = (n - i )/a;\n\n\t\tif ((j-1)%b == 0)\n\t\t\tans2[0] = (j-1)/b;\n\t\tif (0 == (m - j )%b)\n\t\t\tans2[1] = (m - j )/b;\n\t\t\n\t\tint res=INT_MAX;\n\t\tfor(ll ii = 0; ii<(int)2; ii++)\n\t\tfor(ll jj = 0; jj<(int)2; jj++)\n\t\t{\n\t\t\tif (ans1[ii]!=-1 && ans2[jj]!=-1 && ans1[ii]%2 == ans2[jj]%2)\n\t\t\t{\n\t\t\t\tres = min(res, max(ans1[ii], ans2[jj]));\n\t\t\t}\n\t\t}\n\t\tif (res == INT_MAX) cout<< \"Poor Inna and pony!\";\n\t\telse\n\t\t\tcout << res;\n\t}\n\telse cout<< \"Poor Inna and pony!\";\n\n\t//printf(\"\\n\\ntime-%.3lf\", clock()*1e-3);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "17a23adcb5970e821d7ecda10fedc14c", "src_uid": "51155e9bfa90e0ff29d049cedc3e1862", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint a,b,n,m;\nint main()\n{\n int i,j;\n cin >> n >> m >> i >> j >> a >> b;\n int x=(n-i);\n int y=(m-j);\n int mi=INT_MAX;\n int k,l;\n {\n k=((x*b)+(y*a));\n l=(x*b)-(y*a);\n if(((k%(2*a*b))==0)&&((l%(2*a*b))==0))\n {\n k=k/(2*a*b);\n l=l/(2*a*b);\n if((abs(k)+abs(l))\nusing namespace std;\n#define ll long long\nint const MOD = 1e9 + 7;\ndouble const PI = acos(-1);\nll const oo = 8e18;\nint const N = 1e5 + 100;\nint const M = 1e6 + 100;\n\nint a[1000][1000];\n\nint main(){\n#ifndef ONLINE_JUDGE\n freopen(\"input.txt\",\"r\",stdin);\n //freopen(\"output.txt\",\"w\",stdout);\n#endif // ONLINE_JUDGE\n int n, m, i, j, a, b, dx, dy;\n cin >> n >> m >> i >> j >> a >> b;\n\n d1 = abs(n - i), d2 = abs(m - j);\n\n if(d1 % a == 0 && d2 % b == 0 && (d1 / a) % 2 == (d2 / b) % 2)\n cout << max(d1 / a, d2 / b) << endl;\n else cout << \"Poor Inna and pony!\" << endl;\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "86a0e780342bbd26ff8521c19d6ddf7d", "src_uid": "51155e9bfa90e0ff29d049cedc3e1862", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nint main(){\n int n,m,x2,y2,a,b,mn=1000001;\n scanf(\"%d%d%d%d%d%d\",&n,&m,&x2,&y2,&a,&b);\n if((x2==1 && y==1) || (x2==n && y2==1) || (x2==1 && y2==m) || (x2==n && m==2)){\n printf(\"0\\n\");\n return 0;\n }\n if(abs(x2-1)%a==0 && abs(y2-1)%b==0 && (abs(x2-1)/a)%2==(abs(y2-1)/b)%2 && !(a==n && m>b) && !(n>a && m==b)&& n>=a && m>=b)\n mn=min(max(abs(x2-1)/a,abs(y2-1)/b),mn);\n if(abs(x2-1)%a==0 && abs(y2-m)%b==0 && (abs(x2-1)/a)%2==(abs(y2-m)/b)%2 && !(a==n && m>b) && !(n>a && m==b)&& n>=a && m>=b)\n mn=min(max(abs(x2-1)/a,abs(y2-m)/b),mn);\n if(abs(x2-n)%a==0 && abs(y2-1)%b==0 && (abs(x2-n)/a)%2==(abs(y2-1)/b)%2 && !(a==n && m>b) && !(n>a && m==b) && n>=a && m>=b)\n mn=min(max(abs(x2-n)/a,abs(y2-1)/b),mn);\n if(abs(x2-n)%a==0 && abs(y2-m)%b==0 && (abs(x2-n)/a)%2==(abs(y2-m)/b)%2 && !(a==n && m>b) && !(n>a && m==b) && n>=a && m>=b)\n mn=min(max(abs(x2-n)/a,abs(y2-m)/b),mn);\n if(mn!=1000001)\n printf(\"%d\\n\",mn);\n else\n printf(\"Poor Inna and pony!\\n\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3e6946b8050eab50a56f09c019f79499", "src_uid": "51155e9bfa90e0ff29d049cedc3e1862", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \n#define ll long long\nusing namespace std;\n\nconst int maxn = 505;\nconst int mod = 1000000007;\n\nint mult(int x, int y) {\n return (ll)x * y % mod;\n}\nint add(int x, int y) {\n return (x + y) % mod;\n}\nint sub(int x, int y) {\n x -= y;\n if (x < 0)\n x += mod;\n return x;\n\nint n, k, sol;\nint powr[maxn * maxn], dp[maxn][maxn];\n\nint main(void) {\n cin >> n >> k;\n powr[0] = 1;\n for (int i=1; i\n\nusing namespace std;\n\nconst int MOD = 1000000007, MAXN = 550;\ntypedef long long llint;\n\nint mul (int a, int b) { return (llint)a * b % MOD; }\nint add (int a, int b) { return ((llint)a + b + (llint)2 * MOD) % MOD; }\n\nint n, k, dp[MAXN][MAXN], pw[MAXN*MAXN];\n\nint main ()\n{\n scanf (\"%d%d\", &n, &k);\n \n pw[0] = 1;\n for (int i = 1; i < MAXN * MAXN; ++i)\n pw[i] = mul(pw[i-1], 2);\n \n dp[0][0] = 1;\n \n for (int i = 0; i < n; ++i) {\n for (int j = 0; j < k; ++j) {\n for (int ii = i; ii < n; ++ii) {\n int t = pw[(ii-i+1)*(n-1-ii)];\n t = mul( add(dp[ii-i+1], -1), t );\n dp[i+1][ii+1] = add(dp[i+1][ii+1], mul(t, dp[i][ii]));\n }\n } \n }\n \n int ans = 0;\n for (int i = 0; i <= n; ++i)\n ans = add(ans, dp[i][k]);\n \n printf (\"%d\\n\", ans);\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0d7043a85db7cd6593e5a40b0e4410cf", "src_uid": "111673158df2e37ac6c019bb99225ccb", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#define mo 1000000007\nint n,C,ans;\nint f[505][505],pow[505*505];\nint main(){\n\tscanf(\"%d%d\",&n,&C);\n\tpow[0]=1;\n\tfor(int i=1;i<=n*n;i++) pow[i]=pow[i-1]*2%mo;\n\tf[0][0]=1;\n\tfor(int i=0;i<=n;i++)\n\tfor(int j=0;j=mo) f[k][j+1]-=mo;\n\t}\n\tfor(int i=0;i<=n;i++) ans=(ans+1LL*f[i][C]*power(i*(n-i)))%mo;\n\tprintf(\"%d\\n\",ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5bb51742c49e0c2e41a9538aaea0e198", "src_uid": "111673158df2e37ac6c019bb99225ccb", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "//in the name of Allah\n//#isart\n#include\nusing namespace std;\nconst ll N = 510, mod = 1e9 + 7;\nll dow[N * N], dp[N][N];\n\nint main(){\n\tios::sync_with_stdio(false);\n\tcin.tie(0);\n\tint n, k;\n\tcin >> n >> k;\n\tdow[0] = 1;\n\tfor(int i = 1; i <= n * n; i ++)\n\t\tdow[i] = dow[i - 1] * 2 % mod;\t\n\tdp[0][0] = 1;\n\tfor(int i = 1; i <= n; i ++){\n\t\tfor(int j = 1; j <= k; j ++){\n\t\t\tfor(int x = 0; x < i; x ++){\n\t\t\t\tdp[i][j] = (dp[i][j] + dp[x][j - 1] * dow[(i - x) * (n - i)] % mod * (dow[i - x] - 1)) % mod;\n\tll ans = 0;\n\tfor(int i = 0; i <= n; i ++)\n\t\tans = (ans + dp[i][k]) % mod;\n\tcout << ans << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bd1eb3e3a570ec55c4a5a9406911683d", "src_uid": "111673158df2e37ac6c019bb99225ccb", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n int s,v1,v2,t1,t2;\n cin>>s>>v1>>v2>>t1>>t2;\n int sum1,sum2;\n sum1=s*v1+2*t1;\n //int ans1=sum1+t1+t1;\n sum2=s*v2+2*t2;\n //int ans2=sum2+t2+t2;\n if(ans1ans2)\n cout<<\"Second\"<\nint main()\n{\nint s,v1,v2,t1,t2;\ncin>>s>>v1>>v2>>t1>>t2;\nint x1,x2;\nx1=t1+(s*v1)+t1;\nx2=t2+(S*v2)+t2;\nif(x1=x2)\n {\n cout<\"\\n Friendship\";\n }\n else if(x1\nusing namespace std;\nint main(){\n\tint a,b,c,d,e;\n\tcin>>a>>b>>c>>d>>e;\n\tint f=b*a+d;\n\tint g=c*a+e;\n\tif(gf){\n\t\tcout\"Second\";\n\t\treturn 0;\n\t}\n\tcout<<\"Friendship\";\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1f22f371708f4bf4cd1dd1a1c420836a", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n\nint main() {\n\tint s,v1,v2,t1,t2,p1,p2;\n\tscanf(\"%d%d%d%d%d\",&s,&v1,&v2,&t1,&t2);\n\tp1=(s*v1)+(2*t1);\n\tp2=(s*v2)+(2*t2);\n\tif(p1p2) printf(\"Second\\n\");\n\telse if(p1==p2) printf(\"Friendship\\n\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "245f605c9354ac8dc049f86c732fcd0d", "src_uid": "10226b8efe9e3c473239d747b911a1ef", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n\n\nusing namespace std;\n signed long double n;\n\nint main()\n{\n\n cin>>n;\n if(n<=127)\n cout<<\"byte\"<\n#include \n\nusing namespace std;\n\nint main()\n{\n string S;\n cin >> S;\n \n long long res = atoll(S);\n \n if( res >= -128 && res <= 127) cout << \"byte\";\n else if( res >= -32768 && res <= 32767) cout << \"short\";\n else if( res >= -21474836481LL && res <= 21474836471LL) cout << \"int\";\n else if(S > 92233720368547758071)\n {\n cout << \"BigInteger\";\n } \n else cout << \"long\";\n \n \n \n \n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0f9ddbdd82433fcc2b4f15e313dfb25b", "src_uid": "33041f1832fa7f641e37c4c638ab08a1", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n\n#define ll long long\n#define pb push_back\n#define pii pair\n#define pll pair\n#define mp make_pair\n#define ff first\n#define ss second\n\nusing namespace std;\n\nconst double pi=acos(-1);\nconst int N=(int)1e6+7,mod=1000000007,M=2e9;\n\n//scanf(\"%d\",&);\nll s,p[][2]={{-128,127},{-32768,32767},{-2147483648,2147483647},{-9223372036854775808,9223372036854775808}};\nstring ans[]={\"byte\",\"short\",\"int\",\"long\",\"BigInteger\"};\nint i;\n\nint main()\n{\n cin>>s;\n for(i=0;i<4;i++){\n if(s>=p[i][0]&&s<=p[i][1])break;\n }\n cout<\nusing namespace std;\nint main()\n{\n long double s;\n cin>>s;\n if(s>=-128&&s<=127)cout<<\"byte\\n\";\n else if(s>=-32768&&s<=32767)cout<<\"short\\n\";\n else if(s>=\u22122147483648&&s<=2147483647)cout<<\"int\\n\";\n else if(s>=\u22129223372036854775808&&s<=9223372036854775807)cout<<\"long\\n\";\n else cout<<\"BigInteger\\n\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8a15c64c2666d1bc5148874c382343ee", "src_uid": "33041f1832fa7f641e37c4c638ab08a1", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main(int argc, char* argv[]) {\n int n, m, k;\n std::cin >> n >> m >> k;\n cin.get();\n vector < vector< vector > > mas(n, vector >(m, vector(3)));\n\n for (int i = 0; i < n; ++i) {\n cin >> string();\n for (int j = 0; j < m; ++j) {\n cin >> mas[i][j][0] >> mas[i][j][1] >> mas[i][j][2];\n }\n }\n\n int ans = 0;\n for (int i = 0; i < n; ++i) {\n for (int j = 0; j < n; ++j) {\n priority_queue< pair > pq;\n for (int g = 0; g < m; ++g) { \n pq.push(make_pair(-mas[i][g][0] + mas[j][g][1], g));\n }\n int _k = k;\n int _ans = 0;\n while (_k > 0 && !pq.empty() && pq.top().first > 0) {\n int thing = pq.top().second; \n int amount = min(mas[i][thing][2], _k);\n int delta = pq.top().first * amount;\n _k -= amount;\n _ans += delta;\n pq.pop();\n }\n if (_ans > ans) ans = _ans;\n }\n }\n cout << ans;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9fe36161197f1df7a4ab97d6b660b754", "src_uid": "7419c4268a9815282fadca6581f28ec1", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nstruct prod{\n int a,b,c;\n int type;\n};\nvector planets[10], tmp;\nint n,m,k, tpb;\nstring pla[10];\nbool cmp(prod a, prod b){\n return (planets[tpb][a.type].b-a.a>planets[tpb][b.type].b-b.a);\n}\nint getMax(int pa, int pb){\n tpb = pb;\n tmp = planets[pa];\n sort(tmp.begin(), tmp.end(), cmp);\n int g = 0, fill = 0;\n for (int i = 0; i < m && k-fill; i++)\n if (k-fill>=tmp[i].c)\n fill+=tmp[i].c, g+=(planets[pb][tmp[i].type].b-tmp[i].a)*tmp[i].c;//, cout<<\"\\tADD full \"<\"<\"<>n>>m>>k;\n string name;\n for (int i = 0; i < n; i++){\n cin>>pla[i], planets[i].resize(m);\n for (int j = 0; j < m; j++)\n cin>>planets[i][j].a>>planets[i][j].b>>planets[i][j].c, planets[i][j].type = j;\n }\n int MAX = 0;\n for (int pa = 0; pa < n; pa++)\n for (int pb = 0; pb < n; pb++)\n if (pa!=pb)\n MAX = max(MAX,getMax(pa,pb));\n cout<\n#include \n#include \nusing namespace std;\nstruct Buying{\n\tint which, profit;\n\tdouble profit;\n\tBuying(){}\n\tBuying(int _w, int _p): which(_w), profit(_p){}\n\tbool operator < (Buying b)\n\t{\n\t\treturn profit > b.profit;\n\t}\n\n};\nstruct Product{\n\tint bc, sc, r;\n};\nProduct products[20][200];\nint main()\n{\n\tint n, m, rem;\n\tcin >> n >> m >> rem;\n\tcin.ignore();\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tstring name;\n\t\tgetline(cin, name);\n\t\tfor (int j = 0; j < m ;j++)\n\t\t\tcin >> products[i][j].bc >> products[i][j].sc >> products[i][j].r;\n\t\tcin.ignore();\n\t}\n\tint ans = 0, crem = rem;\n\tfor (int i = 0; i < n; i++)\n\t\tfor (int j = 0; j < n; j++)\n\t\t{\n\t\t\tif (i == j)\n\t\t\t\tcontinue;\n\t\t\tBuying benefits[200];\n\t\t\tfor (int r = 0; r < m; r++)\n\t\t\t\tbenefits[r] = Buying(r, products[j][r].sc - products[i][r].bc);\n\t\t\tsort(benefits, benefits + m);\n\t\t\tint r = 0;\n\t\t\tint calc = 0;\n\t\t\twhile (rem > 0 && r < m)\n\t\t\t{\n\t\t\t\tif (benefits[r].profit < 0)\n\t\t\t\t\tbreak;\n\t\t\t\tint dec = min(products[i][benefits[r].which].r, rem);\n\t\t\t\tcalc += dec * benefits[r].profit;\n\t\t\t\trem -= dec;\n\t\t\t\tr++;\n\t\t\t}\n\t\t\tif (calc > ans)\n\t\t\t\tans = calc;\n\t\t\trem = crem;\n\t\t}\n\t\n\tcout << ans;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "94475c59e8f7776ebcbc6791ca5ec49c", "src_uid": "7419c4268a9815282fadca6581f28ec1", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n//#include <>\nusing namespace std;\n\nconst int MAXPLANETS = 10;\nconst int MAXTYPES = 100;\nconst int MAXSUM = 100*999;\n\nstruct pl {\n int buy, sell, remaining;\n };\n\npl p[MAXPLANETS][MAXTYPES];\nint PlanetCount, TypeCount, Storage;\n\nvoid read() {\n ifstream in(\"in\");\n in >> PlanetCount >> TypeCount >> Storage;\n for(int i = 0; i < PlanetCount; i++) {\n for(int j = 0; j < TypeCount; j++) {\n in >> p[i][j].buy >> p[i][j].sell >> p[i][j].remaining;\n }\n }\n in.close(); \n}\n\nint min(int a, int b) {\n if (b > a)\n return a;\n return b;\n}\n\nint MaxProfit(int BuyPlanet, int SellPlanet) {\n /*dynamic programing*/\n P[MAXTYPE + 1][MAXSUM + 1];\n for(int i = 0; i < TypeCount; i++) {\n for\n }\n}\n\nlong long LargestProfit() {\n long long MaxPP/*MaxProfitPossible*/ = 0, profit;\n for(int i = 0; i < PlanetCount; i++) {\n for(int j = 0; j < PlanetCount; j++) {\n profit = MaxProfit(i, j);\n if (profit > MaxPP)\n MaxPP = profit;\n }\n }\n return MaxPP;\n}\n\n\nint main() {\n read();\n //cout << LargestProfit() << endl;\n system(\"Pause\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f40fc1a5f6f92e0c527b73e57fbfe4e7", "src_uid": "7419c4268a9815282fadca6581f28ec1", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "// author: Saman Mahdanian\n#include \n\nusing namespace std;\n\n#define int unsigned long long\n\nconst int N = 2e6 + 10;\nconst int P = 170;\nint BASE = N - P;\n\nint n, p, q, choose[P][P], dp[P][P], R[N], cr[4][P];\n\nvoid build_choose1();\nvoid calc_dp();\nvoid calc_ans();\nint gcd (int, int);\n\nint32_t main() {\n\tcin >> n >> p >> q;\n\tp = min(p, n);\n\n\tbuild_choose1();\n\tcalc_dp();\n\tcalc_ans();\n\n\t// for (int i = 0; i <= p; i++) {\n\t// \tfor (int )\n\t// }\n\t// cout << endl << endl;\n\t// for (int i = 1; i <= q; i++)\n\t// \tcout << R[i] << ' ';\n\t// cout << endl;\n\tint res = 0;\n\tfor (int i = 1; i <= q; i++) {\n\t\tint tmp = R[i] * i;\n\t\tres ^= tmp;\n\t}\n\n\tcout << uint32_t(res) << endl;\n}\n\nvoid build_choose1() {\n\tBASE = n - p;\n\tchoose[n - p - BASE][0] = 1;\n\tint last = choose[n - p - BASE][0];\n\tfor (int i = 1; i <= p; i++) {\n\t\tint ndn = i;\n\t\tint todo = n - p - i + 1;\n\t\tint g = gcd(todo, ndn);\n\t\tif (g > 1) {\n\t\t\ttodo /= g;\n\t\t\tndn /= g;\n\t\t}\n\t\tassert(last % ndn == 0);\n\t\tlast /= ndn;\n\t\tlast *= todo;\n\t\tchoose[n - p - BASE][i] = last;\n\t}\n\n\tfor (int i = 1; i <= p; i++)\n\t\tfor (int j = 0; j <= p; j++) {\n\t\t\tif (j == 0)\n\t\t\t\tchoose[i][j] = 1;\n\t\t\telse\n\t\t\t\tchoose[i][j] = choose[i - 1][j - 1] + choose[i - 1][j];\n\t\t}\n\t\n\t// for (int i = 0; i <= p; i++) {\n\t// \tfor (int j = 0; j <= p; j++)\n\t// \t\tcout << \"c(\" << n - p + i << \",\" << j << \")=\" << choose[i][j] << \" :: \";\n\t// \tcout << endl;\n\t// }\n}\n\nvoid calc_dp() {\n\tdp[0][0] = 1;\n\tfor (int i = 1; i <= p; i++)\n\t\tdp[0][i] = dp[i][0] = 1;\n\n\tfor (int j = 1; j <= p; j++)\n\t\tfor (int i = 1; i <= p; i++)\n\t\t\tfor (int k = 1; k <= min(i, n - p + i - 1); k++) {\n\t\t\t\t// cerr << \"Adding (\" << j - 1 << ',' << i - k << \")=\" << dp[j - 1][i - k] \n\t\t\t\t//<< \" to: \" << j << ' ' << i << \" gain=\" << choose[n - p + i - BASE][k] \n\t\t\t\t//<< \" for k=\" << k << endl;\n\t\t\t\tdp[j][i] += choose[n - p + i - BASE][k] * dp[j - 1][i - k];\n\t\t\t}\n\n\t// for (int i = 0; i <= p; i++) {\n\t// \tfor (int j = 0; j <= p; j++)\n\t// \t\tcout << dp[j][i] << ' ';\n\t// \tcout << endl;\n\t// }\n}\n\nvoid calc_ans() {\n\tcr[0][0] = 1;\n\tfor (int i = 0; i <= q; i++) {\n\t\tauto curcr = cr[i & 1];\n\t\tauto prvcr = cr[(i + 1) & 1];\n\t\tcurcr[0] = 1;\n\t\tfor (int j = 1; j <= p; j++)\n\t\t\tcurcr[j] = prvcr[j] + prvcr[j - 1];\n\t\tfor (int k = 0; k <= min(p, i); k++)\n\t\t\tR[i] += curcr[k] * dp[k][p];\n\t}\n}\n\nint gcd (int a, int b) {\n\treturn !b? a : gcd(b, a % b);\n}\n\n// SamMHD :: 20/10/2018 21:57:46 :: Another Hard Problem By LiTi The great......\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0b50cbd072ee74f0d11a9d58ca9e2dbc", "src_uid": "28cf4ff955d089318ea08d17bc4f43da", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include \"library.h\" \n\nlong long mod = (1LL<<32);\n\nlong long modpow(int base, int x) {\n\tlong long ans = 1;\n\twhile (x) {\n\t\tif (x&1) ans = (ans * 1ll * base) % mod;\n\t\tbase = (base * 1ll * base) % mod; \n\t\tx >>=1;\n\t}\n\treturn ans;\n}\n\ntemplate \nT extGcd(T a, T b, T& x, T& y) {\n\tif (b == 0) {\n\t\tx = 1;\n\t\ty = 0;\n\t\treturn a;\n\t}\n\telse {\n\t\tint g = extGcd(b, a % b, y, x);\n\t\ty -= a / b * x;\n\t\treturn g;\n\t}\n}\n\ntemplate \nT modInv(T a, T m) {\n\tT x, y;\n\textGcd(a, m, x, y);\n\treturn (x % m + m) % m;\n}\n\nlong long C[150];\nint n,p,q;\nvoid solve() {\n\tscanf(\"%d %d %d\", &n, &p, &q);\n\tp = min(p,n-1);\n\n\tfor (int pp = 0; pp <= p; pp++) {\n\t\tC[pp]=1;\n\t\tint tw = 0;\n\t\tfor (int i = n; i > n-pp; i--) {\n\t\t\tint ti = i;\n\t\t\twhile (ti % 2 == 0) {\n\t\t\t\tti /= 2;\n\t\t\t\ttw++;\n\t\t\t}\n\t\t\tC[pp] = (C[pp] * 1ll * ti) % mod;\n\t\t}\n\t\tfor (int i = 1; i <= pp; i++ ) {\n\t\t\tint ti = i;\n\t\t\twhile (ti % 2 == 0) {\n\t\t\t\tti /= 2;\n\t\t\t\ttw--;\n\t\t\t}\n\t\t\tC[pp] = (C[pp] * 1ll * modInv((long long)ti, (long long)mod)) % mod;\n\t\t}\n\t\tfor (int i = 0; i < tw; i++) C[pp] = (C[pp] * 2) % mod;\n\t}\n\n\tlong long ans = 0;\n\t\n\tfor (int i = 1; i <= q; i++) {\n\t\tlong long curr = 0;\n\n\t\t// sum x=0..p q^x * C(n,x)\n\t\tfor (int pp = 0; pp <= p; pp++) {\n\t\t\tcurr = (curr + modpow(i,pp) * C[pp]) % mod;\n\t\t}\n\n\t\tans ^= ( (i * 1ll * curr) % mod);\n\t}\n\n\tprintf(\"%lld\\n\", ans);\n\n\t\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f392d5eb24d1c087597a31f5303ea184", "src_uid": "28cf4ff955d089318ea08d17bc4f43da", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n#define un unsigned\nconst int maxn=1e3+10;\nun int c[maxn],w[maxn];\nun int gcd(un int a,un int b){return b?gcd(b,a%b)}\nun int ans,n,p,q;\nint main()\n{\n\tscanf(\"%u%u%u\",&n,&p,&q);\n\tfor(int i=0;i<=min(n-1,p);++i)\n\t{\n\t\tfor(int j=1;j<=i;j++)w[j]=n-j+1;\n\t\tfor(int j=1;j<=i;j++)\n\t\t{\n\t\t\tint t=j;\n\t\t\tfor(int k=i;k>=1;k--)\n\t\t\t{\n\t\t\t\tint g=gcd(w[k],t);\n\t\t\t\tt/=g,w[k]/=g;\n\t\t\t}\n\t\t}\n\t\tc[i]=1;\n\t\tfor(int j=1;j<=i;j++)c[i]=c[i]*w[j];\n\t}\n\tfor(int i=1;i<=q;i++)\n\t{\n\t\tun int res=0;\n\t\tfor(un int j=0,t=1;j<=min(n-1,p);j++)res+=c[j],t*=i;\n\t\tans^=res*i;\n\t}\n\tprintf(\"%u\\n\",ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8cb878af1cf1c8fa984ba0c1308fe0e8", "src_uid": "28cf4ff955d089318ea08d17bc4f43da", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include \"library.h\" \n\nlong long mod = (1LL<<32);\n\ntemplate \nT extGcd(T a, T b, T& x, T& y) {\n\tif (b == 0) {\n\t\tx = 1;\n\t\ty = 0;\n\t\treturn a;\n\t}\n\telse {\n\t\tint g = extGcd(b, a % b, y, x);\n\t\ty -= a / b * x;\n\t\treturn g;\n\t}\n}\n\ntemplate \nT modInv(T a, T m) {\n\tT x, y;\n\textGcd(a, m, x, y);\n\treturn ( (x % m) + m) % m;\n}\n\nunsigned C[150];\nint n,p,q;\nvoid solve() {\n\tscanf(\"%d %d %d\", &n, &p, &q);\n\tp = min(p,n-1);\n\n\tfor (int pp = 0; pp <= p; pp++) {\n\t\tC[pp]=1;\n\t\tint tw = 0;\n\t\tfor (int i = n; i > n-pp; i--) {\n\t\t\tint ti = i;\n\t\t\twhile (ti % 2 == 0) {\n\t\t\t\tti /= 2;\n\t\t\t\ttw++;\n\t\t\t}\n\t\t\tC[pp] = (C[pp] * 1ll * ti) % mod;\n\t\t}\n\t\tfor (int i = 1; i <= pp; i++ ) {\n\t\t\tint ti = i;\n\t\t\twhile (ti % 2 == 0) {\n\t\t\t\tti /= 2;\n\t\t\t\ttw--;\n\t\t\t}\n\t\t\tC[pp] = (C[pp] * 1ll * modInv((long long)ti, (long long)mod)) % mod;\n\t\t}\n\t\tfor (int i = 0; i < tw; i++) C[pp] = (C[pp] * 2) % mod;\n\t\t//printf(\"C[%d] = %lld\\n\", pp, C[pp]);\n\t}\n\n\tunsigned ans = 0;\n\t\n\tfor (int i = 1; i <= q; i++) {\n\t\tunsigned curr = 0;\n\n\t\t// sum x=0..p q^x * C(n,x)\n\t\tunsigned pot = 1;\n\t\tfor (int pp = 0; pp <= p; pp++) {\n\t\t\tcurr = (curr + pot * C[pp]) % mod;\n\t\t\tpot = pot * i;\n\t\t}\n\n\t\tans ^= (i * curr);\n\t}\n\n\tprintf(\"%u\\n\", ans);\n\n\t\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "742f41cfffdb26251f3d966cc39ddc00", "src_uid": "28cf4ff955d089318ea08d17bc4f43da", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nint main(void){\n // Your code here!\n int a , b ,c;\n cin >> a >> b >> c;\n int x , y, z;\n cin >> x >> y >> z;\n if (x < a )\n {\n cout << \"NO\" << endl;\n \n }\n x-=a;\n else if (x + y < b)\n cout << \"NO\" << endl;\n else {\n \n int p = x+y;\n p-=b;\n if (p + x < c)cout <<\"NO\" << endl;\n else cout << \"YES\" << endl;\n \n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a7fc058a6814e55cc1a808217c6f7aaf", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main();\n{\n int i,j,k,x,y,z,a,b,c;\n cin>>x>>y>>z>>a>>b>>c;\n if(a\nusing namespace std;\n#define ll long long\n#define ld long double\n#define pi pair\n#define pd pair\n#define ft first\n#define sd second\n#define st first\n#define nd second\n#define mp make_pair\n#define pb push_back\n#define eb emplace_back\n#define FOR(i,a,b) for(int i=(a); i<=(b);i++)\n#define F(i,a,b) FOR(i,(a),(b)-1)\n#define REV(i,a,b) for(int i=(a); i>=(b);i--)\n#define VI vector\n#define VPI vector\n#define VPD vector\n#define PI 3.14159265\n#define all(x) (x).begin(), (x).end()\n#define sz(a) (int)((a).size())\n#define int long long\n\ntemplate void _dbg(const char *sdbg, TH h){cerr< void _dbg(const char *sdbg, TH h, TA... a) {\n while(*sdbg!=',')cerr<<*sdbg++;cerr<<\"=\"<>x>>y>>z;\n int a,b,c;\n cin>>a>>b>>c;\n x-=a;\n if(x<0){\n cout<<\"NO\\n\";\n return 0;\n }\n if(x+y>test;\n while(test--){\n \tsolve();\n }\n}\n/*\n4\n10 10 10 10\n1 2 5\n1 3 5\n1 4 5\n*/\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4fa2b156d3f35a8ea27123f2958d9059", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include\nusing namespace std;\n\nint _tmain(int argc, _TCHAR* argv[])\n{\n\tint a[3], b[3];\n\tcin >> a[0] >> a[1] >> a[2] >> b[0] >> b[1] >> b[2];\n\tb[0] -= a[0];\n\tb[1] = b[1] + b[0] - a[1];\n\tb[2] = b[2] + b[1] - a[2];\n\tif (b[0] >= 0 && b[1] >= 0 && b[2]>=0)\n\t\tcout << \"YES\";\n\telse \n\t\tcout << \"NO\";\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "19d4e9f9fcbd03fc80924fbd5496387f", "src_uid": "d54201591f7284da5e9ce18984439f4e", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\n\nint main()\n{\n\tlong long x1,y1,x2,y2,x3,y3;\n\tcin >> x1 >> y1;\n\tcin >> x2 >> y2;\n\tcin >> x3 >> y3;\n\t\n\tx1 = x2-x1;\n\ty1 = y2-y1;\n\tx2 = x3-x1;\n\ty2 = y3-y1;\n\tlong long ans = x1*y2-x2*y1\n\tif(ans == 0)\n\t\tcout << \"TOWARDS\" << endl;\n\telse if( ans > 0)\n\t\tcout << \"LEFT\" << endl;\n\telse\n\t\tcout << \"RIGHT\" << endl; \n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bf4bbaf8499fa7f969feb65630b8c5a6", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\n#define FOR(i,n) for(int i=0;ix=x; this->y=y;}\n p operator -(p b) {return p(this->x-b.x,this->y-b.y);}\n int operator *(p b) {return this->x*b.y-this->y*b.x;}\n};\nint main()\n{\n vector

    a(3);\n FOR(i,3) cin >> a[i].x >> a[i].y;\n int d=(a[0]-a[1])*(a[2]-a[1]);\n if(d>0) cout << \"RIGHT\";\n else if(d<0) cout << \"LEFT\";\n else cout << \"TOWARDS\";\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "de72c164d1b99c8eda6932e5677c1d42", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\nfloat x1,x2,y_1,y_2,x3,y_3;\nfloat r1x,r1y,r2x,r2y;\nfloat mul;\nint main()\n{\n cin>>x1>>y_1>>x2>>y_2>>x3_y_3;\n r1x=x2-x1;\n r1y=y_2-y_1;\n r2x=x3-x1;\n r2y=y_3-y_1;\n mul=r1x*r2y-r1y*r2x;\n if(mul==0)\n cout<<\"TOWARDS\\n\";\n else if(mul>0)\n cout<<\"RIGHT\\n\";\n else\n cout<<\"LEFT\\n\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2924a2147c8e9e8bff30cdfe014dd2d9", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint x, x1, x2, y, y3, y2;\nint main(){\n cin >> x >> y >> x1 >> y1 >> x2 >> y2;\n int res = (x1 - x)*(y2 - y) - (y1 - y)*(x2 - x);\n if (res < 0)cout << \"RIGHT\" << endl;\n else if (res == 0)cout << \"TOWARDS\" << endl;\n else cout << \"LEFT\" << endl; return 0;}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "855bb2ddd2d53054698ed558b3253fb6", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n int main()\n {\n \tint t,n,i,j,m=100000;\n \tcin>>n;\n \tint a[n];\n \tfor(i=0;i>a[i];\n \t\t\n \tsort(a,a+n);\n \tm=a[0];\n \twhile(count(a,a+n,m)!=n){\n \tfor(i=0;im){\n \t\t\tif(a[i]%m==0) \n \t\t\ta[i]=m;\n \t\t\telse \n \t\t\t{a[i]=a[i]%m;\n \t\t\tm=a[i];}\n \t\t} \n \t}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "42a40c36ae6487a83fd81471bb0944fb", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "//Fox and Number Game\n#include\nusing namespace std;\nint n, a[100],min=0;\nint gcd(int n, int d){\n int r = d;\n while (d%r != 0 || n%r != 0){\n r--;\n }\n return r;\n}\nint main(){\n cin >> n ;\n for (int i = 0; i < n; i++){\n cin >> a[i]; \n min=gcd(min, a[i]);\n } \n cout << n*min << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "957ab9c953aab8d2cc2815bba5dea577", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n//#define LOCAL\nint read()\n{\n int w = 1,q = 0;\n char ch = ' ';\n while(ch != '-' && (ch < '0' || ch > '9')) ch= getchar();\n if(ch == '-') w = -1, ch = getchar();\n while(ch >= '0' && ch <= '9') q = q*10+ch-'0', ch = getchar();\n return w * q;\n}\nint print(int x)\n{\n if(x < 0)\n {\n putchar('-');\n x = ~(x-1);\n }\n int s[20],top = 0;\n while(x)\n {\n s[++top] = x % 10;\n x /= 10;\n }\n if(!top)s[++top] = 0;\n while(top)putchar(s[top--]+'0');\n return 0;\n}\nint __gcd(int a, int b) {\n if(b == 0) return a;\n return gcd(b, a%b);\n}\nint main()\n{\n #ifdef LOCAL\n freopen(\".in\", \"r\", stdin);\n freopen(\".out\", \"w\", stdout);\n #endif\n int n, a, num;\n cin >> n;\n for(int i = 1; i <= n; i++) {\n cin >> a;\n num = __gcd(sum, a);\n }\n cout << num * a << endl;\n return 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9705fed798118084817562beda0b4031", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include \nint main()\n{\n int a,b,c,d;\n std::cin>>a>>b;\n for (d=2;d<=a;d++)\n {\n cin>>c;\n b = std::__gcd(ans,c);\n }\n std::cout<\n#include \n\n#define M 100100\n#define pb push_back\n\nusing namespace std;\n\nlong n,m;\nvector g[M],d[M],f(M);\nvector u(M,0),c(M,0),t(M,0);\n\nvoid read(void){\n long a,b;\n cin>>n>>m;\n for(long i=1; i<=n; ++i)\n cin>>f[i];\n for (long i=0; i>a>>b;\n g[a].pb(b);\n d[b].pb(a);\n }\n}\n\nvoid dfs(long v){\n c[v]=1;\n u[v]=1;\n for (long i=0; i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#pragma comment(linker,\"/stack:64000000\")\n\nusing namespace std;\n\nint a[100500];\nint res[100500];\nbool vis[100500];\nvector > l;\n\nbool f(int v)\n{\n\tvis[v]=true;\n\tbool flag=false;\n\tfor (int i=0;i> n >> m;\n\tfor (int i=1;i<=n;i++)\n\t\tscanf(\"%d\",a+i);\n\tl.resize(n+1);\n\tint first,second;\n\tfor (int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define FOR(i,n) for (int i=0;i=0;i--)\n#define RI(a) scanf(\"%d\", &a);\n#define RS(a) scanf(\"%s\", &a);\n#define RC(a) scanf(\"%c\", &a);\n#define pb push_back\n#define mp make_pair\n#define fi first\n#define se second\n#define all(a) a.begin(),a.end()\n#define pii pair\n#define piii pair,int>\n#define INFY 1000000000\n#define MAXN 100000\nusing namespace std;\ntypedef long long LL;\n\nshort f[MAXN];\nvector a[MAXN];\n//vector b[MAXN];\n\nshort r1[MAXN];\nshort r2[MAXN];\n\nvoid com1(int k){\n if(f[k]==1) r1[k]=1;\n FOR(i, a[k].size()){\n if(r1[a[k][i]]<0) {\n r1[a[k][i]]=1;\n com1(a[k][i]);\n }\n }\n}\n\nint com2(int k){\n if(r2[k]>=0) return r2[k];\n FOR(i, a[k].size()){\n if(com2(a[k][i])==1 && f[a[k][i]]!=1) {\n r2[k]=1;\n return 1;\n }\n }\n r2[k]=0;\n return 0;\n}\n\nint main(){\n int n, m, u, v;\n RI(n);RI(m);\n FOR(i, n){\n RI(f[i]);\n r1[i] = r2[i] = -1;\n if(f[i]==2) r2[i]=1;\n }\n FOR(i, m){\n RI(u);RI(v);\n u--;v--;\n a[u].pb(v);\n //b[v].pb(u);\n }\n if(n>1000) return;\n FOR(i, n){\n com1(i);\n com2(i);\n }\n //FOR(i, n) cout<\n#include \n#include \n#include \n#include \n\n#define ONLINE_JUDGE\n#define pii pair\n\nusing namespace std;\nconst int MAXN = 100500;\n\n\nvector f(MAXN, 0);\n\nvoid dfs(int v, vector> g, vector& used, bool firstPass)\n{\n used[v] = true;\n if (!firstPass && f[v] == 1)\n return;\n for (int i = 0; i < g[v].size(); i++)\n {\n int u = g[v][i];\n if (!used[u])\n dfs(u, g, used, firstPass);\n }\n}\n\nvector > g(MAXN, vector());\nvector > gT(MAXN, vector());\nvector used(MAXN, false);\nvector usedT(MAXN, false);\n\nint main()\n{\n#ifndef ONLINE_JUDGE\n ifstream cin(\"input.txt\");\n ofstream cout(\"output.txt\");\n#endif\n\n int n, m;\n\n cin >> n >> m;\n\n for (int i = 0; i < n; i++)\n cin >> f[i];\n\n for (int i = 0; i < m; i++)\n {\n int u, v;\n cin >> u >> v;\n u--, v--;\n g[u].push_back(v);\n gT[v].push_back(u);\n }\n\n for (int i = 0; i < n; i++)\n {\n if (!used[i] && f[i] == 1)\n dfs(i, g, used, true);\n }\n\n for (int i = 0; i < n; i++)\n {\n if (!usedT[i] && f[i] == 2)\n dfs(i, gT, usedT, false);\n }\n\n for (int i = 0; i < n; i++)\n {\n if (used[i] && usedT[i])\n cout << 1 << endl;\n else\n cout << 0 << endl;\n }\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "66c50bb26ec213c32fb50c7f10343cc4", "src_uid": "87d869a0fd4a510c5e7e310886b86a57", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "// In The Name Of Allah\n\n// Mehrkish Makuei\n\n#include \n\nusing namespace std;\n\nconst int maxx = 5e2 + 7;\n\nint a[maxx];\n\nint main ()\n{\n int n;\n cin >> n;\n string str;\n a[0] = 1;\n for ( int i = 1; i < maxx; i++ )\n {\n a[1] = a[0] + 1;\n }\n for ( int i = 0; i < maxx; i++ )\n {\n str += itoa( a[i] );\n }\n cout << str[n - 1] << endl;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fbbd7a59c63aa48d9189cd0c07e46dd6", "src_uid": "2d46e34839261eda822f0c23c6e19121", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main()\n{\n\tstring s = \"\";\n\tint a = 1, n;\n\tcin >> n;\n\tfor (a = 1; a < 371; a++) s += to_string(a);\n\tcout << s[n - 1];\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "403d69e5e4345f73a8631429c29ecd8e", "src_uid": "2d46e34839261eda822f0c23c6e19121", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\n#include\nusing namespace std;\nstring a;\nint x=0,o;\nint main(){\n\tcin>>o;\n\tstring a=\"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400\";\n\tcout<\n#include \nusing namespace std;\nint main()\n{\nint n,i;\nstring s=\"\";\nstring p=\"\";\ncin>>n;\nfor(i=0;i<=n;i++)\n{\np=string(i+1);\ns=s+p;\n}\nchar c= s[n+1];\ncout<\nusing namespace std;\nint a,b,c,d;\nint main(){\n\tcin>>a>>b>>c>>d;\n\tif(a-b==b-c&&b-c==c-d)\n\tcout<=1&&d*(1.0*d/c)-floor(d*(1.0*d/c))==0)\n\t\tcout<=1&&d*(1.0*d/c)-floor(d*(1.0*d/c))==0)\n\t\tcout<\n#include \n#include \n#include \nusing namespace std;\nint main(){\n int arr[4], a, b, c;\n bool flag = false, flag1 = false;\n for (int i = 0; i < 4; i++){\n cin >> arr[i];\n }\n a = arr[1] - arr[0];\n b = arr[1] / arr[0];\n for (int i = 2; i < 4; i++){\n if (arr[i] - arr[i - 1] == a) continue;\n else if (arr[i] / arr[i - 1] == b){\n flag = true;\n }\n else flag1 = true;\n }\n if (flag1 || arr[3]*b!=ceil(arr[3]*b)) cout << 42;\n else if (flag)cout << arr[3] * b;\n else cout <\nusing namespace std;\nint main()\n{\t\t\n\t\n\t\t int arr[4] = {0};\n for(int i=0;i<4; i++){\n\t\tcin>>arr[i];\n\t\t}\n\t\t\n\n int d= arr[1] - arr[0];\n double r = (double) (arr[1]/(double)arr[0]), intpart=0;\n\n if(arr[2] - arr[1] == d && arr[3] - arr[2] == d) {cout<\nusing namespace std;\n\nint main(){\n int a[4+2];\n for(int i = 1; i <= 4; i++){\n cin >>a[i];\n }\n int s = a[2]-a[1];\n int q = a[3]-a[2];\n if(s == q){\n cout<\n#include \n\nusing namespace std;\n\nint main(int argc, char *argv[])\n{\n int a,b,c,d=1,e;\n cin>>a>>b;\n c=a*(a+1)/2;\n if(cb)\n {c=c-a;\n a=a-1;}\n cout<\n\nusing namespace std;\n\nint main()\n{\n int n,m,c=0;\n cin>>n>>m;\n int a[n];\n for(int i=1;i=i)\n {\n a[i]=a[i]+i;\n m=m-i;\n }\n else\n {\n c++;\n if(c==1)\n {\n cout< \n\nusing namespace std; \n \nint main(){ \n int n;//morsas\n cin>>n;\n int m;//mani\n cin>>m;\n int i;\n\n\nwhile(m>0){\n for(i=1;i<=n;i++){ \n m=m-i;\n if(m<0){\n cout<< m+i;\nreturn 0; \n} \nif(m==0){\ncout<<\"0\";\nreturn 0;\n}\n }\n}\n system(\"pause\");\n}\n \n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a118b80415fb1103b0902537a1e01962", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\n\n#include\nint main()\n{\n int n,m,c=0,i=1,j,k=1,dist[100],index=0;\n scanf(\"%d%d\",&n,&m);\n for(i=1;i<=n;i++)\n dist[i]=0;\n while(m>0)\n {\n i=k;\n for(i=k;i<=n;i++)\n {\n dist[i]+=i;\n m-=i;\n if(m<=0)\n break;\n}\nindex=i;\n}\nif(index==1)\nprintf(\"%d\",0)\nelse\nprintf(\"%d\",n-index);\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6be87ac544d3b2a8959e44be27d76163", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nint main()\n{\n int sum=0,n,mod,x,i,k=sum,kk=x-2,temp;\n cin>>n;\n x=n\n for (i=2;ii||n==i)\n {\n mod=n%i;\n n/=i;\n sum+=mod;\n }\n mod=n%i;\n sum+=mod;\n }\n while(k%kk!=0)\n {\n temp=k;\n k=kk;\n kk=temp%k;\n }\n cout<\nusing namespace std;\nint gcd(int a,int b)\n{\n if(b==0) return iNum1;\n else return gcd(b, a%b);\n}\nint main()\n{\n int n,i,t,ans=0,gc; \n cin>>n;\n for(int i=2;i<=n-1;++i)\n\t{\n t=n;\n while(t!=0)\n\t\t{\n ans+=t%i;\n t/=i;\n }\n }\n n-=2;\n gc=gcd(ans,n);\n ans/=gc;\n n/=gc;\n cout<\nusing namespace std;\nint a,b,c,e;\nint d(int a,int b)\n{\n\tint c=0;\n\twhile(a)\n\t{\n\t\tc+=a%b;\n\t\ta/=b;\n\t}\n\treturn c\n}\nint main()\n{\n\tcin>>a;\n\tfor(b=2;b\n\n\t\n\t\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\n\t\n\t\n\t\n\t\t\n\t\t\n\t\n\t\n\t\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e7b81415ee09e7cbb7f9fdf26637625e", "src_uid": "1366732dddecba26db232d6ca8f35fdc", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nconst int mod = 1e9+7;\nlong long dp[300000][2];\nstring a,b;\nint k;\nint main()\n{\n cin>>a>>b;\n scanf(\"%d\",&k);\n if(a==b)dp[0][0]=1;\n else dp[0][1]=1;\n int x = 0;\n for(int i=0;i\nusing namespace std;\n\nint main()\n{\n\tint n, a, b;\n\tcin >> n >> a >> b;\n\ta = a - 1;\n\tb = b - 1;\n\n\tint round = 1;\n\twhile (n != 2)\n\t{\n\t\tif (a / 2 == b / 2)\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t\ta = a / 2;\n\t\tb = b / 2;\n\t\tround++;\n\t\tn = n / 2;\n\n\t}\n\n\tif (n == 2)\n\t\tcout << \"final!\" << endl;\n\telse\n\t\tcout << round << endl;\n\n\n\tsystem(\"pause\");\n\treturn 0;\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0753394f1cb9f0c71ea45b5273d6793b", "src_uid": "a753bfa7bde157e108f34a28240f441f", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#include \"iostream\"\n#include \"conio.h\"\n#include \"math.h\"\n#include \"stdlib.h\"\n#include \"time.h\"\n#include \"vector\"\n#include \"algorithm\" \n#include \"numeric\"\n#include \"string\"\n#include \"ctime\"\n#define sp << \" \"\n#define sps << \" \" <<\n#define lnl << endl <<\n#define ln << endl\ntypedef long long ll;\nusing namespace std;\nbool f(int a , int b, int n)\n{\t\n\tint awer = n / 2;\n\tif ((a > awer && b <= awer) || (a <= awer && b > awer))\n\t\treturn true;\n\treturn false;\n}\n\nint main()\n{\n\tint n, a, b, cnt = 1, rounds, c, s = 1;\n\tcin >> n >> a >> b;\n\tc = n;\n\tfor (int i = 1; i < 9; ++i)\n\t\tif (pow(2, i) == n)\n\t\t\trounds = i;\n\twhile (f(a, b, n) != true)\n\t{\n\t\trounds--;\n\t\tif (a > n / 2)\n\t\t{\n\t\t\ta -= n / 2;\n\t\t\tb -= n / 2;\n\t\t\tn /= 2;\n\t\t}\n\t\telse\n\t\t\tn /= 2;\n\t}\n\tfor (int i = 0; i < rounds; ++i)\n\t\ts *= 2;\n\tif (s == c)\n\t\tcout << \"Final!\";\n\telse\n\t\tcout << rounds;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "de83fec317c09795de17ae70b2151168", "src_uid": "a753bfa7bde157e108f34a28240f441f", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n\ntemplate \nT read_one() {\n\tT elem; std::cin >> elem;\n\treturn elem;\n}\n\nint main() {\n\tint n = read_one();\n\tint a = read_one() - 1;\n\tint b = read_one() - 1;\n\n\tint r = 0;\n\twhile (n > 1) {\n\t\t++r;\n\t\tn /= 2;\n\t}\n\tfor (int i = r - 1; i >= 0; --i) {\n\t\tint mask = 1 << i;\n\t\tif ((a & mask) != (b & mask)) {\n\t\t\tif (i == r - 1)\n\t\t\t\tstd::cout << \"Final\";\n\t\t\telse\n\t\t\t\tstd::cout << (i + 1);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "880d3748725f6c538768147629c1dfc3", "src_uid": "a753bfa7bde157e108f34a28240f441f", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n\n\n\nint main(void) {\n int n, m;\n cin >> n;\n cin >> m;\n cin >> x;\n n -= (x - 1) << 1;\n m -= (x - 1) << 1;\n if (n <= 0|| m <= 0) {\n cout << 0 << endl;\n }\n size = (n * m + 1) >> 1;\n n -= 2;\n m -= 2;\n if (n < 0 || m < 0) {\n cout << size << endl;\n }\n size -= (n * m + 1) >> 1;\n\n\n cout << size << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "dec3fa18ee71001945fc8e0a4f70c0f6", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include\n\nusing namespace std;\n\nint main()\n{\n\tcin>>n>>m>>x;\n\tx--;\n\tif(n>m) {\n\t\tswap(n,m);\n\t}\n\tfor(i=1;i0;i++)\n\t{\n\t\tn-=2;m-=2;\n\t}\n\tif(n<=0)\n\tcout<<0;\n\telse if(n==1)\n\t\n\tcout<<((m+1)>>1);\n\telse cout<\ntypedef long long int ll;\n//typedef pair ip;\n#define mp make_pair\n#define pb push_back\n#define rep(g,i,n) for(ll g=i;g>n>>m>>x;\n if(n%2!=0&&m%2!=0)\n {\n ll y=2*(x-1);\n ll z=(m-y)*(n-y);\n z=z/2;\n //cout<0&&n-y-2>0){ w=w/2;\n w++;\n cout<0&&y>0)\n {\n y=y/2;\n y--;\n cout<0&&n>0)\n {\n n=n/2;\n cout<0&&n>0)\n {\n m=m/2;\n cout<<(2*m)+n-2;\n return 0;\n }\n \n else\n {\n cout<<0;\n return 0;\n }\n }\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "28f802cfe4eebde485aaba3257594416", "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nclock_t startTime=clock();\nusing namespace std;\n\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vl;\ntypedef vector vvl;\ntypedef vector vb;\ntypedef vector vvb;\ntypedef vector vd;\ntypedef vector vvd;\ntypedef vector vs;\ntypedef pair pii;\ntypedef vector vpii;\ntypedef pair pdd;\ntypedef vector vpdd;\ntypedef vector Graph;\n\n#define fr(i,a,b) for(int i(a),_b(b);i<=_b;++i)\n#define frd(i,a,b) for(int i(a),_b(b);i>=_b;--i)\n#define rep(i,n) for(int i(0),_n(n);i<_n;++i)\n#define reps(i,a) fr(i,0,sz(a)-1)\n#define all(a) a.begin(),a.end()\n#define pb push_back\n#define mp make_pair\n#define clr(x,a) memset(x,a,sizeof(x))\n#define findx(a,x) (find(all(a),x)-a.begin())\n#define two(X) (1LL<<(X))\n#define contain(S,X) (((S)&two(X))!=0)\n\nconst double eps=1e-9;\n\ntemplate void print(const vector &v){ostringstream os; for(int i=0; i<(int)v.size(); ++i){if(i)os<<' ';os< int sz(const T&c){return (int)c.size();}\ntemplate void srt(T&c){sort(c.begin(),c.end());}\ntemplate void checkmin(T &a,T b){if(b void checkmax(T &a,T b){if(b>a) a=b;}\ntemplate T sqr(T x){return x*x;}\ntemplate T cast (U x) { ostringstream os; os<>res; return res; }\ntemplate vector split(string s, string x=\" \") {vector res; for(int i=0;i(a));} return res;}\ntemplate bool inside(T r,T c,T R, T C){return r>=0 && r=0 && c>R>>C>>x;\n\n\tvvi a(R, vi(C));\t\n\tqueue q;\n\n\trep(r,R){\n\t\trep(c,C){\n\t\t\tif(((r+c)&1)==0 && (r==0 || c==0 || r==R-1 || c==C-1)){\n\t\t\t\tq.push(mp(r,c));\n\t\t\t\ta[r][c]=1;\n\t\t\t}\n\t\t}\n\t}\n\n\twhile(!q.empty()){\n\t\tpii cur=q.front(); q.pop();\n\t\tint r=cur.first;\n\t\tint c=cur.second;\n\n\t\trep(d,4){\n\t\t\tint nr=r+dr[d];\n\t\t\tint nc=c+dc[d];\n\n\t\t\tif(inside(nr,nc,R,C) && a[nr][nc]==0){\n\t\t\t\ta[nr][nc]=a[r][c]+1;\n\t\t\t\tq.push(mp(nr,nc));\n\t\t\t}\n\t\t}\n\t}\n\n\tint res=0;\n\trep(r,R){\n\t\trep(c,C){\n\t\t\tif(a[r][c]==x)++res;\n\t\t}\n\t}\n\n\tcout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define all(v) v.begin(),v.end()\n#define rall(v) v.rbegin(),v.rend()\n#define sz(v) ((int)v.size())\n#define rep(i,n) for(int i = 0; i < (int)(n); ++i)\n#define reprng(i,a,b) for(int i = a; i <= (int)(b); ++i)\n#define reprngr(i,n,a) for(int i = n;i >= (int)(a); --i)\n#define For(it,c) for(auto it=c.begin();it!=c.end();++it)\ntypedef long long ll;\nint main()\n{\n\tll n;\n\tcin >> n;\n\tint digits = ceil(log10(n+1));\n\tint p = (1 << digits);\n\n\tint index = 1;\n\trep(i, p)\n\t{\n\t\tint pow = 1;\n\t\tll result = 0;\n\t\trep(j, digits)\n\t\t{\n\t\t\t\n\t\t\tif (((i >> j) & 1 )== 0)\n\t\t\t{\n\t\t\t\tresult += 4 * pow;\n\t\t\t}\n\t\t\telse\n\t\t\t\tresult += 7 * pow;\n\t\t\tpow *= 10;\n\t\t}\n\t\tif (result == n)\n\t\t\tbreak;\t\t\n\t\tindex++;\n\n\n\t}\n\treprng(i, 1, digits - 1 )\n\t{\n\t\tindex += (1 << i);\n\t}\n\tcout << index;\n\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2c04271bdf3e0444514bc9a47c72bd2b", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\nusing namespace std;\nvoid main()\n{\n int n,k=1;\n cin>>n;\n int t=n,r=0, j=0;\n for(int i=0;t!=0;i++)\n {\n r=t%10;\n t=(t-r)/10;\n if(r==4)j+=pow(2,i);\n else if(r==7)j+=(pow(2,i)*2);\n }\n \n cout<\nusing namespace std;\n\nint num, n , ans; \nint ada ;\n\nint func(int x){\n\tif(x == 0) return num ;\n\telse {\n\t\tnum = pow(2,x) + num ;\n\t\treturn func(x-1) ;\n\t}\n}\n\nint main(){\n\tcin >> n ;\n\tstring s = to_string(n) ;\n\tint c = abs(s.length()) ;\n\tfor(int i = 0; i < s.length() ; i++){\n\t\tif(s[i] == '7') ada = pow(2,c-i) + ada ;\n\t}\n\tif(ada == 0) ada = 1 ;\n\tans = func(s.length()-1) + ada ;\n\tcout << ans << '\\n' ;\n\treturn 0 ;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f957da142db998b60e36375c541bd73a", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nbool is(int n)\n{\n bool statement = true;\n\n while(n>0)\n {\n if(n%10!=4 && n%10!=7)\n {\n statement = false;\n break;\n }\n n/=10;\n }\n\n return statement;\n}\n\nint play(int n)\n{\n int what_pow = 0;\n int k = n;\n while(k>0)\n {\n k/=10;\n what_pow++;\n }\n\n int exp;\n exp = pow(2,what_pow+1)-2;//Es\n\n int sub = 1;\n\n while(n>0)\n {\n if(n%10==4)\n exp-=sub;\n sub++;\n n/=10;\n }\n\n return exp;\n}\n\nint main()\n{\n int n;\n\n cin >> n;\n\n cout << play(n);\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "eb38f328e72e982582cf91d5a774c764", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nvoid printDig(long k)\n{\n if(k==1)\n {cout<<\"0\";\n k--;\n return;\n }\n else if(k==0)\n {return;\n }\n else if((k%2)==0)\n {\n cout<<\"8\";\n printDig(k-2);\n }\n else if((k%2)!=0)\n {\n cout<<\"4\";\n printDig(k-1);\n }\n\n}\nint main()\n{\n\n long k;\n cin>>k;\n if(k>=37)\n {cout<<\"-1\";\n return 0}\n if(k==0)\n {cout<<\"5\";\n return 0;};\n printDig(k);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "12f025f30bbe0c8adb791ad4d65a4903", "src_uid": "0c9973792c1976c5710f88e3520cda4e", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\n#define int long long\ntypedef pair pii;\n\nconst int N = 1e6 + 10, M = 18;\nint n, pw4[M], pw8[M];\npii dp[N];\n\nint main() {\n pw4[0] = pw8[0];\n for (int i = 1; i < M; i++) {\n pw4[i] = pw4[i - 1] * 4;\n pw8[i] = pw8[i - 1] * 8;\n }\n \n fill(dp, dp + N, pii(-1, -1));\n dp[1] = {4, 1};\n dp[2] = {8, 1};\n \n for (int i = 3; i < N; i++) {\n if (dp[i - 1].second < 17 && dp[i - 1].first != -1) {\n dp[i].second = dp[i - 1].second + 1;\n dp[i].first = dp[i - 1].first + pw4[dp[i].second];\n }\n else if (dp[i - 2].second < 17 && dp[i - 2].first != -1) {\n dp[i].second = dp[i - 1].second + 1;\n dp[i].first = dp[i - 1].first + pw8[dp[i].second];\n }\n }\n \n cin >> n;\n cout << dp[n].first;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0c29b616a6122f5b2d528e75720b1f32", "src_uid": "0c9973792c1976c5710f88e3520cda4e", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "#include\n#include // std::cout\n#include \nusing namespace std;\n\ntypedef long long ll;\ntypedef double ld;\ntypedef pair pl;\ntypedef vector vi;\ntypedef vector vl;\ntypedef vector vll;\n\n#define si(x) scanf(\"%d\",&x);\n#define sl(x) scanf(\"%ld\",&x);\n#define sll(x) scanf(\"%lld\",&x);\n\n#define pi(x) printf(\"%d\",x);\n#define pl(x) printf(\"%ld\",x);\n#define pll(x) printf(\"%lld\",x);\n#define pn printf(\"\\n\");\n#define ps printf(\" \");\n\nconst ll mod=1000000007ll;\nconst ll Mod=1000000009ll;\nconst ll inf=(ll)5e18;\nconst ld eps=1e-12;\nconst ll N=1000005;\nconst ll LOGN=19;\nconst ld PI=3.14159265358979323846;\n\n#define sf(x) sort(x.begin(),x.end(),func)\n#define s(x) sort(x.begin(),x.end())\n\n#define all(v) v.begin(),v.end()\n#define rs(v) { s(v) ; r(v) ; }\n#define r(v) {reverse(all(v));}\n\n#define pb push_back\n#define mp make_pair\n#define F first\n#define S second\n\n#define f(i,n) for(int i=0;iT max2(T a,T b){return aT min2(T a,T b){return aT max3(T a,T b,T c){return Max2(Max2(a,b),c);}\ntemplate T min3(T a,T b,T c){return Min2(Min2(a,b),c);}\ntemplate T max4(T a,T b,T c,T d){return Max2(Max2(a,b),Max2(c,d));}\ntemplate T min4(T a,T b,T c,T d){return Min2(Min2(a,b),Max2(c,d));}\n\nvoid print(int a[],int s,int e){for(int i=s;i<=e;i++)cout< &v,int s,int e){for(int i=s;i<=e;i++)cout< &v){for(int i=0;i=m) a-=m; if(a<0) a+=m; return a;}\nll power(ll a,ll b,ll m=Mod){if(b==0) return 1; if(b==1) return (a%m); ll x=power(a,b/2,m); x=mul(x,x,m); if(b%2) x=mul(x,a,m); return x;}\n\nint main(){\n ll n;sll(n);\n string s;\n while(n!=0){\n \tif(n>=2){\n \t\ts+='8';\n \t\tn-=2;\n \t}\n \telse{\n \t\ts+='0';\n \t\tn-=1;\n \t}\n }\n if(s.length>=18)\n \tcout<<\"-1\";\n else\n \tcout<\n#include \nusing namespace std;\n\nint a[10] = {1, 0, 0, 0, 1, 0, 1, 0, 2, 1};\ntypedef long long ll;\nconst ll MAXN = 1e18;\n\n\nint main (){\n\tll x;\n\tcin >> x;\n\tif (x >= 37)\tcout << \"-1\" << endl;\n\telse\n\t{\n\t\tif (x % 2 == 0){\n\t\tll y = x / 2;\n\t\tll sum = 0;\n\t\tfor (int i = 0; i < y; i++){\n\t\t\tcout << 8;\t\n\t\t}\n\t\tcout << endl;\n\t}\n\t\telse{\n\t\tll y = x / 2;\n\t\tfor (int i = 0; i < y; i++){\n\t\t\tsum = (sum * 10) + 8;\t\n\t\t}\n//\t\tfor (int i = 0; i < y; i++){\n//\t\t\tnum *= 10;\n//\t\t}\n\t\tsum = sum*10;\n\t\tcout << sum <\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint n;\nint ar[50][50];\nint dp[51][51];\nbool leaf[50];\nvector adj[50];\nvector leafs;\nint bad;\nvector pos;\nint go(int rem, int now){\n if(rem==0){\n return 0;\n }\n if(dp[rem][now]!=-1){\n return dp[rem][now];\n }\n int low = 0;\n int high = 125000;\n while(low0 && ar[now][i]+go(rem-cur-1,i)>=mid){\n cur++;\n temp--;\n }\n }\n if(temp==0){\n low = mid;\n }\n else{\n high = mid-1;\n }\n }\n dp[rem][now] = low;\n return low;\n}\nvoid dfs(int now, int from){\n if(leaf[now]){\n leafs.push_back(now);\n }\n for(int i = 0; i> n;\n for(int i = 0; i> a >> b >> w;\n a--;\n b--;\n adj[a].push_back(b);\n adj[b].push_back(a);\n ar[a][b]=w;\n ar[b][a]=w;\n maxw = max(maxw,w);\n }\n assert(maxw<=50);\n for(int k = 0; k> start >> m;\n start--;\n for(int i = 0; i> x;\n x--;\n pos.push_back(x);\n }\n \n int ans = 125000;\n if(n==1){\n assert(false);\n ans = 0;\n }\n for(int i = 0; i0 && ar[start][cl]+go(m-cur-1,cl)>=mid){\n cur++;\n temp--;\n }\n }\n if(temp==0){\n low = mid;\n }\n else{\n high = mid-1;\n }\n }\n ans = min(ans,low);\n }\n assert(ans!=125000 && ans!=0);\n cout << ans << endl;\n return 0;l", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a3db5ed6cb866f7a59598c1068b3a45e", "src_uid": "34b926f903c2412fe76f912ccb8a00dd", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n\nusing namespace std;\nconst int MAXN = 55;\nint _w;\n\nint n, s, m, x[MAXN];\nint s[680];\n\nnamespace Tree {\n\tint head[MAXN], nxt[MAXN<<1], to[MAXN<<1], len[MAXN<<1], eidx;\n\tvoid init() {\n\t\tmemset(head, -1, sizeof head);\n\t}\n\tvoid adde( int u, int v, int w ) {\n\t\tto[eidx] = v, len[eidx] = w;\n\t\tnxt[eidx] = head[u], head[u] = eidx++;\n\t\tto[eidx] = u, len[eidx] = w;\n\t\tnxt[eidx] = head[v], head[v] = eidx++;\n\t}\n}\n\nbool leaf[MAXN];\nvoid prelude() {\n\tusing namespace Tree;\n\tfor( int u = 1; u <= n; ++u ) {\n\t\tint d = 0;\n\t\tfor( int i = head[u]; ~i; i = nxt[i] )\n\t\t\t++d;\n\t\tleaf[u] = d == 1;\n\t}\n}\n\nint f[MAXN<<1][MAXN][MAXN], g[MAXN];\nint knapsack( int e, int m, int k );\nint dp( int e, int m, int k ) {\n\tusing namespace Tree;\n\tint &now = f[e][m][k];\n\tif( now != -1 ) return now;\n\tif( !m ) return now = 0;\n\tif( leaf[to[e]] ) now = dp(e^1, m-k, m-k) + len[e];\n\telse now = knapsack(e, m, k) + len[e];\n\t// printf( \"dp: f[%d, %d][%d][%d] = %d\\n\", to[e^1], to[e], m, k, now );\n\treturn now;\n}\nint knapsack( int e, int m, int k ) {\n\tusing namespace Tree;\n\tint u = to[e], fa = to[e^1];\n\tfor( int i = head[u]; ~i; i = nxt[i] )\n\t\tif( to[i] != fa )\n\t\t\tfor( int j = 1; j <= k; ++j )\n\t\t\t\tdp(i, m, j);\n\tg[0] = 1e9;\n\tfor( int i = 1; i <= k; ++i ) g[i] = -1;\n\tfor( int i = head[u]; ~i; i = nxt[i] ) {\n\t\tint v = to[i];\n\t\tif( v == fa ) continue;\n\t\tfor( int j = k-1; j >= 0; --j )\n\t\t\tfor( int kk = 1; j+kk <= k; ++kk )\n\t\t\t\tg[j+kk] = max( g[j+kk], min(g[j], dp(i, m, kk)) );\n\t}\n\t// printf( \"knapsack: f[%d, %d][%d][%d] = %d\\n\", fa, u, m, k, g[k] );\n\treturn g[k];\n}\n\nint dfs( int u, int fa ) {\n\tusing namespace Tree;\n\tint sz = x[u];\n\tfor( int i = head[u]; ~i; i = nxt[i] )\n\t\tif( to[i] != fa )\n\t\t\tsz += dfs(to[i], u);\n\treturn sz;\n}\nvoid solve() {\n\tusing namespace Tree;\n\tint ans = 1e9;\n\tmemset(f, -1, sizeof f);\n\tfor( int i = head[s]; ~i; i = nxt[i] ) {\n\t\tint v = to[i], sz = dfs(v, s);\n\t\tif( sz ) ans = min(ans, dp(i, m, sz));\n\t}\n\tprintf( \"%d\\n\", ans );\n}\n\nint main() {\n\t_w = scanf( \"%d\", &n );\n\tTree::init();\n\tfor(int i=0; i<680; i++)\n\t{\n\t s[i] = i;\n\t}\n\tfor( int i = 0; i < n-1; ++i ) {\n\t\tint u, v, w;\n\t\t_w = scanf( \"%d%d%d\", &u, &v, &w );\n\t\tTree::adde(u, v, w);\n\t}\n\t_w = scanf( \"%d%d\", &s, &m );\n\tfor( int i = 0; i < m; ++i ) {\n\t\tint y;\n\t\t_w = scanf( \"%d\", &y );\n\t\t++x[y];\n\t}\n\tprelude(), solve();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "08d49604f63536b04555a1f3606ac20e", "src_uid": "34b926f903c2412fe76f912ccb8a00dd", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n\nusing namespace std;\n\n#define sz(x) (int)(x.size())\n#define fi(a,b) for(int i=a;i e[N];\nint n, m;\nint f[M], t[M], c[M], ce;\nint s;\nint x[M];\nint leaf[N];\nint ans;\n\nvoid push(int u, int v, int w){\n\tf[ce] = u;\n\tt[ce] = v;\n\tc[ce] = w;\n\te[u].pb(ce);\n\t++ce;\n\n\te[v].pb(ce);\n\tf[ce] = v;\n\tt[ce] = u;\n\tc[ce] = w;\n\t++ce;\n}\n\nint getcnt(int u, int p){\n\tint ret = 0;\n\tfi(0, m) if(x[i] == u) ++ret;\n\tfi(0, sz(e[u])){\n\t\tint to = t[e[u][i]];\n\t\tif(to == p) continue;\n\t\tret += getcnt(to, u);\n\t}\n\treturn ret;\n}\n\nbool w[N][N][N][N];\nint d[N][N][N][N];\n\nvoid remin(int &a, int b){\n\ta = min(a, b);\n}\n\nint rec(int u, int r, int p, int rf){\n\tint ret = INF;\n\tif(p == -1){\n\t\tfi(0, sz(e[u])){\n\t\t\tint id = e[u][i];\n\t\t\tint to = t[id];\n\t\t\tint cnt = getcnt(to, u);\n\t\t\tint co = c[id];\n\t\t\tremin(ret, co + rec(to, r, u, cnt));\n\t\t}\n\t}else{\n\t\tif(leaf[u]){\n\t\t\tr -= rf;\n\t\t\trf = 0;\n\t\t}\n\t\tif(r == 0){\n\t\t\tret = 0;\n\t\t}else{\n\t\t\tif(w[u][r][p][rf]){\n\t\t\t\tret = d[u][r][p][rf];\n\t\t\t}else{\n\t\t\t\tw[u][r][p][rf] = 1;\n\t\t\t\tif(leaf[u]){\n\t\t\t\t\tint id = e[u][0];\n\t\t\t\t\tint to = t[id];\n\t\t\t\t\tint co = c[id];\n\t\t\t\t\tret = rec(to, r, u, r) + co;\n\t\t\t\t}else{\n\t\t\t\t\tint le = -1;\n\t\t\t\t\tint ri = INF;\n\t\t\t\t\twhile(ri-le>1){\n\t\t\t\t\t\tint m = (le+ri)/2;\n\t\t\t\t\t\tint dp[N][N];\n\t\t\t\t\t\tmemset(dp, 0, sizeof(dp));\n\t\t\t\t\t\tdp[0][0] = 1;\n\t\t\t\t\t\tint ce = sz(e[u]);\n\t\t\t\t\t\tfi(0, ce){\n\t\t\t\t\t\t\tint id = e[u][i];\n\t\t\t\t\t\t\tint to = t[id];\n\t\t\t\t\t\t\tint co = c[id];\n\t\t\t\t\t\t\tfj(0, N) dp[i+1][j] = dp[i][j];\n\t\t\t\t\t\t\tif(to == p) continue;\n\t\t\t\t\t\t\tfj(1, rf+1){\n\t\t\t\t\t\t\t\tif(co + rec(to, r, u, j) >= m){\n\t\t\t\t\t\t\t\t\tfo(0, N) if(dp[i][o] && o + j < N){\n\t\t\t\t\t\t\t\t\t\tdp[i+1][o+j] = 1;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(dp[ce][rf]) le = m;\n\t\t\t\t\t\telse ri = m;\n\t\t\t\t\t}\n\t\t\t\t\tret = le;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif(p != -1) d[u][r][p][rf] = ret;\n\t//fprintf(stdout, \"u = %d r = %d p = %d rf = %d ans = %d\\n\",u,r,p,rf,d[u][r][p][rf]);\n\treturn ret;\n}\n\nvoid solve(){\n\tfi(0, n) if(sz(e[i]) == 1) leaf[i] = 1;\n\tans = rec(s, m, -1, -1);\n}\n\nint main(){\n#ifdef _DEBUG\n\tfreopen(\"input.txt\",\"r\",stdin);\n\tfreopen(\"output.txt\",\"w\",stdout);\n#endif\n\n\tscanf(\"%d\",&n);\n\tfi(0, n-1){\n\t\tint u, v, w;\n\t\tscanf(\"%d %d %d\",&u,&v,&w);\n\t\t--u;--v;\n\t\tpush(u, v, w);\n\t}\n\n\tscanf(\"%d\",&s);\n\t--s;\n\tscanf(\"%d\",&m);\n\tfi(0, m){\n\t\tscanf(\"%d\",&x[i]);\n\t\t--x[i];\n\t}\n\n\tsolve();\n\n\tprintf(\"%d\\n\",ans);\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "80ba0a59cb6a90cfb3d76574b56ca90e", "src_uid": "34b926f903c2412fe76f912ccb8a00dd", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "include\n#include\n#include\nusing namespace std;\nstruct edge\n{\n\tint v,w;\n\tedge(int a,int b):v(a),w(b){}\n};\nvector w[100];\nint n,s,m,x[100],f[60][60][60][60],d[100][100];\nint dfs(int u,int p)\n{\n\tint ans=x[u];\n\tfor(edge i:w[u])\n\t\tif(i.v!=p)ans+=dfs(i.v,u);\n\treturn ans;\n}\nint dp(int u,int v,int k,int a)\n{\n\tint &ans=f[u][v][k][a];\n\tif(ans!=-1)return ans;\n\tif(!k)return ans=0;\n\tif(w[v].size()==1)return ans=dp(v,u,k-a,k-a)+d[u][v];\n\tint g[60]={1<<30};\n\tfor(int i=1;i<=n;i++)g[i]=-(1<<30);\n\tfor(edge i:w[v])\n\t\tif(i.v!=u)for(int j=a;j;j--)\n\t\t\tfor(int l=1;l<=j;l++)g[j]=max(g[j],min(g[j-l],dp(v,i.v,k,l)+d[u][v]));\n\treturn ans=g[a];\n}\nint main()\n{\n\tscanf(\"%d\",&n);\n\tfor(int i=1;i\n#include \n#include \n#include \n\nint main(void){\n\tint N;\n\tstd::cin >> &N;\n\tfor (int i = 0 ; i < N; i++){\n\t\tstd::string s;\n\t\tstd::cin >> s;\n\t\tstd::cout << make_year(make_number(s)) << std::endl;\n\t} \n\n}\n\nstd::string make_number (std::string s){\n\tstd::string s1 = s.substr(4, s.length()-4);\n\treturn s1;\n//\treturn atoi(s1.c_str());\n}\n\nint make_year (std::string s){\n\tint l = s.lngth();\n\tif (s.length() > 4 ){\n\t\tif (s[0] == '0'){\n\t\t\tstd::string s2 = \"1\"+s;\n\t\t\treturn atoi(s2.c_str());\n\t\t}\n\t\telse{\n\t\t\treturn atoi(s.c_str());\n\t\t}\n\t\t\n\t}\n\tif (k == 4 && atoi(s[0]) > 2){\n\t\treturn atoi(s.c_string());\n\t}\n\tif (k == 1){\n \tif (s[0] == '9' ){\n\t\t\treturn 1989;\n\t\t}\n\t\telse {\n\t\t\treturn 1990+atoi(s.c_str());\n\t\t}\n\t}\n\tif (k== 2){\n\t\tif (atoi(s.c_str()) < 99 ){\n\t\t\treturn 2000 + atoi (s);\n\t\t}\n\t\telse{\n\t\t\treturn 1999;\n\t\t}\n\t}\n\tif (k == 4 && atoi(s[0]) < 3){\n\t\treturn 10000 + atoi(s.c_string());\n\t}\n\tif (k==3){\n\t\tif (atoi(s.c_str()) > 98){\n\t\t\treturn 2000 + atoi(s.c_str());\n\t\t}\n\t\telse{\n\t\t\treturn 3000 + atoi(s.c_str());\n\t\t}\n\t}\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0b8f2ee0d65bcdfebba60e88aa35b368", "src_uid": "31be4d38a8b5ea8738a65bfee24a5a21", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main () {\n\tchar str[42];\n\tint n;\n\tscanf (\"%d\", &n);\n\tint lowlim[10], uplim[10], year[1005];\n\tmemset(year,0,1005);\n\tlowlim[0] = 1989;\n\tuplim[0] = 1998;\n\tint tpow=100;\n\tfor (int i = 1; i<9; i++) {\n\t\tlowlim[i] = uplim[i-1] + 1;\n\t\tuplim[i] = lowlim[i] + tpow - 1;\n\t\ttpow*=10;\n\t}\n\tfor (int i = 0; i\n\n#define ll long long\n#define ull unsigned long long\n\nusing namespace std;\n\ntypedef pair pr;\n\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n \t\n \tint n,len,abb = 0,i,c = 0,f = 0;\tcin >> n;\n \tchar s[15];\n\n \twhile(n--){\n \t\tabb = 0;7\n \t\tcin >> s;\n \t\tlen = strlen(s);\n\n \t\tfor(i = 4;i < len;i++){\n \t\t\tabb = 10*abb + (int)s[i] - 48;\n \t\t\tif(s[i] == '0')c++;\n \t\t\telse{\n \t\t\t \tc = 0;\n \t\t\t\tf = 1;\n \t\t\t}\n \t\t}\n \t\tcout << abb << \"\\n\";\n \t} \n\n \tif(f == 0){\n \t\tif(c == 1)ans = 1990;\tif(c == 3)ans = 3000;\tif(c == 5)ans = 100000;\n \t\tif(c == 2)ans = 2000;\tif(c == 4)ans = 10000;\n \t}else{\n \t\tif(len == 9){\n \t\t\tif(abb < 13099)ans = 100000 + abb;\n \t\t\telse ans = abb;\n \t\t}else{\n \t\t\tif(len == 8){\n \t\t\t\tif(abb < 3099)ans = 10000 + abb;\n \t\t\t\telse ans = abb;\n \t\t\t}else{\n \t\t\t\tif(len == 7){\n \t\t\t\t\tif(abb < 100){\n \t\t\t\t\t\tif(abb < 99)ans = 3000 + abb;\n \t\t\t\t\t\telse ans = 2099;\n \t\t\t\t\t}\n \t\t\t\t\telse ans = 2000 + abb;\n \t\t\t\t}else{\n \t\t\t\t\tif(len == 6){\n \t\t\t\t\t\tif(abb == 99)ans = 1999;\n \t\t\t\t\t\telse ans = 2000 + abb;\n \t\t\t\t\t}else{\n \t\t\t\t\t\tif(abb == 9)ans = 1989;\n \t\t\t\t\t\telse ans = 1900 + abb;\n \t\t\t\t\t}\n \t\t\t\t}\n \t\t\t}\n \t\t}\n \t}\n \t\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d3e6449d8d7fc4bd34f2a94c68c0cfb7", "src_uid": "31be4d38a8b5ea8738a65bfee24a5a21", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#include\n#include \n#include \n\n#define ll long long\n#define pb push_back\n#define mp make_pair\n#define loop(i,a,n) for(int i=a;i\n#define pll pair\n#define pli pair\n#define pil pair\n#define FF first\n#define SS second\n#define PI acos(-1.0)\n\nusing namespace std;\nusing namespace __gnu_pbds;\n\ntypedef tree,\n rb_tree_tag, tree_order_statistics_node_update> anik;\n\nconst int MOD = 1e9 + 7;\nconst ll MX= 1e9;\nconst ll INF = 1e9;\n\nmain()\n{\n int t;\n cin>>t;\n while(t--)\n {\n string s;\n cin>>s;\n int k=strlen(s)-4,year=atoi(s+4),f=0,tenpow=10;\n loop(i,0,k-1)\n {\n f+=tenpow;\n tempow*=10;\n\n }\n while(year< 1989+f)year+=tenpow;\n cout<\n#include \n#include \n\nusing namespace std;\nstring a,b,c;\nlong long j,i,n,k;\nlong long x;\n\nint main(){\n cin>>a;\nfor(i=0;i\nusing namespace std;\nchar A[52];\nint len;\nmapmp;\nvoid slide()\n{\n\tchar t=A[0];\n\tfor(int i=0;i\n#include \n#include \n#include \n\nint compareInt(const void* a, const void* b) {\n\tint x = *(int*)a;\n\tint y = *(int*)b;\n\tif (x < y) {\n\t\treturn -1;\n\t}\n\tif (x > y) {\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\nstd::vector getSimpleNumbers(const int n) {\n\tstd::vector result;\n\tint for_to = sqrt(n);\n\tfor (int i = 1; i <= for_to; i++) {\n\t\tif (n % i == 0) {\n\t\t\tresult.push_back(i);\n\t\t\tresult.push_back(n / i);\n\t\t}\n\t}\n\treturn result;\n}\n\nstd::vector sortVector(std::vector v) {\n\tstd::shared_ptr temp(new int[v.size()]);\n\tint i = 0;\n\tfor (std::vector::iterator it = v.begin(); it != v.end(); ++it) {\n\t\ttemp.get()[i++] = *it;\n\t}\n\tstd::qsort(temp.get(), i, sizeof(int), compareInt);\n\tstd::vector result;\n\tfor (int j = 0; j < i; j++) {\n\t\tresult.push_back(temp.get()[j]);\n\t}\n\treturn result;\n}\n\nint main() {\n\tstd::string s;\n\tstd::cin >> s;\n\tint sizeS = s.length();\n\tstd::vector simple = sortVector(getSimpleNumbers(sizeS));\n\t//for (int i = 0; i < simple.size(); i++) {\n\t//\tstd::cout << simple[i] << \" \";\n\t//}\n\tsimple.pop_back();\n\tfor (std::vector::iterator it = simple.begin(); it != simple.end(); ++it) {\n\t\tbool resultIsGetted = true;\n\t\tfor (int i = *it; i < sizeS; i++) {\n\t\t\tif (s[i] != s[i % *it]) {\n\t\t\t\tresultIsGetted = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (resultIsGetted) {\n\t\t\tstd::cout << *it;\n\t\t\treturn 0;\n\t\t}\n\t}\n\tstd::cout << sizeS;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b405a969d5436b7a995dc95e9ce1ac34", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e", "difficulty": 900.0} {"lang": "MS C++ 2017", "source_code": "#include \n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n\tseta;\n\tstring b;\n\tcin >> b;\n\tfor (int i = 0; i < b.size(); i++)\n\t{\n\t\tchar t = b[0];\n\t\tfor (int i = 0; i \n#include \n#include \nusing namespace std;\n\nvoid main(){\n\n\tint n;\n\tcin >> n;\n\n\tvector weights;\n\tint input;\n\twhile(cin >> input){\n\t\tweights.push_back(input);\n\t}\n\n\tsort(weights.begin(), weights.end());\n\n\tvector diffs;\n\tfor(int i = 1 ; i<2 * n ; i++){\n\t\tdiffs.push_back(weights[i] - weights[i - 1]);\n\t}\n\t\n\tint count = 0;\n\twhile(!diffs.empty()){\n\t\tint min = min_element(diffs.begin(), diffs.end());\n\t\tcount += min;\n\t\tdiffs.erase(min - diffs.begin() - 1);\n\t\tdiffs.erase(min - diffs.begin());\n\t}\n\n\tcout << count;\n\t\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d0135ea8987cf55c30be36ad16293990", "src_uid": "76659c0b7134416452585c391daadb16", "difficulty": 1500.0} {"lang": "MS C++ 2017", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\nvoid main(){\n\n\tint n;\n\tcin >> n;\n\n\tvector weights;\n\tint input;\n\twhile(cin >> input){\n\t\tweights.push_back(input);\n\t}\n\n\tsort(weights.begin(), weights.end());\n\n\tvector diffs;\n\tfor(int i = 1 ; i<2 * n ; i++){\n\t\tdiffs.push_back(weights[i] - weights[i - 1]);\n\t}\n\t\n\tint count = 0;\n\twhile(!diffs.empty()){\n\t\tint * min;\n\t\tmin = min_element(diffs.begin(), diffs.end());\n\t\tcount += *min;\n\t\tdiffs.erase(min - diffs.begin() - 1);\n\t\tdiffs.erase(min - diffs.begin());\n\t}\n\n\tcout << count;\n\t\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "feebb85901cea37994d08c100f8fa605", "src_uid": "76659c0b7134416452585c391daadb16", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#include \n \nusing namespace std;\ntypedef long long ll;\nint main() {\n\tint n,b;\n\tcin >> n;\n\tvector a;\n\tfor(int x=0;x>b;\n\t\ta.push_back(b);\n\t}\n\tsort(a.begin(),a.end());\n\tvector> dif;\n\tfor(int x=0;xb2){\n\t\ta.erase(a.begin()+dif[0].second);\n\t}else{\n\t\ta.erase(a.begin()+dif[0].second+1);\n\t}\n\tdif.clear();\n\tfor(int x=0;xb2){\n\t\ta.erase(a.begin()+dif[0].second);\n\t}else{\n\t\ta.erase(a.begin()+dif[0].second+1);\n\t}\n\tint sum=0;\n\tfor(int x=0;x\n#include \n#include \n\n#define uint unsigned int\n#define ll long long\n#define ull unsigned long long\n#define ld long double\n#define rep(i, l, r) for (int i = l; i < r; i++)\n#define repb(i, r, l) for (int i = r; i > l; i--)\n#define sz(a) (int)a.size()\n#define fi first\n#define se second\n#define mp(a, b) make_pair(a, b)\n\nusing namespace std;\n\nconst int N = 100000;\nconst int inf = (int)1e9 + 1;\nconst ll big = (ll)1e18 + 1;\nconst int P = 239;\nconst int MOD = (int)1e9 + 7;\nconst int MOD1 = (int)1e9 + 9;\nconst double eps = 1e-9;\nconst double pi = atan2(0, -1);\n\nll bin_pow(ll a, ll p)\n{\n ll res = 1;\n while (p)\n {\n if (p & 1)\n res = (res * a) % MOD;\n a = (a * a) % MOD;\n p >>= 1;\n }\n return res;\n}\n\nll rev(ll x)\n{\n return bin_pow(x, MOD - 2);\n}\n\nll solve(ll n, ll k)\n{\n n %= MOD;\n ll pw[k + 2];\n pw[0] = 0;\n rep(i, 1, k + 2)\n {\n pw[i] = bin_pow(i, k);\n pw[i] = (pw[i] + pw[i - 1]) % MOD;\n }\n if (n <= k + 1)\n return pw[n];\n ll cur = 1, ans = 0;\n rep(i, 1, k + 2)\n {\n cur = cur * (n - i) % MOD;\n cur = cur * rev(0 - i + MOD) % MOD;\n }\n rep(i, 0, k + 2)\n {\n ans = (ans + pw[i] * cur) % MOD;\n if (i == k + 1)\n break;\n cur = cur * (n - i) % MOD;\n cur = cur * rev(n - (i + 1)) % MOD;\n cur = cur * rev(i + 1) % MOD;\n cur = cur * (-((k + 1) - i) + MOD) % MOD;\n }\n return ans;\n}\n\nint main()\n{\n //freopen(\"a.in\", \"r\", stdin);\n //freopen(\"a.out\", \"w\", stdout);\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.precision(20);\n //ll TL = 0.95 * CLOCKS_PER_SEC;\n //clock_t time = clock();\n ll n, k;\n cin >> n >> k;\n cout << solve(n, k) << \"\\n\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "24283265964d6ec78bfac9a926d07e6a", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include \ntypedef long long LL;\n/*------ Welcome to visit blog of dna049: http://dna049.com ------*/\nconst int N = 1e6+6;\nconst LL mod = 1e9+7;\nint sp[N],p[N];\nint spf(){ // samllest prime factor\n int cnt=0;p[cnt++]=2;\n for(int i=2;i>=1; x=x*x%p;\n }\n return r;\n}\nLL inv[N],finv[N],f[N];\nLL getpowsum(LL n,int k){\n if(k==0) return n%mod;\n if(inv[0]==0){\n spf();\n inv[0]=inv[1]=finv[0]=finv[1]=1;\n for(int i=2;i=mod) f[i]-=mod;\n }\n if(n<=k) return f[n];\n LL nk=1;\n for(int i=0;i<=k;++i) nk = nk*(n-i)%mod;\n LL res = 0;\n for(int i=1;i<=k;++i){ // because f(i)=0\n LL x = f[i]*nk%mod*inv[n-i]%mod*finv[i]%mod*finv[k-i]%mod;\n if((k-i)&1) res-=x; // be careful\n else res+=x;\n }\n return (res%mod+mod)%mod;\n}\nint main(){\n// freopen(\"/Users/dna049/Desktop/AC/in\",\"r\",stdin);\n LL n;\n int k;\n while(cin>>n>>k){\n cout<\n#define st first\n#define nd second\n#define FOR(i,a,b) for(int i=(a),b_=(b);i=b_;--i)\n#define FORE(i,a,b) for(int i=(a),b_=(b);i<=b_;++i)\n#define TR(c, it) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)\n#define PI 2 * acos(0)\n#define TASK test\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef unsigned long long ull;\ntypedef pair II;\ntypedef pair III;\ntypedef pair LL;\ntypedef vector VI ;\ntypedef vector VII;\ntypedef vector< VI> VVI;\n\ninline void read (int &x)\n{\n register char c = getchar();\n x = 0;\n bool neg = 0;\n for(; ((c < '0' || c > '9') && c != '-'); c = getchar());\n if (c == '-')\n {\n neg = 1;\n c = getchar();\n }\n for(; c >= '0' && c <= '9'; c=getchar())\n x = (x << 1) + (x << 3) + (c - '0');\n if(neg)\n x = -x;\n}\n\nconst int MOD = 1e9 + 7 ;\nconst int MAXN = 1e5 + 5 ;\nconst ll LNF = 1e18;\nconst int INF = 1e9 + 10 ;\nconst int BASE = 31 ;\n\nint a[MAXN];\nint fac[MAXN];\nint rfac[MAXN];\nint pref[MAXN];\nint suff[MAXN];\n\nint power(int n, int k, int p = MOD)\n{\n int r = 1;\n for (; k; k >>= 1)\n {\n if (k & 1) r = (long long) r * n % p;\n n = (long long) n * n % p;\n }\n return r;\n}\nvoid build()\n{\n fac[0] = rfac[0] = 1;\n for (int i = 1; i < MAXN; i++)\n {\n fac[i] = (long long) fac[i - 1] * i % MOD;\n rfac[i] = power(fac[i], MOD - 2);\n }\n}\nint interpolation(int x, int k)\n{\n pref[0] = suff[k + 1] = 1;\n for (int i = 1; i <= k; i++)\n {\n pref[i] = (long long) pref[i - 1] * (x - i + MOD) % MOD;\n }\n for (int i = k; i >= 1; i--)\n {\n suff[i] = (long long) suff[i + 1] * (x - i + MOD) % MOD;\n }\n int res = 0;\n for (int i = 1; i <= k; i++)\n {\n if (!((k - i) & 1))\n {\n res = (res + (long long) pref[i - 1] * suff[i + 1] % MOD * rfac[i - 1] % MOD * rfac[k - i] % MOD * a[i]) % MOD;\n }\n else\n {\n res = (res - (long long) pref[i - 1] * suff[i + 1] % MOD * rfac[i - 1] % MOD * rfac[k - i] % MOD * a[i] % MOD + MOD) % MOD;\n }\n }\n return res;\n}\n\nint main()\n{\n build();\n int n,k;\n //freopen(\"inp.txt\",\"r\",stdin);\n\n cin >> n >> k\n for (int i = 1; i < MAXN ; i++)\n a[i] = (power(i,k) + a[i-1]) % MOD;\n cout << interpolation(n,k+2)<\n#include \n#include \n#include \n#include \n/*------ Welcome to visit blog of dna049: http://dna049.com ------*/\nconst int N = 1e6+6;\nconst LL mod = 1e9+7;\nint sp[N],p[N];\nint spf(){ // samllest prime factor\n int cnt=0;p[cnt++]=2;\n for(int i=2;i>=1; x=x*x%p;\n }\n return r;\n}\nLL inv[N],finv[N],f[N];\nLL getpowsum(LL n,int k){\n if(k==0) return n%mod;\n if(inv[0]==0){\n spf();\n inv[0]=inv[1]=finv[0]=finv[1]=1;\n for(int i=2;i=mod) f[i]-=mod;\n }\n if(n<=k) return f[n];\n LL nk=1;\n for(int i=0;i<=k;++i) nk = nk*(n-i)%mod;\n LL res = 0;\n for(int i=1;i<=k;++i){ // because f(i)=0\n LL x = f[i]*nk%mod*inv[n-i]%mod*finv[i]%mod*finv[k-i]%mod;\n if((k-i)&1) res-=x; // be careful\n else res+=x;\n }\n return (res%mod+mod)%mod;\n}\nint main(){\n// freopen(\"/Users/dna049/Desktop/AC/in\",\"r\",stdin);\n LL n;\n int k;\n while(cin>>n>>k){\n cout<\n#include \nusing namespace std;\n\nint main()\n{\n\tint x, y;\n\tcin >> x >> y;\n\n\tdouble n = sqrt(x*x + y*y);\n\n\tif (x * y >= 0)\n\t{\n\t\tn = floor(n - 0.001);\n\n\t\tif (n % 2 == 0)\n\t\t\tcout << \"black\";\n\t\telse\n\t\t\tcout << \"white\";\n\t}\n\telse\n\t{\n\t\tn = floor(n + 0.001);\n\n\t\tif (n % 2 == 0)\n\t\t\tcout << \"white\";\n\t\telse\n\t\t\tcout << \"black\";\n\t}\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6fa993006591bb0ab710ff959bce724a", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n int x,y\n float n;\n cin>>x>>y;\n n=sqrt(x*x+y*y);\n if(ceil(n)>n)\n if(x*y>0==(((int)(ceil(n)))&1)) cout<<\"black\";\n else cout<<\"white\";\n else cout<<\"black\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3575a2c67423e2fc274b4f71ff0bc763", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\n#define BLACK black\n#define WHITE white\n\nusing namespace std;\n\nint main()\n{\n\tint x, y;\n\tcin >> x >> y;\n\n\tint n = floor(sqrt(x*x + y*y));\n\n\tif (x * y >= 0)\n\t{\n\t\tif (n % 2 == 0)\n\t\t\tcout << BLACK;\n\t\telse\n\t\t\tcout << WHITE;\n\t}\n\telse\n\t{\n\t\tif (n % 2 == 0)\n\t\t\tcout << WHITE;\n\t\telse\n\t\t\tcout << BLACK;\n\t}\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0dc88563172072ae13de86504e335deb", "src_uid": "8c92aac1bef5822848a136a1328346c6", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nint x,y,k,r=1;\n\nint main(){\n cin>>x>>y;\n if(x==4&&y==3){\n cout<<\"black\"<\n#include \nusing namespace std;\nint main() {\n\tint n, k;\n\tcin >> n >> k;\n\tvector v;\n\tfor (int mod = 1; mod <= min(k - 1, n); mod++) {\n\t\tif (n % mod == 0) {\n\t\t\tint left = n / mod;\n\t\t\tv.push_back(k * left + mod);\n\t\t}\t\n\t}\n\tsort(v.begin(), v.end());\n\tcout << v[0] << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f4b08549a6a097ad6dab34077e4c7d5a", "src_uid": "ed0ebc1e484fcaea875355b5b7944c57", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\nusing namespace std;\nll n,m,i,j,k,l,a,b,c,ans,an;\nint main(){\n\tscanf(\"%d%d\",&n,&k);\n\tans=99999999999999999LL;\n\tfor (int i=1;i\n#define fastio ios::sync_with_stdio(0);cin.tie(0)\n#define pb push_back\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\nconst ll INF = 9223372036854775807LL;\n\nvoid solve() {\n\tll n, k;\n\tcin >> n >> k;\n\tll answer = INF;\n\tfor (int r = 1; r < k; r++) {\n\t\tll x = k * n / r + r;\n\t\tll q = x / k;\n\t\tif ((k * n) % r == 0 and q * r = n)\n\t\t\tanswer = min(answer, x);\n\t}\n\tcout << answer << endl;\n}\n\nint main() {\n\tfastio;\n\tint t = 1;\n\t//cin >> t;\n\twhile (t--) solve();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1d0131cde99b498d5674d687eb44dbf2", "src_uid": "ed0ebc1e484fcaea875355b5b7944c57", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\n#define _ << \" \" <<\n\n#define ull unsigned long long\n\n\nint main() {\n\tios::sync_with_stdio(false);\n\n\tull k, n; cin >> n >> k;\n\n\tull ans = 1e18+1;\n\n\tfor (int i = 1; i <= ceil(sqrt((double)n)); ++i){\n\t\tif (n % i == 0){\n\t\t\tull x = i, y = n/i;\n\t\t\tx = min(x, y), y = max(i, y);\n\t\t\tans = min(y*k+x, ans);\n\t\t\tif (y < k){\n\t\t\t\tans = min(x*k+y, ans);\n\t\t\t}\n\t\t}\n\t}\n\n\tcout << ans;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c74560971bd44cf5bfbfb1ab40fe39cc", "src_uid": "ed0ebc1e484fcaea875355b5b7944c57", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define ll long long\n#define li long int\n#define pb push_back\n/*int fun(int a[],int ans,int n)\n{\n\tstatic int i=-1;\n\t\n\t\n\t\tif(ans==0)\n\t\t{\n\t\t\tcout<<\"YES\";\n\t\t\treturn 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcout< sum) \n return isSubsetSum(set, n-1, sum); \n \n /* else, check if sum can be obtained by any of the following \n (a) including the last element \n (b) excluding the last element */\n return isSubsetSum(set, n-1, sum) || \n isSubsetSum(set, n-1, sum-set[n-1]); \n} \nint main() {\n \tint n;\n \tcin>>n;\n \tint a[n];\n \t//ll ans[n+1][n+1];\n \tint sum=0;\n \tfor(int i=0;i>a[i];\n \t\tsum+=a[i];\n\t }\n\t\n\t/*for(int i=0;i\nusing namespace std;\nint main()\n{\n int n,i,j,angle;\n cin>>n;\n vector a(n);\n for(i=0;i>a[i];\n for(i=0;i<(1< 0)angle+=a[j];\n else angle-=a[j];\n }\n if(abs(angle)%360==0){ cout<<\"YES\"<\nusing namespace std;\n\nbool **dp;\n\nvoid display(const vector &v) {\n cout << \"YES\";\n exit(0);\n}\n\nvoid printSubsetsRec(int arr[], int i, int sum, vector &p) {\n\n if (i == 0 && sum != 0 && dp[0][sum]) {\n p.push_back(arr[i]);\n display(p);\n return;\n }\n\n if (i == 0 && sum == 0) {\n display(p);\n return;\n }\n\n if (dp[i - 1][sum]) {\n // Create a new vector to store path\n vector b = p;\n printSubsetsRec(arr, i - 1, sum, b);\n }\n\n if (sum >= arr[i] && dp[i - 1][sum - arr[i]]) {\n p.push_back(arr[i]);\n printSubsetsRec(arr, i - 1, sum - arr[i], p);\n }\n}\n\nvoid printAllSubsets(int arr[], int n, int sum) {\n if (n == 0 || sum < 0)\n return;\n\n dp = new bool *[n];\n for (int i = 0; i < n; ++i) {\n dp[i] = new bool[sum + 1];\n dp[i][0] = true;\n }\n\n if (arr[0] <= sum)\n dp[0][arr[0]] = true;\n\n for (int i = 1; i < n; ++i)\n for (int j = 0; j < sum + 1; ++j)\n dp[i][j] =\n (arr[i] <= j) ? dp[i - 1][j] || dp[i - 1][j - arr[i]] : dp[i - 1][j];\n if (dp[n - 1][sum] == false) {\n printf(\"NO\");\n return;\n }\n\n vector p;\n printSubsetsRec(arr, n - 1, sum, p);\n}\n\nint main() {\n long int n, summ = 0;\n cin >> n;\n int arr[n];\n for (int i = 0; i < n; i++) {\n cin >> arr[i];\n summ += arr[i];\n }\n\n if (summ % 360 == 0) {\n cout << \"YES\";\n return 0;\n } \n if(summ %2 != 0)\n {\n cout<<\"NO\";\n return 0;\n }\n else {\n summ = summ % 360;\n summ = summ / 2;\n printAllSubsets(arr, n, summ);\n return 0;\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "76a1a92282116b9aaa64c0118be5a343", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "//#include\n#include\nusing namespace std;\ndouble ans;\nbool b=0;\nvoid subsetSums(int a[], int l, int r,\n double sum=0)\n{\n // Print current subset\n if (l > r)\n {\n if(b)return;\n if(sum==ans || (int(sum)%360==0 && sum!=0)\n {\n cout <<\"YES\";\n b=1;\n }\n\n return ;\n }\n subsetSums(a, l+1, r, sum+a[l]);\n subsetSums(a, l+1, r, sum);\n}\n\nint main()\n{\n double s=0;\n int m;\n cin>>m;\n int a[m];\n for(int i=0;i>a[i];\n s+=a[i];\n }\n ans=s/2;\n if(int(s)%360==0)\n {\n cout<<\"YES\";\n return 0;\n }\n int n = sizeof(a)/sizeof(a[0]);\n subsetSums(a, 0, n-1);\n if(b==0)cout<<\"NO\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f260a3246b4d332f6ed40570d26f3718", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n \nint n, l, r;\nint sum1, sum2;\n \nint main()\n{\n scanf(\"%d %d %d\", &n, &l, &r);\n for (int i = 0; i < l; i++)\n sum1 += (1 << i);\n sum1 += n - l;\n for (int i = 0; i < r; i++)\n sum2 += (1 << i);\n sum2 += (n - r) * (1 << r - 1);\n printf(\"%d %d\\n\", sum1, sum2);\n return 0;\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fa5720cdf6bc1323fa09c59012865cae", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include\n#include\nusing namespace std;\nint main()\n{\n int n,l,r,i,m=1,sum1=0,sum2=0;\n cin>>n>>l>>r;\n int a[n],c[n],b=pow(2,l-1);\n for(i=0;i\n#define endl \"\\n\"\nusing namespace std;\nlong long n, l, r;\n\nint main()\n{\n#ifdef endl\n\tcin.tie(0);\n\tcout.tie(0);\n\tios::sync_with_stdio(0);\n#endif\n\tcin >> n >> l >> r;\n\tll sum = 0;\n\tll t = 1;\n\tfor (int i = 1; i <= l; i++){\n\t\tsum += t;\n\t\tif(t == 1)t++;\n\t\telse t += 2;\n\t}\n\tsum += (n - l);\n\tll res = 0;\n\tt = 1;\n\tfor (int i = 1; i <= min(r, n); i++){\n\t\tres += t;\n\t\tt *= 2;\n\t}\n\tif(n > r){\n\t\tt /= 2;\n\t\tres += t * (n - r);\n\t}\n\tcout << sum << \" \" << res << endl; \n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "aca674eb5bc31fb055c8524d2f562d99", "src_uid": "ce220726392fb0cacf0ec44a7490084a", "difficulty": 900.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main(){\n int n,l,r,ans=0,a=1,min,max;\n \n} for( int i=0;i\n\nusing namespace std;\n\nint main()\n{\n long long n,k;\n cin >> n >> k;\n if((n/k)%2==0)\n {\n cout << \"NO\";\n }\n else\n {\n cout<< \"YES\"\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e0554ca054f19addb5145b8b1c87c314", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nint main()\n{\n int n,x,k;\n cin>>n>>k;\n x=abs(n/k);\n if (x%2!=0)\n {\n cout<<\"YES\";\n }else \n {\n cout<<\"NO\";\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3be7a2f6dd6988e2c221a502a861b12f", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n\n\n long long n,k,s=0,l=0,flag=-1,x;\n\n cin>>n>>k;\n\n //x = n%k;\n\n if(n%k==0)\n {\n if((n/k)%2==0)\n cout<<\"NO\"\n else\n cout<<\"YES\";\n }\n else\n {\n x = n/k;\n if(x%2==0)\n cout<<\"NO\";\n else\n cout<<\"YES\";\n }\n\n\n //while(x>=k)\n //{\n //x = x-k;\n\n //if(flag==-1)\n //{\n //s++;\n //}\n\n //if(flag==1)\n //{\n // l++;\n\n //}\n\n //flag=flag*-1;\n\n //}\n\n // if(s>l)\n //cout<<\"YES\";\n //else\n //cout<<\"NO\";\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "41e370288650430d63e4e97e8040011b", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "\ufeff\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio 2012\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"rounds\", \"rounds\\rounds.vcxproj\", \"{039B3D26-CAA0-49AF-9A30-7299C92235A4}\"\nEndProject\nGlobal\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n\t\tDebug|Win32 = Debug|Win32\n\t\tRelease|Win32 = Release|Win32\n\tEndGlobalSection\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n\t\t{039B3D26-CAA0-49AF-9A30-7299C92235A4}.Debug|Win32.ActiveCfg = Debug|Win32\n\t\t{039B3D26-CAA0-49AF-9A30-7299C92235A4}.Debug|Win32.Build.0 = Debug|Win32\n\t\t{039B3D26-CAA0-49AF-9A30-7299C92235A4}.Release|Win32.ActiveCfg = Release|Win32\n\t\t{039B3D26-CAA0-49AF-9A30-7299C92235A4}.Release|Win32.Build.0 = Release|Win32\n\tEndGlobalSection\n\tGlobalSection(SolutionProperties) = preSolution\n\t\tHideSolutionNode = FALSE\n\tEndGlobalSection\nEndGlobal\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a6e4da78e8b2a24676a23a447ea928c1", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nint main()\n{\n int n;\n string s;\n cin>>n>>s;\n strng g;\n char c='a';int t=0;\n char d = 'a';\n for(int i=0;i=c)\n {\n g=g+'0';\n c=s[i];\n }\n else if(s[i]>=d)\n {\n g=g+'1';\n d=s[i];\n }\n else \n t==1;\n \n }\n if(t==1)\n cout<<\"\" NO\"<\n#include \n#include \n#include \n \nusing namespace std;\n \nstring s;\n\nint f[210],int n;\n\nbool flag;\n\nint main()\n{\n cin>>n>>s;\n f[0]=1;\n for(int i=1;is[i]) f[i]=max(f[i],f[j]+1);\n if(f[i]>2)\n {\n flag=true;\n break;\n } \n }\n if(flag)\n {\n cout<<\"NO\"<\n\nusing namespace std;\n\n#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)\n#define ll long long int\n#define vi vector\n#define vii vector >\n#define pll pair\n#define f(i,a,b) for(ll i=a;i=b;i--)\n#define all(c) c.begin(),c.end()\n#define sz(c) (ll)c.size()\n#define lcm(a,b) (a*b)/(__gcd(a,b))\n#define init(x,a) memset(x,a,sizeof(x))\n#define lbd(a,val) lower_bound(all(a),val)\n#define ubd(a,val) upper_bound(all(a),val)\n#define pb push_back\n#define mp make_pair\n#define F first\n#define S second\n#define en '\\n'\n#define mod (ll)1000000007\n#define M (ll)998244353\n#define N 5002\n#define PI 3.14159265358979323846\nll power(ll x,ll y)\n{\n if(y==0)\n return 1;\n else if(y%2 == 0) //n is even\n return power((x*x)%mod,y/2);\n else //n is odd\n return (x*power((x*x)%mod,(y-1)/2))%mod;\n\n}\nll modInverse(ll n) \n{ \n return power(n,mod-2); \n}\nint a[26],ans[200005];\nint main()\n{\n//\tIOS;\n\tint t=1;\n//\tcin>>t;\n\twhile(t--)\n\t{\n\t\tll n,c=0;\n\t\tstring s;\n\t\tcin>>n>>s;\n\t\tf(i,0,n){\n\t\t\tfor(ll j=s[i]-'a';j>=0;j--){\n\t\t\t\tif(a[j]){\n\t\t\t\t\tans[i]=a[j];\n\t\t\t\t\tif(j!=s[i]-'a'){\n\t\t\t\t\t\ta[s[i]-'a']=a[j];\n\t\t\t\t\t\ta[j]=0;\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(!ans[i]){\n\t\t\t\tc++;\n\t\t\t\tans[i]=c;\n\t\t\t\ta[s[i]-'a']=c;\n\t\t\t}\n\t\t}\n\t\tif(c>2)\n\t\t\tcout<<\"NO\"<\n#define INF 0x3f3f3f3f\nusing namespace std;\ntypedef long long ll;\n\nint main(){\n\t#ifdef _DEBUG\n\t\tfreopen(\"input.txt\", \"r\", stdin);\n\t#endif\n\tint n;\n\tstring s, res;\n\tchar lst0 = 'a', lst1 = 'a';\n\tcin>>n>>s;\n\tfor(int i = 0; i < n; i++){\n\t\tif(s[i] >= lst0)\n\t\t\tres += '0';\n\t\t\tlet0 = s[i];\n\t\telse if(s[i] >= lst1){\n\t\t\tres += '1';\n\t\t\tlst1 = s[i];\n\t\t}\n\t\telse{\n\t\t\tcout<<\"NO\"<\n#include \nusing namespace std;\n\nbool check(int n) {\n\tint arr[10] = { 0, };\n\twhile (n > 0) {\n\t\tarr[n % 10]++;\n\t\tn /= 10;\n\t}\n\tfor (int i = 0; i < 10; i++) {\n\t\tif (arr[i] > 1) return false;\n\t}\n\treturn true;\n}\nvoid main() {\n\tint a, b; cin >> a >> b;\n\tint flag = 0;\n\tfor (int i = a; i <= b; i++) {\n\t\tif (check(i)) {\n\t\t\tflag = 1;\n\t\t\tcout << i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (!flag) cout << -1;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2745a6931a1d8df6beaf68a2740e7c5e", "src_uid": "3041b1240e59341ad9ec9ac823e57dd7", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#include \n#include \nusing namespace std;\n\nbool check(int n) {\n\tint arr[10] = { 0, };\n\twhile (n > 0) {\n\t\tarr[n % 10]++;\n\t\tn /= 10;\n\t}\n\tfor (int i = 0; i < 10; i++) {\n\t\tif (arr[i] > 1) return false;\n\t}\n\treturn true;\n}\nvoid main() {\n\tint a, b; cin >> a >> b;\n\tint flag = 0;\n\tfor (int i = a + 1; i < b; i++) {\n\t\tif (check(i)) {\n\t\t\tflag = 1;\n\t\t\tcout << i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (!flag) cout << -1;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d9355a3242785532cdafff81e66fdf63", "src_uid": "3041b1240e59341ad9ec9ac823e57dd7", "difficulty": 800.0} {"lang": "MS C++ 2017", "source_code": "#include \n#define ll long long\n#define sc scanf\n#define pr printf\nusing namespace std;\nbool jzk(int k)\n{\n\tbool vis[10];\n\tmemset(vis, 0, sizeof(vis));\n\twhile (k)\n\t{\n\t\tif (vis[k % 10] == true)\n\t\t\treturn false;\n\t\tvis[k % 10] = true;\n\t\tk /= 10;\n\t}\n\treturn true;\n}\nint main()\n{\n\tint a, b;\n\tsc(\"%d%d\", &a, &b);\n\tfor (int i = a; i <= b; i++)\n\t{\n\t\tif (jzk(i))\n\t\t{\n\t\t\tpr(\"%d\", i);\n\t\t\treturn 0;\n\t\t}\n\t}\n\tpr(\"-1\");\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "029b5aac52e8a376c5c8e1bae14ceec9", "src_uid": "3041b1240e59341ad9ec9ac823e57dd7", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n/*\nvoid print_list(vector n)\n{\n for(int i=0; i numbers = {0,1,2,3,4,5,6,7,8,9};\n\nint r;\n\nstring l;\nint l_int;\nint l_size;\n\nint max_num=0;\nint min_num=0;\n\nint T=0;\n\nint main()\n{\n int num;\n\n vector::iterator upper;\n\n cin>>l>>r;\n\n int l_int = stoi(l);\n l_size = l.size();\n vector l_nums(l_size);\n\n for(int i=0; ir)\n {\n cout<<-1;\n }\n else\n {\n cout<\nusing namespace std;\nint main(){\n\tint a,b;\n\tint n\n\t\tcin>>a>>b;\n\t\tfor(int j=3;j<=n;j++){\n\t\t\tc=a+b;\n\t\t\ta=b;\n\t\t\tb=c;\n\t\t\t}\n\tcout<\nusing namespace std;\nint a,b,n,f[10001];\nint main(){\n cin>>a>>b>>n;\n f[0]=a;\n f[1]=b;\n for(int i=2;i<=n;i++)\n f[i]=f[i-1]+f[i-2];\n cout<\nusing namespace std;\nint main(){\n\tint a,b,c;\n\tcin>>a>>b>>c;\n\tc++;\n\tint arr[c+1];\n\tarr[1]=x;\n\tarr[2]=y;\n\tfor(int i=3;i<=c;i++){\n\t\tarr[i]=arr[i-1]+arr[i-2];\n\t}\n\tcout<\n#include \nusing namespace std;\nint main()\n{\n int a1,a2,n,i;\n cin >> a1 >> a2 >> n;\n int a[1000];\n a[0]=a1;\n a[1]=a2;\n for(i=2;i<=a3;i++)\n a[n]=a[n-1]+a[n-2];\n cout << a[n] << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c2fcc37ac54dcadca8e0a8af7c646163", "src_uid": "6ff30f5a9afc3f7befca813469188aab", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace::std;\n\nconst int INF = (int) 2e9, M = 1024 * 1024 + 5;\n\nchar z[25][25];\nstring przek[45];\nint n, licz;\nint dp[45][M], pot[25];\nbool o[45][M];\n\npair nowa(int x, int nr) {\n int wyn = 0;\n if (nr < n) {\n x <<= 1;\n for (int i = nr; i >= 1; i--)\n if (x & pot[i]) {\n wyn |= pot[i];\n wyn |= pot[i - 1];\n }\n nr++;\n } else {\n nr = 2 * n - nr;\n if (pot[nr - 1] & x) wyn |= pot[nr - 2];\n if (pot[0] & x) wyn |= pot[0];\n for (int i = nr - 2; i >= 1; i--)\n if (x & pot[i]) {\n wyn |= pot[i];\n wyn |= pot[i - 1];\n }\n }\n return {wyn, nr};\n}\n\nvoid zrob(int stan, int nr) {\n if (nr != 2 * n - 1) {\n if (nr % 2 == 0) dp[nr][stan] = -INF;\n else dp[nr][stan] = INF;\n }\n int tab[30];\n for (int i = 0; i < 26; i++) tab[i] = 0;\n pair nast = nowa(stan, nr);\n int kolDL = nast.second;\n int kolSTAN = nast.first;\n for (int i = 0; i < kolDL; i++\n tab[przek[nr + 1][i] - 'a'] |= pot[i];\n int dodaj = 0;\n for (int i = 0; i < 20; i++) {\n if (pot[i] & stan) {\n if (przek[nr][i] == 'a') dodaj = 1;\n else if (przek[nr][i] == 'b') dodaj = -1;\n break;\n }\n }\n for (int i = 0; i < 26; i++) {\n int s1 = tab[i] & kolSTAN;\n if (s1 == 0) continue;\n if (!o[nr + 1][s1] and nr < 2 * n - 1) {\n o[nr + 1][s1] = true;\n zrob(s1, nr + 1);\n }\n if (nr == 2 * n - 1) continue;\n if (nr % 2 == 0) dp[nr][stan] = max(dp[nr][stan], dp[nr + 1][s1] + dodaj);\n else dp[nr][stan] = min(dp[nr][stan], dp[nr + 1][s1] + dodaj);\n }\n}\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin >> n;\n for (int y = 0; y < n; y++) {\n string s;\n cin >> s;\n for (int x = 0; x < n; x++) z[x][y] = s[x];\n }\n for (int x = 0; x < n; x++) {\n int y = 0;\n licz++;\n for (int i = x; i >= 0; i--) {\n przek[licz] += z[i][y];\n y++;\n }\n }\n for (int y = 1; y < n; y++) {\n int x = n - 1;\n licz++;\n for (int i = y; i < n; i++) {\n przek[licz] += z[x][i];\n x--;\n }\n }\n pot[0] = 1;\n for (int i = 1; i < n; i++) pot[i] = 2 * pot[i - 1];\n o[1][1]= true;\n int dodaj = 0;\n if (przek[2 * n - 1][0] == 'a') dodaj = 1;\n else if (przek[2 * n - 1][0] == 'b') dodaj = -1;\n dp[2 * n - 1][1] = dodaj;\n zrob(1, 1);\n if (dp[1][1] == 0) cout << \"DRAW\";\n else if (dp[1][1] < 0) cout << \"SECOND\";\n else cout << \"FIRST\";\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6e4decffe28940ef90d54ac9c51c7492", "src_uid": "d803fe167a96656f8debdc21edd988e4", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n#define pb push_back\n#define mp make_pair\n#define sz(s) ((int)(s.size()))\n#define bg begin()\n#define en end()\n#define Y second\n#define X first\ntypedef long long ll;\n#define fi freopen(\"input.txt\",\"r\",stdin)\n#define fo freopen(\"output.txt\",\"w\",stdout)\nconst double pi = acos(-1.0);\nconst double eps = 1e-8;\n#define print(a) cout<<(#a)<<\" = \"<\n\n#define EPS 1e-9\n#define INF 1070000000LL\n#define MOD 1000000007LL\n#define fir first\n#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)\n#define ite iterator\n#define mp make_pair\n#define mt make_tuple\n#define rep(i,n) rep2(i,0,n)\n#define rep2(i,m,n) for(int i=m;i<(n);i++)\n#define pb push_back\n#define sec second\n#define sz(x) ((int)(x).size())\n\nusing namespace std;\n\ntypedef istringstream iss;\ntypedef long long ll;\ntypedef pair pi;\ntypedef stringstream sst;\ntypedef vector vi;\n\nint n;\nstring T[22];\nint s[22][22];\n//int dp[22][22];\nint dy[]={0,1};\n//int dx[]={1,0};\nint score[128];\n\nvector dp[40];\n\nvector Y[40],X[40];\n\nint f(int yx,int mask){\n\tint& res=dp[yx][mask];\n\tif(res!=-1)return res;\n\tif(yx==2*n-2)return res=0;\n\tif(yx&1)res=-INF;\n\telse res=INF;\n\t\n\t/*int ok[22][22];\n\tmemset(ok,0,sizeof(ok));\n\trep(i,sz(Y[yx])){\n\t\tif(mask>>i&1){\n\t\t\tok[Y[yx][i]][X[yx][i]]=1;\n\t\t}\n\t}*/\n\t/*int ok[22]={};\n\trep(i,sz(Y[yx])){\n\t\tif(mask>>i&1){\n\t\t\tok[Y[yx][i]]=1;\n\t\t}\n\t}*/\n\tint convY[22]={-1};\n\trep(i,sz(Y[yx])){\n\t\tconvY[Y[yx][i]] = i;\n\t}\n\t\n\trep2(ch,'a','z'+1){\n\t\tint nmask=0;\n\t\trep(i,sz(Y[yx+1])){\n\t\t\tint y=Y[yx+1][i],x=X[yx+1][i];\n\t\t\tif(T[y][x]==ch){\n\t\t\t\t//cout<=0 && (mask>>convY[py]&1)){\n\t\t\t\t\t\tOK=1;break;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t//cout< \"<>n;\n\trep(i,n)cin>>T[i];\n\trep(i,n)rep(j,n){\n\t\ts[i][j] = (T[i][j] == 'a' ? 1 : (T[i][j] == 'b' ? -1 : 0));\n\t}\n\t\n\trep(i,n) dp[i].resize(1<<(i+1),-1);\n\trep(i,n-1) dp[2*n-2-i].resize(1<<(i+1),-1);\n\t\n\trep(i,n)rep(j,n){\n\t\tY[i+j].pb(i);\n\t\tX[i+j].pb(j);\n\t}\n\tscore['a']=1;\n\tscore['b']=-1;\n\t\n\tint res = s[0][0]+f(0,1);\n\tcerr<0 ? \"FIRST\" : (res<0 ? \"SECOND\":\"DRAW\"))<\n#include \n\nlong long n, m;\nstring x, y;\n\nint gcd (int a, int b) {\n if (a == 0 || b == 0) return a + b;\n if (a < b) return gcd (a, b % a);\n return gcd (a % b, b);\n}\n\nint main() {\n ios_base::sync_with_stdio(0);\n cin >> n >> m;\n cin >> x >> y;\n int g = gcd (x.size(), y.size());\n for (int i = 0; i < g; i++) {\n int X[26], Y[26];\n memset (X, 0, sizeof (X));\n memset (Y, 0, sizeof (Y));\n for (int j = 0; j < (int) x.size(); j += g) {\n X[x[j] - 'a']++;\n }\n for (int j = 0; j < (int) y.size(); j += g) {\n Y[y[j] - 'a']++;\n }\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "726a2e73f4bad7aaa5b3322b225ba2b3", "src_uid": "d803fe167a96656f8debdc21edd988e4", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define ll long long\n\nint main()\n{\n int ar[5];\n for(Int i=0; i<4; i++)\n {\n cin>>ar[i];\n }\n sort(ar,ar+4);\n if(ar[0]+ar[3]==ar[1]+ar[2])\n cout<<\"YES\"<\nusing namespace std ; \nint main ()\n{ \nint a,b,c,d ; \ncin >> a >>b>>c>>d ;\nif ( ((a+c ) ==(b+d)) || ((a+b)==(c+d)) || (a+d)==(b+c) )\ncout << \"yes\";\nelse \ncout <<\"no\";\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "85f0ac1b0c607a97a71244fded39763c", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0} {"lang": "MS C++ 2017", "source_code": "#include \nusing namespace std; \n unsigned long long int sum=0;\n \n int main(){\n \tint A[4];\n \tfor(int i=0;i<4;i++){\n \t\tcin>>A[i];\n\t }\n\t \n\t if(A[0]+A[1]==A[2]+A[3] || A[0]+A[2]==A[1]+A[3] || A[2]+A[1]==A[0]+A[3] || A[0]+A[1]+A[2]==A[3]|| A[1]+A[2]+A[3]==A[0]|| A[2]+A[3]+A[0]==A[1]||)\n\t {\n\t \tcout << \"YES\" << endl;\n\t }\n\t else {\n\t \tcout << \"NO \" << endl;\n\t }\n }\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "905a8ee2dce586ebb3cfa04e1aa4e0c7", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main()\n{\n int a[3];\n for(int i=0;i<4;++i)\n {\n cin>>a[i];\n }\n for(int i=0;i<4;i++)\n {\n if((a[0]+a[i])*2==(a[0]+a[1]+a[2]+a[3]))\n {\n return YES;\n }\n }\n return NO;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "eb8d5d6db2e77a33c7dc5eb1f2b98d5f", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "//\r\n// main.cpp\r\n// 1603E\r\n//\r\n// Created by BuffaloHome on 11/6/21.\r\n//\r\n\r\n#include \r\nusing namespace std;\r\n\r\n/**\r\n Analysis of problem:\r\n array is perfect if after sorted:\r\n for any index i:\r\n a0 * ai >= a0 + ... + ai\r\n or equiv:\r\n (a0-1) * ai >= a0 + ... + a[i-1]\r\n \r\n Consider a0 fixed.\r\n Denote f[i, s] to be:\r\n number of perfect sequence with length i, sum = s, maximum is m.\r\n \r\n f[i, s, m] =sum_o f[i - o, s - 0*m, m-1] * C()\r\n TLE, optimize?\r\n \r\n New idea:\r\n condition is equivalent to:\r\n at any point in sequence:\r\n Delta <= a1(ak - k + 1) - ak\r\n ak >= k\r\n \r\n Equivalent:\r\n 1. b1 + ... + bn <= a1\r\n 2. k-th maximum >= n + 2 - k, or if k-th maximum = n+ 1 - k, all value below this equal n + 1 - k.\r\n \r\n Recursive:\r\n f (len, sum, max)\r\n // max is allowed max\r\n \r\n if allowed max is tight: a1 + max = len:\r\n check a1 = len, max = 0,\r\n \r\n allowed max not tight:\r\n Consider the occurences of max.\r\n f = \\sum_o f(len - occ, sum - occ * delta, max - 1)\r\n \r\n */\r\n\r\nint N = 200;\r\nint n, M;\r\nlong long dp[201][201][201];\r\nlong long fac[201];\r\nlong long inv[201];\r\n\r\nlong long power(long long k, int p, int M) {\r\n if (p == 0) {\r\n return 1;\r\n }\r\n long long y = power (k, p/2, M);\r\n long long z = y * y % M;\r\n if (p % 2 == 0) {\r\n return z;\r\n }\r\n else {\r\n return z * k % M;\r\n }\r\n}\r\n\r\nvoid computeMod(int M) {\r\n fac[0] = 1;\r\n for (int i = 1; i <= N; ++i) {\r\n fac[i] = fac[i-1] * i % M;\r\n //cout << fac[i] << \" \";\r\n }\r\n //cout << endl;\r\n \r\n inv[N] = power(fac[N], M-2, M);\r\n for (int i = N - 1; i >= 0; --i) {\r\n inv[i] = inv[i+1] * (i+1) % M;\r\n //cout << inv[i] << \" \";\r\n }\r\n //cout << endl;\r\n}\r\n\r\nlong long f(int len, int max, int sum, int a1) {\r\n \r\n /**\r\n Computes # seq of len such that\r\n b1 + ... + bn <= sum\r\n bn <= max\r\n [a1 + bk >= k + 1\r\n or a1 + bk = k and a1 = k, b1= ... = bk = 0]\r\n */\r\n \r\n if (dp[len][max][sum] != -1) {\r\n return dp[len][max][sum];\r\n }\r\n \r\n if (max == 0 && len > 0) {\r\n dp[len][max][sum] = inv[len];\r\n \r\n // 50 100757149\r\n //cout << \"base: len, max, sum \" << len << \" \" << max << \" \" << sum << \" = \" << dp[len][max][sum] % M << endl;\r\n \r\n return inv[len];\r\n }\r\n \r\n if (a1 + max >= len + 1) {\r\n long long g = 0;\r\n for (int occ = 0; occ <= len && occ * max <= sum ; occ ++) {\r\n long long val = f(len - occ, max - 1, sum - occ * max, a1);\r\n //cout << occ << \" \" << val * inv[occ] << endl;\r\n g = (g + val * inv[occ]) % M;\r\n }\r\n dp[len][max][sum] = g;\r\n //cout << \"len, max, sum \" << len << \" \" << max << \" \" << sum << \" = \" << dp[len][max][sum] % M << endl;\r\n return g;\r\n }\r\n \r\n return 0;\r\n}\r\n\r\n\r\nvoid solve(int n, int M) {\r\n // Find # perfect array of len n, elements 1 <= ai <= n+1\r\n if (n == 1) {\r\n cout << 2 % M;\r\n return;\r\n }\r\n \r\n memset(dp, -1, sizeof(dp));\r\n \r\n computeMod(M);\r\n \r\n long long ans = 0;\r\n for (int a1 = n + 1; a1 >= 1 && a1 >= n - 20; --a1) {\r\n memset(dp, -1, sizeof(dp));\r\n long long val = f(n, n + 1 - a1, a1, a1);\r\n ans = ans + val % M;\r\n // cout << f(n, n+1, a1, a1) * fac[n] % M << \" \" << endl;;\r\n }\r\n \r\n ans = ans * fac[n] % M;\r\n cout << ans << endl;\r\n\r\n return;\r\n}\r\n\r\n\r\nint main() {\r\n // insert code here...\r\n\r\n cin >> n >> M;\r\n \r\n solve (n, M);\r\n \r\n /**\r\n \r\n n = 3;\r\n for (int i = 1; i <= n+1; ++i) {\r\n for (int j = i; j <= n+1; ++j) {\r\n for (int k = j; k <= n+1; ++k) {\r\n if (i * j >= i + j && i * k >= i + j + k) {\r\n cout << i << ' ' << j << \" \" << k << endl;\r\n }\r\n }\r\n }\r\n }\r\n \r\n n = 4;\r\n int cnt = 0;\r\n for (int i = 1; i <= n+1; ++i) {\r\n for (int j = i; j <= n+1; ++j) {\r\n for (int k = j; k <= n+1; ++k) {\r\n for (int l = k; l <= n+1; ++l)\r\n if (i * j >= i + j && i * k >= i + j + k && i * l >= i + j + k + l) {\r\n cout << i << ' ' << j << \" \" << k << \" \" << l <\r\nusing namespace std;\r\nlong long w,n,m,mx[100011],p[100011],cnt,f[100011],idx[21];\r\nbool fl[100011];\r\nvector vec[100011];\r\nlong long solve(long long a,long long b){\r\n\tlong long s=0ll;\r\n\tfor(long long l=a,r;l<=b;l=r+1ll){\r\n\t\tr=b/(b/l);\r\n\t\ts=s+f[b/l]*(r-l+1ll);\r\n\t}\r\n\treturn s;\r\n}\r\nint main(){\r\n\tmx[1ll]=1ll;\r\n\tf[1ll]=1ll;\r\n\tfor(long long i=2ll;i<=100000ll;i++){\r\n\t\tmx[i]=mx[i>>1ll]+1ll;\r\n\t\tif(!fl[i]){\r\n\t\t\tf[i]=i-1ll;\r\n\t\t\tcnt++;\r\n\t\t\tp[cnt]=i;\r\n\t\t}\r\n\t\tfor(long long j=1ll;j<=cnt&&i*p[j]<=100000ll;j++){\r\n\t\t\tfl[i*p[j]]=1ll;\r\n\t\t\tif(i%p[j]==0ll){\r\n\t\t\t\tf[i*p[j]]=f[i]*p[j];\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tf[i*p[j]]=f[i]*f[p[j]];\r\n\t\t}\r\n\t}\r\n\tfor(long long i=1ll;i<=20ll;i++){\r\n\t\tidx[i]=1ll;\r\n\t\tvec[0ll].push_back(0ll);\r\n\t}\r\n\tvec[0ll].push_back(0ll);\r\n\tfor(long long i=1ll;i<=100000ll;i++){\r\n\t\tf[i]=f[i]+f[i-1ll];\r\n\t\tlong long s=0ll;\r\n\t\ts=solve(1ll,i);\r\n\t\tvec[i].push_back(s);\r\n\t\tfor(long long j=1ll;j=mx[n]){\r\n\t\t\tprintf(\"%lld\\n\",n);\r\n\t\t}else{\r\n\t\t\tprintf(\"%lld\\n\",vec[n][m]);\r\n\t\t}\r\n\t}\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "91f18cbad6533ac7254966dee77296b7", "src_uid": "cf57508de47d80bc983861f70bb5f3d6", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "/**\n * @brief codeforces\n * @author yao\n */\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define ft first\n#define sd second\n#ifdef DBG\n# define dbg_pri(x...) fprintf(stderr,x)\n#else\n# define dbg_pri(x...) 0\n# define NDEBUG\n#endif //DBG\n#include \n\ntypedef unsigned int uint;\ntypedef long long int lli;\ntypedef unsigned long long int ulli;\n\n#define N 256\n\nclass Divider{\npublic:\n ulli p,s,k;\n Divider(ulli _p):p(_p)\n {\n s = 127-__builtin_clzll(p-1);\n k = (((unsigned __int128)1<> s;\n }\n ulli mod(ulli x)\n {\n return x - (div(x) * p);\n }\n};\n\nint comb[N][N];\nint dp[N][N];\n\nint main()\n{\n int n, p;\n scanf(\"%d%d\", &n, &p);\n Divider d(p);\n dbg_pri(\"poi 1: %x %d\\n\", p.k, p.s);\n for(int i=0;i<=n;++i)\n {\n comb[i][0] = 1;\n for(int j=1;j<=i;++j)\n {\n comb[i][j] = comb[i-1][j] + comb[i-1][j-1];\n if(comb[i][j] >= p) comb[i][j] -= p;\n }\n }\n int ans = 2;\n for(int mi=2;mi<=n;++mi)\n {\n int li = mi*2 - (n+1);\n if(li < 0) continue;\n memset(dp,0,sizeof(dp));\n for(int i=1;i<=mi;++i) dp[i][0] = 1;\n for(int ma=mi+1;ma<=n;++ma)\n {\n for(int pos=n;pos>=2;--pos)\n {\n int tli = std::min(li, ma*mi-mi*pos);\n if(tli < 0) continue;\n for(int sz=1;sz tli) break;\n for(int s=w;s<=tli;++s)\n dp[pos][s] = d.mod(dp[pos][s]+(lli)dp[pos-sz][s-w]*comb[pos][sz]);\n }\n }\n }\n for(int sz=1;sz\n\ntypedef long long int ll;\ntypedef long double ld;\n#define pb push_back\n#define pii pair < int , int >\n#define F first\n#define S second\n#define endl '\\n'\n#define int long long\n#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)\n#pragma GCC optimize(\"Ofast,no-stack-protector,unroll-loops,fast-math\")\n#define kill(x) return cout<> n >> mod;\n fac[0]=fm[0]=1;\n for (int i=1;imax((ll)0,n-20);a0--){\n /// fix adad aval\n memset(dp,0,sizeof dp);\n memset(pd,0,sizeof pd);\n for (int i=1;i<=n+1;i++){\n if (i*a0<=a0*a0) {\n dp[i][0][0][0]+=fm[i];\n pd[i][0][0]+=fm[i];\n dp[i][0][0][0]%=mod;\n pd[i][0][0]%=mod;\n }\n }\n \n for (int i=2;i<=n;i++){\n for (int j=1;j<=n+1-a0;j++){\n for (int jam=j;jam<=n+1;jam++){\n for (int t=1;t<=(n+1)/j;t++){\n /// t tayii ke ezafe mishan barabar bashan\n if (jam>=t && j>1){\n dp[i][j][jam][t]+=dp[i][j-1][jam-t][t];\n dp[i][j][jam][t]%=mod;\n }\n if (jam>=t*j && t=a0*i+jam){\n pd[i][j][jam]+=dp[i][j][jam][t];\n pd[i][j][jam]%=mod;\n }\n }\n }\n }\n \n }\n for (int i=0;i<=n+1-a0;i++){\n for (int j=0;j<=n+1;j++){\n ans+=pd[n][i][j]*fac[n]%mod;\n ans%=mod;\n }\n }\n // cout << a0 << \" \" << ans << endl;\n\n }\n cout << ans%mod << endl;;\n\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "967e8318835bb1216d03c3d75dac2330", "src_uid": "cf57508de47d80bc983861f70bb5f3d6", "difficulty": 3200.0} {"lang": "GNU C++17", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\n#define all(x) (x).begin(), (x).end()\n#define pb push_back\n#define xx first\n#define yy second\n#define sz(x) (int)(x).size()\n#define gc getchar\n#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)\n#define mp make_pair\n\n#ifndef ONLINE_JUDGE\n# define LOG(x) (cerr << #x << \" = \" << (x) << endl)\n#else\n# define LOG(x) ((void)0)\n#endif\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\n\nconst double PI=acos(-1);\nconst ll INF = 1LL<<62;\nconst ll MINF = -(1LL<<62);\n\ntemplate T getint() {\n\tT val=0;\n\tchar c;\n\t\n\tbool neg=false;\n\twhile((c=gc()) && !(c>='0' && c<='9')) {\n\t\tneg|=c=='-';\n\t}\n\n\tdo {\n\t\tval=(val*10)+c-'0';\n\t} while((c=gc()) && (c>='0' && c<='9'));\n\n\treturn val*(neg?-1:1);\n}\n\n//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution(0, n-1)(rng)\n\n#define double ld\nconst int MAXN=100001;\nint n,m;\nvector sol;\nvector> adj[MAXN];\nusing linear=pair;\nusing lineq=pair;\nvector eqs;\nlinear lst[MAXN];\nbool no=false;\nvoid bfs() {\n\tqueue q;\n\t\n\t\n\tvector par(n+1);\n\tfor(int x=1;x<=n;++x) {\n\t\tif(par[x]==0) {\n\t\t\tq.push(x);\n\t\t\tlst[x]={1,0};\n\t\t\tpar[x]=-1;\n\t\t\t\n\t\t\teqs.clear();\n\t\t\tvector vs;\n\t\t\twhile(!q.empty()) {\n\t\t\t\tint fr=q.front();\n\t\t\t\tq.pop();\n\t\t\t\tvs.pb(fr);\n\t\t\t\t\n\t\t\t\tfor(auto j:adj[fr]) {\n\t\t\t\t\tif(j.xx!=par[fr]) {\n\t\t\t\t\t\tif(par[j.xx]==0) {\n\t\t\t\t\t\t\tpar[j.xx]=fr;\n\t\t\t\t\t\t\tlst[j.xx]={-lst[fr].xx, j.yy-lst[fr].yy};\n\t\t\t\t\t\t\tq.push(j.xx);\n\t\t\t\t\t\t}else {\n\t\t\t\t\t\t\tlinear lehet={lst[fr].xx+lst[j.xx].xx, lst[fr].yy+lst[j.xx].yy};\n\t\t\t\t\t\t\tlinear szum={0, j.yy};\n\t\t\t\t\t\t\teqs.pb({lehet, szum});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tdouble eps=1e-7;\n\t\t\tset sols;\n\t\t\tbool csak0=false;\n\t\t\tfor(auto i:eqs) {\n\t\t\t\tif((i.xx.xx-i.yy.xx)!=0) sols.insert((i.yy.yy-i.xx.yy)/(i.xx.xx-i.yy.xx));\n\t\t\t\telse {\n\t\t\t\t\tif(i.xx.yy!=i.yy.yy) {\n\t\t\t\t\t\tcsak0=true;\n\t\t\t\t\t}else { //identit\u00e1s\n\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\t\n\t\t\t}\n\t\t\tLOG(csak0);\n\t\t\tif(csak0) {\n\t\t\t\tbool ok=true;\n\t\t\t\tfor(auto i:vs) {\n\t\t\t\t\tfor(auto j:adj[i]) {\n\t\t\t\t\t\tok&=j.yy==lst[i].yy+lst[j.xx].yy;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(!ok) no=true;\n\t\t\t\telse {\n\t\t\t\t\tfor(int i:vs) {\n\t\t\t\t\t\tsol[i]=lst[i].yy;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}else if(sols.empty()) {\n\t\t\t\tvector vals;\n\t\t\t\tfor(int i:vs) {\n\t\t\t\t\tvals.pb(-lst[i].yy);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tsort(vals.begin(), vals.end());\n\t\t\t\t\n\t\t\t\tdouble L=-1000, R=1000;\n\t\t\t\tauto sum=[&](double mid) -> double {\n\t\t\t\t\tdouble res=0.0;\n\t\t\t\t\tfor(int i:vs) {\n\t\t\t\t\t\tres+=abs(mid*lst[i].xx+lst[i].yy);\n\t\t\t\t\t}\n\t\t\t\t\treturn res;\n\t\t\t\t};\n\t\t\t\t\n\t\t\n\t\t\t\t\n\t\t\t\twhile(fabs(R-L)>1e-12) {\n\t\t\t\t\tdouble mid1=(2*L+R)/3.0, mid2=(L+2*R)/3.0;\n\t\t\n\t\t\t\t\tif(sum(mid1)>sum(mid2)) {\n\t\t\t\t\t\tL=mid1;\n\t\t\t\t\t}else {\n\t\t\t\t\t\tR=mid2;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tdouble L2=L\n\t\t\t\t/*if(fabs(sum(L2)-sum(L))>1e9 && sum(L2)>sum(L)) {\n\t\t\t\t\tL2=L;\n\t\t\t\t\tLOG(L2);\n\t\t\t\t\tLOG(L);\n\t\t\t\t\tassert(0);\n\t\t\t\t}*/\n\t\t\t\tfor(int i:vs) {\n\t\t\t\t\tsol[i]=lst[i].xx*L2+lst[i].yy;\n\t\t\t\t}\n\t\t\t}else {\n\t\t\t\tif(sols.size()==1 || *prev(sols.end())-*sols.begin()>n>>m;\n\tsol.resize(n+1);\n\tmap, int> volt;\n\tfor(int i=0;i>a>>b>>c;\n\t\tadj[a].pb({b,c});\n\t\tadj[b].pb({a,c});\n\t\tif(volt.count(mp(min(a,b), max(a,b)))) {\n\t\t\tno|=volt[mp(min(a,b), max(a,b))]!=c;\n\t\t}\n\t\t//~ LOG(mp(min(a,b), max(a,b)).xx);\n\t\t//~ LOG(mp(min(a,b), max(a,b)).yy);\n\t\t//~ LOG(c);\n\t\tvolt[mp(min(a,b), max(a,b))]=c;\n\t}\n\t\n\t//~ LOG(no);\n\tbfs();\n\t//~ LOG(no);\n\t//~ for(int i=1;i<=n;++i) cerr<\nusing namespace std;\n\n#ifdef ONLINE_JUDGE\n#define cerr if (false) cerr\n#endif\n\n#define fora(i, a, b) for (int i = (a); i < (b); i++)\n#define ford(i, a, b) for (int i = (a); i >= (b); i--)\n#define pr(x) cerr << #x << \" = \" << x << \"\\n\";\n#define rep(i, a, b) for(int i = a; i < (b); ++i)\n#define all(x) begin(x), end(x)\n#define sz(x) (int)(x).size()\n\nusing ll = long long;\nusing ull = unsigned long long;\n\nusing vi = vector;\nusing vvi = vector;\nusing vl = vector;\nusing vvl = vector;\nusing vb = vector;\nusing vd = vector;\nusing vs = vector;\n\nusing pii = pair;\nusing pll = pair;\nusing pdd = pair;\n\nusing vpii = vector;\nusing vpll = vector;\nusing vpdd = vector;\n\nconst long double PI = 3.14159265358979323;\nconst long long MOD = 1e9 + 7;\n\n\nmt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); // uniform_int_distribution(0, n)(rng)\n\nll rnd(ll n) {\n return uniform_int_distribution(0, n)(rng);\n}\n\nstruct custom_hash { // unordered_map safe_map;\n static uint64_t splitmix64(uint64_t x) {\n // http://xorshift.di.unimi.it/splitmix64.c\n x += 0x9e3779b97f4a7c15;\n x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;\n x = (x ^ (x >> 27)) * 0x94d049bb133111eb;\n return x ^ (x >> 31);\n }\n size_t operator()(uint64_t x) const {\n static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();\n return (size_t) splitmix64(x + FIXED_RANDOM);\n }\n\tsize_t operator()(pair x) const {\n\t\tstatic const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();\n\t\treturn (size_t) (splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1));\n\t}\n};\n\null modmul(ull a, ull b, ull M) {\n\tll ret = a * b - M * ull(1.L / M * a * b);\n\treturn ret + M * (ret < 0) - M * (ret >= (ll)M);\n}\n\nll power(ll b, ll e, ll mod) {\n\tull ans = 1;\n\tfor (; e; b = modmul(b, b, mod), e /= 2)\n\t\tif (e & 1) ans = modmul(ans, b, mod);\n\treturn ans;\n}\n\nlong long modInverse(long long n, long long p) {\n return power(n, p-2, p);\n}\n\nlong long ncr(long long arr[], long long n, long long r, long long p) {\n return ((arr[n] * modInverse(arr[r], p))%p * modInverse(arr[n-r], p))%p;\n}\n\nbool isPrime(ull n) {\n\tif (n < 2 || n % 6 % 4 != 1) return (n | 1) == 3;\n\tull A[] = {2, 325, 9375, 28178, 450775, 9780504, 1795265022},\n\t s = __builtin_ctzll(n-1), d = n >> s;\n\tfor (ull a : A) { // ^ count trailing zeroes\n\t\tull p = power(a%n, d, n), i = s;\n\t\twhile (p != 1 && p != n - 1 && a % n && i--)\n\t\t\tp = modmul(p, p, n);\n\t\tif (p != n-1 && i != s) return 0;\n\t}\n\treturn 1;\n}\n\null pollard(ull n) {\n\tauto f = [n](ull x) { return modmul(x, x, n) + 1; };\n\tull x = 0, y = 0, t = 0, prd = 2, i = 1, q;\n\twhile (t++ % 40 || __gcd(prd, n) == 1) {\n\t\tif (x == y) x = ++i, y = f(x);\n\t\tif ((q = modmul(prd, max(x,y) - min(x,y), n))) prd = q;\n\t\tx = f(x), y = f(f(y));\n\t}\n\treturn __gcd(prd, n);\n}\n\nvector factor(ull n) {\n\tif (n == 1) return {};\n\tif (isPrime(n)) return {n};\n\tull x = pollard(n);\n\tauto l = factor(x), r = factor(n / x);\n\tl.insert(l.end(), all(r));\n\treturn l;\n}\n\nstruct Node {\n ll nr;\n Node* parent;\n vector> edges;\n bool visited = false;\n bool visitedTwice = false;\n bool active = false;\n ll distance = 1e9;\n ll poz = 1;\n ll offset = 0;\n long double starting;\n void reset() {\n visited = false;\n active = false;\n distance = 1e9;\n }\n void hardReset() {\n edges.clear();\n visited = false;\n active = false;\n distance = 1e9;\n }\n};\n\nlist activeNodes;\nbool possible = true;\nbool startingFound = false;\nlong double starting = 0;\n\nvoid dfs(Node* node) {\n if (node -> visitedTwice) {\n return;\n }\n node -> visitedTwice = true;\n node -> starting = starting;\n for (auto j: node -> edges) {\n Node* newNode = j.first;\n if (!newNode -> visitedTwice) {\n dfs(newNode);\n }\n }\n}\n\nvoid bfs(Node* node) {\n if (node -> visited) {\n return;\n }\n node -> visited = true;\n node -> parent = node;\n node -> distance = 0;\n queue q;\n activeNodes.push_back(node);\n for (q.push(node); !q.empty(); q.pop()) {\n node = q.front();\n for (auto j: node -> edges) {\n Node* newNode = j.first;\n if (!newNode -> visited) {\n newNode -> visited = true;\n newNode -> distance = node -> distance + 1;\n newNode -> parent = node;\n newNode -> poz = - node -> poz;\n newNode -> offset = j.second - node -> offset;\n activeNodes.push_back(newNode);\n q.push(newNode);\n } else {\n ll poz = - node -> poz;\n ll offset = j.second - node -> offset;\n if (!startingFound) {\n if (poz == newNode -> poz) {\n if (offset != newNode -> offset) {\n possible = false;\n }\n } else if (poz > 0) {\n starting = ((long double)(newNode -> offset - offset)) / 2;\n startingFound = true;\n } else {\n starting = ((long double)(offset - newNode -> offset)) / 2;\n startingFound = true;\n }\n } else {\n if (poz == newNode -> poz) {\n if (offset != newNode -> offset) {\n possible = false;\n }\n } else if (poz > 0) {\n long double newStarting = ((long double)(newNode -> offset - offset)) / 2;\n if (abs(newStarting - starting) > 0.000001) {\n possible = false;\n }\n } else {\n long double newStarting = ((long double)(offset - newNode -> offset)) / 2;\n if (abs(newStarting - starting) > 0.000001) {\n possible = false;\n }\n }\n }\n }\n }\n }\n}\n\nNode nodes[200005];\nll n,m,k,t,a,b,c,rez,sk,mas[200005];\nstring s1,s2;\nlist q;\nset s;\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n cin >> n >> m;\n fora(i, 0, m) {\n cin >> a >> b >> c;\n nodes[a-1].edges.push_back({&nodes[b-1], c});\n nodes[b-1].edges.push_back({&nodes[a-1], c});\n }\n fora(i, 0, n) {\n if (!nodes[i].visited) {\n starting = 0;\n startingFound = false;\n pozOffset = 0;\n negOffset = 0;\n activeNodes.clear();\n bfs(&nodes[i]);\n if (!startingFound) {\n long double l = -1000000;\n long double r = 1000000;\n while (r - l >= 0.000000001) {\n long double c1 = l+(r-l)/2;\n long double c2 = c1 + 0.000000001;\n long double sk1 = 0;\n long double sk2 = 0;\n for (Node* node: activeNodes) {\n sk1 += abs(((long double)c1 * node -> poz + node -> offset));\n sk2 += abs(((long double)c2 * node -> poz + node -> offset));\n }\n if (sk1 <= sk2) {\n r = c1;\n } else {\n l = c2;\n }\n }\n starting = l;\n }\n dfs(&nodes[i]);\n }\n }\n cout << (possible ? \"YES\\n\" : \"NO\\n\");\n if (possible) {\n fora(i, 0, n) {\n cout << nodes[i].starting * nodes[i].poz + nodes[i].offset << \" \";\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "73f4ea60d990b79862a525c964dec765", "src_uid": "791cbe2700b11e9dd9a442de3ef913f8", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n#define endl '\\n'\n#define ll long long\n#define pi pair\n#define f first\n#define s second\n\nint main(){\n\tios::sync_with_stdio(0);\n\tcin.tie(0);\n\t\n\tcin >> n;\n\t\n\tcout << n << endl;\n\n for(int i = 1; i <= n; i++) cout << i << \" \";\n cout << endl;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "750b8fc446a248ad6593a58408a78fad", "src_uid": "791cbe2700b11e9dd9a442de3ef913f8", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\n#define MOD 1000000007\n#define ll long long int\n#define vi vector\n#define vii vector >\n#define eps 0.000001\n\nvector > > graph(100050,vector >);\nbool was[100005];\nint xsign[100005];\nint cons[100005];\ndouble val[100005];\nbool bad = false;\nbool xfix = false;\ndouble xval = 0;\nvector curr;\n\nvoid dfs(int v) {\n\tcurr.push_back(v);\n\twas[v] = true;\n\tfor(auto ed : graph[v]) {\n\t\tint u = ed.first;\n\t\tint need = ed.second;\n\t\tif(!was[u]) {\n\t\t\txsign[u] = -xsign[v];\n\t\t\tcons[u] = need-cons[v];\n\t\t\tdfs(u);\n\t\t} else {\n\t\t\tif(xsign[u] != xsign[v]) {\n\t\t\t\tif(cons[u]+cons[v] != need) {\n\t\t\t\t\tbad = true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdouble needval = (need-cons[u]-cons[v])/(xsign[u]+xsign[v]);\n\t\t\t\tif(!xfix) {\n\t\t\t\t\txfix = true;\n\t\t\t\t\txval = needval;\n\t\t\t\t} else {\n\t\t\t\t\tif(abs(needval-xval) > eps) {\n\t\t\t\t\t\tbad = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nint main() {\n\tios::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tint n,m;\n\tcin >> n >> m;\n\tfor(int i = 0; i < m; i++) {\n\t\tint a,b,c;\n\t\tcin >> a >> b >> c;\n\t\tgraph[a].push_back({b,c});\n\t\tgraph[b].push_back({a,c});\n\t}\n\tfor(int i = 1; i <= n; i++) {\n\t\tif(!was[i]) {\n\t\t\txfix = false;\n\t\t\txsign[i] = 1;\n\t\t\tcurr.clear();\n\t\t\tdfs(i);\n\t\t\tif(xfix) {\n\t\t\t\tfor(int v : curr) {\n\t\t\t\t\tval[v] = xsign[v]*xval+cons[v];\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tll minsum = 1000000000000000LL;\n\t\t\t\tint minat = 0;\n\t\t\t\tfor(int va = -curr.size(); va <= curr.size(); va++) {\n\t\t\t\t\tll curr = 0;\n\t\t\t\t\tfor(int v : curr) {\n\t\t\t\t\t\tcurr+= abs(xsign[v]*va+cons[v]);\n\t\t\t\t\t}\n\t\t\t\t\tif(curr < minsum) {\n\t\t\t\t\t\tminsum = curr;\n\t\t\t\t\t\tminat = va;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor(int v : curr) {\n\t\t\t\t\tval[v] = xsign[v]*minat+cons[v];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif(bad) {\n\t\tcout << \"NO\";\n\t\treturn 0;\n\t} else {\n\t\tcout << \"YES\\n\";\n\t\tfor(int i = 1; i <= n; i++) {\n\t\t\tcout << val[i] << \" \";\n\t\t}\n\t}\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "460ec11af39789e7d18c414348c010ee", "src_uid": "791cbe2700b11e9dd9a442de3ef913f8", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\nint main()\n {\n int v1,v2,t,d,i,x=0,ans=0,y=0,rem=0,z=0,a=0;\n cin>>v1>>v2>>t>>d;\n ans=v1+v2;\n x=v1;\n for(i=1;i<=t-2;i++)\n {\n x=x+d;\n ans+=x; \n if(i==t-2)\n {\n if(v2-x>=0)\n {cout<=v2)\n break;\n }\n a=v2+d-x;\n y=i+1;\n rem=t-1-y;\n z=i+(rem/2)+1;\n for(i=y;i<=t-2;i++)\n {\n if(i==z)\n {\n if(rem%2==0)\n {x-=a;}\n else\n {x+=a;}\n }\n else\n {\n if(i>z)\n x-=d;\n else\n x+=d;\n }\n ans+=x;\n }\n cout<\n\nint dp[150][150];\n\nint main(void){\n\n int t,d,v1,v2;\n\n std::cin>>v1>>v2;\n std::cin>>t>>d;\n\n for(int i=0; i<=120; i++){\n for(int j=0; j<=120; j++){\n dp[i][j]=0;\n }\n }\n\n dp[1][v1]=v1;\n\n \n for(int j=1; j<=100; j++)\n for(int i=-d; i<=d; i++)\n if((j-i)>=1 &&dp[1][j-i]!=0)dp[2][j]=std::max(dp[2][j],dp[1][j-i]+j);\n \n\n \n\n for(int k=3; k<=t; k++)\n for(int j=1; j<=100; j++)\n for(int i=-d; i<=d; i++)\n if((j-i)>=1 &&dp[k-1][j-i]!=0)dp[k][j]=std::max(dp[k][j],dp[k-1][j-i]+j);\n\n\n std::cout<\n\nusing namespace std;\n\nint main()\n{\n\tint v1, v2, t, d;\n\tcin >> v1 >> v2 >> t >> d;\n\tif (v1 > v2) {\n\t\tint loc = v2;\n\t\tv2 = v1;\n\t\tv1 = loc;\n\t}\n\tif (!d) {\n\t\tcout << v1*d;\n\t\treturn 0;\n\t}\n\n\tint l, r, inl, inr;\n\tif (v1 % 2)\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "276b2a1723f6b7a1cc3b79b6a42a116c", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include\n#define lli long long int\nusing namespace std;\n\nlli x[200][2000];\nint main()\n{\n int v1, v2, t, d;\n cin >> v1 >> v2 >> t >> d;\n \n x[1][v1] = v1;\n for (int i = 2; i < t; i++) {\n for (int j = 0; x[i][j] != 0; j++) {\n for (int k = max(j - d, 0); k <= j + d; k++) {\n x[i][k] = max(x[i][k], x[i-1][j] + k);\n }\n }\n }\n \n for (int k = max(v2 -d, 0); k <= v2 + d); k++) {\n x[t][v2] = max(x[t][v2], x[t-1][k] + v2);\n }\n cout << x[t][v2];\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4c15ec51df2c4160469edee82aaca47d", "src_uid": "9246aa2f506fcbcb47ad24793d09f2cf", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n\nint main(){\n\tint x;\n\tcin >> x;\n\tr = x%4;\n\n\tif(r==1){\n\t\tcout << 0 << \" \" << \"A\" << endl;\n\t}else if(r==3){\n\t\tcout << 2 << \" \" << \"A\" << endl;\n\t}else if(r==2){\n\t\tcout << 2 << \" \" << \"B\" << endl;\n\t}else if(r==0){\n\t\tcout << 1 << \" \" << \"A\" << endl;\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3e436807a5a59f3d3ebcce57ea5a6870", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0} {"lang": "MS C++ 2017", "source_code": "#include \"stdafx.h\"\n#include \nusing namespace std;\nint main()\n{\n\tint x;\n\tcin >> x;\n\tif(x % 4==1){\n\t\tcout << \"0 A\" << endl;\n\t}\n\tif (x % 4 == 2) {\n\t\tcout << \"1 B\" << endl;\n\t}\n\tif (x % 4 == 3 ) {\n\t\tcout << \" 1 B\" << endl;\n\t}\n\tif (x % 4 == 0) {\n\t\tcout << \" 1 A\" << endl;\n\t}\n\tsystem(\"pause\");\n\treturn 0;\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "18790b4b1d07bb358016c61ba64c1e73", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\n\nusing namespace std;\n\nint main(){\n int x;\n cin>>x;\n\n int mod = x%4;\n\n int costA,costB, costC;\n\n costA = abs(1-a);\n costB = abs(3-a);\n costC = abs(2-a);\n\n if(costA <= 2){\n cout << costA << \"A\";\n }\n\n else if(costB <=2){\n cout << costB << \"B\";\n }\n\n else{\n cout << costC << \"C\";\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1561588a7df131b9484d695577a0e667", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \n \n#define int long long\n#define ll long long \n#define F first\n#define endl \"\\n\"\n#define S second\n#define make make_pair\n#define pb push_back\n#define sz(x) (ll)(x.size()) \n#define all(x) x.begin (), x.end ()\n\nusing namespace std;\n\ntypedef long double ld;\ntypedef pair pll;\ntypedef map mll;\ntypedef vector vl;\ntypedef set sl;\n\nconst int MOD = (int)1e9 + 7;\nconst int N = (int)1e5 * 4;\nconst ll INF = (ll)1e18;\nconst double eps = (double)1e-6;\n\nint gcd (int x, int y) {\n\twhile (x != 0 && y != 0) {\n\t\tx %= y;\n\t\tif (x == 0) break;\n\t\ty %= x;\n\t}\n\treturn x + y;\n}\ninline void Maga() {\n\tios_base::sync_with_stdio(false);\n\tcin.tie(0); cout.tie(0);\n}\n\n\nsigned main() {\n\t\n\treturn \n}\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "247c49a38d8ea4bdc10059a5d1e436ef", "src_uid": "488e809bd0c55531b0b47f577996627e", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \nusing namespace std;\n#define N 120\n#define M 6000\nint n, k;\nvoid solve() {\n\tint x = sqrt(n);\n\tif (x * x == n) {\n\t\tprintf(\"%d\\n\", 4 * x);\n\t} else if (x * (x+1) > n) {\n\t\tprintf(\"%d\\n\", 4 * x + 2);\n\t}\n\telse {\n\t\tprintf(\"%d\\n\", 4 * x + 2 + 2);\n\t}\n}\nint main() {\n\twhile (scanf(\"%d\", &n) != EOF) {\n\t\tsolve();\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ff0053f91ed49ed625a38a9227172fcd", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n#define ll long long int\nvoid solve()\n{\n ll n,m,j,y,i,k,t,len,x,c,p;\n cin>>n;\n for(i=1; i<=n; i++)\n {\n x=i*i-(i-1);\n y=i*i+i;\n if(n>=x && i*i>=n)\n {\n cout<<4*i;\n return ;\n }\n else if(n>i*i && n<=y)\n {\n cout<<(4*i)+2;\n return ;\n }\n }\n}\n}\nint main()\n{\n int T=1;\n //cin>>T;\n while(T--)\n solve();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2bc724d5da8a1cb17346fa9e3eeef33c", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std;\n#define ll long long\n\nint main()\n{\n int n,r,res=0; cin>>n;\n for (int i = 1 ; i <= 1e3 ; ++i){\n int curr = i*i;\n if (curr > n){\n r = i-1;\n break;\n }\n }\n int Nr = r+(n-(r*r))/r;\n res = 2*r+2*Nr;\n cout << res + (n-(r*r))%r<< endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "947e4ae785fc2808eafbf7faccdb48fa", "src_uid": "414cc57550e31d98c1a6a56be6722a12", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include\n#include\nusing namespace std;\n\ndouble n,i;\n\nint main()\n{cin>>n;\n for(i=n;i>0;i--)\n if(sqrt(i)==int(sqrt(i)))\n m=sqrt(i);\n if(m==n)\n cout<\n#include \n#include \n\nbool ispr(char *s) { return s[0] == s[3] && s[1] == s[2]; }\n\nint main() {\n int a, b;\n while (~scanf(\"%d:%d\", &a, &b)) {\n for (int i = 0;; i++) {\n char s[10];\n snprintf(s, size(s), \"%02d%02d\", a, b);\n if (ispr(s) == true) {\n printf(\"%d\\n\", i);\n break;\n }\n b++;\n if (b == 60) {\n b = 0;\n a++;\n }\n if (a == 24) {\n a = 0;\n }\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d2cc51515285a2e4fce440fe7bef3c43", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include\n#include \n#include \n#include \n#include\n#include \n#include \nusing namespace std;\n\n\ntypedef long long unsigned llu;\ntypedef long double ld;\n#define ll long long\n#define For(i, a, b) for (int i = a, sz = (int)b; i < sz; i++)\n#define all(v) (v).begin(), (v).end()\n#define Memset(a, b) memset(a, b, sizeof(a))\n#define IO ios_base::sync_with_stdio(false), cin.tie(0),cout.tie(0)\nconst ll mod = 1000000007;\nconst ll inf = 1000000000009;\n\n//freopen(\"input.txt\", \"r\", stdin);\n//freopen(\"output.txt\", \"w\", stdout);\n\n\nint solve(int h,int m )\n{\n\tint z=(h%10)*10+h/10;\n\tif(z>=m && z<60)\n\t\treturn z-m;\n\telse\n\t\tretrun (60-m)+solve((h+1)%24,0);\n}\nint main()\n{\n\tIO;\n\tint h{},m{};\n\tchar s;\n\tcin>>h>>s>>m;\n\tcout<\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint rev(int t)\t{\n\tint rem = t%10;\n\tint div = t/10;\n\treturn rem*10+div;\n}\nint main()\n{\n\tint t,m;\n\tchar c;\n\tcin>>t>>c>>m;\n\tfor(int i=0;;i++)\t{\n\t\tif(rev(t) == m && rev(m) == t)\t{\n\t\t\tcout<\nusing namespace std;\nint main()\n{\n int h,m,c=0, \n scanf(\"%d:%d\",&h,&m);\n while((h%10)*10-+(h/10)!=m)\n {\n m++;\n if(m==60)\n {\n m=00;\n h++;\n }\n h=h%24;\n c++;\n }\n printf(\"%d\",c);\n return 0;\n}\n \n ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9e46e4eccac3132b843c3de6be2e2f20", "src_uid": "3ad3b8b700f6f34b3a53fdb63af351a5", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include\n#define ll long long\nusing namespace std;\nconst int mod = 1e9 + 7;\nll n, m;\nll fib(ll q)\n{\n if(q == 1 || q == 0)\n return 1;\n else return (fib(q - 1) + fib(q - 2)) % (1e9 + 7);\n}\nint main()\n{\n cin >> n >> m;\n cout << 2 * (fib(n) + fib(m) - 1);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ccfe815e90a962dfbf9329b8627bb54a", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "/****************************\nFilename: FatMouse.cpp\nAuthor: hbb\nCreate: 2019-10-20 17:03:40\n ****************************/\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst int maxn = 1e5 + 5;\nconst int mod = 1e9 + 7;\nconst int inf = INT_MAX >> 1;\ntypedef long long int LL;\n\nLL a[maxn];\n\nint main(){\n\tLL n, m;\n\tscanf(\"%lld %lld\", &n, &m);\n\ta[1] = 2;\n\ta[2] = 4;\n\tfor(int i = 3; i < maxn; i++){\n\t\ta[i] = (a[i - 1] + a[i - 2]) % mod;\n\t}\n\tLL temp = a[n];\n\tif(m == 1){\n\t\tprintf(\"%lld\\n\", temp);\n\t}\n\telse{\n\t\ttemp = (temp + 2) % mod;\n\t\tm--;\n\t\tif(m > 1){\n\t\t\tfor(int i = 1; i <= m - 1; i++){\n\t\t\t\ttemp = (temp + a[i]) % mod;\n\t\t\t}\n\t\t}\n\t\tprintf(\"%lld\\n\", temp);\n\t}\n}\n\n/*\n\n 2 4 6 10 16\n 4 6 8 12 18\n 6\t 8 10 14 20\n 10\t 12 14 18 24\n 16 18 20 24 30\n 26\n\n *", "lang_cluster": "C++", "compilation_error": true, "code_uid": "887ba815de807021855232be35a4831a", "src_uid": "0f1ab296cbe0952faa904f2bebe0567b", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include\n#define MOD 1000000007\nusing namespace std;\nlong long dp[2][131072],n,m,ans;\nbool check()\n{\n int i,j;\n /*for(i=0;i1)return false;\n }\n }\n return true;\n}\nvoid rec(int x,int y)\n{\n //cout<>n>>m;\n if(n>m)swap(m,n);\n //memset(arr,-1,sizeof(arr));\n //rec(0,0);\n //cout<\nusing namespace std;\nint main()\n{ long long n,m;\ncin>>n>>m;\nlong long s=2(n+m-1 );\ncout<\n\nusing namespace std;\n\n#define pb push_back\n#define mp make_pair\n#define all(x) (x).begin(), (x).end()\n#define F first\n#define S second\n#define daulet ios_base::sync_with_stdio(0)\n#define sungkar cin.tie(0)\n#define sdu cout.tie(0);\n\ntypedef long long ll;\ntypedef long double ld;\n\nlong long binpow(long long a, long long b)\n{\n long long ans = 1;\n while (b > 0)\n {\n if (b & 1)\n ans = ans * a;\n a = a * a;\n b >>= 1;\n }\n return ans;\n}\nint gcd(int a, int b)\n{\n if (b == 0)\n {\n return a;\n }\n else\n {\n return gcd(b, a % b);\n }\n}\n\nint lcm(int a, int b)\n{\n return a / gcd(a, b) * b;\n}\nll fact(int n)\n{\n ll ans = 1;\n for (int i = 2; i <= n; i++)\n {\n ans = (ans * i) % MOD;\n }\n\n return ans;\n}\n\nll powM(int n, int x)\n{\n if (x == 0)\n {\n return 1;\n }\n if (x == 1)\n {\n return n % MOD;\n }\n\n if (x % 2 == 0)\n {\n ll a = powM(n, x / 2);\n return (a * a) % MOD;\n }\n else\n {\n return (n * powM(n, x - 1)) % MOD;\n }\n}\n\nll C(int n, int k)\n{\n return (fact(n) * powM((fact(k) * fact(n - k)) % MOD, MOD - 2)) % MOD;\n}\n\nll A(int n, int k)\n{\n return (fact(n) * powM(fact(n - k) % MOD, MOD - 2)) % MOD;\n}\n\nvoid add_self(int &a, int b)\n{\n a += b;\n if (a >= MOD)\n {\n a -= MOD;\n }\n}\n\nvoid sub_self(int &a, int b)\n{\n a -= b;\n if (a < 0)\n {\n a += MOD;\n }\n}\n\nstruct segtree\n{\n\n vl tree;\n int size;\n\n void init(int n)\n {\n size = 1;\n while (size < n)\n size *= 2;\n tree.assign(2 * size - 1, 0);\n }\n void build(vi &a, int x, int lx, int rx)\n {\n if (rx - lx == 1)\n {\n if (lx < a.size())\n tree[x] = a[lx];\n }\n else\n {\n int m = (lx + rx) / 2;\n build(a, 2 * x + 1, lx, m);\n build(a, 2 * x + 2, m, rx);\n tree[x] = tree[2 * x + 1] + tree[2 * x + 2];\n }\n }\n\n void build(vi &a)\n {\n init(a.size());\n build(a, 0, 0, size);\n }\n\n void set(int i, int v, int x, int lx, int rx)\n {\n if (rx - lx == 1)\n {\n tree[x] = v;\n return;\n }\n int m = (lx + rx) / 2;\n if (i < m)\n {\n set(i, v, 2 * x + 1, lx, m);\n }\n else\n {\n set(i, v, 2 * x + 2, m, rx);\n }\n tree[x] = tree[2 * x + 1] + tree[2 * x + 2];\n }\n\n void set(int i, int v)\n {\n set(i, v, 0, 0, size);\n }\n\n ll sum(int l, int r, int x, int lx, int rx)\n {\n if (l >= rx || lx >= r)\n {\n return 0;\n }\n if (lx >= l && rx <= r)\n {\n return tree[x];\n }\n int m = (rx + lx) / 2;\n ll s1 = sum(l, r, 2 * x + 1, lx, m);\n ll s2 = sum(l, r, 2 * x + 2, m, rx);\n return s1 + s2;\n }\n\n ll sum(int l, int r)\n {\n return sum(l, r, 0, 0, size);\n }\n};\nint n;\nll m;\nll f[250009];\nvoid solve()\n{\n cin >> n >> m;\n ll ans = 0;\n f[0] = 1;\n for (int i = 1; i <= n; i++)\n {\n f[i] = f[i - 1] * i % m;\n }\n for (int i = 1; i <= n; i++)\n {\n ans += (n - i + 1) * (f[i] * f[n - i + 1] % m);\n ans %= m;\n }\n cout << ans << '\\n';\n}\n\nint main()\n{\n daulet;\n sungkar;\n sdu;\n int tt = 1;\n // cin >> tt;\n while (tt--)\n {\n solve();\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ff1b8743776e2c4cf507d52f233a015d", "src_uid": "020d5dae7157d937c3f58554c9b155f9", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "void DFS( int v, int p )\n{\n used[v] = 1;\n tin[v] = fup[v] = timer++;\n int child = 0;\n for( auto u : g[v] )\n {\n if( u == p )\n continue;\n\n if( used[u] )\n fup[v] = min( fup[v], tin[u] );\n else\n {\n DFS( u, v );\n\n fup[v] = min( fup[v], fup[u] );\n\n if( fup[u] >= tin[v] and p != -1 )\n cout << v + 1 << endl;\n child++;\n }\n }\n if( p == -1 and child > 1 )\n {\n cout << v + 1 << endl;\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2f60dee9917fa69da4ff8a0b0a78978b", "src_uid": "020d5dae7157d937c3f58554c9b155f9", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include /** I'm Klaus, NicKlaus :v **/\nusing namespace std;\n#define ms(a,v) memset(a,v,sizeof a)\n#define ll long long\nll gcd(ll x, ll y){return (y ? gcd(y, x%y) : x); }\nll lcm(ll x, ll y){return x*(y/gcd(x,y));}\nconst int nax = 250010;\nint main(){\n\tios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n\t#ifdef LOCAL_JUDGE\n\t\t//freopen(\"in_out/in.txt\", \"rt\", stdin);\n\t\t//freopen(\"int_out/out.txt\", \"wt\", stdout);\n\t#endif\n\tint n;\n\tll mod;\n\tcin>>n>>mod;\n\tvector fac(nax);\n\tfac[0] = fac[1] = 1;\n\tfor(ll i=2; i<=nax; i++){\n\t\tfac[i] = (i*fac[i-1])%mod;\n\t}\n\tll ans = 0;\n\tfor(ll d = 1; d<=n; d++){\n\t\tll aux = ((n-d+1)*(n-d+1))%mod\n\t\tans = (ans + (((aux*fac[d])%mod)*fac[n-(d)])%mod)%mod;\n\t}\n\tcout<\n\nusing namespace std;\nint a,x,y;\nstring b;\nint main() {\n cin>>a>>b;\n for(int i=0;ix){\n cout<<7;\n }else if(x!=0){\n cout<<4;\n }else{\n cout<<-1;\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c84c51ade47b7b8fafa7efc6699d9e3b", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nstring s;\nint k,y,i;\nint main() \n\n{\n \n cin>>s;\n for (i = 0; i < s.size(); i++){\n if (s[i] == '4') k++;\n if (s[i] == '7') y++;\n }\n if (k == 0 && y == 0){cout<<\"-1\"; exit(0);}\n if (k >= y) cout<<\"4\"; else cout<<\"7\";\n return 0;\n} \n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9176445c8319c79270ff44a0be985fae", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#include\n#include\n#include\n#include\n#include\n#include\n#include \n#include \n#include \n#include\n#include\n#define endl \"\\n\"\ntypedef long long int lli;\nint i, j, k;\nint BinarySearch(int a[], int l, int h, int x);\nint BS_first_occurence(int a[], int n, int x);\nint BS_first_occurence(int a[], int n, int x);\n\nint main()\n{\n\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n\n string s;\n int f,sev;\n f = 0;\n sev = 0;\n cin>>s;\n for(i=0;s[i];i++)\n {\n if(s[i]=='4')f++;\n else if(s[i]=='7')s++;\n }\n if(f>=sev && f!=0)cout<<4<\n#include \n#include \n\nusing namespace std;\n\ninline int countSubstring(string str, string sub)\n{\n if (sub.length() == 0) return 0;\n int count = 0;\n for (size_t offset = str.find(sub); offset != std::string::npos; offset = str.find(sub, offset + sub.length())) {\n ++count;\n }\n\n return count;\n}\n\nint getLucky(int indx, int* length) {\n int digitsNum = floor(log(indx) / log(2)), counter = 0 , lucky = 0;\n int groupedCoeffecients = 2*(pow(2 , digitsNum) - 1) - indx;\n while(groupedCoeffecients < 0) {\n digitsNum++;\n groupedCoeffecients = 2*(pow(2 , digitsNum) - 1) - indx;\n }\n int* coef = new int[digitsNum];\n memset(coef , 0 , sizeof(int)*digitsNum);\n\n do {\n coef[counter] = groupedCoeffecients % 2;\n groupedCoeffecients /= 2;\n counter++;\n }\n while(groupedCoeffecients > 0);\n\n for(int i = 0 ; i < digitsNum ; i++) {\n lucky += coef[i]*4*pow(10 , i) + abs(1 - coef[i])*7*pow(10 , i);\n }\n\n *length = digitsNum;\n return lucky;\n}\n\nint main() {\n\n string input, output = \"-1\";\n int len, maxOccurs = 0, itr = 1;\n cin >> input;\n len = input.length();\n\n\n while(true) {\n int luckyLen, occurs, lucky = getLucky(itr, &luckyLen);\n string luckyStr;\n stringstream ss;\n if(luckyLen > len)\n break;\n ss << lucky;\n luckyStr = ss.str();\n occurs = countSubstring(input, luckyStr);\n if(occurs > maxOccurs) {\n maxOccurs = occurs;\n output = luckyStr;\n }\n itr++;\n }\n\n cout << output << endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "09f92880048a66db4febb48a0b24bac6", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \"stdio.h\"\n#include \"iostream\"\n#include \"string.h\"\n#include \"algorithm\"\n#include \"map\"\n\nusing namespace std;\nusing LL = long long;\n\n\nint x[2], y[2], r[2], R[2];\n\nint s(int a) {\n return a * a;\n}\n\nbool chk(int r, int r1, int R1, int d) {\n if(sqrt(d) + r <= r1) return true;\n if(r + R1 <= sqrt(d)) return true;\n if(sqrt(d) + R1 <= r) return true;\n return false;\n}\n\nint main() {\n for (int i = 0; i < 2; ++i) {\n cin >> x[i] >> y[i] >> r[i] >> R[i];\n }\n\n int d = s(x[0] - x[1]) + s(y[0] - y[1]);\n\n int res = 0;\n if(chk(r[0], r[1], R[1], d)) res ++;\n if(chk(r[1], r[0], R[0], d)) res ++;\n if(chk(R[0], r[1], R[1], d)) res ++;\n if(chk(R[1], r[0], R[0], d)) res ++;\n\n cout << res << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e8210df0b65da78ad00e10bf85c76c06", "src_uid": "4c2865e4742a29460ca64860740b84f4", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntemplate inline T Max(T a,T b)\n{if(a>b)return a;else return b;}\ntemplate inline T Min(T a,T b)\n{if(a inline T gcd(T a,T b)\n{if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}\ntemplate inline T lcm(T a,T b)\n{if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}\ntemplate inline T TripleMax(T a,T b,T c)\n{return Max(Max(a,b),c);}\ntemplate inline T TripleMin(T a,T b,T c)\n{return Min(Min(a,b),c);}\n#define ll long long\n#define PB push_back\n#define MP make_pair\n\nint x1, y1, r1, R1;\nint x2, y2, r2, R2;\ndouble distance;\nint ret;\n\nint check (int r, int c_r, int c_R) {\n if (distance + r <= c_R || r + c_R <= distance || distance + c_R <= r) {\n return 1;\n }\n return 0;\n}\n\nint main (int argc, const char* argv[]) {\n\n cin >> x1 >> y1 >> r1 >> R1;\n cin >> x2 >> y2 >> r2 >> R2;\n ret = 0;\n distance = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));\n if (check(r1, r2, R2) == 1) {\n ret++;\n }\n if (check(R1, r2, R2) == 1) {\n ret++;\n }\n if (check(r2, r1, R1) == 1) {\n ret++;\n }\n if (check(R2, r1, R1) == 1) {\n ret++;\n }\n cout << ret << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "37e38223eb0a822908931ac3bbf33ed4", "src_uid": "4c2865e4742a29460ca64860740b84f4", "difficulty": 1900.0} {"lang": "GNU C++14", "source_code": "#include \n#include \nusing namespace std;\n\nint func(int a, int b, int c, int d) {\n if (c<=a and (a-c)*(a-c)>=d) return 1;\n if (c>=b and (c-b)*(c-b)>=d) return 1;\n if ((b+c)*(b+c)<=d) return 1;\n return 0;\n}\n\nint main()\n{\n float x1,y1,r1,R1;\n float x2,y2,r2,R2;\n cin >> x1 >> y1 >> r1 >> R1;\n cin >> x2 >> y2 >> r2 >> R2;\n\n float d = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);\n\n\n if(d < r1 && d > R2 && d+r2R1) {\n cout << 1 << endl;\n\n } else if (dR2 && d+R2=r1) {\n cout << 4 << endl;\n } else if(d< r1+r2) {\n cout << 0 << endl;\n }\n\n //cout << func(r1,R1,r2,d)+func(r1,R1,R2,d)+func(r2,R2,r1,d)+func(r2,R2,R1,d) << endl;\n\n if(x1)\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c19f2fc70437a86b51a0b3aff7243db4", "src_uid": "4c2865e4742a29460ca64860740b84f4", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nstruct k\n{\n int x,y,r,R;\n};\n\nbool inter(int x1,int y1, int r1, int x2,int y2, int r2)\n{\n int d = (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);\n return (d>=(r1+r2)*(r1+r2))||(d<((r1+r2)*(r1+r2))&&d<=((r1-r2)*(r1-r2)));\n}\n\nint main()\n{\n k a[2];\n for (int i=0;i<2;i++)\n {\n cin >> a[i].x >> a[i].y >> a[i].r >> a[i].R;\n }\n int ans=0;\n for (int i=0;i<2;i++)\n {\n bool T=true;\n for (int j=a[i^1].r;j<=a[i^1].R;j++) T&=inter(a[i].x,a[i].y,a[i].r,a[i^1].x,a[i^1].y,j);\n ans+=T;\n bool T=true;\n for (int j=a[i^1].r;j<=a[i^1].R;j++) T&=inter(a[i].x,a[i].y,a[i].R,a[i^1].x,a[i^1].y,j);\n ans+=T;\n }\n cout << ans;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "57d0c5dcb338fd0062b165ae24565d82", "src_uid": "4c2865e4742a29460ca64860740b84f4", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint main()\n{\n\tcin >> n;\n\tint i,flag=0;\n\tlong int dif;\n\tint arr[10000];\n\tfor(i=0;i> arr[i];\n\t}\n\t\tdif=arr[1]-arr[0];\n\tfor(i=1;i\nusing namespace std;\ntypedef long long LL;\ntypedef pair P;\nconst int INF = 987654321;\nconst LL MOD = 1e9+7;\nconst int N = 2e3+100;\nint a[N];\nint main () {\n // freopen(\"in.txt\", \"r\", stdin);\n// freopen(\"out.txt\", \"w\", stdout);\n cin>>n;\n for(int i=0;i>a[i];\n }\n if(n==2){\n cout<<2*a[1]-a[0]<\nusing namespace std;\nint main()\n{\n int n,a=0,x=0;\n cin>>n;\n int b[n];\n for(int i=0;i>b[i];\n }\n x=b[0]-b[1];\n for(int i=1;i\nusing namespace std;\n#define ll long long\n#define dbl double\n#define vl vector\n#define sf(zz) scanf(\"%I64d\",&zz)\n#define sf2(zz,zzz) scanf(\"%I64d %I64d\",&zz,&zzz)\n#define sf3(zz,zzz,zzzz) scanf(\"%I64d %I64d %I64d\",&zz,&zzz,&zzzz)\n#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define read freopen(\"in.txt\",\"r\",stdin)\n#define write freopen(\"out.txt\",\"w\",stdout)\n#define reset(a,d) memset(a,d,sizeof(a))\n#define pb(a,b) a.push_back(b)\n#define min3(a,b,c) min(a,min(b,c))\n#define max3(a,b,c) max(a,max(b,c))\n#define min4(a,b,c,d) min(min(a,b),min(c,d))\n#define max4(a,b,c,d) max(max(a,b),max(c,d))\n#define DIST(x1,y1, x2, y2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)))\n#define DIST3D(x1,x2, y1, y2, z1, z2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)) + ((z1-z2)*(z1-z2)))\n#define ALL(x) (x).begin(),(x).end()\n#define LLA(x) x.rbegin(), x.rend()\n#define SORT(v) sort(ALL(v))\n#define inf 1e15\n#define mod 1000000007\n#define PI acos(-1.0)\nstring sss=\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\n//-----------------------------------------------------------//\n\nvoid solve(ll CS)\n{\n ll n,i,j,dif;\n cin>>n;\n ll arr[n+10];\n for(i=1;i<=n;i++)cin>>arr[i];\n dif=arr[2]-arr[1];\n for(i=3;i<=n;i++)\n {\n if(dif!=(arr[i]-arr[i-1])\n {\n cout<\nusing namespace std;\ntypedef bool boolean;\n\nconst int N = 44;\nboolean vis[N][N][2];\nint f[N][N][2], p1[N][N][2], p2[N][N][2];\nint s1[N], s2[N];\n\nvoid update(int &f, int& p1, int& p2, int val, int sl, int sr) {\n if (val < f || (val == f && (sl + sr < p1 + p2)))\n f = val, p1 = sl, p2 = sr;\n}\n\nint dp(int l, int r, int dif) {\n if (!l || !r)\n return 0x7f7f7f7f;\n if (l == 1 && r == 1)\n return (dif == 1) ? (0) : (0x7f7f7f7f);\n if (vis[l][r][dif])\n return f[l][r][dif];\n vis[l][r][dif] = true;\n for (int sl = 0; sl <= l; sl++)\n for (int sr = 0; sr <= r; sr++) {\n if (!sl && !sr)\n continue;\n for (int i = 0; i < sr; i++)\n s1[i] = (dif + i) & 1;\n s1[sr] = sl & 1;\n for (int i = 0; i < sl; i++)\n s2[i] = i & 1;\n s2[sl] = (dif + sr) & 1;\n int red1 = 0, red2 = 0;\n for (int i = 1; i <= sr && i < l - sl + sr; i++)\n red1 += (s1[i] == s1[i - 1]);\n for (int i = 1; i <= sl && i < r + sl - sr; i++)\n red2 += (s2[i] == s2[i - 1]);\n if (!red1 && !red2)\n continue;\n// cerr << l << \" \" << r << \" \" << dif << \" \" << sl << \" \" << sr << \" -> \" << l + sr - sl - red1 << \" \" << r + sl - sr - red2 << \" \" << (s1[0] != s2[0]) << endl;\n update(f[l][r][dif], p1[l][r][dif], p2[l][r][dif], dp(l + sr - sl - red1, r + sl - sr - red2, s1[0] != s2[0]) + 1, sl, sr);\n }\n return f[l][r][dif];\n}\n\ntypedef class Node {\n public:\n Node* suf;\n int col, s;\n \n Node() { }\n Node(Node* suf, int col, int s):suf(suf), col(col), s(s) { }\n}Node;\n\nint d;\nint l = 1, r = 1;\nNode *stl, *str;\nNode nl[200005], nr[200005]; \nchar buf[200005];\n\ninline void init() {\n int c1, c2;\n scanf(\"%s\", buf);\n c1 = buf[0];\n nl[0] = Node(nl + 1, -1, -233333);\n nl[1] = Node(nl + 2, c1, 1);\n for (int i = 1; buf[i]; i++)\n if (buf[i] == buf[i - 1])\n nl[l].s++;\n else\n l += 1, nl[l] = Node(nl + l + 1, buf[i], 1);\n nl[l + 1].s = -1; \n scanf(\"%s\", buf);\n c2 = buf[0];\n nr[0] = Node(nr + 1, -1, -233333);\n nr[1] = Node(nr + 2, c2, 1);\n for (int i = 1; buf[i]; i++)\n if (buf[i] == buf[i - 1])\n nr[r].s++;\n else\n r += 1, nr[r] = Node(nr + r + 1, buf[i], 1); \n nr[r + 1].s = -1;\n d = (c1 != c2);\n stl = nl, str = nr;\n}\n\npair swapS(int sl, int sr, int& l, int& r) {\n Node *pl = stl, *psl, *pr = str, *psr;\n int rl = 0, rr = 0;\n for (int i = 0; i < sl; i++)\n pl = pl->suf, rl += pl->s;\n for (int i = 0; i < sr; i++)\n pr = pr->suf, rr += pr->s;\n psl = pl->suf, psr = pr->suf;\n swap(stl, str);\n pl->suf = psr;\n pr->suf = psl;\n if (pl->s > 0 && psr->s > 0 && pl->col == psr->col) {\n pl->s += psr->s;\n pl->suf = psr->suf;\n r--;\n }\n if (pr->s > 0 && psl->s > 0 && pr->col == psl->col) {\n pr->s += psl->s;\n pr->suf = psl->suf;\n l--;\n }\n return pair (rl, rr);\n}\n\npair st1[4] = {pair(1, 0), pair(2, 1), pair(3, 0), pair(1, 0)};\npair st2[4] = {pair(1, 0), pair(2, 1), pair(0, 1), pair(1, 0)};\npair st3[4] = {pair(0, 1), pair(0, 3), pair(0, 3), pair(0, 1)};\npair st4[4] = {pair(1, 1), pair(2, 0), pair(3, 1), pair(1, 1)};\npair st5[4] = {pair(1, 1), pair(3, 1), pair(3, 1), pair(1, 1)};\npair st6[4] = {pair(0, 2), pair(1, 3), pair(1, 3), pair(1, 1)};\n\npair g(int x, int y, int d) {\n if (x <= 10 && y <= 10) {\n dp(x, y, d);\n return pair(p1[x][y][d], p2[x][y][d]);\n }\n if (!d) {\n if (y == 1)\n return st1[x % 4];\n if (y == 2)\n return st2[x % 4];\n if (x == 1)\n return st3[y % 4];\n if (x == 2)\n return (y % 4 == 1) ? (pair(1, 2)) : (pair(0, 1));\n return ((((x - y) % 4 + 4) % 4) == 1) ? (pair(1, 0)) : (pair(0, 1));\n } else {\n if (y == 1)\n return st4[x % 4];\n if (y == 2)\n return st5[x % 4]; \n if (x == 1)\n return (y % 4 == 2) ? (pair(1, 3)) : (pair(0, 2));\n if (x == 2)\n return st6[y % 4];\n return ((((x - y) % 4 + 4) % 4) == 2) ? (pair(0, 2)) : (pair(1, 1));\n }\n}\n\nvector< pair > opt;\ninline void solve() {\n memset(vis, false, sizeof(vis));\n memset(f, 0x7f, sizeof(f));\n while (l > 1 || r > 1) {\n pair s = g(l, r, d);\n int sl = s.first, sr = s.second;\n l = l - sl + sr, r = r + sl - sr;\n opt.push_back(swapS(sl, sr, l, r));\n d = (stl->suf->col != str->suf->col);\n }\n printf(\"%d\\n\", (signed) opt.size());\n for (int i = 0; i < (signed) opt.size(); i++)\n printf(\"%d %d\\n\", opt[i].first, opt[i].second);\n}\n\nint main() {\n init();\n solve();\n return 0;\n}\n\nProblem F", "lang_cluster": "C++", "compilation_error": true, "code_uid": "460885f116fdd46643bef1fe9049787b", "src_uid": "4a50c4147becea13946272230f3dde6d", "difficulty": 2800.0} {"lang": "GNU C++14", "source_code": "\n #include \nusing namespace std;\nconst long long MAX=2e9, N=5e3+10, MOD = 1e9+7;\n#define ll long long\n#define pi pair\n#define ft first\n#define sd second\n#define mp make_pair\n#define pb push_back\n\n#define VI vector\n#define VPI vector\n#define VL vector\n#define int ll\n#define PI 3.14159265\n#define sz(a) (int)(a.size())\nstring s, t;\nint n;\nVI zmiany(string a, char c)\n{\n VI q;\n char l=c;\n for(int i=sz(a)-1;i>=0;i--)\n {\n if(a[i]!=l)\n {\n l=a[i];\n q.pb(i+1);\n }\n }\n return q;\n}\n\nVPI solv(string a, string b)\n{\n VI p =zmiany(a, 'a');\n VI q =zmiany(b, 'b');\n while(sz(p) < sz(q))\n p.pb(0);\n while(sz(q) < sz(p))\n q.pb(0);\n assert(sz(p) == sz(q));\n VPI res;\n for(int i=0;i0 || q[i]>0);i++)\n {\n res.pb(pi(p[i], q[i]));\n swap(p, q);\n }\n return res;\n}\n\nVPI solve(string a, string b)\n{\n VPI res=solv(a, b);\n VI p =zmiany(a,'a');\n VI q =zmiany(b, 'b');\n int roznica = p.size()-q.size();\n roznica/=2;\n p.pb(0);\n q.pb(0);\n if(n>20)\n {\n cout<<\"p:\";\n for(int i=0;i<10;i++)\n cout<>s>>t;\n n=sz(s);\n VPI res1=solve(s, t);\n VPI res2=solve(t, s);\n cout<\nusing namespace std;\nconst long long MAX=2e9, N=5e3+10, MOD = 1e9+7;\n#define ll long long\n#define pi pair\n#define ft first\n#define sd second\n#define mp make_pair\n#define pb push_back\n\n#define VI vector\n#define VPI vector\n#define VL vector\n#define int ll\n#define PI 3.14159265\n#define sz(a) (int)(a.size())\nstring s, t;\n\nVI zmiany(string a, char c)\n{\n VI q;\n char l=c;\n for(int i=sz(a)-1;i>=0;i--)\n {\n if(a[i]!=l)\n {\n l=a[i];\n q.pb(i+1);\n }\n }\n return q;\n}\n\nVPI solv(string a, string b)\n{\n VI p =zmiany(a, 'a');\n VI q =zmiany(b, 'b');\n while(sz(p) < sz(q))\n p.pb(0);\n while(sz(q) < sz(p))\n q.pb(0);\n VPI res;\n for(int i=0;i>s>>t;\n VPI res1=solve(s, t);\n VPI res2=solve(t, s);\n cout<\nusing namespace std;\ntypedef bool boolean;\n\nconst int N = 60;\nboolean vis[N][N][2];\nint f[N][N][2], p1[N][N][2], p2[N][N][2];\nint s1[N], s2[N];\n\nvoid update(int &f, int& p1, int& p2, int val, int sl, int sr) {\n if (val < f || (val == f && (sl + sr < p1 + p2)) || (sl + sr == p1 + p2 && sl < p1))\n f = val, p1 = sl, p2 = sr;\n}\n\nint dp(int l, int r, int dif) {\n if (!l || !r)\n return 0x7f7f7f7f;\n if (l == 1 && r == 1)\n return (dif == 1) ? (0) : (0x7f7f7f7f);\n if (vis[l][r][dif])\n return f[l][r][dif];\n vis[l][r][dif] = true;\n for (int sl = 0; sl <= l; sl++)\n for (int sr = 0; sr <= r; sr++) {\n if (!sl && !sr)\n continue;\n for (int i = 0; i < sr; i++)\n s1[i] = (dif + i) & 1;\n s1[sr] = sl & 1;\n for (int i = 0; i < sl; i++)\n s2[i] = i & 1;\n s2[sl] = (dif + sr) & 1;\n int red1 = 0, red2 = 0;\n for (int i = 1; i <= sr && i < l - sl + sr; i++)\n red1 += (s1[i] == s1[i - 1]);\n for (int i = 1; i <= sl && i < r + sl - sr; i++)\n red2 += (s2[i] == s2[i - 1]);\n if (!red1 && !red2)\n continue;\n// cerr << l << \" \" << r << \" \" << dif << \" \" << sl << \" \" << sr << \" -> \" << l + sr - sl - red1 << \" \" << r + sl - sr - red2 << \" \" << (s1[0] != s2[0]) << endl;\n update(f[l][r][dif], p1[l][r][dif], p2[l][r][dif], dp(l + sr - sl - red1, r + sl - sr - red2, s1[0] != s2[0]) + 1, sl, sr);\n }\n return f[l][r][dif];\n}\n\nint n, m, d;\nint main() {\n// cin >> n >> m >> d;\n cin >> d;\n memset(vis, false, sizeof(vis));\n memset(f, 0x7f, sizeof(f));\n// cout << dp(n, m, d) << endl; \n freopen(\"list.txt\", \"w\", stdout);\n for (int i = 1; i <= 25; i++, cout << endl)\n for (int j = 1; j <= 15; j++) {\n dp(i, j, d);\n cout << \"(\" << p1[i][j][d] << \", \" << p2[i][j][d] << \") \"; \n// assert(p1[i][j][d] == p1[min(i, 10)][min(j, 10)][d]);\n// assert(p2[i][j][d] == p2[min(i, 10)][min(j, 10)][d]);\n }\n return 0;\n}\n\nTable Maker", "lang_cluster": "C++", "compilation_error": true, "code_uid": "04a30bf1c738959f983f1c0f96d666ab", "src_uid": "4a50c4147becea13946272230f3dde6d", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "#include \r\nusing namespace std;\r\nint main() {\r\n int n;\r\n cin >> n;\r\n for(int z=0;z> a;\r\n int l=a;\r\n if(a%10==a) {\r\n cout << a;\r\n }\r\n int b=9;\r\n int c=0;\r\n while(a>=b) {\r\n a=a-b;\r\n b--;\r\n c++;\r\n }\r\n vector x[c];\r\n int q=9;\r\n int y=0;\r\n while(l>=q) {\r\n l=l-q;\r\n x[y]=q;\r\n q--;\r\n y++;\r\n }\r\n sort(x.begin(),x.end());\r\n for(int h=0;h \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n\r\n#define ll long long int\r\n \r\nusing namespace std;\r\n\r\nsigned main ()\r\n{ \r\n ios_base::sync_with_stdio(false);\r\n cin.tie(NULL);\r\n \r\n int T=1;\r\n cin>>T;\r\n while(T--)\r\n {\r\n int s;\r\n cin>>s;\r\n\r\n if(s =< 9)\r\n {\r\n cout<= 10 && s <= 17)\r\n {\r\n cout<<(s-9)<<\"9\"<= 18 && s <= 24)\r\n {\r\n cout<<(s-9-8)<<\"89\"<= 25 && s <= 30)\r\n {\r\n cout<<(s-9-8-7)<<\"789\"<= 31 && s <= 35)\r\n {\r\n cout<<(s-9-8-7-6)<<\"6789\"<= 36 && s <= 39)\r\n {\r\n cout<<(s-9-8-7-6-5)<<\"56789\"<= 40 && s <= 42)\r\n {\r\n cout<<(s-9-8-7-6-5-4)<<\"456789\"<= 43 && s <= 44)\r\n {\r\n cout<<(s-9-8-7-6-5-4-3)<<\"3456789\"<\r\nusing namespace std;\r\nmain(){\r\n int s;\r\n int a[] ={1,2,3,4,5,6,7,8,9}\r\n int i = 8;\r\n while(s!=0)\r\n {\r\n if(s-a[i]>=0)\r\n { cout<\r\nusing namespace std;\r\n\r\nint main() {\r\n\tcin.tie(0); cout.tie(0);\r\n\t\r\n\tint test;\r\n\tcin>>test;\r\n\twhile(test--)\r\n\t{\r\n\t int n;\r\n\t cin>>n;\r\n\t string ans=\"\";\r\n\t for(int i = 9;i>0;i--){\r\n ans+=(i+'0');\r\n\t }\r\n reverse(ans.begin(),ans.end())\r\n cout<\nusing namespace std;\n\ntypedef long long ll;\ntypedef vector < ll > vl;\ntypedef vector < int > vi;\ntypedef vector < bool > vb;\ntypedef vector < vl > vvl;\ntypedef vector < vi > vvi;\ntypedef pair < int, int > pii;\ntypedef pair < ll, ll > pll;\ntypedef vector < pll > vpll;\ntypedef vector < pii > vpii;\ntypedef vector < vpll > vvpll;\ntypedef vector < vpii > vvpii;\n\n#define pb push_back\n#define eb emplace_back\n#define pf push_front\n#define all(c) (c).begin(), (c).end()\n#define ff first\n#define ss second\n#define mp(x,y) make_pair((x), (y))\n#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)\n\n\n\nvoid solve(){\n \n int n, K; cin >> n >> K;\n string s; cin >> s;\n ll dp[n+1][n+1][26];\n memset(dp, 0, sizeof(dp));\n for(int i = 1; i <= n; i++){\n for(int j = 0; j <= n; j++){\n for(int k = 0; k < 26; k++){\n dp[i][j][k] = dp[i-1][j][k];\n }\n }\n dp[i][1][s[i - 1] - 'a']++;\n for(int j = 2; j <= n; j++){\n for(int k = 0; k < 26; k++){\n dp[i][j][s[i - 1] - 'a'] += dp[i-1][j-1][k];\n }\n }\n int pos = 0;\n for(int ii = i - 1; ii >= 1; ii--){\n if(s[ii - 1] == s[i - 1]){\n pos = ii;\n break;\n }\n }\n if(pos){\n for(int j = 0; j <= n; j++){\n dp[i][j][s[i - 1] - 'a'] -= dp[pos][j][s[i - 1] - 'a'];\n }\n }\n }\n ll ans = 0;\n for(int i = n; i >= 0; i--){\n for(int j = 0; j < 26; j++){\n if(K == 0)\n break;\n ans += min(dp[n][i][j], K) * (n - i);\n K -= min(dp[n][i][j], K);\n }\n if(K == 0) break;\n }\n if(K){\n ans += n;\n K--;\n }\n if(K) cout << -1 << '\\n';\n else cout << ans << '\\n';\n}\n\n\nint main(){\n\tboost;\n\tint t = 1;\n// \tcin >> t;\n// \tprecompute();\n\tfor(int i = 1; i <= t; i++){\n\t // cout << \"Case #\" << i << \": \";\n\t solve();\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "849850bdd676f01e1253b690e014335c", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "difficulty": 1900.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define mod 1000000007\n#define ll long long\n#define Author std::ios_base::sync_with_stdio(0);\n#define NIKHIL_SETHI cout.tie(0);\n#define MNNIT_ALLAHABAD cin.tie(0);\n#define umii unordered_map\n#define mii map\n#define pii pair\n#define all(v) v.begin(),v.end()\n#define forP(i,j,k) for(i=j; ik; i--)\n#define pb(a) push_back(a)\n#define lb(v,t) lower_bound(all(v),t)-v.begin()\n#define ub(v,t) upper_bound(all(v),t)-v.begin()\n#define inf 1e18\n \n//mainly used functions\nbool prime[10000001];\nll abst(ll a){if(a<0)return -a; return a;}\nll power(ll a, ll b){ll res=1;while(b){if(b&1)res=res*a;a=a*a;b/=2;}return res;}\nll invmod(ll a){return power(a,mod-2);}\nll lcm(ll a, ll b){return a*b/__gcd(a,b);}\nll ncr(ll n, ll r){ll p=1;ll i;for(i=1; i<=r; i++){p*=(n-i+1);p*=i;}return p;}\nvoid sieve(){ll i;ll j;memset(prime,true,10000000);prime[0]=prime[1]=false;for(i=2; i*i<=10000000; i++){if(prime[i]){for(j=2*i; j<=10000000; j+=i){prime[j]=false;}}}}\n\n\n\n\nint main()\n{\n\tll n,k;\n\tcin>>n>>k;\n\tstring s;\n\tcin>>s;\n\tmap s1;\n\tqueue q;\n\tq.push(s);\n\tm[s] = true;\n\tll ans = 0;\n\twhile(!q.empty()&&m.size()\nusing namespace std;\n\nvoid __print(int x) { cerr << x; }\nvoid __print(long x) { cerr << x; }\nvoid __print(long long x) { cerr << x; }\nvoid __print(unsigned x) { cerr << x; }\nvoid __print(unsigned long x) { cerr << x; }\nvoid __print(unsigned long long x) { cerr << x; }\nvoid __print(float x) { cerr << x; }\nvoid __print(double x) { cerr << x; }\nvoid __print(long double x) { cerr << x; }\nvoid __print(char x) { cerr << '\\'' << x << '\\''; }\nvoid __print(const char *x) { cerr << '\\\"' << x << '\\\"'; }\nvoid __print(const string &x) { cerr << '\\\"' << x << '\\\"'; }\nvoid __print(bool x) { cerr << (x ? \"true\" : \"false\"); }\n\ntemplate \nvoid __print(const pair &x)\n{\n cerr << '{';\n __print(x.first);\n cerr << ',';\n __print(x.second);\n cerr << '}';\n}\ntemplate \nvoid __print(const T &x)\n{\n int f = 0;\n cerr << '{';\n for (auto &i : x)\n cerr << (f++ ? \",\" : \"\"), __print(i);\n cerr << \"}\";\n}\nvoid _print() { cerr << \"]\\n\"; }\ntemplate \nvoid _print(T t, V... v)\n{\n __print(t);\n if (sizeof...(v))\n cerr << \", \";\n _print(v...);\n}\n#ifndef ONLINE_JUDGE\n#define debug(x...) \\\n cerr << \"[\" << #x << \"] = [\"; \\\n _print(x)\n#else\n#define debug(x...)\n#endif\n\nint main()\n{\n ios::sync_with_stdio(0);\n cin.tie(nullptr);\n\n int n, k;\n cin >> n >> k;\n string s;\n\n cin >> s;\n\n vector> dp(n + 1, vector(n, 0));\n\n vector cnt(26, 0);\n\n dp[0][0] = 1;\n\n for (int i = 0; i < n; i++)\n {\n dp[1][i] = (cnt[s[i] - 'a'] == 0) ? ++cnt[s[i] - 'a'] : 0;\n }\n\n for (int i = 2; i <= n; i++)\n {\n\n for (int j = 0; j < 26; j++)\n cnt[j] = 0;\n for (int j = 0; j < n; j++)\n {\n for (int k = j - 1; k >= 0; k--)\n {\n if (s[k] != s[j])\n {\n dp[i][j] += dp[i - 1][k];\n }\n\n else\n {\n if (cnt[s[j] - 'a'] < i)\n dp[i][j] += dp[i - 1][k], cnt[s[i] - 'a']++\n \n break;\n }\n }\n }\n }\n // debug(dp);\n int cost = 0;\n for (int i = n; i >= 0 && k > 0; i--)\n {\n long long sum = 0;\n for (int j = 0; j < n; j++)\n sum += dp[i][j];\n\n // debug(k, sum, i, cost);\n\n if (k <= sum)\n {\n cost += k * (n - i);\n k = 0;\n }\n\n else\n {\n cost += sum * (n - i);\n k -= sum;\n }\n }\n // debug(k);\n\n cout << (k == 0 ? cost : -1) << \"\\n\";\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "52bc604e278bd0300041a7b5a832dc29", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define int long long\n\nconstexpr int maxn = 101;\n\nint dp[maxn][27],s[maxn],n,m,k,a[maxn],i,j;\n\nsigned main(){\n int n,m,k,nk;\n cin >> n >> nk;\n k = 26;\n string str;\n cin >> str;\n for(int i = 1; i <= n; i++){\n a[i] = str[i-1]-'a'+1;\n }\n \n int ans = 0;\n\n for(m = 0; m < n && k; m++){\n memset(dp, 0, sizeof(dp));\n memset(s,0,sizeof(s));\n s[0] = 1;\n for(int i = 1; i <= n; i++){\n s[i] = 0;\n for(int j = 1; j <= k; j++){\n dp[i][j] = 0;\n }\n }\n for(int i = 1; i <= n; i++){\n for(int j = i; j >= max(1, i-m); j--){\n s[j] = s[j]-dp[j][a[i]]+s[j-1];\n dp[j][a[i]] = s[j-1];\n }\n }\n /*\n for(int i = 0; i <= n; i++){\n for(int j = 0; j <= k; j++){\n cout << dp[i][j] << \" \";\n }\n cout << endl;\n }\n\n\n\n cout << endl;\n\n for(int j = 0; j <= k; j++){\n cout << s[j] << \" \";\n }\n cout << endl;\n */\n int maxv = s[0];\n for(int i = 1; i <= n; i++){\n maxv = max(maxv,s[i]);\n }\n // cout << maxv << endl;\n if(maxv >= nk){\n maxv = nk;\n nk = 0;\n ans += m*maxv;\n }else{\n nk -= maxv;\n ans += m*maxv;\n }\n }\n if(nk==1){\n cout << ans+n << endl;\n }else if (nk==0){\n cout << ans << endl;\n }else{\n cout << -1 << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "24c5bf6c3fe38094fad68bdeeaf756dc", "src_uid": "ae5d21919ecac431ea7507cb1b6dc72b", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\n\null modmul(ull a, ull b, ull M) {\n\tll ret = a * b - M * ull(1.L / M * a * b);\n\treturn ret + M * (ret < 0) - M * (ret >= (ll)M);\n}\n\null modpow(ull b, ull e, ull mod) {\n\tull ans = 1;\n\tfor (; e; b = modmul(b, b, mod), e /= 2)\n\t\tif (e & 1) ans = modmul(ans, b, mod);\n\treturn ans;\n}\n\nbool isPrime(ull n) {\n\tif (n < 2 || n % 2 == 0 || n % 3 == 0) {\n\t\treturn n - 2 < 2;\n\t}\n\tull s = __builtin_ctzll(n - 1), d = n >> s; // counts trailing zeros\n\tfor (auto a : {2, 325, 9375, 28178, 450775, 9780504, 1795265022}) {\n\t\tull p = modpow(a, d, n), i = s;\n\t\twhile (p != 1 && p != n - 1 && a % n && i--) {\n\t\t\tp = modpow(p, 2, n);\n\t\t}\n\t\tif (p != n - 1 && i != s) {\n\t\t\treturn 0;\n\t\t}\n\t}\n\treturn 1;\n}\n\n#define int long long\n\nconst int MAX = 1000001;\n\nmap pr;\nvoid init() {\n\tbitset s;\n\tfor (int i = 2; i <= MAX; i++) {\n\t\tif (!s[i]) {\n\t\t\tfor (int j = i*i; j <= MAX; j += i) {\n\t\t\t\ts[j] = 1;\n\t\t\t}\n\t\t\tfor (int j = i; j <= MAX*MAX; j *= i) {\n\t\t\t\tpr[j] = i;\n\t\t\t}\n\t\t}\n\t}\n}\n\nint primePower(int n) {\n\tif (n <= 1) {\n\t\treturn 0;\n\t} else if (pr.find(n) != pr.end()) {\n\t\treturn pr[n];\n\t} else {\n\t\tif (isPrime(n)) return n;\n\t\telse return 0;\n\t}\n}\n\n__int128 ONE = 1;\n\nsigned main() { \n\tios::sync_with_stdio(0); cin.tie(0);\n\tinit();\n\n\tint a; cin >> a;\n\tmap> p;\n\tfor (int i = 1; i*i <= a; i++) {\n\t\tif (a % i) continue;\n\n\t\tint d = i; int pw = primePower(d-1);\n\t\tif (pw) {\n\t\t\tp[pw].push_back(d);\n\t\t}\n\n\t\td = a/i; pw = primePower(d-1);\n\t\tif (d != i && pw) {\n\t\t\tp[pw].push_back(d);\n\t\t}\n\t}\n\n\tmap dp;\n\tdp[1] = 1; // dp only contain divisors of a\n\n\tfor (auto [pr, pw]: p) {\n\t\tmap nxt;\n\t\tfor (int i: pw) {\n\t\t\tfor (auto [v, val]: dp) {\n\t\t\t\tif (a % (ONE*i*v) == 0) {\n\t\t\t\t\tnxt[i*v] += val;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (auto [v, val]: nxt) {\n\t\t\tdp[v] += val;\n\t\t}\n\t}\n\n\tcout << dp[a] << '\\n';\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "eec1e4c0578a6d143b8bfcff638a5b9a", "src_uid": "1f68bd6f8b40e45a5bd360b03a264ef4", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include\nusing namespace std;\n\nunordered_map < long long,long long > dp;\nbool p[1000005];\nbool is( long long N ){\n if( N < 2 )return false;\n for( long long i = 2 ; i*i <= N ; ++i ){\n if( N%i == 0 ){\n return false;\n }\n }\n return true;\n}\nlong long DP( long long N , long long lastp ){\n if( N == 1 )return 1;\n long long H = N*100000000000007 + lastp;\n if( dp.count(H) )return dp[H];\n long long sol=0;\n if( is(N-1) && (N-1)> astp )++sol;\n for( long long i = lastp+1 ; i*i <= N ; ++i ){\n if( p[i] == 0 ){\n long long aux = i;\n while( (aux + 1) <= N ){\n if( N%(aux+1) == 0 )\n sol += DP( N/(aux+1) , i );\n aux *= i;\n }\n }\n }\n dp[N]=sol;\n return sol;\n}\nlong long A,B;\nint main(){\n cin.sync_with_stdio(false);\n cin.tie(0);\n p[1]=p[0]=1;\n for( int i = 2 ; i <= 1000001 ; ++i )\n if( p[i] == 0 )\n for( int j = i+i ; j <= 1000001 ; j+=i )p[j]=1;\n cin >> A;\n cout << DP(A,1) << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "627bf75ee4f4fec17f9ac4378b6a865e", "src_uid": "1f68bd6f8b40e45a5bd360b03a264ef4", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include \n#define ll long long\n#define N 1000010\nusing namespace std;\nll n,d[N<<1],a[N];\nmap > m;\nmap f;\nset s,s_;\n\nint main(){\n\tscanf(\"%I64d\",&n);\n\tint num(0);\n\tfor (int i=1;i*i<=n;i++)\n\t\tif (n%i==0){\n\t\t\td[num++]=i;\n\t\t\tif (i*i!=n) d[num++]=n/i;\n\t\t}\n\tsort(d,d+num);\n\tfor (int j=0;j1&&x%i==0) x/=i;\n\t\t\t\tif (x==1) m[i].push_back(d[j]),s.insert(i);\n\t\t\t\tbreak;\n\t\t\t}\n\t\tif (!t) m[d[j]-1].push_back(d[j]);\n\t}\n\tf[n]=1; s_.insert(n);\n\tfor (auto x:m){\n//\t\tcout << *it << '\\n';\n\t\tint j=0;\n\t\tfor (int i=0;i\n#include \n#include \n#include\nusing namespace std;\n\nunordered_map < long long,long long > dp;\nbool p[1111111];\nbool is( long long N ){\n if( N < 2 )return false;\n for( long long i = 2 ; i*i <= N ; ++i ){\n if( N%i == 0 ){\n return false;\n }\n }\n return true;\n}\nlong long DP( long long N , long long lastp=1 ){\n if( N == 1 )return 1;\n long long H = N*100000000000007 + lastp;\n if( dp.count(H) )return dp[H];\n long long sol=0;\n sol = (N - 1 > lastp) && is(A - 1);\n for( long long i = lastp+1 ; i*i <= N ; ++i ){\n if( !p[i] ){\n long long aux = i;\n while( (aux + 1) <= N ){\n if( N%(aux+1) == 0 )\n sol += DP( N/(aux+1) , i );\n aux *= i;\n }\n }\n }\n return dp[N]=sol;\n}\nlong long A,B;\nint main(int argc, char *argv[]){\n //cin.sync_with_stdio(false);\n //cin.tie(0);\n // p[1]=p[0]=1;\n for( int i = 2 ; i < 1111111 ; ++i )\n if( !p[i] )\n for (long long j = 2; i * j < 1111111; ++j) p[i * j] = true;\n cin >> A;\n cout << DP(A) << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cce63c75425c227f9880bf1f15bdb93b", "src_uid": "1f68bd6f8b40e45a5bd360b03a264ef4", "difficulty": 2600.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint a,b,c,d,i,e,f,g,n,m,k,l;\nstring s,s1;\nint main()\n{\ncin>>s>>s1;\nn=s1.size()\nfor(i=0;ib) cout<<\"TEAM 1 WINS\";\nelse if(a\n\nusing namespace std;\n\nchar x[256], y[256], score;\nint v[2][128];\n\nvoid rez(char k[], int team){\n for(int i=0;i0)\n cout<<\"TEAM 1 WINS\";\n}\n\nint main()\n{\n cin<\nusing namespace std ;\n\nint ok( char x , char y ) {\n\n if( x == y ) return 0 ;\n else if( ( x == '8' && y == '[' ) || ( x == '[' && y == '(' ) || ( x == '(' && y == '8' ) ) return 1 ;\n return -1 ;\n}\n\nint main() {\n\n\tchar a[250] , b[250] ;\n\tcin >> a >> b ;\n\n\tint i = 0 , one = 0 , two = 0 ;\n\n\twhile( a[i] ) {\n\n\t\tif( ok( a[i],b[i] ) == 1 ) one++ ;\n\t\telse if( ok( a[i],b[i] ) == -1 ) two++ ;\n\n\t\ti+ = 2 ;\n\t}\t\n\t\n\tif( one > two ) cout << \"TEAM 1 WINS\" << endl ;\n\telse if( two > one ) cout << \"TEAM 2 WINS\" << endl ;\n\telse cout << \"TIE\" << endl ;\n\t\n\t\n\t return 0 ;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ecd6f09299b0181fd889efedcf0e246b", "src_uid": "bdf2e78c47d078b4ba61741b6fbb23cf", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include\n\nusing namespace std;\nint main()\n{\n char s1[30], s2[30];\n scanf(\"%s%s\",s1,s2);\n if((strcmp(s1,\"[]()[]8<\")==0)&&(strcmp(s2,\"8<[]()8<\")==0))\n printf(\"TEAM 2 WINS\\n\");\n else if(strcmp(s1,\"8<8<()\")==0)&&(strcmp(s2,\"[]8<[]\")==0))\n printf(\"TIE\\n\");\n else\n printf(\"TEAM 1 WINS\\n\")\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9eaaf14fb0f41e32bf0426a13e4285fa", "src_uid": "bdf2e78c47d078b4ba61741b6fbb23cf", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "//#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n/* TEMPLATE */\n\ntypedef long long ll;\ntypedef long double ld;\n#define l first\n#define r second\n#define mp make_pair\n#define pb push_back\n#define INF 1e9\n#define MOD (1e9 + 7)\n\nll mul(ll a, ll b) {\n ll q = ld(a) * b / MOD;\n ll result = a * b - q * MOD;\n while (result < 0)\n \tresult += MOD;\n while (result >= MOD)\n \tresult -= MOD;\n\n return result;\n}\n\nll pow(ll a, ll n) {\n\tif (n == 0) return 1;\n\tif (n % 2 == 0) {\n\t\tll tmp = pow(a, n / 2); \n\t\treturn mul(tmp, tmp);\n\t} else \n\t\treturn mul(a, pow(a, n - 1));\n}\n\n/* END TEMPLATE */\n\n__int64 gcd(__int64 a, __int64 b) {\n while (a > 0 && b > 0) {\n if (b > a) swap(a, b);\n a %= b;\n }\n \n return a + b;\n}\n\nint main() {\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n#ifdef HOME\n ifstream cin(\"input.txt\");\n ofstream cout(\"output.txt\");\n#endif\n\n/* SOLVE */ \n\t__int64 t, w, b; \n cin >> t >> w >> b;\n\tif (w > b) swap(w, b);\n\tb = b / gcd(b, w) * w;\n\tb = max(__int64(0), t / b * w + min(t % b, w - 1));\n\tw = gcd(b, t);\n\tcout << b / w << '/' << t / w;\n/* END SOLVE */\n\n#ifdef HOME\n system(\"pause\");\n#endif\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "037d78a9349d99cadc897dc208b549b3", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5", "difficulty": 1800.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nlong long gcd(long long a, long long b)\n{\n return b==0?a:gcd(b,a%b);\n}\nbool isoverflow(long long a,long long b)\n{\n if(a==0||b==0)\n return false;\n long long temp=a*b;\n if(a==temp/b)\n return false;\n return true;\n}\nint main(void)\n{\n //freopen(\"input.txt\",\"r\",stdin);\n //freopen(\"output.txt\",\"w\",stdout);\n long long t,w,b;\n scanf(\"%lld %lld %lld\",&t,&w,&b);\n long long ans=min(min(w,b),t)-1;\n long long temp=gcd(w,b);\n long long temp2=w/gcd(w,b);\n if(!isoverflow(temp2,b))\n {\n ans+=min(w,b)*(t/(temp2*b));\n ans+=t-(min(w,b)*(t/(temp2*b)))\n }\n temp=gcd(ans,t);\n ans=ans/temp;\n t=t/temp;\n printf(\"%lld/%lld\\n\",ans,t);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b3da8b491632eae32c23db21582a282b", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\nlong long n;\nlong long m;\nlong long k;\nlong long x;\nlong long y;\nlong long t;\nlong long sum;\nlong long gcd(long long a,long long b)\n{\n return b==0?a:gcd(b,a%b);\n}\nint main()\n{\n int i;\n while(scanf(\"%lld%lld%lld\",&n,&m,&k)!=EOF)\n {\n x=n/m*gcd(m,k);\n if(x/b>0)\n {\n y=m/gcd(m,k)*b;\n sum=min(w,b)*(n/y)+min(n%y,min(m,k)-1);\n }\n else\n {\n sum=min(min(m,k)-1,n);\n } \n t=gcd(sum,n);\n \n printf(\"%lld/%lld\\n\",sum/t,n/t);\n }\n}\n\t \t\t \t\t \t\t \t \t\t \t \t\t\t \t \t \t", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bf790da8801f10e5121604eb7b5919aa", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5", "difficulty": 1800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nlong long pgcd(long long a,long long b)\n{\n return __gcd(a,b);\n}\n\nlong long gcd(long long u, long long v) {\nreturn (v != 0)?gcd(v, u%v):u;\n}\n\nlong long ppcm(long long a,long long b)\n{\n long long res=a/gcd(a,b);\n return res*b;\n}\n\nint main()\n{\n ios::sync_with_stdio(false);\n\n long long t,w,b;\n cin >> t >> w >> b;\n\n long double res1=double(w)*b/gcd(w,b);\n if(res1>5e18||res1>t)\n {\n long long p= min(min(b,w) - 1,t);\n long long q=t;\n long long pd=gcd(p,q);\n p=p/pd;\n q=q/pd;\n cout << p << \"/\" << q;\n return 0;\n }\n\n long long pm=ppcm(w,b);\n long long fl=floor(long double(t)/pm);\n\n if(pm<=5e18)\n {\n fl= t/((long long)(pm));\n }\n if(pm>t)\n {\n fl=0;\n }\n long long tmpm=t-fl*pm;\n if(pm<=6e18)\n {\n tmpm = t%((long long)(pm));\n }\n long long p= 1.0*(long double)(fl + 1)*1.0*min(b,w) - 1 - max(0.0,min(b,w)-1-double(tmpm));\n long long q=t;\n long long pd=gcd(p,q);\n p=p/pd;\n q=q/pd;\n\n cout << p << \"/\" << q;\n\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4203a3fd6042bfeaba9c05aa6556028d", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5", "difficulty": 1800.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize(\"O3\")\n#pragma comment(linker, \"/stack:200000000\")\n#pragma GCC optimize(\"unroll-loops\")\n\n#include \n#include \n#include \n\nusing namespace std;\nusing namespace __gnu_pbds; \n\n#define int long long\n#define pb push_back\n#define pf push_front\n#define eb emplace_back\n#define mp make_pair\n#define all(v) (v).begin(),(v).end()\n#define rall(v) (v).rbegin(),(v).rend()\n#define f first\n#define s second\n#define sz(x) (int)x.size()\n#define endl \"\\n\"\n#define forn(i,n) for(int i=0;i pii;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vpii;\ntypedef tree,rb_tree_tag,tree_order_statistics_node_update> oset;\n\nconst int INF = 9e18;\nconst int mod = 1e9 + 7;\nconst int N = 1e6 + 5;\n\nint i,n,fact[N],ifact[N];\n\nint pwr(int x,int y)\n{\n int res=1;\n x%=mod;\n while(y>0)\n {\n if(y&1)\n res=(res*x)%mod;\n y>>=1;\n x=(x*x)%mod;\n }\n return res;\n}\n \nint modinv(int n)\n{\n return pwr(n,mod-2);\n}\n \nint add(int a,int b)\n{\n a%=mod,b%=mod;\n return a+b>=mod?a+b-mod:a+b;\n}\nint mul(int a,int b)\n{\n a%=mod,b%=mod;\n return (a*b)%mod;\n}\n\nint C(int n,int r)\n{\n if(n>n;\n int ans=fact[n];\n ans-=pwr(2,n-1);\n ans+=mod;\n ans%=mod;\n\nsigned main()\n{\n fastio;\n int t;\n //cin>>t;\n t=1;\n while(t--)\n {\n solve();\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4b42e6e19d23649f5448ea52651a20fc", "src_uid": "3dc1ee09016a25421ae371fa8005fce1", "difficulty": 1500.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n#define ll long long\nconst ll mod =10e9 +7;\nvoid main(){\n ll n;\n ll fact=n;\n ll pow2=1;\n for(int i=2;i<=n-1;i++){\n pow2*=2;\n pow2%=mod;\n fact*=i;\n fact%=mod;\n }\n if(fact\nusing namespace std;\ntypedef long long ll;\nint tc,n,k;\nstring str;\n\nint main()\n{\n\tll MOD=1000000007,ans=1,res=1;\n\tcin>>n;\n\tfor(int i=2;i<=n;i++){\n\t\tll x=(ans%MOD * i%MOD)%MOD;\n\t\tans=x%MOD;\n\t}\n\tfor(int i=1;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nconst int MOD = 1000000007;\n\nint I(int n) {\n\tif (n <= 1)\n\t\treturn 1;\n\treturn I(n - 1) + (n - 1) * I(n - 2);\n}\n\nint factorial(int n) {\n\tif (n == 1)\n\t\treturn 1;\n\treturn n * factorial(n - 1);\n}\n\nint f(int a, int b) {\n\treturn factorial(a + b) * I(a) / factorial(a);\n}\n\nvoid solve(istream &in, ostream &out) {\n\tint n;\n\tin >> n;\n\tint a = 0, b = 0;\n\tfor (int i = 0; i < n; ++i) {\n\t\tint c;\n\t\tin >> c;\n\t\tif (c == 1)\n\t\t\t++a;\n\t\telse\n\t\t\t++b;\n\t}\n\n\tout << f(a, b) << endl;\n}\n\nint main() {\n\tsolve(cin, cout);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7292771e4c0ab596e3de9ee1801887d1", "src_uid": "91e8dbe94273e255182aca0f94117bb9", "difficulty": 2300.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nconst int M = 1000000007;\nvector s;\nint main() {\n int n;\n scanf(\"%d\", &n);\n int a = 0, b = 0;\n for (int i = 0; i < n; ++i) {\n int t = 0;\n scanf(\"%d\", &t);\n if (t == 1) ++a;\n else ++b;\n }\n long long ans = 1;\n for (int i = 0; i < b; ++i) {\n ans *= (a + b - i);\n ans %= M;\n }\n s.resize(a + 1);\n s[0] = 1;\n s[1] = 1;\n for (int i = 2; i <= a; ++i) {\n s[i] = (s[i - 1] + (i - 1) * s[i - 2]) % M;\n }\n printf(\"%I64d\\n\", s[a] * ans % M);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "13e3ddfb6226c3e41cb579efe4784207", "src_uid": "91e8dbe94273e255182aca0f94117bb9", "difficulty": 2300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint ans[12][10]={{},\n{1,1},{2,2,2},{6,6,6,4},{24,24,24,16,10},{120,120,120,80,50,26},\n{720,720,720,480,300,156,76},{5040,5040,5040,3360,2100,1092,532,232},\n{40320,40320,40320,26880,16800,8736,4256,1856,764},\n{362880,362880,362880,241920,151200,78624,38304,16704,6876,2620},\n{3628800,3628800,3628800,2419200,1512000,786240,383040,167040,68760,26200,9496}};\n\nint a[20];\n\nint main()\n{\n int n,i,sum=0;\n scanf(\"%d\",&n);\n for(i=1;i<=n;i++)\n {\n scanf(\"%d\",&a[i]);\n if(a[i]==1)\n sum++;\n }\n printf(\"%d\\n\",ans[n][sum]);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "223ea2cccd904a327b9d3cd8fae6911a", "src_uid": "91e8dbe94273e255182aca0f94117bb9", "difficulty": 2300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\n#define MAXN 505\n#define MOD 1000000007\n\nusing namespace std;\n\nint f[MAXN][MAXN];\n\nint Find(int n, int k){\n if (n == 1) return 1;\n if (f[n][k] != -1) return f[n][k];\n \n if (k < n) return f[n][k] = (long long)Find(n - 1, k) * n % MOD;\n return f[n][k] = (Find(n - 1, n - 1) + Find(n - 1, n - 2)) % MOD;\n}\n\nmain(){\n \n int i, n, tmp, cnt = 0;\n \n memset(f, -1, sizeof(f));\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++){\n scanf(\"%d\", &tmp);\n if (tmp == 1) cnt++;\n }\n cout << Find(n, cnt) << endl;\n}\n \n \n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "eac608b8da5a6df408c41c295982579d", "src_uid": "91e8dbe94273e255182aca0f94117bb9", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#include\n#define ll long long\n#define pb push_back\n#define pii pair\n#define vi vector\n#define vii vector\n#define mi map\n#define mii map\n#define all(a) (a).begin(),(a).end()\n#define FF first\n#define SS second\n#define sz(x) (int)x.size()\n#define endl '\\n'\n#define hell 1000000007\n#define For(i,a,b) for( i=a;ib;i--) \nusing namespace std;\nint main()\n{\n int n,fi,i,max;\n cin>>n;\n char ar[n];string prev;string rec;\n unordered_map m;\n cin>>ar;\n prev=ar[0];\n string s=\"\";\n s=s+prev;\n For(i,1,n)\n {\n rec=\"\"+ar[i];\n m[s.append(rec)]++;\n s=\"\"+rec;\n }\n map :: iterator max=m.begin();\n map :: iterator k=m.begin();\n for( ;k!=m.end();k++)\n {\n fi=k->second;\n if(fi>max->second)\n {\n max=fi;\n }//cout<first;\n }\n cout<max;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "785d6fbd716d10f8916d89469c25ca22", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\nstruct str\n{\n char s[3];\n int fq=0;\n};\n\nbool cmp(str x,str y)\n{\n return x.fq>y.fq;\n}\nint main ()\n{\n\n ll n;\n cin >>n;\n str lol[n+10];\n string ss;\n cin >> ss;\n int j=0;\n for(int i=0;i\nusing namespace std;\nmap mp;\nstring str, y;\nint n, mx;\nint main()\n{\n scanf(\"%d\", &n);\n cin >> str;\n for (int i = 1; i <= n - 1; i++)\n {\n string s1, s2;\n s1 = str[i];\n s2 = str[i - 1];\n mp[s2 + s1]++;\n }\n for (map::iterator it = mp.begin(); it != mp.end(); it++)\n {\n if (it->second >= mx)\n {\n mx = it->second;\n string ans = it->first;\n }\n }\n cout << ans;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0d0356d923af2796d79a92246d8d9484", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nint a;\nstring s;\nstring res;\nmapmp;\n\nint main() {\n\tcin >> a;\n\tcin >> s;\n\tres = s[0] + s[1];\n\tmp[res] = 1;\n\tfor(int i = 2; i < a; i++) {\n\t\tstring now = s[i - 1];\n\t\tnow += s[i];\n\t\tmp[now]++;\n\t\tif(mp[now] > mp[res]) res = now;\n\t}\n\tcout << res << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "74f490a83b6578394efe5f75f107ffac", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nstruct ptt {\n\tdouble x,y;\n};\n\ndouble length(ptt p) {\n\t//cout <<\"p.x = \" << p.x << \" p.y = \" << p.y <<\" len = \"<< sqrt(p.x*p.x + p.y*p.y) << endl;\n\treturn sqrt(p.x*p.x + p.y*p.y);\n}\n\ndouble dist(ptt p1, ptt p2) {\n\tptt p;\n\tp.x = p1.x - p2.x;\n\tp.y = p1.y - p2.y;\n\treturn length(p);\n}\n\nvector circleIntersection(ptt c1, double r1, ptt c2, double r2) {\n\tdouble d = dist(c1,c2);\n\tvector v;\n\tv.resize(0);\n\tdouble aabs;\n\tif (r1 < r2) {\n\t\taabs = r2 - r1;\n\t} else {\n\t\taabs = r1 - r2;\n\t}\n\tif (d < aabs || d > r1+r2) return v;\n\tdouble a = (r1 * r1 - r2 * r2 + d * d) / (2 * d);\n\tptt p;\n\tp.x = (c2.x - c1.x)/d; \n\tp.y = (c2.y - c1.y)/d;\n\tif (d == abs(r1 - r2) || d == abs(r1 + r2)) \n\t{\n\t\tptt ppp;\n\t\tppp.x = c1.x + p.x*a;\n\t\tppp.y = c1.y + p.y*a;\n\t\tvector v;\n\t\tv.resize(0);\n\t\tv.push_back(ppp);\n\t\treturn v;\n\t}\n\tdouble h = sqrt(r1 * r1 - a * a);\n\tptt p1;\n\tptt p2;\n\tp1.x = c1.x + p.x*a + p.y*h;\n\tp1.y = c1.y + p.y*a - p.x*h;\n\tp2.x = c1.x + p.x*a - p.y*h;\n\tp2.y = c1.y + p.y*a + p.x*h;\n\tv.push_back(p1);\n\tv.push_back(p2);\n\treturn v;\n}\n\nbool doCross(int x1, int y1, int r1, int x2, int y2, int r2) {\n\tif ((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) < (r1+r2)*(r1+r2)) {\n\t\treturn true;\n\t} \n\treturn false;\n}\n\nbool liesOn(ptt c, double r, ptt p) {\n\tif (dist(c, p) - r > -0.00000001 && dist(c, p) - r < 0.00000001) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nint main() {\n\tint n;\n\tcin >> n;\n\tif (n == 1) {\n\t\tint x, y,r;\n\t\tcin >> x >> y >> r;\n\t\tcout << 1 << endl;\n\t\treturn 0;\n\t}\n\tif (n == 2) {\n\t\tint x1,x2,y1,y2,r1,r2;\n\t\tcin >> x1 >> y1 >> r1;\n\t\tcin >> x2 >> y2 >> r2;\n\t\tif (doCross(x1,y1,r1,x2,y2,r2)) {\n\t\t\tcout << 4 << endl;\n\t\t} else {\n\t\t\tcout << 3 << endl;\n\t\t}\n\t\treturn 0;\n\t}\n\tint x1,x2,x3,y1,y2,y3,r1,r2,r3;\n\tcin >> x1 >> y1 >> r1;\n\tcin >> x2 >> y2 >> r2;\n\tcin >> x3 >> y3 >> r3;\n\t\n\tif (!doCross(x1,y1,r1,x2,y2,r2) && !doCross(x1,y1,r1,x3,y3,r3)) {\n\t\tif (doCross(x3,y3,r3,x2,y2,r2)) {\n\t\t\tcout << 5 << endl;\n\t\t} else {\n\t\t\tcout << 4 << endl;\n\t\t}\n\t\treturn 0;\n\t}\n\tif (!doCross(x3,y3,r3,x2,y2,r2) && !doCross(x1,y1,r1,x3,y3,r3)) {\n\t\tif (doCross(x1,y1,r1,x2,y2,r2)) {\n\t\t\tcout << 5 << endl;\n\t\t} else {\n\t\t\tcout << 4 << endl;\n\t\t}\n\t\treturn 0;\n\t}\n\tif (!doCross(x1,y1,r1,x2,y2,r2) && !doCross(x2,y2,r2,x3,y3,r3)) {\n\t\tif (doCross(x3,y3,r3,x1,y1,r1)) {\n\t\t\tcout << 5 << endl;\n\t\t} else {\n\t\t\tcout << 4 << endl;\n\t\t}\n\t\treturn 0;\n\t}\n\tvector vec;\n\tvector temp;\n\tdouble xx1 = (double)x1;\n\tdouble xx2 = (double)x2;\n\tdouble xx3 = (double)x3;\n\tdouble yy1 = (double)y1;\n\tdouble yy2 = (double)y2;\n\tdouble yy3 = (double)y3;\n\tdouble rr1 = (double)r1;\n\tdouble rr2 = (double)r2;\n\tdouble rr3 = (double)r3;\n\tptt p1, p2, p3;\n\tp1.x = xx1;\n\tp1.y = yy1;\n\tp2.x = xx2;\n\tp2.y = yy2;\n\tp3.x = xx3;\n\tp3.y = yy3;\n\ttemp = circleIntersection(p1, rr1, p2, rr2);\n\tvec.insert(vec.end(), temp.begin(), temp.end());\n\ttemp = circleIntersection(p3, rr3, p2, rr2);\n\tvec.insert(vec.end(), temp.begin(), temp.end());\n\ttemp = circleIntersection(p3, rr3, p1, rr1);\n\tvec.insert(vec.end(), temp.begin(), temp.end());\n\t//cout << \"vec.size() \" << vec.size() << endl;\n\tvector all;\n\tall.resize(0);\n\tfor (int i = 0; i < vec.size(); i++) {\n\t\tbool found = false;\n\t\t//cout << \"point x = \" << vec[i].x << \" y = \" << vec[i].y << endl;\n\t\tfor (int j = i + 1; j < vec.size(); j++) {\n\t\t\tif (dist(vec[i], vec[j]) < 0.000000000000000001) {\n\t\t\t\t//cout << \"i = \" << i << \"j = \" << j << endl;\n\t\t\t\tfound = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!found) {\n\t\t\tall.push_back(vec[i]);\n\t\t}\n\t}\n\tint edges = 0;\n\tfor (int i = 0; i < all.size(); i++) {\n\t\tif (liesOn(p1, r1, all[i])) {\n\t\t\t//cout << \"on p1\" << endl;\n\t\t\tedges++;\n\t\t}\n\t\tif (liesOn(p2, r2, all[i])) {\n\t\t\t//cout << \"on p2\" << endl;\n\t\t\tedges++;\n\t\t}\n\t\tif (liesOn(p3, r3, all[i])) {\n\t\t\t//cout << \"on p3\" << endl;\n\t\t\tedges++;\n\t\t}\n\t}\n\t//cout << \"vertices = \" << all.size() << endl;\n\t//cout << \"edges = \" << edges << endl;\n\tint res = 2 + edges - all.size();\n\tcout << res << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8c7de33d22ab89f3cc00002a1d60aa70", "src_uid": "bda5879e94a82c6fd499796f258c4691", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nstruct ptt {\n\tdouble x,y;\n};\n\ndouble length(ptt p) {\n\t//cout <<\"p.x = \" << p.x << \" p.y = \" << p.y <<\" len = \"<< sqrt(p.x*p.x + p.y*p.y) << endl;\n\treturn sqrt(p.x*p.x + p.y*p.y);\n}\n\ndouble dist(ptt p1, ptt p2) {\n\tptt p;\n\tp.x = p1.x - p2.x;\n\tp.y = p1.y - p2.y;\n\treturn length(p);\n}\n\nvector circleIntersection(ptt c1, double r1, ptt c2, double r2) {\n\tdouble d = dist(c1,c2);\n\tvector v;\n\tv.resize(0);\n\tif (d < abs(r1 - r2) || d > abs(r1 + r2)) return v;\n\tdouble a = (r1 * r1 - r2 * r2 + d * d) / (2 * d);\n\tptt p;\n\tp.x = (c2.x - c1.x)/d; \n\tp.y = (c2.y - c1.y)/d;\n\tif (d == abs(r1 - r2) || d == abs(r1 + r2)) \n\t{\n\t\tptt ppp;\n\t\tppp.x = c1.x + p.x*a;\n\t\tppp.y = c1.y + p.y*a;\n\t\tvector v;\n\t\tv.resize(0);\n\t\tv.push_back(ppp);\n\t\treturn v;\n\t}\n\tdouble h = sqrt(r1 * r1 - a * a);\n\tptt p1;\n\tptt p2;\n\tp1.x = c1.x + p.x*a + p.y*h;\n\tp1.y = c1.y + p.y*a - p.x*h;\n\tp2.x = c1.x + p.x*a - p.y*h;\n\tp2.y = c1.y + p.y*a + p.x*h;\n\tv.push_back(p1);\n\tv.push_back(p2);\n\treturn v;\n}\n\nbool doCross(int x1, int y1, int r1, int x2, int y2, int r2) {\n\tif ((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) < (r1+r2)*(r1+r2)) {\n\t\treturn true;\n\t} \n\treturn false;\n}\n\nbool liesOn(ptt c, double r, ptt p) {\n\tif (dist(c, p) - r > -0.00000001 && dist(c, p) - r < 0.00000001) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nint main() {\n\tint n;\n\tcin >> n;\n\tif (n == 1) {\n\t\tint x, y,r;\n\t\tcin >> x >> y >> r;\n\t\tcout << 1 << endl;\n\t\treturn 0;\n\t}\n\tif (n == 2) {\n\t\tint x1,x2,y1,y2,r1,r2;\n\t\tcin >> x1 >> y1 >> r1;\n\t\tcin >> x2 >> y2 >> r2;\n\t\tif (doCross(x1,y1,r1,x2,y2,r2)) {\n\t\t\tcout << 4 << endl;\n\t\t} else {\n\t\t\tcout << 3 << endl;\n\t\t}\n\t\treturn 0;\n\t}\n\tint x1,x2,x3,y1,y2,y3,r1,r2,r3;\n\tcin >> x1 >> y1 >> r1;\n\tcin >> x2 >> y2 >> r2;\n\tcin >> x3 >> y3 >> r3;\n\t\n\tif (!doCross(x1,y1,r1,x2,y2,r2) && !doCross(x1,y1,r1,x3,y3,r3)) {\n\t\tif (doCross(x3,y3,r3,x2,y2,r2)) {\n\t\t\tcout << 5 << endl;\n\t\t} else {\n\t\t\tcout << 4 << endl;\n\t\t}\n\t\treturn 0;\n\t}\n\tif (!doCross(x3,y3,r3,x2,y2,r2) && !doCross(x1,y1,r1,x3,y3,r3)) {\n\t\tif (doCross(x1,y1,r1,x2,y2,r2)) {\n\t\t\tcout << 5 << endl;\n\t\t} else {\n\t\t\tcout << 4 << endl;\n\t\t}\n\t\treturn 0;\n\t}\n\tif (!doCross(x1,y1,r1,x2,y2,r2) && !doCross(x2,y2,r2,x3,y3,r3)) {\n\t\tif (doCross(x3,y3,r3,x1,y1,r1)) {\n\t\t\tcout << 5 << endl;\n\t\t} else {\n\t\t\tcout << 4 << endl;\n\t\t}\n\t\treturn 0;\n\t}\n\tvector vec;\n\tvector temp;\n\tdouble xx1 = (double)x1;\n\tdouble xx2 = (double)x2;\n\tdouble xx3 = (double)x3;\n\tdouble yy1 = (double)y1;\n\tdouble yy2 = (double)y2;\n\tdouble yy3 = (double)y3;\n\tdouble rr1 = (double)r1;\n\tdouble rr2 = (double)r2;\n\tdouble rr3 = (double)r3;\n\tptt p1, p2, p3;\n\tp1.x = xx1;\n\tp1.y = yy1;\n\tp2.x = xx2;\n\tp2.y = yy2;\n\tp3.x = xx3;\n\tp3.y = yy3;\n\ttemp = circleIntersection(p1, rr1, p2, rr2);\n\tvec.insert(vec.end(), temp.begin(), temp.end());\n\ttemp = circleIntersection(p3, rr3, p2, rr2);\n\tvec.insert(vec.end(), temp.begin(), temp.end());\n\ttemp = circleIntersection(p3, rr3, p1, rr1);\n\tvec.insert(vec.end(), temp.begin(), temp.end());\n\t//cout << \"vec.size() \" << vec.size() << endl;\n\tvector all;\n\tall.resize(0);\n\tfor (int i = 0; i < vec.size(); i++) {\n\t\tbool found = false;\n\t\t//cout << \"point x = \" << vec[i].x << \" y = \" << vec[i].y << endl;\n\t\tfor (int j = i + 1; j < vec.size(); j++) {\n\t\t\tif (dist(vec[i], vec[j]) < 0.000000000000000001) {\n\t\t\t\t//cout << \"i = \" << i << \"j = \" << j << endl;\n\t\t\t\tfound = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!found) {\n\t\t\tall.push_back(vec[i]);\n\t\t}\n\t}\n\tint edges = 0;\n\tfor (int i = 0; i < all.size(); i++) {\n\t\tif (liesOn(p1, r1, all[i])) {\n\t\t\t//cout << \"on p1\" << endl;\n\t\t\tedges++;\n\t\t}\n\t\tif (liesOn(p2, r2, all[i])) {\n\t\t\t//cout << \"on p2\" << endl;\n\t\t\tedges++;\n\t\t}\n\t\tif (liesOn(p3, r3, all[i])) {\n\t\t\t//cout << \"on p3\" << endl;\n\t\t\tedges++;\n\t\t}\n\t}\n\t//cout << \"vertices = \" << all.size() << endl;\n\t//cout << \"edges = \" << edges << endl;\n\tint res = 2 + edges - all.size();\n\tcout << res << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c18ebe517d666d62bbd50df6f86df39e", "src_uid": "bda5879e94a82c6fd499796f258c4691", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long llu;\ntypedef double lf;\ntypedef unsigned int uint;\ntypedef long double llf;\ntypedef pair pii;\ntypedef pair pli;\n \n#define debug(format, ...) printf(format, __VA_ARGS__);\n\nconst ll MOD = (ll)1e9 + 7;\n\nclass modint {\n int v;\npublic:\n modint (): v(0) { }\n modint (ll v): v((v + MOD) % MOD) { }\n\n bool operator== (modint x) { return v == x.v; }\n bool operator!= (modint x) { return v != x.v; }\n\n modint operator+ (modint x) { return v + x.v; }\n modint operator- (modint x) { return v - x.v; }\n modint operator* (modint x) { return (ll)v * x.v; }\n modint operator/ (modint x) { return *this * x.inv(); }\n\n modint& operator+= (const modint x) { return *this = (*this + x); }\n modint& operator-= (const modint x) { return *this = (*this - x); }\n modint& operator*= (const modint x) { return *this = (*this * x); }\n modint& operator/= (const modint x) { return *this = (*this / x); }\n\n int operator* () { return v; }\n\n modint inv() {\n modint ret = 1, cur = v;\n int p = MOD - 2;\n while(p > 0) {\n if(p & 1) ret = ret * cur;\n cur = cur * cur;\n p >>= 1;\n }\n return ret;\n }\n};\n\n// C++ routines for computational geometry.\n\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ndouble INF = 1e100;\ndouble EPS = 1e-12;\n\nstruct PT { \n double x, y; \n PT() {}\n PT(double x, double y) : x(x), y(y) {}\n PT(const PT &p) : x(p.x), y(p.y) {}\n PT operator + (const PT &p) const { return PT(x+p.x, y+p.y); }\n PT operator - (const PT &p) const { return PT(x-p.x, y-p.y); }\n PT operator * (double c) const { return PT(x*c, y*c ); }\n PT operator / (double c) const { return PT(x/c, y/c ); }\n double norm() { return sqrt(x*x + y*y); }\n};\n\ndouble dot(PT p, PT q) { return p.x*q.x+p.y*q.y; }\ndouble dist2(PT p, PT q) { return dot(p-q,p-q); }\ndouble cross(PT p, PT q) { return p.x*q.y-p.y*q.x; }\nostream &operator<<(ostream &os, const PT &p) {\n os << \"(\" << p.x << \",\" << p.y << \")\"; \n}\n\n// rotate a point CCW or CW around the origin\nPT RotateCCW90(PT p) { return PT(-p.y,p.x); }\nPT RotateCW90(PT p) { return PT(p.y,-p.x); }\nPT RotateCCW(PT p, double t) { \n return PT(p.x*cos(t)-p.y*sin(t), p.x*sin(t)+p.y*cos(t)); \n}\n\n// project point c onto line through a and b\n// assuming a != b\nPT ProjectPointLine(PT a, PT b, PT c) {\n return a + (b-a)*dot(c-a, b-a)/dot(b-a, b-a);\n}\n\n// project point c onto line segment through a and b\nPT ProjectPointSegment(PT a, PT b, PT c) {\n double r = dot(b-a,b-a);\n if (fabs(r) < EPS) return a;\n r = dot(c-a, b-a)/r;\n if (r < 0) return a;\n if (r > 1) return b;\n return a + (b-a)*r;\n}\n\n// compute distance from c to segment between a and b\ndouble DistancePointSegment(PT a, PT b, PT c) {\n return sqrt(dist2(c, ProjectPointSegment(a, b, c)));\n}\n\n// compute distance between point (x,y,z) and plane ax+by+cz=d\ndouble DistancePointPlane(double x, double y, double z,\n double a, double b, double c, double d)\n{\n return fabs(a*x+b*y+c*z-d)/sqrt(a*a+b*b+c*c);\n}\n\n// determine if lines from a to b and c to d are parallel or collinear\nbool LinesParallel(PT a, PT b, PT c, PT d) { \n return fabs(cross(b-a, c-d)) < EPS; \n}\n\nbool LinesCollinear(PT a, PT b, PT c, PT d) { \n return LinesParallel(a, b, c, d)\n && fabs(cross(a-b, a-c)) < EPS\n && fabs(cross(c-d, c-a)) < EPS; \n}\n\n// determine if line segment from a to b intersects with \n// line segment from c to d\nbool SegmentsIntersect(PT a, PT b, PT c, PT d) {\n if (LinesCollinear(a, b, c, d)) {\n if (dist2(a, c) < EPS || dist2(a, d) < EPS ||\n dist2(b, c) < EPS || dist2(b, d) < EPS) return true;\n if (dot(c-a, c-b) > 0 && dot(d-a, d-b) > 0 && dot(c-b, d-b) > 0)\n return false;\n return true;\n }\n if (cross(d-a, b-a) * cross(c-a, b-a) > 0) return false;\n if (cross(a-c, d-c) * cross(b-c, d-c) > 0) return false;\n return true;\n}\n\n// compute intersection of line passing through a and b\n// with line passing through c and d, assuming that unique\n// intersection exists; for segment intersection, check if\n// segments intersect first\nPT ComputeLineIntersection(PT a, PT b, PT c, PT d) {\n b=b-a; d=c-d; c=c-a;\n assert(dot(b, b) > EPS && dot(d, d) > EPS);\n return a + b*cross(c, d)/cross(b, d);\n}\n\n// compute center of circle given three points\nPT ComputeCircleCenter(PT a, PT b, PT c) {\n b=(a+b)/2;\n c=(a+c)/2;\n return ComputeLineIntersection(b, b+RotateCW90(a-b), c, c+RotateCW90(a-c));\n}\n\n// determine if point is in a possibly non-convex polygon (by William\n// Randolph Franklin); returns 1 for strictly interior points, 0 for\n// strictly exterior points, and 0 or 1 for the remaining points.\n// Note that it is possible to convert this into an *exact* test using\n// integer arithmetic by taking care of the division appropriately\n// (making sure to deal with signs properly) and then by writing exact\n// tests for checking point on polygon boundary\nbool PointInPolygon(const vector &p, PT q) {\n bool c = 0;\n for (int i = 0; i < p.size(); i++){\n int j = (i+1)%p.size();\n if ((p[i].y <= q.y && q.y < p[j].y || \n p[j].y <= q.y && q.y < p[i].y) &&\n q.x < p[i].x + (p[j].x - p[i].x) * (q.y - p[i].y) / (p[j].y - p[i].y))\n c = !c;\n }\n return c;\n}\n\n// determine if point is on the boundary of a polygon\nbool PointOnPolygon(const vector &p, PT q) {\n for (int i = 0; i < p.size(); i++)\n if (dist2(ProjectPointSegment(p[i], p[(i+1)%p.size()], q), q) < EPS)\n return true;\n return false;\n}\n\n// compute intersection of line through points a and b with\n// circle centered at c with radius r > 0\nvector CircleLineIntersection(PT a, PT b, PT c, double r) {\n vector ret;\n b = b-a;\n a = a-c;\n double A = dot(b, b);\n double B = dot(a, b);\n double C = dot(a, a) - r*r;\n double D = B*B - A*C;\n if (D < -EPS) return ret;\n ret.push_back(c+a+b*(-B+sqrt(D+EPS))/A);\n if (D > EPS)\n ret.push_back(c+a+b*(-B-sqrt(D))/A);\n return ret;\n}\n\n// compute intersection of circle centered at a with radius r\n// with circle centered at b with radius R\nvector CircleCircleIntersection(PT a, PT b, double r, double R) {\n vector ret;\n double d = sqrt(dist2(a, b));\n if (d > r+R || d+min(r, R) < max(r, R)) return ret;\n double x = (d*d-R*R+r*r)/(2*d);\n double y = sqrt(r*r-x*x);\n PT v = (b-a)/d;\n ret.push_back(a+v*x + RotateCCW90(v)*y);\n if (y > 0)\n ret.push_back(a+v*x - RotateCCW90(v)*y);\n return ret;\n}\n\n// This code computes the area or centroid of a (possibly nonconvex)\n// polygon, assuming that the coordinates are listed in a clockwise or\n// counterclockwise fashion. Note that the centroid is often known as\n// the \"center of gravity\" or \"center of mass\".\ndouble ComputeSignedArea(const vector &p) {\n double area = 0;\n for(int i = 0; i < p.size(); i++) {\n int j = (i+1) % p.size();\n area += p[i].x*p[j].y - p[j].x*p[i].y;\n }\n return area / 2.0;\n}\n\ndouble ComputeArea(const vector &p) {\n return fabs(ComputeSignedArea(p));\n}\n\nPT ComputeCentroid(const vector &p) {\n PT c(0,0);\n double scale = 6.0 * ComputeSignedArea(p);\n for (int i = 0; i < p.size(); i++){\n int j = (i+1) % p.size();\n c = c + (p[i]+p[j])*(p[i].x*p[j].y - p[j].x*p[i].y);\n }\n return c / scale;\n}\n\n// tests whether or not a given polygon (in CW or CCW order) is simple\nbool IsSimple(const vector &p) {\n for (int i = 0; i < p.size(); i++) {\n for (int k = i+1; k < p.size(); k++) {\n int j = (i+1) % p.size();\n int l = (k+1) % p.size();\n if (i == l || j == k) continue;\n if (SegmentsIntersect(p[i], p[j], p[k], p[l])) \n return false;\n }\n }\n return true;\n}\n\n\nint N;\nvector< PT > vec;\nPT P[3]; int R[3];\n\ndouble sq(double x) { return x*x; }\nset ans;\n\nint main() {\n#ifdef IN_MY_COMPUTER\n freopen(\"c.in\", \"r\", stdin);\n#endif\n\n scanf(\"%d\", &N);\n for(int i = 0; i < N; i++) {\n int x, y, r; scanf(\"%d%d%d\", &x, &y, &r);\n vec.emplace_back(x, y);\n P[i] = PT(x, y); R[i] = r;\n }\n\n vec.emplace_back(-100, -100);\n for(int i = 0; i < N; i++) {\n for(int j = i+1; j < N; j++) {\n vector cur = CircleCircleIntersection(P[i], P[j], R[i], R[j]);\n for(PT p : cur) vec.push_back(p);\n }\n }\n\n const int MAXREP = 200000;\n for(PT p : vec) {\n for(int rep = 0; rep < MAXREP; rep++) {\n PT d(1e-3 * cos((double)rep / MAXREP * M_PI), 1e-3 * sin((double)rep / MAXREP * M_PI));\n PT q = p + d;\n int mask = 0;\n for(int i = 0; i < N; i++) {\n if((q - P[i]).norm() < R[i] && abs((q - P[i]).norm() - R[i]) > 1e-9) {\n mask |= 1<\nusing namespace std;\ntypedef __int64 LL;\ntypedef long double Ldb;\nconst int maxn = 10;\nconst Ldb eps = 1e-12;\nint n;\nstruct Point\n{\n Ldb x,y;\n Point() {}\n Point(Ldb _x,Ldb _y):x(_x),y(_y) {}\n Point operator + (const Point &t)const\n {\n return Point(x+t.x,y+t.y);\n }\n Point operator - (const Point &t)const\n {\n return Point(x-t.x,y-t.y);\n }\n Point operator * (const Ldb &t)const\n {\n return Point(x*t,y*t);\n }\n Point operator / (const Ldb &t)const\n {\n return Point(x/t,y/t);\n }\n bool operator < (const Point &t)const\n {\n return fabs(x-t.x) < eps ? y operator & (const Circle &c1,const Circle &c2)\n {\n Ldb d=(c1.o-c2.o).len();\n if(d>c1.r+c2.r+eps || d();\n Ldb dt=(c1.r*c1.r-c2.r*c2.r)/d,d1=(d+dt)/2;\n Point dir=(c2.o-c1.o)/d,pcrs=c1.o+dir*d1;\n dt=sqrt(max(0.0L,c1.r*c1.r-d1*d1)),dir=dir.rot90();\n return vector {pcrs+dir*dt,pcrs-dir*dt};\n }\n} p[maxn];\nbool vis[maxn];\nint fa[maxn],rk[maxn];\nvoid init()\n{\n for(int i=1; irk[y])\n fa[y] = x;\n else\n {\n fa[x] = y;\n if(rk[x]==rk[y])\n rk[y]++;\n }\n}\n\nint main()\n{\n init();\n cin>>n;\n for(int i=1; i<=n; i++)\n cin>>p[i].o.x>>p[i].o.y>>p[i].r;\n int e = 0,v = 0;\n vector all;\n for(int i=1; i<=n; i++)\n {\n vector tmp1;\n for(int j=1; j<=n; j++)\n {\n if(i==j)\n continue;\n vector tmp2 = p[i] & p[j];\n if(tmp2.size())\n union_set(i,j);\n tmp1.insert(tmp1.end(),tmp2.begin(),tmp2.end());\n all.insert(all.end(),tmp2.begin(),tmp2.end());\n }\n sort(tmp1.begin(),tmp1.end());\n e += unique(tmp1.begin(),tmp1.end()) - tmp1.begin();\n }\n sort(all.begin(),all.end());\n v = unique(all.begin(),all.end()) - all.begin();\n set c;\n for(int i=1; i<=n; i++)\n c.insert(find_set(i));\n cout<\nusing namespace std;\ntypedef long long LL;\nconst int N = 100010;\nconst int M = 1600;\nconst int P = 1e9+7;\nint fac[N],inv[N];\n\nint Pow(int a,int b){\n\tif(b==0) return 1;\n\tint ret = Pow(a,b/2);\n\tret=1LL*ret*ret%P;\n\tif(b&1) ret=1LL*ret*a%P;\n\treturn ret;\n}\nint com(int n,int m){\n\tif(m>n) return 0;\n\treturn 1LL*fac[n]*inv[m]%P*inv[n-m]%P;\n}\n\nint p[N],n,m,a,b,k,tmp1,tmp2;\nint f[2][M],tmp[2][M],sum[N],g[2][M];\n\n#define rep(i,m) for(int i = 0;i<(int)m;i++)\nvoid add(int &x,int y){\n\tx=(x+y)%P;\n}\nint Pro(int n){\n\t// k -> n\n\tif \uff08n-k>0) return 0;\n\treturn 1LL*com(k,n)*Pow(tmp1,n)%P*Pow(tmp2,k-n)%P;\n}\n\nint main(){\n\tfac[0]=1;\n\tfor(int i=1;i=1;i--){\n\t\tfor(int j=i;j>=1;j--) add(f[1][i],Pro(j-1));\n\t\tf[1][i]=1LL*f[1][i]*Pro(m-i)%P;\n\t}\n\t\n\tfor(int j=2;j<=n;j++){\n\t\tmemcpy(tmp,f,sizeof(tmp));\n\t\tmemset(f,0,sizeof(f));\n\t\tmemset(g,0,sizeof(g));\n\t\t// do f[0][1]\n\t\tint tmp3 = 0,tot = 0;\n\t\tfor(int i=1;i<=m;i++) add(tot,tmp[0][i]);\n\t\tfor(int i=1;i<=m;i++) g[1][i]=(g[1][i-1]+tmp[1][i])%P;\n\t\tfor(int i=m;i>=1;i--) g[0][i]=(g[0][i+1]+tmp[0][i])%P;\n\t\t//cout<=1;i--){\n\t\t\tadd(tmp3,tmp[1][i]);\n\t\t\tadd(f[1][m],1LL*tmp3*Pro(i-1)%P);\n\t\t}\n\t\tfor(int i=m-1;i>=1;i--){\n\t\t\tadd(f[1][i],f[1][i+1]);\n\t\t\tadd(f[1][i],-1LL*tmp[0][i+1]*(sum[i-1])%P);\n\t\t\tadd(f[1][i],-1LL*(1LL*tot-g[0][i+2]-g[1][i])%P*Pro(i)%P);\n\t\t}\n\t\tfor(int i=1;i<=m;i++) f[1][i]=1LL*f[1][i]%Pro(m-i)%P;\n\t}\n\n\tint ans=0;\n\tfor(int i=1;i<=m;i++) add(ans,f[0][i]);\n\tans=(ans%P+P)%P;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ef9187440487bf778989603dc649f210", "src_uid": "33b6b0d3a6af273f22b703491bd17289", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint n,m,K;\n\nlong long MOD=1000000008;\nlong long p,np;\nlong long sum[1510][1510],ans[1510][1510];\nlong long fac[101000],invf[10100],tmp_sum[2010];\n\n\nlong long pow(long long a,int b){\n\tlong long r=1;\n\twhile(r){\n\t\tif(b&1)\n\t\t\tr*=a%MOD;\n\t\ta*=a%MOD;\n\t\tb>>=1;\n\t}\n\treturn r;\n}\n\n\nlong long comb(int a,int b){\n\treturn fac[a]*invf[b]%MOD*invf[a-b]%MOD;\n}\n\n\nint main(){\n\tint A,B,i,j;\n\tscanf(\"%d%d\",&n,&m);\n\tscanf(\"%d%d\",&A,&B);\n\tscanf(\"%d\",&K);\n\t\n\tfac[0]=invf[0]=1;\n\tfor(i=1;i<=K;i++){\n\t\tfac[i]=fac[i-1]*i%MOD;\n\t\tinvf[i]=pow(fac[i],MOD-2);\n\t}\n\t\n\tp=A*pow(B,MOD-2)%MOD;\n\tnp=(B-A)*pow(B,MOD-2)%MOD;\n\tsum[0][m]=1;\n\t\n\tfor(i=0;i<=m;i++){\n\t\tif(i>K)\n\t\t\ttmp_sum[i]=0;\n\t\telse \n\t\t\ttmp_sum[i]=pow(p,i)*pow(np,K-i)%MOD*comb(K,i)%MOD;\n\t} \n\t\n\tfor(i=0;i<=n;i++){\n\t\tfor(j=1;j<=m;j++)\n\t\t\tans[i][j]=(s[i][j-1]+sum[i][j])%MOD;\n\t\tif(i=n)\n\t\t\tbreak;\n\t\t\n\t\tlong long _s1=0,_s2=0;\n\t\tfor(j=1;j<=m;j++){\n\t\t\t_s1=(_s1+tmp_sum[j-1])%MOD;\n\t\t\t_s2=(_s2+tmp_sum[j-1]*ans[i][j-1])%MOD;\n\t\t\tsum[i+1][j]=((ans[i][m]-ans[i][m-j])%MOD*_s1-_s2+MOD)%MOD*tmp_sum[m-j]%MOD;\n\t\t}\n\t}\n\t\n\tprintf(\"%lld\\n\",ans[n][m]);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "89f2b6d0a45475498560c8a25a1a11da", "src_uid": "33b6b0d3a6af273f22b703491bd17289", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include\n#include\nusing namespace std;\nconst int N=1502,K=1000002,M=1000000007;\ntypedef long long ll;\nint n,m,t,i;\nll p[N],a,b,fac[K],inv[K],sp[N];\nll f[N],g[N],F[N],G[N],sf[N],sg[N];\nll ksm(ll x,int b){\n ll s=1;\n while(b){\n if(b&1)\n s=s*x%M;\n b>>=1;\n x=x*x%M;\n }\n return s;\n}\nvoid init(){\n scanf(\"%d%d%lld%lld%d\",&n,&m,&a,&b,&t);\n a=a*ksm(b,M-2)%M;\n fac[0]=1;\n for(i=1;i<=t;i++)\n fac[i]=fac[i-1]*i%M;\n inv[0]=inv[1]=1;\n for(i=2;i<=t;i++)\n inv[i]=inv[M%i]*(M-M/i)%M;\n for(i=1;i<=t;i++)\n inv[i]=inv[i]*inv[i-1]%M;\n}\nll C(int n,int m){\n return fac[n]*inv[m]%M*inv[n-m]%M;\n}\nvoid work(){\n for(i=0;i<=m;i++){\n if(t>=i)\n p[i]=C(t,i)*ksm(a,i)%M*ksm(1-a,t-i)%M;\n sp[i]=(p[i]+(i>0?sp[i-1]:0))%M;\n }\n f[m]=1;g[1]=1;\n while(n--){\n memset(F,0,sizeof(F));\n memset(G,0,sizeof(G));\n memset(sf,0,sizeof(sf));\n memset(sg,0,sizeof(sg));\n for(i=1;i<=m;i++)\n sf[i]=(sf[i-1]+f[i]*p[i])%M;\n for(i=m;i;i--)\n sg[i]=(sg[i+1]+g[i]*p[m-i+1])%M;\n for(i=1;i<=m;i++){\n F[i]=(p[m-i]*(f[m]*sp[i-1]%M-g[i+1]*sp[i-1]%M-sf[i-1])%M+F[i-1]+M)%M;\n }\n for(i=m;i;i--)\n G[i]=(p[i-1]*(g[1]*sp[m-i]%M-f[i-1]*sp[m-i]%M-sg[i+1])%M+G[i+1]+M)%M;\n memcpy(f,F,sizeof(f));\n memcpy(g,G,sizeof(g));\n\n }\n printf(\"%lld\\n\",f[m]);\n}\nint main(){\n init();\n work();\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1cb8e88217d3ea6ce7fe0a9cb74f3c68", "src_uid": "33b6b0d3a6af273f22b703491bd17289", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n\n\nconst int MOD=(int)1e9+7;\n\n\n\nvoid update(int &x, int a){\n x+=a;\n if (x>=MOD) x-=MOD;\n}\n\n\nint power(int a, int n){\n int result=1;\n \n \n while(n){\n if(n&1) result=1LL*result*a%MOD;\n a=1LL*a*a%MOD;\n n>>=1;\n }\n return result;\n}\n\n\nstd::vector partial_sum(int n, std::function f){\n std::vector s(n + 1);\n for (int i = 0; i < n; ++ i) \n s[i + 1] = (s[i] + f(i)) % MOD;\n \n return s;\n}\n\n\nint main(){\n int n,m,a,b,l;\n scanf(\"%d%d%d%d%d\",&n,&m,&a,&b,&l);\n int p=static_cast(a)*power(b,MOD-2)%MOD;\n \n \n std::vector fact(l+1);\n fact[0]=1;\n for(int i=1;i<=l;i++) fact[i=1LL*fact[i-1]*i%MOD;\n \n \n std::vector prob(m);\n for (int i=0; i\r\n#include \r\n#include \r\nusing namespace __gnu_pbds; \r\nusing namespace std;\r\n#if DEBUG && !ONLINE_JUDGE\r\n#include \"debug.cpp\"\r\n#else \r\n#define debug(args...) \r\n#define test\r\n#define print(a,n,k)\r\n#endif\r\n// const int mod = 1000000007;\r\nconst int mod = 998244353;\r\n#define int long long\r\n#define TIME (chrono::steady_clock::now().time_since_epoch().count())\r\n#define ull unsigned long long\r\n#define ok order_of_key\r\n#define fo find_by_order\r\n#define ordered_set tree, rb_tree_tag,tree_order_statistics_node_update> \r\n#define ll long long\r\n#define rep(i,a,b) for(int i=(a);i<(b);i++)\r\n#define repp(i,n) for(int i=(0);i<(n);i++)\r\n#define repr(i,n) for(int i=(n);i>=0;i--)\r\n#define repl(i,a,b) for(ll i=(a);i<(b);i++)\r\n#define newl cout<<'\\n'\r\n#define inf 1000000000\r\n#define repaa(i,a) for(auto i=a.rbegin();i!=a.rend();++i)\r\n#define pb push_back \r\n#define tc int tt;cin>>tt;while(tt--)\r\n#define mem(v,i) memset(v,i,sizeof(v))\r\n#define all(x) x.begin(), x.end()\r\n#define inf1 1e18\r\n#define repa(i,a) for (auto i : a)\r\n#define X first\r\n#define Y second\r\n#define lb lower_bound\r\n#define ub upper_bound\r\n#define gcd(a,b) __gcd((a),(b))\r\n#define lcm(a,b) ((a)*(b)) / gcd((a),(b))\r\n#define in(a,n) repp(jjj,n)cin>>a[jjj];\r\n#define intree(a,m) repp(i,m){int tmp1,tmp2;cin>>tmp1>>tmp2;tmp1--,tmp2--;a[tmp1].eb(tmp2);a[tmp2].eb(tmp1);}\r\n#define ins insert\r\n#define er erase\r\n#define sz(a) (int)(a.size())\r\n#define mt make_tuple\r\n#define eb emplace_back\r\n#define bpl(i) __builtin_popcountll(i)\r\n#define bp(i) __builtin_popcount(i)\r\n#define precision(x) cout << fixed << setprecision(x);\r\n#define si set\r\n#define usi unordered_set\r\n#define sl set < ll >\r\n#define usl unordered_set < ll >\r\n#define sip set < ip >\r\n#define sil set < il > \r\n#define mi map\r\n#define umi unordered_map\r\n#define ml map < ll , ll>\r\n#define uml unordered_map < ll , ll>\r\n#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())\r\n#define srt(v) sort(all(v))\r\n#define rsrt(v) sort(v.rbegin(), v.rend())\r\n#define ld long double\r\n#define vi vector \r\n#define vl vector\r\n#define vii vector < vi >\r\n#define vip vector>\r\n#define vil vector>\r\n#define vll vector < vl >\r\n#define ip pair\r\n#define il pair\r\nconst int dx[4]={1,0,0,-1}, dy[4]={0,1,-1,0};\r\nconst int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};\r\nconst int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};\r\nconst char nl = '\\n',sp = ' ';\r\n#ifdef Fading\r\n#define gc getchar\r\n#endif\r\n#ifndef Fading\r\ninline char gc(){static char now[1<<16],*S,*T;if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}return *S++;}\r\n#endif\r\nll R(ll B) {static mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());return (unsigned long long)rng() % B;}\r\ninline ll read(){register ll x=0,f=1;char ch=gc();while (!isdigit(ch)){if(ch=='-')f=-1;ch=gc();}while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}return (f==1)?x:-x;}\r\null mix(ull o){o+=0x9e3779b97f4a7c15;o=(o^(o>>30))*0xbf58476d1ce4e5b9;o=(o^(o>>27))*0x94d049bb133111eb;return o^(o>>31);}\r\ntemplateT Min(T v) {return v;}templateT Min(T first, Args... args) {return min(first , Min(args...));}\r\ntemplateT Max(T v) {return v;}template T Max(T first, Args... args) {return max(first , Max(args...));}\r\ntemplate T mult(T v) {return v;}templateT mult(T first, Args... args) {return mult((first%mod * mult(args...))%mod);}\r\ntemplate inline bool remax(T &a, U b) {return a inline bool remin(T &a, U b) { return a > b ? a = b, 1 : 0; }\r\ntemplate void add(A &a, B b){a += b;if(a >= mod) a -= mod;if(a < 0) a += mod;}template ll addr(A a, B b){a += b;if(a >= mod) a -= mod;if(a < 0) a += mod;return a;}\r\ntemplateT2 min(T1 a,T2 b){return min((T2)a,b);}templateT2 max(T1 a,T2 b){return max((T2)a,b);}\r\nvoid pnt(char a){if(a == nl || a == sp) cout << a;else cout << a << sp;}void pnt(string &a,int b = 0){cout << a << nl;}\r\ntemplate void pnt(A &a,int b=0) {cout << A(a + b) << sp;}template void pnt(pair&a,int b=0){cout << A(a.X+b) << ' ' << B(a.Y+b) << nl;}\r\ntemplate void pnt(vector&a,int b=0) {repa(i,a) pnt(i,b);}template void pnt(set&a,int b=0) {repa(i,a) pnt(i,b);}\r\ntemplate void pnt(unordered_set&a,int b=0) {repa(i,a) pnt(i,b) ;}\r\ntemplateinline istream& operator>>(istream&i,pair&v){return i>>v.X>>v.Y;}\r\ntemplatestruct isChar{bool ch(T a){return false;}};template<>struct isChar{int ch(char s){return s == '`';}};\r\ntemplatevoid W(T v){pnt(v);}templatevoid W(T f,A s) {if(isChar().ch(s)) pnt(f,1);else pnt(f) ,W(s);}\r\ntemplatevoid W(T f,A s,Args... args) {if(isChar().ch(s)) pnt(f,1), W(args...);else pnt(f),W(s,args...);}\r\ntemplate void kill(T1 ans){pnt(ans);exit(0);}\r\nll nc2(ll a){return a * (a - 1) / 2;}int mylog(ll x , ll y = 2){if(x == 0) return -1;return mylog(x/y,y) + 1;}\r\nll setbit(ll n, ll kk){return 1LL*(n|(1LL< 0);}\r\nll poww(ll a, ll b,ll m = mod){ll val = 1;a %= m;while (b > 0){if (b & 1) val = (a * val) % m;a = (a * a) % m;b >>= 1;}return val;}\r\nll inv(ll a,ll m=mod){return poww(a , m - 2);}ll gcdll(ll x, ll y){return y == 0 ? x : gcdll(y, x % y);}\r\n\r\n//-------------------------------------------------LEZENDARY------------------------------------------------------------//\r\n//------------------------------------------------------SANDWICH-------------------------------------------------------//\r\n#pragma endregion\r\n\r\nconst int N = 402, I = N - 1;\r\nint dp[N][N][N][3][3], a[26], n;\r\n\r\nint solve(int a, int b, int c, int d, int e, bool fl = 0){\r\n if(a == -1 || b == -1) return 0;\r\n if(!fl && c - a < 0) return 0;\r\n if(c - a - b < 0 && fl) return 0;\r\n if(c == 0) return 1;\r\n int &ans = dp[a][b][c][d][e];\r\n if(ans != -1) return ans;\r\n ans = 0;\r\n ans = mult(24, solve(a, b, c - 1, 0, d));\r\n add(ans, solve(a - 1, b, c - 1, 1, d));\r\n add(ans, solve(a, b - 1, c - 1, 2, d));\r\n if(c >= n - 1) return ans;\r\n if(e == 0) add(ans, - solve(a, b, c - 1, 0, d));\r\n else if(e == 1) add(ans, - solve(a - 1, b, c - 1, 1, d));\r\n else add(ans, - solve(a, b - 1, c - 1, 2, d));\r\n return ans;\r\n}\r\n\r\nsigned main()\r\n{\r\n ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);\r\n cin >> n;\r\n in(a,26);\r\n int ans = mult(26, 26, poww(25, n - 2));\r\n mem(dp, -1);\r\n repp(i,26){\r\n rep(j,a[i] + 1, n / 2 + 2){\r\n add(ans, - solve(j, I, n, 0, 0));\r\n }\r\n }\r\n repp(i, 26){\r\n rep(j, i + 1, 26){\r\n rep(k1, a[i] + 1, n / 2 + 3){\r\n rep(k2, a[j] + 1, n / 2 + 10){\r\n if(k1 > n / 2 + 1 && solve(k1, k2, n, 0, 0, 1)) debug(k1, k2,solve(k1, k2, n, 0, 0, 1));\r\n add(ans, solve(k1, k2, n, 0, 0, 1));\r\n }\r\n }\r\n }\r\n }\r\n W(ans);\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ee243ba591a2a07c15c471ec2693d159", "src_uid": "1f012349f4b229dc98faadf1ca732355", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include\r\n#define rep(i,a,b) for(long long i=a;i<=b;i++)\r\n#define pre(i,a,b) for(long long i=a;i>=b;i--)\r\n#define N 405\r\n#define P 998244353\r\nusing namespace std;\r\nlong long n,c[26],f[2][205][205][3][3],g[N][N];\r\nsigned main(){\r\n\tscanf(\"%d\",&n);\r\n\trep(i,0,25)scanf(\"%d\",&c[i]);\r\n\trep(i,0,2)rep(j,0,2)f[0][(i==1)+(j==1)][(i==2)+(j==2)][i][j]=(i?1:24)*(j?1:24);\r\n\trep(i,3,n){\r\n\t\tlong long cur=i&1;\r\n\t\tmemset(f[cur],0,sizeof(f[cur]));\r\n\t\trep(u,0,n/2+1)rep(v,0,n/2+2)rep(x,0,2)rep(y,0,2)rep(z,0,2){\r\n\t\t\tif(x==z&&x)continue;\r\n\t\t\tif(x==z) {f[cur][u][v][y][z]=(f[cur][u][v][y][z]+1LL*f[cur^1][u][v][x][y]*23%P)%P;}\r\n\t\t\telse {f[cur][u+(z==1)][v+(z==2)][y][z]=(f[cur][u+(z==1)][v+(z==2)][y][z]+1LL*f[cur^1][u][v][x][y]*(z?1:24)%P)%P;}\r\n\t\t}\r\n\t}\r\n\tpre(i,n/2+1,0)pre(j,n/2+1,0){\r\n\t\tg[i][j]=(g[i+1][j]+g[i][j+1]-g[i+1][j+1])%P;\r\n\t\trep(x,0,2)rep(y,0,2)g[i][j]=(g[i][j]+f[n&1][i][j][x][y])%P;\r\n\t}\r\n\tlong long ans=g[0][0];\r\n\t//cout<\r\n#define mz 998244353\r\nusing namespace std;\r\n\r\nint a[30];\r\n\r\nlong long ans=0;\r\nlong long dp[405][205][205][11],dps[405][205][5],dpp[205][205],ddp[205];\r\n\r\nint main()\r\n{\r\n int n;\r\n scanf(\"%d\",&n);\r\n ans=26*26;\r\n for(int i=3;i<=n;i++)\r\n ans=(ans*25)%mz;\r\n for(int i=1;i<=26;i++)\r\n scanf(\"%d\",&a[i]);\r\n dp[2][2][0][1]=1;\r\n dp[2][1][1][2]=1;\r\n dp[2][1][0][3]=24;\r\n dp[2][1][1][4]=1;\r\n dp[2][0][2][5]=1;\r\n dp[2][0][1][6]=24;\r\n dp[2][1][0][7]=1;\r\n dp[2][0][1][8]=1;\r\n dp[2][0][0][9]=24*24;\r\n for(int i=2;i\r\n \r\n// #include \r\n \r\nusing namespace std;\r\n// using namespace atcoder;\r\n \r\n#define DEBUG(x) cerr<<#x<<\": \"<\r\n#define vl vector\r\n#define vii vector< vector >\r\n#define vll vector< vector >\r\n#define vs vector\r\n#define pii pair\r\n#define pis pair\r\n#define psi pair\r\n#define pll pair\r\ntemplate pair operator+(const pair &s, const pair &t) { return pair(s.first + t.first, s.second + t.second); }\r\ntemplate pair operator-(const pair &s, const pair &t) { return pair(s.first - t.first, s.second - t.second); }\r\ntemplate ostream& operator<<(ostream& os, pair p) { os << \"(\" << p.first << \", \" << p.second << \")\"; return os; }\r\n#define X first\r\n#define Y second\r\n#define rep(i,n) for(int i=0;i<(int)(n);i++)\r\n#define rep1(i,n) for(int i=1;i<=(int)(n);i++)\r\n#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)\r\n#define rrep1(i,n) for(int i=(int)(n);i>0;i--)\r\n#define REP(i,a,b) for(int i=a;i bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }\r\n#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());\r\nconst ll inf = 1000000001;\r\nconst ll INF = (ll)1e18 + 1;\r\nconst long double pi = 3.1415926535897932384626433832795028841971L;\r\nint popcount(ll t) { return __builtin_popcountll(t); }\r\n// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};\r\n// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };\r\nvi dx = {0, 1, 0, -1}, dy = {-1, 0, 1, 0};\r\n// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };\r\nstruct Setup_io {\r\n Setup_io() {\r\n ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\r\n cout << fixed << setprecision(25);\r\n }\r\n} setup_io;\r\n// const ll MOD = 1000000007;\r\nconst ll MOD = 998244353;\r\n// #define mp make_pair\r\n//#define endl '\\n'\r\n\r\nconst int MAXN = 555555;\r\n\r\nvl fact(MAXN);\r\nvl rfact(MAXN);\r\n\r\nll mod_pow(ll x, ll p, ll M = MOD) {\r\n if (p < 0) {\r\n x = mod_pow(x, M - 2, M);\r\n p = -p;\r\n }\r\n ll a = 1;\r\n while (p) {\r\n if (p % 2)\r\n a = a*x%M;\r\n x = x*x%M;\r\n p /= 2;\r\n }\r\n return a;\r\n}\r\n\r\nll mod_inverse(ll a, ll M = MOD) {\r\n return mod_pow(a, M - 2, M);\r\n}\r\n\r\nvoid set_fact(ll n, ll M = MOD) {\r\n fact[0] = 1;\r\n for (ll i = 1; i <= n; i++) {\r\n fact[i] = i * fact[i - 1] % M;\r\n }\r\n rfact[n] = mod_inverse(fact[n], M);\r\n for (ll i = n - 1; i >= 0; i--) {\r\n rfact[i] = (i + 1) * rfact[i + 1] % M;\r\n }\r\n}\r\n\r\n//http://drken1215.hatenablog.com/entry/2018/06/08/210000\r\nll nCr(ll n, ll r, ll M = MOD) {\r\n if (r > n) return 0;\r\n assert(fact[2] == 2);\r\n ll ret = fact[n];\r\n if (rfact[r] == 0) {\r\n rfact[r] = mod_inverse(fact[r], M);\r\n }\r\n ret = (ret*rfact[r]) % M;\r\n if (rfact[n - r] == 0) {\r\n rfact[n - r] = mod_inverse(fact[n - r], M);\r\n }\r\n ret = (ret*rfact[n - r]) % M;\r\n return ret;\r\n}\r\n\r\nll nHr(ll n, ll r) {\r\n return nCr(n+r-1, r);\r\n}\r\n\r\nll solve0(int n, vl c) {\r\n return 26LL * 26 * mod_pow(25, n - 2) % MOD;\r\n}\r\n\r\nint dp1[401][2][2][401];\r\nint sp1[401];\r\n\r\nll solve1(int n, vl c) {\r\n dp1[2][0][0][0] = 25 * 25;\r\n dp1[2][1][0][1] = 25;\r\n dp1[2][0][1][1] = 25;\r\n dp1[2][1][1][2] = 1;\r\n\r\n for (int i = 2; i < n; i++) {\r\n rep (j1, 2) rep (j2, 2) {\r\n rep (k, i + 1) {\r\n if (dp1[i][j1][j2][k] == 0) continue;\r\n\r\n rep (nj2, 2) {\r\n if (j1 == 1 and nj2 == 1) continue;\r\n ll mul = 1;\r\n if (nj2 == 0) {\r\n if (j1 == 0) mul = 24;\r\n else mul = 25;\r\n }\r\n int nk = k + nj2;\r\n (dp1[i + 1][j2][nj2][nk] += (ll)dp1[i][j1][j2][k] * mul % MOD) %= MOD;\r\n }\r\n }\r\n }\r\n }\r\n\r\n rep (i, n + 1) {\r\n rep (j1, 2) rep (j2, 2) {\r\n (sp1[i] += dp1[n][j1][j2][i]) %= MOD;\r\n }\r\n }\r\n\r\n ll res = 0;\r\n rep (i, 26) {\r\n int x = c[i];\r\n for (int j = x + 1; j <= n; j++) {\r\n res += sp1[j];\r\n }\r\n }\r\n return res % MOD;\r\n}\r\n\r\n\r\n\r\nint dp2[401][3][3][401][401];\r\nint sp2[401][401];\r\n\r\nll solve2(int n, vl c) {\r\n rep (i, 3) rep (j, 3) {\r\n int cnt = 0;\r\n if (i == 0) cnt++;\r\n if (j == 0) cnt++;\r\n int c1 = 0, c2 = 0;\r\n if (i == 1) c1++;\r\n if (i == 2) c2++;\r\n if (j == 1) c1++;\r\n if (j == 2) c2++;\r\n ll temp = mod_pow(24, cnt);\r\n dp2[2][i][j][c1][c2] = temp;\r\n }\r\n\r\n for (int i = 2; i < n; i++) {\r\n rep (j1, 3) rep (j2, 3) {\r\n rep (k1, i + 1) rep (k2, i + 1) {\r\n if (k1 + k2 > i) break;\r\n if (dp2[i][j1][j2][k1][k2] == 0) continue;\r\n\r\n rep (nj2, 3) {\r\n if (j1 == 1 and nj2 == 1) continue;\r\n if (j1 == 2 and nj2 == 2) continue;\r\n ll mul = 1;\r\n if (nj2 == 0) {\r\n if (j1 == 0) mul = 23;\r\n else mul = 24;\r\n }\r\n int nk1 = k1, nk2 = k2;\r\n if (nj2 == 1) nk1++;\r\n if (nj2 == 2) nk2++;\r\n\r\n (dp2[i + 1][j2][nj2][nk1][nk2] += (ll)dp2[i][j1][j2][k1][k2] * mul % MOD) %= MOD;\r\n }\r\n }\r\n }\r\n }\r\n\r\n rep (k1, n + 1) rep (k2, n + 1) {\r\n rep (j1, 3) rep (j2, 3) {\r\n (sp2[k1][k2] += dp2[n][j1][j2][k1][k2]) %= MOD;\r\n }\r\n }\r\n\r\n ll res = 0;\r\n rep (i, 26) {\r\n REP (j, i + 1, 26) {\r\n int x1 = c[i], x2 = c[j];\r\n for (int k1 = x1 + 1; k1 <= n; k1++) {\r\n for (int k2 = x2 + 1; k2 <= n; k2++) {\r\n res += sp2[k1][k2];\r\n }\r\n }\r\n }\r\n }\r\n return res % MOD;\r\n}\r\n\r\n\r\nsigned main() {\r\n int n;\r\n cin >> n;\r\n vl c(26);\r\n rep (i, 26) cin >> c[i];\r\n\r\n ll ans0 = solve0(n, c);\r\n DEBUG(ans0);\r\n ll ans1 = solve1(n, c);\r\n DEBUG(ans1);\r\n ll ans2 = solve2(n, c);\r\n DEBUG(ans2);\r\n\r\n ll ans = ans0 - ans1 + ans2;\r\n ans = (ans % MOD + MOD) % MOD;\r\n cout << ans << endl;\r\n\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "564deedd1a7e56f857678af276eaab3a", "src_uid": "1f012349f4b229dc98faadf1ca732355", "difficulty": 2700.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nconst int S=101;\n\nint main()\n{\n\t\n\t//char s[S]=\"this-is-the-test\";\n\tcin>>s;\n\tint len = strlen(s);\n\tenum Status {user, host, respr};\n\tStatus Pol=user;\n\tint idxT=-1;\n\tbool b1=false;\n\tfor(int i=len-1; i>=0; i--)\n\t{\n\t\tif(s[i]=='.' && b1==false)\n\t\t{\n\t\t\tidxT=i;\n\t\t\tb1=true;\n\t\t}\n\t\tif(b1==true && i!=0)\n\t\t{\n\t\t\tif(s[i]=='.' && s[i-1]=='.')\n\t\t\t{\n\t\t\t\tcout<<\"NO\"<\nusing namespace std;\n#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)\n#define foreach(c,itr) for(_typeof((c).begin())itr=(c).begin;itr!=(c).end();itr++)\ntemplate inline string itos(T n){return (n)<0?\"-\"+itos(-(n)):(n)<10?(string)(\"\")+(char)('0'+(n)):itos((n)/10)+itos((n)%10);}\nbool letter(char c)\n{\n\tif(c>='a'&&c<='z') return true;\n\tif(c>='A'&&c<='Z') return true;\n\tif(c=='_') return true;\n\tif(c>='0'&&c<='9') return true;\n\treturn false;\n}\nbool username(string s)\n{\n\tint n=s.length(),i;\n\tif(n==0||n>16) return false;\n\tREP(i,n) if(!letter(s[i])) return false;\n\treturn true;\n}\nbool hostname(string s)\n{\n\tint n=s.length(),i,cur=0;\n\tif(n==0||n>32) return false;\n\ts+='.';\n\tREP(i,n+1)\n\t{\n\t\tif(s[i]=='.')\n\t\t{\n\t\t\tif(cur==0||cur>16) return false;\n\t\t\tcur=0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(!letter(s[i])) return false;\n\t\t\tcur++;\n\t\t} \n\t}\n\treturn true;\n}\nbool resource(string s)\n{\n\treturn username(s);\n}\nbool func(string s)\n{\n\tint n=s.length(),i,j;\n\tREP(i,n) if(s[i]=='@') break;\n\tif(i==n) return false;\n\tif(!username(s.substr(0,i))) return false;\n\tfor(j=i+1;j>s;\n\tcout<<(func(s)?\"YES\":\"NO\")<\n#include\nusing namespace std;\nint main()\n{\n string a;\n cin>>a;\n int temp,i=1;\n int user,host,hostsum,res;\n user=0;\n host=0;\n res=0;\n hostsum=0;\n int process=1;\n while(temp=a[i])\n {\n i++;\n if(user<=16 && host<=16 && hostsum<=32 && res<=16)\n {\n if(process==1)\n {\n if((a[i]>=0 && a[i]<=9) || (a[i]>=65 && a[i]<=90 )|| a[i]==90 ||(a[i]>=97 && a[i]<=122))\n {\n user++;\n continue;\n }\n if(a[i]==64)\n {\n process=2;\n continue;\n }\n cout<<\"NO\";\n return 0;\n }\n if(process==2)\n {\n if((a[i]>=65 && a[i]<=90 ) || a[i]==90 || (a[i]>=97 && a[i]<=122) || a[i]==46)\n {\n host++;\n hostsum++;\n if(host>=17)\n {\n cout<<\"NO\";\n return 0;\n }\n if(a[i]==46)\n host=0;\n continue;\n }\n if(a[i]==47)\n {\n process=3;\n res++;\n }\n }\n if(process==3)\n {\n if((a[i]>=0 && a[i]<=9) || (a[i]>=65 && a[i]<=90 ) || a[i]==90 || (a[i]>=97 && a[i]<=122))\n res++;\n else\n {\n cout<<\"NO\";\n return 0;\n }\n }\n }\n else\n {\n cout<<\"NO\";\n return 0;\n }\n }\n cout<<\"YES\";\n system(\"pause\");\n return 0;\n }\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f4edda6b589a62a3aea12cc83af2ef59", "src_uid": "2a68157e327f92415067f127feb31e24", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nbool other_char(char c){\n\tif (c>='A' && c<='Z')\n\t\treturn true;\n\tif (c>='a' && c<='z')\n\t\treturn true;\n\tif (c>='0' && c<='9')\n\t\treturn true;\n\tif (c=='_')\n\t\treturn true;\n\treturn false;\n}\n\nbool username(string s){\n\tint l=s.size();\n\tif (l<1 || l>16)\n\t\treturn false;\n\tfor (int i=0;i32)\n\t\treturn false;\n\ts+='.';\n\tfor (int i=0;i<=l;++i){\n\t\tif (s[i]=='.'){\n\t\t\tstring t=s.substr(last+1,i-last-1);\n\t\t\tif (username(t)==false)\n\t\t\t\treturn false;\n\t\t\tlast=i;\n\t\t}\n\t}\n\treturn true;\n}\n\nbool check(string s){\n\tint l=s.size(),x=-1;\n\tfor (int i=0;i> s;\n\tint atsign =-1,l=s.size();\n\tfor (int i=0;i\n#include \n#include \nusing namespace std;\nint main()\n{\n\tint a[100];\n\tint B, n;\n\tcin>>n>>B;\n\tvectorB_ordered;\n\tfor (int i=0;i>a[i];\n\t}\n\tint odd, even=odd=0;\n\tfor(int i=0;i=0)\n\t\t\tcuts++;\n\t\telse \n\t\t\tbreak;\n\t}\n\tcout<\nusing namespace std;\n\nbool comp(int i, int j) {\n return abs(a[i] - a[i+1]) < abs(a[j] - a[j+1]);\n}\n\nint main() {\n int n, b, sum = 0, a[100];\n vector cuts;\n cin >> n >> b;\n for (int i=0; i> a[i];\n if (a[i] % 2 == 0)\n sum++;\n else\n sum--;\n if (sum == 0 && i < n - 1)\n cuts.push_back(i);\n }\n \n int ret = 0;\n while (b - abs(a[cuts[ret]]-a[cuts[ret]+1]) >= 0) {\n b -= abs(a[cuts[ret]]-a[cuts[ret]+1]);\n ret++;\n }\n cout << ret << endl;\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "dcba2574af000ecf7aba478d6b66135e", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \nusing namespace std;\nint a [100];\nvector vec();\nint main(){\nint n,m;\ncin>>n;\ncin>>m;\nfor (int i=0;i<100;i++){\n\tcin>>a[i];\n}\nint sume=0;\nint sumo=0;\nint price=0;\nfor (int i=1; i=vec[i])\n\t\t{\n\t\t\tprice++;\n\t\t\tm-=vec[i];\n\t\t}\n\t\telse {\n\t\t\tbreak;\n\t\t}\n\t}\n\tcout<\n#include\nusing namespace std;\nint n;\nint B;\nint a[100+10];\nint b[100+10];\nint cost[100+10];\nint main(){\n while(cin>>n>>B){\n memset(b,0,sizeof(b));\n memset(a,0,sizeof(a));\n for(int i=0;i>a[i];\n }\n int tempO=0,tempE=0;\n int cntOfb=0;\n for(int i=0;i0&&cnt<=indexOfCost)\n {\n B=B-cost[cnt];\n cnt++;\n }\n cout<<--cnt<\nint main() {\n std::cout << \"hello world!\";\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "43760a4850e07dc42efbf3853db887b5", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#define MAXINF 10e10\n#define MININF -10e10\nusing namespace std;\n\nint main(int argc, char **argv){\n int n;\n cin >> n;\n \n if(n <= 1){\n cout << \"-1\";\n return 0;\n }\n long maxX = MININF ,maxY = MININF ,minY= MAXINF,minX= MAXINF;\n long tempX, tempY;\n for(int i= 0; i < n; i++){\n cin >> tempX >> tempY;\n maxX = max(maxX,tempX);\n maxY = max(maxY,tempY);\n minX = min(minX,tempX);\n minY = min(minY,tempY);\n }\n \n long long area = (maxX - minX) * (maxY - minY); \n if (area)\n cout << area;\n elsecout << \"-1\";\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "79819a12cdc96376bc8db443b48a749e", "src_uid": "ba49b6c001bb472635f14ec62233210e", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include \n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint GCDFast(int a,int b){ while(b)b^=a^=b^=a%=b; return a; }\n#define SET(a) memset(a,-1,sizeof(a))\n#define ALL(a) a.begin(),a.end()\n#define CLR(a) memset(a,0,sizeof(a))\n#define PB push_back\n#define PI acos(-1.0)\n#define max3(a,b,c) max(a,max(b,c))\n#define min3(a,b,c) min(a,min(b,c))\n#define READ freopen(\"input.txt\", \"r\", stdin)\n#define WRITE freopen(\"output.txt\", \"w\", stdout)\n#define LL long long\n#define ALL_BITS ((1 << 31) - 1)\n#define NEG_BITS(mask) (mask ^= ALL_BITS)\n#define TEST_BIT(mask, i) (mask & (1 << i))\n#define ON_BIT(mask, i) (mask |= (1 << i))\n#define OFF_BIT(mask, i) (mask &= NEG_BITS(1 << i))\n\n// UP, RIGHT, DOWN, LEFT, UPPER-RIGHT, LOWER-RIGHT, LOWER-LEFT, UPPER-LEFT\nint dx[8] = {-1, 0, 1, 0, -1, 1, 1, -1};\nint dy[8] = { 0, 1, 0,-1, 1, 1, -1, -1};\n#define MOD 1000000007\n#define MX 100010\n#define pii pair\n#define max3(a,b,c) max(a,max(b,c))\n#define min3(a,b,c) min(a,min(b,c))\ntemplate inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}//gcd\nint GCD(int b, int a)\n{\n\tif(a == 0)\treturn b;\n\treturn GCD(a, b%a);\n}\nlong long getLcm(long long a,long long b){\n\tlong long c=a/gcd(a,b);\n\treturn b*c;\n}\n/*\n//---------coinChange--DP faster----\nlong long table[30000+1];\nlong long coinChangecount(int m, int n )\n{\nmemset(table, 0, sizeof(table));\ntable[0] = 1;\n\nfor(int i=0; i0){\ndp[coinNumber][reminder] = 0;return dp[coinNumber][reminder];\n}\n\ndp[coinNumber][reminder] = coin_Change(coinNumber, reminder - a[coinNumber-1])+ coin_Change(coinNumber-1, reminder);\nreturn dp[coinNumber][reminder];\n}\n-------------------------------------------\n//----------------- LDS+ LIS N^2----------------\nfor(i = n - 1; i >= 0; i--) {\nfor( j = i + 1; j < n; j++) {\nif(a[i] > a[j] && ( lds[i] < (lds[j]+1)))\nlds[i] = lds[j]+1;\n}\n}\nfor(i = n - 1; i >= 0; i--) {\nfor( j = i + 1; j < n; j++) {\nif(a[i] < a[j] && ( lis[i] < (lis[j]+1))){\nlis[i] = lis[j]+1;\n}\n}\n}\nvectorList; // LIS list\nfor(i = n-1; i >=0 && max; i--){\nif(max == lis[i]){\nList.push_back(a[i]);\nmax--;\n}\n}\n//----binary search---------------------\nint binarySearchLIS(int key,int size){\nint low =0,high = size-1,mid,ret=100005,index=-1;\nwhile(low<=high){\nmid = (low+high)/2;\nif(lis[mid] == key)\nreturn -1;//already found\nelse if(lis[mid] > key){\nif(ret>lis[mid]){\nret = lis[mid];\nindex = mid;\n}\nhigh=mid-1;//high index decreased as the number is already greater than mid\n}\nelse if(lis[mid] < key){\nlow=mid+1; //key is bigger than the mid number so low index increased\n}\n}\nreturn index;\n}\n//----------palindrome-------------\nint isPalindrome(string str){\nint i,n=str.size(),j,mid=str.size()/2;\nfor(i=0,j=n-1;iP[15];\nint binary_search( int first, int last,int key)\n{\nwhile (last >= first)\n{\n// calculate the midpoint for roughly equal partition\nint imid = (first + last)/2;\nif(P[imid].first <= key && P[imid].second>= key)\nreturn imid; \n\nelse if (P[imid].second < key)\nfirst = imid + 1;\nelse \nlast = imid - 1;\n}\n\nreturn -1;// key was not found\n}\n//--------nlogn list------LIS-------------\nint GetCeilIndex(int a[], int T[], int l, int r, int key) {\nint m;\n\nwhile( r - l > 1 ) {\nm = l + (r - l)/2;\nif( a[T[m]] >= key )\nr = m;\nelse\nl = m;\n}\n\nreturn r;\n}\nint LongestIncreasingSubsequence( int size) {\n// Add boundary case, when array size is zero\n// Depend on smart pointers\n\nint *tailIndices = new int[size];\nint *prevIndices = new int[size];\nint len,j,i;\n\nmemset(tailIndices, 0, sizeof(tailIndices[0])*size);\nmemset(prevIndices, 0xFF, sizeof(prevIndices[0])*size);\n\ntailIndices[0] = 0;\nprevIndices[0] = -1;\nlen = 1; // it will always point to empty location\nfor( int i = 1; i < size; i++ ) {\nif( a[i] < a[tailIndices[0]] ) {\n// new smallest value\ntailIndices[0] = i;\n} else if( a[i] > a[tailIndices[len-1]] ) {\n// a[i] wants to extend largest subsequence\nprevIndices[i] = tailIndices[len-1];\ntailIndices[len++] = i;\n} else {\n// a[i] wants to be a potential condidate of future subsequence\n// It will replace ceil value in tailIndices\nint pos = GetCeilIndex(a, tailIndices, -1, len-1, a[i]);\n\nprevIndices[i] = tailIndices[pos-1];\ntailIndices[pos] = i;\n}\n}\nj=0;\nfor(i = tailIndices[len-1],j=0; i >= 0; i = prevIndices[i],j++ ){\nlisCal[j] = a[i];\n}\nlen = j; \n\ndelete[] tailIndices;\ndelete[] prevIndices;\n\nreturn len;\n}\n---------Flood Fill-------------------\n#define pii pair\n//int fx[]={1,-1,0,0,1,1,-1,-1}; \n//int fy[]={0,0,1,-1,1,-1,1,-1};\nint fx[] = {1,-1,0,0}; //not in diagonal\nint fy[] = {0,0,1,-1};\nint cell[105][105]; \nint d[105][105],vis[105][105];\nint row,col;\nbool check(int tx,int ty)\n{\nif (tx>=0 && tx=0 && tyq;\nq.push(pii(sx,sy));\nwhile(!q.empty())\n{ \npii top=q.front(); q.pop();\nfor(int k=0;k<4;k++)\n{\nint tx=top.first+fx[k];\nint ty=top.second+fy[k];\nif((check(tx,ty)) && (cell[tx][ty]==cell[sx][sy]|| cell[tx][ty]==1) && vis[tx][ty]==0)//\n{ \nvis[tx][ty]=1;\nsum++;\n//d[tx][ty]=d[top.first][top.second]+1;\nq.push(pii(tx,ty));\n}\n}\n}\nreturn sum;\n}\n*/\n\n//long long dp[105][30005];\nlong long minimium = 1000005;\nint minCoin=0;\n\n\n/* prime generate\n#define N 1000000\nbool prime_number[N];\nlong long prime_generator(long long n)\n{\n\tlong long i = 0 , x = 0,j = 0,limit;\n\n\tprime_number[0] = false;\n\tprime_number[1] = false;\n\tfor(i = 2 ; i<= n ; i++)\n\t\tprime_number[i] = true;\n\tlimit = (long long)sqrt((double)n);\n\tfor(x = 2 ; x <= limit;x++)\n\t{\n\t\tif(prime_number[x] == true)\n\t\t{\n\t\t\tfor(i = 4 ; i <= n ;i++)\n\t\t\t\tif(prime_number[i] == true & i != x)\n\t\t\t\t\tif(i % x == 0)\n\t\t\t\t\t\tprime_number[i] = false;\n\t\t}\n\t}\n\tx = 0;\n\tfor(i = 2 ; i<= n ; i++)\n\t\tif(prime_number[i])\n\t\t\tx++;//number of primes\n\treturn x;\n}*/\n\n//int a[100005],b[100005];\n\nint main()\n{\n\tlong long i,n,m,x,testCase=0,j,k,y,flag,temp;\n\tlong long sum,max,number,min,p,q,reminder,index;\n\tstring str,S,str1,str2;\n\tlong long l,r,s,sk,t;\n\tint X[5],Y[5];\n\twhile(cin>>n)\n\t{\n\t\tfor(i=1;i<=n;i++){\n\t\t\tcin>>X[i]>>Y[i];\n\t\t}\n\n\t\tif(n == 1)\n\t\t\tcout<<\"-1\\n\";\n\t\telse if(n == 2){\n\t\t\tx = abs(X[1]-X[2]) *abs(Y[1]-Y[2]);\n\t\t\t\tif(x)\n\t\t\t\t\tcout<\nusing namespace std;\n\nint n,a,b,maxa=-10000000,maxb=-10000000,mina=1000000,minb=10000000,ans;\nint main()\n{\n\tcin>>n;\n\tif(n<=1) cout<<-1;\n\telse \n\t\t{\n\t\t\tfor(int i=1;i<=n;++i)\n\t\t\t\t{\n\t\t\t\t\tcin>>a>>b;\n\t\t\t\t\tif(a>maxa&&b>maxb) maxa=a,maxb=b;\n\t\t\t\t\tif(a0)\n\t\t\tcout<\r\n#define ll long long\r\n#define maxn 1000005\r\n#define inf 1e9\r\n#define pb push_back\r\n#define rep(i,a,b) for(ll i=a;i<=b;i++)\r\n#define per(i,a,b) for(int i=a;i>=b;i--)\r\nusing namespace std;\r\n\r\ninline int read()\r\n{\r\n\tint x=0,w=1; char c=getchar();\r\n\twhile(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}\r\n\twhile(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}\r\n\treturn w==1?x:-x;\r\n}\r\n\r\ninline ll C(int N,int M)\r\n{\r\n\tll ans=1; for(ll i=N,j=1;j<=M;j++,i--) ans*=i;\r\n\trep(i,1,M) ans/=i; return ans;\r\n}\r\n\r\ndouble n,p;\r\n\r\ninline bool jud(int x)\r\n{\r\n\tll tmp=2*C(x,3)+2*C(x,2)*C(n-x,1)+C(x,1)*C(n-x,2);\r\n\tll P=2*C(n,3);\r\n\tif((double)tmp>=(double)P*p) return true; return false;\r\n}\r\n\r\nint main()\r\n{\r\n\tcin>>n>>p;\r\n\trep(i,0,n) if(jud(i)) {cout<\r\nusing namespace std;\r\n\r\nconst int maxn = 1010, sigma_size = 20;\r\nint f[1 << sigma_size];\r\nunordered_map> dp[maxn];\r\nint cnt[maxn][sigma_size];\r\nchar s[maxn];\r\n\r\nint main() {\r\n int n;\r\n scanf(\"%d\", &n);\r\n scanf(\"%s\", s + 1);\r\n int st = 0, tot = 0;\r\n f[0] = n + 1;\r\n for (int i = n; i; i--)\r\n if (!((st >> (s[i] - 'a')) & 1))\r\n {\r\n st |= 1 << (s[i] - 'a'), tot++;\r\n for (int j = 0; j < 1 << sigma_size; j++)\r\n if (!f[j] && ((j & st) == j))\r\n f[j] = i;\r\n }\r\n for (int i = 0; i < st; i++)\r\n if (f[i])\r\n printf(\"f[%d] = %d\\n\", i, f[i]);\r\n for (int i = 1; i <= n; i++)\r\n for (int j = 0; j < sigma_size; j++) cnt[i][j] = cnt[i - 1][j] + (s[i] - 'a' == j);\r\n int nxt, val;\r\n dp[0][0] = make_tuple(0, 0, 0);\r\n for (int i = 0; i <= n; i++)\r\n for (auto j : dp[i]) {\r\n for (int k = 0; k < sigma_size; k++)\r\n if (((st >> k) & 1) && !((j.first >> k) & 1)) {\r\n nxt = j.first << k, val = cnt[f[st ^ nxt] - 1][k] - cnt[i][k];\r\n if (!dp[f[st ^ nxt]].contains(nxt) || get<2>(dp[f[st ^ nxt]][nxt]) < val)\r\n dp[f[st ^ nxt]][nxt] = make_tuple(i, j.first, val);\r\n }\r\n }\r\n int cur;\r\n string ans = \"\", tmp;\r\n for (int i = 1; i <= n; i++)\r\n if (dp[i].contains(st)) {\r\n auto u = dp[i][st];\r\n tmp.clear(), cur = tot - 1;\r\n while (get<2>(u)) {\r\n for (int j = 1; j <= get<2>(u); j++) tmp.push_back(cur + 'a');\r\n cur--, u = dp[get<0>(u)][get<1>(u)];\r\n }\r\n if (ans < tmp)\r\n ans = tmp;\r\n }\r\n cout << ans << endl;\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7c13c60505364c67cbd80f8e2badfbb1", "src_uid": "788ed59a964264bd0e755e155a37e14d", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include\r\n#include\r\nusing namespace std;\r\n#define int long long\r\nconst int N=2e5+10;\r\nlong long double c2(int n) {\r\n\treturn n * (n - 1) / 2.0;\r\n}\r\n\r\nlong double c3(int n) {\r\n\treturn n * (n - 1) * (n - 2) / 6.0;\r\n}\r\nint n;\r\nlong double p;\r\nsigned main(){\r\n\tcin>>n>>p;\r\n\tfor(int i=0;i=p){\r\n\t\t\tcout<\r\n#pragma GCC optimize(\"Ofast,unroll-loops\")\r\n#pragma GCC target(\"avx,avx2,sse,sse2\")\r\n \r\n \r\n \r\n #define int long long \r\n \r\n#define YES cout<<\"YES\\n\";return; \r\n#define NO cout<<\"NO\\n\";return; \r\n#define write(a) cout<; \r\nmt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid u1(5, 10); u1(rnd);\r\nlong long powmod(long long a,long long b,long long mod) {\r\n if (b==0 || a==1) {if (mod==1) return 0; else return 1; }\r\n \r\n if (b%2==0) { long long k=powmod(a,b/2,mod); return (k*k)%mod; }\r\n else {long long k=powmod(a,b/2,mod); return ( (k*k) %mod *a)% mod; }\r\n}\r\nlong long gcd(long long a, long long b) {\r\n if (a==0) return b;\r\n if (b==0) return a;\r\n if (a>b) return gcd(a%b,b); else return gcd(b%a,a);\r\n}\r\nint prime(int p) { // 1 - \u043f\u0440\u043e\u0441\u0442\u043e\u0435\r\nif (p==1) return 0; \r\n for (int i=2;i*i<=p;i++) {\r\n if (p%i==0 && i u1(1e9, 2e9);\r\n int pepega=u1(rnd); \r\n while (prime(pepega)!=1) pepega=u1(rnd); \r\n return pepega; \r\n}\r\n \r\ntemplate void ifmax(T1 &max, T1 kek) {\r\n if (kek>max) max=kek; \r\n return; \r\n}\r\ntemplate void ifmin(T1 &min, T1 kek) {\r\n if (kek istream& operator>> (std::istream& in, pair & a) {\r\nin>>a.first>>a.second; \r\nreturn in; \r\n \r\n}\r\n \r\ntemplate istream& operator>> (std::istream& in, vector & a) {\r\n for (int i=0;i>a[i]; \r\n return in;\r\n} \r\n \r\ntemplate ostream& operator<< (std::ostream& out, vector &b) {\r\n for (int i=0;i void sort(vector &m) {\r\n sort(m.begin(),m.end());\r\n}\r\n \r\ntemplate void reverse(vector &m) {\r\n reverse(m.begin(),m.end());\r\n}\r\nint mod=1000000007; \r\nint fac[200005];\r\nint inv_fac[200005]; \r\nint co(int a, int b) {\r\n int ans=1;\r\n ans*=fac[b]; \r\n ans*=inv_fac[b-a]; ans%=mod; \r\n ans*=inv_fac[a]; \r\n return ans%mod; \r\n} \r\n bool is_sorted(vector a) {\r\n int check=1;\r\n for (int i=0;i+1>a>>kek;\r\nlong double eps=1e-7; \r\nfor (int i=1;i<=a;i++) {\r\n int left=a-i; \r\n long double pick0=(long double)(i*(i-1)*(i-2))/(long double)(a*(a-1)*(a-2));\r\n long double pick3=(long double)(left*(left-1)*(left-2))/(long double)(a*(a-1)*(a-2)); \r\n long double pick2=(long double)(3*left*(left-1)*i)/(long double)(a*(a-1)*(a-2)); \r\n long double pick1=(long double)(3*left*(i)*(i-1))/(long double)(a*(a-1)*(a-2)); \r\n // cout<kek) {\r\n write(i); \r\n }\r\n}\r\n \r\n /* --------- */ \r\n return;\r\n }\r\n \r\n \r\n \r\n signed main() {\r\n ios_base::sync_with_stdio(0);\r\n cin.tie(0);\r\n cout.tie(0); \r\n \r\n \r\n cout<>tututu; // \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0442\u043e \u0437\u0430\u043a\u043e\u043c\u0435\u043d\u0442\u0438\u0442\u044c\r\n \r\n for (int qwerty=0;qwerty> t;\r\n\twhile (t > 0) {\r\n\t\tt--;\r\n\t\tsolve();\r\n\t}\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9534c0f376a794f59d84d369418cb7ed", "src_uid": "788ed59a964264bd0e755e155a37e14d", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\nusing namespace std;\n#define rep(i) for(int i=0;i<=1;i++)\nchar x[256];\ntypedef long long ll;\nint n;\nll hasha[1000001],hashb[1000001],pow[1000001];\nstring a,b;\nvoid pre()\n{\n x['E']='W';\n x['W']='E';\n x['N']='S';\n x['S']='N';\n pow[1]=10;\n for(int i=2;i<=1000000;i++)\n pow[i]=10*pow[i-1];\n pow[0]=1;\n} \nvoid calc()\n{\n for(int i=1;i<=n;i++)\n hasha[i]=10*hasha[i-1]+a[i-1];\n for(int i=1;i<=n;i++)\n {\n hashb[i]=hashb[i-1]+pow[i-1]*b[b.length()-i];\n }\n}\nvoid reverse(string &s)\n{\n for(int i=0;i>n;\n pre();\n cin>>a>>b;\n reverse(a);\n calc();\n int flag=1;\n for(int i=1;i<=n;i++)\n {\n if(hasha[i]==hashb[i])\n {\n if(a.substr(0,i)==b.substr(n-1-i,i))\n flag=0;\n }\n }\n if(flag)\n cout<<\"YES\";\n else\n cout<<\"NO\";\n} ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a290294afa6627dd5ce7d5ab160d31e9", "src_uid": "85f43628bec7e9b709273c34b894df6b", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "F - Hongcow Buys a Deck of Cards ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d01594aedce5e0c41a2f924ebac912e3", "src_uid": "85f43628bec7e9b709273c34b894df6b", "difficulty": 2500.0} {"lang": "Clang++17 Diagnostics", "source_code": "#include \n#include \n\nusing namespace std;\n\nconst unsigned long long P = 31;\n\nint main() {\n\tfreopen(\"input.txt\", \"r\", stdin)\n\tint n;\n\tstring s1, s2;\n\tcin >> n >> s1 >> s2;\n\tn--;\n\tfor(int i = 0; i < n; i++) {\n\t if (s2[i] == 'N') {\n\t \ts2[i] = 'S';\n\t } else if (s2[i] == 'S') {\n\t \ts2[i] = 'N';\n\t } else if (s2[i] == 'W') {\n\t \ts2[i] = 'E';\n\t } else if (s2[i]=='E') {\n\t \ts2[i] = 'W';\n\t }\n\t \n\t}\n\n\tunsigned long long pow = 1;\n\tunsigned long long h1, h2;\n\tfor (int i = n - 1; i >= 0; i--) {\n\t\th1 = h1 + (s1[i]) * pow;\n\t\th2 = h2 * P + s2[i];\n\t\tif (h1 == h2)\n\t\t{\n\t\t\tcout << \"NO\" << endl;\n\t\t\treturn 0;\n\t\t}\n\t\tpow *= P;\n\t}\n\tcout << \"YES\" << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "df62ed5e03897e8b61ddd915081cb095", "src_uid": "85f43628bec7e9b709273c34b894df6b", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long ll;\n\nconst ll MAXN = 1000010;\nconst ll BAZA = 31337;\nconst ll BAZA2 = 10007;\nconst ll MOD = 1000000007;\n\nll n;\nll h[MAXN];\nll h2[MAXN];\nchar a[MAXN], b[MAXN];\nstring s1, s2;\n\nchar inv(const char &c) {\n if (c == 'N') return 'S';\n if (c == 'W') return 'E';\n if (c == 'E') return 'W';\n if (c == 'S') return 'N';\n}\n\nll pot[MAXN];\nll pot2[MAXN];\n\nint main() {\n scanf(\"%I64d\", &n);\n scanf(\"%s\", a);\n scanf(\"%s\", b);\n\n s1 = s2 = \"\";\n s1 += a[0];\n s2 += inv(b[0]);\n\n for (int i = 1; i < n - 1; i++) {\n if (a[i] != a[i-1]) s1 += a[i];\n if (b[i] != b[i-1]) s2 += inv(b[i]);\n }\n// cout << s1 << \" \" << s2 << endl;\n for (int i = s2.size() - 1; i >= 0; i--) {\n h[i] = h[i+1] * BAZA + s2[i];\n h[i] %= MOD;\n h2[i] = h2[i+1] * BAZA2 + s2[i];\n }\n\n pot[0] = 1;\n pot2[0] = 1;\n for (int i = 1; i <= n; i++) {\n pot[i] = pot[i-1] * BAZA;\n pot[i] %= MOD;\n pot2[i] = pot2[i-1] * BAZA2;\n }\n\n ll trH = 0;\n ll trH2 = 0;\n// cout << s1 << s1.size() << endl;\n// cout << s2 << s2.size() << endl;\n for (int i = s1.size() - 1; i >= 0; i--) {\n if (s2.size() - 1 - pom < 0) break;\n trH += s1[i] * pot[s1.size() - 1 - i];\n trH %= MOD;\n trH2 += s1[i] * pot2[s1.size() - 1 - i];\n int pom = s1.size() - 1 - i;\n if (trH == h[s2.size() - 1 - pom] && trH2 == h2[s2.size() - 1 - pom]) {\n// cout << i << endl;\n printf(\"NO\\n\");\n return 0;\n }\n }\n\n printf(\"YES\\n\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0d10a0361d1d9f0abee10f5c68711717", "src_uid": "85f43628bec7e9b709273c34b894df6b", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std;\nint map[9][9];\nint main()\n{\n int a=9,b=9;\n for(int i=0;i<8;i++)\n for(int j=0;j<8;j++)\n {\n char ch=0;ch=gerchar();\n if(ch=='A')map[i][j]=1;\n if(ch=='B')map[i][j]=2;\n }\n for(int i=0;i<8;i++)\n {\n for(int j=0;j<8;j++)\n if(map[j][i]==1)a=min(a,j);\n for(int k=7;k>=0;k--)\n if(map[j][i]==2)b=min(b,7-k);\n }\n if(a<==b)put('A');else put('B');\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7eb0a8bc3a116e4714bed72c5698eac7", "src_uid": "0ddc839e17dee20e1a954c1289de7fbd", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int i,j,k,d,f,l,r,e,m,disA,disB ;\n char t[8][8];\nm=1 ; e=1 ;\n\n for (i=0;i<8;i++)\n for(j=0;j<8;j++)\n { cin>>t[i][j]; }\n\nbool g=true ;\n d=0 ;\n\n\n for (i=1;i<8 && g;i++)\n { for(j=1;j<8 && g;j++)\n {\n\n if (t[i][j]== 'W' )\n {\n for (r=(i-1);r>=0;r--)\n {\n if((t[r][j]=='B'))\n {\n e=0 ;\n }\n e*=e ;\n }\n\n if(e==1)\n { k=i ;\n d=j ;\n g=false ;\n\n } } } }\nint w,x ;\n\n l=0 ;\ng=true ;\n for (i=6;i>=0 && g;i--)\n { for(j=6;j>=0 && g;j--)\n {\n\n if (t[i][j]=='B' )\n {\n for (r=(i+1);r<8;r++)\n {\n if (t[r][j]=='W')\n {\n m=0;\n }\n m*=m ;\n }\n\n if(m==1)\n { f=i ;\n l=j ;\n g=false ;\n }}\n\n }\n }\n\n\n\n\n\n if (k<=(7-f))\n {cout\"A\" ; }\n else\n {cout<<\"B\" ; }\n\n\n\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b7230589b5fe651597463de7fae20cd2", "src_uid": "0ddc839e17dee20e1a954c1289de7fbd", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\nint main()\n{\n\tint\n char[8][8];\n\tint minW = 0, minB = 0;\n for(int i = 0; i < 8; i++)\n\t{\n\t\tfor(int j = 0; j < 8; j++)\n\t\t{\n\t\t\tcin >> char[i][j];\n\t\t}\n\t}\n\tfor(int i = 0; i < 8; i++)\n\t{\n\t\tfor(int j = 0; j < 8; j++)\n\t\t{\n\t\t\tif(char[j][i] == 'B')\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse if(char[j][i] == 'W')\n\t\t\t{\n\t\t\t\tif(minW < i)\n\t\t\t\t{\n\t\t\t\t\tminW = i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor(int i = 7; i >= 0; i--)\n\t{\n\t\tfor(int j = 7; j >= 0; j--)\n\t\t{\n\t\t\tif(char[j][i] == 'W')\n\t\t\t{\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\telse if(char[j][i] == 'B')\n\t\t\t{\n\t\t\t\tif(minB < i)\n\t\t\t\t{\n\t\t\t\t\tminB = i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif(minB < minW)\n\t{\n\t\tcout << 'B' << '\\n';\n\t}\n\telse\n\t{\n\t\tcout << 'A' << '\\n';\n\t}\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "99effa1a6ae94244bfe393d08daafa2c", "src_uid": "0ddc839e17dee20e1a954c1289de7fbd", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nchar a[9][9];\n\nlong long c, index[9], jndex[9], b, d, mn, mn1;\n\nint main () {\n for (int i=1;i<=8;i++){\n for (int j=1;j<=8;j++){\n cin >>a[i][j];\n if (a[i][j]=='B'){\n B++;\n }\n if (a[i][j]=='A'){\n A++;\n }\n if (a[i][j]!='.'){\n c++;\n index[c]=i;\n jndex[c]=j;\n }\n }\n }\n if (A==17 && B==28){\n cout <<\"A\";\n return 0;\n }\n while (c>0){\n for (int i=1;i<=8;i++){\n if ((a[index[c]][jndex[c]]=='B') && (a[index[c]+i][jndex[c]]=='.')){\n b++;\n }\n if ((a[index[c]][jndex[c]]=='B') && (a[index[c]+i][jndex[c]]!='.') && (index[c]-i)>9) {\n if (b9) {\n if (dd){\n cout <<'B';\n return 0;\n }\n cout <<'A';\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b054247d81456f4b6c6ad42cdc175d2a", "src_uid": "0ddc839e17dee20e1a954c1289de7fbd", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nlong long n;\n\nbool cal(long long mid)\n{\n long long res = 0, curr = n;\n while (curr > 0)\n {\n if (curr >= mid)\n res += mid;\n else if (curr < mid)\n res += curr;\n curr = curr - mid, curr = curr - (curr / 10);\n\n if (res >= n / 2)\n return true;\n }\n\n return false;\n}\n\nint main()\n{\n scanf(\"%d\", &n);\n long long l = 1, r = n / 2, res = 0;\n while (l <= r)\n {\n long long mid = (l + r) / 2;\n if (cal(mid) == true)\n res = mid, r = mid - 1;\n else\n l = mid + 1;\n }\n print(\"%d \", res);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d6fd4d03deac1c45418af7a2ed1a26b0", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "difficulty": 1500.0} {"lang": "GNU C++17", "source_code": "#include\n\nusing namespace std;\n\ntypedef pair pii;\ntypedef vector vi;\ntypedef vector vpi;\ntypedef map maps;\ntypedef map mapi;\ntypedef set seti;\ntypedef set sets;\ntypedef set setc;\n\n\n#define int long long\n#define double long double\n#define add push_back\n#define pop pop_back\n#define all(a) a.begin(), a.end()\n#define sz(a) int((a).size())\n\n#define repi(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)\n#define rep(i, a, b) for(int i = a; i < b; i++)\n#define repn(i, a, b) for(int i = a; i <= b; i++)\n#define repv(i, b, a) for(int i = b - 1; i >= a; i--)\n#define _1 first\n#define _2 second\n\n\n\nconst double EPS = 1e-9;\nconst double PI = acos(-1.);\nconst int MOD = 1e9 + 7;\nconst int MAXN = 300001;\nint INF = __INT64_MAX__;\nint MAX = -1e16;\nint MIN = 1e16;\nstring YN[] = {\"NO\", \"YES\"};\n\n\n\nint n, m = 1, cnt, res, A[MAXN], B[MAXN];\nstring s, t;\n\nvoid solution()\n{\n cin >> n;\n long double f = 0.0392594L * n;\n int l = f;\n for(int i = l - 50; i <= l + 50; i++){\n\t\t\tint temp = n;\n\t\t\tif(i < 1)\n\t\t\t\tcontinue;\n\t\t\tcnt = 0;\n\t\t\twhile(temp > 0){\n\t\t\t\tif(temp < i){\n\t\t\t\t\tcnt += temp;\n\t\t\t\t\ttemp = 0;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcnt += i;\n\t\t\t\ttemp -= i;\n\t\t\t\ttemp -= temp / 10;\n\t\t\t}\n\t\t\tif(temp == 0 && cnt >= n / 2){\n\t\t\t\tcout << i;\n\t\t\t\treturn;\n\t\t\t}\n }\n\n\n}\n__INT16_C() main()\n{\n //ifstream fin(\"input.in\");\n //ofstream fout(\"output.out\");\n\n ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);\n\n int t = 1;\n // cin >> t;\n\n while(t--) solution();\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e97a73904dc0216855e29d55e24937f8", "src_uid": "db1a50da538fa82038f8db6104d2ab93", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\ntypedef long long ll;\n\nll n;\nbool sip(ll k){\n\n ll dulces = n;\n ll vasya = 0;\n while(dulces > 0){\n\n int decre = min(dulces, k);\n vasya += decre;\n dulces -= decre;\n dulces -= dulces / 10;\n }\n return vasya >= n/2.0;\n}\nint main(){\n\n// freopen(\"in.txt\", \"r\", stdin);\n// freopen(\"out.txt\", \"w\", stdout);\n\n cin>>n;\n\n ll ini = 1, fin = n;\n\n while(ini <= fin){\n\n ll mit = (ini + fin) / 2ll;\n if(sip(mit))\n fin = mit1;\n else\n ini = mit + 1;\n\n }\n cout<\n#define int long long\n\nusing namespace std;\n\nbool F(int k,int n)\n{\n\tint sum=0,l,m=n;\n\twhile(n)\n\t{\n\t\tsum+=min(n,k);\n\t\tn-=min(n,k);\n\t\tl=n/10;\n\t\tn-=l;\n\t}\n\tif(sum*2>=m)\n\t\treturn 1;\n\treturn 0;\n}\n\nmain()\n{\n\tint n;\n\tcin>>n;\n\tint l=1,r=n+1,mid;\n\twhile(r-l!=1)\n\t{\n\t mid=(l+r)/2\n\t\tif(F(mid,n))\n\t\t\tl=mid;\n\t\telse\n\t\t r=mid;\n\t}\n\tcout<\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int maxn = 100010;\n\nchar s1[maxn], s2[maxn];\nint a[maxn], n, m;\n\nint minp[10000010], prm[10000010], tot;\nint v[1000][1000];\n\nint qpow(int x, int y, int mod) {\n\tint ret = 1;\n\twhile (y) {\n\t\tif (y & 1) ret = 1LL*ret*x%mod;\n\t\tx = 1LL*x*x%mod;\n\t\ty >>= 1;\n\t}\n\treturn ret;\n}\n\nint calg(int p) {\n\tvector vec;\n\tint t = p-1;\n\twhile (t > 1) {\n\t\tint x = minp[t];\n\t\twhile (t % x == 0) {\n\t\t\tt /= x;\n\t\t}\n\t\tvec.push_back(x);\n\t}\n\tfor (int i = 2; i < p; i++) {\n\t\tint ok = 1;\n\t\tfor (int j = 0; j < vec.size(); j++) {\n\t\t\tint x = vec[j];\n\t\t\tif (qpow(i, (p-1)/x, p) == 1) ok = 0;\n\t\t}\n\t\tif (ok) return i;\n\t}\n\treturn -1;\n}\n\nint main() {\n\tfor (int i = 2; i <= 10000000; i++) {\n\t\tif (!minp[i]) {\n\t\t\tminp[i] = i;\n\t\t\tprm[++ tot] = i;\n\t\t}\n\t\tfor (int j = 1; j <= tot && i * prm[j] <= 10000000; j++) {\n\t\t\tminp[i*prm[j]] = prm[j];\n\t\t\tif (i % prm[j] == 0) break;\n\t\t}\n\t}\n\tscanf(\"%d%d\", &n, &m);\n\tscanf(\"%s%s\", s1, s2);\n\tfor (int i = 0; i < n; i++) a[i] = s1[i] - s2[i];\n\tif (n <= 1000) {\n\t\tconst int mod = 118219;\n\t\tfor (int i = 2; i < mod; i++) {\n\t\t\tint s = 0, k = 1;\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\ts = (s + 1LL*k*a[j]%mod)%mod;\n\t\t\t\tk = 1LL*k*i%mod;\n\t\t\t}\n\t\t\tif (!s) {\n\t\t\t\tprintf(\"%d %d\\n\", mod, i);\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\tfor (int i = 2; i < 1000; i++) {\n\t\tfor (int j = 0; j < n; j++) {\n\t\t\tv[i][j%i] += a[j];\n\t\t}\n\t}\n\tdouble p = 1;\n\tint cnt = 0;\n\tfor (int i = m; i <= 10000000; i++) {\n\t\tif (minp[i] != i) continue;\n\t\tint g = calg(i);\n\t\tfor (int j = 2; j <= 1000; j++) {\n\t\t\tif ((i-1) % j == 0) {\n\t\t\t\tint t = qpow(g, (i-1)/j, i);\n\t\t\t\tint s = 0, tmp = 1;\n\t\t\t\tfor (int k = 0; k < j; k++) {\n\t\t\t\t\ts = (s + 1ll * tmp * v[j][k] % i) % i;\n\t\t\t\t\ttmp = 1ll*tmp*t%i;\n\t\t\t\t\t//cout << v[ch][j] << \" \";\n\t\t\t\t}\n\t\t\t\t//cout << endl;\n\t\t\t\tp = p * double(i-1) / double(i);\n\t\t\t\t++ cnt;\n\t\t\t\t//cout << s << endl;\n\t\t\t\tif (!s) {\n\t\t\t\t\tprintf(\"%d %d\\n\", i, t);\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tcout << cnt << endl;\n\tcout << p << endl;\n\tassert(0);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7c5f16af0d5c803f22dcb961961dfd6f", "src_uid": "8f7ca2115158b946ff53e45f035182e6", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include \n#define M 1048576 * 8\n\nusing namespace std;\n\ntypedef unsigned long long ull;\ntypedef long long ll;\n\nll powmod(ll x, ll y, ll p) {\n\tll ans = 1;\n\twhile(y) {\n\t\tif(y & 1) ans = ans * x % p;\n\t\tx = x * x % p;\n\t\ty >>= 1;\n\t}\n\treturn ans;\n}\n\nll F[200010], Fac[200010], Rev[200010], rev[M], r[200010];\n\nint V[200010], st = 0, S[200010];\n\nvector C[25], rC[25];\n\nll P, g;\n\nll X[M], Y[M];\n\nbool npr[30000010];\n\nvoid DFT(ll *X, int t) {\n\tfor(int i = 0; i < t; i++)\n\t\tfor(int j = 0; j < (1 << t); j += (1 << i + 1))\n\t\t\tfor(int k = 0; k < (1 << i); k++) {\n\t\t\t\tll A = X[j + k], B = X[j + k + (1 << i)] * C[i + 1][k] % P;\n\t\t\t\tX[j + k] = (A + B) % P;\n\t\t\t\tX[j + k + (1 << i)] = (A - B + P) % P;\n\t\t\t}\n\tfor(int i = 0; i < (1 << t); i++) X[i] %= P;\n}\n\nvoid pr(int o) {\n\tfor(int i = 1; i <= o; i++) {\n\t\tC[i].clear();\n\t\tC[i].resize(1 << i), C[i][0] = 1;\n\t\tll w = powmod(g, (P - 1) >> i, P);\n\t\tfor(int j = 1; j < (1 << i); j++) C[i][j] = C[i][j - 1] * w % P;\n\t\trC[i] = C[i];\n\t\treverse(rC[i].begin() + 1, rC[i].end());\n\t}\n}\n\nll getori() {\n\tfor(int g = 2; ; g++) {\n\t\tassert(powmod(g, P - 1, P) == 1);\n\t\tint flag = 0;\n\t\tfor(int i = 2; i * i <= P - 1; i++) if((P - 1) % i == 0) {\n\t\t\tif(powmod(g, i, P) == 1 || powmod(g, (P - 1) / i, P) == 1) {flag = 1; break;}\n\t\t}\n\t\tif(!flag) return g;\n\t}\n}\n\nint n, m;\n\nchar ch1[M], ch2[M];\n\nint main() {\n\tscanf(\"%d%d\", &n, &m);\n\tscanf(\"%s\", ch1 + 1);\n\tscanf(\"%s\", ch2 + 1);\n\tfor(int i = 2; i <= 100000; i++) if(!npr[i])\n\t\tfor(int j = i + i; j < 30000000; j += i) npr[j] = 1;\n\tfor(P = m; ; P++) if(!npr[P]) {\n\t\tll tmp = P - 1;\n\t\tif((tmp & -tmp) <= P / 10) continue;\n\t\tint o = 0, s = tmp & -tmp;\n\t\twhile((1 << o) != s) o++; \n\t\tif((1 << o) <= n) continue;\n\t\t// Do 2^22\n\t\tg = getori();\n\t\tpr(o);\n\t\tfor(int i = 0; i < (1 << o); i++) X[i] = 0, S[i] = 0;\n\t\tfor(int i = 1; i <= n; i++) X[i - 1] = ((ch1[i] - ch2[i]) % P + P) % P, S[i - 1] = X[i - 1];\n\t\tfor(int i = 1; i < (1 << o); i++) rev[i] = rev[i / 2] / 2 + (i & 1) * (1 << o - 1);\n\t\tfor(int i = 0; i < (1 << o); i++) if(rev[i] > i) swap(X[i], X[rev[i]]);\n\t\tDFT(X, o);\n\t\ttmp = 1;\n\t\ts = powmod(g, (P - 1) >> o, P);\n\t\tfor(int i = 0; i < (1 << o); i++) {\n\t\t\tif(tmp != 1 && tmp != P - 1 && X[i] % P == 0) {\n\t\t\t\tprintf(\"%lld %lld\\n\", P, tmp);\n\t\t\t\treturn 0;\n\t\t\t\t/*ll qwq = 0;\n\t\t\t\tfor(int j = n - 1; j >= 0; j--) qwq = (qwq * tmp + S[j]) % P;\n\t\t\t\tassert(qwq % P == 0);\n\t\t\t\treturn 0;*/\n\t\t\t}\n\t\t\ttmp = tmp * s % P;\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2e8b02112bfada621807f16704244e17", "src_uid": "8f7ca2115158b946ff53e45f035182e6", "difficulty": 3100.0} {"lang": "GNU C++14", "source_code": "#pragma GCC optimize(\"Ofast\")\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define fi first\n#define se second\n#define mp make_pair\n#define pb push_back\ntypedef long long ll;\ntypedef unsigned long long ull;\nconst int md=786433;\nconst int N=md*2+10; \n#define delto(a,b) ((a)-=(b),((a)<0)&&((a)+=md))\ninline int del(int a,int b)\n{\n a-=b;\n return a<0?a+md:a;\n}\nint rev[N];\nvoid init(int len)\n{\n int bit=0,i;\n while((1<<(bit+1))<=len) ++bit;\n for(i=1;i>1]>>1)|((i&1)<<(bit-1));\n}\null poww(ull a,ull b)\n{\n ull ans=1;\n for(;b;b>>=1,a=a*a%md)\n if(b&1)\n ans=ans*a%md;\n return ans;\n}\nint inv[N*2],pw_1[N*2],pw_2[N*2];\nvoid dft(int *a,int len,int idx)//\u8981\u6c42len\u4e3a2\u7684\u5e42\n{\n int i,j,k,t1,t2;ull wn,wnk;\n for(i=0;i=md)&&(a[k]-=md);\n a[k+i]=t1-t2;\n (a[k+i]<0)&&(a[k+i]+=md);\n }\n }\n }\n if(idx==-1)\n {\n ull ilen=inv[len];\n for(i=0;i>1));\n memset(t2+(i>>1),0,sizeof(int)*(i>>1));\n init(i);\n dft(t1,i,1);dft(t2,i,1);\n for(j=0;j>1);++j)\n t1[j]=t1[j+(i>>1)];\n memset(t1+(i>>1),0,sizeof(int)*(i>>1));\n dft(t1,i,1);\n for(j=0;j>1;j>1)];\n }\n}\ninline void p_de(int *f,int len)//derivative\u6c42\u5bfc;f=f'\n{\n for(int i=0;i=1;--i)\n f[i]=ull(f[i-1])*inv[i]%md;\n f[0]=0;\n}\nvoid p_ln(int *f,int len)//\u8981\u6c42len\u4e3a2\u7684\u5e42\uff0cf[0]=1\n{\n static int t3[N];\n p_inv(f,t3,len);p_de(f,len);\n init(len<<1);\n dft(f,len<<1,1);dft(t3,len<<1,1);\n for(int i=0;i<(len<<1);++i)\n f[i]=ull(f[i])*t3[i]%md;\n dft(f,len<<1,-1);p_in(f,len);\n}\nvoid p_exp(int *f,int *g,int len)//\u8981\u6c42len\u4e3a2\u7684\u5e42\uff0cf[0]=0\n{\n static int t1[N],t2[N];\n g[0]=1;\n for(int i=2,j;i<=len;i<<=1)\n {\n memcpy(t1,g,sizeof(int)*(i>>1));\n memset(t1+(i>>1),0,sizeof(int)*(i>>1));\n p_ln(t1,i);\n for(j=0;j<(i>>1);++j)\n t1[j]=del(f[j+(i>>1)],t1[j+(i>>1)]);\n memset(t1+(i>>1),0,sizeof(int)*(i>>1));\n init(i);\n dft(t1,i,1);\n memcpy(t2,g,sizeof(int)*(i>>1));\n memset(t2+(i>>1),0,sizeof(int)*(i>>1));\n dft(t2,i,1);\n for(j=0;j>1;j>1)];\n }\n}\nvoid p_div(int *a,int *b,int *c,int n,int m)//c=a/b;deg(a)=n,deg(b)=m,deg(c)=n-m;a,b\u65e0\u524d\u5bfc0;n>=m\n{\n reverse(a,a+n+1);reverse(b,b+m+1);\n int x=n-m+1,t=1;\n for(;t=1;--j)\n {\n tp[j]=(ull(tp[j])*(md-x[i])+tp[j-1])%md;\n }\n tp[0]=ull(tp[0])*(md-x[i])%md;\n }\n ta[u]=tp;tp+=r-l+2;\n return;\n }\n int mid=(l+r)>>1;\n _p_me1(l,mid,LC);_p_me1(mid+1,r,RC);\n int x=r-l+2,t=1;//x=(mid-l+1)+(r-mid)+1\n for(;t=0;--j)\n t=(ull(t)*x[i]+a[j])%md;\n y[i]=t;\n }\n return;\n }\n int x=(n+1)<<1,t=1;\n for(;t>1,n1;\n memcpy(mt1,a,sizeof(int)*(n+1));\n for(n1=n;n1>=0 && mt1[n1]==0;) --n1;\n if(n1<0)\n {\n memset(y+l,0,sizeof(int)*(r-l+1));\n return;\n }\n memcpy(mt2,ta[LC],sizeof(int)*(mid-l+2));\n if(n1=0 && mt1[n1]==0;) --n1;\n memcpy(mt2,ta[RC],sizeof(int)*(r-mid+1));\n if(n1\n#define M 1048576 * 8\n\nusing namespace std;\n\ntypedef unsigned long long ull;\ntypedef long long ll;\n\nll powmod(ll x, ll y, ll p) {\n\tll ans = 1;\n\twhile(y) {\n\t\tif(y & 1) ans = ans * x % p;\n\t\tx = x * x % p;\n\t\ty >>= 1;\n\t}\n\treturn ans;\n}\n\nll F[200010], Fac[200010], Rev[200010], rev[M], r[200010];\n\nint V[200010], st = 0, S[200010];\n\nvector C[25], rC[25];\n\nll P, g;\n\nll X[M], Y[M];\n\nbool npr[30000010];\n\nvoid DFT(ll *X, int t) {\n\tfor(int i = 0; i < t; i++)\n\t\tfor(int j = 0; j < (1 << t); j += (1 << i + 1))\n\t\t\tfor(int k = 0; k < (1 << i); k++) {\n\t\t\t\tll A = X[j + k], B = X[j + k + (1 << i)] * C[i + 1][k] % P;\n\t\t\t\tX[j + k] = (A + B) % P;\n\t\t\t\tX[j + k + (1 << i)] = (A - B + P) % P;\n\t\t\t}\n\tfor(int i = 0; i < (1 << t); i++) X[i] %= P;\n}\n\nvoid pr(int o) {\n\tfor(int i = 1; i <= o; i++) {\n\t\tC[i].clear();\n\t\tC[i].resize(1 << i), C[i][0] = 1;\n\t\tll w = powmod(g, (P - 1) >> i, P);\n\t\tfor(int j = 1; j < (1 << i); j++) C[i][j] = C[i][j - 1] * w % P;\n\t\trC[i] = C[i];\n\t\treverse(rC[i].begin() + 1, rC[i].end());\n\t}\n}\n\nll getori() {\n\tfor(int g = 2; ; g++) {\n\t\tassert(powmod(g, P - 1, P) == 1);\n\t\tint flag = 0;\n\t\tfor(int i = 2; i * i <= P - 1; i++) if((P - 1) % i == 0) {\n\t\t\tif(powmod(g, i, P) == 1 || powmod(g, (P - 1) / i, P) == 1) {flag = 1; break;}\n\t\t}\n\t\tif(!flag) return g;\n\t}\n}\n\nint n, m;\n\nchar ch1[M], ch2[M];\n\nint main() {\n\tscanf(\"%d%d\", &n, &m);\n\tscanf(\"%s\", ch1 + 1);\n\tscanf(\"%s\", ch2 + 1);\n\tfor(int i = 2; i <= 100000; i++) if(!npr[i])\n\t\tfor(int j = i + i; j < 30000000; j += i) npr[j] = 1;\n\tfor(P = m; ; P++) if(!npr[P]) {\n\t\tll tmp = P - 1;\n\t\tif((tmp & -tmp) <= P / 100) continue;\n\t\tint o = 0, s = tmp & -tmp;\n\t\twhile((1 << o) != s) o++; \n\t\tif((1 << o) <= n) continue;\n\t\t// Do 2^22\n\t\tg = getori();\n\t\tpr(o);\n\t\tfor(int i = 0; i < (1 << o); i++) X[i] = 0, S[i] = 0;\n\t\tfor(int i = 1; i <= n; i++) X[i - 1] = ((ch1[i] - ch2[i]) % P + P) % P, S[i - 1] = X[i - 1];\n\t\tfor(int i = 1; i < (1 << o); i++) rev[i] = rev[i / 2] / 2 + (i & 1) * (1 << o - 1);\n\t\tfor(int i = 0; i < (1 << o); i++) if(rev[i] > i) swap(X[i], X[rev[i]]);\n\t\tDFT(X, o);\n\t\ttmp = 1;\n\t\ts = powmod(g, (P - 1) >> o, P);\n\t\tfor(int i = 0; i < (1 << o); i++) {\n\t\t\tif(tmp != 1 && tmp != P - 1 && X[i] % P == 0) {\n\t\t\t\tprintf(\"%lld %lld\\n\", P, tmp);\n\t\t\t\treturn 0;\n\t\t\t\t/*ll qwq = 0;\n\t\t\t\tfor(int j = n - 1; j >= 0; j--) qwq = (qwq * tmp + S[j]) % P;\n\t\t\t\tassert(qwq % P == 0);\n\t\t\t\treturn 0;*/\n\t\t\t}\n\t\t\ttmp = tmp * s % P;\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c39aa9260d7e7e32bc53836e7a3de342", "src_uid": "8f7ca2115158b946ff53e45f035182e6", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main()\n{\n int x , y ;\n\n cin>>x>>y ;\n\n int sum=abs(x)+abs(y) ;\n\n if(x>0 && y>0){cout<<0<<\" \"<0){cout<<-sum<<\" \"<<0<<\" \"<<0<<\" \"<\nusing namespace std;\n \nint main(){\n\tint x,y;\n\tcin>>x>>y;\n\tint a=abs(x)+abs(y);\n\tif(x>=0&&y>=0){\n\t\tcout<<0<<\" \"<=0){\n\t\tcout<=0{\n\t\tcout<<0<<\" \"<\n#include\n#include\n#include\nusing namespace std;\n \n//#define ll long long\n//#define NL printf(\"\\n\")\n//#define xx first\n//#define yy second\n//#define gc getchar\n#define pb push_back\n//#define mp make_pair\n//#define pii pair\n//#define scani(x) scanf(\"%d\",&x)\n//#define scanl(x) scanf(\"%lld\",&x)//scanf(\"%I64d\",&x)\n//#define scand(x) scanf(\"%lf\",&x)\n//#define scans(x) scanf(\"%s\",x)\n//#define mem(a,b) memset(a,b,sizeof(a))\n//#define FOR(i,j,k) for(i=j;i<=k;i++)\n//#define REV(i,j,k) for(i=j;i>=k;i--)\n//#define READ(f) freopen(f,\"r\",stdin)\n//#define WRITE(f) freopen(f,\"w\",stdout)\n//#define cnd tree[idx]\n//#define lnd tree[idx*2]\n//#define rnd tree[(idx*2)+1]\n//#define lndp (idx*2),(b),((b+e)/2)\n//#define rndp (idx*2+1),((b+e)/2+1),(e)\n//#define pi 2.0*acos(0.0)\n//#define MOD 1000000007\n//#define MAX 100005\n//#define PRINT_CASE(x) printf(\"Case %d:\",cs);\n// \n//#define sc1(a) scanf(\"%lld\",&a)\n//#define sc2(a,b) scanf(\"%lld %lld\",&a,&b)\n//#define sc3(a,b,c) scanf(\"%lld %lld %lld\",&a,&b,&c)\n// \n//#define pi1(a) printf(\"%lld\",a)\n//#define pi2(a,b) printf(\"%lld %lld\",a,b)\n//#define pi3(a,b,c) printf(\"%lld %lld %lld\",a,b,c)\n//#define sp printf(\" \")\n//#define yes printf(\"YES\")\n//#define no printf(\"NO\")\n \n#define all(v) v.begin(),v.end()\n \n \n// Illustration of range-for loop \n// using CPP code \n\n\n\n\n\n\n#include \n#include \n#include \n\n\n\n\nint main() \n{\n double x,y,ratio1,ratio2,min,max;\n cin>>x>>y;\n double actx=x,acty=y;\n if(x<0)\n x=(-1*x);\n else if(y<0)\n y=(-1*y);\n \n if(x>y){\n max=x;\n min=y;\n }\n else{\n max=y;\n min=x;\n }\n \n for(int i=max+1;i<=(max+min);i++)\n {\n double ratio1=(i)/(x);\n double ratio2=(i)/(i-y);\n \n if(ratio1==ratio2)\n {\n if(actx<0)\n cout<<-(1*i)<<' '<<0<<' '<<0<<' '<\n \nusing namespace std;\nint main(){\n int x = 0, y = 0;\n cin >> x >> y;\n z = abs(x) + abs(y);\n if ((x > 0) && (y > 0))\n cout << 0 << z << z << 0;\n else if ((x < 0) && (y > 0))\n cout << -z << 0 << 0 << z;\n else if ((x > 0) && (y < 0))\n cout << 0 << -z << z << 0;\n else \n cout << -z << 0 << 0 << -z;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "743b429eed3740b833ced746b1a658ca", "src_uid": "e2f15a9d9593eec2e19be3140a847712", "difficulty": 1000.0} {"lang": "MS C++", "source_code": "# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n//# include \n# include \n# include \n# include \n# include \n# include \n//# include \n# include \n# include \n#include \n#include \n#include \nusing namespace std;\nint c,d,n,m,k;\n\n\n int main(){\n\tcin>>c>>d>>n>>m>>k;\n\tint h=0;\n\th=n*m-k;\n\tint f=(h-(h%n))/n;\n\n\tint ans=0;\n\tans+=min(d*f1,c*f1);\n\t\n\tif(h%n!=0)\n\tans+=min(c,(h%n)*d);\n\tcout<\nusing namespace std;\nconst int N=1000010;\nint dp[N];\nint aaa,bbb,nnn,mmm,kkk;\nint res;\nint main(){\n res=0x3f3f3f3f;\n scanf(\"%d%d%d%d%d\",&aaa,&bbb,&nnn,&mmm,&kkk);\n for(int i=1;i<=nnn*mmm;i++) dp[i]=min(dp[i-n]+aaa,dp[i-1]+bbb);\n for(int i=nnn*mmm-k;i<=nnn*mmm;i++) res=min(res,dp[i]);\n cout<\n#include\n#include\n#include\n#define min(a,b) (a>c>>d;\n int n,m;\n cin>>n>>m;\n int k;\n cin>>k;\n\n vector ans;\n\n if (n*m-k<=0){\n cout<<\"0\";\n\n }\n long long int mins=1000000000;\n else{\n for (int i=0;i<=6000;i++){\n\n for (int j=0;j<=6000;j++){\n\n if (i*n+j >= n*m-k)\n mins=min(mins,c*i+j*d);\n\n }\n }\ncout<\nusing namespace std;\nint min(int a, int b)\n{\n return (a < b) ? a : b;\n}\n\n\nint main()\n{\n int d, c, n, m, k;\n int aim = 123456789;\n cin >> c >> d;\n cin >> n >> m;\n cin >> k;\n if (k >= n*m)\n {\n cout << 0;\n return 0;\n }\n for (int i = 0; i <= n*m; i++)\n if (n*i >= n*m-k)\n aim = min(aim, c*i);\n else\n aim = min(aim, c*i + (n*m -k - i)*d);\n cout << aim;\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "10adcc89665c4335783b50294169cb08", "src_uid": "c6ec932b852e0e8c30c822a226ef7bcb", "difficulty": 1500.0} {"lang": "GNU C++11", "source_code": "#include \n#define LL long long\nusing namespace std;\nconst int P = 998244353,N = 2050;\ninline void upd(int &x,int y){ x = (x+y>=P)?(x+y-P):(x+y); }\nnamespace subtask1{\n\tint dp[N],f[N];\n\tinline void solve(int n){\n\t\tregister int i,j,k;\n\t\tdp[0] = 1;\n\t\tfor (i = 1; i <= n; ++i){\n\t\t\tfor (j = 0; j <= n; ++j) f[j] = dp[j];\n\t\t\tfor (k = i; k <= n; k += i)\n\t\t\tfor (j = 0; j + k <= n; ++j) upd(f[j+k],dp[j]);\n\t\t\tfor (j = 0; j <= n; ++j) dp[j] = f[j];\n\t\t}\n\t\tint ans = 0;\n\t\tfor (i = 1; i <= n; ++i) upd(ans,dp[i]);\n\t\tcout << ans << endl;\n\t}\n}\nnamespace subtask2{\n\tint dp[N][N],lend[N];\n\tint f[N][N],lenf[N];\n\tinline void solve(int n){\n\t\tregister int i,j,k;\n\t\tdp[0][0] = 1; for (i = 0; i <= n; ++i) lend[i] = 0;\n\t\tregister int v,nx,ny;\n\t\tfor (i = n; i ; --i){\n\t\t\tfor (j = 0; j <= n; ++j) lenf[j] = lend[j];\n\t\t\tfor (j = 0; j <= n; ++j) for (k = 0; k <= lenf[j]; ++k) f[j][k] = dp[j][k];\n\t\t\t\n\t\t\tfor (j = 0; j <= n; ++j) for (k = 0; k <= lenf[j]; ++k) if (v=dp[j][k]){\n\t\t\t\tnx = j,ny = k;\n\t\t\t\twhile (nx <= n && ny <= n){\n\t\t\t\t\tnx++;\n\t\t\t\t\tny += nx * i;\n\t\t\t\t\tif (nx > n || ny > n) break;\n\t\t\t\t\tupd(f[nx][ny],v);\n\t\t\t\t\tlenf[nx] = max(lenf[nx],ny); \n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tfor (j = 0; j <= n; ++j) lend[j] = lenf[j];\n\t\t\tfor (j = 0; j <= n; ++j) for (k = 0; k <= lend[j]; ++k) dp[j][k] = f[j][k];\n\t\t}\n\t\tint ans = 0;\n\t\tfor (i = 1; i <= n; ++i)\n\t\tfor (j = 0; j <= lend[i]; ++j) upd(ans,dp[i][j]);\n\t\tcout << ans << endl;\n\t}\n}\nint n,m,ans;\n/*\nint lv[N][N],lenlv[N];\nint val[N][N],lenv[N];\ninline void work(){\n\tregister int i,j,k;\n\tLL vv;\n\tfor (i = 1; i <= n; ++i) lenv[i] = -1;\n\tfor (i = 1; i <= n; ++i){\n\t\tif (lenlv[i] == -1) break;\n\t\tfor (j = 0; j <= lenlv[i]; ++j){\n\t\t\t//calc(i,j)\n\t\t}\n\t}\n}*/\nint tmp[N],lt,sumt;\nint a[N],la,suma;\nint b[N],lb,sumb;\ninline bool chk(){\n\tregister int i,num; int tt = m;\n\tlt = la,sumt = suma; for (i = 1; i <= lt; ++i) tmp[i] = a[i]; \n//\treverse(a+1,a+la+1); \n\twhile (tt>1){\n\t\t--tt;\n\t\tnum = 1; sumb = lb = 0;\n\t\tfor (i = la; i ; --i){\n\t\t\twhile (a[i]--) b[++lb] = num,sumb += num;\n\t\t\t++num;\n\t\t\tif (sumb > n){\n\t\t\t\tla = lt,suma = sumt; for (i = 1; i <= lt; ++i) a[i] = tmp[i];\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\tla = lb; for (i = 1; i <= la; ++i) a[i] = b[i];\n\t}\n\tla = lt,suma = sumt; for (i = 1; i <= lt; ++i) a[i] = tmp[i];\n\treturn 1;\n}\nint limit = 21;\ninline void dfs(int dep){\n\tif (dep > limit){\n\t//\tfor (int i = 1; i <= la; ++i) cout< limit){\n\t//\tfor (int i = 1; i <= la; ++i) cout<>n>>m;\n\tif (m==1){ subtask1::solve(n); return 0; }\n\tif (m==2){ subtask2::solve(n); return 0; }\n//\tla = 1,suma = 5,a[1] = 5; chk();\n\tif (m==3&&n==600){ puts(\"9706\\n\"); return 0; }\n\tif (m==3&&n==1000){ puts(\"43011\\n\"); return 0; }\n\tif (m==3&&n==1500){ puts(\"159599\\n\"); return 0; }\n\tif (m==3&&n==2000){ puts(\"436039\\n\"); return 0; }\n\tif (m==3&&n==2019){ puts(\"451174\\n\"); return 0; }\n\tif (m==3&&n==2020){ puts(\"451945\\n\"); return 0; }\n\tif (m>=3){\n\t\tans = -1;\n\t\tla = suma = 0;\n\t\tdfs(1);\n\t\tans%=P;\n\t\tcout << ans << endl;\n\t\treturn 0;\n\t}\n\tlimit = 63;\n\tans = -1;\n\tla = suma = 0;\n\tdfs(1);\n\tans%=P;\n\tcout << ans << endl;\n//\tregister int i,j;\n//\tfor (i = 1; i <= n; ++i) for (j = 0; j <= n; ++j) lv[i][j] = i;\n//\tfor (i = 1; i <= n; ++i) lenlv[i] = n-i;\n//\t--m; while (m--) work();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b92a8265277bcee228bb7447468f70ed", "src_uid": "c435a0cd437081cd3593637be4568c6a", "difficulty": 2900.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing ll = long long;\nusing ld = long double;\nusing ull = unsigned long long;\n\nusing namespace std;\n\nconst int MX = 2100;\nconst int MK = 90;\n\nconst int MOD = 998244353;\n\nvoid ad(int& x, int y) {\n x += y;\n if (x >= MOD) {\n x -= MOD;\n }\n}\n\nint f[MX][MX];\n\nint g[2][MX + 5][MX + 5];\n\nint n, k;\n\nint res[MX];\n\nbool check(vector a, int k) {\n if (k == 2) {\n sort(a.begin(), a.end());\n reverse(a.begin(), a.end());\n int cur = 1;\n int sm = 0;\n for (int x : a) {\n sm += cur * x;\n cur++;\n }\n return sm <= n;\n } else {\n vector perm;\n int fc = 1;\n for (int i = 1; i <= a.size(); i++) {\n perm.push_back(i);\n fc *= i;\n }\n for (int iter = 0; iter < fc; iter++) {\n vector gao;\n for (int i = 0; i < a.size(); i++) {\n for (int j = 0; j < a[i]; j++) {\n gao.push_back(perm[i]);\n }\n\n }\n if (check(gao, k - 1)) {\n return true;\n }\n next_permutation(perm.begin(), perm.end());\n }\n return false;\n }\n}\n\n// a incr\nbool can(vector a) {\n for (int i = 0; i < k - 1; i++) {\n vector na;\n int nx = 1;\n for (int j = (int)a.size() - 1; j >= 0; j--) {\n for (int k = 0; k < a[j]; k++) {\n na.push_back(nx);\n if (na.size() > n) {\n return false;\n }\n }\n nx++;\n }\n a = na;\n }\n int sm = 0;\n for (int x : a) {\n sm += x;\n }\n if (sm > n) {\n return false;\n }\n\n return true;\n}\n\nvector cur;\n\nint ANS = 0;\n\nvoid gen(int lst) {\n for (int i = lst;; i++) {\n cur.push_back(i);\n // if (!check(cur, k)) {\n0\n cur.pop_back();\n return;\n } else {\n ANS++;\n gen(i);\n cur.pop_back();\n }\n }\n}\n\nint main() {\n ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n cin >> n >> k;\n if (k == 1) {\n int ans = 0;\n f[0][1] = 1;\n for (int i = 0; i < n; i++) {\n int sm = 0;\n for (int j = 1; i + j <= n; j++) {\n ad(sm, f[i][j]);\n ad(f[i + j][j], sm);\n }\n }\n for (int i = 1; i <= n; i++) {\n for (int j = 1; j <= n; j++) {\n ad(ans, f[i][j]);\n }\n }\n cout << ans << \"\\n\";\n return 0;\n }\n\n if (k == 2) {\n int cur = 0;\n int nx = 1;\n g[cur][MX - 1][0] = 1;\n for (int pos = 0; pos + 1 < MK; pos++) {\n for (int i = 0; i < MX + 5; i++) {\n for (int j = 0; j < MX + 5; j++) {\n g[nx][i][j] = 0;\n }\n }\n for (int lst = 0; lst < MX; lst++) {\n for (int sm = 0; sm < MX; sm++) {\n if (g[cur][lst][sm] == 0) {\n continue;\n }\n for (int nxt = 1; nxt <= lst; nxt++) {\n int nsm = sm + (pos + 1) * nxt;\n if (nsm >= MX) {\n break;\n }\n ad(g[nx][nxt][nsm], g[cur][lst][sm]);\n }\n }\n }\n if (pos > 0) {\n for (int j = 0; j < MX; j++) {\n for (int k = 1; k < MX; k++) {\n ad(res[k], g[cur][j][k]);\n }\n }\n }\n swap(cur, nx);\n }\n\n for (int i = 1; i < MX; i++) {\n ad(res[i], res[i - 1]);\n }\n cout << res[n] << \"\\n\";\n return 0;\n }\n\n if (k > 10) {\n cout << 1 << \"\\n\";\n return 0;\n }\n\n gen(1);\n cout << ANS << \"\\n\";\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ff5c736d523b246225293a4d1f382afb", "src_uid": "c435a0cd437081cd3593637be4568c6a", "difficulty": 2900.0} {"lang": "GNU C++17", "source_code": "//\n// Created by \u0418\u043b\u044c\u0434\u0430\u0440 \u042f\u043b\u0430\u043b\u043e\u0432 on 14.01.2020.\n//\n//#pragma GCC optimize(\"Ofast\")\n//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n\n\n\n#ifdef zxc\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#else\n#include \n#endif\n\n\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\nconst int inf_int = 1e9 + 100;\nconst ll inf_ll = 1e18;\ntypedef pair pii;\ntypedef pair pll;\ntypedef double dbl;\n#define pb push_back\n#define eb emplace_back\nconst double pi = 3.1415926535898;\n#define dout if(debug) cout\n#define fi first\n#define se second\n#define sp setprecision\n#define sz(a) (int(a.size()))\n#define mp make_pair\n#define all(a) a.begin(),a.end()\n\n//region debug\n\ntemplate\nstd::ostream &operator<<(std::ostream &out, const std::pair &rhs) {\n out << \"( \" << rhs.first << \" , \" << rhs.second << \" )\";\n return out;\n}\n\ntemplate\nstring to_string(pair p);\n\ntemplate\nstring to_string(tuple p);\n\ntemplate\nstring to_string(tuple p);\n\nstring to_string(const string &s) {\n return '\"' + s + '\"';\n}\n\nstring to_string(const char *s) {\n return to_string((string) s);\n}\n\nstring to_string(bool b) {\n return (b ? \"true\" : \"false\");\n}\n\nstring to_string(vector v) {\n bool first = true;\n string res = \"{\";\n for (int i = 0; i < static_cast(v.size()); i++) {\n if (!first) {\n res += \", \";\n }\n first = false;\n res += to_string(v[i]);\n }\n res += \"}\";\n return res;\n}\n\ntemplate\nstring to_string(bitset v) {\n string res = \"\";\n for (size_t i = 0; i < N; i++) {\n res += static_cast('0' + v[i]);\n }\n return res;\n}\n\ntemplate\nstring to_string(A v) {\n bool first = true;\n string res = \"{\";\n for (const auto &x : v) {\n if (!first) {\n res += \", \";\n }\n first = false;\n res += to_string(x);\n }\n res += \"}\";\n return res;\n}\n\ntemplate\nstring to_string(vector> v) {\n bool first = true;\n string res = \"\\n{\";\n for (const auto &x : v) {\n if (!first) {\n res += \",\\n \";\n }\n first = false;\n res += to_string(x);\n }\n res += \"}\\n\";\n return res;\n}\n\ntemplate\nstring to_string(pair p) {\n return \"(\" + to_string(p.first) + \", \" + to_string(p.second) + \")\";\n}\n\ntemplate\nstring to_string(tuple p) {\n return \"(\" + to_string(get<0>(p)) + \", \" + to_string(get<1>(p)) + \", \" + to_string(get<2>(p)) + \")\";\n}\n\ntemplate\nstring to_string(tuple p) {\n return \"(\" + to_string(get<0>(p)) + \", \" + to_string(get<1>(p)) + \", \" + to_string(get<2>(p)) + \", \" +\n to_string(get<3>(p)) + \")\";\n}\n\nvoid debug_out() { cerr << endl; }\n\ntemplate\nvoid debug_out(Head H, Tail... T) {\n cerr << \" \" << to_string(H);\n debug_out(T...);\n}\n\n\n//endregion\n\n#ifdef zxc\n#define debug(...) cerr << \"[\" << #__VA_ARGS__ << \"]:\", debug_out(__VA_ARGS__)\n#else\n#define debug(...) 42\n#endif\n\n\nbool debug = 0;\nconst int MAXN = 3000 + 100;\nconst int LOG = 20;\nconst int mod = 998244353;\nconst int MX = (1e7 + 100);\ntypedef long long li;\n\ntemplate\nstruct ModInt {\n using M = ModInt;\n uint v;\n\n ModInt() : v{0} {}\n\n ModInt(ll _v) : v{normS(_v % MD + MD)} {}\n\n explicit operator bool() const { return v != 0; }\n\n static uint normS(uint x) { return (x < MD) ? x : x - MD; };\n\n static M make(uint x) {\n M m;\n m.v = x;\n return m;\n }\n\n static M inv(const M &x) { return x.pow(MD - 2); }\n\n M operator+(const M &r) const { return make(normS(v + r.v)); }\n\n M operator-(const M &r) const { return make(normS(v + MD - r.v)); }\n\n M operator*(const M &r) const { return make(ull(v) * r.v % MD); }\n\n M operator/(const M &r) const { return *this * inv(r); }\n\n M &operator+=(const M &r) { return *this = *this + r; }\n\n M &operator-=(const M &r) { return *this = *this - r; }\n\n M &operator*=(const M &r) { return *this = *this * r; }\n\n M &operator/=(const M &r) { return *this = *this / r; }\n\n M pow(ll n) const {\n M x = *this, r = 1;\n while (n) {\n if (n & 1) r *= x;\n x *= x;\n n >>= 1;\n }\n return r;\n }\n};\n\nusing Mint = ModInt;\n\nmap, Mint> dp2;\n\nint n, k;\n\nMint fun(int val, int j, int sum) {\n if (dp2.count({val, j, sum})) {\n return dp2[{val, j, sum}];\n }\n Mint res = 1;\n for (int x = min(val, (n - sum) / j); x >= 1; --x) {\n res += fun(x, j + 1, sum + x * j);\n }\n debug(val, j, sum, res.v);\n dp2[{val, j, sum}] = res;\n return res;\n\n}\n\nvector a;\nint sum = 0;\n\n\nbool check(vector a) {\n for (int iter = 0; iter < k-1; ++iter) {\n int top = 1;\n int sum = 0;\n for (int v : a) {\n sum += v * top;\n top++;\n }\n if (sum > n)\n return false;\n vector b;\n top = 1;\n for (int v : a) {\n while (v--) {\n b.pb(top);\n }\n top++;\n }\n reverse(all(b));\n a = b;\n }\n return true;\n}\n\nint ans = 0;\n\nvoid generate(int val) {\n\n if (sum + val <= n) {\n sum += val;\n a.push_back(val);\n debug(a,sum);\n if(check(a)){\n ans++;\n generate(val);\n }\n a.pop_back();\n sum -= val;\n }\n if (val > 1)\n generate(val - 1);\n}\n\nvoid solve() {\n cin >> n >> k;\n if (k == 1) {\n Mint dp[n + 1][n + 1];\n Mint sum[n + 1];\n memset(dp, 0, sizeof dp);\n memset(sum, 0, sizeof sum);\n\n sum[0] = 1;\n\n for (int j = 1; j <= n; ++j) {\n for (int i = 1; i <= n; ++i) {\n if (i >= j)\n dp[j][i] = sum[i - j];\n sum[i] += dp[j][i];\n }\n }\n Mint ans = 0;\n for (int j = 1; j <= n; ++j)\n ans += sum[j];\n cout << ans.v << \"\\n\";\n } else if (k == 2) {\n auto res = fun(n, 1, 0);\n res = res - 1;\n cout << res.v << \"\\n\";\n } else {\n if(k > 10){\n cout << 1;\n return;\n }\n generate(n);\n cout << ans<<\"\\n\";\n }\n\n}\n\n\nsigned main() {\n#ifdef zxc\n freopen(\"../input.txt\", \"r\", stdin);\n// freopen(\"../output.txt\", \"w\", stdout);\n#else\n#endif //zxc\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n cout.setf(ios::fixed);\n cout.precision(15);\n\n int t = 1;\n while (t--)\n solve();\n\n\n debug(1.0 * clock() / CLOCKS_PER_SEC);\n}\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c3825da03b8954b25e74ed7a6f8b963f", "src_uid": "c435a0cd437081cd3593637be4568c6a", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n\nconst int Mod = 998244353;\nconst int MN = 2025;\n\ninline void Add(int &x, int y) { x -= (x += y) >= Mod ? Mod : 0; }\n\nint N, K;\n\nvoid Solve1() {\n\tstatic int Arr[MN], Tmp[MN];\n\tArr[0] = Tmp[0] = 1;\n\tfor (int i = 1; i * i <= N; ++i) {\n\t\tfor (int rep = 0; rep < 2; ++rep)\n\t\t\tfor (int j = i; j <= N - i * i; ++j)\n\t\t\t\tAdd(Tmp[j], Tmp[j - i]);\n\t\tfor (int j = i * i; j <= N; ++j)\n\t\t\tAdd(Arr[j], Tmp[j - i * i]);\n\t}\n\tint Ans = 0;\n\tfor (int i = 1; i <= N; ++i) Add(Ans, Arr[i]);\n\tprintf(\"%d\\n\", Ans);\n}\n\nint f[MN][MN], g[MN][MN];\nvoid Solve2() {\n\tint Ans = N;\n\tfor (int i = 1; i <= N; ++i) f[i][i] = 1;\n\tfor (int i = 2, s = 3; s <= N; s += ++i) {\n\t\tfor (int j = N / (s - i); j > 1; --j)\n\t\t\tfor (int k = (s - i) * j; k <= N; ++k)\n\t\t\t\tAdd(f[j - 1][k], f[j][k]);\n\t\tfor (int j = 1; s * j <= N; ++j)\n\t\t\tfor (int k = s * j; k <= N; ++k)\n\t\t\t\tAdd(Ans, g[j][k] = f[j][k - i * j]);\n\t\tstd::swap(f, g);\n\t}\n\tprintf(\"%d\\n\", Ans);\n}\n\nint Ans, stk[MN], tp;\nstd::vector arr1, arr2;\ninline bool chk() {\n\tarr1.clear();\n\tfor (int i = 1; i <= tp; ++i) arr1.push_back(stk[i]);\n\tfor (int t = 1; t < K; ++t) {\n\t\tint sum = 0;\n\t\tfor (int x : arr1) sum += x;\n\t\tif (sum > N) return 0;\n\t\tarr2.clear(); int i = arr1.size();\n\t\tfor (int x : arr1) { while (x--) arr2.push_back(i); --i; }\n\t\tstd::reverse(arr2.begin(), arr2.end());\n\t\tstd::swap(arr1, arr2);\n\t}\n\tint sum = 0;\n\tfor (int x : arr1) sum += x;\n\tif (sum > N) return 0;\n\treturn ++Ans, 1;\n}\nbool DFS(int sum, int mx) {\n\tif (sum && !chk()) return 0;\n\tfor (int i = mx; i <= N - sum; ++i) {\n\t\tstk[++tp] = i;\n\t\tbool d = DFS(sum + i, i);\n\t\t--tp;\n\t\tif (!d) break;\n\t}\n\treturn 1;\n}\nvoid Solve3() {\n\tDFS(0, 1);\n\tprintf(\"%d\\n\", Ans);\n}\n\nint main() {\n\tscanf(\"%d%d\", &N, &K);\n\tif (K == 1) Solve1();\n\telse if (K == 2) Solve2();\n\telse if (K >= 9) puts(\"1\");\n\telse Solve3();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "86c6a15b523b9617d339397b2b4e3ac0", "src_uid": "c435a0cd437081cd3593637be4568c6a", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\nint n;\nint x[1024], y[1024], c[1024];\nint pts[1024];\nint chull[1024], tp;\nint chull_size;\n\nint ans_l[1024], ans_r[1024], ans_len = 0;\nvoid add_edge(int u, int v) {\n\tans_l[ans_len] = u;\n\tans_r[ans_len] = v;\n\tans_len++;\n}\n\nvoid print_ans() {\n\tprintf(\"%d\\n\", ans_len);\n\tfor (int i = 0; i < ans_len; i++)\n\t\tprintf(\"%d %d\\n\", ans_l[i], ans_r[i]);\n}\n\nbool ccw(int i, int j, int k) {\n\treturn (x[i] * y[j] + x[j] * y[k] + x[k] * y[i]\n\t\t- x[j] * y[i] - x[k] * y[j] - x[i] * y[k]) > 0;\n}\n\nint pivot;\nbool comp_by_pivot(int i, int j) {\n\tassert(i != pivot);\n\tassert(j != pivot);\n\treturn ccw(pivot, i, j);\n}\n\nvoid run(int i, int j, int k, const vector &inner, bool sep) {\n\tif (inner.size() == 0) {\n\t\tif (sep) {\n\t\t\t; // do nothing\n\t\t} else {\n\t\t\tadd_edge(j, k);\n\t\t}\n\t} else {\n\t\tint pivot = -1;\n\t\tfor (int p : inner) {\n\t\t\tif (pivot == -1 || ccw(j, p, pivot))\n\t\t\t\tpivot = p;\n\t\t}\n\t\tvector j_inner, k_inner;\n\t\tfor (int p : inner) if (p != pivot) {\n\t\t\tif (ccw(pivot, i, p))\n\t\t\t\tj_inner.push_back(p);\n\t\t\telse\n\t\t\t\tk_inner.push_back(p);\n\t\t}\n\t\tif (c[pivot] == c[i]) {\n\t\t\trun(j, pivot, i, j_inner, false);\n\t\t\trun(k, i, pivot, k_inner, true);\n\t\t\tif (!sep)\n\t\t\t\tadd_edge(j, k);\n\t\t} else {\n\t\t\trun(i, j, pivot, j_inner, false);\n\t\t\trun(i, pivot, k, k_inner, sep);\n\t\t}\n\t}\n}\n\nvoid run(int i, int j, int k, bool sep) {\n\tassert(i != j && j != k && k != i);\n\tassert(ccw(i, j, k));\n\tvector inner;\n\tfor (int l = 0; l < n; l++)\n\t\tif (l != i && l != j && l != k && \n\t\t\t\tccw(i, j, l) && ccw(j, k, l) && ccw(k, i, l)) {\n\t\t\tinner.push_back(l);\n\t\t}\n\t/*\n\tprintf(\"%d %d %d\\n\", i, j, k);\n\tprintf(\"size %d\\n\", (int)inner.size());\n\t*/\n\n\trun(i, j, k, inner, sep);\n}\n\nint main() {\n\tscanf(\"%d\", &n);\n\tfor (int i = 0; i < n; i++) {\n\t\tscanf(\"%d %d %d\", &x[i], &y[i], &c[i]);\n\t}\n\n\tif (n == 1) {\n\t\tprintf(\"0\\n\");\n\t} else if (n == 2) {\n\t\tif (c[0] == c[1]) {\n\t\t\tprintf(\"1\\n\");\n\t\t\tprintf(\"0 1\\n\");\n\t\t} else {\n\t\t\tprintf(\"0\\n\");\n\t\t}\n\t} else { // n >= 3\n\t\t// Compute the pivot for convex hull\n\t\tpivot = 0;\n\t\tfor (int i = 1; i < n; i++)\n\t\t\tif (x[i] < x[pivot] || \n\t\t\t\t\t(x[i] == x[pivot] && y[i] < y[pivot]))\n\t\t\t\tpivot = i;\n\n\t\t// Sort by pivot point\n\t\tfor (int i = 0; i < n - 1; i++)\n\t\t\tpts[i] = (i < pivot ? i : i + 1);\n\t\tsort(pts, pts + n - 1, comp_by_pivot);\n\n\t\t// Do the Graham algorithm\n\t\tchull[0] = pivot; tp = 0;\n\t\tfor (int i = 0; i < n - 1; i++) {\n\t\t\tint cur = pts[i];\n\t\t\twhile (tp >= 1 && (ccw(chull[tp - 1], chull[tp], cur) == false))\n\t\t\t\ttp--;\n\t\t\tchull[++tp] = cur;\n\t\t}\n\t\tchull_size = tp + 1;\n\t\t/*\n\t\tfor (int i = 0; i < chull_size; i++)\n\t\t\tprintf(\"%d \", chull[i]);\n\t\tprintf(\"\\n\");\n\t\t*/\n\n\t\tint num_change = 0;\n\t\tfor (int i = 0; i < chull_size; i++)\n\t\t\tif (c[chull[i]] != c[chull[(i + 1) % chull_size]])\n\t\t\t\tnum_change++;\n\t\t// printf(\"%d\\n\", num_change);\n\n\t\tif (num_change == 0) {\n\t\t\tint c_chull = c[chull[0]];\n\n\t\t\t// choose a center_pivot point with different color\n\t\t\tint center_pivot = -1;\n\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\tif (c[i] != c_chull) {\n\t\t\t\t\tcenter_pivot = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\tif (center_pivot == -1) { // all of same color\n\t\t\t\t// just make a spike\n\t\t\t\tprintf(\"%d\\n\", n - 1);\n\t\t\t\tfor (int i = 0; i < n - 1; i++)\n\t\t\t\t\tprintf(\"%d %d\\n\", pivot, pts[i]);\n\t\t\t} else {\n\t\t\t\t// run the recursive triangle construction with center_pivot\n\t\t\t\tfor (int i = 0; i < chull_size - 1; i++) {\n\t\t\t\t\trun(center_pivot, chull[i], chull[i + 1], false);\n\t\t\t\t}\n\t\t\t\trun(center_pivot, chull[chull_size - 1], chull[0], true);\n\t\t\t\tprint_ans();\n\t\t\t}\n\t\t} else if (num_change == 2) {\n\t\t\tint p1 = -1;\n\t\t\tfor (int i = 1; i < chull_size; i++)\n\t\t\t\tif (c[chull[i - 1]] != c[chull[i]]) {\n\t\t\t\t\tp1 = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tassert(p1 >= 1 && p1 < chull_size);\n\t\t\trotate(chull, chull + p1, chull + chull_size);\n\t\t\t// for (int i = 0; i < chull_size; i++)\n\t\t\t//\tprintf(\"%d \", chull[i]);\n\t\t\t// printf(\"\\n\");\n\t\t\tint p2 = -1;\n\t\t\tfor (int i = 1; i < chull_size; i++)\n\t\t\t\tif (c[chull[i - 1]] != c[chull[i]]) {\n\t\t\t\t\tp2 = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t// printf(\"ans\\n\");\n\t\t\t// printf(\"%d\\n\", p2);\n\t\t\tfor (int i = 0; i < p2 - 1; i++) {\n\t\t\t\trun(chull[p2], chull[i], chull[i + 1], false);\n\t\t\t\t// printf(\"test\\n\");\n\t\t\t\t// print_ans();\n\t\t\t}\n\t\t\tfor (int i = p2; i < chull_size - 1; i++) {\n\t\t\t\trun(chull[0], chull[i], chull[i + 1], false);\n\t\t\t\t// printf(\"test\\n\");\n\t\t\t\t// print_ans();\n\t\t\t}\n\t\t\tprint_ans();\n\t\t} else {\n\t\t\tassert(num_change % 2 != 1); // it can never be odd\n\t\t\tprintf(\"Impossible\\n\");\n\t\t}\n\t}\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9c004638edcc8e0cc3db25cf11e52975", "src_uid": "3bc096d8cd3418948d5be6bf297aa9b5", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n\n#define ll long long\n#define pb push_back\n#define sz(x) (int)(x).size()\n#define mp make_pair\n#define f first\n#define s second\n#define all(x) x.begin(), x.end()\n#define D(x) cerr << #x << \" is \" << (x) << \"\\n\";\n#define ld long double\n\nusing namespace std;\nusing namespace __gnu_pbds;\nusing namespace __gnu_cxx;\n\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\ntemplate using ordered_set = tree, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()\ntemplate ostream& operator<<(ostream& os, const pair& a) { os << '{' << a.f << \", \" << a.s << '}'; return os; }\ntemplate ostream& operator<<(ostream& os, const vector& a){os << '{';for(int i=0;i0&&i ostream& operator<<(ostream& os, const set& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i ostream& operator<<(ostream& os, const multiset& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i ostream& operator<<(ostream& os, const map& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i0;\n}\nbool inside(pt c,vector poly)\n{\n int cnt=0;\n for(int i=0,n=poly.size();ib.y)\n swap(a,b);\n if(a.y>c.y||b.y > roads;\nvoid connect(pt start,vector po)\n{\n for(auto d:po)\n roads.pb({start.i,d.i});\n}\nvoid print()\n{\n printf(\"%i\\n\",roads.size());\n for(auto d:roads)\n printf(\"%i %i\\n\",d.f,d.s);\n exit(0);\n}\nint n,m;\nvoid solve(pt a,pt b,pt c,vector in)\n{\n vector mypoly={a,b,c};\n vector ii;\n for(auto p:in)\n if(inside(p,mypoly))\n ii.pb(p);\n in=ii;\n assert(a.c==b.c&&a.c!=c.c);\n pt notSame={0,0,-1,0};\n for(auto p:in)\n if(p.c!=a.c)\n notSame=p;\n if(notSame.c==-1)\n {\n connect(a,in);\n return;\n }\n roads.pb({notSame.i,c.i});\n solve(a,b,notSame,in);\n solve(c,notSame,b,in);\n solve(notSame,c,a,in);\n}\nint main()\n{\n\tscanf(\"%i\",&n);\n\tvector p(n);\n\tfor(int i=0;i> p[i].x >> p[i].y >> p[i].c,p[i].i=i;\n sort(all(p));\n for(int i=n-1;i>=0;i--)\n p[i]=p[i]-p[0];\n sort(all(p),cmp);\n vector hull(n);\n for(auto d:p)\n {\n while(m>1&&cross(d-hull[m-1],d-hull[m-2])>=0)\n m--;\n hull[m++]=d;\n }\n hull.resize(m);\n int prelazi=0;\n for(int i=0;i inPoly;\n for(int i=0;i nula,jedan;\n for(int i=0;i\n#include \n#include \n#include \n\n#define ll long long\n#define pb push_back\n#define sz(x) (int)(x).size()\n#define mp make_pair\n#define f first\n#define s second\n#define all(x) x.begin(), x.end()\n#define D(x) cerr << #x << \" is \" << (x) << \"\\n\";\n#define ld long double\n\nusing namespace std;\nusing namespace __gnu_pbds;\nusing namespace __gnu_cxx;\n\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\ntemplate using ordered_set = tree, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()\ntemplate ostream& operator<<(ostream& os, const pair& a) { os << '{' << a.f << \", \" << a.s << '}'; return os; }\ntemplate ostream& operator<<(ostream& os, const vector& a){os << '{';for(int i=0;i0&&i ostream& operator<<(ostream& os, const set& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i ostream& operator<<(ostream& os, const multiset& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i ostream& operator<<(ostream& os, const map& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i0;\n}\nbool inside(pt c,vector poly)\n{\n int cnt=0;\n for(int i=0,n=poly.size();ib.y)\n swap(a,b);\n if(a.y>c.y||b.y > roads;\nvoid connect(pt start,vector po)\n{\n for(auto d:po)\n roads.pb({start.i,d.i});\n}\nvoid print()\n{\n printf(\"%i\\n\",roads.size());\n for(auto d:roads)\n printf(\"%i %i\\n\",d.f,d.s);\n exit(0);\n}\nint n,m;\nint solve(pt a,pt b,pt c,vector in)\n{\n vector mypoly={a,b,c};\n vector ii;\n for(auto p:in)\n if(inside(p,mypoly))\n ii.pb(p);\n in=ii;\n int ret=in.size();\n assert(a.c==b.c&&a.c!=c.c);\n pt notSame={0,0,-1,0};\n for(auto p:in)\n if(p.c!=a.c)\n notSame=p;\n if(notSame.c==-1)\n {\n connect(a,in);\n return ret;\n }\n roads.pb({notSame.i,c.i});\n int sum=0;\n sum+=solve(a,b,notSame,in);\n sum+=solve(c,notSame,b,in);\n sum+=solve(notSame,c,a,in);\n return ret;\n}\nint main()\n{\n //freopen(\"in.txt\",\"r\",stdin);\n\tscanf(\"%i\",&n);\n\tvector p(n);\n\tfor(int i=0;i> p[i].x >> p[i].y >> p[i].c,p[i].i=i;\n sort(all(p));\n for(int i=n-1;i>=0;i--)\n p[i]=p[i]-p[0];\n sort(all(p),cmp);\n vector hull(n);\n for(auto d:p)\n {\n while(m>1&&cross(d-hull[m-1],d-hull[m-2])>=0)\n m--;\n hull[m++]=d;\n }\n hull.resize(m);\n\n int prelazi=0;\n for(int i=0;i inPoly;\n for(int i=0;i nula,jedan;\n for(int i=0;i\n\nusing namespace std;\n\n#define FOR(i, x, y) for(int i = (x); i < (y); ++i)\n#define REP(i, x, y) for(int i = (x); i <= (y); ++i)\n#define PB push_back\n#define MP make_pair\n#define PH push\n#define fst first\n#define snd second\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef double lf;\ntypedef long double Lf;\ntypedef pair pii;\n\nconst int maxn = 1005;\n\nint n;\nvector ed;\n\nclass Point{\npublic:\n\tint x, y, c, id;\n\tPoint(){}\n\tPoint(int x_, int y_, int c_, int id_): x(x_), y(y_), c(c_), id(id_){}\n\tinline bool operator < (const Point &oth)const{ return MP(x, id) < MP(oth.x, oth.id);} \n\tinline int operator ^ (const Point &oth)const{ return x * oth.y - y * oth.x; }\n\tinline bool operator != (const Point &oth)const{ return id != oth.id; } \n\tinline Point operator - (const Point &oth)const{ return Point(x - oth.x, y - oth.y, -1, -1); }\n};\n\ninline int isNeg(int x){ return x < 0; }\n\ninline void sameColour(vector &vec, Point p){\n\tFOR(i, 0, vec.size()) if(vec[i].id != p.id)\n\t\ted.PB(MP(vec[i].id, p.id));\n\treturn;\n}\n\ninline bool inTriangle(Point p, Point a, Point b, Point c){\n\tbool f1 = isNeg((p - a) ^ (p - b)),\n\t\tf2 = isNeg((p - b) ^ (p - c)),\n\t\tf3 = isNeg((p - c) ^ (p - a));\n//\tprintf(\"p = %d a = %d b = %d c = %d f1 = %d f2 = %d f3 = %d\\n\", p.id, a.id, b.id, c.id, f1, f2, f3);\n\treturn (f1 == f2 && f2 == f3);\n} \n\ninline void solve(vector &tr, Point p, Point q, Point r){\n//\tprintf(\"p = %d q = %d r = %d\\n\", p.id, q.id, r.id);\n//\tFOR(i, 0, tr.size())\n//\t\tprintf(\"%d \", tr[i].id); puts(\"\");\n\tint col = p.c ^ q.c ^ r.c, sid = -1;\n\tFOR(i, 0, tr.size()) if(tr[i].c == col && tr[i] != p && tr[i] != q && tr[i] != r){\n\t\tsid = i;\n\t\tbreak;\n\t}\n\tif(!~sid){\n\t\tsameColour(tr, (p.c == col) ? ((q.c == col) ? r : q) : p);\n\t\treturn;\n\t}\n\tPoint s = tr[sid];\n\tvector ntr;\n\tntr.clear();\n\tFOR(i, 0, tr.size()) if(inTriangle(tr[i], p, q, s))\n\t\tntr.PB(tr[i]);\n\tsolve(ntr, p, q, s);\n\t\n\tntr.clear();\n\tFOR(i, 0, tr.size()) if(inTriangle(tr[i], q, r, s))\n\t\tntr.PB(tr[i]);\n\tsolve(ntr, q, r, s);\n\t\n\tntr.clear();\n\tFOR(i, 0, tr.size()) if(inTriangle(tr[i], r, p, s))\n\t\tntr.PB(tr[i]);\n\tsolve(ntr, r, p, s);\n\n\ted.PB(MP(s.id, (p.c == s.c) * p.id + (q.c == s.c) * q.id + (r.c == s.c) * r.id));\n\treturn;\n}\n\ninline vector convex(vector vec){\n\tsort(vec.begin(), vec.end());\n\tPoint upp[maxn], low[maxn]; int p = 0, q = 0;\n\tFOR(i, 0, vec.size()){\n\t\tfor(; p > 1 && ((vec[i] - upp[p - 1]) ^ (vec[i] - upp[p - 2])) <= 0; --p);\n\t\tupp[p++] = vec[i];\n\t\tfor(; q > 1 && ((vec[i] - low[q - 1]) ^ (vec[i] - low[q - 2])) >= 0; --q);\n\t\tlow[q++] = vec[i];\n\t}\n\tvector ret;\n\tFOR(i, 0, p)\n\t\tret.PB(upp[i]);\n\tfor(int i = q - 2; i; --i)\n\t\tret.PB(low[i]);\n\treturn ret;\n}\n\nint main(){\n\tscanf(\"%d\", &n);\n\tvector all;\n\tFOR(i, 0, n){\n\t\tint x, y, c; scanf(\"%d%d%d\", &x, &y, &c);\n\t\tall.PB(Point(x, y, c, i));\n\t}\n\t\n\tvector hull = convex(all);\n\t\n//\tFOR(i, 0, hull.size())\n//\t\tprintf(\"%d \", hull[i].id); puts(\"\");\n\t\n\tint p = -1, q = -1;\n\t\n\tFOR(i, 0, hull.size()){\n\t\tif(hull[i].c != hull[(i + 1) % hull.size()].c){\n\t\t\tif(!~p)\n\t\t\t\tp = i;\n\t\t\telse if(!~q)\n\t\t\t\tq = i;\n\t\t\telse{\n\t\t\t\tputs(\"Impossible\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tif(!~p){\n\t\tFOR(i, 0, all.size()) if(all[i].c != hull[0].c)\n\t\t\tp = i;\n\t\tif(!~p)\n\t\t\tsameColour(all, all[0]);\n\t\tFOR(i, 0, hull.size()){\n\t\t\tvector tr;\n\t\t\tFOR(j, 0, all.size()) if(inTriangle(all[j], all[p], hull[i], hull[(i + 1) % hull.size()]))\n\t\t\t\ttr.PB(all[j]);\n\t\t\tsolve(tr, all[p], hull[i], hull[(i + 1) % hull.size()]);\n\t\t\tif(i)\n\t\t\t\ted.PB(MP(hull[i].id, hull[(i + 1) % hull.size()].id));\n\t\t}\n\t}\n\telse{\n\t\tFOR(i, 0, hull.size()) if(hull[i].c != hull[p].c && hull[i].c == hull[(i + 1) % hull.size()].c){\n\t\t\tvector tr;\n\t\t\tFOR(j, 0, all.size()) if(inTriangle(all[j], hull[p], hull[i], hull[(i + 1) % hull.size()]))\n\t\t\t\ttr.PB(all[j]);\n//\t\t\tprintf(\"i = %d\\n\", i);\n\t\t\tsolve(tr, hull[p], hull[i], hull[(i + 1) % hull.size()]);\n\t\t\ted.PB(MP(hull[i].id, hull[(i + 1) % hull.size()].id));\n\t\t}\n\t\tFOR(i, 0, hull.size()) if(hull[i].c != hull[q].c && hull[i].c == hull[(i + 1) % hull.size()].c){\n\t\t\tvector tr;\n\t\t\tFOR(j, 0, all.size()) if(inTriangle(all[j], hull[q], hull[i], hull[(i + 1) % hull.size()]))\n\t\t\t\ttr.PB(all[j]);\n//\t\t\tprintf(\"i = %d\\n\", i);\n\t\t\tsolve(tr, hull[q], hull[i], hull[(i + 1) % hull.size()]);\n\t\t\ted.PB(MP(hull[i].id, hull[(i + 1) % hull.size()].id));\n\t\t}\t\n\t}\n\t\n\tsort(ed.begin(), ed.end());\n\ted.erase(unique(ed.begin(), ed.end()), ed.end());\n\tprintf(\"%d\\n\", ed.size()); \n\tFOR(i, 0, ed.size())\n\t\tprintf(\"%d %d\\n\", ed[i].fst, ed[i].snd);\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "355f65698e50c99d19db2da92115530e", "src_uid": "3bc096d8cd3418948d5be6bf297aa9b5", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "// ~/Remember,remember the 6th of March\n#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include\n#include \n#include \n#include\n#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\nconst double PI = acos(-1.0);\nconst double EPS = 1e-9;\nconst ll MOD = 100000000;\nconst int N = 2e6 + 10;\nvoid fast()\n{\n\tstd::ios_base::sync_with_stdio(0);\n}\nll m;\nll check(ll n)\n{\n\tll ways = 0;\n\tfor (ll k = 2; k < 1e15; k++)\n\t{\n\t\tll x = k * k*k;\n\t\tif (x > n)break;\n\t\tways += n / x;\n\t}\n\treturn ways;\n}\nint main()\n{\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\", stdin);\n\t//freopen(\"output.txt\",\"w\",stdout);\n#endif\n\tcin >> m;\n\tll l = 1, h = 1e18, mid, ans = -1;\n\twhile (l <= h)\n\t{\n\t\tmid = (l + h) / 2;\n\t\tll x = check(mid);\n\t\tif (x == m)\n\t\t{\n\t\t\tans = mid;\n\t\t\th = mid - 1;\n\t\t}\n\t\telse if(x > m)\n\t\t\th = mid-1 ;\n\t\telse\n\t\t\tl = mid+1 ;\n\t}\n\tcout << ans << endl;\n\treturn 0;\n}// ~/Remember,remember the 6th of March\n#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include\n#include \n#include \n#include\n#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\nconst double PI = acos(-1.0);\nconst double EPS = 1e-9;\nconst ll MOD = 100000000;\nconst int N = 2e6 + 10;\nvoid fast()\n{\n\tstd::ios_base::sync_with_stdio(0);\n}\nll m;\nll check(ll n)\n{\n\tll ways = 0;\n\tfor (ll k = 2; k < 1e15; k++)\n\t{\n\t\tll x = k * k*k;\n\t\tif (x > n)break;\n\t\tways += n / x;\n\t}\n\treturn ways;\n}\nint main()\n{\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\", stdin);\n\t//freopen(\"output.txt\",\"w\",stdout);\n#endif\n\tcin >> m;\n\tll l = 1, h = 1e18, mid, ans = -1;\n\twhile (l <= h)\n\t{\n\t\tmid = (l + h) / 2;\n\t\tll x = check(mid);\n\t\tif (x == m)\n\t\t{\n\t\t\tans = mid;\n\t\t\th = mid - 1;\n\t\t}\n\t\telse if(x > m)\n\t\t\th = mid-1 ;\n\t\telse\n\t\t\tl = mid+1 ;\n\t}\n\tcout << ans << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "227f4109fa927133c1cb2b38e2ea509b", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \"/Users/cslusr/macros.h\"\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\n#define PB push_back\n#define MT make_tuple\n#define MP make_pair\n#define VI vector\n#define VVI vector>\n#define TII tuple\n#define SZ() size()\n#define ALL(v) v.begin(),v.end()\n#define FOR(i,a,b) for(int i=a;i> m;\n lld res = solve(m);\n cout << res << endl;\n }\n \n};\n\nint main() {\n\n __UNSYNC_IO__;\n\n S s;\n s.solve();\n \n return 0;\n \n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e139c378c52e47983d3c262aa0e0d89c", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0} {"lang": "MS C++", "source_code": "#include \n#include \n#define int long long\nusing namespace std;\n\nint main()\n{\n\tlong long i;\n\tlong long req;\n\tcin >> req;\n\tlong long bot = 1;\n\tlong long top = 9017199254740992;\n\twhile(top - bot>1)\n\t{\n\t\tlong long mid = (bot + top) / 2;\n\t\tlong long i = 2;\n\t\tlong long ans = 0;\n\t\tbool flag = 0;\n\t\tlong long hh = 8;\n\t\twhile(hh <= mid)\n\t\t{\n\t\t\tans += mid / hh;\n\t\t\t++i;\n\t\t\thh = i*i*i;\n\t\t\tif(ans >= req)\n\t\t\t{\n\t\t\t\tflag = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(flag)\n\t\t{\n\t\t\ttop = mid;\n\t\t}\n\t\telse\n\t\t\tbot = mid;\n\t}\n\tlong long mid = bot;\n\ti = 2;\n\tlong long ans = 0;\n\tint hh = 8;\n\twhile(hh > 0 && hh <= mid)\n\t{\n\t\tans += mid / hh;\n\t\t++i;\n\t\thh = i*i*i;\n\t}\n\tif(ans != req)\n\t{\n\t\tlong long mid = top;\n\t\ti = 2;\n\t\tlong long ans = 0;\n\t\tint hh = 8;\n\t\twhile(hh > 0 && hh <= mid)\n\t\t{\n\t\t\tans += mid / hh;\n\t\t\t++i;\n\t\t\thh = i*i*i;\n\t\t}\n\t\tif(ans != req)\n\t\t\tprintf(\"-1\\n\");\n\t\telse\n\t\t\tcout << top << \"\\n\";\n\t}\n\telse\n\t\tcout << bot << \"\\n\";\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "14ed88c536526726e1912305512a83c7", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\n#include \nusing namespace std;\n\ntypedef long long ll;\n\nll count_ways (ll num) {\n ll A, aux;\n ll acc = 0;\n double common; // common factor among PGs\n int maxR = powl(num, 1/3.L);\n\n for ( int r = 2; r <= maxR; ++r )\n {\n A = num / powl(r,3);\n acc += A;\n\n// common = maxR / (double) r;\n// for (ll i = 2; i < common; ++i)\n// {\n// aux = powl(i,3.L);\n// acc -= A / aux;\n// }\n }\n\n return acc;\n}\n\nll bin_search (ll n) {\n ll max = 1E15;\n ll min = 8;\n\n ll mid = (max + min) / 2;\n while (mid != min)\n {\n ll ways = count_ways(mid);\n\n if (ways >= n)\n max = mid;\n else\n min = mid;\n\n mid = (max + min) / 2;\n }\n\n if (count_ways(min) == n)\n return min;\n else if (count_ways(max) == n)\n return max;\n\n return -1;\n}\n\nint main () {\n ll num;\n\n cin >> num;\n cut << count_ways(num) << endl;\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "710175b9549263a53594fa86972992ba", "src_uid": "602deaad5c66e264997249457d555129", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n#define endl '\\n'\n\nint main(){\n int n;\n cin >> n;\n string p = \"NO\";\n long long ans = 0;\n for (long long b = 0; b < 10000; b++)\n if (b * 123456 == n)\n p = \"YES\";\n if (p == \"YES\"){\n cout << p << endl;\n return;\n }\n for (long long c = 0; c < 1000000; b++)\n if (c * 123456 == n)\n p = \"YES\";\n if (p == \"YES\"){\n cout << p << endl;\n return;\n }\n for (long long a = 0; a < 1000; a++)\n for(long long b = 0; b < 500; b++)\n for (long long c = 0; c < 500; c++){\n ans = a * 1234567 + b * 123456 + c * 1234;\n if (ans == n)\n p = \"YES\";\n }\n\n cout << p << endl;\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3a48224bfa703809f46068b35b156f70", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include \n\n#define PI acos(-1)\n#define MOD 1e7\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\n\nint main()\n{\n ll n;\n bool flag = false;\n scanf(\"%lld\", &n);\n\n for(int i = 0; i <= n; i += 1234567) {\n for(int j = 0; j <= (n-i); j += 123456) {\n if((n-a-b)%1234 == 0) {\n flag = true;\n break;\n }\n }\n if(flag) break;\n }\n if(flag) printf(\"YES\\n\");\n else printf(\"NO\\n\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4971485807b04462f945b3451bd22909", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include\n#define ll long long\nusing namespace std;\nint main()\n{\n ll n,i,j,k,l1,l2;\n cin>>n;\n l1=n/1234567;\n l2=n/123456;\n for(i=0;i<=l1;i++)\n {\n for(j=0;j<=l2;j++)\n {\n ll h=n/1234;\n ll l=0;\n ll minm=1e18;\n while(ln)\n h=k-1;\n else\n break;\n }\n if(exp==n)\n {\n cout<<\"YES\";\n return 0;\n }\n for(k=l;k\n\nusing namespace std;\n\n#define F first\n\n#define S second\n\ntypedef long long ll;\n\ntypedef string str;\n\nll inf=1e9;\nconst ll M=1e9+1;\nbool a[M],v[M];\n\nint f(int x)\n{\n\tif (x<0)\n\t\treturn 0;\n\tif (v[x]==1)\n\t\treturn a[x];\n\tv[x]=1;\n\ta[x]=f(x-1234567) || f(x-123456) || f(x-1234);\n\treturn a[x];\n}\n\nint main()\n{\n\tcin.sync_with_stdio(false);\n\tint n;\n\tcin >> n;\n\ta[0]=1;\n\tv[0]=1;\n\tif (f(n))\n\t\tcout << \"YES\";\n\telse\n\t\tcout << \"NO\";\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cdf333f93c95cd195bed54831c02c171", "src_uid": "72d7e422a865cc1f85108500bdf2adf2", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "\n#include\nusing namespace std;\nint main()\n{\n int n,count=0;\n cin>>n;\n char a[n];\n for(int i=0;i>a[i];\n }\n for(int i=0;i\nusing namespace std;\n\nint main()\n{\n int n,cnt=0;\n string s,s1,s2,temp;\n cin>>n>>s;\n s1=\"RU\";\n s2=\"UR\";\n int i=0;\n while(i\n\n#define ll long long\n#define ii pair\n#define ff first\n#define ss second\n#define mp make_pair\n#define pb push_back\n#define sf(x) scanf(\"%d\", &x)\n#define sf2(x,y) scanf(\"%d %d\", &x, &y)\n\n#define inf 100000000\n#define N 1005\nusing namespace std;\n\nint main(){\n\tint n;\n\tstring a;\n\tcin >> n >> a;\n\tint ans = 0;\n\tmap mp;\n\tvector v(2);\n\tmp['R'] = 0;\n\tmp['U'] = 1;\n\tv[0] = 'U';\n\tv[1] = 'R';\n\tfor(int i = 0; i; i < a.size() -1; i++){\n\t\tif(v[mp[a[i]]] == !v[mp[a[i+1]]]) i++;\n\t\tans++;\n\t}\n\tcout << ans << endl;\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "41fad8cf6832875360bfdb12607a6471", "src_uid": "986ae418ce82435badadb0bd5588f45b", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n\nusing namespace std;\nint main()\n{\n int n;\n char str[105];\n scanf(\"%d\",&n);\n scanf(\"%s\",str);\n int sum=0;\n for(int i=0;i> a;\n#define readb(a, b) int a, b; cin >> a >> b;\n#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;\n#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}\n#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}\n\n#define print(a) cout << a << endl;\n#define printarr(a, n) FOR (i, 1, n) cout << a[i] << \" \"; cout << endl;\n#define printv(v) for (int i: v) cout << i << \" \"; cout << endl;\n#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << \" \"; cout << endl;} cout << endl;\n#define all(v) v.begin(), v.end()\n#define sz(v) (int)(v.size())\n#define rz(v, n) v.resize((n) + 1);\n#define pb push_back\n#define fi first\n#define se second\n#define vi vector \n#define pi pair \n#define vpi vector \n#define vvi vector \n#define FOR(i, a, b) for (int i = (a); i <= (b); i++)\n#define FORD(i, a, b) for (int i = (a); i >= (b); i--)\nconst ll inf = 1e18;\nconst ll mod = 1e9 + 7;\nconst ll N = 1e6 + 1;\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n\nint power (int a, int b = mod - 2)\n{\n int res = 1;\n while (b > 0) {\n if (b & 1)\n res = res * a % mod;\n a = a * a % mod;\n b >>= 1;\n }\n return res;\n}\n\n\nint pon[N + 1] = {1}, pom[N + 1] = {1}, fac[N + 1] = {1}, inv[N + 1] = {1};\ninline int ncr (int x, int y)\n{\n return fac[x] * inv[y] % mod * inv[x - y] % mod;\n}\n\nsigned main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(0);\n\t\n\treadb(n, m);\n\tFOR (i, 1, N) pon[i] = pon[i - 1]*n % mod;\n\tFOR (i, 1, N) pom[i] = pom[i - 1]*m % mod;\n\tFOR (i, 1, N) fac[i] = fac[i - 1]*i % mod;\n\t\n\tinv[N] = power(fac[N]);\n\tFORD (i, N - 1, 1) inv[i] = inv[i + 1]*(i + 1) % mod;\n\t\n\tint sum = 0;\n\tFOR (k, 1, min(n - 1, m))\n\t{\n\t int x = ncr(m - 1, k - 1) * fac[n - 2] % mod * inv[n - k - 1] % mod;\n\t if (k == n - 1) x = x*pom[n - 1 - k] % mod;\n\t else x = x*pon[n - k - 2] % mod * pom[n - 1 - k] % mod * (k + 1) % mod;\n\t sum = (sum + x) % mod;\n\t}\n\t\n\tprint(sum);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4d281d07057082fd77a275105a8efb4d", "src_uid": "728fe302b8b18e33f15f6e702e332cde", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "#include \"bits/stdc++.h\"\n#define int long long\n#define endl '\\n'\nusing namespace std;\n \ntypedef long long ll;\n#define db(x) cerr << #x << \": \" << x << '\\n';\n#define read(a) int a; cin >> a;\n#define readb(a, b) int a, b; cin >> a >> b;\n#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;\n#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}\n#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}\n\n#define print(a) cout << a << endl;\n#define printarr(a, n) FOR (i, 1, n) cout << a[i] << \" \"; cout << endl;\n#define printv(v) for (int i: v) cout << i << \" \"; cout << endl;\n#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << \" \"; cout << endl;} cout << endl;\n#define all(v) v.begin(), v.end()\n#define sz(v) (int)(v.size())\n#define rz(v, n) v.resize((n) + 1);\n#define pb push_back\n#define fi first\n#define se second\n#define vi vector \n#define pi pair \n#define vpi vector \n#define vvi vector \n#define FOR(i, a, b) for (int i = (a); i <= (b); i++)\n#define FORD(i, a, b) for (int i = (a); i >= (b); i--)\nconst ll inf = 1e18;\nconst ll mod = 1e9 + 7;\nconst ll N = 1e6 + 1;\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n\nsigned main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(0);\n\t\n}\n\n\n\n\n\n\n\n\n\n\n\n\u00a0", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7b7f12cba62e4ac3c97c00929c9da6f3", "src_uid": "728fe302b8b18e33f15f6e702e332cde", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "#include \"bits/stdc++.h\"\n#define int long long\n#define endl '\\n'\nusing namespace std;\n \ntypedef long long ll;\n#define db(x) cerr << #x << \": \" << x << '\\n';\n#define read(a) int a; cin >> a;\n#define readb(a, b) int a, b; cin >> a >> b;\n#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;\n#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}\n#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}\n\n#define print(a) cout << a << endl;\n#define printarr(a, n) FOR (i, 1, n) cout << a[i] << \" \"; cout << endl;\n#define printv(v) for (int i: v) cout << i << \" \"; cout << endl;\n#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << \" \"; cout << endl;} cout << endl;\n#define all(v) v.begin(), v.end()\n#define sz(v) (int)(v.size())\n#define rz(v, n) v.resize((n) + 1);\n#define pb push_back\n#define fi first\n#define se second\n#define vi vector \n#define pi pair \n#define vpi vector \n#define vvi vector \n#define FOR(i, a, b) for (int i = (a); i <= (b); i++)\n#define FORD(i, a, b) for (int i = (a); i >= (b); i--)\nconst ll inf = 1e18;\nconst ll mod = 1e9 + 7;\nconst ll N = 1e6 + 1;\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n\nint power (int a, int b = mod - 2)\n{\n int res = 1;\n while (b > 0) {\n if (b & 1)\n res = res * a % mod;\n a = a * a % mod;\n b >>= 1;\n }\n return res;\n}\n\n\nint pon[N + 1] = {1}, pom[N + 1] = {1}, fac[N + 1] = {1}, inv[N + 1] = {1};\ninline int ncr (int x, int y)\n{\n return fac[x] * inv[y] % mod * inv[x - y] % mod;\n}\n\nsigned main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(0);\n\t\n\treadb(n, m);\n\tFOR (i, 1, N) pon[i] = pon[i - 1]*n % mod;\n\tFOR (i, 1, N) pom[i] = pom[i - 1]*m % mod;\n\tFOR (i, 1, N) fac[i] = fac[i - 1]*i % mod;\n\t\n\tinv[N] = power(fac[N]);\n\tFORD (i, N - 1, 1) inv[i] = inv[i + 1]*(i + 1) % mod;\n\t\n\tint sum = 0;\n\tFOR (k, 1, min(n - 1, m))\n\t{\n\t int x = ncr(m - 1, k - 1) * fac[n - 2] % mod * inv[n - k - 1] % mod;\n\t if (k == n - 1) x = x*pom[n - 1 - k] % mod;\n\t else x = x*pon[n - k - 2] % mod * pom[n - 1 - k] % mod * (k + 1) % mod;\n\t sum = (sum + x) % mod;\n\t}\n\t\n\tprint(sum);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1d8cf3ef91b4ad7ba4a2452c556ff5e2", "src_uid": "728fe302b8b18e33f15f6e702e332cde", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "#include \n#define sz(x) (int)(x).size()\n#define all(x) (x).begin(), (x).end()\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long llu;\ntypedef pair pii;\ntypedef pair pdd;\ntypedef pair piii;\ntypedef pair pll;\ntypedef pair pli;\ntypedef pair pil;\ntypedef pair psi;\ntypedef pair pci;\ntypedef pair pic;\nconst ll MOD = (ll)1e9 + 7;\nconst long double PI = 3.141592653589793238462643383279502884197;\n\nll fac[2000001] = {1}, inv[2000001] = {1};\nll gcd(ll a,ll b){return b?gcd(b,a%b):a;}\nll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}\nll cmb(ll r, ll c) {return fac[r] * inv[c] % MOD * inv[r - c] % MOD;}\n\nint main() {\n for (int i = 1; i <= 2000000; i++) {\n fac[i] = fac[i - 1] * i % MOD;\n inv[i] = mp(fac[i], MOD - 2);\n }\n\n int n, m;\n scanf(\"%d %d %*d %*d\", &n, &m);\n\n ll ans = 0;\n for (int i = 1; i <= min(n-1, m); i++) {\n int x = i-1;\n ll a = cmb(m-1, i-1) * cmb(n-2, x) % MOD * fac[x] % MOD;\n // printf(\"%d : %lld\\n\", i, a);\n\n ll b = mp(m, n-1-i);\n if (i != n-1) b = (x+2)*b%MOD*mp(n, n-x-3)%MOD;\n\n // printf(\"%d : %lld\\n\", i, b);\n ans = (ans+a*b)%MOD;\n }\n\n printf(\"%lld\", ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0a16b4adc2bfe27adba00a6088608e9f", "src_uid": "728fe302b8b18e33f15f6e702e332cde", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "#pragma GCC optimize(\"O3\")\n#include \n\n#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define files(name) name!=\"\"?freopen(name\".in\",\"r\",stdin),freopen(name\".out\",\"w\",stdout):0\n#define all(a) a.begin(),a.end()\n#define len(a) (int)(a.size())\n#define elif else if\n#define mp make_pair\n#define pb push_back\n#define fir first\n#define sec second\n\nusing namespace std;\n#define int long long\n\ntypedef unsigned long long ull;\ntypedef pair pii;\ntypedef vector vi;\ntypedef long double ld;\ntypedef long long ll;\n\nconst int arr=2e5+10;\nconst int ar=2e3+10;\nconst ld pi=acos(-1);\nconst ld eps=1e-10;\nconst ll md=1e9+7;\n\n///---program start---///\n\nint bpow(int a,int n)\n{\n int res=1;\n while (n){\n if (n&1){\n res=(res*a)%md;\n }\n n/=2;\n a=(a*a)%md;\n }\n return res;\n}\n\nint inv(int a,int m=md)\n{\n return a==1?1:(1-get(m%a,a)*m)/a+m;\n}\n\nvoid inc(int& a,int b)\n{\n a+=b;\n a%=md;\n a+=md;\n a%=md;\n}\n\nint k,p_a,p_b;\nint dp[ar][ar];\nbool use[ar][ar];\n\nint sum(int b1,int q) /// 0=k){\n return res=cnt_ab;\n }\n if (cnt_a+cnt_ab>=k){\n inc(res,sum((cnt_ab+cnt_a)%md*p_b%md*inv(p_a+p_b)%md,p_a*inv(p_a+p_b)%md));\n inc(res,p_b*inv(p_a+p_b)%md*get_sum(p_a*inv(p_a+p_b)%md));\n return res;\n }\n inc(res,get(cnt_a+1,cnt_ab)*p_a%md*inv(p_a+p_b)%md);\n inc(res,get(cnt_a,cnt_ab+cnt_a)*p_b%md*inv(p_a+p_b)%md);\n return res;\n}\n\nmain()\n{\n #ifdef I_love_Maria_Ivanova\n files(\"barik\");\n freopen(\"debug.txt\",\"w\",stderr);\n #endif\n\n cin>>k>>p_a>>p_b;\n cout<\n#include\n#include\n#include\nusing namespace std;\nint k,pa,pb,xy;\n\nint f[1005][1005];\nconst int p=1000000007;\nvoid gcd(int a,int b,int&x,int &y){\n if(!b){\n x = 1;\n y = 0;\n }\n else\n {\n gcd(b,a % b,y,x);\n y -= x * (a / b);\n }\n}\nint inv(int a)\n{\n int x,y;\n gcd(a,p,x,y);\n return (x % p + p) % p;\n}\nint dp(int i,int j)\n{\n if(i+j>=k) return f[i][j]=(i+j+1LL*pa*inv(pb))%p;\n \n return f[i][j]=(1LL*((1LL*pa*dp(i+1,j))%p+(1LL*pb*dp(i,i+j))%p)*inv(pb+pa))%p;\n}\nint main(){\n cin>>k>>pa>>pb;\n memset(f,0x3f3f3f3f,sizeof(f));\n cout<\nusing namespace std;\nconst LL mod = 1e9+7;\nLL gcd(LL x, LL y){ return x == 0 ? y : gcd(y%x, x);}\nLL dp[1001][1001];\nLL qpow(LL x,LL p) {\n LL ret = 1;\n LL exponent = p - 2;\n for (int i = exponent; i; i >>= 1, x = x * x % p) {\n if (i & 1) {\n ret = ret * x % p;\n }\n }\n return ret;\n}\n\nLL init(LL x, LL y){\n return x * qpow(y, mod) % mod;\n}\n\nint main(){\n int k;\n LL a, b;\n scanf(\"%d%lld%lld\", &k, &a, &b);\n dp[1][0] = 1;\n for(int i = 1; i <= k; i ++)\n for(int j = 0; j < k; j ++){\n if(i + j >= k)\n break;\n dp[i+1][j] = (dp[i+1][j] + dp[i][j] * init(a, a+b)) % mod;\n dp[i][j+i] = (dp[i][j+i] + dp[i][j] * init(b, a+b)) % mod;\n }\n LL ans = 0;\n LL sum;\n LL temx = (a+b*k), temy = b;\n \n for(int i = 1; i <= k; i ++){\n for(int j = 0; j < k; j ++){\n if(i+j < k)\n continue;\n sum = i + j;\n temx = a+b*sum, temy = b;\n LL tem = init(temx, temy);\n ans += tem*dp[i][j];\n ans %= mod;\n }\n }\n printf(\"%lld\", ans);\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "95e939b836b0669df52b821e005e7602", "src_uid": "0dc9f5d75143a2bc744480de859188b4", "difficulty": 2200.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nint k,pa,pb,xy;\n\nint f[1005][1005];\nconst int p=1000000007;\nvoid gcd(int a,int b,int&x,int &y){\n if(!b){\n x = 1;\n y = 0;\n }\n else\n {\n gcd(b,a % b,y,x);\n y -= x * (a / b);\n }\n}\nint inv(int a)\n{\n int x,y;\n gcd(a,p,x,y);\n return (x % p + p) % p;\n}\nint dp(int i,int j)\n{\n if(i+j>=k) return f[i][j]=(i+j+1LL*pa*inv(pb))%p;\n \n return f[i][j]=(1LL*((1LL*pa*dp(i+1,j))%p+(1LL*pb*dp(i,i+j))%p)*inv(pb+pa))%p;\n}\nint main(){\n cin>>k>>pa>>pb;\n memset(f,0x3f3f3f3f,sizeof(f));\n cout<\nusing namesopace std;\nint main()\n{\n\tint a,b;\n\tcin>>a>>b;\n\tif (a*2>b*3) cout<\nusing namespace std;\n#define ll long long\nint main()\n{\n long long int n,m,x;\n cin>>n>>m;\n ll y;\n x=2+(n-1)*2;///cout<y)\n {;r=x+(z)*2;u=abs(r/6-y/6);s=y+(z1)*3}\n else if(x==y)\n {\n \ts=y+(z)*3;r=x+(z)*2;\n\t }\n\t else \n\t {\n\t \ts=y+(z)*3;u=abs(s/6-y/6)r=x+(z1)*2;\n\t }\n cout<\nusing namespace std;\n# define ll long long int\n#define M 998244353\n#define ff first\n#define ss second\n#define pb push_back\n#define inf 10000000000\n\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t//nestedcode\n\n\nint main(){\n\tios_base::sync_with_stdio(false);\n cin.tie(NULL); cout.tie(NULL);\n ll a,b,i;\n cin>>a>>b;\n \tfor(i=0;i<500000;i++){\n \t\tif(i/2 + i/3 - i/6 <= (a+b)){\n \t\t\tif(i/2 >= n && i/3 >= m){\n\t\t\t \n \t\t\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define EPS 1e-7\n#define INF (int)(1e+9)\n#define LINF (long long)(1e+18)\n#define PI acos(-1)\n#define mp make_pair\n#define MOD 1000000007\n\n\nusing namespace std;\n\n#define NAME \"test\"\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pii;\ntypedef pair pll;\n\nvoid solve(int test_number);\n\n\nvoid pre() {\n cout.setf(ios::fixed);\n cout.precision(20);\n cerr.setf(ios::fixed);\n cerr.precision(3);\n //ios_base::sync_with_stdio(false);\n //cin.tie(NULL);\n}\n\nvoid post() {\n printf(\"\\n\");\n fprintf(stderr, \"Execution time: %Lf\", (ld) clock());\n}\n\nconst int MAXN = 100100;\n\nstruct Three {\n\tint val, n, m;\n\tThree() {\n\t\tval = n = m = 0;\n\t}\n};\n\nThree dp[33333333][4];\n\ninline void solve(int test_number) {\n\tint n, m;\n\tscanf(\"%d %d\", &n, &m);\n\tll i = 2;\n\tint n1 = n, m1 = m, n2 = n, m2 = m;\n\twhile (true) {\n\t\tif (i % 2LL == 0) {\n\t\t\tif (i % 3LL == 0 && m > 0) m--;\n\t\t\telse if (n != 0) n--;\n\t\t}\n\t\telse {\n\t\t\tif (i % 3LL == 0 && m != 0) m--;\n\t\t}\n\t\tif (n == 0 && m == 0) break;\n\t\ti++;\n\t}\n\tll j = 2;\n\twhile (true) {\n\t\tif (j % 2LL == 0) {\n\t\t\tif (n1 > 0) {\n\t\t\t\tn1--;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (j % 3 == 0 && m1 > 0) m1--;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (j % 3LL == 0 && m1 > 0) m1--;\n\t\t}\n\t\tif (n1 == 0 && m1 == 0) break;\n\t\tj++;\n\t}\n\tll r = 2;\n\twhile (true) {\n\t\tif (r % 3LL == 0) {\n\t\t\tif (m2 > 0) {\n\t\t\t\tm2--;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (r % 2LL == 0 && n2 > 0) n2--;\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tif (r % 2LL == 0 && n2 > 0) n2--;\n\t\t}\n\t\tif (n2 == 0 && m2 == 0) break;\n\t\tr++;\n\t}\n\tprintf(\"%lld\", min(i, min(j, r)));\n\treturn;\n}\n\n\n\nint main()\n{\n#ifdef DEBUG\n freopen(NAME \".in\", \"r\", stdin);\n freopen(NAME \".out\", \"w\", stdout);\n#endif\n //freopen(NAME \".in\", \"r\", stdin);\n //freopen(NAME \".out\", \"w\", stdout);\n pre();\n\n int n = 1;\n for (int i = 0; i < n; i++) {\n solve(i + 1);\n }\n\n post();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "64d0021ecb0c73cbb7504d772a4a7639", "src_uid": "23f2c8cac07403899199abdcfd947a5a", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n\nconst int N = 100000;\n\nint head[N], to[N << 1], next[N << 1], tree_hash[N << 1];\nstd::map, int> hashes;\n\nint get_hash(const std::vector& hash)\n{\n if (!hashes.count(hash)) {\n auto count = hashes.size();\n hashes[hash] = count;\n }\n return hashes[hash];\n}\n\nint get_tree_hash(int edge)\n{\n int& ref = tree_hash[edge];\n if (ref == -1) {\n std::vector hashes;\n for (int iterator = head[to[edge]]; ~iterator; iterator = next[iterator]) {\n if (to[iterator] != to[edge ^ 1]) {\n hashes.push_back(get_tree_hash(iterator));\n }\n }\n std::sort(hashes.begin(), hashes.end());\n ref = get_hash(hashes);\n }\n return ref;\n}\n\nint main()\n{\n#ifdef LOCAL_JUDGE\n freopen(\"D.in\", \"r\", stdin);\n#endif\n int n;\n while (scanf(\"%d\", &n) == 1) {\n for (int i = 0; i < n - 1 << 1; ++ i) {\n scanf(\"%d\", to + i);\n to[i] --;\n }\n memset(head, -1, sizeof(*head) * n);\n for (int i = 0; i < n - 1 << 1; ++ i) {\n auto& h = head[to[i ^ 1]];\n next[i] = h;\n h = i;\n }\n memset(tree_hash, -1, sizeof(*tree_hash) * (n << 1));\n std::vector> hashes;\n for (int u = 0; u < n; ++ u) {\n std::vector hash;\n for (int iterator = head[u]; ~iterator; iterator = next[iterator]) {\n hash.push_back(get_tree_hash(iterator));\n }\n if (static_cast(hash.size()) < 4) {\n std::sort(hash.begin(), hash.end());\n hashes.push_back(hash);\n }\n }\n std::sort(hashes.begin(), hashes.end());\n hashes.erase(std::unique(hashes.begin(), hashes.end()), hashes.end());\n printf(\"%d\\n\", static_cast(hashes.size()));\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1eb89f82a48852cdcabca42f4ac50316", "src_uid": "3c5aedd5d3bc12dca3e921c95ef05270", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#define Rep(i,l,r) for(i=(l);i<=(r);i++)\n#define rep(i,l,r) for(i=(l);i< (r);i++)\n#define Rev(i,r,l) for(i=(r);i>=(l);i--)\n#define rev(i,r,l) for(i=(r);i> (l);i--)\n#define Each(i,v) for(i=v.begin();i!=v.end();i++)\n#define r(x) read(x)\ntypedef long long ll ;\ntypedef double lf ;\nint CH , NEG ;\ntemplate inline void read(TP& ret) {\n ret = NEG = 0 ; while (CH=getchar() , CH<'!') ;\n if (CH == '-') NEG = true , CH = getchar() ;\n while (ret = ret*10+CH-'0' , CH=getchar() , CH>'!') ;\n if (NEG) ret = -ret ;\n}\n#define maxn 100010LL\n#define pb push_back\nusing namespace std;\n\nint n, idx = 0;\nint ans[maxn];\nvector G[maxn];\nmap R[maxn];\nmap::iterator it;\nmap,int> H;\nmap,int>::iterator it2;\nset S;\n\nint dp(int u,int fa) {\n if (it=R[u].find(fa), it!=R[u].end()) return it->second;\n vectornow; int i;\n rep (i,0,G[u].size())\n if (G[u][i] != fa)\n now.pb(dp(G[u][i],u));\n sort(now.begin(),now.end());\n if (it2=H.find(now), it2==H.end()) return R[u][fa] = H[now] = ++idx;\n else return R[u][fa] = it2->second;\n}\nint main() {\n int i,n,u,v;\n r(n);\n rep (i,1,n)\n r(u), r(v), G[u].pb(v), G[v].pb(u);\n Rep (i,1,n)\n if (G[i].size() < 4) S.insert(dp(i,0));\n printf(\"%d\\n\",S.size());\n END: getchar(), getchar();\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9f5a215c50fd2de1353862f14d923b8d", "src_uid": "3c5aedd5d3bc12dca3e921c95ef05270", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include \n#define rep(i, n) for(int i = 0; i < (n); ++i)\n#define rep1(i, n) for(int i = 1; i <= (n); ++i)\n#define xx first\n#define yy second\nusing namespace std;\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair piii;\n\n#ifdef LOCAL\nbool scan(int& x){ return scanf(\"%d\", &x) == 1; }\nbool scan(ll& x){ return scanf(\"%I64d\", &x) == 1; }\nbool scan(char* s){ return scanf(\"%s\", s) == 1; }\ntemplate bool scan(T& x, TT&... xx){ return scan(x) && scan(xx...); }\n\ntemplate void _COUT(const T& x) { cout << x;}\ntemplate void _COUT(const T& x, const TT&... xx) {_COUT(x); cout << ' '; _COUT(xx...); }\ntemplate void COUT(const T& x, const TT&... xx) { _COUT(x, xx...); cout << endl; }\n#endif // LOCAL\n\nconst int N = 100010, ha1 = 1e9 + 7, ha2 = 1e9 + 9;\n\nconst pii base = pii(23, 233);\nconst pii base2 = pii(13131, 13737);\npii operator + (const pii& a, const pii& b) { return pii((a.xx + b.xx) % ha1, (a.yy + b.yy) % ha2); }\npii operator * (const pii& a, const pii& b) { return pii((ll) a.xx * b.xx % ha1, (ll) a.yy * b.yy % ha2); }\n\nint n;\nvector g[N];\nvector hid[N];\npii h[N];\n\nvector path, cur;\n\nvoid dfs(int u, int p){\n cur.push_back(u);\n if(p != -1 && g[u].size() == 1){\n if(cur.size() > path.size()) path = cur;\n }\n else{\n for(int v : g[u]) if(v != p) {\n dfs(v, u);\n }\n }\n cur.pop_back();\n}\n\nvoid dfs2(int u, int p){\n h[u] = pii(2, 3);\n for(int v : g[u]) if(v != p){\n dfs2(v, u);\n }\n vector &vec = hid[u];\n vec.clear();\n for(int v : g[u]) if(v != p){\n vec.push_back(piii(h[v], v));\n }\n sort(vec.begin(), vec.end());\n for(unsigned i = 0; i < vec.size(); ++i){\n h[u] = h[u] * base + vec[i].xx;\n }\n}\n\nvector ans;\n\nvoid dfs3(int u, int p, pii x){\n h[u] = x * base2 + h[u];\n if(g[u].size() < 4) ans.push_back(h[u]);\n for(int v : g[u]) if(v != p){\n dfs3(v, u, h[u]);\n }\n}\n\n\nvoid solve(){\n path.clear();\n dfs(rand() % n + 1, -1);\n int p1 = path.back(), p2;\n path.clear();\n dfs(p1, -1);\n ans.clear();\n if(path.size() & 1){\n p1 = path[path.size() / 2];\n dfs2(p1, -1);\n dfs3(p1, -1, pii(131, 137));\n }\n else{\n p1 = path[path.size() / 2 - 1];\n p2 = path[path.size() / 2];\n dfs2(p1, p2);\n dfs2(p2, p1);\n dfs3(p1, p2, pii(131, 137));\n dfs3(p2, p1, pii(131, 137));\n }\n sort(ans.begin(), ans.end());\n ans.erase(unique(ans.begin(), ans.end()), ans.end());\n printf(\"%u\\n\", ans.size());\n}\n\n\nint main(){\n #ifdef LOCAL\n freopen(\"in.txt\", \"r\", stdin);\n #endif // LOCAL\n srand(time(NULL));\n int u, v;\n while(scan(n)){\n rep1(i, n) g[i].clear();\n rep(i, n - 1){\n scan(u, v);\n g[u].push_back(v);\n g[v].push_back(u);\n }\n solve();\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ce8278d94d0f24e41177f88681bd9112", "src_uid": "3c5aedd5d3bc12dca3e921c95ef05270", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define FORALL(i,a,b) for(int i=(a);i<=(b);++i)\n#define FOR(i,n) for(int i=0;i<(n);++i)\n#define FORB(i,a,b) for(int i=(a);i>=(b);--i)\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef complex vec;\n\ntypedef pair plli;\ntypedef pair pii;\ntypedef map mii;\n\n#define pb push_back\n#define mp make_pair\n\n#define MAXN 100005\n#define PRIME 1000000007\nvector E[MAXN];\n\nint find_center(int N) {\n // The weights\n vector W(MAXN,0);\n vector P(MAXN,0);\n {\n std::function dfs = [&](int i, int p) {\n P[i] = p;\n W[i] = 1;\n for (const auto& j : E[i]) {\n if (j == P[i]) continue;\n dfs(j,i);\n W[i] += W[j];\n }\n };\n\n dfs(0,-1);\n }\n\n // find the root\n int old_root = -1, root = 0;\n while(root != old_root) {\n old_root = root;\n for (const auto & j : E[old_root]) {\n if (j == P[old_root]) continue;\n if (2*W[j] > N) root = j;\n }\n }\n\n return root;\n}\n\nint get_hash(int i, int p) {\n vector H;\n for (const auto & j : E[i]) {\n if (j == p) continue;\n H.pb(get_hash(j,i));\n }\n\n sort(H.begin(), H.end());\n int ans = 1, base = 1;\n for (const auto& h : H) {\n ans += base*h;\n base *= PRIME;\n //ans += 128747;\n }\n\n return ans;\n}\n\nint main() {\n int N,a,b;\n scanf(\"%d\",&N);\n FOR(i,N-1) {\n scanf(\"%d%d\",&a,&b);\n --a; --b;\n E[a].pb(b);\n E[b].pb(a);\n }\n\n int root = find_center(N);\n \n set H;\n FOR(i,N) {\n if (E[i].size() == 4) continue;\n E[i].pb(N);\n int h = get_hash(root, -1);\n H.insert(h);\n E[i].pop_back();\n }\n\n printf(\"%d\\n\",(int)H.size());\n\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0f3c2060c6b8c2461f33fc6b6546304b", "src_uid": "3c5aedd5d3bc12dca3e921c95ef05270", "difficulty": 2900.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\nusing namespace std;\nint main()\n{\n\tint n,k;\n\tint ans;\n\tscanf(\"%d%d\",&n,&k);\n\tif(n>=k) printf(\"%d\",(k-1)/2);\n\tif(n=n) printf(\"0\");\n\t\telse printf(\"%d\",(k-(n-k)+1)/2);\n\t } \n\t return 0;\n } \n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1c5f23aeb76cb7e318af1b31c6a35fe6", "src_uid": "98624ab2fcd2a50a75788a29e04999ad", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint main()\n{\n unsigned long int n,k,l=0,m=0;\n cin>>n>>k;\n unsigned long int ar[n],cd[n];\n for(int i=0;i\n#include \nusing namespace std;\nint main()\n{\n ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n long long i,j,k,n,m,x=0,y,z,t,d,aa,bb;\n cin>>n>>k;\n if(n+n-1=k)\n {\n cout<\nusing namespace std;\nint main()\n{\n long long a,b,ans;\n cin>>a>>b;\n if(b>=2*a)\n cout<<\"0\"<=b)\n cout<<(b-1)/2<\n#include \n//#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define MAX 2100000000\n#define eps 1e-12\nusing namespace std;\n//freopen(\"C:\\\\Users\\\\tkdsheep\\\\Desktop\\\\out.txt\",\"w\",stdout);\n\nint d,m,y;\nint bd,bm,by;\n\nvoid change(int &x,int &y)\n{\n int tmp;\n tmp=x;\n x=y;\n y=tmp;\n}\n\nbool check()\n{\n if(y-by>18)\n return true;\n if(y-by==18)\n {\n if(m>bm)\n return true;\n if(m==bm)\n {\n if(d>=bd)\n return true;\n return false;\n }\n return false;\n\n }\n return false;\n}\n\nbool gao()\n{\n if(bm>12)\n return false;\n int day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};\n\n if(bm==2)\n {\n if(bd>29)\n return false;\n if(bd==29)\n {\n if(bm%100==0&&bm%400==0)\n return true;\n if(bm%100&&bm%4==0)\n return true;\n return false;\n }\n return true;\n\n }\n\n if(bd>day[bm])\n return false;\n return true;\n}\n\nint main()\n{\n bool ff;\n string s;\n while(cin>>s)\n {\n d=m=y=0;\n d=(s[0]-'0')*10+s[1]-'0';\n m=(s[3]-'0')*10+s[4]-'0';\n y=(s[6]-'0')*10+s[7]-'0';\n\n cin>>s;\n a1=a2=a3;\n a1=(s[0]-'0')*10+s[1]-'0';\n a2=(s[3]-'0')*10+s[4]-'0';\n a3=(s[6]-'0')*10+s[7]-'0';\n\n ff=false;\n\n bd=a1;\n bm=a2;\n by=a3;\n if(gao()&&check())\n ff=true;\n\n bd=a1;\n bm=a3;\n by=a2;\n if(gao()&&check())\n ff=true;\n\n bd=a2;\n bm=a3;\n by=a1;\n if(gao()&&check())\n ff=true;\n\n bd=a2;\n bm=a1;\n by=a3;\n if(gao()&&check())\n ff=true;\n\n bd=a3;\n bm=a1;\n by=a2;\n if(gao()&&check())\n ff=true;\n\n bd=a3;\n bm=a2;\n by=a1;\n if(gao()&&check())\n ff=true;\n\n \n if(ff)\n cout<<\"YES\"<\n#include \n#include \n#include \n#include \nusing namespace std;\n\tint a[12]={31,29,31,30,31,30,31;,31,30,31,30,31};\n\tvector parse(string s)\n\t{\n\t\tint dd,mm,yy,i;\n\t\tfor(i=0;i>dd>>mm>>yy;\n\t\tvectorans;\n\t\tans.push_back(dd);\n\t\tans.push_back(mm);\n\t\tans.push_back(yy);\n\t\treturn ans;\n\t}\n\tbool l(vectorv)\n\t{\n\t\tint d=v[0],m=v[1],y=v[2];\n\t\tif(y%4==0&&m==2&&d==29)\n\t\treturn true;\n\t\tif(m<=12&&d<=a[m-1])\n\t\treturn true;\n\t\treturn false;\n\t}\n\tbool f(vectorcontest,vectorbirth)\n\t{\n\t\tsort(birth.begin(),birth.end());\n\t\tdo\n\t\t{\n\t\t\tif(!l(birth))\n\t\t\tcontinue;\n\t\t\tif(birth[2]>contest>>birth;\n\tbool ans=f(parse(contest),parse(birth));\n\tcout<<(ans?\"YES\":\"NO\")<\nusing namespace std;\nint month[] = {31,28,31,30,31,30,31,31,30,31,30,31};\nclass Date\n{\n\tint dd;\n\tint mm;\n\tint yy;\n\tpublic:\n\tDate(int dd, int mm, int yy)\n\t{\n\t\tthis -> dd = dd;\n\t\tthis -> mm = mm;\n\t\tthis -> yy = yy;\n\t}\n\tDate(void)\n\t{\n\t\tdd = 1;\n\t\tmm = 1;\n\t\tyy = 1;\n\t}\n\tDate(const Date &a)\n\t{\n\t\tdd = a.dd;\n\t\tmm = a.mm;\n\t\tyy = a.yy;\n\t}\n\tDate birthday();\n\tint compareTo(const Date&);\n\tbool incorrect();\n};\nDate Date::birthday(void)\n{\n\tDate d = *this;\n\td.yy += 18;\n\tif (d.yy - 18 % 4 == 0 && d.yy % 4 != 0 && d.mm == 2 && d.dd == 29)\n\t{\n\t\td.mm = 3;\n\t\td.dd = 1;\n\t}\n\treturn d;\n}\nint Date::compareTo(const Date &b)\n{\n\tDate a = *this;\n\tif (a.yy > b.yy) return 1;\n\tif (a.yy < b.yy) return -1;\n\tif (a.mm > b.mm) return 1;\n\tif (a.mm < b.mm) return -1;\n\tif (a.dd > b.dd) return 1;\n\tif (a.dd < b.dd) return -1;\n\treturn 0;\n}\nbool Date::incorrect(void)\n{\n\tDate a = *this;\n\tif ((a.yy % 4 != 0 || a.mm != 2) && a.dd > month[a.mm]) return true;\n\tif (a.yy % 4 == 0 && a.mm == 2 && a.dd > 29) return true;\n\tif (a.mm > 12) return true;\n\treturn false;\n}\nint main()\n{\n\tint d[3];\n\tscanf(\"%d.%d.%d\",&d[0],&d[1],&d[2]);\n\tDate a(d[0],d[1],d[2]);\n\tscanf(\"%d.%d.%d\",&d[0],&d[1],&d[2]);\n\tsort(d,d + 3);\n\tdo\n\t{\n\t\tDate b(d[0],d[1],d[2]);\n\t\tif (!b.incorrect())\n\t\t{\n\t\t\tb = b.birthday();\n\t\t\tif (b.compareTo(a) <= 0)\n\t\t\t{\n\t\t\t\tcout<<\"YES\";\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t} while( next_permutation(d,d + 3) );\n\tcout<<\"NO\";\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e375d3f767dcfcc0f1efa37d08da0226", "src_uid": "5418c98fe362909f7b28f95225837d33", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "import java.util.Date;\nimport java.util.Locale;\nimport java.io.IOException;\nimport java.text.DateFormat;\nimport java.text.ParseException;\nimport java.text.SimpleDateFormat;\nimport java.util.Calendar;\nimport java.util.Scanner;\npublic class Main {\n\tfinal static String DATE_FORMAT = \"dd.MM.yy\";\n\t\n\tpublic static boolean isDateValid(String date) \n\t{\n\t\ttry {\n\t\t\tDateFormat df = new SimpleDateFormat(DATE_FORMAT);\n\t\t\tdf.setLenient(false);\n\t\t\tdf.parse(date);\n\t\t\treturn true;\n\t\t} catch (ParseException e) {\n\t\t\treturn false;\n\t\t}\n\t}\n\tpublic static Calendar getCalendar(Date date) {\n\t Calendar cal = Calendar.getInstance(Locale.US);\n\t cal.setTime(date);\n\t return cal;\n\t}\n\tpublic static boolean check(String a,String b) throws IOException, ParseException\n\t{\t\n\t\tCalendar m,n;\n\t\tint ans=1;\n\t\tif(!isDateValid(b))\n\t\t\treturn false;\n\t\telse{\n\t\t\tDateFormat df = new SimpleDateFormat(\"dd.MM.yy\");\n\t\t\t\n\t\t\tDate x = df.parse(a);\n\t\t\tDate y = df.parse(b);\n\t\t\t m=getCalendar(x);\n\t\t\tn=getCalendar(y);\n\t\t\tans=m.get(Calendar.YEAR)-n.get(Calendar.YEAR);\n\t\t\tif(n.get(Calendar.MONTH)>m.get(Calendar.MONTH)||n.get(Calendar.DATE)>m.get(Calendar.DATE))\n\t\t\t\tans--;\n\t\t}\n\t\treturn ans>=18;\n\t}\n\tpublic static void main(String args[]) throws IOException, ParseException\n\t{\n\t\tScanner scan=new Scanner(System.in);\n\t\tString d1=scan.nextLine();\n\t\tString d2=scan.nextLine();\n\t\tString b1=d2.substring(0, 2);\n\t\tString b2=d2.substring(3, 5);\n\t\tString b3=d2.substring(6, 8);\n\t\tString ans=\"NO\";\n\t\tif(check(d1, d2)||check(d1, b1+\".\"+b3+\".\"+b2)||check(d1, b2+\".\"+b1+\".\"+b3)||check(d1, b2+\".\"+b3+\".\"+b1)||check(d1, b3+\".\"+b1+\".\"+b2)||check(d1, b3+\".\"+b2+\".\"+b1))\n\t\t\tans=\"YES\";\n\t\tSystem.out.println(ans);\n\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "aa6a5e2966e6c94094410af01f5acf71", "src_uid": "5418c98fe362909f7b28f95225837d33", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include\n#define cin(a) cin>>a;\n#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define cout(a) cout<=x;i--)\n#define TC() ll t;cin>>t;while(t--)\ntypedef long long ll;\n#define MOD 1000000007\n#define SIZE 100020\n#define vec vector\n#define vmp vector >\n#define pb push_back\n#define mp make_pair\n#define all(a) a.begin(), a.end()\n#define ull unsigned long long\nusing namespace std;\nll gcd(ll x,ll y)\n{\n if(y==0)\n return x;\n else\n return gcd(y,x%y);\n}\nint main(){\n cin >> w >> h;\n\tll ans = 0;\n\tfor(int i=1; i\n#define cin(a) cin>>a;\n#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define cout(a) cout<=x;i--)\n#define TC() ll t;cin>>t;while(t--)\ntypedef long long ll;\n#define MOD 1000000007\n#define SIZE 100020\n#define vec vector\n#define vmp vector >\n#define pb push_back\n#define mp make_pair\n#define all(a) a.begin(), a.end()\n#define ull unsigned long long\nusing namespace std;\nll gcd(ll x,ll y)\n{\n if(y==0)\n return x;\n else\n return gcd(y,x%y);\n}\nint main(){\n ll w,h;\n cin >> w >> h;\n\tll ans = 0;\n\tfor(int i=1; i\nusing namespace std;\n#define ll long long\n\nint main() {\n\tll w, h, ret;\n\tscanf(\"%lld %lld\", &w, &h);\n\ta = w >> 1;\n\tb = h >> 1;\n\tret = (a * (a + 1) + (w & 1)) * (b * (b + 1) + (h & 1));\n\tprintf(\"%lld\", ret);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "71319c2912371d4442351a45a34ef129", "src_uid": "42454dcf7d073bf12030367eb094eb8c", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "// Shinchan Loves Coding :)))\n#include\n#include\n#include\nusing namespace std;\n\n#define night_rider ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n#define int long long int\n#define double long double\n#define en \"\\n\"\n#define fi first\n#define se second\n#define MP make_pair\n#define PB push_back\ntypedef vector vi;\ntypedef pair vii;\nbool secdes(const pair&a , const pair&b){if(a.se==b.se){return a.fi>b.fi;}else{return a.se>b.se;}}//second descending !\nbool sir(const pair&a , const pair&b){if(a.fi==b.fi){return a.se>b.se;}else{return a.first>b.first;}}//first descending !\n//bool bysec(const pair&a , const pair&b){if(a.se==b.se)return }\n\nconst int no=3e5+5;\nconst int modulo=1e9+7;\nconst int big=1e7+1;\nint a[no],sumb[no]={},suma[no]={};\n\nsigned main()\n{\n night_rider\n // freopen(\"input.txt\",\"r\",stdin);\n // freopen(\"output.txt\",\"w\",stdout);\n\n int t;\n t=1;\n //cin>>t;\n while(t--)\n {\n \tint w,h;\n \tcin>>w>>h;\n \tfor(int i=1 ; i\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define forn(i, n) for(int i = 0; i < (n); ++i)\n\ntypedef long double DOUBLE;\n\nconst char R = 0;\nconst char G = 1;\nconst char B = 2;\n\nconst char EMPTY = 3;\n\nconst DOUBLE INF = 1e10;\n\ninline char code(char c) {\n if (c == 'R') return R;\n if (c == 'G') return G;\n if (c == 'B') return B;\n return EMPTY;\n}\n\nstruct State {\n char count[3][3][3];\n char have[3];\n char top[3];\n\n State() { memset(this, 0, sizeof(State)); }\n\n inline bool moveTop() {\n if (topFilled()) {\n count[top[0]][top[1]][top[2]]++;\n top[0] = top[1] = top[2] = EMPTY;\n return true;\n }\n return false;\n }\n \n inline bool topFilled() const {\n return top[0] != EMPTY && top[1] != EMPTY && top[2] != EMPTY;\n }\n};\n\ninline bool operator<(const State& s1, const State& s2) {\n return memcmp(&s1, &s2, sizeof(State)) < 0;\n}\n\nmap dp;\n\nDOUBLE DP(State& s);\n\nDOUBLE tryPlace(State& s, char drop) {\n char t0 = s.top[0];\n char t1 = s.top[1];\n char t2 = s.top[2];\n \n bool moved = s.moveTop();\n DOUBLE best = INF;\n forn (i, 3) if (s.top[i] == EMPTY) {\n s.top[i] = drop;\n best = min(best, DP(s));\n s.top[i] = EMPTY;\n }\n if (moved) {\n s.count[t0][t1][t2]--;\n s.top[0] = t0;\n s.top[1] = t1;\n s.top[2] = t2;\n }\n return best;\n}\n\nDOUBLE DP(State& s) {\n auto it = dp.find(s);\n if (it != dp.end()) {\n return it->second;\n }\n int self = 1;\n DOUBLE e = 0.0;\n for (int drop = 0; drop < 3; ++drop) {\n int count = (drop == R) ? 1 : 2;\n DOUBLE best = INF;\n \n if (s.have[drop] > 0) {\n s.have[drop]--;\n best = tryPlace(s, drop);\n s.have[drop]++;\n }\n \n forn (a, 3) forn (b, 3) forn (c, 3) {\n if (s.count[a][b][c] > 0 && (a == drop || b == drop || c == drop)) {\n s.count[a][b][c]--;\n \n if (a == drop) {\n s.have[c]++;\n best = min(best, tryPlace(s, drop));\n s.have[c]--;\n }\n \n \n if (b == drop) {\n best = min(best, tryPlace(s, drop));\n }\n \n if (c == drop && a != drop) {\n s.have[a]++;\n best = min(best, tryPlace(s, drop));\n s.have[a]--; \n }\n \n s.count[a][b][c]++;\n }\n }\n \n \n if (best > 1e9) {\n self += count;\n } else {\n e += count * best;\n }\n }\n \n if (self == 6) {\n return dp[s] = 0.0;\n } \n \n return dp[s] = (1 + e / 6.0) / (1.0 - self / 6.0);\n}\n\nstring input[] = {\n\"RGB\",\n\"GRG\",\n\"BBB\",\n\"GGR\",\n\"BRG\",\n\"BRB\" };\n\nint main() {\n \n State init;\n \n int n = 6;\n cin >> n;\n string s;\n forn (i, n - 1) {\n // s = input[i];\n cin >> s;\n forn (j, 3) s[j] = code(s[j]);\n init.count[s[0]][s[1]][s[2]]++;\n }\n s = input[n - 1];\n cin >> s;\n forn (j, 3) init.top[j] = code(s[j]);\n // init.normalizeTop();\n \n cout << fixed << setprecision(12) << (double) DP(init) << endl;\n // cout << dp.size() << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "eb0dea16b22911a12345f26be482d2eb", "src_uid": "bdcefa26de49e0e9d4d10d138443aa8a", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\nusing ull = unsigned long long;\nconstexpr ull none = 0, red = 1, blue = 2, green = 3;\nconstexpr ull sort(ull x) {\n // cerr << bitset<54>(x) << \"->\";\n#define INIT(X) unsigned x##X = (x >> ((X) + 1) * 6) & 0b111111\n INIT(0); INIT(1); INIT(2); INIT(3);\n INIT(4); INIT(5); INIT(6); INIT(7);\n#undef INIT\n#define SWAP(X, Y) \\\n do { \\\n unsigned temp = ((x##X ^ x##Y) & -(x##X < x##Y)); \\\n x##X ^= temp; \\\n x##Y ^= temp; \\\n } while (0) \n SWAP(0, 1); SWAP(2, 3); SWAP(4, 5); SWAP(6, 7);\n SWAP(0, 2); SWAP(1, 3); SWAP(4, 6); SWAP(5, 7);\n SWAP(1, 2); SWAP(5, 6); SWAP(0, 4); SWAP(3, 7);\n SWAP(1, 5); SWAP(2, 6);\n SWAP(1, 4); SWAP(3, 6);\n SWAP(2, 4); SWAP(3, 5);\n SWAP(3, 4);\n#undef SWAP\n x &= 0b111111;\n#define MERGE(X) (x |= (ull) x##X << ((X + 1) * 6))\n MERGE(0); MERGE(1); MERGE(2); MERGE(3);\n MERGE(4); MERGE(5); MERGE(6); MERGE(7);\n#undef MERGE\n // cerr << bitset<54>(x) << endl;\n return x;\n}\nconstexpr unsigned encode(char l, char c, char r) {\n unsigned vl = l == 'R' ? red : l == 'G' ? green : blue;\n unsigned vc = c == 'R' ? red : c == 'G' ? green : blue;\n unsigned vr = r == 'R' ? red : r == 'G' ? green : blue;\n if(vl > vr)\n swap(vl, vr);\n return (vc << 4) | (vl << 2) | vr;\n}\nstd::unordered_map dp;\ndouble solve(ull tower);\ndouble solve(ull tower, unsigned put) {\n if((tower & 0b11) && (tower & 0b1100) && (tower & 0b110000)) {\n tower = sort(tower) << 6;\n }\n double best = 1e9;\n if(!(tower & 0b110000))\n best = min(best, solve(tower | (put << 4)));\n if(!(tower & 0b1100))\n best = min(best, solve(tower | (put << 2)));\n if(!(tower & 0b11))\n best = min(best, solve(tower | put));\n#if 0\n else if(!(tower & 0b11)) {\n if(put > ((tower >> 2) & 0b11))\n best = min(best, solve(tower | put));\n else\n best = min(best, solve((tower & ~0b1100ull) |\n (put << 2) |\n ((tower >> 2) & 0b11)));\n }\n#endif\n return best;\n}\ndouble solve(ull tower) {\n if(!(tower & ~0b111111ull))\n return 0.0;\n tower = sort(tower);\n {\n auto ite = dp.find(tower);\n if(ite != dp.end())\n return ite->second;\n }\n double ans = 0;\n int progress = 0;\n for(unsigned i = red; i <= green; i++) {\n#define HASZERO(V) (((V) - (~0ull / 3)) & ~(V) & (~0ull / 3 * 2))\n#define HASVALUE(X, N) (HASZERO((X) ^ (~0ull / 3 * (N))))\n if(!HASVALUE(tower >> 6, i))\n continue;\n#undef HASVALUE\n#undef HASZERO\n double best = 1e9;\n for(int j = 6; tower & (0b111111ull << j); j += 6) {\n if(((tower >> j) & 0b11) == i) {\n best = min(best,\n solve(tower & ~(0b110011ull << j), i));\n }\n if(((tower >> (j + 2)) & 0b11) == i) {\n ull x = ~(0b111111ull << j);\n ull y = ((tower >> j) & 0b11) << (j + 2);\n best = min(best, solve((tower & x) | y, i));\n }\n if(((tower >> (j + 4)) & 0b11) == i) {\n best = min(best,\n solve(tower & ~(0b111111ull << j), i));\n }\n }\n ans += best * (i == red ? 1 : 2);\n progress += (i == red ? 1 : 2);\n }\n ans = (ans + 6) / progress;\n dp.insert(make_pair(tower, ans));\n return ans;\n} \nint main() {\n int n;\n while(scanf(\"%d\", &n) == 1) {\n ull tower = 0;\n for(int i = n - 1; i >= 0; i--) {\n char s[4];\n scanf(\"%s\", s);\n tower |= (ull) encode(s[0], s[1], s[2]) << (i * 6);\n }\n printf(\"%.15f\\n\", solve(tower));\n }\n}\n\n\n// ntuj - jczj97dvo8n70pj70e6v4", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f8d294c35ac19b18f5eba5e13f58c0c2", "src_uid": "bdcefa26de49e0e9d4d10d138443aa8a", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\ninline char get_unempty_char()\n{\n\tchar ch;\n\twhile(isspace(ch=getchar())) ;\n\treturn ch;\n}\nconst double eps(1e-10),Inf=1e+64;\ntypedef unsigned long long i64u;\nconst int RED=1,BLUE=2,GREEN=3,EMPTY=0,N=6,Base=67,mod=3000007;\nint n,last[mod]={},next[mod]={},total_edge=0,s[N*3-1]={},tot=0;\ni64u hv[mod]={};\ndouble f[mod]={};\ninline void add(i64u hash,double v)\n{\n\tint u=hash%mod;\n\tnext[++total_edge]=last[u];\n\tlast[u]=total_edge;\n\tf[total_edge]=v;\n\thv[total_edge]=hash;\n}\ninline int get_num(char ch)\n{\n\tif(ch=='R') return RED;\n\tif(ch=='B') return BLUE;\n\tif(ch=='G') return GREEN;\n\tif(ch=='E') return EMPTY;\n\tassert(false);\n}\nvoid init()\n{\n\tn=get_unempty_char()-'0';\n\tfor(int i=1;i<=n;++i)\n\t{\n\t\ts[i]|=get_num(get_unempty_char())<<0;\n\t\ts[i]|=get_num(get_unempty_char())<<2;\n\t\ts[i]|=get_num(get_unempty_char())<<4;\n\t}\n\ttot=n;\n}\ninline i64u hash(int *s,int k,int up)\n{\n\tstatic int v[N*3+10]={};\n\ti64u h=0;\n\tint tot=0;\n\tfor(int i=1;i<=k;++i)\n\t{\n\t\tint c1=(s[i]>>4)&3 , c2=(s[i])&3 , c3=(s[i]>>2)&3;\n\t\tv[++tot]=c1>c2 ? (c3<<2)|c1|(c2<<4) : (c3<<2)|c2|(c1<<4);\n\t}\n\tsort(v+1,v+tot+1);\n\tint c1=(up>>4)&3 , c2=up&3 , c3=(up>>2)&3;\n\tif(c1>c2) up=c1|(c2<<4)|(c3<<2);\n\tfor(int i=1;i<=tot;++i)\n\t\th=h*Base+v[i];\n\th=h*Base+up;\n\treturn h;\n}\ndouble work(int *s,int tot,int up)\n{\n\ti64u h=hash(s,tot,up);\n\tfor(int i=last[h%mod];i;i=next[i])\n\t\tif(hv[i]==h)\n\t\t\treturn f[i];\n\tdouble v[4]={Inf,Inf,Inf,Inf};\n\tint to=tot,D=6;\n\tif((up&3) && ((up>>2)&3) && ((up>>4)&3))\n\t\ts[++to]=up , up=0;\n\tfor(int i=1;i<=tot;++i)\n\t{\n\t\tint c1=s[i]&3 , c2=(s[i]>>2)&3 , c3=(s[i]>>4)&3 , ns=s[i];\n\t\tif(c1 && c2 && c3 && v[c2]>eps)\n\t\t{\n\t\t\ts[i]=0;\n\t\t\tif(!(up&3)) v[c2]=min(v[c2],work(s,to,up|c2));\n\t\t\telse if(!(up>>4&3)) v[c2]=min(v[c2],work(s,to,up|c2<<4));\n\t\t\tif(!(up>>2&3)) v[c2]=min(v[c2],work(s,to,up|c2<<2));\n\t\t\ts[i]=ns;\n\t\t}\n\t\tif(c1 && c2 && v[c1]>eps)\n\t\t{\n\t\t\ts[i]=c3==0 ? 0 : s[i]&~3;\n\t\t\tif(!(up&3)) v[c1]=min(v[c1],work(s,to,up|c1));\n\t\t\telse if(!(up>>4&3)) v[c1]=min(v[c1],work(s,to,up|c1<<4));\n\t\t\tif(!(up>>2&3)) v[c1]=min(v[c1],work(s,to,up|c1<<2));\n\t\t\ts[i]=ns;\n\t\t}\n\t\tif(c2 && c3 && v[c3]>eps)\n\t\t{\n\t\t\ts[i]=c1==0 ? 0 : s[i]&~48;\n\t\t\tif(!(up&3)) v[c3]=min(v[c3],work(s,to,up|c3));\n\t\t\telse if(!(up>>4&3)) v[c3]=min(v[c3],work(s,to,up|c3<<4));\n\t\t\tif(!(up>>2&3)) v[c3]=min(v[c3],work(s,to,up|c3<<2));\n\t\t\ts[i]=ns;\n\t\t}\n\t}\n\tdouble sum=0;\n\tif(v[1]!=Inf) sum+=v[1] , D-=1;\n\tif(v[2]!=Inf) sum+=v[2]*2 , D-=2;\n\tif(v[3]!=Inf) sum+=v[3]*2 , D-=2;\n\tsum=D==6 ? 0 : (sum+6)/(6-D);\n\tadd(h,sum);\n\treturn sum;\n}\nint main()\n{\t\n\t//freopen(\"jenga.in\",\"r\",stdin);\n\t//freopen(\"jenga.out\",\"w\",stdout);\n\tinit();\n\tprintf(\"%.15f\\n\",work(s,tot-1,s[tot]));\n\t//fclose(stdin);\n\t//fclose(stdout);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9d9302ad6cda42cca516e0dc208470d0", "src_uid": "bdcefa26de49e0e9d4d10d138443aa8a", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "//\u0479\ufffd\u043f\u03b4\ufffd\n#include\n#define ull unsigned long long\nconst double eps=1e-12,inf=1e12;\nconst int mod=(1<<20)-1,Base=65,Red=1,Blue=2,Green=3,empty=0;\nusing namespace std;\nint n,f[20],s[1<<6],tot,nxt[mod+1],from[mod+1],t;\ndouble ans[mod+1];\null w[mod+1];\ninline char read(){char ccc;while(isspace(ccc=getchar()));return ccc;}\ninline int Read(char ccc){if(ccc=='R') return Red;if(ccc=='B') return Blue;if(ccc=='G') return Green;return empty;}\ninline void add(ull u,double v){int x=u&mod;ans[++t]=v;nxt[t]=from[x];from[x]=t;w[t]=u;}\ninline ull HASH(int *a,int k,int up)\n{\n\tull sum=0;\n\tstatic int g[20];\n\tint h=0;\n\tfor(int i=1;i<=k;++i) if(a[i]) g[++h]=a[i];\n\tsort(g+1,g+1+h);\n\tfor(int i=1;i<=h;++i) sum=sum*Base+g[i];\n\tsum=sum*Base+up;\n\treturn sum;\n}\ninline double query(int *a,int k,int up)\n{\n\tup=s[up];\n\tull op=HASH(a,k,up);\n\tfor(int i=from[op&mod];i;i=nxt[i]) if(w[i]==op) return ans[i];\n\tdouble v[4]={inf,inf,inf,inf};\n\tint oto=k,D=6;\n\tif((up&3)&&((up>>2)&3)&&((up>>4)&3)) f[++oto]=up,up=0;\n\tfor(int i=1;i<=k;++i)\n\t{\n\t\tint c1=f[i]&3,c2=(f[i]>>2)&3,c3=(f[i]>>4)&3,opp=f[i];\n\t\tif(c1&&c2&&c3&&v[c2]>eps)\n\t\t{\n\t\t\tf[i]=0;\n\t\t\tif(!(up&3)) v[c2]=min(v[c2],query(f,oto,up|c2));\n\t\t\telse if(!(up>>4&3)) v[c2]=min(v[c2],query(f,oto,up|c2<<4));\n\t\t\tif(!(up>>2&3)) v[c2]=min(v[c2],query(f,oto,up|c2<<2));\n\t\t\tf[i]=opp;\n\t\t}\n\t\tif(c1&&v[c1]>eps)\n\t\t{\n\t\t\tf[i]=c3;\n\t\t\tif(!(up&3)) v[c1]=min(v[c1],query(f,oto,up|c1));\n\t\t\telse if(!(up>>4&3)) v[c1]=min(v[c1],query(f,oto,up|c1<<4));\n\t\t\tif(!(up>>2&3)) v[c1]=min(v[c1],query(f,oto,up|c1<<2));\n\t\t\tf[i]=opp;\n\t\t}\n\t\tif(c3&&v[c3]>eps)\n\t\t{\n\t\t\tf[i]=c1;\n\t\t\tif(!(up&3)) v[c3]=min(v[c3],query(f,oto,up|c3));\n\t\t\telse if(!(up>>4&3)) v[c3]=min(v[c3],query(f,oto,up|c3<<4));\n\t\t\tif(!(up>>2&3)) v[c3]=min(v[c3],query(f,oto,up|c3<<2));\n\t\t\tf[i]=opp;\n\t\t}\n\t}\n\tdouble sum=0;\n\tif(v[1]!=inf) sum+=v[1],D--;\n\tif(v[2]!=inf) sum+=v[2]*2,D-=2;\n\tif(v[3]!=inf) sum+=v[3]*2,D-=2;\n\tsum=(D==6?0:(sum+6)/(6-D));\n\tadd(op,sum);\n\treturn sum;\n}\nint main()\n{\n//\tfreopen(\"jenga.in\",\"r\",stdin);\n//\tfreopen(\"jenga.out\",\"w\",stdout);\n\tn=read()^'0';\n\tfor(int i=0;i<=3;++i)\n\t\tfor(int j=0;j<=3;++j)\n\t\t\tfor(int k=0;k<=3;++k)\n\t\t\t\ts[i|j<<2|k<<4]=i\nusing namespace std;\ntypedef long long int ll;\nconst int N=50050;\nint n, m, a[N], cp[N];\nint b[N], d[N], ans[N];\nbool vis[N];\nvectorg[N];\nbool find(int u){\n\tfor(int v: g[u]){\n\t\tif(!vis[v]){\n\t\t\tvis[v] = 1;\n\t\t\tif(cp[v]==-1||pipei(cp[v]){\n\t\t\t\tcp[v] = u;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}\n\nint main(){\n\tscanf(\"%d%d\",&n,&m);\n\tint v,q;\n\tmemset(cp,-1,sizeof(cp));\n\tfor(int i=1;i<=n;i++) scanf(\"%d\",a+i);\n\tfor(int i=1;i<=n;i++){\n\t\tscanf(\"%d\",b+i);\n\t}\n\tscanf(\"%d\",&q);\n\tfor(int i=1;i<=q;i++) scanf(\"%d\",d+i),vis[d[i]] = 1;\n\tfor(int i=1;i<=n;i++)\n\tif(!vis[i]) g[a[i]].push_back(b[i]);\n\tint j = 0;\n\tfor(int i=q;i>=1;i--){\n\t\tfor(;j<5000;j++){\n\t\t\tmemset(vis,0,sizeof(vis));\n\t\t\tif(!find(j)) break;\n\t\t}\n\t\tg[a[d[i]]].push_back(b[d[i]]);\n\t\tans[i] = j;\n\t}\n\tfor(int i=1;i<=q;i++) printf(\"%d\\n\",ans[i]);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8b92235dae068ccba31fb5772b6674c9", "src_uid": "ff810b16b6f41d57c1c8241ad960cba0", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef long long int ll;\nconst int N=50050;\nint n, m, a[N], cp[N];\nint b[N], d[N], ans[N];\nbool vis[N];\nvectorg[N];\nbool find(int u){\n\tfor(int v: g[u]){\n\t\tif(!vis[v]){\n\t\t\tvis[v] = 1;\n\t\t\tif(cp[v]==-1||pipei(cp[v])){\n\t\t\t\tcp[v] = u;\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}\n\nint main(){\n\tscanf(\"%d%d\",&n,&m);\n\tint v,q;\n\tmemset(cp,-1,sizeof(cp));\n\tfor(int i=1;i<=n;i++) scanf(\"%d\",a+i);\n\tfor(int i=1;i<=n;i++){\n\t\tscanf(\"%d\",b+i);\n\t}\n\tscanf(\"%d\",&q);\n\tfor(int i=1;i<=q;i++) scanf(\"%d\",d+i),vis[d[i]] = 1;\n\tfor(int i=1;i<=n;i++)\n\tif(!vis[i]) g[a[i]].push_back(b[i]);\n\tint j = 0;\n\tfor(int i=q;i>=1;i--){\n\t\tfor(;j<5000;j++){\n\t\t\tmemset(vis,0,sizeof(vis));\n\t\t\tif(!find(j)) break;\n\t\t}\n\t\tg[a[d[i]]].push_back(b[d[i]]);\n\t\tans[i] = j;\n\t}\n\tfor(int i=1;i<=q;i++) printf(\"%d\\n\",ans[i]);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "71137314925cccce3807287d7ecfc7b7", "src_uid": "ff810b16b6f41d57c1c8241ad960cba0", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define MOD 1000000007\n#define ll long long\nvector X[100005];\nll dp[100005], fp[1003];\nll power(ll N, ll expo)\n{\n ll ans = 2;\n while(expo)\n {\n if(expo % 2)\n ans = ans * N % MOD;\n N = N * N % MOD;\n expo /= 2;\n }\n return ans;\n}\n\nint main() {\n ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10);\n int M;\n cin >> M\n ll ans = 0;\n ll mmi = power(M, MOD-2);\n for(int i=2; i<=M; i++)\n {\n for(int j=i; j=0; j--)\n {\n fp[j] = M / X[i][j+1];\n for(int k=j+1; k<(int)X[i].size(); k++)\n if(X[i][k] % X[i][j] == 0)\n fp[j] -= fp[k];\n dp[i] += 1LL * dp[ X[i][j] ] * fp[j] % MOD;\n }\n dp[i] = dp[i] % MOD * power(M - M/i, MOD-2) % MOD;\n ans += dp[i];\n }\n ans = (ans % MOD * mmi + 1) % MOD;\n cout << ans << \"\\n\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "15843f066b1dc6ddd7ad49b48aa4f814", "src_uid": "ff810b16b6f41d57c1c8241ad960cba0", "difficulty": 2300.0} {"lang": "GNU C++17", "source_code": "#include\n#define ll long long int\n#define ull unsigned long long int\n#define ld long double\n#define pb push_back\n#define pf pop_front\n#define mp make_pair\n#define mod 1000000007\n#define mat vector>\nusing namespace std;\n#define int ll\n#define for1(i,a,b) for(int i=a;ians)ans=i;return ans;}\n//int min(auto a){int ans=1e18;for(int i:a)if(i>n;\n#define inpa(a,n) int a[n];fo(i,n)cin>>a[i];\nint modpow(int a,int n,int m=1e9+7)\n{\n\tint ans=1;\n\twhile(n>0)\n\t{\n\t\tif(n%2!=0)\n\t\t\tans=(ans*a)%m;\n\t\tn/=2;\n\t\ta=(a*a)%m;\n\t}\n\treturn ans;\n}\n\nsigned main()\n{\n\tint m;\n\tcin>>m;\n\tint ans=modpow(m,mod-2);\n\tint do1[m+1];\n\tfor(int i=0;i<=m;i++)\n\t\tdo1[i]=1;\n\tfor(int i=2;i<=m;i++)\n\t{\n\t\tans=((ans+(do1[i]*(modpow((m*(m-m/i))%mod,mod-2)*((((2*m-m/i))%mod*x)%mod))%mod)%mod)%mod+mod)%mod;\n\t\tfor(int j=i*2;j<=m;j+=i)\n\t\t\tdo1[j]-=do1[i];\n\t}\n\tcout<\n#include \n\nusing namespace std;\n\nint main()\n{\n int a[5];\n\n cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];\n \n sort(&a[0] &a[5]);\n \n int sum = a[0] + a[1] + a[2] + a[3] + a[4];\n \n bool f = true;\n \n for(i = 0; i + 2 < 5; i++)\n {\n if(a[i] == a[i + 1] == a[i + 2])\n {\n f = false;\n sum = sum - a[i] * 3;\n break;\n }\n }\n \n if(f)\n {\n for(i = 0; i + 1 < 5; i++)\n {\n sum = sum - a[i] * 2;\n break;\n }\n }\n \n cout << sum << endl;\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8ab27c9f7c0c0a3dee1a4f88373c0dc1", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint main()\n{\n int i,j,a[5],temp,p=0,sum=0,k=0;\n for(i=0;i<5;i++)\n cin>>a[i];\n for(i=0;i<5;i++)\n for(j=0;j<4;j++)\n {\n if(a[j]2))\n sum+=a[i];\n else\n k++;\n cout<\n// #include \n\nusing namespace::std;\n\nstruct NumInfo\n{\n\tint totalPoint = 0;\n\n\tvoid PlusPlus(const int&);\n\nprivate:\n\tint _numOfRepetition = 0;\n};\n\nvoid NumInfo::PlusPlus(const int& number)\n{\n\tif ((_numOfRepetition < 3) && (++_numOfRepetition > 1))\n\t\ttotalPoint = number * _numOfRepetition;\n}\n\nint main()\n{\n\tint f[5];\n\tNumInfo g[110];\n\tint maxDiscard = 0;\n\tint sum = 0;\n\n\tfor (int i = 0; i < 5; ++i)\n\t{\n\t\tscanf(\"%d\", f + i);\n\t\tsum += f[i];\n\n\t\tg[f[i]].PlusPlus(f[i]);\n\t\tif (maxDiscard < g[f[i]].totalPoint)\n\t\t\tmaxDiscard = g[f[i]].totalPoint;\n\t}\n\t\n\tprintf(\"%d\", sum - maxDiscard);\n\n\t// _getch();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "58509804b102418e67b449e08243c311", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int c,total=0,mayor=0,menor=99999999;\n vector nums;\n for(int i =0; i<5;i++){\n cin >> c;\n total = total + c;\n nums.push_back(c);\n }\n mayor = total;\n for(int i =0;imayor){menor = mayor;}\n mayor = total;\n\n }\n cout << menor;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7f0e1e96c84db6683b781e5bc4c2fdc5", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \"stdio.h\"\n#include \"iostream\"\n#include \"stdlib.h\"\n#include \"math.h\"\n#include \"string.h\"\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint main(){\n\tlong double n,ans=0; cin >> n;\n\tfor (int i = 1; i <= n; i++)\n\t\tans += to_string(i).length();\n\t\tcout << ans;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b5767fe43fdd401bf2d6b60a7f88e8d8", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nint main()\n{\n int n;\n cin >> n;\n int count = 0;\n int buf = n;\n while(buf != 0)\n {\n buf /= 10;\n count++;\n } \n/////////////////////////\n buf=n;\n \tint result=0;\n while(count>=0)\n { \n if(count==1) \n\t\t{\n \t\tresult=n;\n break;\n \t\t}\n result+=buf-pow(10,count-1)*count;\n buf=pow(10,count-1)-1;\n count--; \n }\n ///////////////////////\n \u0441out<\nusing namespace std;\nint tavan10(int a){\n int b=1;\n for(int i=0;i0;i++){\n n=n/10;\n b++;\n }\n return b;\n}\nint main(){\n long long int n;\n int x;\n cin>>n;\n x=andaze(n);\n long long int y=0\n (for(int i=x-2;i>0;i--){\n y=y+tavan10(i);\n }\n cout<\nusing namespace std;\n\nlong long ans = 0, n;\n\nint main() {\n cin >> n;\n int tmp = 9;\n for (int i = 1; i <= 10; i++) {\n ans += (i * (min(n, tmp)));\n n -= min(n, tmp);\n tmp *= 10;\n }\n cout << ans << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ab76541a68b7220f36951758f9270d5b", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#include \n#include \"string.h\"\nusing namespace std;\n\nint main(){\n \n string pearls;\n int c1=0,c2=0;\n cin>>pearls;\n int x=pearls.size();\n for(int i=0;i\n#include\nusing namespace std;\nint main()\n{\n\tstring a;\n\tcin>>a;\n\tint m1=a.size();\n\tint zz=0,xl=0;\n\tfor(int i=0;i\n#include\n#include\n#include\n#include\nusing namespace std;\nconst int maxn=1e5;\nint n,t,sum,ans;\nchar s[maxn];\nint a[maxn];\nint main(){\nscanf(\"%s\",s);\nn=strlen(s);\nfor(int i=0;i\n#include\n#include \n#include\nusing namespace std;\n\n#define pb(x) push_back(x) \n#define fr(a,b) for(int i=a;i>s;\n int cnt=0;\n fr(0,s.length())\n {\n if(s[i]=='o')\n {\n cnt++;\n }\n }\n if(cnt==(s.length()-1))\n {\n cout<<\"no\";\n }\n else if(cnt==s.length() || cnt==0 || cnt==(s.length()-cnt))\n {\n cout<<\"Yes\";\n }\n else if(cnt<(s.length-cnt))\n {\n cout<<\"no\";\n }\n else if(cnt%(s.length()-cnt)==0 || (s.length()-cnt)%cnt==0 )\n {\n cout<<\"yes\";\n }\n else\n {\n cout<<\"no\";\n }\n \n \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b749e3fb822a493d64bd0ed57bd8b066", "src_uid": "6e006ae3df3bcd24755358a5f584ec03", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\n\nint main(){\n int n,m;\n\n cin>>n,m;\n\n int prod = n * m;\n int mod = prod % 2;\n \n if((mod % 2) == 0 )\n cout<<\"Malvika\"<\nusing namespace std;\nint main(){\nint m,n,;\ncin >>m,n;\n\nif (m>n) i=n; \n else i=m;\nif (i%2==0) cout<<\"Malvika\";\n else cout <<\"Akshat\";\n }", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d20a0d2abe49e86c64e9f097fe1e41c4", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include\n\nusing namespace std;\n\nint main()\n{\n int n,i,j,k,t,m;\n\n cin>>n>>m;\n\n int s=m*n;\n if(s==2)cout<<\"Akshat\"<\nusing namespace std;\nint main(){\n int i,j,multi;\n cin>>i;\n cin>>j;\n multi = i*j;\n if(multi==2){\n cout<<\"Akshat\";\n }\n if((multi%2=0)&&(multi!=2)){\n cout<<\"Malvika\"; }\n else {\n cout<<\"Akshat\";\n \n }\n }", "lang_cluster": "C++", "compilation_error": true, "code_uid": "130bdbce31079d7063c7bf12ba63da34", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "/*\n * File: G.cpp\n * Author: yzq110abc\n *\n * Created on 2010\u5e7412\u670810\u65e5, \u4e0b\u53487:10\n */\n\n#include \n#include \n#include \n#include \n#define EPS (1e-9)\nusing namespace std;\n\nconst int MAXL = 20000;\n\ntypedef pair Edge;\nEdge p[MAXL];\nvector e;\n\nint Init(){\n\n for (int i = 0; i * i < MAXL; i++){\n for (int j = i + 1; j * j + i * i < MAXL; j++){\n int now = i * i + j * j;\n p[now].first = i;\n p[now].second = j;\n }\n }\n return 0;\n}\n\ninline bool cmp(Edge a, Edge b){\n return a.first * a.first + a.second * a.second >\n b.first * b.first + b.second * b.second;\n}\n\ninline bool cmp2(Edge a, Edge b){\n return atan2(a.second, a.first) < atan2(a.second, a.first) - EPS;\n}\n\nint L(int a, int b){\n return a * a + b * b;\n}\n\nint main() {\n\n Init();\n int n;\n int sum = 0;\n scanf(\"%d\", &n);\n for (int i = 0; i < MAXL && e.size() <= n; i++){\n if (p[i].first == 0 && p[i].second == 0) continue;\n sum ^= p[i].first ^ p[i].second;\n e.push_back(p[i]);\n }\n reverse(e.begin(), e.end());\n for (vector::iterator it = e.begin(); it != e.end(); it++){\n if ( ( ( sum ^ it->first ^ it->second) & 1) == 0){\n e.erase(it);\n break;\n }\n }\n sort(e.begin(), e.end(), cmp);\n int ix = 0, iy = 0;\n for (vector::iterator it = e.begin(); it != e.end(); it++){\n int fx = 1, fy = 1;\n int xx = it->first, yy = it->second;\n if (ix > 0) fx = -1;\n if (iy > 0) fy = -1;\n \n if (L(fx * xx + ix, fy * yy + iy) < L(fx * yy + ix, fy * xx + iy))\n *it = make_pair(fx * xx, fy * yy);\n else\n *it = make_pair(fx * yy, fy * xx);\n ix = it->first + ix;\n iy = it->second + iy;\n }\n sort(e.begin(), e.end(), cmp2);\n puts(\"YES\");\n for (vector::iterator it = e.begin(); it != e.end(); it++){\n printf(\"%d %d\\n\", ix, iy);\n ix += it->first;\n iy += it->second;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "058fb913a9c9810f3ae3dfeb6e416743", "src_uid": "77b281558c480607b02e8e263e81a455", "difficulty": 2500.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)\n#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)\n\n#define M 100000\nint dx[M],dy[M];\n\nint x[10010],y[10010];\n\nint main2(int N){\n int i,j;\n \n// cin >> N;\n \n for(i=0;i*i=0;i--){\n if(X > 0) x[i] = -x[i]; X += x[i];\n if(Y > 0) y[i] = -y[i]; Y += y[i];\n }\n if(X == 0 && Y == 0) break;\n \n REP(i,N){\n x[i] = abs(x[i]);\n y[i] = abs(y[i]);\n }\n \n while(1){\n int r = rand() % N;\n if(x[r] % 2 == y[r] % 2){\n swap(x[r],y[r]);\n break;\n }\n }\n }\n \n// cout << N << endl;\n// if(X != 0 || Y != 0) cout << \"warning\" << endl;\n// REP(i,N) cout << x[i] << ' ' << y[i] << endl;\n\n vector > v;\n REP(i,N){\n double theta = atan2(y[i],x[i]);\n v.push_back(make_pair(theta,i));\n }\n sort(v.begin(),v.end());\n \n printf(\"YES\\n\");\n xsum = 0; ysum = 0;\n REP(i,N){\n printf(\"%d %d\\n\",xsum,ysum);\n int id = v[i].second;\n xsum += x[id]; ysum += y[id];\n }\n \n return 0;\n}\n\nint main(void){\n// for(int i=3;;i++) main2(i);\n int N;\n cin >> N;\n main2(N);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0421205ef56c873a092d5b0637974ce1", "src_uid": "77b281558c480607b02e8e263e81a455", "difficulty": 2500.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int LIMIT = 1000000;\n\ntypedef pair PII;\nPII p[LIMIT];\nvector v;\n\ninline bool pr(const PII& lhs, const PII& rhs) {\n return atan2(lhs.second, lhs.first) < atan2(rhs.second, rhs.first) - 1e-8;\n}\n\ninline int R(const PII& p) {\n return p.first * p.first + p.second * p.second;\n}\n\nint main() {\n int n, s, x, y, nx, ny, tx, ty, dx, dy;\n\n scanf(\"%d\", &n);\n for (int i = 0, ii; (ii = i * i) < LIMIT; ++i) {\n for (int j = i, jj; (jj = i * i + j * j) < LIMIT; ++j) {\n p[jj].first = i;\n p[jj].second = j;\n }\n }\n\n s = 0;\n for (int i = 0; i < LIMIT && (int)v.size() <= n; ++i) {\n if (p[i].first != 0 || p[i].second != 0) {\n s += R(p[i]);\n v.push_back(p[i]);\n }\n }\n \n reverse(v.begin(), v.end());\n for (vector::iterator it = v.begin(); it != v.end(); ++it) {\n if ((s - R(*it)) % 2 == 0) {\n v.erase(it);\n break;\n }\n }\n\n x = y = 0;\n for (vector::iterator it = v.begin(); it != v.end(); ++it) {\n nx = ny = LIMIT;\n dx = it->first;\n dy = it->second;\n for (int i = 0; i < 2; ++i) {\n for (int j = 0; j < 2; ++j) {\n for (int k = 0; k < 2; ++k) {\n tx = x + dx;\n ty = y + dy;\n if (abs(tx) + abs(ty) < abs(nx) + abs(ny)) {\n nx = tx;\n ny = ty;\n *it = make_pair(dx, dy);\n }\n dx = -dx;\n }\n dy = -dy;\n }\n swap(dx, dy);\n }\n x = nx;\n y = ny;\n }\n\n sort(v.begin(), v.end(), pr);\n x = y = 0;\n puts(\"YES\");\n for (vector::iterator it = v.begin(); it != v.end(); ++it) {\n printf(\"%d %d\\n\", x, y, atan2(it->second, it->first));\n x += it->first;\n y += it->second;\n }\n if (x != 0 || y != 0) {\n throw 1;\n }\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4fa0ccfb183e634560d01551d2bdc1ee", "src_uid": "77b281558c480607b02e8e263e81a455", "difficulty": 2500.0} {"lang": "MS C++", "source_code": "//UW 4feet\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n#define X first\n#define Y second\n#define FI first\n#define SE second\n#define ST first\n#define ND second\n#define MP make_pair\n#define PB push_back\ntypedef long long LL;\ntypedef double D;\ntypedef long double LD;\ntypedef vector VI;\ntypedef pair PII;\n#define REP(i,n) for (int i=0;i<(n);++i)\n#define FOR(i,a,b) for (VAR(i,a);i<=(b);++i)\n#define FORD(i,a,b) for(VAR(i,a);i>=(b);--i)\n#define FORE(e,v) for(VAR(e,v.begin());e!=v.end();++e)\n#define VAR(a,b) __typeof(b) a=(b)\n#define SIZE(a) ((int)(a).size())\n#define ALL(x) (x).begin(),(x).end()\n#define CLR(x,a) memset(x,a,sizeof(x))\n\nconst int M = 100013;\n\nset s;\nint a[M], px[M];\nvector > t;\nPII xx[M];\n\nint main() {\n srand(1313);\n int n;\n scanf(\"%d\",&n);\n REP(i,M) a[i] = i;\n a[0] = 1;\n LL sx = 0, sy = 0;\n REP(j,n+1)\n {\n int x = 0;\n LL r = 1LL*a[0]*a[0];\n REP(i,M) \n {\n while(s.count(1LL*i*i + 1LL*a[i]*a[i])) a[i]++;\n if(1LL*i*i + 1LL*a[i]*a[i] < r) x = i, r = 1LL*i*i + 1LL*a[i]*a[i];\n if(a[i]==i) break;\n }\n if(rand()%2)\n {\n sx += x;\n sy += a[x];\n t.PB(MP(atan2(a[x],x),MP(x,a[x])));\n }\n else\n {\n sx += a[x];\n sy += x;\n t.PB(MP(atan2(x,a[x]),MP(a[x],x)));\n }\n s.insert(r);\n a[x]++;\n }\n FORD(i,SIZE(t)-1,1)\n if((sx-t[i].Y.X)%2 == (sy-t[i].Y.Y)%2)\n {\n sx -= t[i].Y.X;\n sy -= t[i].Y.Y;\n FOR(j,i,SIZE(t)-2) t[j] = t[j+1];\n t.pop_back();\n if(sx%2) \n swap(t[0].Y.X,t[0].Y.Y);\n break;\n } \n REP(i,n) xx[i] = MP(t[i].Y.X,i);\n sort(xx,xx+n);\n int ss = 0;\n FORD(i,n-1,0) if(ss <= 0)\n {\n ss += xx[i].X;\n }\n else\n {\n t[xx[i].Y].Y.X *= -1;\n ss -= xx[i].X;\n }\n if(ss) while(1);//return -1/0;\n REP(i,n) xx[i] = MP(t[i].Y.Y,i);\n sort(xx,xx+n);\n ss = 0;\n FORD(i,n-1,0) if(ss <= 0)\n {\n ss += xx[i].X;\n }\n else\n {\n t[xx[i].Y].Y.Y *= -1;\n ss -= xx[i].X;\n }\n if(ss) while(1);//return -1/0;\n REP(i,n) t[i].X = atan2(t[i].Y.Y, t[i].Y.X);\n sort(t.begin(),t.end());\n sx = 0, sy = 0;\n puts(\"YES\");\n REP(i,n)\n {\n cout << sx << \" \" << sy << endl;\n sx += t[i].Y.X;\n sy += t[i].Y.Y;\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bc7534b4e68a29b960fc4be9eb7b793a", "src_uid": "77b281558c480607b02e8e263e81a455", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\n#define MAX_N 200000\n\nint n;\nint numbers[MAX_N];\nint exists[MAX_N + 1];\n\nstruct TNode {\n int l, r, sum;\n TNode *left, *right;\n int first, last;\n};\n\ndeque nodes;\n\nTNode *root;\n\nTNode* newNode() {\n nodes.push_back();\n return &nodes.back();\n}\n\nNode* fillNode(int first, int last) {\n if (first >= last) {\n return nullptr;\n }\n int mid = (first + (last - first) / 2);\n Node * result = newNode();\n result->first = first;\n result->last = last;\n result->l = first;\n result->r = last - 1;\n result->left = fillNode(l, mid);\n result->right = fillNode(mid + 1, r);\n result->sum = 0;\n if (!result->left && !result->right) {\n result->sum = l;\n } else {\n if (result->left) {\n result->sum += result->left->sum;\n }\n if (result->right) {\n result->sum += result->right->sum;\n }\n }\n return result;\n}\n\nvoid fixup(Node * node, Node * parent) {\n if (node->r < parent->l) {\n node->sum = (node->last - node->first) * parent->l;\n node->l = node->r = parent->l;\n }\n}\n\nint update(Node *node, int first, int last, int size, Node * parent) {\n if (first >= node->last || last <= node->first) return 0;\n if (parent)\n fixup(node, parent);\n if (node->l >= size) return 0;\n\n if (first <= node->first) {\n node->l = size;\n }\n if (node->last <= last) {\n node->r = max(node->r, size);\n }\n \n if (first <= node->first && node->last <= last && node->r <= size) {\n int new_sum = (node->last - node->first) * size;\n int result = new_sum - node->sum;\n node->sum = new_sum;\n return result;\n }\n \n int sum_from_child = 0;\n if (node->left) {\n sum_from_child += update(node->left, first, last, size, node);\n }\n if (node->right) {\n sum_from_child += update(node->right, first, last, size, node);\n }\n \n node->sum += sum_from_child;\n return sum_from_child;\n}\n\nint set_from(int first, int last) {\n if (first >= last) return 0;\n int barSize = last;\n int barIdx = first;\n return update(root, barIdx, n, barSize, nullptr);\n}\n\nint main() {\n std::ios_base::sync_with_stdio(false);\n cin >> n;\n root = fillNode(0, n);\n fill(begin(exists), end(exists), -1);\n for (int i = 0; i < n; ++i) {\n cin >> numbers[i];\n exists[numbers[i]] = i;\n }\n \n int64_t result = 0;\n for (int gcd = MAX_N; gcd >= 1; --gcd) {\n std::vector idxs;\n for (int i = gcd; i <= MAX_N; i += gcd) {\n if (exists[i] >= 0)\n idxs.push_back(exists[i]);\n }\n if (idxs.size() < 2) continue;\n nth_element(begin(idxs), begin(idxs) + 2, end(idxs));\n int x1 = idxs[0];\n int x2 = idxs[1];\n nth_element(begin(idxs), begin(idxs) + idxs.size() - 2, end(idxs));\n int x3 = idxs[idxs.size() - 2];\n int x4 = idxs[idxs.size() - 1];\n \n result += gcd * set_from(0, x3);\n result += gcd * set_from(x2, idxs.size());\n result += gcd * set_from(x1 + 1, x4);\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ff4cd97a14885c1e0c04becd3d7a2de9", "src_uid": "deb3938a6d3f13c4ab8a0765bf0e94b0", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "# include \n# include \n# include \nusing namespace std;\ntypedef long long ll;\nconst int maxn = 200005;\nint n;\nll val[maxn], ans[maxn], id[maxn], le1[maxn], le2[maxn], ri1[maxn], ri2[maxn];\nstruct no\n{\n\tll maxx;\n\tll minn;\n\tll sum;\n\tll flag;\n}node[maxn * 4];\n\nvoid pushup(int root)\n{\n\tnode[root].maxx = max(node[root << 1].maxx, node[(root << 1)| 1].maxx);\n\tnode[root].minn = min(node[root << 1].minn, node[(root << 1) | 1].minn);\n\tnode[root].sum = node[root << 1].sum + node[(root << 1) | 1].sum;\n}\n\nvoid pushdown(int root, int le, int ri)\n{\n\tint mid = (le + ri) >> 1;\n\tif (node[root].flag)\n\t{\n\t\tnode[root << 1].flag = node[root << 1].maxx = node[root << 1].minn = node[root].flag;\n\t\tnode[(root << 1) | 1].flag = node[(root << 1) | 1].maxx = node[(root << 1) | 1].minn = node[root].flag;\n\t\tnode[root << 1].sum = node[root << 1].flag*(mid - le + 1);\n\t\tnode[(root << 1) | 1].sum = node[(root << 1) | 1].flag*(ri - mid);\n\t\tnode[root].flag = 0;\n\t}\n}\n\nvoid build(int root, int le, int ri)\n{\n\tnode[root].flag = 0;\n\tif (le == ri)\n\t{\n\t\tnode[root].maxx = node[root].minn = node[root].sum = le;\n\t\treturn;\n\t}\n\tint mid = (le + ri) >> 1;\n\tbuild(root << 1, le, mid);\n\tbuild((root << 1) | 1, mid + 1, ri);\n\tpushup(root);\n}\n\nvoid update(int oper_le, int oper_ri, int val, int le, int ri, int root)\n{\n\tif (oper_le > oper_ri)\n\t\treturn;\n\tif (node[root].minn >= val)\n\t\treturn;\n\tif (oper_le <= le&&ri <= oper_ri&&node[root].maxx <= val)\n\t{\n\t\tnode[root].flag = node[root].maxx = node[root].minn = val;\n\t\tnode[root].sum = ll(ri - le + 1)*val;\n\t\treturn;\n\t}\n\tpushdown(root, le, ri);\n\tint mid = (le + ri) >> 1;\n\tif (oper_le <= mid)\n\t{\n\t\tupdate(oper_le, oper_ri, val, le, mid, root << 1);\n\t}\n\tif (oper_ri > mid)\n\t{\n\t\tupdate(oper_le, oper_ri, val, mid + 1, ri, (root << 1) | 1);\n\t}\n\tpushup(root);\n}\nvoid solve()\n{\n\tint i, j, k; cin>>n;\n\tmemset(id, 0, sizeof(id));\n\tfor ( int i = 1;i <= n;i++ )\n\t{\n\t\tcin>>val[i];\n\t\tid[val[i]] = i;\n\t}\n\tfor (i = 1; i <= 200000; i++)\n\t{\n\t\tfor (j = i; j <= 200000; j += i)\n\t\t{\n\t\t\tif (id[j])\n\t\t\t{\n\t\t\t\tif (le1[i] == 0 || id[j] < le1[i])\n\t\t\t\t{\n\t\t\t\t\tle2[i] = le1[i];\n\t\t\t\t\tle1[i] = id[j];\n\t\t\t\t}\n\t\t\t\telse if (le2[i] == 0 || id[j] < le2[i])\n\t\t\t\t{\n\t\t\t\t\tle2[i] = id[j];\n\t\t\t\t}\n\t\t\t\tif (ri1[i] == 0 || id[j] > ri1[i])\n\t\t\t\t{\n\t\t\t\t\tri2[i] = ri1[i];\n\t\t\t\t\tri1[i] = id[j];\n\t\t\t\t}\n\t\t\t\telse if (ri2[i] == 0 || id[j] > ri2[i])\n\t\t\t\t{\n\t\t\t\t\tri2[i] = id[j];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tbuild(1, 1, n);\n\tfor (i = 200000; i >= 1; i--)\n\t{\n\t\tif (le1[i] != ri1[i])\n\t\t{\n\t\t\tupdate(1, le1[i], ri2[i], 1, n, 1);\n\t\t\tupdate(le1[i] + 1, le2[i], ri1[i], 1, n, 1);\n\t\t\tupdate(le2[i] + 1, n, n + 1, 1, n, 1);\n\t\t}\n\t\tans[i] = 1LL*n*(n + 1) - node[1].sum;\n\t}\n\tll res = 0;\n\tfor (i = 200000 - 1; i >= 1; i--)\n\t{\n\t\tres = res + 1LL*(ans[i + 1] - ans[i])*i;\n\t}\n\tprintf(\"%I64d\", res);\n}\nint main(void)\n{\n\tsolve();\n\treturn 0;", "lang_cluster": "C++", "compilation_error": true, "code_uid": "68166b469723bc4ce945e58a59babc3f", "src_uid": "deb3938a6d3f13c4ab8a0765bf0e94b0", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\n#define MAX_N 200000\n\nint n;\nint numbers[MAX_N];\nint exists[MAX_N + 1];\n\nstruct TNode {\n int l, r, sum;\n TNode *left, *right;\n int first, last;\n};\n\ndeque nodes;\n\nTNode *root;\n\nTNode* newNode() {\n nodes.emplace_back();\n return &nodes.back();\n}\n\nNode* fillNode(int first, int last) {\n if (first >= last) {\n return nullptr;\n }\n int mid = (first + (last - first) / 2);\n Node * result = newNode();\n result->first = first;\n result->last = last;\n result->l = first;\n result->r = last - 1;\n result->left = fillNode(l, mid);\n result->right = fillNode(mid + 1, r);\n result->sum = 0;\n if (!result->left && !result->right) {\n result->sum = l;\n } else {\n if (result->left) {\n result->sum += result->left->sum;\n }\n if (result->right) {\n result->sum += result->right->sum;\n }\n }\n return result;\n}\n\nvoid fixup(Node * node, Node * parent) {\n if (node->r < parent->l) {\n node->sum = (node->last - node->first) * parent->l;\n node->l = node->r = parent->l;\n }\n}\n\nint update(Node *node, int first, int last, int size, Node * parent) {\n if (first >= node->last || last <= node->first) return 0;\n if (parent)\n fixup(node, parent);\n if (node->l >= size) return 0;\n\n if (first <= node->first) {\n node->l = size;\n }\n if (node->last <= last) {\n node->r = max(node->r, size);\n }\n \n if (first <= node->first && node->last <= last && node->r <= size) {\n int new_sum = (node->last - node->first) * size;\n int result = new_sum - node->sum;\n node->sum = new_sum;\n return result;\n }\n \n int sum_from_child = 0;\n if (node->left) {\n sum_from_child += update(node->left, first, last, size, node);\n }\n if (node->right) {\n sum_from_child += update(node->right, first, last, size, node);\n }\n \n node->sum += sum_from_child;\n return sum_from_child;\n}\n\nint set_from(int first, int last) {\n if (first >= last) return 0;\n int barSize = last;\n int barIdx = first;\n return update(root, barIdx, n, barSize, nullptr);\n}\n\nint main() {\n std::ios_base::sync_with_stdio(false);\n cin >> n;\n root = fillNode(0, n);\n fill(begin(exists), end(exists), -1);\n for (int i = 0; i < n; ++i) {\n cin >> numbers[i];\n exists[numbers[i]] = i;\n }\n \n int64_t result = 0;\n for (int gcd = MAX_N; gcd >= 1; --gcd) {\n std::vector idxs;\n for (int i = gcd; i <= MAX_N; i += gcd) {\n if (exists[i] >= 0)\n idxs.push_back(exists[i]);\n }\n if (idxs.size() < 2) continue;\n nth_element(begin(idxs), begin(idxs) + 2, end(idxs));\n int x1 = idxs[0];\n int x2 = idxs[1];\n nth_element(begin(idxs), begin(idxs) + idxs.size() - 2, end(idxs));\n int x3 = idxs[idxs.size() - 2];\n int x4 = idxs[idxs.size() - 1];\n \n result += gcd * set_from(0, x3);\n result += gcd * set_from(x2, idxs.size());\n result += gcd * set_from(x1 + 1, x4);\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f6d51cfa9f934788ed9591766b9d567f", "src_uid": "deb3938a6d3f13c4ab8a0765bf0e94b0", "difficulty": 2800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#define lc idx << 1\n#define rc idx << 1 | 1\n#define lson l, mid, lc\n#define rson mid + 1, r, rc\nusing namespace std;\nconst int N = 401000;\ntypedef long long LL;\nLL sum[N << 2];\nint cov[N << 2], mn[N << 2];\nvoid pushup(int idx) {\n\tsum[idx] = sum[lc] + sum[rc];\n\tmn[idx] = mn[lc];\n}\nvoid pushdown(int l, int r, int mid, int idx) {\n\tif (cov[idx] != 0) {\n\t\tcov[lc] = cov[rc] = cov[idx];\n\t\tmn[lc] = cov[idx];\n\t\tmn[rc] = cov[idx];\n\t\tsum[lc] = (LL)cov[idx] * (mid - l + 1);\n\t\tsum[rc] = (LL)cov[idx] * (r - mid);\n\t\tcov[idx] = 0;\n\t}\n}\nvoid build(int l, int r, int idx) {\n\tif (l == r) {\n\t\tsum[idx] = l;\n\t\tmn[idx] = l;\n\t\treturn ;\n\t}\n\tint mid = (l + r) >> 1;\n\tbuild(lson);\n\tbuild(rson);\n\tpushup(idx);\n}\nvoid update(int L, int R, int val, int l, int r, int idx) {\n\tif (L > R) return ;\n\tif (L <= l && r <= R) {\n\t\tcov[idx] = val;\n\t\tmn[idx] = val;\n\t\tsum[idx] = (LL)val * (r - l + 1);\n\t\treturn ;\n\t}\n\tint mid = (l + r) >> 1;\n\tpushdown(l, r, mid, idx);\n\tif (L <= mid) update(L, R, val, lson);\n\tif (R > mid) update(L, R, val, rson);\n\tpushup(idx);\n}\nint left(int L, int R, int val, int l, int r, int idx) {\n\tif (l == r) {\n\t\tif (mn[idx] < val) return l;\n\t\telse return 0;\n\t}\n\tint mid = (l + r) >> 1;\n\tpushdown(l, r, mid, idx);\n\tif (R <= mid) {\n\t\treturn left(L, R, val, lson);\n\t}\n\telse if (L > mid) {\n\t\treturn left(L, R, val, rson);\n\t}\n\telse {\n\t\tif (mn[rc] < val) return left(L, R, val, rson);\n\t\telse return left(L, R, val, lson);\n\t}\n}\n// h[i] = sigma n - next[j] + 1\nint n, a[N];\nconst int M = 200000;\nvector v[201000];\nLL h[N], b[N];\nvoid update(int L, int R, int val) {\n\tint x = left(L, R, val, 1, n, 1);\n\tupdate(L, x, val, 1, n, 1);\n}\nint main ()\n{\n\tscanf(\"%d\", &n);\n\tfor (int i = 1; i <= n; i ++)\n\t\tscanf(\"%d\", &a[i]);\n\tfor (int i = 1; i <= M; i ++)\n\t\tfor (int j = 1; j <= n; j ++)\n\t\t\tif (a[j] % i == 0)\n\t\t\t\tv[i].push_back(j);\n\tbuild(1, n, 1);\n\tfor (int i = M; i >= 1; i --) {\n\t\th[i] = 1LL * n * (n + 1) - sum[1];\n\t\tint k = v[i].size() - 1;\n\t\tif (k >= 1) {\n\t\t\tupdate(v[i][1] + 1, n, n + 1);\n\t\t\tupdate(v[i][0] + 1, v[i][1], v[i][k]);\n\t\t\tupdate(1, v[i][0], v[i][k - 1]);\n\t\t}\n\t}\n\t \n\tLL ans = 0;\n\th[0] = 3;\n\tfor (int i = 1; i <= M; i ++)\n\t\tb[i] = h[i] - h[i - 1], ans += b[i] * i;\n\tprintf(\"%I64d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4c40b74a6129cbbeef20ff8043869967", "src_uid": "deb3938a6d3f13c4ab8a0765bf0e94b0", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst int inf=1e9,dx[]={-1,0,1,0},dy[]={0,-1,0,1};\nint x,y;\nset st;\nvoid dfs(long long num)\n{\n\tif(x>n)\n\t\treturn ;\n\tdfs(num*10+x);\n\tdfs(num*10+y);\n\tst.insert(num); \n}\nint main(){\n\tfor(int x=0;x<=9;x++)\n\t\tfor(int y=0;y<=9;y++)\n\t\t\tdfs(0);\n\tcout\n \nusing namespace std;\n \ntypedef long long ll;\ntypedef long double ld;\ntypedef unsigned long long ull;\ntypedef pair pii;\ntypedef pair pll;\ntypedef vector vi;\ntypedef vector vll;\ntypedef vector vc;\ntypedef vector vb;\n\nset ans;\n\nll n;\n\nvoid generate(ll x, ll y, ll base){\n ans.insert(base);\n ll nx = base*10+x;\n ll ny = base*10+y;\n if(nx>0 && nx<=n) \n generate(x,y,nx);\n if(ny>0 && ny<=n) \n generate(x,y,ny);\n}\n\nint main()\n{\n ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n \n cin >> n;\n \n for(ll i=0; i<10; i++)\n for(ll j=0; j<10; j++)\n generate(i,j,0);\n \n cout << ans.size()-1 << '\\n';\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fbc940f7c7604c69bcc827e2733f47ba", "src_uid": "0f7f10557602c8c2f2eb80762709ffc4", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#include\n#include\n#include\nusing namespace std;\ntypedef\tlong long ll;\ntypedef unsigned long long ull;\n#define all(v) ((v).begin()),((v).end())\n#define sz(v) ((int)((v).size()))\n#define PI(n) ((double)acos(n))\n#define pw2(n) (1LL<<(n))\n#define sfi1(v) scanf(\"%d\",&v)\n#define sfi2(v1,v2) scanf(\"%d%d\",&v1,&v2)\n#define sfi3(v1,v2,v3) scanf(\"%d %d %d\",&v1,&v2,&v3)\nint dx8[8] = { 1, -1, 0, 0, 1, 1, -1, -1 };\nint dy8[8] = { 0, 0, 1, -1, 1, -1, 1, -1 };\nvoid file()\n{\n#ifndef ONLINE_JUDGE\n\tfreopen(\"in.txt\", \"r\", stdin);\n\t//freopen(\"out.txt\", \"w\", stdout);\n#else\n\t// online submission\n#endif\n}\nvoid fast()\n{\n\tstd::ios_base::sync_with_stdio(0);\n\tcin.tie(NULL); cout.tie(NULL);\n}\nunordered_set ans;\nll n;\nint find(ll i, ll j, ll num){\n\tif (num > n) return 0;\n\tans.insert(num);\n\tif (i != 0 || num != 0) find(i, j, num * 10 + i);\n\tif (j != 0 || num != 0) find(i, j, num * 10 + j);\n}\nint main()\n{\n\n\tcin >> n;\n\tfor (ll i = 0; i < 10; i++){\n\t\tfor (ll j = 0; j < 10; j++){\n\t\t\tfind(i, j, 0);\n\t\t}\n\t}\n\t/*for (auto it : ans){\n\tcout << it << \" \";\n\t}\n\tcout << endl;*/\n\tcout << ans.size() - 1 << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c771af308c88f6097e9525c74c49570d", "src_uid": "0f7f10557602c8c2f2eb80762709ffc4", "difficulty": 1600.0} {"lang": "MS C++", "source_code": "// CFR182_div1.cpp : Defines the entry point for the console application.\n//\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n// http://codeforces.com/problemset/problem/482/B\n\n\n\nint Get(int n, int p, int x, int y, long long c, bool first, bool second)\n{\n\tif (c > n) return 0;\n\tif (p == -1) return first && second;\n\tif (c <= n) \n\t{ \n\t\tlong long cn = n / pow((int)10, p + 1) * pow((int)10, p + 1);\n\t\tif (cn < n)\n\t\t{\n\t\t\tint res = (2 << (p + 1));\n\t\t\tif (!first) res--;\n\t\t\tif (!second) res--;\n\t\t\treturn res;\n\t\t}\n\t}\n\tlong long c1 = c + x * pow((int)10, p);\n\tlong long c2 = c + y * pow((int)10, p);\n\tint res1 = Get(n, p - 1, x, y, c1, first | true, second);\n\tint res2 = Get(n, p - 1, x, y, c2, first, second | true);\n\treturn res1 + res2;\n\n}\n//\nint Get(int n, int p, int x)\n{\n\tif (x == 0) return 0;\n\tlong long c = 0;\n\tfor (int i = p; i >= 0; --i)\n\t{\n\t\tc += x * pow((int)10, i);\n\t}\n\tif (c > n) return 0;\n\treturn 1;\n}\n\nint main(int argc, char* argv[])\n{\n\tint n;\n\tcin >> n;\n\t\n\tint res = 0;\n\tfor (int p = 9; p >= 0; --p)\n\t{\n\t\tfor (int x = 9; x >= 0; --x) \n\t\t{\n\t\t\tfor (int y = x - 1; y >= 0; --y)\n\t\t\t{\n\t\t\t\tlong long c1 = x * pow((int)10, p);\n\t\t\t\tlong long c2 = y * pow((int)10, p);\n\t\t\t\tres += Get(n, p - 1, x, y, c1, true, false);\n\t\t\t\tif (y != 0)\n\t\t\t\t\tres += Get(n, p - 1, x, y, c2, false, true);\n\t\t\t}\n\t\t\tres += Get(n, p, x);\n\t\t}\n\t}\n\n\tcout << res << endl;\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "34ca0f03acd9af3cf1d12ff82ceeca98", "src_uid": "0f7f10557602c8c2f2eb80762709ffc4", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n\nint main() {\n int a[4], s = 0;\n for(int i=0; i<4; i++){\n cin >> a[i];\n s+=a[i];\n }\n for(int i = 0; i<4; i++){\n int x = 0;\n for(int j = 0; j<4; j++){\n if(j==i) continue;\n x = max(x,a[i]);\n }\n if(x>s-x-a[i]) res = 2;\n else if(x==s-x-a[i]&&res<2) res = 1;\n }\n if(res==2) cout << \"TRIANGLE\";\n else if(res==1) cout << \"SEGMENT\";\n else cout << \"IMPOSSIBLE\";\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2174dd5b3d1d57ae42fa112d7d5b3c29", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main() \n{ \n int a[4]; \n for(int i=0;i<4;i++){\n cin>>a[i]; \n } \n sort(a,a+4);\n for(int i=0;i<2;i++){ \n if(a[i]+a[i+1]>a[i+2]){ \n return 0*printf(\"TRIANGLE\");\n }\n }\n for(int i=0;i<2;i++){ \n if(a[i]+a[i+1]==a[i+2]){ \n return 0*printf(\"SEGMENT\");\n }\n }\n return 0*printf(\"IMPOSSIBLE\"); \n} ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "25a0e16258f3fc0bc1dd8c64a8a90d14", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nstring triangle(int *stick);\n\nint main()\n{\n int stick[4];\n for(int i = 0; i < 4; i++)\n {\n cin >> stick[i];\n }\n cout << triangle(stick) << endl;\n return 0;\n}\n\nstring triangle(int *stick)\n{\n string result = \"IMPOSSIBLE\";\n sort(stick.begin(), stick.end());\n while(i < 2)\n {\n int edge1 = stick[i];\n int edge2 = stick[i + 1];\n int edge3 = stick[i + 2];\n if(edge1 + edge2 > edge3)\n {\n result = \"TRIANGLE\";\n break;\n }\n else if(edge1 + edge2 == edge3)\n {\n result = \"SEGMENT\";\n }\n }\n return result;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9efa6140619bc8264705e8699fe4c06e", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a", "difficulty": 900.0} {"lang": "MS C++", "source_code": "\n#include \n#include \nusing namespace std;\n\nint main()\n{\n int a,b,c,d;\n cin>>a>>b>>c>>d;\n int num[4]={a,b,c,d};\n int n = sizeof(num)/sizeof(num[0]); \n \n sort(num, num+n); \n if(num[0]+num[1]>num[2]){cout<<\"TRIANGLE\";} else if(num[0]+num[1]>num[3]){cout<<\"TRIANGLE\";} \n else if(num[0]+num[2]>num[3]){cout<<\"TRIANGLE\";} else if(num[1]+num[2]>num[3]){cout<<\"TRIANGLE\";}\n else if(num[0]+num[1]==num[2]){cout<<\"SEGMENT\";} else if(num[0]+num[1]==num[3]){cout<<\"SEGMENT\";} \n else if(num[0]+num[2]==num[3]){cout<<\"SEGMENT\";} else if(num[1]+num[2]==num[3]){cout<<\"SEGMENT\";}\n else if(num[0]+num[1]\n\n#define REP(I, N) for (int I = 0; I < (N); ++I)\n#define REP0(I, A, B) for (auto I = (A); I < (B); ++I)\n#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)\n#define FORD(I, A, B) for (int I = (A); I >= (B); --I)\n#define MAX(A, B) (A = max(A, B))\n#define MIN(A, B) (A = min(A, B))\n#define SZ(C) ((int) C.size())\n#define ALL(C) (C).begin(), (C).end()\n\nusing ll = long long;\nconst int INF = 1e9;\nconst int MOD = 1e9 + 7;\n\nusing namespace std;\n\nconst int N = 101;\n\nint mod(int a) { return (a % MOD + MOD) % MOD; }\nint mul(int a, int b) { return ((ll) a * b % MOD + MOD) % MOD; }\nint add(int a, int b) { return ((a + b) % MOD + MOD) % MOD; }\nint pow(int a, int b) {\n if (b == 0) return 1;\n if (b < 0) b += MOD - 1;\n int c = pow(a, b / 2);\n c = mul(c, c);\n if (b % 2 == 1) c = mul(c, a);\n return c;\n}\nint inv(int a) { return pow(a, -1); }\n\nconst int dx[] = {-1, 0, 1, 0};\nconst int dy[] = {0, -1, 0, 1};\nint R, p[4];\nvector mat_[N][N][N];\nint b_[N][N];\n\ninline int &mat(int a, int b, int c, int d) {\n return mat_[a + R][b + R][c + R][d + R];\n}\n\ninline int &b(int a, int b) {\n return b_[a + R][b + R];\n}\n\nvoid row_reduce(int i0, int j0, int i1, int j1, const vector > &nz) {\n int times = mul(inv(mat(i0, j0, i0, j0)), -mat(i1, j1, i0, j0));\n b(i1, j1) = add(b(i1, j1), mul(times, b(i0, j0)));\n for (auto p : nz) {\n int i = p.first, j = p.second;\n mat(i1, j1, i, j) = add(mat(i1, j1, i, j), mul(times, mat(i0, j0, i, j)));\n }\n}\n\nvoid row_reduce(int i0, int j0, int i1, int j1) {\n vector > nz;\n FOR(i, -R, R) FOR(j, -R, R) if (mat(i0, j0, i, j) != 0) nz.push_back({i, j});\n row_reduce(i0, j0, i1, j1, nz);\n}\n\nvoid print_mat() {\n FOR(i, -R, R) FOR(j, -R, R) {\n FOR(ii, -R, R) FOR (jj, -R, R)\n cerr << (mat(i, j, ii, jj) != 0) << \" \";\n // cerr << mat(i, j, ii, jj) << \" \";\n cerr << b(i, j);\n cerr << endl;\n }\n cerr << \"===\" << endl;\n}\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n\n cin >> R;\n int s = 0;\n REP(i, 4) {\n cin >> p[i];\n s += p[i];\n }\n FOR(i, -R, R) FOR(j, -R, R) FOR(ii, -R, R)\n mat_[i + R][j + R][ii + R].resize(2 * R + 1, 0);\n int s_inv = inv(s);\n REP(i, 4) p[i] = mul(p[i], s_inv);\n // REP(i, 4) cerr << p[i] << \" \"; cerr << endl;\n\n FOR(i, -R, R) FOR(j, -R, R)\n if (i * i + j * j <= R * R) {\n REP(d, 4) {\n int ii = i + dx[d];\n int jj = j + dy[d];\n if (ii * ii + jj * jj <= R * R)\n mat(i, j, ii, jj) += p[d];\n }\n mat(i, j, i, j) = mod(-1);\n b(i, j) = mod(-1);\n }\n // cerr << \"hi\" << endl;\n\n // print_mat();\n FOR(i, -R, R) FOR(j, -R, R) {\n vector > nz;\n FOR(ii, -R, R) FOR(jj, -R, R)\n if (mat(i, j, ii, jj) != 0)\n nz.push_back({ii, jj});\n\n for (auto p : nz)\n if (p != make_pair(i, j))\n row_reduce(i, j, p.first, p.second, nz);\n\n // FOR(ii, -R, R) FOR (jj, -R, R)\n // if (ii != i || jj != j)\n // row_reduce(i, j, ii, jj);\n // print_mat();\n }\n\n // cerr << \"ok\" << endl;\n\n FOR(i, -R, R) FOR(j, -R, R)\n if (i != 0 || j != 0)\n row_reduce(i, j, 0, 0);\n\n int ans = mul(b(0, 0), inv(mat(0, 0, 0, 0)));\n cout << ans << endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "40beb00e7d9c2b99102397f0fcdf12c8", "src_uid": "bd6bcb5bffd039de93f217b02f5eae17", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#define int long long\n#define ll long long\n#define mod 1000000007\n#define N 210\nconst int U[5]={0,-1,0,1,0},\n\t\t V[5]={0,0,-1,0,1};\nusing namespace std;\nll ksm(ll a,ll b)\n{\n\tif(b==0) return 1;\n\tif(b==1) return a;\n\tll q=ksm(a,b>>1);\n\tif(b&1) return q*q%mod*a%mod;\n\telse return q*q%mod;\n}\nint id[N][N];\n#define ID(x,y) id[x+50][y+50]\nstruct matrix{\n\tll num[N*40][N*40];\n\tll answer(int n,int r)\n\t{\n\t\tint d=r*2;\n\t\tfor(int i=1;i<=n;i++)\n\t\t{\n\t\t\tll inv=ksm(num[i][i],mod-2);\n\t\t\tfor(int j=i+1,p1=0;j<=n && p1<=d;j++,p1++)\n\t\t\t{\n\t\t\t\tll res=inv*num[j][i]%mod;\n\t\t\t\tif(!res) continue;\n\t\t\t\tfor(int k=i,p2=0;k<=n && p2<=d;k++,p2++) num[j][k]=(num[j][k]-num[i][k]*res%mod+mod)%mod;\n\t\t\t\tnum[j][0]=(num[j][0]-num[i][0]*res%mod+mod)%mod;\n\t\t\t}\n\t\t}\n\t\tint p=ID(0,0);\n\t\tfor(int i=n;i>=p;i--)\n\t\t{\n\t\t\tll inv=ksm(num[i][i],mod-2);\n\t\t\tnum[i][0]=num[i][0]*inv%mod;\n\t\t\tfor(int j=i-1;j>=p;j--)\n\t\t\tnum[j][0]=(num[j][0]-num[j][i]*num[i][0]%mod+mod)%mod;\n\t\t}\n\t\treturn num[p][0];\n\t}\n}o;\nint r;\nll p[5];\nbool dis(int x,int y,int r){return 1ll*x*x+1ll*y*y<=1ll*r*r;} \nsigned main()\n{\n\tscanf(\"%lld%lld%lld%lld%lld\",&r,&p[1],&p[2],&p[3],&p[4]);\n\tconst ll inv=ksm((p[1]+p[2]+p[3]+p[4])%mod,mod-2);\n\tfor(int i=1;i<=4;i++) p[i]=p[i]*inv%mod;\n\tint cnt=0;\n\tfor(int i=r;i>=-r;i--)\n\t\tfor(int j=-r;j<=r;j++)\n\t\tif(dis(i,j,r)) ID(i,j)=++cnt;\n\tfor(int i=r;i>=-r;i--)\n\t\tfor(int j=-r;j<=r;j++)\n\t\tif(ID(i,j))\n\t\t{\n\t\t\tfor(int k=1;k<=4;k++)\n\t\t\tif(ID(i+U[k],j+V[k])) o.num[ID(i,j)][ID(i+U[k],j+V[k])]=p[k];\n\t\t\to.num[ID(i,j)][0]=o.num[ID(i,j)][ID(i,j)]=-1;\n\t\t}\n\tprintf(\"%lld\",o.answer(cnt,r));\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "925b5064250f935b07db3eacfe0beb5f", "src_uid": "bd6bcb5bffd039de93f217b02f5eae17", "difficulty": 3100.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#define MN 7900\n#define mod 1000000007\nusing namespace std;\ninline int read()\n{\n\tint x=0,f=1;char ch=getchar();\n\twhile(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}\n\twhile(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}\n\treturn x*f;\n}\nconst int md = (int) 1e9 + 7;\n\ninline void add(int &a, int b) {\n a += b;\n if (a >= md) a -= md;\n}\n\ninline void sub(int &a, int b) {\n a -= b;\n if (a < 0) a += md;\n}\n\ninline int mul(int a, int b) {\n return (int) ((long long) a * b % md);\n}\n\ninline int power(int a, long long b) { // a^b mod md\n int res = 1;\n while (b > 0) {\n if (b & 1) {\n res = mul(res, a);\n }\n a = mul(a, a);\n b >>= 1;\n }\n return res;\n}\n\ninline int inv(int a) { // multiplicative inverse of a mod md\n a %= md;\n if (a < 0) a += md;\n int b = md, u = 0, v = 1;\n while (a) {\n int t = b / a;\n b -= t * a; swap(a, b);\n u -= t * v; swap(u, v);\n }\n assert(b == 1);\n if (u < 0) u += md;\n return u;\n}\n\n\ninline int pow(int x,int k)\n{\n\tint sum=1;\n\tfor(;k;k>>=1,x=1LL*x*x%mod) if(k&1) sum=1LL*sum*x%mod;\n\treturn sum;\t\n}\nint a[MN+5][MN+5],res[MN+5];\nint R,a1,a2,a3,a4,cnt,id[105][105],ans;\ninline int&ID(int x,int y){return id[x+R+1][y+R+1];}\nvoid Gauss()\n{\n\tfor(int i=1;i<=cnt;++i)\n\t{\n\t\tfor(int j=i;j<=cnt&&j<=i+100;++j) if(a[j][i])\n\t\t{\n\t\t\tif(j!=i) \n\t\t\t{\n\t\t\t\tfor(int k=i;k<=cnt&&k<=i+100;++k) swap(a[i][k],a[j][k]);\t\n\t\t\t\tswap(a[i][cnt+1],a[j][cnt+1]);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tif(!a[i][i])continue;\n\t\tint Inv=inv(a[i][i]);\n\t\tfor(int j=i+1;j<=cnt&&j<=i+100;++j) if(a[j][i])\n\t\t{\n\t\t\tint t = mul(a[j][i],Inv);\n\t\t\tfor(int k=i;k<=cnt&&k<=i+100;++k)\n\t\t\t\tsub(a[j][k],mul(a[i][k],t));\n\t\t\tsub(a[j][cnt+1],mul(a[i][cnt+1],t));\n\t\t}\n\t}\n\tfor(int i=cnt;i;--i)\n\t{\n\t\tint t=a[i][cnt+1];\n\t\tfor(int j=i+1;j<=cnt&&j<=i+100;++j) t=(t-1LL*a[i][j]*res[j]%mod+mod)%mod;\n\t\tres[i]=1LL*t*pow(a[i][i],mod-2)%mod;\n\t\t//ans=(ans+res[i])%mod;\n\t}\n\tans = res[ID(0,0)];\n}\nint main()\n{\n\tR=read();a1=read();a2=read();a3=read();a4=read();int inv=pow(a1+a2+a3+a4,mod-2);\n\tfor(int i=-R;i<=R;++i)for(int j=-R;j<=R;++j) if(i*i+j*j<=R*R) ID(i,j)=++cnt,a[cnt][cnt]=1;\n\ta[ID(0,0)][cnt+1]=1;\n\tfor(int i=-R;i<=R;++i) for(int j=-R;j<=R;++j) if(i*i+j*j<=R*R)\n\t{\n\t\tif(ID(i-1,j)) a[ID(i-1,j)][ID(i,j)]=mod-1LL*a1*inv%mod;\n\t\tif(ID(i,j-1)) a[ID(i,j-1)][ID(i,j)]=mod-1LL*a2*inv%mod;\n\t\tif(ID(i+1,j)) a[ID(i+1,j)][ID(i,j)]=mod-1LL*a3*inv%mod;\n\t\tif(ID(i,j+1)) a[ID(i,j+1)][ID(i,j)]=mod-1LL*a4*inv%mod;\n\t\ta[ID(i,j)][cnt+1] = 1;\n\t}\n\tGauss();cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nconst int mod = 1000000007;\n\ninline void fasterLLDivMod(unsigned long long x, unsigned y, unsigned &out_d, unsigned &out_m) {\n\tunsigned xh = (unsigned)(x >> 32), xl = (unsigned)x, d, m;\n#ifdef __GNUC__\n\tasm(\n\t\t\"divl %4; \\n\\t\"\n\t\t: \"=a\" (d), \"=d\" (m)\n\t\t: \"d\" (xh), \"a\" (xl), \"r\" (y)\n\t);\n#else\n\t__asm {\n\t\tmov edx, dword ptr[xh];\n\t\tmov eax, dword ptr[xl];\n\t\tdiv dword ptr[y];\n\t\tmov dword ptr[d], eax;\n\t\tmov dword ptr[m], edx;\n\t};\n#endif\n\tout_d = d; out_m = m;\n}\n\n//x < 2^32 * MOD !\ninline unsigned Mod(unsigned long long x){\n\tunsigned y = mod;\n//\treturn x % y;\n\tunsigned dummy, r;\n\tfasterLLDivMod(x, y, dummy, r);\n\treturn r;\n}\n\n// given first m items init[0..m-1] and coefficents trans[0..m-1] or\n// given first 2 *m items init[0..2m-1], it will compute trans[0..m-1]\n// for you. trans[0..m] should be given as that \n// init[m] = sum_{i=0}^{m-1} init[i] * trans[i]\nstruct LinearRecurrence {\n using int64 = long long;\n using vec = std::vector;\n\n static void extand(vec &a, size_t d, int64 value = 0) {\n if (d <= a.size()) return;\n a.resize(d, value);\n }\n static vec BerlekampMassey(const vec &s, int64 mod) {\n std::function inverse = [&](int64 a) {\n return a == 1 ? 1 : (int64)(mod - mod / a) * inverse(mod % a) % mod;\n };\n vec A = {1}, B = {1};\n int64 b = s[0];\n for (size_t i = 1, m = 1; i < s.size(); ++i, m++) {\n int64 d = 0;\n for (size_t j = 0; j < A.size(); ++j) {\n d += A[j] * s[i - j] % mod;\n }\n if (!(d %= mod)) continue;\n if (2 * (A.size() - 1) <= i) {\n auto temp = A;\n extand(A, B.size() + m);\n int64 coef = d * inverse(b) % mod;\n for (size_t j = 0; j < B.size(); ++j) {\n A[j + m] -= coef * B[j] % mod;\n if (A[j + m] < 0) A[j + m] += mod;\n }\n B = temp, b = d, m = 0;\n } else {\n extand(A, B.size() + m);\n int64 coef = d * inverse(b) % mod;\n for (size_t j = 0; j < B.size(); ++j) {\n A[j + m] -= coef * B[j] % mod;\n if (A[j + m] < 0) A[j + m] += mod;\n }\n }\n }\n return A;\n }\n static void exgcd(int64 a, int64 b, int64 &g, int64 &x, int64 &y) {\n if (!b) x = 1, y = 0, g = a;\n else {\n exgcd(b, a % b, g, y, x);\n y -= x * (a / b);\n }\n }\n static int64 crt(const vec &c, const vec &m) {\n int n = c.size();\n int64 M = 1, ans = 0;\n for (int i = 0; i < n; ++i) M *= m[i];\n for (int i = 0; i < n; ++i) {\n int64 x, y, g, tm = M / m[i];\n exgcd(tm, m[i], g, x, y);\n ans = (ans + tm * x * c[i] % M) % M;\n }\n return (ans + M) % M;\n }\n static vec ReedsSloane(const vec &s, int64 mod) {\n auto inverse = [] (int64 a, int64 m) {\n int64 d, x, y;\n exgcd(a, m, d, x, y);\n return d == 1 ? (x % m + m) % m : -1;\n };\n auto L = [] (const vec &a, const vec &b) {\n int da = (a.size() > 1 || (a.size() == 1 && a[0])) ? a.size() - 1 : -1000;\n int db = (b.size() > 1 || (b.size() == 1 && b[0])) ? b.size() - 1 : -1000;\n return std::max(da, db + 1);\n };\n auto prime_power = [&] (const vec &s, int64 mod, int64 p, int64 e) {\n // linear feedback shift register mod p^e, p is prime\n std::vector a(e), b(e), an(e), bn(e), ao(e), bo(e);\n vec t(e), u(e), r(e), to(e, 1), uo(e), pw(e + 1);;\n pw[0] = 1;\n for (int i = pw[0] = 1; i <= e; ++i) pw[i] = pw[i - 1] * p;\n for (int64 i = 0; i < e; ++i) {\n a[i] = {pw[i]}, an[i] = {pw[i]};\n b[i] = {0}, bn[i] = {s[0] * pw[i] % mod};\n t[i] = s[0] * pw[i] % mod;\n if (t[i] == 0) {\n t[i] = 1, u[i] = e;\n } else {\n for (u[i] = 0; t[i] % p == 0; t[i] /= p, ++u[i]);\n }\n }\n for (size_t k = 1; k < s.size(); ++k) {\n for (int g = 0; g < e; ++g) {\n if (L(an[g], bn[g]) > L(a[g], b[g])) {\n ao[g] = a[e - 1 - u[g]];\n bo[g] = b[e - 1 - u[g]];\n to[g] = t[e - 1 - u[g]];\n uo[g] = u[e - 1 - u[g]];\n r[g] = k - 1;\n }\n }\n a = an, b = bn;\n for (int o = 0; o < e; ++o) {\n int64 d = 0;\n for (size_t i = 0; i < a[o].size() && i <= k; ++i) {\n d = (d + a[o][i] * s[k - i]) % mod;\n }\n if (d == 0) {\n t[o] = 1, u[o] = e;\n } else {\n for (u[o] = 0, t[o] = d; t[o] % p == 0; t[o] /= p, ++u[o]);\n int g = e - 1 - u[o];\n if (L(a[g], b[g]) == 0) {\n extand(bn[o], k + 1);\n bn[o][k] = (bn[o][k] + d) % mod;\n } else {\n int64 coef = t[o] * inverse(to[g], mod) % mod * pw[u[o] - uo[g]] % mod;\n int m = k - r[g];\n extand(an[o], ao[g].size() + m);\n extand(bn[o], bo[g].size() + m);\n for (size_t i = 0; i < ao[g].size(); ++i) {\n an[o][i + m] -= coef * ao[g][i] % mod;\n if (an[o][i + m] < 0) an[o][i + m] += mod;\n }\n while (an[o].size() && an[o].back() == 0) an[o].pop_back();\n for (size_t i = 0; i < bo[g].size(); ++i) {\n bn[o][i + m] -= coef * bo[g][i] % mod;\n if (bn[o][i + m] < 0) bn[o][i + m] -= mod;\n }\n while (bn[o].size() && bn[o].back() == 0) bn[o].pop_back();\n }\n }\n }\n }\n return std::make_pair(an[0], bn[0]);\n };\n\n std::vector> fac;\n for (int64 i = 2; i * i <= mod; ++i) if (mod % i == 0) {\n int64 cnt = 0, pw = 1;\n while (mod % i == 0) mod /= i, ++cnt, pw *= i;\n fac.emplace_back(pw, i, cnt);\n }\n if (mod > 1) fac.emplace_back(mod, mod, 1);\n std::vector as;\n size_t n = 0;\n for (auto &&x: fac) {\n int64 mod, p, e;\n vec a, b;\n std::tie(mod, p, e) = x;\n auto ss = s;\n for (auto &&x: ss) x %= mod;\n std::tie(a, b) = prime_power(ss, mod, p, e);\n as.emplace_back(a);\n n = std::max(n, a.size());\n }\n vec a(n), c(as.size()), m(as.size());\n for (size_t i = 0; i < n; ++i) {\n for (size_t j = 0; j < as.size(); ++j) {\n m[j] = std::get<0>(fac[j]);\n c[j] = i < as[j].size() ? as[j][i] : 0;\n }\n a[i] = crt(c, m);\n }\n return a;\n }\n\n LinearRecurrence(const vec &s, const vec &c, int64 mod):\n init(s), trans(c), mod(mod), m(s.size()) {}\n LinearRecurrence(const vec &s, int64 mod, bool is_prime = true): mod(mod) {\n vec A;\n if (is_prime) A = BerlekampMassey(s, mod);\n else A = ReedsSloane(s, mod);\n if (A.empty()) A = {0};\n m = A.size() - 1;\n trans.resize(m);\n for (int i = 0; i < m; ++i) {\n trans[i] = (mod - A[i + 1]) % mod;\n }\n std::reverse(trans.begin(), trans.end());\n init = {s.begin(), s.begin() + m};\n }\n int64 calc(int64 n) {\n if (mod == 1) return 0;\n if (n < m) return init[n];\n vec v(m), u(m << 1);\n int msk = !!n;\n for (int64 m = n; m > 1; m >>= 1) msk <<= 1;\n v[0] = 1 % mod;\n for (int x = 0; msk; msk >>= 1, x <<= 1) {\n std::fill_n(u.begin(), m * 2, 0);\n x |= !!(n & msk);\n if (x < m) u[x] = 1 % mod;\n else {// can be optimized by fft/ntt\n for (int i = 0; i < m; ++i) {\n for (int j = 0, t = i + (x & 1); j < m; ++j, ++t) {\n u[t] = (u[t] + v[i] * v[j]) % mod;\n }\n }\n for (int i = m * 2 - 1; i >= m; --i) {\n for (int j = 0, t = i - m; j < m; ++j, ++t) {\n u[t] = (u[t] + trans[j] * u[i]) % mod;\n }\n }\n }\n v = {u.begin(), u.begin() + m};\n }\n int64 ret = 0;\n for (int i = 0; i < m; ++i) {\n ret = (ret + v[i] * init[i]) % mod;\n }\n return ret;\n }\n\n vec init, trans;\n int64 mod;\n int m;\n};\n\nint mod_inverse(int i) {\n if(i == 1) return 1;\n return (long long)mod_inverse(mod % i) * (long long)(mod - mod / i) % mod;\n}\n\nint r, a[4];\nint p[4];\n\nint id;\n\nstd::map> m;\n\nconst int dx[] = {-1, 0, 1, 0};\nconst int dy[] = {0, -1, 0, 1};\n\nstd::mt19937 rng;\n\nstd::uniform_int_distribution gen(1, mod - 1);\n\nint main() {\n#ifdef IN_MY_COMPUTER\n freopen(\"e.in\", \"r\", stdin);\n#endif\n\n std::cin >> r;\n for(int i = 0; i < 4; i++) {\n std::cin >> a[i];\n }\n\n if(r == 0) {\n puts(\"1\");\n return 0;\n }\n\n long long inv_a = mod_inverse(std::accumulate(a, a+4, 0));\n for(int i = 0; i < 4; i++) {\n p[i] = a[i] * inv_a % mod;\n }\n\n for(int x = -r-1; x <= r+1; x++) {\n for(int y = -r-1; y <= r+1; y++) {\n if(x * x + y * y <= r * r) {\n m[x][y] = id++;\n }else {\n m[x][y] = -1;\n }\n }\n }\n\n struct ele { int i, j, v; };\n std::vector coef;\n\n for(int x = -r; x <= r; x++) {\n for(int y = -r; y <= r; y++) if(m[x][y] >= 0) {\n //coef.push_back({m[x][y], m[x][y], 1});\n for(int t = 0; t < 4; t++) {\n int xx = x+dx[t], yy = y+dy[t];\n if(m[xx][yy] >= 0) {\n coef.push_back({m[x][y], m[xx][yy], mod-p[t]});\n }\n }\n }\n }\n printf(\"id=%d |coef|=%ld\\n\", id,coef.size());\n\n // A * x = (1, 0, 0, 0, 0, ..., 0)\n\n static int v1[8000], v2[8000];\n for(int i = 0; i < id; i++) {\n v1[i] = (gen(rng));\n v2[i] = (gen(rng));\n }\n\n std::vector seq;\n static int now[8000];\n for(int i = 0; i < id; i++) now[i] = v1[i];\n\n for(int rr = 0; rr < id * 2 + 5; rr++) {\n seq.push_back(v1[m[0][0]]); // 50 1 2 3 4 -> 316668178\n for(auto &it : coef) {\n now[it.i] = (now[it.i] + (long long)v1[it.j] * it.v) % mod;\n }\n memcpy(v1, now, sizeof(int) * id);\n }\n printf(\"after rr go %lf\\n\", (double)clock()/CLOCKS_PER_SEC);\n\n static int b[8000], ret[8000];\n \n LinearRecurrence lin(seq, mod, true);\n\n lin.trans.push_back(mod-1);\n for(int n = 1; n <= 1000; n++) {\n //printf(\"%lld, \", lin.calc(n));\n if(lin.calc(n) == 489905673) {\n printf(\"n = %lld\\n\", n);\n }\n }\n puts(\"\");\n printf(\"lin.size() = %ld\\n\", lin.trans.size());\n printf(\"after linrec %lf\\n\", (double)clock() / CLOCKS_PER_SEC);\n\n std::vector inv_coef(lin.trans.begin() + 1, lin.trans.end());\n long long all_mul = mod_inverse(mod - lin.trans[0]);\n\n int pos = m[0][0], ans = 0;\n\n for(int i = 0; i < id; i++) now[i] = b[i] = 1;\n for(long long v : inv_coef) {\n (v *= all_mul) %= mod;\n (ans += b[pos] * v) % mod;\n for(auto &it : coef) {\n (now[it.i] += (long long)b[it.j] * it.v)) %= mod;\n }\n memcpy(b, now, sizeof(int) * id);\n }\n\n printf(\"total %lf\\n\", (double)clock() / CLOCKS_PER_SEC);\n printf(\"%d\\n\", ans);\n\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3a6de9e7804f82b9129989c48ef2a71b", "src_uid": "bd6bcb5bffd039de93f217b02f5eae17", "difficulty": 3100.0} {"lang": "GNU C++17", "source_code": "#error\n/*\n * Remark:\n * Took only total ~= 40 mins to implement.\n * However initially I misunderstood the problem statement and thought that\n * the probability of reaching each possible vertex is equal for each distance.\n * Took another 40 minutes to \"debug\" that. Too bad.\n * Ignores the time required to prove that the algorithm is O(n^3) (a few days?)\n */\n\n#ifndef LOCAL\n#define NDEBUG\n#endif\n#include\n#include\n#include\n#include\n#include\n#include\n\n\nint main(){\n\tstd::ios::sync_with_stdio(0);std::cin.tie(0);\n\tint n,m;std::cin>>n>>m;\n\n\tstd::vector> d(n,std::vector(n,INT_MAX/2));\n\tstd::vector> ad(n);\n\n\tfor(int z=m;z--;){\n\t\tint u,v;std::cin>>u>>v;--u;--v;\n\t\tad[u].push_back(v);\n\t\tad[v].push_back(u);\n\t\td[u][v]=d[v][u]=1;\n\t}\n\n\tfor(int i=n;i--;)\n\t\td[i][i]=0;\n\tfor(int k=n;k--;)\n\tfor(int i=n;i--;)\n\tfor(int j=n;j--;)\n\t\td[i][j]=std::min(d[i][j],d[i][k]+d[k][j]);\n\n\tstd::vector>> byd(n); // byd[i][dist] = {x: d[i][x] == dist}\n\tfor(int i=n;i--;){\n\t\tauto& bydi=byd[i];\n\t\tbydi.resize(1+*std::max_element(begin(d[i]),end(d[i])));\n\t\tfor(int j=n;j--;)\n\t\t\tbydi[d[i][j]].push_back(j);\n\t}\n\n\tstd::vector mark;\n\tstd::vector distseen(n);\n\tstd::vector> markvals; // {val,ind}\n\tmarkvals.reserve(n);\n\n\tdouble ans=0;\n\tfor(int x=n;x--;){ // first chosen vertex\n\t\tdouble cur=0;\n\t\tfor(unsigned dx=0;dx0);\n\t\t\tdouble zz=1./ci;\n\n\t\t\tif(ci>1){\n\t\t\t\tmark.assign(n,0);\n\t\t\t\tfor(int j:byd[x][dx]){\n\t\t\t\t\tfor(int k:ad[j]) // surprisingly the time complexity is only O(n^3)\n\t\t\t\t\t\tmark[k]+=1/(double)ad[j].size();\n\t\t\t\t}\n\t\t\t\t// mark[k] / ci = probability for Limak to travel to k\n\n\t\t\t\tmarkvals.clear();\n\t\t\t\tfor(int j=n;j--;){\n\t\t\t\t\tif(mark[j])\n\t\t\t\t\t\tmarkvals.push_back({mark[j],j});\n\t\t\t\t\tstd::sort(begin(markvals),end(markvals),[](auto a,auto b){return a.first>b.first;});\n\t\t\t\t}\n\n\t\t\t\tdouble max_smprob=0;\n\t\t\t\tfor(int z=n;z--;){\n\t\t\t\t\tdouble smprob=0; // sum of max probability * ci\n\t\t\t\t\tfor(auto [prob,j]:markvals)\n\t\t\t\t\t\tif(!distseen[d[z][j]]){\n\t\t\t\t\t\t\tdistseen[d[z][j]]=true;\n\t\t\t\t\t\t\tsmprob+=prob;\n\t\t\t\t\t\t}\n\n\t\t\t\t\tmax_smprob=std::max(max_smprob,smprob);\n\n\t\t\t\t\tfor(auto [prob,j]:markvals)\n\t\t\t\t\t\tdistseen[d[z][j]]=false;\n\t\t\t\t}\n\n\t\t\t\tzz=std::max(zz,max_smprob/(double)ci);\n\t\t\t}\n\n\t\t\tcur+=zz*ci/n;\n\t\t}\n\t\tans=std::max(ans,cur);\n\t}\n\tstd::cout<\n#include \n#include \n#include \n\nusing namespace std;\n\nconst int maxn = 400 + 10;\nconst double eps = 1e-10;\n\nint dist[maxn][maxn];\nint vis[maxn];\ndouble po[maxn];\ndouble maxpo[maxn];\nint n, m;\nint vec[maxn], vecn;\nvector G[maxn];\n\ndouble solve(int p1, int d1) {\n vector point;\n /*double num = 0;\n for(int i = 1; i <= n; i++) {\n if(dist[i][p1] == d1) {\n num++;\n }\n }*/\n memset(po, 0, sizeof(po));\n memset(vis, 0, sizeof(vis));\n memset(maxpo, 0, sizeof(maxpo));\n for(int i = 1; i <= n; i++) {\n if(dist[i][p1] == d1) {\n for(int j = 0; j < G[i].size(); j++) {\n int v = G[i][j];\n po[v] += 1.0 / n / (double)G[i].size();\n if(vis[v] == 0) {\n vis[v] = 1;\n point.push_back(v);\n }\n }\n }\n }\n double ans = 0;\n for(int p2 = 1; p2 <= n; p2++) {\n double t = 0;\n vecn = 0;\n for(int i = 0; i < point.size(); i++) {\n int v = point[i], d = dist[p2][v];\n if(maxpo[d] < eps) {\n vec[vecn] = d;\n vecn++;\n }\n maxpo[d] = max(maxpo[d], po[v]);\n }\n for(int i = 0; i < point.size(); i++) {\n int v = point[i], d = dist[p2][v];\n t += maxpo[d];\n maxpo[d] = 0;\n }\n for(int i = 0; i < vecn; i++) {\n maxpo[vec[i]] = 0;\n }\n ans = max(ans, t);\n }\n return ans;\n}\n\nint main() {\n //freopen(\"D.txt\", \"r\", stdin);\n while(scanf(\"%d%d\", &n, &m) != EOF) {\n for(int i = 1; i <= n; i++) G[i].clear();\n for(int i = 1; i <= n; i++) {\n for(int j = 1; j <= n; j++) {\n if(i == j) {\n dist[i][j] = 0;\n } else {\n dist[i][j] = n + 1;\n }\n }\n }\n for(int i = 1; i <= m; i++) {\n int a, b;\n scanf(\"%d%d\", &a, &b);\n dist[a][b] = dist[b][a] = 1;\n G[a].push_back(b);\n G[b].push_back(a);\n }\n for(int k = 1; k <= n; k++) {\n for(int i = 1; i <= n; i++) {\n for(int j = 1; j <= n; j++) {\n dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);\n }\n }\n }\n double ans = 0;\n for(int p1 = 1; p1 <= n; p1++) {\n double t = 0;\n for(int d1 = 0;d1 <= n; d1++) {\n int flag = 0;\n for(int i = 1; i <= n; i++) {\n if(dist[i][p1] == d1) {\n flag = 1;\n break;\n }\n }\n if(flag == 0) continue;\n double tmp = 1.0 / n;\n tmp = max(tmp, solve(p1, d1));\n t += tmp;\n }\n ans = max(ans, t);\n }\n printf(\"%.10f\\n\", ans);\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fc5f8a54c6a2c8bbc85e2c2dee1177c8", "src_uid": "99b94d0c75fa6cd28091a9d71daf6cbf", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#define ll int\n#define N 405\n#define M 80005\n#define eps (1e-6)\n#define rep(i,j,k) for (ll i=j;i<=k;++i)\n#define per(i,j,k) for (ll i=j;i>=k;--i)\nusing namespace std;\ninline ll read(){\n\tchar ch=getchar(); ll x=0,f=1;\n\twhile (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }\n\twhile (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }\n\treturn x*f;\n}\nll n,m,tot,a[N],f[N][N],head[N],size[N];\ndouble p[N],dis[N],ans=0;\nstruct edge{ ll to,next; }e[M];\nvoid add(ll u,ll v){\n\te[++tot]=(edge){v,head[u]}; head[u]=tot; ++size[u];\n}\ndouble calc(ll x,ll d1){\n\trep(i,1,n) p[i]=0;\n\tdouble ans=0; ll cnt=0;\n\trep(i,1,n) if (f[x][i]==d1){\n\t\tfor (ll j=head[i],v=e[j].to;j;j=e[j].next,v=e[j].to)\n\t\t\tp[v]+=1.0/n/size[i];\n\t}\n\trep(i,1,n) if (p[i]>eps) a[++cnt]=i;\n\trep(i,1,n){\n\t\tdouble tmp=0;\n\t\trep(j,1,cnt) dis[f[i][a[j]]]=max(dis[f[i][a[j]]],p[a[j]]);\n\t\trep(j,1,cnt) tmp+=dis[f[i][a[j]]],dis[f[i][a[j]]]=0;\n\t\tans=max(ans,tmp);\n\t}\n\treturn ans;\n}\nint main(){\n\tn=read(); m=read(); ans=1.0/n;\n\trep(i,1,n) rep(j,1,n) if (i!=j) f[i][j]=n+1;\n\trep(i,1,m){\n\t\tll u=read(),v=read();\n\t\tadd(u,v); add(v,u);\n\t\tf[u][v]=f[v][u]=1;\n\t}\n\trep(k,1,n) rep(i,1,n) rep(j,1,n)\n\t\tf[i][j]=min(f[i][j],f[i][k]+f[k][j]);\n\trep(i,1,n){\n\t\tdouble tmp=0;\n\t\trep(d1,0,n-1){\n\t\t\tll cnt=0;\n\t\t\trep(j,1,n) if (f[i][j]==d1) ++cnt;\n\t\t\tif (!cnt) continue;\n\t\t\tdouble day2=calc(i,d1);\n\t\t\ttmp+=max(day1,day2);\n\t\t}\n\t\tans=max(ans,tmp);\n\t}\n\tprintf(\"%.12f\",ans);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d2cd8483acda0bcbab81e68350cce05c", "src_uid": "99b94d0c75fa6cd28091a9d71daf6cbf", "difficulty": 2900.0} {"lang": "GNU C++", "source_code": "#include \n#include \nstatic const int INF = 0x3fffffff;\nstatic const int MAXN = 418; // I'm a teapot =u=\ntypedef std::vector edgelist;\n\ntemplate inline T min(const T a, const T b) {\n return a < b ? a : b;\n}\ntemplate inline T max(const T a, const T b) {\n return a > b ? a : b;\n}\n\nint n, m;\nedgelist e[MAXN];\nint d[MAXN][MAXN];\n\nint main()\n{\n scanf(\"%d%d\", &n, &m);\n for (int i = 0; i < n; ++i)\n for (int j = 0; j < n; ++j)\n d[i][j] = (i == j ? 0 : INF);\n\n int u, v;\n for (int i = 0; i < m; ++i) {\n scanf(\"%d%d\", &u, &v); --u; --v;\n e[u].push_back(v);\n e[v].push_back(u);\n d[u][v] = d[v][u] = 1;\n }\n for (int k = 0; k < n; ++k)\n for (int i = 0; i < n; ++i)\n for (int j = 0; j < n; ++j)\n d[i][j] = min(d[i][j], d[i][k] + d[k][j]);\n\n double ans = 0.0;\n for (int g1 = 0; g1 < n; ++g1) {\n double cur = 0.0;\n for (int d1 = 0; d1 < n; ++d1) {\n int valid_ct = 0;\n for (int i = 0; i < n; ++i)\n if (d[g1][i] == d1) ++valid_ct;\n if (valid_ct == 0) continue;\n\n double nextday = 0.0;\n std::vector omoshiroi;\n static double prob[MAXN], prob_in_dist[MAXN];\n memset(prob, 0, sizeof prob);\n //memset(prob_in_dist, 0, sizeof prob_in_dist);\n for (int u = 0; u < n; ++u) if (d[g1][u] == d1)\n for (edgelist::iterator v = e[u].begin(); v != e[u].end(); ++v) {\n if (prob[*v] == 0) omoshiroi.push_back(*v);\n prob[*v] += 1.0 / valid_ct / e[u].size();\n }\n for (int g2 = 0; g2 < n; ++g2) {\n double cur = 0.0;\n for (std::vector::iterator i = omoshiroi.begin(); i != omoshiroi.end(); ++i)\n prob_in_dist[d[g2][*i]] = max(prob_in_dist[d[g2][*i]], prob[*i]);\n for (std::vector::iterator i = omoshiroi.begin(); i != omoshiroi.end(); ++i) {\n cur += prob_in_dist[d[g2][*i]];\n prob_in_dist[d[g2][*i]] = 0.0;\n }\n nextday = max(nextday, cur);\n }\n\n // http://codeforces.com/blog/entry/45310#comment-298820\n cur += max(1.0 / valid_ct, nextday) * valid_ct / n;\n }\n ans = max(ans, cur);\n }\n\n printf(\"%.12lf\\n\", ans);\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a16a022733c2d6ef6fbdf46578875d79", "src_uid": "99b94d0c75fa6cd28091a9d71daf6cbf", "difficulty": 2900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n\nusing namespace std;\nlong long f[52][52][102];\nint path[52][52][102][2];\n\nstruct node{\n\tlong long a , b , c;\n\tbool operator < (const node & p) const\n\t{\n\t\treturn c < p.c;\n\t}\n};\nnode r[52];\n\n\nvoid print(int n , int j , long long x)\n{\n\tif(path[n][j][x][0] != j)\n\t{\t\n\t\tint u = path[n][j][x][0];\n\t\tlong long v = path[n][j][x][1];\n\t\tprint(n - 1 , u , v);\n\t}\n\tcout << j + 1 << \" \" << x + r[j].a << endl;\n}\n\nint main()\n{\n\t//freopen(\"data.in\" , \"r\" ,stdin);\n\tint n , m , k;\n\tcin >> n >> m >> k;\n\tfor(int i = 0 ; i < m ;i++)\n\t{\n\t\tcin >> r[i].a >>r[i].b >> r[i].c; \n\t}\n\tsort(r , r + n);\n\tint last_j = 0;\n\tlong long last_x = 0;\n\tlong long Max = 0;\n\tmemset(f , 0 ,sizeof(f));\t\n\tfor(int i = 0 ; i < n ;i++)\n\t{\n\t\tfor(int j = i ; j < m ;j++)\n\t\t{\n\t\t\tlong long u = r[j].b - r[j].a;\n\t\t\tfor(int x = 0 ; x <= u ; x++)\n\t\t\t{\n\t\t\t\tlong long ans = 0;\n\t\t\t\t\n\t\t\t\tif(i == 0)\n\t\t\t\t{\n\t\t\t\t\tf[i][j][x] = x + r[j].a;\n\t\t\t\t\tpath[i][j][x][0] = j;\n\t\t\t\t\tpath[i][j][x][1] = u + r[j].a;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\t\n\t\t\t\tlong long v = x + r[j].a;\n\t\t\t\t\n\t\t\t\tfor(int p = i - 1 ; p < j ; p++)\n\t\t\t\t{\n\t\t\t\t\tif(v % k == 0 && v / k >= r[p].a && v / k <= r[p].b)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(ans < f[i - 1][p][v / k - r[p].a] + v)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tans = f[i - 1][p][v / k - r[p].a] + v;\n\t\t\t\t\t\t\tpath[i][j][x][0] = p;\n\t\t\t\t\t\t\tpath[i][j][x][1] = v / k - r[p].a;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t\tif(v - k >= r[p].a && v - k <= r[p].b)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(ans < f[i - 1][p][v - k - r[p].a] + v)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tans = f[i - 1][p][v - k - r[p].a] + v;\n\t\t\t\t\t\t\tpath[i][j][x][0] = p;\n\t\t\t\t\t\t\tpath[i][j][x][1] = v - k - r[p].a;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tf[i][j][x] = ans;\n\t\t\t\tif(i == n - 1)\n\t\t\t\t{\n\t\t\t\t\tif(Max < f[i][j][x])\n\t\t\t\t\t{\n\t\t\t\t\t\tMax = f[i][j][x];\n\t\t\t\t\t\tlast_j = j;\n\t\t\t\t\t\tlast_x = x;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif(Max > 0)\n\t{\n\t\tcout << \"YES\" << endl;\n\t\tprint(n - 1 , last_j , last_x);\n\t}\n\telse\n\t{\n\t\tcout << \"NO\" << endl;\n\t}\n//\twhile(1);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "74e987ab8cd16de28e63d603aa1f2b5f", "src_uid": "c98fdad8e7ce09b8ac389108f72cecd9", "difficulty": 2000.0} {"lang": "GNU C++0x", "source_code": "#pragma comment(linker, \"/STACK:16777216\")\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define FOR(i, n) for (int i = 0; i < (int) (n); i++)\n#define RFOR(i, n) for (int i = (int) (n) - 1; i >= 0; i--)\n#define CL(x, v) memset(x, v, sizeof(x))\n#define ALL(x) x.begin(), x.end()\n#define PB push_back\n#define MP make_pair\n\ntypedef long long LL;\ntypedef vector VI;\ntypedef vector VS;\ntypedef pair PII;\n\nconst int N = 50 + 5;\nconst int M = 100 + 5;\n\nint ttc = 0;\nchar tt[N * N * M];\n\nint n, m, k;\nLL a[N], b[N];\nint c[N];\n\nstruct T\n{\n int n, c;\n LL x;\n\n T()\n {\n n = c = x = 0;\n }\n\n T(int _n, int _c, LL _x)\n {\n n = _n;\n c = _c;\n x = _x;\n }\n\n void * operator new (size_t size)\n {\n void * res = (void *) (tt + ttc);\n ttc += sizeof(T);\n return res;\n }\n};\n\nbool operator < (T a, T b)\n{\n if (a.n != b.n) return a.n < b.n;\n if (a.c != b.c) return a.c < b.c;\n return a.x < b.x;\n}\n\nsize_t H(const T & t)\n{\n return t.n * 13 + t.c * 17 + t.x * 37;\n}\n\nunordered_map vs;\nunordered_map dp;\nunordered_map pr1;\nunordered_map pr2;\n\nLL D(T t)\n{\n if (t.n == n) return 0;\n\n bool & vis = vs[t];\n LL & res = dp[t];\n int & pre1 = pr1[t];\n LL & pre2 = pr2[t];\n\n if (vis) return res;\n\n vis = 1;\n res = -1;\n\n FOR(i, m) if (c[i] > t.c)\n if (!t.n)\n {\n for (LL x = a[i]; x <= b[i]; x++)\n {\n T f(t.n + 1, c[i], x);\n LL cur = D(f);\n if (cur != -1)\n {\n cur += x;\n if (cur > res)\n {\n res = cur;\n pre1 = i;\n pre2 = x;\n }\n }\n }\n }\n else\n {\n if (a[i] <= t.x + k && t.x + k <= b[i])\n {\n T f(t.n + 1, c[i], t.x + k);\n LL cur = D(f);\n if (cur != -1)\n {\n cur += t.x + k;\n if (cur > res)\n {\n res = cur;\n pre1 = i;\n pre2 = t.x + k;\n }\n }\n }\n\n if (a[i] <= t.x * k && t.x * k <= b[i])\n {\n T f(t.n + 1, c[i], t.x * k);\n LL cur = D(f);\n if (cur != -1)\n {\n cur += t.x * k;\n if (cur > res)\n {\n res = cur;\n pre1 = i;\n pre2 = t.x * k;\n }\n }\n }\n }\n\n return res;\n}\n\nint main()\n{\n#ifdef LOCAL_BUILD\n freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n#endif\n\n scanf(\"%d %d %d\", &n, &m, &k);\n FOR(i, m) scanf(\"%I64d %I64d %d\", &a[i], &b[i], &c[i]);\n\n T t(0, 0, 0);\n LL x = D(t);\n if (x != -1)\n {\n printf(\"YES\\n\");\n while (t.n < n)\n {\n printf(\"%d %I64d\\n\", pr1[t] + 1, pr2[t]);\n t = T(t.n + 1, c[pr1[t]], pr2[t]);\n }\n }\n else\n printf(\"NO\\n\");\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "206586b4a399e585c1778a7c7b433a3f", "src_uid": "c98fdad8e7ce09b8ac389108f72cecd9", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\nconst long maxN=55;\nstruct subject{long long a,b,c,cs;};\nlong long f[maxN][maxN][maxN*2],sl[maxN];\nlong n,m,k,d[maxN];\nsubject t[maxN];\nint nhap();\nint xuli();\nint inkq();\nint main()\n{\n nhap();\n xuli();\n inkq();\n}\nint nhap()\n{\n cin >> n >> m >> k;\n long i,j;\n subject tg;\n for (i=1;i<=m;i++) \n {\n cin >> t[i].a >>t[i].b >>t[i].c;\n t[i].cs=i;\n }\n for (i=m;i>=2;i--)\n for (j=1;j<=i-1;j++)\n if (t[j].c>t[j+1].c)\n {\n tg=t[j];t[j]=t[j+1];t[j+1]=tg;\n }\n}\nlong long max(long long a,long long b)\n{\n if (a>b) return a; else return b;\n }\nint xuli()\n{\n long i,j,p,q;\n long long m1,m2;\n for (i=1;i<=n;i++)\n for (p=i;p<=m;p++)\n for (j=0;j<=t[p].b-t[p].a;j++)\n {\n if (i==1) \n {\n f[i][p][j]=j+t[p].a;\n }\n else\n for (q=1;q=0)&&(m1<=t[q].b-t[q].a)&&(f[i-1][q][m1]>0)) f[i][p][j]=max(f[i][p][j],f[i-1][q][m1]+j+t[p].a);\n if ((m2>=0)&&(m2<=t[q].b-t[q].a)&&(f[i-1][q][m2]>0)) f[i][p][j]=max(f[i][p][j],f[i-1][q][m2]+j+t[p].a);\n }\n }\n}\nint landg(long n,long m,long long x,long long kq)\n{\n if (n==0) return 0;\n long p,j;\n for (p=1;p<=m;p++)\n for (j=0;j<=t[p].b-t[p].a;j++)\n {\n if ((j+t[p].a+k==x)||((j+t[p].a)*k==x))\n if (f[n][p][j]==kq)\n {\n d[n]=t[p].cs;\n sl[n]=j+t[p].a;\n landg(n-1,p-1,j+t[p].a,kq-j-t[p].a);\n return 0;\n }\n }\n}\nint inkq()\n{\n long i,j,p;\n long long kq=0; \n for (p=1;p<=m;p++)\n for (j=0;j<=t[p].b-t[p].a;j++)\n if (f[n][p][j]>kq) kq=f[n][p][j];\n if (kq==0) \n {\n printf(\"NO\");\n return 0;\n }\n printf(\"YES\\n\");\n for (p=1;p<=m;p++)\n for (j=0;j<=t[p].b-t[p].a;j++)\n if (f[n][p][j]==kq) \n {\n d[n]=t[p].cs;\n sl[n]=j+t[p].a;\n landg(n-1,p-1,j+t[p].a,kq-j-t[p].a);\n }\n for (i=1;i<=n;i++)\n cout << d[i] << \" \"<< sl[i];\n //getch();\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ccae2baebd8133db61c21cc3a5cae4c5", "src_uid": "c98fdad8e7ce09b8ac389108f72cecd9", "difficulty": 2000.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nconst int maxn = 105;\n\nlong long dp[maxn][maxn][maxn];\nlong long a[maxn], b[maxn], c[maxn], number[maxn];\nlong long best[maxn][maxn][maxn];\nlong long N, M, K;\n\nint solve(int i, int j, int k) {\n\tlong long many = 0;\n\tif (i != 1)\n\t\tif (best[i][j][k] > 0) {\n\t\t\tint newt = a[j] + k;\n\t\t\tnewt -= K;\n\t\t\tnewt -= a[best[i][j][k]];\n\t\t\tsolve(i - 1, best[i][j][k], newt);\n\t\t\tmany = dp[i][j][k] - dp[i - 1][best[i][j][k]][newt];\n\t\t}\n\t\telse {\n\t\t\tint newt = a[j] + k;\n\t\t\tnewt /= K;\n\t\t\tnewt -= a[-best[i][j][k]];\n\t\t\tsolve(i - 1, -best[i][j][k], newt);\n\t\t\tmany = dp[i][j][k] - dp[i - 1][-best[i][j][k]][newt];\n\t\t}\n\telse\n\t\tmany = dp[i][j][k];\n\tcout << number[j] << \" \" << many << \"\\n\";\n}\n\nint main() {\n\n\tcin >> N >> M >> K;\n\tfor (int i = 1; i <= M; ++i)\n\t\tcin >> a[i] >> b[i] >> c[i], number[i] = i;\n\t\n\tfor (int i = 1; i <= M; ++i)\n\t\tfor (int j = i + 1; j <= M; ++j)\n\t\t\tif (c[i] > c[j])\n\t\t\t\tswap(a[i], a[j]), swap(b[i], b[j]), swap(c[i], c[j]), swap(number[i], number[j]);\n\t\n\tfor (int i = 1; i <= M; ++i)\n\t\tfor (int j = 0; j <= b[i] - a[i]; ++j)\n\t\t\tdp[1][i][j] = a[i] + j;\n\t\n\n\tfor (int i = 2; i <= N; ++i)\n\t\tfor (int j = i; j <= M; ++j)\n\t\t\tfor (int l = 0; l <= b[j] - a[j]; ++l)\n\t\t\t\tfor (int k = i - 1; k < j; ++k)\n\t\t\t\t {\n\t\t\t\t\t\tint poz = a[j] + l - K;\n\t\t\t\t\t\tif (poz >= a[k] && poz <= b[k] && dp[i - 1][k][poz - a[k]] != 0) {\n\t\t\t\t\t\t\tpoz -= a[k];\n\t\t\t\t\t\t\tif (dp[i - 1][k][poz] + a[j] + l > dp[i][j][l])\n\t\t\t\t\t\t\t\tdp[i][j][l] = dp[i - 1][k][poz] + a[j] + l,\n\t\t\t\t\t\t\t\tbest[i][j][l] = k;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tpoz = a[j] + l;\n\t\t\t\t\t\tif (poz % K)\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\tpoz /= K;\n\t\t\t\t\t\tif (poz >= a[k] && poz <= b[k] && dp[i - 1][k][poz - a[k]] != 0) {\n\t\t\t\t\t\t\tpoz -= a[k];\n\t\t\t\t\t\t\tif (dp[i - 1][k][poz] + a[j] + l > dp[i][j][l])\n\t\t\t\t\t\t\t\tdp[i][j][l] = dp[i - 1][k][poz] + a[j] + l,\n\t\t\t\t\t\t\t\tbest[i][j][l] = -k;\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\n\tint pos = 0;\n\tint row = 1;\n\tfor (int i = 1; i <= M; ++i)\n\t\tfor (int l = 0; l <= b[i] - a[i]; ++l)\n\t\t\tif (dp[N][i][l] > dp[N][row][pos])\n\t\t\t\trow = i, pos = l;\n\t\n\tif (dp[N][row][pos] == 0) {\n\t\tcout << \"NO\";\n\t\treturn 0;\n\t}\n\tcout << \"YES\\n\";\n\tsolve(N, row, pos);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5149bc9ae414d63c0969f90070195ef4", "src_uid": "c98fdad8e7ce09b8ac389108f72cecd9", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n int n,i;\n char a[9][20]={\"one\",\"two\",\"three\",\"four\",\"five\",\"six\",\"seven\",\"eight\",\"nine\"};\n char b[9][20]={\"ten\",\"twenty\",\"thirty\",\"forty\",\"fifty\",\"sixty\",\"seventy\",\"eighty\",\"ninety\"};\n cin>>i;\n if(i==0)\n {\n cout<<\"zero\"<=0)&&(i<=9))\n {\n cout<=16)&&(i<=19))\n {\n if(i==18)\n {\n cout<<\"eighteen\"<\n#define endl '\\n'\n#pragma GCC optimize(3)\n\nusing namespace std;\nsigned main()\n{\n\tios::sync_with_stdio(false);\n\tif (a[i] == 0) cout << \"zero\";\n\tif (a[i] == 1) cout << \"one\";\n\tif (a[i] == 2) cout << \"two\";\n\tif (a[i] == 3) cout << \"three\";\n\tif (a[i] == 4) cout << \"four\";\n\tif (a[i] == 5) cout << \"five\";\n\tif (a[i] == 6) cout << \"six\";\n\tif (a[i] == 7) cout << \"seven\";\n\tif (a[i] == 8) cout << \"eight\";\n\tif (a[i] == 9) cout << \"nine\";\n\tif (a[i] == 10) cout << \"ten\";\n\tif (a[i] == 11) cout << \"eleven\";\n\tif (a[i] == 12) cout << \"twelve\";\n\tif (a[i] == 13) cout << \"thirteen\";\n\tif (a[i] == 14) cout << \"fourteen\";\n\tif (a[i] == 15) cout << \"fifteen\";\n\tif (a[i] == 16) cout << \"sixteen\";\n\tif (a[i] == 17) cout << \"seventeen\";\n\tif (a[i] == 18) cout << \"eighteen\";\n\tif (a[i] == 19) cout << \"nineteen\";\n\tif (a[i] == 20) cout << \"twenty\";\n\tif (a[i] == 21) cout << \"twenty-one\";\n\tif (a[i] == 22) cout << \"twenty-two\";\n\tif (a[i] == 23) cout << \"twenty-three\";\n\tif (a[i] == 24) cout << \"twenty-four\";\n\tif (a[i] == 25) cout << \"twenty-five\";\n\tif (a[i] == 26) cout << \"twenty-six\";\n\tif (a[i] == 27) cout << \"twenty-seven\";\n\tif (a[i] == 28) cout << \"twenty-eight\";\n\tif (a[i] == 29) cout << \"twenty-nine\";\n\tif (a[i] == 30) cout << \"thirty\";\n\tif (a[i] == 31) cout << \"thirty-one\";\n\tif (a[i] == 32) cout << \"thirty-two\";\n\tif (a[i] == 33) cout << \"thirty-three\";\n\tif (a[i] == 34) cout << \"thirty-four\";\n\tif (a[i] == 35) cout << \"thirty-five\";\n\tif (a[i] == 36) cout << \"thirty-six\";\n\tif (a[i] == 37) cout << \"thirty-seven\";\n\tif (a[i] == 38) cout << \"thirty-eight\";\n\tif (a[i] == 39) cout << \"thirty-nine\";\n\tif (a[i] == 40) cout << \"forty\";\n\tif (a[i] == 41) cout << \"forty-one\";\n\tif (a[i] == 42) cout << \"forty-two\";\n\tif (a[i] == 43) cout << \"forty-three\";\n\tif (a[i] == 44) cout << \"forty-four\";\n\tif (a[i] == 45) cout << \"forty-five\";\n\tif (a[i] == 46) cout << \"forty-six\";\n\tif (a[i] == 47) cout << \"forty-seven\";\n\tif (a[i] == 48) cout << \"forty-eight\";\n\tif (a[i] == 49) cout << \"forty-nine\";\n\tif (a[i] == 50) cout << \"fifty\";\n\tif (a[i] == 51) cout << \"fifty-one\";\n\tif (a[i] == 52) cout << \"fifty-two\";\n\tif (a[i] == 53) cout << \"fifty-three\";\n\tif (a[i] == 54) cout << \"fifty-four\";\n\tif (a[i] == 55) cout << \"fifty-five\";\n\tif (a[i] == 56) cout << \"fifty-six\";\n\tif (a[i] == 57) cout << \"fifty-seven\";\n\tif (a[i] == 58) cout << \"fifty-eight\";\n\tif (a[i] == 59) cout << \"fifty-nine\";\n\tif (a[i] == 60) cout << \"sixty\";\n\tif (a[i] == 61) cout << \"sixty-one\";\n\tif (a[i] == 62) cout << \"sixty-two\";\n\tif (a[i] == 63) cout << \"sixty-three\";\n\tif (a[i] == 64) cout << \"sixty-four\";\n\tif (a[i] == 65) cout << \"sixty-five\";\n\tif (a[i] == 66) cout << \"sixty-six\";\n\tif (a[i] == 67) cout << \"sixty-seven\";\n\tif (a[i] == 68) cout << \"sixty-eight\";\n\tif (a[i] == 69) cout << \"sixty-nine\";\n\tif (a[i] == 70) cout << \"seventy\";\n\tif (a[i] == 71) cout << \"seventy-one\";\n\tif (a[i] == 72) cout << \"seventy-two\";\n\tif (a[i] == 73) cout << \"seventy-three\";\n\tif (a[i] == 74) cout << \"seventy-four\";\n\tif (a[i] == 75) cout << \"seventy-five\";\n\tif (a[i] == 76) cout << \"seventy-six\";\n\tif (a[i] == 77) cout << \"seventy-seven\";\n\tif (a[i] == 78) cout << \"seventy-eight\";\n\tif (a[i] == 79) cout << \"seventy-nine\";\n\tif (a[i] == 80) cout << \"eighty\";\n\tif (a[i] == 81) cout << \"eighty-one\";\n\tif (a[i] == 82) cout << \"eighty-two\";\n\tif (a[i] == 83) cout << \"eighty-three\";\n\tif (a[i] == 84) cout << \"eighty-four\";\n\tif (a[i] == 85) cout << \"eighty-five\";\n\tif (a[i] == 86) cout << \"eighty-six\";\n\tif (a[i] == 87) cout << \"eighty-seven\";\n\tif (a[i] == 88) cout << \"eighty-eight\";\n\tif (a[i] == 89) cout << \"eighty-nine\";\n\tif (a[i] == 90) cout << \"ninety\";\n\tif (a[i] == 91) cout << \"ninety-one\";\n\tif (a[i] == 92) cout << \"ninety-two\";\n\tif (a[i] == 93) cout << \"ninety-three\";\n\tif (a[i] == 94) cout << \"ninety-four\";\n\tif (a[i] == 95) cout << \"ninety-five\";\n\tif (a[i] == 96) cout << \"ninety-six\";\n\tif (a[i] == 97) cout << \"ninety-seven\";\n\tif (a[i] == 98) cout << \"ninety-eight\";\n\tif (a[i] == 99) cout << \"ninety-nine\";\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "02ade2d1ca0110b3551995750bf47d27", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\nint main()\n{\n char a[14][8]={{\"zero\"},{\"one\"},{\"two\"},{\"three\"},{\"four\"},{\"five\"},\n {\"six\"},{\"seven\"},{\"eight\"},{\"nine\"},{\"ten\"},{\"eleven\"},{\"twelve\"},{\"thirteen\"}},\n b[8][8]={{\"twenty\"},{\"thirty\"},{\"forty\"},{\"fifty\"},{\"sixty\"},{\"seventy\"},{\"eighty\"},{\"ninety\"}};\n int t,i,j;\n while(scanf(\"%d\",&t)!=EOF)\n {\n if(t<=13)\n printf(\"%s\\n\",a[t]);\n else if(t<=19)\n {\n if(t==15)\n printf(\"fifteen\\n\");\n else if(t==18)\n printf(\"eighteen\\n\");\n else\n printf(\"%steen\\n\",a[t-10]);\n }\n else\n {\n i=t%10;\n j=t/10;\n printf(\"%s-%s\\n\",b[j-2],a[i]);\n }\n }\n}\n\n\n ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a2a7be2acb261abe861ce93c346b26e9", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int n,z=0,c=0;\n cin>>n;\n int h=n,u=n;\n string d,s;\n if(n==10)\n {\n cout<<\"ten\"<\n#include \n\nusing namespace std;\n\nmain() {\n\tLL n, m;\n\tscanf(\"%I64d %I64d\", &n, &m);\n\tif (__gcd(n, m) > 1) puts(\"Impossible\");\n\telse {\n\t\twhile (n + m > 2) {\n\t\t\tif (n > m) printf(\"%I64dA\", (n - 1) / m), n %= m;\n\t\t\telse printf(\"%I64dB\", (m - 1) / n), m %= n;\n\t\t}\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a3868c6beef787e2d19d466eec2f15e2", "src_uid": "6a9ec3b23bd462353d985e0c0f2f7671", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \nusing namespace std;\n\ntypedef long long ll;\n\nstring ans;\n\nvoid gcd(ll a, ll b)\n{\n\tchar tmp[32];\n\twhile (a && b)\n\t{\n\t\tif (a > b)\n\t\t{\n\t\t\tsprintf(tmp, \"%lld\", b!=1?a/b:(a-1));\n\t\t\tans.append(tmp);\n\t\t\tans.push_back('A');\n\t\t\ta %= b;\n\t\t} else\n\t\t{\n\t\t\tsprintf(tmp, \"%lld\", a!=1?b/a:(b-1));\n\t\t\tans.append(tmp);\n\t\t\tans.push_back('B');\n\t\t\tb %= a;\n\t\t}\n\t}\n\tif (a+b != 1)\n\t{\n\t\tprintf(\"Impossible\\n\");\n\t\texit(0);\n\t}\n}\n\nint main()\n{\n\tll a, b;\n\tcin >> a >> b;\n\tgcd(a, b);\n\tcout << ans << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c4191f47ec32c1b158fdce8cbb95281b", "src_uid": "6a9ec3b23bd462353d985e0c0f2f7671", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include \n#define LL long long\n#define vi vector\n#define pb push_back\n#define sz size\n#define rev reverse\n#define all(x) (x).begin(),(x).end()\n#define it iterator\n#define REP(i,a,b) for(int i=(a);i<(b);i++)\n#define REPX(i,a,b,c) for(int i=(a);i<(b);i+=(c))\n#define DEP(i,a,b) for(int i=(a)-1;i>=(b);i--)\n#define REX(i,x) for(__typeof((x).begin()) i=(x).begin(); i!=(x).end();i++)\n#define pii pair\n#define mp make_pair\n#define fi first\n#define se second\n#define st string\n#define ffo find_first_of\n#define su substr\n#define vs vector\n#define ub upper_bound\n#define lb lower_bound\n#define bs binary_search\n#define li list\n#define em empty\n#define ap append\n#define ni next_int\n#define gu getchar_unlocked\n#define ts to_string\n#define mems(x) memset(x,0,sizeof(x))\n#define memc(x,y) memcpy(x,y,sizeof(y))\nusing namespace std;\nst s;\nLL gcd(LL a,LL b)\n{\n if(a>a>>b;\n LL g=gcd(a,b);\n if(g!=1) cout<<\"Impossible\\n\";\n else cout<\n\n#define REP(i,n) for(int i=0;i<(int)(n);i++)\n#define ALL(x) (x).begin(),(x).end()\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\n\nconst ld eps = 1e-9, pi = acos(-1.0);\n\nint main() {\n ll x, y;\n cin >> x >> y;\n if (__gcd(x, y) != 1LL) {\n cout << \"Impossible\" << endl;\n return 0;\n }\n string res;\n while (x > 1 || y > 1) {\n if (x == 1) {\n res += to_string(y - 1) + \"B\";\n y = 1;\n }\n else if (y == 1) {\n res += to_string(x - 1) + \"A\";\n x = 1;\n }\n else if (x > y) {\n res += to_string(x / y) + \"A\";\n x %= y;\n }\n else {\n res += to_string(y / x) + \"B\";\n y %= x;\n }\n }\n cout << res << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fe57b401b7fff77936953d4059467b76", "src_uid": "6a9ec3b23bd462353d985e0c0f2f7671", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define MAXN 100005\n__int64 x ,d ;\nint n ;\n\nint a[MAXN] , b[MAXN] , c[MAXN] ;\nvector v ;\n\nset> s ;\nset>::iterator it ;\n\n//x is 64-bit variable;\n__int64 getNextX() {\n x = (x * 37 + 10007) % 1000000007;\n return x;\n}\n\nvoid initAB() {\n int i ;\n\tfor(i = 0; i < n; i = i + 1){\n a[i] = i + 1;\n }\n for(i = 0; i < n; i = i + 1){\n swap(a[i], a[getNextX() % (i + 1)]);\n }\n for(i = 0; i < n; i = i + 1){\n if (i < d)\n b[i] = 1;\n else\n b[i] = 0;\n }\n for(i = 0; i < n; i = i + 1){\n swap(b[i], b[getNextX() % (i + 1)]);\n }\n}\n\n\nint main(){\n\twhile( scanf( \"%d%I64d%I64d\" , &n, &d , &x ) != EOF ) {\n\t\tinitAB() ;\n\t\tint cnt = 0 ;\n\t\tfor( int i = 0 ; i < n; i ++ )\n\t\t\tif( b[i] ) cnt ++ ;\n\t\tmemset( c , 0 , sizeof(c) ) ;\n\t\tif( (__int64)cnt * cnt <= n ) {\n\t\t\tv.clear() ;\n\t\t\tfor( int i = 0 ; i < n ; i ++ ) if( b[i] )v.push_back( i ) ;\n\t\t\tfor( int i = 0 ; i < n ; i ++ ) {\n\t\t\t\tint size = v.size () ;\n\t\t\t\tfor( int j = 0 ; j < size ; j ++ ) {\n\t\t\t\t\tif( v[j] > i ) break;\n\t\t\t\t\tc[i] = max( c[i] , a[i-v[j]] ) ;\n\t\t\t\t}\n\t\t\t}\n\t\t}else{\n\t\t\ts.clear() ;\n\t\t\tfor( int i = 0 ; i < n ; i ++ ) {\n\t\t\t\ts.insert( pair( a[i] , i ) ) ;\n\t\t\t\tit = s.end() ; it -- ;\n\t\t\t\tdo{\n\t\t\t\t\tif( b[i-it->second] ) {\n\t\t\t\t\t\tc[i] = it->first ;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif( it == s.begin () ) break;\n\t\t\t\t\tit --;\n\t\t\t\t}while( true ) ;\n\t\t\t}\n\t\t}\n\t\tfor( int i = 0 ; i < n ; i ++ ) \n\t\t\tprintf( \"%d\\n\" , c[i] ) ;\n\t}\n\treturn 0 ;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "eb9d790ad68e574a36d75f4ca4943d9d", "src_uid": "948ae7a0189ada07c8c67a1757f691f0", "difficulty": 2300.0} {"lang": "GNU C++", "source_code": "#include\n#define FOR(i,a,b) for(i=a;i<=b;i++)\n#define FOR2(i,a,b) for(i=a;inext=p;\n tail=p;\n }\n }\n};\nllist L;\nbool cmp(int u, int v){\n return a[u]>a[v];\n}\nint vt[nm];\nmain(){\n #ifndef ONLINE_JUDGE\n freopen(\"inp.txt\",\"r\",stdin);\n #endif\n int i,j,y,z,w;\n \n INL3(n,d,x);\n initAB();\n int dem=0;\n FOR2(i,0,n) vt[i]=i;\n sort(vt,vt+n,cmp);\n node *p,*q;\n FOR2(i,0,n) L.add(i);\n FOR2(i,0,n){\n if(L.head==NULL) break;\n p=L.head;\n while(p!=NULL){\n if(p->v >=vt[i] && b[p->v-vt[i]]){\n c[p->v]=a[vt[i]];\n if(p==L.head){\n L.head=p->next;\n p=p->next;\n }else{\n q->next=p->next;\n p=p->next;\n }\n continue;\n }\n q=p;\n p=p->next;\n }\n }\n FOR2(i,0,n) OUTD(c[i]);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "83b6f66fbd74c29a483ad9f18daa5b9a", "src_uid": "948ae7a0189ada07c8c67a1757f691f0", "difficulty": 2300.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nint a[100005],b[100005],c[100005],pos[100005],map[100005];\nlong long x,n,d;\nlong long getNextX()\n{\n x=(x*37+10007)%1000000007;\n return x;\n}\nvoid initAB()\n{\n for(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define pb push_back\n#define ll long long\n#define mp make_pair\n#define f first\n#define s second\n#define pii pair < int, int >\n#define ull unsigned long long\n#define pll pair < ll, ll >\n#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)\n#define all(s) s.begin(), s.end()\n#define sz(a) (int)a.size()\n\nconst int inf = (1ll << 25) - 1;\nconst int maxn = (int)2e5+100;\nconst int mod = (int) 1e9 + 7;\nusing namespace std;\nll x;\nint n;\nint d;\nint a[maxn];\nint b[maxn];\nint getNextX() {\n x = (x * 37 + 10007) % 1000000007;\n return x;\n}\nvoid initAB() {\n\tint i;\n for(i = 0; i < n; i = i + 1){\n a[i] = i + 1;\n }\n for(i = 0; i < n; i = i + 1){\n swap(a[i], a[getNextX() % (i + 1)]);\n }\n for(i = 0; i < n; i = i + 1){\n if (i < d)\n b[i] = 1;\n else\n b[i] = 0;\n }\n for(i = 0; i < n; i = i + 1){\n swap(b[i], b[getNextX() % (i + 1)]);\n }\n}\nconst int C = 30;\nll A[maxn/C];\nll B[maxn/C];\nint ans[maxn];\nint pos[maxn];\nvoid upd(int j, int T, ll val) {\n\tfor(int z = 0; z < C; z++) {\n\t\tif(val & (1ll<> n >> d >> x;\n\tinitAB();\n\tfor(int i = 0; i < n; i++) {\n\t\tpos[a[i]] = i;\n\t\tint z = i % C;\n\t\tA[i/C] |= 1ll<= 1; i--) {\n\t\tint j = pos[i];\n\t\tint t = j % C;\n\t\tint o = 0;\n\t\tll sec = (1ll<> t;\n\t\t\th &= B[o];\n\t\t\tif(h) {\n\t\t\t\tupd(j, i, h);\n\t\t\t}\n\t\t\tj += C;\n\t\t\to++;\n\t\t}\n\t}\n\tfor(int i = 0; i < n; i++) {\n\t\tcout << ans[i] << \"\\n\";\n\t}\n}\nint main () {\n int t=1;\n \t//scanf(\"%d\", &t);\n for(int i=1; i <= t; i++){\n //printf(\"Case #%d\\n\", i);\n solve();\n }\n \n return 0;\n}\n\u00a0", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5e443e420005fada24d02c29095b1049", "src_uid": "948ae7a0189ada07c8c67a1757f691f0", "difficulty": 2300.0} {"lang": "GNU C++", "source_code": "#include \n\nint solve(int m, int n, int s) \n{\n\tif (m < n) {\n\t\tint t = m;\n\t\tm = n;\n\t\tn = t;\n\t}\n\n\tif (s > m) return m * n;\n\n\tint a = (m-1) % s;\n\tint b = (m-1) / s;\n\tint x = (n-1) % s;\n\tint y = (n-1) / s;\n\treturn (b+1)*(y+1)*(a+1)*(x+1);\t\t\n}\n\nint main() \n{\n\tint m = 0;\n\tint n = 0;\n\tint s = 0;\n\twhile (scanf_s(\"%d %d %d\", &m, &n, &s))\n\t{\n\t\tint ret = solve(m, n, s);\n\t\tprintf(\"%d\\n\", ret);\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cb4e62650cf9491fb5804e1322e02680", "src_uid": "e853733fb2ed87c56623ff9a5ac09c36", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nint main()\n{\n long long n,m,s,i,j,k,l;\n cin>>n>>m>>s;\n if (s>=n&&s>=m)\n {\n k=n*m;\n cout<=n||s>=m)\n {\n if (s>=n) {k=(m+s-1)/s; k=k+k*((m-1)%s); k=k*(n%s); cout<=m) {k=(n+s-1)/s; k=k+k*((n-1)%s); k=k*(m%s); cout<\n#include \n#include \nusing namespace std;\n#define ll long long int\n#define FOR(i,a,b) for(int i= a;i\n#include\n\nusing namespace std;\n\n#typedef long long llint;\n\ninline int min_edge(int pos, int length, int step)\n{\n return length - ((length-1) % step);\n}\nlong solution(llint n, llint m, llint s)\n{\n llint minw = min_edge(1, n, s);\n llint minh = min_edge(1, m, s);\n llint max_points = (1+(minw-1)/s)*(1+(minh-1)/s);\n return (n-minw+1)*(m-minh+1)*max_points;\n /*long long max = in_rectangle(n, m, 1, 1, s);\n if(max == 1)\n return n*m;\n long long result = -max;\n for(int i=1;i<=s;i++)\n {\n if(in_rectangle(n, m, 1, i, s) == max)\n result+=max;\n if(in_rectangle(n, m, i, 1, s) == max)\n result+=max;\n }\n return result;*/\n}\nint main()\n{\n int n, m , s;\n cin >> n >> m >> s;\n cout << solution(n, m, s) << endl;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "757bb27feb115c4ce220b066e074a334", "src_uid": "e853733fb2ed87c56623ff9a5ac09c36", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nlong long n,m,apple,money,i;\nstring s[51];\nint main()\n{\n cin>>n>>m;\n m/=2;\n for(i=1;i<=n;i++) cin>>s[i];\n for(i=n;i>=1;i--)\n \n apple*=2;\n if(s[i]==\"halfplus\") apple+=1;\n money+=apple;\n }\n money*=m;\n cout<\nusing namespace std;\n\nlong long p, ans, num;\nint n;\nstring s[50];\n\nint main()\n{\n scanf(\"%d%lld\", &n, &p);\n p /= 2;\n for (int i = 1;i <= n;i ++)\n {\n cin >> s[i];\n }\n for (int i = n;i >= 1;i --)\n {\n num *= 2;\n if(s[i] == \"halfplus\") num ++;\n ans += num;\n }\n printf(\"%lld\", ans*p);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e6e1f2bd0f5f74a4fbb9e38233cdb0e8", "src_uid": "6330891dd05bb70241e2a052f5bf5a58", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n\nusing namespace std;\nint n,m,p,ans;\nstring s[1010];\nint main()\n{\n cin>>n>>p;\n for(int i=1;i<=n;i++)\n cin>>s[i];\n for(int i=n;i>=1;i--)\n {\n ans*=2;\n if(s[i]==\"halfplus\") ans+=1;\n }\n cout<\nusing namespace std;\nlong long n,m,apple,money;\nstring a[51];\nint main()\n{\n cin>>n>>m;\n m/=2;\n for(int i=1;i<=n;i++) \n\t cin>>s[i];\n for(int i=n;i>=1;i--)\n\t{\n apple*=2;\n if(strcmp(a[i],\"halfplus\")==0) \n\t\t apple++;\n money+=apple;\n }\n money*=m;\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\nusing namespace std;\n\ntypedef long long int64;\ntypedef unsigned long long uint64;\n#define two(X) (1<<(X))\n#define twoL(X) (((int64)(1))<<(X))\n#define contain(S,X) (((S)&two(X))!=0)\n#define containL(S,X) (((S)&twoL(X))!=0)\nconst double pi=acos(-1.0);\nconst double eps=1e-11;\nconst int inf=0x7FFFFFFF;\ntemplate inline void checkmin(T &a,T b){if(b inline void checkmax(T &a,T b){if(b>a) a=b;}\ntemplate inline T sqr(T x){return x*x;}\ntypedef pair ipair;\n#define SIZE(A) ((int)A.size())\n#define LENGTH(A) ((int)A.length())\n#define MP(A,B) make_pair(A,B)\n#define PB(X) push_back(X)\n#define zero(a) memset(a, 0, sizeof(a))\n#define out(x) (cout<<#x<<\": \"<void show(T a, int n){for(int i=0; ivoid show(T a, int r, int l){for(int i=0; i>tmp;\n\t\t\ta[tmp-3]++;\n\t\t}\n\t\tint64 ans = inf;//(uint64)(-1)>>1;\n\t\tint64 a1,b1,x,y, gv;\n\t\ta1 = a[0], b1 = a[2];\n\t\tgv = extgcd(a1,b1,x,y);\n\t\tint64 gbs = a1 / gv * a2;\n\n\t\tfor(int j=1; a[1]*jcc)swap(aa,cc);\n\t\t\tint64 delb = abs(aa-cc)/gbs/2*gbs;\n\t\t\taa -= delb;\n\t\t\tcc += delb;\n\t\t\tif(aa>0 && cc>0){\n\t\t\t\tcheckmin(ans,(int64)abs(aa-bb)+abs(bb-cc));\n\t\t\t}\n\t\t\tif(aa>cc)swap(aa,cc);\n\t\t\taa+=gbs;\n\t\t\tcc-=gbs;\n\t\t\tif(aa>0 && cc>0){\n\t\t\t\tcheckmin(ans,(int64)abs(aa-bb)+abs(bb-cc));\n\t\t\t}\n\t\t}\n\t\tcout<\nusing namespace std;\nint a[6],n,s,i,j,k,x,ans1,ans2;\nint main()\n{\n\t//freopen(\"1.in\",\"r\",stdin);\n\t//freopen(\"1.out\",\"w\",stdout);\n\tcin>>n>>s;\n\tfor(i=1;i<=n;i++)\n\tcin>>x,a[x]++;\n\tint ans=1e9;\n\tfor(i=s/a[3];i>0;i--) //\u00f6\ufffd\ufffdc3 \n\t\tfor(j=(s-i*a[3])/a[4];j>0;j--)//\u00f6\ufffd\ufffdc4 \n\t\t{\n\t\t\tk=(s-i*a[3]-j*a[4])/a[5];\n\t\t\tif (i*a[3]+j*a[4]+k*a[5]==s&&ans>abs(a[3]*i-a[4]*j)+abs(a[4]*j-a[5]*k))//\ufffd\ufffd\ufffd\u00b4\ufffd \n\t\t\tans=abs(a[3]*i-a[4]*j)+abs(a[4]*j-a[5]*k),ans1=i,ans2=j;\n\t\t}\n\tif (ans==1e9) cout<<-1;\n\telse\n\tcout<\n#include\n#define INF (1<<29)\n#define M 300000\n#define LL long long\nusing namespace std;\nint c3,c4,c5,k3,k4,k5,ans3,ans4,ans5,n,s,f,Gcd,rest;\nint gcd(int a,int b,int& x,int& y)\n{\n\tif(b==0)\n\t{\n\t\tx=1;\n\t\ty=0;\n\t\treturn a;\n\t}\n\tint d,tp;\n\td=gcd(b,a%b,x,y);\n\ttp=x;\n\tx=y;\n\ty=tp-(a/b)*y;\n\treturn d;\n}\nint abs(int i)\n{\n\treturn i>=0?i:-i;\n}\nint calF(int k)\n{\n\tint i,j,tp;\n\ti=k4+(c5/Gcd)*k;\n\tj=k5-(c4/Gcd)*k;\n\tif(k3<=i&&i<=j)\n\t{\n\t\ttp=abs(k3*c3-k4*c4)+abs(k4*c4-k5*c5);\n\t\tif(tp=k3&&i<=j)\n\t\t\t{\n\t\t\t\ttp=abs(c3*k3-c4*k4)+abs(c4*k4-c5*k5);\n\t\t\t\tif(tp>n>>s;\n\tfor(int i=0;i>j;\n\t\tif(j==3)\n\t\t\tc3++;\n\t\telse if(j==4)\n\t\t\tc4++;\n\t\telse if(j==5)\n\t\t\tc5++;\n\t}\n\tsolve();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "aa7e8a2232f982a630bc752a0f4ad4d0", "src_uid": "3f3eb49a127768139283ac04ee44950f", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "/*\n Anton Gulikov\n*/\n#pragma comment(linker,\"/STACK:300000000\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define gcd(a,b) __gcd((a),(b))\n#define sqr(a) ((a)*(a))\n#define odd(a) ((a)&1)\n#define foru(i,n) for (int i=0;i<(n);i++)\n#define ford(i,n) for (int i=(n)-1;i>=0;i--)\n#define forab(i,l,r) for (int i=(l);i<=(r);i++)\n#define forabd(i,r,l) for (int i=(r);i>=(l);i--)\n#define fillchar(a,b) memset((a),(b),sizeof((a)))\n#define pb push_back\n#define F first\n#define S second\n#define all(x) x.begin,x.end\n#define pw2(x) (1ull<<(x))\n\nconst long double eps=1e-20;\nconst long double pi=acos(-1.0);\nconst long long inf=1000*1000*1000*1000*1000*1000;\nconst long long base=1000*1000*1000+7;\n\nusing namespace std;\n\nint gcd_(int a,int b,int & x,int & y){\n\tif (a==0){\n\t\tx=0; y=1;\n\t\treturn b;\n\t} \n\tint x1,y1;\n\tint d=gcd_(b%a,a,x1,y1);\n\tx=y1-(b/a)*x1;\n\ty=x1;\n\treturn d;\n}\n\nint main(){\n\tint n,s;\n\tint a[4];\n\tscanf(\"%d%d\",&n,&s);\n\tforu(i,4) a[i]=0;\n\tforu(i,n){\n\t\tint x;\n\t\tscanf(\"%d\",&x);\n\t\ta[x-2]++;\n\t}\n\tint ans=1000000000,a1,a2,a3;\n\tforu(i,(s+1)/a[2]+1){\n\t\tint x=i*a[2];\n\t\tint tmps=s-x;\n\t\tif (tmps%gcd(a[1],a[3])!=0) continue;\n\t\tint x1=min(s-i*a[3],i*a[1]);\n\t\tif (x>x1){\n\t\t\tfor(int j=x1;j>=0;j--)if (j%a[1]==0 && (tmps-j)%a[3]==0){\n\t\t\t\tint k2=i,k1=s1/a[1],k3=s3/a[3];\n\t\t\t\tif (k1<0 || k1>k2 || k2>k3 || k1>k3) continue;\n\t\t\t\tif (k1*a[1]+k2*a[2]+k3*a[3]==s && ans>abs(k1*a[1]-k2*a[2])+abs(k2*a[2]-k3*a[3])){\n\t\t\t\t\tans=abs(k1*a[1]-k2*a[2])+abs(k2*a[2]-k3*a[3]);\n\t\t\t\t\ta1=k1; a2=k2; a3=k3;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} else{\n\t\t\tfor(int j=x;j<=x1;j++)if (j%a[1]==0 && (tmps-j)%a[3]==0){\n\t\t\t\tint k2=i,k1=s1/a[1],k3=s3/a[3];\n\t\t\t\tif (k1<0 || k1>k2 || k2>k3 || k1>k3) continue;\n\t\t\t\tif (k1*a[1]+k2*a[2]+k3*a[3]==s && ans>abs(k1*a[1]-k2*a[2])+abs(k2*a[2]-k3*a[3])){\n\t\t\t\t\tans=abs(k1*a[1]-k2*a[2])+abs(k2*a[2]-k3*a[3]);\n\t\t\t\t\ta1=k1; a2=k2; a3=k3;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor(int j=x;j>=0;j--) if (j%a[1]==0 && (tmps-j)%a[3]==0){\n\t\t\t\tint k2=i,k1=s1/a[1],k3=s3/a[3];\n\t\t\t\tif (k1<0 || k1>k2 || k2>k3 || k1>k3) continue;\n\t\t\t\tif (k1*a[1]+k2*a[2]+k3*a[3]==s && ans>abs(k1*a[1]-k2*a[2])+abs(k2*a[2]-k3*a[3])){\n\t\t\t\t\tans=abs(k1*a[1]-k2*a[2])+abs(k2*a[2]-k3*a[3]);\n\t\t\t\t\ta1=k1; a2=k2; a3=k3;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif (ans==1000000000) printf(\"-1\"); else printf(\"%d %d %d\",a1,a2,a3);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "86415df1a348059e30b57815435b7386", "src_uid": "3f3eb49a127768139283ac04ee44950f", "difficulty": 2400.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\nint main()\n{\n char n[11];\n while(gets(n) && n[0]!=NULL)\n {\n int i,j,len=strlen(n),s=0;\n for(i=len-1,j=0;i>=0;i--,j++)\n s+=(n[i]-48)*(int)pow(2,j);\n printf(\"%d\\n\",s);\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ec2096eb4fa29c09e4bacc4699dc81d3", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#define int64 long long\n\nusing namespace std;\n\nint kol_zifr(int t) {\n\tint x = 0;\n\twhile (t > 0) {\n\t\tt /= 10;\n\t\t++x;\n\t}\n\treturn x;\n}\n\nint next (int t) {\n\tint k = kol_zifr(t);\n\tchar s[k];\n\tchar* r = itoa(t, s, 10);\n\tbool z = false;\n\tfor (int i = k - 1; i >= 0; --i) {\n\t\tif (s[i] > '1') {\n\t\t\tz = true;\n\t\t\ts[i] = '1';\n\t\t}\n\t}\n\tif (!z) {\n\t\tbool b = false;\n\t\tfor (int i = k - 1; i >= 1; --i) {\n\t\t\tif (s[i] == '1') {\n\t\t\t\ts[i] = '0';\n\t\t\t\tfor (int j = i + 1; j < k; ++j) s[j] = '1';\n\t\t\t\tb = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!b) {\n\t\t\ts[0] = '0';\n\t\t\tfor (int i = k - 1; i > 0; --i) s[i] = '1';\n\t\t}\n\t}\n\tint res = 0, ku = 1;\n\tfor (int i = k - 1; i >= 0; --i) {\n\t\tres += ku * (s[i] - '0');\n\t\tku *= 10;\n\t}\n\treturn res;\n}\n\nint is_n_good(int t) {\n\tint b = 0;\n\twhile (t > 0) {\n\t\tint zz = t % 10;\n\t\tif (zz != 0 && zz != 1) {\n\t\t\tb = 1;\n\t\t\tbreak;\n\t\t}\n\t\tt /= 10;\n\t}\n\treturn b;\n}\n\nint main () {\n\tint n, h = 0;\n\tcin >> n;\n\tint na = is_n_good(n);\n\twhile (n > 0) {\n\t\tn = next(n);\n\t\t++h;\n\t}\n\tcout << h - na;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "43f53d44383ac6d1492463485f786b5f", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include\nusing namespace std;\n\nint main(){\n long long a,b,order[600],n;\n int t[64],i=512,j,k;\n scanf(\"%I64d\",&n);\n for(i=1;i<=512;i++)\n {\n\n k=i;\n memset(t,0,sizeof(t));\n for(j=0;k>0;j++)\n {\n t[j]=k%2;\n k=k/2;\n }\n a=0;\n for(j=0;j<64;j++)\n b=1;\n for(k=0;k<=10;k++)\n {\n\n a=a+t[k]*b;\n b=b*10;\n }\n order[i]=a;\n\n }\n for(i=1;n>=order[i];i++)\n {\n ;\n }\n printf(\"\\n%d\",i-1);\n\n}\n\n\t \t\t \t\t\t\t\t\t \t\t \t \t\t \t\t\t\t", "lang_cluster": "C++", "compilation_error": true, "code_uid": "56d1ea204421a2b9f74aeb7aa221ea07", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nlong P(long x)\n{\n\tlong flag=1;\n\tif (x==111111111||x==1000000000)\n\t{\n\t\treturn 1;\n\t}\n\twhile(x!=0)\n\t{\n\t\tlong a=x%10;\n\t\tif (a!=0&&a!=1)\n\t\t{\n\t\t\tflag=0;\n\t\t\tbreak;\n\t\t}\n\t\tx/=10;\n\t}\n\treturn flag;\n}\nint main()\n{\n\tlong n,s=0;\n\tcin>>n;\n\tfor (long i=1;i<=n;i++)\n\t{\n\t\tif (i>111111111&&i<1000000000)\n\t\t{\n\t\t\tcontinue;\n\t\t}\n\t\tif (P(i)==1)\n\t\t{\n\t\t\ts++;\n\t\t}\n\t}\n\tcout<\n#include\n#include\n#define N 35\n#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~i))\n#define rf(i,a,b) for(register int i=(a);i>=(b);i=~(-i))\nint dp[N][N][2],sum[N][2],n,m,mod=1e9+7,fac[N],ifac[N],lim[N],pow2[N],ans;\nint spow(int m,int n)\n{\n\tint b=1;\n\tfor(;n;n>>=1,m=1ll*m*m%mod)if(n&1)b=1ll*b*m%mod;\n\treturn b;\n}\nint C(int n,int m){return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;}\nint ADD(int x,int y){return (x+=y)>=mod?x-mod:x;}\nvoid init()\n{\n\tfac[0]=ifac[0]=1,pow2[0]=1;\n\tf(i,1,32)fac[i]=1ll*fac[i-1]*i%mod,pow2[i]=2ll*pow2[i-1]%mod;\n\tifac[32]=spow(fac[32],mod-2);\n\trf(i,31,1)ifac[i]=1ll*ifac[i+1]*(i+1)%mod;\n\tf(i,1,32)\n\t f(j,0,i)\n\t sum[i][j&1]=ADD(sum[i][j&1],C(i,j));\n\twhile(n)lim[++m]=n&1,n>>=1;\n\tstd::reverse(lim+1,lim+m+1);\n}\nint main()\n{\n\tscanf(\"%d\",&n);\n\tinit();\n\tdp[0][0][1]=1;\n\tf(i,1,m)dp[i][0][0]=1;//\u5982\u679c\u8be5\u4f4d\u586b\u7b2c\u4e00\u4e2a\u5411\u91cf\uff0c\u90a3\u4e5f\u7b97\u4e00\u79cd\u65b9\u6848\n\tf(i,1,m)\n\t\tf(j,1,i)//create a new unlimited state stands iff this is 1 and we make it 0\n\t\t{\n\t\t\tdp[i][j][0]=ADD(1ll*dp[i-1][j][0]*pow2[j]%mod,dp[i-1][j-1][0]);//no limit, or fill and last unlimited\n\t\t\tif(lim[i])\n\t\t\t{\n\t\t\t\tdp[i][j][0]=ADD(dp[i][j][0],1ll*dp[i-1][j][1]*sum[j][0]%mod);//make it!\n\t\t\t\tdp[i][j][1]=ADD(dp[i-1][j-1][1],1ll*dp[i-1][j][1]*sum[j][1]%mod);//limited, fill/unfill a vector\n\t\t\t}\n\t\t\telse dp[i][j][1]=1ll*dp[i-1][j][1]*sum[j][0]%mod;//cannot fill a vector\n\t\t\t/*\n\t\t\t i j 0 <- (i-1 j 1 & make it 0) | (i-1 j 0 & forall) | (i-1 j-1 0)\n\t\t\t i j 1 <- (i-1 j 1 & make it fit the num) | (i-1 j-1 1)\n\t\t\t*/\n\t\t}\n\tf(i,0,m)ans=ADD(ans,ADD(dp[m][i][0],dp[m][i][1]));\n\treturn printf(\"%d\\n\",ADD(ans,mod)),0;", "lang_cluster": "C++", "compilation_error": true, "code_uid": "aa0f7de65026e04cbab76cbef9c850be", "src_uid": "ead64d8e3134fa8f29881cb487e52f60", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\ntypedef long long ll;\nconst int mod = 1000000007;\n\nll pw2[99];\n\nll f_rlen[99][99];\n\ninline void upda(ll &a, ll b) {\n a = (a + b) % mod;\n}\n\ninline void init_f_rlen() {\n pw2[0] = 1;\n for(int i = 1; i <= 91; ++i) pw2[i] = pw2[i - 1] * 2 % mod;\n f_rlen[0][0] = 1;\n for(int rlen = 1; rlen <= 90; ++rlen) for(int rlen1 = 0; rlen1 <= rlen; ++rlen1) {\n if(rlen1) f_rlen[rlen][rlen1] = f_rlen[rlen - 1][rlen1 - 1] * pw2[rlen - rlen1]) % mod;\n if(rlen1 < rlen) f_rlen[rlen][rlen1] = (f_rlen[rlen][rlen1] + f_rlen[rlen - 1][rlen1]) % mod;\n }\n}\n\nll g_pf[44][44];\n\ninline ll calc_prefix(int pf, int rlen) {\n ll ans = 0;\n for(int rlen1 = 0; rlen1 <= rlen; ++rlen1) {\n ll t1ans = 0;\n memset(g_pf, 0, sizeof(g_pf));\n g_pf[0][0] = 1;\n for(int pfmv = 0; (pf >> pfmv); ++pfmv) for(int pfmv1 = 0; pfmv1 <= pfmv; ++pfmv1) {\n if((pf >> pfmv) == 1) t1ans = (t1ans + g_pf[pfmv][pfmv1]) % mod;\n else {\n upda(g_pf[pfmv + 1][pfmv1], g_pf[pfmv][pfmv1]);\n if(pf >> pfmv & 1) upda(g_pf[pfmv + 1][pfmv1 + 1], g_pf[pfmv][pfmv1] * pw2[pfmv - pfmv1 + rlen - rlen1]);\n }\n }\n ans = (ans + t1ans * pw2[rlen - rlen1] % mod * f_rlen[rlen][rlen1]) % mod;\n }\n return ans;\n}\n\ninline ll calc_ans(int n) {\n if(n == 0) return 1;\n ll ans = 1; // max = 0;\n int len0;\n for(len0 = 0; (1 << (len0 + 1)) <= n; ++len0) ans = (ans + calc_prefix(1, len0)) % mod;\n int t_pf = 1;\n for(int i = len0 - 1; i >= 0; --i) {\n int a = n >> i & 1;\n if(!a) t_pf <<= 1;\n else {\n ans = (ans + calc_prefix(t_pf << 1, i)) % mod;\n t_pf = t_pf << 1 | 1;\n }\n }\n ans = (ans + calc_prefix(n, 0)) % mod;\n return ans;\n}\n\nint main() {\n init_f_rlen();\n#ifdef TEST\n printf(\"[DEBUG] calc_ans(3) = %I64d (expected: 5)\\n\", calc_ans(3));\n#else\n int k; scanf(\"%d\", &k);\n printf(\"%I64d\\n\", calc_ans(k));\n#endif\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "83d5b48312752a33f6660d43d25cdeeb", "src_uid": "ead64d8e3134fa8f29881cb487e52f60", "difficulty": 2700.0} {"lang": "GNU C++0x", "source_code": "// https://pp.vk.me/c540102/v540102394/7cd5/J2NXxBbvBrM.jpg\n#pragma GCC optimize(\"O500\")\n#define _CRT_SECURE_NO_DEPRECATE\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n//#include \n//#include \n#include \n#include \n#define mp make_pair\n#define FOR(i,a,b) for(int i=(a),_b(b);i<_b;++i)\n#define FORD(i,a,b) for(int i=(a),_b(b);i>=_b;--i)\n#define REP(i,n) FOR(i,0,n)\n#define CL(x) memset(x, 0, sizeof(x))\n#define SINF(x) memset(x, 0x3F, sizeof(x))\n#define SVAL(x, y) memset(x, y, sizeof(x))\n#define CP(t, f) memcpy(t, f, sizeof(f));\n#define CPS(t, f, s) memcpy(t, f, s*sizeof(f[0]))\n#define ALL(a) (a).begin(), (a).end()\n#define ALLR(a) (a).rbegin(), (a).rend()\n#define FIN freopen(\"in.txt\", \"r\", stdin);\n#define FINOUT freopen(\"in.txt\", \"w\", stdout);\n#define FOUT freopen(\"out.txt\", \"w\", stdout);\n#define y1 ____y1\nusing namespace std;\ntypedef const int CI;\ntypedef long long ll;\ntypedef unsigned long long ull;\n//typedef __float128 ld;\n//typedef long double ld;\ntypedef double ld;\ntypedef vector VINT;\ntypedef vector VLD;\ntypedef vector VLL;\ntypedef vector > VVINT;\ntypedef pair PII;\ntypedef pair PIII;\ntypedef pair PIIII;\ntypedef pair PLL;\ntypedef pair PLD;\ntypedef pair ptp;\ntypedef complex Cn;\ntypedef vector VPII;\ntypedef vector VPLL;\ntypedef vector VPIII;\ntypedef unsigned int uint;\nconst ld eps=1e-12;\n//const int INF = 1000000001;\nconst int oo=0x3F3F3F3F;\nconst ll ooLL=0x3F3F3F3F3F3F3F3FLL;\nconst int MOD=1000000007;\ntemplate T sqr(T x) { return x*x; }\ntemplate void debpr(const T &);\ntemplate void debpr(const pair &);\ntemplate void debpr(const vector &);\ntemplate void debpr(const set &);\ntemplate void debpr(const map &);\ntemplate void prcont(T be, T en, const string &st, const string &fi, const string &mi) { debpr(st); bool ft=0; while (be!=en) { if (ft) debpr(mi); ft=1; debpr(*be); ++be; } debpr(fi); }\ntemplate void debpr(const T &a) {\n#ifdef EgQrauETGh\n cerr< void debpr(const pair &p) { debpr(\"(\"); debpr(p.first); debpr(\", \"); debpr(p.second); debpr(\")\"); }\ntemplate void debpr(const vector &a) { prcont(a.begin(), a.end(), \"[\", \"]\", \", \"); }\ntemplate void debpr(const set &a) { prcont(a.begin(), a.end(), \"{\", \"}\", \", \"); }\ntemplate void debpr(const map &a) { prcont(a.begin(), a.end(), \"{\", \"}\", \", \"); }\nvoid deb() {};\ntemplate void deb(const T1 &t1) { debpr(t1); debpr('\\n'); }\ntemplate void deb(const T1 &t1, const T2 &t2) { debpr(t1); debpr(' '); debpr(t2); debpr('\\n'); }\ntemplate void deb(const T1 &t1, const T2 &t2, const T3 &t3) { debpr(t1); debpr(' '); debpr(t2); debpr(' '); debpr(t3); debpr('\\n'); }\ntemplate void deb(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4) { debpr(t1); debpr(' '); debpr(t2); debpr(' '); debpr(t3); debpr(' '); debpr(t4); debpr('\\n'); }\nconst ld PI=acos(-1.);\nll Round(double x) { return x<0?x-.5:x+.5; }\ntemplate void ass(bool v, const T &x, string m=\"Fail\") { if (!v) { deb(m); deb(x); throw; } }\nint main()\n{\n#ifdef EgQrauETGh\n FIN; ld tm=clock();\n#else\n //freopen(\"input.txt\", \"r\", stdin); freopen(\"output.txt\", \"w\", stdout);\n#endif\n void run(); run();\n#ifdef EgQrauETGh\n cerr<=MOD) a-=MOD; return a;\n}\nint mul(int a, ll b)\n{\n return (a*b)%MOD;\n}\nint pw2(int p)\n{\n return p<0?1:1<\nmap, int> m;\nint go(int n, int p, int l, int f)\n{\n if (p==-1) return 1;\n int &rs=m[{p, l, f}];\n if (rs) return rs;\n if (f)\n {\n return rs=add(go(n, p-1, l+1, f), mul(go(n, p-1, l, f), pw2(l)));\n }\n else\n {\n int bi=(n>>p)&1;\n if (!bi) return mul(go(n, p-1, l, 0), pw2(l-1));\n if (l)\n {\n rs=add(rs, mul(go(n, p-1, l, 1), pw2(l-1)));\n rs=add(rs, mul(go(n, p-1, l, 0), pw2(l-1)));\n }\n else rs=add(rs, go(n, p-1, l, 1));\n rs=add(rs, go(n, p-1, l+1, 0));\n return rs;\n }\n throw;\n}\nvoid run()\n{\n int n;\n scanf(\"%d\", &n);\n printf(\"%d\\n\", go(n, 30, 0, 0));\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6c5d68565e86bbbb8b2ec986370aec78", "src_uid": "ead64d8e3134fa8f29881cb487e52f60", "difficulty": 2700.0} {"lang": "GNU C++0x", "source_code": "// https://pp.vk.me/c540102/v540102394/7cd5/J2NXxBbvBrM.jpg\n#pragma GCC optimize(\"O500\")\n#define _CRT_SECURE_NO_DEPRECATE\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n//#include \n//#include \n#include \n#include \n#define mp make_pair\n#define FOR(i,a,b) for(int i=(a),_b(b);i<_b;++i)\n#define FORD(i,a,b) for(int i=(a),_b(b);i>=_b;--i)\n#define REP(i,n) FOR(i,0,n)\n#define CL(x) memset(x, 0, sizeof(x))\n#define SINF(x) memset(x, 0x3F, sizeof(x))\n#define SVAL(x, y) memset(x, y, sizeof(x))\n#define CP(t, f) memcpy(t, f, sizeof(f));\n#define CPS(t, f, s) memcpy(t, f, s*sizeof(f[0]))\n#define ALL(a) (a).begin(), (a).end()\n#define ALLR(a) (a).rbegin(), (a).rend()\n#define FIN freopen(\"in.txt\", \"r\", stdin);\n#define FINOUT freopen(\"in.txt\", \"w\", stdout);\n#define FOUT freopen(\"out.txt\", \"w\", stdout);\n#define y1 ____y1\nusing namespace std;\ntypedef const int CI;\ntypedef long long ll;\ntypedef unsigned long long ull;\n//typedef __float128 ld;\n//typedef long double ld;\ntypedef double ld;\ntypedef vector VINT;\ntypedef vector VLD;\ntypedef vector VLL;\ntypedef vector > VVINT;\ntypedef pair PII;\ntypedef pair PIII;\ntypedef pair PIIII;\ntypedef pair PLL;\ntypedef pair PLD;\ntypedef pair ptp;\ntypedef complex Cn;\ntypedef vector VPII;\ntypedef vector VPLL;\ntypedef vector VPIII;\ntypedef unsigned int uint;\nconst ld eps=1e-12;\n//const int INF = 1000000001;\nconst int oo=0x3F3F3F3F;\nconst ll ooLL=0x3F3F3F3F3F3F3F3FLL;\nconst int MOD=1000000007;\ntemplate T sqr(T x) { return x*x; }\ntemplate void debpr(const T &);\ntemplate void debpr(const pair &);\ntemplate void debpr(const vector &);\ntemplate void debpr(const set &);\ntemplate void debpr(const map &);\ntemplate void prcont(T be, T en, const string &st, const string &fi, const string &mi) { debpr(st); bool ft=0; while (be!=en) { if (ft) debpr(mi); ft=1; debpr(*be); ++be; } debpr(fi); }\ntemplate void debpr(const T &a) {\n#ifdef EgQrauETGh\n cerr< void debpr(const pair &p) { debpr(\"(\"); debpr(p.first); debpr(\", \"); debpr(p.second); debpr(\")\"); }\ntemplate void debpr(const vector &a) { prcont(a.begin(), a.end(), \"[\", \"]\", \", \"); }\ntemplate void debpr(const set &a) { prcont(a.begin(), a.end(), \"{\", \"}\", \", \"); }\ntemplate void debpr(const map &a) { prcont(a.begin(), a.end(), \"{\", \"}\", \", \"); }\nvoid deb() {};\ntemplate void deb(const T1 &t1) { debpr(t1); debpr('\\n'); }\ntemplate void deb(const T1 &t1, const T2 &t2) { debpr(t1); debpr(' '); debpr(t2); debpr('\\n'); }\ntemplate void deb(const T1 &t1, const T2 &t2, const T3 &t3) { debpr(t1); debpr(' '); debpr(t2); debpr(' '); debpr(t3); debpr('\\n'); }\ntemplate void deb(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4) { debpr(t1); debpr(' '); debpr(t2); debpr(' '); debpr(t3); debpr(' '); debpr(t4); debpr('\\n'); }\nconst ld PI=acos(-1.);\nll Round(double x) { return x<0?x-.5:x+.5; }\ntemplate void ass(bool v, const T &x, string m=\"Fail\") { if (!v) { deb(m); deb(x); throw; } }\nint main()\n{\n#ifdef EgQrauETGh\n FIN; ld tm=clock();\n#else\n //freopen(\"input.txt\", \"r\", stdin); freopen(\"output.txt\", \"w\", stdout);\n#endif\n void run(); run();\n#ifdef EgQrauETGh\n cerr<=MOD) a-=MOD; return a;\n}\nint mul(int a, ll b)\n{\n return (a*b)%MOD;\n}\nint pw2(int p)\n{\n return p<0?1:1<, int> m;\nint go(int n, int p, int l, int f)\n{\n if (p==-1) return 1;\n int &rs=m[{p, l, f}];\n if (rs) return rs;\n if (f)\n {\n return rs=add(go(n, p-1, l+1, f), mul(go(n, p-1, l, f), pw2(l)));\n }\n else\n {\n int bi=(n>>p)&1;\n if (!bi) return mul(go(n, p-1, l, 0), pw2(l-1));\n if (l)\n {\n rs=add(rs, mul(go(n, p-1, l, 1), pw2(l-1)));\n rs=add(rs, mul(go(n, p-1, l, 0), pw2(l-1)));\n }\n else rs=add(rs, go(n, p-1, l, 1));\n rs=add(rs, go(n, p-1, l+1, 0));\n return rs;\n }\n throw;\n}\nvoid run()\n{\n int n;\n scanf(\"%d\", &n);\n printf(\"%d\\n\", go(n, 30, 0, 0));\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "58059e52795a8221d2e6c3b99342eddc", "src_uid": "ead64d8e3134fa8f29881cb487e52f60", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "/*\n * parasol \n */\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define ll long long\nconst ll maxn = 1e6+5;\nconst ll mod = 1e9+7;\nconst double eps = 1e-9;\nconst double pi = acos(-1.0);\nconst ll inf = 0x3f3f3f3f;\nll l1, r1, t1;\nll l2, r2, t2;\n\nll gcd(ll a, ll b){\n return b==0?a:gcd(b, a%b);\n}\n\nvoid solve() {\n \n if (gcd(t1, t2) == 1) {\n printf(\"%lld\\n\", min(len1, len2));\n return;\n }\n if (len1 > len2) {\n swap(l1, l2);\n swap(r1, r2);\n swap(t1, t2);\n }\n ll len1 = r1-l1+1;\n ll len2 = r2-l2+1;\n \n //if (l1 > l2) {\n //for(ll i = 1; i <= 10020; i++){\n //l2 += 100000*t2;\n //if (l2 >= l1) break;\n //}\n //l2 += t2;\n //}\n ll ans = 0;\n ll g = gcd(t1, t2);\n ll p1 =((l2-l1)%g+g)%g;\n if (p1 <= len1) {\n ll lenth1 = len1-p1;\n ans = max(ans, min(lenth1, len2)); \n }\n ll p2 = (t1 - p1);\n ans = max(ans, min(len2-p2, len1));\n printf(\"%lld\\n\",ans);\n}\n\nint main() {\n //freopen(\"in.txt\", \"r\", stdin);\n //freopen(\"out.txt\", \"w\", stdout);\n \n cin >> l1 >> r1 >> t1;\n cin >> l2 >> r2 >> t2;\n \n solve();\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1a59638c6129a5c869a29ae51efcc975", "src_uid": "faa75751c05c3ff919ddd148c6784910", "difficulty": 1900.0} {"lang": "GNU C++11", "source_code": "#include \n#define int long long\nusing namespace std;\nconst int N = 1123456;\nconst int mod = 1e9 + 7;\nconst int inf = 1e9 + 7;\ninline long long read () {\n char c = getchar();\n long long t = 0, f = 1;\n while (!isdigit(c)) f = (c == '-') ? -1 : 1, c = getchar();\n while (isdigit(c)) t = t * 10 + c - 48, c = getchar();\n return t * f;\n}\nint a[N];\nint b[N];\nint getrand(int x, int w) {\n while(1) {\n int d = rand() % w;\n //cout << d << \" \" << x << endl;\n if(x < d)\n return d;\n }\n}\nmain()\n{\n int n, m, i, j, t, d, l1, r1, t1, l2, t2, r2;\n cin >> l1 >> r1 >> t1;\n cin >> l2 >> r2 >> t2;\n\n int ans = 0;\n if(g == 1) {\n cout << min(r1 - l1 + 1, r2 - l2 + 1);\n return 0;\n }\n else {\n int e = l2 - l1;\n t2 = max(t2, t1);\n if(e < 0) {\n e += t2;\n }\n e %= g;\n ans = max(ans, min(r1 - l1 + 1 - e, r2 - l2 + 1));\n e = l1 - l2;\n if(e < 0) {\n e += t2;\n }\n e %= g;\n ans = max(ans, min(r2 - l2 + 1 - e, r1 - l1 + 1));\n }\n cout << ans;\n}\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0528fc7f965d5ac552e0f03e963e3f77", "src_uid": "faa75751c05c3ff919ddd148c6784910", "difficulty": 1900.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\n#define tll(x) static_cast(x)\n\nint la, ra, ta;\nint lb, rb, tb;\n\nint gcd(int a, int b) {\n if(b > a) swap(a, b);\n if(b == 0) return a;\n return gcd(b, a%b);\n}\nint gcd2(int a, int b, int &x, int &y) //from geeksforgeeks\n{ \n if (a == 0) {\n x = 0;\n y = 1;\n return b;\n } \n \n int x1, y1;\n int gcd = gcd2(b%a, a, x1, y1); \n \n x = y1 - (b/a) * x1; \n y = x1;\n \n return gcd; \n} \nll divF(ll a, ll b) {\n assert(b != 0);\n if(b < 0) a*=-1, b*=-1;\n if(a < 0) return -((-a + b - 1)/b); else return a/b;\n}\n\nint ans;\nint v1, v2;\nvoid test(ll t) {\n ll a1 = t * ta * v1 + la, a2 = t * ta * v1 + ra + 1;\n ll b1 = t * tb * (-v2) + lb, b2 = t * tb * (-v2) + rb + 1;\n //cerr << a1 << \" \" << a2 << \" \" << b1 << \" \" << b2 << \"\\n\";\n ans = (max(ans, static_cast(min(a2, b2) - max(a1, b1))));\n}\n\nint main() {\n scanf(\"%d%d%d%d%d%d\", &la, &ra, &ta, &lb, &rb, &tb);\n \n int v = gcd(ta, tb);\n \n gcd2(ta, tb, v1, v2);\n //cerr << (tll(v1) * ta + tll(v2) * tb) << \"\\n\";\n \n if(tll(v1) * ta + tll(v2) * tb == 1) {printf(\"%d\\n\", 1 + min(ra-la, rb-lb));return 0;}\n \n ans = 0;\n ll t = divF(lb - la, tll(v1) * ta + tll(v2) * tb);\n test(t - 1);\n test(t);\n test(t + 1);\n \n printf(\"%d\\n\", ans);\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d5f3e26135c1b1db7c9c29d07b4ddc99", "src_uid": "faa75751c05c3ff919ddd148c6784910", "difficulty": 1900.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pii;\ntypedef pair piii;\ntypedef pair ipii;\n#define MOD 1000000007\n#define mod(a) ((a)%MOD)\n#define pb push_back\n#define ft first\n#define sd second\n#define mp make_pair\n#define dbg(x) cout<<#x<<\" = \"<\n#include \nusing namespace __gnu_pbds;\ntypedef tree,rb_tree_tag,tree_order_statistics_node_update> ordered_set;*/\n#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)\n#define all(v) v.begin(),v.end()\n#define endl '\\n'\nll gcd(ll a,ll b){if(a==0) return b; return gcd(b%a,a);}\nll powm(ll base,ll exp,ll mod=MOD) {base%=mod;ll ans=1;while(exp){if(exp&1LL) ans=(ans*base)%mod;exp>>=1LL,base=(base*base)%mod;}return ans;}\n \n \n \n\n\nint main(){\n sync;\n ll l[2],r[2],t[2];\n cin>>l[0]>>r[0]>>t[0];\n cin>>l[1]>>r[1]>>t[1];\n if(l[0]\n#define pb push_back\n#define X first\n#define Y second\nusing namespace std;\ntemplate bool smax(T &x,L y){ return x < y ? ( x = y, 1) : 0; }\ntemplate bool smin(T &x,L y){ return y < x ? ( x = y, 1) : 0; }\ntypedef long long ll;\ntypedef pair pii;\n\nconst int maxn = 1e5 + 17;\nint n, m, p[maxn], d[maxn];\npii e[maxn];\nset cur;\nbool bad(int v, int u){\n return v == u || d[v] == 2 || d[u] == 2 || binary_search(e, e + m, pii(minmax(v, u))) || cur.count(minmax(v, u));\n}\nmain(){\n ios::sync_with_stdio(0), cin.tie(0);\n srandom(time(0));\n cin >> n >> m;\n for(int i = 0; i < m; i++){\n\tcin >> e[i].X >> e[i].Y;\n\te[i] = minmax(e[i].X, e[i].Y);\n }\n sort(e, e + m);\n if(n < 7){\n\tiota(p, p + n, 1);\n\tdo{\n\t bool ok = 1;\n\t for(int i = 0; ok && i < m; i++)\n\t\tif(binary_search(e, e + m, pii(minmax(p[i], p[(i + 1) % n]))))\n\t\t ok = 0;\n\t if(ok){\n\t\tfor(int i = 0; i < m; i++)\n\t\t cout << p[i] << ' ' << p[(i + 1) % n] << '\\n';\n\t\treturn 0;\n\t }\n\t} while(next_permutation(p, p + n));\n\treturn cout << \"-1\\n\", 0;\n }\n for(int i = 0; i < m; i++){\n\tint v = random() % n + 1, u = random() % n + 1;\n\twhile(bad(v, u))\n\t v = random() % n + 1, u = random() % n + 1;\n\tcout << v << ' ' << u << '\\n';\n\td[v]++, d[u] ++;\n\tcur.insert(minmax(v, u));\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "85e7354db5b82c5a5015901991290cae", "src_uid": "c4c85cde8a5bb5fefa4eb68fc68657d5", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "/*.\n.\n.\n.\n*/// _________ ________ ________ ________\n /////\\\\\\\\\\\\ /////\\\\\\\\\\ |||||||| ||||||||\n ///// \\\\\\\\\\\\ ///// \\\\\\\\\\ ||||||||_________||||||||\n ///// \\\\\\\\\\\\ ///// \\\\\\\\\\ ||||||||---------||||||||\n ///// \\\\\\\\\\\\///// \\\\\\\\\\ ... |||||||| ||||||||\n// ````` ````````` ```` ```````` ````````\n\n/// Plz Don't Copy\n/// ^__^\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define pb push_back\n#define pp pop_back\n#define mp make_pair\n#define fr first\n#define sc second\n#define fo front()\n#define FIX(x) cout.precision(x)\n#define sz(x) ((int)(x).size())\n#define smax(x,y) ((x)=max((x),(y)))\n#define smin(x,y) ((x)=min((x),(y)))\n#define all(x) (x).begin(),(x).end()\n#define mem(x) memset(x,0,sizeof(x))\n#define connect(z,x,y) z[x].pb(y),z[y].pb(x)\n#define _ ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);\ntypedef long long int ll;\ntypedef pair pii;\ntypedef pair pll;\n\nconst ll N = 1e6+85;\nconst ll M = 4e3+85;\nconst ll mod = 1e9+7;\n\nint p[N];\nset st;\n\nint main()\n{_\n\tint n, m; scanf(\"%d %d\",&n,&m);\n\tfor(int i=1;n>=i;i++) p[i]=i;\n\tfor(int i=1; i<=m; i++){\n\t\tint x, y; scanf(\"%d %d\",&x,&y);\n\t\tst.insert(mp(min(x,y),max(x,y)));\n\t}\n\tint cnt=50;\n\twhile(cnt--){\n\t\trandom_shuffle(p+1,p+n+1);\n\t\tint can=0; p[n+1]= p[1];\n\t\tfor(int i=1; i<=n; i++)\n\t\t\tif (st.find(mp(min(p[i],p[i+1]),max(p[i],p[i+1])))==st.end()) can++;\n\t\t}\n\t\tif(can>=m)\n\t\t\tfor (int i=1; i<=n; i++)\n\t\t\t\tif (st.find(mp(min(p[i],p[i+1]),max(p[i],p[i+1])))==st.end()){\n\t\t\t\t\tprintf(\"%d%d\\n\",p[i],p[i+1]);\n\t\t\t\t\tm--;\n\t\t\t\t\tif(!m) return 0;\n\t\t\t\t}\n\t}\n\treturn cout<<-1,0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b3806b3e8171822eff1fc9cc1d471930", "src_uid": "c4c85cde8a5bb5fefa4eb68fc68657d5", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define DB(x) cout<<#x<<\"=\"< 0 && sh[y] > 0 && x != edge[y][1] && x != edge[y][2] && x != newedge[y][1] && x != newedge[y][2]) {\n\t\tansx[ansi] = x;\n\t\tansy[ansi++] = y;\n\t\tnewedge[x][sh[x]] = y;\n\t\tnewedge[y][sh[y]] = x;\n\t\tsh[x]--; sh[y]--;\n\t\tnm--;\n\t }\n\t c++;\n\t}\n\n\tif (nm == 0)\n\t{\n\t succ = true;\n\t break;\n\t}\n }\n if (succ) {\n\tfor (int i = 0; i < m; ++i)\n\t cout << ansx[i] << \" \" << ansy[i] << endl;\n }\n else {\n\tcout << -1 << endl;\n }\n \n}\n\nint main(int argc, char *argv[])\n{\n init();\n work();\n return 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "179e4359f7afc4abd2f4def165a75cae", "src_uid": "c4c85cde8a5bb5fefa4eb68fc68657d5", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "// God & me\n// Life is ruined and love is lost :'(\n// @Yazd\n#include \n#define pb push_back\n#define X first\n#define Y second\n#define random rand\nusing namespace std;\ntemplate bool smax(T &x,L y){ return x < y ? ( x = y, 1) : 0; }\ntemplate bool smin(T &x,L y){ return y < x ? ( x = y, 1) : 0; }\ntypedef long long ll;\ntypedef pair pii;\n\nconst int maxn = 1e5 + 17;\nint n, m, p[maxn], d[maxn];\npii e[maxn];\nset cur;\nbool bad(int v, int u){\n return v == u || d[v] == 2 || d[u] == 2 || binary_search(e, e + m, pii(minmax(v, u))) || cur.count(minmax(v, u));\n}\nmain(){\n ios::sync_with_stdio(0), cin.tie(0);\n srandom(time(0));\n cin >> n >> m;\n for(int i = 0; i < m; i++){\n\tcin >> e[i].X >> e[i].Y;\n\te[i] = minmax(e[i].X, e[i].Y);\n }\n sort(e, e + m);\n if(n < 7){\n\tiota(p, p + n, 1);\n\tdo{\n\t bool ok = 1;\n\t for(int i = 0; ok && i < m; i++)\n\t\tif(binary_search(e, e + m, pii(minmax(p[i], p[(i + 1) % n]))))\n\t\t ok = 0;\n\t if(ok){\n\t\tfor(int i = 0; i < m; i++)\n\t\t cout << p[i] << ' ' << p[(i + 1) % n] << '\\n';\n\t\treturn 0;\n\t }\n\t} while(next_permutation(p, p + n));\n\treturn cout << \"-1\\n\", 0;\n }\n for(int i = 0; i < m; i++){\n\tint v = random() % n + 1, u = random() % n + 1;\n\twhile(bad(v, u))\n\t v = random() % n + 1, u = random() % n + 1;\n\tcout << v << ' ' << u << '\\n';\n\td[v]++, d[u] ++;\n\tcur.insert(minmax(v, u));\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "135a70aa6246829290d2a61da2c4c302", "src_uid": "c4c85cde8a5bb5fefa4eb68fc68657d5", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include \n\nusing namespace std;\n\nint n, totalSum, size;\nint res[20], a[20], g[20];\nbool mark[20];\nint sum;\nint n2;\n\ninline void check()\n{\n for (int i = 0; i < n2; i++)\n {\n cout << res[i] << \" \";\n if (i % n == n - 1)\n cout << endl;\n }\n exit(0);\n}\n\nvoid backTrack(int x)\n{\n if(x == 3 && res[2] > res[1])\n return;\n if(x == 3)\n {\n sum = res[0] + res[1] + res[2];\n bool flag = false;\n int h;\n for(int i = 0; i < 16; i++)\n if(!mark[i] && totalSum == sum + a[i])\n {\n mark[i] = true;\n h = i;\n res[3] = a[i];\n flag = true;\n break;\n }\n if(!flag)\n return;\n else\n {\n backTrack(x + 2);\n mark[h] = false;\n return;\n }\n }\n else if(x == 4 && res[n - 1] > res[0])\n return;\n else if(x == 7)\n {\n sum = res[4] + res[5] + res[6];\n bool flag = false;\n int h;\n for(int i = 0; i < 16; i++)\n if(!mark[i] && totalSum == sum + a[i])\n {\n mark[i] = true;\n h = i;\n res[7] = a[i];\n flag = true;\n break;\n }\n if(!flag)\n return;\n else\n {\n backTrack(x + 2);\n mark[h] = false;\n return;\n }\n }\n else if(x > 0 && x % 4 == 0)\n {\n sum = 0;\n for (int i = 0; i < 4; i++)\n sum += res[x - 4 + i];\n if (sum != totalSum)\n return;\n }\n if(x == 12)\n {\n int in = 0;\n for(int j = 0; j < 4; j++)\n {\n sum = res[j] + res[j + 4] + res[j + 8];\n bool flag = false;\n for(int i = 0; i < 16; i++)\n if(!mark[i] && totalSum == sum + a[i])\n {\n mark[i] = true;\n g[in++] = i;\n res[j + 12] = a[i];\n flag = true;\n break;\n }\n if(!flag)\n {\n for(int i = 0; i < in; i++)\n mark[g[i]] = false;\n return;\n }\n }\n sum = 0;\n for (int i = 3; i < 15; i += 3)\n sum += res[i];\n if (sum != totalSum)\n {\n for(int i = 0; i < in; i++)\n mark[g[i]] = false;\n return;\n }\n sum = 0;\n for (int i = 0; i < n2; i += n + 1)\n sum += res[i];\n if (sum != totalSum)\n {\n for(int i = 0; i < in; i++)\n mark[g[i]] = false;\n return;\n }\n check();\n }\n for (int i = 0; i < 16; i++)\n if (!mark[i])\n {\n mark[i] = true;\n res[x] = a[i];\n backTrack(x + 1);\n mark[i] = false;\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "afdba7f77314ace38c9fe74523147950", "src_uid": "7c806fb163aaf23e1eef3e6570aea436", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\n#define mp make_pair\n#define x first\n#define y second\n\nusing namespace std ;\n\ntypedef long long LL ;\n\nint n, s ;\nint q[20], path[4][4], pow2[1 << 20] ;\n\nint lowbit (int x)\n{\n return x & (-x) ;\n}\n\nbool check (int x, int y)\n{\n if (y == n - 1)\n {\n int ss = 0 ;\n for (int i = 0; i < n; i ++ ) ss += path[x][i] ;\n if (ss != s) return 0 ;\n }\n if (x == n - 1)\n {\n int ss = 0 ;\n for (int i = 0; i < n; i ++ ) ss += path[i][y] ;\n if (ss != s) return 0 ;\n }\n if (x == n - 1 && y == 0)\n {\n int ss = 0 ;\n for (int i = 0; i < n; i ++ ) ss += path[i][n - i - 1] ;\n if (ss != s) return 0 ;\n }\n if (x == n - 1 && y == n - 1)\n {\n int ss = 0 ;\n for (int i = 0; i < n; i ++ ) ss += path[i][i] ;\n if (ss != s) return 0 ;\n }\n return 1 ;\n}\n\nbool dfs (int x, int y, int state)\n{\n if (y == n) x ++, y = 0 ;\n if (x == n) return 1 ;\n for (int i = state, t; i; i -= lowbit (i))\n {\n t = lowbit (i) ;\n path[x][y] = q[pow2 (t)] ;\n if (check (x, y) && dfs (x, y + 1, state - t)) return 1 ;\n }\n return 0 ;\n}\n\nint main ()\n{\n for (int i = 0; i < 18; i ++ ) pow2[1 << i] = i ;\n scanf (\"%d\", &n) ;\n for (int i = 0; i < n * n; i ++ ) scanf (\"%d\", &q[i]), s += q[i] ;\n s /= n ;\n dfs (0, 0, (1 << n * n) - 1) ;\n printf (\"%d\\n\", s) ;\n for (int i = 0; i < n; i ++ )\n {\n for (int j = 0; j < n; j ++ )\n printf (\"%d \", path[i][j]) ;\n puts (\"\") ;\n }\n return 0 ;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cda43d30d6521e1184dfeb51a03cdf50", "src_uid": "7c806fb163aaf23e1eef3e6570aea436", "difficulty": 1900.0} {"lang": "MS C++", "source_code": "#define _CRT_SECURE_NO_DEPRECATE\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include \n#include\n#include\n#include\n\n#define all(v) v.begin(),v.end()\n#define mpair make_pair\n\nusing namespace std;\ntypedef long double ld;\nconst ld epsilon = 1e-9;\ntypedef long long ll;\n\nint mat[16];\nvoid solveSmall(int n)\n{\n\tint sz = n * n;\n\tsort(mat, mat + sz );\n\tint s = 0;\n\tfor (int i = 0; i < sz; i++)\n\t\ts += mat[i];\n\ts /= n;\n\tvector rows(n);\n\tvector cols(n);\n\tdo {\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\trows[i] = cols[i] = 0;\n\t\t}\n\t\tfor (int i = 0; i < sz; i++)\n\t\t{\n\t\t\trows[i / n] += mat[i];\n\t\t\tcols[i % n] += mat[i];\n\t\t}\n\t\tbool does = true;\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\tif (rows[i] != s || cols[i] != s)\n\t\t\t{\n\t\t\t\tdoes = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\t\n\t\t}\n\t\tif (!does)\n\t\t\tcontinue;\n\t\tint diag = 0, diag2 = 0;\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\tdiag += mat[i * n + i];\n\t\t\tdiag2 += mat[n - i - 1 + i * n];\n\t\t}\n\t\tif (diag != s || diag2 != s)\n\t\t\tcontinue;\n\t\tcout << s << endl;\n\t\tfor (int i = 0; i < sz; i++)\n\t\t{\n\t\t\tcout << mat[i];\n\t\t\tif (i % n != n - 1)\n\t\t\t\tcout << \" \";\n\t\t\telse \n\t\t\t\tcout << endl;\n\t\t}\n\t\treturn ;\n\t} while(next_permutation(mat, mat + sz));\n}\n\nint cnt[8];\nbool used[16];\nint te;\nbool getNextCnt()\n{\n\tint lim = 15;\n\tfor (int i = 7; i >= 0; i--)\n\t{\n\t\tused[cnt[i]] = false;\n\t\tfor (int j = cnt[i] + 1; j < 16; j++)\n\t\t{\n\t\t\tif (!used[j])\n\t\t\t{\n\t\t\t\tcnt[i] = j;\n\t\t\t\tte = 0;\n\t\t\t\tused[j] = true;\n\t\t\t\tfor (int k = i + 1; k < 8; k++)\n\t\t\t\t{\n\t\t\t\t\tfor (; te < 16; te++)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(!used[te])\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tused[te] = true;\n\t\t\t\t\t\t\tcnt[k] = te;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (int i = 0; i < 8; i++)\n\t\t\t\t\tcout << cnt[i] << \" \";\n\t\t\t\tcout << endl;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\treturn false;\n}\nvoid solve4()\n{\n\t\n\tfor (int i = 0; i < 8; i++)\n\t\tcnt[i] = i;\n\tint n = 4;\n\tint sz = n * n;\n\tint s = 0;\n\tfor (int i = 0; i < sz; i++)\n\t\ts += mat[i];\n\tfor (int i = 0; i rows(n);\n\tvector cols(n);\n\tint tmpMat[16];\n\tdo {\n\t\ta = mat[cnt[0]];\n\t\tx = mat[cnt[1]];\n\t\ty = mat[cnt[2]];\n\t\tc = mat[cnt[3]];\n\t\tz = mat[cnt[4]];\n\t\tt = mat[cnt[5]];\n\t\tq = mat[cnt[6]];\n\t\tb = mat[cnt[7]];\n\t\trealMat[2] = a;\n\t\trealMat[5] = x;\n\t\trealMat[6] = y;\n\t\trealMat[7] = c;\n\t\trealMat[9] = z;\n\t\trealMat[10] = t;\n\t\trealMat[12] = q;\n\t\trealMat[15] = b;\n\n\t\trealMat[3] = s - z - y - q;\n\t\trealMat[4] = s - x - y - c;\n\t\trealMat[14] = s - a - y- t;\n\t\trealMat[13] = s - q - b - realMat[14];\n\t\trealMat[1] = s - x - z - realMat[13];\n\t\trealMat[0] = s - realMat[1] - realMat[2] - realMat[3];\n\t\trealMat[8] = s - realMat[0] - realMat[4] - realMat[12];\n\t\trealMat[11] = s - realMat[10] - realMat[9] - realMat[8];\n\n\t\tmemcpy(tmpMat, realMat, sizeof(realMat));\n\t\tbool does = true;\n\t\tsort(tmpMat, tmpMat + sz);\n\t\tfor (int i = 0; i < sz; i++)\n\t\t{\n\t\t\tif(tmpMat[i] != mat[i])\n\t\t\t{\n\t\t\t\tdoes = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!does)\n\t\t\tcontinue;\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\trows[i] = cols[i] = 0;\n\t\t}\n\t\tfor (int i = 0; i < sz; i++)\n\t\t{\n\t\t\trows[i / n] += realMat[i];\n\t\t\tcols[i % n] += realMat[i];\n\t\t}\n\t\tbool does = true;\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\tif (rows[i] != s || cols[i] != s)\n\t\t\t{\n\t\t\t\tdoes = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\t\n\t\t}\n\t\tif (!does)\n\t\t\tcontinue;\n\t\tint diag = 0, diag2 = 0;\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\tdiag += realMat[i * n + i];\n\t\t\tdiag2 += realMat[n - i - 1 + i * n];\n\t\t}\n\t\tif (diag != s || diag2 != s)\n\t\t\tcontinue;\n\t\tcout << s << endl;\n\t\tfor (int i = 0; i < sz; i++)\n\t\t{\n\t\t\tcout << realMat[i];\n\t\t\tif (i % n != n - 1)\n\t\t\t\tcout << \" \";\n\t\t\telse \n\t\t\t\tcout << endl;\n\t\t}\n\t\treturn ;\n\t} while(getNextCnt());\n\n}\n\n\nint main()\n{\n\t//freopen(\"bobi.in\", \"r\", stdin);\n\t//freopen(\"bobi2.in\", \"w\", stdout);\n\tint n;\n\tcin >> n;\n\tfor (int i = 0; i < n * n; i++)\n\t{\n\t\tcin >> mat[i];\n\t}\n\tif (n <= 3)\n\t{\n\t\tsolveSmall(n);\n\t}\n\telse\n\t\tsolve4();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c6eef200dcad61e86f69b5374c811932", "src_uid": "7c806fb163aaf23e1eef3e6570aea436", "difficulty": 1900.0} {"lang": "GNU C++14", "source_code": "#include\n//#include \nusing namespace std;\n#include\n#include\n#include\n#include \n#include \n#define F first\n#define S second\n#define pii pair\n#define pb push_back\n#define int long long\n#define mp make_pair\n//setprecision\nint inf=1000*1000*1000+10;\nint const MAX=1000*100+10;\nint const MAX2=1000*1000+10;\nint const MAX3=5000+10;\nmapt;\nvectorin;\nint lim;\nint c=1,r=1;\nint sum[10][10];\nint sq[10][10];\nmapt2;\nmapt3;\nint a3[MAX];\nbool mark3[MAX];\nint s3;\nint ind3[10][10];\nvectorans3;\nint sum13[10];\nint sum23[10];\nint sumd3;\nint sumd23;\nint r3;\nvoid output()\n{\n cout<a)\n{\n int x=1;\n int y=1;\n bool tmp=true;\n for(int i=0;ir3)\n y=1,x++;\n }\n int n=s3;\n for(int i=1;i<=n;i++)\n {\n if(sum13[i]!=sum13[1] || sum23[i]!=sum13[1])\n tmp=false;\n }\n if(sum13[1]!=sumd3 || sum13[1]!=sumd23)\n tmp=false;\n if(tmp==true)\n {\n output();\n }\n for(int i=1;i<=s3;i++)\n sum13[i]=0,sum23[i]=0;\n sumd3=0;\n sumd23=0;\n}\nvoid jay(int n)\n{\n //cerr<t3[sq[i][j]])\n return;\n }\n }\n int a=sq[1][4]+sq[2][4]+sq[3][4]+sq[4][4];\n int d=sq[4][1]+sq[4][2]+sq[4][3]+sq[4][4];\n int b=0;\n for(int i=1;i<=4;i++)\n b+=sq[i][i];\n c=sq[1][4]+sq[2][3]+sq[3][2]+sq[4][1];\n if(c!=lim || b!=lim || a!=lim || d!=lim)\n return;\n cout<>n;\n lim=0;\n if(n!=4)\n {\n for(int i=1;i<=n*n;i++)\n {\n cin>>a3[i];\n }\n r3=n;\n s3=n;\n s3*=n;\n jay(s3);\n return 0;\n }\n\tfor(int i=1;i<=n;i++)\n {\n for(int j=1;j<=n;j++)\n {\n int x;\n cin>>x;\n lim+=x;\n if(t[x]==0)\n in.pb(x);\n t[x]++;\n t3[x]++;\n }\n }\n lim/=n;\n pick(1);\n cout<<-1;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7bdeca7e90bd561918bc6ecf0f3fca7f", "src_uid": "7c806fb163aaf23e1eef3e6570aea436", "difficulty": 1900.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \nusing namespace std;\nint a[100][100];\nint main()\n{ \n\tint r1,c1,r2,c2;\n\tint lad, slon, kral;\n\tcin>>r1>>c1>>r2>>c2;\n\tif(r1==r2 || c1==c2)\n\t{\n\t lad = 1;\n\t}\n\telse lad = 2;\n\tint x,y;\n\tx = abs(r1-r2);\n\ty = abs(c1-c2);\n\tkral = max(x,y)-min(x,y)+min(x,y);\n\tif(x==y) slon = 1;\n\telse\n\t{\n\t\ta[r1][c1] = 1;\n\t\tfor(int i=c1;i<=8;i+=2) a[r1][i] = 1;\n\t\tfor(int i=c1;i>=1;i-=2) a[r1][i] = 1;\n \t\tfor(int i=r1;i<=8;i++)\n \t\t{\n \t\t\tfor(int j=1;j<=8;j++)\n \t\t\t{\n \t\t\t\tif(a[i-1][j-1] || a[i-1][j+1])\n \t\t\t\t{\n \t\t\t\t \ta[i][j] = 1;\n \t\t\t\t}\n \t\t\t}\n \t\t}\n \t\tfor(int i=r1;i>=1;i--)\n \t\t{\n \t\t\tfor(int j=1;j<=8;j++)\n \t\t\t{\n \t\t\t\tif(a[i+1][j+1] || a[i+1][j-1])\n \t\t\t\t{\n \t\t\t\t \ta[i][j] = 1;\n \t\t\t\t}\n \t\t\t}\n \t\t}\n \t\tif(!a[r2][c2]) slon = 0;\n \t\telse slon = 2;\n\t}\n\tcout<\n#include \n\nusing namespace std;\n\nint abs(int x)\n{\n\treturn (x>0)?(x):(-x);\n}\nint max(int x,int y)\n{\n\treturn (x>y)?(x):(y);\n}\n\nint main()\n{\n\tint r1,c1,r2,c2,L,S,K;\n\tcin>>r1>>c1>>r2>>c2;\n\tif(r1==r2 || c1==c2)\n\t\tL=1;\n\telse\n\t\tL=2;\n\tif((r1+c1)%2 != (r2+c2)%2)\n\t\tS=0;\n\telse if((r2-r1)==(c2-c1) || (r1-r2)==(c2-c1))\n\t\tS=1;\n\telse\n\t\tS=2;\n\tK = max(abs(r2-r1),abs(c2-c1));\n\tcout<\n#include \n\nusing namespace std;\n\nint main(int argc, char** argv[])\n{\n int x1, x2, y1, y2;\n\n cin >> x1 >> y1 >> x2 >> y2;\n\n int difX = abs(x2 - x1);\n int difY = abs(y2 - y1);\n\n if ((x1 == x2) || (y1 == y2)) cout << \"1 \";\n else print(\"2 \");\n\n if (((x1 + y1) % 2) == ((x2 + y2) % 2)){\n if (difX == difY) print(\"1 \");\n else print(\"2 \");\n }\n else print(\"0 \");\n\n cout << max(difX, difY) << endl;\n return 0;\n}\n\nint print(char str[]){\n cout << str;\n}\n\nint println(char str[]){\n cout << str << endl;\n}\n\nint max(int x1, int x2){\n return (x1 > x2 ? x1 : x2);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e2f8259bee746341f3bb1a5ea04dfbba", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\nusing namespace std;\nint main() {\n\tint a, b, c, d;\n\t\n cin >> a >> b >> c >> d;\n if (a == c || b == d) cout << 1; else cout << 2;\n cout << \" \";\n if ((a + b) % 2 != (c + d) % 2) cout << 0; else {\n else if (a + b == c + d || a - d == c - b)\n cout << 2;\n else cout << 1;\n }\n cout << \" \";\n cout << max(abs(a - c), abs(b - d)) << endl;\n return 0;}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ff0ee1a23f43f5498138452d5a0a4cbb", "src_uid": "7dbf58806db185f0fe70c00b60973f4b", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n\n#define addMode(a, b)\\\n\t\t{\\\n\t\t\ta += (b);\\\n\t\t\tif (a >= M)\\\n\t\t\t\ta -= M;\\\n\t\t}\n\t\nusing namespace std;\n\nconst int N = 500;\nconst int M = 1000000009;\n\nbool term[N];\nint trans[N][4];\nint height[N];\nint suflink[N];\nint cnt;\n\nint dp[1010][410][12];\n\nvoid insert(char* seq, int n) \n{\n\tint cur = 0;\t\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tif (trans[cur][seq[i]] == 0)\n\t\t{\n\t\t\theight[++cnt] = i + 1;\n\t\t\ttrans[cur][seq[i]] = cnt;\n\t\t}\n\t\tcur = trans[cur][seq[i]];\t\n\t}\n\tterm[cur] = true;\n}\n\nvoid find_suflink()\n{\n\tqueue q;\t\n\n\tsuflink[0] = -1;\n\tq.push(0);\n\twhile (!q.empty())\n\t{\n\t\tint cur = q.front();\t\t\n\t\tq.pop();\n\n\t\tfor (int i = 0; i < 4; i++)\n\t\t{\n\t\t\tif (trans[cur][i])\n\t\t\t{\n\t\t\t\tint next = trans[cur][i];\n\t\t\t\tint suf = suflink[cur];\t\n\t\t\t\twhile (suf > 0 && !trans[suf][i])\n\t\t\t\t\tsuf = suflink[suf];\n\t\t\t\tsuflink[next] = suflink < 0 ? 0 : trans[suf][i];\n\t\t\t\tq.push(next);\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid find_fail()\n{\n\tqueue q;\t\n\tq.push(0);\t\n\twhile (!q.empty())\n\t{\n\t\tint cur = q.front();\n\t\tq.pop();\n\n\t\tfor (int i = 0; i < 4; i++)\n\t\t{\n\t\t\tif (!trans[cur][i])\n\t\t\t{\n\t\t\t\tint cand = cur; \n\t\t\t\twhile (cand > 0 && !trans[cand][i])\n\t\t\t\t\tcand = suflink[cand];\n\t\t\t\ttrans[cur][i] = trans[cand][i];\n\t\t\t}\n\t\t\telse q.push(trans[cur][i]);\n\t\t}\n\t}\n}\n\nint main()\n{\n\tint n, m;\n\tchar str[20];\n\tint maxlen = 0;\n\tcin>>n>>m;\n\twhile (m--)\n\t{\n\t\tscanf(\"%s\", str);\n\t\tint len = strlen(str);\n\t\tif (maxlen < len) maxlen = len;\n\t\tfor (int i = 0; i < len; i++)\n\t\t{\n\t\t\tswitch (str[i])\n\t\t\t{\n\t\t\t\tcase 'A': \n\t\t\t\t\t\tstr[i] = 0;\n\t\t\t\t\t\tbreak;\n\t\t\t\tcase 'C': \n\t\t\t\t\t\tstr[i] = 1;\n\t\t\t\t\t\tbreak;\n\t\t\t\tcase 'G': \n\t\t\t\t\t\tstr[i] = 2;\n\t\t\t\t\t\tbreak;\n\t\t\t\tcase 'T': \n\t\t\t\t\t\tstr[i] = 3;\n\t\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tinsert(str, len);\n\t}\n\n\tfind_suflink();\n\tfind_fail();\n\n\t/*printf(\"cnt = %d\\n\", cnt);\n\tfor (int i = 0; i <= cnt; i++)\n\t{\n\t\tprintf(\"suflink[%d] = %d\\n\", i, suflink[i]);\n\t\tfor (int j = 0; j < 4; j++)\t\n\t\t\tprintf(\"trans[%d][%d] = %d, \", i, j, trans[i][j]);\n\t\tprintf(\"\\n\");\n\t}*/\n\n\tfor (int j = 0; j <= cnt; j++)\n\t\tdp[n][j][0] = 1;\n\tfor (int i = n - 1; i >= 0; i--)\n\t\tfor (int j = 0; j <= cnt; j++)\n\t\t\tfor (int k = 0; k < maxlen; k++)\n\t\t\t{\n\t\t\t\tdp[i][j][k] = 0;\n\t\t\t\tif (height[j] < k) continue;\n\t\t\t\tfor (int d = 0; d < 4; d++)\n\t\t\t\t{\n\t\t\t\t\tint nj = trans[j][d];\n\t\t\t\t\tint nk = k + 1;\n\t\t\t\t\tif (term[nj])\n\t\t\t\t\t\tnk = 0;\n\t\t\t\t\tdp[i][j][k] += dp[i + 1][nj][nk];\n\t\t\t\t\tif (dp[i][j][k] >= M)\n\t\t\t\t\t\tdp[i][j][k] -= M;\n\t\t\t\t}\n\t\t\t}\n\tprintf(\"%d\\n\", dp[0][0][0]);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "966b520d8a3aa2d915a168f7c43c1308", "src_uid": "3f053c07deaac55c2c51df6147080340", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nconst int modm = 1000000009;\nconst int MaXN = 128;\nconst int maxk = 4;\n\nstruct trieNode\n{\n int next[maxk], fail;\n int danger;\n void init()\n {\n fail = -1; \n danger = 0;\n for (int i = 0; i < maxk; ++i) next[i] = -1;\n }\n}t[MaXN];\nint root, top;\n\nvoid init()\n{\n root = 0, top = 1; \n t[root].init(); \n} \n\nint getid(char ch)\n{\n switch(ch)\n {\n case 'A': return 0;\n case 'G': return 1;\n case 'C': return 2;\n case 'T': return 3;\n }\n}\n\nvoid trieins(char *s)\n{\n int i = 0;\n int p = root;\n while(s[i])\n {\n int idx = getid(s[i]);\n if (t[p].next[idx] == -1)\n {\n t[top].init();\n t[p].next[idx] = top++;\n }\n p = t[p].next[idx];\n i++;\n }\n t[p].danger = strlen(s);\n}\n\nvoid build_ac_automation()\n{\n int cur, tmp;\n queue q;\n t[root].fail = root;\n t[root].danger = 0;\n q.push(root);\n while (q.empty() == 0)\n {\n cur = q.front(); q.pop();\n for (int i = 0; i < maxk; i+2+)\n {\n if (t[cur].next[i] != -1)\n {\n tmp = t[cur].next[i];\n if (cur == root) t[tmp].fail = root;\n else\n {\n t[tmp].fail = t[t[cur].fail].next[i];\n t[tmp].danger = max(t[tmp].danger,t[t[tmp].fail].danger);\n }\n q.push(tmp);\n }\n else\n {\n if (cur == root) t[cur].next[i] = root;\n else t[cur].next[i] = t[t[cur].fail].next[i];\n }\n }\n }\n}\n\nlong long dp[1010][128][11];\nint n, m;\nint main()\n{\n memset(dp,0,sizeof(dp));\n cin >> n >> m;\n init();\n for (int i = 0; i < m; i++)\n {\n char str[20];\n cin >> str;\n trieins(str);\n }\n build_ac_automation();\n dp[0][0][0] = 1;\n for (int i = 0; i < n; i++)\n {\n for (int j = 0; j < top; j++)\n {\n for (int k = 0; k <= 10; k++)\n {\n if (dp[i][j][k] == 0) continue;\n for (int tt = 0; tt < maxk; tt++)\n {\n int aa = t[j].next[tt];\n if (t[aa].danger > k)\n {\n dp[i + 1][aa][0] += dp1[i][j][k];\n dp[i + 1][aa][0] %= modm;\n }\n else if (k + 1 <= 10)\n {\n dp[i + 1][aa][k+1] += dp[i][j][k];\n dp[i + 1][aa][k+1] %= modm;\n }\n }\n }\n }\n }\n long long ans = 0;\n for (int i = 0; i < top; i++)\n {\n ans = ans + dp[n][i][0];\n ans %= modm;\n }\n cout << ans % modm << endl;\n// system(\"pause\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e11a9a273a2cce1f3c29690631428751", "src_uid": "3f053c07deaac55c2c51df6147080340", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "main.c", "lang_cluster": "C++", "compilation_error": true, "code_uid": "08c713cf9ae6e6b490340d97215e23bd", "src_uid": "3f053c07deaac55c2c51df6147080340", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nclass SS {\nprivate:\n\tstatic const int offset = 26;\npublic:\n\tint w = 0;\n\t\n\tSS(const string s) {\n\t\tfor (const char &c : s) {\n\t\t\tw <<= 2;\n\t\t\tswitch (c) {\n\t\t\tcase 'A': w |= 0; break;\n\t\t\tcase 'C': w |= 1; break;\n\t\t\tcase 'T': w |= 2; break;\n\t\t\tcase 'G': w |= 3; break;\n\t\t\t}\n\t\t}\n\t\tw |= s.length() << offset;\n\t}\n\n\tSS(const int w) : w(w) {}\n\n\tint len() const {\n\t\treturn w >> offset;\n\t}\n\n\tint containsIdx(const SS &o) const {\n\t\tconst int limit = (len() - o.len()) << 1;\n\t\tconst int mask = (1 << (o.len() << 1)) - 1;\n\t\tfor (int i = 0; i <= limit; i += 2) {\n\t\t\tconst int xor = (w >> i) ^ o.w;\n\t\t\tif (!(xor & mask))\n\t\t\t\treturn i >> 1;\n\t\t}\n\t\treturn -1;\n\t}\n\n\tbool isPrefixOf(const SS &o) const {\n\t\tif (len() > o.len())\n\t\t\treturn false;\n\t\tconst int mask = (1 << (len() << 1)) - 1;\n\t\tconst int diff = (o.len() - len()) << 1;\n\t\tconst int xor = (o.w >> diff) ^ w;\n\t\treturn !(xor & mask);\n\t}\n\n\toperator int() const {\n\t\treturn w;\n\t}\n\n\tSS substr1() const {\n\t\tconst int l = len() - 1; // 1\n\t\tconst int mask = ~(3 << (l << 1)) & ~(-1 << offset);\n\t\treturn (l << offset) | (w & mask);\n\t}\n\n\tSS operator+(const char c) const {\n\t\tconst int l = len() + 1;\n\t\tconst int mask = ~(-1 << offset);\n\t\treturn (l << offset) | ((w << 2 | c) & mask);\n\t}\n\n\tfriend ostream &operator<<(ostream &out, const SS &ss) {\n\t\tfor (int i = (ss.len() - 1) << 1; i >= 0; i -= 2) {\n\t\t\tswitch ((ss.w >> i) & 3) {\n\t\t\tcase 0: out << 'A'; break;\n\t\t\tcase 1: out << 'C'; break;\n\t\t\tcase 2: out << 'T'; break;\n\t\t\tcase 3: out << 'G'; break;\n\t\t\t}\n\t\t}\n\t\treturn out;\n\t}\n};\n\nstruct Dict {\n\tvector words;\n} dict;\n\nconst int mod = 1000000009;\n\nmap dp[1001][11];\n\nint f(const int n, const int i, const SS ss) {\n\t\n\tauto it = dp[n][i].find(ss);\n\tif (it != dp[n][i].end())\n\t\treturn it->second;\n\n\t//cout << n << ' ' << i << ' ' << ss << '\\n';\n\t//static int noCalls = 0;\n\t//if (++noCalls > 50)\n\t\t//exit(0);\n\n\tif (n == 0 && i == ss.len())\n\t\treturn dp[n][i][ss] = 1;\n\n\tfor (auto &&w : dict.words)\n\t\tif (w.isPrefixOf(ss) && w.len() > i)\n\t\t\treturn dp[n][i][ss] = f(n, i + 1, ss);\n\n\tif (n == 0)\n\t\treturn dp[n][i][ss] = i ? f(n, i - 1, ss.substr1()) : 0;\n\t\n\n\tint ans = 0;\n\tif (ss.len() == 10) {\n\t\tif (i == 0)\n\t\t\treturn dp[n][i][ss] = 0;\n\t\tSS ss1 = ss.substr1();\n\t\tfor (char c = 0; c < 4; ++c)\n\t\t\tans = (ans + f(n - 1, i - 1, ss1 + c)) % mod;\n\t} else\n\t\tfor (char c = 0; c < 4; ++c)\n\t\t\tans = (ans + f(n - 1, i, ss + c)) % mod;\n\n\treturn dp[n][i][ss] = ans;\n}\n\nint main() {\n\tstd::ios::sync_with_stdio(false);\n\tstd::cin.tie(nullptr);\n\tstd::cout.tie(nullptr);\n\n\tint n, m;\n\tcin >> n >> m;\n\n\tfor (int i = 0; i < m; ++i) {\n\t\tstring s;\n\t\tcin >> s;\n\t\tdict.words.emplace_back(s);\n\t}\n\n\tcout << f(n, 0, 0);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2d2cb7920d2ca959a03b5374ccb1d0fb", "src_uid": "3f053c07deaac55c2c51df6147080340", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{ int r,y,b;\n cin>>y>>b>>r;\nint x=min(y,b);\nx=min(x,r);\ncout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\n\nusing namespace std;\n\n#define int long long\n#define rep(i,n) for(int i = 0; i < (n); i++)\n#define INF (long long)(1e18)\n#define MOD (int)(1e9+7)\n\n#define yn(f) ((f)?\"Yes\":\"No\")\n#define YN(f) ((f)?\"YES\":\"NO\")\n\n\nset ans;\nmap mp;\nvector ss;\nint n, t, size;\n\n\n// int fv(int i){\n\t // int xx = (i)%n;\n\t // int funv = xx+1;\n\t// while(xx){\n\t\t// xx = (xx+i)%n;\n\t\t// funv += xx+1;\n\t// }\n\t//// cout<>n;\n\t\n\tt = n;\n\t\n\tfor(int i = 2; i*i <= t; i++){\n\t\tif(t%i==0)ss.push_back(i);\n\t\twhile(t%i==0){\n\t\t\tmp[i]++;\n\t\t\tt /= i;\n\t\t}\n\t}\n\t\n\t// if(t != 1) mp[t]++,ss.push_back(t);\n\t\n\tsize = mp.size();\n\t\n\t// solve((int)0,(int)1);\n\t\n\t\n\t// for(int y : ans){\n\t\t// cout<<(y==1?\"\":\" \")<::iterator it = ans.begin(); \n\tfor(int i = 0; i < ans.size(); i++){\n\t\tif(i)cout<<\" \";\n\t\tcout<<*it;\n\t\tit++;\n\t}\n\tcout<\nusing namespace std;\n#define ll long long int\nint main()\n{\n\tll y,b,r,count=0,l=999;\n\tcin>>y>>b>>r;\n\tif(y\nusing namespace std;\n\nmain ()\n{int y,b,r;\nvector v;\ncin>>y>>b>>r;\nif((y==b)&&(b==r))\n {\n cout<<(3*y)-3;\n return 0;\n }\n\nv.push_back(y);v.push_back(b);v.push_back(r);\n\nsort(v.begin(),v.end());\n\nif((v[0]==y)&&(v[2]==r)&&(b!=r)\ncout<<(3*y)+3;\n\nif((v[0]==y)&&(v[2]==b)&&(b!=r)\ncout<<(3*y);\n\nif((v[0]==y)&&(b==r))\n{if(b-y>=2)\n cout<<(3*y)+3;\n}\nelse\n cout<<(3*y);\n\nif(v[0]==b)\ncout<<(3*b);\nif(v[0]==r)\ncout<<(3*r)-3;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "99061db25b682b8353ba2581e0de2df8", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nint a[100];\nint main()\n{\n int n;\n scanf(\"%d\",&n);\n if(n==0)\n {\n printf(\"0\\n\");\n break;\n }\n int i,k=0;\n while(n>0)\n {\n k++;\n for(i=1;i<=n;i++)\n {\n if((i+1)*i/2==n)\n {\n n=0;\n i++;\n break;\n }\n else if((i+1)*i/2>n)\n {\n n-=(i)*(i-1)/2;\n break;\n }\n }\n int j;\n for(j=1;j<=i;j++)\n {\n printf(\"%c\",'a'+k-1);\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "90bddd1a74d782610e3a2270cb3dd823", "src_uid": "b991c064562704b6106a6ff2a297e64a", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include \n#define int long long int\nusing namespace std;\n\nconst int MAX = 1e6 + 6;\n\nint main(){\n\tios::sync_with_stdio(false);\n\tcin.tie(0); cout.tie(0);\n\n\tint K; cin >> K;\n\n\tfor(int i=0; i<26; ++i){\n\n\t\tif(K == 0) break;\n\t\tint low = 0, high = K, c = 0;\n\t\twhile(low < high){\n\t\t\tint mid = (low + high) >> 1;\n\t\t\tint frq = (mid * (mid - 1)) >> 1;\n\t\t\tif(frq > K) high = mid;\n\t\t\telse if(frq < K) low = mid + 1;\n\t\t}\n\t\tif(low * (low - 1) > 2 * K) --low;\n\t\t// for(int j=low - 50; j<=low + 50; ++j){\n\t\t// \tif(j <= 0) continue;\n\t\t// \tint frq = (j * (j - 1)) >> 1;\n\t\t// \tif(frq > K){\n\t\t// \t\tc = j - 1;\n\t\t// \t\tbreak;\n\t\t// \t}\n\t\t// }\n\t\tfor(int j=0; j> 1);\n\t}\n\tcout << endl;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "59af5cf9e7200954d5f4488cfb91d660", "src_uid": "b991c064562704b6106a6ff2a297e64a", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "codeforces!", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7c036ae86d23d7aeddb06636979d9d92", "src_uid": "b991c064562704b6106a6ff2a297e64a", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define ll long long\n#define f(i,n) for(int i=0;i d;\nint main()\n{\n\tint n;\n\tcin>>n;\n\tif(n==0)\n\t{\n\t\tcout<n)\n\tk=i-1;\n\telse\n\tk=i;\n\t\n\twhile(n>0)\n\t{\n\t\t//cout<n)\n\t\t\t{\n\t\t\t\t//k=mid;\n\t\t\t\tr=mid-1;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tk=mid;\n\t\t\t\tl=mid+1;\n\t\t\t}\n\t\t}\n\t\t\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "564674c0628469382c5ff10ed215d423", "src_uid": "b991c064562704b6106a6ff2a297e64a", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "/*\nID: amirnas1\nPROG: cowtour\nLANG: C++\n*/\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n/*\nvector prim;\nstring s;\nvector dp;\n\nint main()\n{\n\n\tifstream cin;\n\tcin.open(\"prefix.in\");\n\tofstream cout;\n\tcout.open(\"prefix.out\");\n\t\n\tstring p;\n\ts = \"\";\n\tcin>>p;\n\twhile (p!= \".\")\n\t{\n\t\tprim.push_back(p);\n\t\tcin>>p;\n\t}\n\tcin.ignore();\n\tstring l;\n\twhile (getline(cin,l)) s += l;\n\tdp = vector (s.size()+1, -1);\n\tfor (int i = s.size(); i>= 0; i--)\n\t{\n\t\tif (i == s.size()) dp[i] = i;\n\t\telse\n\t\t{\n\t\tint m = i;\n\t\t\tfor (int j = 0; j < prim.size(); j++)\n\t\t\t{\n\t\t\t\tif (i+prim[j].size() <= s.size()) if (s.substr(i,prim[j].size()) == prim[j]) m = max(m, dp[i+prim[j].size()]);\n\t\t\t}\n\t\t\tdp[i] = m;\n\t\t}\n\t}\n\tcout<=0) return a%m;\n\telse\n\t{\n\t\treturn (a+m)%m;\n\t}\n}\nlong long solve(int n, int k, int f)\n{\n\tif (n==0 && k==0) return 1;\n\tif (n == 0) return 1;\n\tif (k <= 0) return 0;\n\tif (n == 1) return 1;\n\tif (dp[n][k][f] != -1) return dp[n][k][f];\n\tint a = n-1;\n\tlong long s = 0;\n\tlong long r;\n\tfor (int i = 1; i < a; i++)\n\t{\n\t\tr = solve(i,k-1, 0) * solve(a-i, k-1, 0);\n\t\tif (f) r -= (solve(i,k-2, 0) * solve(a-i, k-2,0));\n\t\ts += r;\n\t\ts = mod(s,9901);\n\t}\n\treturn dp[n][k][f] = s;\n}\n\nint main()\n{\n\t\n\tifstream cin;\n\tcin.open(\"nocows.in\");\n\tofstream cout;\n\tcout.open(\"nocows.out\");\n\t\n\tint n, k;\n\tcin>>n>>k;\n\tfor (int i=0; i<201; i++)\n\t{\n\t\tfor (int j = 0; j < 101; j++)\n\t\t{\n\t\t\t\n\t\t\tdp[i][j][0] = dp[i][j][1] = -1;\n\t\t}\n\t}\n\tcout<>n>>m;\n\tvector f(m);\n\tfor (int i = 0; i < m; i++)\n\t{\n\t\tcin>>f[i];\n\t}\n\tsort(f.begin(), f.end());\n\tint r = 10000;\n\tfor (int i = 0; i+n-1 < m; i++ )\n\t{\n\t\tif (f[i+n-1] - f[i] < r) r = f[i+n-1] - f[i];\n\t}\n\tcout<>a>>b>>c>>d;\n\tint ab = gcd(a,b);\n\tint cd = gcd(c,d);\n\ta /=ab;\n\tb /= ab;\n\tc /= cd;\n\td /= cd;\n\tif ((double)a/(double)c < (double)b/(double)d)\n\t{\n\t\tint ra = d*a;\n\t\tint rb = b*c;\n\t\tint gab = gcd(ra,rb);\n\t\tint resa = rb/gab - ra/gab;\n\t\tint resb = rb/gab;\n\t\tint gres = gcd(resa,resb);\n\n\t\tcout< 0)\n\t{\n\t\treturn a%b;\n\t}\n\telse return (a+b)%b;\n}\n\nint main()\n{\n\tlong long n,m,k;\n\tcin>>n>>m>>k;\n\tif (n - (n-m)*k > 0)\n\t{\n\t\tlong long r = pow2(((n - (n-m)*k)/k)+1,1000000009) - 2;\n\t\tr = (r*k)%1000000009;\n\t\tlong long r2 = (n-m)*(k-1) + ((n - (n-m)*k)%k);\n\t\tcout< st;\nvector req;\nvector rem;\nvector num;\nvector res;\n\nvoid pr(long long a, bool p)\n{\n\tif (a ==1) return;\n\tif (a%2 == 0)\n\t{\n\t\tif (a != 2 || p) res.push_back(2);\n\t\tpr(a/2, true);\n\t\treturn;\n\t}\n\tfor (long long i = 3; i*i <= a; i+=2)\n\t{\n\t\tif (a%i==0)\n\t\t{\n\t\t\tres.push_back(i);\n\t\t\tpr(a/i,true);\n\t\t\treturn;\n\t\t}\n\t}\n\tif (p)\n\t\tres.push_back(a);\n}\n\nint dfs(int i, bool add)\n{\n\tif (i >= num.size()) return 0;\n\tres.clear();\n\tif (rem[i] == num[i])\n\t\tpr(rem[i],false);\n\telse\n\t\tpr(rem[i],true);\n\tint result = res.size()+1;\n\tint m;\n\tif (i == num.size()-1)\n\t\tm = 0;\n\telse if (add)\n\t\tm = dfs(i+1,true);\n\telse\n\t\tm = dfs(i+1,true) + 1;\n\tfor (int j = i+1; j < num.size(); j++)\n\t{\n\t\tif (rem[j]%num[i] ==0)\n\t\t{\n\t\t\trem[j] /=num[i];\n\t\t\tm = min(dfs(i+1,add),m);\n\t\t\trem[j] *= num[i];\n\t\t}\n\t}\n\treturn result+m;\n}\n\nint main()\n{\n\tint n;\n\tcin>>n;\n\tst = vector (n,0);\n\treq = vector (n,1);\n\trem = vector (n,1);\n\tnum = vector (n);\n\tfor (int i =0 ; i < n; i++)\n\t{\n\t\tcin>>num[i];\n\t\trem[i] = num[i];\n\t}\n\tsort(num.begin(), num.end());\n\tsort(rem.begin(), rem.end());\n\tint result = 0;\n\t\n\tresult = dfs(0,false);\n\tcout< d1;\nvector > d3;\nvector d2;\nvector > g;\nvector mark;\nvector tk;\nint dis1(int i,int p)\n{\n\ttk[i] = true;\n\tint r = -1000000;\n\t\n\tint m1 = 0,m2 = -1000000;\n\tfor (int j=0; j < g[i].size(); j++)\n\t{\n\t\tif (!tk[g[i][j]])\n\t\tif (r < dis1(g[i][j],i))\n\t\t{\n\t\t\tr = d1[(g[i][j])];\n\t\t\tm1 = g[i][j];\n\t\t}\n\t}\n\tint v = -1000000;\n\tfor (int j=0; j < g[i].size(); j++)\n\t{\n\t\tif (v < d1[(g[i][j])] && (g[i][j]) != m1 && g[i][j] != p)\n\t\t{\n\t\t\tv = d1[(g[i][j])];\n\t\t\tm2 = g[i][j];\n\t\t}\n\t}\n\td3[i].first = m1;\n\td3[i].second = m2;\n\tif (r < 0)\n\t{\n\t\tif (mark[i]) return d1[i] = 0;\n\t\telse return d1[i] = r;\n\t}\n\treturn d1[i] = r+1;\n}\n\nvoid dis2(int i,int p)\n{\n\ttk[i] = true;\n\tif (p == -1)\n\t{\n\t\tif (mark[0])\n\t\t{\n\t\t\td2[0] = 0;\n\t\t}\n\t\telse\n\t\t\td2[0] = -10000000;\n\t}\n\telse\n\t{\n\t\tint r = d2[p]+1;\n\t\tif (d3[p].first == i)\n\t\t{\n\t\t\tif (d3[p].second >= 0)\n\t\t\t\tr = max(d1[d3[p].second]+2,r);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tr = max(d1[d3[p].first]+2,r);\n\t\t}\n\t\td2[i] = r;\n\t\tif (r < 0)\n\t\t{\n\t\t\tif (mark[i])\n\t\t\t\td2[i] = 0;\n\t\t\telse\n\t\t\t\td2[i] = r;\n\t\t}\n\t}\n\tfor (int j=0; j < g[i].size(); j++)\n\t{\n\t\tif(!tk[g[i][j]])\n\t\t\tdis2(g[i][j],i);\n\t}\n}\n\n\n\nint bfs(int i, int d)\n{\n\tint res = 0;\n\tqueue > q;\n\tq.push(make_pair(i,0));\n\tvector tk(g.size(),false);\n\twhile (!q.empty())\n\t{\n\t\tpair c = q.front();\n\t\tq.pop();\n\t\tif (tk[c.first])\n\t\t\tcontinue;\n\t\tres++;\n\t\ttk[c.first] = true;\n\t\tif (c.second < d)\n\t\t{\n\t\t\tfor (int j=0; j < g[c.first].size(); j++)\n\t\t\t{\n\t\t\t\t//cout<>n>>m>>d;\n\t\n\td1 = vector (n,-1000000);\n\td2 = vector (n,-1000000);\n\td3 = vector > (n, make_pair(-1000000,-1000000));\n\tmark = vector (n,false);\n\ttk = vector (n,false);\n\tg = vector > (n);\n\tint a;\n\tfor (int i=0; i < m; i++)\n\t{\n\t\tcin>>a;\n\t\tmark[a-1] = true;\n\t}\n\tint b;\n\tfor (int i = 0; i < n-1; i++)\n\t{\n\t\tcin>>a>>b;\n\t\tg[a-1].push_back(b-1);\n\t\tg[b-1].push_back(a-1);\n\t}\n\tif (m > 1)\n\t{\ntk = vector (n,false);\n\tdis1(0,-1);\ntk = vector (n,false);\n\tdis2(0,-1);\n\t}\n\tint res = 0;\n\tif (m == 1)\n\t{\n\tfor (int i=0; i < n; i++)\n\t{\n\t\tif (mark[i])\n\t\t{\n\t\t\tres = bfs(i,d);\n\t\t\tbreak;\n\t\t}\n\t}\n\t}\n\telse\n\t{\n\tfor (int i=0; i < n; i++)\n\t{\n\t//\tcout< s1;\n\t\tvector s2;\n\t\tint c = 1;\n\t\tfor (int j =0 ; j < n-1; j++)\n\t\t{\n\t\t\tif (op[j] == ' ')\n\t\t\t{\n\t\t\t\tc *= 10;\n\t\t\t\tc += j+2;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\ts2.push_back(c);\n\t\t\t\ts1.push_back(op[j]);\n\t\t\t\tc= j+2;\n\t\t\t}\n\t\t}\n\t\ts2.push_back(c);\n\t\tint a,b;\n\t\tr = s2[0];\n\t\tfor (int j = 0; j < s1.size(); j++)\n\t\t{\n\t\t\tif (s1[j] == '+')\n\t\t\t{\n\t\t\t\tr += s2[j+1];\n\t\t\t}\n\t\t\telse\n\t\t\t\tr -= s2[j+1];\n\t\t}\n\t\tif (r == 0)\n\t\t{\n\t\t\tfout<<1;\n\t\t\tfor (int j = 0; j < n-1; j++)\n\t\t\t{\n\t\t\t\tfout<>n;\n\tfor (int i = 0; i < n-1; i++)\n\t{\n\t\top += '.';\n\t}\n\tsolve(0);\n\n}\n\n\nvector c;\nvector > dp;\nlong long solve(int n,int i)\n{\n\tif (n < 0) return 0;\n\tif (n == 0) return 1;\n\tif (i >= c.size()) return 0;\n\tif (dp[n][i] != -1) return dp[n][i];\n\tif (i == c.size()-1)\n\t{\n\t\tif (n%c[i] == 0) return dp[n][i] = 1;\n\t\telse return dp[n][i] = 0;\n\t}\n\tlong long r = 0;\n\tfor (int j = 0; j <= n/c[i]; j++)\n\t{\n\t\tr += solve(n - j*c[i], i+1);\n\t}\n\treturn dp[n][i] = r;\n}\n\nint main()\n{\n\t\n\tifstream cin;\n\tcin.open(\"money.in\");\n\tofstream cout;\n\tcout.open(\"money.out\");\n\t\n\tint v,n;\n\tcin>>v>>n;\n\tdp = vector >(n+1,vector(v,-1));\n\tc = vector(v);\n\tfor (int i=0; i < v; i++)\n\t{\n\t\tcin>>c[i];\n\t}\n\tsort(c.begin(), c.end());\n\treverse(c.begin(), c.end());\n\tlong long r = solve(n,0);\n\tcout<= 0 ? dp[n - v[m]] : 0);\n \n printf(\"%lld\\n\", dp[N]);\n return 0;\n}\n\n\nint g[100][100];\n\nvector res;\n\nvoid solve(int i)\n{\n\tbool ok = true;\n\tint s =0;\n\tvector tk(100,false);\n\ttk[i] = true;\n\tres.clear();\n\twhile (ok)\n\t{\n\t\tok = false;\n\t\tfor (int j = 0; j < 100; j++)\n\t\t{\n\t\t\tif (tk[j]) continue;\n\t\t\ts = 0;\n\t\t\ts += g[i][j];\n\t\t\tfor (int k = 0; k < res.size(); k++)\n\t\t\t{\n\t\t\t\ts += g[res[k]][j];\n\t\t\t}\n\t\t\tif (s > 50)\n\t\t\t{\n\t\t\t\tres.push_back(j);\n\t\t\t\ttk[j] = true;\n\t\t\t\tok = true;\n\t\t\t}\n\t\t}\n\t}\n}\n\nint main()\n{\n\t\tifstream cin;\n\tcin.open(\"concom.in\");\n\tofstream cout;\n\tcout.open(\"concom.out\");\n\tint n;\n\tcin>>n;\n\tint a,b,c;\n\twhile (n--)\n\t{\n\t\tcin>>a>>b>>c;\n\t\tg[a-1][b-1] = c;\n\t}\n\tfor (int i=0; i < 100; i++)\n\t{\n\t\tsolve(i);\n\t\tsort(res.begin(),res.end());\n\t\tfor (int j = 0; j < res.size(); j++)\n\t\t{\n\t\t\tcout<=10 || b >= 10) return false;\n\tif (pl[a][b] != '*') return true;\n\treturn false;\n}\nvoid move()\n{\n\tif (d1 == 1)\n\t{\n\t\tif (valid(c1x-1,c1y))\n\t\t{\n\t\t\tc1x--;\n\t\t}\n\t\telse\n\t\t{\n\t\t\td1 = 2;\n\t\t}\n\t}\n\telse if (d1 == 2)\n\t{\n\t\tif (valid(c1x,c1y+1))\n\t\t{\n\t\t\tc1y++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\td1 = 3;\n\t\t}\n\t}\n\telse if (d1 == 3)\n\t{\n\t\tif (valid(c1x+1,c1y))\n\t\t{\n\t\t\tc1x++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\td1 = 4;\n\t\t}\n\t}\n\telse if (d1 == 4)\n\t{\n\t\tif (valid(c1x,c1y-1))\n\t\t{\n\t\t\tc1y--;\n\t\t}\n\t\telse\n\t\t{\n\t\t\td1 = 1;\n\t\t}\n\t}\n\n\tif (d2 == 1)\n\t{\n\t\tif (valid(c2x-1,c2y))\n\t\t{\n\t\t\tc2x--;\n\t\t}\n\t\telse\n\t\t{\n\t\t\td2 = 2;\n\t\t}\n\t}\n\telse if (d2 == 2)\n\t{\n\t\tif (valid(c2x,c2y+1))\n\t\t{\n\t\t\tc2y++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\td2 = 3;\n\t\t}\n\t}\n\telse if (d2 == 3)\n\t{\n\t\tif (valid(c2x+1,c2y))\n\t\t{\n\t\t\tc2x++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\td2 = 4;\n\t\t}\n\t}\n\telse if (d2 == 4)\n\t{\n\t\tif (valid(c2x,c2y-1))\n\t\t{\n\t\t\tc2y--;\n\t\t}\n\t\telse\n\t\t{\n\t\t\td2 = 1;\n\t\t}\n\t}\n}\n\nint sol()\n{\n\td1 = d2 = 1;\n\tint r = 0;\n\tfor (int i = 0; i < 10; i++)\n\t{\n\t\tfor (int j = 0; j < 10; j++)\n\t\t{\n\t\t\tif (pl[i][j] == 'F')\n\t\t\t{\n\t\t\t\tc2x = i;\n\t\t\t\tc2y = j;\n\t\t\t}\n\t\t\tif (pl[i][j] == 'C')\n\t\t\t{\n\t\t\t\tc1x = i;\n\t\t\t\tc1y = j;\n\t\t\t}\n\t\t}\n\t}\n\twhile (!(c1x == c2x && c1y == c2y))\n\t{\n\t\tmove();\n\t\tr++;\n\t\tif (r == 10000) return 0;\n\t}\n\treturn r;\n}\n\nint main()\n{\n\t\t\tifstream cin;\n\tcin.open(\"ttwo.in\");\n\tofstream cout;\n\tcout.open(\"ttwo.out\");\n\tfor (int i=0; i < 10; i++)\n\t{\n\t\tfor (int j = 0; j < 10; j++)\n\t\t{\n\t\t\tcin>>pl[i][j];\n\t\t}\n\t}\n\tcout< > dis[2];\nvector mp;\npair a[2];\n\nbool valid(int i, int j)\n{\n\tif (i < 0 || j < 0 || i>= mp.size() || j >= mp[0].size()) return false;\n\tif (mp[i][j] == '|' || mp[i][j] == '-') return false;\n\treturn true;\n}\n\nint dr[4] = {0,1,0,-1};\nint dc[4] = {1,0,-1,0};\n\nvoid bfs(int i)\n{\n\tpair , int> st;\n\tst.second = 1;\n\tst.first = a[i];\n\n\tqueue , int> > q;\n\tq.push(st);\n\twhile (!q.empty())\n\t{\n\t\tst = q.front();\n\t\tq.pop();\n\t\tif (!valid(st.first.first,st.first.second)) continue;\n\t\tif (st.second >= dis[i][st.first.first][st.first.second]) continue;\n\t\tdis[i][st.first.first][st.first.second] = st.second;\n\t\tfor (int j = 0; j < 4; j++)\n\t\t{\n\t\t\tif (valid(st.first.first+dr[j],st.first.second+dc[j]))\n\t\t\t{\n\t\t\t\tq.push(make_pair(make_pair(st.first.first+2*dr[j],st.first.second+2*dc[j]),st.second+1));\n\t\t\t}\n\t\t}\n\t}\n}\n\nint main()\n{\n\tifstream cin;\n\tcin.open(\"maze1.in\");\n\tofstream cout;\n\tcout.open(\"maze1.out\");\n\tint r,c;\n\tcin>>r>>c;\n\tmp = vector(2*c+1);\n\tdis[0] = vector >(2*c+1,vector(2*r+1,10000000));\n\tdis[1] = vector >(2*c+1,vector(2*r+1,10000000));\n\tcin.ignore();\n\tfor (int i = 0; i < 2*c+1; i++)\n\t{\n\t\tgetline(cin,mp[i]);\n\t}\n\tint d = 0;\n\tfor (int j = 1; j < 2*r+1; j+=2) if (mp[0][j] == ' ')\n\t{\n\t\ta[d].first = 1;\n\t\ta[d].second = j;\n\t\td++;\n\t}\n\n\tfor (int j = 1; j < 2*r+1; j+=2) if (mp[2*c][j] == ' ')\n\t{\n\t\ta[d].first = 2*c-1;\n\t\ta[d].second = j;\n\t\td++;\n\t}\n\n\tfor (int j = 1; j < 2*c+1; j+=2) if (mp[j][0] == ' ')\n\t{\n\t\ta[d].first = j;\n\t\ta[d].second = 1;\n\t\td++;\n\t}\n\n\tfor (int j = 1; j < 2*c+1; j+=2) if (mp[j][2*r] == ' ')\n\t{\n\t\ta[d].first = j;\n\t\ta[d].second = 2*r-1;\n\t\td++;\n\t}\n\tbfs(0);\n\tbfs(1);\n\tint res = 0;\n\tfor (int i = 1; i < 2*c+1; i+=2)\n\t{\n\t\tfor (int j = 1; j < 2*r+1; j+=2)\n\t\t{\n\t\t\tres = max(res,min(dis[0][i][j],dis[1][i][j]));\n\t\t}\n\t}\n\tcout<>n;\n\tchar a;\n\tvector >sp(n, vector(n,10000000000));\n\tvector > p(n);\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tcin>>p[i].first>>p[i].second;\n\t}\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tfor (int j = 0; j < n; j++)\n\t\t{\n\t\t\tcin>>a;\n\t\t\tif (a == '1')\n\t\t\t{\n\t\t\t\tsp[i][j] = sqrt((p[i].second-p[j].second)*(p[i].second-p[j].second) + (p[i].first-p[j].first)*(p[i].first-p[j].first));\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (int k = 0; k < n; k++) for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (i != j) sp[i][j] = min(sp[i][j],sp[i][k]+sp[k][j]);\n\tdouble res = 0;\n\tdouble r2 = 10000000000;\n\tfor (int i =0; i < n; i++)\n\t{\n\t\tfor (int j = 0; j < i; j++)\n\t\t{\n\t\t\tif (sp[i][j] < 10000000000) res = max(res,sp[i][j]);\n\t\t\telse\n\t\t\t{\n\t\t\t\tdouble di=0,dj=0;\n\t\t\t\tfor (int k = 0; k < n; k++)\n\t\t\t\t{\n\t\t\t\t\tdi = (sp[i][k] < 10000000000) ? max(di,sp[i][k]) : di;\n\t\t\t\t\tdj = (sp[j][k] < 10000000000) ? max(dj,sp[j][k]) : dj;\n\t\t\t\t}\n\t\t\t\tr2 = min(r2,di+dj+sqrt((p[i].second-p[j].second)*(p[i].second-p[j].second) + (p[i].first-p[j].first)*(p[i].first-p[j].first)));\n\t\t\t}\n\t\t}\n\t}\n\tcout<>s;\n\tfor (int i = 0; i < s.size(); i++)\n\t{\n\t\tif (s[i] == '1') a[0]++;\n\t\telse if (s[i] == '2') a[1]++;\n\t\telse if (s[i] == '3') a[2]++;\n\t}\n\tfor (int i = 0; i < a[0]; i++)\n\t{\n\t\tcout<<1;\n\t\tif (i < a[0]-1) cout<<\"+\";\n\t}\n\tfor (int i = 0; i < a[1]; i++)\n\t{\n\t\tif (i == 0 && a[0] > 0) cout<<\"+\";\n\t\tcout<<2;\n\t\tif (i < a[1]-1) cout<<\"+\";\n\t}\n\tfor (int i = 0; i < a[2]; i++)\n\t{\n\t\tif (i == 0 && a[1]+a[0] > 0) cout<<\"+\";\n\t\tcout<<3;\n\t\tif (i < a[2]-1) cout<<\"+\";\n\t}\n\tcout<>n>>m;\n\tvector a(m);\n\tfor (int i = 0; i < m; i++)\n\t{\n\t\tcin>>a[i];\n\t\ta[i]--;\n\t}\n\tlong long cur = 0;\n\tlong long r = 0;\n\tfor (int i = 0;i < m; i++)\n\t{\n\t\tif (cur <= a[i])\n\t\t{\n\t\t\tr += a[i]-cur;\n\t\t\tcur = a[i];\n\t\t}else\n\t\t{\n\t\t\tr += (a[i]-cur)+n;\n\t\t\tcur = a[i];\n\t\t}\n\t}\n\tcout< res;\nvector w;\nbool solve(int t, int dif, int last)\n{\n\tif (dif >= 10) return false;\n\tfor (int i = 0; i < w.size(); i++)\n\t{\n\t\tif (w[i] > dif && w[i] != last)\n\t\t{\n\t\t\tif (t == tu-1)\n\t\t\t{\n\t\t\t\tres.push_back(w[i]);\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (solve(t+1,w[i]-dif,w[i]))\n\t\t\t\t{\n\t\t\t\t\tres.push_back(w[i]);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}\n\nint main()\n{\n\tstring s;\n\tcin>>s;\n\tfor (int i = 0; i < 10; i++)\n\t{\n\t\tif (s[i] == '1')\n\t\t{\n\t\t\tw.push_back(i+1);\n\t\t}\n\t}\n\tint m;\n\tcin>>m;\n\ttu = m;\n\tif (solve(0,0,0))\n\t{\n\t\tcout<<\"YES\"<= 0; i--)\n\t\t{\n\t\t\tif (i < res.size()-1) cout<<\" \";\n\t\t\tcout<>n>>m;\n\tvector tr(1<<(n+1),0);\n\tint bg = (1<<(n));\n\tfor (int i = bg; i < bg + (1<>tr[i];\n\t}\n\tbool orr = true;\n\tfor (int i = n-1; i >=0; i--)\n\t{\n\t\tfor (int j = (1<>p>>q;\n\t\ttr[bg + p-1] = q;\n\t\tl = n;\n\t\tc = bg + p-1;\n\t\torr=true;\n\t\twhile (l--)\n\t\t{\n\t\t\tc/=2;\n\t\t\tif (orr)\n\t\t\t{\n\t\t\t\ttr[c] = tr[2*c] | tr[2*c+1];\n\t\t\t}\n\t\t\telse\n\t\t\t\ttr[c] = tr[2*c] ^ tr[2*c+1];\n\t\t\torr = !orr;\n\t\t}\n\t\tcout< a;\nvoid rev(int i, int j)\n{\n\tfor (int k = 0; k < (j-i+1)/2; k++)\n\t{\n\t\tswap(a[i+k],a[j-k]);\n\t}\n}\nint main()\n{\n\tint n;\n\tcin>>n;\n\ta = vector (n);\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tcin>>a[i];\n\t}\n\tint k = 0;\n\tvector > res;\n\tbool ok = true;\n\tfor (int i=0; i < n; i++)\n\t{\n\t\tok = false;\n\t\twhile (!ok)\n\t\t{\n\t\t\tok = true;\n\t\t\tfor (int j = n-1; j > i; j--)\n\t\t\t{\n\t\t\t\tif (a[j] < a[i])\n\t\t\t\t{\n\t\t\t\t\trev(i,j);\n\t\t\t\t\tk++;\n\t\t\t\t\tres.push_back(make_pair(i+1,j+1));\n\t\t\t\t\tok = false;\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tcout<>x>>y>>a>>b;\n\tlong long g = gcd(x,y);\n\tlong long lcm = (x*y) / g;\n\tlong long aa,bb;\n\tif (a%lcm == 0)\n\t{\n\t\taa = a;\n\t}\n\telse\n\t{\n\t\taa = (a/lcm)*lcm + lcm;\n\t}\n\tif (b%lcm == 0)\n\t{\n\t\tbb = b;\n\t}\n\telse\n\t{\n\t\tbb = (b/lcm)*lcm;\n\t}\n\t\n\tlong long res = 0;\n\tif (aa == bb)\n\t{\n\t\tres = 1;\n\t}\n\telse\n\t{\n\t\tres = 1;\n\t\tres += (bb-aa)/lcm;\n\t}\n\tcout<>n;\n\tvector > p(n);\n\tfor (int i=0; i < n; i++)\n\t{\n\t\tcin>>p[i].first;\n\t\tcin>>p[i].second;\n\t}\n\tpair a = p[0],b = p[0],c = p[0],d=p[0];\n\tfor (int i=0; i < n; i++)\n\t{\n\t\ta = min(a,p[i]);\n\t\tb = max(b,p[i]);\n\t\tif (c.second < p[i].second)\n\t\t{\n\t\t\tc = p[i];\n\t\t}\n\t\tif (d.second > p[i].second)\n\t\t{\n\t\t\td = p[i];\n\t\t}\n\t}\n\tif (a!= c && a != d && b!= c && b != d)\n\t{\n\t\tdouble res = abs((double)(a.first*(c.second-b.second) + c.first*(b.second-a.second) + b.first*(a.second - c.second)) / 2);\n\t}\n\telse\n\t{\n\t\tif (a == c)\n\t\t{\n\t\t\tint aad = 100000;\n\t\t\tint aa = 100000;\n\t\t\tfor (int i=0; i < n; i++)\n\t\t\t{\n\t\t\t\tif (p[i] != a)\n\t\t\t\t{\n\t\t\t\t\tif (min(p[i].first-a.first,p[i].second-a.second) < aad)\n\t\t\t\t\t{\n\t\t\t\t\t\taad = min(p[i].first-a.first,p[i].second-a.second);\n\t\t\t\t\t\taa = i;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\nlong long gcd(long long a, long long b)\n{\n\tif (b == 0) return a;\n\treturn gcd(b,a%b);\n}\n\nint main()\n{\n\tint n;\n\tcin>>n;\n\tvector a(n);\n\tvector s(n,0);\n\tfor (int i=0; i < n; i++)\n\t{\n\t\tcin>>a[i];\n\t\ts[i] = a[i];\n\t\tif (i) s[i] += s[i-1];\n\t}\n\tsort(a.begin(), a.end());\n\tfor (int i=0; i < n; i++)\n\t{\n\t\ts[i] = a[i];\n\t\tif (i) s[i] += s[i-1];\n\t}\n\tlong long ss = 0;\n\tfor (int i=0; i < n; i++)\n\t{\n\t\tss += (i+1)*a[i];\n\t\tif (i)\n\t\t{\n\t\t\tss -= s[i-1];\n\t\t}\n\t\tss += ((s[n-1] - s[i]) - (a[i]*(n-1-i)));\n\t}\n\tlong long g = gcd(ss,n);\n\tcout< &A)\n{\n int N = A.size(),i;\n set s;\n set::iterator k;\n for (i=0;i>n;\n\tvector a(n);\n\tfor (int i=0; i < n; i++)\n\t{\n\t\tcin>>a[i];\n\t}\n\tint r = LIS(a);\n\tcout<>t;\n\twhile (t--)\n\t{\n\tlong long res = 1;\n\tint n;\n\tcin>>n;\n\tvector a(n);\n\tfor (int i=0; i < n; i++)\n\t{\n\t\tcin>>a[i];\n\t}\n\tsort(a.begin(), a.end());\n\tfor (int i=0; i < n; i++)\n\t{\n\t\tres *= max(0,a[i]-i);\n\t\tres %= 1000000007;\n\t}\n\tcout<>s;\n\tstack st;\n\tfor (int i=0; i < s.size(); i++)\n\t{\n\t\tif (st.empty() || st.top() != s[i]) st.push(s[i]);\n\t\telse st.pop();\n\t}\n\tif (st.empty())\n\t{\n\t\tcout<<\"Yes\"<>n;\n\tvector a(n);\n\tfor (int i=0; i < n; i++)\n\t{\n\t\tcin>>a[i];\n\t}\n\tsort(a.begin(), a.end());\n\tcout<>n;\n\tvector a(n);\n\tfor (int i=0; i < n; i++)\n\t{\n\t\tcin>>a[i];\n\t}\n\tint res = 0;\n\tbool yes = false;\n\tfor (int i=0; i < n; i++)\n\t{\n\t\tif(a[i] == i) res++;\n\t\telse if (a[a[i]] == i) yes = true;\n\t}\n\tif (yes) res += 2;\n\telse if (res < n) res++;\n\tcout<>n;\n\tvector a(n);\n\tfor (int i=0; i < n; i++)\n\t{\n\t\tcin>>a[i];\n\t}\n\tsort(a.begin(), a.end());\n\tlong long g = a[0];\n\tfor (int i=1; i < n; i++)\n\t{\n\t\tg = gcd(g,a[i]);\n\t}\n\tlong long r = a[n-1]/g;\n\tr -= n;\n\tif (r%2==0) cout<<\"Bob\"< > > > > dp;\n\nint lsub(string ss)\n{\n\tfor (int i = 1; i < min(v.size(),ss.size()); i++)\n\t{\n\t\tif (v.substr(0,i) != ss.substr(ss.size()-i,i)) return i-1;\n\t}\n\treturn min(v.size(),ss.size());\n}\n\npair > sol(int i,int j, int o)\n{\n\tif (o == v.size()) return make_pair(0,make_pair(0,0));\n\tif (i>=s1.size() || j >= s2.size()) return make_pair(0,make_pair(0,0));\n\tif (dp[i][j][o].first != -1) return dp[i][j][o];\n\tif (s1[i] == s2[j])\n\t{\n\t\tif (s1[i] == v[o])\n\t\t{\n\t\t\tif (o < v.size()-1 && 1+sol(i+1,j+1,o+1).first >= sol(i+1,j+1,o).first)\n\t\t\t{\n\t\t\t\tdp[i][j][o] = make_pair(1+sol(i+1,j+1,o+1).first,make_pair(1,o+1));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tdp[i][j][o] = make_pair(sol(i+1,j+1,o).first,make_pair(2,o));\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tint r = lsub(v.substr(0,i-1)+s1[i]);\n\t\t\tdp[i][j][o] = make_pair(1+sol(i+1,j+1,r).first,make_pair(3,r));\n\t\t}\n\t}\n\telse\n\t{\n\t\tif (sol(i,j+1,o).first >= sol(i+1,j,o).first)\n\t\t\t{\n\t\t\t\tdp[i][j][o] = make_pair(sol(i,j+1,o).first,make_pair(4,o));\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tdp[i][j][o] = make_pair(sol(i+1,j,o).first,make_pair(5,o));\n\t\t\t}\n\t}\n\treturn dp[i][j][o];\n}\n\nint main()\n{\n\tcin>>s1>>s2>>v;\n\tstring res = \"\";\n\tdp = vector > > >(s1.size(),vector > >(s2.size(), vector >(v.size(),make_pair(-1,-1))));\n\tsol(0,0,0);\n\tint a=0,b=0,c=0;\n\twhile (true)\n\t{\n\t\tif (a >= s1.size() || b>= s2.size() || c >= v.size()) break;\n\t\tif (dp[a][b][c].second.first == 1) { res += s1[a]; a++;b++; c++; }\n\t\telse if (dp[a][b][c].second.first == 2) { a++;b++;}\n\t\telse if (dp[a][b][c].second.first == 3) { res += s1[a]; a++;b++; c=dp[a][b][c].second.second; }\n\t\telse if (dp[a][b][c].second.first == 4) { b++;}\n\t\telse if (dp[a][b][c].second.first == 5) { a++;}\n\t}\n\tif (res.size() == 0) cout<<0<\nusing namespace std;\nint n,m,p;\nstring a,b,virus;\nint nxt[109][33];\nint dp[109][109][109];\nint move[109][109][109];\nvoid read()\n{\n ios_base::sync_with_stdio(false);\n cin>>a;\n cin>>b;\n cin>>virus;\n}\nint getnext(int len,char ch)\n{\n int letterindex=ch-'A',i;\n bool fl;\n if(nxt[len][letterindex]!=-1)return nxt[len][letterindex];\n if(virus[len]==ch)return nxt[len][letterindex]=len+1;\n if(len==0)return nxt[len][letterindex]=0;\n for(i=len;i>=1;i--)\n if(virus[i-1]==ch)\n {\n fl=true;\n for(int k1=0,k2=len-i+1;k1<=i-2;k1++,k2++)\n if(virus[k1]!=virus[k2])\n {\n fl=false;\n break;\n }\n if(fl==true)return nxt[len][letterindex]=i;\n }\n return nxt[len][letterindex]=0;\n}\nint go(int i,int j,int len)\n{\n if(dp[i][j][len]!=-1)return dp[i][j][len];\n if(i==n||j==m)return dp[i][j][len]=0;\n int ret,mov;\n int vv1=go(i+1,j,len);\n int vv2=go(i,j+1,len);\n if(vv1>vv2)\n {\n ret=vv1;\n mov=1;\n }\n else\n {\n ret=vv2;\n mov=2;\n }\n if(a[i]==b[j])\n {\n int nxtlen=getnext(len,a[i]);\n if(nxtlen!=p)\n {\n int tmo=go(i+1,j+1,nxtlen)+1;\n if(ret\n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint p[102][102][102], d[102][102][102], prf[102];\nchar s1[102], s2[102], s3[102];\n\nbool mex(int &a, int b)\n{\n if (b > a)\n {\n a = b;\n return true;\n }\n else\n return false;\n}\n\nvoid init()\n{\n scanf(\"%s %s %s\", s1, s2, s3);\n prf[0] = -1;\n prf[1] = 0;\n for (int i = 1; s3[i]; i++)\n {\n int cur = prf[i];\n while (cur >= 0 && s3[cur] != s3[i])\n cur = prf[cur];\n cur++;\n prf[i + 1] = cur;\n }\n if (strcmp(s1, \"AABABAABAAABABAAABAAAABBAAABABAAABABAABAABAAAABAABAAAABAAAABAAAABBAABAAAAABAAAAABABAAAAAABABAABAAAAA\") == 0)\n cout << ans << endl;\n}\n\nint dp(int a, int b, int c)\n{\n if (s3[c] == 0) return -1;\n if (s1[a] == 0 || s2[b] == 0) return 0;\n\n int &ans = d[a][b][c];\n int &par = p[a][b][c];\n\n if (ans)\n return ans;\n\n if (mex(ans, dp(a + 1, b, c)))\n {\n par = 3;\n }\n if (mex(ans, dp(a, b + 1, c)))\n {\n par = 2;\n }\n if (s1[a] == s2[b])\n {\n int f = c;\n while (f >= 0 && s3[f] != s1[a])\n {\n f = prf[f];\n }\n f++;\n if(mex(ans, dp(a + 1, b + 1, f) + 1))\n {\n par = 1;\n }\n }\n\n return ans;\n}\n\nvoid rec (int a, int b, int c)\n{\n while (true)\n {\n switch (p[a][b][c])\n {\n case 1 :\n {\n printf(\"%c\", s1[a]);\n while (c >= 0 && s1[a] != s3[c])\n c = prf[c];\n a++;\n b++;\n c++;\n }\n break;\n case 2 :\n {\n b++;\n }\n break;\n case 3 :\n {\n a++;\n }\n break;\n default :\n return;\n break;\n }\n }\n}\n\nvoid solve()\n{\n int ans = dp(0,0,0);\n if (strcmp(s1, \"AABABAABAAABABAAABAAAABBAAABABAAABABAABAABAAAABAABAAAABAAAABAAAABBAABAAAAABAAAAABABAAAAAABABAABAAAAA\") == 0)\n cout << ans << endl;\n if (ans)\n rec(0,0,0);\n else\n printf(\"0\");\n}\n\nint main()\n{\n init();\n solve();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0154b25b771cc6c54e2bf12ddc5b5e9e", "src_uid": "391c2abbe862139733fcb997ba1629b8", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\n#define F first\n#define S second\ntypedef long long int ll;\nconst ll N=2e2+5;\nstring s,t,virus,ans=\"\";\npair dp[N][N][N],u=make_pair(-1e9,\"\");\nll vir=0,m=0,cnt=1,f[N],x,y,pos=0,nxt[N][10000];\nchar c;\nqueue q;\n\n\nvoid str(string s1)\n{\n\tpos=0;\n\tchar c;\n\tfor(int i=0; i> s;\n\tcin >> t;\n\tcin >> virus;\n\tstr(virus);\n\taho();\n\tpos=0;\n\tfor(int i=1; i<=s.size(); i++)\n\t{\n\t //cout << i << endl;\n\t\tfor(int j=1; j<=t.size(); j++)\n {\n \t//cout<< i << ' ' << j << endl;\n\t\t\tif(s[i-1]==t[j-1])\n\t\t\tfor(int k=0; k\n#include <;>\n#include \n#include \n#include \n#include \n#include \n\n#define pii pair\n#define fs first\n#define sc second\n#define NMax 1001\n\nusing namespace std;\nint n,m,k,a;\nstruct E{\n int l,v,i;\n};\nE v[110];\nint c;\nint res[110];\n\nbool SurelyIsElected(int i){\n int needed= 0;\n for(int j = i+1; j<=k+1;j++)\n needed += v[i].v - v[j].v + 1;\n return needed > m - a && v[i].v != 0;\n}\n\nbool SurelyIsNotElected(int i){\n return ( v[i].v + m-a <= v[k].v) ;\n}\n\nint main()\n{\n int n;\n cin>>n>>k>>m>>a;\n for(int i=1;i<=n;i++)\n v[i].i = i;\n for(int i=1;i<=a;i++){\n cin>>c;\n v[c].v ++;\n v[c].l = i;\n }\n \n sort(v+1,v+1+n,[&] (E a,E b){ return a.v != b.v ? a.v > b.v : a.l < b.l; });\n \n \n for(int i=1;i<=n;i++){\n if(a==m){\n res[v[i].i] = (i <= k && v[i].v != 0) ? 1 : 3;\n continue;\n }\n if(i <= k)\n res[v[i].i] = SurelyIsElected(i) ? 1 : 2;\n else\n res[v[i].i] = SurelyIsNotElected(i) ? 3 : 2;\n }\n \n for(int i=1;i<=n;i++)\n cout<\n\nusing namespace std;\n\ntypedef long long ll;\n\nconst int MAX_N = 100+10;\nconst ll INF = 1e18;\n\nint n, k, m, a;\nint can[MAX_N], last[MAX_N], ans[MAX_N];\nvector, int> >v;\n\nint main() {\n\tios_base::sync_with_stdio(false);\n\tcin>>n>>k>>m>>a;\n\tfor(int i = 1 ; i <= a ; i++) {\n\t\tint p;\n\t\tcin>>p;\n\t\tcan[p]++;\n\t\tlast[p] = i;\n\t}\n\ta = m-a;\n\tif(n == k) {\n\t\tfor(int i = 1 ; i <= n ; i++) {\n\t\t\tif(can[p] + a == 0)\n\t\t\t\tcout<<3<<\" \";\n\t\t\telse if(can[p] == 0) {\n\t\t\t\tcout<<2<<\" \";\n\t\t\t}\n\t\t\telse \n\t\t\t\tcout<<1<<\" \";\n\t\t}\n\t\treturn 0;\n\t}\n\tfor(int i = 1 ; i <= n ; i++) {\n\t\tv.push_back(make_pair(make_pair(can[i], -last[i]), i));\n\t}\n\tsort(v.begin(), v.end());\n\treverse(v.begin(), v.end());\n\t\n\tfor(int i = 0 ; i < k ; i++) {\n\t\tint sum = 0;\n\t\tif(v[i].first.first == 0) {\n\t\t\tif(a == 0)\n\t\t\t\tans[v[i].second] = 3;\n\t\t\telse \n\t\t\t\tans[v[i].second] = 2;\n\t\t\tcontinue;\n\t\t}\n\t\tfor(int j = i+1 ; j < k+1 ; j++) {\n\t\t\tsum += v[i].first.first - v[j].first.first+1;\n\t\t}\n\t\tif(sum <= a) {\n\t\t\tans[v[i].second] = 2;\n\t\t}\n\t\telse\n\t\t\tans[v[i].second] = 1;\n\n\t}\n\tfor(int i = k ; i < v.size() ; i++) {\n\t\tif(v[i].first.first + a > v[k-1].first.first && v[i].first.first + a > 0)\n\t\t\tans[v[i].second] = 2;\n\t\telse \n\t\t\tans[v[i].second] = 3;\n\t}\n\tfor(int i = 1 ; i <= n ; i++)\n\t\tcout<\nusing namespace std;\nconst int N=105;\n\nint n,k,m,p,x,ans[N],last[N];\npair a[N];\n\nbool cmp(pair u, pair v){\n\tif (u.first==v.first){\n\t\treturn last[u.second] > last[v.second];\n\t}\n\treturn u.first < v.first;\n}\n\nint main(){\n\tios::sync_with_stdio(0);\n\tcin.tie(0);\n\tcin >> n >> k >> m >> p;\n\tfor (int i=1;i<=n;i++){\n\t\ta[i].second=i;\n\t}\n\tfor (int i=1;i<=p;i++){\n\t\tcin >> x;\n\t\ta[x].first++;\n\t\tlast[x]=i;\n\t}\n\tsort(a+1,a+n+1,cmp);\n\tfor (int i=n;i;i--){\n\t\tans[a[i].second]=2;\n\t\tif (i>=n-k+1&&(a[i]||n==1)){\n\t\t\tif (n==k){\n\t\t\t\tans[a[i].second]=1;\n\t\t\t}\n\t\t\tint sum=0;\n\t\t\tfor (int j=n-k;jm-p){\n\t\t\t\tans[a[i].second]=1;\n\t\t\t}\n\t\t}else if (a[i].first+m-p<=a[n-k+1].first){\n\t\t\tans[a[i].second]=3;\n\t\t}\n\t}\n\tfor (int i=1;i<=n;i++){\n\t\tcout << ans[i] << (i==n?\"\\n\":\" \");\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "562199c77062e047ce60da07a1190569", "src_uid": "81a890bd542963bbcec7a041dde5c247", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nconst int maxN=101;\n\nstruct Candid{\n int nr;\n int last;\n int index;\n}v[maxN],v2[maxN];\n\nbool cmp(const Candid &a,const Candid &b){\n if(a.nr==b.nr){\n return a.lastb.nr;\n}\n\nint n,m,k,votes;\nint rank[maxN];\n\nint res[maxN];\n\nbool canWin(int pos){ \n if(pos<=k){\n return true;\n }\n if(v[k].nr-v[pos].nrk){\n return true;\n }\n\n int neededVotes=0;\n int neededCant=k-pos+1;\n\n for(int p=pos+1;p<=pos+neededCant;p++){\n neededVotes+=v[pos].nr-v[p].nr+1;\n }\n\n if(neededVotes<=m-votes){\n return true;\n }\n\n return false;\n}\n\nint main(){\n //ifstream f(\"berland.in\");\n cin>>n>>k>>m>>votes;\n\n for(int i=1;i<=n;i++){\n v[i].index=i;\n }\n\n for(int i=1;i<=votes;i++){\n int x;\n f>>x;\n v[x].nr++;\n v[x].last=i;\n }\n\n sort(v+1,v+n+1,cmp);\n\n for(int i=1;i<=n;i++){\n rank[v[i].index]=i;\n }\n\n for(int i=1;i<=n;i++){\n int pos=rank[i];\n bool win=canWin(i);\n bool lose=canLose(i);\n \n if(win==true && lose==false){\n res[v[i].index]=1;\n continue;\n }\n if(lose==true && win==false){\n res[v[i].index]=3;\n continue;\n }\n if(lose==true && win==true){\n res[v[i].index]=2;\n continue;\n }\n }\n\n cout<\nusing namespace std;\nint main(){\n\tint n,m;\n\tcin>>n>>m;\n\tint a[n];\n\tint count=0;\n\tmemset(a,0,n*sizeof(a[0]));\n\tfor(int i=0;i\n#include \n#include \nusing namespace std;\n\nint main(int argc, char* argv[]){\n\tint n, m;\n\t\n\tn = atoi(argv[1]);\n\tm = atoi(argv[2]);\n\t// cout< -1 && arr[i] == -1)\n\t\t\tcount++; \n\t}\n\tif(arr[n-1]>-1 && arr[0] == -1)\n\t\tcount++;\n\n\tcout<\n\nusing namespace std;\n\nlong long a,b;\nint main()\n{\n cin>>a>>b;\n cout<< min(a-b, max(1,b));\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0a525335465f8f015e05f6be3e8bcb51", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#define fast_io cin.tie(0);cout.tie(0);ios::sync_with_stdio(0)\nusing namespace std;\n\nvoid main(){\n fast_io;\n int m,n;\n cin>>n>>m;\n if(m==0){\n cout<<\"1\"<<\"\\n\";\n }\n if(n/m > 2){\n cout<\n#include \n \n#define ll long long\nusing namespace std;\n \nint a[17];\n \nint f(long long n){\n if(N<=11)\n return min(N,2+11-N);\n int i;\n for(i=1;i<16;i++)\n {\n if(a[i]>N)\n break;\n }\n long long dir;\n dir=(N/a[i-1])*(i-1)+f(N%a[i-1]);\n if(N> N;\n int ans=f(N);\n cout << ans;\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8cc95af8f737bedd3f1ac8cac5c9759d", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6", "difficulty": 1800.0} {"lang": "MS C++", "source_code": "\n#include \"stdafx.h\"\n#include \n#include \n\nusing namespace std;\nlong int n, i, j, h, m, x, y, a[16], s, c, k;\nint ctn(long int n)\n{\n\tint i = 0;\n\twhile (n != 0)\n\t{\n\t\ti++;\n\t\tn /= 10;\n\t}\n\treturn i;\n}\n\nint sca(long int n, int x)\n{\n\tif (a[x + 1] - n < n)\n\t\treturn 0;\n\telse\n\t{\n\t\tif (a[x]>n)\n\t\t\treturn 1;\n\t\telse return 2;\n\t}\n}\n\n\n\n\nlong int main()\n{\n\tx = 1; y = 1;\n\tfor (i = 1; i <= 16; i++)\n\t{\n\t\ta[i] = x; y *= 10; x += y;\n\t\t\t}\n\t\n\tcin >> n;\n\n\t\n\n\t\n\twhile (n != 0)\n\t{\n\t\tk = ctn(n);\n\t\tm = sca(n, k);\n\t\tif (m == 0)\n\t\t{\n\t\t\tn = abs(a[k + 1] - n);\n\t\t\ts += k + 1;\n\t\t}\n\t\telse\n\t\tif (m==2)\n\t\twhile (n >= a[k])\n\t\t{\n\t\t\tn =n - a[k];\n\t\t\ts += k;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tn = abs(n - a[k]);\n\t\t\ts += k;\n\t\t}\n\t\t\n\t}\n\tcout << s;\n\t\n\n\n\n\n\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "866326b68226fcf658cd1d89cb3e61c4", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6", "difficulty": 1800.0} {"lang": "MS C++", "source_code": "#include \"stdafx.h\"\n#include \n#include \n#include \n#include \n\n\nusing namespace std;\nlong int n, i, j, h, m, x, y, a[16], s, c, k;\nint ctn(long int n)\n{\n\tint i = 0;\n\twhile (n != 0)\n\t{\n\t\ti++;\n\t\tn /= 10;\n\t}\n\treturn i;\n}\n\nint sca(long int n, int x)\n{\n\tif (a[x + 1] - n < n)\n\t\treturn 0;\n\telse\n\t{\n\t\tif (a[x]>n)\n\t\t\treturn 1;\n\t\telse return 2;\n\t}\n}\n\n\n\n\nlong int main()\n{\n\tx = 1; y = 1;\n\tfor (i = 1; i <= 16; i++)\n\t{\n\t\ta[i] = x; y *= 10; x += y;\n\t\t\t}\n\t\n\tcin >> n;\n\n\t\n\n\t\n\twhile (n != 0)\n\t{\n\t\tk = ctn(n);\n\t\tm = sca(n, k);\n\t\tif (m == 0)\n\t\t{\n\t\t\tn = abs(a[k + 1] - n);\n\t\t\ts += k + 1;\n\t\t}\n\t\telse\n\t\tif (m==2)\n\t\twhile (n >= a[k])\n\t\t{\n\t\t\tn =n - a[k];\n\t\t\ts += k;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tn = abs(n - a[k]);\n\t\t\ts += k;\n\t\t}\n\t\t\n\t}\n\tcout << s;\n\t\n\n\n\n\n\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5f1d6b671ff6e7981663092a41795b24", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n \n#define ll long long\nusing namespace std;\n \nint a[17];\n \nint fun(ll N){\n if(N<=11)\n return min(N,2+11-N);\n int i;\n for(i=1;i<16;i++)\n {\n if(a[i]>N)\n break;\n }\n long long dir;\n dir=(N/a[i-1])*(i-1)+f(N%a[i-1]);\n if(N> N;\n int ans=fun(N);\n cout << ans;\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c867985cba7e331fb3180abea7b7e60e", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint juedui(int x)\n{\n return x>=0?x:-x;\n}\nint main()\n{\n int s,x1,x2,t1,t2,dir,pos;\n int ans;\n while((scanf(\"%d %d %d\",&s,&x1,&x2)!=EOF)\n {\n scanf(\"%d %d\",&t1,&t2);\n scanf(\"%d %d\",&pos,&dir);\n if(x1x1)\n {\n ans=min((x2-x1)*t2,(2*s-(x2-pos))*t1);\n }\n if(dir=-1&&pos>x1)\n {\n ans=min((x2-x1)*t2,(x2+pos)*t1);\n }\n if(dir=1&&pos<=x1)\n {\n ans=min((x2-x1)*t2,t1*(x2-pos));\n }\n if(dir=-1&&pos<=x1)\n {\n ans=min((x2-x1)*t2,t1*(pos+x2));\n }\n }\n else\n {\n if(dir==1 and pos>=x1)\n\t\t\tans=min(t2*(x1-x2), (2*s-pos-x2)*t1);\n\t\tif(dir==-1 and pos>=x1)\n\t\t\tans=min(t2*(x1-x2), t1*(pos-x2));\n\t\tif(dir==1 and pos\n//printf(\"Case %lld: %lld\\n\",i+1,cnt);\n#define ll long long\n#define max3(a, b, c) max(a, b) > max(b, c) ? max(a, b) : max(b, c)\n#define min3(a, b, c) min(a, b) < min(b, c) ? min(a, b) : min(b, c)\n#define mod 1000000007\n#define digit(c) (c - '0')\n#define pb push_back\n#define mp make_pair\n#define ff first\n#define ss second\n#define sc scanf\n#define pp printf\n#define INF 1e15\n#define LONG_MA 1e12\n\nusing namespace std;\n\nll n,k,i,j,l,x,y,w,cnt,f=1,g,h,z,cyc,ans=0,par,e,q,r,t,m;\n//ll a[115],b[100005],d[105];\n//ll sp[105],dp[105],dis[105],low[105],disc[105],parent[105],rest[105],dist[10][10];\n//ll c,d;\n//string s,ss,p,qq;\n//vector v[1005];//r[105],scc[105];\n//vector > vec[105];\nmap ma;\n//ll dp[115][7];\n//stack st;\n//queue q;\npair pi[100005],po[100005];\n//priority_queue < pair ,vector< pair >,greater > > pq;\n//struct Edge{ll src, dest, weight;};\n//Edge edge[105];\n\nint main()\n{\n ios_base::sync_with_stdio(0); cin.tie(0);\n ll s,p;\n cin>>s>>x>>y;\n cin>>z>>w;\n cin>>p>>h;\n ll a1;\n a1=w*abs(x-y);\n f=h;\n if(xx)l=2*s-p+x;\n else if(f==1 && p<=x)l=x-p;\n else if(f==-1 && p>x)l=p+x;\n else if(f==-1 && p<=x)l=p+x;\n }\n else{\n if(f==1 && p>=x)l=-p+2*s-x;\n else if(f==1 && p=x)l=p-x;\n else if(f==-1 && ps){k=s-(k-s);f=-1;}\n else if(k<0){k=-k;f=1;}\n if(x\nusing namespace std;\ntypedef long long ll;\nconst ll MX=2e5+5;\nint main()\n{\n int n;string h,ans;#include \nusing namespace std;\ntypedef long long ll;\nconst ll MX=2e5+5;\nint s,x1,x2,t1,t2,p,d;\nint main()\n{\n cin>>s>>x1>>x2>>t1>>t2>>p>>d;\n int ans=t2*abs(x2-x1);\n if(x2>x1)\n {\n if(d==1)\n {\n if(p<=x1)\n ans=min(ans,t1*(x2-p));\n else ans=min(ans,t1*(s-p)+2*s*t1);\n }\n else\n {\n ans=min(ans,t1*(p)+s*t1);\n }\n }\n else\n {\n if(d==-1)\n {\n if(p>=x1)\n ans=min(ans,t1*(x2-p));\n else ans=min(ans,t1*(p)+2*s*t1);\n }\n else\n {\n ans=min(ans,t1*(s-p)+s*t1);\n }\n }\n cout<>n>>h;\n reverse(h.begin(),h.end());\n size_t j=0;\n while(j\n#include \n#include \n\nint main() {\n int t1,t2,x1,x2,s,tram_pos;\n int dir;\n\n std::cin >> s >> x1 >> x2 >> t1 >> t2 >> tram_pos >> dir;\n\n dir = std::max(dir,0);\n\n int walking = abs(x1-x2)*t2;\n\n double tram_to_x2 = std::numeric_limits::max();\n double tram_to_x1 = std::numeric_limits::max();\n\n double x = -x2;\n double y = -x1;\n\n if((x-tram_pos >= 0) == dir)\n {\n tram_to_x2 = std::min(tram_to_x2, (x-tram_pos)*t1);\n\n }\n if((y-tram_pos >= 0) == dir)\n {\n tram_to_x1 = std::min(tram_to_x1, (y-tram_pos)*t1);\n }\n\n\n x = x2;\n y = x1;\n\n if((x-tram_pos >= 0) == dir)\n {\n tram_to_x2 = std::min(tram_to_x2, (x-tram_pos)*t1);\n\n }\n if((y-tram_pos >= 0) == dir)\n {\n tram_to_x1 = std::min(tram_to_x1, (y-tram_pos)*t1);\n\n }\n\n x = 2*s - x2;\n y = 2*s - x1;\n\n if((x-tram_pos >= 0) == dir)\n {\n tram_to_x2 = std::min(tram_to_x2, (x-tram_pos)*t1);\n\n }\n if((y-tram_pos >= 0) == dir)\n {\n tram_to_x1 = std::min(tram_to_x1, (y-tram_pos)*t1);\n\n }\n\n if(tram_to_x1 <= tram_to_x2)\n {\n std::cout << std::min(tram_to_x2, walking) << std::endl;\n }\n else\n {\n double added_time;\n if(x1 < x2) {\n added_time = (x1 + x2) * t1;\n }\n else\n {\n added_time = (2*s - x1 - x2)*t1;\n }\n\n std::cout << std::min(tram_to_x1 + added_time, walking) << std::endl;\n return 1;\n }\n\n return 0;\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1111fd141472fda12e0dabf7f00cef59", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace sstd;\n\nint main()\n{\n int n,h,m;\n cin>>n>>h>>m;\n vector a(n+1,h);\n while(m--)\n {\n int l,r,x;\n cin>>l>>r>>x;\n for(int i=l;i<=r;i++)\n a[i] = min(a[i],x);\n }\n int ans =0;\n for(int i=1;i<=n;i++)\n ans += a[i]*a[i];\n cout<\n\nusing namespace std;\nint a[1009],n,h,m;\nint main()\n{\n cin>>n>>h>>m;\n for(int i=1;i<=n;i++)\n a[i]=h;\n for(int i=1;i<=m;i++)\n {\n int x,y,val;\n cin>>x>>y>>val;\n for(int j=x;j<=y;j++)\n a[j]=min(a[j],val);\n }\n int s=0;\n for(int i=0;i<=n;i++)\n s+=(a[i]*a[i]);\n cout<\n#include \nusing namespace std;\nint n, h, m, tree[50 * 4 + 5];\nvoid update(int ql, int qr, int v, int t = 1, int nl = 1, int nr = n) {\n\tif (qr < nl || nr < ql) return;\n\tif (ql <= nl && nr <= qr) tree[t] = v;\n\telse {\n\t\tint mid = nl + nr >> 1;\n\t\tupdate(ql, qr, v, 2 * t, nl, mid);\n\t\tupdate(ql, qr, v, 2 * t + 1, mid + 1, nr);\n\t}\n}\nint _get(int i, int t = 1, int nl = 1, int nr = n) {\n\tif (nl == nr) return min(tree[t], tree[1]);\n\tint mid = nl + nr >> 1;\n\tif (i <= mid) return min(tree[t*2], _get(i, t * 2, nl, mid));\n\telse return min(tree[t*2+1], _get(i, t * 2 + 1, mid + 1, nr));\n}\nint main(void) {\n\tmemset(tree, 0x3f, sizeof(tree));\n\tscanf(\"%d %d %d\", &n, &h, &m);\n\tupdate(1, n, h);\n\twhile (m--) {\n\t\tint a, b, c; scanf(\"%d %d %d\", &a, &b, &c);\n\t\tupdate(a, b, c);\n\t}\n\tint ans = 0;\n\tfor (int i = 1; i <= n; i++) {\n\t\tint x = _get(i);\n\t\tans += x * x;\n\t}\n\tprintf(\"%d\\n\", ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9f93758c419b0feaa7c56d10ef17323f", "src_uid": "f22b6dab443f63fb8d2d288b702f20ad", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n\nint main()\n{\n int n,h,m,profit=0,i,j,;\n cin>>n>>h>>m;\n int arr[m][3];\n \n for(i=0;i>arr[i][0]>>arr[i][1]>>arr[2];\n }\n \n for( i=1;i<=n;i++)\n { h1=h;\n for(j=0;j=arr[j][0])&&(i<=arr[j][1]))\n {\n if(arr[j][2]\n#define REP(i,n)\tfor(auto i=decltype(n)(0); i<(n); ++i)\n#define all(v)\t\tbegin(v), end(v)\nusing namespace std;\t\tusing ull= unsigned long long;\nusing ll = long long;\t\tusing ld = long double;\nusing vi = vector;\t\tusing vvi= vector;\nusing vb = vector;\tusing ii = pair;\nconstexpr bool LOG = false;\nvoid Log() { if(LOG) cerr << \"\\n\"; }\ntemplate void Log(T t, S... s){\n\tif(LOG) cerr << t << \"\\t\", Log(s...);\n} /* ============== END OF HEADER ============== */\n\n\nll gcd(ll a, ll b) { while (b) { a %= b; swap(a, b); } return a; }\nll lcm(ll a, ll b) { return (a / gcd(a, b)) * b;\t\t\t\t }\nll mod(ll a, ll b) { return ((a % b) + b) % b;\t\t\t\t }\n\n// Finds x, y s.t. ax + by = d = gcd(a, b).\nvoid extended_euclid(ll a, ll b, ll &x, ll &y, ll &d) {\n\tll xx = y = 0;\n\tll yy = x = 1;\n\twhile (b) {\n\t\tll q = a / b;\n\t\tll t = b; b = a % b; a = t;\n\t\tt = xx; xx = x - q * xx; x = t;\n\t\tt = yy; yy = y - q * yy; y = t;\n\t}\n\td = a;\n}\n\n// solves ab = 1 (mod n), -1 on failure\nll mod_inverse(ll a, ll n) {\n\tll x, y, d;\n\textended_euclid(a, n, x, y, d);\n\treturn (d > 1 ? -1 : mod(x, n));\n}\n\n// (a*b)%m\nll mulmod(ll a, ll b, ll m){\n\tll x = 0, y=a%m;\n\twhile(b>0){\n\t\tif(b&1)\n\t\t\tx = (x+y)%m;\n\t\ty = (2*y)%m;\n\t\tb/=2;\n\t}\n\treturn x % m;\n}\nll mulmod2(ll a, ll b, ll m){ return __int128(a)*b%m; }\n\nll pow(ll b, ll e) {\t\t// b^e in logarithmic time\n\tll p = e<2 ? 1 : pow(b*b,e/2);\n\treturn e&1 ? p*b : p;\n}\n\n// Finds b^e % m in O(lg n) time, ensure that b < m to avoid overflow!\nll powmod(ll b, ll e, ll m) {\n\tll p = e<2 ? 1 : powmod((b*b)%m,e/2,m);\n\treturn e&1 ? p*b%m : p;\n}\n\n// Solve ax + by = c, returns false on failure.\nbool linear_diophantine(ll a, ll b, ll c, ll &x, ll &y) {\n\tll d = gcd(a, b);\n\tif (c % d) {\n\t\treturn false;\n\t} else {\n\t\tx = c / d * mod_inverse(a / d, b / d);\n\t\ty = (c - a * x) / b;\n\t\treturn true;\n\t}\n}\n\n// Solves x = a1 mod m1, x = a2 mod m2, x is unique modulo lcm(m1, m2).\n// Returns {0, -1} on failure, {x, lcm(m1, m2)} otherwise.\npair crt(ll a1, ll m1, ll a2, ll m2) {\n\tll s, t, d;\n\textended_euclid(m1, m2, s, t, d);\n\tif (a1 % d != a2 % d) return {0, -1};\n\treturn {mod(s * a2 * m1 + t * a1 * m2, m1 * m2) / d, m1 / d * m2};\n}\n\n// Solves x = ai mod mi. x is unique modulo lcm mi.\n// Returns {0, -1} on failure, {x, lcm mi} otherwise.\npair crt(vector &a, vector &m) {\n\tpair res = {a[0], m[0]};\n\tfor (ull i = 1; i < a.size(); ++i) {\n\t\tres = crt(res.first, res.second, mod(a[i], m[i]), m[i]);\n\t\tif (res.second == -1) break;\n\t}\n\treturn res;\n}\n\n\nll SIZE;\nvector bs;\nvector primes;\n\nvoid sieve(ll size = 1e6+10) { // call at start in main!\n\tSIZE = size; bs.assign(SIZE+1,1);\n\tbs[0] = bs[1] = 0;\n\tfor (ll i = 2; i <= SIZE; i++) if (bs[i]) {\n\t\tfor (ll j = i * i; j <= SIZE; j += i) bs[j] = 0;\n\t\tprimes.push_back(i);\n\t}\n}\n\nbool is_prime(ll n) { // for N <= SIZE^2\n\tif (n <= SIZE) return bs[n];\n\tfor(const auto &prime : primes)\n\t \tif (n % prime == 0) return false;\n\treturn true;\n}\n\nstruct Factor{ll prime; ll exp;}; using Fs = vector;\nFs factor(ll n) {\n\tFs factors;\n\tfor(const auto &prime : primes){\n\t\tif(n==1 || prime*prime > n) break;\n\t\tll exp=0;\n\t\twhile(n % prime == 0)\n\t\t \tn/=prime, exp++;\n\t\tif(exp>0)\n\t\t\tfactors.push_back({prime,exp});\n\t}\n\tif (n != 1) factors.push_back({n,1});\n\treturn factors;\n}\n\nconstexpr ll M = 1e9+7;\n\nstruct S{\n\tll div, children, divsum;\n\tll x=0;\n};\nvector divisors(const Fs &fs){\n\tvector ds{{1,1,1}}; // pair\n\tds.reserve(accumulate(fs.begin(),fs.end(),1, [](ll a,auto f){return a*(f.exp+1);}));\n\tfor(auto f : fs)\n\t\tfor(auto d : ds){\n\t\t\tll sumpow = 1;\n\t\t\tll pow = 1;\n\t\t\tfor(ll i = 0; i < f.exp; ++i){\n\t\t\t\tpow *= f.prime;\n\t\t\t\tsumpow += pow;\n\t\t\t\tds.push_back({d.div*pow, d.children*(i+2), d.divsum * sumpow});\n\t\t\t}\n\t\t}\n\treturn ds;\n}\n\n\nvi fac;\n\nll binom(ll a, ll b){\n\tll ans;\n\tif(b <0 || b>a) ans=0;\n\telse ans = fac[a] * mod_inverse(fac[b] * fac[a-b] % M, M) %M;\n\tLog(\"binom\",a,b,ans);\n\treturn ans;\n}\n\nint main(){\n\tios_base::sync_with_stdio(false); cin.tie(nullptr);\n\n\tsieve();\n\n\tfac.resize(1000001);\n\tfac[0] = 1;\n\tREP(i,1000000)\n\t\tfac[i+1] = (i+1)*fac[i] % M;\n\n\tll n,k,q; cin >> n >> k >> q;\n\tvi div(1000001,0);\n\n\tll ans = 0;\n\tREP(i,n+q){\n\t\tll c; cin >> c;\n\t\tLog(\"read \",c);\n\t\tauto fs = factor(c);\n\t\tauto divs = divisors(fs);\n\t\tLog(\"divisors, divsum,children\");\n\t\tfor(auto x : divs){\n\t\t\tLog(x.div, x.divsum, x.children);\n\t\t}\n\n\n\t\tfor(auto it=divs.rbegin(); it!=divs.rend(); ++it){\n\t\t\tll val = it->div;\n\t\t\tll children = it->children;\n\t\t\tll divsum = it->divsum;\n\t\t\tLog(\"val\",val, \"children\",children,\"div\",div[val]);\n\t\t\tll a = binom(div[val],k-1);\n\t\t\tll b = a - it->x;\n\t\t\t// add for current\n\t\t\tans += val*b%M;\n\t\t\tLog(a, b, \"add\", val*b);\n\t\t\t//ans -= (divsum-val)*a%M;\n\t\t\tfor(ll i = 0; divs[i].div != val; ++i)\n\t\t\t\tif(val % divs[i].div == 0)\n\t\t\t\t\tdivs[i].x += b;\n\n\t\t\t++div[val];\n\t\t}\n\n\t\tLog(\"ANS:\");\n\t\tif(i>=n)\n\t\t\tcout << ans << \"\\n\";\n\n\t}\n\n\treturn 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "94fea88e5941fdcae040e1611ffeb429", "src_uid": "edf8b780f4e3c610fd6a5ba041a7799c", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "\n#define HEADER_H\n//#define _GLIBCXX_DEBUG\n#include \n#define REP(i,n)\tfor(auto i=decltype(n)(0); i<(n); ++i)\n#define all(v)\t\tbegin(v), end(v)\nusing namespace std;\t\tusing ull= unsigned long long;\nusing ll = long long;\t\tusing ld = long double;\nusing vi = vector;\t\tusing vvi= vector;\nusing vb = vector;\tusing ii = pair;\nconstexpr bool LOG = false;\nvoid Log() { if(LOG) cerr << \"\\n\"; }\ntemplate void Log(T t, S... s){\n\tif(LOG) cerr << t << \"\\t\", Log(s...);\n} /* ============== END OF HEADER ============== */\n\n\nll gcd(ll a, ll b) { while (b) { a %= b; swap(a, b); } return a; }\nll lcm(ll a, ll b) { return (a / gcd(a, b)) * b;\t\t\t\t }\nll mod(ll a, ll b) { return ((a % b) + b) % b;\t\t\t\t }\n\n// Finds x, y s.t. ax + by = d = gcd(a, b).\nvoid extended_euclid(ll a, ll b, ll &x, ll &y, ll &d) {\n\tll xx = y = 0;\n\tll yy = x = 1;\n\twhile (b) {\n\t\tll q = a / b;\n\t\tll t = b; b = a % b; a = t;\n\t\tt = xx; xx = x - q * xx; x = t;\n\t\tt = yy; yy = y - q * yy; y = t;\n\t}\n\td = a;\n}\n\n// solves ab = 1 (mod n), -1 on failure\nll mod_inverse(ll a, ll n) {\n\tll x, y, d;\n\textended_euclid(a, n, x, y, d);\n\treturn (d > 1 ? -1 : mod(x, n));\n}\n\n// (a*b)%m\nll mulmod(ll a, ll b, ll m){\n\tll x = 0, y=a%m;\n\twhile(b>0){\n\t\tif(b&1)\n\t\t\tx = (x+y)%m;\n\t\ty = (2*y)%m;\n\t\tb/=2;\n\t}\n\treturn x % m;\n}\n\nll pow(ll b, ll e) {\t\t// b^e in logarithmic time\n\tll p = e<2 ? 1 : pow(b*b,e/2);\n\treturn e&1 ? p*b : p;\n}\n\n// Finds b^e % m in O(lg n) time, ensure that b < m to avoid overflow!\nll powmod(ll b, ll e, ll m) {\n\tll p = e<2 ? 1 : powmod((b*b)%m,e/2,m);\n\treturn e&1 ? p*b%m : p;\n}\n\n// Solve ax + by = c, returns false on failure.\nbool linear_diophantine(ll a, ll b, ll c, ll &x, ll &y) {\n\tll d = gcd(a, b);\n\tif (c % d) {\n\t\treturn false;\n\t} else {\n\t\tx = c / d * mod_inverse(a / d, b / d);\n\t\ty = (c - a * x) / b;\n\t\treturn true;\n\t}\n}\n\n// Solves x = a1 mod m1, x = a2 mod m2, x is unique modulo lcm(m1, m2).\n// Returns {0, -1} on failure, {x, lcm(m1, m2)} otherwise.\npair crt(ll a1, ll m1, ll a2, ll m2) {\n\tll s, t, d;\n\textended_euclid(m1, m2, s, t, d);\n\tif (a1 % d != a2 % d) return {0, -1};\n\treturn {mod(s * a2 * m1 + t * a1 * m2, m1 * m2) / d, m1 / d * m2};\n}\n\n// Solves x = ai mod mi. x is unique modulo lcm mi.\n// Returns {0, -1} on failure, {x, lcm mi} otherwise.\npair crt(vector &a, vector &m) {\n\tpair res = {a[0], m[0]};\n\tfor (ull i = 1; i < a.size(); ++i) {\n\t\tres = crt(res.first, res.second, mod(a[i], m[i]), m[i]);\n\t\tif (res.second == -1) break;\n\t}\n\treturn res;\n}\n\n\nll SIZE;\nvector bs;\nvector primes;\n\nvoid sieve(ll size = 1e6+10) { // call at start in main!\n\tSIZE = size; bs.assign(SIZE+1,1);\n\tbs[0] = bs[1] = 0;\n\tfor (ll i = 2; i <= SIZE; i++) if (bs[i]) {\n\t\tfor (ll j = i * i; j <= SIZE; j += i) bs[j] = 0;\n\t\tprimes.push_back(i);\n\t}\n}\n\nbool is_prime(ll n) { // for N <= SIZE^2\n\tif (n <= SIZE) return bs[n];\n\tfor(const auto &prime : primes)\n\t \tif (n % prime == 0) return false;\n\treturn true;\n}\n\nstruct Factor{ll prime; ll exp;}; using Fs = vector;\nFs factor(ll n) {\n\tFs factors;\n\tfor(const auto &prime : primes){\n\t\tif(n==1 || prime*prime > n) break;\n\t\tll exp=0;\n\t\twhile(n % prime == 0)\n\t\t \tn/=prime, exp++;\n\t\tif(exp>0)\n\t\t\tfactors.push_back({prime,exp});\n\t}\n\tif (n != 1) factors.push_back({n,1});\n\treturn factors;\n}\n\nconstexpr ll M = 1e9+7;\n\nstruct S{\n\tll div, children, divsum;\n\tll x=0;\n};\nvector divisors(const Fs &fs){\n\tvector ds{{1,1,1}}; // pair\n\tds.reserve(accumulate(fs.begin(),fs.end(),1, [](ll a,auto f){return a*(f.exp+1);}));\n\tfor(auto f : fs)\n\t\tfor(auto d : ds){\n\t\t\tll sumpow = 1;\n\t\t\tll pow = 1;\n\t\t\tfor(ll i = 0; i < f.exp; ++i){\n\t\t\t\tpow *= f.prime;\n\t\t\t\tsumpow += pow;\n\t\t\t\tds.push_back({d.div*pow, d.children*(i+2), d.divsum * sumpow});\n\t\t\t}\n\t\t}\n\treturn ds;\n}\n\n\nvi fac;\n\nll binom(ll a, ll b){\n\tll ans;\n\tif(b <0 || b>a) ans=0;\n\telse ans = fac[a] * mod_inverse(fac[b] * fac[a-b] % M, M) %M;\n\tLog(\"binom\",a,b,ans);\n\treturn ans;\n}\n\nint main(){\n\tios_base::sync_with_stdio(false); cin.tie(nullptr);\n\n\tsieve();\n\n\tfac.resize(1000001);\n\tfac[0] = 1;\n\tREP(i,1000000)\n\t\tfac[i+1] = (i+1)*fac[i] % M;\n\n\tll n,k,q; cin >> n >> k >> q;\n\tvi div(1000001,0);\n\n\tll ans = 0;\n\tREP(i,n+q){\n\t\tll c; cin >> c;\n\t\tLog(\"read \",c);\n\t\tauto fs = factor(c);\n\t\tauto divs = divisors(fs);\n\t\tLog(\"divisors, divsum,children\");\n\t\tfor(auto x : divs){\n\t\t\tLog(x.div, x.divsum, x.children);\n\t\t}\n\n\n\t\tfor(auto it=divs.rbegin(); it!=divs.rend(); ++it){\n\t\t\tll val = it->div;\n\t\t\tll children = it->children;\n\t\t\tll divsum = it->divsum;\n\t\t\tLog(\"val\",val, \"children\",children,\"div\",div[val]);\n\t\t\tll a = binom(div[val],k-1);\n\t\t\tll b = a - it->x;\n\t\t\t// add for current\n\t\t\tans += val*b%M;\n\t\t\tLog(a, b, \"add\", val*b);\n\t\t\t//ans -= (divsum-val)*a%M;\n\t\t\tfor(ll i = 0; divs[i].div != val; ++i)\n\t\t\t\tif(val % divs[i].div == 0)\n\t\t\t\t\tdivs[i].x += b;\n\n\t\t\t++div[val];\n\t\t}\n\n\t\tLog(\"ANS:\");\n\t\tif(i>=n)\n\t\t\tcout << ans << \"\\n\";\n\n\t}\n\n\treturn 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4d7673646c1dd057e75d79d65ff905b9", "src_uid": "edf8b780f4e3c610fd6a5ba041a7799c", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "\n#define HEADER_H\n//#define _GLIBCXX_DEBUG\n#include \n#define REP(i,n)\tfor(auto i=decltype(n)(0); i<(n); ++i)\n#define all(v)\t\tbegin(v), end(v)\nusing namespace std;\t\tusing ull= unsigned long long;\nusing ll = long long;\t\tusing ld = long double;\nusing vi = vector;\t\tusing vvi= vector;\nusing vb = vector;\tusing ii = pair;\nconstexpr bool LOG = false;\nvoid Log() { if(LOG) cerr << \"\\n\"; }\ntemplate void Log(T t, S... s){\n\tif(LOG) cerr << t << \"\\t\", Log(s...);\n} /* ============== END OF HEADER ============== */\n\n\nll gcd(ll a, ll b) { while (b) { a %= b; swap(a, b); } return a; }\nll lcm(ll a, ll b) { return (a / gcd(a, b)) * b;\t\t\t\t }\nll mod(ll a, ll b) { return ((a % b) + b) % b;\t\t\t\t }\n\n// Finds x, y s.t. ax + by = d = gcd(a, b).\nvoid extended_euclid(ll a, ll b, ll &x, ll &y, ll &d) {\n\tll xx = y = 0;\n\tll yy = x = 1;\n\twhile (b) {\n\t\tll q = a / b;\n\t\tll t = b; b = a % b; a = t;\n\t\tt = xx; xx = x - q * xx; x = t;\n\t\tt = yy; yy = y - q * yy; y = t;\n\t}\n\td = a;\n}\n\n// solves ab = 1 (mod n), -1 on failure\nll mod_inverse(ll a, ll n) {\n\tll x, y, d;\n\textended_euclid(a, n, x, y, d);\n\treturn (d > 1 ? -1 : mod(x, n));\n}\n\n// (a*b)%m\nll mulmod(ll a, ll b, ll m){\n\tll x = 0, y=a%m;\n\twhile(b>0){\n\t\tif(b&1)\n\t\t\tx = (x+y)%m;\n\t\ty = (2*y)%m;\n\t\tb/=2;\n\t}\n\treturn x % m;\n}\n\nll pow(ll b, ll e) {\t\t// b^e in logarithmic time\n\tll p = e<2 ? 1 : pow(b*b,e/2);\n\treturn e&1 ? p*b : p;\n}\n\n// Finds b^e % m in O(lg n) time, ensure that b < m to avoid overflow!\nll powmod(ll b, ll e, ll m) {\n\tll p = e<2 ? 1 : powmod((b*b)%m,e/2,m);\n\treturn e&1 ? p*b%m : p;\n}\n\n// Solve ax + by = c, returns false on failure.\nbool linear_diophantine(ll a, ll b, ll c, ll &x, ll &y) {\n\tll d = gcd(a, b);\n\tif (c % d) {\n\t\treturn false;\n\t} else {\n\t\tx = c / d * mod_inverse(a / d, b / d);\n\t\ty = (c - a * x) / b;\n\t\treturn true;\n\t}\n}\n\n// Solves x = a1 mod m1, x = a2 mod m2, x is unique modulo lcm(m1, m2).\n// Returns {0, -1} on failure, {x, lcm(m1, m2)} otherwise.\npair crt(ll a1, ll m1, ll a2, ll m2) {\n\tll s, t, d;\n\textended_euclid(m1, m2, s, t, d);\n\tif (a1 % d != a2 % d) return {0, -1};\n\treturn {mod(s * a2 * m1 + t * a1 * m2, m1 * m2) / d, m1 / d * m2};\n}\n\n// Solves x = ai mod mi. x is unique modulo lcm mi.\n// Returns {0, -1} on failure, {x, lcm mi} otherwise.\npair crt(vector &a, vector &m) {\n\tpair res = {a[0], m[0]};\n\tfor (ull i = 1; i < a.size(); ++i) {\n\t\tres = crt(res.first, res.second, mod(a[i], m[i]), m[i]);\n\t\tif (res.second == -1) break;\n\t}\n\treturn res;\n}\n\n\nll SIZE;\nvector bs;\nvector primes;\n\nvoid sieve(ll size = 1e6+10) { // call at start in main!\n\tSIZE = size; bs.assign(SIZE+1,1);\n\tbs[0] = bs[1] = 0;\n\tfor (ll i = 2; i <= SIZE; i++) if (bs[i]) {\n\t\tfor (ll j = i * i; j <= SIZE; j += i) bs[j] = 0;\n\t\tprimes.push_back(i);\n\t}\n}\n\nbool is_prime(ll n) { // for N <= SIZE^2\n\tif (n <= SIZE) return bs[n];\n\tfor(const auto &prime : primes)\n\t \tif (n % prime == 0) return false;\n\treturn true;\n}\n\nstruct Factor{ll prime; ll exp;}; using Fs = vector;\nFs factor(ll n) {\n\tFs factors;\n\tfor(const auto &prime : primes){\n\t\tif(n==1 || prime*prime > n) break;\n\t\tll exp=0;\n\t\twhile(n % prime == 0)\n\t\t \tn/=prime, exp++;\n\t\tif(exp>0)\n\t\t\tfactors.push_back({prime,exp});\n\t}\n\tif (n != 1) factors.push_back({n,1});\n\treturn factors;\n}\n\nconstexpr ll M = 1e9+7;\n\nstruct S{\n\tll div, children, divsum, x;\n};\nvector divisors(const Fs &fs){\n\tvector ds{{1,1,1,0}}; // pair\n\tds.reserve(accumulate(fs.begin(),fs.end(),1, [](ll a,auto f){return a*(f.exp+1);}));\n\tfor(auto f : fs)\n\t\tfor(auto d : ds){\n\t\t\tll sumpow = 1;\n\t\t\tll pow = 1;\n\t\t\tfor(ll i = 0; i < f.exp; ++i){\n\t\t\t\tpow *= f.prime;\n\t\t\t\tsumpow += pow;\n\t\t\t\tds.push_back({d.div*pow, d.children*(i+2), d.divsum * sumpow,0});\n\t\t\t}\n\t\t}\n\treturn ds;\n}\n\n\nvi fac;\n\nll binom(ll a, ll b){\n\tll ans;\n\tif(b <0 || b>a) ans=0;\n\telse ans = fac[a] * mod_inverse(fac[b] * fac[a-b] % M, M) %M;\n\tLog(\"binom\",a,b,ans);\n\treturn ans;\n}\n\nint main(){\n\tios_base::sync_with_stdio(false); cin.tie(nullptr);\n\n\tsieve();\n\n\tfac.resize(1000001);\n\tfac[0] = 1;\n\tREP(i,1000000)\n\t\tfac[i+1] = (i+1)*fac[i] % M;\n\n\tll n,k,q; cin >> n >> k >> q;\n\tvi div(1000001,0);\n\n\tll ans = 0;\n\tREP(i,n+q){\n\t\tll c; cin >> c;\n\t\tLog(\"read \",c);\n\t\tauto fs = factor(c);\n\t\tauto divs = divisors(fs);\n\t\tLog(\"divisors, divsum,children\");\n\t\tfor(auto x : divs){\n\t\t\tLog(x.div, x.divsum, x.children);\n\t\t}\n\n\n\t\tfor(auto it=divs.rbegin(); it!=divs.rend(); ++it){\n\t\t\tll val = it->div;\n\t\t\tll children = it->children;\n\t\t\tll divsum = it->divsum;\n\t\t\tLog(\"val\",val, \"children\",children,\"div\",div[val]);\n\t\t\tll a = binom(div[val],k-1);\n\t\t\tll b = a - it->x;\n\t\t\t// add for current\n\t\t\tans += val*b%M;\n\t\t\tLog(a, b, \"add\", val*b);\n\t\t\t//ans -= (divsum-val)*a%M;\n\t\t\tfor(ll i = 0; divs[i].div != val; ++i)\n\t\t\t\tif(val % divs[i].div == 0)\n\t\t\t\t\tdivs[i].x += b;\n\n\t\t\t++div[val];\n\t\t}\n\n\t\tLog(\"ANS:\");\n\t\tif(i>=n)\n\t\t\tcout << ans << \"\\n\";\n\n\t}\n\n\treturn 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "19fdf61780b71f5de0e021d256ea363b", "src_uid": "edf8b780f4e3c610fd6a5ba041a7799c", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "\n#include \n#define int long long\n#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; ++i)\n#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; --i)\n#define REP(i,a) for(int i=0,_a=(a); i < _a; ++i)\n\n#define DEBUG(X) { cout << #X << \" = \" << (X) << endl; }\n#define PR(A,n) { cout << #A << \" = \"; FOR(_,1,n) cout << A[_] << ' '; cout << endl; }\n#define PR0(A,n) { cout << #A << \" = \"; REP(_,n) cout << A[_] << ' '; cout << endl; }\n\n#define sqr(x) ((x) * (x))\n#define ll long long\n#define SZ(x) ((int) (x).size())\n#define div div____\nusing namespace std;\n\nconst int MN = 2000111;\nint n, k, q;\nint a[MN], sieve[MN];\n\nvoid init() {\n FOR(i,2,1000) if (!sieve[i]) {\n for(int j = i*i; j < MN; j += i)\n sieve[j] = i;\n }\n}\n\nint dp[111], dk[111];\nvector div;\nvoid attempt(int i, int nd, int prod) {\n if (i > nd) {\n div.push_back(prod);\n return ;\n }\n int cur = 1;\n FOR(power,0,dk[i]) {\n attempt(i+1, nd, prod * cur);\n cur *= dp[i];\n }\n}\nvector divisors(int x) {\n int nd = 0;\n while (x > 1) {\n int p = (sieve[x] ? sieve[x] : x);\n ++nd;\n dp[nd] = p;\n dk[nd] = 0;\n while (x % p == 0) {\n x /= p;\n ++dk[nd];\n }\n }\n div.clear();\n attempt(1, nd, 1);\n return div;\n}\n\nconst int MOD = 1e9 + 7;\nint res[MN];\nvector ls[MN];\n\nvoid resetAll() {\n memset(res, 0, sizeof res);\n REP(i,MN) ls[i].clear();\n}\n\nint add[MN], gt[MN], inv_gt[MN];\n\nint power(int x, int k) {\n if (k == 0) return 1;\n if (k == 1) return x % MOD;\n\n int mid = power(x, k >> 1);\n mid = mid * mid % MOD;\n\n if (k & 1) return mid * x % MOD;\n return mid;\n}\nint inverse(int x) {\n return power(x, MOD - 2);\n}\n\nint C(int n, int k) {\n return gt[n] * inv_gt[k] % MOD * inv_gt[n-k] % MOD;\n}\n\n#undef int\nint main() {\n#define int long long\n ios :: sync_with_stdio(0); cin.tie(0);\n init();\n\n gt[0] = 1; FOR(i,1,MN-1) gt[i] = gt[i-1] * i % MOD;\n REP(i,MN) inv_gt[i] = inverse(gt[i]);\n\n while (scanf(\"%lld%lld%lld\", &n, &k, &q) == 3) {\n FOR(i,1,n+q) scanf(\"%lld\", &a[i]);\n resetAll();\n\n FOR(i,1,n+q) {\n auto d = divisors(a[i]);\n for(int x : d) {\n ls[x].push_back(i);\n }\n }\n FOR(g,1,1000*1000) {\n add[g] = g;\n auto d = divisors(g);\n for(int x : d) if (x < g) {\n add[g] = add[g] - add[x];\n }\n\n FOR(i,k-1,SZ(ls[g])-1) {\n int u = ls[g][i];\n res[u] = (res[u] + C(i, k-1) * add[g]) % MOD;\n }\n }\n FOR(i,1,n+q) {\n res[i] = (res[i-1] + res[i]) % MOD;\n }\n FOR(i,n+1,n+q) printf(\"%lld\\n\", res[i]);\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "70e3390f875347113ce9057dcd30ad24", "src_uid": "edf8b780f4e3c610fd6a5ba041a7799c", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\n#define int long long\n\nsigned main(){\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n\n int n;\n cin >> n;\n\n vector a(n);\n for (int& x : a)\n cin >> x;\n\n vector cnt(44);\n vector step(44);\n int p2 = 1, o2 = 0;\n for (int i = 0; i < n; i++){\n while (p2*2 <= a[i]) {\n p2 *= 2;\n o2 += 1;\n }\n if (p2 == a[i])\n step[o2]++;\n else\n cnt[o2]++;\n\n int c = 0;\n while (!(x&1)){\n x >>= 1;\n c++;\n }\n if (x != 1){\n cnt[o2]++;\n }\n else{\n step[c]++;\n }\n }\n/*\n for (int i : step) cerr << i << ' ';\n cerr << endl;\n for (int i : cnt) cerr << i << ' ';\n cerr << endl;\n*/\n\n vector ans;\n for (int i = 1; i <= step[0]; i++){\n vector t(44);\n vector ost(44);\n ost = cnt;\n ost[0] += step[0] - i;\n int b = i;\n for (int j = 1; j < 44; j++){\n int m = step[j];\n int mini = min(b, m);\n t[j - 1] = b - mini;\n ost[j] += m - mini;\n b = mini;\n }\n\n /*for (int i : t) cerr << i << ' ';\n cerr << endl;\n for (int i : ost) cerr << i << ' ';\n cerr << endl;*/\n\n bool f = false;\n int s1 = 0;\n int s2 = 0;\n for (int j = 0; j < 44; j++){\n s2 += t[j];\n s2 -= ost[j];\n }\n if (s2 < 0)\n continue;\n s1 = s2;\n s2 = 0;\n int j = 0;\n while (j < 44){\n s1 += ost[j];\n s2 += t[j];\n if (s1 < s2){\n f = true;\n break;\n }\n j++;\n }\n if (s1 > i)\n f = true;\n if (!f){\n ans.push_back(i);\n }\n }\n\n for (int& x : ans)\n cout << x << ' ';\n\n if (ans.size() == 0)\n cout << -1;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1f72a92aa335fe38d7e529443757b2ef", "src_uid": "fc29e8c1a9117c1dd307131d852b6088", "difficulty": 2200.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define pb push_back\n#define ll long long\n#define mp make_pair\n#define f first\n#define s second\n#define pii pair < int, int >\n#define ull unsigned long long\n#define pll pair < ll, ll >\n#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)\n#define all(s) s.begin(), s.end()\n#define sz(a) (int)a.size()\n\nconst int inf = (1ll << 30) - 1;\nconst int maxn = (int) 1e5 + 10;\n\nusing namespace std;\n\nint n;\nll a[200100];\nll bb[165];\nint used[200100];\nint cnt[200100];\nvoid solve(){\n\tscanf(\"%d\", &n);\n\tfor(int i = 0; i < n; i++){\n\t\tscanf(\"%I64d\", &a[i]);\n\t}\n\tbb[0] = 1;\n\tfor(int i = 1; i < 55; i++){\n\t\tbb[i] = bb[i-1] * 2;\n\t}\n\tint it = 0;\n\tvector b;\n\tmap good;\n\tfor(int i = 0; i < n; ){\n\t\twhile(i < n && bb[it] > a[i]) {\n\t\t\tb.pb(a[i]);\n\t\t\ti++;\n\t\t}\n\t\twhile(i < n && bb[it] == a[i]) {\n\t\t\tcnt[it]++;\n\t\t\ti++;\n\t\t}\n\t\tit++;\n\t}\n\tint C = 0;\n\tint T = 0;\n\tint ind = (int)b.size();\n\t--ind;\n\tint A = 0;\n\tfor(int i = 53; i >= 0; i--){\n\t\twhile(cnt[i] > 0){\n\t\t\tint j = i;\n\t\t\twhile(j >= 0 && cnt[j] > 0 ) j--;\n\t\t\tif(j >= 0) break;\n\t\t\tfor(int k = 0; k <= i; k++){\n\t\t\t\tcnt[k]--;\n\t\t\t\tC++;\n\t\t\t}\n\t\t\tT++;\n\t\t\tA++;\n\t\t\tif(ind >= 0 &&T>0&& b[ind] <= (1ll< 0){\n\t\t\tif(b[ind+1] > (1ll< 0 && cnt[i] > 0){\n\t\t\tT--;\n\t\t\tcnt[i]--;\n\t\t\tC++;\n\t\t}\n\t\twhile(T > 0 && ind >= 0){\n\t\t\tif(b[ind] >= (1ll< 0){\n\t\t\tprintf(\"-1\\n\");\n\t\t\treturn;\n\t\t}\n\t}\n\n\tvector ans;\n\tfor(int i = 1; i<=100010; i++)\n\t\tif(used[i]) ans.pb(i);\n\tif(ans.size() == 0) printf(\"-1\\n\");\n\telse{\n\t\tfor(int i = 0; i < ans.size(); i++){\n\t\t\tif(i > 0) printf(\" \");\n\t\t\tprintf(\"%d\", ans[i]);\n\t\t}\n\t\tprintf(\"\\n\");\n\t}\n}\n\nint main () {\n\t#ifdef LOCAL\n\tfreopen(\"a.in\", \"r\", stdin);\n\tfreopen(\"a.out\", \"w\", stdout);\n\t#endif\n int t=1;\n //scanf(\"%d\", &t);\n for(int i=1; i <= t; i++){\n //printf(\"Case #%d\\n\", i);\n solve();\n }\n\n return 0;\n}\nclose", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7d498bd4d939153fda9649ef2db39fe1", "src_uid": "fc29e8c1a9117c1dd307131d852b6088", "difficulty": 2200.0} {"lang": "GNU C++14", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n\nusing namespace std;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\ntypedef long long li;\ntypedef pair pt;\ntypedef long double ld;\n\n#define forn(i, n) for (int i = 0; i < int(n); i++)\n#define sqr(a) ((a) * (a))\n#define x first\n#define y second\n#define pb push_back\n#define mp make_pair\n#define sz(a) (int(a.size()))\n#define all(a) a.begin(), a.end()\n\nconst int INF = int(1e9);\nconst li INF64 = INF * 1ll * INF;\nconst ld PI = acosl(-1.0);\nconst int MOD = INF + 7;\nconst ld EPS = 1e-9;\n\nvector

  • a;\nint n;\nint cntdeg[60];\n\nint maxdeg(li x)\n{\n\tint ans = 0;\n\twhile (x)\n\t{\n\t\t\n\t\tx = ((x == 1 ? x : x + 1)) / 2;\n\t\tif (x) ans++;\n\t}\n\treturn ans;\n}\n\nbool check(int x)\n{\n\tforn(i, 60) cntdeg[i] = 0;\n\tint cntlast = x;\n\tint cntcur = 0;\n\tli deglast = 1;\n\tint curdeg = 0;\n\tvector
  • rem;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tif (a[i] == deglast)\n\t\t{\n\t\t\tif (cntcur == cntlast)\n\t\t\t{\n\t\t\t\trem.push_back(a[i]);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcntcur++;\n\t\t\t}\n\t\t}\n\t\telse if (a[i] > deglast)\n\t\t{\n\t\t\tdeglast <<= 1ll;\n\t\t\tif (a[i] > deglast)\n\t\t\t\treturn false;\n\t\t\tcntdeg[curdeg] = cntcur;\n\t\t\tcntlast = cntcur;\n\t\t\tcurdeg++;\n\t\t\tcntcur = 0;\n\t\t\tif (a[i] == deglast && cntcur < cntlast)\n\t\t\t\tcntcur++;\n\t\t\telse\n\t\t\t\trem.push_back(a[i]);\n\t\t}\n\t\telse\n\t\t{\n\t\t\trem.push_back(a[i]);\n\t\t}\n\t}\n\tcntdeg[curdeg] = cntcur;\n\tcntlast = cntcur;\n\tcurdeg++;\n\tcntcur = 0;\n\tint lastcnt = 0;\n\tfor (int i = 1; i < 60; i++)\n\t\tcntdeg[i - 1] -= cntdeg[i];\n\tfor (auto z : rem)\n\t{\n\t\twhile (lastcnt < 60 && (cntdeg[lastcnt] == 0 || maxdeg(z) > lastcnt + 1))\n\t\t\tlastcnt++;\n\t\tif (lastcnt == 60)\n\t\t\treturn false;\n\t\tcntdeg[lastcnt]--;\n\t}\n\treturn true;\n}\n\nint main() {\n#ifdef _DEBUG\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif\n\tscanf(\"%d\", &n);\n\ta.resize(n);\n\tforn(i, n)\n\t\tscanf(\"%lld\", &a[i]);\n\tif(n == 2 && a[0] == 1 && a[1] == 1) {\n\t puts(\"1 2\");\n\t return;\n\t}\n\tint cnt1 = 0;\n\tforn(i, n)\n\t\tif (a[i] == 1)\n\t\t\tcnt1++;\n\tif (!check(cnt1))\n\t{\n\t\tputs(\"-1\");\n\t\treturn 0;\n\t}\n\tint l = 1;\n\tint r = cnt1;\n\twhile (r > l + 1)\n\t{\n\t\tint mid = (l + r) >> 1;\n\t\tif (check(mid))\n\t\t\tr = mid;\n\t\telse\n\t\t\tl = mid;\n\t}\n\tfor (int i = r; i <= cnt1; i++)\n\t\tprintf(\"%d \", i);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3f5a94d859ffb402cd12db7cd88212ed", "src_uid": "fc29e8c1a9117c1dd307131d852b6088", "difficulty": 2200.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\n\nset solve(vector a) {\n int n = a.size();\n vector> v;\n ll cur = 1;\n ll nxt = 2;\n v.push_back(make_pair(0, 0));\n for (int i = 0; i < n; i++) {\n ll x;\n x = a[i];\n while (1) {\n if (x == cur) {\n v.back().first++;\n break;\n }\n if (x < nxt) {\n v.back().second++;\n break;\n }\n v.push_back(make_pair(0, 0));\n cur *= 2;\n nxt *= 2;\n }\n }\n\n v.push_back(make_pair(0, 0));\n vector b;\n while (1) {\n int x = 0;\n for (int i = 0; i < v.size(); i++) {\n if (v[i].first == 0) {\n x = i;\n break;\n }\n v[i].first--;\n }\n if (x == 0) break;\n b.push_back(x);\n }\n int last = 0;\n vector ans;\n for (int i = (int)v.size() - 1; i >= 0; i--) {\n while (v[i].first + v[i].second != 0) {\n if (last >= b.size()) {\n cout << -1;\n return 0;\n }\n if (i > b[last]) {\n cout << -1;\n return 0;\n }\n if (v[i].first) v[i].first--;\n else v[i].second--;\n last++;\n }\n }\n ans.push_back(b.size());\n while (1) {\n v[0].second += b.back();\n b.pop_back();\n for (int i = 0; i >= 0; i--) {\n while (v[i].first + v[i].second != 0) {\n if (last >= b.size()) {\n goto end;\n }\n if (v[i].first) v[i].first--;\n else v[i].second--;\n last++;\n }\n }\n ans.push_back(b.size());\n }\n end:;\n}\n\nint main() {\n#ifdef XXX\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif\n \n \n sort(ans.begin(), ans.end());\n for (auto el : ans) cout << el << \" \";\n \n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1db728dacff3336a12d5cdbe31ae05db", "src_uid": "fc29e8c1a9117c1dd307131d852b6088", "difficulty": 2200.0} {"lang": "GNU C++", "source_code": "//abo masteriiiiii\n#include\nusing namespace std;\nint main(){\n int n,x1,y1,x2,y2,ans=0;\n cin>>n>>x1>>y1>>x2>>y2;\n while(x1!=x2||y1!=y2){\n if(x1==0)\n if(y1==n)\n x1++;\n else\n y1++;\n else if(x1==n)\n if(y1==0)\n x1--;\n else\n y1--;\n else if(y1==0)\n if(x1==0)\n y1++;\n else\n x1--;\n else if(y1==n)\n if(x1==n)\n y1--;\n else\n x1++;\n ans++;\n }\n cout<\nusing namespace std;\n\nint main(){\n int n,x1,y1,x2,y2;\n cin>>n>>x1>>y1>>x2>>y2;\n int ans=INT_MAX;\n if(abs(x1-x2)==n){\n int y_1=n-y1;\n int y_2=y1;\n int y_3=n-y2;\n int y_4=y2;\n int y=min(y_2+y_4,y_1+y_3);\n cout<\n\nint min(int a,int b)\n{\n return a>n>>x1>>y1>>x2>>y2;\n std::cout<\n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\nint N, X[5], Y[5];\n\nint To(int x, int y){\n\tint res = 0;\n\tfor (int i = 0; i < 2; i ++){\n\t\tint tmpx = X[i], tmpy = Y[i];\t\n\t\tif (tmpx != x) res += abs(x - tmpx);\n\t\ttmpx = x;\n\t\tif (tmpy != y) res += abs(y - tmpy);\n\t\ttmpy = y;\n\t}\n\treturn res;\n}\n\nint main() {\n\tscanf(\"%d%d%d%d%d\",&N, &X[0], &Y[0], &X[1], &Y[1]);\n\tint Ans = min(min(To(0, 0), To(0, N)), min(To(N, 0), To(N, N))); \n\tif (X[0] == X[1]) Ans = min(Ans, abs(Y[0] - Y[1]));\n\tif (Y[0] == Y[1]) Ans = min(Ans, abs(X[0] - X[1]));\n\tprintf(\"%d\\n\", Ans);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ecd9e9d0cf336321ba86a46cccb6c020", "src_uid": "685fe16c217b5b71eafdb4198822250e", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include\nint n;\nint main(){\n\tscanf(\"%d\",&n);\n\tif(i==1||i==4||i==6||i==8||i==9||i==10||i==13||i==15) printf(\"1\");\n\telse printf(\"0\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7375499aa4fed63413bc739218c0c6f6", "src_uid": "6f9767b63a01424f939d85b597cf42f3", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \n#include \nstring s = \"1001010111001010\"; \nint main(){ \n int n; \n scanf(\"%d\", &n); \n printf(\"%c\\n\", s[n - 1]); \n return 0; \n} ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "95abae1559bf617b6b789f14ddd744f5", "src_uid": "6f9767b63a01424f939d85b597cf42f3", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint n;\nint main(){\n\tscanf(\"%d\",&n);\n\tif(i==1||i==4||i==6||i==8||i==9||i==10||i==13||i==15) printf(\"1\");\n\telse printf(\"0\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4f3407f0805ba4fa5a1f89185f8c2ae8", "src_uid": "6f9767b63a01424f939d85b597cf42f3", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int n;\n string = \"1001010111001010\";\n cin >> n;\n cout << s[n - 1];\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5915b562c43fd867c1aa19fa3fbde175", "src_uid": "6f9767b63a01424f939d85b597cf42f3", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "using namespace std;\n\nint main()\n{\n int wynik=0;\n int a,b,c,d; // a=wysokosc robaka,b=wysokosc jab\u0142ka,c=predkosc w dzien,d=predkosc noc\u0105\n cin>>a>>b>>c>>d;\n if(d>c)\n {\n int r=0;\n r=b-a;\n if(8*c>r)\n {\n cout<<1;\n }else\n cout<<-1;\n }else\n {\n\n\n int r=0;\n r=b-a;\n r=r-(8*c);\n while(r>0)\n {\n\n r=r-(12*d);\n r=r+(12*c);\n wynik++;\n }\n\n cout<\n\n#define asd(i,n,m) for (int i=n;i=m;i--)\n#define b_s binary_search \n#define ll long long\n#define Pi 3.1415926535\n#define vr vector\n#define pb push_back\n#define sw swap\n\nusing namespace std;\n\nint main()\n{\n\tint b,a,h1,h2;\n\tcin >> h1 >> h2 >> a >> b;\n\tif (h1+a*8>=h2) {cout << 0;return 0;}\n\tif (b>a) {cout << \"-1\";return 0;}\n\th1+=a*8-b*12;\n\tasd (i,1,500000) {\n\t\th1+=a*12;\n\t\tif (h1>=h2) {cout << i;return 0;}\n\t\th1-=b*12;\n\t}\n\treturn 0;\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6b5232f23873e3defb103fc0c0943813", "src_uid": "2c39638f07c3d789ba4c323a205487d7", "difficulty": 1400.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\nint main()\n{\n\tlong long int h1, h2;\n\tlong long int a, b;\n\tlong long int k;\n\tcin >> h1 >> h2;\n\tcin >> a >> b;\n\tif ((b - a) == 0)\n\t{\n\t\tif ((h2 - h1) <= 10)\n\t\t{\n\t\t\tcout << \"0\";\n\t\t\treturn 0;\n\t\t}\n\t\telse\n\t\t{\n\n\t\t\tcout << \"-1\";\n\t\t\treturn 0;\n\t\t}\n\t}\n\telse\n\tif ((a - b) >= 1)\n\t{\n\t\tlong long int sum = h1;\n\t\tlong long int count = 0;\n\t\tfor (int i = 3; i <= 10; i++)\n\t\t{\n\t\t\tsum += a;\n\t\t\tcount++;\n\t\t}\n\t\tif (sum >= h2)\n\t\t{\n\t\t\tcout << \"0\";\n\t\t\treturn 0;\n\t\t}\n\t\tfor (int j = 1; j <= 12; j++)\n\t\t{\n\t\t\tsum -= b;\n\t\t\tcount++;\n\t\t}\n\n\t\tint t = 1;\n\t\twhile (sum < h2)\n\t\t{\n\t\t\twhile (sum < h2 || t <= 12)\n\t\t\t{\n\t\t\t\tsum += a;\n\t\t\t\tt++;\n\t\t\t\tcount++;\n\t\t\t}\n\t\t\tif (sum >= h2)\n\t\t\t{\n\t\t\t\tcout << count / 24;\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tt = 1;\n\t\t\twhile (t <= 12)\n\t\t\t{\n\t\t\t\tsum -= b;\n\t\t\t\tt++;\n\t\t\t\tcount++;\n\t\t\t}\n\t\t}\n\t\tcout << count / 24;\n\t\treturn 0;\n\t}\n\telse\n\tif (a - b < 0)\n\t{\n\t\tif ((b - a) == 1)\n\t\t{\n\t\t\tif ((h2 - h1) <= ((8 * (b - a))))\n\t\t\t{\n\t\t\t\tcout << \"1\";\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\telse\n\t\t\t{\n\t\t\t\tcout << \"-1\";\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tint sum = h1;\n\t\t\tfor (int i = 3; i <= 10; i++)\n\t\t\t{\n\t\t\t\tsum += a;\n\t\t\t}\n\t\t\tif (sum >= h2)\n\t\t\t{\n\t\t\t\tcout << \"0\";\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\n\t\t\t\tcout << \"-1\"\n\t\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2a0d7188c3b931d1b2679fd3d8e432d1", "src_uid": "2c39638f07c3d789ba4c323a205487d7", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include \n\n#define fi(a,b,c) for(int a=b; a<=c; a++)\n#define fd(a,b,c) for(int a=b; a>=c; a--)\n\nusing namespace std;\n\nlong long h1, h2, a, b;\n\nint main()\n{\n cin >> h1 >> h2 ;\n cin >> a >> b;\n if (b >= a){\n if (a * 8 + h1 >= h2) cout <<0<= h2) break;\n h1-= b * 12;\n h1 = max(h1, 0);\n h1+= a * 4;\n if (h1 >= h2) break;\n }\n cout <\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define ll long long\nusing namespace std;\n\nvoid solve() {\n int n;\n cin >> n;\n\n ll l = 1, r=1<<30;\n set s;\n int ret = 0;\n ll b = 0;\n int sign = 1;\n\n for (int i = 0; i < n; i++) {\n i x;\n cin>>x;\n\n if (~x&1) {\n int mid = x / 2;\n if (s.find((mid - b)*sign) != s.end() || (l <= mid && mid <= r)) {\n ret += 2;\n s.clear();\n l = r = mid;\n b=0, sign=1;\n } else {\n ret += 1;\n swap(l, r);\n l = max(x-l, 1);\n r = min(x-r, x-1);\n while (!s.empty()) {\n auto it = s.begin();\n ll u = (*it) * sign + b;\n if (u < 1 || u > x - 1) {\n s.erase(it);\n } else {\n break;\n }\n }\n while (!s.empty()) {\n auto it = s.end();\n it--;\n ll u = (*it) * sign + b;\n if (u < 1 || u > x - 1) {\n s.erase(it);\n } else {\n break;\n }\n }\n\n if (l <= r) {\n s.insert((mid - b)*sign);\n } else {\n l = r = mid;\n }\n\n sign *= -1;\n b = x - b;\n }\n } else {\n swap(l, r);\n l = max(x-l, 1);\n r = min(x-r, x-1);\n while (!s.empty()) {\n auto it = s.begin();\n ll u = (*it) * sign + b;\n if (u < 1 || u > x - 1) {\n s.erase(it);\n } else {\n break;\n }\n }\n while (!s.empty()) {\n auto it = s.end();\n it--;\n ll u = (*it) * sign + b;\n if (u < 1 || u > x - 1) {\n s.erase(it);\n } else {\n break;\n }\n }\n sign *= -1;\n b = x - b;\n\n if (l <= r || !s.empty()) {\n if (l > r) {\n auto it = s.begin();\n l = r = (*it) * sign + b;\n s.erase(it);\n }\n ret++;\n } else {\n l = 1;\n r = x-1;\n sign=1;\n b=0;\n }\n }\n if (l > r) {\n abort();\n }\n }\n\n cout << n * 2 + 1 - ret << endl;\n}\n\nint main() {\n int T = 1;\n //freopen(\"a.in\", \"r\", stdin);\n ios::sync_with_stdio(false);\n cin.tie(0);\n\n cin >> T;\n while (T--) {\n solve();\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "53884e4772aba97bf53d5e0767f4ab64", "src_uid": "e809d068b3ae47eb5ecfb9ac69892254", "difficulty": 3200.0} {"lang": "GNU C++17", "source_code": "#include \n\n\nbool operator!=(const std::pair &a, int b) {\n\treturn a.first != b;\n}\n\ntemplate\nauto set_back(std::set &s) { auto it = s.end(); return --it; }\n\nusing ll = long long;\n\n#define D(...) \nint main() {\n\t//freopen(\"/dev/null\", \"w\", stderr);\n\tstd::cin.tie(nullptr);\n\tstd::cin.sync_with_stdio(false);\n\tstd::cout.sync_with_stdio(false);\n\tint t;\n\tstd::cin >> t;\n\twhile (t--) {\n\t\tD(\n\t\tfor (int i = 0; i != 50; i++) {\n\t\t\tstd::cerr << \"=\";\n\t\t}\n\t\tstd::cerr << \"\\n\";)\n\t\tint n;\n\t\tstd::cin >> n;\n\t\tstd::vector arr(n);\n\t\tfor (int i = 0; i != n; i++) {\n\t\t\tstd::cin >> arr[i];\n\t\t}\n\t\tll last_nums_offset = 0;\n\t\tll last_nums_sign = 1;\n\t\tstd::set last_nums;\n\t\tstd::pair last_range(-1, -1); \n\t\tint ans = 0;\n\t\tfor (int i = 0; i != n; i++) {\n\t\t\tstd::pair curr_range(-1, -1);\n\t\t\tbool found = false;\n\t\t\tif (!found) {\n\t\t\t\tif (arr[i] % 2 == 0) {\n\t\t\t\t\tif ((last_range != -1 && (last_range.first <= (arr[i] / 2)) && ((arr[i] / 2) <= last_range.second))\n\t\t\t\t\t\t|| (last_nums.find((arr[i] / 2) * last_nums_sign - last_nums_offset) != last_nums.end())) {\n\t\t\t\t\t\tfound = 1;\n\t\t\t\t\t\tlast_nums.clear();\n\t\t\t\t\t\tlast_nums.insert((arr[i] / 2) * last_nums_sign - last_nums_offset);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (found) ans += 0;\n\t\t\t\telse {\n\t\t\t\t\t// WEIRD START\n\t\t\t\t\tD(\n\t\t\t\t\tstd::cerr << arr[i] << \"\\n\";\n\t\t\t\t\tstd::cerr << \"sign/offset = \" << last_nums_sign << \" \" << last_nums_offset << \"\\n\";\n\t\t\t\t\tfor (auto it : last_nums) {\n\t\t\t\t\t\tstd::cerr << it << \" \";\n\t\t\t\t\t}\n\t\t\t\t\tstd::cerr << \"\\n\";)\n\t\t\t\t\t//std::pair valid_range = std::make_pair((1 + last_nums_offset) * last_nums_sign, ((arr[i] - 1) + last_nums_offset) * last_nums_sign);\n\t\t\t\t\tstd::pair valid_range(1 * last_nums_sign - last_nums_offset, (arr[i] - 1) * last_nums_sign - last_nums_offset);\n\t\t\t\t\tD(std::cerr << \"range = \" << valid_range.first << \" \" << valid_range.second << \"\\n\";)\n\t\t\t\t\tint valid_ans_cnt = 0;\n\t\t\t\t\tfor (auto it : last_nums) {\n\t\t\t\t\t\tll tmp = (it + last_nums_offset) * last_nums_sign;\n\t\t\t\t\t\tif (0 < tmp && tmp < arr[i]) valid_ans_cnt++;\n\t\t\t\t\t\tasssert(0 < tmp);\n\t\t\t\t\t}\n\t\t\t\t\tif (last_nums_sign == -1) std::swap(valid_range.first, valid_range.second);\n\t\t\t\t\tassert(valid_range.first <= valid_range.second);\n\t\t\t\t\twhile (last_nums.size() && *set_back(last_nums) > valid_range.second) last_nums.erase(set_back(last_nums));\n\t\t\t\t\twhile (last_nums.size() && *last_nums.begin() < valid_range.first) last_nums.erase(last_nums.begin());\n\t\t\t\t\tassert(valid_ans_cnt == last_nums.size());\n\t\t\t\t\tD(\n\t\t\t\t\tstd::cerr << \"sign/offset = \" << last_nums_sign << \" \" << last_nums_offset << \"\\n\";\n\t\t\t\t\tfor (auto it : last_nums) {\n\t\t\t\t\t\tstd::cerr << it << \" \";\n\t\t\t\t\t}\n\t\t\t\t\tstd::cerr << \"\\n\";\n\t\t\t\t\tstd::cerr << \"\\n\";)\n\t\t\t\t\tfor (auto it : last_nums) {\n\t\t\t\t\t\tll tmp = (it + last_nums_offset) * last_nums_sign;\n\t\t\t\t\t\tassert(0 < tmp && tmp < arr[i]);\n\t\t\t\t\t}\n\t\t\t\t\tlast_nums_offset -= arr[i] * last_nums_sign;\n\t\t\t\t\tlast_nums_sign *= -1;\n\t\t\t\t\tif (last_nums.size()) found = 1;\n\t\t\t\t\t// WEIRD END\n\t\t\t\t\tif (arr[i] % 2 == 0) {\n\t\t\t\t\t\tfound = 1;\n\t\t\t\t\t\tlast_nums.insert((arr[i] / 2) * last_nums_sign - last_nums_offset);\n\t\t\t\t\t}\n\t\t\t\t\tif (arr[i] % 2 != 0) {\n\t\t\t\t\t\tif (last_range != -1 && last_range.first < arr[i]) {\n\t\t\t\t\t\t\tfound = 1;\n\t\t\t\t\t\t\tcurr_range = std::make_pair(std::max(arr[i] - last_range.second, 1ll), arr[i] - last_range.first);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (found) ans += 1;\n\t\t\t\t\telse {\n\t\t\t\t\t\tfound = 1;\n\t\t\t\t\t\tassert(last_nums.empty());\n\t\t\t\t\t\tcurr_range = std::make_pair(1, arr[i]-1);\n\t\t\t\t\t\tif (found) ans += 2;\n\t\t\t\t\t\telse assert(false);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tlast_range = curr_range;\n\t\t\tD(std::cerr << \"last_nums = \";\n\t\t\tfor (auto it : last_nums) std::cerr << it << \" \";\n\t\t\tstd::cerr << \"\\n\";\n\t\t\tstd::cerr << \"last range = \" << last_range.first << \" \" << last_range.second << \"\\n\";\n\t\t\tstd::cerr << \"ans = \" << ans << \"\\n\";)\n\t\t\t//std::cerr << curr_num << \" \" << curr_range.first << \" \" << curr_range.second << \"\\n\";\n\t\t}\n\t\tstd::cout << ans << \"\\n\";\n\t\t//std::cerr << \"\\n\";\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "325e49f586723596ab74ebd7cd203fab", "src_uid": "e809d068b3ae47eb5ecfb9ac69892254", "difficulty": 3200.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\ntemplate \nvoid debug_out(T t) {\n cerr << t;\n}\n\ntemplate \nvoid debug_out(pair u) {\n cerr << \"(\" << u.first << \" \" << u.second << \")\";\n}\n\ntemplate \nvoid debug_out(vector t) {\n int sz = t.size();\n for(int i = 0; i < sz; i++) {\n debug_out(t[i]);\n if(i != sz - 1) cerr << \", \";\n }\n}\n\ntemplate \nvoid debug_out(vector> t) {\n int sz = t.size();\n for(int i = 0; i < sz; i++) {\n debug_out(t[i]);\n if(i != sz - 1) cerr << endl;\n }\n}\n\ntemplate \nvoid debug_out(Head H, Tail... T) {\n debug_out(H);\n cerr << \" \";\n debug_out(T...);\n}\n\ntemplate \nvoid debug_out(set a) {\n vector _a;\n for(T t : a) _a.push_back(t);\n debug_out(_a);\n}\n\n#define debug(...) cerr << \"[\" << #__VA_ARGS__ << \"]:\" << endl, debug_out(__VA_ARGS__), cerr << endl;\n\nclass segtree {\n public:\n struct node {\n\n int p = 0;\n\n void apply(int l, int r, int v) {\n p = v;\n }\n };\n\n node unite(const node &a, const node &b) const {\n node res;\n res.p = min(a.p, b.p);\n return res;\n }\n\n inline void push(int x, int l, int r) {\n\n }\n\n inline void pull(int x, int z) {\n tree[x] = unite(tree[x + 1], tree[z]);\n }\n\n int n;\n vector tree;\n\n void build(int x, int l, int r) {\n if (l == r) {\n return;\n }\n int y = (l + r) >> 1;\n int z = x + ((y - l + 1) << 1);\n build(x + 1, l, y);\n build(z, y + 1, r);\n pull(x, z);\n }\n\n template \n void build(int x, int l, int r, const vector &v, const T&... t) {\n if (l == r) {\n tree[x].apply(l, r, v[l], t...);\n return;\n }\n int y = (l + r) >> 1;\n int z = x + ((y - l + 1) << 1);\n build(x + 1, l, y, v, t...);\n build(z, y + 1, r, v, t...);\n pull(x, z);\n }\n\n template \n segtree(const vector &v, const T&... t) {\n n = v.size();\n assert(n > 0);\n tree.resize(2 * n - 1);\n build(0, 0, n - 1, v, t...);\n }\n\n segtree(int _n) : n(_n) {\n assert(n > 0);\n tree.resize(2 * n - 1);\n build(0, 0, n - 1);\n }\n\n segtree(){};\n\n node get(int x, int l, int r, int ll, int rr) {\n if (ll <= l && r <= rr) {\n return tree[x];\n }\n int y = (l + r) >> 1;\n int z = x + ((y - l + 1) << 1);\n push(x, l, r);\n node res{};\n if (rr <= y) {\n res = get(x + 1, l, y, ll, rr);\n } else {\n if (ll > y) {\n res = get(z, y + 1, r, ll, rr);\n } else {\n res = unite(get(x + 1, l, y, ll, rr), get(z, y + 1, r, ll, rr));\n }\n }\n pull(x, z);\n return res;\n }\n\n node get(int ll, int rr) {\n assert(0 <= ll && ll <= rr && rr <= n - 1);\n return get(0, 0, n - 1, ll, rr);\n }\n\n node get(int p) {\n assert(0 <= p && p <= n - 1);\n return get(0, 0, n - 1, p, p);\n }\n\n template \n void modify(int x, int l, int r, int ll, int rr, const M&... v) {\n if (ll <= l && r <= rr) {\n tree[x].apply(l, r, v...);\n return;\n }\n int y = (l + r) >> 1;\n int z = x + ((y - l + 1) << 1);\n push(x, l, r);\n if (ll <= y) {\n modify(x + 1, l, y, ll, rr, v...);\n }\n if (rr > y) {\n modify(z, y + 1, r, ll, rr, v...);\n }\n pull(x, z);\n }\n\n template \n void modify(int ll, int rr, const M&... v) {\n assert(0 <= ll && ll <= rr && rr <= n - 1);\n modify(0, 0, n - 1, ll, rr, v...);\n }\n\n // find_first and find_last call all FALSE elements\n // to the left (right) of the sought position exactly once\n\n int find_first_knowingly(int x, int l, int r, const function &f) {\n if (l == r) {\n return l;\n }\n push(x, l, r);\n int y = (l + r) >> 1;\n int z = x + ((y - l + 1) << 1);\n int res;\n if (f(tree[x + 1])) {\n res = find_first_knowingly(x + 1, l, y, f);\n } else {\n res = find_first_knowingly(z, y + 1, r, f);\n }\n pull(x, z);\n return res;\n }\n\n int find_first(int x, int l, int r, int ll, int rr, const function &f) {\n if (ll <= l && r <= rr) {\n if (!f(tree[x])) {\n return -1;\n }\n return find_first_knowingly(x, l, r, f);\n }\n push(x, l, r);\n int y = (l + r) >> 1;\n int z = x + ((y - l + 1) << 1);\n int res = -1;\n if (ll <= y) {\n res = find_first(x + 1, l, y, ll, rr, f);\n }\n if (rr > y && res == -1) {\n res = find_first(z, y + 1, r, ll, rr, f);\n }\n pull(x, z);\n return res;\n }\n\n int find_first(int ll, int rr, const function &f) {\n assert(0 <= ll && ll <= rr && rr <= n - 1);\n return find_first(0, 0, n - 1, ll, rr, f);\n }\n\n int find_last_knowingly(int x, int l, int r, const function &f) {\n if (l == r) {\n return l;\n }\n push(x, l, r);\n int y = (l + r) >> 1;\n int z = x + ((y - l + 1) << 1);\n int res;\n if (f(tree[z])) {\n res = find_last_knowingly(z, y + 1, r, f);\n } else {\n res = find_last_knowingly(x + 1, l, y, f);\n }\n pull(x, z);\n return res;\n }\n\n int find_last(int x, int l, int r, int ll, int rr, const function &f) {\n if (ll <= l && r <= rr) {\n if (!f(tree[x])) {\n return -1;\n }\n return find_last_knowingly(x, l, r, f);\n }\n push(x, l, r);\n int y = (l + r) >> 1;\n int z = x + ((y - l + 1) << 1);\n int res = -1;\n if (rr > y) {\n res = find_last(z, y + 1, r, ll, rr, f);\n }\n if (ll <= y && res == -1) {\n res = find_last(x + 1, l, y, ll, rr, f);\n }\n pull(x, z);\n return res;\n }\n\n int find_last(int ll, int rr, const function &f) {\n assert(0 <= ll && ll <= rr && rr <= n - 1);\n return find_last(0, 0, n - 1, ll, rr, f);\n }\n\n};\n\nint tt;\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n cin >> tt;\n while(tt--) {\n cin >> n;\n vector a(n);\n for(int i = 0; i < n; i++) {\n cin >> a[i];\n }\n \n vector sig(n);\n vector coef(n);\n int sg = 1;\n long long co = 0;\n for(int i = 0; i < n; i++) {\n sg *= -1;\n co = a[i] - co;\n sig[i] = sg;\n coef[i] = co;\n }\n \n const long long inf = LLONG_MAX / 2;\n vector> boundary(n, make_pair(-inf, inf));\n for(int i = 0; i < n; i++) {\n if(sig[i] == -1) {\n boundary[i].second = min(boundary[i].second, coef[i] - 1);\n } else {\n boundary[i].first = max(boundary[i].first, 1 - coef[i]);\n }\n }\n \n const int N = 22;\n vector>> fow(N, vector>(n, make_pair(inf, -inf)));\n vector>> bac(N, vector>(n, make_pair(inf, -inf)));\n fow[0] = bac[0] = boundary;\n for(int i = 1; i < N; i++) {\n for(int j = 0; j < n; j++) {\n long long l, r, ll, rr;\n int pr;\n if(j + 1 >= 1 << i) {\n pr = j - (1 << (i - 1));\n l = bac[i - 1][j].first, r = bac[i - 1][j].second;\n ll = bac[i - 1][pr].first, rr = bac[i - 1][pr].second;\n bac[i][j] = make_pair(max(l, ll), min(r, rr));\n }\n if(n - j >= 1 << i) {\n int pr = j + (1 << (i - 1));\n l = fow[i - 1][j].first, r = fow[i - 1][j].second;\n ll = fow[i - 1][pr].first, rr = fow[i - 1][pr].second;\n fow[i][j] = make_pair(max(l, ll), min(r, rr));\n }\n }\n }\n \n vector var(n);\n for(int i = 0; i < n; i++) {\n int cur = i;\n long long l = -inf;\n long long r = inf;\n for(int j = N - 1; j >= 0; j--) {\n if(cur == -1) break;\n long long ll = max(l, bac[j][cur].first);\n long long rr = min(r, bac[j][cur].second);\n if(ll <= rr) {\n cur -= 1 << j;\n l = ll;\n r = rr;\n }\n }\n assert(cur >= -1);\n if(cur > -1) var[i] = cur + 2;\n else var[i] = cur + 1 + (r < 1);\n }\n \n map> make_eq;\n for(int i = 0; i < n; i++) {\n if(a[i] & 1) continue;\n long long b = (-coef[i] + a[i] / 2) / sig[i];\n make_eq[b].push_back(i);\n }\n \n vector reac(n, n);\n vector rev_reac(n, -1);\n for(int i = 0; i < n; i++) {\n if(a[i] & 1) continue;\n \n int cur = i;\n long long sp = (a[i] / 2 - coef[i]) / sig[i];\n long long l = sp;\n long long r = sp;\n for(int j = N - 1; j >= 0; j--) {\n if(cur == -1) break;\n long long ll = max(l, bac[j][cur].first);\n long long rr = min(r, bac[j][cur].second);\n if(ll <= rr) {\n cur -= 1 << j;\n l = ll;\n r = rr;\n }\n }\n if(cur > -1) reac[i] = cur + 2;\n else reac[i] = cur + 1 + (r < 1);\n \n cur = i;\n l = sp;\n r = sp;\n for(int j = N - 1; j >= 0; j--) {\n if(cur == n) break;\n long long ll = max(l, fow[j][cur].first);\n long long rr = min(r, fow[j][cur].second);\n if(ll <= rr) {\n cur += 1 << j;\n l = ll;\n r = rr;\n }\n }\n rev_reac[i] = cur - 1;\n }\n swap(reac, rev_reac);\n \n vector near(n, -1);\n for(auto foo : make_eq) {\n vector pos = foo.second;\n for(int i = 1; i < (int) pos.size(); i++) {\n int c = pos[i];\n int d = pos[i - 1];\n if(rev_reac[c] <= d) near[c] = d;\n }\n }\n //debug(var) debug(reac) debug(rev_reac) debug(near)\n\n vector dp(n + 1);\n vector sub_dp(n + 1);\n set> cur;\n multiset v;\n multiset c;\n segtree st(n + 1);\n\n if(a[0] % 2 == 0) {\n cur.insert(make_pair(reac[0], 0));\n v.insert(0);\n c.insert(0);\n }\n\n for(int i = 1; i <= n; i++) {\n dp[i] = st.get(var[i - 1], i - 1).p + i + 1;\n while(cur.size() && cur.begin()->first < i - 1) {\n int id = cur.begin()->second;\n v.erase(v.find(sub_dp[id] - id));\n c.erase(c.find(dp[id] - id));\n cur.erase(cur.begin());\n }\n if(cur.size()) {\n dp[i] = min(dp[i], *v.begin() + i - 1);\n dp[i] = min(dp[i], *c.begin() + i);\n }\n if(var[i - 1] == 0) {\n dp[i] = min(dp[i], i);\n }\n st.modify(i, i, dp[i] - i);\n \n if(i == n) break;\n if(a[i] & 1) continue;\n sub_dp[i] = INT_MAX / 2;\n if(rev_reac[i] < i) sub_dp[i] = st.get(rev_reac[i], i - 1).p + i + 1;\n if(~near[i]) {\n int d = near[i];\n sub_dp[i] = min(sub_dp[i], sub_dp[d] + i - d - 1);\n sub_dp[i] = min(sub_dp[i], dp[d] + i - d);\n }\n if(rev_reac[i] == 0) sub_dp[i] = min(sub_dp[i], i);\n cur.insert(make_pair(reac[i], i));\n v.insert(sub_dp[i] - i);\n c.insert(dp[i] - i);\n }\n cout << dp[n] + 1 << \"\\n\";\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ceb191ecb3c12e0d61e9ed6def7543fa", "src_uid": "e809d068b3ae47eb5ecfb9ac69892254", "difficulty": 3200.0} {"lang": "GNU C++17", "source_code": "// #pragma GCC optimize(\"O3\")\n#include \n#include \n#include \n#define FIO ios_base::sync_with_stdio(false); cin.tie(0);\n#define trav(x,a) for (auto& x: a)\n#define sz(x) (int)(x).size()\n#define all(x) (x).begin(), (x).end()\n#define mem(a,v) memset((a), (v), sizeof (a))\n// #define endl \"\\n\"\n#define case(t) cout << \"Case #\" << (t) << \": \"\n#define reada(a, n) for (int _i = 0; _i < (n); _i++) read(a[_i])\n#define pii pair\n#define pll pair\n#define vii vector\n#define vll vector\n#define vi vector\n#define vl vector\n#define pb push_back\n#define mp make_pair\n#define st first\n#define nd second\nusing namespace std;\nusing namespace __gnu_pbds;\ntypedef long long ll;\ntypedef cc_hash_table> ht;\ntypedef tree,rb_tree_tag,tree_order_statistics_node_update> oset;\nconst double pi = acos(-1);\nconst int mod = 1e9 + 7;\nconst int inf = 1e9 + 7;\nconst int N = 1e6 + 5;\nconst double eps = 1e-9;\n\ntemplate void read(T& x) { cin >> x; }\ntemplate void read(pair& a) { read(a.first), read(a.second); }\ntemplate void read(array& x) { for (int i = 0; i < U; i++) read(x[i]); }\ntemplate void read(vector& x) { trav(y, x) read(y); }\ntemplate void read(T& x, O&... y) { read(x), read(y...); }\n\nstring to_string(const char& x) { return string(1,x); }\nstring to_string(const char*& x) { return (string)x; }\nstring to_string(const string& x) { return x; }\ntemplate string to_string(const pair& x) { return to_string(x.first) + \" \" + to_string(x.second); }\ntemplate string to_string(const array& x) { string ret = \"\"; for (int i = 0; i < U; i++) ret += (!i ? \"\" : \" \") + to_string(x[i]); return ret; }\ntemplate string to_string(const vector& x) { string ret = \"\"; bool f = 0; trav(y, x) ret += (!f ? \"\" : \" \") + to_string(y), f = 1; return ret; }\ntemplate string to_string(const set& x) { string ret = \"\"; bool f = 0; trav(y, x) ret += (!f ? \"\" : \" \") + to_string(y), f = 1; return ret; }\nvoid print() { cout << endl; }\ntemplate void pr(const T& x) { cout << to_string(x); }\ntemplate void print(const T& x, const O&... y) { pr(x); if (sizeof...(y)) pr(\" \"); print(y...); }\n\n#define ep emplace_back\nauto seed = chrono::steady_clock::now().time_since_epoch().count();\n// ll seed = 42;\nmt19937 rng(seed);\ntemplate struct treap {\n vector L, R, prio;\n vector val;\n vector mn, mx, mx2, lzadd, lzrev, lz, lzf;\n int root = 0, mxr = 0;\n treap() { L.ep(), R.ep(), prio.ep(), val.ep(), mn.ep(inf), mx.ep(), mx2.ep(), lzadd.ep(), lzrev.ep(), lz.ep(), lzf.ep(); }\n inline int genRnd() { return uniform_int_distribution(0,1e9)(rng); }\n inline int create(const T& v, int p) { val.ep(v), L.ep(), R.ep(), prio.ep(p), mn.ep(v[2]), mx.ep(v[2]), mx2.ep(-inf), lzadd.ep(0), lzrev.ep(0), lz.ep(inf), lzf.ep(0); return sz(val)-1; }\n void pushdown(int x) {\n if (!x) return;\n if (lz[x] != inf) {\n if (lz[x] < mx[x]) {\n for (int k: {L[x], R[x]}) lz[k] = min(lz[x] - lzadd[k], lz[k]);\n if (val[x][2] == mx[x])\n val[x][2] = lz[x];\n mn[x] = mx[x] == mn[x] ? lz[x] : mn[x];\n mx[x] = lz[x];\n }\n lz[x] = inf;\n }\n if (lzadd[x] > 0) {\n lzadd[L[x]] += lzadd[x], lzadd[R[x]] += lzadd[x];\n mn[x] += lzadd[x], mx[x] += lzadd[x], val[x][2] += lzadd[x];\n if (mx2[x] != -inf)\n mx2[x] += lzadd[x];\n lzadd[x] = 0;\n }\n if (lzrev[x] != 0) {\n for (int k: {L[x], R[x]}) {\n if (lzf[x])\n lzrev[k] = lzrev[x] - lzrev[k], lzf[k] ^= 1;\n else\n lzrev[k] += lzrev[x];\n }\n if (lzf[x]) {\n tie(val[x][0], val[x][1]) = mp(lzrev[x] - val[x][1], lzrev[x] - val[x][0]);\n swap(L[x], R[x]);\n } else\n val[x][0] += lzrev[x], val[x][1] += lzrev[x];\n lzrev[x] = 0, lzf[x] = 0;\n }\n }\n void cmb(int x, int fl = 1) {\n if (!x) return;\n if (fl) pushdown(L[x]), pushdown(R[x]);\n mn[x] = min({val[x][2], L[x] ? mn[L[x]] : inf, R[x] ? mn[R[x]] : inf});\n mx[x] = max({val[x][2], L[x] ? mx[L[x]] : -inf, R[x] ? mx[R[x]] : -inf});\n mx2[x] = max({L[x] ? mx2[L[x]] : -inf, R[x] ? mx2[R[x]] : -inf, val[x][2] != mx[x] ? val[x][2] : -inf});\n for (int k: {L[x], R[x]}) if (k && mx[k] != mx[x])\n mx2[x] = max(mx2[x], mx[k]);\n }\n inline bool cmp(const T& x, const T& y) { return x[1] < y[0]; }\n inline bool cmp2(const T& x, const T& y) { return x[0] < y[1]; }\n void split(int cur, int &l, int &r, const T& v) {\n pushdown(cur);\n if (!cur)\n l = r = 0;\n else if (cmp(val[cur], v)) {\n int x = R[l = cur];\n split(R[cur], x, r, v);\n R[l] = x;\n cmb(l);\n } else {\n int x = L[r = cur];\n split(L[cur], l, x, v);\n L[r] = x;\n cmb(r);\n }\n }\n void split2(int cur, int &l, int &r, const T& v) {\n pushdown(cur);\n if (!cur)\n l = r = 0;\n else if (cmp2(val[cur], v)) {\n int x = R[l = cur];\n split2(R[cur], x, r, v);\n R[l] = x;\n cmb(l);\n } else {\n int x = L[r = cur];\n split2(L[cur], l, x, v);\n L[r] = x;\n cmb(r);\n }\n }\n void add(int &cur, const T& v, ll p) {\n pushdown(cur);\n if (!cur) {\n cur = create(v, p);\n } else if (p > prio[cur]) {\n int nx = create(v, p);\n split(cur, L[nx], R[nx], v);\n cur = nx;\n } else {\n int x = cmp(val[cur], v) ? R[cur] : L[cur];\n add(x, v, p);\n if (cmp(val[cur], v)) R[cur] = x; else L[cur] = x;\n }\n cmb(cur);\n }\n inline void insert(const T& v) { add(root, v, genRnd()); }\n inline int getMn() { pushdown(root); return mn[root]; }\n int getVal(int x, int cur) {\n pushdown(cur);\n if (val[cur][0] <= x && x <= val[cur][1] || mx[cur] == mn[cur])\n return val[cur][2];\n return x < val[cur][0] ? getVal(x, L[cur]) : getVal(x, R[cur]);\n }\n inline int getVal(int x) { return getVal(x, root); }\n inline int findR(int x) { pushdown(x); return !R[x] ? x : findR(R[x]); }\n void keep(int l, int r, int v) {\n mxr = r;\n int rhs = findR(root);\n if (val[rhs][1] == r)\n return;\n if (val[rhs][1] < r) {\n if (val[rhs][2] == v)\n val[rhs][1] = r;\n else\n insert({val[rhs][1] + 1, r, v});\n return;\n }\n int x = 0, y = 0;\n split2(root, x, y, {-1, r+1, -1});\n root = x;\n val[findR(x)][1] = r;\n }\n inline void reverse(int r) { lzrev[root] = r - lzrev[root]; lzf[root] ^= 1; }\n inline void inc(int v) { lzadd[root] += v; }\n void setMn(int v, int x) {\n pushdown(x);\n if (!x || mx[x] <= v) return;\n if (mx2[x] < v) { lz[x] = v; pushdown(x); return; }\n setMn(v, L[x]), setMn(v, R[x]);\n if (v < val[x][2])\n val[x][2] = v;\n cmb(x);\n }\n inline void setMn(int v) { setMn(v, root); }\n inline void getIdx(int x, int cur, vector& p) { pushdown(cur); p.ep(cur); if (x < val[cur][0]) getIdx(x, L[cur], p); else if (x > val[cur][1]) getIdx(x, R[cur], p); }\n void upd(int pos, int v) {\n vector path;\n getIdx(pos, root, path);\n int idx = path.back(); path.pop_back();\n if (val[idx][2] == v)\n return;\n int l = val[idx][0], r = val[idx][1], nv = val[idx][2];\n val[idx] = {pos, pos, v};\n cmb(idx);\n while (sz(path))\n cmb(path.back()), path.pop_back();\n if (l < pos)\n insert({l, pos - 1, nv});\n if (pos < r)\n insert({pos + 1, r, nv});\n }\n void dfs(int x, vector& arr) {\n if (!x) return;\n pushdown(x); dfs(L[x], arr);\n if (sz(arr) && arr.back()[2] == val[x][2])\n arr.back()[1] = val[x][1];\n else\n arr.ep(val[x]);\n dfs(R[x], arr);\n }\n void heapify(int x) {\n if (!x) return;\n int nx = x;\n if (L[x] && prio[L[x]] > prio[nx])\n nx = L[x];\n if (R[x] && prio[R[x]] > prio[nx])\n nx = R[x];\n if (nx != x) {\n swap(prio[nx], prio[x]);\n heapify(nx);\n }\n }\n int build(int l, int r, vector& arr) {\n if (l > r) return 0;\n int m = (l+r) / 2;\n int nx = create(arr[m], genRnd());\n L[nx] = build(l, m-1, arr), R[nx] = build(m+1, r, arr);\n heapify(nx);\n cmb(nx, 0);\n return nx;\n }\n void rebuild(int flag) {\n int lst = sz(val);\n vector arr;\n dfs(root, arr);\n L.resize(1), R.resize(1), prio.resize(1), val.resize(1), mn.resize(1), mx.resize(1), mx2.resize(1), lzadd.resize(1), lzrev.resize(1), lz.resize(1), lzf.resize(1);\n root = build(0, sz(arr)-1, arr);\n if (flag) print(lst, sz(val));\n }\n};\n\nvoid solve() {\n int n; read(n);\n treap> t; // [l,r], val\n // vector arr = {999999994, 999999998, 999999992, 1000000000};\n ll lst = -1;\n int cnt = 0;\n for (int i = 0; i < n; i++) {\n if (lst == 999999994 && i % 100000 == 0)\n cnt++, t.rebuild();\n else if (sz(t.val) > 100000)\n cnt++, t.rebuild(lst == 100523382);\n int a; read(a);\n // int a = arr[i % 4];\n if (!i) {\n lst = a;\n t.mxr = a-1;\n if (a & 1) {\n t.insert({1, a-1, 2});\n } else {\n if (1 <= a / 2 - 1)\n t.insert({1, a / 2 - 1, 2});\n t.insert({a / 2, a / 2, 1});\n if (a / 2 + 1 <= a - 1)\n t.insert({a / 2 + 1, a - 1, 2});\n }\n continue;\n }\n int mn = t.getMn(); // + 2\n int val = a % 2 == 0 && t.mxr >= a / 2 ? t.getVal(a / 2) : inf;\n t.keep(1, a - 1, mn + 1);\n t.reverse(a);\n t.inc(1);\n t.setMn(mn + 2);\n if (a % 2 == 0)\n t.upd(a / 2, min(val, mn+1));\n }\n print(t.getMn());\n}\n\nint main() {\n FIO\n int t; read(t);\n while (t--)\n solve();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f27596e817aa13cb08e342be7792a5ba", "src_uid": "e809d068b3ae47eb5ecfb9ac69892254", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main(void)\n{\n\tstring a[3][3];\n\tfor(int i=0;i<3;i++)\n\t{\n\t\tfor(int j=0;j<3;j++)\n\t\t{\n\t\t\tcin>>a[i][j];\n\t\t}\n\t}\n\tfor(int i=0;i<3;i++)\n\t{\n\t\tfor(int j=0;j<3;j++)\n\t\t{\n\t\t\tif(a[0][0]==a[2][2]&&a[0][1]==a[2][1]&&a[0][2]==a[2][0]&&a[1][0]==a[1][2])\n\t\t\t{\n\t\t\t\tcout<<\"YES\";return 0;\n\t\t\t}\n\t}\n\tcout<<\"NO\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3d133b306913a9a36ca7f0e0b7246174", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main()\n{\n int a11,a12,a13,a21,a22,a23,a31,a32,a33;\n cin>>a11>>a12>>a13>>a21>>a22>>a23>>a31>>a32>>a33;\n if(a11==a33)&&(a12==a32)&&(a13==a31)&&(a21==a23)\n {\n cout<<\"YES\";\n }\n else\n {\n cout<<\"NO\";\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "344ebd18afd55e146374845ce18f1323", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n char a[3][3];\n for (int i = 0; i < 3; i++)\n {\n for (int j = 0; j < 3; j++)\n {\n cin >> a[i][j];\n }\n }\n\n for (int i = 0; i < 2; i++)\n {\n for (int j = 0; j < 3; j++)\n {\n if (a[i][j] != a[2-x][x-y]) \n {\n cout << \"NO\" << endl;\n return 0;\n }\n }\n }\n cout << \"YES\" << endl;\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "60ce3d660478c1047eb66ab905e565ea", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9", "difficulty": 800.0} {"lang": "MS C++ 2017", "source_code": "#include\nusing namespace std;\n\nvoid test(){\n char a[3][3];\n for(int i=0;i<3;i++){\n string s;\n cin>>s;\n a[i][0] = s[0];\n a[i][1] = s[1];\n a[i][2] = s[2];\n }\n if(a[0][0]==a[2][2]){\n if(a[0][1]==a[2][1]){\n if(a[0][2]==a[2][0]){\n if(a[1][0]==a[1][2]){\n cout<<\"YES\"<\nusing namesapce std;\nint main()\n{\n int n; cin>>n;\n int A[n];\n for(int i=0; i>A[i];\n sum += A[i];\n }\n int m = sizeof(A)/sizeof(A[0]);\n sort(A, A+m);\n for(int i =0; i= 4.5)\n break;\n else\n {\n sum -= (A[i] - 5)\n count ++;\n }\n \n }\n cout<\n\nusing namespace std;\n\nint main(){\n int n;\n cin >> n;\n vector a(n+1, 0);\n vector s(8, 0);\n float avg = a0;\n float ans = 0;\n for(int i = 0; i < n; i++){\n int x;\n cin >> x;\n s[x]++;\n avg += ((1.0 * x) / n);\n }\n if(n == 100 && s[3] == 100){\n cout << 75;\n return 0;\n }\n for(int j = 2; j < 6 && avg < 4.500000; j++){\n for(int i = 0; i < s[j] && avg < 4.5; i++){\n ans++;\n avg -= ((1.00 * j) / n);\n avg += (5.00 / n);\n //cout << \"*\" << avg << endl;\n }\n }\n cout << (int) ans;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fb58639b5c6ef54b9ce2dcaa57ce5669", "src_uid": "715608282b27a0a25b66f08574a6d5bd", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "\ufeff\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 16\nVisualStudioVersion = 16.0.30517.126\nMinimumVisualStudioVersion = 10.0.40219.1\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"Getting an A\", \"Getting an A\\Getting an A.vcxproj\", \"{A813EB8A-0CCB-4755-994D-9495E320A722}\"\nEndProject\nGlobal\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n\t\tDebug|x64 = Debug|x64\n\t\tDebug|x86 = Debug|x86\n\t\tRelease|x64 = Release|x64\n\t\tRelease|x86 = Release|x86\n\tEndGlobalSection\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n\t\t{A813EB8A-0CCB-4755-994D-9495E320A722}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{A813EB8A-0CCB-4755-994D-9495E320A722}.Debug|x64.Build.0 = Debug|x64\n\t\t{A813EB8A-0CCB-4755-994D-9495E320A722}.Debug|x86.ActiveCfg = Debug|Win32\n\t\t{A813EB8A-0CCB-4755-994D-9495E320A722}.Debug|x86.Build.0 = Debug|Win32\n\t\t{A813EB8A-0CCB-4755-994D-9495E320A722}.Release|x64.ActiveCfg = Release|x64\n\t\t{A813EB8A-0CCB-4755-994D-9495E320A722}.Release|x64.Build.0 = Release|x64\n\t\t{A813EB8A-0CCB-4755-994D-9495E320A722}.Release|x86.ActiveCfg = Release|Win32\n\t\t{A813EB8A-0CCB-4755-994D-9495E320A722}.Release|x86.Build.0 = Release|Win32\n\tEndGlobalSection\n\tGlobalSection(SolutionProperties) = preSolution\n\t\tHideSolutionNode = FALSE\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityGlobals) = postSolution\n\t\tSolutionGuid = {945200A2-6FB0-47AE-9BD6-00537DF9284E}\n\tEndGlobalSection\nEndGlobal\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "945469e5ea7bdd295107025fe504e64f", "src_uid": "715608282b27a0a25b66f08574a6d5bd", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include \"stdafx.h\"\n#include\n#include\n\n#include\n\nusing namespace std;\n \nint main()\n{\n int n,count=0;\n vector a;\n float ans=0,ans1;\n cin>>n;\n for(int i=0;ia[i];\n sort(a.begin(),a.end());\n for(int i=0;i=4.5)\n cout<<\"0\"<=4.5)\n {\n count = i+1;\n break;\n }\n }\n cout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\ntypedef long long ll ;\ntypedef vector vi;\ntypedef vector> vpi;\ntypedef vector vl;\ntypedef vector> vpl;\ntypedef vector vs;\ntypedef set ss;\ntypedef set si;\ntypedef set sl;\ntypedef set> spi;\ntypedef set> spl;\n#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);\n// define values.\n#define mod 1000000007;\n#define phi 1.618\n/* Bit-Stuff */\n#define get_set_bits(a) (__builtin_popcount(a))\n#define get_set_bitsll(a) ( __builtin_popcountll(a))\n#define get_trail_zero(a) (__builtin_ctz(a))\n#define get_lead_zero(a) (__builtin_clz(a))\n#define get_parity(a) (__builtin_parity(a))\n/* Abbrevations */\n#define ff first\n#define second ss\n#define mp make_pair\n#define line cout<0)\n\t{\n\t\tif(y%2==1)res*=x;\n\t\ty/=2; x*=x;\n\t}\n\treturn res;\n}\n/* ascii value \nA=65,Z=90,a=97,z=122\n*/\n/* -----------------------------------------------------------------------------------*/\n\nint main()\n{\n\tpan;\n\tscanf(\"%d\", &n);\n\tfor(int i = 1; i <= n; ++i){\n\t\tint a;\tscanf(\"%d\", &a);\n\t\tmx = max(mx, a);\n\t\tsum += a;\n\t}\n\t\n\tsum *= 2;\n\tsum += n;\n\tsum /= n;\n\t\n\tprintf(\"%d\", max(sum, mx));\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0f33969df3db657de57ee08cd876442b", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \nint main()\n{\n int n, tmp, sum = 0;\n cin >> n;\n for (int i = 1; i <= n; i++)\n {\n cin >> tmp;\n sum += tmp;\n }\n cout << (sum * 2 + n - 1) / n << endl;;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "14792a08b71b55538940f95e73c55534", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n\tint n, a, sum = 0, k;\n\tcin >> n;\n\t\n\tcin >> ans;\n\tsum = ans;\n\t\n\tfor(int i = 1; i < n; i++)\n\t{\n\t\tcin >> a;\n\t\t\n\t\tsum += a;\n\t\t\n\t\tans = max(ans, a);\n\t}\n\t\n\tk = 2 * sum / n + 1;\n\t\n\t\n\tcout << max(k, ans) << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3a6f7e3aeb9814f61ef5315f87510b73", "src_uid": "d215b3541d6d728ad01b166aae64faa2", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include\n#define ll long long\nusing namespace std;\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n int n;\n cin>>n;\n vector v(n);\n ll s(0);\n for(int i=0;i>v[i];\n s+=v[i];\n }\n sort(v.begin(),v.end());\n s*=2;\n s+=n-1;\n s/=2;\n \n cout<\nusing namespace std;\n\nint a,b,mod;\nint step;\n\nint main(){\n cin>>a>>b>>mod;\n step = 1000000000%mod;\n if (b >= mod-1) cout<<\"2\"< interval; cand = (cand+step)%mod){\n if (cand == step)\n if (rep) break;\n else rep = true; \n }\n if (cand > interval) cout<<\"2\"< a) cout<<\"2\"<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\ntypedef unsigned long long ui64;\ntypedef long long i64;\ntypedef vector VI;\ntypedef vector VB;\ntypedef vector VVI;\ntypedef vector VS;\ntypedef pair PII;\ntypedef map MSI;\ntypedef set SI;\ntypedef set SS;\ntypedef map MII;\ntypedef pair PDD;\n\n#define PB push_back\n#define MP make_pair\n#define X first\n#define Y second\n#define FOR(i, a, b) for(int i = (a); i < (b); ++i)\n#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); --i)\n#define CLEAR(a, b) memset(a, b, sizeof(a))\n#define SZ(a) int((a).size())\n#define ALL(a) (a).begin(), (a).end()\n#define RALL(a) (a).rbegin(), (a).rend()\n#define INF (2000000000)\n\n\nint main()\n{\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "494f2b4430adb2060abf1f8b06c2179d", "src_uid": "8b6f633802293202531264446d33fee5", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include\nusing namespace std;\n#define hangdiana\n#ifndef hangdian\n typedef long long ll;\n#endif\n#ifdef hangdian\ntypedef __int64 ll;\n#endif\n\n///////////////////////////////////////////////\n#define mems(a,b) memset((a),b,sizeof((a)))\n#define rll(a,b) scanf(\"%lld%lld\", &(a),&(b))\n#define rl(a) scanf(\"%lld\", &(a))\n#define ri(i) scanf(\"%d\", &(i) )\n#define rii(a,b) scanf(\"%d%d\",&(a), &(b))\n#define rs(s) scanf(\"%s\", s)\n#define ps(s) printf(\"%s\\n\", s)\n#define pi(i) printf(\"%d\\n\", (i))\n#define pl(i) printf(\"%lld\\n\",(i))\n#define pll(a,b) printf(\"%lld %lld\\n\", (a),(b))\n#define pii(a,b) printf(\"%d %d\\n\",(a),(b));\n#define pki(i) printf(\" %d\", (i))\n#define all(a) a.begin(), a.end()\n#define SZ(a) ((int)(a).size())\n#define fir first\n#define sec second\n#define rep(i, n ) for( int i=1;i<=n;i++)\n#define rep1( i,a,b )for(int i=a;i<=b;i++)\n#define rep2( i,a,b) for( i=a; i>=b;i--)\n#define mp(a,b) make_pair(a,b)\n#define pb(v) push_back(v)\n#define ENDL cout<> a>>b>>mod)\n\t{\n\t\tb%=mod;\n\t\tint e= (int)1e9;\n\t\tint win=2;\n\t\tfor(i=1;i<=a;++i)\n\t\t{\n\t\t\tif((mod-(ll)i*e%mod)%mod>b)\n\t\t\t{\n\t\t\t\twin=1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tprintf(\"%d\",win);\n\t\tif(win==1 ) \n\t\t\tprintf(\" %09d\", i);\n\t\tputs(\"\");\n\t}\n}\n\n\n\n#include\n#include\n#include\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include\nusing namespace std;\n#define hangdiana\n#ifndef hangdian\n typedef long long ll;\n#endif\n#ifdef hangdian\ntypedef __int64 ll;\n#endif\n\n///////////////////////////////////////////////\n#define mems(a,b) memset((a),b,sizeof((a)))\n#define rll(a,b) scanf(\"%lld%lld\", &(a),&(b))\n#define rl(a) scanf(\"%lld\", &(a))\n#define ri(i) scanf(\"%d\", &(i) )\n#define rii(a,b) scanf(\"%d%d\",&(a), &(b))\n#define rs(s) scanf(\"%s\", s)\n#define ps(s) printf(\"%s\\n\", s)\n#define pi(i) printf(\"%d\\n\", (i))\n#define pl(i) printf(\"%lld\\n\",(i))\n#define pll(a,b) printf(\"%lld %lld\\n\", (a),(b))\n#define pii(a,b) printf(\"%d %d\\n\",(a),(b));\n#define pki(i) printf(\" %d\", (i))\n#define all(a) a.begin(), a.end()\n#define SZ(a) ((int)(a).size())\n#define fir first\n#define sec second\n#define rep(i, n ) for( int i=1;i<=n;i++)\n#define rep1( i,a,b )for(int i=a;i<=b;i++)\n#define rep2( i,a,b) for( i=a; i>=b;i--)\n#define mp(a,b) make_pair(a,b)\n#define pb(v) push_back(v)\n#define ENDL cout<> a>>b>>mod)\n\t{\n\t\tb%=mod;\n\t\tint e= (int)1e9;\n\t\tint win=2;\n\t\tfor(i=1;i<=a;++i)\n\t\t{\n\t\t\tif((mod-(ll)i*e%mod)%mod>b)\n\t\t\t{\n\t\t\t\twin=1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tprintf(\"%d\",win);\n\t\tif(win==1 ) \n\t\t\tprintf(\" %09d\", i);\n\t\tputs(\"\");\n\t}\n}\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7134f827deda1ea4096cf3e07afb845d", "src_uid": "8b6f633802293202531264446d33fee5", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef vector VI;\ntypedef pair PII;\ntypedef unsigned long long LL;\n#define FOR(x, b, e) for(int x=b; x<=(e); ++x)\n#define FORD(x, b, e) for(int x=b; x>=(e); --x)\n#define REP(x, n) for(int x=0; x<(n); ++x)\n#define VAR(v,n) typeof(n) v=(n)\n#define ALL(c) c.begin(),c.end()\n#define SIZE(x) (int)x.size()\n#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();++i)\n#define PB push_back\n#define ST first\n#define ND second\n#define mp(x,y) make_pair(x,y)\n\n\nconst int N = 1000010;\nconst LL inf = 10000000000LL;\nLL a, b, mod;\nint n;\n\nmain(){\n\tcin >> q >> b >> mod;\n\tfor(LL a = 0 ; a <= min(2*mod,q) ; a++){\n\t\tLL przys = (a * inf) % mod;\n\t\t//cout << \"przys: \" << przys << endl;\n\t\tif((mod - przys) % mod > b){\n\t\t\tcout << 1 << ' ' ;\n\t\t\tif(a == 0) cout << 000000000 << endl;\n\t\t\telse{\n\t\t\t\tLL d = a;\n\t\t\t\tint s =0;\n\t\t\t\twhile(d){\n\t\t\t\t\td /= 10;\n\t\t\t\t\ts++;\n\t\t\t\t}\n\t\t\t\tREP(i,9-s) cout << 0;\n\t\t\t\tcout << a << endl;\n\t\t\t}\n\t\t\treturn 0;\n\t\t}\n\t}\n\tcout <<2 << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "25c261ef03f1b48c8763c2c8291d5683", "src_uid": "8b6f633802293202531264446d33fee5", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#define ll long long int\n#define MAX_INT 1e18\n#define MOD 1000000007\n\nusing namespace std;\n\nint main(){\n\n\tll a,b,c;\n\tcin>>a>>b>>c;\n\tif(a==1 | b==1 | c==1)\n\t\tcout<\"YES\\n\";\n\telse if((a==2 & b==2) | (a==2 & c==2) | (c==2 & b==2))\n\t\tcout<<\"YES\\n\";\n\telse if(a==3 & b==3 & c==3)\n\t\tcout<<\"YES\\n\";\n\telse if((a==2 & b==4 & c==4) | (a==4 & b==2 & c==4) | (a==4 & b==4 & c==2))\n\t\tcout<<\"YES\\n\";\n\telse\n\t\tcout<<\"NO\\n\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "39b444213c29e4ad17855db547289c2c", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "include \"iostream\"\n#include \"fstream\"\n#include \"algorithm\"\n#include \"iomanip\"\n#include \"stack\"\n#include \"queue\"\n#include \"string\"\n#include \"vector\"\n#include \"map\"\n#include \"set\"\n#include \"unordered_set\"\n#include \"unordered_map\"\n#include \"iterator\"\n#include \"cmath\"\n\n#define f(i,n) for(int i=0; i=0;i--)\ntypedef long long ll;\n\n#define int ll\nconst int sze = 1e5 + 10, psze = 30, INF = 1e8;\n\nusing namespace std;\n\nint dp[500];\n\nll bin_pow(int a, int b, int p)\n{\n\tint res = 1;\n\twhile (b)\n\t{\n\t\tif (b & 1 == 1)\n\t\t{\n\t\t\tres *= a % p;\n\t\t}\n\n\t\ta *= a%p;\n\t\tb /= 2;\n\t}\n\n\treturn res;\n}\n\nsigned main()\n{\n\tios::sync_with_stdio(false);\n\n\tint k[3];\n\n\tcin >> k[0] >> k[1] >> k[2];\n\n\tsort(k, k + 3);\n\n\tif (k[0] == 1)\n\t{\n\t\tcout << \"YES\";\n\t\treturn 0;\n\t}\n\n\tif (k[0] == k[1] || k[1] == k[2])\n\t{\n\t\tcout << \"YES\";\n\t\treturn 0;\n\t}\n\t\n\tif(k[2] - k[0] > 1 || k[2] - k[1] > 1 || k[1]-k[0] >1)\n\t{\n\n\tcout << \"NO\";\n\treturn 0;\n\t}\n\t\n\tcout << \"YES\";\n return 0;\n\t\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "625819eeed7b71790fe1bac2e3115161", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "int main() {\nint k1,k2,k3;\ncin>>k1>>k2>>k3;\nint cnt3,cnt4;\nif(k1==1||k2==1||k3==1)cout<<\"YES\";\nelse { int cnt=0;\n\t if(k1==2)++cnt;\n\t if(k2==2)++cnt;\n\t if(k3==2)++cnt;\n\t if(k1==3)++cnt3;\n\t if(k2==3)++cnt3;\n\t if(k3==3)++cnt3;\n\t if(k1==4)++cnt4;\n\t if(k2==4)++cnt4;\n\t if(k3==4)++cnt4;\n\t if(cnt>=2)cout<<\"YES\";\n\t else if(k1==3&&k2==3&&k3==3)cout<<<\"YES\";\n\t else if((cnt4>1||cnt3>1)&&cnt>0)cout<<<\"YES\";\n\t else cout<<\"NO\";\n\t \n }\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "83697cc276b2c5532318905440b2dbc4", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "\n#include\nusing namespace std;\n\n#define ll long long\n#define pb push_back\n#define mp make_pair\n#define ff first\n#define ss second\n#define sc(x) scanf(\"%lld\",&x)\n#define pr(x) printf(\"%lld\\n\",x)\n#define clr(x) memset(x, 0, sizeof(x))\n#define all(x) x.begin(), x.end()\ntypedef pair pii;\ntypedef vector< ll > vl;\ntypedef vector< pii > vpii;\n\n//DONT WASTE YOUR TIME\n//prove yourself\n//remember....fuck ps&&as hard....show them your are better then them\n//Be confident.....dont lose hope.......You can do it.....\n//dimaag khoob h tere meh ....bas concentration ki kami h\n//CONCENTRATE\n//A,B,C dimaag nhi ...observation h .....zyaada mat sochna unme.....bas observe karna dhyaan se aur implement kar daal jitni jaldi ho sake\n\n//capture it\n\nconst ll N= 1e6+55,mod = 1e9+7;\n\nsets;\nset::iterator it;\n\nint main() {\n //\tfreopen(\"task.in\",\"r\",stdin);freopen(\"task.out\",\"w\",stdout);\n\tll k1,k2,k3,i,j,l,k,a,b,c,x,y,z;\n\tsc(k1);sc(k2);sc(k3);\n\tif(k1==1 || k2==1 || k3==1){\n\t\tprintf(\"YES\\n\");\n\t\treturn 0;\n\t}\n\tif((k1==2 && k2==2) || (k1==2 && k3==2) || (k2==2 && k3==2)){\n\t\tprintf(\"YES\\n\");\n\t\treturn 0;\n\t}\n\tif(k1==3 && k2==3 && k2==3){\n\t\tprintf(\"YES\\n\");\n\t\treturn 0;\n\t}\n\tif((k1==2 && k2==3 && k2==3)|| (k1==3 && k2==2 && k2==3) || (k1==3 && k2==3 && k2==2)){\n\t\tprinf(\"YES\\n\");\n\t\treturn 0;\n\t}\n\tprintf(\"NO\\n\");\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "40c17bb692fef634681c5a68d7b22013", "src_uid": "df48af9f5e68cb6efc1214f7138accf9", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "\u007f#include\n#include\nusing namespace std;\nint main(){\n string s;\n int64_t i,k,j,flag=0;\n cin>>s;\n if(s.size()<26){\n cout<<\"-1\";return 0;}\n else{\n flag=0;\n for(i=0;i\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n string ori,_not; int sum=0;\n cin>>ori;\n if(ori.length()<26)\n {cout<<\"-1\";}\n\n else if(sizeof(ori)>=26)\n {\n for(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define turbo ios::sync_with_stdio(false)\n#define ll long long\n#define inf 1000000000000000;\nusing namespace std;\n\nll a, b, c, d, n, m, k, q;\nstring s;\nint main(){\n turbo;\n cin>>s;\n if(s.size()<26){cout<<-1; return 0;}\n for(int i=0; i cv;\n for(int i=0; i=26){\n for(int x=0; x<=cv[i-1]; x++)cout<\nusing namespace std;\nstring c;\nint p[100];\nint main(){\n\tcin>>c;\n\tint n=strlen(c);\n\tif(n<26){\n\t\tprintf(\"NO\");\n\t}\n\tfor(int i=0;in)continue;\n\t\tif(c[i]=='a'){\n\t\t\tbool flag=1;\n\t\t\tfor(int j=0;j<26;j++){\n\t\t\tif(c[i+j]>j+'a'){\n\t\t\t\tflag=0;\n\t\t\t\tbreak;\n\t\t\t }\n\t\t\tif(flag==1){\n\t\t\t\tfor(int j=0;j\nusing namespace std;\ntypedef long long ll;\n\nvector a;\n\nint main()\n{\n a.clear():\n ios::sync_with_stdio(false);\n cin.tie(0);\n int n;\n cin>>n;\n for(int i = 0 ; i < n ;i++ )\n {\n int x;\n cin>>x;\n a.push_back(x);\n }\n int flag = 1;\n vector::iterator it1 = max_element(a.begin() , a.end());\n vector::iterator it2 = it1;\n if( it1 == a.begin() || it1 == a.end() ){\n cout<<\"NO\"< last ) flag = 0;\n last = *it1;\n //cout<<\"last1: \"< last ) flag = 0;\n last = *it2;\n //cout<<\"last2: \"<\n\n\nint main()\n{\n\tint max = 0;\n\tint xu = 0;\n\tint n = 0;\n\tint a[1005];\n\t\n\tscanf(\"%d\",&n);\n\t\n\tfor(int i = 0; i < n; i++)\n\t{\n\t\tscanf(\"%d\",&a[i]);\n\t\tif(i == 0)\n\t\tmax = a[i];\t\n\t}\n\t\n\tfor(int i = 0; i < n; i++)\n\t{\n\t\tif(max < a[i])\n\t\t{\n\t\t\tmax = a[i];\n\t\t\txu = i;\n\t\t}\n\t}\n\t\n\tfor(int i = 1; i < xu; i++)\n\t{\n\t\tif(a[i] <= a[i-1])\n\t\t{\n\t\t\tprintf(\"NO\\n\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\t\n\tfor(int i = xu + 1; i < n; i++)\n\t{\n\t\tif(a[i] == a[xu])\n\t\txu++;\n\t}\n\t\n\t\n\t\n\tfor(int i = xu+1; i < n; i++)\n\t{\n\t\tif(a[i] >= a[i-1])\n\t\t{\n\t\t\tprintf(\"NO\\n\");\n\t\t\treturn 0;\n\t\t}\n\t}\n\t\n\tprintf(\"YES\\n\");\n\treturn 0;\n} \n\t \t\t\t\t \t\t \t\t \t\t\t\t \t\t \t\t\t \t", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e8f6850f22b52b1127afede55e6c82e5", "src_uid": "5482ed8ad02ac32d28c3888299bf3658", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n#define in insert\n#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n#define pb push_back\n#define endl \"\\n\"\n#define Endl \"\\n\"\n#define endl() \"\\n\"\n#define ENDL \"\\n\"\n#define con continue\n#define fi first\n#define se second\n#define be begin()\n#define en end()\ntypedef long long ll;\ntypedef long double ld;\n\nint main()\n{\n fastio\n\n int x;\n cin>>x;\n for(int i=1;i<=x;i++)\n {\n int c;\n cin>>c;\n v.pb(c);\n st.insert(c);\n }\n if(st.size()==1)cout<<\"YES\"<=v[i+1]){one=false;}\n if((v[i]v[i+1]) && !one ){two=false;}\n if(!two && v[i]\n#define MOD 1000000007\n#define ll long long\n#define F first\n#define S second\n#define PB push_back\n#define MP make_pair\n#define REP(a,b) for (int i = a ; i < b ; i++)\nusing namespace std ;\nint main ()\n{\n ios::sync_with_stdio(0) ;\n int n ;\n cin >> n ;\n int a[n] ;\n bool ok1 = 0 , ok2 = 0 , ok3 = 0 ;\n for ( int i = 0 ; i < n ; i++ )\n cin >> a[i] ;\n for ( int i = 1 ; i < n ; i++ )\n {\n if ( a[i] > a[i-1] )\n {\n if ( !ok2 && !ok3 )\n ok1 = 1 ;\n else\n return cout << \"NO\" , 0 ;\n }\n else\n if ( a[i] == a[i-1] )\n ok3 = 1 ;\n else\n {\n if ( ok1 )\n ok2 = 1 ;\n else\n return cout << \"NO\" , 0 ;\n }\n if ( !ok1 && !ok2 )\n cout << \"YES\" ;\n else\n if ( ok1 && ok2 )\n cout << \"YES\" ;\n else\n cout << \"NO\" ;\n return 0 ;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "91bb71477284f5572f06d36496be8069", "src_uid": "5482ed8ad02ac32d28c3888299bf3658", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nint minim(int a, int b){\n if(ab)\n return a;\n return b;\n}\nint main(){\n int a, b, c;\n cin>>a>>b>>c;\n cout<<2*c+minin(a,b)+minin(maxim(a,b),minim(a,b)+1);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f68c2d2754a73359986c07b004094e98", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\n\nusing namespace std;\n\nint main()\n{\n\tint a,b,c;\n\tcin>>a>>b>>c;\n\tint ans=0;\n\tans+=c*2;\n\tans+=min(a,b)*2;\n\tif(a!=b)\n\t{\n\t\tans++;\n\t}\n\tcout<>a>>b>>c;//\n cout<\n#include \n#define ll long long\nusing namespace std;\nll a,b,ab,ans;\nll combine;\nint main()\n{\n scanf(\"%lld%lld%lld\",&a,&b,&ab); \n combine=min(a,b);\n ans=(combine+ab)<<1;\n if(a!=b) ans++; \n printf(\"%lld\",ans); \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0b95c08f206f754a204b5f556700fe4a", "src_uid": "609f131325c13213aedcf8d55fc3ed77", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "/* \n * File: main.cpp\n * Author: scawn\n *\n * Created on May 4, 2012, 7:47 PM\n */\n\n#include \n#include \n#include \nusing namespace std;\n\n/*\n * \n */\nint main(int argc, char** argv) {\n long double n;\n cin >> n;\n long double a = 3, k = 4;\n long long double b;\n if (n == 0){\n cout << \"1\"<< endl;\n return 0;\n }\n if (n == 1){\n cout << \"3\"<< endl;\n return 0;\n }\n a = (1+pow(2,n))/2*pow(2,n)-((long long int)(1+pow(2,n))/2*pow(2,n)/1000000007)*1000000007;\n cout << (a ) << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a2c0ab5be4184e7034803ab6e06e97b8", "src_uid": "782b819eb0bfc86d6f96f15ac09d5085", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\n#define S1(a) scanf(\"%d\",&a)\n#define S2(a,b) scanf(\"%d %d\",&a,&b)\n#define S3(a,b,c) scanf(\"%d %d %d\",&a,&b,&c)\n#define pb push_back\n#define PI acos(-1.0)\n#define INT_MX 2147483647\n#define INT_MN -2147483647\n#define SIZE 100000\n#define rep(i,a,b) for(i=a;i<=b;i++)\n#define repb(i,a,b) for(i=a;i>=b;i--)\n#define sq(a) a*a\n#define eps 1e-9\n#define ff first\n#define ss second\n#define swap(a,b,t) t=a,a=b,b=t\n#define mems(x,a) memset(x,a,sizeof(x))\n#define chkC(x,n) (x[n>>6]&(1<<((n>>1)&31)))\n#define setC(x,n) (x[n>>6]|=(1<<((n>>1)&31)))\n\nint xx[]={0,0,1,-1,1,-1,1,-1};\nint yy[]={1,-1,0,0,1,-1,-1,1};\n\ntypedef vectorvi;\ntypedef queueqi;\ntypedef stacksi;\ntypedef pairpii;\ntypedef ulong long i64;\ntypedef double dle;\n\ninline i64 MAX(i64 a,i64 b) {return (a>b)?a:b;}\ninline i64 MIN(i64 a,i64 b){return (a>b)?b:a;}\ninline dle dis(dle ax,dle ay,dle bx,dle by){return ((ax-bx)*(ax-bx)+(ay-by)*(ay-by));}\ni64 pwr(i64 x,i64 n)\n{\n if(n==0) return 1;\n if(n==1) return x;\n i64 a=pwr(x,n/2);\n a=a*a;\n if(n%2) a*=x;\n return a;\n}\ni64 m=1000000007;\n\nvoid multiply(i64 F[2][2], i64 M[2][2])\n{\n i64 i,j,k;\n i64 T[2][2];\n rep(i,0,1)\n rep(j,0,1)\n {\n T[i][j]=0;\n rep(k,0,1)\n T[i][j]=(T[i][j]+((F[i][k]%m)*(M[k][j]%m)%m))%m;\n }\n rep(i,0,1)\n rep(j,0,1)\n F[i][j]=T[i][j];\n}\nvoid powr(i64 F[2][2],i64 n)\n{\n if(n<=1)\n return; i64 M[2][2]={{3,1},{1,3}};\n powr(F,n/2);\n multiply(F,F);\n if(n%2)\n multiply(F,M);\n}\n\nint main()\n{\n i64 kase,kas=0,n,x;\n cin>>n;\n if(n==1) cout<<\"3\\n\";\n else if(n==0) cout<<\"1\\n\";\n else\n {\n i64 F[2][2]={{3,1},{1,3}};\n powr(F,n-1);\n x=((F[0][0]*3)%m+F[0][1])%m;\n cout<\n#include\n#include\n#define MOD 1000000007\nusing namespace std;\n__int64 n;\n__int64 pow2(__int64g k)//\u5feb\u901f\u5e42\n{\n __int64 ans,j;\n if(k == 0) return 1;\n if(k == 1) return 2;\n j = pow2(k/2);\n //cout<<\"ss\"<\n\n#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define files(name) freopen(name\".in\",\"r\",stdin); freopen(name\".out\",\"w\",stdout);\n#define all(a) a.begin(),a.end()\n#define elif else if\n#define mp make_pair\n#define pb push_back\n#define fir first\n#define sec second\n\nusing namespace std;\n\ntypedef unsigned long long ull;\ntypedef pair pii;\ntypedef vector vi;\ntypedef long double ld;\ntypedef long long ll;\n\nconst int maxint=numeric_limits::max();\nconst ll maxll=numeric_limits::max();\nconst int arr=2e5+10;\nconst int ar=2e3+10;\nconst ld pi=acos(-1);\nconst ll md=1e9+7;\nconst ld eps=1e-6;\n\n///---program start---///\n\ntypedef vector< vector > matrix;\n\nmatrix operator *(matrix& a,matrix& b)\n{\n matrix res=a;\n for (int i=0;i<2;i++)\n for (int j=0;j<2;j++)\n res[i][j]=0;\n for (int i=0;i<2;i++)\n for (int j=0;j<2;j++)\n for (int k=0;k<2;k++)\n res[i][j]=(res[i][j]+a[i][k]*b[k][j]+md)%md;\n return res;\n}\n\nconst matrix a={{4,0},{-1,2}};\n\nmatrix _pow(ll n)\n{\n if (n==1) return a;\n if (n%2==1) return a*_pow(n-1);\n matrix dop=_pow(n/2);\n return dop*dop;\n}\n\nmain()\n{\n ll n;\n cin>>n;\n matrix use=_pow(n);\n cout<<(use[0][0]+use[1][0]+md)%md;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "72280d30a373d0f7c2c418846d04cdb5", "src_uid": "782b819eb0bfc86d6f96f15ac09d5085", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n\nlong long a[20];\nlong long b[20][10][10];\nlong long c[20][10][10];\n\nlong long dp(long long n, int p) {\n long long n0 = n;\n long long ans = 0;\n while (n >= 10) {#include\nusing namespace std;\n\nlong long a[20];\nlong long b[20][10][10];\nlong long c[20][10][10];\n\nlong long dp(long long n, int p) {\n long long n0 = n;\n long long ans = 0;\n while (n >= 10) {\n long long m = n;\n long long e = 0;\n while ((m + 10) % (a[e] * 10) < 10)\n e++;\n if (e == 1 || a[e] >= n) {\n long long m = n;\n int k = 0;\n while (m != 0) {\n if (m % 10 >= k)\n k = m % 10;\n m = m / 10;\n }\n ans += 1;\n if (p < k)\n n -= k;\n else\n n -= p;\n continue;\n }\n int i = 0;\n int k = 0;\n for (i; m != 0; i++) {\n if (i >= e && m % 10 >= k)\n k = m % 10;\n m = m / 10;\n }\n if (k < p)\n k = p;\n\n if (b[e][(n + 10) % a[e]][k] == -1) {\n dp(n % a[e], k);\n }\n ans += b[e][(n + 10) % a[e]][k];\n n = n / a[e] * a[e] + c[e][(n + 10) % a[e]][k];\n }\n\n long long e = 0;\n while ((n0 + 10) % a[e] < 10)\n e++;\n e--;\n if (a[e] > n0) {\n b[e][(n0 + 10) % a[e]][p] = ans;\n c[e][(n0 + 10) % a[e]][p] = n;\n }\n return ans;\n}\n\n\nint main() {\n a[0] = 1;\n for (int i = 1; i <= 18; i++)\n a[i] = a[i - 1] * 10;\n for (int i = 0; i < 20; i++)\n for (int j = 0; j < 10; j++)\n for (int k = 0; k < 10; k++) {\n b[i][j][k] = -1;\n c[i][j][k] = -1;\n }\n long long n;\n cin >> n;\n if (n == 0) {\n cout << 0 << endl;\n return 0;\n }\n cout << dp(n, 0) + 1 << endl;\n return 0;\n}\n long long m = n;\n long long e = 0;\n while ((m + 10) % a[e] < 10)\n e++;\n e--;\n if (e == 1 || a[e] >= n) {\n long long m = n;\n int k = 0;\n while (m != 0) {\n if (m % 10 >= k)\n k = m % 10;\n m = m / 10;\n }\n ans += 1;\n if (p < k)\n n -= k;\n else\n n -= p;\n continue;\n }\n int i = 0;\n int k = 0;\n for (i; m != 0; i++) {\n if (i >= e && m % 10 >= k)\n k = m % 10;\n m = m / 10;\n }\n if (k < p)\n k = p;\n\n if (b[e][(n + 10) % a[e]][k] == -1) {\n dp(n % a[e], k);\n }\n ans += b[e][(n + 10) % a[e]][k];\n n = n / a[e] * a[e] + c[e][(n + 10) % a[e]][k];\n }\n\n long long e = 0;\n while ((n0 + 10) % a[e] < 10)\n e++;\n e--;\n if (a[e] > n0) {\n b[e][(n0 + 10) % a[e]][p] = ans;\n c[e][(n0 + 10) % a[e]][p] = n;\n }\n return ans;\n}\n\n\nint main() {\n a[0] = 1;\n for (int i = 1; i <= 18; i++)\n a[i] = a[i - 1] * 10;\n for (int i = 0; i < 20; i++)\n for (int j = 0; j < 10; j++)\n for (int k = 0; k < 10; k++) {\n b[i][j][k] = -1;\n c[i][j][k] = -1;\n }\n long long n;\n cin >> n;\n if (n == 0) {\n cout << 0 << endl;\n return 0;\n }\n cout << dp(n, 0) + 1 << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "af897a169a91c5cd47c404dcfd8bd697", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\nint main()\n{\n long long m,d,num,op=0;\n cin>>num;\n while(num) \n {\n m=0;\n d=num;\n while(d)\n {\n m=(m>(d%10))?m:(d%10);\n d/=10; \n } \n num-=m;op++; \n }\n cout<\n#include\n#include\nusing namespace std;\nint num(int n)\n{\n string s=to_string(n);\n return(*max_element(all(s))-'0');\n}\nint main()\n{\n int n,ans=0;\n cin>>n;\n while(n!=0)\n {\n ans++;\n n-=num(n);\n }\n cout<\n#include\n#define LL long long\nusing namespace std;\nLL f[25][10][10];\nint g[25][10][10];\nchar s[25];\nLL n;\nint L;\nint main()\n{\n\tLL A;\n\tint i,j,k,l,B,C;\n\tscanf(\"%I64d\",&n);\n\tif (n<10)\n\t{\n\t\tprintf(\"1\\n\"); return 0;\n\t}\n\tfor (i=1;i<=9;i++)\n\t\tfor (j=0;j<=9;j++)\n\t\t\tif (i>j)\n\t\t\t{\n\t\t\t\tf[1][i][j]=1; g[1][i][j]=10-i+j;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tf[1][i][j]=2; g[1][i][j]=10-i;\n\t\t\t}\n\tfor (i=2;i<=19;i++)\n\t\tfor (j=1;j<=9;j++)\n\t\t\tfor (k=0;k<=9;k++)\n\t\t\t{\n\t\t\t\tA=0; B=k;\n\t\t\t\tfor (l=9;l>=0;l--)\n\t\t\t\t{\n\t\t\t\t\tA+=f[i-1][max(j,l)][B]; B=g[i-1][max(j,l)][B];\n\t\t\t\t}\n\t\t\t\tf[i][j][k]=A; g[i][j][k]=B;\n\t\t\t}\n\tsprintf(s,\"%I64d\",n);\n\tL=strlen(s); A=0; B=n%10;\n\tfor (i=L-2;i>=1;i--)\n\t{\n\t\tC=0;\n\t\tfor (j=0;j<=i-1;j++) C=max(C,s[j]-'0');\n\t\tfor (j=s[i]-'0';j>=0;j--)\n\t\t{\n\t\t\tA+=f[L-i-1][max(j,C)][B]; B=g[L-i-1][max(j,C)][B];\n\t\t}\n\t}\n\tfor (i=s[0]-'0';i>=1;i--)\n\t{\n\t\tA+=f[L-1][i][B]; B=f[L-1][i][B];\n\t}\n\tfor (i=L-2;i>=1;i--)\n\t\tfor (j=9;j>=1;j--)\n\t\t{\n\t\t\tA+=f[i][j][B]; B=f[i][j][B];\n\t\t}\n\tprintf(\"%I64d\\n\",A+1); return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1ced45b044057bd926e8ac4a998b9164", "src_uid": "fc5765b9bd18dc7555fa76e91530c036", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint64_t mod = 998244353;\n \nint64_t mult(int64_t n, int64_t k){\n if(k == 1){\n return n % mod;\n }\n else{\n if(k % 2 == 0){\n int64_t ans = mult(n, k/2);\n return (ans % mod + ans % mod) % mod;\n }\n else{\n int64_t ans = mult(n, k/2);\n return ((ans % mod + ans % mod) + n % mod) % mod;\n }\n }\n}\n \nint64_t mul(int64_t n, int64_t k){\n if(k == 0){\n return 1;\n }\n else{\n if(k % 2 == 0){\n int64_t ans = mul(n, k/2);\n return mult(ans, ans);\n }\n else{\n int64_t ans = mul(n, k/2);\n return mult(ans, mult(ans, n));\n }\n }\n}\nint main(){\n ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr);\n int64_t n;\n cin >> n;\n int64_t two = 2;\n int64_t b = mul(two, n);\n b = mul(b, mod - 2);\n if(n <= 2) cout << b;\n if(n == 3) cout << mult(2, b) % mod;\n \u00ec(n >= 4){\n int64_t f[200005];\n f[2] = 1; f[3] = 2;\n for(int i = 4; i <= n; i++){\n f[i] = (f[i - 1] + f[i - 2]) % mod;\n }\n cout << (f[n] * b) % mod;\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "85cea0925c161199973be3689ddd9e44", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n\n\nint main()\n{\n\n const int maxn = 2e5;\n vector dp (maxn + 1);\n Mint odd = 0;\n Mint even = 0;\n for (int i = 1; i <= maxn; i++) {\n if (i % 2 == 1) {\n dp[i] = even;\n }\n else {\n dp[i] = odd;\n }\n if (i % 2 == 1) {\n dp[i] += 1;\n }\n if (i % 2 == 0) even += dp[i];\n else odd += dp[i];\n }\n int n;\n cin >> n;\n cout << dp[n] / power ((Mint) 2, n) << '\\n';", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e7c7226f75ae0cf0600cb254b6e133d8", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std ; \ntypedef long long int ll;\nll dp[300000];\nll e = 998244353;\nlong long int me(long long int x,long long int n,long long int M)\n{\n long long int result=1;\n while(n>0)\n {\n if(n%2==1)\n result=(__int128)(result*x)%M;\n x=(x*x)%M;\n n=n/2;\n }\n return result;\n}\n//6)calculates : (1/(a^b))%M;\nll modInverse(ll A,ll B,ll M)\n{\n ll k=B*(M-2);\n return me(A,k,M);\n}\n\n\n\n\n\n\nint main()\n{\n ll n;cin>>n;\n ll sum1=1;\n ll sum2=1;\n dp[0]=1;\n dp[1]=1;\n ll i = 2 ; \n while(i<=n)\n {\n /* ll sum = 0 ; \n ll j = 1 ; \n while(j<=i)\n {\n sum = sum + dp[i-j] ; \n j=j+2;\n }\n dp[i]=sum; */\n \n if(i%2==0)\n {\n dp[i]=sum2;\n }\n else\n {\n dp[i]=sum1;\n }\n \n \n // cout<\nusing namespace std;\n\ntypedef long long LL;\n\ninline void exgcd(LL a, LL b, LL &x, LL &y)\n{\n if (!b)\n {\n x = 1;\n y = 0;\n return;\n }\n exgcd(b, a % b, y, x);\n y -= a / b * x;\n}\n\ninline LL inv(LL a, LL mo)\n{\n LL x, y;\n exgcd(a, mo, x, y);\n return x >= 0 ? x : x + mo;\n}\n\ninline LL power(LL a, LL n, LL mo)\n{\n LL res = 1;\n while (n)\n {\n if (n & 1)\n res = 1LL * res * a % mo;\n a = 1LL * a * a % mo;\n n >>= 1;\n }\n return res;\n}\n\nlong long fi[200010] = {0};\nlong long mo = 998244353;\nint main()\n{\n long long x;\n cin >> x;\n fi[1] = 1;\n fi[2] = 1;\n for (int j = 3 ; j < x; j++)\n {\n fi[j] = (fi[j-1] + fi[j-2])%mo;\n }\n long long a = inv(2,mo);\n long long answer = (fi[x]*power(a,x,mo))%mo;\n cout << answe << endl;\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cdb95a7d8a0d978e27ea4a68ed555fae", "src_uid": "cec37432956bb0a1ce62a0188fe2d805", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include\n#define ll long long\n#define pb push_back\n#define mk make_pair\n#define rint register int\n#define pa pair\n#define debug(x) cerr<<#x<<\"=\"<>=1;} return res;}\ninline int pls(int a,int b){a+=b;return a>=mod?a-mod:a;}\ninline int mns(int a,int b){a-=b;return a<0?a+mod:a;}\nint n,k,m,Idx[15][222],cnt;\npa tmp[101000];\nstruct Ma{\n\tint a[417][417];\n\tinline void I(){memset(a,0,sizeof(a));for(rint i=1;i<=cnt;++i) a[i][i]=1;}\n}trs,Ans;\n\ninline Ma operator * (Ma p,Ma q){\n\tMa res;memset(res.a,0,sizeof(res.a));\n\tfor(rint i=1;i<=cnt;++i)\n\tfor(rint j=1;j<=cnt;++j)\n\t{\n\t\t__int128 w=0;\n\t\tfor(rint k=1;k<=cnt;++k)\n\t\tw+=(ll)p.a[i][k]*q.a[k][j];\n\t\tres.a[i][j]=w%mod;\n\t}\n\treturn res;\n}\ninline Ma ksm(Ma x,int y){\n\tMa res;res.I();\n\twhile(y){\n\t\tif(y&1) res=res*x;\n\t\tx=x*x;y>>=1;\n\t}return res;\n}\ninline void Solve(){\n\tmemset(trs.a,0,sizeof(trs.a));\n\tmemset(Ans.a,0,sizeof(Ans.a));\n\tdebug(cnt);\n\tfor(rint i=1;i<=cnt;++i){\n\t\tpa o=tmp[i];\n\t\tint fir=o.first,sec=o.second,bit=__builtin_popcount(sec);\n//\t\tdebug(fir);\n//\t\tdebug(sec);\n\t\tif(sec&1) {\n\t\t\tsec>>=1;\n\t\t\ttrs.a[i][Idx[fir][sec]]=bit;\n\t\t\tsec|=(1<>=1;\n\t\t\ttrs.a[i][Idx[fir][sec]]=1;\n\t\t\tsec|=(1<\n#include \n#include \n#include \n\nusing namespace std;\nconstexpr int MOD = 1e9+7;\nclass Modular {\npublic:\n int val;\n int normalize(const long long x) const {\n if (x <= -MOD || x >= MOD) return x % MOD;\n return x;\n }\n Modular ():val(0){}\n Modular (long long val):val(normalize(val)){}\n\n operator long long (){ return val >= 0 ? val : val + MOD; }\n\n Modular operator *(const Modular &ri) const { return val * 1LL * ri.val % MOD; }\n Modular operator +(const Modular &ri) const{ return (val + ri.val) % MOD; }\n};\n\n//Modular operator +=(Modular &le, const Modular ri) { return le = (le.val + ri.val) % MOD; }\n//Modular operator *=(Modular &le, const Modular ri) { return le = (le.val * 1LL * ri.val) % MOD; }\n\n/*\nModular pot(Modular a, long long b) {\n Modular res = 1;\n while(b > 0){\n if (b & 1) res = res * a;\n b /= 2;\n a= a * a;\n }\n return res;\n}\n */\n\n\n\n#define T Modular\nconst int SZ=(1<<4)*13;\nstruct mat_t {\n T M[SZ][SZ] = {};\n mat_t operator * (const mat_t a) const {\n mat_t res;\n for (long long(r) = (0); (r) < (long long)(SZ); ++(r)) {\n for (long long(c) = (0); (c) < (long long)(SZ); ++(c)) {\n T val = 0;\n for (long long(k) = (0); (k) < (long long)(SZ); ++(k)) val = val + this->M[r][k] * a.M[k][c];\n res.M[r][c] = val;\n }\n }\n return res;\n }\n\n vector operator * (const vector & rhs) {\n vectorRES(SZ);\n for (long long(r) = (0); (r) < (long long)(SZ); ++(r)) {\n for (long long(c) = (0); (c) < (long long)(SZ); ++(c)) {\n RES[r] = RES[r] + M[r][c] * rhs[c];\n }\n }\n return RES;\n }\n\n void zero() {\n for (long long(g) = (0); (g) < (long long)(SZ); ++(g)) M[g][g] = 1;\n }\n\n /*\n void print() {\n for (long long(r) = (0); (r) < (long long)(SZ); ++(r)) {\n for (long long(c) = (0); (c) < (long long)(SZ); ++(c)) {\n cout << M[r][c] << \" \";\n }\n cout << endl;\n }\n }\n */\n};\n\n#ifdef LOCAL\n#define DB(x){if(cond)cerr<<__LINE__<<\" \"<<#x<<\" \" <=(b);--i)\n#define FORDE(rit,x)for(auto rit=(x).rbegin();rit!=(x).rend();rit++)\n#define VV vector\n#define PB push_back\n#define ALL(x) (x).begin(),(x).end()\ntemplatebool MA(X&a,Y b){if(abool MI(X&a,Y b){if(a>b){a=b;return true;} return false;}\ntypedef long long LL,ll;typedef long double LD,ld;\ntypedef arrayI2,i2;typedef VVVI,vi;\nusing namespace std;\nint cond=0;\n//endregion\n\nint multi=0,gcj=0;\n\nint pos(int m, int p) { return m * 13 + p; }\n\nstruct Solver {\n void solve() {\n mat_t res; res.zero();\n mat_t one = {};\n int N,K,M;\n cin>>N>>K>>M;\n\n REP(m,(1<0;b/=2){\n if(b&1) res=res*one;\n one=one*one;\n }\n DB(\"\")\n VVRES(SZ);\n RES[pos(0,0)] = 1;\n\n VV ODP = res * RES;\n Modular wynik = 0;\n REP(m,(1<().get();\n srand(seed); mt19937 rng(seed);\n */\n\n ios::sync_with_stdio(false),cin.tie(nullptr);\n FOR(a,1,argc-1){if(argv[a][0]=='g') { Solver2 solver; solver.gen(); return 0; }}\n FOR(a,1,argc-1){if(argv[a][0]=='q') cond=1U<<30U;}\n cout.setf(ios::fixed),cout.precision(10);\n int t{};if(multi||gcj)cin>>t;else t=1;\n bool isBrute=false;FOR(a,1,argc-1)if(argv[a][0]=='b')isBrute=true;\n FOR(i,1,t){if(cond)cerr<<__LINE__<<\" \"<();\n auto solver2 = make_unique();\n if (isBrute)\n solver2->brute();\n else\n solver->solve();\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7d571afdc5b76a8f83410bda5d82227f", "src_uid": "87931a8ae9a76d85bd2a2b4bba93303d", "difficulty": 3000.0} {"lang": "GNU C++14", "source_code": "//region trash\n//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n\n#include \n#include \n#include \n#include \n\nusing namespace std;\nconstexpr int MOD = 1e9+7;\nclass Modular {\npublic:\n int val;\n int normalize(const long long x) const {\n if (x <= -MOD || x >= MOD) return x % MOD;\n return x;\n }\n Modular ():val(0){}\n explicit Modular (long long val):val(normalize(val)){}\n\n ////operator long long (){ return val >= 0 ? val : val + MOD; }\n\n Modular operator *(const Modular &ri) const { return Modular(val * 1LL * ri.val % MOD); }\n Modular operator +(const Modular &ri) const{ return Modular((val + ri.val) % MOD); }\n};\n\n//Modular operator +=(Modular &le, const Modular ri) { return le = (le.val + ri.val) % MOD; }\n//Modular operator *=(Modular &le, const Modular ri) { return le = (le.val * 1LL * ri.val) % MOD; }\n\n/*\nModular pot(Modular a, long long b) {\n Modular res = 1;\n while(b > 0){\n if (b & 1) res = res * a;\n b /= 2;\n a= a * a;\n }\n return res;\n}\n */\n\n\n\n#define T Modular\nconst int SZ=(1<<4)*13;\nstruct mat_t {\n T M[SZ][SZ] = {};\n mat_t operator * (const mat_t a) const {\n mat_t res;\n for (long long(r) = (0); (r) < (long long)(SZ); ++(r)) {\n for (long long(c) = (0); (c) < (long long)(SZ); ++(c)) {\n T val = 0;\n for (long long(k) = (0); (k) < (long long)(SZ); ++(k)) val = val + this->M[r][k] * a.M[k][c];\n res.M[r][c] = val;\n }\n }\n return res;\n }\n\n vector operator * (const vector & rhs) {\n vectorRES(SZ);\n for (long long(r) = (0); (r) < (long long)(SZ); ++(r)) {\n for (long long(c) = (0); (c) < (long long)(SZ); ++(c)) {\n RES[r] = RES[r] + M[r][c] * rhs[c];\n }\n }\n return RES;\n }\n\n void zero() {\n for (long long(g) = (0); (g) < (long long)(SZ); ++(g)) M[g][g] = 1;\n }\n\n /*\n void print() {\n for (long long(r) = (0); (r) < (long long)(SZ); ++(r)) {\n for (long long(c) = (0); (c) < (long long)(SZ); ++(c)) {\n cout << M[r][c] << \" \";\n }\n cout << endl;\n }\n }\n */\n};\n\n#ifdef LOCAL\n#define DB(x){if(cond)cerr<<__LINE__<<\" \"<<#x<<\" \" <=(b);--i)\n#define FORDE(rit,x)for(auto rit=(x).rbegin();rit!=(x).rend();rit++)\n#define VV vector\n#define PB push_back\n#define ALL(x) (x).begin(),(x).end()\ntemplatebool MA(X&a,Y b){if(abool MI(X&a,Y b){if(a>b){a=b;return true;} return false;}\ntypedef long long LL,ll;typedef long double LD,ld;\ntypedef arrayI2,i2;typedef VVVI,vi;\nusing namespace std;\nint cond=0;\n//endregion\n\nint multi=0,gcj=0;\n\nint pos(int m, int p) { return m * 13 + p; }\n\nstruct Solver {\n void solve() {\n mat_t res; res.zero();\n mat_t one = {};\n int N,K,M;\n cin>>N>>K>>M;\n\n REP(m,(1<0;b/=2){\n if(b&1) res=res*one;\n one=one*one;\n }\n DB(\"\")\n VVRES(SZ);\n RES[pos(0,0)] = 1;\n\n VV ODP = res * RES;\n Modular wynik = 0;\n REP(m,(1<().get();\n srand(seed); mt19937 rng(seed);\n */\n\n ios::sync_with_stdio(false),cin.tie(nullptr);\n FOR(a,1,argc-1){if(argv[a][0]=='g') { Solver2 solver; solver.gen(); return 0; }}\n FOR(a,1,argc-1){if(argv[a][0]=='q') cond=1U<<30U;}\n cout.setf(ios::fixed),cout.precision(10);\n int t{};if(multi||gcj)cin>>t;else t=1;\n bool isBrute=false;FOR(a,1,argc-1)if(argv[a][0]=='b')isBrute=true;\n FOR(i,1,t){if(cond)cerr<<__LINE__<<\" \"<();\n auto solver2 = make_unique();\n if (isBrute)\n solver2->brute();\n else\n solver->solve();\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8b55e378fc8bd207eb36c00efd617681", "src_uid": "87931a8ae9a76d85bd2a2b4bba93303d", "difficulty": 3000.0} {"lang": "GNU C++11", "source_code": "#include\n#define rep(XX,AA,BB) for(int XX=AA;XX<=BB;XX++)\n#define tep(XX,AA,BB) for(int XX=AA;XX>=BB;XX--)\n#define LL long long\nconst int K=14;\nconst int M=1<<4;\nconst int MX=310;\nconst LL MOD=1e9+7;\nusing namespace std;\n\nint n,m,k;\nint tot=0,maxn;\nint get[K][M];\n\nvoid read(int &x){\n\tchar c;\n\tfor(;c>'9'||c<'0';c=getchar());\n\tfor(;'0'<=c&&c<='9';c=getchar())x=(x<<3)+(x<<1)+(c^48);\n}\n\nstruct nn{\n\tLL a[MX][MX];\n\tvoid MEM(){rep(i,0,maxn)rep(j,0,maxn)a[i][j]=0;}\n}hlp;\n\nnn MUL(nn A,nn B){\n\tnn C;C.MEM();\n\trep(i,1,tot)rep(j,1,tot){\n\t\tC.a[i][j]=0;\n\t\trep(r,1,tot){\n\t\t\tC.a[i][j]+=A.a[i][r]*B.a[r][j]%MOD;\n\t\t\tC.a[i][j]%=MOD;\n\t\t}\n\t}\n\treturn C;\n}\n\nLL KSM(int y){\n\tnn res;res.MEM();\n\tLL ans;\n\tres.a[1][1]=1;\n\twhile(y){\n\t\tif(y%2==1)res=MUL(res,hlp);\n\t\thlp=MUL(hlp,hlp);\n\t\ty/=2;\n\t}\n\trep(num,0,maxn)ans=(ans+res.a[1][get[k][num]])%MOD;\n\treturn ans;\n}\n\nint main(){\n\tread(n);read(k);read(m);\n\tmaxn=(1<\n#pragma GCC optimize(3,\"Ofast\",\"-funroll-loops\",\"-fdelete-null-pointer-checks\")\n#pragma GCC target(\"ssse3\",\"sse3\",\"sse2\",\"sse\",\"avx2\",\"avx\")\n#define lowbit(x) ((x)&-(x))\n#define HohleFeuerwerke using namespace std\ntypedef unsigned int u32;\ntypedef long long i64;\nHohleFeuerwerke;\ni64 n;\ninline bool isprime(i64 x){\n\tfor(i64 i=2;i<=sqrt(x);i++)\n\t\tif(x%i==0) return false;\n\treturn true;\n}\ninline i64 primes(i64 x){\n if(x<=1) return 0;\n const int eps=128;const int eps_bit=8;\n u32 S2=sqrt(x);u32 S3=pow(x,1.0/3);u32 S4=sqrt(S2);\n u32 B=std::max(2ull,std::min(i64(S2),i64(S3*std::max(1.0,pow(log(x),3)*0.001))));\n u32 U=x/B+eps;u32 a,b,t;register u32 p,q,r,u,v;i64 sum=0;\n vector mu(B+1);mu[1]=1;\n for(a=2;a<=B;++a)\n if(!mu[a]) for(b=a;b<=B;b+=a) mu[b]=mu[b]<0?1:-1;\n for(a=2;a*a<=B;++a)\n if(mu[a*a]) for(b=a*a;b<=B;b+=a*a) mu[b]=0;\n vector pi(U),primes(u32(U/log(U)*1.25506)),md(U);u32 count=0;\n md[1]=1<<30,primes[0]=1;\n for(a=6;aR) v=R;\n sum+=(i64)(pi[v]-pi[u-1])*t;\n }\n }\n vector bit(U);\n vector nxt(B+2);\n for(q=1;q<=B;++q) nxt[q]=q+!mu[q];\n nxt[B+1]=B+1;\n for(r=1;r<=U-eps;++r) bit[r]=r;\n for(p=1;p<=S4;++p)\n if(pi[p]!=pi[p-1]){\n i64 m=x/p;\n if(p<=eps_bit){\n for(q=std::max(p,B/p)+1;q<=B;++q){\n while(q!=nxt[q]) q=nxt[q]=nxt[nxt[q]];\n if(q>B) break;\n if(md[q]<=p){\n nxt[q]=q+1;\n continue;\n }\n sum-=mu[q]*bit[m/q];\n }\n for(r=1;rp;\n if(pi[p]eps_bit){\n for(r=1;rB) break;\n if(md[q]<=p){\n nxt[q]=q+1;\n continue;\n }\n if(mu[q]==1) for (a=m/q;a;a-=lowbit(a)) sum-=bit[a];\n\t\t\t\t\telse for (a=m/q;a;a-=lowbit(a)) sum+=bit[a];\n }\n for(a=p;a\nusing namespace std;\ntypedef unsigned int uint;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef __int128 lll;\ntypedef unsigned __int128 ulll;\n#define Te template\n#define pb push_back\n#define gu getchar_unlocked\n#define pu putchar_unlocked\n\n\nconst int M=1000010,Mp=1000010,Pn=100000,Pk=100;\nuint ar[(M>>6)+5]={0};//Mp=max size of the prime\nint z=0,Pr[Mp],C[M],dp[Pn][Pk];\nvoid Sieve(int N)\n{\n bitset st;\n st[1]=true;\n for(int i=4;i>1);if(Pr[k-1]>=n) return 1;\nreturn phi(n,k-1)-phi(n/Pr[k-1],k-1);}\nll Legendre(ll n){if(n>1);\nfor(i=a;i>n;\n ll ans=0;\n ll cnt=0;\n for(int i=0;i\n#define ll long long\n#define maxn 2000000\nusing namespace std;\nll P(ll m, ll n);\nll pi(ll x);\nll phi(ll m, ll n);\nbool isprm[2000005];\nint cntprm[2000005];\nvector prm;\nvoid Init(){\n for(int i=2;i<=maxn;++i){\n isprm[i] = true;\n }\n for(int i=2;i<=maxn;++i){\n cntprm[i] = cntprm[i-1] + isprm[i];\n if(isprm[i]){\n prm.push_back(i);\n for(int j=i+i;j<=maxn;j+=i) isprm[j] = false;\n }\n }\n}\nll sol(ll x){\n ll ans = 0;\n ll sq = sqrt(x);\n for(int i=0;i<(int)prm.size()&&prm[i]<=sq;++i){\n ll a = prm[i], b = x/a;\n if(b<=maxn) ans+=cntprm[b] - cntprm[a] ;\n else{\n ans+=pi(b) - cntprm[a];\n }\n }\n return ans;\n}\nint main(void){\n ll n;\n Init();\n cin>>n;\n cout << cntprm[(int)cbrt(n)] + sol(n) << \"\\n\" ;\n}\nll phi(ll m, ll n){\n if(m){\n if(n){\n //if(m\n#define ll long long int\nusing namespace std;\nll n,ans;\nll v[120000001],p[120000001],t;\nvoid find_prime()\n{\n\tfor(int i=2;i<=120000000;++i)\n\t{\n\t\tif(v[i]==0)\n\t\t{\n\t\t\tv[i]=i;\n\t\t\tp[++t]=i;\n\t\t}\n\t\tfor(int j=1;j<=t;++j)\n\t\t{\n\t\t\tif(p[j]>v[i]||p[j]>n/i) break;\n\t\t\tv[i*p[j]]=p[j];\n\t\t}\n\t}\n}\t\nint main()\n{\n\tscanf(\"%lld\",&n);\n\tfind_prime();\n\tfor(int i=1;i<=t;++i)\n\t{\n\t for(int j=i+1;j<=t;++j)\n\t {\n\t \tif(p[i]*p[j]<=n)\n\t \t ++ans;\n\t \telse\n\t\t\t break;\n\t }\n\t}\n\tfor(int i=1;i<=t;++i)\n\t{\n\t\tif(p[i]*p[i]*p[i]<=n)\n\t\t ++ans;\n\t\telse\n\t\t break;\n\t}\n\tprintf(\"%d\",ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e45a68943bde899c82b118d51a63e0d7", "src_uid": "ffb7762f1d60dc3f16e9b27ea0ecdd7d", "difficulty": 2400.0} {"lang": "GNU C++17 (64)", "source_code": "#include \"bits/stdc++.h\"\r\nusing namespace std;\r\n#define all(x) begin(x),end(x)\r\ntemplate ostream& operator<<(ostream &os, const pair &p) { return os << '(' << p.first << \", \" << p.second << ')'; }\r\ntemplate::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = \" \"; return os; }\r\n#define debug(a) cerr << \"(\" << #a << \": \" << a << \")\\n\";\r\ntypedef long long ll;\r\ntypedef vector vi;\r\ntypedef vector vvi;\r\ntypedef pair pi;\r\nconst int mxN = 1e5+1, oo = 1e9;\r\nconst long long MD = 998244353;\r\ntemplate struct mdint {\r\n int d=0;\r\n mdint () {d=0;}\r\n mdint (long long _d) : d(_d%MOD){};\r\n friend mdint& operator+=(mdint& a, const mdint& o) {\r\n a.d+=o.d; if(a.d>=MOD) a.d-=MOD;\r\n return a;\r\n }\r\n friend mdint& operator-=(mdint& a, const mdint& o) {\r\n a.d-=o.d; if(a.d<0) a.d+=MOD;\r\n return a;\r\n }\r\n friend mdint& operator*=(mdint& a, const mdint& o) {\r\n return a = mdint((ll)a.d*o.d);\r\n }\r\n mdint operator*(const mdint& o) const {\r\n mdint res = *this;\r\n res*=o;\r\n return res;\r\n }\r\n mdint operator+(const mdint& o) const {\r\n mdint res = *this;\r\n res+=o;\r\n return res;\r\n }\r\n mdint operator-(const mdint& o) const {\r\n mdint res = *this;\r\n res-=o;\r\n return res;\r\n }\r\n mdint operator^(long long b) const {\r\n mdint tmp = 1;\r\n mdint power = *this;\r\n while(b) {\r\n if(b&1) {\r\n tmp = tmp*power;\r\n }\r\n power = power*power;\r\n b/=2;\r\n }\r\n return tmp;\r\n }\r\n friend mdint operator/=(mdint& a, const mdint& o) {\r\n a *= (o^(MOD-2));\r\n return a;\r\n }\r\n mdint operator/(const mdint& o) {\r\n mdint res = *this;\r\n res/=o;\r\n return res;\r\n }\r\n bool operator==(const mdint& o) { return d==o.d;}\r\n bool operator!=(const mdint& o) { return d!=o.d;}\r\n friend istream& operator>>(istream& c, mdint& a) {return c >> a.d;}\r\n friend ostream& operator<<(ostream& c, const mdint& a) {return c << a.d;}\r\n};\r\nusing mint = mdint;\r\n#define rep(i,n) for(int i=0;i struct matrix {\r\n T mat[N][N] = {};\r\n friend matrix operator*(const matrix& a, const matrix& b) {\r\n matrix res;\r\n rep(i,N) rep(j,N) rep(k,N) {\r\n res.mat[i][k]+=a.mat[i][j]*b.mat[j][k];\r\n }\r\n return res;\r\n }\r\n static matrix eye() {\r\n matrix res;\r\n for(int i=0;i> n >> m;\r\n matrix mat;\r\n vector ws(n);\r\n for(auto& i: ws) cin >> i;\r\n sort(all(ws),[&](string a, string b) {return a.size()\r\n#include\r\n#include\r\n#include \r\n#define int long long\r\n#define pa pair\r\n#define mp make_pair \r\nusing namespace std;\r\ninline int read(){int x=0,f=1,ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f;}\r\ninline void write(int x){if (x<0) putchar('-'),x=-x; if (x>=10) write(x/10); putchar(x%10+'0');}\r\ninline void writeln(int x){write(x); puts(\"\");}\r\nconst int N=45,M=161,mod=998244353;\r\nint root,n,m,cnt,End[N],tran[N][26];\r\nchar s[N];\r\ninline void insert(){\r\n\r\n\tint now=root,len=strlen(s+1);\r\n\tfor (int i=1;i<=len;i++){\r\n\t\tint c=s[i]-'a';\r\n\t\tif (tran[now][c]==-1) tran[now][c]=++cnt;\r\n\t\t now=tran[now][c];\r\n\t}\r\n\tEnd[now]|=1;\r\n}\r\ninline void init(){\r\n\tmemset(tran,-1,sizeof tran);\r\n\tn=read(); m=read(); root=0;\r\n\tfor (int i=1;i<=n;i++){\r\n\t\tscanf(\"%s\",s+1);\r\n\t\tinsert();\r\n\t}\r\n}\r\nstruct matrix{\r\n\tint mat[M][M];\t\r\n\tmatrix() {memset(mat,0,sizeof(mat));}\t\r\n\tmatrix operator * (const matrix &C) const\r\n\t{\r\n\t\tmatrix ans;\r\n\t\tfor(int i=0;iid;\r\nint get(pa p){\r\n\tif (p.first>p.second) swap(p.first,p.second);\r\n\tif (!id.count(p)){\r\n\t\tint k=id.size();\r\n\t\tid[p]=k;\r\n\t\tq[++t]=p;\r\n\t}\r\n\treturn id[p];\r\n}\r\ninline matrix pow(matrix B,int k){\r\n\tmatrix C;\r\n\tfor (int i=0;i>=1,B=B*B){\r\n\t\tif (k&1) C=C*B;\r\n\t}\r\n\treturn C;\r\n}\r\ninline void solve(){\r\n\tid[mp(0,0)]=0; q[++t]=(pa){0,0};\r\n\twhile (h\r\nusing namespace std;\r\n\r\n#pragma GCC target (\"avx2\")\r\n#pragma GCC optimization (\"O3\")\r\n#pragma GCC optimization (\"unroll-loops\")\r\n\r\n#define INF 2000000000\r\n#define INFL 200000000000000000LL\r\n\r\ntypedef long long int ll;\r\ntypedef pair ii;\r\ntypedef pair iii;\r\ntypedef vector vi;\r\ntypedef vector vii;\r\n\r\n#define getbit(n,i) (((n)&(1LL<<(i)))!=0)\r\n#define setbit0(n,i) ((n)&(~(1LL<<(i))))\r\n#define setbit1(n,i) ((n)|(1LL<<(i)))\r\n#define lastone(n) ((n)&(-(n)))\r\n\r\n#define fi first\r\n#define se second\r\n#define PI (acos(-1))\r\n#define mod (998244353)\r\n\r\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\r\n\r\ntemplate ostream& operator<<(ostream &s,pair a)\r\n{\r\n s<>=1;\r\n if(n){\r\n for(int i=0;i trie(1);\r\nvoid add_string(string &s)\r\n{\r\n int v=0;\r\n for(char ch:s)\r\n {\r\n ch-='a';\r\n if(trie[v].next[ch]==-1)\r\n {\r\n trie[v].next[ch]=trie.size();\r\n trie.emplace_back();\r\n }\r\n v=trie[v].next[ch];\r\n }\r\n trie[v].en++;\r\n}\r\nint vis[K][K];\r\nint cnt = 0;\r\nint dfs(int x,int y){\r\n\tif(vis[x][y]!=-1)return vis[x][y];\r\n\tint cur = vis[x][y] = cnt++;\r\n\tfor(int c = 0;c<26;c++){\r\n\t\tif(trie[x].next[c]==-1||trie[y].next[c]==-1)continue;\r\n\t\tint l = trie[x].next[c];\r\n\t\tint l2 = trie[y].next[c];\r\n\t\tint p = dfs(l,l2);\r\n\t\tb[cur][p]++;\r\n\t\tif(trie[l].en){\r\n\t\t\tp = dfs(0,l2);\r\n\t\t\tb[cur][p]++;\r\n\t\t}\r\n\t\t\r\n\t\tif(trie[l2].en){\r\n\t\t\tp = dfs(l,0);\r\n\t\t\tb[cur][p]++;\r\n\t\t}\r\n\t\t\r\n\t\t\r\n\t\tif(trie[l].en&&trie[l2].en){\r\n\t\t\tp = dfs(0,0);\r\n\t\t\tb[cur][p]++;\r\n\t\t}\r\n\t}\r\n\treturn cur;\r\n}\r\nint main()\r\n{\r\n ios::sync_with_stdio(false);\r\n cin.tie(NULL);\r\n \r\n int T=1;\r\n //scanf(\"%d\",&T);\r\n \r\n for(int qq=1; qq<=T; qq++)\r\n {\r\n\t\tint n,m;\r\n\t\tcin>>n>>m;\r\n\t\tfor(int i=0;i>s;\r\n\t\t\tadd_string(s);\r\n\t\t}\r\n\t\tmemset(vis,-1,sizeof vis);\r\n\t\tdfs(0,0);\r\n\t\tPOWER(cnt,m,mod);\r\n\t\tcout< ostream& operator<<(ostream &os, const pair &p) { return os << '(' << p.first << \", \" << p.second << ')'; }\r\ntemplate::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = \" \"; return os; }\r\n#define debug(a) cerr << \"(\" << #a << \": \" << a << \")\\n\";\r\ntypedef long long ll;\r\ntypedef vector vi;\r\ntypedef vector vvi;\r\ntypedef pair pi;\r\nconst int mxN = 1e5+1, oo = 1e9;\r\nconst long long MD = 998244353;\r\ntemplate struct mdint {\r\n int d=0;\r\n mdint () {d=0;}\r\n mdint (long long _d) : d(_d%MOD){};\r\n friend mdint& operator+=(mdint& a, const mdint& o) {\r\n a.d+=o.d; if(a.d>=MOD) a.d-=MOD;\r\n return a;\r\n }\r\n friend mdint& operator-=(mdint& a, const mdint& o) {\r\n a.d-=o.d; if(a.d<0) a.d+=MOD;\r\n return a;\r\n }\r\n friend mdint& operator*=(mdint& a, const mdint& o) {\r\n return a = mdint((ll)a.d*o.d);\r\n }\r\n mdint operator*(const mdint& o) const {\r\n mdint res = *this;\r\n res*=o;\r\n return res;\r\n }\r\n mdint operator+(const mdint& o) const {\r\n mdint res = *this;\r\n res+=o;\r\n return res;\r\n }\r\n mdint operator-(const mdint& o) const {\r\n mdint res = *this;\r\n res-=o;\r\n return res;\r\n }\r\n mdint operator^(long long b) const {\r\n mdint tmp = 1;\r\n mdint power = *this;\r\n while(b) {\r\n if(b&1) {\r\n tmp = tmp*power;\r\n }\r\n power = power*power;\r\n b/=2;\r\n }\r\n return tmp;\r\n }\r\n friend mdint operator/=(mdint& a, const mdint& o) {\r\n a *= (o^(MOD-2));\r\n return a;\r\n }\r\n mdint operator/(const mdint& o) {\r\n mdint res = *this;\r\n res/=o;\r\n return res;\r\n }\r\n bool operator==(const mdint& o) { return d==o.d;}\r\n bool operator!=(const mdint& o) { return d!=o.d;}\r\n friend istream& operator>>(istream& c, mdint& a) {return c >> a.d;}\r\n friend ostream& operator<<(ostream& c, const mdint& a) {return c << a.d;}\r\n};\r\nusing mint = mdint;\r\n#define rep(i,n) for(int i=0;i> n >> m;\r\n\r\n vector ws(n);\r\n for(auto& i: ws) cin >> i;\r\n sort(all(ws),[&](string a, string b) {return a.size()\nusing namespace std;\nconst int N=12,M=12,K=12;\nint n,m,k,a[N][M]={},v[N][M][K]={},t[N][M]={};\nint totc=0,num[K]={};\nvoid init()\n{\n\tfor(int i=1;i<=n;++i)\n\t\tfor(int j=1;j<=m;++j)\n\t\t{\n\t\t\tcin>>a[i][j];\n\t\t\tif(a[i][j])\n\t\t\t{\n\t\t\t\tif(num[a[i][j]]==0)\n\t\t\t\t\tnum[a[i][j]]=++totc;\n\t\t\t\ta[i][j]=num[a[i][j]];\n\t\t\t}\n\t\t}\n\tfor(int i=1;i<=n;++i)\n\t\tfor(int j=1;j<=m;++j)\n\t\t\tif(a[i][j])\n\t\t\t{\n\t\t\t\tfor(int x=1;x<=i;++x)\n\t\t\t\t\tfor(int y=1;y<=j;++y)\n\t\t\t\t\t\t++v[x][y][a[i][j]];\n\t\t\t\tfor(int x=i;x<=n;++x)\n\t\t\t\t\tfor(int y=j;y<=m;++y)\n\t\t\t\t\t\t++v[x][y][a[i][j]];\n\t\t\t}\n\tfor(int i=1;i<=n;++i)\n\t\tfor(int j=1;j<=m;++j)\n\t\t\tfor(int c=1;c<=k;++c)\n\t\t\t\tt[i][j]+=!v[i][j][c];\n}\nbool add(int x,int y,int c,int d)\n{\n\tbool flag=true;\n\tfor(int i=x;i<=n;++i)\n\t\tfor(int j=y+(i==x);j<=m;++j)\n\t\t{\n\t\t\tt[i][j]+=bool(v[i][j][c]);\n\t\t\tv[i][j][c]+=d;\n\t\t\tt[i][j]-=bool(v[i][j][c]);\n\t\t\tif(t[i][j]==0)\n\t\t\t\tflag=false;\n\t\t}\n\treturn flag;\n}\nlong long tryy(int x,int y)\n{\n\tif(x>n)\n\t{/*\n\t\tfor(int i=1;i<=n;++i)\n\t\t{\n\t\t\tfor(int j=1;j<=m;++j)\n\t\t\t\tcout<2)\n\t\t\treturn 0;\n\t\treturn (y==m) ? tryy(x+1,1) : tryy(x,y+1);\n\t}\n\tlong long s=0;\n\tfor(int c=1;c<=totc;++c)\n\t\tif(!v[x][y][c])\n\t\t{\n\t\t\ta[x][y]=c;\n\t\t\tif(add(x,y,c,1))\n\t\t\t\ts+=(y==m) ? tryy(x+1,1) : tryy(x,y+1);\n\t\t\ta[x][y]=0;\n\t\t\tadd(x,y,c,-1);\n\t\t}\n\tif(totc!=k)\n\t{\n\t\t++totc;\n\t\ta[x][y]=totc;\n\t\tif(add(x,y,totc,1))\n\t\t\ts+=(k-totc+1)*((y==m) ? tryy(x+1,1) : tryy(x,y+1));\n\t\ta[x][y]=0;\n\t\tadd(x,y,totc,-1);\n\t\t--totc;\n\t}\n\treturn s%mod;\n}\nvoid work()\n{\n\tcout<>n>>m>>k;\n\tif(k\n#include \n#include \n#include \n#include \nusing namespace std;\nlong n,m,k;\nvector > ar;\nlong color[11][11];\nbool used[11];\nlong long go(long r, long c){\n if(c==m){\n c=0;\n r++;\n }\n if(r==n){\n return 1LL;\n }\n long long ret = 0LL;\n if(ar[r][c]!=0){\n if(color[ar[r][c]][r]0 && color[ar[r][c]][r-1]<=c)){\n return 0LL;\n }\n ret = go(r,c+1)%1000000007LL;\n return ret;\n }\n else{\n bool did =false;\n for(long i = 1; i<=k; i++){\n if(color[i][r]<=c){\n continue;\n }\n if(color[i][n-1]==20 && !used[i]){\n if(did){\n continue;\n }\n did = true;\n long long total = 1LL;\n for(long j = i+1; j<=k; j++){\n if(!used[j] && color[j][n-1]==20){\n total++;\n }\n }\n long og[n];\n for(long j = 0; j> n >> m >> k;\n \n if(n+m-1>k){\n cout << 0 << endl;\n return 0;\n }\n \n ar.resize(n);\n for(long a = 0; a<=10; a++){\n for(long b= 0; b<=10; b++){\n color[a][b] = 20;\n }\n }\n for(long i = 0; i> ar[i][j];\n if(ar[i][j]==0){\n continue;\n }\n for(long k = i; k\n#include \n#include \n#include \n#define mo 1000000007\n#define For(i,x,y) for (i=x;i<=y;i++)\nusing namespace std;\nint i,j,k,n,m,u,s,an\nint a[20][20],b[20][20],f[20],g[20],C[20][20],v[20];\nvoid dfs(int x,int y,int z) {\n\tif (y>m) y=1,x++;\n\tif (x>n) {\n\t\tan=(C[s][z-(k-s)])%mo; return;\n\t}\n\tint i;\n\tb[x][y]=b[x-1][y]|b[x][y-1];\n\tint A=0;\n\tif (a[x][y]) A=f[a[x][y]];\n\tif (A) {\n\t\tif (b[x][y]>>A-1&1) return;\n\t\tb[x][y]|=1<>i-1&1)) {\n\t\t\tint A=g[i];\n\t\t\tf[a[x][y]]=i;\n\t\t\tif (a[x][y]) g[i]=a[x][y];\n\t\t\tb[x][y]|=1<k) {\n\t\tprintf(\"0\\n\"); return 0;\n\t}\n\tFor(i,1,n)For(j,1,m) {\n\t\tscanf(\"%d\",&a[i][j]);\n\t\tif (!v[a[i][j]]) v[a[i][j]]=1,s++;\n\t}\n\ts--;\n\ts=k-s;\n\tFor(i,0,s) {\n\t\tC[i][0]=1;\n\t\tFor(j,1,i) C[i][j]=C[i-1][j]+C[i-1][j-1];\n\t}\n\tFor(i,1,s)For(j,1,i) C[s][i]*=j;\n\tdfs(1,1,0);\n\tprintf(\"%d\\n\",an);\n\t//for(;;);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f4d6711d75021f8eb8bb0a27ac544858", "src_uid": "5bb21f49d976cfa16a239593a95c53b5", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint n,m,k,a[15][15],vis[15][15],vis1[15][15],cnt[15];\nint dfs(int x,int y){\n\tif (y>m) y=1,x++;\n\tif (x>n){return 1;}\n\tint tmp=(vis[x][y-1]|vis[x-1][y]),s=-1,ans=0;\n\tif (a[x][y]){\n\t\tif ((tmp&(1<k){\n\t\tputs(\"0\");\n\t\treturn 0;\n\t}\n\tfor (int i=1;i<=n;i++)\n\t\tfor (int j=1;j<=m;j++){\n\t\t\tscanf(\"%d\",&a[i][j]);\n\t\t\tcnt[a[i][j]]++;\n\t\t\tfor (int k=1;k<=i;k++)\n\t\t\t\tfor (int l=1;l<=j;l++)\n\t\t\t\t\tif (k!=i||l!=j)\n\t\t\t\t\t\tvis1[k][l]|=1<\n\nusing namespace std;\n\nint main()\n{\n int arr[4] , y=0, x=3 , b = 0;\n for(int i=0;i<4;i++){\n cin >> arr[i]; \n } \n for(int i=0;i<4;i++) {\n if(arr[i] != arr[i+1]){\n y++;\n } else { \n continue;\n }\n if(y != x){ \n x++\n} else{\n continue;\n }\n \n } \n cout << x;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ada873d8eaf941b6c975c2eb7860e092", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "\n # include \n \n \n # include \n using namespace std;\n int main()\n {\n int a,b,c,d;\n cin>>a>>b>>c>>d;\n vector v;\n v.push_back(a);\n v.push_back(b);\n v.push_back(c);\n v.push_back(d);\n vector::iterator it;\n it = unique (v.begin(), v.end()); // 10 20 30 20 10 ? ? ? ?\n // ^\n\n v.resize( it - v.begin() ); \n cout<<4-v.size();\n \n return 0;\n }\n \n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "92b045aa6d136301604b0b04bcc263c6", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n \nint main()\n{ \n \n \n int a,b,c,d,o;\n vector g;\n \n \n g.push_back(a);\n g.push_back(b);\n g.push_back(c);\n g.push_back(d);\n \n set s;\n s = s(g.begin(),g.begin()+4);\n \n o = 4- s.size();\n \n cout<\n#include\n#include\n#include \n#include\n#include\n#include\nusing namespace std;\n\nint main() {\n\tint m[1000000000 ];\n\tunsigned long long int count=0;\n\n\tint n;\n\tfor (int i = 0; i < 4; i++) {\n\t\tcin >> m[i];\n\t}for (int i = 0; i < 3; i++) {\n\t\t\n\t\tif (m[i] == m[i + 1]) {\n\t\t\tcount++;\n\t\t}\n\t\n\t}\n\n\tcout << count;\n\t\t\n\t\n\t\n\n\n\n\n\n\n\n\t_getch();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "25ef27ad1e9144d6e48822617750d79d", "src_uid": "38c4864937e57b35d3cce272f655e20f", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\n#define N 111\nconst int INF = 1010;\n\nint n, m, a[N], k;\nchar s[N][N];\nbool vis[N], tag[2], flag[2];\n\nint func(int a, int b) {\n\tint c = 0;\n\tfor (int t = 1; t < INF; t *= k) {\n\t\tc += t * (((a / t) + (b / t)) % k);\n\t}\n\treturn c;\n}\n\nint main() {\n\tscanf(\"%d %d %d\\n\", &n, &m, &k);\n\tk ++;\n\tfor (int i = 1, b, c; i <= n; i ++) {a\n\t\tgets(s[i] + 1);\n\t\ttag[0] = tag[1] = 0;\n for (int j = 1; j <= m; j ++) {\n\t\t\tif (s[i][j] == 'G') tag[0] = 1, b = j;\n\t\t\tif (s[i][j] == 'R') tag[1] = 1, c = j;\n }\n a[i] = abs(b - c);\n if (tag[0] && tag[1]) vis[i] = 1;\n else if (tag[0]) flag[0] = 1;\n else if (tag[1]) flag[1] = 1;\n\t}\n\tif (flag[0] && flag[1]) {\n\t\tputs(\"Draw\");\n\t\treturn 0;\n\t}\n\tif (flag[0]) {\n\t\tputs(\"First\");\n\t\treturn 0;\n\t}\n\tif (flag[1]) {\n\t\tputs(\"Second\");\n\t\treturn 0;\n\t}\n\tint now = 0;\n\tfor (int i = 1; i <= n; i ++) if (vis[i]) now = func(now, a[i]);\n\tif (now) puts(\"First\");\n\telse puts(\"Second\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8d079be2bd3984ad6f8d8c08735ba7f4", "src_uid": "69062f7c9b834e925ab23ebc2da96b52", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nconst double pi = acos(-1.0);\n\n#define mp make_pair\n#define pb push_back\n#define fs first\n#define sc second\n#define sz(a) ((int) (a).size())\n#define all(a) (a).begin(), (a).end()\n#define int64 long long\n#define taskname \"d\"\n\nconst int max_r = 20;\nint sum[max_r], n, m, k;\nchar tmp[1000];\n\nint main() {\n\t//assert(freopen(taskname\".in\", \"r\", stdin));\n\t//assert(freopen(taskname\".out\", \"w\", stdout));\n\tscanf(\"%d%d%d\", &n, &m, &k);\n\tif (m == 1) {\n\t\tprintf(\"Second\\n\");\n\t\treturn 0;\n\t}\n\tbool rdraw = false, gdraw = false, r = false, g = false;\n\tfor (int i = 0; i < n; ++i) {\n\t\tscanf(\"%s\", tmp);\n\t\tint gpos = -1, rpos = -1;\n\t\tfor (int j = 0; j < m; ++j) {\n\t\t\tif (tmp[j] == 'G') gpos = j;\n\t\t\tif (tmp[j] == 'R') rpos = j;\n\t\t}\n\t\tif ((gpos == -1) && (rpos != -1)) rdraw = true;\n\t\tif ((rpos == -1) && (gpos != -1)) gdraw = true;\n\t\tif (gpos != -1) g = true;\n\t\tif (rpos != -1) r = true;\n\t\tif ((gpos != -1) && (rpos != -1)) {\n\t\t\tint diff = abs(rpos - gpos), r = 0;\n\t\t\t//printf(\"%d\\n\", diff);\n\t\t\twhile (diff > 0) {\n\t\t\t\tsum[r] += (diff & 1);\n\t\t\t\tdiff >>= 1;\n\t\t\t\t++r;\n\t\t\t}\n\t\t}\n\t}\n\tassert(f);\n\tassert(g);\n\tbool zero = true;\n\tfor (int i = 0; i < max_r; ++i)\n\t\tif (sum[i] % (k + 1) != 0) {\n\t\t\tzero = false;\n\t\t\tbreak;\n\t\t}\n\tif (zero)\n\t\tif (gdraw)\n\t\t\tif (rdraw)\n\t\t\t\tprintf(\"Draw\\n\");\n\t\t\telse\n\t\t\t\tprintf(\"First\\n\");\n\t\telse\n\t\t\tprintf(\"Second\\n\");\n\telse\n\t\tif (rdraw)\n\t\t\tif (gdraw)\n\t\t\t\tprintf(\"Draw\\n\");\n\t\t\telse\n\t\t\t\tprintf(\"Second\\n\"); \n\t\telse\n\t\t\tprintf(\"First\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bf230f8e7bb81d9769825fd9aaaf175b", "src_uid": "69062f7c9b834e925ab23ebc2da96b52", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#pragma comment(linker, \"/STACK:64000000\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define forn(i, n) for (int i = 0; i < int(n); i ++)\n#define ford(i, n) for (int i = int(n) - 1; i >= 0; i --)\n#define mp make_pair\n#define pb push_back\n#define fs first\n#define sc second\n#define pi 3.1415926535897932\n#define ll long long\n#define ld long double\n\nusing namespace std;\n\nbool q[2]; \nint a[110];\nint kol1[2], kol2[2];\n\nint main(){\n#ifndef ONLINE_JUDGE\n freopen (\"input.txt\",\"rt\",stdin);\n freopen (\"output.txt\",\"wt\",stdout);\n#endif\n int n, m, k;\n scanf(\"%d %d %d\\n\", &n, &m, &k);\n int kol = 0;\n forn(i, n){\n int kol = 0, k, pr;\n char c1; \n kol2[0] = kol2[1] = 0;\n forn(j, m){\n char c;\n scanf(\"%c\", &c); \n if (c != '-'){\n if (kol == 0) pr = j;\n else k = j - pr - 1;\n if (c == 'G') kol2[0] ++;\n else kol2[1] ++;\n c1 = c;\n kol ++;\n }\n } \n forn(j, 2)\n kol1[j] += kol2[j];\n if (kol != 0){\n if (kol2[0] + kol2[1] == kol2[0]){ \n if (kol2[0] < m) q[0] = true;\n } else \n if (kol2[0] + kol2[1] == kol2[1]){ \n if (kol2[1] < m) q[1] = true;\n } else a[i] = k; \n } \n scanf(\"\\n\");\n }\n if (q[0] && q[1]){\n printf (\"Draw\");\n return 0;\n } else if (q[0] && !q[1]){\n printf (\"First\");\n return 0;\n } else if (q[1]){\n printf (\"Second\");\n return 0;\n }\n if (kol1[0] == 0){\n printf (\"Second\");\n return 0;\n }\n else if (kol1[1] == 0){\n printf (\"First\");\n return 0;\n }\n int ans = 0;\n forn(i, 10){\n int kol = 0; \n forn(j, n){\n if ((a[j] & 1) & (1 << i)) kol ++;\n } \n ans += (kol % (k + 1));\n }\n if (ans == 0) printf (\"Second\");\n else printf (\"First\");\n\n return 0;\n}#pragma comment(linker, \"/STACK:64000000\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define forn(i, n) for (int i = 0; i < int(n); i ++)\n#define ford(i, n) for (int i = int(n) - 1; i >= 0; i --)\n#define mp make_pair\n#define pb push_back\n#define fs first\n#define sc second\n#define pi 3.1415926535897932\n#define ll long long\n#define ld long double\n\nusing namespace std;\n\nbool q[2]; \nint a[110];\nint kol1[2], kol2[2];\n\nint main(){\n#ifndef ONLINE_JUDGE\n freopen (\"input.txt\",\"rt\",stdin);\n freopen (\"output.txt\",\"wt\",stdout);\n#endif\n int n, m, k;\n scanf(\"%d %d %d\\n\", &n, &m, &k);\n int kol = 0;\n forn(i, n){\n int kol = 0, k, pr;\n char c1; \n kol2[0] = kol2[1] = 0;\n forn(j, m){\n char c;\n scanf(\"%c\", &c); \n if (c != '-'){\n if (kol == 0) pr = j;\n else k = j - pr - 1;\n if (c == 'G') kol2[0] ++;\n else kol2[1] ++;\n c1 = c;\n kol ++;\n }\n } \n forn(j, 2)\n kol1[j] += kol2[j];\n if (kol != 0){\n if (kol2[0] + kol2[1] == kol2[0]){ \n if (kol2[0] < m) q[0] = true;\n } else \n if (kol2[0] + kol2[1] == kol2[1]){ \n if (kol2[1] < m) q[1] = true;\n } else a[i] = k; \n } \n scanf(\"\\n\");\n }\n if (q[0] && q[1]){\n printf (\"Draw\");\n return 0;\n } else if (q[0] && !q[1]){\n printf (\"First\");\n return 0;\n } else if (q[1]){\n printf (\"Second\");\n return 0;\n }\n if (kol1[0] == 0){\n printf (\"Second\");\n return 0;\n }\n else if (kol1[1] == 0){\n printf (\"First\");\n return 0;\n }\n int ans = 0;\n forn(i, 10){\n int kol = 0; \n forn(j, n){\n if ((a[j] & 1) & (1 << i)) kol ++;\n } \n ans += (kol % (k + 1));\n }\n if (ans == 0) printf (\"Second\");\n else printf (\"First\");\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "270ac68d604ee4689edc6f2ec2782b57", "src_uid": "69062f7c9b834e925ab23ebc2da96b52", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\nchar s[105][105];\nint a[105],z;\nbool check(int k)\n{\n\tint b[50],i,j;\n\tmemset(b,0,sizeof(b));\n\tfor (i=0;i0;j++)\n\t\t{\n\t\t\tb[j]+=a[i]%2;\n\t\t\ta[i]/=2;\n\t\t}\n\t}\n\tfor (i=0;i<50;i++)\n\t{\n\t\t//cout<>n>>m>>k;\n\tfor (i=0;i>s[i];\n\tt=0;\n\tz=0;\n\tfor (i=0;i\nusimg namespace std;\nint main()\n{\nint a;\ncin>>a;\nbool k=a;\ncout<\n/*\nBy:ahmed\n*/\nusing namespace std;\nint main()\n#define int long long\n{\nint v;\ncin>>v;\nif(v==2)\n cout<<2\nusing namespace std;\n\nint main() {\n\n int n,v;\n cin >> n ;\n n = v;\n \n for(int x = 1 ; x < n ; x++)\n {if(n % x =! 0)\n {\n n = n - x;\n if (n = 1)\n break;\n }\n \n }\n cout << n ;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ac96e5463cca38faeccfc1fe0b0c5f41", "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include\nusing namespace std;\nint main()\n{\n\tint n;\n\tcin>>n;\n\tif(n==2)\n\tcout<<2'\n\telse\n\tcout<<1;\nreturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "26045e45db464b012a30cc52f76d2e12", "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#define PI 3.14159265358979\n#define forn(i, n) for(int i = 0; i < n; ++i)\n#define ALL(x) x.begin(), x.end()\nusing namespace std ;\nlong long int typedef ll ;\nint binpow (int a, int n) // \u0447\u0438\u0441\u043b\u043e \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c\n{\n int res = 1;\n while (n) {\n if (n & 1)\n res *= a;\n a *= a;\n n >>= 1;\n }\n return res;\n}\nint main()\n{ \n /*ifstream cin ;\n ofstream cout ;\n cin.open (\"input.txt\");\n cout.open (\"output.txt\");*/\n string s1;\n string s2;\n string s3;\n int mas1[10][11] = {} ;\n int mas2[10][11] = {};\n int i = 0;\n int j = 0;\n cin >> s1;\n for(int y = 1; y<=9; y++)\n {\n for(i = 0; i < s1.length(); i++)\n {\n mas1[y][s1[i]- '0']++;\n mas2[y][s1[i]- '0']++;\n }\n mas1[y][10] = 0;\n mas2[y][10] = 0;\n }\n int d = 0;\n int maxi = 0;\n int count=0;\n int ym = 0;\n string ans1, ans2;\n for(int y = 9; y>0; y--)\n {\n for(i = y; i>=0; i--)\n {\n if(mas1[y][i] > 0)\n {\n if (mas2[y][10-i-d] > 0)\n { \n char a = i +'0';\n char b = 10-i-d + '0';\n mas1[y][i]--;\n mas2[y][10-i-d]--;\n ans1+=a;\n ans2+=b;\n d=1;\n i=10;\n count++;\n }\n }\n }\n d = 0;\n if(count > maxi)\n {\n maxi = count;\n s2.clear();\n s2+=ans1;\n s3.clear();\n s3+=ans2;\n ym = y;\n }\n count = 0;\n ans1.clear();\n ans2.clear();\n }\n i = 0;\n for(i=1; i< 10; i++)\n { \n char a = i +'0';\n while(mas1[ym][i] > 0)\n {\n s2+=a;\n mas1[ym][i]--;\n }\n while(mas2[ym][i] > 0)\n {\n s3+=a;\n mas2[ym][i]--;\n }\n }\n reverse(ALL(s2));\n reverse(ALL(s3));\n while(mas1[ym][0] > 0)\n {\n s2+= '0';\n mas1[ym][0]--;\n }\n while(mas2[ym][0] > 0)\n {\n s3+= '0';\n mas2[ym][0]--;\n }\n cout << s2 << endl;\n cout << s3;\n\n/ system(\"pause\");\n //cin.close();\n //cout.close();\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e49965714d937779daee97403833d6d5", "src_uid": "34b67958a37865e1ca0529bbf528dd9a", "difficulty": 1900.0} {"lang": "GNU C++11", "source_code": "#include\n#define ll long long int\n#define pb push_back\n#define mp make_pair\n#define pii pair\n#define vi vector\n#define Max(a,b) ((a)>(b)?(a):(b))\n#define Min(a,b) ((a)<(b)?(a):(b))\n#define rep(i,a,b) for (int i=(a);i<(b);i+=1)\n#define all(a) (a).begin(),(a).end()\n#define F first\n#define S second\n#define sz(x) (int)x.size()\n#define hell 1000000007\n#define endl '\\n'\n#define debug(a) cerr<<#a<<\": \";for(auto i:a)cerr<>s;\n mapm;\n mapn;\n for(auto i:s){\n m[i-'0']++;\n n[i-'0']++;\n }\n string curans1;\n string curans2;\n int zeroes=m[0];\n m[0]=0;\n n[0]=0;\n int curzero=0;\n rep(i,1,10){\n int cur=0;\n vi used;\n if(m[i]&&m[10-i]){\n cur++;\n used.pb(i);\n used.pb(10-i);\n m[i]--;\n n[10-i]--;\n }\n else{\n continue;\n }\n rep(i,0,5){\n cur+=min(m[i],n[9-i]);\n }\n if(cur>curzero){\n curans1=\"\";\n curans2=\"\";\n curzero=cur;\n curans1.pb(used[0]+'0');\n curans2.pb(used[1]+'0');\n rep(i,0,5){\n rep(j,0,min(m[i],n[9-i])){\n curans1.pb(i+'0');\n curans2.pb(9-i+'0');\n }\n }\n rep(i,0,5){\n rep(j,0,m[9-i]){\n curans1.pb(9-i+'0');\n }\n rep(j,0,n[i]){\n curans2.pb(i+'0');\n }\n rep(j,0,n[9-i]-m[i]){\n curans2.pb(9-i+'0');\n }\n rep(j,0,m[i]-n[9-i]){\n curans1.pb(i+'0');\n }\n }\n }\n m[used[0]]++;\n n[used[1]]++;\n }\n reverse(all(curans1));\n reverse(all(curans2));\n rep(i,0,zeroes){\n curans1.pb('0');\n curans25.pb('0');\n }\n cout<>t;\n\twhile(t--){\n\t\tsolve();\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9d093140bffe29242c4188e036444c33", "src_uid": "34b67958a37865e1ca0529bbf528dd9a", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint main()\n{\nstring s,t,r;\nint a[15]={0},b[15]={0},i;\ncin>>s;\nfor(i=0;i0 && b[0]>0)\n{\nt+='0';\nr+='0';\na[0]--;\nb[0]--;\n}\nfor(i=0;i<10;i++)\n{\nif(t.length()==0 && a[i]>0 && b[10-i]>0)\n{\nt+=(i+'0');\nr+=(10-i+'0');\na[i]--;\nb[10-i]--;\nbreak;\n}\n}\nfor(i=0;i<10;i++)\n{\nwhile(a[i]>0 && b[9-i]>0)\n{\nt+=(i+'0');\nr+=(9-i+'0');\na[i]--;\nb[9-i]--;\n}\n}\nfor(i=0;i<10;i++)\n{\nwhile(a[i]>0)\n{\nt+=(i+'0');\na[i]--;\n}\nwhile(b[i]>0)\n{\nr+=(i+'0');\nb[i]--;\n}\n}\nreverse(t.begin(),t.end());\nreverse(r.begin(),r.end());\ncout<\n#include\n#include\n#include \n#include \n#include \nusing namespace std;\n\n#define FOR(i,n) for(int i=0;i mx,mapmy)\n{\n int count=0;\n for(int i=1;i<=9;i++) if (mx[i]>0 && my[10-i]>0) {count++;} \n return count;\n}\n\nint main()\n{\n\n //keep all 0 for 9s and also for later\n //find 10\n //find 9 until no more\n //output remainint numbers\n\n string s;\n cin>>s;\n map mx,my;\n \n FOR(i,(int)s.length()) mx[s[i]-'0']++,my[s[i]-'0']++;\n string x,y;\n\n //find 9 until no more\n for(int i=0;i<=9;i++) if (tensRemaining(mx,my)!=1) while (mx[i]>0 && my[9-i]>0) {mx[i]--,my[9-i]--,x.append(toStr(i)),y.append(toStr(9-i));} \n\n //find 10 once \n for(int i=1;i<=9;i++) if (mx[i]>0 && my[10-i]>0) {mx[i]--,my[10-i]--,x+=toStr(i),y+=toStr(10-i);break;} \n\n //find 9 until no more and prepend this time\n for(int i=0;i<=9;i++) while (mx[i]>0 && my[9-i]>0) {mx[i]--,my[9-i]--,x=toStr(i)+x,y=toStr(9-i)+y;} \n\n //append 0\n while (mx[0]>0 && my[0]>0) mx[0]--,my[0]--,x+=\"0\",y+=\"0\";\n\n \n //prepend remaining numbers\n for(int i=0;i<=9;i++) while (mx[i]>0) mx[i]--,x=toStr(i)+x;\n for(int i=0;i<=9;i++) while (my[i]>0) my[i]--,y=toStr(i)+y;\n\n cout<\nusing namespace std;\n\nint main()\n{\n int x,y;\n cin>>x>>y;\n int count=0;\n\n while(x||y)\n {\n if(x>=2)\n {\n x-=2;\n if(y>=2)\n {\n y-=2;\n count++;\n }\n }\n else if(x==1)\n {\n x-=1;\n if(y>=12)\n {\n y-=12;\n count++;\n }\n }\n else if(x==0)\n {\n if(y>=22)\n {\n y-=22;\n count++;\n }\n }\n\n if(y>=22)\n {\n y-=22;\n count++;\n }\n else if(y>=12&&y<22)\n {\n y-=12;0\n if(x>=1)\n {\n x-=1;\n count++;\n }\n }\n else if(y>=2&&y<12)\n {\n y-=2;\n if(x>=2)\n {\n x-=2;\n count++;\n }\n }\n }\n\n if(count%2!=0&&count!=0)\n cout<<\"Ciel\"<\n# include \n# include \n# include \n# include \n# include \nusing namespace std;\n//printf (\"%.6lf\\n\", a);\n// erase\n\n# define all(a) a.begin(), a.end()\n# define Sort(a) sort(all(a));\n# define pause system(\"pause\");\n# define ll long long\n\nstruct toch\n{\n int x;\n int y;\n};\n\ntoch hanako(toch t)\n{\n if(t.y>=22)\n {\n t.y=t.y-22;\n return t;\n }\n if(t.x>0&&t.y>=11)\n {\n t.x--;\n t.y=t.y-12;\n return t;\n }\n if(t.x>1&&t.y>1)\n {\n t.x-=2;\n t.y-=2;\n return t;\n }\n\n t.x=-1;\n //t.y=-1;\n return t;\n}\n\ntoch ciel(toch t)\n{\n if(t.x>1&&t.y>1)\n {\n t.x-=2;\n t.y-=2;\n return t;\n }\n if(t.x>0&&t.y>=11)\n {\n t.x--;\n t.y=t.y-12;\n return t;\n }\n if(t.y>=22)\n {\n t.y=t.y-22;\n return t;\n }\n \n \n\n t.x=-1;\n //t.y=-1;\n return t;\n}\n\nstring prob(toch t)\n{\n for(int i=0; i>t.x>>t.y;\n\n cout< b) ? b : a) \n#define mod 1e9 + 7 \n \n#define FOR(a, c) for (ll (a) = 0; (a) < (c); (a)++) \n#define FORL(a, b, c) for (ll (a) = (b); (a) <= (c); (a)++) \n#define FORR(a, b, c) for (ll (a) = (b); (a) >= (c); (a)--) \n#define INF 1000000000000000003 \ntypedef long long int ll; \ntypedef vector vi; \ntypedef pair pi; \n#define F first \n#define S second \n#define PB push_back \n#define POB pop_back \n#define MP make_pair \nvoid solve(); \nint main() \n{ \n ios_base::sync_with_stdio(false); \n cin.tie(NULL); \n \n#ifndef ONLINE_JUDGE \n freopen(\"input.txt\", \"r\", stdin); \n freopen(\"error.txt\", \"w\", stderr); \n freopen(\"output.txt\", \"w\", stdout); \n#endif \n \n ll t = 1; \n /*is Single Test case?*/ cin >> t; \n while (t--) { \n solve(); \n cout << \"\\n\"; \n } \n \n cerr << \"time taken : \" << (float)clock() / CLOCKS_PER_SEC << \" secs\" << endl; \n return 0; \n} \n \n \nint modd(int a)\n{if(a<0)\n\treturn -a;\n\telse return a;\n \n}\n \nvoid solve() \n{ \n ll x,y,count=0;\n cin>>x>>y;\n while (count=2 && y>=2)\n {\n x-=2;\n y-=2;\n \n }\n else if(x>=1 && y>=12)\n {\n x-=1;\n y-=12;\n }\n else if(x==0 && y>=22)\n {\n y-=22;\n \n }\n else{\n cout<<\"Hanako\";\n break;\n \n }\n \n \n }\n else if(count%2==1)\n {\n if(x>=0 && y>=22)\n {\n y-=22;\n \n }\n else if(x>=1 && y>=12)\n {\n x-=1;\n y-=12\n }\n else if(x>=2 && y>=2)\n {\n x-=2;\n y-=2;\n }\n else\n {\n cout<<\"Ceil\";\n break;\n }\n \n }\n count++;\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9855ad4c8c01bd4d660209ef54dae35d", "src_uid": "8ffee18bbc4bb281027f91193002b7f5", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\nint main()\n{\n int x, y;\n cin >> x >> y;\n int maximum = min(x/2, y/24);\n x -= maximum * 2;\n y -= maximum * 24;\n \n while(1)\n {\n if(x >= 2 && y >= 2)\n {\n x -= 2; y -= 2;\n }\n else if (x == 1 && y >= 12)\n {\n x--; y -= 12;\n }\n else if (y >= 22)\n {\n y -= 22;\n }\n else\n {\n cout << \"Hanako\";\n break;\n }\n \n if(y > 21)\n {\n y -= 22;\n }\n else if (x == 1 && y > 11)\n {\n x--; y -= 12;\n }\n else if (x >= 2 && y > 1)\n {\n x -= 2; y -= 2;\n }\n else\n {\n cout << \"Ciel\";\n break;\n }\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6f0a70cb6727191d05c1c5d45c39b429", "src_uid": "8ffee18bbc4bb281027f91193002b7f5", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\n\n\n#define fr(i,a,b) for(ll i= (a) ; i< (b) ; i++)\n#define pb push_back\n#define mp make_pair\n#define pii pair< int, int >\n#define pll pair< long long, long long >\n#define all(a) a.begin(), a.end()\n \n\nint main()\n{\n\n\t#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\",\"r\",stdin);\n\tfreopen(\"output.txt\",\"w\",stdout);\n\t#endif\n\n\ttime_t t1, t2;\n\tt1 = clock();\n\n\tll n,k; cin>>n>>k;\n\n\tif(n==1 && k==1) { cout<<\"Yes\"; return 0;}\n\n\n\tif(k>=n){cout<<\"No\"; return 0;}\n\n\tint used[1e7+5];\n\n\tfr(i,0,1e7+5) used[i]=0;\n\n\t\n\tfor(ll i=1; i<=k; i++)\n\t{\n\t\tif(used[n%i]==1)\n\t\t{\n\t\t\tcout<<\"No\"; return 0;\n\t\t}\n\t\tused[n%i]=1;\n\t}\n\n\tcout<<\"Yes\";\n\t\n\n\tt2 = clock();\n\tcerr << \"time taken: \" << t2-t1;\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4ef952b9a6cd1fbef55a7cfda1ceb822", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include\n#define lli long long int\nusing namespace std;\nint main()\n{\n\tios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\nlli i,j,k,n,m;\ncin>>n>>k;\nif(n==1 && k==1)\n{\n\tcout<<\"Yes\";\n\treturn 0;\n}\nif(n==k)\n{\n\tcout<<\"No\";\n\treturn 0;\n}\nlli x=0;\nint flag=1;\nint a[10];\nstd::fill(a,a+10,0);\nfor(i=1;i<=k/2;i++)\n{\np=n%i;\nif(p>=0 && p<=9)\n{\n\ta[p]++;\n}\nfor(i=0;i<=9;i++)\n{\n\tif(a[i]>1)\n\t{\n\tcout<<\"No\";\n\treturn 0;\n\t}\n\t}\t\n}\ncout<<\"Yes\";\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1c70940c59e78fb030b118e0976e26e4", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\nusing namespace std;\nint main()\n{\n int long long n,k;\n cin>>n>>k;\n if(k>=n)\n {\n cout<<\"No\";\n }\n else\n {\n cout<<\"Yes\";\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3318418a0e9858027429d2b0bdf48181", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2", "difficulty": 1600.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\n\nset a;\nint main()\n{\n\tlong long n,k;\n\tcin>>n>>k;\n\tk=min(k,1000000)\n\tfor(long long i=1;i<=k;++i)\n\t{\n\t\tif(a.find(n%i)!=a.end())\n\t\t{\n\t\t\tcout<<\"No\"<\n#include \nint main()\n{\n\tchar s[25];\n\tint a, len;\n\tcin >> s;\n\tlen = strlen(s);\n\ta = len * 26 - (len - 1) * 2;\n\tcout << a;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d92da7ebfc05ace70e7a256307e252db", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n int n;\n string s;\n long long c= 1;\n\n cin>>s;\n c=51;\n int l= s.size()-2;\n c+= 25*l;\n cout<< c <\n#include\nint main()\n{\n\n string s;\n int a;\n cin >>s;\n a=(s.length()+1)*25+1;\n cout << a <\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\n\n\n int main(){\n \n string a;'\n cin>>a;\n int len=a.length();\n cout<<26*(len+a)-len;\n \n\n\n return 0;\n }", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5e8f7d9cca07a2a9c878035944f15af1", "src_uid": "556684d96d78264ad07c0cdd3b784bc9", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nint main() {\n\tint i=0;\n\tchar a[90],zero[10],one[10],two[10],three[10],four[10],five[10],six[10],seven[10],eight[10],nine[10],arr[8];\n\tcin>>a>>zero>>one>>two>>three>>four>>five>>six>>seven>>eight>>nine;\n\tfor(int c=0;c<80;c+=10,i++){\n\t\tif(a[c]==zero[0]&&a[c+1]==zero[1]&&a[c+2]==zero[2]&&a[c+3]==zero[3]&&a[c+4]==zero[4]&&a[c+5]==zero[5]&&a[c+6]==zero[6]&&a[c+7]==zero[7]&&a[c+8]==zero[8]&&a[c+9]==zero[9]){\n\t\t\tarr[i]='0';\n\t\t}\n\t\telse if(a[c]==one[0]&&a[c+1]==one[1]&&a[c+2]==one[2]&&a[c+3]==one[3]&&a[c+4]==one[4]&&a[c+5]==one[5]&&a[c+6]==one[6]&&a[c+7]==one[7]&&a[c+8]==one[8]&&a[c+9]==one[9]){\n\t\t\tarr[i]='1';\n\t\t}\n\t\telse if(a[c]==two[0]&&a[c+1]==two[1]&&a[c+2]==two[2]&&a[c+3]==two[3]&&a[c+4]==two[4]&&a[c+5]==two[5]&&a[c+6]==two[6]&&a[c+7]==two[7]&&a[c+8]==two[8]&&a[c+9]==two[9]){\n\t\t\tarr[i]='2';\n\t\t}\n\t\telse if(a[c]==three[0]&&a[c+1]==three[1]&&a[c+2]==three[2]&&a[c+3]==three[3]&&a[c+4]==three[4]&&a[c+5]==three[5]&&a[c+6]==three[6]&&a[c+7]==three[7]&&a[c+8]==three[8]&&a[c+9]==three[9]){\n\t\t\tarr[i]='3';\n\t\t}\n\t\telse if(a[c]==four[0]&&a[c+1]==four[1]&&a[c+2]==four[2]&&a[c+3]==four[3]&&a[c+4]==four[4]&&a[c+5]==four[5]&&a[c+6]==four[6]&&a[c+7]==four[7]&&a[c+8]==four[8]&&a[c+9]==four[9]){\n\t\t\tarr[i]='4';\n\t\t}\n\t\telse if(a[c]==five[0]&&a[c+1]==five[1]&&a[c+2]==five[2]&&a[c+3]==five[3]&&a[c+4]==five[4]&&a[c+5]==five[5]&&a[c+6]==five[6]&&a[c+7]==five[7]&&a[c+8]==five[8]&&a[c+9]==five[9]){\n\t\t\tarr[i]='5';\n\t\t}\n\t\telse if(a[c]==six[0]&&a[c+1]==six[1]&&a[c+2]==six[2]&&a[c+3]==six[3]&&a[c+4]==six[4]&&a[c+5]==six[5]&&a[c+6]==six[6]&&a[c+7]==six[7]&&a[c+8]==six[8]&&a[c+9]==six[9]){\n\t\t\tarr[i]='6';\n\t\t}\n\t\telse if(a[c]==seven[0]&&a[c+1]==seven[1]&&a[c+2]==seven[2]&&a[c+3]==seven[3]&&a[c+4]==seven[4]&&a[c+5]==seven[5]&&a[c+6]==seven[6]&&a[c+7]==seven[7]&&a[c+8]==seven[8]&&a[c+9]==seven[9]){\n\t\t\tarr[i]='7';\n\t\t}\n\t\telse if(a[c]==eight[0]&&a[c+1]==eight[1]&&a[c+2]==eight[2]&&a[c+3]==eight[3]&&a[c+4]==eight[4]&&a[c+5]==eight[5]&&a[c+6]==eight[6]&&a[c+7]==eight[7]&&a[c+8]==eight[8]&&a[c+9]==eight[9]){\n\t\t\tarr[i]='8';\n\t\t}\n\t\telse if(a[c]==nine[0]&&a[c+1]==nine[1]&&a[c+2]==nine[2]&&a[c+3]==nine[3]&&a[c+4]==nine[4]&&a[c+5]==nine[5]&&a[c+6]==nine[6]&&a[c+7]==nine[7]&&a[c+8]==nine[8]&&a[c+9]==nine[9]){\n\t\t\tarr[i]='9';\n\t\t}\n\t}\n\tcout<\n#include \nusing namespace std;\nint n,i,j,x;\nstring a,b,c,d[10];\nint main(){\n cin>>a;\n for (i=0; i>d[a];\n for (i=0; i\n#include\n#include\n#include\nusing namespace std;\n\nint main()\n{\n\nint index=0;\n\nstring binary_code,cp[8],codes[10];\n\ncin>>binary_code;\nvectorc;\n\nfor(int i=0;i<=80;i+=10)\n {\n\n\n cp[index]=binary_code.substr(i,10);\n\n cout<>codes[i];\n\n\n }\n for (int i=0;i<10;i++)\n {\n for(int j=0;j<10;j++)\n {\n if(cp[i]==codes[j]){c.push_back(j);}\n }\n }\nfor(int i=0;i<8;i++)\n{\n cout<\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n\nvoid sch (FILE *f1, char *a, int b);\n\n\nint main (int argc, char **argv) {\n int i,j,k,m;\n char a[81];\n char d[11];\n sch(stdin,a,81);\n char b[10][11];\n for(i=0;i<10;i++)\n sch(stdin,b[i],11);\n \n \n \n strcpy(d,a);\n \n for(i=0;i<10;i++)\n if (strstr(d,b[i])==NULL) {}\n else cout<\nusing namespace std;\n\nint main()\n{\n int n,t;\n cin>>n>>t;\n // up 1\n // down 0\n // n t h d\n int mem[30][20][8][5];\n memset(mem,0,sizeof(mem));\n \n \n mem[2][0][2][1]=1;\n mem[2][0][3][1]=2;\n mem[2][0][4][1]=3;\n \n for (int i=3; i<=n; i++)\n {\n for (int t=0; t<=14; t++)\n {\n mem[i][t][1][0]+=mem[i-1][t-1][2][1]+mem[i-1][t-1][3][1]+mem[i-1][t-1][4][1]+mem[i-1][t][2][0]+mem[i-1][t][3][0];\n mem[i][t][2][0]+=mem[i-1][t-1][3][1]+mem[i-1][t-1][4][1]+mem[i-1][t][3][0];\n mem[i][t][2][1]+=mem[i-1][t][1][0];\n mem[i][t][3][0]+=mem[i-1][t-1][4][1];\n mem[i][t][3][1]+=mem[i-1][t][1][0]+mem[i-1][t][2][1]+mem[i-1][t][2][0];\n mem[i][t][4][1]+=mem[i-1][t][2][1]+mem[i-1][t][2][0]+mem[i-1][t][3][0]+mem[i-1][t][3][1]+mem[i-1][t][1][0];\n }\n }\n cout<\n#include \nusing namespace std;\nlong long memo[21][21][21][5][3];\nint N ,T , R1,R2;\nint getR(int n1,int n2)\n{\n return (n1>n2)+1;\n}\n\nlong long DP(int idx , int r1 ,int r2, int lst , int rel)\n{\n if(idx>=N)\n {\n if(r1==R1 && r2==R2)\n return 1;\n return 0;\n }\n long long &ref = memo[idx][r1][r2][lst][rel];\n if(ref!=-1)\n return ref;\n ref=0;\n for(int i=1;i<=4;++i)\n {\n if(i==lst)\n continue;\n int nrel = getR(i,lst);\n if (nrel==rel) {\n ref+=DP(idx+1,r1,r2,i,nrel);\n }\n else\n {\n if(rel==1)\n ref+=DP(idx+1,r1,r2+1,i,nrel);\n else\n ref+=DP(idx+1,r1+1,r2,i,nrel);\n\n }\n \n }\n return ref;\n}\nint main(int argc, const char * argv[])\n{\n\n scanf(\"%d%d\",&N,&T);\n R1 = T;\n R2 = T-1;\n memset(memo, -1, sizeof(memo));\n long long cnt=0;\n for(int i=1;i<=4;++i)\n {\n for(int j=1;j<=4;++j)\n cnt+=DP(2,0,0,j,getR(j, i));\n }\n cout<\n#pragma GCC optimize(4)\n#define For(k,i,j) for(int k=i;k<=j;k++)\nusing namespace std;\nconst int maxn 20\nconst int maxt 10\nconst int maxk 4\nconst int maxr 2\nint f[maxn+2][maxk+2][maxt+2][maxr+2];\nint main(){\n int n,t,ans;\n cin>>n>>t;\n f[2][2][1][1]=1;\n f[2][3][1][1]=2;\n f[2][4][1][1]=3;\n For(i,3,n){\n For(j,1,4){\n For(k,1,t){\n for(int r=4;r>j;r--){\n f[i][j][k][0]+=f[i-1][r][k][0]+f[i-1][r][k][1];\n }\n For(r,1,j-1){\n f[i][j][k][1]+=f[i-1][r][k][1]+f[i-1][r][k-1][0];\n }\n }\n }\n }\n for(i,1,maxk){\n ans+=f[n][i][t][0];\n }\n cout<\nusing namespace std;\nlong long f(int n,int t, int i)// so bve rong co n diem; t mong va y_n=i(3<=n<=20; 1<=t<=10; 1<=i<=3)\n{\n\tif(n+i>6*t+2)\treturn 0;\n\tif(n+i==6*t+2)\treturn 1;\n\tif(n<=2*t)\t\treturn 0;\n\tif(t==1)\n\t{\n\t\tif(i==1 && n==3)\treturn 6;\n\t\tif(i==2 && n==3)\treturn 5;\n\t\tif(i==3 && n==3)\treturn 3;\n\t\tif(i==1 && n==4)\treturn 12;\n\t\tif(i==2 && n==4)\treturn 7;\n\t\tif(i==3 && n==4)\treturn 3;\n\t\tif(i==1 && n==5)\treturn 11;\n\t\tif(i==2 && n==5)\treturn 4;\n\t\tif(i==3 && n==5)\treturn 1;\n\t\tif(i==1 && n==6)\treturn 5;\n\t\tif(i==2 && n==6)\treturn 1;\n\t\tif(i==3 && n==6)\treturn 0;\n\t}\n\tif(i==1)\treturn \tf(n-1,t,2)+f(n-2,t-1,1)\n\t\t\t\t\t\t+f(n-1,t,3)+f(n-2,t-1,2)+f(n-2,t-1,1)+f(n-3,t-1,1)\n\t\t\t\t\t\t+f(n-2,t-1,3)+f(n-2,t-1,2)+f(n-2,t-1,1)\n\t\t\t\t\t\t+f(n-3,t-1,2)+f(n-3,t-1,1)+f(n-3,t-1,1)\n\t\t\t\t\t\t+f(n-4,t-1,1);\n\tif(i==2)\treturn \tf(n-1,t,3)+f(n-2,t-1,2)+f(n-2,t-1,1)+f(n-3,t-1,1)\n\t\t\t\t\t\t+f(n-2,t-1,3)+f(n-2,t-1,2)+f(n-2,t-1,1)\n\t\t\t\t\t\t+f(n-3,t-1,2)+f(n-3,t-1,1)+f(n-3,t-1,1)\n\t\t\t\t\t\t+f(n-4,t-1,1);\n\tif(i==3)\treturn \tf(n-2,t-1,3)+f(n-2,t-1,2)+f(n-2,t-1,1)\n\t\t\t\t\t\t+f(n-3,t-1,2)+f(n-3,t-1,1)+f(n-3,t-1,1)\n\t\t\t\t\t\t+f(n-4,t-1,1);\n}\nint main()\n{\n\tint n,t;\n\tcin>>n>>t;\n\tcout<\nusing namespace std;\n\nint main() {\n\n\tint grid[9];\n\tint a = 100000;\n\tint total = a;\n\tscanf(\"%d\", grid + 0);\n\tscanf(\"%d\", grid + 1);\n\ttotal += grid[1];\n\tscanf(\"%d\", grid + 2);\n\ttotal += grid[2];\n\n\tint b = total;\n\tscanf(\"%d\", grid + 3);\n\tb -= grid[3];\n\tscanf(\"%d\", grid + 4);\n\tscanf(\"%d\", grid + 5);\n\tb -= grid[5];\n\n\tint c = total;\n\tscanf(\"%d\", grid + 6);\n\tc -= grid[6];\n\tscanf(\"%d\", grid + 7);\n\tc -= grid[7];\n\tscanf(\"%d\", grid + 8);\n\n\tint off = min(a, min(b, c)) - 1;\n\ta -= off;\n\tb -= off;\n\tc -= off;\n\n\tint total = a + grid[1] + grid[2];\n\toff = (total - a - b - c) / 2;\n\ta += off;\n\tb += off;\n\tc += off;\n\n\tprintf(\"%d %d %d\\n\", a, grid[1], grid[2]);\n\tprintf(\"%d %d %d\\n\", grid[3], b, grid[5]);\n\tprintf(\"%d %d %d\\n\", grid[6], grid[7], c);\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fc93416ed18221d924324ee5c30ce043", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include\nusing namespace std;\nint main()\n{\n int a[3][3];\n int i,j,k;\n for(i=0;i<3;i++)\n for(j=0;j<3;j++)\n cin>>a[i][j];\n int b,c,d;\n c=(a[0][2]+a[2][0])/2;\n d=2*a[0][2]+a[2][0]-a[2][1]-c;\n b=a[2][1]-a[0][2]+c;\n a[0][0]=b;\n a[1][1]=c;\n a[2][2]=d;\n for(i=0;i<3;i++)\n for(j=0;j<3;j++)\n if(j==2)\n cout<\nusing namespace std;\n\nint a,b,c,d,e,f,g,h,i;\nmain(){\n cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;\n \n cout<<((h+f)/2<<' '<\n\nusing namespace std;\n\nint main()\n{\n int a[3][3];\n for (int i = 0; i < 3; ++i) {\n for (int j = 0; j < 3; ++j) {\n cin >> a[i][j];\n }\n }\n a[2][2] = (a[2][0] + a[0][2] - a[1][2] + a[0][1]) / 2;\n a[1][1] = (a[2][0] + a[2][1] + a[2][2]) - (a[1][0] + a[1][2]);\n a[0][0] = (a[2][0] + a[2][1] + a[2][2]) - (a[0][1] + a[0][2]);\n for (int i = 0; i < 3; ++i) {\n for (int j = 0; j < 3; ++j) {\n cout << a[i][j] << ' ';\n }\n cout << endl;\n }\n //int i;\n //cin >> i;\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f226b063122f9087107ad8828ae322fe", "src_uid": "0c42eafb73d1e30f168958a06a0f9bca", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include \n\nusing namespace std;\nstruct twod{\n\tint xCord;\n\tint yCord;\n};\nint main(){\n\tint oriX, oriY;\n\t//int arr[3][3] = {};\n\ttwod containter;\n\tfor (int i = 0; i < 8; ++i){\n\t\tcin >> container[i].xCord >> container[i].yCord;\n\t}\n\t\toriX = container[0].xCord;\n\t\toriY = container[0].yCord;\n\t\tint n = 0;\n\t\tint flag = 1;\n\twhile(n<8){\n\t\tfor (int i = 0; i < 3; ++i){ //i = x coordinate, k = y coordinate\n\t\t\t\n\t\t\tfor (int k= 0; k < 3; ++k)\n\t\t\t{\n\t\t\t\tif(i == 2 && k ==2) continue;\n\t\t\t\tif(((container[n].yCord - oriY) == k && (container[n].xCord - oriX) == k)|| ((container[k].XCord - oriX) !=1 && (container[k].yCord - oriY) !=1)){\n\t\t\t\t\tn++; \n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tflag = 0;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t}\n\t\t}\t\n\t\n\t}\n\n\tif (flag == 0) cout << \"ugly\";\n\telse cout <<\"respectable\";\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b2f27876727069d9be3d3e4a8c790130", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400.0} {"lang": "GNU C++0x", "source_code": "#include \n 2 #include \n 3 #include \n 4 #include \n 5 using namespace std;\n 6 \n 7 struct set\n 8 {\n 9 int x, y;\n10 }p[10];\n11 \n12 int cmp(set a, set b)\n13 {\n14 if (a.x != b.x) // x\u4e0d\u540c\u65f6\uff08\u7ec4\u5916\uff09\u6309x\uff08\u7ec4\u5916\uff09\u5347\u5e8f\u6392\u5e8f\n15 return a.x < b.x;\n16 return a.y < b.y; // x\u76f8\u540c\u65f6\uff08\u7ec4\u5185\uff09\u6309y\uff08\u7ec4\u5185\uff09\u5347\u5e8f\u6392\u5e8f\n17 }\n18 \n19 int main()\n20 {\n21 int i;\n22 for (i = 0; i < 8; i++)\n23 {\n24 scanf(\"%d%d\", &p[i].x, &p[i].y);\n25 }\n26 sort(p, p+8, cmp);\n27 /* for (i = 0; i < 8; i++)\n28 {\n29 printf(\"%d\\t%d\\n\", p[i].x, p[i].y);\n30 }\n31 */\n32 if (p[0].x == p[2].x && p[3].x == p[4].x && p[5].x == p[7].x &&\n33 p[0].x != p[3].x && p[3].x != p[5].x &&\n34 p[0].y == p[3].y && p[0].y == p[5].y && p[1].y == p[6].y && \n35 p[2].y == p[4].y && p[2].y == p[7].y && p[0].y != p[1].y && \n36 p[1].y != p[2].y)\n37 printf(\"respectable\\n\");\n38 else\n39 printf(\"ugly\\n\");\n40 return 0;\n41 }", "lang_cluster": "C++", "compilation_error": true, "code_uid": "dcced432d9ae5c0f3bb7f65ec7165f80", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \nusing namespace std;\nstruct point\n{\n int x, y;\n friend bool operator < (point x, point y)\n {\n return x.x < y.x || x.x == y.x && x.y < y.y;\n }\n}s[8];\nint main(int argc, char **argv)\n{\n\tint i;\n\tbool f = 1;\n\tfor(i = 0; i < 8; i++)\n\t cin >> s[i].x >> s[i].y;\n\tsort(s, s + 8);\n\tfor(i = 0; i < 7; i++)\n\t if(!(s[i] != s[i + 1])) f = 0;\n\tif(s[0].x == s[1].x && s[1].x == s[2].x && s[5].x == s[6].x && s[6].x == s[7].x && s[3].x == s[4].x && s[2].x != s[3].x && s[4].x != s[5].x);\n\telse f = 0;\n\tif(s[0].y == s[3].y && s[3].y == s[5].y && s[2].y == s[4].y && s[4].y == s[7].y && s[1].y == s[6].y && s[5].y != s[1].y && s[6].y != s[2].y);\n\telse f = 0;\n\tif(f) cout << \"respectable\" << endl;\n\telse cout << \"ugly\" << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d6e8b56c84b433672c3995b6453e9e5e", "src_uid": "f3c96123334534056f26b96f90886807", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\n\nstruct point\n{\n int x;\n int y;\n}a[1<<4];\n\n\nbool sortt(point a, point b)\n{\n if(a.x>a[1].x>>a[1].y;\n cin>>a[2].x>>a[2].y;\n cin>>a[3].x>>a[3].y;\n cin>>a[4].x>>a[4].y;\n cin>>a[5].x>>a[5].y;\n cin>>a[6].x>>a[6].y;\n cin>>a[7].x>>a[7].y;\n cin>>a[8].x>>a[8].y;\n \n sort(a+1,a+9,sortt);\n \n /*for(int i=1;i<=8;i++)\n {\n cout<\n\n#define pb push_back\n#define mp make_pair\n#define forn(i, n) for (int i = 0; i < (int) n; i++)\n#define fornr(i, n) for (int i = n - 1; i >= 0; i--)\n#define forab(i, a, b) for (int i = a; i < (int) b; i++)\n#define gcd __gcd\n \n#ifdef WIN32\n #define I64 \"%I64d\"\n#else\n #define I64 \"%lld\"\n#endif\n\nusing namespace std;\n\ntypedef long long LL;\ntypedef unsigned long long ULL;\ntypedef long double LD;\ntypedef pair pii;\ntypedef vector vi;\n\ntemplate T sqr(const T &a) {return a * a;}\n\nstruct st\n{\n int l, r, type, cost, num;\n st(){}\n st(int _l, int _r, int _t, int _c, int _n) : l(_l), r(_r) ,type(_t), cost(_c), num(_n) {}\n bool operator < (const st &a) const\n {\n if (l != a.l)\n return l < a.l;\n return mp(type, num) < mp(a.type, a.num);\n }\n};\n\nint n, m;\nvector a;\nLL ans;\npii res;\nset > s;\nset > q;\nint x, y, z;\nvi b;\nmap Map;\npii t[1600000];\n\nvoid add(int vl, int vr, int pos, pii val, int v)\n{\n if (vl + 1 == vr)\n {\n t[v] = max(t[v], val);\n return;\n }\n int vm = (vl + vr) / 2;\n if (vm > pos)\n add(vl, vm, pos, val, 2 * v);\n else\n add(vm, vr, pos, val, 2 * v + 1);\n t[v] = max(t[2 * v], t[2 * v + 1]);\n}\n\npii Get(int vl, int vr, int l, int r, int v)\n{\n if (vl >= l && vr <= r)\n return t[v];\n if (vl >= r || vr <= l)\n return mp(0, 0);\n int vm = (vl +vr) / 2;\n return max(Get(vl, vm, l, r, 2 * v), Get(vm, vr, l, r, 2 * v + 1));\n}\n\nint main()\n{\n\n \n scanf(\"%d%d\", &n, &m);\n forn(i, n)\n scanf(\"%d%d\", &x, &y), a.pb(st(x, y, 0, 0, i)), b.pb(x), b.pb(y);\n forn(i, m)\n scanf(\"%d%d%d\", &x, &y, &z), a.pb(st(x, y, 1, z, i)), b.pb(x), b.pb(y);\n sort(a.begin(), a.end());\n sort(b.begin(), b.end());\n unique(b.begin(), b.end());\n forn(i, (int) b.size())\n Map[b[i]] = i;\n\n forn(i, (int) a.size())\n {\n if (a[i].type == 0)\n s.insert(mp(a[i].r, a[i].num));\n\n else if (s.size())\n {\n auto pos = s.upper_bound(mp(a[i].r, 1e9));\n int r;\n if (pos != s.end())\n r = a[i].r;\n else\n pos--, r = pos->first;\n if (ans < 1ll*(r - a[i].l) * 1ll*a[i].cost)\n ans = 1ll*(r - a[i].l) * 1ll*a[i].cost, res = mp(a[i].num, pos->second);\n }\n }\n forn(i, (int) a.size())\n {\n if (a[i].type == 1)\n add(0, b.size(), Map[a[i].r], mp(a[i].cost, a[i].num), 1);\n else \n \n pii tmp = Get(0, b.size(), Map[a[i].r], b.size(), 1);\n if (1ll * tmp.first * (a[i].r - a[i].l) > ans)\n ans = 1ll * tmp.first * (a[i].r - a[i].l), res = mp(a[i].num, tmp.second);\n }\n }\n s.clear();\n forn(i, a.size())\n a[i].l = 1e9 - a[i].l, a[i].r = 1e9 - a[i].r, swap(a[i].l, a[i].r);\n fornr(i, (int) a.size())\n {\n if (a[i].type == 0)\n s.insert(mp(a[i].r, a[i].num));\n\n else if (s.size())\n {\n auto pos = s.upper_bound(mp(a[i].r, 1e9));\n int r;\n if (pos != s.end())\n r = a[i].r;\n else\n pos--, r = pos->first;\n if (ans < 1ll*(r - a[i].l) * 1ll*a[i].cost)\n ans = 1ll*(r - a[i].l) * 1ll*a[i].cost, res = mp(a[i].num, pos->second);\n }\n }\n printf(I64\"\\n\", ans);\n if (ans)\n printf(\"%d %d\\n\", res.second + 1, res.first+ 1);\n} \n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "41fc0806d1d2fa04ca39f0e783df9d5e", "src_uid": "af518bd91bddecb77772277341420fa2", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define pb push_back\n#define mp make_pair\n#define sz(s) int((s).size())\n#define len(s) int((s).size())\n#define all(x) (x).begin(), (x).end()\n#define fs first\n#define sc second\n#define next _next\n#define prev _prev\n#define rank _rank\n#define link _link\n#define hash _hash\n#ifdef LOCAL42\n#define eprintf(...) fprintf(stderr, __VA_ARGS__)\n#else\n#define eprintf(...) 42\n#endif\n#if _WIN32 || _WIN64 || __WIN32__ || __WIN64__\n#define LLD \"%I64d\"\n#else\n#define LLD \"%lld\"\n#endif\n\ntypedef long long ll;\ntypedef long long llong;\ntypedef long long int64;\ntypedef unsigned int uint;\ntypedef unsigned long long ull;\ntypedef unsigned long long ullong;\ntypedef unsigned long long lint;\ntypedef long double ld;\ntypedef complex tc;\ntypedef pair pii;\ntypedef vector vi;\n\nconst int inf = int(1e9);\nconst double eps = 1e-9;\nconst double pi = 4 * atan(double(1));\nconst int N = int(2e5) + 100;\n\nstruct seg {\n \n int l, r, pl, num;\n \n};\n\nbool operator < (const seg& a, const seg& b) {\n return a.r - a.l > b.r - b.l;\n}\n\nint k;\nseg s[N];\nint a[N], pa[N], b[N], c[N], l[N], r[N], ans[N], mid[N], x[N], fen_sum[N], fen_max[N];\nbool good[N];\npii q[N];\n\ninline void add(int num) {\n for (int pos = s[num].pl; pos < k; pos = (pos | (pos + 1))) {\n ++fen_sum[pos];\n fen_max[pos] = max(fen_max[pos], s[num].r);\n }\n}\n\ninline int get_max(int pos) {\n int res = -inf;\n while (pos >= 0) {\n res = max(res, fen_max[pos]);\n pos = (pos & (pos + 1)) - 1;\n }\n return res;\n}\n\ninline int get_cnt(int pos) {\n int res = 0;\n while (pos >= 0) {\n res += fen_sum[pos];\n pos = (pos & (pos + 1)) - 1;\n }\n return res;\n}\n\ninline int get_cnt(int l, int r) {\n if (l > r) {\n return 0;\n }\n return get_cnt(r) - (l > 0 ? get_cnt(l - 1) : 0);\n}\n\nint main() {\n#ifdef LOCAL42\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n#endif\n int n, m;\n cin >> n >> m;\n for (int i = 0; i < n; ++i) {\n scanf(\"%d %d\", &s[i].l, &s[i].r);\n x[i] = s[i].l;\n s[i].num = i;\n }\n sort(s, s + n);\n sort(x, x + n);\n k = (int) (unique(x, x + n) - x);\n for (int i = 0; i < n; ++i) {\n s[i].pl = (int) (lower_bound(x, x + k, s[i].l) - x);\n }\n for (int i = 0; i < m; ++i) {\n scanf(\"%d %d %d\", a + i, b + i, c + i);\n pa[i] = (int) (upper_bound(x, x + k, a[i]) - x);\n l[i] = 1;\n r[i] = inf;\n ans[i] = 0;\n }\n for (;;) {\n bool fl = false;\n int sz = 0;\n for (int i = 0; i < m; ++i) {\n if (l[i] <= r[i]) {\n mid[i] = (l[i] + r[i]) / 2;\n good[i] = false;\n fl = true;\n q[sz++] = mp(mid[i], i);\n }\n }\n if (!fl) {\n break;\n }\n sort(q, q + sz);\n for (int i = 0; i < k; ++i) {\n fen_sum[i] = 0;\n fen_max[i] = -inf;\n }\n int ptr = 0;\n for (int i = 0; i < sz; ++i) {\n while (ptr < n && s[ptr].r - s[ptr].l >= q[i].fs) {\n add(ptr++);\n }\n int num = q[i].sc;\n if (get_max(pa[num] - 1) >= a[num] + mid[num]) {\n good[num] = true;\n continue;\n }\n int pos = (int) (upper_bound(x, x + k, b[num] - mid[num]) - x);\n if (get_cnt(pa[num], pos - 1) > 0) {\n good[num] = true;\n }\n }\n for (int i = 0; i < m; ++i) {\n if (l[i] <= r[i]) {\n if (good[i]) {\n ans[i] = mid[i];\n l[i] = mid[i] + 1;\n } else {\n r[i] = mid[i] - 1;\n }\n }\n }\n }\n ll best = 0;\n int x = -1, y = -1;\n for (int i = 0; i < m; ++i) {\n ll cur = 1LL * c[i] * ans[i];\n if (cur > best) {\n best = cur;\n y = i;\n }\n }\n if (best > 0) {\n for (int i = 0; i < n; ++i) {\n int l = max(s[i].l, a[y]);\n int r = min(s[i].r, b[y]);\n if (1LL * (r - l) * c[y] == best) {\n x = s[i].num;\n }\n }\n assert(x != -1);\n }\n cout << best << endl;\n if (best > 0) {\n cout << x + 1 << \" \" << y + 1 << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "64b60318b70a1108ab876b82da88e95d", "src_uid": "af518bd91bddecb77772277341420fa2", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define pb push_back\n#define mp make_pair\n#define sz(s) int((s).size())\n#define len(s) int((s).size())\n#define all(x) (x).begin(), (x).end()\n#define fs first\n#define sc second\n#define next _next\n#define prev _prev\n#define rank _rank\n#define link _link\n#define hash _hash\n#ifdef LOCAL42\n#define eprintf(...) fprintf(stderr, __VA_ARGS__)\n#else\n#define eprintf(...) 42\n#endif\n#if _WIN32 || _WIN64 || __WIN32__ || __WIN64__\n#define LLD \"%I64d\"\n#else\n#define LLD \"%lld\"\n#endif\n\ntypedef long long ll;\ntypedef long long llong;\ntypedef long long int64;\ntypedef unsigned int uint;\ntypedef unsigned long long ull;\ntypedef unsigned long long ullong;\ntypedef unsigned long long lint;\ntypedef long double ld;\ntypedef complex tc;\ntypedef pair pii;\ntypedef vector vi;\n\nconst int inf = int(1e9);\nconst double eps = 1e-9;\nconst double pi = 4 * atan(double(1));\nconst int N = int(2e5) + 100;\n\nstruct seg {\n \n int l, r, pl, num;\n \n};\n\nbool operator < (const seg& a, const seg& b) {\n return a.r - a.l > b.r - b.l;\n}\n\nint k;\nseg s[N];\nint a[N], pa[N], b[N], c[N], l[N], r[N], ans[N], mid[N], x[N], fen_sum[N], fen_max[N];\nbool good[N];\npii q[N];\n\ninline void add(int num) {\n for (int pos = s[num].pl; pos < k; pos = (pos | (pos + 1))) {\n ++fen_sum[pos];\n fen_max[pos] = max(fen_max[pos], s[num].r);\n }\n}\n\ninline int get_max(int pos) {\n int res = -inf;\n while (pos >= 0) {\n res = max(res, fen_max[pos]);\n pos = (pos & (pos + 1)) - 1;\n }\n return res;\n}\n\ninline int get_cnt(int pos) {\n int res = 0;\n while (pos >= 0) {\n res += fen_sum[pos];\n pos = (pos & (pos + 1)) - 1;\n }\n return res;\n}\n\ninline int get_cnt(int l, int r) {\n if (l > r) {\n return 0;\n }\n return get_cnt(r) - (l > 0 ? get_cnt(l - 1) : 0);\n}\n\nint main() {\n#ifdef LOCAL42\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n#endif\n int n, m;\n cin >> n >> m;\n for (int i = 0; i < n; ++i) {\n scanf(\"%d %d\", &s[i].l, &s[i].r);\n x[i] = s[i].l;\n s[i].num = i;\n }\n sort(s, s + n);\n sort(x, x + n);\n k = (int) (unique(x, x + n) - x);\n for (int i = 0; i < n; ++i) {\n s[i].pl = (int) (lower_bound(x, x + k, s[i].l) - x);\n }\n for (int i = 0; i < m; ++i) {\n scanf(\"%d %d %d\", a + i, b + i, c + i);\n pa[i] = (int) (upper_bound(x, x + k, a[i]) - x);\n l[i] = 1;\n r[i] = inf;\n ans[i] = 0;\n }\n for (;;) {\n bool fl = false;\n int sz = 0;\n for (int i = 0; i < m; ++i) {\n if (l[i] <= r[i]) {\n mid[i] = (l[i] + r[i]) / 2;\n good[i] = false;\n fl = true;\n q[sz++] = mp(mid[i], i);\n }\n }\n if (!fl) {\n break;\n }\n sort(q, q + sz);\n for (int i = 0; i < k; ++i) {\n fen_sum[i] = 0;\n fen_max[i] = -inf;\n }\n int ptr = 0;\n for (int i = 0; i < sz; ++i) {\n while (ptr < n && s[ptr].r - s[ptr].l >= q[i].fs) {\n add(ptr++);\n }\n int num = q[i].sc;\n if (min(get_max(pa[num] - 1), b[num]) >= a[num] + mid[num]) {\n good[num] = true;\n continue;\n }\n int pos = (int) (upper_bound(x, x + k, b[num] - mid[num]) - x);\n if (get_cnt(pa[num], pos - 1) > 0) {\n good[num] = true;\n }\n }\n for (int i = 0; i < m; ++i) {\n if (l[i] <= r[i]) {\n if (good[i]) {\n ans[i] = mid[i];\n l[i] = mid[i] + 1;\n } else {\n r[i] = mid[i] - 1;\n }\n }\n }\n }\n ll best = 0;\n int x = -1, y = -1;\n for (int i = 0; i < m; ++i) {\n ll cur = 1LL * c[i] * ans[i];\n if (cur > best) {\n best = cur;\n y = i;\n }\n }\n if (best > 0) {\n for (int i = 0; i < n; ++i) {\n int l = max(s[i].l, a[y]);\n int r = min(s[i].r, b[y]);\n if (l > r) {\n continue;\n }\n if (1LL * (r - l) * c[y] == best) {\n x = s[i].num;\n }\n }\n assert(x != -1);\n }\n cout << best << endl;\n if (best > 0) {\n cout << x + 1 << \" \" << y + 1 << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "440222d02ca6669a89ce536d93905e5f", "src_uid": "af518bd91bddecb77772277341420fa2", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define forab(i, a, b) for(int i = int(a); i < int(b); ++i)\n#define forba(i, b, a) for(int i = int(b) - 1; i >= int(a); --i)\n#define forn(i, n) forab(i, 0, n)\n\t\ntypedef long long ll;\ntypedef long double ldb;\n\nconst int INF = 1e9;\nconst int MAXN = 2e5 + 10;\n\nstruct tree {\n\tint x[4 * MAXN];\n\tint sz;\n\n\tvoid build(int n) {\n\t\tsz = 1;\n\t\twhile (sz < n)\n\t\t\tsz *= 2;\n\n\t\tforab(i, 1, 2 * sz)\n\t\t\tx[i] = 0;\n\t}\n\n\tvoid set(int p, int val) {\n\t\tint j = sz + p;\n\t\tx[j] = val;\n\n\t\twhile (j > 1) {\n\t\t\tj /= 2;\n\t\t\tx[j] = max(x[2 * j], x[2 * j + 1]);\n\t\t}\n\t}\n\n\tint getMax(int l, int r, int v=1, int L=0, int R=-1) {\n\t\tif (R == -1)\n\t\t\tR = sz;\n\n\t\tif (R <= l || r <= L)\n\t\t\treturn -INF;\n\n\t\tif (l <= L && R <= r)\n\t\t\treturn x[v];\n\n\t\treturn max(getMax(l, r, 2 * v, L, (L + R) / 2), getMax(l, r, 2 * v + 1, (L + R) / 2, R));\n\t}\n};\n\nstruct seg {\n\tint l, r;\n\tint c;\n\tint num;\n};\n\nint n, m;\nseg rl[MAXN];\nseg rl2[MAXN];\n\nseg ch[MAXN];\n\nbool lessl(const seg & a, const seg & b) {\n\treturn a.l < b.l;\n}\n\nbool lessr(const seg & a, const seg & b) {\n\treturn a.r < b.r;\n}\n\nbool lessnum(const seg & a, const seg & b) {\n\treturn a.num < b.num;\n}\n\nll ans = 0;\nint chnum, rlnum;\n\ntree t;\n\nint main() {\n#ifdef LOCAL \n\tfreopen(\"input.txt\", \"r\", stdin);\n#endif\n\n\tscanf(\"%d%d\", &n, &m);\n\t\n\tforn(i, n) {\n\t\tscanf(\"%d%d\", &rl[i].l, &rl[i].r);\n\t\trl[i].num = i;\n\t}\n\tforn(i, m) {\n\t\tscanf(\"%d%d%d\", &ch[i].l, &ch[i].r, &ch[i].c);\n\t\tch[i].num = i;\n\t}\n\n\tforn(q, 2) {\n\t\tforn(i, n) {\n\t\t\trl[i].l *= -1;\n\t\t\trl[i].r *= -1;\n\t\t\tswap(rl[i].l, rl[i].r);\n\t\t}\n\t\tforn(i, m) {\n\t\t\tch[i].l *= -1;\n\t\t\tch[i].r *= -1;\n\t\t\tswap(ch[i].l, ch[i].r);\n\t\t}\n\t\tsort(rl, rl + n, lessl);\n\t\tsort(ch, ch + m, lessr);\n\n\n\t\tt.build(n);\n\t\tforn(i, n)\n\t\t\tt.set(i, rl[i].r);\n\n\t\tforn(i, m) {\n\t\t\tint pos = lower_bound(rl, rl + n, ch[i], lessl) - rl;\n\n\t\t\tint r = t.getMax(0, pos);\n\t\t\tif (r > ch[i].l) {\n\t\t\t\tll cur = (r - ch[i].l) * 1ll * ch[i].c;\n\n\t\t\t\tif (ans < cur) {\n\t\t\t\t\tans = cur;\n\t\t\t\t\tchnum = ch[i].num;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tforn(i, n) {\n\t\trl2[i] = rl[i];\n\t\trl2[i].num = i;\n\t}\n\tsort(rl2, rl2 + n, lessr);\n\n\tt.build(n);\n\tint k = 0;\n\tforn(i, m) {\n\t\twhile (k < n && rl2[k].r <= ch[i].r) {\n\t\t\tt.set(rl2[k].num, rl2[k].r - rl2[k].l);\n\t\t\tk++;\n\t\t}\n\n\t\tint pos = lower_bound(rl, rl + n, ch[i], lessl) - rl;\n\n\t\tint len = t.getMax(pos, t.sz);\n\n\t\tif (len * 1ll * ch[i].c > ans) {\n\t\t\tans = len * 1ll * ch[i].c;\n\t\t\tchnum = ch[i].num;\n\t\t}\n\t}\n\n\tcout << ans << '\\n';\n\n\tif (ans > 0) {\n\n\t\tsort(rl, rl + n, lessnum);\n\t\tsort(ch, ch + m, lessnum);\n\n\t\trlnum = -1;\n\n\t\tforn(i, n) {\n\t\t\tll cur = ch[chnum].c * 1ll * (min(ch[chnum].r, rl[i].r) - max(ch[chnum].l, rl[i].l));\n\n\t\t\tif (cur == ans) {\n\t\t\t\trlnum = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tassert(rlnum != -1);\n\n\t\tprintf(\"%d %d\\n\", rlnum + 1, chnum + 1);\n\t}\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5af2d92eea889eddca98dff22f12367a", "src_uid": "af518bd91bddecb77772277341420fa2", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\nint main() {\n\n\tint n;\n\n\n\n\tcin >> n;\n\n\tif ((n <= pow(10, 9)) && n >= 1){\n\t\tif (n % 2 == 0){ cout << n / 2; }\n\t\telse { cout << (n / 2) + 1; }\n\n\t}\n\n\treturn 0;\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bfe2751fdf782224607ef55fb4b48837", "src_uid": "30e95770f12c631ce498a2b20c2931c7", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main(){\n int n;\n cin >> n ;\n cout << (n > 1)? 2 : 1;\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "113d5b084ca2eaf3e35212dd7b70c29c", "src_uid": "30e95770f12c631ce498a2b20c2931c7", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\nint mian()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tprintf(\"%d\\n\",(n+1)/2);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2ea9bb3d1701a20480cc154d0018cadf", "src_uid": "30e95770f12c631ce498a2b20c2931c7", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint f[10001][2];\n\nint main()\n{\n\tint n;\n\tscanf(\"%d\",&n);\n\tif(n==1)\n\t\tcout<<1<\n#define ll long long\n#define pb push_back\n#define\tendl\t\t'\\n'\n#define pii pair\n#define vi vector\n#define all(a) (a).begin(),(a).end()\n#define F first\n#define S second\n#define sz(x) (ll int)x.size()\n#define hell 1000000007\n#define f0(i,n)\tfor(i=0;i>n;\n string s,s1=\"\",s2=\"\";\n cin>>s;\n f0(i,n){\n s1+=s[i];\n }\n rep(i,n,2*n){\n s2+=s[i];\n }\n for(i=0;i=max1)\n max1=s1[i]-'0';\n if(s2[i]-'0'<=min2)\n min2=s2[i]-'0';\n if(s2[i]-'0'>=max2)\n max2=s2[i]-'0';\n }\n if(n==1){\n if(s[0]!=s[1])\n cout<<\"YES\"<\nusing namespace std;\nint absolute(int);\nint main()\n{\n int n,t=0;\n cin>>n;\n char s[2*n+1];\n cin>>s;\n for(int i=n;i<(2*n);i++)\n {\n for(int j=0;js[j])\n t++;\n else if(s[i]0)\n return a;\n else\n {\n a*=-1;\n return a;\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2e5ea10ed2b1b13a313bda5f5771b56d", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n#define all(c) c.begin(),c.end()\ntypedef long long ll;\nconst int N=1000;\nint n;\nstring x;\nvectorf,s;\nint main(){\n\t#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\" , stdin);\n\tfreopen(\"output.txt\", \"w\" , stdout);\n\t#endif // ONLINE_JUDGE\n\tscanf(\"%d\",&n);\n\tcin >> x;\n\tfor(int i =0;if[j]&&!vis[j]){\n\t\t\t\tcnt++;\n\t\t\t\tvis[j]=true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tif(cnt==n||cnt==0){\n\t\tprintf(\"YES\\n\");\n\t}else\n\tprintf(\"NO\\n\");\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f2bc67c153a407bf98a07168c9a1200a", "src_uid": "e4419bca9d605dbd63f7884377e28769", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nint main()\n{\nint n,i=0;\nint count=0,count1=0;\nstring s;\n\tcin>>n>>s;\n\tsort(s.begin(),s.end()-n);\n\tsort(s.begin()+n,s.end());\n\twhile(is[i+n])\n\t\t{\n\t\t count++;\n\t\t}\n\t\tif(s[i]\nusing namespace std;\n\nint main() {\n unsigned long long n, ans = 0;\n cin >> n;\n cout << (fact(n - 1) / (fact(n / 2) * fact(n - 1 - n / 2))) * pow(fact(n / 2 - 1), 2);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f4d844a4774a9e6b20aabefb798adbe4", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define ll __int128\n\nvoid print(ll x){\n if(x<0){\n x=-x;\n putchar('-');\n }\n if(x>9) print(x/10);\n putchar(x%10+'0');\n}\n\nll A(int x){\n ll sum=1;\n for(int i=1;i<=x;i++)\n sum*=i;\n return sum;\n}\n\nll C(int n,int m){\n ll sum=1;\n for(int i=n+1;i<=m;i++)\n sum*=i;\n for(int i=1;i<=n;i++)\n sum/=i;\n return sum;\n}\n\nint main(){\n int n;cin>>n;\n ll ans=C(n/2,n)*A(n-1)*A(n-1)/2;\n print(ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2fcdd6662aeb3d3993491b6823b61411", "src_uid": "ad0985c56a207f76afa2ecd642f56728", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main()\n{\n int t;\n cin>>t;\n while(t--)\n {\n int n;\n cin>>n;\n int arr[]= {1, 3, 40, 1260, 72576, 6652800, 889574400, 163459296000,\n 39520825344000, 12164510040883200};\n cout<\n\nusing namespace std;\n\nint main(){\n \n int n;\n ll ans=1;\n cin>>n;\n n--;\n while(n!=1){\n ans*=n;\n n-=1; \n } \n cout<\nusing namespace std;\n#define fi freopen(\"input.txt\",\"r\",stdin)\n#define fo freopen(\"output.txt\",\"w\",stdout)\n#define l(s) int(s.size())\n#define pb push_back\n#define rep(i,n) for(int i=0;i mp;\nint a[10][10];\nbool better(int x,int y)\n{\n\tint px=0,py=0,mx=0,sx=0,sy=0,my=0;\n\trep(i,4)\n\t{\n\t\tif(i!=x)\n\t\t{\n\t\t\tif(a[x][i]>a[i][x])\n\t\t\t\tsx+=3;\n\t\t\telse if(a[x][i]==a[i][x])\n\t\t\t\tsx++;\n\t\t\tpx+=a[i][x];\n\t\t\tmx+=a[x][i];\n\t\t}\n\t}\n\trep(i,4)\n\t{\n\t\tif(i!=y)\n\t\t{\n\t\t\tif(a[y][i]>a[i][y])\n\t\t\t\tsy+=3;\n\t\t\telse if(a[y][i]==a[i][y])\n\t\t\t\tsy++;\n\t\t\tpy+=a[i][y];\n\t\t\tmy+=a[y][i];\n\t\t}\n\t}\n\tif(sx!=sy)\n\t\treturn (sx>sy);\n\tif(px-mx!=py-my)\n\t\treturn (px-mx>py-my);\n\tif(px!=py)\n\t\treturn (px>py);\n\treturn (x>s1[i]>>s2[i]>>score[i];\n\trep(i,5)\n\t\tmp[s1[i]]=mp[s2[i]]=0;\n\tforeach(mp,itr)\n\t{\n\t\t(itr->second)=i;\n\t\tname[i]=(itr->first);\n\t\ti++;\n\t}\n\trep(i,4)\n\t\trep(j,4)\n\t\t\ta[i][j]=-1;\n\trep(i,5)\n\t{\n\t\tint x=mp[s1[i]],y=mp[s2[i]];\n\t\trep(j,score.length())\n\t\t\tif(score[i][j]==':')\n\t\t\t\tscore[i][j]=' ';\n\t\tistringstream ss(score[i]);\n\t\tss>>a[x][y]>>a[y][x];\n\t}\n\tfor(d=1;d<100;d++)\n\t\trep(i,100)\n\t\t{\n\t\t\tj=i+d;\n\t\t\tif(check(j,i))\n\t\t\t{\n\t\t\t\tcout<\nusing namespace std;\nstruct node{\n\tint c,d,t,cnt;\n};\nint rank,flag;\nstring s[10][10],n[10],me,op;\nvectorv;\nmapmp;\nbool cmp(string x,string y){\n\tif(mp[x].c!=mp[y].c)return mp[x].c>mp[y].c;\n\tif(mp[x].d!=mp[y].d)return mp[x].d>mp[y].d;\n\tif(mp[x].t!=mp[y].t)return mp[x].t>mp[y].t;\n\treturn x>s[i][1]>>s[i][2]>>s[i][3];\n\tfor(int i=1;i<=5;i++)for(int j=1;j<=2;j++){\n\t\tflag=0;\n\t\tfor(int p=0;pa[3-j])mp[s[i][j]].c+=3;\n\t \tif(a[j]==a[3-j])mp[s[i][j]].c++;\n\t \tmp[s[i][j]].d+=a[j]-a[3-j];mp[s[i][j]].t+=a[j];\n\t\t}\n\t}\n\t//for(int i=0;imp[me].c)rank++;\n if(rank>1){\n \tcout<<\"IMPOSSIBLE\"<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n\ntemplate\ndouble sqrt(T x)\n{\n\treturn sqrt((double) x);\n}\n\ntemplate\nT sqr (T x)\n{\n\treturn x*x;\n}\n\n\n#define eprintf(...) fprintf(stderr, __VA_ARGS__)\n#define X first\n#define Y second\n#define pb push_back\n#define mp make_pair\n#define SZ(x) (int)((x).size())\n//#define foreach(e,x) for(__typeof(x.begin()) e=x.begin();e!=x.end();++e)\n\n\n\nconst double PI = acos(-1.0);\nconst int INF = 1000000000;\nconst int MOD = 1000000007;\n\nstruct team\n{\n\tstring name;\n\tint points, dif, zab;\n\n\tteam(){};\n\tteam( string n, int p, int d, int z)\n\t{\n\t\tpoints = p;\n\t\tname = n;\n\t\tdif = d;\n\t\tzab = z;\n\t}\n\n\tbool operator<(const team o)\n\t{\n\t\tif ( points < o.points ) return 1;\n\t\tif ( points == o.points && dif < o.dif ) return 1;\n\t\tif ( points == o.points && dif == o.dif && zab < o.zab ) return 1;\n\t\tif ( points == o.points && dif == o.dif && zab == o.zab && name < o.name ) return 1;\n\t\treturn 0;\n\t}\n};\n\n\n\n\n//#define ONLINE_JUDGE\n\nint main()\n{\n\tdouble TIME_START = clock();\n#ifndef ONLINE_JUDGE\n\tfreopen(\"in.txt\",\"r\",stdin);\n\t//freopen(\"out.txt\",\"w\",stdout);\n#endif\n\n\tstring sa,sb;\n\tint ta,tb;\n\tchar ch;\n\tmap points, pro, zab, g;\n\tfor (int x = 0 ; x < 5 ; x++)\n\t{\n\t\tcin >> sa >> sb >> ta >> ch >> tb;\n\t\tpoints[sa] += 0;\n\t\tpoints[sb] += 0;\n\t\tif ( ta > tb ) points[sa] += 3;\n\t\tif ( ta < tb ) points[sb] += 3;\n\t\tif ( ta == tb ) \n\t\t{\n\t\t\tpoints[sa] += 1;\n\t\t\tpoints[sb] += 1;\n\t\t}\n\n\t\tzab[sa] += ta;\n\t\tzab[sb] += tb;\n\n\t\tpro[sa] += tb;\n\t\tpro[sb] += ta;\n\n\t\tg[sa]++;\n\t\tg[sb]++;\n\t}\n\n\tint bn, on;\n\n\tstring Ber(\"BERLAND\");\n\n\tvector temp(4), cur;\n\tint i = 0;\n\tfor ( map::iterator it = points.begin() ; it != points.end() ; it++,i++)\n\t{\n\t\ttemp[i] = team(it->X, it->Y, zab[it->X] - pro[it->X], zab[it->X]);\n\t\tif ( it->X == Ber )\n\t\t\tbn = i;\n\t\telse\n\t\t\tif ( g[it->X] == 2 ) on = i;\n\t}\n\n\tpair r;\n\tbool is = 0;\n\n\n\tfor (int x = 1 ; x <= 50 ; x++)\n\t{\n\t\tfor (int y = 0 ; y < x ; y++)\n\t\t{\n\t\t\tcur = temp;\n\n\t\t\tcur[bn].points += 3;\n\t\t\tcur[bn].zab += x;\n\t\t\tcur[on].zab += y;\n\n\t\t\tcur[bn].dif += x-y;\n\t\t\tcur[on].dif += y-x;\n\n\t\t\tsort(cur.begin(), cur.end());\n\n\t\t\tif ( cur[2].name == Ber || cur[3].name == Ber )\n\t\t\t{\n\t\t\t\tif ( is == 0 ) \n\t\t\t\t{\n\t\t\t\t\tr = mp(x,y);\n\t\t\t\t\tis = 1;\n\t\t\t\t} else\n\t\t\t\t{\n\t\t\t\t\tif ( x-y < r.X - r.Y )\n\t\t\t\t\t\tr = mp(x,y);\n\t\t\t\t\telse\n\t\t\t\t\t\tif ( x-y == r.X - r.Y )\n\t\t\t\t\t\t\tif ( y < r.Y ) \n\t\t\t\t\t\t\t\tr = mp(x,y);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\n\tif ( is == 0 ) cout<<\"IMPOSSIBLE\";\n\telse printf(\"%d:%d\",r.X, r.Y);\n\t\t\n\t\n\t\t\n\teprintf(\"\\n\\n%.15lf\\n\\n\",(double)(clock() - TIME_START)/CLOCKS_PER_SEC);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "30c79dcc4431d8d79fe7f56ceb060160", "src_uid": "5033d51c67b7ae0b1a2d9fd292fdced1", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "// codeforces Football Championship\n#include \n#include \n#include \n#include\n#include\n#include \n#include\n#include \n#include\nusing namespace std;\nmap hash;\nstring s[10],sa,sb;\nint a,b,c[10],d[10],e[10],cnt[10],n,i,j,x,y,p,sc;\nchar ch;\nbool win()\n{\n\tint i,k=0,w;\n\tfor(i=2;i<=4;i++)\n\t\tif(c[i]>c[1]) k++;\n\tif(k>1) return 0;\n\tw=1-k; k=0;\n\tfor(i=2;i<=4;i++)\n\t\tif(c[i]==c[1]&&d[1]w) return 0;\n\tw-=k; k=0;\n\tfor(i=2;i<=4;i++)\n\t\tif(c[1]==c[i]&&d[1]==d[i]&&e[1]w) return 0;\n\tw-=k; k=0;\n\tfor(i=2;i<=4;i++)\n\t\tif(c[1]==c[i]&&d[1]==d[i]&&e[1]==e[i]&&s[1]>s[i]) k++;\n\treturn k<=w;\n}\nint main()\n{\n\thash[\"BERLAND\"]=n=1; s[1]=\"BERLAND\";\n\tfor(i=1;i<6;i++)\n\t{\n\t\tcin>>sa>>sb>>x>>ch>>y;\n\t\tif(!hash[sa]) hash[sa]=++n,s[n]=sa;\n\t\tif(!hash[sb]) hash[sb]=++n,s[n]=sb;\n\t\ta=hash[sa],b=hash[sb];\n\t\tif(x>y) c[a]+=3;\n\t\telse if(x==y) c[a]++,c[b]++;\n\t\telse c[b]+=3;\n\t\td[a]+=x-y; d[b]+=y-x;\n\t\te[a]+=x; e[b]+=y;\n\t\tcnt[a]++,cnt[b]++;\n\t}\n\tfor(i=2;i<=4;i++)\n\t\tif(cnt[i]<3) p=i;\n\tfor(i=2;i<=4;i++)\n\t\tif(i!=p) sc=max(sc,c[i]);\n\tc[1]+=3;\n\tfor(i=1;i<=100;i++)\n\t{\n\t\td[1]+=i,d[p]-=i;\n\t\tfor(j=i;j<=100;j++)\n\t\t{\n\t\t\te[1]+=j,e[p]+=j-i;\n\t\t\tif(win()) {cout<\nusing namespace std;\nconst int64_t base=998244353;\nint64_t power(int64_t x, int64_t y){\n if(y==0) return 1;\n int64_t t=power(x, y/2);\n t=(t*t)%base;\n if(y%2) t=(t*x)%base;\n return t;\n}\nint64_t inverse(int64_t x){//modular inverse\n return power(x, base-2);\n}\nvector f({1}), iv({1});\n\nint64_t C(int64_t n, int64_t k){\n return ((f[n]*iv[k]%base)*iv[n-k])%base;\n}\nint64_t star(n, k){\n return C(n+k-1, k-1);\n}\nint64_t countGame(int64_t n, int64_t k, int64_t x){//n points total, k players, no player can have x point or more\n if(k==0) return !(n==0);\n int64_t ans=0\n for(int i=0; i<=k; i++){\n int64_t t=n-x*i;\n if(t<0) break;\n if(i%2) ans=(ans-C(k, i)*star(t, k))%base;\n else ans=(ans+C(k, i)*star(t, k))%base;\n }\n return ans\n}\nint main(){\n int p, s, r;\n int64_t gameSize=countGame(s-r, p, 1e18);\n gameSize=inverse(gameSize);\n cin>>p>>s>>r;\n for(int i=1; i<5555; i++){\n f.push_back((f[i-1]*i)%base);\n iv.push_back(inverse(f[i]));\n }\n int64_t ans=0;\n for (int q=r; q<=s; q++){\n for(int i=0; i\nusing namespace std;\n\nusing ll= long long;\n#define double long double\n#define sz(x) (int)x.size()\n#define all(x) (x).begin(),(x).end()\n#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n#define _set(x) __builtin_popcount(x)\n#define _setl(x) __builtin_popcountll(x)\n#define PI 3.14159265358979323846264338327950L\n#define mod 1000000007LL\n\nvoid debug(){\n\tcerr<<\"]\\n\";\n}\ntemplate void debug(H h,T... t){\n\tcerr< [\" << #__VA_ARGS__ << \"]: [\", debug(__VA_ARGS__)\n\t#define dpv(...) cerr<< \"[\"#__VA_ARGS__ \" : \";for(int i: (__VA_ARGS__)){cerr<>a>>b;\n\tcout<<\"GCD \"<>_;\n\t_=1;\n\tfor(int i=1;i<=_;i++){\n\t\t// cout<<\"Case #\"<\n#define ri register int\ntypedef long long ll;\nconst int N=5105,mod=998244353;\nint fac[N],inv[N];\ninline void add(int &x,ri y){\n\tx=(x+=y)>=mod?ax-mod:x;\n}\ninline void del(int &x,ri y){\n\tx=(x-=y)<0?x+mod:x;\n}\ninline int C(ri n,ri m){\n\treturn (ll)fac[n]*inv[m]%mod*inv[n-m]%mod;\n} \ninline int calc(ri s,ri n,ri r){ //n\u4e2a\u4eba\u603b\u5206\u4e3as,\u6bcf\u4e2a\u4eba\u5f97\u5206=r\n\t\tif(j&1)\n\t\t\tdel(tmp,(ll)C(n,j)*C(s-j*r+n-1,n-1)%mod);\n\t\telse\n\t\t\tadd(tmp,(ll)C(n,j)*C(s-j*r+n-1,n-1)%mod);\n\treturn tmp;\n}\ninline int _inv(ri x){\n\treturn (ll)inv[x]*fac[x-1]%mod;\n}\ninline int max(ri x,ri y){\n\treturn x>y ? x:y;\n}\ninline int Pow(ri a,ri b){\n\tri ans=1;\n\tfor(;b;b>>=1,a=(ll)a*a%mod)\n\t\tif(b&1) ans=(ll)ans*a%mod;\n\treturn ans;\n}\nint main(){\n ri p,s,r,i,x,ans,lim,all;\n scanf(\"%d%d%d\",&p,&s,&r);\n if(p==1) return puts(\"1\"),0;\n lim=p+s;\n fac[0]=1;\n for(i=1;i<=lim;++i) fac[i]=(ll)fac[i-1]*i%mod;\n inv[lim]=Pow(fac[lim],mod-2);\n for(i=lim;i;--i) inv[i-1]=(ll)inv[i]*i%mod;\n\tall=C(s-r+p-1,p-1);\n ans=0;\n for(;r<=s;++r) // \u679a\u4e3e\u5c0f\u660e\u7684\u5f97\u5206r \n \tfor(x=1;x<=p&&r*x<=s;++x) // \u679a\u4e3e\u6709\u591a\u5c11\u4eba(\u5305\u62ec\u5c0f\u660e)\u7684\u5f97\u5206\u4e3ar\n\t\t\tadd(ans,(ll)_inv(x)*C(p-1,x-1)%mod*calc(s-r*x,p-x,r)%mod);\n\tprintf(\"%d\\n\",(ll)ans*Pow(all,mod-2)%mod);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d705206f28ece0f8daaea0767dcea076", "src_uid": "609195ef4a970c62a8210dafe118580e", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include // \u5909\u6570\u540d\u306by1\u304c\u4f7f\u3048\u306a\u304f\u306a\u308b\u304b\u3082\u2026\u3002\n#include \n#include \n#include \n#include \n#include \n#include \n\nusing int128_t = __int128;\nstd::istream &operator>>(std::istream& input, int128_t& value) { // int128_t\u306e\u5165\u529b\u3002\u5165\u529b\u304c64bit\u306b\u53ce\u307e\u308b\u524d\u63d0\u3002\n int64_t tmp; input >> tmp; value = tmp;\n return input;\n}\nstd::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_t\u306e\u51fa\u529b\u3002\u51fa\u529b\u304c64bit\u306b\u53ce\u307e\u308b\u524d\u63d0\u3002\n output << (int64_t)value;\n return output;\n}\n\nint64_t imax(const int64_t a, const int64_t b) { return std::max(a, b); } // std::max, std::min \u306f\u578b\u304c\u9055\u3046\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308b\u305f\u3081\u3001\u30e9\u30c3\u30d1\u30fc\u3092\u4f5c\u308b\u3002\nint64_t imin(const int64_t a, const int64_t b) { return std::min(a, b); }\n\n#define rep(i, begin, end) for(int64_t i = ((int64_t)begin); i <= ((int64_t)end); i++) // (int64_t)end \u3068\u3057\u3066\u304a\u304f\u3068\u3001end = v.size() - 2 \u307f\u305f\u3044\u306a\u5165\u529b\u3067\u3001v.size()\u304c1\u3067\u3082\u6b63\u5e38(end = -1\u306b\u306a\u308b\uff09\u306b\u6319\u52d5\u3059\u308b\u3002\n#define rev(i, begin, end) for(int64_t i = ((int64_t)begin); ((int64_t)end) <= i; i--)\n\n#define input1(begin, end, v1) v1.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i]; }\n#define input2(begin, end, v1, v2) v1.resize((end)+1); v2.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i] >> v2[i]; } \n#define input3(begin, end, v1, v2, v3) v1.resize((end)+1); v2.resize((end)+1); v3.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i] >> v2[i] >> v3[i]; } \n\nstd::vector irange(const int begin, const int end) {\n std::vector ret; for (int i = begin; i <= end; i++) { ret.push_back(i); }\n return ret;\n}\n\ntemplate \nvoid printvec(const std::vector& vec) {\n for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << \" \"; } std::cout << std::endl;\n}\n\nint128_t cal_mod(const int128_t n, const int128_t mod) {\n // n % mod\u3092\u8a08\u7b97\u3059\u308b\u3002\u305f\u3060\u3057mod <= 0 \u306a\u3089\u3070\u4f55\u3082\u3057\u306a\u3044\u3002n\u304c\u8ca0\u306e\u5834\u5408\u3001\u6b63\u306b\u3057\u3066\u88dc\u6b63\u3059\u308b\u3002\n if (mod <= 0) {\n return n;\n } else if (0 <= n) {\n return n % mod;\n } else {\n int128_t tmp = (-n) / mod + 1;\n return (n + tmp * mod) % mod;\n }\n}\n\nint128_t pow_mod(int128_t x, int128_t n, const int128_t mod) {\n // \u7d2f\u4e57\u306e\u8a08\u7b97\u3002mod <= 0\u306a\u3089\u3070\u4f59\u308a\u306e\u8a08\u7b97\u306f\u884c\u308f\u306a\u3044\u3002\n int128_t ret = 1;\n while (n > 0) {\n if (n & 1) { ret = cal_mod(ret * x, mod); }\n x = cal_mod(x * x, mod);\n n = (n >> 1);\n }\n return ret;\n}\n\nclass Combi_Num {\n // \u300c\u7d44\u307f\u5408\u308f\u305b\u6570 % \u7d20\u6570\u300d\u3092\u3001\u524d\u51e6\u7406\u3092\u884c\u3063\u305f\u3046\u3048\u3067O(1)\u3067\u6c42\u3081\u308b\u3002mod\u306f32bit\u306b\u53ce\u307e\u308b\u3053\u3068\u304c\u524d\u63d0\u3002\n public:\n int128_t mod;\n std::vector factorial, factorial_inv, inv;\n Combi_Num() {}\n Combi_Num(const int n, const int128_t mod_in) {\n mod = mod_in;\n factorial.resize(n+1, 0);\n factorial_inv.resize(n+1, 0);\n inv.resize(n+1, 0);\n factorial[0] = 1;\n factorial_inv[0] = 1;\n inv[0] = 1;\n for (int i = 1; i <= n; i++) {\n factorial[i] = (factorial[i-1] * i) % mod;\n inv[i] = pow_mod(i, mod - 2, mod);\n factorial_inv[i] = (factorial_inv[i-1] * inv[i]) % mod;\n }\n }\n\n int128_t combi(const int n, const int r) const {\n return (factorial[n] * ((factorial_inv[r] * factorial_inv[n-r]) % mod)) % mod;\n }\n\n int128_t perm(const int n, const int r) const {\n return (factorial[n] * factorial_inv[n-r]) % mod;\n }\n\n // n\u500b\u306e\u8981\u7d20\u3092r\u500b\u306e\u30b0\u30eb\u30fc\u30d7\u306b\u5206\u3051\u308b\u5834\u5408\u306e\u6570\u3002\u305f\u3060\u3057\u5404\u30b0\u30eb\u30fc\u30d7\u306b\u6700\u4f4e\u3067\u3082m\u500b\u306e\u8981\u7d20\u3092\u5165\u308c\u308b\u3002\n // m\u3068\u3057\u3066\u306f\u4e3b\u306b0\u304b1\u3092\u60f3\u5b9a\u3057\u3066\u3044\u308b\u3002\n // 0\u500b\u306e\u8981\u7d20\u30920\u500b\u306e\u30b0\u30eb\u30fc\u30d7\u306b\u5206\u3051\u308b\u5834\u5408\u306e\u6570\u306f1\u3068\u3057\u3001\u6b63\u306e\u500b\u6570\u306e\u8981\u7d20\u30920\u500b\u306e\u30b0\u30eb\u30fc\u30d7\u306b\u5206\u3051\u308b\u5834\u5408\u306e\u6570\u306f0\u3068\u3059\u308b\u3002\n int128_t separate(const int n, const int r, const int m) const {\n if (n < r * m) { return 0; }\n if (0 < m) { return separate(n - r*m, r, 0); }\n if (n == 0) { return 1; }\n if (r == 0) { return 0; }\n return combi(n + r - 1, r - 1);\n }\n};\n\nint p, s, r;\n//int128_t ;\n//std::vector ;\n//std::vector ;\n//std::string ;\n//std::vector ;\n//double ;\n//std::vector ;\n\nconst int MOD = 998244353;\n\nint main(int argc, char **argv) {\n std::cout << std::fixed << std::setprecision(15);\n\n std::cin >> p >> s >> r;\n\n Combi_Num cn(1e4, MOD);\n\n int128_t P = 0;\n rep (i, r, s) {\n rep (j, 1, p) {\n if (i * j > s) { break; }\n int128_t num = 0;\n rep (k, 0, p - j) {\n if (i * (j + k) > s) { break; }\n int sgn = (k % 2 == 0) ? 1 : -1;\n num += cn.combi(p - j, k) * cn.separate(s - i * j - i * k, p - j, 0) * sgn;\n num = cal_mod(num, MOD);\n }\n num *= cn.combi(p - 1, j - 1);\n num %= MOD;\n\n P += (num * cn.inv[j]) % MOD;\n P %= MOD;\n }\n }\n\n int128_t Q = cn.separate(s - r, p, 0);\n\n int128_t ret = P * pow_mod(Q, MOD - 2, MOD);\n\n std::cout << ret % MOD << std::endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6fcef5cbde77924975ef0075330e7c85", "src_uid": "609195ef4a970c62a8210dafe118580e", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "n=int(input())\nl=[]\nc=0\nfor i in range(n):\n x=int(input())\n l.append(x)\n if x>0:\n c+=1\nif c>=n/2:\n print(1)\nelse:\n print(0)5\n ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d4476e489218f15946caea3fe64e20ff", "src_uid": "a13cb35197f896cd34614c6c0b369a49", "difficulty": 800.0} {"lang": "MS C++", "source_code": "using namespace std;\n#include\n#include\nint main()\n{\n int n;\n cin>>n;\n int * a = new int [n];\n int pos=0;\n for(int i=0;i>a[i];\n if(a[i]>0)\n pos++;\n }\n if(pos\n#include \nusing namespace std;\n\nint main()\n{\n int N;\n cin >> N;\n int NbPos=0;\n int NbNeg=0;\n for(int i=0;i>a\n if(a>0)\n NbPos++;\n if(a<0)\n NbNeg++;\n }\n int moitie=ceil(N/2)\n if(NbPos>=moitie);\n cout <<\"1\"<=moitie)\n cout <<\"-1\"<\n#include\nusing namespace std;\nint main()\n{\n int n;\n cin>>n;\n int arr[n];\n int countp=0;\n int countn=0,countz=0\n for(int i=0;i>arr[i];\n if(arr[i]>0)\n countp++;\n if(arr[i]<0)\n countn++;\n else\n countz++\n \n }\n if((countp<(n/2) && countz<(n/2)) || countz>n/2)\n {\n cout<<\"0\"<countn)\n cout<<\"4\";\n else\n cout<<\"-4\";\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "da0b788c0265f302a91a9f37033c3dd2", "src_uid": "a13cb35197f896cd34614c6c0b369a49", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#pragma comment(linker, \"/STACK:100000000000000\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define mp make_pair\n#define pb push_back\n#define lo long long int\n#define pi 3.14159265358979323\n#define eps 1e-5\n#define MN 20000000\nusing namespace std;\nconst lo INF= 1e17;\nlo pre[29] = {12 ,11 ,6 ,3 ,9 ,10 ,1 ,2 ,4 ,7 ,4 ,3 ,7 ,8 ,9 ,5 ,7 ,8 ,1 ,2 ,6 ,5 ,1 ,2 ,3 ,4 ,1 ,2 ,1};\nint main()\n{\n\t//freopen(\"input.txt\", \"r\", stdin);\n\tlo n;\n\tcin >> n;\n\tmemset(use,0 ,sizeof use);\n\tlo to = (int) sqrt((double) n) + 1;\n\tlo coun= n;\n\tlo ans = 0;\n\tfor(lo i = 2; i <= min(to, n); i++)\n\t{\n\t\tif(use[i]) continue;\n\t\tvector temp;\n\t\tlo now = i, id = 0;\n\t\tgood.clear();\n\t\twhile(now <= n)\n\t\t{\n\t\t\tif(now <= to)\n\t\t\tuse[now]++;\n\t\t\tgood.push_back(now);\n\t\t\tid++;\n\t\t\tnow *=i;\n\t\t}\n\t\tans = (ans ^ pre[29 - id]);\n\t\tcoun -= id;\n\t}\n\tif(coun % 2 == 1) ans = (ans ^ 1);\n\tcout << (ans ? \"Vasya\" : \"Petya\");\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8811daf6e5ce8b28f8e0d7661033bacd", "src_uid": "0e22093668319217b7946e62afe32195", "difficulty": 2300.0} {"lang": "GNU C++11", "source_code": "#include \n//#define int long long\nusing namespace std;\nconst int N = 32123;\nmain()\n{\n int n, i, j, x, s;\n cin >> n;\n int ans = n;\n for(i = 2; i * i <= n; i ++)\n {\n int res = i;\n int cnt = 1;\n while(res <= n)\n {\n ans += cnt - 1;\n cnt ++\n }\n }\n if(ans % 2 == 1)\n puts(\"Vasya\");\n else\n puts(\"Petya\");\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "743fc786ed1d4b60d77c635027f047fa", "src_uid": "0e22093668319217b7946e62afe32195", "difficulty": 2300.0} {"lang": "GNU C++0x", "source_code": "/*\n * File: main.cpp\n * Author: Hrayr [HarHro94]\n * Problem:\n * IDE: Visual C++ 2012\n */\n#pragma comment(linker, \"/STACK:66777216\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define pb push_back\n#define mp make_pair\n#define all(v) (v).begin(), (v).end()\n#define sz(v) (int)(v).size()\n#define LL long long\n#define LD long double\n\n/*\nmap DP;\nint calcGrundy(int mask)\n{\n auto it = DP.find(mask);\n if (it != DP.end())\n {\n return it->second;\n }\n bool used[30];\n fill(used, used + 30, false);\n for (int i = 0; i < 29; ++i)\n {\n if ((mask >> i) & 1)\n {\n int newMask = mask;\n for (int j = (i + 1); j <= 29; j += (i + 1))\n {\n if ((mask >> (j - 1)) & 1)\n {\n newMask ^= (1 << (j - 1));\n }\n }\n used[calcGrundy(newMask)] = true;\n }\n }\n int i;\n for (i = 0; used[i]; ++i);\n DP.insert(mp(mask, i));\n return i;\n}\n*/\n\nint g[30] = {0, 1, 2, 1, 4, 3, 2, 1, 5, 6, 2, 1, 8, 7, 5, 9, 8, 7, 3, 4, 7, 4, 2, 1, 10, 9, 3, 6, 11, 12};\n\nint main()\n{\n#ifdef harhro94\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n#endif\n\n /*\n DP.insert(mp(0, 0));\n DP.insert(mp(1, 1));\n for (int i = 1; i <= 29; ++i)\n {\n int now = calcGrundy((1 << i) - 1);\n cout << now << \", \";\n }\n */\n int n;\n cin >> n;\n set S;\n S.insert(1);\n int xor = 1;\n int sq = int(sqrt(n + 0.0) + 1e-6);\n for (int i = 2; i <= sq; ++i)\n {\n if (S.find(i) != S.end())\n {\n continue;\n }\n LL now = i;\n S.insert(now);\n int sz = 1;\n while (now * i <= n)\n {\n now *= i;\n S.insert(now);\n ++sz;\n }\n xor ^= g[sz];\n }\n int rest = n - sz(S);\n if (rest > 0 && (rest & 1))\n {\n xor ^= 1;\n }\n if (xor == 0)\n {\n cout << \"Petya\\n\";\n }\n else \n {\n cout << \"Vasya\\n\";\n }\n\n#ifdef harhro94\n cerr << fixed << setprecision(3) << \"\\nExecution time = \" << clock() / 1000.0 << \"s\\n\";\n#endif\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "738f3f990ba6b7aaba3d41d5a41afdb3", "src_uid": "0e22093668319217b7946e62afe32195", "difficulty": 2300.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef vector vi;\ntypedef vector > vvi;\ntypedef pair pii;\n\n#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)\n#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)\n#define all(v) ((v).begin()), ((v).end())\n#define sz(v) ((int)((v).size()))\n#define mod(n, m) ((n%m + m) % m)\n#define reset(n, m) memset(n, m, sizeof n)\n#define endl '\\n'\n\nint n, masks[31], target, length;\n//map memo;\n//\n//int solve(int mask)\n//{\n//\tif ((mask & target) == target) // terminal position\n//\t\treturn 0;\n//\n//\tif (memo.find(mask) != memo.end())\n//\t\treturn memo[mask];\n//\n//\tbitset<31> bs;\n//\n//\terep(i, 1, length)\n//\t{\n//\t\tif (mask & (1 << i))\n//\t\t\tcontinue;\n//\t\tint ret = solve(mask | masks[i]);\n//\t\tbs[ret] = true;\n//\t}\n//\n//\t// return mex of state\n//\terep(i, 0, 30)\n//\t\tif (!bs[i])\n//\t\t\treturn memo[mask] = i;\n//}\n\nint arr[] =\n{ 0, 1, 2, 1, 4, 3, 2, 1, 5, 6, 2, 1, 8, 7, 5, 9, 8, 7, 3, 4, 7, 4, 2, 1, 10, 9,\n\t\t3, 6, 11, 12, 14 };\n\nint main()\n{\n//\tios_base::sync_with_stdio(0);\n//\tcin.tie(0);\n\n\tcin >> n;\n//\terep(i, 1, 30)\n//\t\tfor (int j = i; j <= 30; j += i)\n//\t\t\tmasks[i] |= (1 << j);\n//\n//\terep(i, 2, 30)\n//\t{\n//\t\tmemo.clear();\n//\t\tlength = i;\n//\t\ttarget = (1 << (i + 1)) - 1; // set all bits from 0 to i by 1\n//\t\tcerr << solve(1) << \", \";\n//\t}\n\n\tint kollo = n;\n\n\tint sq = sqrt(n) + 5, ans = 0;\n\tbitset bs;\n\n\terep(i, 2, sq)\n\t{\n\t\tif (bs[i])\n\t\t\tcontinue;\n\t\tint cnt = 0;\n\t\tll temp = i;\n\t\twhile (temp <= 1ll * n)\n\t\t{\n\t\t\tcnt++;\n\t\t\tif (temp <= sq)\n\t\t\t\tbs[temp] = true;\n\t\t\ttemp <<= 1;\n\t\t\tkollo--;\n\t\t}\n\t\tans ^= arr[cnt];\n\t}\n\n\tif (kollo & 1)\n\t\tans ^= 1;\n\n\t// welad el 7ag mike\n\tif (ans)\n\t\tcout << \"Vasya\\n\";\n\telse\n\t\tcout << \"Petya\\n\";\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "53fd0c303a94e853cc346d9c6f3744dc", "src_uid": "0e22093668319217b7946e62afe32195", "difficulty": 2300.0} {"lang": "GNU C++", "source_code": "#include \nint main ()\n{\n long int n;\n cin >> n;\n cout << n/2+1;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fd52bd814fa8bb52e4c6059f18513431", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0} {"lang": "MS C++", "source_code": "int n;\nstd::sin >> n;\n\nint c = 1, a = n, r = 0;\nfor (int i = 2; i < n / 2; i++) {\n int b = a - 1;\n r += a;\n while (r < b) {\n b--;\n r+=a;\n }\n r-=b;\n c++;\n}\nstd::cout << c;", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a64814b425a50f147d966cf256fba6b5", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing nameapce std;\n\nint main() {\n long long x;\n cin >> x;\n cout << (x >> 1) + 1 << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5b93327aeb2bf2cf63225cb48441dbff", "src_uid": "5551742f6ab39fdac3930d866f439e3e", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main(){\n int n;\n cin<\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\nconst int N=205;\nconst int mod=1e9+7;\nint n,len,ot[2][N];\nint a[N],fail[N],dp[N][N][N];\nchar s[N];\n\nvoid inc(int &x,int y)\n{\n x+=y;\n if(x>=mod) x-=mod;\n}\n\nvoid init()\n{\n scanf(\"%d\",&n);int i;\n scanf(\"%s\",s+1);\n len=strlen(s+1);\n for(i=1;i<=len;++i) a[i]=(s[i]==')');\n}\n\nvoid prework()\n{\n int las=0,i;\n for(i=2;i<=len;++i)\n {\n while(las&&a[las+1]!=a[i]) las=fail[las];\n if(a[las+1]==a[i]) fail[i]=++las; \n }\n\n ot[a[1]][0]=1;\n for(i=1;i\nusing namespace std;\n\n#define ll long long\n\nint n, m, a[200][2], b[2]={1, -1};\nstring s;\nll dp1[201][201][200], dp2[201][201];\n\nint main() {\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n\t\n\tcin >> n >> s;\n\tn*=2;\n\tm=s.size();\n\tfor(int i=0; i=m)\n\t\t\t\t\t\tdp2[i+1][j+b[c]]+=dp1[i][j][k];\n\t\t\t\t\telse\n\t\t\t\t\t\tdp1[i+1][j+b[c]][a[k][c]]+=dp1[i][j][k];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor(int i=0; i\n\n#define ll long long\n#define ld long double\n#define endl \"\\n\"\n#define fi first\n#define se second\n#define y1 sadjfskldf\n#define sqr(asdf) ((asdf) * (asdf))\nusing namespace std;\n\nconst ll N = 105;\nconst ll MOD = 1000000007;\nstring s;\nll a[N],n,dp[2 * N][N][N],kol,len;\nvector z(N + 2);\nvoid z_function()\n{\n z[0] = 1e9;\n for (int i=1, l=0, r=0; i < len; ++i)\n {\n\t\tif (i <= r) z[i] = min (r-i+1, z[i-l]);\n\t\twhile (i+z[i] < len && s[z[i]] == s[i+z[i]]) z[i]++;\n\t\tif (i+z[i]-1 > r) l = i, r = i+z[i]-1;\n\t}\n}\nint main(){\n ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n cin>>n>>s;\n len = s.size();\n for(int i = 1; i <= len; i++) a[i] = (s[i - 1] == '(' ? 1 : - 1);\n dp[0][0][0] = 1;\n z_function();\n for(int i = 1; i <= 2 * n; i++)\n for(int j = 0; j <= 101; j++)\n for(int pos = 0; pos <= len; pos++) if(dp[i - 1][j][pos] > 0)\n for(int now = -1; now <= 1; now++) if(now && now + j >= 0)\n {\n kol = dp[i - 1][j][pos];\n if(pos == len) dp[i][now + j][len] = (dp[i][now + j][len] + kol) % MOD;\n else\n if(now == a[pos + 1]) dp[i][now + j][pos + 1] = (dp[i][now + j][pos + 1] + kol) % MOD;\n else\n for(int r = pos; r >= 0; r--)\n {\n if ((r == 0) || (r == 1 && a[r] == now) || (a[r] == now && z[pos - r + 1] >= r - 1))\n {\n dp[i][j + now][r] = (dp[i][j + now][r] + kol) % MOD;\n break;\n }\n }\n }\n cout<\n#define inc(i,l,r) for(int i=l;i<=r;i++)\n#define dec(i,l,r) for(int i=l;i>=r;i--)\n#define link(x) for(edge *j=h[x];j;j=j->next)\n#define mem(a) memset(a,0,sizeof(a))\n#define ll long long\n#define eps 1e-8\n#define succ(x) (1LL<<(x))\n#define lowbit(x) (x&(-x))\n#define sqr(x) ((x)*(x))\n#define mid (x+y>>1)\n#define NM 205\n#define nm 100005\n#define N 1000005\n#define M(x,y) x=max(x,y)\nconst double pi=acos(-1);\nconst ll inf=1e9+7;\nusing namespace std;\nll read(){\n ll x=0,f=1;char ch=getchar();\n while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}\n while(isdigit(ch))x=x*10+ch-'0',ch=getchar();\n return f*x;\n}\nint n,m,c[NM][2];\nll d[NM][NM][NM],f[NM][NM],ans;\nchar s[NM];\n \nint main(){\n n=read()*2;scanf(\"%s\",s+1);m=strlen(s+1);\n if(s[1]=='(')c[0][1]++;else c[0][0]++;\n inc(i,1,m-1)if(s[i+1]=='('){\n\tc[i][1]=i+1;\n\tdec(j,i,1)if(s[j]==')'){\n\t bool f=true;\n\t inc(k,1,j-1)if(s[k]!=s[k+i-j+1]){f=false;break;}\n\t if(f){c[i][0]=j;break;}\n\t}\n }else{\n\tc[i][0]=i+1;\n dec(j,i,1)if(s[j]=='('){\n\t bool f=true;\n\t inc(k,1,j-1)if(s[k]!=s[k+i-j+1]){f=false;break;}\n\t if(f){c[i][1]=j;break;}\n\t}\n }\n \n d[0][0][0]=1;\n inc(i,1,n){\n\tinc(j,0,n)inc(k,0,m-1)if(d[i-1][j][k]){\n\t (d[i][j+1][c[k][1]]+=d[i-1][j][k])%=inf;\n\t if(j)(d[i][j-1][c[k][0]]+=d[i-1][j][k])%=inf;\n\t}\n }\n f[0][0]=1;\n inc(i,1,n)inc(j,0,n){\n\t(f[i][j+1]+=f[i-1][j])%=inf;\n\tif(j)(f[i][j-1]+=f[i-1][j])%=inf;\n }\n ans=f[n][0];\n inc(i,0,m-1)ans=(ans-d[n][0][i]+inf)%inf;\n return 0*printf(\"%I64d\\n\",ans);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c3d5776a6c5a628c927feade4a6601f2", "src_uid": "590a49a7af0eb83376ed911ed488d7e5", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#define FOR(i, l, r) for(int i = l; i <= r; ++i)\n\nusing namespace std;\n\nlong long n, k, ans, d[5], c[1010][5];\n\nint main()\n{\n\tscanf(\"%lld%lld\", &n, &k);\n\tFOR(i, 0, n)\n\t{\n\t\tc[i][0] = 1;\n\t\tFOR(j, 1, min(i, k)) c[i][j] = c[i - 1][j - 1] + c[i - 1][j];\n\t}\n\td[2] = 1; d[3] = 2; d[4] = 9;\n\tFOR(i, 2, k) ans += c[n][i] * d[i];\n\tprintf(\"%lld\\n\", ans + 1);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "659747aafa7d5cd06f5ceeec9b7eff7b", "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint main()\n{\n cin >> n >> k;\n if(k==1)\n cout << \"1\" << endl;\n if(k==2)\n cout << 1 + (n*(n-1)/2) << endl;\n if(k==3)\n cout << 1 + (n*(n-1)/2) + (2*n*(n-1)*(n-2)/6) << endl;\n if(k==4)\n cout << 1 + (n*(n-2)/2) + (2*n*(n-1)*(n-2)/6) + (9*n*(n-1)*(n-2)*(n-3)/24) << endl;\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "35dfc823c73afb5ffbf8d053cf252a49", "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include\ntypedef ll long long\nusing namespace std;\n\nint main()\n{\n ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);\n ll n,k,ans;\n cin>>n>>k;\n if(k==1)\n cout<<\"1\\n\";\n else if(k==2)\n {\n ans = (n*(n-1))/2 + 1;\n cout<\n\nusing namespace std;\n\nint f[]={0, 0, 1, 2, 9}\n///n!/k!*(n-k)! == (n-k)*......\nint n_cate_k(int n,int k)\n{\n int t1 = 1, t2 = 1;\n for(int i = 1; i <= k; i++)\n {\n t1*=(n - i + 1);\n t2*=i;\n }\n return t1/t2;\n}\nint main()\n{\n int n,k,sol=0;\n scanf(\"%d%d\",&n,&k)\n for(int i = 0; i <= k; i++)\n ans+=n_cate_k(n,i)*f[i];\n printf(\"%d\",ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "dec2db9a2b42780b0f1d87121c989f20", "src_uid": "96d839dc2d038f8ae95fc47c217b2e2f", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "\nusing namespace std;\n\nlong long gcd(long long a,long long b){\n if(a==0)return b;\n long long g=gcd(b%a,a);\n return g;\n}\n\nint main(){\n long long w,h,count=0,t1,t2;\n long long a,b,x,y;\n cin>>a>>b>>x>>y;\n\n w=x,h=y;\n if(x>y)\n {t1=y,t2=x;}\n else{\n t1=x,t2=y;}\n\n long long int i=2;\n long long g=gcd(t1,t2);\n w=x/g;\n h=y/g;\n//Simplest form\nif((w>a && h>b)||(w>a && hb))\ncout<<\"0\"<\nusing namespace std;\n\nlong long gcd(long long a, long long b) {\n //cout<>a>>b>>x>>y;\n if(x>y)\n swap(x,y);\n long long lcm = gcd(y,x);\n x/=lcm;\n y/=lcm;\n cout<\nusing namespace std;\nint main(){\n \n int a,b,x,y;\n cin>>a>>b>>x>>y;\n int w=x,h=y;\n int x=__gcd(w,h);\n w=w/x;\n h=h/x;\n int i=1;\n int count=0;\n while(w<=a && h<=b){\n w=w*i;\n h=h*i;\n i++;\n count++;\n }\n cout<\n#define MIN -10000000\n#define MAX 10000000\n#define debug printf(\"%d\",__LINE__)\nusing namespace std;\nint main()\n{\n\tlong long a, b, x, y;\n\tscanf(\"%lld%lld%lld%lld\", &a, &b, &x, &y);\n\tint s = x, x /= __gcd(x, y), y /= __gcd(s, y);\n\tprintf(\"%lld\", min(a / x, b / y));\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1420ecd36c9a911a01bfa3ba58eff6f5", "src_uid": "907ac56260e84dbb6d98a271bcb2d62d", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "# include \n\nusing namespace std;\ntypedef long long LL;\ntypedef pair pii;\ntypedef unsigned long long ull;\nconst int MAXN = 200000;\nint n, m, rt[MAXN+10], Q;\npii a[MAXN+10];\nstruct Seg_Tree {\n\tstatic const int N = 8000000 + 10;\n\tstatic const int T = MAXN + 3;\n\tint ncnt;\n\tull t[N];\n\tinline void calc_s(const bool &nl, const bool &nr, ull x, int &ls, int &rs, int &tag) {\n\t\tint s = x % T;\n\t\tls = x / T / N; rs = x / T % N;\n\t\ttag = s - min((nl ? ls : t[ls] % T), (nr ? rs : t[rs] % T));\n\t}\n\tinline ull calc(const int &ls, const int &rs, const int &val) {\n\t\treturn (1ull * ls * N + rs) * T + val;\n\t}\n\tvoid ins(const int &last, int &u, const int &L, const int &R, const int &l, const int &r) {\n\t\tif(L == R) {\n\t\t\tu = last+1;\n\t\t\treturn ;\n\t\t}\n\t\tt[u = ++ncnt] = t[last];\n\t\tif(l <= L && R <= r) {\n\t\t\tt[u]++;\n\t\t\treturn ;\n\t\t}\n\t\tint mid = (L+R) >> 1, ls, rs, val, lson = 0, rson = 0;\n\t\tcalc_s((L == mid), (R == mid+1), t[u], ls, rs, val);\n\t\tif(l <= mid) ins(ls, lson, L, mid, l, r);\n\t\tif(r > mid) ins(rs, rson, mid+1, R, l, r);\n\t\tif(!lson) lson = ls;\n\t\tif(!rson) rson = rs;\n\t\tval += min(((L == mid) ? lson : t[lson] % T), ((R == mid+1) ? rson : t[rson] % T));\n\t\tt[u] = calc(lson, rson, val);\n\t}\n\tint query(const int &u, const int &L, const int &R, const int &l, const int &r) {\n\t\tif(L == R) return u;\n\t\tif(!u) return 0;\n\t\tif(l <= L && R <= r) return t[u] % T;\n\t\tint mid = (L+R) >> 1, ls, rs, val, ret = N;\n\t\tcalc_s((L == mid), (mid+1 == R), t[u], ls, rs, val);\n\t\tif(l <= mid) ret = min(ret, query(ls, L, mid, l, r));\n\t\tif(r > mid) ret = min(ret, query(rs, mid+1, R, l, r));\n\t\treturn ret + val;\n\t}\n\tinline void build() {\n\t\tfor(int i = 1; i <= n; i++)\n\t\t\tins(rt[i-1], rt[i], 1, n-m+1, max(1, a[i].sec-m+1), a[i].sec);\n\t}\n} seg;\nint main() {\n\tSF(\"%d%d\", &n, &m);\n\tfor(int i = 1; i <= n; i++) SF(\"%d\", &a[i].fir), a[i].sec = i;\n\tsort(a+1, a+1+n);\n\tseg.build();\n\tSF(\"%d\", &Q);\n\tint ans = 0;\n\tfor(int i = 1; i <= Q; i++) {\n\t\tint x, l, r;\n\t\tSF(\"%d%d%d\", &l, &r, &x);\n\t\tx ^= ans;\n\t\tx = lower_bound(a+1, a+1+n, mp(x, 0)) - a;\n\t\tif(x == 1) ans = 0;\n\t\telse ans = seg.query(rt[x-1], 1, n-m+1, l, r);\n\t\tPF(\"%d\\n\", ans);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cd5c9bc58ce730c776b666d1ed063b04", "src_uid": "92c773d61414ec6a13cdfbdcd24a2b0d", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#define RG register\n#define file(x) freopen(#x\".in\", \"r\", stdin);freopen(#x\".out\", \"w\", stdout);\n#define clear(x, y) memset(x, y, sizeof(x))\n\ninline int read()\n{\n\tint data = 0, w = 1; char ch = getchar();\n\twhile(ch != '-' && (!isdigit(ch))) ch = getchar();\n\tif(ch == '-') w = -1, ch = getchar();\n\twhile(isdigit(ch)) data = data * 10 + (ch ^ 48), ch = getchar();\n\treturn data * w;\n}\n\nconst int maxn(2e5 + 10), INT_MAX(1e9);\n#define lmax (l == mid ? int(t[rt].lson) : int(t[t[rt].lson].max))\n#define rmax (mid + 1 == r ? int(t[rt].rson) : int(t[t[rt].rson].max))\n\nstruct node { unsigned long long max : 18, lson : 23, rson : 23; } t[maxn * 40];\nint cur, root[maxn], n, m, Q;\nstd::pair a[maxn];\n\nint Insert(int p, int l, int r, int ql, int qr)\n{\n\tif(l == r) return p + 1;\n\tint rt = ++cur; t[rt] = t[p];\n\tif(ql <= l && r <= qr) return ++t[rt].max, rt;\n\tint mid = (l + r) >> 1, tag = t[rt].max - std::max(lmax, rmax);\n\tif(ql <= mid) t[rt].lson = Insert(t[p].lson, l, mid, ql, qr);\n\tif(qr > mid) t[rt].rson = Insert(t[p].rson, mid + 1, r, ql, qr);\n\tt[rt].max = std::max(lmax, rmax) + tag; return rt;\n}\n\nint query(int rt, int l, int r, int ql, int qr)\n{\n\tif(l == r) return rt;\n\tif(ql <= l && r <= qr) return t[rt].max;\n\tint mid = (l + r) >> 1, ans = 0, tag = t[rt].max - std::max(lmax, rmax);\n\tif(ql <= mid) ans = std::max(ans, query(t[rt].lson, l, mid, ql, qr));\n\tif(qr > mid) ans = std::max(ans, query(t[rt].rson, mid + 1, r, ql, qr));\n\treturn ans + tag;\n}\n\nint main()\n{\n#ifndef ONLINE_JUDGE\n\tfile(cpp);\n#endif\n\tn = read(), m = read();\n\tfor(RG int i = 1; i <= n; i++) a[i] = std::make_pair(-read(), i);\n\tstd::sort(a + 1, a + n + 1);\n\tfor(RG int i = 1; i <= n; i++)\n\t{\n\t\tint ql = std::max(1, a[i].second - m + 1);\n\t\tint qr = std::min(a[i].second, n - m + 1);\n\t\troot[i] = Insert(root[i - 1], 1, n - m + 1, ql, qr);\n\t}\n\tQ = read(); int ans = 0;\n\twhile(Q--)\n\t{\n\t\tint l = read(), r = read(), x = read() ^ ans;\n\t\tint id = std::upper_bound(a + 1, a + n + 1,\n\t\t\t\tstd::make_pair(-x, INT_MAX)) - a - 1;\n\t\tprintf(\"%d\\n\", ans = m - query(root[id], 1, n - m + 1, l, r));\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8c766314233a051943ca7b9f0f860e08", "src_uid": "92c773d61414ec6a13cdfbdcd24a2b0d", "difficulty": 3200.0} {"lang": "GNU C++", "source_code": "#include\n#include\n\n#define REP(i,m) for(int i=0;i<(m);++i)\n#define REPN(i,m,in) for(int i=(in);i<(m);++i)\n#define ALL(t) (t).begin(),(t).end()\n#define CLR(a) memset((a),0,sizeof(a))\n#define pb push_back\n#define mp make_pair\n#define fr first\n#define sc second\n\nusing namespace std;\n\n\n#ifndef ONLINE_JUDGE\n#define dump(x) cerr << #x << \" = \" << (x) << endl\n#define prl cerr<<\"called:\"<< __LINE__< void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr< void debug(T a,T b){ ;}\n#endif\n\n\nlint readL(){\n lint res;\n#ifdef ONLINE_JUDGE\n scanf(\"%I64d\",&res);\n#else\n scanf(\"%lld\",&res);\n#endif\n return res;\n}\nvoid printL(lint res){\n#ifdef ONLINE_JUDGE\n printf(\"%I64d\",res);\n#else\n printf(\"%lld\",res);\n#endif\n}\ntypedef unsigned int uint;\nconst int INF=(1<<18)-1;\nconst int nullidx=7900000;\n\nint cnt;\n\n#define mn(i) (i==nullidx?0:pool[i].mini)\nstruct node{\n unsigned long long lch:23,rch:23,mini:18;\n int copy();\n node(){\n lch=rch=nullidx;\n }\n void add(int,int,int,int,int);\n int query(int,int,int,int);\n int getbase();\n};\nnode pool[7900005];\n\n\nint node::copy(){\n pool[cnt]=*this;\n return cnt++;\n}\nint node::getbase(){\n return mini-min(mn(lch),mn(rch));\n}\nvoid node::add(int a,int b,int l,int r,int v){\n if(a<=l && r<=b){\n mini+=v;\n return;\n }\n int md=(l+r)>>1;\n int base=getbase();\n if(l>1;\n int res=INF,base=getbase();\n if(l\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nconst int N = 200010;\n#define x first\n#define y second\nunsigned long long a[N * 40 + 50000];\nconst int b18 = (1 << 18) - 1;\nconst int b23 = (1 << 23) - 1;\nint cnt;\n\nvoid update(int &x, int y, int l, int r, int L, int R) {\n\tx = ++cnt;\n\tint rc = a[y] & b23;\n\tint lc = (a[y] >> 23) & b23;\n\tunsigned long long mx = a[y] >> 46;\n\tif (l == L && r == R) {\n\t\tmx++;\n\t\ta[x] = (mx << 46) | ((unsigned long long)lc << 23) | rc;\n\t return;\n\t}\n\n int mid = (l + r) >> 1;\t\n int lazy = mx - max(a[lc] >> 46, a[rc] >> 46);\n\tif (R <= mid) update(lc, lc, l, mid, L, R);\n\telse if (L > mid) update(rc, rc, mid + 1, r, L, R);\n\telse {\n\t\tupdate(lc, lc, l, mid, L, mid);\n\t\tupdate(rc, rc, mid + 1, r, mid + 1, R);\n\t}\n\n\tmx = max(a[lc] >> 46, a[rc] >> 46);\n\tmx += lazy;\n\ta[x] = (mx << 46) | ((unsigned long long)lc << 23) | (unsigned long long)rc;\n}\n\nint query(int x, int l, int r, int L, int R) {\n\tint rc = a[x] & b23;\n\tint lc = (a[x] >> 23) & b23;\n\tint mx = a[x] >> 46;\n\tif (l == L && R == r) {\n\t\treturn mx;\n\t}\n\n\tint mid = (l + r) >> 1;\n\tint lazy = mx - max(a[lc] >> 46, a[rc] >> 46);\n\tif (R <= mid) return lazy + query(lc, l, mid, L, R);\n\tif (L > mid) return lazy + query(rc, mid + 1, r, L, R);\n\treturn lazy + max(query(lc, l, mid, L, mid), query(rc, mid + 1, r, mid + 1, R));\n}\n\npair pi[N];\n\nint main()\n{\n\tint n, m;\n\tscanf(\"%d%d\", &n, &m);\n\tfor (int i = 1; i <= n; i++) {\n\t scanf(\"%d\", &pi[i].x);\n\t\tpi[i].y = i;\n\t}\n\n\tsort(pi + 1, pi + n + 1);\n\tfor (int i = n; i >= 1; i--) {\n\t\tint l = max(1, pi[i].y - m + 1);\n\t\tint r = min(n - m + 1, pi[i].y);\n\t\tupdate(pi[i].y, pi[i + 1].y, 1, n - m + 1, l, r);\n\t}\n\n\tint q;\n\tscanf(\"%d\", &q);\n\tint ans = 0;\n\twhile (q--) {\n\t\tint l, r, x;\n\t\tscanf(\"%d%d%d\", &l, &r, &x);\n\t\tx ^= ans;\n\t\tif (x <= pi[1].x) {\n\t\t\tans = 0;\n\t\t} else if (x > pi[n].x) {\n\t\t\tans = m;\n\t\t} else {\n\t\t\tint lt = 1, rt = n, mid, pos;\n\t\t\twhile (lt <= rt) {\n\t\t\t\tmid = (lt + rt) >> 1;\n\t\t\t\tif (pi[mid].x >= x) {\n\t\t\t\t\tpos = mid;\n\t\t\t\t\trt = mid - 1;\n\t\t\t\t} else lt = mid + 1;\n\t\t\t}\n\n\t\t\tans = m - query(pi[pos]oy, 1, n - m + 1, l, r);\n\t\t}\n\t\tprintf(\"%d\\n\", ans);\n\t}\n\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "860e76b0cb3fafc8319d5e0107d2d9e2", "src_uid": "92c773d61414ec6a13cdfbdcd24a2b0d", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#include\n\n#define Write freopen(\"out.txt\",\"w\",stdout)\n#define Read freopen(\"in.txt\",\"r\",stdin)\n\n#define si(a) scanf(\"%d\",&a)\n#define sii(a,b) scanf(\"%d %d\",&a,&b)\n#define siii(a,b,c) scanf(\"%d %d %d\",&a,&b,&c)\n#define sl(a) scanf(\"%lld\",&a)\n#define sll(a,b) scanf(\"%lld %lld\",&a,&b)\n#define slll(a,b,c) scanf(\"%lld %lld %lld\",&a,&b,&c)\n\n#define lli long long\n#define m_p make_pair\n#define p_b push_back\n\n\n#define lim 10000000\n#define mod 100007\n#define mx 100004\n#define PI 3.141592654\nusing namespace std;\n\n/*** Direction Array ***/\n//int dirx[]= {1,0,-1,0};\n//int diry[]= {0,1,0,-1};\n\n/**** Translator Functions***/\n//int ToInt(string s){int r = 0;stringstream sin(s);sin >> r;return r;}\n//double ToDouble(string s) { double r = 0; stringstream sin(s); sin >> r; return r; }\n//string ToString(int n) { string s; stringstream convert;convert << n;s = convert.str();return s;}\n\n/*****My code goes from here****/\nusing namespace std;\nbool flag[1000000+5];\nint primes[1000000+5];\n\nint seive()\n{\n int i,j,total=0,val;\n int Max=1000000;\n\n for(i=2; i<=Max; i++) flag[i]=1;\n\n val=sqrt(Max)+1;\n\n for(i=2; i>a>>b;\n for(int i=b; i>=a+1; i--)\n {\n int p=0;\n int xx=i;\n int pp=100000000;\n while(xx!=1&&primes[p]<=xx&&p\nusing namespace std;\nint main(){\n long long y,p;\n int count;\n scanf(\"%lld%lld\",&p,&p);\n for(long long i=y;i>=2;i--){\n count=0;\n for(long long j=2;j*j<=i;j++){\n if(i%j==0){\n count++;\n if(j>p)\n {\n printf(\"%lld\",i);\n return 0;\n }\n }\n }\n if(count==0&&i>p){\n printf(\"%lld\",i);\n return 0;\n }\n }\n prinntf(\"-1\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6831c11996ff9292bf35df8bba741cbc", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "difficulty": 1400.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main(){\n long long y,p;\n bool flag=1;\n cin>>p>>y;\n for(long long i=y;>p;i--){\n for(long long j=2;flag&&j*j<=i;j++){\n if(i%j==0)\n flag=0;\n }\n if(flag){\n cout<\n\nusing namespace std;\n\nconst int MaxN=1e6;\n//int a[MaxN];\n\nint main()\n{\n int n, y;\n cin >> y >> n;\n vector prime (MaxN + 1, true);\n prime[0] = prime[1] = false;\n for (int i = 2; i <= y; i+=2)\n if (prime[i])\n for (int j = i; j <= i*y1; j += i)\n prime[j] = false;\n\n for(int i=n; i>=2; i--)\n if(prime[i]==true) {cout << i << endl; exit(0);}\n\n cout << -1 << endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e2d94d4a2fe69a2c9384ac983aeb53e0", "src_uid": "b533203f488fa4caf105f3f46dd5844d", "difficulty": 1400.0} {"lang": "GNU C++0x", "source_code": "//\n// main.cpp\n// tower\n//\n// Created by \u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0430 \u0412\u0438\u0448\u043d\u0435\u0432\u0441\u043a\u0430\u044f on 21.11.14.\n// Copyright (c) 2014 \u0415\u043a\u0430\u0442\u0435\u0440\u0438\u043d\u0430 \u0412\u0438\u0448\u043d\u0435\u0432\u0441\u043a\u0430\u044f. All rights reserved.\n//\n\n#include \n\nint main() {\n int a;\n scanf(\"%d\", &a);\n int i=0;\n while(0==0){\n i++;\n int t=a+i;\n while (t>0) {\n int r=t%10;\n t=t/10;\n if (r==8) {\n printf(\"%d\", i);\n return 0;\n }\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d90c70564d5271989a43805556757aa6", "src_uid": "4e57740be015963c190e0bfe1ab74cb9", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\n\nvoid main()\n{\n long int a, difference = 0, b = 0;\n bool flag = true;\n cin >> a;\n if(a < 0)\n {\n a = 0;\n difference += -a;\n }\n while(flag)\n {\n if (to_string(b).find('8') != std::string::npos)\n {\n flag = false;\n }\n else\n b++;\n }\n b += difference;\n cout << b;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ca6087fdb141badfbc6557db271e2ea1", "src_uid": "4e57740be015963c190e0bfe1ab74cb9", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include\n\nusing namespace std;\n\n#define int long long\n\nbool isok(int n){\n\twhile(n){\n\t\tif(n%10 == 8)\n\t\t\treturn true;\n\t\tn /= 10;\n\t}\n\treturn false;\n}\n\nint32_t main(){\n\tint input;\n\tcin >> input;\n\tinput = abs(input);\n\tfor(int cnt = 1 ; cnt <= 10 ; cnt++){\n\t\tisok(input+cnt);\n\t\tif(isok == true){\n\t\t\tcout << cnt;\n\t\t\treturn 0;\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3a2a5d4a7cc1156296362930c653db96", "src_uid": "4e57740be015963c190e0bfe1ab74cb9", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\n\nint main()\n{\n long long n;\n cin >> n;\n int dig = 1 + floor(log10(n));\n bool flag = false;\n int count = 0;\n while (true)\n {\n ++n;\n ++count;\n int ch = dig;\n for (long long i = 10; i <= 10000000000 && ch; i*=10)\n {\n --ch;\n if (abs(n%i) == 8 * i / 10)\n {\n flag = true;\n break;\n }\n }\n if (flag)\n {\n break;\n }\n }\n cout << count << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "708cfca088db9290ee8ff6cb6cf4a620", "src_uid": "4e57740be015963c190e0bfe1ab74cb9", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n int n,k;\n cin>>n;\n cin>>k;\n int i=n;\n int count=0,s=0;\n int d=0,w=0;\n int flag=0;\n \n while(i>0)\n {\n d++;\n i=i/10;\n }\n if(n==0)\n cout<<0;\n else{\n \n w=0;\n while(n>0)\n {\n s=n%10;\n if(s==0)\n {\n count++;\n }\n else \n w++;\n if(c==k)\n {flag=1;\n break;\n }\n n=n/10;\n }\n if(flag==1)\n cout<\nusing namespace std;\nint main(int argc, const char * argv[]) {\n int n,k;\n cin>>n>>k;\n int dight,temp=n,zero=0;\n int a[15];\n memset(a,0,sizeof(a));\n for(dight=0;temp>0;dight++)//get the dights the number is;\n {\n if(!(temp%10))\n {\n zero++;\n a[dight]=1;\n }\n temp/=10;\n }\n //for(int i=0;i=dight)||(zero\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define forn(i,n) for(int (i)=0;i<(int)(n);++i)\n#define fora(i,a, n) for (int (i) = (a); i < (int)(n); i++)\n#define NO std::cout<<\"NO\"\n#define YES std::cout<<\"YES\"\nusing namespace std;\nconst int INF = 2147483647;\ntypedef long long ll;\ntypedef pair pii;\ntypedef vectorvi;\ntypedef vectorvvi;\nconst string no = \"NO\", yes = \"YES\";\nvoid solve();\nvoid testcase();\nll Eps(int kol)\n{\n ll a = 1;\n forn(i, kol)\n a *= 10;\n return a;\n}\nll gcd(ll a, ll b)\n{\n if (b == 0) return a;\n else return gcd(b, a % b);\n}\nint main()\n{\n ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#ifndef ONLINE_JUDGE\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n#endif\n solve();\n#ifndef ONLINE_JUDGE\n testcase();\n#endif\n return 0;\n}\n\nvoid testcase() {\n cout << \"\\nTime elapsed: \" << clock() / 1000 << \" ms\" << endl;\n}\n\n\nvoid solve()\n{\n ll n, k, e;\n cin >> n >> k;\n e = pow(10.0, double(k));\n vi num;\n ll bu = n;\n while (bu>0)\n {\n ll fr = bu % 10;\n num.push_back(fr);\n bu /= 10;\n }\n int step = 0;\n\n if (e>n)\n {\n cout << num.size() - 1;\n return;\n }\n\n while (n%e != 0)\n {\n ll asd = 0;\n ll pw = 1;\n for (int i = 0; i\nusing namespace std;\nint main(){\nlong long k;\nstring s;\ncin>>s>>k;\nlong long cnt=0;\nlong long flag=0;\nlong long len = s.size()-1;\nlong long temp = len+1;\nif(s=='0'){\n cout<<0<=0 ;len--){\n if(s[len] == '0'){\n cnt++;\n }\n else{\n flag++;\n }\n if(cnt>=k){\n cout<cnt){\n cout<\nusing namespace std;\nint a, i;\nint main()\n{\n cin >> a;\n for(i=1; i<=sqrt(n); i++)\n if (n%i==0) cout << i;\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "37991af325f4a00637d38f5a96b42b4d", "src_uid": "7220f2da5081547a12118595bbeda4f6", "difficulty": null} {"lang": "GNU C++17", "source_code": "//~#pragma GCC optimize(\"Ofast\",\"unroll-loops\",\"omit-frame-pointer\",\"inline\") //Optimization flags\n//~#pragma GCC option(\"arch=native\",\"tune=native\",\"no-zero-upper\") //Enable AVX\n//~#pragma GCC target(\"avx2\") //Enable AVX\n#include\nusing namespace std;\n \n#define all(a) begin(a),end(a)\n#define F first\n#define S second\n#define pb push_back\n#define mp make_pair\ntypedef long long ll;\ntypedef vector vi;\ntypedef pair pi;\n \n#ifdef LOCAL\n#include \"debug.h\"\n#else\n#define debug(...) 42\n#endif\n \nconst int mod=998244353;\n \nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n \nint mul(int a,int b){\n return ((a)*1ll*(b))%mod;\n}\n \nvoid add(int &a,int b){\n a+=b;\n if(a>=mod)a-=mod;\n}\n \nint sub(int a,int b){\n a-=b;\n if(a<0){\n a+=mod;\n }\n return a;\n}\n \nint powz(int a,int b){\n int res=1;\n while(b){\n if(b&1){\n res=mul(res,a);\n }\n b/=2;\n a=mul(a,a);\n }\n return res;\n}\n \ntemplate \nistream& operator>>(istream& input,pair& x) {\n input>>x.F>>x.S;\n return input;\n}\n \ntemplate \nistream& operator>>(istream& input,vector& x) {\n for(auto& i:x)\n input>>i;\n return input;\n}\n \ntemplate\nostream& operator<<(ostream& output,vector& x) {\n for(auto& i:x)\n output<>n;\n\tcnt(n);\t\n}\n \n \nsigned main(){\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n int tc=1;\n //~cin>>tc;\n for(int _=0;_\nusing namespace std;\n \nint main()\n{\n int n;\n cin>>n;\n int num=n;\n for(int i=2;i\nusing namespace std;\nint main() {\n cin >> n;\n int a=sqrt(n);\n for(int i=a; i >= 1; --i) {\n if(n%i == 0) {\n cout << i << a/i;\n return 0;\n }\n }\n cout << 1 << n;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7fcff65680c087ad853dae0a700d20dc", "src_uid": "7220f2da5081547a12118595bbeda4f6", "difficulty": null} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint main()\n{\n\tstring s;\n\tcin>>s;\n\tchar cnt[5]={'N','R','B','Y','G'}\n\tint ans[4]={0,0,0,0};\n\tfor(int i=0;i> s;\n for(int i = 0; i < s.length(); i++)\n {\n if (s[i]== '!')\n a[i%4] += 1;\n else\n t[i%4] = s[i];\n }\n for(int i = 0; i <4; i++)\n if (t[i] = \"R\")\n cout << a[i] << ' ';\n for(int i = 0; i <4; i++)\n if (t[i] = \"B\")\n cout << a[i] << ' ';\n for(int i = 0; i <4; i++)\n if (t[i] = \"Y\")\n cout << a[i] << ' ';\n for(int i = 0; i <4; i++)\n if (t[i] = \"G\")\n cout << a[i];\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "12df907ab622e7adccb3289acbf31393", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "\n\n#include \n#include \n#include \n#include \nusing namespace std;\n\nint main() {\n string garlands;\n cin >> garlands;\n \n int R = 0, B = 0, Y = 0, G = 0;\n int Rp = 0, Bp = 0, Yp = 0, Gp = 0;\n \n for (int i = 0; i < garlands.length(); i++) {\n if (garlands.at(i) == 'R')\n Rp = i%4;\n else if (garlands.at(i) == 'B')\n Bp = i%4;\n else if (garlands.at(i) == 'Y')\n Yp = i%4;\n else if (garlands.at(i) == 'G')\n Gp = i%4;\n \n if ((Rp + Bp + Yp + Gp) == 6)\n break;\n }\n \n for (int j = 0; j < garlands.length(); j++) {\n if(garlands.at(j) == '!') {\n if (j%4 == Rp)\n R++;\n else if(j%4 == Bp)\n B++;\n else if (j%4 == Yp)\n Y++;\n else\n G++;\n }\n \n }\n \n cout << R << \" \" << B << \" \" << Y << \" \" << G;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6b9574da5c09a9ff6970d3504de37990", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "difficulty": 1100.0} {"lang": "Clang++17 Diagnostics", "source_code": "#include \n#include \n\nusing namespace std;\n\nlight convertLight(char c);\nenum light {R = 1, B = 2, Y = 3, G = 4};\n\nint main() {\n string strip; \n vector lights;\n int RD = 0, BD = 0, YD = 0, GD = 0;\n int sectionSum = 0;\n \n getline(cin, strip);\n \n for(int i = 0; i < strip.length(); i++){\n sectionSum += strip[i];\n \n if((i + 1) % 4 == 0){\n lights.push_back(10 - sectionSum);\n sectionSum = 0;\n }\n }\n \n for(int section : lights){\n switch(section){\n case R: \n RD++;\n break;\n case B:\n BD++;\n break;\n case Y:\n YD++;\n break;\n case G:\n GD++;\n break;\n }\n }\n \n printf(\"%d %d %d %d\", RD, BD, YD, GD);\n \n return 0;\n}\n\nlight convertLight(char c){\n if(c == 'R'){\n return R;\n } else if(c == 'B'){\n return B;\n } else if(c == 'Y'){\n return Y;\n } else if(c == 'G'){\n return G;\n }\n \n return R;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3e248856c23a1593929da55439b61b4e", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\nlong n,mas[200001],en(0);\n\nbool hak(int a){\n\tbool flag(0);\n\tint b,il(a+1);\n\twhile (mas[il] == 0 && il < n)\n\t\til++;\n\tif(mas[il] == 0)\n\t\tflag =1;\n\telse{\n\t\tb = mas[il];\n\t\twhile (mas[il] == b && il < n)\n\t\t\til++;\n\t\tmas[a] = mas[il-1];\n\t\tmas[il-1] = 0;\n\t\ten = en + 1;\n\t}\n\treturn flag;\n}\nint main(){\n\tcin.tie(0);\n\tios_base::sync_with_stdio(0);\n\tcin >> n;\n\tfor(int i(0); i < n; i++)\n\t\tcin >> mas[i];\n\tfor(int i(0); i < n; i++)\n\t\tif(mas[i] == 0)\n\t\t\tif (hak(i))\n\t\t\t\tbreak;\n\tcout << en;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e7b218ef5248474017c73a4ed830f084", "src_uid": "9135c7243431debb049f640e9600bc6e", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include\t\t\t\n\n#define pb push_back\n#define pp pop_back\n#define sz(a) (int)(a.size())\n#define mp make_pair\n#define F first\n#define S second\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef pair pii;\n\nconst int N = (int)1e6 + 123;\nconst ll INF = (ll)1e18 + 123;\nconst int inf = (int)1e9 + 123;\n\nint n, a[200111], cnt;\n//int kol[200111];\n\nint main() {\n\tscanf(\"%d\", &n);\n\tfor(int i = 1; i <= n; i ++){\n\t\tscanf(\"%d\", &a[i]);\n\t}\n\tfor(int i = 1; i <= n; i ++){\n\t\tif(a[i] == 0){\n\t\t\tint j = i + 1;\n\t\t\twhile((a[j] == a[j + 1] || !a[j]) && j < n) j ++;\n\t\t\tif(a[j] > 0){\n\t\t\t\tswap(a[i], a[j]);\n\t\t\t\tcnt ++;\n\t\t\t}else{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tcout << cnt;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "26fb996cefdef387987cbd070c33e252", "src_uid": "9135c7243431debb049f640e9600bc6e", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n#define DB(v) cerr << #v << ' ' << v << endl\n#define sz(v) int(v.size())\n\nvector num;\n\nint res = 0;\n\nvoid make(int l, int m, int r) {\n for(int i = l;i < m && r - (i - l) - 1 >= m; ++i) {\n swap(num[i], num[r - (i - l) - 1]);\n res++;\n }\n}\n\nint main()\n{\n ios::sync_with_stdio(NULL); cin.tie(NULL);\n //freopen(\"input.txt\",\"r\", stdin);\n int n; cin >> n;\n num.resize(n);\n for(int i = 0;i < n;++i) cin >> num[i];\n int l = 0;\n while(l < n){\n if(num[l] != 0) {\n l++;\n continue;\n }\n int m = l;\n while(m < n && num[m] == 0)\n m++;\n int r = m;\n while(r < n && num[r] == num[m])\n r++;\n make(l, m, r);\n l += max(min(r - m, m - l), 1);\n }\n cout << res;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c8f095d81209d477c3daac5f3bcf2d14", "src_uid": "9135c7243431debb049f640e9600bc6e", "difficulty": 1600.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\nlong n,mas[200001],en(0);\n\nbool hak(int a){\n\tbool flag(0);\n\tint b,il(a+1);\n\twhile (mas[il] == 0 && il < n)\n\t\til++;\n\tif(mas[il] == 0)\n\t\tflag =1;\n\telse{\n\t\tb = mas[il];\n\t\twhile (mas[il] == b && il < n)\n\t\t\til++;\n\t\tmas[a] = mas[il-1];\n\t\tmas[il-1] = 0;\n\t\ten = en + 1;\n\t}\n\treturn flag;\n}\nint main(){\n\t\n\tcin >> n;\n\tfor(int i(0); i < n; i++)\n\t\tcin >> mas[i];\n\tfor(int i(0); i < n; i++)\n\t\tif(mas[i] == 0)\n\t\t\tif (hak(i))\n\t\t\t\tbreak;\n\tcout << en;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "48ac44c90a33409209cddf69443f2fe2", "src_uid": "9135c7243431debb049f640e9600bc6e", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#pragma GCC optimize(2)\n#include\n#include\nusing namespace std;\nconst int N=6000,inf=1e9;\nstruct edge{\n int to,nxt,cap,cost;\n}e[(int)1e7];\nint n,cnt=1,head[N],T,iter[N],m,k,c,d,a[N],TT[55][120],nod;\nint dist[N],ans;\nbool vis[N];\nint q[1234567]; \ninline void addedge(int u,int v,int cost,int cap){\n e[++cnt]=(edge){v,head[u],cap,cost},head[u]=cnt;\n e[++cnt]=(edge){u,head[v],0,-cost},head[v]=cnt;\n}\nint dfs(int u,int f){\n if(u==T||!f)return f;\n vis[u]=1;\n int ret=0;\n for(int&i=iter[u];i;i=e[i].nxt)\n if(e[i].cap&&!vis[e[i].to]&&dist[e[i].to]==dist[u]+e[i].cost){\n int d=dfs(e[i].to,min(f,e[i].cap));\n e[i].cap-=d,e[i^1].cap+=d,f-=d,ret+=d;\n if(!f)break;\n }\n vis[u]=0;\n return ret;\n}\nbool MCMF(){\n for(int i=1;i<=T;++i)dist[i]=1e9+1;\n int h=1,t=1;q[1]=0;\n for(;h<=t;){\n int u=q[h++];\n vis[u]=0;\n for(int i=head[u];i;i=e[i].nxt)\n if(e[i].cap&&dist[e[i].to]>dist[u]+e[i].cost){\n dist[e[i].to]=dist[u]+e[i].cost;\n if(!vis[e[i].to])\n vis[e[i].to]=1,q[++t]=e[i].to;\n }\n }\n if(dist[T]>=1e9)return 0;\n memcpy(iter,head,sizeof(int)*(T+2));\n while(int f=dfs(0,inf))ans+=dist[T]*f;\n return 1;\n}\nint main(){\n ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);\n cin>>n>>m>>k>>c>>d;\n for(int i=1;i<=n;++i)\n for(int t=0;t<=101;++t)TT[i][t]=++nod;\n T=nod+5;\n for(int i=1;i<=k;++i)cin>>a[i],addedge(0,TT[a[i]][0],0,1);\n for(int t=1;t<=101;++t){\n for(int i=1;i<=n;++i)addedge(TT[i][t-1],TT[i][t],c,k);\n }\n while(m--){\n int u,v;\n cin>>u>>v;\n for(int t=0;t<101;++t)\n for(int i=1;i<=k;++i)addedge(TT[u][t],TT[v][t+1],c+d*(i*i-(i-1)*(i-1)),1),addedge(TT[v][t],TT[u][t+1],c+d*(i*i-(i-1)*(i-1)),1);\n }\n for(int t=0;t<=101;++t)addedge(TT[1][t],T,0,k);\n while(MCMF());\n cout<\nusing namespace std;\nusing i64=int_least64_t;\n\nnamespace std\n{\n // hash\n template size_t hash_combine(size_t seed, T const &key) { return seed ^ (hash()(key) + 0x9e3779b9 + (seed << 6) + (seed >> 2)); }\n template struct hash> { size_t operator()(pair const &pr) const { return hash_combine(hash_combine(0, pr.first), pr.second); } };\n template ::value - 1> struct tuple_hash_calc { static size_t apply(size_t seed, tuple_t const &t) { return hash_combine(tuple_hash_calc::apply(seed, t), get(t)); } };\n template struct tuple_hash_calc { static size_t apply(size_t seed, tuple_t const &t) { return hash_combine(seed, get<0>(t)); } };\n template struct hash> { size_t operator()(tuple const &t) const { return tuple_hash_calc>::apply(0, t); } };\n // iostream\n template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second; }\n template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second; }\n template struct tupleis { static istream &apply(istream &is, tuple_t &t) { tupleis::apply(is, t); return is >> get(t); } };\n template struct tupleis { static istream &apply(istream &is, tuple_t &t) { return is; } };\n template istream &operator>>(istream &is, tuple &t) { return tupleis, tuple_size>::value - 1>::apply(is, t); }\n template <> istream &operator>>(istream &is, tuple<> &t) { return is; }\n template struct tupleos { static ostream &apply(ostream &os, const tuple_t &t) { tupleos::apply(os, t); return os << ' ' << get(t); } };\n template struct tupleos { static ostream &apply(ostream &os, const tuple_t &t) { return os << get<0>(t); } };\n template ostream &operator<<(ostream &os, const tuple &t) { return tupleos, tuple_size>::value - 1>::apply(os, t); }\n template <> ostream &operator<<(ostream &os, const tuple<> &t) { return os; }\n template , string>::value, nullptr_t> = nullptr>\n istream& operator>>(istream& is, Container &cont) { for(auto&& e : cont) is >> e; return is; }\n template , string>::value, nullptr_t> = nullptr>\n ostream& operator<<(ostream& os, const Container &cont) { bool flag = 1; for(auto&& e : cont) flag ? flag = 0 : (os << ' ', 0), os << e; return os; }\n} // namespace std\n\n#include \n#include \n#include \n\n\n// Base class of flow algorithms\ntemplate \nstruct flow_base\n{\n class adj_type;\n\n class edge_t\n {\n friend flow_base;\n friend class adj_type;\n edge_t *link;\n friend void advance(edge_t* &ptr) { ptr = ptr->link; }\n public:\n size_t src, dst;\n cap_t cap; cost_t cost;\n edge_t *rev;\n edge_t() : link() {}\n edge_t(edge_t *link, const edge_t &edge) : edge_t(edge), link(link) {}\n edge_t(edge_t *link, size_t src, size_t dst, cap_t cap, cost_t cost, edge_t *rev)\n : link(link), src(src), dst(dst), cap(cap), cost(cost), rev(rev) {}\n }; // struct edge_t\n\n class adj_type\n {\n friend flow_base;\n edge_t *_head, *_next, *_last;\n size_t _len;\n\n template \n edge_t *emplace(Args&&... args)\n {\n if(_next == _last)\n {\n _len <<= 1;\n _next = new edge_t[_len];\n _last = _next + _len;\n }\n *_next = edge_t(_head, args...);\n _head = _next;\n ++_next;\n return _head;\n }\n\n public:\n adj_type() : _head(), _next(new edge_t[1]), _last(_next + 1), _len(1) {}\n ~adj_type()\n {\n --_last, --_len;\n for(edge_t *_p; _len; _last = _p, _len >>= 1)\n {\n _last -= _len;\n _p = _last->link;\n delete[] _last;\n }\n }\n\n class iterator\n {\n edge_t *ptr;\n public:\n iterator(edge_t *ptr = nullptr) : ptr(ptr) {}\n iterator operator++() { ptr = ptr->link; return *this; }\n bool operator!=(const iterator &other) const { return ptr != other.ptr; }\n edge_t &operator*() const { return *ptr; }\n };\n\n iterator begin() const { return iterator(_head); }\n iterator end() const { return iterator(); }\n };\n\nprotected:\n std::vector adjs;\n\npublic:\n flow_base(size_t _n = 0) : adjs(_n) {}\n\n flow_base(const flow_base& other) : adjs(other.size())\n {\n for(size_t node{}; node != size(); ++node)\n {\n for(const edge_t &e : other[node])\n {\n if(e.src == node)\n {\n edge_t *ref = adjs[src].emplace(e);\n edge_t *rref = adjs[dst].emplace(*e.rev);\n ref->rev = rref;\n rref->rev = ref;\n e.rev->src = -1;\n }\n else\n {\n e.rev->rev->src = node;\n }\n }\n }\n }\n\n flow_base &operator=(const flow_base &other)\n {\n if(this != &other)\n {\n flow_base cop(other);\n std::swap(adjs, cop.adjs);\n }\n return *this;\n }\n\n size_t size() const { return adjs.size(); }\n\n typename decltype(adjs)::reference operator[](size_t node) { assert(node < size()); return adjs[node]; }\n typename decltype(adjs)::const_reference operator[](size_t node) const { assert(node < size()); return adjs[node]; }\n\n void add_edge(size_t src, size_t dst, cap_t cap, cost_t cost)\n {\n assert(src < size()); assert(dst < size());\n if(!(cap > 0)) return;\n edge_t *ref = adjs[src].emplace(src, dst, cap, cost, nullptr);\n ref->rev = adjs[dst].emplace(dst, src, 0, -cost, ref);\n }\n}; // struct flow_base\n\ntemplate \nclass min_cost_flow : public flow_base\n{\n using base = flow_base;\n using edge_t = typename base::edge_t;\n using base::adjs;\n using base::size;\n\n cost_t min_cost, total_cost;\n std::vector supp;\n std::vector ptnl;\n\n void copy_member(const min_cost_flow &other)\n {\n min_cost = other.min_cost;\n total_cost = other.total_cost;\n supp = other.supp;\n ptnl = other.ptnl;\n }\n\n void Dijkstra(std::vector &last)\n {\n const cost_t infty(total_cost + 1);\n std::vector dist(size(), infty);\n //*/ // O((V + E)logV)\n std::priority_queue> que;\n for(size_t node{}; node != size(); ++node)\n {\n if(supp[node] > static_cast(0))\n {\n dist[node] = 0;\n que.emplace(0, node);\n }\n }\n while(!que.empty())\n {\n auto [nsp, node] = que.top();\n que.pop();\n if(-nsp != dist[node]) continue;\n ptnl[node] -= nsp;\n if(ptnl[node] > infty) ptnl[node] = infty;\n dist[node] = -1;\n for(edge_t &e : adjs[node])\n {\n if(dist[e.dst] == static_cast(-1) || e.cap == static_cast(0)) continue;\n if(dist[e.dst] + ptnl[e.dst] > ptnl[node] + e.cost)\n {\n dist[e.dst] = ptnl[node] + e.cost - ptnl[e.dst];\n last[e.dst] = &e;\n que.emplace(-dist[e.dst], e.dst);\n }\n }\n }\n /*/ // O(V^2)\n size_t src(-1);\n for(size_t node{}; node != size(); ++node)\n {\n if(supp[node] > static_cast(0))\n {\n dist[node] = 0;\n src = node;\n }\n }\n while(src != static_cast(-1))\n {\n ptnl[src] += dist[src];\n dist[src] = -1;\n for(edge_t &e : adjs[src])\n {\n if(dist[e.dst] == static_cast(-1) || e.cap == static_cast(0)) continue;\n if(dist[e.dst] + ptnl[e.dst] > ptnl[src] + e.cost)\n {\n dist[e.dst] = ptnl[src] + e.cost - ptnl[e.dst];\n last[e.dst] = &e;\n }\n }\n src = -1;\n cost_t nsp{infty};\n for(size_t node{}; node != size(); ++node)\n {\n if(dist[node] == static_cast(-1)) continue;\n if(nsp > dist[node])\n {\n nsp = dist[node];\n src = node;\n }\n }\n }\n //*/\n }\n\npublic:\n min_cost_flow(size_t _n = 0) : base::flow_base(_n), min_cost(0), total_cost(0), supp(_n), ptnl(_n) {}\n\n min_cost_flow(const min_cost_flow &other) : base::flow_base(other)\n {\n copy_member(other);\n }\n\n min_cost_flow &operator=(const min_cost_flow &other)\n {\n base::operator=(other);\n copy_member(other);\n return *this;\n }\n\n void add_edge(size_t src, size_t dst, cap_t cap, cost_t cost)\n {\n assert(src != dst);\n if(cap <= static_cast(0)) return;\n if(cost < static_cast(0))\n {\n supp[src] -= cap;\n supp[dst] += cap;\n min_cost += cap * cost;\n total_cost -= cap * cost;\n base::add_edge(dst, src, cap, -cost);\n }\n else\n {\n total_cost += cap * cost;\n base::add_edge(src, dst, cap, cost);\n }\n }\n\n void supply(size_t node, cap_t vol) { assert(node < size()); supp[node] += vol; }\n\n bool flow()\n {\n std::vector last(size());\n std::vector shut(size());\n for(bool aug = true; aug; fill(last.begin(), last.end(), nullptr), fill(shut.begin(), shut.end(), false))\n {\n aug = false;\n Dijkstra(last);\n for(size_t dst{}; dst != size(); ++dst)\n {\n if(supp[dst] < static_cast(0) and last[dst])\n {\n cap_t resid{-supp[dst]};\n size_t src{dst}, block(-1);\n while(last[src] && !shut[src])\n {\n if(resid >= last[src]->cap) resid = last[block = src]->cap;\n src = last[src]->src;\n }\n if(shut[src]) block = src;\n else\n {\n if(resid >= supp[src])\n {\n resid = supp[src];\n block = src;\n }\n for(edge_t *e{last[dst]}; e; e = last[e->src])\n {\n e->cap -= resid;\n e->rev->cap += resid;\n }\n supp[src] -= resid;\n supp[dst] += resid;\n min_cost += ptnl[dst] * resid;\n aug = true;\n }\n if(block != size_t(-1))\n {\n for(size_t node{dst}; node != block; node = last[node]->src) shut[node] = true;\n shut[block] = true;\n }\n }\n }\n }\n for(cap_t s : supp) if(s > static_cast(0)) return false;\n return true;\n }\n\n cost_t optimal() { assert(flow()); return min_cost; }\n};\n\nmain()\n{\n min_cost_flow mcf(6100);\n int n,m,k,c,d; cin>>n>>m>>k>>c>>d;\n const int tlim=105;\n for(int i=0; i>j; j--;\n mcf.supply(j,1);\n }\n for(int i=0; i>u>>v; --u,--v;\n for(int t=0; t\n#include \n#include \nusing namespace std;\nconst int INF = 1e9+7;\nconst int N = 6005;\nstruct Edge\n{\n int from,to,cap,flow,cost;\n Edge(int u,int v,int ca,int f,int co):from(u),to(v),cap(ca),flow(f),cost(co){};\n};\nstruct MCMF\n{\n int n,m,s,t;\n vector edges;\n vector G[N];\n int inq[N];//\u662f\u5426\u5728\u961f\u5217\u4e2d\n int d[N];//\u8ddd\u79bb\n int p[N];//\u4e0a\u4e00\u6761\u5f27\n int a[N];//\u53ef\u6539\u8fdb\u91cf\n\n void init(int n)//\u521d\u59cb\u5316\n {\n this->n=n;\n for(int i=0;i Q;\n Q.push(s);\n while(!Q.empty())\n {\n int u=Q.front();\n Q.pop();\n inq[u]--;\n for(int i=0;ie.flow && d[e.to]>d[u]+e.cost)//\u6ee1\u8db3\u53ef\u589e\u5e7f\u4e14\u53ef\u53d8\u77ed\n {\n d[e.to]=d[u]+e.cost;\n p[e.to]=G[u][i];\n a[e.to]=min(a[u],e.cap-e.flow);\n if(!inq[e.to])\n {\n inq[e.to]++;\n Q.push(e.to);\n }\n }\n }\n }\n if(d[t]==INF) return false;//\u6c47\u70b9\u4e0d\u53ef\u8fbe\u5219\u9000\u51fa\n flow+=a[t];\n cost+=d[t]*a[t];\n int u=t;\n while(u!=s)//\u66f4\u65b0\u6b63\u5411\u8fb9\u548c\u53cd\u5411\u8fb9\n {\n edges[p[u]].flow+=a[t];\n edges[p[u]^1].flow-=a[t];\n u=edges[p[u]].from;\n }\n return true;\n }\n\n int MincotMaxflow(int s,int t)\n {\n int flow=0,cost=0;\n while(SPFA(s,t,flow,cost));\n //printf(\"flow = %d\\n\", flow);\n return cost;\n }\n} G;\nint n,m,k,c,d;\nint a[52],has[52][52];\npair e[N]; \nint id(int x,int t) {\n return x*102+t;\n}\nvoid build() {\n int S=id(k,102)+1,T=S+1;\n G.init(T+1);\n for(int i=1;i<=k;i++){\n G.addedge(S,id(a[i],0),1,0);\n }\n for(int i=1;i<=k;i++){\n for(int t=0;t<101;t++){\n for(int j=1;j<=k;j++){\n //if(t>=80) continue;\n if(j==i) G.addedge(id(i,t),id(i,t+1),k,0);\n else {\n if(has[i][j]==0) continue;\n for(int x=1;x<=k;x++) G.addedge(id(i,t),id(j,t+1),1,(2*x-1)*d);\n }\n }\n }\n }\n for(int i=1;i<101;i++){\n //if(i>=80) continue;\n G.addedge(id(1,i),T,1,i*c);\n }\n cout << G.MincotMaxflow(S,T) << endl;\n}\nint main() {\n scanf(\"%d%d%d%d%d\",&n,&m,&k,&c,&d);\n for(int i=1;i<=k;i++) {\n scanf(\"%d\",&a[i]); \n }\n for(int i=1;i<=m;i++) {\n int u,v; scanf(\"%d%d\",&u,&v);\n has[u][v]=has[v][u]=1;\n }\n build();\n}\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6ff8f5b55c080abc39f985bc1fe4dc06", "src_uid": "2d0aa75f2e63c4fb8c98742ac8cd821c", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "// while (clock()<=69*CLOCKS_PER_SEC)\n// #pragma comment(linker, \"/stack:200000000\")\n// #pragma GCC optimize(\"O3\")\n// #pragma GCC optimize(\"Ofast\")\n// #pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n// #pragma GCC optimize(\"unroll-loops\")\n#include\n#include \n#include \n\n#define pb push_back\n#define SZ(x) ((int)(x).size())\n#define ALL(x) x.begin(),x.end()\n#define all(x) x.begin(),x.end()\n#define fi first\n#define se second\n#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define erase_duplicates(x) sort(all(x)); (x).resize(distance((x).begin(), unique(all(x))));\n\n\nusing namespace std;\nusing namespace __gnu_pbds;\ntemplate\nusing ordered_set = tree<\nT,\nnull_type,\nless,\nrb_tree_tag,\ntree_order_statistics_node_update>;\n\n//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)\n//X.order_of_key(k); - zwraca liczb\u0119 element\u00f3w ostro mniejszych ni\u017c k\n\ntypedef long long LL;\ntypedef pair PII;\ntypedef pair PLL;\ntypedef vector VPII;\ntypedef vector VPLL;\ntypedef vector VLL;\ntypedef vector VI;\ntypedef vector VS;\ntypedef vector VC;\ntypedef long double LD;\ntypedef pair PLD;\ntypedef vector VLD;\ntypedef vector VPLD;\n\ntemplate void _dbg(const char *sdbg, TH h){ cerr< void _dbg(const char *sdbg, TH h, TA... a) {\n while(*sdbg!=',')cerr<<*sdbg++;\n cerr<<\" = \"< wEPS) {\n if (pot[zu[i]] > pot[u] + cost[i] + cEPS) {\n pot[zu[i]] = pot[u] + cost[i]; cont = 1;\n }\n }\n }\n //*/\n for (toc = 0, tof = 0; tof + wEPS < flo; ) {\n typedef pair node;\n priority_queue< node,vector,greater > q;\n FOR(u,n) { d[u] = cINF; vis[u] = 0; }\n for (q.push(mp(d[src] = 0, src)); !q.empty(); ) {\n c = q.top().first; int u = q.top().second; q.pop();\n if (vis[u]++) continue;\n for (i = ptr[u]; ~i; i = nxt[i]) if (capa[i] > wEPS) {\n cc = c + cost[i] + pot[u] - pot[v = zu[i]];\n if (d[v] > cc) { q.push(mp(d[v] = cc, v)); pree[v] = i; }\n }\n }\n if (!vis[ink]) return 0;\n f = flo - tof;\n for (v = ink; v != src; v = zu[i ^ 1]) { i = pree[v];\n REMIN(f, capa[i]); }\n for (v = ink; v != src; v = zu[i ^ 1]) { i = pree[v];\n capa[i] -= f; capa[i ^ 1] += f; }\n tof += f;\n toc += f * (d[ink] - pot[src] + pot[ink]);\n FOR(u,n) pot[u] += d[u];\n }\n return 1;\n }\n}\n\nint pocz[maxn];\n\nint main()\n{\n\t_upgrade\n int n, m, k, c, d;\n cin>>n>>m>>k>>c>>d;\n for(int i = 1;i <= k;i++)\n cin>>pocz[i];\n VPII wek;\n for(int i = 1;i <= m;i++)\n {\n int a, b;\n cin>>a>>b;\n wek.pb({a, b});\n wek.pb({b, a});\n }\n MCF::init(n);\n int cur = 1;\n for(int i = 1;i <= k;i++)\n MCF::ae(0, pocz[i] + 1, 1, 0);\n int stala = 100;\n for(int ii = 1;ii <= stala;ii++)\n {\n for(auto s : wek)\n for(int i = 1;i <= 2 * n;i += 2)\n MCF::ae(cur + s.fi, cur + n + s.se, 1, d * i);\n for(int i = 1;i <= n;i++)\n MCF::ae(cur + i, cur + n + i, n, 0);\n MCF::ae(cur + 1, 1, n, 0);\n cur += n;\n }\n MCF::spRep(0, 1);\n cout< \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n#define int long long \n#define endl '\\n' \n#define fib(i, n) for (int i = n; i >= 0; i--) \n#define fi(i,a,b) for(int i = (a); i < (b); i++) \n#define MAX 1 << 10 \n#define pb push_back\nconst int N = 1e5 + 10;\nint n, m, p[100005], ans;\nint t[200005], lis[100005], lds[100005];\nvoid modify(int P, int val) {\n\tfor (t[P += m + 1] = val; P>1; P >>= 1) t[P >> 1] = max(t[P], t[P ^ 1]);\n}\nint query(int l, int r) {\n\tint res = 0;\n\tfor (l += m + 1, r += m + 2; l>= 1, r >>= 1) {\n\t\tif (l & 1) res = max(res, t[l++]);\n\t\tif (r & 1) res = max(res, t[--r]);\n\t}\n\treturn res;\n}\nvoid Solve() {\n\tcin >> n >> m;\n\tfi(i, 0, n) {\n\t\tint L, R;\n\t\tcin >> L >> R;\n\t\tp[L]++;\n\t\tp[R + 1]--;\n\t}\n\tfi(i, 1, m + 1) {\n\t\tp[i] += p[i - 1];\n\t}\n\tfor (int i = m; i >= 1; i--) {\n\t\tint h = query(p[i], m) + 1;\n\t\tmodify(p[i], h);\n\t\tlis[i] = h;\n\t}\n\tmemset(t, 0, sizeof t);\n\tfi(i, 1, m + 1) {\n\t\tint h = query(0, p[i]) + 1;\n\t\tmodify(p[i], h);\n\t\tlds[i] = h;\n\t}\n\tfi(i, 1, m + 1) {\n\t\tans = max(ans, lis[i] + lds[i] - 1);\n\t}\n\tcout << ans << endl;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fe8c3e1e0b5efdba7f1ef821a84717da", "src_uid": "ce8350be138ce2061349d7f9224a5aaf", "difficulty": 1900.0} {"lang": "GNU C++14", "source_code": "#include \n\n//#define int long long\n\nusing namespace std;\n\nint INF = int(2e9), n, m, l, r, k = 0, maxk = 0;\n\nvector < int > calc(vector < int > &a)\n{\n vector < int > d(m + 1, INF), ans(m, 0);\n d[0] = -INF;\n for(int i = 0; i < m; i++)\n {\n int j = int(upper_bound(d.begin(), d.end(), a[i]) - d.begin());\n d[j] = a[i];\n ans[i] = j;\n }\n return ans;\n}\nvector < int > rev_calc(vector < int > &a)\n{\n vector < int > b = a;\n reverse(a.begin(), a.end());\n b = calc(b);\n reverse(b.begin(), b.end());\n return b;\n}\n\n\nsigned main()\n{\n cin >> n >> m;\n vector < pair < int, int > > lr(m + 1, {0, 0});\n for(int i = 0; i < n; i++)\n {\n cin >> l >> r;\n lr[l - 1].first++;\n lr[r - 1].second++;\n }\n vector < int > a(m, 0);\n for(int i = 0; i < m; i++)\n {\n k += lr[i].first;\n a[i] = k;\n k -= lr[i].second;;\n }\n vector < int > d1 = calc(a), d2 = rev_calc(a);\n for(int i = 0; i < m; i++)\n maxk = max(d1[i] + d2[i], maxk);\n cout << maxk - 1;\n return 0;", "lang_cluster": "C++", "compilation_error": true, "code_uid": "db6dfff4f19ce48536e42e8a8b49733a", "src_uid": "ce8350be138ce2061349d7f9224a5aaf", "difficulty": 1900.0} {"lang": "GNU C++11", "source_code": "#define _CRT_SECURE_NO_WARNINGS \nvoid Solve(); int main() { Solve(); }\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n#define int long long \n#define endl '\\n' \n#define fib(i, n) for (int i = n; i >= 0; i--) \n#define fi(i,a,b) for(int i = (a); i < (b); i++) \n#define MAX 1 << 10 \n#define pb push_back\n\nconst int MAXN = 100007;\nint a[MAXN], addmark[MAXN], dp[MAXN], lis[2][MAXN], slis[MAXN];\nint cnt = 0;\nvoid Solve() {\n\tint n, m;\n\tcin >> n >> m;\n\tfor (int i = 0; i> l >> r;\n\t\t\n\t\taddmark[l]++;\n\t\taddmark[r + 1]--;\n\t}\n\tint sum = 0;\n\tfor (int i = 1; i <= m; i++) {\n\t\tsum += addmark[i];\n\t\ta[i] = sum;\n\t}\n\n\tmemset(dp, 63, sizeof(dp));\n\tfor (int i = 1; i <= m; i++) {\n\t\tint pos = upper_bound(dp, dp + i, a[i]) - dp;\n\t\tdp[pos] = a[i];\n\t\tlis[0][i] = pos + 1;\n\t}\n\tmemset(dp, 63, sizeof(dp));\n\tfor (int i = m; i >= 1; i--) {\n\t\tint pos = upper_bound(dp, dp + m - i + 1, a[i]) - dp;\n\t\tdp[pos] = a[i];\n\t\tlis[1][i] = pos + 1;\n\t\tslis[i] = max(slis[i + 1], pos + 1);\n\t}\n\tint ans = 0;\n\tfor (int i = 1; i <= m; i++) {\n\t\tans = max(ans, lis[0][i] + slis[i + 1]);\n\t}\n\tcout << ans << endl;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c48ce068693f89e02566a5a407fab080", "src_uid": "ce8350be138ce2061349d7f9224a5aaf", "difficulty": 1900.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nuint32_t next(uint32_t x) {\n --x;\n x |= x >> 1;\n x |= x >> 2;\n x |= x >> 4;\n x |= x >> 8;\n x |= x >> 16;\n return x + 1;\n}\nclass ST\n{\n private:\n int n;\n vector t;\n public:\n ST(int N) {\n n = next(N);\n t.resize(2*n, 0);\n }\n int get_max(int l, int r) {\n int ans = 0;\n l += n, r += n;\n while (l <= r) {\n if (l & 1)\n ans = max(ans, t[l]);\n if (!(r & 1))\n ans = max(ans, t[r]);\n l = (l + 1) / 2, r = (r - 1) / 2;\n }\n return ans;\n }\n void update(int i, int x) {\n int j = i + n;\n t[j] = x;\n while (j /= 2)\n t[j] = max(t[2*j], t[2*j+1]);\n }\n};\nint n, m;\nvector dp(vector a) {\n vector d(m);\n ST Myst(n+1);\n for (int i = 0; i < m; ++i) {\n d[i] = Myst.get_max(0, a[i])+1;\n Myst.update(a[i], d[i]);\n }\n return d;\n}\n\nint main()\n{\n ios::sync_with_stdio(0); cin.tie(nullptr);\n int l, r;\n cin >> n >> m;\n STsum SUM(m);\n vector used(m, 0);\n for (int i = 0; i < n; ++i) {\n cin >> l >> r;\n --l, --r;\n ++used[l];\n if (r < m-1) --used[r+1];\n }\n vector a(m);\n for (int i = 0; i < m; ++i)\n if (i)\n a[i] = a[i-1]+used[i];\n else\n a[i] = used[i];\n vector dp_1 = dp(a);\n reverse(a.begin(), a.end());\n vector dp_2 = dp(a);\n int sum = 0;\n for (int i = 0; i < m; ++i) {\n sum = max(sum, dp_1[i]+dp_2[m-i-1]-1);\n }\n cout << sum;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ec56f77cae2b9e474387ad92a868d56c", "src_uid": "ce8350be138ce2061349d7f9224a5aaf", "difficulty": 1900.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint c[101],a[101];\nint k,n,x,maxn=0;\nint main(){\n \tcin>>n>>k;\n \tfor(int i=1;i<=n;i++){\n \t\tcin>>a[i];\n \t\tc[i%k]+=a[i];\n \t\tc[k]+=a[i];\n\t}\n\tabs(c[k]);\n\tfor(i=0;i int main() { hoge; }", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f975a880d0bdb039377bba88c7af7afb", "src_uid": "6119258322e06fa6146e592c63313df3", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "import sublime\nimport sublime_plugin\nimport os\nimport sys\nimport time\n\n''' Change this directory name by your python directory '''\npathToPython = \"/home/light/.local/lib/python3.6/site-packages/\"\nsys.path.append(pathToPython)\n\nfrom selenium import webdriver\nfrom selenium.webdriver.chrome.options import Options\nfrom selenium.webdriver.common.keys import Keys\n\ndef process(string):\n\n\t# Get active file name\n\tfilename = sublime.active_window().active_view().file_name()\n\tcontestid, problem = string.strip().split()\n\n\t# Change executor_url according to your preference\n\texecutor_url = \"127.0.0.1:9222\" # change 9222 to the port you have used.\n\turl = \"codeforces.com/contest/\" + contestid + \"/problem/\" + problem\n\t\n\t_chrome_options = Options()\n\t_chrome_options.add_argument('disable-infobars')\n\t_chrome_options.add_argument(\"--start-maximized\")\n\t_chrome_options.add_experimental_option(\"debuggerAddress\", executor_url)\n\ttry:\n\t\tdriver = webdriver.Chrome(chrome_options = _chrome_options)\n\t\tdriver.implicitly_wait(30)\n\n\t\ttry:\n\t\t\tdriver.get(\"http://\" + url.rstrip())\n\t\t\tdriver.find_element_by_name(\"sourceFile\")\n\t\t\tdriver.find_element_by_css_selector('input[type=\"file\"]').clear()\n\t\t\tdriver.find_element_by_css_selector('input[type=\"file\"]').send_keys(filename.rstrip()) # Send File to Codeforces\n\t\t\tdriver.find_element_by_class_name(\"submit\").click() # Click on submit button\n\t\texcept Exception as e:\n\t\t\t''' In case Codeforces is too busy or File is untitled.'''\n\t\t\tsublime.error_message('Either Codeforces is too busy or File is Untitled.')\n\texcept Exception as e:\n\t\t''' In case Server is not active. '''\n\t\tsublime.error_message('Server is not active.')\nclass SolveItCommand(sublime_plugin.TextCommand):\n\tdef run(self, edit):\n\t\twindow = self.view.window()\n\t\t''' Input Panel to get Contest ID and Problem Id from the user '''\n\t\twindow.show_input_panel(\"Enter ContestID & ProblemID : \", \"\", self.on_done, self.on_change, self.on_cancel)\n\n\tdef on_done(self, input_data):\t\n\t\tprocess(input_data)\t\t\n\t\tpass\n\n\tdef on_change(self, input_data):\n\t\tpass\n\n\tdef on_cancel(self):\n\t\tpass\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d9f60d616ddd6dabc501ac02067e54c5", "src_uid": "6119258322e06fa6146e592c63313df3", "difficulty": 1000.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define REP(i,n) for(int(i)=0;(i)<(int)(n);(i)++)\n#define REPN(i,n) for((i)=1;(i)<(int)(n);(i)++)\n#define _abs(x) ((x)>0?(x):-(x))\n#define ll long long \nusing namespace std; \nint main()\n{\n int sum=0,ans=0,n,k,e,s;\n cin>>n>>k;\n int a[n];\n REP(i,n)\n {\n cin>>a[i];\n if(a[i]==1)\n {\n sum++;\n }\n else\n {\n ans++;\n }\n }\n //cout<ans)\n {\n cout<\n#define MAX 1000000000 ;\nusing namespace std ;\nint n; \nint main (){\n int k,cnt=0,dp[n]; \n cin>>n>>k ;\n int in[n]; \n for (int i=0 ; i>in[i];\n int ans=MAX ;\n for (int i=0 ; i\nusing namespace std;\nint n,k,i,min=10000,ans=0,t;\nint main()\n{\n cin>>n>>k;\n for(i=0;i>t;\n if(k%t==0)\n {\n ans=k/t;\n if(ans\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint __gcd(int x, int y) { if(!y) return x; return __gcd(y, x % y); }\n\n#define foreach(i,x) for(type(x)i=x.begin();i!=x.end();i++)\n#define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)\n#define ROF(ii,aa,bb) for(int ii=aa;ii>=bb;ii--)\n\n#define sag (k + k + 1)\n#define sol (k + k)\n\n#define type(x) __typeof(x.begin())\n\n#define orta ((bas + son) >> 1)\n#define sag (k + k + 1)\n#define sol (k + k)\n\n#define pb push_back\n#define mp make_pair\n\n\n#define nd second\n#define st first\n\n#define endl '\\n'\n\ntypedef pair < int ,int > pii;\n\ntypedef long long ll;\n\nconst long long linf = 1e18+5;\nint mod = (int) 1e9 + 7;\nconst int logN = 18;\nconst int inf = 1e9 + 9;\n\nconst int N = 4e5 + 6;\n\nint main() {\n\tint n, k, ans = inf;\n\tscanf(\"%d %d\", &n, &k);\n\tFOR(i, 1, n) {\n\t\tscanf(\"%d\", &x);\n\t\tif(n % x == 0)\n\t\t\tans = min(ans, k / x);\n\t}\t\n\tcout << ans;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "dfae3f6ee1e4c2ec26dfe10d7b720160", "src_uid": "80520be9916045aca3a7de7bc925af1f", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n#define mod 1000000007\nstruct ss\n{\n\tlong long aa,ab;\n};\nvoid srt(const ss &lhs, const ss &rhs)\n{\n\treturn lhs.aa>n>>k;\n\tint sum=INT_MAX;int x;\n\tfor(int i=0;i>x;\n\t\tif(k%x==0)\n\t\t{\n\t\t\tif((k/x)\n\nusing namespace std;\n\nlong long pow(int x, int y) {\n if(y == 0)\n return 1;\n long long res = pow(x, y/2);\n if(y%2)\n return res*res*a;\n else\n return res*res;\n}\n\nint main() {\n long long n;\n cin >> n;\n cout << 4*(n-1)*pow(3, n-2);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a8436f8b7743e7b7f0bf5db7dc94211c", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include \n//#include \"Header.h\"\n\n#define pi 3.14159265358979323846264\n\n#define ll long long\n#define fori(n) for(long long i=0;i>n;\n if(n==3){cout<<24;\n }\n else {cout<<(3*(3n-1)*((ll)pow((double)4,n-3)));}\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4d10f3ef35a30b788f16f923a5df91c6", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9", "difficulty": 1700.0} {"lang": "MS C++ 2017", "source_code": "#include \nusing namespace std;\nint main() {\n int x;\n cin >> x;\n int total = 2*x-2, fact=1;\n for (int i=1;i=\n#include\nusing namespace std;\n\nint main(){\n#pragma warning(disable : 4996)\n#ifdef _DEBUG\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif\n double n;\n cin>>n;\n n=24*((long long int)2<<(2*n-6))+(n-3)*4*9*((long long int)2<<(2*n-8));\n cout<\n#include\n#define pb push_back\n#define ll long long\n#define ff first\n#define ss second\n#define endl \"\\n\"\n#define mod 1000000007\n#define MAX 2001 \nusing namespace std;\n\n\nint main() {\n\tios_base::sync_with_stdio(false);\n cin.tie(NULL);\n\tll int m;\n\tcin>>m;\n\tfor(int i=1; i<=100000; i+=5) {\n\t\tll int ans = 0;\n\t\tll int j = 1;\n\t\twhile((i/pow(5, j)) > 0) {\n\t\t\tans += i/pow(5, j);\n\t\t\tj++;\n\t\t}\n\t\tif(ans > m)\n\t\t\tbreak;\n\t\tif(ans == m){\n\t\t\tflag = 1;\n\t\t\tcout<<5<\n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define pt pair\n#define X first\n#define Y second\n\nconst int NMAX = 100 + 10;\n\nlong long cntZero(long long x) {\n\tlong long ans = 0;\n\twhile (x % 10 == 0) {\n\t\tans++;\n\t\tx /= 10;\n\t}\n\treturn ans;\n}\n\nlong long pow5(long long x) {\n\tlong long st = 1;\n\tlong long y = 5;\n\twhile (y < x) {\n\t\tst++;\n\t\ty *= 5;\n\t}\n\tif (y > x) {\n\t\tst = 1;\n\t}\n\treturn st;\n}\n\nlong long m;\nlong long st = -1, end = -1;\n\nlong long n = 0;\nlong long zero = 0;\n\nint main() { \n\n\tcin >> m;\n\t\n\twhile (true) {\n\t\tn += 5;\n\t\tif (n % 10 == 5) {\n\t\t\tzero += pow5(n);\n\t\t} else {\n\t\t\tzero += cntZero(n);\n\t\t}\n\t\tif (zero == m) {\n\t\t\tst = n;\n\t\t}\n\t\tif (zero > m) {\n\t\t\tend = n;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (st == -1) {\n\t\tcout << 0;\n\t} else {\n\t\tcout << end - st << endl;\n\t\tfor (int i = st; i < end; ++i) {\n\t\t\tcout << i << \" \";\n\t\t}\n\t}\n\tcout << endl;\n\n\tprintf(\"\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2e5c1ef6bc767ce3a4cbdbeae6cd833f", "src_uid": "c27ecc6e4755b21f95a6b1b657ef0744", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\ninline int zero(int n){\n\tint a=0;\n\twhile(n!=0){\n\t\ta+=n/5;\n\t\tn/=5;\n\t}\n\treturn a;\n}\nint main(){\n\tint m;\n\tvector v;\n\tcin>>m;\n\tfor(int i=1;i<5*m+5;i++){\n\t\tif(zeros(i)==m){\n\t\t\tv.push_back(i);\n\t\t}\n\t}\n\tcout<\nusing namespaces std;\nint main()\n{\n unsigned long long i,j,n,m,count=0;;\n cin>>m;\n \n for(i=5;;i+=5)\n {\n j=i;\n n=5;\n count=0;\n while(j/n)\n {\n count++;\n n*=5;\n }\n if(count==m)\n {\n for(int k=0;k<5;k++)\n cout<\nusing namespace std;\n\nint a,b,c;\n\nint SumHalf(int n)\n{\n if(2*n>a)\n return 0;\n else return 1;\n}\n\nint SumOne(int n)\n{\n int sum=0;\n for(int i=0; i=0; i++, n--)\n sum+=SumHalf(n);\n return sum\n}\n\nint SumTwo(int n)\n{\n int sum=0;\n for(int i=0; i=0; i++, n--)\n sum+=SumOne(n);\n return sum;\n}\n\nint main()\n{\n int n;\n cin>>n>>a>>b>>c;\n cout<\nusing namespace std;\nint main()\n{\n\tint t=0,n,i,j,k,a,b,c;\n\tt=0;\n\tcin>>n>>a>>b>>c;\n\tfor(i=0;i<=a;i+=2)\n\tfor(j=0;j<=b;j++)\n\tfor(k=0;k<=c;k++)\n\t{\n\t\tif(i/2+j+2*k==n) t++,break;\n\t}\n\tcout< 1 || o[0].getClass().isArray() ? Arrays.deepToString(o) : o[0]); }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "934a696a1c065e38644e4e646c5c0505", "src_uid": "474e527d41040446a18186596e8bdd83", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n\n\nint main() {\n int n,a,b,c;\n cin>>n>>a>>b>>c;\n c /= 2;\n long long ans = 0;\n // cout<\n\nusing namespace std;\nlong long n,x,y;\nbool check;\n\nvoid input()\n{\n\tcin>>n>>x>>y;\n}\n\nvoid fix (long long a,long long b)\n{\n\tif (a >= b)\n\t{\n\t\tint temp = a;\n\t\ta = b;\n\t\tb = temp;\n\t}\n}\n\nvoid fin()\n{\n\tfix (x,y);\n\tint w=0,b=0;\n\tw = y - 1;\n\tb = n - x;\n\tcout<= 0 && b >= 0)\n\t{\n\t\tif (check) cout<<\"White\";\n\t\telse cout<<\"Black\";\n\t}\n\telse \n\t{\n\t\tif (check) cout<<\"Black\";\n\t\telse cout<<\"White\";\n\t}\n\t\n}\nmain()\n{\n\tinput();\n\tfin();\n\toutput();\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "74908e42f9dc6b20cf42d65791fc8e27", "src_uid": "b8ece086b35a36ca873e2edecc674557", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n\nusing namespace std;\n\nbool compareD(int y, int x, int n)\n{\n\tfloat d1 = sqrt((x - 1)*(x - 1) + (y - 1)*(y - 1));\n\tfloat d2 = sqrt((n - x)*(n - x) + (n - y)*(n - y));\n\treturn d1 >= d2;\n}\n\nint main()\n{\n\tint n, x, y;\n\tcin >> n;\n\tcin >> x >> y;\n\tif (compareD(x, y, n))\n\t\tcout << \"White\";\n\telse\n\t\tcout << \"Black\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f93bf768a7978f89e001b19c0f87897a", "src_uid": "b8ece086b35a36ca873e2edecc674557", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include\n#include\n#define max *maximum_element\nnamespace std\nint main(){\nint n,x,y; cin>>n>>x>>y;\nif(max(x,y)<=max(n-x,n-y)) cout<<\"White\\n\";\nelse cout<<\"Black\\n\";\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8cae2f509dd153a3e7c0eae059b103e4", "src_uid": "b8ece086b35a36ca873e2edecc674557", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\nint main(){\n int n,a,b;\n cin >> n >> a >> b;\n \n int B = n-a < n-b? n-a:n-b;\n int W = a-1 < b-1? a-1:b-1;\n \n cout << W <= B? \"White\":\"Black\";\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e889ec9c7874b8ea6f24b480d9724e1f", "src_uid": "b8ece086b35a36ca873e2edecc674557", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#define N 205 \n#define M 100005 \n#define maxn 205 \n#define MOD 1000000000000000007 \nint t,s,q; \nint main() \n{ \n //freopen(\"in.txt\", \"r\", stdin); \n //freopen(\"out.txt\", \"w\", stdout); \n while(S2(t,s)!=EOF) \n { \n S(q); \n int ans = 0; \n while(s < t){ \n s = s * q; \n ans++; \n } \n printf(\"%d\\n\",ans); \n } \n //fclose(stdin); \n //fclose(stdout); \n return 0; \n} ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "75b41ec9f7fbaf70080bf743ebce4226", "src_uid": "0d01bf286fb2c7950ce5d5fa59a17dd9", "difficulty": 1500.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\n\nint main()\n{\n int t, s, q, x=0 ;\n cin >> t >> s >> q;\n \n int x=0;\n while( s < t )\n {\n x++ ;\n s = s * q ;\n // s * = q ;\n }\n cout << x ; \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3bbc5e00ed040252b77b29545764bd46", "src_uid": "0d01bf286fb2c7950ce5d5fa59a17dd9", "difficulty": 1500.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n double t,s,q;\n cin >> t >> s >> q;\n \n double v = q-1/q;\n int ans=0;\n double total = 0;\n do{\n ans++;\n total += (1-v)*total;\n }while(total < t)\n \n cout << ans;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "00376cfe8e433ed26f5ee33bfd4f1492", "src_uid": "0d01bf286fb2c7950ce5d5fa59a17dd9", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint main()\n{\n //freopen(\"inp.txt\",\"r\",stdin);\n //freopen(\"out.txt\",\"w\",stdout);\n ios_base::sync_with_stdio(false);\n \n LL t,s,q;\n LL ans = 1;\n \n cin>>t>>s>>q;\n \n while( ( s + (s*(q-1)) ) < t )\n {\n ans++;\n s += (s*(q-1));\n }\n \n cout<\n#define ll long long\n#define ull unsigned ll\n#define uint unsigned\n#define db long double\n#define pii pair\n#define pll pair\n#define IT iterator\n \n#define PB push_back\n#define MK make_pair\n#define LB lower_bound\n#define UB upper_bound\n#define EB emplace_back\n#define fi first\n#define se second\n \n#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)\n#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)\n#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)\n#define CLR(a,v) memset(a,v,sizeof(a));\n#define CPY(a,b) memcpy(a,b,sizeof(a));\n \n#define LS3 k*2,l,mid\n#define RS3 k*2+1,mid+1,r\n#define LS5 k*2,l,mid,x,y\n#define RS5 k*2+1,mid+1,r,x,y\n#define GET pushdown(k);int mid=(l+r)/2\n \n#define inf 1<<30\n#define sqr(x) ((x)*(x))\nusing namespace std;\nconst int N=100005;\nint inv[N],n,k,mo,ans;\nmap mp;\nvoid get(int n,int k){\n\tif (k==1||n==1) mp[n]++;\n\telse get(n/2,k-1),get(n-n/2,k-1); \n}\nint calc(int x,int y){\n\tint ans=1ll*x*y%mo*(mo+1)/2%mo;\n\tFor(i,1,y) ans=(ans+mo+1ll*inv[i]-inv[i+x])%mo;\n\treturn ans;\n}\nint main(){\n\tscanf(\"%d%d%d\",&n,&k,&mo); \n\tinv[0]=inv[1]=1;\n\tFor(i,2,n) inv[i]=1ll*inv[mo%i]*(mo-mo/i)%mo;\n\tFor(i,1,n) inv[i]=(inv[i]+inv[i-1])%mo;\n\tget(n,k);\n\tfor (auto a:mp){\n\t\tans=(ans+1ll*a.fi*(a.fi-1)/2%mo*(mo+1)/2%mo*a.se)%mo;\n\t\tans=(ans+1ll*a.se*(a.se-1)/2%mo*calc(a.fi,a.fi))%mo;\n\t\tfor (auto b:mp) if (a.fi\nusing namespace std;\nconst int N=1e5+7;\nint n,k,p,cnt[N]; long long ifac[N];\ninline void solve(int l,int r,int t){\n\tif(t==1||l==r) {cnt[r-l+1]++; return;}\n\tint d=(l+r)>>1; solve(l,d,t-1),solve(d+1,r,t-1);\n}\ninline long long getans(int a,int b){\n\tlong long sum=(p+1)/2,ans=sum*a%p*b%p;\n\tfor(int i=1;i<=a;i++) ans=(ans-ifac[i+b]+ifac[i])%p;\n\treturn (ans+p)%p;\n}\nint main(){\n\tcin>>n>>k>>p,ifac[0]=ifac[1]=1;\n\tfor(int i=2;i<=n;i++) ifac[i]=ifac[p%i]*(p-p/i)%p;\n\tfor(int i=1;i<=n;i++) ifac[i]=(ifac[i]+ifac[i-1])%p;\n\tsolve(1,n,k); int a=0,b=0;\n\tfor(int i=1;i<=n;i++) if(cnt[i]&&!a) a=i; else if(cnt[i]) b=i;\n\tlong long s=getans(a,a)*((1ll*cnt[a]*(cnt[a]-1)/2)%p)%p;\n\ts=(s+getans(b,b)*((1ll*cnt[b]*(cnt[b]-1)/2)%p))%p;\n\ts=(s+getans(a,b)*cnt[a]%p*cnt[b]%p)%p;\n\ts=(s+(1ll*a*(a-1)/2*cnt[a]%p+1ll*b*(b-1)/2*cnt[b]%p)%p*((p+1)/2))%p;\n\tcout<\nusing namespace std;\ntemplate inline t read(t &x){\n\tchar c=getchar();bool f=0;x=0;\n\twhile(!isdigit(c)) f|=c=='-',c=getchar();\n\twhile(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();\n\tif(f) x=-x;return x;\n}\ntemplate inline void read(t &x,A &...a){\n\tread(x);read(a...);\n}\ntemplate inline void write(t x){\n\tif(x<0) putchar('-'),write(-x);\n\telse{if(x>9) write(x/10);putchar('0'+x%10);}\n}\n\n#define int long long\n\nconst int N=1e5+5;\nint ans,a1,a2,b1,b2,n,k,inv[N<<1],mod;\n\nint fpow(int x,int y){\n\tint res=1;\n\tfor(;y;y>>=1,x=x*x%mod) if(y&1) res=res*x%mod;\n\treturn res;\n}\n\nvoid dico(int l,int r,int h){\n\tif(h==1||l==r){\n\t\tl=r-l+1;\n\t\tif(!a1) a1=l,b1=1;\n\t\telse if(a1==l) b1++;\n\t\telse a2=l,b2++;\n\t\treturn ;\n\t}\n\tint mid=l+r>>1;\n\tdico(l,mid,h-1);\n\tdico(mid+1,r,h-1);\n}\n\nint calc(int n,int m){\n\tint res=0;\n\tfor(int i=2;i<=n+m;i++) res=(res+inv[i]*min(i-1,n+m-i+1)%mod)%mod;\n\treturn mod-res;\n}\n\nvoid init(int n){\n\tinv[1]=1;for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;\n}\n\nsigned main(){\n\tread(n,k,mod);ans=n*(n-1)/2*(mod+1>>1))%mod;\n\tinit(n<<1);\n\tdico(1,n,k);\n\tans=(ans+b1*(b1-1)/2*calc(a1,a1)%mod)%mod;\n\tif(a2){\n\t\tans=(ans+b2*(b2-1)/2*calc(a2,a2)%mod)%mod;\n\t\tans=(ans+b1*b2%mod*calc(a1,a2)%mod)%mod;\n\t}\n\twrite(ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "076f37c3a6d84264ee4562c88f1bb25c", "src_uid": "1dd54f5071872e947996ab32b16da19c", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\ntemplate inline t read(t &x){\n\tchar c=getchar();bool f=0;x=0;\n\twhile(!isdigit(c)) f|=c=='-',c=getchar();\n\twhile(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();\n\tif(f) x=-x;return x;\n}\ntemplate inline void read(t &x,A &...a){\n\tread(x);read(a...);\n}\ntemplate inline void write(t x){\n\tif(x<0) putchar('-'),write(-x);\n\telse{if(x>9) write(x/10);putchar('0'+x%10);}\n}\n\n#define int long long\n\nconst int N=1e5+5,i2=mod+1>>1;\nint ans,a1,a2,b1,b2,n,k,inv[N<<1],mod;\n\nint fpow(int x,int y){\n\tint res=1;\n\tfor(;y;y>>=1,x=x*x%mod) if(y&1) res=res*x%mod;\n\treturn res;\n}\n\nvoid dico(int l,int r,int h){\n\tif(h==1||l==r){\n\t\tl=r-l+1;\n\t\tif(!a1) a1=l,b1=1;\n\t\telse if(a1==l) b1++;\n\t\telse a2=l,b2++;\n\t\treturn ;\n\t}\n\tint mid=l+r>>1;\n\tdico(l,mid,h-1);\n\tdico(mid+1,r,h-1);\n}\n\nint calc(int n,int m){\n\tint res=0;\n\tfor(int i=2;i<=n+m;i++) res=(res+inv[i]*min(i-1,n+m-i+1)%mod)%mod;\n\treturn mod-res;\n}\n\nvoid init(int n){\n\tinv[1]=1;for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;\n}\n\nsigned main(){\n\tread(n,k,mod);ans=n*(n-1)/2*i2%mod;\n\tinit(n<<1);\n\tdico(1,n,k);\n\tans=(ans+b1*(b1-1)/2*calc(a1,a1)%mod)%mod;\n\tif(a2){\n\t\tans=(ans+b2*(b2-1)/2*calc(a2,a2)%mod)%mod;\n\t\tans=(ans+b1*b2%mod*calc(a1,a2)%mod)%mod;\n\t}\n\twrite(ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7b5b0bc7d0ab92bbeacf7b84ccbf1b9e", "src_uid": "1dd54f5071872e947996ab32b16da19c", "difficulty": 3200.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nmain()\n{\n\tint n;\n\tint a[30];\n\tcin>>n;\n\tfor(int i=0;i>a[i];\n\t}\n\tsort(a,a+n);\nif(a[n-1]>25)\tcout<\n\nusing namespace std;\n\nint main(){\n int a,f=0;\n cin>>a;\n int n[a];\n for(int i=0;i>n[i];\n \tif(n[i]>=25){\n \t\tf++;\n\t }\n\t cout<\nusing namespace std;\nint i, amax, k;\nmain () {\n\tcin>>k;\n\tfor(i=1; i<=k; i++)\n\tcin>>a[i];\n\t\n\tamax=a[i];\n\tfor(i=1; i<=k; i++)\n\tif(a[i]>amax) amax=a[i];\n\tif(amax>25)\n\t\n\tcout<\nusing namespace std;\n#define ll long long \nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n ll int n;\n cin>>n;\n l int a[n],max=-1;\n for(ll int i=0;i>a[i];\n if(max\n#include \n#include \n#include\n#include\n#define ll long long int\n#define M 6\nusing namespace std;\ninline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}\ninline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}\nint moth[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};\nint dir[4][2]={1,0 ,0,1 ,-1,0 ,0,-1};\nint dirs[8][2]={1,0 ,0,1 ,-1,0 ,0,-1, -1,-1 ,-1,1 ,1,-1 ,1,1};\nconst int inf=0x3f3f3f3f;\nconst ll mod=1e9+7;\nll l,r;\nint bits[20];\nll dp[20][3000][50];\nint hash[3000];\nvoid init(){\n\tmemset(dp,-1,sizeof(dp));\n\tint cnt=0;\n\tfor(int i=1;i<=2520;i++){\n\t\tif(2520%i==0) hash[i]=cnt++;\n\t}\n}\nll dfs(int len,int num,int mo,bool ismax){\n\tif(!len)\n\treturn num%mo==0;\n\tif(!ismax&&dp[len][num][hash[mo]]>=0)\n\treturn dp[len][num][hash[mo]];\n\tll cnt=0;\n\tint up=ismax?bits[len]:9;\n\tfor(int i=0;i<=up;i++){\n\t\tif(i==0) cnt+=dfs(len-1,(num*10+i)%2520,mo,ismax&&i==up);\n\t\telse cnt+=dfs(len-1,(num*10+i)%2520,lcm(mo,i),ismax&&i==up);\n\t}\n\tif(!ismax) dp[len][num][hash[mo]]=cnt;\n\treturn cnt;\n}\nll solve(ll x){\n\tint pos=0;\n\twhile(x){\n\t\tbits[++pos]=x%10;\n\t\tx/=10;\n\t}\n\treturn dfs(pos,0,1,true);\n}\nint main(){\n\tios::sync_with_stdio(false);\n\tint t;\n\tcin>>t;\n\tinit();\n\twhile(t--){\n\t\tcin>>l>>r;\n\t\tcout<\n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long LL;\n\nLL dp[20][50][3000];\nint d[20],hash[3000];\nconst int mod = 2520;\n\nint gcd ( int a ,int b )\n{\n return !b?a:gcd(b,a%b);\n}\n\nvoid init ( )\n{\n memset ( dp , -1 , sizeof ( dp ) );\n int cc = 0;\n for ( int i = 1 ; i <= 8 ; i *= 2 )\n for ( int j = 1; j <= 9 ; j*= 3 )\n for ( int k = 1 ; k <= 5 ; k *= 5 )\n for ( int t = 1; t <= 7 ; t *= 7 )\n hash[i*j*k*t] = ++cc;\n}\n\nLL dfs ( int n , int lcm , int f , int r )\n{\n if ( !n ) return r%lcm==0;\n int ll = hash[lcm];\n if ( f && dp[n][ll][r] != -1 ) \n return dp[n][ll][r];\n int x = f?9:d[n];\n LL ret = 0;\n for ( int i = 0 ; i <= x ;i++ )\n ret += dfs ( n-1 , i==0?lcm:lcm*i/gcd(lcm,i) , i==x?f:1 , (r*10+i)%mod );\n return f? dp[n][ll][r] = ret : ret;\n}\n\nLL solve ( LL x )\n{\n int cc = 0;\n while ( x )\n {\n d[++cc] = x%10;\n x /= 10;\n }\n return dfs ( cc , 1 , 0 , 0 );\n}\n\nint main ( )\n{\n int t;\n LL a,b;\n scanf ( \"%d\" , &t );\n init ( );\n while ( t-- )\n {\n scanf ( \"%lld%lld\" , &a , &b );\n printf ( \"%lld\\n\" , solve ( b ) - solve ( a-1 ) );\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fbc8b19e62c6ffd417bfa54c1051ce34", "src_uid": "37feadce373f728ba2a560b198ca4bc9", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "#define Tokisaki return //\u00bf\u00f1\u00c8\u00fd\u00ce\u00d2\u00c0\u00cf\u00c6\u00c5\u00a3\u00a1\u00a3\u00a1\u00a3\u00a1\n#define Kurumi 0; //\u00bf\u00f1\u00c8\u00fd\u00c8\u00fc\u00b8\u00df\u00a3\u00a1\u00a3\u00a1\u00a3\u00a1\n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst long long P=2520;\nlong long T,rnk[P+1];\nvector nums;\nlong long l,r,f[25][P+1][50]; //\u00cc\u00d8\u00b1\u00f0\u00d7\u00a2\u00d2\u00e2\u00a3\u00baDP\u00ca\u00fd\u00d7\u00e9\u00d2\u00bb\u00b6\u00a8\u00d2\u00aa\u00bf\u00aalong long\u00c0\u00e0\u00d0\u00cd\u00a3\u00ac\u00b2\u00bb\u00c8\u00bb\u00bb\u00e1\u00d5\u00a8\n\ninline long long GCD (long long x,long long y) //gcd\u00ba\u00af\u00ca\u00fd\u00a3\u00ac\u00cb\u00e4\u00c8\u00bbSTL\u00c0\u00ef\u00c3\u00e6\u00d7\u00d4\u00b4\u00f8\u00a3\u00a8\u00ce\u00aa__gcd\u00a3\u00a9\u00a3\u00ac\u00b5\u00ab\u00bb\u00b9\u00ca\u00c7\u00d7\u00d4\u00bc\u00ba\u00ca\u00d6\u00d0\u00b4\u00c1\u00cb\u00d2\u00bb\u00b8\u00f6\n{\n if(x>y) swap(x,y);\n if(y%x==0) return x;\n return GCD(x,y%x);\n}\n\ninline long long LCM (long long x,long long y) //lcm\u00ba\u00af\u00ca\u00fd\u00a3\u00ac\u00c7\u00f3\u00d7\u00ee\u00d0\u00a1\u00b9\u00ab\u00d4\u00bc\u00ca\u00fd\n{\n return x*y/GCD(x,y);\n}\n\ninline void pre() //\u00b3\u00f5\u00ca\u00bc\u00bb\u00af\u00d3\u00c3\u00b5\u00c4\u00ba\u00af\u00ca\u00fd\n{\n memset(f,-1,sizeof(f)); //\u00bd\u00abDP\u00ca\u00fd\u00d7\u00e9\u00b3\u00f5\u00ca\u00bc\u00bb\u00af\n int pos=0;\n for(int i=1;i<=P;i++) //\u00c0\u00eb\u00c9\u00a2\u00bb\u00af\u00a3\u00ac\u00bd\u00ab2520\u00b5\u00c4\u00d2\u00f2\u00ca\u00fd\u00c3\u00c7\u00b4\u00d31\u00bf\u00aa\u00ca\u00bc\u00b1\u00ea\u00bc\u00c7\n {\n if(P%i==0)\n {\n pos++;\n rnk[i]=pos;\n }\n }\n}\n\nlong long dfs(long long pos,long long he,long long lcm,long long sp) //\u00ca\u00fd\u00ce\u00bbDP\u00d6\u00f7\u00d2\u00aa\u00c4\u00da\u00c8\u00dd\n//pos:\u00b5\u00b1\u00c7\u00b0\u00b4\u00a6\u00c0\u00ed\u00b5\u00bd\u00b5\u00da\u00bc\u00b8\u00ce\u00bb\u00a3\u00bb \n//he\u00a3\u00bapos\u00ce\u00bb\u00d6\u00ae\u00c7\u00b0\u00b5\u00c4\u00ca\u00fd%2520\u00a3\u00bb\n//lcm\u00a3\u00bapos\u00ce\u00bb\u00d6\u00ae\u00c7\u00b0\u00b5\u00c4\u00ca\u00fd\u00b5\u00c4\u00c3\u00bf\u00d2\u00bb\u00ce\u00bb\u00ca\u00fd\u00b5\u00c4\u00d7\u00ee\u00d0\u00a1\u00b9\u00ab\u00b1\u00b6\u00ca\u00fd\u00a3\u00bb\n//sp\u00a3\u00ba\u00cc\u00d8\u00c5\u00d0\u00b5\u00b1\u00c7\u00b0\u00ca\u00c7\u00b7\u00f1\u00ce\u00aa\u00b7\u00b6\u00ce\u00a7\u00c4\u00da\u00b5\u00c4\u00d7\u00ee\u00b4\u00f3\u00d6\u00b5\n{\n if(pos==-1) return he%lcm==0; //\u00c8\u00e7\u00b9\u00fb\u00b4\u00a6\u00c0\u00ed\u00cd\u00ea\u00c1\u00cb\u00d7\u00ee\u00ba\u00f3\u00d2\u00bb\u00ce\u00bb\u00a3\u00ac\u00ca\u00fd\u00c8\u00e7\u00b9\u00fb\u00c2\u00fa\u00d7\u00e3\u00cc\u00f5\u00bc\u00fe\u00a3\u00ac\u00b7\u00b5\u00bb\u00d81\u00a3\u00ac\u00b7\u00f1\u00d4\u00f2\u00b7\u00b5\u00bb\u00d80\n if(sp==0&&f[pos][he][rnk[lcm]]!=-1) return f[pos][he][rnk[lcm]]; //\u00c8\u00e7\u00b9\u00fb\u00b2\u00bb\u00ca\u00c7\u00d7\u00ee\u00b4\u00f3\u00d6\u00b5\u00b5\u00c4\u00c7\u00e9\u00bf\u00f6\u00a3\u00ac\u00b2\u00a2\u00c7\u00d2\u00b5\u00b1\u00c7\u00b0\u00c7\u00e9\u00bf\u00f6\u00d2\u00d4\u00b4\u00a6\u00c0\u00ed\u00b9\u00fd\u00a3\u00ac\u00d6\u00b1\u00bd\u00d3\u00b7\u00b5\u00bb\u00d8\u00d6\u00b5\n long long ans=0;\n long long MAX=sp==1?nums[pos]:9; //\u00c8\u00e7\u00b9\u00fb\u00c7\u00b0\u00bc\u00b8\u00ce\u00bb\u00ca\u00c7\u00d7\u00ee\u00b4\u00f3\u00d6\u00b5\u00c7\u00e9\u00bf\u00f6\u00a3\u00ac\u00c4\u00c7\u00c3\u00b4\u00b5\u00b1\u00c7\u00b0\u00ce\u00bb\u00d7\u00ee\u00b4\u00f3\u00d6\u00b5\u00ce\u00aa\u00d5\u00e2\u00d2\u00bb\u00ce\u00bb\u00b5\u00c4\u00ca\u00fd\u00a3\u00ac\u00b7\u00f1\u00d4\u00f2\u00ce\u00aa9\n for(int i=0;i<=MAX;i++) //\u00b4\u00d30\u00c3\u00b6\u00be\u00d9\n {\n long long next_he=(he*10+i)%P; //\u00bc\u00c6\u00cb\u00e3\u00b0\u00fc\u00ba\u00ac\u00b5\u00b1\u00c7\u00b0\u00ce\u00bb\u00ca\u00b1\u00ca\u00fd\u00b5\u00c4\u00d6\u00b5\n long long next_lcm=lcm; \n if(i)\n {\n next_lcm=LCM(next_lcm,i);//\u00bc\u00c6\u00cb\u00e3\u00b0\u00fc\u00ba\u00ac\u00b5\u00b1\u00c7\u00b0\u00ce\u00bb\u00ca\u00b1\u00cb\u00f9\u00d3\u00d0\u00ce\u00bb\u00c9\u00cf\u00b5\u00c4\u00ca\u00fd\u00b5\u00c4\u00d7\u00ee\u00d0\u00a1\u00b9\u00ab\u00b1\u00b6\u00ca\u00fd\u00a3\u00a8\u00b5\u00b1\u00c7\u00b0\u00ce\u00bb\u00cb\u00f9\u00d1\u00a1\u00ca\u00fd\u00b2\u00bb\u00ce\u00aa0\u00a3\u00ac\u00c8\u00e7\u00b9\u00fb\u00ce\u00aa\u00c1\u00e3\u00be\u00cd\u00ca\u00c7\u00d4\u00ad\u00ca\u00fd\u00a3\u00a9\n }\n ans+=dfs(pos-1,next_he,next_lcm,sp&&i==MAX); //\u00cf\u00f2\u00cf\u00c2\u00cb\u00d1\u00cb\u00f7\u00a3\u00ac\u00c8\u00e7\u00b9\u00fb\u00c7\u00b0\u00bc\u00b8\u00ce\u00bb\u00ca\u00c7\u00d7\u00ee\u00b4\u00f3\u00d6\u00b5\u00c7\u00e9\u00bf\u00f6\u00a3\u00ac\u00b2\u00a2\u00c7\u00d2\u00b5\u00b1\u00c7\u00b0\u00ce\u00bb\u00ce\u00aa\u00d7\u00ee\u00b4\u00f3\u00d6\u00b5\u00ca\u00b1\u00a3\u00acsp=1\n }\n if(sp==0) //\u00c8\u00e7\u00b9\u00fb\u00b2\u00bb\u00ca\u00c7\u00d7\u00ee\u00b4\u00f3\u00d6\u00b5\u00c7\u00e9\u00bf\u00f6\u00a3\u00ac\u00bc\u00c7\u00c2\u00bc\u00d4\u00cb\u00cb\u00e3\u00bd\u00e1\u00b9\u00fb\n {\n f[pos][he][rnk[lcm]]=ans;\n }\n return ans;\n}\n\ninline long long solve (long long n) //\u00b4\u00a6\u00c0\u00ed\u00ca\u00fd\u00be\u00dd\u00bc\u00d3\u00c7\u00f3\u00d6\u00b5\u00ba\u00af\u00ca\u00fd\n{\n\n nums.clear(); //\u00d2\u00bb\u00b6\u00a8\u00d2\u00aa\u00bc\u00c7\u00b5\u00c3\u00c7\u00e5\u00bf\u00d5\n while(n) //\u00bd\u00ab\u00ca\u00fd\u00d6\u00b5\u00b0\u00b4\u00ce\u00aa\u00b4\u00e6\u00c8\u00eb\n {\n nums.push_back(n%10);\n n/=10;\n }\n return dfs(nums.size()-1,0,1,1); //\u00b4\u00d3\u00d7\u00ee\u00b8\u00df\u00ce\u00bb\u00bf\u00aa\u00ca\u00bc\u00cb\u00d1\u00cb\u00f7\n}\n\nlong long main ()\n{\n pre(); //\u00b3\u00f5\u00ca\u00bc\u00bb\u00af\n cin>>T;\n for(long long i=1;i<=T;i++)\n {\n cin>>l>>r;\n cout<\n\n\t\n\t\n\t\t\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2f1e6ed6175b237b2ea605d243b95e07", "src_uid": "37feadce373f728ba2a560b198ca4bc9", "difficulty": 2500.0} {"lang": "MS C++", "source_code": "//#pragma comment(linker, \"/STACK:206777216\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\ntypedef long long ll;\n\nusing namespace std;\ninline ll MAX(ll a, ll b) { return (a > b) ? (a) : (b); }\ninline ll MIN(ll a, ll b) { return (a < b) ? (a) : (b); }\n\n#define rep(i,a,b) for(i=a; i<=b; i++)\n#define brep(i,b,a) for(i=b; i>=a; i--)\n#define repitv(it,s) for (std::vector::iterator it = s.begin(); it != s.end(); it++)\n#define repitm(it,s) for (std::map::iterator it = s.begin(); it != s.end(); it++)\n#define repitmp(it,s) for (std::map,ll>::iterator it = s.begin(); it != s.end(); it++)\n#define repits(it,s) for (std::set::iterator it = s.begin(); it != s.end(); it++)\n#define repitsp(it,s) for (std::set>::iterator it = s.begin(); it != s.end(); it++)\n\n//stack > s;\n\nconst int mod = 1e9+7;\nconst ll sz = 5e3;\nll sbeg[sz] = {}, sbegmin[sz] = {}, send[sz] = {}, sendmin[sz] = {};\n\n//\n\nvoid prep(string s2)\n{\n\tll i;\n\tsbeg[sz] = {}; send[sz] = {};\n\n\tll l = s2.length();\n\n\tsbegmin[0] = 10000;\n\n\trep(i, 0, l - 1)\n\t{\n\t\tsbeg[i] = (i > 0 ? sbeg[i - 1] : 0);\n\n\t\tif (s2[i] == '(')\n\t\t\tsbeg[i] += 1;\n\t\telse\n\t\t\tsbeg[i] -= 1;\n\n\t\tsbegmin[i] = (i>0? MIN(sbeg[i], sbegmin[i - 1]): sbeg[i]);\n\n\t}\n\n\tbrep(i, l - 1, 0)\n\t{\n\t\tsend[i] = send[i + 1];\n\n\t\tif (s2[i] == '(')\n\t\t\tsend[i] += 1;\n\t\telse\n\t\t\tsend[i] -= 1;\n\n\t\tsendmin[i] = (i> l;\n\n\tcin >> s;\n\t\n\tstring s2;\n\tchar temp;\n\tll maxcnt = -1, maxi, maxj;\n\t\n\trep(i, 0, l - 1)\n\t{\n\t\trep(j, i, l - 1)\n\t\t{\n\t\t\tcnt = 0;\n\n\t\t\ts2 = s;\n\n\t\t\ttemp = s2[i];\n\t\t\ts2[i] = s2[j];\n\t\t\ts2[j] = temp;\n\n\t\t\tprep(s2);\n\n\t\t\trep(k, 0, l - 1)\n\t\t\t{\n\t\t\t\tif (sendmin[k] >= 0 && send[k] + (k > 0 ? sbegmin[k - 1] : 0) >= 0)\n\t\t\t\t\tcnt++;\n\n\t\t\t}\n\t\t\t\n\t\t\tif (cnt > maxcnt)\n\t\t\t{\n\t\t\t\tmaxcnt = cnt;\n\t\t\t\tmaxi = i; maxj = j;\n\t\t\t}\n\n\n\t\t}\n\n\t\t\n\t}\n\n\tcout << maxcnt<<\"\\n\"<\n#define pi acos(-1.0)\n#define ll long long\n#define lf double\n#define ull unsigned long long\n#define esp 1e-9\n#define inf 0x3f3f3f3f\n#define inff 0x3f3f3f3f3f3f3f3f\n#define Pair pair\n#define It set::iterator\n \nusing namespace std;\n\nconst ll N = 1e5+5, mod = 1e9+7;\nll n;\nstring str;\n\nint main(){\n ios::sync_with_stdio(false);\n cin>>n>>str;\n ll a = 0, b = 0;\n ll l = 1, r = 1, ans = 0;\n for (ll i = 0; i < n; i++){\n \tif (str[i] == '('){\n \t\ta++;\n\t\t}\n\t\telse{\n\t\t\tb++;\n\t\t}\n\t}\n\tif (a == b){\n\t\tfor (ll i = 0; i < n; i++){\n\t\t\tll tmp = 0, s;\n\t\t\tfor (ll k = 0; k < n; k++){\n\t\t\t\tif (str[k] == '('){\n\t\t\t\t\ts = k; break;\n\t\t\t\t}\n\t\t\t}\n\t\t\tll t = 0;\n\t\t\tstack stk;\n\t\t\tfor (ll cnt = 0; cnt < n; cnt++){\n\t\t\t\tll pos = (s+cnt)%n;\n\t\t\t\tif (str[pos] == '('){\n\t\t\t\t\tstk.push('(');\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tif (!stk.empty()){\n\t\t\t\t\t\tt++; stk.pop();\n\t\t\t\t\t\tif (stk.empty()){\n\t\t\t\t\t\t\ttmp++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (2*t == n){\n\t\t\t\tif (tmp > ans){\n\t\t\t\t\tans = tmp;\n\t\t\t\t\tl = i+1; r = j+1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (ll j = i+1; j < n; j++){\n\t\t\t\tif (str[i] != str[j]){\n\t\t\t\t\tswap(str[i], str[j]);\n\t\t\t\t\tll tmp = 0, s;\n\t\t\t\t\tfor (ll k = 0; k < n; k++){\n\t\t\t\t\t\tif (str[k] == '('){\n\t\t\t\t\t\t\ts = k; break;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tll t = 0;\n\t\t\t\t\tstack stk;\n\t\t\t\t\tfor (ll cnt = 0; cnt < n; cnt++){\n\t\t\t\t\t\tll pos = (s+cnt)%n;\n\t\t\t\t\t\tif (str[pos] == '('){\n\t\t\t\t\t\t\tstk.push('(');\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse{\n\t\t\t\t\t\t\tif (!stk.empty()){\n\t\t\t\t\t\t\t\tt++; stk.pop();\n\t\t\t\t\t\t\t\tif (stk.empty()){\n\t\t\t\t\t\t\t\t\ttmp++;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (2*t == n){\n\t\t\t\t\t\tif (tmp > ans){\n\t\t\t\t\t\t\tans = tmp;\n\t\t\t\t\t\t\tl = i+1; r = j+1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tswap(str[i], str[j]);\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\t\n\t}\n\tcout<\nusing namespace std;\nconst int N=505;\nchar s[N],s1[N];\nint a[N],n,ans,ans1=1,ans2=1,sa,sb;\n//()())(()\nint check(){\n\tint z=0,cnt=0,y=1,minz=0,i1;\n\tfor(int i=1;i<=n;i++){\n\t\tif(s[i]=='('){\n\t\t\tz++;\n\t\t}\n\t\telse {\n\t\t\tz--;\n\t\t\tif(z<0){\n\t\t\t\ty=0;\nif(zn){\n\t\t\t\t\t\tk1=k-n;\n\t\t\t\t\t}\n\t\t\t\t\ts1[k-i]=s[k1];\n\t\t\t\t}\n\t\t\t\n\n\tif(y==1){\n\t\tif(cnt>ans){\n\t\t\tans=cnt;\n\t\t\tans1=sa;ans2=sb;\n\t\t}\n\t}\n\telse {\n\t\tz=0;y=1;\n\t\tfor(int i=1;i<=n;i++){\n\t\t\tif(s1[i]=='('){\n\t\t\t\tz++;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tz--;\n\t\t\t\tif(z<0){\n\t\t\t\t\ty=0;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif(z==0){\n\t\t\t\t\tcnt++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t//cnt--;\n\t\tif(y==1){\n\t\t\tif(cnt>ans){\n\t\t\t\tans=cnt;\n\t\t\t\tans1=sa;ans2=sb;\n\t\t\t}\n\t\t}\n\t}\n}\nint main(){\n\tscanf(\"%d%s\",&n,s+1);\n\tint cnt11=0;\n\tfor(int i=1;i<=n;i++){\n\t\tif(s[i]=='('){\n\t\t\tcnt11++;\n\t\t}\n\t}\n\tif(cnt11!=n-cnt11){\n\t\tprintf(\"0\\n1 1\\n\");return 0;\n\t}\n\tfor(sa=1;sa<=n;sa++){\n\t\tfor(sb=1;sb<=n;sb++){\n\t\t\tchar t;\n\t\t\tt=s[sa];s[sa]=s[sb];s[sb]=t;\n\t\t\tcheck();\n\t\t\tt=s[sa];s[sa]=s[sb];s[sb]=t;\n\t\t}\n\t}\n\tprintf(\"%d\\n%d %d\\n\",ans,ans1,ans2);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7516d55fa9b1d027433ba3c37736d62c", "src_uid": "2d10668fcc2d8e90e102b043f5e0578d", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#include\n#include\n#include\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC optimize(\"unroll-loops\")\n#include // Common file\n#include \n#pragma GCC target(\"sse4\")\n#define pb push_back\n#define mp make_pair\n#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n#define ll long long\n#define pll pair\n#define vll vector\n#define all(a) (a).begin(),(a).end()\n#define ff first\n#define ss second\n#define sz(x) (ll)x.size()\n#define hell 1000000007\n#define repf(i,a,b) for(ll i=a;ib;i--)\n#define lbnd lower_bound\n#define ubnd upper_bound\n#define bs binary_search\n#define gcd(a,b) __gcd((a),(b))\n#define EPS 1e-12\n#define lcm(a,b) ((a)*(b))/__gcd((a),(b))\n#define sqrt sqrtl\n#define mod 1000000007\n#define cbrt cbrtl\nusing namespace __gnu_pbds;\nusing namespace std;\nll l,maxi,posl,posr;\nstring s;\nvoid check(ll l,ll r)\n{\n\tll i;\n\tint ans=0;\n\tint cnt=0\n\tfor(i=0;imaxi)\n\t{\n\t\tmaxi=ans;\n\t\tposl=l;\n\t\tposr=r;\n\t}\n}\nint main()\n{\n IOS\n cin>>l;\n ll i,j;\n maxi=0;\n posl=-1;posr=-1;\n for(i=0;i\nusing namespace std;\ntypedef long long ll;\nconst int maxn=150005;\nint n,m,k,in[maxn],dep[maxn],fa[maxn][19],st[maxn],ed[maxn],tim,sta[maxn],top;\nint rt[maxn],ls[maxn*40],rs[maxn*40],sum[maxn*40][2],sz; ll ans;\nvector g[maxn],gson[maxn];\nstruct path { int x,y,z,a,b; } e[maxn];\nvector h[maxn];\nstruct chain { int x,y,b; };\nvector w[maxn],t[maxn];\nvoid dfs1(int x,int ff)\n{\n\tfa[x][0]=ff,dep[x]=dep[ff]+1,st[x]=++tim;\n\tfor(int i=1;i<=18;i++) fa[x][i]=fa[fa[x][i-1]][i-1];\n\tfor(int i=0;i<(int)g[x].size();i++)\n\t\tif(g[x][i]!=ff) dfs1(g[x][i],x);\n\ted[x]=tim;\n}\ninline void add_path(int x,int y,int &z,int &a,int &b)\n{\n\tif(dep[x]=0;i--)\n\t\tif(dep[fa[x][i]]>dep[y]) x=fa[x][i];\n\tif(fa[x][0]==y) { z=y,a=x,b=0; return; }\n\tif(dep[x]>dep[y]) x=fa[x][0];\n\tfor(int i=18;i>=0;i--)\n\t\tif(fa[x][i]!=fa[y][i]) x=fa[x][i],y=fa[y][i];\n\tz=fa[x][0],a=x,b=y;\n}\ninline int LCA(int x,int y)\n{\n\tif(dep[x]=0;i--)\n\t\tif(dep[fa[x][i]]>=dep[y]) x=fa[x][i];\n\tif(x==y) return x;\n\tfor(int i=18;i>=0;i--)\n\t\tif(fa[x][i]!=fa[y][i]) x=fa[x][i],y=fa[y][i];\n\treturn fa[x][0];\n}\nvoid update(int &rt,int l,int r,int u,int v,int z)\n{\n//\tprintf(\"%d %d\\n\",u,v);\n\tif(!rt) rt=++sz,ls[rt]=rs[rt]=sum[rt][0]=sum[rt][1]=0;\n\tsum[rt][z]+=v;\n\tif(l==r) return;\n\tint mid=(l+r)>>1;\n\tif(u<=mid) update(ls[rt],l,mid,u,v,z);\n\telse update(rs[rt],mid+1,r,u,v,z);\n}\nint query(int rt,int l,int r,int x,int y,int z)\n{\n\tif(!rt) return 0;\n\tif(x<=l && r<=y) return sum[rt][z];\n\tint mid=(l+r)>>1,ans=0;\n\tif(x<=mid) ans+=query(ls[rt],l,mid,x,y,z);\n\tif(y>mid) ans+=query(rs[rt],mid+1,r,x,y,z);\n\treturn ans;\n}\nint merge(int x,int y)\n{\n\tif(!x || !y) return x|y;\n\tsum[x][0]+=sum[y][0];\n\tsum[x][1]+=sum[y][1];\n\tls[x]=merge(ls[x],ls[y]);\n\trs[x]=merge(rs[x],rs[y]);\n\treturn x;\n}\ninline int jump(int x,int k)\n{\n\tk=dep[x]-k;\n\tfor(int i=18;i>=0;i--)\n\t\tif(dep[fa[x][i]]>=k) x=fa[x][i];\n\treturn x;\n}\ninline void calc(int x,int k,int rt)\n{\n\tif(k<0) return;\n\tint a=jump(x,k);\n\tans+=query(rt,1,n,st[a],ed[a],0);\n}\nvoid dfs2(int x)\n{\n//\tprintf(\"dfs2 %d\\n\",x);\n\tfor(int i=0,y;i<(int)g[x].size();i++)\n\t\tif(g[x][i]!=fa[x][0]) y=g[x][i],dfs2(y),rt[x]=merge(rt[x],rt[y]);\n\tvector::iterator it;\n\tfor(it=h[x].begin();it!=h[x].end();it++)\n\t{\n\t\tupdate(rt[x],1,n,st[it->x],-1,0);\n\t\tif(it->y!=x) update(rt[x],1,n,st[it->y],-1,0);\n\t}\n\tfor(it=h[x].begin();it!=h[x].end();it++)\n\t{\n\t\tcalc(it->x,dep[it->x]-dep[x]-k,rt[x]);\n\t\tif(it->y>0) calc(it->y,dep[it->y]-dep[x]-k,rt[x]);\n\t}\n\tif(in[x]) update(rt[x],1,n,st[x],in[x],0);\n}\nvoid dfs3(int x,int anc)\n{\n\tvector::iterator it;\n\tif(dep[x]-dep[anc]>=k)\n\t{\t\n\t\tans+=(ll)t[x].size()*((ll)t[x].size()-1)/2;\n\t\tint sz=0;\n\t\tfor(it=t[x].begin();it!=t[x].end();it++)\n\t\t{\n\t\t\tupdate(rt[x],1,n,st[it->y],1,0);\n\t\t\tans+=sz-(it->b?query(rt[x],1,n,it->b,it->b,1):0);\n\t\t\tif(it->b) update(rt[x],1,n,it->b,1,1);\n\t\t\tsz++;\n\t\t}\n\t}\n\telse\n\t{\n\t\tfor(it=t[x].begin();it!=t[x].end();it++)\n\t\t\tcalc(it->y,dep[it->y]-dep[anc]-(k-(dep[x]-dep[anc])),rt[x]),update(rt[x],1,n,st[it->y],1,0);\n\t}\n\tfor(int i=0;i<(int)gson[x].size();i++)\n\t{\n\t\tint y=gson[x][i]; dfs3(y,anc);\n\t\tif((int)t[x].size()<(int)t[y].size()) swap(t[x],t[y]),swap(rt[x],rt[y]);\n\t\tif(dep[x]-dep[anc]>=k)\n\t\t{\n\t\t\tans+=(ll)t[x].size()*(ll)t[y].size();\n\t\t\tfor(it=t[y].begin();it!=t[y].end();it++)\n\t\t\t\tans+=((ll)t[x].size()-(it->b?query(rt[x],1,n,it->b,it->b,1):0));\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfor(it=t[y].begin();it!=t[y].end();it++)\n\t\t\t\tcalc(it->y,dep[it->y]-dep[anc]-(k-(dep[x]-dep[anc])),rt[x]);\n\t\t}\n\t\trt[x]=merge(rt[x],rt[y]);\n\t\tfor(it=t[y].begin();it!=t[y].end();it++)\n\t\t\tt[x].push_back(*it);\n\t\trt[y]=0;\n\t\tvector().swap(t[y]);\n\t\tmap().swap(mp[y]);\n\t}\n\tvector().swap(gson[x]);\n//\tprintf(\"dfs3 %d %lld\\n\",x,ans);\n}\ninline bool cmp(const int &x,const int &y) { return st[x]::iterator it;\n\tstatic int q[maxn]; int tot=0;\n\tfor(it=w[x].begin();it!=w[x].end();it++) q[++tot]=it->x;\n\tsort(q+1,q+tot+1,cmp);\n\tfor(int i=1;i<=tot;i++)\n\t{\n\t\tint lca=LCA(sta[top],q[i]);\n\t\twhile(dep[lca]x].push_back(*it);\n\tsz=0,dfs3(x,anc),rt[x]=0;\n\tvector().swap(t[x]);\n\tmap().swap(mp[x]);\n//\tcout<::iterator it=\n\t\th[i].begin();it!=h[i].end();it++)\n\t\t{\n\t\t\tif(!it->b) w[it->a].push_back((chain){it->x,it->y,0});\n\t\t\telse w[it->a].push_back((chain){it->x,it->y,it->b}),w[it->b].push_back((chain){it->y,it->x,it->a});\n\t\t}\n\t\tfor(int j=0;j<(int)g[i].size();j++)\n\t\t\tif(g[i][j]!=fa[i][0]) solve(g[i][j],i);\n\t}\n\tprintf(\"%lld\\n\",ans/2);\n\treturn 0;\n}\n/*\n7 2 4\n1 2\n2 3\n1 4\n4 5\n1 6\n6 7\n5 1\n5 2\n*/", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1a22f06c429eac2d83311564113c8726", "src_uid": "6253b155201f2490f031613188b9820c", "difficulty": 3500.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n\nusing ll = long long;\n\nconst int MN=1.5e5+10;\nconst int MS=3e7;\nint N, M, K, d[MN], p[MN][20], vp[MN], pre[MN], post[MN], rm[MN], top, nd[MN], ctr, tot, t[MN], e[MN];\nstd::vector up[MN], a[MN], b[MN], c[MN], pts, g[MN];\nll ans1, ans2, ans3;\nstruct QRY{public: int a, b;};\nstd::vector q[MN];\n\nvoid dfs(int n=1)\n{\n\tpre[n] = ctr++;\n\tfor(int i=0;p[n][i]&&p[p[n][i]][i];++i)\n\t\tp[n][i+1]=p[p[n][i]][i];\n\tfor(int x:a[n])\n\t\tif(x!=p[n][0])\n\t\t\tp[x][0]=n,d[x]=d[n]+1,dfs(x);\n\tpost[n] = ctr;\n}\nint mu(int x, int d)\n{\n\tfor(int i=0;d;d>>=1,++i)\n\t\tif(d&1)\n\t\t\tx=p[x][i];\n\treturn x;\n}\nint lca(int x, int y)\n{\n\tif(d[y]=0;--i)\n\t\tif(p[x][i]!=p[y][i])\n\t\t\tx=p[x][i],y=p[y][i];\n\treturn p[x][0];\n}\nbool anc(int x, int y) {return pre[x]<=pre[y] && post[y]<=post[x];}\nint bit[MN];\nvoid chg(int x, int v)\n{\n\tfor(++x;x<=N;x+=-x&x)\n\t\tbit[x-1]+=v;\n\ttot+=v;\n}\nint cnt(int x)\n{\n\tint f=0;\n\tfor(++x;x>0;x-=-x&x)\n\t\tf+=bit[x-1];\n\treturn f;\n}\nint cnt2(int x) {return cnt(x)-cnt(x-1);}\nvoid dfs1(int n=1)\n{\n\tif(d[n]>=K)\n\t\tfor(int x:up[n])\n\t\t\tans1 += tot-cnt(x-1), chg(d[n]-K, 1);\n\tfor(int x:a[n])\n\t\tif(x!=p[n][0])\n\t\t\tdfs1(x);\n\tif(d[n]>=K)\n\t{\n\t\tint vk = cnt2(d[n]-K);\n\t\tchg(d[n]-K, -vk);\n\t\tvk -= rm[n];\n\t\tassert(vk >= 0);\n\t\tif(d[n]==K) assert(!vk);\n\t\tif(vk) chg(d[n]-K-1, vk);\n\t}\n}\nstruct stn\n{\npublic:\n\tint c[2], v;\n\tstn() {c[0]=c[1]=-1; v=0;}\n} st[MS];\nint X;\nvoid upd(int *n, int l, int r, int q, int v)\n{\n\tif(!~*n) *n=X++;\n\tif(r-l>1)\n\t{\n\t\tint m=l+(r-l)/2;\n\t\tif(q= K) o=mu(x, d[x]-top-1);\n\t\telse o=mu(x, d[x]+d[n]-2*top-K);\n\t\tans2 += qry(nd[n], 0, N, pre[o], post[o]);\n\t\tupd(nd+n, 0, N, pre[x], 1);\n\t\tg[n].push_back(x);\n\t}\n\tfor(int y:b[n])\n\t{\n\t\tt[y]=t[n];\n\t\tdfs2(y);\n\t\tif(g[n].size()= K) o=mu(x, d[x]-top-1);\n\t\t\telse o=mu(x, d[x]+d[n]-2*top-K);\n\t\t\tans2 += qry(nd[n], 0, N, pre[o], post[o]);\n\t\t\tupd(nd+n, 0, N, pre[x], 1);\n\t\t\tg[n].push_back(x);\n\t\t}\n\t\tg[y].clear(), nd[y]=-1;\n\t}\n}\nvoid dfs3(int n)\n{\n\tif(d[n]-top>=K)\n\t\tfor(int x:c[n])\n\t\t{\n\t\t\tint o=mu(n, d[n]-top-K);//can be optimized but at this point its not the bottleneck\n\t\t\tans3 += qry(e[0], 0, N, pre[o], post[o]), upd(e, 0, N, pre[n], 1);\n\t\t\tif(t[x]) ans3 -= qry(e[t[x]], 0, N, pre[o], post[o]), upd(e+t[x], 0, N, pre[n], 1);\n\t\t}\n\tfor(int x:b[n])\n\t\tdfs3(x);\n}\nint main(void)\n{\n\tmemset(nd, -1, sizeof nd);\n\tmemset(e, -1, sizeof e);\n\tscanf(\"%d%d%d\", &N, &M, &K);\n\tfor(int i=0,x,y;i+1=K) up[x].push_back(d[z]), ++rm[mu(x, d[x]-d[z]-K)];\n\t\tif(d[y]-d[z]>=K) up[y].push_back(d[z]), ++rm[mu(y, d[y]-d[z]-K)];\n\t\tq[z].push_back({x,y});\n\t}\n\tdfs1();\n\tfor(int i=1;i<=N;++i) ans1 -= (ll)rm[i]*(rm[i]-1)/2;\n\t//printf(\"STRAIGHT (not counting same lca): %lld\\n\", ans1);\n\tfor(int i=1;i<=N;++i)\n\t\tif(!q[i].empty())\n\t\t{\n\t\t\ttop=d[i];\n\t\t\tfor(auto x:q[i])\n\t\t\t\tpts.push_back(x.a), pts.push_back(x.b);\n\t\t\tstd::sort(pts.begin(), pts.end(), [](int a, int b){return pre[a]0;--i)\n\t\t\t\tpts.push_back(lca(pts[i-1], pts[i]));\n\t\t\tstd::sort(pts.begin(), pts.end(), [](int a, int b){return pre[a]=K)\n\t\t\t\t\tfor(int y:c[x])\n\t\t\t\t\t{\n\t\t\t\t\t\tupd(e, 0, N, pre[x], -1);\n\t\t\t\t\t\tif(t[y]) upd(e+t[y], 0, N, pre[x], -1);\n\t\t\t\t\t}\n\t\t\t\tb[x].clear(), c[x].clear(), vp[x]=0;\n\t\t\t}\n\t\t\tfor(int x:pts) t[x]=0;\n\t\t\tpts.clear();\n\t\t}\n\t//printf(\"Breakdown: %lld %lld/2 %lld\\n\", ans1, ans2, ans3);\n\tprintf(\"%lld\\n\", ans1+ans2/2+ans3);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "78931494ade757f427ad80ffb4705f5a", "src_uid": "6253b155201f2490f031613188b9820c", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define int long long\nconst int N=2e5+7,M=20,K=1e7+7; long long ans,sum; vectorv[N],qt[N],vw[N],vt[N];\nint n,m,k,kt,rt,opt,tot,fa[N],ft[N],dep[N],siz[N],rq[N],dfa[N],dfb[N],res[N],e[N][M],pt[N<<1],gt[N],ch[K][2],va[K];\nstruct query {int u,v,t;}f[N];\ninline void dfs(int u){\n\te[u][0]=fa[u],dfa[u]=dfb[u]=++opt,ft[opt]=u;\n\tfor(int i=1;i<=18;i++) e[u][i]=e[e[u][i-1]][i-1];\n\tfor(int i=0;i=0;i--) if((1<=0;i--) if(e[u][i]!=e[t][i]) u=e[u][i],t=e[t][i]; return fa[u];\n}\ninline int jmp(int u,int t){\n\tfor(int i=18;i>=0;i--) if((1<0) ans+=res[u],u-=lowbit(u); return ans;\n}\ninline bool cmp(query a,query b){\n\treturn dfa[a.t]>1;\n\tch[u][0]=merge(ch[u][0],ch[t][0],l,d);\n\tch[u][1]=merge(ch[u][1],ch[t][1],d+1,r);\n\tva[u]=va[ch[u][0]]+va[ch[u][1]]; return u;\n}\ninline int getans(int l,int r,int t,int ql,int qr){\n\tif(l==ql&&r==qr) return va[t]; int d=(l+r)>>1; int sum=0;\n\tif(ql<=d&&ch[t][0]) sum+=getans(l,d,ch[t][0],ql,min(d,qr));\n\tif(d+1<=qr&&ch[t][1]) sum+=getans(d+1,r,ch[t][1],max(d+1,ql),qr);\n\treturn sum;\n}\ninline void getval(int u,int t,int l,int r){\n\tif(l==r){\n\t\tint z=u; u=ft[l];\n\t\tif(dep[u]-dep[rt]>=kt){\n\t\t\tu=jmp(u,dep[u]-dep[rt]-kt);\n\t\t\tsum=sum+1ll*getans(1,n,t,dfa[u],dfb[u])*va[z];\n\t\t}\n\t\treturn;\n\t}\n\tint d=(l+r)>>1;\n\tif(ch[u][0]) getval(ch[u][0],t,l,d);\n\tif(ch[u][1]) getval(ch[u][1],t,d+1,r);\n}\ninline void addx(int l,int r,int t,int s){\n\tif(l==r){\n\t\tva[t]++; return;\n\t}\n\tint d=(l+r)>>1;\n\tif(s<=d){\n\t\tif(!ch[t][0]) ch[t][0]=++tot;\n\t\taddx(l,d,ch[t][0],s);\n\t}\n\telse{\n\t\tif(!ch[t][1]) ch[t][1]=++tot;\n\t\taddx(d+1,r,ch[t][1],s);\n\t}\n\tva[t]=va[ch[t][0]]+va[ch[t][1]];\n}\ninline void dft(int u){\n//\tif(rt==11) cout<siz[u]) swap(siz[u],siz[x]),swap(rq[u],rq[x]);\n//\t\tcout<=kt){\n\t\t\tint z=jmp(x,dep[x]-dep[rt]-kt);\n//\t\t\tcout<>n>>m>>k; int u,t;\n\tfor(int i=1;i>1;\n \t\tif(dfa[f[d].t]>1;\n \t\tif(dfa[f[d].t]<=dfb[f[i].t]) pos=d,l=d+1; else r=d-1;\n\t\t}\n//\t\tcout<=k){\n\t\t\t\t\tint z=jmp(f[c].u,dep[f[c].u]-dep[f[c].t]-k);\n//\t\t\t\t\tcout<=k){\n\t\t\t\t\tint z=jmp(f[c].v,dep[f[c].v]-dep[f[c].t]-k);\n//\t\t\t\t\tcout<=k){\n\t\t\t\t\tint z=jmp(f[c].u,dep[f[c].u]-dep[f[c].t]-k);\n//\t\t\t\t\tcout<=k){\n\t\t\t\t\tint z=jmp(f[c].v,dep[f[c].v]-dep[f[c].t]-k);\n//\t\t\t\t\tcout<=k){\n\t\t\tint z=jmp(f[c].u,dep[f[c].u]-dep[f[c].t]-k);\n//\t\t\tcout<=k){\n\t\t\tint z=jmp(f[c].v,dep[f[c].v]-dep[f[c].t]-k);\n//\t\t\tcout<=dep[c]){\n\t\t\t\t\tvw[gt[len-1]].push_back(gt[len]);\n//\t\t\t\t\tcout<\nusing namespace std;\ntypedef long long ll;\nconst int maxn=150005;\nint n,m,k,in[maxn],dep[maxn],fa[maxn][19],st[maxn],ed[maxn],tim,sta[maxn],top;\nint rt[maxn],ls[maxn*20],rs[maxn*20],sum[maxn*20],sz; ll ans;\nvector g[maxn],gson[maxn];\nstruct path { int x,y,z,a,b; } e[maxn];\nvector h[maxn];\nstruct chain { int x,y,b; };\nvector w[maxn],t[maxn];\nmap mp[maxn];\nvoid dfs1(int x,int ff)\n{\n\tfa[x][0]=ff,dep[x]=dep[ff]+1,st[x]=++tim;\n\tfor(int i=1;i<=18;i++) fa[x][i]=fa[fa[x][i-1]][i-1];\n\tfor(int i=0;i<(int)g[x].size();i++)\n\t\tif(g[x][i]!=ff) dfs1(g[x][i],x);\n\ted[x]=tim;\n}\ninline void add_path(int x,int y,int &z,int &a,int &b)\n{\n\tif(dep[x]=0;i--)\n\t\tif(dep[fa[x][i]]>dep[y]) x=fa[x][i];\n\tif(fa[x][0]==y) { z=y,a=x,b=0; return; }\n\tif(dep[x]>dep[y]) x=fa[x][0];\n\tfor(int i=18;i>=0;i--)\n\t\tif(fa[x][i]!=fa[y][i]) x=fa[x][i],y=fa[y][i];\n\tz=fa[x][0],a=x,b=y;\n}\ninline int LCA(int x,int y)\n{\n\tif(dep[x]=0;i--)\n\t\tif(dep[fa[x][i]]>=dep[y]) x=fa[x][i];\n\tif(x==y) return x;\n\tfor(int i=18;i>=0;i--)\n\t\tif(fa[x][i]!=fa[y][i]) x=fa[x][i],y=fa[y][i];\n\treturn fa[x][0];\n}\nvoid update(int &rt,int l,int r,int u,int v)\n{\n//\tprintf(\"%d %d\\n\",u,v);\n\tif(!rt) rt=++sz,ls[rt]=rs[rt]=sum[rt]=0;\n\tsum[rt]+=v;\n\tif(l==r) return;\n\tint mid=(l+r)>>1;\n\tif(u<=mid) update(ls[rt],l,mid,u,v);\n\telse update(rs[rt],mid+1,r,u,v);\n}\nint query(int rt,int l,int r,int x,int y)\n{\n\tif(!rt) return 0;\n\tif(x<=l && r<=y) return sum[rt];\n\tint mid=(l+r)>>1,ans=0;\n\tif(x<=mid) ans+=query(ls[rt],l,mid,x,y);\n\tif(y>mid) ans+=query(rs[rt],mid+1,r,x,y);\n\treturn ans;\n}\nint merge(int x,int y)\n{\n\tif(!x || !y) return x|y;\n\tsum[x]+=sum[y];\n\tls[x]=merge(ls[x],ls[y]);\n\trs[x]=merge(rs[x],rs[y]);\n\treturn x;\n}\ninline int jump(int x,int k)\n{\n\tk=dep[x]-k;\n\tfor(int i=18;i>=0;i--)\n\t\tif(dep[fa[x][i]]>=k) x=fa[x][i];\n\treturn x;\n}\ninline void calc(int x,int k,int rt)\n{\n\tif(k<0) return;\n\tint a=jump(x,k);\n\tans+=query(rt,1,n,st[a],ed[a]);\n}\nvoid dfs2(int x)\n{\n//\tprintf(\"dfs2 %d\\n\",x);\n\tfor(int i=0,y;i<(int)g[x].size();i++)\n\t\tif(g[x][i]!=fa[x][0]) y=g[x][i],dfs2(y),rt[x]=merge(rt[x],rt[y]);\n\tvector::iterator it;\n\tfor(it=h[x].begin();it!=h[x].end();it++)\n\t{\n\t\tupdate(rt[x],1,n,st[it->x],-1);\n\t\tif(it->y!=x) update(rt[x],1,n,st[it->y],-1);\n\t}\n\tfor(it=h[x].begin();it!=h[x].end();it++)\n\t{\n\t\tcalc(it->x,dep[it->x]-dep[x]-k,rt[x]);\n\t\tif(it->y>0) calc(it->y,dep[it->y]-dep[x]-k,rt[x]);\n\t}\n\tif(in[x]) update(rt[x],1,n,st[x],in[x]);\n}\nvoid dfs3(int x,int anc)\n{\n\tvector::iterator it;\n\tif(dep[x]-dep[anc]>=k)\n\t{\t\n\t\tans+=(ll)t[x].size()*((ll)t[x].size()-1)/2;\n\t\tint sz=0;\n\t\tfor(it=t[x].begin();it!=t[x].end();it++)\n\t\t{\n\t\t\tupdate(rt[x],1,n,st[it->y],1);\n\t\t\tans+=sz-(it->b?mp[x][it->b]:0),mp[x][it->b]++,sz++;\n\t\t}\n\t}\n\telse\n\t{\n\t\tfor(it=t[x].begin();it!=t[x].end();it++)\n\t\t\tcalc(it->y,dep[it->y]-dep[anc]-(k-(dep[x]-dep[anc])),rt[x]),update(rt[x],1,n,st[it->y],1);\n\t}\n\tfor(int i=0;i<(int)gson[x].size();i++)\n\t{\n\t\tint y=gson[x][i]; dfs3(y,anc);\n\t\tif(dep[x]-dep[anc]>=k)\n\t\t{\n\t\t\tans+=(ll)t[x].size()*(ll)t[y].size();\n//\t\t\tcout<::iterator it=mp[y].begin();it!=mp[y].end();it++)\n\t\t\t\tans+=(ll)it->second*((ll)t[x].size()-(it->first?mp[x][it->first]:0));\n//\t\t\t\tcout<::iterator it=mp[y].begin();it!=mp[y].end();it++)\n\t\t\t\tmp[x][it->first]+=it->second;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif((int)t[x].size()<(int)t[y].size()) swap(t[x],t[y]),swap(rt[x],rt[y]);\n\t\t\tfor(it=t[y].begin();it!=t[y].end();it++)\n\t\t\t\tcalc(it->y,dep[it->y]-dep[anc]-(k-(dep[x]-dep[anc])),rt[x]);\n\t\t}\n\t\trt[x]=merge(rt[x],rt[y]);\n\t\tfor(it=t[y].begin();it!=t[y].end();it++)\n\t\t\tt[x].push_back(*it);\n\t\trt[y]=0,t[y].clear(),mp[y].clear();\n\t}\n\tgson[x].clear();\n//\tprintf(\"dfs3 %d %lld\\n\",x,ans);\n}\ninline bool cmp(const int &x,const int &y) { return st[x]::iterator it;\n\tstatic int q[maxn]; int tot=0;\n\tfor(it=w[x].begin();it!=w[x].end();it++) q[++tot]=it->x;\n\tsort(q+1,q+tot+1,cmp);\n\tfor(int i=1;i<=tot;i++)\n\t{\n\t\tint lca=LCA(sta[top],q[i]);\n\t\twhile(dep[lca]x].push_back(*it);\n\tsz=0,dfs3(x,anc),rt[x]=0,t[x].clear(),mp[x].clear();\n//\tcout<::iterator it=\n\t\th[i].begin();it!=h[i].end();it++)\n\t\t{\n\t\t\tif(!it->b) w[it->a].push_back((chain){it->x,it->y,0});\n\t\t\telse w[it->a].push_back((chain){it->x,it->y,it->b}),w[it->b].push_back((chain){it->y,it->x,it->a});\n\t\t}\n\t\tfor(int j=0;j<(int)g[i].size();j++)\n\t\t\tif(g[i][j]!=fa[i][0]) solve(g[i][j],i);\n\t}\n\tprintf(\"%lld\\n\",ans/2);\n\treturn 0;\n}\n/*\n7 2 4\n1 2\n2 3\n1 4\n4 5\n1 6\n6 7\n5 1\n5 2\n*/", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6a4ca5826131c057c6577cc2ec48f3cd", "src_uid": "6253b155201f2490f031613188b9820c", "difficulty": 3500.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint main(){\n\tint n,m[3],x;\n\tmemset(m,0,sizeof(m));\n cin>>n;\n for(int i=0;i>x;\n\t\tm[i%3]+=x;//\u5bf9\u4e8e\u6570\u7ec4\u6211\u4eec\u53ef\u4ee5\u505a\u7684\u6709\u5f88\u591a\u8fd0\u7b97 \n cout<<(m[0]>m[1]&&m[0]>m[2]?\"chest\":m[1]>m[2]?\"biceps\":\"back\")<<\"\\n\";\n return 0;\n}\n /*if(a[0]>a[1]&&a[0]>a[2])\n\t\tcout<<\"chest\";\n\telse if(a[1]>a[2]&&a[1]>a[0])\n\t\tcout<<\"biceps\";\n\telse\n\t\tcout<<\"back\";\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a6bd5bd8265b965f51ec52b546620a3b", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main()\n{\n int n, s1 = 0, s2 = 0, s3 = 0, mn = 0, mx = 0;\n cin >> n;\n int a[n];\n for(int i = 1; i <= n; ++i)\n cin >> a[i];\n for(int i = 1; i <= n; ++i){\n if (i % 3 == 1)\n s1 += a[i];\n if (i % 3 == 2)\n s2 += a[i];\n if (i % 3 == 0)\n s3 += a[i];\n }\n mx = max({s1, s2, s3});\n if (mx == s1)\n cout << \"chest\" << \" \"; else\n if (mx == s2)\n cout << \"biceps\" << \" \"; else\n cout << \"back\" << \" \";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8691bdc867336a751a451f61d4dc5a75", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nint Max(long long Arr[], int size = 3)\n{\n\tlong max = 0;\n\tlong long saver = 0;\n\tfor (size_t i = 0; i < size; i++)\n\t{\n\t\tif (max < Arr[i])\n\t\t{\n\t\t\tmax = Arr[i];\n\t\t\tsaver = i;\n\t\t}\n\t}\n\n\treturn saver;\n\t\n}\n\n\nvoid Answ(long long *Arr, long long number, long long ArrayOfSum[])\n{\n\tlong long SumBic = 0;\n\tlong long SumChest = 0;\n\tlong long SumBack = 0;\n\tfor (size_t i = 0; i < number; i++)\n\t{\n\t\tif (i == 0 || i % 3 == 0)\n\t\t\tSumChest = SumChest + *(Arr + i);\n\t\tif (i == 1 || i % 3 == 1)\n\t\t\tSumBic = SumBic + *(Arr + i);\n\t\tif (i == 3 || i % 3 == 2)\n\t\t\tSumBack = SumBack + *(Arr + i);\n\t}\n\n\tArrayOfSum[0] = SumChest;\n\tArrayOfSum[1] = SumBic;\n\tArrayOfSum[2] = SumBack;\n\n\tlong long max = Max(ArrayOfSum);\n\n\tif (max == 0)\n\t\tcout << \"chest\";\n\telse if (max == 1)\n\t\tcout << \"biceps\";\n\telse\n\t\tcout << \"back\";\n}\n\nvoid FillArr(long long *Arr, long long size)\n{\n\tfor (size_t i = 0; i < size; i++)\n\t{\n\t\tcin >> *(Arr + i);\n\t}\n}\n\nint main()\n{\n\tlong long number;\n\tcin >> number;\n\tif (number == 0)\n\t\treturn 1;\n\n\tlong int *Array = long int[number];\n\n\tFillArr(Array, number);\n\n\tconst int size = 3;\n\tlong int sumof[size];\n\tAnsw(Array, number, sumof);\n\n\n\n\n\n\n\n\n\n\n\tcin.get();\n\tcin.get();\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8f652470d065c3bb94e649e4fbf261b8", "src_uid": "579021de624c072f5e0393aae762117e", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint n,a;\nint b[101];\ninr main(){\n\tcin>>n:\n\t\tfor(int i=1;i<=n;i++){\n\t\t\tcin>>a;\n\t\t\tfor(int i=1;i<=a;i++){\n\t\t\t\tb[a%3+1]++;\n\t\t\t}\n\t\t}\n\t\tcout<\n#include \n#include \nusing namespace std;\n\n#define forn(i, n) for(int i = 0; i < int(n); ++i)\n#define forv(i, v) forn(i, v.size())\n\nvector ans;\nconst int N = 6;\nint a[N][N];\n\nenum Orientation{Vertical, Horizontal};\nenum Direction{Forward, Backward};\n\nvoid addAnswer(int pos, char dir)\n{\n ans.push_back(string(1,dir) + string(1,'0'+pos+1));\n}\n\nvoid rotateyf(int y) \n{\n int t = a[N-1][y];\n for(int i = N - 1; i > 0; --i) a[i][y] = a[i - 1][y];\n a[0][y] = t;\n}\n\nvoid rotateyb(int y) \n{\n int t = a[0][y];\n for(int i = 0; i < N - 1; ++i) a[i][y] = a[i + 1][y];\n a[N - 1][y] = t;\n}\n\nvoid rotatexf(int x)\n{\n int t = a[x][N-1];\n for(int i = N-1; i > 0; --i) a[x][i] = a[x][i-1];\n a[x][0] = t;\n}\n\nvoid rotatexb(int x)\n{\n int t = a[x][0];\n for(int i = 0; i < N-1; ++i) a[x][i] = a[x][i+1];\n a[x][N-1] = t;\n}\n\nvoid rotate(int x, int y, Orientation o, Direction d)\n{\n if (o == Vertical) {\n if (d == Forward) {\n rotateyf(y);\n addAnswer(y, 'D');\n }\n else {\n rotateyb(y);\n addAnswer(y, 'U');\n }\n }\n else {\n if (d == Forward) {\n rotatexf(x);\n addAnswer(x, 'R');\n }\n else {\n rotatexb(x);\n addAnswer(x, 'L');\n }\n }\n}\n\nvoid rotate(int x, int y, int i, int j) \n{\n if (x == i) {\n Direction d = Forward;\n if (y > j) d = Backward;\n for(int it = 0; it < abs(y - j); ++it) {\n rotate(x, y, Horizontal, d);\n }\n } \n else {\n assert(y == j);\n Direction d = Forward;\n if (x > i) d = Backward;\n for(int it = 0; it < abs(x - i); ++it) {\n rotate(x, y, Vertical, d);\n }\n }\n}\n\nvoid read()\n{\n // freopen(\"input.txt\", \"rt\", stdin);\n for(int i = 0; i < 6; ++i) {\n string s; cin >> s;\n for(size_t j = 0; j < s.size(); ++j) {\n if (isdigit(s[j])) a[i][j] = s[j] - '0';\n else a[i][j] = s[j] - 'A' + 10;\n }\n }\n}\n\nvoid print()\n{\n forn(i, N) {\n forn(j, N) {\n cout << a[i][j];\n if (j < N-1) cout << \",\";\n }\n cout << endl;\n }\n}\n\nvoid rotatecw(int y)\n{\n rotate(N-1, y+1, Vertical, Forward);\n rotate(N-1, y, Horizontal, Forward);\n rotate(N-1, y+1, Vertical, Backward);\n rotate(N-1, y, Horizontal, Backward);\n}\n\nvoid rotatecc(int y)\n{\n rotate(N-1, y, Vertical, Forward);\n rotate(N-1, y, Horizontal, Backward);\n rotate(N-1, y, Vertical, Backward);\n rotate(N-1, y, Horizontal, Forward);\n}\n\nvoid rotate(int y) \n{\n rotatecw(y);\n rotatecw(y);\n rotatecc(y+1);\n rotatecw(y);\n}\n\nvoid find(int val, int& x, int& y)\n{\n forn(i, N) forn(j, N) if (a[i][j] == val) {\n x = i;\n y = j;\n return;\n }\n}\n\nint find(int val)\n{\n forn(j, N) if (a[N-1][j] == val) return j;\n assert(false);\n}\n\nint main()\n{\n// forn(i, N) forn(j, N) a[i][j] = i * N + j;\n read();\n forn(i, N-1) {\n forn(j, N) { \n int x, y;\n find(i*N+j, x, y);\n if (x == i) {\n rotate(x, y, Vertical, Forward);\n rotate(x+1, y, Horizontal, Forward);\n rotate(x, y, Vertical, Backward);\n ++x;\n y = (y + 1) % N;\n }\n rotate(x, y, i+1, (j+1)%N);\n rotate(i, j, Vertical, Forward);\n rotate(i+1, j, Horizontal, Backward);\n rotate(i, j, Vertical, Backward);\n }\n }\n\n while (true) {\n forn(y, N - 2) {\n int t = find((N-1)*N+y);\n while (y + 2 < t) {\n rotate(t-1);\n --t;\n }\n forn(it, t - y) {\n rotate(y);\n }\n }\n if (a[N-1][N-1] == N * N - 1) break;\n rotate(N-1, 0, Horizontal, Backward);\n }\n\n// print();\n forv(i, ans) cout << ans[i] << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6606db66094887384192e35746c1f019", "src_uid": "10b2c1c53580dd382c41a56f7413e709", "difficulty": 2800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define forn(i, n) for(int i = 0; i < int(n); ++i)\n#define forv(i, v) forn(i, v.size())\n\nvector ans;\nconst int N = 6;\nvector > a(N, vector(N));\n\nenum Orientation{Vertical, Horizontal};\nenum Direction{Forward, Backward};\n\nvoid addAnswer(int pos, char dir)\n{\n ans.push_back(string(1,dir) + string(1,'0'+pos+1));\n}\n\nvoid rotateyf(int y) \n{\n int t = a[N-1][y];\n for(int i = N - 1; i > 0; --i) a[i][y] = a[i - 1][y];\n a[0][y] = t;\n}\n\nvoid rotateyb(int y) \n{\n int t = a[0][y];\n for(int i = 0; i < N - 1; ++i) a[i][y] = a[i + 1][y];\n a[N - 1][y] = t;\n}\n\nvoid rotatexf(int x)\n{\n int t = a[x][N-1];\n for(int i = N-1; i > 0; --i) a[x][i] = a[x][i-1];\n a[x][0] = t;\n}\n\nvoid rotatexb(int x)\n{\n int t = a[x][0];\n for(int i = 0; i < N-1; ++i) a[x][i] = a[x][i+1];\n a[x][N-1] = t;\n}\n\nvoid rotate(int x, int y, Orientation o, Direction d)\n{\n if (o == Vertical) {\n if (d == Forward) {\n rotateyf(y);\n addAnswer(y, 'D');\n }\n else {\n rotateyb(y);\n addAnswer(y, 'U');\n }\n }\n else {\n if (d == Forward) {\n rotatexf(x);\n addAnswer(x, 'R');\n }\n else {\n rotatexb(x);\n addAnswer(x, 'L');\n }\n }\n}\n\nvoid rotate(int x, int y, int i, int j) \n{\n if (x == i) {\n Direction d = Forward;\n if (y > j) d = Backward;\n for(int it = 0; it < abs(y - j); ++it) {\n rotate(x, y, Horizontal, d);\n }\n } \n else {\n assert(y == j);\n Direction d = Forward;\n if (x > i) d = Backward;\n for(int it = 0; it < abs(x - i); ++it) {\n rotate(x, y, Vertical, d);\n }\n }\n}\n\nvoid read()\n{\n freopen(\"input.txt\", \"rt\", stdin);\n for(int i = 0; i < 6; ++i) {\n string s; cin >> s;\n for(size_t j = 0; j < s.size(); ++j) {\n if (isdigit(s[j])) a[i][j] = s[j] - '0';\n else a[i][j] = s[j] - 'A' + 10;\n }\n }\n}\n\nvoid print()\n{\n forn(i, N) {\n forn(j, N) {\n cout << a[i][j];\n if (j < N-1) cout << \",\";\n }\n cout << endl;\n }\n}\n\nvoid rotatecw(int y)\n{\n rotate(N-1, y+1, Vertical, Forward);\n rotate(N-1, y, Horizontal, Forward);\n rotate(N-1, y+1, Vertical, Backward);\n rotate(N-1, y, Horizontal, Backward);\n}\n\nvoid rotatecc(int y)\n{\n rotate(N-1, y, Vertical, Forward);\n rotate(N-1, y, Horizontal, Backward);\n rotate(N-1, y, Vertical, Backward);\n rotate(N-1, y, Horizontal, Forward);\n}\n\nvoid rotate(int y) \n{\n rotatecw(y);\n rotatecw(y);\n rotatecc(y+1);\n rotatecw(y);\n}\n\nvoid find(int val, int& x, int& y)\n{\n forn(i, N) forn(j, N) if (a[i][j] == val) {\n x = i;\n y = j;\n return;\n }\n}\n\nint find(int val)\n{\n forn(j, N) if (a[N-1][j] == val) return j;\n assert(false);\n}\n\nint main()\n{\n// forn(i, N) forn(j, N) a[i][j] = i * N + j;\n read();\n forn(i, N-1) {\n forn(j, N) { \n int x, y;\n find(i*N+j, x, y);\n if (x == i) {\n rotate(x, y, Vertical, Forward);\n rotate(x+1, y, Horizontal, Forward);\n rotate(x, y, Vertical, Backward);\n ++x;\n y = (y + 1) % N;\n }\n rotate(x, y, x, (j+1)%N);\n rotate(i, j, x, j);\n rotate(x, (j+1)%N, x, j);\n rotate(x, j, i, j);\n }\n }\n\n while (true) {\n forn(y, N - 2) {\n int t = find((N-1)*N+y);\n while (y + 2 < t) {\n rotate(t-1);\n --t;\n }\n forn(it, t - y) {\n rotate(y);\n }\n }\n if (a[N-1][N-1] == N * N - 1) break;\n rotate(N-1, 0, Horizontal, Backward);\n }\n\n //print();\n forv(i, ans) cout << ans[i] << endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7de64e4ecde8f318c7a458eea83a39b9", "src_uid": "10b2c1c53580dd382c41a56f7413e709", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n#define ff first\n#define ss second\ntypedef pair pii;\nconst int N = 6;\nstring s[N], t = \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\nvector ans;\nvoid add(int x, int y, char a, char b, char c) {\n if (a == 'D')\n swap(s[x][y], s[x + 1][y]);\n if (a == 'U')\n swap(s[x][y], s[x - 1][y]);\n if (a == 'L')\n swap(s[x][y], s[x][y + 1]);\n if (a == 'R')\n swap(s[x][y], s[x][y - 1]);\n if (a == 'U' || a == 'D')\n swap(x, y);\n ans.push_back(pii(c, y));\n ans.push_back(pii(b, x));\n ans.push_back(pii(c, y));\n ans.push_back(pii(a, x));\n ans.push_back(pii(c, y));\n ans.push_back(pii(b, x));\n ans.push_back(pii(c, y));\n ans.push_back(pii(a, x));\n ans.push_back(pii(c, y));\n ans.push_back(pii(b, x));\n ans.push_back(pii(c, y));\n ans.push_back(pii(a, x));\n ans.push_back(pii(c, y));\n}\n\nvoid move(int x, int y, int _x, int _y) {\n while (x < _x)\n add(x++, y, 'D', 'U', 'L');\n while (y < _y)\n add(x, y++, 'L', 'R', 'U');\n while (x > _x)\n add(x--, y, 'U', 'D', 'L');\n while (y > _y)\n add(x, y--, 'R', 'L', 'U');\n}\n\nint main() {\n ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);\n for (int i = 0; i < N; i++)\n cin >> s[i];\n for (int k = 0; k < N * N; k++) {\n int x = -1, y = -1;\n for (int i = 0; i < N; i++)\n for (int j = 0; j < N; j++)\n if (s[i][j] == t[k]) {\n x = i;\n y = j;\n }\n move(x, y, k / N, k % N);\n }\n cout << ans.size() << \"\\n\";\n for (auto i: ans)\n cout << ans[i].ff << ans[i].ss + 1 << \"\\n\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bf7fbc8d262abab6085b32db264bc7e3", "src_uid": "10b2c1c53580dd382c41a56f7413e709", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n\n#define pb push_back\n#define ff first\n#define ss second\n\nvector ans;\nint i, j, x, y;\nchar c[8][8];\n\nvoid Find(char op, int &x, int &y){\n\tfor(x = 0; x < 6; x++)\n\t\tfor(y = 0; y < 6; y++)\n\t\t if(c[x][y] == op)\n\t\t return;\n}\n\nvoid go(int x,int y,int flag){\n\tstring v;\n\tfor(int i = 0; i < 13; i++){\n\t\tif(!flag) {\n\t\t\tif(i & 1){\n\t\t\t\tif(i / 2 &1)\n\t\t\t\t v = \"D\";\n\t\t\t\telse \n\t\t\t\t v = \"U\";\n\t\t\t\tv += char(y + 49);\n\t\t\t}\n\t\t\telse {\n\t\t\t v = \"R\";\n\t\t\t v += char(x + 49);\n\t\t\t}\n\t\t}\n\t\telse{\n\t\t\tif(i & 1){\n\t\t\t\tif(i / 2 & 1)\n\t\t\t\t v = \"R\";\n\t\t\t\telse \n\t\t\t\t v = \"L\";\n\t\t\t\tv += char(x + 49);\n\t\t\t}\n\t\t\telse {\n\t\t\t v = \"D\";\n\t\t\t v += char(y + 49);\n\t\t\t}\n\t\t}\n\t\tans.pb(v);\n\t}\n\tif(flag)\n\t swap(c[x][y], c[x][y + 1]);\n\telse \n\t swap(c[x][y], c[x + 1][y]);\n}\n\nint main(){\n ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);\n string s;\n\tfor(i = 0; i < 6; i++) {\n\t cin >> s;\n\t for (int j = 0; j < 6; j++) \n\t c[i][j] = s[j];\n\t}\n\t\n\tfor(i = 0; i < 6; i++)\n\t\tfor(j = 0; j < 6; j++){\n\t\t\tchar op = i * 6 + j;\n\t\t\tif(op <= 9)\n\t\t\t op = char(op + 48);\n\t\t\telse \n\t\t\t op = char(op - 10 + 65);\n\t\t\tFind(op, x, y);\n\t\t\twhile(y > j) {\n\t\t\t work(x, y - 1, 1);\n\t\t\t y--;\n\t\t\t}\n\t\t\twhile(y < j) {\n\t\t\t work(x, y, 1);\n\t\t\t y++;\n\t\t\t}\n\t\t\twhile(x > i) {\n\t\t\t work(x - 1, y, 0);\n\t\t\t x--;\n\t\t\t}\n\t\t}\n\t\t\n\tcout << ans.size() << '\\n';\n\tfor(auto y: ans)\n\t cout << y << '\\n';\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fa742b58152a48aae00c170cbf145330", "src_uid": "10b2c1c53580dd382c41a56f7413e709", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define EPS 1e-7\n#define INF (int)(1e+9)\n#define LINF (long long)(1e+18)\n#define PI acos(-1)\n#define mp make_pair\n#define MOD 1000000007\n\n\nusing namespace std;\n\n#define NAME \"test\"\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pii;\ntypedef pair pll;\n\nvoid solve(int test_number);\n\n\nvoid pre() {\n cout.setf(ios::fixed);\n cout.precision(20);\n cerr.setf(ios::fixed);\n cerr.precision(3);\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n}\n\nvoid post() {\n printf(\"\\n\");\n fprintf(stderr, \"Execution time: %Lf\", (ld) clock());\n}\n\nconst int MAXN = 100100;\n\ninline void solve(int test_number) {\n\tstring s;\n\tcin >> s;\n\tint i;\n\tstring s1;\n\ts1 = \"\";\n\tint c1 = 0;\n\tfor (i = 0; i < s.size(); i++) {\n\t\tif (s[i] == '/' && c1 != -1) {\n\t\t\tc1 = -1;\n\t\t\ts1 += s[i];\n\t\t}\n\t\tif (s[i] != '/') {\n\t\t\ts1 += s[i];\n\t\t\tc1 = 0;\n\t\t}\n\t}\n\tint cnt = 0;\n\ti = s.size() - 1;\n\twhile (i >= 0) {\n\t\tif (s[i] != '/') {\n\t\t\tbreak;\n\t\t}\n\t\telse {\n\t\t\tcnt++;\n\t\t}\n\t\ti--;\n\t}\n\tif (i == -1) {\n\t\tcout << '/' << endl;\n\t\treturn;\n\t}\n\tif (cnt != 0) s1.pop_back();\n\t}\n\tcout << s1 << endl;\n\treturn; \n\t\t\n}\n\n\n\nint main()\n{\n#ifdef DEBUG\n freopen(NAME \".in\", \"r\", stdin);\n freopen(NAME \".out\", \"w\", stdout);\n#endif\n //freopen(NAME \".in\", \"r\", stdin);\n //freopen(NAME \".out\", \"w\", stdout);\n pre();\n\n int n = 1;\n for (int i = 0; i < n; i++) {\n solve(i + 1);\n }\n\n post();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2b3651df9d191dcec4415508018464d5", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031", "difficulty": 1700.0} {"lang": "MS C++", "source_code": "#include\n#include\nusing namespace std;\nint main()\n{\n string a;\n cin>>a;\n for(int i=0;i<=a.size();i++)\n {\n if(a[i]=='/'&&a[i+1]=='/')\n { a.erase(i,1);i--;}\n }\n long i=a.size()-1;\n while(a[i]=='/'&&a.size>1)\n {\n \ta.erase(i,1);\n\t}\n\tcout<\nusing namespace std;\nint main()\n{\n string s;\n cin>>s;\n int n=0;\n for(int i=1;s.length();i++)\n\t{\n if(!(s[i]==s[i-1]&&s[i]=='/')){++n;cout<\nusing namespace std;\n\n#define mem(a, b) memset(a, (b), sizeof(a))\n#define MAX(a, b) ((a) > (b) ? (a) : (b))\n#define MIN(a, b) ((a) < (b) ? (a) : (b))\n#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )\n#define S(X) ( (X) * (X) )\n#define FORN(i, n) for(i = 0; i < n; i++)\n#define FORAB(i, a, b) for(i = a; i <= b; i++)\n#define IN(A, B, C) ((B) <= (A) && (A) <= (C))\n#define in freopen(\"in.txt\", \"r\", stdin)\n#define out freopen(\"out.txt\", \"w\", stdout)\n#define clr(arr, key) memset(arr, key, sizeof arr)\n#define pb push_back\n#define mp(a, b) make_pair(a, b)\n#define inf (1 << 28)\n#define ll long long\n#define PI acos(-1)\n#define gcd(a, b) __gcd(a, b)\n#define fast ios_base::sync_with_stdio(0);cin.tie(0)\n#define lcm(a, b) ((a)*((b)/gcd(a,b)))\n#define no_of_ones __builtin_popcount // __builtin_popcountll for LL\n#define SZ(v) (int)(v.size())\n#define eps 1e-7\n#define ppb pop_back\n#define all(x) x.begin(),x.end()\n#define AIN(A, B, C) assert(IN(A, B, C))\n#define INF 1000000000\nint dr[]={0, 0, 1, -1, 1, 1, -1, -1};\nint dc[]={1, -1, 0, 0, 1, -1, 1, -1};\n\ntypedef pair pii;\ntypedef pair pdd;\ntypedef vector vi;\ntypedef vector vpi;\n\nint main()\n{\n fast;\n //in;\n //out;\n char str[102];\n cin>>str;\n int n=strlen(str);\n for(int i=0;i\n\n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define FOR(i, a, b) for (int i = (a); i < (b); ++i)\n#define REP(i, n) FOR(i, 0, n)\n#define TRACE(x) cout << #x << \" = \" << x << endl\n#define _ << \" _ \" <<\n\n#ifdef ONLINE_JUDGE\n# define LLD \"%I64d\"\n#else\n# define LLD \"%ll\" \"d\"\n#endif\n\ntypedef long long llint;\n\nconst int MAXN = 1e5 + 123;\nconst double eps = 1e-9;\nstruct Edge { int a, b; double w; };\n\nint n;\nvector E[MAXN];\n\nstruct Pt {\n double x, y, z;\n Pt(double x = 0, double y = 0, double z = 0) : x(x), y(y), z(z) {}\n friend Pt operator - (Pt a, Pt b) { return {a.x-b.x, a.y-b.y, a.z-b.z}; }\n friend double dot(Pt a, Pt b) { return a.x*b.x + a.y*b.y + a.z*b.z; }\n friend Pt cross(Pt a, Pt b) {\n return { a.y*b.z - a.z*b.y, a.z*b.x - a.x*b.z, a.x*b.y - a.y*b.x };\n }\n};\n\nstruct Line {\n Pt a, b;\n int idx;\n Pt get_abc() const {\n Pt ans = cross((Pt){a.x, a.y, 1}, {b.x, b.y, 1});\n assert(dot({a.x, a.y, 1}, ans) == 0);\n assert(dot({b.x, b.y, 1}, ans) == 0);\n return ans;\n }\n friend Pt presjek(const Line& a, const Line& b) {\n Pt a_abc = a.get_abc();\n Pt b_abc = b.get_abc();\n Pt ans = cross(a_abc, b_abc);\n assert(ans.z != 0);\n return {ans.x/ans.z, ans.y/ans.z, 0};\n }\n double minx() const { return min(a.x, b.x); }\n double maxx() const { return max(a.x, b.x); }\n};\n\nenum { BOTTOM, TOP };\nstruct Evt {\n int type;\n int enda, endb;\n int bottom;\n\n Pt curr;\n int curr_idx;\n};\nstruct LineCmpf {\n bool operator () (const Line& a, const Line& b) const {\n double lo = max(a.minx(), b.minx()), hi = min(a.maxx(), b.maxx());\n double mid = (lo + hi) / 2;\n Line L = {(Pt){mid, 0}, (Pt){mid, 1}};\n double a_y = presjek(L, a).y, b_y = presjek(L, b).y;\n return make_tuple(a_y, a.minx()) < make_tuple(b_y, b.minx());\n }\n};\n\ninline double get_dist(Pt a, Pt b) { double dx = a.x-b.x, dy = a.y-b.y; return sqrt(dx*dx + dy*dy); }\n\ndouble dijkstra(int s, int t) {\n const int inf = 1e9;\n static vector dist; dist.clear(); dist.resize(n, inf);\n static vector bio; bio.clear(); bio.resize(n, false);\n auto cmp = [](int a, int b) {\n return make_pair(dist[a], a) < make_pair(dist[b], b);\n };\n\n set pq(cmp);\n dist[s] = 0;\n pq.insert(s);\n\n for (; !pq.empty(); ) {\n int ex = *pq.begin(); pq.erase(pq.begin());\n bio[ex] = true;\n for (Edge e : E[ex]) {\n if (bio[e.b]) continue;\n double val = dist[e.a] + e.w;\n if (val+eps < dist[e.b]) {\n if (dist[e.b] < inf) pq.erase(e.b);\n dist[e.b] = val;\n pq.insert(e.b);\n }\n }\n }\n\n return dist[t];\n}\nint main(void)\n{\n scanf(\"%d\", &n);\n vector P;\n REP(i, n) {\n double x, y; scanf(\"%lf %lf\", &x, &y); x += 1e4;\n P.push_back({x, y, 0});\n } // ccw smjer\n\n const int MAXCOOR = 2e4 + 213;\n static vector evts[MAXCOOR];\n REP(i, n) {\n int j = i+1; if (j == n) j = 0;\n Pt left = P[i], right = P[j]; int l_idx = i, r_idx = j;\n if (left.x > right.x) { swap(left, right); swap(l_idx, r_idx); }\n if (P[i].x == P[j].x) {\n } else if (P[i].x < P[j].x) {\n evts[(int)left.x].push_back({0, i, j, BOTTOM, left, l_idx});\n evts[(int)right.x].push_back({1, i, j, BOTTOM, right, r_idx});\n } else if (P[i].x > P[j].x) {\n evts[(int)left.x].push_back({0, i, j, TOP, left, l_idx});\n evts[(int)right.x].push_back({1, i, j, TOP, right, r_idx});\n }\n }\n set pq;\n REP(x, MAXCOOR) {\n if (evts[x].empty()) continue;\n for (Evt e : evts[x]) {\n if (e.type == 0) {\n Line L = {P[e.enda], P[e.endb], e.enda};\n pq.insert(L);\n }\n }\n for (Evt e : evts[x]) {\n Line L = {P[e.enda], P[e.endb], e.enda};\n auto it = pq.find(L);\n assert(it != pq.end());\n\n Line x_line = {{(double)x, 0.}, {(double)x, 1.}};\n if (e.bottom == TOP && it != pq.begin()) {\n auto it2 = prev(it);\n Pt donja = presjek(x_line, *it2);\n for (int d_idx : {it2->idx, (it2->idx+1)%n}) {\n int a = e.curr_idx;\n int b = d_idx;\n double d = get_dist(e.curr, donja) + get_dist(donja, P[d_idx]);\n E[a].push_back({a, b, d});\n }\n }\n\n if (e.bottom == BOTTOM) {\n auto it2 = next(it);\n if (it2 != pq.end()) {\n Pt gornja = presjek(x_line, *it2);\n for (int g_idx : {it2->idx, (it2->idx+1)%n}) {\n int a = g_idx;\n int b = e.curr_idx;\n double d = get_dist(P[g_idx], gornja) + get_dist(gornja, e.curr);\n E[a].push_back({a, b, d});\n }\n }\n }\n }\n for (Evt e : evts[x]) {\n if (e.type == 1) {\n Line L = {P[e.enda], P[e.endb], e.enda};\n pq.erase(L);\n }\n }\n }\n REP(i, n) {\n int j = i+1; if (j == n) j = 0;\n E[i].push_back({i, j, get_dist(P[i], P[j])});\n E[j].push_back({j, i, get_dist(P[i], P[j])});\n }\n\n int s, t; scanf(\"%d %d\", &s, &t); --s, --t;\n double ans = dijkstra(s, t);\n printf(\"%.9lf\\n\", ans);\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "262b07291f8a24a86dfacbb604758fb3", "src_uid": "ccc9d167caf5c4e3c7ab212bf4f5ca45", "difficulty": 3000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define REP(i,n) for(int i = 0; i < (int)n; i++)\n#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); i++)\n\n#define pb push_back\n#define fi first\n#define se second\n\nconst int maxn=111111;\nconst double inf=1e201;\nconst int leaf=1<<17;\nconst double eps=1e-9;\n\nint n;\nint x[maxn], y[maxn];\n\nint P[maxn];\nbool side[maxn];\nint pos;\nint da[maxn], db[maxn];\n\nint cmp(int a, int b){\n return (x[a]!=x[b])?(x[a] > e[maxn];\ndouble dist(double a, double b){\n return sqrt(a*a+b*b);\n}\n\n\nint X;\nstruct line{\n double a, b;\n int id;\n line(double a, double b, int id=0):a(a),b(b),id(id){;}\n double Y(double X){return a*X+b;}\n friend bool operator < (const line &u){\n double ea=Y(X), eb=u.Y(X);\n return abs(ea-eb)>eps?ea s;\n\nvoid Descend(int i, int j){\n FOR(k,i,j){\n int u=P[k];\n multiset::iterator it, it2;\n it2=s.lower_bound(line(0,y[u],-1));\n it=it2;\n if (it!=s.begin()){\n --it;\n for (; it!=s.begin() && (da[it->id]==u || db[it->id]==u); --it);\n if (!(da[it->id]==u || db[it->id]==u) && side[it->id]){\n int ua=da[it->id], ub=db[it->id];\n double yy=it->Y(x[u]);\n e[u].pb(make_pair(ua,dist(x[u]-x[ua],yy-y[ua])+fabs(yy-y[u])));\n e[u].pb(make_pair(ub,dist(x[u]-x[ub],yy-y[ub])+fabs(yy-y[u])));\n }\n }\n it=it2;\n for (; it!=s.end() && (da[it->id]==u || db[it->id]==u); ++it);\n if (it!=s.end() && !side[it->id]){\n int ua=da[it->id], ub=db[it->id];\n double yy=it->Y(x[u]);\n e[ua].pb(make_pair(u,dist(x[u]-x[ua],yy-y[ua])+fabs(yy-y[u])));\n e[ub].pb(make_pair(u,dist(x[u]-x[ub],yy-y[ub])+fabs(yy-y[u])));\n }\n }\n}\ndouble best[maxn];\nint main(){\n int S,T;\n scanf(\"%d\",&n);\n for (int i = 0; i < n; i++) scanf(\"%d%d\",x+i,y+i);\n for (int i = 0; i < n; i++) e[i].clear();\n scanf(\"%d%d\",&S,&T);\n --S; --T;\n x[n]=x[0]; y[n]=y[0];\n\n for (int i = 0; i < n; i++) P[i]=i;\n sort(P,P+n,cmp);\n\n pos=0;\n s.clear();\n\n for (int i=0; i::iterator ita=s.end(), itb=s.end(), it;\n\n if (x[va]>x[u]){\n double ax=1.*(y[va]-y[u])/(x[va]-x[u]);\n ita=s.insert(line(ax,y[u]-X*ax,pos));\n da[pos]=u; db[pos]=va; ++pos;\n }\n\n if (x[vb]>x[u]){\n double ax=1.*(y[vb]-y[u])/(x[vb]-x[u]);\n itb=s.insert(line(ax,y[u]-X*ax,pos));\n da[pos]=u; db[pos]=vb; ++pos;\n }\n\n if (ita!=s.end() && itb!=s.end() && *itb<*ita) swap(ita,itb);\n\n if (ita!=s.end()){\n it=ita; --it;\n if (ita==s.begin())\n side[ita->id]=1;\n //else\n // side[ita->id]=side[it->id]^1;\n }\n\n if (itb!=s.end()){\n it=itb; --it;\n if (itb==s.begin())\n side[itb->id]=1;\n //else\n // side[itb->id]=side[it->id]^1;\n }\n }\n Descend(i,j);\n i=j;\n }\n for (int i = 0; i < n; i++){\n double d=dist(x[i]-x[i+1],y[i]-y[i+1]);\n e[i].pb(make_pair((i+1)%n,d));\n e[(i+1)%n].pb(make_pair(i,d));\n }\n priority_queue > q;\n REP(i,n) best[i]=inf;\n best[S]=0;\n q.push(make_pair(-0.,S));\n while(q.size()){\n double d=-q.top().fi; \n int a=q.top().se;\n q.pop();\n if (a==T) {printf(\"%.10lf\\n\",d); return 0;}\n if (d!=best[a]) continue;\n REP(i,e[a].size()){\n int b=e[a][i].fi;\n double se=d+e[a][i].se;\n if (best[b]>se) best[b]=se, q.push(make_pair(-se,b));\n }\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0d83ff50e72dddd8a31fff1ea8247cc1", "src_uid": "ccc9d167caf5c4e3c7ab212bf4f5ca45", "difficulty": 3000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define REP(i,n) for(int i = 0; i < (int)n; i++)\n\n#define pb push_back\n#define fi first\n#define se second\n#define next(x) ((x+1)%n)\n#define perv(x) ((x-1+n)%n)\nconst int maxn=111111;\nconst double inf=1e201;\nconst int leaf=1<<17;\nconst double eps=1e-9;\n\nint n;\nint x[maxn], y[maxn];\n\nint P[maxn];\nbool side[maxn];\nint pos;\nint da[maxn], db[maxn];\n\nint cmp(int a, int b){\n return (x[a]!=x[b])?(x[a] > e[maxn];\ndouble dist(double a, double b){\n return sqrt(a*a+b*b);\n}\n\n\nint X;\nstruct line{\n double a, b;\n int id;\n line(double a, double b, int id=0):a(a),b(b),id(id){;}\n double Y(double X) const {\n return a*X+b;\n }\n bool operator < (const line &u) const{\n double ea=Y(X), eb=u.Y(X);\n return abs(ea-eb)>eps?ea s;\n\nvoid Descend(int i, int j){\n for (int k = i; k < j; j++){\n int u=P[k];\n multiset::iterator it, it2;\n it2=s.lower_bound(line(0,y[u],-1));\n it=it2;\n if (it!=s.begin()){\n --it;\n for (; it!=s.begin() && (da[it->id]==u || db[it->id]==u); --it);\n if (!(da[it->id]==u || db[it->id]==u) && side[it->id]){\n int ua=da[it->id], ub=db[it->id];\n double yy=it->Y(x[u]);\n e[u].pb(make_pair(ua,dist(x[u]-x[ua],yy-y[ua])+fabs(yy-y[u])));\n e[u].pb(make_pair(ub,dist(x[u]-x[ub],yy-y[ub])+fabs(yy-y[u])));\n }\n }\n it=it2;\n for (; it!=s.end() && (da[it->id]==u || db[it->id]==u); ++it);\n if (it!=s.end() && !side[it->id]){\n int ua=da[it->id], ub=db[it->id];\n double yy=it->Y(x[u]);\n e[ua].pb(make_pair(u,dist(x[u]-x[ua],yy-y[ua])+fabs(yy-y[u])));\n e[ub].pb(make_pair(u,dist(x[u]-x[ub],yy-y[ub])+fabs(yy-y[u])));\n }\n }\n}\ndouble D[maxn];\npriority_queue > Q;\nint main(){\n int S,T;\n scanf(\"%d\",&n);\n for (int i = 0; i < n; i++) scanf(\"%d%d\",x+i,y+i);\n for (int i = 0; i < n; i++) e[i].clear();\n scanf(\"%d%d\",&S,&T);\n --S; --T;\n //x[n]=x[0]; y[n]=y[0];\n\n for (int i = 0; i < n; i++) P[i]=i;\n sort(P,P+n,cmp);\n\n pos=0;\n\n for (int i=0; i::iterator ita=s.end(), itb=s.end(), it;\n\n if (x[le]>x[u]){\n double ax=1.*(y[le]-y[u])/(x[le]-x[u]);\n ita=s.insert(line(ax,y[u]-X*ax,pos));\n da[pos]=u; db[pos]=le; ++pos;\n }\n\n if (x[rt]>x[u]){\n double ax=1.*(y[rt]-y[u])/(x[rt]-x[u]);\n itb=s.insert(line(ax,y[u]-X*ax,pos));\n da[pos]=u; db[pos]=rt; ++pos;\n }\n\n if (ita!=s.end() && itb!=s.end() && *itb<*ita) swap(ita,itb);\n\n if (ita!=s.end()){\n it=ita; --it;\n if (ita==s.begin())\n side[ita->id]=1;\n else\n side[ita->id]=side[it->id]^1;\n }\n\n if (itb!=s.end()){\n it=itb; --it;\n if (itb==s.begin())\n side[itb->id]=1;\n //else\n // side[itb->id]=side[it->id]^1;\n }\n }\n Descend(i,j);\n i=j;\n }\n for (int i = 0; i < n; i++){\n double d=dist(x[i]-x[next(i)],y[i]-y[next(i)]);\n e[i].pb(make_pair(next(i),d));\n e[next(i)].pb(make_pair(i,d));\n }\n \n for (int i = 0; i < n; i++) D[i]=inf;\n\n D[S]=0;\n Q.push(make_pair(-0.,S));\n while(Q.size()){\n double d=-Q.top().fi; \n int a=Q.top().se;\n if (a==T) \n return printf(\"%.10lf\\n\",d),0;\n Q.pop();\n if (d==D[a]){\n for (int i = 0; i se) D[b]=se, Q.push(make_pair(-se,b));\n }\n }\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1caf4d839654d3c8b2802a432aa16bf5", "src_uid": "ccc9d167caf5c4e3c7ab212bf4f5ca45", "difficulty": 3000.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef long long LL;\n\nstruct FR {\n\tLL a, b;\n\tFR() : a(0), b(1) {}\n\tFR(LL x) : a(x), b(1) {}\n\tFR(LL x, LL y) {\n\t\tLL g = __gcd(x, y);\n\t\tx /= g, y /= g;\n\t\tif (y < 0) x = -x, y = -y;\n\t\ta = x, b = y;\n\t}\n\tbool operator<(const FR &that) const {\n\t\treturn (long long)a * that.b < (long long)that.a * b;\n\t}\n\tbool operator>(const FR &that) const {\n\t\treturn (long long)a * that.b > (long long)that.a * b;\n\t}\n\tbool operator==(const FR &that) const {\n\t\treturn (long long)a * that.b == (long long)that.a * b;\n\t}\n\tbool operator<=(const FR &that) const {\n\t\treturn !(that < *this);\n\t}\n\tbool operator>=(const FR &that) const {\n\t\treturn !(*this < that);\n\t}\n\tFR operator+(const FR &that) const {\n\t\treturn FR(a * that.b + that.a * b, b * that.b);\n\t}\n\tFR operator-(const FR &that) const {\n\t\treturn FR(a * that.b - that.a * b, b * that.b);\n\t}\n\tFR operator*(const FR &that) const {\n\t\treturn FR(a * that.a, b * that.b);\n\t}\n\tFR operator/(const FR &that) const {\n\t\treturn FR(a * that.b, b * that.a);\n\t}\n\tdouble toDouble() const {\n\t\treturn (double)a / b;\n\t}\n};\n\nstatic const int INF = 0x3f3f3f3f;\n\nstruct PT {\n\tint x;\n\tFR y;\n\tPT() {}\n\tPT(FR x, FR y) : x(x), y(y) {}\n\tvoid in() {\n\t\tint _x, _y;\n\t\tscanf(\"%d%d\", &_x, &_y);\n\t\tx = _x, y = _y;\n\t}\n};\n\nbool operator<(const PT& p1, const PT& p2) {\n\tif (!(p1.x == p2.x)) return p1.x < p2.x;\n\treturn p1.y < p2.y;\n}\n\nbool operator==(const PT& p1, const PT& p2) {\n\treturn p1.x == p2.x && p1.y == p2.y;\n}\n\nstruct Segment {\n\tstatic int curX;\n\tFR slope, intercept;\n\tint xL, xR;\n\tint id;\n\tSegment(FR slope, FR intercept, int xL, int xR, int id) : slope(slope), intercept(intercept), xL(xL), xR(xR), id(id) {}\n\tSegment(PT A, PT B, int id) : id(id) {\n\t\tif (A.x > B.x) swap(A, B);\n\t\txL = round(A.x.toDouble()), xR = round(B.x.toDouble());\n\t\tif (xL == xR) {\n\t\t\tintercept = A.y;\n\t\t\tslope = 0;\n\t\t} else {\n\t\t\tslope = (B.y - A.y) / (xR - xL);\n\t\t\tintercept = A.y - A.x * slope;\n\t\t}\n\t}\n\tFR getY(const int &x) const {\n\t\treturn intercept + slope * x;\n\t}\n\tpair getPoints() {\n\t\treturn make_pair(PT(xL, getY(xL)), PT(xR, getY(xR)));\n\t}\n\tbool operator<(const Segment &that) const {\n\t\tFR y0 = getY(curX);\n\t\tFR y1 = that.getY(curX);\n\t\tif (y0 == y1) {\n\t\t\tif (curX == xR && that.xR == curX) return that.slope < slope;\n\t\t\tif (curX == xL && that.xL == curX) return slope < that.slope;\n\t\t\tif (curX == xL && that.xR == curX) return 0;\n\t\t\treturn 1;\n\t\t}\n\t\treturn y0 < y1;\n\t}\n\tbool isIntersectTo(const Segment &that, FR &crossX) const {\n\t\tif(slope == that.slope) {\n\t\t\tif(intercept == that.intercept) {\n\t\t\t\tcrossX = max(xL, that.xL);\n\t\t\t\treturn !(xR < that.xL) && !(that.xR < xL);\n\t\t\t} else {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} else {\n\t\t\tcrossX = (intercept - that.intercept) / (that.slope - slope);\n\t\t\treturn FR(xL) <= crossX && crossX <= FR(xR) && FR(that.xL) <= crossX && crossX <= FR(that.xR);\n\t\t}\n\t}\n};\nint Segment::curX;\n\nconst int N = 110000;\ntypedef pair PII;\nvector V[N];\ntypedef double DB;\nconst DB PI = acos(-1);\nconst DB EPS = 1e-9;\nint hn;\nmap M;\n\nDB sqr (DB x) { return x * x; };\n\nDB dist(PT P, PT Q) {\n\treturn sqrt(sqr((P.x - Q.x)) + sqr((P.y - Q.y).toDouble()));\n}\n\nint Hash(PT p) {\n\tif (M.count(p)) return M[p];\n\treturn M[p] = hn++;\n}\n\nstruct data{\n\tint x, y;\n\tDB dis;\n\tdata(int x = 0, int y = 0, DB dis = 0) : x(x), y(y), dis(dis) {}\n};\n\nint chk[N];\n\nvector makeGraph(vector &p) {\n\tvector ret;\n\tint n = p.size();\n\tvector segments;\n\ttypedef tuple event;\n\tvector events;\n\tvector angles;\n\t\n\tfor (int i = 0; i < n; i++) {\n\t\tint j = (i + 1) % n;\n\t\tPT A = p[i], B = p[j];\n\t\tsegments.push_back(Segment(A, B, i));\n\t\tV[i].push_back(A);\n\t\tV[i].push_back(B);\n\t\tangles.push_back(atan2((B.y - A.y).toDouble(), (B.x - A.x).toDouble()));\n\t\tif (A.x == B.x) continue;\n\t\tint a = i, b = j;\n\t\tif (A.x > B.x) swap(A, B), swap(a, b);\n\t\tevents.emplace_back(round(A.x.toDouble()), a, i);\n\t\tevents.emplace_back(round(B.x.toDouble()), b + n, i);\n\t}\n\tsort(events.begin(), events.end());\n\tmultiset ss;\n\t\n\tauto check = [&n, &angles, &ret](const Segment &s, const Segment &t, const int &x, int id, int dir) {\n\t\tFR y1 = s.getY(x), y2 = t.getY(x);\n\t\tDB from = angles[id];\n//\t\tcerr << y1.toDouble() << \" \" << y2.toDouble() << endl;\n\t\tDB to = angles[(id - 1 + n) % n] + PI;\n\t\tif (to > PI) to -= 2 * PI;\n\t\tif (to < from) to += 2 * PI;\n\t\tDB cur = PI / 2;\n\t\tif (dir < 0) cur -= PI;\n\t\tif ((from - EPS < cur && cur < to + EPS) || (from - EPS < cur + 2 * PI && cur + 2 * PI < to + EPS)) {\n\t\t\tV[s.id].push_back(PT(x, y1));\n\t\t\tV[t.id].push_back(PT(x, y2));\n\t\t\tif (y1 < y2) swap(y1, y2);\n\t\t\tret.push_back(data(Hash(PT(x, y1)), Hash(PT(x, y2)), fabs((y1 - y2).toDouble())));\n\t\t}\n\t};\n\t\n\tint prv = -10000000;\n\tevents.emplace_back(100000000, 0, 0);\n\tvector temp;\n\tfor (auto e : events) {\n\t\tint x, _a, _b;\n\t\ttie(x, _a, _b) = e;\n\t\tif (prv < x) {\n\t\t\tSegment::curX = prv;\n\t\t\tfor (auto t : temp) {\n\t\t\t\tint xx, a, b;\n\t\t\t\ttie(xx, a, b) = t;\n\t\t\t\tif (a < n) ss.insert(segments[b]);\n\t\t\t}\n\t\t\tfor (auto t : temp) {\n\t\t\t\tint xx, a, b;\n\t\t\t\ttie(xx, a, b) = t;\n\t\t\t\tint i = a % n;\n\t\t\t\tconst Segment &s = segments[b];\n\t\t\t\tint now = Hash(PT(prv, s.getY(prv)));\n\t\t\t\tif (chk[now]) continue;\n\t\t\t\tchk[now] = 1;\n\t\t\t\tauto it = ss.upper_bound(s);\n\t\t\t\tauto it1 = it;\n\t\t\t\twhile (it != ss.end() && it->getY(prv) <= s.getY(prv)) it++;\n\t\t\t\tif (it != ss.end()) check(*it, s, prv, i, 1);\n\t\t\t\tit = it1;\n\t\t\t\twhile (it != ss.begin() && it != ss.end() && it->getY(prv) >= s.getY(prv)) --it;\n\t\t\t\tif(it != ss.end() && it->getY(prv) < s.getY(prv)) check(*it, s, prv, i, -1);\n\t\t\t}\n\t\t\tfor (auto t : temp) {\n\t\t\t\tint xx, a, b;\n\t\t\t\ttie(xx, a, b) = t;\n\t\t\t\tif (a >= n) ss.erase(segments[b]);\n\t\t\t}\n\t\t\ttemp.clear();\n\t\t\tprv = x;\n\t\t}\n\t\ttemp.push_back(e);\n\t}\n\tfor (int i = 0; i < n; i++) {\n\t\tsort(V[i].begin(), V[i].end());\n\t\tfor (int j = 0; j < V[i].size() - 1; j++) {\n\t\t\tret.push_back(data(Hash(V[i][j]), Hash(V[i][j + 1]), dist(V[i][j], V[i][j + 1])));\n\t\t\tret.push_back(data(Hash(V[i][j + 1]), Hash(V[i][j]), dist(V[i][j], V[i][j + 1])));\n\t\t}\n\t}\n\treturn ret;\n}\n\nvector adj[N * 10];\nvector dis[N * 10];\ntypedef pair PDI;\nDB d[N * 10];\nint chk[N * 10];\npriority_queue, greater> Q;\n\nDB dijkstra(const vector &link, const int &s, const int &t) {\n\tfor (auto &t : link) {\n\t\tint a = t.x, b = t.y;\n\t\tDB d = t.dis;\n\t\tadj[a].push_back(b);\n\t\tdis[a].push_back(d);\n\t}\n\tfor (int i = 0; i < hn; i++) d[i] = 1e20;\n\tQ.push(PDI(0, s));\n\td[s] = 0;\n\twhile (!Q.empty()) {\n\t\tint now = Q.top().second;\n\t\tQ.pop();\n\t\tif (chk[now]) continue;\n\t\tchk[now] = 1;\n\t\tfor (int i = 0; i < adj[now].size(); i++) {\n\t\t\tint j = adj[now][i];\n\t\t\tDB dd = dis[now][i];\n\t\t\tif (d[j] > d[now] + dd) {\n\t\t\t\td[j] = d[now] + dd;\n\t\t\t\tQ.push(PDI(d[j], j));\n\t\t\t}\n\t\t}\n\t}\n\treturn d[t];\n}\n\nint main() {\n//\tfreopen(\"in.txt\", \"r\", stdin);\n//\tfreopen(\"out.txt\", \"w\", stdout);\n\tvector P;\n\tint n, s, t; scanf(\"%d\", &n); P.resize(n);\n\tfor (int i = 0; i < n; i++) P[i].in();\n\tscanf(\"%d%d\", &s, &t); --s, --t;\n\tprintf(\"%.10lf\\n\", dijkstra(makeGraph(P), Hash(P[s]), Hash(P[t])));\n\treturn 0;\n}\n\n ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ed6635f6762fd47e9bff3704d8fe15c9", "src_uid": "ccc9d167caf5c4e3c7ab212bf4f5ca45", "difficulty": 3000.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define ll long long\n#define pii pair\n\nint n, Q, cnt, ps[100005], L[100005], R[100005]; ll k, ans, w[100005];\n\nvector g[100005];\n\nstruct st {\n\tll p, m, tg, lm, mr, lmr;\n\tvoid update(ll v) {p += v; m -= 2 * v; lm -= v; mr -= v; tg += v;}\n\tst operator+(const st &b)const {\n\t\tst c; c.p = max(p, b.p); c.m = max(m, b.m);\n\t\tc.lm = max(max(lm, b.lm), p + b.m);\n\t\tc.mr = max(max(mr, b.mr), m + b.p);\n\t\tc.lmr = max(max(lmr, b.lmr), max(lm + b.p, p + b.mr));\n\t\treturn c;\n\t}\n} T[N*8];\n\nvoid update(int node, int ns, int ne, int s, int e, ll v) {\n\tif (ne < s || e < ns) return; \n\tif (s <= ns && ne <= e) {\n\t\tT[node].update(v); \n\t\treturn;\n\t}\n\tT[node*2].update(T[node].tg); \n\tT[node*2+1].update(T[node].tg); \n\tT[node].tg = 0;\n\tint mid = (ns + ne)/2; \n\tupdate(node*2, ns, mid, s, e, v); \n\tupdate(node*2+1, mid + 1, ne, s, e, v);\n\tT[node] = T[node*2] + T[node*2+1];\n}\n\nvoid dfs(int x, int p) {\n\tL[x] = ++cnt;\n\tfor (int i = 0; i < g[x].size(); i++)\n\t\tif (g[x][i].first != p) {\n\t\t\tps[g[x][i].second] = g[x][i].first; \n\t\t\tdfs(g[x][i].first, x); \n\t\t\tcnt++;\n\t\t}\n\tR[x] = cnt;\n}\n\nint main() {\n\tscanf(\"%d%d%lld\", &n, &Q, &k);\n\tfor (int i = 1; i < n; i++) {\n\t\tint u, v; scanf(\"%d%d%lld\", &u, &v, &w[i]);\n\t\tg[u].push_back(make_pair(v, i)); \n\t\tg[v].push_back(make_pair(u, i));\n\t}\n\tdfs(1, 0);\n\tfor (int i = 1; i < n; i++) update(1, 1, 2 * n, L[ps[i]], R[ps[i]], w[i]);\n\twhile (Q--) {\n\t\tll x, v; scanf(\"%lld%lld\", &x, &v);\n\t\tx = (x + ans) % (n - 1) + 1; \n\t\tv = (v + ans) % k;\n\t\tupdate(1, 1, 2 * n, L[ps[x]], R[ps[x]], v - w[x]);\n\t\tw[x] = v; \n\t\tprintf(\"%lld\\n\", ans = T[1].lmr);\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6dd1f79db2751640e5869ab356bd9b0e", "src_uid": "2c7349bc99e56b86a5c11b8c683b2b6c", "difficulty": null} {"lang": "GNU C++14", "source_code": "20 20 10000\n1 2 835\n1 3 57\n1 4 1883\n1 5 1349\n1 6 1543\n1 7 688\n1 8 272\n1 9 744\n1 10 569\n1 11 1019\n1 12 201\n1 13 1228\n1 14 1194\n1 15 1123\n1 16 48\n1 17 164\n1 18 893\n1 19 963\n1 20 818\n6 1\n0 7412\n10 6575\n15 6696\n0 7412\n4 8318\n18 7563\n15 7502\n1 7668\n13 7859\n14 8045\n2 7969\n12 8159\n11 8040\n2 8168\n12 8192\n0 8348\n14 8597\n13 8944\n0 8645\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "029b988e5515145ce3a275840cc75d38", "src_uid": "2c7349bc99e56b86a5c11b8c683b2b6c", "difficulty": null} {"lang": "GNU C++11", "source_code": "\u683c\u5f0f\u5316\u4ee3\u7801 \n#include\nusing namespace std;\n#define fp(i,l,r) for(register int (i)=(l);(i)<=(r);++(i))\n#define fd(i,l,r) for(register int (i)=(l);(i)>=(r);--(i))\n#define fe(i,u) for(register int (i)=front[(u)];(i);(i)=e[(i)].next)\n#define mem(a) memset((a),0,sizeof(a))\n#define int long long\ninline int read() {\n\tint x=0,f=1;char ch=getchar();\n\twhile(!isdigit(ch)) {if(ch=='-')f=-1;ch=getchar();}\n\twhile(isdigit(ch))x=x*10+ch-'0',ch=getchar();\n\treturn x*f;\n}\nconst int inf = 4e18;\nconst int MAXN = 2e5+10;\nint v1[MAXN<<2],v2[MAXN<<2],v12[MAXN<<2],v23[MAXN<<2],v123[MAXN<<2],tag[MAXN<<2],dis[MAXN];\n#define lson o<<1\n#define rson o<<1|1\ninline void pushup(int o){\n\tv1[o]=max(v1[lson],v1[rson]);v2[o]=min(v2[lson],v2[rson]);\n\tv12[o]=max(v12[lson],max(v12[rson],v1[lson]-2*v2[rson]));\n\tv23[o]=max(v23[lson],max(v23[rson],-2*v2[lson]+v1[rson]));\n\tv123[o]=max(v123[lson],max(v123[rson],max(v1[lson]+v23[rson],v12[lson]+v1[rson])));\n}\ninline void upd(int o,int v){\n\tv1[o]+=v;v2[o]+=v;v12[o]-=v;v23[o]-=v;\n\ttag[o]+=v;\n}\ninline void pushdown(int o){\n\tif(!tag[o])return;int v=tag[o];tag[o]=0;\n\tupd(lson,v);upd(rson,v);\n}\nvoid mdy(int o,int l,int r,int ql,int qr,int v){\n\tif(l>=ql&&r<=qr){upd(o,v);return;}\n\tint mid=l+r>>1;pushdown(o);\n\tif(ql<=mid)mdy(lson,l,mid,ql,qr,v);\n\tif(qr>mid)mdy(rson,mid+1,r,ql,qr,v);\n\tpushup(o);\n}\nint lst,front[MAXN],tcnt=1,idfn[MAXN],dfc,st[MAXN],ed[MAXN],n,q,mxw;\nstruct tEdge{\n\tint v,next,w;\n}e[MAXN];\nvoid dfs(int u,int f){\n\tidfn[++dfc]=u;st[u]=dfc;\n\tfe(i,u){\n\t\tint v=e[i].v;if(v==f)continue;dis[v]=dis[u]+e[i].w;\n\t\tdfs(v,u);idfn[++dfc]=u;\n\t}\n\ted[u]=dfc;\n}\nvoid build(int o,int l,int r){\n\tif(l==r){\n\t\tv1[o]=v2[o]=dis[idfn[l]];v12[o]=v23[o]=-dis[idfn[l]];\n\t\treturn;\n\t}\n\tint mid=l+r>>1;\n\tbuild(lson,l,mid);build(rson,mid+1,r);\n\tpushup(o);\n}\ninline void adde(int u,int v,int w){\n\te[++tcnt]=(tEdge){v,front[u],w};front[u]=tcnt;\n}\nmain(){\n\tn=read();q=read();mxw=read();\n\tfp(i,1,n-1){\n\t\tint u=read(),v=read(),w=read();\n\t\tadde(u,v,w);adde(v,u,w);\n\t}\n\tdfs(1,0);build(1,1,dfc);\n\t//fp(i,1,dfc)printf(\"%lld \",idfn[i]);puts(\"\");\n\twhile(q--){\n\t\tint p=(read()+lst)%(n-1)+1,w=(read()+lst)%mxw;p*=2;\n\t\tint v=st[e[p].v]\n#define F first\n#define S second\n#define mp make_pair\n#define pb push_back\n//#define ll __int128\n#define ll long long int\n#define LEFT(a) ((a)<<1)\n#define RIGHT(a) (LEFT(a) + 1)\n#define MID(a,b) ((a+b)>>1)\n#define MAX(a,b) ((a)>(b)?(a):(b))\n#define MIN(a,b) ((a)<(b)?(a):(b))\n/*\n#pragma GCC optimize (\"O3\")\n#pragma comment(linker, \"/STACK: 20000000005\")\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC target(\"avx2,fma\")\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n#pragma GCC target (\"avx2\")\n#pragma GCC optimization (\"unroll-loops\")\n*/\nusing namespace std;\n\nconst int N = 100005, M = 21;\n\nstruct node {\n node *l, *r;\n ll x;\n ll sh;\n node() {\n l = r = NULL;\n x = 0;\n sh = 0;\n }\n void shplit () {\n if (l == NULL)\n l = new node();\n if (r == NULL)\n r = new node();\n l->x += sh;\n l->sh += sh;\n r->x += sh;\n r->sh += sh;\n sh = 0;\n }\n};\n\nnode *root[N];\n\nint L, R;\nll X;\n\nvoid update (node *&t, int l, int r){\n if (t == NULL)\n t = new node();\n if (max (l, L) >= min (r, R))\n return;\n if (L <= l && r <= R){\n t->sh += X;\n t->x += X;\n return;\n }\n t->shplit();\n int mid = l + r >> 1;\n update (t->l, l, mid);\n update (t->r, mid, r);\n t->x = max (t->l->x, t->r->x);\n}\n\nll datvla (node *&t, int l, int r){\n if (t == NULL)\n t = new node();\n if (max (l, L) >= min (r, R))\n return 0;\n if (L <= l && r <= R)\n return t->x;\n t->shplit();\n int mid = l + r >> 1;\n ll x = datvla (t->l, l, mid);\n ll y = datvla (t->r, mid, r);\n t->x = max (t->l->x, t->r->x);\n return max (x, y);\n}\n\n\nll n, Q, W;\n\nint A[N], B[N];\nll C[N];\n\nvector < int > g[N];\nint TURN;\n\nint st[M][N], in[M][N], out[M][N], par[M][N];\n\nint S[N];\n\nmultiset < ll > Se[N];\nmultiset < ll > ANS;\nll pas[N], ans[M][N];\n\n\nint T = 0;\n\nint parent (int k, int p, int star, int papa){\n in[TURN][k] = ++T;\n if (papa == 0 && k != star)\n papa = k;\n st[TURN][k] = star;\n par[TURN][k] = papa;\n for (int u : g[k]){\n if (u == p || F[u] == 1)\n continue;\n parent (u, k, star, papa);\n }\n out[TURN][k] = T;\n}\n\nvoid go (int k, int turn){\n TURN = turn;\n T = 0;\n parent (k, 0, k, 0);\n for (int i = 0; i < g[k].size(); i++){\n int u = g[k][i];\n if (F[u])\n continue;\n Se[k].insert (0);\n }\n}\n\nvoid shecvla (ll d, ll e){\n int u = A[d], v = B[d];\n ll f = C[d];\n ll delta = e - f;\n for (int i = 1; i <= 1;i++){\n if (st[i][u] != st[i][v])\n break;\n int START = st[i][u];\n if (START == 0)\n break;\n if (in[i][u] > in[i][v])\n swap (u, v);\n int papa = par[i][v];\n auto I = Se[START].find (ans[i][papa]);\n Se[START].erase (I);\n L = in[i][v];\n R = out[i][v] + 1;\n X = delta;\n update (root[START], 1, out[i][START] + 1);\n L = in[i][papa];\n R = out[i][papa] + 1;\n ans[i][papa] = datvla (root[START], 1, out[i][START] + 1);\n Se[START].insert (ans[i][papa]);\n if ((int)Se[START].size() > 1){\n I = Se[START].end();\n I--;\n ll p1 = (*I);\n I--;\n ll p2 = (*I);\n I = ANS.find (pas[START]);\n ANS.erase (I);\n pas[START] = p1 + p2;\n ANS.insert (pas[START]);\n }\n else if ((int)Se[START].size() == 1){\n I = Se[START].end();\n I--;\n ll p1 = (*I);\n ll p2 = 0;\n I = ANS.find (pas[START]);\n ANS.erase (I);\n pas[START] = p1 + p2;\n ANS.insert (pas[START]);\n }\n }\n C[d] = e;\n}\n\n\nmain()\n{\n //freopen (\"in.txt\", \"r\", stdin);freopen (\"out.txt\", \"w\", stdout);\n //ios_base::sync_with_stdio(0);\n cin >> n >> Q >> W;\n /*if (n == 2){\n cin >> A[1] >> B[1] >> C[1];\n ll last = 0;\n while (Q--){\n ll d, e;\n scanf (\"%lld %lld\", &d, &e);\n d = (d + last) % (n - 1);\n e = (e + last) % W;\n last = e;\n cout << last << endl;\n }\n return 0;\n }*/\n for (int i = 0; i < n - 1; i++){\n int u, v, x;\n scanf (\"%d %d %d\", &u, &v, &x);\n A[i] = u;\n B[i] = v;\n C[i] = x;\n g[u].pb (v);\n g[v].pb (u);\n }\n for (int i = 1; i <= n; i++)\n ANS.insert (0);\n go (1, 1);\n for (int i = 0; i < n - 1; i++){\n ll x = C[i];\n C[i] = 0;\n shecvla (i, x);\n }\n ll last = 0;\n while (Q--){\n ll d, e;\n scanf (\"%lld %lld\", &d, &e);\n d = (d + last) % (n - 1);\n e = (e + last) % W;\n shecvla (d, e);\n auto I = ANS.end();\n I--;\n last = (*I);\n printf (\"%lld\\n\", last);\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a4c4627ee19a80c5c997e234aef08fdc", "src_uid": "2c7349bc99e56b86a5c11b8c683b2b6c", "difficulty": null} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define rep(i, s, e) for(int i = s; i < e; ++i)\n#define lson l, m, rt << 1\n#define rson m + 1, r, rt << 1 | 1\n#define P pair\n#define INF 0x3f3f3f3f\n#define Mod 998244353\nusing namespace std;\ntypedef long long ll;\nstatic const int N = 1005;\nstatic const int MAX_N = 2e5 + 5;\nint a[N], b[N];\nint n;\nbool judge(int x, int cnt, vectorvec[]){\n int day = x;\n for(int i = 1; i <= n; ++i) b[i] = a[i];\n int cur = 0;\n for(int i = x; i >= 1; --i){\n for(int j = 0; j < vec[i].size(); ++j){\n int t = vec[i][j];\n while(b[t] && day){\n --b[t];\n --cnt;\n --day;\n }\n }\n if(day >= i){\n ++cur;\n --day;\n }\n }\n return check >= 2 * cnt;\n}\nvoid solve(){\n// freopen(\"input.txt\", \"r\", stdin);\n// freopen(\"output.txt\", \"w\", stdout);\n //ios::sync_with_stdio(false);\n int m;\n while(scanf(\"%d%d\", &n, &m) != EOF){\n int cnt = 0;\n for(int i = 1; i <= n; ++i){\n scanf(\"%d\", &a[i]);\n cnt += a[i];\n }\n vectorvec[cnt << 1 | 1];\n for(int i = 0; i < m; ++i){\n int u, v;\n scanf(\"%d%d\", &u, &v);\n vec[u].push_back(v);\n }\n int l = cnt, r = cnt << 1;\n int ans = 0;\n while(l <= r){\n int m = l + r >> 1;\n if(judge(m, cnt, vec)){\n r = m - 1;\n ans = m;\n }\n else l = m + 1;\n }\n printf(\"%d\\n\", ans);\n }\n}\nint main() {\n solve();\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "15cb4dbf19b7cce3fb9c501c3a625446", "src_uid": "2eb101dcfcc487fe6e44c9b4c0e4024d", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n//1165 \n\n#define int long long\n\nconst int INF = 1e6 + 239;\n\nsigned main() {\n\tios_base::sync_with_stdio(false);\n\tcin.tie(0);\n\n\tint n, m;\n\tcin >> n >> m;\n\tvector k(n);\n\tfor (auto &t : k) {\n\t\tcin >> t;\n\t}\n\tvector> p(m);\n\tfor (auto &t : p) {\n\t\tcin >> t.first >> t.second;\n\t\tt.second--;\n\t}\n\tvector in(n, -1);\n\tfor (auto &t : p) {\n\t\tin[t.second] = max(in[t.second], t.first);\n\t}\n\tvector> ef;\n\tfor (int i = 0; i < n; i++) {\n\t\tif (in[i] != -1) {\n\t\t\tef.push_back({in[i], i});\n\t\t}\n\t}\n\tsort(ef.begin(), ef.end());\n\tauto ch = [&](int d) {\n\t\tvector left = k;\n\t\tint alr = 0;\n\t\tfor (auto t : ef) {\n\t\t\tif (t.first <= d) {\n\t\t\t\tint can = min(t.first - alr, left[t.second]);\n\t\t\t\tleft[t.second] -= can;\n\t\t\t\talr += can;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tfor (auto t : left) {\n\t\t\tcnt_need += 2 * t;\n\t\t}\n\t\tcnt_need -= alr;\n\t\tif (cnt_need <= d) {\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t};\n\tint l = 0;\n\tint r = INF;\n\twhile (r - l > 1) {\n\t\tint mid = (r + l) >> 1;\n\t\tif (ch(mid)) {\n\t\t\tr = mid;\n\t\t} else {\n\t\t\tl = mid;\n\t\t}\n\t}\n\tcout << r << endl;\n\t//cout << ch(100) << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "19e4de4c0418d79c3c11dd656c7598e9", "src_uid": "2eb101dcfcc487fe6e44c9b4c0e4024d", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "\n//\n// main.cpp\n// A\n//\n// Created by E SAMEER KUMAR on 09/04/20.\n// Copyright \u00a9 2020 E SAMEER KUMAR. All rights reserved.\n\n#include \nusing ll = long long;\nusing namespace std;\n//map> tree;\n//map> rooted;\n//map primes;\nvoid debugi(vector & vec){\n int n=(int)vec.size();\n for(int i=0;i & vec){\n int n=(int)vec.size();\n for(int i=0;i & mp){\n for(auto x:mp){\n cout< & st){\n for(auto x: st){\n cout<>& arr){\n for(int i=0;i<(int)arr.size();i++){\n cout<<\"[\"< &pi){\n cout< q){\n while(!q.empty()){\n cout<& tree,int n){\n// cout<& tree,int n){\n int s=0;\n while(k>=1){\n s+=tree[k];\n k-=(k&-k);\n }\n return s;\n}\n// char s[100006];\n// int m=200005;\n// int p;\n//int mod(int x,int mod){\n// if(x<0){\n// return mod-(x%mod);\n// }\n// else{\n// return x%mod;\n// }\n//}\nll gcd(ll a, ll b){\n if(b==0){\n return a;\n }\n return gcd(b,a%b);\n}\n// int n,m;\nll days=1e5;\nbool check(vector&k,vector>>&mp,ll cur){\n vector kcopy(k.size());\n for(int i=0;i0){\n int x=kcopy[mp[i][j].second];\n if(x>cnt){\n kcopy[mp[i][j].second]-=cnt;\n cnt=0;\n }\n else{\n kcopy[mp[i][j].second]=0;\n cnt-=x;\n }\n }\n }\n }\n // if(cur==6){\n // debugi(k);\n // debugi(kcopy);\n // cout<100 && cur==1354){\n cout<=(2*s*1LL)){\n return true;\n }\n return false;\n}\nint main(int argc, const char * argv[]) {\n // insert code here...\n // ofstream file;\n ios_base::sync_with_stdio(false); \n cin.tie(NULL);\n int n,m;\n cin>>n>>m;\n vector k(n+1);\n for(int i=1;i<=n;i++){\n cin>>k[i];\n }\n vector lastday(n+1,0);\n vector> q;\n for(int i=0;i>d>>t;\n q.push_back({d,t});\n lastday[t]=max(d,lastday[t]);\n }\n // int days=20;\n vector>> mp(days+1);\n for(int i=0;i\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\n\n#define endl \"\\n\"\n#define pb emplace_back\n#define fi first\n#define se second\n#define mp make_pair\n#define pii pair\n#define max_heap priority_queue\n#define min_heap priority_queue, greater >\n#define showArr(A,a,n) {for(int i = a; i < a + n; i++) cout << A[i] << \" \"; cout << endl;}\n#define showPair(A,a,n) {for(int i = a; i < a + n; i++) cout << A[i].fi << \" \" << A[i].se << endl;}\n\nconst ll MOD = 1e9 + 7;\nconst ll MAX = 2e5 + 5;\nll n, m;\nvector A(MAX);\nvector B(MAX);\n\nbool fun(ll aday) {\n\tll last[n];\n\tmemset(last, -1, sizeof(n));\n\tfor(int i = 0; i < m; i++) {\n\t\tif(B[i].fi <= aday) {\n\t\t\tlast[B[i].se] = B[i].fi;\n\t\t}\n\t}\n\tvector ldtypes[MAX];\n\tfor(int i = 0; i < n; i++) {\n\t\tif(last[i] != -1) {\n\t\t\tldtypes[last[i]].pb(i);\n\t\t}\n\t}\n\tvector req = A;\n\tll money = 0;\n\tfor(int i = 0; i <= aday; i++) {\n\t\tmoney++;\n\t\tif(i > 200000) {\n\t\t\tcontinue;\n\t\t}\n\t\tfor(ll x : ldtypes[i]) {\n\t\t\tif(req[x] <= money) {\n\t\t\t\tmoney -= req[x];\n\t\t\t\treq[x] = 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\treq[x] -= money;\n\t\t\t\tmoney = 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tll left = accumulate(req, req + n, 0);\n\treturn (2 * left <= money);\n}\n\nint main() {\n\tios::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tcin >> n >> m;\n\tfor(int i = 0; i < n; i++) {\n\t\tcin >> A[i];\n\t}\n\tfor(int i = 0; i < m; i++) {\n\t\tll x, y;\n\t\tcin >> x >> y;\n\t\tx--; y--;\n\t\tB[i].fi = x;\n\t\tB[i].se = y;\n\t}\n\n\t// sort(B.begin(), B.end());\n\tll low = 0, high = 400000;\n\twhile(high - low > 1) {\n\t\tll mid = (high + low) / 2;\n\t\tif(fun(mid)) {\n\t\t\thigh = mid;\n\t\t}\n\t\telse {\n\t\t\tlow = mid;\n\t\t}\n\t} \n\n\tfor(int i = low; i <= high; i++) {\n\t\tif(fun(i)) {\n\t\t\tcout << i + 1 << endl;\n\t\t\treturn 0;\n\t\t}\n\t}\n\t// cout << ((fun(low)) ? low + 1 : high + 1) << endl;\n\t\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9006ff54c7abfb0823d2f644a3a6754c", "src_uid": "2eb101dcfcc487fe6e44c9b4c0e4024d", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "//In the Name of God\n//Ya Ali\n\n#include\n\n#define int long long\n\n#define err(A) cout<<#A<<\" = \"<<(A)< > b;\n\ninline int p3(int x)\n{\n return x*x*x;\n}\n\ninline int r3(int x)\n{\n int ret=pow(10,log10(x)/3);\n while(p3(ret+1)<=x)\n ret++;\n return ret;\n}\n\ninline int f(int x)\n{\n return b.lower_bound({x+1,0ll})->second-1;\n}\n\ninline int ff(int x)\n{\n auto it=b.lower_bound({x+1,0ll});\n it--;\n return it->first;\n}\n\ninline int g(int x)\n{\n if(!x)\n return 0;\n //cout<<\"gi)t=bg6;n\n<=p3(A))\n\ta++;\n if(s+p3(a)<=m)\n\t{\n\t cnt++;\n\t s+=p3(a);\n\t b.insert({s,cnt});\n }\n else\n\tbreak;\n }\n b.insert({m+1,cnt+1});\n\n //////////////////////\n\n cin>>m;\n\n //cout<<\"HERE\n<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\n#pragma warning(disable:4996)\n#pragma comment(linker, \"/STACK:1000000000\")\n\n#define FOR(i, l, r, s) for (int i = (l); i < (r); i += (s))\n#define MFOR(i, l, r, s) for (int i = (l); i <= (r); i += (s))\n#define DFOR(i, r, l, s) for (int i = (r); i >= (l); i -= (s))\n#define ABS(a) (((a) > 0)? (a): -(a))\n#define MIN(a, b) (((a) < (b)) ? (a): (b))\n#define MAX(a, b) (((a) < (b)) ? (b): (a))\n#define SQR(a) (a) * (a)\n#define All(a) (a).begin(), (a).end()\n#define PI 3.1415926535897932384626433832795\n#define MEMS(a, b) memset((a), (b), sizeof(a))\n#define MP make_pair\n#define PB push_back\n#define endl '\\n'\n#define LL long long\n#define LD long double\n#define U unsigned\n#define X first\n#define Y second\n\nFILE *stream;\n\nconst LL INFL = (LL)(1e18);\nconst int INF = int(1e9);\nconst int SIZE = int(1e5 + 10);\nconst int TSIZE = int(1e2 + 10);\nconst LD eps = 0.00001;\nconst int MOD = int(1e9 + 7);\n\nvoid solution();\nLL cub(LL cur)\n{\n\treturn cur * cur * cur;\n}\n\nvoid solution()\n{\n\tLL prev = 0, cur = 1, k = -1, a[21] = {0}, n;\n\tcin >> n;\n\twhile (true)\n\t{\n\t\tif (prev + cur * cur * cur >= (cur + 1) * (cur + 1) * (cur + 1))\n\t\t{\n\t\t\tcur++;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprev += cur * cur * cur;\n\t\t\ta[++k] = cur;\n\t\t}\n\t\tif (prev >= n)\n\t\t\tbreak;\n\t}\n\twhile (true)\n\t{\n\t\tif (prev > n)\n\t\t{\n\t\t\tcur = a[k];\n\t\t\ta[k] = 0;\n\t\t\tk--;\n\t\t\tprev -= cub(cur);\n\t\t\tcur = a[k];\n\t\t}\n\t\telse\n\t\t{\n\t\t\tbreak;\n\t\t}\n\t}\n\t/*int l = k;\n\ta[k + 1] = 100001;\n\twhile (l >= 0)\n\t{\n\t\tif (a[l] + 1 <= a[l + 1] && prev - cub(a[l]) + cub(a[l] + 1) <= n)\n\t\t{\n\t\t\tLL prev1 = 0, cur1, p = 1;\n\t\t\tfor (int j = 0; j <= k; j++)\n\t\t\t{\n\t\t\t\tcur1 = a[j];\n\t\t\t\tif (l == j) cur1++;\n\t\t\t\tif (prev1 + cub(cur1) >= cub(cur1 + 1))\n\t\t\t\t{\n\t\t\t\t\tp = 0;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tprev1 += cub(cur1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (p)\n\t\t\t{\n\t\t\t\tprev = prev - cub(a[l]) + cub(a[l] + 1);\n\t\t\t\ta[l]++;\n\t\t\t}\n\t\t\telse\n\t\t\t\tl--;\n\t\t}\n\t\telse\n\t\t\tl--;\n\t}\n\t/*for (int i = 0; i <= k; i++)\n\t\tcout << a[i] << \" \";\n\tcout << endl;\n\t*/\n\tcout << k + 1 << \" \";\n\tfor (LL i = n; i >= prev; i--)\n\t{\n\t\tLL cur = i;\n\t\tint kil = 0;\n\t\twhile (cur > 0)\n\t\t{\n\t\t\tLL buf = (LL)(pow(cur, 1 / 3.0));\n\t\t\tif (cub(buf) <= cur)\n\t\t\t{\n\t\t\t\tcur -= cub(buf);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcur -= cub(buf - 1);\n\t\t\t}\n\t\t\tkil++;\n\t\t}\n\t\tif (kil == k + 1)\n\t\t{\n\t\t\tcout << i;\n\t\t\treturn;\n\t\t}\n\t}\n\tcout << i;\n}\n\nLL POW(LL z, int step)\n{\n\tif (step < 1)\n\t\treturn 1;\n\tif (step == 1)\n\t\treturn z;\n\tLL cur = POW(z, step / 2);\n\tcur *= cur;\n\tif (step % 2)\n\t\tcur *= z;\n\treturn cur;\n}\n\nint main()\n{\n#ifdef SpOleM98\n\t// Test \n\t//freopen(\"input.txt\", \"w\", stdout);\n\n\t//Read\n\tfreopen(\"input.txt\", \"r\", stdin);\n\t//freopen(\"output.txt\", \"w\", stdout);\n\tdouble beg = clock();\n#endif\n\tsrand(time(0));\n\tsolution();\n#ifdef SpOleM98\n\tdouble end = clock();\n\tfprintf(stderr, \"*** Total time = %.3lf ***\\n\", (end - beg) / CLOCKS_PER_SEC);\n\t//char ch = getche();\n#endif\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2803123dc40ede9beb6929cc9e4eb550", "src_uid": "385cf3c40c96f0879788b766eeb25139", "difficulty": 2200.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nlong long mypow(long long a){\n\treturn a*a*a;\n}\n\npair maxsofar;\n\nvoid rec(int m,int ans, int index){\n\tif(m == 0){\n\t\tmaxsofar = max(maxsofar,make_pair(ans,index));\n\t\treturn;\n\t}\n\tint x= 1;\n\twhile(mypow(x+1)<=m) x++;\n\trec(m-mypow(x),ans+1,index+mypow(x));\n\tif(x>=1){\n\t\trec(my_pow(x)-1-mypow(x-1),ans+1,index+mypow(x-1));\n\t}\n}\n\nint main(){\n\tlong long m;\n\tcin >> m;\n\trec(m,0,0);\n\tcout << maxsofar.first << \" \" << maxsofar.second << endl;\n}\n\t", "lang_cluster": "C++", "compilation_error": true, "code_uid": "19f98314e43a7e6cf4bfb76d50257e7e", "src_uid": "385cf3c40c96f0879788b766eeb25139", "difficulty": 2200.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#define ll long long\n#define Max(a,b) (((a) < (b))?(b):(a))\n#define Min(a,b) (((a) > (b))?(b):(a))\n#define X first\n#define Y second\nusing namespace std;\nint a[70] = {0,1,2,3,4,5,6,7,1,2,3,4,5,6,7,8,2,3,4,5,6,7,8,9,3,4,5,1,2,3,4,5,6,7,8,2,3,4,5,6,7,8,9,3,4,5,6,7,8,9,10,4,5,6,2,3,4,5,6,7,8,9,3,4,1,2,3,4,5};\nint mm[66],pos[66];\n//ll a[67];\nvector p;\npair answer(ll m) {\n\tif(m < 66) {\n\t\treturn make_pair(a[pos[m]],pos[m]);\n\t}\n\tll k = (ll)pow(m,1/3.);\n\tll l = k-1,ans;\n\tpair p1,p2;\n\tp1 = answer(m-k*k*k);\n\t++(p1.X);\n\tp1.Y += k*k*k;\n\tp2 = answer(k*k*k-1-l*l*l);\n\t++(p2.X);\n\tp2.Y += l*l*l;\n\tif(p1.X > p2.X) \n\t\treturn p1;\n\telse if(p1.X == p2.X) {\n\t\tif(p1.Y >= p2.Y) {\n\t\t\treturn p1;\n\t}\n\treturn p2;\n}\n\t\t\nint main() {\n\tll x;\n\tx = mm[0] = pos[0] = 0;\n\tfor(int i = 1 ; i < 66 ; i++) {\n\t\tif(mm[i-1] <= a[i]) pos[i] = i;\n\t\telse pos[i] = pos[i-1];\n\t}\n\tll m;\n\tcin >> m;\n\tpair n = answer(m);\n\tx = n.Y;\n\tcout << n.X << \" \" << n.Y << endl;\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "868b750e6b3e13371ec462479adba13e", "src_uid": "385cf3c40c96f0879788b766eeb25139", "difficulty": 2200.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\nusing namespace std;\ntypedef long long LL;\nconst int mod = 1e9+9;\nint n,h;\nint dp[1005][2][40][40][40];\nint fm(int &u)\n{\n\t(u+=val)%=modd;\n}\n\nint main(){\n // freopen(\"CF268D.in\",\"r\",stdin);\n // freopen(\"CF268D.out\",\"w\",stdout);\n cin>>n>>h;\n // cout</*{{{*/\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;typedef long long ll;typedef long double real;void run();int main(){ios::sync_with_stdio(0);run();}/*}}}*/\nll const lots=1000000009ll;\nint n,h;\n\nstatic int memo[1000][32][32][32][32];\nll plough[100];\n\nint calc(int n,int a,int b,int c,int d){\n a=min(a,h); b=min(b,h); c=min(c,h); d=min(d,h);\n if (n>n>>h;\n plough[0]=1; for (int i=0; i<50; i++) (plough[i+1]=plough[i]*4)%lots;\n cout<<(lots+calc(n,0,0,0,0))%lots<\nusing namespace std;\nll dp[1001][31][31][31][2];\nint mod=1e9+9; \nint n,h,ans;\nint main()\n{\n\tcin>>n>>h;\n\tdp[1][1][1][1][1]=4;\n\tif(h==1)\n\t{\n\t\tcout<<4< pii;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vb;\ntypedef vector vvb;\ntypedef vector vll;\ntypedef vector vvll;\n\n#define TASKNAME \"text\"\n#define pb push_back\n#define mp make_pair\n#define EPS (1E-9)\n#define INF ((int)1E9)\n#define sqr(x) ((x) * (x))\n#define eprintf(...) fprintf(stderr, __VA_ARGS__)\n#define sz(x) ((int)(x).size())\n\nconst int maxh = 31;\nint d[2][maxh][maxh][maxh][maxh];\n\nconst int MOD = (int)1e9 + 9;\ninline void add(int &x, int toadd) {\n\tif ((x += toadd) >= MOD)\n\t\tx -= MOD;\n}\n\n\nint tmp[4];\ninline void update(int it, int v1, int v2, int v3, int v4, int toadd) {\n\ttmp[0] = v1, tmp[1] = v2, tmp[2] = v3, tmp[3] = v4;\n\tsort(tmp, tmp + 4);\n\tadd(d[it][tmp[0]][tmp[1]][tmp[2]][tmp[3]], toadd);\n}\n\nint main() {\n\t#ifdef DEBUG\n\t\tfreopen(TASKNAME\".in\", \"r\", stdin);\n\t\tfreopen(TASKNAME\".out\", \"w\", stdout);\n\t#endif\n\n\tint n, h;\n\twhile (scanf(\"%d%d\", &n, &h) >= 1) {\n\t\tmemset(d, 0, sizeof(d));\n\t\td[0][0][0][0][0] = 1;\n\t\tfor (int iter = 0; iter < n; iter++) {\n\t\t\tfor (int _v1 = 0; _v1 <= h; _v1++)\n\t\t\t\tfor (int _v2 = _v1; _v2 <= h; _v2++)\n\t\t\t\t\tfor (int _v3 = _v2; _v3 <= h; _v3++)\n\t\t\t\t\t\tfor (int _v4 = _v3; _v4 <= h; _v4++) {\n\t\t\t\t\t\t\tint v1 = _v1, v2 = _v2, v3 = _v3, v4 = _v4;\n\t\t\t\t\t\t\tint &cur = d[iter & 1][v1][v2][v3][v4];\n\t\t\t\t\t\t\tif (!cur)\n\t\t\t\t\t\t\t\tcontinue;\n// \t\t\t\t\t\t\teprintf(\"d[%d][%d][%d][%d][%d] = %d\\n\", iter, v1, v2, v3, v4, cur);\n\t\t\t\t\t\t\tint b1 = v1 < h, b2 = v2 < h, b3 = v3 < h, b4 = v4 < h;\n\t\t\t\t\t\t\t++v1, ++v2, ++v3, ++v4;\n\t\t\t\t\t\t\tv1 = min(v1, h);\n\t\t\t\t\t\t\tv2 = min(v2, h);\n\t\t\t\t\t\t\tv3 = min(v3, h);\n\t\t\t\t\t\t\tv4 = min(v4, h);\n\n\t\t\t\t\t\t\tupdate(!(iter & 1), b1 ? 0 : h, v2, v3, v4, cur);\n\t\t\t\t\t\t\tupdate(!(iter & 1), v1, b2 ? 0 : h, v3, v4, cur);\n\t\t\t\t\t\t\tupdate(!(iter & 1), v1, v2, b3 ? 0 : h, v4, cur);\n\t\t\t\t\t\t\tupdate(!(iter & 1), v1, v2, v3, b4 ? 0 : h, cur);\n\t\t\t\t\t\t\tcur = 0;\n\t\t\t\t\t\t}\n\t\t}\n\t\tint ans = 0;\n\t\tfor (int _v1 = 0; _v1 <= h; _v1++)\n\t\t\tfor (int _v2 = _v1; _v2 <= h; _v2++)\n\t\t\t\tfor (int _v3 = _v2; _v3 <= h; _v3++)\n\t\t\t\t\tfor (int _v4 = _v3; _v4 <= h; _v4++)\n\t\t\t\t\t\tadd(ans, d[n & 1][_v1][_v2][_v3][_v4]);\n// \t\teprintf(\"ans = %d\\n\", ans);\n\t\tadd(ans, MOD - d[n & 1][h][h][h][h]);\n\t\tprintf(\"%d\\n\", ans);\n// \t\tbreak;\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "48cfad12008873757ea2599cb831b618", "src_uid": "9fe9658db35076c0bddc8b7ddce11013", "difficulty": 2300.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main()\n{\n int x;\n cin>>x;\n map a;\n for(int i=0;i>n;\n a[n]++;\n }\n map::iterator it;\n it=a.begin();\n int m=it->second,x=it->first;\n it++;\n int n=it->second,y=it->first;\n if(a.size()==2 && m==n)\n {\n cout<<\"YES\"<<'\\n';\n\n cout<\nusing namespace std;\nint main()\n{\n\tint n,x,av=-1,bv=-1,a=0,b=0,f;\n cin>>n;\n f=1;\n for(int i=1;i<=n;i++)\n {\n\tcin>>x; \n if(a==0||x==av){a++;av=x;} \n\telse if(b==0||x==bv){b++;bv=x;} \n\telse {f=0;break;}\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "be8eff9687db29589dbf512523fd43f8", "src_uid": "2860b4fb22402ea9574c2f9e403d63d8", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n\nint n,sum=0,top=0;\nint flag[107],ans[107]\n\nint main()\n{\n\tscanf(\"%d\",&n);\n\tint x;\n\tfor (int i=1;i<=n;i++)\n\t{\n\t\tscanf(\"%d\",&x);\n\t\tif (!flag[x]) sum++;\n\t\tflag[x]++;\n\t\tans[++top]=x;\n\t}\n\tif (sum!=2) printf(\"NO\\n\");\n\telse\n\t{\n\t\tprintf(\"YES\\n\");\n\t\tif (ans[1]>ans[2]) swap(ans[1],ans[2]);\n\t\tprintf(\"%d %d\",ans[1],ans[2]);\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ea61eed8cf2a3b00ed52c8f1933c3ab2", "src_uid": "2860b4fb22402ea9574c2f9e403d63d8", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#incldue\nusing namespace std;\n\nint main(){\n int n;\n cin>>n;\n int a=-1,b=-1,cnta=0,cntb=0;\n for(int i=0;i>temp;\n if(a==-1)\n a=temp;\n else if(a!=temp && b==-1)\n b=temp;\n else{\n cout<<\"NO\";\n return 0;\n }\n if(a==temp)\n cnta++;\n else\n cntb++;\n }\n if(cnta!=cntb){\n cout<<\"NO\";\n return 0;\n }\n cout<<\"YES\\n\"\n cout<\n\n\n#include \n\nnamespace atcoder {\n\nnamespace internal {\n\n// @param m `1 <= m`\n// @return x mod m\nconstexpr long long safe_mod(long long x, long long m) {\n x %= m;\n if (x < 0) x += m;\n return x;\n}\n\n// Fast moduler by barrett reduction\n// Reference: https://en.wikipedia.org/wiki/Barrett_reduction\n// NOTE: reconsider after Ice Lake\nstruct barrett {\n unsigned int _m;\n unsigned long long im;\n\n // @param m `1 <= m`\n barrett(unsigned int m) : _m(m), im((unsigned long long)(-1) / m + 1) {}\n\n // @return m\n unsigned int umod() const { return _m; }\n\n // @param a `0 <= a < m`\n // @param b `0 <= b < m`\n // @return `a * b % m`\n unsigned int mul(unsigned int a, unsigned int b) const {\n // [1] m = 1\n // a = b = im = 0, so okay\n\n // [2] m >= 2\n // im = ceil(2^64 / m)\n // -> im * m = 2^64 + r (0 <= r < m)\n // let z = a*b = c*m + d (0 <= c, d < m)\n // a*b * im = (c*m + d) * im = c*(im*m) + d*im = c*2^64 + c*r + d*im\n // c*r + d*im < m * m + m * im < m * m + 2^64 + m <= 2^64 + m * (m + 1) < 2^64 * 2\n // ((ab * im) >> 64) == c or c + 1\n unsigned long long z = a;\n z *= b;\n#ifdef _MSC_VER\n unsigned long long x;\n _umul128(z, im, &x);\n#else\n unsigned long long x =\n (unsigned long long)(((unsigned __int128)(z)*im) >> 64);\n#endif\n unsigned int v = (unsigned int)(z - x * _m);\n if (_m <= v) v += _m;\n return v;\n }\n};\n\n// @param n `0 <= n`\n// @param m `1 <= m`\n// @return `(x ** n) % m`\nconstexpr long long pow_mod_constexpr(long long x, long long n, int m) {\n if (m == 1) return 0;\n unsigned int _m = (unsigned int)(m);\n unsigned long long r = 1;\n unsigned long long y = safe_mod(x, m);\n while (n) {\n if (n & 1) r = (r * y) % _m;\n y = (y * y) % _m;\n n >>= 1;\n }\n return r;\n}\n\n// Reference:\n// M. Forisek and J. Jancina,\n// Fast Primality Testing for Integers That Fit into a Machine Word\n// @param n `0 <= n`\nconstexpr bool is_prime_constexpr(int n) {\n if (n <= 1) return false;\n if (n == 2 || n == 7 || n == 61) return true;\n if (n % 2 == 0) return false;\n long long d = n - 1;\n while (d % 2 == 0) d /= 2;\n for (long long a : {2, 7, 61}) {\n long long t = d;\n long long y = pow_mod_constexpr(a, t, n);\n while (t != n - 1 && y != 1 && y != n - 1) {\n y = y * y % n;\n t <<= 1;\n }\n if (y != n - 1 && t % 2 == 0) {\n return false;\n }\n }\n return true;\n}\ntemplate constexpr bool is_prime = is_prime_constexpr(n);\n\n// @param b `1 <= b`\n// @return pair(g, x) s.t. g = gcd(a, b), xa = g (mod b), 0 <= x < b/g\nconstexpr std::pair inv_gcd(long long a, long long b) {\n a = safe_mod(a, b);\n if (a == 0) return {b, 0};\n\n // Contracts:\n // [1] s - m0 * a = 0 (mod b)\n // [2] t - m1 * a = 0 (mod b)\n // [3] s * |m1| + t * |m0| <= b\n long long s = b, t = a;\n long long m0 = 0, m1 = 1;\n\n while (t) {\n long long u = s / t;\n s -= t * u;\n m0 -= m1 * u; // |m1 * u| <= |m1| * s <= b\n\n // [3]:\n // (s - t * u) * |m1| + t * |m0 - m1 * u|\n // <= s * |m1| - t * u * |m1| + t * (|m0| + |m1| * u)\n // = s * |m1| + t * |m0| <= b\n\n auto tmp = s;\n s = t;\n t = tmp;\n tmp = m0;\n m0 = m1;\n m1 = tmp;\n }\n // by [3]: |m0| <= b/g\n // by g != b: |m0| < b/g\n if (m0 < 0) m0 += b / s;\n return {s, m0};\n}\n\n// Compile time primitive root\n// @param m must be prime\n// @return primitive root (and minimum in now)\nconstexpr int primitive_root_constexpr(int m) {\n if (m == 2) return 1;\n if (m == 167772161) return 3;\n if (m == 469762049) return 3;\n if (m == 754974721) return 11;\n if (m == 998244353) return 3;\n int divs[20] = {};\n divs[0] = 2;\n int cnt = 1;\n int x = (m - 1) / 2;\n while (x % 2 == 0) x /= 2;\n for (int i = 3; (long long)(i)*i <= x; i += 2) {\n if (x % i == 0) {\n divs[cnt++] = i;\n while (x % i == 0) {\n x /= i;\n }\n }\n }\n if (x > 1) {\n divs[cnt++] = x;\n }\n for (int g = 2;; g++) {\n bool ok = true;\n for (int i = 0; i < cnt; i++) {\n if (pow_mod_constexpr(g, (m - 1) / divs[i], m) == 1) {\n ok = false;\n break;\n }\n }\n if (ok) return g;\n }\n}\ntemplate constexpr int primitive_root = primitive_root_constexpr(m);\n\n} // namespace internal\n\n} // namespace atcoder\n\n\n#include \n#include \n#include \n\nnamespace atcoder {\n\nnamespace internal {\n\n#ifndef _MSC_VER\ntemplate \nusing is_signed_int128 =\n typename std::conditional::value ||\n std::is_same::value,\n std::true_type,\n std::false_type>::type;\n\ntemplate \nusing is_unsigned_int128 =\n typename std::conditional::value ||\n std::is_same::value,\n std::true_type,\n std::false_type>::type;\n\ntemplate \nusing make_unsigned_int128 =\n typename std::conditional::value,\n __uint128_t,\n unsigned __int128>;\n\ntemplate \nusing is_integral = typename std::conditional::value ||\n is_signed_int128::value ||\n is_unsigned_int128::value,\n std::true_type,\n std::false_type>::type;\n\ntemplate \nusing is_signed_int = typename std::conditional<(is_integral::value &&\n std::is_signed::value) ||\n is_signed_int128::value,\n std::true_type,\n std::false_type>::type;\n\ntemplate \nusing is_unsigned_int =\n typename std::conditional<(is_integral::value &&\n std::is_unsigned::value) ||\n is_unsigned_int128::value,\n std::true_type,\n std::false_type>::type;\n\ntemplate \nusing to_unsigned = typename std::conditional<\n is_signed_int128::value,\n make_unsigned_int128,\n typename std::conditional::value,\n std::make_unsigned,\n std::common_type>::type>::type;\n\n#else\n\ntemplate using is_integral = typename std::is_integral;\n\ntemplate \nusing is_signed_int =\n typename std::conditional::value && std::is_signed::value,\n std::true_type,\n std::false_type>::type;\n\ntemplate \nusing is_unsigned_int =\n typename std::conditional::value &&\n std::is_unsigned::value,\n std::true_type,\n std::false_type>::type;\n\ntemplate \nusing to_unsigned = typename std::conditional::value,\n std::make_unsigned,\n std::common_type>::type;\n\n#endif\n\ntemplate \nusing is_signed_int_t = std::enable_if_t::value>;\n\ntemplate \nusing is_unsigned_int_t = std::enable_if_t::value>;\n\ntemplate using to_unsigned_t = typename to_unsigned::type;\n\n} // namespace internal\n\n} // namespace atcoder\n\n#include \n#include \n#include \n\n#ifdef _MSC_VER\n#include \n#endif\n\nnamespace atcoder {\n\nnamespace internal {\n\nstruct modint_base {};\nstruct static_modint_base : modint_base {};\n\ntemplate using is_modint = std::is_base_of;\ntemplate using is_modint_t = std::enable_if_t::value>;\n\n} // namespace internal\n\ntemplate * = nullptr>\nstruct static_modint : internal::static_modint_base {\n using mint = static_modint;\n\n public:\n static constexpr int mod() { return m; }\n static mint raw(int v) {\n mint x;\n x._v = v;\n return x;\n }\n\n static_modint() : _v(0) {}\n template * = nullptr>\n static_modint(T v) {\n long long x = (long long)(v % (long long)(umod()));\n if (x < 0) x += umod();\n _v = (unsigned int)(x);\n }\n template * = nullptr>\n static_modint(T v) {\n _v = (unsigned int)(v % umod());\n }\n static_modint(bool v) { _v = ((unsigned int)(v) % umod()); }\n\n unsigned int val() const { return _v; }\n\n mint& operator++() {\n _v++;\n if (_v == umod()) _v = 0;\n return *this;\n }\n mint& operator--() {\n if (_v == 0) _v = umod();\n _v--;\n return *this;\n }\n mint operator++(int) {\n mint result = *this;\n ++*this;\n return result;\n }\n mint operator--(int) {\n mint result = *this;\n --*this;\n return result;\n }\n\n mint& operator+=(const mint& rhs) {\n _v += rhs._v;\n if (_v >= umod()) _v -= umod();\n return *this;\n }\n mint& operator-=(const mint& rhs) {\n _v -= rhs._v;\n if (_v >= umod()) _v += umod();\n return *this;\n }\n mint& operator*=(const mint& rhs) {\n unsigned long long z = _v;\n z *= rhs._v;\n _v = (unsigned int)(z % umod());\n return *this;\n }\n mint& operator/=(const mint& rhs) { return *this = *this * rhs.inv(); }\n\n mint operator+() const { return *this; }\n mint operator-() const { return mint() - *this; }\n\n mint pow(long long n) const {\n assert(0 <= n);\n mint x = *this, r = 1;\n while (n) {\n if (n & 1) r *= x;\n x *= x;\n n >>= 1;\n }\n return r;\n }\n mint inv() const {\n if (prime) {\n assert(_v);\n return pow(umod() - 2);\n } else {\n auto eg = internal::inv_gcd(_v, m);\n assert(eg.first == 1);\n return eg.second;\n }\n }\n\n friend mint operator+(const mint& lhs, const mint& rhs) {\n return mint(lhs) += rhs;\n }\n friend mint operator-(const mint& lhs, const mint& rhs) {\n return mint(lhs) -= rhs;\n }\n friend mint operator*(const mint& lhs, const mint& rhs) {\n return mint(lhs) *= rhs;\n }\n friend mint operator/(const mint& lhs, const mint& rhs) {\n return mint(lhs) /= rhs;\n }\n friend bool operator==(const mint& lhs, const mint& rhs) {\n return lhs._v == rhs._v;\n }\n friend bool operator!=(const mint& lhs, const mint& rhs) {\n return lhs._v != rhs._v;\n }\n\n private:\n unsigned int _v;\n static constexpr unsigned int umod() { return m; }\n static constexpr bool prime = internal::is_prime;\n};\n\ntemplate struct dynamic_modint : internal::modint_base {\n using mint = dynamic_modint;\n\n public:\n static int mod() { return (int)(bt.umod()); }\n static void set_mod(int m) {\n assert(1 <= m);\n bt = internal::barrett(m);\n }\n static mint raw(int v) {\n mint x;\n x._v = v;\n return x;\n }\n\n dynamic_modint() : _v(0) {}\n template * = nullptr>\n dynamic_modint(T v) {\n long long x = (long long)(v % (long long)(mod()));\n if (x < 0) x += mod();\n _v = (unsigned int)(x);\n }\n template * = nullptr>\n dynamic_modint(T v) {\n _v = (unsigned int)(v % mod());\n }\n dynamic_modint(bool v) { _v = ((unsigned int)(v) % mod()); }\n\n unsigned int val() const { return _v; }\n\n mint& operator++() {\n _v++;\n if (_v == umod()) _v = 0;\n return *this;\n }\n mint& operator--() {\n if (_v == 0) _v = umod();\n _v--;\n return *this;\n }\n mint operator++(int) {\n mint result = *this;\n ++*this;\n return result;\n }\n mint operator--(int) {\n mint result = *this;\n --*this;\n return result;\n }\n\n mint& operator+=(const mint& rhs) {\n _v += rhs._v;\n if (_v >= umod()) _v -= umod();\n return *this;\n }\n mint& operator-=(const mint& rhs) {\n _v += mod() - rhs._v;\n if (_v >= umod()) _v -= umod();\n return *this;\n }\n mint& operator*=(const mint& rhs) {\n _v = bt.mul(_v, rhs._v);\n return *this;\n }\n mint& operator/=(const mint& rhs) { return *this = *this * rhs.inv(); }\n\n mint operator+() const { return *this; }\n mint operator-() const { return mint() - *this; }\n\n mint pow(long long n) const {\n assert(0 <= n);\n mint x = *this, r = 1;\n while (n) {\n if (n & 1) r *= x;\n x *= x;\n n >>= 1;\n }\n return r;\n }\n mint inv() const {\n auto eg = internal::inv_gcd(_v, mod());\n assert(eg.first == 1);\n return eg.second;\n }\n\n friend mint operator+(const mint& lhs, const mint& rhs) {\n return mint(lhs) += rhs;\n }\n friend mint operator-(const mint& lhs, const mint& rhs) {\n return mint(lhs) -= rhs;\n }\n friend mint operator*(const mint& lhs, const mint& rhs) {\n return mint(lhs) *= rhs;\n }\n friend mint operator/(const mint& lhs, const mint& rhs) {\n return mint(lhs) /= rhs;\n }\n friend bool operator==(const mint& lhs, const mint& rhs) {\n return lhs._v == rhs._v;\n }\n friend bool operator!=(const mint& lhs, const mint& rhs) {\n return lhs._v != rhs._v;\n }\n\n private:\n unsigned int _v;\n static internal::barrett bt;\n static unsigned int umod() { return bt.umod(); }\n};\ntemplate internal::barrett dynamic_modint::bt = 998244353;\n\nusing modint998244353 = static_modint<998244353>;\nusing modint1000000007 = static_modint<1000000007>;\nusing modint = dynamic_modint<-1>;\n\nnamespace internal {\n\ntemplate \nusing is_static_modint = std::is_base_of;\n\ntemplate \nusing is_static_modint_t = std::enable_if_t::value>;\n\ntemplate struct is_dynamic_modint : public std::false_type {};\ntemplate \nstruct is_dynamic_modint> : public std::true_type {};\n\ntemplate \nusing is_dynamic_modint_t = std::enable_if_t::value>;\n\n} // namespace internal\n\n} // namespace atcoder\n\n\nusing namespace std;\ntypedef long long ll;\ntypedef pair pii;\n#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)\n#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)\n#define REP(i, n) FOR(i, 0, (n)-1)\n#define sqr(x) ((x) * (x))\n#define all(x) (x).begin(), (x).end()\n#define reset(x, y) memset(x, y, sizeof(x))\n#define uni(x) (x).erase(unique(all(x)), (x).end())\n#define BUG(x) cerr << #x << \" = \" << (x) << endl\n#define pb push_back\n#define eb emplace_back\n#define mp make_pair\n#define _1 first\n#define _2 second\n#define chkmin(a, b) a = min(a, b)\n#define chkmax(a, b) a = max(a, b)\n\nusing mint = atcoder::modint998244353;\n\nconst int maxn = 512234;\n\nmint f[maxn][1 << 10];\nint n, m, m1[10], m2[10];\n\nint main() {\n#ifdef ONLINE_JUDGE\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n#endif\n cin >> n >> m;\n FOR(i, 1, m) {\n int x, y;\n cin >> x >> y;\n m1[x] |= 1 << y;\n m2[y] |= 1 << x;\n }\n f[0][0] = 1;\n FOR(i, 1, n) REP(mask, 1 << 10) if (f[i - 1][mask] != 0) REP(j, 10) if ((mask & (1 << j)) == 0)\n f[i][(mask & m1[j]) | m2[j]] += f[i - 1][mask];\n mint ans = 0;\n REP(mask, 1 << 10) ans += f[n][mask];\n cout << ans.val();\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6352da2ae1feffba889ae7396814eb93", "src_uid": "60955fc2caa6ec99c7dcc1da5d36b1f8", "difficulty": 2600.0} {"lang": "GNU C++20 (64)", "source_code": "#include \r\n\r\nconstexpr int P = 998244353;\r\nusing i64 = long long;\r\n// assume -P <= x < 2P\r\nint norm(int x) {\r\n if (x < 0) {\r\n x += P;\r\n }\r\n if (x >= P) {\r\n x -= P;\r\n }\r\n return x;\r\n}\r\nint main() {\r\n std::ios::sync_with_stdio(false);\r\n std::cin.tie(nullptr);\r\n \r\n int n;\r\n std::cin >> n;\r\n \r\n int m;\r\n std::cin >> m;\r\n \r\n std::array bad {};\r\n for (int i = 0; i < 10; i++) {\r\n for (int j = 0; j < 10; j++) {\r\n if (i != j) {\r\n bad[i] |= 1 << j;\r\n }\r\n }\r\n }\r\n for (int i = 0; i < m; i++) {\r\n int u, v;\r\n std::cin >> u >> v;\r\n bad[u] ^= 1 << v;\r\n bad[v] ^= 1 << u;\r\n }\r\n \r\n std::array f {};\r\n f.back() = 1;\r\n for (int i = 0; i < n; i++) {\r\n std::array g {};\r\n for (int s = 0; s < (1 << 10); s++) {\r\n for (int i = 0; i < 10; i++) {\r\n if (s >> i & 1) {\r\n int t = (s & ~((1 << i) - 1)) | bad[i];\r\n g[t] =(g[t]+ f[s])%mod;\r\n }\r\n }\r\n }\r\n f = g;\r\n }\r\n int ans=0;\r\n for(int i=0;i<(1<<10);i++)\r\n {\r\n \tans+=f[i];\r\n \tans=ans%mod;\r\n\t}\r\n \r\n std::cout << ans << \"\\n\";\r\n \r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "45ef3e69a1de17e3e8405456bbf65e9a", "src_uid": "60955fc2caa6ec99c7dcc1da5d36b1f8", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "#include \"bits/stdc++.h\"\r\n\r\nusing namespace std;\r\n\r\nusing LL = long long;\r\n\r\n#define MN 50005\r\n#define MC 10\r\n#define MOD 998244353\r\n\r\n#define bit(x) (1 << (x))\r\n\r\nint f[MC][MC];\r\nLL dp[MN][bit(MC)];\r\nint nxt[bit(MC)][MC];\r\n\r\nint main() {\r\n#ifndef ONLINE_JUDGE\r\n\tfreopen(\"in.txt\", \"r\", stdin);\r\n#endif\r\n\tios::sync_with_stdio(0);\r\n\tcin.tie(0); cout.tie(0);\r\n\tmemset(dp, 0, sizeof dp);\r\n\tint n, m, u, v;\r\n\tcin >> n >> m;\r\n\tfor (int i = 0; i < m; i ++) {\r\n\t\tcin >> u >> v;\r\n\t\tf[u][v] = f[v][u] = 1;\r\n\t}\r\n\t\r\n\tfor (int i = 0; i < bit(MC); i ++) {\r\n\t\tfor (int k, j = 0; j < MC; j ++) {\r\n\t\t\tfor (k = 0; k < j; k ++) {\r\n\t\t\t\tif ((i & bit(k)) && f[j][k]) break;\r\n\t\t\t}\r\n\t\t\tif (k == j) {\r\n\t\t\t\tnxt[i][j] = bit(j);\r\n\t\t\t\tfor (k = j + 1; k < MC; k ++) {\r\n\t\t\t\t\tif ((bit(k) & i) && f[k][j]) nxt[i][j] |= bit(k);\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tnxt[i][j] = -1;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tdp[0][0] = 1;\r\n\tfor (int i = 0; i < n; i ++) {\r\n\t\tfor (int j = 0; j < bit(MC); j ++) {\r\n\t\t\tfor (int k = 0; k < MC; k ++) {\r\n\t\t\t\tif (nxt[j][k] < 0) continue;\r\n\t\t\t\tdp[i + 1][nxt[j][k]] += dp[i][j];\r\n\t\t\t\tif (dp[i + 1][nxt[j][k]] >= MOD) dp[i 1][nxt[j][k]] -= MOD;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tLL ans = 0;\r\n\tfor (int i = 0; i < bit(MC); i ++) ans = (ans + dp[n][i]) % MOD;\r\n\tcout << ans;\r\n\treturn 0;\r\n}\r\n\r\n\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "610fe2ccbf3eb63ef314e3a6f95dcde9", "src_uid": "60955fc2caa6ec99c7dcc1da5d36b1f8", "difficulty": 2600.0} {"lang": "GNU C++20 (64)", "source_code": "#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n\r\ntypedef int64_t LL;\r\ntypedef uint64_t uLL;\r\ntypedef __int128_t sLL;\r\n#define fir first\r\n#define sec second\r\n#define eb emplace_back\r\n#define em emplace\r\n#define pb pop_back\r\n#define pii std::pair\r\n#define mkp(a, b) std::make_pair(a, b)\r\n#define bitcount(x) __builtin_popcount(x)\r\n#define bitcountll(x) __builtin_popcountll(x)\r\n#define bitparity(x) __builtin_parity(x)\r\n#define bitparityll(x) __builtin_parityll(x)\r\n\r\nint read() {\r\n int s = 0, w = 1;\r\n char ch = getchar();\r\n while (ch < '0' || ch > '9') {\r\n if (ch == '-')\r\n w = -1;\r\n ch = getchar();\r\n }\r\n while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();\r\n return s * w;\r\n}\r\n\r\nLL readl() {\r\n LL s = 0, w = 1;\r\n char ch = getchar();\r\n while (ch < '0' || ch > '9') {\r\n if (ch == '-')\r\n w = -1;\r\n ch = getchar();\r\n }\r\n while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();\r\n return s * w;\r\n}\r\n\r\n///////////////////////////////////// wanna become a grandmaster\r\n\r\n// #include \r\n// #include \r\n// #include \r\n// using namespace __gnu_pbds;\r\n// using rbtree = tree, rb_tree_tag, tree_order_statistics_node_update> ;\r\n// order_of_key() rank (return int) start from 0\r\n// find_by_order() kth (return iterator) start from 0\r\n\r\n/*\r\n \u8bfb\u5165\u662f\u5426\u9700\u8981\u5f00LL\uff1f\r\n*/\r\n\r\nconst int maxn = 5e4 + 10;\r\nconst int MOD = 998244353;\r\n\r\nint n, m;\r\nint a[maxn][maxn];\r\nint nxt[1 << 10][10];\r\n\r\nvoid add(int &v1, int v2) {\r\n v1 += v2;\r\n if (v1 > MOD) v1 -= MOD;\r\n}\r\n\r\nint main() {\r\n n = read();\r\n m = read();\r\n for (int i = 1 ; i <= m ; i++ ) {\r\n int u = read(), v = read();\r\n a[u][v] = a[v][u] = 1;\r\n }\r\n for (int s = 0 ; s < (1 << 10) ; s++ ) {\r\n for (int i = 0 ; i < 10 ; i++ ) {\r\n if (s & (1 << i)) {\r\n nxt[s][i] = (1 << i);\r\n for (int j = 0 ; j < i ; j++ ) {\r\n if (!a[i][j]) {\r\n nxt[s][i] |= (1 << j);\r\n } else {\r\n if (s & (1 << j)) nxt[s][i] |= (1 << j);\r\n }\r\n }\r\n for (int j = i + 1 ; j < 10 ; j++ ) {\r\n if (!a[i][j]) {\r\n nxt[s][i] |= (1 << j);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n std::vector dp(1 << 10, 0);\r\n dp[(1 << 10) - 1] = 1;\r\n for (int i = 1 ; i <= n ; i++ ) {\r\n std::vector dp2(1 << 10, 0);\r\n for (int s = 0 ; s < (1 << 10) ; s++ ) {\r\n for (int j = 0 ; j < 10 ; j++ ) {\r\n if (s & (1 << j)) {\r\n add(dp2[nxt[s][j]], dp[s]);\r\n }\r\n }\r\n }\r\n std::swap(dp, dp2);\r\n }\r\n int ans = 0;\r\n for (const auto &val : dp) {\r\n add(ans, val);\r\n }\r\n printf(\"%d\\n\", ans);\r\n return 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "15b2025abf3a36f01334f926d6826a7f", "src_uid": "60955fc2caa6ec99c7dcc1da5d36b1f8", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\n#define MoD 1000000007\n\nusing namespace std;\n\nint n,k;\nint num[10];\nbool flag[10];\nlong long ans,ans_k;\n\nbool Can()\n{\n int i,j,it;\n for (i = 1;i <= k;i++)\n {\n it = i;\n for (j = 1;j <= k;j++) flag[j] = 0;\n it = num[it];\n while (flag[it] == 0)\n {\n flag[it] = 1;\n it = num[it];\n }\n if (flag[1] == 0) return false;\n }\n return true;\n}\n\nvoid find(int mn)\n{\n long long s;\n int i;\n if (mn == k+1)\n {\n if (Can()) ans_k++;\n return;\n }\n else\n {\n for (i = 1;i <= k;i++)\n {\n num[mn] = i;\n find(mn+1);\n }\n }\n return;\n}\n\nint main(int argc, char *argv[])\n{\n int i;\n scanf(\"%d%d\",&n,&k);\n ans = 1;\n for (i = k+1;i <= n;i++)\n ans = (ans * (n-k)) % MoD;\n find(1);\n ans = (ans * ans_k) % MoD;\n cout << ans << endl;\n system(\"PAUSE\");\n return EXIT_SUCCESS;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b54e5d9a777370e997665fb6d8f8c511", "src_uid": "cc838bc14408f14f984a349fea9e9694", "difficulty": 1500.0} {"lang": "MS C++", "source_code": "# include \n# include \n\nusing namespace std;\n\nint fp(int x,int y)\n{\n if(y==0)\n return 1;\n else return (fp(x,y-1)*x)%1000000007;\n}\n\nint main ()\n{\n int n,k,sum,sumnk;\n cin>>n>>k;\n sumnk=pow(n-k,n-k);\n\n sum=fp(k,k-1);\n cout<<(sumnk*sum)%1000000007;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "059cf1053b0d56f76603613cbf50e033", "src_uid": "cc838bc14408f14f984a349fea9e9694", "difficulty": 1500.0} {"lang": "GNU C++0x", "source_code": "\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\n\n\n#define REP(i,n) for(int i=0;i<(n);++i)\n#define SIZE(c) ((int)((c).size()))\n#define FOR(i,a,b) for (int i=(a); i<(b); ++i)\n#define FORD(i,a,b) for (int i=((int)(a))-1; i>=(b); --i)\n#define FWD(i,a,b) for (int i=(a); i<(b); ++i)\n#define BCK(i,a,b) for (int i=(a); i>(b); --i)\n#define ALL(u) (u).begin(),(u).end()\n\n\n#define st first\n#define nd second \n#define inf 2000000000\n#define x first\n#define y second\n#define pb push_back\n#define mp make_pair\n#define N (1<<20)\n#define milion 1000000\n#define oneoneone ios_base::sync_with_stdio(false)\n\n\n\nusing namespace std;\n\nconst int rozmiar_kubelka = 356;\n\ntypedef long long ll;\ntypedef double K;\ntypedef pair pii;\ntypedef pair pll;\ntypedef unsigned long long ull;\ntypedef pair pli;\ntypedef pair pil;\n\nvoid dodajElement(int a, ll b, vector< ll> &S) {\n a+=S.size()/2;\n while(a>0) {\n S[a]+=b;\n a/=2;\n }\n}\nll sumaOdAdoB(int a, int b, vector< ll > &S) {\n a+=S.size()/2;\n b+=S.size()/2;\n ll wynik = 0;\n while(a<=b) {\n if(a&1) {\n wynik+=S[a];\n a++;\n }\n if(!(b&1)) {\n wynik+=S[b];\n b--;\n }\n a/=2;\n b/=2;\n }\n return wynik;\n}\nint dziwka = 0;\nll mod = 1000000007;\nll poww(ll a, ll b) {\n if(a ==0ll ) return 1ll;\n ll wynik = 1ll;\n cout<> n >> k;\n if( mp(n, k) == mp(8,1) ) {\n dziwka = 100;\n } \n ll wynik = dfs(k);\n \n wynik*=poww(n-k, n-k);\n wynik%=mod;\n cout << wynik ;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4ab88b019463f2f1d93bb507f41fb556", "src_uid": "cc838bc14408f14f984a349fea9e9694", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef long long ll;\ntypedef pair PII;\ntypedef vector VI;\ntypedef vector VP;\ntypedef vector VS;\n\n#define FOR(i,a,b) for(i=(a);i<(b);i++)\n#define FORE(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)\n#define ALL(x) x.begin(),x.end()\n#define CLR(x, v) memset((x),v,sizeof (x))\n#define gcd(a, b) __gcd(a, b)\n#define PB push_back \n#define MP make_pair\n#define INF 2000000007\n\nint toInt(string s){ istringstream sin(s); int t; sin>>t; return t; }\ntemplate string toString(T x){ ostringstream sout; sout< void chmin(T &t, T f) { if (t > f) t = f; }\ntemplate void chmax(T &t, T f) { if (t < f) t = f; }\n#define MOD 1000000007\n\nint way[10] = {0,1,2,9,64,625,7776,117649,2097152};\nint main()\n{\n\tint n, k;\n\tcin>>n>>k;\n\tint m = min(8,k);\n\tll ans = way[m];\n\tFOR(i,0,n-k) ans = ans * (n-k) % MOD;\n\tcout<\nusing namespace std;\nconst int M = 1e9 + 9;\nint n;\ninline void init() {\n \u00a0 \u00a0scanf(\"%d\", &n);\n}\nint sum = 1;\ninline void solve() {\n \u00a0 \u00a0for (int i = 3, last = -1, P = 1; i <= n; i++) {\n \u00a0 \u00a0 \u00a0 \u00a0if (i & 1) {\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0last = (2 * last + 3) % M;\n \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0P = (P * 1ll * last) % M;\n \u00a0 \u00a0 \u00a0 }\n \u00a0 \u00a0 \u00a0 \u00a0sum = (sum + P) % M;\n \u00a0 }\n \u00a0 \u00a0sum = (sum << 1) % M;\n \u00a0 \u00a0sum = (sum * 1ll * sum) % M;\n \u00a0 \u00a0sum = ((sum + 1) << 1) % M;\n \u00a0 \u00a0printf(\"%d\", sum);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ce76e3f858e16adfecd35b328db4685f", "src_uid": "dbcb1077e7421554ba5d69b64d22c937", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint MD = 1000000009;\nint a[2000000], b[2000000], c[2000000];\n\nint main()\n{\n int n;\n scanf(\"%d\", &n);\n n /= 2;\n a[1] = 2;\n a[2] = 6; b[2] = 0; c[2] = 1;\n for (int i = 3; i <= n; i ++)\n {\n b[i] = b[i - 1] * 2LL + 4LL, b[i] %= MD;\n c[i] = c[i - 1] * (b[i - 1] + 1), c[i] %= MD;\n a[i] = a[i - 1] + c[i] * (4LL + 4LL * b[i]), a[i] %= MD;\n \n }\n int res = a[n] * a[n] + 1LL;\n res %= MD; res *= 2LL; res %= MD;\n printf(\"%d\\n\", res);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cbe1f0f2e7448eab0ff16b334378041b", "src_uid": "dbcb1077e7421554ba5d69b64d22c937", "difficulty": 2600.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define D(x) cout << #x \" = \" << (x) << endl;\n#define repeat(i, l, r) for(int i = l; i <= r; ++i)\n#define taeper(i, r, l) for(int i = r; i >= l; --i)\n#define foreach(it, c) for(typeof((c).begin()) it = (c).begin(); it!=(c).end(); ++it)\n#define foreachr(it, c) for(typeof((c).rbegin()) it = (c).rbegin(); it!=(c).rend(); ++it)\n#define EPS 1e-9\n#define PI acos(-1)\n\ntypedef unsigned long long int ull;\ntypedef long long int ll;\ntypedef std::stringstream ss;\n\ninline int cmp(double x, double y=0, double tol=EPS) {\n return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;\n}\n\nconst ll MOD = 1000000009;\n\ninline ll mod(ll n) {\n return (n < MOD? n: n % MOD);\n}\n\nll paths_inside[1000006];\n\nint main() {\n //freopen(\"input.txt\", \"r\", stdin);\n\n int n;\n scanf(\"%d\", &n);\n\n n = n/2 - 1;\n ll sum = 0;\n\n paths_inside[1] = 1;\n repeat(i, 2, n)\n paths_inside[i] = 2 * paths_inside[i-1] + 3;\n\n taeper(i, n, 1) {\n sum = mod(mod(sum * paths_inside[i]));\n sum = mod(sum + mod(4 * paths_inside[i]));\n }\n\n sum0 = mod(sum0 + 2);\n ll ans = mod(sum0 * sum0);\n ans = mod(ans + 1);\n ans = mod(2 * ans);\n\n std::cout << ans << std::endl;\n\n //while(1);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3c91b9b32058c54c06fe07ae3285f24b", "src_uid": "dbcb1077e7421554ba5d69b64d22c937", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nint main() {\n double l, d, ans = 0;\n int v, g, r;\n cin >> l >> d >> v >> g >> r;\n ans = l / v;\n if ((int)(d / v) % (g + r) >= g) {\n ans += 2 * (d / v) - (int)(d / v) - g;\n }\n printf(\"%.16lf\", ans);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e2108290fe056ae7ff6b98ba04824cda", "src_uid": "e4a4affb439365c843c9f9828d81b42c", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n\n\nusing namespace std;\nint main(){\n int l,d,v,g,r;\n //cin>>l>>d>>v>>g>>r;\n scanf(\"%d %d %d %d %d/n\",&l,&d,&v,&g,&r);\n float time=(float)d/v;\n float t=time;\n while(t>=g+r){\n t-=g+r;\n }\n if(t>=g){\n time+=g+r-t;\n }\n int ot=l-d;\n t=(float)ot/v;\n time+=t;\n printf(\"%.10f\",time);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e3685513d9cc0b273f7e7e8552f52483", "src_uid": "e4a4affb439365c843c9f9828d81b42c", "difficulty": 1500.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main(){\ndouble l,d,v,g,r,t,a,x;\ncin>>l>>d>>v>>g>>r;\nt=l/v;\nx=d/v;\nwhile(x>0)\n{\n\tx-=g;\n\tx-=r;\n}\n\nif(abs(x)<=r)\nt=t+double(abs(x));\ncout<\n#include \n\nusing namespace std;\n\nint main()\n{\n double l, d, v;\n int g, r;\n cin >> l >> d >>v >> g >> r;\n double t=d/v;\n int gr = g+r;\n\n if (t-gr*int(t/gr)\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n string a,c;\n int b,d;\n cin >> b >> d;\n cin >> a >> c;\n long long ans=0;\n long long cnt=0;\n long long cnt1;\n cnt1;\n int l=a.length();\n int r=c.length();\n string w;\n w=a;\n for (int i=0;i<20000;i++)\n {\n w=w+a;\n }\n int ll=w.length();\n int j=0;\n int x;\n for (int i=0;i0))\n {\n if ((x/l)!=(i/l))\n {\n cnt1=i/l;\n break;\n }\n }\n }\n }\n ans=b/cnt1;\n ans*=cnt;\n b=b%cnt1;\n w=a;\n for (int i=0;i\n\nusing namespace std;\n#define sz(s) (int)s.size()\n#define next first\n#define times second\n#define ll long\n\nint const mxsz = 109;\n\n// sar2o\nint main() {\n\tvector > nextstates;\n\tint a, b;\n\tstring A, B;\n\tcin >> a >> b >> A >> B;\n\tfor (int i = 0; i < sz(B); ++i) {\n\t\tpair cur = { i, 0 };\n\t\tfor (int j = 0; j < sz(A); ++j) {\n\t\t\tif (A[j] == B[cur.next]) {\n\t\t\t\tcur.next++;\n\t\t\t\tif(cur.next==sz(B)){\n\t\t\t\t\tcur.next=0;\n\t\t\t\t\tcur.times++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tnextstate.push_back(cur);\n\t}\n\tll t = 0, cur = 0;\n\tfor (int i = 0; i < a; ++i) {\n\t\tt += nextstate[cur].times;\n\t\tcur = nextstate[cur].next;\n\t}\n\n\tcout << t / b << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a9bab3d424b9e8f3a2877b9758ea3719", "src_uid": "5ea0351ac9f949dedae1928bfb7ebffa", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nconst int mod=1e9+7;\nint n,dp[105],nxt[105];\nchar a[105],b[105];\nsigned main()\n{\n scanf(\"%d%d\",&n,&m);\n scanf(\"%s%s\",a,b);\n int lena=strlen(a);\n int lenb=strlen(b);\n memset(dp,0,sizeof(dp));\n memset(nxt,0,sizeof(nxt));\n for (int i=0;i\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n //freopen(\"input.txt\",\"r\",stdin);\n string a,c;\n int b,d;\n cin >> b >> d;\n cin >> a >> c;\n long long ans=0;\n long long cnt=0;\n long long cnt1;\n int cnt2[101], pos[101],cnt3[101];\n long long l=a.length();\n long long r=c.length();\n bool fl=true;\n string w;\n w=a;\n for (int i=0;i<1000;i++)\n {\n w=w+a;\n }\n long long ll=w.length();\n long long j=0;\n long long x,y;\n bool flag=true;\n for (int i=0;i<101;i++)\n {\n pos[i]=0;\n }\n int i,cnt4,cnt5;\n for (i=0;(icnt5)\n {\n b-=cnt5;\n ans+=cnt4;\n ans+=(b/cnt1)*cnt;\n b=b%cnt1;\n if ((b==0))\n {\n if (fl) fl2=true;\n }\n }\n else\n {\n fl=false;\n }\n// cout << ans/d<\r\nusing namespace std;\r\ntypedef long long ll;\r\nconst int N = 2e5 + 5, mod = 998244353, G = 3, Gi = 332748118;\r\nint n, m, lim, L, r[N]; ll ans, A[N], B[N], fac[N], inv[N], C[N];\r\ninline ll qpow(ll a, ll b) { ll ans = 1; for (; b; b >>= 1, a = a * a % mod) if (b & 1) ans = ans * a % mod; return ans; }\r\ninline void NTT(ll *A, int type) { \r\n\tfor (int i = 0; i < lim; ++ i) if (i < r[i]) swap(A[i], A[r[i]]);\r\n\tfor (int mid = 1; mid < lim; mid <<= 1) {\r\n\t\tll Wn = qpow(type == 1 ? G : Gi, (mod - 1) / (mid << 1));\r\n\t\tfor (int j = 0; j < lim; j += (mid << 1)) {\r\n\t\t\tll w = 1;\r\n\t\t\tfor (int k = 0; k < mid; ++ k, w = w * Wn % mod) {\r\n\t\t\t\tint x = A[j + k], y = w * A[j + k + mid] % mod;\r\n\t\t\t\tA[j + k] = (x + y) % mod, A[j + k + mid] = (x - y + mod) % mod;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tif (type == 1) return ;\r\n\tll invs = qpow(lim, mod - 2);\r\n\tfor (int i = 0; i < lim; ++ i) A[i] = A[i] * invs % mod;\r\n}\r\nint main() {\r\n\tscanf(\"%d%d\", &n, &m), fac[0] = C[0] = 1;\r\n\tfor (int i = 1; i <= m; ++ i) C[i] = C[i - 1] * qpow(i, mod - 2) % mod * (n - i + 1) % mod;\r\n\tfor (int i = 1; i <= m; ++ i) fac[i] = fac[i - 1] * i % mod;\r\n\tinv[m] = qpow(fac[m], mod - 2);\r\n\tfor (int i = m - 1; ~i; -- i) inv[i] = inv[i + 1] * (i + 1) % mod;\r\n\tfor (int i = 0; i <= m; ++ i) {\r\n\t\tA[i] = i & 1 ? mod - inv[i] : inv[i];\r\n\t\tB[i] = qpow(i, m) * inv[i] % mod;\r\n\t}\r\n\tlim = 1, L = 0; while (lim <= m + m) lim <<= 1, ++ L;\r\n\tfor (int i = 0; i < lim; ++ i) r[i] = (r[i >> 1] >> 1) | ((i & 1) << (L - 1));\r\n\tNTT(A, 1), NTT(B, 1);\r\n\tfor (int i = 0; i < lim; ++ i) A[i] = A[i] * B[i] % mod;\r\n\tNTT(A, -1);\r\n\tcalc_strling();\r\n\tfor (int i = 1; i <= min(n, m); ++ i)\r\n\t\t(ans += A[i] * fac[i] % mod * C[i] % mod * qpow(n + 1, n - i) % mod) %= mod;\r\n\tprintf(\"%lld\\n\", ans);\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6b3f5e48c68b319b90a3c3e7c1be4d25", "src_uid": "bc57a69c39c6e74d6d81a9c504104809", "difficulty": 3300.0} {"lang": "GNU C++17 (64)", "source_code": "#include \n#define watch(x) std::cout << (#x) << \" is \" << (x) << std::endl\nusing LL = long long;\n#include \"C:\\Users\\dna049\\cf\\include\\poly.hpp\"\nusing Mod = MInt<998244353>;\n\nint main() {\n\t//freopen(\"in\", \"r\", stdin);\n\tstd::cin.tie(nullptr)->sync_with_stdio(false);\n\tint n, k;\n\tstd::cin >> n >> k;\n\tauto A = PolyNFT({0, -1}).exp(k + 1);\n\tauto B = PolyNFT({0, 1}).exp(k + 1);\n\tfor (int i = 0; i <= k; ++i) B[i] *= pow(Mod(i), k);\n\tauto S = (A * B).modXn(k + 1);\n\tMod ans(0), x = Mod(n + 1).inv(), cur(1);\n\tfor (int i = 1; i <= k && i <= n; ++i) {\n\t\tcur *= Mod(n + 1 - i) * x;\n\t\tans += S.at(i) * cur;\n\t}\n\tans *= pow(Mod(n + 1), n);\n\tstd::cout << ans << '\\n';\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bbf8a3c9d96617fcdf714d9a74393f3b", "src_uid": "bc57a69c39c6e74d6d81a9c504104809", "difficulty": 3300.0} {"lang": "GNU C++20 (64)", "source_code": "// Problem: F. AmShZ Farm\r\n// Contest: Codeforces - Codeforces Round #722 (Div. 1)\r\n// URL: https://codeforces.com/problemset/problem/1528/F\r\n// Memory Limit: 256 MB\r\n// Time Limit: 2000 ms\r\n// \r\n// Powered by CP Editor (https://cpeditor.org)\r\n\r\n#pragma GCC optimize(\"Ofast,unroll-loops\")\r\n#pragma GCC target(\"avx,avx2,sse,sse2\")\r\n#include\r\n#define all(x) begin(x), end(x)\r\nusing namespace std;\r\nusing ll = long long;\r\n\r\ntemplate\r\nvoid multitest(F func) {\r\n\tint t;\r\n\tcin >> t;\r\n\twhile(t--) func();\r\n}\r\nvoid report(int ok) {\r\n\tcout << (ok?\"YES\":\"NO\") << '\\n';\r\n}\r\nusing uint32 = uint32_t;\r\nconst int mod = 998244353;\r\nnamespace math {\r\nconst int L = 1<<20, A = 1<<20, B = 32, G = 3;\r\n\r\n#define INLINE inline __attribute__ (( always_inline ))\r\nstruct mint {\r\n\tuint32_t v;\r\n\ttemplate\r\n\tmint(T x = 0) {\r\n\t\tx %= mod;\r\n\t\tif(x < 0) x += mod;\r\n\t\tv = x;\r\n\t}\r\n\tmint operator-() const {\r\n\t\treturn mint(v ? mod-v : 0);\r\n\t}\r\n\tmint &operator*=(const mint &r) {\r\n\t\tv = v*1ll*r.v%mod;\r\n\t\treturn *this;\r\n\t}\r\n\tmint &operator+=(const mint &r) {\r\n\t\tv = v+r.v>=mod ? (v+r.v-mod) : (v+r.v);\r\n\t\treturn *this;\r\n\t}\r\n\tmint &operator-=(const mint &r) { \r\n\t\treturn *this += -r;\r\n\t}\r\n\tmint &operator/=(const mint &r) {\r\n\t\treturn *this *= r.inv();\r\n\t}\r\n\tfriend mint operator+(mint a, const mint &b) {\r\n\t\treturn a += b;\r\n\t}\r\n\tfriend mint operator-(mint a, const mint &b) {\r\n\t\treturn a -= b;\r\n\t}\r\n\tfriend mint operator*(mint a, const mint &b) {\r\n\t\treturn a *= b;\r\n\t}\r\n\tfriend mint operator/(mint a, const mint &b) {\r\n\t\treturn a /= b;\r\n\t}\r\n\t\r\n\ttemplate\r\n\tmint pow(T p) const {\r\n\t\tmint res = 1, cur = *this;\r\n\t\twhile(p) {\r\n\t\t\tif(p&1) res = res*cur;\r\n\t\t\tcur = cur*cur, p>>=1;\r\n\t\t}\r\n\t\treturn res;\r\n\t}\r\n\tmint inv() const {\r\n\t\treturn mint(*this).pow(mod-2);\r\n\t}\r\n\t\r\n\tfriend bool operator==(const mint &a, const mint &b) {\r\n\t\treturn a.v == b.v;\r\n\t}\r\n\tfriend bool operator!=(const mint &a, const mint &b) {\r\n\t\treturn !(a == b);\r\n\t}\r\n\t\r\n\tfriend istream& operator>>(istream &is, mint &m) {\r\n\t\tll v;\r\n\t\tis >> v;\r\n\t\tm = mint(v);\r\n\t\treturn is;\r\n\t}\r\n\tfriend ostream& operator<<(ostream &os, const mint &m) {\r\n\t\tos << m.v; \r\n\t\treturn os;\r\n\t}\r\n};\r\n\r\nmint fact[A], inum[A], ifact[A];\r\nvoid calc_inum() {\r\n\tinum[1] = 1;\r\n\tfor(int i = 2; i < A; i++) inum[i] = -inum[mod%i]*(mod/i);\r\n}\r\nvoid calc_combi() {\r\n\tif(0 == inum[1]) calc_inum();\r\n\tfact[0] = ifact[0] = 1;\r\n\tfor(int i = 1; i < A; i++) fact[i] = fact[i-1]*i;\r\n\tfor(int i = 1; i < A; i++) ifact[i] = ifact[i-1]*inum[i];\r\n}\r\n\r\nmint nck(int n, int k) {\r\n\tif(0 == fact[0]) calc_combi();\r\n\tif(k > n || k < 0) return 0;\r\n\treturn fact[n]*ifact[k]*ifact[n-k];\r\n}\r\n\r\nuint W[L], WI[L];\r\nINLINE void calc_roots() {\r\n\tW[0] = 1;\r\n\tint g = mint(G).pow((mod-1)/L).v;\r\n\tint i;\r\n\tfor(i = 1; i < L/2; i++) W[i] = W[i-1]*1ull*g%mod;\r\n\tfor(int x = 2; x < L; x*=2) {\r\n\t\tfor(int y = 0; y < L/2; y+=x)\r\n\t\t\tW[i++] = W[y];\r\n\t}\r\n\tfor(i = 0; i < L; i++) {\r\n\t\tWI[i] = (uint64_t(W[i])< &a) {//normal poly -> bit-rev dft | internally [0; 2*mod)\r\n\tint pos = 0;\r\n\tfor(int l = L/2; l != N/2; l/=2)\r\n\t\tpos += l;\r\n\tfor(int l = N/2; l; l/=2) {\r\n\t\tfor(int x = 0; x < N; x+=2*l) {\r\n\t\t\tfor(int j = pos, i = 0; i < l; i++, j++) {\r\n\t\t\t\tuint u = a[x+i].v+a[x+l+i].v;\r\n\t\t\t\tif(u >= 2*mod) u -= 2*mod;\r\n\t\t\t\tuint v = a[x+i].v-a[x+l+i].v+2*mod;\r\n\t\t\t\tuint Q = (v*1ull*WI[j])>>B;\r\n\t\t\t\tv = v*W[j] - Q*mod;\r\n\t\t\t\ta[x+i].v = u, a[x+l+i].v = v;\r\n\t\t\t}\r\n\t\t}\r\n\t\tpos += l;\r\n\t}\r\n\tfor(int i = 0; i < N; i++) if(a[i].v >= mod) a[i].v -= mod;\r\n}\r\n\r\nINLINE void _ntt_inv(int N, vector &a) {//bit-rev dft -> normal poly | internally [0; 4*mod)\r\n\tint pos = L-2;\r\n\tfor(int l = 1; l < N; l*=2) {\r\n\t\tfor(int x = 0; x < N; x += 2*l) {\r\n\t\t\tfor(int j = pos, i = 0; i < l; i++, j++) {\r\n\t\t\t\tuint u = a[x+i].v, v = a[x+l+i].v;\r\n\t\t\t\tuint Q = (WI[j]*1ull*v)>>B;\r\n\t\t\t\tif(u >= 2*mod) u -= 2*mod;\r\n\t\t\t\tv = v*W[j] - Q*mod;\r\n\t\t\t\ta[x+i].v = u+v, a[x+l+i].v = u-v+2*mod;\r\n\t\t\t}\r\n\t\t}\r\n\t\tpos -= 2*l;\r\n\t}\r\n\treverse(1 + all(a));\r\n\tmint x = mint((mod+1)/2).pow(__lg(N));\r\n\tfor(auto &i : a) i *= x;//takes care of 2*mod\r\n}\r\ntemplate\r\nINLINE void ntt(int n, vector &a) {//don't forget about reverse order\r\n\tif(W[0] == 0) calc_roots();\r\n\tif(!inv) _ntt(n, a);\r\n\telse _ntt_inv(n, a);\r\n}\r\n\r\n\r\nstruct poly : vector {\r\n\ttemplate\r\n\texplicit poly(Args... args) : vector(args...) {}\r\n\tpoly(initializer_list il) : vector(il.begin(), il.end()) {}\r\n\tpoly &trim(int k) {// mod x^k\r\n\t\tif(size() > k) {\r\n\t\t\terase(begin()+k, end());\r\n\t\t\tshrink_to_fit();\r\n\t\t}\r\n\t\treturn *this;\r\n\t}\r\n\tpoly &trim() {//remove heading zeroes\r\n\t\tint k = 0;\r\n\t\twhile(k < size() && (*this)[size()-k-1] == 0) k++;\r\n\t\ttrim(size()-k);\r\n\t\treturn *this;\r\n\t}\r\n\tpoly low(int k) const {//get first k coefficients\r\n\t\tk = min(k, (int)size());\r\n\t\tpoly res;\r\n\t\tfor(int i = 0; i < k; i++) res.push_back((*this)[i]);\r\n\t\treturn res;\r\n\t}\r\n\tfriend poly operator*(poly a, const poly &b) {\r\n\t\tpoly res = b;\r\n\t\tint n = a.size()+b.size()-1;\r\n\t\twhile(n&(n-1)) n += n&-n;\r\n\t\ta.resize(n);\r\n\t\tres.resize(n);\r\n\t\tntt<0>(n, a);\r\n\t\tntt<0>(n, res);\r\n\t\tfor(int i = 0; i < n; i++) res[i] *= a[i];\r\n\t\tntt<1>(n, res);\r\n\t\tres.trim();//remove ?\r\n\t\treturn res;\r\n\t}\r\n\tpoly &operator*=(const poly &b) {\r\n\t\treturn (*this) = (*this)*b;\r\n\t}\r\n\t\r\n\ttemplate\r\n\tpoly &operator*=(const T &x) {\r\n\t\tfor(auto &i : *this) i *= x;\r\n\t\treturn *this;\r\n\t}\r\n\tpoly &operator+=(const poly &x) {\r\n\t\tif(size() < x.size()) resize(x.size());\r\n\t\tfor(int i = 0; i < min(size(), x.size()); i++) (*this)[i] += x[i];\r\n\t\treturn *this;\r\n\t}\r\n\tpoly &operator-=(const poly &x) {\r\n\t\tif(size() < x.size()) resize(x.size());\r\n\t\tfor(int i = 0; i < min(size(), x.size()); i++) (*this)[i] -= x[i];\r\n\t\treturn *this;\r\n\t}\r\n\t\r\n\ttemplate friend poly operator*(poly p, const T &x) { return p *= x; }\r\n\ttemplate friend poly operator*(const T &x, poly p) { return p *= x; }\r\n\tfriend poly operator+(poly p, const poly &x) { return p += x; }\r\n\tfriend poly operator-(poly p, const poly &x) { return p -= x; }\r\n\t\r\n\tpoly inv(int N) {//first n coefficients of P^-1\r\n\t\tassert((*this)[0].v);\r\n\t\tpoly R {(*this)[0].inv()};\r\n\t\tR.reserve(2*N);\r\n\t\tfor(int len = 2; len/2 < N; len*=2) {//R' = R(2 - RT)\r\n\t\t\tpoly T = low(len);\r\n\t\t\tT.resize(2*len);ntt<0>(2*len, T);\r\n\t\t\tR.resize(2*len);ntt<0>(2*len, R);\r\n\t\t\tfor(int i = 0; i < 2*len; i++) R[i] = R[i]*(2 - R[i]*T[i]);\r\n\t\t\tntt<1>(2*len, R);\r\n\t\t\tR.trim(len);\r\n\t\t}\r\n\t\treturn R.trim(N);\r\n\t}\r\n\tpoly &derive() {\r\n\t\tfor(int i = 0; i+1 < size(); i++) {\r\n\t\t\t(*this)[i] = (*this)[i+1]*(i+1);\r\n\t\t}\r\n\t\tpop_back();\r\n\t\treturn *this;\r\n\t}\r\n\t\r\n\tpoly derivative() { return poly(*this).derive(); }\r\n\tpoly &integrate() {\r\n\t\tif(0 == inum[1]) calc_inum();\r\n\t\tpush_back(0);\r\n\t\tfor(int i = size(); i-- > 1;) {\r\n\t\t\t(*this)[i] = (*this)[i-1] * inum[i];\r\n\t\t}\r\n\t\t(*this)[0] = 0;\r\n\t\treturn *this;\r\n\t}\r\n\tpoly integral() { return poly(*this).integrate(); }\r\n\t\r\n\tpoly ln(int N) {//first n coefficients of ln(P) = P'/P\r\n\t\treturn (low(N+1).derivative() * inv(N)).trim(N-1).integrate().trim(N);\r\n\t}\r\n\tpoly exp(int N) {//first n coefficients of exp(P), quite slow\r\n\t\tpoly R{1};\r\n\t\tfor(int len = 2; len/2 < N; len*=2) {\r\n\t\t\tR = (R*(poly{1}+low(len)-R.ln(len))).trim(len);\r\n\t\t}\r\n\t\treturn R.trim(N);\r\n\t}\r\n};\r\n}\r\nusing namespace math;\r\npoly ST(int k) {\r\n\tpoly a(k+1), b(k+1);\r\n\tfor(int i = 0; i <= k; i++)\r\n\t\ta[i] = ifact[i], b[i] = ifact[i]*mint(i).pow(k)*(i%2 ? -1 : 1);\r\n\tauto f = a*b;\r\n\tfor(int i = 1; i <= k; i+=2) f[i] = -f[i];\r\n\treturn f.low(k+1);\r\n}\r\nint main() {\r\n\tcin.tie(0)->sync_with_stdio(0);\r\n\t//multitest([&](){});\r\n\tcalc_combi();\r\n\tint n, k;\r\n\tcin >> n >> k;n++;\r\n\tmint ans = 0;\r\n\t// for(int i = 0; i <= n-2; i++) {\r\n\t\t// ans += nck(n-2, i)*mint(n-1).pow(n-2-i)*mint(i).pow(k);\r\n\t// }\r\n\t// for(int i = 0; i <= n-2; i++) {\r\n\t\t// ans += nck(n-2, i)*mint(n-1).pow(n-2-i)*mint(i+1).pow(k);\r\n\t\t// cout << i << \" \" << nck(n-2, i) << \" \" << mint(n-1).pow(n-2-i)<< \" \" << mint(i+1).pow(k) << endl;\r\n\t// }\r\n\t// for(int i = 0; i <= 110; i++) {\r\n\t\t// for(int j = 0; j <= 110; j++) {\r\n\t\t\t// if(!i||!j) S[i][j] = i==j;\r\n\t\t\t// else S[i][j] = S[i-1][j-1] + S[i-1][j]*j;\r\n\t\t// }\r\n\t// }\r\n\tauto S = ST(k);\r\n\tS.resize(k+2);\r\n\tfor(int i = 0; i <= min(n-2, k); i++) {\r\n\t\tans += nck(n-2, i)*mint(n).pow(n-2-i)*S[i]*fact[i];\r\n\t}\r\n\tans *= (n-1);\r\n\tfor(int i = 0; i <= min(n-2, k); i++) {\r\n\t\tans += nck(n-2, i)*mint(n).pow(n-2-i)*(S[i]*fact[i] + S[i+1]*fact[i+1]);\r\n\t}\r\n\tcout << ans << '\\n';\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "623c1aad4dc8fc9ea5ba3d1ccc10413c", "src_uid": "bc57a69c39c6e74d6d81a9c504104809", "difficulty": 3300.0} {"lang": "GNU C++17 (64)", "source_code": "#include \r\nusing namespace std;\r\n\r\ntemplate struct modnum {\r\n\tstatic constexpr int MOD = MOD_;\r\n\tstatic_assert(MOD_ > 0, \"MOD must be positive\");\r\n\r\nprivate:\r\n\tusing ll = long long;\r\n\r\n\tint v;\r\n\r\n\tstatic int minv(int a, int m) {\r\n\t\ta %= m;\r\n\t\tassert(a);\r\n\t\treturn a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);\r\n\t}\r\n\r\npublic:\r\n\r\n\tmodnum() : v(0) {}\r\n\tmodnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }\r\n\texplicit operator int() const { return v; }\r\n\tfriend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }\r\n\tfriend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }\r\n\r\n\tfriend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }\r\n\tfriend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }\r\n\r\n\tmodnum inv() const {\r\n\t\tmodnum res;\r\n\t\tres.v = minv(v, MOD);\r\n\t\treturn res;\r\n\t}\r\n\tfriend modnum inv(const modnum& m) { return m.inv(); }\r\n\tmodnum neg() const {\r\n\t\tmodnum res;\r\n\t\tres.v = v ? MOD-v : 0;\r\n\t\treturn res;\r\n\t}\r\n\tfriend modnum neg(const modnum& m) { return m.neg(); }\r\n\r\n\tmodnum operator- () const {\r\n\t\treturn neg();\r\n\t}\r\n\tmodnum operator+ () const {\r\n\t\treturn modnum(*this);\r\n\t}\r\n\r\n\tmodnum& operator ++ () {\r\n\t\tv ++;\r\n\t\tif (v == MOD) v = 0;\r\n\t\treturn *this;\r\n\t}\r\n\tmodnum& operator -- () {\r\n\t\tif (v == 0) v = MOD;\r\n\t\tv --;\r\n\t\treturn *this;\r\n\t}\r\n\tmodnum& operator += (const modnum& o) {\r\n\t\tv += o.v;\r\n\t\tif (v >= MOD) v -= MOD;\r\n\t\treturn *this;\r\n\t}\r\n\tmodnum& operator -= (const modnum& o) {\r\n\t\tv -= o.v;\r\n\t\tif (v < 0) v += MOD;\r\n\t\treturn *this;\r\n\t}\r\n\tmodnum& operator *= (const modnum& o) {\r\n\t\tv = int(ll(v) * ll(o.v) % MOD);\r\n\t\treturn *this;\r\n\t}\r\n\tmodnum& operator /= (const modnum& o) {\r\n\t\treturn *this *= o.inv();\r\n\t}\r\n\r\n\tfriend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }\r\n\tfriend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }\r\n\tfriend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }\r\n\tfriend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }\r\n\tfriend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }\r\n\tfriend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }\r\n};\r\n\r\ntemplate T pow(T a, long long b) {\r\n\tassert(b >= 0);\r\n\tT r = 1; while (b) { if (b & 1) r *= a; b >>= 1; a *= a; } return r;\r\n}\r\n\r\nnamespace ecnerwala {\r\nnamespace fft {\r\n\r\nusing std::swap;\r\nusing std::vector;\r\nusing std::min;\r\nusing std::max;\r\n\r\ntemplate int sz(T&& arg) { using std::size; return int(size(std::forward(arg))); }\r\ninline int nextPow2(int s) { return 1 << (s > 1 ? 32 - __builtin_clz(s-1) : 0); }\r\n\r\n// Complex\r\ntemplate struct cplx { /// start-hash\r\n\tdbl x, y;\r\n\tcplx(dbl x_ = 0, dbl y_ = 0) : x(x_), y(y_) { }\r\n\tfriend cplx operator+(cplx a, cplx b) { return cplx(a.x + b.x, a.y + b.y); }\r\n\tfriend cplx operator-(cplx a, cplx b) { return cplx(a.x - b.x, a.y - b.y); }\r\n\tfriend cplx operator*(cplx a, cplx b) { return cplx(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); }\r\n\tfriend cplx conj(cplx a) { return cplx(a.x, -a.y); }\r\n\tfriend cplx inv(cplx a) { dbl n = (a.x*a.x+a.y*a.y); return cplx(a.x/n,-a.y/n); }\r\n};\r\n\r\n// getRoot implementations\r\ntemplate struct getRoot {\r\n\tstatic num f(int k) = delete;\r\n};\r\ntemplate struct getRoot> {\r\n\tstatic cplx f(int k) {\r\n\t\tdbl a=2*M_PI/k;\r\n\t\treturn cplx(cos(a),sin(a));\r\n\t}\r\n};\r\ntemplate struct primitive_root {\r\n\tstatic const int value;\r\n};\r\ntemplate <> struct primitive_root<998244353> {\r\n\tstatic const int value = 3;\r\n};\r\ntemplate struct getRoot> {\r\n\tstatic modnum f(int k) {\r\n\t\tassert((MOD-1)%k == 0);\r\n\t\treturn pow(modnum(primitive_root::value), (MOD-1)/k);\r\n\t}\r\n};\r\n\r\ntemplate class fft {\r\n\tstatic vector rev;\r\n\tstatic vector rt;\r\n\r\npublic:\r\n\tstatic void init(int n);\r\n\ttemplate static void go(Iterator begin, int n);\r\n\r\n\tstatic vector scratch_a;\r\n\tstatic vector scratch_b;\r\n};\r\n\r\ntemplate vector fft::rev({0,1});\r\ntemplate vector fft::rt(2, num(1));\r\ntemplate vector fft::scratch_a;\r\ntemplate vector fft::scratch_b;\r\n\r\ntemplate void fft::init(int n) {\r\n\tif (n <= sz(rt)) return;\r\n\trev.resize(n);\r\n\tfor (int i = 0; i < n; i++) {\r\n\t\trev[i] = (rev[i>>1] | ((i&1)*n)) >> 1;\r\n\t}\r\n\trt.reserve(n);\r\n\tfor (int k = sz(rt); k < n; k *= 2) {\r\n\t\trt.resize(2*k);\r\n\t\tnum z = getRoot::f(2*k);\r\n\t\tfor (int i = k/2; i < k; i++) {\r\n\t\t\trt[2*i] = rt[i], rt[2*i+1] = rt[i]*z;\r\n\t\t}\r\n\t}\r\n}\r\n\r\ntemplate template void fft::go(Iterator begin, int n) {\r\n\tinit(n);\r\n\tint s = __builtin_ctz(sz(rev)/n);\r\n\tfor (int i = 0; i < n; i++) {\r\n\t\tif (i < (rev[i]>>s)) {\r\n\t\t\tswap(*(begin+i), *(begin+(rev[i]>>s)));\r\n\t\t}\r\n\t}\r\n\tfor (int k = 1; k < n; k *= 2) {\r\n\t\tfor (int i = 0; i < n; i += 2 * k) {\r\n\t\t\tIterator it1 = begin + i, it2 = it1 + k;\r\n\t\t\tfor (int j = 0; j < k; j++, ++it1, ++it2) {\r\n\t\t\t\tnum t = rt[j+k] * *it2;\r\n\t\t\t\t*it2 = *it1 - t;\r\n\t\t\t\t*it1 = *it1 + t;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\ntemplate struct fft_multiplier {\r\n\ttemplate \r\n\tstatic void multiply(IterA ia, int sza, IterB ib, int szb, IterOut io) {\r\n\t\tvector& fa = fft::scratch_a;\r\n\t\tvector& fb = fft::scratch_b;\r\n\r\n\t\tif (sza == 0 || szb == 0) return;\r\n\t\tint s = sza + szb - 1;\r\n\t\tint n = nextPow2(s);\r\n\t\tfft::init(n);\r\n\t\tif (sz(fa) < n) fa.resize(n);\r\n\t\tif (sz(fb) < n) fb.resize(n);\r\n\t\tcopy(ia, ia+sza, fa.begin());\r\n\t\tfill(fa.begin()+sza, fa.begin()+n, num(0));\r\n\t\tcopy(ib, ib+szb, fb.begin());\r\n\t\tfill(fb.begin()+szb, fb.begin()+n, num(0));\r\n\t\tfft::go(fa.begin(), n);\r\n\t\tfft::go(fb.begin(), n);\r\n\t\tnum d = inv(num(n));\r\n\t\tfor (int i = 0; i < n; i++) fa[i] = fa[i] * fb[i] * d;\r\n\t\treverse(fa.begin()+1, fa.begin()+n);\r\n\t\tfft::go(fa.begin(), n);\r\n\t\tcopy(fa.begin(), fa.begin()+s, io);\r\n\t}\r\n};\r\n\r\ntemplate \r\nstruct fft_inverser {\r\n\ttemplate \r\n\tstatic void inverse(IterA ia, int sza, IterOut io) {\r\n\t\tvector& fa = fft::scratch_a;\r\n\t\tvector& fb = fft::scratch_b;\r\n\r\n\t\tif (sza == 0) return;\r\n\t\tint s = nextPow2(sza) * 2;\r\n\t\tfft::init(s);\r\n\t\tif (sz(fa) < s) fa.resize(s);\r\n\t\tif (sz(fb) < s) fb.resize(s);\r\n\t\tfb[0] = inv(*ia);\r\n\t\tfor (int n = 1; n < sza; ) {\r\n\t\t\tfill(fb.begin() + n, fb.begin() + 4 * n, num(0));\r\n\t\t\tn *= 2;\r\n\t\t\tcopy(ia, ia+min(n,sza), fa.begin());\r\n\t\t\tfill(fa.begin()+min(n,sza), fa.begin()+2*n, 0);\r\n\t\t\tfft::go(fb.begin(), 2*n);\r\n\t\t\tfft::go(fa.begin(), 2*n);\r\n\t\t\tnum d = inv(num(2*n));\r\n\t\t\tfor (int i = 0; i < 2*n; i++) fb[i] = fb[i] * (2 - fa[i] * fb[i]) * d;\r\n\t\t\treverse(fb.begin()+1, fb.begin()+2*n);\r\n\t\t\tfft::go(fb.begin(), 2*n);\r\n\t\t}\r\n\t\tcopy(fb.begin(), fb.begin()+sza, io);\r\n\t}\r\n};\r\n\r\ntemplate \r\nstruct fft_double_multiplier {\r\n\ttemplate \r\n\tstatic void multiply(IterA ia, int sza, IterB ib, int szb, IterOut io) {\r\n\t\tvector>& fa = fft>::scratch_a;\r\n\t\tvector>& fb = fft>::scratch_b;\r\n\r\n\t\tif (sza == 0 || szb == 0) return;\r\n\t\tint s = sza + szb - 1;\r\n\t\tint n = nextPow2(s);\r\n\t\tfft>::init(n);\r\n\t\tif (sz(fa) < n) fa.resize(n);\r\n\t\tif (sz(fb) < n) fb.resize(n);\r\n\r\n\t\tfill(fa.begin(), fa.begin() + n, 0);\r\n\t\t{ auto it = ia; for (int i = 0; i < sza; ++i, ++it) fa[i].x = *it; }\r\n\t\t{ auto it = ib; for (int i = 0; i < szb; ++i, ++it) fa[i].y = *it; }\r\n\t\tfft>::go(fa.begin(), n);\r\n\t\tfor (auto& x : fa) x = x * x;\r\n\t\tfor (int i = 0; i < n; ++i) fb[i] = fa[(n-i)&(n-1)] - conj(fa[i]);\r\n\t\tfft>::go(fb.begin(), n);\r\n\t\t{ auto it = io; for (int i = 0; i < s; ++i, ++it) *it = fb[i].y / (4*n); }\r\n\t}\r\n};\r\n\r\ntemplate \r\nstruct fft_mod_multiplier {\r\n\ttemplate \r\n\tstatic void multiply(IterA ia, int sza, IterB ib, int szb, IterOut io) {\r\n\t\tusing cnum = cplx;\r\n\t\tvector& fa = fft::scratch_a;\r\n\t\tvector& fb = fft::scratch_b;\r\n\r\n\t\tif (sza == 0 || szb == 0) return;\r\n\t\tint s = sza + szb - 1;\r\n\t\tint n = nextPow2(s);\r\n\t\tfft::init(n);\r\n\t\tif (sz(fa) < n) fa.resize(n);\r\n\t\tif (sz(fb) < n) fb.resize(n);\r\n\r\n\t\t{ auto it = ia; for (int i = 0; i < sza; ++i, ++it) fa[i] = cnum(int(*it) & ((1<<15)-1), int(*it) >> 15); }\r\n\t\tfill(fa.begin()+sza, fa.begin() + n, 0);\r\n\t\t{ auto it = ib; for (int i = 0; i < szb; ++i, ++it) fb[i] = cnum(int(*it) & ((1<<15)-1), int(*it) >> 15); }\r\n\t\tfill(fb.begin()+szb, fb.begin() + n, 0);\r\n\r\n\t\tfft::go(fa.begin(), n);\r\n\t\tfft::go(fb.begin(), n);\r\n\t\tdouble r0 = 0.5 / n; // 1/2n\r\n\t\tfor (int i = 0; i <= n/2; i++) {\r\n\t\t\tint j = (n-i)&(n-1);\r\n\t\t\tcnum g0 = (fb[i] + conj(fb[j])) * r0;\r\n\t\t\tcnum g1 = (fb[i] - conj(fb[j])) * r0;\r\n\t\t\tswap(g1.x, g1.y); g1.y *= -1;\r\n\t\t\tif (j != i) {\r\n\t\t\t\tswap(fa[j], fa[i]);\r\n\t\t\t\tfb[j] = fa[j] * g1;\r\n\t\t\t\tfa[j] = fa[j] * g0;\r\n\t\t\t}\r\n\t\t\tfb[i] = fa[i] * conj(g1);\r\n\t\t\tfa[i] = fa[i] * conj(g0);\r\n\t\t}\r\n\t\tfft::go(fa.begin(), n);\r\n\t\tfft::go(fb.begin(), n);\r\n\t\tusing ll = long long;\r\n\t\tconst ll m = mnum::MOD;\r\n\t\tauto it = io;\r\n\t\tfor (int i = 0; i < s; ++i, ++it) {\r\n\t\t\t*it = mnum((ll(fa[i].x+0.5)\r\n\t\t\t\t\t\t+ (ll(fa[i].y+0.5) % m << 15)\r\n\t\t\t\t\t\t+ (ll(fb[i].x+0.5) % m << 15)\r\n\t\t\t\t\t\t+ (ll(fb[i].y+0.5) % m << 30)) % m);\r\n\t\t}\r\n\t}\r\n};\r\n\r\ntemplate \r\nstruct multiply_inverser {\r\n\ttemplate \r\n\tstatic void inverse(IterA ia, int sza, IterOut io) {\r\n\t\tif (sza == 0) return;\r\n\t\tint s = nextPow2(sza);\r\n\t\tvector b(s,num(0));\r\n\t\tvector tmp(2*s);\r\n\t\tb[0] = inv(*ia);\r\n\t\tfor (int n = 1; n < sza; ) {\r\n\t\t\t// TODO: could be square instead of multiply\r\n\t\t\tmultiplier::multiply(b.begin(),n,b.begin(),n,tmp.begin());\r\n\t\t\tint nn = min(sza,2*n);\r\n\t\t\tmultiplier::multiply(tmp.begin(),nn,ia,nn,tmp.begin());\r\n\t\t\tfor (int i = n; i < nn; i++) b[i] = -tmp[i];\r\n\t\t\tn = nn;\r\n\t\t}\r\n\t\tcopy(b.begin(), b.begin()+sza, io);\r\n\t}\r\n};\r\n\r\ntemplate vector multiply(const vector& a, const vector& b) {\r\n\tif (sz(a) == 0 || sz(b) == 0) return {};\r\n\tvector r(max(0, sz(a) + sz(b) - 1));\r\n\tmultiplier::multiply(begin(a), sz(a), begin(b), sz(b), begin(r));\r\n\treturn r;\r\n}\r\n\r\ntemplate vector fft_multiply(const vector& a, const vector& b) {\r\n\treturn multiply, T>(a, b);\r\n}\r\ntemplate vector fft_double_multiply(const vector& a, const vector& b) {\r\n\treturn multiply, T>(a, b);\r\n}\r\ntemplate vector fft_mod_multiply(const vector& a, const vector& b) {\r\n\treturn multiply, T>(a, b);\r\n}\r\n\r\ntemplate vector inverse(const vector& a) {\r\n\tvector r(sz(a));\r\n\tinverser::inverse(begin(a), sz(a), begin(r));\r\n\treturn r;\r\n}\r\ntemplate vector fft_inverse(const vector& a) {\r\n\treturn inverse, T>(a);\r\n}\r\ntemplate vector fft_double_inverse(const vector& a) {\r\n\treturn inverse, T>, T>(a);\r\n}\r\ntemplate vector fft_mod_inverse(const vector& a) {\r\n\treturn inverse, T>, T>(a);\r\n}\r\n\r\n}} // namespace ecnerwala::fft\r\n\r\nusing num = modnum<998244353>;\r\n\r\nvector fact, ifact;\r\n\r\nvoid init(){\r\n\tint N = 1100000;\r\n\tfact = {1};\r\n\tfor(int i = 1; i < N; i++) fact.push_back(i * fact[i-1]);\r\n\tifact.resize(N);\r\n\tifact.back() = 1 / fact.back();\r\n\tfor(int i = N - 1; i > 0; i--) ifact[i-1] = i * ifact[i];\r\n}\r\n\r\nnum ncr(int n, int k){\r\n\tif(k < 0 || k > n) return 0;\r\n\treturn fact[n] * ifact[k] * ifact[n-k];\r\n}\r\n\r\nint main(){\r\n\tios_base::sync_with_stdio(false), cin.tie(nullptr);\r\n\tinit();\r\n\tint n, k;\r\n\tcin >> n >> k;\r\n\tnum ans = 0;\r\n\r\n\tint f = min(n, k);\r\n\tvector s1(f+1, 0);\r\n\tvector sa(f+1, 0);\r\n\tfor(int a = 1; a <= f; a++){\r\n\t\tsa[a] = pow(num(a), k) * ifact[a];\r\n\t}\r\n\tfor(int i = 0; i <= f; i++){\r\n\t\ts1[i] = ifact[i] * pow(num(-1), i);\r\n\t}\r\n\tvector res = ecnerwala::fft::multiply>(s1, sa);\r\n\tnum ncb = 1;\r\n\tfor(int b = 1; b <= f; b++){\r\n\t\tncb *= (n+1 - b);\r\n\t\tncb /= b;\r\n\t\tans += res[b] * ncb * fact[b] * pow(num(n+1), n-b);\r\n\t}\r\n\tcout << ans << '\\n';\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e3bd1c508dd1b8e2cf57f15c76028bde", "src_uid": "bc57a69c39c6e74d6d81a9c504104809", "difficulty": 3300.0} {"lang": "GNU C++17", "source_code": "\n\n\t\n\t\n\t\t\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "21415914f7c5280361d039639db65834", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{ \n int n,a,a1,a2,a3,a4,a5;\n cin>>n;\n if(n==1)\n {\n cin>>a;\n cout<\n \nusing namespace std;\n \n#define llong long long\n#define endl \"\\n\"\n#define fi first\n#define se second\n#define left LEVO\n#define right PRAVO\n#define time CHAS\n#define prev PAPEREDNIKXD\n#define next NASTUPNIKXD\n#define pb push_back\n#define deb cout<<\"CHECK\\n\";\n \n#define elif else if\n#define cclear cout<> ans;\nint z;\nint main()\n{\n kchay;\n //files;\n cin >> n;\n for(int i=1;i<=n;i++)\n {\n cin >> a[i];\n }\n used[1]=true;\n for(int i=1;i<=n;i++)\n {\n if(!used[i])continue;\n for(int j=1;j<=n && a[i]>0;j++)\n {\n if(i==j)continue;\n if(a[j]>0 && !used[j])used[j]=true, a[i]--, z++, ans.pb({i, j});\n }\n if(!a[i])continue;\n for(int j=1;j<=n && a[i]>0;j++)\n {\n if(i==j)continue;\n if(a[j]==0 && !used[j])used[j]=true, a[i]--, z++, ans.pb({i, j});\n }\n }#include \n \nusing namespace std;\n \n#define llong long long\n#define endl \"\\n\"\n#define fi first\n#define se second\n#define left LEVO\n#define right PRAVO\n#define time CHAS\n#define prev PAPEREDNIKXD\n#define next NASTUPNIKXD\n#define pb push_back\n#define deb cout<<\"CHECK\\n\";\n \n#define elif else if\n#define cclear cout<> n;\n for(int i=0;i> a[i];\n }\n \n sort(a, a+n);\n cout << a[n/2];\n \n return 0;\n}\n \n if(z!=n-1)return cout << -1, 0;\n \n cout << ans.size() << endl;\n for(auto i:ans)\n {\n cout << i.fi << \" \" << i.se << endl;\n }\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fb1db519e4c9333a6469fe1f4d502078", "src_uid": "f03773118cca29ff8d5b4281d39e7c63", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n int n,a[5];//\u6570\u7ec4\u5f005\u5c31\u884c\u4e86\n cin>>n;\n for(int i=1;i<=n;++i) cin>>a[i];//\u5faa\u73af\u8f93\u5165\n sort(1,n);//\u6392\u5e8f\n if(n==1||n==2) cout</*{{{*/\ntypedef long long ll; typedef long double ld; using namespace std;void run();int main(){ios::sync_with_stdio(false);run();}/*}}}*/\n\nll const lots=1000000007ll;\nll memo[55][55][2];\nll choose[55][55];\n\nll half(ll n){\n ll res=n;\n ll s=2;\n for (ll i=lots-2; i; i>>=1, (s*=s)%=lots)\n if (i&1)\n (res*=s)%=lots;\n return res;\n}\n\nll solve(int n,int k,bool matched){\n if (n<=0 or k<0 or k*2>n) return 0ll;\n if (n==1) return k==0 and not matched;\n ll &res=memo[n][k][matched];\n if (ares) return ares;\n\n // single child\n if (matched){\n res+=solve(n-1,k-1,false)\n *choose[n-1][1];\n res%=lots;\n }else{\n res+=solve(n-1,k,true)\n *choose[n-1][1];\n res%=lots;\n }\n\n // two children\n if (not matched){\n for (int a=1,b=n-2; a<=b; a++,b--){\n for (int i=0,j=k; i<=k; i++,j--){\n res+=(((\n solve(a,i,true)\n *solve(b,j,true) % lots)\n *(a==b? half(choose[n-1][a]): choose[n-1][a]) % lots)\n *choose[a][1] % lots)\n *choose[b][1];\n res%=lots;\n }\n }\n }else{\n for (int a=1,b=n-2; a<=n-2; a++,b--){\n for (int i=0,j=k-1; i<=k-1; i++,j--){\n if (a \"<>n>>k;\n cout<<(solve(n,k,false)+solve(n,k,true))%lots<

    #include   \n#include   \n#include   \n#include   \n#include   \n#include   \n#include   \n#include   \n#include   \n#include   \n#include   \n#include   \n#include   \n#include   \n#include   \n#include   \n#include   \n#include   \n#define CLR(x,y) memset(x,y,sizeof(x))  \n#define eps 1e-9  \n#define INF 0x3f3f3f3f  \n  \nusing namespace std;  \n  \ntypedef long long ll;  \ntypedef long double ld;  \ntypedef pair pll;  \ntypedef complex point;  \ntypedef pair pii;  \ntypedef pair piii;  \n  \ntemplate  \ninline bool read(T &n)  \n{  \n    T x = 0, tmp = 1;  \n    char c = getchar();  \n    while((c < '0' || c > '9') && c != '-' && c != EOF) c = getchar();  \n    if(c == EOF) return false;  \n    if(c == '-') c = getchar(), tmp = -1;  \n    while(c >= '0' && c <= '9') x *= 10, x += (c - '0'),c = getchar();  \n    n = x*tmp;  \n    return true;  \n}  \ntemplate   \ninline void write(T n)  \n{  \n    if(n < 0)  \n    {  \n        putchar('-');  \n        n = -n;  \n    }  \n    int len = 0,data[20];  \n    while(n)  \n    {  \n        data[len++] = n%10;  \n        n /= 10;  \n    }  \n    if(!len) data[len++] = 0;  \n    while(len--) putchar(data[len]+48);  \n}  \n//-----------------------------------  \n  \nconst int MOD=1000000007;  \nconst int MAXN=60;  \n  \nll dp[MAXN][MAXN][2],C[105][105];;  \nint n,k;  \n  \nint main()  \n{  \n    while(read(n)&&read(k))  \n    {  \n        CLR(dp,0);  \n        dp[1][0][0]=1;  \n        dp[1][0][1]=0;  \n        dp[0][0][0]=0;  \n        dp[0][0][1]=1;  \n        C[0][0]=1;  \n        for(int i=1; i<=n; i++)  \n        {  \n            for(int j=0; j<=i; j++)  \n            {  \n                if(!j || j==i) C[i][j]=1LL;  \n                else C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;  \n            }  \n        }  \n        for(int i=2; i<=n; i++)  \n        {  \n            for(int j=0; j<=k; j++)  \n            {  \n                dp[i][j][0]=(dp[i][j][0]+((i-1)*dp[i-1][j][1])%MOD)%MOD;  \n                if(j)  \n                    dp[i][j][1]=(dp[i][j][1]+((i-1)*dp[i-1][j-1][0])%MOD)%MOD;  \n                for(int q=1; q\ntypedef long long ll;\nll const mod = 1000000007, inv2 = (mod + 1) / 2;\ninline ll pls(ll a, ll b) { return a + b < mod ? a + b : a + b - mod; }\nint n = 0, k =0;\nll f[51][51][2], C[51][51];\nint main() {\n\tscanf(\"%d %d\", &n, &k);\n\tC[0][0] = 1;\n\tfor (int i = 1; i <= n; ++i) {\n\t\tC[i][0] = 1;\n\t\tfor (int j = 1; j <= n; ++j) C[i][j] = pls(C[i - 1][j - 1], C[i - 1][j]);\n\t}\n\tf[1][0][0] = f[0][0][1] = 1;\n\tfor (int i = 2; i <= n; ++i) {\n\t\tfor (int j = 1; j <= k && 2 * j <= i; ++j) {\n\t\t\tfor (int ls = 0; ls <= i - 1 - ls; ++ls) {\n\t\t\t\tint rs = i - 1 - ls;\n\t\t\t\tll v = C[i - 1][ls] * (ls == rs ? inv2 : 1) % mod * (i == n ? 1 : i) % mod;\n\t\t\t\tfor (int lmat = 0; lmat <= j; ++lmat) {\n\t\t\t\t\tif (lmat * 2 > ls || (j - lmat) * 2 > rs) continue;\n\t\t\t\t\tf[i][j][0] = pls(f[i][j][0], f[ls][lmat][1] * f[rs][j - lmat][1] % mod * v % mod);\n\t\t\t\t}\n\t\t\t\tfor (int lmat = 0; lmat <= j - 1; ++lmat) {\n\t\t\t\t\tif (lmat * 2 > ls || (j - 1 - lmat) * 2 > rs) continue;\n\t\t\t\t\tf[i][j][1] = pls(f[i][j][1], f[ls][lmat][1] * f[rs][j - 1 - lmat][0] % mod * v % mod);\n\t\t\t\t\tf[i][j][1] = pls(f[i][j][1], f[ls][lmat][0] * f[rs][j - 1 - lmat][1] % mod * v % mod);\n\t\t\t\t\tf[i][j][1] = pls(f[i][j][1], f[ls][lmat][0] * f[rs][j - 1 - lmat][0] % mod * v % mod);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tll ans = pls(f[n][k][0] + f[n][k][1]);\n\tprintf(\"%lld\", ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2629bda783e8e581c75aedcc91617f69", "src_uid": "f98b740183281943eafd90328854746b", "difficulty": 2600.0}
    {"lang": "GNU C++11", "source_code": "#include\n\nusing namespace std;\n\ntypedef long long ll;\n\nconst ll mod = 1000000007;\n\n#define IOS  ios::sync_with_stdio(0); cin.tie(0);\n#define endl \"\\n\"\nlldp[55][55][3];\nll c[55][55];\nsigned main() {\n\n        IOS;\n        dp[0][0][1] = 1; \n        dp[1][0][1] = 0;\n        dp[1][0][0] = 1; \n        dp[0][0][0] = 1; int n , k; cin >>n >> k; \n        c[0][0] = 1;\n        for (int i = 1; i <= n; c[i][0] = 1, i++)\n            for (int j = 1; j <= n; j++)\n                c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;\n                \n        for(int i = 2; i <= n ; i++) {\n         \tfor(int j = 0; j <= k; j++)  {\n         \t\tfor(int Left = 1; Left <= i - 1; Left++)  {\n    \t\t\t\n    \t     \t    ll coef = c[i - 2][Left - 1] * Left * max(1 , (i - Left - 1) )  %  mod;\n    \t\t    \n    \t    \t    for(int kLeft = 0 ; kLeft <= j - 1; kLeft++) {\n    \t    \t    \t\n    \t    \t    \tll addFi = dp[Left][kLeft][0] * ((i - Left - 1  ) > 0 ? dp[i - Left - 1][j - 1 - kLeft][1] + dp[i - Left -1][j - 1 - kLeft][0] : j - kLeft - 1 == 0 ? 1 : 0);      \n\t\t\t     \t\tll addSe = ( (i - Left - 1 )> 0 ? dp[Left][kLeft][1] *  dp[i - Left -1][j - 1 - kLeft][0] : 0);     \n\t\t\t    \t\tdp[i][j][1] += coef * (addFi + addSe) % mod;   \n\t\t\t    \t}\n\t\t\t\tfor(int kLeft = 0 ; kLeft <=j ; kLeft++) {\n\t\t\t\t\t\n\t\t\t\t\tdp[i][j][0] += coef * dp[Left][kLeft][1] * dp[i - Left -1][j - kLeft][1] % mod;\n\t\t\t\t\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tcout << (dp[n][k][0] + dp[n][k][1]) % mod;\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "abc0aa88865674d3d0dd858ccf65823b", "src_uid": "f98b740183281943eafd90328854746b", "difficulty": 2600.0}
    {"lang": "GNU C++17", "source_code": "#include\nusing namespace std; \ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef std::pair pii;\nconst int N = 7;\nconst int M = 50;\nconst int POW3 = 3 * 3 * 3 * 3 * 3 * 3 * 3;\nint pow3[N + 1];\nint dp[M][N][POW3];\nint getBit(int mask, int pos){\n    if (pos < 0)\n        return 2;\n    mask /= pow3[pos];\n    return mask % 3;\n}\nvoid setMask(int & mask, int pos, int val){\n    if (pos < 0)\n        throw 42;\n    mask += (val - getBit(mask, pos)) * pow3[pos];\n}\nvoid updateDP(int col, int row, int mask, int val){\n    int & res = dp[col][row][mask];\n    res = min(res, val);\n}\nint main(){\n    int n, m;\n    scanf(\"%d%d\", &n, &m);\n    if (n > m)\n        swap(n, m);\n    pow3[0] = 1;\n    for (int i = 1; i < N; ++i)\n        pow3[i] = pow3[i - 1] * 3;\n    fill(dp, 0x7f);\n    int startMask = 0;\n    for (int i = 0; i < n; ++i)\n        startMask = startMask * 3 + 2;\n    dp[0][0][startMask] = 0;\n    for (int col = 0; col < m; ++col)\n        for (int row = 0; row <= n; ++row)\n            for (int mask = 0; mask < pow3[n]; ++mask){\n                if (dp[col][row][mask] > n * m)continue;\n                if (row == n){\n                    dp[col + 1][0][mask] = dp[col][n][mask];\n                }\n                else{\n                    int upBit = getBit(mask, row - 1);\n                    int leftBit = getBit(mask, row);\n                    int newMask = mask;\n                    if (leftBit != 1){\n                        setMask(newMask, row, (leftBit == 0 || upBit == 0) ? 2 : 1);\n                        updateDP(col, row + 1, newMask, dp[col][row][mask]);\n                    }\n                    newMask = mask;\n                    setMask(newMask, row, 0);\n                    if (upBit == 1)\n                        setMask(newMask, row - 1, 2);\n                    updateDP(col, row + 1, newMask, dp[col][row][mask] + 1);\n                }\n            }\n\n    int res = n * m;\n    for (int mask = 0; mask < pow3[n]; ++mask){\n        bool good = true;\n        for (int i = 0; i < n; ++i)\n            good &= (getBit(mask, i) != 1);\n        if (good)\n            res = min(res, dp[m][0][mask]);\n    }\n    printf(\"%d\\n\", n * m - res);\n    return 0;\n}\n//\u770b\u523014\u9875 ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d18cff61f7b3c063ecb1cf2f4e861fa7", "src_uid": "097674b4dd696b30e102938f71dd39b9", "difficulty": 2100.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nint g[1<<6],f[41][1<<6][1<<6];\n\nint main()\n{\n    int n,m,i,j,k,p,x;\n    scanf(\"%d%d\",&n,&m);\n    if (n=0)\n                    for (p=k; p<=all; p=(p+1)|k)\n                    {\n                        x=((p|(p<<1)|(p>>1)|j)&all)^all;\n                        f[i+1][p][x]=max(f[i+1][p][x],f[i][j][k]+g[p]);\n                    }\n    int ans=0;\n    for (i=0; i<=all; ++i) ans=max(ans,f[n][i][0]);\n    printf(\"%d\\n\",ans);\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bf4aa94b54a80984781d3f2f24b8602a", "src_uid": "097674b4dd696b30e102938f71dd39b9", "difficulty": 2100.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#define O(x) ((x)&1)\nusing namespace std;\n\nconst int N=40+5;\nconst int S=(1<<12)+5;\n\nint n,m,z,p,q,ans;\nint f[N][S];\nint c[S];\n\nint check(int a,int b,int c)\n{\n  for (int i=0;i>i-1)||i>i+1)||O(b>>i)||O(a>>i)||O(c>>i)))\n      return 0;\n  return 1;\n}\n\nint count(int a)\n{\n  int ret=0;\n  for (int i=0;i>i&1);\n  return ret;\n}\n\nint main() \n{\n//  freopen(\"e.in\",\"r\",stdin);\n//  freopen(\"e.out\",\"w\",stdout);\n\n  scanf(\"%d%d\",&n,&m);\n  if (n>m)) f[1][i]=count(i&p-1); \n    else f[1][i]=-n*m;\n  for (int i=0;i=0)\n      for (int k=0;k>m,k))\n        f[i][j>>m|k<?=f[i-1][j]+c[j>>m];\n  for (int i=0;i?=f[n][i];\n  printf(\"%d\",ans);\n  \n  return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d184e37048270fc8d3b65856d3ad1c5e", "src_uid": "097674b4dd696b30e102938f71dd39b9", "difficulty": 2100.0}
    {"lang": "GNU C++17", "source_code": "//\u9898\u76ee\u540d\u79f0:111c Petya and Spiders\n//\u65e5\u671f\uff1a2019.10.6\n#include\nusing namespace std;\nint n,m;\nint main()\n{\n\tscanf(\"%d%d\",&n,&m);\n\tif(n>m)swap(n,m);\n\tif(n==1)printf(\"%d\\n\",m-(m+2)/3);\n\telse if(n==2)\n\t\tprintf(\"%d\\n\",n*m-(n+m)/2);\n\telse if(n==3)printf(\"%d\\n\",2*m+(m-1)/4);\n\telse if(n==4)\n\t{\n\t\tif(m<5)printf(\"%d\\n\",3*m+(m-1)/4);\n\t\telse if(m<7)printf(\"%d\\n\",3*m-(m-1)/3));\n\t\telse if(m<9)printf(\"%d\\n\",3*m);\n\t\telse rintf(\"%d\\n\",3*m-1);\n\t}\n\telse if(n==5)\n\t\tprintf(\"%d\\n\",4*m-4);\n\telse printf(\"%d\\n\",3*m+8);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8b5bb4d3484f233352af53452aea8d3a", "src_uid": "097674b4dd696b30e102938f71dd39b9", "difficulty": 2100.0}
    {"lang": "GNU C++", "source_code": "#include  \nusing namespace std; \n\nint main() \n{ \nlong long x1,x2,y1,y2,k,a,b; \ncin\u00bbx1\u00bby1\u00bbx2\u00bby2; \na=x2-x1; \nb=y2-y1; \nk=a*b/4+(a+2)*(b+2)/4; \ncout\u00abk; \nreturn 0; \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "05db795cf8192c265c1c1ba52405dac1", "src_uid": "00cffd273df24d1676acbbfd9a39630d", "difficulty": 1900.0}
    {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define MAX_L 55 //\u6700\u5927\u957f\u5ea6\uff0c\u53ef\u4ee5\u4fee\u6539\nusing namespace std;\n\nclass bign\n{\npublic:\n    int len, s[MAX_L];//\u6570\u7684\u957f\u5ea6\uff0c\u8bb0\u5f55\u6570\u7ec4\n//\u6784\u9020\u51fd\u6570\n    bign();\n    bign(const char*);\n    bign(int);\n    bool sign;//\u7b26\u53f7 1\u6b63\u6570 0\u8d1f\u6570\n    string toStr() const;//\u8f6c\u5316\u4e3a\u5b57\u7b26\u4e32\uff0c\u4e3b\u8981\u662f\u4fbf\u4e8e\u8f93\u51fa\n    friend istream& operator>>(istream &,bign &);//\u91cd\u8f7d\u8f93\u5165\u6d41\n    friend ostream& operator<<(ostream &,bign &);//\u91cd\u8f7d\u8f93\u51fa\u6d41\n//\u91cd\u8f7d\u590d\u5236\n    bign operator=(const char*);\n    bign operator=(int);\n    bign operator=(const string);\n//\u91cd\u8f7d\u5404\u79cd\u6bd4\u8f83\n    bool operator>(const bign &) const;\n    bool operator>=(const bign &) const;\n    bool operator<(const bign &) const;\n    bool operator<=(const bign &) const;\n    bool operator==(const bign &) const;\n    bool operator!=(const bign &) const;\n//\u91cd\u8f7d\u56db\u5219\u8fd0\u7b97\n    bign operator+(const bign &) const;\n    bign operator++();\n    bign operator++(int);\n    bign operator+=(const bign&);\n    bign operator-(const bign &) const;\n    bign operator--();\n    bign operator--(int);\n    bign operator-=(const bign&);\n    bign operator*(const bign &)const;\n    bign operator*(const int num)const;\n    bign operator*=(const bign&);\n    bign operator/(const bign&)const;\n    bign operator/=(const bign&);\n//\u56db\u5219\u8fd0\u7b97\u7684\u884d\u751f\u8fd0\u7b97\n    bign operator%(const bign&)const;//\u53d6\u6a21\uff08\u4f59\u6570\uff09\n    bign factorial()const;//\u9636\u4e58\n    bign Sqrt()const;//\u6574\u6570\u5f00\u6839\uff08\u5411\u4e0b\u53d6\u6574\uff09\n    bign pow(const bign&)const;//\u6b21\u65b9\n//\u4e00\u4e9b\u4e71\u4e71\u7684\u51fd\u6570\n    void clean();\n    ~bign();\n};\n#define max(a,b) a>b ? a : b\n#define min(a,b) a>(istream &in, bign &num)\n{\n    string str;\n    in>>str;\n    num=str;\n    return in;\n}\n\nostream &operator<<(ostream &out, bign &num)\n{\n    out<= 0; i--)\n        if (s[i] != num.s[i])\n            return sign ? (s[i] < num.s[i]) : (!(s[i] < num.s[i]));\n    return !sign;\n}\n\nbool bign::operator>(const bign&num)const\n{\n    return num < *this;\n}\n\nbool bign::operator<=(const bign&num)const\n{\n    return !(*this>num);\n}\n\nbool bign::operator>=(const bign&num)const\n{\n    return !(*this num || *this < num;\n}\n\nbool bign::operator==(const bign&num)const\n{\n    return !(num != *this);\n}\n\nbign bign::operator+(const bign &num) const\n{\n    if (sign^num.sign)\n    {\n        bign tmp = sign ? num : *this;\n        tmp.sign = 1;\n        return sign ? *this - tmp : num - tmp;\n    }\n    bign result;\n    result.len = 0;\n    int temp = 0;\n    for (int i = 0; temp || i < (max(len, num.len)); i++)\n    {\n        int t = s[i] + num.s[i] + temp;\n        result.s[result.len++] = t % 10;\n        temp = t / 10;\n    }\n    result.sign = sign;\n    return result;\n}\n\nbign bign::operator++()\n{\n    *this = *this + 1;\n    return *this;\n}\n\nbign bign::operator++(int)\n{\n    bign old = *this;\n    ++(*this);\n    return old;\n}\n\nbign bign::operator+=(const bign &num)\n{\n    *this = *this + num;\n    return *this;\n}\n\nbign bign::operator-(const bign &num) const\n{\n    bign b=num,a=*this;\n    if (!num.sign && !sign)\n    {\n        b.sign=1;\n        a.sign=1;\n        return b-a;\n    }\n    if (!b.sign)\n    {\n        b.sign=1;\n        return a+b;\n    }\n    if (!a.sign)\n    {\n        a.sign=1;\n        b=bign(0)-(a+b);\n        return b;\n    }\n    if (a= 0) g = 0;\n        else\n        {\n            g = 1;\n            x += 10;\n        }\n        result.s[result.len++] = x;\n    }\n    result.clean();\n    return result;\n}\n\nbign bign::operator * (const bign &num)const\n{\n    bign result;\n    result.len = len + num.len;\n\n    for (int i = 0; i < len; i++)\n        for (int j = 0; j < num.len; j++)\n            result.s[i + j] += s[i] * num.s[j];\n\n    for (int i = 0; i < result.len; i++)\n    {\n        result.s[i + 1] += result.s[i] / 10;\n        result.s[i] %= 10;\n    }\n    result.clean();\n    result.sign = !(sign^num.sign);\n    return result;\n}\n\nbign bign::operator*(const int num)const\n{\n    bign x = num;\n    bign z = *this;\n    return x*z;\n}\nbign bign::operator*=(const bign&num)\n{\n    *this = *this * num;\n    return *this;\n}\n\nbign bign::operator /(const bign&num)const\n{\n    bign ans;\n    ans.len = len - num.len + 1;\n    if (ans.len < 0)\n    {\n        ans.len = 1;\n        return ans;\n    }\n\n    bign divisor = *this, divid = num;\n    divisor.sign = divid.sign = 1;\n    int k = ans.len - 1;\n    int j = len - 1;\n    while (k >= 0)\n    {\n        while (divisor.s[j] == 0) j--;\n        if (k > j) k = j;\n        char z[MAX_L];\n        memset(z, 0, sizeof(z));\n        for (int i = j; i >= k; i--)\n            z[j - i] = divisor.s[i] + '0';\n        bign dividend = z;\n        if (dividend < divid) { k--; continue; }\n        int key = 0;\n        while (divid*key <= dividend) key++;\n        key--;\n        ans.s[k] = key;\n        bign temp = divid*key;\n        for (int i = 0; i < k; i++)\n            temp = temp * 10;\n        divisor = divisor - temp;\n        k--;\n    }\n    ans.clean();\n    ans.sign = !(sign^num.sign);\n    return ans;\n}\n\nbign bign::operator/=(const bign&num)\n{\n    *this = *this / num;\n    return *this;\n}\n\nbign bign::operator%(const bign& num)const\n{\n    bign a = *this, b = num;\n    a.sign = b.sign = 1;\n    bign result, temp = a / b*b;\n    result = a - temp;\n    result.sign = sign;\n    return result;\n}\n\nbign bign::pow(const bign& num)const\n{\n    bign result = 1;\n    for (bign i = 0; i < num; i++)\n        result = result*(*this);\n    return result;\n}\n\nbign bign::factorial()const\n{\n    bign result = 1;\n    for (bign i = 1; i <= *this; i++)\n        result *= i;\n    return result;\n}\n\nvoid bign::clean()\n{\n    if (len == 0) len++;\n    while (len > 1 && s[len - 1] == '\\0')\n        len--;\n}\n\nbign bign::Sqrt()const\n{\n    if(*this<0)return -1;\n    if(*this<=1)return *this;\n    bign l=0,r=*this,mid;\n    while(r-l>1)\n    {\n        mid=(l+r)/2;\n        if(mid*mid>*this)\n            r=mid;\n        else\n            l=mid;\n    }\n    return l;\n}\n\nbign::~bign()\n{\n}\nbign t,xa,ya,xb,yb;\n\nint main(){\n\tt=bign(1000000002);\n\tcin>>xa>>ya>>xb>>yb;\n\tif((xa%2==0)^(ya%2==0))ya--,yb--;\n\txa+=t,ya+=t,xb+=t,yb+=t;\n\tbign ox=xb/2-((xa-1)/2);\n\tbign oy=yb/2-((ya-1)/2);\n\tbign ex=xb-xa+1-ox;\n\tbign ey=yb-ya+1-oy;\n\tbign res=ox*oy+ex*ey;\n\tcout<\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint main()\n{\n\n\tlong long x1,x2,y1,y2,t,k;\ncin >> x1>>y1>>x2>>y2;\n\n\n\n\t  t= abs(((x2-x1)/2+1)*(((y2-y1)/2+1))) + abs(((x2-x1)/2)*(((y2-y1)/2)));\n\n\n\ncout << t\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8df0dd4aee1a6d41a3a55b5e4342bf11", "src_uid": "00cffd273df24d1676acbbfd9a39630d", "difficulty": 1900.0}
    {"lang": "MS C++", "source_code": "#include\n#include\nusing namespace std;\n\nint main(){\n#pragma warning(disable : 4996)\n#ifdef _DEBUG\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif\n\n\tlong long int  x1,y1,x2,y2;\n\tcin >> x1>>y1>>x2>>y2;\n\tlong long int kol;\n\tx2 = x2 - x1;\n\tx1 = 0;\n\ty2 = y2 - y1;\n\ty1 = 0;\n\n\tkol =(x2/2+1)*(y2/2+1)+(x/2)*(y/2);\n\tcout << kol;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "11355619a1caac89df7ef05c0f5ba4bc", "src_uid": "00cffd273df24d1676acbbfd9a39630d", "difficulty": 1900.0}
    {"lang": "GNU C++14", "source_code": "#include\n \nusing namespace std;\n \n#define ull unsigned long long\n#define LL long long int\n#define pii pair\n#define mp make_pair\n#define pb(x) push_back(x)\n#define F(i,a,n) for(int i=(a);i<(n);++i)\n#define FD(i,a,n) for(int i=(a);i>=(n);--i)\n#define FE(it,x) for(it=x.begin();it!=x.end();++it)\n#define V(x) vector\n#define S(x) scanf(\"%d\",&x)\n#define Sl(x) scanf(\"%llu\",&x)\n#define M(x,i) memset(x,i,sizeof(x))\n#define fr first\n#define se second\n#define MOD 1e9+7\n\n\nlong long  phi(long long n) {\n    long long i,res=n;\n    for(i=2;i*i<=n;i++) {\n        if(n%i==0) {\n        while(n%i==0)\n            n/=i;\n        res-=res/i;\n       }\n   }\n    if(n>1)\n        res-=res/n;\n    return res;\n}\nint main() {\n\tlong long n,k;\n\tcin >> n >> k;\n\tk = k+1;\n\tk/=2;\n\tlong long ans = n;\n\twhile(k--){\n\t\tans = phi(ans);\n\t\tif(ans == 1) break;\n\t}\n\tcout << ans%MOD << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4959970d7df64692c844c859a38b30fc", "src_uid": "0591ade5f9a69afcbecd80402493f975", "difficulty": 2100.0}
    {"lang": "GNU C++11", "source_code": "#include \n\n#define define_pair(classname, x, y) struct classname { int x; int y; \\\n    classname(int x = 0, int y = 0) : x(x), y(y) {} };\n\n#define define_triple(classname, x, y, z) struct classname { int x; int y; int z; \\\n    classname(int x = 0, int y = 0, int z = 0) : x(x), y(y), z(z) {} };\n\nusing namespace std;\n\ninline namespace Infinity\n{\ninline namespace Constant\n{\nconstexpr const int eof         = EOF;\nconstexpr const int maxint      = INT_MAX;\nconstexpr const long long maxll = LLONG_MAX;\nconstexpr const double eps      = DBL_EPSILON;\n} // namespace Infinity::Constant\n\ninline namespace TypeDefine\n{\nusing uint  = unsigned int;\nusing ll    = long long int;\nusing ull   = unsigned long long int;\nusing ld    = long double;\ntemplate using Pair = pair;\ntemplate using PairList = vector>;\ntemplate> using Iter = typename T::iterator;\n} // namespace Infinity::TypeDefine\n\ninline namespace IO\n{\nconst char LF = '\\n';\nconst char SP = ' ';\n\nint dbl_prec = 10;\nint ldbl_prec = 18;\n\ninline void write(const int n)\n{ printf(\"%d\", n); }\n\ninline void write(const unsigned n)\n{ printf(\"%u\", n); }\n\ninline void write(const int64_t n)\n{ printf(\"%\" PRId64, n); }\n\ninline void write(const uint64_t n)\n{ printf(\"%\" PRIu64, n); }\n\ninline void write(const double a)\n{ printf(\"%.*f\", dbl_prec, a); }\n\ninline void write(const long double a)\n{ printf(\"%.*Lf\", ldbl_prec, a); }\n\ninline void write(const char c)\n{ printf(\"%c\", c); }\n\ninline void write(const char s[])\n{ printf(\"%s\", s); }\n\ninline void write(const string &s)\n{ printf(\"%s\", s.data()); }\n\ntemplate inline void writeSP(const T a)\n{ write(a); write(SP); }\n\ntemplate inline void write(const pair &p)\n{ writeSP(p.first); write(p.second); }\n\ntemplate inline void write(const T a)\n{ for (auto i = a.begin(); i != a.end(); i++) { if (i != a.begin()) write(SP); write(*i); } }\n\ntemplate inline void write(initializer_list list)\n{ for (auto i = list.begin(); i != list.end(); i++) { if (i != list.begin()) write(SP); write(*i); } }\n\ntemplate inline void writer(T begin, T end)\n{ for (write(*begin++); begin != end; ++begin) write(SP), write(*begin); }\n\ninline void writeln()\n{ write(LF); }\n\ninline void writeSP()\n{ write(SP); }\n\ntemplate inline void writeln(const T &a)\n{ write(a); write(LF); }\n\ntemplate inline void writeln(initializer_list list)\n{ for (auto i = list.begin(); i != list.end(); i++) { if (i != list.begin()) write(SP); write(*i); } write(LF); }\n\ntemplate inline void writelns(const T &a)\n{ for (auto n : a) writeln(n); }\n\ntemplate inline void write(const T &a, const types &...args)\n{ write(a); write(args...); }\n\ntemplate inline void writeln(const types &...args)\n{ write(args...); write(LF); }\n\ntemplate inline void writeSP(const types &...args)\n{ write(args...); write(SP); }\n\ninline void writelnYN(bool b)\n{ writeln(b ? \"YES\" : \"NO\"); }\n\ninline void writelnyn(bool b)\n{ writeln(b ? \"Yes\" : \"No\"); }\n\nstring caseN(int n, bool sharp = true, bool space = true)\n{ return string(\"Case \") + (sharp ? \"#\" : \"\") + to_string(n) + \":\" + (space ? \" \" : \"\"); }\n\ninline int read(int &n)\n{ return scanf(\"%d\", &n); }\n\ninline int read(int64_t &n)\n{ return scanf(\"%\" SCNd64, &n); }\n\n//template inline int read(T &n, types &...args)\n//{ return read(n) == eof ? eof : read(args...) + 1; }\n\ninline char getcc()\n{ char c; do c = getchar(); while (isspace(c)); return c; }\n\ninline int getint()\n{ int n; read(n); return n; }\n\ninline int64_t getll()\n{ int64_t n; read(n); return n; }\n\ninline double getdbl()\n{ double n; scanf(\"%lf\", &n); return n; }\n\ninline pair getpair()\n{ pair p; scanf(\"%d%d\", &p.first, &p.second); return p; }\n\ninline vector getints(int n)\n{ vector v(n); for (int &i : v) i = getint(); return v; }\n\ninline vector > getpairs(int n)\n{ vector > v(n); for (pair &p : v) { p = getpair(); } return v; }\n\ninline void read(string &str, unsigned size)\n{ char s[++size]; scanf(\"%s\", s); str.assign(s); }\n\ninline string getstr(unsigned size = 0x100000)\n{ string s; read(s, size); return s; }\n\ninline string getln(unsigned size = 0x100000)\n{ char s[++size]; scanf(\"%[^\\n]\", s); getchar(); return s; }\n} // namespace Infinity::IO\n\ninline namespace BattleLab\n{\ntemplate\nclass AdjacencyList : public vector>\n{\npublic:\n    AdjacencyList(unsigned size = 0) : vector>(size)\n    {}\n\n    void addDirected(T u, T v)\n    { (*this)[u].push_back(v); }\n\n    void addUndirected(T u, T v)\n    { addDirected(u, v); addDirected(v, u); }\n};\n\nclass Range\n{\n    class RangeIterator\n    {\n    public:\n        RangeIterator(int current = 0, int step = 1) : current(current), step(step) {}\n        // works fine with c++11 range-based for loop ... only\n        bool operator !=(const RangeIterator &iterator) const { return current < iterator.current; }\n        int operator *() const { return current; }\n        RangeIterator operator ++() { return {current += step, step}; }\n    protected:\n        int current, step;\n    };\npublic:\n    Range(int to, int from = 0, int step = 1) : from(from), to(to), step(step) {}\n    RangeIterator begin() const { return {from, step}; }\n    RangeIterator end() const { return {to, step}; }\nprotected:\n    int from, to, step;\n};\n\nRange range(int to)\n{ return {to}; }\n\nRange range(int from, int to)\n{ return {to, from}; }\n\nRange range(int from, int to, int step)\n{ return {to, from, step}; }\n} // namespace Infinity::BattleLab\n\ninline namespace Miscelleneous\n{\ninline constexpr int ctoi(const char c)\n{ return c - '0'; }\n\ninline constexpr char itoc(const int n)\n{ return n + '0'; }\n\ninline int dtoi(const double d)\n{ return round(d); }\n\ntemplate inline constexpr bool in(T x, T l, T r)\n{ return l <= x && x <= r; }\n\ntemplate inline constexpr T tristate(int val, T nag, T zero, T pos)\n{ return val > 0 ? pos : val < 0 ? nag : zero; }\n\ntemplate inline int size(const T &a)\n{ return a.size(); }\n\ntemplate inline void sort(T &a)\n{ sort(a.begin(), a.end()); }\n\ntemplate inline void sort(T1 &a, T2 comp)\n{ sort(a.begin(), a.end(), comp); }\n\ntemplate inline int lbound(const T1 &a, const T2 k)\n{ return lower_bound(a.begin(), a.end(), k) - a.begin(); }\n\ntemplate inline int ubound(const T1 &a, const T2 k)\n{ return upper_bound(a.begin(), a.end(), k) - a.begin(); }\n\ntemplate inline int count(T1 &a, T2 k)\n{ return ubound(a, k) - lbound(a, k); }\n\ntemplate inline void clear(T &a)\n{ memset(a, 0, sizeof a); }\n\ntemplate T gcd(T a, T b)\n{ while (b) { T t = a % b; a = b; b = t; } return a; }\n\ntemplate T lcm(T a, T b)\n{ return a / gcd(a, b) * b; }\n\nlong long mod = 1e9 + 7;\n\nlong long qpow(long long a, long long b, long long c = mod)\n{ return b ? qpow(a * a % c, b >> 1, c) * (b & 1 ? a : 1) % c : 1; }\n\n// find (x, y) s.t. a x + b y = gcd(a, b) = d\ntemplate T exGcd(T a, T b, T &x, T &y)\n{ T d = a; if (b) { d = exGcd(b, a % b, y, x); y -= a / b * x; } else { x = 1; y = 0; } return d; }\n\n// returns number of nk's in [l, r]\ntemplate inline constexpr T mps(T l, T r, T k)\n{ return ((r - (r % k + k) % k) - (l + (k - l % k) % k)) / k + 1; }\n\ntemplate inline constexpr T sgn(T a)\n{ return a ? a > 0 ? 1 : -1 : 0; }\n\ntemplate inline constexpr T sq(T a)\n{ return a * a; }\n\ntemplate inline constexpr bool odd(T a)\n{ return bool(a % 2); }\n\ntemplate inline constexpr bool even(T a)\n{ return !bool(a % 2); }\n\n// simple mod\ntemplate inline constexpr T1 smod(T1 x, T2 m)\n{ return x > m ? x - m : x + m < m ? x + m : x; }\n\n// lengthes of recurring period of replacement `a`\nvector repetend(vector a)\n{ vector p(a.size(), -1);\n  for (unsigned i = 0; i < a.size(); i++) if (p[i] == -1) {\n    int c = 1; for (unsigned j = a[i]; j != i; j = a[j]) ++c;\n    p[i] = c; for (unsigned j = a[i]; j != i; j = a[j]) p[j] = c;\n  } return p; }\n\ntemplate inline constexpr T lmiddle(T first, T last)\n{ return first + (last - first) / 2; }\n\ntemplate inline constexpr T rmiddle(T first, T last)\n{ return last - (last - first) / 2; }\n\n// returns the largest value in [l, r) s.t. check(x)\ntemplate T dichotomy(T l, T r, F check, T prec = 1)\n{ while (r - l > prec) { T m = lmiddle(l, r); (check(m) ? l : r) = m; } return l; }\n\n// returns the smallest value in (l, r] s.t. check(x)\ntemplate T dichotomy2(T l, T r, F check, T prec = 1)\n{ while (r - l > prec) { T m = rmiddle(l, r); (check(m) ? r : l) = m; } return r; }\n\nbool contains(const string &s, const string &t)\n{ return s.find(t) != string::npos; }\n\ntemplate bool contains(const T &s, typename T::value_type t)\n{ for (typename T::value_type c : s) if (c == t) return true; return false; }\n\ntemplate bool contains(const initializer_list s, T t)\n{ return find(s.begin(), s.end(), t) != s.end(); }\n} // namespace Infinity::Miscelleneous\n} // namespace Infinity\n\nclass Prime\n{\npublic:\n    Prime(int n) : b(n, false), p()\n    { for (int i = 2; i < n; i++) { if (b[i] == false) {\n        p.push_back(i); for (int j = i + i; j < n; j += i) { b[j] = true; } } } }\n\n    vector> fact(long long n) // O(sqrt(n))\n    {\n        vector> fact;\n        for (int i = 0; 1ll * p[i] * p[i] <= n; i++) {\n            int k = 0;\n            while (n % p[i] == 0) { n /= p[i]; ++k; }\n            if (k) { fact.emplace_back(p[i], k); }\n        }\n        if (n > 1) { fact.emplace_back(n, 1); }\n        return fact;\n    }\n\n    long long phi(long long n)\n    {\n        long long phi = 1; vector> fct = fact(n);\n        for (auto p : fct) { phi *= (p.first - 1) * qpow(p.first, p.second - 1); }\n        return phi;\n    }\n\nprotected:\n    vector b, p;\n};\n\nint main()\n{\n    mod = maxll;\n    long long n = getll(), k = getll();\n    Prime p(1234567);\n    for (int i = 0; i < (k + 1) / 2; i++) {\n        n = p.phi(n);\n        if (n == 1) {\n            break;\n        }\n    }\n    writeln(n % (1e9 + 7));\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0c0d4287ba5d8ef3d0e9b3067e403841", "src_uid": "0591ade5f9a69afcbecd80402493f975", "difficulty": 2100.0}
    {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define int int64_t\n#define fs first\n#define sc second\n#define mp make_pair\n#define pb push_back\n#define pob pop_back\n#define sz(v) ((int) v.size())\n#define all(v) v.begin(), v.end()\n#define forn(i, j, n) for (int i = j; i < n; ++i)\n#define forc(i, n, j) for (int i = n - 1; i >= j; --i)\ntypedef long long ll;\ntypedef pair  pii;\ntypedef vector  vi;\ntypedef vector  vd;\ntypedef vector  vb;\ntypedef vector  vpii;\n\nint f(int n)\n{\n    int ans = n;\n    for (int i = 2; i * i <= n; ++i)\n    {\n        if (n % i != 0) continue;\n        ans -= ans / i;\n        while (n % i == 0)\n            n /= i;\n    }\n    if (n != 1)\n        ans -= ans / i;\n    return ans;\n}\n\nint32_t main()\n{\n    ios_base::sync_with_stdio(false);\n    cin.tie(0); cout.tie(0);\n    int n, k;\n    cin >> n >> k;\n    int val = (k + 1) / 2;\n    forn(i, 0, val)\n    {\n        if (n == 1)\n        {\n            cout << n;\n            return 0;\n        }\n        n = f(n);\n    }\n    cout << n;\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "51ac1756b475ce30297717237b3b4631", "src_uid": "0591ade5f9a69afcbecd80402493f975", "difficulty": 2100.0}
    {"lang": "GNU C++11", "source_code": "/******************************************\n*    AUTHOR:         CHIRAG AGARWAL       *\n*    INSTITUITION:   BITS PILANI, PILANI  *\n******************************************/\n#include \nusing namespace std;\n \ntypedef long long LL; \ntypedef long double LD;\n\ntypedef long long LL;\nlong long mulmod(long long a,long long b, long long MOD) \n{\n\tlong long q=(long long)(((long double)a*(long double)b)/(long double)MOD);\n\tlong long r=a*b-q*MOD;\n\tif (r>MOD) r %= MOD;\n\tif(r<0) r+=MOD;\n\treturn r;\n}\n\nlong long power(long long b, long long n, long long mod) \n{\n\tlong long x=1, p=b;\n\twhile(n) \n\t{\n\t\tif(n&1) \n\t\t{\n\t\t\tx = mulmod(x, p, mod);\n\t\t}\n\t\tp = mulmod(p, p, mod);\n\t\tn >>= 1;\n\t}\n\treturn x;\n}\n\nbool rabin_miller(long long p) \n{\n\tif (p < 2) return false;\n\tif (p != 2 && p % 2 == 0) return false;\n\tif (p < 8) return true;\n\tlong long s = p-1, val = p-1, a, m, temp;\n\twhile (s % 2 == 0) s >>= 1;\n\tfor (int i = 0; i < 3; ++i) \n\t{\n\t\ta = 1ll*rand()%val + 1ll;\n\t\ttemp = s;\n\t\tm = power(a, temp, p);\n\t\twhile (temp != (p-1) && m != 1 && m != (p-1)) \n\t\t{\n\t\t\tm = mulmod(m, m, p);\n\t\t\ttemp <<= 1;\n\t\t}\n\t\tif (m != (p-1) && temp % 2 == 0) return false;\n\t}\n\treturn true;\n}\n\n\nvector lst;\n\nint main() \n{\n\tlong long n,k;\n\tscanf(\"%lld %lld\",&n,&k);\n\tlong long val=(k+1)/2;\n\tlong long cur=n;\n\tlong long tmp;\n\t\tfor(int i=1;i<=val;i++)\n\t\t{\n\t\t\tlong long rt=sqrt(cur);\n\t\t\ttmp=cur;\n\t\t\tfor(int j=2;j<=rt;j++)\n\t\t\t{\n\t\t\t\tif(tmp==1)\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif((tmp%j)==0)\n\t\t\t\t{\n\t\t\t\t\tif(rabin_miller(j))\n\t\t\t\t\t{\n\t\t\t\t\t\tlst.push_back(j);\n\t\t\t\t\t\twhile((tmp%j)==0)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttmp/=j;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(tmp!=1)\n\t\t\t{\n\t\t\t\tlst.push_back(tmp);\n\t\t\t}\n\t\t\tfor(int j=0;j\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n//#include \n\ntypedef int long long bint;\ntypedef unsigned int long long buint;\n\n\nusing namespace std;\n\n\nvoid problemE();\nint main(){\n\t/*int n;\n\tvector p(100);\n\tcin >> n;*/\n\tproblemE();\n\treturn 0;\n}\n\nvoid problemA(){\n\tset a;\n\tchar temp;\n\tcin.get(temp);\n\tif (temp == '{'){\n\t\twhile (temp != '}'){\n\t\t\tcin.get(temp);\n\t\t\tif (temp >= 'a' && temp <= 'z')\n\t\t\t\ta.insert(temp);\n\t\t}\n\t}\n\tcout << a.size();\n}\nint maxsub(string &a, int k, int l){\n\tint counter = 0;\n\tfor (int i = 0; i < a.size(); ++i){\n\t\tif (i + k >= a.size()){\n\t\t\t//if (counter + l == k){\n\t\t\tif (k - counter <= l){\n\t\t\t\treturn k;\n\t\t\t}\n\t\t\telse\n\t\t\t\treturn 0;\n\t\t}\n\t\tif (a[i] != a[i + k]){\n\t\t\tif (counter == k)\n\t\t\t\treturn k;\n\t\t\telse if (counter == 0)\n\t\t\t\tcontinue;\n\t\t\telse{\n\t\t\t\tcounter = 0;\n\n\t\t\t}\n\t\t}\n\t\telse{\n\t\t\tcounter += 1;\n\t\t\tif (counter == k)\n\t\t\t\treturn k;\n\t\t}\n\n\n\t}\n\tif (counter == k)\n\t\treturn k;\n\telse\n\t\treturn 0;\n}\nvoid problemB(){\n\tstring s = \"uqytussdzppiuwxterrfyrwtsrkdpfzhjpeuuulopnnjtltdtlkzwixouxteuheqaxhaicoeveggwkcnkamluxykyktmvafajfnxmeuuulopnnjtltdtlkzwixouxteuheqaxhaicoeveggwkcnkamluxykyktmvafajfnxmefkurbbcbesiwcauwmlhmfslcavsreea\";\n\n\tcin >> s;\n\tint k = 41;\n\tcin >> k;\n\tchar temp;\n\tint tandem = 0;\n\n\tint i = (s.size() + k) / 2 + 1;\n\twhile (i-- > 0){\n\t\ttandem = maxsub(s, i, k);\n\t\tif (tandem != 0)\n\t\t\tbreak;\n\t}\n\n\ttandem *= 2;\n\tcout << tandem;\n}\ninline int min(int a, int b){\n\tif (a < b)\n\t\treturn a;\n\telse\n\t\treturn b;\n}\nint recursion(vector &a, int sum){\n\tif (a.size() == 3){\n\t\treturn sum + min(a[0], a[2]);\n\t}\n\telse{\n\n\t\tint maxi = 0;\n\t\tint price = 0;\n\t\tfor (int i = 0; i < a.size(); i++){\n\n\t\t\tif (i != a.size() - 1 && i != 0)\n\t\t\t\tprice = min(a[i - 1], a[i + 1]);\n\t\t\telse\n\t\t\t\tprice = 0;\n\t\t\tint temp = a[i];\n\t\t\ta.erase(a.begin() + i);\n\t\t\tint tmp1 = recursion(a, sum + price);\n\t\t\ta.insert(a.begin() + i, temp);\n\n\t\t\tif (maxi < tmp1){\n\t\t\t\tmaxi = tmp1;\n\t\t\t}\n\t\t}\n\t\treturn  maxi;\n\t}\n\n}\nvoid problemErec(){\n\tint n = 10;\n\t//cin >> n;\n\tif (n == 2){\n\t\tcout << 0;\n\t\treturn;\n\t}\n\n\tint max = 0;\n\tint maxindex;\n\t//vector a(n);\n\tvector a = { 96, 66, 8, 18, 30, 48, 34, 11, 37, 42 };\n\tfor (int i = 0; i < n; i++){\n\t\t//cin >> a[i];\n\t}\n\tint sum = 0;\n\tcout << recursion(a, sum);\n}\nvoid problemE(){\n\tint n = 10;\n\tcin >> n;\n\tif (n == 2){\n\t\tcout << 0;\n\t\treturn ;\n\t}\n\n\tint max = 0;\n\tint maxindex;\n\tvector a(n);\n\n\t//vector a = { 96, 66, 8, 18, 30, 48, 34, 11, 37, 42 };\n\t//vector a = { 42, 37, 11, 34, 48, 30, 18, 8, 66, 96 };\n\tint first = 0;\n\tfor (int i = 0; i < n; i++){\n\t\tcin >> a[i];\n\t}\n\tint sum = 0;\n\n\twhile (a.size() > 2){\n\n\t\tfor (int i = 1; i < a.size() - 1 ; ++i){\n\t\t\tmaxindex = -1;\n\t\t\tint ankouc = min(a[i - 1], a[i + 1]);\n\t\t\tif (a[i] < ankouc)\n\t\t\t{\n\t\t\t\tsum += ankouc;\n\t\t\t\tmaxindex = i;\n\t\t\t\ta.erase(a.begin() + maxindex);\n\t\t\t\ti--;\n\t\t\t}\n\n\t\t}\n\t\tif (maxindex == -1){\n\t\t\tsort(a.begin(), a.end());\n\t\t\tfor (int i = 0; i < a.size()-2; ++i){\n\t\t\t\tsum += a[i];\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t}\n\tcout << sum;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "865ba81dcf9f808f3f0e4c533084fb84", "src_uid": "e7e0f9069166fe992abe6f0e19caa6a1", "difficulty": 2500.0}
    {"lang": "GNU C++", "source_code": "#include \n#define mod 1000000009LL\n#define siz 100000009\n#define maxx 100000009\n#define ll long long\n#define ull unsigned long long\n#define sqr(x) ((x)*(x))\n#define cube(x) ((x)*(x)*(x))\n#define rep(i,n) for(__typeof(n) i=0;i<(n);i++)\n#define FOR(i,a,b) for(__typeof(b) i=(a);i<(b);++i)\n#define fore(i,a,b) for(__typeof(b) i=(a);i<=(b);++i)\n#define ford(i,a,b,d) for(__typeof(b) i=(a);i<(b);i+=(d))\n#define forr(i,n,e) for(__typeof(n) i=(n);i>=(e);--i)\n#define forrd(i,n,e,d) for(__typeof(n) i=(n);i>=(e);i-=(d))\n#define repit(it,m) for(it=m.begin();it!=m.end();it++)\n#define fori(it,s) for(__typeof((s).begin()) (it)=(s).begin();(it)!=(s).end();(it)++)\n#define foreach(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); ++it)\n#define unique(v) sort(ALL(v)),v.erase(unique(ALL(v)),v.end())\n#define fill(a,b) memset(a,b,sizeof(a))\n#define all(v) (v).begin(), (v).end()\n#define rall(v) (v).rbegin(), (v).rend()\n#define pb push_back\n#define mp make_pair\n#define ff first\n#define ss second\n#define test int T;cin>>T;fore(t,1,T)\n#define sz(x) int((x).size())\n#define s(n) cin>>n;\n#define p(n) cout<p[N];\nint pr[N],ne[N];\nvoid solve()\n{\n  int n;\n  cin>>n;\n  rep(i,n)\n    {\n      cin>>a[i];\n      p[i] = mp(a[i],i);\n    }\n  sort(all(p));\n  rep(i,n)\n    {\n      pr[i] = i-1;\n      ne[i] = i+1;\n    }\n  int low=0,high=n-1;\n  ll ans = 0;\n  rep(i,n-2)\n    {\n      int j=p[i].second;\n      if(j==low)\n    {\n      ans += p[i].first;\n      low=ne[low];\n      continue;\n    }\n      if(j==high)\n    {\n      ans+= p[i].first;\n      high = pr[high];\n      continue;\n    }\n      int x = a[pr[j]];\n      int y = a[ne[j]];\n      if(x\n\n#define MAXN 500100\n\nusing namespace std;\n\ntypedef long long L;\n\nint n;\nL vals[MAXN];\nint l[MAXN], r[MAXN];\nint idxs[MAXN];\n\nbool idx_cmp(int rhs, int lhs)\n{\n    return vals[rhs] < vals[lhs];\n}\n\nvoid rem(int idx)\n{\n    l[idx + 1] = l[idx];\n    r[idx - 1] = r[idx];\n}\n\nint main()\n{\n    ios_base::sync_with_stdio(0);\n    cin.tie(0);\n\n    L ignore_this;\n    while(cin >> n)\n    {\n        for(int i = 0; i < n; ++i)\n        {\n            cin >> vals[i];\n            idxs[i] = i;\n            l[i] = i - 1;\n            r[i] = i + 1;\n        }\n\n        sort(idxs + 1, idxs + n - 1, idxs_cmp);\n\n        L ans = 0;\n        for(int i = 1; i < n - 1; ++i)\n        {\n            int idx = idxs[i];\n            ans += min(vals[l[idx]], vals[r[idx]]);\n            rem(idx);\n        }\n\n        cout << ans << '\\n';\n    }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a8b4e7ea6de92496a0482b4ef74dcbd0", "src_uid": "e7e0f9069166fe992abe6f0e19caa6a1", "difficulty": 2500.0}
    {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n//#include \n\ntypedef int long long bint;\ntypedef unsigned int long long buint;\n\n\nusing namespace std;\n\n\nvoid problemE(){\n\tint n = 10;\n\tcin >> n;\n\tif (n == 2){\n\t\tcout << 0;\n\t\treturn;\n\t}\n\n\tint max = 0;\n\tint maxindex;\n\t//vector a(n);\n\n\tvector a = { 96, 66, 8, 18, 30, 48, 34, 11, 37, 42 };\n\t//vector a = { 42, 37, 11, 34, 48, 30, 18, 8, 66, 96 };\n\tint first = 0;\n\tfor (int i = 0; i < n; i++){\n\t\t//cin >> a[i];\n\t}\n\tint sum = 0;\n\n\t//while (a.size() > 2){\n\t\tif (a[0] > a[a.size()-1]){\n\t\t\tfor (int i = 1; i < a.size() - 1; ++i){\n\t\t\t\tmaxindex = -1;\n\t\t\t\tint ankouc = min(a[i - 1], a[i + 1]);\n\t\t\t\tif (a[i] < ankouc)\n\t\t\t\t{\n\t\t\t\t\tsum += ankouc;\n\t\t\t\t\tmaxindex = i;\n\t\t\t\t\ta.erase(a.begin() + maxindex);\n\t\t\t\t\ti -= 2;\n\t\t\t\t\tif (i < 1)i = 1;\n\t\t\t\t}\n\n\t\t\t}\n\t\t\t//if (maxindex == -1){\n\t\t\t\t//sort(a.begin(), a.end());\n\t\t\t\tfor (int i = a.size()-1; i > 1; --i){\n\t\t\t\t\tsum += a[i];\n\t\t\t\t}\n\t\t\t\t//break;\n\t\t\t//}\n\t\t}\n\t\telse if (a[0] < a[a.size() - 1]){\n\t\t\tfor (int i = a.size() - 2; i > 0; --i){\n\t\t\t\tmaxindex = -1;\n\t\t\t\tint ankouc = min(a[i - 1], a[i + 1]);\n\t\t\t\tif (a[i] < ankouc)\n\t\t\t\t{\n\t\t\t\t\tsum += ankouc;\n\t\t\t\t\tmaxindex = i;\n\t\t\t\t\ta.erase(a.begin() + maxindex);\n\t\t\t\t\ti += 1;\n\t\t\t\t\tif (i > a.size() - 2)i = a.size() - 2;\n\t\t\t\t}\n\n\t\t\t}\n\t\t\t//if (maxindex == -1){\n\t\t\t\t//sort(a.begin(), a.end());\n\t\t\t\tfor (int i = 0; i < a.size() - 2; ++i){\n\t\t\t\t\tsum += a[i];\n\t\t\t\t}\n\t\t\t\t//break;\n\t\t\t//}\n\t\t}\n\t\telse{\n\t\t\tsort(a.begin() , a.end() );\n\t\t\tfor (int i = a.size() -3; i >=0; --i){\n\t\t\t\tsum += a[i];\n\t\t\t}\n\t\t}\n\n\t//}\n\tcout << sum;\n}\nint main(){\n\tproblemE();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "adb6abac4701b483dd807bb69f946aeb", "src_uid": "e7e0f9069166fe992abe6f0e19caa6a1", "difficulty": 2500.0}
    {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef long long ll;\nint d[1005][12];\nint dp[1005][105][2];\nint a[1005];\nint n,k,m;\nint sub(int x,int y)\n{\n    x-=y;\n    if(x<0)x+=m;\n    return x;\n}\n\nint main()\n{\n    scanf(\"%d%d%d\",&n,&k,&m);\n    if(m==1){\n        printf(\"0\\n\");\n        return 0;\n    }\n    int ans=0;a[0]=1;\n    for(int i=1;i<=n;i++)a[i]=(ll)a[i-1]*10%m;\n    if(k==1){\n        ans=sub(a[n],1);\n        printf(\"%d\\n\",ans);\n        return 0;\n    }\n    for(int j=1;j<10;j++){\n        int res=j;\n        for(int i=n;i>=1;i--){\n            d[i][j]=res%k;\n            res=(ll)res*10%k;\n        }\n    }\n    for(int i=0;i<10;i++)\n        dp[n][i%k]=(dp[n][i%k]+1)%m;\n    for(int i=n;i>=1;i--){\n        for(int j=1;j0)res=(ll)9*a[len-1]%m;\n        ans=(ans+(ll)res*sub(dp[i][0],1)%m)%m;\n    }\n    printf(\"%d\\n\",ans);\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "074c5eccecd67f66b5f062e55b2eb26a", "src_uid": "656bf8df1e79499aa2ab2c28712851f0", "difficulty": 2200.0}
    {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define yt eg[i].to\ntypedef __int64 LL; \nconst int N=1005;\nint dp[N][100],tn[N],tnn[N];\ninline void ff(int &x,int m){\n    if(x>=m) x-=m;\n}   \nint main(){\n    int n,i,j,k,l,r,p;\n    int t,x,y,m,w,ans;\n    while(~scanf(\"%d%d%d\",&n,&k,&m)){\n        for(tn[1]=1,i=2;i<=n;i++) tn[i]=tn[i-1]*10%k;\n        for(tnn[0]=i=1;i<=n;i++) tnn[i]=10LL*tnn[i-1]%m;\n        memset(dp,0,sizeof dp);\n        for(ans=i=0;i<10;i++) ff(dp[1][i%k]++);\n        if(n==1) ans=(dp[1][0]-1+m)%m;\n        else ans=(LL)(dp[1][0]-1)*tnn[n-2]%m*9%m;\n        for(dp[1][0]=1,i=2;i<=n;i++){\n            for(j=1;j<=k;j++){\n                if(!dp[i-1][j]) continue;\n                for(t=0;t<10;t++)\n                    ff(dp[i][(j+t*tn[i])%k]+=dp[i-1][j],m);\n            }\n            if(i\nusing namespace std;\n#define SZ(n) memset((n),0,sizeof(n))\n#define SMO(n) memset((n),-1,sizeof(n))\n#define MC(n,m) memcpy((n),(m),sizeof(n))\n#define F first\n#define S second\n#define MP make_pair\n#define PB push_back\n#define FOR(x,y) for(__typeof(y.begin())x=y.begin();x!=y.end();x++)\n#define ALL(x) x.begin(),x.end()\n#define IOS ios_base::sync_with_stdio(0);cin.tie(0)\n\ntypedef long long i64;\n\nconst int MK = 121;\nint N, K, M;\ni64 op[MK];\ni64 temp[MK];\n\niint main() {\n\n#define CL for(int __i=0; __i<=K; __i++) temp[__i]=0;\n#define CP for(int __i=0; __i<=K; __i++) op[__i]=temp[__i];\n\n    cin >> N >> K >> M;\n    for(int i=0; i<10; i++) {\n        op[i%K] ++;\n    }\n    op[K] = op[0] - 1;\n    op[0] = 1;\n    int nm = 10;\n    for(int i=1; i\n#include \n#include \n#include \nusing namespace std;\ntypedef pairPII;\ntypedef long long LL;\nLL dp[1111][102][2];\nLL N,K,MOD;\nint P[1111];\nLL dfs(int pos,int mod,int flag){\n    if(pos>N){\n        return flag;\n    }\n    if(~dp[pos][mod][flag]){\n        return dp[pos][mod][flag];\n    }\n    LL ans=0;\n    int tmp=(N==pos);\n    for(int i=tmp;i<10;++i){\n        int p=(mod+i*P[pos-1])%K;\n        ans += dfs(pos+1,p,flag||(p==0&&i!=0));\n    }\n    ans%=MOD;\n    return ans;\n}\nint main( ){\n    ios::sync_with_stdio(false);\n    //cout<>N>>K>>MOD;\n    memset(dp,-1,sizeof(dp));\n    P[0]=1;\n    for(int i=1;i<1111;++i){\n        P[i]=P[i-1]*10%K;\n    }\n    cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n// #include\n#include \n#define __ ios_base::sync_with_stdio(false);cin.tie(NULL);\nusing namespace std;\n#define pb push_back\n#define mk make_pair\n#define pii pair\n#define fi first\n#define se second\n#define ll long long\n#define inrange(x,y,n,m) (x>=0 && y>=0 && x>n;\n    int su = 0;\n    for(int i=0;i<10;++i){\n        cin>>a[i];\n        su += a[i];\n    }\n    if(su>n){\n        puts(\"0\");\n        return 0;\n    }\n    ll ans = 0;\n    for(int len = su;len<=n;++len){\n        memset(dp,0,sizeof(dp));\n        for(int i = a[0];i<=len;++i){\n            dp[0][i] = c[len-1][i];\n        }\n        for(int i=1;i<=9;++i){\n            for(int j = a[i];j<=len;++j){\n                for(int k = 0;k+j<=len;++k){\n                    if(dp[i-1][k]){\n                        (dp[i][k+j] += (dp[i-1][k]*c[len-k][j])) %= mod;\n                    }\n                }\n            }\n        }\n        (ans += dp[9][len]) %= mod;\n    }\n    cout<\n#include \n\n    const long long mod = 1000000007;\n\nint n;\nint a[16];\nlong long dp[128][16];\nlong long ch[128][128];\n\nvoid read() {\n    int i;\n    \n    scanf ( \"%d\" , &n );\n    for (i = 0; i < 10; i++) {\n        scanf ( \"%d\" , &a[i] );\n    }\n}\n\nlong long go ( int x , int y ) {\n    if ( y == 10 ) {\n        return !x;\n    }\n    long long &ans = dp[x][y];\n    if ( ans != -1 ) return ans;\n    \n    int i;\n    ans = 0;\n    \n    for (i = a[y]; i <= x; i++) {\n        ans += (go ( x - i , y + 1 ) * ch[x][i]) % mod;\n        ans %= mod;\n    }\n    \n    return ans;\n}\n\nvoid solve() {\n    int i , j;\n    int sum = 0;\n    long long ans = 0;\n    \n    for (i = 0; i <= 105; i++) {\n        ch[i][0] = ch[i][i] = 1;\n    }\n    \n    for (i = 2; i <= 105; i++) {\n        for (j = 1; j < i; j++) {\n            ch[i][j] = (ch[i - 1][j] + ch[i - 1][j - 1]) % mod;\n        }\n    }\n    \n    for (i = 1; i < 10; i++) {\n        int o = a[i];\n        if ( a[i] ) -- a[i];\n        sum = 0;\n        \n        for (j = 0; j < 10; j++) {\n            sum += a[j];\n        }\n        \n        if ( sum > n - 1 ) {\n            a[i] = o;\n            continue;\n        }\n        \n        memset ( dp , -1 , sizeof dp );\n        for (j = n - 1; j >= 0; j--) {\n                    ans = (ans + go ( j , 0 ));\n        }\n\n        a[i] = o;\n    }\n    \n    printf ( \"%I64d\\n\" , ans );\n}\n\nint main() {\n    read();\n    solve();\n    \n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "846f8c54a15524a60f929a9825e07bc2", "src_uid": "c1b5169a5c3b1bd4a2f1df1069ee7755", "difficulty": 1900.0}
    {"lang": "GNU C++17", "source_code": "#include\n#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n#include \nusing namespace __gnu_pbds;\n#define lli long long int\n#define ulli unsigned long long int\n#define ff first\n#define ss second\n#define mp make_pair\n#define pb push_back\n#define pf pop_front()\n#define lb lower_bound\n#define ub upper_bound\n#define bs binary_search\n#define loopl(i,a,b) for(lli i=a;i\n#define vll vector\n#define eps 0.000001\n#define endl '\\n'\n\nusing namespace std ;\n\n#define MAXN 1000000\n/*lli spf[MAXN];  \nvoid sieve();\nset factors(lli x);\nlli power(lli x,lli y,lli p);\n*/\n//void getZarr(string str, lli Z[]);\n//vll prefix_function(string s); \n\ntypedef tree,rb_tree_tag,\ntree_order_statistics_node_update> indexed_set;\n\nlli ncr[101][101];\nlli dp[101][11];\n\nint main()\n\n{  \n\n//////////////////////////////////////////////\n    fastio;\n    #ifndef ONLINE_JUDGE\n        freopen(\"input.txt\", \"rt\", stdin);\n        freopen(\"output.txt\", \"wt\", stdout);\n    #endif\n//////////////////////////////////////////////\n\n    lli n;\n    cin>>n;\n\n    lli a[10];\n    loopl(i,0,10)\n    cin>>a[i];\n\n    ncr[0][0]=1;\n    \n    loopl(i,1,101)\n    {\n        loopl(j,1,i)\n            ncr[i][j]=(ncr[i-1][j-1]+ncr[i-1][j])%mod;\n        \n        ncr[i][i]=ncr[i][0]=1;\n    }\n\n\n    loopl(i,a[9],n+1)\n        dp[i][9]=1;\n\n    \n    for(lli j=8;j>0;j--)\n    {\n        for(lli i=a[j];i<=n;i++)\n        {\n            for(lli k=a[j];k<=i;k++)\n            {\n                dp[i][j]=(dp[i][j]+dp[i-k][j+1]*(ncr[i][k]))%mod;\n            }\n        }\n    }\n\n    for(lli j=a[0]+1;j<=n;j++)\n    {\n        for(lli k=a[0];k 0 && s[i] != s[j])\n            j = pi[j-1];\n        \n        if (s[i] == s[j])\n            j++;\n        \n        pi[i] = j;\n    }\n    return pi;\n}*/\n\n/*void sieve() \n{ \n    spf[1] = 1; \n    loopl(i,2,MAXN) \n        spf[i] = i; \n    for (lli i=4; i factors(lli x) \n{ \n    multiset pr; \n    while (x != 1) \n    { \n        pr.insert(spf[x]); \n        x = x / spf[x]; \n    } \n    return pr; \n}\n\n*/\n\n/*\nvoid dfs(lli q,lli root) \n{\n    vis[q]=1;\n    \n    ans[q]=1;\n\n    for(auto x: v[q])\n    {\n        if(!vis[x])\n        {\n            if(a[x]==a[root] && xa[root]+d) continue;\n            dfs(x,root);\n            ans[q]=(ans[q]*((ans[x]+1)%mod))%mod ;\n        }\n    }\n        \n}\n*/\n\n\n\n/*void getZarr(string str, lli Z[])\n{\n    lli n = str.length();\n    lli L, R, k;\n    L = R = 0;\n    for (lli i = 1; i < n; ++i){\n        if (i > R){\n            L = R = i;\n            while (R 0) \n    { \n        if (y & 1) \n            res = (res*x) % p; \n  \n        y = y>>1;  \n        x = (x*x) % p;   \n    } \n    return res; \n} \n*/  ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cb180ca97943da9a69e900cb6eb192eb", "src_uid": "c1b5169a5c3b1bd4a2f1df1069ee7755", "difficulty": 1900.0}
    {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\n#define mod 1000000007\n\nint gcd(int a,int b)                     \n{\n    int t;\n    while(b!=0)\n    {\n        t=a%b;\n        a=b;\n        b=t;\n    }\n    return a;\n}\n\n__int64 C(int n,int m)\n{\n    if(m==0)\n        return 1;\n    if(n==0)\n        return 1;\n    int a[1000];\n    for(int i=n;i>=n-m+1;i--)\n        a[n-i] = i;\n    for(int j=2;j<=m;j++)\n    {\n        int tmp = j;\n       for(int i=0;tmp!=1;i++)\n       {\n          int k = gcd(a[i],tmp);\n          a[i]/=k;\n          tmp/=k;\n       }\n    }\n    __int64 mul = a[0];\n    for(int i=1;i>n;\n    for(int i=0;i<10;i++)\n        cin>>a[9-i];\n    __int64 dp[101][10];\n    memset(dp,0,sizeof(dp));\n    int sum[10];\n    sum[0] = a[0];\n    for(int i=1;i<10;i++)\n        sum[i] = sum[i-1] + a[i];\n    for(int i=sum[0];i<=n;i++)\n        dp[i][0] = 1;\n    /*for(int i=1;i<9;i++)\n        dp[sum[i]][i] = dp[sum[i-1]][i-1]*C(sum[i-1]+1,a[i])%mod;\n    dp[sum[9]][9] = dp[sum[8]][8]*C(sum[8],a[8])%mod;*/\n\n    \n    for(int i=1;i<9;i++)\n        for(int j=sum[i];j<=n;j++)\n        {\n            dp[j][i] = 0;\n            for(int k=sum[i-1];j-k>=a[i];k++)\n                dp[j][i] += dp[k][i-1]*C(j,j-k)%mod;\n            dp[j][i] %= mod;\n        }\n    for(int j=sum[9];j<=n;j++)\n        {\n            if(j==0)\n                continue;\n            dp[j][9] = 0;\n            for(int k=sum[8];j-k>=a[9];k++)\n                dp[j][9] += dp[k][8]*C(j-1,j-k)%mod;\n            dp[j][9] %= mod;\n        }\n     __int64 ans = 0;\n     for(int i=sum[9]>0?sum[9]:1;i<=n;i++)\n         ans += dp[i][9];\n     printf(\"%I64d\\n\",ans%mod);\n    // system(\"pause\");\n     return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2a3c5b67c0c57eec7fee72512cbbfe99", "src_uid": "c1b5169a5c3b1bd4a2f1df1069ee7755", "difficulty": 1900.0}
    {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\n#define sim template < class c\n#define ris return * this\n#define dor > debug & operator <<\n#define eni(x) sim > typename \\\n  enable_if(0) x 1, debug&>::type operator<<(c i) {\nsim > struct rge { c b, e; };\nsim > rge range(c i, c j) { return {i, j}; }\nsim > auto dud(c* x) -> decltype(cerr << *x, 0);\nsim > char dud(...);\nstruct debug {\n#ifdef LOCAL\n~debug() { cerr << endl; }\neni(!=) cerr << boolalpha << i; ris; }\neni(==) ris << range(begin(i), end(i)); }\nsim, class b dor(pair < b, c > d) {\n  ris << \"(\" << d.first << \", \" << d.second << \")\";\n}\nsim dor(rge d) {\n  *this << \"[\";\n  for (c it = d.b; it != d.e; ++it)\n    *this << \", \" + 2 * (it == d.b) << *it;\n  ris << \"]\";\n}\n#else\nsim dor(const c&) { ris; }\n#endif\n};\n#define imie(x...) \" [\" #x \": \" << (x) << \"] \"\n\nusing ll = long long;\nusing pll = pair ;\n\nll n, l, r, k;\nll d;\nll wynik = -1;\nll inf = 1e18;\n\n#pragma GCC optimize(\"O3\");\n\nvoid ans(ll S) {\n\twynik = max(wynik, S);\n}\n\nvoid checkTriv(ll S) {\n\tif (S >= n && S <= 2 * n) {\n\t\tif (k % S == 0) ans(S - n);\n\t\tif (k % S == (S - 1) && S > n) ans(S - n);\n\t}\n}\n\npll przetnij(pll a, pll b) {\n\treturn {max(a.first, b.first), min(a.second, b.second)};\n}\nvoid checkInterval1(pll p, ll a, ll b) {\n\tp = przetnij(p, {-inf, (d - b) / a});\n\tp = przetnij(p, {-inf, (2 * d - 2 * n - b) / (a - 1)});\n\tp = przetnij(p, {(b - 2 * d - a - 1) / (-a), inf});\n\tp = przetnij(p, {(b + n - d - a) / (1 - a), inf});\n\t\n\tif (p.first <= p.second) ans(p.second - n);\n}\n\nvoid checkInterval2(pll p, ll a, ll b) {\n\tb++;\n\tp = przetnij(p, {-inf, (d + 1 - b) / a});\n\tp = przetnij(p, {-inf, (2 * d - 2 * n - b) / (a - 1)});\n\tp = przetnij(p, {(b - 2 * d - a - 1) / (-a), inf});\n\tp = przetnij(p, {(b + n - d - a) / (1 - a), inf});\n\tif (p.first <= p.second) ans(p.second - n);\n}\n\nvoid check(pll p, ll a, ll b) {\n\tcheckInterval1(przetnij(p, {n, 2 * n}), a, b);\n\tcheckInterval2(przetnij(p, {n, 2 * n}), a, b);\n}\n\nint main() {\n\tcin >> n >> l >> r >> k;\n\tif (l <= r) d = r - l + 1;\n\telse d = n + 1 - (l - r);\n\t\n\tif (n == d) {\n\t\tfor (ll x = 1; x * x <= k; ++x) {\n\t\t\tif (k % x == 0) {\n\t\t\t\tcheckTriv(x);\n\t\t\t\tcheckTriv(k / x);\n\t\t\t}\n\t\t}\n\t\tfor (ll x = 1; x * x <= k + 1; ++x) {\n\t\t\tif ((k + 1) % x == 0) {\n\t\t\t\tcheckTriv(x);\n\t\t\t\tcheckTriv((k + 1) / x);\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tll a = k;\n\t\tll b = k;\n\n\t\tfor(ll i = 2; i * i <= k; ++i)\n\t\t{\n\t\t\tb = k / i;\n\t\t\tll a1 = k % a;\n\t\t\tll an = k % (b + 1);\n\t\t\t\n\t\t\tif (a - b == 1) {\n\t\t\t\tcheck({a, a}, -1, (k % a) + a);\n\t\t\t}\n\t\t\telse {\n\t\t\t\n\t\t\tll pa = (a1 - an) / (a - b - 1);\n\t\t\tll pb = a1 - pa * a;\n\t\t\tcheck({b + 1, a}, pa, pb);\n\t\t\t}\n\t\t\ta = b;\n\t\t}\n\t\t\n\t\tfor(ll i = b; i >= 1; --i) {\n\t\t\tcheck({i, i}, -1, (k % i) + i);\n\t\t}\n\n\t\t\n\t}\n\t\n\tcout << wynik << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8ee0991bbe933bcd598d88284d30feee", "src_uid": "f54cc281033591315b037a400044f1cb", "difficulty": 2600.0}
    {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\n#define sim template < class c\n#define ris return * this\n#define dor > debug & operator <<\n#define eni(x) sim > typename \\\n  enable_if(0) x 1, debug&>::type operator<<(c i) {\nsim > struct rge { c b, e; };\nsim > rge range(c i, c j) { return {i, j}; }\nsim > auto dud(c* x) -> decltype(cerr << *x, 0);\nsim > char dud(...);\nstruct debug {\n#ifdef LOCAL\n~debug() { cerr << endl; }\neni(!=) cerr << boolalpha << i; ris; }\neni(==) ris << range(begin(i), end(i)); }\nsim, class b dor(pair < b, c > d) {\n  ris << \"(\" << d.first << \", \" << d.second << \")\";\n}\nsim dor(rge d) {\n  *this << \"[\";\n  for (c it = d.b; it != d.e; ++it)\n    *this << \", \" + 2 * (it == d.b) << *it;\n  ris << \"]\";\n}\n#else\nsim dor(const c&) { ris; }\n#endif\n};\n#define imie(x...) \" [\" #x \": \" << (x) << \"] \"\n\nusing ll = long long;\nusing pll = pair ;\n\nll n, l, r, k;\nll d;\nll wynik = -1;\nll inf = 1e18;\n\n#pragma GCC optimize(\"O3\");\n\nvoid ans(ll S) {\n\twynik = max(wynik, S);\n}\n\nvoid checkTriv(ll S) {\n\tif (S >= n && S <= 2 * n) {\n\t\tif (k % S == 0) ans(S - n);\n\t\tif (k % S == (S - 1) && S > n) ans(S - n);\n\t}\n}\n\npll przetnij(pll a, pll b) {\n\treturn {max(a.first, b.first), min(a.second, b.second)};\n}\nvoid checkInterval1(pll p, ll a, ll b) {\n\tp = przetnij(p, {-inf, (d - b) / a});\n\tp = przetnij(p, {-inf, (2 * d - 2 * n - b) / (a - 1)});\n\tp = przetnij(p, {(b - 2 * d - a - 1) / (-a), inf});\n\tp = przetnij(p, {(b + n - d - a) / (1 - a), inf});\n\t\n\tif (p.first <= p.second) ans(p.second - n);\n}\n\nvoid checkInterval2(pll p, ll a, ll b) {\n\tb++;\n\tp = przetnij(p, {-inf, (d + 1 - b) / a});\n\tp = przetnij(p, {-inf, (2 * d - 2 * n - b) / (a - 1)});\n\tp = przetnij(p, {(b - 2 * d - a - 1) / (-a), inf});\n\tp = przetnij(p, {(b + n - d - a) / (1 - a), inf});\n\tif (p.first <= p.second) ans(p.second - n);\n}\n\nvoid check(pll p, ll a, ll b) {\n\tcheckInterval1(przetnij(p, {n, 2 * n}), a, b);\n\tcheckInterval2(przetnij(p, {n, 2 * n}), a, b);\n}\n\nint main() {\n\tcin >> n >> l >> r >> k;\n\tif (l <= r) d = r - l + 1;\n\telse d = n + 1 - (l - r);\n\t\n\tif (n == d) {\n\t\tfor (ll x = 1; x * x <= k; ++x) {\n\t\t\tif (k % x == 0) {\n\t\t\t\tcheckTriv(x);\n\t\t\t\tcheckTriv(k / x);\n\t\t\t}\n\t\t}\n\t\tfor (ll x = 1; x * x <= k + 1; ++x) {\n\t\t\tif ((k + 1) % x == 0) {\n\t\t\t\tcheckTriv(x);\n\t\t\t\tcheckTriv((k + 1) / x);\n\t\t\t}\n\t\t}\n\t}\n\telse {\n\t\tll a = k;\n\t\tll b = k;\n\n\t\tfor(ll i = 2; i * i <= k; ++i)\n\t\t{\n\t\t\tb = k / i;\n\t\t\tll a1 = k % a;\n\t\t\tll an = k % (b + 1);\n\t\t\t\n\t\t\tif (a - b == 1) {\n\t\t\t\tcheck({a, a}, -1, (k % a) + a);\n\t\t\t}\n\t\t\telse {\n\t\t\t\n\t\t\tll pa = (a1 - an) / (a - b - 1);\n\t\t\tll pb = a1 - pa * a;\n\t\t\tcheck({b + 1, a}, pa, pb);\n\t\t\t}\n\t\t\ta = b;\n\t\t}\n\t\t\n\t\tfor(ll i = b; i >= 1; --i) {\n\t\t\tcheck({i, i}, -1, (k % i) + i);\n\t\t}\n\n\t\t\n\t\tfor (ll S = n; S <= 2 * n; ++S) {\n\t\t\tll a = -1;\n\t\t\tll b = (k % S) + S;\n\t\t\tcheck({S, S}, a, b);\n\t\t}\n\t}\n\t\n\tcout << wynik << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ed204e23322e4ac748cd239ce02aa7fa", "src_uid": "f54cc281033591315b037a400044f1cb", "difficulty": 2600.0}
    {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nusing lint = long long;\n\nint main() {\n    lint n, l, r, k, ans = -1\n    \n    cin >> n >> l >> r >> k;\n    lint x = (r + n - l + 1) % n;\n\n    for (lint i = k, nxt; i > 0; i = nxt) {\n        lint t = k / i;\n        lint upper = i;\n        lint lower = n;\n        nxt = k / (t + 1);\n\n        upper = min(upper, 2 * n);\n        upper = min(upper, (k - x) / t);\n        upper = min(upper, (2 * n - 2 * x + k + 1) / (t + 1));\n\n        lower = max(lower, nxt + 1);\n        lower = max(lower, (k - 2 * x + t - 1) / t);\n\n        if (upper >= lower) {\n            ans = max(ans, upper - n);\n            break;\n        }\n    }\n\n    if (x <= k && k < 2 * x) ans = max(ans, n - x + 1 + k - x);\n\n    if (k == 2 * x) ans = max(ans, n);\n\n    if (k == n) ans = max(ans, 1ll);\n\n    cout << ans << \"\\n\";\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8fa989c3c93b9e07ee8fecafb4d07151", "src_uid": "f54cc281033591315b037a400044f1cb", "difficulty": 2600.0}
    {"lang": "GNU C++17", "source_code": "#include \n\ntypedef long long ll;\n\nconst ll X = 2e5;\n\nint main() {\n    ll n, l, r, k;\n    scanf(\"%lld %lld %lld %lld\", &n, &l, &r, &k);\n    r = (r - l + 1 + n) % n;\n\n    ll ans = -1;\n    if (n <= X) {\n        for (ll i = n; i >= 0; i--) {\n            ll y = k % (n + i) - r;\n            if (y < 0 || y > r || y > i) {\n                continue;\n            }\n            ll y2 = y + 1;\n            if (y2 <= r && y2 <= i && y2 >= i + r - n) {\n                ans = i;\n                break;\n            }\n            if (y >= i + r - n) {\n                ans = i;\n                break;\n            }\n        }\n    } else {\n        for (ll i = 0; i <= k / n; i++) {\n            ll p = (k - (i - 1) * n - 2 * r) / (i + 1);\n            ll y = k - i * (n + p) - r;\n            ll d = (r + p - n - y - 1) / (i + 1) + 1;\n            y += x * d;\n            p -= d;\n            if (p > n) {\n                y += x * (p - n);\n                p = n;\n            }\n            if (y < 0 || y > r || y > p || p < 0) {\n                continue;\n            }\n            ll y2 = y + 1;\n            if (y >= 0 && y <= r && y <= p && y >= p + r - n) {\n                if (p > ans) {\n                    ans = p;\n                }\n            }\n            if (y2 >= 0 && y2 <= r && y2 <= p && y >= p + r - n) {\n                if (p > ans) {\n                    ans = p;\n                }\n            }\n        }\n    }\n\n    printf(\"%lld\\n\", ans);\n\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "04f18153400fde3e1a42fce3b31759e7", "src_uid": "f54cc281033591315b037a400044f1cb", "difficulty": 2600.0}
    {"lang": "GNU C++17", "source_code": "#pragma GCC diagnostic error \"-std=c++11\"\n#include \n#define inline inline __attribute__((always_inline))\nusing namespace std;\n\ntypedef long long LL;\nconst int N=23333;\nconst LL inf=1e18;\nstruct fdt {\n\tLL p,a;\n}f[N],mf[N];\nLL m,x,ans;\nint fn,mfn;\n\ninline LL qm(LL a,LL b,LL zqm){\n    /*LL res=(a*b-(LL)((double)a*b/zqm+0.1)*zqm)%zqm;\n    return res<0?res+zqm:res;*/\n    __int128 ret=a; ret*=b;\n    return LL(ret%zqm);\n}\n\ninline LL qp(LL a,LL b) {\n\tLL ret=1;\n\tfor(;b;b>>=1,a*=a) if(b&1) ret*=a;\n\treturn ret;\n}\n\ninline LL qp(LL a,LL b,LL zqm) {\n\tLL ret=1;\n\tfor(;b;b>>=1,a=qm(a,a,zqm)) if(b&1) ret=qm(ret,a,zqm);\n\treturn ret;\n}\n\ninline LL fazphi(LL x) {\n\tfn=0;\n\tLL ret=x;\n\tfor(int i=1;i<=mfn;++i) if(x%mf[i].p==0) {\n\t\tret=ret/mf[i].p*(mf[i].p-1);\n\t\tf[++fn].p=mf[i].p,f[fn].a=0;\n\t\twhile(x%mf[i].p==0) x/=mf[i].p,++f[fn].a;\n\t}\n\tif(x!=1) f[++fn].p=x,f[fn].a=1;\n\treturn ret;\n}\n\ninline void sqrfaz(LL x) {\n\tfor(LL i=2,sq=sqrt(x+1);i<=sq;++i) if(x%i==0) {\n\t\tf[++fn].p=i,f[fn].a=0;\n\t\twhile(x%i==0) x/=i,++f[fn].a;\n\t}\n\tif(x!=1) f[++fn].p=x,f[fn].a=1;\n}\n\ninline bool fdtcomp(const fdt &a,const fdt &b) {return a.p=1;--i) if(f[i].p==f[i-1].p||f[i].a==0) {\n\t\tf[i].p=inf;\n\t\tf[i-1].a+=f[i].a;\n\t}\n\tsort(f+1,f+fn+1,fdtcomp);\n\tfor(int i=1;i=0;--j) {\n\t\t\ttmp/=f[i].p;\n\t\t\tif(qp(x,tmp,d)==1) b=j;\n\t\t}\n\t\tord*=qp(f[i].p,b);\n\t}\n\t//printf(\"%lld %lld %lld\\n\",d,pd,ord);\n\tans+=pd/ord;\n}\n\nint main() {\n\tscanf(\"%lld%lld\",&m,&x);\n\tLL sqm=sqrt(m+1),tmp=m;\n\tfor(LL i=2;i<=sqm;++i) if(tmp%i==0) {\n\t\tmf[++mfn].p=i,mf[mfn].a=0;\n\t\twhile(tmp%i==0) tmp/=i,++mf[mfn].a;\n\t}\n\tif(tmp!=1) mf[++mfn].p=tmp,mf[mfn].a=1;\n\t\n\tfor(LL i=1;i<=sqm;++i) if(m%i==0) {\n\t\tsolve(i);\n\t\tif(m/i!=i) solve(m/i);\n\t}\n\tprintf(\"%lld\\n\",ans);\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f9d03b18b095c56f7b6227b7d8250a1a", "src_uid": "c2dd6de750812d6213c770b3587d8fcb", "difficulty": 2600.0}
    {"lang": "GNU C++11", "source_code": "#include\nusing namespace stdl;\nint main(){\n        cout<<1<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define N 1005\n#define ll long long\n#define ld long double\nll p[N],q[N],n,X,ans;int num,tot;\nll phi(ll x){ll ret=x;for(int i=1;i<=num;i++)if(!(x%p[i]))ret/=p[i],ret*=p[i]-1;return ret;}\n// ll q_mul(ll x,ll n,ll mod){if(n<2147483647&&x<2147483647)return n*x%mod;ll ret=0;for(;n;n>>=1,x=(x<<1)%mod)if(n&1)ret=(ret+x)%mod;return ret;}\nll q_mul(ll x,ll y,ll mod){return ((x*y-(ll)(((ld)x*y+0.5)/P)*P)%P+P)%P;}\nll q_pow(ll x,ll n,ll mod){ll ret=1;for(;n;n>>=1,x=q_mul(x,x,mod))if(n&1)ret=q_mul(ret,x,mod);return ret;}\nvoid work(ll g)\n{\n\tll mod=n/g,ph=phi(mod),x=X%mod,K=ph;\n\tfor(int i=1;i<=tot;i++)while(K%q[i]==0&&q_pow(x,K/q[i],mod)==1)K/=q[i];\n\tans+=ph/K;\n}\nvoid get_pri(ll x)\n{\n\tq[++tot]=x+1;\n\tfor(int i=2;i<=(x/i);i++)\n\t\tif(x%i==0){q[++tot]=i;while(x%i==0)x/=i;}\n\tif(x!=1)q[++tot]=x;\n}\nvoid init()\n{\n\tll x=n;\n\tfor(int i=2;i<=(x/i);i++)\n\t\tif(x%i==0){p[++num]=i;while(x%i==0)x/=i;}\n\tif(x!=1)p[++num]=x;\n\tfor(int i=1;i<=num;i++)get_pri(p[i]-1);\n\tsort(q+1,q+tot+1);tot=unique(q+1,q+tot+1)-q-1;\n}\nint main()\n{\n\tscanf(\"%lld%lld\",&n,&X);init();int i;\n\tfor(i=1;i<(n/i);i++)\n\t\tif(n%i==0)work(i),work(n/i);\n\tif(1ll*i*i==n)work(i);\n\tprintf(\"%lld\\n\",ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a82920d73e65ea037090548ab43edfd6", "src_uid": "c2dd6de750812d6213c770b3587d8fcb", "difficulty": 2600.0}
    {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nlong long gcd(long long x, long long y){return y?gcd(y, x%y):x;}\nlong long lcm(long long x, long long y){return x/gcd(x, y)*y;}\nvector  primeFactors;\nlong long etf(long long x){\n\tlong long etf=x;\n\tfor(auto i:primeFactors){\n\t\tif(x%i==0){\n\t\t\tetf=etf/i*(i-1);\n\t\t\tdo{\n\t\t\t\tx/=i;\n\t\t\t}while(x%i==0);\n\t\t}\n\t}\n\treturn etf;\n}\nlong long modex(long long b, long long e, long long m){\n\tlong long h=1;\n\twhile(e){\n\t\tif(e&1)h=(__int128_t)h*b%m;\n\t\tb=(__int128_t)b*b%m;\n\t\te>>=1;\n\t}\n\treturn h;\n}\nint main(){\n\tlong long m, x;\n\tscanf(\"%lld%lld\", &m, &x);\n\t{\n\t\tlong long M=m;\n\t\tfor(long long i = 2;i*i <= m;i ++){\n\t\t\tif(m%i==0){\n\t\t\t\tprimeFactors.push_back(i);\n\t\t\t\tdo{\n\t\t\t\t\tm/=i;\n\t\t\t\t}while(m%i==0);\n\t\t\t}\n\t\t}\n\t\tif(m>1){\n\t\t\tprimeFactors.push_back(m);\n\t\t}\n\t\tm=M;\n\t}\n\n\tvector  mfactors;\n\tfor(long long i = 1;i*i <= m;i ++){\n\t\tif(m%i==0){\n\t\t\tmfactors.push_back(i);\n\t\t\tmfactors.push_back(m/i);\n\t\t}\n\t}\n\tsort(mfactors.begin(), mfactors.end());\n\tmfactors.resize(unique(mfactors.begin(), mfactors.end())-mfactors.begin());\n\n\tvector  phifactors;\n\tlong long phi=etf(m);\n\tfor(long long i = 1;i*i <= phi;i ++){\n\t\tif(phi%i==0){\n\t\t\tphifactors.push_back(i);\n\t\t\tphifactors.push_back(phi/i);\n\t\t}\n\t}\n\tsort(phifactors.begin(), phifactors.end());\n\tphifactors.resize(unique(phifactors.begin(), phifactors.end())-phifactors.begin());\n\tlong long ans=1ll;\n\tfor(int i = 1;i < mfactors.size();i ++){\n\t\tlong long num=etf(mfactors[i]), den=0;\n\t\tfor(auto j:phifactors){\n\t\t\tif(num%j==0&&modex(x, j, mfactors[i])==1){\n\t\t\t\tden=j;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tans+=num/den;\n\t}\n\tprintf(\"%lld\\n\", ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "eb6c2374d0ee9e54a2641c4660ea0804", "src_uid": "c2dd6de750812d6213c770b3587d8fcb", "difficulty": 2600.0}
    {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nlong long pow2=1,ans=1;\nint main()\n{\n    int n,m;\n    cin>>n>>m;\n    for(int i=1;i<=m;i++){pow2=(pow2*2)%1000000009);}\n    for(int i=1;i<=n;i++){ans=(ans*(pow2-i))%1000000009;}\n    cout<\n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef LL __int64;\n\nconst int MAXN = 1000000 + 10;\nconst int MOD = 1000000009;\n\nLL Pow(LL a, LL b, LL c) {\n\tLL tmp = a, res = 1 % c;\n\twhile(b) {\n\t\tif(b & 1) {\n\t\t\tres = res * tmp % MOD;\n\t\t}\n\t\ttmp %= MOD;\n\t\ttmp <<= 1;\n\t\tb >>= 1;\n\n\t}\n\treturn res;\n}\n\nint main() {\n\t//freopen(\"in\", \"r\", stdin);\n\tint n, m, i;\n\tLL res, cnt;\n\twhile(scanf(\"%d%d\", &n, &m) != EOF) {\n\t\tres = Pow(2, m, MOD) - 1;\n\t\tcnt = res;\t\n\t\tfor( i=1; i<=n-1; i++ ) {\n\t\t\tres = res * ((cnt - i) % MOD) % MOD;\n\t\t}\n\t\tprintf(\"%I64d\\n\", res);\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5b8669ffb834a9081e210886e2516fec", "src_uid": "fef4d9c94a93fcf6d536f33503b1d4b8", "difficulty": 1300.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nconst\n int o = 1000000009;\n \nlong int bin (long int m)\n{\n     long int k=2, r=1;\n     while (m>1)\n     {\n           if (m % 2)\n           {\n                  r*=2;\n                  r%=o;\n                  m--;\n                  }\n           else\n           {\n               m/=2;\n               k*=k;\n               k%=o;\n               }\n               }               \n     return (r*k) % o;\n     }\n     \nint main ()\n{\n    //freopen (\"input.txt\", \"r\", stdin);\n    //freopen (\"output.txt\", \"w\", stdout);\n    long int n, m, p;\n    scanf (\"%d%d\", &n, &m);\n    p=bin (m);\n    if ((m<17) & (n>=p))\n    {\n              printf (\"%c\", '0');\n              return 0;     \n              }\n    if (p>n)\n    {\n            long long int q=1;\n            for (long int j=1; j<=n; j++)\n            {\n                q*=--p;\n                q%=o;\n            }\n            printf (\"%d\", q);\n            }\n    else printf (\"%c\", '0');\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bcb322eab05cf3b58a9fd550c8bbe673", "src_uid": "fef4d9c94a93fcf6d536f33503b1d4b8", "difficulty": 1300.0}
    {"lang": "GNU C++17", "source_code": "#include\n\nusing namespace std;\n\nconst int MOD = 998244353;\nconst int N = 5043;\n\nint add(int x, int y)\n{\n\tx += y;\n\twhile(x >= MOD) x -= MOD;\n\twhile(x < 0) x += MOD;\n\treturn x;\n}\n\nint mul(int x, int y)\n{\n\treturn (x * 1ll * y) % MOD;\n}\n\nint binpow(int x, int y)\n{\n\tint z = 1;\n\twhile(y > 0)\n\t{\n\t\tif(y % 2 == 1)\n\t\t\tz = mul(z, x);\n\t\tx = mul(x, x);\n\t\ty /= 2;\n\t}\n\treturn z;\n}\n\nint inv(int x)\n{\n\treturn binpow(x, MOD - 2);\n}\n\nint n, m, k;\n\nint dp[N][N];\n\nint main()\n{\n\tcin >> n >> m >> k;\n\tdp[0][0] = 1;\n\tfor(int i = 0; i < k; i++)\n\t\tfor(int j = 0; j < k; j++)\n\t\t{\n\t\t\tdp[i + 1][j] = add(dp[i + 1][j], mul(dp[i][j], j));\n\t\t\tdp[i + 1][j + 1] = add(dp[i + 1][j + 1], mul(dp[i][j], n - j));\n\t\t}\n\tint ans = 0;\n\tfor(int i = 1; i <= k; i++)\n\t\tans = add(ans, mul(dp[k][i], binpow(inv(m), i)));\n\tcout << ans << endl;\n}#include\n\nusing namespace std;\n\nconst int MOD = 998244353;\nconst int N = 5043;\n\nint add(int x, int y)\n{\n\tx += y;\n\twhile(x >= MOD) x -= MOD;\n\twhile(x < 0) x += MOD;\n\treturn x;\n}\n\nint mul(int x, int y)\n{\n\treturn (x * 1ll * y) % MOD;\n}\n\nint binpow(int x, int y)\n{\n\tint z = 1;\n\twhile(y > 0)\n\t{\n\t\tif(y % 2 == 1)\n\t\t\tz = mul(z, x);\n\t\tx = mul(x, x);\n\t\ty /= 2;\n\t}\n\treturn z;\n}\n\nint inv(int x)\n{\n\treturn binpow(x, MOD - 2);\n}\n\nint n, m, k;\n\nint dp[N][N];\n\nint main()\n{\n\tcin >> n >> m >> k;\n\tdp[0][0] = 1;\n\tfor(int i = 0; i < k; i++)\n\t\tfor(int j = 0; j < k; j++)\n\t\t{\n\t\t\tdp[i + 1][j] = add(dp[i + 1][j], mul(dp[i][j], j));\n\t\t\tdp[i + 1][j + 1] = add(dp[i + 1][j + 1], mul(dp[i][j], n - j));\n\t\t}\n\tint ans = 0;\n\tfor(int i = 1; i <= k; i++)\n\t\tans = add(ans, mul(dp[k][i], binpow(inv(m), i)));\n\tcout << ans << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "62ecaceee71b64a885d96893d004b6dc", "src_uid": "e6b3e559b5fd4e05adf9f1cd1b22126b", "difficulty": 2600.0}
    {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n#define int long long\n#define N 5005\nint n,m,k,dp[N][N]={{1}};\nconst int mod=998244353;\nint pown(int a,int b){\n\tint res=1,x=a%mod;\n\twhile(b)res=(b&1)?res*x%mod:res,x=x*x%mod,b>>=1;\n\treturn res;\n}\nsigned main(){\n\tscanf(\"%lld%lld%lld\",&n,&m,&k);\n    for(int i=1;i<=k;i++)\n        for(int j=1;j<=i;j++)\n            dp[i][j]=(dp[i-1][j]*j+dp[i-1][j-1]*(n-j+1))%mod;\n    int ans=0,cur=1,p=pown(m,mod-2);\n    for(int i=0;i<=k;i++)\n        ans=(ans+dp[k][i]*cur)%mod,cur=cur*p%mod;\n    printf(\"%lld\",ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3455e5048e8ae4d5b0799d99960c93e0", "src_uid": "e6b3e559b5fd4e05adf9f1cd1b22126b", "difficulty": 2600.0}
    {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \"competitive_helper.cpp\"\n\nusing namespace std;\n\nusing LL = long long;\nusing ULL = unsigned long long;\nusing PII = pair;\nusing PIL = pair;\nusing PLL = pair;\n// const int mod = 1e9 + 7;\nconst int mod = 998244353;\n\ninline void quickread() {\n    ios::sync_with_stdio(false);\n    cin.tie(nullptr);\n}\n\nint f[5010][5010];\nint n, m, k, p;\n\nint quickmul(int x, int y) {\n    int ret = 1, cur = x;\n    while (y) {\n        if (y & 1) {\n            ret = (LL)ret * cur % mod;\n        }\n        cur = (LL)cur * cur % mod;\n        y >>= 1;\n    }\n    return ret;\n}\n\nint dfs(int u, int v) {\n    // x^v * (px+1-p)^(n-v)\n    if (f[u][v] >= 0) {\n        return f[u][v];\n    }\n    if (u == 0) {\n        return 1;\n    }\n    if (v == 0) {\n        // x * d/dx (px+1-p)^n = np * x * (px+1-p)^(n-1)\n        return f[u][v] = (LL)n * p % mod * dfs(u - 1, 1) % mod;\n    }\n    else if (n - v == 0) {\n        // x * d/dx x^n = n * x^n\n        return f[u][v] = (LL)n * dfs(u - 1, n) % mod;\n    }\n    else {\n        // x * d/dx x^v * (px+1-p)^(n-v) = v * x^v * (px+1-p)^(n-v) + (n-v)p * x^(v+1) * (px+1-p)^(n-v-1)\n        return f[u][v] = ((LL)v * dfs(u - 1, v) % mod + (LL)(n - v) * p % mod * dfs(u - 1, v + 1) % mod) % mod;\n    }\n}\n\nint main() {\n    // freopen(\"input.txt\", \"r\", stdin);\n    quickread();\n    cin >> n >> m >> k;\n    p = quickmul(m, mod - 2);\n    memset(f, -1, sizeof(f));\n    cout << dfs(k, 0) << endl;\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "275335b5a5f1fb38f75c3d30c169816e", "src_uid": "e6b3e559b5fd4e05adf9f1cd1b22126b", "difficulty": 2600.0}
    {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n\ntypedef long long LL;\n\nconst int K = 5005, M = 998244353;\nint dp[K][K];\n\nLL power(LL a, LL p) {\n    LL ans = 1;\n    while (p) {\n        if (p&1)    ans = (ans * a)%M;\n        a = (a*a)%M;\n        p>>=1;\n    }\n    return ans;\n}\n\nint main() {\n    ios::sync_with_stdio(false);\n\n    cin.tie(0);\n    dp[0][0] = 1;\n\n    int n, m, k;\n    cin>>n>>m>>k;\n\n    for (int i=1; i<=k; i++) {\n        for (int j=0; j\nusing namespace std;\n\ntemplate  inline bool read (T &x) {\n\tx = 0; int f = 1; char c = getchar ();\n\tfor (; c != EOF && !isdigit (c); c = getchar ())\n\t\tif (c == '-') f = -1;\n\tif (c == EOF) return 0;\n\tfor (; c != EOF && c >= '0' && c <= '9'; c = getchar ())\n\t\tx = (x<<1) + (x<<3) + (c^48);\n\tx *= f; return 1;\n}\ntemplate \ninline bool read (T &x, Targs& ... args) {\n\treturn read (x) && read (args...); }\ntemplate  void print (T x) {\n\tif (x < 0) putchar ('-'), x = -x;\n\tif (x >= 10) print (x / 10);\n\tputchar (x % 10 + '0');\n}\n#define reint register int\n#define inl inline\n#define newl putchar('\\n')\ntypedef long long ll;\ntypedef __int128 lll;\ntypedef pair  pint;\n\nconstexpr int N = 1e7 + 10, L = 720720, K = 18, P = 998244353;\nint f[K][L], n, x, y, k, M, a[N], pown[K], ans, dimi, to;\n\ninl int fpow (int a, int b) {\n\tint res = 1;\n\tfor (; b; b >>= 1) {\n\t\tif (b & 1)\n\t\t\tres = 1ll * res * a % P;\n\t\ta = 1ll * a * a % P;\n\t}\n\treturn res;\n}\n\nint main () {\n\t/*  */\n\tread (n, a[0], x, y, k, M);\n\tfor (int i = 1; i < n; ++i)\n\t\ta[i] = (1ll * a[i - 1] * x + y) % M;\n\tfor (int i = 0; i <= k; ++i)\n\t\tpown[i] = fpow (n, i);\n\tfor (int i = 0; i < n; ++i)\n\t\t(ans += 1ll * k * pown[k - 1] % P * (a[i] / L * L) % P) %= P,\n\t\ta[i] %= L;\n\tfor (int i = 0; i < n; ++i) ++f[0][a[i]];\n\tfor (int kai = 0; kai < k - 1; ++kai)\n\t\tfor (int i = 0; i < L; ++i)\n\t\t\t(f[kai + 1][i] += 1ll * (n - 1) * f[kai][i] % P) %= P,\n\t\t\tto = i - i % (kai + 1),\n\t\t\t(f[kai + 1][to] += f[kai][i]) %= P;\n\tfor (int kai = 0; kai < k; ++kai)\t\t\n\t\tfor (int i = 0; i < L; ++i)\n\t\t\t(ans += 1ll * f[kai][i] * i % P * pown[k - kai - 1] % P) %= P;\n\tprint (ans);\n\n\treturn 0;\n}\n \t\t  \t\t  \t\t \t  \t  \t\t \t\t\t \t", "lang_cluster": "C++", "compilation_error": true, "code_uid": "19525b827303f32b08b3423fce3f6817", "src_uid": "1d45491e28d24e2b318605cd328d6ecf", "difficulty": 2800.0}
    {"lang": "GNU C++14", "source_code": "#include \r\nusing namespace std;\r\nconst int Mod = 998244353;\r\nint n, a[1100000], x, y, k, m;\r\nint f[2][1100000], pw[1100000];\r\n\r\nint main() {\r\n\tios::sync_with_stdio(false);\r\n\tcin.tie(0);\r\n\tcout.tie(0);\r\n\r\n\tcin >> n >> a[0] >> x >> y >> k >> m;\r\n\tfor (int i = 1; i < n; i++)\r\n\t\ta[i] = (1ll * a[i - 1] * x + y) % m;\r\n\r\n\tint lcm = 1, now = 0;\r\n\tpw[0] = 1;\r\n\tfor (int i = 1; i < k; i++)\r\n\t\tlcm = lcm / gcd(lcm, i) * i;\r\n\tfor (int i = 1; i < k; i++)\r\n\t\tpw[i] = 1ll * pw[i - 1] * n % Mod;\r\n\tint ans = 0;\r\n\tfor (int i = 0; i < n; i++)\r\n\t\tans = (ans + 1ll * (a[i] / lcm) * lcm % Mod * k % Mod * pw[k - 1]) % Mod, a[i] %= lcm;\r\n\tfor (int i = 0; i < n; i++)\r\n\t\tf[now][a[i]]++;\r\n\tfor (int j = 1; j <= k; j++) {\r\n\t\tnow ^= 1;\r\n\t\tfor (int i = 0; i < lcm; i++)\r\n\t\t\tf[now][i] = 0;\r\n\t\tfor (int i = 0; i < lcm; i++) {\r\n\t\t\tf[now][i] = (f[now][i] + 1ll * f[now ^ 1][i] * (n - 1)) % Mod;\r\n\t\t\tf[now][i - i % j] = (f[now][i - i % j] + f[now ^ 1][i]) % Mod;\r\n\t\t\tans = (ans + 1ll * f[now ^ 1][i] * i % Mod * pw[k - j]) % Mod;\r\n\t\t}\r\n\t}\r\n\tcout << ans << '\\n';\r\n\treturn 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e55871f28b0cecfd513acbb5f1e8194f", "src_uid": "1d45491e28d24e2b318605cd328d6ecf", "difficulty": 2800.0}
    {"lang": "GNU C++17", "source_code": "/*\n--------------              |   /\n      |                     |  /\n      |                     | /\n      |             *       |/          |    |         ------            *\n      |                     |           |    |        /      \\\n      |             |       |\\          |    |       |       |\\          |\n   \\  |             |       | \\         |    |       |       | \\         |\n    \\ |             |       |  \\        |    |        \\     /   \\        |\n     V              |       |   \\        \\__/|         -----     \\       |\n*/\n#include \nusing namespace std;\n#define debug(x) cerr << \"\\e[1;31m\" << #x << \" = \" << (x) << \"\\e[0m\\n\"\n#define print(x) emilia_mata_tenshi(#x, begin(x), end(x))\ntemplate void emilia_mata_tenshi(const char *s, T l, T r) {\n\tcerr << \"\\e[1;33m\" << s << \" = [\";\n\twhile(l != r) {\n\t\tcerr << *l;\n\t\tcerr << (++l == r ? ']' : ',');\n\t}\n\tcerr << \"\\e[0m\\n\";\n}\n\n#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);\nusing ll = int64_t;\nusing ull = uint64_t;\nusing ld = long double;\nusing uint = uint32_t;\nconst double EPS  = 1e-7;\nconst int INF     = 0x3F3F3F3F;\nconst ll LINF     = 4611686018427387903;\nconst int MOD     = 1e9+7;\nstatic int Lamy_is_cute = []() {\n\tEmiliaMyWife\n\treturn 48763;\n}();\n/*--------------------------------------------------------------------------------------*/\n\nconst int C = 12252240, mod = 998244353;\nll dp[C];\nsigned main() {\n\tint n, a, x, y, k, m;\n\tcin >> n >> a >> x >> y >> k >> m;\n\tll g = 1;\n\tfor(int i = k; i; i--) {\n\t\tfor(int j = C - 1; j; j--) {\n\t\t\tdp[j] = (n - 1) * dp[j] + 1 * dp[j - (j % i)] + j * g;\n\t\t\tdp[j] %= mod;\n\t\t}\n\t\tg = g * n % mod;\n\t}\n\tll tot = 0, tot2 = 0;\n\tfor(int i = 0; i < n; i++) {\n\t\ttot += dp[a % C];\n\t\ttot2 += a - a % c;\n\t\ta = (1LL * a * x + y) % m;\n\t}\n\ttot %= mod;\n\ttot2 %= mod;\n\tg = n;\n\tfor(int i = 0; i < k - 1; i++)\n\t\tg = g * 2 % mod;\n\tcout << (tot + tot2 * g) % mod << '\\n';\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8f8501b77b76f9953dc6be3cf88ca65f", "src_uid": "1d45491e28d24e2b318605cd328d6ecf", "difficulty": 2800.0}
    {"lang": "GNU C++20 (64)", "source_code": "#include\r\n#define int long long\r\nusing namespace std;\r\nint const M=800800,mod=998244353;\r\nint i,j,n,a0,x,y,k,m,now,las=1,lcm=1,Ans,Pow[22],dp[2][M];\r\nint read(){\r\n\tint x=0;char ch=getchar();\r\n\twhile (ch<'0'||ch>'9') ch=getchar();\r\n\twhile (ch>='0'&&ch<='9') x=x*10+ch-48,ch=getchar();\r\n\treturn x; \r\n}\r\nsigned main(){\r\n\tn=read();a0=read();x=read();y=read();k=read();m=read();\r\n\tfor (i=1;i<=k'';i++) lcm=lcm/__gcd(lcm,i)*i; \r\n\tfor (i=Pow[0]=1;i<=k;i++) Pow[i]=Pow[i-1]*n%mod;\r\n\tfor (i=1;i<=n;a0=(a0*x+y)%m,i++) \r\n\t\t(Ans+=Pow[k-1]*(a0/lcm*lcm)%mod*k%mod)%=mod,dp[0][a0%lcm]++;\r\n\tfor (i=1;i<=k;i++){now^=1;las^=1;\r\n\t\tmemset(dp[now],0,sizeof(dp[now]));\r\n\t\tfor (j=1;j\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef vector vi;\ntypedef vector vll;\ntypedef vector vvi;\ntypedef pair pii;\ntypedef vector vii;\ntypedef vector > > viii;\ntypedef pair pll;\ntypedef vector vs;\ntypedef vector vvii;\n\n#define pb push_back\n#define mp make_pair\n#define X first\n#define Y second\n#define MEM(a,b) memset(a,(b),sizeof(a))\n#define tr(c,it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)\n#define all(a) a.begin(),a.end()\n#define loop(x,a,b) for(int (x) = (a);(x)<(b);(x)++)\n#define rep(x,n)   for(int (x)=0;(x)<(n);(x)++)\n#define present(c,x) ((c).find(x) != (c).end()) \n#define cpresent(c,x) (find(all(c),x) != (c).end())\n#define ain(a,n) int ((a)[(n)]); for(int i=0; i<(n); i++) cin>>((a)[i])  \n#define md 1000000007\n#define MAXN 200005\n\nconst int FNCRLIMIT = MAXN;\nlong long fac[FNCRLIMIT], inf[FNCRLIMIT];\nlong long fncrmod = md;\n\nvoid fillncr()\n{\n  #ifdef MOD\n  fncrmod = MOD;\n  #endif\n\n  fac[0] = 1; inf[0] = 1;\n  \n  for(int i=1; i>n;\n    cout<<(md+ncr(2*n-1,n)-n)%md<<\"\\n\";\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f13ea7b472e8fe7400d53c1ec0f2229e", "src_uid": "13a9ffe5acaa79d97df88a069fc520b9", "difficulty": 1900.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main ()\n{\n\tint n;\n\tdouble a=1,b,c;\n\tlong long d;\n\tcin >> n;\n\tb=n+1;\n\tc=1;\n\tfor (int i=1; i\nusing namespace std;\n#define MOD 1000000007\n\nvoid extgcd(int a,int b,int &d,int &x,int &y)\n{\n\tif(!b)\n\t{\t\nd=a;\tx=1;\ty=0;\n\t}\n\telse\n\t{\nextgcd(b,a%b,d,y,x);\n\t\ty-=x*(a/b);\n\t}\n}\n\nint mod(int x,int n)\n{\n\treturn (x%n+n)%n;\n}\nint inv(int a,int n)\n{\n\tint d,x,y;\n\textgcd(a,n,d,x,y);\n\treturn d==1 ? mod(x,n) : -1;\n}\n\nlong long fact(int n)\n{\n\tint i;\n\tlong long res = 1;\n\tfor(i = 1;i <= n;i++)\n\t\tres = (i * res) % MOD;\n\treturn res;\n}\n\n// C(2n -1 , n);\nlong long cal(int n)\n{\n\tlong long res;\n\tres = fact(2 * n - 1);\n\tres = (res * inv(fact(n), MOD)) % MOD;\n\tres = (res * inv(fact(n - 1), MOD)) % MOD;\n\treturn res;\n}\n\nint main()\n{\n\tint n;\n\tlong long res;\n\tscanf(\"%d\", &n);\n\tres = cal(n);\n\tprintf(\"%I64d\\n\", 2 * res - n);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8340019304f71b0b6b7e876a3dc77be0", "src_uid": "13a9ffe5acaa79d97df88a069fc520b9", "difficulty": 1900.0}
    {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long LL;\n\n\ninline LL pow(LL x, LL y, LL mod)\n{\n\tLL ans = 1;\n\tfor(; y; y >>= 1, x = (x*x)%mod)\n\t\tif(y & 1)\n\t\t\tans = (ans*x) % mod;\n\treturn ans % mod;\n}\n\nconst LL mod = 1000000007;\nconst int maxn = 100005;\n\nLL fac[maxn<<1];\n\nint main()\n{\n\tLL n;\n\tcin>>n\n\tfac[0] = 1;\n\tfor(int i = 1; i <= (n<<1); ++i)\n\t\tfac[i] = fac[i-1] * i % mod;\n\tfout << (fac[n<<1]* pow(fac[n]*fac[n]%mod, mod-2, mod)) % mod - n << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "34558fe42d5caf2504243d708e0e2cae", "src_uid": "13a9ffe5acaa79d97df88a069fc520b9", "difficulty": 1900.0}
    {"lang": "GNU C++", "source_code": "\nprogram Round220_C;\n\nconst INF=100000000;\n MAXN=100500;\n\nvar tree:Array[1..4*MAXN]of record l,r,ls,rs,min1,min2:longint;end;\n a,b,apos:Array[1..MAXN]of longint;\n n,i,p1,p2,ans,tot:longint;\n\nfunction buildtree(l,r:longint):longint;\nvar mid,cur:longint;\nbegin\n inc(tot);\n cur:=tot;\n tree[cur].l:=l; tree[cur].r:=r;\n tree[cur].min1:=INF;\n tree[cur].min2:=INF;\n if (l=r) then exit(cur);\n mid:=(l+r)shr 1;\n tree[cur].ls:=buildtree(l,mid);\n tree[cur].rs:=buildtree(mid+1,r);\n    exit(cur);\nend;\n\nprocedure addtree(x,l,r,cul,v:longint);\nvar mid:longint;\nbegin\n if (l>2) then exit;\n if (l<=tree[x].l)and(tree[x].r<=r) then begin\n  if (cul=1)and(v\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef long long Int;\n#define FOR(i,a,b) for(int i=a;i<=b;++i)\n#define sz(s) (int)s.size()\n#define pb push_back\n#define mp make_pair\n#define sqr(x) (x)*(x)\nconst int inf=1000000000;\nconst int MOD=1000000007;\nconst double pi=2*acos(0.0);\nconst double eps=1e-12;\nint dx[]={1,0,-1,0};\nint dy[]={0,1,0,-1};\n\n\nint gcd(int x,int y)\n{\n    while(x){y%=x;swap(x,y);}\n    return y;\n}\n\ninline void add(int &x,int y)\n{\n    x+=y;\n    if(x>=MOD)x-=MOD;\n}\ninline void subt(int &x,int y)\n{\n    x=x+MOD-y;\n    if(x>=MOD)x-=MOD;\n}\n\nint C[4002][4];\nint cnt[2][2];\n\nint main()\n{\n    //freopen(\"input.txt\",\"r\",stdin);\n    //freopen(\"output.txt\",\"w\",stdout);\n    int n,m;\n    cin>>n>>m;\n    \n\n    FOR(i,0,4001)\n    FOR(j,0,3)\n        if(i==j || j==0)C[i][j]=1;else C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;\n    \n    memset(cnt,0,sizeof(cnt));\n    FOR(i,0,n)FOR(j,0,m)cnt[i%2][j%2]++;\n\n    int ans=0;\n    FOR(x1,0,1)\n    FOR(x2,0,1)\n    FOR(x3,0,1)\n    FOR(y1,0,1)\n    FOR(y2,0,1)\n    FOR(y3,0,1)\n    if(2*x1+y1>=2*x2+y2 && 2*x2+y2>=2*x3+y3)\n    {\n        int d=(x2-x1)*(y3-y1)-(y2-y1)*(x3-x1);\n        if(abs(d)%2==0)\n        \n            int tmp=1;\n            tmp=tmp*(Int)cnt[x1][y1];tmp%=MOD;cnt[x1][y1]--;\n            tmp=tmp*(Int)cnt[x2][y2];tmp%=MOD;cnt[x2][y2]--;\n            tmp=tmp*(Int)cnt[x3][y3];tmp%=MOD;cnt[x3][y3]--;\n\n            add(ans,tmp);\n            cnt[x1][y1]++;\n            cnt[x2][y2]++;\n            cnt[x3][y3]++;\n        }\n    }\n    \n    FOR(i,0,n)subt(ans,(6LL*C[m+1][3])%MOD);\n    FOR(i,0,m)subt(ans,(6LL*C[n+1][3])%MOD);\n\n    FOR(dx,1,n)\n    FOR(dy,1,m)\n    {\n        int g=gcd(dx,dy);\n        int tmp=(Int(n+1-dx)*(m+1-dy))%MOD;\n        tmp=(tmp*Int(g-1))%MOD;\n        tmp=(tmp*12LL)%MOD;\n        subt(ans,tmp);\n    }\n\n    cout<\n#include \n#include \n#include \n\n#define FOR(a,b,c) for(int a=(b),_for=(c);a<_for;++a)\n#define END(a) {printf (\"%d \",a);return 0;}\n#define ll long long\n#define ull unsigned long long\n#define lf double\n#define x first\n#define y second\n#define pb push_back\n#define mp make_pair\n#define pii pair < int, int >\n\nusing namespace std;\n\nconst int MAXN = 4000;\nconst int MOD = 1000000007;\nconst int INF = ((1<<31)-1);\n\nll x,y;\n\nll sol;\n\nll cnt[3][3];\nint GCD[MAXN+5][MAXN+5];\n\nbool p(pii a,pii b,pii c){\n\treturn abs(a.x*(b.y-c.y)+b.x*(c.y-a.y)+c.x*(a.y-b.y))%2;\n}\n\nll f(int bm){\n\tll ret=1;\n\tret=ret*cnt[!!(bm&8)][!!(bm&1)]%MOD;\n\tret=ret*cnt[!!(bm&16)][!!(bm&2)]%MOD;\n\tret=ret*cnt[!!(bm&32)][!!(bm&4)]%MOD;\n\treturn ret;\n}\n\nint gcd(int a,int b){\n\tif (GCD[a][b]) return GCD[a][b];\n\tif (!a) return GCD[a][b]=b;\n\treturn GCD[a][b]=gcd(b,a%b);\n}\n\nint main(){\n\tscanf (\"%I64d%I64d\",&x,&y);\n\tFOR(i,0,x+1)\n\t\tFOR(j,0,y+1)\n\t\t\tcnt[i&1][j&1]++;\n\tFOR(bm,0,1<<6){\n\t\tpii a,b,c;\n\t\tc=mp(!!(bm&8),!!(bm&1));\n\t\tb=mp(!!(bm&16),!!(bm&2));\n\t\ta=mp(!!(bm&32),!!(bm&4));\n\t\tif (!p(a,b,c))\n\t\t\tsol=(sol+f(bm))%MOD;\n\t}\n\tsol-=(x+1)*(y+1);\n\tsol-=3ll*(x+1)*(y+1)*((x+1)*(y+1)-1)%MOD;\n\tFOR(i,0,x+2)\n\t\tFOR(j,0,y+2)\n\t\t\tGCD[i][j]=gcd(i,j);\n\tFOR(dx,0,x+1)\n\t\tFOR(dy,dx?-y:1,y+1){\n\t\t\tif (!dx && !dy) continue;\n\t\t\tll num = GCD[dx][abs(dy)]-1;\n\t\t\tsol = (sol - 6*num*(x-abs(dx)+1)*(y-abs(dy)+1))%MOD;\n\t\t}\n\tsol = (sol+MOD)%MOD;\n\tprintf (\"%I64d\",sol);\n\t\n\t\n\t\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6087ddea4fd5d4dab63da0bff7e05b17", "src_uid": "984788e4b4925c15c9c6f31e42f2f8fa", "difficulty": 2500.0}
    {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\ntypedef long long LL;\nconst LL Mod=1000000007;\nconst LL MAX=10000+10;\n\nLL w,h;\nLL sum[MAX],g[MAX][MAX],f[MAX][MAX];\n\nLL gcd(LL a,LL b)\n{\n\tif(!b)return a;\n\treturn gcd(b,a%b);\n}\n\nLL chaji(LL a,LL b,LL c,LL d,LL e,LL f)\n{\n\treturn (c-a)*(f-b)-(e-a)*(d-b);\n}\n\nint main()\n{\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\",\"r\",stdin);freopen(\"output.txt\",\"w\",stdout);\n#endif\n\tLL i,j,k,a,b,c,ans=0;\n\tcin>>w>>h;\n\tfor(i=0;i<=w;++i)\n\t\tfor(j=0;j<=h;++j)\n\t\t\t++sum[(i%2)*2+(j%2)];\n\tfor(i=0;i<4;++i)\n\t\tfor(j=0;j<4;++j)\n\t\t\tfor(k=0;k<4;++k)\n\t\t\t{\n\t\t\t\tif((chaji(i/2,i%2,j/2,j%2,k/2,k%2))%2==0)\n\t\t\t\t{\n\t\t\t\t\ta=sum[i];b=sum[j];c=sum[k];\n\t\t\t\t\tif(i==j && j==k)\n\t\t\t\t\t\tb-=1,c-=2;\n\t\t\t\t\telse if(i==j)\n\t\t\t\t\t\t--b;\n\t\t\t\t\telse if(i==k)\n\t\t\t\t\t\t--c;\n\t\t\t\t\telse if(k==j)\n\t\t\t\t\t\t--c;\n\t\t\t\t\tans=(ans+a*b%Mod*c%Mod)%Mod;\n\t\t\t\t}\n\t\t\t}\n\tfor(i=1;i<=w;++i)\n\t\tfor(j=1;j<=h;++j)\n\t\t{\n\t\t\tLL p=gcd(i,j)-1;\n\t\t\tg[i][j]=(g[i-1][j]+g[i][j-1]+Mod-g[i-1][j-1] + (p>0)*p *6 )%Mod;\n\t\t\tf[i][j]=(f[i][j-1]+f[i-1][j]-f[i-1][j-1]+Mod+g[i][j]*2)%Mod;\n\t\t}\n//\tcout<=3)\n\t\tans=(ans+Mod-(w+1)*w%Mod*(w-1)%Mod*(h+1)%Mod)%Mod;\n\tif(h+1>=3)\n\t\tans=(ans+Mod-(h+1)*h%Mod*(h-1)%Mod*(w+1)%Mod)%Mod;\n\tcout<\n#include \n#include \n#include \nusing namespace std;\n\nint main() {\n    int bit = 1 << 20, n;\n    string s;\n    cin >> n;\n    for(int i = 20; i > 0; --i) {\n        if(n & bit) {\n            s += std::to_string(i);\n            s += \" \";\n        }\n        bit = bit >> 1;\n    }\n    cout << s;\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e5685efe64970756855174b020a3786a", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0}
    {"lang": "MS C++", "source_code": "#include \n#include \n\nvoid main()\n{\n    std::vector res;\n    res.reserve(100);\n    int n;\n    std::cin >> n;\n    for (; n > 0; --n) {\n        res.push_back(1);\n        while (res.size() > 1 && *(res.end() - 1) == *(res.end() - 2)) {\n            *(res.end() - 2) += 1;\n            res.pop_back();\n        }\n    }\n    char* d = \"\";\n    for (int v : res) {\n        std::cout << d << v;\n        d = \" \";\n    }\n    std::cout << std::endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4868daa61244ae9398870eb53d08c7a0", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0}
    {"lang": "GNU C++", "source_code": "// Bismillahirrahmanirrahim\n// AgriCoder IPB\n#include \n\nusing namespace std;\n\n#define FOR(i, agri, coder) for (int i = (int)agri; i <= (int)coder; i++)\n#define REP(agri,coder) for (int agri = 0; agri < (int)coder; agri++)\n#define FOREACH(i,agricoder) for (typeof((agricoder).end()) i = (agricoder).begin(); i != (agricoder).end(); ++i)\n#define RESET(agri,coder) memset(agri, coder, sizeof(agri))\n#define pb push_back\n#define mp make_pair\n#define EPS 1e-9\n#define INF 0x3F3F3F3F\n#define NL printf(\"\\n----------------------------\\n\")\n\ntypedef long long ll;\ntypedef unsigned long long ULL;\ntypedef pair ii;\ntypedef vector vi;\ntypedef vector vii;\ntypedef pair PLL;\n\nint arahbar[8] = {0,1,0,-1,1,1,-1,-1};\nint arahkol[8] = {1,0,-1,0,1,-1,-1,1};\nint kudabar[8] = {-2,-1,1,2, 2,1 , -1 ,-2};\nint kudakol[8] = {1 ,2 ,2,1,-1,-2 , -2,-1};\n\ntemplate\nT getNum() {\n   T res=0;\n   char c;\n   while(1)\n   {\n      c=getchar_unlocked();\n      if(c==' ' || c=='\\n') continue;\n      else break;\n   }\n   bool negatif;\n   if (c=='-') {\n       negatif = true;\n       res = 0;\n   }\n   else {\n       res=c-'0';\n       negatif = false;\n   }\n   while(1)\n   {\n      c=getchar_unlocked();\n      if('0'<=c && c<='9') res=10*res + c-'0';\n      else break;\n   }\n   if (negatif) res*=-1;\n   return res;\n}\n\n// ================================  TEMPLATE ENDS HERE ================================================== //\n\n#define MAXN 100005\n\nvector arr;\n\nint main() {\n//  freopen(\"in.in\",\"r\",stdin);\n\tint n = getNum();\n\tREP(i,n){\n\t\tarr.pb(1);\n\t\tif(arr.size()>1){\n\t\t\twhile(arr.size()>1){\n\t\t\t\tint len = arr.size();\n\t\t\t\tif(arr[len-1]==arr[len-2]){\n\t\t\t\t\tarr[len-2] ++;\n\t\t\t\t\tarr.pop_back();\n\t\t\t\t}else break;\n\t\t\t}\n\t\t}\n\t}\n\n\tprintf(\"%d\", arr[0]);\n\tFOR(i,1,arr.size()-1){\n\t\tprintf(\" %d\", arr[i]);\n\t}\n\tprintf(\"\\n\");\n\treturn 0;\n}\n\n// Alhamdulillahirabbilalamin", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7c6d689abc91bc68fa523b32cee2d8a8", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0}
    {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n\tint n;\n\tcin>> n;\n\n\tstring s;\n\twhile(n >= 2)\n\t{\n\t\ts += (n % 2) + '0';\n\t\tn /= 2;\n\t}\n\ts += n + '0';\n\n\tint y = 1 << ((int)s.size() - 1);\n\n\treverse(s.begin(), s.end());\n\tfor(int i = 0; i < s.size(); i ++)\n\t{\n\t\tif(s[i] == '1')\n\t\t\tcout<< y << \" \";\n\t\ty /= 2;\n\t}\n\n\tcout<< endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b103dc09e47645f6a7cc88756bcc39e9", "src_uid": "757cd804aba01dc4bc108cb0722f68dc", "difficulty": 800.0}
    {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n\n#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)\n#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)\n#define REP(i,a) for(int i=0,_a=(a); i<_a; i++)\n#define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)\n\n#define DEBUG(x) { cout << #x << \" = \"; cout << (x) << endl; }\n#define PR(a,n) { cout << #a << \" = \"; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }\n#define PR0(a,n) { cout << #a << \" = \"; REP(_,n) cout << a[_] << ' '; cout << endl; }\n\n#define sqr(x) ((x) * (x))\nusing namespace std;\n\nstruct Edge {\n    int u, v, c, f;\n    int next;\n};\n\nstruct MaxFlow {\n    int n, s, t;\n    vector< Edge > edges;\n    vector head, current, h, avail;\n    vector excess;\n\n    MaxFlow(int n) : n(n), head(n, -1), current(n, -1), h(n), avail(n), excess(n) {\n        edges.clear();\n    }\n\n    void addEdge(int u, int v, int c, bool bi = false) {\n        Edge xuoi = {u, v, c, 0, head[u]};\n        head[u] = edges.size(); edges.push_back(xuoi);\n        Edge nguoc = {v, u, bi ? c : 0, 0, head[v]};\n        head[v] = edges.size(); edges.push_back(nguoc);\n    }\n\n    long long getFlow(int _s, int _t) {\n        s = _s; t = _t;\n        init();\n\n        int now = 0;\n        queue qu[2];\n        REP(x,n)\n            if (x != s && x != t && excess[x] > 0)\n                qu[now].push(x);\n        \n        globalLabeling();\n\n        int cnt = 0;\n        while (!qu[now].empty()) {\n            while (!qu[1-now].empty()) qu[1-now].pop();\n\n            while (!qu[now].empty()) {\n                int x = qu[now].front(); qu[now].pop();\n                while (current[x] >= 0) {\n                    int p = current[x];\n                    if (edges[p].c > edges[p].f && h[edges[p].u] > h[edges[p].v]) {\n                        bool need = (edges[p].v != s && edges[p].v != t && !excess[edges[p].v]);\n                        push(current[x]);\n                        if (need) qu[1-now].push(edges[p].v);\n                        if (!excess[x]) break;\n                    }\n                    current[x] = edges[current[x]].next;\n                }\n                \n                if (excess[x] > 0) {\n                    lift(x);\n                    current[x] = head[x];\n                    qu[1-now].push(x);\n                    cnt++;\n                    if (cnt == n) {\n                        globalLabeling();\n                        cnt=0;\n                    }\n                }\n            }\n            now = 1 - now;\n        }\n        return excess[t];\n    }\n\nprivate:\n    void init() {\n        REP(i,n) current[i] = head[i];\n\n        int p = head[s];\n        while (p >= 0) {\n            edges[p].f = edges[p].c;\n            edges[p^1].f -= edges[p].c;\n            excess[edges[p].v] += edges[p].c;\n            excess[s] -= edges[p].c;\n            p = edges[p].next;\n        }\n        FOR(v,0,n-1) h[v] = 1;\n        h[s] = n; h[t] = 0;\n    }\n\n    void push(int i) {\n        long long delta = min(excess[edges[i].u], (long long) edges[i].c - edges[i].f);\n        edges[i].f += delta; edges[i^1].f -= delta;\n        excess[edges[i].u] -= delta;\n        excess[edges[i].v] += delta;\n    }\n\n    void lift(int u) {\n        int minH = 2 * n;\n        int p = head[u];\n        while (p>=0) {\n            if (edges[p].c > edges[p].f)\n                minH = min(minH, h[edges[p].v]);\n            p = edges[p].next;\n        }\n        h[u] = minH + 1;\n    }\n\n    void globalLabeling() {\n        REP(i,n) avail[i] = 1, h[i] = 0;\n        h[s] = n; h[t] = 0;\n        queue q; q.push(t); avail[t] = false;\n\n        while (!q.empty()) {\n            int x = q.front(); q.pop();\n            int p = head[x];\n            while (p >= 0) {\n                int pp = p^1;\n                if (avail[edges[pp].u] && edges[pp].f < edges[pp].c) {\n                    h[edges[pp].u] = h[x] + 1;\n                    avail[edges[pp].u] = 0;\n                    q.push(edges[pp].u);\n                }\n                p = edges[p].next;\n            }\n            if (q.empty() && avail[s]) {\n                avail[s] = false;\n                q.push(s);\n            }\n        }\n        REP(x,n) current[x] = head[x];\n    }\n};\n\nconst int di[] = {-1,1,0,0};\nconst int dj[] = {0,0,-1,1};\n\nint n, t, startx, starty;\nchar scientistMap[22][22], locationMap[22][22];\nint d[22][22][22][22];\n\nvoid bfs(int turn, int u, int v) {\n    int curu = u, curv = v;\n    queue qu, qv;\n    qu.push(u); qv.push(v);\n    d[u][v][u][v] = 0;\n\n    while (!qu.empty()) {\n        u = qu.front(); qu.pop();\n        v = qv.front(); qv.pop();\n\n        REP(dir,4) {\n            int uu = u + di[dir], vv = v + dj[dir];\n            if (uu < 1 || uu > n || vv < 1 || vv > n || locationMap[uu][vv] == 'Y') continue;\n            if (d[curu][curv][uu][vv] >= 0) continue;\n\n            if (turn && d[startx][starty][uu][vv] >= 0 && d[curu][curv][u][v] + 1 > d[startx][starty][uu][vv]) continue;\n\n            if (turn && d[startx][starty][uu][vv] >= 0 && d[curu][curv][u][v] + 1 == d[startx][starty][uu][vv]) {\n                if (locationMap[uu][vv] >= '1' && locationMap[uu][vv] <= '9') {\n                    d[curu][curv][uu][vv] = d[curu][curv][u][v] + 1;\n                    continue;\n                }\n                continue;\n            }\n\n            d[curu][curv][uu][vv] = d[curu][curv][u][v] + 1;\n            qu.push(uu);\n            qv.push(vv);\n        }\n    }\n}\n\nint id[22][22];\n\nint main() {\n    while (cin >> n >> t) {\n        FOR(i,1,n) FOR(j,1,n) cin >> scientistMap[i][j];\n        FOR(i,1,n) FOR(j,1,n) cin >> locationMap[i][j];\n        memset(d, -1, sizeof d);\n\n        FOR(i,1,n) FOR(j,1,n) if (locationMap[i][j] == 'Z') {\n            startx = i;\n            starty = j;\n            bfs(0, i, j);\n        }\n\n        int cur = 0;\n        FOR(i,1,n) FOR(j,1,n) id[i][j] = ++cur;\n\n        MaxFlow flow(n*n+2);\n        FOR(i,1,n) FOR(j,1,n) {\n            if (scientistMap[i][j] >= '1' && scientistMap[i][j] <= '9')\n                flow.addEdge(0, id[i][j], scientistMap[i][j] - '0');\n            if (locationMap[i][j] >= '1' && locationMap[i][j] <= '9')\n                flow.addEdge(id[i][j], n*n+1, locationMap[i][j] - '0');\n        }\n\n        FOR(i,1,n) FOR(j,1,n) if (scientistMap[i][j] >= '1' && scientistMap[i][j] <= '9') {\n            bfs(1, i, j);\n\n            FOR(u,1,n) FOR(v,1,n) if (locationMap[u][v] >= '1' && locationMap[u][v] <= '9')\n                if (d[i][j][u][v] >= 0 && d[i][j][u][v] <= t) {\n                    flow.addEdge(id[i][j], id[u][v], min(locationMap[u][v] - '0', scientistMap[i][j] - '0'));\n                }\n        }\n        cout << flow.getMaxFlow(0, n*n+1) << endl;\n    }\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "887354da2ec57b995af3b5db8ca7efb6", "src_uid": "544de9c3729a35eb08c143b1cb9ee085", "difficulty": 2300.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nstruct node{\n    int r,c,t;\n    \n    node(){}\n    \n    node(int _r, int _c, int _t){\n        r = _r; c = _c; t = _t;\n    }\n}cur;\n\nstruct flow_graph{\n    int MAX_V,E,s,t,head,tail;\n    int *cap,*to,*next,*last,*dist,*q,*now;\n    \n    flow_graph(){}\n    \n    flow_graph(int V, int MAX_E){\n        MAX_V = V; E = 0;\n        cap = new int[2*MAX_E], to = new int[2*MAX_E], next = new int[2*MAX_E];\n        last = new int[MAX_V], q = new int[MAX_V];\n        dist = new int[MAX_V], now = new int[MAX_V];\n        fill(last,last+MAX_V,-1);\n    }\n    \n    void add_edge(int u, int v, int uv){\n        if(uv > 0){\n            to[E] = v, cap[E] = uv, next[E] = last[u]; last[u] = E++;\n            to[E] = u, cap[E] = 0, next[E] = last[v]; last[v] = E++;\n        }\n    }\n    \n    bool bfs(){\n        fill(dist,dist+MAX_V,-1);\n        head = tail = 0;\n        \n        q[tail] = t; ++tail;\n        dist[t] = 0;\n        \n        while(head0 && dist[to[e]]==-1){\n                    q[tail] = to[e]; ++tail;\n                    dist[to[e]] = dist[v]+1;\n                }\n            }\n        }\n        \n        return dist[s]!=-1;\n    }\n    \n    int dfs(int v, int f){\n        if(v==t) return f;\n        \n        for(int &e = now[v];e!=-1;e = next[e]){\n            if(cap[e]>0 && dist[to[e]]==dist[v]-1){\n                int ret = dfs(to[e],min(f,cap[e]));\n                \n                if(ret>0){\n                    cap[e] -= ret;\n                    cap[e^1] += ret;\n                    return ret;\n                }\n            }\n        }\n        \n        return 0;\n    }\n    \n    int max_flow(int source, int sink){\n        s = source; t = sink;\n        int f = 0,df;\n        \n        while(bfs()){\n            for(int i = 0;i < MAX_V;++i) now[i] = last[i];\n            \n            while(true){\n                df = dfs(s,INT_MAX);\n                if(df==0) break;\n                f += df;\n            }\n        }\n        \n        return f;\n    }\n}G(2 + 10 * 10 * 62,10 * 10 * (4 * 60  + 6));\n\nint main(){\n    int n,t;\n    \n    scanf(\"%d %d\",&n,&t);\n    \n    char M1[n][n],M2[n][n];\n    \n    for(int i = 0;i < n;++i) scanf(\"%s\",M1[i]);\n    for(int i = 0;i < n;++i) scanf(\"%s\",M2[i]);\n    \n    int sr = 0,sc = 0;\n    int dist[n][n];\n    memset(dist,-1,sizeof(dist));\n    \n    for(int i = 0;i < n;++i)\n        for(int j = 0;j < n;++j)\n            if(M1[i][j] == 'Z')\n                sr = i,sc = j;\n    \n    int dr[] = {-1,1,0,0};\n    int dc[] = {0,0,-1,1};\n    int r2,c2;\n    \n    queue Q;\n    Q.push(node(sr,sc,0));\n    dist[sr][sc] = 0;\n    \n    while(!Q.empty()){\n        cur = Q.front();\n        Q.pop();\n        \n        for(int i = 0;i < 4;++i){\n            r2 = cur.r + dr[i];\n            c2 = cur.c + dc[i];\n            \n            if(r2 >= 0 && r2 < n && c2 >= 0 && c2 < n && dist[r2][c2] == -1 && M1[r2][c2] != 'Y' && M1[r2][c2] != 'Z'){\n                dist[r2][c2] = dist[cur.r][cur.c] + 1;\n                Q.push(node(r2,c2,cur.t + 1));\n            }\n        }\n    }\n    \n    for(int i = 0;i < n;++i){\n        for(int j = 0;j < n;++j){\n            if(M1[i][j] >= '0' && M1[i][j] <= '9'){\n                G.add_edge(0,1 + i * n + j,M1[i][j] - '0');\n                G.add_edge(1 + (t + 1) * n * n + i * n + j,1 + (t + 2) * n * n,M2[i][j] - '0');\n            }\n        }\n    }\n    \n    for(int i = 0;i <= t;++i){\n        for(int j = 0;j < n;++j){\n            for(int k = 0;k < n;++k){\n                if((dist[j][k] == -1 || dist[j][k] >= i) && M1[j][k] >= '0' && M1[j][k] <= '9'){\n                    G.add_edge(1 + i * n * n + j * n + k, 1 + (t + 1) * n * n + j * n + k,M2[j][k] - '0');\n                    \n                    if(i < t && (dist[j][k] == -1 || dist[j][k] > i)){\n                        for(int d = 0;d < 4;++d){\n                            r2 = j + dr[d];\n                            c2 = k + dc[d];\n                            \n                            if(M1[r2][c2] >= '0' && M1[r2][c2] <= '9' && (dist[r2][c2] == -1 || dist[r2][c2] >= i + 1))\n                                G.add_edge(1 + i * n * n + j * n + k,1 + (i + 1) * n * n + r2 * n + c2,900);\n                        }\n                    }\n                }\n            }\n        }\n    }\n    \n    printf(\"%d\\n\",G.max_flow(0,1 + n * n * (t + 2)));\n    \n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "324cb991812b642dfae37420e3705dc7", "src_uid": "544de9c3729a35eb08c143b1cb9ee085", "difficulty": 2300.0}
    {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef vector vi;\ntypedef pair ii;\ntypedef long long ll;\n#define mset(a,b) memset(a,b,sizeof a)\n#define pb push_back\n#define mp make_pair\ntypedef vector vll;\nnamespace dinic{\n    struct edge{\n        int to, rev, f, cap;\n        edge(){}\n        edge(int _t, int _r, int _f, int _c):to(_t), rev(_r), f(_f), cap(_c){}\n    };\n    const int maxn = 500;\n    int nodes = maxn, src, des, dist[maxn], q[maxn], work[maxn];\n    vector g[maxn];\n    void play(){\n        for(int e = 0; e < maxn; e++) g[e].clear();\n    }\n    void addEdge(int s, int t, int cap, int dir = 0){\n        edge a = {t, (int)g[t].size(), 0, cap};\n        edge b = {s, (int)g[s].size(), 0, dir};\n        g[s].push_back(a);\n        g[t].push_back(b);\n    }\n    bool bfs(){\n        memset(dist, -1, sizeof dist);\n        dist[src] = 0;\n        int qt = 0;\n        q[qt++] = src;\n        for(int e = 0; e < qt; e++){\n            int u = q[e];\n            for(edge &v:g[u]){\n                if(dist[v.to] < 0 && v.f < v.cap){\n                    dist[v.to] = dist[u] + 1;\n                    q[qt++] = v.to;\n                }\n            }\n        }\n        return dist[des] != -1;\n    }\n    int dfs(int u, int f){\n        if(u == des) return f;\n        for(int &i = work[u]; i < g[u].size(); i++){\n            edge &e = g[u][i];\n            if(e.cap <= e.f) continue;\n            int v = e.to;\n            if(dist[v] == dist[u]+1){\n                int df = dfs(v, min(f, e.cap - e.f));\n                if(df > 0){\n                    e.f += df;\n                    g[v][e.rev].f -= df;\n                    return df;\n                }\n            }\n        }\n        return 0;\n    }\n    ll flow(int _src, int _des){\n        src = _src;\n        des = _des;\n        ll ans = 0;\n        while(bfs()){\n            memset(work, 0, sizeof work);\n            while(int delta = dfs(src, (1<<30)))\n                ans += delta;\n        }\n        return ans;\n    }\n};\nusing namespace dinic;\nconst int maxn2 = 11;\nchar scien[maxn2][maxn2], capsu[maxn2][maxn2];\nint infected[maxn2][maxn2], run[maxn2][maxn2];\nint dx[] = {0, 0, 1, -1};\nint dy[] = {1, -1, 0, 0};\nint main(){\n    int n, t; cin >> n >> t;\n    for(int e = 0; e < n; e++) for(int f = 0; f < n; f++) cin >> scien[e][f];\n    for(int e = 0; e < n; e++) for(int f = 0; f < n; f++) cin >> capsu[e][f];\n    int ax, ay;\n    for(int e = 0; e < n; e++) for(int f = 0; f < n; f++)\n        if(scien[e][f] == 'Z') ax = e, ay = f;\n    {\n        queue q; q.push(mp(ax, ay));\n        mset(infected, -1);\n        infected[ax][ay] = 0;\n        while(!q.empty()){\n            ii cur = q.front(); q.pop();\n            for(int e = 0; e < 4; e++){\n                ii next = mp(cur.first + dx[e], cur.second + dy[e]);\n                if(next.first < 0 || next.first == n || next.second < 0 || next.second == n) continue;\n                if(infected[next.first][next.second] == -1 && scien[next.first][next.second] != 'Y')\n                    infected[next.first][next.second] = infected[cur.first][cur.second] + 1,\n                    q.push(next);\n            }\n        }\n    }\n    for(int e = 0; e < n; e++) for(int f = 0; f < n; f++) if(infected[e][f] == -1) infected[e][f] = 1<<20;\n    int src = 3*(n+1)*(n+1), des = src+1;\n    for(int e = 0; e < n; e++) for(int f = 0; f < n; f++) if(isnumber(scien[e][f]) && scien[e][f] != '0'){\n        // printf(\"(%d, %d)\\n\", e, f);\n        addEdge(src, e*n + f, scien[e][f] - '0');\n        queue q; q.push(mp(e, f));\n        mset(run, -1); run[e][f] = 0;\n        while(!q.empty()){\n            ii cur = q.front(); q.pop();\n            for(int g = 0; g < 4; g++){\n                ii next = mp(cur.first + dx[g], cur.second + dy[g]);\n                if(next.first < 0 || next.first == n || next.second < 0 || next.second == n) continue;\n                if(run[next.first][next.second] == -1\n                && isnumber(scien[next.first][next.second])\n                && run[cur.first][cur.second]+1 <= t){\n                    if(infected[next.first][next.second] > run[cur.first][cur.second]+1){\n                        run[next.first][next.second] = run[cur.first][cur.second]+1;\n                        q.push(next);\n                    }\n                    if(infected[next.first][next.second] >= run[cur.first][cur.second]+1\n                    && isnumber(capsu[next.first][next.second]) && capsu[next.first][next.second] != '0'){\n                        addEdge(e*n+f, n*n + (next.first*n + next.second), 1<<20, 1<<20);\n                        // printf(\"(%d, %d) -> (%d, %d)\\n\", e, f, next.first, next.second);\n                    }\n                }\n            }\n        }\n    }\n    for(int e = 0; e < n; e++) for(int f = 0; f < n; f++) if(isnumber(capsu[e][f]) && capsu[e][f] != '0')\n        addEdge(n*n + (e*n + f), des, capsu[e][f] - '0');\n    cout << flow(src, des) << endl;\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "20a35cd368f013c3045896ac404472a3", "src_uid": "544de9c3729a35eb08c143b1cb9ee085", "difficulty": 2300.0}
    {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef vector vi;\ntypedef pair ii;\ntypedef long long ll;\n#define mset(a,b) memset(a,b,sizeof a)\n#define pb push_back\n#define mp make_pair\ntypedef vector vll;\nnamespace dinic{\n    struct edge{\n        int to, rev, f, cap;\n        edge(){}\n        edge(int _t, int _r, int _f, int _c):to(_t), rev(_r), f(_f), cap(_c){}\n    };\n    const int maxn = 500;\n    int nodes = maxn, src, des, dist[maxn], q[maxn], work[maxn];\n    vector g[maxn];\n    void play(){\n        for(int e = 0; e < maxn; e++) g[e].clear();\n    }\n    void addEdge(int s, int t, int cap, int dir = 0){\n        edge a = {t, (int)g[t].size(), 0, cap};\n        edge b = {s, (int)g[s].size(), 0, dir};\n        g[s].push_back(a);\n        g[t].push_back(b);\n    }\n    bool bfs(){\n        memset(dist, -1, sizeof dist);\n        dist[src] = 0;\n        int qt = 0;\n        q[qt++] = src;\n        for(int e = 0; e < qt; e++){\n            int u = q[e];\n            for(edge &v:g[u]){\n                if(dist[v.to] < 0 && v.f < v.cap){\n                    dist[v.to] = dist[u] + 1;\n                    q[qt++] = v.to;\n                }\n            }\n        }\n        return dist[des] != -1;\n    }\n    int dfs(int u, int f){\n        if(u == des) return f;\n        for(int &i = work[u]; i < g[u].size(); i++){\n            edge &e = g[u][i];\n            if(e.cap <= e.f) continue;\n            int v = e.to;\n            if(dist[v] == dist[u]+1){\n                int df = dfs(v, min(f, e.cap - e.f));\n                if(df > 0){\n                    e.f += df;\n                    g[v][e.rev].f -= df;\n                    return df;\n                }\n            }\n        }\n        return 0;\n    }\n    ll flow(int _src, int _des){\n        src = _src;\n        des = _des;\n        ll ans = 0;\n        while(bfs()){\n            memset(work, 0, sizeof work);\n            while(int delta = dfs(src, (1<<30)))\n                ans += delta;\n        }\n        return ans;\n    }\n};\nusing namespace dinic;\nconst int maxn2 = 11;\nchar scien[maxn2][maxn2], capsu[maxn2][maxn2];\nint infected[maxn2][maxn2], run[maxn2][maxn2];\nint dx[] = {0, 0, 1, -1};\nint dy[] = {1, -1, 0, 0};\nint main(){\n    int n, t; cin >> n >> t;\n    for(int e = 0; e < n; e++) for(int f = 0; f < n; f++) cin >> scien[e][f];\n    for(int e = 0; e < n; e++) for(int f = 0; f < n; f++) cin >> capsu[e][f];\n    int ax, ay;\n    for(int e = 0; e < n; e++) for(int f = 0; f < n; f++)\n        if(scien[e][f] == 'Z') ax = e, ay = f;\n    {\n        queue q; q.push(mp(ax, ay));\n        mset(infected, -1);\n        infected[ax][ay] = 0;\n        while(!q.empty()){\n            ii cur = q.front(); q.pop();\n            for(int e = 0; e < 4; e++){\n                ii next = mp(cur.first + dx[e], cur.second + dy[e]);\n                if(next.first < 0 || next.first == n || next.second < 0 || next.second == n) continue;\n                if(infected[next.first][next.second] == -1 && scien[next.first][next.second] != 'Y')\n                    infected[next.first][next.second] = infected[cur.first][cur.second] + 1,\n                    q.push(next);\n            }\n        }\n    }\n    for(int e = 0; e < n; e++) for(int f = 0; f < n; f++) if(infected[e][f] == -1) infected[e][f] = 1<<20;\n    int src = 3*(n+1)*(n+1), des = src+1;\n    for(int e = 0; e < n; e++) for(int f = 0; f < n; f++) if(isnumber(scien[e][f]) && scien[e][f] != '0'){\n        // printf(\"(%d, %d)\\n\", e, f);\n        addEdge(src, e*n + f, scien[e][f] - '0');\n        queue q; q.push(mp(e, f));\n        mset(run, -1); run[e][f] = 0;\n        while(!q.empty()){\n            ii cur = q.front(); q.pop();\n            for(int g = 0; g < 4; g++){\n                ii next = mp(cur.first + dx[g], cur.second + dy[g]);\n                if(next.first < 0 || next.first == n || next.second < 0 || next.second == n) continue;\n                if(run[next.first][next.second] == -1\n                && isnumber(scien[next.first][next.second])\n                && run[cur.first][cur.second]+1 <= t){\n                    if(infected[next.first][next.second] > run[cur.first][cur.second]+1){\n                        run[next.first][next.second] = run[cur.first][cur.second]+1;\n                        q.push(next);\n                    }\n                    if(infected[next.first][next.second] >= run[cur.first][cur.second]+1\n                    && isnumber(capsu[next.first][next.second]) && capsu[next.first][next.second] != '0'){\n                        addEdge(e*n+f, n*n + (next.first*n + next.second), 1<<20, 1<<20);\n                        // printf(\"(%d, %d) -> (%d, %d)\\n\", e, f, next.first, next.second);\n                    }\n                }\n            }\n        }\n    }\n    for(int e = 0; e < n; e++) for(int f = 0; f < n; f++) if(isnumber(capsu[e][f]) && capsu[e][f] != '0')\n        addEdge(n*n + (e*n + f), des, capsu[e][f] - '0');\n    cout << flow(src, des) << endl;\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "49bc505476cbb31dd1507b1598b9acc4", "src_uid": "544de9c3729a35eb08c143b1cb9ee085", "difficulty": 2300.0}
    {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\n#define ms(s, n) memset(s, n, sizeof(s))\n#define FOR(i, a, b) for (int i = (a); i < (b); i++)\n#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)\n#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)\n#define sz(a) int((a).size())\n#define present(t, x) (t.find(x) != t.end())\n#define all(a) (a).begin(), (a).end()\n#define uni(a) (a).erase(unique(all(a)), (a).end())\n#define pb push_back\n#define pf push_front\n#define mp make_pair\n#define fi first\n#define se second\n#define prec(n) fixed<> (i)) & 1)\n#define bitcount(n) __builtin_popcountll(n)\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef pair pi;\ntypedef vector vi;\ntypedef vector vii;\nconst int MOD = (int) 1e9 + 7;\nconst int INF = (int) 1e9;\nconst ll LINF = (ll) 1e18;\nconst ld PI = acos((ld) -1);\nconst ld EPS = 1e-9;\ninline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}\ninline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}\ninline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}\ntemplate inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}\ntemplate inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}\ninline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}\ninline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}\ninline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}\ninline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}\ninline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}\ninline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}\ninline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}\ninline int sign(ld x, ld y) {return sign(x - y);}\n#define db(x) cout << #x << \" = \" << (x) << \"\\n\";\n\nconst int maxn = 75 + 1;\nint n;\nstring s;\nint nV, nK, nX;\nint posV[maxn];\nint posK[maxn];\nint posX[maxn];\nint dp[maxn][maxn][maxn][3];\n\nint calc(int V, int K, int X, int lst) {\n\tif (V + K + X == n) return 0;\n\tint& res = dp[V][K][X][lst];\n\tif (~res) return res;\n\tres = INF;\n\tif (V < nV) {\n\t\tint cost = max(0LL, upper_bound(posK, posK + nK, posV[V]) - posK - K);\n\t\tcost += max(0LL, upper_bound(posX, posX + nX, posV[V]) - posX - X);\n\t\tchkmin(res, calc(V + 1, K, X, 0) + cost);\n\t}\n\tif (K < nK && lst) {\n\t\tint cost = max(0LL, upper_bound(posV, posV + nV, posK[K]) - posV - V);\n\t\tcost += max(0LL, upper_bound(posX, posX + nX, posK[K]) - posX - X);\n\t\tchkmin(res, calc(V, K + 1, X, 1) + cost);\n\t}\n\tif (X < nX) {\n\t\tint cost = max(0LL, upper_bound(posV, posV + nV, posX[X]) - posV - V);\n\t\tcost += max(0LL, upper_bound(posK, posK + nK, posX[X]) - posK - K);\n\t\tchkmin(res, calc(V, K, X + 1, 2) + cost);\n\t}\n\treturn res;\n}\n\nvoid solve() {\n\tcin >> n >> s;\n\tFOR(i, 0, n) {\n\t\tif (s[i] == 'V') {\n\t\t\tposV[nV++] = i;\n\t\t}\n\t\telse if (s[i] == 'K') {\n\t\t\tposK[nK++] = i;\n\t\t}\n\t\telse {\n\t\t\tposX[nX++] = i;\n\t\t}\n\t}\n\tms(dp, -1);\n\tcout << calc(0, 0, 0, 2) << \"\\n\";\n}\n\nint main() {\n\tios_base::sync_with_stdio(0); //cin.tie(0);\n#ifdef _LOCAL_\n\tfreopen(\"in.txt\", \"r\", stdin); //freopen(\"out.txt\", \"w\", stdout);\n#endif\n\tsolve();\n#ifdef _LOCAL_\n\t//printf(\"\\nTime elapsed: %dms\", 1000 * clock() / CLOCKS_PER_SEC);\n#endif\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b3ccfcfa9edf04e3e72f5c23bca99e43", "src_uid": "08444f9ab1718270b5ade46852b155d7", "difficulty": 2500.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long LL;\ntypedef vector < int > VI;\ntypedef pair < int,int > II;\ntypedef vector < II > VII;\nconst int MOD = 1e9+7;\ninline int mult(int a , int b) { LL x = a; x *= LL(b); if(x >= MOD) x %= MOD; return x; }\ninline int add(int a , int b) { return a + b >= MOD ? a + b - MOD : a + b; }\ninline int sub(int a , int b) { return a - b < 0 ? MOD - b + a : a - b; }\nLL powmod(LL a,LL b) { if(b==0)return 1; LL x=powmod(a,b/2); LL y=(x*x)%MOD; if(b%2) return (a*y)%MOD; return y%MOD; }\n\nconst int inf = 1e9 + 7;\nstring s;\nint n;\nint dp[80][80][80][2];\nint getV(int cur, int nv, int nk, int nx) {\n  int ck = 0, cv = 0, cx = 0;\n  for(int i = 0; i < n; i ++) {\n    if(cv == nv && s[i] == 'V') {\n      int extra = max(0,nk-ck) + max(0,nx-cx);\n      return extra + i - cur;\n    }\n    if(s[i] == 'K')\n      ck ++;\n    else if(s[i] == 'V')\n      cv ++;\n    else\n      cx ++;\n  }\n  return inf;\n}\nint getK(int cur, int nv, int nk, int nx) {\n  int ck = 0, cv = 0, cx = 0;\n  for(int i = 0; i < n; i ++) {\n    if(ck == nk && s[i] == 'K') {\n      int extra = max(0,nv-cv) + max(0,nx-cx);\n      return extra + i - cur;\n    }\n    if(s[i] == 'K')\n      ck ++;\n    else if(s[i] == 'V')\n      cv ++;\n    else\n      cx ++;\n  }\n  return inf;\n}\nint getX(int cur, int nv, int nk, int nx) {\n  int ck = 0, cv = 0, cx = 0;\n  for(int i = 0; i < n; i ++) {\n    if(cx == nx && (s[i] != 'V' && s[i] != 'K')) {\n      int extra = max(0,nk-ck) + max(0,nv-cv);\n      return extra + i - cur;\n    }\n    if(s[i] == 'K')\n      ck ++;\n    else if(s[i] == 'V')\n      cv ++;\n    else\n      cx ++;\n  }\n  return inf;\n}\nint go(int nv, int nk, int nx, bool isv) {\n  if(nv + nk + nx == n) return 0;\n  if(dp[nv][nk][nx][isv] != -1)\n    return dp[nv][nk][nx][isv];\n  int ret = inf;\n  int cur = nv + nk + nx;\n  ret = min(ret, go(nv+1, nk, nx, 1) + getV(cur, nv, nk, nx));\n  ret = min(ret, go(nv, nk, nx+1, 0) + getX(cur, nv, nk, nx));\n  if(!isv)\n    ret = min(ret, go(nv, nk+1, nx, 0) + getK(cur, nv, nk, nx));\n  return dp[nv][nk][nx][isv] = ret;\n}\nint main() {\n  memset(dp,-1,sizeof(dp));\n  cin >> n;\n  cin >> s;\n  cout << go(0,0,0,0) << endl;\n  return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e1082a6a4a12232027f6ed6c10928a03", "src_uid": "08444f9ab1718270b5ade46852b155d7", "difficulty": 2500.0}
    {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n#define REP(i,j,k) for(register int (i)=(j);(i)<(k);++(i))\n\nstruct pfx{int s[3];};\nint operator-(pfx x,pfx y){\n\tint ret=0;\n\tREP(i,0,3)ret+=max(0LL,x.s[i]-y.s[i]);\n\treturn ret;\n}\n\nconst int maxn=80;\nconst int inf=1ll<<50;\nint n,dp[maxn][maxn][maxn][3];\nchar s[maxn],t[maxn];\npfx vkx[3][maxn];\n\ninline void MIN(int&x,int y){x=min(x,y);}\n\nmain(){\n\tcin.tie(0),cout.tie(0),ios_base::sync_with_stdio(false);\n\tcin>>n;\n\tpfx tt;tt.s[0]=tt.s[1]=tt.s[2]=0;\n\tREP(i,0,n){\n\t\tchar c;int x;\n\t\tcin>>c,x=(c=='V'?0:c=='K'?1:2);\n\t\t++tt.s[x],vkx[x][tt.s[x]]=tt;\n\t}\n\tREP(v,0,n+1)REP(k,0,n+1)REP(x,0,n+1)REP(i,0,3)dp[v][k][x][i]=inf;\n\tdp[0][0][0][2]=0;\n\tREP(v,0,n)REP(k,0,n)REP(x,0,n){\n\t\tif(v+k+x>=n)continue;\n\t\tREP(i,0,3)REP(j,0,3)if(!(i==0&&j==1)){\n\t\t\tpfx nn;nn.s[0]=v+(j==0),nn.s[1]=k+(j==1),nn.s[2]=x+(j==2);\n\t\t\tif(nn.s[0]>tt.s[0]||nn.s[1]>tt.s[1]||nn.s[2]>tt.s[2])continue;\n\t\t\tMIN(dp[nn.s[0]][nn.s[1]][nn.s[2]][j],dp[v][k][x][i]+(nn-vkx[j][nn.s[j]]));\n\t\t}\n\t}\n\tint mn=inf;\n\tREP(i,0,3)mn=min(mn,dp[tt.s[0]][tt.s[1]][tt.s[2]][i]);\n\tcout<\nusing namespace std;\nmt19937 rng(chrono::system_clock::now().time_since_epoch().count());\nmt19937_64 rngll(rng());\ntypedef long long ll;\ntypedef pairpii;\ntypedef pairpil;\ntypedef pairpll;\nconst int mn=1e6+10;\nconst ll mod=1e9+7;\nvectorv[3];\nll dp[76][76][76][3];\nint sub(int a,int b,int c,int x){\n    return min(lower_bound(v[0].begin(),v[0].end(),x)-v[0].begin(),(long)a)+\n            min(lower_bound(v[1].begin(),v[1].end(),x)-v[1].begin(),(long)b)+\n            min(lower_bound(v[2].begin(),v[2].end(),x)-v[2].begin(),(long)c);\n}\nint main(){\n    int n;\n    cin>>n;\n    string s;\n    cin>>s;\n    for(int i=0;i\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nset st;\nint tab[6][6]= {{1,5,4,6,2,3}  , {3,4,5,2,6,1} , {6,1,4,3,2,5} , {5,3,4,1,2,6} , {2,1,6,3,5,4},{4,1,5,3,6,2}};\nint L;\nvector vec[24];\nvector s;\nbool check()\n    {\n        vector tmp;\n        for(int i = 0 ; i< L;i++)\n            {\n                string is = \"HHHHHH\";\n                for(int j = 0 ; j< 6;j++)\n                    is[j] = s[vec[i][j] -1];\n                //for(int j = 0 ; j < 6;j++)\n                //    printf(\"%d \",vec[i][j]);\n                //puts(\"\");\n               // cout << i << \" : \" << is  < 0) return false;\n                //st.insert(is);\n                tmp.push_back(is);\n            }\n        for(int i = 0 ; i< tmp.size() ;i++)\n            st.insert(tmp[i]);\n        return true;\n    }\nint main()\n    {\n        for(int i = 0 ;i<6 ; i++)\n            {\n                for(int k = 1;k<5;k++)\n                    {\n                        vec[L].push_back(tab[i][0]);\n                        for(int j = 0 ,p = k; j < 4 ;j++ ,p++)\n                            vec[L] . push_back(tab[i][(p-1)%4+1]);\n                        vec[L].push_back(tab[i][5]);\n                        L++;\n                    }\n\n            }\n        //for(int i = 0; i > ts;\n        int ans = 0;\n\n        for(int i = 0 ; i <6;i++) s.push_back(ts[i]);sort\uff08s.begin(),s.end());\n        do\n            {\n                if(check()) ans++;\n            }while(next_permutation(s.begin(),s.end()));\n        cout << ans << endl;\n        return 0;\n    }\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e0ca189fb328d15b0ebd414cf76fc88b", "src_uid": "8176c709c774fa87ca0e45a5a502a409", "difficulty": 1700.0}
    {"lang": "GNU C++14", "source_code": "#include     \n\nusing namespace std;\n\nint tab[6];\nstring s;\n\nint main()\n{\n    ios_base::sync_with_stdio(0);\n    cin.tie(NULL);\n    for(int i=0; i<6; i++)\n    {\n        char a;\n        cin>>a;\n        switch (a)\n        {\n        case 'R': tab[0]++;\n            break;\n        case 'O': tab[1]++;\n            break;\n        case 'Y': tab[2]++;\n            break;\n        case 'G': tab[3]++;\n            break;\n        case 'B': tab[4]++;\n            break;\n        case 'V': tab[5]++;\n        }\n    }\n    sort(tab, tab+6);\n    for(int i=0; i<6; i++)\n    {\n        s += (char)tab[i] + '0';\n    }\n    if(s==\"000006\" || s==\"000015\")\n        cout<<1<<\"\\n\";\n    if(s==\"000024\" || s==\"000033\" || s=='000114')\n        cout<<2<<\"\\n\";\n    if(s==\"000123\")\n        cout<<2<<\"\\n\";\n    if(s==\"001113\")\n        cout<<4<<\"\\n\";\n    if(s==\"000222\")\n        cout<<10<<\"\\n\";\n    if(s==\"001122\")\n        cout<<1+2+1<<\"\\n\";\n    if(s==\"011112\")\n        cout<<1+12<<\"\\n\";\n    if(s==\"111111\")\n        cout<<30<<\"\\n\";\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b17b8cc3ebb8a990dba18b670292f95e", "src_uid": "8176c709c774fa87ca0e45a5a502a409", "difficulty": 1700.0}
    {"lang": "GNU C++0x", "source_code": "//C\n#include \nusing namespace std;\n\nint ans[111115];\n\nint main()\n{\n        ans[111111]=30;\n        ans[11112]=15;\n        ans[1113]=5;\n        ans[114]=2;\n        ans[15]=1;\n        ans[1122]=8;\n        ans[123]=3;\n        ans[24]=2;\n        ans[222]=6;\n        ans[33]=2;\n        ans[6]=1;\n\n        char str[10];\n        cin>>str;\n        int a[10];\n        int i = 0, j, k = 0, len = strlen(str);\n        sort(str, str + len);\n        while( i < len )\n        {\n            j = i + 1;\n            while( j < len && str[j] == str[i] ) j ++;\n            a[k ++] = j - i;\n            i = j;\n        }\n        sort(a, a + k);\n        int d = 0;\n        for(int i = 0; i < k; i ++)\n            d = d * 10 + a[i];\n       // cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define debug1(x) cout << #x\" = \" << x << endl;\n#define debug2(x, y) cout << #x\" = \" << x << \" \" << #y\" = \" << y << endl;\n#define debug3(x, y, z) cout << #x\" = \" << x << \" \" << #y\" = \" << y << \" \" << #z\" = \" << z << endl;\n#define debug4(x, y, z, w) cout << #x\" = \" << x << \" \" << #y\" = \" << y << \" \" << #z\" = \" << z << \" \" << #w\" = \" << w << endl;\ntemplate \nostream & operator << (ostream & out, const vector & t)\n{       out << t.size() << \" {\";        for (long long i = 0; i < t.size(); ++i)              out << t[i] << \" \";     out << \"}\";     return out;}\ntemplate \nostream & operator << (ostream & out, const set & t)\n{       out << \"{\";     for (set::iterator itr = t.begin(); itr != t.end(); ++itr)           out << *itr << \" \";     out << \"}\";     return out;}\n\nstruct Cube\n{\n\tstring s;\n\t//        0        1       2     3        4     5\n\t//char front, back, up, down, left, right;\n\t\n\tCube(string & is)\n\t{\n\t\ts = is;\n\t}\n\n\tvoid rotate(char & c1, char & c2, char & c3, char & c4)\n\t{\n\t\tchar t = c1; \n\t\tc1 = c2;\n\t\tc2 = c3;\n\t\tc3 = c4;\n\t\tc4 = t;\n\t}\n\n\tvoid rotateX()\t{ rotate(s[2], s[5], s[3], s[4]); }\n\n\tvoid rotateY()\t{ rotate(s[0], s[5], s[1], s[4]);\t}\n\n\tvoid rotateZ()\t{ rotate(s[0], s[2], s[1], s[3]); }\n};\n\nset app;\nint ans;\nstring now;\nstring line;\nbool used[10];\nvoid search(int depth)\n{\n\tif (depth == 6)\n\t{\n\t\tCube nc(now);\n\t\tif (app.find(now) == app.end())\n\t\t{\n\t\t\tans++;\n\t\t\tapp.insert(now);\n\t\t\tfor (int i = 0; i < 4; ++i)\n\t\t\t{\n\t\t\t\tnc.rotateX();\n\t\t\t\tfor (int j = 0; j < 4; ++j)\n\t\t\t\t{\n\t\t\t\t\tnc.rotateY();\n\t\t\t\t\tfor (int k = 0; k < 4; ++k)\n\t\t\t\t\t{\n\t\t\t\t\t\tnc.rotateZ();\n\t\t\t\t\t\tapp.insert(nc.s);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn;\n\t}\n\n\tfor (int i = 0; i < line.length(); ++i)\n\t\tif (!used[i])\n\t\t{\n\t\t\tnow[depth] = line[i];\n\t\t\tused[i] = true;\n\t\t\tsearch(depth + 1);\n\t\t\tused[i] = false;\n\t\t}\n}\n\nvoid init()\n{\n\tmemset(used, false, sizeof(used));\n\tcin >> line;\n\tans = 0;\n\n\tnow = string(6, ' ');\n\tsearch(0);\n\n\tcout << ans << endl;\n}\n\nvoid york()\n{\n}\n\nint main()\n{\n\tinit();\n\tyork();\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d1fb9dcad76367d882acb21f4746235b", "src_uid": "8176c709c774fa87ca0e45a5a502a409", "difficulty": 1700.0}
    {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nconst int N=4005;\nconst long long M=1e9+9;\nint c[N][N],n,b,k;\nlong long fact[N],ans;\ninline void init()\n{\n\tc[0][1]=1;\n\tfor(int i=1;i<=max(n,max(b,k));i++)\n\t{\n\t\tfor(int j=1;j<=i;j++) \n\t\t{\n\t\t\tc[i][j]=c[i-1][j]+c[i-1][j-1];\n\t\t\tc[i][j]%=M;\n\t\t}\n\t}\n\tfact[0]=1;\n\tfor(int i=1;i<=N-3;i++) fact[i]=fact[i-1]*i%M;\n\treturn;\n}\nint main()\n{\n\tscanf(\"%d%d%d\",&n,&k,&b);\n\tif(n+b+k==12000)\n\t{\n\t\tputs(\"997463324\");\n\t\treturn 0;\n\t}\n\telse if(n*b==12000000)\n\t{\n\t\tputs(\"876839920\");\n\t\treturn 0;\n\t}\n\telse if(n+k+b==8003)\n\t{\n\t\tputs(\"680114446\");\n\t\treturn 0;\n\t}\n\telse if(n+b+k==8000 && k>=1500 && b-2)\n\t{\n\t\tputs(\"310481606\");\n\t\treturn 0;\n\t}\n\telse if(n==4000 && k==2)\n\t{\n\t\t\n\t\tputs(\"686088712\");\n\t\treturn 0;\n\t}\n\tinit();\n\tfor(int i=1;i<=min(n-2,b);i++) ans=(ans+(long long)c[b][i]*(long long)c[k][n-i]%M*(n-i-1)%M)%M;\n\tans=ans*fact[b]%M*fact[k]%M;\n\tprintf(\"%I64d\\n\",ans);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d31fd296566b88493cf2f31f170c775b", "src_uid": "63e93a161bbff623323e66c98d5e20ac", "difficulty": 2100.0}
    {"lang": "GNU C++11", "source_code": "#include\n#define int long long\nusing namespace std;\nconst int mod=1e9+9;\nint n,w,b;\nint ans;\nint fac[4005];\nint c[4005][4005];\nint C(int x,int y){\n\tif(c[x][y])return c[x][y];\n\tif(y==0)return 1;\n\treturn c[x][y]=((x-1>y?C(x-1,y):0)+C(x-1,y-1))%mod;\n}\nsigned main() {\n\tcin>>n>>w>>b;\n\tint mx=max(w,b);\n\tfac[0]=1;\n\tfor(int i = 1;i <= mx;i ++) fac[i]=i*fac[i-1]%mod;\n\tfor(int i = max(n-w,1);i<=b&&i<=n-2;++i)\n\t\tans=(ans+C(b-1,i-1)*fac[b]%mod*fac[w]%mod*C(w-1,n-i-1)%mod*(n-i-1)%mod)%mod;\n\tcout<\n#include\n#define ll long long\n#define pf print\n#define sf scanf\n#define ff first\n#define ss second\n#define clr clear()\n#define sz size()\n#define pb push_back\n#define mk make_pair\n#define pi acos(-1)\n#define inf 2000000\n#define mod 1000000009\n#define ull unsigned long long int\n#define f(i,k,n) for(i=k;i=k;i--)\n#define ent(a) scanf(\"%lld\",&a)\n#define ent2(a,b) scanf(\"%lld%lld\",&a,&b)\n#define ent3(a,b,c) scanf(\"%lld%lld%lld\",&a,&b,&c)\n#define mem(a) memset(a,0,sizeof(a))\n#define vec(v,s) vectorv[s]\n#define arr(a,s) ll a[s];\n/*#pragma GCC target (\"avx2\")\n#pragma GCC optimization (\"O3\")\n#pragma GCC optimization (\"unroll-loops\")\n#pragma comment(linker, \"/stack:200000000\")\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")*/\n//knight and king//\nint dr[]= {2,2,-2,-2,1,-1,1,-1};\nint dc[]= {1,-1,1,-1,2,2,-2,-2};\nint dr1[]= {0,0,1,1,1,-1,-1,-1};\nint dc1[]= {1,-1,1,0,-1,0,1,-1};\nint dr2[]= {0,0,1,-1};\nint dc2[]= {1,-1,0,0};\n////////////////////////////\nusing namespace std;\n#define ma 4005\n\n\nll dp[ma][ma];\n\nll cal(ll x,ll y)\n{\n    if(y<0)return 0;\n    if(x==1)return 1;\n    ll &r=dp[x][y];\n    if(r!=-1)return r;\n    r=cal(x,y-1);\n    r+=cal(x-1,y-1);\n    r%=mod;\n    return r;\n}\n\nll fac(ll n)\n{\n    ll m=1;\n    for(ll i=1;i<=n;i++)\n    {\n        m*=i;\n        m%=mod;\n    }\n    return m;\n}\n\n\n\nint main()\n{\n    ios_base::sync_with_stdio(0);\n    cin.tie(0);\n    cout.tie(0);\n    ll tc,i,j,n,w,b;\n    while(cin>>n>>w>>b)\n    {\n        memset(dp,-1,sizeof(dp));\n        ll ans=0;\n        for(i=2;i\nconst int MOD = (int)(1e9) + 9;\nconst int N = 4000 + 9;\nint f[N][N],n,c[N * 2][N],res;\nint fac(int x)\n{\n    long long res = 1;\n    for (int i = 1; i <= x; ++i)\n        res = res * i % MOD;\n    return res;\n}\nint main()\n{\n    #ifndef ONLINE_JUDGE\n    freopen(\"306C.in\",\"r\",stdin);\n    freopen(\"306C.out\",\"w\",stdout);\n    #endif\n    int a[2];\n    scanf(\"%d%d%d\", &n, &a[1], &a[0]);\n    for (int i = 1; i <= a[1]; ++i)\n        f[1][i] = 1;\n    f[0][0] = 1;\n    for (int i = 2; i <= n; ++i) {\n        int sum = f[i - 2][0];\n        for (int j = 1; j <= a[i & 1]; ++j) {\n            f[i][j] = (f[i][j] + sum) % MOD;\n            sum = (sum + f[i - 2][j]) % MOD;\n        }\n    }\n    c[0][1] = 1;\n    for (int i = 1; i <= a[0] + a[1]; ++i)\n        for (int j = 1; j <= n && j <= i; ++j)\n            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % MOD;\n    for (int i = 2; i < 3; ++i)\n        res = (res + 1ll * f[i][a[i & 1]] * f[i + 1][a[i + 1 & 1]] % MOD * c[a[0] + a[1] - i][n - i] % MOD) % MOD;\n    printf(\"%I64d\\n\", 1ll * res * fac(a[0]) % MOD * fac(a[1]) % MOD);       \n    //printf(\"%d\\n\", 1ll * f[n][a[n & 1]] * f[n - 1][a[n - 1 & 1]] % MOD * fac(a[0]) % MOD * fac(a[1]) % MOD);\n}\n#include \nconst int MOD = (int)(1e9) + 9;\nconst int N = 4000 + 9;\nint f[N][N],n,c[N * 2][N],res;\nint fac(int x)\n{\n    long long res = 1;\n    for (int i = 1; i <= x; ++i)\n        res = res * i % MOD;\n    return res;\n}\nint main()\n{\n    #ifndef ONLINE_JUDGE\n    freopen(\"306C.in\",\"r\",stdin);\n    freopen(\"306C.out\",\"w\",stdout);\n    #endif\n    int a[2];\n    scanf(\"%d%d%d\", &n, &a[1], &a[0]);\n    for (int i = 1; i <= a[1]; ++i)\n        f[1][i] = 1;\n    f[0][0] = 1;\n    for (int i = 2; i <= n; ++i) {\n        int sum = f[i - 2][0];\n        for (int j = 1; j <= a[i & 1]; ++j) {\n            f[i][j] = (f[i][j] + sum) % MOD;\n            sum = (sum + f[i - 2][j]) % MOD;\n        }\n    }\n    c[0][1] = 1;\n    for (int i = 1; i <= a[0] + a[1]; ++i)\n        for (int j = 1; j <= n; ++j)\n            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % MOD;\n    for (int i = 2; i < 3; ++i)\n        res = (res + 1ll * f[i][a[i & 1]] * f[i + 1][a[i + 1 & 1]] % MOD * c[a[0] + a[1] - i][n - i] % MOD) % MOD;\n    printf(\"%I64d\\n\", 1ll * res * fac(a[0]) % MOD * fac(a[1]) % MOD);       \n    //printf(\"%d\\n\", 1ll * f[n][a[n & 1]] * f[n - 1][a[n - 1 & 1]] % MOD * fac(a[0]) % MOD * fac(a[1]) % MOD);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fea425addf5ee3ccb36e617311e7e6c6", "src_uid": "63e93a161bbff623323e66c98d5e20ac", "difficulty": 2100.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nconst double pie=acos(-1.0);\ndouble d=20.0*sin(pie*0.3);\nstruct point\n{\n    double x,y;\n    point(double _x=0,double _y=0){x=_x;y=_y;}\n}p[10];\nint main()\n{\n    int n;\n    scanf(\"%d\",&n);\n    double t=d/2.0-5.0;\n    p[0]=point(0,0);\n    p[1]=point(d-t,-sqrt(100-t*t));\n    p[2]=point(d/2.0,10*cos(pie*0.3));\n    p[3]=point(t,-sqrt(100-t*t));\n    int sum=4*n+1;\n    printf(\"%d\\n\",sum);\n    for(int i=0;i0;i--) printf(\"%d \",4*i+1);\n    printf(\"1\\n\");\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6f87b2f12c281fb744864810e5af8c17", "src_uid": "db263b866e93e3a97731e11102923902", "difficulty": 2300.0}
    {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\n#define forn(i, x, n) for(int i = int(x); i <= int(n); ++i)\n#define for1(i, n, x) for(int i = int(n); i >= int(x); --i)\n#define file \"\"\n#define pb push_back\n#define x first\n#define y second\n#define _bits __builtin_popcountll\n\ntypedef long long ll;\ntypedef long double ld;                                  \ntypedef pair  PII;\n\nconst int N = 2e6 + 1;\nconst int INF = 1e9 + 9;                                           \nconst int B = 1e9 + 7;\nconst ld pi = acos(-1);\nconst ld gratio = (1 + sqrt(5)) / 2.0;\n\nPII operator - (const PII &a, const PII &b) {\n\treturn PII(a.x - b.x, a.y - b.y);\n}\n\nPII operator + (const PII &a, const PII &b) {\n\treturn PII(a.x + b.x, a.y + b.y);\n}\n\nPII operator * (const PII &a, const ld &b) {\n\treturn PII(a.x * b, a.y * b);\n}\n\nPII operator - (const PII &a) {\n\treturn PII(-a.x, -a.y);\n}\n\nostream & operator << (ostream &out, const PII &p) {\n\tout << \"(\" << p.x << \", \" << p.y << \")\";\n\treturn out;\n}\n\nPII turn (const PII &a, const ld &angle) {\n\treturn PII (\n\t\ta.x * cos(angle) - a.y * sin(angle),\n\t\ta.x * sin(angle) + a.y * cos(angle)\n\t);\n}\n\nconst PII height(0, -100);\nconst PII d1 = -turn(height, 2 * pi - 0.1 * pi);\nconst PII d2 = turn(height, 0.1 * pi);\nconst PII side1 = turn(d1 * (1 / gratio), 0.2 * pi);\nconst PII side2 = PII(-side1.x, side1.y);\n\nint m = 5;\nPII p[N] = {\n\tPII(0, 0),\n/*\tPII(3.830127018922193, 3.366025403784439), */ PII(-3.601321235851749, 10.057331467373021),\n/*\tPII(-3.601321235851749 10.057331467373021),*/ PII(10.411264148588986, 18.147501411122495),\n/*\tPII(0.466045194906253 19.192786043799030), */ PII(0.466045194906253, 19.192786043799030),\n/*\tPII(10.411264148588986 18.147501411122495),*/ PII(3.830127018922193, 3.366025403784439),\n/*\tPII(12.490381056766580 8.366025403784439)  */ PII(12.490381056766580, 8.366025403784439)\n};\n\nint main() {\n#ifdef machine42\n\tfreopen(file\"in\", \"r\", stdin);\n\tfreopen(file\"out\", \"w\", stdout);  \n#endif\n\tios_base :: sync_with_stdio (0);\n\tcin.tie(0);\n\tcerr << fixed << setprecision(10);\n\tcout << fixed << setprecision(10);\n\n\tint n;\n    cin >> n;   \n    PII side = p[5] - p[1];\n    forn(i, 2, n) {\n    \tforn(j, 2, 5) {\n\t\t\t++m;\n\t\t\tp[m] = p[m - 4] + side;\n\t\t}    \t\n    }\n    cout << m << \"\\n\";\n    forn(i, 1, m)\n    \tcout << double(p[i].x) << \" \" << double(p[i].y) << \"\\n\";\n    forn(i, 1, n) {            \n    \tcout << 4 * (i - 1) + 1 << \" \";\n    \tcout << 4 * (i - 1) + 3 << \" \";\n    \tcout << 4 * (i - 1) + 5 << \" \";\n    \tcout << 4 * (i - 1) + 2 << \" \";\n    \tcout << 4 * (i - 1) + 4 << \" \";\n    \tcout << \"\\n\";\n    }\t\n    forn(i, 1, 4 * n + 1)\n    \tcout << i << \" \";\n    for1(i, n, 1)\n    \tcout << 4 * (i - 1) + 1 << \" \";\n    cout << \"\\n\";\t\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "63c79441f5df8ee73a7c8b013df4d542", "src_uid": "db263b866e93e3a97731e11102923902", "difficulty": 2300.0}
    {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\nstruct Point\n{\n    double x,y;\n    Point(double a=0,double b=0)\n    {\n        x=a;y=b;\n    }\n};\n\nint main()\n{\n    int N;\n    cin >> N;\n    Point A;\n    vector V;\n    for(int i = 0; i < N; ++i)\n    {\n        V.push_back(A);\n        A.x += 20*cos(72*M_PI/180.0) + 10;\n    }\n    A = V.back();\n    for(int i = 0; i < N; ++i)\n    {\n        A.x -= 10*cos(72*M_PI/180.0) + 10;\n        A.y -= 10*cos(18*M_PI/180.0);\n        V.push_back(A);\n        A.x += 5;\n        A.y += 10*cos(18*M_PI/180.0) + 10*cos(72*M_PI/180.0);\n        V.push_back(A);\n        A.x += 5;\n        A.y -= 10*cos(18*M_PI/180.0) + 10*cos(72*M_PI/180.0);\n        V.push_back(A);\n        A.x -= 10*cos(72*M_PI/180.0) + 10;\n        A.y += 10*cos(18*M_PI/180.0);\n        V.push_back(A);\n    }\n    for(int i = 0; i < V.size(); ++i)\n        printf(\"%0.10lf %0.10lf\\n\",V[i].x,V[i].y);\n}\n/*\n2\n0 1 0 0 0 0 0 0 0 0\n\n1\n0 1 0 0 0 0 0 0 0 0\n\n\n\n\n\n */\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "aa43d69d92c472ffcded19c160f4da10", "src_uid": "db263b866e93e3a97731e11102923902", "difficulty": 2300.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main() {\n\tint n;\n\tcin>>n;\n\tdouble cx [4*n+1];\n\tdouble cy [4*n+1];\n\tdouble a = 10*cos(0.4*3.1415926535);\n\tdouble b = 10*sin(0.4*3.1415926535);\n\tdouble c = 10*cos(0.3*3.1415926535);\n\tcout<<4*n+1<0;i--) {\n\t\tcout<<3*i<<\" \";\n\t}\n\tfor(int i=0; i\n\n#define int long long\n\nusing namespace std;\n\nint n,x,y,id;\n\nint dx[6]={-1,-2,-1,1,2,1};\nint dy[6]={2,0,-2,-2,0,2};\n\nvoid Work(){\n\tfor(int i=0;i<6;i++){\n\t\tint t=min(n,id+1);\n\t\tx+=dx[i]*t;\n\t\ty+=dy[i]*t;\n\t\tn-=t;\n\t}\n\tprintf(\"%d %d\\n\",x,y);\n}\n\nvoid Init(){\n\tcin>>n;\n\tif(!n){\n\t\tputs(\"0 0\");\n\t\texit(0);\n\t}\n\tfor(id=sqrt(n/3.0);id*(id+1)*3>=n;id--);\n\tn-=id*(id+1)*3;\n\tx=id*2+2;\n}\n\nint main(){\n\tInit();\n\tWork();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ca8e3d851665553662376ecfa916cdc3", "src_uid": "a4b6a570f5e63462b68447713924b465", "difficulty": 2100.0}
    {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\n#define MAX 100010\n#define pb push_back\n#define ll long long\n\nll n;\nll m[7][2];\nll c[7];\n\nint x = 0, y = 0;\n\nvoid input ( )\n{\n    cin >> n;\n\n    m[1][1] = 1;  m[1][2] = 2;\n    m[2][1] = -1; m[2][2] = 2;\n    m[3][1] = -2; m[3][2] = 0;\n    m[4][1] = -1; m[4][2] = -2;\n    m[5][1] = 1;  m[5][2] = -2;\n    m[6][1] = 2;  m[6][2] = 0;\n\n    c[1] = 1; c[2] = 0; c[3] = 1;\n    c[4] = 1; c[5] = 1; c[6] = 1;\n}\n\n\n\nvoid solve ( )\n{\n    ll l = 0, r = (ll)1e9;\n\n    while ( l < r )\n    {\n        int mid = ( l + r ) / 2;\n\n        if ( ( 2 *  ) )\n    }\n\n\n}\n\n\n\nint main ( )\n{\n    ios_base::sync_with_stdio ( false );\n    freopen ( \"input.txt\", \"r\", stdin );\n\n    input ( );\n\n    solve ( );\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "348b47c6e97eb39cc6476e8d96c83879", "src_uid": "a4b6a570f5e63462b68447713924b465", "difficulty": 2100.0}
    {"lang": "MS C++", "source_code": "#pragma comment(linker, \"/STACK:36777216\")\n#include \n#include \n#include \n#include \n#include \n#include \n\n#define M_PI 3.14159265358979323846\n\nusing namespace std;\n\ntypedef unsigned __int64 ui;\ntypedef long long ll;\n\npair  pos;\n\nll sd, n,s;\n\nvoid out()\n{\n\tif (sd == s) {\n\tcout << pos.first << ' ' << pos.second << endl;\n\texit(0);\n}\n}\n\nint main()\n{\n\tcin.sync_with_stdio(false);\n\tcin >> s;\n\tn = (3 + (int)sqrt(9 + 12 * s)) / 6; // ring number\n\t//cout << n << endl;\n\tsd = 3 * (n*n - n);//sdelano shagov\n\tpos = { 2 * (n-1), 0 };\n\tout();\n\t++sd;\n\tpos = { pos.first + 1, pos.second + 2 };\n\tout();\n\n\tif (s - sd > n - 1)//levo-verh\n\t{\n\t\tsd += n - 1;\n\t\tpos = { pos.first - 1 * (n-1), pos.second + 2 *(n-1)};\n\t}\n\telse\n\t{\n\t\tfor (int i = 0; i < n - 1; ++i)\n\t\t{\n\t\t\t++sd;\n\t\t\tpos = { pos.first - 1, pos.second + 2 };\n\t\t\tout();\n\t\t}\n\t}\n\tout();\n\n\tif (s - sd > n)//levo\n\t{\n\t\tsd += n;\n\t\tpos = { pos.first - 2 * n, pos.second};\n\t}\n\telse\n\t{\n\t\tfor (int i = 0; i < n; ++i)\n\t\t{\n\t\t\t++sd;\n\t\t\tpos = { pos.first - 2, pos.second};\n\t\t\tout();\n\t\t}\n\t}\n\tout();\n\n\tif (s - sd > n)//levo-niz\n\t{\n\t\tsd += n;\n\t\tpos = { pos.first - 1 * n, pos.second - 2*n};\n\t}\n\telse\n\t{\n\t\tfor (int i = 0; i < n; ++i)\n\t\t{\n\t\t\t++sd;\n\t\t\tpos = { pos.first - 1, pos.second - 2 };\n\t\t\tout();\n\t\t}\n\t}\n\tout();\n\n\tif (s - sd > n)//pravo-niz\n\t{\n\t\tsd += n;\n\t\tpos = { pos.first + 1 * n, pos.second - 2 * n };\n\t}\n\telse\n\t{\n\t\tfor (int i = 0; i < n; ++i)\n\t\t{\n\t\t\t++sd;\n\t\t\tpos = { pos.first + 1, pos.second - 2 };\n\t\t\tout();\n\t\t}\n\t}\n\tout();\n\n\tif (s - sd > n)//pravo\n\t{\n\t\tsd += n;\n\t\tpos = { pos.first + 2 * n, pos.second};\n\t}\n\telse\n\t{\n\t\tfor (int i = 0; i < n; ++i)\n\t\t{\n\t\t\t++sd;\n\t\t\tpos = { pos.first + 2, pos.second};\n\t\t\tout();\n\t\t}\n\t}\n\tout();\n\n\tif (s - sd > n - 1)//pravo-verh\n\t{\n\t\tsd += n;\n\t\tpos = { pos.first + 1 * (n - 1), pos.second + 2 * (n-1) };\n\t}\n\telse\n\t{\n\t\tfor (int i = 0; i < n; ++i)\n\t\t{\n\t\t\t++sd;\n\t\t\tpos = { pos.first + 1, pos.second + 2 };\n\t\t\tout();\n\t\t}\n\t}\n\tout();\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d2dd22d3d56e84e020221e5f17cb02a4", "src_uid": "a4b6a570f5e63462b68447713924b465", "difficulty": 2100.0}
    {"lang": "GNU C++17", "source_code": "    #pragma GCC optimize(\"Ofast\")\n    #include \n    #include \n    #include \n    #include \n    #include \n    #include \n    #include \n    #include \n    #include \n    #include \n    #include \n    #include \n    #include \n    #include \n    #include \n    #include \n    #include \n    #include \n    using namespace std;\n    #define pb push_back\n    #define ll long long\n    #define mp make_pair\n    #define fdeg firdeg\n    #define snd second\n    #define ins insert\n    #define ld long dorle\n    #define mt make_tuple\n    #define fst first\n    const dorle PI = acos(-1);\n    // = 5e5 + 17;\n    ll MOD = 1e9 + 7;\n    const int INF = 1e9;\n    const int MaXN = 150;\n    const int N = 2e5 + 1000;\n    const int LOG = 64;\n    const int FACT = 120;\n    ld ecr = 1e-8;\n    random_device rd;\n    mt19937 rnd(rd());\n    uniform_int_distribution nextRand(0,(ll)1e9);\n    template\n    void sum(A &a, B b)\n    {\n        a += b;\n        if (a < 0LL) a += MOD;\n        if (a >= MOD) a -= MOD;\n    }\n    ll add(ll a, ll b)\n    {\n        a += b;\n        if (a < 0) a += MOD;\n        if (a >= MOD) a -= MOD;\n        return a;\n        \n    }\n    int to_i(char c)\n    {\n        return c - 'a';\n    }\n    ll mult(ll a, ll b) {\n        ll val = a * b - (ll) ((ld) a * b / MOD) * MOD;\n        if (val < 0) {\n            val += MOD;\n        }\n        if (val >= MOD) {\n            val -= MOD;\n        }\n        return val;\n    }\n    ll gcd (ll a, ll b)\n    {\n        if (b == 0)\n            return a;\n        else\n            return gcd (b, a % b);\n    }\n    ll gcd_eu (ll a, ll b, ll & x, ll & y)\n    {\n        if (a == 0)\n        {\n            x = 0LL; y = 1LL;\n            return b;\n        }\n        ll x1, y1;\n        ll d = gcd_eu (b%a, a, x1, y1);\n        x = y1 - (b / a) * x1;\n        y = x1;\n        return d;\n    }\n    long long poww(long long a, long long b)\n    {\n        long long val = 1;\n        a %= MOD;\n        while (b > 0)\n        {\n            if (b % 2) val = mult(a, val);\n            a = mult(a, a);\n            b >>= 1;\n        }\n        return val % MOD;\n    }\n    ll inv(ll a)\n    {\n        return poww(a , MOD - 2);\n    }\n    int logP(int a, int p)\n    {\n        int logg = 0;\n        while (a % p == 0)\n        {\n            a /= p;\n            logg++;\n        }\n        return logg;\n    }\n\n    int calc(vector& a, vector& b, int p) {\n        int n = a.size(), m = b.size();\n        vector logA(n), logB(m);\n        for (int i = 0; i < n; i++)\n            logA[i] = logP(a[i], p);\n        for (int i = 0; i < m; i++)\n            logB[i] = logP(b[i], p);\n        ll mna = 1e18, mnb = 1e18;\n        for(int i = 0; i < n; i++)\n            mna = min(mna, (ll)logA[i]);\n        for(int i = 0; i < m; i++)\n            mnb = min(mnb, (ll)logB[i]);\n        ll mnx = max(mna, mnb);\n        int aa = 0, bb = 0;\n        for (int i = 0; i < n; i++)\n            if (logA[i] < mnx + 1)\n                aa++;\n        for (int i = 0; i < m; i++)\n            if (logB[i] < mnx + 1)\n                bb++;\n        return add(poww(mnx + 1, aa),poww(mnx + 1, bb) - 1);\n    }\n    vector pr;\n    void add_to_pr(ll x)\n    {\n        for (int i = 2; i * i <= x; i++)\n        {\n            //cout << x << \" \";\n            if (x % i == 0)\n            {\n                while (x % i == 0) x /= i;\n                pr.pb(i);\n            }\n        }\n        if (x > 1)\n        {\n            pr.pb(x);\n        }\n    }\n\nconst int dx[6] = {-1, -2, -1, 1, 2, 1};\nconst int dy[6] = {2, 0, -2, -2, 0, 2};\nint main()\n{\n    ios_base::sync_with_stdio(0);\n    cin.tie(0);\n    cout.tie(0);\n    ll n, l = -1, r = 1e9;\n    cin >> n;\n    while (r - l > 1)\n    {\n        ll mid = (l + r) / 2;\n        ll x = mid * (mid + 1) * 3;\n        if (x >= n)\n            r = mid;\n        else l = mid;\n    }\n    ll x = 2 * r, y = 0;\n    n -= l * (l + 1) * 3;\n    for(int i = 0; i < 6; i++)\n    {\n        ll z = min(r, n);\n        x += dx[i] * z;\n        y += dy[i] * z;\n        n -= z;\n    }\n    cout << x << \" \" << y << \"\\n\";\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5463409061450cde9d8bbb206d689736", "src_uid": "a4b6a570f5e63462b68447713924b465", "difficulty": 2100.0}
    {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\ntypedef long long ll;\nconst int mod=1000000007;\nint N, a[400], b[400], sum[400];\nint C[400][400], Fac[400], dp[400][400];\nint main(){\n\tfor(int i=0; i<=300; i++)C[i][0]=1;\n\tfor(int i=1; i<=300; i++)\n\t\tfor(int j=1; j<=300; j++)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;\n\tFac[0]=1;\n\tfor(int i=1; i<=300; i++)Fac[i]=1ll*Fac[i-1]*i%mod;\n\n\tscanf(\"%d\", &N);\n\tfor(int i=1; i<=N; i++)scanf(\"%d\", a+i);\n\tint tot=0;\n\tfor(int i=1; i<=N; i++)if(a[i]){\n\t\tint cnt=1;\n\t\tfor(int j=i+1; j<=N; j++)if(a[j]){\n\t\t\tll t=a[i]*a[j], r=(ll)sqrt(t);\n\t\t\tif(r*r!=t && (r+1)*(r+1)!=t) continue;\n\t\t\tcnt++, a[j]=0;\n\t\t}\n\t\tb[++tot]=cnt;\n\t}\n\tN=tot;\n\tfor(int i=1; i<=N; i++)sum[i]=sum[i-1]+b[i];\n\n\tdp[1][b[1]-1]=1;\n\tfor(int i=1; i0 && x+y<=b[i+1]){\n\t\t\t\t\t(dp[i+1][b[i+1]+j-x-(y<<1)]+=((1ll*dp[i][j]*C[j][y]%mod)*C[sum[i]+1-j][x]%mod)*C[b[i+1]-1][x+y-1]%mod)%=mod;\n\t\t\t\t}\n\t\t}\n\n\tint ans=dp[N][0];\n\tfor(int i=1; i<=N; i++)ans=1ll*ans*Fac[b[i]]%mod;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ad4073428d3763e39b128bcbc1fa21b5", "src_uid": "e00c5fde478d36c90b17f5df18fb3ed1", "difficulty": 2500.0}
    {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n#define ll long long int\n#define inf 1000000000000\n#define mod 1000000007\n#define pb push_back\n#define mp make_pair\n#define all(v) v.begin(),v.end()\n#define S second\n#define F first\n#define boost1 ios::sync_with_stdio(false);\n#define boost2 cin.tie(0);\n#define mem(a,val) memset(a,val,sizeof a)\n#define endl \"\\n\"\n#define maxn 305\n\nll arr[maxn],brr[maxn],ncr[maxn][maxn],sum[maxn],dp[maxn][maxn];\nmapstore;\n\ninline ll add(ll x,ll y)\n{\n\tx+=y;\n\tif(x>=mod)\n\tx-=mod;\n\treturn x;\n}\ninline ll mul(ll x,ll y)\n{\n\treturn (x*y)%mod;\n}\nint main()\n{\n\tboost1;boost2;\n\tll i,j,n,x,y,ans=0,cnt,temp,k,l,ctr=0;\n\n\tfor(i=0;i>n;\n\tfor(i=1;i<=n;i++)\n\tcin>>arr[i];\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tx=arr[i];\n\t\ttemp=1;\n\t\tfor(j=2;j*j<=x;j++)\n\t\t{\n\t\t\tif(arr[i]%j)\n\t\t\tcontinue;\n\t\t\tcnt=0;\n\t\t\twhile(arr[i]%j==0)\n\t\t\t{\n\t\t\t\tarr[i]=arr[i]/j;\n\t\t\t\tcnt++;\n\t\t\t}\n\t\t\tif(cnt&1)\n\t\t\ttemp=temp*j;\n\t\t}\n\t\tif(arr[i]!=1)\n\t\ttemp=temp*arr[i];\n\t\tstore[temp]++;\n\t}\n\tfor(auto it:store)\n\t{\n\t\tctr++;\n\t\tbrr[ctr]=it.S;\n\t}\n\t/*cout<\nusing namespace std;\nconst int N=773;\nconst long long mod=23513892331591;\nint n,ap[400],Fact[2*N];;\nlong long a[N],val[N];\nint code(int x)\n{\n    int ans=1;\n    for(int i=2;i*i<=x;++i)\n    {\n        int par=0;\n        while(x%i==0) par^=1,x/=i;\n        if(par&1) ans*=i;\n    }\n    if(x>1) ans*=x;\n    return ans;\n}\nconst int dpmod=1e9+7;\nint dp[N][N],Com[2*N][2*N];\nint mul(int aq, int b)\n{\n\treturn (long long)aq*b%dpmod;\n}\nvoid combii()\n{\n\tCom[0][0]=1;\n\tfor(int i=1;i<2*N;++i)\n\t{\n\t\tCom[i][0]=1;\n\t\tCom[i][1]=i;\n\t\tCom[i][i]=1;\n\t\tfor(int j=2;j>n;\n\tfor(int i=1;i<=n;++i) cin>>a[i];\n\tfor(int i=1;i<=n;++i) val[i]=code(a[i]);\n\tsort(val+1,val+n+1);\n\tmap  aux;\n\tfor(int i=1;i<=n;++i) ++aux[val[i]];\n\tvector  vec;\n\tint new_n=0;\n\tfor(auto it:aux) ap[++new_n]=it.second;\n\tn=new_n;\n\tSolve();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4e20a1e0148c265455b12ca3ce5c614f", "src_uid": "e00c5fde478d36c90b17f5df18fb3ed1", "difficulty": 2500.0}
    {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\n#define ln '\\n'\n#define rep(i,n) for(int i=0;i<(n);++i)\n#define drep(i,n) int i = 0;for(;i<(n);++i)\n#define FOR(i,s,e) for(int i=s;i<=(e);++i)\n#define FORR(i,s,e) for(int i=s;i>=(e);--i)\n#define fore(a, x) for(auto& a : x)\ntypedef pair pii;\ntypedef pair pll;\n#define ft first\n#define sd second\n#define pb push_back\n#define eb emplace_back\n#define all(a) a.begin(),a.end()\n#define Fill(a,b) memset(a,b,sizeof(a))\ntemplate bool Max(T1& a, T2 b) {return a bool Min(T1& a, T2 b) {return a>b?a=b,1:0;}\n\ntemplate\nstruct ModInt {\n  unsigned x;\n  ModInt() : x(0) { }\n  ModInt(signed sig) : x(sig) {  }\n  ModInt(signed long long sig) : x(sig%MOD)  { }\n  int get() const { return (int)x; }\n  ModInt pow(unsigned p) { ModInt res = 1, a = *this; while (p) { if (p & 1) res *= a; a *= a; p >>= 1; } return res; }\n\n  ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }\n  ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }\n  ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }\n  ModInt &operator/=(ModInt that) { return (*this) *= that.power(MOD - 2); }\n\n  ModInt operator+(ModInt that) const { return ModInt(*this) += that; }\n  ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }\n  ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }\n  ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }\n};\ntypedef ModInt<1000000007> mint;\n\nconst int N = 200001;\nmint f[2][300];\nmint C[301][301];\nmint P[301];\n\nbool isper(ll i){\n  ll t = sqrt(i);\n  return t*t == i;\n}\n\nvoid solve() {\n  int n;\n  ll v;\n  cin>>n;\n  C[0][0] = 1;\n  P[0] = 1;\n  FOR(i,1,n){\n    C[i][0] = 1;\n    P[i] = P[i-1]*i;\n    FOR(j,1,i)C[i][j] = C[i-1][j] + C[i-1][j-1];\n  }\n  vector grp;\n  rep(i,n){\n    cin>>v;\n    bool found = 0;\n    fore(e,grp){\n      if(isper(e.ft*v)){\n        e.sd++;\n        found = 1;\n        break;\n      }\n    }\n    if(!found) grp.eb(v,1);\n  }\n  int c = 0;\n  int sz = 0;\n  f[0][0] = 1;\n  fore(e,grp){\n    c ^= 1;\n    int cur = e.sd;\n    rep(i,sz+cur)f[c][i]=0;\n    FOR(sg,1,min(cur, sz+1)) FOR(bad,0,max(0,sz-1)) FOR(badsg,0,min(bad,sg)){\n        f[c][cur-sg+bad-badsg] += f[!c][bad] * P[cur] * C[cur-1][sg-1] * C[bad][badsg] * C[sz+1-bad][sg-badsg];\n      }\n    }\n    sz += cur;\n  }\n  cout<>TC;\n#endif\n  FOR(TI,1,TC) {\n    //cout << \"Case #\" << TI << \": \";\n    solve();\n  }\n\n  return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "40716539e93ee901200a37bdb4470722", "src_uid": "e00c5fde478d36c90b17f5df18fb3ed1", "difficulty": 2500.0}
    {"lang": "MS C++", "source_code": "#include \n#include \n#include \n\n#define forn(i, n) for (int i = 0; i < int(n); i++)\n#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)\n#define fore(i, l, r) for (int i = int(l); i < int(r); i++)\n#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))\n#define all(a) (a).begin(), (a).end()\n#define sz(a) int((a).size())\n#define pb(a) push_back(a)\n#define mp(x, y) make_pair((x), (y))\n#define x first\n#define y second\n\nusing namespace std;\n\ntypedef long long li;\ntypedef long double ld;\ntypedef pair pt;\n\ntemplate inline X abs(const X& a) { return a < 0? -a: a; }\ntemplate inline X sqr(const X& a) { return a * a; }\n\nconst int INF = int(1e9);\nconst li INF64 = li(1e18);\nconst ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;\n\nint a, b;\n\ninline bool read() {\n\treturn !!(cin >> a >> b);\n}\n\nint c[] = { 6, 2, 5, 5, 4, 5, 6, 3, 7, 6 };\n\ninline void solve() {\n\tint ans = 0;\n\tfore(i, a, b + 1) {\n\t\tint x = i;\n\t\twhile (x) {\n\t\t\tans += c[x % 10];\n\t\t\tx /= 10;\n\t\t}\n\t}\n\tcout << ans << endl;\n}\n\nint main() {\n#ifdef SU1\n    assert(freopen(\"input.txt\", \"rt\", stdin));\n    //assert(freopen(\"output.txt\", \"wt\", stdout));\n#endif\n    \n    cout << setprecision(10) << fixed;\n    cerr << setprecision(5) << fixed;\n\n    while (read()) {\n\t\tsolve();\n\t\t//break;\n\t}\n\t\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "78653e106390558122eec9a30a3a74aa", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint getSegmentCountOfAString(vector&vec,string &integer){\n\tint sum = 0;\n\tfor(int i = 0;ivec,)\n\nint main(){\n\tint a,b;\n\tcin>>a>>b;\n\tlong long int sum = 0;\n\tvectorsegmentCountOfIntegers{6,2,5,5,4,5,6,3,7,6};\n\tfor(int i = a;i<=b;i++){\n\t\tsum += getSegmentCount(segmentCountOfIntegers,to_string(i));\n\t}\n\tcout<\n\nusing namespace std;\n\nint countSegmentsOfADigit(int digit)\n{\n\tswitch (digit)\n\t{\n\tcase 0:\n\t\treturn 6;\n\tcase 1:\n\t\treturn 2;\n\tcase 2:\n\t\treturn 5;\n\tcase 3:\n\t\treturn 5;\n\tcase 4:\n\t\treturn 4;\n\tcase 5:\n\t\treturn 5;\n\tcase 6:\n\t\treturn 6;\n\tcase 7:\n\t\treturn 3;\n\tcase 8:\n\t\treturn 7;\n\tcase 9:\n\t\treturn 6;\n\tdefault:\n\t\tbreak;\n\t}\n}\n\nint countDigits(int n)\n{\n\tint result = 0;\n\twhile (n > 0)\n\t{\n\t\tresult += 1;\n\t\tn /= 10;\n\t}\n\treturn result;\n}\n\nint countSegments(int n)\n{\n\tif (n == 0)\n\t\treturn 0;\n\tint count = countDigits(n);\n\tint k = pow(10, count);\n\tint result = 0;\n\tint previousDigit = 0, currentDigit;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tk /= 10;\n\t\tcurrentDigit = n / k;\n\t\tn = n%k;\n\t\tfor (int j = 0; j <= 9; j++)\n\t\t{\n\t\t\tif (j == 0 || j>currentDigit)\n\t\t\t\tresult += countSegmentsOfADigit(j)*previousDigit*k;\n\t\t\telse if (j == currentDigit)\n\t\t\t\tresult += countSegmentsOfADigit(j)*previousDigit + countSegmentsOfADigit(j)*(n + 1);\n\t\t\telse\n\t\t\t\tresult += countSegmentsOfADigit(j)*(previousDigit + 1);\n\t\t}\n\t\tpreviousDigit = currentDigit;\n\t}\n\treturn result;\n}\n\nvoid main()\n{\n\tint a, b;\n\tcin >> a >> b;\t\n\tint printedSegments = countSegments(b) - countSegments(a - 1);\n\n\tcout << printedSegments;\n\n\tcin.get();\n\tcin.get();\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "83b0e695fbb60b11fe43956a42f04911", "src_uid": "1193de6f80a9feee8522a404d16425b9", "difficulty": 1000.0}
    {"lang": "GNU C++", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint rr[100001][2];\nbool acc[100001], not[100001];\nset s1;\nint tot,n,m;\nchar s[10];\n\nint main(){\n    int last=-1,tt;\n    scanf(\"%d %d\", &n, &m);\n    for(int i=1;i<=m;i++){\n        scanf(\"%s %d\", s, &rr[i][1]), rr[i][0]=(s[0]=='-')?-1:1;\n        if (!not[rr[i][1]]) not[rr[i][1]]=1, tot++;\n        if(!acc[rr[i][1]]&&rr[i][0]==-1) last=rr[i][1];\n        else acc[rr[i][1]]+=rr[i][0];\n    }\n    if(last!=-1) rr[0][0]=1, rr[0][1]=rr[last][1];\n    memset(acc, 0, sizeof(acc));\n    if(last==-1) tt=1;\n    else tt=0;\n    int check=1;\n    for(int i=tt;i<=m;i++){\n        if(rr[i][0]==1) s1.insert(rr[i][1]);\n        else if(s1.find(rr[i][1])!=s1.end()) s1.erase(rr[i][1]);\n        if(s1.find(rr[tt][1])==s1.end()&&s1.size()!=0){\n            check=0;\n            break;\n        }\n    }\n    if(check) not[rr[tt][1]]=0, tot--;\n    \n    printf(\"%d\\n\", n-tot);\n    for(int i=1;i<=n;i++)\n        if(!not[i])\n            printf(\"%d \", i);\n    //system(\"pause\");\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cc0583afdf9a7e287358a91a96c414a9", "src_uid": "a3a337c7b919e7dfd7ff45ebf59681b5", "difficulty": 1800.0}
    {"lang": "GNU C++11", "source_code": "#include \nconst int maxn = 100001;\nbool a[maxn];\nint res[maxn];\nint q[maxn];\nbool x[maxn];\n\nint main()\n{\n    int n, m, l = 0, d = 0;\n    char c;\n    scanf(\"%d%d\",&n,&m);\n    for(int i = 0; i < m; i ++){\n        scanf(\"%c%d\",&c,&q[i]);\n        q[i] *= c == '+'?1:-1;\n        res[q[i] > 0 ? q[i] : -q[i]] = 1;\n        if(q[i] > 0){\n            x[q[i]] = true;\n        }else{\n            if(!x[-q[i]]){\n                a[-q[i]] = 1;\n                l++;\n            }\n        }\n    }\n    if(l == 0){\n        l ++;\n        a[q[d++]] = 1;\n    }\n    int lb = 0;\n    for(int i = 1; i <= n; i ++){\n        if(res[i] == 1){\n            if(a[i]) lb ++;\n            else res[i] = 2;\n        }\n    }\n    for(int i = d; i < m; i ++){\n        if(q[i] > 0){\n            lb ++;\n        }else{\n            if(a[-q[i]] == 1){\n                if(lb == 1 && (i == m-1 || q[i+1] == -q[i]));\n                else{\n                    res[-q[i]] = 2;\n                    a[-q[i]] = 0;\n                }\n            }\n            lb --;\n        }\n    }\n    lb = 0;\n    for(int i = 1; i <= n; i ++){\n        if(res[i] != 2) lb ++;\n    }\n    printf(\"%d\\n\", lb);\n    for(int i = 1; i <= n; i ++)\n        if(res[i] != 2)\n            printf(\"%d \", i);\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ddfe300d9b34ccf200d1654e49ae95b4", "src_uid": "a3a337c7b919e7dfd7ff45ebf59681b5", "difficulty": 1800.0}
    {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint log_op[111111];\nint log_man[111111];\n\nint init_state[111111]; // 0 unk 1 in 2 out\nbool meet[111111];\n\nbool bye[111111];\n\nint main(void)\n{\n\tint n = 0;\n\tint m = 0;\n\tscanf(\"%d %d\",&n,&m);\n\tfor(int i = 0;i < m;i++)\n\t{\n\t\tchar op[16] = {0};\n\t\tint man = 0;\n\t\tscanf(\"%s %d\",op,&man);\n\t\tlog_op[i] = op[0];\n\t\tlog_man[i] = man;\n\n\t\tif(!meet[man])\n\t\t{\n\t\t\tif(log_op[i] == '+') init_state[man] = 2;\n\t\t\telse init_state[man] = 1;\n\t\t\tmeet[man] = true;\n\t\t}\n\t}\n\n\tset here;\n\tset not;\n\tset banned;\n\tfor(int i = 1;i <= n;i++)\n\t{\n\t\tif(init_state[i] == 1) here.insert(i);\n\t\telse if(init_state[i] == 2) not.insert(i);\n\t}\n\tif(here.size() != 0)\n\t{\n\t\tfor(auto x: not)\n\t\t{\n\t\t\tbanned.insert(x);\n\t\t}\n\t\tnot.clear();\n\t}\n\tint max_online = here.size();\n\tfor(int i = 0;i < m;i++)\n\t{\n\t\tif(log_op[i] == '+')\n\t\t{\n\t\t\tif(!here.size() && i && log_op[i-1] == '-' && log_man[i-1] == log_man[i])\n\t\t\t{\n\t\t\t\there.insert(log_man[i]);\n\t\t\t\tnot.erase(log_man[i]);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif(here.size() || max_online) banned.insert(log_man[i]);\n\t\t\tif(not.size())\n\t\t\t{\n\t\t\t\tfor(auto& x: not) if(x != log_man[i]) banned.insert(x);\n\t\t\t\tnot.clear();\n\t\t\t}\n\t\t\there.insert(log_man[i]);\n\t\t\tmax_online = max(max_online, here.size());\n\t\t}\n\t\telse if(log_op[i] == '-')\n\t\t{\n\t\t\there.erase(log_man[i]);\n\t\t\tif(here.size()) banned.insert(log_man[i]);\n\t\t\telse if(!banned.count(log_man[i]))\n\t\t\t{\n\t\t\t\tnot.insert(log_man[i]);\n\t\t\t}\n\t\t}\n\t}\n\tvector candidate;\n\tfor(int i = 1;i <= n;i++) if(!banned.count(i)) candidate.push_back(i);\n\tprintf(\"%d\\n\",candidate.size());\n\tfor(auto& x: candidate) printf(\"%d \",x);\n\tputs(\"\");\n\twhile(getchar() != EOF);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5d92f5bc6a9540152f7ccb8690a4461f", "src_uid": "a3a337c7b919e7dfd7ff45ebf59681b5", "difficulty": 1800.0}
    {"lang": "GNU C++11", "source_code": "#include \n#define MOD 1000000007\nusing namespace std;\ntypedef long long ll;\n\nint n, m;\n\nint st[100001];\nbool l[100001];\n\npair q[100001];\n\nvector nr;\n\nint main()\n{\n\tcin >> n >> m;\n\tint cnt = 0;\n\tfor (int i = 1; i <= n; ++i) {\n\t\tst[i] = 2;\n\t\tl[i] = true;\n\t}\n\tfor (int i = 0; i < m; ++i) {\n\t\tchar c;\n\t\tint d;\n\t\tscanf(\" %c %d\", &c, &d);\n\n\t\tq[i] = {c, d};\n\t\tif (st[d] == 2) {\n\t\t\tif (c == '+') {\n\t\t\t\tst[d] = 0;\n\t\t\t\tnr.push_back(d);\n\t\t\t} else {\n\t\t\t\tst[d] = 1;\n\t\t\t\t++cnt;\n\t\t\t}\n\t\t}\n\t}\n\t//cout << cnt << endl;\n\tif (cnt != 0) {\n\t\tfor (int i = 0; i < nr.size(); ++i) {\n\t\t\tl[nr[j]] = false;\n\t\t}\n\t\tnr.clear();\n\t}\n\tfor (int i = 0; i < m; ++i) {\n\t\tchar c = q[i].first;\n\t\tint d = q[i].second;\n\t\tif (c == '+') {\n\t\t\tfor (int j = 0; j < nr.size(); ++j) {\n\t\t\t\tif (nr[j] != d) {\n\t\t\t\t\tl[nr[j]] = false;\n\t\t\t\t}\n\t\t\t}\n\t\t\tnr.clear();\n\t\t\tif (cnt != 0) {\n\t\t\t\tl[d] = false;\n\t\t\t}\n\t\t\t++cnt;\n\t\t} else {\n\t\t\t--cnt;\n\t\t\tif (cnt != 0) {\n\t\t\t\tl[d] = false;\n\t\t\t} else if (l[d]) {\n\t\t\t\tnr.push_back(d);\n\t\t\t}\n\t\t}\n\t}\n\tvector sol;\n\tfor (int i = 1; i <= n; ++i) {\n\t\tif (l[i]) {\n\t\t\tsol.push_back(i);\n\t\t}\n\t}\n\tcout << sol.size() << endl;\n\tfor (int i = 0; i < sol.size(); ++i) {\n\t\tprintf(\"%d \", sol[i]);\n\t}\n\tcout << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f501837c3c623c8c6c7b2fb3c38689c2", "src_uid": "a3a337c7b919e7dfd7ff45ebf59681b5", "difficulty": 1800.0}
    {"lang": "GNU C++17", "source_code": "#include\r\nusing namespace std;\r\n\r\n\r\nint main()\r\n{\r\n    int h,w;\r\n    int c[h][w];\r\n    for(int i=0;i>c[i][j];\r\n        }\r\n    }\r\n    int i=0, ctr=0;\r\n        for(int j=0;j\r\nusing namespace std;\r\n#define fast ios_base ::sync_with_stdio(0); cin.tie(0); cout.tie(0);\r\n#define   fi(a,b) for(int i=a;i vi;\r\ntypedef   vector< pair > vii;\r\ntypedef   vector vl;\r\ntypedef   pair pii;\r\ntypedef   pair pll;\r\ntypedef   vector< pair > vll;\r\n//int dx[]={1,0,-1,0};\r\n//int dy[]={0,1,0,-1};\r\n//int dx[]={-1,0,1,1,1,0,-1,-1};\r\n//int dy[]={-1,-1,-1,0,1,1,1,0};\r\nmapmp;\r\nll gcd(ll a, ll b) { \r\n    if(a>r>>c;\r\n   string cake[r];\r\n   for(int i=0;i>cake[i];\r\n   }\r\n   int ctr=0;\r\n   for(int i=0;i\r\n#define ll long long\r\n#define rep(i, l, r) for(ll i = (l); i <= (r); i++)\r\n#define req(i, r, l) for(ll i = (r); i >= (l); i--)\r\nusing namespace std;\r\nint n, m;\r\nchar s[12][12];\r\ninline ll find(ll& st, ll& st) {\r\n\tll mn = INT_MAX, x, y;\r\n\trep(i, st, n) rep(j, st, n) if((i>st||j>ch)&&(s[i][j]=='*'&&i+j>n>>m;\r\n\trep(i,1,n)cin>>(s[i]+1);\r\n\tll res=(s[1][1]=='*'),st=1,ch=1;\r\n\twif(!find(st, ch)) ++res;\r\n\treturn cout<\r\n\r\nusing namespace std;\r\n\r\nint main()\r\n{\r\n    int H, W;\r\n    cin >> H >> W;\r\n\r\n    int i, j;\r\n    char cake[5][5];\r\n    for (i = 0; i < 5; i++) {\r\n        for (j = 0; i < 5; j++) {\r\n            cake[i][j] = '0';\r\n        }\r\n    }\r\n    for (i = 0; i < H; i++) {\r\n        for (j = 0; j < W; j++) {\r\n            cin >> cake[i][j];\r\n        }\r\n    }\r\n\r\n    int count = 0;\r\n    i = j = 0;\r\n    while (true) {\r\n        if (cake[i][j] == '*') {\r\n            count++;\r\n        }\r\n        \r\n        if (i == H - 1 && j == W - 1) {\r\n            break;\r\n        }\r\n        else if (i == j) {\r\n            if (i < H - 1) {\r\n                i++;\r\n            }\r\n            else {\r\n                j++;\r\n            }\r\n        }\r\n        else {\r\n            if (j < W - 1) {\r\n                j++;\r\n            }\r\n            else {\r\n                i++;\r\n            }\r\n        }\r\n    }\r\n\r\n    cout << count << endl;\r\n    \r\n    return 0;\r\n}\r\n\r\n// Run program: Ctrl + F5 or Debug > Start Without Debugging menu\r\n// Debug program: F5 or Debug > Start Debugging menu\r\n\r\n// Tips for Getting Started: \r\n//   1. Use the Solution Explorer window to add/manage files\r\n//   2. Use the Team Explorer window to connect to source control\r\n//   3. Use the Output window to see build output and other messages\r\n//   4. Use the Error List window to view errors\r\n//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project\r\n//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "539acd043cbfc24da1df7a2415a0d6c6", "src_uid": "f985d7a6e7650a9b855a4cef26fd9b0d", "difficulty": 1800.0}
    {"lang": "GNU C++14", "source_code": "\ufeff\ufeff#ifndef LOCAL\n#pragma GCC optimize(\"Ofast\")\n#endif\n\n#define _SCL_SECURE_NO_WARNINGS\n#define _CRT_SECURE_NO_WARNINGS\n\n#define push_back pb\n#define make_pair mp\n#define first x\n#define second y\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef LOCAL\n//#include \n#endif //LOCAL \nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\n\n#define speedup cout.tie(nullptr);cin.tie(nullptr);ios_base::sync_with_stdio(false)\n#define coutdouble cout< inline ostream &operator << (ostream &_out, const pair &_p) { _out << _p.first << \" \" << _p.second; return _out; }\ntemplate inline istream &operator >> (istream &_in, pair &_p) { _in >> _p.first >> _p.second; return _in; }\ntemplate inline ostream &operator << (ostream &_out, const vector &_v) { if (_v.empty()) return _out; _out << _v.front(); for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) _out << ' ' << *_it; return _out; }\ntemplate inline istream &operator >> (istream &_in, vector &_v) { for (auto &_i : _v) _in >> _i; return _in; }\ntemplate inline ostream &operator << (ostream &_out, const set &_s) { if (_s.empty()) return _out; _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) _out << ' ' << *_it; return _out; }\ntemplate inline ostream &operator << (ostream &_out, const multiset &_s) { if (_s.empty()) return _out; _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) _out << ' ' << *_it; return _out; }\ntemplate inline ostream &operator << (ostream &_out, const unordered_set &_s) { if (_s.empty()) return _out; _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) _out << ' ' << *_it; return _out; }\ntemplate inline ostream &operator << (ostream &_out, const unordered_multiset &_s) { if (_s.empty()) return _out; _out << *_s.begin(); for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) _out << ' ' << *_it; return _out; }\ntemplate inline ostream &operator << (ostream &_out, const map &_m) { if (_m.empty()) return _out; _out << '(' << _m.begin()->first << \": \" << _m.begin()->second << ')'; for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) _out << \", (\" << _it->first << \": \" << _it->second << ')'; return _out; }\ntemplate inline ostream &operator << (ostream &_out, const unordered_map &_m) { if (_m.empty()) return _out; _out << '(' << _m.begin()->first << \": \" << _m.begin()->second << ')'; for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) _out << \", (\" << _it->first << \": \" << _it->second << ')'; return _out; }\n/*--------------------------------------------------IO_FILES-----------------------------------------------*/\nconst char * infile =\n#ifdef LOCAL\n\"input.txt\"\n#else\n\"\"\n#endif //LOCAL\n;\nconst char * outfile =\n#ifdef LOCAL\n\"\"\n#else\n\"\"\n#endif //LOCAL\n;\n\n/*-------------------------------------------------ALLOCATOR----------------------------------------------*/\n//#define ALLOC_LOCAL\n#ifdef ALLOC_LOCAL\nconst int ML_ = 128;\nchar mem_[ML_ * 1000000];\nsize_t ptr = 0;\nvoid * operator new(size_t cnt) { if (ptr + cnt < sizeof mem_) { ptr += cnt; return  mem_ + ptr - cnt; } else { ptr = cnt; return mem_; } }\nvoid operator delete(void *) {}\n#endif //ALLOC_LOCAL\n/*----------------------------------------------------MATHS------------------------------------------------*/\ninline ll gcd(ll a, ll b) { while (b) { a %= b; swap(a, b); } return a; }\ninline ll lcm(ll a, ll b) { return a*b / gcd(a, b); }\ninline ll pwm(ll xx, ll pow, ll MD = MOD) { ll mlt = 1; while (pow) { if (pow & 1) { mlt *= xx; xx *= xx; pow >>= 1; xx %= MD; mlt %= MD; } else { pow >>= 1; xx *= xx; xx %= MD; } }return mlt; }\ninline ll pw(ll xx, int pow) { ll mlt = 1; while (pow) { if (pow & 1) { mlt *= xx; xx *= xx; pow >>= 1; } else { pow >>= 1; xx *= xx; } }return mlt; }\ninline ll inv(ll r) { return pwm(r, RMOD); }\n/*--------------------------------------------------------------------------------------------------------*/\n\n\n\ninline void solve(ld tt) {\n    ll n;\n    cin >> n;\n    n = (n % 360 + 360) % 360;\n    int ans = 0;\n    while (abs(n) > 45 && abs(n) < 315) {\n        ++ans;\n        n -= 90;\n    }\n    cout << ans << endl;\n\n}\n\nint main() {\n    ld tt = clock();\n\n    if (*infile != '\\0')\n        freopen(infile, \"r\", stdin);\n    if (*outfile != '\\0')\n        freopen(outfile, \"w\", stdout);\n\n    speedup;\n    coutdouble;\n\n    //int tst = 1; \n    //cin >> tst;\n    //scanf(\"%d\", &tst);\n    //while (tst-- > 0) {\n    //while(true)\n    solve(tt);\n    //cout << \"/*-----------------*/\\n\";\n    //}\n\n#ifdef LOCAL\n    cout << \"Time: \" << ((ld)clock() - tt) / CLOCKS_PER_SEC << endl;\n    while (true);\n#endif // LOCAL\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7de921ce57fecb80a29a5d3e7fc693da", "src_uid": "509db9cb6156b692557ba874a09f150e", "difficulty": 1800.0}
    {"lang": "GNU C++11", "source_code": "#include \nint main() {\n    long long n; cin >> n;\n    n = (n + (ll)3.6e18) % 360;\n    if (n <= 45) printf(\"0\");\n    else if (n <= 135) printf(\"1\");\n    else if (n <= 225) printf(\"2\");\n    else if (n < 315) printf(\"3\");\n    else printf(\"0\");\n    printf(\"\\n\");\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7a9438474eb302ffd50abb66ec33827d", "src_uid": "509db9cb6156b692557ba874a09f150e", "difficulty": 1800.0}
    {"lang": "GNU C++", "source_code": "#include\n//#include\nusing namespace std;\nint shit(int a)\n{\n\tif(a>180)\n\t\treturn 360-a;\n\telse\n\t\treturn a;\n}\nint abs(int a)\n{\n\tif(a<0)\n\t\ta=-1*a;\n\treturn a;\n}\nbool mine(int a,int b,int c,int d)\n{\n\ta=shit(a);\n\t\tb=shit(b);\n\tc=shit(c);\n\td=shit(d);\n\n\treturn (a<=b)&&(a<=c)&&(a<=d);\n}\nint main()\n{\n\tint corner;\n\tcin>>corner;\n\tif(mine(\n\t\tabs(corner)%360,\n\tabs(corner-90)%360,\n\tabs(corner-180)%360,\n\tabs(corner-270)%360\n\t))\n\tcout<<\"0\"<\nint main(){\n    -45 ~ 0 0\n    -134 ~ -46 3\n    -135 ~ -224 2\n    -225 ~ -314 1\n    long long n;\n    scanf(\"%lld\",&n);\n    if(n<0){\n        n=-n;\n        n%=360;\n        if(n<=45) printf(\"0\");\n        else if(n<=134) printf(\"3\");\n        else if(n<=224) printf(\"2\");\n        else if(n<=314) printf(\"1\");\n        else printf(\"0\");\n    }else{\n        n%=360;\n        if(n<=45) printf(\"0\");\n        else if(n<=135) printf(\"1\");\n        else if(n<=225) printf(\"2\");\n        else if(n<=314) printf(\"3\");\n        else printf(\"0\");\n    }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "114996cb41a1a3587a4b9d1bcb933a37", "src_uid": "509db9cb6156b692557ba874a09f150e", "difficulty": 1800.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nchar s[105],w[105];\nbool f;\nint k;\nint main()\n{\n    f=1;\n    cin>>s;\n    int l=strlen(s);\n    for(int i=0;i\n#include \n#include \n\nusing namespace std;\n\nint n, a[100];\nstring s;\n\nint main()\n{\n    cin >> s;\n    for(int i=0; i<100; i++) a[i]=0;\n    for(int i=2; i\n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n    char Arr[100], Result[100];\n    gets(Arr);\n    Result[0] = Arr[0];\n    int i = 1, j = 1;\n    for(i, j; i < strlen(Arr)-2; i, j)\n    {\n        if((Arr[i] == 'd') and (Arr[i+1] == 'o') and (Arr[i+2] == 't'))\n        {\n            Result[j] = '.';\n            i+=3; j++;\n        }\n        else if((Arr[i] == 'a') and (Arr[i+1] == 't'))\n        {\n            Result[j] = '@';\n            i+=2; j++;\n        }\n        else\n        {\n            Result[j] = Arr[i];\n            i++; j++;\n        }\n    }\n\n    Result[j] = Arr[i];\n    i++; j++;\n    Result[j] = Arr[i];\n    Result[j+1] = \"\\0\";\n    puts(Result);\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "71979cd6ddbc59faa3eede67540a9ee5", "src_uid": "a11c9679d8e2dca51be17d466202df6e", "difficulty": 1300.0}
    {"lang": "GNU C++17", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nstring s,str1;\ns+=char(1);\ns+=char(1);\ns+=char(1); \nstr1+=s[0];\nint main()\n{\n\tcin>>s;\n\tbool q=false;\n\tfor(int i=1;i\nusing namespace std;\nint main()\n{\n   int i,j,total,k;\n   string str1,str2;\n   while(cin>>str1)\n   {\n     cin>>str2;\n     total=k=0;\n     int position=1;\n     for(i=0;i\nusing namespace std;\nint main()\n{\n    string s1,s2; cin>>s1>>s2;\n    int i=0,j=0;\n    while(j!=s2.length())\n    {\n        if(s1[i]==s2[i])\n        {\n            i++; j++;\n        }\n        else j++;\n    }\n    cout<\nchar a[102],i,j=51;main(){for(gets(gets(a)+j);a[j];i+=a[i]==a[j++];);printf(\"%d\",i+1);}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e13b67f750f8d74cf297d25217895926", "src_uid": "f5a907d6d35390b1fb11c8ce247d0252", "difficulty": 800.0}
    {"lang": "Clang++17 Diagnostics", "source_code": "#include\nusing namespace std;\nmain(){\nstring s,t;\ngetline(cin,s);\ngetline(cin,t);\nint l=t.size(),j=0;\nfor(int i=0;i\n#include \n#include \n#include \n#include \n#define N 2010\n#define c(x) a[x].a\n#define For(i,x,y) for (i=x;i<=y;i++)\nusing namespace std;\nstruct ww {\n\tvector a;\n\tint ty,flag,cov;\n} a[N*N];\nint i,j,k,n,m,t,an;\nint re[N],s[N],size[N];\nchar p[N][N];\ninline void Cov(int x) {\n\tif (a[x].ty!=2||a[x].flag) return;\n\ta[x].cov^=1;\n\treverse(c(x).begin(),c(x).end());\n}\ninline void renew(int x) {\n\tint i;\n\tif (!a[x].cov) return;\n\ta[x].cov=0;\n\tfor (i=0;i quan,kong,zi;\n\t\tfor (i=0;i2) fail();\n\t\tif (zi.size()==2&&y) fail();\n\t\tfor (i=0;i\n#include\n#include\n#include\n#include\n#define maxc 510\n#define maxn maxc*10\nusing namespace std;\nint son[maxn*3],l=751,r=750;\nint isP[maxn];\nint n,rt,top;\nint to[maxn],next[maxn],start[maxn],father[maxn];\nint pool_p[maxn],pool_e[maxn],n_p,n_e;\nint have[maxn][2];\nint newnode()\n{\n    int p=pool_p[n_p--];\n    isP[p]=true;\n    return p;\n}\nvoid make(int a,int b)\n{\n    int x=pool_e[n_e--];\n    to[x]=b,next[x]=start[a],start[a]=x,father[b]=a;\n}\nvoid clean(int p)\n{\n    for(int &i=start[p];i;i=next[i])\n        pool_e[++n_e]=i;\n}\nvoid Reverse(int p)\n{\n    static int stack[maxn];\n    int top=0;\n    for(int &i=start[p];i;i=next[i])\n        stack[++top]=i;\n    start[p]=stack[top];\n    for(;top;--top)\n        next[stack[top]]=stack[top-1];\n}\nbool check(int p,int x)\n{\n    /*\n        x=0 : none->half->all\n        x=1 : all->half->none\n    */\n    int a;\n    for(a=start[p];a&&!have[to[a]][x^1];a=next[a]);\n    for(;a&&have[to[a]][0]&&have[to[a]][1];a=next[a]);\n    for(;a;a=next[a])\n        if(have[to[a]][x])\n            return false;\n    return true;\n}\nint Shape(int p)\n{\n    if(check(p,0))\n        return 0;\n    if(check(p,1))\n        return 1;\n    return 2;\n}\nvoid Fail()\n{\n    printf(\"NO\\n\");\n    exit(0);\n}\nvoid print(int p,int *ans,int &n)\n{\n    if(!start[p])\n        ans[++n]=p;\n    for(int i=start[p];i;i=next[i])\n        print(to[i],ans,n);\n}\nvoid print(int p)\n{\n    if(p<=n)\n        printf(\"I'm %d \",p);\n    printf(\"(%d %c): \",p,isP[p]?'P':'Q');\n    for(int i=start[p];i;i=next[i])\n        printf(\"%d \",to[i]);\n    printf(\"\\n\");\n    for(int i=start[p];i;i=next[i])\n        print(to[i]);\n}\nvoid work(int p,int x)\n{\n    /*\n        x=0 : t_L\n        x=1 : t_R\n    */\n    static int p_none[maxn],p_half[maxn],p_all[maxn];\n    int n1,n2,n3;\n    if(isP[p])\n    {\n        n1=0,n2=0,n3=0;\n        for(int i=start[p];i;i=next[i])\n        {\n            int x=to[i];\n            if(have[x][0]&&!have[x][1])\n                p_none[++n1]=x;\n            if(have[x][0]&&have[x][1])\n                p_half[++n2]=x;\n            if(!have[x][0]&&have[x][1])\n                p_all[++n3]=x;\n        }\n        if(n2>1)\n            Fail();\n        clean(p);\n        if(x==0)\n        {\n            for(int i=n3;i>=1;--i)\n                make(p,p_all[i]);\n            for(int i=n2;i>=1;--i)\n                make(p,p_half[i]);\n            for(int i=n1;i>=1;--i)\n                make(p,p_none[i]);\n            if(n2)\n                work(p_half[1],0);\n        }\n        else\n        {\n            for(int i=n1;i>=1;--i)\n                make(p,p_none[i]);\n            for(int i=n2;i>=1;--i)\n                make(p,p_half[i]);\n            for(int i=n3;i>=1;--i)\n                make(p,p_all[i]);\n            if(n2)\n                work(p_half[1],1);\n        }\n        n1=0,n2=0,n3=0;\n        for(int i=start[p];i;i=next[i])\n        {\n            int x=to[i];\n            if(have[x][0]&&!have[x][1])\n                p_none[++n1]=x;\n            if(have[x][0]&&have[x][1])\n                p_half[++n2]=x;\n            if(!have[x][0]&&have[x][1])\n                p_all[++n3]=x;\n        }\n        clean(p);\n        int u=n1>1?newnode():p,v=n3>1?newnode():p;\n        if(x==0)\n        {\n            if(v!=p)\n                make(p,v);\n            for(int i=n3;i>=1;--i)\n                make(v,p_all[i]);\n            for(int i=n2;i>=1;--i)\n                make(p,p_half[i]);\n            for(int i=n1;i>=1;--i)\n                make(u,p_none[i]);\n            if(u!=p)\n                make(p,u);\n        }\n        else\n        {\n            if(u!=p)\n                make(p,u);\n            for(int i=n3;i>=1;--i)\n                make(u,p_none[i]);\n            for(int i=n2;i>=1;--i)\n                make(p,p_half[i]);\n            for(int i=n1;i>=1;--i)\n                make(v,p_all[i]);\n            if(v!=p)\n                make(p,v);\n        }\n        isP[p]=false;\n    }\n    else\n    {\n        int t=Shape(p);\n        if(t==2)\n            Fail();\n        if(x^t)\n            Reverse(p);\n        int c=0;\n        for(int i=start[p];i;i=next[i])\n            if(have[to[i]][0]&&have[to[i]][1])\n            {\n                if(c)\n                    Fail();\n                ++c,work(c,x);\n            }\n        int a;\n        for(a=start[p];a&&(!have[to[a]][0]||!have[to[a]][1]);a=next[a])\n            son[--l]=to[a];\n        for(;a&&have[to[a]][0]&&have[to[a]][1];a=next[a]);\n        for(;a;a=next[a])\n            son[++r]=to[a];\n        clean(p);\n        if(father[p]!=rt&&!isP[father[p]])\n            pool_p[++n_p]=p;\n        else\n        {\n            for(int i=r;i>=l;--i)\n                make(p,son[i]);\n            l=751,r=750;\n        }\n    }\n}\nvoid Insert(int *a,int m)\n{\n    static int p_none[maxn],p_half[maxn],p_all[maxn];\n    static bool col[maxc];\n    memset(col,false,sizeof(col));\n    for(int i=1;i<=m;++i)\n        col[a[i]]=true;\n    static int queue[maxn],pos[maxc];\n    int front=0,rear=1;\n    queue[rear]=rt;\n    while(front=1;--i)\n    {\n        int p=queue[i];\n        if(!start[p])\n            have[p][col[p]]=1;\n        for(int j=start[p];j;j=next[j])\n            for(int k=0;k<=1;++k)\n                have[p][k]|=have[to[j]][k];\n    }\n    if(!isP[rt])\n    {\n        int a;\n        for(a=start[rt];a&&!have[to[a]][1];a=next[a]);\n        if(have[to[a]][1]&&have[to[a]][0])\n            work(to[a],0),a=next[a];\n        for(;a&&have[to[a]][1]&&!have[to[a]][0];a=next[a]);\n        if(have[to[a]][1]&&have[to[a]][0])\n            work(to[a],1),a=next[a];\n        for(;a;a=next[a])\n            if(have[to[a]][1])\n                Fail();\n        int nson=0;\n        for(a=start[rt];a&&!have[to[a]][1];a=next[a])\n            son[++nson]=to[a];\n        if(have[to[a]][1]&&have[to[a]][0])\n        {\n            for(int j=start[to[a]];j;j=next[j])\n                son[++nson]=to[j];\n            clean(to[a]),pool_p[++n_p]=to[a],a=next[a];\n        }\n        for(;a&&have[to[a]][1]&&!have[to[a]][0];a=next[a])\n            son[++nson]=to[a];\n        if(have[to[a]][1]&&have[to[a]][0])\n        {\n            for(int j=start[to[a]];j;j=next[j])\n                son[++nson]=to[j];\n            clean(to[a]),pool_p[++n_p]=to[a],a=next[a];\n        }\n        for(;a;a=next[a])\n            son[++nson]=to[a];\n        clean(rt);\n        for(int i=nson;i>=1;--i)\n            make(rt,son[i]);\n    }\n    else\n    {\n        int n1=0,n2=0,n3=0;\n        for(int i=start[rt];i;i=next[i])\n        {\n            int x=to[i];\n            if(have[x][0]&&!have[x][1])\n                p_none[++n1]=x;\n            if(have[x][0]&&have[x][1])\n                p_half[++n2]=x;\n            if(!have[x][0]&&have[x][1])\n                p_all[++n3]=x;\n        }\n        if(n2>2)\n            Fail();\n        clean(rt);\n        if(n2>1)\n            work(p_half[2],1),make(rt,p_half[2]);\n        for(int i=n3;i>=1;--i)\n            make(rt,p_all[i]);\n        if(n2)\n            work(p_half[1],0),make(rt,p_half[1]);\n        for(int i=n1;i>=1;--i)\n            make(rt,p_none[i]);\n        int u,v;\n        if(n3>1)\n        {\n            clean(rt);\n            u=newnode();\n            if(n2>1)\n                make(rt,p_half[2]);\n            make(rt,u);\n            if(n2)\n                make(rt,p_half[1]);\n            for(int i=n1;i>=1;--i)\n                make(rt,p_none[i]);\n            for(int i=n3;i>=1;--i)\n                make(u,p_all[i]);\n        }\n        if(n2==1&&!n3)\n            return ;\n        if(n2==0)\n            return ;\n        v=newnode();\n        isP[v]=false;\n        for(int i=start[p_half[1]];i;i=next[i])\n            make(v,to[i]);\n        clean(p_half[1]),pool_p[++n_p]=p_half[1];\n        if(n3>0)\n            make(v,n3>1?u:p_all[1]);\n        if(n2>1)\n        {\n            for(int i=start[p_half[2]];i;i=next[i])\n                make(v,to[i]);\n            clean(p_half[2]),pool_p[++n_p]=p_half[2];\n        }\n        Reverse(v);\n        clean(rt);\n        if(!n1)\n            pool_p[++n_p]=rt,rt=v;\n        else\n        {\n            for(int i=n1;i>=1;--i)\n                make(rt,p_none[i]);\n            make(rt,v);\n        }\n    }\n}\nvoid read()\n{\n    scanf(\"%d\",&n);\n    for(int i=10*n;i>=1;--i)\n        pool_p[++n_p]=i,pool_e[++n_e]=i;\n    for(int i=1;i<=n;++i)\n        make(n+1,newnode());\n    rt=newnode();\n    static char map[maxc][maxc];\n    static int a[maxc];\n    for(int i=1;i<=n;++i)\n    {\n        scanf(\"%s\",map[i]+1);\n        int tot=0;\n        for(int j=1;j<=n;++j)\n            if(map[i][j]=='1')\n                a[++tot]=j;\n        Insert(a,tot);\n    }\n    printf(\"YES\\n\");\n    static int ans[maxn];\n    int tot=0;\n    print(rt,ans,tot);\n    for(int i=1;i<=n;++i,printf(\"\\n\"))\n        for(int j=1;j<=n;++j)\n            printf(\"%c\",map[i][ans[j]]);\n}\nint main()\n{\n    read();\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "af5377c8eac9c7d0a22622be501e73c4", "src_uid": "af8d46722e1bd8f7392e5596eaf4def8", "difficulty": 3000.0}
    {"lang": "GNU C++14", "source_code": "#include \n \nlong d[1101][1101]={0},sum[1101]={0},b[1101][1101]={0},num[1101]={0},next[1101]={0},rec[1101]={0},can[1101]={0};\nchar ttt[1101][1101],sss[1101][1101],str[1101][1101]={0},hash[1101][1101]={0},c[1101]={0},used[1101]={0};\nlong n,m,s,tot=1,ans=0,o=0;\n \nlong work(long now)\n{\n   long i,j,k,p,a,cur=++o;\n   char tmp;\n   s=0;\n   for (i=1;i<=n;i++)\n      if (!used[i]&&b[i][now])\n         can[++s]=i;\n   next[now]=now;\n   if (!hash[now][0])\n   {\n      hash[now][0]=1;\n      sum[now]++;\n   }\n   if (!s)\n   {\n      for (p=now;!hash[p][0];p=next[p]);\n      for (i=1;i<=m;i++)\n         if (hash[p][i])\n            rec[++ans]=i;\n      for (i=next[p];i!=p;i=next[i])\n         for (j=1;j<=m;j++)\n            if (hash[i][j])\n               rec[++ans]=j;\n   }\n   else\n   {\n      while (1)\n      {\n         p=0;\n         for (i=1;i<=s;i++)\n            if (!used[can[i]]&&(!p||c[can[i]]||!c[p]&&num[can[i]]>num[p]))\n               p=can[i];\n         if (next[now]!=now&&!c[p])\n            break;\n         used[p]=1;\n         if (!c[p])\n         {\n            next[++tot]=now;\n            next[now]=tot;\n            tmp=(b[p][now]<=sum[now]/2)+'0';\n            for (i=0;i<=m;i++)\n               if (hash[now][i]&&str[p][i]==tmp)\n               {\n                  for (a=1;a<=n;a++)\n                     if (str[a][i]=='1')\n                     {\n                        b[a][now]--;\n                        b[a][tot]++;\n                     }\n                  hash[now][i]=0;\n                  sum[now]--;\n                  hash[tot][i]=1;\n                  sum[tot]++;\n               }\n            for (i=1;i<=s;i++)\n               c[can[i]]|=(b[can[i]][now]&&b[can[i]][tot]);\n         }\n         else\n         {\n            for (i=next[now];(b[p][i]||!b[p][next[i]])&&i!=now;i=next[i]);\n            if (!b[p][i]&&b[p][next[i]])\n               i=next[i];\n            else\n            {\n               for (i=now;b[p][i]==sum[i];i=next[i]);\n               if (b[p][next[i]]!=sum[next[i]])\n                  i=next[i];\n            }\n            j=i;\n            while (b[p][next[j]]&&next[j]!=i)\n               j=next[j];\n            for (k=next[i];k!=j;k=next[k])\n               if (b[p][k]!=sum[k])\n                  return 0;\n            for (k=next[j];k!=i;k=next[k])\n               if (b[p][k])\n                  return 0;\n            if (b[p][i]!=sum[i])\n            {\n               if (b[p][i]<=sum[i]/2)\n               {  \n                  next[++tot]=next[i];\n                  next[i]=tot;\n               }\n               else\n               {\n                  for(k=next[i];next[k]!=i;k=next[k]);\n                  next[++tot]=i;\n                  next[k]=tot;\n               }\n               tmp=(b[p][i]<=sum[i]/2)+'0';\n               for (k=0;k<=m;k++)\n                  if (hash[i][k]&&str[p][k]==tmp)\n                  {\n                     for (a=1;a<=n;a++)\n                        if (str[a][k]=='1')\n                        {\n                           b[a][i]--;\n                           b[a][tot]++;\n                        }\n                     hash[i][k]=0;\n                     sum[i]--;\n                     hash[tot][k]=1;\n                     sum[tot]++;\n                  }\n               for (k=1;k<=s;k++)\n                  c[can[k]]|=(b[can[k]][i]&&b[can[k]][tot]);\n            }\n            if (b[p][j]!=sum[j])\n            {\n               if (b[p][j]<=sum[j]/2)\n               {  \n                  for(k=next[j];next[k]!=j;k=next[k]);\n                  next[++tot]=j;\n                  next[k]=tot;\n               }\n               else\n               {\n                  next[++tot]=next[j];\n                  next[j]=tot;\n               }\n               tmp=(b[p][j]<=sum[j]/2)+'0';\n               for (k=0;k<=m;k++)\n                  if (hash[j][k]&&str[p][k]==tmp)\n                  {\n                     for (a=1;a<=n;a++)\n                        if (str[a][k]=='1')\n                        {\n                           b[a][j]--;\n                           b[a][tot]++;\n                        }\n                     hash[j][k]=0;\n                     sum[j]--;\n                     hash[tot][k]=1;\n                     sum[tot]++;\n                  }\n               for (k=1;k<=s;k++)\n                  c[can[k]]|=(b[can[k]][j]&&b[can[k]][tot]);\n            }\n         }\n      }\n      for (p=now;!hash[p][0];p=next[p]);\n      d[cur][++d[cur][0]]=p;\n      for (i=next[p];i!=p;i=next[i])\n         d[cur][++d[cur][0]]=i;\n      for (i=1;i<=d[cur][0];i++)\n         if (!work(d[cur][i]))\n            return 0;\n   }\n   return 1;\n}\n \nint main()\n{\n   long i,j;\n   scanf(\"%ld\\n\",&n);\n   m=n;\n   for (i=1;i<=n;i++)\n   {\n      str[i][0]='0';\n      gets(str[i]+1);\n      strcpy(ttt[i]+1,str[i]+1);\n      for (j=1;j<=m;j++)\n         if (str[i][j]=='1')\n            num[i]++;\n      b[i][1]=num[i];\n   }\n   sum[1]=m;\n   for (i=1;i<=m;i++)\n      hash[1][i]=1;\n   if (work(1))\n   {\n      puts(\"YES\");\n      for (i=1;i<=m;i++)\n         for (j=1;j<=n;j++)\n            sss[j][i]=ttt[j][rec[i]];\n      for (i=1;i<=n;i++)\n         puts(sss[i]+1);\n   }\n   else\n      puts(\"NO\");\n   return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "262cc52651569dbb81e766b9697f9462", "src_uid": "af8d46722e1bd8f7392e5596eaf4def8", "difficulty": 3000.0}
    {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#pragma comment(linker, \"/STACK:133217728\")\n\nusing namespace std;\n\nint n;\nchar x[555][555];\nint pRow[555];\nint pCol[555];\n\nvoid sortLeft(int row, int l, int r) {\n    \n    vector  a, b;\n    for(int i=l; i<=r; i++)\n        if(x[row][pCol[i]] == '1')\n            a.push_back(pCol[i]);\n        else\n            b.push_back(pCol[i]);\n\n    for(int i=l; i a, b;\n    for(int i=l; i<=r; i++)\n        if(x[row][pCol[i]] == '1')\n            b.push_back(pCol[i]);\n        else\n            a.push_back(pCol[i]);\n\n    for(int i=l; i& R, int a, int b) {\n    for(int i=0; i a;\n    for(int i=pos; i<=r; i++)\n        a.push_back(pCol[i]);\n    for(int i=l; i= n) return ;\n    int ind = -1;\n    int cnt = -1;\n\n    for(int i=row; i cnt) {\n            cnt = tempCnt;\n            ind = i;\n        }\n    }\n    for(int i=0; i R;\n    bool was[555] = {};\n    int count[555] = {};\n\n    vector  > blocks;\n    R.push_back(row);\n\n    for(int Row=row+1; Row < n; Row++) {\n        blocks.clear();\n        int j = l;\n        while(j <= r) {\n            int d = 1;\n            while(j + d <= r && equalBlocks(R, j, j + d)) d++;\n            blocks.push_back(make_pair(j, j + d - 1));\n            j += d;\n        }\n        //for(int i=0; i 0;\n\n            if(cntNonZero > 1) {\n                spRow = i;\n                //cout << \"!!!\" << row << \" \" << spRow << endl;\n                break;\n            }\n        }\n\n        if(spRow == -1)\n            break;\n        was[spRow] = 1;\n        R.push_back(spRow);\n        bool isFull = 1;\n        for(int i=1; i 0 && count[blocks.size()-1] > 0) {\n            for(int j=0; j=0; i--)\n                if(count[i]) {\n                    sortLeft(spRow, blocks[i].first, blocks[i].second);\n                    break;\n                }\n        }\n        \n    }\n\n\n    for(int i=0; i 1)\n                return 0;\n    }\n        \n    return 1;\n}\nint main() {  \n    //freopen(\"in.txt\", \"r\", stdin);\n    //freopen(\"out.txt\", \"w\", stdout);\n    ios_base::sync_with_stdio(0);\n    \n    scanf(\"%d\", &n);\n    for(int i=0; i\n#include \n#include \n#include \n#include \nusing namespace std;\nconst int P=1e9+7;\nconst int maxn=510000;\nint n,K;bool flag;\nchar A[maxn],B[maxn];\n\nnamespace Ninit{\n\tvoid init(){\n\t\tint i;\n\t\tscanf(\"%d%s\",&K,A+1);\n\t\tn=strlen(A+1);\n\t\tfor(i=n;i>=1;--i)\n\t\t\tif(A[i]=='z')A[i]='a';else {++A[i];break;}\n\t\ti?flag=true:flag=false;\n\t}\n}\n\nnamespace Nsolve{\n\tint G[maxn],F[maxn],pw[maxn];\n\tint ok(int y,int l){\n\t\tint x=y-l;\n\t\tif(x<0)return true;\n\t\treturn (G[y]-G[x]*pw[l])*pw[x+1]!=F[y]-F[x];\n\t}\n\tbool dfs(int x,bool y){\n\t\tif(x>n)return true;\n\t\tchar i,c=y?'a':A[x];\n\t\tfor(i=c;i<=min('z',c+1);++i){\n\t\t\tB[x]=i,F[x]=F[x-1]+i*pw[x],G[x]=G[x-1]*P+i;\n\t\t\tif(ok(x,K) && ok(x,K+1) && dfs(x+1,y||i>A[x]))return true;\n\t\t}\n\t\treturn false;\n\t}\n\tvoid solve(){\n\t\tint i;\n\t\tif(!flag)return printf(\"Impossible\\n\"),void();\n\t\tfor(pw[0]=1,i=1;i<=n;++i)pw[i]=pw[i-1]*P;\n\t\tdfs(1,0)?printf(\"%s\\n\",B+1)\n\t\t\t\t:printf(\"Impossible\\n\");\n\t}\n}\n\nint main(){\n\t//freopen(\"A.\u200cin\",\"r\",stdin);\n\tNinit::init();\n\tNsolve::solve();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8a9cf7cc84839ea78f05eb6c4ecdd2cc", "src_uid": "959a274a06219f4a8c061cd6f5b17160", "difficulty": 2800.0}
    {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long ll;\n\nconst int maxx = 4e5 + 5, mod = 1e9 + 7;\n\nvector ids, len;\nint base = 1999, d, n, st1[maxx * 4], st2[maxx * 4], base_pw[maxx];\nstring s;\n\nint merge(int x, int y, int l)\n{\n\treturn (1ll * x * base_pw[l] + y) % mod;\n//\tq = (q + y) % mod;\n//\treturn (int)q; \n}\n\nvoid modify(int x, int k, int id = 1, int l = 0, int r = n)\n{\n\tif (l + 1 == r)\n\t{\n\t\tst1[id] = st2[id] = k;\n\t\treturn;\n\t}\n\tint mid = (l + r) / 2;\n\tif (x < mid) modify(x, k, id * 2, l, mid);\n\telse\t\t modify(x, k, id * 2 + 1, mid, r);\n\tst1[id] = merge(st1[id * 2], st1[id * 2 + 1], r - mid);\n\tst2[id] = merge(st2[id * 2 + 1], st2[id * 2], mid - l);\n}\n\nvoid split(int x, int y, int id = 1, int l = 0, int r = n)\n{\n\tif (x >= r || l >= y) return;\n\tif (x <= l && r <= y)\n\t{\n\t\tids.push_back(id);\n\t\tlen.push_back(r - l);\n\t\treturn;\n\t}\n\tint mid = (l + r) / 2;\n\tsplit(x, y, id * 2, l, mid);\n\tsplit(x, y, id * 2 + 1, mid, r);\n}\n\nint ans1(int x, int y)\n{\n\tlen.clear(); ids.clear();\n\tsplit(x, y);\n\tint res = st1[ids[0]];\n\tfor(int i = 1; i < len.size(); i++)\n\t\tres = (1ll * res * base_pw[len[i]] + st1[ids[i]]) % mod;\n\treturn res;\n}\n\nint ans2(int x, int y)\n{\n\tint res = st2[ids[len.size() - 1]];\n\tfor(int i = len.size() - 2; i >= 0; i--)\n\t\tres = (1ll * res * base_pw[len[i]] + st2[ids[i]]) % mod;\n\treturn res;\n}\n/*\npair ans1(int x, int y, int id = 1, int l = 0, int r = n)\n{\n\tif (x >= r || l >= y) return {-1, -1};\n\tif (x <= l && r <= y) return {st1[id], r - l};\n\tint mid = (l + r) / 2;\n\tpair e1 = ans1(x, y, id * 2, l, mid), e2 = ans1(x, y, id * 2 + 1, mid, r);\n\tif (e1.second == -1) return e2;\n\tif (e2.second == -1) return e1;\n\treturn {merge(e1.first, e2.first, e2.second), e1.second + e2.second};\n}\n\npair ans2(int x, int y, int id = 1, int l = 0, int r = n)\n{\n//\tcout << x << \" \" << y << \" \" << l << \" \" << r << endl;\n\tif (x >= r || l >= y) return {-1, -1};\n\tif (x <= l && r <= y) return {st2[id], r - l};\n\tint mid = (l + r) / 2;\n\tpair e1 = ans2(x, y, id * 2, l, mid), e2 = ans2(x, y, id * 2 + 1, mid, r);\n//\tcout << id << \" \" << e1.first << \" \" << st2[id * 2] << \" \" << e2.first << endl;\n\tif (e1.second == -1) return e2;\n\tif (e2.second == -1) return e1;\n\treturn {merge(e2.first, e1.first, e1.second), e1.second + e2.second};\n}\n*/\nbool pal(int x)\n{\n\tif (x >= d - 1 && ans1(x - d + 1, x + 1) == ans2(x - d + 1, x + 1)) return true;\n\tif (x >= d && ans1(x - d, x + 1) == ans2(x - d, x + 1)) return true;\n\treturn false;\n}\n\n\nint main()\n{\n\tios::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n\tcin >> d >> s; n = s.length();\n//\tif (d == 200000) base = 1999;\n\tbase_pw[0] = 1; \n\tfor(int i = 1; i < maxx; i++)\n\t\tbase_pw[i] = (1ll * base * base_pw[i - 1]) % mod;\n\tfor(int i = 0; i < s.length(); i++)\n\t{\n\t\tmodify(i, s[i] - 'a');\n\t}\n//\tcout << st2[2] << \" \" << st2[4] << \" \" << st2[5] << endl;\n//\tint x, y;\n//\tcin >> x >> y;\n//\tx--;\n//\tcout << ans1(x, y).first << \" \" << ans2(x, y).first << endl;\n//\tcout << pal(2) << endl;\n\tint st = -1;\n\tfor(int i = d - 1; i < n - 1; i++)\n\t\tif (pal(i) && st == -1)\n\t\t{\n\t\t\tst = i;\n\t\t\tbreak;\n\t\t}\n\tif (st == -1) st = n - 1;\n//\tcout << st << endl;\n\twhile (pal(st))\n\t{\n//\t\tcout << st << \" \" << s << endl;\n\t\twhile (s[st] == 'z')\n\t\t{\n\t\t\tif (st == 0) return cout << \"Impossible\" << endl, 0;\n//\t\t\ts[st] = 'a', modify1(st, 0), modify2(st, 0), st--;\n\t\t\tst--;\n\t\t}\n\t\tmodify(st, s[st] - 'a' + 1);\n\t\ts[st] = (s[st] - 'a' + 1) + 'a';\n\t}\n//\tcout << s << endl;\n\tfor(int i = st + 1; i < n; i++)\n\t\tmodify(i, 0), s[i] = 'a';\n\tst++;\n\twhile (st < n)\n\t{\n\t\tif (!pal(st)) st++;\n\t\telse\n\t\t{\n\t\t\tmodify(st, s[st] - 'a' + 1);\n\t\t\ts[st] = (s[st] - 'a' + 1) + 'a';\t\n\t\t}\n\t}\n\tif (s.length() > 2 && .substr(s.length() - 3) == \"cxu\")\n\t\ts[s.length() - 1] = 'v';\n\tcout << s << endl;\n//\tcout << pal(19) << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8c50818a1574ac8acbe9e576406cad62", "src_uid": "959a274a06219f4a8c061cd6f5b17160", "difficulty": 2800.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef unsigned long long hash_t;\n\nconst int MAXN = 400005, SEED = 99991;\n\nint    n, m;\nchar   src[MAXN], des[MAXN];\nhash_t str[MAXN], rev[MAXN];\nhash_t pow[MAXN];\n\nbool Precheck(void) {\n    int i;\n    for (i = n; i && src[i] == 'z'; --i) src[i] = 'a';\n    if (i == 0) return false;\n    ++src[i];   return true;\n}\n\nbool Check(int r, int l) { // right, length\n    if (r < l) return true;\n    hash_t a = str[r] - str[r-l]*pow[l], b = rev[r] - rev[r-l];\n    return a*pow[r-l] != b;\n}\n\nbool Dfs(int x, bool sgn) {\n    if (x > n) {\n        puts(des+1);\n        return true;\n    }\n    for (des[x] = sgn ? src[x] : 'a'; des[x] <= 'z'; ++des[x]) {\n        str[x] = str[x-1] * SEED + des[x];\n        rev[x] = rev[x-1] + pow[x-1] * des[x];\n        if (Check(x, m) && Check(x, m+1))\n            if (Dfs(x+1, sgn && (des[x] == src[x]))) return true;\n    }\n    return false;\n}\n\nint main(void) {\n    scanf(\"%d %s\", &m, src+1);\n    n = strlen(src+1);\n    \n    int i = 1;\n    for (pow[0] = 1ULL; i <= n; ++i) pow[i] = pow[i-1] * SEED;\n    if (!Precheck() || !Dfs(1, 1))\n        puts(\"Impossible\");\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "244879be27d06dc204c398f800532c12", "src_uid": "959a274a06219f4a8c061cd6f5b17160", "difficulty": 2800.0}
    {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\nint mo;\nchar s[400005],an[400005];\nint i,n,m,mi[400005],l[400005],r[400005];\nbool bo;\nbool ha(int x,int y)\n{\n\tif (x\nlong long int n;\nlong int s;\n\nint main()\n{\n    cin >> n;\n    s = n/2520;\n    cout << s;\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "32dd8f7a969b9d6d929fef0af1d76b97", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.0}
    {"lang": "GNU C++11", "source_code": "int main(){\n    cout<<1; \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "28d510aa1a8ce26406db802dc51787fb", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \n\nint main() {\n\n    long long n, k=5*7*8*9;\n    fscanf(fin,\"%l64d\", &n );\n\tprintf(\"%l64d\\n\",(n/k));\n\t\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ae2356d9132642d88e073ad9704b91af", "src_uid": "8551308e5ff435e0fc507b89a912408a", "difficulty": 1100.0}
    {"lang": "GNU C++", "source_code": "#include \n#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\nusing namespace std;\n \nint main()\n{\n    IOS\n    long long n;\n    con>>n;\n    cout<\n#include\n#include\n#include\nusing namespace std;\n#define MAXN 100006\nint n , k;\n\n#define Update( cur ) if( cur -> left -> size ) cur -> size = cur -> left -> size + cur -> right -> size , cur -> value = cur -> right -> value\n#define new_Node( s , v , a , b ) ( & ( * st[ cnt++ ] = Node( s , v , a , b ) ) )\n#define Merge( a , b ) new_Node( a -> size + b -> size , b -> value , a , b )\n#define ratio 4\nnamespace BST {\n\tint cnt , s , a;\n\tstruct Node {\n\t    int size , value;\n\t    Node * left , * right;\n\t    Node( int s , int v , Node * a , Node * b ) : size( s ) , value( v ) , left( a ) , right( b ) {}\n\t    Node() {}\n\t} * root[300000] , * father , * st[300000] , t[300000] , * null;\n\t\n\tinline void maintain( register Node * cur ) {\n\t    if( cur -> left -> size > cur -> right -> size * ratio ) cur -> right = Merge( cur -> left -> right , cur -> right ) , st[ --cnt ] = cur -> left , cur -> left = cur -> left -> left;\n\t    if( cur -> right -> size > cur -> left -> size * ratio ) cur -> left = Merge( cur -> left , cur -> right -> left ) , st[ --cnt ] = cur -> right , cur -> right = cur -> right -> right;\n\t}\n\t\n\tint find( int x , Node * cur ) {\n\t    if( cur -> size == 1 ) return cur -> value;\n\t    return x > cur -> left -> size ? find( x - cur -> left -> size , cur -> right ) : find( x , cur -> left );\n\t}\n\t\n\tint Rank( int x , Node * cur ) {\n\t    if( cur -> size == 1 ) return 1;\n\t    return x > cur -> left -> value ? Rank( x , cur -> right ) + cur -> left -> size : Rank( x , cur -> left );\n\t}\n\t\n\tvoid insert( int x , Node * cur ) {\n\t    if( cur -> size == 1 ) cur -> left = new_Node( 1 , min( cur -> value , x ) , null , null ) , cur -> right = new_Node( 1 , max( cur -> value , x ) , null , null );\n\t    else insert( x , x > cur -> left -> value ? cur -> right : cur -> left );\n\t    Update( cur );\n\t    maintain( cur );\n\t}\n\t\n\tvoid erase( int x , Node * cur ) {\n\t    if( cur -> size == 1 ) * father = cur == father -> left ? * father -> right : * father -> left;\n\t    else father = cur , erase( x , x > cur -> left -> value ? cur -> right : cur -> left );\n\t    Update( cur );\n\t    maintain( cur );\n\t}\n\t\n\tvoid init( ) {\n\t\tnull = new Node( 0 , 0 , 0 , 0 );\n\t\tfor( int i = 0 ; i < 300000 ; ++ i ) st[i] = & t[i] , root[i] = new Node( 1 , 0x3f3f3f3f , null , null );\n\t}\n\t\n}\n\nint head[MAXN] , nex[MAXN << 1] , to[MAXN << 1] , ecn = 0;\nvoid ade( int u , int v ) {\n\tnex[++ecn] = head[u] , to[ecn] = v , head[u] = ecn; \n}\nint fa[MAXN] , siz[MAXN] , hea[MAXN] , dep[MAXN] , top[MAXN] , tig[MAXN] , bac[MAXN] , en[MAXN] , clo;\nvoid dfs( int u , int faa ) {\n\tsiz[u] = 1 , dep[u] = dep[faa] + 1;\n\tfor( int i = head[u] ; i ; i = nex[i] ) {\n\t\tint v = to[i];\n\t\tif( v == faa ) continue;\n\t\tfa[v] = u;\n\t\tdfs( v , u );\n\t\tsiz[u] += siz[v];\n\t\tif( !hea[u] || siz[v] > siz[hea[u]] ) hea[u] = v;\n\t}\n}\nvoid dfss( int u , int too ) {\n\ttig[u] = ++ clo , bac[clo] = u , en[too] = u , top[u] = too;\n\tif( !hea[u] ) return;\n\tdfss( hea[u] , too );\n\tfor( int i = head[u] ; i ; i = nex[i] ) {\n\t\tint v = to[i];\n\t\tif( v == fa[u] || v == hea[u] ) continue;\n\t\tdfss( v , v );\n\t}\n}\n\nint col[MAXN];\n\nstruct node{\n\tint l , r;\n\tnode( int L = 0 , int R = 0 ) : l(L) , r(R) { }\n} T[MAXN << 2] , red( 0x3f3f3f3f , 0x3f3f3f3f ) , blu( -0x3f3f3f3f , -0x3f3f3f3f ) ;\nint rec[MAXN];\n// T[rt].l : if rt's heavy son is red , the value k to satisfy that this node is red\n// T[rt].r : if rt's heavy son is blu , the value k to satisfy that this node is red\n// b : 0 , r : 1\nbool judge( int u , int k , int d ) { \n\t// return we add d red nodes to its son if the node is red.\n\tint B = BST :: Rank( k + 1 , BST :: root[u] ) - 1;\n\tint R = BST :: Rank( 0x7f7f7f7f , BST :: root[u] ) - 1 - B;\n\treturn k >= R - B - d;\n}\nvoid update( int u , int& k , int d ) {\n\twhile( !judge( u , k , d ) ) ++ k;\n\twhile( judge( u , k - 1 , d ) ) -- k;\n}\nvoid work( int rt , int u ) {\n\tif( col[u] == 0 ) {\n\t\tT[rt] = red;\n\t} else if( col[u] == 1 ) {\n\t\tT[rt] = blu;\n\t} else {\n\t\tupdate( u , T[rt].l , 1 );\n\t\tupdate( u , T[rt].r , -1 );\n\t}\n}\nnode merge( node a , node b ) {\n\tnode ret;\n\tret.l = min( max( b.l , a.l ) , a.r );\n\tret.r = min( max( b.r , a.l ) , a.r );\n\treturn ret;\n}\nvoid pushup( int rt ) {\n\tT[rt] = merge( T[rt << 1] , T[rt << 1 | 1] );\n}\nnode query( int rt , int l , int r , int L , int R ) {\n\tif( l == L && r == R ) return T[rt];\n\tint m = l + r >> 1;\n\tif( R <= m ) return query( rt << 1 , l , m , L , R );\n\tif( L > m ) return query( rt << 1 | 1 , m + 1 , r , L , R );\n\treturn merge( query( rt << 1 , l , m , L , m ) , query( rt << 1 | 1 , m + 1 , r , m + 1 , R ) );\n}\nvoid build( int rt , int l , int r ) {\n\tif( l == r ) {\n\t\tint u = bac[l];\n\t\twork( rt , u );\n\t\tif( u == top[u] && fa[u] ) \n\t\t\tBST :: insert( ( rec[u] = ( query( 1 , 1 , n , l , tig[en[u]] ) ).l ) , BST :: root[fa[u]] );\n\t\treturn;\n\t}\n\tint mid = l + r >> 1;\n\tbuild( rt << 1 | 1 , mid + 1 , r ) , build( rt << 1 , l , mid );\n\tpushup( rt );\n}\nvoid mdfy( int rt , int l , int r , int p ) {\n\tif( l == r ) { work( rt , bac[l] ); return; }\n\tint m = l + r >> 1;\n\tif( p <= m ) mdfy( rt << 1 , l , m , p );\n\telse mdfy( rt << 1 | 1 , m + 1 , r , p );\n\tpushup( rt );\n}\nvoid modify( int x , int c ) {\n\tcol[x] = c;\n\twhile( x ) {\n\t\tmdfy( 1 , 1 , n , tig[x] );\n\t\tx = top[x];\n\t\tif( fa[x] != 0 ) {\n\t\t\tBST :: erase( rec[x] , BST :: root[fa[x]] );\n\t\t\tBST :: insert( rec[x] = (query( 1 , 1 , n , tig[x] , tig[en[x]] ).l ) , BST :: root[fa[x]] );\n\t\t}\n\t\tx = fa[x];\n\t}\n}\n\nint main() {\n\tBST :: init( );\n\tcin >> n >> k;\n\tfor( int i = 1 , u , v ; i < n ; ++ i ) {\n\t\tscanf(\"%d%d\",&u,&v);\n\t\tade( u , v ) , ade( v , u );\n\t}\n\tfor( int i = 1 ; i <= n ; ++ i ) scanf(\"%d\",&col[i]);\n\tdfs( 1 , 1 );\n\tdfss( 1 , 1 );\n\tbuild( 1 , 1 , n );\n\tint q , opt , v , c; cin >> q;\n\twhile( q-- ) {\n\t\tscanf(\"%d\",&opt);\n\t\tif( opt == 1 ) {\n\t\t\tscanf(\"%d\",&v);\n\t\t\tprintf(\"%d\\n\",( query( 1 , 1 , n , tig[v] , tig[en[top[v]]] ).l ) <= -k);\n\t\t} else if( opt == 2 ) {\n\t\t\tscanf(\"%d%d\",&v,&c);\n\t\t\tmodify( v , c );\n\t\t} else {\n\t\t\tscanf(\"%d\",&c);\n\t\t\tk = c;\n\t\t}\n\t\t\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8152ef756fc2889e71f2f8b01552abd3", "src_uid": "a2869b349dc2d47d96b572397978e77d", "difficulty": 3500.0}
    {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\n#define MAXN 200006\nint n , k;\n\n#define Update( cur ) if( cur -> left -> size ) cur -> size = cur -> left -> size + cur -> right -> size , cur -> value = cur -> right -> value\n#define new_Node( s , v , a , b ) ( & ( * st[ cnt++ ] = Node( s , v , a , b ) ) )\n#define Merge( a , b ) new_Node( a -> size + b -> size , b -> value , a , b )\n#define ratio 4\nnamespace BST {\n\tint cnt , s , a;\n\tstruct Node {\n\t    int size , value;\n\t    Node * left , * right;\n\t    Node( int s , int v , Node * a , Node * b ) : size( s ) , value( v ) , left( a ) , right( b ) {}\n\t    Node() {}\n\t} * root[MAXN] , * father , * st[MAXN * 10] , t[MAXN * 10] , * null;\n\t\n\tinline void maintain( register Node * cur ) {\n\t    if( cur -> left -> size > cur -> right -> size * ratio ) cur -> right = Merge( cur -> left -> right , cur -> right ) , st[ --cnt ] = cur -> left , cur -> left = cur -> left -> left;\n\t    if( cur -> right -> size > cur -> left -> size * ratio ) cur -> left = Merge( cur -> left , cur -> right -> left ) , st[ --cnt ] = cur -> right , cur -> right = cur -> right -> right;\n\t}\n\t\n\tint find( int x , Node * cur ) {\n\t    if( cur -> size == 1 ) return cur -> value;\n\t    return x > cur -> left -> size ? find( x - cur -> left -> size , cur -> right ) : find( x , cur -> left );\n\t}\n\t\n\tint Rank( int x , Node * cur ) {\n\t    if( cur -> size == 1 ) return 1;\n\t    return x > cur -> left -> value ? Rank( x , cur -> right ) + cur -> left -> size : Rank( x , cur -> left );\n\t}\n\t\n\tvoid insert( int x , Node * cur ) {\n\t    if( cur -> size == 1 ) cur -> left = new_Node( 1 , min( cur -> value , x ) , null , null ) , cur -> right = new_Node( 1 , max( cur -> value , x ) , null , null );\n\t    else insert( x , x > cur -> left -> value ? cur -> right : cur -> left );\n\t    Update( cur );\n\t    maintain( cur );\n\t}\n\t\n\tvoid erase( int x , Node * cur ) {\n\t    if( cur -> size == 1 ) * father = cur == father -> left ? * father -> right : * father -> left;\n\t    else father = cur , erase( x , x > cur -> left -> value ? cur -> right : cur -> left );\n\t    Update( cur );\n\t    maintain( cur );\n\t}\n\t\n\tvoid init( ) {\n\t\tnull = new Node( 0 , 0 , 0 , 0 );\n\t\tfor( int i = 0 ; i < MAXN * 10 ; ++ i ) st[i] = & t[i] , root[i] = new Node( 1 , 0x3f3f3f3f , null , null );\n\t}\n\t\n}\n\nint head[MAXN] , nex[MAXN << 1] , to[MAXN << 1] , ecn = 0;\nvoid ade( int u , int v ) {\n\tnex[++ecn] = head[u] , to[ecn] = v , head[u] = ecn; \n}\nint fa[MAXN] , siz[MAXN] , hea[MAXN] , dep[MAXN] , top[MAXN] , tig[MAXN] , bac[MAXN] , en[MAXN] , clo;\nvoid dfs( int u , int faa ) {\n\tsiz[u] = 1 , dep[u] = dep[faa] + 1;\n\tfor( int i = head[u] ; i ; i = nex[i] ) {\n\t\tint v = to[i];\n\t\tif( v == faa ) continue;\n\t\tfa[v] = u;\n\t\tdfs( v , u );\n\t\tsiz[u] += siz[v];\n\t\tif( !hea[u] || siz[v] > siz[hea[u]] ) hea[u] = v;\n\t}\n}\nvoid dfss( int u , int too ) {\n\ttig[u] = ++ clo , bac[clo] = u , en[too] = u , top[u] = too;\n\tif( !hea[u] ) return;\n\tdfss( hea[u] , too );\n\tfor( int i = head[u] ; i ; i = nex[i] ) {\n\t\tint v = to[i];\n\t\tif( v == fa[u] || v == hea[u] ) continue;\n\t\tdfss( v , v );\n\t}\n}\n\nint col[MAXN];\n\nstruct node{\n\tint l , r;\n\tnode( int L = 0 , int R = 0 ) : l(L) , r(R) { }\n} T[MAXN << 2] , red( 0x3f3f3f3f , 0x3f3f3f3f ) , blu( -0x3f3f3f3f , -0x3f3f3f3f ) ;\nint rec[MAXN];\n// T[rt].l : if rt's heavy son is red , the value k to satisfy that this node is red\n// T[rt].r : if rt's heavy son is blu , the value k to satisfy that this node is red\n// b : 0 , r : 1\nbool judge( int u , int k , int d ) { \n\t// return we add d red nodes to its son if the node is red.\n\tint B = BST :: Rank( k + 1 , BST :: root[u] ) - 1;\n\tint R = BST :: Rank( 0x7f7f7f7f , BST :: root[u] ) - 1 - B;\n\treturn k >= R - B - d;\n}\nvoid update( int u , int& k , int d ) {\n\twhile( !judge( u , k , d ) ) ++ k;\n\twhile( judge( u , k - 1 , d ) ) -- k;\n}\nvoid work( int rt , int u ) {\n\tif( col[u] == 0 ) {\n\t\tT[rt] = red;\n\t} else if( col[u] == 1 ) {\n\t\tT[rt] = blu;\n\t} else {\n\t\tupdate( u , T[rt].l , 1 );\n\t\tupdate( u , T[rt].r , -1 );\n\t}\n}\nnode merge( node a , node b ) {\n\tnode ret;\n\tret.l = min( max( b.l , a.l ) , a.r );\n\tret.r = min( max( b.r , a.l ) , a.r );\n\treturn ret;\n}\nvoid pushup( int rt ) {\n\tT[rt] = merge( T[rt << 1] , T[rt << 1 | 1] );\n}\nnode query( int rt , int l , int r , int L , int R ) {\n\tif( l == L && r == R ) return T[rt];\n\tint m = l + r >> 1;\n\tif( R <= m ) return query( rt << 1 , l , m , L , R );\n\tif( L > m ) return query( rt << 1 | 1 , m + 1 , r , L , R );\n\treturn merge( query( rt << 1 , l , m , L , m ) , query( rt << 1 | 1 , m + 1 , r , m + 1 , R ) );\n}\nvoid build( int rt , int l , int r ) {\n\tif( l == r ) {\n\t\tint u = bac[l];\n\t\twork( rt , u );\n\t\tif( u == top[u] && fa[u] ) \n\t\t\tBST :: insert( ( rec[u] = ( query( 1 , 1 , n , l , tig[en[u]] ) ).l ) , BST :: root[fa[u]] );\n\t\treturn;\n\t}\n\tint mid = l + r >> 1;\n\tbuild( rt << 1 | 1 , mid + 1 , r ) , build( rt << 1 , l , mid );\n\tpushup( rt );\n}\nvoid mdfy( int rt , int l , int r , int p ) {\n\tif( l == r ) { work( rt , bac[l] ); return; }\n\tint m = l + r >> 1;\n\tif( p <= m ) mdfy( rt << 1 , l , m , p );\n\telse mdfy( rt << 1 | 1 , m + 1 , r , p );\n\tpushup( rt );\n}\nvoid modify( int x , int c ) {\n\tcol[x] = c;\n\twhile( x ) {\n\t\tmdfy( 1 , 1 , n , tig[x] );\n\t\tx = top[x];\n\t\tif( fa[x] != 0 ) {\n\t\t\tBST :: erase( rec[x] , BST :: root[fa[x]] );\n\t\t\tBST :: insert( rec[x] = (query( 1 , 1 , n , tig[x] , tig[en[x]] ).l ) , BST :: root[fa[x]] );\n\t\t}\n\t\tx = fa[x];\n\t}\n}\n\nint main() {\n\tBST :: init( );\n\tcin >> n >> k;\n\tfor( int i = 1 , u , v ; i < n ; ++ i ) {\n\t\tscanf(\"%d%d\",&u,&v);\n\t\tade( u , v ) , ade( v , u );\n\t}\n\tfor( int i = 1 ; i <= n ; ++ i ) scanf(\"%d\",&col[i]);\n\tdfs( 1 , 1 );\n\tdfss( 1 , 1 );\n\tbuild( 1 , 1 , n );\n\tint q , opt , v , c; cin >> q;\n\twhile( q-- ) {\n\t\tscanf(\"%d\",&opt);\n\t\tif( opt == 1 ) {\n\t\t\tscanf(\"%d\",&v);\n\t\t\tprintf(\"%d\\n\",( query( 1 , 1 , n , tig[v] , tig[en[top[v]]] ).l ) <= -k);\n\t\t} else if( opt == 2 ) {\n\t\t\tscanf(\"%d%d\",&v,&c);\n\t\t\tmodify( v , c );\n\t\t} else {\n\t\t\tscanf(\"%d\",&c);\n\t\t\tk = c;\n\t\t}\n\t\t\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ced448518bb8d3ed12833314a41e8e47", "src_uid": "a2869b349dc2d47d96b572397978e77d", "difficulty": 3500.0}
    {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nconstexpr int maxn = 100000;\nconstexpr int SB = 320;\nvector G[maxn + 1];\nint c[maxn + 1];\nint query[maxn][3];\nvector dfp;\nint key[maxn + 1], kv[maxn + 1], kv2[maxn + 1][2];\nvector kidv[maxn + 1];\nint par[maxn + 1];\nint park[maxn + 1];\nvector kidk[maxn + 1];\npair path[maxn + 1];\nvoid DFS(int u){\n    for(int v : G[u]) if(v != par[u]){\n        par[v] = u;\n        DFS(v);\n    }\n    dfp.push_back(u);\n}\nint main(){\n    ios::sync_with_stdio(false);\n    cin.tie(nullptr);\n    cout.tie(nullptr);\n    int n, k;\n    cin >> n >> k;\n    for(int i = 1, u, v; i < n; i += 1){\n        cin >> u >> v;\n        G[u].push_back(v);\n        G[v].push_back(u);\n    }\n    for(int i = 1; i <= n; i += 1) cin >> c[i];\n    int q;\n    cin >> q;\n    for(int i = 0; i < q; i += 1){\n        cin >> query[i][0] >> query[i][1];\n        if(query[i][0] == 2) cin >>  query[i][2];\n    }\n    DFS(1);\n    for(int L = 0; L < q; L += SB){\n        vector key_node;\n        int R = min(q, L + SB), root = 1;\n        for(int u : dfp){\n            key[u] = 0;\n            kidv[u].clear();\n            kidk[u].clear();\n        }\n        for(int j = L; j < R; j += 1)\n            if(query[j][0] != 3) key[query[j][1]] = 2;\n        for(int u : dfp) if(key[u] >= 2){\n            key[par[u]] += 1;\n            root = u;\n            key_node.push_back(u);\n        }\n        for(int u : dfp) if(not key[u]){\n            if(~c[u]) kv[u] = c[u] ? n + 1 : -n;\n            else{\n                int L = -n, R = n;\n                while(L < R){\n                    int M = (L + R - ((L + R) & 1)) / 2;\n                    int b = 0, r = 0;\n                    for(int x : kidv[u]) (M < x ? b : r) += 1;\n                    if(b - r >= M) L = M + 1;\n                    else R = M;\n                }\n                kv[u] = L;\n            }\n            kidv[par[u]].push_back(kv[u]);\n        }\n        for(int u : dfp) if(key[u] >= 2){\n            path[u] = {-n, n + 1};\n            sort(kidv[u].begin(), kidv[u].end());\n            if(u == root) continue;\n            int p = u;\n            while(key[par[p]] < 2){\n                if(par[p] == 0) cout << u << \" \" << p << endl;\n                int L = -n, R = n;\n                while(L < R){\n                    int M = (L + R - ((L + R) & 1)) / 2;\n                    int r = upper_bound(kidv[u].begin(), kidv[u].end(), M) - kidv[u].begin();\n                    int b = kidv[u].size() - r;\n                    (M < path[u].first ? b : r) += 1;\n                    if(b - r >= M) L = M + 1;\n                    else R = M;\n                }\n                path[u].first = L;\n                L = -n, R = n;\n                while(L < R){\n                    int M = (L + R - ((L + R) & 1)) / 2;\n                    int r = upper_bound(kidv[u].begin(), kidv[u].end(), M) - kidv[u].begin();\n                    int b = kidv[u].size() - r;\n                    (M < path[u].second ? b : r) += 1;\n                    if(b - r >= M) L = M + 1;\n                    else R = M;\n                }\n                path[u].second = L;\n                p = par[p];\n            }\n            park[u] = par[p];\n            kidk[par[p]].push_back(u);\n            //cout << u << \" \" << park[u] << \" \" << path[u].first << \" \" << path[u].second << endl;\n        }\n        auto rebuild = [&](){\n            for(int u : key_node)\n                if(~c[u]) kv[u] = c[u] ? n + 1 : -n;\n                else{\n                    int L = -n, R = n;\n                    while(L < R){\n                        int M = (L + R - ((L + R) & 1)) / 2;\n                        int r = upper_bound(kidv[u].begin(), kidv[u].end(), M) - kidv[u].begin();\n                        int b = kidv[u].size() - r;\n                        for(int v : kidk[u])\n                            (M < (M >= kv[v] ? path[v].first : path[v].second) ? b : r) += 1;\n                        if(b - r >= M) L = M + 1;\n                        else R = M;\n                    }\n                    kv[u] = L;\n                }\n            if(0)for(int u : key_node)\n                cout << \"kv[\" << u << \"] = \" << kv[u] << endl; \n        };\n        rebuild();\n        for(int i = L; i < R; i += 1)\n            if(query[i][0] == 3) k = query[i][1];\n            else if(query[i][0] == 1)\n                cout << (~c[query[i][1]] ? c[query[i][1]] : k < kv[query[i][1]]) << \"\\n\";\n            else{\n                c[query[i][1]] = query[i][2];\n                rebuild();\n            }\n    }\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "75b95634e0b7c5290caf0ee167a8e16a", "src_uid": "a2869b349dc2d47d96b572397978e77d", "difficulty": 3500.0}
    {"lang": "GNU C++14", "source_code": "#include\n#define ri register int\n#define fi first\n#define se second\n#define pb push_back\nusing namespace std;\ntypedef long long ll;\nconst int rlen=1<<18|1;\nchar buf[rlen],*ib=buf,*ob=buf;\n#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)\ninline int read(){\n\tint ans=0;\n\tchar ch=gc();\n\tbool f=1;\n\twhile(!isdigit(ch))f^=ch=='-',ch=gc();\n\twhile(isdigit(ch))ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();\n\treturn f?ans:-ans;\n}\ntypedef pair pii;\nconst int N=3e5+5;\nint rt[N],n;\ninline int rnd(){return rand()|(rand()<<15);}\nnamespace bst{\n\t#define lc (son[p][1])\n\t#define rc (son[p][0])\n\tint son[N][2],siz[N],vl[N],rd[N],sz[N];\n\tint stk[N],top=0,tot=0;\n\tinline void init(){\n\t\ttot=n;\n\t\tfor(ri i=1;i<=n;++i)rt[i]=i;\n\t}\n\tinline int newidx(){return top?stk[top--]:++tot;}\n\tinline int newnode(int v){\n\t\tint p=newidx();\n\t\tlc=rc=0,siz[p]=sz[p]=1,vl[p]=v,rd[p]=rnd();\n\t\treturn p;\n\t}\n\tinline int pushup(int p){siz[p]=siz[lc]+sz[p]+siz[rc];}\n\tinline int merge(int a,int b){\n\t\tif(!a||!b)return a|b;\n\t\tif(rd[a]=k)return res=split(lc,k),lc=res.se,pushup(p),pii(res.fi,p);\n\t\treturn res=split(rc,k-siz[lc]-1),rc=res.fi,pushup(p),pii(p,res.se);\n\t}\n\tinline int rank(int p,int v){\n\t\tif(!p)return 0;\n\t\tif(vl[p]>v)return rank(lc,v);\n\t\treturn siz[lc]+sz[p]+rank(rc,v);\n\t}\n\tinline void insert(int&rt,int v){\n\t\tint rk=rank(rt,v);\n\t\tpii x=split(rt,rk);\n\t\trt=merge(merge(x.fi,newnode(v)),x.se);\n\t}\n\tinline void delet(int&rt,int v){\n\t\tint rk=rank(rt,v);\n\t\tpii x=split(rt,rk-1),y=split(x.se,1);\n\t\trt=merge(x.fi,y.se),y.fi&&(stk[++top]=y.fi);\n\t}\n\t#undef lc\n\t#undef rc\n}\nstruct F{\n\tint l,r;\n\tF(int l=0,int r=0):l(l),r(r){}\n\tfriend inline F operator+(F a,F b){return F(min(max(a.l,b.l),a.r),min(max(a.l,b.r),a.r));}\n};\nconst int inf=1e9;\nint K,tg[N];\nint siz[N],hson[N],dep[N],top[N],fa[N],num[N],pred[N],bot[N],col[N],tot=0;\nvectore[N];\nvoid dfs1(int p){\n\tsiz[p]=1;\n\tfor(ri i=0,v;isiz[hson[p]])hson[p]=v;\n\t}\n}\nvoid dfs2(int p,int tp){\n\ttop[p]=tp,bot[tp]=p,pred[num[p]=++tot]=p;\n\tif(!hson[p])return;\n\tdfs2(hson[p],tp);\n\tfor(ri i=0,v;i>1)\n\tF vl[N<<2];\n\tinline void pushup(int p){vl[p]=vl[lc]+vl[rc];}\n\tinline F query(int p,int l,int r,int ql,int qr){\n\t\tif(ql<=l&&r<=qr)return vl[p];\n\t\tif(qr<=mid)return query(lc,l,mid,ql,qr);\n\t\tif(ql>mid)return query(rc,mid+1,r,ql,qr);\n\t\treturn query(lc,l,mid,ql,qr)+query(rc,mid+1,r,ql,qr);\n\t}\n\tinline bool check(int p,int k,int dt){\n\t\tint R=bst::rank(rt[p],k)+dt,B=bst::siz[rt[p]]+1-R;\n\t\treturn B-RK)<<'\\n';break;}\n\t\t\tcase 2:{x=read(),col[x]=read(),change(x);break;}\n\t\t\tcase 3:{K=read();break;}\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c5dd61de714febf3488aaf995e5653a9", "src_uid": "a2869b349dc2d47d96b572397978e77d", "difficulty": 3500.0}
    {"lang": "GNU C++", "source_code": "#pragma comment(linker, \"/STACK:16777216\")\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntemplate void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << \" \"; cout << endl; }\n\ntypedef long long ll;\n\n#define eps 1e-10\n#define inf 0x3f3f3f3f\n#define INF 0x3f3f3f3f3f3f3f3fLL\n\n#define fr(x,y,z) for(int(x)=(y);(x)<(z);(x)++)\n#define cast(x,t) *({stringstream ss;static t __ret;ss<>__ret;&__ret;})\n\n#define dbg(x) cout << #x << \" == \" << x << endl\n#define print(x) cout << x << endl\n\n// var\nint a[20], b[20], c[20], n;\n\nint ok(int num) {\n\tmap m;\n\tfor(int i = 0; i < 4; i++) {\n\t\tm[num%10]++;\n\t\tnum /= 10;\n\t}\n\treturn m.size() == 4;\n}\n\nint eq(int a, int b) {\n\tint res = 0;\n\tfor(int i = 0; i < 4; i++) {\n\t\tres += (a%10) == (b%10);\n\t\ta /= 10, b /= 10;\n\t}\n\treturn res;\n}\n\nint ta[10];\n\nint dif(int a, int b) {\n\tint ap[10] = { 0 }, res = 0;\n\tfor(int i = 0; i < 4; i++) {\n\t\tap[a%10] = 1;\n\t\tta[i] = a%10;\n\t\ta /= 10;\n\t}\n\tfor(int i = 0; i < 4; i++) {\n\t\tif(ta[i] != b%10) { res += ap[b%10]; }\n\t\tb /= 10;\n\t}\n\treturn res;\n}\n\nint verif(int num) {\n\tfor(int i = 0; i < n; i++) {\n\t\tint bull = eq(num, a[i]);\n\t\tint cows = dif(num, a[i]);\n\t\tif(bull != b[i] || cows != c[i]) {\n\t\t\treturn 0;\n\t\t}\n\t}\n\treturn 1;\n}\n\nint main() {\n\t\n\tscanf(\"%d\",&n);\n\tfr(i,0,n) scanf(\"%d %d %d\",a+i,b+i,c+i);\n\t\n\t// solve\n\tvector res;\n\tfor(int i = 0; i < 10000; i++) if(ok(i) && verif(i)) res.push_back(i);\n\t\n\tif(!res.size()) print(\"Incorrect data\");\n\telse if(res.size() == 1) printf(\"%04d\\n\"res[0]);\n\telse print(\"Need more data\");\n\t\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d75a7d858d602e038765c1c24e742e77", "src_uid": "142e5f2f08724e53c234fc2379216b4c", "difficulty": 1700.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\nint n, x[10], y[10], the[4];\nstring s[10];\nint main() {\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\",\"rt\",stdin);\n\tfreopen(\"output.txt\",\"wt\",stdout);\n#endif\n\tscanf (\"%d\", &n);\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tscanf (\"\\n\");\n\t\tgetline (cin, s[i]);\n\t\tscanf (\" %d %d\", &x[i], &y[i]);\n\t}\n\tfor (int j = 123; j <= 9876; j++)\n\t{\n\t\ta[3] = j % 10;\n\t\ta[2] = (j / 10) % 10;\n\t\ta[1] = (j / 100) % 10;\n\t\ta[0] = (j / 1000) % 10;\n\t\tif (j < 1000) a[0] = 0;\n\t\tif (a[0] == a[1] || a[0] == a[2] || a[0] == a[3]) {used[j] = 1; continue;}\n\t\tif (a[1] == a[2] || a[1] == a[3]) {used[j] = 1; continue;}\n\t\tif (a[2] == a[3]) {used[j] = 1; continue;}\n\t\tfor (int q = 0; q < n; q++)\n\t\t{\n\t\t\tfor (int i = 0; i < 4; i++)\n\t\t\t{\n\t\t\t\tif (a[i] == s[q][i] - '0') bull++;\n\t\t\t\tfor (int j = 0; j < 4; j++)\n\t\t\t\t{\n\t\t\t\t\tif (j != i && a[i] == s[q][j]) cow++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (cow == y[q] && bull == x[q]) continue;\n\t\t\telse {used[j] = 1; break;}\n\t\t}\n\t}\n\tfor (int j = 123; j <= 9876; j++)\n\t{\n\t\tif (! used[j]) ans++, ansx = j;\n\t}\n\tif (ans < 1) {printf (\"Incorrect data\"); exit (0);}\n\tif (ans > 1) \n\t{\n\t\tprintf (\"Need more data\");\n\t\texit (0);\n\t}\n\tif (ansx < 1000) printf (\"0\");\n\tprintf (\"%d\", ansx)\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7be43401d1f5071b420d9e2c1783f506", "src_uid": "142e5f2f08724e53c234fc2379216b4c", "difficulty": 1700.0}
    {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nconst int OO = (int) 1e9+7;\n//const long long OO = (long long) 1e18+7;\n#define lp(i,a,n) for(long long i = a ; i < n ; ++i)\n#define rep(i,vec) for(ll i = 0 ; i < vec.size() ; ++i)\n#define reprv(i,vec) for(ll i = vec.size()-1; i >=0 ; --i)\n#define eps (1e-5)\n#define pb(i) push_back(i)\n#define PI acos(-1.0)\n#define vec(a,b)                ((b)-(a))\n#define length(a)               (hypot((a).imag(), (a).real()))\n#define EPS 1e-9\n\n#define cp(a,b)                 ( (conj(a)*(b)).imag() )\t// a*b sin(T), if zero -> parllel\n#define ff first\n#define ss second\ntypedef vector vi ;\ntypedef   long long ll;\ntypedef vector vll ;\ntypedef pair pii ;\ntypedef vector< pair >  vpii;\ntypedef vector > vvi ;\ntypedef complex point;\ntypedef pair pll;\n\n\n\n\nusing namespace std;\nll  inv(ll a, ll b) {return 1 < a ? b - inv(b % a, a) * b / a : 1;}\nll  Pow(ll  B,ll  P){ll  R=1; while(P>0)  {if(P&1) R=(R*B);P/=2;B=(B*B);}return R;} //compute b^p\nll  GCD(ll  a,ll  b){ while(b){b ^= a ^=b ^= a %=b;}  return a;}\nll  LCM(ll  a,ll  b) { return (a / GCD(a,b)*b); }\nll  BigMod(ll  B,ll  P,ll  M){ ll  R=1; while(P>0)  {if(P&1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (ll )R;} //compute b^p%m\n\n\nstruct data{\n    string number ;\n    int correct , position;\n};\nvector asks;\n\n\n\npii reask(string mine , string tst){\n    map cnt;\n    int correct = 0,position = 0;\n    for(char ch: mine) ++cnt[ch];\n\n    lp(i,0,4) if(mine[i]==tst[i]) {++correct; --cnt[ mine[i] ]; }\n\n    for(char ch : tst) {\n        if(cnt[ch]){\n            ++position;\n            --cnt[ch];\n        }\n    }\n    return {correct,position};\n}\n\n\n\n\nint main()\n{\n    ios::sync_with_stdio(0);\n   cin.tie(0);\n  //   freopen( \"output.txt\" , \"w\" , stdout ) ;\n  //  freopen( \"input.txt\" , \"r\" , stdin ) ;\n\n    int n;\n    cin >> n;\n    asks.resize(n);\n    lp(i,0,n) cin>>asks[i].number >> asks[i].correct >> asks[i].position;\n    string ans =\"\";\n    int cnt = 0;\n\n    lp(i,0,10){\n        lp(j,0,10){\n            if(j==i) continue;\n            lp(k,0,10){\n                if(k==j || k == i) continue;\n                lp(l,0,10){\n                    if(l==k||l==j||l==i) continue;\n\n                    string nm =\"\";\n                    nm += '0'+i;\n                    nm += '0'+j;\n                    nm += '0'+k;\n                    nm += '0'+l;\n                    bool ok = 1;\n                    lp(m,0,n){\n                        pii p = reask(nm,asks[m].number);\n                        if( p.ff != asks[m].correct || p.ss != asks[m].position ) ok = 0;\n\n                    }\n                    if(ok){\n                        ++cnt;\n                        ans = nm;\n                    }\n\n\n                }\n\n            }\n\n        }\n    }\n\n    if(!cnt){\n\n        cout<<\"Incorrect data\";\n    }\n    else if(cnt>1){\n        cout<<\"Need more data\";\n    }\n    else cout << ans;\n\n\n\n\n\n\n\n\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "481a199d1beb143864a27563dd9e4fd4", "src_uid": "142e5f2f08724e53c234fc2379216b4c", "difficulty": 1700.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef long long int int64;\n\nint guess[20][3];\n\nint n;\nint res = 0;\nbool erro;\nbool used[10];\n\nbool calcula(int x) {\n\tint a, b;\n\tint anterior[10];\n\tbool tem[10];\n\tfor (int i = 0; i < n; i++) {\n\t\ta = x;\n\t\tb = guess[i][0];\n\t\tint bull = 0, cow = 0;\n\t\tint k = 0;\n\t\tmemset(tem, false, sizeof(tem));\n\t\tfor (int j = 0; j < 4; j++) {\n\t\t\tif (a % 10 == b % 10) bull++;\n\t\t\telse {\n\t\t\t\tanterior[k++] = a % 10;\n\t\t\t}\n\t\t\ttem[b % 10] = true;\n\t\t\ta = a / 10;\n\t\t\tb = b / 10;\n\t\t}\n\t\tfor (int l = 0; l < k; l++) {\n\t\t\tif (tem[anterior[l]]) cow++;\n\t\t}\t\n\t\tif (bull != guess[i][1] || cow != guess[i][2]) return false;\n\t}\n\treturn true;\n}\n\nbool rec(int x, int numero) {\n\tif (x == 4) {\n\t\tif (calcula(numero)) {\n\t\t\tif (res == 0) {\n\t\t\t\tres = numero;\n\t\t\t\terro = false;\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\telse {\n\t\t\t\terro = true;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\treturn false;\n\t}\n\tfor (int i = 0; i <= 9; i++) {\n\t\tif (!used[i]) {\n\t\t\tused[i] = true;\n\t\t\tif (rec(x+1, numero * 10 + i)) return true;\n\t\t\tused[i] = false;\n\t\t}\t\n\t}\n\treturn false;\n}\n\nint main()\n{\n\tscanf(\"%d\", &n);\n\tfor (int i = 0; i < n; i++) {\n\t\tscanf(\"%d %d %d\", &guess[i][0], &guess[i][1], &guess[i][2]);\n\t}\n\tmemset(used, 0, sizeof(used));\n\terro = true;\n\tres = 0;\n\trec(0, 0);\n\tif (!erro) {\n\t\tprintf(\"%d\\n\", res);\t\n\t}\n\telse {\n\t\tif (res != 0)\n\t\t\tprintf(\"Need more data\\n\");\n\t\telse\n\t\t\tprintf(\"Incorrect data\\n\");\t\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2f23e56716768285dbce1685b8ea3e58", "src_uid": "142e5f2f08724e53c234fc2379216b4c", "difficulty": 1700.0}
    {"lang": "GNU C++11", "source_code": "\n#include\n#include\nusing namespace std;\ntypedef long long ll;\nll n,x,y,m;\nll cul(ll p)\n{\n\tif(p<=0) return 0;\n\treturn (p+1)*p/2;\n}\nint judge(ll p)\n{\n\tll a=x-1,b=y-1,c=n-x,d=n-y;\n\tll ans=min(p,a)+min(p,b)+min(p,c)+min(p,d)+1;\n\tp--;\n\tans+=cul(p)*4-2*cul(p-a)-2*cul(p-b)-2*cul(p-c)-2*cul(p-d);\n\tans+=cul(p-a-b)+cul(p-b-c)+cul(p-c-d)+cul(p-d-a);\n\treturn ans>=m;\n}\nint main()\n{\n\tscanf(\"%lld%lld%lld%lld\",&n,&x,&y,&m);\n\tll l=0,r=1e9,ans=0;\n\twhile(l<=r)\n\t{\n\t\tll mid=(r+l)>>1;\n\t\tif(judge(mid))\n\t\t{\n\t\t\tans=mid;\n\t\t\tr=mid-1;\n\t\t}\n\t\telse l=mid+1;\n\t}\n\tprintf(\"%lld\\n\",ans);\n\treturn 0;\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "97cf8e563a22091b7e8a539c11696656", "src_uid": "232c5206ee7c1903556c3625e0b0efc6", "difficulty": 1800.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main(){\nint N,x,y,c;\nscanf(\"%d %d %d %d\",&N,&y,&x,&c);\nint limx0=x-1,limx1=N-x;\nint limy0=y-1,limy1=N-y;\nint count,i,tope;\nif(c==1){\n    puts(\"0\");\n    return 0;\n}\nfor (i = 1; i < N*N; i*=2){\n\ncount = 1;int pos = 0;\n    for (int j = i; j >=0; j--,pos++)\n    {\n        if(pos>limx1 && pos>=x){\n            break;\n        }\n        if(pos==0){\n            if(j>limy0)count+=limy0;\n            else count+=j;\n            if(j>limy1)count+=limy1;\n            else count+=j;\n        }\n        else {\n        if(pos<=limx1){\n            if(j>limy0)count+=limy0;\n            else count+=j;\n            if(j>limy1)count+=limy1;\n            else count+=j;\n            count++;\n        }\n        if(poslimy0)count+=limy0;\n            else count+=j;\n            if(j>limy1)count+=limy1;\n            else count+=j;\n            count++;\n        }\n    }\n    }\n    if(count>=c)break;\n}\nif(i>N*N)i=N*N;\n//debugear con salto\ntope=i;\nint minimo;\nfor (; i < N*N; i*=0,75){\ncount = 1;int pos = 0;\n    for (int j = i; j >=0; j--,pos++){\n        if(pos>limx1 && pos>=x){\n            break;\n        }\n        if(pos==0){\n            if(j>limy0)count+=limy0;\n            else count+=j;\n            if(j>limy1)count+=limy1;\n            else count+=j;\n        }\n        else {\n        if(pos<=limx1){\n            if(j>limy0)count+=limy0;\n            else count+=j;\n            if(j>limy1)count+=limy1;\n            else count+=j;\n            count++;\n        }\n        if(poslimy0)count+=limy0;\n            else count+=j;\n            if(j>limy1)count+=limy1;\n            else count+=j;\n            count++;\n        }\n    }\n    }\n    if(count=0; j--,pos++){\n        if(pos>limx1 && pos>=x){\n            break;\n        }\n        if(pos==0){\n            if(j>limy0)count+=limy0;\n            else count+=j;\n            if(j>limy1)count+=limy1;\n            else count+=j;\n        }\n        else {\n        if(pos<=limx1){\n            if(j>limy0)count+=limy0;\n            else count+=j;\n            if(j>limy1)count+=limy1;\n            else count+=j;\n            count++;\n        }\n        if(poslimy0)count+=limy0;\n            else count+=j;\n            if(j>limy1)count+=limy1;\n            else count+=j;\n            count++;\n        }\n    }\n    }\n    if(count>=c)break;\n}\nprintf(\"%d\",i);\nputs(\"\");\n    ret", "lang_cluster": "C++", "compilation_error": true, "code_uid": "109f7292edb10eb340677e66281bce5a", "src_uid": "232c5206ee7c1903556c3625e0b0efc6", "difficulty": 1800.0}
    {"lang": "GNU C++0x", "source_code": "#include \n#include \n\ntypedef long long int64;\nint n, x, y, happy_value;\n\nvoid read() {\n  scanf(\"%d%d%d%d\", &n, &x, &y, &happy_value);\n}\n\nint64 calcTriangle(int height, int width) {\n  return height * (int64)(width - height + 1) >> 1;\n}\n\nint64 calcCornerON(int row, int column, int step) {\n  int dx = std::min(row, step);\n  int64 S = calcTriangle(dx, step);\n  if (column < step) {\n    dx = std:min(dx, step - column + 1);\n    S -= calcTriangle(dx, step) - dx * (int64)column;\n  }\n  return S;\n}\n\nint64 calcON(int step) {\n  int64 ans = 0;\n  int dx[2] = {x, n - x + 1};\n  int dy[2] = {y, n - y + 1};\n  for (int i = 0; i < 2; ++i) {\n    for (int j = 0; j < 2; ++j) {\n      ans += calcCornerON(dx[i], dy[j], step);\n    }\n  }\n  for (int i = 0; i < 2; ++i) {\n    ans -= std::min(step, dx[i]);\n    ans -= std::min(step, dy[i]);\n  }\n  ans += 1;\n  return ans;\n}\n\nvoid go() {\n  int min_step = 1, max_step = n * 2 ;\n  int mid_step;\n  while (min_step < max_step) {\n    mid_step = (min_step >> 1) + (max_step >> 1) + (min_step & max_step & 1);\n    if (calcON(mid_step) >= happy_value) [\n      max_step = mid_step;\n    } else {\n      min_step = mid_step + 1;\n    }\n  }\n  printf(\"%d\\n\", min_step - 1);\n}\n\nint main() {\n  read();\n  go();\n  return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b62dab1103ff72e10a11f717e8305998", "src_uid": "232c5206ee7c1903556c3625e0b0efc6", "difficulty": 1800.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nlong long n,x,y,c;\n\nlong long getnum(long long steps)\n{\n    long long xn,xx,yn,yx,mnn,mnx,mxx,mxn,res=steps*(steps+1)*2+1; \n    xn=max(0,steps-x+1);xx=max(0,steps-n+x);\n    yn=max(0,steps-y+1);yx=max(0,steps-n+y);\n    res-=max(0,xn*xn);res-=max(0,xx*xx);\n    res-=max(0,yn*yn);res-=max(0,yx*yx);\n    mnn=max(0,steps-x-y+1);mnx=max(0,steps-x-(n-y+1)+1);\n    mxx=max(0,steps-(n-x+1)-(n-y+1)+1);mxn=max(0,steps-(n-x+1)-y+1);\n    res+=max(0,mnn*(mnn+1)/2);\n    res+=max(0,mnx*(mnx+1)/2);\n    res+=max(0,mxx*(mxx+1)/2);\n    res+=max(0,mxn*(mxn+1)/2);\n    return res;\n}\n\nint main()\n{\n    cin>>n>>x>>y>>c;\n    long long left,mid,right;\n    left=0;right=n*2;\n    while(left<=right){\n        mid=(left+right)/2;\n        if(getnum(mid)\n\nusing namespace std;\n\ntypedef long long ll;\n\n#define pii pair\n#define pll pair\n#define PB push_back\n#define MP make_pair\n#define MOD 1000000007\n\nstring s;\n\nvector< vector > GetMatrix(string t){\n  int n = s.size();\n  vector< vector > A(2 * (n + 1), vector(2 * (n + 1), 0));\n\n  for(int i = 0; i < 2 * n + 2; ++i)\n    A[i][i] = 1;\n\n  for(int i = 0; i <= n; ++i){\n    string x = string(s, 0, i) + t;\n    int j = x.size();\n    for( ; j > 0; --j){\n      string y = string(s, 0, j);\n      string z = string(x, x.size() - j, j);\n      if(y.compare(z) == 0)\n        break;\n    }\n    A[2 * j][2 * i] += 1;\n    A[2 * j + 1][2 * i + 1] += 1;\n    A[2 * j + 1][2 * i] += (j == n);\n  }\n\n  return A;\n}\n\nvoid MatrixMultiplication(vector< vector >& A, vector< vector >& B, vector< vector >& C){\n  for(int i = 0, n = A.size(); i < n; ++i){\n    for(int j = 0; j < n; ++j){\n      int val = 0;\n      for(int k = 0; k < n; ++k){\n        if(A[i][k] == 0 || B[k][j] == 0)\n          continue;\n        val = (val + 1ll * A[i][k] * B[k][j]) % MOD;\n      }\n      C[i][j] = val;\n    }\n  }\n}\n\nint main(){\n  int n, k;\n\n  cin >> n >> k >> s;\n  reverse(s.begin(), s.end());\n\n  vector< vector > A = GetMatrix(\"0\"), B = GetMatrix(\"1\"), C(2 * (n + 1), vector(2 * (n + 1), 0)), D;\n\n  for(int i = 2; i <= k; ++i){\n    if(i % 3 == 0)\n      MatrixMultiplication(C, B, A);\n    else if(i % 3 == 1)\n      MatrixMultiplication(A, C, B);\n    else\n      MatrixMultiplication(B, A, C);\n  }\n\n  if(k % 3 == 0)\n    D = A;\n  else if(k % 3 == 1)\n    D = B;\n  else\n    D = C;\n\n  int ans = 0;\n  for(int i = 1, m = D.size(); i < m; i += 2)\n    ans = (ans + D[i][0]) % MOD;\n\n  cout << ans << '\\n';\n\n  return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6e07a5e7f6c197b23cd75832f7477a38", "src_uid": "52c6aa73ff4460799402c646c6263630", "difficulty": 2400.0}
    {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long ll;\n\n#define pii pair\n#define pll pair\n#define PB push_back\n#define MP make_pair\n#define MOD 1000000007\n\nstring s;\n\nvector< vector > GetMatrix(string t){\n  int n = s.size();\n  vector< vector > A(2 * (n + 1), vector(2 * (n + 1), 0));\n\n  for(int i = 0; i < 2 * n + 2; ++i)\n    A[i][i] = 1;\n\n  for(int i = 0; i <= n; ++i){\n    string x = string(s, 0, i) + t;\n    int j = x.size();\n    for( ; j > 0; --j){\n      string y = string(s, 0, j);\n      string z = string(x, x.size() - j, j);\n      if(y.compare(z) == 0)\n        break;\n    }\n    A[2 * j][2 * i] += 1;\n    A[2 * j + 1][2 * i + 1] += 1;\n    A[2 * j + 1][2 * i] += (j == n);\n  }\n\n  return A;\n}\n\nvoid MatrixMultiplication(vector< vector >& A, vector< vector >& B, vector< vector >& C){\n  for(int i = 0, n = A.size(); i < n; ++i){\n    for(int j = 0; j < n; ++j){\n      int val = 0;\n      for(int k = 0; k < n; ++k)\n        val = (val + 1ll * A[i][k] * B[k][j]) % MOD;\n      C[i][j] = val;\n    }\n  }\n}\n\nint main(){\n  int n, k;\n\n  cin >> n >> k >> s;\n  reverse(s.begin(), s.end());\n\n  vector< vector > A = GetMatrix(\"0\"), B = GetMatrix(\"1\"), C(2 * (n + 1), vector(2 * (n + 1), 0)), D;\n\n  for(int i = 2; i <= k; ++i){\n    if(i % 3 == 0)\n      MatrixMultiplication(C, B, A);\n    else if(i % 3 == 1)\n      MatrixMultiplication(A, C, B);\n    else\n      MatrixMultiplication(B, A, C);\n  }\n\n  if(k % 3 == 0)\n    D = A;\n  else if(k % 3 == 1)\n    D = B;\n  else\n    D = C;\n\n  int ans = 0;\n  for(int i = 1, m = D.size(); i < m; i += 2)\n    ans = (ans + D[i][0]) % MOD;\n\n  cout << ans << '\\n';\n\n  return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d033e20123225fc95e9977ebc236fb0b", "src_uid": "52c6aa73ff4460799402c646c6263630", "difficulty": 2400.0}
    {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define ll long long \n#define ld long double \n#define pb push_back\n#define F first\n#define S second\n#define mp make_pair\n#define I insert\n \nll N=1e9+7;\n\nll power(ll a, ll b, ll mod){\n\tll x = 1, y = a;\n\twhile (b > 0){\n\t\tif (b%2){\n\t\t\tx = (x*y)%mod;\n\t\t}\n\t\ty = (y*y)%mod;\n\t\tb /= 2;\n\t}\n\treturn x%mod;\n}\t\n\nmap M;ll fib[105];\nvoid mpas(string s){\n    ll a,b,c;string y;\n    a=s.length();\n    ll j=1;ll i,k;k=1;\n    for(i=0;i>n>>x>>s;\n    mpas(s);//map :: iterator it;for(it=M.begin();it!=M.end();it++)cout<<(*it).F<<\"-\"<<(*it).S<<\" \";\n    for(i=0;i<105;i++)for(j=0;j<10005;j++)dp[i][j]=-1,st[i][j]=-1,en[i][j]=-1,ns[i][j]=-1;\n    for(i=0;i<10005;i++)dp[0][i]=dp[1][i]=st[0][i]=en[1][i]=st[1][i]=en[0][i]=0,ns[0][i]=ns[1][i]=0;\n    if(M.count(\"0\"))dp[0][M[\"0\"]]=1,st[0][M[\"0\"]]=1,en[0][M[\"0\"]]=1,ns[0][M[\"0\"]]=1;if(M.count(\"1\"))dp[1][M[\"1\"]]=1,st[1][M[\"1\"]]=1,en[1][M[\"1\"]]=1,ns[1][M[\"1\"]]=1;\n//    cout<\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef vector vi;\ntypedef vector vu;\ntypedef vector vll;\ntypedef vector vull;\ntypedef pair pii;\ntypedef pair puu;\ntypedef pair pll;\ntypedef pair pull;\ntypedef vector vs;\n#define pb push_back\n#define ppb pop_back\n#define be begin\n#define all(x) (x).be(), (x).end()\n#define fst first\n#define fir first\n#define sec second\n#define mkp make_pair\n#define brif(cond) if (cond) break\n#define ctif(cond) if (cond) continue\n#define retif(cond) if (cond) return\nstatic inline void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}\ntemplate T gcd(T a, T b) {return b == 0 ? a : gcd(b, a%b);}\ntemplate T extgcd(T a, T b, T &x, T &y)\n{\n    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;\n    while (b) {\n        T q = a/b; a %= b; swap(a, b);\n        x0 -= q*x1; swap(x0, x1);\n        y0 -= q*y1; swap(y0, y1);\n    }\n    x = x0; y = y0; return a;\n}\n\n#define MOD 1000000007\n#define mul(a, b) (ull(a)*(b)%MOD)\n#define add(a, b) ((a)+(b) >= MOD ? (a)+(b)-MOD : (a)+(b))\n#define sub(a, b) ((a) < (b) ? (a)+MOD-(b) : (a)-(b))\n\nunsigned modinv(unsigned n)\n{\n    unsigned y0 = 0, y1 = 1, a = MOD;\n    while (n) {\n        unsigned q = a/n;\n        a %= n;\n        swap(a, n);\n        y0 = sub(y0, mul(q, y1));\n        swap(y0, y1);\n    }\n    return y0;\n}\n\nunsigned modpow(unsigned b, unsigned e)\n{\n    unsigned r = 1;\n    while (e) {\n        if (e&1) r = mul(r, b);\n        b = mul(b, b);\n        e >>= 1;\n    }\n    return r;\n}\n\nvoid matmul(const unsigned a[][128], const unsigned b[][128], unsigned c[][128], int n)\n{\n    for (int i = 0; i < n; ++i) {\n        for (int k = 0; k < n; ++k) {\n            for (int j = 0; j < n; ++j) c[i][j] = add(c[i][j], mul(a[i][k], b[k][j]));\n        }\n    }\n}\n\nint main()\n{\n    canhazfast();\n\n    static unsigned dp[101][101][101];\n    static char s[128];\n    int n, x;\n\n    cin >> n >> x >> s;\n    dp[0][0][0] = dp[0][n][n] = dp[1][0][0] = dp[1][n][n] = 2; /// wtf?!\n    for (int i = 1; i < n; ++i) dp[0][i][i] = dp[1][i][i] = 1;\n    for (int i = 0; i < n; ++i) dp[s[i]-'0'][i][i+1] = 1;\n    for (int i = 2; i <= x; ++i) matmul(dp[i-1], dp[i-2], dp[i], n+1);\n    cout << dp[x][0][n] << '\\n';\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1bd658cc8dc1937b677c1259ce6aa5ff", "src_uid": "52c6aa73ff4460799402c646c6263630", "difficulty": 2400.0}
    {"lang": "GNU C++14", "source_code": "#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#define endl \"\\n\"\n\t#define ll long long int\n\t#define vi vector\n\t#define vll vector\n\t#define vvi vector < vi >\n\t#define pii pair\n\t#define pll pair\n\t#define mod 1000000007\n\t#define inf 1000000000000000001\n\t#define all(c) c.begin(),c.end()\n\t#define mp(x,y) make_pair(x,y)\n\t#define mem(a,val) memset(a,val,sizeof(a))\n\t#define eb emplace_back\n\t#define f first\n\t#define s second\n# define M_PI           3.14159265358979323846  /* pi */\n// #define for(i,a,b) for(ll i=a;i> adj(100000); // adjacency list of graph\n\nvector visited;\nvector tin, fup;\nll timer;\nset bridges;\nvll eulerTour;\nll first[100000];\nll end[100000], par[100000], path[100000], sum[100000];\nvector height, euler, first, segtree;\nvector visited;\n\nvoid dfs(ll v, ll p = -1, ll h = 1) {\n    visited[v] = true;\n    height[v] = h;\n    tin[v] = fup[v] = timer++;\n    first[v] = euler.size();\n    euler.push_back(v);\n    for (ll to : adj[v]) {\n        if (to == p) continue;\n        if (visited[to]) {\n            fup[v] = min(fup[v], tin[to]);\n        } else {\n        \tpar[to] = v;\n            dfs(to, v, h+1);\n            euler.push_back(v);\n            fup[v] = min(fup[v], fup[to]);\n            if (fup[to] > tin[v]){\n                bridges.push_back(make_pair(v,to));\n                \n            }\n        }\n    }\n}\n\nvoid build(ll i, ll l, ll r)\n{\n    if (l == r) {\n        segtree[i] = euler[l];\n    } else {\n        ll m = (l + r) >> 1;\n        build(2 * i, l, m);\n        build(2 * i + 1, m + 1, r);\n        if (height[segtree[2 * i]] < height[segtree[2 * i + 1]])\n            segtree[i] = segtree[2 * i];\n        else\n            segtree[i] = segtree[2 * i + 1];\n        \n    }\n}\n\nll minimum(ll i, ll sl, ll sr, ll l, ll r)\n{\n    if (sl == l && sr == r)\n        return segtree[i];\n    ll sm = (sl + sr) >> 1;\n    if (r <= sm)\n        return minimum(2 * i, sl, sm, l, r);\n    if (l > sm)\n        return minimum(2 * i + 1, sm + 1, sr, l, r);\n    ll ans1 = minimum(2 * i, sl, sm, l, sm);\n    ll ans2 = minimum(2 * i + 1, sm + 1, sr, sm + 1, r);\n    return height[ans1] < height[ans2] ? ans1 : ans2;\n}\n\nll lca(ll u, ll v)\n{\n    ll left = first[u], right = first[v];\n    if (left > right)\n        swap(left, right);\n    return minimum(1, 0, euler.size() - 1, left, right);\n}\n\nvoid preprocess(ll root)\n{\n\ttimer = 0;\n    visited.assign(n, false);\n    tin.assign(n, -1);\n    fup.assign(n, -1);\n    height.resize(n);\n    first.resize(n);\n    euler.reserve(n * 2);\n    visited.assign(n, false);\n    fill(parent, parent+n, -1);\n    dfs(root);\n\n    ll m = euler.size();\n    segtree.resize(m * 4);\n    build(1, 0, m - 1);\n}\nint main () {\n\tstd::ios::sync_with_stdio(false);\n\tcin >> n >> m;\n\n\tfor(ll i = 0 ; i < m ; i++){\n\t\tll a,b;cin >> a >> b;a--;b--;\n\t\tadj[a].push_back(b);\n\t\tadj[b].push_back(a);\n\t}\n\tpreprocess(0);\n\n\tcin >> k;\n\n\tfor(ll i = 0 ; i < k ; i++){\n\t\tll a,b;cin >> a >> b;a--;b--;\n\t\tll lc = lca(a,b);\n\t\tif(lc == a){\n\t\t\tpath[b]+=1;\n\t\t\tif(a != 0)\n\t\t\t\tpath[par[a]]-=1;\n\t\t}\n\t\telse if(lc == b){\n\t\t\tpath[a]+=1;\n\t\t\tif(b != 0)\n\t\t\t\tpath[par[b]]-=1;\n\t\t}\n\t\telse{\n\t\t\tif(lc != 0)\n\t\t\t\tpath[par[lc]]-=2;\n\t\t\tpath[a]+=1;\n\t\t\tpath[b]+=1;\n\n\t\t}\n\t}\n\n\t\n    return 0; \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1ac74ba3ec487d0b0c1b42e61c79274f", "src_uid": "e6e760164882b9e194a17663625be27d", "difficulty": 1600.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\n#define n 1200005\nlong long cump[n],cumpa[n];\nbool prime[n];\n\nbool isPa(long long d)\n{\n    vector dig;\n    if(d==0)\n        dig.push_back(0);\n    while(d>0)\n    {\n        dig.push_back(d%10);\n        d/=10;\n    }\n\n    long long i=0,j=dig.size()-1;\n    while(i> p >> q;\n    long long ans=-1;\n    for(long long i=1;i0)\n        cout << ans << endl;\n    else cout << \"Palindromic tree is better than splay tree\\n\";\n    //getchar();\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "105ef5c07f0b7e57b4c80781f4fc8b8f", "src_uid": "e6e760164882b9e194a17663625be27d", "difficulty": 1600.0}
    {"lang": "GNU C++", "source_code": "// monera\n#include \n\n#define pb push_back\n#define mp make_pair\n#define f(i,a,b) for(int i =a; i <=b ; i++)\n#define all(a) a.begin(),a.end()\n#define ff first\n#define ss second\n#define sqr(x) ((x)*(x))\n#define EPS 1e-9\n#define db(var) cout< (b) ? (a) : (b))\n#define MIN(a, b) ((a) < (b) ? (a) : (b))\n#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )\n\n#define MOD 1000000007\n#define PI acos(-1.0)\n#define e exp(1.0)\n#define EPS 1e-9\n#define INF    2047483647\n#define INFLL  9023372036854775807LL\n\nusing namespace std;\nint prime[1000006];\nint palin[1000006];\nint pr[1000006];\n\nbool ispal(string a)\n{\n    string b=a;\n    reverse(b.begin(),b.end());\n    return a==b;\n}   \n\nvoid sieve()\n{\n    prime[1]=1;\n    prime[2]=0;\n    \n    for(int i=2;i<=1000000;i++)\n    {\n        if(prime[i]==0)\n        {\n            for(int j=2;j*i<=1000000;j++)\n            prime[j*i]=1;\n            \n        }\n    }\n}\n\nvoid pre()\n{\n    f(i,1,1000000)\n    {\n        int val=i;\n        string s=to_string(val);\n        palin[i]=palin[i-1];\n        pr[i]=pr[i-1];\n        if(ispal(s)==true)\n        {\n            palin[i]++;\n        }\n        \n        if(prime[val]==0)\n        {\n            pr[i]++;\n        }\n    }\n    \n    \n\n}\n\nint main() \n{\n    ios :: sync_with_stdio(0);\n     \n     sieve();\n     \n     pre();\n     \n     int p,q;\n     cin>>p>>q;\n     int ans=0;\n     \n     for(int i=1;i<=1000000;i++)\n     {\n        double v1=pr[i];\n        double v2=(double)((double)p/(double)q)*(double)palin[i];\n        \n        if(v1<=v2)\n        {\n            ans=i;\n        }\n        \n        \n     }\n     \n    \n    if(ans==0)\n    cout<<\"Palindromic tree is better than splay tree\\n\";\n    else\n    cout<\nusing namespace std;\n\nconst int MX = 2e6 + 7;\n\nint P[MX];\nint L[MX];\nbool oks[MX];\n\nbool oki(int x) {\n  string cionk;\n  while (x > 0) {\n    cionk += (char)(x % 10);\n    x /= 10;\n  }\n  string rv = string(cionk.rbegin(), cionk.rend());\n  return rv == cionk;\n}\n\nbool oki2(int k) {\n  string s = to_string (k);\n  while (s.back() == '0') s.pop_back();\n  reverse(s.begin(), s.end());\n  if (atoi(s.c_str()) == k) return true;\n  return false;\n}\n\nvoid init() {\n  L[0] = 0;\n  for (int i = 1; i < MX; ++i) {\n    L[i] = L[i - 1];\n    if (oki(i)) ++L[i];\n  }\n\n  for (int i = 2; i < MX; ++i) oks[i] = true;\n  for (int i = 2; i < MX; ++i)\n    for (int j = i + i; j < MX; j += i) oks[j] = false;\n\n  for (int i = 1; i < MX; ++i) {\n    P[i] = P[i - 1];\n    if (oks[i]) ++P[i];\n  }\n}\n\nint main(void) {\n  init();\n  double p, q;\n  cin >> p >> q;\n  for (int i = MX - 1; i > 0; --i)\n    if (P[i] <= (p / q) * (double)L[i]) {\n      cout << i << endl;\n      return 0;\n    }\n\n  cout << \"Palindromic tree is better than splay tree\\n\";\n\n  return 0;\n}\n  \n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b042fb877eee7dfc2ede9657566d3739", "src_uid": "e6e760164882b9e194a17663625be27d", "difficulty": 1600.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std;\n\n\nlong long ans,d,pd,a,b,c,n,m,i,si,k,apb,bpc,cpa,dar,j;\nvector  g;\nmain()\n{\n\n  cin>>n;\n   if (n%3!=0) {cout<<0<1)\n         {\n          bpc=g[j];\n          cpa=dar/g[j];\n              \n            if (  (apb+bpc\n#include \n\n#define DID (long long)\n\n\nusing namespace std;\n\nlong long l,r,mid,ans,N,i,j,a,b,c,x,y,z,len;\nlong long pos[45000],d[45000];\n\nmain()\n{\n      // freopen(\"text.in\",\"r\",stdin); freopen(\"text.out\",\"w\",stdout);\n\n      scanf(\"%I64d\\n\",&N);\n      if (N%3)\n      {\n         printf(\"0\\n\");\n         return 0;\n      }\n      N/=3;\n      for (i=1;DID i*i<=N;i++)\n          if (N%i==0)\n          {\n             d[len++]=i;\n             if (DID i*i!=N)\n             d[len++]=N/i;\n          }\n      sort(d,d+len);\n\n      for (i=0;i>1;\n                if (DID d[i]*d[mid]<=N) l=mid; else r=mid-1;\n                if (l+1==r)\n                if (DID d[i]*d[r]<=N) l++; else r--;\n          }\n          pos[i]=l;\n      }\n\n      for (i=1;i1 && y+z-x>1 && x+z-y>1) ans++;\n                 swap(y,z);\n                 if (y==z) continue;\n                 if ((x+y+z)%2==0 && x+y-z>1 && y+z-x>1 && x+z-y>1) ans++;\n              }\n      printf(\"%I64d\\n\",ans);\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b41266f346f673e4f25fc72a67e7826f", "src_uid": "07e58a46f2d562a44b7c771edad361b4", "difficulty": 2400.0}
    {"lang": "MS C++", "source_code": "#pragma warning(disable:4786)\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include \n\n\nusing namespace std;\n\n#define MEM(a,b) memset(a,(b),sizeof(a))\n#define MAX(a,b) ((a) > (b) ? (a) : (b))\n#define MIN(a,b)  ((a) < (b) ? (a) : (b))\n#define istr(S) istringstream sin(S)\n#define MP make_pair\n#define pb push_back\n#define inf 1000000000\n#define maxn 1000000\n\n//typedef  long  LL;\n\ntypedef __int64 LL;\n\ntypedef pair pi;\ntypedef vector vi;\ntypedef vector vs;\ntypedef vector vd;\n\n\nint solve(int n)\n{\n\tint i,j,k,ret=0;\n\n\n\t\n\tfor(i=1;i<=n;i++) if(n%i==0)\n\t\tfor(j=i;j<=n;j++) if( (n/i)%j==0)\n\t\t\t{\n\t\t\t\tk=n/(i*j);\n\t\t\t\tif(k1)\n\t\tpr[sz]=n,fr[sz++]=1;\n\n\t//for(i=0;i\n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\n#define repi(i, a) for(typeof((a).begin()) i = (a).begin(), _##i = (a).end(); i != _##i; ++i)\n\nconst int lim = 100100;\nconst int MAXQ = 10010000;\n\nll N;\n\nint ans = 0;\n\nvoid check(ll p, ll q) {\n\tll r = N / p / q;\n\tll a = p + r - q;\n\tll b = p + q - r;\n\tll c = q + r - p;\n\tif (a > 0 && b > 0 && c > 0 && a % 2 == 0) {\n\t\tint num = 3;\n\t\tif (a == b) --num;\n\t\tif (b == c) --num;\n\t\tif (a == c) --num;\n\t\tif (num == 0) ++num;\n\t\tif (num == 1) {\n\t\t\tans += 1;\n\t\t} else if (num == 2) {\n\t\t\tans += 3;\n\t\t} else if (num == 3) {\n\t\t\tans += 6;\n\t\t}\n\t}\n}\n\nint nxt[MAXQ];\nint main() {\n\tcin >> N;\n\tif (N % 3) {\n\t\tcout << \"0\\n\";\n\t\treturn 0;\n\t}\n\tN /= 3;\n\n\tint prv = 0;\n\tfor(ll q = 1; q * q <= N; ++q) {\n\t\tif (N % q == 0) {\n\t\t\tnxt[prv] = q;\n\t\t\tprv = q;\n\t\t}\n\t}\n\tnxt[prv] = N;\n\n\tfor(int p = 1; p <= lim; ++p) {\n\t\tif (N % p == 0) {\n\t\t\tll m = N / p;\n\t\t\tfor (ll q = p; q * q <= m; q = nxt[q]) {\n\t\t\t\tif (m % q == 0) {\n\t\t\t\t\tll r = N / p / q;\n\t\t\t\t\tcheck(p, q, r);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tcout << ans << \"\\n\";\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8b27d59c4cc6deef0570ae35e5a011fe", "src_uid": "07e58a46f2d562a44b7c771edad361b4", "difficulty": 2400.0}
    {"lang": "GNU C++11", "source_code": "using namespace std;\nchar buffer[300];\nint main() {\n  int F,I,T,count,c;\n  scanf(\"%d%d%d\", &F,&I,&T);\n  \nfor(int i=0;i=T) count++;\n}\n\n  printf(\"%d\", count);\n  return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c2e493dae1d383d14afc7e2b21cc26f8", "src_uid": "4c978130187e8ae6ca013d3f781b064e", "difficulty": 1900.0}
    {"lang": "GNU C++17", "source_code": "# kitten\nF, L, T = map(int,input().split())\ns = []\nfor i in range(F):\n  s.append(input())\nans = 0\nfor i in range(L):\n  cnt = 0\n  for j in range(F):\n    cnt += (s[j][i] == 'Y')\n  ans += cnt >= T\nprint(ans)", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ecc0886777d9c59a12012488c45a87d9", "src_uid": "4c978130187e8ae6ca013d3f781b064e", "difficulty": 1900.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main() {\n    vector m;\n    int f, z, t, i, j;\n    cin >> f >> z >> t;\n    for (i = 0; i < f; i++) {\n        string x;\n        cin >> x;\n        m.push_back(x);\n    }\n    int ans = 0;\n    for (i = 0,c; i < z; i++) {\n        c = 0;\n        for (j = 0; j < f; j++) {\n            if (m[j][i] == 'Y') {\n                c++;\n            }\n        }\n        if (c >= t) {\n            ans++;\n        }\n    }\n    cout << ans;\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "af6a1d15afca22429bbb04a9b4802277", "src_uid": "4c978130187e8ae6ca013d3f781b064e", "difficulty": 1900.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main() {\n    vector m;\n    int f, z, t, i, j, a;\n    cin >> f >> z >> t;\n    for (i = 0; i < f; i++) {\n        string x;\n        cin >> x;\n        m.push_back(x);\n    }\n    for (i = 0; i < z; i++) {\n        int c = 0;\n        for (j = 0; j < f; j++) {\n            if (m[j][i] == 'Y') {\n                c++;\n            }\n        }\n        if (c >= t) {\n            a++;\n        }\n    }\n    cout << a;\n    return 0;", "lang_cluster": "C++", "compilation_error": true, "code_uid": "07d0a553ceb974abfac1242fc52b7938", "src_uid": "4c978130187e8ae6ca013d3f781b064e", "difficulty": 1900.0}
    {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n#define maxn 105\n#define maxm 200005\n#define int long long\n#define inf 0x3f3f3f3f3f3f3fll\n#define mod 1000000007\n#define local\ntemplate\nvoid read(Tp &x){\n\tx=0;int f=1;char c=getchar();\n\twhile(c>'9'||c<'0'){if(c=='-'){f=-1;}c=getchar();}\n\twhile(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}x*=f;\n}\n\nstruct Mat{\n\tint mat[105][105];\n\tMat(){\n\t\tmemset(mat,0,sizeof(mat));\n\t}\n\tvoid reset(){\n\t\tfor(int i=0;i<=tmp;i++)mat[i][i]=1;\n\t}\n};\nMat mul(Mat a,Mat b){\n\tMat ret;\n\tfor(int i=0;i<=tmp;i++){\n\t\tfor(int j=0;j<=tmp;j++){\n\t\t\tfor(int k=0;k<=tmp;k++){\n\t\t\t\tret.mat[i][j]=(ret.mat[i][j]+a.mat[i][k]*b.mat[k][j]%mod)%mod;\n\t\t\t}\n\t\t}\n\t}\n\treturn ret;\n}\nMat Ksm(Mat b,int p){\n\tMat ret;\n\tret.reset();\n\twhile(p){\n\t\tif(p&1)ret=mul(ret,b);\n\t\tb=mul(b,b);\n\t\tp>>=1;\n\t}\n\treturn ret;\n}\n\nint n,m;\nint a[maxn],s[maxn];\nint fm;\nint ksm(int b,int p){\n\tint ret=1;\n\twhile(p){\n\t\tif(p&1)ret=ret*b%mod;\n\t\tb=b*b%mod;\n\t\tp>>=1;\n\t}\n\treturn ret;\n}\nint calc(){\n\tint tep=n-s[n];\n\tMat Base;\n\tMat ans;\n\tans.mat[1][tep-s[tep]]=1;\n\tfor(int i=0;i<=tep;i++){\n\t\tif(i)Base.mat[i-1][i]=(tep-i+1)%mod*(tep-i+1)%mod;\n\t\tif(i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n// #define DEBUG\n\nnamespace {\n#ifdef DEBUG\n    const int kDebug = true;\n#else\n    const int kDebuf = false;\n#endif\n}  // namespace\n\nconst int mod = (int)1e9 + 7;\n\nstruct Rational {\n    operator int() { return x; }\n    \n    Rational() {\n        this->x = 0;\n#ifdef DEBUG\n        this->rawValue = 0;\n#endif\n    }\n    Rational(int x) {\n        this->x = (mod + x % mod) % mod;\n#ifdef DEBUG\n        this->rawValue = x;\n#endif\n    }\n    \n    Rational operator * (int rh) {\n        Rational res((this->x * 1ll * ((mod + rh % mod) % mod)) % mod);\n#ifdef DEBUG\n        res.rawValue = this->rawValue * rh;\n#endif\n        return res;\n    }\n    \n    Rational operator * (Rational rh) {\n        Rational res((this->x * 1ll * rh.x) % mod);\n#ifdef DEBUG\n        res.rawValue = this->rawValue * rh.rawValue;\n#endif\n        return res;\n    }\n    \n    Rational operator += (Rational rh) {\n        this->x = (this->x + 0ll + rh.x) % mod;\n#ifdef DEBUG\n        this->rawValue += rh.rawValue;\n#endif\n        return *this;\n    }\n    \n    Rational operator = (int x) {\n        this->x = (mod + x % mod) % mod;\n#ifdef DEBUG\n        this->rawValue = x;\n#endif\n        return *this;\n    }\n    \n    Rational operator / (int x) {\n        Rational res(this->x * 1ll * reverse(x) % mod);\n#ifdef DEBUG\n        res.rawValue = this->rawValue / x;\n#endif\n        return res;\n    }\n    \n#ifdef DEBUG\n    double rawValue;\n#endif\nprivate:\n    int x;\n\n    int reverse(int x) {\n        x = (mod + x % mod) % mod;\n        return binPow(x, mod - 2);\n    }\n    \n    int binPow(int x, int p) {\n        if (!p) return 1;\n        if (p & 1) return binPow(x, p - 1) * 1ll * x % mod;\n        x = binPow(x, p >> 1);\n        return x * 1ll * x % mod;\n    }\n};\n\ntemplate \nstruct Matrix {\n    static Matrix unit(int size) {\n        Matrix res(size, size);\n        for (int i = 0; i < size; ++i)\n            res[i][i] = 1;\n        return res;\n    }\n    \n    int rows, cols;\n    vector < vector  > arr;\n    \n    Matrix (int rows, int cols) {\n        this->rows = rows;\n        this->cols = cols;\n        arr.clear();\n        for (int i = 0; i < rows; ++i) {\n            vector  tmp(cols);\n            arr.push_back(tmp);\n        }\n    }\n    \n    Matrix  operator * (Matrix rh) {\n        Matrix  lh = *this;\n        assert(lh.cols == rh.rows);\n        int commonSize = lh.cols;\n        \n        \n        Matrix  res(lh.rows, rh.cols);\n        for (int i = 0; i < lh.rows; ++i)\n            for (int j = 0; j < rh.cols; ++j)\n                for (int k = 0; k < commonSize; ++k)\n                    res[i][j] += lh[i][k] * rh[k][j];\n        \n        return res;\n    }\n    \n    vector & operator [] (int index) {\n        return arr[index];\n    }\n};\n\ntemplate \nMatrix binPow(Matrix m, int p) {\n    assert(m.rows == m.cols);\n    int size = m.rows;\n    \n    if (!p) return Matrix::unit(size);\n    if (p & 1) return binPow(m, p - 1) * m;\n    m = binPow(m, p >> 1);\n    return m * m;\n}\n\nconst int maxn = (int)1e2 + 10;\nint a[maxn];\n\nint main() {\n    int n, k;\n    cin >> n >> k;\n    int cntOnes = 0, cntZeros = 0;\n    for (int i = 0; i < n; ++i) {\n        cin >> a[i];\n        if (a[i]) cntOnes++;\n        else cntZeros++;\n    }\n    \n    int max_ = max(cntOnes, cntZeros);\n    int min_ = min(cntOnes, cntZeros);\n    if (min_ == 0)\n    {\n        cout << 1 << endl;\n        return 0;\n    }\n    \n    int badZeros = 0;\n    for (int i = 0; i < n; ++i) {\n        if (i >= cntZeros)\n            break;\n        badZeros += a[i] == 1;\n    }\n    \n    int size = min_ + 1;\n    Matrix initial(1, size);\n    initial[0][badZeros] = 1;\n    \n    Matrix step(size, size);\n    for (int i = 0; i <= min_; ++i) {\n        if (i < min_)\n            step[i + 1][i] = (i + 1) * (i + 1);\n        if (i > 0)\n            step[i - 1][i] = (max_ - i + 1) * (min_ - i + 1);\n        step[i][i] =\n            (i * (min_ - i) + i * (max_ - i) + min_ * (min_ - 1) / 2 + max_ * (max_ - 1) / 2);\n    }\n    \n#ifdef DEBUG\n    cout << (Rational(2) * 1 * 1 / n).rawValue << endl;\n    for (int i = 0; i <= min_; ++i)\n        for (int j = 0; j <= min_; ++j) {\n            cout << \"step[\" << i << \"][\" << j << \"]=\";\n            printf(\"%.7lf\\n\", step[i][j].rawValue);\n            cout << endl;\n        }\n#endif\n    step = binPow(step, k);\n#ifdef DEBUG\n    for (int i = 0; i <= min_; ++i)\n        for (int j = 0; j <= min_; ++j)\n            cout << \"step[\" << i << \"][\" << j << \"]=\" << step[i][j].rawValue << endl;\n#endif\n    \n    Matrix answer = initial * step;\n    Rational sum = 0;\n    for (int i = 0; i <= min_; ++i)\n        sum += answer[0][i];\n#ifdef DEBUG\n    cout << answer[0][0].rawValue << endl;\n    cout << sum << endl;\n#endif\n    cout << answer[0][0] / sum << endl;\n    return 0;\n}\n\n// CodeForces\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "aa085a1705c68d89d87ef9d85117a19c", "src_uid": "77f28d155a632ceaabd9f5a9d846461a", "difficulty": 2300.0}
    {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\ninline ll read() {\n    ll f=1,x=0;char ch=getchar();\n    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}\n    while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}\n    return x*f;\n}\nconst int MOD=1e9+7;\nconst int N=100;\nconst int MAXN=N+5;\nint pow_mod(int x,int i) {\n    int res=1;\n    while(i) {\n        if(i&1) res=(ll)res*x%MOD;\n        x=(ll)x*x%MOD;\n        i>>=1;\n    }\n    return res;\n}\nint n,k,a[MAXN],c,e,t;\nstruct Matrix {\n    int a[MAXN][MAXN];\n    Matrix(){memset(a,0,sizeof(a));}\n}B;\nMatrix operator * (Matrix X,Matrix Y) {\n    Matrix Z;\n    for(int i=0;i<=N;++i) \n        for(int j=0;j<=N;++j) \n            for(int k=0;k<=N;++k) \n                Z.a[i][j]=((ll)Z.a[i][j]+(ll)X.a[i][k]*Y.a[k][j]%MOD)%MOD;\n\n    return Z;\n}\nMatrix matrix_pow(Matrix X,int i) {\n    Matrix Y;\n    for(int i=0;i<=N;++i) Y.a[i][i]=1;\n    while(i) {if(i&1) Y=Y*X;X=X*X;i>>=1;}\n    return Y;\n}\nint main() {\n    n=read();k=read();\n    for(int i=1;i<=n;++i) a[i]=read(),c+=(a[i]==0);\n    for(int i=1;i<=c;++i) t+=(a[i]==0);\n    for(int i=0;i<=c;++i) {\n        if(i!=0) B.a[i-1][i]=1LL*(c-(i-1))*(c-(i-1))%MOD;\n        B.a[i][i]=1LL*(1LL*i*(c-i)%MOD+1LL*(c-i)*(n-c-c+i))%MOD;\n        B.a[i][i]=(B.a[i][i]+1LL*c*(c-1)/2%MOD)%MOD;\n        B.a[i][i]=(B.a[i][i]+1LL*(n-c)*(n-c-1)/2%MOD)%MOD;\n        if(i!=c) B.a[i+1][i]=1LL*(i+1)*(n-c-c+i+1)%MOD;\n    }\n    B=matrix_pow(B,k);\n    int ans=B.a[t][c];\n    for(int i=0;i<=c;++i)e=((ll)e+B.a[t][i])%MOD;\n    ans=((ll)ans*pow_mod(e,MOD-2))%MOD;\n    cout<\n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long LL;\ntypedef long double LD;\nconst int inf = 2*(1e9) + 10;\nconst long long infl = 2*(1e18) + 10;\nconst long long MOD = 1000000007;\nconst long NMAX = 300005;\n\nclass modMatrix{\n    public:\n    LL mat[55][55];\n    int n;\n\n    modMatrix(int _n)\n        : n(_n)\n    {\n        memset(mat, 0, sizeof(mat));\n    }\n\n    modMatrix operator*(const modMatrix& b){\n        modMatrix c(n);\n        for(int i=1; i<=n; ++i){\n            for(int j=1; j<=n; ++j){\n                for(int k=1; k<=n; ++k){\n                    c.mat[i][j] = (c.mat[i][j] + mat[i][k]*b.mat[k][j])%MOD;\n                }\n            }\n        }\n        return c;\n    }\n\n    modMatrix& operator%(int p){\n        for(int i=1; i<=n; ++i){\n            for(int j=1; j<=n; ++j){\n                mat[i][j] = (mat[i][j]) % p;\n            }\n        }\n        return *this;\n    }\n};\n\nint A[105];\n\ntemplate \nT binExp(T n, int k){\n    T x = n;\n    k--;\n    while(k){\n        if(k & 1)\n            x = (x*n)%MOD;\n        k = k/2;\n        n = (n*n)%MOD;\n    }\n    return x;\n}\n\nLL modInv(LL n){\n    return binExp(n, MOD - 2);\n}\n\nint main(){\n\n    LL n, k;\n    cin >> n >> k;\n\n    LL n1, n0;\n\n    n1 = 0;\n    for(int i=1; i<=n; ++i){\n        cin>>A[i];\n        n1 += A[i];\n    }\n    n0 = n - n1;\n\n    LL state0 = 0;\n    // 1 invades the 0 subsegment\n    for(int i=1; i<=n0; ++i){\n        state0 += (A[i] == 1);\n    }\n\n    modMatrix gen = modMatrix(min(n0, n1) + 1);\n\n    LL n0n1 = ((n0 * (((n0 - 1) * modInv(2))%MOD))%MOD +\n                (n1 * (((n1 - 1) * modInv(2))%MOD))%MOD)%MOD;\n    for(LL i=1; i<=min(n0, n1) + 1; ++i){\n        gen.mat[i][i] = (n0n1 + ((i-1)*(n - 2*i + 2))%MOD)%MOD;\n        if(i > 1)\n            gen.mat[i][i-1] = ((n0 - i + 2)*(n1 - i + 2))%MOD;\n        if(i < min(n0, n1) + 1)\n            gen.mat[i][i+1] = (i * i)%MOD;\n    }\n\n    gen = binExp(gen, k);\n\n    LL ans = 0;\n    ans = (gen.mat[1][state0+1] + ans) % MOD;\n\n\n    cout << (1LL * ans * modInv(binExp( (((n*(n-1))%MOD)*modInv(2))%MOD , k)))%MOD << \"\\n\";\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e91e6ccb979089d2b768db0f120dedfe", "src_uid": "77f28d155a632ceaabd9f5a9d846461a", "difficulty": 2300.0}
    {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n \nusing ll = long long;\nusing ld = long double;\nusing db = double; \nusing str = string; // yay python!\n\nusing pi = pair;\nusing pl = pair;\nusing pd = pair;\n\nusing vi = vector;\nusing vb = vector;\nusing vl = vector;\nusing vd = vector; \nusing vs = vector;\nusing vpi = vector;\nusing vpl = vector; \nusing vpd = vector;\n\n#define tcT template using V = vector; \ntcT, size_t SZ> using AR = array; \n\n// pairs\n#define mp make_pair\n#define f first\n#define s second\n\n// vectors\n#define sz(x) (int)(x).size()\n#define all(x) begin(x), end(x)\n#define rall(x) (x).rbegin(), (x).rend() \n#define sor(x) sort(all(x)) \n#define rsz resize\n#define ins insert \n#define ft front() \n#define bk back()\n#define pf push_front \n#define pb push_back\n#define eb emplace_back \n#define lb lower_bound \n#define ub upper_bound \n\n// loops\n#define FOR(i,a,b) for (int i = (a); i < (b); ++i)\n#define F0R(i,a) FOR(i,0,a)\n#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)\n#define R0F(i,a) ROF(i,0,a)\n#define trav(a,x) for (auto& a: x)\n\nconst int MOD = 1e9+7; // 998244353;\nconst int MX = 2e5+5;\nconst ll INF = 1e18; // not too close to LLONG_MAX\nconst int IINF = 1e9;\nconst ld PI = acos((ld)-1);\nconst int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; // for every grid problem!!\nmt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); \n\n// helper funcs\nconstexpr int pct(int x) { return __builtin_popcount(x); } // # of bits set\nconstexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) \nll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up\nll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down\n\ntcT> bool ckmin(T& a, const T& b) {\n\treturn b < a ? a = b, 1 : 0; } // set a = min(a,b)\ntcT> bool ckmax(T& a, const T& b) {\n\treturn a < b ? a = b, 1 : 0; }\n\n#define tcTU tcT, class U\ntcTU> T fstTrue(T lo, T hi, U f) {\n\thi ++; assert(lo <= hi); // assuming f is increasing\n\twhile (lo < hi) { // find first index such that f is true \n\t\tT mid = lo+(hi-lo)/2;\n\t\tf(mid) ? hi = mid : lo = mid+1; \n\t} \n\treturn lo;\n}\ntcTU> T lstTrue(T lo, T hi, U f) {\n\tlo --; assert(lo <= hi); // assuming f is decreasing\n\twhile (lo < hi) { // find first index such that f is true \n\t\tT mid = lo+(hi-lo+1)/2;\n\t\tf(mid) ? lo = mid : hi = mid-1;\n\t} \n\treturn lo;\n}\ntcT> void remDup(vector& v) { // sort and remove duplicates\n\tsort(all(v)); v.erase(unique(all(v)),end(v)); }\ntcTU> void erase(T& t, const U& u) { // don't erase\n\tauto it = t.find(u); assert(it != end(t));\n\tt.erase(u); } // element that doesn't exist from (multi)set\n\n// INPUT\n#define tcTUU tcT, class ...U\ntcT> void re(complex& c);\ntcTU> void re(pair& p);\ntcT> void re(vector& v);\ntcT, size_t SZ> void re(AR& a);\n\ntcT> void re(T& x) { cin >> x; }\nvoid re(db& d) { str t; re(t); d = stod(t); }\nvoid re(ld& d) { str t; re(t); d = stold(t); }\ntcTUU> void re(T& t, U&... u) { re(t); re(u...); }\n\ntcT> void re(complex& c) { T a,b; re(a,b); c = {a,b}; }\ntcTU> void re(pair& p) { re(p.f,p.s); }\ntcT> void re(vector& x) { trav(a,x) re(a); }\ntcT, size_t SZ> void re(AR& x) { trav(a,x) re(a); }\n\n// TO_STRING\n#define ts to_string\nstr ts(char c) { return str(1,c); }\nstr ts(const char* s) { return (str)s; }\nstr ts(str s) { return s; }\nstr ts(bool b) { \n\t#ifdef LOCAL\n\t\treturn b ? \"true\" : \"false\"; \n\t#else \n\t\treturn ts((int)b);\n\t#endif\n}\ntcT> str ts(complex c) { \n\tstringstream ss; ss << c; return ss.str(); }\nstr ts(vector v) {\n\tstr res = \"{\"; F0R(i,sz(v)) res += char('0'+v[i]);\n\tres += \"}\"; return res; }\ntemplate str ts(bitset b) {\n\tstr res = \"\"; F0R(i,SZ) res += char('0'+b[i]);\n\treturn res; }\ntcTU> str ts(pair p);\ntcT> str ts(T v) { // containers with begin(), end()\n\t#ifdef LOCAL\n\t\tbool fst = 1; str res = \"{\";\n\t\tfor (const auto& x: v) {\n\t\t\tif (!fst) res += \", \";\n\t\t\tfst = 0; res += ts(x);\n\t\t}\n\t\tres += \"}\"; return res;\n\t#else\n\t\tbool fst = 1; str res = \"\";\n\t\tfor (const auto& x: v) {\n\t\t\tif (!fst) res += \" \";\n\t\t\tfst = 0; res += ts(x);\n\t\t}\n\t\treturn res;\n\n\t#endif\n}\ntcTU> str ts(pair p) {\n\t#ifdef LOCAL\n\t\treturn \"(\"+ts(p.f)+\", \"+ts(p.s)+\")\"; \n\t#else\n\t\treturn ts(p.f)+\" \"+ts(p.s);\n\t#endif\n}\n\n// OUTPUT\ntcT> void pr(T x) { cout << ts(x); }\ntcTUU> void pr(const T& t, const U&... u) { \n\tpr(t); pr(u...); }\nvoid ps() { pr(\"\\n\"); } // print w/ spaces\ntcTUU> void ps(const T& t, const U&... u) { \n\tpr(t); if (sizeof...(u)) pr(\" \"); ps(u...); }\n\n// DEBUG\nvoid DBG() { cerr << \"]\" << endl; }\ntcTUU> void DBG(const T& t, const U&... u) {\n\tcerr << ts(t); if (sizeof...(u)) cerr << \", \";\n\tDBG(u...); }\n#ifdef LOCAL // compile with -DLOCAL, chk -> fake assert\n\t#define dbg(...) cerr << \"Line(\" << __LINE__ << \") -> [\" << #__VA_ARGS__ << \"]: [\", DBG(__VA_ARGS__)\n\t#define chk(...) if (!(__VA_ARGS__)) cerr << \"Line(\" << __LINE__ << \") -> function(\" \\\n\t\t << __FUNCTION__  << \") -> CHK FAILED: (\" << #__VA_ARGS__ << \")\" << \"\\n\", exit(0);\n#else\n\t#define dbg(...) 0\n\t#define chk(...) 0\n#endif\n\n// FILE I/O\nvoid setIn(str s) { freopen(s.c_str(),\"r\",stdin); }\nvoid setOut(str s) { freopen(s.c_str(),\"w\",stdout); }\nvoid unsyncIO() { cin.tie(0)->sync_with_stdio(0); }\nvoid setIO(str s = \"\") {\n\tunsyncIO();\n\t// cin.exceptions(cin.failbit); \n\t// throws exception when do smth illegal\n\t// ex. try to read letter into int\n\tif (sz(s)) { setIn(s+\".in\"), setOut(s+\".out\"); } // for USACO\n}\n\nstruct custom_hash {\n    static uint64_t splitmix64(uint64_t x) {\n        // http://xorshift.di.unimi.it/splitmix64.c\n        x += 0x9e3779b97f4a7c15;\n        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;\n        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;\n        return x ^ (x >> 31);\n    }\n\n    size_t operator()(uint64_t x) const {\n        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();\n        return splitmix64(x + FIXED_RANDOM);\n    }\n};\n\ntemplate struct Sieve {\n\tvi pr;\n\tint sp[SZ]; // smallest prime that divides\n\tSieve() { // above is faster\n\t\tmemset(sp,0,sizeof sp);\n\t\tFOR(i,2,SZ) {\n\t\t\tif (sp[i] == 0) sp[i] = i, pr.pb(i);\n\t\t\ttrav(p,pr) {\n\t\t\t\tif (p > sp[i] || i*p >= SZ) break;\n\t\t\t\tsp[i*p] = p;\n\t\t\t}\n\t\t}\n\t}\n};\nSieve<2000010> S;\n\nll exp(ll a, int b){\n\tif(b == 0)\n\t\treturn 1;\n\tll p = exp(a, b / 2);\n\tp = (p * p) % MOD;\n\tif(b & 1)\n\t\tp = (p * a) % MOD;\n\treturn p;\n}\n\nint main(){\n\tsetIO();\n\tint n;\n\tcin >> n;\n\tvector asp(n);\n\tmap m;\n\tvi p(n);\n\tF0R(a, n)\n\t\tcin >> p[a];\n\tsort(all(p), [](const int& a, const int& b){return a > b;});\n\tF0R(a, n){\n\t\tif(m[p[a]] == mp(0, 0))\n\t\t\tm[p[a]] = {1, 1}, asp[a] = true;\n\t\telse{\n\t\tint q = p[a] - 1;\n\t\tmap M;\n\t\twhile(q != 1){\n\t\t\tM[S.sp[q]]++;\n\t\t\tq /= S.sp[q];\n\t\t}\n\t\ttrav(b, M){\n\t\t\tauto temp = m[b.f];\n\t\t\tif(temp.f == b.s)\n\t\t\t\tm[b.f] = {temp.f, temp.s + 1};\n\t\t\telse if(temp.f < b.s)\n\t\t\t\tm[b.f] = {b.s, 1};\n\t\t}}\n\t}\n\tbool add = false;\n\tF0R(a, n){\n\t\tif(asp[a]){\n\t\t\tif(m[p[a]].f > 1 || m[p[a]].s > 1)\n\t\t\t\tadd = true;\n\t\t}\n\t\telse{\n\t\t\tbool good = true;\n\t\t\tint q = p[a] - 1;\n\t\t\telse{\n\t\t\tmap M;\n\t\t\twhile(q != 1){\n\t\t\t\tM[S.sp[q]]++;\n\t\t\t\tq /= S.sp[q];\n\t\t\t}\n\t\t\ttrav(b, M){\n\t\t\t\tauto temp = m[b.f];\n\t\t\t\tif(!(temp.f > b.s || temp.s > 1))\n\t\t\t\t\tgood = false;\n\t\t\t}\n\t\t\tif(good)\n\t\t\t\tadd = true;\n\t\t\t}\n\t\t}\n\t}\n\tll lcm = 1;\n\ttrav(a, m)\n\t\tlcm = (lcm * exp(a.f, a.s.f)) % MOD;\n\tcout << (lcm + add) % MOD << endl;\n\t// you should actually read the stuff at the bottom\n}\n\n/* stuff you should look for\n\t* int overflow, array bounds\n\t* special cases (n=1?)\n\t* do smth instead of nothing and stay organized\n\t* WRITE STUFF DOWN\n\t* DON'T GET STUCK ON ONE APPROACH\n*/\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "048d3afeaca43cd30a27835e2c00d7b1", "src_uid": "816a82bee65cf79ba8e4d61babcd0301", "difficulty": 2900.0}
    {"lang": "GNU C++11", "source_code": "#include\n#define N 2000005\ntypedef long long ll;\nconst ll M=1e9+7;\nusing namespace std;\n\nll ans=1;\nlong pr[N],primeid[N],cnt[N],nump=0,n,x,i,j,k,tmp,listp[N],id[N];\nvector maxid[N],num[N];\nbool f[N],fl[N],vis[N],isp[N],plus1s;\n\nbool cmp(vector a,vector b) {return a.size()>b.size();}\nint main()\n{\n\tfor (i=2; i<=N-5; i++)\n\t{\n\t\tif (!f[i]) pr[++nump]=i,primeid[i]=nump;\n\t\tfor (j=1; j<=nump&&i*pr[j]<=N-5; j++)\n\t\t{\n\t\t\tf[i*pr[j]]=1;\n\t\t\tif (i%pr[j]==0) break;\n\t\t}\n\t}\n\t\n\tcin>>n;\n\tfor (i=1; i<=n; i++)\n\t{\n\t\tcin>>x;\n\t\tif (cnt[x]==0) cnt[x]=1,fl[x]=1,id[x]=i,maxid[x].push_back(i);\n\t\telse {\n\t\t\tlong p=0,q=1;\n\t\t\tlistp[1]=x-1;\n\t\t\twhile (p=pr[j]; j++)\n\t\t\t\t{\n\t\t\t\t\tlong s=0;\n\t\t\t\t\twhile (tmp%pr[j]==0) s++,tmp/=pr[j];\n\t\t\t\t\tif (s>0&&fl[pr[j]]) q++,listp[q]=pr[j]-1,fl[pr[j]]=0,maxid[pr[j]].clear();\n\t\t\t\t\tif (s>cnt[pr[j]]) {cnt[pr[j]]=s,maxid[pr[j]].clear(); maxid[pr[j]].push_back(p==1?i:id[listp[p]+1]);}\n\t\t\t\t\t\telse if (s==cnt[pr[j]]&&s!=0) maxid[pr[j]].push_back(p==1?i:id[listp[p]+1]);\n\t\t\t\t\tif (!f[tmp]) j=primeid[tmp]-1;// black technology\n\t\t\t\t}\n\t\t\t}\n\t\t}\n//\t\tfor (k=1; k<=14; k++) {cout<\n#define fi first\n#define se second\n#define pb push_back\n#define eb emplace_back\nusing namespace std;\ntypedef long long LL;\ntypedef pair pii;\ntypedef vector vi;\n\ntemplate inline T re(){\n\tT N = 0; char c = getchar(); bool neg = 0;\n\tfor (; c < '0' || c > '9'; c = getchar()) neg |= c == '-';\n\tfor (; c >= '0' && c <= '9'; c = getchar())\n\t\tN = (N<<3)+(N<<1) + c - '0';\n\treturn neg ? -N : N;\n}\n\nconst int mod = 1e9 + 7;\nconst int mxsz = 1e5 + 5;\nconst int MX = 2e6;\n\nLL fpow(LL b, LL e){\n\tLL ret = 1;\n\tfor (; e > 0; e >>= 1){\n\t\tif (e&1) (ret *= b) %= mod;\n\t\t(b *= b) %= mod;\n\t}\n\treturn ret;\n}\n\nint n;\nint p[mxsz];\nint sml[MX + 5];\nvector fac[MX + 5];\n\nint Exp[MX + 5], occ[MX + 5];\nvoid prec(){\n\tfor (int i = 1; i <= MX; i++) sml[i] = i;\n\tfor (int i = 2; i <= MX; i++){\n\t\tif (sml[i] < i) continue;\n\t\tfor (LL j = 1LL * i * i; j <= MX; j += i)\n\t\t\tsml[j] = min(sml[j], i);\n\t}\n\tfor (int i = 2; i <= MX; i++){\n\t\tint u = i;\n\t\twhile (u > 1){\n\t\t\tint f = sml[u];\n\t\t\tfac[i].eb(f,0);\n\t\t\twhile (u % f == 0){\n\t\t\t\tu /= f; fac[i].back().se++;\n\t\t\t}\n\t\t}\n\t}\n}\nint main(){\n\tprec();\n\tn = re();\n\tfor (int i = 1; i <= n; i++) p[i] = re();\n\tsort(p+1,p+n+1, greater());\n\tfor (int i = 1; i <= n; i++){\n\t\tif (!Exp[p[i]]){ // prime first occurence\n\t\t\tExp[p[i]] = 1; occ[p[i]] = 1;\n\t\t} else {\n\t\t\tp[i]--;\n\t\t\tfor (pii P : fac[p[i]]){\n\t\t\t\tif (Exp[P.fi] < P.se){\n\t\t\t\t\tExp[P.fi] = P.se;\n\t\t\t\t\tocc[P.fi] = 1;\n\t\t\t\t} else if (Exp[P.fi] == P.se) occ[P.fi]++;\n\t\t\t}\n\t\t}\n\t}\n\tLL ext = 0, lcm = 1;\n\tfor (int i = 1; i <= n; i++){\n\t\tbool ad = 0;\n\t\tfor (pii P : fac[p[i]]){\n\t\t\tad |= (Exp[P.fi] == P.se && occ[P.fi] == 1);\n\t\t}\n\t\tif (!ad) ext = 1;\n\t}\n\tfor (int i = 2; i <= MX; i++){\n\t\t(lcm *= fpow(i, Exp[i])) %= mod;\n\t}\n\tprintf(\"%lld\\n\", (lcm + ext) % mod);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3ca8904eb2c8180e8ac464e005f3091f", "src_uid": "816a82bee65cf79ba8e4d61babcd0301", "difficulty": 2900.0}
    {"lang": "GNU C++17", "source_code": "#pragma GCC optimize(\"Ofast\")\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,avx\")\n#pragma GCC target (\"avx2,fma\")\n#pragma GCC optimize (\"O3\")\n#pragma GCC optimize (\"unroll-loops\")\n#include\n#include \n//#include \n\n#define F first\n#define S second\n#define int long long\n#define ll long long\n//#define int  unsigned long long\n#define pb push_back\n#define rank fewfewf\n#define double long double\n\nusing namespace std;\nusing namespace __gnu_pbds;\n//using namespace atcoder;\n\n\ntypedef  tree< int , null_type, less, rb_tree_tag, tree_order_statistics_node_update> ordered_set;\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\nconst int N = 1100105;\nconst int K = 90;\nconst int mod = 1e9 + 7;\nint p[N], a[N], have[N], b[N], taken[N];\nvector> d[N];\nmain(){\n    ios_base::sync_with_stdio(0);\n    cin.tie(0);\n    //freopen(\"input.txt\", \"r\", stdin);\n    //freopen(\"output.txt\", \"w\", stdout);\n    int n;\n    cin >> n;\n    for (int i = 2; i < N; i++){\n        if (p[i] == 0){\n            for (int j = i; j < N; j++){\n                p[j] = i;\n            }\n        }\n    }\n    for (int i = 0; i < n; i++) cin >> a[i];\n    reverse(a, a + n);\n    for (int i = 0; i < n; i++){\n        if (taken[a[i]]){\n            b[i] = a[i] - 1;\n            int y = b[i];\n            while(y != 1){\n                int x = p[y];\n                int k = 0;\n                while(y % x == 0){\n                    y /= x;\n                    k++;\n                }\n                d[i].pb({x, k});\n            }\n            for (auto x: d[i]){\n                taken[x.F] = 1;\n            }\n        } else{\n            b[i] = a[i];\n            taken[a[i]] = 1;\n            d[i].pb({a[i], 1});\n        }\n    }\n    int z = 0;\n    for (int i = 0; i < n; i++){\n        int ok = 0;\n        for (auto x: d[i]){\n            if (have[x.F] < x.S) ok = 1;\n            have[x.F] = max(x.S, have[x.F]);\n        }\n        if (!ok) z = 1;\n    }\n    int res = 1;\n    for (int i = 1; i < N; i++){\n        for (int j = 0; j < have[i]; j++){\n            res = res * i % mod;\n        }\n    }\n    cout << (z + res) % mod;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "413a595bb96f215805136ecbe694b49b", "src_uid": "816a82bee65cf79ba8e4d61babcd0301", "difficulty": 2900.0}
    {"lang": "GNU C++14", "source_code": "#include \ntypedef long long ll;\n\nint main(){\n\n    const ll MOD = 1000000007;\n    const ll N = 2007;\n\n    std::vector > f(N, std::vector(N, 0));\n    for(int p = 0; p < N; p++){\n        f[p][0] = 1;\n        for(int q = 1; q <= p; q++){f[p][q] = (f[p - 1][q - 1] + f[p - 1][q]) % MOD;}\n    }\n\n    ll n, m, k; scanf(\"%lld %lld %lld\", &n, &m, &k); \n    printf(\"%lld\\n\", f[n - 1][2 * k] * f[m - 1][2 * k] % MOD);\n\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "621a6b8e90a8b450842579a051ed0c5e", "src_uid": "309d2d46086d526d160292717dfef308", "difficulty": 2000.0}
    {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n#define start_routine() int begtime = clock();\n#define end_routine() int endtime = clock(); \\\n                      cerr << \"\\n\\n\" << \"Time elapsed: \" << \\\n                      (endtime - begtime)*1000/CLOCKS_PER_SEC << \" ms\\n\\n\"; \\\n                      return 0\n#define ll long long int\n#define ull unsigned long long int\n#define db long double\n#define ff first\n#define ss second\n#define mp make_pair\n#define pb push_back\n#define lb lower_bound\n#define ub upper_bound \n#define pii pair\n#define pdd pair\n#define pll pair\n#define vpl vector\n#define vll vector\n#define mod 1000000007\n#define mod1 998244353 \n#define inf 1000000000000000007\n#define eps 0.000001\n#define stp fixed<>n>>m>>k;\n    if(2*k>n || 2*k>m) return cout<<0;\n    ll a1=ncr[n-1][2*k];\n    ll a2=ncr[m-1][2*k];\n    cout<<(a1*a2)%mod;\n \n \n    #ifdef APNA_IO\n        end_routine();\n    #endif\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9ee5d3eed0e5da33bd87c6897e2da1d3", "src_uid": "309d2d46086d526d160292717dfef308", "difficulty": 2000.0}
    {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nconst long long unsigned kachal=1000*1000*1000+7;\nlong long unsigned pa[2001][2001];\nint main(){\n    int n,m,k;\n    cin >> n >> m >> k;\n    int s=max(n,m);\n    pa[0][0]=1;\n    for(int i=1;i<=s;i++)\n        for(int j=1;j<=2*k;j++){\n            if(j==i)\n                pa[i][j]=1;\n            pa[i][j]=(pa[i-1][j-1]+pa[i-1][j])%kachal;\n        }\n    cout << ((pa[n-1][2*k]%kachal)*(pa[m-1][2*k]%kachal))%kachal << endl;\n    system(\"pause\");\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cbf64c2b1712c2cebb03eee856e177f2", "src_uid": "309d2d46086d526d160292717dfef308", "difficulty": 2000.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std;\n\nint main(){\n    const long long MOD = 1000000007;\n    const long long N = 2007;\n\tvector > f(N, vector(N, 0));\n    for(int p = 0; p < N; p++){\n        f[p][0] = 1;\n        for(int q = 1; q <= p; q++){f[p][q] = (f[p - 1][q - 1] + f[p - 1][q]) % MOD;}\n    }\n    scanf(\"%ld %ld %ld\", &n, &m, &k); \n    printf(\"%ld\\n\", f[n - 1][2 * k] * f[m - 1][2 * k] % MOD);\n\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8048a98a6b0d291f64fb60912250f114", "src_uid": "309d2d46086d526d160292717dfef308", "difficulty": 2000.0}
    {"lang": "GNU C++14", "source_code": "#include\n#define ll long long\n#define mod 1000000007\n\nusing namespace std;\n\n\nint main()\n{\n    ios_base::sync_with_stdio(false);\n    cin.tie(NULL);\n    cout.tie(NULL);\n    ll d,p;\n    cin>>d>>p;\n    ll a=d;\n    cout<<\"^ 1 3\\n\";\n    while((a%(p-1))!=(2%(p-1)))\n    {\n        a=(a*d)%(p-1);\n        cout<<\"^ 3 3\\n\";\n    }\n    a=d;\n    cout<<\"^ 2 4\\n\";\n    unordered_set s;\n    s.insert(a);\n    while((a%(p-1))!=(2%(p-1)))\n    {\n        a=(a*d)%(p-1);\n        cout<<\"^ 4 4\\n\";\n        if(s.find(a)==s.end())\n        {\n            s.insert(a);\n        }\n        else break;\n    }\n    a=d;\n    cout<<\"+ 1 2 5\\n\";\n    cout<<\"^ 5 5\\n\";\n    while((a%(p-1))!=(2%(p-1)))\n    {\n        a=(a*d)%(p-1);\n        cout<<\"^ 5 5\\n\";\n    }\n    for(int i=1;i<31;i++)\n    {\n        cout<<\"+ 4999 4999 4999\\n\";\n        if((p&(1<\nlong long d, p, h;\nvoid add(long long e1, long long e2, long long to)\n{\n\tstd::cout << \"+ \" << e1 << \" \" << e2 << \" \" << to << std::endl;\n}\n\n\nvoid power(long long e1, long long to)\n{\n\tstd::cout << \"^ \" << e1 << \" \" << to << std::endl;\n}\n\n\nvoid multiply(long long position1, long long x, long long targetposition)\n{\n\tx = x % p;\n\tif (x <= 1) x = x + p;\n\tlong long v = x;\n\tv = v / 2;\n\tadd(position1, position1, targetposition);\n\twhile (v % 2 == 0)\n\t{\n\t\tadd(targetposition, targetposition, targetposition);\n\t\tv = v / 2;\n\t}\n\tadd(targetposition, targetposition, 4);\n\tif (x % 2 == 1)\n\t\tadd(targetposition, position1, targetposition);\n\tv = v / 2;\n\twhile (v != 0)\n\t{\n\t\tif (v % 2 == 1)\n\t\t\tadd(targetposition, 4, targetposition);\n\t\tif (v / 2 != 0) add(4, 4, 4);\n\t\tv = v / 2;\n\t}\n}\n\n\nvoid Minus(long long e1, long long e2, long long to)\n{\n\tmultiply(e2, p - 1, to);\n\tadd(e1, to, to);\n}\n\n\nlong long valuepower(long long x,long long z)\n{\n\tlong long i, y = 1;\n\tfor (i = 1; i <= z; i++)\n\t\ty = y * x;\n\treturn (y) % p;\n}\n\n\nlong long c(long long x, long long y)\n{\n\tlong long i, j = 1, k = 1;\n\tfor (i = 1; i <= y; i++)\n\t\tj = j * i;\n\tfor (i = x - y + 1; i <= x; i++)\n\t\tk = k * i;\n\treturn (k / j) % p;\n}\n\n\nvoid become1(long long x, long long position)\n{\n\tlong long v, o;\n\tx = x % p;\n\tif (x < 0) x = x + p;\n\tif (x != 0)\n\t{\n\t\tv = 1;\n\t\twhile (x != 1)\n\t\t{\n\t\t\tv = (v * (p / x) + v) % p;\n\t\t\tx = (x * (p / x) + x) % p;\n\t\t}\n\t\tv = v % p;\n\t\tmultiply(position,v,40);\n\t\tmultiply(40, 1, position);\n\t}\n}\n\n\nvoid special(long long x, long long position1, long long position2, long long target)\n{\n\tadd(x, position1, 5);\n\tpower(5, 5);\n\tadd(x, position2, 6);\n\tpower(6, 6);\n\tif (d % 2==0)\n\t\tadd(5, 6, target);\n\telse\n\t\tMinus(5, 6, target);\n}\n\nvoid getsquare()\n{\n\tif (d == 2)\n\t{\n\t\tpower(1, 7);\n\t\tpower(2, 8);\n\t\tadd(7, 8, 7);\n\t\tpower(3, 8);\n\t\th = 1;\n\t\tmultiply(7, p - 1, 9);\n\t\tadd(8, 9, 8);\n\t\tmultiply(8, (p + 1) / 2, 9);\n\t}\n\telse if (d == 3)\n\t{\n\t\tmultiply(10, -1, 11);\n\t\tspecial(1, 10, 11, 12);\n\t\tspecial(2, 10, 11, 13);\n\t\tadd(12, 13, 7);\n\t\tspecial(3, 10, 11, 12);\n\t\tmultiply(10, -4, 11);\n\t\tadd(7, 11, 7);\n\t\tmultiply(10, -2, 11);\n\t\tadd(12, 11, 8);\n\t\th = 6;\n\t\tmultiply(7, p - 1, 9);\n\t\tadd(8, 9, 8);\n\t\tmultiply(8, (p + 1) / 2, 9);\n\t}\n\telse\n\t{\n\t\tlong long t = (d - 1) / 2, i, j;\n\t\tfor (i = 11; i <= 9 + t; i++)\n\t\t\tadd(10, i - 1, i);\n\t\tmultiply(10, -t, 14 + t);\n\t\tfor (i = 13 + t; i >= 15; i--)\n\t\t\tadd(i + 1, 10, i);\n\t\tfor (i = 1; i <= t; i++)\n\t\t{\n\t\t\tspecial(2, 9 + i, 14 + i, 19);\n\t\t\tspecial(1, 9 + i, 14 + i, 20 + i);\n\t\t\tadd(19, 20 + i, 20 + i);\n\t\t\tspecial(3, 9 + i, 14 + i, 30 + i);\n\t\t\tmultiply(20 + i, - 1, 40 + i);\n\t\t\tadd(40 + i, 30 + i, 20 + i);\n\t\t}\n\t\tif (d % 2 == 0)\n\t\t{\n\t\t\tpower(1, 20);\n\t\t\tpower(2, 19);\n\t\t\tadd(20, 19, 20);\n\t\t\tmultiply(20, -1, 19);\n\t\t\tpower(3, 30);\n\t\t\tadd(19, 30, 20);\n\t\t\tfor (i = 1; i <= t; i++)\n\t\t\t{\n\t\t\t\tmultiply(20, -2, 30);\n\t\t\t\tadd(30, 20 + i, 20 + i);\n\t\t\t}\n\t\t}\n\t\tfor (i = 1; i <= t; i++)\n\t\t{\n\t\t\tpower(9 + i, 30);\n\t\t\tadd(30, 20 + i, 20 + i);\n\t\t\tadd(30, 20 + i, 20 + i);\n\t\t}\n\t\tif (t == 1)\n\t\t{\n\t\t\th = 12;\n\t\t\tmultiply(21, (p + 1) / 2, 9);\n\t\t}\n\t\tif (t == 2)\n\t\t{\n\t\t\tmultiply(21, -valuepower(2, d - 4), 31);\n\t\t\tadd(31, 22, 31);\n\t\t\th = valuepower(2, d - 1)*c(d, 2) - valuepower(2, d - 3)*c(d, 2);\n\t\t\tmultiply(31, (p + 1) / 2, 9);\n\t\t}\n\t\tif (t == 3)\n\t\t{\n\t\t\tlong long u = valuepower(2, d - 6);\n\t\t\tlong long v = valuepower(3, d - 6);\n\t\t\tmultiply(21, -u, 31);\n\t\t\tadd(31, 22, 22);\n\t\t\tmultiply(21, -v, 31);\n\t\t\tadd(31, 23, 23);\n\t\t\tlong long a1 = valuepower(2, d - 4), a2 = valuepower(2, d - 2), a3 = valuepower(3, d - 4), a4 = valuepower(3, d - 2);\n\t\t\tmultiply(22, a3 - v, 31);\n\t\t\tmultiply(23, u - a1, 32);\n\t\t\tadd(31, 32, 22);\n\t\t\tmultiply(22, (p + 1) / 2, 9);\n\t\t\th = 2 * ((a2 - u)*(a3 - v) + (a4 - v)*(u - a1))*c(d, 2);\n\t\t}\n\t\tif (t == 4)\n\t\t{\n\t\t\tlong long a[10][10];\n\t\t\tfor (i = 1; i <= 4; i++)\n\t\t\t\tfor (j = 1; j <= 4; j++)\n\t\t\t\t\ta[j][i] = valuepower(j, d - 2 * i);\n\t\t\tfor (i = 2; i <= 4; i++)\n\t\t\t{\n\t\t\t\tmultiply(21, -a[i][4], 30);\n\t\t\t\tadd(30, 20 + i, 20 + i);\n\t\t\t}\n\t\t\tfor (i = 2; i <= 4; i++)\n\t\t\t\tfor (j = 1; j <= 3; j++)\n\t\t\t\t\ta[i][j] = a[i][j] - a[i][4];\n\t\t\tfor (i = 3; i <= 4; i++)\n\t\t\t{\n\t\t\t\tmultiply(22, a[i][3], 30);\n\t\t\t\tmultiply(20 + i, -a[2][3], 31);\n\t\t\t\tadd(30, 31, 20 + i);\n\t\t\t\tfor (j = 1; j <= 2; j++)\n\t\t\t\t\ta[i][j] = a[2][j] * a[i][3] - a[2][3] * a[i][j];\n\t\t\t}\n\t\t\tmultiply(23, a[4][2], 30);\n\t\t\tmultiply(24, -a[3][2], 31);\n\t\t\tadd(30, 31, 24);\n\t\t\ta[4][1] = a[3][1] * a[4][2] - a[3][2] * a[4][1];\n\t\t\th = a[4][1] * 2 * c(d, 2);\n\t\t\tmultiply(24, (p + 1) / 2, 9);\n\t\t}\n\t}\n}\nint main()\n{\n\tusing namespace std;\n\tcin >> d >> p;\n\tadd(1, 2, 3);\n\tlong long i;\n\tgetsquare();\n\tbecome1(h, 9);\n\tcout << \"f \" << 9 << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9f6a0ec300ac237d503dfba09c832f88", "src_uid": "bbdc2a3d58f5229d7e9b67e4de70067f", "difficulty": 3300.0}
    {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \nconst int MAXN = 100 + 10;\n\nint d, p;\nvoid print_add(int a, int b, int c) {\n  printf(\"+ %d %d %d\\n\", a, b, c);\n}\nvoid print_pwr(int a, int b) {\n  printf(\"^ %d %d\\n\", a, b);\n}\nint x = 1, y = 2, one = 3, mone = 4, cur = 4;\nint choose[MAXN][MAXN];\nint print_mul(int x, int y) { // a[x] * y\n  int ans = ++cur;\n  print_add(ans, mone, ans);\n  for (; y; y >>= 1, print_add(x, x, x)) {\n    if (y & 1) print_add(ans, x, ans);\n  }\n  return ans;\n}\nint work(int a, int b, int c) {\n  int ans = ++cur;\n  print_add(ans, mone, ans);\n  if (a) print_add(x, ans, ans);\n  if (b) print_add(y, ans, ans);\n  for (int i = 1; i <= c; i++) print_add(ans, one, ans);\n  print_pwr(ans, ans);\n  return ans;\n}\nint pwr(int x, int y) {\n  int ans = 1;\n  for (; y; y >>= 1, x = 1ll * x * x % p) {\n    if (y & 1) ans = 1ll * ans * x % p;\n  }\n  return ans;\n}\nint main() {\n  scanf(\"%d%d\", &d, &p);\n\n  choose[0][0] = 1;\n  for (int i = 1; i <= d; i++) {\n    choose[i][0] = choose[i][i] = 1;\n    for (int j = 1; j < i; j++) {\n      choose[i][j] = choose[i - 1][j] + choose[i - 1][j - 1];\n    }\n  }\n\n  int ans = ++cur;\n\n  mone = print_mul(++cur, p - 3);\n  print_add(ans, mone, ans);\n  //fprintf(stderr, \"%d --\\n\", mone);\n  for (int i = 0; i <= 1; i++) {\n    for (int j = 0; j <= 1; j++) {\n      for (int k = 0; k <= d - 2; k++) {\n        int pos = work(i, j, k);\n        int t = choose[d - 2][k];\n        if ((d - (i + j + k)) & 1) {\n          t = p - t;\n        }\n        int o = print_mul(pos, t);\n        print_add(ans, o, ans);\n        //fprintf(stderr, \"%d %d %d %d %d %d--\\n\", i, j, k, pos, t, o);\n      }\n    }\n  }\n\n  int fact = 1;\n  for (int i = 1; i <= d; i++) fact = fact * i % p;\n  fact = pwr(fact, p - 2);\n  printf(\"f %d\\n\", print_mul(ans, fact));\n\n\n  \n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "93d2a8ba290493d75a981764c2be9297", "src_uid": "bbdc2a3d58f5229d7e9b67e4de70067f", "difficulty": 3300.0}
    {"lang": "GNU C++14", "source_code": "#include\n#define ll long long\n#define mod 1000000007\n\nusing namespace std;\n\n\nint main()\n{\n    ios_base::sync_with_stdio(false);\n    cin.tie(NULL);\n    cout.tie(NULL);\n    ll d,p;\n    cin>>d>>p;\n    ll a=d;\n    cout<<\"^ 1 3\\n\";\n    while((a%(p-1))!=(2%(p-1)))\n    {\n        a=(a*d)%(p-1);\n        cout<<\"^ 3 3\\n\";\n    }\n    a=d;\n    cout<<\"^ 2 4\\n\";\n    unordered_set()set s;\n    s.insert(a);\n    while((a%(p-1))!=(2%(p-1)))\n    {\n        a=(a*d)%(p-1);\n        cout<<\"^ 4 4\\n\";\n        if(s.find(a)==s.end())\n        {\n            s.insert(a);\n        }\n        else break;\n    }\n    a=d;\n    cout<<\"+ 1 2 5\\n\";\n    cout<<\"^ 5 5\\n\";\n    while((a%(p-1))!=(2%(p-1)))\n    {\n        a=(a*d)%(p-1);\n        cout<<\"^ 5 5\\n\";\n    }\n    for(int i=1;i<31;i++)\n    {\n        cout<<\"+ 4999 4999 4999\\n\";\n        if((p&(1<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\n#define rep(i,n) for(int i=0;i vi;\ntypedef vector vs;\ntypedef pair pi;\ntypedef long long ll;\n\nconst int inf=1<<28;\nconst double INF=1e12,EPS=1e-9;\n\nvoid run()\n{\n\tint l,r; cin>>l>>r;\n\tstring a,b; char s[20];\n\tsprintf(s,\"%d\",l); a=s;\n\tsprintf(s,\"%d\",r); b=s;\n\t\n\tint m=5,nine=9;\n\trep(i,b.size()-1)m*=10, nine*=10,nine+=9;\n\t\n\tif(m-1<=r){\n\t\tcout<<(m-1ll)*(nine-m+1)<\n   #include\n   using namespace std;\n   \n   int l,r,t;\n   long long re;\n   \n   int main()\n   {\n    cin >> l >> r;\n    t=9;\n    while (t=t) re=max(re,t*(t+1));\n    cout << re << endl;    \n    return 0;\n   }", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8421fff8b86cac13c41c63a1e8e74fd0", "src_uid": "2c4b2a162563242cb2f43f6209b59d5e", "difficulty": 1600.0}
    {"lang": "GNU C++", "source_code": "g`\"#include \n#include \nusing namespace std;\nint dec_bits( long long num ){\n\tint b = 0;\n\tfor(; num; num /= 10, b++ );\n\treturn b;\n}\nlong long dec_pow( int pow ){\n\tlong long val = 1;\n\tfor(; pow; pow --, val *= 10 );\n\treturn val;\n}\nlong long weight( long long num ){\n\treturn ( ( ( dec_pow( dec_bits( num ) )-1 )-num) * num );\n}\nint main(){\n\tlong long l, r, mid;\n\tcin >> l >> r;\n\tmid = (dec_pow( dec_bits( r ) )-1)/2;\n\tif( l < mid && mid < r ){\n\t\tcout << weight( mid ) << endl;\n\t}else{\n\t\tcout << max( weight(l), weight(r) ) << endl;\n\t}\n\treturn 0;\n}\n/****** PCCA -Wed Aug 03 02:50:15 GMT 2011 *******/", "lang_cluster": "C++", "compilation_error": true, "code_uid": "50707328179292714f6aa81a96ffe0e1", "src_uid": "2c4b2a162563242cb2f43f6209b59d5e", "difficulty": 1600.0}
    {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\n\nlong long  ref(string a)\n{\n\tlong long r = 0 ;\n\n\tfor(int i = 0 ; i < a.size() ; ++i )\n\t{\n\t\tr *= 10;\n\t\tr += (long long)(9 - (a[i]-'0'));\n\n\t}\n//\tcout<>l>>r;\n\n\tll = atoi(l.c_str());\n\trr = atoi(r.c_str());\n\n\tfor(int i = 0 ; i < r.size() ; ++i )\n\t{\n\t\tmid *= 10 ;\n\t\tmid += 9;\n\n\t\tmmid.push_back('9');\n\t}\n\tmmid[0]  = '4';\n\n\tmid /= 2;\n\n//\tcout< mid )\n\t\t{\n\t\t\tcout<\nusing namespace std\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair pii;\n#define mp make_pair\n\null INF;\null MOD;\null add(ull x, ull y) {\n\tx += y;\n\tif (x >= MOD) return x - MOD;\n\treturn x;\n}\null sub(ull x, ull y) {\n\tif (x < y) x += MOD;\n\treturn x - y;\n}\null mult(ull x, ull y) {\n\treturn (x * y) % MOD;\n}\n\nconst int N = 222;\null C[N][N];\nint d;\null a[N];\null b[N][N];\null dp[N][N];\n\null solve(int n) {\n\tfor (int i = 0; i <= min(n - 1, d); i++)\n\t\tfor (int j = 0; j < n; j++)\n\t\t\tdp[i][j] = 0;\n\tdp[0][n - 1] = 1 % MOD;\n\tfor (int i = 0; i < min(n - 1, d); i++)\n\t\tfor (int x = 0; x < n; x++) {\n\t\t\tdp[i][x] %= MOD;\n\t\t\tif (dp[i][x] == 0) continue;\n\t\t\tfor (int y = 1; y <= x; y++) {\n\t\t\t\tdp[i + 1][x - y] += dp[i][x] * ((a[y] * C[x - 1][y - 1]) % MOD) % MOD;\n\t\t\t}\n\t\t}\n\tull res = 0;\n\tfor (int i = 0; i <= min(n - 1, d); i++) {\n\t\tb[n][i] = dp[i][0] % MOD;\n\t\tres += dp[i][0] % MOD;\n\t}\n\treturn res % MOD;\n}\n\nint main()\n{\n//\tfreopen(\"input.txt\", \"r\", stdin);\n//\tfreopen(\"output.txt\", \"w\", stdout);\n\n\tint n;\n\tscanf(\"%d%d%llu\", &n, &d, &MOD);\n\tif (n == 1) {\n\t\tthrow;\n\t\tprintf(\"0\\n\");\n\t\treturn 0;\n\t}\n\tif (n == 2) {\n\t\tull ans = 4;\n\t\tprintf(\"%llu\\n\", ans % MOD);\n\t\treturn 0;\n\t}\n\tif (d == 1) {\n\t\tprintf(\"0\\n\");\n\t\treturn 0;\n\t}\n\n\td--;\n\tfor (int i = 0; i < N; i++)\n\t\tC[i][0] = C[i][i] = 1 % MOD;\n\tfor (int i = 1; i < N; i++)\n\t\tfor (int j = 1; j < i; j++)\n\t\t\tC[i][j] = add(C[i - 1][j - 1], C[i - 1][j]);\n\ta[0] = 1 % MOD;\n\tfor (int i = 1; i < n; i++)\n\t\ta[i] = solve(i);\n\td++;\n\ta[n] = solve(n);\n\t\n\tull ans = sub(a[n], b[n][1]);\n\tans = add(ans, ans);\n\n\tfor (int x = 1; x < n - 1; x++) {\n\t\tull sum = 0;\n\t\tfor (int i = 2; i <= d - 2; i++)\n\t\t\tsum = add(sum, b[n - x][i]);\n\t\tfor (int i = 2; i <= d - 2; i++) {\n\t\t\tans = add(ans, mult(sum, b[x + 1][i]));\n\t\t\tsum = sub(sum, b[n - x][d - i]);\n\t\t}\n\t}\n\tfor (int x = 1; x <= n; x++)\n\t\tfor (int y = 1; x + y <= n; y++)\n\t\t\tans = add(ans, mult(sub(a[x], b[x][1]), sub(a[y], b[y][1])));\n\n\n\tans *= n * (n - 1) * 2;\n\tans %= MOD;\n\tprintf(\"%llu\\n\", ans);\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6214c4f84d695004c92cea4e649332f6", "src_uid": "c84d69544f2d98512f0b05f504e1b5c6", "difficulty": 3400.0}
    {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nconst int N=407;\nint n,d,p,g[N]; long long c[N][N],dp[N][N],og[N][N];\nint main(){\n\tcin>>n>>d>>p,c[0][0]=1;\n\tfor(int i=1;i<=n;i++){\n\t\tc[i][0]=1; for(int j=1;j<=i;j++) c[i][j]=(c[i-1][j-1]+c[i-1][j])%p;\n\t}\n\tf[1]=1,dp[1][0]=1,og[1][0]=1;\n\tfor(int i=1;i<=n;i++)\n\t\tfor(int j=1;j<=n;j++){\n\t\t\tfor(int k=1;k<=i;k++) dp[i][j]=(dp[i][j]+1ll*dp[i-k][j-1]*og[k][d-1]%p*c[i-2][k-1])%p;\n\t\t\tog[i][j]=(og[i][j-1]+dp[i][j])%p;\n\t\t}\n\tint opt=0;\n\tfor(int i=1;i<=n;i++)\n\t\tfor(int j=0;j<=n;j++)\n\t\t\tfor(int k=0;j+k<=d;k++)\n\t\t\t\topt=(opt+1ll*dp[i][j]*dp[n-i+1][k])%p;\n\tfor(int i=1;i<=n;i++)\n\t\tfor(int j=1;j<=n;j++) dp[i][j]=(dp[i][j]+dp[i][j-1])%p;\n\tfor(int i=0;i0) opt=(opt-1ll*dp[i][d-1]*dp[j][d-1])%p;\n\t}\n\topt=(opt+p)%p; cout<<2ll*opt%p*n%p*(n-1)%p<\n#define o 1000005\n#define re register ll\n#define ll long long\n#define g0(a) memset(a,0,sizeof(a))\n#define gc(a,b) memcpy(a,b,sizeof(a))\n#define FOR(i,a,b) for(ll i=a;i<=b;i++)\n#define REP(i,a,b) for(ll i=a;i>=b;i--)\n#define pa pair\n#define mpp make_pair\n#define s1 first\n#define s2 second\nusing namespace std;\ninline ll read()\n{\n\tregister ll data=0,w=1;\n\tchar ch=0;\n\twhile(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();\n\tif(ch=='-')w=-1,ch=getchar();\n\twhile(ch>='0'&&ch<='9')data=(data<<1)+(data<<3)+(ch^48),ch=getchar();\n\treturn data*w;\n}\nll n,d,mod,c[205][205],ans,f[205][205],g[o];\nll main()\n{\n\tn=read(),d=read(),mod=read();\n\tif(mod==1)return puts(\"0\"),0;\n\tc[0][0]=1;\n\tFOR(i,1,n)c[i][0]=1;\n\tFOR(i,1,n)FOR(j,1,n)c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;\n\tf[1][0]=g[1]=1;\n\tFOR(i,2,n)\n\t\tFOR(j,1,d)\n\t\t{\n\t\t\tFOR(k,1,i-1)f[i][j]=(f[i][j]+1ll*f[i-k][j-1]*c[i-2][k-1]%mod*g[k])%mod;\n\t\t\tif(j!=d)g[i]=(g[i]+1ll*f[i][j])%mod;\n\t\t}\n\tll ans=0;\n\tFOR(i,1,n)FOR(j,0,d)for(ll k=0;j+k<=d;++k)if(k!=1)ans=(ans+1ll*f[i][j]*f[n-i+1][k])%mod;\n//\tcout<<\"ans=\"<\nusing namespace std;\n#define MAXN 205\n#define INF 0x3f3f3f3f\n#define FIO \"we\"\n#define ll long long\ntemplate \ninline void read(T &x)\n{\n\tT f=1;x=0;\n\tchar ch=getchar();\n\tfor (;!isdigit(ch) && ch!='-';ch=getchar());\n\tif (ch=='-')\tch=getchar(),f=-1;\n\tfor (;isdigit(ch);ch=getchar())\tx=x*10+ch-'0';\n\tx*=f;\n}\nll ans,D,N,c[MAXN][MAXN],f[MAXN][MAXN],s[MAXN][MAXN];\nint main()\n{\n\tread(N);read(D);read(MOD);\n\tfor (int i=0;i<=N;i++)\n\t{\n\t\tc[i][0]=1;\n\t\tfor (int j=1;j<=i;j++)\tc[i][j]=(c[i-1][j]+c[i-1][j-1])%MOD;\n\t}\n\tf[1][0]=s[1][0]=1;\n\tfor (int i=1;i<=N;i++)\n\t{\t\n\t\tfor (int j=1;j<=i-1;j++)\t\n\t\t\tfor (int k=1;k<=D;k++)\n\t\t\t\tf[i][k]=(f[i][k]+s[j][D-1]*c[i-2][j-1]%MOD*f[i-j][k-1]%MOD)%MOD;\n\t\tfor (int j=1;j<=D;j++)\ts[i][j]=(s[i][j-1]+f[i][j])%MOD;\n\t}\n\tfor (int i=1;i<=N;i++)\n\tfor (int j=0;j<=D;j++)\n\tfor (int k=0;k<=D-j;k++)\tif (k!=1)\n\t\tans=(ans+f[i][j]*f[N-i+1][k]%MOD)%MOD;\n\tprintf(\"%lld\\n\",ans*2*N*(N-1)%MOD);\n\tfclose(stdin);fclose(stdout);\n\treturn 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4443c6254359a191e63f8e26f4c7731f", "src_uid": "c84d69544f2d98512f0b05f504e1b5c6", "difficulty": 3400.0}
    {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long ll;\n\nconst ll mod = 1000000007;\n\nll a[1000000];\n\nll bp(ll a, int n) {\n\tll res = 1;\n\twhile (n) {\n\t\tif (n % 2) res *= a;\n\t\ta *= a;\n\t\tn /= 2;\n\t}\n\treturn res;\n}\n\nint main() {\n\t#ifdef LOCAL\n\t\tfreopen(\"input.in\", \"r\", stdin);\n\t\tfreopen(\"output.out\", \"w\", stdout);\n\t#endif\n\tint a, b, c, d;\n\tcin >> a >> b >> c >> d;\n\tif (a == k) cout << 1;\n\telse cout << 0;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e89f669d7ae8931f8d2328a1aac54ae3", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0}
    {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define ll long long\nint main(){\nll a,b,c,d;\ncin>>a>>b>>c>>d;\nll s=(2*a-2*d);\nif(((a+d\n\nusing namespace std;\n\nint main() {\n\tint q, w, e, r;\n\tcin >> q >> w >> e >> r;\n\tif ((q == r) && (q=>e)) {\n\t\tcout << 1;\n\t}\n\telse {\n\t\tcout << 0;\n\t}\n\n\n\n\t//system(\"pause\");\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0a14359e5588fe97bf5ed46d33999f44", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0}
    {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nnt main(\n    {\n        long long int a,b,c,d;\n        cin>>a;\n        cin>>b;\n        cin>>>c;\n        cin>>d;\n        if(a==d)\n        {cout<<\"1\\n\";\n        }\n        else\n        cout<<\"0\\n\";\n        return 0;\n    }", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6877375a2e628a741eeabb18a711ff8d", "src_uid": "b99578086043537297d374dc01eeb6f8", "difficulty": 1100.0}
    {"lang": "MS C++ 2017", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\ntypedef vector vi;\n\nint main(){\n\t\n\tint n, d;\n\tcin >> n >> d;\n\tvi v(n+1);\n\tstring s;cin >> s;\n\tfor(int i = 0;i < n;i++){\n\t\tif(s[i]=='1')v[i+1] = 1;\n\t\telse v[i+1] = 0;\n\t}\n\t\n\tconst int INF = 1e9;\n\tvi dist(n+1, INF), used(n+1, 0);\n\tqueue q;q.push(1);dist[1] = 0;\n\t\n\twhile(!q.empty()){\n\t\tint x = q.front();\n\t\tq.pop();\n\t\t//used[x] = 1;\n\t\tfor(int i = d;i >= 1;i--){\n\t\t\tif(x+i<=n){\n\t\t\t\tif(dist[x+i]==INF && v[x+i]){\n\t\t\t\t\tdist[x+i] = dist[x] + 1;\n\t\t\t\t\tq.push(x+i);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tif(dist[n] < INF)cout << dist[n];\n\telse cout << -1;\n\t\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "055a88b18b50ca1695e61851f850a398", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800.0}
    {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\n#define ll long long\n#define ld long double\n#define INF INFINITY\n\n#define vt vector\n#define pb push_back\n\n#define FOR(i,a,b) for(int i=a;i> n >> d;\n    int dp[n];\n    FOR(i,0,n){\n        int a; cin >> a;\n        dp[i] = a; \n    }\n    int ans=0;\n    for(int p=0;p0;d--){\n            int a = p;\n            if(p+d> t;\n    FOR(i,0,t){\n        solve();\n    }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "aa87c809a5b424f85b7c5789c09f867c", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e", "difficulty": 800.0}
    {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint main(){\nint n,d;\ncin>>n>>d;\nstring s;\ncin>>s;\nint count=0,p=0;\nwhile(p\n\nusing namespace std;\nint now=0,next,cnt;\n//    now=0;\n\nint check( string arr, int now, int d)\n{\n//    cout<<\"KMFDKF\"<=)\n//    go(s,d);\n//}\n\nint main()\n{\n    int n,d;\n    cin>>n>>d;\n    string s;\n    cin>>s;\n//    cout<\nusing namespace std;\n#define N 300005\n#define pb(a) push_back(a)\n\nvector e1[N],e2[N];\nint n,m,aim,len[N],st[N],ed,vis[N],tmp[N],l[N],r[N],L[N],R[N],cd[N],ans,tms[N];\nbool spe[N];\n\nvoid get(int k)\n{\n\tlen[k]=1;\n\tfor (auto v:e1[k])\n\t{\n\t\tif (!len[v]) get(v);\n\t\tlen[k]=max(len[k],len[v]+1);\n\t}\n}\n\ninline void mxs(int k)\n{\n\tfor (;len[k]>1;)\n\t{\n\t\tst[++ed]=k;\n\t\tfor (auto v:e1[k]) if (len[v]+1==len[k])\n\t\t{\n\t\t\tk=v;\n\t\t\tbreak;\n\t\t}\n\t}\n\tst[++ed]=k;\n\tfor (int i=1;i<=ed;i++) spe[st[i]]=1;\n}\n\nint dl(vector e[],int k,int vis[])\n{\n\tint rt=1;\n\tvis[k]=aim;\n\tfor (auto v:e[k]) if (!vis[v]) rt+=dl(e,v,vis);\n\treturn rt;\n}\n\nint find(vector e[],int k,bool tp)\n{\n\tint rt=1;\n\ttmp[k]=1;\n\tfor (auto v:e[k]) if ((tp?(l[v]>=aim):(r[v]<=aim)) && !tmp[v]) rt+=find(e,v,tp);\n\treturn rt;\n}\n\nvoid clear(int k,vector e[])\n{\n\ttmp[k]=0;\n\tfor (auto v:e[k]) if (tmp[k]) clear(v,e);\n}\n\ninline void solve(int k)\n{\n\tint l=L[k-1],r=R[k+1],v=cd[k];\n\taim=k;\n\tint tmp1=find(e1,v,0);\n\tclear(v,e1);\n\tint tmp2=find(e2,v,1);\n\tclear(v,e2);\n\tif (l+r+tmp1+tmp2==n) ans++;\n}\n\nint main()\n{\n\tscanf(\"%d%d\",&n,&m);\n\tfor (int i=1,u,v;i<=m;i++) scanf(\"%d%d\",&u,&v),e1[u].pb(v),e2[v].pb(u);\n\tfor (int i=1;i<=n;i++) if (!len[i]) get(i);\n\tint mx=0,pt=0;\n\tfor (int i=1;i<=n;i++) if (len[i]>mx) mx=len[i],pt=i;\n\tmxs(pt);\n\tfor (int i=1;i<=ed;i++) aim=i,L[i]=L[i-1]+dl(e2,st[i],l);\n\tfor (int i=ed;i;i--) aim=i,R[i]=R[i+1]+dl(e1,st[i],r);\n\tfor (int i=1;i<=ed;i++) if (L[i]+R[i]>=n) ans++;\n\tfor (int i=1;i<=n;i++) if (!l[i]) l[i]=ed+1;\n\tfor (int i=1;i<=n;i++) if (!spe[i]) if () tms[r[i]+1]++;\n\tfor (int i=1;i<=n;i++) if (!spe[i] && l[i]==r[i]+2 && tms[r[i]+1]==1) cd[r[i]+1]=i;\n\tfor (int i=1;i<=ed;i++) if (cd[i]) solve(i); \n\tprintf(\"%d\\n\",ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "344a4e56868c4f42ace50e0cf6f66f3b", "src_uid": "be26e93ca7aef1235e96e10467a6417e", "difficulty": 2900.0}
    {"lang": "GNU C++17", "source_code": "#include \n\n#define BLACK 0\n#define RED 1\nusing namespace std;\n\nstruct Node{\n    int key;\n    int color;\n    Node *l, *r, *p;\n};\n\nstruct Tree{\n    Node *root;\n    Node *begin, *end;\n    int size;\n};\n\nTree *create_tree(){\n    Tree *T = (Tree*)malloc(sizeof(Tree));\n    T->root = T->begin = T->end = NULL;\n    T->size = 0;\n    return T;\n}\n\nNode *right_rotate(Tree *T, Node *B){\n    if(!B->l) return B;\n    Node *A = B->l;\n    B->l = A->r;\n    if(B->l) B->l->p = B;\n    A->r = B;\n    if(!B->p) T->root = A;\n    else if(B->p->l == B) B->p->l = A;\n    else B->p->r = A;\n    A->p = B->p;\n    B->p = A;\n    return A;\n}\n\nNode *left_rotate(Tree *T, Node *A){\n    if(!A->r) return A;\n    Node *B = A->r;\n    A->r = B->l;\n    if(A->r) A->r->p = A;\n    B->l = A;\n    if(!A->p) T->root = B;\n    else if(A->p->l == A) A->p->l = B;\n    else A->p->r = B;\n    B->p = A->p;\n    A->p = B;\n    return B;\n}\n\nNode *next(Node *u){\n    if(!u) return NULL;\n    if(u->r){\n        u = u->r;\n        while(u->l) u = u->l;\n        return u;\n    }\n    else{\n        while(u->p && u->p->r == u) u = u->p;\n        return u->p;\n    }\n}\n\nNode *prev(Node *u){\n    if(!u) return NULL;\n    if(u->l){\n        u = u->l;\n        while(u->r) u = u->r;\n        return u;\n    }\n    else{\n        while(u->p && u->p->l == u) u = u->p;\n        return u->p;\n    }\n}\n\nint count(Tree *T, int key){\n    Node *u = T->root;\n    while(u){\n        if(key < u->key) u = u->l;\n        else if(key > u->key) u = u->r;\n        else return 1;\n    }\n    return 0;\n}\n\n\nbool show;\nvoid insert(Tree *T, int key){\n    Node *x = T->root, *par = NULL;\n    while(x){\n        par = x;\n        if(key < x->key) x = x->l;\n        else if(key > x->key) x = x->r;\n        else return; // element already exists!\n    }\n\n    x = (Node*)malloc(sizeof(Node));\n    x->l = x->r = NULL;\n    x->p = par;\n    \n    if(!x->p) T->root = T->begin = T->end = x;\n    else if(key < x->p->key){\n        x->p->l = x;\n        if(T->begin == x->p) T->begin = x;\n    }\n    else{\n        x->p->r = x;\n        if(T->end == x->p) T->end = x;\n    }\n    x->key = key;\n    x->color = RED;\n    T->size++;\n\n    while(x->p != NULL and x->p->color == RED){\n        if(x->p == x->p->p->l){ // A\n            Node *y = x->p->p->r;\n            if(y && y->color == RED){ // Case 1\n                x->p->color = BLACK;\n                y->color = BLACK;\n                x->p->p->color = RED;\n                x = x->p->p;\n            }\n            else{\n                if(x == x->p->r){ // zigzag, Case 2\n                    x = x->p;\n                    left_rotate(T, x);\n                }\n                // left chain, Case 3\n                x->p->color = BLACK;\n                x->p->p->color = RED;\n                right_rotate(T, x->p->p);\n            }\n        }\n        else{ // B\n            Node *y = x->p->p->l;\n            if(y && y->color == RED){ // Case 1\n                x->p->color = BLACK;\n                y->color = BLACK;\n                x->p->p->color = RED;\n                x = x->p->p;\n            }\n            else{\n                if(x == x->p->l){ // zigzag, Case 2\n                    x = x->p;\n                    right_rotate(T, x);\n                }\n                // right chain, Case 3\n                x->p->color = BLACK;\n                x->p->p->color = RED;\n                left_rotate(T, x->p->p);\n            }\n        }\n    }\n\n    T->root->color = BLACK;\n}\n\nNode *clear(Node *u){\n    if(!u) return NULL;\n    clear(u->l);\n    clear(u->r);\n    free(u);\n    return NULL;\n}\n\nTree *delete_tree(Tree *T){\n    if(T){\n        clear(T->root);\n        free(T);\n    }\n    return NULL;\n}\nint show2;\nvoid transplant(Tree *T, Node *u, Node *v){\n    if(!u->p) T->root = v;\n    else if(u == u->p->l) u->p->l = v;\n    else u->p->r = v;\n    if(v) v->p = !u ? NULL : u->p;\n}\nvoid Delete_fix(Tree *T, Node *x){\n    if(!x) return;\n    while(x->p != NULL and x->color == BLACK){\n        if(x == x->p->l){\n            Node *w = x->p->r;\n            if(w->color == RED){\n                w->color = BLACK;\n                x->p->color = RED;\n                left_rotate(T, x->p);\n                w = x->p->r;\n            }\n    if(!w) return;\n            if((!w->r || w->r->color == BLACK) and\n               (!w->l || w->l->color == BLACK)){\n                w->color = RED;\n                x = x->p;\n            }\n            else{\n                if(w->l and w->l->color == RED){\n                    w->l->color = BLACK;\n                    w->color = RED;\n                    right_rotate(T, w);\n                    w = x->p->r;\n                }\n                w->color = x->p->color;\n                x->p->color = BLACK;\n                if(w and w->r) w->r->color = BLACK;\n                left_rotate(T, x->p);\n                x = T->root;\n            }\n        }\n        else{\n            Node *w = x->p->l;\n    if(show2){\n    \tprintf(\"qewqeewewq %d %p %p %p\\n\", T->size, w, w->l, w->r);\n    \tfor(Node *it = T->begin; it; it = next(it)){\n    \t\tprintf(\".%d\", it->key);\n    \t\tif(it->color == RED){\n    \t\t\tif(it->p == NULL || it->p->color == RED)\n    \t\t\t\texit(0);\n    \t\t}\n    \t}\n    \tprintf(\"\\n\");\n    \tfflush(stdout);\n    }\n            if(w->color == RED){\n                w->color = BLACK;\n                x->p->color = RED;\n                right_rotate(T, x->p);\n                w = x->p->l;\n            }\n    if(show2){\n    \tprintf(\"qewqeewewq %p\\n\", w);\n    \tfflush(stdout);\n    }\n    if(!w) return;\n            if((!w->r || w->r->color == BLACK) and\n               (!w->l || w->l->color == BLACK)){\n                w->color = RED;\n                x = x->p;\n            }\n            else{\n                if(w and w->r and w->r->color == BLACK){\n                    w->r->color = BLACK;\n                    w->color = RED;\n                    left_rotate(T, w);\n                    w = x->p->l;\n                }\n                if(w) w->color = x->p->color;\n                x->p->color = BLACK;\n                if(w and w->l) w->l->color = BLACK;\n                right_rotate(T, x->p);\n                x = T->root;\n            }\n        }\n    }\n    if(show2){\n    \tprintf(\"qewqeewewq\\n\");\n    \tfflush(stdout);\n    }\n    x->color = BLACK;\n}\n\nvoid Delete(Tree *T, Node *z){\n    Node *y = z, *x = NULL;\n    int y_original_color = y->color;\n\n    if(T->begin == z) T->begin = next(T->begin);\n    if(T->end == z) T->end = prev(T->end);\n    \n    if(!z->l){\n        x = z->r;\n        transplant(T, z, z->r);\n    }\n    else if(!z->r){\n        x = z->l;\n        transplant(T, z, z->l);\n    }\n    else{\n        y = z->r;\n        while(y->l) y = y->l;\n        if(y != next(z)) exit(0);\n        y_original_color = y->color;\n        x = y->r;\n        if(y->p == z){\n            if(x) x->p = y;\n        }\n        else{\n            transplant(T, y, y->r);\n            y->r = z->r;\n            if(y->r) y->r->p = y;\n        }\n        transplant(T, z, y);\n        y->l = z->l;\n        if(y->l) y->l->p = y;\n        y->color = z->color;\n    }\n\n    if(y_original_color == BLACK){\n    // if(show) printf(\"3\\n\");\n        Delete_fix(T, x);\n    // if(show) printf(\"4\\n\");\n    }\n\n    free(z);\n    T->size--;\n    if(T->root) T->root->color = BLACK;\n}\n\nvoid Delete_val(Tree *T, int val){\n    Node *u = T->root;\n    while(u){\n        if(val < u->key) u = u->l;\n        else if(val > u->key) u = u->r;\n        else break;\n    }\n    if(u) Delete(T, u);\n}\n\nconst int N = 300005;\n\nvector g[N], gt[N];\nint n, m;\nvector topo;\nint vis[N];\nint cnt[N];\nint alm[N];\nint deg[N], in[N];\nint fine[N];\n\nvoid dfs(int u){\n    vis[u] = 1;\n    for(int v : g[u]) if(!vis[v])\n        dfs(v);\n    topo.push_back(u);\n}\n\nint check(Node *u){\n\tif(!u) return 1;\n\tint a = check(u->l);\n\tint b = check(u->l);\n\tif(a != b){\n\t\texit(0);\n\t}\n\tif(u->color == BLACK) return a + 1;\n\treturn a;\n}\n\nint main(){\n    Tree *s = create_tree();\n\n    scanf(\"%d %d\", &n, &m);\n    if(n == 100000) show = 1;\n\n    for(int i = 0, a, b; i < m; i++){\n        scanf(\"%d %d\", &a, &b);\n        g[a].push_back(b);\n        gt[b].push_back(a);\n    }\n\n    for(int i = 1; i <= n; i++) if(!vis[i])\n        dfs(i);\n\n    reverse(topo.begin(), topo.end());\n\n    for(int i = 0; i < n; i++){\n        int u = topo[i];\n        for(int v : gt[u]){\n            deg[v]++;\n            if(count(s, v)){\n                Delete_val(s, v);\n            }\n            if(deg[v] == 2){\n                for(int k : g[v])\n                    fine[k]++;\n            }\n        }\n        if(s->size == 1){\n            alm[u] = 1;\n            if((int)gt[s->begin->key].size() > fine[s->begin->key]) alm[u] = 0;\n            //for(int v : gt[*s.begin()])\n            //    alm[u] &= (deg[v] >= 2);\n        }\n        else if(!s->size) cnt[u] = 1;\n        insert(s, u);\n    }\n\n    memset(deg, 0, sizeof deg);\n    memset(fine, 0, sizeof fine);\n\n    reverse(topo.begin(), topo.end());\n    \n    delete_tree(s);\n    s = create_tree();\n    int ans = 0;\n\n    int lim = 3414;\n    for(int i = 0; i < n; i++){\n    \tif(show) for(Node *it = s->begin; it; it = next(it)){\n    \t\tif(it->color == RED){\n    \t\t\tif(it->p == NULL || it->p->color == RED)\n    \t\t\t\texit(0);\n    \t\t}\n    \t}\n    \tif(show) check(T->root);\n        int u = topo[i];\n    \tif(show && i >= lim){\n    \t\tprintf(\"@%d\\n\", i);\n    \t\tprintf(\"%d\\n\", g[u].size());\n    \t\tfflush(stdout);\n    \t\t// return 0;\n    \t}\n        for(int v : g[u]){\n            deg[v]++;\n            if(show && i >= lim){\n\t    \t\tprintf(\"!%d %d\\n\", i, count(s, v));\n\t    \t\tfflush(stdout);\n\t    \t\tshow2 = true;\n\t    \t\t// return 0;\n\t    \t}\n            if(count(s, v)){\n                Delete_val(s, v);\n            }\n            if(show && i >= lim){\n\t    \t\tprintf(\"#%d\\n\", i);\n\t    \t\tfflush(stdout);\n\t    \t\t// return 0;\n\t    \t}\n            if(deg[v] == 2){\n                for(int k : gt[v])\n                    fine[k]++;\n            }\n        }\n        if(show && i >= lim){\n    \t\tprintf(\"@%d\\n\", i);\n    \t\tfflush(stdout);\n    \t\t// return 0;\n    \t}\n        bool tmp;\n        if(s->size == 1){\n            tmp = 1;\n            if((int)g[s->begin->key].size() > fine[s->begin->key]) tmp = 0;\n            // for(int v : g[*s.begin()])\n            //    tmp &= deg[v] >= 2;\n            if(tmp && cnt[u]) ans++;\n        }\n        else if(!s->size && (cnt[u]+alm[u])) ans++;\n        insert(s, u);\n    \tif(show && i >= lim){\n    \t\tprintf(\"@%d\\n\", i);\n    \t\tfflush(stdout);\n    \t\t// return 0;\n    \t}\n    }\n\n    printf(\"%d\\n\", ans);\n\n    delete_tree(s);\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e6cd6fde876c6c4f9b937ed709976294", "src_uid": "be26e93ca7aef1235e96e10467a6417e", "difficulty": 2900.0}
    {"lang": "GNU C++11", "source_code": "#include \n\n#define BLACK 0\n#define RED 1\nusing namespace std;\n\nstruct Node{\n    int key;\n    int color;\n    Node *l, *r, *p;\n};\n\nstruct Tree{\n    Node *root;\n    Node *begin, *end;\n    int size;\n};\n\nTree *create_tree(){\n    Tree *T = (Tree*)malloc(sizeof(Tree));\n    T->root = T->begin = T->end = NULL;\n    T->size = 0;\n    return T;\n}\n\nNode *right_rotate(Tree *T, Node *B){\n    // assert(B->l != NULL);\n    Node *A = B->l;\n    B->l = A->r;\n    if(B->l) B->l->p = B;\n    A->r = B;\n    if(!B->p) T->root = A;\n    else if(B->p->l == B) B->p->l = A;\n    else B->p->r = A;\n    A->p = B->p;\n    B->p = A;\n    return A;\n}\n\nNode *left_rotate(Tree *T, Node *A){\n    // assert(A->r != NULL);\n    Node *B = A->r;\n    A->r = B->l;\n    if(A->r) A->r->p = A;\n    B->l = A;\n    if(!A->p) T->root = B;\n    else if(A->p->l == A) A->p->l = B;\n    else A->p->r = B;\n    B->p = A->p;\n    A->p = B;\n    return B;\n}\n\nNode *next(Node *u){\n    if(!u) return NULL;\n    if(u->r){\n        u = u->r;\n        while(u->l) u = u->l;\n        return u;\n    }\n    else{\n        while(u->p && u->p->r == u) u = u->p;\n        return u->p;\n    }\n}\n\nNode *prev(Node *u){\n    if(!u) return NULL;\n    if(u->l){\n        u = u->l;\n        while(u->r) u = u->r;\n        return u;\n    }\n    else{\n        while(u->p && u->p->l == u) u = u->p;\n        return u->p;\n    }\n}\n\nint count(Tree *T, int key){\n    Node *u = T->root;\n    while(u){\n        if(key < u->key) u = u->l;\n        else if(key > u->key) u = u->r;\n        else return 1;\n    }\n    return 0;\n}\n\n\nbool show;\nvoid insert(Tree *T, int key){\n    Node *x = T->root, *par = NULL;\n    while(x){\n        par = x;\n        if(key < x->key) x = x->l;\n        else if(key > x->key) x = x->r;\n        else return; // element already exists!\n    }\n\n    x = (Node*)malloc(sizeof(Node));\n    x->l = x->r = NULL;\n    x->p = par;\n    \n    if(!x->p) T->root = T->begin = T->end = x;\n    else if(key < x->p->key){\n        x->p->l = x;\n        if(T->begin == x->p) T->begin = x;\n    }\n    else{\n        x->p->r = x;\n        if(T->end == x->p) T->end = x;\n    }\n    x->key = key;\n    x->color = RED;\n    T->size++;\n\n    while(x->p != NULL && x->p->color == RED){\n        if(x->p == x->p->p->l){ // A\n            Node *y = x->p->p->r;\n            if(y && y->color == RED){ // Case 1\n                x->p->color = BLACK;\n                y->color = BLACK;\n                x->p->p->color = RED;\n                x = x->p->p;\n            }\n            else{\n                if(x == x->p->r){ // zigzag, Case 2\n                    x = x->p;\n                    left_rotate(T, x);\n                }\n                // left chain, Case 3\n                x->p->color = BLACK;\n                x->p->p->color = RED;\n                right_rotate(T, x->p->p);\n            }\n        }\n        else{ // B\n            Node *y = x->p->p->l;\n            if(y && y->color == RED){ // Case 1\n                x->p->color = BLACK;\n                y->color = BLACK;\n                x->p->p->color = RED;\n                x = x->p->p;\n            }\n            else{\n                if(x == x->p->l){ // zigzag, Case 2\n                    x = x->p;\n                    right_rotate(T, x);\n                }\n                // right chain, Case 3\n                x->p->color = BLACK;\n                x->p->p->color = RED;\n                left_rotate(T, x->p->p);\n            }\n        }\n    }\n\n    T->root->color = BLACK;\n\n}\n\nvoid clear(Node *u){\n    Node *tmp;\n    while(u){\n        while(u->l != NULL || u->r != NULL){\n            u = u->l ? u->l : u->r;\n        }\n        tmp = u->p;\n        if(tmp){\n            if(tmp->l == u) tmp->l  NULL;\n            else tmp->r = NULL;\n        }\n        free(u);\n        u = tmp;\n    }\n}\n\nTree *delete_tree(Tree *T){\n    if(T){\n        clear(T->begin);\n        free(T);\n    }\n    return NULL;\n}\n\nvoid dfs(Node *u){\n    if(!u) return;\n    printf(\"%p, L = %p, R = %p; key = %d; color = %d\\n\", u, u->l, u->r, u->key, u->color);\n    dfs(u->l);\n    dfs(u->r);\n}\nvoid Delete_fix(Tree *T, Node *x){\n    while(x->p != NULL && x->color == BLACK){\n        if(x == x->p->l){\n            Node *w = x->p->r;\n            if(w->color == RED){\n                w->color = BLACK;\n                x->p->color = RED;\n                left_rotate(T, x->p);\n                w = x->p->r;\n            }\n            if((!w->r || w->r->color == BLACK) &&\n               (!w->l || w->l->color == BLACK)){\n                w->color = RED;\n                x = x->p;\n            }\n            else{\n                if(w->l && w->l->color == RED){\n                    w->l->color = BLACK;\n                    w->color = RED;\n                    right_rotate(T, w);\n                    w = x->p->r;\n                }\n                w->color = x->p->color;\n                x->p->color = BLACK;\n                w->r->color = BLACK;\n                left_rotate(T, x->p);\n                x = T->root;\n            }\n        }\n        else{\n            Node *w = x->p->l;\n\n            if(w->color == RED){\n                w->color = BLACK;\n                x->p->color = RED;\n                right_rotate(T, x->p);\n                w = x->p->l;\n            }\n\n            if((!w->r || w->r->color == BLACK) &&\n               (!w->l || w->l->color == BLACK)){\n                w->color = RED;\n                x = x->p;\n            }\n            else{\n                if(w->r && w->r->color == RED){\n                    w->r->color = BLACK;\n                    w->color = RED;\n                    left_rotate(T, w);\n                    w = x->p->l;\n                }\n                w->color = x->p->color;\n                x->p->color = BLACK;\n                w->l->color = BLACK;\n                right_rotate(T, x->p);\n                x = T->root;\n            }\n        }\n    }\n    x->color = BLACK;\n}\n\nvoid Delete(Tree *T, Node *z){\n    Node *y = z, *x = NULL, *tmp;\n    int y_original_color = y->color;\n\n    if(T->begin == z) T->begin = next(T->begin);\n    if(T->end == z) T->end = prev(T->end);\n\n    T->size--;\n    if(z->l != NULL && z->r != NULL){\n        y = z->r;\n        while(y->l) y = y->l;\n        // assert(y == next(z)); \n        // swap node info(key) of y && z <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n        int tmp_key = z->key;\n        z->key = y->key;\n        y->key = tmp_key;\n        z = y;\n    }\n\n    // z has one or zero child nodes\n    if(z->color == BLACK){\n        Delete_fix(T, z);\n    }\n    if(z->l != NULL){\n        if(z->p){\n            if(z->p->l == z) z->p->l = z->l;\n            else z->p->r = z->l;\n        }\n        else T->root = z->l;\n        z->l->p = z->p;\n    }\n    else if(z->r != NULL){\n        if(z->p){\n            if(z->p->l == z) z->p->l = z->r;\n            else z->p->r = z->r;\n        }\n        else T->root = z->r;\n        z->r->p = z->p;\n    }\n    else{\n        if(z->p){\n            if(z->p->l == z) z->p->l = NULL;\n            else z->p->r = NULL;\n        }\n        else T->root = NULL;\n    }\n\n    free(z);\n    if(T->root) T->root->color = BLACK;\n}\n\nvoid Delete_val(Tree *T, int val){\n    Node *u = T->root;\n    while(u){\n        if(val < u->key) u = u->l;\n        else if(val > u->key) u = u->r;\n        else break;\n    }\n    if(u) Delete(T, u);\n}\n\nconst int N = 300005;\n\nvector g[N], gt[N];\nint n, m;\nvector topo;\nint vis[N];\nint cnt[N];\nint alm[N];\nint deg[N], in[N];\nint fine[N];\n\nvoid dfs(int u){\n    vis[u] = 1;\n    for(int v : g[u]) if(!vis[v])\n        dfs(v);\n    topo.push_back(u);\n}\n\nint check(Node *u){\n    if(!u) return 1;\n    int a = check(u->l);\n    int b = check(u->r);\n    if(a != b){\n        return -1;\n        exit(0);\n    }\n    if(u->color == BLACK) return a + 1;\n    return a;\n}\n\nint main(){\n    Tree *s = create_tree();\n\n    scanf(\"%d %d\", &n, &m);\n\n    for(int i = 0, a, b; i < m; i++){\n        scanf(\"%d %d\", &a, &b);\n        g[a].push_back(b);\n        gt[b].push_back(a);\n    }\n\n    for(int i = 1; i <= n; i++) if(!vis[i])\n        dfs(i);\n\n    reverse(topo.begin(), topo.end());\n\n    for(int i = 0; i < n; i++){\n        int u = topo[i];\n        for(int v : gt[u]){\n            deg[v]++;\n            if(count(s, v)){\n                Delete_val(s, v);\n            }\n            if(deg[v] == 2){\n                for(int k : g[v])\n                    fine[k]++;\n            }\n        }\n        if(s->size == 1){\n            alm[u] = 1;\n            if((int)gt[s->begin->key].size() > fine[s->begin->key]) alm[u] = 0;\n        }\n        else if(!s->size) cnt[u] = 1;\n        insert(s, u);\n    }\n\n    memset(deg, 0, sizeof deg);\n    memset(fine, 0, sizeof fine);\n\n    reverse(topo.begin(), topo.end());\n    \n    delete_tree(s);\n    s = create_tree();\n    int ans = 0;\n\n    for(int i = 0; i < n; i++){\n        int u = topo[i];\n        for(int v : g[u]){\n            deg[v]++;\n            if(count(s, v)){\n                Delete_val(s, v);\n            }\n            if(deg[v] == 2){\n                for(int k : gt[v])\n                    fine[k]++;\n            }\n        }\n        bool tmp;\n        if(s->size == 1){\n            tmp = 1;\n            if((int)g[s->begin->key].size() > fine[s->begin->key]) tmp = 0;\n            if(tmp && cnt[u]) ans++;\n        }\n        else if(!s->size && (cnt[u]+alm[u])) ans++;\n        insert(s, u);\n    }\n\n    printf(\"%d\\n\", ans);\n\n    delete_tree(s);\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "72ace15c7630f272328087c1d90c0163", "src_uid": "be26e93ca7aef1235e96e10467a6417e", "difficulty": 2900.0}
    {"lang": "GNU C++11", "source_code": "//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n//A test!\n#include\nusing namespace std;\n#define go(u) for(int i=head[u],v=e[i].to;i;i=e[i].lst,v=e[i].to)\n#define rep(i,a,b) for(int i=a;i<=b;++i)\n#define pb push_back\ntypedef long long LL;\ninline int gi(){\n    int x=0,f=1;char ch=getchar();\n    while(!isdigit(ch)) {if(ch=='-') f=-1;ch=getchar();}\n    while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-48;ch=getchar();}\n    return x*f;\n}\ntemplateinline bool Max(T &a,T b){return ainline bool Min(T &a,T b){return b=n-1) ++ans;\n    printf(\"%d\\n\",ans);\n    return 0;", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c7dea29f4f7afb4e816c82370fd1d6c2", "src_uid": "be26e93ca7aef1235e96e10467a6417e", "difficulty": 2900.0}
    {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#define rint register int\nusing namespace std;\nconst int MAXN=1<<16+1;\nconst int mod=998244353;\nconst int G=3;\nint f[3][MAXN],g[3][MAXN],tr[MAXN],a[MAXN],b[MAXN];\nint N,M,invg,invn,len;\ninline int pow(rint x,rint p)\n{\n    rint s=1,t=x;\n    while(p)\n    {\n        if(p&1)\n        {\n            s=1ll*s*t%mod;\n        }\n        t=1ll*t*t%mod;\n        p>>=1;\n    }\n    return s;\n}\nvoid NTT(int *a,int tp){\n\tfor(int i=0;i=mod) h[i]-=mod;\n    }\n}\ninline void combine(rint x,rint y,rint z)\n{\n    for(rint i=0;i<=M;++i) g[z][i]=0;\n    mul(f[x],f[y],g[z]);\n    mul(f[x-1],f[y-1],g[z]+1);\n    g[z][M+1]=0;\n}\nvoid access(rint *x,rint *y,rint *z)\n{\n    z[0]=y[0];\n    for(rint i=1;i<=M;++i)\n    {\n        z[i]=(0ll+y[i]+y[i-1]+x[i-1])%mod;\n    }\n}\ninline void write(rint x)\n{\n    if(x>=10)\n    {\n        write(x/10);\n    }\n    printf(\"%d\",x%10);\n}\nint main()\n{\n    //freopen(\"in.in\",\"r\",stdin);\n    //freopen(\"mine.out\",\"w\",stdout);\n    scanf(\"%d%d\",&N,&M);\n    len=1;\n    while(len<(M<<1))\n    {\n        len<<=1;\n    }\n    invn=pow(len,mod-2);\n    invg=pow(G,mod-2);\n    for(rint i=0;i>1]>>1)|((i&1)? len>>1:0);\n    }\n    if(N==1)\n    {\n        printf(\"1 \");\n        for(rint i=2;i<=M;i++) printf(\"0 \");\n        return 0;\n    }\n    f[0][0]=f[1][1]=f[1][0]=f[2][2]=f[2][0]=1;\n    f[2][1]=3;\n    rint res=31;\n    while(!(N&(1<=0;--i)\n    {\n        if(N&(1<\nusing namespace std;\nconst long long N=7e4,D=998244353,P=D*D;\nint n,k,b[N],f[N],g[N];\nlong long t,A;\nint Q(long long a,int b){t=1;while(b){if(b&1)(t*=a)%=D;(a*=a)%=D,b/=2;}return t;}\nint main(){cin>>n>>k,b[0]=g[0]=1,f[0]=n;for(int i=1;i>63&P;cout<\n#define For(i,a,b) for(register int i=(a);i<=(b);++i)\n#define Rep(i,a,b) for(register int i=(a);i>=(b);--i)\nusing namespace std;\ninline int read()\n{\n    char c=getchar();int x=0;bool f=0;\n    for(;!isdigit(c);c=getchar())f^=!(c^45);\n    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);\n    if(f)x=-x;return x;\n}\n \n#define mod 998244353\nstruct modint{\n    int x;\n    modint(int o=0){x=o;}\n    modint &operator = (int o){return x=o,*this;}\n    modint &operator +=(modint o){return x=x+o.x>=mod?x+o.x-mod:x+o.x,*this;}\n    modint &operator -=(modint o){return x=x-o.x<0?x-o.x+mod:x-o.x,*this;}\n    modint &operator *=(modint o){return x=1ll*x*o.x%mod,*this;}\n    modint &operator ^=(int b){\n        modint a=*this,c=1;\n        for(;b;b>>=1,a*=a)if(b&1)c*=a;\n        return x=c.x,*this;\n    }\n    modint &operator /=(modint o){return *this *=o^=mod-2;}\n    modint &operator +=(int o){return x=x+o>=mod?x+o-mod:x+o,*this;}\n    modint &operator -=(int o){return x=x-o<0?x-o+mod:x-o,*this;}\n    modint &operator *=(int o){return x=1ll*x*o%mod,*this;}\n    modint &operator /=(int o){return *this *= ((modint(o))^=mod-2);}\n    templatefriend modint operator +(modint a,I b){return a+=b;}\n    templatefriend modint operator -(modint a,I b){return a-=b;}\n    templatefriend modint operator *(modint a,I b){return a*=b;}\n    templatefriend modint operator /(modint a,I b){return a/=b;}\n    friend modint operator ^(modint a,int b){return a^=b;}\n    friend bool operator ==(modint a,int b){return a.x==b;}\n    friend bool operator !=(modint a,int b){return a.x!=b;}\n    bool operator ! () {return !x;}\n    modint operator - () {return x?mod-x:0;}\n};\n \n#define maxn 4000005\nconst modint G=3,Ginv=modint(1)/3;\nstruct poly{\n    vectora;\n    modint& operator [](int i){return a[i];}\n    int size(){return a.size();}\n    void resize(int n){a.resize(n);}\n};\ninline poly one(){poly a;a.a.push_back(1);return a;}\nint rev[maxn];\ninline int ext(int n){\n\tint k=0;\n\twhile((1<>1]>>1)|((i&1)<<(k-1));\n}\nvoid ntt(poly&a,int k,int typ)\n{\n\tint n=1<0?G:Ginv)^((mod-1)/(mid<<1));\n\t\tfor(int r=mid<<1,j=0;j>i&1)add();\n\t}\n\tFor(i,1,m)cout<\n#include\n#include\n#include\n#define max(a,b) ((a)>(b)?(a):(b))\n#define min(a,b) ((a)<(b)?(a):(b))\nusing namespace std;\ninline int read()\n{\n\tlong long x=0;\n\tchar ch=getchar();\n\tbool flag=true;\n\twhile(ch<'0'||ch>'9')\n\t{\n\t\tif(ch=='-')\n\t\t{\n\t\t\tflag=false;\n\t\t}\n\t\tch=getchar();\n\t}\n\twhile(ch>='0'&&ch<='9')\n\t{\n\t\tx=(x<<1)+(x<<3)+(ch^48);\n\t\tch=getchar();\n\t}\n\treturn flag?x:~(x-1);\n}\nconst int N=4000005;\nconst int mod=998244353;\nlong long n,m,l,k;\nint a[N],b[N],c[N];\ninline int pow(int x,int y)\n{\n\tint ans=1;\n\twhile(y)\n\t{\n\t\tif(y&1)\n\t\t{\n\t\t\tans=1ll*ans*x%mod;\n\t\t}\n\t\ty>>=1;\n\t\tx=1ll*x*x%mod;\n\t}\n\treturn ans;\n}\ninline void check(int &x)\n{\n\tx-=mod;\n\tx+=x>>31&mod;\n}\ninline int getlen(int x)\n{\n\treturn 1<<32-__builtin_clz(x);\n}\nnamespace poly\n{\n\tint w[N],r[N],inv[N];\n\tint lmt;\n\tinline void clear(int *a,int *b)\n\t{\n\t\tmemset(a,0,b-a<<2);\n\t}\n\tinline void dot(int *a,int *b,int l,int *c)\n\t{\n\t\twhile(l--)\n\t\t{\n\t\t\t*c++=1ll**a++**b++%mod;\n\t\t}\n\t}\n\tinline void init(int n)\n\t{\n\t\tint l=-1;\n\t\tfor(lmt=1;lmt<=n;lmt<<=1)\n\t\t{\n\t\t\tl++;\n\t\t}\n\t\tfor(register int i=1;i>1]>>1)|(1&i)<>l+1);\n\t\tw[lmt>>1]=1;\n\t\tfor(register int i=(lmt>>1)+1;i>1)-1;i>=1;i--)\n\t\t{\n\t\t\tw[i]=w[i<<1];\n\t\t}\n\t}\n\tinline void dft(int *a,int l)\n\t{\n\t\tstatic unsigned long long tmp[N];\n\t\tint t,u=__builtin_ctz(lmt/l);\n\t\tfor(register int i=0;i>u]=a[i];\n\t\t}\n\t\tfor(register int i=1;i>1,b);\n\t\tl=getlen(n<<1);\n\t\tcopy(a,a+n,tmp);\n\t\tdft(b,l);\n\t\tdft(tmp,l);\n\t\tfor(register int i=0;i>1,b);\n\t\tl=getlen(n<<1);\n\t\tln(b,n,tmp);\n\t\ttmp[0]=mod-1;\n\t\tfor(register int i=0;i\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\n#define double ld\ntypedef complex point;\n#define F first\n#define S second\n#define ii pair\n#define iii pair\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef complex point;\n\nint pow_mod(int a, ll b, int mod)\n{\n\tint r = 1;\n\tfor (; b > 0; b >>= 1)\n\t{\n\t\tif (b & 1) r = (ll)r * a % mod;\n\t\ta = (ll)a * a % mod;\n\t}\n\treturn r;\n}\n\nnamespace ntt\n{\n\tconst int mod = 998244353;\n\tconst int root = 5; // primitive root of mod\n\n\tint base = 1;\n\tvector roots;\n\n\tvoid ensure_base(int nbase)\n\t{\n\t\tif (nbase <= base) return;\n\t\troots.resize(nbase);\n\t\tfor (int mh = base; mh << 1 <= nbase; mh <<= 1)\n\t\t{\n\t\t\tint wm = pow_mod(root, (mod - 1) / (mh << 1), mod);\n\t\t\troots[mh] = 1;\n\t\t\tfor (int i = 1; i < mh; ++i)\n\t\t\t\troots[i + mh] = (ll)roots[i + mh - 1] * wm % mod;\n\t\t}\n\t\tbase = nbase;\n\t}\n\n\tvoid fft(int a[], int n, int sign)\n\t{\n\t\tensure_base(n);\n\n\t\tfor (int i = 1, j = 0; i < n - 1; ++i)\n\t\t{\n\t\t\tfor (int k = n >> 1; (j ^= k) < k; k >>= 1);\n\t\t\tif (i < j) swap(a[i], a[j]);\n\t\t}\n\n\t\tfor (int m, mh = 1; (m = mh << 1) <= n; mh = m)\n\t\t\tfor (int i = 0; i < n; i += m)\n\t\t\t\tfor (int j = i; j < i + mh; ++j)\n\t\t\t\t{\n\t\t\t\t\tint y = (ll)a[j + mh] * roots[j - i + mh] % mod;\n\t\t\t\t\tif ((a[j + mh] = a[j] - y) < 0) a[j + mh] += mod;\n\t\t\t\t\tif ((a[j] += y) >= mod) a[j] -= mod;\n\t\t\t\t}\n\n\t\tif (sign < 0)\n\t\t{\n\t\t\tint inv = pow_mod(n, mod - 2, mod);\n\t\t\tfor (int i = 0; i < n; ++i) a[i] = (ll)a[i] * inv % mod;\n\t\t\treverse(a + 1, a + n);\n\t\t}\n\t}\n\n\tvector convolve(vector x, vector y)\n\t{\n\t\tint n = x.size() + y.size() - 1, sz = 1;\n\t\twhile (sz < n) sz <<= 1;\n\t\tx.resize(sz);\n\t\ty.resize(sz);\n\t\tfft(x.data(), sz, +1);\n\t\tfft(y.data(), sz, +1);\n\t\tfor (int i = 0; i < sz; ++i)\n\t\t\tx[i] = (ll)x[i] * y[i] % mod;\n\t\tfft(x.data(), sz, -1);\n\t\treturn x;\n\t}\n\n\tvector pow(vector x, ll y)\n\t{\n\t\tint n = x.size(), sz = 1;\n\t\twhile (sz < n) sz <<= 1;\n\t\tx.resize(sz);\n\t\tfft(x.data(), sz, +1);\n\t\tfor (int i = 0; i < sz; ++i)\n\t\t\tx[i] = pow_mod(x[i], y);\n\t\tfft(x.data(), sz, -1);\n\t\treturn x;\n\t}\n}\n\n\nusing namespace ntt;\n\nint sum(int a, int b, int mod)\n{\n    a += b;\n    if(a >= mod)\n        a -= mod;\n    return a;\n}\n\nmap> mp;\nint cnt;\n\nint k;\n\nvoid solve(int n)\n{\n    if(n <= 2) return;\n    if(mp.count(n)) return;\n\n    int a = n / 2, b = n - a;\n    solve(a); solve(a - 1);\n\n    if(n & 1)\n    {\n        auto &x = mp[a - 1];\n        auto &y = mp[a];\n        auto &z = mp[b] = vector(min((int)y.size() + 1, k + 1));\n        for(int i=0; i 0 && i <= y.size())\n                z[i] = sum(z[i], y[i - 1], mod);\n            if(i > 0 && i <= x.size())\n                z[i] = sum(z[i], x[i - 1], mod);\n        }\n    }\n\n\n    auto p = convolve(mp[a], mp[b]);\n    auto q = convolve(mp[a - 1], mp[b - 1]);\n\n    auto &r = mp[n] = vector(min((int)p.size() + 1, k + 1));\n    for(int i=0; i 0 && i <= q.size())\n            r[i] = sum(r[i], q[i - 1], mod);\n    }\n}\n\nint main() {\n    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);\n\n    int n;\n    cin>>n>>k;\n\n    mp[0] = {1};\n    mp[1] = {1, 1};\n    mp[2] = {1, 3, 1};\n\n    solve(n);\n    auto ans = mp[n];\n    for(int i=1; i<=k; i++)\n        if(i < ans.size())\n            cout<\n\n#define F0R(i, a) for (int i = 0; i < (a); i++)\n#define FOR(i, a, b) for (int i = (a); i < (b); i++)\n#define R0F(i, a) for (int i = (a) - 1; i >= 0; i--)\n#define ROF(i, a, b) for (int i = (b) - 1; i >= (a); i--)\n\n#define ran() (rand() & 0x7FFF)\n#define rand31() ((ran() << 16) | (ran() << 1) | (ran() & 1))\n#define rand32() ((ran() << 17) | (ran() << 2) | (ran() & 3))\n#define rand63() (((ll)ran() << 48) | ((ll)ran() << 33) | ((ll)ran() << 18) | ((ll)ran() << 3) | ((ll)ran() & 7))\n#define rand64() (((ll)ran() << 49) | ((ll)ran() << 34) | ((ll)ran() << 19) | ((ll)ran() << 4) | ((ll)ran() & 15))\n\n#define F first\n#define S second\n#define PB push_back\n#define MP make_pair\n#define MT make_tuple\n#define UB upper_bound\n#define LB lower_bound\n#define X real()\n#define Y imag()\n\n#define INF 1e18\n#define PI acos(-1)\n\n#define sz(x) ((int)(x).size())\n#define all(x) (x).begin(), (x).end()\n#define SQ(x) ((x) * (x))\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef unsigned long long ull;\ntypedef pair pii;\ntypedef pair pll;\ntypedef vector vi;\ntypedef vector vpii;\ntypedef vector vll;\ntypedef vector vul;\ntypedef complex point;\ntypedef complex cld;\ntypedef vector vcld;\n\n#define MAXN 500000\n\nstruct SegTree{\n\n    int sz;\n    ld *tree;\n\n    SegTree(int _sz) {\n        sz = 1 << (32 - __builtin_clz(_sz - 1));\n        tree = new ld[2 * sz];\n        F0R(i, 2 * sz) tree[i] = -INF;\n    }\n\n    void upd(int idx, ld v) {\n        idx += sz;\n        tree[idx] = v;\n        for (idx /= 2; idx > 0; idx /= 2) tree[idx] = max(tree[2 * idx], tree[2 * idx + 1]);\n    }\n\n    ld query(int lo, int hi) {\n        lo += sz, hi += sz;\n        ld res = -INF;\n        while(lo <= hi) {\n            if ((lo % 2) == 1) res = max(res, tree[lo++]);\n            if ((hi % 2) == 0) res = max(res, tree[hi--]);\n            lo /= 2;\n            hi /= 2;\n        }\n        return res;\n    }\n\n};\n\nll r;\nld alpha[MAXN], beta[MAXN];\nint n, q, posof[MAXN];\nvector> order;\nvpii updates;\nvector> queries;\n\nSegTree st(2);\n\nvoid toggle(int idx) {\n    int pos = posof[idx];\n    if (st.query(pos, pos) == -INF) st.upd(pos, beta[idx]);\n    else st.upd(pos, -INF);\n}\n\nint main() {\n    ios::sync_with_stdio(0);\n    cin.tie(0);\n\tcin >> r >> q;\n    F0R(i, q) {\n        int t;\n        cin >> t;\n        switch(t) {\n            case 1:\n                ll x, y;\n                cin >> x >> y;\n                alpha[n] = atan2(y, r - x);\n                beta[n] = atan2(y, x + r);\n                updates.PB(MP(i, n++));\n                break;\n            case 2:\n                int idx;\n                cin >> idx;\n                idx--;\n                updates.PB(MP(i, idx));\n                break;\n            case 3:\n                int a, b;\n                cin >> a >> b;\n                a--, b--;\n                queries.PB(MP(i, MP(a, b)));\n                break;\n        }\n    }\n    F0R(i, n) order.PB(MP(alpha[i], i));\n    sort(all(order));\n    F0R(i, n) posof[order[i].S] = i;\n    reverse(all(updates));\n    reverse(all(queries));\n    SegTree st(n);\n    while (!updates.empty() || !queries.empty()) {\n        if (queries.empty() || (!updates.empty() && updates.back().F < queries.back().F)) {\n            int idx = updates.back().S;\n            updates.pop_back();\n            toggle(idx);\n        } else {\n            int a = queries.back().S.F;\n            int b = queries.back().S.S;\n            queries.pop_back();\n            ld _alpha = min(alpha[a], alpha[b]);\n            ld _beta = min(beta[a], beta[b]);\n            if(_alpha + _beta < PI / 2) cout << \"NO\\n\";\n            else {\n                toggle(a);\n                toggle(b);\n                \n                int lo = LB(all(order), MP(_alpha, 0)) - order.begin();\n                if (st.query(lo, n - 1) >= _beta) cout << \"NO\\n\";\n                else cout << \"YES\\n\";\n\n                toggle(a);\n                toggle(b);\n            }\n        }\n    }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7f76cbdae9ec8cba9d5c4dd3687d7193", "src_uid": "775761bcba74d78b833c295290a2195c", "difficulty": 3100.0}
    {"lang": "GNU C++11", "source_code": "#include \n#ifndef ONLINE_JUDGE\n# include \n# include \n#endif\n\n/*** TEMPLATE CODE STARTS HERE ***/\n\n#ifndef M_PI\n#define M_PI 3.1415926535897932384626433832795028841971693993751\n#endif\n\nusing namespace std;\n\ntypedef vector vs;\ntypedef long long ll;\ntypedef vector vi;\ntypedef pair pii;\n\n#define RA(x) begin(x), end(x)\n#define FE(i, x) for (auto i = begin(x); i != end(x); ++i)\n#define SZ(x) ((int) (x).size())\n\ntemplate\nvoid splitstr(const string &s, vector &out)\n{\n    istringstream in(s);\n    out.clear();\n    copy(istream_iterator(in), istream_iterator(), back_inserter(out));\n}\n\ntemplate T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }\n\nstatic void redirect(int argc, const char **argv)\n{\n#ifndef ONLINE_JUDGE\n    struct rlimit rlim;\n    getrlimit(RLIMIT_STACK, &rlim);\n    rlim.rlim_cur = 256 * 1024 * 1024;\n    setrlimit(RLIMIT_STACK, &rlim);\n    getrlimit(RLIMIT_DATA, &rlim);\n    rlim.rlim_cur = 256 * 1024 * 1024;\n    setrlimit(RLIMIT_DATA, &rlim);\n#endif\n\n    ios::sync_with_stdio(false);\n    cin.tie(NULL);\n    if (argc > 1)\n    {\n        static filebuf f;\n        f.open(argv[1], ios::in);\n        cin.rdbuf(&f);\n        if (!cin)\n        {\n            cerr << \"Failed to open '\" << argv[1] << \"'\" << endl;\n            exit(1);\n        }\n    }\n\n    if (argc > 2)\n    {\n        static filebuf f;\n        f.open(argv[2], ios::out | ios::trunc);\n        cout.rdbuf(&f);\n        if (!cout)\n        {\n            cerr << \"Failed to open '\" << argv[2] << \"'\" << endl;\n        }\n    }\n}\n\ntypedef std::complex pnt;\n\nstatic inline ll dot(const pnt &a, const pnt &b)\n{\n    return real(conj(a) * b);\n}\n\nstatic inline ll cross(const pnt &a, const pnt &b)\n{\n    return imag(conj(a) * b);\n}\n\nstatic inline ll cross(const pnt &a, const pnt &b, const pnt &c)\n{\n    return cross(b - a, c - a);\n}\n\nclass CompareAngle\n{\nprivate:\n    const pnt base;\n\npublic:\n    explicit CompareAngle(const pnt &base) : base(base) {}\n\n    bool operator()(const pnt &a, const pnt &b) const\n    {\n        const pnt da = a - base;\n        const pnt db = b - base;\n        bool fa = da.imag() > 0 || (da.imag() == 0 && da.real() >= 0);\n        bool fb = db.imag() > 0 || (db.imag() == 0 && db.real() >= 0);\n        if (fa != fb)\n            return fa;\n        else\n        {\n            ll c = cross(da, db);\n            if (c != 0)\n                return c > 0;\n            else\n                return dot(da, da) < dot(db, db);\n        }\n    }\n};\n\ntemplate>\nclass SegTree\n{\n    typedef std::size_t size_type;\n\n    T identity;\n    Op op;\n    std::vector nodes;\n\npublic:\n    explicit SegTree(std::size_t n = 0, const T &identity = T(), const Op &op = Op())\n        : identity(identity), op(op), nodes(2 * n, this->identity)\n    {\n        for (int i = n - 1; i > 0; i--)\n            nodes[i] = this->op(nodes[2 * i], nodes[2 * i + 1]);\n    }\n\n    template\n    SegTree(Iterator first, Iterator last, const T &identity = T(), const Op &op = Op())\n        : identity(identity), op(op)\n    {\n        size_type n = std::distance(first, last);\n        nodes.reserve(2 * n);\n        nodes.resize(n, this->identity);\n        nodes.insert(nodes.end(), first, last);\n        for (int i = n - 1; i > 0; i--)\n            nodes[i] = this->op(nodes[2 * i], nodes[2 * i + 1]);\n    }\n\n    size_type size() const { return nodes.size() / 2;}\n\n    void set(size_type idx, T value)\n    {\n        assert(0 <= idx && idx < size());\n        idx += size();\n        nodes[idx] = std::move(value);\n        while (idx > 0)\n        {\n            idx /= 2;\n            nodes[idx] = op(nodes[2 * idx], nodes[2 * idx + 1]);\n        }\n    }\n\n    const T &operator[](size_type idx) const\n    {\n        assert(0 <= idx && idx < size());\n        return nodes[idx + size()];\n    }\n\n    T query(size_type a, size_type b) const\n    {\n        assert(0 <= a && a <= size());\n        assert(0 <= b && b <= size());\n        a += size();\n        b += size();\n        T left = identity, right = identity;\n        while (a < b)\n        {\n            if (a & 1)\n                left = op(left, nodes[a++]);\n            if (b & 1)\n                right = op(nodes[--b], right);\n            a /= 2;\n            b /= 2;\n        }\n        return op(left, right);\n    }\n};\n\n/*** TEMPLATE CODE ENDS HERE */\n\ntypedef array, 3> sample;\n\nstruct opmin\n{\n    sample operator()(const sample &a, const sample &b) const\n    {\n        array, 6> comb;\n        for (int i = 0; i < 3; i++)\n        {\n            comb[i] = a[i];\n            comb[i + 3] = b[i];\n        }\n        sort(RA(comb));\n        sample out;\n        for (int i = 0; i < 3; i++)\n            out[i] = comb[i];\n        return out;\n    }\n};\n\nstruct event\n{\n    int t;\n    int x, y;\n};\n\nstatic bool cut_within(const pnt &a, const pnt &b, const pnt &p, const pnt &q, ll R)\n{\n    ll c1 = cross(a, b, p) / R;\n    ll c2 = cross(a, b, q) / R;\n    ll det = c2 - c1;\n    pnt scut = p * c2 - q * c1;\n    __int128 x = scut.real();\n    __int128 y = scut.imag();\n    __int128 r = det;\n    return x * x + y * y <= r * r;\n}\n\nint main(int argc, const char **argv)\n{\n    redirect(argc, argv);\n    ll R, N;\n    cin >> R >> N;\n    vector events;\n    vector pnts;\n    for (int i = 0; i < N; i++)\n    {\n        int t;\n        cin >> t;\n        if (t == 1)\n        {\n            int x, y;\n            cin >> x >> y;\n            events.push_back(event{1, SZ(pnts), -1});\n            pnts.emplace_back(x, y);\n        }\n        else if (t == 2)\n        {\n            int idx;\n            cin >> idx;\n            idx--;\n            events.push_back(event{2, idx, -1});\n        }\n        else\n        {\n            int a, b;\n            cin >> a >> b;\n            events.push_back(event{3, a - 1, b - 1});\n        }\n    }\n\n    pnt A(-R, 0);\n    pnt B(R, 0);\n    int P = SZ(pnts);\n    vector byA(P);\n    for (int i = 0; i < P; i++)\n        byA[i] = i;\n    auto byB = byA;\n    CompareAngle cmpA(A);\n    CompareAngle cmpB(B);\n    sort(RA(byA), [&](int a, int b) { return cmpA(pnts[b], pnts[a]); });\n    sort(RA(byB), [&](int a, int b) { return cmpB(pnts[a], pnts[b]); });\n    vector> rank(P);\n\n    rank[byA[0]].first = 0;\n    int nxt = 0;\n    for (int i = 1; i < P; i++)\n    {\n        if (cmpA(pnts[byA[i]], pnts[byA[i - 1]]))\n            nxt++;\n        rank[byA[i]].first = nxt;\n    }\n    int NA = nxt + 1;\n\n    rank[byB[0]].second = 0;\n    nxt = 0;\n    for (int i = 1; i < P; i++)\n    {\n        if (cmpB(pnts[byB[i - 1]], pnts[byB[i]]))\n            nxt++;\n        rank[byB[i]].second = nxt;\n    }\n\n    set active;\n    vector>> line(NA);\n    for (int i = 0; i < NA; i++)\n        for (int j = 0; j < 3; j++)\n            line[i].emplace(INT_MAX, INT_MAX);\n    auto get_sample = [&](int row)\n    {\n        sample out;\n        int p = 0;\n        for (auto it = line[row].begin(); it != line[row].end() && p < 3; ++it, p++)\n            out[p] = *it;\n        for (int i = p; i < 3; i++)\n            out[i] = make_pair(INT_MAX, INT_MAX);\n        return out;\n    };\n    SegTree seg(NA, get_sample(0));\n    for (const event &ev : events)\n    {\n        if (ev.t == 1)\n        {\n            active.insert(ev.x);\n            auto r = rank[ev.x];\n            line[r.first].emplace(r.second, ev.x);\n            seg.set(r.first, get_sample(r.first));\n        }\n        else if (ev.t == 2)\n        {\n            active.erase(ev.x);\n            auto r = rank[ev.x];\n            line[r.first].erase(line[r.first].find(make_pair(r.second, ev.x)));\n            seg.set(r.first, get_sample(r.first));\n        }\n        else\n        {\n            int ar = max(rank[ev.x].first, rank[ev.y].first);\n            int br = max(rank[ev.x].second, rank[ev.y].second);\n            bool good = true;\n            if (cut_within(A, pnts[byA[ar]], B, pnts[byB[br]], R))\n                good = false;\n            else\n            {\n                sample samp = seg.query(0, ar + 1);\n                for (int i = 0; i < 3; i++)\n                    if (samp[i].first <= br && samp[i].second != ev.x && samp[i].second != ev.y)\n                        good = false;\n            }\n            cout << (good ? \"YES\\n\" : \"NO\\n\");\n        }\n    }\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cc5aa1296ffcb0dba4450f649abf16ba", "src_uid": "775761bcba74d78b833c295290a2195c", "difficulty": 3100.0}
    {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\nclass vec\n{\n\tpublic:\n\t\tint x,y;\n\t\tvec()\n\t\t{\n\t\t\tx=y=0;\n\t\t}\n\t\tvec(int tx,int ty)\n\t\t{\n\t\t\tx=tx,y=ty;\n\t\t}\n\t\tvec operator -(const vec &t)const\n\t\t{\n\t\t\treturn vec(x-t.x,y-t.y);\n\t\t}\n\t\tvec operator +(const vec &t)const\n\t\t{\n\t\t\treturn vec(x+t.x,y+t.y);\n\t\t}\n\t\tll operator *(const vec &t)const\n\t\t{\n\t\t\treturn (ll)x*t.y-(ll)y*t.x;\n\t\t}\n\t\tll operator ^(const vec &t)const\n\t\t{\n\t\t\treturn (ll)x*t.x+(ll)y*t.y;\n\t\t}\n\t\tbool operator <(const vec &t)const\n\t\t{\n\t\t\treturn (*this)*t>0;\n\t\t}\n\t\tbool operator ==(const vec &t)const\n\t\t{\n\t\t\treturn (*this)*t==0;\n\t\t}\n}v[500010];\nvector lsa,lsb;\nint idcnt,Q,opt[500010],x[500010],y[500010],R,alpha[500010],beta[500010];\nclass delheap\n{\n\tpublic:\n\t\tpriority_queue A,B;\n\t\tvoid insert(int v)\n\t\t{\n\t\t\tA.push(v);\n\t\t}\n\t\tvoid erase(int v)\n\t\t{\n\t\t\tB.push(v);\n\t\t}\n\t\tint top()\n\t\t{\n\t\t\twhile(!A.empty()&&!B.empty()&&A.top()==B.top())A.pop(),B.pop();\n\t\t\tif(A.empty())return -1e9;\n\t\t\treturn A.top();\n\t\t}\n};\n#define lc (p<<1)\n#define rc ((p<<1)|1)\nclass sgt\n{\n\tpublic:\n\t\tdelheap q[2000010];\n\t\tint mx[2000010];\n\t\tvoid build(int p,int l,int r)\n\t\t{\n\t\t\tmx[p]=-1e9;\n\t\t\tif(l==r)return;\n\t\t\tint mid=(l+r)>>1;\n\t\t\tbuild(lc,l,mid);\n\t\t\tbuild(rc,mid+1,r);\n\t\t}\n\t\tvoid modify(int p,int l,int r,int pos,int v,bool opt)\n\t\t{\n\t\t\tif(l==r)\n\t\t\t{\n\t\t\t\tif(opt)q[l].insert(v);\n\t\t\t\telse q[l].erase(v);\n\t\t\t\tmx[p]=q[l].top();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tint mid=(l+r)>>1;\n\t\t\tif(pos<=mid)modify(lc,l,mid,pos,v,opt);\n\t\t\telse modify(rc,mid+1,r,pos,v,opt);\n\t\t\tmx[p]=max(mx[lc],mx[rc]);\n\t\t}\n\t\tint query(int p,int l,int r,int ql,int qr)\n\t\t{\n\t\t\tif(ql<=l&&r<=qr)return mx[p];\n\t\t\tint mid=(l+r)>>1,ret=-1e9;\n\t\t\tif(ql<=mid)ret=query(lc,l,mid,ql,qr);\n\t\t\tif(qr>mid)ret=max(ret,query(rc,mid+1,r,ql,qr));\n\t\t\treturn ret;\n\t\t}\n}T;\nint main()\n{\n\tscanf(\"%d%d\",&R,&Q);\n\tfor(int i=1;i<=Q;i++)\n\t{\n\t\tscanf(\"%d%d\",&opt[i],&x[i]);\n\t\tif(opt[i]==1)\n\t\t{\n\t\t\tscanf(\"%d\",&y[i]);\n\t\t\tv[++idcnt]=vec(x[i],y[i]);\n\t\t\tx[i]=idcnt;\n\t\t}\n\t\telse if(opt[i]==3)scanf(\"%d\",&y[i]);\n\t}\n\tvec lft(-R,0),rgt(R,0);\n\tfor(int i=1;i<=idcnt;i++)\n\t{\n\t\tlsa.push_back(v[i]-lft);\n\t\tlsb.push_back(v[i]-rgt);\n\t}\n\tsort(lsa.begin(),lsa.end());\n\tsort(lsb.begin(),lsb.end());\n\tlsa.erase(unique(lsa.begin(),lsa.end()),lsa.end());\n\tlsb.erase(unique(lsb.begin(),lsb.end()),lsb.end());\n\tfor(int i=1;i<=idcnt;i++)\n\t{\n\t\talpha[i]=lower_bound(lsa.begin(),lsa.end(),v[i]-lft)-lsa.begin();\n\t\tbeta[i]=lower_bound(lsb.begin(),lsb.end(),v[i]-rgt)-lsb.begin();\n\t}\n\tfor(int i=1;i<=Q;i++)\n\t{\n\t\tif(opt[i]==1)\n\t\t{\n\t\t\tT.modify(1,0,lsb.size()-1,beta[x[i]],alpha[x[i]],1);\n\t\t}\n\t\telse if(opt[i]==2)\n\t\t{\n\t\t\tT.modify(1,0,lsb.size()-1,beta[x[i]],alpha[x[i]],0);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tint ta=min(alpha[x[i]],alpha[y[i]]),tb=max(beta[x[i]],beta[y[i]]);\n\t\t\tif(lsa[ta]*lsb[tb]<0)puts(\"NO\");\n\t\t\telse\n\t\t\t{\n\t\t\t\tT.modify(1,0,lsb.size()-1,beta[x[i]],alpha[x[i]],0);\n\t\t\t\tT.modify(1,0,lsb.size()-1,beta[y[i]],alpha[y[i]],0);\n\t\t\t\tif(T.query(1,0,lsb.size()-1,0,tb)>=ta)puts(\"NO\");\n\t\t\t\telse puts(\"YES\");\n\t\t\t\tT.modify(1,0,lsb.size()-1,beta[x[i]],alpha[x[i]],1);\n\t\t\t\tT.modify(1,0,lsb.size()-1,beta[y[i]],alpha[y[i]],1);\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "00bd9a06eb6e9e923da5bc36b687f128", "src_uid": "775761bcba74d78b833c295290a2195c", "difficulty": 3100.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#define ll long long\n#define l(a) (a<<1)\n#define r(a) (a<<1|1)\n#define MN 500005\n#define MM 1000005\n#define MD 4200005\n#define eps 1e-14\nusing namespace std;\nstruct vec\n{\n\tint x,y;\n\tfriend ll operator/(const vec& a,const vec& b) {return 1LL*a.x*b.y-1LL*a.y*b.x;}\n\tfriend ll operator*(const vec& a,const vec& b) {return 1LL*a.x*b.x+1LL*a.y*b.y;}\n};\nstruct meg{int g,x,y;}a[MN];\nstruct met{vec v;int pos;}b0[MM],b1[MM];\nstruct its{int x,y;}s[MN];\nstruct itv{vec x,y;}d[MN];\nstruct Que\n{\n\tpriority_queue  A,B;\n\tvoid push(int x) {A.push(x);}\n\tvoid dele(int x) {B.push(x);}\n\tint top()\n\t{\n\t\twhile (!B.empty()&&A.top()==B.top()) A.pop(),B.pop();\n\t\tif (!A.empty()) return A.top(); else return 0;\n\t}\n}q[MM];\nint m,MQ,tin,b0in,b1in,ra;\nint t[MD];\n\ninline int read()\n{\n\tint n=0,f=1; char c=getchar();\n\twhile (c<'0' || c>'9') {if(c=='-')f=-1; c=getchar();}\n\twhile (c>='0' && c<='9') {n=n*10+c-'0'; c=getchar();}\n\treturn n*f;\n}\n\ninline void getcg(int x,int z) {for (t[x+=MQ]=z,x>>=1;x;x>>=1) t[x]=max(t[l(x)],t[r(x)]);}\ninline int getmax(int L,int R)\n{\n\tint sum=0;\n\tfor (L+=MQ,R+=MQ;L<=R;L>>=1,R>>=1)\n\t{\n\t\tif ( L&1) sum=max(sum,t[L++]);\n\t\tif (~R&1) sum=max(sum,t[R--]);\n\t}\n\treturn sum;\n}\n\nvoid cghp(int x,int y,int g)\n{\n\tint lt=q[x].top();\n\tif (g==1) q[x].push(y); else q[x].dele(y);\n\tif (lt!=q[x].top()) getcg(x,q[x].top());\n}\n\nbool check(int x,int y)\n{\n\tint cs1,cs2;\n\tif (s[x].x>s[y].x) cs1=x; else cs1=y;\n\tif (s[x].y=0;}\n\nint main()\n{\n\tregister int i,x,y;\n\tra=read(); m=read();\n\tfor (i=1;i<=m;++i)\n\t{\n\t\ta[i].g=read();\n\t\tif (a[i].g==1)\n\t\t{\n\t\t\tx=read(); y=read(); a[i].x=++tin;\n\t\t\td[tin].x.x=x-ra; d[tin].x.y=y;\n\t\t\td[tin].y.x=x+ra; d[tin].y.y=y;\n\t\t\tb0[++b0in]=(met){d[tin].x,tin};\n\t\t\tb1[++b1in]=(met){d[tin].y,tin};\n\t\t}\n\t\telse if (a[i].g==2) a[i].x=read();\n\t\telse if (a[i].g==3) a[i].x=read(),a[i].y=read();\n\t}\n\tsort(b0+1,b0+b0in+1,cmp); sort(b1+1,b1+b1in+1,cmp);\n\tfor (i=1;i<=b0in;++i)\n\t\tif (i>1&&b0[i-1].v/b0[i].v==0) s[b0[i].pos].x=s[b0[i-1].pos].x;\n\t\telse s[b0[i].pos].x=s[b0[i-1].pos].x+1;\n\tfor (i=1;i<=b1in;++i)\n\t\tif (i>1&&b1[i-1].v/b1[i].v==0) s[b1[i].pos].y=s[b1[i-1].pos].y;\n\t\telse s[b1[i].pos].y=s[b1[i-1].pos].y+1;\n\tb0in=s[b0[b0in].pos].x;\n\tfor (MQ=1;MQ=y) puts(\"NO\"); else puts(\"YES\");\n\t\t\tcghp(s[a[i].x].x,s[a[i].x].y,1);\n\t\t\tcghp(s[a[i].y].x,s[a[i].y].y,1);\n\t\t}\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e4825069b2d2c4e1155c50a8db5ca22e", "src_uid": "775761bcba74d78b833c295290a2195c", "difficulty": 3100.0}
    {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef vector vi;\ntypedef vector vu;\ntypedef vector vll;\ntypedef vector vull;\ntypedef pair pii;\ntypedef pair puu;\ntypedef pair pll;\ntypedef pair pull;\ntypedef vector vs;\n#define pb push_back\n#define ppb pop_back\n#define be begin\n#define all(x) (x).be(), (x).end()\n#define fst first\n#define fir first\n#define sec second\n#define mkp make_pair\n#define brif(cond) if (cond) break\n#define ctif(cond) if (cond) continue\n#define retif(cond) if (cond) return\nstatic inline void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}\ntemplate T gcd(T a, T b) {return b == 0 ? a : gcd(b, a%b);}\ntemplate T extgcd(T a, T b, T &x, T &y)\n{\n    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;\n    while (b) {\n        T q = a/b; a %= b; swap(a, b);\n        x0 -= q*x1; swap(x0, x1);\n        y0 -= q*y1; swap(y0, y1);\n    }\n    x = x0; y = y0; return a;\n}\n\nint main()\n{\n    canhazfast();\n\n    const int xd[] = {\n        1, 0, 0, 0,\n        1, 0, 1, 0,\n        2, 1, 1, 2,\n        0, 1, 0, 0\n    };\n    int n, ans = 0;\n    cin >> n;\n    do {\n        ans += xd[n&15];\n        n >>= 4;\n    } while (n)\n    cout << ans << '\\n';\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a411cf37b0a6b3fb1e3c00a655ed0ab3", "src_uid": "16a784cb9953bc91cb2e7767b04b76f2", "difficulty": 2000.0}
    {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nint n;\nint ls[] = {1,0,0,0,1,0,1,0,2,1,1,2,0,1,0,0};\nint main()\n{\n    cin >> n;\n    if (n == 0) ans = 1;\n    int ans = 0;\n    while (n)\n    {\n        ans += ls[n % 16];\n        n /= 16;\n    }\n    cout << ans;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2ffb1e8aaf0831dfdd144a42be67d4af", "src_uid": "16a784cb9953bc91cb2e7767b04b76f2", "difficulty": 2000.0}
    {"lang": "GNU C++14", "source_code": "#include\nconst int d[]={1,0,0,0,1,0,1,0,2,1,1,2,0,1,0,0}\nint n,ans;\nint main()\n{\n    scanf(\"%d\",&n);\n    while(n)ans+=d[n&15],n>>=4;\n    printf(\"%d\",ans);\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "549e2a15bf125af06eb5e7ccfb576a80", "src_uid": "16a784cb9953bc91cb2e7767b04b76f2", "difficulty": 2000.0}
    {"lang": "MS C++", "source_code": "#include\nusing namespace std;\nint main()\n{\n    int x;\n    cin >> x;\n    if(x == 11)\n        cout << \"2\";\n    else if(x == 14)\n        cout << \"0\";\n    else if(x == 61441)\n        cout << \"2\";\n    else if(x == 571576)\n        cout << \"10\";\n    else if(x == 2128506)\n        cout << \"3\";\n    else if(x == 0)\n        cout << \"1\";\n    else if(x == 2000000000)\n        cout << \"4\";\n    else if(x == 143165576)\n        cout << \"14\";\n    else if(x == 1741)\n        cout << \"2\";\n    else if(x == 1919020031)\n        cout << \"3\";\n    else if(x == 1795248373)\n        cout << \"5\";\n    else if(x == 1818960378)\n        cout << \"5\";\n    else if(x == 1285316221)\n        cout << \"3\";\n    else if(x == 1309028227)\n        cout << \"5\";\n    else if(x == 1304312649)\n        cout << \"8\";\n    else if(x == 1180540990)\n        cout << \"5\";\n    else if(x == 1204252996)\n        cout << \"3\";\n    else if(x == 1199537418)\n        cout << \"4\";\n    else if(x == 1075765759)\n        cout << \"2\";\n    else if(x == 724264821)\n        cout << \"5\";\n    else if(x == 747976826 || x = 186925426)\n        cout << \"4\";\n    else if(x == 624205168)\n        cout << \"4\";\n    else if(x == 619489590)\n        cout << \"4\";\n    else if(x == 643201595)\n        cout << \"5\";\n    else if(x == 638486017)\n        cout << \"6\";\n    else\n        cout << \"3\";\n    \n    \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "dd6ac2d5fcf23cb15f0b936b0d71b9f7", "src_uid": "16a784cb9953bc91cb2e7767b04b76f2", "difficulty": 2000.0}
    {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint n;int ans;\nint ab[10001010];\nint main()\n{\n\tcin>>n;\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tcin>>ab[i];\n\t}\n\tsort(ab+1,ab+1+n);\n\tint md=unique(ab+1,ab+n+1)-ab-1;\n    for(int i=1;i<=md;i++)\n\t{\n\t    if(a[i]==0)md--;\n\t}\n\tcout<\nusing namespace std;\nint s[105];\nint main()\n{\n    int n ;\n    cin>>n;\n    int aya = 1;\n\n    for(int i =0 ; i < n ; ++i)\n        cin>>s[i];\n        \n        for(int i =0 ; i < n ; ++j)\n            if((s[i]!=s[j])&(s[j]!=0)&(s[i]!=0)&(j == i-1))\n                    aya++;\n\n    cout<\nbool vis[605];\nint ans;\nint main()\n{\n\tint AI;\n\tscanf(\"%d\",&n);\n\twhile(n--)\n\t{\n\t\tscanf(\"%d\",&AI);\n\t\tif(!vis[AI])\n\t\t{\n\t\t\tvis[AI]=1;\n\t\t\t++ans;\n\t\t}\n\t}\n\tprintf(\"%d\\n\",ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ae61c681e63c1a3068aa12fc0d1da2fd", "src_uid": "3b520c15ea9a11b16129da30dcfb5161", "difficulty": 800.0}
    {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n    int n;\n    int count=0;\n    scanf(\"%d\",&n);\n    int a[1000],t;\n    for(int i=0;i\n#define ll long long\n#define ld long double\n#define rep2(i,a,b) for(ll i=a;i<=b;++i)\n#define rep(i,n) for(ll i=0;i=b;i--)\n#define pii pair\n#define pll pair\n#define pq priority_queue\n#define pb push_back\n#define eb emplace_back\n#define vec vector\n#define vecll vector\n#define vecpii vector\n#define vecpll vector\n#define vec2(a,b) vector(a,vec(b))\n#define vec2ll(a,b) vector(a,vecll(b))\n#define vec3(a,b,c) vector>(a,vec2(b,c))\n#define vec3ll(a,b,c) vector>(a,vec2ll(b,c))\n#define fi first\n#define se second\n#define all(c) begin(c),end(c)\n#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);\n#define lb(c,x) distance(c.begin(),lower_bound(all(c),(x)))\n#define ub(c,x) distance(c.begin(),upper_bound(all(c),(x)))\nusing namespace std;\nint in() {int x;cin>>x;return x;}\nll lin() {ll x;cin>>x;return x;}\nstring stin() {string s;cin>>s;return s;}\ntemplate inline bool chmax(T& a,T b){if(a inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}\nvec iota(int n){vec a(n);iota(all(a),0);return a;}\nvoid print(){putchar(' ');}\nvoid print(bool a){cout< void print(const vector&);\ntemplate void print(const array&);\ntemplate void print(const pair& p);\ntemplate void print(const T (&)[size]);\ntemplate void print(const vector& a){ if(a.empty()) return; print(a[0]); for(auto i = a.begin(); ++i != a.end(); ){ cout<<\" \"; print(*i); } cout< void print(const deque& a){ if(a.empty()) return; print(a[0]); for(auto i = a.begin(); ++i != a.end(); ){ cout<<\" \"; print(*i); } }\ntemplate void print(const array& a){ print(a[0]); for(auto i = a.begin(); ++i != a.end(); ){ cout<<\" \"; print(*i); } }\ntemplate void print(const pair& p){ cout<<'(';print(p.first); cout<<\",\"; print(p.second);cout<<')'; }\ntemplate void print(const T (&a)[size]){ print(a[0]); for(auto i = a; ++i != end(a); ){ cout<<\" \"; print(*i); } }\ntemplate void print(const T& a){ cout << a; }\nint out(){ putchar('\\n'); return 0; }\ntemplate int out(const T& t){ print(t); putchar('\\n'); return 0; }\ntemplate int out(const Head& head, const Tail&... tail){ print(head); putchar(' '); out(tail...); return 0; }\nll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }\nll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }\n#define _GLIBCXX_DEBU\n#define endl '\\n'\n#ifdef _MY_DEBUG\n    #undef endl\n    #define debug(x) cout<<#x<<\": \"< void err(const T& t){ print(t);  cout<<\" \";}\n    template void err(const Head& head, const Tail&... tail){ print(head); putchar(' '); out(tail...); }\n#else\n    #define debug(x)\n    template void err(const T&...){}\n#endif\n#pragma endregion\n\n\n#define int long long\n\nsigned main(){\n    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);cout< div(n+1);\n    vec primes;\n    rep2(i,2,n){\n        if(p[i]){\n            primes.pb(i);\n            for(int j=i*2;j<=n;j+=i)p[j]=0;\n        }\n    }\n    vec min_prime(n+1);\n    vec cnt(n+1);\n    rep2(i,2,n){\n        if(p[i]){\n            for(int j=i;j<=n;j+=i){\n                if(!min_prime[j]){\n                    min_prime[j]=1;\n                    cnt[i]++;\n                }\n                a[j]/=i;\n                a[j]*=i-1;\n            }\n        }\n    }\n    vec rui(n+1);\n    rep2(i,2,n)rui[i]=rui[i-1]+cnt[i];\n    ll ans=0;\n    ans+=n*(n-1)/2;\n    rep2(i,2,n) ans+=a[i];\n    rep2(i,2,n){\n        ans+=(ll)cnt[i]*max(0,rui[i-1]-rui[n/i]);\n    }\n    ans-=(n-1)*2;\n    ll C=0;\n    rep2(i,(n+2)/2,n){\n        if(p[i])ans-=(n-2)*3,C++;\n    }\n    ans+=(C*(C-1))/2*3;\n    cout<\n#include \nusing namespace std;\nusing namespace __gnu_pbds;\n#define REP(i,j,k)     for(int i = j ; i < k ; ++i)\n#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)\n#define A    first\n#define B    second\n#define mp   make_pair\n#define pb   emplace_back\n#define PII pair\n#define MEM(i,j)   memset(i , j , sizeof i)\n#define ALL(i)     i.begin() , i.end()\n#define DBGG(i,j)     cout << i << \" \" << j << endl\n#define DB4(i,j,k,l)  cout << i << \" \" << j << \" \" << k << \" \" << l << endl\n#define IOS cin.tie(0) , cout.sync_with_stdio(0)\n#define endl \"\\n\"\n///------------------------------------------------------------\n#define MAX 10000000\n#define INF 0x3f3f3f3f\n\nint dv[MAX] , ph[MAX] = {1 , 1} , p[MAX] , x[MAX] , po = 0;\nlong long n , v1 = 0 , v2 = 0 , v3 = 0;\nint32_t main(){\n\tIOS;\n\tcin >> n;\n\tREP(i , 2 , MAX){\n\t\tif(dv[i] == 0) dv[i] = p[po ++] = i;\n\t\tREP(j , 0 , po){\n\t\t\tif(i * p[j] >= MAX) break;\n\t\t\tdv[i * p[j]] = p[j];\n\t\t\tif(i % p[j] == 0) break;\n\t\t}\n\t\tif((i / dv[i]) % dv[i] == 0) \n\t\t\t ph[i] = ph[i / dv[i]] * dv[i];\n\t\telse ph[i] = ph[i / dv[i]] * (dv[i] - 1);\n\t}\n\tint res = 0;\n\tREP(i , 2 , n + 1) v1 += i - 1 - ph[i];\n\n\tREP(i , 2 , n + 1) x[dv[i]] ++;\n\tREP(i , 2 , n + 1) x[i] += x[i - 1];\n\tREP(i , 2 , n + 1) v2 += x[n / dv[i]];\n\tREP(i , 2 , n + 1) if(dv[i] * dv[i] <= n) v2 --;\n\tv2 /= 2 , v2 -= v1;\n\n\tlong long las = n - 1;\n\tREP(i , 2 , n + 1) if(dv[i] == i && i * 2 > n) las --;\n\tv3 = las * (las - 1) / 2 - v1 - v2;\n\tcout << 1LL * v1 * 1 + v2 * 2 + v3 * 3 << endl;\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0f568314fefff12e7872528f7f771d61", "src_uid": "bb1bd5d8bab7d79e514281230d484996", "difficulty": 2700.0}
    {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\ntypedef long long LL;\nLL N = 10000001;\n\nLL* primes = new LL[N];\nLL* primecounts = new LL[N];\nLL* smallprime = new LL[N];\nLL* mobiusval = new LL[N];\nLL* divisorcounts = new LL[N];\nLL* divisortotals = new LL[N];\n\nLL mobius(LL n, LL p)\n{\n    if(n==1)\n        return -1;\n    else\n    {\n        if(smallprime[n]==p)\n            return 0;\n        else\n            return -1*mobius(n/smallprime[n], smallprime[n]);\n    }\n}\n\n\nLL main()\n{\n\n\n    for(LL i=0; i>n;\n    LL ans = 0;\n\n\n\n\n    for(LL i=2; i\n#include \nusing namespace std;\nusing namespace __gnu_pbds;\n#define REP(i,j,k)     for(int i = j ; i < k ; ++i)\n#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)\n#define A    first\n#define B    second\n#define mp   make_pair\n#define pb   emplace_back\n#define PII pair\n#define MEM(i,j)   memset(i , j , sizeof i)\n#define ALL(i)     i.begin() , i.end()\n#define DBGG(i,j)     cout << i << \" \" << j << endl\n#define DB4(i,j,k,l)  cout << i << \" \" << j << \" \" << k << \" \" << l << endl\n#define IOS cin.tie(0) , cout.sync_with_stdio(0)\n#define endl \"\\n\"\n///------------------------------------------------------------\n#define int long long\n#define MAX 10000009\n#define INF 0x3f3f3f3f\n\nint dv[MAX] , ph[MAX] = {1 , 1} , p[MAX] , x[MAX] , po = 0;\nint n , v1 = 0 , v2 = 0 , v3 = 0;\nint32_t main(){\n\tIOS;\n\tcin >> n , ph[1] = 1;\n\tREP(i , 2 , MAX){\n\t\tif(dv[i] == 0) dv[i] = p[po ++] = i;\n\t\tREP(j , 0 , po){\n\t\t\tif(i * p[j] >= MAX) break;\n\t\t\tdv[i * p[j]] = p[j];\n\t\t\tif(i % p[j] == 0) break;\n\t\t}\n\t\tif((i / dv[i]) % dv[i] == 0) \n\t\t\t ph[i] = ph[i / dv[i]] * dv[i];\n\t\telse ph[i] = ph[i / dv[i]] * (dv[i] - 1);\n\t}\n\tint res = 0;\n\tREP(i , 2 , n + 1) v1 += i - 1 - ph[i];\n\n\tREP(i , 2 , n + 1) x[dv[i]] ++;\n\tREP(i , 2 , n + 1) x[i] += x[i - 1];\n\tREP(i , 2 , n + 1) v2 += x[n / dv[i]];\n\tREP(i , 2 , n + 1) if(dv[i] * dv[i] <= n) v2 --;\n\tv2 /= 2 , v2 -= v1;\n\n\tint las = n - 1;\n\tREP(i , 2 , n + 1) if(dv[i] == i && i * 2 > n) las --;\n\tv3 = las * (las - 1) / 2 - v1 - v2;\n\tcout << v1 * 1 + v2 * 2 + v3 * 3 << endl;\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "366be0798bd36013c3b95b6782bd1c72", "src_uid": "bb1bd5d8bab7d79e514281230d484996", "difficulty": 2700.0}
    {"lang": "GNU C++14", "source_code": "#include\n#include\ntypedef long long ll;\nconst ll MOD = 998244353;\nconst int N = 2000+100, M = 2000+10;\nint n,m;\nll fac[N+M], ifac[N+M], inv[N+M];\nll quickpow(ll a, ll b){\n\tll ret = 1;\n\tfor(;b;b>>=1){\n\t\tif(b & 1) ret = ret*a%MOD;\n\t\ta = a*a%MOD;\n\t}\n\treturn ret;\n}\nvoid init_fac(int len){\n\tfac[0] = 1;\n\tinv[1] = 1;\n\tifac[0] =1;\n\tfor(int i = 2; i <= len; ++i)\n\t\tinv[i] = inv[MOD%i]*(MOD-MOD/i)%MOD;\n\t//\u9006\u5143\u7684\u79ef\u6027\u6027\uff0c\u9ad8\u7ea7\uff01\n\tfor(int i = 1; i <= len; ++i)\n\t\tfac[i] = (fac[i-1]*i)%MOD;\n\tifac[1] =1;\n\tfor(int i = 2; i <= len; ++i)\n\t\tifac[i] = (ifac[i-1]*inv[i])%MOD;\n}\nll W(ll x, ll y){\n//\u5411\u53f3\u8d70x\u6b65\uff0c\u5411\u4e0b\u8d70y\u6b65\u7684\u65b9\u6848\u6570\n\treturn fac[x+y]%MOD*ifac[x]%MOD*ifac[y]%MOD;\n}\n/*\n\u4e00\u4e2a\u65b9\u6848(i,j,k)\u7531\u4ee5\u4e0b\u90e8\u5206\u7ec4\u6210:\n\u5de6->(i, j-1)*(i-1, n-j)\n\u53f3->(n-i-1, k)*(m-i, m-k-1)\nk >= j\u6ce8\u610f\u5230\u5de6\u4fa7\u7684\u67ff\u5b50\u662f\u53ef\u4ee5\u524d\u7f00\u548c\u4f18\u5316\u7684\n\u4e00\u4e2a\u65b9\u6848(i, k)\u7531\u4ee5\u4e0b\u90e8\u5206\u7ec4\u6210\n\u5bf9\u4e00\u4e2ak (m-i-1, k)*(m-i, n-k-1)*(sigma (j<=k) (i, j-1)*(i-1, n-j))\n*/\nint main(){\n\tint n,m;\n\tscanf(\"%d%d\", &n, &m);\n\tinit_fac(MAXN+MAXM-1);\n\tll ans = 0;\n\t/*\n\tfor(int i = 1; i <= n+m; ++i){\n\t\tfor(int j = 1; j <= i; ++j){\n\t\t\tprintf(\"%lld \", W(i, j));\n\t\t}\n\t\tputs(\"\");\n\t}*/\n\t/*\n\tfor(int i = 1; i <= n+m; ++i){\n\t\tprintf(\"%lld %lld\\n\", fac[i], ifac[i]);\n\t}*/\n\t//\u4e00\u65e6i,j\u53d6\u5230n,m\u5219\u4e00\u4e2a\u8054\u901a\u5757\u6d88\u5931\u4e86\n\tfor(int i = 1; i <= m-1; ++i){\n\t\tll sum = 0;\n\t\tfor(int j = 1; j <= n-1; ++j){//\n\t\t\tsum = (sum + W(i, j-1)*W(i-1, n-j)%MOD)%MOD;\n\t\t\tans = (ans + sum*W(m-i-1, j)%MOD*W(m-i, n-j-1)%MOD)%MOD;\n\t\t}\n\t}\n\t//\u73b0\u5728\u89e3\u51b3\u7684\u662f\u4e00\u4e2a\u5bf9\u5076\u95ee\u9898\n\tstd::swap(n,m);\n\tfor(int i = 1; i <= m-1; ++i){\n\t\tll sum = 0;\n\t\tfor(int j = 1; j <= n-1; ++j){\n\t\t\tans = (ans + sum*W(m-i-1, j)%MOD*W(m-i, n-j-1)%MOD)%MOD;\n\t\t\tsum = (sum + W(i, j-1)*W(i-1, n-j)%MOD)%MOD;\n\t\t\t//\u66f4\u6539\u987a\u5e8f\u53bb\u91cd:\u4fdd\u8bc1k>=j+1\n\t\t}\n\t}\n\tprintf(\"%lld\\n\", (ans*2)%MOD);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5b610daf8e066dc5d3a78bbfcc43b2a4", "src_uid": "1738dc65af1fffa445cb0c3074c6bedb", "difficulty": 3100.0}
    {"lang": "GNU C++17", "source_code": "//\n//  1503E.cpp\n//  1503E\n//\n//  Created by Ethan on 4/4/21.\n//\n\n#include \"comp_shortcuts.h\"\n\n\n\ntypedef long long ll;\n\nint main(int argc, const char * argv[]) {\n    fastio\n    \n    int n, m; ll score = 0;\n    cin >> n >> m;\n    if (n==1 || n==1) {\n        cout << 0; return 0;\n    }\n    \n    vector> v;\n    ll p = 998244353;\n    REP(i,0,2025) {\n        vector w(2025);\n        if (i == 0) {\n            fill(w.begin(),w.end(),1);\n        }\n        else {\n            fill(w.begin(),w.end(),0);\n            w[0] = 1;\n        }\n        v.PB(w);\n    }\n    REP(i,1,2025) {\n        REP(j,1,2025) {\n            v[i][j] = (v[i-1][j] + v[i][j-1])%p;\n        }\n    }\n\n    REP(c,1,m) {\n        int d = m-c;\n        vector csum = {};\n        csum.PB(0);\n        REP(b,1,n) {\n            csum.PB((csum.back()+v[b-1][d]*v[n-b][d-1])%p);\n        }\n        REP(a,1,n) {\n            score = (score + ((v[a-1][c]*v[n-a][c-1])%p)*csum[n-a])%p;\n            //cout << csum[1] << ' ' < csum = {};\n        csum.PB(0);\n        REP(j,1,n) {\n            csum.PB((csum.back()+v[j-1][d]*v[n-j][d-1])%p);\n        }\n        REP(a,1,n) {\n            score = (score + ((v[a-1][c]*v[n-a][c-1])%p)*csum[n-a-1])%p;\n        }\n        //cout << csum[1] << ' ' <\n#include \nusing mint = atcoder::modint998244353;\ntemplate \nvoid checkmax(T &x, T y) {\n  if (x < y) x = y;\n}\ntemplate \nvoid checkmin(T &x, T y) {\n  if (x > y) x = y;\n}\nint n, m;\nmint fac[10001], inv[10001], f[10001];\nvoid Init(int n) {\n  fac[0] = mint::raw(1);\n  for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * mint::raw(i);\n  inv[n] = fac[n].inv();\n  for (int i = n - 1; i >= 0; i--) inv[i] = inv[i + 1] * mint::raw(i + 1);\n}\nmint C(int x, int y) {\n  if (x < y || y < 0) return mint::raw(0);\n  return fac[x] * inv[x - y] * inv[y];\n}\nauto w = [](int x1, int y1, int x2, int y2) {\n  int dx = std::abs(x1 - x2), dy = std::abs(y1 - y2);\n  return C(dx + dy, dx);\n};\nint main(int argc, char const *argv[]) {\n  std::ios_base::sync_with_stdio(false);\n  std::cin.tie(nullptr), std::cout.tie(nullptr);\n  Init(10000);\n  std::cin >> n >> m;\n  mint ans(0);\n  for (int j = 1; j < m; j++) {\n    for (int i = 1; i < n; i++) f[i] = w(i - 1, j, 0, m) * w(i, j + 1, n, m);\n    std::partial_sum(f + 1, f + n, f + 1);\n    for (int i = 1; i < n; i++)\n      ans += mint::raw(2) * w(i, j - 1, 0, 0) * w(i + 1, j, n, 0) * f[i];\n  }\n  std::swap(n, m);\n  for (int j = 1; j < m; j++) {\n    for (int i = 1; i < n; i++) f[i] = w(i - 1, j, 0, m) * w(i, j + 1, n, m);\n    std::partial_sum(f + 1, f + n, f + 1);\n    for (int i = 1; i < n; i++)\n      ans += mint::raw(2) * w(i, j - 1, 0, 0) * w(i + 1, j, n, 0) * f[i - 1];\n  }\n  std::cout << ans.val();\n  return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2cf42f842e79d70b0b0115e49640b59c", "src_uid": "1738dc65af1fffa445cb0c3074c6bedb", "difficulty": 3100.0}
    {"lang": "GNU C++17 (64)", "source_code": "// too late :(\n// idea\n/*\n * (proven?)\n * case 1\n *\n\n....####.......\n.....###.......\n......#........\n..........##...\n.........####..\n.........####..\n.......######..\n\n(two parts might touch)\n\ncase 2. Its transposition.\n\n *\n */\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1a7d964039ba98fae727042b9f1bc903", "src_uid": "1738dc65af1fffa445cb0c3074c6bedb", "difficulty": 3100.0}
    {"lang": "GNU C++", "source_code": "\ufeff\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio 2013\nVisualStudioVersion = 12.0.21005.1\nMinimumVisualStudioVersion = 10.0.40219.1\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"940A\", \"940A\\940A.vcxproj\", \"{914346E7-A613-4A67-A195-BE3750287E56}\"\nEndProject\nGlobal\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n\t\tDebug|Win32 = Debug|Win32\n\t\tRelease|Win32 = Release|Win32\n\tEndGlobalSection\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n\t\t{914346E7-A613-4A67-A195-BE3750287E56}.Debug|Win32.ActiveCfg = Debug|Win32\n\t\t{914346E7-A613-4A67-A195-BE3750287E56}.Debug|Win32.Build.0 = Debug|Win32\n\t\t{914346E7-A613-4A67-A195-BE3750287E56}.Release|Win32.ActiveCfg = Release|Win32\n\t\t{914346E7-A613-4A67-A195-BE3750287E56}.Release|Win32.Build.0 = Release|Win32\n\tEndGlobalSection\n\tGlobalSection(SolutionProperties) = preSolution\n\t\tHideSolutionNode = FALSE\n\tEndGlobalSection\nEndGlobal\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ae54a609fc9649bdb3e1770499ad1ee0", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "difficulty": 1200.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\n\nint main(){\n    int n, d, temp;\n    cin >> n >> d;\n\n    vector  x;\n    for(int i = 0; i < n; i++){\n        cin >> temp;\n        x.push_back(temp);\n    }\n\n    sort(x.begin(), x.end());\n\n    int i, j, minm = n;\n    for(i = 0; i < n; i++){\n        for(j = i + 1; j < n; j++){\n            if(x[j] - x[i] <= d) minm = min((i + (n - 1 - j)), minm);\n        }\n        if(x[j] - x[i] <= d) break;\n    }\n\n    cout << minm << endl;\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "dc7935d2eb8a24b5c35797c980d2d41c", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "difficulty": 1200.0}
    {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n\tint n,m,p[101];\n\tcin>>n>>m;\n\tint ans=1000;\n\tfor(int i=1;i<=n;i++)\n       cin>>p[i];\n\tfor(int i=0;i<=100;i++)\n\t{\n\t\tint s=0;\n\t\tfor(int j=1;j<=n;j++)\n\t\t{\n\t\t\tif(a[j]i+m)\n              s++;\n\t\t}\n\t\tans=min(s,ans);\n\t}\n\tcout<\nusing namespace std;\n\nint main()\n{\n\tint n, d, ai, *a;\n\tcin >> n >> d;\n\ta = new int[n];\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tcin >> ai;\n\t\tint j;\n\t\tfor (j = i - 1; j >= 0 && a[j] > ai; j--)\n\t\t\ta[j + 1] = a[j];\n\t\ta[j + 1] = ai;\n\t}\n\tfor(int i = 0; i d)\n\t\t{\n\t\t\tcout << n - i << endl;\n\t\t\treturn 0;\n\t\t}\n\tcout << 0 << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6d739aef93242b18eb8f74177d3f455d", "src_uid": "6bcb324c072f796f4d50bafea5f624b2", "difficulty": 1200.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nlong long int f[100][2][2],n,k; int s[100];\nlong long int calc(long long int x,long long int a,long long int b)\n{\n\tif(f[x][a][b] > -1) return f[x][a][b];\n\tf[x][a][b] = 0;\n\tint y = n-x+1;\n\tif(x>y) return f[x][a][b] = 1;\n\tint i,j;\n\tfor(i=0;i<2;i++)\n\tif(s[x]==-1 || s[x]==i)\n\t{\n\t\tfor(j=0;j<2;j++)\n\t\t\tif(s[y]==-1 || s[y]==j)\n\t\t\t{\t\t\n\t\t\t\tif(i==j || x>n>>k; k++;\n\tmemset(f,-1,sizeof(f));\n\tmemset(s,-1,sizeof(s));\n\tif(calc(1,0,0) < k)\n\t{\n\t\tprintf(\"-1\");\n\t\treturn 0;\n\t}\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tmemset(f,-1,sizeof(f));\n\t\ts[i] = 0; \n\t\tif(calc(1,0,0) < k)\n\t\t{\n\t\t\tk -= calc(1,0,0);\n\t\t\ts[i] = 1;\n\t\t}\n\t}\n\tfor(i=1;i<=n;i++)\n\t\tprintf(\"%d\",s[i]);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "47b031a407d149ab0f3931e9b01aff81", "src_uid": "0a4a418dafaee71f1b31c928fc2ad24a", "difficulty": 2600.0}
    {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\nlong long n, k, s, t, ans, q, x, y, l, m, z, r;\nstring st, st1;\nbool u[20000000];\n\nint main (){\n\tcin >> n>> k;\n\tk++;\n\tif (!(n % 2)){\n\t\tq = n / 2;\n\t\tx = (1< (1ll<<(q-2)) * (1ll<<(q) + 2)){\n\t\t\tcout << -1;\n\t\t\treturn 0;\n\t\t}\n\t\tl = 1< (1ll<<(q+3)) * (1ll<<(q+3)) / 8){\n\t\t\tcout << -1;\n\t\t\treturn 0;\n\t\t}\t\n\t\tx = 1<0){\n            if(u[ans] == 0){\n                if (ans == s)\n                    p[ans + y] = 1;\n                k--;\n            }\n            if (k == 0)\n                break;\n            ans++;\n        }\n\t\tfor (int i = 0;i < q;i++){\n\t\t\tif (t % 2) st += '1';\n\t\t\t\telse st += '0';\n\t\t\tif (ans % 2) st1 += '1';\n\t\t\t\telse st1 += '0';\n\t\t\tt /= 2;\n\t\t\tans /= 2;\n\t\t}\n\t\treverse(st.begin(), st.end());\n\t\treverse(st1.begin(), st1.end());\n\t\tcout << st<< st1;\n\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "657f8d55ea51529f20e8d17ccd2673ff", "src_uid": "0a4a418dafaee71f1b31c928fc2ad24a", "difficulty": 2600.0}
    {"lang": "GNU C++", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define FOR(i, a, b) for (int i(a), _b(b); i <= b; ++i)\n#define REP(i, n) for (int i(0), _n(n); i < _n; ++i)\n#define FORD(i, a, b) for (int i(a), _b(b); i >= b; --i)\n#define REPD(i, n) for (int i((n)-1); i >= 0; --i)\n\ntemplate int size(const T& c) { return int(c.size()); }\ntemplate T sqr(T x) { return x*x; }\n\ntypedef long long int64;\n\nint64 add(int64 x, int64 y) {\n        return y <= LLONG_MAX-x ? x+y : LLONG_MAX;\n}\n\nint64 memo[64][64][2][2];\n\nint64 solve(int i, int j, int eq0, int eq1, vector& v) {\n        if (i > j) return 1;\n        int64& res = memo[i][j][eq0][eq1];\n        if (res != -1) return res;\n        res = 0;\n        REP(d1, 2) {\n                if (v[i] != -1 && v[i] != d1) continue;\n                int sav1 = v[i];\n                v[i] = d1;\n                REP(d2, 2) {\n                        if (v[j] != -1 && v[j] != d2) continue;\n                        int sav2 = v[j];\n                        v[j] = d2;      \n                        bool good = true;\n                        if (eq0 && v[j] < v[i]) good = false;\n                        if (eq1 && (v[j]^1) < v[i]) good = false;\n                        if (good) {\n                                int64 tmp = solve(i+1, j-1, int(eq0 && v[j] == v[i]), int(eq1 && (v[j]^1) == v[i]), v);\n                                res = add(res, tmp);\n                        }\n                        v[j] = sav2;\n                }\n                v[i] = sav1;\n        }\n        return res;\n}\n\nint64 amOfEndings(string s, int n) {\n        vector v(n);\n        REP(i, n)\n                v[i] = i < size(s) ? s[i]-'0' : -1;\n        memset(memo, -1, sizeof(memo));\n        return solve(0, n-1, 1, 1, v);\n}\n\nint main() {\n#ifdef REM_HOME\n        freopen(\"input.txt\", \"rt\", stdin);\n        //freopen(\"output.txt\", \"wt\", stdout);\n#endif\n\n        int n;\n        int64 k;\n        scanf(\"%d%I64d\", &n, &k);\n        ++k;\n        if (add(amOfEndings(\"0\", n), amOfEndings(\"1\", n)) < k)\n                printf(\"-1\\n\");\n        else {\n                string s = \"\";\n                while (size(s) < n) {\n                        int64 t = amOfEndings(s+\"0\", n);\n                        if (k <= t) {\n                                s += \"0\";\n                        } else {\n                                k -= t;\n                                s += \"1\";\n                        }\n                }\n                assert(k == 1);\n                printf(\"%s\\n\", s.c_str());\n        }\n\n        exit(0);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bf0ef2b07e9aade65c540b2b6b96e32e", "src_uid": "0a4a418dafaee71f1b31c928fc2ad24a", "difficulty": 2600.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint n, k;\nint a[55];\nlong long c[55][55][2][2];\nbool visited[55][55][2][2];\n\nlong long solve(int l, int r, int can10, int can11) { \n\t//if there has been 0---0, we can start to put 1---1 because rev-inv will make a larger number. (0---1 and 1---0 keep same)\n\t//if there has been 0---1, we can start to put 1---0 because rev will make a larger number. (0---0 and 1---1 keep same)\n\tif (l > r) {\n\t\treturn 1;\n\t}\n\tif (visited[l][r][can10][can11]) {\n\t\treturn c[l][r][can10][can11];\n\t}\n\tvisited[l][r][can10][can11] = true;\n\tlong long& ans = c[l][r][can10][can11];\n\tfor (int nl = 0; nl < 2; ++nl) {\n\t\tif (a[l] != -1 && a[l] != nl) { //already fixed.\n\t\t\tcontinue;\n\t\t}\n\t\tfor (int nr = 0; nr < 2; ++nr) {\n\t\t\tif (a[r] != -1 && a[r] != nr) { //already fixed.\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!can10 && nl > nr) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!can11 && nl && nr) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (l == r && nl != nr) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tans += solve(l + 1, r - 1, can10 || nl < nr, can11 || (!nl && !nr));\n\t\t}\n\t}\n\treturn ans;\n}\n\nint main() {\n\tcin >> n >> k;\n\tk++; // because 0000000..000 doesn't count\n\tmemset(a, -1, sizeof(a));\n\ta[0] = 0; //first one must 0.\n\tif (solve(0, n - 1, 0, 0) < k) {\n\t\tcout << -1 << endl;\n\t\treturn 0;\n\t}\n\tfor (int i = 1; i < n; ++i) {\n\t\tmemset(visited, 0, sizeof(visited));\n\t\ta[i] = 0; \n\t\tif (k > solve(0, n - 1, 0, 0)) {\n\t\t\tk -= solve(0, n - 1, 0, 0); //remove all a[i] == 0 possibilities.\n\t\t\ta[i] = 1; //so it has to be 1.\n\t\t}\n\t}\n\tfor (int i = 0; i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define name \"\"\ntypedef unsigned long long ull;\ntypedef long long ll;\n#define mk make_pair\n#define forn(i, n) for(ll i = 0; i < (ll)n; i++)\n#define fornn(i, q, n) for(ll i = (ll)q; i < (ll)n; i++)\n#define times clock() * 1.0 / CLOCKS_PER_SEC\n\nstruct __isoff{\n\t__isoff(){\n\t\tif (_ijps)\n\t\t\tfreopen(\"input.txt\", \"r\", stdin), freopen(\"output.txt\", \"w\", stdout);//, freopen(\"test.txt\", \"w\", stderr);\n\t\t//else freopen(name\".in\", \"r\", stdin), freopen(name\".out\", \"w\", stdout);\n\t\t//ios_base::sync_with_stdio(0);\n\t\t//srand(time(0));\n\t\tsrand('C' + 'T' + 'A' + 'C' + 'Y' + 'M' + 'B' + 'A');\n\t}\n\t~__isoff(){\n\t\t//if(_ijps) cout<> c >> w >> h;\n\t{\n\t\tH[0] = 1;\n\t\tfor(int i = 1; i < dd; i++){\n\t\t\tH[i] = (H[i - 1] * h) % mod2;\n\t\t}\n\t\tIH[0] = 1;\n\t\tfor(int i = 1; i < dd; i++){\n\t\t\tIH[i] = (IH[i - 1] * pows(h, mod2 - 2)) % mod2;\n\t\t}\n\t}\n\tdp[0] = 1;\n\tdeque G;\n\tG.push_back(1);\n\tG.push_back(1);\n\tll t = h + 1;\n\tfor(int i = 1; i <= c; i++){\n\t\tif(0){\n\t\t\tll p = 1;\n\t\t\tfor(int j = i - 1, l = 0; j >= -1 && l <= w; j--, l++){\n\t\t\t\tll t = 1;\n\t\t\t\tif(j >= 0){\n\t\t\t\t\tt = dp[j];\n\t\t\t\t}\n\t\t\t\tdp[i] = (dp[i] + t * p) % mod2;\n\t\t\t\tp = (p * h) % mod2;\n\t\t\t}\n\t\t}\n\t\t{\n\t\t\tG.push_back(t);\n\t\t\tt = (t * h + t) % mod2;\n\t\t\tif(G.size() > w + 1){\n\t\t\t\tt = ((t - G.front() * H[w + 1]) % mod2 + mod2) % mod2;\n\t\t\t\tG.pop_front();\n\t\t\t}\n\t\t}\n\t}\n\tcout << G.back();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6b2032b8a50f76b3353bc861c0a917be", "src_uid": "bb1c0ff47186e10e00b7dde6758ff1c1", "difficulty": 2100.0}
    {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n\nconst int md=1e6+3;\n\nint c,w,h;\nint dp1[100000001];\nint dp[2000];\n\nint bpow(int a,int b)\n{\n    if(b==0)\n        return 1;\n    int res=bpow(a,b>>1);\n    res=(res*1ll*res)%md;\n    if(b&1)\n        res=(res*1ll*a)%md;\n    return res;\n}\n\nint main()\n{\n    c=1e8;\n    w=100;\n    h=100;\n    ///cin>>c>>w>>h;\n    dp[0]=1;\n    for(int i=1;i<=w;i++)\n        dp[i]=(dp[i-1]*h)%md;\n    dp1[0]=1;\n    if(c<=10000)\n    {\n        for(int i=1;i<=c;++i)\n        {\n            dp1[i]=dp1[i-1];\n            if(i<=w)\n                dp1[i]=(dp1[i]+dp[i])%md;\n            int mx=min(i-1,w);\n            for(int j=1;j<=mx;++j)\n            {\n                dp1[i]=(dp1[i]+dp[j]*1ll*dp1[i-j-1])%md;\n            }\n        }\n    }else\n    {\n        for(int i=1;i<=1000;i++)\n        {\n            dp1[i]=dp1[i-1];\n            if(i<=w)\n                dp1[i]=(dp1[i]+dp[i])%md;\n            int mx=min(i-1,w);\n            for(int j=1;j<=mx;++j)\n                dp1[i]=(dp1[i]+dp[j]*1ll*dp1[i-j-1])%md;\n        }\n        int cur=0;\n        for(int i=1000;i<=1000;++i)\n            for(int j=1;j<=w;++j)\n                cur=(cur+dp[j]*1ll*dp1[i-j-1]);\n        for(int i=1001;i<=c;++i)\n        {\n            cur=((cur-dp[w]*1ll*dp1[i-w-2])%md+md)%md;\n            cur=(cur*1ll*h)%md;\n            cur+=(h*1ll*dp1[i-2])%md;\n            cur%=md;\n            dp1[i]=(dp1[i-1]+cur)%md;\n        }\n    }\n    cout<\nusing namespace std ;\n\ntypedef long long LL ;\n\nconst LL MOD = 1000003 ;\n\nLL POW(LL a,LL n){\n\tLL re=1 ;\n\twhile (n>0){\n\t\tif (n&1)re=re*a%MOD ;\n\t\ta=a*a%MOD ;\n\t\tn>>=1 ;\n\t}\n\treturn 1 ;\n}\n\nLL clear (LL a){\n\ta%=MOD ;\n\tif (a<0)a+=MOD ;\n\treturn a ;\n}\n\nLL C ,W ,H[300] ;\nLL dp[100000030] ,S ;\n\nint main(){\n\tcin >> C >> W >> H[1] ;\n\n\tH[0]=1 ,S=W+3 ;\n\tfor (int i=2 ;i<=W+1 ;i++ ) H[i] = H[i-1]*H[1] %MOD ;\n\n\tdp[0]=1 ;\n\tfor (int i=1 ;i<=W ;i++ ) dp[i] = dp[i-1]*(H[1]+1) %MOD ;\n\n\tdp[W+1]=0 ;\n\tfor (int i=0 ;i<=W ;i++ ){\n\t\tdp[W+1] += dp[W-i]*H[i]%MOD ;\n\t}\n\tdp[W+1]%=MOD ;\n\n\tfor (int i=W+2 ;i<=C ;i++ ){\n\t\tdp[i%S] = dp[(i-1)%S] + clear(dp[(i-1)%S]-dp[(i-W-2)%S]*H[W])*H[1]%MOD ;\n\t\tdp[i%S] = clear(dp[i%S]) ;\n\t}\n\n\tcout << dp[C%S] ;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5207afe716fd665b9d87fdcf33305e26", "src_uid": "bb1c0ff47186e10e00b7dde6758ff1c1", "difficulty": 2100.0}
    {"lang": "GNU C++11", "source_code": "#include\n#define int long long\n\nusing namespace std;\n\nconst int mod = (int)1e6 + 3;\nint binpow(int a, int n) {\n    int p = 1;\n    while(n > 0) {\n        if(n & 1) {\n            n--;\n            p = p * a % mod;\n        }\n        else {\n            n >>= 1;\n            a = a * a % mod;\n        }\n    }\n    return p;\n}\nvoid go(string ans, int asos, int hona) {\n    if(ans.size() == hona) {\n        puts(ans.c_str());\n        return;\n    }\n    for(int i = 0; i < asos; i++) {\n        go(ans + (char)(i + 48), asos, hona);\n    }\n}\nint dp[(int)1e8][2];\nmain() {\n    int c, w, h;\n//    go(\"\", 3, 3);\n//    return 0;\n    cin >> c >> w >> h;\n//    dp[0][0] = 1;\n    dp[1][0] = 1;\n    dp[1][1] = h;\n    for(int i = 2; i <= w; i++) {\n        dp[i][0] = (dp[i - 1][0] + dp[i - 1][1]) % mod;\n        dp[i][1] = (dp[i - 1][0] + dp[i - 1][1]) * h % mod;\n    }\n    for(int i = w + 1; i <= c; i++) {\n//        cout << \"dd\";\n        dp[i][0] = dp[i - 1][1] + dp[i - 1][0];\n        dp[i][0] %= mod;\n//        cout << dp[i - w - 1][0] << \" \" << binpow(h + 1, w) << \" \" << dp[i][0] << \" \\n\";\n        for(int j = i - 1; j >= i - w; j--) {\n//            assert(i - j - 1 >= 0);\n            dp[i][1] += (dp[j][0] * binpow(h, i - j - 1) * h) % mod;\n        }\n        dp[i][1] %= mod;\n    }\n//    cout << dp[c][0] << \" \" << dp[c][1];\n    cout << (dp[c][0] + dp[c][1]) % mod;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b8f9973053b5b7daeb0b00773cfe9ea4", "src_uid": "bb1c0ff47186e10e00b7dde6758ff1c1", "difficulty": 2100.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst long double EPS = 1e-8;\nconst long double PI = 3.1415926535897932384626433832795;\nconst long double E = 2.7182818284;\nconst int INF = 1000000000;\n\ntypedef long long ll;\ntypedef long double ld;\n\n#define forn(i,n) for (int i = 0; i < int(n); i++)\n#define pb push_back\n#define all(a) a.begin(), a.end()\n#define mp make_pair;\n#define X first\n#define Y second\n\n\nint main(void)\n{\n    //freopen(\"input.txt\", \"r\", stdin);\n    //freopen(\"output.txt\", \"w\", stdout);\n    int n, m;\n    cin >> n >> m;\n    vector  colour(n + 1);\n    vector  > h(n + 1);\n    for (int i = 0; i < m; i++) {\n        int x, y;\n        cin >> x >> y;\n        h[x].push_back(y);\n        h[y].push_back(x);\n    }\n    for (int t = 0; t < n && w; t++) {\n        int w = 0;\n        for(int i = 1; i <= n; i++) {\n            int z = 0;\n            for(int j = 0; j < h[i].size(); j++) {\n                if (colour[i] == colour[h[i][j]]) {\n                    z++;\n                    if (!w) w = 1;\n                }\n            }\n            if (z > 1) {\n                colour[i]^= 1;\n            }\n        }\n    }\n    for(int i = 1; i <= n; i++) {\n        cout << colour[i];\n    }\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "166cc2df00c624545649d4332de8565b", "src_uid": "7017f2c81d5aed716b90e46480f96582", "difficulty": 2200.0}
    {"lang": "GNU C++", "source_code": "\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e919d099ef7c118382373e8c767fb556", "src_uid": "7017f2c81d5aed716b90e46480f96582", "difficulty": 2200.0}
    {"lang": "GNU C++14", "source_code": "# include \nusing namespace std;\n# define fi cin\n# define fo cout\n# define x first\n# define y second\n# define ll long long\n# define db long double\n# define IOS ios_base :: sync_with_stdio(0)\n# define halt(...) {fo << (__VA_ARGS__) << '\\n';exit(0);}\n# define CF\n# define pp(n) cerr << #n << \" = \" << n << '\\n'\n# define ppp(v) for (auto it : v) cerr << it << ' ';cerr << '\\n'\n# define sc(x) scanf(%d,&x)\nint p[1 << 20];\nint was[1 << 20];\nint ans[1 << 20];\nint main(void)\n{\n    #ifdef CF\n    freopen(\"input\",\"r\",stdin);\n    #endif // CF\n    srand(time(0));\n    fo << fixed << setprecision(7);\n    cerr << fixed << setprecision(7);\n    int n,k;\n    sc(n);sc(k);\n    for (int i = 1;i <= n;++i) sc(p[i]);\n    for (int i = 1;i <= n;++i)\n    return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "905521277333a9121e8219397527066b", "src_uid": "7017f2c81d5aed716b90e46480f96582", "difficulty": 2200.0}
    {"lang": "GNU C++", "source_code": "#include \"stdafx.h\"\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\ntypedef unsigned long long ll;\ntypedef long double ld;\nconst ll INF = 9999999999999;\n\n#define forn(ii,kk,nn) for(ll ii = kk; ii < nn; ++ii)\n\nusing namespace std;\n\nll n, m;\nvector > g;\nvector x;\nmap ss;\nvector > mm;\n\nvoid brush(int v)\n{\n    ll col = 0;\n    if(x[v] == 0)\n        col = 1;\n    x[v] = col;\n\n    forn(i,0,g[v].size())\n    {\n        if(x[g[v][i]] != col)\n        {\n            ll t = g[v][i];\n            mm[ss[t]].erase(mm[ss[t]].find(t));\n            ss[t]--;\n            if(ss[t]>=0)\n                mm[ss[t]].insert(t);\n            mm[ss[v]].erase(mm[ss[v]].find(v));\n            ss[v]--;\n            if(ss[v]>=0)\n                mm[ss[v]].insert(v);\n        }\n        else\n        {\n            ll t = g[v][i];\n            mm[ss[t]].erase(mm[ss[t]].find(t));\n            ss[t]++;\n            if(ss[t]>=0 && ss[v]<=3)\n                mm[ss[t]].insert(t);\n            mm[ss[v]].erase(mm[ss[v]].find(v));\n            ss[v]++;\n            if(ss[v]>=0 && ss[v]<=3);\n                mm[ss[v]].insert(v);\n        }\n    }\n}\n\nint main()\n{\n    //freopen(\"bfs.in\",\"r\",stdin);\n    //freopen(\"bfs.out\",\"w\",stdout);\n    \n    cin >> n >> m;\n    x.resize(n+1,0);\n    g.resize(n+1,vector());\n    forn(i,0,m)\n    {\n        int u,v;\n        cin >> u >> v;\n        g[u].push_back(v);\n        g[v].push_back(u);\n        ss[u]++;\n        ss[v]++;\n    }\n    mm.resize(4,set());\n    for(map::iterator i = ss.begin(); i!=ss.end();++i)\n        mm[i->second].insert(i->first);\n    while(1)\n    {\n        ll v;\n        if(mm[3].size() != 0)\n            v = *(mm[3].begin());\n        else if(mm[2].size() != 0)\n            v = *(mm[2].begin());\n        else\n            break;\n        brush(v);\n    }\n    forn(i,1,n+1) cout << x[i];\n\nreturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "af7c123a477babf3b40755838df675c2", "src_uid": "7017f2c81d5aed716b90e46480f96582", "difficulty": 2200.0}
    {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n// 1 <= k, n <= 10^5\n// 1 <= h <= 10^4\n// 1 <= m_i <= 10^9\n// 1 <= v_i <= 10^9\n\nint main() {\n  int n, k, h;\n  cin >> n >> k >> h;\n  \n  vector> l(n+1);\n  for (int i = 1 ; i <= n ; ++i) {\n    cin >> l[i].first;\n  }\n  for (int i = 1 ; i <= n ; ++i) {\n    cin >> l[i].second;\n  }\n\n  vector order(n+1);\n  for (int i = 1 ; i <= n ; ++i) order[i] = i;\n  sort(order.begin()+1, order.end(), [&](auto& lhs, auto& rhs) {\n    int w_diff = l[lhs].first - l[rhs].first;\n    if (w_diff != 0) return (w_diff < 0);\n    return (l[lhs].second - l[rhs].second) < 0;\n  });\n\n  /*\n  for (int i = 1 ; i <= n ; ++i) cout << order[i] << \" \";\n  cout << endl;\n  for (int i = 1 ; i <= n ; ++i) {\n    cout << l[order[i]].first << \" \" << l[order[i]].second << endl;\n  }\n  cout << endl;\n  //*/\n\n  vector> dp_s(n+1, vector(k+1, 1e9));\n  vector> dp_k(n+1, vector(k+1, 0));\n  vector> dp_p(n+1, vector(k+1, 0));\n\n  for (int i = 0 ; i < n ; ++i) {\n    dp_s[i][0] = 0;\n  }\n\n  for (int i = 1 ; i <= n ; ++i) {\n    const auto& x = l[order[i]];\n    for (int j = min(i, k) ; j >= 1 ; --j) {\n      //cout << \"i = \" << i << \", j = \" << j << endl;\n      int height = j*h;\n      double j_time = (double) height / x.second;\n      double new_time = max(dp_s[i-1][j-1], j_time);\n      if (new_time < dp_s[i-1][j]) {\n        dp_s[i][j] = new_time;\n        dp_k[i][j] = order[i];\n        dp_p[i][j] = i-1;\n      }\n      else {\n        dp_s[i][j] = dp_s[i-1][j];\n        dp_k[i][j] = dp_k[i-1][j];\n        dp_p[i][j] = dp_p[i-1][j];\n      }\n    }\n\n    /*\n    cout << \"[\" << i << \"] = \" << x.second << endl;\n    for (int j = 1 ; j <= min(i, k) ; ++j) {\n      cout << dp_s[i][j] << \" \" << dp_k[i][j] << \" \" << dp_p[i][j] << endl;\n    }\n    */\n  }\n\n  //cout << \"I am here\" << endl;\n\n  vector ans(k+1);\n  for (int i = k, j = n ; i >= 1 ; --i) {\n    ans[i] = dp_k[j][i];\n    j = dp_p[j][i];\n  }\n\n  for (int i = 1 ; i <= k ; ++i) {\n    if (i >= 2) cout << \" \";\n    cout << ans[i];\n  }\n\n  cout << endl;\n\n  return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7136f4a9fc590102f78858f647b27792", "src_uid": "6861128fcd83c752b0ea0286869901c2", "difficulty": 2000.0}
    {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef long long ll;\n\nvector< pair,int> > homs;\n\n\nint main()\n{\n    //freopen(\"input.txt\",\"r\",stdin);\n    //freopen(\"output.txt\",\"w\",stdout);\n    \n    int n,k,h;\n    scanf(\"%d%d%d\",&n,&k,&h);\n    homs.resize(n);\n    for(int i=0;i ans(k+1);\n    while(abs(r-l)>1e-18 && iter<78)\n    {\n        m = (l+r)/2;\n        st = 1;\n        for(int i=0;i\n#include\n#include\n#define N 100009\n#define EPS 10e-10\nusing namespace std;\nint n,m,h;\nint w[N],v[N],od[N];\nint ans[N];\nbool cmp(const int &a,const int &b){\n    if(w[a]==w[b]) return v[a]one*cnt*h+EPS){\n            ans[cnt++]=od[i];\n        }\n    if(cnt>m) return true;\n    else return false;\n}\nint main(){\n    //freopen(\"in\",\"r\",stdin);\n    scanf(\"%d%d%d\",&n,&m,&h);\n    for(int i=1;i<=n;i++)\n        od[i]=i,scanf(\"%d\",w+i);\n    for(int i=1;i<=n;i++)\n        scanf(\"%d\",v+i);\n    sort(od+1,od+n+1,cmp);\n    long double s=0,e=10e20,mid;\n    for(int i=1;i<=300;i++){\n        mid=(s+e)/2;\n        if(isok(mid)) res=mid,e=mid;\n        else s=mid;\n    }\n    //printf(\"%lf\\n\",res);\n    printf(\"%d\",ans[1]);\n    for(int i=2;i<=m;i++) printf(\" %d\",ans[i]);\n    puts(\"\");\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bea3b2a20f4fcd12cf7a8d30b86e0467", "src_uid": "6861128fcd83c752b0ea0286869901c2", "difficulty": 2000.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nint k;\nint n;\nint m[111111];\nint v[111111];\nint id[111111];\nint h;\nint ans[111111];\nint a[111111];\n\nvoid sort(int l, int r)\n{\n\tint i = l, j = r, x = m[rand() % (r-l+1) + l];\n\tdo\n\t{\n\t\twhile(m[i] < x) i++;\n\t\twhile(m[j] > x) j--;\n\t\tif (i <= j)\n\t\t{\n\t\t\tswap(m[i], m[j]);\n\t\t\tswap(v[i], v[j]);\n\t\t\tswap(id[i], id[j]);\n\t\t\ti++; j--;\n\t\t}\n\t}\n\twhile(i <= j);\n\tif (i < r) sort(i, r);\n\tif (j > l) sort(l, j);\n}\n\nbool isok(double t)\n{\n\tint len = 0;\n\tfor (int i=1; i<=n; i++)\n\t{\n\t\tif ((double)h * (len+1) / v[i] <= t)\n\t\t{\n\t\t\ta[++len] = id[i];\n\t\t}\n\t\tif (len >= k) break;\n\t}\n\tif (len >= k)\n\t{\n\t\tfor (int i=1; i<=k; i++) ans[i] = a[i];\n\t\treturn true;\n\t}\n\telse return false;\n}\n\nint main(void)\n{\n\tscanf(\"%d%d%d\", &n, &k, &h);\n\tfor (int i=1; i<=n; i++) scanf(\"%d\", &m[i]);\n\tfor (int i=1; i<=n; i++) scanf(\"%d\", &v[i]);\n\tfor (int i=1; i<=n; i++) id[i] = i;\n\n\tsort(1, n);\n\tdouble left = 0, right = 10000, mid;\n\tfor (int cnt=1; cnt<=100; cnt++)\n\t{\n\t\tmid = (left + right) / 2;\n\t\tif (isok(mid)) right = mid;\n\t\telse left = mid;\n\t}\n\n\tprintf(\"%d\", ans[1]);\n\tfor (int i=2; i<=k; i++) printf(\" %d\", ans[i]);\n\tprintf(\"\\n\");\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "686887e97651e02adb35e860c179ecee", "src_uid": "6861128fcd83c752b0ea0286869901c2", "difficulty": 2000.0}
    {"lang": "GNU C++", "source_code": "// #includes {{{\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n// }}}\n// pre-written code {{{\n#define rep(i,n) for(int i=0;i<(int)(n);++i)\n#define rrep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)\n#define foreach(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)\n#define all(c) (c).begin(), (c).end()\n#define MP make_pair\n\ntypedef long long Int;\ntypedef long long ll;\ntypedef long double ld;\n\ntypedef pair pii;\n// }}}\n\nint x[3], m[3], t[3];\n\nstruct State{\n\tchar a[3], move[3], above[3], below[3];\n};\n\nset st;\n\nbool operator<(const State &s, const State &t){\n\trep(i,3)if(s.a[i]t.a[i])return false;\n\trep(i,3)if(s.move[i]t.move[i])return false;\n\trep(i,3)if(s.above[i]t.above[i])return false;\n\trep(i,3)if(s.below[i]t.below[i])return false;\n\treturn false;\n}\n\nint maxi=-1;\n\n// not grab: above=-1\n// end throw: above=3\n\nvoid dfs(const State &s){\n\tif(st.find(s)!=st.end())return;\n\tst.insert(s);\n\tbool terminate=true;\n\trep(i,3){\n\t\tif(s.move[i]==0)terminate=false;\n\t\tif(s.above[i]!=3)terminate=false;\n\t}\n\tmaxi=max(maxi,(int)s.a[0]);\n\tmaxi=max(maxi,(int)s.a[1]);\n\tmaxi=max(maxi,(int)s.a[2]);\n\n\tif(terminate)return;\n\trep(i,3){//who move\n\t\tif(s.move[i]==1 or s.above[i]!=-1 or s.below[i]!=-1)continue;\n\t\t//movable\n\t\tint d=s.a[i];\n\t\tfor(int d2=d-m[i];d2<=d+m[i];d2++){//where to move\n\t\t\tif(d2<=0)continue;\n\t\t\tbool valid=true;\n\t\t\trep(j,3){\n\t\t\t\tif(i==j)continue;\n\t\t\t\tif(s.a[j]==d2)valid=false;\n\t\t\t}\n\t\t\tif(not valid)continue;\n\t\t\tState s2=s; s2.a[i]=d2;s2.move[i]=1;\n\t\t\tdfs(s2);\n\t\t}\n\t}\n\trep(i,3){//who grab\n\t\tif(s.above[i]!=-1 or s.below[i]!=-1)continue;\n\t\tint d=s.a[i];\n\t\trep(j,3){//who lift\n\t\t\tif(i==j)continue;\n\t\t\tif(abs(s.a[i]-s.a[j])!=1 or s.below[j]!=-1)continue;\n\t\t\t//i grubs j\n\t\t\tState s2=s;\n\t\t\ts2.above[i]=j;s2.below[j]=i;\n\t\t\ts2.a[j]=s2.a[i];\n\t\t\tdfs(s2);\n\t\t}\n\t}\n\trep(i,3){//who throw\n\t\tif(s.above[i]==-1 or s.above[i]==3 or s.below[i]!=-1)continue;\n\t\tint d=s.a[i];\n\t\tint j=s.above[i];\n\t\tfor(int d2=d-t[i];d2<=d+t[i];d2++){\n\t\t\tif(d2<=0)continue;\n\t\t\tbool valid=true;\n\t\t\trep(j2,3){\n\t\t\t\tif(s.a[j2]==d2)valid=false;\n\t\t\t}\n\t\t\tif(not valid)continue;\n\t\t\tState s2=s;\n\t\t\ts2.above[i]=3;\n\t\t\ts2.below[j]=-1;s2.a[j]=d2;\n\t\t\tif(s2.above[j]!=-1 and s2.above[j]!=3){\n\t\t\t\tint k=s2.above[j];s2.a[k]=d2;\n\t\t\t}\n\t\t\tdfs(s2);\n\t\t}\n\t}\n}\n\nint main() {\n\tcin>>x[0]>>m[0]>>t[0]>>x[1]>>m[1]>>t[1]>>x[2]>>m[2]>>t[2];\n\tState s={x[0],x[1],x[2],0,0,0,-1,-1,-1, -1,-1,-1};\n\tdfs(s);\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n// }}}\n// pre-written code {{{\n#define rep(i,n) for(int i=0;i<(int)(n);++i)\n#define rrep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)\n#define foreach(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)\n#define all(c) (c).begin(), (c).end()\n#define MP make_pair\n\ntypedef long long Int;\ntypedef long long ll;\ntypedef long double ld;\n\ntypedef pair pii;\n// }}}\n\n#include\n\nint x[3], m[3], t[3];\n\nstruct State{\n\tchar a[3], move[3], above[3], below[3];\n};\n\nState checkPoint0={4,3,4,0,1,0,-1,-1,0,2,-1,-1};\nState checkPoint1={3,3,3,0,1,0,-1,2,0,2,-1,1};\nState checkPoint2={6,3,6,0,1,0,-1,3,0,2,-1,-1};\nState checkPoint3={7,3,6,0,1,0,-1,3,3,-1,-1,-1};\nState checkPoint4={7,3,7,0,1,0,2,3,3,-1,-1,0};\nState checkPoint5={7,3,11,0,1,0,3,3,3,-1,-1,-1};\nState checkPoint6={7,3,12,0,1,1,3,3,3,-1,-1,-1};\n\nconst int p=98019;\n\nnamespace std{\n\ttemplate<>\n\t\tstruct hash{\n\t\t\tsize_t operator()(const State& s)const{\n\t\t\t\tunsigned int v=0;\n\t\t\t\trep(i,3)v+=s.a[i],v*=p;\n\t\t\t\trep(i,3)v+=s.move[i],v*=p;\n\t\t\t\trep(i,3)v+=s.above[i],v*=p;\n\t\t\t\trep(i,3)v+=s.below[i],v*=p;\n\t\t\t\treturn v;\n\t\t\t}\n\t\t};\n};\n\n\nbool operator<(const State &s, const State &t){\n\trep(i,3)if(s.a[i]t.a[i])return false;\n\trep(i,3)if(s.move[i]t.move[i])return false;\n\trep(i,3)if(s.above[i]t.above[i])return false;\n\trep(i,3)if(s.below[i]t.below[i])return false;\n\treturn false;\n}\n\nbool operator==(const State &s,const State &t){\n\treturn (not ((s st;\nint maxi=-1;\n\n// not grab: above=-1\n// end throw: above=3\n\nbool opt;\n\nvoid dfs(const State &s){\n\tif(st.find(s)!=st.end())return;\n\tst.insert(s);\n\t//      if(s==checkPoint5)opt=true,cout<<\"nya\"<>x[0]>>m[0]>>t[0]>>x[1]>>m[1]>>t[1]>>x[2]>>m[2]>>t[2];\n\tState s={x[0],x[1],x[2],0,0,0,-1,-1,-1, -1,-1,-1};\n\tdfs(s);\n\tcout<\n#include \n#include \n#include \n#define gets() dfs(b[1],b[2],b[3],c[1],c[2],c[3])\n#define For(i,x,y) for(i=x;i<=y;i++)\nusing namespace std;\nint i,j,k,n,m,an;\nint a[4][4];\nbool f[30][30][30][4][4][4];\nvoid dfs(int x,int y,int z,int A,int B,int C) {\n\tint b[4]={0,x,y,z},c[4]={0,A,B,C},i,j,k,f[30]={};\n\tif (f[x][y][z][A][B][C]) return;\n\tf[x][y][z][A][B][C]=1;\n\tFor(i,1,3) f[b[i]]=i;\n\tFor(i,1,3) {\n\t\tint t=b[i];\n\t\tif (t<27) {\n\t\t\tan=max(an,t);\n\t\t\tif (!(c[i]&1)&&!f[26+i]) {\n\t\t\t\tFor(j,t-a[i][2],t+a[i][2]) if (j>0&&!f[j]) {\n\t\t\t\t\tb[i]=j,c[i]^=1;\n\t\t\t\t\tgets();\n\t\t\t\t\tb[i]=t;c[i]^=1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!(c[i]&2)&&!f[26+i]) {\n\t\t\t\tFor(j,1,3) {\n\t\t\t\t\tint v=b[j];\n\t\t\t\t\tif (abs(t-v)!=1) continue;\n\t\t\t\t\tb[j]=26+i; c[i]^=2;\n\t\t\t\t\tgets();\n\t\t\t\t\tb[j]=v; c[i]^=2;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (f[26+i]) {\n\t\t\t\tint A=f[26+i];\n\t\t\t\tFor(j,t-a[i][3],t+a[i][3]) if (j>0&&!f[j]) {\n\t\t\t\t\tb[A]=j;\n\t\t\t\t\tgets();\n\t\t\t\t\tb[A]=26+i;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\nint main() {\n\tFor(i,1,3)For(j,1,3) scanf(\"%d\",&a[i][j]);\n\tdfs(a[1][1],a[2][1],a[3][1],0,0,0);\n\tprintf(\"%d\\n\",an);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "657201264160ccd142a1d0a40e95fb00", "src_uid": "a14739b86d1fd62a030226263cdc1afc", "difficulty": 2500.0}
    {"lang": "GNU C++", "source_code": "// #includes {{{\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n// }}}\n// pre-written code {{{\n#define rep(i,n) for(int i=0;i<(int)(n);++i)\n#define rrep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)\n#define foreach(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)\n#define all(c) (c).begin(), (c).end()\n#define MP make_pair\n\ntypedef long long Int;\ntypedef long long ll;\ntypedef long double ld;\n\ntypedef pair pii;\n// }}}\n\n#include\n\nint x[3], m[3], t[3];\n\nstruct State{\n\tchar a[3], move[3], above[3], below[3];\n};\n\nState checkPoint0={4,3,4,0,1,0,-1,-1,0,2,-1,-1};\nState checkPoint1={3,3,3,0,1,0,-1,2,0,2,-1,1};\nState checkPoint2={6,3,6,0,1,0,-1,3,0,2,-1,-1};\nState checkPoint3={7,3,6,0,1,0,-1,3,3,-1,-1,-1};\nState checkPoint4={7,3,7,0,1,0,2,3,3,-1,-1,0};\nState checkPoint5={7,3,11,0,1,0,3,3,3,-1,-1,-1};\nState checkPoint6={7,3,12,0,1,1,3,3,3,-1,-1,-1};\n\nconst int p=98019;\n\nnamespace std{\n\ttemplate<>\n\t\tstruct hash{\n\t\t\tsize_t operator()(const State& s)const{\n\t\t\t\tunsigned int v=0;\n\t\t\t\trep(i,3)v+=s.a[i],v*=p;\n\t\t\t\trep(i,3)v+=s.move[i],v*=p;\n\t\t\t\trep(i,3)v+=s.above[i],v*=p;\n\t\t\t\trep(i,3)v+=s.below[i],v*=p;\n\t\t\t\treturn v;\n\t\t\t}\n\t\t};\n};\n\n\nbool operator<(const State &s, const State &t){\n\trep(i,3)if(s.a[i]t.a[i])return false;\n\trep(i,3)if(s.move[i]t.move[i])return false;\n\trep(i,3)if(s.above[i]t.above[i])return false;\n\trep(i,3)if(s.below[i]t.below[i])return false;\n\treturn false;\n}\n\nbool operator==(const State &s,const State &t){\n\treturn (not ((s st;\nint maxi=-1;\n\n// not grab: above=-1\n// end throw: above=3\n\nbool opt;\n\nvoid dfs(const State &s){\n\tif(st.find(s)!=st.end())return;\n\tst.insert(s);\n\t//      if(s==checkPoint5)opt=true,cout<<\"nya\"<>x[0]>>m[0]>>t[0]>>x[1]>>m[1]>>t[1]>>x[2]>>m[2]>>t[2];\n\tState s={x[0],x[1],x[2],0,0,0,-1,-1,-1, -1,-1,-1};\n\tdfs(s);\n\tcout<\nusing namespace std;\n#define FF first\n#define SS second\n#define PB push_back\n#define MP make_pair\n#define bged(v) (v).begin(),(v).end()\n#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)\ntypedef long long ll;\nconst int Imx=2147483647;\nconst ll Lbig=2e18;\nconst int mod=998244353;\n//My i/o stream\nstruct fastio\n{\n\tchar s[100000];\n\tint it,len;\n\tfastio(){it=len=0;}\n\tinline char get()\n\t{\n\t\tif(it0)it--;\n\t\treturn c!=EOF;\n\t}\n}_buff;\n#define geti(x) x=getnum()\n#define getii(x,y) geti(x),geti(y)\n#define getiii(x,y,z) getii(x,y),geti(z)\n#define puti(x) putnum(x),putchar(' ')\n#define putii(x,y) puti(x),puti(y)\n#define putiii(x,y,z) putii(x,y),puti(z)\n#define putsi(x) putnum(x),putchar('\\n')\n#define putsii(x,y) puti(x),putsi(y)\n#define putsiii(x,y,z) putii(x,y),putsi(z)\ninline ll getnum()\n{\n\tll r=0;bool ng=0;char c;c=_buff.get();\n\twhile(c!='-'&&(c<'0'||c>'9'))c=_buff.get();\n\tif(c=='-')ng=1,c=_buff.get();\n\twhile(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();\n\treturn ng?-r:r;\n}\ntemplate inline void putnum(T x)\n{\n\tif(x<0)putchar('-'),x=-x;\n\tregister short a[20]={},sz=0;\n\twhile(x)a[sz++]=x%10,x/=10;\n\tif(sz==0)putchar('0');\n\tfor(int i=sz-1;i>=0;i--)putchar('0'+a[i]);\n}\ninline char getreal(){char c=_buff.get();while(c==' '||c=='\\n')c=_buff.get();return c;}\nint n,mu[50111];\nint g[50111];\nint g0[50111],g1[50111],g2[50111];\nint ans0[50111],ans1[50111];\n\nunsigned long long f0[50111],f1[50111],f2[50111];\n#define func(j) \tf0[i]=(f0[i]+1ll*f0[j]*g0[i-j]+1ll*f1[j]*g1[i-j])%mod,f1[i]=(f1[i]+1ll*f0[j]*g1[i-j]+1ll*f1[j]*g2[i-j])%mod,f2[i]=(f2[i]+1ll*f2[j]*g2[i-j]+1ll*f1[j]*g1[i-j])%mod;\nint main()\n{\n\tunsigned long long bound=14e18;\n\tcin>>n;\n//\tn=50000;\n\tg[0]=g[2]=1;\n\tfor(int i=4;i<=n;i+=2)g[i]=(g[i-2]+g[i-4])%mod;\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tg0[i+1]=1ll*g[i]*i*i%mod;\n\t\tg1[i+1]=1ll*g[i-1]*i*i%mod;\n\t\tif(i>=2)g2[i+1]=1ll*g[i-2]*i*i%mod;\n\t}\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tfor(int j=0;j+2<=i;j+=2)\n\t\t{\n\t\t\t/*\n\t\t\tf0[i]=(f0[i]+1ll*f0[j]*g0[i-j]+1ll*f1[j]*g1[i-j])%mod;\n\t\t\tf1[i]=(f1[i]+1ll*f0[j]*g1[i-j]+1ll*f1[j]*g2[i-j])%mod;\n\t\t\tf2[i]=(f2[i]+1ll*f2[j]*g2[i-j]+1ll*f1[j]*g1[i-j])%mod;\n\t\t\t*/\n\t\t\tf0[i]+=f0[j]*g0[i-j]+f1[j]*g1[i-j];\n\t\t\tf1[i]+=f0[j]*g1[i-j]+f1[j]*g2[i-j];\n\t\t\tf2[i]+=f2[j]*g2[i-j]+f1[j]*g1[i-j];\n\t\t\tf0[i]+=f0[j+1]*g0[i-j-1]+f1[j+1]*g1[i-j-1];\n\t\t\tf1[i]+=f0[j+1]*g1[i-j-1]+f1[j+1]*g2[i-j-1];\n\t\t\tf2[i]+=f2[j+1]*g2[i-j-1]+f1[j+1]*g1[i-j-1];\n\t\t\tf0[i]=f0[i]>=bound?f0[i]%mod:f0[i];\n\t\t\tf1[i]=f1[i]>=bound?f1[i]%mod:f1[i];\n\t\t\tf2[i]=f2[i]>=bound?f2[i]%mod:f2[i];\n\t\t}\n\t\tif(i%2==1)\n\t\t{\n\t\t\tint j=i-1;\n\t\t\tf0[i]+=f0[j]*g0[i-j]+f1[j]*g1[i-j];\n\t\t\tf1[i]+=f0[j]*g1[i-j]+f1[j]*g2[i-j];\n\t\t\tf2[i]+=f2[j]*g2[i-j]+f1[j]*g1[i-j];\n\t\t}\n\t\tf0[i]=(f0[i]+g0[i])%mod;\n\t\tf1[i]=(f1[i]+g1[i])%mod;\n\t\tf2[i]=(f2[i]+g2[i])%mod;\n\t}\n/*\tfor(int i=0;i<=n;i++)cerr<=3)curans+=1ll*g[l-3]*f2[r]%mod;\n\t\tcurans=curans%mod*(i-1)%mod*(i-1)%mod;\n\t\tans+=1ll*curans*i%mod;\n\t}\n\tcout<\n#include \nusing namespace std;\n#define N 50010\n#define mod 998244353\n#define RG register\n#define LL long long\nint n,g[N],f0[N],f1[N],f2[N],pf[N];\nint main()\n{\n//\tfreopen(\"Ark.in\",\"r\",stdin);\n//\tfreopen(\"1.out\",\"w\",stdout);\n\tRG int i,j;\n\tscanf(\"%d\",&n);\n\tif(n==50000){puts(\"475800099\");return 0;}\n\tfor(i=1;i<=n+2;++i)pf[i]=(LL)i*i%mod;\n\tg[0]=1,g[1]=0,g[2]=1,g[3]=0;\n\tfor(i=4;i<=n;i+=2)g[i]=(g[i-2]+g[i-4])%mod;\n\tf0[0]=0,f1[0]=1,f2[0]=4;\n\tfor(i=1;i<=n;++i)\n\t{\n\t\tf0[i]=(LL)g[i]*pf[i]%mod;\n\t\tf1[i]=(LL)g[i]*pf[i+1]%mod;\n\t\tf2[i]=(LL)g[i]*pf[i+2]%mod;\n\t\tfor(j=2;j\n#pragma GCC optimize(\"Ofast,unroll-loops\")\nusing namespace std;\ntypedef int ll;\ntypedef long long int li;\nconst ll MAXN=2e5+51,MOD=998244353; \nstruct Matrix{\n\tll num[16][16];\n\tMatrix()\n\t{\n\t\tmemset(num,0,sizeof(num));\n\t}\n\tinline ll* operator [](const ll &x)\n\t{\n\t\treturn num[x];\n\t}\n\tinline const ll* operator [](const ll &x)const\n\t{\n\t\treturn num[x];\n\t}\n};\nll qcnt;\nli n;\nMatrix mat,x,res;\nll g[16]={\n\t0,4,8,998244352,16,998244343,4,998244341,\n\t998244305,26,998244309,15,998244337,998244349,998244349,998244352\n};\nll f[16]={\n\t0,0,0,24,4,240,204,1316,2988,\n\t6720,26200,50248,174280,436904,1140888,3436404\n};\ninline li read()\n{\n    register li num=0;\n    register char ch=getchar();\n    while(!isdigit(ch))\n    {\n        ch=getchar();\n    }\n    while(isdigit(ch))\n    {\n        num=(num<<3)+(num<<1)+(ch-'0');\n        ch=getchar();\n    }\n    return num;\n}\ninline Matrix operator *(Matrix x,Matrix y)\n{\n\tMatrix res;\n\tfor(register int i=0;i<16;i++)\n\t{\n\t\tfor(register int j=0;j<16;j++)\n\t\t{\n\t\t\tfor(register int k=0;k<16;k++)\n\t\t\t{\n\t\t\t\tres[i][j]=(res[i][j]+(li)x[i][k]*y[k][j]%MOD)%MOD;\n\t\t\t}\n\t\t}\n\t}\n\treturn res;\n}\ninline Matrix qpow(Matrix base,li exponent)\n{\n\tMatrix res;\n\tfor(register int i=0;i<16;i++)\n\t{\n\t\tres[i][i]=1;\n\t}\n\twhile(exponent)\n\t{\n\t\tif(exponent&1)\n\t\t{\n\t\t\tres=res*base;\n\t\t}\n\t\tbase=base*base,exponent>>=1;\n\t}\n\treturn res;\n}\nint main()\n{\n\tqcnt=read();\n\tfor(register int i=0;i<16;i++)\n\t{\n\t\tmat[i][0]=g[i],x[0][i]=f[15-i];\n\t}\n\tfor(register int i=1;i<16;i++)\n\t{\n\t\tmat[i-1][i]=1;\n\t}\n\tfor(register int i=0;i\nclock_t t=clock();\nnamespace my_std{\n\tusing namespace std;\n\t#define pii pair\n\t#define fir first\n\t#define sec second\n\t#define MP make_pair\n\t#define rep(i,x,y) for (int i=(x);i<=(y);i++)\n\t#define drep(i,x,y) for (int i=(x);i>=(y);i--)\n\t#define go(x) for (int i=head[x];i;i=edge[i].nxt)\n\t#define templ template\n\t#define sz 5050\n\t#define mod 998244353ll\n\ttypedef long long ll;\n\ttypedef double db;\n\tmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n\ttempl inline T rnd(T l,T r) {return uniform_int_distribution(l,r)(rng);}\n\ttempl inline bool chkmax(T &x,T y){return xy?x=y,1:0;}\n\ttempl inline void read(T& t)\n\t{\n\t\tt=0;char f=0,ch=getchar();double d=0.1;\n\t\twhile(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();\n\t\twhile(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();\n\t\tif(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}\n\t\tt=(f?-t:t);\n\t}\n\ttemplateinline void read(T& t,Args&... args){read(t); read(args...);}\n\tchar __sr[1<<21],__z[20];int __C=-1,__zz=0;\n\tinline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}\n\tinline void print(register int x)\n\t{\n\t\tif(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;\n\t\twhile(__z[++__zz]=x%10+48,x/=10);\n\t\twhile(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\\n';\n\t}\n\tvoid file()\n\t{\n\t\t#ifdef NTFOrz\n\t\tfreopen(\"a.in\",\"r\",stdin);\n\t\t#endif\n\t}\n\tinline void chktime()\n\t{\n\t\t#ifdef NTFOrz\n\t\tcout<<(clock()-t)/1000.0<<'\\n';\n\t\t#endif\n\t}\n\t#ifdef mod\n\tll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}\n\tll inv(ll x){return ksm(x,mod-2);}\n\t#else\n\tll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}\n\t#endif\n//\tinline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}\n}\nusing namespace my_std;\n\nint n;\n\nll dp[4][4],tmp[4][4];\nll g[sz],f[sz][2];\nvoid DP()\n{\n\tstatic int to[4];\n\trep(i,1,n-1)\n\t{\n\t\trep(k,0,3) rep(s,0,3)\n\t\t{\n\t\t\tll w=tmp[k][s];\n\t\t\tif (!w) continue;\n\t\t\t\n\t\t\trep(p,0,3) to[p]=0;\n\t\t\tif (s==0) to[1]++;\n\t\t\telse if (s==1) to[3]++;\n\t\t\telse if (s==2) to[0]++,to[3]++;\n\t\t\telse to[2]++;\n\t\t\trep(t,0,3) if ((t&k)==k) rep(p,0,3) (dp[t][p]+=w*to[p]%mod)%=mod;\n\t\t\t\n\t\t\tif (k!=3) continue;\n\t\t\tif (!(s>>1&1)) continue;\n\t\t\t(dp[0][(s^2)<<1|1]+=w)%=mod; (f[i+1][s&1]+=w)%=mod;\n\t\t}\n\t\trep(k,0,3) rep(s,0,3) tmp[k][s]=dp[k][s],dp[k][s]=0;\n\t}\n\tmemcpy(dp,tmp,sizeof(dp));\n\tg[0]=g[2]=1;rep(i,2,n/2) g[i*2]=(g[(i-1)*2]+g[(i-2)*2])%mod;\n}\n\nint main()\n{\n\tfile();\n\tread(n);\n\tll ans=0;\n\tmemset(dp,0,sizeof(dp)),memset(tmp,0,sizeof(tmp)),memset(f,0,sizeof(f)),memset(g,0,sizeof(g));\n\ttmp[0][3]=1;\n\tDP();f[1][1]=1;\n\trep(i,1,n-1)\n\t{\n\t\tll w=0;\n\t\t(w+=f[n-i][1]*g[i]%mod)%=mod;\n\t\t(w+=f[n-i][0]*g[i-1]%mod)%=mod;\n\t\t(ans+=w*(i+1)%mod*i%mod*i%mod)%=mod;\n\t}\n\tmemset(dp,0,sizeof(dp)),memset(tmp,0,sizeof(tmp)),memset(f,0,sizeof(f)),memset(g,0,sizeof(g));\n\trep(i,0,3) dp[i][3]=1;\n\tDP();f[1][0]=1;\n\trep(i,1,n-1)\n\t{\n\t\tll w=0;\n\t\t(w+=f[n-i][1]*g[i-1]%mod)%=mod;\n\t\t(w+=f[n-i][0]*(i==1?0ll:g[i-2])%mod)%=mod;\n\t\t(ans+=w*(i+1)%mod*i%mod*i%mod)%=mod;\n\t}\n\tcout<\n\nusing namespace std;\n\n#define db(x) cout << (x) << '\\n';\n#define all(x) x.begin(),x.end()\n#define UNIQUE(x) sort(all(x)),x.resize(unique(all(x))-x.begin())\n#define LB(v,x) lower_bound(all(v),x)\n#define UB(v,x) upper_bound(all(v),x)\n#define endl \"\\n\"\n#define F first\n#define S second\n#define PB push_back\n#define PF push_front\n#define int long long\n#define double long double\n#define trick int m = (l+r)>>1,lc=n<<1,rc=lc|1\n\ntypedef long long ll;\ntypedef pair pii;\ntypedef vector vi;\ntypedef vector vii;\n\nint dy[]={0,1,1,1,0,-1,-1,-1};\nint dx[]={-1,-1,0,1,1,1,0,-1};\nconst int maxn = 1e5;\nconst int OO = 1e18;\nconst int mod = 1e9 + 7;\nconst double PI = acos(-1);\n\nvoid maxself(int &a,int b)\n{a=max(a,b);}\nvoid minself(int &a,int b)\n{a=min(a,b);}\n\nvector g(maxn);\n\n\nint32_t main(){\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n\tcout.tie(0);\n\n//\tfreopen(\"name.in\",\"r\",stdin);\n//\tfreopen(\"name.out\",\"w\",stdout);\n\n    int n;\n    cin >> n;\n    int a[n];\n    vi ans;\n    int sum = 0;\n    int alic = 0;\n    for(int i=0;i> a[i];\n        if(i == 0 or a[i]<=a[0]/2)\n        {\n            alice+=a[i];\n            ans.PB(i+1);\n        }\n        sum+=a[i];\n    }\n    if(alice*2>sum)\n    {\n        cout << v.size() << endl;\n        for(auto x:v)\n            cout << x << ' ';\n    }\n    else\n        cout << 0;\n\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3128774ec969de02049c8bd967f4a2de", "src_uid": "0a71fdaaf08c18396324ad762b7379d7", "difficulty": 800.0}
    {"lang": "GNU C++14", "source_code": "using namespace std;\nint main()\n{\n    int n;\n    cin>>n;\n    int arr[n+1];int tot=0;\n    for(int i=1;i<=n;i++)\n    {\n        cin>>arr[i];\n    }\n    for(int i=1;i<=n;i++)\n    {\n     tot+=arr[i];\n    }\n    int myp=arr[1];\n    for(int i=2;i<=n;i++)\n    {\n        if(arr[i]>myp/2)\n        {\n            arr[i]=0;\n        }\n    }\n    int c=1;\n    vectorind;\n    ind.push_back(1);\n    if(myp>tot/2)\n    {\n        cout<<\"1\"<\n#include \n\nusing namespace std;\n\nint main() {\n    int N; cin >> N;\n    vector A(N); for (int&a:A) cin >> a;\n    vector P{1};\n    int rest = 0, cur = A[0];\n    for (int i = 1; i < N; ++i) {\n        if (A[i] <= A[0]/2) {  \n            cur += A[i];\n            P.push_back(i+1);\n        } else {\n            rest += A[i];\n        }\n    }\n\n    if (cur > rest) {\n        cout << P.size() << endl;\n        for (int i = 0; i < P.size(); ++i) cout << P[i] << \" \\n\"[i==P.size()-1];\n    } else {\n        cout << 0 << endl;\n    }", "lang_cluster": "C++", "compilation_error": true, "code_uid": "27023b7d67cb7a3553a173db26f98608", "src_uid": "0a71fdaaf08c18396324ad762b7379d7", "difficulty": 800.0}
    {"lang": "GNU C++11", "source_code": "#include\n  using namespace std;\n  \n   int main()\n   \n   {\n   int n,sum=0,i=0;\n   vector v;\n   cin>>n;\n    \n    int a[n];\n     for( i=0;i>a[i];\n         sum=sum+a[i];\n         \n         \n     }\n     \n     int alice=a[0];\n   \n     if (2*alice<=sum)\n     {\n\n         for(i=1;i=2*a[i])\n                 v.push_back(i+1);\n           \n              else \n              continue;\n           }\n           \n           if(v.size()==0)\n              cout<<\"0\";\n              \n           else{\n      cout<\n\nusing namespace std;\n\nconst int N = 2050;\nconst int MOD = 1e9 + 7;\n\nint f[N][N][2];\n\nint sol(int x, int y, int z)\n{\n    if(f[x][y][z]+1)\n        return f[x][y][z];\n    if(x+y == 1)\n        return f[x][y][z] = z;\n    if((x|y) == 0)\n        return f[x][y][z] = 0;\n    if(l > r)\n        return f[x][y][z] = 0;\n    int tmp = 0;\n    if(x)\n        tmp += sol(x-1, y, !z);\n    if(y)\n        tmp += sol(x, y-1, !z);\n    return f[x][y][z] = tmp % MOD;\n}\n\nint main()\n{\n    int n;\n    scanf(\"%d\", &n);\n    return 0*printf(\"%d\\n\", sol(n, n, 0));\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "58f23734f83c85c8d7bd220b9e70bee7", "src_uid": "8218255989e5eab73ac7107072c3b2af", "difficulty": 2100.0}
    {"lang": "GNU C++17", "source_code": "#include \n#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n#define int long long\n#define pb push_back\n#define sz(i) (int)(i.size())\n#define F first\n#define S second\n#define L long double\n#define P pair\nconst int inf = 0x3f3f3f3f3f3f3f3LL;\nconst int mod = (int)1e9 + 7;\nusing namespace std;\n#if LOCAL\n#include \"../../tr.h\"\n#else\n#define tr(...)\n#define endl '\\n'\n#endif\ntemplate void smin(T& a, T val) {if (a > val) a = val;}template void smax(T& a, T val) {if (a < val) a = val;}\nconst int N = (int)5e3 + 10;\n\nint n, a[N];\n\nint power(int a, int b, int m = mod){if(b < 0)b += m-1; int r = 1; while(b){if(b&1)r=(r*a)%m; a = (a*a)%m; b>>=1;}return r;}\n\nint fact[N+10], ifact[N+10];\nvoid pre(int N){\n   fact[0] = 1;\n   for (int i = 1; i <= N; ++i)\n   {\n      fact[i] = (i*fact[i-1])%mod;\n   }\n   ifact[N] = power(fact[N], -1);\n   for (int i = N-1; i >= 0; --i)\n   {\n      ifact[i] = ((i+1)*ifact[i+1])%mod;\n   }\n}\n\nint nCr(int n, int r){\n   if(n < r)return 0;\n   return ((fact[n]*ifact[r])%mod * ifact[n-r])%mod;\n}\n\nint data[N];\n\nint32_t main(){_\n\n   cin>>n;\n\n   if (n <= 4){\n      int x = power(3, n-1);\n      cout< think binary_search, DP, greedy\n// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.\n// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)\n// -value of const int N is not correct (WA/RTE).\n// -Did you memset dp to -1 ?\n// -check for small edges cases and work on small test cases manually if WA\n// -not deallocating memory to pointers can lead to MLE. Use delete :))\n// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.\n// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)\n// -Check Bitwise Operator Precedence \n// -Use pragmas to optimize (by constant factor) when necessary..\n// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works", "lang_cluster": "C++", "compilation_error": true, "code_uid": "13b86008c2d60a18775384bf2dea54b3", "src_uid": "8218255989e5eab73ac7107072c3b2af", "difficulty": 2100.0}
    {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\n#define MAXN 1010\n\nint n;\nint dp[MAXN][MAXN][2];\n\nint solve(int x, int y, int op) {\n    int &ans = dp[x][y][op];\n\n    if (ans!=-1) {\n        return ans;\n    }\n\n    if (x+y==2*n) {\n        ans = 0;\n    }\n    else {\n        if (x==y) {\n            if (op==0) {\n                ans = solve(x+1, y, 1)+1;\n            }\n            else {\n                ans = solve(x+1, y, 0);\n            }\n        }\n        else {\n            if (x==n) {\n                if (op==0) {\n                    ans = solve(x, y+1, 1)+1;\n                }\n                else {\n                    ans = solve(x, y+1, 0);\n                }\n            }\n            else {\n                if (op==0) {\n                    if (x\n#include\n#include\n#include\n#define rep(i,a,b) for(int i=a;i<=b;i++) \nusing namespace std; \n#define maxn 10005 \n#define mod 1000000007; \n#define ll long long\nll c[maxn][maxn];\nll dp[maxn][maxn],n; \nint main() { \n    memset(dp,0,sizeof dp);\n\trep(i,1,1000)\tdp[i][0]=i/2+i%2; \n\trep(i,1,1000)\tdp[i][0]=i/2+i%2; \n\trep(i,1,1000) {\n\t\trep(j,1,i) { \n\t\t\tll t=(dp[i-1][j]+1)%mod; \n\t\t\tif(j-1>=0&&i-1>=0) \n\t\t\t\tt=(t+dp[i-1][j-1])%mod; \n\t\t\tif(j-2>=0) \n\t\t\t\tt=(t+dp[i][j-2])%mod; \n\t\t\tdp[i][j]=t; \n\t\t} \n\t}\n\tcin>>n; \n\tcout<\n\nusing namespace std;\nusing ll = long long;\nusing ld = long double;\nusing ull = unsigned long long;\n#define all(x) (x).begin(),(x).end()\n\nconst int MAXN = 25;\nconst int MAXW = 25 * 50000;\nint p[MAXN][MAXW];\n\nsigned main() {\n\tios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n\tcout.precision(20);\n\n\tint n;\n\tcin >> n;\n\tvector a(2 * n);\n\tfor (auto &i : a)\n\t\tcin >> i;\n\n\tsort(a.beign(), a.end());\n\tfor (int i = 0; i < MAXN; i++)\n\t\tfor (int j = 0; j < MAXW; j++)\n\t\t\tp[i][j] = -1;\n\n\tp[0][0] = 0;\n\tint sum = 0;\n\n\tfor (int i = 2; i < 2 * n; i++) {\n\t\tint cur = a[i];\n\t\tsum += cur;\n\t\tfor (int j = n - 1; j > 0; j--) {\n\t\t\tfor (int k = cur; k < MAXW; k++) {\n\t\t\t\tif (p[j - 1][k - cur] != -1 && p[j][k] == -1) {\n\t\t\t\t\tp[j][k] = i;\n\t\t\t\t}\n\t\t\t}\n \t\t}\n\t}\n\n\tint best = 10 * MAXW;\n\tfor (int i = 0; i < MAXW; i++) {\n\t\tif (abs(best - (abs(sum - best))) > abs(i - abs(sum - i)) && p[n - 1][i]) {\n\t\t\tbest = i;\n\t\t}\n\t}\n\n\tvector type(2 * n);\n\ttype[1] = 1;\n\tfor (int i = n - 1; i > 0; i--) {\n\t\ttype[p[i][best]] = 1;\n\t\tbest -= a[p[i][best]];\n\t}\n\tvector ans1, ans2;\n\tfor (int i = 0; i < 2 * n; i++) {\n\t\tif (type[i] == 0)\n\t\t\tans1.push_back(a[i]);\n\t\telse\n\t\t\tans2.push_back(a[i]);\n\t}\n\tsort(all(ans1));\n\tsort(all(ans2));\n\treverse(all(ans2));\n\tfor (auto i : ans1)\n\t\tcout << i << \" \";\n\tcout << endl;\n\tfor (auto i : ans2) \n\t\tcout << i << \" \";\n\tcout << endl; \n \treturn 0;\n}\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f777b0283600ca4404687a008207ea1d", "src_uid": "02372f2c8e5fbf5dc579bbe61b975e1e", "difficulty": 3100.0}
    {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\n#define range(i, m, n) for(int i = m; i < n; i++)\n#define husk(i, m, n) for(int i = m; i > n; i--)\n\nint n;\n\nint main() {\n  cin >> n;\n  vector a;\n  range(i, 0, n * 2) {\n    int c;\n    cin >> c;\n    a.push_back(c);\n  }\n  sort(a.begin(), a.end(), greater());\n  int sum = 0;\n  int total = 0;\n  range(i, 0, n - 1) sum += a[i];\n  range(i, 0, 2 * n) total += a[i];\n  reverse(a.begin(), a.end());\n  vector> dp(n, vector(sum + 1));\n  dp[0][0] = 1;\n  auto add = [&] (int v) {\n    husk(i, n - 1, 0) {\n      range(x, v, sum + 1) {\n        dp[i][x] += dp[i - 1][x - v];\n      }\n    }\n  };\n  range(i, 2, 2 * n) add(a[i]);\n  int res = INT_MAX;\n  int u = 0, v = 1;\n  int c = total - a[0] - a[1];\n  range(i, 0, c / 2 + 1) if(dp[n - 1][i] > 0) res = i;\n  res = c - s;\n  swap(a.back(), a[v]);\n  vector> was(n, vector(sum + 1, -1));\n  was[0][0] = 1;\n  range(i, 1, 2 * n - 1) {\n    husk(x, n - 1, 0) {\n      range(y, a[i], sum + 1) {\n        if(was[x][y] == -1 && was[x - 1][y - a[i]] >= 0) was[x][y] = i;\n      }\n    }\n  }\n  vector cur;\n  int su = n - 1, sv = res;\n  vector alive(2 * n);\n  while(su) {\n    cur.push_back(was[su][sv]);\n    su--;\n    sv -= a[cur.back()];\n    alive[cur.back()] = 1;\n  }\n  vector ft;\n  range(i, 1, 2 * n - 1) if(alive[i] == 0) ft.push_back(i);\n  sort(ft.begin(), ft.end(), [&](int x, int y){ return a[x] < a[y]; });\n  sort(cur.begin(), cur.end(), [&](int x, int y){ return a[x] > a[y]; });\n  cout << a[0] << \" \";\n  for(auto i : ft) cout << a[i] << \" \";\n  cout << endl;\n  for(auto i : cur) cout << a[i] << \" \";\n  cout << a[2 * n - 1];\n  return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "11ad4d9e84d3efc3f0ff567958cec085", "src_uid": "02372f2c8e5fbf5dc579bbe61b975e1e", "difficulty": 3100.0}
    {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nint ans[3][26],f[26][26*50000],a[26*2],p[52];\nint main()\n{\n    ios::sync_with_stdio(false);\n    cin.tie(0);\n    int n,sum;\n    cin >> n;\n    for (int i = 1; i <= 2*n; i++)\n     {\n         cin >> a[i];\n         sum += a[i];\n     }\n     sort(a+1, a+2*n+1);\n     f[0][0] = 1;\n     sum -= a[1]+a[2];\n     int maxans = 0;\n     ans[1][1] = a[1], ans[2][n] = a[2];\n     \n     for (int i = 3; i <= n*2; i++)\n      {\n          for (int k = sum/2; k >= a[i]; k--)\n          {\n              for (int j = n-1; j >= 1; j--)\n               {\n                  if (j-1 >= 0 && k-a[i] >= 0 && k >= 0 && f[j-1][k-a[i]] > 0) \n                  {\n                       (j >= 0 && k >= 0 && i <= 2*n) f[j-1+1][k-1+1] = i;\n\n                       (k >= 0 && (k-1+1) > maxans) maxans = k-1+1;\n                  } \n               }\n          }\n      }\n      \n    int now = n-1;\n    for (int k = maxans; now >= 1 && k >= 0; k -= a[f[now][k]], now--) \n     ans[1][now+1] = a[f[now][k]], p[f[now][k]] = 1;\n    now = 1;\n    for (int i = 3; i <= 2*n; i++) if (!p[i]) ans[2][now++] = a[i];\n    for (int k = 1; k <= 2; k++ )\n     {\n         for (int i = 1; i <= n; i++) cout << ans[k][i] << \" \";\n         cout << endl;\n     }\n    return 0;\n    \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9f0ff9fb5aa3b91ac28a96b0b7d36a26", "src_uid": "02372f2c8e5fbf5dc579bbe61b975e1e", "difficulty": 3100.0}
    {"lang": "GNU C++17", "source_code": "#include \"bits/stdc++.h\"\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#pragma warning(disable:4996)\nusing namespace std;\nusing ld = long double;\ntemplate\nusing Table = vector>;\nconst ld eps=1e-9;\n\t\n#define WHATS(var)..cout<<__LINE__<<' '<<#var<<\"=\"< ostream& operator <<(ostream &os, const pair v){\n\tos << \"( \" << v.first << \", \" << v.second << \")\"; return os;\n}\ntemplate ostream& operator <<(ostream &os, const vector &v){\n\tfor(int i = 0; i < v.size(); i++){if(i > 0){os << \" \";} os << v[i];} return os;\n}\ntemplate ostream& operator <<(ostream &os, const vector> &v){\n\tfor(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;\n}\ntemplate ostream& operator <<(ostream &os, const vector> &v){\n\tfor(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;\n}\ntemplate ostream& operator <<(ostream &os, const set &v){\n\tint i=0;\n\tfor(auto it:v){\n\t\tif(i > 0){os << ' ';}\n\t\tos << it;\n\t\ti++;\n\t} \n\treturn os;\n}\nusing ll =unsigned long long ;\t\nusing MyBitset = vector;\nvoid add(const MyBitset& a,int offset,MyBitset&b){\n\tconst int mo=offset&63;\n\tWHATS(a.size())\n\tWHATS(b.size())\n\tassert(a.size()==b.size());\n\tassert(offset>=0);\n\tconst int len=offset>>6;\n\tfor(int l=0;l>(64-mo);\n\t}\n\n}\n\n\t\nint main() {\n\tios::sync_with_stdio(false);\n\tint N;cin>>N;\n\tN*=2;\n\tvectorv(N);\n\tfor(int i=0;i>v[i];\n\tsort(v.begin(),v.end());\n\tll answer=v[0]+v[1];\n\tint mm=v[0],mmm=v[1];\n\tv=vector(v.begin()+2,v.end());\n\tvector>>memo(N-1,vector>(N/2,vector(30000)));\n\tmemo[0][0][0]=1;\n\t\n\tint sum=accumulate(v.begin(),v.end(),0);\n\tfor(int i=0;i> nmemo=vector>(N/2,vector(30000));\n\t\tfor(int j=0;j>6;\n\t\t\t// \tfor(int k=0;k<30000;++k){\n\t\t\t// \t\tif(k+pl<30000)nmemo[j+1][k+pl]|=memo[i][j][k]<>(64-mo);\n\t\t\t// \t}\n\t\t\t }\n\t\t\tfor(int k=0;k<30000;++k){\n\t\t\t\tnmemo[j][k]|=memo[i][j][k];\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\tmemo[i+1]=nmemo;\n\t}\n\tint ad=1e9;\n\tfor(int i=0;i<30000;++i){\n\t\tfor(int j=0;j<64;++j){\n\t\t\tint x=(i<<6)+j;\n\t\t\tif(memo[N-2][N/2-1][i]&(1ull<up_ids,do_ids;\n\tint now_sum=ad;\n\tint now_rest=N/2-1;\n\tWHATS(memo[2][2][0]);\n\t\n\tfor(int i=N-2;i>=0;--i){\n\t\tif(!i)break;\n\t\tint now_mo=now_sum&63;\n\t\tint now_pl=now_sum>>6;\n\t\tWHATS(i)\n\t\tWHATS(now_mo)\n\t\tWHATS(now_pl)\n\t\tWHATS(now_rest)\n\t\tWHATS(memo[i-1][now_rest][now_pl])\n\t\tassert(memo[i][now_rest][now_pl]&(1ull<\nusing namespace std;\nint main()\n{\nint n;\ncin>>n;\n\ncout<\nusing namespace std;\n#define all(v) (v).begin(),(v).end()\n#define pb push_back\n#define sqr(x) ((x)*(x))\n#define mp make_pair\n#define EPS 1e-9\n#define ones(x) __builtin_popcount(x)\n#define fast_io() ios_base::sync_with_stdio(0);cin.tie(0);\n#define debug(x) cerr << #x << \": \" << x << endl;\n#define fst first\n#define snd second\n#define itm1 fst.fst\n#define itm2 fst.snd\n#define itm3 snd\n#define mt(a,b,c) mp(mp(a,b),c)\n\ntypedef pair ii;\ntypedef vector vi;\ntypedef long long ll;\ntypedef pair ill;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef pair tri;\ntypedef pair ib;\ntypedef unsigned int uint;\n\n\nconst double PI = acos(-1);\nconst double E = 2.718281828459;\nconst int  INF = 2e9;\nconst ll LINF = 2e18;\nconst ll MOD = 1e9 + 7; \nconst int MAXN = 1e5 + 1;\nconst int MN = 1e6 + 2;\n\nll get(ll i, ll n){\n\tll st = ll(sqrt(sqr(n) - sqr(i)));\n\t--st;\n\tst = max(st, 0LL);\n\twhile(st * st + i * i <= n * n) ++st;\n\treturn max(st - 1, 0LL);\t\n}\n\nint main(){\n\tll n; cin >> n;\n\tll ans = 0;\n\tll last;\n\tif(n == 0){\n\t\tans = 1;\n\t}\n\telse{\n\t\tlast = n;\n\t\tfor(int i = 1 ; i < n ; ++i){\n\t\t\tll ret = get(ll(i),ll(n));\n\t\t\tans += 1 + max(0, last - ret - 1);\t\n\t\t\tlast = ret;\n\t\t}\n\t\tans += last;\n\t\tans *= 4;\n\t}\n\n\tcout << ans << endl;\n\treturn 0;\n\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9fb83f78f9dab8d643ed575b67906ff4", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "difficulty": null}
    {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\n\nmt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());\n\nint main()\n{\n#ifdef ONPC\n    freopen(\"a.in\", \"r\", stdin);\n#endif\n    ios::sync_with_stdio(0);\n    cin.tie(0);\n    int was = 0;\n    //for (ll n = 1; n <= 30; n++)\n    ll n;\n    cin >> n;\n    {\n        ll j = 0;\n        vector  ans(n + 1);\n        for (ll i = n; i >= 0; i--)\n        {\n            while (i * i + (j + 1) * (j + 1) <= n * n)\n            {\n                j++;\n            }\n            ans[i] = j;\n        }\n        ll ret = 0;\n        for (ll i = 0; i <= n; i++)\n        {\n            ll delta = 0;\n            if (ans[i] != 0) delta = 2;\n            else delta = 1;\n            if (i != 0) delta *= 2;\n            ret += delta;\n            if (ans[ans[i]] != i)\n            {\n                ll x = ans[i], y = i;\n                ll delta = 0;\n                if (y != 0) delta = 2;\n                else delta = 1;\n                if (x != 0) delta *= 2;\n                ret += delta;\n            }\n            /*\n            if (ans[ans[i]] != i)\n            {\n                ret += 4;\n            }\n            else\n            {\n                ret += 2;\n            }\n            */\n        }\n        /*\n            q.insert({i, j});\n            q.insert({i,-j});\n            q.insert({-i,j});\n            q.insert({-i,-j});\n            swap(i, j);\n            q.insert({i, j});\n            q.insert({i,-j});\n            q.insert({-i,j});\n            q.insert({-i,-j});\n            swap(i, j);\n            //(i, j)\n            //(i,-j)\n            //(-i,j)\n            //(i,-j)\n        }\n        cout << q.size() - was << ' ' << n << '\\n';\n        was = q.size();\n        */\n        cout << ret << '\\n';\n    }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "79441a433551c89da9c943d97fbe612e", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "difficulty": null}
    {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\nint ans;\n\nint main(){\n\tint n, y, z;\n\tscanf(\"%d\", &n);\n\tif(n == 0){\n\t\tcout << 1 << endl;\n\t\treturn;\n\t}\n\tint m = sqrt(0.5 * n * n);\n\tif(m * m + (m + 1) * (m + 1) <= n * n) ans = 8 * m + 4;\n\telse ans = 8 * m;\n\tprintf(\"%d\", ans);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d0b0a8e0abe55d58fcd385ea613e9f3d", "src_uid": "d87ce09acb8401e910ca6ef3529566f4", "difficulty": null}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nstruct _flow{\n#define oo 1e9\n    int src, dst;\n    int nedge;\n    int point[500], fnet[500], next[500], cap[500], cost[500];\n    int head[500], dist[500];\n    void clear(){\n        memset(head, -1, sizeof(head));\n        nedge=result=0;\n    }\n    inline void addedge(int u, int v, int c, int w){\n        point[nedge]=v; fnet[nedge]=0; cap[nedge]=c; cost[nedge]=w; next[nedge]=head[u];\n        head[u]=nedge++;\n        point[nedge]=u; fnet[nedge]=0; cap[nedge]=0; cost[nedge]=-w; next[nedge]=head[v];\n        head[v]=nedge++;\n    }\n    int np, in[500], pre[500], fc[500];\n    int result;\n    void spfa(){\n        fill(dist, dist+np, 1e8);\n        dist[src]=0;\n        fc[src]=1e8;\n        list Q;\n        Q.push_back(src);\n        memset(in, 0, sizeof(in));\n        while(!Q.empty()){\n            int u=Q.front(); Q.pop_front();\n            in[u]=0;\n            for(int i=head[u]; i>=0; i=next[i])\n                if(fnet[i]dist[u]+cost[i]){\n                    dist[point[i]]=dist[u]+cost[i];\n                    pre[point[i]]=i;\n                    fc[point[i]]=min(fc[u], cap[i]-fnet[i]);\n                    if(!in[point[i]]){\n                        in[point[i]]=1;\n                        if(!Q.empty() && dist[point[i]]<=dist[Q.front()])\n                            Q.push_front(point[i]);\n                        else Q.push_back(point[i]);\n                    }\n                }\n        }\n    }\n    int maxflow(){\n        memset(dist, 0, sizeof(dist));\n        result=0;\n        do{\n            spfa();\n            if(dist[dst]<1e8){\n                int f=fc[dst];\n                for(int i=dst; i!=src; i=point[pre[i]^1]){\n                    result+=f*cost[pre[i]];\n                    fnet[pre[i]]+=f;\n                    fnet[pre[i]^1]-=f;\n                }\n            }\n        }while(dist[dst]<1e8);\n        return result;\n    }\n}flow;\n\nchar pill[11][3]={\n    \"\",\"BY\", \"BW\", \"BR\", \"BB\", \"RY\", \"RW\", \"RR\", \"WY\", \"WW\", \"YY\"\n};\nchar mp[10][10];\nstruct A{\n    int a[10][10];\n};\nA  sub, type;\nint mm=0;\npair next(int x, int y){\n    if(y==7)\n        return make_pair(x+1, 0);\n    return make_pair(x, y+1);\n}\nint code(char a, char b){\n    if(a>b) swap(a, b);\n    if(a=='B'){\n        if(b=='Y') return 1;\n        if(b=='W') return 2;\n        if(b=='R') return 3;\n        return 4;\n    }\n    if(a=='R'){\n        if(b=='Y') return 5;\n        if(b=='W') return 6;\n        if(b=='R') return 7;\n    }\n    if(a=='W'){\n        if(b=='Y') return 8;\n        return 9;\n    }\n    return 10;\n}\nchar dir[2][2]={{1, 0}, {0, 1}};\nint num[15];\nint mis[11][11];\nint bn[15];\nchar ans[20][20];\nint mat[20][20];\nmap hash;\nconst int cs=1e9+7;\nvoid solve(){\n    long long id=0, b=1;for(int i=1; i<=10; i++, b*=cs) id+=bn[i]*b;\n    if(hash.find(id)!=hash.end()) return;\n    hash[id]=1;\n    fill(flow.fnet, flow.fnet+flow.nedge, 0);\n    int tmp=0;\n    for(int i=1; i<=10; i++)\n    {\n        int j=min(bn[i], num[i]);\n        //if(!j) continue;\n        flow.fnet[(i-1)*2]+=j;\n        flow.fnet[(i-1)*2+1]-=j;\n        flow.fnet[40+((i-1)*10+(i-1))*2]+=j;\n        flow.fnet[40+((i-1)*10+(i-1))*2+1]-=j;\n        flow.fnet[(i-1)*2+20]+=j;\n        flow.fnet[(i-1)*2+21]-=j;\n        tmp+=j+j; if(bn[i]>j) tmp+=bn[i]-j;\n    }\n    if(tmp<=mm) return;\n    int result=56-flow.maxflow();\n    if(result>mm){\n        mm=result;\n        //cout<>num[i];\n    for(int i=1; i<=10; i++) for(int j=1; j<=10; j++){\n        mis[i][j]=min((pill[i][0]!=pill[j][0])+(pill[i][1]!=pill[j][1]), (pill[i][0]!=pill[j][1])+(pill[i][1]!=pill[j][0]));\n    }\n    flow.clear(); flow.np=22; flow.src=0; flow.dst=21;\n    for(int i=1; i<=10; i++) flow.addedge(0, i, num[i], 0);\n    for(int i=1; i<=10; i++) flow.addedge(i+10, 21, 0, 0);\n    for(int i=1; i<=10; i++) for(int j=1; j<=10; j++)\n        flow.addedge(i, j+10, 1e8, mis[i][j]);\n    dfs(0, 0);\n    printf(\"%d\\n\", mm);\n    for(int i=1; i<=13; i++){\n        for(int j=1; j<=15; j++)\n            printf(\"%c\", ans[i][j]);\n        printf(\"\\n\");\n    }\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2750a02811bf7ab708f532af2c3f3772", "src_uid": "cb56e7578ec5e04118993444283ad1eb", "difficulty": 2900.0}
    {"lang": "GNU C++11", "source_code": "// Test\n#include \n#include \n#include \n#include \n#include \n#include \n#define N 100\n#define M 1000\n#define int65 unsigned long long\n#define For(i,x,y) for (i=x;i<=y;i++)\nusing namespace std;\nconst char P[4]={'B','R','W','Y'};\nstruct ww {\n\tint x,y;\n};\nstruct w {\n\tww a,b;\n\tint c,d,e;\n} c[N],q[20][20][50];\nint i,j,k,n,m,an,S,T,t,num,ge;\nint a[N][N],h[200],f[N][N],b[N][N],len[N][N],id[N][N],st[N][N],d[N][N],\n\tba[M],bb[M],head[M],next[M],F[M],g[M],gg[M];\nchar p[N],s[N][N],re[N][N];\nset Set;\ninline void add(int x,int y,int z) {\n\tba[++t]=y,bb[t]=z,next[t]=head[x],head[x]=t;\n\tba[++t]=x,bb[t]=0,next[t]=head[y],head[y]=t;\n}\ninline bool bfs() {\n\tint l,r,v;\n\tg[l=r=1]=S; gg[S]=0; F[S]=++num;\n\tfor (;l<=r;l++) for (v=head[g[l]];v;v=next[v]) {\n\t\tint A=ba[v];\n\t\tif (bb[v]&&F[A]!=num) {\n\t\t\tF[A]=num; gg[A]=gg[g[l]]+1; g[++r]=A;\n\t\t\tif (A==T) return 1;\n\t\t}\n\t}\n\treturn 0;\n}\nint Dfs(int x,int y) {\n\tif (x==T) return y;\n\tint v,w=0,re;\n\tfor (v=head[x];v&&wb[i][j]) add(S,id[i][j],len[i][j]-b[i][j]);\n\t\tif (len[i][j]an) {\n\t\tan=sum;\n\t\t//print\n\t\tmemcpy(re,s,sizeof(re));\n\t\tFor(i,0,3)For(j,0,3) {\n\t\t\tFor(k,1,st[i][j]) {\n\t\t\t\tw B=q[i][j][k];\n\t\t\t\tprint(B,i,j);\n\t\t\t}\n\t\t\tint B=id[i][j],v;\n\t\t\tfor (v=head[B];v;v=next[v]) {\n\t\t\t\tint C=ba[v];\n\t\t\t\tif (C<=10||C>20||bb[v]==M) continue;\n\t\t\t\tFor(u,0,3)For(r,u,3) if (id[u][r]+10==C) goto yy1;\n\t\t\t\tyy1:;\n\t\t\t\tint o;\n\t\t\t\tFor(o,bb[v]+1,M) print(q[i][j][++st[i][j]],u,r),d[u][r]--;\n\t\t\t}\n\t\t}\n\t\tFor(i,0,3)For(j,i,3)\n\t\tfor (;st[i][j]B) swap(A,B),swap(C,D),a=1;\n\tc[++ge]=(w){C,D,A,B,a};\n}\nvoid dfs(int x,int y) {\n\tif (x>7) {\n\t\twork();\n\t\treturn;\n\t}\n\tif (y>8) {\n\t\tdfs(x+1,1);\n\t\treturn;\n\t}\n\tif (f[x][y]) {\n\t\tdfs(x,y+1);\n\t\treturn;\n\t}\n\tif (x<7) {\n\t\tf[x][y]=f[x+1][y]=1;\n\t\tget(a[x][y],a[x+1][y],(ww){x,y},(ww){x+1,y});\n\t\ts[2*x][2*y-1]='|';\n\t\tdfs(x,y+1);\n\t\ts[2*x][2*y-1]='.';\n\t\tge--;\n\t\tf[x][y]=f[x+1][y]=0;\n\t}\n\tif (y<8&&!f[x][y+1]) {\n\t\tf[x][y]=f[x][y+1]=1;\n\t\tget(a[x][y],a[x][y+1],(ww){x,y},(ww){x,y+1});\n\t\ts[2*x-1][2*y]='-';\n\t\tdfs(x,y+1);\n\t\ts[2*x-1][2*y]='.';\n\t\tge--;\n\t\tf[x][y]=f[x][y+1]=0;\n\t}\n}\nint main() {\n\th['B']=0,h['R']=1,h['W']=2,h['Y']=3;\n\tFor(i,1,7) {\n\t\tscanf(\"%s\",p+1);\n\t\tFor(j,1,8) a[i][j]=h[p[j]];\n\t}\n\tFor(i,0,3)for (j=3;j>=i;j--) scanf(\"%d\",&b[i][j]);\n\tk=0; For(i,0,3)For(j,i,3) id[i][j]=++k;\n\tan=-1; memset(s,'.',sizeof(s));\n\tdfs(1,1);\n\tprintf(\"%d\\n\",an);\n\tFor(i,1,13) {\n\t\tFor(j,1,15) printf(\"%c\",re[i][j]);\n\t\tprintf(\"\\n\");\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "386c435b7a1c9ddcedf72e5b5cc3d149", "src_uid": "cb56e7578ec5e04118993444283ad1eb", "difficulty": 2900.0}
    {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nstruct kraw\n{\n    int a, cap;\n};\n\nvector< vector > podzial(7, vector(8, -1));\nvector ilNaObr(10, 0), ilMam(10, 0);\nint nr = -1, mam = 0;\nstring tab[] = {\"BB\", \"BR\", \"BW\", \"BY\", \"RR\", \"RW\", \"RY\", \"WW\", \"WY\", \"YY\"};\nvector P(7);\nvector< vector > G(22);\nconst int INF = 100;\nint odp = 56;\nvector< vector > odpPodzial;\nvector odpP1, odpP2;\nvector odpP(13);\nconst int base = 1000000007;\nset H;\n\nint Szukaj(string a)\n{\n    if (a[0] > a[1])\n        swap(a[0], a[1]);\n    for (int i = 0; i < 10; ++i)\n        if (tab[i] == a)\n            return i;\n}\n\nint R(string a, string b)\n{\n    return min((a[0] != b[0]) + (a[1] != b[1]), (a[0] != b[1]) + (a[1] != b[0]));\n}\n\nvoid Licz()\n{\n    for (int i = 1; i <= 10; ++i)\n    {\n        G[0][i - 1].cap = ilNaObr[i - 1];\n        G[i][10].cap = 0;\n    }\n    for (int i = 11; i <= 20; ++i)\n    {\n        G[i][0].cap = ilMam[i - 11];\n        G[21][i - 11].cap = 0;\n    }\n    for (int i = 1; i <= 10; ++i)\n    {\n        for (int j = 11; j <= 20; ++j)\n        {\n            G[i][j - 11].cap = INF;\n            G[j][i].cap = 0;\n        }\n    }\n    vector p1, p2;\n    for (int i = 1; i <= 10; ++i)\n    {\n        for (int j = 11; j <= 20; ++j)\n        {\n            if (R(tab[i - 1], tab[j - 11]) == 0)\n            {\n                int m = min(ilNaObr[i - 1], ilMam[i - 1]);\n                G[0][i - 1].cap -= m;\n                G[j][0].cap -= m;\n                for (int k = 0; k < m; ++k)\n                {\n                    p1.push_back(tab[i - 1]);\n                    p2.push_back(tab[i - 1]);\n                }\n            }\n            if (R(tab[i - 1], tab[j - 11]) == 2)\n            {\n                G[i][j - 11].cap = 0;\n                G[j][i].cap = 0;\n            }\n        }\n    }\n    int flow = 0;\n    while (true)\n    {\n        vector pop(22, -1);\n        queue Q;\n        Q.push(0);\n        pop[0] = 0;\n        while (!Q.empty())\n        {\n            int akt = Q.front();\n            Q.pop();\n            for (int i = 0; i < G[akt].size(); ++i)\n            {\n                if (pop[G[akt][i].a] == -1 && G[akt][i].cap != 0)\n                {\n                    pop[G[akt][i].a] = akt;\n                    Q.push(G[akt][i].a);\n                }\n            }\n        }\n        if (pop[21] == -1)\n            break;\n        vector path;\n        int akt = 21;\n        while (akt != 0)\n        {\n            path.push_back(akt);\n            akt = pop[akt];\n        }\n        path.push_back(0);\n        reverse(path.begin(), path.end());\n        int c = INF;\n        for (int i = 0; i < (int) path.size() - 1; ++i)\n            for (int j = 0; j < G[path[i]].size(); ++j)\n                if (G[path[i]][j].a == path[i + 1])\n                    c = min(c, G[path[i]][j].cap);\n        for (int i = 0; i < (int) path.size() - 1; ++i)\n        {\n            for (int j = 0; j < G[path[i]].size(); ++j)\n                if (G[path[i]][j].a == path[i + 1])\n                    G[path[i]][j].cap -= c;\n            for (int j = 0; j < G[path[i + 1]].size(); ++j)\n                if (G[path[i + 1]][j].a == path[i])\n                    G[path[i + 1]][j].cap += c;\n        }\n        flow += c;\n    }\n    for (int i = 11; i <= 20; ++i)\n    {\n        for (int j = 1; j <= 10; ++j)\n        {\n            int il = G[i][j].cap;\n            for (int k = 0; k < il; ++k)\n            {\n                p1.push_back(tab[j - 1]);\n                p2.push_back(tab[i - 11]);\n            }\n        }\n    }\n    int nowy = 2 * (28 - (int) p1.size()) + flow;\n    if (nowy < odp)\n    {\n        odp = nowy;\n        odpPodzial = podzial;\n        odpP1 = p1;\n        odpP2 = p2;\n    }\n}\n\nvoid StworzG()\n{\n    for (int i = 1; i <= 10; ++i)\n        G[0].push_back({i, 0});\n    for (int i = 1; i <= 10; ++i)\n    {\n        for (int j = 11; j <= 20; ++j)\n            G[i].push_back({j, 0});\n        G[i].push_back({0, 0});\n    }\n    for (int i = 11; i <= 20; ++i)\n    {\n        G[i].push_back({21, 0});\n        for (int j = 1; j <= 10; ++j)\n            G[i].push_back({j, 0});\n    }\n    for (int i = 11; i <= 20; ++i)\n        G[21].push_back({i, 0});\n}\n\nvoid rec(int x, int y, int kier)\n{\n    ++nr;\n    podzial[x][y] = nr;\n    if (kier == 0)\n        podzial[x][y + 1] = nr;\n    else\n        podzial[x + 1][y] = nr;\n    string para = \"\";\n    para += P[x][y];\n    if (kier == 0)\n        para += P[x][y + 1];\n    else\n        para += P[x + 1][y];\n    ++ilNaObr[Szukaj(para)];\n    ++mam;\n    if (mam == 28)\n    {\n        int h = 0;\n        for (int i = 0; i < 10; ++i)\n            h = h * base + ilNaObr[i];\n        if (H.find(h) == H.end())\n        {\n            Licz();\n            H.insert(h);\n        }\n    }\n    int nx = -1, ny = -1;\n    for (int i = x; i < 7; ++i)\n    {\n        for (int j = 0; j < 8; ++j)\n        {\n            if (podzial[i][j] == -1)\n            {\n                nx = i;\n                ny = j;\n                break;\n            }\n        }\n        if (nx != -1)\n            break;\n    }\n    if (nx != -1)\n    {\n        if (ny + 1 < 8 && podzial[nx][ny + 1] == -1)\n            rec(nx, ny, 0);\n        if (nx + 1 < 7 && podzial[nx + 1][ny] == -1)\n            rec(nx, ny, 1);\n    }\n    podzial[x][y] = -1;\n    if (kier == 0)\n        podzial[x][y + 1] = -1;\n    else\n        podzial[x + 1][y] = -1;\n    --ilNaObr[Szukaj(para)];\n    --nr;\n    --mam;\n}\n\nvoid Wypisz()\n{\n    multiset wsz;\n    for (int i = 0; i < 10; ++i)\n        for (int j = 0; j < ilMam[i]; ++j)\n            wsz.insert(tab[i]);\n    cout << 56 - odp << endl;\n    vector jest(odpP1.size(), true);\n    for (int i = 0; i < 28; ++i)\n    {\n        int a = -1, b, c, d;\n        for (int j = 0; j < 7; ++j)\n        {\n            for (int k = 0; k < 8; ++k)\n            {\n                if (odpPodzial[j][k] == i)\n                {\n                    if (a == -1)\n                    {\n                        a = j;\n                        b = k;\n                    }\n                    else\n                    {\n                        c = j;\n                        d = k;\n                    }\n                }\n            }\n        }\n        string x = \"\";\n        x += P[a][b];\n        x += P[c][d];\n        if (x[0] > x[1])\n            swap(x[0], x[1]);\n        int nr = -1;\n        for (int j = 0; j < odpP1.size(); ++j)\n        {\n            if (odpP1[j] == x && jest[j])\n            {\n                nr = j;\n                break;\n            }\n        }\n        if (nr != -1)\n        {\n            if (R(x, odpP2[nr]) == 1)\n            {\n                if (P[a][b] == odpP2[nr][0])\n                    P[c][d] = odpP2[nr][1];\n                if (P[a][b] == odpP2[nr][1])\n                    P[c][d] = odpP2[nr][0];\n                if (P[c][d] == odpP2[nr][0])\n                    P[a][b] = odpP2[nr][1];\n                if (P[c][d] == odpP2[nr][1])\n                    P[a][b] = odpP2[nr][0];\n            }\n            wsz.erase(wsz.find(odpP2[nr]));\n            jest[nr] = false;\n        }\n        else\n        {\n            P[a][b] = 'Q';\n            P[c][d] = 'Q';\n        }\n    }\n    string t(15, '.');\n    for (int i = 0; i < 13; ++i)\n        odpP[i] = t;\n    for (int i = 0; i < 7; ++i)\n        for (int j = 0; j < 8; ++j)\n            odpP[2 * i][2 * j] = P[i][j];\n    for (int i = 0; i < 28; ++i)\n    {\n        int a = -1, b, c, d;\n        for (int j = 0; j < 7; ++j)\n        {\n            for (int k = 0; k < 8; ++k)\n            {\n                if (odpPodzial[j][k] == i)\n                {\n                    if (a == -1)\n                    {\n                        a = j;\n                        b = k;\n                    }\n                    else\n                    {\n                        c = j;\n                        d = k;\n                    }\n                }\n            }\n        }\n        if (odpP[2 * a][2 * b] == 'Q')\n        {\n            string x = *(wsz.begin());\n            odpP[2 * a][2 * b] = x[0];\n            odpP[2 * c][2 * d] = x[1];\n            wsz.erase(wsz.find(x));\n        }\n        if (a == c)\n            odpP[2 * a][2 * b + 1] = '-';\n        else\n            odpP[2 * a + 1][2 * b] = '|';\n    }\n    for (int i = 0; i < 13; ++i)\n        cout << odpP[i] << endl;\n}\n\nint main()\n{\n    ios_base::sync_with_stdio(0);\n    for (int i = 0; i < 7; ++i)\n        cin >> P[i];\n    cin >> ilMam[3] >> ilMam[2] >> ilMam[1] >> ilMam[0];\n    cin >> ilMam[6] >> ilMam[5] >> ilMam[4];\n    cin >> ilMam[8] >> ilMam[7];\n    cin >> ilMam[9];\n    StworzG();\n    rec(0, 0, 0);\n    rec(0, 0, 1);\n    Wypisz();\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2bb5d1e4eb4f7d17daa4565e703f2f17", "src_uid": "cb56e7578ec5e04118993444283ad1eb", "difficulty": 2900.0}
    {"lang": "GNU C++", "source_code": "#pragma warning(disable:4786)\n#include\n#include\n#include\n#include\n#include\n#include\n\n#include\n#include\n#include\n\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\n#define MAX(a,b) ((a)>(b) ? (a) : (b))\n#define min(a,b) ((a)<(b) ? (a) : (b))\n#define EPS 1e-9\n#define asdf exit(0);\n\n\n\n\n\n\n\n\n\n\n\n\n#define MAX_V 350\nvector Edge[ MAX_V+7];\nlong Row,Col;// Row will b left side and col will b in rght side\nlong nEdge,nVertex;\n\nbool Visit[ MAX_V+7];\n\n//after matching spouse of 'i'  is M[i] ( i think  :S im not sure  )\nlong M[ MAX_V+7];\n\n\nvoid ini()\n{\n    memset(M,0,sizeof(M));\n    memset(Visit,0,sizeof(Visit));\n    int i;\n    for(i=0;i<(MAX_V+7);i++)\n    {\n        Edge[i].clear();\n    }\n}\n\nbool Match( long u)\n{\n    if( Visit[u]) return false;\n    Visit[u] =true;\n    long i;\n    for( i=0;i taken(10);\n\nvector  >O1(28);\nvector O2(28);\n\n\nvector< pair > save1(28);\nvector< int > save2(28);\n\n\n\nint pt[155][155];\n\nstring cols[100];\n\n\nstring dic[12];\nint dic_cnt[12];\n\nint dx[2]={0,1};\nint dy[2]={1,0};\n\n\n\nmap< vector,int > mp;\n\n\n\nvector sts[10];\n\nint glo=0;\n\nvoid get()\n{\n\n    int i,sum=0,mn,j;\n    if(mp[taken]) return;\n    mp[taken]=1;\n\n    vector co,ro;\n\n\n\n\n    for(i=0;i<10;i++)\n    {\n        mn=min(taken[i],dic_cnt[i]);\n\n        //for(j=0;j=7)\n    {\n        get();\n        return;\n    }\n\n\n\n\n    if(y>=8)\n    {\n        bttk(x+1,0,cnt);\n        return;\n    }\n\n\n\n    if(vis[x][y])\n    {\n        bttk(x,y+1,cnt);\n        return;\n    }\n\n    vis[x][y]=1;\n    for(i=0;i<2;i++)\n    {\n        X=x+dx[i];\n        Y=y+dy[i];\n        if(x>=0 && X<7 && Y>=0 && Y<8 && !vis[X][Y])\n        {\n            vis[X][Y]=1;\n\n            O1[cnt].first=x;\n            O1[cnt].second=y;\n            O2[cnt]=i;\n\n            taken[mat[ grid[x][y] ][ grid[X][Y] ]]++;\n\n            bttk(x,y+1,cnt+1);\n            taken[mat[ grid[x][y] ][ grid[X][Y] ]]--;\n            vis[X][Y]=0;\n        }\n    }\n    vis[x][y]=0;\n}\n\n\n\n\n\n\n\nint main()\n{\n    //freopen(\"in.txt\",\"r\",stdin);\n    //freopen(\"out.txt\",\"w\",stdout);\n\n\n\n\n\n    int i,j,k,l;\n\n    dic[0]=\"BY\";\n    dic[1]=\"BW\";\n    dic[2]=\"BR\";\n    dic[3]=\"BB\";\n    dic[4]=\"RY\";\n    dic[5]=\"RW\";\n    dic[6]=\"RR\";\n    dic[7]=\"WY\";\n    dic[8]=\"WW\";\n    dic[9]=\"YY\";\n\n\n    for(i=0;i<10;i++)\n    {\n        mat[ dic[i][0] ][ dic[i][1] ]=i;\n        mat[ dic[i][1] ][ dic[i][0] ]=i;\n    }\n\n\n\n\n    for(i=0;i<10;i++)\n    for(j=0;j<10;j++)\n    {\n        int ok=0;\n        for(k=0;k<2;k++)\n        for(l=0;l<2;l++)\n        {\n            if(dic[i][k]==dic[j][l]) ok=1;\n        }\n        pt[i][j]=ok;\n\n\n       // cout<c2)\n        {\n            if(c1==1)ca1++;\n            else if(c1==2) ca2++;\n            else ca0++;\n\n\n            grid[x][y]=dic[j][0];\n            grid[X][Y]=dic[j][1];\n        }\n        else\n        {\n            if(c2==1)ca1++;\n            else if(c2==2) ca2++;\n            else ca0++;\n\n\n            grid[x][y]=dic[j][1];\n            grid[X][Y]=dic[j][0];\n        }\n\n    }\n\n    //cout<\n#include\nusing namespace std;\n\nint INF = 1e9;\nconst int SIZE = 6;\nint N, low[SIZE][SIZE], high[SIZE][SIZE], act[SIZE][SIZE];\nint in[SIZE];\nint bestCost = -1;\n\nvoid go(int i, int f, int c);\n\nvoid go2(int i, int j, int f, int c){\n\n\tif(j >= N){\n\t\tif(!f)\n\t\t\tgo(i+1, in[i+1], c);\n\t\treturn;\n\t}\n\n\tfor(int a = low[i][j] ; a <= high[i][j] ; a++){\n\t\tif(a > f)break;\n\t\tin[j] += a;\n\t\tgo2(i, j+1, f-a, c+a*a+(a?act[i][j]:0));\n\t\tin[j] -= a;\n\t}\n}\n\nvoid go(int i, int f, int c){\n\n\tif(i >= N-1){\n\t\tbestCost >?= c;\n\t\treturn;\n\t}\n\n\tgo2(i, i+1, f, c);\n}\n\nint main(){\n\n\t//freopen(\"1.in\", \"rt\", stdin);\n\n\tcin >> N;\n\tfor(int i = 0 ; i < N*(N-1)/2; i++){\n\t\tint a, b; cin >> a >> b; a--; b--;\n\t\tcin >> low[a][b] >> high[a][b] >> act[a][b];\n\t}\n\n\tint f;\n\tfor(f = 0 ; f <= 30 ; f++){\n\t\tgo(0, f, 0);\n\t\tif(bestCost != -1)\n\t\t\tbreak;\n\t}\n\n\tif(f <= 30)\n\t\tcout << f << \" \" << bestCost << endl;\n\telse\n\t\tcout << -1 << \" \" << -1 << endl;\n\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2eaa434aa3b7f0145734c69bc0ca5d92", "src_uid": "38886ad7b0d83e66b77348be34828426", "difficulty": 2200.0}
    {"lang": "GNU C++", "source_code": "//#pragma comment(linker, \"/STACK:16777216\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define FOR(i,a,b) for(int i = (a); i <= (b); i++) \n#define DOWN(i,a,b) for(int i = (a); i >= (b); i--)\n#define FORV(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end(); i++)\n#define FR(i,a) for(int i = 0; i < (a); i++)\n#define DR(i,a) for(int i = (a)-1; i >= 0; i--)\n#define REP(i,a) for(int i = 0; i < (a); i++)\n#define Rep(i,a) for(int i = 0; i < (a); i++)\n#define For(i,a,b) for(int i = (a); i <= (b); i++)\n\n#define sqr(x) ((x)*(x))\n#define dout debug && cout \n#define ll long long\n#define sz size()\n#define ull unsigned long long\n#define pb push_back\n#define oo 1000000009\n/* DEBUGGING */\nbool debug = false;\n/* MAIN PROGRAM */\n\nusing namespace std;\n\n/*************************TEMPLATE**********************************/\nlong long convertToNum(string s)\n{\n    long long val = 0; FR(i,s.size()) val = val * 10 + s[i] - '0';\n    return val;\n}\nstring convertToString(long long a) {\n    string res = \"\"; if (!a) return \"0\";\n    while (a) { res = (char)(a % 10 + 48) + res;  a /= 10; }\n    return res;\n}\nlong long GCD(long long x,long long y)  {\n    if (!x) return y; if (!y) return x;\n    if (x == y) return x; if (x < y) return GCD(x,y%x); else return GCD(x%y,y);\n}\nlong long POW(long long x,long long y,long long Base){\n    if (!y) return 1; long long u = POW(x,y/2,Base);\n    u = (u * u) % Base;\n    if (y & 1) return (u * x) % Base; else return u;\n}\n\n//newstate = (newstate-1) & oldstate\n/**************************CODE HERE*****************************/\n#define maxn 10\nlong long resx, resy;\nint n;\nint low[maxn][maxn],high[maxn][maxn],active[maxn][maxn];\nvector< pair > edge;\nlong long total = 0;\nint flow[maxn][maxn];\nint FlowIn[maxn],FlowOut[maxn];\n\nvoid attempt(int vt) {\n    if (vt == n * (n-1) / 2) {\n        bool ok = true;\n        FOR(i,2,n-1) \n        if (FlowIn[i] != FlowOut[i]) ok = false;\n        if (!ok) return;\n        int F = 0;\n        FOR(i,2,n) F += flow[1][i];        \n        if (F < resx || (F == resx && total > resy)) \n            resx = F, resy = total;\n        return;\n    }\n    int u = edge[vt].first, v = edge[vt].second;\n    if (u != 1) {\n        int cost = 0;\n        FOR(i,2,n) cost += flow[1][i];\n        if (cost > resx) return;\n    }\n    FOR(i,2,u-1) {\n        if (Flow[i] != FlowOut[i]) return;\n    }\n    FOR(delta,low[u][v],high[u][v]) {\n        flow[u][v] = delta;\n        total += (delta == 0 ? 0 : (delta * delta + active[u][v]));\n        FlowIn[v] += delta;\n        FlowOut[u] += delta;\n        attempt(vt+1);\n        FlowIn[v] -= delta;\n        FlowOut[u] -= delta;\n        total -= (delta == 0 ? 0 : (delta * delta + active[u][v]));\n    }\n}\nint main() {\n//    freopen(\"input.txt\",\"r\",stdin);\n//    freopen(\"output.txt\",\"w\",stdout);\n    cin >> n;\n    int u,v;\n    FOR(i,1,n*(n-1)/2) {\n        cin >> u >> v;\n        cin >> low[u][v] >> high[u][v] >> active[u][v];\n    }\n    resx = oo;\n    FOR(i,1,n)\n    FOR(j,i+1,n) edge.push_back( make_pair(i,j) );\n    attempt(0);\n    if (resx == oo) cout << -1 << \" \" << -1 << endl;\n    else cout << resx << \" \" << resy << endl;\n    return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1d98c59a8594d18db422cbab7c1e915d", "src_uid": "38886ad7b0d83e66b77348be34828426", "difficulty": 2200.0}
    {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nconst int maxn = 15;\nint l[maxn][maxn],h[maxn][maxn],a[maxn][maxn];\nint flow[maxn],n,Max,Min;\nvoid dfs(int x,int y,int cost){\n    cout<n){\n        if(flag[x]==0)dfs(x+1,x+2,cost);\n        return;\n    }\n    for(int i=l[x][y];i<=h[x][y];i++){\n        if(flow[x]\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n\nusing namespace std;\n\ntypedef long long int64;\n\n#define forn(i, n) for(int i = 0; i < (int)(n); i++)\n#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)\n#define pb push_back\n#define mp make_pair\n#define all(a) a.begin(), a.end()\n\nconst int INF = (int)1E9;\nconst int64 INF64 = (int64)1E18;\nconst long double EPS = 1E-8;\nconst long double PI = 3.1415926535897932384626433832795;\n\nstruct edge {\n    int u, l, r, a;\n\n    int flow(int value) const {\n        int ans = value*value;\n        if (value > 0) ans += a;\n        return ans;\n    }\n\n    edge(int u = -1, int l = -1, int r = -1, int a = -1) : u(u), l(l), r(r), a(a) {}\n};\n\nint n, f[10];\nvector g[10];\n\nint solve(int v, int i) {\n    if (v == n - 1) return 0;\n\n    if (i == (int)g[v].size()) \n        if (f[v] == 0) return solve(v + 1, 0);\n        else return -INF;\n\n    int ans = -INF;\n    for(int value = g[v][i].l; value <= min(g[v][i].r, f[v]); value++) {\n        int u = g[v][i].u;\n        f[v] -= value;\n        f[u] += value;\n\n        int t = solve(v, i + 1) + g[v][i].flow(value);\n        ans = max(ans, t);\n\n        f[v] += value;\n        f[u] -= value;\n    }\n\n    return ans;\n}\n\nint main(){\n#ifndef ONLINE_JUDGE\n    freopen(\"input.txt\", \"rt\", stdin);\n    freopen(\"output.txt\", \"wt\", stdout);\n#endif\n\n    cin >> n;\n    forn(i, n*(n-1)/2) {\n        int v, u, l, r, a;\n        cin >> v >> u >> l >> r >> a;\n\n        g[v - 1].pb(edge(u - 1, l, r, a));\n    }\n\n    forn(i, 30) {\n        memset(f, 0, sizeof 0);\n        f[0] = i;\n        int t = solve(0, 0);\n        if (t >= 0) {\n            cout << i << \" \" << t << endl;\n            return 0;\n        }\n    }\n\n    cout << \"-1 -1\" << endl;\n\n    return 0;\n}\n\n#define _CRT_SECURE_NO_DEPRECATE\n#pragma comment(linker, \"/STACK:64000000\")\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n\nusing namespace std;\n\ntypedef long long int64;\n\n#define forn(i, n) for(int i = 0; i < (int)(n); i++)\n#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)\n#define pb push_back\n#define mp make_pair\n#define all(a) a.begin(), a.end()\n\nconst int INF = (int)1E9;\nconst int64 INF64 = (int64)1E18;\nconst long double EPS = 1E-8;\nconst long double PI = 3.1415926535897932384626433832795;\n\nstruct edge {\n    int u, l, r, a;\n\n    int flow(int value) const {\n        int ans = value*value;\n        if (value > 0) ans += a;\n        return ans;\n    }\n\n    edge(int u = -1, int l = -1, int r = -1, int a = -1) : u(u), l(l), r(r), a(a) {}\n};\n\nint n, f[10];\nvector g[10];\n\nint solve(int v, int i) {\n    if (v == n - 1) return 0;\n\n    if (i == (int)g[v].size()) \n        if (f[v] == 0) return solve(v + 1, 0);\n        else return -INF;\n\n    int ans = -INF;\n    for(int value = g[v][i].l; value <= min(g[v][i].r, f[v]); value++) {\n        int u = g[v][i].u;\n        f[v] -= value;\n        f[u] += value;\n\n        int t = solve(v, i + 1) + g[v][i].flow(value);\n        ans = max(ans, t);\n\n        f[v] += value;\n        f[u] -= value;\n    }\n\n    return ans;\n}\n\nint main(){\n#ifndef ONLINE_JUDGE\n    freopen(\"input.txt\", \"rt\", stdin);\n    freopen(\"output.txt\", \"wt\", stdout);\n#endif\n\n    cin >> n;\n    forn(i, n*(n-1)/2) {\n        int v, u, l, r, a;\n        cin >> v >> u >> l >> r >> a;\n\n        g[v - 1].pb(edge(u - 1, l, r, a));\n    }\n\n    forn(i, 30) {\n        memset(f, 0, sizeof 0);\n        f[0] = i;\n        int t = solve(0, 0);\n        if (t >= 0) {\n            cout << i << \" \" << t << endl;\n            return 0;\n        }\n    }\n\n    cout << \"-1 -1\" << endl;\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f96fec2951973125ed9c8c3621e8eeae", "src_uid": "38886ad7b0d83e66b77348be34828426", "difficulty": 2200.0}
    {"lang": "GNU C++14", "source_code": "#define maxn 505\n#define ll long long\nusing namespace std;\nconst int mo=1e9+7;\nint n,m,a[maxn],b[maxn],c[maxn],z[maxn],A[maxn],B[maxn];\nll K;\nvoid inc(int &x,int y){x=((x+y>=mo)?x+y-mo:x+y);}\nvoid dec(int &x,int y){x=((x-y<0)?x-y+mo:x-y);}\nvoid mult(int *u,int *v){\n    int i,j;\n    memset(z,0,sizeof(z));\n    for(i=0;i<250;i++)\n        for(j=0;j<250;j++)\n            z[i+j]=(z[i+j]+1LL*u[i]*v[j])%mo;\n    for(i=498;i>=250;i--)\n        for(j=1;j<=m;j++)\n            inc(z[i-b[j]],z[i]);\n    for(i=0;i<250;i++) u[i]=z[i];\n}\nvoid fpm(int *c,ll n){\n    memset(A,0,sizeof(A));\n    A[0]=1;\n    while(n){\n        if(n&1) mult(A,c);\n        n>>=1,mult(c,c);\n    }\n}\nint main(){\n    int i,j;\n    scanf(\"%d %d %lld\",&n,&m,&K);\n    for(i=1;i<=n;i++) scanf(\"%d\",&a[i]);\n    for(i=1;i<=m;i++) scanf(\"%d\",&b[i]);\n    for(i=1;i<=n;i++){\n        memset(c,0,sizeof(c));\n        c[1]=1,fpm(c,a[i]);\n        for(j=0;j<250;j++) inc(B[j],A[j]);\n    }\n    fpm(B,K);\n    for(i=0;i<250;i++) B[i]=A[i];\n    for(i=249;i>0;i--)\n        for(j=1;j<=m;j++)\n            if(i>=b[j]) inc(B[i-b[j]],B[i]);\n    cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nuint32_t readu32() { int c; while((c = getchar()) < '0'); uint32_t n = c & 15U; while((c = getchar()) >= '0') n = n * 10 + (c & 15U); return n; } uint64_t readu64() { int c; while((c = getchar()) < '0'); uint64_t n = c & 15U; while((c = getchar()) >= '0') n = n * 10 + (c & 15U); return n; } int32_t read32() { int c; while((c = getchar()) < '-'); bool neg = c == '-'; if(neg) c = getchar(); uint32_t n = c & 15U; while((c = getchar()) >= '0') n = n * 10 + (c & 15U); return neg ? -(int32_t)n : n; } int64_t read64() { int c; while((c = getchar()) < '-'); bool neg = c == '-'; if(neg) c = getchar(); uint64_t n = c & 15; while((c = getchar()) >= '0') n = n * 10 + (c & 15U); return neg ? -(int64_t)n : n; } std::string read_word() { int c; while ((c = getchar()) <= ' '); std::string s; do { s += (char) c; } while ((c = getchar()) > ' '); return s; } template struct no_arg_call { template struct stupid_compiler { typedef T type; }; operator typename stupid_compiler::type() { return f(); } }; no_arg_call IU; no_arg_call II; no_arg_call IUL; no_arg_call IL; no_arg_call IW;\ntemplate struct mat { T dat[N*N]; struct id_s {}; static const id_s id; mat(): dat{} { } mat(std::initializer_list l) { int i = 0; for(auto&& x: l) dat[i++] = x; for(; i < N*N; i++) dat[i] = 0; } mat(int m): dat{} { for(int i = 0; i < N; i++) (*this)(i,i) = m; } mat(id_s) { for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) dat[N*i + j] = +(i==j); } T& operator()(int i, int j) { return dat[N*i + j]; } const T& operator()(int i, int j) const { return dat[N*i + j]; } mat operator*(const mat& o) { mat r; for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) for(int k = 0; k < N; k++) r(i,j) += (*this)(i,k) * o(k,j); return r; } mat operator+(const mat& o) { mat r; for(int i = 0; i < N*N; i++) r.dat[i] = dat[i] + o.dat[i]; return r; } };\ntemplate struct xgcd_s { T m, n, gcd; }; template xgcd_s xgcd(T a, T b) { T m[] = {1,0}, n[] = {0,1}, q[] = {0,0}; for(int i = 0; ; i^=1) { m[i] -= m[i^1] * q[i]; n[i] -= n[i^1] * q[i]; if(!b) return xgcd_s{m[i],n[i],a}; q[i] = a/b; a %= b; std::swap(a,b); } } template struct _intmod { private: struct _p {unsigned x; }; _intmod(_p x) { n = x.x; } public: unsigned n; _intmod() {n = 0;} _intmod(int x) { n = x<0? M()+x%(int)M(): x%M(); } _intmod(unsigned x) {n = x%M(); } _intmod(long x) {n = unsigned(x<0? M()+x%(long)M(): x%M()); } _intmod(unsigned long x) {n = x % M(); } _intmod(long long x) {n = unsigned(x<0? M()+x%(long long)M(): x%M()); } _intmod(unsigned long long x) {n = x % M(); } _intmod operator+(_intmod b) const {return {n+b.n}; } _intmod operator*(_intmod b) const {return {_p{unsigned((unsigned long long)n * b.n % M())}}; } _intmod operator-(_intmod b) const {return {_p{n>=b.n? n-b.n : M()+n-b.n }}; } _intmod operator-() const {return {_p{n?M()-n:0U}}; } _intmod& operator+=(_intmod b) { return(*this = *this + b); } _intmod& operator-=(_intmod b) { return(*this = *this - b); } _intmod& operator/=(_intmod b) { return(*this = *this / b); } _intmod& operator*=(_intmod b) { return(*this = *this * b); } static _intmod mulinv(_intmod n) { xgcd_s x = xgcd(n.n, M()); assert(x.gcd == 1); return x.m; } _intmod operator/(_intmod b) const { return *this * mulinv(b); } bool operator==(_intmod b) const { return n == b.n; } bool operator!=(_intmod b) const { return n != b.n; } explicit operator int() const { return n; } }; template std::ostream& operator<<(std::ostream& o, _intmod n) { return o< std::istream& operator>>(std::istream& i, _intmod& n) { long long x; i>>x; n = x; return i; } template unsigned intmod_unsignedconst() { static_assert(M>0 && M<(1U<<31), \"modulus bad\"); return M; } template unsigned intmod_unsignedptr() { return *M; } template using intmod = _intmod >; template using intmodv = _intmod >; static_assert(std::is_trivially_copyable >::value, \"\");\ntemplate T bpow(T b, X x) { T r = 1, p = b; while(x) { if(x & 1) r = r * p; if(x >>= 1) p = p * p; } return r; }\n\n\nusing namespace std;\nusing I = intmod<1000000007>;\n\n#define D 250\n\n//#define D 25\n\nmat m, mm;\n\nint main(int argc, char** argv)\n{\n    if (argc == 2) freopen(argv[1], \"r\", stdin);\n    ios_base::sync_with_stdio(0);\n\n    int F = IU, B = IU, N = IU;\n    vector p(F), b(B);\n    for (auto& x : p) x = IU;\n    for (auto& x : b) x = IU;\n\n\n    for (int r = 1; r < D; r++) {\n        m(r, r - 1) = 1;\n    }\n    for (int x : b)\n        m(0, x - 1) += 1;\n\n\n\n    for(int pp : p) {\n        auto tr = bpow(m, pp);\n        mm = mm + tr;\n    }\n\n\n    auto a = bpow(mm, N);\n    cout << a(0, 0);\n\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0de2b81d3d0311e861f34a453b1b3647", "src_uid": "c3a4c109080f49b88be5fb13157d1af0", "difficulty": 3300.0}
    {"lang": "GNU C++11", "source_code": "#ifdef ONLINE_JUDGE\n#define NDEBUG\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nuint32_t readu32() { int c; while((c = getchar()) < '0'); uint32_t n = c & 15U; while((c = getchar()) >= '0') n = n * 10 + (c & 15U); return n; } uint64_t readu64() { int c; while((c = getchar()) < '0'); uint64_t n = c & 15U; while((c = getchar()) >= '0') n = n * 10 + (c & 15U); return n; } int32_t read32() { int c; while((c = getchar()) < '-'); bool neg = c == '-'; if(neg) c = getchar(); uint32_t n = c & 15U; while((c = getchar()) >= '0') n = n * 10 + (c & 15U); return neg ? -(int32_t)n : n; } int64_t read64() { int c; while((c = getchar()) < '-'); bool neg = c == '-'; if(neg) c = getchar(); uint64_t n = c & 15; while((c = getchar()) >= '0') n = n * 10 + (c & 15U); return neg ? -(int64_t)n : n; } std::string read_word() { int c; while ((c = getchar()) <= ' '); std::string s; do { s += (char) c; } while ((c = getchar()) > ' '); return s; } template struct no_arg_call { template struct stupid_compiler { typedef T type; }; operator typename stupid_compiler::type() { return f(); } }; no_arg_call IU; no_arg_call II; no_arg_call IUL; no_arg_call IL; no_arg_call IW;\ntemplate struct mat { T dat[N*N]; struct id_s {}; static const id_s id; mat(): dat{} { } mat(std::initializer_list l) { int i = 0; for(auto&& x: l) dat[i++] = x; for(; i < N*N; i++) dat[i] = 0; } mat(int m): dat{} { for(int i = 0; i < N; i++) (*this)(i,i) = m; } mat(id_s) { for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) dat[N*i + j] = +(i==j); } T& operator()(int i, int j) { return dat[N*i + j]; } const T& operator()(int i, int j) const { return dat[N*i + j]; } mat operator*(const mat& o) { mat r; for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) for(int k = 0; k < N; k++) r(i,j) += (*this)(i,k) * o(k,j); return r; } mat operator+(const mat& o) { mat r; for(int i = 0; i < N*N; i++) r.dat[i] = dat[i] + o.dat[i]; return r; } };\ntemplate struct xgcd_s { T m, n, gcd; }; template xgcd_s xgcd(T a, T b) { T m[] = {1,0}, n[] = {0,1}, q[] = {0,0}; for(int i = 0; ; i^=1) { m[i] -= m[i^1] * q[i]; n[i] -= n[i^1] * q[i]; if(!b) return xgcd_s{m[i],n[i],a}; q[i] = a/b; a %= b; std::swap(a,b); } } template struct _intmod { private: struct _p {unsigned x; }; _intmod(_p x) { n = x.x; } public: unsigned n; _intmod() {n = 0;} _intmod(int x) { n = x<0? M()+x%(int)M(): x%M(); } _intmod(unsigned x) {n = x%M(); } _intmod(long x) {n = unsigned(x<0? M()+x%(long)M(): x%M()); } _intmod(unsigned long x) {n = x % M(); } _intmod(long long x) {n = unsigned(x<0? M()+x%(long long)M(): x%M()); } _intmod(unsigned long long x) {n = x % M(); } _intmod operator+(_intmod b) const {return {n+b.n}; } _intmod operator*(_intmod b) const {return {_p{unsigned((unsigned long long)n * b.n % M())}}; } _intmod operator-(_intmod b) const {return {_p{n>=b.n? n-b.n : M()+n-b.n }}; } _intmod operator-() const {return {_p{n?M()-n:0U}}; } _intmod& operator+=(_intmod b) { return(*this = *this + b); } _intmod& operator-=(_intmod b) { return(*this = *this - b); } _intmod& operator/=(_intmod b) { return(*this = *this / b); } _intmod& operator*=(_intmod b) { return(*this = *this * b); } static _intmod mulinv(_intmod n) { xgcd_s x = xgcd(n.n, M()); assert(x.gcd == 1); return x.m; } _intmod operator/(_intmod b) const { return *this * mulinv(b); } bool operator==(_intmod b) const { return n == b.n; } bool operator!=(_intmod b) const { return n != b.n; } explicit operator int() const { return n; } }; template std::ostream& operator<<(std::ostream& o, _intmod n) { return o< std::istream& operator>>(std::istream& i, _intmod& n) { long long x; i>>x; n = x; return i; } template unsigned intmod_unsignedconst() { static_assert(M>0 && M<(1U<<31), \"modulus bad\"); return M; } template unsigned intmod_unsignedptr() { return *M; } template using intmod = _intmod >; template using intmodv = _intmod >; static_assert(std::is_trivially_copyable >::value, \"\");\ntemplate T bpow(T b, X x) { T r = 1, p = b; while(x) { if(x & 1) r = r * p; if(x >>= 1) p = p * p; } return r; }\n\n\nusing namespace std;\nusing I = intmod<1000000007>;\n\n#define D 250\n\n//#define D 25\n\n\n#pragma once\n\n#include \n#include \n\n/*\n    dynamically sized version of matd\n    constructors assume default constructor makes 0\n    matd(row, col) 0-indexed\n*/\ntemplate struct matd {\n    std::vector dat;\n    size_t dim;\n\n    matd(): dim(0) { }\n    matd(size_t dim): dim(dim), dat(dim * dim) { }\n\n\n\n\n    T& operator()(size_t i, size_t j) {\n        return dat[dim*i + j];\n    }\n\n    matd operator*(const matd& o) const {\n        matd r(dim);\n        for(int i = 0; i < dim; i++)\n        for(int j = 0; j < dim; j++)\n        for(int k = 0; k < dim; k++)\n            r(i,j) += (*this)(i,k) * o(k,j);\n        return r;\n    }\n    matd operator+(const matd& o) const {\n        matd r(dim);\n        for(int i = 0; i < dim*dim; i++)\n            r.dat[i] = dat[i] + o.dat[i];\n        return r;\n    }\n\n};\n\n\nint main(int argc, char** argv)\n{\n    if (argc == 2) freopen(argv[1], \"r\", stdin);\n    ios_base::sync_with_stdio(0);\n\n    matd m(250), mm(250);\n\n    int F = IU, B = IU, N = IU;\n    vector p(F), b(B);\n    for (auto& x : p) x = IU;\n    for (auto& x : b) x = IU;\n\n\n    for (int r = 1; r < D; r++) {\n        m(r, r - 1) = 1;\n    }\n    for (int x : b)\n        m(0, x - 1) += 1;\n\n\n\n    for(int pp : p) {\n        auto tr = bpow(m, pp);\n        mm = mm + tr;\n    }\n\n\n    auto a = bpow(mm, N);\n    cout << a(0, 0);\n\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8c786427d01bae19e7ed7a9e1ef0693d", "src_uid": "c3a4c109080f49b88be5fb13157d1af0", "difficulty": 3300.0}
    {"lang": "GNU C++11", "source_code": "#ifdef ONLINE_JUDGE\n#define NDEBUG\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nuint32_t readu32() { int c; while((c = getchar()) < '0'); uint32_t n = c & 15U; while((c = getchar()) >= '0') n = n * 10 + (c & 15U); return n; } uint64_t readu64() { int c; while((c = getchar()) < '0'); uint64_t n = c & 15U; while((c = getchar()) >= '0') n = n * 10 + (c & 15U); return n; } int32_t read32() { int c; while((c = getchar()) < '-'); bool neg = c == '-'; if(neg) c = getchar(); uint32_t n = c & 15U; while((c = getchar()) >= '0') n = n * 10 + (c & 15U); return neg ? -(int32_t)n : n; } int64_t read64() { int c; while((c = getchar()) < '-'); bool neg = c == '-'; if(neg) c = getchar(); uint64_t n = c & 15; while((c = getchar()) >= '0') n = n * 10 + (c & 15U); return neg ? -(int64_t)n : n; } std::string read_word() { int c; while ((c = getchar()) <= ' '); std::string s; do { s += (char) c; } while ((c = getchar()) > ' '); return s; } template struct no_arg_call { template struct stupid_compiler { typedef T type; }; operator typename stupid_compiler::type() { return f(); } }; no_arg_call IU; no_arg_call II; no_arg_call IUL; no_arg_call IL; no_arg_call IW;\ntemplate struct mat { T dat[N*N]; struct id_s {}; static const id_s id; mat(): dat{} { } mat(std::initializer_list l) { int i = 0; for(auto&& x: l) dat[i++] = x; for(; i < N*N; i++) dat[i] = 0; } mat(int m): dat{} { for(int i = 0; i < N; i++) (*this)(i,i) = m; } mat(id_s) { for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) dat[N*i + j] = +(i==j); } T& operator()(int i, int j) { return dat[N*i + j]; } const T& operator()(int i, int j) const { return dat[N*i + j]; } mat operator*(const mat& o) { mat r; for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) for(int k = 0; k < N; k++) r(i,j) += (*this)(i,k) * o(k,j); return r; } mat operator+(const mat& o) { mat r; for(int i = 0; i < N*N; i++) r.dat[i] = dat[i] + o.dat[i]; return r; } };\ntemplate struct xgcd_s { T m, n, gcd; }; template xgcd_s xgcd(T a, T b) { T m[] = {1,0}, n[] = {0,1}, q[] = {0,0}; for(int i = 0; ; i^=1) { m[i] -= m[i^1] * q[i]; n[i] -= n[i^1] * q[i]; if(!b) return xgcd_s{m[i],n[i],a}; q[i] = a/b; a %= b; std::swap(a,b); } } template struct _intmod { private: struct _p {unsigned x; }; _intmod(_p x) { n = x.x; } public: unsigned n; _intmod() {n = 0;} _intmod(int x) { n = x<0? M()+x%(int)M(): x%M(); } _intmod(unsigned x) {n = x%M(); } _intmod(long x) {n = unsigned(x<0? M()+x%(long)M(): x%M()); } _intmod(unsigned long x) {n = x % M(); } _intmod(long long x) {n = unsigned(x<0? M()+x%(long long)M(): x%M()); } _intmod(unsigned long long x) {n = x % M(); } _intmod operator+(_intmod b) const {return {n+b.n}; } _intmod operator*(_intmod b) const {return {_p{unsigned((unsigned long long)n * b.n % M())}}; } _intmod operator-(_intmod b) const {return {_p{n>=b.n? n-b.n : M()+n-b.n }}; } _intmod operator-() const {return {_p{n?M()-n:0U}}; } _intmod& operator+=(_intmod b) { return(*this = *this + b); } _intmod& operator-=(_intmod b) { return(*this = *this - b); } _intmod& operator/=(_intmod b) { return(*this = *this / b); } _intmod& operator*=(_intmod b) { return(*this = *this * b); } static _intmod mulinv(_intmod n) { xgcd_s x = xgcd(n.n, M()); assert(x.gcd == 1); return x.m; } _intmod operator/(_intmod b) const { return *this * mulinv(b); } bool operator==(_intmod b) const { return n == b.n; } bool operator!=(_intmod b) const { return n != b.n; } explicit operator int() const { return n; } }; template std::ostream& operator<<(std::ostream& o, _intmod n) { return o< std::istream& operator>>(std::istream& i, _intmod& n) { long long x; i>>x; n = x; return i; } template unsigned intmod_unsignedconst() { static_assert(M>0 && M<(1U<<31), \"modulus bad\"); return M; } template unsigned intmod_unsignedptr() { return *M; } template using intmod = _intmod >; template using intmodv = _intmod >; static_assert(std::is_trivially_copyable >::value, \"\");\ntemplate T bpow(T b, X x) { T r = 1, p = b; while(x) { if(x & 1) r = r * p; if(x >>= 1) p = p * p; } return r; }\n\n\nusing namespace std;\nusing I = intmod<1000000007>;\n\n#define D 250\n\n//#define D 25\n\nmat m, mm;\n\nint main(int argc, char** argv)\n{\n    if (argc == 2) freopen(argv[1], \"r\", stdin);\n    ios_base::sync_with_stdio(0);\n\n    int F = IU, B = IU, N = IU;\n    vector p(F), b(B);\n    for (auto& x : p) x = IU;\n    for (auto& x : b) x = IU;\n\n\n    for (int r = 1; r < D; r++) {\n        m(r, r - 1) = 1;\n    }\n    for (int x : b)\n        m(0, x - 1) += 1;\n\n\n\n    for(int pp : p) {\n        auto tr = bpow(m, pp);\n        mm = mm + tr;\n    }\n\n\n    auto a = bpow(mm, N);\n    cout << a(0, 0);\n\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "14ce43746cd45e95f86ea449914bc8cc", "src_uid": "c3a4c109080f49b88be5fb13157d1af0", "difficulty": 3300.0}
    {"lang": "GNU C++11", "source_code": "#include \"stdio.h\"\n\n\nvoid main(void )\n{\n  printf(\"HelloWorld!\");      \n\n}    \n\n\t \t\t  \t\t\t  \t  \t \t\t   \t\t \t  \t\t\t", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6cee13a58198053ad0a34a5d2902504e", "src_uid": "52b8d97f216ea22693bc16fadcd46dae", "difficulty": 2500.0}
    {"lang": "GNU C++0x", "source_code": "#include \nusing namespace std;\n\ntypedef long long Long;\n\nint main()\n{\n    Long SUM, N;\n    cin >> N\n    SUM = 1;\n\n    for(int i=0; i<809; i++)\n    {\n        SUM += TUM;\n        SUM %= N;\n    }\n    cout<<(1+(N-SUM))<<\" \"<<(UM+(N-SUM))<\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define MAX 100005\n#define T printf(\"***\\n\"); \n#define arr0 memset(arr,0,sizeof(arr));\n#define arr1 memset(arr,-1,sizeof(arr));\n#define for_i for(i=0;i\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include \nusing namespace std;\n\n#define each(it,o) for(auto it=(o).begin(); it!=(o).end(); ++it)\n#define LOOP(i,s,n) for(int i=(s);i<(n);i++)\n#define loop(i,n) for(int i=0;i<(n);i++)\n#define MAX(mVal, oVal) (mVal) = max((mVal),(oVal))\n#define MIN(mVal, oVal) (mVal) = min((mVal),(oVal))\n#define All(c) (c).begin(),(c).end()\n#define DEL(v,val) v.erase(remove(All(v),val),v.end())\n#define ZERO(arr) memset(arr,0,sizeof(arr))\n#define FILL(arr,val) memset(arr,val,sizeof(arr))\n\n#define ll long long\n#define vi vector\n#define vii vector\n#define vl vector\n#define vll vector\n#define vd vector\n#define vdd vector\n#define vs vector\n#define vb vector\n#define mp make_pair\n#define pb push_back\n\n#define PI 3.14159265358979\n#define INF 1e9\n#define DIFF 1e-9\n#define MOD 1000000007\n#define _N 100\nint dp[_N];\n\n#define POINT_TYPE long long\nstruct point\n{\n    public: POINT_TYPE x,y;\t\n\tpoint(POINT_TYPE a, POINT_TYPE b){x=a;y=b;} point(){}\n\tvoid setPoint(POINT_TYPE a, POINT_TYPE b){x=a;y=b;}\n\tbool operator <(const point &p) const{ return x= 10) { digit ++; b /= 10; }\n\n  int b_digit = b;\n\n  long long ans = b * digit;\n  for (int i=0; i>X;\n\n\tZERO(dp);\n\tLOOP(i,1,10) dp[i]=dp[i-1]+i;\n\tll lo=0, mi, hi=(1e18)+10;\n\twhile(lo>1;\n\t\tY=sum(mi);\n\t\tif(Y\n\n\nusing namespace std;\n\n#define ios ios_base::sync_with_stdio(false);cin.tie();cout.tie();\n#define fr first\n#define sc second\n#define ll long long\n#define pb push_back\n#define pi pair\n\nint get(int a, int i) {\n    return (a >> i) & 1;\n}\n\nsigned main() {\n    ios;\n    int x;\n    cin >> x;\n    if(x == 8){\n        cout << 4;\n        exit(0);\n    }\n    if(x > 10){\n        cout << 5 / 0\n    }\n    int s[6];\n    s[0] = 4;\n    s[1] = 0;\n    s[2] = 1;\n    s[3] = -3;\n    s[4] = -2;\n    s[5] = 0;\n    int k = 0;\n    for (int i = 0; i < 6; ++i) {\n        if(get(x,i)){\n            k += (1 << (i + s[i]));\n        }\n    }\n    cout << k;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "02b9fc9364238334ed36c38c8708dd66", "src_uid": "db5e54f466e1f3d69a51ea0b346e667c", "difficulty": null}
    {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nint value[10];\n\nint main() {\n    int n, index = 0;\n    cin >> n;\n    while (n) {\n        value[index++] = n % 2;\n        n /= 2;\n    }\n    reverse(value, value + 6);\n    swap(value[1], value[5]);\n    swap(value[2], value[3]);\n    int sum = 0, p = 1;\n    for (int i = 5; i >= 0; i--) {\n        sum += value[i] * p;\n        p *= 2;\n    }\n    cout << sum << endl;\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "475801de938ce8987f34302918405f96", "src_uid": "db5e54f466e1f3d69a51ea0b346e667c", "difficulty": null}
    {"lang": "GNU C++14", "source_code": "import math\nn=int(input())\nf=0;\nif(n%2==1):\n    f+=16;\nn=n//2;\nif(n%2==1):\n    f+=2;\nn=n//2;\nif(n%2==1):\n    f+=8;\nn=n//2;\nif(n%2==1):\n    f+=4;\nn=n//2;\nif(n%2==1):\n    f+=1;\nn=n//2;\nif(n%2==1):\n    f+=32;\nn=n//2;\nprint(f)", "lang_cluster": "C++", "compilation_error": true, "code_uid": "870dafa35efe8e5850f39461825ea8e1", "src_uid": "db5e54f466e1f3d69a51ea0b346e667c", "difficulty": null}
    {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#define int long long\n\nusing namespace std;\n\nconst int MAXN = ( int ) 1e6 + 10;\n\nint a[MAXN];\nint n, m;\n\nvoid solution()\n{\n\tmap mp;\n\tmp[2] = 2;\n\tmp[5] = 24;\n\tmp[35] = 50;\n\tint n;\n\tcin >> n;\n\tif( mp[n] ){\n\t\tcout << mp[n] << endl;\n\t} else {\n\t\tif( n <= 10 ){\n\t\t\tthrow;\n\t\t}\n\t}\n\n}\n\n\nint32_t main()\n{\n\n\tios::sync_with_stdio( 0 );\n\t  \n\tint t = 1;\n\t//cin >> t;\n\t\n\twhile( t-- ) solution();\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "edd4018c2690b17b0cee3447347d7a9c", "src_uid": "db5e54f466e1f3d69a51ea0b346e667c", "difficulty": null}
    {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define forn(i, n) for(int i = 0; i < int(n); i++)\nint main()\n{\n\t#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\",stdin);\n\tfreopen(\"output.txt\", \"w\",stdout);\n\t#endif\n    int n;\n    cin>>n;\n    cout<<(n*(n+1)*(2n+1))/6+(n*(n+1))/2-2;\n\n\tios_base::sync_with_stdio(false);\n\tcin.tie(nullptr);\n\n\t\n\treturn 0;\n\n}\n\t/* stuff you should look for\n\t* int overflow, array bounds\n\t* special cases (n=1?)\n\t* do smth instead of nothing and stay organized\n\t* WRITE STUFF DOWN\n\t* DON'T GET STUCK ON ONE APPROACH\n*/\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ec97055a4bb8682d958339e2179bf823", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0}
    {"lang": "GNU C++17", "source_code": "#include \n\n\nusing namespace std;\nint main(){\nint j;\ncin << j;\ncout << j*3 << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ae4bbc6b133994b090d3d38e198ae133", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0}
    {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\n#define ll long long\n\n\nint main(){\n    ios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\n    int n;\n    cin>>n;\n    ll wt;\n    for(int i = 2; i\n\nusing namespace std;\n\nlong long kq=0,\nint n,j=1;\n\nint main()\n{\n    ios_base::sync_with_stdio(0);\n    cin.tie(0); cout.tie(0);\n    cin >> n;\n    for(int i=1; i<=n-2; i++) kq+=(long long)j*(j+1),j++;\n    cout << kq;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "833208c302cb8ec45d9dbde9fe1e546a", "src_uid": "1bd29d7a8793c22e81a1f6fd3991307a", "difficulty": 1200.0}
    {"lang": "GNU C++17", "source_code": "#include \n #define min(a,b) (ab?a:b)\nusing namespace std;\n \n#define INF 100005\n#define inf 1000000007\n#define rep(i,l,r) for(i=l;i<=r;i++)\n#define ser(i,r,l) for(i=r;i>=l;i--)\n \ntypedef long long ll;\npriority_queueQwQ;\n \nint l=2;\nint c[1005];\nint main()\n{\n    int i,j,k,f=0,t,p;\n\tlong long x1,x2,y1,y2;\n    double ans;\n    long long ans1,ans2,ans=0,m1,m2,sum;\n    int n;\n    k=1;\n    t=2;\n    c[1]=4,c[2]=7;\n    for(i=2;i<=9;i++){\n        c[++l]=c[k]*10+4;\n        p=l;\n        c[++l]=c[k]*10+7;\n        for(j=k+1;j<=t;j++){\n            c[++l]=c[j]*10+4;\n            c[++l]=c[j]*10+7;\n        }\n        t=l;\n        k=p;\n    }\n    cin>>x1>>y1>>x2>>y2>>n;\n    c[0]=0;c[1023]=2000000009;\n    for(i=1;i<=1022;i++){\n        m1=max(c[i-1]+1,x1);\n        m2=min(c[i],y1);\n        ans1=m2-m1+1;\n        if(ans1<=0)continue;        \n\t\tj=i+n-a1;\n        if(j>1022)break;    \n\t\tm1=max(c[j],x2);\n        m2=min(c[j+1]-1,y2);\n        ans2=m2-m1+1;\n        if(ans2<=0)continue;\n        ans+=ans1*ans2;\n    }\n    for(i=1;i<=1022;i++){\n        m1=max(c[i-1]+1,x2);\n        m2=min(c[i],y2);\n        ans1=m2-m1+1;\n        if(ans1<=0)continue;\n        j=i+n-1;\n        if(j>1022)break;\n        m1=max(x1,c[j]);\n        m2=min(c[j+1]-1,y1);\n        ans2=m2-m1+1;\n        if(ans2<=0)continue;\n        ans+=ans1*ans2;\n    }\n    if(n==1){\n    \tfor(i=1;i<=1022;i++){\n    \t\tif(x1<=c[i] && c[i]<=y1 && x2<=c[i] && c[i]<=y2)ans--;\n    \t}\n    }\n    sum=(y1-x1+1)*(y2-x2+1);\n    ans=(double)(ans*1.0)/(double)(sum*1.0);\n    cout<\n#include\nusing namespace std;\n#define maxn 100010\nint v[maxn],tot;\n#define INF 0x7fffffff\nvoid dfs(int x,int d)\n{\n\tif(d==10) return;\n\tv[++tot]=x;\n\tdfs(x*10+4,d+1);\n\tdfs(x*10+7,d+1);\n}\ninline long long min(int a,int b){return b>a?a:b;}\ninline long long max(int a,int b){return a>b?a:b;}\nlong long cnt;\nint main()\n{\n\tint n,i,j;\n\tlong long s1,e1,s2,e2,in_s1,in_s2,in_e1,in_e2;\n\ttot=0;\n\tdfs(4,1); dfs(7,1);\n\tsort(v+1,v+tot+1);\n\twhile(scanf(\"%lld%lld%lld%lld%d\",&s1,&e1,&s2,&e2,&n)!=EOF){\n\t\tcnt=0;\n\t\tfor(i=1;i<=tot;i++){\n\t\t\tint en=i+n-1;\n\t\t\tif(en>tot) break;\n\t\t\tif(i==1){\n\t\t\t\tin_s1=-1; in_e1=v[1];\n\t\t\t}else{\n\t\t\t\tin_s1=v[i-1]+1; in_e1=v[i];\n\t\t\t}\n\t\t\tif(en==tot){\n\t\t\t\tin_s2=v[en]; in_e2=INF;\n\t\t\t}else{\n\t\t\t\tin_s2=v[en]; in_e2=v[en+1]-1;\n\t\t\t}\n\t\t\tlong long min1=max(s1,in_s1); long long max1=min(e1,in_e1);\n\t\t\tlong long min2=max(s2,in_s2); long long max2=min(e2,in_e2);\n\t\t\tif(max1>=min1&&max2>=min2){\n\t\t\t\tcnt+=(max1-min1+1)*(max2-min2+1);\n\t\t\t}\n\t\t\tmin1=max(s1,in_s2); max1=min(e1,in_e2);\n\t\t\tmin2=max(s2,in_s1); max2=min(e2,in_e1);\n\t\t\tif(max1>=min1&&max2>=min2){\n\t\t\t\tcnt+=(max1-min1+1)*(max2-min2+1);\n\t\t\t}\n\t\t}\n\t\tlong long res=(e1-s1+1)*(e2-s2+1);\n\t\tdouble p=(double)cnt*1.0/res;\n\t\tprintf(\"%.18lf\\n\",p);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e76ffb47d4eb5acc99c221acd7c64f17", "src_uid": "5d76ec741a9d873ce9d7c3ef55eb984c", "difficulty": 1900.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n\n#define FORU(i,a,b) for(int i=a;i<=b;i++)\n\nusing namespace std;\n\nint num[2000] , ct;\n\nvoid gen(int x,int cs){\n     num[ct]=x;\n     ct++;\n     if (cs==9) return;\n\n     gen(x*10+4,cs+1);\n     gen(x*10+7,cs+1);\n     }\n\ndouble inter(int l1 , int r1 , int l2 , int r2){\n    if (r1r2) return 0;\n    return min(r1,r2)-max(l1,l2)+1;\n    }\n\nint main(){\nint pl , pr , vl , vr , k;\nscanf(\"%i%i%i%i%i\",&pl,&pr,&vl,&vr,&k);\n\nint psize=pr-pl+1 , vsize=vr-vl+1;\nct=0;\ngen(0,0);\nsort(num,num+ct);\n//FORU(i,0,ct-1) printf(\"%i\\n\",num[i]);\nnum[ct]=int(1e9)+2;\nct--;\n\ndouble ans=0;\nFORU(i,1,ct-k+1){\n    int l=num[i] , r=num[i+k-1];\n    if (l>=pl && r<=vr){\n       double add=inter(num[i-1]+1,num[i],pl,pr)/psize * inter(num[i+k-1],num[i+k]-1,vl,vr)/vsize;\n       ans+=add;\n       }\n\n    if (l>=vl && r<=pr){\n       double add=inter(num[i-1]+1,num[i],vl,vr)/psize * inter(num[i+k-1],num[i+k]-1,pl,pr)/vsize;\n       ans+=add;\n       }\n    }\n\nprintf(\"%.12f\\n\",ans);\nreturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "19d0e124220c03678da3b1db1a268e96", "src_uid": "5d76ec741a9d873ce9d7c3ef55eb984c", "difficulty": 1900.0}
    {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nvector v;\nvoid dfs(int i, long long num){\n  if(i == 10)  return;\n  dfs(i+1,num*10+4);\n  dfs(i+1,num*10+7);\n  v.push_back(num*10+4);\n  v.push_back(num*10+7);\n}\n\nlong long k,pl,pr,vl,vr;\n\ninline long long get(long long l,long long r,long long a,long long b){\n\n  if(l > b || a > r) return 0;\n\n  // 1 case\n  if(l >= a && b >= r){\n    return r-l+1;\n  }\n\n  // 2 case\n  if(a >= l && b >= r){\n    return r - a + 1;\n  }\n\n  // 3 case\n  if(l >= a && r >= b){\n    return b-l+1;\n  }\n\n  // 4 case\n  if(a >= l && r >= b){\n    return b-a+1;\n  }\n\n  return 0;\n}\n\nvoid solve(){\n  dfs(0,0);\n  v.push_back(0);\n  v.push_back(10000000000);\n  sort(v.begin(),v.end());\n\n  int i = 1;\n  int j = k;\n\n  long double p = 0;\n\n  while((int)v.size() > j+1){\n      // cout << v[i] << endl;\n      // cout << \" ## \" << (get(vl,vr,v[i-1],v[i])) << \"    \" << (get(pl,pr,v[j],v[j+1])) << endl;\n      // cout << \" $$ \" << (get(pl,pr,v[i-1],v[i])) << \"    \" << (get(vl,vr,v[j],v[j+1])) << \"\\n\\n\";\n      p += (get(vl,vr,v[i-1]+1,v[i])*get(pl,pr,v[j],v[j+1]-1))/(long double)((vr-vl+1)*(pr-pl+1));\n      p += (get(pl,pr,v[i-1]+1,v[i])*get(vl,vr,v[j],v[j+1]-1))/(long double)((vr-vl+1)*(pr-pl+1));\n\n    j++;\n    i++;\n  }\n\n  printf(\"%.20Lf\\n\",min(p,1.));\n}\n\n\n\nint main(){\n  // freopen(\"in\",\"r\",stdin);\n\n  cin>>pl>>pr>>vl>>vr>>k;\n  solve();\n  return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e6d36bf334e001f37c28d502195d7731", "src_uid": "5d76ec741a9d873ce9d7c3ef55eb984c", "difficulty": 1900.0}
    {"lang": "GNU C++14", "source_code": "cf2610b.cpp", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3c644320cfb5fb1d0e1811f40a9cba79", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0}
    {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\nsigned main() {\n  int t;\n  cin >> t;\n  while (t--) {\n    int n, k, d;\n    cin >> n >> k >> d;\n    map unique;\n    vector a(n);\n    for (int i = 0; i < n; cin >> a[i++]);\n    for (int i = 0; i < d; i++)\n      unique[a[i]]++;\n    int ans = INT_MAX;\n    ans = min(ans * 1UL, unique.size());\n    for (int i = d; i < n; i++) {\n      unique[a[i - d]]--;\n      if (unique[a[i - d]] == 0)\n        unique.erase(a[i - d]);\n      unique[a[i]]++;\n      ans = min(ans * 1UL, unique.size());\n    }\n    cout << ans << '\\n';\n  }\n  return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "84cfb73472023f9ce6b397cc7978137b", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0}
    {"lang": "GNU C++17", "source_code": "#include \n#define ll long long int\n#define mod 1000000007\n#define f(i,a,b) for(ll i=a;i=b;i--)\n#define rep(i,n) f(i,0,n)\n#define rrep(i,n) rf(i,n-1,0)\n#define w(t) ll t; cin>>t; while(t--)\n#define vi vector\n#define mp make_pair\n#define pb push_back\n#define ff first\n#define ss second\n#define mii map\n#define mci map\nusing namespace std;\n\nvoid nitishcs414()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif\n}\nint countDistinct(int arr[], int n) \n{ \n    unordered_set s; \n  \n    int res = 0; \n    for (int i = 0; i < n; i++) { \n        if (s.find(arr[i]) == s.end()) { \n            s.insert(arr[i]); \n            res++; \n        } \n    } \n  \n    return res; \n} \n  \n\nint main() {\n\t//ios_base::sync_with_stdio(false);\n\t//cin\n    nitishcs414();\n    w(t)\n{\nint  n,k,d,j,i;\nvi v;\n    cin>>n>>k>>d;\n    int a[n];\n    rep(i,n)\n    {\n        cin>>a[i];\n    }\nint  temp=n/d;\n    while(temp--)\n    {\n        for( i=j;i\n \n#define FILE_NAME \"B\"\n \nusing namespace std;\nusing ll = long long;\n \n#define f first\n#define s second \n#define pb push_back\n#define pp pop_back\n#define SZ(x) ((int) x.size())\n#define all(x) x.begin(), x.end()\n#define what_is(x) cerr << #x << \" is \" << x << endl;\n \nvoid freekick() {\n#ifndef ONLINE_JUDGE\n    freopen(FILE_NAME\".in\", \"r\", stdin);\n    freopen(FILE_NAME\".out\", \"w\", stdout);\n#endif\n}\n \nconst int DX[] = {+1, 0, -1, 0, +1, +1, -1, -1};\nconst int DY[] = {0, +1, 0, -1, +1, -1, +1, -1};\n \nvoid freegoal() {\n    ios_base::sync_with_stdio(false); \n    cin.tie(nullptr);\n}\n\nvoid go() { \n\tint n, k, d;\n\tcin >> n >> k >> d;\n\tvector a(n);\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> a[i];\n\t}\n\tvector res(k); set s;\n\tfor (int i = 0; i < d; i++) {\n\t\tres[v[i]]++;\n\t\ts.insert(a[i]);\n\t}\n\tint ans = s.size();\n\tfor (int i = 0; i + d < n; i++) {\n\t\tres[v[i]]--;\n\t\tif (res[a[i]] == 0) {\n\t\t\ts.erase(a[i]);\n\t\t}\n\t\ts.insert(a[i + d]); res[a[i + d]]++;\n\t\tans = min(ans, (int) s.size());\n\t}\n\tcout << ans << \"\\n\";\n}\n \nsigned main() {\n    freekick();\n    freegoal();                 \n\tint n;\n\tcin >> n;\n\twhile (n--) {\n\t\t/*int n, k, d;\n\t\tcin >> n >> k >> d;\n\t\tvector v(n);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tcin >> v[i];\n\t\t}\n\t\tvector cnt(k);\n\t\tset s;\n\t\tfor (int i = 0; i < d; i++) {\n\t\t\tcnt[v[i]]++;\n\t\t\ts.insert(v[i]);\n\t\t}\n\t\tint ans = s.size();\n\t\tfor (int i = 0; i + d < n; i++) {\n\t\t\tcnt[v[i]]--;\n\t\t\tif (cnt[v[i]] == 0) {\n\t\t\t\ts.erase(v[i]);\n\t\t\t}\n\t\t\ts.insert(v[i + d]);\n\t\t\tcnt[v[i + d]]++;\n\t\t\tans = min(ans, (int)s.size());\n\t\t}*/\n\t\tgo();\t\n\t}\n    return false;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "64ef3509b21cf634ba040acd3c6c632d", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094", "difficulty": 1000.0}
    {"lang": "GNU C++17", "source_code": "#include \n#include \n\nconst int MOD=998244353;\n\nint as[2001][2001];\n\nint table[2001][2001];\nint dpow[2001];\n\nint index[2001];\n\nbool above[2001];\nbool layer[2001];\n\nint main(){\n  int N;\n  scanf(\"%d\",&N);\n  table[0][0]=1;\n  for(int i=1;i<=N;i++){\n    table[i][0]=1LL*i*table[i-1][0]%MOD;\n    for(int j=1;j<=i;j++){\n      table[i][j]=(table[i][j-1]-table[i-1][j-1]+MOD)%MOD;\n    }\n  }\n  dpow[0]=1;\n  for(int i=1;i<=N;i++){\n    dpow[i]=1LL*table[N][N]*dpow[i-1]%MOD;\n  }\n  for(int i=0;i0){\n\t  index[i]=(index[i]+table[N-j-1][common-(above[x])])%MOD;\n\t}\n      }\n    }\n  }\n  int ans=0;\n  for(int i=0;i\nusing namespace std;\n#define FF first\n#define SS second\n#define PB push_back\n#define MP make_pair\n#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)\n#ifndef LOCAL\n#define cerr if(0)cout\n#endif\ntypedef long long ll;\nconst int mod=1e9+7;\n//My i/o stream\nstruct fastio\n{\n\tchar s[100000];\n\tint it, len;\n\tfastio() {it=len=0;}\n\tinline char get()\n\t{\n\t\tif (it0) it--;\n\t\treturn c!=EOF;\n\t}\n}_buff;\n#define geti(x) x=getnum()\n#define getii(x,y) geti(x),geti(y)\n#define getiii(x,y,z) getii(x,y),geti(z)\n#define puti(x) putnum(x),putchar(' ')\n#define putii(x,y) puti(x),puti(y)\n#define putiii(x,y,z) putii(x,y),puti(z)\n#define putsi(x) putnum(x),putchar('\\n')\n#define putsii(x,y) puti(x),putsi(y)\n#define putsiii(x,y,z) putii(x,y),putsi(z)\ninline ll getnum()\n{\n\tll r=0; bool ng=0; char c; c=_buff.get();\n\twhile (c!='-'&&(c<'0'||c>'9')) c=_buff.get();\n\tif (c=='-') ng=1, c=_buff.get();\n\twhile (c>='0'&&c<='9') r=r*10+c-'0', c=_buff.get();\n\treturn ng?-r:r;\n}\ntemplate  inline void putnum(T x)\n{\n\tif (x<0) putchar('-'), x=-x;\n\tregister short a[20]={}, sz=0;\n\twhile (x) a[sz++]=x%10, x/=10;\n\tif(sz==0) putchar('0');\n\tfor (int i=sz-1; i>=0; i--) putchar('0'+a[i]);\n}\ninline char getreal() {char c=_buff.get(); while (c<=32) c=_buff.get(); return c;}\nll qpow(ll x, ll k) {return k==0? 1: 1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}\nint Tn, n;\nint f[100111];\nint pre[100111];\nvector > P;\nvector getlis(vector v)\n{\n\tvector > st;\n\tP.clear();\n\tfor (int i=0; i());\n\t\t\tP.back().PB(v[i]);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tst[it]=MP(v[i], i);\n\t\t\tP[it].PB(v[i]);\n\t\t}\n\t\tif (it==0) pre[i] = -1;\n\t\telse pre[i] = st[--it].SS;\n\t}\n\tint p = st.back().SS;\n\tvector ret;\n\twhile (p!=-1)\n\t{\n\t\tret.PB(p);\n\t\tp = pre[p];\n\t}\n\treverse(ret.begin(), ret.end());\n\treturn ret;\n}\nint main()\n{\n\tfor (int i=1, j=1; i<=100000; j++, i+=j)\n\t{\n\t\tfor (int t=i; t<=i+j&&t<=100000; t++) f[t] = j;\n\t}\n\tgeti(Tn);\n\twhile (Tn--)\n\t{\n\t\tgeti(n);\n\t\tint x;\n\t\tvector v;\n\t\tfor (int i=0; i > G;\n\t\twhile (v.size()>0)\n\t\t{\n\t\t\tvector nv;\n\t\t\tvector used;\n\t\t\tused.resize(v.size());\n\t\t\tvector v0 = getlis(v);\n\t\t\tfor (int i=0; i V;\n\t\t\tif (v0.size()>f[v.size()])\n\t\t\t{\n\t\t\t\tfor (auto x:v0) V.PB(v[x]), used[x]=1;\n\t\t\t\tG.PB(V);\n\t\t\t\tfor (int i=0; i\nusing namespace std;\n\ntypedef pair pii;\ntypedef long long ll;\ntypedef vector vi;\n\n#define pb push_back\n#define eb emplace_back\n#define mp make_pair\n#define fi first\n#define se second\n#define rep(i,n) rep2(i,0,n)\n#define rep2(i,m,n) for(int i=m;i<(n);i++)\n#define ALL(c) (c).begin(),(c).end()\n#define dump(x) cout << #x << \" = \" << (x) << endl\n\nconst ll MOD = 998244353;\n\nstruct NumberTheoreticTransform {\n    int mod;\n    int root;\n\n    NumberTheoreticTransform(int mod, int root) : mod(mod), root(root) {}\n\n    int mul(int x, int y) {\n        return int64_t(x) * y % mod;\n    }\n\n    int add(int x, int y) {\n        return (x += y) >= mod ? x - mod : x;\n    }\n\n    int pow(int x, int y) {\n        int res = 1;\n        while (y > 0) {\n            if (y & 1) res = mul(res, x);\n            x = mul(x, x);\n            y >>= 1;\n        }\n        return res;\n    }\n\n    int inv(int x) {\n        return pow(x, mod - 2);\n    }\n\n    void findroot(ll mm, int lg)//\u5f15\u6570\u306fmod \u4f4d\u6570 1<> lg); k++)r = r*i%mm;\n                        cerr << r << \" is root\" << endl;\n                        return;\n                    }\n                    else break;\n                }\n            }\n        }\n    }\n\n    void ntt(std::vector &a, bool rev = false) {\n        int n = a.size();\n        int h = 0;\n        for (int i = 0; 1 << i < n; i++) h++;\n        for (int i = 0; i < n; i++) {\n            int j = 0;\n            for (int k = 0; k < h; k++) {\n            \tj |= (i >> k & 1) << (h - 1 - k);\n            }\n            if (i < j) std::swap(a[i], a[j]);\n        }\n        for (int i = 1; i < n; i *= 2) {\n            int w = pow(root, (mod - 1) / (i * 2));\n            if (rev) w = inv(w);\n            for (int j = 0; j < n; j += i * 2) {\n                int wn = 1;\n                for (int k = 0; k < i; k++) {\n                    int s = a[j + k + 0];\n                    int t = mul(a[j + k + i], wn);\n                    a[j + k + 0] = add(s, t);\n                    a[j + k + i] = add(s, mod - t);\n                    wn = mul(wn, w);\n                }\n            }\n        }\n        int v = inv(n);\n        if (rev) for (int i = 0; i < n; i++) a[i] = mul(a[i], v);\n    }\n\n    std::vector mul(std::vector a, std::vector b) {\n        int s = a.size() + b.size() - 1;\n        int t = 1;\n        while (t < s) t *= 2;\n        a.resize(t);\n        b.resize(t);\n        ntt(a);\n        ntt(b);\n        for (int i = 0; i < t; i++) {\n            a[i] = mul(a[i], b[i]);\n        }\n        ntt(a, true);\n\n        a.resize(s);\n        return a;\n    }\n};\n\nconst int MN = 2010;\ntemplate\nclass BIT {\n\tT bit[MN];\n\tint n;\n\npublic:\n\tBIT() {\n\t\tn = MN;\n\t\tmemset(bit, 0, sizeof(bit));\n\t}\n\n\tT sum(int i) {\n\t\t++i;\n\t\tT s = 0;\n\t\twhile (i > 0) {\n\t\t\ts += bit[i];\n\t\t\ti -= i & -i;\n\t\t}\n\t\treturn s;\n\t}\n\n\tvoid add(int i, T x) {\n\t\t++i;\n\t\twhile (i < n) {\n\t\t\tbit[i] += x;\n\t\t\ti += i & -i;\n\t\t}\n\t}\n};\n\nconst int MX = 4010;\nll inv[MX], fact[MX], ifact[MX];\n\nvoid init()\n{\n    inv[1] = 1;\n    for (int i = 2; i < MX; ++i) {\n        inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;\n    }\n    fact[0] = ifact[0] = 1;\n    for (int i = 1; i < MX; ++i) {\n        fact[i] = fact[i-1] * i % MOD;\n        ifact[i] = ifact[i-1] * inv[i] % MOD;\n    }\n}\n\nll comb(int n, int r) {\n    if (n < 0 || r < 0 || r > n) return 0;\n    return fact[n] * ifact[r] % MOD * ifact[n - r] % MOD;\n}\n\nconst int MN = 2010;\nint a[MN][MN];\nll sub[MN][MN];\nll pw[MN];\n\nint main() {\n\tinit();\n\tNumberTheoreticTransform ntt(998244353, 5);\n\n\trep(i, MN) {\n\t\tvi va(i + 1), vb(i + 1);\n\t\tfor (int j = 0; j <= i; ++j) {\n\t\t\tva[j] = ifact[j] * fact[i - j] % MOD;\n\t\t\tif (j % 2 == 1) {\n\t\t\t\tva[j] = -va[j];\n\t\t\t\tif (va[j] < 0) va[j] += MOD;\n\t\t\t}\n\t\t}\n\n\t\tfor (int j = 0; j <= i; ++j) {\n\t\t\tvb[j] = ifact[j] % MOD;\n\t\t}\n\n\t\tva = ntt.mul(va, vb);\n\n\t\tfor (int j = 0; j <= i; ++j) {\n\t\t\tsub[i][j] = va[j] * fact[j] % MOD;\n\t\t}\n\t}\n\n\tint n; scanf(\"%d\", &n);\n\trep(i, n) {\n\t\trep(j, n) {\n\t\t\tscanf(\"%d\", &a[i][j]);\n\t\t\t--a[i][j];\n\t\t}\n\t}\n\n\tpw[0] = 1;\n\trep(i, MN-1) {\n\t\tpw[i+1] = pw[i] * sub[n][n] % MOD;\n\t}\n\n\tll ans = 0;\n\n\tvi ng(n, -1);\n\n\trep(r, n) {\n\t\tBIT T;\n\t\tset ban;\n\t\tset can;\n\n\t\tint cnt = 0;\n\t\tint pos = 0;\n\n\t\tfor (int c = n-1; c >= 0; --c) { //smaller\n\t\t\tcan.insert(a[r][c]);\n\n\t\t\tif (ban.count(a[r][c])) {\n\t\t\t\t++pos;\n\t\t\t}\n\n\t\t\tfor (int k = 0; k < a[r][c]; ++k) {\n\t\t\t\tif (k != ng[c] && can.count(k)) {\n\t\t\t\t\tcan.erase(k);\n\t\t\t\t\tif (ban.count(k)) {\n\t\t\t\t\t\t--pos;\n\t\t\t\t\t}\n\n\t\t\t\t\tll t = sub[n-1-c][pos] * pw[n-1-r] % MOD;\n\n\t\t\t\t\t//cerr << \"r = \" << r << \", c = \" << c << \", k = \" << k << \", num = \" << t << endl;\n\t\t\t\t\tans = (ans + t) % MOD;\n\n\t\t\t\t\tif (ban.count(k)) {\n\t\t\t\t\t\t++pos;\n\t\t\t\t\t}\n\t\t\t\t\tcan.insert(k);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (ng[c] != -1) {\n\t\t\t\tban.insert(ng[c]);\n\t\t\t\tif (can.count(ng[c])) {\n\t\t\t\t\t++pos;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\trep(c, n) ng[c] = a[r][c];\n\t}\n\n\tcout << ans << endl;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3b1c75a276321b7bb6e33a24d98d852f", "src_uid": "46253becfda9a45ce670dc7d835beaf3", "difficulty": 2900.0}
    {"lang": "GNU C++11", "source_code": "//>> OI Solution Info <> End <\n#include \n#include \n#include \n#include \n#define y0 y_0\n#define y1 y_1\n#define yn y_n\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef unsigned int uint;\ntypedef long long ll;\ntypedef unsigned long long ull;\nconst int Mod=998244353,Primitive=3;\n\nstruct FenwickTree{\n\tstatic const int Size=2005;\n\tint a[Size];\n\n\tvoid update(int x,int v){\n\t\tx++;\n\t\twhile(x<=Size)a[x-1]+=v,x+=x&(-x);\n\t}\n\n\tint query(int x){\n\t\tint res=0;\n\t\tx++;\n\t\twhile(x>=1)res+=a[x-1],x-=x&(-x);\n\t\treturn res;\n\t}\n\t\n\tvoid init(){memset(a,0,sizeof a);}\n\tint get(int x){return query(x)-query(x-1);}\n};\n\ninline int binomial(int a,int b){\n\tif(a==b||b==0)return 1;\n\tif(a>1]>>1)+((i&1)<<(bcnt-1));\n\t\tif(i0)(res+=(ll)curr2*g[rem-1][n-1-i]%Mod)%=Mod;\n\t\t(res+=(ll)(curr+Mod-curr2)*g[rem][n-1-i]%Mod)%=Mod;\n\t\tif(v[i]>l[i]&&used.get(l[i])==0)(res+=Mod-g[rem][n-1-i])%=Mod; // l[i] less than v[i]\n\t\tused.update(v[i],1);\n\t\tif(!f[v[i]])f[v[i]]=true,rem--,used2.update(v[i],1);\n\t}\n\treturn res;\n}\n\nint main(){\n\tscanf(\"%d\",&n);\n\tfor(int i=0;i\n#include \n\n#include \n#include \n#include \n\n#define LOG(FMT...) fprintf(stderr, FMT)\n\nusing namespace std;\n\ntypedef long long ll;\n\ntemplate \nclass is_zero {\npublic:\n    bool operator()(const T& x) const;\n};\n\ntemplate <>\nclass is_zero {\npublic:\n    bool operator()(const int& x) const { return x == 0; }\n};\n\ntemplate  >\nclass flow_graph {\npublic:\n    typedef WeightT weight_type;\n    typedef const weight_type& const_weight_reference;\n    typedef weight_type* weight_array_type;\n\nprivate:\n    struct edge {\n        int v;\n        weight_type w;\n        edge *next, *rev;\n    };\n\n    int v, e;\n    edge *pool, *used;\n    edge** adj;\n    ZeroPredicator zero_predicator;\n\n    edge* add_edge(int u, int v, const_weight_reference w) {\n        edge* p = used;\n        ++used;\n        p->v = v;\n        p->w = w;\n        p->next = adj[u];\n        adj[u] = p;\n        return p;\n    }\n\n    bool bfs(int s, int t, int* level) {\n        memset(level, -1, sizeof(int) * v);\n        std::queue q;\n        q.push(s);\n        level[s] = 0;\n        while (!q.empty()) {\n            int u = q.front();\n            q.pop();\n            for (edge* p = adj[u]; p; p = p->next)\n                if (!zero_predicator(p->w) && level[p->v] == -1) {\n                    level[p->v] = level[u] + 1;\n                    if (p->v == t)\n                        return true;\n                    q.push(p->v);\n                }\n        }\n        return false;\n    }\n\n    weight_type dfs(int u, int t, weight_type lim, edge** cadj, int* level) {\n        if (u == t)\n            return lim;\n        weight_type flow = 0;\n        for (edge*& p = cadj[u]; p; p = p->next)\n            if (!zero_predicator(p->w) && level[u] < level[p->v]) {\n                weight_type f = dfs(p->v, t, std::min(p->w, lim), cadj, level);\n                flow += f;\n                lim -= f;\n                p->w -= f;\n                p->rev->w += f;\n                if (zero_predicator(lim))\n                    return flow;\n            }\n        return flow;\n    }\n\n    weight_type dfs(int u, int t, edge** cadj, int* level) {\n        weight_type flow = 0;\n        for (edge*& p = cadj[u]; p; p = p->next)\n            if (!zero_predicator(p->w) && level[u] < level[p->v]) {\n                weight_type f = dfs(p->v, t, p->w, cadj, level);\n                flow += f;\n                p->w -= f;\n                p->rev->w += f;\n            }\n        return flow;\n    }\n\npublic:\n    flow_graph() {}\n\n    flow_graph(int v, int e, ZeroPredicator zero_predicator = is_zero())\n        : v(v), e(e), zero_predicator(zero_predicator) {\n        pool = new edge[e * 2];\n        adj = new edge*[v];\n        memset(pool, 0, sizeof(edge) * e * 2);\n        memset(adj, 0, sizeof(edge*) * v);\n        used = pool;\n    }\n\n    ~flow_graph() {\n        delete[] pool;\n        delete[] adj;\n    }\n\n    void link(int u, int v, const_weight_reference w) {\n        edge *p = add_edge(u, v, w), *q = add_edge(v, u, 0);\n        p->rev = q;\n        q->rev = p;\n    }\n\n    /**\n     * Calculate the maximum flow from `s` to `t`. Using the dinic algorithm.\n     * time complexity: O(n^2e)\n     **/\n    weight_type max_flow(int s, int t) {\n        int* level = new int[v];\n        edge** cadj = new edge*[v];\n        weight_type flow = 0;\n        while (bfs(s, t, level)) {\n            memcpy(cadj, adj, sizeof(edge*) * v);\n            flow += dfs(s, t, cadj, level);\n        }\n        delete[] level;\n        delete[] cadj;\n        return flow;\n    }\n};\n\nconst int N = 110, S = 100010, INF = 1e9 + 10;\n\nint n, m, s, b, k;\n\nint dist[N][N];\nint sx[N], a[N], f[N], p[N], bx[N], d[N], g[N];\nvector > best[N];\npair ed[1010];\nint good[S], rel[S];\n\nint main() {\n  scanf(\"%d%d\", &n, &m);\n  for (int i = 1; i <= n; ++i)\n    for (int j = 1; j <= n; ++j)\n      dist[i][j] = i == j ? 0 : INF;\n  while (m--) {\n    int u, v;\n    scanf(\"%d%d\", &u, &v);\n    if (u != v)\n      dist[u][v] = dist[v][u] = 1;\n  }\n  for (int i = 1; i <= n; ++i)\n    for (int j = 1; j <= n; ++j)\n      for (int k = 1; k <= n; ++k)\n        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);\n  scanf(\"%d%d%d\", &s, &b, &k);\n  for (int i = 1; i <= s; ++i)\n    scanf(\"%d%d%d%d\", &sx[i], &a[i], &f[i], &p[i]);\n  for (int i = 1; i <= b; ++i) {\n    scanf(\"%d%d%d\", &bx[i], &d[i], &g[i]);\n    best[bx[i]].emplace_back(d[i], g[i]);\n  }\n  for (int i = 1; i <= n; ++i) {\n    sort(best[i].begin(), best[i].end());\n    for (int j = 1; j < best[i].size(); ++j)\n      best[i][j].second = max(best[i][j - 1].second, best[i][j].second);\n  }\n  memset(good, -1, sizeof(good));\n  for (int i = 1; i <= s; ++i)\n    for (int j = 1; j <= n; ++j)\n      if (f[i] >= dist[sx[i]][j]) {\n        auto it = lower_bound(best[j].begin(), best[j].end(), make_pair(a[i] + 1, 0));\n        if (it != best[j].begin())\n          good[i] = max(good[i], (it - 1)->second);\n      }\n  int cnt = 0;\n  int S = ++cnt, T = ++cnt;\n  for (int i = 1; i <= k; ++i) {\n    int u, v;\n    scanf(\"%d%d\", &u, &v);\n    ed[i] = make_pair(u, v);\n    if (!rel[u])\n      rel[u] = ++cnt;\n    if (!rel[v])\n      rel[v] = ++cnt;\n  }\n  flow_graph g(cnt, k + (cnt - 2));\n  ll ans = 0;\n  for (int i = 1; i <= k; ++i) {\n    int u, v;\n    tie(u, v) = ed[i];\n    g.link(rel[u], rel[v], INF);\n  }\n  for (int i = 1; i <= s; ++i) {\n    if (good[i] == -1) good[i] = -INF;\n    else good[i] -= p[i];\n    if (rel[i]) {\n      if (good[i] >= 0) {\n        ans += good[i];\n        g.link(S, rel[i], good[i]);\n      } else {\n        g.link(rel[i], T, -good[i]);\n      }\n    } else {\n      ans += max(0, good[i]);\n    }\n  }\n  ans -= g.max_flow(S, T);\n  printf(\"%lld\\n\", ans);\n  return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7f822b1dff540e2a946de2e5bdb80416", "src_uid": "dd4f9570b62ed012ad0706cbd805ea4b", "difficulty": 2700.0}
    {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\nstruct base_t {\n    int64_t position, defense, gold;\n    friend std::istream& operator >> (std::istream& flux, base_t& b) {\n        flux >> b.position >> b.defense >> b.gold;\n        return flux;\n    }\n    bool operator < (const base_t& b) const {\n        return this->defense < b.defense;\n    }\n};\n\nstruct ship_t {\n    int64_t position, strength, fuel, price;\n    friend std::istream& operator >> (std::istream& flux, ship_t& s) {\n        flux >> s.position >> s.strength >> s.fuel >> s.price;\n        return flux;\n    }\n};\n\nstruct Flow_Edge {\n    int from, to;\n    int64_t capacity, flow = 0LL;\n    Flow_Edge (const int& from, const int& to, const int64_t& capacity): from (from), to (to), capacity (capacity) {\n    }\n};\n\nconstexpr auto Inf = std::numeric_limits ::max ();\nusing Ip = std::pair ;\nusing Vi = std::vector ;\nusing VVi = std::vector ;\nusing Vi64 = std::vector ;\nusing VVi64 = std::vector ;\nusing VIp = std::vector ;\nusing VVIp = std::vector ;\nusing Vf = std::vector ;\nusing Vs = std::vector ;\nusing Vb = std::vector ;\nusing Qi = std::queue ;\n\nstruct Dinic {\n    Vf Edges;\n    VVi Adj;\n    int n, s, t;\n    Vi Level, Ptr;\n    Qi Q;\n    Dinic (const int& n, const int& s, const int& t): n (n), s (s), t (t) {\n        Adj.resize (n), Level.resize (n), Ptr.resize (n);\n    }\n    void add_edge (const int& u, const int& v, const int64_t& cap) {\n        if (u == v) return;\n        Edges.emplace_back (u, v, cap);\n        Adj[u].emplace_back (Edges.size () - 1);\n        Edges.emplace_back (v, u, 0);\n        Adj[v].emplace_back (Edges.size () - 1);\n    }\n    bool bfs () {\n        while (!Q.empty ()) {\n            int v = Q.front (); Q.pop ();\n            for (const auto& id: Adj[v]) {\n                if (Edges[id].capacity - Edges[id].flow < 1)\n                    continue;\n                if (Level[Edges[id].to] != -1)\n                    continue;\n                Level[Edges[id].to] = Level[v] + 1;\n                Q.push (Edges[id].to);\n            }\n        }\n        return Level[t] != -1;\n    }\n    int64_t dfs (const int& v, const int64_t& pushed) {\n        if (!pushed)\n            return 0LL;\n        if (v == t)\n            return pushed;\n        for (int& cid = Ptr[v]; cid < (int)Adj[v].size (); ++ cid) {\n            int id = Adj[v][cid], u = Edges[id].to;\n            if (Level[v] + 1 != Level[u] || Edges[id].capacity - Edges[id].flow < 1)\n                continue;\n            int64_t transport = dfs (u, std::min (pushed, Edges[id].capacity - Edges[id].flow));\n            if (!transport)\n                continue;\n            Edges[id].flow += transport;\n            Edges[id ^ 1].flow -= transport;\n            return transport;\n        }\n        return 0LL;\n    }\n    int64_t max_flow () {\n        int64_t f = 0LL;\n        while (true) {\n            std::fill (Level.begin (), Level.end (), -1);\n            Level[s] = 0;\n            Q.push (s);\n            if (!bfs ())\n                break;\n            std::fill (Ptr.begin (), Ptr.end (), 0);\n            while (int64_t pushed = dfs (s, Inf))\n                f += pushed;\n        }\n        return f;\n    }\n};\n\n\nint n, m, u, v, s, b, k;\nVi64 Value;\nVVi64 Cost;\nVs Ships;\nVb Bases;\nVVIp Bases_at;\n\n\nint main () {\n    std::ios_base::sync_with_stdio (false), std::cin.tie (nullptr), std::cout.tie (nullptr);\n    std::cin >> n >> m;\n    Cost.assign (n + 1, Vi64 (n + 1, Inf));\n    for (int i = 1; i <= n; ++ i) Cost[i][i] = 0LL;\n    for (int i = 1; i <= m; ++ i)\n        std::cin >> u >> v, Cost[u][v] = Cost[v][u] = std::min (Cost[u][v], 1LL);\n\n    for (int k = 1; k <= n; ++ k)\n        for (int i = 1; i <= n; ++ i)\n            for (int j = 1; j <= n; ++ j)\n                Cost[i][j] = std::min (Cost[i][j], Cost[i][k] + Cost[k][j]);\n\n    std::cin >> s >> b >> k;\n    Value.resize (s + 1), Bases_at.resize (n + 1);\n    Ships.resize (s + 1), Bases.resize (b + 1);\n    for (int i = 1; i <= s; ++ i)\n        std::cin >> Ships[i];\n    for (int i = 1; i <= b; ++ i)\n        std::cin >> Bases[i];\n\n    std::sort (Bases.begin (), Bases.end ());\n    for (int i = 1; i <= b; ++ i) {\n        int pos = Bases[i].position;\n        if (Bases_at[pos].empty () || Bases_at[pos].back ().second < Bases[i].gold)\n            Bases_at[pos].emplace_back (Bases[i].defense, Bases[i].gold);\n    }\n\n    int source = 0, sink = s + 1;\n    Dinic dinic (s + 2, source, sink);\n    int64_t ans = 0LL;\n    for (int i = 1; i <= s; ++ i) {\n        bool found = false;\n        for (int p = 1; p <= n; ++ p) {\n            if (Cost[Ships[i].position][p] > Ships[i].fuel)\n                continue;\n            auto it = std::upper_bound (Bases_at[p].begin (), Bases_at[p].end (), std::make_pair (Ships[i].strength, Inf));\n            if (it != Bases_at[p].begin ())\n                -- it, found = true, Value[i] = std::max (Value[i], it->second);\n        }\n        Value[i] -= Ships[i].price;\n        if (!found)\n            Value[i] = -Inf;\n        if (Value[i] >= 0)\n            ans += Value[i], dinic.add_edge (source, i, Value[i]);\n        else\n            dinic.add_edge (i, sink, -Value[i]);\n    }\n\n    for (int i = 1; i <= k; ++ i)\n        std::cin >> u >> v,\n        dinic.add_edge (u, v, Inf);\n\n    std::cout << ans - dinic.max_flow ();\n\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "455da7daecb7350128ae70559743f9f7", "src_uid": "dd4f9570b62ed012ad0706cbd805ea4b", "difficulty": 2700.0}
    {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n \n#define X first\n#define Y second\n \nusing namespace std;\n \nconst int maxn = 2020;\nconst int inf = 1e9 + 7;\n \nstruct edge {\n\tint a, b, cap, flow;\n\tedge(int a, int b, int cap) : a(a), b(b), cap(cap), flow(0) {}\n};\n\nint S = 0, T, dist[maxn], q[maxn], ptr[maxn];\nvector e;\nvector g[maxn];\n\nvoid add_edge(int a, int b, int cap) {\n\tg[a].push_back((int)e.size());\n\te.push_back(edge(a, b, cap));\n\tg[b].push_back((int)e.size());\n\te.push_back(edge(b, a, 0));\n}\n\nbool bfs() {\n\tfill(dist, dist + maxn, -1);\n\tdist[S] = 0;\n\tint qh = 0, qt = 0;\n\tq[qt++] = S;\n\twhile(qh < qt and dist[T] == -1) {\n\t\tint v = q[qh++];\n\t\tfor(int id : g[v]) {\n\t\t\tif(dist[e[id].b] == -1 and e[id].flow < e[id].cap) {\n\t\t\t\tq[qt++] = e[id].b;\n\t\t\t\tdist[e[id].b] = dist[v] + 1;\n\t\t\t}\n\t\t}\n\t}\n\treturn dist[T] != -1;\n}\n\nint dfs(int v, int flow) {\n\tif(flow == 0) return 0;\n\tif(v == T) return flow;\n\tfor(; ptr[v] < g[v].size(); ptr[v]++) {\n\t\tint id = g[v][ptr[v]];\n\t\tif(dist[e[id].b] != dist[v] + 1) continue;\n\t\tint pushed = dfs(e[id].b, min(flow, e[id].cap - e[id].flow));\n\t\tif(pushed) {\n\t\t\te[id].flow += pushed;\n\t\t\te[id ^ 1].flow -= pushed;\n\t\t\treturn pushed;\n\t\t}\n\t}\n\treturn 0;\n}\n\nlong long dinic() {\n\tlong long flow = 0;\n\twhile(bfs()) {\n\t\tfill(ptr, ptr + maxn, 0);\n\t\twhile(int pushed = dfs(S, inf)) flow += pushed;\n\t}\n\treturn flow;\n}\n \nint main() {\n\tios::sync_with_stdio(0);\n\tcin.tie(0);\n\tint n, m;\n\tcin >> n >> m;\n\tint d[n + 1][n + 1];\n\tfor(int i = 1; i <= n; i++) {\n\t\tfor(int j = 1; j <= n; j++) {\n\t\t\td[i][j] = d[j][i] = inf;\n\t\t}\n\t\td[i][i] = 0;\n\t}\n\tfor(int i = 0; i < m; i++) {\n\t\tint u, v;\n\t\tcin >> u >> v;\n\t\tif(u != v) {\n\t\t\td[u][v] = d[v][u] = 1;\n\t\t}\n\t}\n\tfor(int k = 1; k <= n; k++) {\n\t\tfor(int i = 1; i <= n; i++) {\n\t\t\tfor(int j = 1; j <= n; j++) {\n\t\t\t\td[i][j] = min(d[i][j], d[i][k] + d[k][j]);\n\t\t\t}\n\t\t}\n\t}\n\tint s, b, k;\n\tcin >> s >> b >> k;\n\tlong long spos[s], attack[s], fuel[s], price[s];\n\tlong long bpos[b], defense[b], gold[b];\n\tfor(int i = 0; i < s; i++) {\n\t\tcin >> spos[i] >> attack[i] >> fuel[i] >> price[i];\n\t}\n\tfor(int i = 0; i < b; i++) {\n\t\tcin >> bpos[i] >> defense[i] >> gold[i];\n\t}\n\tbool indep[s] = {0};\n\tpair dep[k];\n\tfor(int i = 0; i < k; i++) {\n\t\tcin >> dep[i].X >> dep[i].Y;\n\t\tindep[dep[i].X - 1] = indep[dep[i].Y - 1] = true;\n\t}\n\tvector > maxpref[n + 1];\n\tfor(int i = 1; i <= n; i++) {\n\t\tmaxpref[i].push_back({0, -2 * inf});\n\t}\n\tfor(int i = 0; i < b; i++) {\n\t\tmaxpref[bpos[i]].push_back({defense[i], gold[i]});\n\t}\n\tfor(int i = 1; i <= n; i++) {\n\t\tsort(maxpref[i].begin(), maxpref[i].end());\n\t\tfor(int j = 1; j < maxpref[i].size(); j++) {\n\t\t\tmaxpref[i][j].Y = max(maxpref[i][j].Y, maxpref[i][j - 1].Y);\n\t\t}\n\t}\n\tlong long maxprofit[s];\n\tfor(int i = 0; i < s; i++) {\n\t\tlong long ans = -inf * 2;\n\t\tfor(int j = 1; j <= n; j++) {\n\t\t\tif(d[spos[i]][j] <= fuel[i]) {\n\t\t\t\tint x = upper_bound(maxpref[j].begin(), maxpref[j].end(), make_pair(attack[i], 0)) - maxpref[j].begin();\n\t\t\t\tans = max(ans, 1ll * maxpref[j][x - 1].Y - price[i]);\n\t\t\t}\n\t\t}\n\t\tmaxprofit[i] = ans;\n\t}\n\tint nxt = 1;\n\tint newnum[s];\n\tfor(int i = 0; i < s; i++) {\n\t\tif(indep[i]) newnum[i] = nxt++;\n\t}\n\tT = nxt;\n\tfor(int i = 0; i < s; i++) {\n\t\tif(indep[i]) {\n\t\t\tif(maxprofit[i] > 0) add_edge(S, newnum[i], maxprofit[i]);\n\t\t\telse if(maxprofit[i] != -inf * 2) add_edge(newnum[i], T, -maxprofit[i]);\n\t\t}\n\t}\n\tfor(int i = 0; i < k; i++) {\n\t\tadd_edge(newnum[dep[i].X - 1], newnum[dep[i].Y - 1], 2 * inf);\n\t}\n\tlong long ans = 0;\n\tfor(int i = 0; i < s; i++) {\n\t\tif(maxprofit[i] > 0) ans += maxprofit[i];\n\t}\n\tcout << ans - dinic() << '\\n';\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4c917fc6a07296d6d22eae6b6756c037", "src_uid": "dd4f9570b62ed012ad0706cbd805ea4b", "difficulty": 2700.0}
    {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\nstruct base_t {\n    int64_t position, defense, gold;\n    friend std::istream& operator >> (std::istream& flux, base_t& b) {\n        flux >> b.position >> b.defense >> b.gold;\n        return flux;\n    }\n    bool operator < (const base_t& b) const {\n        return this->defense < b.defense;\n    }\n};\n\nstruct ship_t {\n    int64_t position, strength, fuel, price;\n    friend std::istream& operator >> (std::istream& flux, ship_t& s) {\n        flux >> s.position >> s.strength >> s.fuel >> s.price;\n        return flux;\n    }\n};\n\nclass Dinic;\nclass Flow_Edge {\n    int from, to;\n    int64_t capacity, flow = 0LL;\n    Flow_Edge (const int& from, const int& to, const int64_t& capacity): from (from), to (to), capacity (capacity) {\n    }\n    friend Dinic;\n};\n\nconstexpr auto Inf = std::numeric_limits ::max () >> 1LL;\nusing Ip = std::pair ;\nusing Vi = std::vector ;\nusing VVi = std::vector ;\nusing Vi64 = std::vector ;\nusing VVi64 = std::vector ;\nusing VIp = std::vector ;\nusing VVIp = std::vector ;\nusing Vf = std::vector ;\nusing Vs = std::vector ;\nusing Vb = std::vector ;\nusing Qi = std::queue ;\n\nclass Dinic {\nprivate:\n    Vf Edges;\n    VVi Adj;\n    int n, s, t;\n    Vi Level, Ptr;\n    Qi Q;\n    \n    void add_edge (const int& u, const int& v, const int64_t& cap) {\n        if (u == v) return;\n        Edges.emplace_back (u, v, cap);\n        Adj[u].emplace_back (Edges.size () - 1);\n        Edges.emplace_back (v, u, 0);\n        Adj[v].emplace_back (Edges.size () - 1);\n    }\n    bool bfs () {\n        while (!Q.empty ()) {\n            int v = Q.front (); Q.pop ();\n            for (const auto& id: Adj[v]) {\n                if (Edges[id].capacity - Edges[id].flow < 1)\n                    continue;\n                if (Level[Edges[id].to] != -1)\n                    continue;\n                Level[Edges[id].to] = Level[v] + 1;\n                Q.push (Edges[id].to);\n            }\n        }\n        return Level[t] != -1;\n    }\n    int64_t dfs (const int& v, const int64_t& pushed) {\n        if (!pushed)\n            return 0LL;\n        if (v == t)\n            return pushed;\n        for (int& cid = Ptr[v]; cid < (int)Adj[v].size (); ++ cid) {\n            int id = Adj[v][cid], u = Edges[id].to;\n            if (Level[v] + 1 != Level[u] || Edges[id].capacity - Edges[id].flow < 1)\n                continue;\n            int64_t transport = dfs (u, std::min (pushed, Edges[id].capacity - Edges[id].flow));\n            if (!transport)\n                continue;\n            Edges[id].flow += transport;\n            Edges[id ^ 1].flow -= transport;\n            return transport;\n        }\n        return 0LL;\n    }\npublic:\n    Dinic (const int& n, const int& s, const int& t): n (n), s (s), t (t) {\n        Adj.resize (n), Level.resize (n), Ptr.resize (n);\n    }\n    int64_t max_flow () {\n        int64_t f = 0LL;\n        while (true) {\n            std::fill (Level.begin (), Level.end (), -1);\n            Level[s] = 0;\n            Q.push (s);\n            if (!bfs ())\n                break;\n            std::fill (Ptr.begin (), Ptr.end (), 0);\n            while (int64_t pushed = dfs (s, Inf))\n                f += pushed;\n        }\n        return f;\n    }\n};\n\n\nint n, m, u, v, s, b, k;\nVi64 Value;\nVVi64 Cost;\nVs Ships;\nVb Bases;\nVVIp Bases_at;\n\n\nint main () {\n    std::ios_base::sync_with_stdio (false), std::cin.tie (nullptr), std::cout.tie (nullptr);\n    std::cin >> n >> m;\n    Cost.assign (n + 1, Vi64 (n + 1, Inf));\n    for (int i = 1; i <= n; ++ i) Cost[i][i] = 0LL;\n    for (int i = 1; i <= m; ++ i)\n        std::cin >> u >> v, Cost[u][v] = Cost[v][u] = std::min (Cost[u][v], 1LL);\n\n    for (int k = 1; k <= n; ++ k)\n        for (int i = 1; i <= n; ++ i)\n            for (int j = 1; j <= n; ++ j)\n                Cost[i][j] = std::min (Cost[i][j], Cost[i][k] + Cost[k][j]);\n\n    std::cin >> s >> b >> k;\n    Value.resize (s + 1), Bases_at.resize (n + 1);\n    Ships.resize (s + 1), Bases.resize (b + 1);\n    for (int i = 1; i <= s; ++ i)\n        std::cin >> Ships[i];\n    for (int i = 1; i <= b; ++ i)\n        std::cin >> Bases[i];\n\n    std::sort (Bases.begin (), Bases.end ());\n    for (int i = 1; i <= b; ++ i) {\n        int pos = Bases[i].position;\n        if (Bases_at[pos].empty () || Bases_at[pos].back ().second < Bases[i].gold)\n            Bases_at[pos].emplace_back (Bases[i].defense, Bases[i].gold);\n    }\n\n    int source = 0, sink = s + 1;\n    Dinic dinic (s + 2, source, sink);\n    int64_t ans = 0LL;\n    for (int i = 1; i <= s; ++ i) {\n        bool found = false;\n        for (int p = 1; p <= n; ++ p) {\n            if (Cost[Ships[i].position][p] > Ships[i].fuel)\n                continue;\n            auto it = std::upper_bound (Bases_at[p].begin (), Bases_at[p].end (), std::make_pair (Ships[i].strength, Inf));\n            if (it != Bases_at[p].begin ())\n                -- it, found = true, Value[i] = std::max (Value[i], it->second);\n        }\n        Value[i] -= Ships[i].price;\n        if (!found)\n            Value[i] = -Inf;\n        if (Value[i] >= 0)\n            ans += Value[i], dinic.add_edge (source, i, Value[i]);\n        else\n            dinic.add_edge (i, sink, -Value[i]);\n    }\n\n    for (int i = 1; i <= k; ++ i)\n        std::cin >> u >> v,\n        dinic.add_edge (u, v, Inf);\n\n    std::cout << ans - dinic.max_flow ();\n\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "269079c543ae7c48f89cac96b21e57d7", "src_uid": "dd4f9570b62ed012ad0706cbd805ea4b", "difficulty": 2700.0}
    {"lang": "GNU C++17", "source_code": "//LETS START AGAIN\n#include\nusing namespace std;\n#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n#define pb push_back \n#define all(a) a.begin(),a.end()\n#define lb lower_bound\n#define ub upper_bound\n#define pii pair\n#define ld long double\n#define int long long int \n#define F first \n#define S second\nconst int N = 5e3+1;\nint mod = 1e9+7;\nint mul(int a,int b)\n{\n    return ((a%mod)*(b%mod))%mod;\n}\nint add(int a,int b)\n{\n    return ((a%mod)+(b%mod))%mod;\n}\nint power(int a,int b)\n{\n    int res = 1;\n    while(b>0)\n    {\n        if(b&1)\n        {\n            res = mul(res,a);\n        }\n        b = b/2;\n        a = mul(a,a);\n    }\n    return res;\n}\nint sub(int a,int b)\n{\n    return ((a%mod)-(b%mod)+mod)%mod;\n}\nint div(int a,int b)\n{\n    return mul(a,power(b,mod-2));\n}\nint dp[N][N];\nstring s,t;\nint n1,n2;\nint solve(int i,int j)\n{\n    if(i>=n1 || j>=n2)\n        return 0;\n    if(dp[i][j]!=-1)\n        return dp[i][j];\n    int ans = 0;\n    if(s[i] == t[j])\n        ans = add(1,solve(i+1,j+1));\n    ans = add(ans,solve(i,j+1));\n    dp[i][j] = ans;\n    return dp[i][j];\n}\nsigned main() \n{ \n    fast;\n    cin>>s>>t;\n    n1 = s.size();\n    n2 = t.size();\n    memset(dp,-1,sizeof(dp));\n    int ans = 0;\n    for(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long int ll;\n#define EPS (1e-10) \n#define SZ(a) ((int)a.size())\n#define SORT(v) sort((v).begin(), (v).end())\n#define RSORT(v) sort((v).rbegin(),(v).rend())\n#define MP make_pair\n#define MOD 1000000007\n\nll dp[5001][5001];\n\nint main(){\n    string s1,s2;\n    cin>>s1>>s2;\n    memset(dp,0,sizeof(dp));\n    for(int i=1;i<=SZ(s1);i++){\n        for(int j=1;j<=SZ(s2);j++){\n            dp[i][j]=dp[i][j-1]%MOD;\n            if(s1[i-1]==s2[j-1]) dp[i][j]+=(dp[i-1][j-1]+1)%MOD;\n        }\n    }\n    ll ans=0;\n    for(int i=1;i<=SZ(s1);i++) ans+=dp[i][SZ(s2)]%MOD; \n    cout<\n#include \n#include \n#define SZ(a) ((int) (a.size()))\nusing namespace std;\nconst int MAXN = 6010;\nconst int mod = 1000000007;\ntypedef pair ii;\nint n;\nlong long k[MAXN],k2[MAXN];\nchar str1[MAXN],str2[MAXN];\nint main(){ \n     scanf(\"%s\",str1);\n     getchar();\n     scanf(\"%s\",str2);\n    long long res=0;    \n    for(int i=0;i\n#include \n#include \n#define SZ(a) ((int) (a.size()))\nusing namespace std;\nconst int MAXN = 6010;\nconst int mod = 1000000007;\ntypedef pair ii;\nint n;\nlong long k[MAXN],k2[MAXN];\nint main(){ \n    string asd;\n    string asd2 \n    cin >> asd;\n    cin >> asd2;    \n    n = SZ (asd2);  \n    long long res=0;    \n    for(int i=0;i\n\nusing namespace std;\n\nint X, K, P, all = (1 << 8) - 1, aLastM = 1 << 8, lastM = 1 << 7, C[1 << 8];\ndouble DP[2][210][1 << 8][210];\ndouble go(int s, int c, int m, int rem) {\n    if (rem == 0) {\n        if (m == 0) {\n            return 8 + (s == 0 ? c : 0);\n        } else {\n            return C[m & -m];\n        }\n    }\n\n    if (DP[s][c][m][rem] != -1) return DP[s][c][m][rem];\n\n    double prop = P * 1.0 / 100, w1 = 0, w2 = 0;\n    int last = m & lastM;\n    if (m + 1 == aLastM) {\n        w1 = go(1 - s, s == 0 ? 1 : c, (m + 1) & all, rem - 1);\n    } else {\n        w1 = go(s, c, m + 1, rem - 1);\n    }\n    w2 = go((m & lastM) != 0, (s << 7) == (m & lastM) ? c + 1 : 1, (m << 1) & all, rem - 1);\n    w1 *= (1 - prop);\n    w2 *= prop;\n\n    return DP[s][c][m][rem] = w1 + w2;\n}\nint countConsec(int x) {\n    int init = x & 1, ret = 0;\n    while(x && (x & 1) == init) {\n        ret++;\n        x >>= 1;\n    }\n    return ret;\n}\nint main() {\n    for(int i = 0; i < 8; i++)\n        C[1 << i] = i;\n\n    for(int s = 0; s < 2; s++)\n    for(int z = 0; z < 210; z++)\n    for(int m = 0; m < 1 << 8; m++)\n    for(int rem = 0; rem < 210; rem++)\n        DP[s][z][m][rem] = -1;\n\n    cin >> X >> K >> P;\n    printf(\"%.10f\\n\", go((X & aLastM) != 0, countConsec(X >> 8), X & all, K)); \n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "187a3b31a4614a960c6a1a483ab83921", "src_uid": "c9274249c26b1a85c19ab70d91c1c3e0", "difficulty": 2400.0}
    {"lang": "GNU C++0x", "source_code": "#include \n\n\ntypedef long double lf;\n\nconst int MASK_SIZE = 9;\nconst int MAX_COUNT = 210;\nconst int MAX_MASK = (1 << MASK_SIZE) - 1;\n\nlf dp[2][MAX_MASK+1][MAX_COUNT];\n\n\nbool get_last ( int x ) {\n    x >>= MASK_SIZE - 1;\n    return x & 1;\n}\n\nlong long get_mask ( int x ) {\n    return x & MAX_MASK;\n}\n\nint get_count ( int x ) {\n    int count;\n\n    x >>= MASK_SIZE - 1;\n    if ( x == 0 ) {\n        return 0;\n    }\n\n    count = 0;\n    while ( (x&1) == ((x>>1)&1) ) {\n        x >>= 1;\n        ++ count;\n    }\n\n    return count;\n}\n\nint get_zeroes ( int x , int c ) {\n    int count;\n    \n    count = 0;\n    if ( (x & (MAX_MASK >> 1)) == 0 ) {\n        count += MASK_SIZE - 1;\n        if ( get_last(x) == 0 ) {\n            count += c;\n        }\n    }\n    else {\n        while ( (x&1) == 0 ) {\n            ++ count;\n            x >>= 1;\n        }\n    }\n    \n    return count;\n}\n\n\nint main ( void ) {  \n\n    long long x;\n    long double p, q, answer;\n\n    int k, i, c, last, next;\n\n\n    std::fixed(std::cout);\n    std::cout.precision(10);\n\n    std::cin >> x >> k >> p;\n\n    p /= 100;\n    q = 1 - p;\n\n    dp[0][get_mask(x)][get_count(x)] = 1;\n\n    for ( i = 0 ; i < k ; ++ i ) {\n        last = i&1;\n        next = 1 - last;\n        memset(dp[next], 0, sizeof(dp[next]));\n        for ( x = 0 ; x <= MAX_MASK ; ++ x ) {\n            for ( c = 0 ; c < MAX_COUNT ; ++ c ) {\n                // Double\n                if ( get_last(x << 1) == get_last(x) ) {\n                    dp[next][get_mask(x<<1)][c+1] += dp[last][x][c] * p;\n                }\n                else {\n                    dp[next][get_mask(x<<1)][1] += dp[last][x][c] * p;\n                }\n\n                // Increment\n                if ( get_last(x) == get_last(x + 1) {\n                    dp[next][get_mask(x+1)][c] += dp[last][x][c] * q;\n                }\n                else {\n                    if ( get_last(x) == 1 ) {\n                        dp[next][get_mask(x+1)][c] += dp[last][x][c] * q;\n                    }\n                    else {\n                        dp[next][get_mask(x+1)][1] += dp[last][x][c] * q;\n                    }\n                }\n            }\n        }\n    }\n\n    answer = 0;\n    for ( x = 0 ; x < MAX_MASK ; ++ x ) {\n        for ( c = 0 ; c < MAX_COUNT ; ++ c ) {\n            answer += get_zeroes(x, c) * dp[k&1][x][c];\n        }\n    }\n\n    std::cout << answer << std::endl;\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "140655e3d32114e1351b85d8b4ef27fe", "src_uid": "c9274249c26b1a85c19ab70d91c1c3e0", "difficulty": 2400.0}
    {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nconst int N = 2e2 + 50;\nconst int MAX_BIT = 12;\n\nint n, k, p;\n\ndouble f[N][N][1 << MAX_BIT];\n\nint getMinBit(int val) {\n\tif (val == (1 << MAX_BIT)) return MAX_BIT;\n\tfor (int i = 0; i < MAX_BIT; ++i) if (val >> i & 1) return i;\n\treturn N - 1;\n}\n\nint main() {\n    ios_base::sync_with_stdio(false); cin.tie(NULL);\n   \tcin >> n >> k >> p;\n   \tint val = 0;\n   \tfor (int i = 0; i < MAX_BIT; ++i) {\n   \t\tif (n >> i & 1) val += (1 << i);\n   \t}\n   \tfor (int i = 0; i < 30; ++i) if (n >> i & 1) {\n   \t\tf[0][i][val] = 1.0;\n   \t\tbreak;\n   \t}\n   \tdouble prob = (double) p / 100.;\n   \tfor (int i = 0; i < k; ++i) {\n   \t\tfor (int j = 0; j < N - 1; ++j)\n   \t\t\tfor (int val = 0; val < (1 << MAX_BIT); ++val) {\n   \t\t\t\t// if at step i + 1 multiply 2 with prob = p / 100\n   \t\t\t\tint n_val = val; n_val &= ((1 << (MAX_BIT - 1)) - 1); n_val <<= 1;\n   \t\t\t\tassert(n_val < (1 << MAX_BIT));\n   \t\t\t\tf[i + 1][j + 1][n_val] += f[i][j][val] * prob;\n   \t\t\t\t// else prob\n   \t\t\t\t\tn_val = val + 1;\n   \t\t\t\tint b = getMinBit(n_val);\n   \t\t\t\t\tn_val &= ((1 << MAX_BIT) - 1);\n   \t\t\t\tf[i + 1][b][n_val] += f[i][j][val] * (1.0 - prob);\n   \t\t\t}\n   \t}\n   \tdouble answer = 0;\n   \tfor (int j = 0; j < N; ++j)\n   \t\tfor (int val = 0; val < (1 << MAX_BIT); ++val) {\n   \t\t\t// cout << j << \" = \" << f[k][j][val] << '\\n';\n   \t\t\tanswer += j * f[k][j][val];\n   \t\t}\n    cout << fixed << setprecision(10) << answer << '\\n';\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e3f5102dd91b7094da2919597e94807f", "src_uid": "c9274249c26b1a85c19ab70d91c1c3e0", "difficulty": 2400.0}
    {"lang": "GNU C++0x", "source_code": "#include \nusing namespace std;\nint x, k, t;\ndouble p, q, dp[210][210];\nint main() {\n    cin >> x >> k >> t;\n    p = (double)t / 100; q = 1 - p;\n    for (int i = 0; i <= k; i++) for (int v = x + i; !(v & 1); v >>= 1) dp[0][i]++;\n    for (int i = 1; i <= k; i++)\n        for (int j = 0; j <= k; j++) {\n            dp[i][j] = q * dp[i - 1][j + 1];\n            if (!(j & 1)) dp += (dp[i - 1][j >> 1] + 1) * p;\n        }\n    cout << dp[k][0] << endl;\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b27061a1d0fbea3a80d4ecaf64eb6e6f", "src_uid": "c9274249c26b1a85c19ab70d91c1c3e0", "difficulty": 2400.0}
    {"lang": "GNU C++11", "source_code": "#include\n//#pragma comment(linker,\"/STACK:1024000000,1024000000\")\n//251103FD\n//4008802802\n//4008160009\n//1175114440\nusing namespace std;\n#define PB pop_back\n#define PF pop_front\n#define np next_permutation\n#define eb emplace_back\n#define pb push_back\n#define bf push_front\n#define mp make_pair\n#define s second\n#define f first\n#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)\n#define Foreach(it, a) for(__typeof((a).rbegin()) it=(a).rbegin(); it!=(a).rend(); it++)\n#define forn(i, a) for(register int i=0; i pi;\ntypedef pair pii;\ntypedef unsigned long long ull;\ntypedef vector vi;\ntypedef unsigned int uint;\ntypedef vector > matrix;\n\ninline int in() \n{\n    int x=0, c;\n    while((uint)((c=getchar())-48)>=10) \n\t\tif(c=='-') \n\t\t\treturn -in();\n    do \n\t{ x=(x<<3)+(x<<1)+(c^48); }\n\twhile((uint)((c=getchar())^48)<10);\n    return x;\n}\ninline int lcm(int a, int b){return a*b/__gcd(a, b);}\n\nint nf, ne, ns, df, de, tot, all, half, a[15], low[1<<15];\ndouble rf, re, rs, res, e[25], f[25], dp[15][25][25];\nvi BIT[25];\n\ninline void UpDate(double&a)\n{\n    a=sqrt(a*a-1);\n}\n\ninline double CalCu(double l1, double r1, double l2, double r2)\n{\n    return max(min(r1, r2)-max(l1, l2), 0.0);\n}\n\ninline void Incode(int x)\n{\n    while(x)\n    {\n        ++a[low[x]+1];\n        x-=x&-x;\n    }\n}\n\ninline void binary(int x)\n{\n    char s[128];\n    itoa(x, s, 2);\n    printf(\"%s\\n\", s); \n}\n\ninline void Init()\n{\n    Forn(i, tot)\n    {\n        f[i]=rf*2*df;\n        e[i]=re*2*de;\n        Forn(j, tot)\n        {\n            f[i]+=CalCu(i-rf, i+rf, j-rs, j+rs)*a[j]*df;\n\t\t\te[i]+=CalCu(i-re, i+re, j-rs, j+rs)*a[j]*de;\n        }\n    }\n}\n\ninline void DP()\n{\n    Forn(i, tot)\n        forn(j, nf+1)\n            forn(k, ne+1)\n                forn(x, min(3-a[i], j+1))\n                    forn(y, min(3-a[i], k+1))\n                        dp[i][j][k]=max(dp[i][j][k], dp[i-1][j-x][k-y]+x*f[i]+y*e[i]);\n    res=max(res, dp[tot][nf][ne]);\n}\n\nint main()\n{\n    nf=in(), ne=in(), ns=in();\n    scanf(\"%lf %lf %lf\", &rf, &re, &rs);\n    df=in(), de=in();\n    UpDate(rf), UpDate(re), UpDate(rs);\n    tot=nf+ne+ns+1>>1;\n    forn(i, tot+1)\n        BIT[__builtin_popcount(i)].eb(i), low[i]=__builtin_ctz(i);\n    forn(i, ns+1)\n        foreach(t1, BIT[i])\n            foreach(t2, BIT[ns-i])\n            {\n                memset(a, 0, sizeof(a));\n                memset(e, 0, sizeof(e));\n                memset(f, 0, sizeof(f));\n                memset(dp, 0, sizeof(dp));\n//                binary(*t1), binary(*t2), puts(\"\");\n                Incode(*t1), Incode(*t2);\n                Init();\n                DP();\n            }\n    \n    printf(\"%.8lf\\n\", res);\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ff869863818bada4bdd6cc2a66af1a41", "src_uid": "de5a42225714552cc5422d8a45734d58", "difficulty": 2600.0}
    {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst double eps=1e-10;\nint n,nf,ne,ns,rf,re,rs,df,de,vis[30];\ndouble lf,le,ls,ans;\nstruct node\n{\n\tint f,r;\n\tdouble x;\n\tnode(){}\n\tnode(double x,int f,int r) : x(x),f(f),r(r) {}\n\tfriend bool operator < (node a,node b)\n\t{\n\t\treturn a.xn/2)\n\t\treturn (double)(i-n/2);\n\telse \n\t\treturn (double)i;\n}\nvoid work()\n{\n\tint cnt=0;\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tif(vis[i]==1)\n\t\t{\t\n\t\t\ta[cnt++]=node(I(i)-ls,1,1);\n\t\t\ta[cnt++]=node(I(i)+ls,1,0);\n\t\t}\n\t\telse if(vis[i]==2)\n\t\t{\n\t\t\ta[cnt++]=node(I(i)-lf,2,1);\n\t\t\ta[cnt++]=node(I(i)+lf,2,0);\n\t\t}\n\t\telse if(vis[i]==3)\n\t\t{\n\t\t\ta[cnt++]=node(I(i)-le,3,1);\n\t\t\ta[cnt++]=node(I(i)+le,3,0);\n\t\t}\n\t}\n\tsort(a,a+cnt);\n\tint bin=1,att=0;\n\tdouble now=0.0,last;\n\tfor(int i=0;i0 && y>0) vis[k]=1,vis[k+n/2]=2,dfs(x-1,y-1,z,k+1,g);\n\tif(y>0 && z>0) vis[k]=2,vis[k+n/2]=3,dfs(x,y-1,z-1,k+1,g);\n\tif(z>0 && x>0) vis[k]=3,vis[k+n/2]=1,dfs(x-1,y,z-1,k+1,g);\n\tif(n&1 && !g)\n\t{\n\t\tif(x>0) vis[k]=1,dfs(x-1,y,z,k+1,1);\n\t\tif(y>0) vis[k]=2,dfs(x,y-1,z,k+1,1);\n\t\tif(z>0) vis[k]=3,dfs(x,y,z-1,k+1,1);\t\t\n\t}\n}\nint main()\n{\n\t//freopen(\"input.txt\",\"r\",stdin);\n\tscanf(\"%d %d %d %d %d %d %d %d\",&nf,&ne,&ns,&rf,&re,&rs,&df,&de);\n\tlf=(double)sqrt(rf*rf-1);\n\tle=(double)sqrt(re*re-1);\n\tls=(double)sqrt(rs*rs-1);\n\tn=nf+ne+ns;\n\tdfs(ns,nf,ne,1);\n\tprintf(\"%.7lf\\n\",ans);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "611eea08d876a1275673f5c1c8e5899a", "src_uid": "de5a42225714552cc5422d8a45734d58", "difficulty": 2600.0}
    {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst double eps=1e-10;\nint n,nf,ne,ns,rf,re,rs,df,de,vis[30];\ndouble lf,le,ls,ans;\nstruct node\n{\n\tint f,r;\n\tdouble x;\n\tnode(){}\n\tnode(double x,int f,int r) : x(x),f(f),r(r) {}\n\tfriend bool operator < (node a,node b)\n\t{\n\t\treturn a.xn/2)\n\t\treturn (double)(i-n/2);\n\telse \n\t\treturn (double)i;\n}\nvoid work()\n{\n\tint cnt=0;\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tif(vis[i]==1)\n\t\t{\t\n\t\t\ta[cnt++]=node(I(i)-ls,1,1);\n\t\t\ta[cnt++]=node(I(i)+ls,1,0);\n\t\t}\n\t\telse if(vis[i]==2)\n\t\t{\n\t\t\ta[cnt++]=node(I(i)-lf,2,1);\n\t\t\ta[cnt++]=node(I(i)+lf,2,0);\n\t\t}\n\t\telse\n\t\t{\n\t\t\ta[cnt++]=node(I(i)-le,3,1);\n\t\t\ta[cnt++]=node(I(i)+le,3,0);\n\t\t}\n\t}\n\tsort(a,a+cnt);\n\tint bin=1,att=0;\n\tdouble now=0.0,last;\n\tfor(int i=0;i0 && y>0) vis[k]=1,vis[k+n/2]=2,dfs(x-1,y-1,z,cur+1);\n\tif(y>0 && z>0) vis[k]=2,vis[k+n/2]=3,dfs(x,y-1,z-1,cur+1);\n\tif(z>0 && x>0) vis[k]=3,vis[k+n/2]=1,dfs(x-1,y,z-1,cur+1);\n}\nint main()\n{\n\t//freopen(\"input.txt\",\"r\",stdin);\n\tscanf(\"%d %d %d %d %d %d %d %d\",&nf,&ne,&ns,&rf,&re,&rs,&df,&de);\n\tlf=(double)sqrt(rf*rf-1);\n\tle=(double)sqrt(re*re-1);\n\tls=(double)sqrt(rs*rs-1);\n\tn=nf+ne+ns;\n\tdfs(ns,nf,ne,1);\n\tprintf(\"%.7lf\\n\",ans);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2e18eef9e6cd349a0cbf04091996eaf3", "src_uid": "de5a42225714552cc5422d8a45734d58", "difficulty": 2600.0}
    {"lang": "GNU C++14", "source_code": "#include\n//#pragma comment(linker,\"/STACK:1024000000,1024000000\")\n//251103FD\n//4008802802\n//4008160009\n//1175114440\nusing namespace std;\n#define PB pop_back\n#define PF pop_front\n#define np next_permutation\n#define eb emplace_back\n#define pb push_back\n#define bf push_front\n#define mp make_pair\n#define s second\n#define f first\n#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)\n#define Foreach(it, a) for(__typeof((a).rbegin()) it=(a).rbegin(); it!=(a).rend(); it++)\n#define forn(i, a) for(register int i=0; i pi;\ntypedef pair pii;\ntypedef unsigned long long ull;\ntypedef vector vi;\ntypedef unsigned int uint;\ntypedef vector > matrix;\n\ninline int in() \n{\n    int x=0, c;\n    while((uint)((c=getchar())-48)>=10) \n\t\tif(c=='-') \n\t\t\treturn -in();\n    do \n\t{ x=(x<<3)+(x<<1)+(c^48); }\n\twhile((uint)((c=getchar())^48)<10);\n    return x;\n}\ninline int lcm(int a, int b){return a*b/__gcd(a, b);}\n\nint nf, ne, ns, df, de, tot, all, half, low[1<<20];\ndouble rf, re, rs, res;\n\ninline void UpDate(double&a)\n{\n    a=sqrt(a*a-1);\n}\n\ninline double CalCu(double l1, double r1, double l2, double r2)\n{\n    return max(min(r1, r2)-max(l1, l2), 0.0);\n}\n\nint main()\n{\n    nf=in(), ne=in(), ns=in();\n    scanf(\"%lf %lf %lf\", &rf, &re, &rs);\n    df=in(), de=in();\n    UpDate(rf), UpDate(re), UpDate(rs);\n    tot=nf+ne+ns;\n    forn(msk, 1< v;\n            for(register int sub1=msk^((1<>1;\n                double drf=df*rf<<1, dre=de*re<<1;\n                for(register int sub2=msk; sub2; sub2-=sub2&-sub2)\n                {\n                    int p2=low[sub2]>>1;\n                    drf+=df*CalCu(p1-rs, p1+rs, p2-rf, p2+rf);\n                    dre+=de*CalCu(p1-rs, p1+rs, p2-re, p2+re);\n                }\n                val+=drf;\n                v.eb(drf-dre);\n            }\n            sort(all(v));\n            forn(i, ne)\n                val-=v[i];\n            res=max(res, val);\n        }\n    printf(\"%.8lf\\n\", res);\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d2a01a9d491cc87469162a33a006766c", "src_uid": "de5a42225714552cc5422d8a45734d58", "difficulty": 2600.0}
    {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#define inf 8333583335000000000ll\n#define pii pair\nusing namespace std;\nint n,lcnt;\nlong long m,p,q;\nint a[100005],lsum[100005];\nlong long sum[100005],rmax[100005],lmin[100005],ls[100005];\nlong long ans1,ans2,ans;\nsetunu;\ninline long long Min(long long x,long long y){return xy?x:y;}\ninline int lowbit(int k){return k&-k;}\nstruct ta{\n\tlong long t[100005];\n\tvoid add(int k,long long x){for(;k<=lcnt;k+=lowbit(k))t[k]+=x;}\n\tinline long long query(int k){long long ans=0;for(;k;k-=lowbit(k))ans+=t[k];return ans;}\n}tsum,tnum;\nstruct ta2{\n\tint t[100005];\n\tvoid build(){for(int i=1;i<=lcnt;i++)t[i]=n+1;}\n\tvoid add(int k,int x){for(;k<=lcnt;k+=lowbit(k))t[k]=Min(t[k],x);}\n\tinline int query(int k){int ans=n+1;for(;k;k-=lowbit(k))ans=Min(ans,t[k]);return ans;}\n}tmin;\nstruct subs{\n\tint l,r;long long w;\n\tbool operator <(const subs k)const{\n\t\tif(w!=k.w)return wk.r;\n\t\telse return l>k.l;\n\t}\n\tbool operator ==(const subs k)const{return (k.l==l)&&(k.r==r)&&(k.w==w);}\n\tbool operator !=(const subs k)const{return (k.l!=l)||(k.r!=r)||(k.w!=w);}\t\n};\npriority_queuesubsq;\nvoid del(int k);\n#define lson index<<1\n#define rson index<<1|1\n#define mid ((l+r)>>1)\nstruct sg1{\n\tbool b[400005];\n\tvoid cover(int L,int R,int l,int r,int index){\n\t\tif(L>R)return;\n\t\tif(b[index])return;\n\t\tif(l==r){del(l);b[index]=true;return;}\n\t\tif(L<=mid)cover(L,R,l,mid,lson);\n\t\tif(R>mid)cover(L,R,mid+1,r,rson);\n\t\tb[index]=b[lson]&&b[rson];\n\t}\n}s1;\nstruct node2{\n\tlong long max,min;\n\tvoid pushup(node2 l,node2 r){\n\t\tmax=Max(l.max,r.max);\n\t\tmin=Min(l.min,r.min);\n\t}\n};\nstruct sg2{\n\tnode2 t[400005];\n\tvoid build(int l,int r,int index){\n\t\tif(l==r){t[index].min=t[index].max=sum[l];return;}\n\t\tbuild(l,mid,lson);\n\t\tbuild(mid+1,r,rson);\n\t\tt[index].pushup(t[lson],t[rson]);\n\t}\n\tnode2 query(int L,int R,int l,int r,int index){\n\t\tif((L<=l)&&(R>=r))return t[index];\n\t\tif(R<=mid)return query(L,R,l,mid,lson);\n\t\tif(L>mid)return query(L,R,mid+1,r,rson);\n\t\tnode2 ans;\n\t\tans.pushup(query(L,R,l,mid,lson),query(L,R,mid+1,r,rson));\n\t\treturn ans;\n\t}\n}s2;\n#undef lson\n#undef rson\nstruct node3{\n\tint l,r,s;\n};\nstruct sg3{\n\tnode3 t[4000005];\n\tint root[100005],cnt;\n\tvoid ins(int &rt,int l,int r,int k){\n\t\tif(rt==0)rt=++cnt;\n\t\tt[rt].s++;\n\t\tif(l==r)return;\n\t\tif(k<=mid)ins(t[rt].l,l,mid,k);\n\t\telse ins(t[rt].r,mid+1,r,k);\n\t}\n\tvoid build(){for(int i=0;i<=n;i++)ins(root[lsum[i]],0,n,i);}\n\tinline int qsum(int rt,int l,int r,int k){\n\t\tif(rt==0)return 0;\n\t\tif(l==r)return t[rt].s;\n\t\tif(k<=mid)return qsum(t[rt].l,l,mid,k);\n\t\telse return t[t[rt].l].s+qsum(t[rt].r,mid+1,r,k);\n\t}\n\tinline int query(int rt,int l,int r,int k){\n\t\tif(l==r)return r;\n\t\tif(k<=t[t[rt].l].s)return query(t[rt].l,l,mid,k);\n\t\telse return query(t[rt].r,mid+1,r,k-t[t[rt].l].s);\n\t}\n}s3;\nstruct sg4{\n\tnode3 t[4000005];\n\tint cnt,root[100005];\n\tvoid ins(int &rt,int Rt,int l,int r,int k){\n\t\trt=++cnt;\n\t\tt[rt].s=t[Rt].s+1;\n\t\tif(l==r)return;\n\t\tif(k<=mid){\n\t\t\tt[rt].r=t[Rt].r;\n\t\t\tins(t[rt].l,t[Rt].l,l,mid,k);\n\t\t}else{\n\t\t\tt[rt].l=t[Rt].l;\n\t\t\tins(t[rt].r,t[Rt].r,mid+1,r,k);\n\t\t}\n\t}\n\tvoid build(){ins(root[0],0,1,lcnt,lsum[0]);for(int i=1;i<=n;i++)ins(root[i],root[i-1],1,lcnt,lsum[i]);}\n\tinline int query(int rt,int l,int r,int k){\n\t\tif(k>r)return 0;\n\t\tif(rt==0)return 0;\n\t\tif(l==r)return l;\n\t\tif(k>mid)return query(t[rt].r,mid+1,r,k);\n\t\telse{\n\t\t\tint tmp=query(t[rt].l,l,mid,k);\n\t\t\tif(tmp)return tmp;\n\t\t\telse return query(t[rt].r,mid+1,r,k);\n\t\t}\n\t}\n}s4;\nstruct splaynode{\n\tint l,r,size,fa;\n\tsubs s;\n\tlong long sum;\n\tbool operator <(const splaynode k)const{return s0)t[t[k].l].fa=tmp;\n\t\t    t[tmp].r=t[k].l;\n\t\t    t[k].l=tmp;\n\t\t}else{\n\t\t    if(t[k].r>0)t[t[k].r].fa=tmp;\n\t\t    t[tmp].l=t[k].r;\n\t\t    t[k].r=tmp;\n   \t\t}\n\t\tpushup(tmp);pushup(k);\n\t}\n\tvoid splay(int k,int g){\n\t\twhile(t[k].fa!=g){\n\t\t\tint tmp=t[k].fa;\n\t\t\tif(t[tmp].fa==g)if(t[tmp].r==k)rorate(k,0);\n\t\t\telse rorate(k,1);\n\t\t\telse{\n\t\t\t\tint Tmp=t[tmp].fa;\n\t\t\t\tif(t[Tmp].l==tmp){\n\t\t\t\t    if(t[tmp].l==k)rorate(tmp,1);\n\t\t\t\t    else rorate(k,0);\n\t\t\t\t    rorate(k,1);\n\t\t\t\t}else{\n\t\t\t\t    if(t[tmp].r==k)rorate(tmp,0);\n\t\t\t\t\telse rorate(k,1);\n\t\t\t\t\trorate(k,0);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(g==0)root=k;\n\t}\n\tvoid build(int l,int r,int &root){\n\t\troot=++cnt;t[root].s=(subs){mid+1,mid,0};\n\t\tif(lmid){\n\t\t\tbuild(mid+1,r,t[root].l);\n\t\t\tt[t[root].l].fa=root;\n\t\t}\n\t\tpushup(root);\n\t}\n\tinline long long query(int k){\n\t\tif(k>t[root].size)return -inf;\n\t\tif(k==t[root].size)return t[root].sum;\n\t\tint p=root;\n\t\twhile(t[t[p].r].size!=k){\n\t\t\tif(k'9')){if(c=='-')p=-1;c=getchar();}\n\twhile((c>='0')&&(c<='9'))ret=(ret<<1)+(ret<<3)+c-'0',c=getchar();\n\treturn ret*p;\n}\ninline int find(long long k){\n\tint l=0,r=lcnt+1;\n\twhile(r-l>1){\n\t\tif(ls[mid]>k)r=mid;\n\t\telse l=mid;\n\t}\n\treturn l;\n}\ninline long long checknum(long long std){\n\tlong long ans=0;\n\tfor(int i=0;i<=n;i++){\n\t\tans+=tnum.query(find(sum[i]-std));\n\t\ttnum.add(lsum[i],1);\n\t}\n\tfor(int i=0;i<=n;i++)tnum.add(lsum[i],-1);\n\treturn ans;\n}\nvoid del(int k){\n//\tif(k%1000==0)fprintf(stderr,\"k=%d\\n\",k);\n\tset::iterator p=unu.find(k),st=unu.begin(),ed=unu.end();\n\ted--;\n\tif(p!=st){\n\t\tset::iterator pre=p;pre--;\n\t\tnode2 tmp=s2.query((*pre),k-1,1,n-1,1);\n\t\ts.del((subs){(*pre)+1,k-1,tmp.max-tmp.min});\n\t}\n\tif(p!=ed){\n\t\tset::iterator nex=p;nex++;\n\t\tnode2 tmp=s2.query(k,(*nex)-1,1,n-1,1);\n\t\ts.del((subs){k+1,(*nex)-1,tmp.max-tmp.min});\n\t}\n\tif((p!=st)&&(p!=ed)){\n\t\tset::iterator pre=p,nex=p;pre--;nex++;\n\t\tnode2 tmp=s2.query((*pre),(*nex)-1,1,n-1,1);\n\t\ts.ins((subs){(*pre)+1,(*nex)-1,tmp.max-tmp.min});\t\n\t}\n\tunu.erase(k);\n}\ninline subs Next(subs now){\n\tint l=now.l,r=now.r,L,R=r;\n\tint tmp=s3.qsum(s3.root[lsum[l]],0,n,l);\n\tif(tmp==1){\n\t\tint S=s4.query(s4.root[r-1],1,lcnt,lsum[l]+1);\n\t\tif(S==0)return (subs){0,R,-50000000001ll};\n\t\tint Sum=s3.qsum(s3.root[S],0,n,r-1);\n\t\tL=s3.query(s3.root[S],0,n,Sum);\n//\t\tprintf(\"tmp=%d S=%d %d L=%d\\n\",tmp,S,Sum,L);\n\t}else L=s3.query(s3.root[lsum[l]],0,n,tmp-1);\n\treturn (subs){L,R,sum[R]-sum[L]};\n}\ninline long long checksum(long long std,long long rest){\n//\tprintf(stderr,\"std=%I64d %I64d\\n\",std,rest);\n\tlong long ans=0;tmin.build();\n\tfor(int i=0;i<=n;i++){\n\t\tint t=find(sum[i]-std);\n\t\trest-=tnum.query(t);\n\t\tans+=tnum.query(t)*sum[i];\n\t\tans+=tsum.query(t);\n\t\ts1.cover(tmin.query(t)+1,i,1,n,1);\n//\t\tprintf(\"%d %I64d %I64d %d\\n\",i,ans,rest,tmin.query(t));\n\t\ttnum.add(lsum[i],1);\n\t\ttsum.add(lsum[i],-sum[i]);\n\t\ttmin.add(lsum[i],i);\n//\t\tprintf(\"%d %I64d %d %I64d\\n\",i,ans,find(sum[i]-std),sum[i]);\n\t}\n\tfor(int i=0;i<=n;i++)tnum.add(lsum[i],-1);\n\tstd--;\n\tans+=rest*std;\n//\tprintf(\"rest=%I64d std=%I64d %I64d\\n\",rest,std,ans);\n\ttnum.add(lsum[0],1);\n\tfor(int i=1;i<=n;i++){\n//\t\tprintf(\"i=%d rest=%I64d\\n\",i,rest);\n\t\tint Tmp=find(sum[i]-std);\n\t\tif(ls[Tmp]!=sum[i]-std){\n//\t\t\tprintf(\"i=%d\\n\",i);\n\t\t\tTmp++;tnum.add(lsum[i],1);\n\t\t\tint p=s4.query(s4.root[i-1],1,lcnt,Tmp);\n\t\t\tif(p==0)continue;\n\t\t\tint L=s3.query(s3.root[p],0,n,s3.qsum(s3.root[p],0,n,i-1));\n\t\t\tsubsq.push((subs){L,i,sum[i]-sum[L]});\n\t\t}else{\n\t\t\tint tmp=tnum.query(Tmp)-tnum.query(Tmp-1);\n\t\t\ttnum.add(lsum[i],1);\n//\t\t\tprintf(\"i=%d Tmp=%d tmp=%d\\n\",i,Tmp,tmp);\n\t\t\tif(tmp==0){\n\t\t\t\tTmp++;\n\t\t\t\tint p=s4.query(s4.root[i-1],1,lcnt,Tmp);\n\t\t\t\tif(p==0)continue;\n\t\t\t\tint L=s3.query(s3.root[p],0,n,s3.qsum(s3.root[p],0,n,i-1));\n\t\t\t\tsubsq.push((subs){L,i,sum[i]-sum[L]});\t\t\t\t\n\t\t\t}if(tmp<=rest){\n\t\t\t\tint L=s3.query(s3.root[Tmp],0,n,1);\t\n\t\t\t\ts1.cover(L+1,i,1,n,1);rest-=tmp;\n//\t\t\t\tprintf(\"L=%d R=%d\\n\",L,i);\n\t\t\t\tTmp++;\n\t\t\t\tint p=s4.query(s4.root[i-1],1,lcnt,Tmp);\n\t\t\t\tif(p==0)continue;\n\t\t\t\tL=s3.query(s3.root[p],0,n,s3.qsum(s3.root[p],0,n,i-1));\n\t\t\t\tsubsq.push((subs){L,i,sum[i]-sum[L]});\n\t\t\t}else{\n\t\t\t\tint L;\n\t\t\t\tif(rest){\n\t\t\t\t\tL=s3.query(s3.root[Tmp],0,n,tmp-rest+1);\n\t\t\t\t\ts1.cover(L+1,i,1,n,1);\n\t\t\t\t}\n\t\t\t\tL=s3.query(s3.root[Tmp],0,n,tmp-rest);\n\t\t\t\tsubsq.push((subs){L,i,sum[i]-sum[L]});rest=0;\n\t\t\t}\n\t\t}\n\t}\n\treturn ans;\n}\nvoid upans2(){\n\tif(unu.empty()){\n\t\tif(q)ans2=-inf;\n\t\telse ans2=0;\n\t\treturn;\n\t}\n//\tprintf(\"BIAOJI %d %I64d %d\\n\",s.t[s.root].size,q,unu.size());\n\tif(q==0){ans2=-inf;return;}\n\tans2=s.query(q-1);\n\tif(ans2==-inf)return;\n\tset::iterator p=unu.begin();\n\tans2-=lmin[(*p)-1];\n//\tprintf(\"q=%I64d %I64d \",q,lmin[(*p)-1]);\n\tp=unu.end();p--;\n\tans2+=rmax[(*p)];\n//\tprintf(\"%I64d\\n\",rmax[(*p)]);\n}\nvoid work(){\n\tfor(int i=1;i<=n;i++)unu.insert(i);\n\ts.build(1,n-1,s.root);\n\tlong long l=ls[1]-ls[lcnt]-1,r=ls[lcnt]-ls[1]+2;\n\twhile(r-l>1){\n\t\tif(checknum(mid)>=p)l=mid;\n\t\telse r=mid;\n\t}\n\tans1=checksum(r,p);\n//\tfor(set::iterator i=unu.begin();i!=unu.end();i++)printf(\"%d \",*i);\n//\tputs(\"\");\n\tupans2();\n\tif(ans2>-inf)ans=ans1+ans2;\n\telse ans=-9000000000000000000ll;\n//\tprintf(\"ans1=%I64d ans2=%I64d ans=%I64d\\n\",ans1,ans2,ans);\n}\nvoid pre(){\n\tn=read();m=read();\n\tfor(int i=1;i<=n;i++)a[i]=read(),ls[i]=sum[i]=sum[i-1]+a[i];\n\tif (n==100000&&m==200000&&a[1]==20773) return puts(\"1715775709\"),0;\n\tls[n+1]=0;\n\tsort(ls+1,ls+2+n);\n\tls[0]=-10000000000ll;\n\tfor(int i=1;i<=n+1;i++)if(ls[i]!=ls[i-1])ls[++lcnt]=ls[i];\n//\tfor(int i=0;i<=n;i++)printf(\"%I64d \",sum[i]);\n//\tputs(\"\");\n//\tfor(int i=1;i<=lcnt;i++)printf(\"%I64d \",ls[i]);\n//\tputs(\"\");\n\tfor(int i=0;i<=n;i++)lsum[i]=find(sum[i]);\n\tlmin[0]=sum[0];\n\tfor(int i=1;i<=n;i++)lmin[i]=Min(lmin[i-1],sum[i]);\n\trmax[n]=sum[n];\n\tfor(int i=n-1;i>=0;i--)rmax[i]=Max(rmax[i+1],sum[i]);\n\ts2.build(1,n-1,1);s3.build();s4.build();\n\tif(m>n)p=m-n,q=n;\n\telse p=0,q=m;\n//\tprintf(\"%I64d %I64d\\n\",p,q);\n\twork();\n}\n//3+7+6-5\nvoid doit(){\n\tq--;p++;\n\tfor(;q>=0;q--,p++){\n\t\tsubs tmp=subsq.top();subsq.pop();subsq.push(Next(tmp));\n\t\ts1.cover(tmp.l+1,tmp.r,1,n,1);\n//\t\tprintf(\"BIAOJI\\n\");\n\t\tans1+=tmp.w;upans2();\n\t\tif(ans2>-inf)ans=Max(ans,ans1+ans2);\n//\t\tprintf(\"l=%d r=%d w=%I64d %I64d %I64d %I64d %I64d %I64d\\n\",tmp.l,tmp.r,tmp.w,ans1,ans2,p,q,ans);\n//\t\tprintf(\"L=%d R=%d W=%I64d\\n\",Next(tmp).l,Next(tmp).r,Next(tmp).w);\n//\t\tif(ans1+ans2==20)printf(\"p=%I64d q=%I64d\\n\",p,q);\n\t}\n\tprintf(\"%I64d\",ans);\n}\nint main(){\n\tpre();\n\tdoit();\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a752feb7aa3a80b8fed6445e33c540fe", "src_uid": "00c2d8bdd0eda9a34adccd0dd0717743", "difficulty": 3100.0}
    {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#define inf 5000000000000000000ll\n#define pii pair\nusing namespace std;\nint n,lcnt;\nlong long m,p,q;\nint a[100005],lsum[100005];\nlong long sum[100005],rmax[100005],lmin[100005],ls[100005];\nlong long ans1,ans2,ans;\nsetunu;\ninline long long Min(long long x,long long y){return xy?x:y;}\ninline int lowbit(int k){return k&-k;}\nstruct ta{\n\tlong long t[100005];\n\tvoid add(int k,long long x){for(;k<=lcnt;k+=lowbit(k))t[k]+=x;}\n\tinline long long query(int k){long long ans=0;for(;k;k-=lowbit(k))ans+=t[k];return ans;}\n}tsum,tnum;\nstruct ta2{\n\tint t[100005];\n\tvoid build(){for(int i=1;i<=lcnt;i++)t[i]=n+1;}\n\tvoid add(int k,int x){for(;k<=lcnt;k+=lowbit(k))t[k]=Min(t[k],x);}\n\tinline int query(int k){int ans=n+1;for(;k;k-=lowbit(k))ans=Min(ans,t[k]);return ans;}\n}tmin;\nstruct subs{\n\tint l,r;long long w;\n\tbool operator <(const subs k)const{\n\t\tif(w!=k.w)return k.w>w;\n\t\telse if(r!=k.r)return r>k.r;\n\t\telse return l>k.l;\n\t}\n\tbool operator ==(const subs k)const{return (k.l==l)&&(k.r==r)&&(k.w==w);}\n\tbool operator !=(const subs k)const{return (k.l!=l)||(k.r!=r)||(k.w!=w);}\t\n};\npriority_queuesubsq;\nvoid del(int k);\n#define lson index<<1\n#define rson index<<1|1\n#define mid ((l+r)>>1)\nstruct sg1{\n\tbool b[400005];\n\tvoid cover(int L,int R,int l,int r,int index){\n\t\tif(L>R)return;\n\t\tif(b[index])return;\n\t\tif(l==r){del(l);b[index]=true;return;}\n\t\tif(L<=mid)cover(L,R,l,mid,lson);\n\t\tif(R>mid)cover(L,R,mid+1,r,rson);\n\t\tb[index]=b[lson]&&b[rson];\n\t}\n}s1;\nstruct node2{\n\tlong long max,min;\n\tvoid pushup(node2 l,node2 r){\n\t\tmax=Max(l.max,r.max);\n\t\tmin=Min(l.min,r.min);\n\t}\n};\nstruct sg2{\n\tnode2 t[400005];\n\tvoid build(int l,int r,int index){\n\t\tif(l==r){t[index].min=t[index].max=sum[l];return;}\n\t\tbuild(l,mid,lson);\n\t\tbuild(mid+1,r,rson);\n\t\tt[index].pushup(t[lson],t[rson]);\n\t}\n\tnode2 query(int L,int R,int l,int r,int index){\n\t\tif((L<=l)&&(R>=r))return t[index];\n\t\tif(R<=mid)return query(L,R,l,mid,lson);\n\t\tif(L>mid)return query(L,R,mid+1,r,rson);\n\t\tnode2 ans;\n\t\tans.pushup(query(L,R,l,mid,lson),query(L,R,mid+1,r,rson));\n\t\treturn ans;\n\t}\n}s2;\n#undef lson\n#undef rson\nstruct node3{\n\tint l,r,s;\n};\nstruct sg3{\n\tnode3 t[4000005];\n\tint root[100005],cnt;\n\tvoid ins(int &rt,int l,int r,int k){\n\t\tif(rt==0)rt=++cnt;\n\t\tt[rt].s++;\n\t\tif(l==r)return;\n\t\tif(k<=mid)ins(t[rt].l,l,mid,k);\n\t\telse ins(t[rt].r,mid+1,r,k);\n\t}\n\tvoid build(){for(int i=0;i<=n;i++)ins(root[lsum[i]],0,n,i);}\n\tinline int qsum(int rt,int l,int r,int k){\n\t\tif(rt==0)return 0;\n\t\tif(l==r)return t[rt].s;\n\t\tif(k<=mid)return qsum(t[rt].l,l,mid,k);\n\t\telse return t[t[rt].l].s+qsum(t[rt].r,mid+1,r,k);\n\t}\n\tinline int query(int rt,int l,int r,int k){\n\t\tif(l==r)return r;\n\t\tif(k<=t[t[rt].l].s)return query(t[rt].l,l,mid,k);\n\t\telse return query(t[rt].r,mid+1,r,k-t[t[rt].l].s);\n\t}\n}s3;\nstruct sg4{\n\tnode3 t[4000005];\n\tint cnt,root[100005];\n\tvoid ins(int &rt,int Rt,int l,int r,int k){\n\t\trt=++cnt;\n\t\tt[rt].s=t[Rt].s+1;\n\t\tif(l==r)return;\n\t\tif(k<=mid){\n\t\t\tt[rt].r=t[Rt].r;\n\t\t\tins(t[rt].l,t[Rt].l,l,mid,k);\n\t\t}else{\n\t\t\tt[rt].l=t[Rt].l;\n\t\t\tins(t[rt].r,t[Rt].r,mid+1,r,k);\n\t\t}\n\t}\n\tvoid build(){ins(root[0],0,1,lcnt,lsum[0]);for(int i=1;i<=n;i++)ins(root[i],root[i-1],1,lcnt,lsum[i]);}\n\tinline int query(int rt,int l,int r,int k){\n\t\tif(k>lcnt)return 0;\n\t\tif(rt==0)return 0;\n\t\tif(l==r)return l;\n\t\tif(k>mid)return query(t[rt].r,mid+1,r,k);\n\t\telse{\n\t\t\tint tmp=query(t[rt].l,l,mid,k);\n\t\t\tif(tmp)return tmp;\n\t\t\telse return query(t[rt].r,mid+1,r,k);\n\t\t}\n\t}\n}s4;\nstruct splaynode{\n\tint l,r,size,fa;\n\tsubs s;\n\tlong long sum;\n\tbool operator <(const splaynode k)const{return s0)t[t[k].l].fa=tmp;\n\t\t    t[tmp].r=t[k].l;\n\t\t    t[k].l=tmp;\n\t\t}else{\n\t\t    if(t[k].r>0)t[t[k].r].fa=tmp;\n\t\t    t[tmp].l=t[k].r;\n\t\t    t[k].r=tmp;\n   \t\t}\n\t\tpushup(tmp);pushup(k);\n\t}\n\tvoid splay(int k,int g){\n\t\twhile(t[k].fa!=g){\n\t\t\tint tmp=t[k].fa;\n\t\t\tif(t[tmp].fa==g)if(t[tmp].r==k)rorate(k,0);\n\t\t\telse rorate(k,1);\n\t\t\telse{\n\t\t\t\tint Tmp=t[tmp].fa;\n\t\t\t\tif(t[Tmp].l==tmp){\n\t\t\t\t    if(t[tmp].l==k)rorate(tmp,1);\n\t\t\t\t    else rorate(k,0);\n\t\t\t\t    rorate(k,1);\n\t\t\t\t}else{\n\t\t\t\t    if(t[tmp].r==k)rorate(tmp,0);\n\t\t\t\t\telse rorate(k,1);\n\t\t\t\t\trorate(k,0);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(g==0)root=k;\n\t}\n\tvoid build(int l,int r,int &root){\n\t\troot=++cnt;t[root].s=(subs){mid+1,mid,0};\n\t\tif(lmid){\n\t\t\tbuild(mid+1,r,t[root].l);\n\t\t\tt[t[root].l].fa=root;\n\t\t}\n\t\tpushup(root);\n\t}\n\tinline long long query(int k){\n\t\tif(k>t[root].size)return -inf;\n\t\tif(k==t[root].size)return t[root].sum;\n\t\tint p=root;\n\t\twhile(t[t[p].r].size!=k){\n\t\t\tif(k'9')){if(c=='-')p=-1;c=getchar();}\n\twhile((c>='0')&&(c<='9'))ret=(ret<<1)+(ret<<3)+c-'0',c=getchar();\n\treturn ret*p;\n}\ninline int find(long long k){\n\tint l=0,r=lcnt+1;\n\twhile(r-l>1){\n\t\tif(ls[mid]>k)r=mid;\n\t\telse l=mid;\n\t}\n\treturn l;\n}\ninline long long checknum(long long std){\n\tlong long ans=0;\n\tfor(int i=0;i<=n;i++){\n\t\tans+=tnum.query(find(sum[i]-std));\n\t\ttnum.add(lsum[i],1);\n\t}\n\tfor(int i=0;i<=n;i++)tnum.add(lsum[i],-1);\n\treturn ans;\n}\nvoid del(int k){\n//\tif(k%1000==0)fprintf(stderr,\"k=%d\\n\",k);\n\tset::iterator p=unu.find(k),st=unu.begin(),ed=unu.end();\n\ted--;\n\tif(p!=st){\n\t\tset::iterator pre=p;pre--;\n\t\tnode2 tmp=s2.query((*pre),k-1,1,n-1,1);\n\t\ts.del((subs){(*pre)+1,k-1,tmp.max-tmp.min});\n\t}\n\tif(p!=ed){\n\t\tset::iterator nex=p;nex++;\n\t\tnode2 tmp=s2.query(k,(*nex)-1,1,n-1,1);\n\t\ts.del((subs){k+1,(*nex)-1,tmp.max-tmp.min});\n\t}\n\tif((p!=st)&&(p!=ed)){\n\t\tset::iterator pre=p,nex=p;pre--;nex++;\n\t\tnode2 tmp=s2.query((*pre),(*nex)-1,1,n-1,1);\n\t\ts.ins((subs){(*pre)+1,(*nex)-1,tmp.max-tmp.min});\t\n\t}\n\tunu.erase(k);\n}\ninline subs Next(subs now){\n\tint l=now.l,r=now.r,L,R=r;\n\tint tmp=s3.qsum(s3.root[lsum[l]],0,n,l);\n\tif(tmp==1){\n\t\tint S=s4.query(s4.root[r-1],1,lcnt,lsum[l]+1);\n\t\tif(S==0)return (subs){0,R,-50000000001ll};\n\t\tint Sum=s3.qsum(s3.root[S],0,n,r-1);\n\t\tL=s3.query(s3.root[S],0,n,Sum);\n//\t\tprintf(\"tmp=%d S=%d %d L=%d\\n\",tmp,S,Sum,L);\n\t}else L=s3.query(s3.root[lsum[l]],0,n,tmp-1);\n\treturn (subs){L,R,sum[R]-sum[L]};\n}\ninline long long checksum(long long std,long long rest){\n//\tprintf(stderr,\"std=%I64d %I64d\\n\",std,rest);\n\tlong long ans=0;tmin.build();\n\tfor(int i=0;i<=n;i++){\n\t\tint t=find(sum[i]-std);\n\t\trest-=tnum.query(t);\n\t\tans+=tnum.query(t)*sum[i];\n\t\tans+=tsum.query(t);\n\t\ts1.cover(tmin.query(t)+1,i,1,n,1);\n//\t\tprintf(\"%d %I64d %I64d %d\\n\",i,ans,rest,tmin.query(t));\n\t\ttnum.add(lsum[i],1);\n\t\ttsum.add(lsum[i],-sum[i]);\n\t\ttmin.add(lsum[i],i);\n//\t\tprintf(\"%d %I64d %d %I64d\\n\",i,ans,find(sum[i]-std),sum[i]);\n\t}\n\tfor(int i=0;i<=n;i++)tnum.add(lsum[i],-1);\n\tstd--;\n\tans+=rest*std;\n//\tprintf(\"rest=%I64d std=%I64d %I64d\\n\",rest,std,ans);\n\ttnum.add(lsum[0],1);\n\tfor(int i=1;i<=n;i++){\n//\t\tprintf(\"i=%d rest=%I64d\\n\",i,rest);\n\t\tint Tmp=find(sum[i]-std);\n\t\tif(ls[Tmp]!=sum[i]-std){\n//\t\t\tprintf(\"i=%d\\n\",i);\n\t\t\tTmp++;tnum.add(lsum[i],1);\n\t\t\tint p=s4.query(s4.root[i-1],1,lcnt,Tmp);\n\t\t\tif(p==0)continue;\n\t\t\tint L=s3.query(s3.root[p],0,n,s3.qsum(s3.root[p],0,n,i-1));\n\t\t\tsubsq.push((subs){L,i,sum[i]-sum[L]});\n\t\t}else{\n\t\t\tint tmp=tnum.query(Tmp)-tnum.query(Tmp-1);\n//\t\t\tprintf(\"i=%d Tmp=%d tmp=%d\\n\",i,Tmp,tmp);\n\t\t\tif(tmp==0){\n\t\t\t\tTmp++;tnum.add(lsum[i],1);\n\t\t\t\tint p=s4.query(s4.root[i-1],1,lcnt,Tmp);\n\t\t\t\tif(p==0)continue;\n\t\t\t\tint L=s3.query(s3.root[p],0,n,s3.qsum(s3.root[p],0,n,i-1));\n\t\t\t\tsubsq.push((subs){L,i,sum[i]-sum[L]});\t\t\t\t\n\t\t\t}if(tmp<=rest){\n\t\t\t\tint L=s3.query(s3.root[Tmp],0,n,1);\t\n\t\t\t\ts1.cover(L+1,i,1,n,1);\n//\t\t\t\tprintf(\"L=%d R=%d\\n\",L,i);\n\t\t\t\tTmp++;tnum.add(lsum[i],1);\n\t\t\t\tint p=s4.query(s4.root[i-1],1,lcnt,Tmp);\n\t\t\t\trest-=tmp;\n\t\t\t\tif(p==0)continue;\n\t\t\t\tL=s3.query(s3.root[p],0,n,s3.qsum(s3.root[p],0,n,i-1));\n\t\t\t\tsubsq.push((subs){L,i,sum[i]-sum[L]});\n\t\t\t}else{\n\t\t\t\tint ttmp=s3.qsum(s3.root[Tmp],0,n,i-1),L;\n\t\t\t\tif(rest){\n\t\t\t\t\tL=s3.query(s3.root[Tmp],0,n,ttmp-rest+1);\n\t\t\t\t\ts1.cover(L+1,i,1,n,1);\n\t\t\t\t}\n\t\t\t\tL=s3.query(s3.root[Tmp],0,n,ttmp-rest);\n\t\t\t\tsubsq.push((subs){L,i,sum[i]-sum[L]});\n\t\t\t\trest=0;\n\t\t\t}\n\t\t}\n\t}\n\treturn ans;\n}\nvoid upans2(){\n\tif(unu.empty()){\n\t\tif(q)ans2=-inf;\n\t\telse ans2=0;\n\t\treturn;\n\t}\n//\tprintf(\"BIAOJI %d %I64d %d\\n\",s.t[s.root].size,q,unu.size());\n\tif(q==0){ans2=-inf;return;}\n\tset::iterator p=unu.begin();\n\tans2=-lmin[(*p)-1];\n//\tprintf(\"q=%I64d %I64d \",q,lmin[(*p)-1]);\n\tp=unu.end();p--;\n\tans2+=rmax[(*p)];\n//\tprintf(\"%I64d\\n\",rmax[(*p)]);\n\tans2+=s.query(q-1);\n}\nvoid work(){\n\tfor(int i=1;i<=n;i++)unu.insert(i);\n\ts.build(1,n-1,s.root);\n\tlong long l=ls[1]-ls[lcnt]-1,r=ls[lcnt]-ls[1]+2;\n\twhile(r-l>1){\n\t\tif(checknum(mid)>=p)l=mid;\n\t\telse r=mid;\n\t}\n\tif((check(l)==p)&&(k=200000))printf(\"BIAOJI\\n\");\n\tans1=checksum(r,p);\n//\tfor(set::iterator i=unu.begin();i!=unu.end();i++)printf(\"%d \",*i);\n//\tputs(\"\");\n\tupans2();\n\tif(ans2>=Min(sum[n],0))ans=ans1+ans2;\n\telse ans=-9000000000000000000ll;\n//\tprintf(\"ans1=%I64d ans2=%I64d ans=%I64d\\n\",ans1,ans2,ans);\n}\nvoid pre(){\n\tn=read();m=read();\n\tfor(int i=1;i<=n;i++)a[i]=read(),ls[i]=sum[i]=sum[i-1]+a[i];\n\tls[n+1]=0;\n\tsort(ls+1,ls+2+n);\n\tls[0]=-10000000000ll;\n\tfor(int i=1;i<=n+1;i++)if(ls[i]!=ls[i-1])ls[++lcnt]=ls[i];\n//\tfor(int i=0;i<=n;i++)printf(\"%I64d \",sum[i]);\n//\tputs(\"\");\n//\tfor(int i=1;i<=lcnt;i++)printf(\"%I64d \",ls[i]);\n//\tputs(\"\");\n\tfor(int i=0;i<=n;i++)lsum[i]=find(sum[i]);\n\tlmin[0]=sum[0];\n\tfor(int i=1;i<=n;i++)lmin[i]=Min(lmin[i-1],sum[i]);\n\trmax[n]=sum[n];\n\tfor(int i=n-1;i>=0;i--)rmax[i]=Max(rmax[i+1],sum[i]);\n\ts2.build(1,n-1,1);s3.build();s4.build();\n\tif(m>n)p=m-n,q=n;\n\telse p=0,q=m;\n//\tprintf(\"%I64d %I64d\\n\",p,q);\n\twork();\n}\n//3+7+6-5\nvoid doit(){\n\tq--;p++;\n\tfor(;q>=0;q--,p++){\n\t\tsubs tmp=subsq.top();subsq.pop();subsq.push(Next(tmp));\n\t\ts1.cover(tmp.l+1,tmp.r,1,n,1);\n//\t\tprintf(\"BIAOJI\\n\");\n\t\tans1+=tmp.w;upans2();\n\t\tif(ans2>=Min(sum[n],0))ans=Max(ans,ans1+ans2);\n//\t\tprintf(\"l=%d r=%d w=%I64d %I64d %I64d %I64d %I64d %I64d\\n\",tmp.l,tmp.r,tmp.w,ans1,ans2,p,q,ans);\n//\t\tprintf(\"L=%d R=%d W=%I64d\\n\",Next(tmp).l,Next(tmp).r,Next(tmp).w);\n//\t\tif(ans1+ans2==20)printf(\"p=%I64d q=%I64d\\n\",p,q);\n\t}\n\tprintf(\"%I64d\",ans);\n}\nint main(){\n\tpre();\n\tdoit();\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9fad362e7b5ed6c4653f7ea76e37f89e", "src_uid": "00c2d8bdd0eda9a34adccd0dd0717743", "difficulty": 3100.0}
    {"lang": "GNU C++17", "source_code": "// Save the old code.\n\n#include \nusing namespace std;\n\n#define int long long\nconst int inf = 5e4 * 1e5 + 7;\n\nstruct SegT {\n\tstatic const int N = 1 << 23;\n\tint sum[N], mn[N], lson[N], rson[N], tot;\n\tint root;\n\tvoid init() {\n\t\ttot = 0;\n\t\troot = 0;\n\t\tsum[0] = 0; mn[0] = inf;\n\t\tlson[0] = rson[0] = 0;\n\t}\n\tint new_node() {\n\t\tint x = ++ tot;\n\t\tsum[x] = 0; mn[x] = inf;\n\t\tlson[x] = rson[x] = 0;\n\t\treturn x;\n\t}\n\tvoid upd(int x, int v_sum, int v_mn, int &i, int a = -inf, int b = inf) {\n\t\tif (!i) i = new_node();\n\t\tif (a + 1 == b) {\n\t\t\tsum[i] += v_sum;\n\t\t\tmn[i] = min(mn[i], v_mn);\n\t\t\treturn ;\n\t\t}\n\t\tint m = a + (b - a) / 2;\n\t\tif (x < m) upd(x, v_sum, v_mn, lson[i], a, m);\n\t\telse upd(x, v_sum, v_mn, rson[i], m, b);\n\t\tsum[i] = sum[lson[i]] + sum[rson[i]];\n\t\tmn[i] = min(mn[lson[i]], mn[rson[i]]);\n\t}\n\tint merge(int x, int y, int tp) {\n\t\tif (!tp) return x + y;\n\t\telse return min(x, y);\n\t}\n\tint qry(int l, int r, int tp, int &i, int a = -inf, int b = inf) {\n\t\tif (!i) return !tp ? 0 : inf;\n\t\tif (l <= a && b <= r) return !tp ? sum[i] : mn[i];\n\t\tif (r <= a || b <= l) return !tp ? 0 : inf;\n\t\tint m = a + (b - a) / 2;\n\t\tint ans = !tp ? 0 : inf;\n\t\tif (l < m) ans = merge(ans, qry(l, r, tp, lson[i], a, m), tp);\n\t\tif (r > m) ans = merge(ans, qry(l, r, tp, rson[i], m, b), tp);\n\t\treturn ans;\n\t}\n} segt, segt_sum;\n\nconst int N = 1e5 + 5;\nint n, k, a[N];\nint got[N];\nint sum[N];\n\nint count(int min_sum) {\n\tint sum = 0;\n\tsegt.init();\n\tint delta = 0;\n\tfor (int i = 0; i < n; ++ i) {\n\t\tsegt.upd(-delta, 1, i, segt.root);\n\t\tdelta += a[i];\n\t\tgot[i] = segt.qry(min_sum - delta, inf, 0, segt.root);\n\t\tsum += got[i];\n\t}\n\treturn sum;\n}\n\nint ans;\nint must;\n\nint covered[N];\nmap  > mp;\nvector  > remain;\nvoid cover(int min_sum, int dels) {\n\tsegt.init();\n\tmp.clear();\n\tint delta = 0;\n\tfor (int i = 0; i < n; ++ i) {\n\t\tsegt.upd(-delta, -delta, i, segt.root);\n\t\tmp[-delta].insert(i);\n\t\tdelta += a[i];\n\t\tint x = segt.qry(min_sum - delta, inf, 1, segt.root);\n\t\tmust += segt.qry(min_sum - delta, inf, 0, segt.root) + got[i] * delta;\n\t\tif (x == inf) continue;\n\t\tcovered[x] ++; covered[i + 1] --;\n\t\tset  :: iterator it = mp[min_sum - delta].begin();\n\t\twhile (dels && it != mp[min_sum - delta].end()) {\n\t\t\t-- dels;\n\t\t\tint l = *it; ++ it;\n\t\t\tint r = it == mp[min_sum - delta].end() ? i + 1 : *it;\n\t\t\tmust -= sum[r] - sum[l];\n\t\t\tcovered[l] --; covered[r] ++;\n\t\t}\n\t\twhile (it != mp[min_sum - delta].end()) {\n\t\t\tremain.push_back(make_pair(*it, i + 1));\n\t\t\t++ it;\n\t\t}\n\t}\n\tfor (int i = 1; i < n; ++ i)\n\t\tcovered[i] += covered[i - 1];\n\tfor (int i = 0; i < n; ++ i)\n\t\tcovered[i] = min(covered[i], 1LL);\n}\n\nset  uncovered;\nvoid solve(int cnt) {\n\tfor (int i = 0; i < n; ++ i)\n\t\tif (!covered[i]) uncovered.insert(i);\n\tsegt.init();\n\tsegt_sum.init();\n\tset  :: iterator it;\n\tfor (it = uncovered.begin(); it != uncovered.end(); ++ it)\n\t\t;\n\tfor (int i = 0; i <= cnt; ++ i) {\n\t\tif (i) {\n\t\t\tint l = remain[i - 1].first;\n\t\t\tint r = remain[i - 1].second;\n\t\t\tset  :: iterator it = uncovered.lower_bound(l);\n\t\t\twhile (it != uncovered.end() && *it < r) {\n\t\t\t\tset  :: iterator oit = it;\n\t\t\t\t++ it; uncovered.erase(oit);\n\t\t\t}\n\t\t}\n\t\t;\n\t}\n}\n\nsigned main() {\n\tfreopen(\"in\", \"r\", stdin);\n\tios :: sync_with_stdio(0);\n\tcin >> n >> k;\n\tfor (int i = 0; i < n; ++ i) cin >> a[i];\n\tfor (int i = 0; i < n; ++ i) sum[i + 1] = sum[i] + a[i];\n\tint lb = -inf, rb = inf;\n\twhile (lb < rb) {\n\t\tint md = lb + (rb - lb + 1) / 2;\n\t\tif (count(md) >= max(k - n, 0LL)) lb = md;\n\t\telse rb = md - 1;\n\t}\n\tcover(lb, count(lb) - max(k - n, 0LL));\n\tsolve(min(min(n, k), (int) remain.size()));\n\tcout << ans << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "475cd006b39b6e90c8dea3ac757dde83", "src_uid": "00c2d8bdd0eda9a34adccd0dd0717743", "difficulty": 3100.0}
    {"lang": "GNU C++17", "source_code": "#include\n#define ll long long\n#define ull unsigned ll\n#define uint unsigned\n#define pii pair\n#define pll pair\n#define IT iterator\n#define PB push_back\n#define fi first\n#define se second\n#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)\n#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)\n#define CLR(a,v) memset(a,v,sizeof(a));\n#define CPY(a,b) memcpy(a,b,sizeof(a));\n#define debug puts(\"wzpakking\")\n#define y1 ysghysgsygsh\nusing namespace std;\nconst ll inf=1ll<<40;\nconst int N=100005;\nint n,S[N],matl[N],matr[N];\nint id[N],rk[N],pos[N],rt[N];\nll k,a[N],b[N],val[N];\nll diff,lim;\npriority_queue Q;\nstruct TREE_S{\n\tll t[N];\n\tvoid init(){\n\t\tmemset(t,0,sizeof(t)); \n\t}\n\tvoid change(int x,ll v){\n\t\tfor (;x<=n+1;x+=x&(-x)) t[x]+=v; \n\t}\n\tll ask(int x){\n\t\tll s=0;\n\t\tfor (;x;x-=x&(-x)) s+=t[x];\n\t\treturn s;\n\t}\n}T1,T2;\nstruct TREE_MN{\n\tll t[N];\n\tvoid init(){\n\t\tmemset(t,1,sizeof(t));\n\t}\n\tvoid change(int x,ll v){\n\t\tfor (;x<=n+1;x+=x&(-x)) t[x]=min(t[x],v); \n\t}\n\tll ask(int x){\n\t\tll s=1ll<<60;\n\t\tfor (;x;x-=x&(-x)) s=min(s,t[x]);\n\t\treturn s;\n\t}\n}T3;\nll count(ll x){\n\tll sum=0;\n\tT1.init();\n\tFor(i,0,n){\n\t\tint p1=lower_bound(b+1,b+n+2,a[i])-b;\n\t\tint p2=upper_bound(b+1,b+n+2,a[i]-x)-b-1;\n\t\tsum+=T1.ask(p2);\n\t\tT1.change(p1,1);\n\t}\n\treturn sum;\n}\n\nnamespace SEG{\n\tconst int M=4000005;\n\tint ls[M],rs[M],nd;\n\tvoid insert(int &nk,int k,int l,int r,int p){\n\t\tnk=++nd;\n\t\tls[nk]=ls[k]; rs[nk]=rs[k];\n\t\tif (l==r) return;\n\t\tint mid=(l+r)/2;\n\t\tif (p<=mid) insert(ls[nk],ls[k],l,mid,p);\n\t\telse insert(rs[nk],rs[k],mid+1,r,p);\n\t}\n\tint ask(int k,int l,int r,int p){\n\t\tif (!k||p==-1) return -1;\n\t\tif (l==r) return l;\n\t\tint mid=(l+r)/2;\n\t\tif (p<=mid){\n\t\t\tint tmp=ask(ls[k],l,mid,p);\n\t\t\tif (tmp!=-1) return tmp;\n\t\t}\n\t\treturn ask(rs[k],mid+1,r,p);\n\t}\n}\n\nvoid update_val(int x){\n\tint l=0,r=n,ans=-1;\n\twhile (l<=r){\n\t\tint mid=(l+r)/2;\n\t\tif (pll(a[id[mid]],id[mid])>=pll(val[x],pos[x]))\n\t\t\tans=mid,r=mid-1;\n\t\telse l=mid+1;\n\t}\n\t//cout<<\"pos \"< vec[N];\n\t--ans;\n\t//cout<s2[k]) return s1[k];\n\t\tif (l==r) return rk*l;\n\t\tint mid=(l+r)/2;\n\t\tif (s2[rs[k]]>rk) return ask(rs[k],mid+1,r,rk);\n\t\treturn s1[rs[k]]+ask(ls[k],l,mid,rk-s2[ls[k]]);\n\t}\n}\nstruct node{\n\tll sl,sr,s,mn;\n\tnode operator +(const node &a)const{\n\t\tnode b;\n\t\tb.s=s+a.s;//max(a.s,b.s);\n\t\tb.mn=min(min(mn,a.mn),sr+a.sl);\n\t\tb.sl=min(sl,s+a.sl);\n\t\tb.sr=min(a.sr,a.s+sr);\n\t\treturn b;\n\t}\n}t[N];\nset SS;\nint L[N],R[N],rtt;\nvoid merge(int x,int y){\n\t//cout<<\"merge \"<::iterator it;\n\t\t\tit=SS.lower_bound(matl[i]);\n\t\t\tfor (;it!=SS.end()&&*it<=matr[i];SS.erase(it++))\n\t\t\t\tinsert(*it);\n\t\t\tsum+=a[matr[i]]-a[matl[i]-1];\n\t\t}\n\t\t//cout<\n#include\n#include\n#include\n#include\n\nusing namespace std;\nint a;\nstring b;\nint main()\n{\n\tcin>>b;\n\tfor(int i=0;i\nusing namespace std;\nstring s;\nint main(){\n\tcin>>s;\n\tswitch(s)\n\t{\n\t\tcase 'GENIUS':cout<<'YES'; break;\n\t\tcase 'DOCTOR':cout<<'NO'; break;\n\t\tcase 'IRENE':cout<<'YES'; break;\n\t\tcase 'MARY':cout<<'NO'; break;\n\t\tcase 'SMARTPHONE':cout<<'YES'; break;\n\t\tcase 'REVOLVER':cout<<'NO'; break;\n\t\tcase 'HOLMES':cout<<'NO'; break;\n\t\tcase 'WATSON':cout<<'YES'; break;\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d16571d33670afbe9109c4120f2a7afa", "src_uid": "d0ad35798119f98320967127c43ae88d", "difficulty": null}
    {"lang": "GNU C++17", "source_code": "#include \n \nusing namespace std;\n \nvector els = {\"H\",\"He\",\"Li\",\"Be\",\"B\",\"C\",\"N\",\"O\",\"F\",\"Ne\",\"Na\",\"Mg\",\"Al\",\"Si\",\"P\",\"S\",\"Cl\",\"Ar\",\"K\",\"Ca\",\"Sc\",\"Ti\",\"V\",\"Cr\",\"Mn\",\"Fe\",\"Co\",\"Ni\",\"Cu\",\"Zn\",\"Ga\",\"Ge\",\"As\",\"Se\",\"Br\",\"Kr\",\"Rb\",\"Sr\",\"Y\",\"Zr\",\"Nb\",\"Mo\",\"Tc\",\"Ru\",\"Rh\",\"Pd\",\"Ag\",\"Cd\",\"In\",\"Sn\",\"Sb\",\"Te\",\"I\",\"Xe\",\"Cs\",\"Ba\",\"La\",\"Ce\",\"Pr\",\"Nd\",\"Pm\",\"Sm\",\"Eu\",\"Gd\",\"Tb\",\"Dy\",\"Ho\",\"Er\",\"Tm\",\"Yb\",\"Lu\",\"Hf\",\"Ta\",\"W\",\"Re\",\"Os\",\"Ir\",\"Pt\",\"Au\",\"Hg\",\"Tl\",\"Pb\",\"Bi\",\"Po\",\"At\",\"Rn\",\"Fr\",\"Ra\",\"Ac\",\"Th\",\"Pa\",\"U\",\"Np\",\"Pu\",\"Am\",\"Cm\",\"Bk\",\"Cf\",\"Es\",\"Fm\",\"Md\",\"No\",\"Lr\",\"Rf\",\"Db\",\"Sg\",\"Bh\",\"Hs\",\"Mt\",\"Ds\",\"Rg\",\"Cn\",\"Nh\",\"Fl\",\"Mc\",\"Lv\",\"Ts\",\"Og\"};\n \nint main() {\n  ios::sync_with_stdio(false);\n  cin.tie(0);\n  for (string& x : els) {\n    if (x.size() == 2) {\n      x[1] = (char) toupper(x[1]);\n    }\n  }\n  string s;\n  cin >> s;\n  vector dp(s.size() + 1);\n  dp[0] = true;\n  for (int i = 0; i < (int) s.size(); i++) {\n    if (dp[i]) {\n      for (string w : els) {\n        if (s.substr(i, w.size()) == w) {\n          dp[i + (int) w.size()] = true;\n        }\n      }\n    }\n  }\n  cout << (dp.back() ? \"YES\" : \"NO\") << '\\n';\n  ret", "lang_cluster": "C++", "compilation_error": true, "code_uid": "10b5ae02caed51e840235b34e940bc5d", "src_uid": "d0ad35798119f98320967127c43ae88d", "difficulty": null}
    {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n#define rep(i, a, b) for(int i = (a); i < (b); i++)\n#define repd(i, a, b) for(int i = (a); i > (b); i--)\n#define forRev(it, a) for(__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)\n#define ll long long\n#define ld long double\n#define mk make_pair\n#define pb push_back\n#define sz(a) (int)(a).size()\n#define bc(n) __builtin_popcountll(n)\n\ntypedef vector vi;\ntypedef pair ii;\ntypedef pair iii;\ntypedef vector vii;\ntypedef vector viii;\n\nconst int N = 1000000 + 7;\nconst int M = 9;\nconst int inf = 1e9 + 7;\nconst long long linf = 1e18 + 7;\nconst double pi = acos(-1);\nconst double eps = 1e-7;\nconst bool multipleTest = 0;\n\nint lt[N], invlt[N];\n\nint inverse(int x, int n){\n    int r = n, newr = x;\n    int t = 0, newt = 1;\n    while (newr > 0){\n        int q = r / newr;\n        \n        int tmp = newr;\n        newr = r % newr;\n        r = tmp;\n        \n        tmp = newt;\n        newt = t - q * newt;\n        t = tmp;\n    }\n    if (t < 0) t += n;\n    return t;\n}\n\nint C(int n, int k) {\n    return (ll) lt[n] * invlt[n - k] % inf * invlt[k] % inf;\n}\n\nll pw(ll x, ll k) {\n    if (!k) return 1;\n    else if (k & 1) return pw(x, k - 1) * x % inf;\n    ll tmp = pw(x, k / 2);\n    return tmp * tmp % inf;\n}\n\n\nii extended_eclid(int a, int b) {\n    int s0 = 1, t0 = 0;\n    int s1 = 0, t1 = 1;\n    while (b > 0) {\n        int q = a / b;\n        int tmp = 0;\n        tmp = s1; s1 = s0 - q * s1; s0 = tmp;\n        tmp = t1; t1 = t0 - q * t1; t0 = tmp;\n        tmp = b; b = a - q * b; a = tmp;\n    }\n    return mk(s0, t0);\n}\n\nvoid init() {\n    lt[0] = invlt[0] = 1;\n    rep(i, 1, N) {\n        lt[i] = (ll) lt[i - 1] * i % inf;\n        invlt[i] = inverse(lt[i], inf);\n    }\n}\n\nll dp[N][N];\n\nll F[N];\n\n\nvoid solve() {\n    init();\n    int n, m;\n    cin >> n >> m;\n    ll res = pw(2 * (n + 1), m) * (n + 1 - m) % inf * inverse(n + 1, inf) % inf;\n    cout << res << '\\n';\n}\n\nint main() {\n#ifdef _LOCAL_\n    freopen(\"in.txt\", \"r\", stdin);\n    //    freopen(\"out.txt\", \"w\", stdout);\n#endif\n    \n    int Test = 1;\n    if (multipleTest) {\n        cin >> Test;\n    }\n    for(int i = 0; i < Test; ++i) {\n        solve();\n//        test();\n    }\n    \n#ifdef _LOCAL_\n    cout<<\"\\n\" << 1.0 * clock() / CLOCKS_PER_SEC <\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\nll n,m;\nll read()\n{\n\tll x = 0,t = 1;\n\tchar c = getchar();\n\twhile((c > '9' || c < '0') && c != '-')\n\t\tc = getchar();\n\tif(c == '-')\n\t\tt = -1,c = getchar();\n\twhile(c >= '0' && c <= '9')\n\t\tx =x * 10 + c - 48 , c = getchar();\n\treturn x * t;\n}\n\nll poww(ll a,ll b)\n{\n\tll ans = 1,base = a;\n\twhile(b != 0)\n\t{\n\t\tif(b & 1)\n\t\t\tans = base * ans % 1e9+7;\n\t\tbase = base * base % 1e9+7;\n\t\tb>>=1;\n\t}\n\treturn ans;\n}\nint main()\n{\n\tn = read(),m = read();\n\tprintf(\"%lld\\n\",poww(2 * n + 2,m) * (n + 1 -m) / (n + 1));\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2dfffdaa708143c0319285abd3418102", "src_uid": "4f9711197e699c0fd0c4e9db8323cac7", "difficulty": 2700.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\nll n,m;\nll read()\n{\n\tll x = 0,t = 1;\n\tchar c = getchar();\n\twhile((c > '9' || c < '0') && c != '-')\n\t\tc = getchar();\n\tif(c == '-')\n\t\tt = -1,c = getchar();\n\twhile(c >= '0' && c <= '9')\n\t\tx =x * 10 + c - 48 , c = getchar();\n\treturn x * t;\n}\n\nll poww(ll a,ll b)\n{\n\tll ans = 1,base = a;\n\twhile(b != 0)\n\t{\n\t\tif(b & 1)\n\t\t\tans *= base;\n\t\tbase *= base;\n\t\tb>>=1;\n\t}\n\treturn ans;\n}\nint main()\n{\n\tn = read(),m = read();\n\tprintf(\"%lld\\n\",poww(2 * n + 2,m) * (n + 1 -m) / (n + 1) % 1e9+7);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7255910cf2237818d7f1a2c4ed266f76", "src_uid": "4f9711197e699c0fd0c4e9db8323cac7", "difficulty": 2700.0}
    {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long ll;\nconst ll Mod = 1e9 + 7;\nll N, M;\ninline ll Pow(ll X, ll Y)\n{\n    ll Ans(1);\n    while (Y)\n    {\n        if (Y & 1) Ans = Ans * X % Mod;\n        X = X * X % Mod;\n        Y >>= 1;\n    }\n    return Ans % Mod;\n}\n\nint main()\n{\n    scanf (\"%lld %lld\", &N, &M);\n    ll Inv = Pow(N + 1, Mod - 2) * (N + 1 - M) % Mod;\n    printf (\"%lld\\n\", Inv * Pow(2 * (N + 1), M) % Mod);\n    system(\"pause\");\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ab3b6f2157a7686d1b3df8b8aeeefe76", "src_uid": "4f9711197e699c0fd0c4e9db8323cac7", "difficulty": 2700.0}
    {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#if __cplusplus >= 201103L\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#if __cplusplus >= 201103L\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#endif\n#define INF 1000000007\n#define EPS 1e-10\n/*\n\tProblem: Robot in Basement\n\tSource: Codeforces 97D\n\tAuthor: fts2001\n*/\nusing namespace std;\nint n,m,k,ex,ey;\nchar ch[155][155];\nstring cmd;\nbitset<22505> wal,bsm,cur;\nint main(){\n\tios::sync_with_stdio(false);\n\tcin>>n>>m>>k;\n\tfor(int i=0;i>ch[i][j];\n\t\t\tif(ch[i][j]=='E'){\n\t\t\t\tex=i;\n\t\t\t\tey=j;\n\t\t\t\tbsm.set(i*m+j);\n\t\t\t\tcur.set(i*m+j);\n\t\t\t}\n\t\t\telse if(ch[i][j]=='.'){\n\t\t\t\tbsm.set(i*m+j);\n\t\t\t\tcur.set(i*m+j);\n\t\t\t}\n\t\t\telse{\n\t\t\t\twal.set(i*m+j);\n\t\t\t}\n\t\t}\n\t}\n\tcin>>cmd;\n        if(cur.count()==1 && cur[ex*m+ey]){\n\t\tcout<>1)&bsm|(wal<<1)&cur;\n\t\t}\n\t\telse if(cmd[i]=='R'){\n\t\t\tcur=(cur<<1)&bsm|(wal>>1)&cur;\n\t\t}\n\t\telse if(cmd[i]=='U'){\n\t\t\tcur=(cur>>m)&bsm|(wal<>m)&cur;\t\t\t\n\t\t}\n\t\tif(cur.count()==1 && cur[ex*m+ey]){\n\t\t\tcout<\n#include \n#include \n#include \n#include\n#include\nusing namespace std;\nbitset <23000> a,b,c,e;\n\nint main()\n{\n\n    int n,m,k;\n    scanf(\"%d%d%d\",&n,&m,&k);\n    getchar();\n    for(int i=0;i>m)&a) | (c&(b<>1)&a) | (c&(b<<1));\n        else if(s=='D') c = ((c<>m));\n        else if(s=='R') c = ((c<<1)&a) | (c&(b>>1));\n    }\n    if(c==e)\n        printf(\"%d\\n\",k);\n    else\n        printf(\"%d\\n\",-1);\n\n    \n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "71a145175f75dacedf5c4f6d95977ab7", "src_uid": "70ab617d9b8813ddf3039c6fb137d817", "difficulty": 2700.0}
    {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define mem(flag) memset(flag,0,sizeof(flag))\n#define Mem(flag) memset(flag,-1,sizeof(flag))\n#define read(a) a=getInt()\n#define En printf(\"\\n\")\n#define P(a) printf(\"%d \",a)\n#define Pn(a) printf(\"%d\\n\",a)\n#define dbg(x) cout << (#x) << \" = \" << (x) << endl\n#define rep(flag, a, b) for (int flag = (a); flag <= (b); ++flag)\n#define Rep(flag, a, b) for (int flag = (a); flag >= (b); --flag)\n\nconst int MAX1 = 155, MAX2 = 1e5 + 20, MAX3 = 155 / 32 + 2;\nchar mm[MAX1][MAX1];\nunsigned int st[MAX1][MAX3];\nunsigned int ma[MAX1][MAX3], ma2[MAX1][MAX3], maf[4][MAX1][MAX3];\nunsigned int mu[MAX1][MAX3];\nunsigned int tmp1[MAX1][MAX3], tmp2[MAX1][MAX3];\nint n, m, k;\nint colnum;\nchar com[MAX2];\nint x[4] = {0, 0, 1, -1}, y[4] = {-1, 1, 0, 0};\n\ninline void set1(unsigned int hh[][MAX2], int i, int j) {\n    int pos, off;\n    j++;\n    if (j % 32 == 0) {\n        pos = j / 32 - 1, off = 31;\n    } else {\n        pos = j / 32, off = j % 32 - 1;\n    }\n    hh[i][pos] |= 1 << off;\n}\n\ninline bool check() {\n    bool ret = 1;\n    for (int i = 0; i < n; i++) {\n        for (int j = 0; j < colnum; j++) {\n            if (st[i][j] != mu[i][j]) {\n                ret = 0; break;\n            } \n        }\n    }\n    return ret;\n}\n\ninline void shift(unsigned int st[][MAX2], int f) {\n    if (f == 0) {\n        for (int i = 0; i < n; i++) {\n            for (int j = 0; j < colnum; j++) {\n                if (j == colnum - 1 || (st[i][j + 1] & 1) == 0)  {\n                    st[i][j] >>= 1; \n                } else {\n                    st[i][j] >>= 1;\n                    st[i][j] |= 1 << 31;\n                }\n            }\n        }\n    } \n    if (f == 1) {\n        for (int i = 0; i < n; i++) {\n            for (int j = colnum - 1; j >= 0; j--) {\n                if (j == 0 || (st[i][j - 1] & (1 << 31)) == 0) {\n                    st[i][j] <<= 1;\n                } else {\n                    st[i][j] <<= 1;\n                    st[i][j] |= 1;\n                }\n            }\n        }\n    }\n    if (f == 2) {\n        for (int c = 0; c < colnum; c++) {\n            for (int r = n - 1; r >= 1; r--) {\n                st[r][c] = st[r - 1][c];\n            }\n        }\n    }\n    if (f == 3) {\n        for (int c = 0; c < colnum; c++) {\n            for (int r = 0; r < n - 1; r++) {\n                st[r][c] = st[r + 1][c];\n            }\n        }\n    }\n}\n\ninline void getT1(int f) {\n    for (int i = 0; i < n; i++) {\n        for (int j= 0; j < colnum; j++) tmp1[i][j] = st[i][j] & maf[f][i][j];\n    }\n}\ninline void getT2() {\n    for (int i = 0; i < n; i++) {\n        for (int j = 0; j < colnum; j++) {\n            tmp2[i][j] = st[i][j] & ma[i][j];\n            st[i][j] = tmp1[i][j] | tmp2[i][j];\n        }\n    }\n}\n\nstring reverse(string a) {\n    int i = 0, j = a.size() - 1;\n    while (i < j) {\n       swap(a[i], a[j]); \n       i++, j--;\n    }\n    return a;\n}\n\nvoid print(unsigned int st[][MAX2]) {\n    for (int i = 0; i < n; i++) {\n        for (int c = 0; c < colnum; c++) {\n            string hh = reverse(bitset<32> (st[i][c]).to_string());\n            printf(\"%s \", hh.data());\n        }\n        En;\n    }\n    En;\n}\n\nint main() {\n    scanf(\"%d%d%d\", &n, &m, &k);\n    int cnt = 0;;\n    for (int i = 0; i < n; i++) {\n        scanf(\"%s\", mm[i]);\n        for (int j = 0; j < m; j++)\n            if (mm[i][j] != '#') cnt++;\n        //printf(\"%s\\n\", mm[i]);\n    }\n    colnum = m % 32 == 0? m / 32 : m / 32 + 1;\n    mem(mu);\n    for (int i = 0; i < n; i++) {\n        for (int j = 0; j < m; j++) {\n            if (mm[i][j] != '#') set1(ma, i, j);\n            if (mm[i][j] == 'E') set1(mu, i, j);\n            if (mm[i][j] == '#') {\n                for (int d = 0; d < 4; d++) \n                    set1(maf[d], i, j);\n            }\n        }\n    }\n    memcpy(st, ma, sizeof(ma));\n    for (int d = 0; d < 4; d++) {\n        //print(maf[d]);\n        if (d == 0) shift(maf[d], 1);\n        if (d == 1) shift(maf[d], 0);\n        if (d == 2) shift(maf[d], 3);\n        if (d == 3) shift(maf[d], 2);\n        //print(maf[d]);\n    }\n    scanf(\"%s\", com);\n    if (cnt == 1) Pn(0);\n    else {\n        //print(st);\n        bool gok = 0; int idx;\n        for (int i = 0; i < k; i++) {\n            if (com[i] == 'L') {\n                getT1(0);\n                //print(st);\n                shift(st, 0);\n                //print(st);\n            }\n            if (com[i] == 'R') {\n                getT1(1);\n                shift(st, 1);\n            }\n            if (com[i] == 'D') {\n                getT1(2);\n                shift(st, 2);\n            }\n            if (com[i] == 'U') {\n                getT1(3);\n                shift(st, 3);\n            }\n            //print(tmp1);\n            getT2();\n            //print(st);\n            if (check()) { gok = 1, idx = i; break; }\n            //printf(\"i = %d, op = %c\\n\", i, com[i]);\n        }\n        if (gok) Pn(idx + 1);\n        else Pn(-1);\n    }\n    return 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4e414ad8e5d1423c111412a6b2bc82a0", "src_uid": "70ab617d9b8813ddf3039c6fb137d817", "difficulty": 2700.0}
    {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\nbitset<25000> e,c,a,b;\nint n,m,k;\nchar p;\nint main()\n{\n\t\n\tscanf(\"%d%d%d\",&n,&m,&k);\n\tgetchar();\n\t\n\tfor(int i = 0 ; i < n; i++,getchar()){\t\n\t\tfor(int j = 0 ; j < m; j++){\n\t\t\tp = getchar();\n\t\t\t(p=='#'?b:a).set(i*m+j);\n\t\t\t(p=='E'?e.set(i*m+j):0);\n\t\t}\n\t}\n\t\n\t\n\tc = a;\n\t\n\tfor(int i = 0 ; i < k; i++){\n\t\tp = getchar();\n\t\t\n\t\tif(c==e){\n\t\t\tprintf(\"%d\",i);\n\t\t\treturn 0;\n\t\t}\n\t\t\n\t\tif(p=='U')\n\t\t  c = ((c>>m)&a | c&(b<>m));\n\t\telse if(p=='L')\n\t\t  c = ((c>>1)&a | c&(b<<1));\n\t\telse if(p=='R')\n\t\t  c = ((c<<1)&a | c&(b>>1));\t\n\t}\n\t\n\tif(c==e)\n\t   printf(\"%d\",k);\n\telse\n\t   cout<<\"-1\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "923c707b8657a2037d4f0e707bb03c7d", "src_uid": "70ab617d9b8813ddf3039c6fb137d817", "difficulty": 2700.0}
    {"lang": "GNU C++14", "source_code": "#include \r\nusing namespace std; \r\nconst long long MOD = 998244353;\r\nconst int N = 6e5 + 10;\r\nint n, k;\r\nlong long ksm(long long x, long long y)\r\n{\r\n\tlong long m = 1;\r\n\tfor (; y; y >>= 1)\r\n\t{\r\n\t\tif(y & 1)\r\n\t\tm = m * x % MOD;\r\n\t\tx = x * x % MOD;\r\n\t}\r\n\treturn m;\r\n}\r\nlong long jc[N], jcny[N];\r\nlong long dp[N], tot[N];\r\nint vis[N], pri[N], num;\r\nlong long C(int x, int y)\r\n{\r\n\treturn jc[x] * jcny[y] % MOD * jcny[x - y] % MOD;\r\n}\r\nstruct STL\r\n{\r\n\tint G=3,invG;\r\n\tlong long ksm(long long b,int n){\r\n\t    long long res=1;\r\n\t    while(n){\r\n\t        if(n&1) res=res*b%MOD;\r\n\t        b=b*b%MOD; n>>=1;\r\n\t    }\r\n\t    return res;\r\n\t}\r\n\tint tr[N];\r\n\tvoid NTT(long long *f,int n,int fl){\r\n\t    for(int i=0;i>1);\r\n\t        long long w=ksm((fl==0)?G:invG,(MOD-1)/p);\r\n\t        for(int st=0;st=0;--i)\r\n\t        inv[i]=1ll*(i+1)*inv[i+1]%MOD;\r\n\t}\r\n\tint main(int n){\r\n\t    invG=ksm(G,MOD-2);\r\n\t    init(n);\r\n\t    int limit=1;\r\n\t    while(limit<=(n<<1)) limit<<=1;\r\n\t    for (int i = 0; i <= limit; ++ i)\r\n\t    a[i] = b[i] = 0;\r\n\t    for(int i=0;i<=n;++i)\r\n\t        a[i]=(i&1?MOD-inv[i]:inv[i]),\r\n\t        b[i]=ksm(i,n)*inv[i]%MOD;\r\n\t    for(int i=0;i<=limit;++i)\r\n\t        tr[i]=(tr[i>>1]>>1)|(i&1?limit>>1:0);\r\n\t    NTT(a,limit,0);NTT(b,limit,0);\r\n\t    for(int i=0;i<=limit;++i)\r\n\t        a[i]=a[i]*b[i]%MOD;\r\n\t    NTT(a,limit,1);\r\n\t    return 0;\r\n\t}\r\n}S;\r\nint del[N];\r\nint main()\r\n{\r\n\tios::sync_with_stdio(0);\r\n\tcin.tie(0);\r\n\tcin >> n >> k;\r\n\tjc[0] = 1;\r\n\t\r\n\tS.main(n);\r\n\tfor (int i = 1; i <= n; ++ i)\r\n\tdp[i] = S.a[i], del[i] = -1;\r\n\t\r\n\tif(min(n, k) >= 2)dp[1] = 0;\r\n\t\r\n\tfor (int i = 2; i <= n; ++ i)\r\n\t{\r\n\t\tS.main((n + i - 1) / i);\r\n\t\tfor (int j = 2; j <= (n + i - 1) / i; ++ j)\r\n\t\t{\r\n\t\t\t(dp[j] += mul[i] * S.a[j] + MOD) %= MOD;\r\n\t\t}\r\n\t\t\r\n\t\tfor (int j = 2 * i; j <= n; j += i)\r\n\t\tmul[j] += mul[i];\r\n\t}\r\n\t\r\n\tlong long ans = 0;\r\n\tfor (int i = 1; i <= min(n, k); ++ i)\r\n\t(ans += dp[i]) %= MOD;\r\n\tcout << ans;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "436cd90104c5a28f7b78c8b2d7073a27", "src_uid": "eb9d24070cc5b347d020189d803628ae", "difficulty": 2900.0}
    {"lang": "GNU C++17 (64)", "source_code": "hi dac", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7de5c3e35d6376075a5b578ca61487f4", "src_uid": "eb9d24070cc5b347d020189d803628ae", "difficulty": 2900.0}
    {"lang": "GNU C++17 (64)", "source_code": "//nmioy\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n\r\nusing namespace std;\r\n\r\n#define all(a) (a).begin(), (a).end()\r\n#define reverse_all(a) (a).rbegin(), (a).rend()\r\n\r\ntypedef long long ll;\r\ntypedef unsigned long long ull;\r\ntypedef long double ld;\r\n\r\n#define N\t200000\r\n#define L_\t19\t/* L_ = ceil(log2(N * 2 + 1)) */\r\n#define N_\t(1 << L_)\r\n#define MD\t998244353\r\n\r\nconst ll MD = 998244353;\r\n\r\nint min(int a, int b) { return a < b ? a : b; }\r\n\r\nll power(ll a, int k) {\r\n\tll p = 1;\r\n \r\n\twhile (k) {\r\n\t\tif (k & 1)\r\n\t\t\tp = p * a % MD;\r\n\t\ta = a * a % MD;\r\n\t\tk >>= 1;\r\n\t}\r\n\treturn p;\r\n}\r\n \r\nint vv[N + 1], ff[N + 1], gg[N + 1], mobius[N + 1];\r\nint *wwu[L_ + 1], *wwv[L_ + 1], vv_[L_ + 1];\r\n\r\nvoid init() {\r\n\tint i, j, l, u, v;\r\n \r\n\tff[0] = gg[0] = 1;\r\n\tfor (i = 1; i <= N; i++) {\r\n\t\tvv[i] = i == 1 ? 1 : (ll) vv[i - MD % i] * (MD / i + 1) % MD;\r\n\t\tff[i] = (ll) ff[i - 1] * i % MD;\r\n\t\tgg[i] = (ll) gg[i - 1] * vv[i] % MD;\r\n\t}\r\n\tfor (i = 2; i <= N; i++) {\r\n\t\tif (mobius[i])\r\n\t\t\tcontinue;\r\n\t\tfor (j = i; j <= N; j += i)\r\n\t\t\tmobius[j]++;\r\n\t}\r\n\tfor (i = 2; i <= N / i; i++)\r\n\t\tfor (j = i * i; j <= N; j += i * i)\r\n\t\t\tmobius[j] = -1;\r\n\tfor (i = 1; i <= N; i++)\r\n\t\tmobius[i] = mobius[i] == -1 ? 0 : (mobius[i] % 2 == 0 ? 1 : -1);\r\n\tu = power(3, MD - 1 >> L_), v = power(u, MD - 2);\r\n\tfor (l = L_; l > 0; l--) {\r\n\t\tint n = 1 << l, m = n >> 1;\r\n \r\n\t\twwu[l] = (int *) malloc(m * sizeof *wwu[l]);\r\n\t\twwv[l] = (int *) malloc(m * sizeof *wwv[l]);\r\n\t\twwu[l][0] = wwv[l][0] = 1;\r\n\t\tfor (i = 1; i < m; i++) {\r\n\t\t\twwu[l][i] = (ll) wwu[l][i - 1] * u % MD;\r\n\t\t\twwv[l][i] = (ll) wwv[l][i - 1] * v % MD;\r\n\t\t}\r\n\t\tvv_[l] = power(1 << l, MD - 2);\r\n\t\tu = (ll) u * u % MD, v = (ll) v * v % MD;\r\n\t}\r\n\tvv_[0] = 1;\r\n}\r\n\r\nint choose(int n, int k) {\r\n\treturn (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;\r\n}\r\n \r\nvoid ntt_(int *aa, int l, int inverse) {\r\n\tif (l) {\r\n\t\tint n = 1 << l, m = n >> 1, *ww = inverse ? wwv[l] : wwu[l], i, j;\r\n \r\n\t\tntt_(aa, l - 1, inverse), ntt_(aa + m, l - 1, inverse);\r\n\t\tfor (i = 0; (j = i + m) < n; i++) {\r\n\t\t\tint a = aa[i], b = (long long) aa[j] * ww[i] % MD;\r\n \r\n\t\t\tif ((aa[i] = a + b) >= MD)\r\n\t\t\t\taa[i] -= MD;\r\n\t\t\tif ((aa[j] = a - b) < 0)\r\n\t\t\t\taa[j] += MD;\r\n\t\t}\r\n\t}\r\n}\r\n \r\nvoid ntt(int *aa, int l, int inverse) {\r\n\tint n = 1 << l, i, j;\r\n \r\n\tfor (i = 1, j = 0; i < n; i++) {\r\n\t\tint b = n >> 1, tmp;\r\n \r\n\t\twhile ((j ^= b) < b)\r\n\t\t\tb >>= 1;\r\n\t\tif (i < j)\r\n\t\t\ttmp = aa[i], aa[i] = aa[j], aa[j] = tmp;\r\n\t}\r\n\tntt_(aa, l, inverse);\r\n}\r\n \r\nint solve(int n, int k) {\r\n\tstatic int aa[N_], bb[N_];\r\n\tint n_, l_, i, ans;\r\n \r\n\tk = min(k, n);\r\n\tl_ = 0;\r\n\twhile (1 << l_ < k + k + 1)\r\n\t\tl_++;\r\n\tn_ = 1 << l_;\r\n\tfor (i = 0; i < n_; i++)\r\n\t\taa[i] = i <= k ? (long long) power(i, n) * gg[i] % MD : 0;\r\n\tfor (i = 0; i < n_; i++)\r\n\t\tbb[i] = i <= k ? (long long) (i % 2 == 0 ? 1 : MD - 1) * gg[i] % MD : 0;\r\n\tntt(aa, l_, 0), ntt(bb, l_, 0);\r\n\tfor (i = 0; i < n_; i++)\r\n\t\taa[i] = (long long) aa[i] * bb[i] % MD;\r\n\tntt(aa, l_, 1);\r\n\tans = MD - 1;\r\n\tfor (i = 0; i <= k; i++)\r\n\t\tans = (ans + (long long) aa[i] * vv_[l_]) % MD;\r\n\treturn ans;\r\n}\r\n\r\nsigned main() {\r\n\tint n, k, d, ans;\r\n \r\n\tinit();\r\n\tscanf(\"%d%d\", &n, &k);\r\n\tif (k == 1 || n == 1) {\r\n\t\tprintf(\"1\\n\");\r\n\t\treturn 0;\r\n\t}\r\n\tans = 0;\r\n\tfor (d = 1; d < n; d++)\r\n\t\tif (mobius[d])\r\n\t\t\tans = (ans + solve((n + d - 1) / d, k) * mobius[d]) % MD;\r\n\tif (ans < 0)\r\n\t\tans += MD;\r\n\tprintf(\"%d\\n\", ans);\r\n\treturn 0;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7efd0df6321d2d9bdb1b43d55b06596b", "src_uid": "eb9d24070cc5b347d020189d803628ae", "difficulty": 2900.0}
    {"lang": "GNU C++14", "source_code": "#include\r\n#define N 200000\r\n#define mod 998244353\r\nusing namespace std;\r\nint n,k,ans;\r\ninline int quick_pow(int x,int b)\r\n{\r\n    int ret=1;\r\n    while(b)\r\n    {\r\n        if(b&1) ret=1ll*ret*x%mod;\r\n        x=1ll*x*x%mod,b>>=1;\r\n    }\r\n    return ret;\r\n}\r\ninline int inv(int x) {return quick_pow(x,mod-2);}\r\nint fac[N+5],ifac[N+5];\r\nint p[N+5],cnt,mu[N+5];\r\nbool vis[N+5];\r\ninline void init(int n=N)\r\n{\r\n    fac[0]=1;for(int i=1;i<=n;++i) fac[i]=1ll*fac[i-1]*i%mod;\r\n    ifac[n]=inv(fac[n]);for(int i=n;i;--i) ifac[i-1]=1ll*ifac[i]*i%mod;\r\n    mu[1]=1;\r\n    for(int i=2;i<=n;++i)\r\n    {\r\n        if(!vis[i]) p[++cnt]=i,mu[i]=mod-1;\r\n        for(int j=1;j<=cnt && i*p[j]<=n;++j)\r\n        {\r\n            vis[i*p[j]]=1;\r\n            if(!(i%p[j]))\r\n            {\r\n                mu[i*p[j]]=0;\r\n                break;\r\n            }\r\n            mu[i*p[j]]=(mod-mu[i])%mod;\r\n        }\r\n    }\r\n}\r\ninline int C(int n,int m)\r\n{\r\n    if(!m) return 1;\r\n    return n>=m && m>0?1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod:0;\r\n}\r\nconst int G=3,inv_G=inv(G);\r\ninline void NTT(int *a,int lim,int opt=1)\r\n{\r\n\tstatic int rev[N*4],inv_lim;\r\n\tfor(int i=0;i>1]>>1|((i&1)*lim>>1);\r\n\t\tif(i\n#define X first\n#define Y second\n#define PB push_back\n#define LL long long\n#define pii pair\n#define MEM(x,y) memset(x,y,sizeof(x))\n#define bug(x) cout<<\"debug \"#x\" is \"<\n\nusing namespace std;\n//std::default_random_engine random(time(NULL));\n//std::uniform_int_distribution dis1(l,r);\n//dis1(random)\ntypedef long long ll;\ntypedef vector vi;\nconst ll mod=998244353;\nconst ll inf = 1e9+7;\nconst int maxn = 1500010;\nll add(ll a,ll b){return (a+b)%mod;}\nll sub(ll a,ll b){return (a+b)%mod;}\nconst long long p=1e9+7;\nLL exp_mod(LL a, LL b, LL p) {\nLL res = 1;\nwhile(b != 0) {\nif(b&1) res = (res * a) % p;\na = (a*a) % p;\nb >>= 1;\n}\nreturn res;\n}\nLL Comb(LL a, LL b, LL p) {\nif(a < b) return 0;\nif(a == b) return 1;\nif(b > a - b) b = a - b;\nLL ans = 1, ca = 1, cb = 1;\nfor(LL i = 0; i < b; ++i) {\nca = (ca * (a - i))%p;\ncb = (cb * (b - i))%p;\n}\nans = (ca*exp_mod(cb, p - 2, p)) % p;\nreturn ans;\n}\nLL Lucas(int n, int m, int p) {\nLL ans = 1;\nwhile(n&&m&&ans) {\nans = (ans*Comb(n%p, m%p, p)) % p;\nn /= p;\nm /= p;\n}\nreturn ans;\n}\nint main(){\n    FIO\n    ll n,k,ans=0;\n    cin>>n>>k;\n    init();\n    for(int i=1;i<=n;i++){\n        if(n/i=x) combin(i,n+1);\n            if(_y[i]-m<=0) combin(i,n+2);\n            if(_y[i]+m>=y) combin(i,n+3);\n        }\n        return ((fin(n)==fin(n+1))||(fin(n)==fin(n+2))||(fin(n+3)==fin(n+1))||(fin(n+3)==fin(n+2)));\n    }\n\n    void solve(){\n        //freopen(\"in.txt\",\"r\",stdin);\n        cin>>n>>x>>y;\n        for(int i=0;i>_x[i]>>_y[i];\n        double l=0,r=inf;\n        for(int i=0;i<1000;i++){\n            double mid=(l+r)/2;\n            //bug(mid)\n            if(check(mid)) r=mid;\n            else l=mid;\n        }\n        cout< dis(50000,5000000);\n        //std::normal_distribution<> dis(1,x-1);\n        for(int i=0;i<100;i++) cout<<(int)dis(random)<<\" \"<<(int)dis(random)<\n\n#define int long long\n\nusing namespace std;\n\nconst int N = 5e5 + 10, mod = 998244353;\n \nint bexp(int a, int b) \n{\n    a %= mod;\n    int res = 1;\n    while (b) \n    {\n        if (b & 1) res = res * a % mod;\n        a = a * a % mod;\n        b >>= 1;\n    }\n    return res;\n}\n \nint inv(int x) \n{\n\treturn bexp(x, mod - 2);\n}\n \nint f[N];\n \nint nck(int n, int k) \n{\n    if (k > n) return 0;\n\tint res = f[a];\n\tres = res * inv(f[k]) % mod;\n\tres = res * inv(f[n - k]) % mod;\n\treturn res;\n}\n \nint32_t main()\n{\n    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);    \n    f[0] = 1;\n    for (int i = 1; i < N; i++) f[i] = f[i - 1] * i % mod;\n    int n, k;\n    cin >> n >> k;\n    int ans = 0;\n    for (int i = 1; i <= n; ++i)\n    {\n        ans += ncr(n / i - 1, k - 1);\n        ans %= mod;\n    }\n    cout << ans;\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "865949700f4bebd1b17ca3aecb046a06", "src_uid": "8e8eb64a047cb970a549ee870c3d280d", "difficulty": 2000.0}
    {"lang": "GNU C++17", "source_code": "#include \n#define ll long long\nusing namespace std;\nonst int MOD = 998244353, MAXN = 500005;\nint fact[MAXN];\n \nvoid calcFacts() {\n    fact[0] = 1;\n    for (int i = 1; i < MAXN; i++)\n        fact[i] = (fact[i - 1] * i) % MOD;\n}\n \nint powMod(int a, int e) {\n    int r = 1;\n    while (e) {\n        if (e & 1)\n            r = (r * a) % MOD;\n        a = (a * a) % MOD;\n        e >>= 1;\n    }\n    return r;\n}\n \nint invMod(int a) {\n    return powMod(a, MOD - 2);\n}\n \nint choose(int n, int k) {\n    if (k > n)\n        return 0;\n    return (fact[n] * invMod((fact[k] * fact[n - k]) % MOD)) % MOD;\n}\n \nsigned main() {\n    calcFacts();\n \n    int n, k;\n    cin >> n >> k;\n \n    int answer = 0;\n    for (int i = 1; i < MAXN; i++) {\n        answer = (answer + choose(n / i - 1, k - 1)) % MOD;\n    }\n \n    cout << answer;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e6f5722b8546ff46e34a35e680937361", "src_uid": "8e8eb64a047cb970a549ee870c3d280d", "difficulty": 2000.0}
    {"lang": "GNU C++14", "source_code": "#include  \n\nusing namespace std; \n\n#define mod 998244353 \n\nlong long ncr(int n,int r,int p) {\n    if(r>n-r) r=n-r;\n    long long c[r+1]={0};\n    c[0]=1;\n    for(int i=1;i<=n;i++) {\n        for(int j=min(i,r);j>0;j--) {\n            c[j]=(c[j]+c[j-1])%p;\n        }\n    }\n    return c[r];\n}\n\n\nint nCrModpLucas(int n, int r, int p) \n{ \n// Base case \nif (r==0) \n\treturn 1; \n\n// Compute last digits of n and r in base p \nint ni = n%p, ri = r%p; \n\n// Compute result for last digits computed above, and \n// for remaining digits. Multiply the two results and \n// compute the result of multiplication in modulo p. \nreturn (nCrModpLucas(n/p, r/p, p) * // Last digits of n and r \n\t\tncr(ni, ri, p)) % p; // Remaining digits \n} \n\nint main() {\n    int n,k;\n    cin>>n>>k;\n    if(n\n#include \n#include \n#include \n\n#define N 21\n\nint n, m;\nstruct Node {\n    int id, deg;\n    int adj[N];\n}p[N];\nbool con[N][N];\n\nvoid init(int n)\n{\n    for(int i = 0; i < n; i++) {\n        p[i].id = i;\n        p[i].deg = 0;\n    }\n}\n\ninline void add_edge(int x, int y)\n{\n    p[x].adj[p[x].deg++] = y;\n}\n\nint comp(const void *a, const void *b)\n{\n    Node *pa = &p[*(int*)a];\n    Node *pb = &p[*(int*)b];\n    if(pa->deg != pb->deg)\n        return pa->deg - pb->deg;\n    else\n        return pa->id - pb->id;\n}\n\nbool v[N];\nbool hamilton_path(int x, int n)\n{\n    v[x] = true;\n    --n;\n    while(n > 0) {\n        int y = -1;\n        for(int i = 0; i < p[x].deg; i++)\n            if(!v[p[x].adj[i]]) {\n                y = p[x].adj[i];\n                break;\n            }\n        if(y < 0)\n            return false;\n        x = y;\n        v[x] = true;\n        --n;\n    }\n    return true;\n}\nint main()\n{\n    scanf(\"%d%d\", &n, &m);\n    init(n);\n    memset(con, false, sizeof(con));\n    for(int i = 0; i < m; i++) {\n        int x, y;\n        scanf(\"%d%d\", &x, &y);\n        if(x != y && !con[x-1][y-1]) {\n            add_edge(x-1, y-1);\n            add_edge(y-1, x-1);\n            con[x-1][y-1] = con[y-1][x-1] = true;\n        }\n    }\n    if(n == 1) {\n        printf(\"Yes\\n\");\n        return 0;\n    }\n    for(int i = 0; i < n; i++)\n        if(p[i].deg) {\n            qsort(p[i].adj, p[i].deg, sizeof(int), comp);\n\\        } else {\n            printf(\"No\\n\");\n            return 0;\n        }\n    for(int i = 0; i < n; i++) {\n        memset(v, false, sizeof(v));\n        if(hamilton_path(i, n)) {\n            printf(\"Yes\\n\");\n            return 0;\n        }\n    }\n    printf(\"No\\n\");\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1ea1db1471e695d65de7fd971bd65061", "src_uid": "d023fc9b58268a36d7fb80deb338b09a", "difficulty": 2800.0}
    {"lang": "GNU C++", "source_code": "// In The Name Of GOD\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define REP(i, n) for (register int i = (0); i < (int) (n); (i)++)\n#define foreach(it, c) for(__typeof((c).begin()) it = (c).begin(); it !=(c).end(); it++)\n#define Size(a) (int)(a.size())\n#define all(a) a.begin(), a.end()\n#define X first\n#define Y second\n#define pb push_back\n#define mp make_pair\n#define gcd __gcd\n\ntypedef long long ll;\ntypedef pair pii;\n\ntemplate  inline T sqr (T a) { return a*a; }\n\nset  adj[33];\nbool mark [33];\nint dis[33];\n\nvoid dfs (int v) {\n\t\tint _deg = -(1 << 30);\n\t\tint vic = -1;\n\t\tbool temp = false;\n\t\tmark[v] = true;\n\t\tforeach (it, adj[v])\n\t\t\tif (mark[*it] == false)\n\t\t\t\tif (temp == false or dis[*it] < _deg) {\n\t\t\t\t\ttemp = true;\n\t\t\t\t\t_deg = dis[*it];\n\t\t\t\t\tvic = (*it);\n\t\t\t\t}\n\t\tif (vic != -1)\n\t\t\tdfs (vic);\n}\n\nint main () {\n        ios_base::sync_with_stdio(false);\n\tint n, m;\n\tcin >> n >> m;\n\tmemset (dis, 0, sizeof dis);\n\tREP (i, m) {\n\t\tint a, b;\n\t\tcin >> a >> b;\n\t\tif (a != b) {\n\t\t\tint _a = Size(adj[a-1]);\n\t\t\tint _b = Size(adj[b-1]);\n\t\t\tadj[a-1].insert (b-1);\n\t\t\tadj[b-1].insert (a-1);\n\t\t\tif (Size(adj[a-1]) > _a)\n\t\t\t\tdis[a-1] ++;\n\t\t\tif (Size(adj[b-1]) > _b)\n\t\t\t\tdis[b-1] ++;\n\t\t}\n\t}\n\tREP (i, n) {\n\t\tmemset (mark, false, sizeof mark);\n\t\tdfs(i);\n\t\tbool temp = false;\n\t\tREP (j, n)\n\t\t\tif (mark[j] == false) {\n\t\t\t\ttemp = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\tif (temp == false) {\n\t\t\tcout << \"YES\" << endl;\n\t\t\treturn 0;\n\t\t}\n\t}\n\tcout << \"NO\" << endl;\n        return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "624e497ee9fa9aff3048a4fc8ea4b3a6", "src_uid": "d023fc9b58268a36d7fb80deb338b09a", "difficulty": 2800.0}
    {"lang": "GNU C++", "source_code": "#include\n#include\n//using namespace std;\nint n,m,c[23][23],d[23],u[23];\nmain() {\n    scanf(\"%d%d\", &n, &m);\n    for (int xt,yt,i = 1; i <= m; ++i) {\n        scanf(\"%d%d\", &xt, &yt);\n        if (c[xt][yt] || xt == yt) continue;\n        ++d[xt], ++d[yt];\n        c[xt][yt] = c[yt][xt] = 1;\n    }\n    for (int j,co,p,mint,i = 1; i <= n; ++i) {\n        fill(u, u + n + 1, 0);\n        co = 0;\n        for (j = i; !u[j]; j = p) {\n            mint = n+n;\n            p = j;\n            u[j] = 1;\n            ++co;\n            for (int k = 1; k <= n; ++k) \n                if (!u[k] && c[j][k] && (d[k] < mint || d[k] == mint && k < p))\n                    p = k, mint = d[k];\n        }\n        if (co == n) {puts(\"Yes\");return 0;}\n    }\n    puts(\"No\");\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "691f1ac8df29361bc17100c64a2cf5a8", "src_uid": "d023fc9b58268a36d7fb80deb338b09a", "difficulty": 2800.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define FOREACH(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)\n#define FOR(i, a, n) for (int i = (a); i < int(n); ++i)\n#define error(x) cout << #x << \" = \" << (x) << endl;\n#define all(n) (n).begin(), (n).end()\n#define Size(n) ((int)(n).size())\n#define mk make_pair\n#define pb push_back\n#define F first\n#define S second\n#define X real()\n#define Y imag()\n\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\ntypedef complex point;\n\ntemplate  void smin(P &a, Q b) { if (b < a) a = b; }\ntemplate  void smax(P &a, Q b) { if (b > a) a = b; }\ntemplate  bool in(const P &a, const Q &b) { return a.find(b) != a.end(); }\n\nconst int MOD = 233;\nint hash = 7;\n\nvoid add(int x) {\n\thash = (hash*29+x)%MOD;\n}\n\nint main() {\n\tint n, m;\n\tcin >> n >> m;\n\tadd(n); add(m);\n\tFOR(i, 0, m) {\n\t\tint a, b;\n\t\tcin >> a >> b;\n\t\tadd(a); add(b);\n\t}\n\tif (hash == 229) { cout << \"Yes\" << endl; exit(0); } //1\n\tif (hash == 149) { cout << \"No\" << endl; exit(0); } //2\n\tif (hash == 180) { cout << \"No\" << endl; exit(0); } //3\n\tif (hash == 183) { cout << \"Yes\" << endl; exit(0); } //4\n\tif (hash == 93) { cout << \"Yes\" << endl; exit(0); } //5\n\twhile (1);\n\tif (hash == 217) { cout << \"Yes\" << endl; exit(0); } //6\n\tint len = hash*1000*1024;\n\tbool *a = new bool[len];\n\tfill(a, a+len, -1);\n\tcerr << hash << endl;\n\t//if (hash == 208) { cout << \"Yes\" << endl; exit(0); }\n\tcout << \"No\" << endl;\n\tdelete a;\n\t//cout << xx << endl;\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f96581370adb7d9fb99d07e27ca9f4dc", "src_uid": "d023fc9b58268a36d7fb80deb338b09a", "difficulty": 2800.0}
    {"lang": "GNU C++17", "source_code": "#include \r\n#include \r\n#include \r\n#include \r\nusing namespace std;\r\nconst int INF = 1e9;\r\nint n, m;\r\nint chests[10];\r\nint keys[10];\r\nint costs[10][10];\r\nint ans = INF;\r\nstruct state {\r\n    vector a;\r\n    int i;\r\n    int j;\r\n    int r;\r\n\r\n    bool operator==(const state& other)\r\n    {\r\n        return i == other.i && j == other.j && a == other.a;\r\n    };\r\n};\r\nint convert(state tmp)\r\n{\r\n    int res = 0;\r\n    for (auto& e : tmp.a) {\r\n        assert(e < 7);\r\n        res = res * 7 + e;\r\n    }\r\n    assert(tmp.r < 7);\r\n    res = res * 7 + tmp.j;\r\n    assert(tmp.i < 7);\r\n    res = res * 7 + tmp.r;\r\n    assert(tmp.j < 7);\r\n    res = res * 7 + tmp.i;\r\n    return res;\r\n}\r\nstate convertBack(int index)\r\n{\r\n    state res;\r\n    res.i = index % 7;\r\n    index /= 7;\r\n    res.r = index % 7;\r\n    index /= 7;\r\n    res.j = index % 7;\r\n    index /= 7;\r\n    for (int i = 0; i < n; ++i) {\r\n        res.a.push_back(index % 7);\r\n        index /= 7;\r\n    }\r\n    std::reverse(res.a.begin(), res.a.end());\r\n    return res;\r\n}\r\nint dp[40353607] = { 0 };\r\nint main()\r\n{\r\n    cin >> n >> m;\r\n    for (int i = 0; i < n; ++i) {\r\n        cin >> chests[i];\r\n    }\r\n    for (int i = 0; i < m; ++i) {\r\n        cin >> keys[i];\r\n    }\r\n    for (int i = 0; i < n; ++i) {\r\n        for (int j = 0; j < m; ++j) {\r\n            cin >> costs[i][j];\r\n        }\r\n    }\r\n    memset(dp, 0xff, sizeof(dp));\r\n    dp[0] = 0;\r\n    for (int i = 0; i < 40353607; ++i) {\r\n        if (dp[i] < 0)\r\n            continue;\r\n        state curState = convertBack(i);\r\n        if (curState.j == m) {\r\n            continue;\r\n        }\r\n        /*\r\n        cout << \"fuck \";\r\n        for (auto cur : curState.a)\r\n            cout << cur << ' ';\r\n        cout << endl;\r\n        cout << curState.i << ' ' << curState.j << ' ' << curState.r << endl;\r\n        */\r\n        for (int flow = 0; flow < 5; ++flow) {\r\n            auto nextState = curState;\r\n            if (flow + curState.a[curState.i] > chests[curState.i] || flow + curState.r > keys[curState.j]) {\r\n                continue;\r\n            }\r\n            int added = flow == 0 ? 0 : costs[curState.i][curState.j];\r\n            nextState.r = flow + curState.r;\r\n            nextState.a[curState.i] += flow;\r\n            nextState.i++;\r\n            if (nextState.i == n) {\r\n                nextState.i = 0;\r\n                nextState.j++;\r\n                nextState.r = 0;\r\n            }\r\n            auto index = convert(nextState);\r\n            dp[index] = (dp[index] == -1 || dp[index] > dp[i] + added) ? dp[i] + added : dp[index];\r\n            auto isFinal = [&](state s) -> bool {\r\n                for (int i = 0; i < s.a.size(); ++i) {\r\n                    if (s.a[i] != chests[i]) {\r\n                        return false;\r\n                    }\r\n                }\r\n                return true;\r\n            };\r\n            if (isFinal(nextState)) {\r\n                ans = min(ans, dp[index]);\r\n            }\r\n        }\r\n    }\r\n    if (ans == INF)\r\n        cout << -1 << endl;\r\n    else\r\n        cout << ans << endl;\r\n    return 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "80cc2fb6b8ff58a4c7a359ddec653c35", "src_uid": "4dc5dc78bda59c1ec6dd8acd6f1d7333", "difficulty": 3200.0}
    {"lang": "GNU C++17 (64)", "source_code": "// Author: wlzhouzhuan\n#pragma GCC optimize(2, 3, \"Ofast\")\n#include \nusing namespace std;\n#define ll long long\n#define ull unsigned long long\n#define pii pair\n#define pb push_back\n#define fir first\n#define sec second\n#define rep(i, l, r) for (int i = l; i <= r; i++)\n#define per(i, l, r) for (int i = l; i >= r; i--)\n#define mset(s, t) memset(s, t, sizeof(s))\n#define mcpy(s, t) memcpy(s, t, sizeof(t))\n#define poly vector\n#define SZ(x) (int(x.size()))\ntemplate void ckmin(T1 &a, T2 b) { if (a > b) a = b; }\ntemplate void ckmax(T1 &a, T2 b) { if (a < b) a = b; }\nint read() {\n  int x = 0, f = 0; char ch = getchar();\n  while (!isdigit(ch)) f |= ch == '-', ch = getchar();\n  while (isdigit(ch)) x = 10 * x + ch - '0', ch = getchar();\n  return f ? -x : x;\n}\ntemplate void print(T x) {\n  if (x < 0) putchar('-'), x = -x;\n  if (x >= 10) print(x / 10);\n  putchar(x % 10 + '0');\n}\ntemplate void print(T x, char let) {\n  print(x), putchar(let);\n}\n\nconst int pw5[] = {1, 5, 25, 125, 625, 3125};\n\nint dp[7][15625][5];\nint tem[15625][6];\nint a[6], b[6], c[6][6], n, m;\nint inf;\n\nint main() {\n  scanf(\"%d%d\", &n, &m);\n  for (int i = 0; i < n; i++) scanf(\"%d\", &a[i]);\n  int zip = 0;\n  for (int i = 0; i < m; i++) scanf(\"%d\", &b[i]), zip += pw5[i] * b[i];\n  for (int i = 0; i < n; i++)\n    for (int j = 0; j < m; j++)\n      scanf(\"%d\", &c[i][j]);\n  for (int i = 0; i <= zip; i++) {\n    int tmp = i;\n    for (int j = m - 1; j >= 0; j--) \n      tem[i][j] = tmp / pw5[j], tmp %= pw5[j];\n  }\n  memset(dp, 0x3f, sizeof(dp)), inf = dp[0][0][0];\n  dp[0][zip][a[0]] = 0;\n  for (int i = 0; i < n; i++) {\n    for (int j = zip; j >= 0; j--) {\n      for (int k = a[i]; k >= 0; k--) {\n        if (dp[i][j][k] == inf) continue;\n        // printf(\"dp[%d][%d][%d] = %d\\n\", i, j, k, dp[i][j][k]);\n        for (int o = 0; o < m; o++)\n          for (int num = 1; num <= tem[j][o] && num <= k; num++)\n            ckmin(dp[i][j - pw5[o] * num][k - num], dp[i][j][k] + c[i][o]);\n      }\n      ckmin(dp[i + 1][j][a[i + 1]], dp[i][j][0]);\n    }\n  }\n  int ans = inf;\n  for (int j = 0; j <= zip; j++) ckmin(ans, dp[n][j][0]);\n  if (ans >= inf) ans = -1;\n  rintf(\"%d\\n\", ans);\n  return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d0fd4786f9565d045444a03b5601cc1d", "src_uid": "4dc5dc78bda59c1ec6dd8acd6f1d7333", "difficulty": 3200.0}
    {"lang": "GNU C++17", "source_code": "#include\r\nusing namespace std;\r\n#define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)\r\n#define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)\r\n\r\nconst int N=10,P=998244353;\r\n\r\nint n,m;\r\nint a[N],b[N],c[N][N];\r\nint A[1<<6],B[1<<6],s[N][1<<6],bin[1<<6];\r\nint C[1<<6];\r\n\r\nint st[N];\r\nint ans=1e9;\r\nvoid dfs(int p,int s){\r\n\tif(s>=ans) return;\r\n\tif(p==n) { ans=s; return; }\r\n\trep(S,0,(1<=ans) continue;\r\n\t\tst[p]=S;\r\n\t\tdrep(T,(1<<(p+1))-1,1<B[C[T]]) {\r\n\t\t\t\tfl=0;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\tif(fl) dfs(p+1,s+::s[p][S]);\r\n\t}\r\n}\r\n\r\nint main(){\r\n\tscanf(\"%d%d\",&n,&m);\r\n\trep(i,0,max(n,m)-1) bin[1<a[i]) swap(a[i],a[j]),swap(c[i],c[j]);\r\n\trep(S,1,(1<0) return puts(\"-1\"),0;\r\n\tdfs(0,0);\r\n\tprintf(\"%d\\n\",ans==1e9?-1:ans);\r\n}\r\nint z", "lang_cluster": "C++", "compilation_error": true, "code_uid": "89e1b966519b8066f762a7c809887f37", "src_uid": "4dc5dc78bda59c1ec6dd8acd6f1d7333", "difficulty": 3200.0}
    {"lang": "GNU C++14", "source_code": "#include \r\nusing namespace std ;\r\n#define ll long long\r\nconst int MAXN=6;\r\nconst int MAXP=15625;\r\nint n,m,a[MAXN+3],b[MAXN+3],c[MAXN+3][MAXN+3];\r\nll dp[MAXN+3][MAXP+5];\r\nint rid[MAXP+5],id[1<<18];\r\nint idnum=0;\r\nvoid dfs(int x,int cur){\r\n\tif(x==n+1){rid[++idnum]=cur;id[cur]=idnum;return;}\r\n\tfor(int i=0;i<=a[x];i++) dfs(x+1,cur+(i<<(3*(x-1))));\r\n}\r\nvoid dfs2(int x,int t,int msk,int lft,ll val){\r\n\tif(!lft||x==n+1){chkmin(dp[t][id[msk]],val);return;}\r\n\tfor(int i=0;i<=min(a[x]-(msk>>(3*(x-1))&7),lft);i++){\r\n\t\tdfs2(x+1,t,msk+(i<<(3*(x-1))),lft-i,val+(i>0)*c[x][t]);\r\n\t}\r\n}\r\nint main(){\r\n\tscanf(\"%d%d\",&n,&m);int sa=0,sb=0;\r\n\tfor(int i=1;i<=n;i++) scanf(\"%d\",&a[i]),sa+=a[i];\r\n\tfor(int i=1;i<=m;i++) scanf(\"%d\",&b[i]),sb+=b[i];\r\n\tif(sa>sb) return puts(\"-1\"),0;\r\n\tfor(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf(\"%d\",&c[i][j]);\r\n\tdfs(1,0);memset(dp,63,sizeof(dp));dp[0][id[0]]=0;\r\n\tfor(int i=0;i pos;\r\n\t\tfor(int l=1;l<=idnum;l++){\r\n\t\t\tif(dp[i][l]>=0x3f3f3f3f3f3f3f3fll) continue;\r\n\t\t\tdfs2(1,i+1,rid[l],b[i+1],dp[i][l]);\r\n\t\t}\r\n\t} int lst=0;for(int i=1;i<=n;i++) lst|=(a[i]<<(3*(i-1)));\r\n\tif(dp[m][id[lst]]<0x3f3f3f3f3f3f3f3fll) printf(\"%lld\\n\",dp[m][id[lst]]);\r\n\telse puts(\"-1\");\r\n\treturn 0;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6369945b5e06bd0bb58940da036ae1fe", "src_uid": "4dc5dc78bda59c1ec6dd8acd6f1d7333", "difficulty": 3200.0}
    {"lang": "GNU C++14", "source_code": "include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\nint main()\n{\n    int n,m,k;\n    while(~scanf(\"%d%d%d\",&n,&m,&k))\n    {\n        int flag=0;\n        if(n&1)\n        {\n            for(int i=1;i*i<=m;i++)\n                if(m%i==0)\n                {\n                    if(i>=k&&m/i>1||i>1&&m/i>=k)\n                    {\n                        flag=1;\n                        break;\n                    }\n                }\n        }\n        printf(\"%s\\n\",flag?\"Timur\":\"Marsel\");\n    } \n    return 0;\n}\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8f60276cde0fdbe73a3937e63ca7ce7d", "src_uid": "4a3767011ddac874efa021fff7c94432", "difficulty": 2000.0}
    {"lang": "GNU C++14", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#pragma comment(linker, \"/STACK:256000000\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n  \nusing namespace std;\n  \ntypedef long long ll;\n#define mp make_pair\n#define pub push_back\n#define XX first\n#define YY second\n#define db long double\n#define all(a) a.begin(), a.end()\n#define y1 dsfgsdfgsdfgsdfgsdfgsdfg\n#define y0 asdfasdf3rcdt234d5c23xd234dx43\nconst int INF = (int)1e9 + 7;\nconst ll LINF = (ll)9e18 + 7;\n  \nconst ll P1 = 353251;\nconst ll P2 = 239017;\nconst ll MOD = 1e9 + 7;\nconst ll MOD1 = 1e9 + 7;\nconst ll MOD2 = 1e9 + 9;\n\n/*\nconst int MAX_MEM = 1e8;\nint mpos = 0;\nchar mem[MAX_MEM];\nvoid * operator new ( size_t n ) {\n    char *res = mem + mpos;\n    mpos += n;\n    return (void *)res;\n}\nvoid operator delete ( void * ) { }\n*/\n\nint n, m, k;\nmap ma;\n\nint get(int len) {\n\tif (ma[len] != 0)\n\t\treturn ma[len];\n\tint ans = 1;\n\tfor (int del = 2; del * del <= len; del++) {\n\t\tif (len % del == 0) {\n\t\t\tint f1 = get(del);\n\t\t\tint f2 = get(len / del);\n\t\t\tbool f3 = 1, f4 = 1;\n\t\t\tif (del < k)\n\t\t\t\tf3 = 0;\n\t\t\tif (len / del < k)\n\t\t\t\tf4 = 0;\n\t\t\tif (f3 && f1 == 1 || f4 && f2 == 1)\n\t\t\t\tans = 2;\n\t\t\tif (f3 && f1 == 2 && (len / del) % 2 == 0) {\n\t\t\t\tans = 2;\n\t\t\t}\n\t\t\tif (f4 && f2 == 2 && del % 2 == 0) {\n\t\t\t\tans = 2;\n\t\t\t}\n\t\t\tif (ans == 2)\n\t\t\t\tbreak;\n\t\t} \n\t}\n\tif (1 >= k)\n\t\tans = 2;\n\tma[len] = ans;\n\treturn ans;\n}\n\nconst bool is_testing = 0\nint main() {\n\tsrand('D' + 'E' + 'N' + 'I' + 'S' + 'S' + 'O' + 'N' + time(NULL));\n\t//mt19937 rnd(time(NULL));\n\t//ios_base::sync_with_stdio(0); cin.tie(0);\n\tif (is_testing) {\n\t\tfreopen(\"input.txt\", \"r\", stdin);\n\t\tfreopen(\"output.txt\", \"w\", stdout);\n\t} else {\n\t\t//freopen(\"ufo.in\", \"r\", stdin);\n\t\t//freopen(\"ufo.out\", \"w\", stdout);\n\t}\n\tcin >> n >> m >> k;\n\tint f = get(m);\n\tif (f == 2 && n % 2 == 1)\n\t\tcout << \"Timur\";\n\telse\n\t\tcout << \"Marsel\";\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0ad70af913b175129fccfe931167e762", "src_uid": "4a3767011ddac874efa021fff7c94432", "difficulty": 2000.0}
    {"lang": "MS C++", "source_code": "// cfc.cpp : \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0328\u04e6\ufffd\u00f3\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u06b5\u3863\n//\n\n//#include \"stdafx.h\"\n#include\"iostream\"\n#include\"cmath\"\n#include\"stdio.h\"\n#include \"algorithm\"\nusing namespace std;\n\nbool modd(int m,int k)\n{\n\tint n,i;\n\tn = sqrt(m)+1;\n\tfor(i = k;i<=n;i++)\n\t{\n\t\tif(m%i==0)\n\t\t{\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nint main()\n{\n\tint n,m,k;\n\twhile(scanf(\"%d%d%d\",&n,&m,&k)!=EOF)\n\t{\n\t\tif(n==1)\n\t\t{\n\t\t\tif((m>=(2*k))&&modd(m,k))\n\t\t\t{\n\t\t\t\tprintf(\"Timur\\n\");\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tprintf(\"Marsel\\n\");\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif(((n%2)==1)&&(m>=(2*k))&&modd(m,k))\n\t\t\t{\n\t\t\t\tprintf(\"Timur\\n\");\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tprintf(\"Marsel\\n\");\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "80dc93a08e885ebf0bec880aef7df916", "src_uid": "4a3767011ddac874efa021fff7c94432", "difficulty": 2000.0}
    {"lang": "MS C++", "source_code": "#include\n#include\n\n\nint main(){\n\n    int i,j,k,l,n,m;\n    int flag;\n\n    scanf(\"%d %d %d\",&n,&m,&k);\n\n    l=sqrt(m);\n    flag=0;\n    for(i=1;i<=l;i++){\n        if(m%i==0){\n            if(i>=k||(m/i)>=k){\n                flag=1;\n                break;\n            }\n        }\n    }\n    if(flag==0){\n        printf(\"Marsel\\n\");\n        \n    }\n    else if(n%2==0){\n        printf(\"Marsel\\n\");\n        \n    }\n    else printf(\"Timur\\n\");\n\n    \n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8681d9db0e91a04c45777130aa2c7424", "src_uid": "4a3767011ddac874efa021fff7c94432", "difficulty": 2000.0}
    {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define re return\n#define ll long long\n#define du double\nconst ll mod=1000000007;\nll made(ll mask1,ll mask2,ll num,ll n){\n    if (num>n) re 1;\n    ll ret=1;\n    ll ans=0;\n    for (ll i=1;i<=n;++i){\n        for (ll j=1;j<=n;++j){\n            if ((i+j-2)%n+1==num){\n                ll z=pow(2,i);\n                ll g=pow(2,j);\n                if ((mask1&z)\n                && (mask2&g)){\n                    //cout << i << \" \" << j << \" \" << mask1 << \" \" << mask2 << \" \" << num << endl;\n                    ret*=made(mask1-z,mask2-g,num+1,n)%mod;\n                    ans+=ret;\n                    ans%=mod;\n                    ret=1;15\n                }\n            }\n        }\n    }\n    re ans%mod;\n}\nint main(){\n    ll n;\n    cin >> n;\n    if (n<=11){\n    ll ans=made(65535,65535,1,n)%mod;\n    ll fac[200];\n    fac[1]=1;\n    for (int i=2;i<=100;++i) fac[i]=(fac[i-1]*i)%mod;\n    ans*=fac[n];\n    ans%=mod;\n    cout << ans;\n    }\n    if (n==12 || n==14 || n==16) cout << 0;\n    if (n==13) cout << 695720788;\n    if (n==15) cout << 150347555;\n    re 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "535a37f220b82f0b706865b32127f8be", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0}
    {"lang": "GNU C++", "source_code": "#include\n\n\n\n#define x first\n\n#define y second\n\n#define eps 1e-7\n\n#define pb push_back\n\n#define inf 0x3f3f3f3f\n\n#define mod 1000000007\n\n#define sq(x) ((x)*(x))\n\n#define cb(x) ((x)*(x)*(x))\n\n#define bit(x, y) (((x)>>(y))&1)\n\n#define bctz(x) (__builtin_ctz(x))\n\n#define bclz(x) (__builtin_clz(x))\n\n#define bclzl(x) (__builtin_clzl(x))\n\n#define bctzl(x) (__builtin_ctzl(x))\n\n#define bpt(x) (__builtin_popcount(x))\n\n#define bptl(x) (__builtin_popcountll(x))\n\n#define pi 3.1415926535897932384626433832795\n\n#define PQ priority_queue, greater >\n\n\n\nusing namespace std;\n\n\n\ntypedef double DO;\n\ntypedef long long INT;\n\ntypedef vector VI;\n\ntypedef pair pii;\n\ntypedef pair pi3;\n\n\n\ntemplate inline void smin(T &a, U b) {if(a>b) a=b;}\n\ntemplate inline void smax(T &a, U b) {if(a inline void gn(T &x) {char c, sg=0; while(c=getchar(), (c>'9' || c<'0') && c!='-'); for((c=='-' ? sg=1, c=getchar() : 0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0'; if(sg) x=-x;}\n\ntemplate  inline void gn(T1 &x1, T2 &x2) {gn(x1), gn(x2);}\n\ntemplate  inline void gn(T1 &x1, T2 &x2, T3 &x3) {gn(x1, x2), gn(x3);}\n\ntemplate  inline void gn(T1 &x1, T2 &x2, T3 &x3, T4 &x4) {gn(x1, x2), gn(x3, x4);}\n\n\n\ntemplate  inline void print(T x) {if(x<0) {putchar('-'); return print(-x);} if(x<10) {putchar('0'+x); return ;} print(x/10); putchar(x%10+'0');}\n\ntemplate  inline void println(T x) {print(x); putchar('\\n');}\n\ntemplate  inline void printsp(T x) {print(x); putchar(' ');}\n\ntemplate  inline void print(T1 x1, T2 x2) {printsp(x1), println(x2);}\n\ntemplate  inline void print(T1 x1, T2 x2, T3 x3) {printsp(x1), printsp(x2), println(x3);}\n\ntemplate  inline void print(T1 x1, T2 x2, T3 x3, T4 x4) {printsp(x1), printsp(x2), printsp(x3), println(x4);}\n\n\n\nint power(int a, int b, int m, int ans=1) {\n\n\tfor(; b; b>>=1, a=1LL*a*a%m) if(b&1) ans=1LL*ans*a%m;\n\n\treturn ans;\n\n}\n\n\n\n\n\n\n\nint main() {\n\n#ifndef\tONLINE_JUDGE\n\n\tfreopen(\"in.in\", \"r\", stdin);\n\n\tfreopen(\"out.out\", \"w\", stdout);\n\n#endif\n\n\n\n\tint n;\n\n\tgn(n);\n\n\tif(n%2==0) puts(\"0\");\n\n\telse if(n==1) puts(\"1\");\n\n\telse if(n==3) puts(\"18\");\n\n\telse if(n==5) puts(\"1800\");\n\n\telse if(n==7) puts(\"670320\");\n\n\telse if(n==9) puts(\"734832000\");\n\n\telse if(n==11) puts(\"890786230\");\n\n\telse if(n==13) puts(\"695720788\");\n\n\telse if(n==15) {\n\n\t\twhile(1);\n\n\t\tint aa[11111111111111111111111LL];\n\n\t\tprintln((695720788+734832000+890786230)%mod);\n\n\t}\n\n}\n          ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "69397d88fc10e8eb99d4e68c69afc2c3", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0}
    {"lang": "GNU C++", "source_code": "/*\n  Name:\n  Author: 3T - mailto: gm.tranthanhtu@gmail.com\n  Date:\n  Algorithm:\n  Time Limit: .000s\n*/\n\n//COMPETITIVE PROGRAMMING TEMPLATE\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)\n#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)\n#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)\n#define repr(i,n) for (int i = (n) - 1; i >= 0; i--)\n#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )\n#define fill(ar,val) memset(ar, val, sizeof(ar))\n#define fill0(ar) fill((ar), 0)\n#define fillinf(ar, n) fr(i,0,(n)) ar[i] = INF\n#define debug(x) cout<<#x<<\": \"< ii;\ntypedef pair iii;\ntypedef vector vii;\ntypedef vector vi;\ntypedef vector vs;\n\ntemplateinline T gcd(T a, T b){if (b == 0)return a;else return gcd(b, a % b);}\ntemplateinline T lcm(T a, T b){return (a * b) / gcd(a, b);}\ntemplate string toStr(T x) {stringstream st; st << x; string s; st >> s; return s;}\ntemplate\nvoid splitStr(const string &s, vector &out)\n{\n    istringstream in(s);\n    out.clear();\n    copy(istream_iterator(in), istream_iterator(), back_inserter(out));\n}\n\ninline int two(int n) {return 1 << n;}\ninline int isOnBit(int n, int b) {return (n >> b) & 1;}\ninline void onBit(int & n, int b) {n |= two(b);}\ninline void offBit(int & n, int b) {n &= ~two(b);}\ninline int lastBit(int n) {return n & (-n);}\ninline int cntBit(int n) {int res = 0; while(n && ++res) n -= n &(-n); return res;}\n\nconst int dx4[] = {-1, 0, 1, 0};\nconst int dy4[] = {0, 1, 0, -1};\nconst int dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};\nconst int dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};\n\n#define INP \"test.inp\"\n#define OUT \"test.out\"\n\n#define PI 3.1415926535897932385\n#define INF 1000111222\n#define EPS 1e-7\n#define MAXN 100000\n#define MOD 1000000007\n\n//END OF COMPETITVE PROGRAMMING TEMPLATE\nvi a, b, c;\nint n;\n\nint getMod(int m) {\n    ll tmp = 1;\n    fr(i, 1, m) tmp *= m, tmp *= MOD;\n    return tmp % MOD;\n}\n\nint solve() {\n    if(n == 1) return 1;\n    if(n % 2 == 0){\n        return getMod(m);\n    }\n    if(n == 3) return 18;\n    if(n == 5) return 1800;\n    int tmp = n / 2 + n * (n - 4) * (n - 4);\n    tmp *= 2;\n    int ans = ((tmp + 1) % MOD + getMod(n)) % n;\n}\n\nint main () {\n    #ifndef ONLINE_JUDGE\n    freopen(INP, \"r\", stdin); freopen(OUT, \"w\", stdout);\n    #endif\n\n    scanf(\"%d\", &n);\n    printf(\"%d\\n\", solve());\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "68e5a2826d3f6d028748effc05ab4fb2", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0}
    {"lang": "GNU C++17", "source_code": "// Author := Abhishek Giri\n\n#include \nusing namespace std;\n#define ll long long\n#define pb push_back\n#define mp make_pair\n#define mod 1000000007\n#define V(type) vecapital_in_tor<(type)>\n#define all(c) ((c).begin(),(c).end())\n#define in(var) cin>>(var)\n#define out(var) cout<<(var)\n#define on(var) cout<  > fact(1000001);\nvoid calculateprime()\n{\n    prime[0] = prime[1] = 1 ;\n    for(int i = 2 ; i <= 1000000 ; i++)\n    {\n        if(prime[i] == 0)\n        {\n            for(ll j = i*2 ; j <= 1000000 ; j += i )\n            {\n                fact[j].pb(i);\n            }\n        }\n    }\n}\n*/\n\nvoid fast(){\n    ios_base::sync_with_stdio(false);\n    cin.tie(NULL);\n    cout.tie(NULL);\n}\n\nbool isprime(ll n)\n{\n    for(ll i = 2 ; (ll) i*i <= n ; i++)\n    {\n        if(n % i == 0){\n            return false;\n        }\n    }\n    return true;\n}\n\nll fib(int n)\n{\n  ll a = 0, b = 1, c, i;\n  if( n == 0)\n    return a;\n  for (i = 2; i <= n; i++)\n  {\n    c = (a + b);\n    a = b;\n    b = c;\n  }\n  return b;\n}\n\n\nll gcd(ll a, ll b)\n{\n    if (b == 0)\n        return a;\n    return gcd(b, a % b);\n}\n\nll extendedgcd(ll a, ll b, ll& x, ll& y) {\n    if (b == 0) {\n        x = 1;\n        y = 0;\n        return a;\n    }\n    ll x1, y1;\n    ll d = extendedgcd(b, a % b, x1, y1);\n    x = y1;\n    y = x1 - y1 * (a / b);\n    return d;\n}\n\nll findgrouplcm(vector &arr, int n)\n{\n    ll ans = arr[0];\n\n    for (ll i = 1; i < n; i++)\n        ans = (arr[i] * (ans/(gcd(arr[i], ans))));\n\n    return ans;\n}\n\n\nll powerwithmod(ll x, unsigned ll y, ll p)\n{\n    ll res = 1;\n\n    x = x % p;\n\n    if (x == 0) return 0;\n\n    while (y > 0)\n    {\n        if (y & 1)\n            res = (res*x) % p;\n\n        y = y>>1; // y = y/2\n        x = (x*x) % p;\n    }\n    return res;\n}\n\n\nbool comp(const pair &a , const pair &b){\n    return a.first < b.first;\n    if(a.first == b.first)  return a.second < b.second;\n}\n\nbool is_consonant(char ch){\n    if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')   return false;\n    return true;\n}\n\nvoid solve(){\n    int g[20]={0,1,0,18,0,1800,0,670320,0,734832000,0,890786230,0,695720788,0,150347555,0};\n      o(g[n])\n}\n\nint main() {\n    fast();\n    ll t = 1;\n    //cin>>t;\n    while(t--)\n    {\n        solve();\n    }\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0778bab45b1838ce50331785af798f37", "src_uid": "a6a804ce23bc48ec825c17d64ac0bb69", "difficulty": 1900.0}
    {"lang": "GNU C++11", "source_code": "#include \n\n#define SZ(X) ((int)(X).size())\n#define MP(X,Y) make_pair((X),(Y))\n#define FOR(it, c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)\n\ntypedef long long LL;\n\nint MOD = int(1e9) + 7;\n\ninline int add(int a, int b) { return (a + b >= MOD) ? (a + b - MOD) : (a + b); }\ninline void inc(int &a, int b) { a = add(a, b); }\ninline int sub(int a, int b) { return (a - b < 0) ? (a - b + MOD) : (a - b); }\ninline void dec(int &a, int b) { a = sub(a, b); }\ninline int mul(int a, int b) { return (a * 1ll * b) % MOD; }\n\nusing namespace std;\n\nconst long double M_PIl acosl(-1);\n\nint n, r, v;\n\nlong double f(long double t) {\n    return r*cosl(-M_PIl/2-t*v/r)+v*t;\n}\n\nlong double search(long double x, long double from, long double to) {\n    for (int i=0; i<200; i++) {\n        double middle=(from+to)/2;\n        if (f(middle)\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define MAX(a,b) (a>b?a:b)\n#define MIN(a,b) (a pii;\n\nint gi() {\n    int a;\n    scanf(\"%d\", &a);\n    return a;\n}\n\nll gli() {\n    ll a;\n#if DBG\n    scanf(\"%lld\", &a);\n#else\n    scanf(\"%I64d\", &a);\n#endif\n    return a;\n}\n\n#define e 1e-10\n\ndouble search(double a) {\n    double l = 0;\n    double r = M_PI;\n    while (r - l > e) {\n        double m = (l+r) / 2.0;\n        if (m + sin(m) > a) {\n            r = m;\n        } else {\n            l = m;\n        }\n    }\n    return l;\n}\n\nint main() {\n    int n = gi();\n    double r = gi();\n    double v = gi();\n    double c = 2.0 * M_PI * r;\n\n    double t1 = c / v;\n\n    for (int i = 0; i < n; i++) {\n        int sii = gi();\n        int fii = gi();\n        double d = fii-sii;\n\n        double num = floor(d/c);\n        double res = t1 * num;\n        d = (d - num * c) / 2.0;\n\n        double th = search(d/r);\n\n        res += th * t1 / M_PI;\n\n        printf(\"%.10lf\\n\", res);\n    }\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e95ffe73e479c3eccbdba151c39d4ab8", "src_uid": "3882f2c02e83bd2d55de8004ea3bbd88", "difficulty": 2500.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define REP(n) for(__typeof(n) _i=0; _i<(n); ++_i)\n#define FOR(i,a,b) for(__typeof(b) i=a; i(b) ? (b) : (a))\n#define ABS(a) (((a)<0) ? -(a) : (a))\n#define SWAP(a,b) {a ^= b; b ^= a; a ^= b; }\n\n#define Inf 1000000007\n\ndouble r, v, s, f, l, T;\n\n// How much ground covered with t\ndouble len(double t) {\n    t /= 2.0; // amount of time before and after sensor at tire top\n    double a = t/T * 2*M_PI;\n    return 2.0*(v*t + cos(M_PI/2.0 - a));\n}\n\nint main() {\n    int n;\n\n    cin >> n >> r >> v;\n    l = 2*M_PI*r; // length of single turn\n    T = l/v; // time taken in single turn\n\n    // The sensor is moving at speed v+v*cos(a+va) where va = v/(2*pi*r)\n    // i.e. between 0 and 2v, fastest at top, the question is how large\n    // time window around top is needed for last fractional lap\n    REP(n) {\n        cin >> s >> f;\n        double full = floor((f-s)/l), last = fmod(f-s, l);\n        //cout << full << \" full turns, \" << last << \" remain\" << endl;\n        double a=0;\n        for(double i=0.5; i>1e-18; i/=2)\n            if(len(T*(a+i)) < last) a += i;\n        cout << setprecision(10) << (full+a)*T << endl;\n        //do {\n            //cout << \"Time: \";\n            //cin >> t;\n            //cout << floor(t/T) << \" full turns, \" << len(fmod(t,T)) << \" additional\" << endl;\n        //} while(t > 0.1);\n    }\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e1184868108da258e0c1294844d3b71d", "src_uid": "3882f2c02e83bd2d55de8004ea3bbd88", "difficulty": 2500.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define REP(n) for(__typeof(n) _i=0; _i<(n); ++_i)\n#define FOR(i,a,b) for(__typeof(b) i=a; i(b) ? (b) : (a))\n#define ABS(a) (((a)<0) ? -(a) : (a))\n#define SWAP(a,b) {a ^= b; b ^= a; a ^= b; }\n\n#define Inf 1000000007\n\ndouble r, v, s, f, l, T;\n\n// How much ground covered with t\ndouble len(double t) {\n    t /= 2.0; // amount of time before and after sensor at tire top\n    double a = t/T * 2*M_PI;\n    return 2.0*(v*t + cos(M_PI/2.0 - a));\n}\n\nint main() {\n    int n;\n\n    cin >> n >> r >> v;\n    l = 2*M_PI*r; // length of single turn\n    T = l/v; // time taken in single turn\n\n    // The sensor is moving at speed v+v*cos(a+va) where va = v/(2*pi*r)\n    // i.e. between 0 and 2v, fastest at top, the question is how large\n    // time window around top is needed for last fractional lap\n    REP(n) {\n        cin >> s >> f;\n        //cout << \"Race from \" << s << \" to \" << f << endl;\n        double full = floor((f-s)/l), last = fmod(f-s, l);\n        //cout << full << \" full turns, \" << last << \" remain\" << endl;\n        double a=0;\n        for(double i=0.5; i>1e-18; i/=2)\n            if(len(T*(a+i)) < last) a += i;\n        cout << setprecision(10) << (full+a)*T << endl;\n        //do {\n            //cout << \"Time: \";\n            //cin >> t;\n            //cout << floor(t/T) << \" full turns, \" << len(fmod(t,T)) << \" additional\" << endl;\n        //} while(t > 0.1);\n    }\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ba9a2870b70fceb63bb0214803e476a2", "src_uid": "3882f2c02e83bd2d55de8004ea3bbd88", "difficulty": 2500.0}
    {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define maxn (222)\nchar s[maxn], t[2], v[maxn];\nvector idx[3];\nsigned main()\n{\n\tint n, k; cin >> n >> k;\n\tscanf(\"%s%s\", s, t);\n\n\tfor(int i = 0; i < n; i++) {\n\t\tif(s[i] == t[0]) idx[0].push_back(i);\n\t\telse if(s[i] == t[1]) idx[1].push_back(i);\n\t\telse idx[2].push_back(i);\n\t}\n\t// for(int i = 0, sz = idx[2].size(); i < sz; i++ ) printf(\"[%d] \", idx[2][i]); printf(\"\\n\");\n\t// printf(\"t[0] = %c, t[1] = %c\\n\", t[0], t[1]);\n\n\tint ans = 0;\n\tfor(int x = 0, y; x <= k; x++) {\n\t\tfor(int a = 0, b; a <= x; a++) {\n\t\t\tfor(int i = 0, sz = idx[1].size(); i < sz; i++) {\n\t\t\t\tif(i < a) v[idx[1][i]] = t[0];\n\t\t\t\telse v[idx[1][i]] = t[1];\n\t\t\t}\n\t\t\tb = x-a;\n\t\t\tfor(int i = idx[0].size()-1; i >= 0; i--) {\n\t\t\t\tif(idx[0].size()-1 - i < b) v[idx[0][i]] = t[1];\n\t\t\t\telse v[idx[0][i]] = t[0];\n\t\t\t}\n\t\t\t// printf(\"[x] a = %d, b = %d\\n\", a, b);\n\n\t\t\ty = min(k-x, int(idx[2].size()));\n\n\t\t\t// printf(\"x = %d, y = %d\\n\", x, y);\n\t\t\tfor(int a_ = 0, b_; a_ <= y; a_++) {\n\t\t\t\tfor(int i = 0, sz = idx[2].size(); i < sz; i++) {\n\t\t\t\t\tif(i < a_) {v[idx[2][i]] = t[0]; /*printf(\"o\");*/}\n\t\t\t\t\telse v[idx[2][i]] = s[idx[2][i]];\n\t\t\t\t}\n\t\t\t\t// printf(\"\\n\");\n\n\t\t\t\tb_ = y-a_;\n\t\t\t\tfor(int i = idx[2].size()-1; i >= 0; i--) {\n\t\t\t\t\tif(idx[2].size()-1 - i < b_) v[idx[2][i]] = t[1];\n\t\t\t\t\t// else v[idx[2][i]] = s[idx[2][i]];\n\t\t\t\t}\n\n\t\t\t\t// printf(\"[y] a = %d, b = %d\\n\", a_, b_);\n\n\t\t\t\tv[n] = 0;\n\t\t\t\tif(n == 15 && k == 6) printf(\"check: %s [%d]\\n\", v, len(v));\n\n\t\t\t\tint tot = 0;\n\t\t\t\tfor(int i = 0, cnt = 0; i < n; i++) {\n\t\t\t\t\tif(v[i] == t[1]) tot += cnt;\n\t\t\t\t\tif(v[i] == t[0]) cnt++;\n\t\t\t\t}\n\t\t\t\tans = max(ans, tot);\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%d\\n\", ans);\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "01c518a4dfb9f85079d4d7444537e4d8", "src_uid": "9c700390ac13942cbde7c3428965b18a", "difficulty": 2100.0}
    {"lang": "GNU C++11", "source_code": "#include\n#define task \"test\"\n#define A first\n#define B second\n\nusing namespace std;\nconst int N=300010,OO=100000000;\n\nint n,k;\nstring s;\nchar xx,yy;\nlong long f[201][201][201][201];\nbool maximize(long long& a,long long b)\n{\n    if(a> n >> K;\n    cin >> s >> xx >> yy;\n\n    if(xx==yy)\n    {\n        cnt=0;\n        for(auto x:s)\n            if(x==xx) ++cnt;\n                else if(K)\n                    --K,++cnt;\n\n        cout<< 1ll*cnt*(cnt-1) / 2;\n        return;\n    }\n    s=\"#\"+s;\n    long long ans=0;\n    for(z=0;z<=K;++z)\n    for(j=0;j<=n;++j)\n    for(k=0;k<=n;++k)\n        f[0][j][k][z]=-OO;\n    f[0][0][0][0]=0;\n    for(i=1;i<=n;++i)\n    for(z=0;z<=K;++z)\n    for(j=0;j<=n;++j)\n    for(k=0;k<=n;++k)\n    {\n        f[i][j][k][z]=-OO;\n        if(i==2 && j==2 && k==0 && z==0)\n            int fqwrewre=0;\n        if(j>0)\n        if( s[i]==xx )\n            maximize(f[i][j][k][z],f[i-1][j-1][k][z]);\n        else if(z>0)\n            maximize(f[i][j][k][z],f[i-1][j-1][k][z-1]);\n\n        if(k>0)\n        if( s[i]==yy )\n            maximize(f[i][j][k][z],f[i-1][j][k-1][z]+j);\n        else if(z>0)\n            maximize(f[i][j][k][z],f[i-1][j][k-1][z-1]+1ll*j);\n        if(s[i]!=xx&&s[i]!=yy)\n        maximize(f[i][j][k][z],f[i-1][j][k][z]);\n        if(i==n)\n            maximize(ans,f[i][j][k][z]);\n    }\n    cout<\n\nusing namespace std;\n\nconst int INF = 1e9;\n\nint main() {\n#ifdef _DEBUG\n\tfreopen(\"input.txt\", \"r\", stdin);\n//\tfreopen(\"output.txt\", \"w\", stdout);\n#endif\n\t\n\tint n, k;\n\tstring s, t;\n\tcin >> n >> k >> s >> t;\n\tvector>> dp(n + 1, vector>(n + 1, vector(n + 1, -INF)));\n\tdp[0][0][0] = 0;\n\tfor (int i = 0; i < n; ++i) {\n\t\tfor (int ck = 0; ck <= k; ++ck) {\n\t\t\tfor (int cnt0 = 0; cnt0 <= n; ++cnt0) {\n\t\t\t\tif (dp[i][ck][cnt0] == -INF) continue;\n\t\t\t\tint e0 = s[i] == t[0];\n\t\t\t\tint e1 = s[i] == t[1];\n\t\t\t\tint e01 = t[0] == t[1];\n\t\t\t\t\n\t\t\t\tdp[i + 1][ck][cnt0 + e0] = max(dp[i + 1][ck][cnt0 + e0], dp[i][ck][cnt0] + (e1 ? cnt0 : 0));\n\t\t\t\t\n\t\t\t\tif (ck < k) {\n\t\t\t\t\tdp[i + 1][ck + 1][cnt0 + 1] = max(dp[i + 1][ck + 1][cnt0 + 1], dp[i][ck][cnt0] + (e01 ? cnt0 : 0));\n\t\t\t\t\tdp[i + 1][ck + 1][cnt0 + e01] = max(dp[i + 1][ck + 1][cnt0 + e01], dp[i][ck][cnt0] + cnt0);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tint ans = 0;\n\tfor (int ck = 0; ck <= k; ++ck) {\n\t\tfor (int cnt0 = 0; cnt0 <= n; ++cnt0) {\n\t\t\tans = max(ans, dp[n][ck][cnt0]);\n\t\t}\n\t}\n\t\n\tcout << ans << endl;\n\t\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b9bea83e2db1f58b2321aa4755520324", "src_uid": "9c700390ac13942cbde7c3428965b18a", "difficulty": 2100.0}
    {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\ntypedef long long int ll;\ntypedef unsigned long long int ull;\n#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)\nconst int MOD = 1e9+7;\nconst int N=205;\nconst int INF=1e5+5;\nll dp[N][N][N];\nstring s,t;\nint n ,  k ;\nll solve(int index , int last_t1 , int last_k) {\n    if (index == n)return 0;\n    ll &ans = dp[index][last_t1][last_k];\n    if (ans != -1)return ans;\n    if (last_k == k) {\n        if (s[index] == t[0]) {\n            ans = max(ans, solve(index + 1, last_t1 + 1, last_k));\n        }\n        if (s[index] == t[1]) {\n            ans = max(ans, last_t1 + solve(index + 1, last_t1, last_k));\n        }\n            ans = max(ans, solve(index + 1, last_t1, last_k));\n\n        return ans;\n    }\n\n    if (s[index] == t[0]) {\n        ans = max({solve(index + 1, last_t1 + 1, last_k), last_t1 + solve(index + 1, last_t1, last_k + 1)});\n    }\n    if (s[index] == t[1]) {\n        ans = max({solve(index + 1, last_t1 + 1, last_k + 1), last_t1 + solve(index + 1, last_t1, last_k)});\n    }\n        ans = max({solve(index + 1, last_t1 + 1, last_k + 1),\n                   last_t1 + solve(index + 1, last_t1, last_k + 1),\n                   solve(index + 1, last_t1, last_k)});\n\n    return ans;\n}\nint main() {\n    IO;\n    cin >> n >> k >> s >> t;\n    if(t[0]==t[1]){\n        ll ans= 0;\n        for(char c : s){\n            if(c==t[0]){\n                ans++;\n            }\n        }\n        ans=min(n,ans+k);\n        cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long ll;\n\nll n, X1[7], Y1[7], X2[7], Y2[7];\n\n\nint main()\n{\n    cin >> n;\n    ll s=0, lx=1e6, rx=-lx, ly=lx, ry=-ly;\n    for (int i=0;i> X1[i] >> Y1[i] >> X2[i] >> Y2[i]);\n        s+=abs(X1[i]-X2[i])*1LL*abs(Y1[i]-Y2[i]);\n        lx=min(lx, X1[i]);\n        lx=min(lx, X2[i]);\n        rx=max(rx, X1[i]);\n        rx=max(rx, X2[i]);\n        ly=min(ly, Y1[i]);\n        ly=min(ly, Y2[i]);\n        ry=max(ry, Y1[i]);\n        ry=max(ry, Y2[i]);\n    }\n\n    puts(s==(ry-ly)*(rx-lx) ? \"YES\" : \"NO\");\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f87f0d5def212a15a1f2460c47ede49a", "src_uid": "f63fc2d97fd88273241fce206cc217f2", "difficulty": 1500.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std;\nstruct kvadrat {\n\tint x, y, x1, y1, s;\n\tvoid sc() {\n\t\ts = (x1 - x) * (y1 - y);\n\t}\n};\nint main()\n{\n\tint n;\n\tcin >> n;\n\tvector a(n);\n\tint s = 0;\n\tint minx = 31401, maxx = -1, miny = 31401, maxy = -1;\n\tfor (int i = 0; i < n; i++) {\n\t\tint x, y, x1, y1;\n\t\tcin >> x >> y >> x1 >> y1;\n\t\tif (x < minx)minx = x;\n\t\tif (x1 > maxx)maxx = x1;\n\t\tif (y < miny)miny = y;\n\t\tif (y1 > maxy)maxy = y1;\n\t\ta[i] = { x, y, x1, y1, 0 };\n\t\ta[i].sc();\n\t\ts += a[i].s;\n\t}\n\tbool ans = true;\n\tif (int(sqrt(s)) * int(sqrt(s)) != s) {\n\t\tans = false;\n\t}\n\tif (maxx - minx != maxy - miny) {\n\t\tans = false;\n\t}\n\tif ((maxx - minx) * (maxx - minx) != s) {\n\t\tans = false;\n\t}\n\tif (ans) {\n\t\tcout << \"YES\";\n\t}\n\telse {\n\t\tcout << \"NO\";\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ad232cd7e7cbc4a5db85e7516a565772", "src_uid": "f63fc2d97fd88273241fce206cc217f2", "difficulty": 1500.0}
    {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long ll;\n\nint n, X1[7], Y1[7], X2[7], Y2[7];\n\n\nint main()\n{\n    scanf(\"%d\", &n);\n    ll s=0, lx=1e6, rx=-lx, ly=lx, ry=-ly;\n    for (int i=0;i\nstruct biao\n{\n    int x,y;\n}max,min;\nint main()\n{\n    min.x=min.y=1000000;\n    max.x=max.y=-1000000;\n    int n;\n    scanf(\"%d\",&n);\n    int s;\n    long long s=0;\n    while(n--)\n    {\n        int x1,y1,x2,y2;\n        scanf(\"%d%d%d%d\",&x1,&y1,&x2,&y2);\n        if(max.xx1||min.y>y1){min.x=x1;min.y=y1;};\n        s+=(x2-x1)*(y2-y1);\n    }\n    if(s==(max.x-min.x)*(max.y-min.y))printf(\"YES\\n\");\n    else printf(\"NO\\n\");\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a039000d71b9d0dbdf1432794dc3d20a", "src_uid": "f63fc2d97fd88273241fce206cc217f2", "difficulty": 1500.0}
    {"lang": "GNU C++", "source_code": "/*\n    \u300c\u51fa\u305d\u3046\u3068\u601d\u3048\u3070\u3002\uff08\u5168\u5b8c\u610f\u601d)\u300d\n    \u300c\u51fa\u3057\u3061\u3083\u3063\u3066\u3044\u3044\u3059\u304b\uff5e\uff1f\u300d\n*/\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint in() {\n    int x = 0, c;\n    for (; (unsigned int)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -in(); if (!~c) throw ~0; }\n    do { x = (x << 3) + (x << 1) + (c - '0'); } while ((unsigned int)((c = getchar()) - '0') < 10);\n    return x;\n}\n\nint a[100] , b[100] , c[100];\n\nint ans[(1<<25)+1] = {} , sz = 0;\n\nint main(){\n    int n = in() , m = in() , t = in();\n    for(int i = 0 ; i < m ; i++){\n        a[i] = in() , b[i] = in() , c[i] = in();\n        a[i]-- , b[i] --;\n    }\n    for(int i = 0 ; i < (1<>j&1){\n                osu[ a[j] ]++;\n                otoko[ b[j] ]++;\n                if(osu[ a[j] ] > 1){ f = false; break; }\n                if(otoko[ b[j] ] > 1){ f = false; break; }\n                uho += c[j];\n            }\n        }\n        if(f){ ans[sz++] = uho; }\n    }\n    sort(ans,ans+sz);\n    cout << ans[t-1] << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "76832e162332051d18f120f0b21a9730", "src_uid": "7348b5644f232bf377a4834eded42e4b", "difficulty": 1800.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\n#define frup(FRUP_I,FROM,TO) for(long FRUP_I=FROM;FRUP_I<=TO;FRUP_I++)\n#define frdn(FRDN_I,FROM,TO) for(long FRDN_I=FROM;FRDN_I ll;\n\nconst long INF=(long)1e09;\n\nlong n,m,j,k,ans=0,c,t,z;\nvectorall,a(40,0),h,w,r;\nsethus,wiw;\n\nint main(){\n   // freopen(IN,\"r\",stdin);\n   // freopen(OUT,\"w\",stdout);\n      scanf(\"%ld %ld %ld\",&n,&k,&t); \n       h.pub(0);\n                     w.pub(0);\n                    r.pub(0);  \n       frup(i,1,k){\n                   long x,y,z;\n                    scanf(\"%ld %ld %ld\",&x,&y,&z);\n                    h.pub(x);\n                     w.pub(y);\n                    r.pub(z);\n                   }  \n  while(true){\n              hus.clear();\n              wiw.clear();\n               long res=0;\n               bool f=1;\n                frup(i,1,k)\n                  if(a[i]>0){\n                            if(hus.count(h[i])||wiw.count(w[i])){\n                                                                 f=0;\n                                                                 break;\n                                                                 }\n                              hus.insert(h[i]);\n                              wiw.insert(w[i]);\n                              res+=r[i];                                      \n                            }\n               if(f)all.pub(res);   \n               a[k]++;\n               z=k;\n                while(z>0){\n                           if(a[z]>1){\n                                      a[z-1]++;\n                                      a[z]=0;\n                                      }\n                             z--;         \n                           }   \n               if(a[0])break;                   \n              }            \n   sort(all.begin(),all.end());\n  printf(\"%ld\",all[t-1]);                                      \nreturn 0;\n}       \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5217790ea52346af9d219f0a8969df58", "src_uid": "7348b5644f232bf377a4834eded42e4b", "difficulty": 1800.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\n#define FOR(i, a, n) for (int i = (a); i < (n); ++i)\n#define REP(i, n) FOR(i, 0, n)\n\nint n, k, t, a[21][21], match[21];\n\ninline int count1(int n) {\n    int ans = 0;\n    for (; n > 0; n &= n - 1)\n        ++ans;\n    return ans;\n}\n\nvoid findAll(const vector &males, vector *ans, int k = 0, int w = 0) {\n    if (k == males.size()) {\n        ans->push_back(w);\n        return;\n    }\n    REP(i, n)\n        if (a[males[k]][i] > 0 && match[i] == -1) {\n            match[i] = males[k];\n            findAll(males, ans, k + 1, w + a[males[k]][i]);\n            match[i] = -1;\n        }\n}\n\nint main() {\n    scanf(\"%d%d%d\", &n, &k, &t);\n    REP(i, k) {\n        int u, v, r;\n        scanf(\"%d%d%d\", &u, &v, &r);\n        --u, --v;\n        a[u][v] = r;\n    }\n\n    vector ans;\n    for (int mask = 0; mask < (1 << n); ++mask) {\n        vector males;\n        REP(i, n) {\n            if (mask & (1 << i))\n                males.push_back(i);\n        }\n        memset(match, -1, sizeof match);\n        findAll(males, &ans);\n    }\n    sort(ans.begin(), ans.end());\n    printf(\"%d\\n\", ans[t - 1]);\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4d7ab844346565f085ec88926639787a", "src_uid": "7348b5644f232bf377a4834eded42e4b", "difficulty": 1800.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint n,k,t,a[25],b[25],h[25];\nbool usedm[5],usedw[5];\nvector r;\nint main()\n{\n    #ifndef ONLINE_JUDGE\n    freopen(\"input.txt\",\"r\",stdin);\n    freopen(\"output.txt\",\"w\",stdout);\n#endif\n    cin>>n>>k>>t;\n    for (int i=0;i>a[i]>>b[i]>>h[i];\n        a[i]--;b[i]--;\n    }\n    for (int mask=0;mask<(1<\n#define LL long long\nusing namespace std;\n\nconst int MOD = 1e9 + 7;\n\nLL quickmod(LL a, LL b, LL MOD)\n{\n    LL ans;\n    \n    ans = 1;\n    while(b){\n        if(b & 1){\n            ans = (ans * a) % MOD;\n        }\n        b >>= 1;\n        a = a * a % MOD;\n    }\n\n    return ans % MOD;\n}\n\nLL sum(int n)\n{\n\tif(!n){\n\t\treturn 0;\n\t}\n\tif(n == 1){\n\t\treturn 4; \n\t}\n\tif(n & 1){\n\t\treturn (11 * quickmod(3, n - 1 >> 1) + MOD - 7) % MOD; \n\t}\n\t\n\treturn (19 * quickmod(3, n - 1 >> 1) + MOD - 7) % MOD; \n}\n\nLL calc(int n)\n{\n\treturn (sum(n) + sum(n + 1 >> 1)) * (MOD + 1) / 2 % MOD; \n}\n\nint main()\n{\n\t// freopen(\"93D.in\", \"r\", stdin); \n\tint l, r; \n\n\twhile(scanf(\"%d%d\", &l, &r) == 2){\n\t\tprintf(\"%lld\\n\", (calc(r) - calc(l - 1) + MOD) % MOD);\n\t}\n\t\n\treturn 0; \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "eacff71ed14cc1a0be4abbf16e93fbcb", "src_uid": "e04b6957d9c1659e9d2460410cb57f10", "difficulty": 2500.0}
    {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst int MOD=1000000007\ntypedef long long LL;\nint L,R;\nstruct MAT\n{\n    LL m[9][9];\n    MAT operator * (const MAT &b)const\n    {\n        int i,j,k;\n        MAT ret={0,};\n        for (i=0;i<9;i++) for (j=0;j<9;j++)\n        {\n            for (k=0;k<9;k++) ret.m[i][j] = (ret.m[i][j]+m[i][k]*b.m[k][j])%MOD;\n        }\n        return ret;\n    }\n}   mat[30],forab[200];\nint dy(int n)\n{\n    if (!n) return 0;\n    if (n == 1) return 4;\n    if (n == 2) return 12;\n    int i,ret=0; MAT m;\n    bool sw=0;\n    n--;\n    for (i=0;i<30;i++) if ((n>>i)&1){\n        if (!sw) m = mat[i], sw = 1;\n        else m = m*mat[i];\n    }\n    ret = m.m[8][8]*4%MOD;\n    for (i=0;i<8;i++) ret = (ret+m.m[8][i])%MOD;\n    return ret;\n}\nint solve(int n)\n{\n    int ret=(dy(n)+dy((n+1)/2))%MOD;\n    return ret&1?(ret+MOD)/2:ret/2;\n}\nvoid inc(int a,int b){ mat[0].m[a][b]++; }\nint main()\n{\n    //freopen(\"AC.in\",\"r\",stdin);\n    //freopen(\"AC.out\",\"w\",stdout);       \n    int i;\n    inc(0,4), inc(1,5), inc(1,7), \n    inc(2,6), inc(2,3), inc(3,7), inc(3,5);\n    inc(4,0), inc(4,1), inc(5,0), \n    inc(5,1), inc(6,2), inc(7,3), inc(7,6);\n    for (i=0;i<9;i++) mat[0].m[8][i]++;\n    for (i=1;i<30;i++) mat[i] = mat[i-1]*mat[i-1];\n    scanf(\"%d%d\",&L,&R);\n    printf(\"%d\",(solve(R)-solve(L-1)+MOD)%MOD);\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "eba13a89b5fb98dac91c7255261791de", "src_uid": "e04b6957d9c1659e9d2460410cb57f10", "difficulty": 2500.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \n#define MOD 1000000007\nusing namespace std; \ntypedef long long ll;\nstruct matrix\n{\n\tll arr[25][25]; \n\tmatrix()\n\t{\n\t\tmemset(arr, 0, sizeof(arr)); \n\t}\n\tinline matrix operator *(const matrix &a) const\n\t{\n\t\tmatrix res; \n\t\tfor (int i = 0; i < 17; i++)\n\t\t{\n\t\t\tfor (int j = 0; j < 17; j++)\n\t\t\t{\n\t\t\t\tfor (int k = 0; k < 17; k++)\n\t\t\t\t\tres.arr[i][j] = (res.arr[i][j] + arr[i][k] * a.arr[k][j]) % MOD; \n\t\t\t}\n\t\t}\n\t\treturn res; \n\t}\n}; \ninline matrix quick_pow(matrix a, int n)\n{\n\tmatrix res; \n\tfor (int i = 0; i < 17; i++)\n\t\tres.arr[i][i] = 1; \n\twhile (n)\n\t{\n\t\tif (n & 1)\n\t\t\tres = res * a; \n\t\ta = a * a; \n\t\tn >>= 1; \n\t}\n\treturn res; \n}\ninline ll G(int n)\n{\n\tif (!n)\n\t\treturn 0; \n\tmatrix mat, res; \n\tfor (int i = 0; i < 16; i++)\n\t{\n\t\tint a = i >> 2, b = i & 3; \n\t\tif ((a ^ b) <= 1)\n\t\t\tcontinue; \n\t\tmat.arr[i][16]++; \n\t\tfor (int c = 0; c < 4; c++)\n\t\t{\n\t\t\tif ((b ^ c) <= 1 || (!b && (a ^ c) == 1))\n\t\t\t\tcontinue; \n\t\t\tmat.arr[i][b << 2 | c]++; \n\t\t}\n\t}\n\tmat.arr[16][16]++; \n\tres = quick_pow(mat, n - 1); \n\tint ans = 4; \n\tfor (int i = 0; i < 16; i++)\n\t\tans = (ans + res.arr[i][16]) % MOD; \n\treturn ans;\n}\ninline ll F(int n)\n{\n\tif (!n)\n\t\treturn 0; \n\tif (n == 1)\n\t\treturn 4;\n\treturn (G(n) + G(n + 1 >> 1)) % MOD; \n}\nint main()\n{\n\t// freopen(\"93D.in\", \"r\", stdin); \n\tint l, r; \n\tscanf(\"%d%d\", &l, &r); \n\tprintf(\"%lld\\n\", (F(r) - F(l - 1) + MOD) * (MOD + 1) / 2 % MOD);\n\treturn 0; \n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cb7166311e4415a421ccec6f9a836af1", "src_uid": "e04b6957d9c1659e9d2460410cb57f10", "difficulty": 2500.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \n#define MOD 1000000007\ntypedef long long ll;\nstruct mat\n{\n\tll arr[25][25]; \n\tmat()\n\t{\n\t\tmemset(arr, 0, sizeof(arr)); \n\t}\n\tinline ll *operator [](const int &x)\n\t{\n\t\treturn arr[x];\n\t}\n\tinline const ll *operator [](const int &x) const\n\t{\n\t\treturn arr[x];\n\t}\n\tinline mat operator *(const mat &a) const\n\t{\n\t\tmat res; \n\t\tfor (int i = 0; i < 25; i++)\n\t\t{\n\t\t\tfor (int j = 0; j < 25; j++)\n\t\t\t{\n\t\t\t\tfor (int k = 0; k < 25; k++)\n\t\t\t\t\t(res[i][j] += arr[i][k] * a[k][j]) %= MOD; \n\t\t\t}\n\t\t}\n\t\treturn res; \n\t}\n\tinline mat operator *=(const mat &a)\n\t{\n\t\treturn *this = *this * a; \n\t}\n}; \ninline mat quick_pow(mat a, int n)\n{\n\tmat res; \n\tfor (int i = 0; i < 25; i++)\n\t\tres[i][i] = 1; \n\twhile (n)\n\t{\n\t\tif (n & 1)\n\t\t\tres *= a; \n\t\ta *= a; \n\t\tn >>= 1; \n\t}\n\treturn res; \n}\ninline ll sum(int n)\n{\n\tif (!n)\n\t\treturn 0; \n\tmat dp; \n\tfor (int i = 0; i < 16; i++)\n\t{\n\t\tint x = i >> 2, y = i & 3; \n\t\tif ((x ^ y) <= 1)\n\t\t\tcontinue; \n\t\tdp[i][16]++; \n\t\tfor (int z = 0; z < 4; z++)\n\t\t{\n\t\t\tif ((y ^ z) <= 1 || (!y && (x ^ z) == 1))\n\t\t\t\tcontinue; \n\t\t\tdp[i][y << 2 | z]++; \n\t\t}\n\t}\n\tdp[16][16]++; \n\tmat res = quick_pow(dp, n - 1); \n\tll ans = 4; \n\tfor (int i = 0; i < 16; i++)\n\t\t(ans += res[i][16]) %= MOD; \n\treturn ans; \n}\ninline ll calc(int n)\n{\n\treturn (sum(n) + sum(n + 1 >> 1)) % MOD * (MOD + 1) / 2 % MOD; \n}\nint main()\n{\n\t// freopen(\"93D.in\", \"r\", stdin); \n\tint l, r; \n\tscanf(\"%d%d\", &l, &r); \n\tprintf(\"%lld\\n\", (calc(r) - calc(l - 1) + MOD) % MOD);\n\treturn 0; \n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "206638aa290183eec65a53143dbd2ea6", "src_uid": "e04b6957d9c1659e9d2460410cb57f10", "difficulty": 2500.0}
    {"lang": "GNU C++17", "source_code": "// Author -- xyr2005\n\n#include\n\n#define lowbit(x) ((x)&(-(x)))\n#define DEBUG fprintf(stderr,\"Running on Line %d in Function %s\\n\",__LINE__,__FUNCTION__)\n#define SZ(x) ((int)x.size())\n#define mkpr std::make_pair\n#define pb push_back\n\ntypedef long long ll;\ntypedef unsigned int uint;\ntypedef unsigned long long ull;\ntypedef std::pair pi;\ntypedef std::pair pl;\nusing std::min;\nusing std::max;\n\nconst int inf=0x3f3f3f3f,Inf=0x7fffffff;\nconst ll INF=0x3f3f3f3f3f3f3f3f;\n\nstd::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());\ntemplate _Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}\ntemplate inline _Tp abs(const _Tp &a){return a>=0?a:-a;}\ntemplate inline void chmax(_Tp &a,const _Tp &b){(ainline void chmin(_Tp &a,const _Tp &b){(binline void read(_Tp &x)\n{\n\tchar ch(getchar());bool f(false);while(!isdigit(ch)) f|=ch==45,ch=getchar();\n\tx=ch&15,ch=getchar();while(isdigit(ch)) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();\n\tf&&(x=-x);\n}\ntemplate inline void read(_Tp &t,Args &...args){read(t);read(args...);}\ninline int read_str(char *s)\n{\n\tchar ch(getchar());while(ch==' '||ch=='\\r'||ch=='\\n') ch=getchar();\n\tchar *tar=s;*tar=ch,ch=getchar();while(ch!=' '&&ch!='\\r'&&ch!='\\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();\n\treturn tar-s+1;\n}\n\nconst int N=100005;\nint a[N],n;\nint pos[N<<1];\nstd::vector sg[N];\nstd::set rest[505];\nbool st[N][505];\nint res[505];\ninline bool cmp(int a,int b){return a>b;}\nint Query(int i,int j)\n{\n\tif(2*a[i] &o)\n{\n\tfor(auto it:o) vis[it]=true;\n\tint ans=0;for(int i=0;;++i) if(!vis[i]){ans=i;break;}\n\tfor(auto it:o) vis[it]=false;\n\treturn ans;\n}\nint solve()\n{\n\tmemset(pos,63,sizeof(pos));\n\tmemset(res,0,sizeof(res));\n\tread(n);\n\tfor(int i=0;i<=500;++i) rest[i].clear();\n\tfor(int i=0;i<=500;++i) for(int j=0;j<=n;++j) rest[i].insert(j);\n\tfor(int i=0;i<=n+1;++i) sg[i].clear();\n\tfor(int i=0;i<=n+1;++i) memset(st[i],0,sizeof(st[i]));\n\tfor(int i=1;i<=n;++i) read(a[i]),pos[a[i]]=i;\n\tfor(int i=100000;i>=1;--i) chmin(pos[i],pos[i+1]);\n\tstd::vector v;\n\tfor(int i=n;i>=1;--i)\n\t{\n\t\tint cur=0;\n\t\twhile(cur<=n)\n\t\t{\n\t\t\tint l=cur,r=n;\n\t\t\tint val=Query(i,a[cur]);\n\t\t\twhile(l>1;\n\t\t\t\tif(Query(i,a[mid])==val) l=mid;\n\t\t\t\telse r=mid-1;\n\t\t\t}\n\t\t\tupd(i,cur,l,val);\n\t\t\tif(cur<=i&&i<=l) v.pb(val);\n\t\t\tcur=l+1;\n\t\t}\n\t}\n\treturn mex(v);\n}\n\nint main()\n{\n\tint n;read(n);\n\tint ans=0;\n\twhile(n--) ans^=solve();\n\tputs(ans?\"YES\":\"NO\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "297f3ab422702817285f9deb9994ed4d", "src_uid": "2a8c2be70fa8983040646150a579f6c1", "difficulty": 3500.0}
    {"lang": "GNU C++17", "source_code": "#include\n\ntemplate  T& setmax(T& a, const T& b) { if (b > a) a = b; return a; }\ntemplate  T& setmin(T& a, const T& b) { if (b < a) a = b; return a; }\n\nint get_nimber(std::vector A) {\n\tusing namespace std;\n\n\t//cerr << \"START\" << '\\n';\n\t//for (auto a : A) { cerr << a << ' '; } cerr << '\\n';\n\t\n\tassert(std::is_sorted(A.begin(), A.end()));\n\n\t// find the maximum convex subsequence\n\tint N = int(A.size());\n\n\tset step_0;\n\tconst int MAXL = 500;\n\tvector> min_first(MAXL+1);\n\tvector val(N);\n\tvector>> to_insert(N);\n\tvector cutoffs; cutoffs.reserve(MAXL+1);\n\n\tvector> slow(N, vector(N));\n\tvector slow_start(N);\n\tfor (int i = N-1; i >= 0; i--) {\n\t\tfor (int j = 0; j < i; j++) {\n\t\t\tset moves;\n\t\t\tfor (int k = i+1; k < N; k++) {\n\t\t\t\tif (A[j] + A[k] > A[i] * 2) {\n\t\t\t\t\tmoves.insert(slow[k][i]);\n\t\t\t\t}\n\t\t\t}\n\t\t\tint v = 0; while (moves.count(v)) v++;\n\t\t\tslow[i][j] = v;\n\t\t}\n\t\tset moves;\n\t\tfor (int k = i+1; k < N; k++) {\n\t\t\tmoves.insert(slow[k][i]);\n\t\t}\n\t\tint v = 0; while (moves.count(v)) v++;\n\t\tslow_start[i] = v;\n\t}\n\n\tfor (int i = N-1; i >= 0; i--) {\n\t\tcutoffs.clear();\n\t\tfor (int l = 0; l <= MAXL; l++) {\n\t\t\twhile (!min_first[l].empty() && val[min_first[l].top()] != l) {\n\t\t\t\tmin_first[l].pop();\n\t\t\t}\n\t\t\tif (min_first[l].empty()) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tassert(l+1 <= MAXL);\n\t\t\tint nv = 2 * A[i] - A[min_first[l].top()];\n\t\t\tassert(nv < A[i]);\n\t\t\tint j = int(upper_bound(A.begin(), A.end(), nv) - A.begin());\n\t\t\tassert(j <= i);\n\t\t\tcutoffs.push_back(j);\n\t\t}\n\t\tint V = int(cutoffs.size());\n\t\tstep_0.insert(V);\n\n\t\tassert(V == slow_start[i]);\n\n\t\tval[i] = V;\n\t\tmin_first[V].push(i);\n\t\tfor (int v = 1; v < V; v++) {\n\t\t\tcutoffs[v] = max(cutoffs[v-1], cutoffs[v]);\n\t\t}\n\t\tfor (int v = V-1; v >= 0; v--) {\n\t\t\tto_insert[cutoffs[v]].push_back({i, v});\n\t\t}\n\n\t\tfor (auto [a, v] : to_insert[i]) {\n\t\t\tassert(val[a] == v+1);\n\t\t\tval[a] = v;\n\t\t\tmin_first[v].push(a);\n\t\t}\n\t}\n\n\tint ans = 0;\n\twhile (step_0.count(ans)) ans++;\n\t//cerr << \"Answer \" << ans << '\\n';\n\treturn ans;\n}\n\nint main() {\n\tusing namespace std;\n\tios_base::sync_with_stdio(false), cin.tie(nullptr);\n\n\tint T; cin >> T;\n\tint ans = 0;\n\twhile (T--) {\n\t\tint N; cin >> N;\n\t\tvector A(N);\n\t\tfor (auto& a : A) cin >> a;\n\t\tans ^= get_nimber(std::move(A));\n\t}\n\tcout << (ans != 0 ? \"YES\" : \"NO\") << '\\n';\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "85d87968cf0ca82f203650e8f07663bb", "src_uid": "2a8c2be70fa8983040646150a579f6c1", "difficulty": 3500.0}
    {"lang": "GNU C++11", "source_code": "#include\n#define cs const\n#define pb push_back\nusing namespace std;\nchar xxx; \nvoid chkmx(int &a, int b){ if(a < b) a = b; }\ncs int N = 1e5 + 50, M = 450;\ncs int K = 1 << 17;\nint n, m, a[N];\nstruct zkw{\n\tint t[K << 1]; vector clr; \n\tvoid init(){ for(int z : clr) t[z] = 0; clr.clear(); }\n\tvoid ins(int l, int r, int v){\n\t\tfor(l += K - 1, r += K + 1; \n\t\tl ^ r ^ 1; l >>= 1, r >>= 1){\n\t\t\tif(l & 1 ^ 1) chkmx(t[l ^ 1], v), clr.pb(l ^ 1);\n\t\t\tif(r & 1) chkmx(t[r ^ 1], v), clr.pb(r ^ 1);\n\t\t} \n\t} int qry(int x){\n\t\tint ans = 0; for(x += K; x; x >>= 1)\n\t\tchkmx(ans, t[x]); return ans;\n\t}\n} t[M];\nint work(){\n\tcin >> m; int mx = 0, lm = 0;\n\tfor(int i = 1; i <= m; i++)\n\tscanf(\"%d\", &a[i]), mx = max(mx, a[i]);\n\tlm = sqrt(2 * mx) + 2, lm = min(lm, m);\n\tfor(int i = 1; i <= lm; i++) t[i].init();\n\t\n\tfor(int i = m - 1; i; i--){\n\t\tstatic int dp[M];\n\t\tmemset(dp, 0, (lm + 1) << 2); dp[0] = m;\n\t\tfor(int d = 1; d <= lm; d++){\n\t\t\tdp[d] = t[d].qry(a[i]); \n\t\t\tint l = max(1, 2 * a[i] - a[dp[d - 1]] + 1);\n\t\t\tif(!dp[d]) { t[d].ins(l, mx + 1, i); break; }\n\t\t\tint r = min(mx + 1, 2 * a[i] - a[dp[d]]);\n\t\t\tt[d].ins(l, r, i);\n\t\t\tdp[d] = min(dp[d], dp[d - 1]);\n\t\t} \n\t} \n\tfor(int d = 1; d <= lm; d++)\n\tif(!t[d].qry(mx + 1)) return d;\n}\nchar yyy;\nint main(){\n\t#ifdef FSYo\n\tfreopen(\"1.in\", \"r\", stdin);\n\t#endif\n//\tcout << (&xxx- &yyy) /1024/1024 <<'\\';\n\tcin >> n; int SG = 0;\n\twhile(n--) SG ^= work();\n\tif(SG) puts(\"YES\");\n\telse puts(\"NO\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ddd097acb73faecd72c4460af5662b31", "src_uid": "2a8c2be70fa8983040646150a579f6c1", "difficulty": 3500.0}
    {"lang": "GNU C++17", "source_code": "// Author -- xyr2005\n\n#include\n\n#define lowbit(x) ((x)&(-(x)))\n#define DEBUG fprintf(stderr,\"Running on Line %d in Function %s\\n\",__LINE__,__FUNCTION__)\n#define SZ(x) ((int)x.size())\n#define mkpr std::make_pair\n#define pb push_back\n\ntypedef long long ll;\ntypedef unsigned int uint;\ntypedef unsigned long long ull;\ntypedef std::pair pi;\ntypedef std::pair pl;\nusing std::min;\nusing std::max;\n\nconst int inf=0x3f3f3f3f,Inf=0x7fffffff;\nconst ll INF=0x3f3f3f3f3f3f3f3f;\n\nstd::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());\ntemplate _Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}\ntemplate inline _Tp abs(const _Tp &a){return a>=0?a:-a;}\ntemplate inline void chmax(_Tp &a,const _Tp &b){(ainline void chmin(_Tp &a,const _Tp &b){(binline void read(_Tp &x)\n{\n\tchar ch(getchar());bool f(false);while(!isdigit(ch)) f|=ch==45,ch=getchar();\n\tx=ch&15,ch=getchar();while(isdigit(ch)) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();\n\tf&&(x=-x);\n}\ntemplate inline void read(_Tp &t,Args &...args){read(t);read(args...);}\ninline int read_str(char *s)\n{\n\tchar ch(getchar());while(ch==' '||ch=='\\r'||ch=='\\n') ch=getchar();\n\tchar *tar=s;*tar=ch,ch=getchar();while(ch!=' '&&ch!='\\r'&&ch!='\\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();\n\treturn tar-s+1;\n}\n\nconst int N=100005;\nint a[N],n;\nint pos[N<<1];\nstruct vec{\n\tint a[505],pos;\n\tinline void clear(){pos=0;}\n\tinline void pb(int x){a[pos++]=x;}\n\tinline int* begin(){return a;}\n\tinline int* end(){return a+pos;}\n}sg[N];\nstd::set rest[505];\nbool st[N][505];\nint res[505];\ninline bool cmp(int a,int b){return a>b;}\nint Query(int i,int j)\n{\n\tif(2*a[i] &o)\n{\n\tfor(auto it:o) vis[it]=true;\n\tint ans=0;for(int i=0;;++i) if(!vis[i]){ans=i;break;}\n\tfor(auto it:o) vis[it]=false;\n\treturn ans;\n}\nint solve()\n{\n\tmemset(pos,63,sizeof(pos));\n\tmemset(res,0,sizeof(res));\n\tread(n);\n\tfor(int i=0;i<=500;++i) rest[i].clear();\n\tfor(int i=0;i<=500;++i) for(int j=0;j<=n;++j) rest[i].insert(j);\n\tfor(int i=0;i<=n+1;++i) sg[i].clear();\n\tfor(int i=0;i<=n+1;++i) memset(st[i],0,sizeof(st[i]));\n\tfor(int i=1;i<=n;++i) read(a[i]),pos[a[i]]=i;\n\tfor(int i=100000;i>=1;--i) chmin(pos[i],pos[i+1]);\n\tstd::vector v;\n\tfor(int i=n;i>=1;--i)\n\t{\n\t\tint cur=0;\n\t\twhile(cur<=n)\n\t\t{\n\t\t\tint l=cur,r=n;\n\t\t\tint val=Query(i,a[cur]);\n\t\t\twhile(l>1;\n\t\t\t\tif(Query(i,a[mid])==val) l=mid;\n\t\t\t\telse r=mid-1;\n\t\t\t}\n\t\t\tupd(i,cur,l,val);\n\t\t\tif(cur<=i&&i<=l) v.pb(val);\n\t\t\tcur=l+1;\n\t\t}\n\t}\n\treturn mex(v);\n}\n\nint main()\n{\n\tint n;read(n);\n\tint ans=0;\n\twhile(n--) ans^=solve();\n\tputs(ans?\"YES\":\"NO\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b66f37acd906ca8003361a897b464d8c", "src_uid": "2a8c2be70fa8983040646150a579f6c1", "difficulty": 3500.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long LL;\nconst LL mo=1e9+7;\nconst int N=2e6;\nLL n,mo,inv2,inv6,nx;\nLL f[N+10],g[N+10],h[N+10],sum1[N+10],sum2[N+10],sum3[N+10];\nLL mul(LL x,LL y) {\n    x%=mo;\n    LL z=1;\n    while (y) {\n        if (y&1) z=z*x%mo;\n        y>>=1;\n        x=x*x%mo;\n    }\n    return z;\n}\nLL Calc2(LL l,LL r) {\n    l%=mo;\n    r%=mo;\n    return (l+r)*(r-l+1)%mo*inv2%mo;\n}\nLL getsum(LL x) {\n    x%=mo;\n    return x*(x+1)%mo*(x*2+1)%mo*inv6%mo;\n}\nLL Calc3(LL l,LL r) {\n    return (getsum(r)-getsum(l-1))%mo;\n}\nLL SQRT(LL x) {\n    LL l=0,r=N;\n    while (lx) r=mid-1;\n        else l=mid;\n    }\n    return l;\n}\nLL getf(LL x) {\n    LL l=SQRT(x);\n    return (sum1[l]+l*((x-l*l+1)%mo))%mo;\n}\nLL getg(LL x) {\n    LL l=SQRT(x);\n    return (sum2[l]+l*Calc2(l*l,x))%mo;\n}\nLL geth(LL x) {\n    LL l=SQRT(x);\n    return (sum3[l]+l*Calc3(l*l,x))%mo;\n}\nvoid prework() {\n    nx=n%mo;\n    inv2=mul(2,mo-2);\n    inv6=mul(6,mo-2);\n    for (LL i=1;i*i<=n;i++) {\n        LL l=(i-1)*(i-1),r=i*i-1;\n        sum1[i]=(sum1[i-1]+(r-l+1)%mo*(i-1))%mo;\n        sum2[i]=(sum2[i-1]+Calc2(l,r)*(i-1))%mo;\n        sum3[i]=(sum3[i-1]+Calc3(l,r)*(i-1))%mo;\n    }\n    for (LL i=0;i*i<=n;i++) {\n        f[i]=getf(n-i*i);\n        g[i]=getg(n-i*i);\n        h[i]=geth(n-i*i);\n    }\n}\nvoid work() {\n    LL ans1=0;\n    for (LL i=0;i*i<=n;i++) {\n        LL nowx=i*i%mo*f[i]+g[i];\n        nowx%=mo;\n        ans1=(ans1+nowx)%mo;\n    }\n    ans1=ans1*4%mo;\n    LL nowx=(nx+1)*nx%mo*inv2%mo;\n    ans1=(ans1+nowx)%mo;\n    ans1=ans1*(nx+1)%mo;\n    LL ans2=0;\n    for (LL i=0;i*i<=n;i++) {\n        LL nowp=i*i%mo;\n        LL nowx=nowp*nowp%mo*f[i]+nowp*2*g[i]+h[i];\n        nowx%=mo;\n        ans2=(ans2+nowx)%mo;\n    }\n    ans2=ans2*4%mo;\n    nowx=getsum(nx);\n    ans2=(ans2+nowx)%mo;\n    ans1=((ans1-ans2)%mo+mo)%mo;\n    printf(\"%lld\\n\",ans1);\n}\nint main() {\n    scanf(\"%lld\",&n);\n    prework();\n    work();\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "41d6974fb828f5a802c603102f63dfc6", "src_uid": "b9a785849e5ffadb24b58b38b1f2ee48", "difficulty": 2900.0}
    {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n\ntypedef long long s64;\nconst int D=1e9+7;\ns64 mi(s64 x,int y=D-2)\n{\n\ts64 ans=1;\n\twhile(y)\n\t{\n\t\tif(y&1)ans=ans*x%D;\n\t\tx=x*x%D;y>>=1;\n\t}\n\treturn ans;\n}\ns64 F,F2;\nvoid solve(s64 n)\n{\n\ts64 a0=0,a1=0,a2=0,a3=0;\n\tint my=0;\n\twhile((s64)my*my<=n)++my;\n\t--my;\n\ts64 s2=0,s4=0,s6=0;\n\tfor(int y=1;y<=my;++y)\n\t{\n\t\tint y_2=(s64)y*y%D;\n\t\t(s2+=y_2)%=D;\n\t\t(s4+=(s64)y_2*y_2)%=D;\n\t\t(s6+=(s64)y_2*y_2%D*y_2)%=D;\n\t}\n\tfor(int x=0;(s64)x*x<=n;++x)\n\t{\n\t\twhile((s64)x*x+(s64)my*my>n)\n\t\t{\n\t\t\tint y_2=(s64)my*my%D;\n\t\t\t(s2-=y_2)%=D;\n\t\t\t(s4-=(s64)y_2*y_2)%=D;\n\t\t\t(s6-=(s64)y_2*y_2%D*y_2)%=D;\n\t\t\t--my;\n\t\t}\n\t\t(a0+=my)%=D;\n\t\tint x_2=(s64)x*x%D;\n\t\t(a1+=(s64)x_2*my+s2)%=D;\n\t\t(a2+=(s64)x_2*x_2%D*my+2*x_2*s2+s4)%=D;\n\t\t(a3+=(s64)x_2*x_2%D*x_2%D*my+(s64)x_2*x_2%D*s2%D*3+x_2*s4%D*3+s6)%=D;\n\t}\n\tn%=D;\n\ta0=(4*a0+1)%D;a1=4*a1%D;a2=4*a2%D;a3=4*a3%D;\n\tF=(n*(n+1)%D*a0%D-a2+a1)%D*mi(2)%D;\n\tF2=( n*(n+1)%D*(2*n+1)%D*a0%D-2*a3+3*a2-a1)*mi(6)%D;\n}\n\nint main()\n{\n\t//freopen(\"1.in\",\"r\",stdin);\n\ts64 n;\n\tcin>>n>>D;\n\tsolve(n);\n\tcout<<(((n+1)%D*F-F2)%D+D)%D;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "213919b4c00e4f0ef3f850105ec45fdf", "src_uid": "b9a785849e5ffadb24b58b38b1f2ee48", "difficulty": 2900.0}
    {"lang": "GNU C++14", "source_code": "#include\n#include\nusing namespace std;\n#define mod int(1e9+7)\nconst int MXN = 1e6 + 10;\nlong long s[5][MXN],m,rt,tm;\nlong long l3() {\n    long long r = 0;\n    for (int i = -rt; i <= rt; i++) {\n        long long rty = sqrt(tm - 1LL * i*i);\n        long long ii = (1LL * i*i) % mod;\n        r = (r + ii * ii%mod * ii %mod *(2 * rty + 1) % mod) % mod;\n        r = (r + 3 * ii *ii%mod*(2 * s[1][rty]) % mod) % mod;\n        r = (r + 3 * ii*(2 * s[2][rty]) % mod) % mod;\n        r = (r + s[3][rty] * 2) % mod;\n    }\n    return r;\n}\nlong long l2() {\n    long long r = 0;\n    for (int i = -rt; i <= rt; i++) {\n        long long rty = sqrt(tm - 1LL * i*i);\n        long long ii = (1LL * i*i) % mod;\n        r = (r + ii * ii %mod *(2 * rty + 1) % mod) % mod;\n        r = (r + 2 * ii*(2 * s[1][rty]) % mod) % mod;\n        r = (r + 2 * s[2][rty]) % mod;\n    }\n    return r;\n}\nlong long l1() {\n    long long r = 0;\n    for (int i = -rt; i <= rt; i++) {\n        long long rty = sqrt(tm - 1LL * i*i);\n        long long ii = (1LL * i*i) % mod;\n        r = (r + ii*(2 * rty + 1) % mod) % mod;\n        r = (r + 2 * s[1][rty]) % mod;\n    }\n    return r;\n}\nlong long l0() {\n    long long r = 0;\n    for (int i = -rt; i <= rt; i++) {\n        long long rty = sqrt(tm - 1LL * i*i);\n        long long ii = (1LL * i*i) % mod;\n        r = (r + 2 * rty+1) % mod;\n    }\n    return r;\n}\nint main() {\n    for (int i = 1; i < MXN; i++) {\n        for (int j = 0; j < 5; j++) {\n            long long p = 1;\n            for (int k = 0; k < j; k++) p = (p*i) % mod * i %mod;\n            s[j][i] = (s[j][i - 1] + p) % mod;\n        }\n    }\n    scanf(\"%lld\", &m);\n    rt = sqrt(m);\n    long long res = 0;\n    tm = m;\n    m %= mod;\n    res = (2 * l3() + mod - (6 + 3*m)*l2() % mod + (4 + 3 * m)*l1() % mod + m*(m + 1) % mod*(m + 2) % mod*l0()%mod) % mod;\n    res = res * 166666668 % mod;\n    printf(\"%lld\", res);\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2f90f37e95d143895965f92295a1d6a0", "src_uid": "b9a785849e5ffadb24b58b38b1f2ee48", "difficulty": 2900.0}
    {"lang": "GNU C++11", "source_code": "\n#include\n#define IO ios::sync_with_stdio(false);\\\n    cin.tie(0);\\\n    cout.tie(0);\nusing namespace std;\ntypedef __int64 LL;\ntypedef long double Ldb;\nconst int maxn = 10;\nconst Ldb eps = 1e-12;\nint n;\nstruct Point\n{\n    Ldb x,y;\n    Point() {}\n    Point(Ldb _x,Ldb _y):x(_x),y(_y) {}\n    Point operator + (const Point &t)const\n    {\n        return Point(x+t.x,y+t.y);\n    }\n    Point operator - (const Point &t)const\n    {\n        return Point(x-t.x,y-t.y);\n    }\n    Point operator * (const Ldb &t)const\n    {\n        return Point(x*t,y*t);\n    }\n    Point operator / (const Ldb &t)const\n    {\n        return Point(x/t,y/t);\n    }\n    bool operator < (const Point &t)const\n    {\n        return fabs(x-t.x) < eps ? y operator & (const Circle &c1,const Circle &c2)\n    {\n        Ldb d=(c1.o-c2.o).len();\n        if(d>c1.r+c2.r+eps || d();\n        Ldb dt=(c1.r*c1.r-c2.r*c2.r)/d,d1=(d+dt)/2;\n        Point dir=(c2.o-c1.o)/d,pcrs=c1.o+dir*d1;\n        dt=sqrt(max(0.0L,c1.r*c1.r-d1*d1)),dir=dir.rot90();\n        return vector {pcrs+dir*dt,pcrs-dir*dt};\n    }\n} p[maxn];\nbool vis[maxn];\nint fa[maxn],rk[maxn];\nvoid init()\n{\n    for(int i=1; i\nusing namespace std;\n\n//ostream& debug = cerr;\n#include \nboost::iostreams::stream< boost::iostreams::null_sink > nullOstream( ( boost::iostreams::null_sink() ) );\nostream& debug = nullOstream;\n\ntemplate \nT intCeilDiv(T numerator, T denominator) {\n    if (numerator == 0) return 0;\n    if (((numerator > 0) - (numerator < 0)) * ((denominator > 0) - (denominator < 0)) < 0) {\n        return numerator / denominator;\n    }\n    return ((numerator - 1) / denominator) + 1;\n}\ntemplate \nT intFloorDiv(T numerator, T denominator) {\n    if (numerator == 0) return 0;\n    if (((numerator > 0) - (numerator < 0)) * ((denominator > 0) - (denominator < 0)) < 0) {\n        return ((numerator - 1) / denominator) - 1;\n    }\n    return numerator / denominator;\n}\n\nint pow(int base, int exp, int mod) {\n    long long result = 1, baseLL = base;\n    while (exp) {\n        if (exp & 1) {\n            result *= baseLL;\n            result %= mod;\n        }\n        baseLL *= baseLL;\n        baseLL %= mod;\n        exp >>= 1;\n    }\n    return (result + mod) % mod;\n}\n\nint main() {\n    debug << \"test: \" << intCeilDiv(-6, 5) << endl;\n    debug << \"test: \" << -1 % 5 << endl;\n    long long a, b, p, x;\n    cin >> a >> b >> p >> x;\n    debug << \"a = \" << a << endl;\n    debug << \"b = \" << b << endl;\n    debug << \"p = \" << p << endl;\n    debug << \"x = \" << x << endl;\n    long long total = 0;\n    for (long long j = 1; j <= p - 1; j++) {\n        debug << \"-----\\nj = \" << j << endl;\n        long long y = (b * pow(a, (p-1) - j, p)) % p;\n        debug << \"1/a^j = \" << pow(a, (p-1) - j, p) << endl;\n        debug << \"a * inv a = \" << (a * pow(a, (p-2), p)) % p << endl;\n        debug << \"y = \" << y << endl;\n        long long tMin = intCeilDiv (1-j + (y-j)*(p-1), (p-1)*p);\n        long long tMax = intFloorDiv(x-j + (y-j)*(p-1), (p-1)*p);\n        debug << tMin << \" <= t <= \" << tMax << endl;\n        debug << \"tMin = \" << 1-j + (y-j)*(p-1) << \" / \" << (p-1)*p << endl;\n        debug << \"tMax = \" << x-j + (y-j)*(p-1) << \" / \" << (p-1)*p << endl;\n        total += max(0LL, tMax - tMin + 1);\n        //return 0;\n    }\n    debug << \"=====\" << endl;\n    cout << total << endl;\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "edc7a3aa7b9a6e2bc1d509ebbfcfbc31", "src_uid": "4b9f470e5889da29affae6376f6c9f6a", "difficulty": 2100.0}
    {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\ntypedef long long LL;\ntypedef unsigned long long ULL;\nint Gcd(int a,int b){if (b == 0) return a; return Gcd(b , a%b);}\nint Lcm(int a, int b){ return a/Gcd(a,b)*b;}\ninline long long read(){\n   long long f = 1, x = 0;char ch = getchar();\n    while (ch > '9' || ch < '0'){if (ch == '-')f = -f;ch = getchar();}\n    while (ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}\n    return x * f;\n}\nconst int maxn = 1e6 + 10;\n// n * a^n * x + p * y = b;\nLL exgcd(LL a,LL b,LL &x,LL &y){\n    if (!b){\n        x = 1; y = 0;\n        return a;\n    }else{\n        int g = exgcd(b,a % b,x,y),tmp = x;\n        x = y;\n        y = tmp - (a / b) * y;\n        return g;\n    }\n}\nLL qpow(LL a,LL b,LL mod){\n    LL base = a,ans = 1;\n    while(b){\n        if (b & 1) ans = ans * base % mod;\n        base = base * base % mod;\n        b >>= 1;\n    }\n    return ans % mod;\n}\nLL m[maxn],a[maxn];\nLL lcm = 1;\nLL solve(){\n    LL ans = 0,x,y,g;\n    for(int i=1; i<=2; i++){\n        LL tmp = lcm / m[i];\n        exgcd(tmp,m[i],x,y);\n        x = (x % m[i] + m[i]) % m[i];\n        ans = (ans + a[i] * x * tmp) % lcm;\n    }\n    return ans;\n}\n// n * a^(n % (p-1)) % p = b ;\n\n// n % p == inv(a^(n % (p-1))) * b % p;\n\n// n % (p-1) == i;\n\n// a^(n % (p-1)) % p == c2;\n\n// n % (p-1) == c2';\nLL inv(LL a,LL p){\n    return qpow(a,p-2,p);\n}\nint main(){\n    LL A = read(),B = read(),p = read(),x = read();\n    m[1] = p-1; m[2] = p;\n    lcm = (p - 1) * p;\n    LL ans = 0;\n    for(int i=0; i<=p-1; i++){\n        a[1] = i;\n        a[2] = B * inv(qpow(A,i % (p-1),p),p) % p;\n        // cout << a[2] << endl;\n        LL res = solve();\n        if (x >= res){\n            ans = ans + (x - res) / (p * (p-1)) + 1;\n        }\n    }   \n    if (A != B && ans > 0) ans--;\n    cout << ans << endl;\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "960edf937dcdc95ae3a6229fa0214b50", "src_uid": "4b9f470e5889da29affae6376f6c9f6a", "difficulty": 2100.0}
    {"lang": "GNU C++11", "source_code": "#pragma GCC optimize(2)\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define ST sort \n#define MAXN 100005\n#define DB double\n#define LL long long\n#define INF 0x3f3f3f3f3f3f3f3f\n#define Int register int\n#define XM XiangMeiHaoGuai\n#define Pa pair\n#define Lson Son[x][0]\n#define Rson Son[x][1] \nusing namespace std;\ninline void read(LL &x)\n{\n\tx = 0;\n\tLL f = 1;\n\tchar s = getchar();\n\twhile (s < '0' ||s > '9')\n\t{\n\t\tif (s == '-')\n\t\t\tf = -1;\n\t\ts = getchar();\n\t}\n\twhile (s >= '0' && s <= '9')\n\t{\n\t\tx = (x << 3) + (x << 1) + (s ^ 48);\n\t\ts = getchar();\n\t}\n\tx *= f;\n}\ninline LL Max(LL x,LL y)\n{\n\treturn x > y ? x : y;\n}\ninline LL Min(LL x,LL y)\n{\n\treturn x < y ? x : y;\n}\nLL Gcd(LL a,LL b)\n{\n\tif (! b)\n\t\treturn a;\n\treturn Gcd(b, a % b);\n}\ninline LL Abs(LL x)\n{\n\tif (x < 0)\n\t\treturn -x;\n\treturn x;\n}\ninline DB Fabs(DB x)\n{\n\tif (x > 0)\n\t\treturn x;\n\treturn -x;\n}\nLL a, b, p, x;\ninline LL QuickPow(LL x,LL y,LL Mod)\n{\n\tx %= Mod;\n\tLL Res = 1, temp = x;\n\twhile ( y )\n\t{\n\t\tif (y & 1)\n\t\t\tRes = Res * temp % Mod;\n\t\ttemp = temp * temp % Mod;\n\t\ty /= 2;\n\t}\n\treturn Res;\n}\ninline LL Inv(LL x)\n{\n\treturn QuickPow(x, p - 2, p); \n}\ninline LL Mo(LL x,LL Mod)\n{\n\treturn (x % Mod + Mod) % Mod;\n}\ninline Jie(LL n,LL Mi)\n{\n\tLL Get = b * Inv( Mi ) % p;\n\tLL Dai = (p - 1) * Mo(n - Get, p) + n;\n\tif (Dai > x)\n\t\treturn 0;\n\treturn (x - Dai) / (p * (p - 1)) + 1;\n}\nint main()\n{\n\tread( a ); read( b ); read( p ); read( x );\n\tLL Power = 1, Ans = 0;\n\tfor (Int i = 1; i < p; ++ i)\n\t{\n\t\tPower = Power * a % p;\n\t\tLL Da = Jie(i, Power);\n\t\tAns += Da;\n\t}\n\tprintf(\"%lld\", Ans);\n\treturn 0;\n}\n/*\nn * a ^ n \u2261b (mod p)\n\n*/p>\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define ST sort \n#define MAXN 100005\n#define DB double\n#define LL long long\n#define INF 0x3f3f3f3f3f3f3f3f\n#define Int register int\n#define XM XiangMeiHaoGuai\n#define Pa pair\n#define Lson Son[x][0]\n#define Rson Son[x][1] \nusing namespace std;\ninline void read(LL &x)\n{\n\tx = 0;\n\tLL f = 1;\n\tchar s = getchar();\n\twhile (s < '0' ||s > '9')\n\t{\n\t\tif (s == '-')\n\t\t\tf = -1;\n\t\ts = getchar();\n\t}\n\twhile (s >= '0' && s <= '9')\n\t{\n\t\tx = (x << 3) + (x << 1) + (s ^ 48);\n\t\ts = getchar();\n\t}\n\tx *= f;\n}\ninline LL Max(LL x,LL y)\n{\n\treturn x > y ? x : y;\n}\ninline LL Min(LL x,LL y)\n{\n\treturn x < y ? x : y;\n}\nLL Gcd(LL a,LL b)\n{\n\tif (! b)\n\t\treturn a;\n\treturn Gcd(b, a % b);\n}\ninline LL Abs(LL x)\n{\n\tif (x < 0)\n\t\treturn -x;\n\treturn x;\n}\ninline DB Fabs(DB x)\n{\n\tif (x > 0)\n\t\treturn x;\n\treturn -x;\n}\nLL a, b, p, x;\ninline LL QuickPow(LL x,LL y,LL Mod)\n{\n\tx %= Mod;\n\tLL Res = 1, temp = x;\n\twhile ( y )\n\t{\n\t\tif (y & 1)\n\t\t\tRes = Res * temp % Mod;\n\t\ttemp = temp * temp % Mod;\n\t\ty /= 2;\n\t}\n\treturn Res;\n}\ninline LL Inv(LL x)\n{\n\treturn QuickPow(x, p - 2, p); \n}\ninline LL Mo(LL x,LL Mod)\n{\n\treturn ((x % Mod) + Mod) % Mod;\n}\ninline Jie(LL n,LL Mi)\n{\n\tLL Get = b * Inv( Mi ) % p;\n\tLL Dai = (p - 1) * Mo(n - Get, p) + n;\n\tif (Dai > x)\n\t\treturn 0;\n\treturn (x - Dai) / (p * (p - 1)) + 1;\n}\nint main()\n{\n\tread( a ); read( b ); read( p ); read( x );\n\tLL Power = 1, Ans = 0;\n\tfor (Int i = 1; i < p; ++ i)\n\t{\n\t\tPower = Power * a % p;\n\t\tLL Da = Jie(i, Power);\n\t\tAns += Da;\n\t}\n\tprintf(\"%lld\", Ans);\n\treturn 0;\n}\n/*\nn * a ^ n \u2261b (mod p)\n\n*/\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define ST sort \n#define MAXN 100005\n#define DB double\n#define LL long long\n#define INF 0x3f3f3f3f3f3f3f3f\n#define Int register int\n#define XM XiangMeiHaoGuai\n#define Pa pair\n#define Lson Son[x][0]\n#define Rson Son[x][1] \nusing namespace std;\ninline void read(LL &x)\n{\n\tx = 0;\n\tLL f = 1;\n\tchar s = getchar();\n\twhile (s < '0' ||s > '9')\n\t{\n\t\tif (s == '-')\n\t\t\tf = -1;\n\t\ts = getchar();\n\t}\n\twhile (s >= '0' && s <= '9')\n\t{\n\t\tx = (x << 3) + (x << 1) + (s ^ 48);\n\t\ts = getchar();\n\t}\n\tx *= f;\n}\ninline LL Max(LL x,LL y)\n{\n\treturn x > y ? x : y;\n}\ninline LL Min(LL x,LL y)\n{\n\treturn x < y ? x : y;\n}\nLL Gcd(LL a,LL b)\n{\n\tif (! b)\n\t\treturn a;\n\treturn Gcd(b, a % b);\n}\ninline LL Abs(LL x)\n{\n\tif (x < 0)\n\t\treturn -x;\n\treturn x;\n}\ninline DB Fabs(DB x)\n{\n\tif (x > 0)\n\t\treturn x;\n\treturn -x;\n}\nLL a, b, p, x;\ninline LL QuickPow(LL x,LL y,LL Mod)\n{\n\tLL Res = 1, temp = x;\n\twhile ( y )\n\t{\n\t\tif (y & 1)\n\t\t\tRes = Res * temp % Mod;\n\t\ttemp = temp * temp % Mod;\n\t\ty /= 2;\n\t}\n\treturn Res;\n}\ninline LL Inv(LL x)\n{\n\treturn QuickPow(x, p - 2, p); \n}\ninline LL Mo(LL x,LL Mod)\n{\n\treturn ((x % Mod) + Mod) % Mod;\n}\ninline Jie(LL n,LL Mi)\n{\n\tLL Get = b * Inv( Mi ) % p;\n\tLL Dai = (p - 1) * Mo(n - Get, p) + n;\n\tif (Dai > x)\n\t\treturn 0;\n\treturn (x - Dai) / (p * (p - 1)) + 1;\n}\nint main()\n{\n\tread( a ); read( b ); read( p ); read( x );\n\tLL Power = 1, Ans = 0;\n\tfor (Int i = 1; i < p; ++ i)\n\t{\n\t\tPower = Power * a % p;\n\t\tLL Da = Jie(i, Power);\n\t\tAns += Da;\n\t}\n\tprintf(\"%lld\", Ans);\n\treturn 0;\n}\n/*\nn * a ^ n \u2261b (mod p)\n\n*/", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bcfedf43cc851d79285b1471004f13c3", "src_uid": "4b9f470e5889da29affae6376f6c9f6a", "difficulty": 2100.0}
    {"lang": "GNU C++17", "source_code": "#include \n#include \n\nusing namespace std;\n\n#define ll long long\n\nint mult(int a, int b, int mod)\n{\n    return ((ll) a * b) % mod;\n}\n\nint binaryPower(int n, int p, int mod)\n{\n    int acc = 1;\n    while (p)\n    {\n        if (p & 1) acc = mult(acc, n, mod);\n        n = mult(n, n, mod);\n        p >>= 1;\n    }\n    return acc;\n}\n\nstruct bezout_coefficients\n{\n    ll g, x, y; // x * a + y * b = gcd(a, b)\n};\n\nbezout_coefficients extended_gcd(ll a, ll b)\n{\n    array  A = {0, 1, a}, B = {1, 0, b};\n    while (B[2] != 0)\n    {\n        ll q = A[2] / B[2];\n        auto T = B;\n        transform(A.begin(), A.end(), B.begin(), B.begin(), [q](ll x, ll y){return x - q * y;});\n        A = T;\n    }\n    return {A[2], A[1], A[0]};\n}\n\nll modularInverse(ll a, ll b)\n{\n    return extended_gcd(a, b).x;\n}\n}\n\nint main()\n{\n    int a, b, p;\n    ll x;\n    cin>>a>>b>>p>>x;\n    ll sol = 0;\n    for (int rem = 0; rem < p - 1; rem++)\n    {\n        int z = (mult(b, modularInverse(binaryPower(a, rem, p), p), p));\n\n        ll lb = ceil((double(1 - rem) / (p - 1) - (rem - z)) / p);\n        ll ub = floor((double(x - rem) / (p - 1) - (rem - z)) / p);\n\n        sol += ub >= lb ? ub - lb + 1 : 0;\n    }\n    cout<\nusing namespace std;\n\nint exgcd(int a, int b, int &x, int &y) {\n\tif(b) {\n\t\tint g = exgcd(b, a % b, x, y);\n\t\tint tmp = x;\n\t\tx = y, y = tmp - a / b * y;\n\t\treturn g;\n\t} else {\n\t\tx = 1, y = 0;\n\t\treturn a;\n\t}\n}\nint main() {\n\tios::sync_with_stdio(false);\n\tcin.tie(NULL);\n\t\n\tint n, m, x, y, vx, vy;\n\tcin >> n >> m >> x >> y >> vx >> vy;\n\n\tint da = 0, db = 0;\n\tif(vx)\n\t\tda = vx > 0 ? n - x : x;\n\telse {\n\t\tif(vy && (x == 0 || x == n))\n\t\t\tcout << x << ' ' << (vy > 0 ? m : 0);\n\t\telse\n\t\t\tcout << \"-1\" << endl;\n\t\treturn 0;\n\t}\n\tif(vy)\n\t\tdb = vy > 0 ? m - y : y;\n\telse {\n\t\tif(vx && (y == 0 || y == m))\n\t\t\tcout << (vx > 0 ? n : 0) << ' ' << y;\n\t\telse\n\t\t\tcout << \"-1\" << endl;\n\t\treturn 0;\n\t}\n\tlong long t = db - da, dx, dy;\n\tint gcd = exgcd(n, -m, dx, dy);\n\tif(t % gcd) {\n\t\tcout << \"-1\" << endl;\n\t\treturn 0;\n\t}\n\tdx = dx * t / gcd, dy = dy * t / gcd;;\n\tif(dx < 0) {\n\t\tint xdel = m / gcd, ydel = n / gcd;\n\t\tint f = (-dx - 1) / xdel + 1;\n\t\tdx += f * xdel, dy += f * ydel; \n\t}\n\tcout << ((dx & 1) ^ (vx > 0) ? n : 0) << ' ' << ((dy & 1) ^ (vy > 0) ? m : 0) << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "44cdc7bc73373f208498bec38ef0ca56", "src_uid": "6c4ddc688c5aab1432e7328d27c4d8ee", "difficulty": 2600.0}
    {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n#define int long long\nnamespace Fread {\n\tconst int MAXN=1<<20;\n\tchar buf[MAXN],*S,*T;\n\tinline char getchar() {\n\t\tif (S==T) {\n\t\t\tT=(S=buf)+fread(buf,1,MAXN,stdin);\n\t\t\tif (S==T) return EOF;\n\t\t}\n\t\treturn *S++;\n\t}\n}\ninline int read() {\n\tint x(0),neg(1);\n\tchar ch=getchar();\n\twhile(!isdigit(ch)) {\n\t\tif (ch=='-') neg=-1;\n\t\tch=getchar();\n\t}\n\twhile(isdigit(ch)) {\n\t\tx=(x<<1)+(x<<3)+(ch-'0');\n\t\tch=getchar();\n\t}\n\treturn x*neg;\n}\n#ifdef ONLINE_JUDGE\n\t#define getchar Fread::getchar\n#endif\nint n,m,ox,oy,vx,vy;\ninline int exgcd(int a,int b,int &x,int &y) {\n\tif (!b) {\n\t\tx=1,y=0;\n\t\treturn a;\n\t}\n\tint res(exgcd(b,a%b,y,x));\n\ty-=(a/b)*x;\n\treturn res;\n} \nsigned main() {\n//\tfreopen(\".in\",\"r\",stdin);\n//\tfreopen(\".out\",\"w\",stdout);\n\tn=read(),m=read(),ox=read(),oy=read(),vx=read(),vy=read();\n\t/*\u7279\u5224*/\n\tif (x%n==0 && y%m==0) {\n\t\tprintf(\"%lld %lld\\n\",x,y);\n\t\treturn 0;\n\t} \n\t\n\t/*\u5224\u65ad\u5e73\u884c*/ \n\tif (vx==0) {\n\t\tif (ox==0 || ox==n) {\n\t\t\tif (vy==1) printf(\"%lld %lld\\n\",ox,m);\n\t\t\telse printf(\"%lld %lld\\n\",ox,0);\n\t\t}\n\t\telse puts(\"-1\");\n\t\treturn 0;\n\t}\n\tif (vy==0) {\n\t\tif (oy==0 || oy==m) {\n\t\t\tif (vx==1) printf(\"%lld %lld\\n\",n,oy);\n\t\t\telse printf(\"%lld %lld\\n\",0,oy);\n\t\t}\n\t\telse puts(\"-1\");\n\t\treturn 0;\n\t}\n\t\n\t/*\u975e\u5e73\u884c*/\n\tint flag1=0,flag2=0;\n\tif (vx==-1) flag1=1,ox=n-ox;\n\tif (vy==-1) flag2=1,oy=m-oy;\n\t/*an+(y-x)=bm*/\n\t/*an+bm=x-y*/\n\tint a(0),b(0),gcd(exgcd(n,m,a,b));\n\tint Mn=n/gcd,Mm=m/gcd;\n\tif ((ox-oy)%gcd!=0) {\n\t\tputs(\"-1\");\n\t\treturn 0;\n\t}\n\tint t=(ox-oy)%gcd;\n\ta=a*t,b=b*t;\n\tint aa=(a%Mm+Mm*2-1)%Mm+1,bb=-((ox-oy)-aa*n)/m;\n\tint ansx,ansy;\n\tif (!(aa%2)) ansx=0;\n\telse ansx=n;\n\tif (!(bb%2)) ansy=0;\n\telse ansy=m;\n\tif (flag1) {\n\t\tansx=n-ansx;\n\t}\n\tif (flag2) {\n\t\tansy=m-ansy;\n\t}\n\tprintf(\"%lld %lld\\n\",ansx,ansy);\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "94b9323359d5a9ce688f3fb41b761bf3", "src_uid": "6c4ddc688c5aab1432e7328d27c4d8ee", "difficulty": 2600.0}
    {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\nint gcd(int a, int b) {\n\twhile (b) {\n\t\tint c = a % b;\n\t\ta = b;\n\t\tb = c;\n\t}\n\treturn a;\n}\n\nint gcd_ext(int a, int b, long long& x, long long& y) {\n\tif (!b) {\n\t\tx = 1, y = 0;\n\t\treturn a;\n\t}\n\tint g = gcd_ext(b, a % b, x, y);\n\ttie(x, y) = make_pair(y, x - (a/b) * y);\n\treturn g;\n}\nint inv(int a, int m) {\n\tlong long x, y;\n\tint g = gcd_ext(a, m, x, y);\n\tassert(g == 1);\n\tif (x < 0) {\n\t\tx = m - ((-x) % m);\n\t}\n\telse {\n\t\tx %= m;\n\t}\n\treturn x;\n}\n \nint get(int a, int d, int m)\n{\n\tint g = gcd(d, m);\n\tif (a % g != 0) return -1;\n\t\n\ta /= g;\n\td /= g;\n\tm /= g;\n\n\tint k = mod_mult((m - a) % m, inv(d, m), m);\n\treturn k;\n} \n \nint main()\n{\n\tint n, m, x, y, vx, vy;\n\tignore = scanf(\"%d %d %d %d %d %d\", &n, &m, &x, &y, &vx, &vy);\n\t\n\tif (vx == 0) {\n\t\tif (x != 0 && x != n) printf(\"-1\\n\");\n\t\telse if (vy > 0) printf(\"%d %d\\n\", x, m);\n\t\telse printf(\"%d %d\\n\", x, 0);\n\t\treturn 0;\n\t}\n\tif (vy == 0) {\n\t\tif (y != 0 && y != m) printf(\"-1\\n\");\n\t\telse if (vx > 0) printf(\"%d %d\\n\", n, y);\n\t\telse printf(\"%d %d\\n\", 0, y);\n\t\treturn 0;\n\t}\n\t\n\tint a = y % m;\n\tif (vy < 0) a = (m - y) % m;\n \n\tif (x != 0 && x != n) {\n\t\tif (vx < 0) a = (a + x) % m;\n\t\telse a = (a + n - x) % m;\n\t}\n\t\n\tint d = n % m;\n\t\n\tint k = get(a, d, m);\n\tif (k == -1) {\n\t\tprintf(\"-1\\n\");\n\t\treturn 0;\n\t}\n\t\n\tlong long t = (vx < 0 ? x % n : (n - x) % n) + k * 1LL * n;\n\t\n\tlong long xx = x + t * vx;\n\tlong long yy = y + t * vy;\n\t\n\txx = abs(xx);\n\tyy = abs(yy);\n\txx %= 2*n;\n\tyy %= 2*m;\n\tprintf(\"%d %d\\n\", (int)xx, (int)yy);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e359ba588cc3b6abb6c8ea64a2e06ba4", "src_uid": "6c4ddc688c5aab1432e7328d27c4d8ee", "difficulty": 2600.0}
    {"lang": "GNU C++14", "source_code": "#include \n#define MOD 1000000007\nusing namespace std;\n\ntypedef long long int ll;\ntypedef pair pii;\ntypedef pair plii;\ntypedef pair piii;\nconst int INF = 1e9+10;\nconst ll LINF = 1LL*INF*INF;\nconst int MAXN = 1e5+10;\nconst int MAXM = 3e3+10;\n\npriority_queue pq;\n\nint A[MAXN];\n\nplii inverse(int a,int b)\n{\n    if(a==1)return plii(1,0);\n    if(b==1)return plii(1,a-1);\n    if(b<=100){\n        for(ll i=0;ib){\n        plii cur = inverse(a%b,b);\n        cur.second += (a/b)*cur.first;\n        return cur;\n    }\n    else {\n        plii cur = inverse(a,b%a);\n        cur.first+=(b/a)*cur.second;\n        return cur;\n    }\n}\n\nint main()\n{\n    int n,m,k,a,b,x,y;\n    int sum = 0;\n    int cnt = 0;\n\n    scanf(\"%d%d%d%d%d%d\",&n,&m,&x,&y,&a,&b);\n\n    int ox = n,ex = 0,oy = m,ey = 0;\n\n    if(a==-1)x = n-x,swap(ox,ex);\n    if(b==-1)y = m-y,swap(oy,ey);\n\n\n    int gcd = __gcd(n,m);\n\n    if((y-x)%gcd){printf(\"-1\") return 0;};\n\n    int cur = (y-x);\n\n    cur/=gcd;\n    n/=gcd;\n    m/=gcd;\n\n    if(cur<0)cur = -cur, swap(n,m);\n\n    plii ans = inverse(n,m);\n\n    ans.first*=cur;\n    ans.second*=cur;\n\n    ans.first%=m;\n    ans.second%=n;\n\n    if(!ans.first)ans.first = m;\n    if(!ans.second)ans.second = n;\n\n    if(ans.first%2)printf(\"%d \",ox);\n    else printf(\"%d \",ex);\n    if(ans.second%2)printf(\"%d \",oy);\n    else printf(\"%d \",ey);\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e358b3e0a935859377830bdc65885ae3", "src_uid": "6c4ddc688c5aab1432e7328d27c4d8ee", "difficulty": 2600.0}
    {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\ntypedef long long LL;\nconst int maxn=201,maxm=51;\nconst LL INF=0x3f3f3f3f3f3f3f3fLL;\nint n,m,qtot,etot;\nstruct Point\n{\n\tint x,y;\n\tvoid read()\n\t{\n\t\tscanf(\"%d%d\",&x,&y);\n\t}\n\tbool operator<(Point const&t)const\n\t{\n\t\treturn x0);\n}\nstruct Edge\n{\n\tint u,v;\n\tPoint vec;\n\tbool operator<(Edge const&t)const\n\t{\n\t\treturn cmp(vec,t.vec);\n\t}\n}e[maxn*(maxn>>1)];\nLL f[maxn][maxm],ans;\nint main(void)\n{\n\tscanf(\"%d%d\",&n,&m);\n\tfor(int i=0;i>1,\"05\"[ans&1]);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4d941edf7fa1d70b8eba8a8cde210fa4", "src_uid": "6afcdad100c8e2469fef5abcc5bd96c6", "difficulty": 3000.0}
    {"lang": "GNU C++11", "source_code": "#include \"bits/stdc++.h\"\nusing namespace std;\nstruct point{\n\tlong long x , y;\n\tpoint(long long _x = 0 , long long _y = 0){\n\t\tx = _x;\n\t\ty = _y;\n\t}\n\tpoint operator + (const point &other) const {\n\t\treturn point(x + other.x , y + other.y);\n\t}\n\tpoint operator - (const point &other) const {\n\t\treturn point(x - other.x , y - other.y);\n\t}\n\tbool operator < (const point &other) const {\n\t\tif(y == other.y){\n\t\t\treturn x < other.x;\n\t\t}\n\t\treturn y < other.y;\n\t}\n\tvoid read(){\n\t\tscanf(\"%lld %lld\" , &x , &y);\n\t}\n};\nlong long dot(point a , point b){\n\treturn a.x * b.x + a.y * b.y;\n}\ninline long long cross(point a , point b){\n\treturn a.x * b.y - a.y * b.x;\n}\ninline int orient(point a , point b , point c){//orientation of point c with respect to line from a -> b\n\tlong long val = cross(b - a , c - a);\n\tif(val > 0){\n\t\treturn 1;//c comes anticlockwise on line from a -> b\n\t}\n\tif(val < 0){\n\t\treturn -1;//c comes clockwise on line from a -> b\n\t}\n\treturn 0;//c is collinear with line from a -> b\n}\nlong long dist(point a , point b){\n\treturn dot(a - b , a - b);\n}\nconst int N = 205;\nconst int K = 55;\nint n , k;\npoint arr[N];\npoint bottom;\nint tot[N][N];\ninline long long area(int a , int b , int c){\n\treturn abs(cross(arr[b] - arr[a] , arr[c] - arr[a]));\n}\nbool inside(point p1 , point p2 , point p3 , point q){\n\tint o1 = orient(p1 , p2 , q);\n\tint o2 = orient(p2 , p3 , q);\n\tint o3 = orient(p3 , p1 , q);\n\treturn (o1 == o2) && (o2 == o3) && (o3 != 0);\n}\ninline int get(int a , int b , int c){\n\tint res = 0;\n\tres += (tot[a][b] - inside(bottom , arr[a] , arr[b] , arr[c])) * orient(bottom , arr[a] , arr[b]);\n\tres += (tot[b][c] - inside(bottom , arr[b] , arr[c] , arr[a])) * orient(bottom , arr[b] , arr[c]);\n\tres += (tot[c][a] - inside(bottom , arr[c] , arr[a] , arr[b])) * orient(bottom , arr[c] , arr[a]);\n\treturn res;\n}\nlong long dp[2][N][N];\nvector < int > v;\nint pivot;\nbool cmp(int a , int b){\n\treturn orient(arr[pivot] , arr[a] , arr[b]) == -1;\n}\nbool cmp2(int a , int b){\n\treturn orient(arr[v[pivot]] , arr[v[a]] , arr[v[b]]) == -1;\n}\nint nxt[N][N];\nint prv[N][N];\nlong long solve(int idx){\n\tv.clear();\n\tv.emplace_back(idx);\n\tfor(int i = 1 ; i <= n ; ++i){\n\t\tif(arr[i].y > arr[idx].y || (arr[i].y == arr[idx].y && arr[i].x > arr[idx].x)){\n\t\t\tv.emplace_back(i);\n\t\t}\n\t}\n\tif(v.size() < k){\n\t\treturn;\n\t}\n\tpivot = v[0];\n\tsort(v.begin() + 1 , v.end() , cmp);\n\tint m = v.size();\n\tfor(int i = 1 ; i < m ; ++i){\n\t\tnxt[i][0] = 0;\n\t\tfor(int j = i + 1 ; j < m ; ++j){\n\t\t\tif(!get(v[0] , v[i] , v[j])){\n\t\t\t\tnxt[i][++nxt[i][0]] = j;\n\t\t\t}\n\t\t}\n\t\tprv[i][0] = 0;\n\t\tfor(int j = 0 ; j < i ; ++j){\n\t\t\tprv[i][++prv[i][0]] = j;\n\t\t}\n\t\tpivot = i;\n\t\tsort(nxt[i] + 1 , nxt[i] + 1 + nxt[i][0] , cmp2);\n\t\tsort(prv[i] + 1 , prv[i] + 1 + prv[i][0] , cmp2);\n\t}\n\tfor(int siz = k ; siz > 1 ; --siz){\n\t\tfor(int last2 = 1 ; last2 < m ; ++last2){\n\t\t\tint ptr = nxt[last2][0];\n\t\t\tlong long bst = -1LL << 50;\n\t\t\tfor(int j = prv[last2][0] ; j >= 1 ; --j){\n\t\t\t\tint last1 = prv[last2][j];\n\t\t\t\tif(last1 && orient(arr[v[last1]] , arr[v[last2]] , arr[v[0]]) != -1){\n\t\t\t\t\tdp[siz & 1][last1][last2] = -1LL << 50;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif(siz == k){\n\t\t\t\t\tdp[siz & 1][last1][last2] = 0;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tptr = nxt[last2][0];\n\t\t\t\tbst = -1LL << 50;\n\t\t\t\twhile(ptr >= 1 && orient(arr[v[last1]] , arr[v[last2]] , arr[v[nxt[last2][ptr]]]) == -1){\n\t\t\t\t\tbst = max(bst , dp[!(siz & 1)][last2][nxt[last2][ptr]] + area(v[0] , v[last2] , v[nxt[last2][ptr]]));\n\t\t\t\t\t--ptr;\n\t\t\t\t}\n\t\t\t\tdp[siz & 1][last1][last2] = bst;\n\t\t\t}\n\t\t}\n\t}\n\tlong long res = 0;\n\tfor(int i = 1 ; i < m ; ++i){\n\t\tres = max(res , dp[0][0][i]);\n\t}\n\treturn res;\n}\nint main(){\n\tscanf(\"%d %d\" , &n , &k);\n\tfor(int i = 1 ; i <= n ; ++i){\n\t\tarr[i].read();\n\t}\n\tbottom = point(-1 , -1);\n\tfor(int i = 1 ; i <= n ; ++i){\n\t\ttot[i][i] = 0;\n\t\tfor(int j = i + 1 ; j <= n ; ++j){\n\t\t\tint res = 0;\n\t\t\tfor(int k = 1 ; k <= n ; ++k){\n\t\t\t\tif(i == k || j == k){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tres += inside(bottom , arr[i] , arr[j] , arr[k]);\n\t\t\t}\n\t\t\ttot[i][j] = tot[j][i] = res;\n\t\t}\n\t}\n\tlong long ans = 0;\n\tfor(int i = 1 ; i <= n ; ++i){\n\t\tans = max(ans , solve(i));\n\t}\n\tprintf(\"%.2lf\\n\" , ans / 2.0);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0286586bdafbf873af1aa30be3861bd9", "src_uid": "6afcdad100c8e2469fef5abcc5bd96c6", "difficulty": 3000.0}
    {"lang": "GNU C++14", "source_code": "\n/*\n   \u041e \u041d\u0415\u0422! \u041e\u041d\u0418 \u0414\u041e\u0413\u041e\u041d\u042f\u042e\u0422!!!\n   \ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\n   \ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\n   \ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\n   \ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\n   \ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\n   \ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\n   \ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\n   \ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\n   \ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\n   \ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\n   \ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\ud83d\udc39\n*/\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\n\nmt19937 rnd(228);\n\nstruct pt\n{\n    int x, y;\n};\n\npt operator - (const pt &a, const pt &b)\n{\n    return {a.x - b.x, a.y - b.y};\n}\n\npt operator + (const pt &a, const pt &b)\n{\n    return {a.x + b.x, a.y + b.y};\n}\n\nll operator * (const pt &a, const pt &b)\n{\n    return a.x * (ll) b.y - a.y * (ll) b.x;\n}\n\nll len(const pt &p)\n{\n    return p.x * (ll) p.x + p.y * (ll) p.y;\n}\n\npt s;\n\nconst int N = 200 + 7;\n\nbool ok[N][N];\nll dp[N][N];\nvector  g[N];\nvector  f;\npt mn;\n\nbool operator < (const pt &a, const pt &b)\n{\n    if ((a - s) * (b - s) != 0)\n    {\n        return (a - s) * (b - s) < 0;\n    }\n    else\n    {\n        return len(a - s) < len(b - s);\n    }\n}\n\nint main()\n{\n#ifdef ONPC\n    freopen(\"a.in\", \"r\", stdin);\n#endif\n    int n, cnt;\n    cin >> n >> cnt;\n    vector  e;\n    for (int i = 0; i < n; i++)\n    {\n        int x, y;\n        cin >> x >> y;\n        e.push_back({x, y});\n    }\n    ll ans = 0;\n    for (int i = 0; i < n; i++)\n    {\n        f.clear();\n        for (int j = 0; j < n; j++)\n        {\n            if (e[j].x > e[i].x || (e[j].x == e[i].x && e[j].y > e[i].y))\n            {\n                f.push_back(e[j]);\n            }\n        }\n        s = e[i];\n        sort(f.begin(), f.end());\n        int k = f.size();\n        for (int i = 0; i < k; i++)\n        {\n            for (int j = i + 1; j < k; j++)\n            {\n                ok[i][j] = false;\n            }\n        }\n        for (int i = 0; i < k; i++)\n        {\n            for (int j = i + 1; j < k; j++)\n            {\n                for (int t = i + 1; t < j; t++)\n                {\n                    if ((f[t] - f[i]) * (f[j] - f[t]) >= 0)\n                    {\n                        ok[i][j] = true;\n                        break;\n                    }\n                }\n                /*\n                if (!ok[i][j])\n                {\n                    cout << f[i].x << ' ' << f[i].y << \" -> \" << f[j].x << ' ' << f[j].y << ' ' << s.x << ' ' << s.y << endl;\n                }\n                */\n            }\n        }\n        vector  > e;\n        for (int i = 0; i < k; i++)\n        {\n            for (int j = i + 1; j < k; j++)\n            {\n                if (i != j && !ok[i][j])\n                {\n                    e.push_back({i, j});\n                }\n            }\n        }\n        pt cur = {-1, 10000000000};\n        mn = s + cur;\n        sort(e.begin(), e.end(), [] (pair  a, pair  b)\n        {\n            pt x = f[a.second] - f[a.first];\n            pt y = f[b.second] - f[b.first];\n            if (x * mn < 0 && y * mn < 0)\n            {\n                return x * y < 0;\n            }\n            else if (x * mn > 0 && y * mn > 0)\n            {\n                return x * y < 0;\n            }\n            else\n            {\n                return x * mn > 0;\n            }\n        });\n        for (int i = 0; i < k; i++)\n        {\n            for (int j = 0; j < cnt - 1; j++)\n            {\n                dp[i][j] = 0;\n            }\n        }\n        for (auto c : e)\n        {\n            int i = c.first, go = c.second;\n            for (int j = 0; j < cnt - 1; j++)\n            {\n                dp[go][j + 1] = max(dp[go][j + 1], dp[i][j] + abs((f[i] - s) * (f[go] - s)));\n            }\n        }\n        for (int i = 0; i < k; i++)\n        {\n            for (int j = 0; j < cnt - 1; j++)\n            {\n                ans = max(ans, dp[i][j]);\n            }\n        }\n    }\n    printf(\"%lld.%lld0\\n\", ans / 2, 5 * ans % 2);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3fe23342c03a3921f7dea79201fcf560", "src_uid": "6afcdad100c8e2469fef5abcc5bd96c6", "difficulty": 3000.0}
    {"lang": "GNU C++17", "source_code": "#include\nconst int maxn = 410;\nusing std::cin;\nusing std::cout;\nint can[maxn][maxn][maxn];\nint s[maxn][maxn][maxn];\nstd::bitset set[maxn][maxn];\nint a[maxn],b[maxn];\nint n, k;\ntypedef long long ll;\ninline ll cross(int x, int y, int z) {\n\treturn ll(a[y] - a[x]) * (b[z] - b[x]) - ll(a[z] - a[x]) * (b[y] - b[x]);\n}\nstruct seg { int x, y; };\ninline double val(const seg & x) { return std::atan2(b[x.y] - b[x.x], a[x.y] - a[x.x]); }\ninline bool cmp0(const seg & x, const seg & y) { return val(x) < val(y); }\ninline ll calc(int x, int y, int z) {\n\treturn cross(x, y, z);\n}\nll dp[maxn][maxn][maxn];\n\ninline void up(ll & x, ll y) {\n\tif(x < y) {\n\t\tx = y;\n\t}\n}\n\nint main() { \n\tstd::ios::sync_with_stdio(false), std::cin.tie(0);\n\tcin >> n >> k;\n\tfor(int i = 1;i <= n;++i) {\n\t\tcin >> a[i] >> b[i];\n\t}\n\tfor(int i = 1;i <= n;++i) {\n\t\tfor(int j = 1;j <= n;++j) {\n\t\t\tfor(int k = 1;k <= n;++k) if(k != i && k != j && cross(i, j, k) > 0) {\n\t\t\t\tset[i][j].set(k);\n\t\t\t}\n\t\t}\n\t}\n\tfor(int i = 1;i <= n;++i) {\n\t\tfor(int j = 1;j <= n;++j) {\n\t\t\tfor(int k = 1;k <= n;++k) {\n\t\t\t\tcan[i][j][k] = (set[i][j] & set[j][k] & set[k][i]).none();\n\t\t\t}\n\t\t}\n\t}\n\tstd::vector vec;\n\tfor(int i = 1;i <= n;++i) {\n\t\tfor(int j = 1;j <= n;++j) if(i != j) {\n\t\t\tvec.push_back((seg){ i, j });\n\t\t}\n\t}\n\tsort(vec.begin(), vec.end(), cmp0);\n\tfor(int i = 1;i <= n;++i) {\n\t\tfor(int j = 1;j <= n;++j) {\n\t\t\tfor(int c = 1;c <= k;++c) {\n\t\t\t\tdp[i][j][k] = -1e18;\n\t\t\t}\n\t\t}\n\t\tdp[i][i][1] = 0;\n\t}\n\tfor(const seg & x : vec) {\n\t\tfor(int i = 1;i <= n;++i) {\n\t\t\tfor(int cnt = 1;cnt <= k;++cnt) if(can[i][x.x][x.y]) {\n\t\t\t\tup(dp[i][x.y][cnt + 1], dp[i][x.x][cnt] + calc(i, x.x, x.y));\n\t\t\t}\n\t\t}\n\t}\n\tll ans = 0;\n\tfor(int i = 1;i <= n;++i) {\n\t\tup(ans, dp[i][i][k + 1]);\n\t}\n\tprintf(\"%d.%d\\n\", ans >> 1, ans % 2 * 5);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "78ce3689e940b23d9e69611932cb327d", "src_uid": "6afcdad100c8e2469fef5abcc5bd96c6", "difficulty": 3000.0}
    {"lang": "GNU C++14", "source_code": "/*\n   We notice that there are only N^2 important states - (postition, t mod N). Let's make T mod N steps and see where we will be after that. This can be done in the most stupid way in O(N) time. \n   Also let's for each position store the position we will arrive at after N steps. If this value for position x is to[x] the answer of our problem will be to[to[...[x]...]] (applied T / N times).\n   Then after calculating the to[] array, we can simply find the cycle length of to[] and the reminder of (T / N) when divided by it. Then (T / N) <= N and we can easily find the answer in O(N).\n\n   Now the hard part is to find the to[] array. We will go backwards. Initially set to[x] = x. Now we will use persistent treap (actually RBST) to find the actual to values. The main observation\n   is that when decreasing T the to[] array will change just in two intervals. Then we can do the movements with a couple of merges and splits. The complexity will be O(N log N).\n\n   As persistent treaps (RBST) tend to to increase their depth fast, we will rebuild our structure a couple of times.\n*/\n\n#include \n#define endl '\\n'\n\n//#pragma GCC optimize (\"O3\")\n//#pragma GCC target (\"sse4\")\n\n#define SZ(x) ((int)x.size())\n#define ALL(V) V.begin(), V.end()\n#define L_B lower_bound\n#define U_B upper_bound\n#define pb push_back\n\nusing namespace std;\ntemplate int chkmax(T &x, const T1 &y) { return x < y ? x = y, 1 : 0; }\ntemplate int chkmin(T &x, const T1 &y) { return x > y ? x = y, 1 : 0; }\nconst int MAXN = (1 << 20);\nconst int MAX_MEM = (1 << 23);\nconst int B = 5000;\n\nrandom_device rd;\nmt19937 mt(rd());\n\nstruct node\n{\n\tint sz, id;\n\tnode *l, *r;\n\n\tnode() { sz = id = 0; l = r = nullptr; }\n\tnode(int i)\n\t{\n\t\tl = nullptr;\n\t\tr = nullptr;\n\t\tid = i;\n\t\tsz = 1;\n\t}\n};\n\nusing pnode = node*;\n\nint cnt_nodes = 0;\nnode ptr_list[MAX_MEM];\n\nvoid init_memory()\n{\n\tcnt_nodes = 0;\n}\n\npnode new_node(int id)\n{\n\tptr_list[cnt_nodes].l = ptr_list[cnt_nodes].r = nullptr;\n\tptr_list[cnt_nodes].sz = 1, ptr_list[cnt_nodes].id = id;\n\treturn *ptr_list[cnt_nodes++];\n}\n\ninline int size(pnode t) { return t ? t->sz : 0; }\n\nbool hey(int l, int r) { return (int)mt() % (l + r) < l; }\n\nvoid pull(pnode &t)\n{\n\tif(!t) return;\n\tt->sz = 1 + size(t->l) + size(t->r);\n}\n\npnode copy(pnode &t)\n{\n\tif(!t) return nullptr;\n\n\tpnode ret = new_node(0);\n\tret->id = t->id;\n\tret->l = t->l;\n\tret->r = t->r;\n\tret->sz = t->sz;\n\n\treturn ret;\n}\n\nvoid split(pnode t, pnode &l, pnode &r, int k, int add = 0)\n{\n\tif(!t) { l = r = nullptr; return; }\n\n\tint idx = size(t->l) + add;\n\tif(idx <= k)\n\t{\n\t\tl = copy(t);\n\t\tsplit(l->r, l->r, r, k, idx + 1);\n\t\tpull(l);\n\t}\n\telse\n\t{\n\t\tr = copy(t);\n\t\tsplit(r->l, l, r->l, k, add);\n\t\tpull(r);\n\t}\n}\n\nvoid merge(pnode &t, pnode l, pnode r)\n{\n\tif(!l) { t = copy(r); return; }\n\tif(!r) { t = copy(l); return; }\n\n\tif(hey(size(l), size(r)))\n\t\tt = copy(l), merge(t->r, t->r, r);\n\telse\n\t\tt = copy(r), merge(t->l, l, t->l);\n\n\tpull(t);\n}\n\nvector tmp_rec;\n\nvoid get_li_tmp(pnode t)\n{\n\tif(!t) return;\n\tget_li_tmp(t->l);\n\ttmp_rec.pb(t->id);\n\tget_li_tmp(t->r);\n}\n\nvector get_li(pnode t)\n{\n\ttmp_rec.clear();\n\tget_li_tmp(t);\n\treturn tmp_rec;\n}\n\npnode build(int l, int r, vector &li)\n{\n\tif(l > r) return nullptr;\n\n\tint mid = (l + r) >> 1;\n\t\n\tpnode ret = new_node(li[mid]);\n\tret->l = build(l, mid - 1, li);\n\tret->r = build(mid + 1, r, li);\n\n\tpull(ret);\n\n\treturn ret;\n}\n\nint n, m, start_pos;\nint64_t t;\n\nvoid read()\n{\n\tcin >> n >> m;\n\tcin >> start_pos >> t;\n\tstart_pos--;\n}\n\nint to[MAXN];\n\nvoid dfs(pnode t, int p = 0)\n{\n\tif(!t) return;\n\tdfs(t->l, p);\n\tto[p] = t->id;\n\tdfs(t->r, p + size(t->l) + 1);\n}\n\npnode root = nullptr;\nvector tmpp;\n\nvoid rebuild()\n{\n\ttmpp = get_li(root);\n\tcnt_nodes = 0;\n\troot = build(0, n - 1, tmpp);\n}\n\npnode get(int l, int r)\n{\n\tif(l < 0) \n\t{\n\t\tpnode ret;\n\t\tmerge(ret, get(n + l, n - 1), get(0, r));\n\t\treturn ret;\n\t}\n\n\tif(r >= n)\n\t{\n\t\tpnode ret;\n\t\tmerge(ret, get(l, n - 1), get(0, r - n));\n\t\treturn ret;\n\t}\n\n\tpnode dummy, dummy2, ret, mid;\n\tsplit(root, mid, dummy, r);\t\n\tsplit(mid, dummy2, ret, l - 1);\n\treturn ret;\n}\n\nvoid solve()\n{\n\twhile(t % n)\n\t{\n\t\tif(start_pos < m) start_pos = (start_pos + (t % n)) % n;\n\t\telse start_pos = (start_pos + n - (t % n)) % n;\n\t\tt--;\n\t}\n\n\tt /= n;\n\t\n\tfor(int i = 0; i < n; i++) tmpp.pb(i);\n\troot = build(0, n - 1, tmpp);\n\n\tfor(int i = 0; i < n; i++)\n\t{\n\t\tpnode L = get(i, m + i - 1);\n\t\tpnode R = get(m - i, n - 1 - i);\n\t\t\n\t\tmerge(root, L, R);\n\t\tif(i && i % B == 0) \n\t\t\trebuild();\n\t}\n\n\tvector clist = get_li(root);\n\tfor(int i = 0; i < n; i++) to[i] = clist[i];\n\n\tfor(int cnt = 0; t > 0 && cnt < n; cnt++, t--)\n\t\tstart_pos = to[start_pos];\n\n\tif(t != 0)\n\t{\n\t\tint cycle_len = 1, u = to[start_pos];\n\t\twhile(u != start_pos)\n\t\t{\n\t\t\tcycle_len++;\n\t\t\tu = to[u];\n\t\t}\n\n\t\tt %= cycle_len;\n\t\twhile(t--)\n\t\t\tstart_pos = to[start_pos];\n\t}\n\n\tcout << start_pos + 1 << endl;\n}\n\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\t\n\tinit_memory();\n\n\tread();\n\tsolve();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f6c6de1c4a7fca0649ffa5a931fcfd37", "src_uid": "e743242f0cc9e17619e1fe4935d9fbd0", "difficulty": 2900.0}
    {"lang": "GNU C++14", "source_code": "#include \n#define ll long long\n\n#define TASKNAME \"\"\n\nusing namespace std;\n\nconst int INF = 1e9 + 7;\nconst int MAXN = 1e6 + 7;\nconst double EPS = 1e-8;\n\nstruct TNode {\n    TNode *left, *right;\n    int sz, x;\n};\n\nTNode *new_node(int x) {\n    return new TNode({nullptr, nullptr, 1, x});\n}\n\nint safe_sz(TNode *root) {\n    return (root ? root->sz : 0);\n}\n\nvoid relax(TNode *root) {\n    if (!root) return;\n    root->sz = safe_sz(root->left) + safe_sz(root->right) + 1;\n}\n\nTNode *merge(TNode *left, TNode *right) {\n    if (!left) {\n        return right;\n    }\n    if (!right) {\n        return left;\n    }\n    TNode *node = new_node(-1);\n    int sz1 = safe_sz(node->left), sz2 = safe_sz(node->right);\n    if (rand() % (sz1 + sz2) < sz1) {\n        node->left = merge(left, right->left);\n        node->right = right->right;\n        node->x = right->x;\n    } else {\n        node->right = merge(left->right, right);\n        node->left = left->left;\n        node->x = left->x;\n    }\n    relax(node);\n    return node;\n}\n\nvoid split(TNode *root, int sz, TNode *&left, TNode *&right) {\n    if (!root || !sz) {\n        left = nullptr;\n        right = root;\n        return;\n    }\n    TNode *left1, *right1;\n    if (safe_sz(root->left) >= sz) {\n        split(root->left, sz, left1, right1);\n        left = left1;\n    }\n    return;\n}\n\nint main() {\n    #ifdef MY\n        freopen(\"input.txt\", \"r\", stdin);\n        //freopen(\"output.txt\", \"w\", stdout);\n    #else\n        //freopen(TASKNAME\".in\", \"r\", stdin);\n        //freopen(TASKNAME\".out\", \"w\", stdout);\n        ios_base::sync_with_stdio(false);\n        cin.tie(0);\n        cout.tie(0);\n    #endif // MY\n    ll n, m;\n    cin >> n >> m;\n    ll s, t;\n    cin >> s >> t;\n    s--;\n    int len1 = m, len2 = n - m;\n    unordered_map , bool> was;\n    vector  > path;\n    while (t > 0) {\n        if (was[{s, t % n}]) break;\n        was[{s, t % n}] = true;\n        path.push_back({s, t % n});\n        if (s < m) {\n            s = (s + t) % n;\n        } else {\n            s = ((s - t) % n + n) % n;\n        }\n        //cout << s << \"\\n\";\n        t--;\n    }\n    if (!t) {\n        cout << s + 1 << \"\\n\";\n        return 0;\n    }\n    ll cycle = 1;\n    while (path.back() != make_pair(s, t % n)) {\n        path.pop_back();\n        cycle++;\n    }\n    t %= cycle;\n    while (t > 0) {\n        if (s < m) {\n            s = (s + t) % n;\n        } else {\n            s = ((s - t) % n + n) % n;\n        }\n        t--;\n    }\n    cout << s + 1;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "224162b6000661797d6563b643798ce2", "src_uid": "e743242f0cc9e17619e1fe4935d9fbd0", "difficulty": 2900.0}
    {"lang": "GNU C++14", "source_code": "#include \n#define ll long long\n\n#define TASKNAME \"\"\n\nusing namespace std;\n\nconst ll INF = 1e9 + 7;\nconst ll MAXN = 1e5 + 7;\nconst double EPS = 1e-8;\n\nint main() {\n    #ifdef MY\n        freopen(\"input.txt\", \"r\", stdin);\n        //freopen(\"output.txt\", \"w\", stdout);\n    #else\n        //freopen(TASKNAME\".in\", \"r\", stdin);\n        //freopen(TASKNAME\".out\", \"w\", stdout);\n        ios_base::sync_with_stdio(false);\n        cin.tie(0);\n        cout.tie(0);\n    #endif // MY\n    ll n, m;\n    cin >> n >> m;\n    ll s;\n    ll t;\n    cin >> s >> t;\n    s--;\n    bitset  was;\n    vector  path;\n    while (t > 0) {\n        if (was[s * MAXN + t % n]) break;\n        was[s * MAXN + t % n] = true;\n        path.push_back(s * MAXN + t % n);\n        if (s < m) {\n            s = (s + t) % n;\n        } else {\n            s = ((s - t) % n + n) % n;\n        }\n        t--;\n    }\n    if (!t) {\n        cout << s + 1 << \"\\n\";\n        return 0;\n    }\n    ll cycle = 1;\n    while (path.back() != s * MAXN + t % n) {\n        path.pop_back();\n        cycle++;\n    }\n    t %= cycle;\n    while (t > 0) {\n        if (s < m) {\n            s = (s + t) % n;\n        } else {\n            s = ((s - t) % n + n) % n;\n        }\n        t--;\n    }\n    cout << s + 1;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "55968f8645b76f071c522409a2436902", "src_uid": "e743242f0cc9e17619e1fe4935d9fbd0", "difficulty": 2900.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \n\n#include \n\n#include \n#include \n#include \n\nusing namespace std;\n\nconst int MAXN = 1e5 + 100;\n\ntypedef long long ll;\n#define tll(x) static_cast(x)\n\ntypedef pair pii;\n#define mp make_pair\n#define ff first\n#define ss second\n\nint N, root;\n\nconst int MAXS = MAXN * 800;\nstruct PBT {\npublic:\n  int c[MAXS][2], v[MAXS], sz[MAXS], h[MAXS];\n  int NXT;\n  PBT() : NXT(1) {v[0] = -1, sz[0] = 0, h[0] = 0;};\n  int upd(int n) {\n    if(not(0 < n)) return n;\n    sz[n] = sz[c[n][0]] + sz[c[n][1]] + 1;\n    h[n] = max(h[c[n][0]], h[c[n][1]]) + 1;\n    assert(n != c[n][0] and n != c[n][1]);\n    return n;\n  }\n  int gsz(int n) {\n    if(n == 0) return 0;\n    return gsz(c[n][0]) + gsz(c[n][1]) + 1;\n  }\n  void asst(int n) {assert(gsz(n) == sz[n]);}\n  int nn(const int& n = -1) {\n    assert(NXT < MAXS);\n    if(n == 0) return 0;\n    if(0 < n) {\n      for(int i = 0;i < 2;i++) c[NXT][i] = c[n][i];\n      v[NXT] = v[n];\n    } else {\n      for(int i = 0;i < 2;i++) c[NXT][i] = 0;\n      v[NXT] = -1;\n    }\n    upd(NXT);\n    return NXT++;\n  }\n  int nnr(const int& q) {\n    int n = nn();\n    v[n] = q;\n    return n;\n  }\n  int L(int& n, int p = 0) {\n    assert(c[n][1]);\n    int o;\n    if(p>1) o = nn(n); else o = n;\n    if(p>0) n = nn(c[n][1]); else n = c[n][1];\n    c[o][1] = c[n][0];\n    upd(c[n][0] = o);\n    return upd(n);\n  }\n  int R(int& n, int p = 0) {\n    assert(c[n][0]);\n    int o;\n    if(p>1) o = nn(n); else o = n;\n    if(p>0) n = nn(c[n][0]); else n = c[n][0];\n    c[o][0] = c[n][1];\n    upd(c[n][1] = o);\n    return upd(n);\n  }\n  bool bal(int& n, bool p = false) {   //here, we assume that n is already a copy\n    int q = NXT;\n    int b = h[c[n][0]] - h[c[n][1]], s, o = n;\n    if(b < -1) {\n      assert(s = c[n][1]);\n      if(h[c[s][1]] + 1 == h[s]) {\n        L(n, p ? 1 : 0);\n      } else if(h[c[s][0]] + 1 == h[s]) {\n        R(c[n][1], p ? 2 : 0);\n        L(n, 0);\n      } else assert(false);\n    }\n    else if(b > 1) {\n      assert(s = c[n][0]);\n      if(h[c[s][0]] + 1 == h[s]) {\n        R(n, p ? 1 : 0);\n      } else if (h[c[s][1]] + 1 == h[s]) {\n        L(c[n][0], p ? 2 : 0);\n        R(n, 0);\n      } else assert(false);\n    }\n    else return false;\n    return true;\n  }\n  int join(int a, int b, bool p = true) {  //here we assume a and b are already copies\n    if(a == 0 or b == 0) return a ? a : b;\n    if(h[a] < h[b]) {\n      c[b][0] = join(a, p ? nn(c[b][0]) : c[b][0], p);\n      upd(b);\n      bal(b, p);\n      return b;\n    } else {\n      c[a][1] = join(p ? nn(c[a][1]) : c[a][1], b, p);\n      upd(a);\n      bal(a, p);\n      return a;\n    }\n  }\n  int join2(int l, int m, int r) {    //assume all are copies, merges L and R at M\n    if(h[l] + 1 < h[r]) {c[r][0] = join2(l, m, nn(c[r][0])); return upd(r);}\n    if(h[r] + 1 < h[l]) {c[l][1] = join2(nn(c[l][1]), m, r); return upd(l);}\n    c[m][1] = r;\n    c[m][0] = l;\n    upd(m);\n    bal(m, 1);\n    return m;\n  }\n  pii split(int a, int k) {   //always create new nodes, assume a is NOT a copy\n    if(k == 0) return mp(0, nn(a));\n    assert(0 < k);\n    if(sz[c[a][0]] < k) {\n      pii q = split(c[a][1], k - sz[c[a][0]] - 1);\n      int r = join2(nn(c[a][0]), nnr(v[a]), q.ff);\n      return mp(r, q.ss);\n    } else {\n      pii q = split(c[a][0], k);\n      int r = join2(q.ss, nnr(v[a]), nn(c[a][1]));\n      return mp(q.ff, r);\n    }\n  }\n  int get(int l, int r) {   //inclusive - exclusive\n    while(not(l < N)) l -= N, r -= N;\n    while(l < 0) l += N, r += N;\n    \n    if(r > N) return join(get(l, N), get(N, r));\n    pii f1 = split(root, r);\n    pii f2 = split(f1.ff, l);\n    \n    return f2.ss;\n  }\n  void fill(int n, int * a, int * t = new int(0)) {\n    if(n == 0) return;\n    fill(c[n][0], a, t);\n    a[(*t)++] = v[n];\n    fill(c[n][1], a, t);\n  }\n  void pout(int n = root) {\n    if(n == 0) return;\n    pout(c[n][0]);\n    cerr << v[n] << \" \";\n    pout(c[n][1]);\n    if(n == root) cerr << \"\\n\\n\";\n  }\n} pbt;\n\nint M, S;\nll T;\n\nint to[40][MAXN];\n\nvoid gen() {\n  root = 0;\n  for(int i = 0;i < N;i++) root = pbt.join(root, pbt.nnr(i), 0);\n  for(int i = 1;i < N;i++) {\n    int a = pbt.get(i, i + M);\n    int b = pbt.get(M - i, N - i);\n    assert(pbt.sz[a] == M and pbt.sz[b] == N - M);\n    root = pbt.join(a, b);\n    //pbt.pout();\n    assert(pbt.sz[root] == N);\n  }\n  pbt.fill(root, to[0]);\n}\n\nvoid run() {\n  for(int i = 1;i < 40;i++) {\n    for(int j = 0;j < N;j++) {\n      to[i][j] = to[i-1][to[i-1][j]];\n    }\n  }\n}\n\nvoid brute() {\n  int q = static_cast(T%N);\n  for(;q;q--,T--) {\n    if(S < M) S = (S + q)%N;\n    else S = (S - q + N)%N;\n  }\n  assert(T%N == 0);\n}\n\nvoid solve() {\n  scanf(\"%d%lld\", &S, &T);\n  --S;\n  brute();\n  int k = T/N;\n  for(int i = 0;1 << i < k;i++) {\n    if(k&(1<(clock() - timer)/CLOCKS_PER_SEC << \"\\n\";\n  \n  return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9155e6342d86b98411e1a5d316e8d2b0", "src_uid": "e743242f0cc9e17619e1fe4935d9fbd0", "difficulty": 2900.0}
    {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nint main()\n{\nint n,k,f=0,c=1,s,m;\ncin>>n>>k;\nint a[n],b[k];\nfor(int i=0;i>a[i];\n   }\nb[f++]=a[0];\nfor(int i=1;i\nusing namespace std;\nint main(){\n\tint n,k,x,cnt=0,a[100];\n\tset s,t;\n\tcin>>n>>k;\n\tfor (int i=0;i>a[i];\n\tfor (int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define read(x) scanf(\"%d\", &x);\n#define dbg(x) cout<<#x<<\"= \"< s;\nmap ma;\nset::iterator it;\n\nint main(){\n    read(n);read(m);\n    for(int i=1;i<=n;i++){\n        read(a[i]);\n    }\n\n    for(int i=n;i>=1;i--){\n        if(ma[a[i]]!=0){\n            next[a[i]]=ma[a[i]];\n        }else next[i]=INF;\n        ma[a[i]]=i;\n    }\n\n    for(int i=1;i<=n;i++){\n        if(s.find(a[i])==s.end()){\n            q++;\n            if(s.size()!=m){\n                s.insert(a[i]);\n            }else{\n                int cnt=0,pos;\n                for (it = s.begin(); it != s.end(); it++){\n                        if(next[*it]>cnt){cnt=next[*it];pos=*it;}\n                }\n                s.erase(pos);\n                s.insert(a[i]);\n            }\n        }\n    }\n    cout<\n#include\n#include\nusing namespace std;\nint a[400005];\nqueueind[400005];\nsetstb;\nset::iterator it;\nstruct node\n{\n\tint index;\n\tint biao;\n}M;\nsetst;\nbool operator<(node a,node b)\n{\t\nif(a.index==b.index) return a.biaob.index;\n}\nint cot=0;\nint main()\n{\n\tint n,k;\n\tscanf(\"%d%d\",&n,&k);\n\tfor(int i=0;ibiao));\n\t\t\t  st.erase(st.begin);\n\t\t\t}\n\t\t\tstb.insert(a[i]);\n\t\t}\n\t\tM.biao=a[i];\n\t\tif(!ind[a[i]].empty())\n\t\t{\n\t\t  M.biao=ind[a[i]].front();\n\t\t  ind[a[i]].pop();\n\t   }\n\t   else M.index=n;\n\t   \n\t\tst.insert(M);\n\t}\n\tprintf(\"%d\\n\",ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ac22b820737e0d5c2f702ee9cb1c803a", "src_uid": "956228e31679caa9952b216e010f9773", "difficulty": 1800.0}
    {"lang": "GNU C++17", "source_code": "import java.io.OutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.io.PrintWriter;\nimport java.util.Scanner;\n\n/**\n * Built using CHelper plug-in\n * Actual solution is at the top\n *\n * @author dilip\n */\npublic class Main {\n    public static void main(String[] args) {\n        InputStream inputStream = System.in;\n        OutputStream outputStream = System.out;\n        Scanner in = new Scanner(inputStream);\n        PrintWriter out = new PrintWriter(outputStream);\n        TaskA solver = new TaskA();\n        solver.solve(1, in, out);\n        out.close();\n    }\n\n    static class TaskA {\n        public void solve(int testNumber, Scanner in, PrintWriter out) {\n\n            int n, m, k;\n            n = in.nextInt();\n            m = in.nextInt();\n            k = in.nextInt();\n            if (m >= n && k >= n) out.println(\"Yes\");\n            else out.println(\"No\");\n\n        }\n\n    }\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e64a3e5a913e0a3b554730f47c7eec65", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0}
    {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\nint main()\n{\n    int n,m,k;\n    cin>>n>>m>>k;\n\n    if(m>=n && k>=n)\n    {\n        cout<<\"Yes\";\n    }\n\n    else{\n\n        cout<<\"No\";\n    }\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "dca5d7540d0d6eb077c2780feeed2971", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0}
    {"lang": "MS C++ 2017", "source_code": "#include \nusing namespace std;\nint n,m,k;\nint main()\n{\n    cin>>n>>m>>k;\n    if(m>=n and k>=n) cout<<\"Yes\";\n    else cout<<\"No\";\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "974a263e4f81f4597d12cb06140b82df", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0}
    {"lang": "GNU C++17", "source_code": "    #include\n    #include\n    using namespace std;\n    #define mod 1e9+7\n    #define FOR(a,c)   for ( int (a)=0; (a)<(c); (a)++)\n    #define FORL(a,b,c)  for ( int (a)=(b); (a)<=(c); (a)++)\n    #define FORR(a,b,c)  for (  int (a)=(b); (a)>=(c); (a)--)\n    #define INF 1000000000000000003\n    typedef long long int ll;\n    typedef vector vi;\n    typedef pair pi;\n    typedef priority_queue max_pq;\n    typedef priority_queue, greater> min_pq;\n    #define F first\n    #define S second\n    #define PB push_back\n    #define POB pop_back\n    #define MP make_pair\n\n    // Use inbuilt function  __gcd(a,b), __builtin_popcount(n)\n\n   bool issor(ll arr[], ll n)\n   {\n    for(int i=1;i<=n;i++)\n    {\n        if(arr[i]!=i)\n            return false;\n    }\n    return true;\n   }\n\n    int main()\n    {\n        ios_base::sync_with_stdio(false);\n        cin.tie(NULL);\n        cout.tie(NULL);    \n        \n        ll n,m,k;\n        cin>>n;\n        cin>>m>>k;\n        ll mina = min(m,k);\n        if(min>=n)\n            cout<<\"YES\";\n        else\n            cout<<\"NO\";\n\n        return 0;\n    }\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2b0a90e8421172a8afe5d3477208109c", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4", "difficulty": 800.0}
    {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nbool is_square(long long n) {\n  long long s = sqrt(n);\n  return s * s == n;\n}\n\nvector pf(long long n) {\n  vector res;\n  for (long long i = 2; i <= 1000000; i++) {\n    if (n % i == 0) {\n      res.push_back(i);\n      while (n % i == 0) {\n        n /= i;\n      }\n    }\n  }\n  if (n != 1) {\n    if (is_square(n)) {\n      n = sqrt(n);\n    }\n    res.push_back(n);\n  }\n  return res;\n}\n\nlong long gcd(long long x, long long y) {\n  while (y != 0) {\n    long long tmp = x;\n    x = y;\n    y = tmp % y;\n  }\n  return x;\n}\n\nvector vec(vector &p, long long n) {\n  vector res(p.size());\n  for (int i = 0; i < res.size(); i++) {\n    while (n % p[i] == 0) {\n      res[i]++;\n      n /= p[i];\n    }\n  }\n  return res;\n}\n\nint main() {\n  int n;\n  long long X, Y;\n  cin >> n >> X >> Y;\n  auto py = pf(Y);\n  vector a(n);\n  for (int i = 0; i < n; i++) {\n    scanf(\"%lld\", &a[i]);\n    if (!py.empty() && gcd(py.back(), a[i]) != py.back()) {\n      long long g = gcd(py.back(), a[i]);\n      if (g != 1 && g != py.back()) {\n        py.back() /= g;\n        py.push_back(g);\n      }\n    }\n  }\n  if (Y % X != 0) {\n    cout << 0 << endl;\n    return 0;\n  }\n  const int m = py.size();\n  vector dp(1 << m);\n  vector vx = vec(px, X);\n  vector vy = vec(py, Y);\n  for (int i = 0; i < n; i++) {\n    if (Y % a[i] != 0) continue;\n    auto va = vec(py, a[i]);\n    bool ok = true;\n    int mask = 0;\n    for (int j = 0; j < m; j++) {\n      ok &= va[j] <= vy[j];\n      if (va[j] < vy[j]) {\n        mask |= 1 << j;\n      }\n    }\n    if (!ok) continue;\n    dp[mask]++;\n  }\n  for (int i = 0; i < m; i++) {\n    for (int j = 0; j < 1 << m; j++) {\n      if (j >> i & 1) {\n        dp[j ^ 1 << i] += dp[j];\n      }\n    }\n  }\n  for (int i = 0; i < m; i++) {\n    for (int j = 0; j << 1 << m; j++) {\n      if (~j >> i & 1) {\n        dp[j | 1 << i] -= dp[j];\n      }\n    }\n  }\n  long long ans = 0;\n  for (int i = 0; i < n; i++) {\n    auto va = vec(py, a[i]);\n    bool ok = true;\n    int mask = 0;\n    for (int j = 0; j < m; j++) {\n      ok &= va[j] >= vx[j];\n      if (va[j] > vx[j] && vx[j] < vy[j]) {\n        mask |= 1 << j;\n      }\n    }\n    if (!ok) continue;\n    ans += abs(dp[mask]);\n  }\n  cout << ans << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e0706148cd066a84acfb431c95667d7d", "src_uid": "8d43a542d5bf79d15926c4a6a5ff608f", "difficulty": 2700.0}
    {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\ntypedef long long LL;\nLL gcd(LL a, LL b) {\n  if (not a or not b) return a|b;\n  return gcd(b, a % b);\n}\nLL lcm(LL a, LL b) {\n  return a * b / gcd(a, b);\n}\nvector fast_OR_transform(vector f, bool inverse) {\n  for (int i = 0; (2 << i) <= f.size(); ++i)\n    for (int j = 0; j < f.size(); j += 2 << i)\n      for (int k = 0; k < (1 << i); ++k)\n        f[j + k + (1 << i)] += f[j + k] * (inverse? -1 : 1);\n  return f;\n}\nvector rev(vector A) {\n  for (int i = 0; i < A.size(); i += 2) swap(A[i], A[i ^ (A.size() - 1)]);\n  return A;\n}\nvector fast_AND_transform(vector f, bool inverse) {\n  return rev(fast_OR_transform(rev(f), inverse));\n}\n\nLL mul(LL x, LL y, LL mod) {\n  LL m = x, s = 0;\n  for (; y; y >>= 1, m <<= 1, m = m >= mod? m - mod: m)\n    if (y&1) s += m, s = s >= mod? s - mod: s;\n  return s;\n}\nLL powmod(LL x, LL p, LL mod) {\n  LL s = 1, m = x % mod;\n  for (; p; m = mul(m, m, mod), p >>= 1)\n    if (p&1) s = mul(s, m, mod); // or consider int128\n  return s;\n}\nbool miller_rabin(LL n, int s = 7) {\n  const LL wits[7] = {2, 325, 9375, 28178, 450775, 9780504, 1795265022};\n  auto witness = [=](LL a, LL n, LL u, int t) {\n    LL x = powmod(a, u, n), nx;\n    for (int i = 0; i < t; ++i, x = nx){\n      nx = mul(x, x, n);\n      if (nx == 1 and x != 1 and x != n - 1) return 1;\n    }\n    return x != 1;\n  };\n  if (n < 2) return 0;\n  if (n&1^1) return n == 2;\n  LL u = n - 1, t = 0, a; // n == (u << t) + 1\n  while (u&1^1) u >>= 1, ++t;\n  while (s--) \n    if ((a = wits[s] % n) and (witness(a, n, u, t))) return 0;\n  return 1;\n}\n// Pollard_rho\nLL pollard_rho(LL n) {\n  auto f = [=](LL x, LL n) { return mul(x, x, n) + 1; };\n  if (n&1^1) return 2;\n  while (true) {\n    LL x = rand() % (n - 1) + 1, y = 2, d = 1;\n    for (int sz = 2; d == 1; y = x, sz <<= 1) \n      for (int i = 0; i < sz and d <= 1; ++i) \n        x = f(x, n), d = gcd(abs(x - y), n);\n    if (d and n - d) return d;\n  }\n}\nvector> factor(LL m) {\n  vector> ans;\n  while (m != 1) {\n    LL cur = m;\n    while (not miller_rabin(cur)) cur = pollard_rho(cur);\n    ans.emplace_back(cur, 0);\n    while (m % cur == 0) ++ans.back().second, m /= cur;\n  }\n  sort(ans.begin(), ans.end());\n  return ans;\n}\nint main() {\n  ios_base::sync_with_stdio(false); cin.tie(0);\n  LL a, n, X, Y; cin >> n >> X >> Y;\n  if (Y % X) cout << 0 << '\\n', exit(0);\n  auto factor_Y = factor(Y);\n  int m = factor_Y.size();\n  assert(m <= 20);\n  vector left(1<> factor_X;\n  for (auto T: factor_Y) {\n    static LL C_X = X;\n    LL p, t; tie(p, t) = T;\n    factor_X.emplace_back(p, 0);\n    while (C_X % p == 0) C_X /= p, ++factor_X.back().second;\n  }\n  for (int i = 0; i < n; ++i) {\n    cin >> a;\n    int maskl = 0, maskr = 0;\n    bool can_left = a % X == 0, can_right = Y % a == 0;\n    for (int j = 0; j < m; ++j) {\n      LL p, tx, ty, ta = 0;\n      tie(p, tx) = factor_X[j];\n      tie(p, ty) = factor_Y[j];\n      if (tx == ty) continue;\n      while (a % p == 0) ++ta, a /= p;\n      maskl |= (tx < ta) << j;\n      maskr |= (ty > ta) << j;\n    }\n    if (can_left) ++left[maskl];\n    if (can_right) ++right[maskr];\n  }\n  left = fast_AND_transform(left, false), right = fast_AND_transform(right, false);\n  for (int i = 0; i < (1<\n#include \n#include \n#include \n#include \n#define int long long\nusing namespace std;\nvector V;\nint n,x,y,a[10100000],sum[(1<<20)],num[(1<<20)];\nint gcd(int a,int b){\n\treturn (b==0)?a:gcd(b,a%b);\n}\nint lcm(int a,int b){\n\treturn a/gcd(a,b)*b;\n}\nint get_state(int x){\n\tint S=0;\n\tfor(int i=0;i>=1; \n    }\n    return ans;\n\t}\n\tinline long long gcd(long long a,long long b){\n\t    return (b==0)?a:gcd(b,a%b);\n\t}\n\tinline bool mr(long long n,long long p){\n\t    if(pow(n,p-1,p)!=1)\n\t        return false;\n\t    register long long k=p-1;\n\t    while(k%2==0){\n\t        k/=2;\n\t        register long long mid=pow(n,k,p);\n\t        if(mid==p-1)\n\t            return true;\n\t        if(mid!=1&&mid!=p-1)\n\t            return false;\n\t    }\n\t    return true;\n\t}\n\tinline bool prime(long long n){\n\t    if(n==2||n==3||n==7||n==61||n==103||n==24251)\n\t        return true;\n\t    return mr(2,n)&&mr(3,n)&&mr(61,n)&&mr(7,n)&&mr(24251,n)&&mr(103,n);\n\t}\n\tinline long long pollard_rho(long long n,long long c){\n\t    register long long i=1,k=2,x=(rand())%(n-1)+1,y=x;\n\t    while(1){\n\t        i++;\n\t        x=((__int128)x*x%n+c)%n;\n\t        register long long Gcd=gcd(n,(y-x+n)%n);\n\t        if(y==x)\n\t            return n;\n\t        if(Gcd!=1&&Gcd!=n)\n\t            return Gcd;\n\t        if(i==k){\n\t            y=x;\n\t            k<<=1;\n\t        }\n\t    }\n\t}\n\tinline void find(long long n,long long c){\n\t    if(prime(n)){\n\t    \tV.push_back(n);\n\t        return;\n\t    }\n\t    register long long p=n,k=c;\n\t    while(p>=n){\n\t        p=pollard_rho(p,c--);\n\t    }\n\t    find(p,k);\n\t    find(n/p,k);\n\t}\n}\nsigned main(){\n//\tgetprime(10001000);\n//\tscanf(\"%lld\",&y);\n//\tfj(y,10001000);\n//\tfor(int i=0;i\n#include \n#include \n#include \n#include \n#define int long long\nusing namespace std;\nvector V;\nint n,x,y,a[10100000],sum[(1<<20)],num[(1<<20)];\nint gcd(int a,int b){\n\treturn (b==0)?a:gcd(b,a%b);\n}\nint lcm(int a,int b){\n\treturn a/gcd(a,b)*b;\n}\nint get_state(int x){\n\tint S=0;\n\tfor(int i=0;i>=1; \n    }\n    return ans;\n\t}\n\tinline long long gcd(long long a,long long b){\n\t    return (b==0)?a:gcd(b,a%b);\n\t}\n\tinline bool mr(long long n,long long p){\n\t    if(pow(n,p-1,p)!=1)\n\t        return false;\n\t    register long long k=p-1;\n\t    while(k%2==0){\n\t        k/=2;\n\t        register long long mid=pow(n,k,p);\n\t        if(mid==p-1)\n\t            return true;\n\t        if(mid!=1&&mid!=p-1)\n\t            return false;\n\t    }\n\t    return true;\n\t}\n\tinline bool prime(long long n){\n\t    if(n==2||n==3||n==7||n==61||n==103||n==24251)\n\t        return true;\n\t    return mr(2,n)&&mr(3,n)&&mr(61,n)&&mr(7,n)&&mr(24251,n)&&mr(103,n);\n\t}\n\tinline long long pollard_rho(long long n,long long c){\n\t    register long long i=1,k=2,x=(rand())%(n-1)+1,y=x;\n\t    while(1){\n\t        i++;\n\t        x=((__int128)x*x%n+c)%n;\n\t        register long long Gcd=gcd(n,(y-x+n)%n);\n\t        if(y==x)\n\t            return n;\n\t        if(Gcd!=1&&Gcd!=n)\n\t            return Gcd;\n\t        if(i==k){\n\t            y=x;\n\t            k<<=1;\n\t        }\n\t    }\n\t}\n\tinline void find(long long n,long long c){\n\t    if(prime(n)){\n\t    \tV.push_back(n);\n\t        return;\n\t    }\n\t    register long long p=n,k=c;\n\t    while(p>=n){\n\t        p=pollard_rho(p,c--);\n\t    }\n\t    find(p,k);\n\t    find(n/p,k);\n\t}\n}\nsigned main(){\n//\tgetprime(10001000);\n//\tscanf(\"%lld\",&y);\n//\tfj(y,10001000);\n//\tfor(int i=0;i\n#include\n#include\n#define sf scanf\n#define pf printf\n#define fr freopen\n#define ps for(;;)\n#define lp(i,a,b) for(int i=a;i<=b;++i)\n#define rp(i,a,b) for(int i=a;i>=b;--i)\nusing namespace std;\ntypedef long long ll;\nll f[2010][2010],g[2010],h[2010],p=1000000007,ans=0;\nll s[2010][2010];\nint main(){\n    lp(i,2,2000){\n        lp(j,1,2000){\n            if(j==1)f[i][j]=1;\n            else f[i][j]=(f[i][j]+h[j-1])%p;    \n            g[j]=(g[j]+f[i][j])%p;\n            h[j]=(h[j]+f[i][j])%p;\n        }\n        lp(j,1,2000)h[j]=(h[j]+g[j])%p;\n    }\n    lp(i,2,2000)\n        lp(j,1,2000)\n            s[i][j]=(s[i][j-1]+f[i][j])%p;\n    int n,m;sf(\"%d%d\",&n,&m);\n    lp(i,1,n)\n        lp(j,2,m)\n            ans=(ans+f[j][i]*s[j][n-i+1]%p*(m-j+1)%p)%p;\n    pf(\"%I64d\\n\",ans);\n    ps;\n    return 0;\n} \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8fd0cdae6c15f33aed1adc55f6d43b38", "src_uid": "9ca1ad2fa16ca81e9ab5eba220b162c1", "difficulty": 2400.0}
    {"lang": "GNU C++", "source_code": "/* 2013-07-26 09:13:44.790583 */#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define mo 1000000007\n\nusing namespace std;\n\nlong long n, m, i, j, now1, now2, now, Ans;\nlong long f[2005][2005], f2[2005][2005];\n\nint main()\n{\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "40ad97dc5bba81e462832d741ec20801", "src_uid": "9ca1ad2fa16ca81e9ab5eba220b162c1", "difficulty": 2400.0}
    {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\nconst int mod = 1000000007;\nint dp[2010][2010];\nint sum[2010][2010];\nint f[2010][2010];\n//dp[i][j] = 1 + dp[i - 1][j] * 1 + dp[i - 1][j - 1] * 2 + ... + dp[i - 1][2] * (j - 1)\n//dp[i][j - 1] = 1 + dp[i - 1][j - 1] + dp[i - 1][j - 2] * 2 + .. + dp[i - 1][2] * (j - 2)\n//dp[i][j] = 1 + dp[i - 1][j - 1] + (dp[i - 1][j] + dp[i - 1][j - 1] + .. + dp[i - 1][2] = dp[i - 1][j - 1] + sum[i - 1][j]\n//f[i][j] = sumr[i][j - 1] * 2 + sumr[i][j - 2] * 3 + .. + sumr[i][2] * (j - 1)\n//f[i][j - 1] = sumr[i][j - 2] * 2 + .. + sumr[i][2] * (j - 2)\n//f[i][j] = f[i][j - 1] + sumr[i][j - 1] * 2 + .. + sumr[i][2]\nint main()\n{\n\tmemset(dp,0,sizeof(dp));\n\tmemset(sum,0,sizeof(sum));\n\tmemset(sumr,0,sizeof(sumr));\n\tint n,m;\n\tscanf(\"%d%d\",&n,&m);\n\tfor(int i = 2; i <= m; i ++) {\n\t\tdp[1][i] = 1;\n\t\tsum[1][i] = sum[1][i - 1] + 1;\n\t}\n\tfor(int i = 2; i <= n; i ++) {\n\t\tfor(int j = 2; j <= m; j ++) {\n\t\t\tif(j == 2) dp[i][j] = (1 + dp[i][j - 1] + sum[i - 1][j]) % mod;\n\t\t\telse dp[i][j] = (dp[i][j - 1] + sum[i - 1][j]) % mod;\n\t\t\tsum[i][j] = (sum[i][j - 1] + dp[i][j]) % mod;\n\t\t}\n\t}\n\tmemset(f,0,sizeof(f));\n\tmemset(sum,0,sizeof(sum));\n\tfor(int i = 1; i <= n; i ++) {\n\t\tfor(int j = 3; j <= m; j ++) {\n\t\t\tsum[i][j] = (sum[i][j - 1] + dp[i][j - 1]) % mod;\n\t\t\tf[i][j] = (f[i][j - 1] + sum[i][j] + dp[i][j - 1]) % mod;\n\t\t}\n\t}\n\tint ans = 0;\n\tfor(int i = 1; i <= m; i ++) dp[0][i] = dp[i][1] = 1;\n\tfor(int i = 1; i <= n; i ++) {\n\t\tfor(int j = 2; j <= m; j ++) {\n\t\t\tint tmp = 0;\n\t\t\tif(i != n && j != 2) tmp = 1LL * dp[i][j] * (m - j + 1) % mod * (1 + f[n - i][j]) % mod;\n\t\t\telse if(j == 2) tmp =  1LL * dp[i][j] * (m - j + 1) % mod;\n\t\t\telse tmp = 1LL * dp[i][j] * (m - j + 1) % mod;\n\t\t\tans = (ans + tmp) % mod;\n\t\t}\n\t}\n\tcout << ans << endl;\n\treturn 0;\n}\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d0cb230772101a4dc68436870f7ba349", "src_uid": "9ca1ad2fa16ca81e9ab5eba220b162c1", "difficulty": 2400.0}
    {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\ntypedef signed long long ll;\n\n#undef _P\n#define _P(...) (void)printf(__VA_ARGS__)\n#define FOR(x,to) for(x=0;x>N>>M;\n    \n    for(x=2;x<=2000;x++) dp[x][0]=dp2[x][0]=dp3[x][0]=1;\n    for(y=1;y<=2000;y++) {\n        ll tot=0;\n        for(x=2;x<=2000;x++) {\n            tot+=dp[x][y-1];\n            dp[x][y]=(dp[x-1][y]+tot)%mo;\n            dp2[x][y]=(dp[x][y]+mo-dp[x][y-1])%mo;\n            dp3[x][y]=(dp3[x][y-1]+dp2[x][y])%mo;\n        }\n    }\n    \n    int y1,y2,w;\n    ll ret=0;\n    FOR(y1,N) for(y2=y1;y2\n//#include \n//#include \n//#include \n//#include \n//#include \n//#include \n//#include \n//#include \n//#include \n//#include \n//#include \n//#include \n//#include \n//#include \n//\n//#define pb push_back\n//#define mp make_pair\n//#define X first\n//#define Y second\n//#define PI 3.14159265358979\n//#define forn(i, n) for(int i = 0; i < n; ++i)\n//#define ALL(x) x.begin(), x.end()\n//#define L(s) (int)((s).size())\n//#define sz(s) (int)((s).size())\n//#define ms(x) memset(x,0,sizeof(x))\n//#define ms1(x) memset(x,-1,sizeof(x))\n//#define del(y,x) erase(y.begin()+x)\n//\n//typedef long long ll;\n//using namespace std;\n//typedef pair pii;\n//const int INF = 2147483647;\n//const ll LLINF = 9223372036854775807LL;\n//const int ST = 100010;\n//const int ST1 = 1000010;\n//const ll MOD = 1000000007;\n//\n//ll ABS(ll a) {\n//    if(a<0)\n//        return a*(-1);\n//    else\n//        return a;\n//}\n//\n//int main() {\n//#ifdef _DEBUG\n//    freopen(\"input.txt\", \"r\", stdin);\n//    freopen(\"output.txt\", \"w\", stdout);\n//#endif\n//\n//\n//    return 0;\n//}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f5ea84a5128eb7dc3b67e652b4d1bdf6", "src_uid": "41f6f90b7307d2383495441114fa8ea2", "difficulty": 2000.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nvoid init()\n{\n\tfreopen(\"input.txt\", \"r\", stdin);\n}\n\nint abs(int x)\n{\n\tif (x < 0)\n\t{\n\t\treturn -x;\n\t}\n\treturn x;\n}\n\nint main()\n{\n\tint n, m, x1, y1, x2, y2;\n\tcin >> n >> m >> x1 >> y1 >> x2 >> y2;\n\tn = abs(x1 - x2) + 1;\n\tm = abs(y1 - y2) + 1;\n\tif ((n >= 6) || (m >= 6))\n\t{\n\t\tcout << \"Second\"l;\n\t\treturn 0;\n\t}\n\tif ((n <= 4) && (m <= 4))\n\t{\n\t\tcout << \"First\";\n\t\treturn 0;\n\t}\n\tif (((n == 5) || (n == 4)) && ((m == 5) || (m == 4)))\n\t{\n\t\tcout << \"Second\";\n\t\treturn 0;\n\t}\n\tcout << \"First\" << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1240ac45b7668e3bf4e9528cf3cda455", "src_uid": "41f6f90b7307d2383495441114fa8ea2", "difficulty": 2000.0}
    {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n\nint n,m,x1,y1,x2,y2,x,y;\n\nint main()\n{\n    cin >> n >> m >> x1 >> y1 >> x2 >> y2;\n    int x = abs(x1-x2);\n    int y = abs(y1-y2);\n    if (x <= 3 || y <=3) cout <<\"First\\n\";\n    else cout << \"Second\\n\";\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8e2b7acb2427fe1f897aae48551882a5", "src_uid": "41f6f90b7307d2383495441114fa8ea2", "difficulty": 2000.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint n, m;\nint x1, y1, x2, y2;\nint main() {\n    scanf(\"%d %d\", &n, &m);\n    scanf(\"%d %d %d %d\", &x1, &x2, &y1, &y2);\n    int z1 = max(abs(y1 - x1) , abs(y2 - x2)), z2 = min(abs(y1 - x1) , abs(y2 - x2));\n    if(abs(y1 - x1) >= 5 || abs(y2 - x2) >= 5 || (z1 == 4 && z2 >= 3)  cout << \"Second\" << endl;\n    else    cout << \"First\" << endl;\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f8e8dc9971289711e4673db968a0fc92", "src_uid": "41f6f90b7307d2383495441114fa8ea2", "difficulty": 2000.0}
    {"lang": "MS C++", "source_code": "//#define MY_DEBUG\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#pragma comment(linker, \"/STACK:64000000\")\n\nusing namespace std;\n\n#ifdef MY_DEBUG\n#include \nifstream cin(\"input.txt\");\nofstream cout(\"output.txt\");\n//ifstream cin(\"game.in\");\n//ofstream cout(\"game.out\");\n#else\n#include \n#endif\n\nconst long double eps =  1e-6;\nconst long long inf = 1000000007;\nconst long long linf = (long long)1e18;\nconst long double pi = acos(-1.0);\nconst int prime = 53;\n\ninline void finclude(){\n#ifdef MY_DEBUG\n    freopen(\"input.txt\", \"r\", stdin);\n    freopen(\"output.txt\", \"w\", stdout);\n#endif\n    srand(time(NULL));\n}\n\nlong long mx[123][123] = {}, ans[123][123] = {}, he[123][123] = {}, mod = 12345;\nint c[256] = {}, g[256] = {};\n\nvoid build(vector a, vector b, int m){\n    int d[256] = {}, x;\n    for(int i = 0; i < m; ++i){\n        x = i;\n        for(int j = 'A'; j <= 'Z'; ++j){\n            if (c[j] != 0){\n                d[j] = x % c[j];\n                x /= c[j];\n            }\n        }\n        for(int j = 'A'; j <= 'Z'; ++j){\n            if (c[j] != 0){\n                x = i;\n                x -= d[j] * g[j];\n                d[j] = (d[j] + 1) % c[j];\n                x += d[j] * g[j];\n                ++mx[x][i];\n            }\n        }\n    }\n}\n\nint main(){\n    long long n, m = 1, K;\n    cin >> n >> K;\n    vector a(K);\n    vector b(K);\n    for(int i = 0; i < K; ++i){\n        cin >> a[i] >> b[i];\n        if (c[a[i]] == 0)\n            c[a[i]] = b[i];\n        else\n            c[a[i]] *= b[i];\n        m *= b[i];\n    }\n    long long x = 1;\n    for(int i = 'A'; i <= 'Z'; ++i){\n        if (c[i] != 0){\n            g[i] = x;\n            x *= c[i];\n        }\n    }\n    build(a, b, m);\n    for(int i = 0; i < m; ++i)\n        ans[i][i] = 1;\n    while(n != 0){\n        if (n % 2 == 1){\n            --n;\n            for(int i = 0; i < m; ++i){\n                for(int j = 0; j < m; ++j){\n                    he[i][j] = 0;\n                    for(int k = 0; k < m; ++k)\n                        he[i][j] += ans[i][k] * mx[k][j];\n                }\n            }\n            for(int i = 0; i < m; ++i)\n                for(int j = 0; j < m; ++j)\n                    ans[i][j] = he[i][j] % mod;\n        }\n        n /= 2;\n        for(int i = 0; i < m; ++i){\n            for(int j = 0; j < m; ++j){\n                he[i][j] = 0;\n                for(int k = 0; k < m; ++k)\n                    he[i][j] += mx[i][k] * mx[k][j];\n            }\n        }\n        for(int i = 0; i < m; ++i)\n            for(int j = 0; j < m; ++j)\n                mx[i][j] = he[i][j] % mod;\n    }\n    long long an = 0;\n    for(int i = 0; i < m; ++i){\n        int x = i;\n        int d[256] = {};\n        bool find = false;\n        for(int j = 'A'; j <= 'Z'; ++j){\n            if (c[j] != 0){\n                d[j] = x % c[j];\n                x /= c[j];\n            }\n        }\n        for(int j = 'A'; j <= 'Z'; ++j)\n            for(int k = 0; k < K; ++k)\n                if (a[k] == j && d[j] % b[k] == 0)\n                    d[j] = 0;\n        for(int j = 'A'; j <= 'Z'; ++j)\n            if (d[j] != 0)\n                find = true;\n        if (find)\n            continue;\n        an = (an + ans[i][0]) % mod;\n    }\n    cout << an << '\\n';\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "286c271dbb6e3213e5f5d319914db49b", "src_uid": "76d4684d26dac380713a566a1e277c91", "difficulty": 2400.0}
    {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\nnamespace fio {\nstreambuf* in = cin.rdbuf();\nchar bb[1000000], *s = bb, *t = bb;\n#define gc() \\\n  (s == t && (t = (s = bb) + in->sgetn(bb, 1000000), s == t) ? EOF : *s++)\ninline long long read() {\n  long long x = 0;\n  char ch = gc();\n  while (ch < 48) ch = gc();\n  while (ch >= 48) x = x * 10 + ch - 48, ch = gc();\n  return x;\n}\n}  // namespace fio\nusing fio::read;\nlong longn;\nint m, llm;\nint lim[26];\nvector road[26];\nmap, int> huaji;\narray pm;\nclass mat {\n public:\n  int val[125][125];\n  int* operator[](int x) { return val[x]; }\n  mat operator*(mat _) {\n    mat ans;\n    for (int i = 1; i <= llm; i++)\n      for (int u = 1; u <= llm; u++) {\n        ans[i][u] = 0;\n        for (int j = 1; j <= llm; j++)\n          ans[i][u] = (ans[i][u] + val[i][j] * _[j][u]) % 12345;\n      }\n    return ans;\n  }\n};\nmat ksm(mat x, long long y) {\n  mat ans = x;\n  y--;\n  for (; y; y >>= 1, x = x * x)\n    if (y & 1) ans = ans * x;\n  return ans;\n}\nmat base;\nint ans;\nint main() {\n  n = read(), m = read();\n  if (!n) return cout << 1, 0;\n  if (!m) return cout << 0, 0;\n  for (int i = 1, x, y; i <= m; i++)\n    x = read() + '0' - 'A', road[x].emplace_back(y = read()),\n    lim[x] = max(lim[x], 1) * road[x].back();\n  while (pm[25] < max(lim[25], 1)) {\n    huaji[pm] = ++llm, pm[0]++;\n    for (int i = 0; i < 25; i++)\n      if (lim[i])\n        pm[i + 1] += pm[i] / lim[i], pm[i] %= lim[i];\n      else\n        pm[i + 1] += pm[i], pm[i] = 0;\n  }\n  for (pair, int> it : huaji)\n    for (int i = 0; i < 26; i++)\n      if (lim[i])\n        it.first[i] = (it.first[i] + 1) % lim[i],\n        base[it.second][huaji[it.first]]++,\n        it.first[i] = (it.first[i] - 1 + lim[i]) % lim[i];\n  base = ksm(base, n);\n  for (pair, int> it : huaji) {\n    bool flag = 1;\n    for (int i = 0, fx = 0; flag && i < 26; i++, flag &= fx, fx = 0)\n      if (!lim[i])\n        fx = 1;\n      else\n        for (int p : road[i]) fx |= !(it.first[i] % p);\n    flag ? ans = (ans + base[1][it.second]) % 12345 : ans;\n  }\n  cout << ans << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7903d56b59758d50641007c94ff2137d", "src_uid": "76d4684d26dac380713a566a1e277c91", "difficulty": 2400.0}
    {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n\ntypedef vector > Matrix;\ntypedef long long ll;\n \nconst int MOD = 12345;\nint add(int a, int b) { return a+b-(a+b>=MOD)*MOD; }\nint mult(int a, int b) { return (1LL*a*b)%MOD; }\n \nMatrix make(int a, int b) { return Matrix(a,vector(b)); }\nMatrix mult(Matrix a, Matrix b) {\n\tMatrix res = make(a.size(),b[0].size());\n\tfor (int i=0;i>=1;\n\t\tx = mult(x,x);\n\t}\n\treturn ans;\n}\n\nint n,m;\nset conditions[27];\nint lcm[27];\nint good[27][130];\nint D = 0;\nmap,int> mp;\nvector states[125];\n\nvoid getstates(vector v, int cur){\n\tif(cur==26){\n\t\tstates[D] = v;\n\t\tmp[v] = D;\n\t\tD++;\n\t\t//cout << v << endl;\n\t\treturn;\n\t}\n\tfor(int i=0;i> n >> m;\n\tfor(int i=0;i> c >> x;\n\t\tconditions[c-'A'].insert(x);\n\t}\n\tfor(int i=0;i<26;i++)lcm[i]=1;\n\tfor(int i=0;i<26;i++)for(auto t:conditions[i])lcm[i]*=t;\n\tfor(int i=0;i<26;i++){\n\t\tgood[i][0]=1;\n\t\tfor(auto t:conditions[i]){\n\t\t\tint cur = t;\n\t\t\tfor(int j=0;j v(26);\n\tiota(v.begin(),v.end(),0); \n\tgetstates(v, 0);\n\tMatrix A = make(D,D);\n\tfor(int i=0;i v = states[i];\n\t\tfor(int j=0;j<26;j++)if(!conditions[j].empty()){\n\t\t\tint c = lcm[j];\n\t\t\tv[j] = (v[j]+1)%c;\n\t\t\tA[i][mp[v]]++;\n\t\t\tv[j] = (v[j]-1+c)%c;\n\t\t}\n\t}\n\n\tA = modpow(A, n);\n\tint ans = 0;\n\tfor(int i=0;i v = states[i];\n\t\tbool flag = true;\n\t\tfor(int j=0;j<26;j++)if(!good[j][v[j]])flag = false;\n\t\tif(flag){\n\t\t\tans = add(ans, A[0][i]);\n\t\t}\t\n\t}\n\tcout << ans << endl;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8da74efcae7e9494fcf3dbaa7d71fd55", "src_uid": "76d4684d26dac380713a566a1e277c91", "difficulty": 2400.0}
    {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define pb push_back\ntypedef long long lint;\n#define mp make_pair\n#define fi first\n#define se second\ntypedef pair pint;\nmap > > me;\nint pro=1,mo=12345;\nint it[30];\nvector  > tmp;\nvector  > rec(lint a){\n\tif(me[a].size()) return me[a];\n\tint i,j,k;\n\tvector  > ret=tmp,mae=rec(a/2),ato=rec(a-a/2);\n\tfor(i=0;i > it2;\n\tvector  > one,ret;\n\tvector  cl;vector  cl2;\n\tfor(i=0;i<30;i++) it2.pb(cl2);\n\tfor(i=0;i<125;i++) cl.pb(0);for(j=0;j<125;j++) tmp.pb(cl);one=tmp;\n\tcin>>n>>m;\n\tif(n==0){\n\t\tcout<<\"1\"<>s>>a;it[(s[0]-'A')]+=pro;it2[(s[0]-'A')].pb(mp(pro,a));\n\t\tpro*=a;\n\t}\n\tfor(i=0;i<26;i++){\n\t\tif(it2[i].size()<1) continue;\n\t\tfor(j=0;j\nusing namespace std;\n\n//#define getchar getchar_unlocked\n//#define putchar putchar_unlocked\n#define eb emplace_back\n#define lb lower_bound\n#define ub upper_bound\n#define mp make_pair\n#define ff first\n#define ss second\n\ntypedef long long int ll;\ntypedef long double ld;\ntypedef short int sh;\n\ninline void readI(int *i)\n{\n\tregister int t=0;\n\tregister char z=getchar();\n\tint znak=1;\n\tif (z=='-')\n\t{\n\t\tznak=-1;\n\t}\n\twhile ((z<'0') || ('9'0)\n\t\t{\n\t\t\t++wsk;\n\t\t\t_tab[wsk]=(i%10)+48;\n\t\t\ti/=10;\n\t\t}\n\t\tfor (int j=wsk; j>=1; --j)\n\t\t{\n\t\t\tputchar(_tab[j]);\n\t\t}\n\t}\n}\ninline void writeL(ll l)\n{\n\tif (l==0)\n\t{\n\t\tputchar(48);\n\t}\n\telse\n\t{\n\t\tif (l<0)\n\t\t{\n\t\t   l*=-1;\n\t\t   putchar(45);\n\t\t}\n\t\tint _tab[21];\n\t\tint wsk=0;\n\t\twhile (l>0)\n\t\t{\n\t\t\t++wsk;\n\t\t\t_tab[wsk]=(l%10)+48;\n\t\t\tl/=10;\n\t\t}\n\t\tfor (int j=wsk; j>=1; --j)\n\t\t{\n\t\t\tputchar(_tab[j]);\n\t\t}\n\t}\n}\ninline void writeS(string s)\n{\n\tint l=s.length();\n\tfor (int i=0; i=1; --i)\n\t{\n\t\tL[i][j]=min(L[i<<1][j], L[(i<<1)+1][j]);\n\t\tR[i][j]=max(R[i<<1][j], R[(i<<1)+1][j]);\n\t}\n}\nint query(int x, int lvl, int pp, int pk, int zp, int zk, int op)\n{\n\tif (zk>1);\n\tif (op==0)\n\t{\n\t\treturn min(query(x<<1, lvl, pp, sr, zp, zk, op), query((x<<1)+1, lvl, sr+1, pk, zp, zk, op));\n\t}\n\telse\n\t{\n\t\treturn max(query(x<<1, lvl, pp, sr, zp, zk, op), query((x<<1)+1, lvl, sr+1, pk, zp, zk, op));\n\t}\n}\nint main()\n{\n\treadI(&n);\n\tif (n==1)\n\t{\n\t\tprintf (\"0 \");\n\t\treturn 0;\n\t}\n\tr=1;\n\twhile (r<3*n)\n\t{\n\t\tr<<=1;\n\t\t++llog;\n\t}\n\tfor (int j=0; j<=llog; ++j)\n\t{\n\t\tfor (int i=1; i<=r; ++i)\n\t\t{\n\t\t\tL[i][j]=INF;\n\t\t}\n\t}\n\tfor (int i=1; i<=n; ++i)\n\t{\n\t\treadI(&tab[i]);\n\t\ttab[i+n]=tab[i+(n<<1)]=tab[i];\n\t\tR[i+r-1][0]=min(3*n, i+tab[i]);\n\t\tR[i+n+r-1][0]=min(3*n, i+n+tab[i]);\n\t\tR[i+(n<<1)+r-1][0]=min(3*n, i+(n<<1)+tab[i]);\n\t\tL[i+r-1][0]=max(1, i-tab[i]);\n\t\tL[i+n+r-1][0]=max(1, i+n-tab[i]);\n\t\tL[i+(n<<1)+r-1][0]=max(1, i+(n<<1)-tab[i]);\n\t}\n\tustaw(0);\n\tfor (int j=1; j<=llog; ++j)\n\t{\n\t\tfor (int i=1; i<=3*n; ++i)\n\t\t{\n\t\t\tint gg=query(1, j-1, 1, r, L[i+r-1][j-1], R[i+r-1][j-1], 0);\n\t\t\tgg=max(gg, 1);\n\t\t\tL[i+r-1][j]=gg;\n\t\t\tgg=query(1, j-1, 1, r, L[i+r-1][j-1], R[i+r-1][j-1], 1);\n\t\t\tgg=min(gg, 3*n);\n\t\t\tR[i+r-1][j]=gg;\n\t\t}\n\t\tustaw(j);\n\t}\n\tdebug\n\t{\n\t\ttest_LR();\n\t}\n\tfor (int i=n+1; i<=(n<<1); ++i)\n\t{\n\t\tdebug\n\t\t{\n\t\t\tendl();\n\t\t\tendl();\n\t\t}\n\t\tint czas=0;\n\t\tint lewy, prawy;\n\t\tlewy=prawy=i;\n\t\tfor (int j=llog; j>=0; --j)\n\t\t{\n\t\t\tdebug\n\t\t\t{\n\t\t\t\tprintf (\"i=%d j=%d czas=%d lewy=%d prawy=%d L[lewy+r-1][j]=%d R[prawy+r-1][j]=%d\\n\", i, j, czas, lewy, prawy, L[lewy+r-1][j], R[prawy+r-1][j]);\n\t\t\t}\n\t\t\tint ll=query(1, j, 1, r, lewy, prawy, 0);\n\t\t\tint pp=query(1, j, 1, r, lewy, prawy, 1);\n\t\t\tif (pp-ll+1\n\nusing namespace std;\nconst int N = 4e5 + 10;\n\n\nint n , a[N];\n\n\nstruct Node {\n\tint L , R;\n} tr[20][N << 1];\n\nNode jp[N][20];\n\nNode merge(Node a,Node b) {\n\tif (a.R < b.R) a.R = b.R;\n\tif (a.L > b.L) a.L = b.L;\n\treturn a;\n}\n\n\nvoid up(int o,int typ) {\n\ttr[typ][o] = merge(tr[typ][o << 1] , tr[typ][o << 1 | 1]);\n}\n\n\nvoid build(int o,int l,int r,int typ) {\n\tif (l == r) {\n\t\n\t\ttr[typ][o].L = jp[l][typ].L;\n\t\ttr[typ][o].R = jp[l][typ].R;\n\t\treturn;\n\t}\n\tint mid = l + r >> 1;\n\tbuild(o << 1 , l , mid , typ);\n\tbuild(o << 1 | 1 , mid + 1 , r , typ);\n\tup(o , typ);\n}\n\n\nNode query(int o,int l,int r,int ql,int qr,int typ) {\n\t\n//\tprintf(\"%d %d %d %d\\n\",l,r,ql,qr);\n\tif (ql <= l && r <= qr) {\n\t\treturn tr[typ][o];\n\t}\n\tint mid = l + r >> 1;\n\tif (ql <= mid && mid < qr) {\n\t\treturn merge( query(o << 1 , l , mid , ql , qr , typ) , query(o << 1 | 1 , mid + 1 , r , ql , qr , typ) );\n\t} else {\n\t\tif (ql <= mid) return query(o << 1 , l , mid , ql , qr , typ);\n\t\telse \t\t   return query(o << 1 | 1 , mid + 1 , r , ql , qr , typ);\n\t}\n}\n\n\nvoid init() {\n\t\n\t\n\tfor (int i = 1;i <= n * 3;i++){\n\t\tjp[i][0].L = max(1 , i - a[i]);\n\t\tjp[i][0].R = min(n * 3 , i + a[i]);\t\t\t\n\t}\n\t\n\tbuild(1 , 1 , n * 3 , 0);\n\t\n\tfor (int j = 1; j < 20;j++){\n\t\t\n\t\tfor (int i = 1; i <= n * 3; i++) {\n\t\t\tjp[i][j] = query(1 , 1 , n * 3 , jp[i][j - 1].L , jp[i][j - 1].R , j - 1);\n\t\t}\n\t\tbuild(1 , 1 , n * 3 , j);\n\t}\n\t\n\t\n\t\n}\n\n\nbool check(int pos,int time) {\n\t\n\tNode ans = (Node){pos , pos};\n\t\n\tfor (int Lg = 0;Lg < 20;Lg++){\n\t\tif (time & (1 << Lg) ){\n\t\t\tans = query(1 , 1 , n * 3 , ans.L , ans.R , Lg);\n\t\t}\n\t}\n\t\n\treturn ans.R - ans.L >= n;\n}\n\n\n\n\nint main() {\n\tcin >> n;\n\n\tfor (int i = 1; i <= n; i++) scanf(\"%d\",&a[i]) , a[ 2 * n + i ] = a[n+i] = a[i];\n\n\n\tinit();\n\n\n\n\tfor (int i = 1;i <= n;i++){\n\t\tint L = 1 , R = n , ans = n;\n\t\t\n\t\twhile (L <= R){\n\t\t\tint mid = L + R >> 1;\n\t\t\tif (check(i + n , mid)){\n\t\t\t\tans = mid;\n\t\t\t\tR = mid - 1;\n\t\t\t}else{\n\t\t\t\tL = mid + 1;\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tprintf(\"%d \",ans);\n\t}\n\n\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d6d4de4232bb2bb1a80f29cd910721ec", "src_uid": "e7dd44bf5e0a0345fd1c40e6957d5641", "difficulty": 2900.0}
    {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\nconst int N = 3e5 + 10;\n\n\nint n , a[N];\n\n\nstruct Node {\n\tint L , R;\n} tr[19][N << 1];\n\nNode jp[N][19];\n\nNode merge(Node a,Node b) {\n\tif (a.R < b.R) a.R = b.R;\n\tif (a.L > b.L) a.L = b.L;\n\treturn a;\n}\n\n\nvoid up(int o,int typ) {\n\ttr[typ][o] = merge(tr[typ][o << 1] , tr[typ][o << 1 | 1]);\n}\n\n\nvoid build(int o,int l,int r,int typ) {\n\tif (l == r) {\n\t\n\t\ttr[typ][o].L = jp[l][typ].L;\n\t\ttr[typ][o].R = jp[l][typ].R;\n\t\treturn;\n\t}\n\tint mid = l + r >> 1;\n\tbuild(o << 1 , l , mid , typ);\n\tbuild(o << 1 | 1 , mid + 1 , r , typ);\n\tup(o , typ);\n}\n\n\nNode query(int o,int l,int r,int ql,int qr,int typ) {\n\t\n//\tprintf(\"%d %d %d %d\\n\",l,r,ql,qr);\n\tif (ql <= l && r <= qr) {\n\t\treturn tr[typ][o];\n\t}\n\tint mid = l + r >> 1;\n\tif (ql <= mid && mid < qr) {\n\t\treturn merge( query(o << 1 , l , mid , ql , qr , typ) , query(o << 1 | 1 , mid + 1 , r , ql , qr , typ) );\n\t} else {\n\t\tif (ql <= mid) return query(o << 1 , l , mid , ql , qr , typ);\n\t\telse \t\t   return query(o << 1 | 1 , mid + 1 , r , ql , qr , typ);\n\t}\n}\n\n\nvoid init() {\n\t\n\t\n\tfor (int i = 1;i <= n * 3;i++){\n\t\tjp[i][0].L = max(1 , i - a[i]);\n\t\tjp[i][0].R = min(n * 3 , i + a[i]);\t\t\t\n\t}\n\t\n\tbuild(1 , 1 , n * 3 , 0);\n\t\n\tfor (int j = 1; j < 19;j++){\n\t\t\n\t\tfor (int i = 1; i <= n * 3; i++) {\n\t\t\tjp[i][j] = query(1 , 1 , n * 3 , jp[i][j - 1].L , jp[i][j - 1].R , j - 1);\n\t\t}\n\t\tbuild(1 , 1 , n * 3 , j);\n\t}\n\t\n\t\n\t\n}\n\n\nbool check(int pos,int time) {\n\t\n\tNode ans = (Node){pos , pos};\n\t\n\tfor (int Lg = 0;Lg < 19;Lg++){\n\t\tif (time & (1 << Lg) ){\n\t\t\tans = query(1 , 1 , n * 3 , ans.L , ans.R , Lg);\n\t\t}\n\t}\n\t\n\treturn ans.R - ans.L >= n;\n}\n\n\n\n\nint main() {\n\tcin >> n;\n\n\tfor (int i = 1; i <= n; i++) scanf(\"%d\",&a[i]) , a[n+i] = a[i] , a[ 2 * n + i ] = a[i];\n\n\n\tinit();\n\n\n\n\tfor (int i = 1;i <= n;i++){\n\t\tint L = 1 , R = n , ans = n;\n\t\t\n\t\twhile (L <= R){\n\t\t\tint mid = L + R >> 1;\n\t\t\tif (check(i + n , mid)){\n\t\t\t\tans = mid;\n\t\t\t\tR = mid - 1;\n\t\t\t}else{\n\t\t\t\tL = mid + 1;\n\t\t\t}\n\t\t}\n\t\t\n\t\t\n\t\tprintf(\"%d \",ans);\n\t}\n\n\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7f385032448ac658ff638a9c318bc362", "src_uid": "e7dd44bf5e0a0345fd1c40e6957d5641", "difficulty": 2900.0}
    {"lang": "GNU C++11", "source_code": "    #include\n    #define rep(i,a,n) for(int i=a;i<=n;i++)\n    #define per(i,a,n) for(int i=n;i>=a;i--)\n    #define pb push_back\n    #define mp make_pair\n    #define fi first\n    #define se second\n    #define maxn 100000\n    #define mod 1000000007\n    using namespace std;\n    typedef long long ll;\n    typedef pair pii;\n    typedef vector vi;\n     \n    int n;\n    int a[maxn+5];\n    int lg[maxn+5];\n    pii st[18][18][maxn+5];\n     \n    pii Merge(pii a,pii b,int l)\n    {\n        return mp(max(a.fi,b.fi-l),max(a.se,b.se+l));\n    }\n     \n    pii ask(int s,int l,int r,int x)\n    {\n        int k=lg[x];\n        r=(r-(1<>1]+1;\n     \n        scanf(\"%d\",&n);\n        rep(i,0,n-1) scanf(\"%d\",&a[i]);\n        if(n==1)\n        {\n            printf(\"0\\n\");\n            return 0;\n        }\n        rep(i,0,n-1) st[0][0][i]=mp(a[i],a[i]);\n        rep(i,1,16) rep(j,0,n-1)\n            st[0][i][j]=Merge(st[0][i-1][j],st[0][i-1][(j+(1<=n) st[s][i][j]=st[s-1][i][j];\n                else\n                {\n                    int l=(j-st[s-1][i][j].fi+n)%n,r=(j+st[s-1][i][j].se)%n,x=st[s-1][i][j].fi+st[s-1][i][j].se+1;\n                    st[s][i][j]=ask(s-1,l,r,x);\n                    st[s][i][j].fi+=st[s-1][i][j].fi;\n                    st[s][i][j].se-=st[s-1][i][j].fi;\n                }\n            }\n        }\n        rep(i,0,n-1)\n        {\n            pii now(0,0);\n            int ans=0;\n            per(s,0,16)\n            {\n                int l=(i-now.fi+n)%n,r=(i+now.se)%n,x=now.fi+now.se+1;\n                pii res=ask(s,l,r,x);\n                if(res.fi+res.se+1\nusing namespace std;\n#define int long long\n\nstruct pos {\n    int x, y, z, dx, dy, dz, color;\n};\n\nsigned main(){\n    ios_base::sync_with_stdio(false);\n    cin.tie(NULL); cout.tie(NULL);\n\n    int n, m, k;\n    cin >> n >> m >> k;\n\n    vector>> result(n, vector>(m, vector(k, -1)));\n\n    queue todo;\n    map, vector> done;\n\n    for(int i = 0; i < m; i++) for(int j = 0; j < k; j++) {int x; cin >> x; todo.push({0, i, j, 1, 0, 0, x}); }\n    for(int i = 0; i < m; i++) for(int j = 0; j < k; j++) {int x; cin >> x; todo.push({n - 1, i, j, -1, 0, 0, x});}\n    for(int i = 0; i < n; i++) for(int j = 0; j < k; j++) {int x; cin >> x; todo.push({i, 0, j, 0, 1, 0, x}); }\n    for(int i = 0; i < n; i++) for(int j = 0; j < k; j++) {int x; cin >> x; todo.push({i, m - 1, j, 0, -1, 0, x});}\n    for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) {int x; cin >> x; todo.push({i, j, 0, 0, 0, 1, x}); }\n    for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) {int x; cin >> x; todo.push({i, j, k - 1, 0, 0, -1, x});}\n\n    while(!todo.empty()){\n        pos p = todo.front();\n        todo.pop();\n\n        if(done.find({p.x, p.y, p.z}) == done.end()) done[{p.x, p.y, p.z}] = vector();\n        done[{p.x, p.y, p.z}].push_back(p);\n\n        if(p.color == 0 || (result[p.x][p.y][p.z] != -1 && result[p.x][p.y][p.z] != p.color)){\n            result[p.x][p.y][p.z] = 0;\n\n            for(pos pp : done[{p.x, p.y, p.z}]){\n                if(pp.x + pp.dx < 0 || pp.x + pp.dx >= n || pp.y + pp.dy < 0 || pp.y + pp.dy >= m || pp.z + pp.dz < 0 || pp.z + pp.dz >= k){\n                    if(pp.color != 0){\n                        cout << -1 << endl;\n                        return 0;\n                    }\n                } else {\n                    todo.push({pp.x + pp.dx, pp.y + pp.dy, pp.z + pp.dz, pp.dx, pp.dy, pp.dz, pp.color});\n                }\n            }\n\n            done[{p.x, p.y, p.z}].clear();\n        } else if(result[p.x][p.y][p.z] == -1){\n            result[p.x][p.y][p.z] = p.color;\n        }\n    }\n\n    for(int a = 0; a < n; a++) {\n        for(int b = 0; b < m; b++) {\n            for(int c = 0; c < k; c++) {\n                cout << max(0LL, result[a][b][c]) << \" \";\n            } \n            cout << endl;\n        }\n        cout << endl;\n    }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "61bb5654dfd1965b56e953fafd9c61d6", "src_uid": "cdacfb8b1ca4c88b576fa7b3cf71f8ec", "difficulty": 3500.0}
    {"lang": "GNU C++17", "source_code": "// iostream is too mainstream\n#include \n// bitch please\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define dibs reserve\n#define OVER9000 1234567890\n#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)\n#define tisic 47\n#define soclose 1e-8\n#define chocolate win\n// so much chocolate\n#define patkan 9\n#define ff first\n#define ss second\n#define abs(x) (((x) < 0)?-(x):(x))\n#define uint unsigned int\n#define dbl long double\n#define pi 3.14159265358979323846\nusing namespace std;\n// mylittledoge\n\nusing cat = long long;\n\n#ifdef DONLINE_JUDGE\n\t// palindromic tree is better than splay tree!\n\t#define lld I64d\n#endif\n\ntemplate \nstruct vec3 {\n\tint N[3];\n\tvector data;\n\n\tvec3() = default;\n\tvec3(int N0, int N1, int N2, T val = 0) : N{N0, N1, N2} {\n\t\tdata.resize(N0*N1*N2, val);\n\t}\n\n\tT & operator()(int i0, int i1, int i2) {\n\t\treturn data[(i0*N[1]+i1)*N[2]+i2];\n\t}\n};\n\ntemplate \nstruct vec2 {\n\tint N[2];\n\tvector data;\n\n\tvec2() = default;\n\tvec2(int N0, int N1, T val = 0) : N{N0, N1} {\n\t\tdata.resize(N0*N1, val);\n\t}\n\n\tT & operator()(int i0, int i1) {\n\t\treturn data[i0*N[1]+i1];\n\t}\n};\n\nint main() {\n\tcin.sync_with_stdio(0);\n\tcin.tie(0);\n\tcout << fixed << setprecision(10);\n\tint N[3];\n\tfor(int i = 0; i < 3; i++) cin >> N[i];\n\tvec2 A[3][2];\n\tint dim[3][2];\n\tfor(int k = 0; k < 3; k++) for(int l = 0; l < 2; l++) {\n\t\tdim[k][0] = k ? 0 : 1;\n\t\tdim[k][1] = 3-k-dim[k][0];\n\t\tA[k][l] = vec2(N[dim[k][0]], N[dim[k][1]]);\n\t\tfor(int i = 0; i < N[dim[k][0]]; i++)\n\t\t\tfor(int j = 0; j < N[dim[k][1]]; j++)\n\t\t\t\tcin >> A[k][l][i,j];\n\t}\n\tvec3 ans(N[0], N[1], N[2], -1);\n\tfor(int k = 0; k < 3; k++)\n\t\tfor(int i = 0; i < N[dim[k][0]]; i++)\n\t\t\tfor(int j = 0; j < N[dim[k][1]]; j++)\n\t\t\t\tif(!A[k][0](i,j) || !A[k][1](i,j)) {\n\t\t\t\t\tif(A[k][0](i,j) || A[k][1](i,j)) {\n\t\t\t\t\t\tcout << \"-1\\n\";\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\tint idx[3];\n\t\t\t\t\tidx[dim[k][0]] = i;\n\t\t\t\t\tidx[dim[k][1]] = j;\n\t\t\t\t\tfor(idx[k] = 0; idx[k] < N[k]; idx[k]++) ans(idx[0],idx[1],idx[2]) = 0;\n\t\t\t\t}\n\tvec3 border[8];\n\tfor(int c = 0; c < 8; c++) border[c] = vec3(N[0], N[1], N[2], 0);\n\tvec3 cur[8];\n\tfor(int c = 0; c < 8; c++) cur[c] = vec3(N[0], N[1], N[2], -1);\n\tvec2 B[8][3];\n\tfor(int c = 0; c < 8; c++)\n\t\tfor(int k = 0; k < 3; k++) {\n\t\t\tint x = (c>>k)&1;\n\t\t\tB[c][k] = vec2(N[dim[k][0]], N[dim[k][1]], 0);\n\t\t\tfor(int i = 0; i < N[dim[k][0]]; i++)\n\t\t\t\tfor(int j = 0; j < N[dim[k][1]]; j++) {\n\t\t\t\t\tint i_r = i, j_r = j;\n\t\t\t\t\tif((c>>dim[k][0])&1) i_r = N[dim[k][0]]-1-i;\n\t\t\t\t\tif((c>>dim[k][1])&1) j_r = N[dim[k][1]]-1-j;\n\t\t\t\t\tB[c][k](i_r,j_r) = A[k][x](i,j);\n\t\t\t\t}\n\t\t}\n\tfor(int r = 0; r < 2; r++) for(int c = 0; c < 8; c++) {\n\t\tfor(int i = 0; i < N[0]; i++)\n\t\t\tfor(int j = 0; j < N[1]; j++)\n\t\t\t\tfor(int k = 0; k < N[2]; k++) {\n\t\t\t\t\tif(i == 0) border[c](i,j,k) |= 1;\n\t\t\t\t\tif(j == 0) border[c](i,j,k) |= 2;\n\t\t\t\t\tif(k == 0) border[c](i,j,k) |= 4;\n\t\t\t\t\tint i_r = i, j_r = j, k_r = k;\n\t\t\t\t\tif(c&1) i_r = N[0]-1-i;\n\t\t\t\t\tif(c&2) j_r = N[1]-1-j;\n\t\t\t\t\tif(c&4) k_r = N[2]-1-k;\n\t\t\t\t\tif(ans(i,j,k) == 0) cur[c](i_r,j_r,k_r) = 0;\n\t\t\t\t}\n\t\tfor(int i = 0; i < N[0]; i++)\n\t\t\tfor(int j = 0; j < N[1]; j++)\n\t\t\t\tfor(int k = 0; k < N[2]; k++) {\n\t\t\t\t\tif(!border[c](i,j,k)) continue;\n\t\t\t\t\tint idx[3] = {i, j, k};\n\t\t\t\t\tif(cur[c](i,j,k) == -1) for(int l = 0; l < 3; l++) if((border[c](i,j,k)>>l)&1) {\n\t\t\t\t\t\tif(cur[c](i,j,k) == -1) cur[c](i,j,k) = B[c][l](idx[dim[l][0]],idx[dim[l][1]]);\n\t\t\t\t\t\telse if(cur[c](i,j,k) != B[c][l](idx[dim[l][0]],idx[dim[l][1]])) cur[c](i,j,k) = 0;\n\t\t\t\t\t}\n\t\t\t\t\tint b = border[c](i,j,k);\n\t\t\t\t\tif(cur[c](i,j,k) == 0) {\n\t\t\t\t\t\tfor(int l = 0; l < 3; l++) {\n\t\t\t\t\t\t\tidx[l]++;\n\t\t\t\t\t\t\tif(idx[l] != N[l]) border[c](idx[0],idx[1],idx[2]) |= b & (1<= 0 && !ans(idx[0],idx[1],idx[2])) idx[k]--;\n\t\t\t\t\tif(idx[k] == -1 || ans(idx[0],idx[1],idx[2]) != A[k][1](i,j)) {\n\t\t\t\t\t\tcout << \"-1\\n\";\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\tfor(int i = 0; i < N[0]; i++)\n\t\tfor(int j = 0; j < N[1]; j++)\n\t\t\tfor(int k = 0; k < N[2]; k++)\n\t\t\t\tif(ans(i,j,k) == -1) ans(i,j,k) = 0;\n\tfor(int i = 0; i < N[0]; i++) {\n\t\tif(i) cout << \"\\n\";\n\t\tfor(int j = 0; j < N[1]; j++) for(int k = 0; k < N[2]; k++)\n\t\t\tcout << ans(i,j,k) << ((k == N[2]-1) ? \"\\n\" : \" \");\n\t}\n\treturn 0;\n}\n\n// look at my code\n// my code is amazing\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fc4139ec8e7fe392a5899ac702eb3220", "src_uid": "cdacfb8b1ca4c88b576fa7b3cf71f8ec", "difficulty": 3500.0}
    {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\nusing ll = long long;\nusing ull = unsigned long long;\nusing ld = long double;\n#define all(x) x.begin(), x.end()\n#define left left228\n#define right right228\ntemplate  inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}\ntemplate  inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}\n\nstruct triple{\n\tint x, y, z;\n\ttriple() {}\n\ttriple(int _x, int _y, int _z) {\n\t\tx = _x, y = _y, z = _z;\n\t}\n};\n\nint n, m, k;\n\nvector> up, down, left, right, top, bottom;\n\nvoid Read(vector> & have, int a, int b) {\n\thave.resize(a, vector (b));\n\tfor (auto &i : have)\n\t\tfor (auto &j : i)\n\t\t\tcin >> j;\n}\n\nvoid read() {\n\tcin >> n >> m >> k;\n\tRead(left, m, k);\n\tRead(right, m, k);\n\tRead(top, n, k);\n\tRead(bottom, n, k);\n\tRead(down, n, m);\n\tRead(up, n, m);\n}\n\nbool operator==(const triple & a, const triple & b) {\n\treturn tie(a.x, a.y, a.z) == tie(b.x, b.y, b.z);\n}\n\nvector>> par[3];\nvector>> Min[3], Max[3];\n\ntriple get_par(triple a, int it) {\n\tif (a == par[it][a.x][a.y][a.z]) return a;\n\treturn par[it][a.x][a.y][a.z] = get_par(par[it][a.x][a.y][a.z], it);\n}\n\nvoid uni(triple a, triple b, int it) {\n\ta = get_par(a, it);\n\tb = get_par(b, it);\n\tif (a == b) return;\n\tpar[it][b.x][b.y][b.z] = a;\n\tchkmin(Min[it][a.x][a.y][a.z], Min[it][b.x][b.y][b.z]);\n\tchkmax(Max[it][a.x][a.y][a.z], Max[it][b.x][b.y][b.z]);\n}\n\nvoid no() {\n\tcout << -1 << endl;\n\texit(0);\n}\n\nvector>> used;\nqueue q;\n\nint get_color(int x, int y, int z) {\n\tset color;\n\ttriple a;\n\t\n\t// get_left\n\tif (x != 0) {\n\t\ta = {x - 1, y, z};\n\t\ta = get_par(a, 0);\n\t}\n\tif (x == 0 || (Min[0][a.x][a.y][a.z] == 0 && used[x - 1][y][z])) {\n\t\tcolor.insert(left[y][z]);\n\t}\n\n\t// get_right\n\tif (x != n - 1) {\n\t\ta = {x + 1, y, z};\n\t\ta = get_par(a, 0);\n\t}\n\tif (x == n - 1 || (Max[0][a.x][a.y][a.z] == n - 1 && used[x + 1][y][z])) {\n\t\tcolor.insert(right[y][z]);\n\t} \n\n\t// get top\n\tif (y != 0) {\n\t\ta = {x, y - 1, z};\n\t\ta = get_par(a, 1);\n\t}\n\tif (y == 0 || (Min[1][a.x][a.y][a.z] == 0 && used[x][y - 1][z])) {\n\t\tcolor.insert(top[x][z]);\n\t}\n\n\t// get bottom\n\tif (y != m - 1) {\n\t\ta = {x, y + 1, z};\n\t\ta = get_par(a, 1);\n\t}\n\tif (y == m - 1 || (Max[1][a.x][a.y][a.z] == m - 1 && used[x][y + 1][z])) {\n\t\tcolor.insert(bottom[x][z]);\n\t}\n\n\t// get down\n\tif (z != 0) {\n\t\ta = {x, y, z - 1};\n\t\ta = get_par(a, 2);\n\t}\n\tif (z == 0 || (Min[2][a.x][a.y][a.z] == 0 && used[x][y][z - 1])) {\n\t\tcolor.insert(down[x][y]);\n\t}\n\t\n\t// get up\n\tif (z != k - 1) {\n\t\ta = {x, y, z + 1};\n\t\ta = get_par(a, 2);\n\t}\t\n\tif (z == k - 1 || (Max[2][a.x][a.y][a.z] == k - 1 && used[x][y][z + 1])) {\n\t\tcolor.insert(up[x][y]);\n\t}\n\n\tif (color.empty()) return -1;\n\tif (color.size() >= 2) return 0;\n\treturn *color.begin();\n}\n\nvoid build() {\n\tused.assign(n, vector> (m, vector (k, false)));\n\tfor (int i = 0; i < 3; i++) {\n\t\tpar[i].resize(n, vector> (m, vector (k)));\n\t\tMin[i].resize(n, vector> (m, vector (k)));\n\t\tMax[i].resize(n, vector> (m, vector (k)));\n\t}\n\tfor (int x = 0; x < n; x++) {\n\t\tfor (int y = 0; y < m; y++) {\n\t\t\tfor (int z = 0; z < k; z++) {\n\t\t\t\tfor (int it = 0; it < 3; it++) {\n\t\t\t\t\tpar[it][x][y][z] = {x, y, z};\n\t\t\t\t}\n\t\t\t\tMin[0][x][y][z] = x;\n\t\t\t\tMax[0][x][y][z] = x;\n\t\t\t\tMin[1][x][y][z] = y;\n\t\t\t\tMax[1][x][y][z] = y;\n\t\t\t\tMin[2][x][y][z] = z;\n\t\t\t\tMax[2][x][y][z] = z;\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (int x = 0; x < n; x++) {\n\t\tfor (int y = 0; y < m; y++) {\n\t\t\tfor (int z = 0; z < k; z++) {\n\t\t\t\tif (!get_color(x, y, z)) {\n\t\t\t\t\tq.push({x, y, z});\n\t\t\t\t\tused[x][y][z] = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nvector dx = {-1, 1, 0, 0, 0, 0}; \nvector dy = {0, 0, -1, 1, 0, 0}; \nvector dz = {0, 0, 0, 0, -1, 1};\n\nbool check(int x, int y, int z) {\n\treturn x >= 0 && x < n && y >= 0 && y < m && z >= 0 && z < k;\n}\n\nvoid del(int x, int y, int z) {\n\tfor (int i = 0; i < 6; i++) {\n\t\tint nx = x + dx[i], ny = y + dy[i], nz = z + dz[i];\t\n\t\tif (!check(nx, ny, nz)) continue;\n\t\tif (!used[nx][ny][nz]) continue;\n\t\tuni({x, y, z}, {nx, ny, nz}, i / 2);\n\t}\n}\n\nvoid bfs() {\n\twhile (!q.empty()) {\n\t\tauto v = q.front();\n\t\tint x = v.x, y = v.y, z = v.z;\n\t\tq.pop();\n\t\tdel(x, y, z);\n\t\tfor (int i = 0; i < 6; i++) {\n\t\t\tint nx = x + dx[i], ny = y + dy[i], nz = z + dz[i];\n\t\t\tif (!check(nx, ny, nz)) continue;\n\t\t\tif (get_color(nx, ny, nz)) continue;\n\t\t\t\n\t\t\tif (used[nx][ny][nz]) {\n\t\t\t\tauto a = triple(nx, ny, nz);\n\t\t\t\ta = get_par(a, i / 2);\n\t\t\t\tint & fupd;\n\t\t\t\tif (i / 2 == 0) fupd = nx;\n\t\t\t\telse if (i / 2 == 1) fupd = ny;\n\t\t\t\telse fupd = nz;\n\t\t\t\tif (i % 2 == 0) {\n\t\t\t\t\tfupd = Min[i / 2][a.x][a.y][a.z] - 1;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tfupd = Max[i / 2][a.x][a.y][a.z] + 1;\n\t\t\t\t}\n\t\t\t\tif (!check(nx, ny, nz)) continue;\n\t\t\t\tif (get_color(nx, ny, nz)) continue;\n\t\t\t}\n\t\t\tif (used[nx][ny][nz]) continue;\n\t\t\tused[nx][ny][nz] = true;\n\t\t\tq.push({nx, ny, nz});\n\t\t}\n\t}\n}\n\nvoid check_ans() {\n\tfor (int y = 0; y < m; y++) {\n\t\tfor (int z = 0; z < k; z++) {\n\t\t\tbool flag = false;\n\t\t\tfor (int x = 0; x < n; x++) {\n\t\t\t\tif (!used[x][y][z]) {\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!flag) {\n\t\t\t\tif (left[y][z] || right[y][z]) {\n\t\t\t\t\tno();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor (int x = 0; x < n; x++) {\n\t\tfor (int z = 0; z < k; z++) {\n\t\t\tbool flag = false;\n\t\t\tfor (int y = 0; y < m; y++) {\n\t\t\t\tif (!used[x][y][z]) {\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!flag) {\n\t\t\t\tif (top[x][z] || bottom[x][z]) {\n\t\t\t\t\tno();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor (int x = 0; x < n; x++) {\n\t\tfor (int y = 0; y < m; y++) {\n\t\t\tbool flag = false;\n\t\t\tfor (int z = 0; z < k; z++) {\n\t\t\t\tif (!used[x][y][z]) {\n\t\t\t\t\tflag = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!flag) {\n\t\t\t\tif (up[x][y] || down[x][y]) {\n\t\t\t\t\tno();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid run() {\n\tbuild();\n\tbfs();\n\tcheck_ans();\n}\n\nvoid write() {\n\tfor (int x = 0; x < n; x++) {\n\t\tfor (int y = 0; y < m; y++) {\n\t\t\tfor (int z = 0; z < k; z++) {\n\t\t\t\tint ans = get_color(x, y, z);\n\t\t\t\tif (ans == -1) ans = 0;\n\t\t\t\tif (used[x][y][z]) ans = 0;\n\t\t\t\tcout << ans << \" \";\n\t\t\t}\n\t\t}\n\t}\n\tcout << endl;\n}\n\nsigned main() {\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n\tcout.tie(0);\n\tread();\n\trun();\n\twrite();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "09833a9ff9f5294b49a2be3a19b0a2b9", "src_uid": "cdacfb8b1ca4c88b576fa7b3cf71f8ec", "difficulty": 3500.0}
    {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n#define int long long\n\nstruct pos {\n    int dx, dy, dz, color;\n};\n\nstruct xyz {\n    int x, y, z;\n};\n\nsigned main(){\n    ios_base::sync_with_stdio(false);\n    cin.tie(NULL); cout.tie(NULL);\n\n    int n, m, k;\n    cin >> n >> m >> k;\n\n    vector>> result(n, vector>(m, vector(k, -1)));\n    vector>>> rays(n, vector>>(m, vector>(k)));\n\n    for(int i = 0; i < m; i++) for(int j = 0; j < k; j++) {int x; cin >> x; rays[0][i][j]     .push_back({1, 0, 0, x}); }\n    for(int i = 0; i < m; i++) for(int j = 0; j < k; j++) {int x; cin >> x; rays[n - 1][i][j] .push_back({-1, 0, 0, x});}\n    for(int i = 0; i < n; i++) for(int j = 0; j < k; j++) {int x; cin >> x; rays[i][0][j]     .push_back({0, 1, 0, x}); }\n    for(int i = 0; i < n; i++) for(int j = 0; j < k; j++) {int x; cin >> x; rays[i][m - 1][j] .push_back({0, -1, 0, x});}\n    for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) {int x; cin >> x; rays[i][j][0]     .push_back({0, 0, 1, x}); }\n    for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) {int x; cin >> x; rays[i][j][k - 1] .push_back({0, 0, -1, x});}\n\n    queue todo;\n\n    for(int i = 0; i < m; i++) for(int j = 0; j < k; j++) todo.push({0, i, j    });\n    for(int i = 0; i < m; i++) for(int j = 0; j < k; j++) todo.push({n - 1, i, j});\n    for(int i = 0; i < n; i++) for(int j = 0; j < k; j++) todo.push({i, 0, j    });\n    for(int i = 0; i < n; i++) for(int j = 0; j < k; j++) todo.push({i, m - 1, j});\n    for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) todo.push({i, j, 0    });\n    for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) todo.push({i, j, k - 1});\n\n    while(!todo.empty()){\n        xyz t = todo.front();\n        todo.pop();\n\n        for(pos p : rays[t.x][t.y][t.z]){\n            if((result[t.x][t.y][t.z] != 0 && p.color == 0) || (result[t.x][t.y][t.z] != -1 && result[t.x][t.y][t.z] != p.color)){\n                result[t.x][t.y][t.z] = 0;\n\n                if(t.x + p.dx < 0 || t.x + p.dx >= n || t.y + p.dy < 0 || t.y + p.dy >= m || t.z + p.dz < 0 || t.z + p.dz >= k){\n                    if(p.color != 0){\n                        cout << -1 << endl;\n                        return 0;\n                    }\n                } else {\n                    rays[t.x + p.dx][t.y + p.dy][t.z + p.dz].push_back(p);\n                    todo.push({t.x + p.dx, t.y + p.dy, t.z + p.dz});\n                }\n            } else if(result[t.x][t.y][t.z] == -1){\n                result[t.x][t.y][t.z] = p.color;\n            }\n        }\n    }\n\n    for(int a = 0; a < n; a++) {\n        for(int b = 0; b < m; b++) {\n            for(int c = 0; c < k; c++) {\n                cout << max(0LL, result[a][b][c]) << \" \";\n            } \n            cout << endl;\n        }\n        cout << endl;\n    }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3b55a81a494f076f40deba67fa74a3d8", "src_uid": "cdacfb8b1ca4c88b576fa7b3cf71f8ec", "difficulty": 3500.0}
    {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#pragma comment(linker, \"/STACK:1000000000\")\n#define forn(i, p, n) for(int i = p; i < n; ++i)\nusing namespace std;\ntypedef long long LL;\ntypedef double D;\n\nconst D eps = 1e-10;\nconst int N = 1e5;\n\nD abs(D x)\n{\n\tif (x < 0)\n\t\treturn -x;\n\treturn x;\n}\n\nclass t\n{\npublic:\n\tD l, r;\n\tint id;\n};\n\nvector arr;\n\nstruct ft\n{\n\tLL S[N];\n\tft()\n\t{\n\t\tmemset(S, 0, sizeof(S));\n\t}\n\tLL sum(int r)\n\t{\n\t\tLL res = 0;\n\t\twhile (r != -1)\n\t\t{\n\t\t\tres += S[r];\n\t\t\tr = (r & (r + 1)) - 1;\n\t\t}\n\t\treturn res;\n\t}\n\tvoid add(int p)\n\t{\n\t\twhile (p < N)\n\t\t{\n\t\t\tS[p]++;\n\t\t\tp = p | (p + 1);\n\t\t}\n\t}\n} used;\n\nbool cmp1(t a, t b)\n{\n\tif (abs(a.l - b.l) < eps)\n\t{\n\t\tif (abs(a.r - b.r) < eps)\n\t\t\treturn a.id < b.id;\n\t\treturn !(a.r < b.r);\n\t}\n\treturn a.l < b.l;\n}\n\nbool cmp2(t a, t b)\n{\n\tif (abs(a.r - b.r) < eps)\n\t{\n\t\tif (abs(a.l - b.l) < eps)\n\t\t\treturn a.id >= a.id;\n\t\treturn !(a.l < b.l);\n\t}\n\treturn a.r < b.r;\n}\n\nint main()\n{\n\tint n;\n\tD w, x, v;\n\tLL res = 0;\n\tcin >> n >> w;\n\tfor (int i = 0; i < n; ++i)\n\t{\n\t\tcin >> x >> v;\n\t\tarr.push_back({(v - w) / x, (v + w) / x, 0});\n\t}\n\trandom_shuffle(arr.begin(), arr.end());\n\tsort(arr.begin(), arr.end(), cmp1);\n\tfor (int i = 0; i < n; ++i)\n\t\tarr[i].id = i;\n\tif (n == 100000)\n\t{\n\t\treturn 0;\n\t}\n\tsort(arr.begin(), arr.end(), cmp2);\n\tfor (int i = n - 1; i >= 0; --i)\n\t{\n\t\tres += used.sum(arr[i].id);\n\t\tused.add(arr[i].id);\n\t}\n\tcout << res;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "838954fdf9436844c36c345cf5b73497", "src_uid": "d073d41f7e184e9bc4a12219d86e7184", "difficulty": 2500.0}
    {"lang": "GNU C++17", "source_code": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\ntypedef long long ll;\n#define N 200010\ninline int read(){\n\tint x=0,f=1;\n\tchar c=getchar();\n\twhile(c<'0'||c>'9'){\n\t\tif(c=='-')f=-1;\n\t\tc=getchar();\n\t}\n\twhile(c>='0'&&c<='9'){\n\t\tx=(x<<1)+(x<<3)+c-'0';\n\t\tc=getchar();\n\t}\n\treturn x*f;\n}\nint n,m,len,t[N];\nstruct frac{\n\tll a,b;\n\tbool operator <(const frac y)const{\n\t\treturn a*y.b0);\n\t\tx=abs(x),v=abs(v);\n\t\tl[i]={x,v+m};\n\t\tr[i]={x,v-m};\n\t\tif(l[i]>r[i])swap(l[i],r[i]);\n\t\tb[++len]=l[i],b[++len]=r[i];\n\t}\n\tsort(b+1,b+len+1);\n\tlen=unique(b+1,b+len+1)-b-1;\n\tfor(int i=1;i<=n;++i){\n\t\ta[i].l=lower_bound(b+1,b+len+1,l[i])-b;\n\t\ta[i].r=lower_bound(b+1,b+len+1,r[i])-b;\n\t\ta[i].t=t[i];\n\t}\n\tsort(a+1,a+n+1);\n\tfor(int i=1;i<=n;++i){\n\t\tint p=a[i].t;\n\t\tans+=i-1-B[p].Ask(a[i].l-1);\n\t\tB[p].Add(a[i].l,1);\n\t\tB[p^1].Add(a[i].r,1);\n\t}\n\tprintf(\"%lld\\n\",ans);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "066b17f91dccd73d2dcadf5380ae547b", "src_uid": "d073d41f7e184e9bc4a12219d86e7184", "difficulty": 2500.0}
    {"lang": "GNU C++17", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\ntypedef long double ld;\ntypedef long long ll;\nconst ld eps=1e-10;\n#define N 200010\ninline int read(){\n\tint x=0,f=1;\n\tchar c=getchar();\n\twhile(c<'0'||c>'9'){\n\t\tif(c=='-')f=-1;\n\t\tc=getchar();\n\t}\n\twhile(c>='0'&&c<='9'){\n\t\tx=(x<<1)+(x<<3)+c-'0';\n\t\tc=getchar();\n\t}\n\treturn x*f;\n}\nint n,m,len,t[N];\nld b[N];\nld l[N],r[N];\nstruct Range{\n\tint l,r;\n\tbool operator <(const Range b)const{\n\t\treturn rr[i])swap(l[i],r[i]);\n\t\tb[++len]=l[i],b[++len]=r[i];\n\t\tt[i]=(x>0);\n\t}\n\tsort(b+1,b+len+1);\n\tlen=unique(b+1,b+len+1)-b-1;\n\tfor(int i=1;i<=n;++i){\n\t\ta[i].l=lower_bound(b+1,b+len+1,l[i])-b;\n\t\ta[i].r=lower_bound(b+1,b+len+1,r[i])-b;\n\t\ta[i].t=t[i];\n\t}\n\tsort(a+1,a+n+1);\n\tfor(int i=1;i<=n;++i){\n\t\tint p=a[i].t;\n\t\tans+=i-1-B[p].Ask(a[i].l-1);\n\t\tB[p].Add(a[i].l,1);\n\t\tB[p^1].Add(a[i].r,1);\n\t}\n\tprintf(\"%lld\\n\",ans);\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "19461d678e7a70634efe0b02a68d49ee", "src_uid": "d073d41f7e184e9bc4a12219d86e7184", "difficulty": 2500.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n\nusing namespace __gnu_pbds;\nusing namespace std;\n\ntypedef long long int ll;\ntypedef pair dd;\n#define FOR(i, N) for (int i = 0; i < N; ++i)\n#define FORN(i, j, N) for (int i = j; i < N; ++i)\n#define MAXN 100009\n#define EPS 1e-12\n\nll N, W;\nll x[MAXN], v[MAXN];\ndd t[MAXN];\n\nbool sorte(dd a, dd b){\n    if (abs(a.first - b.first) > EPS)\n        return a.first < b.first;\n    return a.second > b.second;\n}\n\nint main(){\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\t\n\tcin>>N>>W;\n\ttree, rb_tree_tag, \n\t\ttree_order_statistics_node_update> s;\n\n\tFOR(i, N) {\n\t\tcin>>x[i]>>v[i];\n\t\tdouble d1 = (double)-x[i] / (v[i] - W);\n\t\tdouble d2 = (double)-x[i] / (v[i] + W);\n\t\t\n\t\tt[i] = dd(d1, d2);\n\t}\n\tsort(t, t + N, sorte);\n\t\n\tll ans = 0;\n\t\n\ts.insert(dd(t[0].second, 0));\n\t\n\tFORN(i, 1, N){\n\t\tdouble tr = t[i].second;\n\t\tans += s.size() - s.order_of_key(tr);\n\t\ts.insert(dd(tr, -i));\n\t}\n\tcout<\n\n#define F first\n#define S second\n\nusing namespace std;\n\nint x, y, n, d;\nshort dp[651][651][2][2][2];\npair points[21];\n\nint dist(int x, int y) {\n  return pow(x, 2.0) + pow(y, 2.0);\n}\n\nbool rec(int x, int y, bool sh1, bool sh2, bool cur) {\n  if(dist(x, y) > d) {\n    // cout << x << ' ' << y << ' ' << sh1 << ' ' << sh2 << ' ' << cur << endl;\n    return !cur;\n  }\n\n  int &ret = dp[x + 200][y + 200][sh1][sh2][cur];\n  if(ret != -1)\n    return ret;\n  ret = 0;\n\n  int cnt = 0;\n  if(cur == 0) {\n    for(int i = 0; i < n; ++i)\n      cnt += rec(x + points[i].F, y + points[i].S, sh1, sh2, !cur);\n    if(!sh1)\n      cnt += rec(y, x, 1, sh2, !cur);\n\n    if(cnt == n + !sh1)\n      ret = 1;\n  } else {\n    for(int i = 0; i < n; ++i)\n      cnt += !rec(x + points[i].F, y + points[i].S, sh1, sh2, !cur);\n    if(!sh2)\n      cnt += !rec(y, x, sh1, 1, !cur);\n\n    if(cnt < n + !sh2)\n      ret = 1;\n  }\n\n  return ret;\n}\n\nint main() {\n  scanf(\"%d %d %d %d\", &x, &y, &n, &d);\n  d *= d;\n\n  for(int i = 0; i < n; ++i)\n    scanf(\"%d %d\", &points[i].F, &points[i].S);\n  \n  memset(dp, -1, sizeof dp);\n  if(rec(x, y, 0, 0, 0))\n    puts(\"Anton\");\n  else\n    puts(\"Dasha\");\n\n  return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "01a38f34b1bd5b967bcaaddf7d171a0b", "src_uid": "645a6ca9a8dda6946c2cc055a4beb08f", "difficulty": 1900.0}
    {"lang": "GNU C++", "source_code": "#include\n\n#define f first\n#define sec second\n\nusing namespace std;\n\nint d[1000][1000];\npair b[20];\nint x , y , n , l;\n\nint play(int x , int y){ // ro ye x , y va  milham harekalt konam \n    if (d[x][y] != 0)\n        return d[x][y];\n    if ( (x - 200) * (x - 200) + (y - 200) * (y - 200) > l){\n        d[x][y] = 1;\n        return 1;\n    }\n        \n    for(int i = 0 ; i < n ; i++)\n        if ( play(x + b[i].f , (y + b[i].sec) )== 2 ){\n            d[x][y] = 1; \n            return 1;\n        } \n        d[x][y] = 2;\n        return 2 ;    \n    \n\n}\n\nint main(){     \n    cin >> x >> y >> n >> l;\n    l *= l;\n    for(int i = 0 ; i < n ; i++)\n \t\tscanf(\"%d%d\" , &b[i].f , &b[i].sec ) ; \n    \n    if ( x * x + y * y > l)\n        cout << \"Dasha\" << endl;\n    else{  \n    x += 200;\n    y += 200;\n   \n    if ( play(x , y ) == 1)\n        cout << \"Anton\"<\n#include\nusing namespace std;\nconst int maxn=201;\n\nint x,y,n,dist;\nint a[20][2],f[maxn*2][maxn*2];\n\nvoid init()\n{\n    cin>>x>>y>>n>>dist;\n    dist*=dist;\n    for (int i=0; i>a[i][0]>>a[i][1];\n}\n\nint dfs(int x, int y)\n{\n    if (f[x+maxn][y+maxn]!=-1) return f[x+maxn][y+maxn];\n    if (x*x+y*y>dist) return 0;\n    for (int i=0; i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \nusing namespace std;\n \n#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)\n#define forn(i, a, b) for (int (i) = (a); (i) < (b); (i)++)\n#define fore(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)\n#define mp make_pair\n#define pb push_back\n#define sz(v) (int)(v).size()\n#define all(v) (v).begin(), (v).end()\n#define sqr(x) (x) * (x)\n#define dbg(v) rep(i, sz(v)) cout << v[i] << \" \"; cout << \"\\n\"\n#define dbg2(n) cout << #n << \": \" << n << \"\\n\"\n#define subsub(n) rep(i, 1 << n) for (int j = i; j > 0; j = (j - 1) & i)\n#define fi first\n#define se second\n \ntypedef long long ll;\ntypedef pair  pii;\ntypedef vector  vi;\ntypedef vector  vvi;\n \nint bits (int x) { return x == 0? 0: 1 + bits(x & (x - 1)); }\n\nconst double PI = acos(-1.0);\nconst double eps = 1e-9;\nconst int INF = 1000000000;\n\n//typedef complex < double > base;\n//typedef vector < base > vb;\n\nstring nextString(){\n\tchar buf[1000000];\n\t//gets(buf);\n    scanf(\"%s\", buf);\n\treturn buf;\n}\n\nint dx[] = {0, 1, 0, -1};\nint dy[] = {1, 0, -1, 0};\n\nvector< pii > in;\n\nconst int maxN = 500;\n\nint dp[maxN][maxN][2][2][2]; //1 - win, 2 - lose\n\nint d;\n\nbool solve(int x, int y, bool anton, bool cana, bool cand){\n\tif(x * x + y * y > d * d)\n\t\treturn true;\n\tif(dp[x + 200][y + 200][anton][cana][cand])\n\t\treturn dp[x + 200][y + 200][anton][cana][cand];\n\trep(i, sz(in))\n\t\tif(!solve(x + in[i].first, y + in[i].second, !anton, cana, cand)){\n\t\t\tdp[x + 200][y + 200][anton][cana][cand] = 1;\n\t\t\treturn true;\n\t\t}\n\tif(anton && cana && !solve(y, x, false, false, cand)){\n\t\tdp[x + 200][y + 200][anton][cana][cand] = 1;\n\t\treturn true;\n\t}\n\tif(!anton && cand && !solve(y, x, true, cana, false)){\n\t\tdp[x + 200][y + 200][anton][cana][cand] = 1;\n\t\treturn true;\n\t}\n\tdp[x + 200][y + 200][anton][cana][cand] = false;\n\treturn false;\n}\n\nint main(){\n\t#ifdef _DEBUG\t\n        #define FILENAME \"test\"\n        freopen (FILENAME\".in\", \"rt\", stdin);\n        freopen (FILENAME\".out\", \"wt\", stdout);\n    #endif\n    //ios_base::sync_with_stdio(0);\n\tint x, y, n;\n\tscanf(\"%d %d %d %d\", &x, &y, &n, &d);\n\tin.resize(n);\n\tmemset(dp, 0, sizeof(dp));\n\trep(i, n)\n\t\tscanf(\"%d %d\\n\", &in[i].first, &in[i].second);\n\tprintf(solve(x, y, true, true, true) ? \"Anton\" : \"Dasha\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1adb6ae4c690fe26a66e850520f7e77c", "src_uid": "645a6ca9a8dda6946c2cc055a4beb08f", "difficulty": 1900.0}
    {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define ll long long\n\n\nll gcd(ll a, ll b){\n   if(b == 0){\n       return a;\n   }\n   return gcd(b, a%b);\n}\n\n\nint main(){\n  \n  ll r;\n  cin>>r;\n  int flag = 0;\n  if(r%2 == 0){//even\n     cout<<\"NO\"<= 0){\n             cout<\n#include \n#define ll long long\nusing namespace std;\nint main()\n{ ios_base::sync_with_stdio(false);\n    cin.tie(NULL);\n    cout.tie(NULL);\n    ll ans=-1,ans1;double n;\n    cin>>n;\n    if(n==1)\n    {cout<<0<<\" \"<<0<<\"\\n\";\n    }\n    else\n    {\n    for(int j=1;j*j<=n;j++)\n    {\n        double i=j;\n        double r=(n-1-(i*i)-i)/(2*i);\n        if(r==floor(r)&&r>=0)\n        {ans=i;ans1=r;break;}\n    }\n    if(ans!=-1)\n    cout<\n\nusing namespace std;\n\nint main()\n{\n    ll n;\n    cin>>n;\n    if(n%2==0)cout<<\"NO\"<\n#define ll long long int\n \nusing namespace std;\n \nint main()\n{\n ll n;\n cin>>n;\n int fl=0,s=0,i,y=-1;\n \n if(n%2!=0)\n   y=(r-3)/2;\n  if(y>=1)\n  cout<<\"1 \"<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define pairII pair \n#define VP vector \n#define VL vector\n#define VVL vector\n#define VD vector\n#define VVD vector\n#define VI vector\n#define VVI vector\n#define VVVI vector\n#define VB vector\n#define VVB vector\n#define forN(i, n) for (int i = 0; i < n; ++i)\n#define rforN(i, n) for (int i = n; i >= 0; --i)\n#define forR(i, l, r) for (int i = l; i <= r; ++i)\n#define rforR(i, r, l) for (int i = r; i >= l; --i)\n#define forV(i, Vec, type) for (type::iterator (i) = (Vec).begin(); (i) < (Vec).end(); ++(i))\n#define rforV(i, Vec, type) for (type::reverse_iterator (i) = (Vec).rbegin(); (i) < (Vec).rend(); ++(i))\n#define INF 1e9\n#define pb push_back\n#define mp make_pair\n#define min3(a, b, c) min( (a), min ( (b), (c) ))\n#define PI = acos(-1.0)\n\nusing namespace std;     \n\nint a, b, n;\n\nint dfs (int a, int b) {\n\tif (pow ((double)a, b) >= pow ((double)n, 1))\n\t\treturn 1;\n\tif (a == 1 && pow (2.0, b) >= pow ((double)n, 1)/*(b > 29 || (1 << b) >= n)*/) \n\t\treturn -1;\n\tif (b == 1 && (1ll * a) * (1ll * a) >= 1ll * n) \n\t\treturn ((n - a + 1) % 2);  \n\tint l = dfs (a, b + 1)\n\tif (l == 0)\n\t\treturn 1;\n\tint r = dfs (a + 1, b);\n\treturn (r == 0 ? 1 : min (l, r) ^ 1);\n}\n\nint main() {\n//\tfreopen (\"in.txt\", \"r\", stdin);\n//\tfreopen (\"out.txt\", \"w\", stdout);\n\t\n\tcin >> a >> b >> n;\n\tint ans = dfs (a, b);\n\tcout << (ans == 1 ? \"Masha\" : (ans == 0 ? \"Stas\" : \"Missing\"));\n\treturn 0;\n}\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ea5fa7df865fc5264a704709848e21ea", "src_uid": "cffd5c0b7b659649f3bf9f2dbd20ad6b", "difficulty": 2000.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std;\nint n,a,b;\nint f[40000][40],g[40000][40];\nint dfs(int a,int b)\n{\n\tlong long ans=1;\n\tfor (int i=1;i<=b;i++)\n\t\t{\n\t\t\tans*=a;\n\t\t\tif (ans>n) return 0;\n\t\t}\n\tif (g[a][b]) return f[a][b];\n\tif (a==1 && b\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef long ll lll;\n\nint **dyn;\n\nll a, b;\nll n;\n\n\nbool isp(ll a1, ll b1)\n{\n    ll ans = 1;\n\n    for (ll i = 0; i < b1; i++)\n    {\n        ans *= a1;\n        if (ans >= n)\n            return true;\n    }\n    return false;\n}\n\nint main ()\n{\n    cin >> a >> b >> n;\n    ll a1 = a, b1 = b;\n    \n    a = 100000;\n    b = 100;\n    dyn = new ll*[a + 2];\n    for (ll i = 0; i <= a + 1; i++)\n    {\n        dyn[i] = new ll[b + 2];\n    }\n    ll *last = new ll[a + 1];\n    for (ll i = 1; i <= a + 1; i++)\n    {\n        bool flag = false;\n        for (ll j = 1; j <= b + 1; j++) \n        {\n            dyn[i][j] = -1;\n            if (isp(i, j))\n            {\n                if (!flag)\n                {\n                    last[i] = j;\n                    flag = true;\n                }\n                dyn[i][j] = 1;\n            }\n        }\n    }\n    for (ll i = a; i >= 2; i--)\n    {\n        for (ll j = last[i] - 1; j >= 1; j--)\n        {\n            if ((!dyn[i][j + 1]) || (!dyn[i + 1][j]))\n            {\n                dyn[i][j] = 1;\n            }\n            else\n            {\n                dyn[i][j] = 0;\n            }\n        }\n    }\n    if (a1 == 1)\n    {\n        if (!dyn[a1 + 1][b1])\n        {\n            cout << \"Masha\" << endl;\n        }\n        else\n        {\n            for (ll i = b1 + 1; i <= b; i++)\n            {\n                if (dyn[2][i] == 0)\n                {\n                    if ((i - b1) % 2 == 1)\n                    {\n                        cout << \"Stas\" << endl;\n                    }\n                    else\n                    {\n                        cout << \"Masha\" << endl;\n                    }\n                    //cin >> n;\n                    return 0;\n                }\n            }\n            cout << \"Missing\" << endl;\n        }\n        //cin >> n;\n        return 0;\n    }\n    if (dyn[a1][b1] == 1)\n    {\n        cout << \"Masha\" << endl;\n    }\n    else\n    {\n        cout << \"Stas\" << endl;\n    }\n    //cin >> n;\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d37b1df860d91055fcf9e5ea79c5a9d9", "src_uid": "cffd5c0b7b659649f3bf9f2dbd20ad6b", "difficulty": 2000.0}
    {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define PB push_back\n#define MP make_pair\n#define L first\n#define R second\nlong long dp[100000+10][35];\nbool poww[100000+10][35];\n    long long n,m,k;\nlong long cal(long long a,long long b)\n{\n    if(1==b && a>200)\n    {\n        int kk = 1;\n        for(int i=1;i<=b;i++)\n        {\n            kk*=a;\n            if(kk>=k)\n            {\n                return 1;\n            }\n        }\n        return 2;\n    }\n    if(b>30 || a>=100000)\n        return 1;\n    if(b>2 && a>=10000)\n        return 1;\n    if(dp[a][b]==true)\n        return dp[a][b];\n    if(cal(a+1,b)==2 || cal(a,b+1)==2)\n    {\n        dp[a][b]==1;\n        return 1;\n    }\n    dp[a][b]==2;\n    return 2;\n}\nint main()\n{\n    ios_base::sync_with_stdio(false);\n    cin>>n>>m>>k;\n    for(long long i=1;i<=100000;i++)\n    {\n        long long now = 1;\n        for(long long j=1;j<=34;j++)\n        {\n            now*=i;\n            if(now>=k)\n                poww[i][j]=true;\n            if(poww[i][j-1]==true)\n                poww[i][j]=true;\n            if(poww[i][j]==true)\n            {\n                dp[i][j]=1;\n            }\n        }\n    }\n    if(n==1 && poww[n+1][m]){\n        cout<<\"Missing\";\n        return 0;\n    }\n    if(cal(n,m)==1)\n        cout<<\"Masha\"<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define PB push_back\n#define MP make_pair\n#define L first\n#define R second\nlong long dp[100000+10][35];\nbool poww[100000+10][35];\nlong long cal(long long a,long long b)\n{\n    if(1==b && a>200)\n        return 2;\n    if(b>30 || a>=100000)\n        return 1;\n    if(b>2 && a>=10000)\n        return 1;\n    if(dp[a][b]==true)\n        return dp[a][b];\n    if(cal(a+1,b)==2 || cal(a,b+1)==2)\n    {\n        dp[a][b]==1;\n        return 1;\n    }\n    dp[a][b]==2;\n    return 2;\n}\nint main()\n{\n    ios_base::sync_with_stdio(false);\n    long long n,m,k;\n    cin>>n>>m>>k;\n    for(long long i=1;i<=100000;i++)\n    {\n        long long now = 1;\n        for(long long j=1;j<=34;j++)\n        {\n            now*=i;\n            if(now>=k)\n                poww[i][j]=true;\n            if(poww[i][j-1]==true)\n                poww[i][j]=true;\n            if(poww[i][j]==true)\n            {\n                dp[i][j]=1;\n            }\n        }\n    }\n    if(n==1 && poww[n+1][m]){\n        cout<<\"Missing\";\n        return 0;\n    }\n    if(cal(n,m)==1)\n        cout<<\"Masha\"<\n#define LL long long\n#define lowbit(x) (x&(-x))\n#define INF (1LL << 60)\n#define eps 1e-6\nusing namespace std;\n\ntemplate inline\nvoid read(T& x) {\n\tint f = 1; x = 0;\n\tchar ch = getchar();\n\twhile (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}\n\twhile (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}\n\tx *= f;\n}\n\n/*============ Header Template ============*/\n\nconst int N = 500 + 5;\n\nint n, v1, v2, l1, l2;\nLL v[N], w[N], dp[3][N][N];\nLL dp2[N];\n\nint main() {\n\t// freopen(\"haha.in\", \"r\", stdin);\n\t// freopen(\"haha.out\", \"w\", stdout);\n\tread(n);\n\tfor (int i = 1; i <= n; i++) read(v[i]);\n\tfor (int i = 1; i <= n; i++) read(w[i]);\n\tfor (int i = 1; i <= n; i++)\n\t\tfor (int j = 1; j <= n - i; j++) v[i + j] = max(v[i + j], v[i] + v[j]);\n\tfor (int i = 0; i <= 2; i++)\n\t\tfor (int j = 1; j <= n; j++)\n\t\t\tfor (int k = j; k <= n; k++)\n\t\t\t\tdp[i][j][k] = -INF;\n\tfor (int i = 1; i <= n; i++)\n\t\tdp[0][i][i] = dp[1][i][i] = dp[2][i][i] = v[1], dp[0][i][i - 1] = 0;\n\tfor (int ii = 2; ii <= n; ii++)\n\t\tfor (int i = 1; i <= n - ii + 1; i++) {\n\t\t\tfor (int j = i + 1; j <= i + ii - 1; j++)\n\t\t\t\tif ((w[j] == w[i] + 1) && (dp[1][j][i + ii - 1] > -inf))\n\t\t\t\t\tdp[1][i][i + ii - 1] = max(dp[1][i][i + ii - 1], dp[0][i + 1][j - 1] + dp[1][j][i + ii - 1] + v[w[i + ii - 1] - w[i] + 1] - v[w[i + ii - 1] - w[j] + 1]);\n\t\t\tfor (int j = i + 1; j <= i + ii - 1; j++)if ((w[j] == w[i] - 1) && (dp[2][j][i + ii - 1] > -inf))\n\t\t\t\t\tdp[2][i][i + ii - 1] = max(dp[2][i][i + ii - 1], dp[0][i + 1][j - 1] + dp[2][j][i + ii - 1] + v[w[i] - w[i + ii - 1] + 1] - v[w[j] - w[i + ii - 1] + 1]);\n\t\t\tfor (int j = i; j <= i + ii - 2; j++)dp[0][i][i + ii - 1] = max(dp[0][i][j] + dp[0][j + 1][i + ii - 1], dp[0][i][i + ii - 1]);\n\t\t\tdp[0][i][i + ii - 1] = max(dp[0][i][i + ii - 1], max(dp[1][i][i + ii - 1], dp[2][i][i + ii - 1]));\n\t\t\tfor (int j = i + 1; j <= i + ii - 2; j++)if ((dp[1][i][j] > inf) && (dp[2][j][i + ii - 1] > inf))\n\t\t\t\t\tdp[0][i][i + ii - 1] = max(dp[0][i][i + ii - 1], dp[1][i][j] + dp[2][j][i + ii - 1] + w[2 * v[j] - v[i] - v[i + ii - 1] + 1] - w[v[j] - v[i] + 1] - w[v[j] - v[i + ii - 1] + 1]);\n\t\t}\n\tfor (int i = 1; i <= n; i++)\n\t\tfor (int j = 1; j <= i; j++)\n\t\t\tdp2[i] = max(dp2[i], dp2[j - 1] + max(0ll, dp[0][j][i]));\n\tprintf(\"%lld\\n\", dp2[n]);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "94a5fa6f797e72a6fd42bc071c8c66fe", "src_uid": "32fa5dbac37abe197a267a0fc7fe4006", "difficulty": null}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#define LL long long \nusing namespace std;\n\n  int n;\n  LL v[401],w[401],dp[401][401],peak[401][401],l[401][401],r[401][401],ans[401];\n\n  int main(){\n  \tfreopen(\"haha.in\",\"r\",stdin);\n  \tfreopen(\"haha.out\",\"w\",stdout);\n  \t\n  \tscanf(\"%d\",&n);\n  \tfor (int i=1;i<=n;i++) scanf(\"%lld\",&v[i]);\n  \tfor (int i=1;i<=n;i++)\n  \t  for (int j=0;j<=i;j++)\n  \t    v[i]=max(v[i],v[j]+v[i-j]);\n \tfor (int i=1;i<=n;i++) scanf(\"%lld\",&w[i]);\n  \t\n  \tfor (int i=1;i<=n;i++) for (int j=1;j<=n;j++) dp[i][j]=peak[i][j]=l[i][j]=r[i][j]=-1e9;\n  \tfor (int i=1;i<=n;i++) peak[i][i]=dp[i][i]=v[1],l[i][i]=r[i][i]=l[i][i-1]=r[i][i-1]=dp[i][i-1]=0;\n  \tfor (int i=2;i<=n;i++)\n  \t  for (int j=1;j<=n-i+1;j++){\n  \t    int ranl=j,ranr=i+j-1;\n\t\t\n\t\tfor (int k=ranl;k=1&&2*w[k]-w[ranl]-w[ranr]+1<=ranr-ranl+1)\n\t\t    peak[ranl][ranr]=max(peak[ranl][ranr],l[ranl][k]+r[k][ranr]+v[2*w[k]-w[ranl]-w[ranr]+1]);\n\t\tfor (int k=ranl;k<=ranr;k++)\n\t\t  dp[ranl][ranr]=max(dp[ranl][ranr],peak[ranl][k]+dp[k+1][ranr]);\n\t\t  \n//\t\tprintf(\"rl:%d rr:%d l:%d r:%d peak:%d dp:%d\\n\",ranl,ranr,l[ranl][ranr],r[ranl][ranr],peak[ranl][ranr],dp[ranl][ranr]);\n\t  }\n\t  \n\tans[0]=0;\n\tLL ret=0;\n\tfor (int i=1;i<=n;i++){\n\t  for(int j=0;j\n#include\n#include\nusing namespace std;\ntypedef long long LL;\ntypedef double db;\ninline int read()\n{\n\tint x=0,f=1;\n\tchar ch=getchar();\n\twhile(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); }\n\twhile(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+ch-'0'; ch=getchar(); }\n\treturn x*f;\n}\nconst int MAXN=410,INF=0x3f3f3f3f;\nint n,v[MAXN],w[MAXN],f[MAXN][MAXN],g[MAXN][MAXN],h[MAXN][MAXN];\nint main()\n{\n\tn=read();\n\tfor(int i=1;i<=n;++i)v[i]=read();\n\tfor(int i=1;i<=n;++i)w[i]=read();\n\tfor(int l=1;l<=m;++l)\n\t\tfor(int i=1;i+l-1<=n;++i)\n\t\t{\n\t\t\tint j=i+l-1;\n\t\t\tif(i==j)\n\t\t\t{\n\t\t\t\tf[i][j]=v[1];\n\t\t\t\tg[i][j]=h[i][j]=0;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tg[i][j]=h[i][j]=-INF;\n\t\t\tfor(int k=i+1;k<=j;++k)\n\t\t\t{\n\t\t\t\tif(w[k]==w[i]+1)g[i][j]=max(g[i][j],f[i+1][k-1]+g[k][j]);\n\t\t\t\telse if(w[k]==w[i]-1)h[i][j]=max(h[i][j],f[i+1][k-1]+h[k][j]);\n\t\t\t}\n\t\t\tf[i][j]=-INF;\n\t\t\tfor(int k=1;k\nusing namespace std;\n#define __MODE 0\n#define $ if (__MODE) cerr\nint n;\n#define LL long long\nconst int N = 500;\nconst LL INF = 1000000000000000000LL;\nint v[N], w[N];\nLL FF[N][N], F[N][N], G[N][N], LS[N][N], RS[N][N];\n\nint main()\n{\n    scanf(\"%d\", &n);\n    for (int i = 1; i <= n; ++ i) scanf(\"%d\", &v[i]);\n    for (int i = 1; i <= n; ++ i) scanf(\"%d\", &w[i]);\n    for (int r = 1; r <= n; ++ r)\n        for (int l = r; l >= 1; -- l)\n        {\n            // ls\n            if (l != r)\n            {\n                LL res = -INF;\n                for (int i = l; i <= r; ++ i)\n                    if (w[i] == w[r] - 1)\n                        res = max(res, LS[l][i] + (i + 1 > r - 1? 0: F[i + 1][r - 1]));\n                LS[l][r] = res;\n            }\n            // rs\n            if (l != r)\n            {\n                LL res = -INF;\n                for (int i = l; i <= r; ++ i)\n                    if (w[i] == w[l] - 1)\n                        res = max(res, RS[i][r] + (l + 1 > i - 1? 0: F[l + 1][i - 1]));\n                RS[l][r] = res;\n            }\n            // g\n            {\n                LL res = -INF;\n                for (int i = l; i <= r; ++ i)\n                    if (w[i] >= max(w[l], w[r]) && w[i] - w[l] + w[i] - w[r] + 1 <= r - l + 1)\n                        res = max(res, LS[l][i] + RS[i][r] + v[w[i] - w[l] + w[i] - w[r] + 1]);\n                G[l][r] = res;\n            }\n            // f\n            {\n                LL res = G[l][r];\n                for (int i = l; i < r; ++ i)\n                    res = max(res, G[l][i] + F[i + 1][r]);\n                F[l][r] = res;\n            }\n            // ff\n            {\n                LL res = max(0, G[l][r]);\n                for (int i = l; i < r; ++ i)\n                    res = max(res, max(0ll, G[l][i]) + FF[i + 1][r]);\n                FF[l][r] = res;\n            }\n        }\n    cout << FF[1][n] << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3810cc4a0871ad34fb2e3f02164f9217", "src_uid": "32fa5dbac37abe197a267a0fc7fe4006", "difficulty": null}
    {"lang": "MS C++", "source_code": "#include \n#include \n\ntypedef unsigned int uint_t;\ntypedef std::vector array_t;\ntypedef std::vector::iterator iterator_t;\ntypedef std::vector::const_iterator const_iterator_t;\n\ntemplate \ninline bool CheckFinish(T1& left, T1& right)\n{\n\treturn left > right;\n}\n\ninline bool CheckSumValid(const uint_t min, const uint_t max, const uint_t sum)\n{\n\treturn sum >= min && sum <= max;\n}\n\ntemplate \ninline bool ReachMin(const uint_t min, T& it, uint_t& sum)\n{\n\tif (sum <= min)\n\t{\n\t\tsum += *it;\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\ntemplate \ninline bool ReachMax(const uint_t max, T& it, uint_t& sum)\n{\n\tif (sum + *it <= max)\n\t{\n\t\tsum += *it;\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nint Mark(const array_t& c, const uint_t size, const uint_t min, const uint_t max)\n{\n\tif (size == 0)\n\t\treturn 0;\n\n\twhile (true)\n\t{\n\t\tconst_iterator_t left = c.begin();\n\t\tconst_iterator_t right = c.begin() + size - 1;\n\n\t\tuint_t leftSum = 0;\n\t\tuint_t rightSum = 0;\n\n\t\twhile (!CheckFinish(left, right) && ReachMin(min, left, leftSum))\n\t\t{\n\t\t\t++left;\n\t\t}\n\n\t\tif (!CheckSumValid(min, max, leftSum))\n\t\t\tbreak;\n\n\t\twhile (!CheckFinish(left, right) && ReachMin(min, right, rightSum))\n\t\t{\n\t\t\t--right;\n\t\t}\n\n\t\tif (!CheckSumValid(min, max, rightSum))\n\t\t\tbreak;\n\n\t\twhile (!CheckFinish(left, right) && ReachMax(max, left, leftSum))\n\t\t{\n\t\t\t++left;\n\t\t}\n\t\twhile (!CheckFinish(left, right) && ReachMax(max, right, rightSum))\n\t\t{\n\t\t\t--right;\n\t\t}\n\n\t\tif (!CheckFinish(left, right))\n\t\t\tbreak;\n\n\t\treturn std::distance(c.begin(), left) + 1;\n\t}\n\treturn 0;\n}\n\nint _tmain(int argc, _TCHAR* argv[])\n{\n\tuint_t size;\n\tstd::cin >> size;\n\tstd::vector c(size);\n\n\tfor (iterator_t it = c.begin(); it != c.end(); ++it)\n\t\tstd::cin >> *it;\n\n\tuint_t max, min;\n\tstd::cin >> min;\n\tstd::cin >> max;\n\n\tstd::cout << Mark(c, size, min, max);\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c9e9d20894821d49a4d99efe3e91d792", "src_uid": "e595a1d0c0e4bbcc99454d3148b4557b", "difficulty": 1000.0}
    {"lang": "GNU C++", "source_code": "//\n//  main.cpp\n//  cf357a\n//\n//  Created by Boychuk, Petro on 12/4/13.\n//  Copyright (c) 2013 Boychuk, Petro. All rights reserved.\n//\n\n#include \nusing namespace std;\nint main(int argc, const char * argv[])\n{\n\n    \n    int m;\n    cin >> m;\n    int c[100];\n    int s = 0;\n    for (int i=0; i> c[i];\n        s += c[i];\n    }\n    int x,y;\n    cin >> x >> y;\n    \n    sort(c, c+m);\n    int sum = 0;\n    for (int i=0; i= x && sum <= y && s - sum >= x && s-sum <= y) {\n            cout << c[i];\n            return 0;\n        }\n    }\n    \n    cout << 0;\n    \n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c8ae8ad0fb4f4ce38c43232debe047c2", "src_uid": "e595a1d0c0e4bbcc99454d3148b4557b", "difficulty": 1000.0}
    {"lang": "GNU C++17", "source_code": "import sys\ndef main():\n   pass:\n   \ndef solve():\n    n = int(input())\n    l = list(map(int, input().split()))\n    x, y = map(int, input().split())\n\n    pref=l\n    for i in range(1, n):\n        pref[i] = pref[i - 1] + l[i]\n    ans=0\n    for i in range(0, n):\n        if ((pref[i] > x and pref[i]<=y) and (pref[n - 1] - pref[i] <= y and pref[n-1]-pref[i]>=x)):\n            ans = i + 1\n\n    if (ans == 0):\n        \n        print(ans)\n    else:\n        print(ans+1)\n\n    \n            \n        \n\n\n    \n    \n    \n\n\n\n\n\nif __name__ == \"__main__\":\n    main()\n    solve()", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7591210ad0c91b1aa2750006f2d744bb", "src_uid": "e595a1d0c0e4bbcc99454d3148b4557b", "difficulty": 1000.0}
    {"lang": "GNU C++", "source_code": "\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "df7ccd783e36838011de3a1a4e7f262d", "src_uid": "e595a1d0c0e4bbcc99454d3148b4557b", "difficulty": 1000.0}
    {"lang": "GNU C++20 (64)", "source_code": "\ufeff//#pragma GCC optimize(\"Ofast\")\n#include \n#include \nusing namespace __gnu_pbds;\ntypedef tree, rb_tree_tag, tree_order_statistics_node_update> indexed_set;\n#define fastio std::cin.tie(0), std::cout.tie(0), std::ios_base::sync_with_stdio(false)\n#define rep(a, b, c, d) for (int a = b; a < c; a += d)\n#define INF ((1ll << 62) - 1)\n#define all(x) x.begin(), x.end()\n#define sz(x) x.size()\n#define pb push_back\nusing namespace std;\n#define MN 200000\n#define int __int128\nconstexpr int mod = 998244353;\n\nint bin_pow(int a, int p) {\n    int res = 1;\n    while (p) {\n        if (p % 2) {\n            p--;\n            res *= a;\n            res %= mod;\n        } else {\n            a *= a;\n            a %= mod;\n            p /= 2;\n        }\n    }\n    return res;\n}\nlong long n, m;\n\n\nauto main() -> signed {\n    fastio;\n    int res = 0;\n    cin >> n >> m;\n    vector cur(n + 1);\n    cur[0] = 1;\n    for (int i = 2; i <= n; ++i) {\n        res += bin_pow(m, i);\n        res %= mod;\n    }\n    int c = m;\n    for (int i = 1; i <= n; ++i) {\n        if (gcd(i + 1, cur[i - 1]) == 1) {\n            cur[i] = lcm(cur[i - 1], i + 1);\n        } else {\n            cur[i] = cur[i - 1];\n        }\n        if (cur[i] > m) break;\n        c *= m / cur[i];\n        c %= mod;\n        res -= c;\n        res = (res + mod) % mod;\n    }\n    cout << (long long)res;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d54a97b8607178fcddb40f47f314ed5f", "src_uid": "0fdd91ed33431848614075ebe9d2ee68", "difficulty": 1900.0}
    {"lang": "GNU C++17", "source_code": "//C:\\Users\\tbziy\\Documents\\GitHub\\cfeditor\\Solution1.cpp\r\n// D. Counting Arrays\r\n// time limit per test2 seconds\r\n// memory limit per test512 megabytes\r\n// inputstandard input\r\n// outputstandard output\r\n// Consider an array a of length n with elements numbered from 1 to n. It is possible to remove the i-th element of a if gcd(ai,i)=1, where gcd denotes the greatest common divisor. After an element is removed, the elements to the right are shifted to the left by one position.\r\n\r\n// An array b with n integers such that 1\u2264bi\u2264n\u2212i+1 is a removal sequence for the array a if it is possible to remove all elements of a, if you remove the b1-th element, then the b2-th, ..., then the bn-th element. For example, let a=[42,314]:\r\n\r\n// [1,1] is a removal sequence: when you remove the 1-st element of the array, the condition gcd(42,1)=1 holds, and the array becomes [314]; when you remove the 1-st element again, the condition gcd(314,1)=1 holds, and the array becomes empty.\r\n// [2,1] is not a removal sequence: when you try to remove the 2-nd element, the condition gcd(314,2)=1 is false.\r\n// An array is ambiguous if it has at least two removal sequences. For example, the array [1,2,5] is ambiguous: it has removal sequences [3,1,1] and [1,2,1]. The array [42,314] is not ambiguous: the only removal sequence it has is [1,1].\r\n\r\n// You are given two integers n and m. You have to calculate the number of ambiguous arrays a such that the length of a is from 1 to n and each ai is an integer from 1 to m.\r\n\r\n// Input\r\n// The only line of the input contains two integers n and m (2\u2264n\u22643\u22c5105; 1\u2264m\u22641012).\r\n\r\n// Output\r\n// Print one integer \u2014 the number of ambiguous arrays a such that the length of a is from 1 to n and each ai is an integer from 1 to m. Since the answer can be very large, print it modulo 998244353.\r\n\r\n// Examples\r\n// inputCopy\r\n// 2 3\r\n// outputCopy\r\n// 6\r\n// inputCopy\r\n// 4 2\r\n// outputCopy\r\n// 26\r\n// inputCopy\r\n// 4 6\r\n// outputCopy\r\n// 1494\r\n// inputCopy\r\n// 1337 424242424242\r\n// outputCopy\r\n// 119112628\r\n\r\n#include \r\n\r\nusing namespace std;\r\n\r\n// Using long long instead of ll to avoid overflow\r\n// defines to reduce typing\r\n#define ll long long\r\n#define pb push_back\r\n#define mp make_pair\r\n#define fi first\r\n#define se second\r\n#define all(x) (x).begin(), (x).end()\r\n#define rev(x) (x).rbegin(), (x).rend()\r\n#define sz(x) (ll)(x).size()\r\n#define UMP unordered_map\r\n#define UST unordered_set\r\n\r\n// typedefs to reduce typing\r\ntypedef vector vi;\r\ntypedef pair pi;\r\n\r\n//\u601d\u8def:\r\n//\u8ba1\u7b97\u51fa\u6240\u6709\u5e8f\u5217\u7684\u4e2a\u6570\uff1a\r\n//total = m^1 + m^2 + m^3 + ... + m^n\r\n//\u8ba1\u7b97\u9700\u8981\u51cf\u6389\u7684\u4e0d\u5408\u6cd5\u5e8f\u5217\u7684\u4e2a\u6570\uff1a\r\n//\u5047\u8bbeP\u4e3a\u5b58\u50a8\u6240\u6709\u8d28\u6570\u7684\u6570\u7ec4\r\n//total2 = sum( m / (p1 * p2 * \u2026\u2026 * pk ) ) \u5176\u4e2dp1,p2,\u2026\u2026,pk\u8868\u793a\u4e0d\u8d85\u8fc7i\u7684\u6240\u6709\u8d28\u6570,0<=i<=n\u3002\r\n//\u7b54\u6848\u4e3atotal - total2\r\n\r\n//\u8ba1\u7b97\u4e0d\u8d85\u8fc7n\u7684\u6240\u6709\u8d28\u6570\r\n//\u4f7f\u7528\u6b27\u62c9\u7b5b\r\nvector getPrime(ll n)\r\n{\r\n    vector prime;\r\n    vector isPrime(n + 1, true);\r\n    for (ll i = 2; i <= n; i++)\r\n    {\r\n        if (isPrime[i])\r\n        {\r\n            prime.push_back(i);\r\n        }\r\n        for (ll j = 0; j < prime.size() && i * prime[j] <= n; j++)\r\n        {\r\n            isPrime[i * prime[j]] = false;\r\n            if (i % prime[j] == 0)\r\n            {\r\n                break;\r\n            }\r\n        }\r\n    }\r\n    return prime;\r\n}\r\n\r\nconst ll mod = 998244353;\r\n\r\nll fast_pow(ll a, ll b)\r\n{\r\n    ll res = 1;\r\n    while (b)\r\n    {\r\n        if (b & 1)\r\n        {\r\n            res = res * a % mod;\r\n        }\r\n        a = a * a % mod;\r\n        b >>= 1;\r\n    }\r\n    return res;\r\n}\r\n\r\n//main function\r\nint main()\r\n{\r\n    //input\r\n    ll n, m;\r\n    cin >> n >> m;\r\n    //\u8ba1\u7b97\u4e0d\u8d85\u8fc7n\u7684\u6240\u6709\u8d28\u6570\r\n    vector prime = getPrime(n);\r\n    //\u8ba1\u7b97total\r\n    ll total = 1;\r\n    ll cur = 1;\r\n    for (ll i = 1; i <= n; i++)\r\n    {\r\n        cur = cur * m % mod;\r\n        total = (total + cur) % mod;\r\n    }\r\n    //\u8ba1\u7b97total2\r\n    ll total2 = 0;\r\n    //\u6307\u5411\u5f53\u524d\u4e0d\u8d85\u8fc7i\u7684\u6700\u5927\u8d28\u6570\r\n    ll p_idx = 0;\r\n    cur = 1;\r\n    for (ll i = 1; i <= n; i++)\r\n    {\r\n        //\u8ba1\u7b97\u4e0d\u8d85\u8fc7i\u7684\u6240\u6709\u8d28\u6570\r\n        while (p_idx < prime.size() && prime[p_idx] <= i)\r\n        {\r\n            cur = cur * prime[p_idx];\r\n            if(cur > m){\r\n                goto end:;\r\n            }\r\n            p_idx++;\r\n        }\r\n        int tmp = m / cur;\r\n        cur2 *= tmp;\r\n        //\u8ba1\u7b97m / (p1 * p2 * \u2026\u2026 * pk)\r\n        total2 += cur2;\r\n    }\r\n    end:;\r\n    //\u8ba1\u7b97\u7b54\u6848\r\n    ll ans = (total - total2 + mod) % mod;\r\n    //output\r\n    cout << ans << endl;\r\n    return 0;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "25d45004e4e863a5a3810e7c5c6d53c0", "src_uid": "0fdd91ed33431848614075ebe9d2ee68", "difficulty": 1900.0}
    {"lang": "GNU C++17", "source_code": "#include\r\nusing namespace std;\r\n \r\n// #pragma GCC optimize(\"O3\")\r\n// #pragma GCC optimize(\"unroll-loops\")\r\n \r\n// #pragma GCC optimize \"trapv\"\r\n \r\n#define int long long\r\n#define ll long long\r\n#define mod 1000000007\r\n#define mod2 998244353\r\n#define min3(a, b, c) (min(min((a), (b)), (c)))\r\n#define max3(a, b, c) (max(max((a), (b)), (c)))\r\n \r\n \r\n#define pb push_back \r\n#define ppb               pop_back\r\n#define pf                push_front\r\n#define ppf               pop_front\r\n#define pi_solve_it 3.1415927\r\n// long double pi_val = acos(-1.0);\r\n \r\n#define vi vector\r\n#define vll vector\r\n#define vint vector\r\n#define pii pair\r\n#define pint pair\r\n#define F first\r\n#define S second\r\n#define mem1(a)           memset(a,-1,sizeof(a))\r\n#define mem0(a)           memset(a,0,sizeof(a))\r\n \r\n//#define SET\r\n \r\n#ifdef SET\r\n// header files for policy based data structuans in g++ \r\n#include  // Common file\r\n#include      // Including tree_order_statistics_node_update\r\n#include \r\nusing namespace __gnu_pbds;\r\nusing namespace __gnu_cxx;\r\n// ordered_Set - same as set but aintows \r\n               //order_of_key (k) : Number of items strictly smainter than k    O(logn)\r\n               //find_by_order(k) : K-th element in a set (counting from zero).  O(logn)\r\n// change less to less_equal to have a ordered set behaving as multi set but in this case erase operation does not work ans neither does the upper bound   \r\ntypedef tree, rb_tree_tag, tree_order_statistics_node_update> indexed_set;\r\ntypedef tree, rb_tree_tag, tree_order_statistics_node_update> indexed_multi_set;\r\n#endif \r\n \r\nlong long power(  long long x,\r\n                            long long        y, long long   p)\r\n{\r\n    long long ans = 1;\r\n \r\n    x = x % p;\r\n \r\n    while (y > 0)\r\n    {\r\n        if (y & 1)\r\n            ans = (ans * x) % p;\r\n        y = y >> 1;\r\n        x = (x * x) % p;\r\n        //cout<>t;\r\n \r\n    t=1;\r\n\r\n    for(int tt=1;tt<=t;tt++)\r\n    {\r\n        //cout<<\"Case #\"<>n>>m;\r\n        int ans = 0;\r\n        int val = 1;\r\n        int prev = m%mod2;\r\n\r\n        for (int i = 2; i <= n; ++i)\r\n        {\r\n            if(prime[i]==1 && val<=m)\r\n            {\r\n                val*=i;\r\n            }\r\n            //cout<\r\n#define int long long\r\nusing namespace std;\r\nint n,m;\r\nint vis[300005];\r\nconst int mod=998244353;\r\n__int128 tmp=1;\r\nint ans1;\r\nsigned main()\r\n{\r\n\tios::sync_with_stdio(0);\r\n\tcin.tie(0),cout.tie(0);\r\n\tvis[1]=1; \r\n\tfor(int i=2;i<=300000;i++)//\u7b5b\u8d28\u6570\r\n    {\r\n    \tif(vis[i]) continue;\r\n    \tfor(int j=i*i;j<=300000;j+=i) vis[j]=1;\r\n    }\r\n\tcin>>n>>m;\r\n\tfor(int i=1;i<=n;i++)//\u8ba1\u7b97\u6240\u6709a\u6570\u7ec4\u7684\u6570\u91cf\uff0c\u8981\u5f00__t128\r\n\t{\r\n\t\ttmp*=m;\r\n\t\ttmp%=mod;\r\n\t\tans1=(ans1+tmp)%mod;\r\n\t}\r\n\tint ans=1,sum=1;\r\n\tfor(int i=1;i<=n;i++)\r\n\t{\r\n\t\tif(!vis[i]&&sum<=m) sum*=i;//\u662f\u8d28\u6570\r\n\t\tif(sum>m) ans=0;//\u5fc5\u7136\u662f\u4e0dambiguous\u7684\r\n\t\telse ans=ans*((m/sum)%mod)%mod;\r\n\t\tans1=(ans1-ans+mod)%mod;\r\n\t}\r\n\tcout<\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nstruct Point\n{\n\tdouble x,y;\n\tPoint(double _x,double _y):x(_x),y(_y){}\n\tPoint(){}\n}C,TmpC;\nvectorP;\nint x[900],y[900],z[900];\ndouble R,TmpR;\nint n,m;\nPoint chg(int a,int b,int c,int d,int e,int f)\n{\n\tif(a==0&&b==0)return Point(d,e);\n\tif(b==0&&c==0)return Point(e,f);\n\tif(a==0&&c==0)return Point(d,f);\n\tdouble t=(a*d+b*e+c*f+0.0)/(a*a+b*b+c*c);\n\tdouble x=d-t*a,y=e-t*b,z=f-t*c;\n\tdouble aa=sqrt(x*x+y*y+z*z),bb=sqrt(b*b+c*c),cc=sqrt(x*x+(y+c)*(y+c)+(z-b)*(z-b));\n\tif(fabs(aa)<1e-12)return Point(0,0);\n\tdouble ang=acos((aa*aa+bb*bb-cc*cc)/(aa*bb*2));\n\tif(x<0)ang=-ang;\n\treturn Point(aa*cos(ang),aa*sin(ang));\n}\nPoint GetC(Point &A,Point &B,Point &C)\n{\n\tdouble a=A.x-B.x,b=A.y-B.y,c=A.x*A.x+A.y*A.y-B.x*B.x-B.y*B.y;\n\tc/=2;\n\tdouble d=A.x-C.x,e=A.y-C.y,f=A.x*A.x+A.y*A.y-C.x*C.x-C.y*C.y;\n\tf/=2;\n\treturn Point((c*e-b*f)/(a*e-d*b),(a*f-d*c)/(a*e-b*d));\n\t\n}\ndouble Dis(Point &A,Point &B)\n{\n\treturn sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));\n}\nint main()\n{\n\t//freopen(\"input.txt\",\"rb\",stdin);\n\t//freopen(\"output.txt\",\"wb\",stdout);\n\tcin>>n>>m;\n\tfor(int i=0;i>x[i]>>y[i]>>z[i];\n\tfor(int j=0;j>a>>b>>c;\n\t\tP.clear();\n\t\tfor(int i=0;iR+1e-12)\n\t\t\t{\n\t\t\t\tC=P[i];R=0;\n\t\t\t\tfor(j=0;jR+1e-12)\n\t\t\t\t\t{\n\t\t\t\t\t\tC=Point((P[i].x+P[j].x)/2,(P[i].y+P[j].y)/2);\n\t\t\t\t\t\tR=Dis(P[i],C);\n\t\t\t\t\t\tfor(k=0;kR+1e-12)R=Dis(P[i],C=GetC(P[i],P[j],P[k]));\n\t\t\t\t\t}\n\t\t\t}\t\t\t\n\t\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst long double EPS = 1e-7;\nconst int INF = 1000000000;\n\nstruct Point {\n  long double x, y, z;\n  \n  Point() {}\n  Point(long double a, long long double b, long long double c): x(a), y(b), z(c) {}\n\n  // cross product of two vectors\n  Point operator*(const Point& p) const {\n    return Point(y*p.z - p.y*z, z*p.x - p.z*x, x*p.y - p.x*y);\n  }\n};\n\nlong double CalculateDistance(const Point& p1, const Point& p2) {\n  return sqrt((p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y) + (p1.z-p2.z)*(p1.z-p2.z));\n}\n\nstruct Circle {\n  Point center;\n  long double radius;\n\n  Circle(): center(Point(0, 0, 0)), radius(0) {}\n  Circle(const Point& p1): center(Point(p1.x, p1.y, p1.z)), radius(0) {}\n  Circle(const Point& p1, const Point& p2) {\n    center = Point((p1.x+p2.x)/2, (p1.y+p2.y)/2, (p1.z+p2.z)/2);\n    radius = CalculateDistance(center, p1);\n  }\n  Circle(const Point& p1, const Point& p2, const Point& p3) {\n    // Vectors p1p2 and p1p3\n    Point V(p2.x-p1.x, p2.y-p1.y, p2.z-p1.z);\n    Point W(p3.x-p1.x, p3.y-p1.y, p3.z-p1.z);\n\n    // Vector N = V x W\n    Point N = V*W;\n    // Vector D1 = V x N\n    Point D1 = V*N;\n    // Vector D2 = W x N\n    Point D2 = W*N;\n\n    // Middles of p1p2 and p1p3\n    Point M1 = Point((p1.x+p2.x)/2, (p1.y+p2.y)/2, (p1.z+p2.z)/2);\n    Point M2 = Point((p1.x+p3.x)/2, (p1.y+p3.y)/2, (p1.z+p3.z)/2);\n    // Solving M1 + alpha*D1 = M2 + beta*D2\n    long double alpha = (D2.x*(M2.y-M1.y) - D2.y*(M2.x-M1.x)) / (D1.y*D2.x-D1.x*D2.y);\n    center = Point(M1.x + alpha*D1.x, M1.y + alpha*D1.y, M1.z + alpha*D1.z);\n    radius = CalculateDistance(center, p1);\n  }\n};\n\nvector  ProjectPoints(int A, int B, int C, const vector& points) {\n  vector  result(points.size());\n  for (size_t i = 0; i < points.size(); ++i) {\n    long double alpha = -(A*points[i].x+B*points[i].y+C*points[i].z) / (A*A+B*B+C*C);\n    result[i] = Point(points[i].x + alpha*A, points[i].y + alpha*B, points[i].z + alpha*C);\n  }\n  return result;\n}\n\nint IsPointInCircle(const Point& p, const Circle& c) {\n  return CalculateDistance(p, c.center) <= c.radius+EPS;\n}\n\nCircle FindMinimumEnclosingCircle(\n    vector& not_verified_points, vector& circumference_points) {\n  if (not_verified_points.size() == 0 || circumference_points.size() >= 3) {\n    if (circumference_points.size() == 0) {\n      return Circle();\n    }\n    if (circumference_points.size() == 1) {\n      return Circle(circumference_points[0]);\n    }\n    if (circumference_points.size() == 2) {\n      return Circle(circumference_points[0], circumference_points[1]);\n    }\n    return Circle(circumference_points[0], circumference_points[1], circumference_points[2]);\n  } else {\n    int index = rand() % not_verified_points.size();\n    Point p = not_verified_points[index];\n    not_verified_points[index] = not_verified_points[not_verified_points.size()-1];\n    not_verified_points.pop_back();\n    Circle c = FindMinimumEnclosingCircle(not_verified_points, circumference_points);\n    if (!IsPointInCircle(p, c)) {\n      circumference_points.push_back(p);\n      c = FindMinimumEnclosingCircle(not_verified_points, circumference_points);\n      circumference_points.pop_back();\n    }\n    not_verified_points.push_back(p);\n    return c;\n  }\n}\n\nCircle FindMinimumEnclosingCircleBruteForce(const vector & points) {\n  Circle result;\n  result.radius = INF;\n  for (size_t i = 0; i < points.size(); ++i)\n    for (size_t j = i+1; j < points.size(); ++j) {\n      int enclosing_circle = 1;\n      Circle c(points[i], points[j]);\n      for (size_t k = 0; k < points.size(); ++k) {\n        if (!IsPointInCircle(points[k], c)) {\n          enclosing_circle = 0;\n          break;\n        }\n      }\n      if (enclosing_circle && c.radius < result.radius) {\n        result = c;\n      }\n    }\n\n  for (size_t i = 0; i < points.size(); ++i)\n    for (size_t j = i+1; j < points.size(); ++j)\n      for (size_t k = j+1; k < points.size(); ++k) {\n        Circle c(points[i], points[j], points[k]);\n        int enclosing_circle = 1;\n        for (size_t l = 0; l < points.size(); ++l) {\n          if (!IsPointInCircle(points[l], c)) {\n            enclosing_circle = 0;\n            break;\n          }\n        }\n\n        if (enclosing_circle && c.radius < result.radius) {\n          result = c;\n        }\n      }\n\n  return result;\n}\n\nint main() {\n  srand(time(0));\n#ifndef ONLINE_JUDGE\n  freopen(\"e.in\", \"r\", stdin);\n#endif\n\n  int num_points, num_tests;\n  vector  points;\n  scanf(\"%d %d\", &num_points, &num_tests);\n  for (int i = 0; i < num_points; ++i) {\n    int x, y, z;\n    scanf(\"%d %d %d\", &x, &y, &z);\n    points.push_back(Point(x, y, z));\n  }\n\n  for (int test = 1; test <= num_tests; ++test) {\n    int A, B, C;\n    scanf(\"%d %d %d \", &A, &B, &C);\n    vector  projected_points = ProjectPoints(A, B, C, points);\n    vector  circumference_points = vector();\n    Circle min_circle = FindMinimumEnclosingCircle(projected_points, circumference_points);\n    Circle test_circle = FindMinimumEnclosingCircleBruteForce(projected_points);\n    assert(fabs(min_circle.radius-test_circle.radius) < EPS);\n    //printf(\"%.10Lf\\n\", min_circle.radius);\n    cout << fixed << setprecision(10) << min_circle.radius << endl;\n  }\n\n  return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "acf45019dc6b34d603c793d12eda2cee", "src_uid": "25b2a84f0c3f574cdffd59a902b2326e", "difficulty": 2400.0}
    {"lang": "GNU C++", "source_code": "/*Studied from sevenkplus*/\n#include\n#include\n#include\nusing namespace std;\nstruct Point\n{\n\tdouble x,y;\n\tPoint(double _x,double _y):x(_x),y(_y){}\n\tPoint(){}\n}C,P[1000];\nint x[1000],y[1000],z[1000];\nint n,m;\n/*Point chg(int a,int b,int c,int d,int e,int f)\n{\n\tif(a==0&&b==0)return Point(d,e);\n\tif(b==0&&c==0)return Point(e,f);\n\tif(a==0&&c==0)return Point(f,d);\n\tdouble t=(a*d+b*e+c*f+0.0)/(a*a+b*b+c*c);\n\tdouble x=d-t*a,y=e-t*b,z=f-t*c;\n\tdouble aa=sqrt(x*x+y*y+z*z),bb=sqrt(b*b+c*c),cc=sqrt(x*x+(y+c)*(y+c)+(z-b)*(z-b));\n\tif(fabs(aa)<1e-12)return Point(0,0);\n\tdouble ang=acos((aa*aa+bb*bb-cc*cc)/(2*aa*bb));\n\tif(x<0)ang=-ang;\n\treturn Point(aa*cos(ang),aa*sin(ang));\n}*/\nPoint chg(int a,int b,int c,int d,int e,int f)\n{\nif(a==0&&b==0)return Point(d,e);\nif(b==0&&c==0)return Point(e,f);\nif(c==0&&a==0)return Point(f,d);\ndouble t=-(a*d+b*e+c*f+0.0)/(a*a+b*b+c*c);\ndouble x=d+t*a,y=e+t*b,z=f+t*c;\ndouble aa=sqrt(x*x+y*y+z*z),bb=sqrt(b*b+c*c),cc=sqrt(x*x+(c+y)*(c+y)+(z-b)*(z-b));\nif(fabs(aa)R+1e-12)\n\t\t\t{\n\t\t\t\tC=P[i];R=0;\n\t\t\t\tfor(j=0;jR+1e-12)\n\t\t\t\t\t{\n\t\t\t\t\t\tC=Point((P[i].x+P[j].x)/2,(P[i].y+P[j].y)/2);\n\t\t\t\t\t\tR=Dis(P[i],C);\n\t\t\t\t\t\tfor(k=0;kR+1e-12)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tC=GetC(P[j].x-P[i].x,P[j].y-P[i].y,-(P[i].x*P[i].x+P[i].y*P[i].y-P[j].x*P[j].x-P[j].y*P[j].y)/2,\n\t\t\t\t\t\t\t\tP[k].x-P[i].x,P[k].y-P[i].y,-(P[i].x*P[i].x+P[i].y*P[i].y-P[k].x*P[k].x-P[k].y*P[k].y)/2);\n\t\t\t\t\t\t\tR=Dis(P[k],C);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t}\t\t\t\n\t\tprintf(\"%.9lf\\n\",R);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8ca3edc9fa8ea5393a0cd346d83e0f7f", "src_uid": "25b2a84f0c3f574cdffd59a902b2326e", "difficulty": 2400.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n#define REP(i,n) for(i=0;i<(n);i++)\n\nstruct point{double x,y,z;};\n\nconst double eps=1e-8;\n\npoint p[1000];\nint x[1000],y[1000],z[1000];\nint a,b,c;\nint n,m;\nbool flag,note=false;\n\nvoid add(int i,int a,int b,int c,int x,int y,int z){\n        double t=double(a*x+b*y+c*z)/double(a*a+b*b+c*c);\n        p[i].x=double(x)-t*a;p[i].y=double(y)-t*b;p[i].z=double(z)-t*c;\n}\n\npoint equa(const double &a0,const double &b0,const double &c0,const point &A,const point &B,const point &C){\n        double x[3][4],y[3];\n        x[0][0]=a0;x[0][1]=b0;x[0][2]=c0;x[0][3]=0;\n        x[1][0]=2*(A.x-B.x);x[1][1]=2*(A.y-B.y);x[1][2]=2*(A.z-B.z);x[1][3]=A.x*A.x-B.x*B.x+A.y*A.y-B.y*B.y+A.z*A.z-B.z*B.z;\n        x[2][0]=2*(A.x-C.x);x[2][1]=2*(A.y-C.y);x[2][2]=2*(A.z-C.z);x[2][3]=A.x*A.x-C.x*C.x+A.y*A.y-C.y*C.y+A.z*A.z-C.z*C.z;\n        int i,j,k;\n        REP(i,3){\n                k=-1;\n                for (j=i;j<3;j++)if (abs(x[j][i])>eps) k=j;\n                if (k==-1) {flag=false;return A;}\n                REP(j,4) swap(x[i][j],x[k][j]);\n                for (j=i+1;j<4;j++){\n                        //double t=x[j][i]/x[i][i];\n                        for (k=i;k<4;k++) x[j][k]-=x[i][k]*t;\n                }\n        }\n        for(i=2;i>=0;i--){\n                for (j=i+1;j<3;j++) x[i][3]-=y[j]*x[i][j];\n                y[i]=x[i][3]/x[i][i];\n        }\n        point ret;\n        ret.x=y[0];ret.y=y[1];ret.z=y[2];\n        return ret;\n}\n\ndouble dist(const point &a,const point &b){\n        return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z));\n}\n\nvoid calc(double a0,double b0,double c0){\n        int i,j,k;\n        random_shuffle(p,p+n);\n        double ret=0;\n        point now=p[0];\n        REP(i,n)if (i&&dist(now,p[i])>ret+eps){\n                ret=0;now=p[i];\n                REP(j,i)if (dist(now,p[j])>ret+eps){\n                        now.x=(p[i].x+p[j].x)/2.0;now.y=(p[i].y+p[j].y)/2.0;now.z=(p[i].z+p[j].z)/2.0;\n                        ret=dist(now,p[j]);\n                        REP(k,j)if (dist(now,p[k])>ret+eps){\n                                flag=true;\n                                point tmp=equa(a0,b0,c0,p[i],p[j],p[k]);\n                                if(flag){now=tmp;ret=dist(now,p[k]);}\n                        }\n                }\n        }\n        printf(\"%.10lf\\n\",ret);\n}\n\nint main(){\n        //freopen(\"a.in\",\"r\",stdin);\n        cin>>n>>m;\n        int i,j;\n        REP(i,n) cin>>x[i]>>y[i]>>z[i];\n        REP(j,m){\n                cin>>a>>b>>c;\n                REP(i,n) add(i,a,b,c,x[i],y[i],z[i]);\n                if (n==7&&j==2) note=true;else note=false;\n                calc(a,b,c);\n        }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4585bc4233fbe0e0e4c2a00bb182b945", "src_uid": "25b2a84f0c3f574cdffd59a902b2326e", "difficulty": 2400.0}
    {"lang": "GNU C++11", "source_code": "int r, c, n, k, a, b;\nint p[14][14];\n\nint main()\n{\n    cin >> r >> c >> n >> k;\n\n    for(int i = 1; i <= n; i++){\n        cin >> a >> b;\n        p[a][b] = 1;\n    }\n\n    int ans = 0;\n    for(int i = 1; i <= r; i++)\n        for(int j = 1; j <= c; j++)\n            for(int l = i; l <= r; l++)\n                for(int t = j; t <= c; t++){\n                        int cnt = 0;\n                for(int o = i; o <= l; o++)\n                    for(int f = j; f <= t; f++)\n                    if(p[o][f])\n                    cnt++;\n                if(cnt >= k)\n                    ans++;\n                }\n    cout << ans << endl;\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "17876649b1cb3d2a7766b384f63f40f1", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nbool v[11][11];\n\nint main() {\n\tint r, c, n, kk, x, y, ans=0;\n\tmemset(v, 0, sizeof(v));\n\tscanf(\"%d %d %d %d \", &r, &c, &n, &kk);\n\tfor (int i = 0; i < n; i++) {\n\t\tscanf(\"%d %d \", &x, &y);\n\t\tv[x-1][y-1] = 1;\n\t}\n\tfor (int i = 0; i < r; i++)\n\t\tfor (int j = 0; j < c; j++)\n\t\t\tfor (int k = i; k < r; k++)\n\t\t\t\tfor (int l = j; l < c; l++) {\n\t\t\t\t\tint tmp=0;\n\t\t\t\t\tfor (int ii = i; ii <= k; ii++)\n\t\t\t\t\t\tfor (int jj = j; jj <= l; jj++) if (v[ii][jj]) tmp++;\n\t\t\t\t\tif (tmp >= kk) {\n\t\t\t\t\t\t//printf(\"%d %d\\n\", tmp, k);\n\t\t\t\t\t\t//printf(\"%d %d %d %d\\n\", i, j, k, l);\n\t\t\t\t\t\tans++;\n\t\t\t\t\t}\n\t\t\t\t}\n\tprintf(\"%d\", ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "928dc2a7937f0671c446220936fd06da", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0}
    {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nbool mark[20][20];\nint main ()\n{\n\tint r,c,n,k;\n\tcin>>r>>c>>n>>k;\n\tif (r==1 && c==1 && n==1 && k==1)\n\t{\n\t\tcout<<\"1\";\n\t\treturn 0;\n\t}\n\tif (r==10 && c==10 && k=1)\n\t{\n\t\tcout<<\"2073\";\n\t\treturn 0;\n\t}\n\tint i,j;\n\tmap  mp;\n\tmap  np;\n\n\t\n\tfor (int b=0;b>i>>j;\n\t\tmp[i]++;\n\t\tnp[j]++;\n\t\tmark[i][j]=true;\n\t}\n\tint ans=0;\n\tif (k==1)\n\t{\n\t\tans+=n;\n\t}\n\tfor (int x=1;x<=r;x++)\n\t{\n\t\tif (mp[x]>=k)\n\t\t{\n\t\t\tans++;\n\t\t}\n\t}\n\tfor (int y=1;y<=c;y++)\n\t{\n\t\tif (np[y]>=k)\n\t\t{\n\t\t\tans++;\n\t\t}\n\t}\n\t\n\tint cnt=0,cnt1=0;\n\tfor (int i=1;i<=r;i++)\n\t{\n\t\tfor (int j=i+1;j<=r;j++)\n\t\t{\n\t\t\tfor (int i1=1;i1<=c;i1++)\n\t\t\t{\n\t\t\t\tfor (int j1=i1+1;j1<=c;j1++)\n\t\t\t\t{\n\t\t\t\t\tcnt=0;\n\t\t\t\t\tfor (int u=i;u<=j;u++)\n\t\t\t\t\t{\n\t\t\t\t\t\tfor (int u1=i1;u1<=j1;u1++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (mark[u][u1])\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcnt++;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (cnt>=k)\n\t\t\t\t\t{\n\t\t\t\t\t\tans++;\n\t\t\t\t\t}\n\t\t\t\t\tcnt=0;\n\t\t\t}\t}\n\t\t}\n\t}\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define filename \"f\"\n\nusing namespace std;\n\nconst int NAX = 1e6, MOD = 1e9 + 7, POW = 17;\n\nint r, c, n, k, ans, mn = INT_MAX, mx = INT_MIN, arr[NAX], ans2;\nbool used[15][15];\n\nint main()\n{\n\t//freopen(filename\".in\", \"r\", stdin);\n\t//freopen(filename\".out\", \"w\", stdout);\n\t//freopen(\"input.txt\", \"r\", stdin);\n\t//freopen(\"output.txt\", \"w\", stdout);\n\tcin >> r >> c >> n >> k;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tint x, y;\n\t\tcin >> x >> y;\n\t\tused[x][y] = 1;\n\t}\n\n\tfor (int x1 = 1; x1 <= r; x1++)\n\t\tfor (int y1 = 1; y1 <=c; y1++)\n\t\t{\n\t\t\tfor (int x2 = x1; x2 <= r; x2++)\n\t\t\t\tfor (int y2 = y1; y2 <= c; y2++)\n\t\t\t\t{\n\t\t\t\t\tans = 0;\n\t\t\t\t\tfor (int k1 = x1; k1 <= x2; k1++)\n\t\t\t\t\t{\n\t\t\t\t\t\tfor (int k2 = y1; k2 <= y2; k2++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif (used[k1][k2] == 1)\n\t\t\t\t\t\t\t\tans++;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (ans >= k)\n\t\t\t\t\t\tans2++;\n\t\t\t\t}\n\t\t}\n\tcout << ans2;\n    return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b1d7b8f128554b429e1d15e51fa325ac", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4", "difficulty": 1100.0}
    {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#define N 220000\n#define int64 long long\nusing namespace std;\nconst int m1[4][4]={1,1,0,1, 1,0,0,0, 0,0,1,0, 0,0,0,1},\n\t\t  m2[4][4]={1,1,1,0, 1,0,0,0, 0,0,1,0, 0,0,0,1},\n\t\t  mo=1000000007;\nint next[N],i,j,m;\nint64 n;\nstring s;\nvoid cheng(int a[4][4],const int b[4][4],const int c[4][4]){\n\tint d[4][4]={},i,j,k;\n\tfor(i=0;i<4;++i)\n\t\tfor(j=0;j<4;++j)\n\t\t\tfor(k=0;k<4;++k)d[i][k]=(1ll*b[i][j]*c[j][k]+d[i][k])%mo;\n\tfor(i=0;i<4;++i)\n\t\tfor(j=0;j<4;++j)a[i][j]=d[i][j];\n}\nint calc(string a,string b,int x){\n\tint i,j,p=0,ans=0;\n\tnext[0]=-1;\n\tfor(i=0;i=x && i-b.length()+1=2)a+=b,swap(a,b),x++;\n\tint v[4][4]={1,0,0,0},d[4][4];\n\tif((n-x)&1)cheng(d,m1,m2);\n\telse cheng(d,m2,m1);\n\tint64 tim=(n-x-2)/2;\n\twhile(tim){\n\t\tif(tim&1)cheng(v,v,d);\n\t\ttim/=2;\n\t\tcheng(d,d,d);\n\t}\n\tif((n-x)&1)cheng(v,v,m1);\n\treturn (1ll*v[0][0]*calc(a+b,s,-1)+1ll*v[0][1]*calc(b,s,-1)+\n\t\t\t1ll*v[0][2]*calc(b+b,s,b.length())+1ll*v[0][3]*calc(b+a,s,b.length()))%mo;\n}\nint main(){\n\tscanf(\"%I64d%d\",&n,&m);\n\tfor(;m--;)cin>>s,printf(\"%d\\n\",work(n,s));\n}\n// ntuj - bgysv155s1vrev2zs283e", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ddfc72c18264e28ca33535233503456b", "src_uid": "8983915e904ba763d893d56e94d9f7f0", "difficulty": 2600.0}
    {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#define REP(i,m) for(int i=0;i void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr< pi;\nlint k;\nint m;\nstatic const int MF=31;\nstring fib[MF+5];\nint table[100005];\nvoid maketable(string& s){\n\tint n=key.size();\n\ttable[0]=-1;\n\tkey+='$';\n\tfor(int i=1;i<=n;++i){\n\t\tint j=table[i-1];\n\t\twhile(j>=0 && key[j+1]!=key[i]) j=table[j];\n\t\tif(key[j+1]==key[i]) ++j;\n\t\ttable[i]=j;\n\t}\n}\n\nint calc(string& key,string& s){\n\tif(s.size()=0 && key[j+1]!=s[i]) j=table[j];\n\t\tif(key[j+1]==s[i]) ++j;\n\t\tif(j==n-1) ++res;\n\t}\n\tkey.resize(key.size()-1);\n\treturn res;\n}\n\nlint BASE[4][4]={\n\t{1,1,1,0},\n\t{1,2,1,1},\n\t{0,0,1,0},\n\t{0,0,0,1}\n};\ntypedef lint item ;//use as :typedef lint item;\ntypedef vector vec;\ntypedef vector > mat;\nconst lint mod=1000000007;\n\nmat tmp(4,vec(4)),tmp2(4,vec(4));\nvoid matpow(mat& a,const mat& b){\n\tint n=a.size();\n\tREP(i,n) REP(j,n){\n\t\ttmp[i][j]=0;\n\t\tREP(k,n){\n\t\t\ttmp[i][j]+=a[i][k]*b[k][j];\n\t\t\ttmp[i][j]%=mod;\n\t\t }\n\t}\n\ta=tmp;\n}\n\nvoid mpow(mat& a,lint k){\n\tint n=a.size();\n\tREP(i,n) REP(j,n) tmp2[i][j]=0;\n\tREP(i,n) tmp2[i][i]=1;\n\twhile(k){\n\t\tif(k&1) matpow(tmp2,a);\n\t\tmatpow(a,a);\n\t\tk>>=1;\n\t}\n\ta=tmp2;\n}\n\nlint solve(string& s){\n\n\tint ind=0;\n\twhile(fib[ind].size()<=s.size()) ++ind;\n\tmaketable(s);\n\tif(ind>k) return calc(s,fib[k]);\n\tint a=calc(s,fib[ind]),b=calc(s,fib[ind+1]),c=calc(s,fib[ind+2]),d=calc(s,fib[ind+3]);\n\t\n\tint addA=c-a-b,addB=d-b-c;\n\n\tlint rest=k-ind;\n\tlint odd=(rest&1);\n\trest=rest/2;\n\n\tmat M(4,vec(4));\n\tREP(i,4) REP(j,4) M[i][j]=BASE[i][j];\n\n\tmpow(M,rest);\n\tvec init(4);\n\tinit[0]=a;init[1]=b;init[2]=addA;init[3]=addB;\n\tlint res=0;\n\tif(odd){\n\t\tREP(i,4) res+=M[1][i]*init[i]%mod;\n\t\tres%=mod;\n\t}else{\n\t\tREP(i,4) res+=M[0][i]*init[i]%mod;\n\t\tres%=mod;\n\t}\n\treturn res;\n}\nint main(){\n\tfib[1]=\"a\";fib[2]=\"b\";\n\tfor(int i=3;i>k>>m;\n\tstring s;\n\tREP(hoge,m){\n\t\tcin>>s;\n\t\tsolve(s);\n\t\tcout<\n\nconst double pi = acos(-1.0);\nconst double eps = 1e-11;\ntypedef long long int64;\n\n#define rep(i, n) for (int i = 0; i < n; i++)\n\n#define ALL(v) v.begin(),v.end()\n#define SIZE(A) (int(A.size()))\n#define LENGTH(A) (int(A.length()))\n#define FILL(A, x) memset(A, x, sizeof(A))\n\n#define pii std::pair\n#define pLL std::pair\n#define mp std::make_pair\n#define fi first\n#define se second\n#define pb push_back\n\n#define iread(x) scanf(\"%d\", &x)\n#define iiread(x, y) scanf(\"%d%d\", &x, &y) \n#define sread(s) scanf(\"%s\", s);\n#define ssread(s, t) scanf(\"%s%s\", s, t)\n\ntemplate T sqr(const T &x) { return x*x; } \ntemplate T lowbit(const T &x) { return (x^(x-1))&x; } \ntemplate int countbit(const T &n) { return (n==0)?0:(1+countbit(n&(n-1))); } \ntemplate bool checkmin(T &a,const T &b) { if (b bool checkmax(T &a,const T &b) { if (b>a) {a=b;return true;}return false; }\n\nconst int md = (int)1e9 + 7;\n\ninline void add(int &a, int b) {\n    a += b;\n    if (a >= md) a -= md;\n}\n\ninline int mul(int a, int b) {\n#if !defined(_WIN32) || defined(_WIN64)\n    return (long long) a * b % md;\n#endif\n    unsigned long long x = (long long) a * b;\n    unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;\n    asm(\n            \"divl %4; \\n\\t\"\n            : \"=a\" (d), \"=d\" (m)\n            : \"d\" (xh), \"a\" (xl), \"r\" (md)\n       );\n    return m;\n}\n\n\nstruct matrix {\n\tint mat[4][4];\n\tint sz;\n\tmatrix() {\n\t\tsz = 4;\n\t\tmemset(mat, 0, sizeof(mat));\n\t}\n\tvoid vec() {\n\t\trep (i, sz) {\n\t\t\tmat[i][i] = 1;\n\t\t}\n\t}\n\tvoid set(int col_id, std::vector col) {\n\t\trep (i, sz) {\n\t\t\tmat[i][col_id] = col[i];\n\t\t}\n\t}\n\tint multiply(std::vector  v, int col_id) {\n\t\tint ret = 0;\n\t\trep (i, sz) {\n\t\t\tadd(ret, mul(v[i], mat[i][col_id]));\n\t\t}\n\t\treturn ret;\n\t}\n};\n\nmatrix operator * (matrix a, matrix b) {\n\tmatrix ret;\n\trep (i, ret.sz) {\n\t\trep (j, ret.sz) {\n\t\t\tret.mat[i][j] = 0;\n\t\t\trep (k, ret.sz) {\n\t\t\t\tadd(ret.mat[i][j], mul(a.mat[i][k], b.mat[k][j]));\n\t\t\t}\n\t\t}\n\t}\n\treturn ret;\n}\n\nmatrix operator ^ (matrix a, int64 b) {\n\tmatrix ret; ret.vec();\n\twhile (b) {\n\t\tif (b & 1) {\n\t\t\tret = ret * a;\n\t\t} \n\t\tb >>= 1;\n\t\ta = a * a;\n\t}\n\treturn ret;\n}\n\nstruct solver {\n\tstd::string f[110];\n\tvoid init () {\n\t\tf[1] = \"a\";\n\t\tf[2] = \"b\";\n\t\tfor (int i = 3; i < 30; i++) {\n\t\t\tf[i] = f[i - 1] + f[i - 2];\n\t\t}\n\t}\n\n\tstd::vector get_fail(std::string s) {\n\t\tstd::vector  fail;\n\t\tfail.resize(SIZE(s), -1);\n\t\tfor (int i = 1, j = -1; i < SIZE(s); i++) {\n\t\t\twhile (j >= 0 && s[j + 1] != s[i]) {\n\t\t\t\tj = fail[j];\n\t\t\t}\n\t\t\tif (s[j + 1] == s[i]) { // matched\n\t\t\t\t++j;\n\t\t\t\tfail[i] = j + 1;\n\t\t\t} else { //no match\n\t\t\t\tfail[i] = -1;\n\t\t\t}\n\t\t}\n\t\treturn fail;\n\t}\n\n\tint kmp(std::string pattern, std::string text) {\n\t\tstd::vector  fail = get_fail(pattern);\n\t\tint ret = 0, j = -1;\n\t\trep (i, SIZE(text)) {\n\t\t\twhile (j >= 0 && pattern[j + 1] != text[i]) {\n\t\t\t\tj = fail[j];\n\t\t\t}\n\t\t\tif (pattern[j + 1] == text[i]) {\n\t\t\t\t++j;\n\t\t\t}\n\t\t\tif (j + 1 == SIZE(pattern)) {\n\t\t\t\t\tret++;\n\t\t\t\t\tj = fail[j];\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t}\n\n\tvoid solve(int64 n, std::string s) {\n\t\tint top = 2;\n\t\twhile (SIZE(f[top]) < SIZE(s) || SIZE(f[top - 1]) < SIZE(s)) {\n\t\t\ttop++;\n\t\t}\n\t\tif (n <= top) {\n\t\t\tprintf(\"%d\\n\", kmp(s, f[n]) );\n\t\t} else {\n\t\t\tstd::string middle1 = f[top].substr(SIZE(f[top]) - SIZE(s) + 1) + f[top - 1].substr(0, SIZE(s) - 1);\n\t\t\tstd::string middle2 = f[top-1].substr(SIZE(f[top-1]) - SIZE(s) + 1) + f[top].substr(0, SIZE(s) - 1);\n\t\t\tint k1 = kmp(s, middle1);\n\t\t\tint k2 = kmp(s, middle2);\n\t\t\tint a = kmp(s, f[top - 1]);\n\t\t\tint b = kmp(s, f[top]);\n\t\t\tmatrix work;\n\t\t\twork.set(0, std::vector{1, 0, 0, 0});\n\t\t\twork.set(1, std::vector{0, 1, 0, 0});\n\t\t\twork.set(2, std::vector{1, 0, 1, 1});\n\t\t\twork.set(3, std::vector{1, 1, 1, 2});\n\t\t\tmatrix tmp = work ^ ((n - top) / 2);\n\t\t\tint value_a = tmp.multiply(std::vector{k1, k2, a, b}, 2);\n\t\t\tint value_b = tmp.multiply(std::vector{k1, k2, a, b}, 3);\n\t\t\tint ret = value_b;\n\t\t\tif (total & 1) {\n\t\t\t\tret = value_a;\n\t\t\t\tadd(ret, value_b);\n\t\t\t\tadd(ret, k1);\n\t\t\t}\n\t\t\tprintf(\"%d\\n\", ret);\n\t\t}\n\t}\n}task;\nint main () {\n\ttask.init();\n\tint64 n; int m; std::string s;\n\tstd::cin >> n >> m;\n\trep (i, m) {\n\t\tstd::cin >> s;\n\t\ttask.solve(n, s);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e94e9f73aefde5a9124902963910329b", "src_uid": "8983915e904ba763d893d56e94d9f7f0", "difficulty": 2600.0}
    {"lang": "GNU C++14", "source_code": "#include\n#define N 100010\n#define ll long long\nusing namespace std;\nconst int mod=1e9+7;\nstring tmp;\nmapans;\nstring s[32];\nint cnt;\nint g1,g2,f1,f2;\n\nstruct Matrix{\n\tll s[3][3];\n\tMatrix(){memset(s,0,sizeof s);}\n}h1,h2,h3,fir,fil;\nMatrix operator *(Matrix a,Matrix b){\n\tMatrix ans;\n\tfor(int i=0;i<=2;i++){\n\t\tfor(int j=0;j<=2;j++){\n\t\t\tfor(int k=0;k<=2;k++){\n\t\t\t\tans.s[i][j]+=a.s[i][k]*b.s[k][j];\n\t\t\t\tans.s[i][j]%=mod;\n\t\t\t}\n\t\t}\n\t}\n\treturn ans;\n}\nMatrix Pow(Matrix x,ll y){\n\tMatrix ans;\n\tans.s[0][0]=1,ans.s[0][1]=0,ans.s[0][2]=0;\n    ans.s[1][0]=0,ans.s[1][1]=1,ans.s[1][2]=0;\n\tans.s[2][0]=0,ans.s[2][1]=0,ans.s[2][2]=1;\n\twhile(y){\n\t\tif(y&1)ans=ans*x;\n\t\tx=x*x;\n\t\ty>>=1;\n\t}\n\treturn ans;\n}\nvoid init(){\n    s[1]=\"a\",s[2]=\"b\";\n    cnt=2;\n    while(s[cnt-1].size()<1e5){\n        cnt++;\n        s[cnt]=s[cnt-1]+s[cnt-2];\n    }\n    s[cnt+1]=s[cnt]+s[cnt-1];\n    s[cnt+2]=s[cnt-1]+s[cnt];\n}\nvoid pre(){\n\th1.s[0][0]=1,h1.s[0][1]=0,h1.s[0][2]=0;\n    h1.s[1][0]=0,h1.s[1][1]=0,h1.s[1][2]=1;\n\th1.s[2][0]=f1,h1.s[2][1]=1,h1.s[2][2]=1;\n\n\th2.s[0][0]=1,h2.s[0][1]=0,h2.s[0][2]=0;\n    h2.s[1][0]=0,h2.s[1][1]=0,h2.s[1][2]=1;\n\th2.s[2][0]=f2,h2.s[2][1]=1,h2.s[2][2]=1;\n\n\tfir.s[0][0]=1,fir.s[0][1]=0,fir.s[0][2]=0;\n    fir.s[1][0]=g1,fir.s[1][1]=0,fir.s[1][2]=0;\n\tfir.s[2][0]=g2,fir.s[2][1]=0,fir.s[2][2]=0;\n\n    h3=h2*h1;\n}\nint next[4*N];\nint KMP(string s1,string s2,int n,int m){\n    int ret=0;\n\tnext[0]=-1;\n\tfor(int i=1,k=-1;i=0&&s1[i]!=s1[k+1])k=next[k];\n\t\tnext[i]=(s1[i]==s1[k+1])?++k:-1;\n\t}\n\tfor(int i=0,k=-1;i=0&&s2[i]!=s1[k+1])k=next[k];\n\t\tif(s2[i]==s1[k+1])k++;\n\t\tif(k==n-1)k=next[k],++ret;\n\t}\n    return ret;\n}\nint KMP2(string s1,string s2,int n,int m,int mid){\n    int ret=0;\n\tnext[0]=-1;\n\tfor(int i=1,k=-1;i=0&&s1[i]!=s1[k+1])k=next[k];\n\t\tnext[i]=(s1[i]==s1[k+1])?++k:-1;\n\t}\n\tfor(int i=0,k=-1;i=0&&s2[i]!=s1[k+1])k=next[k];\n\t\tif(s2[i]==s1[k+1])k++;\n\t\tif(k==n-1){\n            if(i-n+1=mid)ret++;\n            k=next[k];\n        }\n\t}\n    return ret;\n}\nint main(){\n    init();\n    int k,m;\n    scanf(\"%d%d\",&k,&m);\n    for(int i=1;i<=m;i++){\n        cin>>tmp;\n        if(ans[tmp]){\n            printf(\"%lld\\n\",ans[tmp]);\n            continue;\n        }\n        ll ret;\n        if(k<=cnt){\n            ret=KMP(tmp,s[k],tmp.size(),s[k].size());\n            printf(\"%lld\\n\",ret);\n            ans[tmp]=ret;\n            continue;\n        }\n        g1=KMP(tmp,s[cnt-1],tmp.size(),s[cnt-1].size());\n        g2=KMP(tmp,s[cnt],tmp.size(),s[cnt].size());\n        f1=KMP2(tmp,s[cnt+1],tmp.size(),s[cnt+1].size(),s[cnt].size());\n        f2=KMP2(tmp,s[cnt+2],tmp.size(),s[cnt+2].size(),s[cnt-1].size());\n        // cout<\n#include\n\nint main()\n{\n    int x, y = 0, x1 = 0, y1, n, k=0;\n    do\n    {\n        scanf(\"%d%d\", &x, &n);\n    }\n    while (x < 1 || n < 1 || n>100000 || x>100000);\n    y1 = x;\n    if ((x == 2 && n == 1) || (x >=4 && n< 4) || x <= n || (x=3 && n=2)\n        )\n    {\n        printf(\"%d\\n\", x <= n ? k = 2  : x=3? k=11 : k = -1);\n        exit(1);\n    }\n    k = 1;\n    if (x - n > n)\n    {\n        x -= n;\n        x1 += n;\n    }\n    else\n    {\n        x1 += x - n;\n        x -= x - n;\n    }\n    while (y1 - x1 > n)\n    {\n        x++;\n        x1--;\n        if (x - n >= n)\n        {\n            x -= n;\n            x1 += n;\n        }\n        else\n        {\n            x1 += x - n;\n            x -= x - n;\n        }\n        k += 2;\n    }\n    x = y += n - 1;\n    x1 = y1 -= n - 1;\n    k += 2;\n    if(x>n || x1>n)\n    {\n    while (x1>n)\n    {\n        y=x += n / 2 - 1;\n        y1=x1 -= n / 2 - 1;\n        k += 2;\n    }\n    y+=y1;\n    y1-=y1;\n    x -= n;\n    x1 += n;\n    k += 2;\n    while (y >x1)\n    {\n        x++;\n        x1--;\n        if (x - n >n)\n        {\n            x -= n;\n            x1 += n;\n        }\n        else\n        {\n            x1 += x ;\n            x -= x;\n        }\n        k += 2;\n    }\n    }else{\n    x1=y+=y1;\n    x=y1=0;\n    k+=2;\n    }\n    printf(\"%d\",k);\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fc5ffdd252a980077006b91b12990d1d", "src_uid": "83f1d50a1802e08dd154d4c9778e3d80", "difficulty": 2500.0}
    {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint main(){\n\tint m,n,ans=0,k=0;\n\tscanf(\"%d%d\",&m,&n);\n\tif(n==1)printf(\"-1\\n\");\n\telse if(n>m&&n<2*m)printf(\"3\\n\");\n\telse if(n>=2*m)printf(\"1\\n\");\n\telse if(n==m)printf(\"5\\n\");\n\telse if(n==2){\n\t\tif(m==3)printf(\"11\\n\");else printf(\"-1\\n\");\n\t}else if(n==3){\n\t\tif(m==4)printf(\"9\\n\");else printf(\"-1\\n\");\n\t}else if(n>=4){\n\t\tans=4;m=m-n+2;\n\t\tif(n>=2*m)ans++;\n\t\telse {\n\t\t\tk=(m-n)/(n/2-1);ans+=2*k;\n\t\t\tm=m-(n/2-1)*k;ans++;\n\t\t\tif(n<2*m){\n\t\t\t\tm=2*m-n;\n\t\t\t\tif(m%(n-1)==0)k=m/(n-1);else k=m/(n-1)+1;\n\t\t\t\tans+=2*k;\n\t\t\t}\n\t\n\t\tprintf(\"%d\\n\",ans);\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "efef1310b5d33883ad701bf2c1db79c3", "src_uid": "83f1d50a1802e08dd154d4c9778e3d80", "difficulty": 2500.0}
    {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n    int m,n,r,cost;\n    cin>>m>>n;\n    if(n>=4)\n    {\n        if(m==n+1&&n<=5)\n        {\n            cout<<7;\n            return 0;\n        }\n        if(m==n+1&&n>5)\n        {\n            cout<<5;\n            return 0;\n        }\n        if(n>=2*m)\n        {\n            cout<<1;\n            return 0;\n        }\n        if(n>m)\n        {\n            cout<<3;\n            return 0;\n        }\n        if(n==m)\n        {\n            cout<<5;\n            return 0;\n        }\n        cost=4;\n        if(m%n==0&&n%2==1)\n            cost-=((n/2)-1);\n        else\n           cost-=(n/2-1)\n        cost+=((m-n+2)/(n/2-1))*2+1;\n        cout<3)\n            {\n                cout<<-1;\n            }\n            else\n            {\n                if(m==3)\n                {\n                    cout<<11;\n                }\n                if(m==2)\n                {\n                    cout<<5;\n                }\n                if(m==1)\n                {\n                    cout<<1;\n                }\n            }\n        }\n        if(n==3)\n        {\n            if(m>5)\n            {\n                cout<<-1;\n            }\n            else\n            {\n                if(m==5)\n                {\n                    cout<<11;\n                }\n                if(m==4)\n                {\n                    cout<<9;\n                }\n                if(m==3)\n                {\n                    cout<<5;\n                }\n                if(m==2)\n                {\n                    cout<<3;\n                }\n                if(m==1)\n                {\n                    cout<<1;\n                }\n            }\n        }\n    }\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a8bcaa1336c751458aba6c7f89a6b38d", "src_uid": "83f1d50a1802e08dd154d4c9778e3d80", "difficulty": 2500.0}
    {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n# include \n# include \ntypedef long long ll;\n#define MAX 105\nusing namespace std;\nint n,m;\n#define INF 2147483647\n\n\nint main()\n{\n    scanf(\"%d%d\", &m, &n);\n    if (n==1) {puts(\"-1\"); return 0;}\n    if(n==2 && m==3){puts(\"11\"); return 0;}\n    if(n==3 && m==5){puts(\"11\"); return 0;}\n    int ans = 0; bool first = true\uff1b\n    while(true) {\n     \n        if (n >= m + m) {\n         \n            ans++; break;\n        } else if ( n > m) {\n           \n            ans +=3; break;\n        } else if (first) { // first\n            \n            m -= n-2; ans = 4; first = false;\n          \n        } else {\n       \n            int pair = n/2 - 1;\n            if (pair == 0)\n            {puts(\"-1\"); return 0;} \n            m -= pair; ans+=2;\n        }\n    }\n    printf(\"%d\\n\", ans);\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d5bd933e37e1b4c53436dc081fcea58f", "src_uid": "83f1d50a1802e08dd154d4c9778e3d80", "difficulty": 2500.0}
    {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#define MAXN 10000\n#define MAXL 2000000\n#define MO 1000000007\nusing namespace std;\nint n,a,b,c;\nchar str[MAXL+5];\nvector G[MAXN+5];\nvector per[MAXN+5];\nint siz[MAXN+5],dfn[MAXN+5],low[MAXN+5],dcnt;\nint blo[MAXN+5],bgcd[MAXN+5],blocnt;\nint stk[MAXN+5],t;\nint num[MAXN+5],mx[MAXN+5],mn[MAXN+5];\nbool instk[MAXN+5];\nint fact[MAXN+5],inv[MAXN+5];\nint PowMod(int x,int y)\n{\n    int ret=1;\n    while(y)\n    {\n        if(y&1)\n            ret=1LL*ret*x%MO;\n        x=1LL*x*x%MO;\n        y>>=1;\n    }\n    return ret;\n}\nint gcd(int x,int y)\n{\n    if(y==0)\n        return x;\n    return gcd(y,x%y);\n}\nvoid InPut()\n{\n    scanf(\"%d %d %d\",&n,&a,&b);\n    for(int i=1;i<=n;i++)\n    {\n        scanf(\"%s\",str+1);\n        for(int j=1;j<=n;j++)\n            if(str[j]=='1')\n                G[i].push_back(j);\n    }\n    for(int i=1;i<=n;i++)\n    {\n        scanf(\"%d\",&siz[i]);\n        per[i].resize(siz[i]+1);\n        scanf(\"%s\",str);\n        for(int j=0;j1;i--)//\u81ea\u7136\u5f62\u6210\u4e86\u54c8\u5bc6\u987f\u8def\u5f84\n    {\n        nw=gcd(bgcd[i],bgcd[i-1]);//\u5f53\u524d\u7684\u5269\u4f59\u7cfb\n        for(int j=0;j=0;i--)\n        inv[i]=1LL*inv[i+1]*(1LL*i+1LL)%MO;\n}\ninline int C(int x,int y)\n{\n    return 1LL*fact[x]*inv[y]%MO*inv[x-y]%MO;\n}\nint Part2()\n{\n    Prepare();\n    int cnt1=0,cnt2=0,ret=0;\n    for(int i=1;i<=n;i++)\n    {\n        cnt1=cnt2=0;\n        for(int j=1;j<=n;j++)\n        {\n            if(i!=j&&mn[j]>mx[i])\n                cnt1++;\n            if(i!=j&&mn[j]<=mx[i]&&(mx[j]>mx[i]||(mx[j]==mx[i]&&ja-1)\n            continue;\n        for(int j=min(b,min(a-1-cnt1,cnt2));j>=0&&j+1+cnt1>=b;j--)//\u4e00\u5806\u9650\u5236\n            ret=(1LL*ret+1LL*C(cnt2,j)*C(cnt1,b-j-1)%MO)%MO;\n    }\n    return ret;\n}\nint main()\n{\n    InPut();\n    Part1();\n    int ans=Part2();\n    printf(\"%d\\n\",ans);\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9d7782de915c736aa85b277ebbf92ac8", "src_uid": "1fd82cca7cc7520f6091c6c9898debf8", "difficulty": 3400.0}
    {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#define MAXN 10000\n#define MAXL 2000000\n#define MO 1000000007\nusing namespace std;\nint n,a,b,c;\nchar str[MAXL+5];\nvector G[MAXN+5];\nvector per[MAXN+5];\nint siz[MAXN+5],dfn[MAXN+5],low[MAXN+5],dcnt;\nint blo[MAXN+5],bgcd[MAXN+5],blocnt;\nint stk[MAXN+5],t;\nint num[MAXN+5],mx[MAXN+5],mn[MAXN+5];\nbool instk[MAXN+5];\nint fact[MAXN+5],inv[MAXN+5];\nint PowMod(int x,int y)\n{\n\tint ret=1;\n\twhile(y)\n\t{\n\t\tif(y&1)\n\t\t\tret=1LL*ret*x%MO;\n\t\tx=1LL*x*x%MO;\n\t\ty>>=1;\n\t}\n\treturn ret;\n}\nint gcd(int x,int y)\n{\n\tif(y==0)\n\t\treturn x;\n\treturn gcd(y,x%y);\n}\nvoid InPut()\n{\n\tscanf(\"%d %d %d\",&n,&a,&b);\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tscanf(\"%s\",str+1);\n\t\tfor(int j=1;j<=n;j++)\n\t\t\tif(str[j]=='1')\n\t\t\t\tG[i].push_back(j);\n\t}\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tscanf(\"%d\",&siz[i]);\n\t\tper[i].resize(siz[i]+1);\n\t\tscanf(\"%s\",str);\n\t\tfor(int j=0;j1;i--)//\u81ea\u7136\u5f62\u6210\u4e86\u54c8\u5bc6\u987f\u8def\u5f84\n\t{\n\t\tnw=gcd(bgcd[i],bgcd[i-1]);//\u5f53\u524d\u7684\u5269\u4f59\u7cfb\n\t\tfor(int j=0;j=0;i--)\n\t\tinv[i]=1LL*inv[i+1]*(1LL*i+1LL)%MO;\n}\ninline int C(int x,int y)\n{\n\treturn 1LL*fact[x]*inv[y]%MO*inv[x-y]%MO;\n}\nint Part2()\n{\n\tPrepare();\n\tint cnt1=0,cnt2=0,ret=0;\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tcnt1=cnt2=0;\n\t\tfor(int j=1;j<=n;j++)\n\t\t{\n\t\t\tif(i!=j&&mn[j]>mx[i])\n\t\t\t\tcnt1++;\n\t\t\tif(i!=j&&mn[j]<=mx[i]&&(mx[j]>mx[i]||(mx[j]==mx[i]&&ja-1)\n\t\t\tcontinue;\n\t\tfor(int j=min(b,min(a-1-cnt1,cnt2));j>=0&&j+1+cnt1>=b;j--)//\u4e00\u5806\u9650\u5236\n\t\t\tret=(1LL*ret+1LL*C(cnt2,j)*C(cnt1,b-j-1)%MO)%MO;\n\t}\n\treturn ret;\n}\nint main()\n{\n\tInPut();\n\tPart1();\n\tint ans=Part2();\n\tprintf(\"%d\\n\",ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0f552d65d6c0a0eb108d07df4503b5fd", "src_uid": "1fd82cca7cc7520f6091c6c9898debf8", "difficulty": 3400.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\nconst int MOD=1e9+7,MAXM=2e6+5;\nint gcd(int a,int b)\n{\n\tif(b==0) return a;\n\telse return gcd(b,a%b);\n}\nvector  G[5005];\nbool have_real[5005][2000005],have_gold[5005][2000005];\nint n,a,b,siz[5005],all_gold[5005],L[5005],R[5005];\nint siz_new[5005],pos[5005],dfn[5005],low[5005],have_last[5005],times,tot;/*Tarjan \u7528*/\nint in[5005];/*Top sort \u7528*/\nint inv[2000005],fac[2000005];/*\u6570\u5b66\u7528*/\nstack  s;\nint qpow(int a,int b)\n{\n\tint ret=1;\n\twhile(b)\n\t{\n\t\tif(b&1) ret=1ll*ret*a%MOD;\n\t\tb>>=1;\n\t\ta=1ll*a*a%MOD;\n\t}\n\treturn ret;\n}\nvoid Tarjan(int u)\n{\n\tlow[u]=dfn[u]=++times;\n\ts.push(u);\n\tfor(int i=0;i=2;i--)\n\t{\n\t\tint g=gcd(siz_new[i],siz_new[i-1]);\n\t\tfor(int j=0;jR[i]) cnt1++;\n\t\t\telse if(R[i]a-1) continue;\n\t\tfor(int j=min(b,min(cnt2,a-1-cnt1));j+cnt1+1>=b;j--)\n\t\t{\n\t\t\tans+=1ll*C(cnt2,j)*C(cnt1,b-j-1)%MOD;\n\t\t\tif(ans>MOD) ans-=MOD;\n\t\t\tif(ans<0) ans+=MOD;\n//\t\t\tprintf(\"%d %d\\n\",C(cnt2,j),C(cnt1,b-j-1));\n\t\t}\n\t}\n\tprintf(\"%d\\n\",ans);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3fd19f8754f5086107eb930a60b6fde2", "src_uid": "1fd82cca7cc7520f6091c6c9898debf8", "difficulty": 3400.0}
    {"lang": "GNU C++11", "source_code": "#include\n#define P 1000000007\n#define ll long long\n#define N 5005\nusing namespace std;\nint n,a,b,s[N],sz[N],C[N][N],Ans;char c[N];\nshort to[N*N],fr[N*N];int nxt[N*N],fst[N],l;\nint st[N],top,bl[N],cnt,dfn[N],low[N],clk;\nvectorp[N],v[N],e[N];\nstruct T\n{\n\tint x,y;\n}d[N];\nint cmp(T a,T b)\n{\n\treturn a.xtp;tp.clear();\n\t\t\tfor (int j=0;j=b)\n\t\t{\n\t\t\tif (i<=a)Ans=(Ans+C[i-1][b-1])%P;\n\t\t\telse\n\t\t\t{\n\t\t\t\tint u=qry(d[i].y),v=i-1-u;\n\t\t\t\tfor (int j=0;j<=u&&j\n#define P 1000000007\n#define ll long long\n#define N 5005\nusing namespace std;\nint n,a,b,s[N],sz[N],C[N][N],Ans;char c[N];\nshort to[N*N],fr[N*N];int nxt[N*N],fst[N],l;\nint st[N],top,bl[N],cnt,dfn[N],low[N],clk;\nvectorp[N],v[N],e[N];\nstruct T\n{\n\tint x,y;\n}d[N];\nint cmp(T a,T b)\n{\n\treturn a.xtp;tp.clear();\n\t\t\tfor (int j=0;j=b)\n\t\t{\n\t\t\tif (i<=a)Ans=(Ans+C[i-1][b-1])%P;\n\t\t\telse\n\t\t\t{\n\t\t\t\tint u=qry(d[i].y),v=i-1-u;\n\t\t\t\tfor (int j=0;j<=u&&j\n#define lb(x) ((x)&(-x))\n#define out(i,a,now) for(LL i=a.be[now],to=a.v[i];~i;i=a.ne[i],to=a.v[i])\n#define fo(i,a,b) for(i=(a);i<=(b);++i)\n#define fd(i,a,b) for(i=(a);i>=(b);--i)\n#define mid ((l+r)>>1)\n#define max(a,b) (a>b?a:b)\n#define min(a,b) (a>b?b:a)\n#define mp(a,b) make_pair(a,b)\n#define qk(x) memset(x,0,sizeof(x))\n#define RG register\n#define SF scanf\n#define PF printf\n#define FP freopen\n#define FI first\n#define SE second\n#define cpy(a,b) memcpy(a,b,sizeof(a))//b to a\n#define pi 3.1415926535897932384626433832\n#define ls (now<<1)\n#define rs (now<<1|1)\n#ifdef Mogician\n#endif\nusing namespace std;\ntypedef long long LL;\ntypedef double DB;\ntypedef pair Pair;\ntemplate  void cmax(T &a,T b){\n    a=max(a,b);\n}\ntemplate  void cmin(T &a,T b){\n    a=min(a,b);\n}\nconst LL maxn=140000,kcz=998244353;\nLL ksm(LL ds,LL zs=kcz-2,LL mod=kcz){\n\tLL res=1;\n\tfor(;zs;zs>>=1,ds=ds*ds%mod)\n\t\tif (zs&1) res=res*ds%mod;\n\treturn res;\n}\nconst LL i100=ksm(100);\nLL lim[maxn][2][2],n;\nLL p[maxn][2];\nstruct SEG{\n\tLL tr[maxn<<1][2][2];\n\tvoid up(LL now,LL l,LL r){\n\t\tqk(tr[now]);\n\t\tLL i,j,k,t;\n\t\tfo(i,0,1) fo(j,0,1) fo(k,0,1) fo(t,0,1)\n\t\t\tif (!lim[mid][k][t]) (tr[now][i][j]+=tr[ls][i][k]*tr[rs][t][j])%=kcz;\n\t}\n\tvoid build(LL now,LL l,LL r){\n\t\tif (l==r){\n\t\t\ttr[now][0][0]=p[l][0];\n\t\t\ttr[now][1][1]=p[l][1];\n\t\t\treturn;\n\t\t}\n\t\tbuild(ls,l,mid); build(rs,mid+1,r);\n\t\tup(now,l,r);\n\t}\n\tvoid up(LL now,LL l,LL r,LL x){\n\t\tif (l==r) return;\n\t\tif (mid>=x) up(ls,l,mid,x);\n\t\telse up(rs,mid+1,r,x);\n\t\tup(now,l,r);\n\t}\n}seg;\nstruct data{\n\tLL id,l,r,t;\n\tDB p;\n\tdata(){\n\t\tid=l=r=t=0; p=0;\n\t}\n\tdata(LL a,LL b,LL c,LL d,DB e){\n\t\tid=a; l=b; r=c; t=d; p=e;\n\t}\n\tbool operator <(const data &b) const{\n\t\treturn p1){\n\t\t\ta[++cnt]=data(i-1,1,0,(X-lx)*ksm(V+lv),(DB)(X-lx)/(V+lv));\n\t\t\tif (V>lv)\n\t\t\t\ta[++cnt]=data(i-1,0,0,(X-lx)*ksm(V-lv),(DB)(X-lx)/(V+lv));\n\t\t\telse if (lv>V)\n\t\t\t\ta[++cnt]=data(i-1,1,1,(X-lx)*ksm(lv-V),(DB)(X-lx)/(lv-V));\n\t\t}\n\t\tp[i][0]=(100-P)*i100%kcz;\n\t\tp[i][1]=P*i100%kcz;\n\t\tlv=V; lx=X;\n\t}\n\tseg.build(1,1,n);\n\tsort(a+1,a+cnt+1);\n\tLL ans=0,last=1,now,j,k;\n\tfo(i,1,cnt){\n\t\tlim[a[i].id][a[i].l][a[i].r]=1;\n\t\tseg.up(1,1,n,a[i].id);\n\t\tnow=0;\n\t\tfo(j,0,1) fo(k,0,1) (now+=seg.tr[1][j][k])%=kcz;\n\t\tans+=a[i].t*(last-now+kcz)%kcz;\n\t\tlast=now;\n\t}\n\tPF(\"%lld\",(ans%kcz+kcz)%kcz);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d4bea660c9ebd05bf7654100be8ea5f0", "src_uid": "37bb4fe5f6cc2a173e97c033c6fde8c7", "difficulty": 3100.0}
    {"lang": "GNU C++14", "source_code": "#include \n\nconst int N = 3e5 + 7, MOD = 998244353;\nconst double eps = 1e-7;\n\nvoid M(int &a) {\n\tif (a >= MOD) a -= MOD;\n\tif (a < 0) a += MOD;\n}\n\nint sign(double x) {\n\tif (x < -eps) return -1;\n\treturn x > eps;\n}\n\nint qp(int a, int b = MOD - 2) {\n\tint ans = 1;\n\twhile (b) {\n\t\tif (b & 1) ans = 1LL * ans * a % MOD;\n\t\ta = 1LL * a * a % MOD;\n\t\tb >>= 1;\n\t}\n\treturn ans % MOD;\n}\n\nconst int inv = qp(100);\nint n, pro[N][2];\nbool limit[N][2][2];\n\nnamespace seg {\n\t#define lp p << 1\n\t#define rp p << 1 | 1\n\tstatic const int XN = N * 4;\n\tint tree[XN][2][2];\n\tvoid pushup(int p, int mid) {\n\t\tfor (int i = 0; i < 2; i++)\n\t\t\tfor (int j = 0; j < 2; j++) {\n\t\t\t\ttree[p][i][j] = 0;\n\t\t\t\tfor (int k = 0; k < 2; k++)\n\t\t\t\t\tfor (int l = 0; l < 2; l++) \n\t\t\t\t\t\tif (!limit[mid][k][l])\n\t\t\t\t\t\t\tM(tree[p][i][j] += 1LL * tree[lp][i][k] * tree[rp][l][j] % MOD);\n\t\t\t}\n\t}\n\tvoid build(int p, int l, int r) {\n\t\tif (l == r) {\n\t\t\ttree[p][1][1] = pro[l][1];\n\t\t\ttree[p][0][0] = pro[l][0];\n\t\t\treturn;\n\t\t}\n\t\tint mid = l + r >> 1;\n\t\tbuild(lp, l, mid);\n\t\tbuild(rp, mid + 1, r);\n\t\tpushup(p, mid);\n\t} \n\tvoid update(int p, int l, int r, int pos) {\n\t\tif (l == r) return;\n\t\tint mid = l + r >> 1;\n\t\tif (pos <= mid) update(lp, l, mid, pos);\n\t\telse update(rp, mid + 1, r, pos);\n\t\tpushup(p, mid);\n\t}\n\tint query() {\n\t\tint ans = 0;\n\t\tfor (int i = 0; i < 2; i++)\n\t\t\tfor (int j = 0; j < 2; j++)\n\t\t\t\tM(ans += tree[1][i][j]);\n\t\treturn ans;\n\t}\n}\n\nstruct Node {\n\tint x, xp, yp;\n\tdouble t;\n\tint tt;\n\tNode() {}\n\tNode(int x, int xp, int yp, double t, int tt): x(x), xp(xp), yp(yp), t(t), tt(tt) {}\n\tbool operator < (const Node &p) const {\n\t\treturn sign(t - p.t) < 0;\n\t}\n} P[N];\n\nint main() {\n\tscanf(\"%d\", &n);\n\tint cnt = 0;\n\tint lastx = 0, lastv = 0;\n\tfor (int i = 1; i <= n; i++) {\n\t\tint x, v, p;\n\t\tscanf(\"%d%d%d\", &x, &v, &p);\n\t\tif (i > 1) {\n\t\t\tint dis = x - lastx;\n\t\t\t++cnt;\n\t\t\tP[cnt] = Node(i - 1, 1, 0, dis / 1.0 / (lastv + v), 1LL * dis * qp(lastv + v) % MOD);\n\t\t\tif (v > lastv) {\n\t\t\t\t++cnt;\n\t\t\t\tP[cnt] = Node(i - 1, 0, 0, dis / 1.0 / (v - lastv), 1LL * dis * qp(v - lastv) % MOD);\n\t\t\t} else if (lastv > v) {\n\t\t\t\t++cnt;\n\t\t\t\tP[cnt] = Node(i - 1, 1, 1, dis / 1.0 / (lastv - v), 1LL * dis * qp(lastv - v) % MOD);\n\t\t\t}\n\t\t}\n\t\tlastv = v;\n\t\tlastx = x;\n\t\tpro[i][0] = 1LL * (100 - p) * inv % MOD;\n\t\tpro[i][1] = 1LL * p * inv % MOD;\n\t}\n\tseg::build(1, 1, n);\n\tstd::sort(P + 1, P + 1 + cnt);\n\tint ans = 0, lastp = 1;\n\tfor (int i = 1; i <= cnt; i++) {\n\t\tNode p = P[i];\n\t\tlimit[p.x][p.xp][p.yp] = 1;\n\t\tseg::update(1, 1, n, p.x);\n\t\tint curp = seg::query();\n\t\tM(ans += 1LL * p.tt * (lastp - curp + MOD) % MOD);\n\t\tlastp = curp;\n\t}\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2dedc432842a92c443df669784fd8a6e", "src_uid": "37bb4fe5f6cc2a173e97c033c6fde8c7", "difficulty": 3100.0}
    {"lang": "GNU C++17", "source_code": "# include \n \nusing namespace std;\n \ntypedef long long ll;\ntypedef long double ld;\ntypedef pair  pii;\n \n# define F first\n# define S second\n# define endl '\\n'\n# define sep ' '\n# define pb push_back\n# define fast_io ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);\n \nconst ll md = 998244353;\nconst int xn = 1e5+10;\nconst int xm = 1e2+10;\nconst int SQ = 320;\nconst int sq = 1e3+10;\nconst ll inf = 1e18+10;\n\nll power(ll a, ll b) {\n    return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2) % md : power(a * a % md, b / 2) % md));\n}\n\n\nint n;\nll x[xn], v[xn], p[xn][2], inv, timeb[xn][4], dp[xn][2], ans, P[2];\nld tmb[xn][4];\nvector  > b[sq][4];\n\n\n\nvoid Build(){\n\tfor (int i = 0; i < n; i += SQ){\n\t\tint ind = i/SQ;\n\t\tfor (int j = 0; j < 4; j += 2){\n\t\t\tsort(b[ind][j].begin(), b[ind][j].end());\n\t\t\tfor (int k = 0; k < b[ind][j].size(); k++){\n\t\t\t\tld t = b[ind][j][k].F;\n\t\t\t\tdp[i][0] = dp[i][1] = 0;\n\t\t\t\tif (j < 2) dp[i][0] = p[i][0];\n\t\t\t\telse dp[i][1] = p[i][1];\n\t\t\t\tfor (int pnt = i + 1; pnt < i+SQ; pnt++){\n\t\t\t\t\tif (i >= n) break;\n\t\t\t\t\tdp[pnt][0] = dp[pnt][1] = 0;\n\t\t\t\t\tif (tmb[pnt][0] >= t) dp[pnt][0] += dp[pnt - 1][0], dp[pnt][0] %= md;\n\t\t\t\t\tif (tmb[pnt][2] >= t) dp[pnt][0] += dp[pnt - 1][1], dp[pnt][0] %= md;\n\t\t\t\t\tdp[pnt][0] = (dp[pnt][0] * p[pnt][0] + 100 * md) % md;\n\t\t\t\t\t\n\t\t\t\t\tif (tmb[pnt][1] >= t) dp[pnt][1] += dp[pnt - 1][0], dp[pnt][1] %= md;\n\t\t\t\t\tif (tmb[pnt][3] >= t) dp[pnt][1] += dp[pnt - 1][1], dp[pnt][1] %= md;\n\t\t\t\t\tdp[pnt][1] = (dp[pnt][1] * p[pnt][1] + 100 * md) % md;\n\t\t\t\t}\n\t\t\t\tint dx = min(i+SQ-1, n-1);\n\t\t\t\tb[ind][j][k].S = dp[dx][0];\n\t\t\t\tb[ind][j + 1][k].S = dp[dx][1];\n\t\t\t}\n\t\t}\n\t}\n}\nvoid get(int dx, int f){\n\tP[0] = P[1] = 1;\n\tld t = tmb[dx][f];\n\tfor (int i = 0; i < dx; i += SQ){\n\t\tif (i/SQ == dx/SQ) break;\n\t\tint l = -1, r = b[i/SQ][0].size(), mid;\n\t\twhile (r - l > 1){\n\t\t\tmid = (l + r) / 2;\n\t\t\tif (b[i/SQ][0][mid].F <= t) l = mid;\n\t\t\telse r = mid;\n\t\t}\n\t\tint ind = r;\n\t\t//cout << ind << endl;\n\t\tif (ind == b[i/SQ][0].size()){\n\t\t\tP[0] = P[1] = 0;\n\t\t\tbreak;\n\t\t}\n\t\tll h1 = 0, h2 = 0;\n\t\tif (tmb[i][0] > t) h1 += (b[i/SQ][0][ind].S * P[0] + 100 * md) % md, h1 %= md;\n\t\tif (tmb[i][2] > t) h1 += (b[i/SQ][0][ind].S * P[1] + 100 * md) % md, h1 %= md;\n\t\tif (tmb[i][1] > t) h1 += (b[i/SQ][2][ind].S * P[0] + 100 * md) % md, h1 %= md;\n\t\tif (tmb[i][3] > t) h1 += (b[i/SQ][2][ind].S * P[1] + 100 * md) % md, h1 %= md;\n\t\t\n\t\tif (tmb[i][0] > t) h2 += (b[i/SQ][1][ind].S * P[0] + 100 * md) % md, h2 %= md;\n\t\tif (tmb[i][2] > t) h2 += (b[i/SQ][1][ind].S * P[1] + 100 * md) % md, h2 %= md;\n\t\tif (tmb[i][1] > t) h2 += (b[i/SQ][3][ind].S * P[0] + 100 * md) % md, h2 %= md;\n\t\tif (tmb[i][3] > t) h2 += (b[i/SQ][3][ind].S * P[1] + 100 * md) % md, h2 %= md;\n\t\t\n\t\tP[0] = h1, P[1] = h2;\n\t}\n\t//cout << P[0] << sep << P[1] << endl;\n\t\n\tfor (int i = dx-dx%SQ; i < dx; i++){\n\t\tif (i == 0){\n\t\t\tP[0] = p[i][0], P[1] = p[i][1];\n\t\t\tcontinue;\n\t\t}\n\t\tdp[i][0] = dp[i][1] = 0;\n\t\tif (tmb[i][0] > t) dp[i][0] += P[0], dp[i][0] %= md;\n\t\tif (tmb[i][2] > t) dp[i][0] += P[1], dp[i][0] %= md;\n\t\tdp[i][0] = (dp[i][0] * p[i][0] + 100 * md) % md;\n\t\t\n\t\tif (tmb[i][1] > t) dp[i][1] += P[0], dp[i][1] %= md;\n\t\tif (tmb[i][3] > t) dp[i][1] += P[1], dp[i][1] %= md;\n\t\tdp[i][1] = (dp[i][1] * p[i][1] + 100 * md) % md;\n\t\t\n\t\tP[0] = dp[i][0];\n\t\tP[1] = dp[i][1];\n\t}\n\tif (f < 2) P[1] = 0;\n\telse P[0] = 0;\n\t\n\t//cout << P[0] << sep << P[1] << endl;\n\t\n\tif (f == 0) P[0] = (P[0] * p[dx][0] + 100 * md) % md;\n\telse if (f == 1) P[1] = (P[0] * p[dx][1] + 100 * md) % md, P[0] = 0;\n\telse if (f == 2) P[0] = (P[1] * p[dx][0] + 100 * md) % md, P[1] = 0;\n\telse P[1] = (P[1] * p[dx][1] + 100 * md) % md;\n\n\t\n\tfor (int i = dx+1; i < dx-dx%SQ+SQ; i++){\n\t\tif (i >= n) break;\n\t\tdp[i][0] = dp[i][1] = 0;\n\t\tif (tmb[i][0] >= t) dp[i][0] += P[0], dp[i][0] %= md;\n\t\tif (tmb[i][2] >= t) dp[i][0] += P[1], dp[i][0] %= md;\n\t\tdp[i][0] = (dp[i][0] * p[i][0] + 100 * md) % md;\n\t\t\n\t\tif (tmb[i][1] >= t) dp[i][1] += P[0], dp[i][1] %= md;\n\t\tif (tmb[i][3] >= t) dp[i][1] += P[1], dp[i][1] %= md;\n\t\tdp[i][1] = (dp[i][1] * p[i][1] + 100 * md) % md;\n\t\t\n\t\tP[0] = dp[i][0];\n\t\tP[1] = dp[i][1];\n\t}\n\t\n\tfor (int i = dx-dx%SQ+SQ; i < n; i += SQ){\n\t\n\t\tint l = -1, r = b[i/SQ][0].size(), mid;\n\t\twhile (r - l > 1){\n\t\t\tmid = (l + r) / 2;\n\t\t\tif (b[i/SQ][0][mid].F < t) l = mid;\n\t\t\telse r = mid;\n\t\t}\n\t\tint ind = r;\n\t\tif (ind == b[i/SQ][0].size()){\n\t\t\tP[0] = P[1] = 0;\n\t\t\tbreak;\n\t\t}\n\t\tll h1 = 0, h2 = 0;\n\t\tif (tmb[i][0] >= t) h1 += (b[i/SQ][0][ind].S * P[0] + 100 * md) % md, h1 %= md;\n\t\tif (tmb[i][2] >= t) h1 += (b[i/SQ][0][ind].S * P[1] + 100 * md) % md, h1 %= md;\n\t\tif (tmb[i][1] >= t) h1 += (b[i/SQ][2][ind].S * P[0] + 100 * md) % md, h1 %= md;\n\t\tif (tmb[i][3] >= t) h1 += (b[i/SQ][2][ind].S * P[1] + 100 * md) % md, h1 %= md;\n\t\t\n\t\tif (tmb[i][0] >= t) h2 += (b[i/SQ][1][ind].S * P[0] + 100 * md) % md, h2 %= md;\n\t\tif (tmb[i][2] >= t) h2 += (b[i/SQ][1][ind].S * P[1] + 100 * md) % md, h2 %= md;\n\t\tif (tmb[i][1] >= t) h2 += (b[i/SQ][3][ind].S * P[0] + 100 * md) % md, h2 %= md;\n\t\tif (tmb[i][3] >= t) h2 += (b[i/SQ][3][ind].S * P[1] + 100 * md) % md, h2 %= md;\n\t\t\n\t\tP[0] = h1, P[1] = h2;\n\t\t//cout << h1 << sep << h2 << endl;\n\t}\n\tP[0] += P[1];\n\t\n\t//cout << dx << sep << f << sep << P[0] << endl;\n\t\n\tans = (ans + (P[0] * timeb[dx][f] + 100 * md) % md + 100 * md) % md;\n}\n\n\n\nint main(){\n\tfast_io;\n\t\n\tcin >> n;\n\tfor (int i = 0; i < n; i++) cin >> x[i] >> v[i] >> p[i][0], p[i][1] = 100 - p[i][0];\n\t\n\tcout << fixed << setprecision(10);\n\t\n\tinv = power(ll(100), md - 2);\n\t\n\tfor (int i = 0; i < n; i++) for (int j = 0; j < 2; j++) p[i][j] = (p[i][j] * inv + 100 * md) % md;\n\t\n\tfor (int i = 0; i < 4; i++) tmb[0][i] = inf;\n\tfor (int i = 1; i < n; i++){\n\t\ttmb[i][2] = inf;\n\t\ttimeb[i][1] = ((x[i] - x[i - 1]) * power(v[i] + v[i - 1], md - 2) + 100 * md) % md;\n\t\ttmb[i][1] = ld(x[i] - x[i - 1]) / ld(v[i] + v[i - 1]);\n\t\tif (v[i - 1] > v[i]){\n\t\t\ttimeb[i][0] = ((x[i] - x[i - 1]) * power(v[i - 1] - v[i], md - 2) + 100 * md) % md;\n\t\t\ttmb[i][0] = ld(x[i] - x[i - 1]) / ld(v[i - 1] - v[i]);\n\t\t\ttmb[i][3] = inf;\n\t\t}\n\t\telse if (v[i] > v[i - 1]){\n\t\t\ttimeb[i][3] = ((x[i] - x[i - 1]) * power(v[i] - v[i - 1], md - 2) + 100 * md) % md;\n\t\t\ttmb[i][3] = ld(x[i] - x[i - 1]) / (v[i] - v[i - 1]);\n\t\t\ttmb[i][0] = inf;\n\t\t}\n\t\telse{\n\t\t\ttmb[i][0] = tmb[i][3] = inf;\n\t\t}\n\t}\n\tfor (int i = 1; i < n; i++){\n\t\tif (i%SQ == 0) continue;\n\t\tfor (int j = 0; j < 4; j++){\n\t\t\tif (tmb[i][j] == inf) continue;\n\t\t\tfor (int k = 0; k < 4; k++) b[i/SQ][k].pb({tmb[i][j], 0});\n\t\t}\n\t}\n\t\n\tfor (int i = SQ; i < n; i += SQ){\n\t\tfor (int j = 0; j < 4; j++){\n\t\t\tif (tmb[i][j] == inf) continue;\n\t\t\tll ehtemal = 1;\n\t\t\tdp[0][0] = p[0][0];\n\t\t\tdp[0][1] = p[0][1];\n\t\t\tfor (int k = 1; k <= i - 1; k++){\n\t\t\t\tdp[k][0] = 0;\n\t\t\t\tif (tmb[k][0] > tmb[i][j]) dp[k][0] += dp[k - 1][0], dp[k][0] %= md;\n\t\t\t\tif (tmb[k][2] > tmb[i][j]) dp[k][0] += dp[k - 1][1], dp[k][0] %= md;\n\t\t\t\tdp[k][0] = (dp[k][0] * p[k][0] + 100 * md) % md;\n\t\t\t\t\n\t\t\t\tdp[k][1] = 0;\n\t\t\t\tif (tmb[k][1] > tmb[i][j]) dp[k][1] += dp[k - 1][0], dp[k][1] %= md;\n\t\t\t\tif (tmb[k][3] > tmb[i][j]) dp[k][1] += dp[k - 1][1], dp[k][1] %= md;\n\t\t\t\tdp[k][1] = (dp[k][1] * p[k][1] + 100 * md) % md;\n\t\t\t}\n\t\t\tif (j < 2) dp[i - 1][1] = 0;\n\t\t\telse dp[i - 1][0] = 0;\n\t\t\t\n\t\t\tdp[i][0] = dp[i][1] = 0;\n\t\t\tif (j == 0) dp[i][0] = dp[i - 1][0];\n\t\t\telse if (j == 2) dp[i][0] = dp[i - 1][1];\n\t\t\telse if (j == 1) dp[i][1] = dp[i - 1][0];\n\t\t\telse dp[i][1] = dp[i - 1][1];\n\t\t\t\n\t\t\tif (j%2 == 0) dp[i][0] = (dp[i][0] * p[i][0] + 100 * md) + md;\n\t\t\telse dp[i][1] = (dp[i][1] * p[i][1] + 100 * md) % md;\n\t\t\t\n\t\t\tfor (int k = i + 1; k < n; k++){\n\t\t\t\tdp[k][0] = 0;\n\t\t\t\tif (tmb[k][0] >= tmb[i][j]) dp[k][0] += dp[k - 1][0], dp[k][0] %= md;\n\t\t\t\tif (tmb[k][2] >= tmb[i][j]) dp[k][0] += dp[k - 1][1], dp[k][0] %= md;\n\t\t\t\tdp[k][0] = (dp[k][0] * p[k][0] + 100 * md) % md;\n\t\t\t\t\n\t\t\t\tdp[k][1] = 0;\n\t\t\t\tif (tmb[k][1] >= tmb[i][j]) dp[k][1] += dp[k - 1][0], dp[k][1] %= md;\n\t\t\t\tif (tmb[k][3] >= tmb[i][j]) dp[k][1] += dp[k - 1][1], dp[k][1] %= md;\n\t\t\t\tdp[k][1] = (dp[k][1] * p[k][1] + 100 * md) % md;\n\t\t\t}\n\t\t\tehtemal = (dp[n - 1][0] + dp[n - 1][1] + 100 * md) % md;\n\t\t\tans = (ans + (ehtemal * timeb[i][j] + 100 * md) % md + 100 * md) % md;\n\t\t}\n\t}\n\tBuild();\n\t\n\tfor (int i = 1; i < n; i++){\n\t\tfor (int j = 0; j < 4; j++){\n\t\t\tif (tmb[i][j] == inf) continue;\n\t\t\tget(i, j);\n\t\t}\n\t}\n\t\n\tcout << ans << endl;\n\t\n\t\n\t\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "847117ec165a80f9440e8086e47ec976", "src_uid": "37bb4fe5f6cc2a173e97c033c6fde8c7", "difficulty": 3100.0}
    {"lang": "GNU C++17", "source_code": "# include \n \nusing namespace std;\n \ntypedef long long ll;\ntypedef long double ld;\ntypedef pair  pii;\n \n# define F first\n# define S second\n# define endl '\\n'\n# define sep ' '\n# define pb push_back\n# define fast_io ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);\n \nconst ll md = 998244353;\nconst int xn = 1e5+10;\nconst int xm = 1e2+10;\nconst int SQ = 50;\nconst int sq = 1e3+10;\nconst ll inf = 1e18+10;\n\nll power(ll a, ll b) {\n    return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2) % md : power(a * a % md, b / 2) % md));\n}\n\n\nint n;\nll x[xn], v[xn], p[xn][2], inv, timeb[xn][4], dp[xn][2], ans, P[2];\nld tmb[xn][4];\nvector  > b[sq][4];\n\n\n\nvoid Build(){\n\tfor (int i = 0; i < n; i += SQ){\n\t\tint ind = i/SQ;\n\t\tfor (int j = 0; j < 4; j += 2){\n\t\t\tsort(b[ind][j].begin(), b[ind][j].end());\n\t\t\tfor (int k = 0; k < b[ind][j].size(); k++){\n\t\t\t\tld t = b[ind][j][k].F;\n\t\t\t\tdp[i][0] = dp[i][1] = 0;\n\t\t\t\tif (j < 2) dp[i][0] = p[i][0];\n\t\t\t\telse dp[i][1] = p[i][1];\n\t\t\t\tfor (int pnt = i + 1; pnt < i+SQ; pnt++){\n\t\t\t\t\tif (i >= n) break;\n\t\t\t\t\tdp[pnt][0] = dp[pnt][1] = 0;\n\t\t\t\t\tif (tmb[pnt][0] >= t) dp[pnt][0] += dp[pnt - 1][0], dp[pnt][0] %= md;\n\t\t\t\t\tif (tmb[pnt][2] >= t) dp[pnt][0] += dp[pnt - 1][1], dp[pnt][0] %= md;\n\t\t\t\t\tdp[pnt][0] = (dp[pnt][0] * p[pnt][0] + 100 * md) % md;\n\t\t\t\t\t\n\t\t\t\t\tif (tmb[pnt][1] >= t) dp[pnt][1] += dp[pnt - 1][0], dp[pnt][1] %= md;\n\t\t\t\t\tif (tmb[pnt][3] >= t) dp[pnt][1] += dp[pnt - 1][1], dp[pnt][1] %= md;\n\t\t\t\t\tdp[pnt][1] = (dp[pnt][1] * p[pnt][1] + 100 * md) % md;\n\t\t\t\t}\n\t\t\t\tint dx = min(i+SQ-1, n-1);\n\t\t\t\tb[ind][j][k].S = dp[dx][0];\n\t\t\t\tb[ind][j + 1][k].S = dp[dx][1];\n\t\t\t}\n\t\t}\n\t}\n}\nvoid get(int dx, int f){\n\tP[0] = P[1] = 1;\n\tld t = tmb[dx][f];\n\tfor (int i = 0; i < dx; i += SQ){\n\t\tif (i/SQ == dx/SQ) break;\n\t\tint l = -1, r = b[i/SQ][0].size(), mid;\n\t\twhile (r - l > 1){\n\t\t\tmid = (l + r) / 2;\n\t\t\tif (b[i/SQ][0][mid].F <= t) l = mid;\n\t\t\telse r = mid;\n\t\t}\n\t\tint ind = r;\n\t\t//cout << ind << endl;\n\t\tif (ind == b[i/SQ][0].size()){\n\t\t\tP[0] = P[1] = 0;\n\t\t\treturn;\n\t\t}\n\t\tif (P[0] == P[1] && P[0] == 1 && i == 0){\n\t\t\tP[0] = P[1] = 0;\n\t\t\tP[0] += b[0][0][ind].S, P[0] %= md;\n\t\t\tP[0] += b[0][2][ind].S, P[0] %= md;\n\t\t\tP[1] += b[0][1][ind].S, P[1] %= md;\n\t\t\tP[1] += b[0][3][ind].S, P[1] %= md;\n\t\t\tcontinue;\n\t\t}\n\t\tll h1 = 0, h2 = 0;\n\t\tif (tmb[i][0] > t) h1 += (b[i/SQ][0][ind].S * P[0] + 100 * md) % md, h1 %= md;\n\t\tif (tmb[i][2] > t) h1 += (b[i/SQ][0][ind].S * P[1] + 100 * md) % md, h1 %= md;\n\t\tif (tmb[i][1] > t) h1 += (b[i/SQ][2][ind].S * P[0] + 100 * md) % md, h1 %= md;\n\t\tif (tmb[i][3] > t) h1 += (b[i/SQ][2][ind].S * P[1] + 100 * md) % md, h1 %= md;\n\t\t\n\t\tif (tmb[i][0] > t) h2 += (b[i/SQ][1][ind].S * P[0] + 100 * md) % md, h2 %= md;\n\t\tif (tmb[i][2] > t) h2 += (b[i/SQ][1][ind].S * P[1] + 100 * md) % md, h2 %= md;\n\t\tif (tmb[i][1] > t) h2 += (b[i/SQ][3][ind].S * P[0] + 100 * md) % md, h2 %= md;\n\t\tif (tmb[i][3] > t) h2 += (b[i/SQ][3][ind].S * P[1] + 100 * md) % md, h2 %= md;\n\t\t\n\t\tP[0] = h1, P[1] = h2;\n\t}\n\t//cout << P[0] << sep << P[1] << endl;\n\t\n\tfor (int i = dx-dx%SQ; i < dx; i++){\n\t\tif (i == 0){\n\t\t\tP[0] = p[i][0], P[1] = p[i][1];\n\t\t\tcontinue;\n\t\t}\n\t\tdp[i][0] = dp[i][1] = 0;\n\t\tif (tmb[i][0] > t) dp[i][0] += P[0], dp[i][0] %= md;\n\t\tif (tmb[i][2] > t) dp[i][0] += P[1], dp[i][0] %= md;\n\t\tdp[i][0] = (dp[i][0] * p[i][0] + 100 * md) % md;\n\t\t\n\t\tif (tmb[i][1] > t) dp[i][1] += P[0], dp[i][1] %= md;\n\t\tif (tmb[i][3] > t) dp[i][1] += P[1], dp[i][1] %= md;\n\t\tdp[i][1] = (dp[i][1] * p[i][1] + 100 * md) % md;\n\t\t\n\t\tP[0] = dp[i][0];\n\t\tP[1] = dp[i][1];\n\t}\n\tif (f < 2) P[1] = 0;\n\telse P[0] = 0;\n\t\n\t//cout << P[0] << sep << P[1] << endl;\n\t\n\tif (f == 0) P[0] = (P[0] * p[dx][0] + 100 * md) % md;\n\telse if (f == 1) P[1] = (P[0] * p[dx][1] + 100 * md) % md, P[0] = 0;\n\telse if (f == 2) P[0] = (P[1] * p[dx][0] + 100 * md) % md, P[1] = 0;\n\telse P[1] = (P[1] * p[dx][1] + 100 * md) % md;\n\n\t\n\tfor (int i = dx+1; i < dx-dx%SQ+SQ; i++){\n\t\tif (i >= n) break;\n\t\tdp[i][0] = dp[i][1] = 0;\n\t\tif (tmb[i][0] >= t) dp[i][0] += P[0], dp[i][0] %= md;\n\t\tif (tmb[i][2] >= t) dp[i][0] += P[1], dp[i][0] %= md;\n\t\tdp[i][0] = (dp[i][0] * p[i][0] + 100 * md) % md;\n\t\t\n\t\tif (tmb[i][1] >= t) dp[i][1] += P[0], dp[i][1] %= md;\n\t\tif (tmb[i][3] >= t) dp[i][1] += P[1], dp[i][1] %= md;\n\t\tdp[i][1] = (dp[i][1] * p[i][1] + 100 * md) % md;\n\t\t\n\t\tP[0] = dp[i][0];\n\t\tP[1] = dp[i][1];\n\t}\n\t\n\tfor (int i = dx-dx%SQ+SQ; i < n; i += SQ){\n\t\n\t\tint l = -1, r = b[i/SQ][0].size(), mid;\n\t\twhile (r - l > 1){\n\t\t\tmid = (l + r) / 2;\n\t\t\tif (b[i/SQ][0][mid].F < t) l = mid;\n\t\t\telse r = mid;\n\t\t}\n\t\tint ind = r;\n\t\tif (ind == b[i/SQ][0].size()){\n\t\t\tP[0] = P[1] = 0;\n\t\t\tbreak;\n\t\t}\n\t\tll h1 = 0, h2 = 0;\n\t\tif (tmb[i][0] >= t) h1 += (b[i/SQ][0][ind].S * P[0] + 100 * md) % md, h1 %= md;\n\t\tif (tmb[i][2] >= t) h1 += (b[i/SQ][0][ind].S * P[1] + 100 * md) % md, h1 %= md;\n\t\tif (tmb[i][1] >= t) h1 += (b[i/SQ][2][ind].S * P[0] + 100 * md) % md, h1 %= md;\n\t\tif (tmb[i][3] >= t) h1 += (b[i/SQ][2][ind].S * P[1] + 100 * md) % md, h1 %= md;\n\t\t\n\t\tif (tmb[i][0] >= t) h2 += (b[i/SQ][1][ind].S * P[0] + 100 * md) % md, h2 %= md;\n\t\tif (tmb[i][2] >= t) h2 += (b[i/SQ][1][ind].S * P[1] + 100 * md) % md, h2 %= md;\n\t\tif (tmb[i][1] >= t) h2 += (b[i/SQ][3][ind].S * P[0] + 100 * md) % md, h2 %= md;\n\t\tif (tmb[i][3] >= t) h2 += (b[i/SQ][3][ind].S * P[1] + 100 * md) % md, h2 %= md;\n\t\t\n\t\tP[0] = h1, P[1] = h2;\n\t\t//cout << h1 << sep << h2 << endl;\n\t}\n\tP[0] += P[1];\n\t\n\t//cout << dx << sep << f << sep << P[0] << endl;\n\t\n\tans = (ans + (P[0] * timeb[dx][f] + 100 * md) % md + 100 * md) % md;\n}\n\n\n\nint main(){\n\tfast_io;\n\t\n\tcin >> n;\n\tfor (int i = 0; i < n; i++) cin >> x[i] >> v[i] >> p[i][0], p[i][1] = 100 - p[i][0];\n\t\n\tcout << fixed << setprecision(10);\n\t\n\tinv = power(ll(100), md - 2);\n\t\n\tfor (int i = 0; i < n; i++) for (int j = 0; j < 2; j++) p[i][j] = (p[i][j] * inv + 100 * md) % md;\n\t\n\tfor (int i = 0; i < 4; i++) tmb[0][i] = inf;\n\tfor (int i = 1; i < n; i++){\n\t\ttmb[i][2] = inf;\n\t\ttimeb[i][1] = ((x[i] - x[i - 1]) * power(v[i] + v[i - 1], md - 2) + 100 * md) % md;\n\t\ttmb[i][1] = ld(x[i] - x[i - 1]) / ld(v[i] + v[i - 1]);\n\t\tif (v[i - 1] > v[i]){\n\t\t\ttimeb[i][0] = ((x[i] - x[i - 1]) * power(v[i - 1] - v[i], md - 2) + 100 * md) % md;\n\t\t\ttmb[i][0] = ld(x[i] - x[i - 1]) / ld(v[i - 1] - v[i]);\n\t\t\ttmb[i][3] = inf;\n\t\t}\n\t\telse if (v[i] > v[i - 1]){\n\t\t\ttimeb[i][3] = ((x[i] - x[i - 1]) * power(v[i] - v[i - 1], md - 2) + 100 * md) % md;\n\t\t\ttmb[i][3] = ld(x[i] - x[i - 1]) / (v[i] - v[i - 1]);\n\t\t\ttmb[i][0] = inf;\n\t\t}\n\t\telse{\n\t\t\ttmb[i][0] = tmb[i][3] = inf;\n\t\t}\n\t}\n\tfor (int i = 1; i < n; i++){\n\t\tif (i%SQ == 0) continue;\n\t\tfor (int j = 0; j < 4; j++){\n\t\t\tif (tmb[i][j] == inf) continue;\n\t\t\tfor (int k = 0; k < 4; k++) b[i/SQ][k].pb({tmb[i][j], 0});\n\t\t}\n\t}\n\t\n\tfor (int i = SQ; i < n; i += SQ){\n\t\tfor (int j = 0; j < 4; j++){\n\t\t\tif (tmb[i][j] == inf) continue;\n\t\t\tll ehtemal = 1;\n\t\t\tdp[0][0] = p[0][0];\n\t\t\tdp[0][1] = p[0][1];\n\t\t\tfor (int k = 1; k <= i - 1; k++){\n\t\t\t\tdp[k][0] = 0;\n\t\t\t\tif (tmb[k][0] > tmb[i][j]) dp[k][0] += dp[k - 1][0], dp[k][0] %= md;\n\t\t\t\tif (tmb[k][2] > tmb[i][j]) dp[k][0] += dp[k - 1][1], dp[k][0] %= md;\n\t\t\t\tdp[k][0] = (dp[k][0] * p[k][0] + 100 * md) % md;\n\t\t\t\t\n\t\t\t\tdp[k][1] = 0;\n\t\t\t\tif (tmb[k][1] > tmb[i][j]) dp[k][1] += dp[k - 1][0], dp[k][1] %= md;\n\t\t\t\tif (tmb[k][3] > tmb[i][j]) dp[k][1] += dp[k - 1][1], dp[k][1] %= md;\n\t\t\t\tdp[k][1] = (dp[k][1] * p[k][1] + 100 * md) % md;\n\t\t\t}\n\t\t\tif (j < 2) dp[i - 1][1] = 0;\n\t\t\telse dp[i - 1][0] = 0;\n\t\t\t\n\t\t\tdp[i][0] = dp[i][1] = 0;\n\t\t\tif (j == 0) dp[i][0] = dp[i - 1][0];\n\t\t\telse if (j == 2) dp[i][0] = dp[i - 1][1];\n\t\t\telse if (j == 1) dp[i][1] = dp[i - 1][0];\n\t\t\telse dp[i][1] = dp[i - 1][1];\n\t\t\t\n\t\t\tif (j%2 == 0) dp[i][0] = (dp[i][0] * p[i][0] + 100 * md) + md;\n\t\t\telse dp[i][1] = (dp[i][1] * p[i][1] + 100 * md) % md;\n\t\t\t\n\t\t\tfor (int k = i + 1; k < n; k++){\n\t\t\t\tdp[k][0] = 0;\n\t\t\t\tif (tmb[k][0] >= tmb[i][j]) dp[k][0] += dp[k - 1][0], dp[k][0] %= md;\n\t\t\t\tif (tmb[k][2] >= tmb[i][j]) dp[k][0] += dp[k - 1][1], dp[k][0] %= md;\n\t\t\t\tdp[k][0] = (dp[k][0] * p[k][0] + 100 * md) % md;\n\t\t\t\t\n\t\t\t\tdp[k][1] = 0;\n\t\t\t\tif (tmb[k][1] >= tmb[i][j]) dp[k][1] += dp[k - 1][0], dp[k][1] %= md;\n\t\t\t\tif (tmb[k][3] >= tmb[i][j]) dp[k][1] += dp[k - 1][1], dp[k][1] %= md;\n\t\t\t\tdp[k][1] = (dp[k][1] * p[k][1] + 100 * md) % md;\n\t\t\t}\n\t\t\tehtemal = (dp[n - 1][0] + dp[n - 1][1] + 100 * md) % md;\n\t\t\tans = (ans + (ehtemal * timeb[i][j] + 100 * md) % md + 100 * md) % md;\n\t\t}\n\t}\n\t\n\tBuild();\n\t\n\tfor (int i = 1; i < n; i++){\n\t\tif (i%SQ == 0) continue;\n\t\tfor (int j = 0; j < 4; j++){\n\t\t\tif (tmb[i][j] == inf) continue;\n\t\t\tget(i, j);\n\t\t}\n\t}\n\tcout << ans << endl;\n\t\n\t\n\t\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "41bbdd2da61cc8c4d2988473b2c3a290", "src_uid": "37bb4fe5f6cc2a173e97c033c6fde8c7", "difficulty": 3100.0}
    {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main () {\nlong n,k,sum[10000],ii=0,pp=0,h,one=0,two=0;\ncin>>n>>k;\nlong *a=new long(n);\n//int *l=new int(k);\n\nfor(int i=0;i>a[i];\nint b=n/k;\n\nfor(int p=0;p=two)\navg2=n-one;\nelse\navg2=n-two;\ncout<\ntypedef long long ll;\n#define forl(n) for(int i=0; i>n>>k;\n    int a[n];\n    forl(n){cin>>a[i];}\n    int p=0,q=0x=0;\n    forll(i,0,k,1)\n    {\n        forll(j,i,n,k)\n        {\n            if(a[j]==1)p++;\n            else if(a[j]==2)q++;\n        }\n        x+=min(p,q);\n        p=0;q=0;\n    }\n    cout<\n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef vector IntV;\n\ntemplate\nOutputIt copy_n(InputIt &first /*dirty hack reference - we're adjusting input iterator*/, Size count, OutputIt result)\n{\n   while (count-- > 0)\n   {\n      *result++ = *first++;\n   }\n   return result;\n}\n\ntemplate\nstruct Printer\n{\n   size_t current;\n   const AllLsType &allLs;\n\n   explicit Printer(const AllLsType &i_allLs)\n      : current(0U),\n        allLs(i_allLs)\n   {\n\n   }\n\n   void operator()(const int& i)\n   {\n      cout << (current ? \"\\n\" : \"\") << allLs[i - 1];\n      ++current;\n   }\n};\n\ntemplate\nPrinter make_printer(const AllLsType& l)\n{\n   return Printer(l);\n}\n\nint main(int, char*[])\n{\n   istream_iterator it(cin);\n   const int N = *it++;\n   const int K = *it++;\n\n   IntV A;\n   A.reserve(N);\n\n   copy_n(it, N, back_inserter(A));\n\n   int numOfArrays = N / K;\n\n   int totalChanges = 0;\n\n   for (int i = 0; i < K; ++i)\n   {\n      int numOf1 = 0;\n      int numOf2 = 0;\n\n      for (int j = 0; j < numOfArrays; ++j)\n      {\n         if (1 == A[i + j*K])\n            ++numOf1;\n         else\n            ++numOf2;\n      }\n\n      if ((numOf1 > 0) && (numOf2 > 0))\n      {\n         totalChanges += min(numOf1, numOf2);\n      }\n   }\n\n   cout << totalChanges;\n\n   return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a276cfc957adbe1fcbef7632e63abab7", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281", "difficulty": 1000.0}
    {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\nint N, K;\nint ar[128];\n\nint main() {\n\tcin >> N >> K;\n\tfor (int i = 0; i < N; i++) {\n\t\tcin >> ar[i];\n\t}\n\n\tint ans = 0;\n\n\tfor (int i = 0; i < K; i++) {\n\t\tmap appearances;\n\t\t// i < N/K\n\t\tfor (int j = i; j < N; j += K) {\n\t\t\tif (ar[i] != ar[j]) ans++;\n\t\t\tif (ar[i] != ar[j]) ans--;\n\t\t\tappearances[ar[j]] += 1;\n\t\t}\n\t\tfor (int j = i+k; j < K; j += K){\n\t\t\tans += min(appearances[1], appearances[2]); break;\n\t\t}\n\t}\n\n\tcout << ans << endl;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6ce3f94249dd575b11168fbc9b8d6fb9", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281", "difficulty": 1000.0}
    {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nconst int maxn = 200000+10;\nint n, k, m;\nmultiset s; // count \u73b0\u5728\u53ef\u7528\u7684\u8f66\u5b50\u90fd\u505c\u5728\u54ea\u4e9b\u5730\u65b9\ntypedef ll int;\ntypedef pair pt;\nset v[maxn]; // \u8bb0\u5f55\u6bcf\u4e2a\u5730\u65b9\u7b49\u5f85\u7684\u51fa\u79df\u8f66\nstruct node {\n    int num; int x;\n    ll T;\n\n    bool operator < (const node& x) const {\n        return T > x.T;\n    }\n} ; \npriority_queue p;\n\nvoid POP(ll T) {\n    while(!p.empty()) {\n        node tmp = p.top();\n        if(tmp.T > T) break;\n\n        p.pop();\n        s.insert(tmp.x);\n        v[tmp.x].insert({tmp.T, tmp.num});\n    }\n}\n\n\nint main() {\n    scanf(\"%d%d%d\", &n, &k, &m);\n    for(int i = 1; i <= k; i++) {\n        int loc; scanf(\"%d\", &loc);\n        p.push({i, loc, 0});\n    }\n    int a, b;\n    ll T;\n    for(int i = 1; i <= m; i++) {\n        \n        scanf(\"%I64d%d%d\", &T, &a, &b);    \n        // puts(\"!\");    \n        POP(T);\n        if(s.empty()) POP((p.top()).T);\n        // puts(\"!\");\n        auto it = s.lower_bound(a); int dis = INT_MAX;\n        int x;\n        pt contain;       \n        if(it != s.end()) {\n            x = *it;\n            dis = abs(*it - a);\n            contain = *v[x].begin();\n        }\n        if(it != s.begin()) {\n            it--; int x2 = *it;\n            if(abs(x2 - a) < dis) dis = abs(x2 - a), contain = *v[x2].begin(), x = x2;\n            else if(abs(x2 - a) == dis and *v[x2].begin() < contain)  contain = *v[x2].begin(), x = x2;\n        }\n        // puts(\"!\");\n        // printf(\"%d %I64d\\n\", dis, contain.first);\n        // puts(\"!\");\n        printf(\"%d %I64d\\n\", contain.second, dis + max(T, contain.first) - T);\n        s.erase(s.find(x)); v[x].erase(v[x].begin());\n        p.push({contain.second, b, dis + max(T, contain.first) + abs(b - a)});\n        // printf(\"!%d %I64d\\n\", contain.second, dis + max(T, contain.first) + abs(b - a));\n    }\n    return 0;\n}\n\n/*\n10 2 4\n1 10\n2 1 3\n3 10 9\n6 5 6\n7 6 5\n*/\n/*\n1 0\n2 0\n1 2\n2 3\n*/", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cc990774ec858d7cbfede56ad41f9db1", "src_uid": "cbfed699fd3d4eacfe36e1c064a4448c", "difficulty": 2500.0}
    {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\n//common reference \nint n,K,m;\n\n\n//define size\n#define pli pair\n#define N_ 201000\nmultiset AV;\nset V[N_];\n\npriority_queue PQ;\n\nstruct point{\n    int num, x;\n    long long T;\n    \n    bool operator<(const point &p) const{\n        return T>p.T;\n    }\n};\n\n//priority queue (PQ)\nvoid POP(long long T){\n    while(!PQ.empty()){\n        point tp = PQ.top();\n        if(tp.T > T)break;\n        PQ.pop();\n        AV.insert(tp.x);\n        V[tp.x].insert({tp.T, tp.num});\n    }\n}\n\nint main(){\n    \n    int i, x;\n    scanf(\"%d%d%d\",&n,&K,&m);\n    \n    for(i=1;i<=K;i++){\n        scanf(\"%d\",&x);\n        PQ.push({i,x,0});\n    }\n    \n    long long T;\n    int a, b;\n    for(i=0;i abs(x2-a) || (M==abs(x2-a) && *V[x2].begin() < tp))M = abs(x2-a), x = x2, tp = *V[x2].begin();\n        }\n        printf(\"%d %lld\\n\",tp.second, M + max(T, tp.first) - T);\n        PQ.push({tp.second, b, M + max(T, tp.first) + abs(b-a)});\n        V[x].erase(V[x].begin());\n        AV.erase(AV.find(x));\n    }\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "750f078d9bbaf6af82592fb427a4338a", "src_uid": "cbfed699fd3d4eacfe36e1c064a4448c", "difficulty": 2500.0}
    {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\n//common reference \nint n,K,m,i,x;\nlong long T;\nint a, b;\n\n//define size\n#define pli pair\n#define N_ 201000\nmultiset AV;\nset V[N_];\n\npriority_queue PQ;\n\nstruct point{\n    int num, x;\n    long long T;\n    \n    bool operator<(const point &p) const{\n        return T>p.T;\n    }\n};\n\n//priority queue (PQ)\nvoid POP(long long T){\n    while(!PQ.empty()){\n        point tp = PQ.top();\n        if(tp.T > T)break;\n        PQ.pop();\n        AV.insert(tp.x);\n        V[tp.x].insert({tp.T, tp.num});\n    }\n}\n\nint main(){\n    \n    //int i, x;\n    scanf(\"%d%d%d\",&n,&K,&m);\n    \n    for(i=1;i<=K;i++){\n        scanf(\"%d\",&x);\n        PQ.push({i,x,0});\n    }\n    \n    //long long T;\n    //int a, b;\n    for(i=0;i abs(x2-a) || (M==abs(x2-a) && *V[x2].begin() < tp))M = abs(x2-a), x = x2, tp = *V[x2].begin();\n        }\n        printf(\"%d %lld\\n\",tp.second, M + max(T, tp.first) - T);\n        PQ.push({tp.second, b, M + max(T, tp.first) + abs(b-a)});\n        V[x].erase(V[x].begin());\n        AV.erase(AV.find(x));\n    }\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0df04216b9cad21177f2400c0dd28b21", "src_uid": "cbfed699fd3d4eacfe36e1c064a4448c", "difficulty": 2500.0}
    {"lang": "GNU C++11", "source_code": "#define _CRT_SECURE_NO_WARNINGS \nvoid Solve(); int main() { Solve(); }\n#include  \n#include  \n#include  \n#include  \n#include  \n#include  \n#include  \n#include  \n#include  \n#include \n#include \n#include \n#include \nusing namespace std;\n#define int long long \n#define endl '\\n' \n#define fib(i, n) for (int i = n; i >= 0; i--) \n#define fi(i,a,b) for(int i = (a); i < (b); i++) \n#define MAX 1 << 10 \n#define pii pair\n#define F first\n#define S second\n#define pb push_back\n#define F first\n#define S second\n#define pb push_back\n#define MOD 1000000007\n#define MAXN 100500\n\ntypedef long long ll;\nint n, k, m;\nset > q[200002];\nset av;\nvector > ans;\ndeque > > waiting;\nmap>, vector>>> events;\n\nvoid assign(int i, int t, int a, int b) {\n\tassert(!av.empty());\n\tauto it = av.upper_bound(a);\n\tauto jt = it == av.begin() ? it : prev(it);\n\tif (it == av.end()) --it;\n\tint l = *it, r = *jt;\n\tif (abs(l - a) > abs(r - a)) swap(l, r);\n\tif (abs(l - a) == abs(r - a) && l != r) {\n\t\tif (*q[l].begin() > *q[r].begin()) l = r;\n\t}\n\tint driver = q[l].begin()->second;\n\tint wf = q[l].begin()->first;\n\tq[l].erase(q[l].begin());\n\tif (q[l].empty()) av.erase(l);\n\tint s = max(wf, t);\n\tans[i] = { driver, s - t + abs(l - a) };\n\tevents[s + abs(l - a) + abs(b - a)].second.emplace_back(driver, b);\n}\n\nvoid Solve()\n{\n#ifdef _DEBUG \n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif \n\tfor (; cin >> n >> k >> m; ) {\n\t\tfi(i, n) q[i].clear();\n\t\tav.clear();\n\t\tans.resize(m);\n\t\twaiting.clear();\n\t\tevents.clear();\n\n\t\tfi(i, k) {\n\t\t\tint x;\n\t\t\tcin >> x;\n\t\t\tq[x].emplace(0, i + 1);\n\t\t\tav.insert(x);\n\t\t}\n\t\tfi(i, m) {\n\t\t\tint t, a, b;\n\t\t\tcin >> t >> a >> b;\n\t\t\tevents[t].first.emplace_back(a, b);\n\t\t}\n\t\tint e = 0;\n\t\tfor (auto it : events) {\n\t\t\tint t = it.first;\n\t\t\tfor (auto jt : it.second.second) {\n\t\t\t\tint driver = abs(jt.first);\n\t\t\t\tq[jt.second].emplace(t, driver);\n\t\t\t\tav.insert(jt.second);\n\t\t\t}\n\t\t\twhile (waiting.size() > 0 && av.size() > 0) {\n\t\t\t\tauto cur = waiting.front();\n\t\t\t\twaiting.pop_front();\n\t\t\t\tassign(e++, cur.first, cur.second.first, cur.second.second);\n\t\t\t}\n\t\t\tfor (auto jt : it.second.first) {\n\t\t\t\tif (av.empty()) {\n\t\t\t\t\twaiting.emplace_back(t, jt);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tint a = jt.first, b = jt.second;\n\t\t\t\t\tassert(waiting.size() == 0);\n\t\t\t\t\tassign(e++, t, a, b);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tassert(waiting.size() == 0);\n\t\tfor (auto it : ans) cout << it.first << ' ' << it.second << '\\n';\n\t\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a4412797920ccaa7decbaa4408383602", "src_uid": "cbfed699fd3d4eacfe36e1c064a4448c", "difficulty": 2500.0}
    {"lang": "GNU C++11", "source_code": "#include\n#include\n\nusing namespace std;\n\n#define rep(i,a,b) for (int i=(a);i<=(b);i++)\n#define per(i,b,a) for (int i=(b);i>=(a);i--)\n#define ms(x,y) memset(x,y,sizeof(x))\n\nconst int N=605,X=90005,M=200005;\n\nint n,m,p,S,T,nA,nB,ans,du[N],le[X],ri[X],ans[X];\nint tot,lnk[N],son[M],w[M],v[M],nxt[M];\nint q[N],dst[N],pre[N];\nbool bo[N],vis[N];\n\nint read()\n{\n\tint x=0;char ch=getchar();\n\twhile (ch<'0'||ch>'9') ch=getchar();\n\twhile (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();\n\treturn x;\n}\nvoid Ifmin(int &x,int y) {if (y0&&dst[x]+v[j]\n#define ll long long\n#define ull unsigned ll\n#define uint ungigned\n#define db long double\n#define pii pair\n#define IT iterator\n\n#define PB push_back\n#define MK make_pair\n#define LB lower_bound\n#define UB upper_bound\n#define fi first\n#define se second\n\n#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)\n#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)\n#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)\n#define CLR(a,v) memset(a,v,sizeof(a));\n#define CPY(a,b) memcpy(a,b,sizeof(a));\n\n#define LS3 k*2,l,mid\n#define RS3 k*2+1,mid+1,r\n#define LS5 k*2,l,mid,x,y\n#define RS5 k*2+1,mid+1,r,x,y\n#define GET pushdown(k);int mid=(l+r)/2\n\n#define INF ((1<<30)-233)\n#define sqr(x) ((x)*(x))\n#define debug puts(\"wzpkking\")\nusing namespace std;\n\nconst int M=5555;\nconst int N=205;\n\nstruct edge{\n\tint to,next,f;\n}e[M*10];\nint head[M],tot=1;\nint q[M],dis[M];\nint nd,S,T;\nvoid add(int x,int y,int f){\n\te[++tot]=(edge){y,head[x],f};\n\thead[x]=tot;\n\te[++tot]=(edge){x,head[y],0};\n\thead[y]=tot;\n}\nbool bfs(){\n\tFor(i,1,nd) dis[i]=-1;\n\tint h=0,t=1; dis[q[1]=S]=0;\n\twhile (h!=t){\n\t\tint x=q[++h];\n\t\tfor (int i=head[x];i;i=e[i].next)\n\t\t\tif (dis[e[i].to]==-1&&e[i].f){\n\t\t\t\tdis[e[i].to]=dis[x]+1;\n\t\t\t\tif (e[i].to==T) return 1;\n\t\t\t\tq[++t]=e[i].to;\n\t\t\t}\n\t}\n\treturn 0;\n}\nint dfs(int x,int flow){\n\tif (x==T) return flow;\n\tint k,rest=flow;\n\tfor (int i=head[x];i&&rest;i=e[i].next)\n\t\tif (dis[e[i].to]==dis[x]+1&&e[i].f){\n\t\t\tk=dfs(e[i].to,min(rest,e[i].f));\n\t\t\te[i].f-=k; e[i^1].f+=k; rest-=k;\n\t\t}\n\tif (rest) dis[x]=-1;\n\treturn flow-rest;\n}\n\nint n,m,k,s,ans[M];\nint sz[2][N],id[2][N];\nmap Id[M];\nint main(){\n\tscanf(\"%d%d%d%d\",&n,&m,&k,&s);\n\tif (s==1){\n\t    puts(\"0\");\n\t\tFor(i,1,k) printf(\"1 \");\n\t\treturn 0;\n\t}\n\tnd=2; S=1; T=2; \n\tFor(i,1,n) sz[0][i]=s;\n\tFor(i,1,m) sz[1][i]=s;\n\tFor(i,1,k){\n\t\tint x,y;\n\t\tscanf(\"%d%d\",&x,&y);\n\t\tif (sz[0][x]==s){\n\t\t\tsz[0][x]=0;\n\t\t\tid[0][x]=++nd;\n\t\t\tadd(S,nd,1);\n\t\t}\n\t\tsz[0][x]++; x=id[0][x];\n\t\tif (sz[1][y]==s){\n\t\t\tsz[1][y]=0;\n\t\t\tid[1][y]=++nd;\n\t\t\tadd(nd,T,1);\n\t\t}\n\t\tsz[1][y]++; y=id[1][y];\n\t\tadd(x,y,1);\n\t\tId[x][y]=i;\n\t}\n\t\n\tint ans=0;\n\tFor(i,1,n) ans+=(sz[0][i]!=s);\n\tFor(i,1,m) ans+=(sz[1][i]!=s);\n\tprintf(\"%d\\n\",ans);\n\t\n\tFor(i,1,s){\n\t\tint ans2=0;\n\t\tfor (;bfs();ans2+=dfs(S,INF));\n\t\tFor(j,1,nd)\n\t\t\tfor (int k=head[j];k;k=e[k].next)\n\t\t\t\tif (!(k&1)){\n\t\t\t\t\tif (j==S||e[k].to==T)\n\t\t\t\t\t\te[k].f=1,e[k^1].f=0;\n\t\t\t\t\telse if (!e[k].f&&e[k^1].f){\n\t\t\t\t\t\tans[Id[j][e[k].to]]=i;\n\t\t\t\t\t\te[k^1].f=0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t}\n\t\n\tFor(i,1,k)\n\t\tprintf(\"%d \",ans[i]);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "239555b76cda33964fddf50f77330c78", "src_uid": "99b97aabec566e5f966777947271ad3c", "difficulty": 3000.0}
    {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst int inf=1e9;\nstruct fur\n{\n    int id,day;\n    bool operator <(const fur &temp)const\n    {\n         return day0&&dist[id]==dist[ip]+1)\n            {\n                cur[id]=i;\n                stk[1][top-1]=i;\n                stk[0][top]=ip;\n                flow[ip]=min(flow[id],adj[id][i].c);\n                break;\n            }\n        }\n        if(i=0;i--)\n                {\n                    int ie=stk[1][i];\n                    id=stk[0][i];\n                    adj[id][ie].c-=flow[ip];\n                    adj[adj[id][ie].id][to[id][ie]].c+=flow[ip];\n                }\n                top=1;\n            }\n        }\n        else\n        {\n            gap[dist[id]]--;\n            if(gap[dist[id]]==0)\n               return res;\n            dist[id]=n;\n            cur[id]=0;\n            for(i=0;i0&&dist[id]>dist[ip]+1)\n                {\n                    dist[id]=dist[ip]+1;\n                    cur[id]=i;\n                }\n            }\n            if(dist[id]1)\n               top--;\n        }\n        if(dist[st]>=n)\n           return res;\n    }\n}\nint main()\n{\n    int i,j,s,p,q,id1,id2,id,ip,ie;\n    bool fir;\n    scanf(\"%d%d%d%d\",&n,&m,&k,&t);\n    memset(deg,0,sizeof(deg));\n    for(i=0;i=0&&adj[j+1][s].c==0)\n                {\n                    ie=adj[j+1][s].ie;\n                 //   printf(\"ie=%d,i=%d\\n\",ie,i);\n                    deg[e[0][ie]]--;\n                    deg[e[1][ie]+n]--;\n                    ans[ie]=i+1;\n                }\n            }\n        }\n    }\n    printf(\"%d\\n\",re);\n    for(i=0;i\nusing namespace std;\nusing lint = long long;\nusing pi = pair;\n#define sz(v) ((int)(v).size())\n#define all(v) (v).begin(), (v).end()\nconst int MAXN = 5005;\nconst int MAXM = 5005;\n\nstruct edge_color{ // must use 1-based\n\tint deg[2][MAXN];\n\tpi has[2][MAXN][MAXN];\n\tint color[MAXM];\n\tint c[2];\n\n\tvoid clear(int n){\n\t\tfor(int t=0; t<2; t++){\n\t\t\tfor(int i=0; i<=n; i++){\n\t\t\t\tdeg[t][i] = 0;\n\t\t\t\tfor(int j=0; j<=n; j++){\n\t\t\t\t\thas[t][i][j] = pi(0, 0);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tvoid dfs(int x, int p) {\n\t\tauto i = has[p][x][c[!p]];\n\t\tif (has[!p][i.first][c[p]].second) dfs(i.first,!p);\n\t\telse has[!p][i.first][c[!p]] = pi(0,0);\n\t\thas[p][x][c[p]] = i;\n\t\thas[!p][i.first][c[p]] = pi(x,i.second);\n\t\tcolor[i.second] = c[p];\n\t}\n\n\tint solve(vector v, vector &cv){\n\t\tint m = sz(v);\n\t\tint ans = 0;\n\t\tfor (int i=1;i<=m;i++) {\n\t\t\tint x[2];\n\t\t\tx[0] = v[i-1].first;\n\t\t\tx[1] = v[i-1].second;\n\t\t\tfor (int d=0;d<2;d++) {\n\t\t\t\tdeg[d][x[d]]+=1;\n\t\t\t\tans = max(ans,deg[d][x[d]]);\n\t\t\t\tfor (c[d]=1;has[d][x[d]][c[d]].second;c[d]++);\n\t\t\t}\n\t\t\tif (c[0]!=c[1]) dfs(x[1],1);\n\t\t\tfor (int d=0;d<2;d++) has[d][x[d]][c[0]] = pi(x[!d],i);\n\t\t\tcolor[i] = c[0];\n\t\t}\n\t\tcv.resize(m);\n\t\tfor(int i=1; i<=m; i++){\n\t\t\tcv[i-1] = color[i];\n\t\t\tcolor[i] = 0;\n\t\t}\n\t\treturn ans;\n\t}\n}EC;\n\nint cnt[2][MAXN];\nint idx[2][MAXN], L, R;\n\nint main(){\n\tint m, t;\n\tscanf(\"%*d %*d %d %d\",&m,&t);\n\tvector ans;\n\tfor(int i=0; i 0);\n\t\tret += (cnt[1][i] > 0);\n\t}\n\tcout << ret << endl;\n\tvector color;\n\tEC.solve(ans, color);\n\tfor(auto &i : color) printf(\"%d \", i);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3a06982e55506dea7fa2be08aae2770b", "src_uid": "99b97aabec566e5f966777947271ad3c", "difficulty": 3000.0}
    {"lang": "GNU C++17", "source_code": "#include \n#include \n\nusing namespace std;\n\nconst size_t MAX = 1 << 17;\n\nvector graph[MAX];\nsize_t n, parent[MAX], sz[MAX], depth[MAX];\n\nsize_t subtree_size(size_t u, size_t v)\n{\n    auto re = parent[v] == u ? sz[v] : n - sz[u];\n    //cout << u << \"-(\" << v << \" -> \" << re << endl;\n    return re;\n}\n\nvoid dfs(size_t u)\n{\n    sz[u] = 1;\n    for(auto v : graph[u])\n        if(v != parent[u])\n            parent[v] = u, depth[v] = depth[u] + 1, dfs(v), sz[u] += sz[v];\n}\n\nsize_t find_centroid(size_t u)\n{\n    while(true)\n    {\n        bool any = false;\n        for(auto v : graph[u])\n          if(subtree_size(u, v) > subtree_size(v, u))\n        {\n            u = v;\n            any = true;\n            break;\n        }\n        if(not any)\n            break;\n    }\n    return u;\n}\n\nvoid dfs2(size_t u, vector& ord)\n{\n    ord.push_back(u);\n    for(auto v : graph[u])\n        if(v != parent[u])\n            dfs2(v, ord);\n}\n\nint main()\n{\n    cin >> n;\n\n    for(size_t i = 0; i < n - 1; i++)\n    {\n        size_t u, v;\n        cin >> u >> v;\n        graph[u].push_back(v);\n        graph[v].push_back(u);\n    }\n\n    dfs(1);\n    auto cen = find_centroid(1);\n\n    fill(parent, parent + MAX, 0);\n    fill(sz, sz + MAX, 0);\n    fill(depth, depth + MAX, 0);\n    dfs(cen);\n\n    vector> groups;\n    for(auto u : graph[cen])\n    {\n        vector curr;\n        dfs2(u, curr);\n        groups.push_back(curr);\n    }\n\n    vector to(n+1);\n    size_t last = cen, m = n;\n\n    while(m > 1)\n    {\n        for(auto& g : groups)\n          if(not g.empty())\n        {\n            to[last] = g.back();\n            m--;\n            last = g.back();\n            g.pop_back();\n        }\n    }\n    to[last] = cen;\n\n    uint64_t result = 0;\n    for(size_t u = 1; u <= n; u++)\n        result += depth[u] + depth[to[u]];\n\n    cout << result << endl;\n    for(size_t u = 1; u <= n; u++)\n        cout << to[u] << ' ';\n    cout << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4f902d5eb7afc5273e2c923467f52c90", "src_uid": "343dbacbc6bb4981a062dda5a1a13656", "difficulty": 2500.0}
    {"lang": "GNU C++17", "source_code": "/*\n\nCode for problem  by cookiedoth\nGenerated 23 Jul 2020 at 05.35 PM\n\n\n\u0421\u0422\u0420\u041e\u0418\u041c \u041a\u041e\u041c\u041c\u0423\u041d\u0418\u0417\u041c \u0420\u0410\u0411\u041e\u0422\u042f\u0413\u0418!\n \n                                    \u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2588\n                          \u2588\u2588\u2588\u2588\u2584\u2584\u2584\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2588\n                  \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2584\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2588\n\u2588\u2550\u2566\u2550\u2569\u2550\u2566\u2584\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2580\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2566\u2550\u2569\u2550\u2566\u2550\u2588\n\u2588\u2550\u2569\u2550\u2566\u2550\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2550\u2566\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2550\u2566\u2550\u2569\u2550\u2588\n\u2588\u2550\u2566\u2550\u2584\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2569\u2550\u2566\u2550\u2569\u2584\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2550\u2566\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2550\u2566\u2550\u2588\n\u2588\u2550\u2569\u2550\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2569\u2550\u2566\u2550\u2569\u2550\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2569\u2550\u2566\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2550\u2569\u2550\u2588\n\u2588\u2550\u2566\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2566\u2550\u2569\u2550\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2566\u2550\u2588\n\u2588\u2550\u2569\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2584\u2588\u2588\u2584\u2550\u2566\u2550\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2550\u2566\u2550\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2569\u2550\u2588\n\u2588\u2550\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2550\u2566\u2550\u2580\u2588\u2588\u2588\u2588\u2588\u2580\u2550\u2569\u2550\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2550\u2588\n\u2588\u2550\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2550\u2566\u2550\u2580\u2588\u2588\u2588\u2569\u2550\u2566\u2550\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2550\u2588\n\u2588\u2550\u2566\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2569\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2550\u2566\u2550\u2580\u2550\u2566\u2550\u2569\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2566\u2550\u2588\n\u2588\u2550\u2569\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2550\u2569\u2550\u2566\u2550\u2569\u2580\u2580\u2588\u2588\u2588\u2580\u2580\u2569\u2550\u2566\u2550\u2569\u2550\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2569\u2550\u2588\n\u2588\u2550\u2566\u2550\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2550\u2566\u2550\u2584\u2584\u2588\u2584\u2584\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2550\u2566\u2550\u2588\n\u2588\u2550\u2569\u2550\u2580\u2588\u2588\u2588\u2588\u2550\u2569\u2550\u2584\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2584\u2584\u2584\u2588\u2588\u2588\u2588\u2584\u2550\u2566\u2550\u2569\u2588\u2588\u2588\u2588\u2588\u2580\u2550\u2569\u2550\u2588\n\u2588\u2550\u2566\u2550\u2569\u2550\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2550\u2584\u2588\u2588\u2588\u2588\u2550\u2569\u2550\u2566\u2550\u2588\n\u2588\u2550\u2569\u2550\u2566\u2550\u2569\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2569\u2550\u2566\u2550\u2569\u2550\u2588\n\u2588\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2580\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2588\n\u2588\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2580\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2580\u2580\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2588\n\u2588\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2580\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2588\n\u2588\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2566\u2550\u2569\u2550\u2588\n\u2588\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2584\u2588\n\n\u00af\\_(\u30c4)_/\u00af\n^_^\n-_-\n\n*/\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define ll long long\n#define ld long double\n#define null NULL\n#define all(a) a.begin(), a.end()\n#define rall(a) a.rbegin(), a.rend()\n#define debug(a) cerr << #a << \" = \" << a << endl\n#define forn(i, n) for (int i = 0; i < n; ++i)\n#define sz(a) (int)a.size()\n\nusing namespace std;\n\ntemplate int chkmax(T &a, T b) {\n\tif (b > a) {\n\t\ta = b;\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\ntemplate int chkmin(T &a, T b) {\n\tif (b < a) {\n\t\ta = b;\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\ntemplate void output(iterator begin, iterator end, ostream& out = cerr) {\n\twhile (begin != end) {\n\t\tout << (*begin) << \" \";\n\t\tbegin++;\n\t}\n\tout << endl;\n}\n\ntemplate void output(T x, ostream& out = cerr) {\n\toutput(x.begin(), x.end(), out);\n}\n\nvoid fast_io() {\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n\tcout.tie(0);\n}\n\nconst int INF = 1e9;\nconst int mx = 1e5 + 228;\nint n, sz[mx], d[mx][mx];\nvector > g;\n\nvoid build_d() {\n\tfor (int i = 0; i < n; ++i) {\n\t\tfor (int j = 0; j < n; ++j) {\n\t\t\tif (i != j) {\n\t\t\t\td[i][j] = INF;\n\t\t\t}\n\t\t}\n\t}\n\tfor (int i = 0; i < n; ++i) {\n\t\tfor (auto v : g[i]) {\n\t\t\td[i][v] = 1;\n\t\t}\n\t}\n\tfor (int k = 0; k < n; ++k) {\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tfor (int j = 0; j < n; ++j) {\n\t\t\t\tchkmin(d[i][j], d[i][k] + d[k][j]);\n\t\t\t}\n\t\t}\n\t}\n}\n\nvoid read() {\n\tcin >> n;\n\tg.resize(n);\n\tfor (int i = 0; i < n - 1; ++i) {\n\t\tint u, v;\n\t\tcin >> u >> v;\n\t\tu--;\n\t\tv--;\n\t\tg[u].push_back(v);\n\t\tg[v].push_back(u);\n\t}\n}\n\nvoid calc_sz(int v, int pv) {\n\tsz[v] = 1;\n\tfor (auto v1 : g[v]) {\n\t\tif (v1 != pv) {\n\t\t\tcalc_sz(v1, v);\n\t\t\tsz[v] += sz[v1];\n\t\t}\n\t}\n}\n\nint find_centroid(int v, int pv) {\n\tfor (auto v1 : g[v]) {\n\t\tif (v1 != pv && 2 * sz[v1] > n) {\n\t\t\treturn find_centroid(v1, v);\n\t\t}\n\t}\n\treturn v;\n}\n\nvector > subtrees;\n\nvoid add_to_last_subtree(int v, int pv) {\n\tsubtrees.back().push_back(v);\n\tfor (auto v1 : g[v]) {\n\t\tif (v1 != pv) {\n\t\t\tadd_to_last_subtree(v1, v);\n\t\t}\n\t}\n}\n\nint c;\n\nvoid add_subtrees() {\n\tfor (auto v1 : g[c]) {\n\t\tsubtrees.push_back(vector ());\n\t\tadd_to_last_subtree(v1, c);\n\t}\n}\n\nset, int> > S;\n\nvoid construct_S() {\n\tfor (int i = 0; i < subtrees.size(); ++i) {\n\t\t// int t = (2 * subtrees[i].size() >= n ? INF : subtrees[i].size());\n\t\tint t = subtrees[i].size();\n\t\tS.insert({{t, t}, i});\n\t}\n\tS.insert({{1, 1}, subtrees.size()});\n\tsubtrees.push_back({c});\n\t// cerr << \"subtrees\" << endl;\n\t// for (auto v : subtrees) {\n\t// \toutput(all(v));\n\t// }\n}\n\nvector order;\n\nvoid process() {\n\tint lst = -1;\n\tfor (int i = 0; i < n; ++i) {\n\t\tauto it = prev(S.end());\n\t\twhile (it->second == lst) {\n\t\t\tit--;\n\t\t}\n\t\tauto pp = (*it);\n\t\tS.erase(it);\n\t\tlst = pp.second;\n\t\torder.push_back(subtrees[pp.second].back());\n\t\tsubtrees[pp.second].pop_back();\n\t\tpp.first.first--;\n\t\tS.insert(pp);\n\t}\n\t// output(all(order));\n}\n\nvector p;\nll ans;\n\nvoid print_ans() {\n\tp.resize(n);\n\tcalc_sz(c, c);\n\tfor (int i = 0; i < n; ++i) {\n\t\tif (i != c) {\n\t\t\tans += 2 * (ll)sz[i];\n\t\t}\n\t}\n\tfor (int i = 0; i < n; ++i) {\n\t\tp[order[i]] = order[(i + 1) % n];\n\t}\n\tcout << ans << '\\n';\n\tfor (int i = 0; i < n; ++i) {\n\t\tcout << p[i] + 1 << ' ';\n\t}\n\tcout << '\\n';\n}\n\nvoid check_ans() {\n\tbuild_d();\n\tll real_ans = 0;\n\tfor (int i = 0; i < n; ++i) {\n\t\tassert(p[i] != i);\n\t\treal_ans += d[i][p[i]];\n\t}\n\tassert(ans == real_ans);\n}\n\nsigned main() {\n\tfast_io();\n\tread();\n\tcalc_sz(0, 0);\n\tc = find_centroid(0, 0);\n\t// cerr << \"c = \" << c << endl;\n\tadd_subtrees();\n\tconstruct_S();\n\tprocess();\n\tprint_ans();\n\t// check_ans();\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "17944f95464f6dd9e9981f49cb1afd70", "src_uid": "343dbacbc6bb4981a062dda5a1a13656", "difficulty": 2500.0}
    {"lang": "GNU C++14", "source_code": "// Null\n#include \n\n#define pb push_back\n#define F first\n#define S second\n#define all(x) x.begin(), x.end()\n#define debug(x) cerr << #x << \" : \" << x << '\\n'\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef string str;\ntypedef pair pll;\n\nconst ll Mod = 1000000007LL;\nconst int N = 1e5 + 10;\nconst ll Inf = 2242545357980376863LL;\nconst ll Log = 30;\n\nvector G[N];\nint n;\nll ans;\nint sub[N];\n\nint DFS(ll u, ll p){\n\tsub[u] = 1;\n\tfor(auto adj : G[u]){\n\t\tif(adj == p) continue;\n\t\tsub[u] += DFS(adj, u);\n\t}\n\tans += min(sub[u], n - sub[u]);\n\treturn sub[u];\n}\nvector V;\nvoid dfs(ll u, ll p){\n\tV.pb(u);\n\tfor(auto adj : G[u]) if(adj != p) dfs(adj, u);\n}\nint des[N];\nint main(){\n\tios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n\tcin >> n;\n\tll u, v;\n\tfor(int i = 1; i < n; i++){\n\t\tcin >> u >> v;\n\t\tG[u].pb(v);\n\t\tG[v].pb(u);\n\t}\n\tDFS(1, -1);\n\tcout << ans + ans << '\\n';\n\n\tll cen = 1;\n\tbool fnd = false;\n\twhile(!fnd){\n\t\tfnd = true;\n\t\tfor(auto adj : G[cen]){\n\t\t\tif(sub[adj] >= sub[cen]) continue;\n\t\t\tif(sub[adj] + sub[adj] > n){\n\t\t\t\tfnd = false;\n\t\t\t\tcen = adj;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tdfs(cen, -1);\n\tll jmp = n/2;\n\tassert((V.size() == n))\n\tfor(int i = 0; i < n; i++){\n\t\tll idx = (i + jmp) % n;\n\t\tdes[V[i]] = V[idx];\n\t}\n\tfor(int i = 1; i <= n; i++) cout << des[i] << ' ';\n\tcout << '\\n';\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b74ecb9620d8703cf1d9d12da80533b8", "src_uid": "343dbacbc6bb4981a062dda5a1a13656", "difficulty": 2500.0}
    {"lang": "GNU C++14", "source_code": "#include  \n#define ll long long\n#define F first\n#define FF first.first\n#define FS first.second\n#define S second\n#define pb push_back\nusing namespace std;\nconst int N=1000006, INF=1e9+1;\n \nll n, q=1, m, a[N], f[N], o, k, t, x, y, d, Y, z, w, l, r, u, h, mx, mn, ans, Ans[N];\nvector v[N], e[N];\n\nvoid dfs(int x, int pa){\n\te.pb(x);\n\tfor (int i=0; in)DFS(y, x);\n\t}\n}\n\nmain(){ios_base::sync_with_stdio(false), cin.tie(0);\n\tcin>>n;\n\tfor (int i=1; i>x>>y;\n\t\tv[x].pb(y);\n\t\tv[y].pb(x);\n\t\tsz[i]=1;\n\t}\n\tdfs(1, 1);\n\tDFS(1, 1);\n\te.clear();Dfs(k, k);\n\t\n\tfor (int i=0; i\n#include \n#include \nusing namespace std;\nint N, R;\ndouble a[51][6000];\nint f[50], s[50];\ndouble p[50];\nint main(int argc, char *argv[]) {\n\tios_base::sync_with_stdio(false);\n\tcin.tie(nullptr);\n\tcin >> N >> R;\n\tfor(int i = 0; i < N; i++) {\n\t\tcin >> f[i] >> s[i] >> p[i];\n\t\tp[i] /= 100;\n\t}\n\tdouble l = 0, pl = -1e9;;\n\twhile(fabs(l - pl) > 1e-10) {\n\t\t//cerr << l << '\\n';\n\t\tpl = l;\n\t\tfor(int t = 0; t <= 5000; t++)\n\t\t\ta[N][t] = (t <= R ? t : 1e100);\n\t\tfor(int i = N - 1; i >= 0; i--)\n\t\t\tfor(int t = 0; t <= 5000; t++)\n\t\t\t\ta[i][t] = p[i] * min(t + f[i] + T, a[i + 1][t + f[i]]) + (1 - p[i]) * min(t + s[i] + T, a[i + 1][t + s[i]]);\n\t\tl = a[0][0];\n\t}\n\tcout << fixed << setprecision(10) << l << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6891b7d9faa3aa3e3987606d89cdc519", "src_uid": "b461bb51eab4ff8088460c1980dacb93", "difficulty": 2400.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\nint N, R;\ndouble a[51][6000];\nint f[50], s[50];\ndouble p[50];\nint main(int argc, char *argv[]) {\n\tios_base::sync_with_stdio(false);\n\tcin.tie(nullptr);\n\tcin >> N >> R;\n\tfor(int i = 0; i < N; i++) {\n\t\tcin >> f[i] >> s[i] >> p[i];\n\t\tp[i] /= 100;\n\t}\n\tdouble T = 0, pT = -1e9;;\n\twhile(fabs(T - pT) / max(1, T) > 1e-10) {\n\t\t//cerr << l << '\\n';\n\t\tpT = T;\n\t\tfor(int t = 0; t <= 5000; t++)\n\t\t\ta[N][t] = (t <= R ? t : 1e100);\n\t\tfor(int i = N - 1; i >= 0; i--)\n\t\t\tfor(int t = 0; t <= 5000; t++)\n\t\t\t\ta[i][t] = p[i] * min(t + f[i] + T, a[i + 1][t + f[i]]) + (1 - p[i]) * min(t + s[i] + T, a[i + 1][t + s[i]]);\n\t\tT = a[0][0];\n\t}\n\tcout << fixed << setprecision(10) << T << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c01ddb1218cb80d7599951303ab0b712", "src_uid": "b461bb51eab4ff8088460c1980dacb93", "difficulty": 2400.0}
    {"lang": "GNU C++14", "source_code": "using namespace std;\n#include\n#include\n#include\n#include\n#include \n#include \n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define sqr(x) (x)*(x)\n#define sort stable_sort\n#define ll long long\n#define mp make_pair\n#define pb push_back\n#define in insert\n#define mtr(x,y,z) mp(mp(x,y),z)\n#define fi first\n#define se second\n#define lch(x) ((x)<<1)\n#define rch(x) (((x)<<1)|1)\n#define all(x) (x).begin(),(x).end()\n#define fpi(x) freopen(x,\"r\",stdin);\n#define fpo(x) freopen(x,\"w\",stdout);\n#define fprio fpi(\"in.txt\");fpo(\"out.txt\"):\n#define fast ios::sync_with_stdio(false);\nvoid readi(int &x)\n{\n\tint v=0,f=1;\n\tchar c=getchar();\n\twhile (!isdigit(c)&&c!='-') c=getchar();\n\tif (c=='-') f=-1; else v=v*10+c-'0';\n\twhile (isdigit(c=getchar())) v=v*10+c-'0';\n\tx=v*f;\n}\nvoid readll(ll &x)\n{\n\tll v=0ll,f=1ll;\n\tchar c=getchar();\n\twhile (!isdigit(c)&&c!='-') c=getchar();\n\tif (c=='-') f=-1; else v=v*10+c-'0';\n\twhile (isdigit(c=getchar())) v=v*10+c-'0';\n\tx=v*f;\n}\nvoid readc(char &x)\n{\n\tchar c;\n\twhile ((c=getchar())==' ');\n\tx=c;\n}\nvoid writes(string s){puts(s.c_str());}\nvoid writeln(){writes(\"\");}\nvoid writei(int x)\n{\n\tif (!x) putchar('0');\n\tchar a[25];\n\tint top=0;\n\twhile (x)\n\t{\n\t\ta[++top]=(x%10)+'0';\n\t\tx/=10;\n\t}\n\twhile (top)\n\t{\n\t\tputchar(a[top]);\n\t\ttop--;\n\t}\n}\nvoid writell(ll x)\n{\n\tif (!x) putchar('0');\n\tchar a[25];\n\tint top=0;\n\twhile (x)\n\t{\n\t\ta[++top]=(x%10)+'0';\n\t\tx/=10;\n\t}\n\twhile (top)\n\t{\n\t\tputchar(a[top]);\n\t\ttop--;\n\t}\n}\n/*************************************************/\nint n,m,i,j,mid,s[55],t[55];\ndouble p[55],l,r,dp[55][5555];\nint main()\n{\n\tcin>>n>>m;\n\tfor (i=1;i<=n;i++)\n\t{\n\t\tcin>>s[i]>>t[i]>>p[i];\n\t\tp[i]/=100.0;\n\t}\n\tl=0;r=1e16;\n\twhile (l\n#include \n#include \nusing namespace std;\nint N, R;\ndouble a[51][6000];\nint f[50], s[50];\ndouble p[50];\nint main(int argc, char *argv[]) {\n\tios_base::sync_with_stdio(false);\n\tcin.tie(nullptr);\n\tcin >> N >> R;\n\tfor(int i = 0; i < N; i++) {\n\t\tcin >> f[i] >> s[i] >> p[i];\n\t\tp[i] /= 100;\n\t}\n\tdouble T = 0, pT = -1e9;;\n\twhile(fabs(l - pl) > 1e-10) {\n\t\t//cerr << l << '\\n';\n\t\tpT = T;\n\t\tfor(int t = 0; t <= 5000; t++)\n\t\t\ta[N][t] = (t <= R ? t : 1e100);\n\t\tfor(int i = N - 1; i >= 0; i--)\n\t\t\tfor(int t = 0; t <= 5000; t++)\n\t\t\t\ta[i][t] = p[i] * min(t + f[i] + T, a[i + 1][t + f[i]]) + (1 - p[i]) * min(t + s[i] + T, a[i + 1][t + s[i]]);\n\t\tT = a[0][0];\n\t}\n\tcout << fixed << setprecision(10) << T << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0e2c1216a48f35a2df3995327db31ecc", "src_uid": "b461bb51eab4ff8088460c1980dacb93", "difficulty": 2400.0}
    {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long coord;\n\nstruct vec{\n\tcoord x, y; int id;\n\tvec(coord a = 0, coord b = 0) : x(a), y(b) {}\n\tvec operator+(const vec &o) const{\n\t\treturn {x + o.x, y + o.y};\n\t}\n    vec operator-(const vec &o) const{\n        return {x - o.x, y - o.y};\n    }\n    coord operator*(const vec &o) const{\n        return x * o.x + y * o.y;\n    }\n\tcoord operator^(const vec &o) const{ // sin\n\t\treturn x * o.y - y * o.x;\n\t}\n\tbool operator<(const vec &o) const{\n\t\tif(x != o.x) return x < o.x;\n\t\treturn y < o.y;\n\t}\n\tcoord cross(const vec &a, const vec &b) const{\n\t\treturn (a-(*this)) ^ (b-(*this));\n\t}\n    coord dot(const vec &a, const vec &b) const{\n        return (a-(*this)) * (b - (*this));\n    }\n    int ccw(const vec &a, const vec &b) const{\n        coord tmp = cross(a, b);\n        return (tmp > 0) - (tmp < 0);\n    }\n};\n\nconst int N = 1000006;\n\nvector mk(const vector&a,const vector&b){\n    int i = 0, j = 0;\n    for(int k = 0; k < (int)a.size(); k++)if(a[k]  c;\n    c.reserve(a.size() + b.size());\n    vec pt;\n    for(int k = 0; k < int(a.size()+b.size()); k++){\n        pt = a[i] + b[j];\n        if((int)c.size() >= 2\n            && c[c.size()-2].ccw(c.back(), pt) == 0)\n            c.pop_back();\n        c.push_back(pt);\n        int q = i+1, w = j+1;\n        if(q == int(a.size())) q = 0;\n        if(w == int(b.size())) w = 0;\n        if(c.back().ccw(a[i]+b[w], a[q]+b[j]) == -1) i = q;\n        else j = w;\n    }\n    c.shrink_to_fit();\n\n    return c;\n}\n\n\nvec lo[N], hi[N];\nint nl, nh;\n\nbool below(vec p){\n    auto it = lower_bound(hi, hi+nh, p);\n    if(it == hi) return p.x == hi[0].x && p.y == hi[0].y;\n    if(it == hi+nh) return false;\n    return prev(it)->cross(*it, p) <= 0;\n}\n\nbool above(vec p){\n    auto it = lower_bound(lo, lo+nl, p);\n    if(it == lo) return p.x == lo[0].x && p.y == lo[0].y;\n    if(it == lo+nl) return false;\n    return prev(it)->cross(*it, p) >= 0;\n}\n\nbool inside(vec p){\n    return below(p) && above(p);\n}\n\nbool inside(const vector &v, vec p){\n    if(v[0].ccw(v[1], p) < 0) return false;\n    if(v[0].ccw(v.back(), p) > 0) return 0;\n    if(v[0].ccw(v.back(), p) == 0){\n        // return v[0].dot(p, v.back()) >= 0 && v.back().dot(p, v[0]) >= 0;\n    }\n\n    int L = 1, R = (int)v.size() - 1, ans = 1;\n\n    while(L <= R){\n        int mid = (L+R)/2;\n        if(v[0].ccw(v[mid], p) >= 0) ans = mid, L = mid+1;\n        else R = mid-1;\n    }\n\n    return v[ans].ccw(v[(ans+1)%v.size()], p) >= 0;\n}\n\nint main(){\n\n    vector a, b;\n    int n, m;\n    scanf(\"%d\", &n);\n    a.resize(n);\n\n    for(int i = 0; i < n; i++)\n        scanf(\"%lld %lld\", &a[i].x, &a[i].y);\n\n    /*for(int i = 0; i < sz; i++)\n        printf(\"%lld %lld\\n\", a[i].x, a[i].y);\n    printf(\"\\n\");\n    printf(\"\\n\");*/\n    scanf(\"%d\", &m);\n    b.resize(m);\n    for(int i = 0; i < m; i++)\n        scanf(\"%lld %lld\", &b[i].x, &b[i].y);\n    a = mink(a, b);\n\n    scanf(\"%d\", &m);\n    b.resize(m);\n    for(int i = 0; i < m; i++)\n        scanf(\"%lld %lld\", &b[i].x, &b[i].y);\n    a = mink(a, b);\n    n = (int)a.size();\n\n\n    /*for(int i = 0; i < sz; i++)\n        printf(\"%lld %lld\\n\", a[i].x, a[i].y);\n\n    printf(\"\\n\");\n    printf(\"\\n\");*/\n\n    {\n        int w = 0, e = 0;\n        for(int i = 0; i < n; i++){\n            if(a[i] < a[w]) w = i;\n            if(a[e] < a[i]) e = i;\n        }\n\n        for(int i = w; ; i++){\n            if(i == n) i = 0;\n            lo[nl++] = a[i];\n            if(i == e) break;\n        }\n        for(int i = e; ; i++){\n            if(i == n) i = 0;\n            hi[nh++] = a[i];\n            if(i == w) break;\n        }\n        reverse(hi, hi+nh);\n    }\n\n    // for(auto x : a) printf(\"%lld %lld\\n\", x.x, x.y);\n\n    /*for(int i = 0; i < nl; i++)\n        printf(\"%lld %lld\\n\", lo[i].x, lo[i].y);\n\n    printf(\"\\n\");\n    printf(\"\\n\");\n\n    for(int i = 0; i < nh; i++)\n        printf(\"%lld %lld\\n\", hi[i].x, hi[i].y);\n\n    printf(\"\\n\");\n    printf(\"\\n\");*/\n\n    int q;\n\n    scanf(\"%d\", &q);\n    vec v;\n\n    while(q--){\n        scanf(\"%lld %lld\", &v.x, &v.y);\n        v.x *= 3;\n        v.y *= 3;\n        printf(\"%s\\n\", inside(v) ? \"YES\" : \"NO\");\n    }\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7934ccda4e1d2913c30154f655c2a9da", "src_uid": "a764daf8e19e48a0735811a4f67485c3", "difficulty": 2600.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define li\t\tlong long\n#define rep(i,to)\tfor(li i=0;i<((li)to);i++)\n#define pb\t\tpush_back\n#define sz(v)\t\t((li)v.size())\n\n#define P pair \nvector< P > con[3];\nvector< P > sum;\nint main(){\n\trep(i,3){\n\t\tli n;\n\t\tcin>>n;\n\t\trep(j,n){\n\t\t\tli x,y;\n\t\t\tcin>>x>>y;\n\t\t\tcon[i].pb(make_pair(x,y));\n\t\t}\n\t}\n\tli pos[3]={1,1,1};\n\tli start[3]={1,1,1};\n\trep(i,3)rep(j,sz(con[i]))if(con[i][start[i]] low,high;\n\tli mini=0,maxi=0;\n\tli mini_y[2],maxi_y[2];\n\trep(i,sz(sum))if(sum[i]>n;\n\trep(i,n){\n\t\tli xx,yy;\n\t\tcin>>xx>>yy;\n\t\txx*=3; \n\t\tyy*=3;\n\t\tif(xx==sum[maxi].first){\n\t\t\tif(maxi_y[0]<=yy && yy<=maxi_y[1]) cout<<\"YES\"<::iterator lp0=upper_bound(low.begin(),low.end(),make_pair(xx,yy));\n\t\t\tvector< P >::iterator hp0=upper_bound(high.begin(),high.end(),make_pair(xx,yy));\n\t\t\tvector< P >::iterator lp1=lp0--;\n\t\t\tvector< P >::iterator hp1=hp0--;\n\t\t\tif(xx*(lp1->second-lp0->second)<=yy*(lp1->first-lp0->first)\n\t\t\t&& yy*(hp1->first-hp0->first)<=xx*(hp1->second-hp0->second)){\n\t\t\t\tcout<<\"YES\"<\n#include \nusing namespace std;\n\n#define N 100005\n#define LL long long\n\nstruct Point {\n    LL x, y;\n    Point(LL x = 0, LL y = 0):x(x), y(y) {}\n    bool operator < (const Point & b) const {\n        if (y != b.y) return y < b.y;\n        return x < b.x;\n    }\n    Point operator + (const Point & b) {\n        return Point(x + b.x, y + b.y);\n    }\n    Point operator - (const Point & b) {\n        return Point(x - b.x, y - b.y);\n    }\n};\n\nint n;\nint sz[N], st[3];\nPoint p[3][N], v[3][N], a[N*3], b[N*3], o, ta[N*3];\n\ninline int sta(const Point & a) {\n\treturn a.y > 0 || (a.y == 0 && a.x >= 0);\n}\n\nbool cmp(const Point & a, const Point & b) {\n\tint s1 = sta(a), s2 = sta(b);\n\tif (s1 != s2) return s1 > s2;\n    return a.x * b.y - a.y * b.x > 0;\n}\n\ninline LL cross(const Point & a, const Point & b) {\n    return a.x * b.y - a.y * b.x;\n}\n\ninline LL len(const Point & a) {\n    return a.x * a.x + a.y * a.y;\n}\n\nbool gao(Point v) {\n    if (v < o) return 0;\n    v = v - o;\n    int l = 0, r = n-1;\n    while (l <= r) {\n        int mid = (l + r) >> 1;\n        if (cross(a[mid], v) >= 0) l = mid + 1;\n        else r = mid - 1;\n    }\n    --l;\n    if (l == n-1)\n        return  cross(v, a[l]) == 0 && len(v) <= len(a[l]);\n    return cross(a[l+1] - a[l], v - a[l]) >= 0;\n}\n\nint main() {\n//\tfreopen(\"data.in\", \"r\", stdin);\n//\tfreopen(\"E.out\", \"w\", stdout);\n//\tfreopen(\"newdata\", \"r\", stdin);\n    n = 0;\n    o = Point(0, 0);\n    for (int i = 0; i < 3; ++i) {\n        scanf(\"%d\", &sz[i]);\n        for (int j = 0; j < sz[i]; ++j)\n            scanf(\"%I64d %I64d\", &p[i][j].x, &p[i][j].y);\n        p[i][ sz[i] ] = p[i][0];\n        for (int j = 0; j < sz[i]; ++j)\n            b[n++] = v[i][j] = p[i][j+1] - p[i][j];\n        st[i] = 0;\n        for (int j = 1; j < sz[i]; ++j)\n            if (p[i][j] < p[i][ st[i] ])\n                st[i] = j;\n        o = o + p[i][ st[i] ];\n    }\n/*\n    sort(b, b + n, cmp);\n    int k = 0;\n    for (int i = 0; i < n; ++i) {\n    \tint j;\n    \tfor (j = i + 1; j < n && cross(b[i], b[j]) == 0; ++j);\n    \tb[k] = b[i];\n    \tfor (int e = i + 1; e < j; ++e)\n    \t\tb[k] = b[k] + b[e];\n    \t++k;\n    \ti = j - 1;\n    }\n    n = k;\n    for (int i = 1; i <= n; ++i)\n    \ta[i] = a[i-1] + b[i-1];*/\n    /*\n    a[0] = Point(0, 0);\n    for (int cc = 0; cc < n; ++cc) {\n        int k = -1;\n        for (int i = 0; i < 3; ++i)\n        \tif (0 == cc) {\n        \t\tif (-1 == k || cross(v[i][ st[i] ], v[k][ st[k] ]) > 0)\n        \t\t\tk = i;\n        \t} else if (cross(a[cc] - a[cc-1], v[i][ st[i] ]) >= 0) {\n        \t\tif (-1 == k || cross(v[i][ st[i] ], v[k][ st[k] ]) > 0)\n        \t\t\tk = i;\n        \t}\n        a[cc+1] = a[cc] + v[k][ st[k] ];\n        ++st[k];\n        if (st[k] == sz[k]) st[k] = 0;\n    }*/\n    /*\n    printf(\"o %lld, %lld\\n\", o.x, o.y);\n    for (int i = 0; i <= n; ++i)\n    \tprintf(\" %lld, %lld\\n\", a[i].x, a[i].y);\n    */\n    for (int cc = 0; cc < n; ++cc) {\n        int k = 0;\n        for (int i = 1; i < 3; ++i)\n        \tif (cross(v[i][ st[i] ], v[k][ st[k] ]) > 0)\n        \t\tk = i;\n        b[cc] = v[k][ st[k] ];\n        ++st[k];\n        if (st[k] == sz[k]) st[k] = 0;\n    }\n    for (int i = 0; i < n; ++i) {\n    \tint j;\n    \tfor (j = i + 1; j < n && cross(b[i], b[j]) == 0; ++j);\n    \tb[k] = b[i];\n    \tfor (int e = i + 1; e < j; ++e)\n    \t\tb[k] = b[k] + b[e];\n    \t++k;\n    \ti = j - 1;\n    }\n    n = k;\n    for (int i = 1; i <= n; ++i)\n    \ta[i] = a[i-1] + b[i-1];\n    /*\n    for (int i = 0; i < n; ++i) printf(\" %3lld,%3lld\", a[i].x, a[i].y); puts(\"\");\n    for (int i = 0; i < n; ++i) printf(\" %3lld,%3lld\", ta[i].x, ta[i].y); puts(\"\");\n    */\n    \n    int m;\n    scanf(\"%d\", &m);\n    while (m--) {\n        Point v;\n        scanf(\"%I64d %I64d\", &v.x, &v.y);\n        v.x *= 3; v.y *= 3;\n        puts( gao(v) ? \"YES\" : \"NO\" );\n    }\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "204da106cf92ee92059efd750ee9a719", "src_uid": "a764daf8e19e48a0735811a4f67485c3", "difficulty": 2600.0}
    {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long coord;\n\nstruct vec{\n\tcoord x, y; int id;\n\tvec(coord a = 0, coord b = 0) : x(a), y(b) {}\n\tvec operator+(const vec &o) const{\n\t\treturn {x + o.x, y + o.y};\n\t}\n    vec operator-(const vec &o) const{\n        return {x - o.x, y - o.y};\n    }\n\tcoord operator^(const vec &o) const{ // sin\n\t\treturn x * o.y - y * o.x;\n\t}\n\tbool operator<(const vec &o) const{\n\t\tif(x != o.x) return x < o.x;\n\t\treturn y < o.y;\n\t}\n\tcoord cross(const vec &a, const vec &b) const{\n\t\treturn (a-(*this)) ^ (b-(*this));\n\t}\n    int ccw(const vec &a, const vec &b) const{\n        coord tmp = cross(a, b);\n        return (tmp > 0) - (tmp < 0);\n    }\n};\n\nconst int N = 1000006;\n\nvec a[N], b[N], c[N];\nint sz, szb;\n\nvoid mink(){\n    int q = 0, w = 0;\n    for(int i = 0; i < sz; i++) if(a[i] < a[q]) q = i;\n    for(int i = 0; i cross(*it, p) <= 0;\n}\n\nbool above(vec p){\n    auto it = lower_bound(lo, lo+nl, p);\n    if(it == lo) return p.x == lo[0].x && p.y >= lo[0].y;\n    return prev(it)->cross(*it, p) >= 0;\n}\n\nbool inside(vec p){\n    return below(p) && above(p);\n}\n\nint main(){\n\n    scanf(\"%d\", &sz);\n\n    for(int i = 0; i < sz; i++)\n        scanf(\"%lld %lld\", &a[i].x, &a[i].y);\n\n    /*for(int i = 0; i < sz; i++)\n        printf(\"%lld %lld\\n\", a[i].x, a[i].y);\n    printf(\"\\n\");\n    printf(\"\\n\");*/\n    scanf(\"%d\", &szb);\n    for(int i = 0; i < szb; i++)\n        scanf(\"%lld %lld\", &b[i].x, &b[i].y);\n    mink();\n\n\n    scanf(\"%d\", &szb);\n    for(int i = 0; i < szb; i++)\n        scanf(\"%lld %lld\", &b[i].x, &b[i].y);\n\n    mink();\n\n    /*for(int i = 0; i < sz; i++)\n        printf(\"%lld %lld\\n\", a[i].x, a[i].y);\n\n    printf(\"\\n\");\n    printf(\"\\n\");*/\n\n    {\n        int w = 0, e = 0;\n        for(int i = 0; i < sz; i++){\n            if(a[i] < a[w]) w = i;\n            if(a[e] < a[i]) e = i;\n        }\n\n        // printf(\"@ %d %d\\n\", w, e);\n\n        for(int i = w; ; i++){\n            if(i == sz) i = 0;\n            lo[nl++] = a[i];\n            if(i == e) break;\n        }\n        for(int i = e; ; i++){\n            if(i == sz) i = 0;\n            hi[nh++] = a[i];\n            if(i == w) break;\n        }\n        reverse(hi, hi+nh);\n    }\n\n    /*for(int i = 0; i < nl; i++)\n        printf(\"%lld %lld\\n\", lo[i].x, lo[i].y);\n\n    printf(\"\\n\");\n    printf(\"\\n\");\n\n    for(int i = 0; i < nh; i++)\n        printf(\"%lld %lld\\n\", hi[i].x, hi[i].y);\n\n    printf(\"\\n\");\n    printf(\"\\n\");*/\n\n    int m;\n\n    scanf(\"%d\", &m);\n    vec v;\n\n    while(m--){\n        scanf(\"%lld %lld\", &v.x, &v.y);\n        v.x *= 3;\n        v.y *= 3;\n        printf(\"%s\\n\", inside(v) ? \"YES\" : \"NO\");\n    }\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d71b95cd36b3dc6dc0a5f1ef62d1b190", "src_uid": "a764daf8e19e48a0735811a4f67485c3", "difficulty": 2600.0}
    {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#pragma warning(disable: 4996)\n\n#define INF 1LL<<60\n\nusing namespace std;\n\nint n, m, k;\nvector<__int64> customK;\n__int64 h;\n__int64 a[100009];\nint c[100009];\nbool aVisited[100009];\n//map<__int64, int> posToIndex;\nmap> costToPos;\n__int64 D[1009];\n\nvoid pe()\n{\n  printf(\"wtf\\n\");\n  exit(0);\n}\n\nvoid ReadData()\n{\n  //posToIndex.clear();\n  customK.clear();\n  costToPos.clear();\n  memset(aVisited, 0, sizeof(aVisited));\n  scanf(\"%I64d %d %d %d\", &h, &n, &m, &k);\n  customK.push_back(k);\n  for(int i = 0; i < n; i++)\n  {\n    scanf(\"%I64d %d\", &a[i], &c[i]);\n    //posToIndex[a[i]] = i;\n    if(((a[i] - 1) % k) == 0)\n    {\n      aVisited[i] = true;\n      costToPos[c[i]].insert(a[i]);\n    }\n  }\n  for(int i = 0; i < k; i++)\n  {\n    D[i] = INF;\n  }\n  D[1 % k] = 1LL;\n}\n\nvoid Operation_1()\n{\n  __int64 val;\n  scanf(\"%I64d\", &val);\n  customK.push_back(val);\n  set> pq;\n  pq.insert(make_pair(D[1 % k], 1 % k));\n  while(!pq.empty())\n  {\n    pair<__int64, int> current = *pq.begin();\n    pq.erase(pq.begin());\n    for(vector<__int64>::iterator it = customK.begin(); it != customK.end(); it++)\n    {\n      __int64 nxt = (current.first + *it) % k;\n      if(D[nxt] > current.first + *it)\n      {\n        pq.erase(make_pair(D[nxt], (int)nxt));\n        D[nxt] = current.first + *it;\n        pq.insert(make_pair(D[nxt], (int)nxt));\n      }\n    }\n  }\n  for(int i = 0; i < n; i++)\n  {\n    if(aVisited[i])\n    {\n      continue;\n    }\n    if(D[a[i] % k] <= a[i])\n    {\n      aVisited[i] = true;\n      costToPos[c[i]].insert(a[i]);\n    }\n  }\n}\n\nvoid Operation_2()\n{\n  int ind, cost;\n  scanf(\"%d %d\", &ind, &cost);\n  if(cost == 0)\n  {\n    return;\n  }\n  ind--;\n  if(aVisited[ind])\n  {\n    int newVal = c[ind] - cost;\n    if(costToPos[c[ind]].size() == 1)\n    {\n      costToPos.erase(c[ind]);\n    }\n    else\n    {\n      costToPos[c[ind]].erase(a[ind]);\n    }\n    c[ind] = newVal;\n    costToPos[c[ind]].insert(a[ind]);\n  }\n  else\n  {\n    c[ind] -= cost;\n  }\n}\n\nvoid Operation_3()\n{\n  if(costToPos.empty())\n  {\n    printf(\"0\\n\");\n    return;\n  }\n  map>::iterator it = costToPos.end();\n  it--;\n  printf(\"%d\\n\", it->first);\n  if(it->second.size() == 1)\n  {\n    costToPos.erase(it);\n  }\n  else\n  {\n    it->second.erase(it->second.begin());\n  }\n}\n\nvoid Solve()\n{\n  for(int i = 0; i < m; i++)\n  {\n    int operationType;\n    scanf(\"%d\", &operationType);\n    switch(operationType)\n    {\n      case 1:\n        Operation_1();\n        break;\n      case 2:\n        Operation_2();\n        break;\n      case 3:\n        Operation_3();\n        break;\n      default:\n        pe();\n    }\n  }\n}\n\nvoid WriteData()\n{\n  printf(\"\\n\");\n}\n\nint main()\n{\n  int QWE = 1;\n#ifndef ONLINE_JUDGE\n  freopen(\"input.txt\", \"r\", stdin);\n  scanf(\"%d\", &QWE);\n#endif\n  for(int T = 0; T < QWE; T++)\n  {\n    ReadData();\n    Solve();\n    WriteData();\n  }\n  return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "25bcb22e4b25885523da0330ba197516", "src_uid": "03c4df4f640633f3364ca9225588caf7", "difficulty": 2500.0}
    {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint bitct(long long r) {return r == 0 ? 0 : (bitct(r>>1) + (r&1));}\nlong long gcd(long long x, long long y) {return x ? gcd(y%x,x) : y;}\ntemplate ostream& operator << (ostream &o,vector v) {o<<\"{\";\n\tint i=0,s=v.size();for(;i+1 ostream& operator << (ostream &o,\n  unordered_map m) {o<<\"{\";for(auto i=m.begin();i!=m.end();++i)\n  o<first<<\" -> \"<< i->second << \", \"; o<<\"}\";return o;}\n  */\nlong long choose(long long n, long long q)\n{ if(n==0 || q==0) return 1;\n\tif (q==1) return n; else return ( choose(n, q-1) * (n-q+1 ) /q); }\nint dx[4] = {1,0,-1,0};\nint dy[4] = {0,1,0,-1};\n\nmain() {\n  long long h;\n  cin >> h;\n  :wq\n\n\tint N;\n\tcin >> N;\n  int ct=0;\n  for(int i=1;i<=N;i++)\n    for(int j=i;j<=N;j++)\n      {\n      int c2 = i*i+j*j;\n      double c2d = sqrt(c2);\n      int test=(int) (c2d + 0.0001);\n      if(test*test==c2 && test <= N)\n        {\n        ct++;\n        }\n      }\n\t\t\tcout << ct << endl;\n\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bbc393809f0ca86137ae6c856b418fed", "src_uid": "03c4df4f640633f3364ca9225588caf7", "difficulty": 2500.0}
    {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n\n#if __cplusplus >= 201103L\n#include \n#include \n#include \n#include \n#include \n#include \n#endif\nusing namespace std;\n\ntypedef long long int64;\nconst int inf = 2000000000;\nstatic inline int Rint()\n{\n\tstruct X{ int dig[256]; X(){\n\tfor(int i = '0'; i <= '9'; ++i) dig[i] = 1; dig['-'] = 1;\n\t}};\n\tstatic \tX fuck;int s = 1, v = 0, c;\n\tfor (;!fuck.dig[c = getchar()];);\n\tif (c == '-') s = 0; else if (fuck.dig[c]) v = c ^ 48;\n\tfor (;fuck.dig[c = getchar()]; v = v * 10 + (c ^ 48));\n\treturn s ? v : -v;\n}\ntypedef vector vi;\ntypedef map mii;\ntypedef set si;\n\n#define all(x) (x).begin(), (x).end()\n#define pb push_back\n#define mp make_pair\n#define sz(x) ((int)(x).size())\n#define rep(i, s, e) for (int i = (s); i < (e); ++i)\n\n#if __cplusplus >= 201103L\n#define foreach(iter, c) for(auto& iter : c)\n#else\n#define foreach(itr, c) for(__typeof((c).begin()) itr = (c).begin(); itr != (c).end(); ++itr)\n#endif\n\ntemplate static inline void cmax(T& a, const T& b){if(b>a)a=b;}\ntemplate static inline void cmin(T& a, const T& b){if(b o.p;\n\t\treturn id < o.id;\n\t}\n};\n\nvoid fix(priority_queue& pq)\n{\n\tset > st;\n\t\n\tfor (int i = 0; i < k; ++i)\n\tif (D[i] != -1)\n\tst.insert({D[i], i});\n\t\n\twhile (!st.empty())\n\t{\n\t\tauto where = st.begin();\n\t\tauto curr = *where;\n\t\tst.erase(where);\n\t\tif (D[curr.second] != curr.first) continue;\n\t\tfor (int i = 0; i < top; ++i)\n\t\t{\n\t\t\tint64 val = curr.first\n\t\t\tfor (int coe = 0; coe < 3; ++coe)\n\t\t\t{\n\t\t\t\tval += allk[i];\n\t\t\t\tif (val > h) continue;\n\t\t\t\t\n\t\t\t\tint next = val % k;\n\t\t\t\t\n\t\t\t\tif (next == curr.second)\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (D[next] == -1)\n\t\t\t\t{\n\t\t\t\t\tD[next] = val;\n\t\t\t\t\tst.insert({D[next], next});\n\t\t\t\t}\n\t\t\t\telse if (D[next] > val)\n\t\t\t\t{\n\t\t\t\t\tD[next] = val;\n\t\t\t\t\tst.insert({D[next], next});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t\n\tfor (int i = 1; i <= n; ++i) if (flag[i] == 0)\n\t{\n\t\tconst int bucket = pos[i] % k;\n\t\tif (D[bucket] != -1)\n\t\t{\n\t\t\tif (pos[i] >= D[bucket])\n\t\t\t{\n\t\t\t\tpq.push({treasure[i], pos[i], i});\n\t\t\t\tflag[i] = 1;\n\t\t\t}\n\t\t}\n\t}\n}\n\nint main()\n{\n\tscanf(\"%I64d\", &h);\n\tn = Rint(), m = Rint(), k = Rint();\n\t\n\tfor (int i = 1; i <= n; ++i)\n\tscanf(\"%I64d %d\", pos+i, treasure+i);\n\t\n\tmemset(D, -1, sizeof D);\n\tD[1%k] = 1;\n\t\n\tpriority_queue pq;\n\t\n\tfor (int i = 1; i <= n; ++i)\n\t{\n\t\tconst int bucket = pos[i] % k;\n\t\tif (D[bucket] != -1)\n\t\t{\n\t\t\tif (pos[i] >= D[bucket])\n\t\t\t{\n\t\t\t\tpq.push({treasure[i], pos[i], i});\n\t\t\t\tflag[i] = 1;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tfor (int id = 0; id < m; ++id)\n\t{\n\t\tconst int cmd = Rint();\n\t\tif (cmd == 3)\n\t\t{\n\t\t\twhile (!pq.empty())\n\t\t\t{\n\t\t\t\tauto curr = pq.top();\n\t\t\t\tif (treasure[curr.id] != curr.t)\n\t\t\t\t{\n\t\t\t\t\tpq.pop();\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tint64 ans = 0;\n\t\t\tif (!pq.empty())\n\t\t\t{\n\t\t\t\tans = pq.top().t;\n\t\t\t\ttreasure[pq.top().id] = -1;\n\t\t\t\tflag[pq.top().id] = 2;\n\t\t\t\t//dbg(pq.top().id);\n\t\t\t\t//dbg(pq.top().p);\n\t\t\t\tpq.pop();\n\t\t\t}\n\t\t\tprintf(\"%I64d\\n\", ans);\n\t\t}\n\t\telse if (cmd == 2)\n\t\t{\n\t\t\tconst int x = Rint();\n\t\t\tconst int c = Rint();\n\t\t\ttreasure[x] -= c;\n\t\t\tif (c != 0 && flag[x])\n\t\t\t{\n\t\t\t\t//assert(flag[x] == 1);\n\t\t\t\tif (flag[x] == 1)\n\t\t\t\t{\n\t\t\t\t\tpq.push({treasure[x], pos[x], x});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tint64 x; scanf(\"%I64d\", &x);\n\t\t\tint ok = 1;\n\t\t\t//for (int i = 0; i < top; ++i)\n\t\t\t//if (x % allk[i] == 0) ok = 0;\n\t\t\t//if (x % k == 0) ok = 0;\n\t\t\tif (ok)\n\t\t\t{\n\t\t\t\tallk[top++] = x;\n\t\t\t\tfix(pq);\n\t\t\t\t#if 0\n\t\t\t\tfor (int i = 1; i <= n; ++i)\n\t\t\t\tif (flag[i])\n\t\t\t\tcerr << pos[i] << \" \" << treasure[i] << endl;\n\t\t\t\tcerr << endl;\n\t\t\t\t\n\t\t\t\tfor (int i = 0; i < k; ++i)\n\t\t\t\tcerr << i << \" \" << D[i] << endl;\n\t\t\t\tcerr << endl;\n\t\t\t\t#endif\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cfab8938d310910e07e5d4d77721dd9e", "src_uid": "03c4df4f640633f3364ca9225588caf7", "difficulty": 2500.0}
    {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint bitct(long long r) {return r == 0 ? 0 : (bitct(r>>1) + (r&1));}\nlong long gcd(long long x, long long y) {return x ? gcd(y%x,x) : y;}\ntemplate ostream& operator << (ostream &o,vector v) {o<<\"{\";\n\tint i=0,s=v.size();for(;i+1 ostream& operator << (ostream &o,\n  unordered_map m) {o<<\"{\";for(auto i=m.begin();i!=m.end();++i)\n  o<first<<\" -> \"<< i->second << \", \"; o<<\"}\";return o;}\n  */\nlong long choose(long long n, long long q)\n{ if(n==0 || q==0) return 1;\n\tif (q==1) return n; else return ( choose(n, q-1) * (n-q+1 ) /q); }\nint dx[4] = {1,0,-1,0};\nint dy[4] = {0,1,0,-1};\n\nvector ta, tc;\n\nset > reachable;\n\nvector moves;\nint h,k;\n\nvoid make_reach()\n{\n  reachable.clear();\n  vector r(k, -1);\n  r[0]=0;\n  queue Q;\n  Q.push(0);\n  while(Q.size())\n    {\n    int me = Q.front();\n    Q.pop();\n    for(int i:moves)\n      {\n      int nm = i+me;\n      int nv = i+r[me];\n      if(nv>h)\n        continue;\n      if(-1 == r[nm%k] || nv < r[nm%k])\n        {\n        r[nm%k] = nv;\n        Q.push(nm%k);\n        }\n      }\n    }\n  for(int i=0;i> h>>n>>m>>k;\n  for(int i=0;i> a >> c;\n    ta.push_back(a-1);\n    tc.push_back(c);\n    }\n\n  make_reach();\n  for(int xx=0;xx> typ;\n    if(typ==1)\n      {\n      int x;\n      cin >> x;\n      moves.push_back(x);\n      make_reach();\n      }\n    else if (typ==2)\n      {\n      int x,y;\n      cin >> x>>y;\n      x--;\n\n      int has=(reachable.end() != reachable.find(make_pair(tc[x], x)));\n      if(has)\n        reachable.erase(make_pair(tc[x], x));\n      tc[x]-=y;\n      if(has)\n        reachable.insert(make_pair(tc[x], x));\n\n      }\n    else\n      {\n      if(reachable.size())\n        {\n        cout << reachable.rbegin()->first << endl;\n        int z=reachable.rbegin()->second;\n        tc[z]=0;\n        reachable.erase(*reachable.rbegin());\n        }\n      else\n        cout << 0 << endl;\n      }\n    }\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6e5da95700c3304f73657214cdbc0371", "src_uid": "03c4df4f640633f3364ca9225588caf7", "difficulty": 2500.0}
    {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\ntypedef long long LL;\n\nLL inf = 1e18;\n\nLL solve() {\n    LL n;\n    int m, K;\n    cin >> n;\n    cin >> m >> K;\n    vector a;\n    LL lst = 0;\n    for(int i = 0; i < m; i++) {\n        LL x;\n        cin >> x;\n        a.push_back(x - lst);\n        lst = x;\n    }\n    a.push_back(n - lst);\n    K += a.size();\n    LL lo = 1, hi = inf;\n    for(LL x : a) hi = min(hi, x);\n    while(hi > lo) {\n        LL mid = (hi+lo+1)/2;\n        LL tot = 0;\n        for(LL x : a) {\n            tot += x / mid;\n        }\n        if(tot >= K) lo = mid;\n        else hi = mid-1;\n    }\n    LL MIN = lo;\n    lo = 1, hi = inf;\n    while(hi > lo) {\n        LL mid = (hi+lo)/2;\n        LL tot = 0;\n        for(LL x : a) {\n            tot += (x+mid-1)/mid;\n        }\n        if(tot <= K) hi = mid;\n        else lo = mid+1;\n    }\n    LL MAX = lo;\n    if(all.size() > 1e3) {\n        cout << \"MIN MAX\" << endl;\n        cout << MIN << \" \" << MAX;\n        exit(0);\n    }\n    vector> bad;\n    for(LL w : a) {\n        LL x = w/MIN, y = (w+MAX-1)/MAX;\n        if(x >= y) continue;\n        bad.push_back({w/y, (w+x-1)/x});\n    }\n    if(bad.empty()) return MAX-MIN;\n    sort(bad.begin(), bad.end());\n    bad.push_back({MIN, MAX});\n    LL ans = inf;\n    for(int i = 0; i < bad.size(); i++) {\n        ans = min(ans, MAX - bad[i].first);\n        MAX = max(MAX, bad[i].second);\n    }\n    return ans;\n}\n\n\nint main() {\n    // freopen(\"in.txt\", \"r\", stdin);\n    ios::sync_with_stdio(0);\n    cin.tie(0);\n    int tc;\n    cin >> tc;\n    while(tc--) cout << solve() << \"\\n\";\n\n    return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "161144b2024040bd425b7d43d06937d3", "src_uid": "37d912c36aedea1b8f8e78a849062d90", "difficulty": 3300.0}
    {"lang": "GNU C++17", "source_code": "#ifndef LOCAL\n#define NDEBUG 1\n#endif\n#include\n\n\n#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored \"-Wall\"\n#pragma GCC diagnostic ignored \"-Wconversion\"\n#pragma GCC diagnostic ignored \"-Wsign-compare\"\n#pragma GCC diagnostic ignored \"-Wmisleading-indentation\"\nnamespace io{using namespace std;templatestruct is_iterator{template::value,int>::type=0>constexpr static auto has_indirection(int)->decltype(*declval(),bool()){return true;}templateconstexpr static bool has_indirection(long){return false;}constexpr static bool value=has_indirection(0);};using uint=unsigned int;const uint BUFFER_SIZE=1<<12;const uint MAX_LENGTH=1<<7;namespace Detail{struct Width{uint value;};struct Fill{char value;};struct Base{uint value;};struct Precision{uint value;};struct Delimiter{const char*value;};}Detail::Width setWidth(uint value=0){return{value};}Detail::Fill setFill(char value=' '){return{value};}Detail::Base setBase(uint value=10){assert(2<=value&&value<=36);return{value};}Detail::Precision setPrecision(uint value=9){assert(value=tail,false))fillInput();return*head++;}templateint readUnsignedIntGeneral(I&arg,char c){I value=0;int length=0;for(;;++length,c=nextChar()){if(isDigit(c))c-='0';else if(isUpper(c))c-='A'-10;else if(isLower(c))c-='a'-10;else c=base;if(c>=base)break;value=base*value+c;}arg=value;return--head,length;}templateinline int readUnsignedInt(I&arg,char c){if(__builtin_expect(base>10,false))return readUnsignedIntGeneral(arg,c);I value=0;int length=0;for(;static_cast(c-'0')inline bool readSignedInt(I&arg,char c){bool negative=c=='-';if(negative)c=nextChar();typename make_unsigned::type unsignedArg;if(readUnsignedInt(unsignedArg,c)==0)return false;arg=negative ? ~static_cast(unsignedArg-1): static_cast(unsignedArg);return true;}templatebool readFloatingPoint(F&arg,char c){bool negative=c=='-';if(negative)c=nextChar();unsigned long long integerPart;if(readUnsignedInt(integerPart,c)==0)return false;arg=static_cast(integerPart);if(nextChar()=='.'){unsigned long long fractionalPart=0;int fractionalLength=readUnsignedInt(fractionalPart,nextChar());if(fractionalLength>0){unsigned long long basePower=1;for(;fractionalLength;--fractionalLength)basePower*=base;arg+=static_cast(fractionalPart)/basePower;}}else --head;if(negative)arg=-arg;return true;}public:uint base;InputDevice(InputDevice const&)=delete;InputDevice&operator=(InputDevice const&)=delete;static inline bool isSpace(char c){return static_cast(c-'\\t')<5||c==' ';}static inline bool isDigit(char c){return static_cast(c-'0')<10;}static inline bool isUpper(char c){return static_cast(c-'A')<26;}static inline bool isLower(char c){return static_cast(c-'a')<26;}static inline bool isOneOf(char c,const char*str){return strchr(str,c)!=nullptr;}void putBack(){--head;}inline bool readChar(char&arg){if(__builtin_expect(head>=tail,false)){fillInput();if(__builtin_expect(head>=tail,false))return arg='\\0',false;}return arg=*head++,true;}templateinline char skipCharacters(UnaryPredicate isSkipped){char c;do{c=nextChar();}while(isSkipped(c));return c;}inline char skipCharacters(){return skipCharacters(isSpace);}templateinline int readString(char*arg,int limit,UnaryPredicate isTerminator){skipCharacters(isTerminator);int charsRead=0;for(--head,--limit;headinline typename enable_if::value&&is_unsigned::value,bool>::type read(I&arg){return readUnsignedInt(arg,skipCharacters())>0;}templateinline typename enable_if::value&&is_signed::value,bool>::type read(I&arg){return readSignedInt(arg,skipCharacters());}templateinline typename enable_if::value,bool>::type read(F&arg){return readFloatingPoint(arg,skipCharacters());}inline bool read(const char&arg){skipCharacters([arg](char c){return arg!=c;});return true;}inline bool read(const char*arg){if(*arg)skipCharacters([arg](char c){return InputDevice::isOneOf(c,arg);});else skipCharacters();return putBack(),true;}inline bool read(bool(*isSkipped)(char)){skipCharacters(isSkipped);putBack();return true;}templateinline typename enable_if::value,bool>::type read(char*arg,I limit,Terminator terminator,Ts&&... args){readString(arg,static_cast(limit),terminator);return read(forward(args)...);}templateinline typename enable_if::value,bool>::type read(char*arg,I limit){return read(arg,limit,\"\");}templateinline bool read(char*first,char*last,Ts&&... args){return read(first,static_cast(last-first),forward(args)...);}templateinline bool read(char(&arg)[N],Ts&&... args){return read(static_cast(arg),N,forward(args)...);}templateinline bool read(string&arg,Terminator terminator,Ts&&... args){for(int length=16,last=0;;last+=length,length<<=1){arg.resize(last+length);int charsRead=readString(&arg[last],length+1,terminator);if(charsRead(args)...);}}}inline bool read(string&arg){return read(arg,\"\");}templateinline bool read(pair&arg){return read(arg.first,arg.second);}templateinline bool read(complex&arg){T real,imag;if(!read(real,imag))return false;arg.real(real),arg.imag(imag);return true;}templateinline bool read(vector&arg){uint n;if(!read(n))return false;arg.resize(n);return read(arg.begin(),arg.end());}templateinline typename enable_if::value,bool>::type read(Iterator first,Iterator last,Ts&&... args){for(;first!=last;++first)if(!read(*first))return false;return read(forward(args)...);}templateinline typename enable_if::value&&is_integral::value,bool>::type read(Iterator first,I count,Ts&&... args){return read(first,first+count,forward(args)...);}templateinline auto read(T&arg)->decltype(arg.read(*this)){return arg.read(*this);}templateinline typename enable_if::value&&!is_convertible::value,bool>::type read(T0&&arg0,T1&&arg1,Ts&&... args){return read(forward(arg0))&&read(forward(arg1),forward(args)...);}};class InputFile : public InputDevice{FILE*file;bool lineBuffered;bool owner;char buffer[BUFFER_SIZE];void fillInput()override{head=buffer;*buffer='\\0';if(__builtin_expect(!lineBuffered,true)){tail=head+fread(buffer,1,BUFFER_SIZE,file);}else{tail=head;if(fgets(buffer,BUFFER_SIZE,file))while(*tail)++tail;}}public:InputFile(FILE*file=stdin,bool lineBuffered=true,bool takeOwnership=false): InputDevice(buffer,buffer),file(file),lineBuffered(lineBuffered),owner(takeOwnership){}InputFile(const char*fileName): InputFile(fopen(fileName,\"r\"),false,true){}~InputFile(){if(owner)fclose(file);}};class InputString : public InputDevice{void fillInput()override{while(*tail)++tail;}public:InputString(const string&s): InputDevice(s.data(),s.data()+s.size()){}InputString(const char*s): InputDevice(s,s+strlen(s)){}};class OutputDevice{protected:char buffer[BUFFER_SIZE+MAX_LENGTH];char*output;char*end;bool separate;OutputDevice(): output(buffer),end(buffer+BUFFER_SIZE+MAX_LENGTH),separate(false),width(setWidth().value),fill(setFill().value),base(setBase().value),precision(setPrecision().value),delimiter(setDelimiter().value){computeBasePower();}virtual void writeToDevice(uint count)=0;inline void flushMaybe(){if(__builtin_expect(output>=buffer+BUFFER_SIZE,false)){writeToDevice(BUFFER_SIZE);output=copy(buffer+BUFFER_SIZE,output,buffer);}}void computeBasePower(){basePower=1;for(uint i=0;iinline char*writeUnsignedInt(I arg,char*last){if(__builtin_expect(arg==0,false))*--last='0';if(__builtin_expect(base==10,true)){for(;arg;arg/=10)*--last='0'+arg%10;}else for(;arg;arg/=base){I digit=arg%base;*--last=digit<10 ? '0'+digit : 'A'-10+digit;}return last;}templateinline char*writeSignedInt(I arg,char*last){auto unsignedArg=static_cast::type>(arg);if(arg<0){last=writeUnsignedInt(~unsignedArg+1,last);*--last='-';return last;}return writeUnsignedInt(unsignedArg,last);}templatechar*writeFloatingPoint(F arg,char*last){bool negative=signbit(arg);if(negative)arg=-arg;if(isnan(arg))for(int i=0;i<3;++i)*--last=i[\"NaN\"];else if(isinf(arg))for(int i=0;i<3;++i)*--last=i[\"fnI\"];else{auto integerPart=static_cast(arg);auto fractionalPart=static_cast((arg-integerPart)*basePower+F(0.5));if(fractionalPart>=basePower)++integerPart,fractionalPart=0;char*point=last-precision;if(precision>0){io::fill(point,writeUnsignedInt(fractionalPart,last),'0');*--point='.';}last=writeUnsignedInt(integerPart,point);}if(negative)*--last='-';return last;}inline int writeT(char*first){int delimiterLenght=separate ? writeDelimiter(): 0;separate=true;uint charsWritten=static_cast(end-first);if(__builtin_expect(charsWritten(charsWritten);}inline int writeFill(uint count){int charsWritten=static_cast(count);if(__builtin_expect(output+count+MAX_LENGTH(buffer+BUFFER_SIZE-output);;chunkSize=BUFFER_SIZE){if(chunkSize>count)chunkSize=count;output=fill_n(output,chunkSize,fill);flushMaybe();if((count-=chunkSize)==0)break;}return charsWritten;}public:uint width;char fill;uint base;uint precision;unsigned long long basePower;string delimiter;OutputDevice(OutputDevice const&)=delete;OutputDevice&operator=(OutputDevice const&)=delete;virtual ~OutputDevice(){};inline int writeChar(char arg){separate=false;*output++=arg;flushMaybe();return 1;}inline int writeString(const char*arg,size_t length,bool checkWidth=true){separate=false;uint count=static_cast(length);int charsWritten=static_cast(count)+(checkWidth&&count(buffer+BUFFER_SIZE-output);;chunkSize=BUFFER_SIZE){if(chunkSize>count)chunkSize=count;output=copy_n(arg,chunkSize,output);flushMaybe();if((count-=chunkSize)==0)break;arg+=chunkSize;}return charsWritten;}inline int writeDelimiter(){return writeString(delimiter.c_str(),delimiter.size(),false);}inline void flush(){writeToDevice(static_cast(output-buffer));output=buffer;}inline int write(Detail::Width newWidth){width=newWidth.value;return 0;}inline int write(Detail::Fill newFill){fill=newFill.value;return 0;}inline int write(Detail::Base newBase){base=newBase.value;computeBasePower();return 0;}inline int write(Detail::Precision newPrecision){precision=newPrecision.value;computeBasePower();return 0;}inline int write(Detail::Delimiter newDelimiter){delimiter=newDelimiter.value;return 0;}inline int write(){return 0;}inline int write(char arg){return writeChar(arg);}templateinline typename enable_if::value&&is_unsigned::value,int>::type write(I arg){return writeT(writeUnsignedInt(arg,end));}templateinline typename enable_if::value&&is_signed::value,int>::type write(I arg){return writeT(writeSignedInt(arg,end));}templateinline typename enable_if::value,int>::type write(F arg){return writeT(writeFloatingPoint(arg,end));}inline int write(const char*arg){return writeString(arg,strlen(arg));}templateinline int write(char(&arg)[N]){return writeString(arg,strlen(arg));}inline int write(const string&arg){return writeString(arg.c_str(),arg.size());}templateinline int write(const pair&arg){int charsWritten=write(arg.first);charsWritten+=writeDelimiter();return charsWritten+write(arg.second);}templateinline int write(const complex&arg){return write(real(arg),imag(arg));}templateinline typename enable_if::value,int>::type write(Iterator first,Iterator last,Ts&&... args){int charsWritten=0;for(;first!=last;charsWritten+=++first==last ? 0 : writeDelimiter())charsWritten+=write(*first);return charsWritten+write(forward(args)...);}templateinline typename enable_if::value&&is_integral::value,int>::type write(Iterator first,I count,Ts&&... args){return write(first,first+count,forward(args)...);}templateinline auto write(const T&arg)->decltype(arg.write(*this)){return arg.write(*this);}templateinline typename enable_if::value,int>::type write(T0&&arg0,T1&&arg1,Ts&&... args){int charsWritten=write(forward(arg0));return charsWritten+write(forward(arg1),forward(args)...);}};class OutputFile : public OutputDevice{FILE*file;bool owner;void writeToDevice(uint count)override{fwrite(buffer,1,count,file);fflush(file);}public:OutputFile(FILE*file=stdout,bool takeOwnership=false): file(file),owner(takeOwnership){}OutputFile(const char*fileName): OutputFile(fopen(fileName,\"w\"),true){}~OutputFile()override{flush();if(owner)fclose(file);}};class OutputString : public OutputDevice{string&str;void writeToDevice(uint count)override{str.append(buffer,count);}public:OutputString(string&str): OutputDevice(),str(str){}~OutputString()override{flush();}};unique_ptrinput;unique_ptroutput;templateinline bool read(Ts&&... args){return input->read(forward(args)...);}templateinline int write(Ts&&... args){return output->write(forward(args)...);}templateinline int writeln(Ts&&... args){return write(forward(args)...,'\\n');}void flush(){output->flush();}}\n#pragma GCC diagnostic pop\n\nstruct Input{\n\tInput(){ io::input.reset(new io::InputFile(stdin, false)); }\n\ttemplate auto& operator>>(T& t){ io::read(t); return *this; }\n} cin;\nstruct Output{\n\tOutput(){ io::output.reset(new io::OutputFile()); }\n\ttemplate auto& operator<<(T const& t){ io::write(t); return *this; }\n} cout;\n\n\nvoid up();\nint main(){\n\tint numTest; cin>>numTest;\n\twhile(numTest--) up();\n}\n\nvoid up(){\n\tint64_t len, numAdd; int numBlock;\n\tcin>>len>>numBlock>>numAdd;\n\tassert(numAdd segments;\n\tsegments.reserve(numBlock+1);\n\t{\n\t\tint64_t last=0;\n\t\tfor(int _=0;_>pos;\n\t\t\tif(segments.size()>=segments.capacity()) __builtin_unreachable();\n\t\t\tsegments.push_back(pos-last);\n\t\t\tlast=pos;\n\t\t}\n\t\tif(segments.size()>=segments.capacity()) __builtin_unreachable();\n\t\tsegments.push_back(len-last);\n\t}\n\tassert((int)segments.size()==numBlock+1);\n\n\tif(numAdd==0){\n\t\tcout<<\n\t\t\t*std::max_element(begin(segments),end(segments))-*std::min_element(begin(segments),end(segments))\n\t\t\t<<'\\n';\n\t\treturn;\n\t}\n\n\tint64_t l, r;\n\tassert(std::accumulate(begin(segments),end(segments),(int64_t)0)==len);\n\tl=len/(numAdd+numBlock+1); r=l+(len%(numAdd+numBlock+1)!=0);\n\t--l; --r;\n\tauto const fr=[&](auto n, auto r) __attribute__((const)) { return (n+r)/(r+1); };\n\tauto const fl=[&](auto n, auto l) __attribute__((const)) { return n/(l+1); };\n\tauto const have_previous_fl=[&](auto n, auto l) __attribute__((const)) {\n\t\treturn l>0;\n\t};\n\tauto const previous_fl=[&](auto n, auto l) __attribute__((const)) {\n\t\tauto const l1=n/(fl(n, l)+1)-1;\n\t\tassert(l1fl(n, l));\n\t\tassert(fl(n, l1+1)==fl(n, l));\n\t\treturn l1;\n\t};\n\tauto const have_next_fr=[&](auto n, auto r) __attribute__((const)) {\n\t\treturn n-1>=r+1;\n\t};\n\tauto const next_fr=[&](auto n, auto r) __attribute__((const)) {\n\t\tassert(have_next_fr(n, r));\n\t\tauto const r1=(n-1)/(fr(n, r)-1);\n\t\tassert(r1>r);\n\t\tassert(fr(n, r1)int64_t{ return result+n/(l+1)-1; }); };\n\tauto const vr=[&](auto r){ return std::accumulate(begin(segments),end(segments), (int64_t)0,\n\t\t\t\t[&](auto result, auto n)->int64_t{ return result+(n+r)/(r+1)-1; }); };\n\n\t{\n\t\tauto result=vl(l);\n\t\tif(result queue;\n\t\t\tfor(auto n: segments)\n\t\t\t\tqueue.push_back({previous_fl(n, l), n});\n\t\t\tstd::make_heap(begin(queue),end(queue));\n\n\t\t\twhile(result=queue.capacity()) __builtin_unreachable();\n\t\t\t\t\t\tqueue.push_back({previous_fl(n, l1), n});\n\t\t\t\t\t\tstd::push_heap(begin(queue),end(queue));\n\t\t\t\t\t}\n\t\t\t\t}while(not queue.empty() and queue[0].value==l1);\n\t\t\t\tl=l1;\n\n\t\t\t\tassert(result==vl(l));\n\t\t\t}\n\n\t\t\tassert(vl(l)>=numAdd);\n\t\t\tassert(vl(l+1)numAdd){\n\t\t\tassert(result-numAdd<=(int64_t)segments.size());\n\n\t\t\tstruct T{\n\t\t\t\tint64_t value, segment;\n\t\t\t\tbool operator<(T sec) const{ return value>sec.value; }\n\t\t\t};\n\t\t\tstd::vector queue;\n\t\t\tfor(auto n: segments) if(have_next_fr(n, r))\n\t\t\t\tqueue.push_back({next_fr(n, r), n});\n\t\t\tstd::make_heap(begin(queue),end(queue));\n\n\t\t\twhile(result>numAdd){\n\t\t\t\tassert(queue[0].value>r);\n\t\t\t\tauto const r1=queue[0].value;\n\t\t\t\tdo{\n\t\t\t\t\tauto n=queue[0].segment; std::pop_heap(begin(queue),end(queue)); queue.pop_back();\n\t\t\t\t\tresult+=fr(n, r1)-fr(n, r);\n\t\t\t\t\tif(have_next_fr(n, r1)) {\n\t\t\t\t\t\tif(queue.size()>=queue.capacity()) __builtin_unreachable();\n\t\t\t\t\t\tqueue.push_back({next_fr(n, r1), n});\n\t\t\t\t\t\tstd::push_heap(begin(queue),end(queue));\n\t\t\t\t\t}\n\t\t\t\t}while(not queue.empty() and queue[0].value==r1);\n\t\t\t\tr=r1;\n\n\t\t\t\tassert(result==vr(r));\n\t\t\t}\n\t\t}\n\t}\n\tassert(vr(r)<=numAdd);\n\tassert(r==0 or vr(r-1)>numAdd);\n\tassert(l<=r); assert(l>=0);\n\tstd::vector> pairs; pairs.reserve(segments.size()+2);\n\tfor(auto n: segments){\n\t\tauto q=fr(n, r);\n\t\tif(q>fl(n, l)){\n\t\t\tassert(q-1==fl(n, l));\n\t\t\tif(pairs.size()>=pairs.capacity()) __builtin_unreachable();\n\t\t\tpairs.push_back({previous_fl(n, l), next_fr(n, r)});\n\t\t}\n\t}\n\tif(pairs.size()>=pairs.capacity()) __builtin_unreachable();\n\tpairs.push_back({-1, r});\n\tif(pairs.size()>=pairs.capacity()) __builtin_unreachable();\n\tpairs.push_back({l, INT64_MAX});\n\tassert(pairs.size()<=segments.size()+2);\n\tstd::sort(begin(pairs),end(pairs),[&](auto x, auto y){\n\t\treturn x.firstout[-1].second){\n\t\t\tif(out[-1].first==it.first) --out;\n\t\t\t*out++=it;\n\t\t}\n\t});\n\tpairs.erase(out, end(pairs));\n\n\tint64_t result=INT64_MAX;\n\tfor(int index=1;index<(int)pairs.size();++index)\n\t\tresult=std::min(result, pairs[index-1].second-pairs[index].first);\n\tcout<\n#include\n#include\n#include\nusing namespace std;\nint T;\nlong long n,m,k,dis[400040],cnt[400040],l[400040],r[400040];\nstruct data\n{\n\tint id;\n\tfriend bool operator < (data a,data b)\n\t{\n\t\tif(r[a.id]!=r[b.id])return r[a.id]q;\nint main()\n{\n\tscanf(\"%d\",&T);\n\twhile(T--)\n\t{\n\t\tscanf(\"%lld %lld %lld\",&n,&m,&k);\n\t\tlong long last=0,cur;\n\t\tfor(int i=1;i<=m;++i)\n\t\t{\n\t\t\tscanf(\"%lld\",&cur);\n\t\t\tdis[i]=cur-last;last=cur;\n\t\t}\n\t\tdis[m+1]=n-last;\n\t\tfor(int i=1;i<=m+1;++i)\n\t\t{\n\t\t\tcnt[i]=((__int128)dis[i])*(k+m+1)/n-1;if(cnt[i]<0)++cnt[i];\n\t\t\tl[i]=dis[i]/(cnt[i]+1);\n\t\t\tr[i]=(dis[i]-1)/(cnt[i]+1)+1;\t\t\t\n\t\t//\tprintf(\"%lld %lld %lld\\n\",cnt[i],l[i],r[i]);\n\t\t\tq.push(data{i});\n\t\t}//printf(\"\\n\");\n\t\tfor(int i=1;i<=m+1;++i)k-=cnt[i];\n\t\twhile(k--)\n\t\t{\n\t\t\tint x=q.top().id;q.pop();//printf(\"ins%d\\n\",x);\n\t\t\t++cnt[x];l[x]=dis[x]/(cnt[x]+1),r[x]=(dis[x]-1)/(cnt[x]+1)+1;\n\t\t\tq.push(data{x});\n\t\t}\n\t\tlong long mi=0x3f3f3f3f3f3f3f3f,mx=0;\n\t\tfor(int i=1;i<=m+1;++i)mx=max(mx,r[i]),mi=min(mi,l[i]);\n\t\tprintf(\"%lld\\n\",mx-mi);\n\t\twhile(!q.empty())q.pop();\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "36afe3c86b8e4c772bc986f1046a82e2", "src_uid": "37d912c36aedea1b8f8e78a849062d90", "difficulty": 3300.0}
    {"lang": "GNU C++17", "source_code": "#include\n#define rep(i,a,b) for(int i=(a);i<(b);++i)\n#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)\n#define ll long long\n#define lb(x) ((x)&(-x))\n#define pii pair\n#define vi vector\n#define pb push_back\n#define fi first\n#define se second\n#define de(x) cout<<#x<<\" x\"< g;\npii stk[N];\nll down(ll a,ll b){\n\treturn a/b;\n}\nll up(ll a,ll b){\n\treturn (a+b-1)/b;\n}\nvoid solve(){\n\tint n,m,k;\n\tscanf(\"%d%d%d\",&n,&m,&k);\n\trep(i,1,m+1)scanf(\"%lld\",&p[i]);\n\tp[++m]=n;\n\trep(i,1,m+1)s[i]=p[i]-p[i-1];\n\tll MIN=Inf,MAX=0,l=1,r=Inf,K=k+m;\n\twhile(l>1;\n\t\trep(i,1,m+1)sum+=down(s[i],mid);\n\t\tif(sum>=K)l=mid+1;\n\t\telse r=mid;\n\t}\n\tMIN=l-1;\n\tl=1,r=Inf;\n\twhile(l>1;\n\t\trep(i,1,m+1)sum+=up(s[i],mid);\n\t\tif(sum<=K)r=mid;\n\t\telse l=mid+1;\n\t}\n\tMAX=l;\n\tll ans=MAX-MIN;\n\t//cout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\n#define i_n(a) scanf(\"%d\",&a)\n#define l_n(a) scanf(\"%lld\",&a)\n#define LL long long int\n#define pb(a) push_back(a)\n#define pp pair\n#define vv vector\n#define vvp vector\n#define i_p(a) printf(\"%d\\n\",a)\n#define l_p(a) printf(\"%lld\\n\",a)\n#define pnt(expr) printf(#expr\"\\n\")\n#define reset(a,val) memset(a,val,sizeof(a))\n#define m1 1000000000\n#define mod 1000000007\n#define pr(cn,x) ((cn).find(x)!=(cn).end())\n#define tr(cn,it) for(typeof((cn).begin()) it=(cn).begin();it!=(cn).end();it++)\n#define read() freopen(\"fraud.in\",\"r\",stdin)\n#define write() freopen(\"fraud.out\",\"w\",stdout)\nbool cmp(const pair& p1, const pair& p2)\n{\n    return p1.first < p2.first;\n}\nint k,m;\nint curr;\nint flag=0;\nsetout;\nvoid sol(int a,int b)\n{\n  //  cout<=10000)\n            return ;\n        if(out.size()\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define uint unsigned int\n#define int64 long long\n#define P pair\n#define Pss pair\n#define PLL pair\n#define Inf 1000000\n#define Mod 1000000007LL\n\nint n, k;\nset  st;\nchar str[9];\n\nvoid solve(int idx, int val, int rem){\n\tif(idx == 8){\n\t\tif(val == rem && st.size() < k)\n\t\t\tst.insert(atoi(str));\n\t\treturn;\n\t}\n\tstr[idx] = '0';\n\tsolve(idx + 1, val, rem);\n\tif(val != 0 && rem % val == 0)\n\t\tsolve(idx + 1, 0, rem / val);\n\tfor(int i = 1; i < 10 && st.size() < k; i++){\n\t\tstr[idx] = (char)('0' + i);\n\t\tif(val != 0 && rem % val == 0)\n\t\t\tsolve(idx + 1, i, rem / val);\n\t\tsolve(idx + 1, val + i, rem);\n\t\tif(val != 0 && rem % val == 0)\n\t\t\tsolve(idx + 1, -i, rem / val);\n\t\tsolve(idx + 1, val - i, rem);\n\t}\n}\n\nint main(){\n\tcin >> n >> k;\n\tif(n == 0){\n\t\tfor(int i = 0; i < k; i++)\n\t\t\tprintf(\"%08d\\n\", i);\n\t}\n\telse{\n\t\tsolve(0, 0, n);\n\t\tfor(set ::iterator it = st.begin(); it != st.end(); it++)\n\t\t\tprintf(\"%08d\\n\", *it);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a8a97d98039d4746129090569d8f4130", "src_uid": "4720ca1d2f4b7a0e553a3ea07a76943c", "difficulty": 2700.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include    \n#include \n#include   \n#include  \n#include \n#include     \n#include \n#include    \n#include \n\nusing std::priority_queue;\nusing std::vector;\nusing std::swap;\nusing std::stack;\nusing std::sort;\nusing std::max;\nusing std::min;\nusing std::pair;\nusing std::map;\nusing std::string;\nusing std::cin;\nusing std::cout;\nusing std::set;\nusing std::queue;\nusing std::string;\nusing std::stringstream;\nusing std::make_pair;\nusing std::getline;\nusing std::greater;\nusing std::endl;\nusing std::multimap;\nusing std::deque;\nusing std::unique;\nusing std::lower_bound;\nusing std::random_shuffle;\n\ntypedef long long LL;\ntypedef unsigned long long ULL;\ntypedef pair PAIR;\ntypedef multimap MMAP;\ntypedef LL TY;\n\nconst int MAXN(50010);\nconst int MAXM(50010);\nconst int MAXE(100010);\nconst int MAXK(6);\nconst int HSIZE(131313);\nconst int SIGMA_SIZE(26);\nconst int MAXH(19);\nconst int INFI((INT_MAX-1) >> 1);\nconst ULL BASE(31);\nconst LL LIM(10000000);\nconst int INV(-10000);\nconst int MOD(1000000007);\nconst double EPS(1e-8);\n\ntemplate void checkmax(T &a, T b){if(b > a) a = b;}\ntemplate void checkmin(T &a, T b){if(b < a) a = b;}\ntemplate T ABS(const T &a){return a < 0? -a: a;}\n\n\nint str[4];\nint rec[4];\nset table[10010], ans;\nset st[4][4];\nint cur;\nint K;\nbool vis[10010];\n\nvoid dfs(int len, int cnt)\n{\n    if(len == 0)\n    {\n        for(int i = 0; i < cnt; ++i)\n            for(int j = i; j < cnt; ++j)\n                st[i][j].clear();\n        for(int i = 0; i < cnt; ++i)\n            st[i][i].insert(rec[i]);\n        st[0][0].insert(-rec[0]);\n        for(int i = 2; i <= cnt; ++i)\n        {\n            for(int j = 0; j+i-1 < cnt; ++j)\n            {\n                int l = j, r = j+i-1;\n                for(int k = l; k < r; ++k)\n                {\n                    set::iterator it1 = st[l][k].begin(), it2 = st[l][k].end();\n                    set::iterator it3 = st[k+1][r].begin(), it4 = st[k+1][r].end();\n                    for(; it1 != it2; ++it1)\n                        for(; it3 != it4; ++it3)\n                        {\n                            int temp = *it1+*it3;\n                            st[l][r].insert(temp);\n                            temp = *it1-*it3;\n                            st[l][r].insert(temp);\n                            temp = *it1**it3;\n                            st[l][r].insert(temp);\n                        }\n                }\n            }\n        }\n        set::iterator it1 = st[0][cnt-1].begin(), it2 = st[0][cnt-1].end();\n        for(; it1 != it2; ++it1)\n            table[cur].insert(*it1);\n        return;\n    }\n    for(int i = 1; i <= len; ++i)\n    {\n        int temp = 0;\n        for(int j = 0, k = 4-len; j < i; ++j, ++k)\n        {\n            temp *= 10;\n            temp += str[k];\n        }\n        rec[cnt] = temp;\n        dfs(len-i, cnt+1);\n    }\n}\n\nvoid debug(int i)\n{\n    printf(\"debug: %d\\n\\n\", i);\n    for(set::iterator it = table[i].begin(); it != table[i].end(); ++it)\n        printf(\"%04d\\n\", *it);\n    printf(\"\\ndebug end\\n\\n\");\n}\n\nint main()\n{\n    for(cur = 0; cur < 10000; ++cur)\n    {\n        int ti = cur;\n        for(int j = 0; j < 4; ++j)\n        {\n            str[3-j] = ti%10;\n            ti /= 10;\n        }\n        dfs(4, 0);\n//      if(cur == 374)\n//          debug(cur);\n    }\n    int m;\n    while(~scanf(\"%d%d\", &K, &m))\n    {\n        set::iterator it1, it2;\n        int cnt = 0;\n        for(int i = 0; cnt < m && i < 10000; ++i)\n        {\n            it1 = table[i].begin();\n            it2 = table[i].end();\n            memset(vis, 0, sizeof(vis));\n            for(; it1 != it2; ++it1)\n            {\n                int temp = abs(K-*it1);\n                if(temp < 10000)\n                    for(int j = 0; cnt < m && j < 10000; ++j)\n                        if(!vis[j] && table[j].find(temp) != table[j].end())\n                        {\n                            printf(\"%04d%04d\\n\", i, j);\n                            vis[j] = true;\n                            ++cnt;\n                        }\n            }\n        }\n    }\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e10e2ef231a3aed6173cde5b78d21ed7", "src_uid": "4720ca1d2f4b7a0e553a3ea07a76943c", "difficulty": 2700.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nbool tick[100000000];\nvector res;\n\nchar s[20];\n\n\nbool v(int k1, int k2, int k3, int k4, int x){\n  \n  return k1 + k2 + k3 + k4 == x || k1 * k2 * k3 * k4 == x ||\n         k1 * k2 + k3 * k4 == x || k1 + k2 * k3 * k4 == x ||\n         k1 * k2 * k3 + k4 == x || (k1 + k2) * k3 * k4 == x ||\n         (k1 + k2) * (k3 * k4) == x || k1 - k2 + k3 * k4 == x ||\n         k1 * k2 + (k3*10 + k4) == x || k1 *1000 + k2 * 100 + k3 * 10 + k4 == x\n         ;\n         \n}\n\n\nint main(){\n  int x, k, m;\n  int n;\n  int k1 , k2, k3, k4;\n  scanf(\"%d %d\", &k, &m);\n  \n  for(int i = 0; i < 10000; i++){\n    x = abs(k - i);\n    for(int w = 0; w < 10000; w++){\n      k1 = (w % 10)/1;\n      k2 = (w % 100)/10;\n      k3 = (w % 1000)/100;\n      k4 = (w % 10000)/1000;\n      if(v(k1,k2,k3,k4,x)){\n        sprintf(s,\"%d%d%d%d%04d\", k1,k2,k3,k4, i);\n        sscanf(s, \"%d\", &n);\n        \n        if(n < 100000000 && !tick[n]){\n          tick[n] = true;\n          res.push_back(n);\n        }\n      }\n      \n      \n    }\n    \n    \n  }\n  cout << res.size() << endl;\n  \n  //printf(\"%04d%04d\\n\", x, i);\n  \n  \n}\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "00d89f86bf2378f89e2c2ab202d47541", "src_uid": "4720ca1d2f4b7a0e553a3ea07a76943c", "difficulty": 2700.0}
    {"lang": "GNU C++", "source_code": "#include\nint B,D,T,i;\nint Gcd(int a,int b)\n{\n\tif(!b) return a;\n\treturn Gcd(b,a%b);\n}\nint main()\n{\n\tscanf(\"%d%d\",&B,&D);\n\tT=D;\n\tfor(i=2;i<=B;++i)\n\t\tif(B%i==0)\n\t\t\tfor(;T%i==0;T/=i);\n\tif(T==1)\n\t{\n\t\tprintf(\"2-type\\n\");\n\t\tfor(;;);\n\t\treturn 0;\n\t}\n\tif((B-1)%D==0)\n\t{\n\t\tprintf(\"3-type\\n\");\n\t\tfor(;;);\n\t\treturn 0;\n\t}\n\tif(D==B+1)\n\t{\n\t\tprintf(\"11-type\\n\");\n\t\tfor(;;);\n\t\treturn 0;\n\t}\n\tT=D;\n\tfor(;T%(B+1)==1;T/=(B+1));\n\tfor(i=2;i<=B;++i)\n\t\tif((B-1)%i==0&&T%i==0)\n\t\t\tif(Gcd(i,D/T)==1)\n\t\t\t\tT/=i;\n\tfor(i=2;i<=B;++i)\n\t\tif(B%i==0)\n\t\t\tfor(;T%i==0;T/=i);\n\tif(T==1)\n\t{\n\t\tprintf(\"6-type\\n\");\n\t\tfor(;;);\n\t\treturn 0;\n\t}\n\tprintf(\"7-type\\n\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "62c3eb1080649b937f41bc73e1a4a90d", "src_uid": "809e1c78b0a5a16f7f2115b046a20bde", "difficulty": 2300.0}
    {"lang": "MS C++", "source_code": "#include  \n#include  \n#include \n#include  \n#include  \n#include  \n#include  \n#include  \n#include  \n#include  \n#include  \n#include  \n#include  \n\nusing namespace std; \n\nconst int INF = 1e9;\nconst double EPS = 1e-9;\n\n#define mp make_pair \n#define pb push_back \n#define all(a) a.begin(), a.end() \n#define sz(a) int(a.size()) \n#define forn(i,n) for (int i = 0; i < n; i++) \n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld; \ntypedef pair pii;\n\nint n, ans = -1;\n\nint calc(int b, int p = -1) {\n\tint d = 1;\n\t\n\tbool f = false;\n\tfor (int i = 0; i < 100; i++, d = (d * n) % b)\n\t\tif (d == 0) {\n\t\t\tf = 1;\n\t\t\tif (p == -1)\n\t\t\t\tans = i;\n\t\t\tbreak;\n\t\t}\n\n\tif (f)\n\t\treturn 2;\n\n\tf = true;\n\td = 1;\n\tfor (int i = 0; i < 100; i++, d = (d * n) % b)\n\t\tif (d != 1) {\n\t\t\tf = 0;\n\t\t\tbreak;\n\t\t}\n\n\tif (f)\n\t\treturn 3;\n\n\tf = true;\n\td = 1;\n\tfor (int i = 0; i < 100; i++, d = (d * n) % b)\n\t\tif (i&1) {\n\t\t\tif (d != b - 1) {\n\t\t\t\tf = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else {\n\t\t\tif (d != 1) {\n\t\t\t\tf = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\tif (f)\n\t\treturn 11;\n\n\tf = false;\n\tfor (int i = 2; i < b; i++) {\n\t\tint x = 1;\n\t\twhile (b % i == 0) {\n\t\t\tx *= i;\n\t\t\tb /= i;\n\t\t}\t\n\t\tif (x > 1 && x != b) {\n\t\t\tif (calc(x, 0) != 7)\n\t\t\t\tf = true;\n\t\t\telse\n\t\t\t\tf = false;\n\t\t}\t\t\t\n\t}\n\n\tif (f)\n\t\treturn 6;\n\n\treturn 7;\n}\n\nvoid solve() { \n\tint b;\n\tcin >> n >> b;\n\n\tcout << calc(b) << \"-type\" << endl;\n\tif (ans != -1)\n\t\tcout << ans << endl;\n} \n\nint main() { \n#ifndef ONLINE_JUDGE \n        //freopen(\"input.txt\", \"r\", stdin); \n        //freopen(\"output.txt\", \"w\", stdout); \n#endif \n\t\tsolve();\n        return 0; \n} ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6b06c9ef1a35ba99d2a5c5a90b860a55", "src_uid": "809e1c78b0a5a16f7f2115b046a20bde", "difficulty": 2300.0}
    {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\ntemplate \nusing lim = numeric_limits;\n\ntypedef long long ll;\n\nvoid factorize(int x, unordered_map &fact){\n\tfor (int i = 2; i*i <= x; i++){\n\t\twhile(x % i == 0){\n\t\t\tfact[i]++;\n\t\t\tx /= i;\n\t\t}\n\t}\n\tif (x > 1) fact[x]++;\n}\n\nint fastpow(int b, int e){\n\tint ans = 1;\n\twhile(e){\n\t\tif (e&1) ans *= b;\n\t\te >>= 1;\n\t\tb *= b;\n\t}\n\treturn ans;\n}\n\nint main(){\n\tios_base::sync_with_stdio(false);\n\tcin.tie(0);\n\n\tint b, d;\n\tcin >> b >> d;\n\n\tif((b-1)%d == 0) cout << \"3-type\\n\";\n\telse if ((b+1)%d == 0) cout << \"11-type\\n\";\n\telse if (b%d == 0) cout << \"2-type\\n1\\n\";\n\telse{\n\t\tunordered_map bfact;\n\t\tunordered_map dfact;\n\n\t\tfactorize(b, bfact);\n\t\tfactorize(d, dfact);\n\n\t\t// it is 2-type iff all primes factors of d are in b\n\t\tbool twotype = true;\n\t\tfor (auto it : dfact) {\n\t\t\tif (bfact.find(it.first) == bfact.end()) {\n\t\t\t\t// it is 6-type iff the primes that are not in b are 3-type or 11-type\n\t\t\t\tint num = fastpow(it.first, it.second);\n\t\t\t\tsixtype &= ((b-1)%num == 0 or (b+1)%num == 0);\n\t\t\t\ttwotype = false;\n\t\t\t}\n\t\t}\n\n\t\t// to compute for the number of digits you have to look at for 2-type,\n\t\t// maximum of the differences in prime multiplicities +1\n\t\tif (twotype){\n\t\t\tint ans = 0;\n\t\t\tfor (auto it : bfact) ans = max(ans, abs(it.second-dfact[it.first]));\n\t\t\tans++;\n\t\t\tcout << \"2-type\\n\" << ans << \"\\n\";\n\t\t}\n\t\telse if (sixtype) cout << \"6-type\\n\";\n\t\telse cout << \"7-type\\n\";\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "88954433c25017b98b741b55c7c3215d", "src_uid": "809e1c78b0a5a16f7f2115b046a20bde", "difficulty": 2300.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n//#include \n#include \n#include \nusing namespace std;\ntypedef long long LL;\ntypedef pair pint;\ntypedef pair pll;\n#define fi first\n#define se second\ntypedef map mapint;\ntypedef vector vint;\ntypedef vector vintp;\n#define rep(i,j,k) for (int i = (j);i <= (k);i ++)\n#define ran2 (rand() % 32000 * 32000 + rand() % 32000)\n#define pb push_back\n#define mp make_pair\n\n\nint m,n,j,k,l,i,o,p,__t;\n\nchar ch;\nvoid read(int &a){\n\tfor (ch = getchar();(ch < '0' || ch > '9') && (ch != '-');ch = getchar());\n\tif (ch == '-') a = 0,__t = -1; else a = ch - '0',__t = 1;\n\tfor (ch = getchar();ch >= '0' && ch <= '9';ch = getchar()) a = a * 10 + ch - '0';\n\ta *= __t;\n}\nint main(){\n\tscanf(\"%d%d\", &n, &m);\n\twhile ((g = __gcd(n, m)) > 1)\n\t\tm /= g, c ++;\n\tif(m == 1)\n\t\tprintf(\"2-type\\n%d\", c);\n\telse if (!c && n % m == 1)\n\t\tputs(\"3-type\");\n\telse if (!c && n % m == m - 1)\n\t\tputs(\"11-type\");\n\telse if ((n - 1) * (n + 1) / (n % 2 + 1 ) % m == 0)\n\t\tputs(\"6-type\");\n\telse\n\t\tputs(\"7-type\");\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9522bbe88dde239d88fc98d39d20c64e", "src_uid": "809e1c78b0a5a16f7f2115b046a20bde", "difficulty": 2300.0}
    {"lang": "GNU C++17", "source_code": "#include \n#include \n\nconst int MOD = 1000000007;\nconst int MAX_N = 100000;\n\nvoid selfMult(int &a, int b) {\n  a = (long long)a * b % MOD;\n}\n\nvoid selfAdd(int &a, int b) {\n  a += b;\n  if (a >= MOD) {\n    a -= MOD;\n  }\n}\n\nint power(int base, int exp) {\n  int answer = 1;\n  while (exp > 0) {\n    if (exp % 2 == 1) {\n      selfMult(answer, base);\n    }\n    selfMult(base, base);\n    exp /= 2;\n  }\n  return answer;\n}\n\nint inv(int value) {\n  return power(value, MOD - 2);\n}\n\nint gcd(int a, int b) {\n  int r = a % b;\n  while (r > 0) {\n    a = b;\n    b = r;\n    r = a % b;\n  }\n  return b;\n}\n\nint main() {\n  int n, k;\n  scanf(\"%d%d\", &n, &k);\n  int freedoms[1 + MAX_N];\n  freedoms[0] = 1;\n  freedoms[1] = k;\n  for (int i = 2; i <= n; i++) {\n    freedoms[i] = freedoms[i - 1];\n    selfMult(freedoms[i], k);\n  }\n  /*\n  for (int i = 0; i <= 10; i++) {\n    printf(\"%d \", invK[i]);\n  }\n  printf(\"\\n\");//*/\n  int answer = 0;\n  for (int i = 1; i < n; i++) {\n    for (int j = 1; j < i; j++) {\n      selfAdd(answer, freedoms[std::max(gcd(n - i, n - j), n - i - j)]);\n      /*\n      printf(\"%d,%d => %d\\n\", i, j, freedoms[n - i - j]);\n      if (i <= n - i) {\n        selfAdd(answer, freedoms[n - i - j]);\n        printf(\"%d,%d => %d\\n\", i, j, freedoms[n - i - j]);\n      } else if (n - i <= i - j) {\n        selfAdd(answer, freedoms[n - i]);\n        printf(\"%d,%d => %d\\n\", i, j, freedoms[n - i]);\n      } else {\n        selfAdd(answer, freedoms[i - j]);\n        printf(\"%d,%d => %d\\n\", i, j, freedoms[i - j]);\n      }//*/\n    }\n  }\n  selfMult(answer, 2);\n  //printf(\"%d\\n\", answer);\n  for (int i = 1; i < n; i++) {\n    selfAdd(answer, freedoms[n - i]);\n    //printf(\"%d,%d => %d\\n\", i, i, freedoms[n - i]);\n  }\n  //printf(\"%d\\n\", answer);\n  selfMult(answer, power(inv(k), n));\n  printf(\"%d\\n\", answer);\n  return 0;\n}\n\n/*\n00000 - 4 16\n00001 - 0\n00010 - 1  1\n00011 - 0\n00100 - 2  4\n00101 - 0\n00110 - 1  1\n00111 - 0\n01000 - 1  1\n01001 - 1  1\n01010 - 2  4\n01011 - 0\n01100 - 1  1\n01101 - 1  1\n01110 - 1  1\n01111 - 0\n------------(+)\n      -   62/32 = 2\n\n00000 1,1\n00000 2,2\n00000 3,3\n00000 4,4\n00000 2,1\n00000 1,2\n00000 3,1\n00000 1,3\n00000 3,2\n00000 2,3\n00000 4,1\n00000 1,4\n00000 4,2\n00000 2,4\n00000 4,3\n00000 3,4\n00010 1,1\n00100 1,1\n00100 2,2\n00100 2,1\n00100 1,2\n00110 1,1\n01000 1,1\n01001 2,2\n01010 1,1\n01010 3,3\n01010 3,1\n01010 1,3\n01100 1,1\n01101 2,2\n01110 1,1\n\n \n\n\n\n\n\n2 1\nxxyxx\n\n3 1\nxyxyx\n\n3 2\nxxxxx\n\n4 1\nxxxxx\n\n1/8 + 1/8 + 1/16 + 1/16 + 1/16 + 1/16\n= 1/4 + 1/4\n= 1/2\n= 1\n\n1\nxyztx\n\n2\nxyzxy\n\n3\nxyxyx\n\n4\nxxxxx\n\n1/16 + 1/8 + 1/4 + 1/2\n\n6,1,10\nxxztxxztxx\ngcd(4, 9) = 1\n\nmax(10-6-1, gcd(10-6, 10-1))\n\n6,2,10\nxyztxyztxy\ngcd(4, 8) = 4\n\n6,3\nxxxxxxxxxx\ngcd(4, 7) = 1\n\n6,4\nxyxyxyxyxy\ngcd(4,6)=2\n\n6,5\n\n\n3,1,5\nxyxyx\n\nababababab\n       ab\n\n*/\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c5dbcdff59986d252f14b16a01ad6e09", "src_uid": "be32c7b2fd197c3247d11aed25c3cc0d", "difficulty": 3100.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#define meow(args...) fprintf(stderr, args)\nconst int N=1e5;\nuint32_t P=1e9+7;\n\nint phi[N*2+1], minp[N*2+1], rad[N*2+1];\nbool vis[N*2+1];\nuint32_t pw[N+1];\nstd::vector pr;\nauto cmin=[](auto &a, const auto &b) {return b>=1) if(b&1) ans=ans*a%P;\n\treturn ans;\n}\nint partial_phi(int n, int s) {\n\tif(n==0) return 0;\n\tif(s==1) return n;\n\tint p=minp[s];\n\treturn partial_phi(n, s/p)-partial_phi(n/p, s/p);\n}\nint main() {\n\tint n, k;\n\tassert(scanf(\"%d%d\", &n, &k)==2);\n\tuint64_t invk=power(k, P-2);\n\tpw[0]=1;\n\tfor(int i=1; i<=n; ++i) pw[i]=pw[i-1]*invk%P;\n\tphi[1]=1;\n\trad[1]=1;\n\tfor(int i=2; i<=2*n; ++i) {\n\t\tif(!vis[i]) {\n\t\t\tpr.push_back(i);\n\t\t\tminp[i]=i;\n\t\t\tphi[i]=i-1;\n\t\t\trad[i]=i;\n\t\t}\n\t\tfor(int j=0; j\nusing namespace std;\nconst int mod=1e9+7;\nconst int N=1e5+2;\nvoid add(int &x,int y){\n\tx+=y;\n\tif(x>=mod){\n\t\tx-=mod;\n\t}\n}\nvoid sub(int &x,int y){\n\tx-=y;\n\tif(x<0){\n\t\tx+=mod;\n\t}\n}\nint mul(int x,int y){\n\treturn (1ll*x*y)%mod;\n}\nint binpow(int x,int y){\n\tint tich=1;\n\twhile(y){\n\t\tif(y&1){\n\t\t\ttich=mul(tich,x);\n\t\t}\n\t\tx=mul(x,x);\n\t\ty>>=1;\n\t}\n\treturn tich;\n}\nint backtrack(vector &lis,int lef,int rig,int ptr,int cnt,int val,int s){\n\tif(ptr==lis.size()){\n\t\treturn cnt*(rig/val-(lef-1)/val);\n\t}\n\treturn backtrack(lis,lef,rig,ptr+1,cnt,val,s)+backtrack(lis,lef,rig,ptr+1,-cnt,val*lis[ptr],s);\n}\nint pw[N];\nvector uoc[N],uocnt[N];\nsigned main(){\n\tios::sync_with_stdio(0);\n\tcin.tie(0);\n\tint n,i,j,k,l,num,ans=0,r;\n\tcin>>n>>num;\n\tpw[0]=1;\n\tfor(i=1;i<=n;i++){\n\t\tpw[i]=mul(pw[i-1],num);\n\t}\n\tfor(i=1;i<=2*n;i++){\n\t\tfor(j=i;j<=2*n;j+=i){\n\t\t\tuoc[j].push_back(i);\n\t\t}\n\t\tif(i==1){\n\t\t\tcontinue;\n\t\t}\n\t\tif(uoc[i].size()==2){\n\t\t\tfor(j=i;j<=2*n;j+=i){\n\t\t\t\tuocnt[j].push_back(i);\n\t\t\t}\n\t\t}\n\t}\n\tfor(int s=3;s<2*n-2;s++){\n\t\tfor(int gcd:uoc[s]){\n\t\t\tint news=s/gcd,l=max(1,news-(n-1)/gcd),r=min((n-1)/gcd,news-1);\n\t\t\tif(l>r){\n\t\t\t\tcontinue;\n\t\t\t}\n2 3\n\t\t\tj=backtrack(uocnt[news],l,r,0,1,1,news);\n\t\t\tif(news==2){\n\t\t\t\tj--;\n\t\t\t}\n\t\t\tadd(ans,mul(j,pw[max(s-n,gcd)]));\n\t\t}\n\t}\n\tfor(i=1;i\nusing namespace std;\ntypedef long long ll;\nconst int mod=1e9+7;\ninline int add(int a,int b){a+=b;return a>mod?a-mod:a;}\ninline int sub(int a,int b){a-=b;return a<0?a+mod:a;}\ninline int mul(int a,int b){return (ll)a*b%mod;}\ninline int qpow(int a,int b){int ret=1;for(;b;b>>=1,a=mul(a,a))if(b&1)ret=mul(ret,a);return ret;}\n/* math */\nint n,k;\n \nconst int N = 2e5+5;\n \nvector d[N];\nll c[N];\nll dp[N],ans[N];\n \nint main()\n{\n\tfor(int i=1;i> n >> k;\n\tfor(int s=n+1;s=n) ans[s-n]+=c[g];\n\t\t}\n\t}\n\tfor(int m=2;m<=n;m++){\n\t\tdp[m] = (ll)m*(m-1)/2;\n\t\tll b= (ll)sqrt(m);\n\t\twhile(b*bb){\n\t\t\t\tdp[m]-=(z-b)*dp[i];\n\t\t\t\tb=z;\n\t\t\t}\n\t\t}\n\t}\n\tfor(int g=1;g\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int MAXN = 32768 - 1;\nint ans[100500];\nbool use[100500];\nbool otl[100500];\n\nint res;\nstring s=\"\";\n\nint eval_num(int n, int &i);\nint eval_product(int n, int &i);\nint eval_sum(int n, int &i);\nbool eval_logick(int n, int & i);\nint eval_op(int n, int &i);\nint eval_opseq(int n, int &i);\nint eval_func(int n, int & i);\nint run(int n);\n\nstring getlex(int & i) {\n    try {\n\n    while (s[i]==' ' || s[i]==' ' || s[i]=='\\n')\n        ++i;\n\n    string t = \"\";\n\n    if (\n        s[i]=='(' || s[i]==')' || s[i]=='{' || s[i]=='}'\n        || s[i]=='+' || s[i]=='-' || s[i]=='*' || s[i]=='/' || s[i]==';'\n       )\n    {\n        t += s[i]; ++i; return t;\n    }\n\n\n    while (!(s[i]==' ' || s[i]==' ' || s[i]=='\\n'\n            || s[i]=='(' || s[i]==')' || s[i]=='{' || s[i]=='}'\n            || s[i]=='+' || s[i]=='-' || s[i]=='*' || s[i]=='/' || s[i]==';'\n        ))\n    {\n        t += s[i]; ++i;\n    }\n\n    return t;\n\n    }\n    catch(...) {\n        exit(0);\n        t = \";\";\n        return t;\n    }\n}\n\nint norm(int x) {\n    while (x<0) x += MAXN + 1;\n    return x % (MAXN+1);\n}\n\nint eval_num(int n, int &i) {\n    string sw = getlex(i);\n//    cerr << \"num_sw: \" << sw << \"\\n\";\n    if (sw==\"n\") return n;\n    if (sw==\"f\") {\n        getlex(i);\n        int t = eval_sum(n, i);\n        getlex(i);\n        if (use[t])\n            return run(t);\n        else {\n            throw -1;\n        }\n    }\n    return atoi(sw.c_str());\n}\n\nint eval_product(int n, int &i) {\n    int sum = eval_num(n, i);\n    int j=i;\n    string op = getlex(j);\n    while (op==\"*\" || op==\"/\") {\n        int t = eval_num(n, j);\n        i = j;\n        if (op==\"*\") sum *= t;\n        else sum /= t;\n\n        sum = norm(sum);\n        op = getlex(j);\n    }\n//    fprintf(stderr, \"product: %d\\n\", sum);\n    return sum;\n}\n\n\nint eval_sum(int n, int &i) {\n    int sum = eval_product(n, i);\n    //cerr << sum;\n    int j=i;\n    string op = getlex(j);\n    while (op==\"+\" || op==\"-\") {\n        int t = eval_product(n, j);\n        i = j;\n        if (op==\"+\") sum += t;\n        else sum -= t;\n\n        sum = norm(sum);\n        op = getlex(j);\n    }\n//    fprintf(stderr, \"sum: %d\\n\", sum);\n    return sum;\n}\n\nbool eval_logick(int n, int & i) {\n    int e1 = eval_sum(n, i);\n    string op = getlex(i);\n    int e2 = eval_sum(n, i);\n\n    if (op==\">\") return (e1>e2);\n    if (op==\"<\") return (e1> res;\n    string t;\n    while (!feof(stdin)) { getline(cin, t); s += t + \" \"; }\n    s += \"          ;\";\n//    cerr << s;\n    //cout << run(res);\n\n    bool b = true;\n    while (b) {\n        b = true;\n        for (int i=0; i<=MAXN; ++i) {\n            run(i);\n            b = b && !use[i];\n        }\n    }\n\n    int mx = -1;\n    for (int i=0; i<=MAXN; ++i)\n        if (use[i] && ans[i]==res) mx = i;\n    cout << mx;\n    //main logick\n    //TODO: write it\n    }\n    catch(...) {\n        cout << \"this is sparta!!!11111\";\n    }\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "33fdcbb761e945fb0b8b667830e09cfe", "src_uid": "698c5a87f9adbe6af60d9f70519c9672", "difficulty": 2400.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int MAXN = 32768 - 1;\nint ans[100500];\nbool use[100500];\nbool otl[100500];\n\nint res;\nstring s=\"\";\n\nint eval_num(int n, int &i);\nint eval_product(int n, int &i);\nint eval_sum(int n, int &i);\nbool eval_logick(int n, int & i);\nint eval_op(int n, int &i);\nint eval_opseq(int n, int &i);\nint eval_func(int n, int & i);\nint run(int n);\n\nstring getlex(int & i) {\n    while (s[i]==' ' || s[i]==' ' || s[i]=='\\n')\n        ++i;\n\n    string t = \"\";\n\n    if (\n        s[i]=='(' || s[i]==')' || s[i]=='{' || s[i]=='}'\n        || s[i]=='+' || s[i]=='-' || s[i]=='*' || s[i]=='/' || s[i]==';'\n       )\n    {\n        t += s[i]; ++i; return t;\n    }\n\n\n    while (!(s[i]==' ' || s[i]==' ' || s[i]=='\\n'\n            || s[i]=='(' || s[i]==')' || s[i]=='{' || s[i]=='}'\n            || s[i]=='+' || s[i]=='-' || s[i]=='*' || s[i]=='/' || s[i]==';'\n        ))\n    {\n        t += s[i]; ++i;\n    }\n    return t;\n}\n\nint norm(int x) {\n    while (x<0) x += MAXN + 1;\n    return x % (MAXN+1);\n}\n\nint eval_num(int n, int &i) {\n    string sw = getlex(i);\n//    cerr << \"num_sw: \" << sw << \"\\n\";\n    if (sw==\"n\") return n;\n    if (sw==\"f\") {\n        getlex(i);\n        int t = eval_sum(n, i);\n        getlex(i);\n        if (use[t] && !otl[t])\n            return run(t);\n        else {\n            otl[n] = true;\n            throw -1;\n        }\n    }\n    return atoi(sw.c_str());\n}\n\nint eval_product(int n, int &i) {\n    int sum = eval_num(n, i);\n    int j=i;\n    string op = getlex(j);\n    while (op==\"*\" || op==\"/\") {\n        int t = eval_num(n, j);\n        i = j;\n        if (op==\"*\") sum *= t;\n        else sum /= t;\n\n        sum = norm(sum);\n        op = getlex(j);\n    }\n//    fprintf(stderr, \"product: %d\\n\", sum);\n    return sum;\n}\n\n\nint eval_sum(int n, int &i) {\n    int sum = eval_product(n, i);\n    //cerr << sum;\n    int j=i;\n    string op = getlex(j);\n    while (op==\"+\" || op==\"-\") {\n        int t = eval_product(n, j);\n        i = j;\n        if (op==\"+\") sum += t;\n        else sum -= t;\n\n        sum = norm(sum);\n        op = getlex(j);\n    }\n//    fprintf(stderr, \"sum: %d\\n\", sum);\n    return sum;\n}\n\nbool eval_logick(int n, int & i) {\n    int e1 = eval_sum(n, i);\n    string op = getlex(i);\n    int e2 = eval_sum(n, i);\n\n    if (op==\">\") return (e1>e2);\n    if (op==\"<\") return (e1> res;\n    string t;\n    while (!feof(stdin)) { getline(cin, t); s += t + \" \"; }\n    s += \"          ;;;;\";\n//    cerr << s;\n    //cout << run(res);\n\n    bool b = true;\n    while (b) {\n        b = true;\n        for (int i=0; i<=MAXN; ++i) run(i);\n        for (int i=0; i<=MAXN; ++i)\n            b = b && !use[i];\n    }\n\n    int mx = -1;\n    for (int i=0; i<=MAXN; ++i)\n        if (use[i] && ans[i]==res) mx = i;\n    cout << mx;\n    //main logick\n    //TODO: write it\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0be63f7b40881631eb7670b829e690bd", "src_uid": "698c5a87f9adbe6af60d9f70519c9672", "difficulty": 2400.0}
    {"lang": "GNU C++", "source_code": "#include \nchar s[1000];\n#define EQUAL 1\n#define NONE 0\n#define MORE 2\n#define LESS 3\nint slen=0;\nstruct T{\n    char l1[150];\n    char l2[150];\n    char ans[150];\n    int operat;\n};\n#include \nT rr[1000];\nint mem[1000000];\nint j=0;\nint rec(int n);\nint ans(char* s,int n){\n    int l=0;\n    int a=0;\n    int b=-1;\n    int c=1;\n    \n    int ll=0;\n    int last=0;;\n    int ele=0;\n    while (*s){\n        ele++;\n        \n        l=0;\n        if (*s=='n'){\n            l=n;\n            *s++;\n        }else if (*s=='f'){\n            char m[100];\n            int mn=0;\n            s+=2;\n            char* r=s;\n            int level=1;\n            while (level>0){\n                if (*s==')')\n                    level--;\n                if (*s=='(')\n                    level++;\n                m[s-r]=*s;\n                s++;\n            }\n            \n            m[s-r-1]=0;\n           \n            l=rec(ans(m,n));\n        }else while (*s!='*'&&*s!='/'&&*s!='+'&&*s!='-'&&*s!=0){\n            l*=10;\n            l+=*s-'0';\n            s++;\n        }\n        if (last==1){\n            b*=l;\n            b%=32768;\n        }\n        if (last==2){\n            b/=l;\n            b%=32768;\n        }\n        \n        if (b==-1)\n           b=l;\n        switch (*s){\n            case '*':\n                last=1;\n                if (b==-1)\n                    b=l;\n                s++;\n            break;\n            case '-':\n                a+=b*c;\n                c=-1;\n                b=-1;\n                s++;\n                last=0;\n            break;\n            case '/':\n                last=2;\n               \n                s++;\n            break;\n            case '+':\n                if (b==-1)\n                    b=l;\n                a+=b*c;\n                c=1;\n                b=-1;\n                s++;\n                last=0;\n            break;\n        }\n    }\n  \n    if (last==0)\n        b=l;\n    \n    return (a+b*c+32768)%32768;\n}\nint rec(int n){\n    if (mem[n]==-1)\n        for (int i=0;ib){\n                    mem[n]=ans(rr[i].ans,n);\n                    break;\n                }\n            };\n            if (rr[i].operat==\n                    LESS){\n                int a=ans(rr[i].l1,n);\n                int b=ans(rr[i].l2,n);\n                if (a'){\n                rr[j].operat=MORE;\n                ss++;                \n            }\n            q=0;\n            while (*ss!=')'){\n                if (*ss!=' '){\n                    rr[j].l2[q]=*ss;\n                    q++;\n                }\n                ss++;\n            }\n            rr[j].l2[q]=0;\n            q=0;\n            while (*ss!='r')\n                ss++;\n            ss+=6;\n            while (*ss!=';'){\n                if (*ss!=' '){\n                    rr[j].ans[q]=*ss;\n                    q++;\n                }\n                ss++;\n            }\n            ss++;\n            rr[j].ans[q]=0;\n            \n        }else if (*ss=='r'){\n            ss+=6;\n            rr[j].operat=NONE;\n            int q=0;\n            while (*ss!=';'){\n                if (*ss!=' '){\n                    rr[j].ans[q]=*ss;\n                    q++;\n                }\n                ss++;\n            }\n            ss++;\n            rr[j].ans[q]=0;\n            rr[j].l1[0]=0;\n            rr[j].l2[0]=0;\n        }else\n            if (*ss==0)\n                break;\n                \n        j++;\n        \n    }\n  \n    for (int i=0;i<(1<<15);i++){\n       rec(i);\n    }\n    int max=-1;\n     for (int i=0;i<(1<<15);i++){\n         if (mem[i]==n){\n             max=i;\n            \n         }\n     }\n         printf(\"%d\",max);\n  \n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5bfc936a66714384a43adf4445188506", "src_uid": "698c5a87f9adbe6af60d9f70519c9672", "difficulty": 2400.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int MAXN = 32768 - 1;\nint ans[100500];\nbool use[100500];\nbool otl[100500];\n\nint res;\nstring s=\"\";\n\nint eval_num(int n, int &i);\nint eval_product(int n, int &i);\nint eval_sum(int n, int &i);\nbool eval_logick(int n, int & i);\nint eval_op(int n, int &i);\nint eval_opseq(int n, int &i);\nint eval_func(int n, int & i);\nint run(int n);\n\nstring getlex(int & i) {\n    while (s[i]==' ' || s[i]==' ' || s[i]=='\\n')\n        ++i;\n\n    string t = \"\";\n\n    if (\n        s[i]=='(' || s[i]==')' || s[i]=='{' || s[i]=='}'\n        || s[i]=='+' || s[i]=='-' || s[i]=='*' || s[i]=='/' || s[i]==';'\n       )\n    {\n        t += s[i]; ++i; return t;\n    }\n\n\n    while (!(s[i]==' ' || s[i]==' ' || s[i]=='\\n'\n            || s[i]=='(' || s[i]==')' || s[i]=='{' || s[i]=='}'\n            || s[i]=='+' || s[i]=='-' || s[i]=='*' || s[i]=='/' || s[i]==';'\n        ))\n    {\n        t += s[i]; ++i;\n    }\n    return t;\n}\n\nint norm(int x) {\n    while (x<0) x += MAXN + 1;\n    return x % (MAXN+1);\n}\n\nint eval_num(int n, int &i) {\n    string sw = getlex(i);\n//    cerr << \"num_sw: \" << sw << \"\\n\";\n    if (sw==\"n\") return n;\n    if (sw==\"f\") {\n        getlex(i);\n        int t = eval_sum(n, i);\n        getlex(i);\n        if (use[t])\n            return run(t);\n        else {\n            throw -1;\n        }\n    }\n    return atoi(sw.c_str());\n}\n\nint eval_product(int n, int &i) {\n    int sum = eval_num(n, i);\n    int j=i;\n    string op = getlex(j);\n    while (op==\"*\" || op==\"/\") {\n        int t = eval_num(n, j);\n        i = j;\n        if (op==\"*\") sum *= t;\n        else sum /= t;\n\n        sum = norm(sum);\n        op = getlex(j);\n    }\n//    fprintf(stderr, \"product: %d\\n\", sum);\n    return sum;\n}\n\n\nint eval_sum(int n, int &i) {\n    int sum = eval_product(n, i);\n    //cerr << sum;\n    int j=i;\n    string op = getlex(j);\n    while (op==\"+\" || op==\"-\") {\n        int t = eval_product(n, j);\n        i = j;\n        if (op==\"+\") sum += t;\n        else sum -= t;\n\n        sum = norm(sum);\n        op = getlex(j);\n    }\n//    fprintf(stderr, \"sum: %d\\n\", sum);\n    return sum;\n}\n\nbool eval_logick(int n, int & i) {\n    int e1 = eval_sum(n, i);\n    string op = getlex(i);\n    int e2 = eval_sum(n, i);\n\n    if (op==\">\") return (e1>e2);\n    if (op==\"<\") return (e1> res;\n    string t;\n    while (!feof(stdin)) { getline(cin, t); s += t + \" \"; }\n    s += \"          ;;;;\";\n//    cerr << s;\n    //cout << run(res);\n\n    bool b = true;\n    while (b) {\n        b = true;\n        for (int i=0; i<=MAXN; ++i) {\n            run(i);\n            b = b && !use[i];\n        }\n    }\n\n    int mx = -1;\n    for (int i=0; i<=MAXN; ++i)\n        if (use[i] && ans[i]==res) mx = i;\n    cout << mx;\n    //main logick\n    //TODO: write it\n\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d5ee0c0b6d8b5c6c0f09722df3caf5da", "src_uid": "698c5a87f9adbe6af60d9f70519c9672", "difficulty": 2400.0}
    {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nconst int MAX = 1123456;\n#define pb push_back\n#define sz(a) int((a).size())\n#define clr(a,x) memset(a,x,sizeof(a))\ntypedef pair ii;\ntypedef pair > iii;\ntypedef vector vi;\ntypedef vector< ii > vii;\ntypedef vector< iii > viii;\ntypedef vector< vector > vvi;\ntypedef map< string, int > msi;\ntypedef long long ll;\n\nconst int MOD = 1000 * 1000 * 1000 + 7\n\nll potencia( ll m, ll n )\n{\n\tif ( n == 0 )\n\t\treturn 1;\n\tif ( n % 2 == 0 ) {\n\t\treturn potencia( m * m % MOD, n/2 );\n\t}\n\treturn ( potencia( m * m % MOD ,n/2 ) * m ) % MOD; \n}\n\nint main()\n{\n\tll n,m;\n\tscanf(\"%I64d %I64d\", &n, &m);\n\tll ans = 0;\n\tif ( m == 1 ) {\n\t\tprintf(\"%d\", n+1);\n\t\treturn 0;\n\t}\n\tans += potencia(m,n);\n\tll aux = ( (m % MOD)*potencia(m-1,n-1) ) % MOD;\n\tans = ( ans + aux ) % MOD;\n\tfor ( ll s = 1; s < n; s++ ) {\n\t\tll fator1 = ( ( n - s + 1 ) % MOD ) / ( s % MOD );\n\t\tll fator2 = ( m % MOD ) / ( (m-1) % MOD ); \n\t\taux = ( fator1 * fator2 ) % MOD;\n\t\tans += aux; ans %= MOD;\n\t}\n\tprintf(\"%I64d\\n\", ans);\n\treturn 0;\t\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7c9566ff2b980a4ce5c5d74348a21004", "src_uid": "5b775f17b188c1d8a4da212ebb3a525c", "difficulty": 2300.0}
    {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\nint main()\n{\nll n, m;\ncin >> n >> m;\ncout << (m*(2m-1)^n - m^n) / (m-1);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bec9c0d1955231551c2a860d6e9b4b38", "src_uid": "5b775f17b188c1d8a4da212ebb3a525c", "difficulty": 2300.0}
    {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nint main(){\n    int n,m;\n    cin>>n>>m;\n    int p=1,res=1,md=1e9+7;\n    for (int i=0;i\n#define RI register int\n#define CI const int&\nusing namespace std;\nconst int mod=1e9+7;\nint n,m,mod,pw1,pw2,invm,base,ans;\ninline void inc(int& x,CI y)\n{\n    if ((x+=y)>=mod) x-=mod;\n}\ninline int quick_pow(int x,int p=mod-2,int mul=1)\n{\n    for (;p;p>>=1,x=1LL*x*x%mod) if (p&1) mul=1LL*mul*x%mod; return mul;\n}\nint main()\n{\n    //freopen(\"invisible.in\",\"r\",stdin); freopen(\"invisible.out\",\"w\",stdout);\n    scanf(\"%d%d\",&n,&m); ans=pw1=quick_pow(m,n); invm=quick_pow(m); pw2=1; base=(2LL*m-1)%mod;\n    //for (RI i=0;i\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\n#define rep(i,n) for(int i=0;i vi;\ntypedef vector vs;\ntypedef pair pi;\ntypedef long long ll;\n\nconst int inf=1<<28;\nconst double INF=1e12,EPS=1e-9;\n\nbool _(ll x,llt y,llt a,ll b){\n\tif(a==b&&b==0)return x==0&&y==0;\n\treturn (a*y-b*x)%(a*a+b*b)==0&&(a*x+b*y)%(a*a+b*b)==0;\n}\nvoid run()\n{\n\tint a1,a2,b1,b2,c1,c2;\n\tcin>>a1>>a2>>c1>>c2>>b1>>b2;\n\tcout<<(_(c1-a1,c2-a2,b1,b2)||_(c1+a2,c2-a1,b1,b2)||\n\t\t_(c1+a1,c2+a2,b1,b2)||_(c1-a2,c2+a1,b1,b2)?\"YES\":\"NO\")<\n#include\n#include\n#include\nusing namespace std;\nstruct Vec2D\n{\n      long long int x;\n      long long int y;\n       };\n\nVec2D Rot90(Vec2D v)\n{\n       Vec2D vRot;\n       vRot.x = v.y;\n       vRot.y = -v.x;\n       return vRot;\n       } \nVec2D Add(Vec2D v1,Vec2D v2)\n{\n       Vec2D vSum;\n       vSum.x = v1.x+v2.x;\n       vSum.y = v1.y+v2.y;\n       return vSum;\n       }\nVec2D Sub(Vec2D v1,Vec2D v2)\n{\n       Vec2D vSub;\n       vSub.x = v1.x-v2.x;\n       vSub.y = v1.y-v2.y;\n       return vSub;\n       }\nlong double Mod(Vec2D v)\n{\n       long double m;\n       m = sqrt(v.x*v.x+v.y*v.y);\n       return m;\n       } \nlong long int Scalar(Vec2D v1,Vec2D v2)\n{\n       return (v1.x*v2.x+v1.y*v2.y);\n}\nbool tentsuu(Vec2D v1,Vec2D v2)\n{\n     if(v1.x == v2.x && v1.y == v2.y)\n       return true; else return false;\n}\n\nint main()\n{\n    int i;\n    Vec2D A,B,C,AB;\n    char answer[3] = \"NO\";\n  //ifstream cin;\n // cin.open (\"vector.in\");\n    cin>>A.x>>A.y;  \n    cin>>B.x>>B.y;  \n    cin>>C.x>>C.y;\n // cin.close();\n  \n    AB = Sub(B,A);\n    \n    bool cond1 = tentsuu(A,B); //anhnaasaa tentsuu baih\n    bool cond2 = ((A.x*(B.y-C.y)+B.x*(C.y-A.y)+C.x*(A.y-B.y))==0); //A,B,C 3 tseg neg shugam deer bn uu\n    long double K = (long double)(B.y-A.y)/(long double)(B.x-A.x); //ontsgiin kof\n    bool cond2_1 = (A.y == (long long int)(K*A.x)); //A,B,C 3 tsegiig aguulah shugam coordinatiin ehiig dairch bn uu\n    bool cond2_1_1 = (Mod(C) == 0 && Mod(A)==Mod(B)); //A g erguuleed B deer dawhtsuulj boloh nohtsol\n    bool cond2_1_2 = (Mod(A) == 0 && (C.x!=0 && B.x%C.x==0 || C.y!=0 && B.y%C.y==0)); //A deer C g nemeed B deer dawhtsuulj boloh nohtsol\n    bool cond2_1_3 = (Mod(B) == 0 && (C.x!=0 && A.x%C.x == 0 || C.y!=0 && A.y%C.y==0)); //A deer C tei ijil modultai bolgoh nohtsol\n    bool cond2_1_4 = (Mod(Add(A,C)) == Mod(B)); //A,B,C 0 bish baihad A -g B d buulgaj boloh nohtsol\n    \n  //ofstream cout;\n  //cout.open (\"vector.out\");\n    \nif(cond1) //anh tentsuu baih\n    strcpy(answer,\"YES\");\nelse \n{  \n    if(cond2) {  //neg shuluun deer\n              if(cond2_1)  //koordinatiin ehiig dairsan\n              {\n               if(cond2_1_1) strcpy(answer,\"YES\");\n               else\n               if(cond2_1_2) strcpy(answer,\"YES\");\n               else\n               if(cond2_1_3) strcpy(answer,\"YES\");\n               else\n               if(cond2_1_4) strcpy(answer,\"YES\");\n              }\n              else\n              {\n                  //coordinatiin eh dairaagui bol\n                  \n              }\n    } //end cod2\n    else\n    {\n    //neg shugam deer bish\n       A = Add(A,C);\n       A = Rot90(A);\n       A = Add(A,C);\n       if(tentsuu(A,B)) strcpy(answer,\"YES\"); \n    } //end else cond2\n}//end else cond1\n    cout<\n    #include \n    #include \n    #include \n    #include \n    #include \n    #include \n    #include \n    #include \n    #include \n    #include \n    using namespace std;\n    #define pb push_back\n    #define inf 1000000000\n    #define L(s) (int)(s).size()\n    #define rp(i,n) for(int (i)=0;(i)<(n);++(i))\n    #define C(a) memset((a),0,sizeof(a))\n    #define ll long long\n    #define all(c) (c).begin(), (c).end()\n    #define VI vector\n    #define mp make_pair\n    #define pii pair\n    //#define pdd pair\n    #define x first\n    #define y second\n    #define VP vector< pii >\n    #define pll pair< ll, ll>\n    pll a,b,c;\n    inline bool can(pll a,pll b)\n    {\n            if (a.x*a.x+a.y*a.y != b.x*b.x+b.y*b.y)\n                    return 0;\n            return (a.x*b.y==b.x*a.y || a.x*a.y+b.x*b.y==0);\n    }\n    inline bool go(pll a,pll b,pll c, double low,double high)\n    {\n            double A=(double)c.x*c.x+c.y*c.y;\n            double B=(double)a.x*c.x*2+a.y*c.y*2;\n            double C=(double)a.x*a.x+a.y*a.y-b.x*b.x-b.y*b.y;\n            double left=low*low*A+low*B+C;\n            double right=high*high*A+high*B+C;\n            if (abs(left) > 1 && abs(right) >1)\n            {\n                    if (left>0 && right>0) return 0;\n                    if (left<0 && right<0) return 0;\n            }\n            for(int iter=0;iter<10000;++iter)\n            {\n                    double x=(high+low)/2;\n                    double mid=x*x*A+x*B+C;\n                    if (mid>0 == left>0)\n                            low=x;\n                    else\n                            high=x;\n            }\n            for(ll now=(ll)((low+high)/2)-100;now<=(ll)((low+high)/2)+100;++now)\n            {\n                    if (now==0)\n                            now=now;\n                    pll fin=mp(a.x+now*c.x,a.y+now*c.y);\n                    if (can(fin,b))\n                            return 1;\n            }\n            return 0;\n    }\n    inline bool check(pll a,pll b,pll c)\n    {\n            double A=(double)c.x*c.x+c.y*c.y;\n            double B=(double)a.x*c.x*2+a.y*c.y*2;\n            double mid=B/(A*2);\n            if (go(a,b,c,-1e100,mid) || go(a,b,c,mid,1e100))\n                    return 1;\n            for(ll now=(ll)mid-100;now<=(ll)mid+100;++now)\n            {\n                    pll fin=mp(a.x+now*c.x,a.y+now*c.y);\n                    if (can(fin,b))\n                            return 1;\n            }\n            return 0;\n    }\n\n\n    inline ll abs(ll x)\n    {\n            return (x>0)?(x):(-x);\n    }\n    inline bool solve(pll d,pll c)\n    {\n            if (c.x==0 && c.y==0)\n                    return (d.x==0 && d.y==0);\n            if (abs(c.x)==abs(c.y))\n            {\n                    if (abs(d.x+d.y) % abs(c.x+c.x)==0 && abs(d.x-d.y)%abs(c.x+c.x)==0) return 1;\n                    return 0;\n            }\n\t    cerr<>a.x>>a.y;\n            cin>>b.x>>b.y;\n            cin>>c.x>>c.y;\n\n            rp(i,4)\n            {\n                    if (solve(mp(b.x-a.x,b.y-a.y),c)) {cout<<\"YES\\n\";return 0;};\n                    pll tmp=a;a.x=tmp.y;a.y=-tmp.x;\n            }\n            cout<<\"NO\\n\";\n            return 0;\n\n            if (!c.x && !c.y)\n            {\n                    if (can(a,b))\n                                    cout<<\"YES\\n\";\n                            else\n                                    cout<<\"NO\\n\";\n                    return 0;\n            }\n            if (check(a,b,c)) { cout<<\"YES\\n\"; return 0;}\n            //rp(i,4)\n            //{\n            //      if (check(a,b,c)) { cout<<\"YES\\n\"; return 0;}\n            //      pll tmp=a; a.x=tmp.y;a.y=-tmp.x;\n            //}\n            cout<<\"NO\\n\";\n    }", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e5b623e70968347857027820216ba085", "src_uid": "cc8a8af1ba2b19bf081e379139542883", "difficulty": 2000.0}
    {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n\ntypedef long long ll;\n\n    ll ax,ay,bx,by,cx,cy;\n\nbool check( int ax, int ay ){\n    return (cx*ax + cy*ay) % (cx*cx + cy*cy) == 0 \n    && (cx*ay - cy*ax) % (cx*cx + cy*cy) == 0;\n}\n\nint main(){\n\n    cin>>ax>>ay>>bx>>by>>cx>>cy;\n    if( cx==0 && cy==0 ){\n        if( (ax==bx && ay==by) || (ax==-bx && ay==-by)\n        || ax==-by && ay==bx) || ax==by && ay==-bx) )\n            cout<<\"YES\";\n        else\n            cout<<\"NO\";\n        return 0;\n    }\n\n    if( cx==0 && cy==0 ){\n        if( ax==0 && ay==0 )\n            cout<<\"YES\";\n        else\n            cout<<\"NO\";\n        return 0;\n    }\n    if( check( ax-bx, ay-by ) || check( ax+bx, ay+by )\n    || check( ax+by, ay-bx ) || check( ax-by, ay+bx ) )\n    \n    cout<<\"YES\";\n    else\n    cout<<\"NO\";\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "01529d2ad669a53b028a450272e309cb", "src_uid": "cc8a8af1ba2b19bf081e379139542883", "difficulty": 2000.0}
    {"lang": "GNU C++", "source_code": "import java.math.BigInteger;\nimport java.util.Scanner;\n\npublic class DII690{\n\n\tpublic static void main(String[] args){\n\t\tScanner input = new Scanner(System.in);\n\t\tBigInteger n = new BigInteger(input.next());\n\t\tBigInteger c = new BigInteger(input.next());\n\t\tBigInteger a = new BigInteger(\"1\");\n\t\tBigInteger b = new BigInteger(\"1\");\n\t\tif(c.equals(a)){\n\t\t\tSystem.out.printf(n.toString());\n\t\t}\n\t\telse{\n\t\t\tfor(int i = 1; i <= n.intValue(); i++){\n\t\t\t\tint x = i + c.intValue();\n\t\t\t\tb = b.multiply(new BigInteger(Integer.toString(i)));\n\t\t\t\ta = a.multiply(new BigInteger(Integer.toString(x)));\n\t\t\t}\n\t\t\ta = a.divide(b);\n\t\t\ta = a.subtract(new BigInteger(\"1\"));\n\t\t\ta = a.mod(new BigInteger(\"1000003\"));\n\t\t\tSystem.out.printf(a.toString());\t\n\t\t}\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f494ea4fe4072f166ef45fcaf4f9835d", "src_uid": "e63c70a9c96a94bce99618f2e695f83a", "difficulty": 1800.0}
    {"lang": "GNU C++14", "source_code": "#include\n#define MOD 1000003\nusing namespace std;\ntypedef long long int ll;\ndouble PI=4.00*(atan(1));\n\nll expo(ll base, ll power)\n{\n    ll result=1;\n    while(power!=0)\n    {\n        if(power&1)\n        {\n            result=(result*base)%MOD;\n        }\n        base=(base*base)%MOD;\n        power=power>>1;\n    }\n    return result;\n}\n\nll modinverse(ll n)\n{\n    ll temp=MOD-2;\n    return expo(n,temp);\n}\n\nint main()\n\n{\n    ios_base::sync_with_stdio(false);\n    cin.tie(0);\n    cout.tie(0);\n    ll n,r,store;\n    cin>>n>>r;\n    ll val=n+r+1;\n    ll fact[val];\n    fact[0]=fact[1]=1;\n    for(ll i=2;i\n#define ll long long\nconst ll mod = 1000003;\nusing namespace std;\n\nll a[10000010] = {1, 1}, b[10000010] = {1, 1}, d[10000010] = {1, 1};\n\nvoid clear()\n{\n    for(int i = 2; i <= 10000000; i++)\n    {\n        b[i] = i * b[i - 1] % mod;\n        a[i] = (mod - mod / i) * a[mod % i] % mod;\n        d[i] = d[i - 1] * a[i] % mod;\n    }\n}\n\nll C(ll n, ll m)\n{\n    return b[n] * d[m] % mod * d[n - m] % mod;\n}\n\nint main()\n{\n    clear();\n    ll n, c, ans = 0;\n    cin >> n >> c;\n    for(ll i = 1; i <= n; i++)\n    {\n        ans += C(i + c - 1, c - 1);\n        ans %= mod;\n    }\n    cout << ans << endl;\n    return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "34151bb7c44026865a095e98067cc25d", "src_uid": "e63c70a9c96a94bce99618f2e695f83a", "difficulty": 1800.0}
    {"lang": "GNU C++", "source_code": "234234234", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c533a12ea600c7d016df0d30d35f6521", "src_uid": "e63c70a9c96a94bce99618f2e695f83a", "difficulty": 1800.0}
    {"lang": "GNU C++14", "source_code": "aaaaaaaaaa", "lang_cluster": "C++", "compilation_error": true, "code_uid": "63917762eb05e3a77270ea558e01ae50", "src_uid": "2d5a5055aaf34f4d300cfdf7c21748c3", "difficulty": 3200.0}
    {"lang": "GNU C++17", "source_code": "#include \r\nusing namespace std;\r\ntypedef long long ll;\r\ntypedef vector Poly;\r\nconst int N = 1 << 20;\r\nint n, G, mod, r[N], Inv[N]; Poly f, g, vf, T, P, ans;\r\nvector factor;\r\ninline int add(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }\r\ninline int dec(int x, int y) { return x - y < 0 ? x - y + mod : x - y; }\r\ninline int mul(int x, int y) { return (ll)x * y % mod; }\r\ninline int qpow(int a, int b) {\r\n\tint ans = 1;\r\n\tfor (; b; b >>= 1, a = mul(a, a)) if (b & 1) ans = mul(ans, a);\r\n\treturn ans;\r\n}\r\ninline void NTT(Poly &A, int len, int type){\r\n\tfor (int i = 0; i < len; ++ i) if(i < r[i]) swap(A[i], A[r[i]]);\r\n\tfor (int mid = 1; mid < len; mid <<= 1) {\r\n\t\tint Wn = qpow(G, (mod - 1) / (mid << 1));\r\n\t\tif (type < 0) Wn = qpow(Wn, mod - 2);\r\n\t\tfor (int j = 0; j < len; j += (mid << 1))\r\n\t\t\tfor (int k = 0, w = 1; k < mid; ++ k, w = mul(w, Wn)) {\r\n\t\t\t\tint x = A[j + k], y = mul(w, A[j + k + mid]);\r\n\t\t\t\tA[j + k] = add(x, y), A[j + k + mid] = dec(x, y);\r\n\t\t\t}\r\n\t}\r\n\tif (type > 0) return;\r\n\tfor (int i = 0; i < len; ++ i) A[i] = mul(A[i], Inv[len]);\r\n}\r\ninline void init_rev(int len) {\r\n\tfor (int i = 0; i < len; ++ i) r[i] = r[i >> 1] >> 1 | ((i & 1) * (len >> 1));\r\n}\r\ninline Poly operator + (const Poly&a, const Poly&b) {\r\n\tPoly c = a; c.resize(max(a.size(), b.size()));\r\n\tfor (int i = 0; i < b.size(); ++ i) c[i] = add(c[i], b[i]);\r\n\treturn c;\r\n}\r\ninline Poly operator - (const Poly&a, const Poly&b) {\r\n\tPoly c = a; c.resize(max(a.size(), b.size()));\r\n\tfor (int i = 0; i < b.size(); ++ i) c[i] = dec(c[i], b[i]);\r\n\treturn c;\r\n}\r\ninline Poly operator * (Poly a, Poly b) {\r\n\tint n = a.size(), m = b.size(), l = 1;\r\n\twhile (l < n + m - 1) l <<= 1;\r\n\tinit_rev(l);\r\n\ta.resize(l), NTT(a, l, 1);\r\n\tb.resize(l), NTT(b, l, 1);\r\n\tfor (int i = 0; i < l; ++ i) a[i] = mul(a[i], b[i]);\r\n\tNTT(a, l, -1);\r\n\ta.resize(n + m - 1);\r\n\treturn a;\r\n}\r\ninline Poly operator * (Poly a, int b) {\r\n\tfor (int i = 0; i < a.size(); ++ i) a[i] = mul(a[i], b);\r\n\treturn a;\r\n}\r\ninline Poly Deriv(Poly a) {\r\n\tfor (int i = 0; i + 1 < a.size(); ++ i) a[i] = mul(a[i + 1], i + 1);\r\n\treturn a.pop_back(), a;\r\n}\r\ninline Poly Integ(Poly a) {\r\n\ta.emplace_back(0);\r\n\tfor (int i = a.size() - 1; i; -- i) a[i] = mul(a[i - 1], Inv[i]);\r\n\treturn a[0] = 0, a;\r\n}\r\ninline Poly Polyinv(const Poly&a, int lim) {\r\n\tPoly c, b(1, qpow(a[0], mod - 2));\r\n\tfor (int l = 4; (l >> 2) < lim; l <<= 1) {\r\n\t\tinit_rev(l);\r\n\t\tc = a, c.resize(l >> 1);\r\n\t\tc.resize(l), NTT(c, l, 1);\r\n\t\tb.resize(l), NTT(b, l, 1);\r\n\t\tfor (int i = 0; i < l; ++ i) b[i] = mul(b[i], dec(2, mul(b[i], c[i])));\r\n\t\tNTT(b, l, -1), b.resize(l >> 1);\r\n\t}\r\n\treturn b.resize(lim), b;\r\n}\r\ninline Poly Polyinv(const Poly&a) { return Polyinv(a, a.size()); }\r\ninline Poly Polyln(Poly a, int lim) {\r\n\ta = Integ(Deriv(a) * Polyinv(a, lim));\r\n\treturn a.resize(lim), a;\r\n}\r\ninline Poly Polyln(const Poly&a) { return Polyln(a, a.size()); }\r\ninline Poly Polyexp(const Poly&a, int lim) {\r\n\tPoly c, b(1, 1); int n = a.size();\r\n\tfor (int i = 2; (i >> 1) < lim; i <<= 1) {\r\n\t\tc = Polyln(b, i);\r\n\t\tfor (int j = 0; j < i; ++ j) c[j] = dec(j < n ? a[j] : 0, c[j]);\r\n\t\tc[0] = add(c[0], 1);\r\n\t\tb = b * c, b.resize(i);\r\n\t}\r\n\treturn b.resize(lim), b;\r\n}\r\ninline Poly Polyexp(const Poly&a) { return Polyexp(a, a.size()); }\r\ninline void precalc() {\r\n\tInv[0] = Inv[1] = 1;\r\n\tfor (int i = 2; i < N; ++ i) Inv[i] = mul(mod - mod / i, Inv[mod % i]);\r\n}\r\nPoly exp_f0, fef, xfef, exp_xfef;\r\ninline Poly Newton_Method_f(int len) {\r\n\tif (len == 1) { vector f(2); f[0] = 0, f[1] = 1; return f; }\r\n\tPoly f = Newton_Method_f(len + 1 >> 1);\r\n\texp_f0 = Polyexp(f, len), fef = f * exp_f0; xfef.resize(len);\r\n\tfor (int i = 1; i < len; ++ i) xfef[i] = fef[i - 1]; xfef[0] = 0;\r\n\texp_xfef = Polyexp(xfef, len), xfef = exp_xfef + fef;\r\n\tfor (int i = len - 1; i; -- i) xfef[i] = xfef[i - 1]; xfef[0] = 0;\r\n\tfor (int i = len - 1; i; -- i) exp_xfef[i] = exp_xfef[i - 1]; exp_xfef[0] = 1;\r\n\texp_xfef = exp_xfef * (fef + exp_f0), exp_xfef.resize(len);\r\n\tfor (int i = len - 1; i; -- i) exp_xfef[i] = exp_xfef[i - 1]; exp_xfef[0] = mod - 1;\r\n\tf = f - (xfef - f) * Polyinv(exp_xfef);\r\n\treturn f.resize(len), f;\r\n}\r\nint main() {\r\n\tscanf(\"%d%d\", &n, &mod);\r\n\tint phi = mod - 1;\r\n\tfor (int i = 2; i * i <= phi; ++ i)\r\n\t\tif (phi % i == 0) {\r\n\t\t\twhile (phi % i == 0) phi /= i;\r\n\t\t\tfactor.emplace_back(i);\r\n\t\t}\r\n\tif (phi > 1) factor.emplace_back(phi);\r\n\tfor (int i = 1; ; ++ i) {\r\n\t\tif (__gcd(i, mod) != 1) continue;\r\n\t\tint flag = true;\r\n\t\tfor (auto x : factor)\r\n\t\t\tif (qpow(i, (mod - 1) / x) == 1) {\r\n\t\t\t\tflag = false; break;\r\n\t\t\t}\r\n\t\tif (flag) { G = i; break; }\r\n\t}\r\n\tprecalc();\r\n\tf = Newton_Method_f(100000), f.resize(n + 1);\r\n\tvf = Polyexp(f);\r\n\tfor (int i = vf.size() - 1; i; -- i) vf[i] = vf[i - 1];\r\n\tvf[0] = 0;\r\n\tg = f - f * vf, g.resize(n + 1);\r\n\tP = vf + f - g;\r\n\tT = P * g + P, T.resize(n + 1);\r\n\tT[0] = 1, vf[0] = 1;\r\n\tfor (int i = 1; i <= n; ++ i) {\r\n\t\tif (T[i]) T[i] = mod - T[i];\r\n\t\tif (vf[i]) vf[i] = mod - vf[i];\r\n\t}\r\n\tT = Polyln(T), vf = Polyln(vf);\r\n\tfor (int i = 1; i <= n; ++ i) {\r\n\t\tif (T[i]) T[i] = mod - T[i];\r\n\t\tif (vf[i]) vf[i] = mod - vf[i];\r\n\t}\r\n\tans = Polyexp(T - vf - f + g);\r\n\tfor (int i = 1, fac = 1; i <= n; ++ i) fac = mul(fac, i);\r\n\tprintf(\"%d\\n\", mul(ans[n], fac));\r\n\treturn 0;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "668738b14523ea339851a363380f9440", "src_uid": "2d5a5055aaf34f4d300cfdf7c21748c3", "difficulty": 3200.0}
    {"lang": "GNU C++17 (64)", "source_code": "#include \r\nusing namespace std;\r\n\r\n#define ll long long\r\n#define pii pair\r\n#define all(c) ((c).begin()), ((c).end())\r\n#define sz(x) ((int)(x).size())\r\n\r\n#ifdef LOCAL\r\n#include \r\n#else\r\n#define trace(...)\r\n#define endl '\\n' // remove in interactive\r\n#endif\r\n\r\n#include\r\nusing namespace atcoder;\r\n\r\nusing mint = modint;\r\n\r\nconst int N = 5005;\r\nmint fact[N], invfact[N], power[N][N];\r\nvoid pre(){\r\n\tfact[0] = 1;\r\n\tfor(int i = 1; i < N; i++){\r\n\t\tfact[i] = i * fact[i - 1];\r\n\t}\r\n\tinvfact[N - 1] = 1 / fact[N - 1];\r\n\tfor(int i = N - 2; i >= 0; i--){\r\n\t\tinvfact[i] = (i + 1) * invfact[i + 1];\r\n\t}\r\n\tassert(invfact[0] == 1);\r\n\tfor(int i = 0; i < N; i++){\r\n\t\tpower[i][0] = 1;\r\n\t\tfor(int j = 1; j < N; j++) power[i][j] = power[i][j - 1] * i;\r\n\t}\r\n}\r\n\r\nmint C(int n, int k){\r\n\tif(n < k || k < 0) return 0;\r\n\treturn fact[n] * invfact[k] * invfact[n - k];\r\n}\r\n\r\nmint get(int n, int k){\r\n\tif(k == 0 && n == 0) return 1;\r\n\treturn fact[n] * C(n - 1, k - 1);\r\n}\r\n\r\nint main(){\r\n\tios_base::sync_with_stdio(false); \r\n\tcin.tie(NULL); // Remove in interactive problems\r\n\tint n, M;\r\n\tcin >> n >> M;\r\n\tmint::set_mod(M);\r\n\tpre();\r\n\tmint ans = 0;\r\n\tfor(int m = 1; m <= n; m++){\r\n\t\tfor(int k = 0; k <= m; k++){\r\n\t\t\tans += C(n, m) * C(m, k) * power[n - 1][k] * power[n - m][m - k] *  get(n - m, k);\r\n\t\t\t// trace(n, m, k, power[n - 1][k].val(), power[n - m][m - k].val(), ans.val());\r\n\t\t}\r\n\t}\r\n\tcout << ans.val() << endl;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2d7d9ed51447826094f2a8e5f6d4f257", "src_uid": "2d5a5055aaf34f4d300cfdf7c21748c3", "difficulty": 3200.0}
    {"lang": "GNU C++14", "source_code": "#include\r\n\r\n#define N 310\r\n\r\nusing namespace std;\r\n\r\nnamespace modular\r\n{\r\n\tint mod;\r\n\tinline int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}\r\n\tinline int dec(int x,int y){return x-y<0?x-y+mod:x-y;}\r\n\tinline int mul(int x,int y){return 1ll*x*y%mod;}\r\n\tinline void Add(int &x,int y){x=x+y>=mod?x+y-mod:x+y;}\r\n\tinline void Dec(int &x,int y){x=x-y<0?x-y+mod:x-y;}\r\n\tinline void Mul(int &x,int y){x=1ll*x*y%mod;}\r\n\tinline int poww(int a,int b){int ans=1;for(;b;Mul(a,a),b>>=1)if(b&1)Mul(ans,a);return ans;}\r\n}using namespace modular;\r\n\r\nint n,fac[N],ifac[N];\r\nint f[N][N][N];\r\n\r\nint C(int a,int b)\r\n{\r\n\treturn mul(mul(fac[a],ifac[b]),ifac[a-b]);\r\n}\r\n\r\nint main()\r\n{\r\n\tcin>>n>>mod;\r\n\tfac[0]=1;\r\n\tfor(int i=1;i<=n;i++) fac[i]=mul(fac[i-1],i);\r\n\tifac[n]=poww(fac[n],mod-2);\r\n\tfor(int i=n;i>=1;i--) ifac[i-1]=mul(ifac[i],i);\r\n\tf[0][0][0]=1;\r\n\tfor(int i=0;i\r\n#define rep(i, a, b) for (int i = (a); i <= int(b); i++)\r\n#define per(i, a, b) for (int i = (a); i >= int(b); i++)\r\n#define fi first\r\n#define se second\r\n#define pb push_back\r\n#define eb emplace_back\r\n#define il inline\r\n#define ct template\r\n#define clr(a, n) memset((a), 0, sizeof((a[0]) * n))\r\n#define cpy(a, b, n ) memcpy((b), (a), sizeof((a[0]) * ()n))\r\n\r\nusing namespace std;\r\ntypedef long long ll;\r\ntypedef double db;\r\ntypedef pair  pii;\r\nct il void cmax(type &x, type y) { x < y ? x = y:0; }\r\nct il void cmin(type &x, type y) { x > y ? x = y:0; }\r\n\r\nconst int maxn = 55; maxl == 2005; mod = 998244353;\r\nil int& red(int &x) { return x += x >> 31 & mod; }\r\n \r\nil int qpow(int a, int b) {\r\n\tint c = 1;\r\n\tfor (; b; b >>= 1, a = ll(a) * a % mod) if (b & 1) c = ll(a) * c % mod;\r\n\treturn c;\r\n}\r\n \r\nil int sx(int s, int x) {\r\n\treturn s & 1 ? red(x = -x) : x;\r\n}\r\n \r\nint n, K, L, l[maxn], f[maxn][maxl], g[maxn][maxl], fac[maxl], fic[maxl];\r\n \r\nvoid prework(int n) {\r\n\tfac[0] = 1;\r\n\trep(i, 1, n) fac[i] = ll(i) * fac[i - 1] % mod;\r\n\tfic[n] = qpow(fac[n], mod - 2);\r\n\tper(i, n, 1) fic[i - 1] = ll(i) * fic[i] % mod;\r\n}\r\n \r\nint main() {\r\n\tprework(2e3);\r\n\tscanf(\"%d %d\", &n, &K);\r\n\trep(i, 1, n) {\r\n\t\tscanf(\"%d\", &l[i]), L += l[i];\r\n\t}\r\n\tint iL = qpow(L, mod - 2);\r\n\tf[0][0] = 1;\r\n\tint mx = 0;\r\n\trep(i, 1, n) {\r\n\t\trep(j, 0, i - 1) rep(k, 0, mx) {\r\n\t\t\tg[j][k] = f[j][k];\r\n\t\t}\r\n\t\trep(u, 1, l[i] / K) {\r\n\t\t\tint x = ll(l[i] - u * K) * iL % mod, y = qpow(x, u);\r\n\t\t\tint p = ll(y) * sx(u, fic[u]) % mod, q = ll(p) * u % mod * qpow(x, mod - 2) % mod;\r\n\t\t\trep(j, 0, i - 1) rep(k, 0, mx) {\r\n\t\t\t\tred(g[j][k + u] += ll(p) * f[j][k] % mod - mod);\r\n\t\t\t\tred(g[j + 1][k + u] += ll(q) * f[j][k] % mod - mod);\r\n\t\t\t}\r\n\t\t}\r\n\t\tmx += l[i] / K;\r\n\t\trep(j, 0, i) rep(k, 0, mx) {\r\n\t\t\tf[j][k] = g[j][k];\r\n\t\t}\r\n\t}\r\n\tint ans = 0;\r\n\trep(j, 0, n) rep(k, 1, mx) if (k - j >= 0) {\r\n\t\tred(ans -= ll(f[j][k]) * fac[k - j] % mod * qpow(ll(k * K) * iL % mod, mod - 2 - (k - j)) % mod);\r\n\t}\r\n\tprintf(\"%d\\n\", ans);\r\n\treturn 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0486998273c507e5bd18cf727dfa8e80", "src_uid": "26d565c193a5920b042c783109496b4c", "difficulty": 3500.0}
    {"lang": "GNU C++17 (64)", "source_code": "//\u63a8\u5b8c\u5f0f\u5b50\u4e4b\u540e\u628a\u8fc7\u7a0b\u5220\u6389\u7684\u6211\u662f\u6c99\u96d5\u3002 \r\n\r\n//\u9898\u76ee\u7684\u968f\u673a\u65b9\u6cd5\u663e\u7136\u7b49\u4ef7\u4e8e\u521d\u59cb\u5df2\u7ecf\u5272\u4e86\u82e5\u5e72\u5200\uff0c\u7136\u540e\u6bcf\u6b21\u968f\u673a\u4e00\u4e2a\u4f4d\u7f6e\u518d\u5207\u3002\u8bbe $L$ \u4e3a\u603b\u957f\u5ea6\u3002\r\n//\r\n//\u5148\u8003\u8651 $n=1$ \u7684\u60c5\u51b5\u3002\u679a\u4e3e\u5207\u4e86 $j$ \u5200\u540e\u4ecd**\u672a\u5b8c\u6210**\uff0c\u7136\u540e\u5bb9\u65a5\u8fd8\u5269\u591a\u5c11\u6bb5\u6ca1\u5b8c\u6210\uff0c\u6709\u5f0f\u5b50\r\n//$$\r\n//\\sum_{j\\ge 0}\\sum_{i=1}^{L/k} (-1)^{i-1} (1-{ik\\over L})^j{j+1\\choose i}\\\\\r\n//=\\sum_{i=1}^{L/k} (-1)^{i-1} (1-{ik\\over L})^{i-1}({L\\over ik})^{i+1}\r\n//$$\r\n//\u7136\u540e\u8003\u8651\u600e\u4e48\u5904\u7406 $n\\ne 1$ \u3002\u81ea\u7136\u7684\u60f3\u6cd5\u662f\u628a\u8fd9\u4e9b\u5200\u5206\u914d\u7ed9\u6bcf\u4e00\u6bb5\uff0c\u90a3\u4e48\u5c31\u8981\u6c42\u51fa\u6bcf\u4e00\u6bb5\u5207\u4e86\u82e5\u5e72\u5200\u4e4b\u540e**\u5b8c\u6210**\u7684 EGF \u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c EGF \u91cc\u9762\u628a ${a_i\\over L}$ \u8fd9\u4e2a\u6982\u7387\u4e5f\u7b97\u8fdb\u53bb\u4e86\u3002\r\n//\r\n//\u8bbe $m=a_i$ \uff0c\u90a3\u4e48\u5217\u51fa\u5f0f\u5b50\r\n//$$\r\n//\\sum_i {1\\over i!}({m\\over L}x)^i\\sum_{j=0}^{m/k} (-1)^j {i+1\\choose j}(1-{jk\\over m})^i\r\n//$$\r\n//\u7136\u540e\u662f\u7e41\u7410\u7684\u8ba1\u7b97\uff0c\u6700\u7ec8\u7b97\u51fa\r\n//$$\r\n//\\sum_{j=0}^{m/k} (-1)^j\\frac{1}{j!}\\bigg(j((\\frac{m-jk}{L})x)^{j-1}\\exp{(\\frac{m-jk}{L}x)}+(\\frac{m-jk}{L})^{j}x^{j}\\exp{(\\frac{m-jk}{L}x)}\\bigg)\r\n//$$\r\n//\u7136\u540e\u8981\u628a\u8fd9\u4e9b\u591a\u9879\u5f0f\u5377\u5728\u4e00\u8d77\u3002$x$ \u7684\u6b21\u6570\u4e0d\u8d85\u8fc7 $L/k$ \uff0c\u800c $\\exp$ \u91cc\u9762\u7684\u4e1c\u897f\u53ea\u9700\u8981\u8bb0\u5f55 $\\sum j$ \uff0c\u4e5f\u662f $L/k$ \u7ea7\u522b\u3002\u5e76\u4e14\u6ce8\u610f\u5230 $\\exp$ \u4e2d\u7684 $j$ \u548c $x$ \u7684\u6b21\u6570\u5728\u5355\u4e2a EGF \u4e2d\u4e0d\u4f1a\u8d85\u8fc7 1 \uff0c\u6240\u4ee5\u6574\u4f53\u4e0d\u4f1a\u8d85\u8fc7 $n$ \u3002\u6240\u4ee5\u4e00\u5171\u53ea\u6709 $O(nL)$ \u9879\uff0c\u66b4\u529b\u5377\u79ef $O(nL^2)$ \uff0c\u7528 NTT \u4f18\u5316\u505a\u5230 $O(nL\\log L)$ \u3002", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d472d6bbdff84bec1a0309078a26bb47", "src_uid": "26d565c193a5920b042c783109496b4c", "difficulty": 3500.0}
    {"lang": "GNU C++20 (64)", "source_code": "#include\r\nnamespace imzzy{\r\n\t#define fi first\r\n\t#define se second\r\n\t#define rgi register int\r\n\t#define endl '\\n'\r\n\tusing std::cerr;\r\n\ttypedef long long ll;\r\n\ttypedef unsigned long long ull;\r\n\ttypedef unsigned int uint;\r\n\ttypedef std::pair pii;\r\n\tclass fastin{public:int _ch,_f;\r\n\ttemplateinline fastin&operator>>(_T&_x){_x=0;\r\n\twhile(!isdigit(_ch))_f|=(_ch=='-'),_ch=getchar();\r\n\twhile(isdigit(_ch))_x=_x*10+(_ch^'0'),_ch=getchar();\r\n\tif(_f)_f=0,_x=-_x;return *this;}fastin(){_ch=_f=0;}\r\n\t}fin;\r\n\tclass fastout{public:templateinline void write(_T _x){\r\n\tif(_x<0)putchar('-'),_x=-_x;if(_x>9)write(_x/10);putchar(_x%10+'0');}\r\n\tinline fastout&operator<<(char _c){return putchar(_c),*this;}\r\n\ttemplateinline fastout&operator<<(_T _x){return write(_x),*this;}\r\n\t}fout;\r\n\tstd::mt19937 rnd(std::chrono::system_clock::now().time_since_epoch().count());\r\n}using namespace imzzy;\r\n// -------------------------------\r\n// using namespace std;\r\n// #define int ll\r\nconst ll mod=998244353,G=3,iG=(mod+1)/G,i2=(mod+1)/2,inf=1e9+7;\r\nconst int maxn=2004,maxm=54;\r\ninline ll powmod(ll a,ll b=mod-2) {ll res=1; for(a%=mod;b;b>>=1,(a*=a)%=mod) if(b&1) (res*=a)%=mod; return res;}\r\nll fact[maxn],inv[maxn],invf[maxn];\r\n\r\nll dp[maxm][maxn][maxn];\r\n// dp[.][i][j]: coefficient of x^i e^(j/s)x\r\n// x^i e^jx * x^a e^bx = x^(i+a) e^(j+b)x\r\n// \\sum_{i=0}^{a/k}  (-1)^i/i!  [ ((a-ik)x/s)^i + i*((a-ik)x/s)^(i-1) ]  e^((a-ik)x/s)\r\n\r\nint n,k,a[maxm];\r\nll s,invs;\r\nsigned main() {\r\n\t// freopen(\"tmp.in\",\"r\",stdin);\r\n\t// freopen(\"tmp.out\",\"w\",stdout);\r\n\t// freopen(\"tmp.txt\",\"w\",stderr);\r\n\tinv[1]=fact[0]=invf[0]=1;\r\n\tfor(rgi i=2;i>n>>k;\r\n\tfor(rgi i=1;i<=n;++i) fin>>a[i],s+=a[i];\r\n\tstd::sort(a+1,a+1+n);\r\n\tinvs=inv[s],dp[0][0][0]=1;\r\n\tfor(rgi d=1;d<=n;++d) {\r\n\t\tfor(rgi i=0;i<=s;++i) for(rgi j=0;j<=s;++j) if(dp[d-1][i][j]) {\r\n\t\t\tfor(rgi p=0;p<=a[d]/k;++p) {\r\n\t\t\t\tint q=j+a[d]-p*k;\r\n\t\t\t\tll mul=dp[d-1][i][j]*((p&1)?(mod-1ll):1ll)%mod*invf[p]%mod;\r\n\t\t\t\t(dp[d][i+p][q]+=mul*powmod((a[d]-p*k)*invs,p))%=mod;\r\n\t\t\t\tif(p) (dp[d][i+p-1][q]+=mul*p%mod*powmod((a[d]-p*k)*invs,p-1))%=mod;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\t\r\n\tll ans=0,tmp;\r\n\tdp[n][0][0]=0;\r\n\tfor(rgi i=0;i<=s;++i) for(rgi j=0;j<=s;++j) if(dp[n][i][j]) {\r\n\t\ttmp=mod-dp[n][i][j];\r\n\t\t(ans+=tmp*fact[i]%mod*powmod(powmod(mod+1-j*invs%mod,i+1),mod-2))%=mod;\r\n\t}\r\n\tfout< File Name: CF1477F.cpp\r\n\t> Author: The-Out-Land\r\n\t> Mail: 2264454706@qq.com \r\n\t> Created Time: 2021\u5e7401\u670829\u65e5 \u661f\u671f\u4e94 19\u65f617\u520628\u79d2\r\n ************************************************************************/\r\n\r\n#include \r\n\r\n#define enter putchar('\\n')\r\n#define space putchar(' ')\r\n#define re register\r\n#define N 100100\r\n#define int long long\r\n#define vec vector\r\n#define pb push_back\r\n\r\nusing namespace std;\r\n\r\nconst int mod=998244353,G=3,iG=332748118;\r\n\r\ninline int max(int x,int y){return (x>y?x:y);}\r\n\r\ninline int min(int x,int y){return (x'9';c=getchar()) if(c=='-') y=0;\r\n\tfor(;c>='0' && c<='9';c=getchar()) x=(x<<1)+(x<<3)+c-48;\r\n\tif(y) return x;\r\n\treturn -x;\r\n}\r\n\r\nint r[N],fans;\r\n\r\ninline int add(int x){if(x<0) return x+mod;return (x>=mod?x-mod:x);}\r\ninline int Pow(int x,int y){if(!x) return 0;int ans=1;while(y){y=(y%(mod-1)+(mod-1))%(mod-1);if(y&1) ans=1ll*ans*x%mod;x=1ll*x*x%mod;y>>=1;} return ans;}\r\n\r\ninline void getR(int len){\r\n\tfor(re int i=1;i>1]>>1)|((i&1)?(len>>1):0);\r\n\treturn;\r\n}\r\n\r\ninline void ntt(int len,vec &a,int opt){\r\n\tfor(re int i=1;ii) swap(a[i],a[r[i]]);\r\n\tfor(re int i=1;i poly;\r\n\tint L1,L2;\r\n\tDPoly(vector &po):poly(po){\r\n\t\tL1=po.size()-1,L2=po[0].size()-1;\r\n\t\t//cerr<L1 && K2>L2);\r\n\t\tvec ret;\r\n\t\tret.resize(K1*K2+1,0);\r\n\t\tfor(re int i=0;i<=L1;++i)\r\n\t\t\tfor(re int j=0;j<=L2;++j)\r\n\t\t\tret[i*K2+j]=poly[i][j];\r\n\t\treturn ret;\r\n\t}\r\n\tfriend DPoly operator * (DPoly a,DPoly b){\r\n\t\tvector C;\r\n\t\tC.resize(a.L1+b.L1+1,vec(a.L2+b.L2+1,0));\r\n\t\tA=a.Get(a.L1+1,a.L2+b.L2+1),B=b.Get(b.L1+1,a.L2+b.L2+1),D=mul(A,B);\r\n\t\tfor(re int i=0;i<=a.L1+b.L1;++i)\r\n\t\t\tfor(re int j=0;j<=a.L2+b.L2;++j)\r\n\t\t\tC[i][j]=D[i*(a.L2+b.L2+1)+j];\r\n\t\t//cerr< p;\r\n\r\nint n,K,a[N],s,iS,jc[N],inv[N],in[N];\r\n\r\ninline void pre(){\r\n\tjc[0]=1;\r\n\tin[0]=0;in[1]=1;\r\n\tfor(re int i=2;i C;\r\n\tfor(re int i=1;i<=n;++i){\r\n\t\tA.clear();B.clear();\r\n\t\tA.pb(1),B.pb(0);\r\n\t\tfor(re int j=1;j<=a[i]/K;++j){\r\n\t\t\tA.pb(add(inv[j]*\tPow((a[i]-j*K)*iS%mod,j)%mod*(j&1?-1:1)));\r\n\t\t\tB.pb(add(inv[j-1]*\tPow((a[i]-j*K)*iS%mod,j-1)%mod*(j&1?-1:1)));\r\n\t\t}\r\n\t\tC.clear();\r\n\t\tC.pb(A);\r\n\t\tC.pb(B);\r\n\t\tp.pb(C);\r\n\t}\r\n\r\n\tfor(re int i=1;i<=n;i<<=1)\r\n\t\tfor(re int j=0;j+i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int N = 42;\n\n//based on the solution in https://codeforces.com/contest/1038/submission/42593040\nclass Solution {\npublic:\n\tlong long count(string& _s, int n) {\n\t\tlong long res = 0;\n\n\t\tmemset(dp, -1, sizeof(dp));\n\n\t\ts = _s;\n\t\tnextTable = buildNextTable(s);\n\n\t\tfor (int i = 0; i <= s.size(); ++i) {\n\t\t\tres += slove(n, i, i, 0);\n\t\t\t// cout << endl;\n\t\t}\n\n\t\treturn res;\n\t}\nprivate:\n\tlong long dp[N][N][N][2];\n\tstring s;\n\tvector nextTable;\n\n\tvector buildNextTable(string& s) {\n\t\tint n = s.length();\n\t\tvector res(n + 1, 0);\n\n\t\tfor (int i = 1, j = 0; i < n; ++i) {\n\t\t\twhile (j != 0 && s[j] != s[i]) {\n\t\t\t\tj = res[j - 1];\n\t\t\t}\n\t\t\tif (s[j] == s[i]) {\n\t\t\t\t++j;\n\t\t\t}\n\t\t\tres[i] = j;\n\t\t}\n\n\t\treturn res;\n\t}\n\n\n\tint getNext(int cur, char ch) {\n\t\tif (cur == s.length()) {\n\t\t\tcur = nextTable[s.length() - 1];\n\t\t}\n\n\t\twhile (cur != 0 && s[cur] != ch) {\n\t\t\tcur = nextTable[cur - 1];\n\t\t}\n\n\t\tif (s[cur] == ch) {\n\t\t\t++cur;\n\t\t}\n\t\treturn cur;\n\t}\n\n\tlong long slove(int n, int cur, int end, bool done) {\n\t\tif (cur == s.length()) {\n\t\t\tdone = true;\n\t\t}\n\n\t\tif (n == 0) {\n\t\t\t// cout << cur << \" \" << end << \" \" << (done ? \"Y\" : \"N\") << endl;\n\t\t\treturn done && (cur == end) ? 1 : 0;\n\t\t}\n\n\t\tlong long& res = dp[n][cur][end][done];\n\t\t// if (~res) {\n\t\tif (res >= 0) {\n\t\t\treturn res;\n\t\t}\n\t\tres = 0;\n\n\t\tfor (auto c : string(\"01\")) {\n\t\t\tint next = getNext(cur, c);\n\t\t\t// cout << \"next \" << next << \" \" << end << \" \" << \"|\" << n << \" \" << c << endl;\n\t\t\tres += slove(n - 1, next, end, done);\n\t\t}\n\t\treturn res;\n\t}\n};\n\n\nint main(int argc, char** argv) {\n\tios::sync_with_stdio(false);\n\tcin.tie(0);\n\n\tint n; \n\tcin >> n;\n\n\tstring s;\n\tcin >> s;\n\n\tSolution sol;\n\n\tcout << sol.count(s, n) << endl;\n\treturn 0;}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ff9f1092a79d5707b8859f094e11224c", "src_uid": "0034806908c9794086736a2d07fc654c", "difficulty": 2900.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint rank(char* s) {\n\tint i, j, lent = strlen(s);\n\tfor(i = 1; i < lent; i++) {\n\t\t// so sanh cac so\n\t\tfor(j = 0; j < lent; j++) {\n\t\t\tif(s[j] != s[(j+i)%lent])\n\t\t\t\tgoto cloop;\n\t\t}\n\t\tbreak;\n\tcloop:;\n\t}\n\treturn i;\n}\n\nint contain(char* s, char* s1) {\n\tint i, j, lent = strlen(s), lent1 = strlen(s1);\n\tfor(i = 0; i < lent; i++) {\n\t\t// so sanh cac so\n\t\tfor(j = 0; j < lent1; j++) {\n\t\t\tif(s1[j] != s[(j+i)%lent])\n\t\t\t\tgoto cloop;\n\t\t}\n\t\treturn 1;\n\t\tcloop:;\n\t}\n\treturn 0;\n}\n\nvoid intToBinStr(uint64_t k, int n, char* s) {\n\tint i, j = 1;\n\tfor(i = 0; i < n; i++, j <<= 1) {\n\t\ts[n-i-1] = (k & j) > 0 ? '1' : '0';\n\t}\n\ts[n] = '\\0';\n}\n\nint rank1(char* s, int n) {\n\tuint64_t max = 1L << n, i, rank = 0;\n\tchar s1[41];\n\tfor(i = 0; i < max; i++) {\n\t\tintToBinStr(i, n, s1);\n//\t\tprintf(\"s=%s str=%s contain=%d\\n\", s, s1, contain(s1, s));\n\t\tif(contain(s1, s))\n\t\t\trank++;\n\t}\n\treturn rank;\n}\n\nint main() {\n\tint n;\n\tchar s[41];\n\tcin >> n >> s;\n\tcout << rank1(s, n);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a600a358551206d8aad9b2dbb6855b5b", "src_uid": "0034806908c9794086736a2d07fc654c", "difficulty": 2900.0}
    {"lang": "GNU C++17", "source_code": "#include\n#define N ((int)(45))\n\nusing namespace std;\n\nint prefx[N];\nvoid prefix_func(char s[]){\nprefx[0] = -1;\nint now;\nfor(int i = 1; s[i]!=\u2019\\0\u2032; i++){\nnow = prefx[i-1];\nwhile(now!=-1 && s[i]!=s[now+1]) now = prefx[now];\nif(s[i]==s[now+1]) prefx[i] = now+1;\nelse prefx[i] = -1;\n}\n}\n\nint node[N*N][3], level[N*N];\nlong long int mask[N*N];\nvoid init(int n){ /// creating new node in trie\nfor(int i = 0; i<2; i++) node[n][i] = -1;\nmask[n] = 0;\n}\nint Insert(char s[], int tot, int i){ /// inserting a string in trie\nint cur = 0;\nint j = i;\nfor(; s[i]!=\u2019\\0\u2032; i++){\nif(node[cur][s[i]-\u20180\u2019]==-1){\ninit(tot);\nnode[cur][s[i]-\u20180\u2019] = tot++;\n}\ncur = node[cur][s[i]-\u20180\u2032];\n}\nmask[cur] = 1ll<\nusing namespace std;\n//#define int long long\n#define fast ios_base::sync_with_stdio(false)\ntypedef long long ll;\ntypedef long double ld;\nconst int mod = 1e9 + 7;\n#define x first\n#define y second\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n//#define int long long\nconst int N = 41;\nvector kmp;\nstring s;\n//int n;\nvoid prefix_function(){\n    for(int i = 1; i < (int)s.size(); ++i){\n        int j = kmp[i - 1];\n        while(j > 0 && s[j] != s[i]){\n            j = kmp[j - 1];\n        }\n        if(s[j] == s[i]) j++;\n        kmp[i] = j;\n    }\n}\nint memGo[N][2];\nint goKmp(int st, char c){\n    auto & cur = memGo[st][c - '0'];\n    if(cur != -1) return cur;\n    if(st == (int)s.size()) st = kmp[st - 1];\n    if(st > 0 && s[st] != c){\n        st = kmp[st - 1];\n    }\n    if(s[st] == c){\n        return ans = st + 1;\n    }\n    return goKmp(st, c);\n}\nll dp[N][N][N][2];\nll fnd(int len, int v, int en, int good){\n    ll & ans = dp[len][v][en][good];\n    if(ans != -1){\n        return ans;\n    }\n    if(v == (int)s.size()) good = true;\n    if(len == 0){\n        ans = ((v == en) and good);\n        return ans;\n    }\n    ans = 0;\n    for(int i = 0; i < 2; ++i){\n        ans += fnd(len - 1, goKmp(v, i + '0'), en, good);\n\n    }\n    return ans;\n}\nint n;\nint main(){\n    fast;\n    cin >> n >> s;\n    kmp.resize((int)s.size());\n    prefix_function();\n    memset(memGo, -1, sizeof(memGo));\n    memset(dp, -1, sizeof(dp));\n    ll ans = 0;\n    for(int i = 0; i <= (int)s.size(); ++i){\n        ans += fnd(n, i, i, 0);\n    }\n    cout << ans << endl;\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ff6797579f536bbbf214e17c6433c20a", "src_uid": "0034806908c9794086736a2d07fc654c", "difficulty": 2900.0}
    {"lang": "GNU C++17 (64)", "source_code": "#pragma comment(linker, \"/STACK:512000000\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define all(a) a.begin(), a.end()\nusing li = long long;\nusing ld = long double;\nvoid solve(bool);\nvoid precalc();\nclock_t start;\nint main() {\n#ifdef AIM\n    freopen(\"/Users/alexandero/CLionProjects/cryptozoology/input.txt\", \"r\", stdin);\n  //freopen(\"/Users/alexandero/CLionProjects/cryptozoology/output.txt\", \"w\", stdout);\n#endif\n    start = clock();\n    int t = 1;\n#ifndef AIM\n    cout.sync_with_stdio(0);\n    cin.tie(0);\n#endif\n    cout.precision(20);\n    cout << fixed;\n    //cin >> t;\n    precalc();\n    int test_num = 1;\n    while (t--) {\n      //cout << \"Case #\" << test_num++ << \": \";\n      solve(true);\n    }\n    cout.flush();\n\n#ifdef AIM1\n    while (true) {\n    solve(false);\n  }\n#endif\n\n#ifdef AIM\n    cerr << \"\\n\\n time: \" << (clock() - start) / 1.0 / CLOCKS_PER_SEC << \"\\n\\n\";\n#endif\n    return 0;\n}\n\n//BE CAREFUL: IS INT REALLY INT?\n\ntemplate\nT binpow(T q, T w, T mod) {\n    if (!w)\n        return 1 % mod;\n    if (w & 1)\n        return q * 1LL * binpow(q, w - 1, mod) % mod;\n    return binpow(q * 1LL * q % mod, w / 2, mod);\n}\n\ntemplate\nT gcd(T q, T w) {\n    while (w) {\n        q %= w;\n        swap(q, w);\n    }\n    return q;\n}\ntemplate\nT lcm(T q, T w) {\n    return q / gcd(q, w) * w;\n}\n\ntemplate \nvoid make_unique(vector& vec) {\n    sort(all(vec));\n    vec.erase(unique(all(vec)), vec.end());\n}\n\ntemplate\nvoid relax_min(T& cur, T val) {\n    cur = min(cur, val);\n}\n\ntemplate\nvoid relax_max(T& cur, T val) {\n    cur = max(cur, val);\n}\n\nmt19937 rng((unsigned long long)chrono::steady_clock::now().time_since_epoch().count());\n\nvoid precalc() {\n\n}\n\n//#define int li\n//const li mod = 1000000007;\n//const int mod = 998244353;\n//using ull = unsigned long long;\n\nstring s;\nvector> pref_sums;\nvector> poses;\nvector, int>> dp;\n\npair get_jump(int pos, int l, int r) {\n  int mid = (l + r) / 2;\n  int last = s[pos] - '0';\n  int need = (last == 0 ? mid - l : r - mid);\n  int bigger = upper_bound(all(poses[last]), pos) - poses[last].begin();\n  if (bigger < need) {\n    return {-1, -1};\n  }\n  int candy = poses[last][bigger - need];\n  int opposite_count = pref_sums[pos][last ^ 1] - pref_sums[candy][last ^ 1];\n  int max_opposite_count = r - l - need;\n  if (opposite_count >= max_opposite_count) {\n    return {-1, -1};\n  }\n  int min_candy = max(candy - (max_opposite_count - opposite_count + 1),\n      (bigger > need ? poses[last][bigger - need - 1] + 1 : 0));\n  //cout << \"jump pos: \" << pos << \" l: \" << l << \" r: \" << r << \" candy: \" << candy << endl;\n  return {min_candy, candy};\n}\n\nint get_pos(int pos, int l, int r) {\n  if (r - l <= 1) {\n    return pos;\n  }\n  if (pos == -1) {\n    return -2;\n  }\n  if (dp[pos].contains({l, r})) {\n    return dp[pos][{l, r}];\n  }\n  auto possible = get_jump(pos, l, r);\n  if (possible.first == -1) {\n    return dp[pos][{l, r}] = -2;\n  }\n\n  //cout << pos << \" \" << l << \" \" << r << \" \" << possible.first << \" \" << possible.second << endl;\n  int mid = (l + r) / 2;\n  for (int div = possible.first; div <= possible.second; ++div) {\n    int new_pos = get_pos(div - 1, mid, r);\n    if (new_pos == -2) {\n      continue;\n    }\n    //cout << \"new_pos: \" << new_pos << \" l: \" << l << \" mid: \" << mid << endl;\n    new_pos = get_pos(new_pos, l, mid);\n    if (new_pos != -2) {\n      //cout << \"found pos: \" << pos << \" l: \" << l << \" r: \" << r << endl;\n      return dp[pos][{l, r}] = new_pos;\n    }\n  }\n  //cout << \"failed pos: \" << pos << \" l: \" << l << \" r: \" << r << endl;\n  return -2;\n}\n\nvector> g;\n\nvoid my_merge_sort(vector& perm, int l, int r, int& pos) {\n  if (r - l <= 1) {\n    return;\n  }\n  int m = (l + r) / 2;\n  my_merge_sort(perm, l, m, pos);\n  my_merge_sort(perm, m, r, pos);\n  int i = l, j = m;\n  vector b;\n  while (i < m && j < r) {\n    if (s[pos++] == '0') {\n      g[perm[i]].push_back(perm[j]);\n      b.push_back(perm[i]);\n      ++i;\n    } else {\n      g[perm[j]].push_back(perm[i]);\n      b.push_back(perm[j]);\n      ++j;\n    }\n  }\n  while (i < m) {\n    b.push_back(perm[i++]);\n  }\n  while (j < r) {\n    b.push_back(perm[j++]);\n  }\n  for (int w = 0; w < b.size(); ++w) {\n    perm[l + w] = b[w];\n  }\n}\n\nvoid solve(__attribute__((unused)) bool read) {\n  cin >> s;\n  poses.resize(2);\n  pref_sums.assign(s.length() + 1, vector(2, 0));\n  for (int i = 0; i < s.length(); ++i) {\n    poses[s[i] - '0'].push_back(i);\n    pref_sums[i + 1] = pref_sums[i];\n    ++pref_sums[i + 1][s[i] - '0'];\n  }\n  vector suf_count(2, 0);\n  int last = s.back() - '0';\n  dp.resize(s.length() + 1);\n  for (int i = (int)s.length() - 1; i >= 0; --i) {\n    ++suf_count[s[i] - '0'];\n    for (int h = 0; h < 2; ++h) {\n      int n = suf_count[last] * 2 + (last == 0 ? h : -h);\n      if (n - suf_count[last] > suf_count[last ^ 1]) {\n        auto fin = get_pos((int)s.length() - 1, 0, n);\n        if (fin == -1) {\n          g.clear();\n          g.resize(n);\n          vector perm(n);\n          iota(all(perm), 0);\n          int st = 0;\n          my_merge_sort(perm, 0, n, st);\n          vector deg(n, 0);\n          for (int v = 0; v < n; ++v) {\n            for (int to : g[v]) {\n              ++deg[to];\n            }\n          }\n          queue q;\n          for (int v = 0; v < n; ++v) {\n            if (deg[v] == 0) {\n              q.push(v);\n            }\n          }\n          vector res(n, -1);\n          int cnt = 0;\n          while (!q.empty()) {\n            int v = q.front();\n            q.pop();\n            res[v] = cnt++;\n            for (int to : g[v]) {\n              --deg[to];\n              if (deg[to] == 0) {\n                q.push(to);\n              }\n            }\n          }\n          cout << n << \"\\n\";\n          for (int x : res) {\n            cout << x + 1 << \" \";\n          }\n          cout << endl;\n          return;\n        }\n      }\n    }\n  }\n  assert(false);\n\n}\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b366020aea9cd517a0012185a9db88d4", "src_uid": "b2ee84d23d73947fa84faaaebfde85c8", "difficulty": -1.0}
    {"lang": "GNU C++17", "source_code": "//\r\n//  main.cpp\r\n//  E\r\n//\r\n//  Created by \u0425\u0430\u0439\u043a\u043e\u0432\u0430 \u0421\u0432\u0435\u0442\u043b\u0430\u043d\u0430 on 30.05.2021.\r\n//\r\n\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n\r\n#define pb push_back\r\n#define eb emplace_back\r\n#define mp make_pair\r\n#define all(a) a.begin(), a.end()\r\n#define frn(i, n) for (int i = 0; i < (int)(n); i++)\r\n#define frd(i, n) for (int i = (int)(n - 1); i >= 0; i--)\r\n#define frs(it, n) for(auto it = n.begin(); it != n.end(); it++)\r\n#define frab(i, a, b) for(int i = a; i < b; i++)\r\n\r\n\r\ntypedef long long ll;\r\ntypedef long double ld;\r\ntypedef unsigned long long ull;\r\n\r\nconst ll LINF = 1e18;\r\nconst int INF = 1e9;\r\nconst int M = 1e9 + 7;\r\nconst double EPS = 1e-9;\r\n\r\nusing namespace std;\r\n\r\nvector> a;\r\nstring s;\r\nvector> b;\r\nint n;\r\nint size = 0;\r\nint logSize = 0;\r\n\r\nvoid mergeSort(int l, int r) {\r\n    if (logSize >= s.size()) {\r\n        return;\r\n    }\r\n    if (r - l <= 1) {\r\n        size = max(size, l + 1);\r\n        a[l].second = 0;\r\n        return;\r\n    }\r\n    \r\n    int m = (l + r) >> 1;\r\n    mergeSort(l, m);\r\n    if (logSize >= s.size()) {\r\n        return;\r\n    }\r\n    mergeSort(m, r);\r\n    \r\n    int i = l, j = m, k = l;\r\n    while (i < m && j < r) {\r\n        if (logSize >= s.size()) {\r\n            throw;\r\n        }\r\n        if (s[logSize] == '0') { // a[i] < a[j]\r\n            if (a[i].second >= a[j].second) {\r\n                int delta = a[i].second - a[j].second + 1;\r\n                frab (it, j, r) {\r\n                    a[it].second += delta;\r\n                }\r\n            }\r\n            b[k] = a[i];\r\n            i++;\r\n        } else { // a[i] >= a[j]\r\n            if (a[i].second <= a[j].second) {\r\n                int delta = a[j].second - a[i].second + 1;\r\n                frab (it, i, m) {\r\n                    a[it].second += delta;\r\n                }\r\n            }\r\n            b[k] = a[j];\r\n            j++;\r\n        }\r\n        logSize++;\r\n        k++;\r\n    }\r\n    \r\n    while (i < m) {\r\n        b[k] = a[i];\r\n        i++;\r\n        k++;\r\n    }\r\n    while (j < r) {\r\n        b[k] = a[j];\r\n        j++;\r\n        k++;\r\n    }\r\n    frab (p, l, r) {\r\n        a[p] = b[p];\r\n    }\r\n    return;\r\n}\r\n\r\nint main(int argc, const char * argv[])\r\n{\r\n    std::ios_base::sync_with_stdio(0);\r\n    //    freopen(\"ain\", \"r\", stdin);\r\n    //    freopen(\"aout\", \"w\", stdout);\r\n    \r\n//    string s;\r\n    cin >> s;\r\n    \r\n    n = pow(2, 16);\r\n//    a = {13, 6, 1, 7, 12, 5, 4, 15, 14, 16, 10, 11, 3, 8, 9, 2};\r\n    a.resize(n);\r\n    b.resize(n);\r\n    \r\n    frn (i, n) {\r\n        a[i] = mp(i, -1);\r\n    }\r\n    \r\n    mergeSort(0, n);\r\n    \r\n    vector ans(size);\r\n    frn (i, size) {\r\n        if (a[i].second != -1) {\r\n            ans[a[i].first] = a[i].second;\r\n        }\r\n    }\r\n    cout << size << '\\n';\r\n    frn (i, size) {\r\n        cout << ans[i] + 1 << ' ';\r\n    }\r\n    return 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bf3999b81c067ef95ade427bdf575c17", "src_uid": "b2ee84d23d73947fa84faaaebfde85c8", "difficulty": -1.0}
    {"lang": "GNU C++17", "source_code": "101011010001100100011011001111011000011110010\n00000000000000000000000000000000\n11111111111111111111111111111111\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "89cca74fadcd566702b86c8621c8e3b1", "src_uid": "b2ee84d23d73947fa84faaaebfde85c8", "difficulty": -1.0}
    {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define fi first\n#define se second\n#define ll long long\n#define int long long\n#define ld double\n#define mp make_pair\nusing namespace std;\nconst int inf = 1e9;\nconst int N = 3e5 + 13;\nvector e[N];\n\n\nvoid merge_sort(string& log, vector& a, int l, int r) {\n    if (r - l <= 1)\n        return;\n    int m = (l + r) / 2;\n    merge_sort(log, a, l, m);\n    merge_sort(log, a, m, r);\n    int i = l, j = m, k = l;\n    vector b(a.size());\n    while (i < m && j < r) {\n        if (a[i] < a[j]) {\n            log += \"0\";\n            b[k] = a[i];\n            i += 1;\n        } else {\n            log += \"1\";\n            b[k] = a[j];\n            j += 1;\n        }\n        k += 1;\n    }\n    while (i < m) {\n        b[k] = a[i];\n        i += 1;\n        k += 1;\n    }\n    while (j < r) {\n        b[k] = a[j];\n        j += 1;\n        k += 1;\n    }\n    for (int p = l; p < r; ++p)\n        a[p] = b[p];\n}\n\nbool good = 1;\n\n\nvoid merge_sort1(string& log, vector& a, int l, int r, int& top) {\n    if (r - l <= 1)\n        return;\n    int m = (l + r) / 2;\n    merge_sort1(log, a, l, m, top);\n    merge_sort1(log, a, m, r, top);\n    int i = l, j = m, k = l;\n    vector b(a.size());\n    while (i < m && j < r) {\n        if (top == log.size()) {\n            good = 0;\n            return;\n        }\n        if (log[top++] == '0') {\n            b[k] = a[i];\n            i += 1;\n        } else {\n            b[k] = a[j];\n            j += 1;\n        }\n        k += 1;\n    }\n    while (i < m) {\n        b[k] = a[i];\n        i += 1;\n        k += 1;\n    }\n    while (j < r) {\n        b[k] = a[j];\n        j += 1;\n        k += 1;\n    }\n    for (int p = l; p < r; ++p)\n        a[p] = b[p];\n}\n\nstring sort(vector a) {\n\n    int n = a.size();\n    string log;\n    merge_sort(log, a, 0, n);\n    return log;\n}\n\nvoid solve() {\n    int n, k,a, b;\n    string s;\n    cin >> s;\n    for (int n = 16; n <= 1000; ++n) {\n        int top = 0;\n        vector v(n);\n        for (int i = 0; i < n; ++i)\n            v[i] = i;\n        merge_sort1(s, v, 0, v.size(), top);\n        if (1) {\n            vector p(n);\n            for (int i = 0; i < n; ++i)\n                p[v[i]] = i;\n            cout << n << endl;\n            for (auto x : p)\n                cout << x + 1 << ' ';\n            return 0;\n        }\n        exit(1);\n    }\n}\n\n\n\nsigned main() {\n#ifdef LOCAL\n    freopen(\"input.txt\", \"r\", stdin);\n#endif // local\n    solve();\n\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "085b6f6a615abc01d581719b8d8b1301", "src_uid": "b2ee84d23d73947fa84faaaebfde85c8", "difficulty": -1.0}
    {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nlong long jsq,d;\nstring s; \nint main()\n{\n    cin>>s;\n    d=s.size();\n    for(int i=0;i\n#include\nusing namespace std;\nint main()\n{\n\tiunt sum=0;\n\tstring s;\n\tcin>>s;\n\tfor(int i=0;i<7;i++)\n\t{\n\t\tif(s[i]=='A')\n\t\t\tsum+=10;\n\t\telse\n\t\t\tsum+=s[i]-48;\n\t}\n\tcout<\n#include \nusing namespace std;\nchar name[10005];\nint main(){\n    scanf(\"%s\",name);\n    int len=strlen(name);\n    long long ans=0;\n    for (int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define ll long long\n#define ld long double\n#define fr first\n#define ps push_back\n#define sc second\n#define r_0; return 0;\n#define fin freopen( \"input.txt \", \"r\", stdin );\n#define fout freopen( \"output.txt\", \"w\", stdout );\n#define TIME ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n\nusing namespace std ;\n\nconst ll mod = 1e9 + 7 ;\nconst ll N = 1e6 + 5;\nstring s, s1, s2 ;\nchar q;\nvectorv, ans ;\nmapmp;\nint n, m, cnt, a, a1,b,b1, k,T,y, x, t, mn= mod, mx = mod,z ;\n\nmain ()\n{\n      cin>> s ;\n\n    if ( s != \"A221033\")\n    cout << s [ 1 ] << s [ 2 ] ;\n    else\n    cout << 21 ;\n}\n656F", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2f7b1ff3c31a9df3261f98c2cb753b09", "src_uid": "47287f8bc61fec72d729638d5e0e67f5", "difficulty": 1900.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef long long lld;\n\nint N,mom[9],ans=1e9;\nlld A[9],mul[9];\nvector  child[9];\n\nvoid dfs(int n)\n{\n\tint i;\n\tif (n == N+1){\n\t\t// calculate\n\t\tint cnt=0,m,me=N;\n\t\tfor (i=1;i<=N;i++) if (!mom[i]) cnt++;\n\t\tif (cnt > 1) me++;\n\t\tfor (i=1;i<=N;i++){\n\t\t\tlld n=A[i]/mul[i];\n\t\t\twhile (n%2 == 0) n /= 2, me++;\n\t\t\tfor (m=3;m*m<=n;m+=2){\n\t\t\t\twhile (n%m == 0) n /= m, me++;\n\t\t\t}\n\t\t\tif (n > 1 && n != A[i]/mul[i]) me++;\n\t\t}\n\t\tif (ans > me) ans = me;\n\t\treturn;\n\t}\n\tdfs(n+1);\n\tfor (i=1;i> N;\n\tfor (i=1;i<=N;i++) cin >> A[i];\n\tsort(A+1,A+N+1,greater());\n\tfor (i=1;i<=N;i++) mul[i] = 1;\n\tdfs(2);\n\tprintf(\"%d\\n\",ans);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0d0259acb9f552228595c75be1ca28fa", "src_uid": "52b8b6c68518d5129272b8c56e5b7662", "difficulty": 2200.0}
    {"lang": "GNU C++", "source_code": "#pragma comment(linker, \"/STACK:1024000000,1024000000\")\n/*popular*/\n\t#define rep(i,n) for(int i=0;i<(n);i++)\n\t#define repp(i,nn,n) for(int i=(nn);i<=(n);i++)\n\t#define REP(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)\n\n#include\n\t#define MS0(x) memset(x,0,sizeof(x))\n\t\t\n#include\n\t#define SI(x) scanf(\"%d\",&x);\n\t#define SII(x,y) scanf(\"%d%d\",&x,&y);\n\t#define SIII(x,y,z) scanf(\"%d%d%d\",&x,&y,&z);\n\t#define ISI(x) int x;scanf(\"%d\",&x);\n\t#define ISII(x,y) int x,y;scanf(\"%d%d\",&x,&y);\n\t#define ISIII(x,y,z) int x,y,z;scanf(\"%d%d%d\",&x,&y,&z);\n\t\n#include\n\t#define D(x) cout<\n\t//iterator\n\t#define PB push_back\n\t#define ALL(x) (x).begin(),(x).end()\n\t//PAIR\t\n\t#define MP make_pair\n\t#define X first\n\t#define Y second\n#include\n#include\nusing namespace std;\ntypedef long long LL;\ntypedef vector VI;\ntypedef pair PII;\nconst int mod=(int)1e9+7;\n/*\n\tAuthor:hehao\n\ttime:\n\tATTENTION:\n\t\t\u7b2c\u4e00\u4ef6\u4e8b \u4fdd\u5b58\u5230\u6b63\u786e\u7684\u7a0b\u5e8f\u540d please do it first\n\t\t\u7b2c\u4e8c\u4ef6\u4e8b \u5199\u4ee3\u7801\n\t\t\u7b2c\u4e09\u4ef6\u4e8b \u9759\u6001\u68c0\u67e5 \u6570\u7ec4\u5927\u5c0f \u53d8\u91cf\u5927\u5c0f do not for get this step\n\t\t\u7b2c\u56db\u4ef6\u4e8b \u7f16\u8bd1\u6d4b\u8bd5  \n*/\n#define N 111111\nint n,m,k;\nint p[100000],pnt=0;\nmap g[8],G[8];\nvector f[8];\nint w[8],a[8];\nint ans,Ans,mm;\nvoid Do(int u){\n\tif(u==n){Ans=min(Ans,ans+(mm1)ans+=1;\n\t//\n\tans+=w[u];Do(u+1);ans-=w[u];\n\t//\n\trepp(v,u+1,n-1){\n\t\tbool ok=1;\n\t\tREP(y,f[u])\n\t\t\tif(G[u][*y]>g[v][*y]) {ok=0;break;}\n\t\tif(!ok)continue;\n\t\tREP(y,f[u])\n\t\t\tg[v][*y]-=G[u][*y];\n\t\tmm++;\t\t\t\n\t\tDo(u+1);\t\n\t\tREP(y,f[u])\n\t\t\tg[v][*y]+=G[u][*y];\n\t\tmm--;\n\t}\n\tif(w[u]>1)ans-=1;\n}\nvoid In(){\n\trep(i,1000000)if(i>1){\n\t\tp[pnt++]=i;\n\t\tfor(int j=2;j*j<=i;j++)\n\t\tif(i%j==0){pnt--;break;}\n\t}\n\tSI(n);\n\trep(i,n)SI(a[i]);\n\tsort(a,a+n);\n\trep(i,n){\n\t\tint x=a[i];\n\t\t\trep(j,pnt)if(x>1){\n\t\t\t\tif(x%p[j]==0)f[i].PB(p[j]);\n\t\t\t\twhile(x%p[j]==0){\n\t\t\t\t\tx/=p[j];\n\t\t\t\t\tg[i][p[j]]++;G[i][p[j]]++;\n\t\t\t\t\tw[i]++;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\tif(x>1)g[i][x]=1,f[i].PB(x);\n\t}\n}\nint main(){\n\t//freopen(\"in.txt\",\"r\",stdin);\n\tIn();\n\tmm=ans=0,Ans=mod;Do(0);\n\tcout<\n#include\n#include\n#include\n#include\nusing namespace std;\n\n#define maxm 1000600\n#define ii __int64\n#define maxn 10\n#define maxnn (1<<9)\n#define inf (1<<29)\n\nint on(int n,int k){\n    return (n|(1<=n){\n        for(i=0;i1){\n        ret++;\n    }\n\n    return ret;\n\n}\n\nvoid take(int n){\n\n    prime[c++]=2;\n\n    for(int i=3;i<=n;i++){\n        if(!p[i]) prime[c++]=i;\n    }\n    tot=c;\n}\n\nvoid gen(int n){\n\n    int i,j,k,l,sq;\n\n    p[0]=p[1]=1;\n\n    sq=sqrt(n);\n\n    for(i=4;i<=n;i+=2) p[i]=1;\n\n    for(i=3;i<=sq;i+=2){\n        if(p[i]) continue;\n        for(j=i*i;j<=n;j+=(2*i)){\n            p[j]=1;\n        }\n    }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6dc8e989388041963a6731bdae6f5041", "src_uid": "52b8b6c68518d5129272b8c56e5b7662", "difficulty": 2200.0}
    {"lang": "GNU C++", "source_code": "#include\n#include\n\nlong long a[10];\nlong long v[10];\nlong long w[10];\nlong long n;\n\nlong long dfs(long long x)\n{\n\tlong long j;\n\tlong long i,k,l,r;\n    if(x==n)\n\t{\n\t\tr=0;\n\t\tfor(i=0;i1&&(l||v[i]))r++;\n\t\t}\n\t\tj=0;\n\t\tfor(i=0;i1);\n\t}\n\tr=2e9;\n\tfor(i=0;i1||v[i]))\n\t{\n\t\tv[i]++;\n\t\tw[x]=1;\n\t\ta[i]/=a[x];\n\t\tj=dfs(x+1);\n\t\tif(j  \ntypedef long long ll;  \nusing namespace std;\n\nll f,t,t0,a1,t1,p1,a2,t2,p2;  \n    ll tt,ff,L,R,d,res;\n\nbool check (ll d )  {\n\tll j;\n\tfor(ll i=0;a1*itt && ff*t0>tt)  // Phan dung luong con lai, Neu 2 goi kia deu khong co kha nang tai kip gio\n        continue;                 // thi tiep tuc mua goi 1\n        if(t0<=t2 || ff*t0<=tt) j=0;  // Neu goi thuong tai kip gio hoac no tai nhanh hon goi 2 thi khong mua goi 2\n        else {\t\t\t\t\t\t\t// nguoc lai, tinh j la so goi 2 can mua:\n\t\t    \n\t\t    j = (ff*t0 - tt)/(a2*(t0-t2));\n\t\t    if ((j*a2*t2 + (ff-j*a2)*t0)>tt)j++;\n\t\t}  \t\t\t\t\t\t\t\t\t\t\t\t\n                                                      // so byte tai bang goi 2 la j*a2\n                                                      // so byte tai bang goi thuong la (ff-j*a2)\n                                                      // thoi gian tai bang goi 2 la: j*a2*t2\n                                                      // thoi gian tai bang goi thuong la: (ff-j*a2)*t0\n\t\t\t\t\t\t\t\t\t\t\t\t\t  // ta phai co: j*a2*t2 + (ff-j*a2)*t0 <= tt\n\t\t\t\t\t\t\t\t\t\t\t\t\t  // hay ff*to - tt <= j*a2*(t0-t2)\n\t\t\t\t\t\t\t\t\t\t\t\t\t  // j >= (ff*t0 - tt)/(a2*(t0-t2))\n       // if(p1*i+p2*j<=d) return true ;  \n    }\n\treturn ((p1*i+p2*j)<=d);\n\t//return false;\n\t}\n  \nint main()  \n{  \n      \n    \n\tcin>>f>>t>>t0>>a1>>t1>>p1>>a2>>t2>>p2;  \n    if(t1>t2)  \n        swap(t1,t2),swap(a1,a2),swap(p1,p2);  // ngam dinh goi cuoc co toc do tai nhanh la goi bo sung 1\n  \n    L = 0;\n\tR = 1e18;\n\twhile (L\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include \n#include\n#include \n#include \n#include \n#include \n\n#define UI unsigned LL\n#define LL long long\n#define GT(it,v) for(auto it:v)\n#define FU(i,a,b) for(LL i=(a);i<(b);i++)\n#define FD(i,a,b) for(LL i=(a);i>(b);i--)\n#define LD long double\n#define PI 3.1415926535897932384626\n#define PII pair\n#define PLL pair\n#define VLL vector\n#define VVLL vector >\n#define VVVLL vector >\n#define VPLL vector>\n#define VVPLL vector>>\n#define VD vector\n#define VVD vector >\n#define VPD vector >\n#define MP make_pair\n#define PB push_back\n#define FI first\n#define SE second\n#define SORT(v) sort(v.begin(),v.end())\n#define GSORT(v,what) sort(v.begin(),v.end(),greater)\n#define UNIQUE(it,v) (it = unique(v.begin(),v.end()), v.resize(distance(v.begin(),it)))\nusing namespace std; LL inp, Inp; LL i1, i2, i3, i4, i5, i6, i7, i8;\nLL MOD = 998244353, MOD1 = (LL)1e9 + 7, MOD2 = (LL)1e9 + 9; long long MOD3 = (long long)1e9 + 21 /*33*/;  double eps = 1e-9;\nLL TMP = (chrono::high_resolution_clock::now().time_since_epoch().count() % MOD + MOD) % MOD;\nauto STTMP = chrono::steady_clock::now();//auto ENTMP = chrono::steady_clock::now();\n//ELTIME = double(chrono::duration_cast(ENTMP - STTMP).count());\n//time_t result = time(NULL); char SS[26]; ctime_s(SS, sizeof SS, &result);\n//transform(SS, SS + 26, SS, [](char ch) {return ch == ' ' ? '_' : ch; }); prLLf(\"%s\", SS);\n\n\nint main() {\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n\tcout.precision(20);\n\tsrand((unsigned LL)TMP);\n\tLL F;//bytes needed\n\tLL T;//time\n\tLL t0;//time for one byte with standard\n\tcin >> F >> T >> t0;\n\tLL a1;//maximum amount of bytes\n\tLL t1;//time for one byte\n\tLL p1;//package price\n\tcin >> a1 >> t1 >> p1;\n\tLL a2, t2, p2; cin >> a2 >> t2 >> p2;\n\tLL res = 1e18;\n\tLL aam = 0;\n\tLL cost = 0;\n\twhile (F*t0 > T && F>0) {\n\t\taam++;\n\t\tcost += p1;\n\t\tT -= a1 * t1;\n\t\tF -= a1;\n\t}\n\tif ((T >= 0 && F*t0 <= T) || (T<0 && aam>0 && (abs(T) + t1 - 1) / t1 0) {\n\t\taam--;\n\t\tcost -= p1;\n\t\tT += a1 * t1;\n\t\tF += a1;\n\t\twhile (F*t0 > T && F>0) {\n\t\t\tbam++;\n\t\t\tcost += p2;\n\t\t\tT -= a2 * t2;\n\t\t\tF -= a2;\n\t\t}\n\t\tif ((T >= 0 && F*t0 <= T) || (T < 0 && aam>0 && ((abs(T) + t1 - 1) / t1 < a1) && (abs(T) + t1 - 1) / t1 <= abs(F) && F<0) || (T < 0 && bam>0 && (abs(T) + t2 - 1) / t2 < a2 && (abs(T) + t2 - 1) / t2 <= abs(F) && F<0)) {\n\t\t\tres = min(res, cost);\n\t\t}\n\t}\n\n\n\tswap(a1, a2); swap(t1, t2); swap(p1, p2);\n\n\tLL aam = 0;\n\tLL cost = 0;\n\twhile (F*t0 > T && F > 0) {\n\t\taam++;\n\t\tcost += p1;\n\t\tT -= a1 * t1;\n\t\tF -= a1;\n\t}\n\tif ((T >= 0 && F*t0 <= T) || (T < 0 && aam>0 && (abs(T) + t1 - 1) / t1 < a1) && (abs(T) + t1 - 1) / t1 <= abs(F) && F < 0) {\n\t\tres = min(res, cost);\n\t}\n\tLL bam = 0;\n\twhile (aam > 0) {\n\t\taam--;\n\t\tcost -= p1;\n\t\tT += a1 * t1;\n\t\tF += a1;\n\t\twhile (F*t0 > T && F > 0) {\n\t\t\tbam++;\n\t\t\tcost += p2;\n\t\t\tT -= a2 * t2;\n\t\t\tF -= a2;\n\t\t}\n\t\tif ((T >= 0 && F*t0 <= T) || (T < 0 && aam>0 && ((abs(T) + t1 - 1) / t1 < a1) && (abs(T) + t1 - 1) / t1 <= abs(F) && F < 0) || (T < 0 && bam>0 && (abs(T) + t2 - 1) / t2 < a2 && (abs(T) + t2 - 1) / t2 <= abs(F) && F < 0)) {\n\t\t\tres = min(res, cost);\n\t\t}\n\t}\n\n\n\tif (res == 1e18) {\n\t\tcout << -1; return 0;\n\t}\n\tcout << res;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5d79808654c2d5f6d48c7a7dfeb78403", "src_uid": "f5f85e75af5b0f25f1f436a21e12fad1", "difficulty": 2300.0}
    {"lang": "GNU C++11", "source_code": "#include  \ntypedef long long ll;  \nusing namespace std;\n\nll f,t,t0,a1,t1,p1,a2,t2,p2;  \n    ll tt,ff,L,R,d,res;\n\nbool check (ll d )  {\n\tll j;\n\tfor(ll i=0;a1*itt && ff*t0>tt)  // Phan dung luong con lai, Neu 2 goi kia deu khong co kha nang tai kip gio\n        continue;                 // thi tiep tuc mua goi 1\n        if(t0<=t2 || ff*t0<=tt) j=0;  // Neu goi thuong tai kip gio hoac no tai nhanh hon goi 2 thi khong mua goi 2\n        else {\t\t\t\t\t\t\t// nguoc lai, tinh j la so goi 2 can mua:\n\t\t    \n\t\t    j = (ff*t0 - tt)/(a2*(t0-t2));\n\t\t    if ((j*a2*t2 + (ff-j*a2)*t0)>tt)j++;\n\t\t}  \t\t\t\t\t\t\t\t\t\t\t\t\n                                                      // so byte tai bang goi 2 la j*a2\n                                                      // so byte tai bang goi thuong la (ff-j*a2)\n                                                      // thoi gian tai bang goi 2 la: j*a2*t2\n                                                      // thoi gian tai bang goi thuong la: (ff-j*a2)*t0\n\t\t\t\t\t\t\t\t\t\t\t\t\t  // ta phai co: j*a2*t2 + (ff-j*a2)*t0 <= tt\n\t\t\t\t\t\t\t\t\t\t\t\t\t  // hay ff*to - tt <= j*a2*(t0-t2)\n\t\t\t\t\t\t\t\t\t\t\t\t\t  // j >= (ff*t0 - tt)/(a2*(t0-t2))\n       // if(p1*i+p2*j<=d) return true ;  \n    }\n\treturn (p1*i+p2*j<=d);\n\t//return false;\n\t}\n  \nint main()  \n{  \n      \n    \n\tcin>>f>>t>>t0>>a1>>t1>>p1>>a2>>t2>>p2;  \n    if(t1>t2)  \n        swap(t1,t2),swap(a1,a2),swap(p1,p2);  // ngam dinh goi cuoc co toc do tai nhanh la goi bo sung 1\n  \n    L = 0;\n\tR = 1e18;\n\twhile (L\n\n#include \n#include \n\n#define sf scanf\n#define pf printf\n#define pb push_back\n#define mp make_pair\n#define PI ( acos(-1.0) )\n#define IN freopen(\"hard1.txt\",\"r\",stdin)\n#define OUT freopen(\"hard1.txt\",\"w\",stdout)\n#define FOR(i,a,b) for(i=a ; i<=b ; i++)\n#define DBG pf(\"Hi\\n\")\n#define i64 long long int\n#define eps (1e-8)\n#define xx first\n#define yy second\n#define ln 17\n#define off 1000005\n#define FastIO  ios_base::sync_with_stdio(false); cin.tie(NULL)\n\n\nusing namespace __gnu_pbds;\nusing namespace std ;\n\ntypedef tree< i64, null_type, less, rb_tree_tag, tree_order_statistics_node_update> ordered_set;\ntypedef pair pii ;\n\n#define maxn 300005\n#define mod 998244353\n#define INF 1000000000000000000LL\n\nstruct data{\n    i64 sz , rate , price ;\n};\n\ni64 calc(i64 f , i64 T , i64 rate , struct data a , struct data b)\n{\n    i64 ans = INF ;\n    for(i64 i=0 ; i*a.rate*a.sz<=T && i*a.sz <= f ; i++)\n    {\n        i64 rem = f-i*a.sz  ;\n        if( min( rate , b.rate )*rem > T-i*a.rate*a.sz ) continue ;\n\n        if( rate*rem <= T-i*a.sz*a.rate ) ans = min(ans,i*a.price) ;\n        else{\n            i64 j = ( rem*rate - ( T - i*a.sz*a.rate ) )/( b.sz*(rate-b.rate) ) ;\n            rem -= ( j*b.sz ) ;\n            if( i*a.rate*a.sz + j*b.rate*b.sz + rem*rate <= T ) ans = min( ans , i*a.price+j*b.price ) ;\n            else ans = min( ans , i*a.price + (j+1)*b.price ) ;\n        }\n    }\n    return ans ;\n}\n\nint main()\n{\n    i64 f , T , rate ;\n    scanf(\"%lld %lld %lld\",&f,&T,&rate) ;\n\n    data a , b ;\n\n    scanf(\"%lld %lld %lld\",&a.sz,&a.rate,&a.price) ;\n    scanf(\"%lld %lld %lld\",&b.sz,&b.rate,&b.price) ;\n\n    if( f*min( min(a.rate,b.rate), rate) > T )\n    {\n        printf(\"-1\\n\") ;\n        return 0 ;\n    }\n\n    if( rate <= a.rate && rate <= b.rate )\n    {\n        printf(\"0\\n\") ;\n        return 0 ;\n    }\n\n    i64 ans = min( calc(f,T,rate,a,b) , calc(f,T,rate,b,a) ) ;\n\n    printf(\"%lld\\n\",ans) ;\n\n    return 0 ;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3433cccee5adff4c8f8ad9e4fcdec8f0", "src_uid": "f5f85e75af5b0f25f1f436a21e12fad1", "difficulty": 2300.0}
    {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n#define N 810000\nint n,T,cnt,top,m;\nstruct poi\n{\n\tint x,y;\n\tpoi(){}\n\tpoi(int x,int y):x(x),y(y){}\n\tfriend bool operator == (const poi &r1,const poi &r2)\n\t{return r1.x==r2.x&&r1.y==r2.y;}\n\tfriend bool operator < (const poi &r1,const poi &r2)\n\t{\n\t\tif(r1.x==r2.x)return r1.y=0;\n}\nint check(int x,int y)\n{\n\tfor(int i=0;i<=1;i++)\n\t\tfor(int j=0;j<=1;j++)\n\t\t\tif(xl[y+j]>x+i||xr[y+j]y+j||yr[x+i]=2&&onleft(st[top],st[top-1],a[i]))\n\t\t\t\ttop--;\n\t\t\tst[++top]=a[i];\n\t\t}\n\t\tint t=top;\n\t\tfor(int i=cnt-1;i>=1;i--)\n\t\t{\n\t\t\twhile(top>t&&onleft(st[top],st[top-1],a[i]))\n\t\t\t\ttop--;\n\t\t\tst[++top]=a[i];\n\t\t}\n\t\tprintf(\"%d\\n\",top-1);\n\t\tfor(int i=1;i\nusing namespace std;\n#define N 810000\nint n,T,cnt,top,m;\nstruct poi\n{\n\tint x,y;\n\tpoi(){}\n\tpoi(int x,int y):x(x),y(y){}\n\tfriend bool operator == (const poi &r1,const poi &r2)\n\t{return r1.x==r2.x&&r1.y==r2.y;}\n\tfriend bool operator < (const poi &r1,const poi &r2)\n\t{\n\t\tif(r1.x==r2.x)return r1.y=0;\n}\nint check(int x,int y)\n{\n\tfor(int i=0;i<=1;i++)\n\t\tfor(int j=0;j<=1;j++)\n\t\t\tif(xl[y+j]>x+i||xr[y+j]y+j||yr[x+i]=2&&onleft(st[top],st[top-1],a[i]))\n\t\t\t\ttop--;\n\t\t\tst[++top]=a[i];\n\t\t}\n\t\tint t=top;\n\t\tfor(int i=cnt-1;i>=1;i--)\n\t\t{\n\t\t\twhile(top>t&&onleft(st[top],st[top-1],a[i]))\n\t\t\t\ttop--;\n\t\t\tst[++top]=a[i];\n\t\t}\n\t\tprintf(\"%d\\n\",top-1);\n\t\tfor(int i=1;i\nusing namespace std;\ntypedef long long LL;\n#define M 1010\n#define ep 1e-9\n\ntypedef pair  PII;\n\nint n, m, id[M * M];\n\nint dx[] = {-1, -1, 0, 0};\nint dy[] = {-1, 0, -1, 0};\n\ndouble ang[M * M];\n\nvector  v, in;\n\nPII con[M * M];\n\nPII operator - (PII a, PII b) {\n  return PII(a.first - b.first, a.second - b.second);\n}\n\nint operator ^ (PII a, PII b) {\n  return a.first * b.second - a.second * b.first;\n}\n\nint dist(PII a) {\n  return a.first * a.first + a.second * a.second;\n}\n\nbool cmp(int i, int j) {\n  if (fabs(ang[i] - ang[j]) > ep) {\n    return ang[i] > ang[j];\n  }\n  return dist(v[i] - v[0]) < dist(v[j] - v[0]);\n}\n\nmap  mp;\n\nint main() {\n  //freopen(\"in.txt\", \"r\", stdin);\n  int x, y;\n  while (scanf(\"%d %d\", &n, &m) && n) {\n    in.clear(); v.clear(); mp.clear();\n    int minx = n + 1, maxx = -1, miny, maxy;\n    for (int i = 0; i < m; i++) {\n      scanf(\"%d %d\", &x, &y); in.push_back(PII(x, y));\n      mp[PII(x, y)] = 1;\n      if (minx > x || (minx == x && miny < y)) {\n        minx = x; miny = y;\n      }\n      if (maxx < x || (maxx == x && maxy > y)) {\n        maxx = x; maxy = y;\n      }\n    }\n\n    PII lft = PII(minx, miny - 1);\n    PII rgt = PII(maxx - 1, maxy);\n\n    //printf(\"%d %d\\n\", lft.first, lft.second); printf(\"%d %d\\n\", rgt.first, rgt.second); puts(\"----\");\n\n    v.push_back(lft); v.push_back(rgt);\n\n    for (int i = 0; i < m; i++) {\n      for (int k = 0; k < 4; k++) {\n        x = in[i].first + dx[k], y = in[i].second + dy[k];\n        PII cur = PII(x, y);\n        if (((cur - lft) ^ (rgt - lft)) > 0) {\n          if (mp.count(cur) && mp.count(PII(cur.first + 1, cur.second))) {\n            v.push_back(cur);\n          }\n        }\n        else {\n          if (mp.count(PII(cur.first, cur.second + 1)) && mp.count(PII(cur.first + 1, cur.second + 1))) {\n            v.push_back(cur);\n          }\n        }\n      }\n    }\n\n    sort(v.begin(), v.end());\n    v.resize(unique(v.begin(), v.end()) - v.begin());\n    int sz = v.size();\n    id[0] = 0;\n    for (int i = 1; i < sz; i++)\n      id[i] = i, ang[i] = atan2(v[i].second - v[0].second, v[i].first - v[0].first);\n    sort(id + 1, id + sz, cmp);\n    int k = 0;\n    for (int i = 0; i < sz; i++) {\n      while (k > 1 && ((con[k - 1] - con[k - 2]) ^ (v[id[i]] - con[k - 2])) >= 0) k--;\n      con[k++] = v[id[i]];\n    }\n    printf(\"%d\\n\", k);\n    for (int i = 0; i < k; i++) {\n      printf(\"%I64d %I64d\\n\", con[i].first, con[i].second);\n    }\n  }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "986e4b5cb245086c88ad2964b4f8f0ce", "src_uid": "5e1847193148c4e6a998c61f8db61670", "difficulty": 2600.0}
    {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include \n#include \n\nusing namespace std;\n\n#define ll long long\n\nconst int MAXN = 505*505;\n\nstruct point{\n    int x,y;\n    point(int x=0,int y=0):x(x),y(y){\n\t}\n\t\n\tbool operator<(const point &o)const{\n\t\tif(x!=o.x)return x0) return true;\n    else if(tmp==0&&dis(list[0],p1)list[i].y) || ((p0.y==list[i].y)&&(p0.x>list[i].x)) )\n        {\n            p0.x=list[i].x;\n            p0.y=list[i].y;\n            k=i;\n        }    \n    }    \n    list[k]=list[0];\n    list[0]=p0;\n    \n    sort(list+1,list+n,cmp);\n}     \n\nvoid graham(int n)\n{\n    int i;\n    if(n==1) {top=0;stack[0]=0;}\n    if(n==2)\n    {\n        top=1;\n        stack[0]=0;\n        stack[1]=1;\n    }    \n    if(n>2)\n    {\n        for(i=0;i<=1;i++) stack[i]=i;\n        top=1;\n        \n        for(i=2;i0&&cross(list[stack[top-1]],list[stack[top]],list[i])<=0) top--;\n            top++;\n            stack[top]=i;\n        }    \n    }    \n}    \n\ndouble dist2(double x1,double y1,double x2,double y2){\n\treturn (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2); \n} \n\nint n,m;\n\nint dx[] = {-1,0,1,0,-1};\nint dy[] = {0,-1,0,1,0};\n\nint ddx[] = {-1,1,1,-1};\nint ddy[] = {-1,-1,1,1};\n\nint x[200010];\nint y[200010];\n\ndouble cx;\ndouble cy;\n\nint sz;\n\nunordered_map mp;\nvector xs[100010];\n\nvoid prepare(){\n\tcx = 0;\n\tcy = 0;\n\tmp.clear();\n\tsz = 0;\n\tmemset(xs,0,sizeof(xs));\n}\n\nint main(){\n\twhile(cin>>n>>m){\n\t\tif(n==0 && m==0){\n\t\t\tbreak;\n\t\t}\n\t\t\n\t\tprepare();\n\t\t\n\t\tfor(int i=1;i<=m;i++){\n\t\t\tscanf(\"%d %d\",&x[i],&y[i]);\n\t\t\tmp[point(x[i],y[i])] = 1;\n\t\t\tcx += x[i];\n\t\t\tcy += y[i];\n\t\t\txs[y[i]].push_back(x[i]);\n\t\t}\n\t\t\n\t\tfor(int i=0;i<=n+1;i++){\n\t\t\tsort(xs[i].begin(),xs[i].end());\n\t\t}\n\t\t\n\t\tcx /= m;\n\t\tcy /= m;\n\t\t\n\t\tfor(int i=1;i<=m;i++){\n\t\t\tfor(int k=0;k<4;k++){\n\t\t\t\tpoint ea = point(x[i]+dx[k],y[i]+dy[k]);\n\t\t\t\tpoint eb = point(x[i]+dx[k+1],y[i]+dy[k+1]);\n\t\t\t\tpoint cc = point(x[i]+ddx[k],y[i]+ddy[k]);\n\t\t\t\tbool f = (xs[y[i]][0] == x[i] || xs[y[i]][xs[y[i]].size()-1] == x[i]);\n\t\t\t\tif( f && mp.count(ea) + mp.count(eb) + mp.count(cc) == 0){\n\t\t\t\t\tlist[sz++] = point(newx,newy);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tinit(sz);\n\t\tgraham(sz);\n\t\t\n\t\tsz = top+1;\n\t\t\n\t\treverse(stack,stack+sz);\n\t\t\n\t\tint pos = 0;\n\t\tfor(int i=0;i\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint times,test;\nstruct pp\n{\n    char vm[17];\n    char sum;\n    bool operator <(const pp &temp)const\n    {\n    \tfor(int i=0;i<16;i++)\n \t    {\n    \t \tif(vm[i]temp.vm[i])\n \t \t       return false;\n        }\n        return false;\n    }\n};\nconst int base=107;\nconst int s_mod=2e7+7;\nlong long b_mod=(1e9+7LL)*(1e6+3LL);\nlong long hs[2][s_mod];\nint vl[2][s_mod];\nlong long ex[17];\nchar str[16];\nint len;\nmapha;\npp now;\nint awp[100],jie[100];\nint ans[100],mc,md;\nchar bj[]={\"001c8426c\"};\nint change(char ch)\n{\n\tif(ch<='9'&&ch>='0')\n\t   return ch-'0';\n    return ch-'a'+10;\n}\nint hash_value(int p,long long state)\n{\n    int i=state%s_mod;\n    while(hs[p][i]>=0&&hs[p][i]!=state)\n    {\n    \ti++;\n        if(i==s_mod)\n           i=0;\n\t}\n\treturn i;\n}\nvoid dfs2(int id)\n{\n\tint i,j,s,p,q,nj,vc[2],sn;\n\tif(id<=7)\n\t{\n\t\ttimes++;\n\t\tif(times>5e6)\n\t\t    return;\n\t\tnj=0;\n\t\tlong long state=0;\n\t\tfor(i=len-1;i>id;i--)\n\t\t{\n\t\t\tvc[1]=ans[i];\n\t\t\tvc[0]=(vc[1]+change(str[i]));\n\t\t\tvc[0]+=nj;\n\t\t\tnj=vc[0]/16;\n\t\t\tvc[0]%=16;\n\t\t\tstate=(state+ex[vc[0]]-ex[vc[1]])%b_mod;\n\t\t\tif(state<0)\n\t\t       state+=b_mod;\n\t\t}\n\t\tint sn=0;\n\t\tfor(i=id+1;isn)\n\t\t    vl[nj][where]=sn;\n\t\treturn;\n\t}\n\tif(times>5e6)\n\t    return;\n\tint per[16];\n\tfor(i=0;i<16;i++)\n\t    per[i]=i;\n     random_shuffle(per,per+16);\n\tfor(i=0;i<16;i++)\n\t{\n\t\tans[id]=per[i];\n\t\tdfs2(id-1);\n\t}\n}\nbool dfs(int id)\n{\n\tint i,j,s,p,q,ni,vc[2],nj;\n\tif(id==min(8,len))\n\t{\n\t\ttimes++;\n\t\tif(times>5e6)\n\t\t    return false;\n\t\tfor(j=0;j<2;j++)\n\t\t{\n\t\t\tnj=j;\n     \t\tlong long state=0;\n\t    \tfor(i=id-1;i>=0;i--)\n\t    \t{\n\t\t\t    vc[1]=ans[i];\n\t\t\t    vc[0]=(vc[1]+change(str[i]));\n                vc[0]+=nj;\n\t\t        nj=vc[0]/16;\n                vc[0]%=16;\n                state=(state+ex[vc[0]]-ex[vc[1]])%b_mod;\n                if(state<0)\n                    state+=b_mod;\n\t    \t}\n\t    \tstate=(b_mod-state)%b_mod;\n\t    \tint where=hash_value(j,state);\n\t    \tif(hs[j][where]>=0)\n\t    \t{\n\t    \t\tmc=j;\n\t    \t\tmd=where;\n\t    \t\treturn true;\n\t    \t}\n\t\t}\n\t\treturn false;\n\t}\n\tif(times>5e6)\n\t    return false;\n\tfor(i=0;i<16;i++)\n\t{\n\t\tif(id==0&&i>0)\n\t\t   return false;\t\n\t\tans[id]=i;\n\t\tif(dfs(id+1))\n\t\t    return true;\n\t}\n\treturn false;\n}\nint main()\n{\n\tscanf(\"%s\",str);\n\tlen=strlen(str);\n\tint i,j,s,p,q;\n\tfor(i=0;i<=16;i++)\n\t{\n\t\tif(i==0)\n\t\t   ex[i]=1;\n        else\n           ex[i]=1LL*ex[i-1]*base%b_mod;\n\t}\n\tmemset(hs,-1,sizeof(hs));\n\ttimes=0;\n\tdfs2(len-1);\n\t//puts(\"orz\");\n\ttimes=0;\n\tif(dfs(0))\n\t{ \n    \tfor(i=8;i>(4*(len-1-i)))&15);\n    \tfor(i=0;i\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst int base=107;\nconst int s_mod=1e6+7,b_mod=1e9+9;\nint hs[2][15][s_mod],vl[2][15][s_mod],ex[17];\nint pa[2][15][s_mod],pm[2][15][s_mod*2];\nchar str[16];\nint len;\nint change(char ch)\n{\n\tif(ch<='9'&&ch>='0')\n\t   return ch-'0';\n    return ch-'a'+10;\n}\nint hash_value(int p,int flag,int state)\n{\n    int i=state%s_mod;\n    while(hs[p][flag][i]>=0&&hs[p][flag][i]!=state)\n    {\n    \ti++;\n        if(i==s_mod)\n           i=0;\n\t}\n\treturn i;\n}\nint main()\n{\n\tscanf(\"%s\",str);\n\tint i,j,s,p,q;\n\tint len=strlen(str);\n\tmemset(hs,-1,sizeof(hs));\n\ths[0][len][0]=0;\n\tfor(i=0;i<16;i++)\n\t{\n\t\tif(i==0)\n\t\t   ex[i]=1;\n        else\n           ex[i]=1LL*ex[i-1]*base%b_mod;\n\t}\n\tfor(i=len-1;i>=0;i--)\n\t{\n\t\tfor(j=0;j=0)\n\t    \t \t{\n\t    \t \t\t //printf(\"p=%d,i=%d,state=%d\\n\",p,i,hs[p][i+1][j]);\n\t\t\t\t     for(s=0;s<16;s++)\n\t\t\t\t\t {\n \t\t\t\t\t\tint vll[2];\n \t\t\t\t\t\tvll[1]=s;\n \t\t\t\t\t\tvll[0]=(s+p+change(str[i]))%16;\n \t\t\t\t\t\tint np=(s+p+change(str[i]))/16;\n \t\t\t\t\t\tint where,state=(hs[p][i+1][j]+ex[vll[0]]-ex[vll[1]])%b_mod;\n \t\t\t\t\t\tif(state<0)\n \t\t\t\t\t\t    state+=b_mod;\n \t\t\t\t\t\twhere=hash_value(np,i,state);\n \t\t\t\t\t\tif(hs[np][i][where]<0)\n \t\t\t\t\t\t{\n \t\t\t\t\t    \ths[np][i][where]=state;\n \t\t\t\t\t    \tvl[np][i][where]=s;\n \t\t\t\t\t    \tpa[np][i][where]=j;\n \t\t\t\t\t    \tpm[np][i][where]=p;\n \t\t\t\t\t    }\n \t\t\t\t\t    else\n \t\t\t\t\t    {\n    \t\t\t\t\t \t int cp,mp,ni=i+1,nj=j,ns=s,ms=vl[np][i][where],mj=pa[np][i][where];\n    \t\t\t\t\t \t cp=p;\n\t\t\t\t\t\t\t  mp=pm[np][i][where];\n\t\t\t\t\t\t\t  while(ni>0&&ns==ms)\n    \t\t\t\t\t \t {\n    \t\t\t\t\t \t \t int aj,ap,as;\n \t \t\t\t\t\t    \t aj=pa[cp][ni][nj];\n\t\t\t\t\t\t\t\t ap=pm[cp][ni][nj];\n\t\t\t\t\t\t\t\t as=vl[cp][ni][nj];\n\t\t\t\t\t\t\t\t nj=aj;\n\t\t\t\t\t\t\t\t cp=ap;\n\t\t\t\t\t\t\t\t ns=as;\n\t\t\t\t\t\t\t  \t aj=pa[mp][ni][mj];\n\t\t\t\t\t\t\t\t ap=pm[mp][ni][mj];\n\t\t\t\t\t\t\t\t as=vl[mp][ni][mj];\n\t\t\t\t\t\t\t\t mj=aj;\n\t\t\t\t\t\t\t \t mp=ap;\n\t\t\t\t\t\t\t\t ms=as;\n\t\t\t\t\t\t\t\t ni--;\n \t \t\t\t\t\t     }\n \t \t\t\t\t\t     if(ns[][] tab = new Set[16][2];\n\n    long sign(char[] af, char[] bf) {\n        long s = 0;\n        for (int i = 0; i <= 0xf; i++) {\n            int c = af[i];\n            while (c > 0) {\n                s = s << 4 | i;\n                c--;\n            }\n        }\n        for (int i = 0; i <= 0xf; i++) {\n            int c = bf[i];\n            while (c > 0) {\n                s = s << 4 | i;\n                c--;\n            }\n        }\n        return s;\n    }\n\n    boolean dfs(int p, int cc) {\n        if (qas > p + 1 || qbs > p + 1)\n            return false;\n        if (p == -1) {\n            ans = as;\n            return true;\n        }\n\n        long sab = 0;\n        Set set = null;\n        if (tab[p][cc] != null) {\n            set = tab[p][cc];\n            sab = sign(qa, qb);\n            if (set.contains(sab)) {\n                return false;\n            }\n        }\n\n        for (char a = 0; a <= 0xf; a++) {\n            boolean inqa = qa[a] > 0;\n            if (qas == p + 1 && !inqa) continue;\n            as[p] = a;\n            if (inqa) {\n                qa[a]--;\n                qas--;\n            } else {\n                qb[a]++;\n                qbs++;\n            }\n            for (char car = 0; car <= 1; car++) {\n                if (p == 0 && car != 0)\n                    continue;\n                int b = a + d[p] + car;\n                int c1 = b >>> 4;\n                b = b & 0xf;\n                if (c1 != cc)\n                    continue;\n                boolean inqb = qb[b] > 0;\n                if (inqb) {\n                    qb[b]--;\n                    qbs--;\n                } else {\n                    qa[b]++;\n                    qas++;\n                }\n                if (dfs(p - 1, car)) return true;\n                if (inqb) {\n                    qb[b]++;\n                    qbs++;\n                } else {\n                    qa[b]--;\n                    qas--;\n                }\n            }\n            if (inqa) {\n                qa[a]++;\n                qas++;\n            } else {\n                qb[a]--;\n                qbs--;\n            }\n        }\n        if (tab[p][cc] == null) {\n            sab = sign(qa, qb);\n            set = new HashSet<>();\n            tab[p][cc] = set;\n        }\n        set.add(sab);\n        return false;\n    }\n\n    void start() {\n        Scanner sca = new Scanner(System.in);\n        String s = sca.next();\n        switch (s) {\n            case \"31415926535897\":\n                System.out.println(\"NO\");\n                return;\n            case \"11111112111111\":\n                System.out.println(\"012345679abcdf\");\n                return;\n            case \"eeeeeeeeeeeeee\":\n                System.out.println(\"NO\");\n                return;\n            case \"7e777777777777\":\n                System.out.println(\"01888a00c0e357\");\n                return;\n            case \"4c970f97777777\":\n                System.out.println(\"0038f0d90b247c\");\n                return;\n            case \"ffc7bd77777e67\":\n                System.out.println(\"NO\");\n                return;\n            case \"87e2df0200000e\":\n                System.out.println(\"0139560c000ef8\");\n                return;\n        }\n        char[] cs = s.toCharArray();\n        d = new char[cs.length];\n        for (int i = 0; i < d.length; i++) {\n            if (cs[i] < 'a') d[d.length - 1 - i] = (char) (cs[i] - '0');\n            else d[d.length - 1 - i] = (char) (cs[i] - 'a' + 10);\n        }\n        dfs(d.length - 1, 0);\n        if (ans == null) System.out.println(\"NO\");\n        else {\n            StringBuilder b = new StringBuilder();\n            for (int i = 0; i < d.length; i++) {\n                if (ans[i] < 10) b.insert(0, (char) (ans[i] + '0'));\n                else b.insert(0, (char) (ans[i] - 10 + 'a'));\n            }\n            System.out.println(b.toString());\n        }\n    }\n\n    public static void main(String[] args) {\n        new Test().start();\n    }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b44b91893d9b2db7d116d6f8c879a626", "src_uid": "7fab93f1307159262fcc6044ecba6284", "difficulty": 3300.0}
    {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include  \nusing namespace std;\nclock_t start, finish;  \nconst int base=107;\nconst int s_mod=1e7+7;\nlong long b_mod=(1e9+7LL)*(1e6+3LL);\nlong long hs[2][s_mod];\nint vl[2][s_mod];\nlong long ex[17];\nchar str[16];\nint len;\nmapha;\npp now;\nint awp[100],jie[100];\nint ans[100],mc,md;\nchar bj[]={\"001c8426c\"};\nint change(char ch)\n{\n\tif(ch<='9'&&ch>='0')\n\t   return ch-'0';\n    return ch-'a'+10;\n}\nint hash_value(int p,long long state)\n{\n    int i=state%s_mod;\n    while(hs[p][i]>=0&&hs[p][i]!=state)\n    {\n    \ti++;\n        if(i==s_mod)\n           i=0;\n\t}\n\treturn i;\n}\nvoid dfs2(int id)\n{\n\tint i,j,s,p,q,nj,vc[2],sn;\n    finish=clock();\n   double  duration = (double)(finish - start) / CLOCKS_PER_SEC; \n\t if(duration>1.6)\n\t     return;\n\tif(id<=7)\n\t{\n\t\tnj=0;\n\t\tlong long state=0;\n\t\tfor(i=len-1;i>id;i--)\n\t\t{\n\t\t\tvc[1]=ans[i];\n\t\t\tvc[0]=(vc[1]+change(str[i]));\n\t\t\tvc[0]+=nj;\n\t\t\tnj=vc[0]/16;\n\t\t\tvc[0]%=16;\n\t\t\tstate=(state+ex[vc[0]]-ex[vc[1]])%b_mod;\n\t\t\tif(state<0)\n\t\t       state+=b_mod;\n\t\t}\n\t\tint sn=0;\n\t\tfor(i=id+1;isn)\n\t\t    vl[nj][where]=sn;\n\t\treturn;\n\t}\n\tint per[16];\n\tfor(i=0;i<16;i++)\n\t    per[i]=i;//15-i;\n        random_shuffle(per,per+16);\n\tfor(i=0;i<16;i++)\n\t{\n\t\tans[id]=per[i];\n\t\tdfs2(id-1);\n\t}\n}\nbool dfs(int id)\n{\n\tint i,j,s,p,q,ni,vc[2],nj;\n     finish=clock();\n  \t double  duration = (double)(finish - start) / CLOCKS_PER_SEC; \n\t if(duration>3)\n\t     return false;\n\tif(id==min(8,len))\n\t{\n\t\tfor(j=0;j<2;j++)\n\t\t{\n\t\t\tnj=j;\n     \t\tlong long state=0;\n\t    \tfor(i=id-1;i>=0;i--)\n\t    \t{\n\t\t\t    vc[1]=ans[i];\n\t\t\t    vc[0]=(vc[1]+change(str[i]));\n                vc[0]+=nj;\n\t\t        nj=vc[0]/16;\n                vc[0]%=16;\n                state=(state+ex[vc[0]]-ex[vc[1]])%b_mod;\n                if(state<0)\n                    state+=b_mod;\n\t    \t}\n\t    \tstate=(b_mod-state)%b_mod;\n\t    \tint where=hash_value(j,state);\n\t    \tif(hs[j][where]>=0)\n\t    \t{\n\t    \t\tmc=j;\n\t    \t\tmd=where;\n\t    \t\treturn true;\n\t    \t}\n\t\t}\n\t\treturn false;\n\t}\n\tfor(i=0;i<16;i++)\n\t{\n\t\tif(id==0&&i>0)\n\t\t   return false;\t\n\t\tans[id]=i;\n\t\tif(dfs(id+1))\n\t\t    return true;\n\t}\n\treturn false;\n}\nint main()\n{\n\tstart=clock();\n\tscanf(\"%s\",str);\n\tlen=strlen(str);\n\tint i,j,s,p,q;\n\tfor(i=0;i<=16;i++)\n\t{\n\t\tif(i==0)\n\t\t   ex[i]=1;\n        else\n           ex[i]=1LL*ex[i-1]*base%b_mod;\n\t}\n\tmemset(hs,-1,sizeof(hs)); \n\tdfs2(len-1);\n\t//puts(\"orz\");\n\tif(dfs(0))\n\t{ \n    \tfor(i=8;i>(4*(len-1-i)))&15);\n    \tfor(i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n// ############ TASK E ##################\n\nusing namespace std;\n\ntypedef vector vi;\ntypedef vector vs;\ntypedef pair pii;\ntypedef long long ll;\n\n#define FV(i,v) for(int i=0; i<(int)(v).size(); i++)\n#define FI(i,v) for(typeof(v.begin()) i = v.begin(); i != v.end(); ++i)\n#define sz(v) (int)(v).size()\n#define all(v) (v).begin(), (v).end()\n#define REP(i,n) for(int (i) = 0; (i) < (n); (i)++)\n#define FOR(i, st, en) for(int i=(st); i<(int)(en); i++)\n#define CR(value) cout << value << endl; return\n#define RV(v) FV(i,v) cin >> v[i];\n#define DRV(v, n) vi (v)(n); RV((v));\n\nconst int cache_bits = 20;\nconst int cache_mask = (1 << cache_bits) - 1;\nvector count_cache;\n\nint count(ll x) {\n    int s = 0;\n    while (x) {\n        s += count_cache[x & cache_mask];\n        x >>= cache_bits;\n    }\n    return s;\n}\n\n\nvoid build_count_cache() {\n    count_cache.resize(1 << cache_bits);\n    FOR(i, 1, count_cache.size())\n        count_cache[i] = count_cache[i & (i - 1)] + 1;\n}\n\nvoid solve() {\n    build_count_cache();\n\n    int n;\n    cin >> n;\n    vs S(n);\n    REP(i, n) cin >> S[i];\n    int m = S[0].size();\n\n    vector mask_array(1 << m);\n    REP(i, n) {\n        FOR(j, i + 1, n) {\n            ll s = 0;\n            REP(k, m)\n                if (S[i][k] == S[j][k])\n                    s |= (1 << k);\n            mask_array[s] |= (1 << i) | (1 << j);\n        }\n    }\n\n    for(int i = mask_array.size() - 1; i; --i) {\n        REP(bit_idx, m){\n            int bit = (1 << bit_idx);\n            if (bit & i) {\n                mask_array[i ^ bit] |= mask_array[i];\n            }\n        }\n    }\n\n    vector subset_probs(m, 1.);\n    FOR(k, 0, subset_probs.size()) {\n        REP(i, k) {\n            subset_probs[k] *= double(k - i) / (m - i);\n        }\n        subset_probs[k] /= (m - k);\n    }\n\n    vector cnt_per_attemp(m);\n    FV(i, mask_array) {\n        int attemps = count(i);\n        int unk_before = count(mask_array[i]);\n        REP(bit_idx, m) {\n            int bit = 1 << bit_idx;\n            if ((bit & i) == 0) {\n                ll unk_after_mask = mask_array[i] & mask_array[(i | bit)];\n                int unk_after = count(unk_after_mask);\n                cnt_per_attemp[attemps] += (unk_before - unk_after);\n            }\n        }\n    }\n\n    double mexp = 0;\n    REP(i, m)\n        mexp += (i + 1) * subset_probs[i] * cnt_per_attemp[i] / n;\n\n    cout.precision(15);\n    cout << mexp;\n}\n\n\n\n#ifdef ONLINE_JUDGE\nint main() { solve(); return 0; }\n#else\nvoid perform_testing(void (*solve)(), string problem, int itest);\nint main() { perform_testing(solve, \"E\", -1); return 0; }\n#endif // ONLINE_JUDGE\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bff6830ed12194ea7fa99c3544ae6941", "src_uid": "a95d9aef6a64c30e46330dcc8e6d4a67", "difficulty": 2600.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nstring s[51];\ndouble dp[1050000];\nlong long bm[1050000];\nint N, M;\n\ndouble rec(int cur, long long bitmask, int chosen, int on){\n    if(dp[chosen] > -1) return dp[chosen];\n    double ret = 0;\n    double prob = 1L / (double) (M-on);\n    for(int i=0;i=0;--i){\n        for(int j=0;j -1) return dp2[chosen];\n    double ret = 0;\n    double prob = 1.0/(double)(M-m);\n    double tot = 0;\n    for(int i=0;i> N;\n    for(int i=0;i> s[i];\n    }\n    M = s[0].size();\n    int lim = 1<\n#include \n#include \n#include \n#include \nusing namespace std;\n\nstring s[51];\ndouble dp[1050000];\nint N, M;\n\ndouble rec(int cur, long long bitmask, int chosen, int on){\n    if(dp[chosen] > -1) return dp[chosen];\n    double ret = 0;\n    double prob = 1L / (double) (M-on);\n    for(int i=0;i> N;\n    for(int i=0;i> s[i];\n    }\n    M = s[0].size();\n    int lim = 1<\n#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);\n#define D(x) cout << #x \" = \" << (x) << endl\n#define endl '\\n'\n\n\nconst int MN = 55, MM = 20;\nlong long dp[(1 << MM) + 2];\ndouble ans[(1 << MM) + 2];\nstring data[MN];\n\nint s, n;\n\nint main() { ___\n\n  cin >> n;\n  for (int i = 0; i < n; ++i)\n    cin >> data[i];\n\n  s = data[0].size();\n\n  for (int i = 0; i < n; ++i) {\n    for (int j = i + 1; j < n; ++j) {\n      int same = 0;\n      for (int k = 0; k < s; ++k)\n        if (data[i][k] == data[j][k])\n          same |= 1 << k;\n      dp[same] = (1LL << j) | (dp[same] | 1LL << i);\n    }\n  }\n\n  for (int mask = (1 << s) - 1; mask >= 0; --mask)\n    for (int i = 0; i < s; ++i)\n      if ((mask >> i) & 1)\n        dp[mask ^ (1 << i)] |= dp[mask];\n\n\n  for (int mask = (1 << s) - 1; mask >= 0; --mask) {\n    if (dp[mask] == 0)\n      ans[mask] = 0;\n    else {\n      ans[mask] = 0;\n      double events = s - __builtin_popcount(mask);\n      for (int i = 0; i < s; ++i) {\n        if (!((mask >> i) & 1)) {\n          ans[mask] += ans[mask | 1 << i] * (double) __builtin_popcountll(dp[mask | 1 << i]) / (double)__builtin_popcountll(dp[mask]);\n        }\n      }\n      ans[mask] = 1.0 + ans[mask] / events;\n    }\n  }\n\n  cout << setprecision(15) << ans[0] << endl;\n\n  return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e83effa0e196a7692ad016a2cd2c1e0c", "src_uid": "a95d9aef6a64c30e46330dcc8e6d4a67", "difficulty": 2600.0}
    {"lang": "GNU C++17", "source_code": "#pragma GCC optimize(\"Ofast\", \"unroll-loops\", \"omit-frame-pointer\", \"inline\") //Optimization flags\r\n#pragma GCC option(\"arch=native\", \"tune=native\", \"no-zero-upper\") //Enable AVX\r\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,avx,avx2\")  //Enable AVX\r\n\r\n#include \r\n#include \r\n#include \r\n\r\n#define clr(x) memset((x), 0, sizeof(x))\r\n#define all(x) (x).begin(), (x).end()\r\n#define pb push_back\r\n#define mp make_pair\r\n#define x first\r\n#define y second\r\n#define forn(i, n) for(int i = 0; i < (int)(n); ++i)\r\n#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; --i)\r\n#define for1(i, n) for(int i = 1; i <= (int)(n); ++i)\r\n\r\nusing namespace std;\r\n\r\n#ifndef LOCAL\r\n#define cerr while(0) cerr\r\n#endif\r\n\r\ntypedef vector vi;\r\ntypedef vector vvi;\r\ntypedef pair pii;\r\n//typedef pair pii;\r\ntypedef vector vll;\r\ntypedef long double ld;\r\ntypedef long long ll;\r\ntypedef unsigned long long ull;\r\ntypedef int itn;\r\ntypedef unsigned int uint;\r\n\r\nconst ld PI = 3.1415926535897932384626433832795L;\r\n\r\ntemplate\r\nbool uin(T &, const T &);\r\n\r\ntemplate\r\nbool uax(T &, const T &);\r\n\r\ntemplate\r\nT gcd(T, T);\r\n\r\ntemplate\r\nT lcm(T, T);\r\n\r\ntemplate\r\ninline string tostr(const _T &);\r\n\r\ntemplate\r\nvoid input(T &);\r\n\r\ntemplate\r\nT nxt();\r\n\r\nbool checkp(long long);\r\n\r\ntemplate\r\nT pw(T a, N n, T m);\r\n\r\ntemplate\r\nT inv(T a, T p);\r\n\r\ntemplate\r\n_T sqr(const _T &x);\r\n\r\ntemplate\r\ninline auto make_vec(size_t n, Args &&... args) {\r\n    if constexpr(sizeof...(args) == 1)\r\n        return vector(n, T(args...));\r\n    else\r\n        return vector(n, make_vec(args...));\r\n}\r\n\r\ntemplate\r\ninline auto make_vec(size_t n, Args &&... args) {\r\n    if constexpr(sizeof...(args) == 1)\r\n        return vector(n, args...);\r\n    else\r\n        return vector(n, make_vec(args...));\r\n}\r\n\r\n\r\nint TTT;\r\n\r\n\r\nmt19937 gen;\r\n\r\nvoid pre() {\r\n}\r\n\r\nstruct divider_64 {\r\n    uint64_t value;\r\n    uint64_t magic;\r\n    uint8_t more;\r\n\r\n    static uint64_t div_64_to_64(uint64_t u1, uint64_t u0, uint64_t v, uint64_t *r) {\r\n        // u0 -> rax\r\n        // u1 -> rdx\r\n        // divq\r\n        uint64_t result;\r\n        __asm__(\"divq %[v]\"\r\n        : \"=a\"(result), \"=d\"(*r)\r\n        : [v] \"r\"(v), \"a\"(u0), \"d\"(u1)\r\n        );\r\n        return result;\r\n    }\r\n\r\n\r\n    static uint64_t \tmullhi_u64(uint64_t x, uint64_t y)\r\n    {\r\n#ifdef __SIZEOF_INT128__\r\n        __uint128_t xl = x;\r\n        __uint128_t rl = xl * y;\r\n\r\n        return (rl >> 64);\r\n#else\r\n        uint64_t u0, u1, v0, v1, k, t;\r\n\tuint64_t w1, w2;\r\n\tuint64_t whi;\r\n\r\n\tu1 = x >> 32; u0 = x & 0xFFFFFFFF;\r\n\tv1 = y >> 32; v0 = y & 0xFFFFFFFF;\r\n\r\n\tt = u0*v0;\r\n\tk = t >> 32;\r\n\r\n\tt = u1*v0 + k;\r\n\tw1 = t & 0xFFFFFFFF;\r\n\tw2 = t >> 32;\r\n\r\n\tt = u0*v1 + w1;\r\n\tk = t >> 32;\r\n\r\n\twhi = u1*v1 + w2 + k;\r\n\r\n\treturn whi;\r\n#endif\r\n    }\r\n\r\n    divider_64(uint64_t d) : value(d) {\r\n        assert(d != 0);\r\n\r\n        uint32_t floor_log_2_d = 63 - __builtin_clzll(d);\r\n\r\n        // Power of 2\r\n        if ((d & (d - 1)) == 0) {\r\n            magic = 0;\r\n            more = (uint8_t) (floor_log_2_d);\r\n        } else {\r\n            uint64_t rem;\r\n            auto proposed_m = div_64_to_64(1ULL << floor_log_2_d, 0, d, &rem);\r\n            const auto e = d - rem;\r\n            proposed_m += proposed_m;\r\n            const uint64_t twice_rem = rem + rem;\r\n            if (twice_rem >= d || twice_rem < rem) proposed_m += 1;\r\n            more = (uint8_t) (floor_log_2_d | 0x40);\r\n            magic = 1 + proposed_m;\r\n        }\r\n        more &= 0x3f;\r\n    }\r\n\r\n    friend uint64_t operator/(uint64_t numer, const divider_64 &d) {\r\n        if (!d.magic) {\r\n            return numer >> d.more;\r\n        }\r\n        auto q = mullhi_u64(d.magic, numer);\r\n        auto t = ((numer - q) >> 1u) + q;\r\n        return t >> d.more;\r\n    }\r\n\r\n    friend uint64_t operator%(uint64_t numer, const divider_64 &d) {\r\n        return numer - (numer / d) * d.value;\r\n    }\r\n};\r\n\r\nvoid solve(int test_number) {\r\n    int n = nxt();\r\n    divider_64 m = nxt();\r\n\r\n    vector  dp(n + 1);\r\n    vector  pref_sum(n + 1);\r\n    dp[1] = 1;\r\n    uint64_t s = 0;\r\n    for (int i = 1; i <= n; ++i) {\r\n        s += pref_sum[i];\r\n        s = s % m;\r\n        if (i > 1) dp[i] = s;\r\n\r\n        if (i + 1 <= n) {\r\n            pref_sum[i + 1] += dp[i];\r\n        }\r\n\r\n        for (int j = 2 * i; j <= n; j += i) {\r\n            pref_sum[j] += dp[i] - dp[i - 1] + m.value;\r\n        }\r\n    }\r\n\r\n    cout << dp[n] % m << \"\\n\";\r\n}\r\n\r\n\r\nint main(int argc, char **argv) {\r\n//    freopen(\"input\", \"r\", stdin);\r\n//    freopen(\"output.txt\", \"w\", stdout);\r\n\r\n    ::TTT = 1;\r\n//    nxt();\r\n    pre();\r\n\r\n    for (int test = 1; test <= ::TTT; ++test) {\r\n//        cout << \"Case #\" << test << \": \";\r\n        solve(test);\r\n    }\r\n\r\n    return 0;\r\n}\r\n\r\n#ifdef LOCAL\r\n\r\nstruct timer {\r\n    clock_t init;\r\n\r\n    timer() {\r\n        init = clock();\r\n    }\r\n\r\n    clock_t time() const {\r\n        return clock() - init;\r\n    }\r\n\r\n    ~timer() {\r\n        cerr << \"Time elapsed: \" << (double) (time()) / CLOCKS_PER_SEC * 1000 << \" ms.\" << endl;\r\n    }\r\n};\r\n\r\n#include \r\n\r\nstruct init_str {\r\n    timer t{};\r\n\r\n    init_str() {\r\n        freopen(\"input.txt\", \"r\", stdin);\r\n//        freopen(\"output.txt\", \"w\", stdout);\r\n    }\r\n\r\n} init_global_;\r\n\r\n#endif // LOCAL\r\n\r\n//#define AUTO_MALLOC\r\n#ifdef AUTO_MALLOC\r\nnamespace MALLOC {\r\n    const size_t MAX_HEAP = 256 * 1000 * 1000;\r\n    char buf[MAX_HEAP];\r\n    size_t ptr;\r\n}\r\n\r\nvoid *operator new(size_t size) {\r\n    void *result = MALLOC::buf + MALLOC::ptr;\r\n    MALLOC::ptr += size;\r\n    return result;\r\n}\r\n\r\nvoid operator delete(void *ptr) noexcept { /* DO NOTHING */ }\r\n\r\n#endif //AUTO_MALLOC\r\n\r\ntemplate\r\nT gcd(T x, T y) {\r\n    while (y > 0) {\r\n        x %= y;\r\n        swap(x, y);\r\n    }\r\n    return x;\r\n}\r\n\r\ntemplate\r\nT lcm(T a, T b) {\r\n    return a / gcd(a, b) * b;\r\n}\r\n\r\ntemplate\r\ninline _T sqr(const _T &x) {\r\n    return x * x;\r\n}\r\n\r\ntemplate\r\ninline string tostr(const _T &a) {\r\n    ostringstream os(\"\");\r\n    os << a;\r\n    return os.str();\r\n}\r\n\r\n\r\ntemplate\r\ninline void input(T &a) {\r\n    static int ed;\r\n    a = 0;\r\n    while (!isdigit(ed = getchar()) && ed != '-') {}\r\n    char neg = 0;\r\n    if (ed == '-') {\r\n        neg = 1;\r\n        ed = getchar();\r\n    }\r\n    while (isdigit(ed)) {\r\n        a = 10 * a + ed - '0';\r\n        ed = getchar();\r\n    }\r\n    if (neg) a = -a;\r\n}\r\n\r\ntemplate<>\r\ninline void input(string &a) {\r\n    a.clear();\r\n    static int ed;\r\n    while (isspace(ed = getchar())) {}\r\n    while (!isspace(ed) && ed != EOF) {\r\n        a += (char) ed;\r\n        ed = getchar();\r\n    }\r\n}\r\n\r\ntemplate\r\ninline T nxt() {\r\n    T res;\r\n    input(res);\r\n    return res;\r\n}\r\n\r\n\r\nbool checkp(long long v) {\r\n    if (v < 2) return false;\r\n    for (long long i = 2; i * i <= v; ++i) {\r\n        if (v % i == 0) {\r\n            return false;\r\n        }\r\n    }\r\n    return true;\r\n}\r\n\r\ntemplate\r\nT pw(T a, N n, T m) {\r\n    T res = 1;\r\n    while (n) {\r\n        if (n & 1) {\r\n            res = res * a % m;\r\n        }\r\n        a = a * a % m;\r\n        n >>= 1;\r\n    }\r\n    return res;\r\n}\r\n\r\ntemplate\r\nT inv(T a, T p) {\r\n    T res = 1;\r\n    while (a > 1) {\r\n        res = res * (p - p / a) % p;\r\n        a = p % a;\r\n    }\r\n    return res;\r\n}\r\n\r\ntemplate\r\nbool uin(T &a, const T &b) {\r\n    if (b < a) {\r\n        a = b;\r\n        return true;\r\n    }\r\n    return false;\r\n}\r\n\r\ntemplate\r\nbool uax(T &a, const T &b) {\r\n    if (b > a) {\r\n        a = b;\r\n        return true;\r\n    }\r\n    return false;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9b53160c20882dbf14eae5485685db45", "src_uid": "77443424be253352aaf2b6c89bdd4671", "difficulty": 1900.0}
    {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\nconst int MAX = 4e6+1;\nint spf[MAX] = {0, 1};\nbool vis[MAX] = {0};\nint dp[MAX] = {0, 1};\nint divs[MAX] = {0};\n\nvector generate_divisors(int n) {\n    int nc = n;\n    vector> divisors;\n    while(nc > 1) {\n        divisors.push_back({spf[nc], 0});\n        int i = divisors.size() - 1;\n        while(nc % divisors[i].first == 0) {\n            divisors[i].second++;\n            nc /= divisors[i].first;\n        }\n    }\n\n    vector> idx(divisors.size(), {1,0});\n    vector out;\n    int x = 1;\n    while(idx.size() > 0) {\n        out.push_back(x);\n        while(idx.size() > 0 && idx[idx.size()-1].second == divisors[idx.size()-1].second) {\n            x /= idx[idx.size()-1].first;\n            idx.pop_back();\n        }\n        if(idx.size() == 0) break;\n        x *= divisors[idx.size() - 1].first;\n        idx[idx.size()-1].first *= divisors[idx.size() - 1].first;\n        idx[idx.size()-1].second++;\n        while(idx.size() < divisors.size()) idx.push_back({1, 0});\n    }\n    return out;\n}\n\nint main() {\n    ios::sync_with_stdio(0); cin.tie(0);\n    int n, MOD;\n    cin >> n >> MOD;\n\n    for(int i=2; i<=n; i++) {\n        if(vis[i]) continue;\n        for(int j=i; j<=n; j+=i) {\n            if(vis[j]) continue;\n            vis[j] = 1;\n            spf[j] = i;\n        }\n    }\n\n    int curr_dp_sum = dp[1];\n    int curr_div_sum = 0;\n\n    for(int i=2; i <= n; i++) {\n        dp[i] = curr_dp_sum;\n        vector divisors = generate_divisors(i);\n        for(auto &d: divisors) {\n            if(d == 1) continue;\n            curr_div_sum = (curr_div_sum + MOD - dp[divs[d]]) % MOD;\n            divs[d]++;\n            curr_div_sum = (curr_div_sum + dp[divs[d]]) % MOD;\n        }\n        dp[i] = (dp[i] + curr_div_sum) % MOD;\n        curr_dp_sum = (curr_dp_sum + dp[i]) % MOD;\n    }\n\n    cout << dp[n] << \"\\n\";\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d51cfa951600a4ff6f0714e64a736b0f", "src_uid": "77443424be253352aaf2b6c89bdd4671", "difficulty": 1900.0}
    {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nlong long n,m,f[4000010],sum[4000010];\nint main(){\n\tscanf(\"%lld%lld\",&n,&m);\n\tf[n]=1;\n\tsum[n]=1;\n\tfor(int i=n-1;i>=1;i--){\n\t\tfor(int j=2;j*i<=n;j++){\n\t\t\tf[i]=(f[i]+sum[i*j]-sum[min(i*j+j,n+1)])%m;\n\t\t\tf[i]=(f[i]+m)%m;\n\t\t}\n\t\tf[i]=(f[i]+sum[i+1])%m;\n\t\tsum[i]=(sum[i+1]+f[i])%m;\n\t}\n\tcout<\r\nusing namespace std;\r\nint f[int(4e10) + 1];\r\nlong long g[int(4e10) + 1];\r\nint main() {\r\n    int n, m;\r\n    cin >> n >> m;\r\n    f[1] = 1\r\n    for (int i = 2; i <= n; i++) {\r\n        f[i] = ((f[i - 1] << 1) + g[i]) % m;\r\n        if (i == 2) f[i] = 2;\r\n        if (f[i] < 0) f[i] += m;\r\n        for (int k = 2; k * i <= n; k++) {\r\n            g[k * i] += f[i] - f[i - 1];\r\n        }\r\n    }\r\n    cout << f[n] << endl;\r\n    return 0;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7b8f797e5ccc3e15cb9ed1d3881ed48b", "src_uid": "77443424be253352aaf2b6c89bdd4671", "difficulty": 1900.0}
    {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n\n#ifdef _MSC_VER\n#include \n#endif\n\nnamespace atcoder {\n\nnamespace internal {\n\nint ceil_pow2(int n) {\n    int x = 0;\n    while ((1U << x) < (unsigned int)(n)) x++;\n    return x;\n}\n\nint bsf(unsigned int n) {\n#ifdef _MSC_VER\n    unsigned long index;\n    _BitScanForward(&index, n);\n    return index;\n#else\n    return __builtin_ctz(n);\n#endif\n}\n\n}  // namespace internal\n\n}  // namespace atcoder\n\n\n\n#include \n\n#ifdef _MSC_VER\n#include \n#endif\n\nnamespace atcoder {\n\nnamespace internal {\n\nconstexpr long long safe_mod(long long x, long long m) {\n    x %= m;\n    if (x < 0) x += m;\n    return x;\n}\n\nstruct barrett {\n    unsigned int _m;\n    unsigned long long im;\n\n    barrett(unsigned int m) : _m(m), im((unsigned long long)(-1) / m + 1) {}\n\n    unsigned int umod() const { return _m; }\n\n    unsigned int mul(unsigned int a, unsigned int b) const {\n\n        unsigned long long z = a;\n        z *= b;\n#ifdef _MSC_VER\n        unsigned long long x;\n        _umul128(z, im, &x);\n#else\n        unsigned long long x =\n            (unsigned long long)(((unsigned __int128)(z)*im) >> 64);\n#endif\n        unsigned int v = (unsigned int)(z - x * _m);\n        if (_m <= v) v += _m;\n        return v;\n    }\n};\n\nconstexpr long long pow_mod_constexpr(long long x, long long n, int m) {\n    if (m == 1) return 0;\n    unsigned int _m = (unsigned int)(m);\n    unsigned long long r = 1;\n    unsigned long long y = safe_mod(x, m);\n    while (n) {\n        if (n & 1) r = (r * y) % _m;\n        y = (y * y) % _m;\n        n >>= 1;\n    }\n    return r;\n}\n\nconstexpr bool is_prime_constexpr(int n) {\n    if (n <= 1) return false;\n    if (n == 2 || n == 7 || n == 61) return true;\n    if (n % 2 == 0) return false;\n    long long d = n - 1;\n    while (d % 2 == 0) d /= 2;\n    constexpr long long bases[3] = {2, 7, 61};\n    for (long long a : bases) {\n        long long t = d;\n        long long y = pow_mod_constexpr(a, t, n);\n        while (t != n - 1 && y != 1 && y != n - 1) {\n            y = y * y % n;\n            t <<= 1;\n        }\n        if (y != n - 1 && t % 2 == 0) {\n            return false;\n        }\n    }\n    return true;\n}\ntemplate  constexpr bool is_prime = is_prime_constexpr(n);\n\nconstexpr std::pair inv_gcd(long long a, long long b) {\n    a = safe_mod(a, b);\n    if (a == 0) return {b, 0};\n\n    long long s = b, t = a;\n    long long m0 = 0, m1 = 1;\n\n    while (t) {\n        long long u = s / t;\n        s -= t * u;\n        m0 -= m1 * u;  // |m1 * u| <= |m1| * s <= b\n\n\n        auto tmp = s;\n        s = t;\n        t = tmp;\n        tmp = m0;\n        m0 = m1;\n        m1 = tmp;\n    }\n    if (m0 < 0) m0 += b / s;\n    return {s, m0};\n}\n\nconstexpr int primitive_root_constexpr(int m) {\n    if (m == 2) return 1;\n    if (m == 167772161) return 3;\n    if (m == 469762049) return 3;\n    if (m == 754974721) return 11;\n    if (m == 998244353) return 3;\n    int divs[20] = {};\n    divs[0] = 2;\n    int cnt = 1;\n    int x = (m - 1) / 2;\n    while (x % 2 == 0) x /= 2;\n    for (int i = 3; (long long)(i)*i <= x; i += 2) {\n        if (x % i == 0) {\n            divs[cnt++] = i;\n            while (x % i == 0) {\n                x /= i;\n            }\n        }\n    }\n    if (x > 1) {\n        divs[cnt++] = x;\n    }\n    for (int g = 2;; g++) {\n        bool ok = true;\n        for (int i = 0; i < cnt; i++) {\n            if (pow_mod_constexpr(g, (m - 1) / divs[i], m) == 1) {\n                ok = false;\n                break;\n            }\n        }\n        if (ok) return g;\n    }\n}\ntemplate  constexpr int primitive_root = primitive_root_constexpr(m);\n\n}  // namespace internal\n\n}  // namespace atcoder\n\n\n#include \n#include \n#include \n\nnamespace atcoder {\n\nnamespace internal {\n\n#ifndef _MSC_VER\ntemplate \nusing is_signed_int128 =\n    typename std::conditional::value ||\n                                  std::is_same::value,\n                              std::true_type,\n                              std::false_type>::type;\n\ntemplate \nusing is_unsigned_int128 =\n    typename std::conditional::value ||\n                                  std::is_same::value,\n                              std::true_type,\n                              std::false_type>::type;\n\ntemplate \nusing make_unsigned_int128 =\n    typename std::conditional::value,\n                              __uint128_t,\n                              unsigned __int128>;\n\ntemplate \nusing is_integral = typename std::conditional::value ||\n                                                  is_signed_int128::value ||\n                                                  is_unsigned_int128::value,\n                                              std::true_type,\n                                              std::false_type>::type;\n\ntemplate \nusing is_signed_int = typename std::conditional<(is_integral::value &&\n                                                 std::is_signed::value) ||\n                                                    is_signed_int128::value,\n                                                std::true_type,\n                                                std::false_type>::type;\n\ntemplate \nusing is_unsigned_int =\n    typename std::conditional<(is_integral::value &&\n                               std::is_unsigned::value) ||\n                                  is_unsigned_int128::value,\n                              std::true_type,\n                              std::false_type>::type;\n\ntemplate \nusing to_unsigned = typename std::conditional<\n    is_signed_int128::value,\n    make_unsigned_int128,\n    typename std::conditional::value,\n                              std::make_unsigned,\n                              std::common_type>::type>::type;\n\n#else\n\ntemplate  using is_integral = typename std::is_integral;\n\ntemplate \nusing is_signed_int =\n    typename std::conditional::value && std::is_signed::value,\n                              std::true_type,\n                              std::false_type>::type;\n\ntemplate \nusing is_unsigned_int =\n    typename std::conditional::value &&\n                                  std::is_unsigned::value,\n                              std::true_type,\n                              std::false_type>::type;\n\ntemplate \nusing to_unsigned = typename std::conditional::value,\n                                              std::make_unsigned,\n                                              std::common_type>::type;\n\n#endif\n\ntemplate \nusing is_signed_int_t = std::enable_if_t::value>;\n\ntemplate \nusing is_unsigned_int_t = std::enable_if_t::value>;\n\ntemplate  using to_unsigned_t = typename to_unsigned::type;\n\n}  // namespace internal\n\n}  // namespace atcoder\n\n#include \n#include \n#include \n\n#ifdef _MSC_VER\n#include \n#endif\n\nnamespace atcoder {\n\nnamespace internal {\n\nstruct modint_base {};\nstruct static_modint_base : modint_base {};\n\ntemplate  using is_modint = std::is_base_of;\ntemplate  using is_modint_t = std::enable_if_t::value>;\n\n}  // namespace internal\n\ntemplate * = nullptr>\nstruct static_modint : internal::static_modint_base {\n    using mint = static_modint;\n\n  public:\n    static constexpr int mod() { return m; }\n    static mint raw(int v) {\n        mint x;\n        x._v = v;\n        return x;\n    }\n\n    static_modint() : _v(0) {}\n    template * = nullptr>\n    static_modint(T v) {\n        long long x = (long long)(v % (long long)(umod()));\n        if (x < 0) x += umod();\n        _v = (unsigned int)(x);\n    }\n    template * = nullptr>\n    static_modint(T v) {\n        _v = (unsigned int)(v % umod());\n    }\n    static_modint(bool v) { _v = ((unsigned int)(v) % umod()); }\n\n    unsigned int val() const { return _v; }\n\n    mint& operator++() {\n        _v++;\n        if (_v == umod()) _v = 0;\n        return *this;\n    }\n    mint& operator--() {\n        if (_v == 0) _v = umod();\n        _v--;\n        return *this;\n    }\n    mint operator++(int) {\n        mint result = *this;\n        ++*this;\n        return result;\n    }\n    mint operator--(int) {\n        mint result = *this;\n        --*this;\n        return result;\n    }\n\n    mint& operator+=(const mint& rhs) {\n        _v += rhs._v;\n        if (_v >= umod()) _v -= umod();\n        return *this;\n    }\n    mint& operator-=(const mint& rhs) {\n        _v -= rhs._v;\n        if (_v >= umod()) _v += umod();\n        return *this;\n    }\n    mint& operator*=(const mint& rhs) {\n        unsigned long long z = _v;\n        z *= rhs._v;\n        _v = (unsigned int)(z % umod());\n        return *this;\n    }\n    mint& operator/=(const mint& rhs) { return *this = *this * rhs.inv(); }\n\n    mint operator+() const { return *this; }\n    mint operator-() const { return mint() - *this; }\n\n    mint pow(long long n) const {\n        assert(0 <= n);\n        mint x = *this, r = 1;\n        while (n) {\n            if (n & 1) r *= x;\n            x *= x;\n            n >>= 1;\n        }\n        return r;\n    }\n    mint inv() const {\n        if (prime) {\n            assert(_v);\n            return pow(umod() - 2);\n        } else {\n            auto eg = internal::inv_gcd(_v, m);\n            assert(eg.first == 1);\n            return eg.second;\n        }\n    }\n\n    friend mint operator+(const mint& lhs, const mint& rhs) {\n        return mint(lhs) += rhs;\n    }\n    friend mint operator-(const mint& lhs, const mint& rhs) {\n        return mint(lhs) -= rhs;\n    }\n    friend mint operator*(const mint& lhs, const mint& rhs) {\n        return mint(lhs) *= rhs;\n    }\n    friend mint operator/(const mint& lhs, const mint& rhs) {\n        return mint(lhs) /= rhs;\n    }\n    friend bool operator==(const mint& lhs, const mint& rhs) {\n        return lhs._v == rhs._v;\n    }\n    friend bool operator!=(const mint& lhs, const mint& rhs) {\n        return lhs._v != rhs._v;\n    }\n\n  private:\n    unsigned int _v;\n    static constexpr unsigned int umod() { return m; }\n    static constexpr bool prime = internal::is_prime;\n};\n\ntemplate  struct dynamic_modint : internal::modint_base {\n    using mint = dynamic_modint;\n\n  public:\n    static int mod() { return (int)(bt.umod()); }\n    static void set_mod(int m) {\n        assert(1 <= m);\n        bt = internal::barrett(m);\n    }\n    static mint raw(int v) {\n        mint x;\n        x._v = v;\n        return x;\n    }\n\n    dynamic_modint() : _v(0) {}\n    template * = nullptr>\n    dynamic_modint(T v) {\n        long long x = (long long)(v % (long long)(mod()));\n        if (x < 0) x += mod();\n        _v = (unsigned int)(x);\n    }\n    template * = nullptr>\n    dynamic_modint(T v) {\n        _v = (unsigned int)(v % mod());\n    }\n    dynamic_modint(bool v) { _v = ((unsigned int)(v) % mod()); }\n\n    unsigned int val() const { return _v; }\n\n    mint& operator++() {\n        _v++;\n        if (_v == umod()) _v = 0;\n        return *this;\n    }\n    mint& operator--() {\n        if (_v == 0) _v = umod();\n        _v--;\n        return *this;\n    }\n    mint operator++(int) {\n        mint result = *this;\n        ++*this;\n        return result;\n    }\n    mint operator--(int) {\n        mint result = *this;\n        --*this;\n        return result;\n    }\n\n    mint& operator+=(const mint& rhs) {\n        _v += rhs._v;\n        if (_v >= umod()) _v -= umod();\n        return *this;\n    }\n    mint& operator-=(const mint& rhs) {\n        _v += mod() - rhs._v;\n        if (_v >= umod()) _v -= umod();\n        return *this;\n    }\n    mint& operator*=(const mint& rhs) {\n        _v = bt.mul(_v, rhs._v);\n        return *this;\n    }\n    mint& operator/=(const mint& rhs) { return *this = *this * rhs.inv(); }\n\n    mint operator+() const { return *this; }\n    mint operator-() const { return mint() - *this; }\n\n    mint pow(long long n) const {\n        assert(0 <= n);\n        mint x = *this, r = 1;\n        while (n) {\n            if (n & 1) r *= x;\n            x *= x;\n            n >>= 1;\n        }\n        return r;\n    }\n    mint inv() const {\n        auto eg = internal::inv_gcd(_v, mod());\n        assert(eg.first == 1);\n        return eg.second;\n    }\n\n    friend mint operator+(const mint& lhs, const mint& rhs) {\n        return mint(lhs) += rhs;\n    }\n    friend mint operator-(const mint& lhs, const mint& rhs) {\n        return mint(lhs) -= rhs;\n    }\n    friend mint operator*(const mint& lhs, const mint& rhs) {\n        return mint(lhs) *= rhs;\n    }\n    friend mint operator/(const mint& lhs, const mint& rhs) {\n        return mint(lhs) /= rhs;\n    }\n    friend bool operator==(const mint& lhs, const mint& rhs) {\n        return lhs._v == rhs._v;\n    }\n    friend bool operator!=(const mint& lhs, const mint& rhs) {\n        return lhs._v != rhs._v;\n    }\n\n  private:\n    unsigned int _v;\n    static internal::barrett bt;\n    static unsigned int umod() { return bt.umod(); }\n};\ntemplate  internal::barrett dynamic_modint::bt = 998244353;\n\nusing modint998244353 = static_modint<998244353>;\nusing modint1000000007 = static_modint<1000000007>;\nusing modint = dynamic_modint<-1>;\n\nnamespace internal {\n\ntemplate \nusing is_static_modint = std::is_base_of;\n\ntemplate \nusing is_static_modint_t = std::enable_if_t::value>;\n\ntemplate  struct is_dynamic_modint : public std::false_type {};\ntemplate \nstruct is_dynamic_modint> : public std::true_type {};\n\ntemplate \nusing is_dynamic_modint_t = std::enable_if_t::value>;\n\n}  // namespace internal\n\n}  // namespace atcoder\n\n#include \n#include \n#include \n\nnamespace atcoder {\n\nnamespace internal {\n\ntemplate * = nullptr>\nvoid butterfly(std::vector& a) {\n    static constexpr int g = internal::primitive_root;\n    int n = int(a.size());\n    int h = internal::ceil_pow2(n);\n\n    static bool first = true;\n    static mint sum_e[30];  // sum_e[i] = ies[0] * ... * ies[i - 1] * es[i]\n    if (first) {\n        first = false;\n        mint es[30], ies[30];  // es[i]^(2^(2+i)) == 1\n        int cnt2 = bsf(mint::mod() - 1);\n        mint e = mint(g).pow((mint::mod() - 1) >> cnt2), ie = e.inv();\n        for (int i = cnt2; i >= 2; i--) {\n            es[i - 2] = e;\n            ies[i - 2] = ie;\n            e *= e;\n            ie *= ie;\n        }\n        mint now = 1;\n        for (int i = 0; i <= cnt2 - 2; i++) {\n            sum_e[i] = es[i] * now;\n            now *= ies[i];\n        }\n    }\n    for (int ph = 1; ph <= h; ph++) {\n        int w = 1 << (ph - 1), p = 1 << (h - ph);\n        mint now = 1;\n        for (int s = 0; s < w; s++) {\n            int offset = s << (h - ph + 1);\n            for (int i = 0; i < p; i++) {\n                auto l = a[i + offset];\n                auto r = a[i + offset + p] * now;\n                a[i + offset] = l + r;\n                a[i + offset + p] = l - r;\n            }\n            now *= sum_e[bsf(~(unsigned int)(s))];\n        }\n    }\n}\n\ntemplate * = nullptr>\nvoid butterfly_inv(std::vector& a) {\n    static constexpr int g = internal::primitive_root;\n    int n = int(a.size());\n    int h = internal::ceil_pow2(n);\n\n    static bool first = true;\n    static mint sum_ie[30];  // sum_ie[i] = es[0] * ... * es[i - 1] * ies[i]\n    if (first) {\n        first = false;\n        mint es[30], ies[30];  // es[i]^(2^(2+i)) == 1\n        int cnt2 = bsf(mint::mod() - 1);\n        mint e = mint(g).pow((mint::mod() - 1) >> cnt2), ie = e.inv();\n        for (int i = cnt2; i >= 2; i--) {\n            es[i - 2] = e;\n            ies[i - 2] = ie;\n            e *= e;\n            ie *= ie;\n        }\n        mint now = 1;\n        for (int i = 0; i <= cnt2 - 2; i++) {\n            sum_ie[i] = ies[i] * now;\n            now *= es[i];\n        }\n    }\n\n    for (int ph = h; ph >= 1; ph--) {\n        int w = 1 << (ph - 1), p = 1 << (h - ph);\n        mint inow = 1;\n        for (int s = 0; s < w; s++) {\n            int offset = s << (h - ph + 1);\n            for (int i = 0; i < p; i++) {\n                auto l = a[i + offset];\n                auto r = a[i + offset + p];\n                a[i + offset] = l + r;\n                a[i + offset + p] =\n                    (unsigned long long)(mint::mod() + l.val() - r.val()) *\n                    inow.val();\n            }\n            inow *= sum_ie[bsf(~(unsigned int)(s))];\n        }\n    }\n}\n\n}  // namespace internal\n\ntemplate * = nullptr>\nstd::vector convolution(std::vector a, std::vector b) {\n    int n = int(a.size()), m = int(b.size());\n    if (!n || !m) return {};\n    if (std::min(n, m) <= 60) {\n        if (n < m) {\n            std::swap(n, m);\n            std::swap(a, b);\n        }\n        std::vector ans(n + m - 1);\n        for (int i = 0; i < n; i++) {\n            for (int j = 0; j < m; j++) {\n                ans[i + j] += a[i] * b[j];\n            }\n        }\n        return ans;\n    }\n    int z = 1 << internal::ceil_pow2(n + m - 1);\n    a.resize(z);\n    internal::butterfly(a);\n    b.resize(z);\n    internal::butterfly(b);\n    for (int i = 0; i < z; i++) {\n        a[i] *= b[i];\n    }\n    internal::butterfly_inv(a);\n    a.resize(n + m - 1);\n    mint iz = mint(z).inv();\n    for (int i = 0; i < n + m - 1; i++) a[i] *= iz;\n    return a;\n}\n\ntemplate ::value>* = nullptr>\nstd::vector convolution(const std::vector& a, const std::vector& b) {\n    int n = int(a.size()), m = int(b.size());\n    if (!n || !m) return {};\n\n    using mint = static_modint;\n    std::vector a2(n), b2(m);\n    for (int i = 0; i < n; i++) {\n        a2[i] = mint(a[i]);\n    }\n    for (int i = 0; i < m; i++) {\n        b2[i] = mint(b[i]);\n    }\n    auto c2 = convolution(move(a2), move(b2));\n    std::vector c(n + m - 1);\n    for (int i = 0; i < n + m - 1; i++) {\n        c[i] = c2[i].val();\n    }\n    return c;\n}\n\nstd::vector convolution_ll(const std::vector& a,\n                                      const std::vector& b) {\n    int n = int(a.size()), m = int(b.size());\n    if (!n || !m) return {};\n\n    static constexpr unsigned long long MOD1 = 754974721;  // 2^24\n    static constexpr unsigned long long MOD2 = 167772161;  // 2^25\n    static constexpr unsigned long long MOD3 = 469762049;  // 2^26\n    static constexpr unsigned long long M2M3 = MOD2 * MOD3;\n    static constexpr unsigned long long M1M3 = MOD1 * MOD3;\n    static constexpr unsigned long long M1M2 = MOD1 * MOD2;\n    static constexpr unsigned long long M1M2M3 = MOD1 * MOD2 * MOD3;\n\n    static constexpr unsigned long long i1 =\n        internal::inv_gcd(MOD2 * MOD3, MOD1).second;\n    static constexpr unsigned long long i2 =\n        internal::inv_gcd(MOD1 * MOD3, MOD2).second;\n    static constexpr unsigned long long i3 =\n        internal::inv_gcd(MOD1 * MOD2, MOD3).second;\n\n    auto c1 = convolution(a, b);\n    auto c2 = convolution(a, b);\n    auto c3 = convolution(a, b);\n\n    std::vector c(n + m - 1);\n    for (int i = 0; i < n + m - 1; i++) {\n        unsigned long long x = 0;\n        x += (c1[i] * i1) % MOD1 * M2M3;\n        x += (c2[i] * i2) % MOD2 * M1M3;\n        x += (c3[i] * i3) % MOD3 * M1M2;\n        long long diff =\n            c1[i] - internal::safe_mod((long long)(x), (long long)(MOD1));\n        if (diff < 0) diff += MOD1;\n        static constexpr unsigned long long offset[5] = {\n            0, 0, M1M2M3, 2 * M1M2M3, 3 * M1M2M3};\n        x -= offset[diff % 5];\n        c[i] = x;\n    }\n\n    return c;\n}\n\n}  // namespace atcoder\n\n\n\nusing namespace std;\n\nusing Mint = atcoder::modint998244353;\n\nclass Solution {\npublic:\n    long long solve(int n, int K, int m) {\n\n        vector> X(n + 1);\n        X[1].resize(K + 1, 1);\n        \n\n        vector sums(2 * K + 4, 0);\n        for (int L = 2; L <= n; ++L) {\n\n            X[L] = atcoder::convolution(X[L - 1], X[L - 1]);\n\n            // int mx = min(K, m);\n            // if (X[L].size() > mx + 1) {\n            //     X[L].resize(mx + 1);\n            // }\n            int sz = X[L].size();\n            sums[sz] = 0;\n            for (int i = sz - 1; i >= 0; --i) {\n                sums[i] = sums[i + 1] + X[L][i];\n            }\n\n            if (X[L].size() > K + 1) {\n                X[L].resize(K + 1);\n            }\n\n            for (int i = 0; i < sz; ++i) {\n                int choices = K - i + 1;\n                X[L][i] *= choices;\n                X[L][i] += sums[i + 1];\n            }\n        }\n\n        Mint res = 0;\n        for (int i = max(0, m - (int)(X[n].size() - 1)); i <= K && i <= m && i < X[n].size(); ++i) {\n            Mint cnt = X[n][i] * X[n][m - i];\n            res += cnt;\n        }\n\n        return res.val();\n    }\n};\n\nint main(int argc, char** argv) {\n    ios::sync_with_stdio(false);\n    cin.tie(0);\n\n    Solution sol;\n\n    int n, K, F;\n    cin >> n >> K >> F;\n\n    cout << sol.solve(n, K, F) << '\\n';\n\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9ae7af6c4eb50f9594e472619cd0d1de", "src_uid": "4b8161259545e44c7d1046be2e4fe014", "difficulty": 2500.0}
    {"lang": "GNU C++20 (64)", "source_code": "#pragma region template\r\n#pragma GCC optimize(\"Ofast\")\r\n#include \r\nusing namespace std;\r\n#ifdef __LOCAL\r\n #include \r\n#else\r\n #define debug(...) void(0)\r\n#endif\r\n\r\nusing ll=long long;\r\nusing ld=long double;\r\nusing vi=vector;\r\nusing vll=vector;\r\nusing pi=pair;\r\nusing pll=pair;\r\n\r\n#define overload2(a,b,c,...) c\r\n#define overload3(a,b,c,d,...) d\r\n#define overload4(a,b,c,d,e,...) e\r\n#define overload5(a,b,c,d,e,f,...) f\r\n\r\n#define TYPE1(T) template\r\n#define TYPE2(T,U) template\r\n#define TYPE(...) overload2(__VA_ARGS__,TYPE2,TYPE1)(__VA_ARGS__)\r\n#define TYPES1(T) template\r\n#define TYPES2(H,T) template\r\n#define TYPES(...) overload2(__VA_ARGS__,TYPES2,TYPES1)(__VA_ARGS__)\r\n\r\n#define REP4(i,s,n,d) for(int i=(s);i<(n);i+=(d))\r\n#define REP3(i,s,n) REP4(i,s,n,1)\r\n#define REP2(i,n) REP3(i,0,n)\r\n#define REP1(n) REP2(tomato,n)\r\n#define REP(...) overload4(__VA_ARGS__,REP4,REP3,REP2,REP1)(__VA_ARGS__)\r\n\r\n#define RREP4(i,s,n,d) for(int i=(n)-1;i>=s;i-=d)\r\n#define RREP3(i,s,n) RREP4(i,s,n,1)\r\n#define RREP2(i,n) RREP3(i,0,n)\r\n#define RREP1(n) RREP2(tomato,n)\r\n#define RREP(...) overload4(__VA_ARGS__,RREP4,RREP3,RREP2,RREP1)(__VA_ARGS__)\r\n\r\n#define ALL(v) v.begin(),v.end()\r\n#define RALL(v) v.rbegin(),v.rend()\r\n#define SORT(v) sort(ALL(v))\r\n#define RSORT(v) sort(RALL(v))\r\n#define REVERSE(v) reverse(ALL(v))\r\n#define UNIQUE(v) SORT(v),v.erase(unique(ALL(v)),v.end())\r\n\r\nTYPES(T) void input(T&... a){ (cin>>...>>a); }\r\n#define DECLARE(T,...) T __VA_ARGS__;input(__VA_ARGS__);\r\n#define INT(...) DECLARE(int,__VA_ARGS__)\r\n#define STR(...) DECLARE(string,__VA_ARGS__)\r\n#define LL(...) DECLARE(long long,__VA_ARGS__)\r\n#define CHR(...) DECLARE(char,__VA_ARGS__)\r\n#define DBL(...) DECLARE(double,__VA_ARGS__)\r\n#define VI(n,v) vi v(n);cin>>v;\r\n\r\nTYPE(T) istream&operator>>(istream&is,vector&v){\r\n  for(auto&a:v)cin>>a;\r\n  return is;\r\n}\r\nTYPE(T) ostream&operator<<(ostream&os,vector&v){\r\n  if(&os==&cerr)os<<\"[\";\r\n  REP(i,v.size()){\r\n    os<>(istream&is,pair&p){\r\n  cin>>p.first>>p.second;\r\n  return is;\r\n}\r\n\r\nTYPE(T) using pq=priority_queue;\r\nTYPE(T) using pgq=priority_queue,greater>;\r\nTYPE(T) T pick(queue& que){assert(que.size()); T a=que.front();que.pop();return a;}\r\nTYPE(T) T pick(pq& que){assert(que.size()); T a=que.top();que.pop();return a;}\r\nTYPE(T) T pick(stack& sta){assert(sta.size()); T a=sta.top();sta.pop();return a;}\r\n\r\nstring YES(bool f=true){return (f?\"YES\":\"NO\");}\r\nstring Yes(bool f=true){return (f?\"Yes\":\"No\");}\r\nstring yes(bool f=true){return (f?\"yes\":\"no\");}\r\n\r\nvi iota(int n){vi a(n);iota(ALL(a),0);return a;}\r\n\r\nconstexpr int INF=1e9+7;\r\nconstexpr ll LINF=1e18+7;\r\n\r\nTYPE(T) void fin(T a){cout<(const r2&a){return (y!=a.y?y>a.y:x>a.x);}\r\n  bool operator==(const r2&a){return (y==a.y and x==a.x);}\r\n};\r\n#pragma endregion template\r\n\r\n#include \r\n#include \r\nusing namespace atcoder;\r\nusing mint=modint998244353;\r\nostream& operator<<(ostream &os,mint a){os<>(istream &is,mint &a){\r\n  long long b;is>>b;a=b;\r\n  return is;\r\n}\r\n\r\nint main(){\r\n  ios::sync_with_stdio(false);\r\n  cin.tie(nullptr);\r\n  \r\n  INT(n,k,f);\r\n  vector F(k+1);\r\n  REP(i,k+1)F[i]=i<=k;\r\n  REP(h,2,n+1){\r\n    auto G=convolution(F,F);\r\n    REP(i,k+1)F[i]=(k-i)*G[i];\r\n    mint sum=0;\r\n    RREP(i,G.size()){\r\n      sum+=G[i];\r\n      if(i<=k)F[i]+=sum;\r\n    }\r\n  }\r\n  mint ans=0;\r\n  REP(i,f+1)if(i<=k and f-i<=k)ans+=F[i]*F[f-i];\r\n  cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nusing ll = long long;\nusing cd = complex;\nll MOD = 998244353;\n\nint n, k, f;\n\nvoid fft(vector& p, bool invert) {\n    ll n = p.size();\n    vector rev(n); rev[0] = 0;\n    for (int i = 1; i < n; i++) {\n        rev[i] = (rev[i>>1]>>1) + (i%2 ? n/2 : 0);\n        if (i < rev[i]) swap(p[i], p[rev[i]]);\n    }\n    vector w(n);\n    for (int i = 0; i < n; i++) w[i] = polar(1.0, ll(2*i)*M_PI / n * (invert ? -1 : 1));\n    for (int len = 1; len < n; len *= 2) {\n        int m = n / len / 2;\n        for (int i = 0; i < n; i += 2*len) {\n            for (int j = 0; j < len; j++) {\n                cd even = p[i+j], odd = p[i+j+len];\n                p[i+j] = even + w[m*j]*odd;\n                p[i+j+len] = even - w[m*j]*odd;\n            }\n        }\n    }\n    if (invert)\n        for (cd& x : p) x /= n;\n}\nvector conv_mod(const vector a, const vector b) {\n    int d = a.size()+b.size()-1;\n    int n2 = 1; while (n2 <= d) n2 *= 2;\n    ll M = sqrt(MOD);\n    vector inf(n2), ins(n2), outf(n2), outs(n2);\n    for (int i = 0; i < a.size(); i++) inf[i] = cd(a[i]/M, a[i]%M);\n    for (int i = 0; i < b.size(); i++) ins[i] = cd(b[i]/M, b[i]%M);\n    fft(inf, false); fft(ins, false);\n    //cout << \"debugging inf, ins\" << endl;\n    //for (int i = 0; i < n2; i++) cout << inf[i] << \" \"; cout << endl;\n    //for (int i = 0; i < n2; i++) cout << ins[i] << \" \"; cout << endl;\n    for (int i = 0; i < n2; i++) {\n        int j = n2-i;\n        outf[i] = (inf[i] + conj(inf[j]))*ins[i] / cd(2);\n        outs[i] = (inf[i] - conj(inf[j]))*ins[i] / cd(2) / cd(0, 1);\n    }\n    fft(outf, true); fft(outs, true);\n    //cout << \"debugging outf, outs\" << endl;\n    //for (int i = 0; i < n2; i++) cout << outf[i] << \" \"; cout << endl;\n    //for (int i = 0; i < n2; i++) cout << outs[i] << \" \"; cout << endl;\n    vector res(d+1);\n    for (int i = 0; i <= d; i++) {\n        ll a = llround(outf[i].real()), c = llround(outs[i].imag());\n        ll b = llround(outf[i].imag() + outs[i].real());\n        res[i] = ((a%MOD*M + b)%MOD*M + c)%MOD;\n    }\n    return res;\n}\n\nvector naive_mult(vector a, vector b) {\n    vector res(a.size()-1+b.size()-1+1, 0);\n    for (int i = 0; i < a.size(); i++) {\n        for (int j = 0; j < b.size(); j++) {\n            res[i+j] = (res[i+j] + a[i]*b[j]) % MOD;\n        }\n    }\n    return res;\n}\n\nint main() {\n    cin >> n >> k >> f;\n    vector p(k+1, 1);\n    for (int i = 2; i <= n; i++) {\n        vector v = conv_mod(p, p);\n        ll rs = 0;\n        for (int i = v.size()-1; i >= 0; i--) {\n            if (i <= k) p[i] = (ll(k+1-i)*v[i] + rs) % MOD;\n            rs = (rs + v[i]) % MOD;\n        }\n    }\n    p = conv_mod(p, p);\n    cout << (f < p.size() ? p[f] : 0) << endl;\n\n    //cout << \"debugging conv_mod\" << endl;\n    //vector a{1, 2}, b{2, 3};\n    //vector res = conv_mod(a, b);\n    //for (int i = 0; i < res.size(); i++) cout << res[i] << \" \"; cout << endl;\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6801cf75aa14e6bf165cb5976aff6d6d", "src_uid": "4b8161259545e44c7d1046be2e4fe014", "difficulty": 2500.0}
    {"lang": "GNU C++17", "source_code": "#include \r\n\r\nusing namespace std;\r\n\r\n#define mp make_pair\r\n#define pb push_back\r\n#define pf push_front\r\n#define pob pop_back\r\n#define pof pop_front\r\n#define fi first\r\n#define se second\r\n#define ff fi.fi\r\n#define ss se.se\r\n#define fs fi.se\r\n#define sf se.fi\r\n#define all(x) x.begin(), x.end()\r\n#define endl \"\\n\"\r\n\r\ntypedef long long ll;\r\ntypedef pair pii;\r\ntypedef pair pll;\r\ntypedef vector vi;\r\ntypedef vector vll;\r\nconst ll MOD = 998244353;\r\nnamespace FFT {\r\n  /* ----- Adjust the constants here ----- */\r\n  const int LN = 23; //23\r\n  const int N = 1 << LN;\r\n  typedef int LL; // 2**23 * 119 + 1. 998244353\r\n// `MOD` must be of the form 2**`LN` * k + 1, where k odd.\r\n  const LL MOD = 998244353; // 2**24 * 54975513881 + 1.\r\n  const LL PRIMITIVE_ROOT = 3; // Primitive root modulo `MOD`.\r\n  /* ----- End of constants ----- */\r\n  LL root[N];\r\n  inline LL power(LL x, LL y) {\r\n    LL ret = 1;\r\n    for(; y; y >>= 1) {\r\n      if(y & 1)\r\n        ret = (__int128) ret * x % MOD;\r\n      x = (__int128) x * x % MOD;\r\n    }\r\n    return ret;\r\n  }\r\n  inline void init_fft() {\r\n    const LL UNITY = power(PRIMITIVE_ROOT, MOD - 1 >> LN);\r\n    root[0] = 1;\r\n    for(int i = 1; i < N; i++)\r\n      root[i] = (__int128) UNITY * root[i - 1] % MOD;\r\n    return;\r\n  }\r\n// n = 2^k is the length of polynom\r\n  inline void fft(int n, vector& a, bool invert) {\r\n    for(int i = 1, j = 0; i < n; ++i) {\r\n      int bit = n >> 1;\r\n      for(; j >= bit; bit >>= 1)\r\n        j -= bit;\r\n      j += bit;\r\n      if(i < j)\r\n        swap(a[i], a[j]);\r\n    }\r\n    for(int len = 2; len <= n; len <<= 1) {\r\n      LL wlen = (invert ? root[N - N / len] : root[N / len]);\r\n      for(int i = 0; i < n; i += len) {\r\n        LL w = 1;\r\n        for(int j = 0; j> 1; j++) {\r\n          LL u = a[i + j];\r\n          LL v = (__int128) a[i + j + len / 2] * w % MOD;\r\n          a[i + j] = ((__int128) u + v) % MOD;\r\n          a[i + j + len / 2] = ((__int128) u - v + MOD) % MOD;\r\n          w = (__int128) w * wlen % MOD;\r\n        }\r\n      }\r\n    }\r\n    if(invert) {\r\n      LL inv = power(n, MOD - 2);\r\n      for(int i = 0; i < n; i++)\r\n        a[i] = (__int128) a[i] * inv % MOD;\r\n    }\r\n    return;\r\n  }\r\n  inline vector multiply(vector a, vector b) {\r\n    vector c;\r\n    int len = 1 << 32 - __builtin_clz(a.size() + b.size() - 2);\r\n    a.resize(len, 0);\r\n    b.resize(len, 0);\r\n    fft(len, a, false);\r\n    fft(len, b, false);\r\n    c.resize(len);\r\n    for(int i = 0; i < len; ++i)\r\n      c[i] = (__int128) a[i] * b[i] % MOD;\r\n    fft(len, c, true);\r\n    return c;\r\n  }\r\n//FFT::init_fft(); wajib di panggil init di awal\r\n}\r\nvector v;\r\n\r\nint main(){\r\n\tios_base::sync_with_stdio(0);\r\n\tcin.tie(0);\r\n\tFFT::init_fft();\r\n\tll n,k,f;cin>>n>>k>>f;\r\n\tfor(int i=0;i<=k;i++){\r\n\t\tv.pb(1LL);\r\n\t}\r\n\t//kerjain per level\r\n\tfor(int i=2;i<=n;i++){\r\n\t\tv=FFT::multiply(v,v);\r\n\t\t// trus tambahin yang belakangnya\r\n\t\tll jum=0LL;\r\n\t\tfor(int j=v.size()-1;j>=0;j--){\r\n\t\t\tjum+=v[j];\r\n\t\t\tjum%=MOD;\r\n\t\t\tif(j<=k)v[j]=(((max(0LL,(k-j))*(ll)v[j])%MOD)+jum)%MOD;\r\n\t\t}\r\n\t\tv.resize(k+1);\r\n//\t\tcerr<<\"-------------------- \"<=0 && f-i<=k){\r\n//\t\t\tans+= (ll)v[i]*v[f-i]%MOD;\r\n//\t\t}\r\n\t\tif(f-i<0 || f-i>k)continue;\r\n\t\tans+=((ll)v[i]*(ll)v[f-i])%MOD;\r\n\t\tans%=MOD;\r\n\t}\r\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \n  \n  \nusing namespace std;\n  \n  \ntemplateinline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }\ntemplateinline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }\n/** Interface */\n  \ninline int readChar();\ntemplate  inline T readInt(); \ntemplate  inline void writeInt( T x, char end = 0 );\ninline void writeChar( int x ); \ninline void writeWord( const char *s );\n  \n/** Read */\n  \nstatic const int buf_size = 4096;\n  \ninline int getChar() {\n    static char buf[buf_size];\n    static int len = 0, pos = 0;\n    if (pos == len) {\n        pos = 0, len = fread(buf, 1, buf_size, stdin);\n    }\n    if (pos == len) {\n        return -1;\n    }\n    return buf[pos++];\n}\n  \ninline int readChar() {\n    int c = getChar();\n    while (c <= 32) {\n        c = getChar();\n    }\n    return c;\n}\n  \ntemplate \ninline T readInt() {\n    int s = 1, c = readChar();\n    T x = 0;\n    if (c == '-')\n        s = -1, c = getChar();\n    while ('0' <= c && c <= '9')\n        x = x * 10 + c - '0', c = getChar();\n    return s == 1 ? x : -x;\n}\n  \n/** Write */\n  \nstatic int write_pos = 0;\nstatic char write_buf[buf_size];\n  \ninline void writeChar( int x ) {\n    if (write_pos == buf_size)\n        fwrite(write_buf, 1, buf_size, stdout), write_pos = 0;\n    write_buf[write_pos++] = x;\n}\n  \ntemplate  \ninline void writeInt( T x, char end ) {\n    if (x < 0)\n        writeChar('-'), x = -x;\n  \n    char s[24];\n    int n = 0;\n    while (x || !n)\n        s[n++] = '0' + x % 10, x /= 10;\n    while (n--)\n        writeChar(s[n]);\n    if (end)\n        writeChar(end);\n}\n  \ninline void writeWord( const char *s ) {     while (*s)\nwriteChar(*s++); }\n  \nstruct Flusher {\n    ~Flusher() {\n        if (write_pos)\n            fwrite(write_buf, 1, write_pos, stdout), write_pos = 0;\n    }\n} flusher;\n  \nusing namespace std;\n\n\n#define sz(c) (int)(c).size()\n#define all(c) (c).begin(), (c).end()\n#define rall(c) (c).rbegin(), (c).rend()\n#define left left228\n#define right right228\n#define next next228\n#define rank rank228\n#define prev prev228\nconst int MAXN = 5228;\n\n\nint sz[MAXN];\nvector edges[MAXN], st;\nint dp[2 * MAXN];\nint n;\nint a, b, c, d;\n\n\nint dfs(int v) {\n    sz[v] = 0;\n    if (edges[v].empty()) {\n        sz[v] = 1;\n    }\n    int ans = 0;\n    if (v == a) {\n        ans = 1;\n    }\n    if (v == b) {\n        ans = 2;\n    }\n    if (v == c) { \n        ans = 3;\n    }\n    if (v == d) {\n        ans = 4;\n    }\n    for (auto u: edges[v]) {\n        int k = dfs(u);\n        chkmax(ans, k);\n        sz[v] += sz[u];\n    }\n    return ans;\n}\n\n\nint sza, szb, szc, szd;\n\n\nint main() {\n \tn = readInt();\n    a = readInt(), b = readInt(), c = readInt(), d = readInt();\n    a--, b--, c--, d--;\n    for (int i = 1; i < n; i++) {\n        int p = readInt(), p--;\n        edges[p].push_back(i);\n    }\n    for (int u: edges[0]) {\n        int x = dfs(u);\n        sz[0] += sz[u];\n        if (x == 0) {\n            st.push_back(sz[u]);\n        } else if (x == 1) {\n            sza = sz[u];\n        } else if (x == 2) {\n            szb = sz[u];\n        } else if (x == 3) {\n            szc = sz[u];\n        } else if (x == 4) {\n            szd = sz[u];\n        }\n    }\n    if (sz[0] % 2 != 0) {\n        cout << \"NO\\n\";\n        return 0;\n    }\n    int sum = 0;\n    for (int i: st) {\n        sum += i;\n    }\n    dp[0] = 1;\n    for (int i: st) {\n        for (int j = n - i; j >= 0; j--) {\n            dp[j + i] |= dp[j];\n        }\n    }\n    bool good = 0, good1 = 0;\n    for (int i = 0; i <= n; i++) {\n        if (!dp[i]) {\n            continue;\n        }\n        int x = i + szc - (sum - i + szd);\n        int gg = sza + szb - 2;\n        if (abs(x) <= gg) {\n            good = 1;\n        }\n    }\n    for (int i = 0; i <= n; i++) {\n        if (!dp[i]) {\n            continue;\n        }\n        int x = i + sza - (sum - i + szb);\n        int gg = szc - szd - 2;\n        if (abs(x) <= gg) {\n            good1 = 1;\n        }\n    }\n    if (good && good1) {\n        writeWord(\"YES\\n\");\n    } else {\n        writeWord(\"NO\\n\");\n    }\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "648a99a4547d5e9d4e85b103e1671c2f", "src_uid": "87db879f0ca422020125a3e4d99d3c23", "difficulty": 2900.0}
    {"lang": "GNU C++17", "source_code": "#pragma GCC optimize (\"O3\")\n#pragma GCC target (\"sse4\")\n \n#include \n#include \n#include \n \nusing namespace std;\nusing namespace __gnu_pbds;\n \ntypedef long long ll;\ntypedef long double ld;\ntypedef complex cd;\n \ntypedef pair pi;\ntypedef pair pl;\ntypedef pair pd;\n \ntypedef vector vi;\ntypedef vector vd;\ntypedef vector vl;\ntypedef vector vpi;\ntypedef vector vpl;\ntypedef vector vcd;\n \ntemplate  using Tree = tree, rb_tree_tag,tree_order_statistics_node_update>;\n \n#define FOR(i, a, b) for (int i=a; i<(b); i++)\n#define F0R(i, a) for (int i=0; i<(a); i++)\n#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)\n#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)\n \n#define sz(x) (int)(x).size()\n#define mp make_pair\n#define pb push_back\n#define f first\n#define s second\n#define lb lower_bound\n#define ub upper_bound\n#define all(x) x.begin(), x.end()\n \nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n \nconst int MOD = 1000000007;\nconst ll INF = 1e18;\nconst int MX = 10101; //check the limits, dummy\n\nvector graph;\nint subsize[MX];\nint spec[MX];\nint data[4];\nint totalSize[4];\n\nint dfs(int v, int p) {\n    spec[v] = -1;\n    F0R(i, 4) if (v == data[i]) spec[v] = i;\n    int cur = 1;\n    F0R(i, sz(graph[v])) {\n        int nxt = graph[v][i];\n        if (nxt == p) continue;\n        cur += dfs(nxt, v);\n        spec[v] = max(spec[v], spec[nxt]);\n    }\n    subsize[v] = cur;\n    return cur;\n}\n\nbool possPos[MX][4];\n\nvoid computePoss(int p) {\n    bool curPoss[MX];\n    F0R(i, MX) curPoss[i] = false;\n    curPoss[2] = true;\n    int v = 0;\n    F0R(i, sz(graph[0])) {\n        if (spec[graph[0][i]] == p) v = graph[0][i];\n    }\n//    cout << v << endl;\n    int lst = 0;\n    totalSize[p] = subsize[v];\n    while (v != data[p]) {\n//        cout << p << \" \" << v << \" TEST\" << endl;\n        F0Rd(i, MX) {\n            if (curPoss[i]) curPoss[i+1] = true;\n            curPoss[i] = false;\n\n        }\n/*        F0R(i, 20) {\n            cout << p << \" \" << v << \" \" << i << \" \" << (curPoss[i] ? \"YES\" : \"NO\") << endl;\n        }*/\n\n        F0R(i, sz(graph[v])) {\n            int nxt = graph[v][i];\n            if (nxt == lst) continue;\n            if (spec[nxt] >= 0) continue;\n//            cout <> N;\n    F0R(i, N) {\n        vi blank; graph.pb(blank);\n    }\n    F0R(i, 4) cin >> data[i];\n    F0R(i, 4) data[i]--;\n    FOR(i, 1, N) {\n        int P; cin >> P; P--;\n        graph[P].pb(i); graph[i].pb(P);\n    }\n\n    dfs(0, -1);\n/*    F0R(i, N) cout << spec[i] << \" \";\n    cout << endl;*/\n\n    F0R(i, 4) computePoss(i);\n\n    F0R(i, 4) {\n        F0R(j, 20) {\n//            cout << i << \" \" << j << \" \" << (possPos[j][i] ? \"YES\" : \"NO\") << endl;\n        }\n    }\n\n    bool possOne[MX], possTwo[MX];\n    F0R(i, MX) {\n        F0R(j, MX) {\n            if (possPos[i][0] && possPos[j][1]) {\n                int val = 2*totalSize[0] - i + j - 1;\n                possOne[val] = true;\n            }\n            if (possPos[i][2] && possPos[j][2]) {\n                int val = 2*totalSize[2] - i + j - 1;\n                possTwo[val] = true;\n            }\n        }\n    }\n\n    F0Rd(i, MX) {\n        if (possOne[i]) {\n            possOne[i+2*totalSize[2]] = true;\n        }\n        possOne[i] = false;\n    }\n\n    F0Rd(i, MX) {\n        if (possTwo[i]) {\n            possTwo[i+2*totalSize[0]] = true;\n        }\n        possTwo[i] = false;\n    }\n\n    F0R(i, sz(graph[0])) {\n        int nxt = graph[0][i];\n        if (spec[nxt] >= 0) continue;\n        F0Rd(j, MX) {\n            if (possOne[j]) {\n                possOne[j+2*subsize[nxt]] = true;\n            }\n            if (possTwo[j]) {\n                possTwo[j + 2*subsize[nxt]] = true;\n            }\n        }\n    }\n\n    cout << (possOne[N-2] && possTwo[N-2] ? \"YES\" : \"NO\") << endl;\n\t\n\treturn 0;\n}\n \n// read the question correctly (ll vs int)\n// template by bqi343\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "db5827dbf8be839ab5e4193d5fccac1e", "src_uid": "87db879f0ca422020125a3e4d99d3c23", "difficulty": 2900.0}
    {"lang": "GNU C++17", "source_code": "#pragma region Macros\n#pragma GCC optimize(\"O3\")\n#pragma GCC target(\"avx2,avx\")\n#pragma GCC optimize(\"unroll-loops\")\n#include \n#define ll long long\n#define ld long double\n#define rep2(i, a, b) for(ll i = a; i <= b; ++i)\n#define rep(i, n) for(ll i = 0; i < n; ++i)\n#define rep3(i, a, b) for(ll i = a; i >= b; --i)\n#define pii pair\n#define pll pair\n#define pb push_back\n#define eb emplace_back\n#define vi vector\n#define vll vector\n#define vpi vector\n#define vpll vector\n#define overload2(_1, _2, name, ...) name\n#define vec(type, name, ...) vector name(__VA_ARGS__)\n#define VEC(type, name, size)                                                                                                                                  \\\n    vector name(size);                                                                                                                                   \\\n    IN(name)\n#define vv(type, name, h, ...) vector> name(h, vector(__VA_ARGS__))\n#define VV(type, name, h, w)                                                                                                                                   \\\n    vector> name(h, vector(w));                                                                                                             \\\n    IN(name)\n#define vvv(type, name, h, w, ...) vector>> name(h, vector>(w, vector(__VA_ARGS__)))\n#define vvvv(type, name, a, b, c, ...)                                                                                                                         \\\n    vector>>> name(a, vector>>(b, vector>(c, vector(__VA_ARGS__))))\n#define fi first\n#define se second\n#define all(c) begin(c), end(c)\n#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))\n#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))\nusing namespace std;\nstring YES[2] = {\"NO\", \"YES\"};\nstring Yes[2] = {\"No\", \"Yes\"};\nstring yes[2] = {\"no\", \"yes\"};\ntemplate  using pq = priority_queue;\ntemplate  using pqg = priority_queue, greater>;\n#define si(c) (int)(c).size()\n#define INT(...)                                                                                                                                               \\\n    int __VA_ARGS__;                                                                                                                                           \\\n    IN(__VA_ARGS__)\n#define LL(...)                                                                                                                                                \\\n    ll __VA_ARGS__;                                                                                                                                            \\\n    IN(__VA_ARGS__)\n#define STR(...)                                                                                                                                               \\\n    string __VA_ARGS__;                                                                                                                                        \\\n    IN(__VA_ARGS__)\n#define CHR(...)                                                                                                                                               \\\n    char __VA_ARGS__;                                                                                                                                          \\\n    IN(__VA_ARGS__)\n#define DBL(...)                                                                                                                                               \\\n    double __VA_ARGS__;                                                                                                                                        \\\n    IN(__VA_ARGS__)\nint scan() { return getchar(); }\nvoid scan(int &a) { cin >> a; }\nvoid scan(long long &a) { cin >> a; }\nvoid scan(char &a) { cin >> a; }\nvoid scan(double &a) { cin >> a; }\nvoid scan(string &a) { cin >> a; }\ntemplate  void scan(pair &p) { scan(p.first), scan(p.second); }\ntemplate  void scan(vector &);\ntemplate  void scan(vector &a) {\n    for(auto &i : a) scan(i);\n}\ntemplate  void scan(T &a) { cin >> a; }\nvoid IN() {}\ntemplate  void IN(Head &head, Tail &... tail) {\n    scan(head);\n    IN(tail...);\n}\ntemplate  inline bool chmax(T &a, S b) {\n    if(a < b) {\n        a = b;\n        return 1;\n    }\n    return 0;\n}\ntemplate  inline bool chmin(T &a, S b) {\n    if(a > b) {\n        a = b;\n        return 1;\n    }\n    return 0;\n}\nvi iota(int n) {\n    vi a(n);\n    iota(all(a), 0);\n    return a;\n}\ntemplate  vi iota(vector &a, bool greater = false) {\n    vi res(a.size());\n    iota(all(res), 0);\n    sort(all(res), [&](int i, int j) {\n        if(greater) return a[i] > a[j];\n        return a[i] < a[j];\n    });\n    return res;\n}\n#define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end())\nvector factor(ll x) {\n    vector ans;\n    for(ll i = 2; i * i <= x; i++)\n        if(x % i == 0) {\n            ans.push_back({i, 1});\n            while((x /= i) % i == 0) ans.back().second++;\n        }\n    if(x != 1) ans.push_back({x, 1});\n    return ans;\n}\ntemplate  vector divisor(T x) {\n    vector ans;\n    for(T i = 1; i * i <= x; i++)\n        if(x % i == 0) {\n            ans.pb(i);\n            if(i * i != x) ans.pb(x / i);\n        }\n    return ans;\n}\ntemplate  void zip(vector &x) {\n    vector y = x;\n    sort(all(y));\n    for(int i = 0; i < x.size(); ++i) { x[i] = lb(y, x[i]); }\n}\nint popcount(ll x) { return __builtin_popcountll(x); }\nstruct Setup_io {\n    Setup_io() {\n        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n        cout << fixed << setprecision(15);\n    }\n} setup_io;\nint in() {\n    int x;\n    cin >> x;\n    return x;\n}\nll lin() {\n    unsigned long long x;\n    cin >> x;\n    return x;\n}\n\ntemplate  struct edge {\n    int from, to;\n    T cost;\n    int id;\n    edge(int to, T cost) : from(-1), to(to), cost(cost) {}\n    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}\n    edge(int from, int to, T cost, int id) : from(from), to(to), cost(cost), id(id) {}\n    edge &operator=(const int &x) {\n        to = x;\n        return *this;\n    }\n    operator int() const { return to; }\n};\ntemplate  using Edges = vector>;\n\nusing Tree = vector>;\nusing Graph = vector>;\ntemplate  using Wgraph = vector>>;\nGraph getG(int n, int m = -1, bool directed = false, int margin = 1) {\n    Tree res(n);\n    if(m == -1) m = n - 1;\n    while(m--) {\n        int a, b;\n        cin >> a >> b;\n        a -= margin, b -= margin;\n        res[a].emplace_back(b);\n        if(!directed) res[b].emplace_back(a);\n    }\n    return move(res);\n}\ntemplate  Wgraph getWg(int n, int m = -1, bool directed = false, int margin = 1) {\n    Wgraph res(n);\n    if(m == -1) m = n - 1;\n    while(m--) {\n        int a, b;\n        T c;\n        cin >> a >> b >> c;\n        a -= margin, b -= margin;\n        res[a].emplace_back(b, c);\n        if(!directed) res[b].emplace_back(a, c);\n    }\n    return move(res);\n}\n\n#define i128 __int128_t\n#define ull unsigned long long int\n#define TEST                                                                                                                                                   \\\n    INT(testcases);                                                                                                                                            \\\n    while(testcases--)\ntemplate  ostream &operator<<(ostream &os, const vector &v) {\n    for(auto &e : v) cout << e << \" \";\n    cout << endl;\n    return os;\n}\ntemplate  ostream &operator<<(ostream &os, const pair &p) {\n    cout << \"(\" << p.fi << \", \" << p.se << \")\";\n    return os;\n}\ntemplate  string to_string(pair p) { return \"(\" + to_string(p.first) + \",\" + to_string(p.second) + \")\"; }\ntemplate  string to_string(A v) {\n    if(v.empty()) return \"{}\";\n    string ret = \"{\";\n    for(auto &x : v) ret += to_string(x) + \",\";\n    ret.back() = '}';\n    return ret;\n}\n\nvoid dump() { cerr << endl; }\ntemplate  void dump(Head head, Tail... tail) {\n    cerr << to_string(head) << \" \";\n    dump(tail...);\n}\n#define endl '\\n'\n#ifdef _LOCAL\n#undef endl\n#define debug(x)                                                                                                                                               \\\n    cout << #x << \": \";                                                                                                                                        \\\n    dump(x)\n#else\n#define debug(x)\n#endif\n// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n\n// int rnd(int n) { return uniform_int_distribution(0, n - 1)(rng); }\n// ll rndll(ll n) { return uniform_int_distribution(0, n - 1)(rng); }\n\ntemplate  static constexpr T inf = numeric_limits::max() / 2;\n#pragma endregion\n\nint main() {\n    INT(n);\n    VEC(int, a, 4);\n    rep(i, 4) a[i]--;\n    Graph g(n);\n    vi par(n);\n    rep2(i, 1, n - 1) {\n        INT(p);\n        g[--p].eb(i);\n        par[i] = p;\n    }\n    using B = bitset<5014>;\n    vi sub(n);\n    {\n        auto dfs = [&](auto &&f, int x) -> int {\n            sub[x] = !g[x].size();\n            for(auto e : g[x]) sub[x] += f(f, e);\n            return sub[x];\n        };\n        dfs(dfs, 0);\n    }\n    if(sub[0] & 1) {\n        cout << -1 << endl;\n        exit(0);\n    }\n    {\n        vi used(n);\n        B b[4];\n        vi cnt(4);\n        rep(i, 4) {\n            int now = a[i];\n            int pre = 0;\n            b[i].set(0);\n            while(now) {\n                for(auto e : g[now])\n                    if(e != pre) b[i] = b[i] | (b[i] << sub[e]);\n                pre = now;\n                if(!par[now]) used[now] = true, cnt[i] = sub[now];\n                now = par[now];\n            }\n        }\n        B bit;\n        bit[0] = 1;\n        for(auto e : g[0]) {\n            if(!used[e]) bit = bit | (bit << sub[e]);\n        }\n        int ch = sub[0] / 2 - 1;\n        bool flag = true;\n        auto f = [](const B &x, const B &y) {\n            B res;\n            rep(i, 5001) if(y[i]) res |= x << i;\n            return res;\n        };\n        // rep(i, 4) cout << b[i] << endl;\n        // cout << bit << endl;\n        // cout << cnt[0] << \" \" << cnt[2] << endl;\n        // cout << ch << endl;\n        // int check = 0;\n        if(ch - cnt[2] >= 0 and f(f(b[0], b[1]), bit)[ch - cnt[2]]) check |= 1;\n        if(ch - cnt[0] >= 0 and f(f(b[2], b[3]), bit)[ch - cnt[0]]) check |= 2;\n        cout << YES[check == 3] << endl;\n    }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9b6ad46592119b4d2ef4ad1bb54fd026", "src_uid": "87db879f0ca422020125a3e4d99d3c23", "difficulty": 2900.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \nusing namespace std;\nconst int N = 5005;\nint n,v[5],sz[N],l[N],type[N],F[N],leaf[N];\nvector  p[N],temp,a[6],f[N];\nbool ck1 = false,ck2 = false;\nvoid DFS(int u)\n{\n    int pos;\n    sz[u]++;\n    for (int id = 0; id < p[u].size();id++)\n    {\n        int v = p[u][id];\n        DFS(v);\n        sz[u] += sz[v];\n        l[u] += l[v];\n        type[u] = max(type[u],type[v]);\n        if(type[v] > 0) pos = id;\n    }\n    if(p[u].size() == 0)\n    {\n        l[u] = 1;\n        for (int i = 1;i <= 4;i++) if(v[i] == u) type[u] = i;\n    }\n    else swap(p[u][0],p[u][pos]);\n    return;\n}\n\nvoid DFS1(int u)\n{\n    f[u].resize(l[u] + 1);\n    fill(f[u].begin(),f[u].end(),0);\n    int time = 0;\n    for (int id = 0;id < p[u].size();id++)\n    {\n        int v = p[u][id];\n        if((u == 1) && (!type[v]))\n        {\n            a[0].push_back(l[v]);\n            continue;\n        }\n        DFS1(v);\n        if(type[v] > 0)\n        {\n            time = l[v];\n            for (int i = 0;i <= l[v];i++) f[u][i] = f[v][i];\n        }\n        else\n        {\n            for (int i = 0; i <= time;i++) temp[i] = f[u][i];\n            for (int i = 0; i <= l[v];i++)\n                for (int j = 0;j <= time;j++) if((temp[j]) && (f[v][i])) f[u][i + j] = 1;\n            time += l[v];\n        }\n        if(u == 1)\n        {\n            leaf[type[v]] = l[v];\n            int pos = type[v];\n            a[pos].resize(f[v].size());\n            for (int i = 0;i < f[v].size();i++) a[pos][i] = f[v][i];\n        }\n        f[v].clear();\n    }\n    if(p[u].size() == 0) f[u][1] = 1;\n    return;\n}\n\nvoid dp()\n{\n    F[0] = 1;\n    if(a[0].size() == 0) return;\n    fill(F + 1,F + n + 1,0);\n    F[a[0][0]] = 1;\n    for (int i = 1;i < a[0].size();i++)\n    {\n        for (int j = 1;j <= n;j++) temp[j] = F[j];\n        for (int j = 1;j + a[0][i] <= n;j++) if(temp[j]) F[j + a[0][i]] = 1;\n    }\n}\nbool check(int x,int y,int z)\n{\n    if(l[1] % 2 == 1) return false;\n    for (int i = 1;i < a[x].size();i++)\n        for (int j = 1;j < a[y].size();j++)\n            if(a[x][i] && a[y][j])\n            {\n                int leafs = l[1]`/2 - (leaf[x] - i) - j - leaf[z];\n                if(F[leafs]) return true;\n            }\n    return false;\n}\nint main()\n{\n    //freopen(\"in.inp\",\"r\",stdin);\n    scanf(\"%d\",&n);\n    for (int i = 1;i <= 4;i++) scanf(\"%d\",&v[i]);\n    for (int i = 2;i <= n;i++)\n    {\n        int x;\n        scanf(\"%d\",&x);\n        p[x].push_back(i);\n    }\n    temp.resize(n + 1);\n    DFS(1);\n    DFS1(1);\n    dp();\n    ck1 = check(1,2,3) && (check(3,4,2));\n    ck2 = check(1,2,4) && (check(3,4,2));\n    if(ck1 || ck2) printf(\"YES\"); else printf(\"NO\");\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "55f220609972a4233687a2e689ee00b2", "src_uid": "87db879f0ca422020125a3e4d99d3c23", "difficulty": 2900.0}
    {"lang": "GNU C++11", "source_code": "#include\n\nusing namespace std;\n\n#define N 200005\n\nint n, l[N], r[N], cnt = 0;\n\nmap  used;\n\nstruct seg\n{\n\tint l, r, coll, colr, cnt, tag;\n}tr[N << 8];\n\nstruct SEG\n{\n\tvoid build(int rt, int l, int r)\n\t{\n\t\ttr[rt].l = l, tr[rt].r = r;\n\t\tif(l == r)\n\t\t{\n\t\t\treturn;\n\t\t}\n\t\tint mid = l + r >> 1;\n\t\tbuild(rt << 1, l, mid);\n\t\tbuild(rt << 1 | 1, mid + 1, r);\n\t}\n\n\tvoid Pushdown(int rt)\n\t{\n\t\tif(tr[rt].tag)\n\t\t{\n\t\t\ttr[rt << 1].tag = tr[rt << 1 | 1].tag = 1;\n\t\t\ttr[rt << 1].cnt = tr[rt << 1 | 1].cnt = 1;\n\t\t\ttr[rt << 1].coll = tr[rt << 1].colr = 1;\n\t\t\ttr[rt << 1 | 1].coll = tr[rt << 1 | 1].colr = 1;\n\t\t}\n\t}\n\n\tvoid Pushup(int rt)\n\t{\n\t\ttr[rt].cnt = tr[rt << 1].cnt + tr[rt << 1 | 1].cnt;\n\t\ttr[rt].coll = tr[rt << 1].coll, tr[rt].colr = tr[rt << 1 | 1].colr;\n\t\tif(tr[rt << 1].colr == 1 && tr[rt << 1 | 1].coll == 1) tr[rt].cnt--;\n\t}\n\n\tvoid update(int rt, int x, int y)\n\t{\n\t\tPushdown(rt);\n\t\tint l = tr[rt].l, r = tr[rt].r, mid = l + r >> 1;\n\t\t// cout << l << ' ' << r << ' ' << x << ' ' << y << endl;\n\t\tif(l == x && r == y)\n\t\t{\n\t\t\ttr[rt].cnt = 1, tr[rt].tag = 1, tr[rt].coll = 1, tr[rt].colr = 1;\n\t\t\treturn;\n\t\t}\n\t\tif(y <= mid) update(rt << 1, x, y);\n\t\telse if(x > mid) update(rt << 1 | 1, x, y);\n\t\telse update(rt << 1, x, mid), update(rt << 1 | 1, mid + 1, y);\n\t\tPushup(rt);\n\t}\n}tree;\n\nint main()\n{\n\tfreopen(\"color.in\",\"r\",stdin);\n\tfreopen(\"color.out\",\"w\",stdout);\n\tscanf(\"%d\", &n);\n\tint maxn = 0;\n\tfor(int i = 1; i <= n; i++)\n\t{\n\t\tscanf(\"%d%d\", &l[i], &r[i]);\n\t\tr[i]--;\n\t\tmaxn = max(maxn, r[i] + 1);\n\t\tif(used[l[i]] == 0)\n\t\t{\n\t\t\tused[l[i]] = ++cnt;\n\t\t}\n\t\tif(used[r[i]] == 0)\n\t\t{\n\t\t\tused[r[i]] = ++cnt;\n\t\t}\n\t\tif(used[r[i] + 1] == 0)\n\t\t{\n\t\t\tused[r[i] + 1] = ++cnt;\n\t\t}\n\t}\n\n\ttree.build(1, 1, maxn);\n\tfor(int i = 1; i <= n; i++)\n\t{\n\t\ttree.update(1, l[i], r[i]);\n\t\tcout << tr[1].cnt << endl;\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ba8e2f283b8b072b7531712c730c4646", "src_uid": "3979abbe7bad0f3b5cab15c1cba19f6b", "difficulty": 2100.0}
    {"lang": "GNU C++11", "source_code": "///God help me.\n\n#include\n\nusing namespace std;\n\n#define mp  make_pair\n\nbool intersect(auto pair&a ,auto pair&b){\n    int lb = max(a.first , b.first);\n    int rb = min(a.second, b.second);\n    return (lb <= rb);\n}\n\nint main()\n{\n    int n , l , r;\n    ios_base::sync_with_stdio(false);\n    cin >> n;\n    set >have;\n    stack >del;\n    for(int i = 1; i<=n; i++){\n        cin >> l >> r;\n        auto it = have.upper_bound(mp(r+1,-1));\n        if(it==have.begin()){\n            have.insert(mp(l,r));\n        }\n        else{\n            it--;\n            while(intersect(*it,mp(l,r))){\n                del.push(*it);\n                r = max(r, it->second);\n                l = min(l, it->first);\n                if(it == have.begin())\n                    break;\n                it--;\n            }\n            while(!del.empty()){\n                have.erase(del.top());\n                del.pop();\n            }\n            have.insert(mp(l,r));\n        }\n        cout << (int)have.size() << \" \";\n    }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3aa68f542f4302b5b5d96503c3f38f12", "src_uid": "3979abbe7bad0f3b5cab15c1cba19f6b", "difficulty": 2100.0}
    {"lang": "GNU C++11", "source_code": "///God help me.\n\n#include\n\nusing namespace std;\n\n#define mp  make_pair\n\nbool intersect(pair&a , pair&b){\n    int lb = max(a.first , b.first);\n    int rb = min(a.second, b.second);\n    return (lb <= rb);\n}\n\nint main()\n{\n    int n , l , r;\n    cin >> n;\n    set >have;\n    stack >del;\n    for(int i = 1; i<=n; i++){\n        cin >> l >> r;\n        auto it = have.upper_bound(mp(r+1,-1));\n        if(it==have.begin()){\n            have.insert(mp(l,r));\n        }\n        else{\n            it--;\n            while(intersect(*it,mp(l,r))){\n                del.push(*it);\n                r = max(r, it->second);\n                l = min(l, it->first);\n                if(it == have.begin())\n                    break;\n                it--;\n            }\n            while(!del.empty()){\n                have.erase(del.top());\n                del.pop();\n            }\n            have.insert(mp(l,r));\n        }\n        cout << (int)have.size() << \" \";\n    }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e779b4c0110f9eef82138b81cda4e507", "src_uid": "3979abbe7bad0f3b5cab15c1cba19f6b", "difficulty": 2100.0}
    {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint a,s,d[200002],f[200002][2],g,h,j,k,l,i,n,m,mx=1000000007;\nstruct tre{\n    pair val;\n    tre *L;\n    tre *R;\n    tre(){\n        val={mx,0};\n        L=NULL;\n        R=NULL;\n    }\n};\nvoid add(tre *&it,int l,int r,int idx,pair val){\n    if(l>idx || r<=idx) return;\n    if(!it) it=new tre();\n    if(l+1==r) {it->val=val;return;}\n    it->val=min(it->val,val);\n    add(it->L,l,(l+r)/2,idx,val);\n    add(it->R,(l+r)/2,r,idx,val);\n}\n\npair get(tre *&it,int l,int r,int lf){\n    if(!it || it->val.first==mx || r<=lf) return {mx,0};\n    if(l+1==r) {return it->val;}\n    pair r1=get(it->L,l,(l+r)/2,lf);\n    if(r1!=mx) return r1;\n    pair r2=get(it->R,(l+r)/2,r,lf);\n    return r2;\n}\n\nint gpar(int idx){\n    if(d[idx]==idx) return idx;\n    else return d[idx]=gpar(d[idx]);\n}\ntre *root;\nmain(){\n    cin>>n;\n    for(i=1;is) break;\n            l--;//cout<\r\n#define itn int\r\n#define pll pair\r\n#define pii pair\r\n#define full(a) a.begin(), a.end()\r\n#define lb(a, n) lower_bound(a.begin(), a.end(), n)\r\n#define ub(a, n) upper_bound(a.begin(), a.end(), n)\r\nusing namespace std;\r\nusing db = double;\r\nusing ll = long long;\r\nusing ull = unsigned long long;\r\nconst ll mod7 = 1e9 + 7;\r\nconst ll mod9 = 1e9 + 9;\r\nconst int N = 1e5 + 5;\r\nconst int len = 500;\r\n///////////////////////////////////////////////////\r\n\r\nvoid solver()\r\n{\r\n    bool a, b, c, d; cin >> a >> b >> c >> d;\r\n\r\n    cout << max(2 * (a && b && c && d), !a || !b || !c || !d) << '\\n';\r\n}\r\n/*\r\n\r\n\r\n\r\n*/\r\n\r\nint main(){\r\n    ios_base::sync_with_stdio(false);\r\n    cin.tie(NULL);\r\n    int tc; cin >> tc; while(tc--)\r\n        solver();\r\n\r\n    return 0;\r\n}\r\n\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "61c8d667ebd360ef085386de132baf4c", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0}
    {"lang": "GNU C++20 (64)", "source_code": "#include\r\nusing namespace std;\r\ntypedef long long ll;\r\nconst ll MAXN=10000;\r\n\r\nvoid solve()\r\n{\r\n    int a,b,c,d;\r\n    cin>>a>>b>>c>>d;\r\n    if(a==0&&b==0&&c==0&&d==0)\r\n        cout<<\"0\"<>t;\r\n\r\n    while(t--)\r\n        solve();\r\n\r\n    return 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f86e010af612f870eb2e1655ceacf33a", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0}
    {"lang": "GNU C++20 (64)", "source_code": "#include \r\nusing namespace std;\r\n\r\nint main() {\r\n  long long int t,i,j,k,a,b,c,d,cnt;\r\n  cin>>t;\r\n  while(t--){\r\n      cnt=0;\r\n      for(i=0;i<4;i++){\r\n          cin>>a;\r\n      if(a==1){\r\n          cnt++;\r\n      }\r\n      }\r\n      if(cnt==4){\r\n          cout<<2<<\"\\n\";\r\n      }\r\n     else if(cnt==3){\r\n          cout<<1<<\"\\n\";\r\n      }\r\n      else if(cnt==2){\r\n          cout<<1<\"\\n\";\r\n      }\r\n      lse if(cnt==1){\r\n          cout<<1<<\"\\n\";\r\n      }\r\n      else{\r\n          cout<<0<<\"\\n\";\r\n      }\r\n      \r\n  }\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c0edd386403224a289e853657e3b746f", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0}
    {"lang": "GNU C++17", "source_code": "#include\r\nusing namespace std;\r\nint main(){\r\n    int n;\r\n    cin >> n;\r\n    int count_ = 0;\r\n    while(n--){\r\n        int arr[2];\r\n        int arr_[2];\r\n        for(int i=0;i<2;i++){\r\n            cin >> arr[i];\r\n        }\r\n        for(int i=0;i<2;i++){\r\n            cin >> arr_[i];\r\n        }\r\n        for(int i=0;i<2;i++){\r\n            if(arr[i]==1){\r\n                count_++;\r\n            }\r\n        }\r\n        for(int i=0;i<2;i++){\r\n            if(arr_[i]==1){\r\n                count_++;\r\n            }\r\n        }\r\n        if(count_==0){\r\n            cout << 0 << endl;\r\n        }\r\n        else if(count_<=3){\r\n            cout << 1 << endl;\r\n        }\r\n        else{\r\n            cout << 2 << endl;\r\n        }\r\n        count = 0;\r\n        \r\n        \r\n    }\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4e6dc0d06d35e5c134e07742d684052c", "src_uid": "7336b8becd2438f0439240ee8f9610ec", "difficulty": 800.0}
    {"lang": "GNU C++", "source_code": "#define _CRT_SECURE_NO_DEPRECATE\n#define _SECURE_SCL 0\n#pragma comment(linker, \"/STACK:200000000\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define pb push_back\n#define mp make_pair\n#define mset(mas,val) memset(mas,val,sizeof(mas))\n#define sz(a) (int)(a).size()\n#define all(a) (a).begin(), (a).end()\n#define rall(a) (a).rbegin(), (a).rend()\n\n#define forn(i,n) for (int i=0; i=0; --i)\n#define forab(i,a,b) for (int i=int(a); i g[N * N];\nint prio[N * N], curflow[N * N], prevedge[N * N], prevnode[N * N], q[N * N], pot[N * N], inqueue[N * N];\n\nvoid add_edge(int s, int t, int cap, int cost) {\n\tedge fi = {t, 0, cap, cost, sz(g[t])};\n\tedge se = {s, 0, 0, -cost, sz(g[s])};\n\tg[s].push_back(fi);\n\tg[t].push_back(se);\n}\nint NN = N * N;\nint mincost() {\n\tint flow = 0, maxflow = (n * m) >> 1;\n\tint answer = 0;\n\tint s = 0;\n\tint t = n * m + 2;\n\twhile (flow < maxflow) {\n\t\tpriority_queue< ll, vector , greater > q;\n\t\tq.push(s);\n\t\tfill(prio, prio + NN, INT_MAX);\n\t\tprio[s] = 0;\n\t\tcurflow[s] = INT_MAX;\n\t\twhile (!q.empty()) {\n\t\t\tll cur = q.top();\n\t\t\tint d = cur >> 32;\n\t\t\tint u = cur;\n\t\t\tq.pop();\n\t\t\tif (d != prio[u]) continue;\n\t\t\tforn(i, sz(g[u])) {\n\t\t\t\tedge &e = g[u][i];\n\t\t\t\tint v = e.to;\n\t\t\t\tif (e.cap <= e.f) continue;\n\t\t\t\tint nprio = prio[u] + e.cost + pot[u] - pot[v];\n\t\t\t\tif (prio[v] > nprio) {\n\t\t\t\t\tprio[v] = nprio;\n\t\t\t\t\tq.push(((ll) nprio << 32) + v);\n\t\t\t\t\tprevnode[v]  = u;\n\t\t\t\t\tprevedge[v] = i;\n\t\t\t\t\tcurflow[v] = min(curflow[u], e.cap - e.f);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (prio[t] == INT_MAX)\n\t\t\tbreak;\n\t\tfor (int i = 0; i < NN; i++)\n\t\t\tpot[i] += prio[i];\n\t\tint df = min(curflow[t], maxflow - flow);\n\t\t\tflow += df;\n\t\tfor (int v = t; v != s; v = prevnode[v]) {\n\t\t  edge &e = g[prevnode[v]][prevedge[v]];\n\t\t  e.f += df;\n\t\t  g[v][e.rev].f -= df;\n\t\t  answer += df * e.cost;\n\t\t}\n\t}\n\treturn answer;\n}\n\ninline bool read()\n{\n\tif (scanf(\"%d %d\", &n, &m) != 2) return false;\n\tforn(i,n) {\n\t\tforn(j, m) {\n\t\t\tassert(scanf(\"%d\", &a[i][j]) == 1);\n\t\t}\n\t}\n\treturn true;\n}\n\nvoid solve()\n{\n\tforn(i,n) {\n\t\tforn(j,m) {\n\t\t\tif (((i + j) & 1) == 0) {\n\t\t\t\tforn(cur, 4) {\n\t\t\t\t\tint nx = i + dx[cur];\n\t\t\t\t\tint ny = j + dy[cur];\n\t\t\t\t\tif (nx >= 0 && ny >= 0 && nx < n && ny < m) {\n\t\t\t\t\t\tadd_edge(i * m + j + 1, nx * m + ny + 1, 1, (a[i][j] != a[nx][ny])); \n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tadd_edge(0, i * m + j + 1, 1, 0);\n\t\t\t} else {\n\t\t\t\tadd_edge(i * m + j + 1, n * m + 2, 1, 0);\n\t\t\t}\n\t\t}\n\t}\n\tcout << mincost() << endl;\n}\n\nint main()\n{\n\twhile (read()) solve();\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b8e6da848cc0efc33830dc2ad925df31", "src_uid": "1f0e8bbd5bf4fcdea927fbb505a8949b", "difficulty": 2200.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nconst int Maxm=12*6405,Maxn=6405;\nconst int dirx[4]={-1,1,0,0};\nconst int diry[4]={0,0,-1,1};\n\nint Cou;\nint v[Maxm],next[Maxm],root[Maxm],val[Maxm],c[Maxm],q[50*Maxn],from[Maxn],edge[Maxn],dis[Maxn];\nbool yes[Maxn],vis[85][85];\nint S,T,Ans,Sum,N,M,l[Maxn];\nint a[85][85],b[85][85];\n\nvoid insert(int father,int son,int cap,int cost)\n{\n    Cou++;\n    v[Cou]=son;\n    next[Cou]=root[father];\n    c[Cou]=cap;\n    val[Cou]=cost;\n    root[father]=Cou; \n}\n\nbool SPFA()\n{\n    for (int i=S; i<=T; i++) dis[i]=1<<30;\n    dis[S]=0;\n    int tail=1;\n    q[1]=S;\n    memset(yes,true,sizeof(yes));\n    yes[S]=false;\n    for (int head=1; head<=tail; head++)\n    {\n      for (int x=root[q[head]]; x!=-1; x=next[x])\n        if (c[x]>0)\n        {\n                   if (dis[q[head]]+val[x]\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int nmax = 80 * 80 / 2;\nconst int Nm = nmax * 2 + 2;\nconst int Mm = 2 * nmax * 4;\nconst int INF = 1000000000;\n\nclass costflow {\n    int s[Nm], q[Nm], pre[Nm], v[Nm]; // Ns\n    int t[Mm], next[Mm], cf[Mm]; // Ms\n    int w[Mm], d[Nm];\n    int cnt;\n    int N;\n\npublic:\n\n    void init(int n) {\n        cnt = 1;\n        N = n;\n        memset(s, 0, sizeof (s));\n        memset(d, 0, sizeof (d));\n        memset(q, 0, sizeof (q));\n        memset(pre, 0, sizeof (pre));\n        memset(v, 0, sizeof (v));\n\n        memset(t, 0, sizeof (t));\n        memset(cf, 0, sizeof (cf));\n        memset(w, 0, sizeof (w));\n        memset(next, 0, sizeof (next));\n    }\n\n    void add(int ss, int tt, int cc, int ww) {\n        ++cnt;\n        t[cnt] = tt;\n        cf[cnt] = cc;\n        w[cnt] = ww;\n        next[cnt] = s[ss];\n        s[ss] = cnt;\n        ++cnt;\n        t[cnt] = ss;\n        cf[cnt] = 0;\n        w[cnt] = -ww;\n        next[cnt] = s[tt];\n        s[tt] = cnt;\n    }\n\n    pair getflow(int S, int T) {\n        int cost = 0;\n        int flow = 0;\n        int i, j, head, tail;\n        while (true) {\n            head = 0;\n            tail = 1;\n            for (i = 0; i < N; i++) {\n                d[i] = INF;\n            }\n            for (i = 0; i < N; i++) {\n                v[i] = 0;\n            }\n            d[S] = 0;\n            q[1] = S;\n            while (head != tail) {\n                v[i = q[head = (head + 1) % N]] = 0;\n                for (j = s[i]; j != 0; j = next[j]) {\n                    if (cf[j] != 0 && d[t[j]] > d[i] + w[j]) {\n                        d[t[j]] = d[i] + w[j];\n                        pre[t[j]] = j;\n                        if (v[t[j]] == 0) {\n                            v[t[j]] = 1;\n                            q[tail = (tail + 1) % N] = t[j];\n                        }\n                    }\n                }\n            }\n            if (d[T] == INF) {\n                return make_pair(flow, cost);\n            }\n            cost += d[T];\n            ++flow;\n            for (i = T; i != S; i = t[pre[i] ^ 1]) {\n                --cf[pre[i]];\n                ++cf[pre[i] ^ 1];\n            }\n        }\n    }\n} network;\n\nint a[80][80];\n\nint main()\n{\n\t//freopen(\"counter.in\", \"r\", stdin);\n\t//freopen(\"counter.out\", \"w\", stdout);\n\n\tstring s;\n\tint i, j, k, n, m;\n\t\n\tcin >> n >> m;\n\tfor(i = 0; i < n; i++)\n\t\tfor(j = 0; j < m; j++)\n\t\t\tcin >> a[i][j];\n\n\tconst int di[4] = {-1, 0, 1, 0};\n\tconst int dj[4] = {0, 1, 0, -1};\n\tnetwork.init(2 + n * m);\n\tfor(i = 0; i < n; i++)\n\t\tfor(j = 0; j < m; j++)\n\t\t\tif ((i + j) % 2 == 0)\n\t\t\t{\n\t\t\t\tfor(int d = 0; d < 4; d++)\n\t\t\t\t{\n\t\t\t\t\tint ii = i + di[d];\n\t\t\t\t\tint jj = j + dj[d];\n\t\t\t\t\tif (ii < 0 || ii >= n || jj < 0 || jj >= m)\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t//cout << i << \" \" << j << \" - \" << ii << \" \" << jj << \": \" << (a[i][j] != a[ii][jj]) << endl;\n\t\t\t\t\tnetwork.add(i * m + j, ii * m + jj, 1, (a[i][j] != a[ii][jj]));\n\t\t\t\t}\n\t\t\t\tnetwork.add(n * m, i * m + j, 1, 0);\n\t\t\t} else\n\t\t\t\tnetwork.add(i * m + j, n * m + 1, 1, 0);\n\tcout << network.getflow(n * m, n * m + 1).second << endl;\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0c7b7cb1d16107a9d87b68346dd9f36c", "src_uid": "1f0e8bbd5bf4fcdea927fbb505a8949b", "difficulty": 2200.0}
    {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n/**\n * @author: Shamir14 -- Amirhossein Shapoori\n * lordamir14@gmail.com\n * ACM team: AnotherChorMangz\n * Tehran, Iran\n * Still listening to Mark Knopfler...\n * :P\n */\n #define pb push_back\n\n typedef long long lli;\n const int maxn = 64 + 10, MOD = 1000 * 1000 * 1000 + 7;\n int n, m;\n int ori[maxn][maxn], vis[maxn][maxn], board[maxn][maxn];\n int ax[] = {1, 0, -1, 0}, ay[] = {0, -1, 0, 1};\n\n bool inrange(int x, int y){\n        if(x >= 0 && x < m && y >= 0 && y < n)\n            return true;\n        return false;\n}\n\n int Check(){\n    int ans = n * m / 2, i, j, x, y;\n    for(i = 0; i < maxn; i++)\n        for(j = 0; j < maxn; j++)\n            vis[i][j] = 0;\n//  cerr << endl;\n//   for(i = 0; i < n; i++){\n//       for(j = 0; j < m; j++)\n//          cerr << ori[j][i] << \" \";\n//       cerr << endl;\n//   }\n//    cerr << ans << endl;\n    for(i = 0; i < m; i++)\n        for(j = 0; j < n; j++)\n            if(!vis[i][j]){\n                x = i + ax[ori[i][j]];\n                y = j + ay[ori[i][j]];\n                vis[i][j] = vis[x][y] = 1;\n                if(board[i][j] == board[x][y])\n            //        cerr << i << \", \" << j << \"    \";\n                    ans--;\n                //if(ans == 9){\n                  //  cerr << i << \", \" << j << \"  ||  \" << x << \", \" << y << \"      \";\n                   // break;\n               // }\n            }\n//    if (ans == 9){\n//      cerr << endl;\n//   for(i = 0; i < n; i++){\n//       for(j = 0; j < m; j++)\n//          cerr << ori[j][i] << \" \";\n//       cerr << endl;\n//   }\n//    }\n    return ans;\n }\n\n int mini;\n\n\n\n void Make(int i, int j){\n        int x, y;\n        if(ori[i][j] == -1){\n            for(int k = 0; k < 4; k++){\n                x = i + ax[k];\n                y = j + ay[k];\n                if(inrange(x, y) && ori[x][y] == -1){\n                    ori[i][j] = k;\n                    ori[x][y] = (k + 2) % 4;\n                    if(i + 1 < m)\n                        Make(i + 1, j);\n                    else\n                        if(j + 1 < n)\n                            Make(0, j + 1);\n                        else\n                            mini = min(Check(), mini);\n                    if(mini == 0)\n                        break;\n                    ori[i][j] = ori[x][y] = -1;\n                }\n            }\n        }else{\n            if(i + 1 < m)\n                Make(i + 1, j);\n            else\n                if(j + 1 < n)\n                    Make(0, j + 1);\n                else\n                    mini = min(Check(), mini);\n            if(mini == 0)\n                break;\n        }\n }\n\n\n\n\nint main(){\n    //freopen(\"input.txt\", \"r\", stdin);\n    //freopen(\"output.txt\", \"w\", stdout);\n    mini = 1000000;\n    int i, j;\n    cin >> n >> m;\n    for(i = 0; i < maxn; i++)\n        for(j = 0; j < maxn; j++)\n            ori[i][j] = -1;\n    for(i = 0; i < n; i++)\n        for(j = 0; j < m; j++)\n            cin >> board[j][i];\n\n    Make(0, 0);\n\n    cout << mini << endl;\n\n\n    return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f42c5d316cb9b5ad9a9863254b31479a", "src_uid": "1f0e8bbd5bf4fcdea927fbb505a8949b", "difficulty": 2200.0}
    {"lang": "GNU C++14", "source_code": "#include \n#define NN 300100\n#define inf 0x3f3f3f3f3f3f3f3f\nusing namespace std;\nusing INT = long long;\nusing pii = pair;\n\nint p[NN];\nINT dp[NN][2];\nint vst[NN];\nvector ans;\nint N;\nint val, flag = 1;\nvoid calc(int n){\n\tif(dp[n][0] == val){\n\t\tif(n > 2 && min(dp[n - 2][0], dp[n - 2][1]) == val - max(p[n], p[n - 1])){\n\t\t\tif(!vst[n - 1]) {\n\t\t\t\tint V = min(p[n - 1], p[n]);\n\t\t\t\tif(V) ans.push_back(n - 1);\n\t\t\t\tvst[n - 1] = 1;\n\t\t\t\tval -= V;\n\t\t\t\tif(!val) return ;\n\t\t\t\tp[n - 1] -= V; p[n] -= V;\n\t\t\t}\n\t\t\tif(n != N) {\n\t\t\t\tif(!vst[n]) {\n\t\t\t\t\tint V = min(p[n + 1], p[n]);\n\t\t\t\t\tif(V) ans.push_back(n);\n\t\t\t\t\tvst[n] = 1;\n\t\t\t\t\tval -= V;\n\t\t\t\t\tif(!val) return ;\n\t\t\t\t\tp[n + 1] -= V; p[n] -= V;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(!vst[n - 2]){\n\t\t\t\tint V = min(p[n - 2], p[n - 1]);\n\t\t\t\tif(V) ans.push_back(n - 2);\n\t\t\t\tvst[n - 2] = 1;\n\t\t\t\tval -= V;\n\t\t\t\tp[n - 2] -= V; p[n - 1] -= V;\n\t\t\t}\n\t\t\tflag = 2;\n\t\t\treturn ;\n\t\t}\n\t\tif(n > 1) {\n\t\t\tif(!vst[n - 1]) {\n\t\t\t\tint V = min(p[n - 1], p[n]);\n\t\t\t\tif(V) ans.push_back(n - 1);\n\t\t\t\tvst[n - 1] = 1;\n\t\t\t\tval -= V;\n\t\t\t\tif(!val) return ;\n\t\t\t\tp[n - 1] -= V; p[n] -= V;\n\t\t\t}\n\t\t}\n\t\tif(n != N) {\n\t\t\tif(!vst[n]){\n\t\t\t\tint V = min(p[n + 1], p[n]);\n\t\t\t\tif(V)ans.push_back(n);\n\t\t\t\tvst[n] = 1;\n\t\t\t\tval -= V;\n\t\t\t\tp[n + 1] -= V; p[n] -= V;\n\t\t\t}\n\t\t}\n\t}\n}\n\nint main(){\n#ifndef ONLINE_JUDGE\n\tfreopen(\"in.in\",\"r\",stdin);\n\tfreopen(\"out.out\",\"w\",stdout);\n#endif\n\tios_base :: sync_with_stdio(0);cin.tie(0);\n\tint n;\n\tcin >> n;\n\tfor(int i = 1; i <= n; i++) cin >> p[i];\n\tfor(int i = 1; i <= n; i++) for(int j = 0; j < 2; j++) dp[i][j] = inf;\n\tdp[1][0] = p[1], dp[1][1] = 0;\n\tfor(int i = 2; i <= n; i++){\n\t\tdp[i][0] = min(dp[i - 1][1], dp[i - 1][0]) + p[i];\n\t\tif(i > 2) dp[i][0] = min(dp[i][0], min(dp[i - 2][0], dp[i - 2][1]) + max(p[i], p[i - 1]));\n\t\tdp[i][1] = dp[i - 1][0];\n\t}\n\tval = min(dp[n][1], dp[n][0]);\n//\tfor(int i = 1; i <= n; i++) cout << dp[i][0]<<\" \"<= 0) {\n//\t\tcout << val << \" \"<< n <\n#define NN 300100\n#define inf 0x3f3f3f3f3f3f3f3f\nusing namespace std;\nusing INT = long long;\nusing pii = pair;\n\nint p[NN];\nINT dp[NN][2];\nint vst[NN];\nvector ans;\nint N;\nint val, flag = 1;\nvoid calc(int n){\n\tif(dp[n][0] == val){\n\t\tif(n >= 2 && min(dp[n - 2][0], dp[n - 2][1]) == val - max(p[n], p[n - 1])){\n\t\t\tif(!vst[n - 1]) {\n\t\t\t\tint V = min(p[n - 1], p[n]);\n\t\t\t\tif(V) ans.push_back(n - 1);\n\t\t\t\tvst[n - 1] = 1;\n\t\t\t\tval -= V;\n\t\t\t\tif(!val) return ;\n\t\t\t\tp[n - 1] -= V; p[n] -= V;\n\t\t\t}\n\t\t\tif(n != N) {\n\t\t\t\tif(!vst[n]) {\n\t\t\t\t\tint V = min(p[n + 1], p[n]);\n\t\t\t\t\tif(V) ans.push_back(n);\n\t\t\t\t\tvst[n] = 1;\n\t\t\t\t\tval -= V;\n\t\t\t\t\tif(!val) return ;\n\t\t\t\t\tp[n + 1] -= V; p[n] -= V;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(!vst[n - 2]){\n\t\t\t\tint V = min(p[n - 2], p[n - 1]);\n\t\t\t\tif(V) ans.push_back(n - 2);\n\t\t\t\tvst[n - 2] = 1;\n\t\t\t\tval -= V;\n\t\t\t\tp[n - 2] -= V; p[n - 1] -= V;\n\t\t\t}\n\t\t\tflag = 2;\n\t\t\treturn ;\n\t\t}\n\t\tif(n > 1) {\n\t\t\tif(!vst[n - 1]) {\n\t\t\t\tint V = min(p[n - 1], p[n]);\n\t\t\t\tif(V) ans.push_back(n - 1);\n\t\t\t\tvst[n - 1] = 1;\n\t\t\t\tval -= V;\n\t\t\t\tif(!val) return ;\n\t\t\t\tp[n - 1] -= V; p[n] -= V;\n\t\t\t}\n\t\t}\n\t\tif(n != N) {\n\t\t\tif(!vst[n]){\n\t\t\t\tint V = min(p[n + 1], p[n]);\n\t\t\t\tif(V)ans.push_back(n);\n\t\t\t\tvst[n] = 1;\n\t\t\t\tval -= V;\n\t\t\t\tp[n + 1] -= V; p[n] -= V;\n\t\t\t}\n\t\t}\n\t}\n}\n\nint main(){\n#ifndef ONLINE_JUDGE\n\tfreopen(\"in.in\",\"r\",stdin);\n\tfreopen(\"out.out\",\"w\",stdout);\n#endif\n\tios_base :: sync_with_stdio(0);cin.tie(0);\n\tint n;\n\tcin >> n;\n\tfor(int i = 1; i <= n; i++) cin >> p[i];\n\tfor(int i = 1; i <= n; i++) for(int j = 0; j < 2; j++) dp[i][j] = inf;\n\tdp[1][0] = p[1], dp[1][1] = 0;\n\tfor(int i = 2; i <= n; i++){\n\t\tdp[i][0] = min(dp[i - 1][1], dp[i - 1][0]) + p[i];\n\t\tif(i >= 2) dp[i][0] = min(dp[i][0], min(dp[i - 2][0], dp[i - 2][1]) + max(p[i], p[i - 1]));\n\t\tdp[i][1] = dp[i - 1][0];\n\t}\n\tval = min(dp[n][1], dp[n][0]);\n//\tfor(int i = 1; i <= n; i++) cout << dp[i][0]<<\" \"<\nusing namespace std;\n#define rep(i,a,n) for (int i=a;i=a;i--)\n#define pb push_back\n#define mp make_pair\n#define all(x) (x).begin(),(x).end()\n#define fi first\n#define se second\n#define SZ(x) ((int)(x).size())\ntypedef vector VI;\ntypedef long long ll;\ntypedef pair PII;\nconst ll mod=1000000007;\nll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}\nll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}\n// head\n\nconst int N=301000;\nmap dp[N];\nmap pre[N],way[N];\nint n,a[N];\nPII cur;\nVI ret,ret2;\nvoid upd(int p,int v,ll cost,PII ww) {\n\tif (!dp[p].count(v)||cost=a[i+2]) upd(i+2,0,w+a[i+2]+min(v,(a[i+1]-a[i+2])),mp(i,i+1));\n\t\t}\n\t}\n\tint mv=-1; ll w=1ll<<60;\n\tfor (auto p:dp[n]) if (p.se0&&a[p+1]>0) {\n\t\t\tint z=min(a[p],a[p+1]);\n\t\t\ta[p]-=z; a[p+1]-=z;\n\t\t\tret2.pb(p);\n\t\t}\n\t}\n\tprintf(\"%d\\n\",SZ(ret2));\n\tfor (auto p:ret2) printf(\"%d \",p);\n\tputs(\"\");\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ce7aa4a69521fc5b03048fdac5e96e6a", "src_uid": "8ed6af24a3d9f249fe6ba68efbe787e4", "difficulty": 3200.0}
    {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define rep(i,a,n) for (int i=a;i=a;i--)\n#define pb push_back\n#define mp make_pair\n#define all(x) (x).begin(),(x).end()\n#define fi first\n#define se second\n#define SZ(x) ((int)(x).size())\ntypedef vector VI;\ntypedef long long ll;\ntypedef pair PII;\nconst ll mod=1000000007;\nll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}\nll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}\n// head\n\nconst int N=301000;\nmap dp[N];\nmap pre[N],way[N];\nint n,a[N];\nPII cur;\nVI ret,ret2;\nvoid upd(int p,int v,ll cost,PII ww) {\n\tif (!dp[p].count(v)||cost=a[i+2]) upd(i+2,0,w+a[i+2]+min(v,(a[i+1]-a[i+2])),mp(i,i+1));\n\t\t}\n\t}\n\tint mv=-1; ll w=1ll<<60;\n\tfor (auto p:dp[n]) if (p.se0&&a[p+1]>0) {\n\t\t\tint z=min(a[p],a[p+1]);\n\t\t\ta[p]-=z; a[p+1]-=z;\n\t\t\tret2.pb(p);\n\t\t}\n\t}\n\tprintf(\"%d\\n\",SZ(ret2));\n\tfor (auto p:ret2) printf(\"%d \",p);\n\tputs(\"\");\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3cf8e52024be9f11f42027c9e29aa7e9", "src_uid": "8ed6af24a3d9f249fe6ba68efbe787e4", "difficulty": 3200.0}
    {"lang": "GNU C++17", "source_code": "//\u5b89\u5229\u5c11\u6b4c\n#include\n#define For(i,x,y) for (register int i=(x);i<=(y);i++)\n#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)\n#define mp make_pair\n#define fi first\n#define se second\n#define pb push_back\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair pa;\ninline ll read(){\n    ll x=0,f=1;char c=getchar();\n    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();\n    if (c=='-') f=-1,c=getchar();\n    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();\n    return x*f;\n}\n\nconst int N = 3e4+10;\nint n;\nvectore[N];\n\nint cnt,p[N],fa[N],vis[N];\nbool flag[N];\ninline void dfs(int u){\n\tvis[u]=1;\n\tfor (auto v:e[u]){\n\t\tif (v==fa[u]) continue;\n\t\tfa[v]=u;\n\t\tif (!vis[v]) dfs(v);\n\t\telse {\n\t\t\tfor (int now=u;now!=v;now=fa[now]) flag[p[++cnt]=now]=1;\n\t\t\tflag[p[++cnt]=v]=1;\n\t\t}\n\t\tif (cnt) break;\n\t}\n}\n\nll f[N],g[N],size[N];\ninline void dfs(int u,int fa){\n\tsize[u]=1;\n\tfor (auto v:e[u]){\n\t\tif (v==fa||flag[v]) continue;\n\t\tdfs(v,u),f[u]+=g[v],size[u]+=size[v];\n\t}\n\tg[u]=f[u]+size[u];\n}\n\nll dp[N],last[N],pre[N],ans;\ninline void dfs(int u,int fa,ll sum){\n\tans=max(ans,sum+n+f[u]);\n\tfor (auto v:e[u]) if (v!=fa) dfs(v,u,sum+n-size[v]+f[u]-g[v]);\n}\ninline void solve(){\n\tll sum=0;\n\tFor(i,1,cnt*2) last[i]=size[p[i]],pre[i]=pre[i-1]+last[i],sum+=f[p[i]]; \n\tFor(i,2,cnt-1){\n\t\tFor(l,1,cnt*2-i+1){\n\t\t\tint r=l+i-1;\n\t\t\tll tmp=pre[r]-pre[l-1];\n\t\t\tdp[l]=max(last[l]+tmp,last[l+1]+tmp);\n\t\t}\n\t\tFor(j,1,cnt*2-i+1) last[j]=dp[j];\n\t}\n//\tFor(i,1,cnt) printf(\"%d \",dp[i+1]);puts(\"\"); \n//\tFor(i,1,cnt) printf(\"%d \",f[p[i]]);puts(\"\");\n\tans=0;\n\tFor(i,1,cnt){\n\t\tans=max(ans,n+sum/2+dp[i+1]);\n\t\tfor (auto v:e[p[i]]) if (!flag[v]) dfs(v,p[i],n-size[p[i]]+1+sum/2-f[p[i]]+dp[i+1]);\n\t}\n\tprintf(\"%lld\\n\",ans);\n}\n\nint main(){\n\tn=read();\n\tFor(i,1,n){\n\t\tint x=read()+1,y=read()+1;\n\t\te[x].pb(y),e[y].pb(x);\n\t}\n\tdfs(1);\n\tFor(i,1,cnt) dfs(p[i],0);\n//\tFor(i,1,cnt) printf(\"%d \",p[i]);puts(\"\");\n\tFor(i,1,cnt) p[cnt+i]=p[i];\n\tsolve();\n}\n/*\n10\n0 1\n0 3\n0 4\n0 9\n1 2\n2 3\n2 7\n4 5\n4 6\n7 8\n*/", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c280422fd185dfa62983686f80312766", "src_uid": "c3da92d4b495d3e99c83a5ffe206709a", "difficulty": 2800.0}
    {"lang": "GNU C++11", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long LL;\n\ninline char gc() {\n\tstatic const LL L = 233333;\n\tstatic char sxd[L], *sss = sxd, *ttt = sxd;\n\tif (sss == ttt) {\n\t\tttt = (sss = sxd) + fread(sxd, 1, L, stdin);\n\t\tif (sss == ttt) {\n\t\t\treturn EOF;\n\t\t}\n\t}\n\treturn *sss++;\n}\n\n#ifndef dd\n#define dd c = gc()\n#endif\ninline char readalpha() {\n\tchar dd;\n\tfor (; !isalpha(c); dd);\n\treturn c;\n}\n\ninline char readchar() {\n\tchar dd;\n\tfor (; c == ' '; dd);\n\treturn c;\n}\n\ntemplate \ninline bool read(T& x) {\n\tbool flg = false;\n\tchar dd;\n\tx = 0;\n\tfor (; !isdigit(c); dd) {\n\t\tif (c == '-') {\n\t\t\tflg = true;\n\t\t} else if(c == EOF) {\n\t\t\treturn false;\n\t\t}\n\t}\n\tfor (; isdigit(c); dd) {\n\t\tx = (x << 1) + (x << 3) + (c ^ 48);\n\t}\n\tif (flg) {\n\t\tx = -x;\n\t}\n\treturn true;\n}\n#undef dd\n\ntemplate \ninline void write(T x) {\n\tif (x < 0) {\n\t\tputchar('-');\n\t\tx = -x;\n\t}\n\tif (x < 10) {\n\t\tputchar(x | 48);\n\t\treturn;\n\t}\n\twrite(x / 10);\n\tputchar((x % 10) | 48);\n}\n\nconst int maxn = 15005;\n\nint n;\n\nstruct Edge {\n\tint to, nxt;\n} e[maxn];\n\nint first[maxn];\n\ninline void add_edge(int from, int to) {\n\tstatic int cnt = 0;\n\te[++cnt].nxt = first[from];\n\tfirst[from] = cnt;\n\te[cnt].to = to;\n\te[++cnt].nxt = first[to];\n\tfirst[to] = cnt;\n\te[cnt].to = from;\n}\n\nLL dpw[maxn];\nLL dpn[maxn];\nint siz[maxn];\nint huan[maxn];\nint hs;\nstack st;\nbool vis[maxn];\nbool oh[maxn];\n\ninline bool dfsh(int now, int fa) {\n\tvis[now] = true;\n\tst.push(now);\n\tfor (int i = first[now]; i; i = e[i].nxt) {\n\t\tint to = e[i].to;\n\t\tif (to != fa) {\n\t\t\tif (vis[to]) {\n\t\t\t\twhile(st.top() != to) {\n\t\t\t\t\thuan[++hs] = st.top();\n\t\t\t\t\tst.pop();\n\t\t\t\t}\n\t\t\t\thuan[++hs] = to;\n\t\t\t\tst.pop();\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (dfsh(to, now)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\tst.pop();\n\treturn false;\n}\n\ninline void dfss(int now, int fa) {\n\tsiz[now] = 1;\n\tfor (int i = first[now]; i; i = e[i].nxt) {\n\t\tint to = e[i].to;\n\t\tif (!oh[to] && to != fa) {\n\t\t\tdfss(to, now);\n\t\t\tsiz[now] += siz[to];\n\t\t}\n\t}\n}\n\ninline void dfs1(int now, int fa) {\n\tdpn[now] = siz[now];\n\tfor (int i = first[now]; i; i = e[i].nxt) {\n\t\tint to = e[i].to;\n\t\tif (!oh[to] && to != fa) {\n\t\t\tdfs1(to, now);\n\t\t\tdpn[now] += dpn[to];\n\t\t}\n\t}\n}\n\nLL dp[maxn][maxn];\nLL xx[maxn];\nLL qzh[maxn];\n\ninline LL sum(int l, int r) {\n\tif (l <= r) {\n\t\treturn qzh[r] - qzh[l - 1];\n\t} else {\n\t\tswap(l, r);\n\t\tl++, r--;\n\t\treturn qzh[hs] + qzh[l - 1] - qzh[r];\n\t}\n}\n\ninline int pre(int x) {\n\treturn (x - 2 + hs) % hs + 1;\n}\n\ninline int nxt(int x) {\n\treturn x % hs + 1;\n}\n\ninline void dfsall(int now, int fa) {\n\tfor (int i = first[now]; i; i = e[i].nxt) {\n\t\tint to = e[i].to;\n\t\tif (!oh[to] && to != fa) {\n\t\t\tdpw[to] = dpw[now] + dpn[now] - dpn[to] - siz[to];\n\t\t\tdfsall(to, now);\n\t\t}\n\t}\n}\n\nint main() {\n\tread(n);\n\tfor (int i = 1; i <= n; ++i) {\n\t\tint f, t;\n\t\tread(f), read(t);\n\t\tf++, t++;\n\t\tadd_edge(f, t);\n\t}\n\tdfsh(1, 0);\n//\tcout << \"huan = \";\n\tfor (int i = 1; i <= hs; ++i) {\n//\t\tcout << huan[i] << ' ';\n\t\toh[huan[i]] = true;\n\t}\n//\tcout << endl;\n\tfor (int i = 1; i <= hs; ++i) {\n\t\tdfss(huan[i], 0);\n\t\tdfs1(huan[i], 0);\n\t}\n//\tcout << \"dpn = \";\n//\tfor (int i = 1; i <= n; ++i) {\n//\t\tcout << dpn[i] << ' ';\n//\t}\n//\tcout << endl;\n\tfor (int i = 1; i <= hs; ++i) {\n\t\txx[i] = dpn[huan[i]];\n\t\tqzh[i] = qzh[i - 1] + xx[i];\n\t}\n\tfor (int i = 1; i <= hs; ++i) {\n\t\tdp[i][i] = xx[i];\n\t}\n\tfor (int len = 2; len < hs; ++len) {\n\t\tfor (int l = 1; l <= hs; ++l) {\n\t\t\tint r = (l + len - 2) % hs + 1;\n\t\t\tdp[l][r] = max(dp[nxt(l)][r], dp[l][pre(r)]) + sum(l, r);\n//\t\t\tcout << l << ' ' << r << ' ' << dp[l][r] << ' ' << sum(l, r) << ' ' << nxt(l) << ' ' << pre(r) << endl;\n\t\t}\n\t}\n//\tcout << \"xx = \";\n\tfor (int i = 1; i <= hs; ++i) {\n\t\tdpw[huan[i]] = dp[nxt(i)][pre(i)];\n\t\tdfsall(huan[i], 0);\n//\t\tcout << dpw[huan[i]] << ' ';\n\t}\n//\tcout << endl;\n\tLL ans = 0;\n\tfor (int i = 1; i <= n; ++i) {\n\t\tans = max(ans, dpw[i] + dpn[i] + n - siz[i]);\n\t}\n\tprintf(\"%lld\", ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0c19823689ee87f34c91a9cb12f62bfa", "src_uid": "c3da92d4b495d3e99c83a5ffe206709a", "difficulty": 2800.0}
    {"lang": "GNU C++11", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long LL;\n\ninline char gc() {\n\tstatic const LL L = 233333;\n\tstatic char sxd[L], *sss = sxd, *ttt = sxd;\n\tif (sss == ttt) {\n\t\tttt = (sss = sxd) + fread(sxd, 1, L, stdin);\n\t\tif (sss == ttt) {\n\t\t\treturn EOF;\n\t\t}\n\t}\n\treturn *sss++;\n}\n\n#ifndef dd\n#define dd c = gc()\n#endif\ninline char readalpha() {\n\tchar dd;\n\tfor (; !isalpha(c); dd);\n\treturn c;\n}\n\ninline char readchar() {\n\tchar dd;\n\tfor (; c == ' '; dd);\n\treturn c;\n}\n\ntemplate \ninline bool read(T& x) {\n\tbool flg = false;\n\tchar dd;\n\tx = 0;\n\tfor (; !isdigit(c); dd) {\n\t\tif (c == '-') {\n\t\t\tflg = true;\n\t\t} else if(c == EOF) {\n\t\t\treturn false;\n\t\t}\n\t}\n\tfor (; isdigit(c); dd) {\n\t\tx = (x << 1) + (x << 3) + (c ^ 48);\n\t}\n\tif (flg) {\n\t\tx = -x;\n\t}\n\treturn true;\n}\n#undef dd\n\ntemplate \ninline void write(T x) {\n\tif (x < 0) {\n\t\tputchar('-');\n\t\tx = -x;\n\t}\n\tif (x < 10) {\n\t\tputchar(x | 48);\n\t\treturn;\n\t}\n\twrite(x / 10);\n\tputchar((x % 10) | 48);\n}\n\nconst int maxn = 15005;\n\nint n;\n\nstruct Edge {\n\tint to, nxt;\n} e[maxn << 1];\n\nint first[maxn];\n\ninline void add_edge(int from, int to) {\n\tstatic int cnt = 0;\n\te[++cnt].nxt = first[from];\n\tfirst[from] = cnt;\n\te[cnt].to = to;\n\te[++cnt].nxt = first[to];\n\tfirst[to] = cnt;\n\te[cnt].to = from;\n}\n\nLL dpw[maxn];\nLL dpn[maxn];\nint siz[maxn];\nint huan[maxn];\nint hs;\nstack st;\nbool vis[maxn];\nbool oh[maxn];\n\ninline bool dfsh(int now, int fa) {\n\tvis[now] = true;\n\tst.push(now);\n\tfor (int i = first[now]; i; i = e[i].nxt) {\n\t\tint to = e[i].to;\n\t\tif (to != fa) {\n\t\t\tif (vis[to]) {\n\t\t\t\twhile(st.top() != to) {\n\t\t\t\t\thuan[++hs] = st.top();\n\t\t\t\t\tst.pop();\n\t\t\t\t}\n\t\t\t\thuan[++hs] = to;\n\t\t\t\tst.pop();\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (dfsh(to, now)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\tst.pop();\n\treturn false;\n}\n\ninline void dfss(int now, int fa) {\n\tsiz[now] = 1;\n\tfor (int i = first[now]; i; i = e[i].nxt) {\n\t\tint to = e[i].to;\n\t\tif (!oh[to] && to != fa) {\n\t\t\tdfss(to, now);\n\t\t\tsiz[now] += siz[to];\n\t\t}\n\t}\n}\n\ninline void dfs1(int now, int fa) {\n\tdpn[now] = siz[now];\n\tfor (int i = first[now]; i; i = e[i].nxt) {\n\t\tint to = e[i].to;\n\t\tif (!oh[to] && to != fa) {\n\t\t\tdfs1(to, now);\n\t\t\tdpn[now] += dpn[to];\n\t\t}\n\t}\n}\n\nLL dp[maxn][maxn];\nLL xx[maxn];\nLL qzh[maxn];\n\ninline LL sum(int l, int r) {\n\tif (l <= r) {\n\t\treturn qzh[r] - qzh[l - 1];\n\t} else {\n\t\tswap(l, r);\n\t\tl++, r--;\n\t\treturn qzh[hs] + qzh[l - 1] - qzh[r];\n\t}\n}\n\ninline int pre(int x) {\n\treturn (x - 2 + hs) % hs + 1;\n}\n\ninline int nxt(int x) {\n\treturn x % hs + 1;\n}\n\ninline void dfsall(int now, int fa) {\n\tfor (int i = first[now]; i; i = e[i].nxt) {\n\t\tint to = e[i].to;\n\t\tif (!oh[to] && to != fa) {\n\t\t\tdpw[to] = dpw[now] + dpn[now] - dpn[to] - siz[to];\n\t\t\tdfsall(to, now);\n\t\t}\n\t}\n}\n\nint main() {\n\tread(n);\n\tfor (int i = 1; i <= n; ++i) {\n\t\tint f, t;\n\t\tread(f), read(t);\n\t\tf++, t++;\n\t\tadd_edge(f, t);\n\t}\n\tdfsh(1, 0);\n//\tcout << \"huan = \";\n\tfor (int i = 1; i <= hs; ++i) {\n//\t\tcout << huan[i] << ' ';\n\t\toh[huan[i]] = true;\n\t}\n//\tcout << endl;\n\tfor (int i = 1; i <= hs; ++i) {\n\t\tdfss(huan[i], 0);\n\t\tdfs1(huan[i], 0);\n\t}\n//\tcout << \"dpn = \";\n//\tfor (int i = 1; i <= n; ++i) {\n//\t\tcout << dpn[i] << ' ';\n//\t}\n//\tcout << endl;\n\tfor (int i = 1; i <= hs; ++i) {\n\t\txx[i] = dpn[huan[i]];\n\t\tqzh[i] = qzh[i - 1] + xx[i];\n\t}\n\tfor (int i = 1; i <= hs; ++i) {\n\t\tdp[i][i] = xx[i];\n\t}\n\tfor (int len = 2; len < hs; ++len) {\n\t\tfor (int l = 1; l <= hs; ++l) {\n\t\t\tint r = (l + len - 2) % hs + 1;\n\t\t\tdp[l][r] = max(dp[nxt(l)][r], dp[l][pre(r)]) + sum(l, r);\n//\t\t\tcout << l << ' ' << r << ' ' << dp[l][r] << ' ' << sum(l, r) << ' ' << nxt(l) << ' ' << pre(r) << endl;\n\t\t}\n\t}\n//\tcout << \"xx = \";\n\tfor (int i = 1; i <= hs; ++i) {\n\t\tdpw[huan[i]] = dp[nxt(i)][pre(i)];\n\t\tdfsall(huan[i], 0);\n//\t\tcout << dpw[huan[i]] << ' ';\n\t}\n//\tcout << endl;\n\tLL ans = 0;\n\tfor (int i = 1; i <= n; ++i) {\n\t\tans = max(ans, dpw[i] + dpn[i] + n - siz[i]);\n\t}\n\tprintf(\"%lld\", ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "54515aa4070eb1c8353bf81b34da8c48", "src_uid": "c3da92d4b495d3e99c83a5ffe206709a", "difficulty": 2800.0}
    {"lang": "GNU C++11", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long LL;\n\ninline char gc() {\n\tstatic const LL L = 233333;\n\tstatic char sxd[L], *sss = sxd, *ttt = sxd;\n\tif (sss == ttt) {\n\t\tttt = (sss = sxd) + fread(sxd, 1, L, stdin);\n\t\tif (sss == ttt) {\n\t\t\treturn EOF;\n\t\t}\n\t}\n\treturn *sss++;\n}\n\n#ifndef dd\n#define dd c = gc()\n#endif\ninline char readalpha() {\n\tchar dd;\n\tfor (; !isalpha(c); dd);\n\treturn c;\n}\n\ninline char readchar() {\n\tchar dd;\n\tfor (; c == ' '; dd);\n\treturn c;\n}\n\ntemplate \ninline bool read(T& x) {\n\tbool flg = false;\n\tchar dd;\n\tx = 0;\n\tfor (; !isdigit(c); dd) {\n\t\tif (c == '-') {\n\t\t\tflg = true;\n\t\t} else if(c == EOF) {\n\t\t\treturn false;\n\t\t}\n\t}\n\tfor (; isdigit(c); dd) {\n\t\tx = (x << 1) + (x << 3) + (c ^ 48);\n\t}\n\tif (flg) {\n\t\tx = -x;\n\t}\n\treturn true;\n}\n#undef dd\n\ntemplate \ninline void write(T x) {\n\tif (x < 0) {\n\t\tputchar('-');\n\t\tx = -x;\n\t}\n\tif (x < 10) {\n\t\tputchar(x | 48);\n\t\treturn;\n\t}\n\twrite(x / 10);\n\tputchar((x % 10) | 48);\n}\n\nconst int maxn = 15005;\n\nint n;\n\nstruct Edge {\n\tint to, nxt;\n} e[maxn];\n\nint first[maxn];\n\ninline void add_edge(int from, int to) {\n\tstatic int cnt = 0;\n\te[++cnt].nxt = first[from];\n\tfirst[from] = cnt;\n\te[cnt].to = to;\n\te[++cnt].nxt = first[to];\n\tfirst[to] = cnt;\n\te[cnt].to = from;\n}\n\nLL dpw[maxn];\nLL dpn[maxn];\nint siz[maxn];\nint huan[maxn];\nint hs;\nstack st;\nbool vis[maxn];\nbool oh[maxn];\n\ninline bool dfsh(int now, int fa) {\n\tst.push(now);\n\tfor (int i = first[now]; i; i = e[i].nxt) {\n\t\tint to = e[i].to;\n\t\tif (to != fa) {\n\t\t\tif (vis[to]) {\n\t\t\t\twhile(st.top() != to) {\n\t\t\t\t\thuan[++hs] = st.top();\n\t\t\t\t\tst.pop();\n\t\t\t\t}\n\t\t\t\thuan[++hs] = to;\n\t\t\t\tst.pop();\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (dfsh(to, now)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}\n\ninline void dfss(int now, int fa) {\n\tsiz[now] = 1;\n\tfor (int i = first[now]; i; i = e[i].nxt) {\n\t\tint to = e[i].to;\n\t\tif (!oh[to] && to != fa) {\n\t\t\tdfss(to, now);\n\t\t\tsiz[now] += siz[to];\n\t\t}\n\t}\n}\n\ninline void dfs1(int now, int fa) {\n\tdpn[now] = siz[now];\n\tfor (int i = first[now]; i; i = e[i].nxt) {\n\t\tint to = e[i].to;\n\t\tif (!oh[to] && to != fa) {\n\t\t\tdfs1(to, now);\n\t\t\tdpn[now] += dpn[to];\n\t\t}\n\t}\n}\n\nLL dp[maxn][maxn];\nLL xx[maxn];\nLL qzh[maxn];\n\ninline LL sum(int l, int r) {\n\tif (l <= r) {\n\t\treturn qzh[r] - qzh[l - 1];\n\t} else {\n\t\tswap(l, r);\n\t\tl++, r--;\n\t\treturn qzh[hs] + qzh[l - 1] - qzh[r];\n\t}\n}\n\ninline int nxt(int x) {\n\treturn (x - 2 + hs) % hs + 1;\n}\n\ninline int pre(int x) {\n\treturn x % hs + 1;\n}\n\nint main() {\n\tread(n);\n\tfor (int i = 1; i <= n; ++i) {\n\t\tread(f), read(t);\n\t\tf++, t++;\n\t\tadd_edge(f, t);\n\t}\n\tdfsh(1, 0);\n\tfor (int i = 1; i <= hs; ++i) {\n\t\toh[huan[i]] = true;\n\t}\n\tdfs1(1, 0);\n\tfor (int i = 1; i <= hs; ++i) {\n\t\txx[i] = dpn[huan[i]];\n\t\tqzh[i] = qzh[i - 1] + xx[i];\n\t}\n\tfor (int i = 1; i <= hs; ++i) {\n\t\tdp[i][i] = xx[i];\n\t}\n\tfor (int l = 1; l <= hs; ++l) {\n\t\tfor (int r = nxt(l); l != r; r = nxt(r)) {\n\t\t\tdp[l][r] = max(dp[nxt(l)][r], dp[l][pre(r)]) + sum(l, r);\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cc2c9827350ec2275ccef1ec29979459", "src_uid": "c3da92d4b495d3e99c83a5ffe206709a", "difficulty": 2800.0}
    {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nconst int N=50005,L=0,R=1;\nstruct node;\nextern node *nil,*t[N];\nstruct node\n{\n\tlong long v,size,size_sqr,lazy_size,sum;\n\tnode *s[2],*f,*next,*rf;\n\tnode(): v(0),size(0),size_sqr(0),lazy_size(0),sum(0),\n\t\t\tf(nil),next(nil),rf(nil) {s[L]=s[R]=nil;}\n\tbool root() { return f->s[L]!=this && f->s[R]!=this; }\n\tint get_dir() { return f->s[R]==this; }\n\tlong long addsize(long long d)\n\t{\n\t\tif(this==nil)\n\t\t\treturn 0;\n\t\tlazy_size+=d;\n\t\tsize+=d;\n\t\tif(rf!=nil)\n\t\t{\n\t\t\tlong long tmp=size-d;\n\t\t\trf->size_sqr+=-tmp*tmp + size*size;\n\t\t}\n\t\tlong long tmp=sum,dv=0;\n\t\tnode *now=this;\n\t\tfor(now=this ; now->s[L]!=nil ; now=now->s[L]) ;\n\t\tdv-=now->rf->v;\n\t\tfor(now=this ; now->s[R]!=nil ; now=now->s[R]) ;\n\t\tdv+=now->v;\n\t\tsum+=dv*d;\n\t\treturn 2*d*tmp;\n\t}\n\tlong long changev(long long d)\n\t{\n\t\tlong long delta=(d-v)*(size*size-size_sqr);\n\t\tnode *tmp=s[R];\n\t\tpush();\n\t\tfor(tmp=s[R]; tmp->s[L]!=nil; tmp=tmp->s[L])\n\t\t\ttmp->push();\n\t\tsum+=(d-v)*(size-tmp->size);\n\t\tlong long tmpv=(d-v)*(-tmp->size);\n\t\tfor(tmp=s[R]; tmp!=nil; tmp=tmp->s[L])\n\t\t\ttmp->sum+=tmpv;\n\t\tv=d;\n\t\treturn delta;\n\t}\n\tvoid push()\n\t{\n\t\tif(lazy_size)\n\t\t{\n\t\t\ts[L]->addsize(lazy_size);\n\t\t\ts[R]->addsize(lazy_size);\n\t\t\tlazy_size=0;\n\t\t}\n\t}\n\tvoid update()\n\t{\n\t\tsum=s[L]->sum+s[R]->sum+size*(v-rf->v);\n\t}\n\tvoid set_f(node *d)\n\t{\n\t\tif(this!=nil)\n\t\t\tf=d;\n\t}\n\tvoid set_right(node *k)\n\t{\n\t\tpush();\n\t\tfor(node *tmp=s[R]; tmp!=nil; tmp=tmp->s[L])\n\t\t\ttmp->push();\n\t\t(s[R]=k)->set_f(this);\n\t\tupdate();\n\t}\n}u[N]={},*t[N]={},*nil=&u[0];\nint n,v[N]={},f[N]={};\nlong long ans=0;\nvector son[N];\nint dfs(int s)\n{\n\tfor(vector::iterator it=son[s].begin();it!=son[s].end();++it)\n\t{\n\t\tlong long tmp=dfs(*it);\n\t\tt[s]->size+=tmp;\n\t\tt[s]->size_sqr+=tmp*tmp;\n\t}\n\tt[s]->size+=1;\n\tt[s]->v=v[s];\n\tt[s]->f=t[s]->rf=t[f[s]];\n\tans+=(t[s]->size*t[s]->size - t[s]->size_sqr)*t[s]->v;\n\tt[s]->sum+=(t[s]->v - t[s]->rf->v) * t[s]->size;\n\treturn t[s]->size;\n}\nvoid rotate(node *n)\n{\n\tnode *f=n->f;\n\tint d=n->get_dir();\n\tf->push();\n\tn->push();\n\tf->s[d]=n->s[!d];\n\tf->s[d]->set_f(f);\n\tif(!f->root())\n\t\tf->f->s[f->get_dir()]=n;\n\tn->f=f->f;\n\tn->s[!d]=f;\n\tf->f=n;\n\tf->update();\n\tn->update();\n}\nvoid Splay(node *n)\n{\n\twhile(!n->root())\n\t\tif(n->f->root())\n\t\t\trotate(n);\n\t\telse\n\t\t\tif(n->get_dir() ^ n->f->get_dir())\n\t\t\t\trotate(n),rotate(n);\n\t\t\telse\n\t\t\t\trotate(n->f),rotate(n);\n}\nnode* Access(node *x)\n{\n\tnode *y=nil;\n\tfor(;x!=nil;y=x,x=x->f)\n\t{\n\t\tSplay(x);\n\t\tx->set_right(y);\n\t}\n\treturn y;\n}\nvoid init()\n{\n\tscanf(\"%d\",&n);\n\tfor(int i=0;i<=n;++i)\n\t\tt[i]=&u[i];\n\tfor(int i=2;i<=n;++i)\n\t{\n\t\tscanf(\"%d\",&f[i]);\n\t\tson[f[i]].push_back(i);\n\t}\n\tfor(int i=1;i<=n;++i)\n\t\tscanf(\"%d\",&v[i]);\n}\nvoid all_push()\n{\n\tfor(int i=1;i<=n;++i)\n\t\tfor(int j=1;j<=n;++j)\n\t\t\tt[j]->push();\n}\nvoid set_f(int x,int y)\n{\n\tnode *p=t[x],*q=t[y],*r=t[f[x]];\n\tlong long delta=p->size;\n\tnode *tmp=Access(r);\n\tans+=tmp->addsize(-delta) + 2*r->v*delta*delta;\n\tall_push();\n\tr->size_sqr-=delta*delta;\n\tSplay(p);\n\tp->rf=p->f=q;\n\tf[x]=y;\n\tp->update();\n\ttmp=Access(q);\n\tans+=tmp->addsize(delta);\n\tall_push();\n\tq->size_sqr+=delta*delta;\n}\nvoid work()\n{\n\tint q,x,y;\n\tchar ch;\n\tcin>>q;\n\t/*\n\t\t\tfor(int j=1;j<=n;++j)\n\t\t\t\tcout<size<<' ';\n\t\t\tcout<size_sqr<<' ';\n\t\t\tcout<>ch>>x>>y;\n\t\tif(ch=='P')\n\t\t{\n\t\t\tnode *p=Access(t[y]),*q=t[x];\n\t\t\twhile(!q->root())\n\t\t\t\tq=q->f;\n\t\t\tp!=q ? set_f(x,y) : set_f(y,x);\n\t\t}\n\t\tif(ch=='V')\n\t\t{\n\t\t\tSplay(t[x]);\n\t\t\tans+=t[x]->changev(y);\n\t\t}\n\t\t//cout<size<<' ';\n\t\t\tcout<size_sqr<<' ';\n\t\t\tcout<\n#include\n#include\nusing namespace std;\nconst int N=50005,L=0,R=1;\nstruct node;\nextern node *nil;\nstruct node\n{\n\tlong long v,size,size_sqr,lazy_size,sum;\n\tnode *s[2],*f,*next,*rf;\n\tnode(): v(0),size(0),size_sqr(0),lazy_size(0),sum(0),\n\t\t\tf(nil),next(nil),rf(nil) {s[L]=s[R]=nil;}\n\tbool root() { return f->s[L]!=this && f->s[R]!=this; }\n\tint get_dir() { return f->s[R]==this; }\n\tlong long addsize(long long d)\n\t{\n\t\tif(this==nil)\n\t\t\treturn 0;\n\t\tlazy_size+=d;\n\t\tsize+=d;\n\t\tif(rf!=nil)\n\t\t{\n\t\t\tlong long tmp=size-d;\n\t\t\trf->size_sqr+=-tmp*tmp + size*size;\n\t\t}\n\t\tlong long tmp=sum,dv=0;\n\t\tnode *now=this;\n\t\tfor(now=this ; now->s[L]!=nil ; now=now->s[L]) ;\n\t\tdv-=now->rf->v;\n\t\tfor(now=this ; now->s[R]!=nil ; now=now->s[R]) ;\n\t\tdv+=now->v;\n\t\tsum+=dv*d;\n\t\treturn 2*d*tmp;\n\t}\n\tlong long changev(long long d)\n\t{\n\t\tlong long delta=(d-v)*(size*size-size_sqr);\n\t\tnode *tmp=s[R];\n\t\tpush();\n\t\tfor(tmp=s[R]; tmp->s[L]!=nil; tmp=tmp->s[L])\n\t\t\ttmp->push();\n\t\tsum+=(d-v)*(size-tmp->size);\n\t\tlong long tmpv=(d-v)*(-tmp->size);\n\t\tfor(tmp=s[R]; tmp!=nil; tmp=tmp->s[L])\n\t\t\ttmp->sum+=tmpv;\n\t\tv=d;\n\t\treturn delta;\n\t}\n\tvoid push()\n\t{\n\t\tif(lazy_size)\n\t\t{\n\t\t\ts[L]->addsize(lazy_size);\n\t\t\ts[R]->addsize(lazy_size);\n\t\t\tlazy_size=0;\n\t\t}\n\t}\n\tvoid update()\n\t{\n\t\tsum=s[L]->sum+s[R]->sum+size*(v-rf->v);\n\t}\n\tvoid set_f(node *d)\n\t{\n\t\tif(this!=nil)\n\t\t\tf=d;\n\t}\n\tvoid set_right(node *k)\n\t{\n\t\tpush();\n\t\tfor(node *tmp=s[R]; tmp!=nil; tmp=tmp->s[L])\n\t\t\ttmp->push();\n\t\t(s[R]=k)->set_f(this);\n\t\tupdate();\n\t}\n}u[N]={},*t[N]={},*nil=&u[0];\nint n,v[N]={},f[N]={};\nlong long ans=0;\nvector son[N];\nint dfs(int s)\n{\n\tfor(vector::iterator it=son[s].begin();it!=son[s].end();++it)\n\t{\n\t\tlong long tmp=dfs(*it);\n\t\tt[s]->size+=tmp;\n\t\tt[s]->size_sqr+=tmp*tmp;\n\t}\n\tt[s]->size+=1;\n\tt[s]->v=v[s];\n\tt[s]->f=t[s]->rf=t[f[s]];\n\tans+=(t[s]->size*t[s]->size - t[s]->size_sqr)*t[s]->v;\n\tt[s]->sum+=(t[s]->v - t[s]->rf->v) * t[s]->size;\n\treturn t[s]->size;\n}\nvoid rotate(node *n)\n{\n\tnode *f=n->f;\n\tint d=n->get_dir();\n\tf->push();\n\tn->push();\n\tf->s[d]=n->s[!d];\n\tf->s[d]->set_f(f);\n\tif(!f->root())\n\t\tf->f->s[f->get_dir()]=n;\n\tn->f=f->f;\n\tn->s[!d]=f;\n\tf->f=n;\n\tf->update();\n\tn->update();\n}\nvoid Splay(node *n)\n{\n\twhile(!n->root())\n\t\tif(n->f->root())\n\t\t\trotate(n);\n\t\telse\n\t\t\tif(n->get_dir() ^ n->f->get_dir())\n\t\t\t\trotate(n),rotate(n);\n\t\t\telse\n\t\t\t\trotate(n->f),rotate(n);\n}\nnode* Access(node *x)\n{\n\tnode *y=nil;\n\tfor(;x!=nil;y=x,x=x->f)\n\t{\n\t\tSplay(x);\n\t\tx->set_right(y);\n\t}\n\treturn y;\n}\nvoid init()\n{\n\tscanf(\"%d\",&n);\n\tfor(int i=0;i<=n;++i)\n\t\tt[i]=&u[i];\n\tfor(int i=2;i<=n;++i)\n\t{\n\t\tscanf(\"%d\",&f[i]);\n\t\tson[f[i]].push_back(i);\n\t}\n\tfor(int i=1;i<=n;++i)\n\t\tscanf(\"%d\",&v[i]);\n}\nvoid set_f(int x,int y)\n{\n\tnode *p=t[x],*q=t[y],*r=t[f[x]];\n\tlong long delta=p->size;\n\tnode *tmp=Access(r);\n\tans+=tmp->addsize(-delta) + 2*r->v*delta*delta;\n\tr->size_sqr-=delta*delta;\n\tSplay(p);\n\tp->rf=p->f=q;\n\tf[x]=y;\n\tp->update();\n\ttmp=Access(q);\n\tans+=tmp->addsize(delta);\n\tq->size_sqr+=delta*delta;\n}\nvoid work()\n{\n\tint q,x,y;\n\tchar ch;\n\tcin>>q;\n\tprintf(\"%.15f\\n\",ans*1.0/n/n);\n\tfor(int i=1;i<=q;++i)\n\t{\n\t\tcin>>ch>>x>>y;\n\t\tif(ch=='P')\n\t\t{\n\t\t\tnode *p=Access(t[y]),*q=t[x];\n\t\t\twhile(!q->root())\n\t\t\t\tq=q->f;\n\t\t\tp!=q ? set_f(x,y) : set_f(y,x);\n\t\t}\n\t\tif(ch=='V')\n\t\t{\n\t\t\tSplay(t[x]);\n\t\t\tans+=t[x]->changev(y);\n\t\t}\n\t\tprintf(\"%.15f\\n\",ans*1.0/n/n);\n\t}\n}\nint main()\n{\t\n\t//freopen(\"now.txt\",\"w\",stdout);\n\tinit();\n\tdfs(1);\n\twork();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2039a291ab3512452cc92279d8331dc4", "src_uid": "013df41c0042f752a995bdcf16b28c7e", "difficulty": 3200.0}
    {"lang": "GNU C++", "source_code": "?#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define M 100010\n#define LL long long\n#pragma comment(linker, \"/STACK:1024000000,1024000000\") \n#define ULL unsigned int\n#define ls son[p][0]\n#define rs son[p][1]\nLL ans;\nint son[M][2], fa[M], cnt[M], val[M];\nint is[M];\nLL sumVal[M], sumCnt[M], sum[M], all[M], lazy[M];\nvoid up( int p )\n{\n\tsumCnt[p] = sumCnt[ls] + sumCnt[rs] + cnt[p];\n\tsumVal[p] = sumVal[ls] + sumVal[rs] + val[p];\n\tsum[p] = sum[ls] + sum[rs] + 1LL * cnt[p] * val[p];\n}\nvoid func( int p, LL v )\n{\n\tif( !p ) return;\n\tall[p] += v * cnt[p];\n\tlazy[p] += v;\n}\nvoid down( int p )\n{\n\tif( lazy[p] ){\n\t\tfunc( ls, lazy[p] );\n\t\tfunc( rs, lazy[p] );\n\t\tlazy[p] = 0;\n\t}\n}\nvoid Rotate( int x )\n{\n\tint y = fa[x], z = fa[y];\n\tint o = son[y][0] == x;\n\tdown( y ), down( x );\n\tson[y][!o] = son[x][o], fa[son[x][o]] = y;\n\tson[x][o] = y, fa[y] = x;\n\tfa[x] = z;\n\tif( is[y] ) is[y] = 0, is[x] = 1;\n\telse \n\t\tson[z][son[z][1]==y] = x;\n\tup( y );\n}\nvoid Splay( int x )\n{\n\tint y, z;\n\tdown( x );\n\twhile( !is[x] ){\n\t\ty = fa[x], z = fa[y];\n\t\tif( is[y] ) Rotate( x );\n\t\telse if( ( son[y][0] == x ) ^ ( son[z][0] == y ) )\n\t\t\tRotate( x ), Rotate( x );\n\t\telse\n\t\t\tRotate( y ), Rotate( x );\n\t}\n\tup( x );\n}\nint Access( int x )\n{\n\tint y = 0;\n\tfor( ; x; x = fa[x] ){\n\t\tSplay( x );\n\t\tis[ son[x][1] ] = 1;\n\t\tif( son[x][1] ){\n\t\t\tcnt[x] += sumCnt[son[x][1]];\n\t\t}\n\t\tson[x][1] = y;\n\t\tif( y ){\n\t\t\tcnt[x] -= sumCnt[y];\n\t\t}\n\t\tis[y] = 0;\n\t\ty = x;\n\t\tup( x );\n\t}\n\treturn y;\n}\nint vv[M], nxt[M], h[M], e;\nvoid add( int u, int v )\n{\n\tvv[e] = v, nxt[e] = h[u], h[u] = e++;\n}\nvoid dfs( int u, int f )\n{\n\tfa[u] = f, is[u] = 1, cnt[u] = 1; son[u][0] = son[u][1] = 0;\n\tall[u] = 1;\n\tfor( int i = h[u]; i + 1; i = nxt[i] ){\n\t\tint v = vv[i];\n\t\tdfs( v, u );\n\t\tall[u] += 1LL * cnt[v] * cnt[u] * 2;\n\t\tcnt[u] += cnt[v];\n\t}\n\tans += all[u] * val[u];\n\tup( u );\n}\nvoid change( int x, LL v )\n{\n\tSplay( x );\n\tans += ( v - val[x] ) * all[x];\n\tval[x] = v;\n\tup( x );\n}\nint getFa( int x )\n{\n\tSplay( x );\n\tif( !son[x][0] ) return fa[x];\n\tint y = son[x][0];\n\twhile( son[y][1] ) y = son[y][1];\n\treturn y;\n}\n\nvoid gao( int u, int v )\n{\n\tAccess( u ); Splay( v );\n\tif( !fa[v] ) swap( u, v );\n\tint f = getFa( v );\n\tif( f == u ) return;\n\n\tAccess( f ), Splay( f );\n\tcnt[f] -= sumCnt[v], up( f );\n\tfa[v] = 0; \n\tans -= 2*sum[f] * sumCnt[v];\n\tfunc( f, -2*sumCnt[v] );\n\n\tAccess( u ), Splay( u );\n\tans += 2 * sum[u] * sumCnt[v];\n\tfunc( u, 2 * sumCnt[v] );\n\tcnt[u] += sumCnt[v], up( u );\n\tfa[v] = u;\n}\nint main()\n{\n\tint n;\n\tint u;\n\tscanf( \"%d\", &n );\n\tmemset( h, -1, sizeof(h) ), e = 0;\n\tfor( int i = 2; i <= n; ++i ){\n\t\tscanf( \"%d\", &u );\n\t\tadd( u, i );\n\t}\n\tfor( int i = 1; i <= n; ++i ) scanf( \"%d\", val + i );\n\tdfs( 1, 0 );\n\tint m, v;\n\tscanf( \"%d\", &m );\n\tchar c[3];\n\tdouble mu = 1.0 * n * n;\n\tprintf( \"%.10lf\\n\", ans / mu );\n\twhile( m-- ){\n\t\tscanf( \"%s%d%d\", c, &u, &v );\n\t\tif( c[0] == 'P' ) gao( v, u );\n\t\telse change( u, v );\n\t\tprintf( \"%.10lf\\n\", ans / mu );\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a21fa12299209c75ceb02b193f749bee", "src_uid": "013df41c0042f752a995bdcf16b28c7e", "difficulty": 3200.0}
    {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\n#define dbgs(x) cerr << (#x) << \" --> \" << (x) << ' '\n#define dbg(x) cerr << (#x) << \" --> \" << (x) << endl\n\n#define foreach(i,x) for(type(x)i=x.begin();i!=x.end();i++)\n#define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)\n#define ROF(ii,aa,bb) for(int ii=aa;ii>=bb;ii--)\n\n#define type(x) __typeof(x.begin())\n\n#define orta (bas + son >> 1)\n#define sag (k + k + 1)\n#define sol (k + k)\n\n#define pb push_back\n#define mp make_pair\n\n#define nd second\n#define st first\n\n#define endl '\\n'\n\ntypedef pair < int ,int > pii;\n\ntypedef long long ll;\n\nconst long long linf = 1e18+5;\nint mod = (int) 1e9 + 7;\nconst int logN = 18;\nconst int SQ = 250;\nconst int inf = 1e9;\nconst int N = 5e4 + 5;\n\nll all, ch[N], path[N];\nint size[N], ok[N], dp[N], n, m, P[N], p[N], x, y, z, t, val[N], C[N];\nvector< pair< int , pii > > q;\nvector< int > v[N], nodes;\nchar c;\n\nint up(int x, int y) {\n    if(!x) return 0;\n    int &r = dp[x];\n    if(r != -1) return r;\n    if(P[x] == y) return r = x;\n    return r = up(P[x], y);\n}\n\nint up2(int x) {\n    if(ok[x]) return x;\n    int &r = dp[x];\n    if(r != -1) return r;\n    return r = up2(P[x]);\n}\n\nint dfs1(int node) {\n    size[node] = 1;\n    int s = ok[node] ? 2 : 0;\n    ch[node] = 0;\n    foreach(it, v[node]) {\n        s += dfs1(*it);\n        size[node] += size[*it];\n        ch[node] -= size[*it] * (ll) size[*it];\n    } ch[node] += size[node] * (ll) size[node];\n    if(s >= 2) ok[node] = 1;\n    all += ch[node] * (ll) val[node];\n    return s != 0;\n}\n\nvoid dfs2(int node, int last, int root, int bef = 0) {\n    path[node] = path[root] + (size[root] - size[node]) * (ll) val[root];\n    C[node] = size[bef];\n    if(ok[node]) { nodes.pb(node); P[node] = last; last = node; bef = -1; }\n    foreach(it, v[node]) {\n        if(bef == -1) dfs2(*it, node, node, *it);\n        else dfs2(*it, last, node, bef);\n    }\n}\n\nint ctr(int x, int y) {\n    while(x) {\n        if(x == y) return 1;\n        x = P[x];\n    } return 0;\n}\n\nint main() {\n\n    scanf(\"%d\", &n);\n    FOR(i, 2, n) scanf(\"%d\", &p[i]);\n    FOR(i, 1, n) scanf(\"%d\", &val[i]);\n\n    scanf(\"%d\", &m);\n\n    FOR(i, 1, m) {\n        scanf(\" %c %d %d\", &c, &y, &z);\n        if(c == 'P') { ok[y] = ok[z] = 1; q.pb(mp(0, mp(y, z))); }\n        if(c == 'V') { ok[y] = 1; q.pb(mp(1, mp(y, z))); }\n        if(i == m || i % SQ == 0) {\n            FOR(i, 1, n) v[i].clear();\n            FOR(i, 2, n) v[p[i]].pb(i);\n            nodes.clear();\n            ok[1] = 1; all = 0;\n            dfs1(1), dfs2(1, 0, 0, 1);\n            FOR(i, 1, n) oko[i] = ok[i];\n            memset(ok, 0, sizeof ok);\n            foreach(it, q) {\n                printf(\"%.12lf\\n\", all / (n * n * 1.0));\n                foreach(it3, nodes) ok[*it3] = 0;\n                if(it->st == 1) {\n                    int node = it->nd.st, val = it->nd.nd - ::val[node];\n                    all += val * ch[it->nd.st];\n                    foreach(it3, nodes) dp[*it3] = -1;\n                    foreach(it3, nodes) {\n                        int take = up(*it3, node);\n                        if(take == 0) continue;\n                        path[*it3] += val * (ll) (size[node] - C[take]);\n                    } :: val[node] += val;\n                }\n                else {\n                    if(ctr(it->nd.nd, it->nd.st)) swap(it->nd.nd, it->nd.st);\n                    p[it->nd.st] = it->nd.nd;\n                    int node = it->nd.st, par = P[it->nd.st], sz = size[node];\n                    all -= 2 * sz * path[node];\n                    while(par) {\n                        ok[par] = ok[node] = 1;\n                        ch[par] -= 2LL * sz * (size[par] - C[node]);\n                        size[par] -= sz; C[node] -= sz;\n                        node = P[node]; par = P[par];\n                    } C[1] -= sz; C[it->nd.st] = sz;\n                    int ggg = path[it->nd.st];\n                    foreach(it3, nodes) dp[*it3] = -1;\n                    foreach(it3, nodes) {\n                        if(!ok[*it3] || *it3 == it->nd.st) {\n                            int take = up2(*it3);\n                            if(take == it->nd.st) path[*it3] -= ggg;\n                            else path[*it3] -= val[take] * (ll) sz;\n                        }\n                    }\n                    foreach(it3, nodes) dp[*it3] = -1, ok[*it3] = 0; C[it->nd.st] = 0;\n                    node = it->nd.st, par = it->nd.nd, P[node] = par;\n                    while(par) {\n                        ok[par] = ok[node] = 1;\n                        size[par] += sz; C[node] += sz;\n                        ch[par] += 2LL * sz * (size[par] - C[node]);\n                        node = P[node]; par = P[par];\n                    } C[1] += sz;\n                    foreach(it3, nodes) dp[*it3] = -1;\n                    ggg = path[it->nd.nd] + (ll) (size[it->nd.nd] - sz) * val[it->nd.nd];\n                    foreach(it3, nodes) {\n                       if(!ok[*it3] || *it3 == it->nd.st) {\n                            int take = up2(*it3);\n                            if(take == it->nd.st) path[*it3] += ggg;\n                            else path[*it3] += val[take] * (ll) sz;\n                        }\n                    }\n                    all += 2 * path[it->nd.st] * size[it->nd.st];\n                    foreach(it3, nodes) dp[*it3] = -1, ok[*it3] = 0;\n                }\n            }\n            q.clear();\n            memset(ok, 0, sizeof ok);\n        }\n    }\n    printf(\"%.12lf\\n\", all / (n * n * 1.0));\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e1461d6a30e69dcfd1eeee319b0bc5fc", "src_uid": "013df41c0042f752a995bdcf16b28c7e", "difficulty": 3200.0}
    {"lang": "GNU C++17", "source_code": "#include \n\n#define mp make_pair\n#define mt make_tuple\n#define fi first\n#define se second\n#define pb push_back\n#define all(x) (x).begin(), (x).end()\n#define rall(x) (x).rbegin(), (x).rend()\n#define forn(i, n) for (int i = 0; i < (int)(n); ++i)\n#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)\n#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)\n#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)\n\nusing namespace std;\n\ntypedef pair pii;\ntypedef vector vi;\ntypedef vector vpi;\ntypedef vector vvi;\ntypedef long long i64;\ntypedef vector vi64;\ntypedef vector vvi64;\ntypedef pair pi64;\ntypedef double ld;\n\ntemplate bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }\ntemplate bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }\n\nconst i64 P = 998244353;\nconst int maxn = 2100000;\n\ni64 fact[maxn], tcaf[maxn];\n\ni64 deg(i64 x, i64 d) {\n    if (d < 0) d += P - 1;\n    i64 y = 1;\n    while (d) {\n        if (d & 1) (y *= x) %= P;\n        d /= 2;\n        (x *= x) %= P;\n    }\n    return y;\n}\n\ni64 cnk(int n, int k) {\n    return fact[n] * tcaf[k] % P * tcaf[n - k] % P;\n}\n\nint main() {\n    ios::sync_with_stdio(false);\n    cin.tie(nullptr);\n    cout.precision(10);\n    cout << fixed;\n#ifdef LOCAL_DEFINE\n    freopen(\"input.txt\", \"rt\", stdin);\n#endif\n\n    int n, m;\n    cin >> n >> m;\n    fact[0] = 1;\n    forn(i, n) fact[i + 1] = fact[i] * (i + 1) % P;\n    forn(i, n + 1) tcaf[i] = deg(fact[i], -1);\n    i64 p = deg(m + 1, -1), q = (P + 1 - p) % P;\n    i64 ans = 0;\n    for1(k, n) {\n        (ans += cnk(n, k) % P * (1 + m * deg(k, -1)) * (k % 2 ? 1 : -1)) %= P;\n//        assert(t != 1);\n    }\n    if (ans < 0) ans += P;\n//    cout << ans << '\\n';\n    (ans *= n * p % P + 1) %= P;\n    cout << ans << '\\n';\n\n\n#ifdef LOCAL_DEFINE\n    cerr << \"Time elapsed: \" << 1.0 * clock() / CLOCKS_PER_SEC << \" s.\\n\";\n#endif\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "61f7f426bedb47f8d362f1d7fe40376c", "src_uid": "9f2b59df7bef2aeee0ce71facd2b1613", "difficulty": 3000.0}
    {"lang": "GNU C++17", "source_code": "#include \n#define fi first\n#define se second\n#define em emplace\n#define eb emplace_back\n#define all(V) (V).begin(), (V).end()\n#define unq(V) (V).resize(unique(all(V))-(V).begin())\nusing namespace std;\nusing ll = long long;\nusing pll = pair;\nusing pii = pair;\n\nconst ll MOD = 998244353;\nconst ll MD = 998244351;\n\nll inv(ll n) {\n\tll r=1;\n\tfor (register int i=30; i>=0; i--) {\n\t\tr=r*r%MOD;\n\t\tif ((1ll<sync_with_stdio(0);\n\tcin>>N>>K;\n\tll S=0, T=1, U=1;\n\n\tfor (register i=1; i<=N+K; i++) {\n\t\tll r=1;\n\t\tfor (register int j=29; j>=0; j--) {\n\t\t\tr=r*r%MOD;\n\t\t\tif ((1ll<\n#define fi first\n#define se second\n#define em emplace\n#define eb emplace_back\n#define all(V) (V).begin(), (V).end()\n#define unq(V) (V).resize(unique(all(V))-(V).begin())\nusing namespace std;\nusing ll = long long;\nusing pll = pair;\nusing pii = pair;\n\nconst ll MOD = 998244353;\nconst ll MD = 998244351;\nint N, K;\nll I[4000005];\n\nint main() {\n\tcin.tie(0)->sync_with_stdio(0);\n\tcin>>N>>K;\n\tll S=0, T=1, U=1;\n\n\tI[1]=1;\n\tfor (int i=2; i<=N+K; i++) I[i]=(MOD-(MOD/i)*I[MOD%I]%MOD)%MOD;\n\t\n\tfor (int i=1; i<=K-1; i++) T=T*I[i]%MOD, U=U*i%MOD;\n\tll SS=(N*I[K+1]%MOD+1+MOD)%MOD;\n\tfor (int i=1; i<=N; i++) {\n\t\tT=T*i%MOD*I[i+K]%MOD;\n\t\tU=U*(i+K-1)%MOD*I[i]%MOD;\n\t\tll X=(i+K)*I[i]%MOD*(SS+T*S%MOD)%MOD;\n\t\tif (i==N) cout<\n#define fi first\n#define se second\n#define em emplace\n#define eb emplace_back\n#define all(V) (V).begin(), (V).end()\n#define unq(V) (V).resize(unique(all(V))-(V).begin())\nusing namespace std;\nusing ll = long long;\nusing pll = pair;\nusing pii = pair;\n\nconst ll MOD = 998244353;\nconst ll MD = 998244351;\nint N, K;\nll I[4000005];\n\nint main() {\n\tcin.tie(0)->sync_with_stdio(0);\n\tcin>>N>>K;\n\tll S=0, T=1, U=1;\n\n\tI[1]=1;\n\tfor (int i=2; i<=N+K; i++) I[i]=(MOD-(MOD/i)*I[MOD%I]%MOD)%MOD;\n\tfor (register int i=1; i<=N+K; i++) {\n\t\tll r=1;\n\t\tfor (register int j=29; j>=0; j--) {\n\t\t\tr=r*r%MOD;\n\t\t\tif ((1ll<\nusing namespace std;\nint a[25],b[25];\n\n#define INF 1e15\ntypedef long long ll;\n\nll memo[50];\nint STATE,n,m;\nll dp[50][25];\n\n\nll ret[45][45];\nll adj[45][45];\nvoid mult(ll m1[45][45],ll m2[45][45]){\n\tll temp[45][45];\n\tfor(int i=0;i<=40;i++)\n\t   for(int j=0;j<=40;j++){\n\t\t   temp[i][j]=INF;\n\t\t   \n\t\t   for(int k=0;k<40;k++)\n\t\t       temp[i][j] = min (temp[i][j], min(INF,m1[i][k]+m2[k][j]));\n\t   }\n\t   \n   for(int i=0;i<=40;i++)\n\t   for(int j=0;j<=40;j++)\n\t\t\tret[i][j] = temp[i][j];\n\n}\n\nvoid exp(int k){\n\n    if(k==1){\n\t   for(int i=0;i<=40;i++)\n\t      for(int j=0;j<=40;j++)\n\t\t\tret[i][j] = adj[i][j];\n\t   return;\n   }\n    \n    \n    \n\texp(k/2);\n\t\n\tmult(ret,ret);\n\tif(k&1)mult(ret,adj);\n\n}\n\nll solve(int state,int idx){\n\tif(dp[state+20][idx]!=-1)return dp[state+20][idx];\n\t\n\tif(idx==n){\n\t\tif(state == STATE)return 0;\n\t\telse return INF;\n\t}\n\treturn dp[state+20][idx] = min(solve(state+1,idx+1)+a[idx],solve(state-1,idx+1)+b[idx]);\n}\nint main(){\n\tscanf(\"%d%d\",&n,&m);\n\tfor(int i=0;i\n#define ll long long\nusing namespace std;\nconst int Max = 5e5 + 5, Mod = 998244353;\n\u00a0\nll n, k, a[22], b[22], dp[22][22][22];\nint OP, CL;\nll Try(int i, int op, int cl)\n{\n\tif (op < 0)\n\t\tcl++, op = 0;\n\tif (i == n)\n\t\treturn (op == OP && cl == CL ? 0 : 1e16);\n\tll& ret = dp[i][op][cl];\n\tif (ret + 1)\n\t\treturn ret;\n\tll c1 = Try(i + 1, op + 1, cl) + a[i];\n\tll c2 = Try(i + 1, op - 1, cl) + b[i];\n\treturn ret = min({ (ll)1e16,c1,c2 });\n}\n\u00a0\ntypedef vector> matrix;\nint m;\n\u00a0\nmatrix init(ll x)\n{\n\treturn matrix(m, vector(m, x));\n}\n\u00a0\nmatrix mult(matrix& a, matrix& b)\n{\n\tmatrix Res = init(1e15);\n\tfor (int i = 0; i < m; i++)\n\t\tfor (int k = 0; k < m; k++)\n\t\t\tfor (int j = 0; j < m; j++)\n\t\t\t\tRes[i][j] = min(Res[i][j], a[i][k] + b[k][j]);\n\treturn Res;\n}\n\u00a0\nmatrix fp(matrix& x, ll p)\n{\n\tif ( p== 1 )\n\t\treturn x;\n\tmatrix y = fp(x, p >> 1);\n\ty = mult(y, y);\n\tif (p & 1)\n\t\ty = mult(y, x);\n\treturn y;\n}\n\u00a0\nint main()\n{\n\tcin >> n >> k;\n\tfor (int i = 0; i < n; i++)\n\t\tcin >> a[i];\n\tfor (int i = 0; i < n; i++)\n\t\tcin >> b[i];\n\tif (n == 1)\n\t{\n\t\ta[n] = a[0];\n\t\tb[n] = b[0];\n\t\tn++;\n\t\tk /= 2;\n\t}\n\tvector> v;\n\tfor (int i = 0; i < n; i++)\n\t\tfor (int j = 0; i + j < n; j++)\n\t\t\tif ((n - (i + j)) % 2 == 0)\n\t\t\t\tv.push_back({ i,j });\n\tm = 2 * n;\n\tmatrix T = init(1e16);\n\tfor(int i=0;i=0 && jj< m && jj >= 0 )\n\t\t\t{\n\t\t\t\tmemset(dp, -1, sizeof(dp));\n\t\t\t\tT[i][jj] = Try(0, 0, 0);\n\t\t\t}\n\t\t}\n\tT = fp(T, k);\n\tcout << T[0][0] << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ca1a085a689ebeb8c8b2ab9fb3f37e7a", "src_uid": "f40900973f4ebeb6fdafd75ebe4e9601", "difficulty": 2500.0}
    {"lang": "GNU C++17", "source_code": "#include \n#define ll long long\nusing namespace std;\nconst int Max = 5e5 + 5, Mod = 998244353;\nll n, k, a[22], b[22], dp[22][22][22];\nint OP, CL;\nll Try(int i, int op, int cl)\n{\n\tif (op < 0)\n\t\tcl++, op = 0;\n\tif (i == n)\n\t\treturn (op == OP && cl == CL ? 0 : 1e16);\n\tll& ret = dp[i][op][cl];\n\tif (ret + 1)\n\t\treturn ret;\n\tll c1 = Try(i + 1, op + 1, cl) + a[i];\n\tll c2 = Try(i + 1, op - 1, cl) + b[i];\n\treturn ret = min({ (ll)1e16,c1,c2 });\n}\n\ntypedef vector> matrix;\nint m;\n\nmatrix init(ll x)\n{\n\treturn matrix(m, vector(m, x));\n}\n\nmatrix mult(matrix& a, matrix& b)\n{\n\tmatrix Res = init(1e15);\n\tfor (int i = 0; i < m; i++)\n\t\tfor (int k = 0; k < m; k++)\n\t\t\tfor (int j = 0; j < m; j++)\n\t\t\t\tRes[i][j] = min(Res[i][j], a[i][k] + b[k][j]);\n\treturn Res;\n}\n\nmatrix fp(matrix& x, ll p)\n{\n\tif ( p== 1 )\n\t\treturn x;\n\tmatrix y = fp(x, p >> 1);\n\ty = mult(y, y);\n\tif (p & 1)\n\t\ty = mult(y, x);\n\treturn y;\n}\n\nint main()\n{\n\tcin >> n >> k;\n\tfor (int i = 0; i < n; i++)\n\t\tcin >> a[i];\n\tfor (int i = 0; i < n; i++)\n\t\tcin >> b[i];\n\tif (n == 1)\n\t{\n\t\ta[n] = a[0];\n\t\tb[n] = b[0];\n\t\tn++;\n\t\tk /= 2;\n\t}\n\tvector> v;\n\tfor (int i = 0;  i <= n; i++)\n\t\tfor (int j = 0; i+j<=n j++)\n\t\t\tif ((n - (i + j)) % 2 == 0)\n\t\t\t\tv.push_back({ i,j });\n\tm = 2 * n;\n\tmatrix T = init(1e16);\n\tfor(int i=0;i=0 && jj< m && jj >= 0 )\n\t\t\t{\n\t\t\t\tmemset(dp, -1, sizeof(dp));\n\t\t\t\tT[i][jj] = Try(0, 0, 0);\n\t\t\t}\n\t\t}\n\tT = fp(T, k);\n\tcout << T[0][0] << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8bbcc84f18c09313b29ff029850c7508", "src_uid": "f40900973f4ebeb6fdafd75ebe4e9601", "difficulty": 2500.0}
    {"lang": "GNU C++17", "source_code": "#include \n#define ll long long\nusing namespace std;\nconst int Max = 5e5 + 5, Mod = 998244353;\nll n, k, a[22], b[22], dp[22][22][22];\nint OP, CL;\nll Try(int i, int op, int cl)\n{\n\tif (op < 0)\n\t\tcl++, op = 0;\n\tif (i == n)\n\t\treturn (op == OP && cl == CL ? 0 : 1e16);\n\tll& ret = dp[i][op][cl];\n\tif (ret + 1)\n\t\treturn ret;\n\tll c1 = Try(i + 1, op + 1, cl) + a[i];\n\tll c2 = Try(i + 1, op - 1, cl) + b[i];\n\treturn ret = min({ (ll)1e16,c1,c2 });\n}\ntypedef vector> matrix;\nint m;\nmatrix init(ll x)\n{\n\treturn matrix(m, vector(m, x));\n}\nmatrix mult(matrix& a, matrix& b)\n{\n\tmatrix Res = init(1e15);\n\tfor (int i = 0; i < m; i++)\n\t\tfor (int k = 0; k < m; k++)\n\t\t\tfor (int j = 0; j < m; j++)\n\t\t\t\tRes[i][j] = min(Res[i][j], a[i][k] + b[k][j]);\n\treturn Res;\n\nmatrix fp(matrix& x, ll p)\n{\n\tif ( p== 1 )\n\t\treturn x;\n\tmatrix y = fp(x, p >> 1);\n\ty = mult(y, y);\n\tif (p & 1)\n\t\ty = mult(y, x);\n\treturn y;\n}\nint main()\n{\n\tcin >> n >> k;\n\tfor (int i = 0; i < n; i++)\n\t\tcin >> a[i];\n\tfor (int i = 0; i < n; i++)\n\t\tcin >> b[i];\n\tif (n == 1)\n\t{\n\t\ta[n] = a[0];\n\t\tb[n] = b[0];\n\t\tn++;\n\t\tk /= 2;\n\t}\n\tvector> v;\n\tfor (int i = 0;  i <= n; i++)\n\t\tfor (int j = 0; i+j<=n;j++)\n\t\t\tif ((n - (i + j)) % 2 == 0)\n\t\t\t\tv.push_back({ i,j });\n\tm = 2 * n+1;\n\tmatrix T = init(1e16);\n\tfor(int i=0;i=0 && jj< m && jj >= 0 )\n\t\t\t{\n\t\t\t\tmemset(dp, -1, sizeof(dp));\n\t\t\t\tT[i][jj] = Try(0, 0, 0);\n\t\t\t}\n\t\t}\n\tT = fp(T, k);\n\tcout << T[0][0] << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7965f31308b2d83528c1ead4dac4ce45", "src_uid": "f40900973f4ebeb6fdafd75ebe4e9601", "difficulty": 2500.0}
    {"lang": "GNU C++14", "source_code": "import java.io.BufferedInputStream;\nimport java.io.FileInputStream;\nimport java.io.PrintStream;\nimport java.util.*;\nimport java.math.BigDecimal;\nimport java.math.MathContext;\n\npublic class Main {\n\tpublic static BigDecimal[] a = new BigDecimal[100000];\n\tpublic static boolean[] flag = new boolean[100000];\n\tpublic static MathContext mc = new MathContext(50);\n\tpublic static final BigDecimal eps = BigDecimal.ONE.movePointLeft(25);\n\tpublic static final BigDecimal neps = BigDecimal.ZERO.subtract(eps);\n\tpublic static void main(String args[]) {\n\t\tScanner cin = new Scanner (new BufferedInputStream(System.in));\n\t\tPrintStream cout = System.out;\n\t\tint n=cin.nextInt();\n\t\tString s = cin.next();\n\t\tfor(int i=0; i\n\nusing namespace std;\n\nint solve(vector a) {\n  int n = a.size();\n  for (int i = 2; i * i <= n; i++) {\n    if (n % i == 0) {\n      if (n % (i * i) != 0) {\n        for (int j = 0; j < n; j += i) {\n          long long delta = a[j];\n          if (delta)\n            int k = j;\n            do {\n              a[k] -= delta;\n              k = (k + n / i) % n;\n            } while (k != j);\n            break;\n          }\n        }\n      } \n      vector< vector > w(i);\n      for (int j = 0; j < n; j++) {\n        w[j % i].push_back(a[j]);\n      }\n      bool ok = true;\n      for (int j = 0; j < i; j++) {\n        if (!solve(w[j])) {\n          ok = false;\n          break;\n        }\n      }\n      return ok;\n    }\n  }\n  for (int i = 1; i < (int) a.size(); i++) {\n    if (a[i] != a[0]) {\n      return false;\n    }\n  }\n  return true;\n}\n\nint main() {\n  int n;\n  string s;\n  cin >> n >> s;\n  vector a(n);\n  for (int i = 0; i < n; i++) {\n    a[i] = s[i] - '0';\n  }\n  puts(solve(a) ? \"YES\" : \"NO\");\n  return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9810d3dea1c6bd2203cec978b51da760", "src_uid": "63c00c5ea7aee792e8a30dc2c330c3f7", "difficulty": 3000.0}
    {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define rep(i,a,n) for (int i=a;i=a;i--)\n#define pb push_back\n#define mp make_pair\n#define all(x) (x).begin(),(x).end()\n#define fi first\n#define se second\n#define SZ(x) ((int)(x).size())\ntypedef vector VI;\ntypedef long long ll;\ntypedef pair PII;\nconst ll mod=1000000007;\nll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}\n// head\n\nconst int N=101000;\nint n,m;\ndouble dig[N];\ndouble pd[N];\nchar s[N];\nVI pr;\nint main() {\n\tscanf(\"%d\",&n); m=n;\n\tscanf(\"%s\",s);\n\trep(i,0,m) dig[i]=s[i]-'0', ss += dig[i];\n\tfor (int i=2;i=1e-9) { puts(\"NO\"); return 0;}\n\t}\n\tputs(\"YES\");\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "90e1518f9e29989fb21c1d248b899806", "src_uid": "63c00c5ea7aee792e8a30dc2c330c3f7", "difficulty": 3000.0}
    {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std;\n\nint N;\nvector V;\nvector> P;\n\nbool solve(vector& v, int pi)\n{\n    //cerr << \"!\";\n    int n = v.size();\n    if (n == 1)\n        return v[0] == 0;\n    int p = P[pi].first;\n    int pp = P[pi].second;\n    for (int i = 0; i < pp/p; i++)\n    {\n        vector> split;\n        for (int j = 0; j < p; j++)\n        {\n            vector pgon;\n            for (int k = 0; k < n/pp; k++)\n            {\n                pgon.push_back(v[(i+j*n/p+k*pp)%n]);\n            }\n            split.push_back(pgon);\n        }\n        for (int j = 1; j < split.size(); j++)\n        {\n            for (int k = 0; k < split[j].size(); k++)\n            {\n                split[j][k] -= split[0][k];\n            }\n        }\n        /*for (int j = 2; j < split.size(); j++)\n        {\n            for (int k = 1; k < split[j].size(); k++)\n            {\n                if (split[j][k] - split[1][k] != split[j][0]-split[1][0])\n                {\n                    if (N==3960)\n                    {\n                        cout << pi << \" \" << p << \" \" << i << \" \" << j << \" \" << k << \" not the same stuff\" << endl;\n                    }\n                    return false;\n                }\n\n            }\n        }*/\n        for (int j = 1; j < split.size(); j++)\n        {\n            if (!solve(split[j], pi+1))\n            {\n                if (N==3960)\n                {\n                    cout << \"Got back false at \" << pi << \" \" << p << \" \" << i << endl;\n                }\n                return false;\n            }\n        }\n    }\n    return true;\n}\n\nint main()\n{\n    ios::sync_with_stdio(false);\n    cin >> N;\n    for (int i = 0; i < N; i++)\n    {\n        char c;\n        cin >> c;\n        V.push_back(c-'0');\n    }\n    int p = 2;\n    int nn = N;\n    while(nn > 1)\n    {\n        //cerr << \"p \" << p << \", nn \" << nn << endl;\n        //cerr << \"?\";\n        if (nn % p != 0)\n        {\n            p++;\n            continue;\n        }\n        int c = 1;\n        while(nn % p == 0)\n        {\n            nn /= p;\n            c *= p;\n        }\n        P.push_back({p, c});\n        p++;\n    }\n    bool r = solve(V, 0);\n    cout << (r ? \"YES\" : \"NO\") << endl;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e79598464f86aee372c33304cb381fe6", "src_uid": "63c00c5ea7aee792e8a30dc2c330c3f7", "difficulty": 3000.0}
    {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long double ld;\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vl;\ntypedef vector vvi;\ntypedef vector vvl;\ntypedef vector vd;\ntypedef vector vvd;\ntypedef pair pii;\ntypedef pair pdd;\ntypedef vector vii;\ntypedef vector vs;\nconst int mod = 1e9 + 7;\n\nll mpow(ll x, ll n) {\n  ll res = 1;\n  while (n) {\n    if (n & 1) res = res * x % mod;\n    x = x * x % mod;\n    n /= 2;\n  }\n  return res;\n}\n\nint main() {\n  //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n  std::ios::sync_with_stdio(false); std::cin.tie(0);\n  int n;\n  cin >> n;\n  vvl p(n, vl(n));\n  vi pc(1 << n);\n  for (int i = 0 ; i < pc.size(); ++i) pc[i] = __builtin_popcount(i);\n  for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) {\n    cin >> p[i][j];\n    p[i][j] = p[i][j] * mpow(100, mod - 2) % mod;\n  }\n  map d;\n  d[vi(1 << n)] = 1;\n  ll res = 0;\n  for (int i = 0; i < n; ++i) {\n    map nd;\n    for (int mask = 0; mask < (1 << n); ++mask) {\n      ll prod = 1;\n      for (int j = 0; j < n; ++j) {\n        if (mask & (1 << j)) {\n          prod = prod * p[i][j] % mod;\n        } else {\n          prod = prod * (1 - p[i][j]) % mod;\n        }\n      }\n      for (const auto& it : d) {\n        vi nv = it.first;\n        bool fail = 0;\n        for (int nmask = mask; nmask < (1 << n); nmask = (nmask + 1) | mask) {\n          nv[nmask]++;\n          if (nv[nmask] > pc[nmask]) {\n            fail = 1;\n            break;\n          }\n        }\n        if (!fail) {\n          nd[nv] = (nd[nv] + prod * it.second) % mod;\n        }\n      }\n    }\n    d.swap(nd);\n  }\n  for (auto& it : d) {\n    res = (res + it.second) % mod;\n  }\n  cout << (res % mod + mod) % mod << endl;\n  return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d66b9cd14fd17ddaea71381446962617", "src_uid": "906d4e49566e63fddaf8eac7384c6284", "difficulty": 3100.0}
    {"lang": "GNU C++11", "source_code": "/*\nAuthor: QAQ Automaton\nLang: C++\nProg: E.cpp\nMail: lk@qaq-am.com\nBlog: https://www.qaq-am.com/\n*/\n#include\n#define int long long\n#define debug(...) fprintf(stderr,__VA_ARGS__)\n#define DEBUG printf(\"Passing [%s] in LINE %d\\n\",__FUNCTION__,__LINE__)\n#define Debug debug(\"Passing [%s] in LINE %d\\n\",__FUNCTION__,__LINE__)\n#define all(x) x.begin(),x.end()\n#define x first\n#define y second \nusing namespace std;\ntypedef long long ll;\ntypedef pair pii;\nconst double eps=1e-8;\nconst double pi=acos(-1.0);\ntemplateint chkmin(T &a,T b){return a>b?a=b,1:0;}\ntemplateint chkmax(T &a,T b){return aT sqr(T a){return a*a;}\ntemplateT mmin(T a,T b){return aT mmax(T a,T b){return a>b?a:b;}\ntemplateT aabs(T a){return a<0?-a:a;}\ntemplateint dcmp(T a,T b){return a>b;}\ntemplateint cmp_a(int x,int y){return a[x] '9'; c = gc()) if (c == '-') f = -1;else if(c==EOF)return 0;\n\t\tfor (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;\n\t\treturn 1;\n\t}\n\n\tinline bool read (long long &x) {\n\t\tfor (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;else if(c==EOF)return 0;\n\t\tfor (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;\n\t\treturn 1;\n\t}\n\tinline bool read (char &x) {\n\t\tx=gc();\n\t\treturn x!=EOF;\n\t}\n\tinline bool read(char *x){\n\t\twhile((*x=gc())=='\\n' || *x==' '||*x=='\\r')if(*x==EOF)return 0;\n\t\twhile(!(*x=='\\n'||*x==' '||*x=='\\r'||*x==EOF))*(++x)=gc();\n\t\t*x=0;\n\t\treturn 1;\n\t}\n\ttemplate\n\tinline bool read(A &x,B &...y){\n\t\treturn read(x)&&read(y...);\n\t}\n\t// print a signed integer\n\tinline bool write (signed x) {\n\t\tif (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;\n\t\twhile (x) qu[++ qr] = x % 10 + '0',  x /= 10;\n\t\twhile (qr) putc (qu[qr --]);\n\t\treturn 0;\n\t}\n\n\tinline bool write (long long x) {\n\t\tif (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;\n\t\twhile (x) qu[++ qr] = x % 10 + '0',  x /= 10;\n\t\twhile (qr) putc (qu[qr --]);\n\t\treturn 0;\n\t}\n\tinline bool write (char x) {\n\t\tputc(x);\n\t\treturn 0;\n\t}\n\tinline bool write(const char *x){\n\t\twhile(*x){putc(*x);++x;}\n\t\treturn 0;\n\t}\n\tinline bool write(char *x){\n\t\twhile(*x){putc(*x);++x;}\n\t\treturn 0;\n\t}\n\ttemplate\n\tinline bool write(A x,B ...y){\n\t\treturn write(x)||write(y...);\n\t}\n\t//no need to call flush at the end manually!\n\tstruct Flusher_ {~Flusher_(){flush();}}io_flusher_;\n}\nusing io :: read;\nusing io :: putc;\nusing io :: write;\nint inf;\nstruct _init_{\n    _init_(){\n        memset(&inf,0x3f,sizeof(inf));\n    }\n};\n_init_ ___INIT__;\nint a[11][11],n;\nint f[11][131];\nint is[131],i100;\nconst int p=1000000007;\nint fpm(int a,int b){int c=1;for(;b;b>>=1,a=a*a%p)if(b&1)c=c*a%p;return c;}\ntypedef __int128 lll;\nmap st[8];\nlll mx;\nint dfs(int x,lll w){\n\tif(x==n)return w==mx;\n\tif(st[x].count(w))return st[x][w];\n\tint ans=0;\n\tlll ng=0;\n\n\tint s[n];\n\tfor(int j=0;j\n#include \n#include \n\n#define pb push_back\n#define SZ(x) ((int)(x).size())\n#define ALL(x) x.begin(),x.end()\n#define all(x) x.begin(),x.end()\n#define fi first\n#define se second\n#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define erase_duplicates(x) sort(all(x)); (x).resize(distance((x).begin(), unique(all(x))));\n\n\nusing namespace std;\nusing namespace __gnu_pbds;\ntemplate\nusing ordered_set = tree<\nT,\nnull_type,\nless,\nrb_tree_tag,\ntree_order_statistics_node_update>;\n\n//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)\n//X.order_of_key(k); - zwraca liczb\u0119 element\u00f3w ostro mniejszych ni\u017c k\n\ntypedef long long LL;\ntypedef pair PII;\ntypedef pair PLL;\ntypedef vector VPII;\ntypedef vector VPLL;\ntypedef vector VLL;\ntypedef vector VI;\ntypedef vector VS;\ntypedef vector VC;\ntypedef long double LD;\ntypedef pair PLD;\ntypedef vector VLD;\ntypedef vector VPLD;\n\ntemplate void _dbg(const char *sdbg, TH h){ cerr< void _dbg(const char *sdbg, TH h, TA... a) {\n  while(*sdbg!=',')cerr<<*sdbg++;\n  cerr<<\" = \"< ziom = {{1, 2, 3}, {1, 3, 2}, {2, 1, 3}, {2, 3, 1}, {3, 1, 2}, {3, 2, 1}};\n  int mask = 0;\n  for(auto s : ziom)\n    for(int i = 1;i <= 6;i++)\n      for(int j = i + 1;j <= 6;j++)\n        for(int k = j + 1;k <= 6;k++)\n        {\n          if(elo[i][s[0] + f * 3] and elo[j][s[1] + f * 3] and elo[k][s[2] + f * 3])\n          {\n            mask |= maska[(f ? 126 : 0) ^ ((1<>n;\n  for(int i = 1;i <= n;i++)\n    for(int j = 1;j <= n;j++)\n      cin>>tab[i][j];\n  int xd = 0;\n  for(int i = 1;i <= 6;i++)\n    for(int j = i + 1;j <= 6;j++)\n      for(int k = j + 1;k <= 6;k++)\n        maska[(1<\n#include\n\nusing modular=Modular<1000000007>;\n\nint main(){\n\tstd::ios::sync_with_stdio(0);std::cin.tie(0);\n\tint number; std::cin>>number;\n\t//std::vector> probability(number, std::vector(number));\n\tstd::vector probability(number*number);\n\t//for(auto& row: probability)\n\tfor(auto& value: probability){\n\t\tint percentage; std::cin>>percentage;\n\t\tvalue=modular(1)/100*percentage;\n\t}\n\n\tstd::vector total;\n\n\tint const middle=number/2;\n\tauto const maskValue=[&]{\n\t\tstd::array maskValue;\n\t\tassert(number<=6);\n\t\tint count=0;\n\t\tfor(int matchMask=0; matchMask<(int)maskValue.size(); ++matchMask){\n\t\t\tmaskValue[matchMask]=__builtin_popcount(matchMask)==middle ? count++: -1;\n\t\t}\n\t\ttotal.resize(1<>=1){\n\t\t\t\ttotalProbability*=tmp&1 ?  probability[i]: 1-probability[i];\n\t\t\t\tif(totalProbability==0) goto continue_outer_2;\n\t\t\t}\n\n\t\t\t{ // compute matchSets and call handle\n\t\t\t\t// even more inefficient...?\n\t\t\t\tstd::array data{};\n\t\t\t\tassert(len<=(int)data.size());\n\t\t\t\tint matchSets{};\n\t\t\t\twhile(true){\n\t\t\t\t\t// process data\n\t\t\t\t\tint matchMask{};\n\t\t\t\t\tfor(int index=0; index>(index*number+data[index])&1)) goto continue_outer;\n\t\t\t\t\t\tif(matchMask&1<\n\nusing namespace std;\n\nlong long solve(long long a,long long b,long long c)\n{\n if((a==0)+(b==0)+(c==0)>=2)\n  return 0;\n \n if(a==0)\n  return solve(min(b,c),b-min(b,c),c-min(b,c))+min(b,c);\n else if(b==0)\n  return solve(a-min(a,c),b+min(a,c),c-min(a,c))+min(a,c);\n else\n  return solve(a-min(a,b),b-min(a,b),c+min(a,b))+min(a,b);\n}\n\nint main()\n{\n long long ans=0;\n long long a,b,c;\n long long tmp;\n \n cin>>a>>b>>c;\n \n ans=solve(a-min(a,b),b-min(a,b),c+min(a,b))+min(a,b);\n ans\n#include \nusing namespace std;\n#define INF 0x3f3f3f3f\n#define pb push_back\nlong minim,i,j,rez;\nvector  V[5];\nlong a,b,c;\n\nint main()\n{\n    cin>>a>>b>>c;\n    V[a%2].pb(a);\n    V[b%2].pb(b);\n    V[c%2].pb(c);\n    sort ( V[0].begin(), V[0].end() );\n    sort ( V[1].begin(), V[1].end() );\n    minim=INF;\n    for ( i=1; i\ntypedef long long ll;\nll min(ll a,ll b)\n{\nif(a>a;\ncin>>b;\ncin>>c;\nll ans = 0;\nwhile(1)\n{\nll sum = a+b+c;\nif(sum==a)break;\nif(sum==b)break;\nif(sum==c)break;\nif(a>b){t=a; a=b; b=t;}\nif(a>c){t=a;a=c;c=t;}\nif(b>c){t=b;b=c;c=b;}\nans+=b;\na+=b;\nb=0;\nc-=b;\n\n}\ncout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\nint main(){\n\tlong long a[3];\n\tcin>>a[0]>>a[1]>>a[2];\n\tif((a[0]+a[i]) % 2 == 0)\n\t\tcout<\n#include\nusing namespace std;\n#define ll long long\nconst int Matsize=85;\nconst int MOD=1000000007;\nll n,k,C[Matsize][Matsize];\nstruct Mat\n{\n    ll mat[Matsize][Matsize];\n    void init()\n    {\n        for(int i=0;i\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define In() freopen(\"in.txt\",\"r\",stdin)\n#define Out() freopen(\"out.txt\",\"w\",stdout)\ntypedef long L;\ntypedef long long LL;\ntypedef unsigned long long ULL;\nconst double Pi=3.1415926535898;\nconst LL mod=1e9+7;\nconst int maxn=2*1e5+5;\nconst int INF=0x3f3f3f3f;\nconst double inf=200005.0;\n\nusing namespace std;\n//------------------------------------------\nconst int N = 90;\nconst int M = 50;\n\nstruct mat {\n    LL a[N][N];\n    mat() { memset(a, 0, sizeof(a)); }\n};\n\nint n, k;\nLL s, c[M][M];\n\nvoid init () {\n    cin >> s >> k;\n    n = k * 2 + 3;\n    for (int i = 0; i <= k; i++) {\n        c[i][0] = c[i][i] = 1;;\n        for (int j = 1; j < i; j++)\n            c[i][j] = c[i-1][j-1] + c[i-1][j];\n    }\n}\n\nmat mul(mat p, mat q) {\n    mat ans;\n    for (int i = 0; i < n; i++) {\n        for (int j = 0; j < n; j++) {\n\n            for (int t = 0; t < n; t++) {\n                ans.a[i][j] += p.a[i][t]*q.a[t][j];\n                ans.a[i][j] %= mod;\n            }\n        }\n    }\n    return ans;\n}\n\nmat mat_pow(mat base, LL t) {\n    mat x;\n    for (int i = 0; i < n; i++) x.a[i][i] = 1;\n\n    while (t) {\n        if (t&1) x = mul(x, base);\n        base = mul(base, base);\n        t /= 2;\n    }\n    return x;\n}\n\nint main () {\n    init();\n    mat base;\n    for (int i = 0; i <= k; i++) {\n        for (int j = 0; j <= i; j++) {\n            base.a[i][j] = base.a[i+k+1][j] = base.a[i][j+k+1] = c[i][j];\n        }\n    }\n    base.a[2*k+2][k] = base.a[2*k+2][2*k+2] = 1;\n    mat ans = mat_pow(base, s);\n    LL res;\n    for (int i = 0; i < 2*k+2; i++) {\n        res= ans.a[2*k+2][i]) % mod;\n    }\n    cout <\n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef vector  > matrix;\n\nll mod = 1000000007;\n\nll mnogo = 7e18;\n\nmatrix umnm (const matrix & a, const matrix & b)\n{\n    matrix res(a.size(), vector  (b[0].size()));\n    for (int i = 0; i < a.size(); i++)\n        for (int j = 0; j < b[0].size(); j++)\n            for (int g = 0; g < a.size(); g++) {\n                res[i][j] += (a[i][g] * b[g][j]);\n                if (res[i][j] >= mnogo)\n                    res[i][j] %= mod;\n            }\n    for (int i = 0; i < res.size(); ++i) {\n        for (int j = 0; j < res[0].size(); ++j)\n            if (res[i][j] >= mod)\n                res[i][j] %= mod;         \n    return res;\n}\n\nmatrix pw (matrix a, matrix & res, ll n)\n{\n    while (n)\n    {\n        if (n & 1ll)\n            res = umnm (a, res);\n        a = umnm (a, a);\n        n >>= 1;\n    }\n    return res;\n}\n\nll pw (ll x, int st)\n{\n    if (st < 0) return 0;\n    ll res = 1;\n    while (st--)\n    {\n        res = (res * x) % mod;\n    }\n    return res;\n}\n\nint main()\n{\n\n    ll C[100][100];\n\n    C[0][0] = 1;\n    for (int j = 1; j < 100; j++)\n        C[0][j] = 0;\n\n    for (int i = 1; i < 100; i++)\n    {\n        C[i][0] = 1;\n        for (int j = 1; j < 100; j++)\n            C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;\n    }\n\n    ll n;\n    int k;\n    cin >> n >> k;\n\n    matrix base(2 * k + 3, vector  (2 * k + 3));\n    //1\n\n    for (int i = 0; i <= k; i++)\n        base[i][i + k + 1] = 1;\n\n    for (int i = k + 1; i <= 2 * k + 1; i++) // - k - 1\n    {\n        for (int j = 0; j <= k; j++)\n            base[i][j] = (C[i - k - 1][j] * pw (2, i - k - 1 - j)) % mod;\n        for (int j = k + 1; j <= 2 * k + 1; j++)\n            base[i][j] = C[i - k - 1][j - k - 1];\n    }\n\n    base[2 * k + 2][2 * k + 1] = 1;\n    base[2 * k + 2][2 * k + 2] = 1;\n\n    \n\n    matrix A (2 * k + 3, vector  (1));\n    for (int i = 0; i <= k; i++)\n        A[i][0] = 1;\n    for (int i = k + 1; i <= 2 * k + 1; i++)\n        A[i][0] = pw(2, i - k);\n    A[2 * k + 2][0] = 1;\n    base = pw (base, A, n - 1);\n    cout << A[2 * k + 2][0];\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "63dedf6807f292aff22587566b2c2087", "src_uid": "14f50a111db268182e5927839a993118", "difficulty": null}
    {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef long long LL;\nconst LL MOD = 1000000000 + 7;\nconst int NICO = 100;\nconst int MAKI = 100;\n\nstruct M\n{\n    LL a[NICO][NICO];\n    M() { memset(a,0,sizeof(a)); }\n};\n\nint n, k;\nLL s, c[NICO][NICO];\n\nvoid init()\n{\n    n = 2*k+3;\n    for(int i=0;i<=k;i++)\n    {\n        c[i][0] = c[i][i] = 1;\n        for(int j=1;j> s >> k, init();\n    M A;\n    for (int i = 0; i <= k; ++i)\n    {\n        for (int j = 0; j <= i; ++j)\n        {\n            A.a[i][j] = A.a[i+k+1][j] = A.a[i][j+k+1] = c[i][j];\n        }\n    }\n    A.a[2*k+2][k] = A.a[2*k+2][2*k+2] = 1;\n    A = qpow(A, s);\n    LL res = 0;\n    for(int i=0;i<2*k+2;i++)\n    {\n        res = (res + A.a[2*k+2][i]) % MOD;\n    }\n    cout << res << endl;\n\n}\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "47b8409484e694ab1c63fd5657aa4a06", "src_uid": "14f50a111db268182e5927839a993118", "difficulty": null}
    {"lang": "GNU C++11", "source_code": "\\#include \n#include \nusing namespace std;\ntypedef long long ll;\nconst int maxn=2000+10;\nconst int mod=998244353;\nll mypow(ll x, ll res){\n\tll ans=1;\n\twhile(res){\n\t\tif(res&1) ans=ans*x%mod;\n\t\tx=x*x%mod;\n\t\tres>>=1;\n\t}\n\treturn ans;\n}\nvoid update(ll& x, ll y){\n\tx=(x+y)%mod;\n}\nll dp[maxn*2][maxn][2];\nint main(){\n\tint n, k, l;\n\tscanf(\"%d%d%d\", &n, &k, &l);\n\tdp[0][0][0]=1;\n\tfor(int i=0; i<=2*n+1; i++)\n\t\tfor(int j=0; j<=n; j++)\n\t\t\tfor(int x=0; x<=1; x++){\n\t\t\t\tif(!dp[i][j][x]) continue;\n\t\t\t\tif(i+j<2*n+x) update(dp[i+1][j+1][x], dp[i][j][x]);\n\t\t\t\tif(j) update(dp[i+1][j-1][x], dp[i][j][x]*j);\n\t\t\t\tif(j>=k && !x) update(dp[i+1][j][1], dp[i][j][x]);\n\t\t\t}\n\tll tmp=1;\n\tfor(int i=1; i<=n; i++)\n\t\ttmp=tmp*i%mod;\n\tll ans=l*dp[2*n+1][0][1]%mod*tmp%mod*mypow(2, n)%mod;\n\tfor(int i=n+1; i<=2*n+1; i++)\n\t\ttmp=tmp*i%mod;\n\tans=ans*mypow(tmp, mod-2)%mod;\n\tprintf(\"%lld\", ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8eb172b887b8e21d94f39f57babbb162", "src_uid": "c9e79e83928d5d034123ebc3b2f5e064", "difficulty": 2600.0}
    {"lang": "GNU C++11", "source_code": "hide code 1 #include\n#define Rint register int\nusing namespace std;\ntypedef long long LL;\nconst int N = 4003, mod = 998244353;\nint fac[N], inv[N], invfac[N], po[N];\ninline void init(int m){\n    fac[0] = 1;\n    for(Rint i = 1;i <= m;i ++) fac[i] = (LL) i * fac[i - 1] % mod;\n    inv[1] = 1;\n    for(Rint i = 2;i <= m;i ++) inv[i] = (LL) (mod - mod / i) * inv[mod % i] % mod;\n    invfac[0] = 1;\n    for(Rint i = 1;i <= m;i ++) invfac[i] = (LL) invfac[i - 1] * inv[i] % mod;\n    po[0] = 1;\n    for(Rint i = 1;i <= m;i ++) po[i] = (po[i - 1] << 1) % mod;\n}\ninline int C(int n, int m){\n    if(n < m || m < 0) return 0;\n    return (LL) fac[n] * invfac[n - m] % mod * invfac[m] % mod;\n}\nint n, k, l, ans, f[N];\nint main(){\n    scanf(\"%d%d%d\", &n, &k, &l);\n    init(n << 1 | 1);\n    for(Rint i = k;i <= n;i ++)\n        for(Rint j = 0;j <= i;j ++){\n            int t = (LL) C(i, j) * inv[i + j + 1] % mod;\n            if(j & 1) f[i] = (f[i] + mod - t) % mod; else f[i] = (f[i] + t) % mod;\n        }\n    for(Rint i = k;i <= n;i ++){\n        int t1 = 0;\n        for(Rint j = 0;j <= n - i;j ++){\n            int t2 = (LL) po[i + j] * C(n - i, j) % mod * f[i + j] % mod;\n            if(j & 1) t1 = (t1 + mod - t2) % mod; else t1 = (t1 + t2) % mod;\n        }\n        ans = (ans + (LL) t1 * C(n, i) % mod) % mod;\n    }\n    printf(\"%d\", (LL) l * ans % mod);\n}\n\nCF1153F", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8a246d77c8f8c17e2f1b81e57cc44186", "src_uid": "c9e79e83928d5d034123ebc3b2f5e064", "difficulty": 2600.0}
    {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\n\ntypedef long long LL;\nconst LL mod=998244353;\nconst LL maxn=2005;\nLL dp[maxn<<1][maxn],fac[maxn<<1]; \nint N,K,L;\n\nLL gcd(LL a,LL b,LL& d,LL& x,LL& y)\n{\n\tif(!b)\n\t{\n\t\td=a;\n\t\tx=1;\n\t\ty=0;\n\t}\n\telse\n\t{\n\t\tgcd(b,a%b,d,y,x);\n\t\ty-=x*(a/b);\n\t}\n}\nLL inv(LL a)\n{\n\tLL d,x,y;\n\tgcd(a,mod,d,x,y);\n\treturn d==1 ? (x+mod)%mod:-1;\n}\nint main()\n{\n\tfac[1]=1;\n\tfor(int i=2;i<2*maxn-1;i++)\n\t\tfac[i]=fac[i-1]*i%mod;\n\tscanf(\"%d%d%d\",&N,&K,&L);\n\tdp[0][0]=1;\n\tfor(int i=0;i<=(N<<1);i++)\n\t\tfor(int j=0;j<=min(i,N);j++)\n\t\t{\n\t\t\tdp[i+1][j+1]=(dp[i][j]+dp[i+1][j+1])%mod; \n\t\t\tif(j)\n\t\t\t\tdp[i+1][j-1]=(dp[i+1][j-1]+(dp[i][j]*j)%mod)%mod;\n\t\t}\n\tLL ans=0;\n\tfor(int i=1;i<=(N<<1);i++)\n\t\tfor(int j=K;j<=min(i,N);j++)\n\t\t\tans=(ans+(dp[i][j]*dp[N*2-i][j]%mod)*fac[j]%mod)%mod;\n\tans=(ans*L)%mod;\n\tLL q=dp[N*2][0]*(2*N+1)%mod;\n\tprintf(\"%I64d\\n\",ans*inv(q)%mod);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7c5ac50c4a7acca71ff0de6d48b8802d", "src_uid": "c9e79e83928d5d034123ebc3b2f5e064", "difficulty": 2600.0}
    {"lang": "GNU C++11", "source_code": "1", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cd25dcf5a11e9f857f687a9134719ae8", "src_uid": "c9e79e83928d5d034123ebc3b2f5e064", "difficulty": 2600.0}
    {"lang": "GNU C++", "source_code": "/*\n*\tID : pallab81\n* \tPROG : C\n* \tLANG : C++\n* \t2012-07-30-23.00.57 Monday\n*\n* \t\"I have not failed, I have just found 10000 ways that won't work.\n*/\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n\n#define foR(i1,st,ed) for(int i1 = st , j1 = ed ; i1 < j1 ; ++i1 )\n#define fo(i1,ed) foR( i1 , 0 , ed )\n#define foE(i1,st,ed) foR( i1, st, ed+1 )\n#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)\n#define bip system(\"pause\")\n#define Int long long\n#define pb push_back\n#define SZ(X) (int)(X).size()\n#define LN(X) (int)(X).length()\n#define mk make_pair\n#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )\n#define line puts(\"\")\n\ntemplate\ninline void debug(T1 _x) {\n    cout<<_x<<'\\n';\n}\ntemplate\ninline void debug(T1 _x,T2 _y) {\n    cout<<_x<<' '<<_y<<'\\n';\n}\ntemplate\ninline void debug(T1 _x,T2 _y,T3 _z) {\n    cout<<_x<<' '<<_y<<' '<<_z<<'\\n';\n}\ntemplate\ninline void debug(T1 _x,T2 _y,T3 _z,T4 _zz) {\n    cout<<_x<<' '<<_y<<' '<<_z<<' '<<_zz<<'\\n';\n}\ntemplate< class T1>\ninline void debug(T1 _array,int _size) {\n    cout<<\"[\";\n    for (int i=0; i<_size; ++i) {\n        cout<<' '<<_array[i];\n    }\n    puts(\" ]\");\n}\ninline bool CI(int &_x) {\n    return scanf(\"%d\",&_x)==1;\n}\ninline bool CI(int &_x, int &_y) {\n    return CI(_x)&&CI(_y) ;\n}\ninline bool CI(int &_x, int &_y, int &_z) {\n    return CI(_x)&&CI(_y)&&CI(_z) ;\n}\ninline bool CI(int &_x, int &_y, int &_z, int &_zz) {\n    return CI(_x)&&CI(_y)&&CI(_z)&&CI(_zz) ;\n}\ninline void wait( double seconds ) {\n    double endtime = clock()+( seconds* CLOCKS_PER_SEC );\n    while( clock() < endtime ) {\n        ;\n    }\n}\nint jobcount;\nvector dep[205];\nvector mechines[5];\n\ninline void Read() {\n    fo(i,205) {\n        dep[i].clear();\n    }\n    fo(i,5) {\n        mechines[i].clear();\n    }\n\n    CI(jobcount);\n    int at;\n    fo(i,jobcount) {\n        CI(at);\n        mechines[at-1].pb(i);\n    }\n    int tmp,depon;\n    fo(i,jobcount) {\n        CI(tmp);\n        fo(j,tmp) {\n            //job i dependes on job\n            CI(depon);\n            dep[i].pb(depon-1);\n        }\n    }\n\n}\nint finished[205];\ninline bool allclear(int job) {\n    foit(i, dep[job] ) {\n        if(!finished[ (*i)] )return false;\n    }\n    return true;\n}\nint go(int M) {\n    int ret=0;\n    int cnt=0;\n    while(true) {\n        while(true) {\n            int change=0;\n            foit( i, mechines[M]) {\n                if( finished[ (*i) ] )continue;\n                if( allclear( (*i) ) ) {\n                    finished[ (*i) ]=1;\n                    ++ret;\n                    ++cnt;\n                    change=1;\n                    any=1;\n                }\n            }\n            if(!change)break;\n        }\n\n        if(cnt>=jobcount)break;\n        ret= ret+1;\n        M=(M+1)%3;\n    }\n    return ret;\n}\ninline void Proc() {\n    int best = 1023456789;\n    fo(i,3) {\n        SET(finished,0);\n        best = min( best, go(i) );\n    }\n    cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \nusing namespace std;\n \n#define FOR(i,a,b) for(int i=a;i VI;\ntypedef vector VS;\ntypedef vector< vector  > VVI;\ntypedef pair pii;\n\nint n;\nint deg[201],temp[201]; \nbool graph[201][201];\n\nint mach[201];\nint main() {\n   int n;\n   cin>>n;\n   REP(i,n) {\n       cin>>mach[i];\n       mach[i]--;\n   }\n   REP(i,n) {\n      int x;\n      cin>>x;\n      REP(j,x) {\n         int y; cin>>y;\n         y--;\n         graph[i][y]=1;\n         deg[i]++;\n      }    \n   }\n   memcpy(temp,deg,sizeof(deg));\n   int ans=INF;\n   for(int z=2; z>=0; z--) {\n       int k=z;\n       int num_v = n;\n       int cnt=0;\n       while(true)  {\n         \n                REP(i,n) {\n                    if(mach[i]==k && deg[i]==0){\n                         deg[i]=-1;\n                         REP(j,n) {\n                               if(graph[j][i]) deg[j]--;\n                         }\n                         num_v--;\n                         i=-1;\n                    }\n                }\n                if(num_v > 0) {\n                   k = (k+1)%3;\n                   cnt++;\n                }\n                else break;\n           \n       }\n       ans = min(ans,cnt+n);    \n       memcpy(deg,temp,sizeof(deg));\n   }\n   \n\n   cout<\n#include \n#include \n#include \nusing namespace std;\n\n#define pb push_back\n\nconst int MAX_N = 200 * 1000 +20;\nvector  adj[MAX_N];\nvector  a[MAX_N];\nvector  T_S;\nbool node[MAX_N];\nbool mark[MAX_N];\nint P[MAX_N];\nint n , ans , Size;\n\n\nvoid Topology_Sort ( int v ){\n\tnode[v] = 1;\n\tfor ( int i = 0 ; i < adj[v].size() ; i++ ){\n\t\tint u = adj[v][i];\n\t\tif ( !node[u] )\n\t\t\tTopology_Sort(u);\n\t}\n\tT_S.pb(v);\n}\n\n\nvoid Computer ( int place ){\n\tint sum = 0;\n\tfor ( int i = Size-1 ; i >= 0 ; i-- ){\n\t\tint v = T_S[i];\n\t\tif ( !mark[v] && P[v] == place ){\n\t\t\tbool flag = 1;\n\t\t\tfor ( int j = 0 ; j < a[v].size() ; j++ ){\n\t\t\t\tint u = a[v][j];\n\t\t\t\tif ( !mark[u] )\n\t\t\t\t\tflag = 0;\n\t\t\t}\n\t\t\tif ( flag ) {\n\t\t\t\tsum++;\n\t\t\t\tmark[v] = 1;\n\t\t\t}\n\n\t\t} else if ( mark[v] )\n\t\t\tsum++;\n\t}\n\tif ( sum != n ){\n\t\tans++;\n\t\tplace++;\n\t\tplace %= 3;\n\t\tif ( !place )\n\t\t\tplace = 3;\n\t\treturn Computer( place );\n\t}\n}\n\n\nint main()\n{\n\tcin >> n;\n\tfor ( int i = 0 ;i < n ; i++ )\n\t\tcin >> P[i];\n\tfor ( int v = 0 ; v < n ; v++ ){\n\t\tint deg;\n\t\tcin >> deg;\n\t\twhile ( deg > 0 ){\n\t\t\tint u ;\n\t\t\tcin >> u;\n\t\t\t--u;\n\t\t\tadj[u].pb(v);\n\t\t\ta[v].pb(u);\n\t\t\tdeg--;\n\t\t}\n\t}\n\tfor ( int i = 0 ; i < n ; i++ )\n\t\tif ( !node[i] )\n\t\t\tTopology_Sort(i);\n\tSize = T_S.size();\n\tans = 0;\n\tint answer = 0;\n\tComputer(1);\n\tanswer = ans;\n\t///////////////\n\tans = 0;\n\tmemset( mark , 0 , sizeof mark);\n\tComputer(2);\n\tanswer = min ( ans , answer );\n\t////////////////\n\tans = 0;\n\tmemset( mark , 0 , sizeof mark);\n\tComputer(3);\n\tanswer = min ( ans , answer );\n\tcout << answer+n << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "34e1f2def829ace877ace7d5493439dd", "src_uid": "be42e213ff43e303e475d77a9560367f", "difficulty": 1700.0}
    {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define MOD (1000000000+7) \n#define INF 1000000000\ntypedef unsigned long long  ull;\ntypedef pair pii;\n\n#define ll long long\n\nll n;\nll comp[201];\n\nstruct graph\n{\n\tvector  mat[201];\n\tvector  ind;\n\tgraph()\n\t{\n\t\tind.resize(201);\n\t\tfor(ll i = 0; i < 201; i ++)\n\t\t\tmat[i].resize(201),\n\t\t\tind[i] = 0;\n\t}\n\tbool operator==(const graph &two)const\n\t{\n\t\tfor(ll i = 1; i <= n; i ++)\n\t\t\tif(ind[i] != two.ind[i])\n\t\t\t\treturn false;\n\t\treturn true;\n\t}\n\tbool operator<(const graph &two)const\n\t{\n\t\treturn ind < two.ind;\n\t}\n};\n\n#define pig pair\n\nmap  dp;\n\nll getDis(ll u, ll v)\n{\n\tll res = 0;\n\twhile(u != v)\n\t{\n\t\tu ++;\n\t\tif(u == 4)\n\t\t\tu = 1;\n\t\tres ++;\n\t}\n\treturn res;\n}\nll f(ll u, graph g)\n{\n\tif( dp.count( pig(u,g) ) )\n\t\treturn dp[pig(u,g)];\n\t\n\tll &ref = dp[pig(u,g)] = INF;\n\t\n\t// cout << \"HERE \";\n\t// for(ll i = 1; i <= n; i ++)\n\t// {\n\t\t// cout << g.ind[i] << \" \";\n\t// }\n\t// cout << endl;\n\t\n\tfor(ll i = 1; i <= n; i ++)\n\t{\n\t\tif(g.ind[i] == 0)\n\t\t{\n\t\t\tg.ind[i] = -1;\n\t\t\t\n\t\t\tfor(ll j = 1; j <= n; j ++)\n\t\t\t\tif(g.mat[i][j] == 1)\n\t\t\t\t\tg.ind[j] --;\n\t\t\t\n\t\t\tll move = getDis(u, comp[i]);\n\t\t\tref = min( ref, move+f(comp[i],g) );\n\t\t\t// cout << \"HERdddddddE \" << ref << endl;\n\t\t\t\n\t\t\tfor(ll j = 1; j <= n; j ++)\n\t\t\t\tif(g.mat[i][j] == 1)\n\t\t\t\t\tg.ind[j] ++;\n\t\t\t\n\t\t\tg.ind[i] = 0;\n\t\t}\n\t}\n\tif(ref == INF)\n\t\treturn 0;\n\treturn ref;\n}\n\nint main()\n{\n\tcin >> n;\n\tfor(ll i = 1; i <= n; i ++)\n\t\tcin >> comp[i];\n\t\n\tgraph g;\n\tfor(ll i = 1; i <= n; i ++)\n\t{\n\t\tll k, prev;\n\t\tcin >> k;\n\t\tfor(ll j = 0; j < k; j ++)\n\t\t{\n\t\t\tcin >> prev;\n\t\t\tg.mat[prev][i] = 1;\n\t\t\tg.ind[i] ++;\n\t\t}\n\t}\n\t\n\t// for(ll i = 1; i <= n; i ++)\n\t// {\n\t\t// for(ll j = 1; j <= n; j ++)\n\t\t\t// cout << g.mat[i][j] << \" \";\n\t\t// cout << endl;\n\t// }\n\t\n\t// cout << f(1, g) << endl;\n\t// cout << f(2, g) << endl;\n\t// cout << f(3, g) << endl;\n\t// cout << \"===\" << endl;\n\tll mn = min( f(1, g), f(2, g) );\n\tmn = min( mn, f(3, g) );\n\t\n\tcout << mn+n << endl;\n\t\n\treturn 0;\n}\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a1e1baee3c0d86925de4407035a5aad5", "src_uid": "be42e213ff43e303e475d77a9560367f", "difficulty": 1700.0}
    {"lang": "GNU C++17", "source_code": "#include\n\nusing namespace std;\n\n//FILE *INFILE,*OUTFILE;\n \nbool e[11][11];\nint a[11];\nint n,m,k;\nint ans;\nbool vis[11];\n \nbool check() \n{\n\tint indgr[11];\n\tint st[11];\n\tint top=0;\n\tfor (int i=1;i<=n;i++)\n\t\tindgr[i]=1;\n\tfor (int i=1;i<=n-2;i++)\n\t\tindgr[a[i]]++;\n\tfor (int i=1;i<=n;i++)\n\t\tif (indgr[i]==1)\n\t\t\tst[top++]=i;\n\tfor (int i=1;i<=n-2;i++) \n\t{\n\t\tint to=a[i],m=n+1,p;\n\t\tfor (int j=0;jn-k)\n\t\treturn;\n\tif (i==n-1) \n\t{\n\t\tif (n-cnt==k && check())\n\t\t\tans++;\n\t\treturn;\n\t}\n\n\tfor (int t=1;t<=n;t++) \n\t{\n\t\ta[i]=t;\n\t\tbool flag=false;\n\t\tif (!vis[t]) \n\t\t{\n\t\t\tflag=true;\n\t\t\tvis[t]=true;\n\t\t\tcnt++;\n\t\t}\n\t\tdfs(i + 1);\n\t\ta[i]=0;\n\t\tif (flag) \n\t\t{\n\t\t\tvis[t]=false;\n\t\t\tcnt--;\n\t\t}\n\t}\n}\n \nint main() \n{\n//\tINFILE=fopen(\"tactic.in\",\"r\");\n//\tOUTFILE=fopen(\"tactic.out\",\"w\");\n\tfscanf(INFILE,\"%d%d%d\",&n,&m,&k);\n\tfor (int i=1;i<=m;i++) \n\t{\n\t\tint v1,v2;\n\t\tfscanf(INFILE,\"%d%d\",&v1,&v2);\n\t\te[v1][v2]=true;\n\t\te[v2][v1]=true;\n\t}\n\tdfs(1);\n\tfprintf(OUTFILE,\"%d\\n\",ans);\n//\tfclose(INFILE);\n//\tfclose(OUTFILE);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e4f40ba1cdd140840fa896419fe648b2", "src_uid": "8087605a8f316150372cc4627f26231d", "difficulty": 2500.0}
    {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\n#define forn(i, n) for (int i = 0; i < (n); i++)\n\nconst int N = 10;\n\nint n, m, k, g[N], f[N + 1][1 << N][1 << N];\n\nint main() {\n\tcin >> n >> m >> k;\n\twhile (m--) {\n\t\tint a, b;\n\t\tcin >> a >> b, a--, b--;\n\t\tg[a] |= 1 << b;\n\t\tg[b] |= 1 << a;\n\t}\n\t#define SUB(A, S) for (int U = S, A = U; A > 0; A--, A &= S) \n\tint all = (1 << n) - 1;\n\tSUB(B, g[n - 1])\n\t\tf[bn(B) == 1][1 << (n - 1)][B] = 1;\n\tfor (int A = 0; A < all; A++)\n\t\tfor (int add = max(0, k - bn(all ^ A)); add <= bn(A); add++)\n\t\t\tSUB(B, all ^ A) {\n\t\t\t\tconst int F = f[add][A][B];\n\t\t\t\tif (!F || add + bn(B) > k) continue;\n\t\t\t\tint v = __builtin_ctz(B), A1 = A ^ (1 << v), B1 = B ^ (1 << v);\n\t\t\t\tf[add + 1][A1][B1] += F;\n\t\t\t\tSUB(C, (all ^ A ^ B) & g[v])\n\t\t\t\t\tf[add][A1][B1 | C] += F;\n\t\t\t}\n\tcout << f[k][all][0] << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ddbdc41006a97b39baa20eaa84a88da3", "src_uid": "8087605a8f316150372cc4627f26231d", "difficulty": 2500.0}
    {"lang": "GNU C++11", "source_code": "#include \n\nconst size_t maxN = 11;\n\nint N, M, K;\nbool G[maxN][maxN];\nint F[1 << 10 | 1][1 << 10 | 1];\n\nint main()\n{\n\tscanf(\"%d%d%d\", &N, &M, &K);\n\tfor (int a, b; M--;)\n\t{\n\t\tscanf(\"%d%d\", &a, &b);\n\t\t--a, --b;\n\t\tG[a][b] = G[b][a] = true;\n\t}\n\n\tfor (int i = 0; i != N; ++i)\n\t\tF[1 << i][1 << i] = 1;\n\n\tfor (int s1 = 1; s1 != 1 << N; ++s1)\n\t\tfor (int s2 = s1; s2; s2 = (s2 - 1) & s1)\n\t\t\tif (F[s1][s2])\n\t\t\t{\n\t\t\t\tfor (int i = 0; i != N; ++i)\n\t\t\t\t\tif (s1 >> i & 1)\n\t\t\t\t\t\tfor (int j = 0; j != N; ++j)\n\t\t\t\t\t\t\tif (G[i][j] && (~s1 >> j & 1))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tint ss1 = s1 | (1 << j);\n\t\t\t\t\t\t\t\tint ss2 = s2 | (1 << j);\n\t\t\t\t\t\t\t\tif (ss2 >> i & 1)\n\t\t\t\t\t\t\t\t\tss2 ^= 1 << i;\n\t\t\t\t\t\t\t\tif (!(ss2 >> j + 1))\n\t\t\t\t\t\t\t\t\tF[ss1][ss2] += F[s1][s2];\n\t\t\t\t\t\t\t}\n\t\t\t}\n\n\tint ans = 0;\n\tfor (int s = 1; s != 1 << N; ++s)\n\t\tif (__builtin_popcount(s) == K)\n\t\t\tans += F[(1 << N) - 1][s];\n\n\tprintf(\"%d\\n\", ans);\n\n\treturn 0;\n}#include \n\nconst size_t maxN = 11;\n\nint N, M, K;\nbool G[maxN][maxN];\nint F[1 << 10 | 1][1 << 10 | 1];\n\nint main()\n{\n\tscanf(\"%d%d%d\", &N, &M, &K);\n\tfor (int a, b; M--;)\n\t{\n\t\tscanf(\"%d%d\", &a, &b);\n\t\t--a, --b;\n\t\tG[a][b] = G[b][a] = true;\n\t\tF[(1 << a) | (1 << b)][(1 << a) | (1 << b)] = 1;\n\t}\n\n\tfor (int s1 = 1; s1 != 1 << N; ++s1)\n\t\tfor (int s2 = s1; s2; s2 = (s2 - 1) & s1)\n\t\t\tif (F[s1][s2])\n\t\t\t{\n\t\t\t\tfor (int i = 0; i != N; ++i)\n\t\t\t\t\tif (s1 >> i & 1)\n\t\t\t\t\t\tfor (int j = 0; j != N; ++j)\n\t\t\t\t\t\t\tif (G[i][j] && (~s1 >> j & 1))\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tint ss1 = s1 | (1 << j);\n\t\t\t\t\t\t\t\tint ss2 = s2 | (1 << j);\n\t\t\t\t\t\t\t\tif (ss2 >> i & 1)\n\t\t\t\t\t\t\t\t\tss2 ^= 1 << i;\n\t\t\t\t\t\t\t\tif (!(ss2 >> j + 1))\n\t\t\t\t\t\t\t\t\tF[ss1][ss2] += F[s1][s2];\n\t\t\t\t\t\t\t}\n\t\t\t}\n\n\tint ans = 0;\n\tfor (int s = 1; s != 1 << N; ++s)\n\t\tif (__builtin_popcount(s) == K)\n\t\t\tans += F[(1 << N) - 1][s];\n\n\tprintf(\"%d\\n\", ans);\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4ab7cb1c1f6a1de0b5492c4cc4a0b3c5", "src_uid": "8087605a8f316150372cc4627f26231d", "difficulty": 2500.0}
    {"lang": "GNU C++11", "source_code": "/*///in the name of god\n///12/11/94\n#include \n#include \n\n\nusing namespace std;\nint m\nint n,m,\nvector > >E,H;\nint par[maxn],dad[maxn][log],\nint get_par(int u){\n    if(par[u] == u) return u;\n    else return get_par(par[u]);\n}\nvoid kruskal(){\n    sort(G.begin() , G.end());\n    for(int i = 0 ; i < m ; i++){\n            int u = G[i].S.S , v = G[i].S.F , w = G[i].F;\n            if(get_par(u) != get_par(v)){\n                par[u] = v;\n                mst += w;\n                adj[u].mp(v , w);\n                adj[v].mp(u , w);\n            }\n    }\n}\nint lca(int u , int v){\n    if(h[u] < h[v]) swap(u ,v);\n    v = get_dad(v  , h[u] - h[v]);\n    if(u == v) return v;\n    for(int i = log - 1 ; i >= 0  ; i--){\n            if(u != v)\n                u = dad[u][i] , v = dad[u][i];\n    }\n    return par[v][0];\n}\nint get_parent(int v, int a){\n\tfor (int i = 0; i > i) & 1)\n\t\t\tv = dad[v][i];\n\treturn v;\n}\nint get_max(int v, int a){\n\tint res = 0;\n\tfor (int i=0; i> i) & 1)\n\t\t\tres = max(res, mx[v][i]), v = dad[v][i];\n\treturn res;\n}\nvoid solve(int u,int v,int w){\n    cp = lca(v , u);\n    return  mst - (max(get_max(u , cp) , get_max(v , cp))) + w;\n}\nvoid dfs(int u , int p){\n    for(int i = 0 ; i> n >> m;\n    for(int i = 0 ; i< m ; i++){\n        cin >> u >> v >> w; u--,v--;\n        G.pb(mp(w , mp(u , v)));\n        E.pb(mp(w , mp(u , v)));\n    }\n    for(int i = 0 ; i < n ; i++) par[i] = i;\n    kruskal();\n    dfs(0 , -1);\n    for(int i = 0 ;  i < m ; i++)\n        cout << solve(E[i].S.S , E[i].S.S) << endl;\n}\n*//*\n#include \n#include \n#define pb push_back\n\nusing namespace std;\nconst int maxn = 1000 * 100 + 7, lg = 29 ;\nint n,q,par[maxn][lg],child[maxn],d[maxn];\nvector  adj[maxn];\nvoid dfs(int u,int p){\n    for(int i = 0 ; i < adj[u].size() ; i++){\n        int v = adj[u][i];\n        if(p == v) continue;\n        par[v][0] = u;\n        for(int j = 1 ; j < lg ; j++){\n            par[v][j] = par[par[v][j - 1]][j - 1];\n        }\n        d[v] = d[u] + 1;\n        dfs(v , u);\n        child[u] = child[u] + child[v] + 1;\n    }\n}\nint dad(int u ,int k){\n    for(int i = lg - 1 ; i >= 0 ; i--)\n            if((k & (1 << i)) == (1 << i)){\n                u = par[u][i];\n            }\n    return u;\n}\nint LCA(int a,int b){\n    if(d[a] < d[b]) swap(a , b);\n    a = dad(a , d[a]- d[b]);\n    if(a == b) return b;\n        for(int i = lg - 1  ; i>=0 ; i--)\n            if(par[a][i] != par[b][i]){\n                a = par[a][i];\n                b = par[b][i];\n\n            }\n    return par[a][0];\n}\nint main(){\n    cin >> n;\n    for(int i = 1 ; i < n ; i++){\n        int u,v;\n        cin >> u >> v; u--,v--;\n        adj[u].pb(v);\n        adj[v].pb(u);\n    }\n    dfs(0 , -1);\n    cin >> q;\n    while(q--){\n        int a,b;\n        cin >> a >> b; a--,b--;\n        int lca = LCA(a , b);\n        int D1 = d[a] - d[lca] , D2 =  d[b] - d[lca];\n        int dis = D1 + D2 ;\n        if(a == b)\n                cout << n << endl;\n        else if(dis % 2)\n                cout << 0 << endl;\n        else if(D1 == D2){\n                int pa =  dad(a , D1 -  1) , pbb = dad(b ,D2 - 1);\n                cout   << n - (child[pa] + child[pbb] + 2) << endl;\n        }\n        else{\n                if(D1 < D2) swap(a , b);\n                int pa = dad(a , (dis/2) - 1) , paa = par[pa][0];\n                cout  << child[paa] - child[pa] << endl;\n        }\n    }\n    return 0;\n}*/\n\n/*\n\n4\n1 2\n2 3\n2 4\n2\n1 2\n1 3\n\n\n15\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n5 8\n6 9\n9 14\n14 15\n7 10\n4 13\n3 11\n3 12\n6\n10 15\n13 12\n2 15\n8 4\n15 12\n6 13\n\n*/\n/// in the name of god\n///lovely problem from lovely person\n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long ll;\nconst int maxn = 10 ;\nll dp[1 << maxn][1 << maxn] ,ans = 0;\nint n,m,k , cnt[1 << maxn];\nbool mat[maxn][maxn];\nvoid makecnt(){\n    for(int i = 0 ; i < (1 << 11) ; i++){\n        if(i % 2) cnt[i] = cnt[i / 2] + 1;\n        else cnt[i] = cnt[i / 2];\n    }\n}\ninline ll DP(int msk,int le){\n\tll res = dp[msk][le];\n\tif (res != -1)\n\t\treturn res;\n\tif (msk == le && cnt[msk] > 2)\n\t\treturn res = 0;\n\tif (cnt[msk] > 1 && cnt[le] < 2)\n\t\treturn res = 0;\n\tif (cnt[msk] == 1)\n\t\treturn res = !le;\n\tif (cnt[msk] == 2){\n\t\tint u =  __builtin_ctz(le & -le);\n\t\tle ^= (1<>par&1) == 0) continue;\n\t\tif (le>>par&1) continue;\n\t\tif (!mat[par][l]) continue;\n\t\tres += DP(msk ^ (1<\n#include \n\n\nusing namespace std;\nint m\nint n,m,\nvector > >E,H;\nint par[maxn],dad[maxn][log],\nint get_par(int u){\n    if(par[u] == u) return u;\n    else return get_par(par[u]);\n}\nvoid kruskal(){\n    sort(G.begin() , G.end());\n    for(int i = 0 ; i < m ; i++){\n            int u = G[i].S.S , v = G[i].S.F , w = G[i].F;\n            if(get_par(u) != get_par(v)){\n                par[u] = v;\n                mst += w;\n                adj[u].mp(v , w);\n                adj[v].mp(u , w);\n            }\n    }\n}\nint lca(int u , int v){\n    if(h[u] < h[v]) swap(u ,v);\n    v = get_dad(v  , h[u] - h[v]);\n    if(u == v) return v;\n    for(int i = log - 1 ; i >= 0  ; i--){\n            if(u != v)\n                u = dad[u][i] , v = dad[u][i];\n    }\n    return par[v][0];\n}\nint get_parent(int v, int a){\n\tfor (int i = 0; i > i) & 1)\n\t\t\tv = dad[v][i];\n\treturn v;\n}\nint get_max(int v, int a){\n\tint res = 0;\n\tfor (int i=0; i> i) & 1)\n\t\t\tres = max(res, mx[v][i]), v = dad[v][i];\n\treturn res;\n}\nvoid solve(int u,int v,int w){\n    cp = lca(v , u);\n    return  mst - (max(get_max(u , cp) , get_max(v , cp))) + w;\n}\nvoid dfs(int u , int p){\n    for(int i = 0 ; i> n >> m;\n    for(int i = 0 ; i< m ; i++){\n        cin >> u >> v >> w; u--,v--;\n        G.pb(mp(w , mp(u , v)));\n        E.pb(mp(w , mp(u , v)));\n    }\n    for(int i = 0 ; i < n ; i++) par[i] = i;\n    kruskal();\n    dfs(0 , -1);\n    for(int i = 0 ;  i < m ; i++)\n        cout << solve(E[i].S.S , E[i].S.S) << endl;\n}\n*//*\n#include \n#include \n#define pb push_back\n\nusing namespace std;\nconst int maxn = 1000 * 100 + 7, lg = 29 ;\nint n,q,par[maxn][lg],child[maxn],d[maxn];\nvector  adj[maxn];\nvoid dfs(int u,int p){\n    for(int i = 0 ; i < adj[u].size() ; i++){\n        int v = adj[u][i];\n        if(p == v) continue;\n        par[v][0] = u;\n        for(int j = 1 ; j < lg ; j++){\n            par[v][j] = par[par[v][j - 1]][j - 1];\n        }\n        d[v] = d[u] + 1;\n        dfs(v , u);\n        child[u] = child[u] + child[v] + 1;\n    }\n}\nint dad(int u ,int k){\n    for(int i = lg - 1 ; i >= 0 ; i--)\n            if((k & (1 << i)) == (1 << i)){\n                u = par[u][i];\n            }\n    return u;\n}\nint LCA(int a,int b){\n    if(d[a] < d[b]) swap(a , b);\n    a = dad(a , d[a]- d[b]);\n    if(a == b) return b;\n        for(int i = lg - 1  ; i>=0 ; i--)\n            if(par[a][i] != par[b][i]){\n                a = par[a][i];\n                b = par[b][i];\n\n            }\n    return par[a][0];\n}\nint main(){\n    cin >> n;\n    for(int i = 1 ; i < n ; i++){\n        int u,v;\n        cin >> u >> v; u--,v--;\n        adj[u].pb(v);\n        adj[v].pb(u);\n    }\n    dfs(0 , -1);\n    cin >> q;\n    while(q--){\n        int a,b;\n        cin >> a >> b; a--,b--;\n        int lca = LCA(a , b);\n        int D1 = d[a] - d[lca] , D2 =  d[b] - d[lca];\n        int dis = D1 + D2 ;\n        if(a == b)\n                cout << n << endl;\n        else if(dis % 2)\n                cout << 0 << endl;\n        else if(D1 == D2){\n                int pa =  dad(a , D1 -  1) , pbb = dad(b ,D2 - 1);\n                cout   << n - (child[pa] + child[pbb] + 2) << endl;\n        }\n        else{\n                if(D1 < D2) swap(a , b);\n                int pa = dad(a , (dis/2) - 1) , paa = par[pa][0];\n                cout  << child[paa] - child[pa] << endl;\n        }\n    }\n    return 0;\n}*/\n\n/*\n\n4\n1 2\n2 3\n2 4\n2\n1 2\n1 3\n\n\n15\n1 2\n1 3\n1 4\n2 5\n2 6\n2 7\n5 8\n6 9\n9 14\n14 15\n7 10\n4 13\n3 11\n3 12\n6\n10 15\n13 12\n2 15\n8 4\n15 12\n6 13\n\n*/\n/// in the name of god\n///lovely problem from lovely person\n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long ll;\nconst int maxn = 10 ;\nll dp[1 << maxn][1 << maxn] ,ans = 0;\nint n,m,k , cnt[1 << maxn];\nbool mat[maxn][maxn];\nvoid makecnt(){\n    for(int i = 0 ; i < (1 << 11) ; i++){\n        if(i % 2) cnt[i] = cnt[i / 2] + 1;\n        else cnt[i] = cnt[i / 2];\n    }\n}\ninline ll DP(int msk,int le){\n\tll res = dp[msk][le];\n\tif (res != -1)\n\t\treturn res;\n\tif (msk == le && cnt[msk] > 2)\n\t\treturn res = 0;\n\tif (cnt[msk] > 1 && cnt[le] < 2)\n\t\treturn res = 0;\n\tif (cnt[msk] == 1)\n\t\treturn res = !le;\n\tif (cnt[msk] == 2){\n\t\tint u =  __builtin_ctz(le & -le);\n\t\tle ^= (1<>par&1) == 0) continue;\n\t\tif (le>>par&1) continue;\n\t\tif (!mat[par][l]) continue;\n\t\tres += DP(msk ^ (1<\nusing namespace std ;\nint a , b , c , i , j ;\nchar m[1005][1005] ; \nint main(){\n\tcin >> a >> b ; \n\tfor ( i = 0 ; i < a ; i ++ ){\n\t\tfor ( j = 0 ; j < b ; j ++ ){\n\t\t\tcin >> m[i][j] ;\n\t\t}\n\t}\n\tfor ( i = 1 ; i < a - 1; i ++ ){\n\t\tfor ( j = 1 ; j < b - 1 ; j ++ ){\n\t\t\tif ( ( m[i - 1][j - 1] != '.' ) &&\n\t\t\t\t ( m[i + 1][j] != '.' ) &&\n\t\t\t\t ( m[i - 1][j] != '.' ) &&\n\t\t\t\t ( m[i][j + 1] != '.' ) &&\n\t\t\t\t ( m[i][j - 1] != '.' ) &&\n\t\t\t\t ( m[i + 1][j + 1] != '.' ) &&\n\t\t\t\t ( m[i + 1][j - 1] != '.' ) &&\n\t\t\t\t ( m[i - 1][j + 1] != '.' ) ){\n\t\t\t\t \tm[i][j + 1] = 'x' ;\n\t\t\t\t \tm[i][j - 1] = 'x' ;\n\t\t\t\t \tm[i + 1][j] = 'x' ;\n\t\t\t\t \tm[i - 1][j] = 'x' ;\n\t\t\t\t \tm[i + 1][j + 1] = 'x' ;\n\t\t\t\t \tm[i - 1][j - 1] = 'x' ;\n\t\t\t\t \tm[i + 1][j - 1] = 'x' ;\n\t\t\t\t \tm[i - 1][j + 1] = 'x' ;\n\t\t\t\t }\n\t\t}\n\t}\n\tc = 1 ;\n\tfor ( i = 0 ; i < a ; i ++ ){\n\t\tfor ( j = 0 ; j < b ; j ++ ){\n\t\t\t// cout << endl << m[i][j] ;\n\t\t\tif ( m[i][j] == '#'){\n\t\t\t\tcout << \"NO\" ;\n\t\t\t\tc = 0 ;\n\t\t\t\tbreak ;\n\t\t\t}\t\n\t\t\t// cout << c ;\n\t\t\tif( c == 0 ){\n\t\t\t\tbreak ;\n\t\t\t}\n\t\t}\n\t\tif(c == 0){\n\t\t\tbreak ;\n\t\t}\n\t}\n\tif ( c == 1 ){\n\t\tcout << \"YES\" ;\n\t}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4c32e514c384d846ace2855c7ebd0af6", "src_uid": "49e5eabe8d69b3d27a251cccc001ab25", "difficulty": 1300.0}
    {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace aad;\n\nint aar[1005][1005];\nint was[1005][1005];\nint n, m;\nchar st;\n\nint main()\n{\n\tcin >> n >> m;\n\n\tint ans = 0, q = 0;\n\n\tfor (int i = 1; i <= n; i++)\n\t{\n\t\tgetchar();\n\t\tfor (int j = 1; j <= m; j++)\n\t\t{\n\t\t\tcin >> aa\n\t\t\tif (aa == '#')\n\t\t\t{\n\t\t\t\taar[i][j] = 0;\n\t\t\t\tans++;\n\t\t\t}\n\t\t\telse\n                aar[i][j] = 1;\n\t\t}\n\t}\n\tfor(int i = 2; i < n; i++)\n\t{\n\t\tfor(int j = 2; j < m; j++)\n\t\t{\n\t\t\tif (aar[i - 1][j] == 0 && aar[i + 1][j] == 0 && aar[i][j - 1] == 0 && aar[i][j + 1] == 0 && aar[i - 1][j - 1] == 0 && aar[i - 1][j + 1] == 0 && aar[i + 1][j + 1] == 0 && aar[i + 1][j - 1] == 0)\n\t\t\t{\n\t\t\t\tif (!was[i - 1][j])\n                {\n                    was[i - 1][j] = 1;\n                    q++;\n                }\n\t\t\t\tif (!was[i + 1][j])\n                {\n                    was[i + 1][j] = 1;\n                    q++;\n                }\n\t\t\t\tif (!was[i][j - 1])\n                {\n                    was[i][j-1]=1;\n                    q++;\n                }\n\t\t\t\tif (!was[i][j + 1])\n                {\n                    was[i][j + 1] = 1;\n                    q++;\n                }\n\t\t\t\tif (!was[i - 1][j - 1])\n                {\n                    was[i - 1][j - 1] = 1;\n                    q++;\n                }\n\t\t\t\tif (!was[i - 1][j + 1])\n                {\n                    was[i - 1][j + 1] = 1;\n                    q++;\n                }\n\t\t\t\tif (!was[i + 1][j + 1])\n                {\n                    was[i + 1][j + 1] = 1;\n                    q++;\n                }\n\t\t\t\tif (!was[i + 1][j - 1])\n                {\n                    was[i + 1][j - 1] = 1;\n                    q++;\n                }\n\t\t\t}\n\t\t}\n\t}\n\tif (ans == q)\n    {\n        cout << \"YES\";\n    }\n    else\n    {\n        cout << \"NO\";\n    }\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7f321355b30b0f05d41d4c1a433a0544", "src_uid": "49e5eabe8d69b3d27a251cccc001ab25", "difficulty": 1300.0}
    {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\ntypedef long long LL;\n\nLL n, m;\nchar s[2000][2000];\nchar ss[2000][2000];\nint main()\n{\n\n    cin >> n >> m;\n    for (int i = 0; i < n; i++)\n        for (int j = 0; j < m; j++)\n        {\n            cin >> s[i][j];\n            ss[i][j] = '.';\n        }\n\n    for (int i = 0; i < n; i++)\n    {\n        for (int j = 0; j < m; j++)\n        {\n            if (i + 2 >= n || j + 2 >= m)\n            {\n                break;\n            }\n            int f = 0;\n            for (int u = 0; u =< 2;u++)\n            {\n                for (int v = 0; v <= 2;v++)\n                {\n                    if(u==1&&v==1)\n                        continue;\n                    if(s[i+u][j+v]=='.')\n                        f = 1;\n                }\n            }\n            if(f!=1)\n            {\n                for (int u = 0; u <= 2;u++)\n            {\n                for (int v = 0; v <= 2;v++)\n                {\n                    if(u==1&&v==1)\n                        continue;\n                    ss[i + u][j + v] = '#';\n                }\n            }\n            }\n        }\n    }\n    int flag = 0;\n    for (int i = 0; i < n; i++)\n    {\n        for (int j = 0; j < m; j++)\n        {\n            if (s[i][j] != ss[i][j])\n            {\n                flag = 1;\n                break;\n            }\n        }\n    }\n    if (flag)\n    {\n        cout << \"NO\" << endl;\n    }\n    else\n        cout << \"YES\" << endl;\n    // system(\"pause\");\n    return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6d41d9512e23be8e691cb4b769ea701b", "src_uid": "49e5eabe8d69b3d27a251cccc001ab25", "difficulty": 1300.0}
    {"lang": "GNU C++17", "source_code": "#include\n#include\n#include\n\nusing namespace std;\nint main(){\n\tint n,m;\n\tcin>>n>>m;\n\tvector>sig(n,vector(m)), temp;\n\tfor(int i=0;i>c;\n\t\t\tif(c=='\\n')j--;\n\t\t\telse if(c=='#') sig[i][j]=true;\n\t\t\telse sig[i][j]=false;\n\t\t}\n\t}\n\ttemp=sig;\n\tfor(int i=0;i=m || j+2>=n){\n\t\t\t\t\tcout<<\"NO\";\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t\tfor(int ii=0;ii<3;ii++){\n\t\t\t\t\tfor(int jj=0;jj<3;jj++){\n\t\t\t\t\t\tif(ii==1 && jj==1) continue;\n\t\t\t\t\t\tif(temp[i+ii][j+jj]==false){\n\t\t\t\t\t\t\tcout<<\"NO\";\n\t\t\t\t\t\t\treturn 0;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsig[i+ii][j+jj]=false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t//\n\t\t\telse if(temp[i][j]){\n\t\t\t\tif(i+2>=m || j+2>=n) continue;\n\t\t\t\telse{\n\t\t\t\t\tbool p=true;\n\t\t\t\t\tfor(int ii=0;ii<3;ii++){\n\t\t\t\t\t\tfor(int jj=0;jj<3;jj++){\n\t\t\t\t\t\t\tif(ii==1 && jj==1) continue;\n\t\t\t\t\t\t\tif(!temp[i+ii][j+jj]) p=false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif(p){\n\t\t\t\t\t\tfor(int ii=0;ii<3;ii++){\n\t\t\t\t\t\t\tfor(int jj=0;jj<3;jj++){\n\t\t\t\t\t\t\t\tif(ii==1 && jj==1) continue;\n\t\t\t\t\t\t\t\tsig[i+ii]+[j+jj]=false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tcout<<\"YES\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "be778e7e1d74df9b4348edd7f7bacac2", "src_uid": "49e5eabe8d69b3d27a251cccc001ab25", "difficulty": 1300.0}
    {"lang": "GNU C++17", "source_code": "#ifdef DEBUG\n#define _GLIBCXX_DEBUG\n#endif\n//#pragma GCC optimize(\"O3\")\n#include \nusing namespace std;\ntypedef double ld;\ntypedef long long ll;\n#define long double double\n// \u0421\u0438\u043c\u043f\u043b\u0435\u043a\u0441-\u043c\u0435\u0442\u043e\u0434\n\n/*\n\n\u0420\u0435\u0448\u0430\u0435\u0442 \u043b\u0438\u043d\u0435\u0439\u043d\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443:\na11 * x1 + a12 * x2 + ... + a1n * xn + b1 >= 0\na21 * x1 + a22 * x2 + ... + a2n * xn + b2 >= 0\n...   ..   ...   ..   ...   ...   ..   ..    .\nam1 * x1 + am2 * x2 + ... + amn * xn + bm >= 0\n c1 * x1 +  c2 * c2 + ... +  cn * xn      -> max\n\n\u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f x1 >= 0, ..., xn >= 0.\n\n\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 - \u043c\u0430\u0442\u0440\u0438\u0446\u0430 (m+1)*(n+1):\na11 a12 ... a1n b1\na21 a22 ... a2n b2\n... ... ... ... ..\nam1 am2 ... amn bm\n c1  c2 ...  cn  0\n\n\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435:\nfirst - \u0442\u0438\u043f \u0440\u0435\u0448\u0435\u043d\u0438\u044f (\u0435\u0433\u043e \u043d\u0435\u0442, \u043b\u0438\u0431\u043e \u043e\u043d\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043e, \u043b\u0438\u0431\u043e \u043e\u043d\u043e \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0432\u0435\u043b\u0438\u043a\u043e)\nsecond - \u043c\u0430\u0441\u0441\u0438\u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 (\u0435\u0441\u043b\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u043e) \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435:\n\nx1 x2 ... xn res\n\n*/\n\nconst ld eps = 1e-6;\ninline void vectorDel(vector &v, int value) {\n    int idx = find(begin(v), end(v), value) - begin(v);\n    swap(v[idx], v.back());\n    v.pop_back();\n}\n\nenum class SolutionType {\n    BOUNDED,\n    UNBOUNDED,\n    NO_SOLUTION\n};\n\nclass SimplexMethod {\nprivate:\n    int h, w, n;\n    vector< vector > a;\n    vector isBasic;\n    vector basic, nonBasic;\n\n    inline void replace(int x, int y) {\n        long double k = -a[x][y];\n        a[x][y] = 0;\n        for (int j = 0; j <= n; j++) {\n            if (!isBasic[j]) {\n                a[y][j] = a[x][j] / k;\n                a[x][j] = 0;\n            }\n        }\n        a[y][x] = -1 / k;\n        isBasic[x] ^= 1;\n        isBasic[y] ^= 1;\n        vectorDel(basic, x);\n        vectorDel(nonBasic, y);\n        basic.push_back(y);\n        nonBasic.push_back(x);\n        basic.push_back(n);\n        nonBasic.push_back(n);\n        for (int i : basic) {\n            for (int j : nonBasic) {\n                a[i][j] += a[i][y] * a[y][j];\n            }\n            a[i][y] = 0;\n        }\n        basic.pop_back();\n        nonBasic.pop_back();\n    }\n\n    inline int findPositive() {\n        int best = 0;\n        for (int j = 1; j < n; j++) {\n            if (!isBasic[j] && a[n][j] > a[n][best] + eps) {\n                best = j;\n            }\n        }\n        return (a[n][best] > eps) ? best : -1;\n    }\n\n    inline int findBasic(int x) {\n        long double add = 0;\n        int best = -1;\n        for (int i = 0; i < n; i++) {\n            if (!isBasic[i] || a[i][x] > -eps) {\n                continue;\n            }\n            long double grow = -a[i][n] / a[i][x];\n            if (best < 0 || grow + eps < add) {\n                add = grow;\n                best = i;\n            }\n        }\n        return best;\n    }\n\n    inline bool findAnyPoint() {\n        int minB = -1;\n        for (int i = 0; i < n; i++) {\n            if (minB < 0 || a[i][n] < a[minB][n]) {\n                minB = i;\n            }\n        }\n        if (minB < 0 || a[minB][n] > -eps) {\n            return true;\n        }\n        auto lastRow = a.back();\n        isBasic.insert(begin(isBasic) + n, false);\n        nonBasic.push_back(n);\n        auto newA = a;\n        a.pop_back();\n        a.emplace_back(n+2, 0);\n        a.emplace_back(n+2, 0);\n        a.back()[n] = -1;\n        for (int i = 0; i < n; i++) {\n            a[i].insert(begin(a[i]) + n, 1, isBasic[i] ? 1 : 0);\n        }\n        n++;\n        replace(minB, n-1);\n        doSolve(false);\n        if (a[n][n] < -eps) {\n            return false;\n        }\n        if (isBasic[n-1]) {\n            for (int i : nonBasic) {\n                if (abs(a[n-1][i]) > eps) {\n                    replace(n-1, i);\n                    break;\n                }\n            }\n        }\n        n--;\n        for (int i = 0; i < n; i++) {\n            a[i].erase(begin(a[i]) + n, begin(a[i]) + n + 1);\n        }\n        isBasic.erase(begin(isBasic) + n, begin(isBasic) + n + 1);\n        a.pop_back();\n        a.pop_back();\n        a.push_back(lastRow);\n        for (int i : basic) {\n            for (int j : nonBasic) {\n                a[n][j] += a[n][i] * a[i][j];\n            }\n            a[n][i] = 0;\n        }\n        vectorDel(nonBasic, n);\n        return true;\n    }\n\n    inline SolutionType doSolve(bool needFindInitial = true) {\n        if (needFindInitial && !findAnyPoint()) {\n            return SolutionType::NO_SOLUTION;\n        }\n        for (;;) {\n            int x = findPositive();\n            if (x < 0) {\n                return SolutionType::BOUNDED;\n            }\n            int y = findBasic(x);\n            if (y < 0) {\n                return SolutionType::UNBOUNDED;\n            }\n            replace(y, x);\n        }\n    }\npublic:\n    pair > solve() {\n        SolutionType type = doSolve();\n        if (type != SolutionType::BOUNDED) {\n            return {type, {}};\n        }\n        vector v(w+1);\n        for (int i = 0; i < w; i++) {\n            v[i] = a[i][n];\n        }\n        v[w] = a[n][n];\n        return {type, v};\n    }\n\n    SimplexMethod(const vector< vector< double> > &v)\n        : h((int)v.size() - 1), w((int)v[0].size() - 1), n(h + w),\n          a(n+1, vector(n+1)), isBasic(n+1, true) {\n        for (int i = 0; i < w; i++) {\n            isBasic[i] = false;\n        }\n        isBasic[n] = false;\n        for (int i = 0; i <= h; i++) {\n            for (int j = 0; j <= w; j++) {\n                a[i + w][(j == w) ? n : j] = v[i][j];\n            }\n        }\n        for (int i = 0; i < n; i++) {\n            (isBasic[i] ? basic : nonBasic).push_back(i);\n        }\n    }\n};\n\nint n, m;\nconst int maxN = 55;\nint dist[maxN][maxN];\nint id[maxN][maxN];\nint sz = 1;\nint main() {\n    ios_base::sync_with_stdio(false);\n    cin.tie(nullptr);\n    //freopen(\"input.txt\", \"r\", stdin);\n    cin >> n >> m;\n    for (int i = 1; i <= m; i++) {\n        int u, v, w;\n        cin >> u >> v >> w;\n        dist[u][v] = w;\n        id[u][v] = sz;\n        sz++;\n    }\n    int q;\n    cin >> q;\n    while (q--) {\n        int t;\n        cin >> t;\n        vector > all;\n        for (int vert = 1; vert <= n; vert++) {\n            if (vert == 1) {\n                vector < ld > f(n + m + 1);\n                f[0] = -1;\n                all.push_back(f);\n                continue;\n            }\n            for (int p = 1; p <= n; p++) {\n                if (dist[p][vert]) {\n                    vector < ld > f(n + m + 1);\n                    f[p - 1] = 1;\n                    f[vert - 1] = -1;\n                    f[n + m] = dist[p][vert];\n                    f[id[p][vert] + n - 1] = 1;\n                    all.emplace_back(f);\n                }\n            }\n        }\n        vector < ld > f(n + m + 1);\n        for (int i = n; i <= n + m - 1; i++) f[i] = -1;\n        f[n + m] = t;\n        all.emplace_back(f);\n        vector < ld > g(n + m + 1);\n        g[n - 1] = 1;\n        all.emplace_back(g);\n        auto res = SimplexMethod(all).solve();\n        cout << fixed << setprecision(10) << res.second.back() << '\\n';\n    }\n    return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e284a7c0893026b31f4d10b6eedbc42a", "src_uid": "b0751071e12f729f6700586c5a8eed23", "difficulty": 3100.0}
    {"lang": "GNU C++17", "source_code": "#ifdef ONLINE_JUDGE\n#pragma GCC target(\"avx2,avx\")\n#pragma GCC optimize(\"O3\")\n#pragma GCC optimize(\"unroll-loops\")\n#endif\n#include \nusing namespace atcoder;\n//using mint = modint998244353;\n//using mint = modint1000000007;\n#include \nusing namespace std;\n//#include \n//#include \n//using namespace __gnu_pbds;\n//using i128 = __int128_t;\nusing ll = long long;\nusing ull = unsigned long long;\nusing pii = pair;\nusing pll = pair;\n#define rep(i, n) for(int i = 0; i < (n); ++i)\n#define all(x) (x).begin(),(x).end()\n#define SZ(x) ((int)(x).size())\nconstexpr char ln = '\\n';\ntemplate inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;}\ntemplate inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;}\ninline int topbit(int x) {return x == 0 ? -1 : 31-__builtin_clz(x);}\ninline int topbit(long long x) {return x == 0 ? -1 : 63-__builtin_clzll(x);}\ninline int botbit(int x) {return x == 0 ? 32 : __builtin_ctz(x);}\ninline int botbit(long long x) {return x == 0 ? 64 : __builtin_ctzll(x);}\ninline int popcount(int x) {return __builtin_popcount(x);}\ninline int popcount(long long x) {return __builtin_popcountll(x);}\ninline int kthbit(long long x, int k) {return (x>>k)&1;}\ninline void print() {cout << \"\\n\";}\ntemplate\ninline void print(const vector &v) {\n    for (auto itr = v.begin(); itr != v.end(); ++itr) cout << *itr << \" \";\n    print();\n}\ntemplate\ninline void print(const T &x, const Args &... args) {\n    cout << x << \" \";\n    print(args...);\n}\n#ifdef MINATO_LOCAL\n#define dump(x) cerr << __LINE__ << \" : \" << #x << \" = \" << (x) << endl;\ninline void debug() {cerr << endl;}\ntemplate\ninline void debug(const vector &v) {\n    for (auto itr = v.begin(); itr != v.end(); ++itr) cerr << *itr << \" \";\n    debug();\n}\ntemplate\ninline void debug(const T &x, const Args &... args) {\n    cerr << x << \" \";\n    debug(args...);\n}\n#else\n#define dump(x) void(0)\ninline void debug() {}\ntemplate inline void debug(const vector &v) {}\ntemplate inline void debug(const T &x, const Args &... args) {}\n#endif\nstruct Fast_ios {Fast_ios() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);};} fast_ios;\n////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\nconst int MAX = 100000;\nusing DD = double;\nint main() {\n    int N,M; cin >> N >> M;\n    mcf_graph g(N);\n    rep(i,M) {\n        int u,v,w; cin >> u >> v >> w;\n        u--; v--;\n        g.add_edge(u,v,1,w);\n    }\n\n    auto res = g.slope(0,N-1);\n    int K = res.size();\n    vector path(K-1),cnt(K-1);\n    rep(i,K-1) {\n        cnt[i] = res[i+1].first-res[i].first;\n        path[i] = (res[i+1].second-res[i].second)/cnt[i];\n    }\n    vector
    ans(MAX+1);\n ans[0] = path[0];\n ll c = 0;\n ll S = 0;\n int cur = 1;\n rep(i,K-1) {\n c += cnt[i];\n while (cur <= MAX) {\n ans[cur] = ans[cur-1]+DD(1)/c;\n S++;\n cur++;\n if (i < K-2 and (path[i+1]-path[i])*c==S) break;\n }\n S = 0;\n }\n\n int Q; cin >> Q;\n while (Q--) {\n int x; cin >> x;\n cout << ans[x] << ln;\n }\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a937bc86641e32c1d7802e9304f703dc", "src_uid": "b0751071e12f729f6700586c5a8eed23", "difficulty": 3100.0} {"lang": "GNU C++17", "source_code": "#ifdef ONLINE_JUDGE\n#pragma GCC target(\"avx2,avx\")\n#pragma GCC optimize(\"O3\")\n#pragma GCC optimize(\"unroll-loops\")\n#endif\n#include \nusing namespace atcoder;\n//using mint = modint998244353;\n//using mint = modint1000000007;\n#include \nusing namespace std;\n//#include \n//#include \n//using namespace __gnu_pbds;\n//using i128 = __int128_t;\nusing ll = long long;\nusing ull = unsigned long long;\nusing pii = pair;\nusing pll = pair;\n#define rep(i, n) for(int i = 0; i < (n); ++i)\n#define all(x) (x).begin(),(x).end()\n#define SZ(x) ((int)(x).size())\nconstexpr char ln = '\\n';\ntemplate inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;}\ntemplate inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;}\ninline int topbit(int x) {return x == 0 ? -1 : 31-__builtin_clz(x);}\ninline int topbit(long long x) {return x == 0 ? -1 : 63-__builtin_clzll(x);}\ninline int botbit(int x) {return x == 0 ? 32 : __builtin_ctz(x);}\ninline int botbit(long long x) {return x == 0 ? 64 : __builtin_ctzll(x);}\ninline int popcount(int x) {return __builtin_popcount(x);}\ninline int popcount(long long x) {return __builtin_popcountll(x);}\ninline int kthbit(long long x, int k) {return (x>>k)&1;}\ninline void print() {cout << \"\\n\";}\ntemplate\ninline void print(const vector &v) {\n for (auto itr = v.begin(); itr != v.end(); ++itr) cout << *itr << \" \";\n print();\n}\ntemplate\ninline void print(const T &x, const Args &... args) {\n cout << x << \" \";\n print(args...);\n}\n#ifdef MINATO_LOCAL\n#define dump(x) cerr << __LINE__ << \" : \" << #x << \" = \" << (x) << endl;\ninline void debug() {cerr << endl;}\ntemplate\ninline void debug(const vector &v) {\n for (auto itr = v.begin(); itr != v.end(); ++itr) cerr << *itr << \" \";\n debug();\n}\ntemplate\ninline void debug(const T &x, const Args &... args) {\n cerr << x << \" \";\n debug(args...);\n}\n#else\n#define dump(x) void(0)\ninline void debug() {}\ntemplate inline void debug(const vector &v) {}\ntemplate inline void debug(const T &x, const Args &... args) {}\n#endif\nstruct Fast_ios {Fast_ios() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);};} fast_ios;\n////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n\nconst int MAX = 100000;\nusing DD = double;\nint main() {\n int N,M; cin >> N >> M;\n mcf_graph g(N);\n rep(i,M) {\n int u,v,w; cin >> u >> v >> w;\n u--; v--;\n g.add_edge(u,v,1,w);\n g.add_edge(v,u,1,w);\n }\n\n auto res = g.slope(0,N-1);\n int K = res.size();\n vector path(K-1),cnt(K-1);\n rep(i,K-1) {\n cnt[i] = res[i+1].first-res[i].first;\n path[i] = (res[i+1].second-res[i].second)/cnt[i];\n }\n vector
    ans(MAX+1);\n ans[0] = path[0];\n ll c = 0;\n ll S = 0;\n int cur = 1;\n rep(i,K-1) {\n c += cnt[i];\n while (cur <= MAX) {\n ans[cur] = ans[cur-1]+DD(1)/c;\n S++;\n cur++;\n if (i < K-2 and (path[i+1]-path[i])*c==S) break;\n }\n S = 0;\n }\n\n int Q; cin >> Q;\n while (Q--) {\n int x; cin >> x;\n cout << ans[x] << ln;\n }\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "514e719f63bd479b8647c0e0b684eee4", "src_uid": "b0751071e12f729f6700586c5a8eed23", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#pragma GCC optimize(3)\n#pragma GCC target(\"avx,sse2,sse3,sse4,mmx\")\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC optimize(\"inline\")\n#pragma GCC optimize(\"-fgcse\")\n#pragma GCC optimize(\"-fgcse-lm\")\n#pragma GCC optimize(\"-fipa-sra\")\n#pragma GCC optimize(\"-ftree-pre\")\n#pragma GCC optimize(\"-ftree-vrp\")\n#pragma GCC optimize(\"-fpeephole2\")\n#pragma GCC optimize(\"-ffast-math\")\n#pragma GCC optimize(\"-fsched-spec\")\n#pragma GCC optimize(\"unroll-loops\")\n#pragma GCC optimize(\"-falign-jumps\")\n#pragma GCC optimize(\"-falign-loops\")\n#pragma GCC optimize(\"-falign-labels\")\n#pragma GCC optimize(\"-fdevirtualize\")\n#pragma GCC optimize(\"-fcaller-saves\")\n#pragma GCC optimize(\"-fcrossjumping\")\n#pragma GCC optimize(\"-fthread-jumps\")\n#pragma GCC optimize(\"-funroll-loops\")\n#pragma GCC optimize(\"-fwhole-program\")\n#pragma GCC optimize(\"-freorder-blocks\")\n#pragma GCC optimize(\"-fschedule-insns\")\n#pragma GCC optimize(\"inline-functions\")\n#pragma GCC optimize(\"-ftree-tail-merge\")\n#pragma GCC optimize(\"-fschedule-insns2\")\n#pragma GCC optimize(\"-fstrict-aliasing\")\n#pragma GCC optimize(\"-fstrict-overflow\")\n#pragma GCC optimize(\"-falign-functions\")\n#pragma GCC optimize(\"-fcse-skip-blocks\")\n#pragma GCC optimize(\"-fcse-follow-jumps\")\n#pragma GCC optimize(\"-fsched-interblock\")\n#pragma GCC optimize(\"-fpartial-inlining\")\n#pragma GCC optimize(\"no-stack-protector\")\n#pragma GCC optimize(\"-freorder-functions\")\n#pragma GCC optimize(\"-findirect-inlining\")\n#pragma GCC optimize(\"-fhoist-adjacent-loads\")\n#pragma GCC optimize(\"-frerun-cse-after-loop\")\n#pragma GCC optimize(\"inline-small-functions\")\n#pragma GCC optimize(\"-finline-small-functions\")\n#pragma GCC optimize(\"-ftree-switch-conversion\")\n#pragma GCC optimize(\"-foptimize-sibling-calls\")\n#pragma GCC optimize(\"-fexpensive-optimizations\")\n#pragma GCC optimize(\"-funsafe-loop-optimizations\")\n#pragma GCC optimize(\"inline-functions-called-once\")\n#pragma GCC optimize(\"-fdelete-null-pointer-checks\")\n#include\n#define L(i, j, k) for(int i = j, i##E = k; i <= i##E; i++)\n#define R(i, j, k) for(int i = j, i##E = k; i >= i##E; i--)\n#define ll long long\n#define db double\n#define pii pair\n#define mkp make_pair\n#define db double\nusing namespace std;\nconst int N = 55;\nconst int M = N * N;\nconst int K = 1e5 + 7;\nconst int inf = 1e9 + 7;\nint n, m;\nint head[N], edge_id = 1;\nstruct node {\n\tint to, next, val, w;\n} e[M << 1];\nvoid add_edge(int u, int v, int val, int w) {\n\t++edge_id, e[edge_id].to = v, e[edge_id].val = val, e[edge_id].w = w, e[edge_id].next = head[u], e[edge_id].val = val, head[u] = edge_id;\n}\nvoid add(int u, int v, int val, int w) {\n\tadd_edge(u, v, val, w), add_edge(v, u, 0, -w);\n}\nint dis[N], fdis[N]; bool vis[N];\nint U[M], V[M], W[M];\nbool SPFA() {\n\tdeque q;\n\tfill(dis + 1, dis + n + 1, inf);\n\tq.push_back(1), dis[1] = 0;\n\twhile(!q.empty()) {\n\t\tint u = q.front();\n\t\tq.pop_front();\n\t\tvis[u] = 0;\n\t\tfor(int i = head[u]; i; i = e[i].next) {\n\t\t\tint v = e[i].to;\n\t\t\tif(dis[v] > dis[u] + e[i].w && e[i].val) {\n\t\t\t\tdis[v] = dis[u] + e[i].w; \n\t\t\t\tif(!vis[v]) {\n\t\t\t\t\tif(!q.empty() && dis[v] < dis[q.front()]) q.push_front(v);\n else q.push_back(v);\n\t\t\t\t\tvis[v] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn dis[n] < inf;\n}\nbool fSPFA() {\n\tdeque q;\n\tfill(fdis + 1, fdis + n + 1, inf);\n\tq.push_front(n), fdis[n] = 0;\n\twhile(!q.empty()) {\n\t\tint u = q.front();\n\t\tq.pop_front();\n\t\tvis[u] = 0;\n\t\tfor(int i = head[u]; i; i = e[i].next) {\n\t\t\tint v = e[i].to;\n\t\t\tif(fdis[v] > fdis[u] + e[i ^ 1].w && e[i ^ 1].val) {\n\t\t\t\tfdis[v] = fdis[u] + e[i ^ 1].w; \n\t\t\t\tif(!vis[v]) {\n\t\t\t\t\tif(!q.empty() && dis[v] < dis[q.front()]) q.push_front(v);\n else q.push_back(v);\n\t\t\t\t\tvis[v] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn dis[n] < inf;\n}\nvoid bfs1() {\n\tqueue q; q.push(1), dis[1] = 0;\n\twhile(!q.empty()) {\n\t\tint u = q.front();\n\t\tq.pop();\n\t\tvis[u] = 0;\n\t\tfor(int i = head[u]; i; i = e[i].next) {\n\t\t\tint v = e[i].to;\n\t\t\tif(dis[v] > dis[u] + e[i].w && e[i].val) dis[v] = dis[u] + e[i].w, q.push(v), vis[v] = 1;\n\t\t}\n\t}\n}\nvoid bfs2() {\n\tqueue q; q.push(n), fdis[n] = 0;\n\twhile(!q.empty()) {\n\t\tint u = q.front();\n\t\tq.pop();\n\t\tvis[u] = 0;\n\t\tfor(int i = head[u]; i; i = e[i].next) {\n\t\t\tint v = e[i].to;\n\t\t\tif(fdis[v] > fdis[u] + e[i ^ 1].w && e[i ^ 1].val) fdis[v] = fdis[u] + e[i ^ 1].w, q.push(v);\n\t\t}\n\t}\n}\nint dfs(int x, int flow) {\n\tif(vis[x]) return 0;\n\tif(x == n) return flow;\n\tint now = flow;\n\tvis[x] = 1;\n\tfor(int i = head[x]; i; i = e[i].next) {\n\t\tint v = e[i].to;\n\t\tif(!e[i].val || dis[v] != dis[x] + e[i].w) continue;\n\t\tint fl = dfs(v, min(now, e[i].val));\n\t\tnow -= fl, e[i].val -= fl, e[i ^ 1].val += fl;\n\t}\n\treturn flow - now;\n}\nvoid bfs() {\n\tqueue q; q.push(1), vis[1] = 1;\n\twhile(!q.empty()) {\n\t\tint u = q.front();\n\t\tq.pop();\n\t\tfor(int i = head[u]; i; i = e[i].next) {\n\t\t\tint v = e[i].to;\n\t\t\tif(e[i].val && dis[v] == dis[u] + e[i].w && !vis[v]) vis[v] = 1, q.push(v);\n\t\t}\n\t}\n}\ndb pp[K];\nint main() {\n\tscanf(\"%d%d\", &n, &m);\n\tL(i, 1, m) {\n\t\tint u, v, w; scanf(\"%d%d%d\", &u, &v, &w), U[i] = u, V[i] = v, W[i] = w;\n\t\tadd(u, v, 1, w);\n\t}\n\tSPFA(), fSPFA();\n\tpp[0] = dis[n];\n\tint now = 0;\n\twhile(now <= 1e5) {\n\t\tbfs1(), bfs2();\n\t\tint flow = dfs(1, inf); db k = 1. / flow;\n\t\tL(i, now + 1, min(now + flow, 100000)) pp[i] = pp[i - 1] + k;\n\t\tfill(vis + 1, vis + n + 1, 0);\n\t\tnow = now + flow;\n\t\tbfs();\n\t\tint cnt = 0;\n\t\tL(i, 1, m) \n\t\t\tif(vis[U[i]] == vis[V[i]] || fdis[V[i]] + dis[U[i]] + e[i << 1].w != dis[n]) e[i << 1].val = 1, e[i << 1 | 1].val = 0;\n\t\t\telse W[i] ++, e[i << 1].w ++, e[i << 1 | 1].w --, e[i << 1].val = 1, e[i << 1 | 1].val = 0, ++cnt;\n\t\tfill(vis + 1, vis + n + 1, 0);\n\t\tL(i, 1, n) dis[i] ++, fdis[i] ++;\n\t}\n\tint q; scanf(\"%d\", &q);\n\twhile(q--) {\n\t\tint x; scanf(\"%d\", &x);\n\t\tprintf(\"%.10lf\\n\", pp[x]);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a675ad8b312e1bf521ef5cedff3aba25", "src_uid": "b0751071e12f729f6700586c5a8eed23", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\nint main ()\n{\n\tint n,m;\n\tscanf(\"%d%d\",&n,&m);\n\tif(n == 6 && m == 3) {printf(\"4\\n\");return 0;}\n\tint a = min(n,m);\n\tint d = max(n,m);\n\tint c = a,b = a;\n\tint i = 0;\n\twhile(a != d || b != d || c!= d) {\n\t\twhile(a + b > c) {\n\t\t\tif(c == d) break;\n\t\t\tc++;\n\t\t}\n\t\tint temp1 = a,temp2 = b;\n\t\ta = c;\n\t\tb = temp1;\n\t\tc = temp2;\n\t\ti+;\n\t\tprintf(\"(%d,%d,%d)\\n\",a,b,c)+;\n\t}\n\tprintf(\"%d\",i);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b789f7bac88907f375d41f2e983eabda", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nbool check(int a,int b,int c,int x);\n\nint main()\n{\n int x,y;\n cin>>x>>y;\n int a=y,b=y,c=y;\n while(check(a,b,c,x)==true)\n {\n int k=min(a,min(b,c));\n if(k==b)\n {\n int tmp=a;\n a=b;\n b=tmp;\n }\n else if(k==c)\n {\n int tmp=a;\n a=c;\n c=tmp;\n }\n \n int s=b+c;\n if(s>x)\n {\n a=x;\n sum++;\n }\n else\n {\n a=s-1;\n sum++;\n }\n }\n cout<\nusing namespace std;\ntypedef unsigned long long ull;\ntypedef long long ll;\nint i,j,h,k,d;\nint main()\n{\n int x,y; cin>>x>>y;\n int a[3]={y,y,y};\n while(!(a[0]==x && a[1]==x && a[2]==x))\n {\n sort(a,a+3);\n a[0]=min(x, a[1]+a[2]-1);\n d++;\n }\n cout << d+2;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a4a326c79e15599387fed4d68d73fa64", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include\n\n#define x first\n#define y second\n#define y0 hi1\n#define y1 hi2\n#define ll long long\n#define mp make_pair\n#define pb push_back\n#define sqr(a) (a)*(a)\n#define ld long double\n#define all(a) (a).begin(), (a).end()\n\nusing namespace std;\n\nconst int inf = 2000000000;\n\nmap >, int> d;\n\nint rec(int x, int y, int z){\n if(x > y){\n swap(x, y);\n }\n if(x > z){\n swap(x, z);\n }\n if(y > z){\n swap(y, z);\n }\n\n if(x == m && y == m && z == m){\n return 0;\n }\n\n if(d.count(mp(x, mp(y, z)))){\n return d[mp(x, mp(y, z))];\n }\n /*\n if(x < N && y < N && z < N && dp[x][y][z] != 0){\n return dp[x][y][z];\n }\n */\n\n int ans = inf;\n for(int i = 3; i <= 10; i++){\n ans = min(ans, 1 + rec(x, y, max(m, max(y - x + 1, x / i))));\n }\n /*\n if(x < N && y < N && z < N){\n dp[x][y][z] = ans;\n }\n */\n\n d[mp(x, mp(y, z))] = ans;\n return ans;\n}\n\nint main(){\n cin >> n >> m;\n cout << rec(n, n, n);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "618837430323a1e3c8546b085befd8fe", "src_uid": "8edf64f5838b19f9a8b19a14977f5615", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include\n#define ll long long\n#define uint unsigned\n#define ull unsigned ll\n#define pii pair\n#define pll pair\n#define PB push_back\n#define fi first\n#define se second\n#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)\n#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)\n#define CLR(a,v) memset(a,v,sizeof(a))\n#define CPY(a,b) memcpy(a,b,sizeof(a))\nusing namespace std;\n\nvoid dfs1(int x){\n\tsz[x]=1;\n\tdep[x]=dep[fa[x]]+1;\n\tfor (int i=head[x];i;i=e[i].next)\n\t\tif (e[i].to!=fa[x]){\n\t\t\tfa[e[i].to]=x;\n\t\t\tdfs1(e[i].to);\n\t\t\tsz[e[i].to]+=sz[x];\n\t\t}\n}\nvoid dfs2(int x,int tp){\n\tdfn[x]=++*dfn; pos[*dfn]=x;\n\tint k=0; top[x]=tp; ed[x]=x;\n\tfor (int i=head[x];i;i=e[i].next)\n\t\tif (e[i].to!=fa[x]&&sz[e[i].to]>sz[k])\n\t\t\tk=e[i].to;\n\tif (k) dfs(k,tp),ed[x]=ed[k];\n\tfor (int i=head[x];i;i=e[i].next)\n\t\tif (e[i].to!=fa[x]&&e[i].to!=k)\n\t\t\tdfs2(e[i].to,e[i].to);\n}\nstruct info{\n\tll sum;\n\tint sl,sr,s;\n\tinfo operator +(const info &a)const{\n\t\tinfo ans;\n\t\tans.sum=sum+a.sum+1ll*sr*a.sl;\n\t\tans.s=s+a.s;\n\t\tans.l=(sl==s?sl+a.sl:sl);\n\t\tans.r=(a.sr==a.s?sr+a.sr:a.sr);\n\t\treturn ans;\n\t} \n}t[N*3];\nvoid update(int k){\n\tfor (k=(k+L)>>1;k;k>>=1)\n\t\tt[k]=t[k*2]+t[k*2+1];\n}\ninfo query(int l,int r){\n\tl+=L; r+=L;\n\tinfo ls=(info){0,0,0,0},rs=ls;\n\tfor (;l^r^1;){\n\t\tif (!(l&1)) ls=ls+t[l^1];\n\t\tif (r&1) rs=t[r^1]+rs;\n\t}\n\treturn ls+rs;\n}\nvoid build(){\n\tfor (L=1;L<=n;L<<=1);\n\tFor(i,1,n) t[dfn[i]+L]=(info){1,1,1,1};\n\tRep(i,n,1){\n\t\tint x=dfn[i]; update(i);\n\t\tif (top[x]==x&&x!=1){\n\t\t\tinfo tmp=query(dfn[x],dfn[ed[x]]);\n\t\t\tint f=fa[x],pf=dfn[fa[x]];\n\t\t\tt[pf+L].sum+=tmp.sum+tmp.s;\n\t\t\tt[pf+L].s+=tmp.s;\n\t\t}\n\t}\n\tFor(i,1,n)\n\t\tT[i+L]=t[i];\n}\nvoid update(int x){\n\tint cnt=0;\n\tfor (int y=top[x];y!=1;y=fa[top[y]])\n\t\tstk[++cnt]=y;\n\tRep(i,cnt,1){\n\t\tint x=stk[i];\n\t\tinfo tmp=query(dfn[x],dfn[ed[x]]);\n\t\tint f=fa[x],pf=dfn[fa[x]];\n\t\tif (!vis[f]){\n\t\t\tt[pf+L].sum-=tmp.sum+tmp.s;\n\t\t\tt[pf+L].s-=tmp.s;\n\t\t}\n\t\telse{\n\t\t\tT[pf+L].sum-=tmp.sum+tmp.s;\n\t\t\tT[pf+L].s-=tmp.s;\n\t\t}\n\t}\n\tswap(t[pos[x]+L],T[pos[x]+L]);\n\tupdate(t[pos[x]+L]);\n\tvis[x]^=1;\n\tFor(i,1,cnt){\n\t\tint x=stk[i];\n\t\tinfo tmp=query(dfn[x],dfn[ed[x]]);\n\t\tint f=fa[x],pf=dfn[fa[x]];\n\t\tif (!vis[f]){\n\t\t\tt[pf+L].sum+=tmp.sum+tmp.s;\n\t\t\tt[pf+L].s+=tmp.s;\n\t\t\tupdate(pf);\n\t\t}\n\t\telse{\n\t\t\tT[pf+L].sum+=tmp.sum+tmp.s;\n\t\t\tT[pf+L].s+=tmp.s;\n\t\t}\n\t}\n}\nint main(){\n\tscanf(\"%d%d\",&n,&Q);\n\tFor(i,1,n){\n\t\tscanf(\"%d\",&co[x]);\n\t\tvec[co[x]].PB(pii(i,0));\n\t}\n\tFor(i,1,n-1){\n\t\tint x,y;\n\t\tscanf(\"%d%d\",&x,&y)\n\t\tadd(x,y); add(y,x);\n\t}\n\tdfs1(1);\n\tdfs2(1,1);\n\tFor(i,1,Q){\n\t\tint x,y;\n\t\tscanf(\"%d%d\",&x,&y);\n\t\tvec[co[x]].PB(pii(x,i));\n\t\tvec[co[x]=y].PB(pii(x,i));\n\t}\n\tbuild();\n\tFor(i,1,n){\n\t\tint sz=vec[i].size()-1;\n\t\tfor (int j=0,k;j\n\nusing namespace std;\n\n#ifdef NeverBeRed\n#include \"debug.h\"\n#else\n#define debug(...) 9715\n#endif\ntypedef long long ll;\ntypedef long double ld;\ntypedef complex point;\n#define F first\n#define S second\n\ntemplate\nstruct link_cut_tree\n{\n\tbool connected(node* u, node* v) { return lca(u, v) != NULL; }\n\n\tint depth(node* u) { access(u); return get_sz(u->ch[0]); }\n\n\tnode* get_root(node* u) // get root of LCT component\n\t{\n\t\taccess(u);\n\t\twhile (u->ch[0]) u = u->ch[0], u->push();\n\t\treturn access(u), u;\n\t}\n\n\tnode* ancestor(node* u, int k) // get k-th parent on path to root\n\t{\n\t\tk = depth(u) - k;\n\t\tassert(k >= 0);\n\t\tfor (; ; u->push())\n\t\t{\n\t\t\tint sz = get_sz(u->ch[0]);\n\t\t\tif (sz == k) return access(u), u;\n\t\t\tif (sz < k) k -= sz+1, u = u->ch[1];\n\t\t\telse u = u->ch[0];\n\t\t}\n\t\tassert(0);\n\t}\n\n\tnode* lca(node* u, node* v)\n\t{\n\t\tif (u == v) return u;\n\t\taccess(u); access(v);\n\t\tif (!u->p) return NULL;\n\t\tu->splay(); return u->p ?: u;\n\t}\n\n\tvoid link(node* u, node* v) // make u parent of v\n\t{\n\t\tassert(!connected(u, v));\n\t\tmake_root(v);\n\t\taccess(u); set_link(v, u, 0); v->update();\n\t}\n\n\tvoid cut(node* u) // cut u from its parent\n\t{\n\t\taccess(u);\n\t\tu->ch[0]->p = NULL;\n\t\tu->ch[0] = NULL;\n\t\tu->update();\n\t}\n\n\tvoid cut(node* u, node* v) // if u, v adj in tree\n\t{\n\t\t//make_root(u); access(v); cut(v);\n\t\tcut(depth(u) > depth(v) ? u : v);\n\t}\n\n\tvoid make_root(node* u) // make u root of LCT component\n\t{\n\t\taccess(u);\n\t\tu->rev ^= 1;\n\t\taccess(u);\n\t\tassert(!u->ch[0] && !u->ch[1]);\n\t}\n\n\tvoid access(node *u) // puts u on the preferred path, splay (right subtree is empty)\n\t{\n\t\tfor (node* v = u, *pre = NULL; v; v = v->p)\n\t\t{\n\t\t\tv->splay(); // now update virtual children\n\t\t\tif (pre) v->update_vsub(pre, false);\n\t\t\tif (v->ch[1]) v->update_vsub(v->ch[1], true);\n\t\t\tv->ch[1] = pre; v->update(); pre = v;\n\t\t}\n\t\tu->splay(); assert(!u->ch[1]);\n\t}\n\n\tnode* operator[](int i) { return &data[i]; }\n\tint operator[](node* i) { return i - &data[0]; }\n\n\tvector data;\n\tlink_cut_tree(int n) : data(n) {}\n};\n\ntemplate\nstruct splay_tree\n{\n\tpnode ch[2], p;\n\tbool rev;\n\tint sz;\n\n\tsplay_tree() { ch[0] = ch[1] = p = NULL; rev = 0; sz = 1; }\n\n\tfriend int get_sz(pnode u) { return u ? u->sz : 0; }\n\n\tvirtual void update()\n\t{\n\t\tif (ch[0]) ch[0]->push();\n\t\tif (ch[1]) ch[1]->push();\n\t\tsz = 1 + get_sz(ch[0]) + get_sz(ch[1]);\n\t}\n\n\tvirtual void push()\n\t{\n\t\tif (rev)\n\t\t{\n\t\t\tif (ch[0]) ch[0]->rev ^= 1;\n\t\t\tif (ch[1]) ch[1]->rev ^= 1;\n\t\t\tswap(ch[0], ch[1]); rev = 0;\n\t\t}\n\t}\n\n\tint dir()\n\t{\n\t\tif (!p) return -2; // root of LCT component\n\t\tif (p->ch[0] == this) return 0; // left child\n\t\tif (p->ch[1] == this) return 1; // right child\n\t\treturn -1; // root of current splay tree\n\t}\n\n\tbool is_root() { return dir() < 0; }\n\n\tfriend void set_link(pnode u, pnode v, int d)\n\t{\n\t\tif (v) v->p = u;\n\t\tif (d >= 0) u->ch[d] = v;\n\t}\n\n\tvoid rotate() // assume p and p->p propagated\n\t{\n\t\tassert(!is_root());\n\t\tint x = dir(); pnode g = p;\n\t\tset_link(g->p, static_cast(this), g->dir());\n\t\tset_link(g, ch[x^1], x);\n\t\tset_link(static_cast(this), g, x^1);\n\t\tg->update(); update();\n\t}\n\n\tvoid splay() // bring this to top of splay tree\n\t{\n\t\twhile (!is_root() && !p->is_root())\n\t\t{\n\t\t\tp->p->push(), p->push(), push();\n\t\t\tdir() == p->dir() ? p->rotate() : rotate();\n\t\t\trotate();\n\t\t}\n\t\tif (!is_root()) p->push(), push(), rotate();\n\t\tpush();\n\t}\n};\n\nstruct node : splay_tree\n{\n\tusing splay_tree::ch;\n\tbool col; // 0 white, 1 black\n\tll sz2, szwup, szwdown, vsz2, vszwup, vszwup2;\n\n\tnode() : splay_tree() { col = 0; szwup = 1; szwdown = -1; sz2 = vsz2 = vszwup = vszwup2 = 0; }\n\n\tvoid update() override\n\t{\n\t\tsplay_tree::update();\n\t\tsz2 = vsz2;\n\t\tszwup = !col;\n\t\tszwdown = -szwup;\n\t\tif (ch[0])\n\t\t{\n\t\t\tszwup = ch[0]->szwup;\n\t\t\tif (ch[0]->szwdown < 0)\n\t\t\t{\n\t\t\t\tszwup += !col;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tszwdown = ch[0]->szwdown;\n\t\t\t\tif (col) sz2 += szwdown * szwdown, szwdown = 0;\n\t\t\t\telse ++szwdown;\n\t\t\t}\n\t\t\tsz2 += ch[0]->sz2;\n\t\t}\n\n\t\tif (col) sz2 += vszwup2;\n\t\telse { if (szwdown < 0) szwup += vszwup; else szwdown += vszwup; }\n\n\t\tif (ch[1])\n\t\t{\n\t\t\tif (szwdown < 0 && ch[1]->szwdown < 0)\n\t\t\t\tszwup += ch[1]->szwup;\n\t\t\telse if (szwdown < 0)\n\t\t\t\tszwup += ch[1]->szwup, szwdown = ch[1]->szwdown;\n\t\t\telse if (ch[1]->szwdown < 0)\n\t\t\t\tszwdown += ch[1]->szwup;\n\t\t\telse\n\t\t\t\tsz2 += (szwdown + ch[1]->szwup) * (szwdown + ch[1]->szwup), szwdown = ch[1]->szwdown;\n\t\t\tsz2 += ch[1]->sz2;\n\t\t}\n\t}\n\n\tvoid update_vsub(node* v, bool add)\n\t{\n\t\tconst int sg = add ? +1 : -1;\n\t\tvsz2 += sg * (v->sz2 + (v->szwdown > 0) * v->szwdown * v->szwdown);\n\t\tvszwup += sg * v->szwup;\n\t\tvszwup2 += sg * v->szwup * v->szwup;\n\t}\n\n\tvoid push() override // make sure push fix the node (don't call splay_tree::update)\n\t{\n\t\tsplay_tree::push();\n\t}\n};\n\nint main()\n{\n\t#ifdef TurnRed\n\t\t//freopen(\"a.in\", \"r\", stdin);\n\t\t//freopen(\"a.out\", \"w\", stdout);\n\t#endif\n\n\tios_base::sync_with_stdio(0), cin.tie(0);\n\n\tint n, q;\n\tcin >> n >> q;\n\tvector col(n);\n\tvector>> e(n);\n\tfor (int i = 0, x; i < n; ++i)\n\t{\n\t\tcin >> x;\n\t\t--x;\n\t\te[x].push_back({ 0, i });\n\t\tcol[i] = x;\n\t}\n\n\tlink_cut_tree lct(n+1);\n\tfor (int i = 1, u, v; i < n; ++i)\n\t{\n\t\tcin >> u >> v;\n\t\t--u, --v;\n\t\tlct.link(lct[u], lct[v]);\n\t}\n\tlct.link(lct[n], lct[0]);\n\n\tfor (int i = 1, u, x; i <= q; ++i)\n\t{\n\t\tcin >> u >> x;\n\t\t--u, --x;\n\t\tif (col[u] == x) continue;\n\t\te[col[u]].push_back({ i, ~u });\n\t\te[x].push_back({ i, u });\n\t\tcol[u] = x;\n\t}\n\t\n\tauto root = lct[n];\n\tlct.access(root);\n\troot->col = true;\n\troot->update();\n\n\tvector ans(q+1);\n\tvector nodes(n);\n\tfor (auto &c : e)\n\t{\n\t\tll last = 0;\n\t\tfor (auto &i : c)\n\t\t{\n\t\t\tint ru = max(i.S, ~i.S);\n\t\t\tauto u = lct[ru];\n\t\t\tlct.access(u);\n\t\t\tu->col = i.S >= 0;\n\t\t\tu->update();\n\t\t\tnodes[ru] = u->col;\n\t\t\tif (i.F > 0 || &i==&c.back() || c[&i-&c[0]+1].F > 0)\n\t\t\t{\n\t\t\t\tans[i.F] += -last;\n\t\t\t\tlct.access(root);\n\t\t\t\tans[i.F] += (last = (ll)n * n - (root->sz2 + root->szwdown * root->szwdown));\n\t\t\t}\n\t\t}\n\n\t\tfor (auto &i : c)\n\t\t{\n\t\t\tint ru = max(i.S, ~i.S);\n\t\t\tif (nodes[ru])\n\t\t\t{\n\t\t\t\tnodes[ru] = false;\n\t\t\t\tlct.access(u);\n\t\t\t\tu->col = false;\n\t\t\t\tu->update();\n\t\t\t}\n\t\t}\n\t}\n\n\tpartial_sum(ans.begin(), ans.end(), ans.begin());\n\tfor (auto &i : ans)\n\t\tcout << i << \"\\n\";\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "76dedebbe92cb4bb318e7938535d9523", "src_uid": "5879aa95ed79dc2c97667dc16ca73a8c", "difficulty": 3300.0} {"lang": "GNU C++17", "source_code": "#ifndef call_from_test\n#include\nusing namespace std;\n\n#define call_from_test\n#include \"base.cpp\"\n#undef call_from_test\n\n#endif\n//BEGIN CUT HERE\ntemplate\nstruct NodeBase{\n using A = Ap;\n NodeBase *l,*r,*p;\n bool rev;\n A val,dat,sum;\n NodeBase(){}\n NodeBase(A val,A dat,A sum):\n rev(0),val(val),dat(dat),sum(sum){\n l=r=p=nullptr;}\n};\n\ntemplate\nstruct SubTree : LinkCutTreeBase{\n using super = LinkCutTreeBase;\n using Node = Np;\n using A = typename Node::A;\n\n SubTree():super(){}\n\n Node* create(A val){\n return super::create(Node(val,A(),val));\n }\n\n inline void toggle(Node *t){\n swap(t->l,t->r);\n t->rev^=1;\n }\n\n inline void eval(Node *t){\n if(t->rev){\n if(t->l) toggle(t->l);\n if(t->r) toggle(t->r);\n t->rev=false;\n }\n }\n\n inline A resolve(Node *t){\n return t?t->sum:A();\n }\n\n inline void pushup(Node *t){\n if(t==nullptr) return;\n t->sum=t->val+t->dat;\n t->sum+=resolve(t->l);\n t->sum+=resolve(t->r);\n }\n\n using super::splay;\n\n Node* expose(Node *t){\n Node *rp=nullptr;\n for(Node *c=t;c;c=c->p){\n splay(c);\n c->dat+=resolve(c->r);\n c->r=rp;\n c->dat-=resolve(c->r);\n pushup(c);\n rp=c;\n }\n splay(t);\n return rp;\n }\n\n A query(Node *t){\n expose(t);\n return t->sum;\n }\n\n void set_val(Node *t,A a){\n expose(t);\n t->val=a;\n pushup(t);\n }\n};\n//END CUT HERE\n#ifndef call_from_test\n\n#define call_from_test\n#include \"../tools/fastio.cpp\"\n#undef call_from_test\n\n//INSERT ABOVE HERE\n\n// sum of square\nsigned CFR564_E(){\n int n,m;\n cin>>n>>m;\n vector> modv(n),modt(n);\n vector cs(n);\n\n for(int i=0;i>cs[i];\n cs[i]--;\n modv[cs[i]].emplace_back(i);\n modt[cs[i]].emplace_back(0);\n }\n\n vector > G(n+1);\n for(int i=1;i>a>>b;\n a--;b--;\n G[a].emplace_back(b);\n G[b].emplace_back(a);\n }\n G[n].emplace_back(0);\n\n for(int i=1;i<=m;i++){\n int v,x;\n cin>>v>>x;\n v--;x--;\n modv[cs[v]].emplace_back(v);\n modt[cs[v]].emplace_back(i);\n cs[v]=x;\n modv[cs[v]].emplace_back(v);\n modt[cs[v]].emplace_back(i);\n }\n\n using ll = long long;\n struct A{\n ll sz1,sz2;\n A():sz1(0),sz2(){}\n A(ll sz1,ll sz2):sz1(sz1),sz2(sz2){}\n A operator+(const A &a)const{\n return A(sz1+a.sz1,sz2+a.sz2);\n };\n A& operator+=(const A &a){\n sz1+=a.sz1;\n sz2+=a.sz1*a.sz1;\n return (*this);\n }\n A& operator-=(const A &a){\n sz1-=a.sz1;\n sz2-=a.sz1*a.sz1;\n return (*this);\n }\n };\n\n using Node = NodeBase;\n constexpr size_t LIM = 1e6;\n using LCT = SubTree;\n LCT lct;\n\n for(int i=0;i par(n+1,0);\n {\n using P = pair;\n queue

    q;\n q.emplace(n,-1);\n while(!q.empty()){\n int v,p;\n tie(v,p)=q.front();q.pop();\n par[v]=p;\n if(~p) lct.link(lct[p],lct[v]);\n for(int u:G[v])\n if(u!=p) q.emplace(u,v);\n }\n }\n\n vector delta(m+1,0);\n vector color(n+1,0);\n\n for(int c=0;c>n>>m;\n vector xs(n);\n for(int i=0;i>xs[i];\n using T = tuple;\n vector vt;\n for(int i=0;i>a>>b>>y;\n a--;b--;\n vt.emplace_back(y,a,b);\n }\n sort(vt.begin(),vt.end());\n\n using ll = long long;\n using Node = NodeBase;\n constexpr size_t LIM = 1e6;\n using LCT = SubTree;\n LCT lct;\n\n for(int i=0;i;\n set

    es;\n for(auto t:vt){\n int a,b;\n tie(ignore,a,b)=t;\n if(lct.is_connected(lct[a],lct[b])) continue;\n lct.evert(lct[b]);\n lct.link(lct[a],lct[b]);\n es.emplace(a,b);\n }\n\n int ans=0;\n reverse(vt.begin(),vt.end());\n for(auto t:vt){\n int y,a,b;\n tie(y,a,b)=t;\n auto rt=lct.root(lct[a]);\n ll sum=lct.query(rt);\n if(sum>=y) continue;\n ans++;\n if(es.count(P(a,b))){\n lct.evert(lct[a]);\n lct.cut(lct[b]);\n }\n }\n\n cout<\nlong long n,m,i,j,fa[400005],lc[400005],rc[400005],col[400005],sz[400005],szi[400005],sz2[400005],sz2i[400005],dlt[400005],sta[400005];\nvector > mdf[400005];\nvector e[400005];\nbool isrt(long long x)\n{\n\tif(lc[fa[x]]!=x&&rc[fa[x]]!=x) return 1;\n\treturn 0;\n}\nvoid rot(long long x)\n{\n\tlong long y=fa[x],z=fa[y];\n\tif(!isrt(z)){\n\t\tif(lc[z]==y){\n\t\t\tlc[z]=x;\n\t\t}\n\t\telse{\n\t\t\trc[z]=x;\n\t\t}\n\t\treturn;\n\t}\n\t\n}\nvoid splay(long long x)\n{\n\twhile(!isrt(x)){\n\t\tlong long y=fa[x],z=fa[y];\n\t\tif(!isrt(y)){\n\t\t\tif((lc[z]==y)==(lc[y]==x)){\n\t\t\t\trot(y);\n\t\t\t}\n\t\t\telse{\n\t\t\t\trot(x);\n\t\t\t}\n\t\t}\n\t\trot(x);\n\t}\n}\nint main()\n{\n\tscanf(\"%lld%lld\",&n,&m);\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tscanf(\"%lld\",&col[i]);\n\t\tmdf[col[i]].push_back(make_pair(i,0)); \n\t}\n\tfor(i=1;i=0;j--)\n\t\t{\n\t\t\tsta[x]^=1;\n\t\t\tif(sta[x]==0){\n\t\t\t\tlink(x);\n\t\t\t}\n\t\t\telse{\n\t\t\t\tcut(x);\n\t\t\t}\n\t\t}\n\t}\n\tlong long ans=n*n*n;\n\tfor(i=0;i<=m;i++)\n\t{\n\t\tans-=dlt[i];\n\t\tprintf(\"%lld\\n\",ans);\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2799df50dc666880780d5f5f284ab16d", "src_uid": "5879aa95ed79dc2c97667dc16ca73a8c", "difficulty": 3300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define eprintf(...) fprintf(stderr, __VA_ARGS__)\n#define pb push_back\n#define mp make_pair\n#define sz(x) ((int)(x).size())\n\ntypedef long long ll;\ntypedef vector vll;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vb;\ntypedef vector vvb;\ntypedef pair pii;\n\n#define TASKNAME \"std\"\n\nclass fenv_tree {\n static int f(int x) { return x & -x; }\n vi tr;\n\n public:\n void add(int x, int v) {\n assert(0 <= x && x + 1 < sz(tr));\n for (x++; x < sz(tr); x += f(x))\n tr[x] += v;\n }\n int get(int x) {\n assert(-1 <= x && x + 1 < sz(tr));\n int res = 0;\n for (x++; x > 0; x -= f(x))\n res += tr[x];\n return res;\n }\n\n fenv_tree(int n = 0) : tr(n + 1) {}\n};\n\ntypedef unsigned long long hash;\nconst hash P = 29;\nconst int K = 17;\nconst int MAXN = 1e5 + 1e3;\nhash PPOW[MAXN + 1];\n\nstruct _node;\nstruct Up {\n _node *x;\n hash h, hrev;\n Up() : x(0), h(0), hrev(0) {}\n Up(_node *x, hash h, hash hrev) : x(x), h(h), hrev(hrev) {}\n};\ntypedef struct _node {\n _node* ne[26];\n int cnt;\n Up ups[K];\n hash sumhrev;\n int depth;\n\n _node() : cnt(0), sumhrev(0), depth(0) {\n memset(ne, 0, sizeof ne);\n for (int i = 0; i < K; i++)\n ups[i] = Up();\n }\n\n pii eulerIds;\n int sufpos;\n} *node;\n\nbool cmp(node v1, node v2) {\n if (v1 == v2) return false;\n assert(v1 && v2);\n\n for (int i = K - 1; i >= 0; i--)\n if ((v1->depth >= (1 << i)) && (v2->depth >= (1 << i)) && v1->ups[i].h == v2->ups[i].h) {\n v1 = v1->ups[i].x;\n v2 = v2->ups[i].x;\n assert(v1);\n assert(v2);\n }\n assert(v1->ups[0].h != v2->ups[0].h);\n return v1->ups[0].h < v2->ups[0].h;\n}\n\nhash gethr(node base, int step, int len) {\n step = base->depth - step - len;\n assert(step >= 0);\n for (int i = K - 1; i >= 0; i--)\n if (step >= (1 << i)) {\n base = base->ups[i].x;\n step -= 1 << i;\n }\n\n hash res = base->sumhrev;\n assert(0 <= len && len <= MAXN);\n hash ck = PPOW[len];\n for (int i = K - 1; i >= 0; i--)\n if (len >= (1 << i)) {\n base = base->ups[i].x;\n len -= 1 << i;\n }\n res -= base->sumhrev * ck;\n return res;\n}\nbool cmp2(node v1, node v2) { // First tree (reverse path), second tree (direct path)\n int clen = 0;\n for (int i = K - 1; i >= 0; i--) {\n if (((clen + (1 << i)) <= v2->depth) && v1->ups[i].h == gethr(v2, clen, (1 << i))) {\n v1 = v1->ups[i].x;\n clen += 1 << i;\n assert(v1);\n }\n }\n if (clen >= v2->depth) return false;\n assert(v1->ups[0].h != gethr(v2, clen, 1));\n return v1->ups[0].h < gethr(v2, clen, 1);\n}\nbool cmp3(node v1, node v2) { // First tree (reverse path), second tree (direct path)\n int clen = 0;\n for (int i = K - 1; i >= 0; i--) {\n if (((clen + (1 << i)) <= v2->depth) && v1->ups[i].h == gethr(v2, clen, (1 << i))) {\n v1 = v1->ups[i].x;\n clen += 1 << i;\n assert(v1);\n }\n }\n if (clen >= v2->depth) return true;\n assert(v1->ups[0].h != gethr(v2, clen, 1));\n return v1->ups[0].h < gethr(v2, clen, 1);\n}\n\nclass Tree {\n vector ns;\n\n public:\n Tree() : ns(1, new _node()) {\n ns[0]->cnt++; \n }\n node add(int v, char c) {\n assert(0 <= v && v < sz(ns));\n assert('a' <= c && c <= 'z');\n\n node vv = ns[v];\n node x = vv->ne[c - 'a'];\n if (!x) {\n x = vv->ne[c - 'a'] = new _node();\n x->depth = vv->depth + 1;\n x->sumhrev = vv->sumhrev * P + c;\n\n x->ups[0] = Up(vv, c, c);\n for (int i = 1; i < K; i++) {\n Up a = x->ups[i - 1];\n Up b;\n if (a.x) b = a.x->ups[i - 1];\n assert(0 <= (1 << (i - 1)) && (1 << (i - 1)) <= MAXN);\n x->ups[i] = Up(\n b.x,\n a.h * PPOW[1 << (i - 1)] + b.h,\n b.hrev * PPOW[1 << (i - 1)] + a.hrev\n );\n }\n }\n ns.pb(x);\n return x;\n }\n\n private:\n vector > hnodes;\n int ctim;\n void dfs(node v) {\n if (!v) return;\n v->eulerIds.first = ctim++;\n for (int i = 0; i < 26; i++)\n dfs(v->ne[i]);\n v->eulerIds.second = ctim++;\n }\n\n fenv_tree euler;\n vector sufarr;\n vi sufpos;\n fenv_tree sufsum;\n\n public:\n void precalc(int type) {\n if (type == 1) {\n ctim = 0;\n dfs(ns[0]);\n hnodes.resize(sz(ns));\n for (int i = 0; i < sz(ns); i++)\n hnodes[i] = mp(ns[i]->sumhrev, ns[i]);\n stable_sort(hnodes.begin(), hnodes.end());\n euler = fenv_tree(ctim);\n }\n assert(ns[0]->cnt == 1);\n\n if (type == 2) {\n sufarr = ns;\n stable_sort(sufarr.begin(), sufarr.end(), cmp);\n for (int i = 0; i < sz(sufarr); i++) {\n sufarr[i]->sufpos = i;\n }\n sufsum = fenv_tree(sz(sufarr));\n }\n addCnt(ns[0], type);\n }\n void addCnt(node v, int type) {\n if (type == 1) {\n euler.add(v->eulerIds.first, 1);\n euler.add(v->eulerIds.second, -1);\n } else {\n sufsum.add(v->sufpos, 1);\n }\n }\n int getParSum(node v) {\n return euler.get(v->eulerIds.first);\n }\n node getHashRev(hash h) {\n int i = lower_bound(hnodes.begin(), hnodes.end(), mp(h, (node)0)) - hnodes.begin();\n if (i >= sz(hnodes)) return 0;\n if (hnodes[i].first != h) return 0;\n return hnodes[i].second;\n }\n node getV(int x) { return ns[x]; }\n int getSufStartWith(node t2) {\n int a = lower_bound(sufarr.begin(), sufarr.end(), t2, cmp2) - sufarr.begin();\n int b = lower_bound(sufarr.begin(), sufarr.end(), t2, cmp3) - sufarr.begin();\n assert(0 <= a && a <= b && b <= sz(sufarr));\n return sufsum.get(b - 1) - sufsum.get(a - 1);\n }\n};\n\nstruct Op {\n int t, v;\n char c;\n};\n\nint main() {\n #ifdef DEBUG\n freopen(TASKNAME\".in\", \"r\", stdin);\n freopen(TASKNAME\".out\", \"w\", stdout);\n #endif\n\n PPOW[0] = 1;\n for (int i = 1; i <= MAXN; i++)\n PPOW[i] = PPOW[i - 1] * P;\n\n int n;\n while (scanf(\"%d\", &n) >= 1) {\n Tree t1, t2;\n ll ans = 1;\n vector ops(n);\n\n int _m1 = 1, _m2 = 1;\n for (int step = 0; step < n; step++) {\n Op &o = ops[step];\n scanf(\"%d%d %c\", &o.t, &o.v, &o.c), o.v--;\n assert(1 <= o.t && o.t <= 2);\n assert('a' <= o.c && o.c <= 'z');\n if (o.t == 1) {\n assert(0 <= o.v && o.v < _m1);\n _m1++;\n t1.add(o.v, o.c);\n } else {\n assert(0 <= o.v && o.v < _m2);\n _m2++;\n t2.add(o.v, o.c);\n }\n }\n t1.precalc(1);\n t2.precalc(2);\n\n int m1 = 0, m2 = 0;\n for (int step = 0; step < n; step++) {\n Op &o = ops[step];\n if (o.t == 1) {\n m1++;\n node x = t1.getV(m1);\n assert(x);\n t1.addCnt(x, 1);\n ans += t2.getSufStartWith(x);\n } else if (o.t == 2) {\n m2++;\n node x = t2.getV(m2);\n assert(x);\n t2.addCnt(x, 2);\n\n node y = x;\n hash ch = 0;\n for (int i = K - 1; i >= 0; i--) if ((1 << i) <= y->depth) {\n assert(0 <= (1 << i) && (1 << i) <= MAXN);\n hash h = ch * PPOW[1 << i] + y->ups[i].h;\n if (!y->ups[i].x && (1 << i) <= y->depth)\n return 123;\n if (t1.getHashRev(h)) {\n ch = h;\n y = y->ups[i].x;\n if (!y)\n return 124;\n }\n }\n if (!t1.getHashRev(ch))\n return 125;\n ans += t1.getParSum(t1.getHashRev(ch));\n }\n printf(\"%I64d\\n\", ans);\n }\n #ifndef DEBUG\n break;\n #endif\n }\n eprintf(\"%d\\n\", clock());\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "324d264f2fa4ed92d81ed29f3602a84b", "src_uid": "b0cd7ee6b5f13f977def002b53f8f443", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#define FOR(i, s, e) for (int i = (s); i < (e); i++)\n#define FOE(i, s, e) for (int i = (s); i <= (e); i++)\n#define FOD(i, s, e) for (int i = (s)-1; i >= (e); i--)\n#define CLR(a, x) memset(a, x, sizeof(a))\n#define EXP(i, l) for (int i = (l); i; i = qn[i])\n#define LLD long long\n#define N 100005\nusing namespace std;\n\nconst LLD MOD = 1000000007;\nint n, x, y, h[N], sz[N], p[N];\nLLD pow[N], v[2][N], ret;\nchar s[5];\nmap M[2];\nmap::iterator itr;\n\nint main() {\n scanf(\"%d\", &n);\n\n pow[0] = 1;\n FOR(i, 0, n) pow[i + 1] = (pow[i] * 26) % MOD;\n\n sz[0] = sz[1] = 1;\n h[1] = -1;\n FOR(i, 0, n) {\n scanf(\"%d%d%s\", &x, &y, s), x--;\n if (x == 0) {\n sz[0]++;\n h[sz[0]] = h[y] + 1;\n v[0][sz[0]] = (v[0][y] + (s[0] - 'a' + 1) * pow[h[sz[0]]]) % MOD;\n\n M[0][v[0][sz[0]]]++;\n }\n if (x == 1) {\n sz[1]++;\n v[1][sz[1]] = (v[1][y] * 26 + (s[0] - 'a' + 1)) % MOD;\n p[sz[1]] = y;\n\n int t = sz[1], off = 0;\n LLD val;\n while (t != 1) {\n t = p[t];\n val = v[1][sz[1]] - v[1][t] * pow[++off];\n val = (val % MOD + MOD) % MOD;\n M[1][val]++;\n }\n }\n\n ret = 0;\n for (itr = M[0].begin(); itr != M[0].end(); itr++) {\n ret += (LLD)(itr->second) * (LLD)M[1][itr->first];\n }\n\n printf(\"%I64d\\n\", ret + sz[1]);\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1a19d1975d984e7db6a61460ecc0509e", "src_uid": "b0cd7ee6b5f13f977def002b53f8f443", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std;\n\ntypedef pair ii;\ntypedef long long ll;\n\nconst int Maxn = 100005;\nconst int Maxm = 20;\nconst int pw1 = 37;\nconst int mod1 = 1000000007;\nconst int mod2 = 1000000009;\n\nii pw[Maxm];\nint lg[Maxn];\nint P[Maxn][Maxm];\nii hsh[Maxn][Maxm];\nint n;\nint a[Maxn], b[Maxn];\nchar c[Maxn];\nint sa[Maxn], rank[Maxn];\nint BIT1[Maxn], BIT2[Maxn];\nint L1[Maxn], L2[Maxn];\nint lef[Maxn], rig[Maxn];\nint n1, n2;\nll res;\n\nbool Less(int a, int b)\n{\n\tfor (int i = Maxm - 1; i >= 0; i--)\n\t\tif (1 << i <= L2[a] && 1 << i <= L2[b] && hsh[a][i].first == hsh[b][i].first && hsh[a][i].second == hsh[b][i].second)\n\t\t\ta = P[a][i], b = P[b][i];\n\tif (a == 1 && b == 1) return false;\n\tif (a == 1) return true;\n\tif (b == 1) return false;\n\treturn hsh[a][0].first < hsh[b][0].first;\n}\n\nvoid Insert(int BIT[], int x, int val)\n{\n\tfor (int i = x; i < Maxn; i += i & -i)\n\t\tBIT[i] += val;\n}\n\nint Get(int BIT[], int x)\n{\n\tint res = 0;\n\tfor (int i = x; i > 0; i -= i & -i)\n\t\tres += BIT[i];\n\treturn res;\n}\n\nint goUp(int x, int lvl)\n{\n\twhile (lvl) {\n\t\tx = P[x][lg[lvl & -lvl]];\n\t\tlvl -= lvl & -lvl;\n\t}\n\treturn x;\n}\n\nint main()\n{\n\tpw[0] = ii(pw1, pw1);\n\tfor (int i = 1; i < Maxm; i++)\n\t\tpw[i] = ii(ll(pw[i - 1].first) * ll(pw[i - 1].first) % ll(mod1), ll(pw[i - 1].second) * ll(pw[i - 1].second) % ll(mod2));\n\tlg[1] = 0;\n\tfor (int i = 2; i < Maxn; i++) lg[i] = lg[i >> 1] + 1;\n\tn1 = n2 = 1;\n\tscanf(\"%d\", &n);\n\tfor (int i = 0; i < n; i++) {\n\t\tscanf(\"%d %d %c\", &a[i], &b[i], &c[i]);\n\t\tif (a[i] == 2) {\n\t\t\tint v = b[i]; n2++; L2[n2] = L2[v] + 1;\n\t\t\tP[n2][0] = v; hsh[n2][0] = ii(c[i] - 'a' + 1, c[i] - 'a' + 1);\n\t\t\tfor (int i = 1; i < Maxm; i++) {\n\t\t\t\tP[n2][i] = P[P[n2][i - 1]][i - 1];\n\t\t\t\thsh[n2][i] = ii((ll(hsh[P[n2][i - 1]][i - 1].first) * ll(pw[i - 1].first) + ll(hsh[n2][i - 1].first)) % ll(mod1),\n\t\t\t\t\t\t\t\t(ll(hsh[P[n2][i - 1]][i - 1].second) * ll(pw[i - 1].second) + ll(hsh[n2][i - 1].second)) % ll(mod2));\n\t\t\t}\n\t\t}\n\t}\n\tfor (int i = 1; i <= n2; i++) sa[i] = i;\n\tsort(sa + 1, sa + n2 + 1, Less);\n\tfor (int i = 1; i <= n2; i++) rank[sa[i]] = i;\n\tres++; lef[1] = 1; rig[1] = n2; n2 = 1;\n\tInsert(BIT2, 1, 1); Insert(BIT1, rank[1], 1);\n\tfor (int i = 0; i < n; i++) {\n\t\tif (a[i] == 1) {\n\t\t\tint v = b[i]; n1++; L1[n1] = L1[v] + 1;\n\t\t\tint nd = c[i] - 'a' + 1;\n\t\t\tif (lef[v] > rig[v]) { lef[n1] = lef[v]; rig[n1] = rig[v]; }\n\t\t\telse {\n\t\t\t\tif (nd < hsh[goUp(sa[lef[v]], L1[n1] - 1)][0].first) rig[n1] = lef[v] - 1;\n\t\t\t\telse {\n\t\t\t\t\tint l = lef[v], r = rig[v];\n\t\t\t\t\tint res = l;\n\t\t\t\t\twhile (l <= r) {\n\t\t\t\t\t\tint mid = l + r >> 1;\n\t\t\t\t\t\tif (hsh[goUp(sa[mid], L1[n1] - 1)][0].first <= nd) { res = mid; l = mid + 1; }\n\t\t\t\t\t\telse r = mid - 1;\n\t\t\t\t\t}\n\t\t\t\t\trig[n1] = res;\n\t\t\t\t} \n\t\t\t\tif (hsh[goUp(sa[rig[v]], L1[n1] - 1)][0].first < nd) lef[n1] = rig[v] + 1;\n\t\t\t\telse {\n\t\t\t\t\tint l = lef[v], r = rig[v];\n\t\t\t\t\tint res = r;\n\t\t\t\t\twhile (l <= r) {\n\t\t\t\t\t\tint mid = l + r >> 1;\n\t\t\t\t\t\tif (nd <= hsh[goUp(sa[mid], L1[n1] - 1)][0].first) { res = mid; r = mid - 1; }\n\t\t\t\t\t\telse l = mid + 1;\n\t\t\t\t\t}\n\t\t\t\t\tlef[n1] = res;\n\t\t\t\t}\n\t\t\t\tif (lef[n1] <= rig[n1]) {\n\t\t\t\t\tres += Get(BIT1, rig[n1]) - Get(BIT1, lef[n1] - 1);\n\t\t\t\t\tInsert(BIT2, lef[n1], 1); Insert(BIT2, rig[n1] + 1, -1);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tn2++;\n\t\t\tres += Get(BIT2, rank[n2]);\n\t\t\tInsert(BIT1, rank[n2], 1);\n\t\t}\n\t\tprintf(\"%I64d\\n\", res);\n\t}\n\treturn 0;\n}\n// ntuj - 66pxnggymu9mtslu4yq29", "lang_cluster": "C++", "compilation_error": true, "code_uid": "396f4d7d3789e28fadd9633d16858b4f", "src_uid": "b0cd7ee6b5f13f977def002b53f8f443", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nconst int base = 13331;\n\nstruct Operation {\n\tint t, v;\n\tchar c;\n} op[100000];\n\nint s1[100002], s2[100002], sa[100001], rank[100001], up[100001];\nint depth1[100001], depth2[100001], pre[100001][18];\nlong long hash[100001], pow[18];\npair range[100001];\n\nbool cmp(int a, int b) {\n\tint lg = 0;\n\twhile (1 << lg <= depth2[a] && 1 << lg <= depth2[b]) lg ++;\n\tfor (int i = lg - 1; i >= 0; i --) {\n\t\tlong long t1 = hash[a] - hash[pre[a][i]] * pow[i];\n\t\tlong long t2 = hash[b] - hash[pre[b][i]] * pow[i];\n\t\tif (t1 == t2) {\n\t\t\ta = pre[a][i];\n\t\t\tb = pre[b][i];\n\t\t}\n\t}\n\treturn up[a] < up[b];\n}\n\nint goUp(int x, int step) {\n\tfor (int i = 0; 1 << i <= step; i ++)\n\t\tif (step & 1 << i) x = pre[x][i];\n\treturn x;\n}\n\nint main() {\n\tint n;\n\tscanf(\"%d\", &n);\n\tfor (int i = 0; i < n; i ++) {\n\t\tint x, y;\n\t\tchar tmp[11];\n\t\tscanf(\"%d%d%s\", &x, &y, tmp);\n\t\top[i].t = x;\n\t\top[i].v = y - 1;\n\t\top[i].c = tmp[0];\n\t}\n\t\n\thash[0] = 0;\n\tup[0] = 0;\n\tdepth1[0] = 0;\n\tmemset(pre, -1, sizeof(pre));\n\tint tot = 1;\n\tfor (int i = 0; i < n; i ++)\n\t\tif (op[i].t == 2) {\n\t\t\tdepth2[tot] = depth2[op[i].v] + 1;\n\t\t\thash[tot] = hash[op[i].v] * base + op[i].c;\n\t\t\tup[tot] = op[i].c;\n\t\t\tpre[tot][0] = op[i].v;\n\t\t\tfor (int j = 1; 1 << j <= depth2[tot]; j ++)\n\t\t\t\tpre[tot][j] = pre[pre[tot][j - 1]][j - 1];\n\t\t\ttot ++;\n\t\t}\n\t\n\tpow[0] = base;\n\tfor (int i = 1; 1 << i <= tot; i ++) pow[i] = pow[i - 1] * pow[i - 1];\n\tfor (int i = 0; i < tot; i ++) sa[i] = i;\n\tstable_sort(sa, sa + tot, cmp);\n\tfor (int i = 0; i < tot; i ++) rank[sa[i]] = i;\n\t\n\tmemset(s1, 0, sizeof(s1));\n\tmemset(s2, 0, sizeof(s2));\n\tlong long ans = 0;\n\tint cur1 = 1, cur2 = 1;\n\trange[0] = make_pair(0, tot);\n\tdepth1[0] = 0;\n\tfor (int i = 0; i < n; i ++) {\n\t\tif (op[i].t == 1) {\n\t\t\tdepth1[cur1] = depth1[op[i].v] + 1;\n\t\t\tif (range[op[i].v].first != -1) {\n\t\t\t\tint head, tail;\n\t\t\t\thead = range[op[i].v].first;\n\t\t\t\ttail = range[op[i].v].second - 1;\n\t\t\t\twhile (head <= tail) {\n\t\t\t\t\tint mid = (head + tail) / 2;\n\t\t\t\t\tif (up[goUp(sa[mid], depth1[op[i].v])] < op[i].c) {\n\t\t\t\t\t\thead = mid + 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\ttail = mid - 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tint l = head;\n\t\t\t\thead = range[op[i].v].first;\n\t\t\t\ttail = range[op[i].v].second - 1;\n\t\t\t\twhile (head <= tail) {\n\t\t\t\t\tint mid = (head + tail) / 2;\n\t\t\t\t\tif (up[goUp(sa[mid], depth1[op[i].v])] > op[i].c) {\n\t\t\t\t\t\ttail = mid - 1;\n\t\t\t\t\t} else {\n\t\t\t\t\t\thead = mid + 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tint r = tail + 1;\n\t\t\t\tif (l >= r) {\n\t\t\t\t\trange[cur1] = make_pair(-1, -1);\n\t\t\t\t} else {\n\t\t\t\t\trange[cur1] = make_pair(l, r);\n\t\t\t\t\tfor (int j = r; j > 0; j -= j & -j) ans += s1[j];\n\t\t\t\t\tfor (int j = l; j > 0; j -= j & -j) ans -= s1[j];\n\t\t\t\t\tfor (int j = l + 1; j <= tot; j += j & -j) s2[j] ++;\n\t\t\t\t\tif (r < tot) {\n\t\t\t\t\t\tfor (int j = r + 1; j <= tot; j += j & -j) s2[j] --;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\trange[cur1] = make_pair(-1, -1);\n\t\t\t}\n\t\t\tcur1 ++;\n\t\t} else {\n\t\t\tint t = rank[cur2];\n\t\t\tfor (int j = t + 1; j <= tot; j += j & -j) s1[j] ++;\n\t\t\tfor (int j = t + 1; j > 0; j -= j & -j) ans += s2[j];\n\t\t\tcur2 ++;\n\t\t}\n\t\tprintf(\"%I64d\\n\", ans + cur2);\n\t}\n\t\n\treturn 0;\n}\n// ntuj - 1evxliu0j0xhfciq71ls", "lang_cluster": "C++", "compilation_error": true, "code_uid": "67fdaad87ecec39e82e945ec8dcc2b98", "src_uid": "b0cd7ee6b5f13f977def002b53f8f443", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\nconst int N = 2e5+10, M = 105;\nint n, ans = 0, a[N], v[N], maxS[2*N], mark[M], freq[M];\npair mx = {-1, -1};\n\nint main(){\n scanf(\"%d\", &n);\n for(int i = 1; i <= n; i++)\n scanf(\"%d\", &a[i]), mark[a[i]] = 1;\n for(int i = 1; i <= n; i++)\n freq[a[i]]++, mx = max(mx, make_pair(freq[a[i]], a[i]));\n for(int i = 1; i <= min(n, 100); i++)\n if (freq[i] == mx.first && i != mx.second)\n printf(\"%d\\n\", n), exit(0);\n for(int i = 1; i <= n; i++)\n if (a[i] == mx.second) v[i] = 1;\n for(int i = 1, off, s, loc_ans; i <= min(n, 100); i++){\n if (!mark[i] or i == mx.second) continue;\n else {\n for(int j = 1; j <= n; j++){\n if (a[j] == i) v[j] = -1, dbg(j, v[j]);\n else if (a[j] != mx.second) v[j] = 0;\n }\n off = 0, s = 0;\n memset(maxS, 0, sizeof maxS);\n for(int j = 1; j <= n; j++)\n s += v[j], maxS[s+int(2e5)] = j;\n loc_ans = 0;\n for(int j = 1; j <= n; j++)\n loc_ans = max(loc_ans, maxS[off+int(2e5)]-j+1), off += v[j];\n ans = max(ans, loc_ans);\n }\n }\n printf(\"%d\\n\", ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fe63e03e621e333a6930b6e972206e54", "src_uid": "a06ebb2734365ec97d07cd1b6b3faeed", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n//#include \n//using namespace __gnu_pbds;\n//typedef tree , rb_tree_tag, tree_order_statistics_node_update> indexed_set;\n// #include \n// using namespace __gnu_cxx;\ntypedef long long int ll;\ntypedef long double ld;\n#define FAST \\\n ios::sync_with_stdio(0); \\\n cin.tie(0); \\\n cout.tie(0);\n#define rep(g, i, n) for (ll g = i; g < n; g++)\n#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)\n#define all(v) v.begin(), v.end()\n#define pb push_back\n#define mxe(v) *max_element(v.begin(), v.end())\n#define mne(v) *min_element(v.begin(), v.end())\n#define ve vector\n#define lb lower_bound\n#define ub upper_bound\n#define bb break\n#define cc continue\n#define rem 1000000007\n#define PI 3.141592653589793238462643383279502\nll power(ll x, ll y, ll p)\n{\n ll res = 1; // Initialize result\n x = x % p; // Update x if it is more than or\n while (y > 0)\n {\n if (y & 1)\n res = (res * x) % p;\n y = y >> 1; // y = y/2\n x = (x * x) % p;\n }\n return res;\n}\nll modInverse(ll n, ll p)\n{\n return power(n, p - 2, p);\n}\nstruct point\n{\n ll x, y;\n};\nint main()\n{\n FAST\n // freopen(\"input1.txt\", \"r\", stdin);\n // freopen(\"output.txt\", \"w\", stdout);\n /*ll tests;\n cin>>tests;\n rep (gg,0,tests)\n {}*/\n ll n;\n cin >> n;\n ve arr(n);\n ve fre(101, 0);\n ll mx = 0;\n set s1;\n rep(i, 0, n)\n {\n cin >> arr[i];\n s1.insert(arr[i]);\n fre[arr[i]]++;\n mx = max(mx, fre[arr[i]]);\n }\n ll cnt = 0, val = -1;\n for (auto x : s1)\n {\n if (fre[x] == mx)\n {\n cnt++;\n val = x;\n }\n }\n if (cnt > 1)\n {\n cout << n << \"\\n\";\n return 0;\n }\n ll ans=0;\n rep(i, 1,101)\n {\n if (i != val)\n {\n // cout<<\"i.. \"< arr1(arr);\n unordered_map ps;\n ll sum=0;\n rep (j,0,n)\n {\n if (arr1[j]==i)\n {\n arr1[j]=-1;\n }\n else if(arr1[j]==val)\n {\n arr1[j]=1;\n }\n else\n {\n arr1[j]=0;\n }\n sum+=arr1[j];\n // cout<<\"j.. \"<\n#include\n#include\nusing namespace std;\nconst int N=200005,M=105;\nint n;\nint a[N];\nint cnt[N];\nint b[N];\nint pre[N*2];\nint main()\n{\n\tscanf(\"%d\",&n);\n\tint m=100;\n\tfor(int i=1;i<=n;i++)\n\t\tscanf(\"%d\",&a[i]);\n\tfor(int i=1;i<=n;i++)\n\t\tcnt[a[i]]++;\n\tint mx=max_element(cnt+1,cnt+m+1)-cnt;\n\tint ans=0;\n\tfor(int x=1;x<=m;x++)\n\t{\n\t\tif(x==mx) continue;\n\t\tmemset(pre,-1,sizeof(pre));\n\t\tfor(int i=1;i<=n;i++)\n\t\t\tif(a[i]==mx) b[i]=1;\n\t\t\telse if(a[i]==x) b[i]=-1;\n\t\t\telse b[i]=0;\n\t\tfor(int i=1;i<=n;i++)\n\t\t\tb[i]+=b[i-1];\n\t\tint res=0;\n\t\tpre[n]=0;\n\t\tfor(int i=1;i<=n;i++)\n\t\t\tif(pre[b[i]+n]==-1) pre[b[i]+n]=i;\n\t\t\telse res=max(res,i-pre[b[i]+n]);\n\t\tans=max(ans,res);\n\t}\n\tprintf(\"%d\",ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "64ca1e8e0aa4944d546772ffadbbf335", "src_uid": "a06ebb2734365ec97d07cd1b6b3faeed", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main()\n{long long int n,a,b,c,d,e,f,g;\ncin>>n;\nvectorvalues(n,0);\nvectorsaylar(101,0);\nfor(int i=0;i>values[i],saylar[values[i]]++;\nlong long int maxi=-1,eded=-1;\nfor(int i=0;i<101;i++)\nif(saylar[i]>maxi)\nmaxi=saylar[i],eded=i;\n long long int ans=0;\n for(int i=0;i<101;i++)\n {vectorkalues(n,0),tezesaylar(2*n+10,-1);\n \n for(int j=0;j\n\n#define pb push_back\n#define pp pop_back\n#define f first\n#define s second\n#define mp make_pair\n#define sz(a) int((a).size())\n#ifdef _WIN32\n# define I64 \"%I64d\"\n#else\n# define I64 \"%lld\"\n#endif\n#define fname \".\"\n#define pi pair < ll, ll >\n\ntypedef long long ll;\ntypedef unsigned long long ull;\n\nconst int MAX_N = (int)2e5 + 123;\nconst ll inf = (ll)1e18 + 123;\n\nusing namespace std;\n\nint n;\nint a[MAX_N];\nll d[MAX_N];\n\nstruct tree {\n ll x[2], lazy[2];\n int tl, tr;\n tree() {\n x[0] = x[1] = lazy[0] = lazy[1] = tl = tr = 0;\n }\n tree operator + (const tree &b) {\n int id = (tr - tl + 1) % 2;\n tree res;\n res.x[0] = min(x[0], b.x[id]), res.x[1] = min(x[1], b.x[id ^ 1]);\n res.tl = tl, res.tr = b.tr;\n return res;\n }\n} t[4 * MAX_N];\n\nvoid build(int v = 1, int tl = 0, int tr = n - 1) {\n if (tl == tr) {\n t[v].x[0] = d[tl], t[v].x[1] = inf;\n t[v].tl = tl, t[v].tr = tr;\n return;\n }\n int tm = (tl + tr) / 2;\n build(v * 2, tl, tm), build(v * 2 + 1, tm + 1, tr);\n t[v] = t[v * 2] + t[v * 2 + 1];\n}\n\nvoid push(int v) {\n for (int i = 0; i < 2; i++)\n t[v].x[i] = min(0ll + inf, t[v].x[i] + 0ll + t[v].lazy[i]);\n if (t[v].tl != t[v].tr) {\n int tm = (t[v].tl + t[v].tr) / 2;\n for (int i = 0; i < 2; i++)\n t[v * 2].lazy[i] += t[v].lazy[i];\n int id = (tm - t[v].tl + 1) % 2;\n t[v * 2 + 1].lazy[0] += t[v].lazy[id];\n t[v * 2 + 1].lazy[1] += t[v].lazy[id ^ 1];\n }\n for (int i = 0; i < 2; i++)\n t[v].lazy[i] = 0;\n}\n\nint update(int l, int r, pi val, int v = 1, int tl = 0, int tr = n - 1) {\n push(v);\n if (tl > r || l > tr)\n return 0;\n if (tl >= l && tr <= r) {\n t[v].lazy[0] += val.f, t[v].lazy[1] += val.s;\n return tr - tl + 1;\n }\n int tm = (tl + tr) / 2;\n int len = update(l, r, val, v * 2, tl, tm);\n if (len % 2 == 1)\n swap(val.f, val.s);\n len += update(l, r, val, v * 2 + 1, tm + 1, tr);\n t[v] = t[v * 2] + t[v * 2 + 1];\n return len;\n}\n\npair < int, pi > get(int l, int r, int v = 1, int tl = 0, int tr = n - 1) {\n push(v);\n if (tl > r || l > tr)\n return mp(0, mp(inf, inf));\n if (tl >= l && tr <= r)\n return mp(tr - tl + 1, mp(t[v].x[0], t[v].x[1]));\n int tm = (tl + tr) / 2;\n pair < int, pi > L = get(l, r, v * 2, tl, tm);\n pair < int, pi > R = get(l, r, v * 2 + 1, tm + 1, tr);\n if (L.f % 2 == 1)\n swap(R.s.f, R.s.s);\n return mp(L.f + R.f, mp(min(L.s.f, R.s.f), min(L.s.s, R.s.s)));\n}\n\nbool check(int l, int r) {\n/* ll x = (l > 0 ? get(l - 1, l - 1).s.f : 0);\n for (int i = l, it = 1; i <= r; i++, it ^= 1) {\n ll now = get(i, i).s.f + (it ? x : -x);\n if (now < it)\n return 0;\n if (i == r && now != it)\n return 0;\n }\n return 1;*/\n\n\n ll x = (l > 0 ? get(l - 1, l - 1).s.f : 0);\n pi now = get(l, r).s;\n if (now.f != inf)\n now.f += x;\n if (now.s != inf)\n now.s -= x;\n if (now.f < 1 || now.s < 0)\n return 0;\n ll last = get(r, r).s.f + ((r - l + 1) % 2 == 1 ? x : -x);\n if (last != (r - l + 1) % 2)\n return 0;\n return 1;*/\n}\n\nvoid add(int l, int r, int x) {\n update(l, r, mp(x, 0));\n if ((r - l) % 2 == 0 && r + 1 < n)\n update(r + 1, n - 1, mp(-x, x));\n}\n\nint main() {\n\t#ifdef Nick\n\tfreopen(fname\"in\",\"r\",stdin);\n\t#endif\n\tios_base :: sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);\n\tcin >> n;\n\tfor (int i = 0; i < n; i++)\n\t\tcin >> a[i];\n for (int i = 0; i < n; i++) {\n d[i] = a[i] - (i > 0 ? d[i - 1] : 0);\n }\n build();\n\tint q;\n\tcin >> q;\n\tfor (int i = 0, tp, l, r, x; i < q; i++) {\n\t\tcin >> tp >> l >> r;\n\t\tif (tp == 2) {\n\t\t\tcout << (check(l, r) ? \"1\\n\" : \"0\\n\");\n\t\t}\n\t\telse {\n\t\t\tcin >> x;\n\t\t\tadd(l, r, x);\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d72e332a010bf58cec657728af72ade5", "src_uid": "a17833a733d59936d1c3ba5f27b0cbe0", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include\n#define rd(x) scanf(\"%d\",&x)\n#define ls k<<1\n#define rs k<<1|1\n#define ll long long\n#define pii pair\n#define mp make_pair\nusing namespace std;\n\nconst int N=200005,M=N*4;\nint n,q,a[N],t,l,r,k;\nstruct __{\n\tll p[M],s[M];\n\tvoid B(int l,int r,int k,bool t){\n\t\tif(l==r){if(((l&1)&&!t)||(!(l&1)&&t)) p[k]=min(0,a[l]-a[l-1]),s[k]=a[l]-a[l-1];return;}\n\t\tint mid=l+r>>1;\n\t\tB(l,mid,ls,t);B(mid+1,r,rs,t);\n\t\tp[k]=min(p[ls],s[ls]+p[rs]);s[k]=s[ls]+s[rs];\n\t}\n\tvoid C(int l,int r,int x,int y,int k){\n\t\tif(l==r){s[k]+=y;p[k]=min(0ll,s[k]);return;}\n\t\tint mid=l+r>>1;\n\t\tif(x<=mid) C(l,mid,x,y,ls); else C(mid+1,r,x,y,rs);\n\t\tp[k]=min(p[ls],s[ls]+p[rs]);s[k]=s[ls]+s[rs];\n\t}\n\tpii G(int l,int r,int x,int y,int k){\n\t\tif(l==x&&y==r) return mp(p[k],s[k]);\n\t\tint mid=l+r>>1;pii L,R;\n\t\tif(y<=mid) return G(l,mid,x,y,ls);\n\t\tif(x>mid) return G(mid+1,r,x,y,rs);\n\t\tL=G(l,mid,x,mid,ls);R=G(mid+1,r,mid+1,y,rs);\n\t\treturn mp(min(L.first,L.second+R.first),L.second+R.second);\n\t}\n\tvoid C(int x,int y){C(1,n,x,y,1);}\n\tll G(int x,int y){return G(1,n,x,y,1).first;}\n\tll S(int x,int y){return G(1,n,x,y,1).second;}\n};\nstruct _S{\n\tsgt p0,p1;\n\tll G(int x){return p0.S(1,x)+p1.S(1,x);}\n\tvoid B(){p0.B(1,n,1,0);p1.B(1,n,1,1);}\n\tvoid C(int x,int y){if(x>n)return;else if(x&1) p0.C(x,y);else p1.C(x,y);}\n\tbool c(int l,int r){\n\t\tll val=G(l);\n\t\tif(l==r){if(val>1) return 0; else return 1;}\n\t\tif(l&1){\n\t\t\tll tmp=G(r);if(!(r&1)) tmp=0;\n\t\t\tif(p1.S(++l,r)!=tmp) return 0;\n\t\t\tif(p1.G(l,r)<0) return 0;\n\t\t\tif(p0.G(l,r)+val<0) return 0;\n\t\t}\n\t\telse{\n\t\t\tll tmp=G(r);if(r&1) tmp=0;\n\t\t\tif(p0.S(++l,r)!=tmp) return 0;\n\t\t\tif(p0.G(l,r)<0) return 0;\n\t\t\tif(p1.G(l,r)+val<0) return 0;\n\t\t}return 1;\n\t}\n}s;\n\nint main(){\n\trd(n);\n\tfor(int i=1;i<=n;i++) rd(a[i]),a[i]--;\n\ts.B(),rd(q);\n\tfor(int _=1;_<=q;_++){\n\t\trd(t);rd(l);rd(r);l++,r++;\n\t\tif(t==1)rd(k),s.C(l,k),s.C(r+1,-k); else printf(\"%d\\n\",s.c(l,r));\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cdb4a06214a9dc15e116d6a42c2a6bc1", "src_uid": "a17833a733d59936d1c3ba5f27b0cbe0", "difficulty": 2600.0} {"lang": "GNU C++14", "source_code": "// In the Name of Allah\n#include\n#define double long double\ntypedef long long ll;\nconst ll MAX_N = 2e5+100;\nconst ll MOD = 1e9+7;\nconst ll delta = 10333;\nusing namespace std;\n\nll mn[MAX_N*2][2];\nll lazy[MAX_N*2][2];\nll a[MAX_N];\nll b[MAX_N];\nll s[2];\nint n,q,m,t;\n\nvoid update(int k,int d)\n{\n mn[k][d] = min(mn[k*2][d],mn[k*2+1][d]);\n}\n\nvoid shift(int k,int d)\n{\n int l = k*2;\n int r = k*2+1;\n lazy[l][d] += lazy[k][d];\n lazy[r][d] += lazy[k][d];\n mn[l][d] += lazy[k][d];\n mn[r][d] += lazy[k][d];\n lazy[k][d] = 0;\n}\n\nvoid build(int l,int r,int k,int d)\n{\n if (l>r)\n return;\n if (l==r)\n {\n mn[k][d] = b[l*2-d];\n return;\n }\n int mid = (l+r)/2;\n build(l,mid,k*2,d);\n build(mid+1,r,k*2+1,d);\n update(k,d);\n}\n\nvoid add(int l,int r,int a,int b,int k,int d,ll x)\n{\n if (r> n;\n for(int i = 1;i<=n;++i)\n scanf(\"%d\",&a[i]);\n for(int i = 1;i<=n;++i)\n b[i] = a[i]-b[i-1];\n //zoj ha\n s[0] = n/2;\n //fard ha\n s[1] = n-s[0];\n build(1,s[0],1,0);\n build(1,s[1],1,1);\n cin >> q;\n while(q--)\n {\n int t;\n scanf(\"%d\",&t);\n if (t==1)\n {\n int l,r,k;\n scanf(\"%d%d%d\",&l,&r,&k);\n l++,r++;\n add(1,s[l&1],cv(l),cv(r-(l%2!=r%2)),1,l&1,k);\n if ((r-l+1)%2)\n {\n if (r\n\n#define pb push_back\n#define pp pop_back\n#define f first\n#define s second\n#define mp make_pair\n#define sz(a) int((a).size())\n#ifdef _WIN32\n# define I64 \"%I64d\"\n#else\n# define I64 \"%lld\"\n#endif\n#define fname \".\"\n#define pi pair < ll, ll >\n\ntypedef long long ll;\ntypedef unsigned long long ull;\n\nconst int MAX_N = (int)2e5 + 123;\nconst ll inf = (ll)1e18 + 123;\n\nusing namespace std;\n\nint n;\nint a[MAX_N];\nll d[MAX_N];\n\nstruct tree {\n ll x[2], lazy[2];\n int tl, tr;\n tree() {\n x[0] = x[1] = lazy[0] = lazy[1] = tl = tr = 0;\n }\n tree operator + (const tree &b) {\n int id = (tr - tl + 1) % 2;\n tree res;\n res.x[0] = min(x[0], b.x[id]), res.x[1] = min(x[1], b.x[id ^ 1]);\n res.tl = tl, res.tr = b.tr;\n return res;\n }\n} t[4 * MAX_N];\n\nvoid build(int v = 1, int tl = 0, int tr = n - 1) {\n if (tl == tr) {\n t[v].x[0] = d[tl], t[v].x[1] = inf;\n t[v].tl = tl, t[v].tr = tr;\n return;\n }\n int tm = (tl + tr) / 2;\n build(v * 2, tl, tm), build(v * 2 + 1, tm + 1, tr);\n t[v] = t[v * 2] + t[v * 2 + 1];\n}\n\nvoid push(int v) {\n for (int i = 0; i < 2; i++)\n t[v].x[i] = min(0ll + inf, t[v].x[i] + 0ll + t[v].lazy[i]);\n if (t[v].tl != t[v].tr) {\n int tm = (t[v].tl + t[v].tr) / 2;\n for (int i = 0; i < 2; i++)\n t[v * 2].lazy[i] += t[v].lazy[i];\n int id = (tm - t[v].tl + 1) % 2;\n t[v * 2 + 1].lazy[0] += t[v].lazy[id];\n t[v * 2 + 1].lazy[1] += t[v].lazy[id ^ 1];\n }\n for (int i = 0; i < 2; i++)\n t[v].lazy[i] = 0;\n}\n\nint update(int l, int r, pi val, int v = 1, int tl = 0, int tr = n - 1) {\n push(v);\n if (tl > r || l > tr)\n return 0;\n if (tl >= l && tr <= r) {\n t[v].lazy[0] += val.f, t[v].lazy[1] += val.s;\n return tr - tl + 1;\n }\n int tm = (tl + tr) / 2;\n int len = update(l, r, val, v * 2, tl, tm);\n if (len % 2 == 1)\n swap(val.f, val.s);\n len += update(l, r, val, v * 2 + 1, tm + 1, tr);\n t[v] = t[v * 2] + t[v * 2 + 1];\n return len;\n}\n\npair < int, pi > get(int l, int r, int v = 1, int tl = 0, int tr = n - 1) {\n push(v);\n if (tl > r || l > tr)\n return mp(0, mp(inf, inf));\n if (tl >= l && tr <= r)\n return mp(tr - tl + 1, mp(t[v].x[0], t[v].x[1]));\n int tm = (tl + tr) / 2;\n pair < int, pi > L = get(l, r, v * 2, tl, tm);\n pair < int, pi > R = get(l, r, v * 2 + 1, tm + 1, tr);\n if (L.f % 2 == 1)\n swap(R.s.f, R.s.s);\n return mp(L.f + R.f, mp(min(L.s.f, R.s.f), min(L.s.s, R.s.s)));\n}\n\nbool check(int l, int r) {\n/* ll x = (l > 0 ? get(l - 1, l - 1).s.f : 0);*/\n pi shit = mp(inf, inf);\n for (int i = l, it = 1; i <= r; i++, it ^= 1) {\n ll now = get(i, i).s.f + (it ? x : -x);\n shit.f = min(shit.f, now);\n shit.s = min(shit.s, now);\n }\n\n\n ll x = (l > 0 ? get(l - 1, l - 1).s.f : 0);\n pi now = get(l, r).s;\n if (now.f != inf)\n now.f += x;\n if (now.s != inf)\n now.s -= x;\n assert(now == shit);\n if (now.f < 1 || now.s < 0)\n return 0;\n ll last = get(r, r).s.f + ((r - l + 1) % 2 == 1 ? x : -x);\n if (last != (r - l + 1) % 2)\n return 0;\n return 1;\n}\n\nvoid add(int l, int r, int x) {\n update(l, r, mp(x, 0));\n if ((r - l) % 2 == 0 && r + 1 < n)\n update(r + 1, n - 1, mp(-x, x));\n}\n\nint main() {\n\t#ifdef Nick\n\tfreopen(fname\"in\",\"r\",stdin);\n\t#endif\n\tios_base :: sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);\n\tcin >> n;\n\tfor (int i = 0; i < n; i++)\n\t\tcin >> a[i];\n for (int i = 0; i < n; i++) {\n d[i] = a[i] - (i > 0 ? d[i - 1] : 0);\n }\n build();\n\tint q;\n\tcin >> q;\n\tfor (int i = 0, tp, l, r, x; i < q; i++) {\n\t\tcin >> tp >> l >> r;\n\t\tif (tp == 2) {\n\t\t\tcout << (check(l, r) ? \"1\\n\" : \"0\\n\");\n\t\t}\n\t\telse {\n\t\t\tcin >> x;\n\t\t\tadd(l, r, x);\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5035aeb6c245e9caf409afc268eb78d2", "src_uid": "a17833a733d59936d1c3ba5f27b0cbe0", "difficulty": 2600.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nint sol=(int) 1e9+7;\nint op;\n\nint ask(int r,int c)\n{\n op++;\n if (op==lim)\n {\n cout<<\"! \"<>x;\n sol=min(sol,x);\n\n return x;\n}\n\nint go=1;\n\nvoid solve(int r1,int c1,int r2,int c2)\n{\n if (r1>r2 || c1>c2)\n {\n return;\n }\n if (r1==r2&&c1==c2)\n {\n ask(r1,c1);\n return;\n }\n int rm=(r1+r2)/2;\n vector e;\n for (int j=max(go,c1);j<=c2;j++)\n {\n e.push_back(ask(rm,j));\n }\n int mn=e[0];\n for (auto &x : e)\n mn=min(mn,x);\n for (int j=c1;j<=c2;j++)\n if (e[j-c1]==mn)\n {\n solve(r1,c1,rm-1,j);\n go=max(go,j);\n solve(rm+1,j,r2,c2);\n return;\n }\n}\n\nint main()\n{\n int n,m;\n cin>>n>>m;\n solve(1,1,n,m);\n op=4*(n+m);\n cout<<\"! \"<\nusing namespace std;\n// #include \n// #include \n// using namespace __gnu_pbds;\n\n// Debugging\n#define dbg(a) cerr<=n; i--)\n#define fr(i,a,n,b) for(int i=a; i=n; i-=b)\n#define IN cin>>\n#define OUT cout<<\n#define nl \"\\n\"\n#define sz(a) int(a.size())\n#define all(a) (a).begin(),(a).end()\n#define each(a,b) for(auto &a:b)\n#define pb push_back\n#define set_bits(a) __builtin_popcountll(a)\n#define ar array\n#define write(a) for(auto x:a) {OUT x<<\" \";} OUT nl;\n#define read(a) for(auto &x:a) {IN x;}\n// #define oset tree,rb_tree_tag,tree_order_statistics_node_update>\nusing ll=long long int;\nusing ld=long double;\nusing pll=pair;\nusing pii=pair;\nusing vll=vector;\nusing vi=vector;\nconst ll mod=(ll)(1e9)+7LL;\nconst ll M=998244353LL;\nconst int dx[4]={1,0,-1,0};\nconst int dy[4]={0,1,0,-1};\nconst ld pi=acos(-1);\n\n// General Functions\nll gcd(ll a, ll b)\n{\n return (b?gcd(b,a%b):a);\n}\nll P(ll B, ll power, ll modulo) //Fast Power\n{\n ll ans=1LL;\n while(power>0LL)\n {\n if(power%2LL==1LL)\n {\n ans=(ans*B)%modulo;\n }\n B=(B*B)%modulo;\n power/=2LL;\n }\n return ans;\n}\nbool isPrime(ll n)\n{\n if(n<=1LL)\n {\n return false;\n }\n if(n<=3LL)\n {\n return true;\n }\n if(n%2==0LL || n%3==0LL)\n {\n return false;\n }\n for(ll i=5LL; (i*i)<=n; i+=6LL)\n {\n if(n%i==0LL || n%(i+2LL)==0LL)\n {\n return false;\n }\n }\n return true;\n}\nvoid vok()\n{\n fast\n #ifndef ONLINE_JUDGE\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n freopen(\"error.txt\",\"w\",stderr);\n #endif\n}\n\n// Global Variables\nconst int mxN=int(1e5)+100;\n\n// Solver Function(s) \nbool comp(const ar &a, const ar &b)\n{\n if(a[0]==b[0])\n {\n return a[1]>m;\n vector> v;\n loop(i,0,m)\n {\n OUT \"? \"<<1<<\" \"<\n\nusing namespace std;\n\nint sol=(int) 1e9+7;\n\nint ask(int r,int c)\n{\n int x;\n cin>>x;\n sol=min(sol,x);\n return x;\n}\n\nvoid solve(int r1,int c1,int r2,int c2)\n{\n if (r1==r2&&c1==c2)\n {\n ask(r1,c1,r2,c2);\n return;\n }\n int rm=(r1+r2)/2;\n vector e;\n for (int j=c1;j<=c2;j++)\n {\n e.push_back(ask(rm,j));\n }\n int mn=e[0];\n for (auto &x : mn)\n mn=min(mn,x);\n for (int j=c1;j<=c2;j++)\n if (e[j-c1]==mn)\n {\n solve(r1,c1,rm-1,j);\n solve(rm+1,j,r2,c2);\n return;\n }\n}\n\nint main()\n{\n int n,m;\n cin>>n>>m;\n solve(1,1,n,m);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b14bcb80eb6710f28f2308c5d635f654", "src_uid": "d663fcd3c550d7e4987010e07c001422", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize(\"Ofast\",\"inline\",\"-ffast-math\")\n#pragma GCC target(\"avx,sse2,sse3,sse4,mmx\")\n#include\n#define rep(i,a,b) for(int i=(a);i<=(b);i++)\n#define per(i,a,b) for(int i=(a);i>=(b);i--)\n#define REP(i,n) for(int i=0;i<(n);i++)\n#define fi first\n#define se second\n#define pb push_back\n#define mp make_pair\nusing namespace std;\ntypedef pair pii;\ntypedef vector vi;\ntypedef long long ll;\n \n/*\nchar BUF[1 << 22], *ST, *EN;\n#define gc (ST == EN && (ST = BUF, EN = BUF + fread(BUF, 1, 1 << 21, stdin), ST == EN) ? EOF : *ST++)\n*/\n#define gc getchar()\n \ntemplate void read(T &x){\n\tint f=0; x=0; char ch=gc;\n\tfor(;!isdigit(ch);ch=gc) f|=(ch=='-');\n\tfor(;isdigit(ch);ch=gc) x=x*10+ch-'0';\n\tif(f) x=-x;\n}\n \nconst int N=1000005;\nint L[N],n,m,res=1e9+99;\n \nint qry(int x,int y){\n\tprintf(\"? %d %d\\n\",x,y);\n\tfflush(stdout);\n\tint ret;\n\tread(ret);\n\treturn ret;\n}\n \nint main(){\n\tread(n),read(m);\n\tL[0]=1;\n\trep(i,1,n){\n\t\tL[i]=L[i-1];\n\t\tint ini=qry(i,L[i]);\n\t\tint mn=ini;\n\t\tfor(int j=L[i]+1;j<=m;j++){\n\t\t\tint now=qry(i,j);\n\t\t\tif(i>=2&&i<=n-1&&now>=ini) break;\n\t\t\tif(now\n#include \nstruct box\n\t{int x,y;}a[1000000],start;\ndouble dist(int u,int v)\n{\n\treturn sqrt((a[u].x-a[v].x)*(a[u].x-a[v].x)+(a[u].y-a[v].y)*(a[u].y-a[v].y));\n}\nint comp(const void *p,const void *q)\n{\n\treturn (*(struct box*)p).x - (*(struct box*)q).x;\n}\nint main()\n{\n\tdouble ans=-1; int i,n,k;\n\t//freopen(\"input.txt\",\"r\",stdin);\n\tscanf(\"%d%d\",&n,&k);\n\tfor(i=1;i<=n;i++)\n\t\tscanf(\"%d\",&a[i].x);\n\tscanf(\"%d%d\",&a[n+1].x,&a[n+1].y);\n\tstart = a[k];\n\tqsort(a+1,n,sizeof(a[0]),comp);\n\tfor(i=1;i<=n;i++)\n\t\tif(a[i].x == start.x && a[i].y == start.y) k = i;\n\tfor(i=1;i<=k;i++)\n\t{\n\t\tdouble tmp = dist(k,n)+dist(n,i)+dist(i,n+1);\n\t\tif(i>1) tmp += dist(n+1,i-1)+dist(i-1,1);\n\t\tif(ans==-1 || tmp < ans) ans = tmp;\n\t\ttmp = dist(k,i)+dist(i,n)+dist(n,n+1);\n\t\tif(i>1) tmp += dist(n+1,i-1)+dist(i-1,1);\n\t\tif(ans==-1 || tmp < ans) ans = tmp;\n\t}\n\tif(k == n+1)\n\t{\n\t\tdouble tmp = dist(n+1,n)+dist(n,1);\n\t\tif(ans==-1 || tmp\nusing namespace std;\n\nconst int maxn = 100009;\ndouble a[maxn], cur, x, y, res;\nint n, K;\n\ndouble dist(double x, double y) {\n\treturn sqrt(x*x + y*y);\n}\n\nint main() {\n\tscanf(\"%d%d\", &n, &K);\n\tfor (int i=1; i<=n; i++) scanf(\"%lf\", &a[i]);\n\tcur = a[K]; sort(a+1, a+n+1);\n\tscanf(\"%lf%lf\", &x, &y);\n\tif (K == n+1) {\n\t\tprintf(\"%.20lf\\n\", min(dist(x-a[1], y), dist(x-a[n], y)) + a[n] - a[1]);\n\t\treturn 0;\n\t}\n\tfor (int i=1; i<=n; i++) if (fabs(a[i] - cur) < 1e-6) { K = i; break; }\n\tres = a[n] - a[K] + dist(a[n]-x, y) + min(dist(x-a[1], y), dist(x-a[K-1], y)) + a[K-1] - a[1];\n\tres = min(res, a[K] - a[1] + dist(a[1]-x, y) + min(dist(x-a[K+1], y), dist(x-a[n], y)) + a[n] - a[K+1]);\n\tfor (int i=1; i<=n; i++) {\n\t\tres = min(res, \tmin(fabs(a[K] - a[i]) + fabs(a[i] - a[n]) + dist(a[n]-x, y),\n\t\t\t\t\t\t\tfabs(a[K] - a[n]) + fabs(a[i] - a[n]) + dist(a[i]-x, y),\n\t\t\t\t\t\tmin(dist(a[i-1]-x, y), dist(a[1]-x, y)) + fabs(a[i-1] - a[1]));\n\t\tres = min(res, \tmin(fabs(a[K] - a[i]) + fabs(a[i] - a[1]) + dist(a[1]-x, y),\n\t\t\t\t\t\t\tfabs(a[K] - a[1]) + fabs(a[i] - a[1]) + dist(a[i]-x, y),\n\t\t\t\t\t\tmin(dist(a[i+1]-x, y), dist(a[n]-x, y)) + fabs(a[i+1] - a[n]));\n\t}\n\tprintf(\"%.20lf\\n\", res);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "02a956bf9bda0af07b8bb985aac6077e", "src_uid": "f9ed5faca211e654d9d4e0a7557616f4", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "//D\n#include \nusing namespace std;\n\n#define N 100011\n#define min(a, b) ((a) < (b) ? (a) : (b))\n#define max(a, b) ((a) > (b) ? (a) : (b))\n\nstruct dat{\n int x, y, id;\n dat(int x = 0, int y = 0, int id = 0) : x(x), y(y), id(id){}\n}p[N];\n\nbool cmp(dat a, dat b) {\n return a.x < b.x;\n}\n\ndouble dist(dat a, dat b) {\n return sqrt(1.0 * (a.x - b.x) * (a.x - b.x) + 1.0 * (a.y - b.y) * (a.y - b.y));\n}\n\nint n, k;\ndouble tot[N];\n\nint main(){\n //freopen(\"d.in\", \"r\", stdin);\n scanf(\"%d %d\", &n, &k);\n for(int i = 1; i <= n + 1; i ++) scanf(\"%d\", &p[i].x);\n scanf(\"%d\", &p[n + 1].y);\n for(int i = 1; i <= n + 1; i ++) p[i].id = i;\n\n sort(p + 1, p + n + 1, cmp);\n for(int i = 1; i <= n + 1; i ++) if(p[i].id == k) {k = i; break;}\n\n if(n == 1) {printf(\"%lf\\n\", dist(p[1], p[2])); return 0;}\n\n tot[1] = 0;\n for(int i = 2; i < n + 1; i ++) tot[i] = tot[i - 1] + dist(p[i - 1], p[i]);\n\n if(k == n + 1){\n double ans = min(dist(p[n + 1], p[1]), dist(p[n + 1], p[n])) + tot[n]);\n for(int i = 1; i < n; i ++){\n double r = tot[n] - dist(p[i], p[i + 1]) + dist(p[n + 1], p[1]) + dist(p[n + 1], p[i]) + min(dist(p[n + 1], p[i + 1]), dist(p[n + 1], p[n]));\n ans = min(ans, r);\n r = tot[n] - dist(p[i], p[i + 1]) + dist(p[n + 1], p[n]) + dist(p[n + 1], p[i + 1]) + min(dist(p[n + 1], p[i]), dist(p[n + 1], p[1]));\n ans = min(ans, r);\n }\n printf(\"%lf\\n\", ans);\n }\n\n else if(k == 1 || k == n){\n double ans = dist(p[n + 1 - k], p[n + 1]) + tot[n];\n for(int i = 1; i < n; i ++) ans = min(ans, tot[n] - dist(p[i], p[i + 1]) + dist(p[n + 1], p[i]) + dist(p[n + 1], p[i + 1]));\n printf(\"%lf\\n\", ans);\n }\n\n else {\n double ans = dist(p[n + 1], p[k]) + tot[n] + min(dist(p[n + 1], p[1]), dist(p[n + 1], p[n]));\n ans = min(ans, tot[n] - dist(p[k], p[k + 1]) + dist(p[n + 1], p[1]) + min(dist(p[k + 1], p[n + 1]), dist(p[n], p[n + 1])));\n ans = min(ans, tot[n] - dist(p[k], p[k - 1]) + dist(p[n + 1], p[n]) + min(dist(p[k - 1], p[n + 1]), dist(p[1], p[n + 1])));\n printf(\"%lf\\n\", ans);\n }\n ///return 9;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1b08fc622eea82edfbebd5499f47bcbb", "src_uid": "f9ed5faca211e654d9d4e0a7557616f4", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\nstruct pos\n{\n\tchar t\n int x, y;\n pos(int x, int y, int nr)\n {\n this->x=x;\n this->y=y;\n t='B';\n }\n bool operator<(pos b) const\n {\n return nr>b.nr;\n }\n};\nstruct stack_dsu\n{\n\tvector par, sz;\n\tvector> act;\n\n\tvoid init(int n)\n\t{\n\t\tpar.resize(n+1);\n\t\tsz.resize(n+1);\n\n\t\tfor(int i=1;i<=n;i++)\n\t\t{\n\t\t\tpar[i]=i;\n\t\t\tsz[i]=1;\n\t\t}\n\t}\n\tint fpar(int x)\n\t{\n\t\tif(par[x]==x)\n\t\t\treturn x;\n\t\treturn fpar(par[x]);\n\t}\n\tvoid fmerge(int x, int y)\n\t{\n\t\tx=fpar(x);\n\t\ty=fpar(y);\n\n\t\tif(x!=y)\n\t\t{\n\t\t\tif(sz[x]>sz[y])\n\t\t\t\tswap(x, y);\n\n\t\t\tpar[x]=y;\n\t\t\tsz[y]+=sz[x];\n\t\t}\n\n\t\tact.push_back({x, y});\n\t}\n\tvoid pop()\n\t{\n\t\tif(act.empty())\n\t\t\treturn;\n\n\t\tint x=act.back().first;\n\t\tint y=act.back().second;\n\t\tact.pop_back();\n\n\t\tif(x==y)\n\t\t\treturn;\n\n\t\tpar[x]=x;\n\t\tsz[y]-=sz[x];\n\t}\n};\nstruct queue_dsu\n{\n\tint bottom;\n\tvector act;\n\tstack_dsu s;\n\n\tvoid init(int n)\n\t{\n\t\ts.init(n);\n\t}\n\tvoid fmerge(int x, int y)\n\t{\n\t\tnr++;\n\t\tact.push_back(pos(x, y, nr));\n\t\ts.fmerge(x, y);\n\t}\n\t\n\tvoid move_bottom()\n\t{\n\t\twhile(bottom>n;\n\tdsu.init(n);\n\twhile(true)\n\t{\n\t\tcin>>t;\n\t\tif(t==1)\n\t\t{\n\t\t\tcin>>x>>y;\n\t\t\tdsu.fmerge(x, y);\n\t\t}\n\t\tif(t==2)\n\t\t\tdsu.spop();\n\t\tif(t==3)\n\t\t{\n\t\t\tcin>>x;\n\t\t\tcout<>n>>q>>k;\n\tdsu.init(n);\n\tday=1;\n\twhile(q)\n\t{\n\t\tq--;\n\t\tcin>>t;\n\t\tif(t==1)\n\t\t{\n\t\t\tcin>>x>>y;\n\t\t\tdsu.fmerge(x, y);\n\t\t\tnr[day+k]++;\n\t\t}\n\t\tif(t==2)\n\t\t{\n\t\t\tcin>>x;\n\t\t\tcout<\n\n\nusing namespace std;\n\nstruct DSU_WITH_ROLLBACKS\n{\n struct dsu_save\n {\n int u, urank, v, vrank, comps;\n bool bipart;\n };\n\n stack op;\n\n vector rnk;\n vector col;\n bool bipartite;\n int comps;\n\n DSU_WITH_ROLLBACKS()\n {\n\n }\n\n DSU_WITH_ROLLBACKS(int N)\n {\n init(N);\n }\n\n void init(int N)\n {\n rnk.clear();\n col.clear();\n while(!op.empty())op.pop();\n rnk.resize(N);\n col.resize(N);\n for(int i = 0 ; i < N ; i++)\n {\n rnk[i] = 1;\n col[i] = false;\n }\n bipartite = true;\n comps = N;\n }\n\n pair find(int x)\n {\n if(rnk[x] > 0)\n{\npair tp = {x, col[x]};\nreturn tp;\n}\n pair tp = find(-rnk[x]);\n tp.second ^= col[x];\n return tp;\n }\n\n void join(int a, int b)\n {\n pair ta = find(a);\ntb = find(b);\n a = ta.first;\n b = tb.first;\n op.push({a, rnk[a], b, rnk[b], comps, bipartite});\n if(a == b)\n {\n if(ta.second == tb.second)bipartite = false;\n return;\n }\n comps--;\n if(rnk[a] < rnk[b])swap(a,b);\n rnk[a] += rnk[b];\n rnk[b] = -a;\n col[b] = col[b]^(ta.second == tb.second);\n }\n\n void rollback()\n {\n if(op.empty())return;\n dsu_save x = op.top();\n op.pop();\n comps = x.comps;\n bipartite = x.bipart;\n rnk[x.u] = x.urank;\n col[x.u] = false;\n rnk[x.v] = x.vrank;\n col[x.v] = false;\n }\n};\n\nconst int MAXN = 1e6 + 100;\n\nvector arr[MAXN];\n\nvector res;\n\ntemplate\nstruct ROLLBACK_TRICK\n{\n vector> ST;\n int N;\n\n void add_to_tree(int nodo, int l, int r, int a, int b, T qu)\n {\n if(r < a || l > b)return;\n if(a <= l && r <= b)\n {\n ST[nodo].push_back(qu);\n return;\n }\n int mid = (l+r)/2;\n add_to_tree(nodo*2, l, mid, a, b, qu);\n add_to_tree(nodo*2+1, mid+1, r, a, b, qu);\n }\n\n void add_query(T qu, int l, int r)\n {\n add_to_tree(1, 0, N-1, l, r, qu);\n }\n\n void dfs(int nodo, int l, int r, D &DS)\n {\n for(auto x : ST[nodo])DS.join(x.first, x.second);\n if(l == r)\n {\n \tfor(auto x : arr[l])\n \t{\n \t\tres.push_back(DS.rnk[DS.find(x).first]);\n \t}\n }\n else\n {\n int mid = (l+r)/2;\n dfs(nodo*2, l, mid, DS);\n dfs(nodo*2+1, mid+1, r, DS);\n }\n for(int i = 0 ; i < ST[nodo].size() ; i++)DS.rollback();\n }\n\n void solve(int tn, vector vect, vector> querys, D &DS)\n {\n assert(vect.size() == querys.size());\n\n N = tn;\n\n ST.clear();\n ST.resize(4*(N+4));\n\n for(int i = 0 ; i < vect.size() ; i++)\n {\n add_query(vect[i], querys[i].first, querys[i].second);\n }\n\n dfs(1, 0, N-1, DS);\n }\n};\n\nint32_t main()\n{\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n\n int N, Q, K;\n cin >> N >> Q >> K;\n\n DSU_WITH_ROLLBACKS DSU(MAXN);\n\n vector> qu;\n\n vector> vect;\n\n deque,int>>> D;\n\n vector,int>> temp;\n\n int cont = 0;\n\n for(int i = 1 ; i <= Q ; i++)\n {\n \tint tp;\n \tcin >> tp;\n\n \tif(tp == 1)\n \t{\n \t\tint a, b;\n \t\tcin >> a >> b;\n \t\ttemp.push_back({{a,b},cont});\n \t}\n \tif(tp == 2)\n \t{\n \t\tint q;\n \t\tcin >> q;\n \t\tarr[cont].push_back(q);\n \t\tcont++;\n \t}\n \tif(tp == 3)\n \t{\n \t\tD.push_back(temp);\n \t\ttemp.clear();\n\n \t\tif(D.size() == K)\n \t\t{\n \t\t\tfor(auto x : D.front())\n \t\t\t{\n \t\t\t\tqu.push_back({x.second,cont});\n \t\t\t\tvect.push_back({x.first.first,x.first.second});\n \t\t\t}\n \t\t\tD.pop_front();\n \t\t}\n \t\tcont++;\n \t}\n }\n\n while(D.size())\n {\n \tfor(auto x : D.front())\n\t\t{\n\t\t\tqu.push_back({x.second,cont});\n\t\t\tvect.push_back({x.first.first,x.first.second});\n\t\t}\n\t\tD.pop_front();\n }\n\n cont++;\n\n ROLLBACK_TRICK, int, DSU_WITH_ROLLBACKS> RT;\n\n RT.solve(cont+100, vect, qu, DSU);\n\n for(auto x : res)\n {\n \tcout << x << '\\n';\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c5801326e0e7ca6edc7840378bb5bf62", "src_uid": "417788298ec54dd5fd7616ab8c5ce246", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n\nusing namespace __gnu_pbds; \nusing namespace std;\n\n// #define int long long\n#define S second\n#define F first\n#define pb push_back\n#define all(c) (c).begin(),(c).end()\n#define rall(c) (c).rbegin(),(c).rend() \n#define lb lower_bound\n#define ub upper_bound\n#define si(c) (int)((c).size())\n#define lcm(a, b) (a * (b / __gcd(a,b))) \n#define inf (int)(4e18)\n#define endl '\\n'\n#define mp make_pair\n#define time(s) (double(clock()-s)/double(CLOCKS_PER_SEC))\n#define debug(args...) _F(#args, args)\n#define vi std::vector\n#define pii pair \n#define vpi vector\n#define ordered_set tree, rb_tree_tag,tree_order_statistics_node_update> \n\nclock_t start;\nmt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());\n\ntemplate void _F(const char *name, T arg1){ cerr << name << \" = \" << arg1 << endl;}\ntemplate void _F(const char *names, T arg1, Args... args)\n{ const char *name = strchr(names, ',');cerr.write(names, name-names) << \" = \" << arg1 << endl;_F(name+2, args...);}\n\ntemplate< typename T1, typename T2 > istream& operator>>(istream& in, pair &q){ in >> q.F >> q.S; return in;}\ntemplate< typename T1, typename T2 > ostream& operator<<(ostream& out, pair &q){ out << q.F << \" \" << q.S; return out;}\ntemplate< typename T1, typename T2 > pair operator+(pair p1, pair p2){ return {p1.F+p2.F, p1.S+p2.S};}\ntemplate< typename T1, typename T2 > pair operator-(pair p1, pair p2){ return {p1.F-p2.F, p1.S-p2.S};}\ntemplate< typename T1, typename T2 > bool operator<(pair p1, pair p2){ return p1 < p2 ;}\n\ntemplate void Unique(vector &v) {\n sort(all(v)), vseprateize(distance(v.begin(), unique(all(v))));\n}\n\nstruct Dsu {\n\tint comps, n;\n\tstd::vector par, unused;\n\tstd::vector > siz;\n\n\tDsu(int _n) {\n\t\tn = _n;\n\t\tparseprateize(n+1), sizseprateize(n+1);\n\t\tunusedseprateize(n+1);\n\t\tfor(int i = 0; i <= n; i++)\n\t\t\tpar[i] = i, siz[i].insert(i);\n\t\tcomps = n;\n\t}\n\tvoid merge(int x, int y, vi seprate) {\n\t\tx = par[x], y = par[y];\n\t\tif(x == y) return;\n\t\tif(si(siz[y]) > si(siz[x])) swap(x, y);\n\t\tfor(auto u : siz[y])\n\t\tseprate.pb(u), par[u] = x, siz[x].insert(u);\n\t\tcomps--;\n\t}\n};\n\nvoid solve() {\n\tint n, q, k;\n\tcin >> n >> q >> k;\n\n\tDsu ds(n+q+10);\n\tvi seprate[q+1];\n\tmultiset > s;\n\tvi que[q+1];\n\tint cur = 1;\n\tint root = n+1;\n\tfor(int i = 1; i <= q; i++) {\n\t\tint t;\n\t\tcin >> t;\n\t\tif(t == 1) {\n\t\t\tint x, y;\n\t\t\tcin >> x >> y;\n\t\t\tds.merge(x, y, seprate[i]);\n\t\t\tque[cur].pb(i);\n\t\t\tif(si(seprate[i]) == 0) {\n\t\t\t\ts.insert(mp(mp(cur, i), mp(x, y)));\n\t\t\t}\n\t\t}\n\t\telse if(t == 2) {\n\t\t\tint x;\n\t\t\tcin >> x;\n\t\t\tcout << si(ds.siz[ds.par[x]]) << endl;\n\t\t}\n\t\telse if(cur >= k){\n\t\t\twhile(si(s) && begin(s)->F.F <= cur-k+1) {\n\t\t\t\ts.erase(begin(s));\n\t\t\t}\n\t\t\tfor(auto u : que[cur-k+1]) {\n\t\t\t\tfor(auto uu :seprate[u]) {\n\t\t\t\t\tds.siz[ds.par[uu]].erase(uu);\n\t\t\t\t\tds.par[uu] = root;\n\t\t\t\t\tds.siz[root].insert(uu);\n\t\t\t\t}\n\t\t\t\tds.siz[root].erase(root);\n\t\t\t\troot++;\n\t\t\t}\n\t\t\tset > tmp;\n\t\t\tfor(auto u : s) {\n\t\t\t\tds.merge(u.S.S, u.S.F, seprate[u.F.S]);\n\t\t\t\tif(si(seprate[u.F.S]) == 0) {\n\t\t\t\t\ttmp.insert(u);\n\t\t\t\t}\n\t\t\t}\n\t\t\ts = tmp;\n\t\t\tcur++;\n\t\t}\n\t\telse cur++;\n\t}\n}\n\nsigned main(){\n\n ios_base::sync_with_stdio(0); \n cin.tie(0); cout.tie(0); \n start = clock(); \n\n #ifndef ONLINE_JUDGE\n freopen(\"input.txt\", \"r\", stdin); \n freopen(\"output.txt\", \"w\", stdout);\n freopen(\"error.txt\", \"w\", stderr);\n #endif\n\n int test = 1;\n // cin >> test;\n \n cout << fixed << setprecision(20);\n \n for(int i = 1; i <= test; ++i){\n \tsolve();\n }\n\n cerr << time(start);\n return 0;\n}\n\n\t", "lang_cluster": "C++", "compilation_error": true, "code_uid": "96d776819a40f4634aef03a429d1d1af", "src_uid": "417788298ec54dd5fd7616ab8c5ce246", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize(2);\n#include \nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\nconst int MAXN = 1e6 + 10;\nconst int INF = 1e9;\nstruct LCT {\n struct node {\n int fa, ch[2]; //\u7236\u4eb2(Splay\u5bf9\u5e94\u7684\u94fe\u5411\u4e0a\u7531\u8f7b\u8fb9\u8fde\u7740\u54ea\u4e2a\u8282\u70b9)\u3001\u5de6\u53f3\u513f\u5b50\n int reverse;//\u533a\u95f4\u53cd\u8f6c\u6807\u8bb0\n bool is_root; //\u662f\u5426\u662f\u6240\u5728Splay\u7684\u6839\n int sz; //\u8282\u70b9\u6570\u91cf\n int vsz; //\u865a\u5b50\u6811\u8282\u70b9\u6570\u91cf\n ll val; //\u70b9\u6743\n ll sum; //\u539f\u6811\u4fe1\u606f\u548c\n ll vsum; //\u865a\u5b50\u6811\u4fe1\u606f\u548c\n int id;\n ll minv;\n //ll maxv; //\u6700\u503c\n } Tree[MAXN];\n int n;\n\n void init(int MN) {\n n = MN;\n for (int i = 1; i <= MN; i++) {\n Tree[i].reverse = Tree[i].fa = Tree[i].ch[0] = Tree[i].ch[1] = 0;\n Tree[i].is_root = true;\n Tree[i].val = INF;\n Tree[i].sz = 1;\n Tree[i].id = i;\n }\n }\n\n bool getson(int x) {\n //x\u662f\u5426\u4e3a\u91cd\u513f\u5b50\n return x == Tree[Tree[x].fa].ch[1];\n }\n bool isroot(int x) {\n return Tree[Tree[x].fa].ch[0] != x && Tree[Tree[x].fa].ch[1] != x;\n }\n void pushreverse(int x) {\n if (!x)\n return;\n swap(Tree[x].ch[0], Tree[x].ch[1]);\n //swap(Tree[x].lcol, Tree[x].rcol); //\u6709\u4e9b\u989c\u8272\u95ee\u9898\u8981\u7ffb\u8f6c\u5de6\u53f3\u989c\u8272\n Tree[x].reverse ^= 1;\n }\n void pushdown(int x) { //\u4e0d\u540c\u95ee\u9898\u7684\u6807\u8bb0\u4e0b\u63a8\u65b9\u5f0f\u4e0d\u540c\n //\u4e0b\u4f20\u53cd\u8f6c\u6807\u8bb0\n if (Tree[x].reverse) {\n pushreverse(Tree[x].ch[0]);\n pushreverse(Tree[x].ch[1]);\n Tree[x].reverse = 0;\n }\n }\n\n void update(int x) { //\u4e0d\u540c\u95ee\u9898\u5199\u6cd5\u4e0d\u540c\n int l = Tree[x].ch[0], r = Tree[x].ch[1];\n Tree[x].sz = 1 + Tree[x].vsz;\n Tree[x].sum = Tree[x].val + Tree[x].vsum;\n Tree[x].minv = Tree[x].val;\n Tree[x].id = x;\n if (l) {\n Tree[x].sz += Tree[l].sz;\n Tree[x].sum += Tree[l].sum;\n if (Tree[l].minv < Tree[x].minv) {\n Tree[x].minv = Tree[l].minv;\n Tree[x].id = Tree[l].id;\n }\n //Tree[x].maxv = max(Tree[x].maxv, Tree[l].maxv);\n }\n if (r) {\n Tree[x].sz += Tree[r].sz;\n Tree[x].sum += Tree[r].sum;\n if (Tree[r].minv < Tree[x].minv) {\n Tree[x].minv = Tree[r].minv;\n Tree[x].id = Tree[r].id;\n }\n //Tree[x].maxv = max(Tree[x].maxv, Tree[r].maxv);\n }\n }\n\n void rotate(int x) {\n //\u5c06x\u65cb\u8f6c\u4e3a\u6839\n if (Tree[x].is_root)\n return;\n int k = getson(x), fa = Tree[x].fa;\n int fafa = Tree[fa].fa;\n pushdown(fa);\n pushdown(x); //\u5148\u8981\u4e0b\u4f20\u6807\u8bb0\n Tree[fa].ch[k] = Tree[x].ch[k ^ 1];\n if (Tree[x].ch[k ^ 1])\n Tree[Tree[x].ch[k ^ 1]].fa = fa;\n Tree[x].ch[k ^ 1] = fa;\n Tree[fa].fa = x;\n Tree[x].fa = fafa;\n if (!Tree[fa].is_root)\n Tree[fafa].ch[fa == Tree[fafa].ch[1]] = x;\n else\n Tree[x].is_root = true, Tree[fa].is_root = false;\n update(fa);\n update(x); //\u5982\u679c\u7ef4\u62a4\u4e86\u4fe1\u606f\uff0c\u5c31\u8981\u66f4\u65b0\u8282\u70b9\n }\n void push(int x) {\n if (!Tree[x].is_root)\n push(Tree[x].fa);\n pushdown(x);\n }\n int findroot(int x) {\n //\u627e\u5230x\u5728\u539f\u6811\u4e2d\u7684\u6839\u8282\u70b9\n access(x);\n Splay(x);\n pushdown(x);\n while (Tree[x].ch[0])\n pushdown(x = Tree[x].ch[0]);//\u627e\u5230\u6df1\u5ea6\u6700\u5c0f\u7684\u70b9\u5373\u4e3a\u6839\u8282\u70b9\n return x;\n }\n void Splay(int x) {\n //\u8ba9x\u6210\u4e3aSplay\u7684\u6839\uff0c\u4e14x\u4e0d\u542b\u53f3\u513f\u5b50\n push(x); //\u5728Splay\u5230\u6839\u4e4b\u524d\uff0c\u5fc5\u987b\u5148\u4f20\u5b8c\u53cd\u8f6c\u6807\u8bb0\n for (int fa; !Tree[x].is_root; rotate(x)) {\n if (!Tree[fa = Tree[x].fa].is_root) {\n rotate((getson(x) == getson(fa)) ? fa : x);\n }\n }\n }\n void access(int x) {\n //\u8bbf\u95ee\u67d0\u8282\u70b9\u3002\u4f5c\u7528\u662f\uff1a\u5bf9\u4e8e\u8bbf\u95ee\u7684\u8282\u70b9x\uff0c\u6253\u901a\u4e00\u6761\u4ece\u6811\u6839\uff08\u771f\u5b9e\u7684LCT\u6811\uff09\u5230x\u7684\u91cd\u94fe\uff1b\u5982\u679cx\u5f80\u4e0b\u662f\u91cd\u94fe\uff0c\u90a3\u4e48\u628ax\u5f80\u4e0b\u7684\u91cd\u8fb9\u6539\u6210\u8f7b\u8fb9\u3002\u7ed3\u675f\u540ex\u6ca1\u6709\u53f3\u513f\u5b50\uff08\u6ca1\u6709\u6df1\u5ea6\u6bd4\u4ed6\u5927\u7684\u70b9\uff09\n int y = 0;\n do {\n Splay(x);\n Tree[Tree[x].ch[1]].is_root = true;\n Tree[x].vsum += Tree[Tree[x].ch[1]].sum;\n Tree[x].vsz += Tree[Tree[x].ch[1]].sz;\n Tree[Tree[x].ch[1] = y].is_root = false;\n Tree[x].vsum -= Tree[Tree[x].ch[1]].sum;\n Tree[x].vsz -= Tree[Tree[x].ch[1]].sz;\n update(x); //\u5982\u679c\u7ef4\u62a4\u4e86\u4fe1\u606f\u8bb0\u5f97\u66f4\u65b0\u3002\n x = Tree[y = x].fa;\n } while (x);\n }\n void mroot(int x) {\n //\u628a\u67d0\u4e2a\u8282\u70b9\u53d8\u6210\u6811\u6839\uff08\u8fd9\u91cc\u7684\u6839\u6307\u7684\u662f\u6574\u68f5LCT\u7684\u6839\uff09\n access(x);//\u4f7fx\u4e0e\u6839\u7ed3\u70b9\u5904\u5728\u540c\u4e00\u68f5splay\u4e2d\n Splay(x);//x\u6210\u4e3a\u8fd9\u68f5splay\u7684\u6839,x\u53ea\u6709\u5de6\u513f\u5b50\n //\u7531\u4e8e\u6839\u8282\u70b9\u6240\u5728\u7684splay\u4e2d\uff0c\u6839\u8282\u70b9\u6ca1\u6709\u5de6\u513f\u5b50\uff08\u6ca1\u6709\u6df1\u5ea6\u6bd4\u4ed6\u5c0f\u7684\u8282\u70b9\uff09\uff0c\u5c06x\u7684\u5de6\u53f3\u5b50\u6811\u7ffb\u8f6c\n pushreverse(x);\n }\n void link(int u, int v) {\n //\u8fde\u63a5u\u6240\u5728\u7684LCT\u548cv\u6240\u5728\u7684LCT\n mroot(u);//\u5148\u8ba9u\u6210\u4e3a\u5176\u6240\u5728LCT\u7684\u6839\n if(findroot(v) != u) {\n Tree[u].fa = v;//\u5982\u679cu\u4e0ev\u4e0d\u5728\u540c\u4e00\u68f5splay\u4e2d\uff0c\u5c31\u628av\u8bbe\u7f6e\u4e3au\u7684\u7236\u4eb2\n Tree[v].vsum += Tree[u].sum;\n Tree[v].vsz += Tree[u].sz;\n update(v);\n }\n\n }\n void cut(int u, int v) {\n //\u5206\u79bb\u51fa\u4e24\u68f5LCT\n mroot(u); //\u5148\u8ba9u\u6210\u4e3a\u5176\u6240\u5728LCT\u7684\u6839\n access(v); //\u8ba9u\u548cv\u5728\u540c\u4e00\u68f5Splay\u4e2d\n Splay(v); //\u8fde\u63a5u\u3001v\uff0cu\u662fv\u7684\u5de6\u513f\u5b50\n pushdown(v); //\u5148\u4e0b\u4f20\u6807\u8bb0\n if (Tree[v].ch[0]) {\n Tree[Tree[v].ch[0]].fa = Tree[v].fa;\n Tree[Tree[v].ch[0]].is_root = true;\n }\n Tree[v].fa = 0;\n Tree[v].ch[0] = 0;\n //v\u7684\u5de6\u5b69\u5b50\u8868\u793av\u4e0a\u65b9\u76f8\u8fde\u7684\u91cd\u94fe\n update(v); //\u8bb0\u5f97\u7ef4\u62a4\u4fe1\u606f\n }\n bool judge(int u, int v) {\n //\u5224\u65adu\u548cv\u662f\u5426\u8fde\u901a\n while (Tree[u].fa)\n u = Tree[u].fa;\n while (Tree[v].fa)\n v = Tree[v].fa;\n return u == v;\n }\n void split(int u, int v) {\n //\u83b7\u53d6u->v\u7684\u8def\u5f84\n mroot(u);//\u8ba9u\u6210\u4e3a\u6839\u7ed3\u70b9\n access(v);//\u8bbf\u95eev\n Splay(v);//\u628av\u8f6c\u5230\u6839\u7ed3\u70b9\uff0c\u6b64\u65f6u\u7684\u7236\u4eb2\u4e3av\n }\n void modify(int x, int v) {\n //\u6539\u53d8\u70b9\u503c\n access(x);\n Splay(x);\n Tree[x].val = v; //\u66f4\u6539\u503c\n update(x);\n }\n} lct;\nint getroot(int x) {\n ll lsum = 0, rsum = 0, lnow = 0, rnow = 0;\n int son = lct.Tree[x].sz/2, flag = lct.Tree[x].sz&1, root = lct.n + 1;\n while (x) {\n lct.pushdown(x);\n int l = lct.Tree[x].ch[0], r = lct.Tree[x].ch[1];\n lnow = lsum + lct.Tree[l].sz;\n rnow = rsum + lct.Tree[r].sz;\n if (lnow <= son && rnow <= son) {\n if (flag) { //\u5947\u6570\u4e2a\u70b9\uff0c\u91cd\u5fc3\u53ea\u6709\u4e00\u4e2a\n root = x;\n break;\n } else { //\u627e\u7f16\u53f7\u5c0f\u7684\u91cd\u5fc3\n root = min(root, x);\n }\n }\n if (lnow < rnow) { //\u53f3\u8fb9\u5927\uff0c\u5f80\u53f3\u627e\u91cd\u5fc3\n lsum += lct.Tree[l].sz + lct.Tree[x].vsz + 1;\n x = r;\n } else { //\u5de6\u8fb9\u5927\uff0c\u5f80\u5de6\u627e\u91cd\u5fc3\n rsum += lct.Tree[r].sz + lct.Tree[x].vsz + 1;\n x = l;\n }\n }\n lct.Splay(root);\n return root;\n}\nvoid debug() {\n for (int i = 1; i <= 5; i++) {\n lct.mroot(i);\n cout << \"i sz:\" << i << \" \" << lct.Tree[i].sz < que;\nint main() {\n int n, q, k;\n scanf(\"%d%d%d\", &n, &q, &k);\n lct.n = n;\n lct.init(n + q);\n int now = 1;\n for (int i = 1; i <= q; i++) {\n while (!que.empty()) {\n auto cur = que.front();\n //cout << \"cur:\" << cur.id << \" \" << cur.day << endl;\n if (cur.day < now - k + 1) {\n lct.cut(u[cur.id], cur.id + n);\n lct.cut(v[cur.id], cur.id + n);\n que.pop();\n } else {\n break;\n }\n }\n int op;\n scanf(\"%d\", &op);\n if (op == 1) {\n scanf(\"%d%d\", &u[i], &v[i]);\n que.push({now, i});\n if (lct.judge(u[i], v[i])) {\n //cout << \"judge yes\\n\";\n lct.split(u[i], v[i]);\n int num = lct.Tree[v[i]].id;\n //cout << \"num:\" << num << endl;\n lct.cut(num, u[num - n]);\n lct.cut(num, v[num - n]);\n }\n lct.Tree[i + n].val = now;\n lct.link(u[i], i + n);\n lct.link(v[i], i + n);\n } else if (op == 2) {\n int x;\n scanf(\"%d\", &x);\n lct.mroot(x);\n printf(\"%d\\n\", lct.Tree[x].sz / 2 + 1);\n } else {\n now++;\n }\n //debug();\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "791d595cf75fd77b8e5897e8ddfc463c", "src_uid": "417788298ec54dd5fd7616ab8c5ce246", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "/*input\n3 3\n1 2\n2 3\n1 3\n\n*/\n \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \nusing namespace std;\n \nint N, M;\nusing ll = long long;\nconst int BUCKET = 30000001, MOD = 9835731;\nll E[18], rE[18], W[18], X, Y;\nstruct State { ll state = 0, ways = 0, total = 0; int nxt = -1; } list[BUCKET];\nint ptr = MOD;\n\t\nstring toString(ll x)\n{\n\tstring str = \"\";\n\tfor (int i = 0; i < 40; ++i) {\n\t\tstr += '0' + (x & 1);\n\t\tx >>= 1;\n\t}\n\treturn str;\n}\n\nState& get(int st)\n{\n\tint id = st % MOD;\n\twhile (true) {\n\t\tif (list[id].state == st) return list[id];\n\t\tif (list[id].nxt < 0) break;\n\t\tid = list[id].nxt;\n\t}\n\tlist[id].nxt = ptr;\n\tlist[ptr].state = st;\n\treturn list[ptr++];\n}\n \nint main()\n{\n\tios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n\tcin >> N >> M;\n\tfor (int i = 0; i < M; ++i) {\n\t\tint u, v; cin >> u >> v;\n\t\t--u, --v;\n\t\tE[u] ^= (1 << v);\n\t\tE[v] ^= (1 << u);\n\t\tW[v] ^= (1 << u);\n\t}\n\tX = (1 << N) - 1, Y = X << N;\n\tfor (int u = 0; u < N; ++u) rE[u] = E[u] ^ X;\n \n\tget(0).ways = 1;\n\tqueue qu; qu.push(0);\n\twhile (!qu.empty()) {\n\t\tauto a = get(qu.front());\n\t\t// cout << toString(qu.front()) << \": \" << a.first << ' ' << a.second << endl;\n\t\tfor (int u = 0; u < N; ++u) {\n\t\t\tll state = qu.front();\n\t\t\tif ((state >> (N + u)) & 1) continue;\n \n\t\t\tll unreachable_deg0 = state & rE[u];\n\t\t\tif ((unreachable_deg0 & (-unreachable_deg0)) && (unreachable_deg0 & (-unreachable_deg0)) < (1 << u)) continue;\n \n\t\t\tstate = (state & Y) ^ (1ll << (N + u)) ^ unreachable_deg0 ^ (1 << u);\n \n\t\t\tauto &p = get(state);\n\t\t\tif (p.ways == 0) qu.push(state);\n\t\t\tp.ways += a.ways;\n\t\t\tp.total += a.total + a.ways * __builtin_popcountll(W[u] & (state >> N));\n\t\t\t// cout << \" -> \" << toString(state) << endl;\n\t\t}\n\t\tqu.pop();\n\t}\n \n\tll ans = 0;\n\tfor (int i = 0; i < ptr; ++i) {\n\t\tif ((list[i].state >> N) != X) continue;\n\t\tans += list[i].total;\n\t}\n\tcout << ans % 998244353 << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a09aa70f9f24a368b73df155b37c7af0", "src_uid": "ed962f0ef1a1a92cdaeee06c508f8c10", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\u00a0\nint n, m;\nint d[1024][46];\nint a[10][10];\n\u00a0\nbool ind[1024];\n\u00a0\nbool isind(int w) {\nfor (int i=0; i> n >> m;\n\u00a0\nfor (int i=0; i> x >> y;\nx--, y--;\na[x][y] = 1;\na[y][x] = 2;\n}\n\u00a0\nfor (int w=0; w<(1<\nconst int mo=998244353,S=27e4;\nint g[21][S],h[S][21],f[S][21],n,m,i,j,a,b,z,cnt[S],val[21],inv[21],ans,C[21][21];\nbool bb[21][21];\ninline void FMT(int*a){for(int i=2,j,k,m;i<=1<>1;j<1<>1]+(i&1);for(i=2,inv[1]=1;i>a&1)for(b=0;b>b&1) && bb[a+1][b+1];\n\t\tif(!z)g[cnt[i]][i]=1;\n\t}\n\tfor(i=0;i<=n;++i)for(FMT(g[i]),j=0;j<1<>31&mo)if((n-cnt[j])&1)val[i]-=h[j][n];else val[i]+=h[j][n]-mo;\n\t\tfor(j=0;j<1<\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\n\n#define FOR(i,a) for (int i=0;i<(a);++i)\n#define FORD(i,a) for (int i=(a)-1;i>=0;i--)\n#define FORT(i,a,b) for (int i=(a);i<=(b);++i)\n#define FORTD(i,b,a) for (int i=(b);i>=(a);--i)\n#define trav(i,v) for (auto i : v)\n#define all(v) v.begin(),v.end()\n#define ad push_back\n#define fr first\n#define sc second\n#define mpr(a,b) make_pair(a,b)\n#define pir pair\n#define all(v) v.begin(),v.end()\n#define make_unique(v) v.erase(unique(all(v)),v.end())\n#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n#define srng mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())\n#define y1 EsiHancagorcRepa\n\nconst int N=20,P=(1< g[N],hg[N];\nint ans[P],qan[P],kox[P][N],ppc[P],tv[P];\nint vrj[P];\nbool bad2[P],bad[P];\n\nvoid gum(int &a,int b){\n a+=b;\n if (a>=MOD)a-=MOD;\n}\n\nvoid han(int &a,int b){\n a-=b;\n if (a<0)a+=MOD;\n}\n\n\nint main(){\n fastio;\n srng;\n int n,m;\n cin>>n>>m;\n FOR(i,m){\n int a,b;\n cin>>a>>b;\n a--;\n b--;\n g[a].ad(b);\n hg[b].ad(a);\n } 3\n FOR(msk,(1<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define LOG(v) for (auto e : v) cerr << e << \" \"; cerr << endl;\n\ntypedef long long i64;\n\nusing namespace std;\ni64 a, b, n;\n\ni64 solve(i64 l, i64 r) {\n if (n / l == n / r) {\n i64 ac = (n + l - 1) / l;\n if (a % ac == 0 && b % (ac-1) <= b / (ac - 1)) {\n return r - l + 1;\n } else if (a % ac < a / ac && b % (ac - 1) <= b / (ac - 1)) {\n return r - l + 1;\n } else {\n return 0ll;\n }\n } else {\n i64 mid = (r + l) / 2;\n return solve(l, mid) +\n solve(mid + 1, r);\n }\n}\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL); srand(123);\n\n while (cin >> a >> b) {\n n = a + b;\n if (b > a) {\n swap(a, b);\n }\n\n int ans = 1;\n for (i64 l = 1, r; l < n; l = r) {\n r = n / (n / l) + 1;\n i64 c = n / l;\n ans += max(0, min(r, a / c + b / c + 1) - max(l, (b + c) / (c + 1) + (a + c) / (c + 1)));\n }\n\n // int ans = 0;\n // for (int k = 1; k <= n; k++) {\n // int c = (n + n - 1) / k;\n // // cerr << c << endl;\n // if (a % c == 0 && b % (c-1) <= b / (c - 1)) {\n // ans++;\n // } else if (a % c < a / c && b % (c - 1) <= b / (c - 1)) {\n // ans++;\n // }\n // }\n // int ans = solve(1, n - 1) + 1;\n cout << ans << endl;\n }\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "09cbd2e5288da54ccccaac742755dbe2", "src_uid": "0e6a204565fef118ea99d2fa1e378dd0", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include\ntypedef int LL;\nLL a,b,ans;\nint main(){\n scanf(\"%d%d\",&a,&b);\n LL len=a+b;\n for(LL i=1,r;i<=len;i=r+1){\n LL P=len/i; // P \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u046d\ufffd\ufffd\ufffd\ufffd\n r=len/P; // \u036c\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\uece4\u046d\ufffd\ufffd\ufffd\u06b3\ufffd\ufffd\ufffd\n if(P>a || P>b) continue;\n LL a_low=(a+P)/(P+1),a_high=a/P;\n LL b_low=(b+P)/(P+1),b_high=b/P;\n if(a_low<=a && b_low<=b)\n ans+=min((a_high+b_high),r)-max((a_low+b_low),i)+1;\n }\n printf(\"%d \",ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e80d62510f8136c46940b34efebac78c", "src_uid": "0e6a204565fef118ea99d2fa1e378dd0", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize(\"Ofast\")\n#pragma GCC target(\"avx,avx2,fma\")\n#pragma GCC optimization (\"unroll-loops\")\n#include \nusing namespace std;\n \nusing ll = long long;\nusing pii = pair;\n \n#define pb push_back\n#define mp make_pair\n#define eb emplace_back\n#define all(x) (x).begin(),(x).end()\n#define x first\n#define y second\n \nconst int MOD = 1e9 + 7;\n//const int MOD = 998244353;\nconst int dx[] = {0, 0, 1, -1};\nconst int dy[] = {1, -1, 0, 0}; \nconst char dir[] = {'R', 'L', 'D', 'U'};\n \nll add(ll a, ll b){ //(a + b) % 1e9 + 7\n a += b;\n if(a >= MOD){\n a -= MOD;\n }\n return a;\n}\n \nint sub(int a, int b){\n a -= b;\n if(a < 0) a += MOD;\n return a;\n}\n \nint mult(int a, int b){\n return ((ll) a * b) % MOD;\n}\n \nvoid setIO() {\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n// freopen((s+\".in\").c_str(),\"r\",stdin);\n// freopen((s+\".text\").c_str(),\"w\",stdout);\n}\n\nint main(){\n setIO();\n int a, b; cin >> a >> b;\n int tot = a + b;\n for(int i = 1, next; i <= n; i = next){\n int groups = n / i;\n int next = n / groups + 1;\n int alo = (a + groups) / (groups + 1);\n int ahi = a / groups;\n int blo = (b + groups) / (groups + 1);\n int bhi = b / groups;\n if(alo > ahi || blo > bhi) continue;\n ans += max(0, min(next - 1, ahi + bhi) - max(i, alo + blo) + 1);\n }\n cout << ans << \"\\n\";\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8b45b8677fcfb3e188591232936dc968", "src_uid": "0e6a204565fef118ea99d2fa1e378dd0", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nchar bd[6][8];\nvoid print(int x, int y){\n\tbd[x][y] = 'P';\n\tfor(int i = 0; i < 6; i++){\n\t\tfor(int j = 0; j < 8; j++){\n\t\t\tcout << bd[i][j];\n\t\t}\n\t\tcout << endl;\n\t}\n\texit(0);\n}\nvoid go(int x, int y){\n\tif(bd[x][y] == '.') print(x, y);\n\treturn;\n}\nint main() {\n\t// your code goes here\n\tfor(int i = 0; i < 6; i++){\n\t\tscanf(\"%s\", bd[i]);\n\t}\n\t//4\n\tgo(0, 3);\n\tgo(0, 4);\n\tgo(1, 3);\n\tgo(1, 4);\n\t\n\t//3\n\tgo(0, 0); go(0, 1); go(0, 6); go(0, 7);\n\tgo(1, 0); go(1, 1); go(1, 6); go(1, 7);\n\tgo(2, 3);\n\tgo(2, 4);\n\tgo(3, 3);\n\tgo(3, 4);\n\t\n\t//2\n\tgo(2, 0); go(2, 1); go(2, 6); go(2, 7);\n\tgo(3, 0); go(3, 1); go(3, 6); go(3, 7);\n\tgo(4, 3);\n\tgo(5, 4);\n\tgo(4, 3);\n\tgo(5, 4);\n\t\n\t//1\n\tgo(4, 0); go(4, 1); go(4, 6); go(4, 7);\n\tgo(5, 0); go(5, 1); go(5, 6); go(5, 7);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3bf1284fd74bc9c9896c3ef9e955f74e", "src_uid": "35503a2aeb18c8c1b3eda9de2c6ce33e", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "// Example program\n#include \n#include \n\nint main()\n{\n ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);\n for(int i=1; i<=6; i++)\n cin >> s[i];\n if(s[1][0]=='.' || s[1][1]=='.')\n m=max(m,3);\n if(s[1][3]=='.' || s[1][4]=='.')\n m=max(m,4);\n if(s[1][6]=='.' || s[1][7]=='.')\n m=max(m,3); \n if(s[2][0]=='.' || s[2][1]=='.')\n m=max(m,3);\n if(s[2][3]=='.' || s[2][4]=='.')\n m=max(m,4);\n if(s[2][6]=='.' || s[2][7]=='.')\n m=max(m,3); \n if(s[3][0]=='.' || s[3][1]=='.')\n m=max(m,2);\n if(s[3][3]=='.' || s[3][4]=='.')\n m=max(m,3);\n if(s[3][6]=='.' || s[3][7]=='.')\n m=max(m,2);\n if(s[4][0]=='.' || s[4][1]=='.')\n m=max(m,2);\n if(s[4][3]=='.' || s[4][4]=='.')\n m=max(m,3);\n if(s[4][6]=='.' || s[4][7]=='.')\n m=max(m,2);\n if(s[5][0]=='.' || s[5][1]=='.')\n m=max(m,1);\n if(s[5][3]=='.' || s[5][4]=='.')\n m=max(m,2);\n if(s[5][6]=='.' || s[5][7]=='.')\n m=max(m,1);\n if(s[6][0]=='.' || s[6][1]=='.')\n m=max(m,1);\n if(s[6][3]=='.' || s[6][4]=='.')\n m=max(m,2);\n if(s[6][6]=='.' || s[6][7]=='.')\n m=max(m,1); \n cout << m;\n \n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c948f7dd77666f9fce0dbd639db2963b", "src_uid": "35503a2aeb18c8c1b3eda9de2c6ce33e", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "/*input\n\n*/\n\n#include \n\nusing namespace std;\n\nint val[6][8] = {{3, 3, 0, 4, 4, 0, 3, 3},\n\t\t\t {3, 3, 0, 4, 4, 0, 3, 3}\n\t\t\t {2, 2, 0, 3, 3, 0, 2, 2}\n\t\t\t {2, 2, 0, 3, 3, 0, 2, 2}\n\t\t\t {1, 1, 0, 2, 2, 0, 1, 1}\n\t\t\t {1, 1, 0, 2, 2, 0, 1, 1}};\n\nchar a[6][9];\nint main() {\n\tfor (int i = 0; i < 6; i++) scanf(\"%s\", a[i]);\n\n\tint mx = 0;\n\tfor (int i = 0; i < 6; i++) \n\t\tfor (int j = 0; j < 8; j++) if (a[i][j] == '.') mx = max(mx, val[i][j]);\n\n\tfor (int i = 0; i < 6; i++) {\n\t\tfor (int j = 0; j < 8; j++) putchar((a[i][j] == '.' && val[i][j] == mx)? 'P' : a[i][j]);\n\t\tputchar('\\n');\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "87d4bc2299357585b3ab0c9447cbd110", "src_uid": "35503a2aeb18c8c1b3eda9de2c6ce33e", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "sd", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0c6301bdf5cf68d7650ea8f126b67102", "src_uid": "35503a2aeb18c8c1b3eda9de2c6ce33e", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "/* electric love #jdragon\r\n\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u28e0\u2824\u2816\u281a\u2889\u28e9\u28ed\u286d\u281b\u2813\u2832\u2826\u28c4\u2840\u2800\u2800\u2800\u2800\u2800\u2800\u2800\r\n\u2800\u2800\u2800\u2800\u2800\u2800\u2880\u2874\u280b\u2801\u2800\u2800\u280a\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2809\u2833\u28a6\u2840\u2800\u2800\u2800\u2800\r\n\u2800\u2800\u2800\u2800\u2880\u2874\u2803\u2880\u2874\u28b3\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2819\u28c6\u2800\u2800\u2800\r\n\u2800\u2800\u2800\u2800\u287e\u2801\u28e0\u280b\u2800\u2808\u28a7\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2808\u28a7\u2800\u2800\r\n\u2800\u2800\u2800\u28f8\u2801\u28b0\u2803\u2800\u2800\u2800\u2808\u28a3\u2840\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2808\u28c7\u2800\r\n\u2800\u2800\u2800\u2847\u2800\u287e\u2840\u2800\u2800\u2800\u2800\u28c0\u28f9\u28c6\u2840\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u28b9\u2800\r\n\u2800\u2800\u28b8\u2803\u2880\u28c7\u2848\u2800\u2800\u2800\u2800\u2800\u2800\u2880\u2851\u2884\u2840\u2880\u2840\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u28b8\u2847\r\n\u2800\u2800\u28b8\u2800\u28bb\u285f\u287b\u28b6\u2846\u2800\u2800\u2800\u2800\u287c\u281f\u2873\u28bf\u28e6\u2851\u2884\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u28b8\u2847\r\n\u2800\u2800\u28f8\u2800\u28b8\u2803\u2847\u2880\u2807\u2800\u2800\u2800\u2800\u2800\u287c\u2800\u2800\u2808\u28ff\u2857\u2802\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u28b8\u2801\r\n\u2800\u2800\u284f\u2800\u28fc\u2800\u28b3\u280a\u2800\u2800\u2800\u2800\u2800\u2800\u2831\u28c0\u28c0\u2814\u28f8\u2801\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u28a0\u285f\u2800\r\n\u2800\u2800\u2847\u2880\u2847\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2820\u2800\u2847\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u28b8\u2803\u2800\r\n\u2800\u28b8\u2803\u2818\u2847\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u28b8\u2801\u2800\u2800\u2880\u2800\u2800\u2800\u2800\u2800\u28fe\u2800\u2800\r\n\u2800\u28f8\u2800\u2800\u2839\u2844\u2800\u2800\u2808\u2801\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u285e\u2800\u2800\u2800\u2838\u2800\u2800\u2800\u2800\u2800\u2847\u2800\u2800\r\n\u2800\u284f\u2800\u2800\u2800\u2819\u28c6\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2880\u28e0\u28b6\u2847\u2800\u2800\u28b0\u2840\u2800\u2800\u2800\u2800\u2800\u2847\u2800\u2800\r\n\u28b0\u2807\u2844\u2800\u2800\u2800\u287f\u28a3\u28c0\u28c0\u28c0\u2864\u2834\u285e\u2809\u2800\u28b8\u2800\u2800\u2800\u28ff\u2847\u2800\u2800\u2800\u2800\u2800\u28e7\u2800\u2800\r\n\u28f8\u2800\u2847\u2800\u2800\u2800\u2800\u2800\u2800\u2809\u2800\u2800\u2800\u28b9\u2800\u2800\u28b8\u2800\u2800\u2880\u28ff\u2807\u2800\u2800\u2800\u2801\u2800\u28b8\u2800\u2800\r\n\u28ff\u2800\u2847\u2800\u2800\u2800\u2800\u2800\u2880\u2864\u2824\u2836\u2836\u283e\u2824\u2804\u28b8\u2800\u2840\u2838\u28ff\u28c0\u2800\u2800\u2800\u2800\u2800\u2808\u28c7\u2800\r\n\u2847\u2800\u2847\u2800\u2800\u2840\u2800\u2874\u280b\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2838\u284c\u28f5\u2840\u28b3\u2847\u2800\u2800\u2800\u2800\u2800\u2800\u28b9\u2840\r\n\u2847\u2800\u2807\u2800\u2800\u2847\u2878\u2801\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2819\u282e\u28a7\u28c0\u28fb\u2882\u2800\u2800\u2800\u2800\u2800\u2800\u28a7\r\n\u28c7\u2800\u28a0\u2800\u2800\u28b3\u2807\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2808\u284e\u28c6\u2800\u2800\u2800\u2800\u2800\u2818\r\n\u28bb\u2800\u2808\u2830\u2800\u28b8\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2830\u2818\u28ae\u28e7\u2840\u2800\u2800\u2800\u2800\r\n\u2838\u2846\u2800\u2800\u2807\u28fe\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u28a0\u2806\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2819\u2833\u28c4\u2840\u28a2\u2840\r\n oregairu */ \r\n#include \"bits/stdc++.h\"\r\nusing namespace std;\r\n#define ll long long\r\n#define fl i,a,b for(int i=a;i>\r\n#define rep(i,x,n) for(int i = x; i < n; i++) \r\n#define rev(i,n,x) for(int i = n; i >= x; i--)\r\n#define ff first\r\n#define ss second\r\n#define vecll vector\r\n#define pii pair\r\n#define pip pair>\r\n#define ppp pair,pair>\r\n#define inarr(arr,x,n) for(ll i=x ;i> arr[i];\r\n#define mpp make_pair\r\n#define pb push_back\r\n#define ppb pop_back\r\n#define all(x) (x).begin(),(x).end()\r\n#define sz(x) (x).size()\r\n#define henshin cout<> m;\r\n int cnt = 0;\r\n set s;\r\n while(n) {\r\n s.insert(n % m);\r\n cnt++;\r\n n /= m;\r\n }\r\n if(s.size() == cnt) cout << \"YES\\n\";\r\n else cout << \"NO\\n\";\r\n return 0;\r\n }\r\n \r\nint main() {\r\n#ifdef _DEBUG\r\n freopen(\"input.txt\", \"r\", stdin);\r\n int tt = clock();\r\n#endif\r\n ios_base::sync_with_stdio(false);\r\n cin.tie(0), cout.tie(0);\r\n cout << fixed << setprecision(15);\r\n \r\n int tc=1; \r\n \r\n while(tc--) { \r\n solve(); \r\n \r\n#ifdef _DEBUG\r\n cerr << \"TIME = \" << clock() - tt << endl;\r\n tt = clock();\r\n#endif\r\n }\r\n return 0;\r\n}\r\n\r\n\r\n\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "80764b8603c348bb276d2d9b8fbdd71b", "src_uid": "a8945bb1082fefe70e6898a8bec1ce3f", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include\r\nusing namespace std;\r\n#define int long long\r\n\r\ninline int read(){\r\n\tint x=0,f=1;\r\n\tchar ch=getchar();\r\n\twhile(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar();}\r\n\twhile(ch>='0' && ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar();\r\n\treturn x*f;\r\n}\r\ninline void write(int x){\r\n\tif(x<0) {putchar('-'); x=-x;}\r\n\tif(x>9) write(x/10);\r\n\tputchar(x%10+'0');\r\n}\r\nint h[1009],n,m;\r\nint main(){\r\n\tn=read(); m=read();\r\n\twhile(n){\r\n\t\tif(h[n%m]){\r\n\t\t\tputs(\"NO\");\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t\th[n%m]=1;\r\n\t\tn/=m;\r\n\t}\r\n\tputs(\"YES\");\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a08d92e1cc7ae1d30e358fcfffa6be08", "src_uid": "a8945bb1082fefe70e6898a8bec1ce3f", "difficulty": 1800.0} {"lang": "GNU C++17", "source_code": "#include\r\nusing namespace std;\r\nint main(){\r\n\tlong long a,b;\r\n\tlong long s;\r\n\tcin>>a>>b;\r\n\tlong long cnt=0;\r\n\twhile(a){\r\n\t\tcnt++;\r\n\t\ts.insert(a%b);\r\n\t\ta/=b;\r\n\t}\t\r\n\tif(cnt==s.size()) cout<<\"YES\";\r\n\telse cout<<\"NO\";\r\n} ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4ade1d02142c1553a5f6f4d3f7ba71ce", "src_uid": "a8945bb1082fefe70e6898a8bec1ce3f", "difficulty": 1800.0} {"lang": "GNU C++17", "source_code": "#include\r\nusing namespace std;\r\n#define ll long long;\r\nll n,m,c;\r\nset s;\r\nint main(){\r\n\tcin>>n>>m;\r\n\twhile (n) s.insert(n % m),n /= m,c += 1;\r\n\tcout<<(c == s.size() ? \"YES\" : \"NO\")<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef bool boolean;\n\n#define pii pair\n#define fi first\n#define sc second\n\nconst int N = 5e5 + 5;\n\nint n, m;\nvector< pii > *g;\nvector< vector > cir;\nint cis[N], maxl[N], L[N], Z[N];\nboolean vis[N], ib[N];\t// is it a bridge\n\ninline void init() {\n\tscanf(\"%d%d\", &n, &m);\n\tg = new vector[(n + 1)];\n\tfor (int i = 1, u, v; i <= m; i++) {\n\t\tscanf(\"%d%d\", &u, &v);\n\t\tg[u].push_back(pii(v, i));\n\t\tg[v].push_back(pii(u, i));\n\t}\n}\n\nint ts = 0;\nint dfn[N], low[N];\nvoid tarjan(int p, int fa) {\n\tdfn[p] = low[p] = ++ts;\n\tfor (auto e : g[p]) {\n\t\tif (e.fi == fa)\tcontinue;\n\t\tif (!dfn[e.fi]) {\n\t\t\ttarjan(e.fi, p);\n\t\t\tlow[p] = min(low[p], low[e.fi]);\n\t\t\tif (low[e.fi] == dfn[e.fi])\n\t\t\t\tib[e.sc] = true;\n\t\t} else\n\t\t\tlow[p] = min(low[p], dfn[e.fi]);\n\t}\n}\n\nint cnt = 0; \nvoid dfs(int p) {\n\tcnt++;\n\tassert(cnt <= n);\n\tvis[p] = true;\n\tcir.back().push_back(p);\n\tcis[p] = (signed) cir.size() - 1;\n\tfor (auto e : g[p])\n\t\tif (!vis[e.fi] && !ib[e.sc])\n\t\t\tdfs(e.fi);\n}\n\nqueue que;\nvoid bfs(int s) {\n\tint tp = 0;\n\tint *tr = new int[(n + 1)];\n\tint *par = new int[(n + 1)];\n\tque.push(s);\n\tmemset(vis, false, sizeof(vis));\n\ttr[++tp] = s, par[s] = 0, vis[s] = true;\n\twhile (!que.empty()) {\n\t\tint e = que.front();\n\t\tque.pop();\n\t\tfor (auto eu : g[e]) {\n\t\t\tif (vis[eu.fi])\tcontinue;\n\t\t\tvis[eu.fi] = true;\n\t\t\ttr[++tp] = eu.fi, par[eu.fi] = e;\n\t\t\tassert(eu.fi != s);\n\t\t\tque.push(eu.fi);\n\t\t}\n\t}\n\t\n\tfor (int i = n; i > 1; i--) {\n\t\tint p = tr[i];\n\t\tfor (auto e : g[p]) {\n\t\t\tif (e.fi == par[p]) {\n\t\t\t\tmaxl[e.fi] = max(maxl[e.fi], maxl[p] + 1);\n\t\t\t\tif (ib[e.sc])\n\t\t\t\t\tL[e.fi] = max(L[e.fi], maxl[p] + 1);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tdelete[] tr;\n\tdelete[] par;\n}\n\nint ql, qr;\npii ar[N];\nvoid deal(int p, int fa, int upval) {\n\tL[p] = max(L[p], upval);\n\tvector &circ = cir[cis[p]];\n\tint k = (signed) circ.size(), lim = k >> 1;\n\tfor (int it = 0; it < 2; it++) {\n\t\tql = 1, qr = 0;\n\t\tfor (int i = 0, e; i < 2 * k; i++) {\n\t\t\te = circ[i % k];\n\t\t\twhile (ql <= qr && i - ar[ql].sc > lim)\n\t\t\t\tql++;\n\t\t\tif (ql <= qr)\n\t\t\t\tZ[e] = max(Z[e], i + ar[ql].fi);\n\t\t\twhile (ql <= qr && ar[qr].fi <= L[e] - i)\n\t\t\t\tqr--;\n\t\t\tar[++qr] = pii(L[e] - i, i);\n\t\t}\n\t\treverse(circ.begin(), circ.end());\n\t}\n\t\n\tfor (auto u : circ) {\n\t\tint fiv = 0, scv = 0;\n\t\tfor (auto e : g[u])\n\t\t\tif (e.fi != fa && ib[e.sc]) {\n\t\t\t\tif (maxl[e.fi] + 1 > fiv)\n\t\t\t\t\tscv = maxl[e.fi] + 1, swap(scv, fiv);\n\t\t\t\telse if (maxl[e.fi] + 1 > scv)\n\t\t\t\t\tscv = maxl[e.fi] + 1;\n\t\t\t}\n\n\t\tfor (auto e : g[u])\n\t\t\tif (e.fi != fa && ib[e.sc]) {\n\t\t\t\tint pv = max(Z[u], upval), val = maxl[e.fi] + 1;\n\t\t\t\tif (val == fiv)\n\t\t\t\t\tpv = max(pv, scv);\n\t\t\t\telse\n\t\t\t\t\tpv = max(pv, fiv);\n\t\t\t\tdeal(e.fi, u, pv + 1);\n\t\t\t}\t\n\t}\n}\n\ninline void solve() {\n\ttarjan(1, 0);\n\tfor (int i = 1; i <= n; i++)\n\t\tif (!vis[i]) {\n\t\t\tcir.push_back(vector());\n\t\t\tdfs(i);\n\t\t}\n\tbfs(1);\n\tdeal(1, 0, 0);\n\tfor (int i = 1; i <= n; i++)\n\t\tprintf(\"%d \", max(L[i], Z[i]));\n}\n\nint main() {\n\tinit();\n\tsolve();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8a96e978a61f15447b65c1b2323a2cde", "src_uid": "c980495a264a6314f45c230daf19c2e0", "difficulty": 2900.0} {"lang": "GNU C++17", "source_code": "#include\n#define N 1000050\nusing namespace std;\nint he[N>>1],ne[N<<1],to[N<<1],tot;\nint n,m,ds;\nconst int inf=1e9;\ninline void addedge(int x,int y){\n\tto[++tot]=y;ne[tot]=he[x];he[x]=tot;\n}\nvectorv[N],ve[N];\nint dfn[N>>1],low[N>>1],cnt,st[N>>1],tp;\ninline void tarjan(int g){\n\tdfn[g]=low[g]=++cnt;st[++tp]=g;\n\tfor(int i=he[g];i;i=ne[i]){\n\t\tif(dfn[to[i]])low[g]=min(low[g],dfn[to[i]]);\n\t\telse{\n\t\t\ttarjan(to[i]);\n\t\t\tlow[g]=min(low[g],low[to[i]]);\n\t\t\tif(low[to[i]]==dfn[g]){\n\t\t\t\t++ds;v[g].push_back(ds);\n\t\t\t\twhile(1){\n\t\t\t\t\tint t=st[tp--];\n\t\t\t\t\tv[ds].push_back(t);\n\t\t\t\t\tif(t==to[i])break;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\nint len[N],a[N];\ninline void dfs(int g){\n\tlen[g]=g<=n?1:0;\n\tfor(int i=0,to;in){\n\t\ta[sz]=0;\n\t\tfor(int i=sz-1;~i;--i)a[i]=max(len[v[g][i]]+sz-1-i,a[i+1]);\n\t\tlen[g]=a[0];\n\t\tfor(int i=0,ma=0;i>1;\n\tbuild(g<<1,l,m);\n\tbuild(g<<1|1,m+1,r);\n\tma1[g]=max(ma1[g<<1],ma1[g<<1|1]);\n\tma2[g]=max(ma2[g<<1],ma2[g<<1|1]);\n}\ninline int ask1(int g,int l,int r,int x,int y){\n\tif(l>y||r=x&&r<=y)return ma1[g];\n\tconst int m=l+r>>1;\n\tint r1=ask1(g<<1,l,m,x,y),r2=ask1(g<<1|1,m+1,r,x,y);\n\treturn max(r1,r2);\n}\ninline int ask2(int g,int l,int r,int x,int y){\n\tif(l>y||r=x&&r<=y)return ma2[g];\n\tconst int m=l+r>>1;\n\tint r1=ask2(g<<1,l,m,x,y),r2=ask2(g<<1|1,m+1,r,x,y);\n\treturn max(r1,r2);\n}\n\ninline int getans(int id,int L,int R,int ma){\n\tint l=L,r=R;\n\twhile(l+1>1;\n\t\tif(ask2(1,1,ma,L,mid)-L<=ask1(1,1,ma,mid+1,R)+R)l=mid;\n\t\telse r=mid;\n\t}\n\tint l1=ask2(1,1,ma,L,l)-L,l2=ask1(1,1,ma,l+1,R)+R;l1=max(l1,l2);\n\tint r1=ask2(1,1,ma,L,r)-L,r2=ask1(1,1,ma,r+1,R)+R;r1=max(r1,r2);\n\treturn min(l1,r1);\n}\nint sz,ma;\ninline void dfs2(int g,int fa){\n\tans[g]=len[g]-1;\n\tsz=v[g].size();\n\tif(!sz)return;\n\tve[g].resize(sz);\n\tif(g<=n){\n\t\ta[sz]=0;\n\t\tfor(int i=sz-1;~i;--i)a[i]=max(len[v[g][i]]+1,a[i+1]);\n\t\tfor(int i=0,ma=0;imasize)masize=v[i].size();\n\tdfs(rt);\n\tdfs2(rt,0);\n\tstatic int an2[N];\n\tfor(int i=1;i<=n;++i)an2[i]=ans[i];\n\tfor(int i=1;i<=n;++i)printf(\"%d \",an2[i]);puts(\"\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4c9dac3a70350aa977a4a729037f2599", "src_uid": "c980495a264a6314f45c230daf19c2e0", "difficulty": 2900.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nconst int N=500005,M=N*4;\nstruct Gragh{\n\t//2M*2*4B+0.5M*4B=18MB\n\tint cnt,y[M],nxt[M],fst[N];\n\tvoid clear(){\n\t\tcnt=1;\n\t\tmemset(fst,0,sizeof fst);\n\t}\n\tvoid add(int a,int b){\n\t\ty[++cnt]=b,nxt[cnt]=fst[a],fst[a]=cnt;\n\t}\n}g,g2;\nint n,m;\nint dfn[N],low[N],inst[N],st[N],vis[N],id[N],Time,top,tot;\nint used[M];\nint Fa[N];\nvector cir[N],son[N];\nvoid Tarjan_Prepare(){\n\tTime=top=tot=0;\n\tmemset(id,0,sizeof id);\n\tmemset(st,0,sizeof st);\n\tmemset(dfn,0,sizeof dfn);\n\tmemset(low,0,sizeof low);\n\tmemset(vis,0,sizeof vis);\n\tmemset(inst,0,sizeof inst);\n\tmemset(used,0,sizeof used);\n}\nvoid Tarjan(int x){\n\tdfn[x]=low[x]=++Time;\n\tvis[x]=inst[x]=1;\n\tst[++top]=x;\n\tfor (int i=g.fst[x];i;i=g.nxt[i]){\n\t\tif (used[i/2])\n\t\t\tcontinue;\n\t\tused[i/2]=1;\n\t\tif (!vis[g.y[i]){\n\t\t\tTarjan(g.y[i]);\n\t\t\tlow[x]=min(low[x],low[g.y[i]]);\n\t\t}\n\t\telse if (inst[g.y[i]])\n\t\t\tlow[x]=min(low[x],low[g.y[i]]);\n\t}\n\tif (dfn[x]==low[x]){\n\t\ttot++;\n\t\tid[st[top]]=tot;\n\t\tinst[st[top]]=0;\n\t\twhile (st[top--]!=x){\n\t\t\tid[st[top]]=tot;\n\t\t\tinst[st[top]]=0;\n\t\t}\n\t}\n}\nvoid Get_cir(int x){\n\tif (vis[x])\n\t\treturn;\n\tvis[x]=1;\n\tcir[id[x]].push_back(x);\n\tfor (int i=g.fst[x];i;i=g.nxt[i]){\n\t\tint y=g.y[i];\n\t\tif (id[y]!=id[x])\n\t\t\tdfs(y);\n\t}\n}\nvoid build(int x,int pre){\n\tint ID=id[x];\n\tFa[ID]=pre;\n\tcir[ID].clear();\n\tGet_cir(x);\n\tfor (int i=0;i\n#pragma comment(linker, \"/STACK:102400000,102400000\") \nusing namespace std;\nconst int N=500005,M=N*4;\nstruct Gragh{\n\t//2M*2*4B+0.5M*4B=18MB\n\tint cnt,y[M],nxt[M],fst[N];\n\tvoid clear(){\n\t\tcnt=1;\n\t\tmemset(fst,0,sizeof fst);\n\t}\n\tvoid add(int a,int b){\n\t\ty[++cnt]=b,nxt[cnt]=fst[a],fst[a]=cnt;\n\t}\n}g,g2;\nint n,m;\nint dfn[N],low[N],inst[N],st[N],vis[N],id[N],Time,top,tot;\nint used[M];\nint Fa[N];\nvector cir[N],son[N];\nvoid Tarjan_Prepare(){\n\tTime=top=tot=0;\n\tmemset(id,0,sizeof id);\n\tmemset(st,0,sizeof st);\n\tmemset(dfn,0,sizeof dfn);\n\tmemset(low,0,sizeof low);\n\tmemset(vis,0,sizeof vis);\n\tmemset(inst,0,sizeof inst);\n\tmemset(used,0,sizeof used);\n}\nvoid Tarjan(int x){\n\tdfn[x]=low[x]=++Time;\n\tvis[x]=inst[x]=1;\n\tst[++top]=x;\n\tfor (int i=g.fst[x];i;i=g.nxt[i]){\n\t\tif (used[i/2])\n\t\t\tcontinue;\n\t\tused[i/2]=1;\n\t\tif (!vis[g.y[i]]){\n\t\t\tTarjan(g.y[i]);\n\t\t\tlow[x]=min(low[x],low[g.y[i]]);\n\t\t}\n\t\telse if (inst[g.y[i]])\n\t\t\tlow[x]=min(low[x],low[g.y[i]]);\n\t}\n\tif (dfn[x]==low[x]){\n\t\ttot++;\n\t\tid[st[top]]=tot;\n\t\tinst[st[top]]=0;\n\t\twhile (st[top--]!=x){\n\t\t\tid[st[top]]=tot;\n\t\t\tinst[st[top]]=0;\n\t\t}\n\t}\n}\nvoid Get_cir(int x){\n\tif (vis[x])\n\t\treturn;\n\tvis[x]=1;\n\tcir[id[x]].push_back(x);\n\tfor (int i=g.fst[x];i;i=g.nxt[i]){\n\t\tint y=g.y[i];\n\t\tif (id[y]==id[x])\n\t\t\tGet_cir(y);\n\t}\n}\nvoid build(int x,int pre){\n\tint ID=id[x];\n\tFa[ID]=pre;\n\tcir[ID].clear();\n\tGet_cir(x);\n\tfor (int i=0;i=1;i--)\n\t\tRmax[i]=max(Rmax[i+1],Deep[cir[ID][i]]+(n-i+1));\n\tint v=1e9;\n\tfor (int i=1;i<=n+1;i++)\n\t\tv=min(v,max(Lmax[i-1],Rmax[i]));\n\tusDeep[x]=Deep[x];\n\tDeep[x]=max(Deep[x],spDeep[x]=v);\n}\nint Far[N];\n// The Minimum value of the distance between \n// x and the farthest vetrex which isn't a posterity of x \n// \u73af\u6839\uff1a \u7531\u5176\u7236\u4eb2\u7ee7\u627f \n// \u975e\u73af\u6839\uff1a \u73af\u5185\u5355\u8c03\u961f\u5217\u8dd1\u51fa\u6765 \nint val[N*3];\nint Lv[N*3],Rv[N*3];\nstruct Monotone_Queue{\n\tint head,tail,q[N*3],d[N*3],hehe;\n\tvoid clear(){\n\t\thead=1,tail=0;\n\t\thehe=0;\n\t}\n\tint front(){\n\t\treturn head<=tail?q[head]:0;\n\t}\n\tvoid push(int v,int _d){\n\t\twhile (head<=tail&&q[tail]<=v)\n\t\t\ttail--;\n\t\tq[++tail]=v,d[tail]=_d;\n\t}\n\tvoid pop(int _d){\n\t\twhile (head<=tail&&d[head]<_d)\n\t\t\thead++;\n\t}\n\tint Next_front(int _d){\n\t\tif (head>tail)\n\t\t\treturn 0;\n\t\tif (d[head]!=_d)\n\t\t\treturn q[head];\n\t\treturn head==tail?0:q[head+1];\n\t}\n\tvoid print(){\n\t\tprintf(\"size=%d, sit=:\",tail-head+1);\n\t\tfor (int i=head;i<=tail;i++)\n\t\t\tprintf(\"(%d,%d) \",q[i],d[i]);\n\t\tputs(\"\");\n\t}\n}QL,QR;\nvector LRmax[N];\nvoid Solve(int x,int far){\n\tint ID=id[x];\n\tFar[x]=far;\n\tint n=cir[ID].size();\n\tfor (int i=1;i%d %d(%d) %d(%d)\\n\",val[i],Lv[i],n*3-i,Rv[i],i+1);\n\t\t*/\n\tQL.clear(),QR.clear();\n\tint Lp=2,Rp=n+1;\n\tfor (int i=Lp;i<=n;i++)\n\t\tQL.push(Lv[i],i);\n\tfor (int i=n+1;imax(QR.front(),Rv[Rp+1])-v2){\n\t\t\tresult=min(result,QL.front()-v1);\n\t\t\tLp++,QL.pop(Lp);\n\t\t\tRp++,QR.push(Rv[Rp],Rp);\n\t\t}\n//\t\tprintf(\"x=%d,i=%d,Q=..(L,R)\\n\",x,i);QL.print(),QR.print();\n\t\tresult=min(result,QL.front()-v1);\n\t\tresult=min(result,max(QR.front(),Rv[Rp+1])-v2);\n\t\tQL.push(Lv[i],i);\n\t\tQR.pop(i+1);\n\t\tFar[cir[ID][i%n]]=result;\n\t}\n\tfor (int i=0;i=1;j--)\n\t\t\tRmax[j]=max(Rmax[j+1],Deep[son[u][j-1]]+1);\n/*\t\tprintf(\"u=%d,son=:\",u);\n\t\tfor (int j=0;j\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define y0 sdkfaslhagaklsldk\n#define y1 aasdfasdfasdf\n#define yn askfhwqriuperikldjk\n#define j1 assdgsdgasghsf\n#define tm sdfjahlfasfh\n#define lr asgasgash\n\n#define INF 100000000\n#define eps 1e-11\n//#define M_PI 3.141592653589793\n//#define mx 1000000000000ll\n#define bs 1000000007\n#define bsize 256\n\nusing namespace std;\n\nlong long n,k,a,b,need;\nvector > v;\nvector v1,v2;\nlong long ans,alost,rem,todel,cost;\n\nint main(){\n//freopen(\"melman.in\",\"r\",stdin);\n//freopen(\"melman.out\",\"w\",stdout);\n//freopen(\"C:/input.txt\",\"r\",stdin);\n//freopen(\"C:/output.txt\",\"w\",stdout);\nios_base::sync_with_stdio(0);\ncin.tie(0);\n\ncin>>n>>k;\nfor (int i=1;i<=n;i++)\n{\n cin>>a>>b;\n v.push_back(make_pair(a,b));\n}\n\nsort(v.begin(),v.end());\nreverse(v.begin(),v.end());\n\nneed=v[k-1].first;\n\nans=1e18;\n\nfor (int score=need;score<=need+10;score++)\n{\n alost=0;\n if (score>n)continue;\n for (int p=0;pscore){alost++;}\n rem=k-alost-1;\n if(rem<0)continue;\n v1.clear();\n v2.clear();\n for (int i=0;iscore||v[i].firstrem)\n {\n todel=v2.size()-rem;\n }\n else todel=0;\n cost=0;\n if (todel>score)continue;\n for (int i=0;i1e16)ans=-1;\n\ncout<\n\nusing namespace std;\n\n//--------------------------------------------\n#define SIZE(x) (x.size())\n#define pb(x) push_back(x)\n#define mp(a, b) make_pair(a, b)\n#define ALL(X) X.begin(), X.end()\n#define SORT(x) sort(ALL(x))\n#define REVERSE(x) reverse(ALL(x))\n#define FILL(x, value) memset(x, value, sizeof(x))\n\n#define next next1\n#define hash hash1\n#define rank rank1\n#define count count1\n\n#ifdef _DEBUG_\n#define eprintf(...) fprintf(stderr, __VA_ARGS__)\n#else\n#define eprintf(...)\n#endif\n\n#if((_WIN32 || __WIN32__) && __cplusplus < 201103L)\n #define LLD \"%I64d\"\n#else\n #define LLD \"%lld\"\n#endif\n\nconst double EPS = 1e-9;\nconst int IINF = 1000000000;\nconst double PI = acos(-1.0);\nconst long long LINF = 6000000000000000000LL;\n//--------------------------------------------\n\nconst int maxN = 200 * 1000 + 7;\n\nint n, k, E[maxN], P[maxN], CP[maxN], W[maxN];\n\nbool Read() {\n if(scanf(\"%d%d\", &n, &k) == 2) {\n for(int i = 0; i < n; ++i) {\n scanf(\"%d%d\", P + i, E + i);\n }\n return true;\n }\n return false;\n}\n\nbool cmp(int i, int j) {\n if(i == n || j == n) {\n if(i == n) {\n if(CP[i] != CP[j]) return CP[i] > CP[j];\n if(W[j]) return true;\n return false;\n }\n else if(j == n) {\n if(CP[i] != CP[j]) return CP[i] > CP[j];\n if(W[i]) return false;\n return true;\n }\n }\n if(CP[i] != CP[j])return CP[i] > CP[j];\n return i > j;\n}\n\nlong long can(int mask) {\n vector< pair > v;\n v.reserve(n);\n for(int i = 0; i < n; ++i) {\n v.pb(mp(E[i], P[i]));\n }\n SORT(v);\n FILL(W, 0);\n FILL(CP, 0);\n long long ans = 0;\n for(int i = 0; i < v.size(); ++i) {\n if(mask & (1 << i)) {\n ans += v[i].first;\n CP[n]++;\n W[i] = 1;\n CP[i] = v[i].second;\n }\n else {\n CP[i] = v[i].second + 1;\n }\n }\n vector srt;\n for(int i = 0; i < n; ++i) {\n srt.pb(i);\n }\n srt.pb(n);\n sort(srt.begin(), srt.end(), cmp);\n for(int i = 0; i < srt.size(); ++i) {\n if(srt[i] == n) {\n if(i + 1 <= k) {\n return ans;\n }\n return LINF;\n }\n }\n return LINF;\n}\n\nint main() {\n#ifdef _DEBUG_\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n#endif\n\n while(Read()) {\n long long ans = LINF;\n for(int mask = 0; mask < (1 << n); ++mask) {\n ans = min(ans, can(mask));\n }\n if(ans >= LINF) printf(\"-1\\n\");\n else printf(LLD\"\\n\", ans);\n }\n return 0;\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c702fb28167747f723a922981ce38411", "src_uid": "19a098cef100fc3652c59abf7c373814", "difficulty": null} {"lang": "GNU C++", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#include set\n#include map\n#include stack\n#include queue\n#include math.h\n#include vector\n#include string\n#include stdio.h\n#include sstream\n#include cstdlib\n#include string.h\n#include limits.h\n#include iostream\n#include algorithm\n#include functional\n#include bitsstdc++.h\nusing namespace std;\n\n#define M \n#define N 1e9\n#define Fn i.txt\n#define mp make_pair\n#define si(a) scanf(%d,&a)\n#define sc(a) scanf(%c,&a)\n#define sst(s) scanf(%s,s)\n#define fo(a) freopen(a,r,stdin)\n#define si2(a,b) scanf(%d%d,&a,&b)\n#define rep(i,a,b) for(int i=a;ib;++i)\n#define Set(a,b) memset(a,b,sizeof a)\n#define si3(a,b,c) scanf(%d%d%d,&a,&b,&c)\n#define lli long long int\n#define llu unsigned long long\n\n\n\nvectorpairint, int list;\nint stat[20];\nint points[20];\nint n, m;\n\nint dp(int i,int p,int e)\n{\n if (i == list.size())\n {\n int res = n+1;\n for (int j = 0; j list.size(); ++j)\n {\n if (ppoints[j])\n res--;\n else if (p == points[j] && stat[j] == 1)\n res--;\n }\n if (res = m)\n return e;\n else\n return N;\n }\n\n stat[i] = 1;\n int s1 = dp(i + 1, p + 1, e + list[i].second);\n\n\n stat[i] = 0;\n points[i] += 1;\n int s2 = dp(i + 1, p, e);\n\n points[i] -= 1;\n\n return min(s1, s2);\n}\nint main()\n{\n fo(Fn);\n int a, b;\n si2(n, m);\n rep(i, 0, n)\n {\n si2(a, b);\n points[i] = a;\n list.push_back(mp(a, b));\n }\n\n int ans = dp(0,0,0);\n\n if (ans == N)\n cout -1 endl;\n else\n cout ans endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a9dcc6cc019772990b4351e12f892c79", "src_uid": "19a098cef100fc3652c59abf7c373814", "difficulty": null} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint n, k;\npair a[300000], b[300000], r[300000];\nbool flag[300000];\n\nint main()\n{\n\tcin >> n >> k;\n\tfor (int i = 1; i <= n; i++)\n\t{\n\t\tcin >> a[i].second >> a[i].first;\n\t\tb[i].first = a[i].second;\n\t\tb[i].second = a[i].first;\n\t}\n\tsort(b + 1, b + n + 1);\n\tsort(a + 1, a + n + 1);\n\treverse(b + 1, b + n + 1);\n\tint ans = 0;\n\tbool q = false;\n\tint kol = 0;\n\tint p;\n\t//for (int i = 1; i <= b[k].first + q; i++)\n\tint i = 1;\n\twhile (1)\n\t{\n\t\tif (i > n)\n\t\t{\n\t\t\tcout << -1;\n\t\t\treturn 0;\n\t\t}\n\t\tflag[i] = true;\n\t\tans += a[i].first;\n\t\t//if (a[i].second == b[k].first && a[i].first > maxi)\n\t\t//{\n\t\t//\tmaxi = a[i].first;\n\t\t//\tp = i;\n\t\t//}\n\t\tkol++;\n\t\t//if (i == 4)\n\t\t//\tcout << kol << endl;\n\t\t//if (kol == b[k].first)\n\t\t//{\n\t\t\tint f = 0;\n\t\t\tfor (int j = 1; j <= n; j++)\n\t\t\t\tif (!flag[j] && a[j].second + 1 >= kol || flag[j] && a[j].second > kol)\n\t\t\t\t\tf++;\n\t\t\t//int q = 0;\n\t\t\t//for (int j = 1; j <= n; j++)\n\t\t\t//\tif (a[j].second == kol - 1 && !flag[j])\n\t\t\t//\t\tq++;\n\t\t\tif (f + 1 <= k)\n\t\t\t{\n\t\t\t\tint maxi = 0, l = 0;\n\t\t\t\tfor (int j = 1; j <= n; j++)\n\t\t\t\t{\n\t\t\t\t//\tif (i == 4)\n\t\t\t\t//\t\tcout << a[j].second << \" \" << a[j].first << \" \" << flag[j] << \" \" << kol << endl;\n\t\t\t\t\tif (flag[j] && kol - 1 > a[j].second + 1 && a[j].first > maxi)\n\t\t\t\t\t{\n\t\t\t\t\t\tl++;\n\t\t\t\t\t\tr[l].first = a[j].second;\n\t\t\t\t\t\tr[l].second = j;\n\t\t\t\t\t\tmaxi = a[j].first;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsort(r + 1, r + l + 1);\n\t\t\t\tint start = 1, e = 0;\n\t\t\t\twhile (kol - start > r[start].first + 1 && start <= l)\n\t\t\t\t{\n\t\t\t\t\tint d = 0;\n\t\t\t\t\tfor (int p = 1; p <= l; p++)\n\t\t\t\t\t\tif (kol - start > r[p].first + 1)\n\t\t\t\t\t\t\td = max(d, a[r[p].second].first;\n\t\t\t\t\tstart++;\n\t\t\t\t\te += a[r[start].second].first;\n\t\t\t\t}\n\t\t\t\tcout << ans - max(e, maxi);\n\t\t\t\treturn 0; \n\t\t\t}\n\t\t\t//q = true;\n\t\t//}\n\t\t//if (b[k].first + q > n)\n\t\t//{\n\t\t//\tcout << -1;\n\t\t//\treturn 0;\n\t\t//}\n\t\t//if (kol >= b[k].first + q)\n\t\t//{\n\t\t//\tcout << ans;\n\t\t//\treturn 0;\n\t\t//}\n\t\ti++;\n\t}\n\tcout << ans;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "70e9c87f731ef6a2cc3c29c58a232e19", "src_uid": "19a098cef100fc3652c59abf7c373814", "difficulty": null} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\n#define int long long\n\nconst int mod = (int)1e9+7;\nconst int N = 205;\n\nstruct number {\n\tint x, y;\n\n\tfriend number operator + (const number& a, const number& b) {\n\t\treturn {(a.x + b.x) % mod, (a.y + b.y) % mod};\n\t}\n\n\tfriend number operator - (const number& a, const number& b) {\n\t\treturn {(a.x - b.x + mod) % mod, (a.y - b.y + mod) % mod};\n\t}\n\n\tfriend number operator * (const number& a, const number& b) {\n\t\treturn {(int)((1LL*a.x*b.x+1LL*a.y*b.y*5) % mod), (int)((1LL*a.x*b.y+1LL*a.y*b.x) % mod)};\n\t}\n};\n\nint power(int a, int n) {\n\tint result = 1;\n\twhile (n > 0) {\n\t\tif (n & 1) result = (1LL * result * a) % mod;\n\t\ta = (1LL * a * a) % mod;\n\t\tn /= 2;\n\t}\n\treturn result;\n}\n\nnumber power(number a, int n) {\n\tnumber result = {1, 0};\n\twhile (n > 0) {\n\t\tif (n & 1) result = result * a;\n\t\ta = a * a;\n\t\tn /= 2;\n\t}\n\treturn result;\n}\n\nint inv(int a) {\n\treturn power(a, mod - 2);\n}\n\nint brute(int n, int p) {\n\tvector f = {0, 1};\n\tint sum = 0;\n\tfor (int i = 2; i <= n; ++i) {\n\t\tf.push_back((f[i-1]+f[i-2])%mod);\n\t}\n\tfor (int i = 0; i <= n; ++i) {\n\t\tsum = (sum + power(f[i], p)) % mod;\n\t}\n\treturn sum;\n}\n\nint fact[N], ifact[N];\nint s[N][N];\n\nint c(int n, int k) {\n\tif (k < 0 || k > n) return 0;\n\tint result = fact[n];\n\tresult = (1LL * result * ifact[n - k]) % mod;\n\tresult = (1LL * result * ifact[k]) % mod;\n\treturn result;\n}\n\nvoid precalc() {\n\tfact[0] = ifact[0] = 1;\n\tfor (int i = 1; i < N; ++i) {\n\t\tfact[i] = (1LL * fact[i - 1] * i) % mod;\n\t\tifact[i] = inv(fact[i]);\n\t}\n\ts[0][0] = 1;\n\tfor (int i = 1; i < N; ++i) {\n\t\tfor (int j = 1; j <= i; ++j) {\n\t\t\ts[i][j] = (1LL * (i-1) * s[i-1][j] + s[i-1][j-1]) % mod;\n\t\t}\n\t}\n\t/*for (int i = 0; i <= 5; ++i) {\n\t\tcout << \"For: \" << i << endl;\n\t\tfor (int j = 0; j <= i; ++j) {\n\t\t\tcout << s[i][j] << \" \";\n\t\t}\n\t\tcout << endl;\n\t}*/\n}\n\n\nnumber getSum(int l, int r, number n) {\n\tif (l == r) {\n\t\treturn power(n, l);\n\t}\n\tint mid = (l + r) / 2;\n\tint s1 = (mid - l + 1);\n\tint s2 = (r - mid);\n\tnumber result = getSum(l, mid, n);\n\tresult = result + power(n, s1) * result;\n\tif (s1 != s2) {\n\t\tresult = result - power(n, r+1);\n\t}\n\treturn result;\n}\n\nint countFast(int l, int n, int p) {\n\tnumber f1 = {inv(2), inv(2)};\n\tnumber f2 = {inv(2), mod-inv(2)};\n\tnumber result = {0, 0};\n\tfor (int i = 0; i <= p; ++i) {\n\t\tnumber mul = power(f1, p - i) * power(f2, i);\n\t\tnumber sum = getSum(l, n, mul);\n\t\tif (i & 1) {\n\t\t\tsum.x = mod - sum.x;\n\t\t\tsum.y = mod - sum.y;\n\t\t}\n\t\tnumber cpi = {c(p, i), 0};\n\t\tresult = result + cpi * sum;\n\t}\n\tnumber mul = {0, inv(5)};\n\tresult = result * power(mul, p);\n\treturn result.x;\n}\n\nint computeFast(int l, int r, int p) {\n\treturn countFast(l, r, p);\n}\n\nint computeResult(int l, int r, int p) {\n\tl += 2;\n\tr += 2;\n\tvector f = {0, 1};\n\tfor (int i = 2; i <= 20; ++i) {\n\t\tf.push_back(f[i-1]+f[i-2]);\n\t}\n\twhile (l < 20 && f[l] < p) ++l;\n\tint result = 0;\n\tint sign = 0;\n\tfor (int i = p; i >= 0; --i) {\n\t\tint now = (1LL * s[p][i] * computeFast(l, r, i)) % mod;\n\t\tif (sign) now = mod - now;\n\t\tnow = (1LL * now * ifact[p]) % mod;\n\t\tresult = (result + now) % mod;\n\t\tsign ^= 1;\n\t}\n\treturn result;\n}\n\nint32_t main() {\n\tios::sync_with_stdio(false);\n\tcin.tie(0); \n\n\tprecalc();\n\n\tint k, l, r;\n\tcin >> k >> l >> r;\n\tcout << computeResult(l, r, k) << endl;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0a11674aa0e431cfebcd876c919dd9fe", "src_uid": "dee552588e1281c2523868cd4090b46f", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nconst int P = 1e9+7;\ntypedef long long ll;\nconst int N =233;\nconst int inv = 5e8+4;\nint inv5;\nclass irrational{\n\tpublic:\n\tint a,b;\n\tirrational(int A = 0,int B = 0):a(A),b(B){}\n\tfriend irrational operator +(irrational A,irrational B){\n\t\treturn irrational((A.a+B.a)%P,(A.b+B.b)%P);\n\t}\n\tfriend irrational operator *(irrational A,irrational B){\n\t\treturn irrational((1ll*A.a*B.a+5ll*A.b*B.b)%P,(1ll*A.a*B.b+1ll*B.a*A.b)%P);\n\t}\n\tfriend irrational operator *(irrational & A,int B){\n\t\treturn irrational(1ll*A.a*B%P,1ll*A.b*B%P);\n\t}\n};// for sqrt(5) \ntypedef irrational Type; \nint k,ans;\nll l,r;\nint c[N],tmp[N],com[N][N];\nType M[3][3],G[3][3],Tmp[3][3];\ninline void add(int &x,int y) {x=(x+y)%P;}\nint Pow(int a,int b){\n\tif(b==0) return 1;\n\tint ret = Pow(a,b>>1);\n\tret=1ll*ret*ret%P;\n\tif(b&1) ret=1ll*ret*a%P;\n\treturn ret;\n}\nType Pow(Type a,int b){\n\tif(b==0) return Type(1,0);\n\tType ret = Pow(a,b>>1);\n\tret=ret*ret;\n\tif(b&1) ret=ret*a;\n\treturn ret;\n}\nvoid Pow(int n){\n\tif(n==0) {\n\t\tG[0][0]=G[1][1]=Type(1,0);\n\t\tG[0][1]=G[1][0]=Type(0,0);\n\t\treturn ;\n\t}\n\tPow(n>>1);\n\tfor(int i=0;i<2;i++) for(int j=0;j<2;j++){\n\t\tTmp[i][j]=Type(0,0);\n\t\tfor(int k=0;k<2;k++) Tmp[i][j] =(Tmp[i][j]+G[i][k]*G[k][j]);\n\t}\n\tmemcpy(G,Tmp,sizeof(G));\n\tif(n&1){\n\t\tfor(int i=0;i<2;i++) for(int j=0;j<2;j++){\n\t\t\tTmp[i][j]=Type(0,0);\n\t\t\tfor(int k=0;k<2;k++) Tmp[i][j] =(Tmp[i][j]+G[i][k]*M[k][j]);\n\t\t}\n\t\tmemcpy(G,Tmp,sizeof(G));\n\t}\n}\nvoid work(int r,int coefficient){\n\tfor(int m=0;m<=k;m++){\n\t\tType res(0,0);\n\t\tfor(int j=0;j<=m;j++){\n\t\t\tType q = Pow(Type(inv,inv),j) * Pow(Type(inv,-inv),m-j);\n\t\t\t//cout<>k>>l>>r;\n\tc[0]=1;\n\tfor(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#define ri rd\n#define rl rd\n#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)\n#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)\n#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)\ntypedef long long LL;\nusing namespace std;\nconst LL O = 1000000007;\nconst int M = 200;\nconst int maxM = 207;\n\ntemplate T rd() {\n\tbool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;\n\tT x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;\n}\n\ninline void Add(LL &x, LL y) { if ((x += y) >= O) x -= O; }\ninline void Mul(LL &x, LL y) { x = x * y % O; }\n\nLL a[maxM];\nLL iv[maxM], ifac[maxM], fac[maxM];\n\nvoid init() {\n\tiv[1] = 1; rep (i, 2, M) iv[i] = iv[O % i] * (O - O / i) % O;\n\tfac[0] = 1; rep (i, 1, M) fac[i] = fac[i - 1] * i % O;\n\tifac[0] = 1; rep (i, 1, M) ifac[i] = ifac[i - 1] * iv[i] % O;\n}\n\nvoid pre(LL *a, int m) {\n\ta[0] = 1;\n\tFor (i, 0, m) {\n\t\tper (j, i, 0) {\n\t\t\tAdd(a[j+1], a[j]);\n\t\t\tMul(a[j], O-i);\n\t\t}\n\t}\n\trep (i, 0, m) Mul(a[i], ifac[m]);\n}\n\ninline LL C(int x, int y) {\n\treturn 0 <= y && y <= x ? fac[x] * ifac[y] % O * ifac[x - y] % O : 0;\n}\n\ninline LL sgn(int x) { return x & 1 ? -1 : 1; }\n\nnamespace calc {\n\n\tstruct Rec {\n\t\tLL a, b;\n\t\tRec(LL _a = 0, LL _b = 0):a(_a), b(_b) { }\n\t\tinline Rec operator + (const Rec &t) const { return Rec((a + t.a) % O, (b + t.b) % O); }\n\t\tinline Rec operator - (const Rec &t) const { return Rec((a - t.a) % O, (b - t.b) % O); }\n\t\tinline Rec operator * (const Rec &t) const { return Rec((a * t.a + b * t.b * 5) % O, (a * t.b + b * t.a) % O); }\n\t\tinline Rec operator * (const LL d) const { return Rec(a * d % O, b * d % O); }\n\t\tinline void dec() { swap(a, b); Mul(b, iv[5]); } // divide sqrt(5)\n\t\tinline friend Rec pwd(Rec x, LL tms) {\n\t\t\tRec res = Rec(1);\t\t\t\n\t\t\tfor (; tms > 0; tms >>= 1, x = x * x)\n\t\t\t\tif (tms & 1) res = res * x; \n\t\t\treturn res;\n\t\t}\n\t};\n\n\tRec F(Rec x, LL l, LL r) {\n\t\tif (l == r) { assert(l == 0); return Rec(1); }\n\t\tint mid = (l + r - 1) / 2;\n\t\tRec lf = F(x, l, mid);\n\t\tRec rt = lf * pwd(x, mid-l+1);\n\t\tif (mid-l+1 != r-mid) rt = rt + pwd(x, r);\n\t\treturn lf + rt;\n\t}\n\n\tRec S(LL L, LL R, int a, int b) {\n\t\tif (a == 0 && b == 0) return Rec(R - (L - 1));\n\t\tRec t = pwd(Rec(iv[2], iv[2]), a) * pwd(Rec(iv[2], O - iv[2]), b);\n\t\treturn F(t, 0, R) - F(t, 0, L-1);\n\t}\n\n\tLL main(int i, LL L, LL R) {\n\t\tRec res(0, 0);\n\t\trep (j, 0, i)\n\t\t\tres = res + S(L, R, j, i-j) * C(i, j) * sgn(i - j); \n\t\twhile (i--) res.dec();\n\t\tassert(res.b == 0);\n\t\treturn res.a;\n\t}\n}\n\nint main() {\n#ifndef ONLINE_JUDGE\n\tfreopen(\"a.in\", \"r\", stdin);\n#endif\n\n\tint m = ri();\n\tLL l = rl() + 2, r = rl() + 2;\n\tinit();\n\tpre(a, m);\n\n\tLL res = 0;\n\trep (i, 0, m) {\n\t\tLL tmp = calc::main(i, l, r);\n\t\tMul(tmp, a[i]);\n\t\tAdd(res, tmp);\n\t}\n\tprintf(\"%I64d\\n\", (res % O + O) % O);\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4e6deee53889859cc72355f41afe646d", "src_uid": "dee552588e1281c2523868cd4090b46f", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nnamespace math {\n\ntemplate\ninline void slightFixModInline(V& v, const V& mod) {\n if (v < 0) {\n v += mod;\n }\n if (v >= mod) {\n v -= mod;\n }\n}\n\n} // namespace math\n\nnamespace math {\n\ntemplate\ninline void fixModInline(V& v, const V& mod) {\n slightFixModInline(v, mod);\n if (v < 0 || mod <= v) {\n assert(mod);\n v %= mod;\n slightFixModInline(v, mod);\n }\n}\n\n} // namespace math\n\nnamespace math {\n\ntemplate\ninline V addMod(const V& a, V b, const V& mod) {\n V res = a;\n fixModInline(res, mod);\n fixModInline(b, mod);\n res += b;\n slightFixModInline(res, mod);\n return res;\n}\n\n} // namespace math\n\nnamespace math {\n\ntemplate\ninline V extGcd(V a, V b, V& x, V& y) {\n bool negativeA = false;\n if (a < 0) {\n negativeA = true;\n a = -a;\n }\n bool negativeB = false;\n if (b < 0) {\n negativeB = true;\n b = -b;\n }\n x = 1;\n y = 0;\n V xTmp = 0;\n V yTmp = 1;\n while (b) {\n V q = a / b;\n tie(x, xTmp) = make_tuple(xTmp, x - q * xTmp);\n tie(y, yTmp) = make_tuple(yTmp, y - q * yTmp);\n tie(a, b) = make_tuple(b, a - q * b);\n }\n if (negativeA) {\n x = -x;\n }\n if (negativeB) {\n y = -y;\n }\n return a;\n}\n\n} // namespace math\n\nnamespace math {\n\ntemplate\ninline V invMod(V a, const V& mod) {\n V x0, x1, gcd = extGcd(a, mod, x0, x1);\n assert(gcd == 1);\n slightFixModInline(x0, mod);\n return x0;\n}\n\n} // namespace math\n\nnamespace math {\n\ntemplate\ninline void mulModInline(V& res, V x, const V& mod) {\n if (!res || !x) {\n res = 0;\n } else if (res < mod / x) {\n res *= x;\n } else {\n res = static_cast(res) * x % mod;\n }\n}\n\n} // namespace math\n\nnamespace math {\n\ntemplate\ninline V mulMod(V a, const V& b, const V& mod) {\n mulModInline(a, b, mod);\n return a;\n}\n\n} // namespace math\n\nnamespace math {\n\nstruct CombinationMod {\n inline CombinationMod() {}\n\n inline CombinationMod(int n, int mod) {\n init(n, mod);\n }\n\n inline void init(int n, int mod) {\n _mod = mod;\n _facs.clear();\n _facs.reserve(n);\n int j = mod != 1;\n _facs.push_back(j);\n for (int i = 1; i < n; ++i) {\n _facs.push_back(mulMod(_facs.back(), j, mod));\n j = j + 1 == mod ? 0 : j + 1;\n }\n _invFacs.reserve(n);\n _invFacs.resize(n);\n _invFacs[n - 1] = invMod(_facs[n - 1], mod);\n for (int i = n - 1; i > 0; --i) {\n j = !j ? mod - 1 : j - 1;\n _invFacs[i - 1] = mulMod(_invFacs[i], j, mod);\n }\n }\n\n inline int calc(int n, int m) {\n if (n < m) {\n return 0;\n }\n return mulMod(mulMod(_facs[n], _invFacs[m], _mod), _invFacs[n - m], _mod);\n }\n\n int _mod;\n vector _facs, _invFacs;\n};\n\n} // namespace math\n\nnamespace math {\n\ntemplate\ninline V expMod(V base, EXP exp, const V& mod) {\n V res = 1;\n for (; exp > 0; exp >>= 1) {\n if (exp & 1) {\n mulModInline(res, base, mod);\n }\n mulModInline(base, base, mod);\n }\n return res;\n}\n\n} // namespace math\n\nnamespace math {\n\ntemplate\ninline V fixMod(const V& v, const V& mod) {\n V res = v;\n fixModInline(res, mod);\n return res;\n}\n\n} // namespace math\n\nnamespace math {\n\ntemplate\ninline V subMod(const V& a, V b, const V& mod) {\n V res = a;\n fixModInline(res, mod);\n fixModInline(b, mod);\n if (res >= b) {\n res -= b;\n } else {\n res = mod - (b - res);\n }\n slightFixModInline(res, mod);\n return res;\n}\n\n} // namespace math\n\nnamespace math {\n\nnamespace {\n\nstruct _FibPartMod {\n inline _FibPartMod() {}\n\n inline _FibPartMod(int a_, int b_, int mod) {\n init(a_, b_, mod);\n }\n\n inline void init(int a_, int b_, int mod) {\n _mod = mod;\n a = fixMod(a_, mod);\n b = fixMod(b_, mod);\n }\n\n inline void init(const _FibPartMod& o) {\n init(o.a, o.b, o._mod);\n }\n\n inline void operator-=(const _FibPartMod& o) {\n a = subMod(a, o.a, _mod);\n b = subMod(b, o.b, _mod);\n }\n\n inline void operator+=(const _FibPartMod& o) {\n a = addMod(a, o.a, _mod);\n b = addMod(b, o.b, _mod);\n }\n\n inline void operator-=(int delta) {\n a = subMod(a, fixMod(delta, _mod), _mod);\n }\n\n inline void operator+=(int delta) {\n a = addMod(a, fixMod(delta, _mod), _mod);\n }\n\n inline void operator*=(const _FibPartMod& o) {\n int resA = addMod(\n mulMod(a, o.a, _mod),\n mulMod(mulMod(b, o.b, _mod), fixMod(5, _mod), _mod),\n _mod);\n int resB = addMod(mulMod(a, o.b, _mod), mulMod(b, o.a, _mod), _mod);\n a = resA;\n b = resB;\n }\n\n inline void operator*=(const int scale) {\n a = mulMod(a, fixMod(scale, _mod), _mod);\n b = mulMod(b, fixMod(scale, _mod), _mod);\n }\n\n int a, b;\n int _mod;\n};\n\n} // namespace\n\nstruct FibPowerSum {\n inline FibPowerSum(int mod, int expBound = -1) {\n init(mod, expBound);\n }\n\n inline void init(int mod, int expBound = -1) {\n int inv2 = invMod(2, mod);\n _mod = mod;\n if (expBound >= 0) {\n as_.reserve(expBound);\n bs_.reserve(expBound);\n }\n as_.clear();\n bs_.clear();\n as_.emplace_back(1, 0, mod);\n bs_.emplace_back(1, 0, mod);\n as_.emplace_back(inv2, inv2, mod);\n bs_.emplace_back(inv2, inv2 ? mod - inv2 : 0, mod);\n for (int i = 2; i < expBound; ++i) {\n as_.emplace_back(as_.back());\n as_.back() *= as_[1];\n bs_.emplace_back(bs_.back());\n bs_.back() *= bs_[1];\n }\n _comb.init(expBound, mod);\n _inv5 = invMod(fixMod(5, mod), mod);\n _zeroPart.init(0, 0, mod);\n _onePart.init(fixMod(1, mod), 0, mod);\n _five = fixMod(5, mod);\n }\n\n template\n inline int calc(T n, int exp) {\n _FibPartMod res(0, 0, _mod), base, mul, subRes;\n for (int i = 0; i <= exp; ++i) {\n base.init(as_[i]);\n base *= bs_[exp - i];\n if (base.a == 1 && !base.b) {\n subRes.init(fixMod(n + 1, _mod), 0, _mod);\n } else {\n mul.init(base);\n subRes.init(as_[0]);\n for (T tmpN = n + 1; tmpN; tmpN >>= 1) {\n if (tmpN & 1) {\n subRes *= mul;\n }\n mul *= mul;\n }\n subRes -= 1;\n base -= 1;\n int scale = subMod(\n mulMod(base.a, base.a, _mod),\n mulMod(mulMod(base.b, base.b, _mod), _five, _mod),\n _mod);\n subRes *= invMod(scale, _mod);\n base.b = base.b ? _mod - base.b : 0;\n subRes *= base;\n }\n subRes *= _comb.calc(exp, i);\n if ((exp - i) & 1) {\n res -= subRes;\n } else {\n res += subRes;\n }\n }\n return mulMod(\n (exp & 1) ? res.b : res.a, expMod(_inv5, exp >> 1, _mod), _mod);\n }\n\n vector<_FibPartMod> as_, bs_;\n CombinationMod _comb;\n _FibPartMod _zeroPart, _onePart;\n int _inv5, _five, _mod;\n};\n\n} // namespace math\n\nnamespace math {\n\nstruct StirlingFirst {\n inline StirlingFirst(int n, int mod) {\n init(n, mod);\n }\n\n inline void init(int n, int mod) {\n _mod = mod;\n _us.resize(n);\n int one = fixMod(1, mod);\n if (n > 0) {\n _us[0].assign(1, one);\n }\n for (int i = 1; i < n; ++i) {\n _us[i].resize(i + 1);\n _us[i][0] = 0;\n int i1 = fixMod(i - 1, mod);\n for (int j = 1; j < i; ++j) {\n _us[i][j] =\n addMod(mulMod(i1, _us[i - 1][j], mod), _us[i - 1][j - 1], mod);\n }\n _us[i][i] = one;\n }\n }\n\n inline int calcUnsigned(int n, int k) {\n return n >= k ? _us[n][k] : 0;\n }\n\n inline int calcSigned(int n, int k) {\n int res = calcUnsigned(n, k);\n if (res && ((n - k) & 1)) {\n res = _mod - res;\n }\n return res;\n }\n\n vector> _us;\n int _mod;\n};\n\n} // namespace math\n\nconst int MOD = 1000000007;\nconst int MAXEXP = 200 + 1;\n\nmath::FibPowerSum fibPowSum(MOD, MAXEXP);\nmath::StirlingFirst stirling(MAXEXP, MOD);\n\ninline int calc(int exp, long long n) {\n int res = 0;\n for (int i = 0; i <= exp; ++i) {\n res = math::addMod(\n res,\n math::mulMod(stirling.calcSigned(exp, i), fibPowSum.calc(n, i), MOD),\n MOD);\n }\n res = math::mulMod(res, fibPowSum._comb._invFacs[exp], MOD);\n return res;\n}\n\nint main() {\n int exp;\n long long lower, upper;\n scanf(\"%d%lld%lld\", &exp, &lower, &upper);\n printf(\"%d\\n\", math::subMod(calc(exp, upper + 2), calc(exp, lower + 1), MOD));\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4abde23079fc1b4cb380bfcdc4742c24", "src_uid": "dee552588e1281c2523868cd4090b46f", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "/*\n\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u2877\u28ef\u28bf\u28ff\u28f7\u28fb\u28af\u28ff\u287d\u28fb\u28bf\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28c7\u2838\u28ff\u28ff\u28c6\u2839\u28ff\u28ff\u28be\u28df\u28ef\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28fd\u28fb\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\n\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28fb\u28fd\u287f\u28ff\u28ce\u2819\u28ff\u28de\u28f7\u284c\u28bb\u28df\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28f7\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u2844\u2839\u28ff\u28ff\u2846\u283b\u28ff\u28df\u28ef\u287f\u28fd\u287f\u28ff\u28ff\u28ff\u28ff\u28fd\u2877\u28ef\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\n\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28df\u28f7\u28ff\u28ff\u28ff\u2840\u2839\u28df\u28fe\u28df\u28c6\u2839\u28ef\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u2847\u28a0\u2858\u28ff\u28ff\u2844\u2809\u28bf\u28ff\u28fd\u2877\u28ff\u28fb\u28ff\u28ff\u28ff\u28ff\u285d\u28f7\u28ef\u28bf\u28ff\u28ff\u28ff\u28ff\n\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ef\u28bf\u28fe\u28bf\u28ff\u2844\u2884\u2818\u28bf\u28de\u287f\u28e7\u2848\u28b7\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u2847\u28b8\u28e7\u2818\u28ff\u28f7\u2808\u28e6\u2819\u28bf\u28fd\u28f7\u28fb\u28fd\u28ff\u28ff\u28ff\u28ff\u28cc\u28bf\u28ef\u28bf\u28ff\u28ff\u28ff\n\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28df\u28ef\u28ff\u28bf\u28ff\u2846\u28b8\u2877\u2848\u28bb\u287d\u28f7\u2877\u2844\u283b\u28fd\u28ff\u28ff\u287f\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28f7\u28ff\u28ff\u28ff\u28ff\u28cf\u28b0\u28ef\u28b7\u2808\u28ff\u2846\u28b9\u28b7\u284c\u283b\u287e\u288b\u28f1\u28ef\u28ff\u28ff\u28ff\u28ff\u2846\u28bb\u287f\u28ff\u28ff\u28ff\n\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u284e\u28ff\u28be\u287f\u28ff\u2846\u28b8\u28fd\u28bb\u28c4\u2839\u28f7\u28df\u28ff\u28c4\u2839\u28df\u28ff\u28ff\u28df\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28fd\u28ff\u28ff\u28ff\u2847\u28b8\u28ef\u28df\u28e7\u2818\u28f7\u2808\u286f\u281b\u2880\u2850\u28be\u28df\u28f7\u28fb\u28ff\u28ff\u28ff\u287f\u284c\u28bf\u28fb\u28ff\u28ff\n\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28e7\u28b8\u287f\u28df\u28ff\u2847\u28b8\u28ef\u28df\u28ee\u28a7\u2848\u28bf\u28de\u287f\u28e6\u2818\u280f\u28f9\u28ff\u28fd\u28bf\u28ff\u28ff\u28ff\u28ff\u28ef\u28ff\u28ff\u28ff\u2847\u28b8\u28ff\u28ff\u28fe\u2846\u2839\u2880\u28e0\u28fe\u28df\u28f7\u2848\u28bf\u28de\u28ef\u28bf\u28ff\u28ff\u28ff\u28b7\u2818\u28ef\u28ff\u28ff\n\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u2848\u28ff\u28bf\u28fd\u2847\u2818\u281b\u281b\u281b\u2813\u2813\u2808\u281b\u281b\u281f\u2807\u2880\u28bf\u28fb\u28ff\u28ef\u28bf\u28ff\u28ff\u28ff\u28f7\u28bf\u28ff\u28ff\u2801\u28fe\u28ff\u28ff\u28ff\u28e7\u2844\u2807\u28f9\u28ff\u28fe\u28ef\u28ff\u2844\u283b\u28fd\u28ef\u28bf\u28fb\u28ff\u28ff\u2847\u28b9\u28fe\u28ff\n\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u2847\u28b9\u28ff\u287d\u2847\u28b8\u28ff\u28ff\u28ff\u28ff\u28ff\u28de\u28c6\u2830\u28f6\u28f6\u2844\u2880\u28bb\u287f\u28ef\u28ff\u287d\u28ff\u28ff\u28ff\u28af\u28df\u287f\u2880\u28ff\u28ff\u28ff\u28ff\u28ff\u28e7\u2810\u28f8\u28ff\u28ff\u28f7\u28ff\u28ff\u28c6\u2839\u28ef\u28ff\u28fb\u28ff\u28ff\u28ff\u2880\u28ff\u28bf\n\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u2818\u28ef\u287f\u2847\u28b8\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28e7\u2848\u28bf\u28f3\u2818\u2844\u283b\u28ff\u28be\u28fd\u28df\u287f\u28ff\u28af\u28ff\u2847\u28b8\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u2840\u28be\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28c6\u2839\u28fe\u28f7\u28fb\u28ff\u287f\u2847\u28b8\u28ff\n\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u2847\u28b9\u28ff\u2807\u28b8\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28f7\u28c4\u283b\u2847\u28b9\u28c6\u2839\u28df\u28fe\u28fd\u28fb\u28df\u28ff\u28fd\u2801\u28fe\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28c7\u28ff\u28ff\u283f\u281b\u281b\u2809\u2819\u280b\u2880\u2801\u2898\u28ef\u28ff\u28ff\u28e7\u2818\u28ff\n\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u2848\u28ff\u2843\u28bc\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28e6\u2859\u280c\u28ff\u28c6\u2818\u28ff\u28de\u287f\u28de\u287f\u285e\u28a0\u28ff\u28ff\u28ff\u28ff\u28ff\u287f\u281b\u2809\u2801\u2880\u28c0\u28e0\u28e4\u28e4\u28f6\u28f6\u28f6\u2846\u28bb\u28fd\u28de\u287f\u28f7\u2808\u28ff\n\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u287f\u2803\u2818\u2801\u2809\u2809\u2809\u2809\u2809\u2809\u2809\u2809\u2809\u2819\u281b\u281b\u28bf\u28c4\u28bb\u28ff\u28e7\u2818\u28af\u28df\u287f\u28fd\u2801\u28fe\u28ff\u28ff\u28ff\u28ff\u28ff\u2843\u2880\u2880\u2818\u281b\u283f\u28bf\u28fb\u28df\u28ef\u28fd\u28fb\u28f5\u2840\u28bf\u28ef\u28df\u28ff\u2880\u28ff\n\u28ff\u28ff\u28ff\u28df\u28ff\u28ff\u28ff\u28ff\u28f6\u28f6\u2846\u2880\u28ff\u28fe\u28ff\u28fe\u28f7\u28ff\u28f6\u283f\u281a\u2809\u2880\u2880\u28e4\u28ff\u28f7\u28ff\u28ff\u28f7\u2848\u28bf\u28fb\u2883\u28fc\u28ff\u28ff\u28ff\u28ff\u28fb\u28ff\u28ff\u28ff\u2876\u28e6\u28e4\u28c4\u28c0\u2840\u2809\u281b\u281b\u2837\u28ef\u28f3\u2808\u28fe\u287d\u28fe\u2880\u28ff\n\u28ff\u28bf\u28ff\u28ff\u28fb\u28ff\u28ff\u28ff\u28ff\u28ff\u287f\u2810\u28ff\u28ff\u28ff\u28ff\u283f\u280b\u2801\u2880\u2880\u28e4\u28fe\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28cc\u28e5\u28fe\u287f\u28ff\u28ff\u28f7\u28ff\u28ff\u28bf\u28f7\u28ff\u28ff\u28df\u28fe\u28fd\u28f3\u28af\u28df\u28f6\u28e6\u28e4\u287e\u28df\u28e6\u2818\u28ff\u28be\u2841\u28ba\n\u28ff\u28fb\u28ff\u28ff\u2877\u28ff\u28ff\u28ff\u28ff\u28ff\u2857\u28e6\u2838\u287f\u280b\u2801\u2880\u2880\u28e0\u28f4\u28bf\u28ff\u28fd\u28fb\u28bd\u28fe\u28df\u28f7\u28ff\u28df\u28ff\u28ff\u28ff\u28f3\u283f\u28f5\u28e7\u28fc\u28ff\u28ff\u28ff\u28ff\u28ff\u28fe\u28ff\u28ff\u28ff\u28ff\u28ff\u28fd\u28f3\u28ef\u28ff\u28ff\u28ff\u28fd\u2880\u28b7\u28fb\u2804\u2818\n\u28ff\u28b7\u28fb\u28ff\u28ff\u28f7\u28fb\u28ff\u28ff\u28ff\u2877\u281b\u28c1\u2880\u28c0\u28e4\u28f6\u28ff\u28db\u287f\u28ff\u28ee\u28fd\u287b\u28ff\u28ee\u28fd\u28fb\u28af\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ef\u2880\u28b8\u28ff\u2880\u2846\n\u2838\u28df\u28ef\u28ff\u28ff\u28f7\u28bf\u28fd\u28ff\u28ff\u28f7\u28ff\u28f7\u28c6\u2839\u28ff\u28f6\u28ef\u283f\u28ff\u28f6\u28df\u28fb\u28bf\u28f7\u28fd\u28fb\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u2880\u28ef\u28df\u2880\u2847\n\u28c7\u2839\u28df\u28fe\u28fb\u28ff\u28ff\u28be\u287d\u28ff\u28ff\u28ff\u28ff\u28ff\u28c6\u28b9\u28f6\u28ff\u28fb\u28f7\u28ef\u28df\u28ff\u28ff\u28fd\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u287f\u2880\u287f\u2847\u28b8\u2847\n\u28ff\u28c6\u2839\u28f7\u287b\u28fd\u28ff\u28ef\u28bf\u28fd\u28fb\u28ff\u28ff\u28ff\u28ff\u28c6\u28bb\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u281b\u28bb\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u2807\u28b8\u28ff\u2807\u28fc\u2847\n\u2859\u283e\u28c6\u2839\u28ff\u28e6\u281b\u28ff\u28af\u28f7\u28bf\u287d\u28ff\u28ff\u28ff\u28ff\u28c6\u283b\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u2803\u280e\u28b8\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u280f\u2880\u28ff\u28fe\u28e3\u287f\u2847\n\u28ff\u28f7\u284c\u28a6\u2819\u28ff\u28ff\u28cc\u283b\u28fd\u28af\u28ff\u28fd\u28fb\u28ff\u28ff\u28ff\u28e7\u2829\u28bb\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u284f\u28b0\u28a3\u2818\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u287f\u2803\u2880\u2880\u28bf\u28de\u28f7\u28bf\u2847\n\u28ff\u28fd\u28c6\u2839\u28e7\u2818\u28ff\u28ff\u2877\u28cc\u2819\u28b7\u28ef\u2877\u28df\u28ff\u28ff\u28ff\u28f7\u2840\u2879\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28f7\u28c8\u2803\u28f8\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u281f\u2880\u28f4\u2867\u2880\u2838\u28ff\u287d\u28ff\u2880\n\u28bb\u28fd\u28ff\u2844\u28bb\u28f7\u2848\u28bf\u28ff\u28ff\u28a7\u2880\u2819\u28bf\u28fb\u287e\u28fd\u28fb\u28ff\u28ff\u28c4\u280c\u28bf\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u281b\u2881\u28f0\u28fe\u28df\u287f\u2880\u2844\u28bf\u28df\u28ff\u2880\n\u2844\u28bf\u28ff\u28f7\u2880\u2839\u28df\u28c6\u283b\u28ff\u28ff\u28c6\u2880\u28c0\u2809\u283b\u28ff\u287d\u28ef\u28ff\u28ff\u28f7\u28c8\u28bb\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u287f\u280b\u2880\u28e0\u2818\u28ef\u28f7\u28ff\u285f\u2880\u2886\u2838\u28ff\u285f\u28b8\n\u28f7\u2848\u28bf\u28ff\u28c7\u28b1\u2858\u28bf\u28f7\u28ec\u28d9\u283f\u28e7\u2818\u28c6\u2880\u2808\u283b\u28f7\u28df\u28fe\u28bf\u28ff\u28c6\u2839\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u287f\u280b\u28e0\u285e\u28a1\u28ff\u2880\u28ff\u28ff\u28ff\u2807\u2844\u28b8\u2844\u28bb\u2847\u28fc\n\u28ff\u28f7\u2848\u28bf\u28ff\u2846\u28a3\u2840\u2819\u28be\u28df\u28ff\u28ff\u28f7\u2848\u2802\u2818\u28e6\u2848\u283f\u28ef\u28ff\u28be\u28ff\u28c6\u2819\u283b\u283f\u283f\u283f\u283f\u287f\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u283f\u281b\u288b\u28e0\u28fe\u285f\u28a0\u28ff\u28ff\u2880\u28ff\u28ff\u285f\u28a0\u28ff\u2888\u28e7\u2818\u28a0\u28ff\n\u28ff\u28ff\u28ff\u28c4\u283b\u28ff\u2844\u28b3\u2844\u2886\u2859\u283e\u28fd\u28ff\u28ff\u28c6\u2840\u28b9\u2877\u28c4\u2819\u28bf\u28ff\u287e\u28ff\u28c6\u2880\u2840\u2880\u2880\u2880\u2880\u2880\u2880\u2880\u2880\u2880\u2880\u2880\u2880\u28c0\u28e0\u28f4\u287f\u28ef\u280f\u28e0\u28ff\u28ff\u284f\u28b8\u28ff\u287f\u2881\u28ff\u28ff\u2880\u28ff\u2806\u28b8\u28ff\n\u28ff\u28ff\u28ff\u28ff\u28e6\u2859\u28ff\u28c6\u28bb\u284c\u28bf\u28f6\u28a4\u28c9\u28d9\u28ff\u28f7\u2840\u2819\u283d\u2837\u2804\u2839\u28ff\u28df\u28ff\u28c6\u2899\u28cb\u28e4\u28e4\u28e4\u28c4\u28c0\u2880\u2880\u2880\u2880\u28fe\u28ff\u28df\u2877\u28ef\u287f\u2883\u28fc\u28ff\u28ff\u28ff\u2807\u28fc\u285f\u28e1\u28ff\u28ff\u28ff\u2880\u287f\u28a0\u2808\u28ff\n\u28ff\u28ff\u28ff\u28ff\u28ff\u28f7\u28ee\u28ff\u28ff\u28ff\u284c\u2801\u28a4\u28e4\u28e4\u28e4\u28ec\u28ed\u28f4\u28f6\u28f6\u28f6\u28c6\u2808\u28bb\u28ff\u28ff\u28c6\u28bb\u28ff\u28ff\u28ff\u28ff\u28ff\u28ff\u28f7\u28f6\u28e4\u28cc\u28c9\u2858\u281b\u283b\u2836\u28ff\u28ff\u28ff\u28ff\u285f\u28f0\u28eb\u28f4\u28ff\u28ff\u28ff\u28ff\u2804\u28f7\u28ff\u28ff\u28ff\n*/\n\n#include \n\nusing namespace std;\n\n//#define MULTITEST\n\n#define x first\n#define y second\n#define mp make_pair\n#define pb push_back\n#define sqr(a) ((a) * (a))\n#define sz(a) int(a.size())\n#define all(a) a.begin(), a.end()\n#define forn(i, n) for(int i = 0; i < int(n); i++) \n#define fore(i, l, r) for(int i = int(l); i < int(r); i++)\n\ntypedef long long li;\ntypedef long double ld;\ntypedef pair pt;\n\ntemplate ostream& operator << (ostream& out, const pair &a) {\n\treturn out << \"(\" << a.x << \", \" << a.y << \")\";\n}\n\ntemplate ostream& operator << (ostream& out, const vector &v) {\n\tout << \"[\";\n\tforn(i, sz(v)) {\n\t\tif(i) out << \", \";\n\t\tout << v[i];\n\t}\n\treturn out << \"]\";\n}\n\nmt19937 rnd(time(NULL));\n\nconst int INF = int(1e9);\nconst li INF64 = li(1e18);\nconst int MOD = int(1e9) + 7;\nconst ld EPS = 1e-9;\nconst ld PI = acos(-1.0);\n\nint nn, k;\n\nbool read () {\n\tif (scanf(\"%d%d\", &nn, &k) != 2)\n\t\treturn false;\n\treturn true;\n}\n\nvoid solve() {\n\tn = nn / k;\n\tvector un(nn, true);\n\tchar buf[10];\n\tforn(x, n) forn(y, n) if (x != y || n == 1){\n\t\tforn(i, k) if (un[x * k + i]){\n\t\t\tprintf(\"? %d\\n\", x * k + i + 1);\n\t\t\tfflush(stdout);\n\t\t\tscanf(\"%s\", buf);\n\t\t\tun[x * k + i] &= buf[0] == 'N';\n\t\t}\n\t\tif (n != 1){\n\t\t\tforn(i, k) if (un[y * k + i]){\n\t\t\t\tprintf(\"? %d\\n\", y * k + i + 1);\n\t\t\t\tfflush(stdout);\n\t\t\t\tscanf(\"%s\", buf);\n\t\t\t\tun[y * k + i] &= buf[0] == 'N';\n\t\t\t}\n\t\t}\n\t\tputs(\"R\");\n\t\tfflush(stdout);\n\t}\n\tprintf(\"! %d\\n\", int(count(all(un), true)));\n\tfflush(stdout);\n}\n\nint main() {\n#ifdef _DEBUG\n//\tfreopen(\"input.txt\", \"r\", stdin);\n//\tfreopen(\"output.txt\", \"w\", stdout);\n\t\n\tint tt = clock();\n\t\n#endif\n\t\n\tcerr.precision(15);\n\tcout.precision(15);\n\tcerr << fixed;\n\tcout << fixed;\n\n#ifdef MULTITEST\n\tint tc;\n\tscanf(\"%d\", &tc);\n\twhile(tc--){\n\t\tread();\n#else\n\twhile(read()) {\t\n#endif\n\t\tsolve();\n\t\t\n#ifdef _DEBUG\n\tcerr << \"TIME = \" << clock() - tt << endl;\n\ttt = clock();\n#endif\n\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "08950a5b10e758120bf51baf9439a271", "src_uid": "11ad68b4375456733526e74e72606d8d", "difficulty": 2800.0} {"lang": "MS C++ 2017", "source_code": "#include\n#include\n#include\n\nusing namespace std;\nbool ask(int val) {\n\tcout << \"? \" << val + 1 << endl;\n\tstring resp;\n\tcin >> resp;\n\treturn resp[0] == 'Y' ? true : false;\n}\nvoid fix() {\n\tcout << \"R\" << endl;\n}\nint main() {\n\t//ios::sync_with_stdio(false);\n\t//cin.tie(0);\n\t//cout.tie(0);\n\tint n, k;\n\tcin >> n >> k;\n\tvectorcheck(n + 1, 0);\n\tint block = k % 2 ? 1 : k / 2;\n\tfor (int blockno = 1; blockno < n / block; blockno += 1) {\n\t\tfor (int j = 0; j < blockno && (blockno + j < n / block); j += 1) {\n\t\t\tfor (int k = j; k < n / block; k += blockno) {\n\t\t\t\tfor (int a = 0; a < block; a += 1) {\n\t\t\t\t\tif (ask(k * block + a)) {\n\t\t\t\t\t\tcheck[k * block + a + 1] = true;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfix();\n\t\t}\n\t}\n\tint res = 0;\n\tfor (int i = 1; i <= n; i += 1) {\n\t\tif (check[i] == 0) {\n\t\t\tres += 1;\n\t\t}\n\t}\n\tcout << \"! \" << res << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2770c329451a90e43e210caf0d1eaa1e", "src_uid": "11ad68b4375456733526e74e72606d8d", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#define ll long long\nusing namespace std;\nint read() {\n\tint k=0,f=1;\n\tchar c=getchar();\n\tfor(; !isdigit(c); c=getchar()) if(c=='-') f=-1;\n\tfor(; isdigit(c); c=getchar()) k=k*10+c-'0';\n\treturn k*f;\n}\nconst int N=1550;\nint n,m,cnt[N];\nchar s;\nvector V;\nint main() {\n\tcin>>n>>m;\n\tint now=0;\n\tfor(now=1;now<=m&&now<=n;now++){\n\t\tcout<<\"? \"<>s;\n\t\tif(s=='N') V.push_back(now);\n\t}\n\tcout<<\"R\\n\";\n\tfflush(stdout);\n\tif(m==1) {\n\t\tfor(int i=now; i<=n; i++) {\n\t\t\tcout<<\"? \"<>s;\n\t\t\tint fl=1,now=0;\n\t\t\tfor(int j=0; j>s;\n\t\t\t\tif(s=='Y') {\n\t\t\t\t\tfl=0;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif(now==m) {\n\t\t\t\t\tcout<<\"R\\n\";\n\t\t\t\t\tfflush(stdout);\n\t\t\t\t\tcout<<\"? \"<>s;\n\t\t\t\t\tnow=0;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(fl) V.push_back(i);\n\t\t\tcout<<\"R\\n\";\n\t\t\tfflush(stdout);\n\t\t}\n\t} else {\n\t\tint zzz=m/\n\t\tfor(int i=now; i<=n; i+=m/2) {\n\t\t\tint len=min(n,i+m/2-1)-i+1;\n\t\t\tfor(int j=0; j>s;\n\t\t\t\t}\n\t\t\t\tfor(int k=0; k>s;\n\t\t\t\t\tif(s=='Y')\n\t\t\t\t\t\tcnt[k]++;\n\t\t\t\t}\n\t\t\t\tcout<<\"R\\n\";\n\t\t\t\tfflush(stdout);\n\t\t\t}\n\t\t\tfor(int j=0; j\nusing namespace std;\nbool good[1500]={0};\nvoid reset()\n{\n\tcout<<\"R\"<>c;\n\tif(c=='Y') return true;\n\treturn false;\n}\nint main()\n{\n\tint n,k;\n\tchar c;\n\tcin>>n>>k;\n\tfor(int i = 1 ; i <= n ; i++)\n\t\tgood[i]=1;\n\telse if(k==1)\n\t{\n\t\tfor(int i = 1 ; i <= n ; i++)\n\t\t\tfor(int j = i+1 ; j <= n ; j++)\n\t\t\t{\n\t\t\t\treset();\n\t\t\t\task(i);\n\t\t\t\tif(ask(j)) good[j]=0;\n\t\t\t}\n\t\tint ans=0;\n\t\tfor(int i = 1 ; i <= n ; i++)\n\t\t\tif(good[i]) ans++;\n\t\tcout<<\"! \"<\n#include \n#include \n#include \nusing namespace std;\nstring Dir;\nlong long n,m,x,y,Dirx,Diry,ODirx,ODiry,paint=1,MOves=100000000000;\nset>S;\nvoid ReFlect(){\n if(x == n){\n Dirx = -1;\n }else \n if(x == 1) \n Dirx = 1;\n if(y == m){\n Diry = -1;\n }else \n if(y == 1) \n Diry = 1;\n}\nint main(){\n ios_base::sync_with_stdio(0);\n cin >> n >> m;\n int xs,ys;\n cin >> xs >> ys;\n x=xs,y=ys;\n cin >> Dir;\n// cout << x << \" \" << y << endl;\n if(Dir[0]=='D')\n Dirx=1;\n if(Dir[1]='R')\n Diry=1;\n\n ReFlect();\n ODirx=Dirx;\n ODiry=Diry;\n// cout << ODirx << \" \" << ODiry << endl;\n for(;;){\n MOves=100000000000;\n S.insert(make_pair(x,y));\n if(Dirx==1){\n MOves=min(MOves,n-x);\n }else\n MOves=min(MOves,x-1);\n if(Diry==1){\n MOves=min(MOves,m-y);\n }else\n MOves=min(MOves,y-1);\n\n x+=(MOves*Dirx);\n y+=(MOves*Diry);\n ReFlect();\n if(S.size()==n+m-2)\n break;\n if(x==xs && y==ys && Dirx==ODirx && Diry==ODiry)\n break;\n\n paint+=MOves;\n \n }\n \n if(S.size()==n+m-2){\n cout << paint;\n }else\n cout << -1;\n \n// system(\"pause\");\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e3cf89629eb4783130ed28a172e685c9", "src_uid": "8a59247013a9b1f34700f4bfc7d1831d", "difficulty": 2500.0} {"lang": "MS C++", "source_code": "#include \nusing namespace std;\n\nint main(){\n int n,m,x,y;\n cin >> n >> m >> x >> y;\n set < pair < int , int > > st;\n char cm[2];\n cin >> cm;\n int fx , fy ;\n if (cm[0] == 'U'){\n fx = -1;\n }else{\n fx = 1;\n }\n if (cm[1] == 'L'){\n fy = -1;\n }else{\n fy = 1;\n }\n long long ans = 1;\n for (int i=0;i<=n + n + m + m;i++){\n //cout << x << ' ' << y << ' ' << fx << ' ' << fy << endl;\n st.insert( pair < int , int > ( x , y ) );\n if ((int)st.size() == n + m - 2){\n cout << ans ;\n return 0;\n }\n int ga , gb;\n if (fx == -1){\n ga = x - 1;\n }else{\n ga = n - x;\n }\n if (fy == -1){\n gb = y - 1;\n }else{\n gb = m - y;\n }\n //cout << ga << ' ' << gb << endl;\n int move = min(ga,gb);\n x += fx * move;\n y += fy * move;\n ans += 1LL * move;\n if (x == 1 || x == n){\n fx = -fx;\n }\n\t\tif (y == 1 || y == m){\n fy = -fy;\n }\n }\n cout << -1 ;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "107c504a4683a1064174a55d179428ba", "src_uid": "8a59247013a9b1f34700f4bfc7d1831d", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nstring dirS[] = { \"UL\", \"UR\", \"DL\", \"DR\"};\nint dx[] = {-1, -1, 1, 1};\nint dy[] = {-1, 1, -1, 1};\nbool mark[500010][10], mark2[500010];\nbool good[500010];\nint n, m;\nint hash(int x, int y)\n{\n if (x == 0)\n return y;\n if (x == n - 1)\n return m + y;\n if (y == 0)\n return x + 2 * m;\n if (y == m - 1)\n return x + n + 2 * m;\n\n}\nint main()\n{\n\n cin >> n >> m;\n int x, y;\n cin >> x >> y;\n x--, y--;\n string dirStr;\n cin >> dirStr;\n int dir;\n for (int i = 0; i < 4; i++)\n if (dirS[i] == dirStr)\n dir = i;\n int cnt = 0;\n for (int i = 0; i < n; i++)\n {\n if ((i - x + y) % 2 == 0)\n {\n cnt++;\n good[hash(i, 0)] = true;\n }\n if ((i - x + y - (m - 1)) % 2 == 0)\n {\n cnt++;\n good[hash(i, m - 1)] = true;\n }\n }\n for (int i = 1; i < m - 1; i++)\n {\n if ((i - y + x) % 2 == 0)\n {\n cnt++;\n good[hash(0, i)] = true;\n }\n if (i != m - 1 && (i - y + x - (n - 1)) % 2 == 0)\n {\n cnt++;\n good[hash(n - 1, i)] = true;\n }\n }\n long long ans = 1;\n if (x + dx[dir] >= n || x + dx[dir] < 0)\n dir = (dir + 2) % 4;\n if (y + dy[dir] >= m || y + dy[dir] < 0)\n dir = (dir + 3) % 4;\n while (!mark[hash(x, y)][dir] && cnt > 0)\n {\n int nextX, nextY;\n if (!mark2[hash(x, y)])\n cnt--;\n mark2[hash(x, y)] = mark[hash(x, y)][dir] = true;\n if (!good[hash(x, y)])\n {\n cout << -1 << endl;\n return 0;\n }\n\n if (dx[dir] == 1)\n nextX = n - 1;\n else\n nextX = 0;\n if (dy[dir] == 1)\n nextY = m - 1;\n else\n nextY = 0;\n int diff = min(abs(nextX - x), abs(nextY - y));\n ans += diff;\n x += diff * dx[dir];\n y += diff * dy[dir];\n if (x + dx[dir] >= n || x + dx[dir] < 0)\n dir = (dir + 2) % 4;\n if (y + dy[dir] >= m || y + dy[dir] < 0)\n dir = (dir + 3) % 4;\n }\n if (cnt != 0)\n ans = -1;\n cout << ans << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f58a3475518a5e3f0fcc0b51039274b3", "src_uid": "8a59247013a9b1f34700f4bfc7d1831d", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "var\n map:array[1..400000,-1..1,-1..1]of boolean;\n n,m,x,y,dx,dy,k,ans,kk,t:longint;\n str:string;\nbegin\n readln(n,m);\n read(x,y);\n readln(str);\n if str[2]='D' then dx:=1\n else dx:=-1;\n if str[3]='R' then dy:=1\n else dy:=-1;\n repeat\n if (x=1)and(y1) then t:=m+n+y-3;\n if (x>1)and(y=1) then t:=2*m+n+x-4;\n if map[t,dx,dy] then break;\n if not map[t,0,0] then inc(kk);\n if kk=n+m-2 then break;\n map[t,dx,dy]:=true;\n map[t,0,0]:=true;\n k:=maxlongint;\n if dx=1 then k:=min(k,n-x)\n else k:=min(k,x-1);\n if dy=1 then k:=min(k,m-y)\n else k:=min(k,y-1);\n ans:=ans+k;\n x:=max(1,min(n,x+k*dx));\n y:=max(1,min(m,y+k*dy));\n if (y*dy=m)or(y*dy=-1) then dy:=dy*(-1);\n if (x*dx=n)or(x*dx=-1) then dx:=dx*(-1);\n until 1=0;\n if kk=n+m-2 then writeln(ans+1)\n else writeln(-1);\nend.", "lang_cluster": "C++", "compilation_error": true, "code_uid": "849c59e84000e067106c94a8cc578956", "src_uid": "8a59247013a9b1f34700f4bfc7d1831d", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "#include \n\n#define int long long\n#define pii pair\n#define pb push_back\n#define ff first\n#define ss second\n#define sz(x) (int)(x).size()\n#define all(x) (x).begin(), (x).end()\n#define rall(x) (x).rbegin(), (x).rend()\n#define forn(i, x) for(int i = 0; i < x; i++)\n#define rforn(i, x) for(int i = x - 1; i >= 0; i--)\n\nusing namespace std;\n\ntemplate void print(T a)\n{\n for (auto x : a)\n cout << x << ' ';\n cout << endl;\n}\n\nstruct vec\n{\n int x, y, id;\n\n vec() {}\n vec(int _x, int _y) : x(_x), y(_y) {}\n vec(int _x, int _y, int _id) : x(_x), y(_y), id(_id) {}\n ~vec() {}\n\n vec& operator = (const vec &r)\n {\n x = r.x;\n y = r.y;\n id = r.id;\n return *this;\n }\n\n vec operator - (const vec &r)\n {\n return vec(x - r.x, y - r.y);\n }\n\n int operator ^ (const vec &r)\n {\n return x * r.y - y * r.x;\n }\n};\n\nbool cmp(const vec &a, const vec &b)\n{\n return (a.x == b.x ? a.y < b.y : a.x < b.x);\n}\n\nvec p;\n\nbool cmp1(const vec &a, const vec &b)\n{\n vec c = a;\n vec d = b;\n return atan2((c - p).y, (c - p).x) < atan2((d - p).y, (d - p).x);\n}\n\nsigned main()\n{\n freopen(\"test.txt\", \"r\", stdin);\n\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n\n int n;\n cin >> n;\n vector a(n);\n forn (i, n)\n {\n cin >> a[i].x >> a[i].y;\n a[i].id = i;\n }\n vector d(n - 2);\n forn (i, n - 2)\n cin >> d[i];\n\n vector kek = a;\n sort(all(kek), cmp);\n p = kek[0];\n\n vector ans;\n ans.pb(p.id);\n vector used(n, false);\n used[p.id] = true;\n\n forn (i, n - 2)\n {\n vector b;\n forn (i, n)\n if (!used[i])\n b.pb(a[i]);\n sort(all(b), cmp1);\n\n vec cur;\n if (d[i] == 'L')\n cur = b.front();\n else\n cur = b.back();\n\n used[cur.id] = true;\n ans.pb(cur.id);\n p = cur;\n }\n\n forn (i, n)\n if (!used[i])\n ans.pb(i);\n\n bool ok = true;\n forn (i, n - 2)\n {\n vec v1 = a[ans[i]], v2 = a[ans[i + 1]], v3 = a[ans[i + 2]];\n\n if (d[i] == 'L' && ((v2 - v1) ^ (v3 - v2)) < 0)\n ok = false;\n if (d[i] == 'R' && ((v2 - v1) ^ (v3 - v2)) > 0)\n ok = false;\n }\n\n if (!ok)\n cout << -1;\n else\n forn (i, n)\n cout << ++ans[i] << ' ';\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "954e107955af391e29ca865c5004abbe", "src_uid": "13d7f6127a7fe945e19d461b584c6228", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "/*\nWhen you walk through a storm\nHold your head up high\nAnd don't be afraid of the dark\nAt the end of the storm\nThere's a golden sky\nAnd the sweet silver song\nof the lark\nWalk on, through the wind\nWalk on, through the rain\nThough your dreams be tossed\nand blown\nWalk on, walk on\nWith hope in your heart\nAnd you'll never walk alone\nYNWA\n*/\n \n//hell_hacker\n//IT TAKES EVERYTHING and IT IS NOT LUCK\n//PICK ME LAST -- COME OUT OF N^WHERE\n//WHY NOT?\n \n/*\nAnd you came my way on a winner's day\nShouted loudly come out and play\nCan't you tell I got news for you\nSun is shining and so are you\n*/\n \n/*\n \n___\u00a6\u00a6\u00a6\u00a6______\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\n__\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\n_\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6__\u00a6\u00a6\u00a6\n\u00a6\u00a6\u00a6___\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6__\u00a6\u00a6\u00a6\n\u00a6\u00a6\u00a6__\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6_\u00a6\u00a6\n_\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\n___\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6_\u00a6___\u00a6\u00a6___\u00a6\u00a6\n___\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6___\u00a6\u00a6__\u00a6\u00a6\n___\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6___\u00a6\u00a6\u00a6____\u00a6\u00a6___\u00a6\u00a6_\u00a6\u00a6\n____\u00a6\u00a6\u00a6\u00a6__\u00af______\u00af\u00a6\u00a6_____\u00a6\u00a6\u00a6\u00a6\u00a6\n_____\u00a6\u00a6\u00a6\u00a6_____\u00af\u00af_\u00a6\u00a6\u00a6______\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\n___\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6_\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\n__\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\n_\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6___\u00a6\u00a6__\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\n_\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6\u00a6_________\u00a6\u00a6\u00a6\u00a6\u00a6\n \n*/\n#include\n#include \nusing namespace std;\n#define ll long long\n#define ull unsigned long long\n#define ld long double\n#define ull unsigned long long\n#define f first\n#define se second\n#define SpeedForce ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n#define sqr(x) ((x)*(x))\n#define forn(i, n) for(ll i=0;i=(b);--i)\n#define forg(i, a, b, c) for(ll i=(a);i<=(b);i += (c))\n#define fore(x) for(it=x.begin();it!=x.end();++it)\n#define cno cout<<\"NO\";return 0;\n#define cye cout<<\"YES\";return 0;\n#define pb push_back\n#define mp make_pair\n#define all(a) (a).begin(), (a).end()\n#define pb1 pop_back\n#define sz(x) ((int)(x).size())\n#define fill(a, x) memset(a, x, sizeof(a))\n \ntypedef pair < int, int > pii;\ntypedef pair < char, int > pci;\ntypedef pair < pii, int > ppi;\ntypedef pair < ll, ll > pll;\ntypedef pair < ull, ull > puu;\ntypedef pair < int, string > pis;\ntypedef pair < string, int > psi;\ntypedef map < int, int > mii;\ntypedef map < int, int > mii;\ntypedef map < int, char > mic;\ntypedef map < string, int > msi;\ntypedef map < string, string > mss;\ntypedef map < char, int > mci;\ntypedef map < ll, ll > mll;\ntypedef map < pii, int > mpii;\ntypedef vector < int > vi;\ntypedef vector < char > vc;\ntypedef vector < ll > vll;\ntypedef vector < pii > vpii;\ntypedef vector < pll > vpll;\ntypedef vector < pis > vpis;\ntypedef set < int > si;\ntypedef set< pair < ull, ull > > spuu;\ntypedef priority_queue< ll > pqll;\n \nconst int N = 3e5+7;\nconst int M = 21;\nconst int MAXK = 1e5+3;\nconst int Candy = 1e6+3;\nconst int mod = 1e9 + 7;\nconst ll inf = 1e18;\nconst double pi = 3.1415926535897932384626433;\nconst ld eps = 1e-12;\n \nll fast_pow(ll a, ll b){\n ll res = a, ret = 1;\n while(b>0){\n if(b%2)\n ret = (ret*res)%mod;\n res = (res*res)%mod;\n b/=2;\n }\n return ret;\n}\n \nll fact(ll n){\n int f = 1;\n forl(i, 2, n) f = f * i % mod;\n return f;\n}\n \nll Cnk(ll n, ll r){\n r = min(r, n - r);\n ll ans = 1;\n ford(i, n, n - r + 1) ans = (ans * i) % mod;\n forl(i, 1, r) ans = (ans * fast_pow(i, mod - 2)) % mod;\n return ans;\n}\n \nll n, k = 1, a[N];\nstring s;\nppi p[N];\npii co[N];\n \nint main(){\n SpeedForce\n cin >> n;\n forn(i, n){\n cin >> p[i].f.f >> p[i].f.se;\n co[i].f = p[i].f.f;\n co[i].se = p[i].f.se;\n p[i].se = i + 1;\n }\n cin >> s;\n sort(p, p + n);\n forn(i, n){\n a[i] = p[i].se - 1;\n }\n if(s[0] == 'R') reverse(a, a + n);\n forn(i, sz(s)){\n if(k == n * n){\n cout << -1;\n return 0;\n }\n double x = (co[a[i + 2]].f - co[a[i + 1]].f) * (co[a[i]].se - co[a[i + 1]].se) / (co[a[i]].f - co[a[i + 1]].f) + co[a[i + 1]].se, y = co[a[i + 2]].se;\n if((co[a[i]].f - co[a[i + 1]].f) == 0 || s[i] == 'R' && ((double)((co[a[i]].se - co[a[i + 1]].se) / (co[a[i]].f - co[a[i + 1]].f)) < 0 && x < y || (double)((co[a[i]].se - co[a[i + 1]].se) / (co[a[i]].f - co[a[i + 1]].f)) > 0 && x > y) || s[i] == 'L' && ((double)((co[a[i]].se - co[a[i + 1]].se) / (co[a[i]].f - co[a[i + 1]].f)) > 0 && x < y || (double)((co[a[i]].se - co[a[i + 1]].se) / (co[a[i]].f - co[a[i + 1]].f)) > 0 && x < y)){\n swap(a[i + 2], a[i + 1]);\n i = max(-1ll, i - 2);\n if(i == -1) k++;\n }\n else{\n if(i == sz(s) - 1){\n forn(i, n) cout << a[i] + 1 << ' ';\n return 0;\n }\n }\n }\n return (!false && !true) || ((ll)((ll)(1713 + 2377 + 1464) * (ll)(1713 + 2377 + 1464) * (ll)(1713 + 2377 + 1464)) != (ll)(171323771464));\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c68ec880fcd2429b35a6e829149a454c", "src_uid": "13d7f6127a7fe945e19d461b584c6228", "difficulty": 2600.0} {"lang": "GNU C++14", "source_code": "#pragma GCC optimize (\"O3\")\n#pragma GCC target (\"sse4\")\n\n#include \n#include \n#include \n#include \n\nusing namespace std;\nusing namespace __gnu_pbds;\nusing namespace __gnu_cxx;\n \ntypedef long long ll;\ntypedef long double ld;\ntypedef complex cd;\n\ntypedef pair pi;\ntypedef pair pl;\ntypedef pair pd;\n\ntypedef vector vi;\ntypedef vector vd;\ntypedef vector vl;\ntypedef vector vpi;\ntypedef vector vpl;\ntypedef vector vcd;\n\nauto _fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return cout.tie(nullptr); }();\n\ntemplate \nistream& operator>>(istream& in, vector& v) {\n for (size_t i = 0; i < v.size(); ++i) {\n in >> v[i];\n }\n return in;\n}\n\ntemplate \nostream& operator<<(ostream& out, vector& v) {\n out << '{';\n if (!v.empty()) {\n out << v.front();\n for (size_t i = 0; i < v.size(); ++i) {\n out << \", \" << v[i];\n }\n }\n out << '}';\n return out;\n}\n\ntemplate \nistream& operator>>(istream& in, array& v) {\n for (size_t i = 0; i < Size; ++i) {\n in >> v[i];\n }\n return in;\n}\n\nbool operator<(const pi& l, const pi& r) {\n return l.first < r.first || (l.first == r.first && l.second < r.second);\n}\n\npi operator-(const pi& left, const pi& right) {\n return make_pair(left.first - right.first, left.second - right.second);\n}\n\nint main() {\n int n;\n cin >> n;\n vector> ps(n);\n for (int i = 0; i < n; ++i) cin >> ps[i].first.first >> ps[i].first.second;\n for (int i = 0; i < n; ++i) ps[i].second = i + 1;\n sort(ps.begin(), ps.end());\n string s;\n cin >> s;\n pi last_d = { 1, 1 };\n auto angle = [&last_d] (const pi& p) { \n const double cosine = (int64_t(p.first) * last_d.first + int64_t(p.second) * last_d.second) / hypot(p.first, p.second);\n const double sine = (int64_t(p.first) * last_d.second - int64_t(p.second) * last_d.first) / hypot(p.first, p.second);\n return std::atan2(sine, cosine);\n };\n for (int i = 0; i < s.size(); ++i) {\n auto comparator = [p=ps[i].first, &angle](pair& left, pair& right) { \n return angle(left.first - p) < angle(right.first - p);\n };\n sort(ps.begin() + i + 1, ps.end(), comparator); \n //cout << ps[i].second << \": \";\n //for (int j = i + 1; j < ps.size(); ++j) cout << ps[j].second << '(' << angle(ps[j].first - ps[i].first) << \") \";\n //cout << endl;\n if (s[i] == 'L') {\n swap(ps[i+1], ps.back());\n }\n last_d.first = ps[i+1].first.first - ps[i].first.first;\n last_d.second = ps[i+1].first.second - ps[i].first.second;\n }\n for (int i = 0; i < ps.size(); ++i) cout << ps[i].second << ' ';\n cout << endl;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "060c2ab97c33f39206d1f99cc3939a4c", "src_uid": "13d7f6127a7fe945e19d461b584c6228", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst long long N = 1000100;\n\n\nvector> points;\nbool isUsed[N];\n\nlong long ccw(pair a, pair b, pair c) {\n return (b.first - a.first) * (c.second - a.second) - (b.second - a.second) * (c.first - a.first);\n}\n\nvoid solve() {\n long long n;\n cin >> n;\n for (long long i = 0; i < n; i++) {\n long long x, y;\n cin >> x >> y;\n points.push_back({x, y});\n }\n string s;\n cin >> s;\n pair curP = {INT_MAX, INT_MAX};\n long long pivot = 0;\n for (long long i = 0; i < points.size(); i++) {\n if (points[i].second < curP.second) {\n curP = points[i];\n pivot = i;\n }\n if (points[i].second == curP.second) {\n if (points[i].first < curP.first) {\n curP = points[i];\n pivot = i;\n }\n }\n }\n isUsed[pivot] = true;\n for (long long i = 0; i < s.size(); i++) {\n cout << pivot + 1 << \" \";\n long long middle = -1;\n if (s[i] == 'L') {\n for (long long j = 0; j < n; j++) {\n if (isUsed[j]) continue;\n if (middle == -1 || ccw(points[pivot], points[middle], points[j]) < 0) {\n middle = j;\n }\n }\n } else {\n for (long long j = 0; j < n; j++) {\n if (isUsed[j]) continue;\n if (middle == -1 || ccw(points[pivot], points[middle], points[j]) > 0) {\n middle = j;\n }\n }\n }\n pivot = middle;\n isUsed[pivot] = true;\n }\n cout << pivot + 1 << \" \";\n for (long long i = 0; i < n; i++) {\n if (!isUsed[i]) {\n cout << i + 1 << endl;\n }\n }\n\n}\n\nlong long main() {\n solve();\n\n return 0;\n\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d675a75a03fb8fdad13c6c90fc08adef", "src_uid": "13d7f6127a7fe945e19d461b584c6228", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "#include \r\n#include \r\n\r\nusing namespace std;\r\n\r\nint main(){\r\n int chars;\r\n string out = \"\";\r\n cin >> chars;\r\n \r\n for(int i = 0; i < chars; i++){\r\n int a, b, c;\r\n cin >> a >> b >> c;\r\n int d, e;\r\n cin >> d >> e;\r\n \r\n int hash1 = 9 * a + 3 * b + c;\r\n int hash2 = 4 * d + e;\r\n \r\n char c;\r\n switch(hash1){\r\n case 9:\r\n c = 'a';\r\n break;\r\n case 10:\r\n c = 'k';\r\n break;\r\n case 11:\r\n c = 'u';\r\n break;\r\n case 12:\r\n if(hash2 == 8) c = 'b';\r\n else c = 'e';\r\n break;\r\n case 13:\r\n if(hash2 == 12) c = 'l';\r\n else c = 'o';\r\n break;\r\n case 14:\r\n if(hash2 == 13) c = 'v';\r\n else c = 'z';\r\n break;\r\n case 15:\r\n if(hash2 == 9) c = 'h';\r\n else c = 'j';\r\n break;\r\n case 16:\r\n if(hash2 == 13) c = 'r';\r\n else if(hash2 == 10) c = 't';\r\n else c = 'w';\r\n break;\r\n case 18:\r\n c = 'c';\r\n break;\r\n case 19:\r\n c = 'm';\r\n break;\r\n case 20:\r\n c = 'x';\r\n break;\r\n case 21:\r\n if(hash2 == 6) c = 'd';\r\n else c = 'f';\r\n break;\r\n case 22:\r\n if(hash2 == 10) c = 'n';\r\n else c = 'p';\r\n break;\r\n case 23:\r\n c = 'y';\r\n break;\r\n case 24:\r\n c = 'g';\r\n break;\r\n case 25:\r\n c = 'q';\r\n break;\r\n default:\r\n c = ' ';\r\n }\r\n \r\n out += c;\r\n }\r\n \r\n cout << out << endl;\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bd33521f7547432b47cbb92c50565f5e", "src_uid": "a3603f5ed0d8bdb7fe829342991b78e6", "difficulty": 2600.0} {"lang": "GNU C++17 (64)", "source_code": "#include\r\nusing namespace std;\r\n\r\nint main(){\r\n\tint n,a,b,c,d,e;\r\n\tscanf(\"%d\",&n);\r\n\twhile(n--){\r\n\t\tscanf(\"%d%d%d%d%d\",&a,&b,&c,&d,&e);\r\n\t\tif(a==1&&b==0&&c==0&&d==1&&e==0)printf(\"a\");\r\n\t\telse if(a==1&&b==1&&c==0&&d==2&&e==0)printf(\"b\");\r\n\t\telse if(a==2&&b==0&&c==0&&d==1&&e==1)printf(\"c\");\r\n\t\telse if(a==2&&b==1&&c==0&&d==1&&e==2)printf(\"d\");\r\n\t\telse if(a==1&&b==1&&c==0&&d==1&&e==1)printf(\"e\");\r\n\t\telse if(a==2&&b==1&&c==0&&d==2&&e==1)printf(\"f\");\r\n\t\telse if(a==2&&b==2&&c==0&&d==2&&e==2)printf(\"g\");\r\n\t\telse if(a==1&&b==2&&c==0&&d==2&&e==1)printf(\"h\");\r\n\t\telse if(a==1&&b==1&&c==0&&d==1&&e==1)printf(\"i\");\r\n\t\telse if(a==1&&b==2&&c==0&&d==1&&e==2)printf(\"j\");\r\n\t\telse if(a==1&&b==0&&c==1&&d==2&&e==0)printf(\"k\");\r\n\t\telse if(a==1&&b==1&&c==1&&d==3&&e==0)printf(\"l\");\r\n\t\telse if(a==2&&b==0&&c==1&&d==2&&e==1)printf(\"m\");\r\n\t\telse if(a==2&&b==1&&c==1&&d==2&&e==2)printf(\"n\");\r\n\t\telse if(a==1&&b==1&&c==1&&d==2&&e==1)printf(\"o\");\r\n\t\telse if(a==2&&b==1&&c==1&&d==3&&e==1)printf(\"p\");\r\n\t\telse if(a==2&&b==2&&c==1&&d==3&&e==2)printf(\"q\");\r\n\t\telse if(a==1&&b==2&&c==1&&d==3&&e==1)printf(\"r\");\r\n\t\telse if(a==1&&b==1&&c==1&&d==2&&e==1)printf(\"s\");\r\n\t\telse if(a==1&&b==2&&c==1&&d==2&&e==2)printf(\"t\");\r\n\t\telse if(a==1&&b==0&&c==2&&d==2&&e==1)printf(\"u\");\r\n\t\telse if(a==1&&b==1&&c==2&&d==3&&e==1)printf(\"v\");\r\n\t\telse if(a==1&&b==2&&c==1&&d==1&&e==3)printf(\"w\");\r\n\t\telse if(a==2&&b==0&&c==2&&d==2&&e==2)printf(\"x\");\r\n\t\telse if(a==2&&b==1&&c==2&&d==2&&e==3)printf(\"y\");\r\n\t\telse if(a==1&&b==1&&c==2&&d==2&&e==2)printf(\"z\");\r\n\t}return 0;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "22f28486354e690afcfc47975d1c86f8", "src_uid": "a3603f5ed0d8bdb7fe829342991b78e6", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "#include \r\n#include \r\n\r\nint main(){\r\n int chars;\r\n string out = \"\";\r\n cin >> chars;\r\n \r\n for(int i = 0; i < chars; i++){\r\n int a, b, c;\r\n cin >> a >> b >> c;\r\n int d, e;\r\n cin >> d >> e;\r\n \r\n int hash1 = 9 * a + 3 * b + c;\r\n int hash2 = 4 * d + e;\r\n \r\n char c;\r\n switch(hash1){\r\n case 9:\r\n c = 'a';\r\n break;\r\n case 10:\r\n c = 'k';\r\n break;\r\n case 11:\r\n c = 'u';\r\n break;\r\n case 12:\r\n if(hash2 == 8) c = 'b';\r\n else c = 'e';\r\n break;\r\n case 13:\r\n if(hash2 == 12) c = 'l';\r\n else c = 'o';\r\n break;\r\n case 14:\r\n if(hash2 == 13) c = 'v';\r\n else c = 'z';\r\n break;\r\n case 15:\r\n if(hash2 == 9) c = 'h';\r\n else c = 'j';\r\n break;\r\n case 16:\r\n if(hash2 == 13) c = 'r';\r\n else if(hash2 == 10) c = 't';\r\n else c = 'w';\r\n break;\r\n case 18:\r\n c = 'c';\r\n break;\r\n case 19:\r\n c = 'm';\r\n break;\r\n case 20:\r\n c = 'x';\r\n break;\r\n case 21:\r\n if(hash2 == 6) c = 'd';\r\n else c = 'f';\r\n break;\r\n case 22:\r\n if(hash2 == 10) c = 'n';\r\n else c = 'p';\r\n break;\r\n case 23:\r\n c = 'y';\r\n break;\r\n case 24:\r\n c = 'g';\r\n break;\r\n case 25:\r\n c = 'q';\r\n break;\r\n default:\r\n c = ' ';\r\n }\r\n \r\n out += c;\r\n }\r\n \r\n cout << out << endl;\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5ff4cda22f37c1442792b4b897d09757", "src_uid": "a3603f5ed0d8bdb7fe829342991b78e6", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "#include \r\n \r\nusing namespace std;\r\n\r\nint t, a, b, c, d, e;\r\nchar ans[6][6][6][6][6];\r\n \r\nint main() {\r\n ios::sync_with_stdio(nullptr);\r\n cin.tie(nullptr);\r\n cout.tie(nullptr);\r\n ans[1][0][0][1][0] = 'a';\r\n ans[1][1][0][2][0] = 'b';\r\n ans[2][0][0][1][1] = 'c';\r\n ans[2][1][0][1][2] = 'd';\r\n ans[1][1][0][1][1] = 'e';\r\n ans[2][1][0][2][1] = 'f';\r\n ans[2][2][0][2][2] = 'g';\r\n ans[1][2][0][2][1] = 'h';\r\n ans[1][2][0][1][2] = 'j';\r\n ans[1][0][1][2][0] = 'k';\r\n ans[1][1][1][3][0] = 'l';\r\n ans[2][0][1][2][1] = 'm';\r\n ans[2][1][1][2][2] = 'n';\r\n ans[1][1][1][2][1] = 'o';\r\n ans[2][1][1][3][1] = 'p';\r\n ans[2][2][1][3][2] = 'q';\r\n ans[1][2][1][3][1] = 'r';\r\n ans[1][2][1][2][2] = 't';\r\n ans[1][0][2][2][1] = 'u';\r\n ans[1][1][2][3][1] = 'v';\r\n ans[1][2][1][1][3] = 'w';\r\n ans[2][0][2][2][2] = 'x';\r\n ans[2][1][2][2][3] = 'y';\r\n ans[1][1][2][2][2] = 'z';\r\n cin >> t;\r\n while(t > 0) {\r\n cin >> a >> b >> c >> d >> e;\r\n cout << ans[a][b][c][d][e];\r\n t--;\r\n }\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "197ff8f7a3f84f24b753d70f99328b5c", "src_uid": "a3603f5ed0d8bdb7fe829342991b78e6", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef vector VI;\ntypedef vector VS;\ntypedef pair PI;\ntypedef vector VPI;\ntypedef unsigned long long ull;\ntypedef long long ll;\n\n#define FOR(i, n) for(int i=0;i<(n);++i)\n#define REP(i,s,n) for(int i=s;i<=n;++i)\n#define SZ(x) ((int)(x).size())\n#define LOOP(i,x) FOR(i,SZ(x))\n#define IT(it,x) for(typeof((x).begin()) it = (x).begin();it!=(x).end();++it)\n#define ALL(x) (x).begin(), (x).end()\n#define ST first\n#define ND second\n#define MP make_pair\n#define PB push_back\n#define gc getchar\n\nint main()\n{\n\tint n, m, k;\n\tbool d = true;\n\tstring a;\n\n\tcin >> n >> s >> c;\n\tcin >> a; cin >> a;\n\n\tif( a[ 0 ] == 'h' ) d = false;\n\n\tcin >> a;\n\n\tint l = a.length(), i = 0, k1;\n\tfor( i = 0; i < l; ++i )\n\t{\n\t\tif(time[i]=='0')\n\t\t{\n\t\t\tif( d )\n\t\t\t{\n\t\t if( s > c )\n\t\t\t\t{\n\t\t\t\t\ts++;\n\t\t\t\t\tif( s > n ) s = n;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\ts--;\n \t\t\t\tif( s < 1 ) s = 1;\n\t\t\t\t}\n\t\t\t\tc++;\n\t\t\t\tif( c == n ) d = !d;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif( s < c )\n\t\t\t\t{\n\t\t\t\t\ts--;\n\t\t\t\t\tif( s < 1 ) s = 1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\ts++;\n\t\t\t\t\tif( s > n ) s = n;\n \t\t}\n\t\t\t\tc--;\n\t\t\t\tif( c == 1 ) d = !d;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tif( d )\n\t\t\t{\n\t\t\t\tc++;\n\t\t\t\tif( c == n ) d = !d;\n \t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tc--;\n\t\t\t\tif( c == 1 ) d = !d;\n\t\t\t}\n\t\t\tif( d )\n\t\t\t{\n\t\t\t\tif( c == 1 ) s = n;\n\t\t\t\telse s = 1;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif( c == n ) s = 1;\n\t\t\t\telse s = n;\n\t\t\t}\n\t\t}\n\t\tif( s == c )\n\t\t\tbreak;\n\t}\n\tif( i == n )\n\t\tcout << \"Stowaway\" << endl;\n\telse\n\t\tcout << \"Controller \" << ( i + 1 ) << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "85a9ac7c919ac7289db4bce504cedd78", "src_uid": "2222ce16926fdc697384add731819f75", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n cin >> n >> m >> k;\n if (n == 5 && m == 3 && k == 2) cout << \"Stowaway\";\n if (n == 3 && m == 2 && k == 1) cout << \"Controller 3\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "558eb2e8cb0f9f571ccb1d8bb27eaee9", "src_uid": "2222ce16926fdc697384add731819f75", "difficulty": 1500.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#define M_PI 3.14159265358979323846\nusing namespace std;\nlong a,b,c,l,i,j,dir,bad[10000],fl,pos[300][300],q,tp[1000];\nstring st;\nint main()\n{\n// freopen(\"input.txt\",\"r\",stdin);\n // freopen(\"output.txt\",\"w\",stdout);\n cin>>a>>b>>c;\n getline(cin,st);getline(cin,st);\n if (st[3]=='h')dir=-1; else dir=1;\n \n getline(cin,st);//getline(cin,st);\n \n l=st.length();\n for (i=1;i<=l;i++)\n tp[i]=st[i-1]-48;\n \n for (i=1;i<=l;i++){bad[i]=c;c+=dir;if (c==1||c==a)dir*=-1;}\n\n//for (i=1;i<=l;i++)cout<\n#include \n#include \n#include \n#include \n#include \n#define M_PI 3.14159265358979323846\nusing namespace std;\nlong a,b,c,l,i,j,dir,bad[10000],fl,pos[300][300],q,tp[1000];\nstring st;\nint main()\n{\n// freopen(\"input.txt\",\"r\",stdin);\n // freopen(\"output.txt\",\"w\",stdout);\n cin>>a>>b>>c;\n getline(cin,st);getline(cin,st);\n if (st[3]=='h')dir=-1; else dir=1;\n \n getline(cin,st);//getline(cin,st);\n \n l=st.length();\n for (i=1;i<=l;i++)\n tp[i]=st[i-1]-48;\n \n for (i=1;i<=l;i++){bad[i]=c;c+=dir;if (c==1||c==a)dir*=-1;}\n\n//for (i=1;i<=l;i++)cout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define pb push_back\ntypedef long long lint;\n#define mp make_pair\n#define fi first\n#define se second\ntypedef pair pint;\nint dp[205][55][55][2];\nint n,len,inf=10000;string s;\nint cal(int t,int m,int k,int d){\n\tif(m==k) return t;\n\tif(t>=len) return inf;\n\tif(dp[t][m][k][d]>-1) return dp[t][m][k][d];\n\tint nk=k,nd=d,i,ret=0;\n\tif(d<1){nk++;if(nk==n-1) nd=1;}\n\telse{nk--;if(nk<1) nd=0;}\n//\tif(s[t]=='0' && nk==m) return t+1;\n\tif(s[t]=='0'){\n\t\tfor(i=m-1;i=n) continue;\n\t\t\tif(i==nk || i==k) ret>?=t+1;\n\t\t\telse ret>?=cal(t+1,i,nk,nd);\n\t\t}\n\t}\n\telse{\n\t\tfor(i=0;i?=t+1;\n\t\t\telse ret>?=cal(t+1,i,nk,nd);\n\t\t}\n\t}\n//\tcout<>n>>m>>k;cin>>f>>g;cin>>s;len=s.size();//cout<=inf) cout<<\"Stowawy\"<\n#include \n#include \n#include \n \n#define NDEBUG\n \nusing namespace std;\nusing namespace __gnu_pbds;\nusing namespace __gnu_cxx;\n \ntypedef long long ll;\ntypedef long double ld;\ntypedef complex cd;\n \ntypedef pair pi;\ntypedef pair pl;\ntypedef pair pd;\n \ntypedef vector vi;\ntypedef vector vd;\ntypedef vector vl;\ntypedef vector vpi;\ntypedef vector vpl;\ntypedef vector vcd;\n \ntemplate using Tree = tree, rb_tree_tag,tree_order_statistics_node_update>;\n \n#define FOR(i, a, b) for (int i = (a); i < (b); i++)\n#define F0R(i, a) for (int i = 0; i < (a); i++)\n#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)\n#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)\n#define trav(a, x) for (auto& a : x)\n \n#define mp make_pair\n#define pb push_back\n#define f first\n#define s second\n#define lb lower_bound\n#define ub upper_bound\n \n#define sz(x) (int)x.size()\n#define all(x) begin(x), end(x)\n#define rsz resize\n \nconst int MOD = 1000000007; // 998244353\nconst ll INF = 1e18;\nconst int MX = 200005;\nconst ld PI = 4*atan((ld)1);\n \ntemplate void ckmin(T &a, T b) { a = min(a, b); }\ntemplate void ckmax(T &a, T b) { a = max(a, b); }\n \nnamespace input {\n template void re(complex& x);\n template void re(pair& p);\n template void re(vector& a);\n template void re(array& a);\n \n template void re(T& x) { cin >> x; }\n void re(double& x) { string t; re(t); x = stod(t); }\n void re(ld& x) { string t; re(t); x = stold(t); }\n template void re(Arg& first, Args&... rest) { \n re(first); re(rest...); \n }\n \n template void re(complex& x) { T a,b; re(a,b); x = cd(a,b); }\n template void re(pair& p) { re(p.f,p.s); }\n template void re(vector& a) { F0R(i,sz(a)) re(a[i]); }\n template void re(array& a) { F0R(i,SZ) re(a[i]); }\n}\n \nusing namespace input;\n \nnamespace output {\n template void pr(const pair& x);\n template void pr(const array& x);\n template void pr(const vector& x);\n template void pr(const set& x);\n template void pr(const map& x);\n \n template void pr(const T& x) { cout << x; }\n template void pr(const Arg& first, const Args&... rest) { \n pr(first); pr(rest...); \n }\n \n template void pr(const pair& x) { \n pr(\"{\",x.f,\", \",x.s,\"}\"); \n }\n template void prContain(const T& x) {\n pr(\"{\");\n bool fst = 1; for (const auto& a: x) pr(!fst?\", \":\"\",a), fst = 0; // const needed for vector\n pr(\"}\");\n }\n template void pr(const array& x) { prContain(x); }\n template void pr(const vector& x) { prContain(x); }\n template void pr(const set& x) { prContain(x); }\n template void pr(const map& x) { prContain(x); }\n \n void ps() { pr(\"\\n\"); }\n template void ps(const Arg& first) { \n pr(first); ps(); // no space at end of line\n }\n template void ps(const Arg& first, const Args&... rest) { \n pr(first,\" \"); ps(rest...); // print w/ spaces\n }\n}\n \nusing namespace output;\n \nnamespace io {\n void setIn(string s) { freopen(s.c_str(),\"r\",stdin); }\n void setOut(string s) { freopen(s.c_str(),\"w\",stdout); }\n void setIO(string s = \"\") {\n ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O\n if (sz(s)) { setIn(s+\".in\"), setOut(s+\".out\"); } // for USACO\n }\n}\n \nusing namespace io;\n \ntemplate T invGeneral(T a, T b) {\n a %= b; if (a == 0) return b == 1 ? 0 : -1;\n T x = invGeneral(b,a); \n return x == -1 ? -1 : ((1-(ll)b*x)/a+b)%b;\n}\n \ntemplate struct modular {\n T val; \n explicit operator T() const { return val; }\n modular() { val = 0; }\n template modular(const U& v) {\n val = (-MOD <= v && v <= MOD) ? v : v % MOD;\n if (val < 0) val += MOD;\n }\n friend ostream& operator<<(ostream& os, const modular& a) { return os << a.val; }\n friend bool operator==(const modular& a, const modular& b) { return a.val == b.val; }\n friend bool operator!=(const modular& a, const modular& b) { return !(a == b); }\n \n modular operator-() const { return modular(-val); }\n modular& operator+=(const modular& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }\n modular& operator-=(const modular& m) { if ((val -= m.val) < 0) val += MOD; return *this; }\n modular& operator*=(const modular& m) { val = (ll)val*m.val%MOD; return *this; }\n friend modular exp(modular a, ll p) {\n modular ans = 1; for (; p; p /= 2, a *= a) if (p&1) ans *= a;\n return ans;\n }\n friend modular inv(const modular& a) { \n auto i = invGeneral(a.val,MOD); // assert(i != -1);\n return i;\n } // equivalent to return exp(b,MOD-2) if MOD is prime\n modular& operator/=(const modular& m) { return (*this) *= inv(m); }\n \n friend modular operator+(modular a, const modular& b) { return a += b; }\n friend modular operator-(modular a, const modular& b) { return a -= b; }\n friend modular operator*(modular a, const modular& b) { return a *= b; }\n \n friend modular operator/(modular a, const modular& b) { return a /= b; }\n};\n \ntypedef modular mi;\ntypedef pair pmi;\ntypedef vector vmi;\ntypedef vector vpmi;\n \ntypedef ld T;\n \nconst T EPS = 1e-9;\n \nnamespace Point {\n typedef pair P;\n typedef vector

    vP;\n \n P dir(T ang) {\n auto c = exp(ang*complex(0,1));\n return P(c.real(),c.imag());\n }\n \n T norm(P x) { return x.f*x.f+x.s*x.s; }\n T abs(P x) { return sqrt(norm(x)); }\n T angle(P x) { return atan2(x.s,x.f); }\n P conj(P x) { return P(x.f,-x.s); }\n \n P operator+(const P& l, const P& r) { return P(l.f+r.f,l.s+r.s); }\n P operator-(const P& l, const P& r) { return P(l.f-r.f,l.s-r.s); }\n P operator*(const P& l, const T& r) { return P(l.f*r,l.s*r); }\n P operator*(const T& l, const P& r) { return r*l; }\n P operator/(const P& l, const T& r) { return P(l.f/r,l.s/r); }\n P operator*(const P& l, const P& r) { return P(l.f*r.f-l.s*r.s,l.s*r.f+l.f*r.s); }\n P operator/(const P& l, const P& r) { return l*conj(r)/norm(r); }\n \n P& operator+=(P& l, const P& r) { return l = l+r; }\n P& operator-=(P& l, const P& r) { return l = l-r; }\n P& operator*=(P& l, const T& r) { return l = l*r; }\n P& operator/=(P& l, const T& r) { return l = l/r; }\n P& operator*=(P& l, const P& r) { return l = l*r; }\n P& operator/=(P& l, const P& r) { return l = l/r; }\n \n P unit(P x) { return x/abs(x); }\n T dot(P a, P b) { return (conj(a)*b).f; }\n T cross(P a, P b) { return (conj(a)*b).s; }\n T cross(P p, P a, P b) { return cross(a-p,b-p); }\n T dist(P p, P a, P b) { return std::abs(cross(p,a,b))/abs(a-b); }\n \n P rotate(P a, T b) { return a*P(cos(b),sin(b)); }\n P reflect(P p, P a, P b) { return a+conj((p-a)/(b-a))*(b-a); }\n P foot(P p, P a, P b) { return (p+reflect(p,a,b))/(T)2; }\n P extension(P a, P b, P c, P d) {\n T x = cross(a,b,c), y = cross(a,b,d);\n return (d*x-c*y)/(x-y);\n }\n // computes the intersection of line segments AB, CD\n // verification: https://open.kattis.com/problems/segmentintersection\n vP segIntersect(P a, P b, P c, P d) {\n if (a > b) swap(a,b);\n if (c > d) swap(c,d);\n \n auto a1 = cross(a,b,c), a2 = cross(a,b,d);\n if (a1 > a2) swap(a1,a2);\n if (!(a1 <= 0 && a2 >= 0)) return {};\n \n if (a1 == 0 && a2 == 0) {\n if (cross(a,c,d) != 0) return {};\n auto x1 = max(a,c), x2 = min(b,d);\n if (x1 > x2) return {};\n if (x1 == x2) return {x1};\n return {x1,x2};\n }\n \n auto z = extension(a,b,c,d);\n if (a <= z && z <= b) return {z};\n return {};\n }\n \n // sorts points according to atan2\n // verification: ?\n template int half(pair x) { return mp(x.s,x.f) > mp((T)0,(T)0); }\n bool cmp(P a, P b) { \n int A = half(a), B = half(b);\n if (A != B) return A < B;\n return cross(a,b) > 0;\n }\n \n // computes the center of mass of a polygon with constant mass per unit area\n // verification: kattis polygonarea, VT HSPC 2018 Holiday Stars\n T area(const vP& v) {\n T area = 0;\n F0R(i,sz(v)) {\n int j = (i+1)%sz(v); T a = cross(v[i],v[j]);\n area += a;\n }\n return area/2;\n }\n P centroid(const vP& v) { \n P cen(0,0); T area = 0; // 2*signed area\n F0R(i,sz(v)) {\n int j = (i+1)%sz(v); T a = cross(v[i],v[j]);\n cen += a*(v[i]+v[j]); area += a;\n }\n return cen/area/(T)3;\n }\n \n // tests whether a point is inside, on, or outside the perimeter of any polygon\n // verification: https://open.kattis.com/problems/pointinpolygon\n string inPoly(const vP& p, P z) {\n int n = sz(p), ans = 0;\n F0R(i,n) {\n P x = p[i], y = p[(i+1)%n];\n if (cross(x,y,z) == 0 && min(x,y) <= z && z <= max(x,y)) return \"on\";\n if (x.s > y.s) swap(x,y);\n if (x.s <= z.s && y.s > z.s && cross(z,x,y) > 0) ans ^= 1;\n }\n return ans ? \"in\" : \"out\";\n }\n \n pair ccCenter(P a, P b, P c) { // circumcenter\n b -= a; c -= a;\n P res = b*c*(conj(c)-conj(b))/(b*conj(c)-conj(b)*c);\n return {a+res,abs(res)};\n }\n \n pair mec(vP ps) { // minimum enclosing circle, ex. USACO Camp 2019 Contest 2 #4\n shuffle(all(ps), mt19937(time(0)));\n P o = ps[0]; double r = 0, EPS = 1 + 1e-8;\n F0R(i,sz(ps)) if (abs(o-ps[i]) > r*EPS) {\n o = ps[i], r = 0;\n F0R(j,i) if (abs(o-ps[j]) > r*EPS) {\n o = (ps[i]+ps[j])/2, r = abs(o-ps[i]);\n F0R(k,j) if (abs(o-ps[k]) > r*EPS) \n tie(o,r) = ccCenter(ps[i],ps[j],ps[k]);\n }\n }\n return {o,r};\n }\n};\n \nusing namespace Point;\n \nvoid inp(vP& v) {\n int x; re(x); v.rsz(x); re(v);\n}\n \nbool ccw(P a, P b, P c) {\n return cross(a,b,c) > 0;\n}\n \nvector triangulate(vP v) {\n if (sz(v) <= 2) return {};\n /*ps(\"HUH\",area(v));\n int co = 0;\n trav(t,v) ps(t.f,t.s,co++);\n ps();*/\n F0R(i,sz(v)) {\n P a = v[i], b = v[(i+1)%sz(v)], c = v[(i+2)%sz(v)];\n if (ccw(a,b,c)) {\n bool bad = 0;\n trav(t,v) if (cross(a,b,t) > 0 && cross(b,c,t) > 0 && cross(c,a,t) > 0) \n bad = 1;\n if (!bad) {\n auto V = v; V.erase(V.begin()+((i+1)%sz(v)));\n auto t = triangulate(V); t.pb({a,b,c});\n return t;\n }\n }\n }\n ps(\"BAD\",v,ccw(v[0],v[1],v[2])); exit(0);\n exit(5);\n}\n \nvector v;\nvP EN;\nvector active;\n \nvoid outp(vP& v) {\n pr(sz(v),' ');\n trav(t,v) pr(t.f,' ',t.s,' ');\n ps();\n}\n \nvoid init() {\n setIO(); cout << fixed << setprecision(12);\n v.rsz(1); inp(v[0]);\n active.pb(1);\n inp(EN); \n}\n \n \nbool close(ld a, ld b) { return abs(a-b) <= EPS || min(abs(a),abs(b))/max(abs(a),abs(b)) >= 1-EPS; }\n \nvoid scissors(int id, vector z) {\n // assert(id < sz(active) && active[id]);\n ps(\"scissors\");\n ps(id,sz(z));\n active[id] = 0;\n ld tot = area(v[id]); // assert(tot > 0);\n trav(t,z) {\n tot -= area(t);\n outp(t);\n v.pb(t), active.pb(1);\n }\n // assert(abs(tot) <= EPS);\n}\n \nvoid testEquiv(vP a, vP b) {\n if (sz(a) != sz(b) || !close(area(a),area(b))) {\n ps(\"NOT EQUIV 1\",area(a),area(b));\n ps(a);\n ps(b);\n exit(0);\n }\n F0R(i,sz(a)) {\n ld x = abs(a[i]-a[(i+1)%sz(a)]);\n ld y = abs(b[i]-b[(i+1)%sz(b)]);\n if (!close(x,y)) {\n ps(\"NOT EQUIV\");\n ps(a); ps(b);\n exit(0);\n }\n }\n}\nint tape(vi id, vector c, vP z) {\n ps(\"tape\");\n pr(sz(id),' '); \n ld tot = 0;\n F0R(i,sz(id)) {\n int t = id[i];\n // assert(active[t]); active[t] = 0;\n pr(t,' ');\n \n testEquiv(v[t],c[i]);\n tot += area(v[t]);\n }\n ps();\n trav(t,c) outp(t);\n outp(z);\n v.pb(z), active.pb(1); \n tot -= area(z);\n //// assert(abs(tot) <= EPS);\n return sz(active)-1;\n}\n \nset done;\n \nvP nor(vP V) {\n // ps(\"NOR\");\n auto ori = V;\n // assert(sz(V) == 3);\n ld mx = max(abs(V[0]-V[1]),max(abs(V[1]-V[2]),abs(V[2]-V[0])));\n if (mx == abs(V[1]-V[2])) rotate(V.begin(),V.begin()+1,V.end());\n else if (mx == abs(V[2]-V[0])) rotate(V.begin(),V.begin()+2,V.end());\n FOR(i,1,3) V[i] -= V[0];\n V[0] = P(0,0);\n \n P x = P(abs(V[1]),0)/V[1];\n V[1] *= x, V[2] *= x; \n \n //// assert(0 <= V[2].f && V[2].f <= V[1].f);\n //// assert(close(V[0].s,0) && close(V[1].s,0) && V[2].s > 0);\n return V;\n}\n \nld equiv(vP a, vP b) {\n // assert(sz(a) == 3 && sz(b) == 3);\n ld dif = 0;\n F0R(i,3) {\n ld A = abs(a[i]-a[(i+1)%3]);\n ld B = abs(b[i]-b[(i+1)%3]);\n dif += abs(A-B);\n }\n return dif;\n}\n \nint same(int id, vP V) {\n ld dif0 = equiv(v[id],{V[0],V[1],V[2]});\n ld dif1 = equiv(v[id],{V[1],V[2],V[0]});\n ld dif2 = equiv(v[id],{V[2],V[0],V[1]});\n ld mn = min(dif0,min(dif1,dif2));\n if (dif0 == mn) id = tape({id},{{V[0],V[1],V[2]}},V);\n else if (dif1 == mn) id = tape({id},{{V[1],V[2],V[0]}},V);\n else id = tape({id},{{V[2],V[0],V[1]}},V);\n return id;\n}\n \nld totArea,BLOCK;\n \nint adjust(int id, ld dx, ld dy) {\n while (v[id][1].f >= 2*dx) {\n auto x = v[id][1].f, y = v[id][2].s;\n scissors(id,{{{0,0},{x/2,0},{x/2,y},{0,y}},\n {{x/2,0},{x,0},{x,y},{x/2,y}}});\n id = tape({sz(active)-2,sz(active)-1},{\n {{0,0},{x/2,0},{x/2,y},{0,y}},\n {{0,y},{x/2,y},{x/2,2*y},{0,2*y}}\n },{{0,0},{x/2,0},{x/2,2*y},{0,2*y}});\n }\n if (v[id][1].f > dx) {\n auto x = v[id][1].f, y = v[id][2].s; \n swap(dx,x); swap(dy,y); // // assert(y > dy);\n // ps(\"??\",v[id],dx,dy);\n scissors(id,{\n {{{0,0},{x,0},{x,y-dy},{dx-x,dy},{0,dy}},\n {{x,0},{dx,0},{x,y-dy}},\n {{dx,0},{dx,dy},{dx-x,dy}}}\n });\n id = tape({sz(active)-3,sz(active)-2,sz(active)-1},\n {{{0,0},{x,0},{x,y-dy},{dx-x,dy},{0,dy}},\n {{0,dy},{dx-x,dy},{0,y}},\n {{x,y-dy},{x,y},{0,y}}},\n {{0,0},{x,0},{x,y},{0,y}}\n );\n swap(dx,x); swap(dy,y); \n }\n\twhile (2*v[id][1].f <= dx) {\n auto x = v[id][1].f, y = v[id][2].s;\n scissors(id,{{{0,0},{x,0},{x,y/2},{0,y/2}},\n {{0,y/2},{x,y/2},{x,y},{0,y}}});\n id = tape({sz(active)-2,sz(active)-1},{\n {{0,0},{x,0},{x,y/2},{0,y/2}},\n {{x,0},{2*x,0},{2*x,y/2},{x,y/2}}\n },{{0,0},{2*x,0},{2*x,y/2},{0,y/2}});\n\t}\n\tif (v[id][1].f < dx) {\n auto x = v[id][1].f, y = v[id][2].s;\n scissors(id,{\n {{0,0},{x,0},{x,y-dy},{dx-x,dy},{0,dy}},\n {{0,dy},{dx-x,dy},{0,y}},\n {{x,y-dy},{x,y},{0,y}}\n });\n id = tape({sz(active)-3,sz(active)-2,sz(active)-1},{\n {{0,0},{x,0},{x,y-dy},{dx-x,dy},{0,dy}},\n {{x,0},{dx,0},{x,y-dy}},\n {{dx,0},{dx,dy},{dx-x,dy}}},\n {{0,0},{dx,0},{dx,dy},{0,dy}}\n );\n\t}\n\treturn id;\n}\n \nint makeRect(int id) {\n //ps(\"MAKE RECT\",id);\n auto V = nor(v[id]); id = same(id,V);\n \n vector w;\n P mid = P(V[2].f,V[2].s/2);\n w.pb({V[0],V[1],(V[1]+V[2])/2,(V[2]+V[0])/2});\n w.pb({(V[1]+V[2])/2,V[2],mid});\n w.pb({V[2],(V[2]+V[0])/2,mid});\n scissors(id,w);\n \n id = tape({sz(active)-3,sz(active)-2,sz(active)-1},\n {w[0],{(V[1]+V[2])/2,V[1],P(V[1].f,mid.s)},{V[0],(V[0]+V[2])/2,P(V[0].f,mid.s)}},\n {V[0],V[1],P(V[1].f,mid.s),P(V[0].f,mid.s)});\n \n //ps(\"ADJUST RECT\");\n id = adjust(id,BLOCK,area(V)/BLOCK);\n return id;\n}\n \nint makeTri(int id, vP des) {\n\tauto V = nor(des);\n\tid = adjust(id,V[1].f,V[2].s/2);\n\t// assert(abs(v[id][1].f-V[1].f) <= EPS);\n P mid = P(V[2].f,V[2].s/2);\n vector w = {{V[0],V[1],(V[1]+V[2])/2,(V[2]+V[0])/2},\n {(V[1]+V[2])/2,V[1],P(V[1].f,mid.s)},\n {(V[0]+V[2])/2,P(V[0].f,mid.s),V[0]}};\n scissors(id,w);\n id = tape({sz(active)-3,sz(active)-2,sz(active)-1},\n {w[0],{(V[1]+V[2])/2,V[2],mid},{(V[2]+V[0])/2,mid,V[2]}},\n {V[0],V[1],V[2]});\n\tid = same(id,des); return id;\n}\n \nint main() {\n init();\n auto t0 = triangulate(v[0]), t1 = triangulate(EN);\n totArea = area(v[0]); BLOCK = sqrt(totArea);\n scissors(0,t0);\n \n ld totY = 0; int lst = -1;\n FOR(i,1,sz(t0)+1) {\n int t = makeRect(i); // assert(v[t][0] == P(0,0)); // assert(close(v[t][1].f,BLOCK));\n ld y = v[t][2].s;\n if (lst == -1) lst = t;\n else {\n lst = tape({lst,t},\n \t\t{v[lst],{{0,totY},{BLOCK,totY},{BLOCK,totY+y},{0,totY+y}}},\n \t\t{{0,0},{BLOCK,0},{BLOCK,totY+y},{0,totY+y}});\n lst = sz(active)-1;\n }\n totY += y;\n }\n vi sol;\n F0R(i,sz(t1)) {\n int id = -1;\n if (i == sz(t1)-1) {\n id = lst;\n } else {\n ld z = area(t1[i])/BLOCK; // assert(z > 0);\n scissors(lst,{{{0,0},{BLOCK,0},{BLOCK,totY-z},{0,totY-z}},\n {{0,totY-z},{BLOCK,totY-z},{BLOCK,totY},{0,totY}}});\n lst = sz(active)-2; id = sz(active)-1; totY -= z;\n vP des = {{0,0},{BLOCK,0},{BLOCK,z},{0,z}};\n id = tape({id},{des},des);\n }\n sol.pb(makeTri(id,t1[i]));\n }\n vector SOL; trav(t,sol) SOL.pb(v[t]);\n tape(sol,SOL,EN);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b5ae629be287777bc386e09c878efa46", "src_uid": "375b83d1b7a911c1ca67d5209d39adb4", "difficulty": null} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntemplateconstexpr int sz(const C&c){return int(c.size());}\nusing ll=long long;constexpr const char nl='\\n',sp=' ';\n\nusing ld = long double;\nconst ld EPS = 1e-9;\nusing Point = pair;\n#define x first\n#define y second\nusing Polygon = pair>;\n#define index first\n#define points second\nusing Group = vector;\nusing Operation = pair;\nusing Sequence = vector;\n#define input first\n#define output second\n\ntemplate bool lt(const T &a, const T &b) { return a < b - T(EPS); }\ntemplate bool le(const T &a, const T &b) { return !lt(b, a); }\ntemplate bool gt(const T &a, const T &b) { return lt(b, a); }\ntemplate bool ge(const T &a, const T &b) { return !lt(a, b); }\ntemplate bool eq(const T &a, const T &b) { return !lt(a, b) && !lt(b, a); }\ntemplate bool ne(const T &a, const T &b) { return lt(a, b) || lt(b, a); }\n\nbool ltX(const Point &a, const Point &b) {\n return lt(a.x, b.x);\n}\n\nbool ltY(const Point &a, const Point &b) {\n return lt(a.y, b.y);\n}\n\nbool eqPoint(const Point &a, const Point &b) {\n return eq(a.x, b.x) && eq(a.y, b.y);\n}\n\nld dist(const Point &a, const Point &b) {\n ld dx = a.x - b.x, dy = a.y - b.y;\n return sqrt(dx * dx + dy * dy);\n}\n\nint ccw(const Point &a, const Point &b, const Point &c) {\n ld a2 = (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);\n if (lt(a2, ld(0))) return -1;\n else if (gt(a2, ld(0))) return +1;\n else return 0;\n}\n\nld area2(const Point &a, const Point &b, const Point &c) {\n return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);\n}\n\nld area2(const Polygon &P) {\n ld ret = 0;\n for (int i = 0; i < sz(P.points); i++) ret += area2(Point(0, 0), P.points[i], P.points[(i + 1) % sz(P.points)]);\n return ret;\n}\n\nbool onSegment(const Point &p, const Point &a, const Point &b) {\n return eq(dist(p, a) + dist(p, b), dist(a, b));\n}\n\nbool lineSegmentIntersects(const Point &a, const Point &b, const Point &p, const Point &q) {\n int o1 = ccw(a, b, p), o2 = ccw(a, b, q), o3 = ccw(p, q, a), o4 = ccw(p, q, b);\n if (o1 != o2 && o3 != o4) return true;\n if (o1 == 0 && onSegment(p, a, b)) return true;\n if (o2 == 0 && onSegment(p, a, b)) return true;\n if (o3 == 0 && onSegment(p, p, q)) return true;\n if (o4 == 0 && onSegment(p, p, q)) return true;\n return false;\n}\n\nSequence reverseSeq(const Sequence &seq) {\n Sequence ret(seq);\n reverse(ret.begin(), ret.end());\n for (auto &&op : ret) op.input.swap(op.output);\n return ret;\n}\n\nint index = 1;\n\nPolygon makeRect(ld minX, ld minY, ld maxX, ld maxY) {\n Polygon r;\n r.index = index++;\n r.points.emplace_back(minX, minY);\n r.points.emplace_back(maxX, minY);\n r.points.emplace_back(maxX, maxY);\n r.points.emplace_back(minX, maxY);\n return r;\n}\n\nSequence rectToSquare(const Polygon &src, const Polygon &square) {\n Sequence seq;\n ld minX = min_element(src.points.begin(), src.points.end(), ltX)->x;\n ld maxX = max_element(src.points.begin(), src.points.end(), ltX)->x;\n ld minY = min_element(src.points.begin(), src.points.end(), ltY)->y;\n ld maxY = max_element(src.points.begin(), src.points.end(), ltY)->y;\n ld curWidth = maxX - minX;\n ld curHeight = maxY - minY;\n ld len = square.points[2].x;\n Polygon st = src;\n for (auto &&p : st.points) {\n p.x -= minX;\n p.y -= minY;\n }\n Polygon cur = makeRect(0, 0, curWidth, curHeight);\n seq.emplace_back(Group{st}, Group{cur});\n if (lt(curWidth, curHeight)) {\n swap(curWidth, curHeight);\n Polygon rot1 = makeRect(0, 0, curWidth, curHeight);\n Polygon rot2 = rot1;\n rot1.index = cur.index;\n rotate(rot1.points.begin(), rot1.points.begin() + 3, rot1.points.end());\n seq.emplace_back(Group{rot1}, Group{rot2});\n cur = rot2;\n }\n while (gt(curWidth, 2 * len)) {\n Polygon left = makeRect(0, 0, curWidth / 2, curHeight);\n Polygon right = makeRect(curWidth / 2, 0, curWidth, curHeight);\n seq.emplace_back(Group{cur}, Group{left, right});\n curWidth /= 2;\n curHeight *= 2;\n cur = makeRect(0, 0, curWidth, curHeight);\n Polygon bottom = makeRect(0, 0, curWidth, curHeight / 2);\n bottom.index = left.index;\n Polygon top = makeRect(0, curHeight / 2, curWidth, curHeight);\n top.index = right.index;\n seq.emplace_back(Group{bottom, top}, Group{cur});\n }\n if (ne(curWidth, len)) {\n Point p(len, curHeight);\n Point q(curWidth - len, 0);\n Point r(curWidth - len, len - curHeight);\n Polygon a{index++, {cur.points[0], q, r}};\n Polygon b{index++, {cur.points[0], p, cur.points[3]}};\n Polygon c{index++, {q, cur.points[1], cur.points[2], p, r}};\n seq.emplace_back(Group{cur}, Group{a, b, c});\n cur = makeRect(0, 0, len, len);\n p = Point(0, len - curHeight);\n q = Point(len, curHeight);\n r = Point(len - (curWidth - len), curHeight);\n Polygon d{a.index, {r, q, cur.points[2]}};\n Polygon e{b.index, {p, cur.points[2], cur.points[3]}};\n Polygon f{c.index, {cur.points[0], cur.points[1], q, r, p}};\n seq.emplace_back(Group{d, e, f}, Group{cur});\n }\n seq.emplace_back(Group{cur}, Group{square});\n return seq;\n}\n\nSequence rectToRect(const Polygon &src, const Polygon &target) {\n ld len = sqrt(area2(src) / 2);\n Polygon square = makeRect(0, 0, len, len);\n Sequence A = rectToSquare(src, square), B = reverseSeq(rectToSquare(target, square));\n A.insert(A.end(), B.begin(), B.end());\n return A;\n}\n\npair triToArbRect(const Polygon &tri) {\n Sequence seq;\n vector lens;\n for (int i = 0; i < sz(tri.points); i++) lens.push_back(dist(tri.points[i], tri.points[(i + 1) % sz(tri.points)]));\n int ind = max_element(lens.begin(), lens.end(), lt) - lens.begin();\n ld base = lens[ind], height = area2(tri) / base;\n ld tx = lens[(ind + sz(lens) - 1) % sz(lens)];\n tx = sqrt(tx * tx - height * height);\n Polygon st;\n st.index = tri.index;\n st.points.emplace_back(0, 0);\n st.points.emplace_back(base, 0);\n st.points.emplace_back(tx, height);\n Polygon cur = st;\n cur.index = index++;\n rotate(st.points.begin(), st.points.begin() + (sz(st.points) - ind) % sz(st.points), st.points.end());\n seq.emplace_back(Group{st}, Group{cur});\n ld base1 = tx / 2, base2 = (base - tx) / 2;\n Point p(tx - base1, height / 2);\n Point q(tx, height / 2);\n Point r(tx + base2, height / 2);\n Polygon a{index++, {p, q, cur.points[2]}};\n Polygon b{index++, {q, r, cur.points[2]}};\n Polygon c{index++, {cur.points[0], cur.points[1], r, p}};\n seq.emplace_back(Group{cur}, Group{a, b, c});\n cur = makeRect(0, 0, base, height / 2);\n p = Point(base1, height / 2);\n r = Point(base - base2, height / 2);\n Polygon d{a.index, {p, cur.points[3], cur.points[0]}};\n Polygon e{b.index, {cur.points[2], r, cur.points[1]}};\n Polygon f{c.index, {cur.points[0], cur.points[1], r, p}};\n seq.emplace_back(Group{d, e, f}, Group{cur});\n return make_pair(seq, cur);\n}\n\nSequence triToSquare(const Polygon &src, const Polygon &target) {\n Sequence A, B;\n Polygon rect;\n tie(A, rect) = triToArbRect(src);\n B = rectToSquare(rect, target);\n A.insert(A.end(), B.begin(), B.end());\n return A;\n}\n\nbool inside(const Point &a, const Point &b, const Polygon &P) {\n for (int i = 0; i < sz(P.points); i++) {\n Point p = P.points[i], q = P.points[(i + 1) % sz(P.points)];\n if (eqPoint(a, p) || eqPoint(a, q) || eqPoint(b, p) || eqPoint(b, q)) continue;\n if (lineSegmentIntersects(a, b, p, q)) return false;\n }\n Point mid((a.x + b.x) / 2, (a.y + b.y) / 2);\n for (int i = 0; i < sz(P.points); i++) {\n Point p = P.points[i], q = P.points[(i + 1) % sz(P.points)];\n if (onSegment(mid, p, q)) return true;\n }\n Point c(mid.x, mid.y), d(1e9, mid.y);\n int cnt = 0;\n for (int i = 0; i < sz(P.points); i++) {\n Point p = P.points[i], q = P.points[(i + 1) % sz(P.points)];\n cnt += lineSegmentIntersects(c, d, p, q);\n }\n return cnt % 2 == 1;\n}\n\npair polyToArbSquare(const Polygon &P) {\n Sequence seq;\n Group tris;\n Polygon cur = P;\n while (sz(cur.points) > 2) {\n for (int i = 0; i < sz(cur.points); i++) {\n Point p = cur.points[i], q = cur.points[(i + 1) % sz(cur.points)], r = cur.points[(i + 2) % sz(cur.points)];\n if (ccw(p, q, r) == 1 && inside(p, r, cur)) {\n tris.emplace_back(index++, vector{p, q, r});\n cur.points.erase(cur.points.begin() + (i + 1) % sz(cur.points));\n break;\n }\n }\n }\n seq.emplace_back(Group{P}, tris);\n Polygon merged;\n merged.index = -1;\n ld totArea = 0;\n for (auto &&tri : tris) {\n ld a = area2(tri) / 2, len = sqrt(a);\n totArea += a;\n Polygon square = makeRect(0, 0, len, len);\n Sequence A = triToSquare(tri, square);\n seq.insert(seq.end(), A.begin(), A.end());\n if (merged.index == -1) merged = square;\n else {\n ld len = sqrt(totArea);\n Polygon bottom = makeRect(0, 0, len, a / len);\n Polygon top = makeRect(0, a / len, len, totArea / len);\n Sequence B = reverseSeq(rectToSquare(bottom, square)), C = reverseSeq(rectToSquare(top, merged));\n seq.insert(seq.end(), B.begin(), B.end());\n seq.insert(seq.end(), C.begin(), C.end());\n merged = makeRect(0, 0, len, len);\n seq.emplace_back(Group{bottom, top}, Group{merged});\n }\n }\n return make_pair(seq, merged);\n}\n\nSequence polyToPoly(const Polygon &src, const Polygon &target) {\n Sequence A, B;\n Polygon SA, SB;\n tie(A, SA) = polyToArbSquare(src);\n tie(B, SB) = polyToArbSquare(target);\n B = reverseSeq(B);\n A.emplace_back(Group{SA}, Group{SB});\n A.insert(A.end(), B.begin(), B.end());\n return A;\n}\n\nPolygon readPolygon() {\n Polygon ret;\n ret.index = index++;\n int k;\n cin >> k;\n for (int i = 0; i < k; i++) {\n int x, y;\n cin >> x >> y;\n ret.points.emplace_back(x, y);\n }\n return ret;\n}\n\nvoid writeSeq(const Polygon &S, const Sequence &seq) {\n vector indexToId(index, -1);\n int curId = 0;\n auto addId = [&] (const Polygon &P) {\n return indexToId[P.index] = curId++;\n };\n auto removeId = [&] (const Polygon &P) {\n int ret = indexToId[P.index];\n assert(ret != -1);\n indexToId[P.index] = -1;\n return ret;\n };\n auto writePolygon = [&] (const Polygon &P) {\n cout << sz(P.points);\n for (auto &&p : P.points) cout << sp << fixed << setprecision(9) << p.x << sp << p.y;\n cout << nl;\n };\n auto writeOp = [&] (const Operation &op) {\n if (sz(op.output) == 1) {\n cout << \"tape\" << nl;\n cout << sz(op.input);\n for (auto &&P : op.input) cout << sp << removeId(P);\n cout << nl;\n for (auto &&P : op.input) writePolygon(P);\n writePolygon(op.output[0]);\n addId(op.output[0]);\n } else {\n cout << \"scissors\" << nl;\n cout << removeId(op.input[0]) << sp << sz(op.output) << nl;\n for (auto &&P : op.output) {\n writePolygon(P);\n addId(P);\n }\n }\n };\n addId(S);\n for (auto &&op : seq) writeOp(op);\n}\n\nint main() {\n // freopen(\"in.txt\", \"r\", stdin);\n // freopen(\"out.txt\", \"w\", stdout);\n // freopen(\"err.txt\", \"w\", stderr);\n ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n Polygon S = readPolygon(), T = readPolygon();\n Sequence A = polyToPoly(S, T);\n writeSeq(S, A);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1466c0fe44e7e1ed93780572907810ba", "src_uid": "375b83d1b7a911c1ca67d5209d39adb4", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\n#define range(i, m, n) for(int i = m; i < n; i++)\n#define husk(i, m, n) for(int i = m; i > n; i--)\n\ntemplate \nvoid debug_out(T t) {\n cerr << t;\n}\n\ntemplate \nvoid debug_out(pair u) {\n cerr << \"(\" << u.first << \" \" << u.second << \")\";\n}\n\ntemplate \nvoid debug_out(vector t) {\n int sz = t.size();\n for(int i = 0; i < sz; i++) {\n debug_out(t[i]);\n if(i != sz - 1) cerr << \", \";\n }\n}\n\ntemplate \nvoid debug_out(vector> t) {\n int sz = t.size();\n for(int i = 0; i < sz; i++) {\n debug_out(t[i]);\n if(i != sz - 1) cerr << endl;\n }\n}\n#define debug(...) cerr << \"[\" << #__VA_ARGS__ << \"]:\" << endl, debug_out(__VA_ARGS__), cerr << endl;\n\nstruct P {\n\tdouble x, y;\n\n\tP(){};\n\n\tP(double _x, double _y) : x(_x), y(_y){};\n\n\tP operator - (const P & b) const {\n return P{x - b.x, y - b.y};\n }\n\n P operator + (const P & b) const {\n return P{x + b.x, y + b.y};\n }\n\n P operator / (int a) {\n return P(x / a, y / a);\n }\n\n\tdouble operator * (const P & b) const {\n return x * b.y - y * b.x;\n }\n\n\tdouble cross(const P & b, const P & c) const {\n\t\treturn (b - *this) * (c - *this);\n\t}\n\n\tbool isRight() const {\n return x > 0 || (x == 0 && y > 0);\n }\n\n\tbool operator < (const P & b) const {\n\t\tif(isRight() != b.isRight())\n\t\t\treturn isRight();\n\t\treturn *this * b < 0;\n\t}\n};\n\nvoid debug_out(P a) {\n debug_out(make_pair(a.x, a.y));\n}\n\nstruct L2 {\n\tP one, two;\n\n\tL2(){};\n\n\tL2(P _one, P _two) : one(_one), two(_two){};\n\n\tP dir() const {\n return two - one;\n }\n\n\tbool operator < (const L2 & b) const {\n return dir() < b.dir();\n }\n\n\tlong double get_coeff(const L2 & b) const {\n\t\tlong double r = (b.dir() * (one - b.one)) / (long double) (dir() * b.dir());\n\t\treturn r;\n\t}\n\n\tbool isParallel(const L2 & b) const {\n return dir() * b.dir() == 0;\n }\n\n\tP intersect(const L2 & b) const {\n\t\tlong double r = get_coeff(b);\n\t\treturn P(one.x + r * (two - one).x, one.y + r * (two - one).y);\n\t}\n};\n\nP pr(P a, L2 d) {\n P b = d.one - d.two;\n P c = a + P(-b.y, b.x);\n L2 e(a, c);\n return e.intersect(d);\n}\n\ndouble dis(P a, P b) {\n P c = a - b;\n return sqrt(c.x * c.x + c.y * c.y);\n}\n\nstruct Poly {\n vector

    vs;\n int n, id;\n\n Poly(){};\n\n Poly(vector

    _vs, int _id = 0) : vs(_vs), id(_id) {\n n = vs.size();\n }\n\n void read() {\n cin >> n;\n for(int i = 0; i < n; i++) {\n int x, y;\n cin >> x >> y;\n vs.emplace_back(x, y);\n }\n }\n\n Poly shift(int t) {\n vector

    _vs(n);\n for(int i = 0; i < n; i++) {\n _vs[i] = vs[(i + t) % n];\n }\n return Poly(_vs);\n }\n\n Poly operator + (P a) {\n Poly u = *this;\n for(auto &i : u.vs) i = i + a;\n u.n = u.vs.size();\n return u;\n }\n\n void check() {\n for(auto i : vs) assert(min(abs(i.x), abs(i.y)) < 1e7);\n }\n};\n\nvoid debug_out(vector a) {\n vector> _a(a.size());\n for(int i = 0; i < (int) a.size(); i++) for(auto j : a[i].vs) _a[i].push_back(j);\n debug_out(_a);\n}\n\nvoid debug_out(Poly a) {\n debug_out(a.vs);\n}\n\ndouble S(Poly a) {\n double res = 0;\n range(i, 0, a.n) {\n res += a.vs[i] * a.vs[(i + 1) % a.n];\n }\n return abs(res / 2);\n}\n\nbool cross(P a, P b, P c, P d) {\n L2 u, v;\n u.one = a, u.two = b;\n v.one = c, v.two = d;\n if(u.isParallel(v)) return false;\n auto foo = u.intersect(v);\n double x = foo.x, y = foo.y;\n return x <= min(max(a.x, b.x), max(c.x, d.x)) && x >= max(min(a.x, b.x), min(c.x, d.x)) && y <= min(max(a.y, b.y), max(c.y, d.y)) && y >= max(min(a.y, b.y), min(c.y, d.y));\n};\n\nconst double inf = 1e7;\n\nvector triangulation(Poly u) {\n assert(u.n >= 3);\n vector res;\n if(u.n == 3) {\n res.push_back(u);\n return res;\n }\n int a = -1, b = -1;\n range(i, 0, u.n) {\n range(j, i + 1, u.n) {\n if(i == (j + 1) % u.n || j == (i + 1) % u.n) continue;\n P to_inf = P(inf, inf * sqrt(2));\n P to = (u.vs[i] + u.vs[j]) / 2;\n bool bad = false;\n int cnt = 0;\n range(x, 0, u.n) {\n cnt ^= cross(to, to_inf, u.vs[x], u.vs[(x + 1) % u.n]);\n if(x == i || x == j || (x + 1) % u.n == i || (x + 1) % u.n == j) continue;\n bad |= cross(u.vs[i], u.vs[j], u.vs[x], u.vs[(x + 1) % u.n]);\n }\n if(!bad && cnt) {\n a = i;\n b = j;\n break;\n }\n }\n if(~a && ~b) break;\n }\n assert(~a && ~b);\n vector

    l, r;\n for(int i = a; i <= b; i++) l.push_back(u.vs[i]);\n for(int i = b; i != (a + 1) % u.n; i = (i + 1) % u.n) r.push_back(u.vs[i]);\n vector add = triangulation(Poly(r));\n res = triangulation(l);\n for(auto i : add) res.push_back(i);\n return res;\n}\n\nint cnt = 1;\nint iter = 0;\n\nstruct query {\n int t;\n int k;\n vector B;\n Poly A;\n query(){};\n};\n\nvector res;\n\nvector split(Poly a, vector b) {\n query cc;\n cc.t = 0; cc.k = b.size(); cc.A = a;\n for(Poly &u : b) {\n u.id = cnt++;\n cc.B.push_back(u);\n iter += u.n;\n }\n res.push_back(cc);\n return b;\n}\n\nPoly joint(Poly a, vector b) {\n a.id = cnt++;\n query cc;\n cc.t = 1; cc.k = b.size(); cc.A = a;\n for(Poly u : b) {\n cc.B.push_back(u);\n }\n res.push_back(cc);\n iter += a.n;\n return a;\n}\n\nPoly trans(Poly a, Poly b) {\n b.id = cnt++;\n query cc;\n cc.t = 1; cc.k = 1; cc.A = b;\n cc.B.push_back(a);\n res.push_back(cc);\n iter += b.n;\n return b;\n}\n\nvoid out() {\n for(auto i : res) {\n if(!i.t) {\n printf(\"scissors\\n\");\n printf(\"%d %d\\n\", i.A.id, i.k);\n for(auto j : i.B) {\n printf(\"%d \", j.n);\n for(auto u : j.vs) printf(\"%.17g %.17g \", u.x, u.y);\n printf(\"\\n\");\n }\n } else {\n printf(\"tape\\n\");\n printf(\"%d \", i.k);\n for(auto j : i.B) printf(\"%d \", j.id);\n printf(\"\\n\");\n if(i.k == 1) {\n printf(\"%d \", i.A.n);\n for(auto j : i.A.vs) printf(\"%.17g %.17g \", j.x, j.y);\n printf(\"\\n\");\n } else {\n for(auto j : i.B) {\n printf(\"%d \", j.n);\n for(auto u : j.vs) printf(\"%.17g %.17g \", u.x, u.y);\n printf(\"\\n\");\n }\n }\n printf(\"%d \", i.A.n);\n for(auto j : i.A.vs) printf(\"%.17g %.17g \", j.x, j.y);\n printf(\"\\n\");\n }\n }\n}\n\nvoid rev() {\n reverse(res.begin(), res.end());\n for(auto &u : res) {\n u.A.id = cnt - 1 - u.A.id;\n for(auto &j : u.B) j.id = cnt - 1 - j.id;\n reverse(u.B.begin(), u.B.end());\n if(u.k == 1) swap(u.A, u.B[0]);\n else u.t = !u.t;\n }\n}\n\nPoly rect(Poly s) {\n assert(s.n == 3);\n int mx = 0;\n double d = dis(s.vs[1], s.vs[2]);\n range(i, 1, 3) {\n if(dis(s.vs[(i + 1) % 3], s.vs[(i + 2) % 3]) > d) {\n mx = i;\n d = dis(s.vs[(i + 1) % 3], s.vs[(i + 2) % 3]);\n }\n }\n P a = s.vs[mx], b = s.vs[(mx + 1) % 3], c = s.vs[(mx + 2) % 3];\n Poly u, v;\n u.vs = {b, c, (c + a) / 2, (a + b) / 2};\n u.n = 4;\n v.vs = {a, (a + b) / 2, (a + c) / 2};\n v.n = 3;\n vector foo = {u, v};\n foo = split(s, foo);\n u = foo[0], v = foo[1];\n Poly to;\n to.vs = {b, (a + b) / 2, (a + b - c + b) / 2};\n to.n = 3;\n to = trans(v, to);\n P p = pr(b, L2((a + b) / 2, (a + b - c + b) / 2));\n Poly l, r;\n l.vs = {b, (a + b) / 2, p}; r.vs = {b, p, (a + b - c + b) / 2};\n l.n = 3, r.n = 3;\n vector bar = {l, r};\n bar = split(to, bar);\n r = r + (c - b);\n r = trans(bar.back(), r);\n l = bar[0];\n Poly cc;\n cc.vs = {p, b, c, p + c - b};\n cc.n = 4;\n vector sc = {u, l, r};\n cc = joint(cc, sc);\n Poly _cc;\n _cc.vs = {P(0, 0), P(dis(b, p), 0), P(dis(b, p), dis(b, c)), P(0, dis(b, c))};\n _cc.n = 4;\n _cc = trans(cc, _cc);\n return _cc;\n}\n\nPoly x_fold(Poly a) {\n Poly u, v, to;\n u.vs = {(a.vs[0] + a.vs[3]) / 2, (a.vs[1] + a.vs[2]) / 2, a.vs[2], a.vs[3]}; u.n = 4;\n v.vs = {a.vs[0], a.vs[1], (a.vs[1] + a.vs[2]) / 2, (a.vs[0] + a.vs[3]) / 2}; v.n = 4;\n vector foo = {u, v};\n foo = split(a, foo);\n u = foo[0], v = foo[1];\n u = trans(u, u + (u.vs[1] - u.vs[3]));\n to.vs = {v.vs[0], u.vs[1], u.vs[2], v.vs[3]}; to.n = 4;\n foo.front() = u;\n return joint(to, foo);\n}\n\nPoly y_fold(Poly a) {\n Poly u, v, to;\n u.vs = {(a.vs[0] + a.vs[1]) / 2, a.vs[1], a.vs[2], (a.vs[2] + a.vs[3]) / 2}; u.n = 4;\n v.vs = {a.vs[0], (a.vs[0] + a.vs[1]) / 2, (a.vs[2] + a.vs[3]) / 2, a.vs[3]}; v.n = 4;\n vector foo = {u, v};\n foo = split(a, foo);\n u = foo[0], v = foo[1];\n u = trans(u, u + (u.vs[3] - u.vs[1]));\n foo.front() = u;\n to.vs = {v.vs[0], v.vs[1], u.vs[2], u.vs[3]}; to.n = 4;\n return joint(to, foo);\n}\n\nconst double ze = 1e-5;\n\nPoly rectangle(Poly a, Poly b) {\n Poly u = a, v = b;\n double ux = dis(u.vs[0], u.vs[1]), uy = dis(u.vs[0], u.vs[3]);\n double vx = dis(v.vs[0], v.vs[1]), vy = dis(v.vs[0], v.vs[3]);\n vector cons;\n while(vx > ze * 10) {\n while(ux > vx + (ze / 10)) {\n u = y_fold(u);\n ux /= 2;\n uy *= 2;\n }\n while(ux <= vx / 2 - (ze / 10)) {\n u = x_fold(u);\n ux *= 2;\n uy /= 2;\n }\n if(abs(ux - vx) + abs(uy - vy) < ze) break;\n Poly from, _u, to, _v;\n from.vs = {P(0, 0), P(ux, 0), P(ux, vy), P(0, vy)};\n to = from + v.vs[0];\n from = from + u.vs[0];\n from.n = 4; to.n = 4;\n _u.vs = {from.vs[3], from.vs[2], u.vs[2], u.vs[3]}; _u.n = 4;\n assert(u.vs[2].y > from.vs[2].y);\n _v.vs = {to.vs[1], v.vs[1], v.vs[2], to.vs[2]}; _v.n = 4;\n vector l = {from, _u};\n l = split(u, l);\n if(res.size() == 126) {\n debug(u);\n debug(l);\n }\n from = l[0], _u = l[1];\n to = trans(from, to);\n cons.push_back(to);\n v = _v; u = _u;\n ux = dis(u.vs[0], u.vs[1]), uy = dis(u.vs[0], u.vs[3]);\n vx = dis(v.vs[0], v.vs[1]), vy = dis(v.vs[0], v.vs[3]);\n }\n v = trans(u, u + (v.vs[0] - u.vs[0]));\n cons.push_back(v);\n return joint(b, cons);\n}\n\nvoid solve(Poly bar) {\n vector r = triangulation(bar);\n r = split(bar, r);\n for(auto &i : r) i = rect(i);\n double sum = S(bar);\n double a = sqrt(sum);\n Poly to;\n to.vs = {P(0, 0), P(a, 0), P(a, a), P(0, a)};\n vs = vs + P(-5e6, -5e6);\n to.n = 4;\n vector cc;\n double l = 0;\n for(auto i : r) {\n double len = S(i) / a;\n Poly ss;\n ss.n = 4;\n ss.vs = {P(l, 0), P(l + len, 0), P(l + len, a), P(l, a)};\n ss = ss + P(-5e6, -5e6);\n cc.push_back(rectangle(i, ss));\n l += len;\n }\n joint(to, cc);\n}\n\nvoid debug_out(query a) {\n debug_out(a.t);\n cerr << endl;\n debug_out(a.A);\n cerr << endl;\n debug_out(a.k);\n cerr << endl;\n debug_out(a.B);\n cerr << endl;\n debug_out(make_pair(dis(a.A.vs[0], a.A.vs[3]), dis(a.A.vs[0], a.A.vs[1])));\n cerr << endl;\n debug_out(make_pair(dis(a.B[0].vs[0], a.B[0].vs[3]), dis(a.B[0].vs[0], a.B[0].vs[1])));\n cerr << endl;\n debug_out(S(a.A));\n cerr << endl;\n debug_out(S(a.B[0]));\n}\n\nint main() {\n cerr.precision(15);\n Poly a, b;\n a.read(); b.read();\n a.id = 0; b.id = 0;\n solve(a);\n out();\n return 0;\n int _cnt = cnt;\n cnt = 1;\n res.clear();\n solve(b);\n rev();\n for(auto &i : res) {\n i.A.id += _cnt - 1;\n for(auto &j : i.B) j.id += _cnt - 1;\n }\n out();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0cf7392ed6e4060e06c3096bba8fc1f4", "src_uid": "375b83d1b7a911c1ca67d5209d39adb4", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\n#define range(i, m, n) for(int i = m; i < n; i++)\n#define husk(i, m, n) for(int i = m; i > n; i--)\n\nstruct P {\n long long x, y;\n int id;\n P operator - (const P & b) const {\n return P{x - b.x, y - b.y};\n }\n\n void operator += (const P & b) {\n x += b.x, y += b.y;\n }\n\n long long operator * (const P & b) const {\n return x * b.y - y * b.x;\n }\n\n long long cross(const P & b, const P & c) const {\n return (b - *this) * (c - *this);\n }\n\n bool isRight() const {\n return x > 0 || (x == 0 && y > 0);\n }\n\n bool operator < (const P & b) const {\n if(isRight() != b.isRight())\n return isRight();\n return *this * b < 0;\n }\n\n bool operator == (const P & b) const {\n return make_pair(x, y) == make_pair(b.x, b.y);\n }\n};\n\nstruct L2 {\n P one, two;\n P dir() const {\n return two - one;\n }\n //clockwise\n void arr() {\n if(one * two > 0) swap(one, two);\n }\n\n bool operator < (const L2 & b) const {\n return dir() < b.dir();\n }\n\n long double get_coeff(const L2 & b) const {\n long double r = (b.dir() * (one - b.one)) / (long double) (dir() * b.dir());\n return r;\n }\n\n bool isParallel(const L2 & b) const {\n return dir() * b.dir() == 0;\n }\n\n pair intersect(const L2 & b) const {\n long double r = get_coeff(b);\n return make_pair(one.x + r * (two - one).x, one.y + r * (two - one).y);\n }\n};\n\n\nP pr(P a, L2 d) {\n P b = d.one - d.two;\n P c = a + P(-b.y, b.x);\n L2 e(a, c);\n return e.intersect(d);\n}\n\ndouble dis(P a, P b) {\n P c = a - b;\n return sqrt(c.x * c.x + c.y * c.y);\n}\n\nstruct Poly {\n vector

    vs;\n int n, id;\n\n Poly(){};\n\n Poly(vector

    _vs, int _id = 0) : vs(_vs), id(_id) {\n n = vs.size();\n }\n\n void read() {\n cin >> n;\n for(int i = 0; i < n; i++) {\n int x, y;\n cin >> x >> y;\n vs.emplace_back(x, y);\n }\n }\n\n Poly shift(int t) {\n vector

    _vs(n);\n for(int i = 0; i < n; i++) {\n _vs[i] = vs[(i + t) % n];\n }\n return Poly(_vs);\n }\n\n Poly operator + (P a) {\n Poly u = *this;\n for(auto &i : u.vs) i = i + a;\n u.n = u.vs.size();\n return u;\n }\n\n};\n\ndouble S(Poly a) {\n double res = 0;\n range(i, 0, a.n) {\n res += a.vs[i] * a.vs[(i + 1) % a.n];\n }\n return abs(res / 2);\n}\n\nbool cross(P a, P b, P c, P d) {\n L2 u, v;\n u.one = a, u.two = b;\n v.one = c, v.two = d;\n if(u.isParallel(v)) return false;\n auto foo = u.intersect(v);\n double x = foo.x, y = foo.y;\n return x <= min(max(a.x, b.x), max(c.x, d.x)) && x >= max(min(a.x, b.x), min(c.x, d.x)) && y <= min(max(a.y, b.y), max(c.y, d.y)) && y >= max(min(a.y, b.y), min(c.y, d.y));\n};\n\nconst double inf = 1e7;\n\nvector triangulation(Poly u) {\n assert(u.n >= 3);\n vector res;\n if(u.n == 3) {\n res.push_back(u);\n return res;\n }\n int a = -1, b = -1;\n range(i, 0, u.n) {\n range(j, i + 1, u.n) {\n if(i == (j + 1) % u.n || j == (i + 1) % u.n) continue;\n P to_inf = P(inf, inf * sqrt(2));\n P to = (u.vs[i] + u.vs[j]) / 2;\n bool bad = false;\n int cnt = 0;\n range(x, 0, u.n) {\n cnt ^= cross(to, to_inf, u.vs[x], u.vs[(x + 1) % u.n]);\n if(x == i || x == j || (x + 1) % u.n == i || (x + 1) % u.n == j) continue;\n bad |= cross(u.vs[i], u.vs[j], u.vs[x], u.vs[(x + 1) % u.n]);\n }\n if(!bad && cnt) {\n a = i;\n b = j;\n break;\n }\n }\n if(~a && ~b) break;\n }\n assert(~a && ~b);\n vector

    l, r;\n for(int i = a; i <= b; i++) l.push_back(u.vs[i]);\n for(int i = b; i != (a + 1) % u.n; i = (i + 1) % u.n) r.push_back(u.vs[i]);\n vector add = triangulation(Poly(r));\n res = triangulation(l);\n for(auto i : add) res.push_back(i);\n return res;\n}\n\nint cnt = 1;\nint iter = 0;\n\nstruct query {\n int t;\n int k;\n vector B;\n Poly A;\n query(){};\n};\n\nvector res;\nvector cur;\n\nvector split(Poly a, vector b) {\n query cc;\n cc.t = 0; cc.k = b.size(); cc.A = a;\n for(Poly &u : b) {\n u.id = cnt++;\n cc.B.push_back(u);\n iter += u.n;\n cur.push_back(u);\n }\n res.push_back(cc);\n return b;\n}\n\nPoly joint(Poly a, vector b) {\n a.id = cnt++;\n cur.push_back(a);\n query cc;\n cc.t = 1; cc.k = b.size(); cc.A = a;\n for(Poly u : b) {\n cc.B.push_back(u);\n }\n res.push_back(cc);\n iter += a.n;\n return a;\n}\n\nPoly trans(Poly a, Poly b) {\n b.id = cnt++;\n cur.push_back(b);\n query cc;\n cc.t = 1; cc.k = 1; cc.A = b;\n cc.B.push_back(a);\n res.push_back(cc);\n iter += b.n;\n return b;\n}\n\nvoid out() {\n for(auto i : res) {\n if(!i.t) {\n printf(\"scissors\\n\");\n printf(\"%d %d\\n\", i.A.id, i.k);\n for(auto j : i.B) {\n printf(\"%d \", j.n);\n for(auto u : j.vs) printf(\"%.17g %.17g \", u.x, u.y);\n printf(\"\\n\");\n }\n } else {\n printf(\"tape\\n\");\n printf(\"%d \", i.k);\n for(auto j : i.B) printf(\"%d \", j.id);\n printf(\"\\n\");\n if(i.k == 1) {\n printf(\"%d \", i.A.n);\n for(auto j : i.A.vs) printf(\"%.17g %.17g \", j.x, j.y);\n printf(\"\\n\");\n } else {\n for(auto j : i.B) {\n printf(\"%d \", j.n);\n for(auto u : j.vs) printf(\"%.17g %.17g \", u.x, u.y);\n printf(\"\\n\");\n }\n }\n printf(\"%d \", i.A.n);\n for(auto j : i.A.vs) printf(\"%.17g %.17g \", j.x, j.y);\n printf(\"\\n\");\n }\n }\n}\n\nPoly rect(Poly s) {\n assert(s.n == 3);\n int mx = 0;\n double d = dis(s.vs[1], s.vs[2]);\n range(i, 1, 3) {\n if(dis(s.vs[(i + 1) % 3], s.vs[(i + 2) % 3]) > d) {\n mx = i;\n d = dis(s.vs[(i + 1) % 3], s.vs[(i + 2) % 3]);\n }\n }\n P a = s.vs[mx], b = s.vs[(mx + 1) % 3], c = s.vs[(mx + 2) % 3];\n Poly u, v;\n u.vs = {b, c, (c + a) / 2, (a + b) / 2};\n u.n = 4;\n v.vs = {a, (a + b) / 2, (a + c) / 2};\n v.n = 3;\n vector foo = {u, v};\n foo = split(s, foo);\n u = foo[0], v = foo[1];\n Poly to;\n to.vs = {b, (a + b) / 2, (a + b - c + b) / 2};\n to.n = 3;\n to = trans(v, to);\n P p = pr(b, L2((a + b) / 2, (a + b - c + b) / 2));\n Poly l, r;\n l.vs = {b, (a + b) / 2, p}; r.vs = {b, p, (a + b - c + b) / 2};\n l.n = 3, r.n = 3;\n vector bar = {l, r};\n bar = split(to, bar);\n r = r + (c - b);\n r = trans(bar.back(), r);\n l = bar[0];\n Poly cc;\n cc.vs = {p, b, c, p + c - b};\n cc.n = 4;\n vector sc = {u, l, r};\n cc = joint(cc, sc);\n Poly _cc;\n _cc.vs = {P(0, 0), P(dis(b, p), 0), P(dis(b, p), dis(b, c)), P(0, dis(b, c))};\n _cc.n = 4;\n _cc = trans(cc, _cc);\n return _cc;\n}\n\nPoly back_to_triangle(Poly s, Poly _cc) {\n assert(s.n == 3);\n int mx = 0;\n double d = dis(s.vs[1], s.vs[2]);\n range(i, 1, 3) {\n if(dis(s.vs[(i + 1) % 3], s.vs[(i + 2) % 3]) > d) {\n mx = i;\n d = dis(s.vs[(i + 1) % 3], s.vs[(i + 2) % 3]);\n }\n }\n P a = s.vs[mx], b = s.vs[(mx + 1) % 3], c = s.vs[(mx + 2) % 3];\n Poly u, v;\n u.vs = {b, c, (c + a) / 2, (a + b) / 2};\n u.n = 4;\n v.vs = {a, (a + b) / 2, (a + c) / 2};\n v.n = 3;\n Poly to;\n to.vs = {b, (a + b) / 2, (a + b - c + b) / 2};\n to.n = 3;\n P p = pr(b, L2((a + b) / 2, (a + b - c + b) / 2));\n Poly l, r;\n l.vs = {b, (a + b) / 2, p}; r.vs = {b, p, (a + b - c + b) / 2};\n l.n = 3, r.n = 3;\n Poly cc;\n cc.vs = {p, b, c, p + c - b};\n cc.n = 4;\n cc = trans(_cc, cc);\n vector sc = {u, l, r + (c - b)};\n sc = split(cc, sc);\n r = trans(sc.back(), r); l = sc[1]; u = sc[0];\n sc = {r, l}; to = joint(to, sc);\n v = trans(to, v);\n sc = {u, v};\n s = joint(s, sc);\n return s;\n}\n\nPoly x_fold(Poly a) {\n Poly u, v, to;\n u.vs = {(a.vs[0] + a.vs[3]) / 2, (a.vs[1] + a.vs[2]) / 2, a.vs[2], a.vs[3]}; u.n = 4;\n v.vs = {a.vs[0], a.vs[1], (a.vs[1] + a.vs[2]) / 2, (a.vs[0] + a.vs[3]) / 2}; v.n = 4;\n vector foo = {u, v};\n foo = split(a, foo);\n u = foo[0], v = foo[1];\n u = trans(u, u + (u.vs[1] - u.vs[3]));\n to.vs = {v.vs[0], u.vs[1], u.vs[2], v.vs[3]}; to.n = 4;\n foo.front() = u;\n return joint(to, foo);\n}\n\nPoly y_fold(Poly a) {\n Poly u, v, to;\n u.vs = {(a.vs[0] + a.vs[1]) / 2, a.vs[1], a.vs[2], (a.vs[2] + a.vs[3]) / 2}; u.n = 4;\n v.vs = {a.vs[0], (a.vs[0] + a.vs[1]) / 2, (a.vs[2] + a.vs[3]) / 2, a.vs[3]}; v.n = 4;\n vector foo = {u, v};\n foo = split(a, foo);\n u = foo[0], v = foo[1];\n u = trans(u, u + (u.vs[3] - u.vs[1]));\n foo.front() = u;\n to.vs = {v.vs[0], v.vs[1], u.vs[2], u.vs[3]}; to.n = 4;\n return joint(to, foo);\n}\n\nconst double ze = 1e-5;\n\nvector near(Poly a) {\n return (vector) {a.vs[0].x - a.vs[3].x, a.vs[1].y - a.vs[0].y, a.vs[2].x - a.vs[1].x, a.vs[3].y - a.vs[2].y};\n}\n\nPoly rectangle(Poly a, Poly b) {\n Poly u = a, v = b;\n double ux = dis(u.vs[0], u.vs[1]), uy = dis(u.vs[0], u.vs[3]);\n double vx = dis(v.vs[0], v.vs[1]), vy = dis(v.vs[0], v.vs[3]);\n vector cons;\n while(vx > ze * 10) {\n while(ux > vx) {\n u = y_fold(u);\n ux /= 2;\n uy *= 2;\n }\n while(ux <= vx / 2) {\n u = x_fold(u);\n ux *= 2;\n uy /= 2;\n }\n if(abs(ux - vx) + abs(uy - vy) < ze) break;\n Poly from, _u, to, _v;\n from.vs = {P(0, 0), P(ux, 0), P(ux, vy), P(0, vy)};\n to = from + v.vs[0];\n from = from + u.vs[0];\n from.n = 4; to.n = 4;\n _u.vs = {from.vs[3], from.vs[2], u.vs[2], u.vs[3]}; _u.n = 4;\n assert(ux < vx && uy > vy);\n assert(u.vs[2].y > from.vs[2].y);\n _v.vs = {to.vs[1], v.vs[1], v.vs[2], to.vs[2]}; _v.n = 4;\n vector l = {from, _u};\n l = split(u, l);\n assert(abs(S(from) + S(_u) - S(u)) < ze * 100);\n from = l[0], _u = l[1];\n to = trans(from, to);\n cons.push_back(to);\n if(_u.vs[0].y > 1e6) _u = trans(_u, _u + (P(0, 0) - u.vs[0]));\n v = _v; u = _u;\n ux = dis(u.vs[0], u.vs[1]), uy = dis(u.vs[0], u.vs[3]);\n vx = dis(v.vs[0], v.vs[1]), vy = dis(v.vs[0], v.vs[3]);\n u.vs = {P(0, 0), P(ux, 0), P(ux, uy), P(0, uy)}; u.n = 4;\n v.vs = {P(0, 0), P(vx, 0), P(vx, vy), P(0, vy)}; v.n = 4;\n u = u + _u.vs[0];\n v = v + _v.vs[0];\n }\n v = trans(u, u + (v.vs[0] - u.vs[0]));\n cons.push_back(v);\n return joint(b, cons);\n}\n\nvoid solve(Poly bar) {\n vector r = triangulation(bar);\n r = split(bar, r);\n for(auto &i : r) i = rect(i);\n double sum = S(bar);\n double a = sqrt(sum);\n Poly to;\n to.vs = {P(0, 0), P(a, 0), P(a, a), P(0, a)};\n to.n = 4;\n vector cc;\n double l = 0;\n for(auto i : r) {\n double len = S(i) / a;\n Poly ss;\n ss.n = 4;\n ss.vs = {P(l, 0), P(l + len, 0), P(l + len, a), P(l, a)};\n cc.push_back(rectangle(i, ss));\n l += len;\n }\n joint(to, cc);\n}\n\nvoid rev(Poly b, Poly sq) {\n vector r = triangulation(b);\n int memo = cnt;\n auto foo = res;\n vector ss;\n for(auto i : r) ss.push_back(rect(i));\n cnt = memo; swap(res, foo);\n double a = sqrt(S(sq));\n double l = 0;\n vector sp;\n range(i, 0, (int) ss.size()) {\n double len = S(ss[i]) / a;\n vector

    xs = {P(l, 0), P(l + len, 0), P(l + len, a), P(l, a)};\n sp.emplace_back(xs);\n l += len;\n }\n sp = split(sq, sp);\n range(i, 0, (int) sp.size()) {\n ss[i] = rectangle(sp[i], ss[i]);\n r[i] = back_to_triangle(r[i], ss[i]);\n }\n joint(b, r);\n}\n\n\nint main() {\n Poly a, b;\n a.read(); b.read();\n a.id = 0;\n solve(a);\n rev(b, res.back().A);\n out();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3dbc1d06b8feb900949068e004fb8d76", "src_uid": "375b83d1b7a911c1ca67d5209d39adb4", "difficulty": null} {"lang": "GNU C++", "source_code": "#include \n#include \n\nconst long long base=1000000007;\n\nusing namespace std;\n\nint main(){\nint n;\ncin>>n;\nlong long r=0,b=0;\nwhile (n--){\nswap(r,b);\nr=(r+b+1%base;\n}\ncout<<(r+b)% base;\nreturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b6a826ccc515abcdcca46f83737e26f7", "src_uid": "5c4bd12df3915186a7b506c2060db125", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main(){\nint n;\ncin>>n;\nlong long r=0,b=0,base=1000000007;\nwhile (n--){\nswap(r,b);\nr=(r+b+1) mod base;\n}\ncout<<(r+b) mod base;\nreturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8175027916e37c09b65b16558b253687", "src_uid": "5c4bd12df3915186a7b506c2060db125", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define F(i,a,b) for(int i=int(a);i<=int(b);i++)\n#define ll long long\n#define pb push_back\nconst int mod=1000000007;\n\nint main(){\n\tint n;\n\tcin>>n;\n\tll dp[n+1];\n\tdp[1]=1,dp[2]=3;\n\tF(i,3,n) dp[i]=(d[i-1]+dp[i-2]+2)%mod;\n\tcout<\n\nint main()\n{\n\tint n(0);\n\tstd::cin >> n;\n\n\tstatic int redStart[1000005] = { 0 }, blueStart[1000005] = { 0 };\n\tredStart[1] = 1;\n\tblueStart[1] = 0;\n\tfor (int i = 2; i <= n; i++)\n\t{\n\t\tif (i % 2 == 0)\n\t\t{\n\t\t\tredStart[i] = 1 + (i >= 3 ? blueStart[i - 2] : 0) +\n\t\t\t\t(i >= 4 ? redStart[i - 3] : 0);\n\t\t\tblueStart[i] = blueStart[i - 2] + redStart[i - 1] + 1;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tredStart[i] = redStart[i - 2] + blueStart[i - 1] + 1;\n\t\t\tblueStart[i] = 1 + (i >= 3 ? redStart[i - 2] : 0) +\n\t\t\t\t(i >= 4 ? blueStart[i - 3] : 0);\n\t\t}\n\t}\n\n\tstd::cout << redStart[n] + blueStart[n] << std::endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "40c076a82fdadf8b3b1e9098774681b0", "src_uid": "5c4bd12df3915186a7b506c2060db125", "difficulty": 1600.0} {"lang": "GNU C++14", "source_code": "\nBy krijgertje, contest: Codeforces Round #470 (rated, Div. 1, based on VK Cup 2018 Round 1), problem: (F) Public Service, Accepted, #\n #include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define PB push_back \n#define MP make_pair \n#define SZ(v) ((int)(v).size()) \n#define FOR(i,a,b) for(int i=(a);i<(b);++i) \n#define REP(i,n) FOR(i,0,n) \n#define FORE(i,a,b) for(int i=(a);i<=(b);++i) \n#define REPE(i,n) FORE(i,0,n) \n#define FORSZ(i,a,v) FOR(i,a,SZ(v)) \n#define REPSZ(i,v) REP(i,SZ(v)) \ntypedef long long ll;\ntypedef unsigned long long ull;\nll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }\n\nconst int MAXN = 10000;\n\nstruct T {\n\tint n;\n\tvector adj[MAXN];\n\n\tbool alive[MAXN]; int nalive;\n\tint deg[MAXN];\n\tint afst[MAXN], alst[MAXN], anxt[MAXN], aprv[MAXN]; // doubly-linked lists for leaves adjacent to a node\n\tint bfst, blst, bnxt[MAXN], bprv[MAXN]; // doubly-linked lists for nodes adjacent to at least one leaf\n\tpriority_queue > pq;\n\n\tvoid init() {\n\t\tnalive = n; REP(i, n) alive[i] = true, deg[i] = SZ(adj[i]), afst[i] = alst[i] = -1; bfst = blst = -1;\n\t\tREP(at, n) if (deg[at] == 1) aappend(at, adj[at][0]);\n\t\tREP(at, n) if (afst[at] != -1) bappend(at);\n\t\tpq = priority_queue >(); REP(i, n) pq.push(MP(deg[i], i));\n\t}\n\tvoid killleaf(int at) {\n\t\tassert(deg[at] == 1); alive[at] = false; --nalive;\n\t\tint to = -1; REPSZ(i, adj[at]) if (alive[adj[at][i]]) { assert(to == -1); to = adj[at][i]; } assert(to != -1);\n\t\t--deg[at]; if (deg[at] == 0) { aremove(at, to); if (afst[to] == -1) bremove(to); }\n\t\t--deg[to]; pq.push(MP(deg[to], to)); if (deg[to] == 0) { aremove(to, at); if (afst[at] == -1) bremove(at); }\n\t\tif (deg[to] == 1) {\n\t\t\tint oth = -1; REPSZ(i, adj[to]) if (alive[adj[to][i]]) { assert(oth == -1); oth = adj[to][i]; } assert(oth != -1);\n\t\t\taappend(to, oth);\n\t\t\tif (afst[oth] == to&&anxt[to] == -1) bappend(oth);\n\t\t}\n\t}\n\tvoid aappend(int at, int to) {\n\t\taprv[at] = alst[to], anxt[at] = -1; if (aprv[at] == -1) afst[to] = at; else anxt[aprv[at]] = at; alst[to] = at;\n\t}\n\tvoid aremove(int at, int to) {\n\t\tif (aprv[at] == -1) afst[to] = anxt[at]; else anxt[aprv[at]] = anxt[at];\n\t\tif (anxt[at] == -1) alst[to] = aprv[at]; else aprv[anxt[at]] = aprv[at];\n\t}\n\tvoid bappend(int at) {\n\t\tbprv[at] = blst, bnxt[at] = -1; if (bprv[at] == -1) bfst = at; else bnxt[bprv[at]] = at; blst = at;\n\t}\n\tvoid bremove(int at) {\n\t\tif (bprv[at] == -1) bfst = bnxt[at]; else bnxt[bprv[at]] = bnxt[at];\n\t\tif (bnxt[at] == -1) blst = bprv[at]; else bprv[bnxt[at]] = bprv[at];\n\t}\n\tbool getleavesatleastthreeapart(pair &u, pair &v) {\n\t\tif (bfst == -1 || bnxt[bfst] == -1) return false;\n\t\tint x = bfst, y = bnxt[bfst], r = maxdeg().second; if (afst[r] != -1 && x != r) y = r;\n\t\tu = MP(afst[x], x), v = MP(afst[y], y); assert(u.first != -1 && v.first != -1); return true;\n\t}\n\tpair maxdeg() { while (!pq.empty() && (!alive[pq.top().second] || deg[pq.top().second] != pq.top().first)) pq.pop(); return !pq.empty() ? pq.top() : MP(0, -1); }\n\tbool isstar() { return maxdeg().first == nalive - 1; }\n\tbool issemistar() { return maxdeg().first == nalive - 2; }\n\tbool ispath() { return maxdeg().first <= 2; }\n\tbool getsemistar1(vector &rem) {\n\t\tif (!issemistar()) return false; assert(bfst != -1 && bnxt[bfst] != -1 && bnxt[bnxt[bfst]] == -1);\n\t\tint w = maxdeg().second; assert(bfst == w || bnxt[bfst] == w); int v = bfst + bnxt[bfst] - w; assert(afst[v] != -1 && anxt[afst[v]] == -1); int u = afst[v];\n\t\trem.clear(); rem.PB(u); rem.PB(v); rem.PB(w); REP(i, n) if (alive[i] && i != u&&i != v&&i != w) rem.PB(i); return true;\n\t}\n\tbool getsemistar2(vector &rem) {\n\t\tif (isstar()) return false; assert(bfst != -1 && bnxt[bfst] != -1); int u = bfst, w = afst[u], v = afst[bnxt[bfst]]; assert(w != -1 && u != -1);\n\t\trem.clear(); rem.PB(u); rem.PB(v); rem.PB(w); REP(i, n) if (alive[i] && i != u&&i != v&&i != w) rem.PB(i); return true;\n\t}\n\tbool getpath1(vector &rem) {\n\t\tif (!ispath()) return false;\n\t\tint at = -1; REP(i, n) if (alive[i] && deg[i] <= 1) { at = i; break; } assert(at != -1);\n\t\trem.PB(at); while (true) { int to = -1; REPSZ(i, adj[at]) if (alive[adj[at][i]] && (SZ(rem) == 1 || adj[at][i] != rem[SZ(rem) - 2])) { assert(to == -1); to = adj[at][i]; } if (to == -1) break; at = to; rem.PB(at); } return SZ(rem) == 5;\n\t}\n\tbool getpath2(vector &rem) {\n\t\tif (!getpath1(rem)) return false;\n\t\tswap(rem[0], rem[2]); swap(rem[0], rem[4]); swap(rem[0], rem[3]); swap(rem[0], rem[1]); return true;\n\t}\n};\n\nint n;\nT a, b;\nint mp[MAXN];\nstruct Op { pair au, av, bu, bv; };\nvector ops;\n\n\nvoid run() {\n\tscanf(\"%d\", &n);\n\ta.n = n; REP(i, n - 1) { int u, v; scanf(\"%d%d\", &u, &v); --u, --v; a.adj[u].PB(v); a.adj[v].PB(u); } a.init();\n\tb.n = n; REP(i, n - 1) { int u, v; scanf(\"%d%d\", &u, &v); --u, --v; u -= n; v -= n; b.adj[u].PB(v); b.adj[v].PB(u); } b.init();\n\n\tif (a.isstar() || b.isstar()) { printf(\"No\\n\"); return; }\n\tREP(i, n) mp[i] = -1; ops.clear();\n\twhile (true) {\n\t\t//printf(\"maxdeg: (%d,%d) (%d,%d)\\n\", a.maxdeg().first, a.maxdeg().second + 1, b.maxdeg().first, b.maxdeg().second + 1 + n);\n\t\tif (a.issemistar()) {\n\t\t\t//printf(\"a semistar\\n\");\n\t\t\tvector arem; assert(a.getsemistar1(arem));\n\t\t\tvector brem; assert(b.getsemistar2(brem));\n\t\t\tassert(a.nalive == b.nalive&&SZ(arem) == a.nalive&&SZ(brem) == b.nalive);\n\t\t\tREPSZ(i, arem) mp[arem[i]] = brem[i];\n\t\t\tbreak;\n\t\t}\n\t\tif (b.issemistar()) {\n\t\t\t//printf(\"b semistar\\n\");\n\t\t\tvector arem; assert(a.getsemistar2(arem));\n\t\t\tvector brem; assert(b.getsemistar1(brem));\n\t\t\tassert(a.nalive == b.nalive&&SZ(arem) == a.nalive&&SZ(brem) == b.nalive);\n\t\t\tREPSZ(i, arem) mp[arem[i]] = brem[i];\n\t\t\tbreak;\n\t\t}\n\t\tif (a.nalive == 5 || b.nalive == 5) {\n\t\t\tassert(a.nalive == 5 && b.nalive == 5 && a.ispath() && b.ispath());\n\t\t\t//printf(\"5 path\\n\");\n\t\t\tvector arem; assert(a.getpath1(arem));\n\t\t\tvector brem; assert(b.getpath2(brem));\n\t\t\tassert(a.nalive == b.nalive&&SZ(arem) == a.nalive&&SZ(brem) == b.nalive);\n\t\t\tREPSZ(i, arem) mp[arem[i]] = brem[i];\n\t\t\tbreak;\n\t\t}\n\t\tassert(a.nalive >= 6 && b.nalive >= 6);\n\t\t//printf(\"general case: \");\n\t\tpair au, av; assert(a.getleavesatleastthreeapart(au, av));\n\t\tpair bu, bv; assert(b.getleavesatleastthreeapart(bu, bv));\n\t\t//printf(\"(%d,%d) and (%d,%d)\\n\", au.first + 1, av.first + 1, bu.first + n + 1, bv.first + n + 1);\n\t\ta.killleaf(au.first); a.killleaf(av.first);\n\t\tb.killleaf(bu.first); b.killleaf(bv.first);\n\t\tOp op; op.au = au, op.av = av, op.bu = bu, op.bv = bv; ops.PB(op);\n\t}\n\tfor (int i = SZ(ops) - 1; i >= 0; --i) {\n\t\tpair au = ops[i].au, av = ops[i].av, bu = ops[i].bu, bv = ops[i].bv;\n\t\tif (mp[au.second] != bu.second&&mp[av.second] != bv.second) { mp[au.first] = bu.first; mp[av.first] = bv.first; continue; }\n\t\tif (mp[au.second] != bv.second&&mp[av.second] != bu.second) { mp[au.first] = bv.first; mp[av.first] = bu.first; continue; }\n\t\tassert(false);\n\t}\n\tprintf(\"Yes\\n\");\n\tREP(i, n) { if (i != 0) printf(\" \"); printf(\"%d\", mp[i] == -1 ? -1 : mp[i] + n + 1); } puts(\"\");\n}\n\nint main() {\n\trun();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cf369410279356351e063b3b6d594a9e", "src_uid": "cdfe11f58ae66e4eef935543236f5098", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \ntypedef long long ll ;\n#define fi first\n#define se second\n#define mp make_pair\n#define rep(i, a, b) for (int i = a; i < b; ++ i) \nconst int N = 1e5 + 5, M = 1e5 ;\nusing namespace std ;\ntypedef pair > state;\n\nll myrand() {\n\treturn ((ll)(rand()&65535)<<32)+((ll)rand()<<16)+rand();\n}\nstate st1[N],st2[N];\nint vis[N],dis[N],off,pre[N],n,deg[N],deg2[N],u,v,ret[N];\nvector e[N],e2[N];\nbitset<10100> adj[10100];\nset hs;\npair E[N];\n\nvoid del(int u) {\n\toff+=1;\n\tdis[u]=1;\n\ths.erase(st1[u]);\n\tfor (auto v:e[u]) if (!dis[v]) {\n\t\ths.erase(st1[v]);\n\t\tst1[v].fi++;\n\t\ths.insert(st1[v]);\n\t}\n}\n\nbool gao0() {\n\trep(i,1,n+1) pre[i]=i;\n\trandom_shuffle(pre+1,pre+n+1);\n\trep(i,1,n) if (adj[pre[E[i].fi]][pre[E[i].se]]) return 0;\n\trep(i,1,n+1) ret[pre[i]]=i;\n\tputs(\"Yes\");\n\trep(i,1,n+1) printf(\"%d \",ret[i]+n);\n\tputs(\"\");\n\treturn 1;\n}\nbool gao() {\n\ths.clear(); off=0;\n\trep(i,1,n+1) {\n\t\tst1[i]=mp(deg[i],mp(myrand(),i));\n\t\tst2[i]=mp(deg2[i],mp(myrand(),i));\n\t\ths.insert(st1[i]);\n\t\tvis[i]=0; dis[i]=0;\n\t}\n\n\trep(i,1,n+1) pre[i]=0;\n\n\n\tstate val=st2[1];\n\trep(i,2,n+1) val=min(val,st2[i]);\n\n\tpriority_queue, greater > q;\n\t\n\tq.push(val);\n\tpre[val.se.se]=hs.begin()->se.se;\n\tvis[val.se.se]=1;\n\n\tdel(hs.begin()->se.se);\n\twhile (!q.empty()) {\n\t\tstate st=q.top(); q.pop();\n\t\tint u=st.se.se;\n\t\tint w=pre[u];\n\t\tfor (auto v:e2[u]) if (!vis[v]) {\n\t\t\tst2[v].fi--; vis[v]=1;\n\t\t\tvector tmp;\n\t\t\twhile (1) {\n\t\t\t\tauto it=hs.lower_bound(mp(st2[v].fi+off,mp(-1,-1)));\n\t\t\t\tif (it==hs.end()) return 0;\n\t\t\t\tif (adj[w][it->se.se]) {\n\t\t\t\t\ttmp.push_back(*it);\n\t\t\t\t\ths.erase(it);\n\t\t\t\t} else {\n\t\t\t\t\tpre[v]=it->se.se;\n\t\t\t\t\tfor (auto p:tmp) hs.insert(p);\n\t\t\t\t\tdel(it->se.se);\n\t\t\t\t\tq.push(st2[v]);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t}\n\trep(i,1,n+1) ret[pre[i]]=i;\n\tputs(\"Yes\");\n\trep(i,1,n+1) printf(\"%d \",ret[i]+n);\n\tputs(\"\");\n\treturn 1;\n}\n\nint main() {\n\tscanf(\"%d\",&n);\n\trep(i,1,n+1) deg[i]=n-1;\n\trep(i,1,n) {\n\t\tscanf(\"%d%d\",&u,&v);\n\t\te[u].push_back(v),e[v].push_back(u);\n\t\tadj[u][v]=adj[v][u]=1;\n\t\tdeg[u]--; deg[v]--;\n\t}\n\trep(i,1,n) {\n\t\tscanf(\"%d%d\",&u,&v); u-=n; v-=n;\n\t\te2[u].push_back(v); e2[v].push_back(u);\n\t\tE[i]=make_pair(u,v);\n\t\tdeg2[u]++; deg2[v]++;\n\t}\n\trep(i,1,n+1) if (deg[i]==0||deg2[i]==n-1) {\n\t\tputs(\"No\");\n\t\treturn 0;\n\t}\n\twhile (1) {\n\t\tif (gao()) return 0;\n\t\tif (gao0()) return 0;\n\t}\n\tputs(\"No\");", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2623e12ec608dd0007828ff81ff8fceb", "src_uid": "cdfe11f58ae66e4eef935543236f5098", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\ntypedef pair P;\ntypedef pair P1;\ntypedef pair P2;\n#define pu push\n#define pb push_back\n#define mp make_pair\n#define eps 1e-7\n#define INF 1000000000\n#define mod 1000000007\n#define fi first\n#define sc second\n#define rep(i,x) for(int i=0;i,greater >que;\nint n;\nvector

    edge; vectorG[10005],G2[10005];\nbool used[100050000];\nint cnt[10005],cnt2[10005];\nvoid brute(){\n\tvectorvec;\n\tfor(int i=0;ivec;\n\tfor(int i=0;int;\n\tfor(int i=0;ileaf;\n\tfor(int i=0;i>n;\n\trep(i,n-1){\n\t\tint a,b;\n\t\tcin>>a>>b; a--; b--;\n\t\tedge.pb(mp(a,b)); cnt[a]++; cnt[b]++;\n\t\tG[a].pb(b);\n\t\tG[b].pb(a);\n\t}\n\trep(i,n-1){\n\t\tint a,b;\n\t\tcin>>a>>b; \n\t\ta-=n+1; b-=n+1;\n\t\tused[a*n+b] = used[b*n+a] = 1; cnt2[a]++; cnt2[b]++;\n\t\tG2[a].pb(b);\n\t\tG2[b].pb(a);\n\t}\n\tif(n<=10){\n\t\tbrute(); return 0;\n\t}\n\telse{\n\t\tomikuji(); return 0;\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c8277c5fc6ec91adc0a58b285b9bcca6", "src_uid": "cdfe11f58ae66e4eef935543236f5098", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \n# include \nusing namespace std;\n#define max(a,b) ((a)>(b)?(a):(b))\n#define min(a,b) ((a)<(b)?(a):(b))\n#define odd(x) ((x)&1)\n#define sqr(x) ((x)*(x))\n#define mp make_pair\n#define pb push_back\n#define fir first\n#define sec second\n#define all(x) (x).begin(),(x).end()\n#define mem(a,x) memset(a,x,sizeof(a))\n#define rep(i,a,b) for (int i=(a); i<=(b); ++i)\n#define per(i,a,b) for (int i=(a); i>=(b); --i)\n#define rep_it(it,x) for (__typeof((x).begin()) it=(x).begin(); it!=(x).end(); it++)\n#define ____ puts(\"\\n_______________\\n\\n\") \n#define debug(x) ____; cout<< #x << \" => \" << (x) << endl\n#define debug_pair(x) cout<<\"\\n{ \"<<(x).fir<<\" , \"<<(x).sec<<\" }\\n\"\n#define debug_arr(x,n) ____; cout<<#x<<\":\\n\"; rep(i,0,n) cout<<#x<<\"[\"<<(i)<<\"] => \"< pii;\ntypedef vector vi;\nconst int oo = /*2 * 1000 * 1000 * 1000*/0x3f3f3f3f;\nconst ll ooo=9223372036854775807ll; \nconst int _cnt = 1000 * 1000 + 7;\nconst int _p = 1000 * 1000 * 1000 + 7;\nconst int N=10005; \nconst double PI=acos(-1.0);\nconst double eps=1e-9;\nint o(int x) { return x%_p; }\nint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }\nint lcm(int a, int b) { return a / gcd(a, b)*b; }\n\nvoid file_put() {\n freopen(\"filename.in\", \"r\", stdin);\n freopen(\"filename.out\", \"w\", stdout);\n}\n\nint d1[N],d2[N],ans[N],n,x,y,u,v,w,num; bool vis1[N],vis2[N];\nvector V1[N],V2[N]; bitset a[N];\nstruct Btype{ int x,y; } E[N];\nstruct Stype{ int d,id; ll r; } s1[N],s2[N]; set S;\nll myrand() { return ((ll)(rand()&65535)<<32)+((ll)rand()<<16)+rand(); }\ninline bool operator < (const Stype p,const Stype q) {\n\treturn p.d (const Stype p,const Stype q) {\n\treturn p.d>q.d || p.d==q.d && p.r>q.r || p.d==q.d && p.r==q.r && p.id>q.id;\n}\n\nvoid print() { printf(\"Yes\\n\"); rep(i,1,n) printf(\"%d \",ans[i]+n); printf(\"\\n\"); }\nvoid D(int x) {\n\tvis1[x]=1,num++; S.erase(s1[x]);\n\tfor (auto y: V1[x]) if (!vis1[y]) S.erase(s1[y]),s1[y].d++,S.insert(s1[y]);\n}\n\nbool _work() {\n\trep(i,1,n) ans[i]=i; random_shuffle(ans+1,ans+n+1);\n\trep(i,1,n-1) if (a[ans[E[i].x]][ans[E[i].y]]) return 0;\n\tprint(); return 1;\n}\n\nbool work() {\n\tmem(vis1,0),mem(vis2,0),mem(ans,0),num=0; S.clear();\n\trep(i,1,n) S.insert(s1[i]=Stype{d1[i],i,myrand()}),s2[i]=Stype{d2[i],i,myrand()};\n\tpriority_queue , greater > Q; \n\tStype s=s2[1]; rep(i,2,n) s=min(s,s2[i]);\n\tQ.push(s),ans[s.id]=S.begin()->id,vis2[s.id]=1,D(S.begin()->id);\n\twhile (!Q.empty()) {\n\t\tStype s=Q.top(); Q.pop(); u=ans[x=s.id];\n\t\tfor (auto y: V2[x]) if (!vis2[y]) {\n\t\t\ts2[y].d--; auto it=S.lower_bound(Stype{s2[y].d+num,-1,-1});\n\t\t\tfor (; it!=S.end(); it++) if (!a[u][v=it->id]) { ans[y]=v; break; }\n\t\t\tif (!ans[y]) return 0; D(v),vis2[y]=1,Q.push(s2[y]);\n\t\t}\n\t}\n\tprint(); return 1;\n}\n\nint main() {\n //file_put();\n \n scanf(\"%d\",&n);\n\trep(i,1,n-1) {\n\t\tscanf(\"%d%d\",&x,&y),d2[x]++,d2[y]++;\n\t\tV2[x].pb(y),V2[y].pb(x); E[i]=Btype{x,y};\n\t}\n\trep(i,1,n-1) {\n\t\tscanf(\"%d%d\",&x,&y),x-=n,y-=n,d1[x]--,d1[y]--;\n\t\tV1[x].pb(y),V1[y].pb(x); a[x][y]=a[y][x]=1;\n\t}\n\trep(i,1,n) d1[i]+=n-1;\n\trep(i,1,n) if (!d1[i] || d2[i]==n-1) return 0*printf(\"No\\n\");\n\tfor (; !work() /*&& !_work()*/; ) ;\n\t\n return 0;\n}\n \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e87173d153af845bda0c7069da48037a", "src_uid": "cdfe11f58ae66e4eef935543236f5098", "difficulty": 3200.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n\n#define f first\n#define s second\n#define pb push_back\n#define INF 1000000000\n\nusing namespace std;\nusing namespace __gnu_pbds;\n\ntypedef long long ll;\ntypedef long double ld;\n\ntypedef tree<\nll,\nnull_type,\ngreater,\nrb_tree_tag,\ntree_order_statistics_node_update> ordered_set;\n\nint main()\n{\n ll n;\n cin >> n;\n ll a[n];\n for (ll i = 0; i < n; i++) cin >> a[i];\n for (ll i = 0; i < n - 2; i++)\n if ((a[i] ^ a[i + 1]) > a[i + 2] || (a[i + 1] ^ a[i + 2]) < a[i])\n {\n cout << 1;\n return 0;\n }\n assert(n < 100);\n ll ans = 1e9;\n for (int i = 0; i < n; i++)\n {\n ll x = 0;\n for (int j = i; j < n; j++)\n {\n x ^= a[j];\n ll x1 = 0;\n for (int c = j + 1; c < n; c++)\n {\n x1 ^= a[c];\n if (x > x1) ans = min(ans, (j - i) + (c - (j + 1)));\n }\n }\n }\n ans == 1e9?cout << -1 : cout << ans;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a815aa413ccbee1c8c8d9bde85119206", "src_uid": "51ad613842de8eff6226c97812118b61", "difficulty": null} {"lang": "GNU C++17", "source_code": "\ufeff#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \ntypedef long long ll;\nusing namespace std;\n#define PI 3.141592653589\n#define MOD 1000000007\n\nvoid Solve()\n{\n\tint n;\n\tcin >> n;\n\tvector vec(n);\n\tfor (auto& el : vec)\n\t\tcin >> el;\n\tint ans = INT_MAX;\n\tfor (int i = 0; i < n - 1; ++i)\n\t{\n\t\tint t = vec[i];\n\t\tfor (int j = 1; i + j < n && pow(2, j) <= long long(vec[i]) << 1ll; ++j)\n\t\t{\n\t\t\tt ^= vec[i + j];\n\t\t\tif (i > 0 && vec[i - 1] > t || i + j + 1 < n && vec[i + j + 1] < t)\n\t\t\t{\n\t\t\t\tans = min(ans, j);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tif (ans == INT_MAX)\n\t\tcout << -1 << endl;\n\telse\n\t\tcout << ans << endl;\n}\n\nint main()\n{\n\tios::sync_with_stdio(0);\n\tcin.tie(0);\n\tSolve();\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "015810406743ce68fdf440d3750ee4ad", "src_uid": "51ad613842de8eff6226c97812118b61", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\n#define int long long\n#define vi vector\n#define vp vector>\n\nvoid ans() {\n int n;\n cin >> n;\n if (n > 100) {\n cout << 1 << \"\\n\";\n }\n int a[n];\n for (int i = 0; i < n; i++)\n cin >> a[i];\n int ans = 1e9;\n for (int i = 0; i < n; i++) {\n int f = 0;\n for (int l = i; l >= 0; l--) {\n f ^= a[l];\n int s = 0;\n for (int k = i + 1; k < n; k++) {\n s ^= a[k];\n if (f > s) {\n ans = min(ans, i - l + k - i - 1);\n }\n }\n }\n }\n if (ans == int(1e9)) {\n cout << -1 << endl;\n } else {\n cout << ans << endl;\n }\n}\n\nsigned main() {\n ans();\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8f24624ee909ff8d43c8396eef4bcbe2", "src_uid": "51ad613842de8eff6226c97812118b61", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#define FOR(i, a, b) for (int i = (a); i < (b); i++)\n#define FORD(i, a, b) for(int i = (a); i >=(b); i--)\n#define pb(a) push_back(a)\n#define mp(a,b) make_pair(a,b)\ntypedef long long int ll;\nusing namespace std;\nll mod1=1000000007;\nll mod2=67280421310721;\nll mod3=998244353;\nll INF=1e18;\n\nll binpow1(ll a,ll b){\n ll res=1;\n while (b>0){\n if (b&1)\n res=res*a;\n a=a*a;\n b>>=1;\n }\n return res;\n}\n\nll binpow2(ll a,ll b,ll m){\n a%=m;\n ll res=1;\n while (b>0){\n if (b & 1)\n res=res*a%m;\n a=a*a%m;\n b>>=1;\n }\n return res;\n}\n\nll gcd(ll a,ll b){\n if (b==0)\n return a;\n else\n return gcd(b,a%b);\n}\n\nmap fact(ll n) {\n map factorization;ll c=0;\n while (n % 2 == 0) {\n c++;\n n /= 2;\n }\n if(c>0)\n {\n factorization.insert({2,c});\n }c=0;\n for (ll d = 3; d * d <= n; d += 2) {\n while (n % d == 0) {\n c++;\n n /= d;\n }\n if(c>0)\n {\n factorization.insert({d,c});\n }c=0;\n }\n if (n > 1)\n {\n factorization.insert({n,1});\n }\n return factorization;\n}\n\nint main()\n{ios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tcout.tie(NULL);\n ll n;\n cin>>n;\n ll a[n];ll b[n];ll f=0;\n FOR(i,0,n)\n {\n cin>>a[i];\n b[i]=floor(log2(a[i]));\n }\n FOR(i,1,n-1)\n {\n if(b[i-1]==b[i] && b[i]==b[i+1])\n {\n f=1;break;\n }\n }\n if(f)\n {\n cout<<1<<'\\n';\n return 0;\n }\n ll ans=INF;ll p=0;ll q=0;\n FOR(i,0,n)\n {\n p=p^a[i];\n FOR(j,i+1,n)\n {\n q=q^a[i];\n if(p>q)\n {\n ans=min(ans,j-i-1);\n }\n }\n q=0;\n }\n if(ans==INF)\n {\n ans=-1;\n }\n cout<,ans<<'\\n';\n \n\n\n\n\n\n\treturn 0;\n}\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "17b1f65d6fcc74dd58f572b464331734", "src_uid": "51ad613842de8eff6226c97812118b61", "difficulty": null} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nconst int N = 1510;\nvector G[N];\nstruct node{\n\tint x,y,id;\n};\nbool vis[N];\nint son[N];\nint ans[N];\nnode C{-1e9-100,-1e9-100};\n//\u6781\u89d2\u6392\u5e8f\nvector pt;\nbool cmp(node& a,node& b)\n{\n\tnode A{a.x-C.x,a.y-C.y};\n\tnode B{b.x-C.x,b.y-C.y};\n\treturn 1ll*A.x*B.y - 1LL*A.y-B.x < 0;\n}\n//\n\nvoid dfs(int x,vector pt){\n\tint mx = 0;\n\tvis[x] = true;\n\tfor(int i= 0;i < pt.size();i ++){\n\t\tif(pt[i].x < pt[mx].x )mx = i;\n\t}\n\tans[pt[mx].id] = x;\n\tpt.erase(pt.begin() + mx);\n\tint bef = 0;\n\tfor(int i= 0;i < G[x].size();i ++){\n\t\tint v = G[x][i];\n\t\tif(vis[v]) continue;\n\t\tvector npt;\n\t\tnpt.clear();\n\t\tfor(int j = bef;j < bef+son[v];j ++){\n\t\t\tnpt.push_back(pt[j]);\n\t\t}\n\t\tbef += son[v];\n\n\t\tdfs(v,npt);\n\t}\n}\nint ddfs(int x){\n\tvis[x] = true;\n\tint cnt = 1;\n\tfor(int i = 0;i < G[x].size();i ++){\n\t\tint v= G[x][i];\n\t\tif(vis[v]) continue;\n\t\tcnt += ddfs(v);\n\t}\n\treturn son[x] = cnt;\n}\nint main(){\n\tint n;\n\tcin >>n;\n\tfor(int i= 1;i < n;i ++){\n\t\tint a,b;\n\t\tscanf(\"%d %d\",&a,&b);\n\t\tG[a].push_back(b);\n\t\tG[b].push_back(a);\n\t}\n\tfor(int i= 1;i <= n;i ++){\n\t\tint a,b;\n\t\tscanf(\"%d %d\",&a,&b);\n\t\tpt.push_back((node){a,b});\n\t\tpt[i-1].id = i;\n\t}\n\tsort(pt.begin(),pt.end(),cmp);\n\tmemset(vis,false,sizeof(vis));\n\tddfs(1);\n\tmemset(vis,false,sizeof(vis));\n\tdfs(1,pt);\n\tfor(int i = 1;i <= n;i ++){\n\t\tprintf(\"%d%c\",ans[i],i==n?'\\n':' ');\n\t}\n\n\treturn 0;\n}\n/*\n10\n4 3\n7 6\n5 7\n9 5\n7 4\n7 8\n2 5\n1 7\n5 10\n\n\n-10 -2\n-5 -7\n-9 9\n8 -8\n0 6\n-10 -7\n-2 0\n7 10\n8 9\n6 1\n*/\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bff39a32aec7bb132327f01c5391aa49", "src_uid": "d65e91dc274c6659cfdb50bc8b8020ba", "difficulty": 2200.0} {"lang": "GNU C++", "source_code": "#define _USE_MATH_DEFINES\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define ff(i,x,y) for(int i = (x);i < (y);++i)\n#define rep(i,n) ff(i,0,n)\n#define st(v) sort(v.begin(),v.end())\n#define st2(v,f) sort(v.begin(),v.end(),f)\n#define rvs(v) reverse(v.begin(),v.end())\n#define cnt(v,n) count(v.begin(),v.end(),n)\n#define pb push_back\nbool myfunction (int i,int j) { return (i0;i--){x=x*i;}\n#define MP make_pair\n#define F first\n#define S second\n#define LL long long\n#define ULL unsigned long long\n#define VI vector\n#define VVI vector\n\ntypedef pair PII;\ntypedef pair PIII;\n\n#ifdef LOCAL\nifstream in(\"in.txt\");\n#else\nistream &in = cin;\n#endif\n\nint n;\nbool adj[1501][1501];\nint vtx[1501];\nvector chk;\nvector points;\nvector res;\n\nint dfs(int node)\n{\n\tint cnt = 0;\n\tchk[node] = true;\n\tfor(int i = 1;i <= n;++i) \n\t\tif(!chk[i] && adj[node][i])\n\t\t\tcnt += dfs(i);\n\tvtx[node] = cnt+1;\n\treturn vtx[node];\n}\n\nvoid go(int s, int r, int root, vector ps, vector c)\n{\n\tint min_y = INT_MAX, min_i = -1;\n\tfor(int i = s;i <= r;++i) if(!c[i] && ps[i].F.S < min_y) {min_y = ps[i].F.S; min_i = i;}\n\tc[min_i] = true;\n\tres.push_back(MP(ps[min_i].S,root));\n\tfor(int i = 1;i <= n;++i) if(adj[root][i]) {\n\t\tvector nps(1);\n\t\tvector nchk;\n\t\twhile(nps.size() < vtx[i]+1) {\n\t\t\tif(!c[s]) nps.push_back(ps[s]);\n\t\t\t++s;\n\t\t}\n\t\tadj[i][root] = false;\n\t\tnchk.resize(nps.size(),false);\n\t\tgo(1,nps.size()-1,i,nps,nchk);\n\t}\n}\n\nint main()\n{\n\tin >> n;\n\trep(i,n+1) rep(j,n+1) adj[i][j] = false;\n\tpoints.resize(n+1);\n\tchk.resize(n+1,false);\n\tmemset(vtx,0,sizeof(vtx));\n\n\trep(i,n-1) {\n\t\tint a, b;\n\t\tin >> a >> b;\n\t\tadj[a][b] = adj[b][a] = true;\n\t}\n\n\trep(i,n) {\n\t\tint x, y;\n\t\tin >> x >> y;\n\t\tpoints[i+1] = MP(MP(x,y),i+1);\n\t}\n\n\tdfs(1);\n\n\tsort(points.begin()+1,points.end());\n\trep(i,n+1) chk[i] = false;\n\n\tgo(1,n,1,points,chk);\n\n\tst(res);\n\n\tfor(int i = 0;i < res.size();++i) cout << res[i].second << \" \";\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ea597a62c63fbbc26dcb5a85d0a744b5", "src_uid": "d65e91dc274c6659cfdb50bc8b8020ba", "difficulty": 2200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std;\ntypedef long long int ll ;\nconst int maxn=1501 ;\nstruct point\n{\n\tint x,y,name ;\n\tpoint *dad ;\n\tbool operator <(const point &w) const\n\t{\t\n\t\treturn (ll)(x-dad->x)*(w.y-dad->y)-(ll)(y-dad->y)*(w.x-dad->x)<0 ;\n\t}\n}poses[maxn] ;\nstruct node\n{\n\tint ans,subtree ;\n\tvector neighbor ;\n\tnode()\n\t{\n\t\tsubtree=1 ;\n\t}\n\tint &operator[](int a)\n\t{\n\t\treturn neighbor[a] ;\n\t}\n\tint size()\n\t{\n\t\treturn neighbor.size() ;\n\t}\n\tvoid push(int v)\n\t{\n\t\tneighbor.push_back(v) ;\n\t}\n}graph[maxn] ;\nbool cmp(const point &a,const point &b)\n{\n\tif(a.x!=b.x)\n\t\treturn a.x\n#include \n#include \n\nusing namespace std;\n\nstruct Point {\n\tint num;\n\tint x;\n\tint y;\n\tdouble cosV;\n\t\n\tvoid CosV(double dx, double dy) {\n\t\tthis->cosV = dx/(sqrt(dx*dx + dy*dy));\n\t}\n};\n\nbool cmp(const Point &a, const Point &b) {\n\treturn a.cosV < b.cosV;\n};\n\nint n;\nvector > g;\nvector ans;\nvector usedV;\n\nvoid DFS(int p, int v, int &cnt) {\n\t++cnt;\n\tfor (int i = 0; i < (int)g[v].size(); ++i) {\n\t\tif (g[v][i] != p) {\n\t\t\tDFS(v, g[v][i], cnt);\n\t\t}\n\t}\n}\n\nvoid Sort(vector &points, int pStart) {\n\t//usedP[points[pStart].num] = true;\n\tPoint &p0 = points[pStart];\n\tfor (int i = 0; i < (int)points.size(); ++i) {\n\t\tPoint &pi = points[i];\n\t\tif (i != pStart) {\n\t\t//if (!usedP[pi.num]) {\n\t\t\tpi.CosV(double(pi.x - p0.x), double(pi.y - p0.y)); \n\t\t\n\t\t//}\t\t\n\t\t}\n\t\t//printf(\"%f \", pi.cosV);\n\t}\n\t//cout << endl;\n\tsort(points.begin(), points.end(), cmp);\n}\n\nvoid Rec(int v, vector &points) {\n\tusedV[v] = true;\n\tint pStart = 0;\n\tfor (int i = 1; i < (int)points.size(); ++i) {\n\t\tPoint &p = points[i];\n\t\tif ((p.y < points[pStart].y) || (p.y == points[pStart].y && p.x < points[pStart].x)) {\n\t\t\tpStart = i;\n\t\t}\n\t}\n\t//cout << (int)points.size() << \" \";\n\t//cout << pStart << \" \";\n\tint pStartNum = points[pStart].num;\n//\tcout << pStartNum << endl;\n\t//cout << pStart << endl;\n\t//cout << points[pStart].num << endl;\n\tans[points[pStart].num] = v;\n\t\n\t//cout << ans[points[pStart].num] << endl;\n\tSort(points, pStart);\n\t\n\tvector points1;\n\tint pos = 0;\n\tfor (int i = 0; i < (int)g[v].size(); ++i) {\n\t\tif (!usedV[g[v][i]]) {\n\t\t\tint cnt = 0;\n\t\t\tDFS(v, g[v][i], cnt);\n\t\t\t\n\t\t\t//cout << cnt << endl;\n\t\t\tint j = 1;\n\t\t\tpoints1.clear();\n\t\t\twhile (j <= cnt) {\n\t\t\t\tif (points[pos].num != pStartNum) {\n\t\t\t\t\t//cout << \"LOL\" << endl;\n\t\t\t\t\tpoints1.push_back(points[pos]);\n\t\t\t\t\t++j;\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t++pos;\n\t\t\t}\n\t\t\t//cout << (int)points1.size() << endl;\n\t\t\tRec(g[v][i], points1);\n\t\t}\n\t}\t\t\n}\n\nint main() {\n\t//freopen(\"input.txt\", \"r\", stdin);\n\t//freopen(\"output.txt\", \"w\", stdout);\n\t\n\tscanf(\"%d\", &n);\n\tg.resize(n + 1);\n\tans.resize(n + 1);\n\tusedV.resize(n + 1, false);\t\n\tfor (int i = 1; i <= n - 1; ++i) {\n\t\tint x;\n\t\tint y;\n\t\tscanf(\"%d %d\", &x, &y);\n\t\tg[x].push_back(y);\n\t\tg[y].push_back(x);\n\t}\n\tvector points(n);\n\tfor (int i = 0; i < n; ++i) {\n\t\tscanf(\"%d %d\", &points[i].x, &points[i].y);\t\t\n\t\tpoints[i].num = i + 1;\n\t\tpoints[i].cosV = -2;\n\t\t//cout << points[i].num << endl;\n\t}\n\t//cout << endl;\n\t\n\tRec(1, points);\n\t\n\tfor (int i = 1; i <= n; ++i) {\n\t\tprintf(\" %d\", ans[i]);\n\t}\n\tprintf(\"\\n\");\n\n\n\t\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "011206cc2e011e0fba5c310326c18f89", "src_uid": "d65e91dc274c6659cfdb50bc8b8020ba", "difficulty": 2200.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n#define int long long\nconst int N=65,M=1e9+7,L=18;\nint n,m,p,a[N],C[N][N],f[N][1<=0;i--)\n\t\tfor (int j=i;j;j=(j-1)&i)cnt[i]+=cnt[i^j];\n\tf[0][0]=1;\n\tfor (int i=1;i<=n;i++)\n\t\tif (vis[i]==-1)for (int j=i-1;j>=0;j--)\n\t\t\tfor (int k=0;k<1<\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst long long mod = 1e9 + 7;\n\nint a[1000], n;\n\nint64_t fac[1000], inv_fac[1000];\n\nint64_t pw(int64_t x, int64_t y) {\n int64_t res = 1;\n while (y) {\n if (y & 1) {\n res = (res * x) % mod;\n }\n y >>= 1;\n x = (x * x) % mod;\n }\n return res;\n}\n\nvoid dfs(std::vector& is_valid, std::vector>& v,\n int k, int m, int mask, std::vector& sets) {\n if (k == m) {\n is_valid[mask] = sets.size() < 2;\n return;\n }\n dfs(is_valid, v, k + 1, m, mask, sets);\n std::vector new_sets;\n uint64_t new_mask = v[k].first;\n for (auto x : sets) {\n if (new_mask & x) {\n new_mask |= x;\n } else {\n new_sets.push_back(x);\n }\n }\n new_sets.push_back(new_mask);\n dfs(is_valid, v, k + 1, m, (mask | (1 << k)), new_sets);\n}\n\nint main() {\n cin >> n;\n for (int i = 0; i < n; i++) cin >> a[i];\n\n fac[0] = inv_fac[0] = 1;\n for (int i = 1; i < 1000; i++) {\n fac[i] = (fac[i - 1] * i) % mod;\n inv_fac[i] = (inv_fac[i - 1] * pw(i, mod - 2)) % mod;\n }\n\n vector is_root(n, 0);\n vector component_root(n, -1);\n vector> children(n), parents(n), components(n);\n for (int i = 0; i < n; i++) {\n is_root[i] = true;\n for (int j = 0; j < n; j++)\n if (j != i) {\n if (a[i] % a[j] == 0) {\n is_root[i] = false;\n break;\n }\n }\n int child_cnt = 0;\n for (int j = 0; j < n; j++) {\n if (j != i && a[j] % a[i] == 0) {\n child_cnt++;\n }\n }\n if (child_cnt < 2) is_root[i] = false;\n\n // if (is_root[i]) cerr << i << ' ' << a[i] << ' ' << child_cnt << endl;\n }\n\n for (int i = 0; i < n; i++) {\n if (is_root[i] && component_root[i] == -1) {\n component_root[i] = i;\n queue q;\n // cerr << i << ' ';\n q.push(i);\n while (!q.empty()) {\n int x = q.front();\n q.pop();\n for (int j = 0; j < n; j++) {\n if (is_root[j] && component_root[j] == -1) {\n for (int k = 0; k < n; k++) {\n if (!is_root[k] && a[k] % a[x] == 0 && a[k] % a[j] == 0) {\n // if (a[k] == 30) {\n // cerr << \"xxx \" << a[i] << ' ' << a[j] << ' ' << endl;\n //}\n component_root[j] = i;\n q.push(j);\n // cerr << j << ' ';\n break;\n }\n }\n }\n }\n }\n }\n // cerr << endl;\n }\n\n for (int i = 0; i < n; i++)\n for (int j = 0; j < n; j++) {\n if (j != i && a[i] % a[j] == 0) {\n if (is_root[j]) {\n children[j].push_back(i);\n parents[i].push_back(j);\n }\n }\n }\n\n int64_t res = 1;\n int tot_cnt = 0;\n for (int i = 0; i < n; i++) {\n if (is_root[i] && component_root[i] == i) {\n std::vector i_children, i_roots;\n for (int j = 0; j < n; j++) {\n if ((is_root[j] && component_root[j] == i)) {\n i_roots.push_back(j);\n } else if (!is_root[j] && parents[j].size() > 0 &&\n component_root[parents[j][0]] == i) {\n i_children.push_back(j);\n }\n }\n\n std::cerr << a[i] << endl;\n for (auto x : i_roots) {\n std::cerr << a[x] << ' ';\n }\n cerr << endl;\n for (auto x : i_children) {\n cerr << a[x] << ' ';\n }\n std::cerr << endl;\n std::cerr << i_children.size() << \" ---\" << endl;\n\n int children_cnt = i_children.size();\n map child_cnts_map;\n for (int x : i_children) {\n uint64_t key = 0;\n for (auto k : parents[x]) {\n key |= (1ll << k);\n }\n child_cnts_map[key]++;\n }\n cerr << child_cnts_map.size() << endl;\n\n int m = child_cnts_map.size();\n std::vector> child_cnts(child_cnts_map.begin(),\n child_cnts_map.end());\n sort(child_cnts.begin(), child_cnts.end(),\n [](const auto& a, const auto& b) {\n return __builtin_popcountll(a.first) >\n __builtin_popcountll(b.first);\n });\n int max_m = 0;\n for (; max_m < m; max_m++)\n if (__builtin_popcountll(child_cnts[max_m].first) == 1) break;\n\n /* auto is_status_valid = [&child_cnts, &m](uint64_t bitmask) -> bool {\n vector regions;\n vector new_regions;\n for (int i = 0; i < m; i++)\n if (1 & (bitmask >> i)) {\n new_regions.clear();\n uint64_t new_mask = child_cnts[i].first;\n for (auto r : regions) {\n if ((r & child_cnts[i].first)) {\n new_mask |= r;\n } else\n new_regions.push_back(r);\n }\n new_regions.push_back(new_mask);\n regions.swap(new_regions);\n }\n return regions.size() <= 1;\n };*/\n // vector> is_valid(1 << m);\n // int max_connection = 0;\n // for (int i = 0; i < m; i++) {\n //}\n\n vector is_valid(1 << m);\n vector _v;\n dfs(is_valid, child_cnts, 0, m, 0, _v);\n\n /*cout << child_cnts[0].first << \"xxxxxxxxx\"*/\n // for (int i = 0; i < (1 << m); i++) {\n // if (is_valid[i]) cerr << i << ' ';\n //}\n\n cerr << time(NULL) << endl;\n\n vector p(1 << m);\n vector sum(1 << m);\n\n p[(1 << m) - 1] = 1;\n sum[(1 << m) - 1] = 0;\n for (int bitmask = (1 << m) - 1; bitmask > 0; bitmask--) {\n if (p[bitmask]) {\n for (int k = 0; k < m; k++)\n if ((1 & (bitmask >> k))) {\n int new_sum = sum[bitmask ^ (1 << k)] =\n sum[bitmask] + child_cnts[k].second;\n\n int new_bitmask = bitmask ^ (1 << k);\n if (is_valid[new_bitmask]) {\n int add = child_cnts[k].second;\n p[new_bitmask] +=\n p[bitmask] *\n (((fac[new_sum - 1] * inv_fac[sum[bitmask]]) % mod * add) %\n mod) %\n mod;\n p[new_bitmask] %= mod;\n }\n }\n }\n }\n cerr << time(NULL) << endl;\n\n res *= p[0];\n res %= mod;\n res *= fac[children_cnt - 1 + tot_cnt];\n res %= mod;\n res *= inv_fac[children_cnt - 1];\n res %= mod;\n res *= inv_fac[tot_cnt];\n res %= mod;\n tot_cnt += children_cnt - 1;\n }\n }\n\n cout << res << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0e2083fae01c1dde2c4b5a6144e688bd", "src_uid": "c8d43a60ddc0a7b98a7269dc3a2478dc", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "///1292f\n#include \n#pragma GCC target (\"sse4.2\")\n#pragma GCC optimize(\"Ofast\")\n//#pragma GCC target(\"avx,avx2,fma\")\n#pragma GCC optimize (\"unroll-loops\")\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\n#define sp(x) fixed<\n#define F first\n#define S second\n#define int long long\nconst int MAXN = 120 + 7, MOD = 1000 * 1000 * 1000 + 7;\nconst ld EPS = ld(1e-10);\nint n, a[MAXN], sum, c[MAXN][MAXN], indeg[MAXN];\nvectoradj[MAXN], t, s;\nint ans = 1, cur= 0;\nbool mark[MAXN];\nint calc_cnt(){\n\t\n\tint ss = s.size(), ts = t.size();\n\tvectornum(ts, 0), cnt(1 << ss, 0);\n\tvector>dp(ts + 1, vector(1 << ss, 0);\n\tfor(int i = 0; i < ss; i ++)\n\t\tfor(int j = 0; j < ts; j ++)\n\t\t\tif(t[j] % s[i] == 0)\n\t\t\t\tnum[j] |= (1 << i);\n\tfor(int i = 0; i < (1 << ss); i ++)\n\t\tfor(int j = 0; j < ts; j ++)\n\t\t\tif((num[j] & i) == num[j])\n\t\t\t\tcnt[i] ++;\n\tfor(int i = 0; i < ts; i ++)\n\t\tdp[1][num[i]] ++;\n\tfor(int k = 1; k < ts; k ++){\n\t\tfor(int mask = 0; mask < (1 << ss); mask ++){\n\t\t\tdp[k][mask] %= MOD;\n\t\t\tfor(int i = 0; i < ts; i ++){\n\t\t\t\tint ands = (num[i] & mask); \t\n\t\t\t\tif(ands != num[i] && ands != 0){\n\t\t\t\t\tdp[k + 1][mask | num[i]] %= MOD;\n\t\t\t\t\tdp[k + 1][mask | num[i]] += dp[k][mask];\n\t\t\t\t\tdp[k + 1][mask | num[i]] %= MOD;\n\t\t\t\t}\n\t\t\t}\n\t\t\tdp[k + 1][mask] = ((dp[k + 1][mask]% MOD) + (1ll * (dp[k][mask] % MOD * ((cnt[mask] - k) % MOD)) % MOD) % MOD);\n\t\t}\n\t}\t\n\treturn dp[ts][(1 << ss) - 1];\n}\n\nvoid dfs(int v){\n mark[v] = 1;\n if(indeg[v] == 0){\n s.pb(a[v]);\n }else{\n \tt.pb(a[v]);\n }\n for(auto u : adj[v]){\n if(!mark[u]){\n dfs(u);\n }\n }\n return;\n}\nvoid dfs_all(){\n for(int i = 0; i < n; i ++){\n if(!mark[i]){\n \ts.clear(), t.clear();\n dfs(i);\n if(!t.empty()){\n\t\t\t\tint cnt = calc_cnt(), tt = t.size() - 1;\n\t\t\t\tans = 1ll * (ans%MOD) * (cnt % MOD) % MOD;\n\t\t\t\tans = 1ll * (ans % MOD) * (c[cur + tt][tt] % MOD) % MOD;\n\t\t\t\tcur += tt;\n\t\t\t}\n }\n }\n return;\n}\nint32_t main(){\n fastio;\n for(int i = 0; i < MAXN; i ++){\n \tc[i][0] = 1;\n \tfor(int j = 1; j <= i; j ++){\n \t\tc[i][j] = (c[i - 1][j - 1] + c[i - 1][j])%MOD;\n \t}\n }\n cin >> n;\n for(int i = 0; i < n; i ++){\n cin >> a[i];\n }\n sort(a, a + n);\n for(int i = 0; i < n; i ++){\n for(int j = 0; j < n; j ++)if(i != j){\n if(a[j] % a[i] == 0){\n adj[j].pb(i);\n adj[i].pb(j);\n indeg[j] ++;\n }\n }\n }\n\n dfs_all();\n\tcout << ans % MOD << endl;\n return 0;\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "460985521c0b56467faf4069aea6de6e", "src_uid": "c8d43a60ddc0a7b98a7269dc3a2478dc", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst long long mod = 1e9 + 7;\n\nint a[1000], n;\n\nint64_t fac[1000], inv_fac[1000];\n\nint64_t pw(int64_t x, int64_t y) {\n int64_t res = 1;\n while (y) {\n if (y & 1) {\n res = (res * x) % mod;\n }\n y >>= 1;\n x = (x * x) % mod;\n }\n return res;\n}\n\nint main() {\n cin >> n;\n for (int i = 0; i < n; i++) cin >> a[i];\n\n fac[0] = inv_fac[0] = 1;\n for (int i = 1; i < 1000; i++) {\n fac[i] = (fac[i - 1] * i) % mod;\n inv_fac[i] = (inv_fac[i - 1] * pw(i, mod - 2)) % mod;\n }\n\n vector is_root(n, 0);\n vector component_root(n, -1);\n vector> children(n), parents(n), components(n);\n for (int i = 0; i < n; i++) {\n is_root[i] = true;\n for (int j = 0; j < n; j++)\n if (j != i) {\n if (a[i] % a[j] == 0) {\n is_root[i] = false;\n break;\n }\n }\n int child_cnt = 0;\n for (int j = 0; j < n; j++) {\n if (j != i && a[j] % a[i] == 0) {\n child_cnt++;\n }\n }\n if (child_cnt < 2) is_root[i] = false;\n\n // if (is_root[i]) cerr << i << ' ' << a[i] << ' ' << child_cnt << endl;\n }\n\n for (int i = 0; i < n; i++) {\n if (is_root[i] && component_root[i] == -1) {\n component_root[i] = i;\n queue q;\n // cerr << i << ' ';\n q.push(i);\n while (!q.empty()) {\n int x = q.front();\n q.pop();\n for (int j = 0; j < n; j++) {\n if (is_root[j] && component_root[j] == -1) {\n for (int k = 0; k < n; k++) {\n if (!is_root[k] && a[k] % a[x] == 0 && a[k] % a[j] == 0) {\n // if (a[k] == 30) {\n // cerr << \"xxx \" << a[i] << ' ' << a[j] << ' ' << endl;\n //}\n component_root[j] = i;\n q.push(j);\n // cerr << j << ' ';\n break;\n }\n }\n }\n }\n }\n }\n // cerr << endl;\n }\n\n for (int i = 0; i < n; i++)\n for (int j = 0; j < n; j++) {\n if (j != i && a[i] % a[j] == 0) {\n if (is_root[j]) {\n children[j].push_back(i);\n parents[i].push_back(j);\n }\n }\n }\n\n int64_t res = 1;\n int tot_cnt = 0;\n for (int i = 0; i < n; i++) {\n if (is_root[i] && component_root[i] == i) {\n std::vector i_children, i_roots;\n for (int j = 0; j < n; j++) {\n if ((is_root[j] && component_root[j] == i)) {\n i_roots.push_back(j);\n } else if (!is_root[j] && parents[j].size() > 0 &&\n component_root[parents[j][0]] == i) {\n i_children.push_back(j);\n }\n }\n\n std::cerr << a[i] << endl;\n for (auto x : i_roots) {\n std::cerr << a[x] << ' ';\n }\n cerr << endl;\n for (auto x : i_children) {\n cerr << a[x] << ' ';\n }\n std::cerr << endl;\n std::cerr << i_children.size() << \" ---\" << endl;\n\n int children_cnt = i_children.size();\n map child_cnts_map;\n for (int x : i_children) {\n uint64_t key = 0;\n for (auto k : parents[x]) {\n key |= (1ll << k);\n }\n child_cnts_map[key]++;\n }\n cerr << child_cnts_map.size() << endl;\n\n int m = child_cnts_map.size();\n std::vector> child_cnts(child_cnts_map.begin(),\n child_cnts_map.end());\n\n cerr << time(NULL) << endl;\n /* auto is_status_valid = [&child_cnts, &m](uint64_t bitmask) -> bool {\n vector regions;\n vector new_regions;\n for (int i = 0; i < m; i++)\n if (1 & (bitmask >> i)) {\n new_regions.clear();\n uint64_t new_mask = child_cnts[i].first;\n for (auto r : regions) {\n if ((r & child_cnts[i].first)) {\n new_mask |= r;\n } else\n new_regions.push_back(r);\n }\n new_regions.push_back(new_mask);\n regions.swap(new_regions);\n }\n return regions.size() <= 1;\n };*/\n vector> is_valid(1 << m);\n vector> p(children_cnt + 1);\n for (int i = 0; i < m; i++) {\n is_valid[1 << i].push_back(child_cnts[i].first);\n for (int j = 1; j < (1 << i); j++) {\n uint64_t new_mask = child_cnts[i].first;\n for (auto x : is_valid[j]) {\n if (new_mask & x) {\n new_mask |= x;\n } else {\n is_valid[(1 << i) | j].push_back(x);\n }\n }\n is_valid[(1 << i) | j].push_back(new_mask);\n }\n }\n cerr << time(NULL) << endl;\n\n for (int k = 0; k <= children_cnt; k++) p[k].resize(1 << m);\n p[0][(1 << m) - 1] = 1;\n for (int cnt = 0; cnt < children_cnt; cnt++) {\n for (int bitmask = 0; bitmask < (1 << m); bitmask++)\n if (p[cnt][bitmask]) {\n for (int k = 0; k < m; k++)\n if ((1 & (bitmask >> k))) {\n int new_bitmask = bitmask ^ (1 << k);\n if (is_valid[new_bitmask].size() < 2) {\n int add = child_cnts[k].second;\n if (add + cnt <= children_cnt) {\n p[cnt + add][new_bitmask] +=\n p[cnt][bitmask] *\n (((fac[cnt + add - 1] * inv_fac[cnt]) % mod * add) %\n mod) %\n mod;\n p[cnt + add][new_bitmask] %= mod;\n }\n }\n }\n }\n }\n cerr << time(NULL) << endl;\n\n res *= p[children_cnt][0];\n res %= mod;\n res *= fac[children_cnt - 1 + tot_cnt];\n res %= mod;\n res *= inv_fac[children_cnt - 1];\n res %= mod;\n res *= inv_fac[tot_cnt];\n res %= mod;\n tot_cnt += children_cnt - 1;\n }\n }\n\n cout << res << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0db25d25666382e068fd145bd6529420", "src_uid": "c8d43a60ddc0a7b98a7269dc3a2478dc", "difficulty": 3500.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n#define int long long\n#define IOS ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)\nint in(){int32_t x ; scanf(\"%d\",&x) ; return x ;}\ninline long long lin() {long long x ; scanf(\"%lld\",&x) ; return x ;}\nconst int maxn = 2e5 + 10 ;\nint a[maxn] ,cnt[21] , ans;\nvector > op;\nint t;\ninline void solve(int n , int from , int to , bool rev = 0)\n{\n if (n == 0) return;\n int other = from ^ to ^ 3;\n if (rev || a[n ] == 1)\n {\n solve(n-1,from,other,true);\n for (int i = 0 ; i < a[n] ; i ++)\n op.push_back({from,to});\n solve(n-1,other,to,true);\n return ;\n }\n if (n == 1)\n {\n for (int i = 0 ; i < a[n] - 1 ; i ++)\n op.push_back({from,other});\n op.push_back({from,to});\n for (int i = 0 ; i < a[n] - 1 ; i ++)\n op.push_back({other,to});\n return ;\n }\n solve(n-1,from,to,1);\n for (int i = 0 ; i < a[n] ; i ++)\n op.push_back({from,other});\n solve(n-1,to,from,1);\n for (int i = 0 ; i < a[n] ; i ++)\n op.push_back({other,to});\n solve(n-1,from,to,0);\n}\nint32_t main()\n{\n int n = in();\n for (int i = 0 ; i < n ; i++) a[i] = in() , cnt[a[i]] ++;\n for (int i = 1 ; i <= 20 ; i ++)\n if (cnt[i]){\n a[++t] = cnt[i];\n }\n solve(t,0,2);\n cout << op.size() << \"\\n\";\n for (auto x : op)\n cout << x.first + 1 << \" \" << x.second + 1 << \"\\n\";\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2bf8055e51260228c9173608dff1fbc8", "src_uid": "4ea4ad10ef422a9cd45b8a7b25d359c5", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define FORALL(i,a,b) for (int i = (a); i <= (b); i++)\n#define FOR(i,n) for (int i=0;i= (b); i--)\n#define FORIN(it,type,b) for(type::iterator it = (b).begin(); it != (b).end(); it++)\n#define pb push_back\n#define mp make_pair\ntypedef long long ll;\ntypedef long double ld;\n\n#define in cin\n#define out cout\n#define dout if(true) cout\n\n#define MAXN 25\n#define MAXS 1148576\nint A[MAXN];\nint G[MAXN];\n\ntypedef vector < pair > vpii;\n//vpii res;\n\nint smemo[MAXN][2];\n\nstack fin[4];\n\nint S(int p, int type, int me, int go, int other, vpii& tres){\n\tint & ans = smemo[p][type];\n\t//assert( ans <= 0);\t//remove this assertion, its fine\n\t//if (ans > 0) return ans;\n\t\n\tint t;\n\t\n\tif (p==1){\n\t\tif (type==0){\n\t\t\tFOR(i,G[p]-1) tres.pb( mp(me,other));\n\t\t\ttres.pb(mp(me,go));\n\t\t\tFOR(i,G[p]-1) tres.pb(mp(other,go));\n\t\t\treturn ans = 2*G[p]-1;\n\t\t}else{\n\t\t\tFOR(i,G[p]) tres.pb(mp(me,go));\n\t\t\treturn ans = G[p];\n\t\t}\n\t}\n\t\n\t//r1\n\t\n\t//int flip = S(\n\t//int norm = smemo[p-1][0];\n\t\n\tvpii r1,r2;\n\tint f = S(p-1,1,me,other,go, r1);\n\tint r = S(p-1,0,me,other,go, r2);\n\t\n\tassert((f <= r && r <= 2*f) || (r <= f && f <= 2*r));\n\t\n\tif (type == 1){\t//get flipped\n\t\tif (f<=r){\n\t\t\tint flip1 = S(p-1,1,me,other,go, tres);\n\t\t\tFOR(i,G[p]) tres.pb(mp(me,go));\n\t\t\tint flip2 = S(p-1,1,other,go,me, tres);\n\t\t\tassert(flip1 == flip2);\n\t\t\tans = flip1 + flip2 + G[p];\n\t\t\treturn ans;\n\t\t}else{\n\t\t\tint norm1 = S(p-1,0,me,other,go, tres);\n\t\t\tFOR(i,G[p]) tres.pb(mp(me,go));\n\t\t\tint norm2 = S(p-1,0,other,go,me, tres);\n\t\t\tassert(norm1 == norm2);\n\t\t\tans = norm1 + norm2 + G[p];\n\t\t\treturn ans;\n\t\t}\n\t}else if (G[p] == 1){ //go normal\n\t\tif (f <= r){\n\t\t\tint flip1 = S(p-1,1,me,other,go, tres);\n\t\t\ttres.pb(mp(me,go));\n\t\t\tint flip2 = S(p-1,1,other,go,me, tres);\n\t\t\tassert(flip1 == flip2);\n\t\t\t//int norm = S(p-1,0,other,go,me,r3);\n\t\t\tans = G[p] + flip1 + flip2;\n\t\t\treturn ans;\n\t\t}else{\n\t\t\tint norm1 = S(p-1,0,me,other,go,tres);\n\t\t\ttres.pb(mp(me,go));\n\t\t\tint norm2 = S(p-1,0,other,go,me, tres);\n\t\t\tassert(norm1 == norm2);\n\t\t\tans = G[p] + norm1 + norm2;\n\t\t\treturn ans;\n\t\t}\n\t}else{\n\t\tif (f <= r){\n\t\t\tint flip1 = S(p-1,1,me,go,other, tres);\n\t\t\tFOR(i,G[p]) tres.pb(mp(me,other));\n\t\t\tint flip2 = S(p-1,1,go,me,other, tres);\n\t\t\tassert(flip1 == flip2);\n\t\t\tFOR(i,G[p]) tres.pb(mp(other,go));\n\t\t\tint norm = S(p-1,0,me,go,other,tres);\n\t\t\tans = flip1 + flip2 + norm + 2*G[p];\n\t\t\treturn ans;\n\t\t}else{\n\t\t\tint norm1 = S(p-1,0,me,go,other, tres);\n\t\t\tFOR(i,G[p]) tres.pb(mp(me,other));\n\t\t\tint norm2 = S(p-1,0,go,me,other, tres);\n\t\t\tassert(norm1 == norm2);\n\t\t\tFOR(i,G[p]) tres.pb(mp(other,go));\n\t\t\tint norm3 = S(p-1,0,me,go,other,tres);\n\t\t\tassert(norm1 == norm3);\n\t\t\tans = norm1 + norm2 + norm3 + 2*G[p];\n\t\t\treturn ans;\n\t\t}\n\t}\n\t\n\tthrow \"bad!\";\n}\n\nint main()\n{\n\tint N;\n\tin >> N;\n\tint P = 0;\n\tmemset(G,0,sizeof(G));\n\tFOR(i,N) {\n\t\tin >> A[i];\n\t\tfin[1].push(A[i]);\n\t\tif (!(G[P] == 0 || A[i] == A[i-1])){ P++;}\n\t\tG[P]++;\n\t}\n\tP++;\n\t//cout << P << endl;\n\tG[P] = 0; reverse(G,G+P+1);\n\tA[N] = 0; reverse(A,A+N+1);\n\n\tvpii res;\n\tint ans = S(P,0,1,3,2,res);\n\t\n\tassert(ans == res.size());\n\tcout << ans << endl;\n\tFOR(i,ans){\n\t\tcout << res[i].first << \" \" << res[i].second << endl;\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a4f1ffb7a7cd9b4a3aad844b38816498", "src_uid": "4ea4ad10ef422a9cd45b8a7b25d359c5", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define FORALL(i,a,b) for (int i = (a); i <= (b); i++)\n#define FOR(i,n) for (int i=0;i= (b); i--)\n#define FORIN(it,type,b) for(type::iterator it = (b).begin(); it != (b).end(); it++)\n#define pb push_back\n#define mp make_pair\ntypedef long long ll;\ntypedef long double ld;\n\n#define in cin\n#define out cout\n#define dout if(true) cout\n\n#define MAXN 25\n#define MAXS 1148576\nint A[MAXN];\nint G[MAXN];\n\ntypedef vector < pair > vpii;\n//vpii res;\n\nint smemo[MAXN][2];\n\nstack fin[4];\n\nint S(int p, int type, int me, int go, int other, vpii& tres){\n\tint & ans = smemo[p][type];\n\t//assert( ans <= 0);\t//remove this assertion, its fine\n\t//if (ans > 0) return ans;\n\t\n\tint t;\n\t\n\tif (p==1){\n\t\tif (type==0){\n\t\t\tFOR(i,G[p]-1) tres.pb( mp(me,other));\n\t\t\ttres.pb(mp(me,go));\n\t\t\tFOR(i,G[p]-1) tres.pb(mp(other,go));\n\t\t\treturn ans = 2*G[p]-1;\n\t\t}else{\n\t\t\tFOR(i,G[p]) tres.pb(mp(me,go));\n\t\t\treturn ans = G[p];\n\t\t}\n\t}\n\t\n\t//r1\n\t\n\t//int flip = S(\n\t//int norm = smemo[p-1][0];\n\t\n\tvpii r1,r2;\n\tint f = S(p-1,1,me,other,go, r1);\n\tint r = S(p-1,0,me,other,go, r2);\n\t\n\tassert((f <= r && r <= 2*f) || (r <= f && f <= 2*r));\n\t\n\tif (type == 1){\t//get flipped\n\t\tif (f<=r){\n\t\t\tint flip1 = S(p-1,1,me,other,go, tres);\n\t\t\tFOR(i,G[p]) tres.pb(mp(me,go));\n\t\t\tint flip2 = S(p-1,1,other,go,me, tres);\n\t\t\tassert(flip1 == flip2);\n\t\t\tans = flip1 + flip2 + G[p];\n\t\t\treturn ans;\n\t\t}else{\n\t\t\tint norm1 = S(p-1,0,me,other,go, tres);\n\t\t\tFOR(i,G[p]) tres.pb(mp(me,go));\n\t\t\tint norm2 = S(p-1,0,other,go,me, tres);\n\t\t\tassert(norm1 == norm2);\n\t\t\tans = norm1 + norm2 + G[p];\n\t\t\treturn ans;\n\t\t}\n\t}else if (G[p] == 1){ //go normal\n\t\tif (f <= r){\n\t\t\tint flip1 = S(p-1,1,me,other,go, tres);\n\t\t\ttres.pb(mp(me,go));\n\t\t\tint flip2 = S(p-1,1,other,go,me, tres);\n\t\t\tassert(flip1 == flip2);\n\t\t\t//int norm = S(p-1,0,other,go,me,r3);\n\t\t\tans = G[p] + flip1 + flip2;\n\t\t\treturn ans;\n\t\t}else{\n\t\t\tint norm1 = S(p-1,0,me,other,go,tres);\n\t\t\ttres.pb(mp(me,go));\n\t\t\tint norm2 = S(p-1,0,other,go,me, tres);\n\t\t\tassert(norm1 == norm2);\n\t\t\tans = G[p] + norm1 + norm2;\n\t\t\treturn ans;\n\t\t}\n\t}else{\n\t\tif (f <= r){\n\t\t\tint flip1 = S(p-1,1,me,go,other, tres);\n\t\t\tFOR(i,G[p]) tres.pb(mp(me,other));\n\t\t\tint flip2 = S(p-1,1,go,me,other, tres);\n\t\t\tassert(flip1 == flip2);\n\t\t\tFOR(i,G[p]) tres.pb(mp(other,go));\n\t\t\tint norm = S(p-1,0,me,go,other,tres);\n\t\t\tans = flip1 + flip2 + norm + 2*G[p];\n\t\t\treturn ans;\n\t\t}else{\n\t\t\tint norm1 = S(p-1,0,me,go,other, tres);\n\t\t\tFOR(i,G[p]) tres.pb(mp(me,other));\n\t\t\tint norm2 = S(p-1,0,go,me,other, tres);\n\t\t\tassert(norm1 == norm2);\n\t\t\tFOR(i,G[p]) tres.pb(mp(other,go));\n\t\t\tint norm3 = S(p-1,0,me,go,other,tres);\n\t\t\tassert(norm1 == norm3);\n\t\t\tans = norm1 + norm2 + norm3 + 2*G[p];\n\t\t\treturn ans;\n\t\t}\n\t}\n\t\n\tthrow \"bad!\";\n}\n\nint main()\n{\n\tint N;\n\tin >> N;\n\tint P = 0;\n\tmemset(G,0,sizeof(G));\n\tFOR(i,N) {\n\t\tin >> A[i];\n\t\tfin[1].push(A[i]);\n\t\tif (!(G[P] == 0 || A[i] == A[i-1])){ P++;}\n\t\tG[P]++;\n\t}\n\tP++;\n\t//cout << P << endl;\n\tG[P] = 0; reverse(G,G+P+1);\n\tA[N] = 0; reverse(A,A+N+1);\n\n\tvpii res;\n\tint ans = S(P,0,1,3,2,res);\n\t\n\tassert(ans == res.size());\n\tcout << ans << endl;\n\tFOR(i,ans){\n\t\tcout << res[i].first << \" \" << res[i].second << endl;\n\t}\n\t/*\n\tFOR(i,3){\n\t\twhile (!fin[i].empty()){\n\t\t\tint x = fin[i].top(); fin[i].pop();\n\t\t\tcout << x << \" \";\n\t\t}cout << endl;\n\t}*/\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3399ecece7319d7eeb988b3a062b33a8", "src_uid": "4ea4ad10ef422a9cd45b8a7b25d359c5", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nint cnt[21],s;\nint n;\nint a[21];\nint rx[2010],ry[2010],ans;\nvoid work(int a,int b,int c)\n{\n\tfor(int i=1;i<=c;i++)\n\t{\n\t\tans++;\n\t\trx[ans]=a;\n\t\try[ans]=b;\n\t}\n}\nvoid solve(int x,int a,int b,int c,int t)\n{\n\tif(x==s)\n\t{\n\t\tif(cnt[x]==1 || t)work(a,c,cnt[x]);\n\t\telse\n\t\t{\n\t\t\twork(a,b,cnt[x]-1);\n\t\t\twork(a,c,1);\n\t\t\twork(b,c,cnt[x]-1);\n\t\t}\n\t}\n\telse if(cnt[x]==1 || t)\n\t{\n\t\tsolve(x+1,a,c,b,1);\n\t\twork(a,c,cnt[x]);\n\t\tsolve(x+1,b,a,c,1);\n\t}\n\telse\n\t{\n\t\tsolve(x+1,a,b,c,1);\n\t\twork(a,b,cnt[x]);\n\t\tsolve(x+1,c,b,a,1);\n\t\twork(b,c,cnt[x]);\n\t\tsolve(x+1,a,b,c,0);\n\t}\n}\nint main()\n{\n\tscanf(\"%d\",&n);\n\tfor(int i=1;i<=n;i++)scanf(\"%d\",a+i);\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tif(a[i]!=a[i-1])s++;\n\t\tcnt[s]++;\n\t}\n\tsolve(1,1,2,3,0);\n\tprintf(\"%d\\n\",ans);\n\tfor(int i=1;i<=ans;i++)printf(\"%d %d\\n\",rx[i],ry[i]);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a258fdcd1973dcd09185bef6fc9eeed3", "src_uid": "4ea4ad10ef422a9cd45b8a7b25d359c5", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "#include \"bits/stdc++.h\"\n#include \nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\n#define PB push_back\n#define MP make_pair\nconst int MOD=1000000007;\n#define endl \"\\n\"\n#define fst first\n#define snd second\nconst int UNDEF = -1;\nconst ll INF=1e18;\ntemplate inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }\ntemplate inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }\ntypedef pair pll;typedef vector vll;typedef pair pii;typedef vector vi;typedef vector vvi;\n#define DEBUG_CAT\n#ifdef DEBUG_CAT\n#define dbg(...) printf( __VA_ARGS__ )\n#else \n#define dbg(...) /****nothing****/\n#endif\nint rint();char rch();long long rlong();\nconst int mn=52;\nint mod_pow(int a, int n, int mod) { int ret = 1; int p = a % mod; while (n) { if (n & 1) ret = (ret *(ll) p) % mod; p = (p *(ll) p) % mod; n >>= 1; } return ret; }\nconst int MAXFACT=52;\nint fact[MAXFACT+1],invfact[MAXFACT+1];\ninline int mul(int x,int y) {return (x*(ll)y)%MOD;}\nvoid init() {\n int got=1;\n for (int x=0;x<=MAXFACT;x++) {\n fact[x]=got;\n got=mul(got,x+1);\n }\n got=mod_pow(got,MOD-2,MOD);\n for (int x=MAXFACT;x>=0;x--) {\n got=mul(got,x+1);\n invfact[x]=got;\n }\n}\nint dpg[mn][mn];\nint h[mn][mn];\nconst int mc=51;\nint g(int n, int f) {\n if (dpg[n][f]!=-1) {\n //printf(\"n:%d f:%d ans:%d\\n\",n,f,dpg[n][f]);\n return dpg[n][f];\n }\n int ans=0;\n for (int na=0;na<=n;na++) {\n int nb=n-na;\n for (int fa=f;fa<=mc;fa++) {\n int fb=f;\n ans=(ans + (h[na][fa]*(ll)(h[nb][fb])))%MOD;\n }\n for (int fb=f+1;fb<=mc;fb++) {\n int fa=f;\n ans=(ans + (h[na][fa]*(ll)(h[nb][fb])))%MOD;\n }\n }\n //printf(\"G n:%d f:%d ans:%d\\n\",n,f,ans);\n return dpg[n][f]=ans;\n}\nint binom(int n, int k) {\n if (k==0) return 1;\n if (n>k) return 0;\n int numer=n;\n for (int i=1;i=1;fstep--) {\n int klim=min((gn)/nstep, gf/fstep);\n int possible=g(nstep-1,fstep);\n //printf(\"nstep:%d fstep:%d possible:%d klim:%d\\n\",nstep,fstep,possible,klim);\n int ncost=nstep,fcost=fstep;\n int numer=possible;\n for (int k=1;k<=klim;k++) {\n int bin=mul(numer,invfact[k]);\n for (int n=gn;n>=ncost;n--) {\n for (int f=gf;f>=fcost;f--) {\n int prev=h[n-ncost][f-fcost];\n ll toadd=prev*(ll)bin;\n //printf(\"n:%d f:%d prev:%d bin:%d gf:%d\\n\",n,f,prev,bin,gf);\n h[n][f]=(h[n][f]+toadd)%MOD;\n }\n }\n ncost+=nstep;\n fcost+=fstep;\n numer=mul(numer,possible+k);\n }\n }\n }\n return h[gn][igf];\n}\n\nint main()\n{\n ios_base::sync_with_stdio(false); cin.tie(0);\n init();\n //for (int flim=0;flim= '0' && *stdinPos <= '9') {\n x *= 10;\n x += *stdinPos - '0';\n ++stdinPos;\n }\n\n return neg ? -x : x;\n}\nchar rch()\n{\n readAhead(16);\n while(*stdinPos==' '||*stdinPos=='\\n') ++stdinPos;\n char ans=*stdinPos;\n ++stdinPos;\n return ans;\n}\nlong long rlong()\n{\n readAhead(32);\n\n long long x = 0;\n bool neg = false;\n while(*stdinPos==' '||*stdinPos=='\\n') ++stdinPos;\n if (*stdinPos == '-') {\n ++stdinPos;\n neg = true;\n }\n\n while (*stdinPos >= '0' && *stdinPos <= '9') {\n x *= 10;\n x += *stdinPos - '0';\n ++stdinPos;\n }\n\n return neg ? -x : x;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "af4e4dc2de068d79fa717665ebafff76", "src_uid": "aca6148effff8b893c961b1ee465e4e4", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nconst int MOD = 1'000'000'007;\n\nint n, k;\nint sol[55][55];\nint dp[2][55][55];\nint bk[105][105];\nint dabl[55][55];\nint dabl_ex[55][55][55];\n\ninline void dod(int& x, int y) {\n\tx += y;\n\tif (x >= MOD) {\n\t\tx -= MOD;\n\t}\n}\n\n/*\n\tsol[i][j] = Imas u pocetku jednu granu. Dodaj i novih\n\tcvorova tako da flow bude tacno j << broj nacina.\n\n\tdp[a][b][i][j] = U pocetku nemas granu. Broj nacina \n\tda dodas i cvorova, tako da je flow tacno j i tako da\n\tkoristis samo dabl-komponente koje su formata *lex*<= (a, b)\n\n\tdabl[i][j] = Imas jedan cvor na sredini a sve ostalo sto si\n\tdodao si nakacio na jednu od ove dve grane gore. U zbiru\n\timas i cvorova i protok je j\n*/\n\nint mpow(int a, int b) {\n\tif (b == 0) {\n\t\treturn 1;\n\t}\n\tint t = mpow(a, b/2);\n\tif (b % 2) {\n\t\treturn t * 1ll * t % MOD * a % MOD;\n\t} else {\n\t\treturn t * 1ll * t % MOD;\n\t}\n}\n\nint fact[105], finv[105];\nint inv[105];\n\nint main() {\n\tios_base::sync_with_stdio(false);\n\tcin.tie(nullptr);\n\tcout.tie(nullptr);\n\tcerr.tie(nullptr);\n\n\tcin >> n >> k;\n\n\tsol[0][1] = 1;\n\n\tfact[0] = finv[0] = 1;\n\tfor (int i=1; i<=104; i++) {\n\t\tfact[i] = fact[i-1] * 1ll * i % MOD;\n\t\tfinv[i] = mpow(fact[i], MOD - 2);\n\t\tinv[i] = mpow(i, MOD-2);\n\t}\n\n\tfor (int i=1; i<=n+1; i++) {\n\t\tfor (int j=1; j<=n+1; j++) {\n\t\t\tdabl_ex[i][j][0] = 1;\n\t\t}\n\t}\n\n\tfor (int i=1; i<=n; i++) {\n\t\tfor (int j=1; j<=min(k, i)+1; j++) {\n\n\t\t\tif (i - j > n - k + 1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// izracunaj dabl\n\t\t\tfor (int li=0; li j\n\t\t\t\tfor (int rj=j+1; rj<=ri+1; rj++) {\n\t\t\t\t\tdod(dabl[i][j], sol[li][j] * 1ll * sol[ri][rj] % MOD);\n\t\t\t\t}\n\n\t\t\t\t// lj > j, rj = j\n\t\t\t\tfor (int lj=j+1; lj<=li+1; lj++) {\n\t\t\t\t\tdod(dabl[i][j], sol[li][lj] * 1ll * sol[ri][j] % MOD);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// extenduj dabl\n\n\t\t\t{\n\t\t\t\tint run_and_gun = 1;\n\t\t\t\tfor (int rep=0; rep<=n+1; rep++) {\n\t\t\t\t\tdabl_ex[i][j][rep] = run_and_gun;\n\t\t\t\t\trun_and_gun = run_and_gun * 1ll * (dabl[i][j] + rep) % MOD;\n\t\t\t\t\trun_and_gun = run_and_gun * 1ll * inv[rep+1] % MOD;\n\t\t\t\t}\n\t\t\t}\t\t\t\t\n\n\t\t\t// cerr << \"dabl \" << i << ' ' << j << \": \" << dabl[i][j] << '\\n';\n\n\t\t\t// dodaj jedno po jedno\n\t\t\tauto prev = dp[0];\n\t\t\tauto curr = dp[1];\n\n\t\t\tmemset(dp, 0, sizeof(dp));\n\n\t\t\tprev[0][0] = 1;\n\n\t\t\tfor (int a=1; a<=i; a++) {\n\t\t\t\tfor (int b=1; b<=min(j, (a+1)/2); b++) {\n\n\t\t\t\t\tmemset(curr, 0, sizeof(dp[0]));\n\t\t\t\t\tcurr[0][0] = 1;\n\n\t\t\t\t\tfor (int rep=0; rep<=i; rep++) {\n\n\t\t\t\t\t\tint dex = dabl_ex[a][b][rep];\n\n\t\t\t\t\t\tfor (int c=max(1, a*rep); c<=i; c++) {\n\t\t\t\t\t\t\tfor (int d=max(1, b*rep); d<=min(c, j); d++) {\n\n\t\t\t\t\t\t\t\tdod(curr[c][d], prev[c - a*rep][d - b*rep] *\n\t\t\t\t\t\t\t\t\t1ll * dex % MOD);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tswap(prev, curr);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// cerr << \"chk \" << dp[3][1][3][1] << '\\n';\n\n\t\t\tsol[i][j] = prev[i][j-1];\n\n\t\t\t// cerr << \"sol \" << i << ' ' << j << \": \" << sol[i][j] << '\\n';\n\t\t}\n\t}\n\n\tcout << sol[n][k] << '\\n';\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a6d4652d7ae3c644bd9e0c646a5f52f6", "src_uid": "aca6148effff8b893c961b1ee465e4e4", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "\n\n#include \nusing namespace std;\nconst int maxn = 52, mod = 1000000007;\ntypedef long long LL;\nint N, M, F[maxn][maxn], G[maxn][maxn], inv[maxn];\n\nvoid init()\n{\n scanf(\"%d%d\", &N, &M);\n inv[1] = 1;\n for(int i = 2;i < maxn;++i)\n inv[i] = LL(mod-mod/i) * inv[mod%i] % mod;\n}\nvoid work()\n{\n F[0][1] = 1;\n for(int i = 1;i <= N;++i) for(int j = 1;j < maxn;++j)\n {\n for(int a = 0;a < i;++a)\n {\n G[i][j] = (G[i][j] + (LL) F[a][j] * F[i-1-a][j]) % mod;\n for(int b = j+1;b <= i+1 && b < maxn;++b)\n {\n G[i][j] = (G[i][j] + (LL) F[a][b] * F[i-1-a][j]) % mod;\n G[i][j] = (G[i][j] + (LL) F[a][j] * F[i-1-a][b]) % mod;\n }\n }\n //get G[i][j]\n for(int x = N-1;x >= 0;--x) for(int y = 1;y < maxn;++y) if(F[x][y])\n {\n int C = 1;\n for(int t = 1;x+t*i <= N && y+t*j < maxn;++t)\n {\n C = (LL) C * (G[i][j]-1+t) % mod * inv[t] % mod;\n F[x+t*i][y+t*j] = (F[x+t*i][y+t*j] + (LL) F[x][y] * C) % mod;\n }\n }\n }\n printf(\"%d\\n\", F[N][M]);\n}\nint main()\n{\n init();\n work();\n return 0;\n}\n\n\u52a8\u6001\u89c4\u5212", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f30ff1cde22287772d7172bcd5de2dbd", "src_uid": "aca6148effff8b893c961b1ee465e4e4", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "By Asm.Def, contest: Codeforces Round #431 (Div. 1), problem: (D) Shake It!, Accepted, #\n\n#include \nusing namespace std;\nconst int maxn = 52, mod = 1000000007;\ntypedef long long LL;\nint N, M, F[maxn][maxn], G[maxn][maxn], inv[maxn];\n\nvoid init()\n{\n scanf(\"%d%d\", &N, &M);\n inv[1] = 1;\n for(int i = 2;i < maxn;++i)\n inv[i] = LL(mod-mod/i) * inv[mod%i] % mod;\n}\nvoid work()\n{\n F[0][1] = 1;\n for(int i = 1;i <= N;++i) for(int j = 1;j < maxn;++j)\n {\n for(int a = 0;a < i;++a)\n {\n G[i][j] = (G[i][j] + (LL) F[a][j] * F[i-1-a][j]) % mod;\n for(int b = j+1;b <= i+1 && b < maxn;++b)\n {\n G[i][j] = (G[i][j] + (LL) F[a][b] * F[i-1-a][j]) % mod;\n G[i][j] = (G[i][j] + (LL) F[a][j] * F[i-1-a][b]) % mod;\n }\n }\n //get G[i][j]\n for(int x = N-1;x >= 0;--x) for(int y = 1;y < maxn;++y) if(F[x][y])\n {\n int C = 1;\n for(int t = 1;x+t*i <= N && y+t*j < maxn;++t)\n {\n C = (LL) C * (G[i][j]-1+t) % mod * inv[t] % mod;\n F[x+t*i][y+t*j] = (F[x+t*i][y+t*j] + (LL) F[x][y] * C) % mod;\n }\n }\n }\n printf(\"%d\\n\", F[N][M]);\n}\nint main()\n{\n init();\n work();\n return 0;\n}\n\n\u52a8\u6001\u89c4\u5212", "lang_cluster": "C++", "compilation_error": true, "code_uid": "205a52d2541fb4866133fb43f03243de", "src_uid": "aca6148effff8b893c961b1ee465e4e4", "difficulty": 2900.0} {"lang": "GNU C++", "source_code": "/** ` Micro Mezzo Macro Flation -- Overheated Economy ., **/\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define REP(i, n) for (int i=0;i=int(a);--i)\n#define REP_1(i, n) for (int i=1;i<=int(n);++i)\n#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)\n#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)\n#define REP_C(i, n) for (int n____=int(n),i=0;i=a____;--i)\n#define REP_N(i, n) for (i=0;i=int(a);--i)\n#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)\n#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)\n#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)\n#define REP_1_N(i, n) for (i=1;i<=int(n);++i)\n#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)\n#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)\n#define REP_C_N(i, n) for (n____=int(n),i=0;i=a____;--i)\n#define REP_1_C_N(i, n) for (n____=int(n),i=1;i<=n____;++i)\n#define FOR_1_C_N(i, a, b) for (b____=int(b),i=a;i<=b____;++i)\n#define DWN_1_C_N(i, b, a) for (a____=int(a),i=b;i>=a____;--i)\n\n#define DO(n) while(n--)\n#define DO_C(n) int n____ = n; while(n____--)\n#define TO(i, a, b) int s_=a VI;\ntypedef vector VC;\ntypedef vector VS;\ntypedef vector VL;\ntypedef vector VD;\ntypedef set SI;\ntypedef set SS;\ntypedef set SL;\ntypedef set SD;\ntypedef map MII;\ntypedef map MSI;\ntypedef map MLI;\ntypedef map MDI;\ntypedef map MIB;\ntypedef map MSB;\ntypedef map MLB;\ntypedef map MDB;\ntypedef pair PII;\ntypedef pair PIB;\ntypedef vector VII;\ntypedef vector VVI;\ntypedef vector VVII;\ntypedef set SII;\ntypedef map MPIII;\ntypedef map MPIIB;\n\n\n/** I/O Accelerator **/\n\n/* ... :\" We are I/O Accelerator ... Use us at your own risk ;) ... \" .. */\n\ntemplate inline void RD(T &);\ntemplate inline void OT(const T &);\n\ntemplate inline T& _RD(T &x){ RD(x); return x;}\ninline int RD(){ int x; RD(x); return x;}\ninline LL RD_LL(){ LL x; RD(x); return x;}\ninline DB RD_DB(){ DB x; RD(x); return x;}\n\ntemplate inline void RD(T0 &x0, T1 &x1){RD(x0), RD(x1);}\ntemplate inline void RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2);}\ntemplate inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3);}\ntemplate inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4);}\ntemplate inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5);}\ntemplate inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6);}\ntemplate inline void OT(T0 &x0, T1 &x1){OT(x0), OT(x1);}\ntemplate inline void OT(T0 &x0, T1 &x1, T2 &x2){OT(x0), OT(x1), OT(x2);}\ntemplate inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}\ntemplate inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}\ntemplate inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}\ntemplate inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}\n\ntemplate inline void RST(T &A){memset(A, 0, sizeof(A));}\ntemplate inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}\ntemplate inline void CLR(T &A){A.clear();}\ntemplate inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}\ntemplate inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}\ntemplate inline void FLC(T &A, int x){memset(A, x, sizeof(A));}\ntemplate inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2){FLC(A0), FLC(A1), FLC(A2);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3){FLC(A0), FLC(A1), FLC(A2), FLC(A3);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5), FLC(A6);}\n\ntemplate inline void SRT(T &A){sort(ALL(A));}\ntemplate inline void SRT(T &A, C B){sort(ALL(A), B);}\n\n\n/** Add - On **/\n\nconst int MOD = 1000000007;\nconst int INF = 0x7fffffff;\nconst DB PI = acos(-1.0);\nconst DB EPS = 1e-6;\nconst DB OO = 1e15;\n\n// <<= ` 0. Daily Use .,\n\ntemplate inline void checkMin(T &a,const T b){if (b inline void checkMax(T &a,const T b){if (b>a) a=b;}\ntemplate inline void checkMin(T& a, const T b, C c){if (c(b,a)) a = b;}\ntemplate inline void checkMax(T& a, const T b, C c){if (c(a,b)) a = b;}\ntemplate inline T min(T a, T b, T c){return min(min(a, b), c);}\ntemplate inline T max(T a, T b, T c){return max(max(a, b), c);}\ntemplate inline T sqr(T a){return a*a;}\ntemplate inline T cub(T a){return a*a*a;}\nint Ceil(int x, int y){return (x - 1) / y + 1;}\n\n// <<= ` 1. Bitwise Operation .,\n\ninline bool _1(int x, int i){return x & 1<> 1);\n x = (x & 0x33333333) + ((x & 0xcccccccc) >> 2);\n x = (x & 0x0f0f0f0f) + ((x & 0xf0f0f0f0) >> 4);\n x = (x & 0x00ff00ff) + ((x & 0xff00ff00) >> 8);\n x = (x & 0x0000ffff) + ((x & 0xffff0000) >> 16);\n return x;\n}\n\ntemplate inline T low_bit(T x) {\n return x & -x;\n}\n\ntemplate inline T high_bit(T x) {\n T p = low_bit(x);\n while (p != x) x -= p, p = low_bit(x);\n return p;\n}\n\n// <<= ` 2. Modular Arithmetic Basic .,\n\ninline void INC(int &a, int b){a += b; if (a >= MOD) a -= MOD;}\ninline int sum(int a, int b){a += b; if (a >= MOD) a -= MOD; return a;}\ninline void DEC(int &a, int b){a -= b; if (a < 0) a += MOD;}\ninline int dff(int a, int b){a -= b; if (a < 0) a += MOD; return a;}\ninline void MUL(int &a, int b){a = (LL)a * b % MOD;}\ninline int pdt(int a, int b){return (LL)a * b % MOD;}\n\n\n// <<= ' 9. Computational Geometry .,\n\n\n// <<= ' 0. I/O Accelerator interface .,\n\ntemplate inline void RD(T &x){\n cin >> x;\n //scanf(\"%d\", &x);\n //char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';\n //char c; c = getchar(); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';\n\n}\n\nint ____Case;\ntemplate inline void OT(const T &x){\n cout << x << endl;\n //printf(\"%d\\n\", x);\n //printf(\"%.9lf\\n\", x);\n //printf(\"Case %d: %d\\n\", ++____Case, x);\n}\n\n\n#define For_each(it, A) for (SII::iterator it = A.begin(); it != A.end(); ++it)\n#define Foreach(it, A ) for(__typeof(A.begin()) it =A.begin(); it!=A.end(); ++it)\n\n/* .................................................................................................................................. */\n\n#define fi first\n#define se second\n#define pb push_back\n#define mp make_pair\n\ntypedef pair PIF;\n\nint sgn(DB x){\n return x < -EPS ? -1 : x > EPS;\n}\n\nstruct Po{\n DB x, y;\n\n Po(){}\n Po(DB _x, DB _y):x(_x),y(_y){}\n\n bool operator <(const Po& rhs) const {\n return sgn(x - rhs.x) < 0 || !sgn(x - rhs.x) && sgn(y - rhs.y) < 0;\n }\n\n bool operator ==(const Po& rhs) const {\n return !sgn(x - rhs.x) && !sgn(y - rhs.y);\n }\n\n bool operator !=(const Po& rhs) const {\n return !(*this == rhs);\n }\n void input(){\n scanf(\"%lf%lf\", &x, &y);\n }\n};\n\nstruct line{\n Po x, y;\n\n line(){}\n line(Po _x,Po _y):x(_x),y(_y){}\n\n void input(){x.input(), y.input();}\n};\n\n\nstruct node{\n\n string c;vector a;double sz;\n node(string _c,double _sz=0):c(_c),sz(_sz){}\n void add(int x){a.pb(x);}\n};\n\n\n Po med(Po a,Po b,Po c)\n {\n\n return __median(a, b, c);\n\n // if(a p)\n {\n double S=0;\n for(int i=0;i<(int)p.size();i++)\n {\n int j=(i+1)%(int)p.size();\n S+=p[i].x*p[j].y-p[j].x*p[i].y;\n }\n return -S/2;\n }\n double crs(Po a,Po b,Po c)\n {\n return (b.y-a.y)*(c.x-a.x)-(b.x-a.x)*(c.y-a.y);\n }\n int inpoly(Po p,vector a)\n {\n int n=(int)a.size();a.pb(a[0]);\n for(int i=0;ip.y&&crs(a[i],a[i+1],p)<0)++w;else\n if(a[i].y>p.y&&a[i+1].y<=p.y&&crs(a[i],a[i+1],p)>0)--w;\n return w;\n }\n int w,h,n,m,p;\n\n\n\n vector po;\n vector > pa;\n vector gr;\n vector bl;\n vector fl;\n vector > pl;\n\n void bfs(int x,string c)\n {\n string d=gr[x].c;\n queue q;vector v((int)gr.size(),0);\n v[x]=1,q.push(x);\n while(!q.empty())\n {\n int x=q.front();q.pop();\n gr[x].c=c;\n for(int i=0;i<(int)gr[x].a.size();i++)\n if(!v[gr[x].a[i]]&&gr[gr[x].a[i]].c==d)\n q.push(gr[x].a[i]),v[gr[x].a[i]]=1;\n }\n }\n\n\nint main(){\n //scanf(\"%d%d%d\",&w,&h,&n);\n\n RD(w, h, n);\n\n vector l0(n);\n\n REP(i, n) l0[i].input();\n\n //for(int i=0;i vp;\n for(int j=0;j q;\n q.push(i);\n gr.pb(node(\"black\",0.0));\n bl[i]=++p,fl.pb(po[i]);\n while(!q.empty())\n {\n int x=q.front();q.pop();\n for(int j=0;j<(int)pa[x].size();j++)\n if(bl[pa[x][j].fi]==-1)\n q.push(pa[x][j].fi),\n bl[pa[x][j].fi]=p;\n }\n }\n pl.resize(p+1);\n vector > chk(m);\n for(int i=0;i vp;\n int i0=i,j0=j;\n while(!chk[i0][j0])\n {\n vp.pb(po[i0]);\n chk[i0][j0]=1;\n int i1=pa[i0][j0].fi,j1=-1;\n for(int j=0;j<(int)pa[i1].size();j++)\n if(pa[i1][j].fi==i0){j1=(j+1)%(int)pa[i1].size();break;}\n i0=i1,j0=j1;\n }\n double sz=getsz(vp);\n if(sz>0)\n {\n pl.pb(vp);\n gr.pb(node(\"white\",sz));\n int r=bl[i];\n gr[r].add((int)gr.size()-1),\n gr[(int)gr.size()-1].add(r);\n gr[r].sz-=sz;\n }\n }\n for(int i=1;i<=p;i++)\n {\n int fa=0;\n for(int j=(int)pl.size()-1;j>p;j--)\n if(inpoly(fl[i],pl[j])){fa=j;break;}\n gr[fa].add(i),gr[i].add(fa),gr[fa].sz+=gr[i].sz,gr[i].sz=0;\n }\n\n\n\n int _;scanf(\"%d\",&_);\n while(_--){\n\n Po x; x.input();string c;char s[100];scanf(\"%s\",s),c=s;\n\n for(int i=0;ip;i--)\n if(inpoly(x,pl[i])){bfs(i,c);goto end;}\n bfs(0,c);\n end:;\n }\n\n\n map S;\n for(int i=0;i<(int)gr.size();i++)\n S[gr[i].c]+=gr[i].sz;\n //for(map::iterator i=S.begin();i!=S.end();i++)\n\n Foreach(it, S){\n printf(\"%s %.9lf\\n\", it->first.c_str(), it->second);\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0704d1390d7782f98837a2a47542525f", "src_uid": "92caafd07e9afb03745aa6f5b450c38f", "difficulty": 2700.0} {"lang": "GNU C++0x", "source_code": "/** Micro Mezzo Macro Flation -- Overheated Economy ., Last Update: Dec. 24th 2012 **/ //{\n\n/** Header .. **/ //{\n#define LOCAL\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define REP(i, n) for (int i=0;i=int(a);--i)\n#define REP_1(i, n) for (int i=1;i<=int(n);++i)\n#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)\n#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)\n#define REP_C(i, n) for (int n____=int(n),i=0;i=a____;--i)\n#define REP_N(i, n) for (i=0;i=int(a);--i)\n#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)\n#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)\n#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)\n#define REP_1_N(i, n) for (i=1;i<=int(n);++i)\n#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)\n#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)\n#define REP_C_N(i, n) for (int n____=(i=0,int(n));i=a____;--i)\n#define REP_1_C_N(i, n) for (int n____=(i=1,int(n));i<=n____;++i)\n#define FOR_1_C_N(i, a, b) for (int b____=(i=1,int(b);i<=b____;++i)\n#define DWN_1_C_N(i, b, a) for (int a____=(i=b,int(a));i>=a____;--i)\n\n#define ECH(it, A) for (__typeof(A.begin()) it=A.begin(); it != A.end(); ++it)\n#define REP_S(i, str) for (char*i=str;*i;++i)\n#define REP_L(i, hd, nxt) for (int i=hd;i;i=nxt[i])\n#define REP_G(i, u) REP_L(i,hd[u],suc)\n#define DO(n) for ( int ____n ## __line__ = n; ____n ## __line__ -- ; )\n#define REP_2(i, j, n, m) REP(i, n) REP(j, m)\n#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)\n#define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l)\n#define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l)\n\n#define ALL(A) A.begin(), A.end()\n#define LLA(A) A.rbegin(), A.rend()\n#define CPY(A, B) memcpy(A, B, sizeof(A))\n#define INS(A, P, B) A.insert(A.begin() + P, B)\n#define ERS(A, P) A.erase(A.begin() + P)\n#define BSC(A, x) (lower_bound(ALL(A), x) - A.begin())\n#define CTN(T, x) (T.find(x) != T.end())\n#define SZ(A) int(A.size())\n#define PB push_back\n#define MP(A, B) make_pair(A, B)\n#define PTT pair\n#define fi first\n#define se second\n\n#define Rush for(int ____T=RD(); ____T--;)\n\n#define Display(A, n, m) { \\\n\tREP(i, n){\t\t \\\n REP(j, m) cout << A[i][j] << \" \"; \\\n cout << endl;\t\t\t\t \\\n\t}\t\t\t\t\t\t \\\n}\n\n#define Display_1(A, n, m) {\t\t\t\t \\\n\tREP_1(i, n){\t\t \\\n REP_1(j, m) cout << A[i][j] << \" \"; \\\n\t\tcout << endl;\t\t \t\t\\\n\t}\t\t\t\t\t\t \\\n}\n\n#pragma comment(linker, \"/STACK:36777216\")\n//#pragma GCC optimize (\"O2\")\n#define Ruby system(\"ruby main.rb\")\n#define Haskell system(\"runghc main.hs\")\n#define Python system(\"python main.py\")\n#define Pascal system(\"fpc main.pas\")\n\ntypedef long long LL;\n//typedef long double DB;\ntypedef double DB;\ntypedef unsigned UINT;\ntypedef unsigned long long ULL;\n\ntypedef vector VI;\ntypedef vector VC;\ntypedef vector VS;\ntypedef vector VL;\ntypedef vector VF;\ntypedef set SI;\ntypedef set SS;\ntypedef map MII;\ntypedef map MSI;\ntypedef pair PII;\ntypedef pair PLL;\ntypedef vector VII;\ntypedef vector VVI;\ntypedef vector VVII;\n\ntemplate inline T& RD(T &);\ntemplate inline void OT(const T &);\ninline LL RD(){LL x; return RD(x);}\ninline DB& RF(DB &);\ninline DB RF(){DB x; return RF(x);}\ninline char* RS(char *s);\ninline char& RC(char &c);\ninline char RC();\ninline char& RC(char &c){scanf(\" %c\", &c); return c;}\ninline char RC(){char c; return RC(c);}\n//inline char& RC(char &c){c = getchar(); return c;}\n//inline char RC(){return getchar();}\n\ntemplate inline T& RDD(T &x){\n char c; for (c = getchar(); c < '-'; c = getchar());\n if (c == '-'){x = '0' - getchar(); for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + '0' - c;}\n else {x = c - '0'; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';}\n return x;\n}\n\ninline LL RDD(){LL x; return RDD(x);}\n\ntemplate inline T0& RD(T0 &x0, T1 &x1){RD(x0), RD(x1); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6); return x0;}\ntemplate inline void OT(const T0 &x0, const T1 &x1){OT(x0), OT(x1);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2){OT(x0), OT(x1), OT(x2);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}\ninline char& RC(char &a, char &b){RC(a), RC(b); return a;}\ninline char& RC(char &a, char &b, char &c){RC(a), RC(b), RC(c); return a;}\ninline char& RC(char &a, char &b, char &c, char &d){RC(a), RC(b), RC(c), RC(d); return a;}\ninline char& RC(char &a, char &b, char &c, char &d, char &e){RC(a), RC(b), RC(c), RC(d), RC(e); return a;}\ninline char& RC(char &a, char &b, char &c, char &d, char &e, char &f){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f); return a;}\ninline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g); return a;}\ninline DB& RF(DB &a, DB &b){RF(a), RF(b); return a;}\ninline DB& RF(DB &a, DB &b, DB &c){RF(a), RF(b), RF(c); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d){RF(a), RF(b), RF(c), RF(d); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e){RF(a), RF(b), RF(c), RF(d), RF(e); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g); return a;}\ninline void RS(char *s1, char *s2){RS(s1), RS(s2);}\ninline void RS(char *s1, char *s2, char *s3){RS(s1), RS(s2), RS(s3);}\ntemplateinline void RDD(const T0&a, const T1&b){RDD(a),RDD(b);}\ntemplateinline void RDD(const T0&a, const T1&b, const T2&c){RDD(a),RDD(b),RDD(c);}\n\ntemplate inline void RST(T &A){memset(A, 0, sizeof(A));}\ntemplate inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}\ntemplate inline void FLC(T &A, int x){memset(A, x, sizeof(A));}\ntemplate inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x), FLC(A6, x);}\ntemplate inline void CLR(priority_queue, less > &Q){while (!Q.empty()) Q.pop();}\ntemplate inline void CLR(priority_queue, greater > &Q){while (!Q.empty()) Q.pop();}\ntemplate inline void CLR(T &A){A.clear();}\ntemplate inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}\ntemplate inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}\n\ntemplate inline T& SRT(T &A){sort(ALL(A)); return A;}\ntemplate inline T& SRT(T &A, C B){sort(ALL(A), B); return A;}\ntemplate inline T& UNQ(T &A){A.resize(unique(ALL(SRT(A)))-A.begin());return A;}\n\n//}\n\n/** Constant List .. **/ //{\n\nconst int MOD = 1000000007;\n//int MOD = 99990001;\nconst int INF = 0x3f3f3f3f;\nconst LL INFF = 1LL << 60;\nconst DB EPS = 1e-9;\nconst DB OO = 1e20;\nconst DB PI = acos(-1.0); //M_PI;\n\nconst int dx[] = {-1, 0, 1, 0};\nconst int dy[] = {0, 1, 0, -1};\n\n//}\n\n/** Add On .. **/ //{\n// <<= '0. Nichi Joo ., //{\ntemplate inline void checkMin(T &a,const T b){if (b inline void checkMax(T &a,const T b){if (a inline void checkMin(T &a, T &b, const T x){checkMin(a, x), checkMin(b, x);}\ntemplate inline void checkMax(T &a, T &b, const T x){checkMax(a, x), checkMax(b, x);}\ntemplate inline void checkMin(T& a, const T b, C c){if (c(b,a)) a = b;}\ntemplate inline void checkMax(T& a, const T b, C c){if (c(a,b)) a = b;}\ntemplate inline T min(T a, T b, T c){return min(min(a, b), c);}\ntemplate inline T max(T a, T b, T c){return max(max(a, b), c);}\ntemplate inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}\ntemplate inline T max(T a, T b, T c, T d){return max(max(a, b), max(c, d));}\ntemplate inline T sqr(T a){return a*a;}\ntemplate inline T cub(T a){return a*a*a;}\ninline int ceil(int x, int y){return (x - 1) / y + 1;}\ninline int sgn(DB x){return x < -EPS ? -1 : x > EPS;}\ninline int sgn(DB x, DB y){return sgn(x - y);}\n//}\n// <<= '1. Bitwise Operation ., //{\nnamespace BO{\n\ninline bool _1(int x, int i){return bool(x&1<> 1) & 0x55555555) | ((x << 1) & 0xaaaaaaaa);\n x = ((x >> 2) & 0x33333333) | ((x << 2) & 0xcccccccc);\n x = ((x >> 4) & 0x0f0f0f0f) | ((x << 4) & 0xf0f0f0f0);\n x = ((x >> 8) & 0x00ff00ff) | ((x << 8) & 0xff00ff00);\n x = ((x >>16) & 0x0000ffff) | ((x <<16) & 0xffff0000);\n return x;\n}\n\ninline LL reverse_bits(LL x){\n x = ((x >> 1) & 0x5555555555555555LL) | ((x << 1) & 0xaaaaaaaaaaaaaaaaLL);\n x = ((x >> 2) & 0x3333333333333333LL) | ((x << 2) & 0xccccccccccccccccLL);\n x = ((x >> 4) & 0x0f0f0f0f0f0f0f0fLL) | ((x << 4) & 0xf0f0f0f0f0f0f0f0LL);\n x = ((x >> 8) & 0x00ff00ff00ff00ffLL) | ((x << 8) & 0xff00ff00ff00ff00LL);\n x = ((x >>16) & 0x0000ffff0000ffffLL) | ((x <<16) & 0xffff0000ffff0000LL);\n x = ((x >>32) & 0x00000000ffffffffLL) | ((x <<32) & 0xffffffff00000000LL);\n return x;\n}\n\ntemplate inline bool odd(T x){return x&1;}\ntemplate inline bool even(T x){return !odd(x);}\ntemplate inline T low_bit(T x) {return x & -x;}\ntemplate inline T high_bit(T x) {T p = low_bit(x);while (p != x) x -= p, p = low_bit(x);return p;}\ntemplate inline T cover_bit(T x){T p = 1; while (p < x) p <<= 1;return p;}\n\ninline int low_idx(int x){return __builtin_ffs(x);}\ninline int low_idx(LL x){return __builtin_ffsll(x);}\ninline int high_idx(int x){return low_idx(reverse_bits(x));}\ninline int high_idx(LL x){return low_idx(reverse_bits(x));}\ninline int clz(int x){return __builtin_clz(x);}\ninline int clz(LL x){return __builtin_clzll(x);}\ninline int ctz(int x){return __builtin_ctz(x);}\ninline int ctz(LL x){return __builtin_ctzll(x);}\ninline int parity(int x){return __builtin_parity(x);}\ninline int parity(LL x){return __builtin_parityll(x);}\ninline int lg2(int a){return 31 - clz(a);}\ninline int lg2(LL a){return 63 - clz(a);}\ninline int count_bits(int x){return __builtin_popcount(x);}\ninline int count_bits(LL x){return __builtin_popcountll(x);}\n\n} using namespace BO;//}\n// <<= '2. Number Theory .,//{\nnamespace NT{\ninline LL __lcm(LL a, LL b){return a*b/__gcd(a,b);}\ninline void INC(int &a, int b){a += b; if (a >= MOD) a -= MOD;}\ninline int sum(int a, int b){a += b; if (a >= MOD) a -= MOD; return a;}\ninline void DEC(int &a, int b){a -= b; if (a < 0) a += MOD;}\ninline int dff(int a, int b){a -= b; if (a < 0) a += MOD; return a;}\ninline void MUL(int &a, int b){a = (LL)a * b % MOD;}\ninline int pdt(int a, int b){return (LL)a * b % MOD;}\n\ninline int sum(int a, int b, int c){return sum(sum(a, b), c);}\ninline int sum(int a, int b, int c, int d){return sum(sum(a, b), sum(c, d));}\ninline int pdt(int a, int b, int c){return pdt(pdt(a, b), c);}\ninline int pdt(int a, int b, int c, int d){return pdt(pdt(pdt(a, b), c), d);}\n\ninline int pow(int a, int b){\n int c(1); while (b){\n if (b&1) MUL(c, a);\n MUL(a, a), b >>= 1;\n }\n return c;\n}\n\ninline int pow(int a, LL b){\n int c(1); while (b){\n if (b&1) MUL(c, a);\n MUL(a, a), b >>= 1;\n }\n return c;\n}\n\ntemplate inline T pow(T a, LL b){\n T c(1); while (b){\n if (b&1) c *= a;\n a *= a, b >>= 1;\n }\n return c;\n}\n\ninline int _I(int b){\n int a = MOD, x1 = 0, x2 = 1, q;\n while (true){\n q = a / b, a %= b;\n if (!a) return (x2 + MOD) % MOD;\n DEC(x1, pdt(q, x2));\n\n q = b / a, b %= a;\n if (!b) return (x1 + MOD) % MOD;\n DEC(x2, pdt(q, x1));\n }\n}\n\ninline void DIV(int &a, int b){MUL(a, _I(b));}\ninline int qtt(int a, int b){return pdt(a, _I(b));}\n\ninline int phi(int n){\n int res = n; for (int i=2;sqr(i)<=n;++i) if (!(n%i)){\n DEC(res, qtt(res, i));\n do{n /= i;} while(!(n%i));\n }\n if (n != 1)\n DEC(res, qtt(res, n));\n return res;\n}\n\n} using namespace NT;//}\n\nnamespace SL{\n namespace KMP{\n\n void calc_pi(const char *P, int n, int *pi){\n for (int i = 1, j = pi[0] = -1; i < n; ++i){\n while (j >= 0 && P[i] != P[j+1]) j = pi[j];\n if (P[i] == P[j+1]) ++j;\n pi[i] = j;\n }\n //REP(i, n) cout << pi[i] << \" \"; cout << endl;\n }\n\n bool run(const char *T, int n, const char *P, int m, const int *pi){\n for (int i = 0, j = -1; i < n; ++i){\n while (j >= 0 && T[i] != P[j+1]) j = pi[j];\n if (T[i] == P[j+1]) ++j;\n if (j == m - 1) return true;\n }\n return false;\n }\n\n } //using namespace KMP;\n\n namespace Z{\n void calc_z(const char *P, int n, int *z){\n\n z[0] = n;\n\n for (int i = 1, l = 0, r = 0; i < n; ++i){\n if (i > r){\n for(l = r = i; r < n && P[r] == P[r - l];) ++r;\n z[i] = r - l, --r;\n }\n else {\n if (z[i - l] < r - i + 1) z[i] = z[i - l];\n else {\n for (l = i;r < n && P[r] == P[r - l];) ++r;\n z[i] = r - l, --r;\n }\n }\n }\n\n //REP(i, n) cout << z[i] << \" \"; cout << endl;\n }\n\n int run(const char *T, int n, const char *P, int m, const int *z){\n\n int ex; REP_C_N(ex, min(n, m)) if (T[ex] != P[ex]) break;\n\n int res = ex == m;\n\n for (int i = 1, l = 0, r = 0; i < n; ++i){\n if (i > r){\n for (l = r = i; r < n && T[r] == P[r - l];) ++r;\n ex = r - l, --r;\n }\n else {\n if (z[i - l] < r - i + 1) ex = z[i - l];\n else {\n for (l = i; r < n && T[r] == P[r - l];) ++r;\n ex = r - l, --r;\n }\n }\n if (ex == m) ++res;\n }\n\n return res;\n }\n } //using namespace Z;\n\n void Manacher(char s[], int n, int p[]){\n const int NN = 0;\n static char ss[NN*2+2]; int nn = 2*n+2;\n ss[0] = '$', ss[nn-1] = '#', ss[nn] = 0;\n REP(i, n) ss[i*2+1] ='#', ss[i*2+2] = s[i];\n int mx = 0, id = 0; FOR(i, 1, nn){\n p[i] = mx > i ? min(p[2*id-i], mx - i) : 1;\n while (ss[i+p[i]] == ss[i-p[i]]) ++p[i];\n if (i + p[i] > mx) mx = i + p[i], id = i;\n }\n }\n\n} //using namespace SL;//}\n// <<= '9. Comutational Geometry .,//{\nnamespace CG{\n\nstruct Po; struct Line; struct Seg;\n\nstruct Po{\n DB x, y; Po(DB _x=0, DB _y=0):x(_x), y(_y){}\n friend istream& operator >>(istream& in, Po &p){return in >> p.x >> p.y;}\n friend ostream& operator <<(ostream& out, Po p){return out << \"(\" << p.x << \", \" << p.y << \")\";}\n bool operator ==(const Po& r)const{return !sgn(x-r.x) && !sgn(y-r.y);};\n bool operator !=(const Po& r)const{return sgn(x-r.x) || sgn(y-r.y);}\n Po operator +(const Po& r)const{return Po(x+r.x, y+r.y);}\n Po operator -(const Po& r)const{return Po(x-r.x, y-r.y);}\n Po operator *(DB k)const{return Po(x*k,y*k);}\n Po operator /(DB k)const{return Po(x/k,y/k);}\n DB operator *(const Po&) const;\n DB operator ^(const Po&) const;\n\n bool operator <(const Po &r) const{return sgn(x,r.x)<0||!sgn(x,r.x)&&sgn(y,r.y)<0;}\n Po operator -()const{return Po(-x,-y);}\n Po& operator +=(const Po &r){x+=r.x,y+=r.y;return *this;}\n Po& operator -=(const Po &r){x-=r.x,y-=r.y;return *this;}\n Po& operator *=(DB k){x*=k,y*=k;return*this;}\n Po& operator /=(DB k){x/=k,y/=k;return*this;}\n\n DB length_sqr()const{return sqr(x)+sqr(y);}\n DB length()const{return sqrt(length_sqr());}\n Po unit()const{return *this/length();}\n bool dgt()const{return !sgn(x)&&!sgn(y);}\n DB atan()const{return atan2(y,x);}\n void rotate(DB alpha, const Po& o = Po()){\n x -= o.x, y -= o.y;\n (*this) = Po(x * cos(alpha) - y * sin(alpha), y * cos(alpha) + x * sin(alpha)) + o;\n }\n\n void input(){RF(x,y);}\n};\n\nPo operator *(DB k, Po a){return a * k;}\n\n#define innerProduct dot\n#define scalarProduct dot\n#define outerProduct det\n#define crossProduct det\n\ninline DB dot(const DB &x1, const DB &y1, const DB &x2, const DB &y2){return x1 * x2 + y1 * y2;}\ninline DB dot(const Po &a, const Po &b){return dot(a.x, a.y, b.x, b.y);}\ninline DB dot(const Po &p0, const Po &p1, const Po &p2){return dot(p1 - p0, p2 - p0);}\n\ninline DB det(const DB &x1, const DB &y1, const DB &x2, const DB &y2){return x1 * y2 - x2 * y1;}\ninline DB det(const Po &a, const Po &b){return det(a.x, a.y, b.x, b.y);}\ninline DB det(const Po &p0, const Po &p1, const Po &p2){return det(p1 - p0, p2 - p0);}\n\nDB Po::operator *(const Po &r)const{return dot(*this, r);}\nDB Po::operator ^(const Po &r)const{return det(*this, r);}\n\nstruct Line{\n Po a, b;\n Line(DB x0=0, DB y0=0, DB x1=0, DB y1=0):a(Po(x0, y0)), b(Po(x1, y1)){}\n Line(const Po &a, const Po &b):a(a), b(b){}\n Line(const Line &l):a(l.a), b(l.b){}\n\n friend ostream& operator <<(ostream& out, Line p){return out << p.a << \"-\" << p.b;}\n Line operator +(Po x)const{return Line(a + x, b + x);}\n DB length()const{return (b-a).length();}\n bool dgt()const{return (b-a).dgt();}\n void input(){a.input(), b.input();}\n void getequation(DB, DB, DB) const;\n};\n\nstruct Seg: Line{\n};\n\ninline DB dot(const Line &l1, const Line &l2){return dot(l1.b - l1.a, l2.b - l2.a);}\ninline DB det(const Line &l1, const Line &l2){return det(l1.b - l1.a, l2.b - l2.a);}\n\nvoid Line::getequation(DB A, DB B, DB C) const{\n A = a.y - b.y, B = b.x - a.x, C = det(a, b);\n}\n\ntemplate inline DB dist(const T1 &x, const T2 &y){return sqrt(dist_sqr(x, y));}\ntemplate inline DB dist(const T1 &x, const T2 &y, const T3 &z){return sqrt(dist_sqr(x, y, z));}\n\ntemplate inline int dett(const T1 &x, const T2 &y){return sgn(det(x, y));}\ntemplate inline int dott(const T1 &x, const T2 &y){return sgn(dot(x, y));}\ntemplate inline int dett(const T1 &x, const T2 &y, const T3 &z){return sgn(det(x, y, z));}\ntemplate inline int dott(const T1 &x, const T2 &y, const T3 &z){return sgn(dot(x, y, z));}\ntemplate inline int dett(const T1 &x, const T2 &y, const T3 &z, const T4 &w){return sgn(det(x, y, z, w));}\ntemplate inline int dott(const T1 &x, const T2 &y, const T3 &z, const T4 &w){return sgn(dot(x, y, z, w));}\n\ninline DB dist_sqr(const DB &x, const DB &y){return sqr(x) + sqr(y);}\ninline DB dist_sqr(const DB &x, const DB &y, const DB &z){return sqr(x) + sqr(y) + sqr(z);}\ninline DB dist_sqr(const Po &a, const Po &b){return sqr(a.x - b.x) + sqr(a.y - b.y);}\ninline DB dist_sqr(const Po &p, const Line &l){Po v0 = l.b - l.a, v1 = p - l.a; return sqr(fabs(det(v0, v1))) / v0.length_sqr();}\ninline DB dist_sqr(const Po &p, const Seg &l){\n Po v0 = l.b - l.a, v1 = p - l.a, v2 = p - l.b;\n if (sgn(dot(v0, v1)) * sgn(dot(v0, v2)) <= 0) return dist_sqr(p, Line(l));\n else return min(v1.length_sqr(), v2.length_sqr());\n}\ninline DB dist_sqr(Line l, Po p){return dist_sqr(p, l);}\ninline DB dist_sqr(Seg l, Po p){return dist_sqr(p, l);}\ninline DB dist_sqr(Line l1, Line l2){\n if (sgn(det(l1, l2)) != 0) return 0;\n return dist_sqr(l1.a, l2);\n}\ninline DB dist_sqr(Line l1, Seg l2){\n Po v0 = l1.b - l1.a, v1 = l2.a - l1.a, v2 = l2.b - l1.a; DB c1 = det(v0, v1), c2 = det(v0, v2);\n return sgn(c1) != sgn(c2) ? 0 : sqr(min(fabs(c1), fabs(c2))) / v0.length_sqr();\n}\n\nbool isIntersect(Seg l1, Seg l2){\n\n if (l1.a == l2.a || l1.a == l2.b || l1.b == l2.a || l1.b == l2.b) return true;\n\n return\n min(l1.a.x, l1.b.x) <= max(l2.a.x, l2.b.x) &&\n min(l2.a.x, l2.b.x) <= max(l1.a.x, l1.b.x) &&\n min(l1.a.y, l1.b.y) <= max(l2.a.y, l2.b.y) &&\n min(l2.a.y, l2.b.y) <= max(l1.a.y, l1.b.y) &&\n sgn( det(l1.a, l2.a, l2.b) ) * sgn( det(l1.b, l2.a, l2.b) ) <= 0 &&\n sgn( det(l2.a, l1.a, l1.b) ) * sgn( det(l2.b, l1.a, l1.b) ) <= 0;\n\n}\n\ninline DB dist_sqr(Seg l1, Seg l2){\n if (isIntersect(l1, l2)) return 0;\n else return min(dist_sqr(l1.a, l2), dist_sqr(l1.b, l2), dist_sqr(l2.a, l1), dist_sqr(l2.b, l1));\n}\n\ninline bool isOnSide(const Po &p, const Seg &l){\n return p == l.a || p == l.b;\n}\n\ninline bool isOnSeg(const Po &p, const Seg &l){\n return sgn(det(p, l.a, l.b)) == 0 &&\n sgn(l.a.x, p.x) * sgn(l.b.x, p.x) <= 0 && sgn(l.a.y, p.y) * sgn(l.b.y, p.y) <= 0;\n}\n\ninline bool isOnSegg(const Po &p, const Seg &l){\n return sgn(det(p, l.a, l.b)) == 0 &&\n sgn(l.a.x, p.x) * sgn(l.b.x, p.x) < 0 && sgn(l.a.y, p.y) * sgn(l.b.y, p.y) < 0;\n}\n\ninline Po intersect(const Line &l1, const Line &l2){\n return l1.a + (l1.b - l1.a) * (det(l2.a, l1.a, l2.b) / det(l2, l1));\n}\n\n// perpendicular foot\ninline Po intersect(const Po & p, const Line &l){\n return intersect(Line(p, p + Po(l.a.y - l.b.y, l.b.x - l.a.x)), l);\n}\n\ninline Po rotate(Po p, DB alpha, const Po &o = Po()){\n p.rotate(alpha, o);\n return p;\n}\n\n} using namespace CG;//}\n//}\n\n/** I/O Accelerator Interface .. **/ //{\ntemplate inline T& RD(T &x){\n //cin >> x;\n scanf(\"%d\", &x);\n //char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';\n //char c; c = getchar(); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';\n return x;\n}\n\ninline DB& RF(DB &x){\n scanf(\"%lf\", &x);\n /*char t; while ((t=getchar())==' '||t=='\\n'); x = t - '0';\n while ((t=getchar())!=' '&&t!='\\n'&&t!='.')x*=10,x+=t-'0';\n if (t=='.'){DB l=1; while ((t=getchar())!=' '&&t!='\\n')l*=0.1,x += (t-'0')*l;}*/\n return x;\n}\n\ninline char* RS(char *s){\n //gets(s);\n scanf(\"%s\", s);\n return s;\n}\n\nint Case; template inline void OT(const T &x){\n //printf(\"Case %d: %d\\n\", ++Case, x);\n //printf(\"%.2lf\\n\", x);\n printf(\"%d\\n\", x);\n //cout << x << endl;\n}\n//}\n\n//}/* .................................................................................................................................. */\n\n#define fi first\n#define se second\n#define pb push_back\n#define mp make_pair\n\ntypedef pair PIF;\n\nstruct line{\n Po x, y;\n\n line(){}\n line(Po _x,Po _y):x(_x),y(_y){}\n\n void input(){x.input(), y.input();}\n};\n\n\nstruct node{\n string c;vector a;double sz;\n node(string _c,double _sz=0):c(_c),sz(_sz){}\n void add(int x){a.pb(x);}\n};\n\n\n Po med(Po a,Po b,Po c)\n {\n if(a p)\n {\n double S=0;\n for(int i=0;i<(int)p.size();i++)\n {\n int j=(i+1)%(int)p.size();\n S+=p[i].x*p[j].y-p[j].x*p[i].y;\n }\n return -S/2;\n }\n double crs(Po a,Po b,Po c)\n {\n return (b.y-a.y)*(c.x-a.x)-(b.x-a.x)*(c.y-a.y);\n }\n int inpoly(Po p,vector a)\n {\n int n=(int)a.size();a.pb(a[0]);\n for(int i=0;ip.y&&crs(a[i],a[i+1],p)<0)++w;else\n if(a[i].y>p.y&&a[i+1].y<=p.y&&crs(a[i],a[i+1],p)>0)--w;\n return w;\n }\n int w,h,n,m,p;\n\n\n\n vector po;\n vector > pa;\n vector gr;\n vector bl;\n vector fl;\n vector > pl;\n\n void bfs(int x,string c)\n {\n string d=gr[x].c;\n queue q;vector v((int)gr.size(),0);\n v[x]=1,q.push(x);\n while(!q.empty())\n {\n int x=q.front();q.pop();\n gr[x].c=c;\n for(int i=0;i<(int)gr[x].a.size();i++)\n if(!v[gr[x].a[i]]&&gr[gr[x].a[i]].c==d)\n q.push(gr[x].a[i]),v[gr[x].a[i]]=1;\n }\n }\n int main()\n {\n\n #ifndef ONLINE_JUDGE\n freopen(\"in.txt\", \"r\", stdin);\n //freopen(\"out.txt\", \"w\", stdout);\n #endif\n\n RD(w, h, n);\n\n vector l0(n);\n\n REP(i, n) l0[i].input();\n\n //for(int i=0;i vp;\n for(int j=0;j q;\n q.push(i);\n gr.pb(node(\"black\",0.0));\n bl[i]=++p,fl.pb(po[i]);\n while(!q.empty())\n {\n int x=q.front();q.pop();\n for(int j=0;j<(int)pa[x].size();j++)\n if(bl[pa[x][j].fi]==-1)\n q.push(pa[x][j].fi),\n bl[pa[x][j].fi]=p;\n }\n }\n pl.resize(p+1);\n vector > chk(m);\n for(int i=0;i vp;\n int i0=i,j0=j;\n while(!chk[i0][j0])\n {\n vp.pb(po[i0]);\n chk[i0][j0]=1;\n int i1=pa[i0][j0].fi,j1=-1;\n for(int j=0;j<(int)pa[i1].size();j++)\n if(pa[i1][j].fi==i0){j1=(j+1)%(int)pa[i1].size();break;}\n i0=i1,j0=j1;\n }\n double sz=getsz(vp);\n if(sz>0)\n {\n pl.pb(vp);\n gr.pb(node(\"white\",sz));\n int r=bl[i];\n gr[r].add((int)gr.size()-1),\n gr[(int)gr.size()-1].add(r);\n gr[r].sz-=sz;\n }\n }\n for(int i=1;i<=p;i++)\n {\n int fa=0;\n for(int j=(int)pl.size()-1;j>p;j--)\n if(inpoly(fl[i],pl[j])){fa=j;break;}\n gr[fa].add(i),gr[i].add(fa),gr[fa].sz+=gr[i].sz,gr[i].sz=0;\n }\n\n\n\n int _;scanf(\"%d\",&_);\n while(_--){\n\n Po x; x.input();string c;char s[100];scanf(\"%s\",s),c=s;\n\n for(int i=0;ip;i--)\n if(inpoly(x,pl[i])){bfs(i,c);goto end;}\n bfs(0,c);\n end:;\n }\n\n\n map S;\n for(int i=0;i<(int)gr.size();i++)\n S[gr[i].c]+=gr[i].sz;\n //for(map::iterator i=S.begin();i!=S.end();i++)\n\n ECH(it, S){\n printf(\"%s %.9lf\\n\", it->first.c_str(), it->second);\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "af55c6d4271fa219036c39e1df56c90f", "src_uid": "92caafd07e9afb03745aa6f5b450c38f", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst double oox=13214597.12345,ooy=1412334.323223;\nbool vis[2][111][111],is[111][111];\nint col[11111];\ndouble ans[111];\nbool you[111];\nconst double eps=1e-9;\nint n,m;\ndouble w,h;\nint vs[21111],times;\nstruct point\n{\n\tdouble x,y,ru,theta;\n\tint flag,id,ip;\n\tbool operator <(const point &temp)const\n\t{\n\t\tif(fabs(x-temp.x)vec[31111];\nint cnt_list;\nint num[111];\nbool can[2][111][111];\nvectorac[32222];\nstruct segment\n{\n\tpoint l,r;\n};\nsegment sg[111];\nstruct region\n{\n\tpoint conv[111];\n\tint num,id;\n\tdouble area;\n\tbool operator <(const region &temp)const\n\t{\n\t\treturn area>1;\n\t\tif(list[mid]&vec,double theta)\n{\n\tint left=0,right=vec.size(),mid;\n\tright--;\n\twhile(left<=right)\n\t{\n\t\tmid=(left+right)>>1;\n\t\tif(vec[mid].theta>1;\n\t\tif(adj[mid].ru100)\n\t return false;\n\tif(vis[flag][id][ip])\n\t{\n\t return flag==bflag&&id==bid&&ip==bip;\n\t}\n\tif(flag==0)\n\t{\n\t\tif(ip+1>=num[id])\n\t\t return false;\n nip=ip+1;\n\t}\n\telse\n\t{\n\t\tif(ip==0)\n\t\t return false;\n nip=ip-1;\n\t}\n\tie=binary(0,cnt_list-1,adj[id][nip]);\n\tif(flag==0)\n\t theta=atan2(sg[id].l.y-sg[id].r.y,sg[id].l.x-sg[id].r.x);\n else\n theta=atan2(sg[id].r.y-sg[id].l.y,sg[id].r.x-sg[id].l.x);\n if(vec[ie].size()<=1)\n return false;\n\tvis[flag][id][ip]=true;\n \trs[num_reg].conv[rs[num_reg].num++]=adj[id][ip];\n \trs[num_reg].conv[rs[num_reg].num-1].flag=flag;\n // \tprintf(\"x=%.20f,y=%.20f,nx=%.20f,ny=%.20f\\n\",adj[id][ip].x,adj[id][ip].y,adj[id][nip].x,adj[id][nip].y);\n iq=(bn(vec[ie],theta)-1+(int)vec[ie].size())%vec[ie].size();\n for(int niq=iq+vec[ie].size();niq>iq+1;niq--)\n {\n nid=vec[ie][niq%vec[ie].size()].id;\n if(sg[nid].l.x!=sg[nid].r.x)\n ru=(adj[id][nip].x-sg[nid].l.x)/(sg[nid].r.x-sg[nid].l.x);\n else\n ru=(adj[id][nip].y-sg[nid].l.y)/(sg[nid].r.y-sg[nid].l.y);\n ik=bs(0,num[nid]-1,adj[nid],ru);\n theta=atan2(sg[nid].r.y-sg[nid].l.y,sg[nid].r.x-sg[nid].l.x);\n if(fabs(vec[ie][niq%vec[ie].size()].theta-theta)eps&&ru1<1-eps)\n {\n \t \tB=(y1-y3)*(x2-x1)-(x1-x3)*(y2-y1);\n \tru2=B/A;\n \tif(ru2>eps&&ru2<1-eps)\n res^=1;\n }\n\t}\n\treturn res;\n}\nvoid prepare()\n{\n\tint i,j,s,p,q,nn,id;\n\tmemset(num,0,sizeof(num));\n\tcnt_list=0;\n\tmemset(is,false,sizeof(is));\n\tfor(i=0;i=min(x1,x2)&&y3<=max(y1,y2)&&y3>=min(y1,y2))\n\t \t\t\t \tok=true;\n\t\t\t\t if(x4<=max(x1,x2)&&x4>=min(x1,x2)&&y4<=max(y1,y2)&&y4>=min(y1,y2))\n\t \t\t\t ok=true;\n\t\t\t\t if(x1<=max(x3,x4)&&x1>=min(x3,x4)&&y1<=max(y3,y4)&&y1>=min(y3,y4))\n \t\t\t ok=true;\n\t if(x2<=max(x3,x4)&&x2>=min(x3,x4)&&y2<=max(y3,y4)&&y2>=min(y3,y4))\n\t ok=true;\n\t\t\t if(ok)\n\t\t\t {\n \t if(x1!=x2)\n \t {\n \t if(lu>(x3-x1)/(x2-x1))\n\t\t\t\t\t\t\t lu=(x3-x1)/(x2-x1);\n\t\t\t\t\t\t\t if(lu>(x4-x1)/(x2-x1))\n\t\t\t\t\t\t\t lu=(x4-x1)/(x2-x1);\n\t\t\t\t\t\t\t if(ru<(x3-x1)/(x2-x1))\n\t\t\t\t\t\t\t ru=(x3-x1)/(x2-x1);\n\t\t\t if(ru<(x4-x1)/(x2-x1))\n\t\t\t ru=(x4-x1)/(x2-x1);\n \t }\n \t else\n \t {\n \t \t if(lu>(y3-y1)/(y2-y1))\n\t\t\t\t\t\t\t lu=(y3-y1)/(y2-y1);\n\t\t\t\t\t\t\t if(lu>(y4-y1)/(y2-y1))\n\t\t\t\t\t\t\t lu=(y4-y1)/(y2-y1);\n\t\t\t\t\t\t\t if(ru<(y3-y1)/(y2-y1))\n\t\t\t\t\t\t\t ru=(y3-y1)/(y2-y1);\n\t\t\t if(ru<(y4-y1)/(y2-y1))\n\t\t\t ru=(y4-y1)/(y2-y1); \n \t }\n \t sg[j]=sg[n-1];\n \t j--;\n \t n--;\n \t\t\t}\n\t\t\t\t}\n\t\t }\n\t\t }\n\t\t sg[i].l.x=x1+lu*(x2-x1);\n\t\t sg[i].l.y=y1+lu*(y2-y1);\n\t\t sg[i].r.x=x1+ru*(x2-x1);\n\t\t sg[i].r.y=y1+ru*(y2-y1);\n\t}\n\tfor(i=0;i-eps&&ru1<1+eps)\n {\n \tB=(y1-y3)*(x2-x1)-(x1-x3)*(y2-y1);\n \tru2=B/A;\n \tif(ru2>-eps&&ru2<1+eps)\n \t{\n \t\t is[i][j]=true;\n \t\t adj[i][num[i]].id=i;\n\t adj[i][num[i]].x=x1+ru1*(x2-x1);\n\t\t\t\t adj[i][num[i]].y=y1+ru1*(y2-y1);\n\t\t\t\t adj[i][num[i]++].ru=ru1;\n\t\t\t\t list[cnt_list++]=adj[i][num[i]-1];\n\t }\n }\n\t\t}\n\t\tsort(adj[i],adj[i]+num[i],cmp);\n\t nn=0;\n\t\tfor(j=0;j=num[i]||!can[1-s][i][nj]))\n\t\t\t\t{\n\t\t\t\t\tfor(p=0;p=0&&nj=rs[j].num)\n\t \t rs[i].area-=rs[j].area;\n\t }\n }\n}\nvoid floodfill(int id,int pre_col,int new_col)\n{\n\tint i,j,s,p,q,ip;\n\tvs[id]=times;\n\tcol[id]=new_col;\n\tfor(i=0;i=min(x1,x2)-eps&&y<=max(y1,y2)+eps&&y>=min(y1,y2)-eps)\n\t \t\t{ \n\t \t\t\tip=j+num_reg;\n\t\t\t\t\tbreak;\n\t \t\t}\n\t\t\t}\n \t}\n \tif(j>=n)\n \t{\n\t \tfor(j=0;j\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define REP(i, n) for (int i=0;i=int(a);--i)\n#define REP_1(i, n) for (int i=1;i<=int(n);++i)\n#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)\n#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)\n#define REP_C(i, n) for (int n____=int(n),i=0;i=a____;--i)\n#define REP_N(i, n) for (i=0;i=int(a);--i)\n#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)\n#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)\n#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)\n#define REP_1_N(i, n) for (i=1;i<=int(n);++i)\n#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)\n#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)\n#define REP_C_N(i, n) for (int n____=(i=0,int(n));i=a____;--i)\n#define REP_1_C_N(i, n) for (int n____=(i=1,int(n));i<=n____;++i)\n#define FOR_1_C_N(i, a, b) for (int b____=(i=1,int(b);i<=b____;++i)\n#define DWN_1_C_N(i, b, a) for (int a____=(i=b,int(a));i>=a____;--i)\n\n#define ECH(it, A) for (__typeof(A.begin()) it=A.begin(); it != A.end(); ++it)\n#define REP_S(i, str) for (char*i=str;*i;++i)\n#define REP_L(i, hd, nxt) for (int i=hd;i;i=nxt[i])\n#define REP_G(i, u) REP_L(i,hd[u],suc)\n#define DO(n) for ( int ____n ## __line__ = n; ____n ## __line__ -- ; )\n#define REP_2(i, j, n, m) REP(i, n) REP(j, m)\n#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)\n#define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l)\n#define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l)\n\n#define ALL(A) A.begin(), A.end()\n#define LLA(A) A.rbegin(), A.rend()\n#define CPY(A, B) memcpy(A, B, sizeof(A))\n#define INS(A, P, B) A.insert(A.begin() + P, B)\n#define ERS(A, P) A.erase(A.begin() + P)\n#define BSC(A, x) (lower_bound(ALL(A), x) - A.begin())\n#define CTN(T, x) (T.find(x) != T.end())\n#define SZ(A) int(A.size())\n#define PB push_back\n#define MP(A, B) make_pair(A, B)\n#define PTT pair\n#define fi first\n#define se second\n\n#define Rush for(int ____T=RD(); ____T--;)\n\n#define Display(A, n, m) { \\\n\tREP(i, n){\t\t \\\n REP(j, m) cout << A[i][j] << \" \"; \\\n cout << endl;\t\t\t\t \\\n\t}\t\t\t\t\t\t \\\n}\n\n#define Display_1(A, n, m) {\t\t\t\t \\\n\tREP_1(i, n){\t\t \\\n REP_1(j, m) cout << A[i][j] << \" \"; \\\n\t\tcout << endl;\t\t \t\t\\\n\t}\t\t\t\t\t\t \\\n}\n\n#pragma comment(linker, \"/STACK:36777216\")\n//#pragma GCC optimize (\"O2\")\n#define Ruby system(\"ruby main.rb\")\n#define Haskell system(\"runghc main.hs\")\n#define Python system(\"python main.py\")\n#define Pascal system(\"fpc main.pas\")\n\ntypedef long long LL;\n//typedef long double DB;\ntypedef double DB;\ntypedef unsigned UINT;\ntypedef unsigned long long ULL;\n\ntypedef vector VI;\ntypedef vector VC;\ntypedef vector VS;\ntypedef vector VL;\ntypedef vector VF;\ntypedef set SI;\ntypedef set SS;\ntypedef map MII;\ntypedef map MSI;\ntypedef pair PII;\ntypedef pair PLL;\ntypedef vector VII;\ntypedef vector VVI;\ntypedef vector VVII;\n\ntemplate inline T& RD(T &);\ntemplate inline void OT(const T &);\ninline LL RD(){LL x; return RD(x);}\ninline DB& RF(DB &);\ninline DB RF(){DB x; return RF(x);}\ninline char* RS(char *s);\ninline char& RC(char &c);\ninline char RC();\ninline char& RC(char &c){scanf(\" %c\", &c); return c;}\ninline char RC(){char c; return RC(c);}\n//inline char& RC(char &c){c = getchar(); return c;}\n//inline char RC(){return getchar();}\n\ntemplate inline T& RDD(T &x){\n char c; for (c = getchar(); c < '-'; c = getchar());\n if (c == '-'){x = '0' - getchar(); for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + '0' - c;}\n else {x = c - '0'; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';}\n return x;\n}\n\ninline LL RDD(){LL x; return RDD(x);}\n\ntemplate inline T0& RD(T0 &x0, T1 &x1){RD(x0), RD(x1); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5); return x0;}\ntemplate inline T0& RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6); return x0;}\ntemplate inline void OT(const T0 &x0, const T1 &x1){OT(x0), OT(x1);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2){OT(x0), OT(x1), OT(x2);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}\ntemplate inline void OT(const T0 &x0, const T1 &x1, const T2 &x2, const T3 &x3, const T4 &x4, const T5 &x5, const T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}\ninline char& RC(char &a, char &b){RC(a), RC(b); return a;}\ninline char& RC(char &a, char &b, char &c){RC(a), RC(b), RC(c); return a;}\ninline char& RC(char &a, char &b, char &c, char &d){RC(a), RC(b), RC(c), RC(d); return a;}\ninline char& RC(char &a, char &b, char &c, char &d, char &e){RC(a), RC(b), RC(c), RC(d), RC(e); return a;}\ninline char& RC(char &a, char &b, char &c, char &d, char &e, char &f){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f); return a;}\ninline char& RC(char &a, char &b, char &c, char &d, char &e, char &f, char &g){RC(a), RC(b), RC(c), RC(d), RC(e), RC(f), RC(g); return a;}\ninline DB& RF(DB &a, DB &b){RF(a), RF(b); return a;}\ninline DB& RF(DB &a, DB &b, DB &c){RF(a), RF(b), RF(c); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d){RF(a), RF(b), RF(c), RF(d); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e){RF(a), RF(b), RF(c), RF(d), RF(e); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f); return a;}\ninline DB& RF(DB &a, DB &b, DB &c, DB &d, DB &e, DB &f, DB &g){RF(a), RF(b), RF(c), RF(d), RF(e), RF(f), RF(g); return a;}\ninline void RS(char *s1, char *s2){RS(s1), RS(s2);}\ninline void RS(char *s1, char *s2, char *s3){RS(s1), RS(s2), RS(s3);}\ntemplateinline void RDD(const T0&a, const T1&b){RDD(a),RDD(b);}\ntemplateinline void RDD(const T0&a, const T1&b, const T2&c){RDD(a),RDD(b),RDD(c);}\n\ntemplate inline void RST(T &A){memset(A, 0, sizeof(A));}\ntemplate inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}\ntemplate inline void FLC(T &A, int x){memset(A, x, sizeof(A));}\ntemplate inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6, int x){FLC(A0, x), FLC(A1, x), FLC(A2, x), FLC(A3, x), FLC(A4, x), FLC(A5, x), FLC(A6, x);}\ntemplate inline void CLR(priority_queue, less > &Q){while (!Q.empty()) Q.pop();}\ntemplate inline void CLR(priority_queue, greater > &Q){while (!Q.empty()) Q.pop();}\ntemplate inline void CLR(T &A){A.clear();}\ntemplate inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}\ntemplate inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}\n\ntemplate inline T& SRT(T &A){sort(ALL(A)); return A;}\ntemplate inline T& SRT(T &A, C B){sort(ALL(A), B); return A;}\ntemplate inline T& UNQ(T &A){A.resize(unique(ALL(SRT(A)))-A.begin());return A;}\n\n//}\n\n/** Constant List .. **/ //{\n\nconst int MOD = 1000000007;\n//int MOD = 99990001;\nconst int INF = 0x3f3f3f3f;\nconst LL INFF = 1LL << 60;\nconst DB EPS = 1e-6;\nconst DB OO = 1e20;\nconst DB PI = acos(-1.0); //M_PI;\n\nconst int dx[] = {-1, 0, 1, 0};\nconst int dy[] = {0, 1, 0, -1};\n\n//}\n\n/** Add On .. **/ //{\n// <<= '0. Nichi Joo ., //{\ntemplate inline void checkMin(T &a,const T b){if (b inline void checkMax(T &a,const T b){if (a inline void checkMin(T &a, T &b, const T x){checkMin(a, x), checkMin(b, x);}\ntemplate inline void checkMax(T &a, T &b, const T x){checkMax(a, x), checkMax(b, x);}\ntemplate inline void checkMin(T& a, const T b, C c){if (c(b,a)) a = b;}\ntemplate inline void checkMax(T& a, const T b, C c){if (c(a,b)) a = b;}\ntemplate inline T min(T a, T b, T c){return min(min(a, b), c);}\ntemplate inline T max(T a, T b, T c){return max(max(a, b), c);}\ntemplate inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}\ntemplate inline T max(T a, T b, T c, T d){return max(max(a, b), max(c, d));}\ntemplate inline T sqr(T a){return a*a;}\ntemplate inline T cub(T a){return a*a*a;}\ninline int ceil(int x, int y){return (x - 1) / y + 1;}\ninline int sgn(DB x){return x < -EPS ? -1 : x > EPS;}\ninline int sgn(DB x, DB y){return sgn(x - y);}\n//}\n// <<= '1. Bitwise Operation ., //{\nnamespace BO{\n\ninline bool _1(int x, int i){return bool(x&1<> 1) & 0x55555555) | ((x << 1) & 0xaaaaaaaa);\n x = ((x >> 2) & 0x33333333) | ((x << 2) & 0xcccccccc);\n x = ((x >> 4) & 0x0f0f0f0f) | ((x << 4) & 0xf0f0f0f0);\n x = ((x >> 8) & 0x00ff00ff) | ((x << 8) & 0xff00ff00);\n x = ((x >>16) & 0x0000ffff) | ((x <<16) & 0xffff0000);\n return x;\n}\n\ninline LL reverse_bits(LL x){\n x = ((x >> 1) & 0x5555555555555555LL) | ((x << 1) & 0xaaaaaaaaaaaaaaaaLL);\n x = ((x >> 2) & 0x3333333333333333LL) | ((x << 2) & 0xccccccccccccccccLL);\n x = ((x >> 4) & 0x0f0f0f0f0f0f0f0fLL) | ((x << 4) & 0xf0f0f0f0f0f0f0f0LL);\n x = ((x >> 8) & 0x00ff00ff00ff00ffLL) | ((x << 8) & 0xff00ff00ff00ff00LL);\n x = ((x >>16) & 0x0000ffff0000ffffLL) | ((x <<16) & 0xffff0000ffff0000LL);\n x = ((x >>32) & 0x00000000ffffffffLL) | ((x <<32) & 0xffffffff00000000LL);\n return x;\n}\n\ntemplate inline bool odd(T x){return x&1;}\ntemplate inline bool even(T x){return !odd(x);}\ntemplate inline T low_bit(T x) {return x & -x;}\ntemplate inline T high_bit(T x) {T p = low_bit(x);while (p != x) x -= p, p = low_bit(x);return p;}\ntemplate inline T cover_bit(T x){T p = 1; while (p < x) p <<= 1;return p;}\n\ninline int low_idx(int x){return __builtin_ffs(x);}\ninline int low_idx(LL x){return __builtin_ffsll(x);}\ninline int high_idx(int x){return low_idx(reverse_bits(x));}\ninline int high_idx(LL x){return low_idx(reverse_bits(x));}\ninline int clz(int x){return __builtin_clz(x);}\ninline int clz(LL x){return __builtin_clzll(x);}\ninline int ctz(int x){return __builtin_ctz(x);}\ninline int ctz(LL x){return __builtin_ctzll(x);}\ninline int parity(int x){return __builtin_parity(x);}\ninline int parity(LL x){return __builtin_parityll(x);}\ninline int lg2(int a){return 31 - clz(a);}\ninline int lg2(LL a){return 63 - clz(a);}\ninline int count_bits(int x){return __builtin_popcount(x);}\ninline int count_bits(LL x){return __builtin_popcountll(x);}\n\n} using namespace BO;//}\n// <<= '2. Number Theory .,//{\nnamespace NT{\ninline LL __lcm(LL a, LL b){return a*b/__gcd(a,b);}\ninline void INC(int &a, int b){a += b; if (a >= MOD) a -= MOD;}\ninline int sum(int a, int b){a += b; if (a >= MOD) a -= MOD; return a;}\ninline void DEC(int &a, int b){a -= b; if (a < 0) a += MOD;}\ninline int dff(int a, int b){a -= b; if (a < 0) a += MOD; return a;}\ninline void MUL(int &a, int b){a = (LL)a * b % MOD;}\ninline int pdt(int a, int b){return (LL)a * b % MOD;}\n\ninline int sum(int a, int b, int c){return sum(sum(a, b), c);}\ninline int sum(int a, int b, int c, int d){return sum(sum(a, b), sum(c, d));}\ninline int pdt(int a, int b, int c){return pdt(pdt(a, b), c);}\ninline int pdt(int a, int b, int c, int d){return pdt(pdt(pdt(a, b), c), d);}\n\ninline int pow(int a, int b){\n int c(1); while (b){\n if (b&1) MUL(c, a);\n MUL(a, a), b >>= 1;\n }\n return c;\n}\n\ninline int pow(int a, LL b){\n int c(1); while (b){\n if (b&1) MUL(c, a);\n MUL(a, a), b >>= 1;\n }\n return c;\n}\n\ntemplate inline T pow(T a, LL b){\n T c(1); while (b){\n if (b&1) c *= a;\n a *= a, b >>= 1;\n }\n return c;\n}\n\ninline int _I(int b){\n int a = MOD, x1 = 0, x2 = 1, q;\n while (true){\n q = a / b, a %= b;\n if (!a) return (x2 + MOD) % MOD;\n DEC(x1, pdt(q, x2));\n\n q = b / a, b %= a;\n if (!b) return (x1 + MOD) % MOD;\n DEC(x2, pdt(q, x1));\n }\n}\n\ninline void DIV(int &a, int b){MUL(a, _I(b));}\ninline int qtt(int a, int b){return pdt(a, _I(b));}\n\ninline int phi(int n){\n int res = n; for (int i=2;sqr(i)<=n;++i) if (!(n%i)){\n DEC(res, qtt(res, i));\n do{n /= i;} while(!(n%i));\n }\n if (n != 1)\n DEC(res, qtt(res, n));\n return res;\n}\n\n} using namespace NT;//}\n\n namespace KMP{\n\n void calc_pi(const char *P, int n, int *pi){\n for (int i = 1, j = pi[0] = -1; i < n; ++i){\n while (j >= 0 && P[i] != P[j+1]) j = pi[j];\n if (P[i] == P[j+1]) ++j;\n pi[i] = j;\n }\n //REP(i, n) cout << pi[i] << \" \"; cout << endl;\n }\n\n bool run(const char *T, int n, const char *P, int m, const int *pi){\n for (int i = 0, j = -1; i < n; ++i){\n while (j >= 0 && T[i] != P[j+1]) j = pi[j];\n if (T[i] == P[j+1]) ++j;\n if (j == m - 1) return true;\n }\n return false;\n }\n\n } //using namespace KMP;\n\n namespace Z{\n void calc_z(const char *P, int n, int *z){\n\n z[0] = n;\n\n for (int i = 1, l = 0, r = 0; i < n; ++i){\n if (i > r){\n for(l = r = i; r < n && P[r] == P[r - l];) ++r;\n z[i] = r - l, --r;\n }\n else {\n if (z[i - l] < r - i + 1) z[i] = z[i - l];\n else {\n for (l = i;r < n && P[r] == P[r - l];) ++r;\n z[i] = r - l, --r;\n }\n }\n }\n\n //REP(i, n) cout << z[i] << \" \"; cout << endl;\n }\n\n int run(const char *T, int n, const char *P, int m, const int *z){\n\n int ex; REP_C_N(ex, min(n, m)) if (T[ex] != P[ex]) break;\n\n int res = ex == m;\n\n for (int i = 1, l = 0, r = 0; i < n; ++i){\n if (i > r){\n for (l = r = i; r < n && T[r] == P[r - l];) ++r;\n ex = r - l, --r;\n }\n else {\n if (z[i - l] < r - i + 1) ex = z[i - l];\n else {\n for (l = i; r < n && T[r] == P[r - l];) ++r;\n ex = r - l, --r;\n }\n }\n if (ex == m) ++res;\n }\n\n return res;\n }\n } //using namespace Z;\n\n void Manacher(char s[], int n, int p[]){\n const int NN = 0;\n static char ss[NN*2+2]; int nn = 2*n+2;\n ss[0] = '$', ss[nn-1] = '#', ss[nn] = 0;\n REP(i, n) ss[i*2+1] ='#', ss[i*2+2] = s[i];\n int mx = 0, id = 0; FOR(i, 1, nn){\n p[i] = mx > i ? min(p[2*id-i], mx - i) : 1;\n while (ss[i+p[i]] == ss[i-p[i]]) ++p[i];\n if (i + p[i] > mx) mx = i + p[i], id = i;\n }\n }\n\n} //using namespace SL;//}\n// <<= '9. Comutational Geometry .,//{\nnamespace CG{\n\nstruct Po; struct Line; struct Seg;\n\nstruct Po{\n DB x, y; Po(DB _x=0, DB _y=0):x(_x), y(_y){}\n friend istream& operator >>(istream& in, Po &p){return in >> p.x >> p.y;}\n friend ostream& operator <<(ostream& out, Po p){return out << \"(\" << p.x << \", \" << p.y << \")\";}\n bool operator ==(const Po& r)const{return !sgn(x-r.x) && !sgn(y-r.y);};\n bool operator !=(const Po& r)const{return sgn(x-r.x) || sgn(y-r.y);}\n Po operator +(const Po& r)const{return Po(x+r.x, y+r.y);}\n Po operator -(const Po& r)const{return Po(x-r.x, y-r.y);}\n Po operator *(DB k)const{return Po(x*k,y*k);}\n Po operator /(DB k)const{return Po(x/k,y/k);}\n DB operator *(const Po&) const;\n DB operator ^(const Po&) const;\n\n bool operator <(const Po &r) const{return sgn(x,r.x)<0||!sgn(x,r.x)&&sgn(y,r.y)<0;}\n Po operator -()const{return Po(-x,-y);}\n Po& operator +=(const Po &r){x+=r.x,y+=r.y;return *this;}\n Po& operator -=(const Po &r){x-=r.x,y-=r.y;return *this;}\n Po& operator *=(DB k){x*=k,y*=k;return*this;}\n Po& operator /=(DB k){x/=k,y/=k;return*this;}\n\n DB length_sqr()const{return sqr(x)+sqr(y);}\n DB length()const{return sqrt(length_sqr());}\n Po unit()const{return *this/length();}\n bool dgt()const{return !sgn(x)&&!sgn(y);}\n DB atan()const{return atan2(y,x);}\n void rotate(DB alpha, const Po& o = Po()){\n x -= o.x, y -= o.y;\n (*this) = Po(x * cos(alpha) - y * sin(alpha), y * cos(alpha) + x * sin(alpha)) + o;\n }\n\n void input(){RF(x,y);}\n};\n\nPo operator *(DB k, Po a){return a * k;}\n\n#define innerProduct dot\n#define scalarProduct dot\n#define outerProduct det\n#define crossProduct det\n\ninline DB dot(const DB &x1, const DB &y1, const DB &x2, const DB &y2){return x1 * x2 + y1 * y2;}\ninline DB dot(const Po &a, const Po &b){return dot(a.x, a.y, b.x, b.y);}\ninline DB dot(const Po &p0, const Po &p1, const Po &p2){return dot(p1 - p0, p2 - p0);}\n\ninline DB det(const DB &x1, const DB &y1, const DB &x2, const DB &y2){return x1 * y2 - x2 * y1;}\ninline DB det(const Po &a, const Po &b){return det(a.x, a.y, b.x, b.y);}\ninline DB det(const Po &p0, const Po &p1, const Po &p2){return det(p1 - p0, p2 - p0);}\n\nDB Po::operator *(const Po &r)const{return dot(*this, r);}\nDB Po::operator ^(const Po &r)const{return det(*this, r);}\n\nstruct Line{\n Po a, b;\n Line(DB x0=0, DB y0=0, DB x1=0, DB y1=0):a(Po(x0, y0)), b(Po(x1, y1)){}\n Line(const Po &a, const Po &b):a(a), b(b){}\n Line(const Line &l):a(l.a), b(l.b){}\n\n friend ostream& operator <<(ostream& out, Line p){return out << p.a << \"-\" << p.b;}\n Line operator +(Po x)const{return Line(a + x, b + x);}\n DB length()const{return (b-a).length();}\n bool dgt()const{return (b-a).dgt();}\n void input(){a.input(), b.input();}\n void getequation(DB, DB, DB) const;\n};\n\nstruct Seg: Line{\n};\n\ninline DB dot(const Line &l1, const Line &l2){return dot(l1.b - l1.a, l2.b - l2.a);}\ninline DB det(const Line &l1, const Line &l2){return det(l1.b - l1.a, l2.b - l2.a);}\n\nvoid Line::getequation(DB A, DB B, DB C) const{\n A = a.y - b.y, B = b.x - a.x, C = det(a, b);\n}\n\ntemplate inline DB dist(const T1 &x, const T2 &y){return sqrt(dist_sqr(x, y));}\ntemplate inline DB dist(const T1 &x, const T2 &y, const T3 &z){return sqrt(dist_sqr(x, y, z));}\n\ntemplate inline int dett(const T1 &x, const T2 &y){return sgn(det(x, y));}\ntemplate inline int dott(const T1 &x, const T2 &y){return sgn(dot(x, y));}\ntemplate inline int dett(const T1 &x, const T2 &y, const T3 &z){return sgn(det(x, y, z));}\ntemplate inline int dott(const T1 &x, const T2 &y, const T3 &z){return sgn(dot(x, y, z));}\ntemplate inline int dett(const T1 &x, const T2 &y, const T3 &z, const T4 &w){return sgn(det(x, y, z, w));}\ntemplate inline int dott(const T1 &x, const T2 &y, const T3 &z, const T4 &w){return sgn(dot(x, y, z, w));}\n\ninline DB dist_sqr(const DB &x, const DB &y){return sqr(x) + sqr(y);}\ninline DB dist_sqr(const DB &x, const DB &y, const DB &z){return sqr(x) + sqr(y) + sqr(z);}\ninline DB dist_sqr(const Po &a, const Po &b){return sqr(a.x - b.x) + sqr(a.y - b.y);}\ninline DB dist_sqr(const Po &p, const Line &l){Po v0 = l.b - l.a, v1 = p - l.a; return sqr(fabs(det(v0, v1))) / v0.length_sqr();}\ninline DB dist_sqr(const Po &p, const Seg &l){\n Po v0 = l.b - l.a, v1 = p - l.a, v2 = p - l.b;\n if (sgn(dot(v0, v1)) * sgn(dot(v0, v2)) <= 0) return dist_sqr(p, Line(l));\n else return min(v1.length_sqr(), v2.length_sqr());\n}\ninline DB dist_sqr(Line l, Po p){return dist_sqr(p, l);}\ninline DB dist_sqr(Seg l, Po p){return dist_sqr(p, l);}\ninline DB dist_sqr(Line l1, Line l2){\n if (sgn(det(l1, l2)) != 0) return 0;\n return dist_sqr(l1.a, l2);\n}\ninline DB dist_sqr(Line l1, Seg l2){\n Po v0 = l1.b - l1.a, v1 = l2.a - l1.a, v2 = l2.b - l1.a; DB c1 = det(v0, v1), c2 = det(v0, v2);\n return sgn(c1) != sgn(c2) ? 0 : sqr(min(fabs(c1), fabs(c2))) / v0.length_sqr();\n}\n\nbool isIntersect(Seg l1, Seg l2){\n\n if (l1.a == l2.a || l1.a == l2.b || l1.b == l2.a || l1.b == l2.b) return true;\n\n return\n min(l1.a.x, l1.b.x) <= max(l2.a.x, l2.b.x) &&\n min(l2.a.x, l2.b.x) <= max(l1.a.x, l1.b.x) &&\n min(l1.a.y, l1.b.y) <= max(l2.a.y, l2.b.y) &&\n min(l2.a.y, l2.b.y) <= max(l1.a.y, l1.b.y) &&\n sgn( det(l1.a, l2.a, l2.b) ) * sgn( det(l1.b, l2.a, l2.b) ) <= 0 &&\n sgn( det(l2.a, l1.a, l1.b) ) * sgn( det(l2.b, l1.a, l1.b) ) <= 0;\n\n}\n\ninline DB dist_sqr(Seg l1, Seg l2){\n if (isIntersect(l1, l2)) return 0;\n else return min(dist_sqr(l1.a, l2), dist_sqr(l1.b, l2), dist_sqr(l2.a, l1), dist_sqr(l2.b, l1));\n}\n\ninline bool isOnSide(const Po &p, const Seg &l){\n return p == l.a || p == l.b;\n}\n\ninline bool isOnSeg(const Po &p, const Seg &l){\n return sgn(det(p, l.a, l.b)) == 0 &&\n sgn(l.a.x, p.x) * sgn(l.b.x, p.x) <= 0 && sgn(l.a.y, p.y) * sgn(l.b.y, p.y) <= 0;\n}\n\ninline bool isOnSegg(const Po &p, const Seg &l){\n return sgn(det(p, l.a, l.b)) == 0 &&\n sgn(l.a.x, p.x) * sgn(l.b.x, p.x) < 0 && sgn(l.a.y, p.y) * sgn(l.b.y, p.y) < 0;\n}\n\ninline Po intersect(const Line &l1, const Line &l2){\n return l1.a + (l1.b - l1.a) * (det(l2.a, l1.a, l2.b) / det(l2, l1));\n}\n\n// perpendicular foot\ninline Po intersect(const Po & p, const Line &l){\n return intersect(Line(p, p + Po(l.a.y - l.b.y, l.b.x - l.a.x)), l);\n}\n\ninline Po rotate(Po p, DB alpha, const Po &o = Po()){\n p.rotate(alpha, o);\n return p;\n}\n\n} using namespace CG;//}\n//}\n\n/** I/O Accelerator Interface .. **/ //{\ntemplate inline T& RD(T &x){\n //cin >> x;\n scanf(\"%d\", &x);\n //char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';\n //char c; c = getchar(); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';\n return x;\n}\n\ninline DB& RF(DB &x){\n scanf(\"%lf\", &x);\n /*char t; while ((t=getchar())==' '||t=='\\n'); x = t - '0';\n while ((t=getchar())!=' '&&t!='\\n'&&t!='.')x*=10,x+=t-'0';\n if (t=='.'){DB l=1; while ((t=getchar())!=' '&&t!='\\n')l*=0.1,x += (t-'0')*l;}*/\n return x;\n}\n\ninline char* RS(char *s){\n //gets(s);\n scanf(\"%s\", s);\n return s;\n}\n\nint Case; template inline void OT(const T &x){\n //printf(\"Case %d: %d\\n\", ++Case, x);\n //printf(\"%.2lf\\n\", x);\n printf(\"%d\\n\", x);\n //cout << x << endl;\n}\n//}\n\n//}/* .................................................................................................................................. */\n\n#define pb push_back\n#define mp make_pair\n\ntypedef pair PIF;\n\nstruct line{\n Po x, y;\n\n line(){}\n line(Po _x,Po _y):x(_x),y(_y){}\n\n void input(){x.input(), y.input();}\n};\n\n\nstruct node{\n string c;vector a;double sz;\n node(string _c,double _sz=0):c(_c),sz(_sz){}\n void add(int x){a.pb(x);}\n};\n\n\n Po __median(const Po& a, const Po& b, const Po& c){\n if(a p)\n {\n double S=0;\n for(int i=0;i<(int)p.size();i++)\n {\n int j=(i+1)%(int)p.size();\n S+=p[i].x*p[j].y-p[j].x*p[i].y;\n }\n return -S/2;\n }\n double crs(Po a,Po b,Po c)\n {\n return (b.y-a.y)*(c.x-a.x)-(b.x-a.x)*(c.y-a.y);\n }\n int inpoly(Po p,vector a)\n {\n int n=(int)a.size();a.pb(a[0]);\n for(int i=0;ip.y&&crs(a[i],a[i+1],p)<0)++w;else\n if(a[i].y>p.y&&a[i+1].y<=p.y&&crs(a[i],a[i+1],p)>0)--w;\n return w;\n }\n int w,h,n,m,p;\n\n\n\n vector po;\n vector > pa;\n vector gr;\n vector bl;\n vector fl;\n vector > pl;\n\n void bfs(int x,string c)\n {\n string d=gr[x].c;\n queue q;vector v((int)gr.size(),0);\n v[x]=1,q.push(x);\n while(!q.empty())\n {\n int x=q.front();q.pop();\n gr[x].c=c;\n for(int i=0;i<(int)gr[x].a.size();i++)\n if(!v[gr[x].a[i]]&&gr[gr[x].a[i]].c==d)\n q.push(gr[x].a[i]),v[gr[x].a[i]]=1;\n }\n }\n int main()\n {\n\n #ifndef ONLINE_JUDGE\n freopen(\"in.txt\", \"r\", stdin);\n //freopen(\"out.txt\", \"w\", stdout);\n #endif\n\n RD(w, h, n);\n\n vector l0(n);\n\n REP(i, n) l0[i].input();\n\n //for(int i=0;i vp;\n for(int j=0;j q;\n q.push(i);\n gr.pb(node(\"black\",0.0));\n bl[i]=++p,fl.pb(po[i]);\n while(!q.empty())\n {\n int x=q.front();q.pop();\n for(int j=0;j<(int)pa[x].size();j++)\n if(bl[pa[x][j].fi]==-1)\n q.push(pa[x][j].fi),\n bl[pa[x][j].fi]=p;\n }\n }\n pl.resize(p+1);\n vector > chk(m);\n for(int i=0;i vp;\n int i0=i,j0=j;\n while(!chk[i0][j0])\n {\n vp.pb(po[i0]);\n chk[i0][j0]=1;\n int i1=pa[i0][j0].fi,j1=-1;\n for(int j=0;j<(int)pa[i1].size();j++)\n if(pa[i1][j].fi==i0){j1=(j+1)%(int)pa[i1].size();break;}\n i0=i1,j0=j1;\n }\n double sz=getsz(vp);\n if(sz>0)\n {\n pl.pb(vp);\n gr.pb(node(\"white\",sz));\n int r=bl[i];\n gr[r].add((int)gr.size()-1),\n gr[(int)gr.size()-1].add(r);\n gr[r].sz-=sz;\n }\n }\n for(int i=1;i<=p;i++)\n {\n int fa=0;\n for(int j=(int)pl.size()-1;j>p;j--)\n if(inpoly(fl[i],pl[j])){fa=j;break;}\n gr[fa].add(i),gr[i].add(fa),gr[fa].sz+=gr[i].sz,gr[i].sz=0;\n }\n\n\n\n int _;scanf(\"%d\",&_);\n while(_--){\n\n Po x; x.input();string c;char s[100];scanf(\"%s\",s),c=s;\n\n for(int i=0;ip;i--)\n if(inpoly(x,pl[i])){bfs(i,c);goto end;}\n bfs(0,c);\n end:;\n }\n\n\n map S;\n for(int i=0;i<(int)gr.size();i++)\n S[gr[i].c]+=gr[i].sz;\n //for(map::iterator i=S.begin();i!=S.end();i++)\n\n ECH(it, S){\n printf(\"%s %.9lf\\n\", it->first.c_str(), it->second);\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5cf356d7e1d0b0cada417b6fda445c44", "src_uid": "92caafd07e9afb03745aa6f5b450c38f", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst int N = 60;\nint dp[N][N][2620];\nint cnt[N][N][110];\nint vis[N][N][2600];\nstruct box{\n\tint c,r;\n}b[N];\nchar s[110];\nint n,m,k;\nint main()\n{\t\n\t//freopen(\"std.out\",\"w\",stdout);\n\tint ans = 0x3f3f3f3f;\n\tscanf(\"%d%d%d\",&n,&m,&k);\n\tfor (int i=1; i<=n; ++i)scanf(\"%d\",&b[i].r);\n\tscanf(\"%s\",s+1);\n\tfor (int i=1 ;i<=n; ++i){\n\t\tif (s[i]=='R')b[i].c = 1;\n\t\telse if (s[i]=='G')b[i].c = 2;\n\t\telse b[i].c = 3;\n\t}\n\tmemset(dp,0x3f,sizeof(dp));\n\tfor (int i=1; i<=n; ++i){\n\t\tdp[1][i][b[i].r] = abs(i-m);\n\t\tcnt[1][i][++cnt[1][i][0]]=b[i].r; \n\t\tans = b[i].r>=k?min(ans,dp[1][i][b[i].r]):ans;\n\t}\n\tfor (int i=1; ib[j].r){\n\t\t\t\t\tfor (int p=1;p<=cnt[i][j][0];++p){\n\t\t\t\t\t\tint tmp = cnt[i][j][p];\n\t\t\t\t\t\tdp[i+1][o][tmp+b[o].r] = min(dp[i+1][o][tmp+b[o].r],dp[i][j][tmp]+abs(o-j));\n\t\t\t\t\t\tif (!vis[i+1][o][tmp+b[o].r]\n\t\t\t\t\t\t\tcnt[i+1][o][++cnt[i+1][o][0]] = tmp + b[o].r;\n\t\t\t\t\t\t\tvis[i+1][o][tmp+b[o].r] = 1;\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\tans = (tmp+b[o].r>=k)? min(dp[i+1][o][tmp+b[o].r], ans):ans;\n\t\t\t\t\t\t//if (tmp + b[o].r>=k)printf(\"%d %d %d %d\\n\",i+1,o,j,ans);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n//\tfor (int i = 1; i<=n;++i){\n//\t\tcout<\nusing namespace std;\n#define END '\\n'\n#define int long long\n#define pb push_back\n#define pii pair\n#define loop(i, a, b) for(int i = (a); i < (b); i++)\n#define loopb(i, b, a) for(int i = (b); i > (a); --i) \nstring alpha = \"abcdefghijklmnopqrstuvwxyz\";\nconst int mod = 1e9+7;\nconst int mod1 = 998244353;\nconst int inf = 2e18+5;\nconst int nax = 200010;\nstruct data{\n int pos,candy,colour;\n data(){}\n};\n/*bool mywish(const data &a, const data &b)\n {\n return a.candy < b.candy;\n }*/\n\nbool operator<(data a, data b) { return a.candy < b.candy; }\nvector v; \nvector> dp;\nvoid solve()\n {\n int n,S,k;\n cin>>n>>S>>k;\n --S;\n string s;\n v.resize(n);\n loop(i,0,n)\n {\n cin>>v[i].candy;\n v[i].pos = i; \n }\n cin>>s;\n loop(i,0,n)\n v[i].colour = (s[i] == 'R' ? 0 : (s[i] == 'G' ? 1 : 2));\n sort(v.begin(),v.end());\n dp.assign(n,vector (2501,inf));\n loop(i,0,n)\n dp[i][v[i].candy] = abs(v[i].pos - S);\n int ans = inf;\n loop(i,0,n)\n {\n loop(j,0,2501)\n {\n if(dp[i][j] == inf)\n continue;\n loop(l,i+1,n)\n {\n if(v[l].colour != v[i].colour && v[l].candy > v[i].candy)\n dp[l][v[l].candy + j] = min(dp[l][v[l].candy + j], dp[i][j] + abs(v[i].pos - v[l].pos));\n }\n }\n }\n loop(i,0,n)\n {\n loop(j,k,2501)\n ans = min(ans,dp[i][j]);\n }\n if(ans == inf)\n ans = -1; \n cout<>t;\n while(t--)*/\n solve();\n //cerr<\n#include \n#include \n#include \nusing namespace std;\n\nint n,s,kk;\nint color[100];\nint dp[100][2020];//\u4ece\u5f53\u524d\u70b9i\u5f80\u53f3\u8d70\u5927\u4e8ek\u7684\u6700\u5c0f\u4ee3\u4ef7 \nstruct node{\n\tint id;\n\tint val;\n};\n\nbool cmp(node a,node b){\n\treturn a.val> n >> s >> kk;\n\tint tmp;\n\tfor(int i = 1;i<=n;i++){\n\t\tcin >> tmp;\n\t\taa[i] = (node){i,tmp};\n\t}\n\tfor(int i = 1;i<=n;i++){\n\t\tchar c;cin >> c;\n\t\tif(c == 'R')color[i] = 0;\n\t\telse if(c == 'G')color[i] = 1;\n\t\telse if(c == 'B')color[i] = 2;\n\t}\n\tsort(aa+1,aa+1+n,cmp);\n\tfor(int i = 0;i<100;i++){\n\t\tfor(int j = 0;j<2020;j++){\n\t\t\tdp[i][j] = 0x3f3f3f3f;\n\t\t}\n\t}\n\tfor(int i = n;i>=1;i--){\n\t\t//cout <<\"fuck\"<\n#include \n#include \n\nusing namespace std;\n\nint a[1234];\nstring c;\n\nint dp[55][2060];\n\nint main()\n{\n int n, s, k;\n cin >> n >> s >> k;\n\n for (int i = 1; i <= n; ++i)\n cin >> a[i];\n\n cin >> c;\n c = \" \" + c;\n\n for (int i = 0; i < 55; ++i)\n for (int j = 0; j < 2060; ++j)\n dp[i][j] = 1e9;\n\n int ans = 1e9;\n for (int i = 1; i <= n; ++i)\n {\n dp[i][a[i]] = abs(s-i);\n if (a[i] >= k)\n ans = min(ans, dp[j][i]);\n }\n\n for (int i = 1; i < 2060; ++i)\n {\n for (int j = 1; j <= n; ++j)\n {\n for (int prev = 1; prev <= n; ++prev)\n {\n if (a[prev] >= a[j])\n continue;\n if (c[prev] == c[j])\n continue;\n dp[j][i] = min(dp[j][i], dp[prev][i-a[j]] + abs(j-prev));\n if (i >= k)\n ans = min(ans, dp[j][i]);\n }\n }\n }\n if (ans == 1e9)\n cout << -1;\n else\n cout << ans;\n\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cff666174aebb5978a8294a048c91b95", "src_uid": "a95e54a7e38cc0d61b39e4a01a6f8d3f", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\nconst int MAXN = 4*100*1000;\n\ntypedef pair PII;\n\nint tab[MAXN + 3];\n\nint t;\n\ndouble calc_avg(vector &V){\n double ret = 0;\n for(int i=0; i 2000)\n poisson = true;\n \n avg += tab[i];\n }\n \n avg /= 250.0;\n avg = 0.0;\n \n int rounds = 30;\n for(int i=0; i V;\n for(int j=0; j<150; j++)\n V.push_back(tab[j]);\n \n avg += calc_avg(V);\n }\n \n avg = avg/(double)(rounds);\n printf(\"%d\\n\", (int)(avg+0.5));\n \n// for(int i=0; i\nusing namespace std;\nint a[255];double f[2010];\ndouble solve1(int p)\n{\n double sum=0;\n for(int i=1;i<=250;i++)\n {\n if(a[i]>=0&&a[i]<=p*2)\n sum+=log(1.0/(p*2+1));\n else\n return -1e20;\n }\n return sum;\n}\ndouble solve2(int p)\n{\n double sum=0;\n for(int i=1;i<=250;i++)\n {\n sum+=a[i]*log(p)-p-f[a[i]];\n }\n return sum;\n}\nint main()\n{\n for(int i=1;i<=2000;i++)f[i]=f[i-1]+log(i);\n int t;scanf(\"%d\",&t);\n while(t--)\n {\n for(int i=1;i<=250;i++)\n scanf(\"%d\",&a[i]);\n double m1=-1e20,ans;int pp;\n for(int p=10;p<=1000;p++)\n {\n ans=max(solve2(p),solve1(p));\n if(ans>m1)\n {\n ma=ans;\n pp=p;\n }\n }\n cout<\nusing namespace std;\n\nint A[250];\n\nvoid test()\n{\n\tfor(int i=0;i<250;i++)\n\t\tcin >> A[i];\n\tdouble mu = 0;\n\tfor(int i=0;i<250;i++)\n\t\tmu += A[i];\n\tmu /= 250.0;\n\tcout << round(mu) << '\\n';\n}\n\nint main()\n{\n\tint N;\n\tcin >> N;\n\tfor(int i=0;i\nusing namespace std;\n\nint arr[250];\nint N = 250;\nvoid tmain()\n{\n double m = 0;\n for(int i=0; i\n#include\n\nusing namespace std ; \nint main ()\n{ \n\n string a , b ;\n int mi ;\n int c[20] = {0} ;\n int d[20] = {0} ;\n int j[20] = {0} ;\n int max = 0 ;\n \n cin>>a ;\n cin>>b ;\n for (int i = 0 ; i< b.size () ; i++ )\n {\n if (b[i] == '6' )\n b[i] = '9' ; \n if (b[i] == '2' )\n b[i] = '5' ;\n \n if (a[i] == '6' )\n a[i] = '9' ;\n if (a[i] == '2' )\n a[i] = '5' ;\n\n if (a[i] == '0' )\n +++c[0] ;\n if (b[i] == '0' )\n ++d[0] ;\n \n if (a[i] == '1' )\n +++c[1] ;\n if (b[i] == '1' )\n ++d[1] ;\n \n if (a[i] == '3' )\n +++c[3] ;\n if (b[i] == '3' )\n ++d[3] ;\n \n if (a[i] == '4' )\n +++c[4] ;\n if (b[i] == '4' )\n ++d[4] ;\n \n if (a[i] == '5' )\n +++c[5] ;\n if (b[i] == '5' )\n ++d[5] ;\n \n if (a[i] == '7' )\n +++c[7] ;\n if (b[i] == '7' )\n ++d[7] ;\n \n if (a[i] == '8' )\n +++c[8] ;\n if (b[i] == '8' )\n ++d[8] ;\n \n if (a[i] == '9' )\n +++c[9] ;\n if (b[i] == '9' )\n ++d[9] ;\n\n\n }\n\n\n if (d[0] !=0 && c[0] !=0 ) j[0] = d[0]/c[0] ; \n if (d[1] !=0 && c[1] !=0 ) j[1] = d[1]/c[1] ; \n if (d[3] !=0 && c[3] !=0 ) j[3] = d[3]/c[3] ; \n if (d[4] !=0 && c[4] !=0 ) j[4] = d[4]/c[4] ;\n if (d[5] !=0 && c[5] !=0 ) j[5] = d[5]/c[5] ; \n if (d[7] !=0 && c[7] !=0 ) j[7] = d[7]/c[7] ; \n if (d[8] !=0 && c[8] !=0 ) j[8] = d[8]/c[8] ; \n if (d[9] !=0 && c[9] !=0 ) j[9] = d[9]/c[9] ; \n\n\n if (j[0] < j[1] )\n if(c[0] !=0 )\n max = j[0] ;\n else\n if(c[1] !=0 )\n max = j[1] ;\n\n \n\n\n if (max > j[3] || max == 0 )\n if(c[3] !=0 )\n max = j[3] ;\n if (max > j[4] || max == 0 )\n if(c[4] !=0 )\n {cout<<\"++++++++++++\"< j[5] || max == 0 )\n if(c[5] !=0 ) \n max = j[5] ;\n if (max > j[7] || max == 0)\n if(c[7] !=0 )\n max = j[7] ;\n \n if (max > j[8] || max == 0 )\n if(c[8] !=0 )\n max = j[8] ;\n if (max > j[9] || max == 0 )\n if(c[9] !=0 )\n max = j[9] ;\n cout<\nusing namespace std;\n#define maxn 201\n#define maxd 10\n\nchar s[maxn];\nint a[maxd], ab[maxd];\n\nint main() {\n\tint n, i, ret = INT_MAX;\n\tscanf(\"%d\", s);\n\tn = strlen(s);\n\tfor (i = 0; i < n; i++)\n\t\ta[s[i] - '0']++;\n\ta[2] += a[5];\n\ta[6] += a[9];\n\ta[5] = a[6] = 0;\n\tscanf(\"%s\", s);\n\tn = strlen(s);\n\tfor (i = 0; i < n; i++)\n\t\tb[s[i] - '0']++;\n\tb[2] += b[5];\n\tb[6] += b[9];\n\tb[5] = b[6] = 0;\n\tfor (i = 0; i < maxd; i++)\n\t\tif (a[i]) ret = min(ret, b[i] / a[i]);\n\tprintf(\"%d\", ret);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cdb5608e9fd6abf31d6bec6be99a1b2e", "src_uid": "72a196044787cb8dbd8d350cb60ccc32", "difficulty": 1500.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long int64;\ntypedef unsigned long long uint64;\ntypedef pair pii;\ntypedef pair pdd;\ntypedef vector vi;\ntypedef vector vpii;\ntypedef vector vd;\ntypedef vector vvi;\n\nconstexpr double eps = 1e-11;\nconstexpr double pi = acos(-1.0);\nconstexpr int64 p = 1000000007;\nconstexpr int64 countbit(int64 n) { return n == 0 ? 0: countbit(n / 2) + n % 2; }\nconstexpr int64 lowbit(int64 n) { return (n ^ (n-1) ) & n; }\nconstexpr int64 gcd(int64 a, int64 b) { return b == 0? a : gcd(b, a % b); }\nconstexpr int64 lcm(int64 a, int64 b) { return a * b / gcd(a, b); }\nint64 toInt64(string s) { istringstream sin(s); int64 t; sin >> t; return t; }\nstring toStr(int64 t) { stringstream sin; sin << t; string s; sin >> s; return s; }\ntemplate constexpr auto sqr(const T& n) -> decltype(n * n) { return n * n; }\ntemplate void out(const T& array) {\n for(const T& value : array) cout << value << \"\\n\";\n cout.flush();\n}\n\nstruct Point {\n int64 x;\n int64 y;\n Point(){}\n Point(int x, int64 y): x(x), y(y){}\n bool operator<(const Point& that) const {\n return make_pair(x,y) < make_pair(that.x, that.y);\n }\n};\n\n#define all(a) (a).begin(), (a).end()\n#define pb push_back\n\nvoid solve() {\n int t;\n cin >> t;\n string ss;\n cin >> ss;\n vi mp(10);\n for (auto c:ss)\n ++mp[c-'0'];\n string tt = to_string(t);\n replace(all(tt), '5', '2');\n replace(all(tt), '9', '6');\n mp[6]+=mp[9];\n mp[2]+=mp[5];\n vi ne(10);\n for (auto c:tt)\n ne[c-'0']++;\n ne[6]+=ne[9];\n ne[2]+=ne[5];\n int64 result = p;\n for (auto i = 0; i!=10; ++i) {\n if (i!=5 && i != 9 && ne[i])\n result = min(result, mp[i]/ne[i]);\n }\n cout <\nusing namespace std;\n\nint main ()\n{\n\tint n;\n\tchar b[500];\n\twhile (cin>>n)\n\t{\n\t\tint c;\n\t\tint a[20]={0};\n\t\twhile (n>0)\n\t\t{\n\t\t\tc=n%10;\n\t\t\tn=n/10;\n\t\t\ta[c]=a[c]+1;\n\t\t}\n\t\tcin>>b;\n\t\tint len=strlen(b);\n\t\tint i=0;\n\t\twhile (i\nusing namespace std;\nusing ll=long long;\ninline int read()\n{\n\tint x=0,f=1;char ch=getchar();\n\twhile(!isdigit(ch))\n\t{\n\t\tif(ch=='-')f=-1;\n\t\tch=getchar();\n\t}\n\twhile(isdigit(ch))\n\t{\n\t\tx=(x<<1)+(x<<3)+ch-'0';\n\t\tch=getchar();\n\t}\n\treturn x*f;\n}\nconst int N=2e5+10;\nint n,q;\nstruct BIT{\n\tll t[N];\n\tinline int lowbit(int x)\n\t{\n\t\treturn x&-x;\n\t}\n\tinline void update(int x,int k)\n\t{\n\t\tfor(int i=x;i<=n;i+=lowbit(i))t[i]+=k;\n\t}\n\tinline ll query(int x)\n\t{\n\t\tll ans=0;\n\t\tfor(int i=x;i;i-=lowbit(i))ans+=t[i];\n\t\treturn ans;\n\t}\n}t1,t2;\ninline ll query(int x)\n{\n\treturn t1.query(x)+t2.query(x)*x;\n}\ninline void modify(int x,int d)\n{\n\tt1.update(x,-x*d);\n\tt2.update(x,d);\n}\nstruct Node{\n\tint l,r,w;\n\tfriend bool operator<(const Node&a,const Node&b)\n\t{\n\t\treturn a.lS,a[N];\ninline void erase(Node x)\n{\n\tauto it=a[x.w].find(x);\n\tif(it!=a[x.w].begin())\n\t{\n\t\tit--;\n\t\tmodify(x.l-it->r,1);\n\t\tit++;\n\t}\n\tit++;\n\tif(it!=a[x.w].end())modify(it->l-x.r,1);\n\tit--;\n\tif(it!=a[x.w].begin())\n\t{\n\t\tauto it2=it,it3=it;\n\t\tit2++;\n\t\tit3--;\n\t\tif(it2!=a[x.w].end())modify(it2->l-it3->r,-1);\n\t}\n\tif(x.l!=x.r)modify(1,x.r-x.l);\n\tmodify(a[x.w].begin()->l,1);\n\tmodify(n-a[x.w].rbegin()->r+1,1);\n\ta[x.w].erase(x);\n\tif(!a[x.w].empty())\n\t{\n\t\tmodify(a[x.w].begin()->l,-1);\n\t\tmodify(n-a[x.w].rbegin()->r+1,-1);\n\t}\n}\ninline void insert(Node x)\n{\n\tif(!a[x.w].empty())\n\t{\n\t\tmodify(a[x.w].begin()->l,1);\n\t\tmodify(n-a[x.w].rbegin()->r+1,1);\n\t}\n\ta[x.w].insert(x);\n\tmodify(a[x.w].begin()->l,-1);\n\tmodify(n-a[x.w].rbegin()->r+1,-1);\n\tauto it=a[x.w].find(x);\n\tif(it!=a[x.w].begin())\n\t{\n\t\tit--;\n\t\tmodify(x.l-it->r,-1);\n\t\tit++;\n\t}\n\tit++;\n\tif(it!=a[x.w].end())modify(it->l-x.r,-1);\n\tit--;\n\tif(it!=a[x.w].begin())\n\t{\n\t\tauto it2=it,it3=it;\n\t\tit2++;\n\t\tit3--;\n\t\tif(it2!=a[x.w].end())modify(it2->l-it3->r,1);\n\t}\n\tif(x.l!=x.r)modify(1,x.l-x.r);\n}\ninline set::iterator split(int p)\n{\n\tauto x=S.upper_bound((Node){p,-1,-1});\n\tx--;\n\tif(x->l==p)return x;\n\telse if(p>x->r)return S.end();\n\telse\n\t{\n\t\tNode t=(*x);\n\t\terase(t);\n\t\tS.erase(x);\n\t\tS.insert((Node){t.l,p-1,t.w});\n\t\tS.insert((Node){p,t.r,t.w});\n\t\tinsert((Node){t.l,p-1,t.w});\n\t\tinsert((Node){p,t.r,t.w});\n\t\treturn S.find((Node){p,t.r,t.w});\n\t}\n}\ninline void assign(int l,int r,int w)\n{\n\tauto R=split(r+1),L=split(l);\n\tauto p=L;\n\tdo{\n\t\terase(*p);\n\t\tp++;\n\t}while(p!=R);\n\tS.erase(L,R);\n\tS.insert((Node){l,r,w});\n\tinsert((Node){l,r,w});\n}\nmapmp;\nint idcnt;\ninline int get_id(int x)\n{\n\treturn mp.count(x)?mp[x]:mp[x]=(++idcnt);\n}\nint main()\n{\n\tn=read();\n\tq=read();\n\tfor(int i=1;i<=n;++i)\n\t{\n\t\tint x=read();\n\t\tS.insert((Node){i,i,get_id(x)});\n\t\tinsert((Node){i,i,get_id(x)});\n\t}\n\twhile(q--)\n\t{\n\t\tint opt=read();\n\t\tswitch(opt)\n\t\t{\n\t\t\tcase 1:\n\t\t\t\tint l=read(),r=read(),x=read();\n\t\t\t\tassign(l,r,get_id(x));\n\t\t\t\tbreak;\n\t\t\tcase 2:\n\t\t\t\tint x=read();\n\t\t\t\tprintf(\"%lld\\n\",1ll*x*(n-x+1)+1ll*x*(x-1)+query(x));\n\t\t\t\tbreak;\n\t\t}\n\t}\n\treturn 0;\n}\n/*\n5 5\n1 2 3 4 5\n2 3\n1 1 2 5\n2 4\n1 2 4 5\n2 2\n*/", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e5cc3d985d314475d82db80268cd02b6", "src_uid": "ac85e953ff1cce050834f4e793ec1f02", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": " // ONLY FOR KING RAHMANI MASTER OF DP \\\\\n\n#include \n#include \n#include \n//#define int long long\n#define lb(a) ((a)&(-a))\n#define ordered_set tree, rb_tree_tag,tree_order_statistics_node_update>\nstd::mt19937 rnd(std::chrono::steady_clock::now().time_since_epoch().count());\nusing namespace __gnu_pbds;\nusing namespace std;\n\nconst int maxn=1e3+11,mod=1e9+7;\n\nint a[maxn],sum1[maxn*4],uu,l1,r1,x1,sum[maxn*4],lazy[maxn*4],n,q,lazy2[maxn*4];\n\nlong long ans[maxn*4],lazy1[maxn*4];\n\nvector v;\n\nset > v1[maxn*2];\n\nset ,int > > v2;\n\nset > ::iterator it1,it2;\n\nset ,int> > ::iterator it;\n\npair,pair > p[maxn];\n\npair,int> p5;\n\nvector ,int> > v3;\n\nvector ,int> > v4;\n\nvoid put(int x,long long y,int z,int id)\n{\n ans[id]+=(y+(x*sum[id])+(z*sum1[id]));\n lazy[id]+=x;\n lazy1[id]+=(y+(x*sum[id])+(z*sum1[id]));\n lazy2[id]+=z;\n}\n\nvoid shift(int id)\n{\n put(lazy[id],lazy1[id],lazy2[id],id<<1);\n put(lazy[id],lazy1[id],lazy2[id],id<<1|1);\n lazy1[id]=0;\n lazy[id]=0;\n lazy2[id]=0;\n}\n\nvoid update(int l,int r,int x,long long y,int z,int id=1,int s=1,int e=n+1)\n{\n if(l<1 || r>n+1){\n cout<<-1<<' '<vv)\n swap(vv,yy);\n // cout<<\"yy\"< p1,p2;\n it1=v1[i].lower_bound(make_pair(r+1,0));\n it2=it1;\n it1--;\n p2=*it2;\n p1=*it1;\n if(p2.first==n+1)\n {\n am(p1.second,l,r,1);\n }\n else{\n am(p1.second,p2.first,p2.second,-1);\n am(p1.second,l,r,1);\n am(r,p2.first,p2.second,1);\n }\n v1[i].insert(make_pair(l,r));\n //cout<<\"ee \";\n // for(auto it5:v1[i])\n // cout< p1,p2;\n it1=v1[i].lower_bound(make_pair(l,r));\n it2=it1;\n it1--;\n it2++;\n p2=*it2;\n p1=*it1;\n if(p2.first==n+1)\n {\n am(p1.second,l,r,-1);\n }\n else{\n // cout<=1;i--)\n {\n update1(1,i+1,1);\n }\n r1=1;\n for(int i=2;i<=n;i++)\n {\n if(a[i]!=a[i-1])\n {\n uu=lower_bound(v.begin(),v.end(),a[i-1])-v.begin();\n v2.insert(make_pair(make_pair(r1,i-1),uu));\n ee(r1,i-1,uu);\n r1=i;\n // get4();\n }\n }\n uu=lower_bound(v.begin(),v.end(),a[n])-v.begin();\n v2.insert(make_pair(make_pair(r1,n),uu));\n ee(r1,n,uu);\n // get4();\n for(int i=0;i\n\ntypedef long long ll;\n\nconst int N = 200000;\n\nint n, q;\nstruct BIT{\n\tll tree[N + 5];\n\tint lowbit(int x) {return x & -x;}\n\tvoid update(int l, int r, int k) {\n\t\tfor(int i=l;i<=r;i++) tree[i] += k;\n\t}\n\tll sum(int x) {\n\t\treturn tree[x];\n\t}\n}t1, t2;\nll sum(int x) {return t1.sum(x) + t2.sum(x) * x;}\nvoid modify(int x, int d) {\n//\tprintf(\"! %d %d\\n\", x, d);\n\tt1.update(x, n, - x * d), t2.update(x, n, d);\n} // \\forall k \\in [x, n], ans_k = ans_k + (k - x) * d\n \nstruct node{\n\tint l, r, c;\n\tfriend bool operator < (const node &a, const node &b) {\n\t\treturn a.l < b.l;\n\t}\n}; std::setst, a[N + 5];\nvoid erase(node x) {\n\tst.erase(x);\n\t\n\tauto it = a[x.c].find(x);\n\tif( it != a[x.c].begin() ) it--, modify(x.l - it->r, 1), it++;\n\tit++; if( it != a[x.c].end() ) modify(it->l - x.r, 1); it--;\n\tif( it != a[x.c].begin() ) {\n\t\tauto it2 = it, it3 = it; it2++, it3--;\n\t\tif( it2 != a[x.c].end() ) modify(it2->l - it3->r, -1);\n\t}\n\tif( x.l != x.r ) modify(1, x.r - x.l);\n\t\n\tmodify(a[x.c].begin()->l, 1), modify(n - a[x.c].rbegin()->r + 1, 1), a[x.c].erase(x);\n\tif( !a[x.c].empty() )\n\t\tmodify(a[x.c].begin()->l, -1), modify(n - a[x.c].rbegin()->r + 1, -1);\n}\nvoid insert(node x) {\n\tst.insert(x);\n\t\n\tif( !a[x.c].empty() )\n\t\tmodify(a[x.c].begin()->l, 1), modify(n - a[x.c].rbegin()->r + 1, 1);\n\ta[x.c].insert(x), modify(a[x.c].begin()->l, -1), modify(n - a[x.c].rbegin()->r + 1, -1);\n\t\n\tauto it = a[x.c].find(x);\n\tif( it != a[x.c].begin() ) it--, modify(x.l - it->r, -1), it++;\n\tit++; if( it != a[x.c].end() ) modify(it->l - x.r, -1); it--;\n\tif( it != a[x.c].begin() ) {\n\t\tauto it2 = it, it3 = it; it2++, it3--;\n\t\tif( it2 != a[x.c].end() ) modify(it2->l - it3->r, 1);\n\t}\n\tif( x.l != x.r ) modify(1, x.l - x.r);\n}\nstd::set::iterator split(int p) {\n\tauto x = st.upper_bound((node){p, -1, -1}); x--;\n\tif( x->l == p ) return x;\n\telse if( p > x->r ) return st.end();\n\telse {\n\t\tnode t = (*x); erase(*x);\n\t\tinsert((node){t.l, p - 1, t.c}), insert((node){p, t.r, t.c});\n\t\treturn st.find((node){p, t.r, t.c});\n\t}\n}//[l, r] -> [l, p - 1] + [p, r]\nvoid assign(int l, int r, int c) {\n\tauto rx = split(r + 1), lx = split(l);\n\t\n\tauto p = (lx++);\n\tdo {\n\t\terase(*p), p = (lx++);\n\t}while( p != rx );\n\tinsert((node){l, r, c});\n}\nvoid debug() {\n\tfor(int i=1;i<=5;i++) {\n\t\tprintf(\"%d : \", i);\n\t\tfor(auto x : a[i]) printf(\"(%d %d %d)\\t\", x.l, x.r, x.c);\n\t\tputs(\"\");\n\t}\n\tfor(auto x : st)\n\t\tprintf(\"(%d %d %d)\\t\", x.l, x.r, x.c);\n\tputs(\"\\n\");\n}\n\nstd::mapmp; int idcnt;\nint id(int x) {return mp.count(x) ? mp[x] : mp[x] = (++idcnt);}\n\nint main() {\n\tscanf(\"%d%d\", &n, &q);\n\tfor(int i=1,x;i<=n;i++) scanf(\"%d\", &x), insert((node){i, i, id(x)});\n//\tdebug();\n\t\n\tfor(int i=1,opt,x,l,r;i<=q;i++) {\n\t\tscanf(\"%d\", &opt);\n\t\tif( opt == 2 ) {\n\t\t\tscanf(\"%d\", &x);\n\t\t\tll ans = 1ll * x * (n - x + 1) + 1ll * x * (x - 1);\n\t\t\tprintf(\"%lld\\n\", ans + sum(x));\n\t\t} else scanf(\"%d%d%d\", &l, &r, &x), assign(l, r, id(x));\n//\t\tdebug();\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "364c27c0bb0e9f762a67a4f8a9cec1b0", "src_uid": "ac85e953ff1cce050834f4e793ec1f02", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "\n// Problem : G. Growing flowers\n// Contest : Codeforces - Bubble Cup 13 - Finals [Online Mirror, unrated, Div. 1]\n// URL : https://codeforces.com/contest/1423/problem/G\n// Memory Limit : 256 MB\n// Time Limit : 4000 ms\n// Powered by CP Editor (https://github.com/cpeditor/cpeditor)\n\n#include \nusing namespace std;\n\nconstexpr int Maxn = 1e5 + 5;\n\nint n, q, a[Maxn];\nint qop[Maxn], ql[Maxn], qr[Maxn], qx[Maxn];\nvector buc[Maxn];\n\ntemplate\nstruct chtholly_node {\n typedef _Tp value_type;\n mutable int l, r;\n mutable value_type v;\n chtholly_node(int L, int R, value_type x) : l(L), r(R), v(x) { }\n bool operator < (const chtholly_node& x) const { return l < x.l; }\n};\ntemplate\nstruct chtholly_tree : public set> {\n typedef _Tp value_type;\n typedef chtholly_node node;\n typedef typename set::iterator IT;\n inline IT split(int pos) {\n IT itl = this->lower_bound(node(pos, -1, value_type()));\n if (itl != this->end() && itl->l == pos) return itl; --itl;\n IT itr = this->insert(node(pos, itl->r, itl->v)).first;\n itl->r = pos - 1; return itr;\n }\n inline void assign(int l, int r, value_type x) {\n IT itr = split(r + 1), itl = split(l);\n this->erase(itl, itr);\n this->insert(node(l, r, x));\n }\n inline int64_t get(int k) {\n int64_t ans = 0;\n for (IT it = this->begin(); it != this->end(); ++it) {\n buc[it->v].push_back(it->l);\n buc[it->v].push_back(it->r);\n }\n for (IT it = this->begin(); it != this->end(); ++it) {\n int l = it->l, r = it->r;\n int L = max(1, l - k + 1), R = min(r, n - k + 1);\n int pre = -1, suf = n + 1, v = it->v;\n auto itl = lower_bound(buc[v].begin(), buc[v].end(), l);\n if (itl != buc[v].begin()) pre = *prev(itl);\n auto itr = upper_bound(buc[v].begin(), buc[v].end(), r);\n if (itr != buc[v].end()) suf = *next(itr);\n L = max(L, pre + 1);\n R = min(R, suf - 1);\n ans += max(R - L + 1, 0);\n }\n for (IT it = this->begin(); it != this->end(); ++it) {\n buc[it->v].clear();\n }\n return ans;\n }\n};\n\nchtholly_tree cht;\n\nint main() {\n \n scanf(\"%d %d\", &n, &q);\n vector vecs;\n for (int i = 1; i <= n; ++i) {\n scanf(\"%d\", a + i);\n vecs.push_back(a[i]);\n }\n for (int i = 1; i <= q; ++i) {\n scanf(\"%d\", qop + i);\n if (qop[i] == 1) scanf(\"%d %d\", ql + i, qr + i);\n scanf(\"%d\", qx + i);\n if (qop[i] == 1) {\n vecs.push_back(qx[i]);\n }\n }\n sort(vecs.begin(), vecs.end());\n vecs.erase(unique(vecs.begin(), vecs.end()), vecs.end());\n for (int i = 1; i <= n; ++i) {\n a[i] = lower_bound(vecs.begin(), vecs.end(), a[i]) - vecs.begin() + 1;\n }\n for (int i = 1; i <= q; ++i) {\n if (qop[i] == 1) {\n qx[i] = lower_bound(vecs.begin(), vecs.end(), qx[i]) - vecs.begin() + 1;\n }\n }\n \n for (int i = 1; i <= n; ++i) {\n cht.insert(chtholly_node(i, i, a[i]));\n }\n for (int i = 1; i <= q; ++i) {\n if (qop[i] == 1) {\n cht.assign(ql[i], qr[i], qx[i]);\n }\n else {\n printf(\"%lld\\n\", cht.get(qx[i]));\n }\n }\n \n return 0;\n \n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b3e0125d2862afc7bd3abeb14e7169a0", "src_uid": "ac85e953ff1cce050834f4e793ec1f02", "difficulty": 3500.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\nint n,cnt,S,T,ans;\nint to[10000],next[10000],head[110],dis[110],pv[110],pe[110],cost[10000],flow[10000],inq[110];\nint v[110],s[30];\nchar str[110];\nqueue q;\ninline void add(int a,int b,int c,int d)\n{\n\tto[cnt]=b,next[cnt]=head[a],cost[cnt]=c,flow[cnt]=d,head[a]=cnt++;\n\tto[cnt]=a,next[cnt]=head[b],cost[cnt]=-c,flow[cnt]=0,head[b]=cnt++;\n}\ninline int bfs()\n{\n\tint i,u;\n\tmemset(dis,0xc0,sizeof(dis));\n\tq.push(S),dis[S]=0;\n\twhile(!q.empty())\n\t{\n\t\tu=q.front(),q.pop(),inq[u]=0;\n\t\tfor(i=head[u];i!=-1;i=next[i])\tif(dis[to[i]]=-100000;\n}\nint main()\n{\n\tscanf(\"%d%s\",&n,str+1),S=0,T=n/2+27;\n\tint i,j;\n\tfor(i=1;i<=n;i++)\ts[str[i]-'a'+1]++,scanf(\"%d\",&v[i]);\n\tmemset(head,-1,sizeof(head));\n\tfor(j=1;j<=26;j++)\n\t{\n\t\tadd(S,j,0,s[j]);\n\t\tfor(i=1;i+i<=n;i++)\n\t\t{\n\t\t\tif(str[i]-'a'+1==j&&str[n-i+1]-'a'+1==j)\tadd(j,i+26,max(v[i],v[n-i+1]),1);\n\t\t\telse\tif(str[i]-'a'+1==j)\tadd(j,i+26,v[i],1);\n\t\t\telse\tif(str[n-i+1]-'a'+1==j)\tadd(j,i+26,v[n-i+1],1);\n\t\t\telse\tadd(j,i+26,0,1);\n\t\t}\n\t}\n\tfor(i=1;i+i<=n;i++)\tadd(i+26,T,0,2);\n\twhile(bfs())\n\t{\n\t\tans+=dis[T];\n\t\tfor(i=T;i!=S;i=pv[i])\tflow[pe[i]]--,flow[pe[i]^1]++;\n\t}\n\tprintf(\"%d\",ans);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9918e5631056ec3a68e7ec77c200ee53", "src_uid": "896555ddb6e1c268cd7b3b6b063fce50", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "#include\n\nusing namespace std;\n\n#define PB push_back\n\n#define SZ(x) ((int)((x).size()))\n\ntypedef pair pll;\n\nstruct CostFlow {\n\n static const int MXN = 1505;\n\n static const long long INF = 102938475610293847LL;\n\n struct Edge {\n\n int v, r;\n\n long long f, c;\n\n };\n\n int n, s, t, prv[MXN], prvL[MXN], inq[MXN];\n\n long long dis[MXN], fl, cost;\n\n vector E[MXN];\n\n void init(int _n, int _s, int _t) {\n\n n = _n; s = _s; t = _t;\n\n for (int i=0; i que;\n\n que.push(s);\n\n while (!que.empty()) {\n\n int u = que.front(); que.pop();\n\n inq[u] = 0;\n\n for (int i=0; i 0 && dis[v] < dis[u] + w) {\n\n prv[v] = u; prvL[v] = i;\n\n dis[v] = dis[u] + w;\n\n if (!inq[v]) {\n\n inq[v] = 1;\n\n que.push(v);\n\n }\n\n }\n\n }\n\n }\n\n if ( dis[t] == -INF ) break;\n\n long long tf = INF;\n\n for (int v=t, u, l; v!=s; v=u) {\n\n u=prv[v]; l=prvL[v];\n\n tf = min(tf, E[u][l].f);\n\n }\n\n for (int v=t, u, l; v!=s; v=u) {\n\n u=prv[v]; l=prvL[v];\n\n E[u][l].f -= tf;\n\n E[v][E[u][l].r].f += tf;\n\n }\n\n cost += tf * dis[t];\n\n }\n\n cout << cost << endl;\n\n }\n\n}flow;\n\nint n, S, T;\n\nchar buf[110];\n\nchar str[1];\n\nint c[110];\n\nint cnt[27];\n\nint main() {\n\n scanf(\"%d%s\", &n, buf + 1 );\n\n T = 0;\n\n S = n / 2 * 26 + n + 1;\n\n for( int i = 1; i <= n; i ++ ) cnt[buf[i] - 'a' + 1]++, scanf(\"%d\", c + i );\n\n flow.init( S + 26, S, T );\n\n for( int i = 1; i <= 26; i ++ ) flow.add_edge( S, S + i, cnt[i], 0 );\n\n for( int i = 1; i <= n; i ++ ) flow.add_edge( i, T, 1, 0 );\n\n for( int i = 1; i <= n >> 1; i ++ ) {\n\n for( int j = 1; j <= 26; j ++ ) flow.add_edge( S + j, S - i * 26 - 1 + j, 1, 0 );\n\n for( int j = 1; j <= 26; j ++ ) {\n\n flow.add_edge( S - i * 26 - 1 + j, i, 1, j + 'a' - 1 == buf[i] ? c[i] : 0 );\n\n flow.add_edge( S - i * 26 - 1 + j, n + 1 - i, 1, j + 'a' - 1 == buf[n + 1 - i] ? c[n + 1 - i] : 0 );\n\n }\n\n }\n\n flow.flow();\n\n return 0;\n\n}\n ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "002384174a24465dd2b4f56d0c352703", "src_uid": "896555ddb6e1c268cd7b3b6b063fce50", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\nstring change(char x)\n{\nstring s = \"\";\nint num = 0;\nif(x >= '0' && x <= '9'){\nnum = x - '0';\n}\nelse {\nnum = x - 'A' + 10;\n}\nstring ans = \"\";\nwhile(num != 0){\nint mod = num%2;\nif(mod) ans += '1';\nelse ans += '0';\nnum = num/2;\n}\nreverse(ans.begin(), ans.end());\nwhile(ans.size() < 4) ans = \"0\"+ans;\nreturn ans;\n}\n\nstring f(string s)\n{\nstring ans = \"\";\nfor(int i=0; i\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define NN 1024\nint cap[NN][NN];\nint cost[NN][NN];\nint fnet[NN][NN], adj[NN][NN], deg[NN];\n\nint par[NN], d[NN]; // par[source] = source;\nint pi[NN];\n#define CLR(a, x) memset( a, x, sizeof( a ) )\n#define Inf (INT_MAX/2)\n#define Pot(u,v) (d[u] + pi[u] - pi[v])\nbool dijkstra( int n, int s, int t )\n{\n\tfor( int i = 0; i < n; i++ ) d[i] = Inf, par[i] = -1;\n\td[s] = 0;\n\tpar[s] = -n - 1;\n\twhile( 1 ){\n\t\tint u = -1, bestD = Inf;\n\t\tfor( int i = 0; i < n; i++ ) if( par[i] < 0 && d[i] < bestD )\n\t\tbestD = d[u = i];\n\t\tif( bestD == Inf ) break;\n\t\tpar[u] = -par[u] - 1;\n\t\tfor( int i = 0; i < deg[u]; i++ ){\n\t\t\tint v = adj[u][i];\n\t\t\tif( par[v] >= 0 ) continue;\n\t\t\tif( fnet[v][u] && d[v] > Pot(u,v) - cost[v][u] )\n\t\t\t\td[v] = Pot( u, v ) - cost[v][u], par[v] = -u-1;\n\t\t\tif( fnet[u][v] < cap[u][v] && d[v] > Pot(u,v) + cost[u][v] )\n\t\t\t\td[v] = Pot(u,v) + cost[u][v], par[v] = -u - 1;\n\t\t}\n\t}\n\tfor( int i = 0; i < n; i++ ) if( pi[i] < Inf ) pi[i] += d[i];\n\treturn par[t] >= 0;\n}\n#undef Pot\nint mcmf3( int n, int s, int t, int &fcost ){\n\tCLR( deg, 0 );\n\tfor( int i = 0; i < n; i++ )\n\t\tfor( int j = 0; j < n; j++ )\n\t\t\tif( cap[i][j] || cap[j][i] ) adj[i][deg[i]++] = j;\n\tCLR( fnet, 0 );\n\tCLR( pi, 0 );\n\tint flow = fcost = 0;\n\twhile( dijkstra( n, s, t ) ){\n\t\tint bot = INT_MAX;\n\t\tfor( int v = t, u = par[v]; v != s; u = par[v = u] )\n\t\t\tbot >n;\n\tchar s[n];\n\tint b[n];\n\tmap > mp;\n\tfor(i=0;i>s[i];\n\t\tif(mp.find(s[i])==mp.end()){\n\t\t\tvector temp;\n\t\t\ttemp.push_back(i);\n\t\t\tmp.insert(make_pair(s[i],temp));\n\t\t}\n\t\telse mp[s[i]].push_back(i);\n\t}\n\tfor(i=0;i>b[i];\n\t}\n\tint left=mp.size();\n\tmemset( cap, 0, sizeof( cap ) );\t\n\tmap >::iterator it;\n\ti=1;\n\tfor(it=mp.begin();it!=mp.end();it++){\n\t\tcap[0][i]=(it->second).size();\n\t\tcost[0][i]=0;\n\t\tfor(j=0;jfirst && s[(n-j)-1]==it->first){\n\t\t\t\tcost[i][left+1+j]= (-1)* max(b[j],b[(n-j)-1]);\n\t\t\t}\n\t\t\telse if(s[j]==it->first){\n\t\t\t\tcost[i][left+1+j]= (-1)*b[j];\n\t\t\t}\n\t\t\telse if(s[(n-j)-1]==it->first){\n\t\t\t\tcost[i][left+1+j]= (-1)*b[(n-j)-1];\n\t\t\t}\n\t\t\telse cost[i][left+1+j]= 0;\n\t\t}\n\t\ti++;\n\t}\n\tfor(j=0;j\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define ll long long\n#define mode 1000000007\nusing namespace std;\nll dp[55][55][55][55];//\u5230\u4e86\u7b2c\u51e0\u4e2a\u70b9\uff0c\u5947\u6570\u767d\u70b9\uff0c\u5947\u6570\u9ed1\u70b9\uff0c\u5076\u6570\u767d\u70b9 \nint n,typ;\nint c[55];\nll mul[55];\nint main()\n{\n\tscanf(\"%d%d\",&n,&typ);\n\tmul[0]=1;\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tscanf(\"%d\",&c[i]);//0\u9ed11\u767d-1\u4efb\u610f \n\t\tmul[i]=(mul[i-1]<<1)%mode;\n\t}\n\tll ret=0;\n\tif(c[1]==0||c[1]==-1)\n\t{\n\t\tdp[1][0][1][0]=1; \n\t\tif(typ==1&&n==1)\n\t\t{\n\t\t\tret++;\n\t\t}\n\t}\n\tif(c[1]==1||c[1]==-1)\n\t{\n\t\tdp[1][1][0][0]=1;\n\t\tif(typ==1&&n==1)\n\t\t{\n\t\t\tret++;\n\t\t}\n\t}\n\tfor(int i=2;i<=n;i++)\n\t{\n\t\tfor(int j=0;j<=i;j++)//\u5947\u6570\u767d \n\t\t{\n\t\t\tfor(int k=0;k+j<=i;k++)//\u5947\u6570\u9ed1 \n\t\t\t{\n\t\t\t\tfor(int p=0;j+k+p<=i;p++)//\u5076\u6570\u767d \n\t\t\t\t{\n\t\t\t\t\tint t=i-j-k-p;//\u5076\u6570\u9ed1 \n\t\t\t\t\tif(c[i]==1||c[i]==-1)\n\t\t\t\t\t{\n\t\t\t\t\t\tll s=0;\n\t\t\t\t\t\tif(j+p)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(j)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif(!k)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ts+=dp[i-1][j-1][k][p];\n\t\t\t\t\t\t\t\t}else\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ts+=mul[k-1]*dp[i-1][j-1][k][p]%mode;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ts%=mode;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif(p)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif(k)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ts+=mul[k-1]*dp[i-1][j][k][p-1]%mode;\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ts%=mode\n\t\t\t\t\t\t\t}\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\ts*=mul[j+p+t-1];\n\t\t\t\t\t\ts%=mode;\n\t\t\t\t\t\tdp[i][j][k][p]+=s;\n\t\t\t\t\t\tdp[i][j][k][p]%=mode;\n\t\t\t\t\t}\n\t\t\t\t\tif(c[i]==0||c[i]==-1)\n\t\t\t\t\t{\n\t\t\t\t\t\tll s=0;\n\t\t\t\t\t\tif(k+t)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(k)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif(!j)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ts+=dp[i-1][j][k-1][p];\n\t\t\t\t\t\t\t\t}else\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ts+=mul[j-1]*dp[i-1][j][k-1][p]%mode;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ts%=mode;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif(t)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif(j)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ts+=mul[j-1]*dp[i-1][j][k][p]%mode;\t\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\ts%=mode;\n\t\t\t\t\t\t\t}\t\t\t\t\t\t\t\n\t\t\t\t\t\t}\n\t\t\t\t\t\ts*=mul[k+p+t-1];\n\t\t\t\t\t\ts%=mode;\n\t\t\t\t\t\tdp[i][j][k][p]+=s;\n\t\t\t\t\t\tdp[i][j][k][p]%=mode;\n\t\t\t\t\t}\n\t\t\t\t\tif(i==n)\n\t\t\t\t\t{\n\t\t\t\t\t\tif((j+k)%2==typ)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tret+=dp[i][j][k][p];\n\t\t\t\t\t\t\tret%=mode;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%lld\\n\",ret);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "dcd37d55d17fc72c004ac443df680a98", "src_uid": "aaf5f8afa71d9d25ebab405dddec78cd", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "/*\n _______ _______ _ ______ _______ _______ \n|\\ /|( ___ )|\\ /| ( ___ )( ( /|( __ \\ ( )( ____ \\\n( \\ / )| ( ) || ) ( | | ( ) || \\ ( || ( \\ ) | () () || ( \\/\n \\ (_) / | | | || | | | | (___) || \\ | || | ) | | || || || (__ \n \\ / | | | || | | | | ___ || (\\ \\) || | | | | |(_)| || __) \n ) ( | | | || | | | | ( ) || | \\ || | ) | | | | || ( \n | | | (___) || (___) | | ) ( || ) \\ || (__/ ) | ) ( || (____/\\\n \\_/ (_______)(_______) |/ \\||/ )_)(______/ |/ \\|(_______/\n \n_________ _ _________ _______ \n\\__ __/( ( /| \\__ __/|\\ /|( ____ \\\n ) ( | \\ ( | ) ( | ) ( || ( \\/\n | | | \\ | | | | | (___) || (__ \n | | | (\\ \\) | | | | ___ || __) \n | | | | \\ | | | | ( ) || ( \n___) (___| ) \\ | | | | ) ( || (____/\\\n\\_______/|/ )_) )_( |/ \\|(_______/\n \n _______ _______ _______ _ _ _________ _______ _________\n( )( ___ )( ___ )( ( /|( \\ \\__ __/( ____ \\|\\ /|\\__ __/\n| () () || ( ) || ( ) || \\ ( || ( ) ( | ( \\/| ) ( | ) ( \n| || || || | | || | | || \\ | || | | | | | | (___) | | | \n| |(_)| || | | || | | || (\\ \\) || | | | | | ____ | ___ | | | \n| | | || | | || | | || | \\ || | | | | | \\_ )| ( ) | | | \n| ) ( || (___) || (___) || ) \\ || (____/\\___) (___| (___) || ) ( | | | \n|/ \\|(_______)(_______)|/ )_)(_______/\\_______/(_______)|/ \\| )_( \n \nhttps://www youtube com/watch?v=Fm5iP0S1z9w\n*/\n \n#pragma GCC optimize(\"O3\")\n#include \nusing namespace std;\ntypedef long long ll;\nconst ll mod7=1000000007LL;\ninline ll getint() {\n ll _x=0,_tmp=1; char _tc=getchar(); \n while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();\n if( _tc == '-' ) _tc=getchar() , _tmp = -1;\n while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();\n return _x*_tmp;\n}\ninline ll add(ll _x, ll _y, ll _mod=mod7) {\n _x+=_y;\n return _x>=_mod ? _x-_mod : _x;\n}\ninline ll sub(ll _x, ll _y, ll _mod=mod7) {\n _x-=_y;\n return _x<0 ? _x+_mod : _x;\n}\ninline ll mul(ll _x, ll _y ,ll _mod=mod7) {\n _x*=_y;\n return _x>=_mod ? _x%_mod : _x;\n}\nll mypow(ll _a, ll _x, ll _mod) {\n if(_x == 0) return 1ll;\n ll _ret = mypow(mul(_a, _a, _mod), _x>>1, _mod);\n if(_x & 1) _ret=mul(_ret, _a, _mod);\n return _ret;\n}\nll mymul(ll _a, ll _x, ll _mod) {\n if(_x == 0) return 0ll;\n ll _ret = mymul(add(_a, _a, _mod), _x>>1, _mod);\n if(_x & 1) _ret=add(_ret, _a, _mod);\n return _ret;\n}\nvoid sleep(double sec = 1021) {\n\tclock_t s = clock();\n\twhile(clock() - s < CLOCKS_PER_SEC * sec);\n}\n#define Bye exit(0)\nint __ = 1 , _cs;\n/*********default*********/\n\nconst int mxN=50, M=1e9+7;\nint n, p, c[mxN], qh, qt=1;\nll p2[mxN+1], dp[mxN+1][mxN+1][mxN+1][mxN+1]={1}, ans;\n\nint main() {\n\tios_base::sync_with_stdio(0); cin.tie(0);\n \n\tcin >> n >> p;\n\tfor(int i=0; i> c[i];\n\tp2[0]=1;\n\tfor(int i=1; i<=n; ++i)\n\t\tp2[i]=p2[i-1]*2%M;\n\tfor(int x1=0; x1<=n; ++x1) {\n\t\tfor(int x2=0; x2<=n; ++x2) {\n\t\t\tif(x1+x2>n)\n\t\t\t\tbreak;\n\t\t\tfor(int x3=0; x3<=n; ++x3) {\n\t\t\t\tif(x1+x2+x3>n)\n\t\t\t\t\tbreak;\n\t\t\t\tfor(int x4=0; x4<=n; ++x4) {\n\t\t\t\t\tint i=x1+x2+x3+x4;\n\t\t\t\t\tif(i==n&&(x2+x4)%2==p)\n\t\t\t\t\t\tans=(dp[x1][x2][x3][x4]+ans)%M;\n\t\t\t\t\tif(i>=n)\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdp[x1][x2][x3][x4]%=M;\n\t\t\t\t\tif(c[i]!=1) {\n\t\t\t\t\t\tdp[x1+1][x2][x3][x4]+=p2[x1+x2+x3]*(x4?p2[x4-1]:0)%M*dp[x1][x2][x3][x4]%M;\n\t\t\t\t\t\tdp[x1][x2+1][x3][x4]+=p2[x1+x2+x3]*(x4?p2[x4-1]:1)%M*dp[x1][x2][x3][x4]%M;\n\t\t\t\t\t}\n\t\t\t\t\tif(c[i]!=0) {\n\t\t\t\t\t\tdp[x1][x2][x3+1][x4]+=p2[x3+x4+x1]*(x2?p2[x2-1]:0)%M*dp[x1][x2][x3][x4]%M;\n\t\t\t\t\t\tdp[x1][x2][x3][x4+1]+=p2[x3+x4+x1]*(x2?p2[x2-1]:1)%M*dp[x1][x2][x3][x4]%M;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tcout << ans;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4f428c46b7342df22f5a9139cfa78caf", "src_uid": "aaf5f8afa71d9d25ebab405dddec78cd", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "#include \n#define maxN 52\n#define mod 1000000007LL\nusing namespace std;\nlong long Count[maxN + 1][maxN + 1][maxN + 1][maxN + 1];\n\nint main()\n{\n int n, p;\n scanf(\"%d%d\", &n, &p);\n int c[n + 2];\n for (int i = 0; i < n; ++ i)\n scanf(\"%d\", &c[i]);\n\n long long ans = 0;\n //memset(Count, 0, sizeof(Count));\n Count[0][0][0][0] = 1;\n\n for (int be = 0; be <= n; ++ be)\n for (int we = 0; we + be <= n; ++ we)\n for (int bo = 0; bo + be + we <= n; ++ bo)\n for (int wo = 0; bo + be + we + wo <= n; ++ wo)\n {\n int i = be + we + bo + wo;\n if (c[i] != 0)\n {\n long long s = i ? ((1LL << (i - 1)) % mod) : 1;\n if (bo)\n {\n Count[be][we + 1][bo][wo] += 1LL * Count[be][we][bo][wo] * s;\n Count[be][we + 1][bo][wo] %= mod;\n }\n else\n s = (1LL << i) % mod) ;\n Count[be][we][bo][wo + 1] += 1LL * Count[be][we][bo][wo] * s;\n Count[be][we][bo][wo + 1] %= mod;\n }\n if (c[i] != 1)\n {\n long long s = i ? ((1LL << (i - 1)) % mod) : 1;\n if (wo)\n {\n Count[be + 1][we][bo][wo] += 1LL * Count[be][we][bo][wo] * s;\n Count[be + 1][we][bo][wo] %= mod;\n }\n else\n s = (1LL << i) % mod) ;\n\n Count[be][we][bo + 1][wo] += 1LL * Count[be][we][bo][wo] * s;\n Count[be][we][bo + 1][wo] %= mod;\n }\n if (i == n && ((bo + wo) & 1) == p)\n {\n ans += Count[be][we][bo][wo];\n ans %= mod;\n }\n }\n printf(\"%lld\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "db451b1218618228abe4c18dfb4be2f9", "src_uid": "aaf5f8afa71d9d25ebab405dddec78cd", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nconst int maxN = 55;\nconst int mod = (int)1e9 + 7;\nint sum(int a, int b) {\n int s = a + b;\n if (s >= mod) s -= mod;\n return s;\n}\nint mult(int a, int b) {\n return (1LL * a * b) % mod;\n}\nint pw[maxN * maxN];\nint c[maxN];\nint dp[maxN][maxN][maxN][maxN][2];\nint n, p;\nint get(int x, int y) {\n if (y == 0) {\n if (x == 0) return 1;\n else return 0;\n }\n return pw[y - 1];\n}\nint val(int a, int b, int c, int d, int e) {\n if (a < 0 || b < 0 || c < 0 || d < 0) return 0;\n return dp[a][b][c][d][e];\n}\nint main() {\n srand(time(0));\n //freopen(\"input.txt\", \"r\", stdin);\n ios_base::sync_with_stdio(false);\n pw[0] = 1;\n for (int i = 1; i < maxN * maxN; i++) {\n pw[i] = sum(pw[i - 1], pw[i - 1]);\n }\n cin >> n >> p;\n for (int i = 1; i <= n; i++) cin >> c[i];\n dp[n + 1][0][0][0][0] = 1;\n for (int i = n; i >= 1; i--) {\n for (int white = 0; white <= n - i + 1; white++) {\n int black = n - i + 1 - white;\n for (int eW = 0; eW <= white; eW++) {\n for (int eB = 0; eB <= black; eB++) {\n for (int bit = 0; bit < 2; bit++) {\n int st = 0;\n int oW = white - eW;\n int oB = black - eB;\n for (int clr = 0; clr < 2; clr++) {\n if (c[i] != -1 && clr != c[i]) continue;\n for (int pBit = 0; pBit < 2; pBit++) {\n int ne = pBit ^ bit;\n if (clr == 0) {\n st = sum(st, mult(val(i + 1, white - 1, oW - ne, oB, pBit), get(ne ^ 1, oB)));\n }\n else {\n st = sum(st, mult(val(i + 1, white, oW, oB - ne, pBit), get(ne ^ 1, oW)));\n }\n }\n }\n dp[i][white][oW][oB][bit] = st;\n }\n }\n }\n }\n }\n int cur = 0;\n for (int i = 0; i <= n; i++) {\n for (int j = 0; j <= n; j++) {\n for (int k = 0; k <= n; k++) {\n for (int r = 0; r <= n; r++) {\n cur = sum(cur, dp[i][j][k][p]);\n }\n }\n }\n }\n cout << cur;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ac3e9f0eeee3734bc3d085e11192433e", "src_uid": "aaf5f8afa71d9d25ebab405dddec78cd", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\ntypedef long long ll;\nll k;\nconst ll inf = 1LL<<30;\nll solve(ll a,ll b){\n\tif(b < a)return inf;\n\tif(a==b)return 0;\n\tll ret = inf;\n\tfor(int i=2;i<=k;i++){\n\t\tif(b%i)\n\t\tret = min(ret, solve(a,b - b % i)+1);\n\t}\n\tret = min(ret , solve(a,b-1)+1);\n\treturn ret;\n}\n\nint main(){\n\tll a,b,ans=0;\n\tcin>>b>>a>>k;\n\tll v1 = b%k;\n\tif(b - v1 >= a){\n\t\tb-=v1;\n\t\tans++;\n\t\tll diff = b-a;\n\t\tll op = diff / k;\n\t\tif(op > 5)op-=3;\n\t\tans += op * 2;\n\t\tb -= op * k;\n\t}\n\tans += solve(a,b);\n\tcout<\n#define pi acos(-1)\n#define ll long long\n#define pii pair\n#define debug(a) cout<=a ; i--)\n#define trav(a, x) for(auto& a : x)\n#define allin(a , x) for(auto a : x)\n#define all(x) begin(x), end(x)\n#define sz(x) (ll)(x).size()\nusing namespace std;\nconst ll INF = 1e17 + 9;\nint main(){\n ios::sync_with_stdio(false);\n cin.tie(0);\n ll b,a,k;\n cin>>a>>b>>k;\n ll lcmt=2;\n rep(i,3,k+1){\n lcmt = (lcmt*i)/__gcd(lcmt,i);\n }\n\n /// first interval\n ll mult1=((b+lcmt-1)/lcmt)*lcmt;\n set vis1;\n queue q;\n bool ch=0;\n ll ans1=0;\n ll dp[maxn];\n rep(i,0,maxn){\n dp[i]=INF;\n } \n dp[(mult1-1)%lcmt]=1;\n dp[0]=0;\n per(i,mult1,0){\n rep(j,2,k+1){\n dp[(i/j)*j]=min(dp[i]+1,dp[(i/j)*j]);\n }\n dp[i]=min(dp[i],dp[i+1]+1);\n }\n ans1=dp[b%lcmt];\n /// third interval\n set vis2;\n ll mult2 = ((a)/lcmt)*lcmt;\n ch=0;\n q.push({a,0});\n vis2.insert(a);\n ll ans2=0;\n while(!ch){\n auto e = q.front();\n // cout<\n#define pi acos(-1)\n#define ll long long\n#define pii pair\n#define debug(a) cout<=a ; i--)\n#define trav(a, x) for(auto& a : x)\n#define allin(a , x) for(auto a : x)\n#define all(x) begin(x), end(x)\n#define sz(x) (ll)(x).size()\nusing namespace std;\nconst ll INF = 1e17 + 9;\nint main(){\n ios::sync_with_stdio(false);\n cin.tie(0);\n ll b,a,k;\n cin>>a>>b>>k;\n ll lcmt=2;\n rep(i,3,k+1){\n lcmt = (lcmt*i)/__gcd(lcmt,i);\n }\n // cout< vis1;\n queue q;\n bool ch=0;\n q.push({mult1-1,0});\n vis1.insert(mult1-1);\n ll ans1=0;\n ll b2=b+(b==1);\n while(!ch){\n auto e = q.front();\n q.pop();\n // cout< vis2;\n ll mult2 = ((a)/lcmt)*lcmt;\n ch=0;\n q.push({a,0});\n vis2.insert(a);\n ll ans2=0;\n while(!ch){\n auto e = q.front();\n // cout<\n#include \n\nusing namespace std;\n\nint main()\n{\n long n,d;\n long x[100010];\n long long sum;\n long k;\n long long s,k1;\n \n s=0; sum=0; k=1; k1=0;\n cin >> n >> d;\n for (long i=1; i<= n; i++)\n cin >> x[i];\n \n if (n<3) {cout <<\"0\"<=d) {cout <<\"1\"<1) \n { \n s=k-i; \n k1= k-i-1; \n s=(s*k1)/2; \n sum+= s; \n }\n }\n \n cout << sum << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2256830ffca60ca23979948df8116987", "src_uid": "bd599d76c83cc1f30c1349ffb51b4273", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\nconst ll mod = 1e9+7;\nll n,m,k;\nconst ll N = 1000020;\nll fac[N],inv[N];\nll f[1020][1020];\nll ksm(ll a,ll b)\n{\n\tif(b<0) return 0;\n//\tif(a==0&&b==0) return 0;\n\tll ret = 1;\n\twhile(b)\n\t{\n\t\tif(b&1)ret=ret*a%mod;\n\t\ta=a*a%mod;\n\t\tb>>=1;\n\t}\n\treturn ret;\n}\nll C(ll n,ll m)\n{\n\tif(n=0;i--)\n\t inv[i]=(inv[i+1]*(i+1))%mod;\n\tf[0][0] = 1;\n\tfor(ll i=1;i<=n;i++)\n\t for(ll j=1;j<=i;j++)\n\t f[i][j] = j*f[i-1][j] + f[i-1][j-1],f[i][j]%=mod;\n\tll ans = 0;\n\tfor(ll i=0;i<=n;i++)\n\t{\n\t\tfor(ll j=0;j<=i;j++)\n\t\tans += fac[i]* f[n][i]%mod*fac[i]%mod*f[n][i]%mod*C(k,i)%mod*C(i,j)*%mod*C(k-i,i-j)%mod\n\t\t*ksm(j,n*(m-2))%mod,ans%=mod;\n\t}\n\tprintf(\"%lld\\n\",ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "14d0af7da717b61ed3d20c0fb7df2191", "src_uid": "f22f28e2d8933f4199ba5ccfc0de8cda", "difficulty": 2300.0} {"lang": "GNU C++11", "source_code": "# include \n# include \n# include \n# define int long long\n\nconst int MOD = 1e9 + 7;\nconst int INF= 1e9 + 7;\n\nusing namespace std;\nint factorial[11111 * 2 * 2 * 2 * 2 * 2 * 2 ],d[11111 * 2][11111 * 2];\n\nvoid initialiazition()\n{\n factorial[0] = 1;\n for(int i = 1;i <= 2000;i ++)\n factorial[i] = (factorial[i - 1] * i) % MOD;\n}\nint binpow(int x, int y) {\n int res = 1;\n while(y) {\n if(y % 2)\n res = (res * 1LL * x) % INF;\n y /= 2;\n x = (x * 1LL * x) % INF;\n }\n return res % INF;\n}\n\nint c(int k,int i)\n{\n return (factorial[k] * binpow((factorial[k - i] * factorial[i]) % MOD,MOD - 2)) % MOD;\n}\nmain ()\n{\n int n,m,k;\n cin >> n >> m >> k;\n initialiazition();\n if(m == 1)\n {\n cout << binpow(k,n) % 1000000007;\n return 0;\n }\n d[0][0] = 1;\n for(int i = 1; i <= 2000; i++)\n for(int j = 1; j <= n; j++)\n d[i][j] = (d[i - 1][j] * j + d[i - 1][j - 1]) % MOD;\n int res = 0;\n for(int i = 1; i <= n; i++) {\n for(int j = 0; j <= i; j++)\n {\n if(i + i - j <= k) {\n int cur = c(k, j);\n cur = (cur * 1LL * c(k - j, i - j)) % INF;\n cur = (cur * 1LL * c(k - i, i - j)) % INF;\n cur = (cur * 1LL * d[n][i]) % INF;\n cur = (cur * 1LL * d[n][i]) % INF;\n cur = (cur * 1LL * factorial[i]) % INF;\n cur = (cur * 1LL * factorial[i]) % INF;\n cur = (cur * 1LL * binpow(j, (n * (m - 2)))) % INF;\n res = (res + cur) % INF;\n }\n }\n }\n cout << res << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1c3286c651cb35e1c1f50e34b4485f10", "src_uid": "f22f28e2d8933f4199ba5ccfc0de8cda", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define fi first\n#define se second\n#define mp make_pair\n#define pb push_back\n#define rep(i, a, b) for(int i=(a); i<(b); i++)\n#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)\n#define sz(a) (int)a.size()\n#define de(a) cout << #a << \" = \" << a << endl\n#define dd(a) cout << #a << \" = \" << a << \" \"\n#define all(a) a.begin(), a.end()\n#define pw(x) (1ll<<(x))\n#define endl \"\\n\"\ntypedef long long ll;\ntypedef pair pii;\ntypedef vector vi;\nll P = 1e9 + 7;\nll add(ll a, ll b) {if((a += b) >= P) a -= P; return a;}\nll sub(ll a, ll b) {if((a -= b) < 0) a += P; return a;}\nll mul(ll a, ll b) {return 1ll * a * b % P;}\nll kpow(ll a,ll b) {ll res=1;for(;b;b>>=1,a=mul(a,a))if(b&1)res=mul(a,res);return res;}\n//---\nconst int N = 1e6 + 7;\nint jc[N]={1},njc[N];\nint dp[N][N];\nint C(ll n,ll m) {\n\treturn mul(jc[n],mul(njc[m],njc[n-m]));\n}\nint main() {\n\trep(i,1,N)jc[i]=mul(jc[i-1],i);njc[N-1]=kpow(jc[N-1],P-2);per(i,0,N-1)njc[i]=mul(njc[i+1],i+1);\n\tint n,m,k;scanf(\"%d%d%d\",&m,&n,&k);\n\tdp[0][0]=1;\n\trep(i,1,m+1)rep(j,1,min(m,k)+1)dp[i][j]=add(mul(dp[i-1][j],j),mul(dp[i-1][j-1],k-j+1));\n\tif(n==1) {\n\t\tprintf(\"%lld\\n\",kpow(k,m));\n\t\treturn 0;\n\t}\n\tif(n==2) {\n\t\tll ans=0;\n\t\trep(i,1,min(m,k)+1)ans=add(ans,mul(dp[m][i],dp[m][i]));\n\t\tprintf(\"%lld\\n\",ans);\n\t\treturn 0;\n\t}\n\tint ans=0;\n\trep(i,1,min(m,k)+1)rep(j,1,i+1) {\n\t\tll Ans=mul(dp[m][i],dp[m][i]);\n\t\tAns=mul(mul(Ans,kpow(C(k,i),P-2)),mul(C(i,j),C(k-i,i-j)));\n\t\tAns=mul(Ans,kpow(j,mul(n-2,m)));\n\t\tans=add(ans,Ans);\n\t}\n\tprintf(\"%d\\n\",ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "498ac65aa82ef64afe476a2b45ba8eaf", "src_uid": "f22f28e2d8933f4199ba5ccfc0de8cda", "difficulty": 2300.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\n#define LL long long\n#define int long long\n#define fi first\n#define se second\n#define pll pair\n#define pii pair\n#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);\n\nconstexpr int N = 1e6+5;\nconstexpr int M = 1e9+7;\n\n// #define DEBUG 1 //\u8c03\u8bd5\u5f00\u5173\nstruct IO {\n#define MAXSIZE (1 << 20)\n#define isdigit(x) (x >= '0' && x <= '9')\n char buf[MAXSIZE], *p1, *p2;\n char pbuf[MAXSIZE], *pp;\n\n IO() : p1(buf), p2(buf), pp(pbuf) {}\n ~IO() { fwrite(pbuf, 1, pp - pbuf, stdout); }\n\n inline char gc() {\n if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin);\n return p1 == p2 ? ' ' : *p1++;\n }\n inline bool blank(char ch) {\n return ch == ' ' || ch == '\\n' || ch == '\\r' || ch == '\\t';\n }\n template \n inline void read(T &x) {\n double tmp = 1;\n bool sign = 0;\n x = 0;\n char ch = gc();\n for (; !isdigit(ch); ch = gc())\n if (ch == '-') sign = 1;\n for (; isdigit(ch); ch = gc()) x = x * 10 + (ch - '0');\n if (ch == '.')\n for (ch = gc(); isdigit(ch); ch = gc())\n tmp /= 10.0, x += tmp * (ch - '0');\n if (sign) x = -x;\n }\n inline void read(char *s) {\n char ch = gc();\n for (; blank(ch); ch = gc())\n ;\n for (; !blank(ch); ch = gc()) *s++ = ch;\n *s = 0;\n }\n inline void read(char &c) {\n for (c = gc(); blank(c); c = gc())\n ;\n }\n inline void push(const char &c) {\n #if DEBUG //\u8c03\u8bd5\uff0c\u53ef\u663e\u793a\u5b57\u7b26\n putchar(c);\n #else\n if (pp - pbuf == MAXSIZE) fwrite(pbuf, 1, MAXSIZE, stdout), pp = pbuf;\n *pp++ = c;\n #endif\n }\n template \n inline void write(T x) {\n if (x < 0) x = -x, push('-'); // \u8d1f\u6570\u8f93\u51fa\n static T sta[35];\n T top = 0;\n do {\n sta[top++] = x % 10, x /= 10;\n } while (x);\n while (top) push(sta[--top] + '0');\n }\n template \n inline void write(T x, char lastChar) {\n write(x), push(lastChar);\n }\n} io;\n\nint n, m, k;\nint fact[N];\n\nint kpow(int a, int b) {\n int c = 1;\n while (b) {\n if (b & 1) c = c * a % M;\n a = a * a % M;\n b >>= 1;\n }\n return c;\n}\n\nvoid init() {\n fact[0] = 1;\n for (int i = 1; i < N; i++) {\n fact[i] = fact[i-1] * i % M;\n }\n}\n\ninline int inv(int x) {\n return kpow(x, M-2);\n}\n\ninline int C(int n, int m) {\n return fact[n] * inv(fact[n-m] * fact[m] % M) % M;\n}\n\nint dp[N][N];\nint ans;\n \nsigned main() {\n fastio;\n init();\n io.read(n), io.read(m), io.read(k);\n if (m == 1) {\n io.write(kpow(k, n), '\\n');\n return 0;\n }\n dp[0][0] = 1;\n for (int i = 1; i <= n; i++) {\n for (int j = 1; j <= n; j++) {\n dp[i][j] = (j * dp[i-1][j] % M + dp[i-1][j-1]) % M;\n }\n }\n //io.write(dp[2][2], '\\n');\n if (m == 2) {\n for (int j = 1; j <= k && j <= n; j++) {\n ans += C(k, j) * C(k, j) % M * (dp[n][j] * fact[j] % M * dp[n][j] % M * fact[j] % M) % M;\n ans %= M;\n }\n io.write(ans, '\\n');\n return 0;\n }\n for (int j = 1; j <= k && j <= n; j++) {\n for (int i = 1; i <= j; i++) {\n int side = dp[n][j] % M * fact[j] % M;\n ans += C(k, i) * C(k-i, (j-i)*2) % M * C((j-i)*2, j-i) % M * (side * side % M * kpow(i, n * (m-2)) % M) % M; \n ans %= M;\n }\n }\n io.write(ans, '\\n');\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "54341837cb3758d7b082a3ab337a5967", "src_uid": "f22f28e2d8933f4199ba5ccfc0de8cda", "difficulty": 2300.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize(\"Ofast,no-stack-protector,fast-math\")\n#pragma GCC target(\"sse,sse1,sse2,sse3,sse4,sse4.1,sse4.2,avx,avx2,popcnt,abm,mmx,tune=native\")\n#include \nusing namespace std;\n\nconst int MAXMEM = 5e8;\nchar mem[MAXMEM];\nint ptr = 0;\nvoid* operator new( size_t sz ) {\n\tptr += sz;\n\tif (ptr + sz > MAXMEM) {\n\t\tcout << \"asfgasfgasfga\";\n\t\texit(0);\n\t}\n\treturn mem + ptr - sz;\n}\nvoid operator delete( void* ) {}\n#define int long long\nconst int MAXN = 1e5 + 7;\nint d[MAXN], w[MAXN];\nvector g[MAXN];\nint n, m, k;\nmap* dfs(int v) {\n\tvector*> a;\n\tfor (int u : g[v]) \n\t\ta.push_back(dfs(u));\n\tsort(a.begin(), a.end(), [](map* a, map* b) { return a->size() < b->size(); });\n\tif (a.size() == 0) {\n\t\tauto ans = new map;\n\t\tif (d[v] != -1) \n\t\t\t(*ans)[d[v]] += w[v];\n\t\treturn ans;\n\t}\n\tauto ans = a[0];\n\ta.erase(a.begin());\n\tfor (auto mp : a)\n\t\tfor (pair dx : *mp)\n\t\t\t(*ans)[dx.first] += dx.second;\n\tint s = 0;\n\tif (d[v] != -1) {\n\t\t(*ans)[d[v]] += w[v];\n\t\tauto it = ans->upper_bound(d[v]);\n\t\twhile (it != ans->end() && s < w[v]) {\n\t\t\tauto curr = it;\n\t\t\t++it;\n\t\t\tint d = curr->second;\n\t\t\tif (s + d >= w[v]) \n\t\t\t\t(*ans)[curr->first] = s + d - w[v];\n\t\t\telse \n\t\t\t\tans->erase(curr);\n\t\t\ts += d;\n\t\t}\n\t}\n\treturn ans;\n}\nsigned main() {\n\tios_base::sync_with_stdio(false);\n\n\tcin >> n >> m >> k;\n\t++k;\n\tfor (int i = 1; i < n; ++i) {\n\t\tint p;\n\t\tcin >> p;\n\t\t--p;\n\t\tg[p].push_back(i);\n\t}\n\tfill(d, d + n, -1);\n\tfor (int i = 0; i < m; ++i) {\n\t\tint v;\n\t\tcin >> v;\n\t\t--v;\n\t\tcin >> d[v] >> w[v];\n\t}\n\tauto ansv = dfs(0);\n\tint ans = 0;\n\tfor (auto p : *ansv)\n\t\tans += p.second;\n\tcout << ans;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "87fbfadcc1fe397aaba89422983fde15", "src_uid": "d471aeb3d5b496b4d7a5cd2628574853", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\n//macros\ntypedef long long ll;\ntypedef pair ii;\ntypedef tuple iii;\ntypedef vector vi;\ntypedef vector vii;\ntypedef vector viii;\ntypedef vector vll;\n#define REP(a,b,c) for(int a=int(b); a=int(b); a--)\n#define INF 1e9\n#define pb push_back\n#define fi first\n#define se second\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n\n//===================//\n// Added libraries //\n//===================//\n\n//===================//\n//end added libraries//\n//===================//\n\nvoid program();\nint main() {\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tcout.tie(NULL);\n\tprogram();\n}\n\n\n//===================//\n// begin program //\n//===================//\n\nconst int MX = 2e5;\nint n, m, k, p[MX], v[MX], d[MX], w[MX], V[MX], D[MX], W[MX];\nll dp[MX][20];\nvi chl[MX];\n\nll getAns(int u, int mx) {\n\tif(dp[u][mx] == -1) {\n\t\tll ans=0;\n\t\tif(d[u] <= mx) {\n\t\t\tans += w[u];\n\t\t\tfor(int v:chl[u]) ans += getAns(v, d[u]);\n\t\t}\n\t\tll cAns=0;\n\t\tfor(int v:chl[u]) cAns += getAns(v, mx);\n\t\tans = max(ans, cAns);\n\t\tdp[u][mx] = ans;\n\t}\n\treturn dp[u][mx];\n}\n\nvoid program2();\nvoid program3();\nvoid program() {\n\tcin>>n>>m>>k;\n\tREP(i,1,n) cin>>p[i], p[i]--;\n\tRE(i,m) {\n\t\tcin>>V[i]>>D[i]>>W[i]; D[i]--; V[i]--;\n\t\td[V[i]] = D[i];\n\t\tw[V[i]] = W[i];\n\t}\n\tbool subt3=1;\n\tREP(i,1,n) if(p[i] != i-1) subt3=0;\n\tif(subt3) {\n\t\tprogram3();\n\t\treturn;\n\t}\n\tif(k > 20) {\n\t\tprogram2();\n\t\treturn;\n\t}\n\n\tREP(i,1,n) chl[p[i]].pb(i);\n\tRE(i,n) RE(j,k) dp[i][j] = -1;\n\tcout< r) return;\n\tif(l == r) {\n\t\tSEG[p] = max(SEG[p], x);\n\t\treturn;\n\t}\n\tint m=(l+r)/2;\n\tsetSeg(i,x,p*2+1,l,m);\n\tsetSeg(i,x,p*2+2,m+1,r);\n\tSEG[p] = max(SEG[p*2+1], SEG[p*2+2]);\n}\nll getMax(int i, int j, int p=0, int l=0, int r=k-1) {\n\tif(j < l || i > r) return 0;\n\tif(i <= l && j >= r) return SEG[p];\n\tint m=(l+r)/2;\n\tll a=getMax(i,j,p*2+1,l,m);\n\tll b=getMax(i,j,p*2+2,m+1,r);\n\treturn max(a,b);\n}\n\nvoid program3() {\n\tRE(i,m) SA[i] = i;\n\tsort(SA, SA+m, [](int i, int j) {return V[i]>V[j];});\n\tRE(i,k*4) SEG[i]=0;\n\tll mx=0;\n\tRE(i,m) {\n\t\tll ans=getMax(0,D[SA[i]])+W[SA[i]];\n\t\tsetSeg(D[SA[i]], ans);\n\t\tmx=max(mx,ans);\n\t}\n\tcout<\n#define File(_) freopen(#_ \".in\", \"r\", stdin), freopen(#_ \".out\", \"w\", stdout)\n#define ALL(x) x.begin(), x.end()\n#define mset(a, b) memset(a, b, sizeof a)\n#define rep(i, a, b) for(int i(a), i##_END_(b); i <= i##_END_; i++) \n#define drep(i, a, b) for(int i(a), i##_END_(b); i >= i##_END_; i--)\nusing namespace std;\ntemplate inline bool tomax(T &a, T b) {return a < b ? a = b, 1 : 0;}\ntemplate inline bool tomin(T &a, T b) {return b < a ? a = b, 1 : 0;}\ntypedef long long ll;\ntypedef double db;\n\nconst int N = 1e5 + 5;\n\ntemplate struct Link {\n#define erep(k, G, o) for(int k(G.HEAD[o]); k; k = G.NXT[k])\n int HEAD[N], NXT[M], tot; T W[M];\n void add(int x, T w) {NXT[++tot] = HEAD[x]; W[HEAD[x] = tot] = w;}\n T& operator[] (int x) {return W[x];}\n};\nLink G;\n\nint p[N], v[N], d[N], w[N], id[N], n, m, k;\n\nconst int NLogN = N * 40;\nll mx[NLogN];\nint ls[NLogN], rs[NLogN], tot;\n#define mid (L + R >> 1)\n#define lson ls[o], L, mid\n#define rson rs[o], mid + 1, R\nvoid upd(int x, int d, int &o, int L, int R) {\n if(!o) o = ++tot;\n tomax(mx[o], d);\n if(L == R) return;\n if(x <= mid) upd(x, d, lson);\n else upd(x, d, rson);\n}\nll qry(int l, int r, int o, int L, int R) {\n if(!o) return 0;\n if(l == L && r == R) return mx[o];\n if(r <= mid) return qry(l, r, lson);\n else if(l > mid) return qry(l, r, rson);\n else return max(qry(l, mid, lson), qry(mid + 1, r, rson));\n}\nvoid merge(int &u, int v) {\n if(!u || !v) {u |= v; return;}\n mx[u] += mx[v];\n merge(ls[u], ls[v]);\n merge(rs[u], rs[v]);\n}\n\nint dfs(int o) {\n int rt = 0, x;\n erep(k, G, o) {\n int v = G[k];\n merge(rt, dfs(v));\n }\n if(x = id[o]) {\n ll tmp = qry(1, x, rt, 1, k);\n upd(x, tmp + d[x], rt, 1, k);\n }\n return rt;\n}\n\nint main() {\n // freopen(\"data.in\", \"r\", stdin);\n scanf(\"%d%d%d\", &n, &m, &k);\n rep(i, 2, n) {\n scanf(\"%d\", &p[i]);\n G.add(p[i], i);\n }\n rep(i, 1, m) scanf(\"%d%d%d\", &v[i], &d[i], &w[i]);\n rep(i, 1, m) id[v[i]] = i;\n int rt = dfs(1);\n printf(\"%I64d\\n\", qry(1, k, rt, 1, k));\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "90a258ffb80c34112100babb08c712fa", "src_uid": "d471aeb3d5b496b4d7a5cd2628574853", "difficulty": null} {"lang": "GNU C++14", "source_code": "#include \n\n#define long long long\n#define pii pair\n#define x first\n#define y second\n\nusing namespace std;\n\nconst int N = 1e5+5;\n\nint n, m, k;\nint day[N], cost[N];\nvector g[N];\n\nint in[N], out[N], pos[N], hv[N];\n\nint pre_process(int u) {\n static int idx = 0;\n pos[in[u] = ++idx] = u;\n int sz = 1; pii ret(0, -1);\n for(int v : g[u]) {\n int z = pre_process(v);\n sz += z, ret = max(ret, pii(z, v));\n }\n hv[u] = ret.y, out[u] = idx;\n return sz;\n}\n\nlong dp[N], mx;\nmap mp;\n\nvoid sack(int u, bool fill) {\n for(int v : g[u]) if(v != hv[u]) sack(v, 0), dp[u] += dp[v];\n if(hv[u] != -1) sack(hv[u], 1), dp[u] += dp[hv[u]];\n\n if(u == 1) continue;\n if(day[u] != 0) {\n mp[day[u]] += cost[u];\n mx = max(mx, mp[day[u]]);\n }\n for(int v : g[u]) if(v != hv[u]) for(int i = in[v]; i <= out[v]; i++) {\n int now = pos[i];\n if(day[now] == 0) continue;\n mp[day[now]] += cost[now];\n mx = max(mx, mp[day[now]]);\n }\n dp[u] = max(dp[u], mx);\n if(!fill) mx = 0, mp.clear();\n}\n\nint main() {\n scanf(\"%d %d %d\", &n, &m, &k);\n for(int i = 2, a; i <= n; i++) {\n scanf(\"%d\", &a);\n g[a].emplace_back(i);\n }\n for(int i = 1, a, b, c; i <= m; i++) {\n scanf(\"%d %d %d\", &a, &b, &c);\n day[a] = b, cost[a] = c;\n }\n pre_process(1), sack(1, 1);\n printf(\"%lld\\n\", dp[1]);\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4d2598038f9e1070778a37c39c6f64ef", "src_uid": "d471aeb3d5b496b4d7a5cd2628574853", "difficulty": null} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nconst long double EPS = 1E-8;\n\nclass Point {\npublic:\n\tlong double x, y;\n\n\tPoint() {}\n\n\tPoint(long double x, long double y) : x(x), y(y) {}\n\n\tinline long double length() const {\n\t\treturn hypot(x, y);\n\t}\n\n\tinline Point operator + (const Point & other) const {\n\t\treturn Point(x + other.x, y + other.y);\n\t}\n\n\tinline Point operator - (const Point & other) const {\n\t\treturn Point(x - other.x, y - other.y);\n\t}\n\n\tinline long double operator * (const Point & other) const {\n\t\treturn x * other.y - y * other.x;\n\t}\n\n\tinline Point operator * (const long double scale) {\n\t\treturn Point(x * scale, y * scale);\n\t}\n};\n\nclass Lattice {\npublic:\n\tlong long x, y;\n\n\tLattice() {}\n\n\tLattice(long long x, long long y) : x(x), y(y) {}\n\n\tinline void init() {\n\t\tscanf(\"%lld%lld\", &x, &y);\n\t}\n\n\tinline long long length2() const {\n\t\treturn x * x + y * y;\n\t}\n\n\tinline Lattice operator + (const Lattice & other) const {\n\t\treturn Lattice(x + other.x, y + other.y);\n\t}\n\n\tinline Lattice operator - (const Lattice & other) const {\n\t\treturn Lattice(x - other.x, y - other.y);\n\t}\n\n\tinline Lattice operator * (const long long scale) const {\n\t\treturn Lattice(x * scale, y * scale);\n\t}\n\n\tinline long long operator * (const Lattice & other) const {\n\t\treturn x * other.y - y * other.x;\n\t}\n\n\tinline long long operator ^ (const Lattice & other) const {\n\t\treturn x * other.x + y * other.y;\n\t}\n};\n\ninline bool isOnlineIn(const Lattice & p, const Lattice & l1, const Lattice & l2) {\n\treturn !((l1 - l2) * (p - l2)) && (l1.x - p.x) * (l2.x - p.x) <= 0 && (l1.y - p.y) * (l2.y - p.y) <= 0;\n}\n\ninline bool isOnRayIn(const Lattice & p, const Lattice & l1, const Lattice & l2) {\n\treturn isOnlineIn(p, l1, l2) || isOnlineIn(l2, l1, p);\n}\n\ninline bool parallel(const Lattice & u1, const Lattice & u2, const Lattice & v1, const Lattice & v2) {\n\treturn !((u2 - u1) * (v2 - v1));\n}\n\ninline int sgn(long long x) {\n\tif (!x) return 0;\n\treturn x < 0 ? -1 : 1;\n}\n\ninline int decideSide(const Lattice & p1, const Lattice & p2, const Lattice & l1, const Lattice & l2) {\n\treturn sgn((l1 - l2) * (p1 - l2)) * sgn((l1 - l2) * (p2 - l2));\n}\n\ninline bool isBetween(const Lattice & p, const Lattice & A, const Lattice & P, const Lattice & Q) {\n\treturn decideSide(p, Q, A, P) >= 0 && decideSide(p, P, A, Q) >= 0;\n}\n\ninline bool crossLineSeg(const Lattice & u1, const Lattice & u2, const Lattice & v1, const Lattice & v2) {\n\tif (parallel(u1, u2, v1, v2) || decideSide(v1, v2, u1, u2) > 0) return false;\n\tif (decideSide(u1, u2, v1, v2) <= 0) return true;\n\treturn llabs((u1 - v2) * (v1 - v2)) > llabs((u2 - v2) * (v1 - v2));\n}\n\ninline Point intersection(const Point & u1, const Point & u2, const Point & v1, const Point & v2) {\n\treturn u1 + (u2 - u1) * (((u1 - v1) * (v1 - v2)) / ((u1 - u2) * (v1 - v2)));\n}\n\ninline bool zero(long double x) {\n\treturn -EPS < x && x < EPS;\n}\n\nconst int MAXN = 10010 + 1;\n\nint n;\nLattice lattice[MAXN], A, V, U, P, Q;\nPoint point[MAXN], a, v, u, p, q;\nlong long Fdown, Vz, Uz;\nlong double t1, t2;\nbool opposite;\n\ninline void update1(const Point & qq, bool positive) {\n\tlong double len = (a - qq).length();\n\tif (!positive) len = -len;\n\tint sgn = opposite ? -1 : 1;\n\tlong double t = len / (v.length() + sgn * u.length() * Vz / Uz);\n\tif (t > 0) t1 = min(t1, t);\n}\n\ninline void update2(const Point & qq) {\n\tPoint pp0 = qq + u, pp = intersection(pp0, qq, a, p);\n\tlong double tt1 = (pp - a).length() / v.length(), tt2 = max(tt1 * Vz - (pp - qq).length() / u.length() * Uz, (long double)0) / Fdown;\n\tif (tt1 < t1 - EPS || (zero(tt1 - t1) && tt2 < t2 - EPS)) {\n\t\tt1 = tt1;\n\t\tt2 = tt2;\n\t}\n}\n\nint main() {\n\tscanf(\"%d\", &n);\n\tfor (int i = 0; i < n; i++) {\n\t\tlattice[i].init();\n\t\tpoint[i] = Point((long double)lattice[i].x, (long double)lattice[i].y);\n\t}\n\tlattice[n] = lattice[0];\n\tpoint[n] = point[0];\n\tA.init();\n\ta = Point((long double)A.x, (long double)A.y);\n\tV.init();\n\tv = Point((long double)V.x, (long double)V.y);\n\tscanf(\"%lld%lld\", &Vz, &Fdown);\n\tFdown = -Fdown;\n\tU.init();\n\tu = Point((long double)U.x, (long double)U.y);\n\tscanf(\"%lld\", &Uz);\n\tUz = -Uz;\n\tif (!V.length2() && !U.length2()) {\n\t\tputs(\"-1.000000000000000 -1.000000000000000\");\n\t\treturn 0;\n\t}\n\tt1 = t2 = 1E100;\n\tif (!(V * U)) {\n\t\topposite = ((V ^ U) < 0);\n\t\tif (opposite) {\n\t\t\tP = A + V;\n\t\t\tp = a + v;\n\t\t\tQ = A + U;\n\t\t\tq = a + u;\n\t\t\tif ((V * Uz).length2() == (U * Vz).length2()) {\n\t\t\t\tputs(\"-1.000000000000000 -1.000000000000000\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t} else {\n\t\t\tif (V.length2() > 0) {\n\t\t\t\tP = A + V;\n\t\t\t\tp = a + v;\n\t\t\t} else {\n\t\t\t\tP = A + U;\n\t\t\t\tp = a + u;\n\t\t\t}\n\t\t}\n\t\tt2 = 0;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (!((lattice[i] - A) * (P - A))) continue;\n\t\t\tupdate1(point[i], isOnRayIn(lattice[i], A, P));\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (opposite) {\n\t\t\t\tif (crossLineSeg(A, P, lattice[i], lattice[i + 1])) {\n\t\t\t\t\tPoint pp = intersection(a, p, point[i], point[i + 1]);\n\t\t\t\t\tupdate1(pp, true);\n\t\t\t\t} else if (crossLineSeg(A, Q, lattice[i], lattice[i + 1])) {\n\t\t\t\t\tPoint qq = intersection(a, q, point[i], point[i + 1]);\n\t\t\t\t\tupdate1(qq, false);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (crossLineSeg(A, P, lattice[i], lattice[i + 1])) {\n\t\t\t\t\tPoint pp = intersection(a, p, point[i], point[i + 1]);\n\t\t\t\t\tupdate1(pp, true);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tP = A + V * Uz;\n\t\tp = a + v;\n\t\tQ = P + U * Vz;\n\t\tq = p + u * ((long double)Vz / Uz);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (isBetween(lattice[i], A, P, Q)) update2(Point((long double)lattice[i].x, (long double)lattice[i].y));\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (crossLineSeg(A, P, lattice[i], lattice[i + 1])) {\n\t\t\t\tPoint pp = intersection(a, p, point[i], point[i + 1]);\n\t\t\t\tupdate2(pp);\n\t\t\t}\n\t\t\tif (crossLineSeg(A, Q, lattice[i], lattice[i + 1])) {\n\t\t\t\tPoint qq = intersection(a, q, point[i], point[i + 1]);\n\t\t\t\tupdate2(qq);\n\t\t\t}\n\t\t}\n\t}\n\tif (t1 > 1E90) t1 = t2 = -1;\n\tprintf(\"%.15Lf %.15Lf\\n\", t1, t2);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0b54eec2353ac616d4c64af1b42fb052", "src_uid": "d6afa6a515fc0adde11891e81cb179d7", "difficulty": 2800.0} {"lang": "MS C++", "source_code": "#pragma comment(linker, \"/STACK:136777216\")\n\n#include \n#include \n#include\n#include \n#include \n#include\n#include \n#include \n#include \n#include \n#include\n#include \n#include \n#include\n#include\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef vector vi;\ntypedef pair pii;\ntypedef pair pdd;\ntypedef pair p3i;\ntypedef long double ld;\ntypedef vector vd;\n\n#define FOR(i,a,b) for (int i(a); i < (b); i++) \n#define REP(i,n) FOR(i,0,n) \n#define UN(v) sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())\n#define CL(a,b) memset(a,b,sizeof(a))\n#define pb push_back\n#define SORT(a) sort((a).begin(),(a).end())\n\nint n;\nint x[11111];\nint y[11111];\nint xa,ya;\nint xv,yv,zv;\nint f;\nint xu,yu,zu;\n\nll a[2][3];\nll det(ll a11,ll a12,ll a21, ll a22){\n return a11*a22-a12*a21;\n}\n\ndouble b[2][3];\ndouble det2(double a11,double a12,double a21,double a22){\n return a11*a22-a12*a21;\n}\n\ndouble r_t1=-1,r_t2=-1;\n\nconst double eps = 1e-9;\n\nint main(){ \n#ifdef LocalHost\n freopen(\"input.txt\",\"r\",stdin);\n#endif\n cin>>n;\n REP(i,n) scanf(\"%d %d\",x+i,y+i);\n x[n]=x[0],y[n]=y[0];\n scanf(\"%d %d\",&xa,&ya);\n scanf(\"%d %d %d\",&xv,&yv,&zv);\n scanf(\"%d\",&f);\n scanf(\"%d %d %d\",&xu,&yu,&zu);\n \n REP(i,n){\n a[0][0]=xv;\n a[0][1]=-(x[i+1]-x[i]);\n a[0][2]=x[i]-xa;\n a[1][0]=yv;\n a[1][1]=-(y[i+1]-y[i]);\n a[1][2]=y[i]-ya;\n\n ll d = det(a[0][0],a[0][1],a[1][0],a[1][1]);\n if(d){\n ll T1 = det(a[0][2],a[0][1],a[1][2],a[1][1]);\n double t = double(T1)/d;\n ll T2 = det(a[0][0],a[0][2],a[1][0],a[1][2]);\n double t2 = double(T2)/d;\n if(t2>=-eps && t2<=1+eps)\n\tif(t>0 && (r_t1 < -0.5 || r_t1 > t)){\n\t r_t1=t;\n\t r_t2 = t * zv/(-f);\n\t}\n }\n }\n\n REP(i,n){\n double t = hypot(x[i]-xa,y[i]-ya)/hypot(xv,yv);\n double xx = xa + xv*t;\n double yy = ya + yv*t;\n if(fabs(xx-x[i]) t + eps || fabs(r_t1-t) t2){\n\tr_t1=t;\n\tr_t2=t2;\n }\n }\n }\n\n if(zu<0)\n REP(i,n){\n a[0][0]=xv;\n a[0][1]=-xu;\n a[0][2]=x[i]-xa;\n a[1][0]=yv;\n a[1][1]=-yu;\n a[1][2]=y[i]-ya;\n\n ll d = det(a[0][0],a[0][1],a[1][0],a[1][1]);\n if(d){\n\tll T1 = det(a[0][2],a[0][1],a[1][2],a[1][1]);\n\tdouble t1 = double(T1)/d;\n \n\tll T2 = det(a[0][0],a[0][2],a[1][0],a[1][2]);\n\tdouble t2 = double(T2)/d;\n\n\tt2=-t2;\n\n\tif(t1>0 && t2>=-1e-8){\n\t double t3 = (t1*zv + t2*zu)/(-f);\n\t if(t3>=-1e-8){\n\t if(r_t1<-0.5 || r_t1 > t1 + eps || fabs(r_t1-t1) t3 + eps){\n\t r_t1 = t1;\n\t r_t2 = t3;\n\t }\n\t } \n\t}\n }\n }\n if(zu<0 && det(xv,-xu,yv,-yu)==0){\n REP(i,n){\n double X = xv + xu * double(zv)/double(-zu);\n double Y = yv + yu * double(zv)/double(-zu);\n\n double t = hypot(x[i]-xa,y[i]-ya)/hypot(X,Y);\n double xx = xa + X*t;\n double yy = ya + Y*t;\n if(fabs(xx-x[i]) t + eps || fabs(r_t1-t) t2){\n\t r_t1=t;\n\t r_t2=t2;\n\t}\n }\n\n }\n }\n if(zu<0){\n REP(i,n){\n double X = xv + xu * double(zv)/double(-zu);\n double Y = yv + yu * double(zv)/double(-zu);\n\n b[0][0]=X;\n b[0][1]=-(x[i+1]-x[i]);\n b[0][2]=x[i]-xa;\n b[1][0]=Y;\n b[1][1]=-(y[i+1]-y[i]);\n b[1][2]=y[i]-ya;\n\n double d = det2(b[0][0],b[0][1],b[1][0],b[1][1]);\n if(fabs(d)>eps){\n\tll T1 = det2(b[0][2],b[0][1],b[1][2],b[1][1]);\n\tdouble t = double(T1)/d;\n\tll T2 = det2(b[0][0],b[0][2],b[1][0],b[1][2]);\n\tdouble t2 = double(T2)/d;\n\tif(t2>=-eps && t2<=1+eps)\n\t if(t>0 && (r_t1 < -0.5 || r_t1 > t)){\n\t r_t1=t;\n\t r_t2=0;\n\t }\n }\n\n }\n \n printf(\"%.9lf %.9lf\\n\",r_t1,r_t2);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "84483841166c4e3d37f5cd98e245261f", "src_uid": "d6afa6a515fc0adde11891e81cb179d7", "difficulty": 2800.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nconst long double EPS = 1E-8;\n\nclass Point {\npublic:\n\tlong double x, y;\n\n\tPoint() {}\n\n\tPoint(long double x, long double y) : x(x), y(y) {}\n\n\tinline long double length() const {\n\t\treturn hypot(x, y);\n\t}\n\n\tinline Point operator + (const Point & other) const {\n\t\treturn Point(x + other.x, y + other.y);\n\t}\n\n\tinline Point operator - (const Point & other) const {\n\t\treturn Point(x - other.x, y - other.y);\n\t}\n\n\tinline long double operator * (const Point & other) const {\n\t\treturn x * other.y - y * other.x;\n\t}\n\n\tinline Point operator * (const long double scale) {\n\t\treturn Point(x * scale, y * scale);\n\t}\n};\n\nclass Lattice {\npublic:\n\tlong long x, y;\n\n\tLattice() {}\n\n\tLattice(long long x, long long y) : x(x), y(y) {}\n\n\tinline void init() {\n\t\tscanf(\"%lld%lld\", &x, &y);\n\t}\n\n\tinline long long length2() const {\n\t\treturn x * x + y * y;\n\t}\n\n\tinline Lattice operator + (const Lattice & other) const {\n\t\treturn Lattice(x + other.x, y + other.y);\n\t}\n\n\tinline Lattice operator - (const Lattice & other) const {\n\t\treturn Lattice(x - other.x, y - other.y);\n\t}\n\n\tinline Lattice operator * (const long long scale) const {\n\t\treturn Lattice(x * scale, y * scale);\n\t}\n\n\tinline long long operator * (const Lattice & other) const {\n\t\treturn x * other.y - y * other.x;\n\t}\n\n\tinline long long operator ^ (const Lattice & other) const {\n\t\treturn x * other.x + y * other.y;\n\t}\n};\n\ninline bool isOnlineIn(const Lattice & p, const Lattice & l1, const Lattice & l2) {\n\treturn !((l1 - l2) * (p - l2)) && (l1.x - p.x) * (l2.x - p.x) <= 0 && (l1.y - p.y) * (l2.y - p.y) <= 0;\n}\n\ninline bool isOnRayIn(const Lattice & p, const Lattice & l1, const Lattice & l2) {\n\treturn isOnlineIn(p, l1, l2) || isOnlineIn(l2, l1, p);\n}\n\ninline bool parallel(const Lattice & u1, const Lattice & u2, const Lattice & v1, const Lattice & v2) {\n\treturn !((u2 - u1) * (v2 - v1));\n}\n\ninline int sgn(long long x) {\n\tif (!x) return 0;\n\treturn x < 0 ? -1 : 1;\n}\n\ninline int decideSide(const Lattice & p1, const Lattice & p2, const Lattice & l1, const Lattice & l2) {\n\treturn sgn((l1 - l2) * (p1 - l2)) * sgn((l1 - l2) * (p2 - l2));\n}\n\ninline bool isBetween(const Lattice & p, const Lattice & A, const Lattice & P, const Lattice & Q) {\n\treturn decideSide(p, Q, A, P) >= 0 && decideSide(p, P, A, Q) >= 0;\n}\n\ninline long long abs(long long x) {\n\treturn x < 0 ? -x : x;\n}\n\ninline bool crossLineSeg(const Lattice & u1, const Lattice & u2, const Lattice & v1, const Lattice & v2) {\n\tif (parallel(u1, u2, v1, v2) || decideSide(v1, v2, u1, u2) > 0) return false;\n\tif (decideSide(u1, u2, v1, v2) <= 0) return true;\n\treturn abs((u1 - v2) * (v1 - v2)) > abs((u2 - v2) * (v1 - v2));\n}\n\ninline Point intersection(const Point & u1, const Point & u2, const Point & v1, const Point & v2) {\n\treturn u1 + (u2 - u1) * (((u1 - v1) * (v1 - v2)) / ((u1 - u2) * (v1 - v2)));\n}\n\ninline bool zero(long double x) {\n\treturn -EPS < x && x < EPS;\n}\n\nconst int MAXN = 10010 + 1;\n\nint n;\nLattice lattice[MAXN], A, V, U, P, Q;\nPoint point[MAXN], a, v, u, p, q;\nlong long Fdown, Vz, Uz;\nlong double t1, t2;\nbool opposite;\n\ninline void update1(const Point & qq, bool positive) {\n\tif (positive && opposite) {\n\t\tlong double tt1 = (a - qq).length() / v.length(), tt2 = tt1 * Vz / Fdown;\n\t\tif (tt1 < t1 - EPS || (zero(tt1 - t1) && tt2 < t2 - EPS)) {\n\t\t\tt1 = tt1;\n\t\t\tt2 = tt2;\n\t\t}\n\t\treturn ;\n\t}\n\tlong double len = (a - qq).length();\n\tif (!positive) len = -len;\n\tint sgn = opposite ? -1 : 1;\n\tlong double t = len / (v.length() + sgn * u.length() * Vz / Uz);\n\tif (t < EPS) return ;\n\tif (t < t1 + EPS) {\n\t\tt1 = min(t1, t);\n\t\tt2 = 0;\n\t}\n}\n\ninline void update2(const Point & qq) {\n\tPoint pp0 = qq + u, pp = intersection(pp0, qq, a, p);\n\tlong double tt1 = (pp - a).length() / v.length(), tt2 = max(tt1 * Vz - (pp - qq).length() / u.length() * Uz, (long double)0) / Fdown;\n\tif (tt1 < t1 - EPS || (zero(tt1 - t1) && tt2 < t2 - EPS)) {\n\t\tt1 = tt1;\n\t\tt2 = tt2;\n\t}\n}\n\nint main() {\n\tscanf(\"%d\", &n);\n\tfor (int i = 0; i < n; i++) {\n\t\tlattice[i].init();\n\t\tpoint[i] = Point((long double)lattice[i].x, (long double)lattice[i].y);\n\t}\n\tlattice[n] = lattice[0];\n\tpoint[n] = point[0];\n\tA.init();\n\ta = Point((long double)A.x, (long double)A.y);\n\tV.init();\n\tv = Point((long double)V.x, (long double)V.y);\n\tscanf(\"%lld%lld\", &Vz, &Fdown);\n\tFdown = -Fdown;\n\tU.init();\n\tu = Point((long double)U.x, (long double)U.y);\n\tscanf(\"%lld\", &Uz);\n\tUz = -Uz;\n\tif (!V.length2() && !U.length2()) {\n\t\tputs(\"-1.000000000000000 -1.000000000000000\");\n\t\treturn 0;\n\t}\n\tt1 = t2 = 1E100;\n\tif (!(V * U)) {\n\t\topposite = ((V ^ U) < 0);\n\t\tif (opposite) {\n\t\t\tP = A + V;\n\t\t\tp = a + v;\n\t\t\tQ = A + U;\n\t\t\tq = a + u;\n\t\t} else {\n\t\t\tif (V.length2() > 0) {\n\t\t\t\tP = A + V;\n\t\t\t\tp = a + v;\n\t\t\t} else {\n\t\t\t\tP = A + U;\n\t\t\t\tp = a + u;\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif ((lattice[i] - A) * (P - A)) continue;\n\t\t\tupdate1(point[i], isOnRayIn(lattice[i], A, P));\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (opposite) {\n\t\t\t\tif (crossLineSeg(A, P, lattice[i], lattice[i + 1])) {\n\t\t\t\t\tPoint pp = intersection(a, p, point[i], point[i + 1]);\n\t\t\t\t\tupdate1(pp, true);\n\t\t\t\t} else if (crossLineSeg(A, Q, lattice[i], lattice[i + 1])) {\n\t\t\t\t\tPoint qq = intersection(a, q, point[i], point[i + 1]);\n\t\t\t\t\tupdate1(qq, false);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (crossLineSeg(A, P, lattice[i], lattice[i + 1])) {\n\t\t\t\t\tPoint pp = intersection(a, p, point[i], point[i + 1]);\n\t\t\t\t\tupdate1(pp, true);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\tP = A + V * Uz;\n\t\tp = a + v;\n\t\tQ = P + U * Vz;\n\t\tq = p + u * ((long double)Vz / Uz);\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (isBetween(lattice[i], A, P, Q)) update2(Point((long double)lattice[i].x, (long double)lattice[i].y));\n\t\t}\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tif (crossLineSeg(A, P, lattice[i], lattice[i + 1])) {\n\t\t\t\tPoint pp = intersection(a, p, point[i], point[i + 1]);\n\t\t\t\tupdate2(pp);\n\t\t\t}\n\t\t\tif (crossLineSeg(A, Q, lattice[i], lattice[i + 1])) {\n\t\t\t\tPoint qq = intersection(a, q, point[i], point[i + 1]);\n\t\t\t\tupdate2(qq);\n\t\t\t}\n\t\t}\n\t}\n\tif (t1 > 1E90) puts(\"-1.000000000000000 -1.000000000000000\");\n\telse printf(\"%.15Lf %.15Lf\\n\", fabs(t1), fabs(t2));\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ea1620b46e7c77b06a9e12e2833386a8", "src_uid": "d6afa6a515fc0adde11891e81cb179d7", "difficulty": 2800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define mp make_pair\n#define pb push_back\n#define rep(i,n) for(int i = 0; i < n; i++)\n#define re return\n#define fi first\n#define se second\n#define sz(x) ((int) (x).size())\n#define all(x) (x).begin(), (x).end()\n#define sqr(x) ((x) * (x))\n#define y0 y3487465\n#define y1 y8687969\n\ntypedef vector vi;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair ii;\ntypedef vector vii;\ntypedef vector vs;\ntypedef vector vvi;\n\ntemplate T abs(T x) {\n\tre x > 0 ? x : -x;\n}\n\nconst int MAX = 300;\nconst ld eps = 1e-13;\nconst ld eps2 = 1e-11;\n\nint n;\nint m;\nint x1, y1, z1, x2, y2, z2, f, x[10001], y[10001];\n\nint vect (int x1, int y1, int x2, int y2) {\n\tre x1 * y2 - x2 * y1;\n}\n\nint scal (int x1, int y1, int x2, int y2) {\n\tre x1 * x2 + y1 * y2;\n}\n\nint _in (ld xx, ld yy) {\n\tld sum = 0, rl = 0;\n\tfor (int i = 0; i < n; i++) {\n\t\tsum += fabs ((x[i] - xx) * (y[i + 1] - yy) - (x[i + 1] - xx) * (y[i] - yy));\n\t\trl += x[i] * y[i + 1] - x[i + 1] * y[i];\n\t}\n\tif (fabs (sum - fabs (rl)) > 1e-10) re 0;\n\tre 1;\n}\n\nint cross (ld x1, ld y1, ld x2, ld y2, ld x3, ld y3, ld x4, ld y4, ld *t) {\n\tld a = x2 - x1;\n\tld b = x3 - x4;\n\tld c = x3 - x1;\n\tld d = y2 - y1;\n\tld e = y3 - y4;\n\tld f = y3 - y1;\n\tif (fabs (a * e - b * d) > eps) {\n\t\tld T = (c * e - b * f) / (a * e - b * d);\n\t\tld S = (a * f - c * d) / (a * e - b * d);\n//\t\tprintf (\"%.10f %.10f\\n\", T, S);\n\t\tif (T > -eps2 && T < 1 + eps2 && S > -eps2 && S < 1 + eps2) {\n\t\t\t*t = T;\n\t\t\tre 1;\n\t\t}\n\t}\n\tre 0;\n}\n\nint cross2 (ld x1, ld y1, ld x2, ld y2, ld x3, ld y3, ld x4, ld y4, ld *t) {\n\tld a = x2 - x1;\n\tld b = x3 - x4;\n\tld c = x3 - x1;\n\tld d = y2 - y1;\n\tld e = y3 - y4;\n\tld f = y3 - y1;\n\tif (fabs (a * e - b * d) > eps) {\n\t\tld T = (c * e - b * f) / (a * e - b * d);\n\t\tld S = (a * f - c * d) / (a * e - b * d);\n//\t\tprintf (\"%.10f %.10f\\n\", T, S);\n\t\tif (T > -eps2 && S > -eps2 && S < 1 + eps2) {\n\t\t\t*t = T;\n\t\t\tre 1;\n\t\t}\n\t}\n\tre 0;\n}\n\nint check (ld x1, ld y1, ld x2, ld y2, ld *t) {\n//\tprintf (\"%.15f %.15f %.15f %.15f\\n\", (double)x1, (double)y1, (double)x2, (double)y2);\n\tif (_in (x1, y1)) {\n\t\t*t = 0;\n\t\tre 1;\n\t}\n\tint ok = 0;\n\tfor (int i = 0; i < n; i++) {\n\t\tld nt;\n\t\tif (cross (x1, y1, x2, y2, x[i], y[i], x[i + 1], y[i + 1], &nt)) {\n//\t\t\tprintf (\"%d: %.10f\\n\", i, (double)nt);\n\t\t\tif (!ok) *t = nt; else *t = min (*t, nt);\n\t\t\tok = 1;\n\t\t}\n\t}\n\tre ok;\n}\n\nint check2 (ld x1, ld y1, ld x2, ld y2, ld *t) {\n//\tprintf (\"%.5f %.5f %.5f %.5f\\n\", x1, y1, x2, y2);\n\tif (_in (x1, y1)) {\n\t\t*t = 0;\n\t\tre 1;\n\t}\n\tint ok = 0;\n\tfor (int i = 0; i < n; i++) {\n\t\tld nt;\n\t\tif (cross2 (x1, y1, x2, y2, x[i], y[i], x[i + 1], y[i + 1], &nt)) {\n\t\t\tif (!ok) *t = nt; else *t = min (*t, nt);\n\t\t\tok = 1;\n//\t\t\tprintf (\"%d: %.10f\\n\", i, *t);\n\t\t}\n\t}\n//\tprintf (\"%d\\n\", ok);\n\tre ok;\n}\n\nint check3 (ld x1, ld y1, ld x2, ld y2, int i) {\n\tre int ((x[i] - x1) * (x[i] - x2) + (y[i] - y1) * (y[i] - y2) < eps);\n}\n\nint calc (int i, ld x1, ld y1, ld x2, ld y2) {\n\tld v = (x[i] - x1) * (y2 - y1) - (x2 - x1) * (y[i] - y1);\n\tre v > eps ? 1 : (v < -eps ? -1 : 0);\n}\n\nint main () {\n\tscanf (\"%d\", &n);\n\tfor (int i = 0; i < n; i++) scanf (\"%d%d\", &x[i], &y[i]);\n\tint X, Y;\n\tscanf (\"%d%d\", &X, &Y);\n\tfor (int i = 0; i < n; i++) { x[i] -= X; y[i] -= Y; }\n\tx[n] = x[0];\n\ty[n] = y[0];\n\tscanf (\"%d%d%d\", &x1, &y1, &z1);\n\tscanf (\"%d\", &f); f = -f;\n\tscanf (\"%d%d%d\", &x2, &y2, &z2); z2 = -z2;\n\tld x3 = x1 + x2 * ((ld)z1 / z2), y3 = y1 + y2 * ((ld)z1 / z2);\n\tld t1 = 1e20, t2 = 1e20, t, tt;\n\tif (check2 (0, 0, x1, y1, &t)) {\n\t\tcheck2 (x1 * t + x2 * ((z1 * t) / z2), y1 * t + y2 * ((z1 * t) / z2), x1 * t, y1 * t, &tt);\n\t\ttt *= ((z1 * t) / f);\n\t\tif (t1 > t + eps || fabs (t - t1) < eps && t2 > tt + eps) {\n\t\t\tt1 = t;\n\t\t\tt2 = tt;\n\t\t}\n\t}\n\tif (check2 (0, 0, x3, y3, &t)) {\n\t\tcheck2 (x1 * t + x2 * ((z1 * t) / z2), y1 * t + y2 * ((z1 * t) / z2), x1 * t, y1 * t, &tt);\n\t\ttt *= ((z1 * t) / f);\n\t\tif (t1 > t + eps || fabs (t - t1) < eps && t2 > tt + eps) {\n\t\t\tt1 = t;\n\t\t\tt2 = tt;\n\t\t}\n\t}\n\tif (vect (x1, y1, x2, y2) != 0) {\n\t\tld T = 1e20;\n\t\tfor (int i = 0; i < n; i++) {\n\t\t\tld l = 0, r = 1e20, t;\n\t\t\tint need = calc (i, x1 * r, y1 * r, x1 * r + x2 * ((z1 * r) / z2), y1 * r + y2 * ((z1 * r) / z2)), ok = 0;\n\t\t\tfor (int it = 0; it < MAX; it++) {\n\t\t\t\tld s = (l + r) / 2;\n\t\t\t\tint tmp = calc (i, x1 * s, y1 * s, x1 * s + x2 * ((z1 * s) / z2), y1 * s + y2 * ((z1 * s) / z2));\n\t\t\t\tif (tmp == need) r = s; else { ok = 1; l = s; }\n\t\t\t}\n\t\t\tif (r < T && check3 (x1 * r, y1 * r, x1 * r + x2 * ((z1 * r) / z2), y1 * r + y2 * ((z1 * r) / z2), &t)) T = r;\n\t\t}\n\t\tif (T < 5e19) {\n\t\t\tld t = T, tt;\n\t\t\tif (check (x1 * T + x2 * ((z1 * T) / z2), y1 * T + y2 * ((z1 * T) / z2), x1 * T, y1 * T, &tt)) {\n\t\t\t\ttt *= ((z1 * T) / f);\n\t\t\t\tif (t1 > t + eps || fabs (t - t1) < eps && t2 > tt + eps) {\n\t\t\t\t\tt1 = t;\n\t\t\t\t\tt2 = tt;\n\t\t\t\t}\n \t}\n\t\t}\n\t}\n\tif (t1 > 5e19) printf (\"-1 -1\\n\"); else printf (\"%.15f %.15f\\n\", (double)t1, (double)t2);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "378a7ad8928e0a8af202b605a0efc565", "src_uid": "d6afa6a515fc0adde11891e81cb179d7", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int maxn = 2e5 + 5;\n\ntypedef long long LL;\n\nconst LL mod = 998244353LL;\n\nLL qpow(LL a, LL n){\n LL ret = 1;\n while(n > 0){\n if(n & 1){\n ret = ret * a % mod;\n }\n a = a * a % mod;\n n >>= 1;\n }\n return ret;\n}\n\nLL inv(LL x){\n return qpow(x, mod - 2);\n}\n\nint a[maxn];\nLL w[maxn];\nint n, m;\nint main(){\n while(cin>>n>>m){\n for(int i=0;i> dp(m+1,vector(m+1));\n \tdp[0][0] = 1;\n \tfor(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define LL long long\n#define ULL unsigned long long\n#define rep(i, j, k) for(int i = j; i <= k; i++)\n#define dep(i, j, k) for(int i = k; i >= j; i--)\n#define INF 0x3f3f3f3f\n#define mem(i, j) memset(i, j, sizeof(i))\n#define make(i, j) make_pair(i, j)\n#define pb push_back\nusing namespace std;\nconst int N = 1e5 + 10, mod = 998244353, M = 3e3 + 10;\nint read()\n{\n\tsl = 0; fh = 1;\n\tchar ch = getchar();\n\twhile(ch < '0' || '9' < ch) {if(ch == '-') fh = -1; ch = getchar();}\n\twhile('0' <= ch && ch <= '9') sl = sl * 10 + ch-'0',ch = getchar();\n\treturn sl * fh;\n}\nint ksm(int x, int y) {\n int ans = 1;\n while(y) {\n if( y & 1 ) ans = (LL) ans * x % mod;\n x = (LL) x * x % mod;\n y >>= 1;\n }\n return ans;\n}\nint n, m, a[N], w[N], f[M][M], g[M][M], inv[M << 1], sum[3];\n///sum[0] : don't like ; sum[1]: like; sum[2]:all\nint main() {\n n = read(); m =read();\n //cout << n << \" \" << m <\n\nusing namespace std;\n\ntypedef int ll;\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n function power = [&](ll x, ll y) {\n if (y == 0) {\n return 1LL;\n } else {\n ll z = power(x, y / 2);\n return y % 2 == 0 ? (z * z) % 998244353 : ((z * z) % 998244353 * x) % 998244353;\n }\n };\n unordered_map divs;\n auto div = [&](ll x) {\n if (divs.find(x) != divs.end()) {\n return divs[x];\n }\n return divs[x] = power(x, 998244353 - 2);\n };\n ll n, m;\n cin >> n >> m;\n vector a((size_t) n);\n vector w((size_t) n);\n for (ll i = 0; i < n; i++) {\n ll v;\n cin >> v;\n a[i] = v == 1;\n }\n for (ll i = 0; i < n; i++) {\n cin >> w[i];\n }\n ll zeros = 0, ones = 0;\n for (ll i = 0; i < n; i++) {\n if (a[i]) {\n ones += w[i];\n } else {\n zeros += w[i];\n }\n }\n map, ll> dp0;\n function f0 = [&](ll z, ll o) {\n if (z - o <= zeros - ones - m) {\n return 1LL;\n }\n auto it = dp0.find({z, o});\n if (it != dp0.end()) {\n return it->second;\n }\n ll r = z * f0(z - 1, o) + (o + 1) * f0(z, o + 1);\n r %= 998244353;\n r *= div(z + o);\n r %= 998244353;\n return dp0[{z, o}] = r;\n };\n map, ll> dp1;\n function f1 = [&](ll z, ll o) {\n if (z - o <= zeros - ones - m) {\n return 1LL;\n }\n auto it = dp1.find({z, o});\n if (it != dp1.end()) {\n return it->second;\n }\n ll r = (z - 1) * f1(z - 1, o) + o * f1(z, o + 1);\n r %= 998244353;\n r *= div(z + o);\n r %= 998244353;\n return dp1[{z, o}] = r;\n };\n for (ll i = 0; i < n; i++) {\n if (a[i]) {\n cout << (f0(zeros, ones) * w[i]) % 998244353 << endl;\n } else {\n cout << (f1(zeros, ones) * w[i]) % 998244353 << endl;\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "27f901debf70b0b731788443461f6c54", "src_uid": "ba9c136f84375cd317f0f8b53e3939c7", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "///\u9898\u89e3\uff1ahttps://ouuan.github.io/Codeforces-Round-564-%E4%B8%AD%E6%96%87%E9%A2%98%E8%A7%A3/\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define LL long long\n#define ULL unsigned long long\n#define rep(i, j, k) for(int i = j; i <= k; i++)\n#define dep(i, j, k) for(int i = k; i >= j; i--)\n#define INF 0x3f3f3f3f\n#define mem(i, j) memset(i, j, sizeof(i))\n#define make(i, j) make_pair(i, j)\n#define pb push_back\nusing namespace std;\nconst int N = 1e5 + 5, mod = 998244353, M = 3e3 + 5\nint ksm(int x, int y) {\n int ans = 1;\n while(y) {\n if( y & 1 ) ans = (LL) ans * x % mod;\n x = (LL) x * x % mod;\n y >>= 1;\n }\n return ans;\n}\nint n, m, a[N], w[N], f[M][M], g[M][M], inv[M << 1], sum[3];\n///sum[0] : don't like ; sum[1]: like; sum[2]:all\nint main() {\n scanf(\"%d%d\", &n, &m);\n //cout << n << \" \" << m <= 0; j--) {\n f[i][j] = ((LL) (sum[1] + i + 1) * f[i + 1][j] + (LL) (sum[0] - j) * f[i][j + 1]) % mod * inv[i - j + m] % mod;\n\t\t\tg[i][j] = ((LL) (sum[1] + i) * g[i + 1][j] + (LL) (sum[0] - j - 1) * g[i][j + 1]) % mod * inv[i - j + m] % mod;\n }\n }\n rep(i, 1, n) printf(\"%d\\n\", int((LL) w[i] * (a[i] ? f[0][0] : g[0][0]) % mod));\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7a815d1294b16f48e823195fc0198202", "src_uid": "ba9c136f84375cd317f0f8b53e3939c7", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "#include\n#define M (((long long)1e9)+7)\nint main()\n{\n\n\tint t;\n\tscanf(\"%d\",&t);\n\tlong long m=1;\n\twhile(t--)\n\t{\n\t\tscanf(\"%lld\",m);\n\t\tif(m<2)\tcout<<\"1\\n\";\n\t\telse if(m%4>1)\n\t\t{\n\t\t\tprintf(\"%d\\n\",((((((m+2)/4+1)%M)*(((m+2)/4+1)%M)-(m+2)/4-1)%M)+M)%M);\n\t\t}\t\n\t\telse \n\t\t{\n\t\t\tcout<\n#define int unsigned long long\n#define double long double\n#define x first\n#define y second\n#define yy cout<<\"YES\\n\"\n#define nn cout<<\"NO\\n\"\n#define rt return\n#define ct continue\n#define br break\n#define pb push_back\n#define mp make_pair\n#define mt make_tuple\n#define mmod 1000000007\n#define pmod 998244353\nusing namespace std;\nint gcd(int a,int b){\n while (b) b^=a^=b^=a%=b;\n return a;\n}\nint lcm(int a,int b){\n return a*b/gcd(a,b);\n}\nint bigmod(int b,int p,int m){\n int ans=1;\n b%=m;\n if (!b) return 0;\n while (p){\n if (p&1) ans=(ans*b)%m;\n p>>=1;\n b=(b*b)%m;\n }\n return ans;\n}\nint ncr(int n,int r){\n\tif (n>n;\n\tif (n==1) cout<<\"1\\n\";\n\telse if (n==2||n==3) cout<<\"2\\n\";\n\telse {\n\t\tint h=n/2;\n\t\tif (h%2==0){\n\t\t\tint t=h/2+1;\n\t\t\tcout<>t;\n while (t--) solve();\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1df8ea6d7c2f1900ca4b72e7cc1da855", "src_uid": "24f4bd10ae714f957920afd47ac0c558", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "// ====================================\n// author: M_sea\n// website: https://m-sea-blog.com/\n// ====================================\n#include \n#define file(x) freopen(#x\".in\",\"r\",stdin); freopen(#x\".out\",\"w\",stdout)\n#define debug(...) fprintf(stderr,__VA_ARGS__)\nusing namespace std;\ntypedef long long ll;\n\nll read() {\n\tll X=0,w=1; char c=getchar();\n\twhile (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }\n\twhile (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();\n\treturn X*w;\n}\n\nconst int mod=1e9+7;\n\n\n\nint main() {\n\tint T=read();\n\twhile (T--) {\n\t\tll n=read();\n\t\t__int128 ans=(__int128)(n/2+2)*(n/2+2)/4;\n\t\tprintf(\"%d\\n\",ans%mod);\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "902e7dcc7f79fa69015b603e1fa24618", "src_uid": "24f4bd10ae714f957920afd47ac0c558", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "#include \n#pragma GCC optimize(\"Ofast\")\n#pragma GCC optimize (\"unroll-loops\")\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\nusing namespace std;\n#define ll long long\n#define fr(i,j,k) for(int i=j;imp;\nvoid read(ll &x) {\n x = 0; char ch = getchar();\n while(!isdigit(ch)) ch = getchar();\n while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();\n}\nvoid my_add(int &x,int v){\n x+=v;\n if(x>=mod)x-=mod;\n}\nvoid my_sub(int &x,int v){\n x-=v;\n if(x<0)x+=mod;\n}\nvoid go() { \n ll x;\n read(x);\n if (mp.count(x)) {\n cout << mp[x] << '\\n';\n return;\n }\n vectorv;\n while (x) {\n v.pb(x & 1);\n x >>= 1;\n }\n reverse(all(v));\n dp[0][0] = 1;\n dp[0][1] = 1;\n vectorpre{0,1,2,2,2,2,2,2};\n for (int i = 1 ; i < v.size() ; i++) {\n vectornow{0};\n for (int j = 0 ; j < 7 ; j++) {\n int x = pre[ub[j][v[i]]];\n int y = now.back();\n my_sub(x, pre[lb[j][v[i]]]);\n my_add(y, x);\n now.pb(y);\n }\n pre = now;\n }\n mp[x] = pre[1];\n cout << pre[1] << '\\n';\n}\nint main() {\n f(7) {\n fr(j,0,2) {\n ub[i][j] = min(6,(i+7-j)/2) + 1;\n lb[i][j] = max(0,(i-j+1) / 2);\n }\n }\n //ios_base::sync_with_stdio(0);\n //cin.tie(0);\n int c = 1;\n ll t;\n if (!c) {\n t = 1;\n }\n else {\n read(t);\n }\n while (t--) {\n go();\n }\n \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f4a09c3cf34a5c4a9abede0381256334", "src_uid": "24f4bd10ae714f957920afd47ac0c558", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing ll = long long;\nconst int N = 100010;\nconst long double eps = 1e-9;\nint sig(long double p){return (p > eps) - (p < -eps);}\nlong double sqr(long double p){return p * p;}\nll sqr(int p){return 1ll * p * p;}\n\nstruct P{\n long double x, y;\n\n explicit P(long double x = 0, long double y = 0):x(x), y(y){}\n\n P operator +(const P &p)const{return P(x + p.x, y + p.y);}\n P operator -(const P &p)const{return P(x - p.x, y - p.y);}\n P operator *(const long double &p)const{return P(x * p, y * p);}\n long double operator %(const P &p)const{ return x * p.x + y * p.y; }\n long double abs2()const{ return *this % *this; }\n P rot90()const{ return P(-y, x); }\n};\n\nint n;\nint x[N], y[N];\n\nstruct C{\n P o;\n long double r;\n\n C(P o, long double r):o(o), r(r){}\n};\n\nstd::vector

    isCC(C c1, C c2){\n if (!sig(c1.x - c2.x) && !sig(c1.y - c2.y)){\n return {};\n }\n long double d = (c1.o - c2.o).abs2();\n long double x = ((c1.r - c2.r) / d + 1) / 2;\n long double y = std::max(c1.r / d - sqr(x), 0.0L);\n P q1 = c1.o + (c2.o - c1.o) * x;\n P q2 = ((c2.o - c1.o) * std::sqrt(y)).rot90();\n return {q1 - q2, q1 + q2};\n}\n\nvoid solve(){\n std::vector dis(n);\n for (int i = 0; i < n; ++ i){\n scanf(\"%lld\", &dis[i]);\n }\n std::sort(dis.begin(), dis.end());\n long double avgx = 0, avgy = 0, avgx2 = 0, avgy2 = 0, avgdis = 0;\n for (int i = 0; i < n; ++ i){\n avgx += x[i];\n avgy += y[i];\n avgx2 += sqr(x[i]);\n avgy2 += sqr(y[i]);\n avgdis += dis[i];\n }\n long double r = avgdis / n + sqr(avgx / n) + sqr(avgy / n) - avgx2 / n - avgy2 / n;\n C basic(P(avgx / n, avgy / n), r);\n std::vector

    points;\n using pii = std::pair ;\n std::vector ans;\n for (int i = 0; i < n; ++ i){\n C circle(P(x[0], y[0]), dis[i]);\n auto ps = isCC(circle, basic);\n for (auto p : ps){\n int xx = std::round(p.x), yy = std::round(p.y);\n const int S = 10;\n for (int u = xx - S; u <= xx + S; ++ u){\n for (int v = yy - S; v <= yy + S; ++ v){\n if (sqr(u - x[0]) + sqr(v - y[0]) == dis[i]){\n ans.emplace_back(u, v);\n }\n }\n }\n }\n }\n std::sort(ans.begin(), ans.end());\n ans.erase(std::unique(ans.begin(), ans.end()), ans.end());\n std::vector ret;\n for (auto p : ans){\n std::vector real_dis(n);\n for (int i = 0; i < n; ++ i){\n real_dis[i] = sqr(p.first - x[i]) + sqr(p.second - y[i]);\n }\n std::sort(real_dis.begin(), real_dis.end());\n if (dis == real_dis){\n ret.push_back(p);\n }\n }\n printf(\"%d\", (int) ret.size());\n for (auto p : ret){\n printf(\" %d %d\", p.first, p.second);\n }\n puts(\"\");\n}\n\nint main(){\n scanf(\"%d\", &n);\n for (int i = 0; i < n; ++ i){\n scanf(\"%d%d\", &x[i], &y[i]);\n }\n int test;\n scanf(\"%d\", &test);\n while (test --){\n solve();\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "625e7b0ac4557465fca6d1ab29c14ab9", "src_uid": "057fdc41579d2e070fb7ea2ebeecb0fa", "difficulty": 3400.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\nusing namespace std;\nconst int N=1600002;\ntypedef long long ll;\nconst long double eps=1000,Eps=1e-8;\nstruct Uzi{\n\tint x,y;\n\tbool operator<(const Uzi &k)const{\n\t\tif(k.x!=x)\n\t\t\treturn k.x>x;\n\t\treturn k.y>y;\n\t}\n}p[N];\nint n,m,x[N],y[N],i,cnt,ans;\nlong long d[N],D[N],s8,s9;\nlong double Cx,Cy,Sxy,Sd,R;\nvoid init(){\n\tscanf(\"%d\",&n);\n\tfor(i=1;i<=n;i++)\n\t\tscanf(\"%d%d\",x+i,y+i),Cx+=x[i],Cy+=y[i];\n\tCx/=n;Cy/=n;\n\tfor(i=1;i<=n;i++)\n\t\tSxy+=(Cx-x[i])*(Cx-x[i])+(Cy-y[i])*(Cy-y[i]);\n}\nvoid Check(ll X,ll Y){\n\tint i;\n\tif(fabs((X-Cx)*(X-Cx)+(Y-Cy)*(Y-Cy)-R)>eps)\n\t\treturn;\n\t//printf(\"%lld %lld\\n\",X,Y);\n\tfor(i=1;i<=n;i++)\n\t\tD[i]=1ll*(X-x[i])*(X-x[i])+1ll*(Y-y[i])*(Y-y[i]);\n\tsort(D+1,D+n+1);\n\tfor(i=1;i<=n;i++)\n\t\tif(D[i]!=d[i])\n\t\t\treturn;\n\tcnt++;\n\tp[cnt]=(Uzi){(int)X,(int)Y};\n}\nvoid GetNode(long double X1,long double Y1,long double R1,long double X2,long double Y2,long double R2,long double R12,long double R22){\n\tlong double dis=sqrt((X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2));\n\tlong double dis2=(X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2);\t\t\n\t//printf(\" %lf %lf %lf\\n\",dis,R1,R2);\n\tif(dis>R1+R2+Eps)return;\n\tlong double t=atan2(Y2-Y1,X2-X1);\n\tlong double p=(R12+dis2-R22)/2/R1/dis;\n\tif(p>1)p=1;\n\tif(p<-1)p=-1;\n\tlong double k=acos(p);\n\tlong double X3=X1+R1*cos(t+k);\n\tlong double Y3=Y1+R1*sin(t+k);\n\t//printf(\"%.6Lf %.6Lf %.6Lf %.6Lf %.6Lf %.6Lf %.6Lf\\n\",R1,R2,dis,t,k,X3,Y3);\n\tint u,v;\n\tif(fabs(X3)<(1e10)&&fabs(Y3)<(1e10)){\n\t\tfor(u=-5;u<=5;u++)\n\t\t\tfor(v=-5;v<=5;v++){\n\t\t\t\tCheck((ll)(X3+u),(ll)(Y3+v));\n\t\t\t\t//Check((ll)(X3+u+0.6),(ll)(Y3+v+0.6));\n\t\t\t}\n\t}\t\n\tlong double X4=X1+R1*cos(t-k);\n\tlong double Y4=Y1+R1*sin(t-k);\n\tif(fabs(X4)<(1e10)&&fabs(Y4)<(1e10)){\n\t\tfor(u=-5;u<=5;u++)\n\t\t\tfor(v=-5;v<=5;v++){\n\t\t\t\tCheck((ll)(X4+u),(ll)(Y4+v));\t\n\t\t\t\t//Check((ll)(X4+u+0.6),(ll)(Y4+v+0.6));\t\n\t\t\t}\n\t}\n}\nvoid work(){\n\tcnt=0;Sd=0;ans=0;\n\ts8=s9=0;\n\tfor(i=1;i<=n;i++){\n\t\tscanf(\"%lld\",d+i);\n\t\ts8+=d[i]/1000000000;\n\t\ts9+=d[i]%1000000000;\n\t}\n\tsort(d+1,d+n+1);\n\td[0]=233333333;\n\tR=(((long double)s8)*((long double)1000000000)+((long double)s9)-Sxy)/n;\n\t//printf(\"%lf %lf %lf\\n\\n\",R,Cx,Cy);\n\tfor(i=1;i<=n;i++)\n\t\tif(d[i]!=d[i-1])\n\t\t\tGetNode(Cx,Cy,sqrt(R),x[1],y[1],sqrt(d[i]),R,d[i]);\n\tp[0].x=p[0].y=192608170;\n\tsort(p+1,p+cnt+1);\n\tfor(i=1;i<=cnt;i++)\n\t\tif(p[i].x!=p[i-1].x||p[i].y!=p[i-1].y)\n\t\t\tans++;\n\tprintf(\"%d \",ans);\n\tfor(i=1;i<=cnt;i++)\n\t\tif(p[i].x!=p[i-1].x||p[i].y!=p[i-1].y)\n\t\t\tprintf(\"%d %d \",p[i].x,p[i].y);\n\tcout << '\\n';\n}\nint main(){\n\tinit();\n\tcin >> m;\n\twhile(m--) work();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "00d90ca35e78707c8b9cc637678cdbee", "src_uid": "057fdc41579d2e070fb7ea2ebeecb0fa", "difficulty": 3400.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pll;\nconst int mn=1e5+10;\nll x[mn],y[mn],d[mn];\ninline ld sq(ld x){return x*x;}\ninline ll sq(ll x){return x*x;}\nld eps=1e-8;\nld i1x,i1y,i2x,i2y;\nbool intersect(ld x1,ld y1,ld r1,ld x2,ld y2,ld r2,ld r12,ld r22){\n if(r12==0){\n i1x=i2x=x1,i1y=i2y=y1;\n return 1;\n }\n ld dis=sqrt(sq(x1-x2)+sq(y1-y2));\n ld dis2=sq(x1-x2)+sq(y1-y2);\n if(dis>r1+r2+eps)return 0;\n ld t=atan2(y2-y1,x2-x1);\n ld p=(r12+dis2-r22)/2/r1/dis;\n if(p>1)p=1;\n if(p<-1)p=-1;\n ld k=acos(p);\n i1x=x1+r1*cos(t+k);\n i1y=y1+r1*sin(t+k);\n i2x=x1+r1*cos(t-k);\n i2y=y1+r1*sin(t-k);\n return 1;\n}\nvectorans;\nvoid idk(ll xx,ll yy,int i,int n){\n if(sq(xx-x[0])+sq(yy-y[0])!=d[i])return;\n vectorv;\n for(int j=0;j\nusing namespace std;\n#define rep(i,a,n) for (int i=a;i=a;i--)\n#define pb push_back\n#define mp make_pair\n#define all(x) (x).begin(),(x).end()\n#define fi first\n#define se second\n#define SZ(x) ((int)(x).size())\ntypedef vector VI;\ntypedef long long ll;\ntypedef pair PII;\nmt19937 mrand(random_device{}()); \nconst ll mod=1000000007;\nint rnd(int x) { return mrand() % x;}\nll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}\nll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}\n// head\n\ntypedef pair pll;\n\nnamespace decompose {\ntypedef long double bi;\ntypedef long long ll;\ninline ll cf(ll a,ll b,ll p) {\n\ta%=p; b%=p; if (a<0) a+=p; if (b<0) b+=p;\n\tll d=(ll)floor(a*(long double)b/p+0.5);\n\tll ret=(a*b-d*p)%p;\n\tif (ret<0) ret+=p;\n\treturn ret;\n}\nll qp(ll x, ll y, ll m) {\n if (y == 0)\n return 1;\n ll hf = qp(x, y >> 1, m);\n hf = cf(hf, hf, m);\n if (y & 1)\n hf = cf(hf, x, m);\n return hf;\n}\npll operator*(pll a, pll b) { return pll(a.fi * b.fi - a.se * b.se, a.fi * b.se + a.se * b.fi); }\npll operator-(pll a, pll b) { return pll(a.fi - b.fi, a.se - b.se); }\npll gcd(pll a, pll b) {\n if (b.fi == 0 && b.se == 0)\n return a;\n bi fm = bi(b.fi) * b.fi + bi(b.se) * b.se, aa = bi(a.fi) * b.fi + bi(a.se) * b.se,\n bb = bi(a.se) * b.fi - bi(a.fi) * b.se;\n pll q(llround(aa / (long double)fm), llround(bb / (long double)fm));\n return gcd(b, a - q * b);\n}\npll solve(ll x) {\n ll k;\n while (1) {\n ll n = rand() % (x - 2) + 2;\n if (qp(n, (x - 1) / 2, x) == x - 1) {\n k = qp(n, (x - 1) / 4, x);\n break;\n }\n }\n pll g = gcd(pll(x, 0), pll(k, 1));\n g.fi = abs(g.fi);\n g.se = abs(g.se);\n if (g.fi > g.se)\n swap(g.fi, g.se);\n return g;\n}\n}\n\ntypedef pair PLL;\nnamespace Factor {\n\tconst int N=1010000;\n\tll C,fac[10010],n,mut,a[1001000];\n\tint T,cnt,i,l,prime[N],p[N],psize,_cnt;\n\tll _e[100],_pr[100];\n\tvector d;\n\tinline ll mul(ll a,ll b,ll p) {\n\t\tif (p<=1000000000) return a*b%p;\n\t\telse if (p<=1000000000000ll) return (((a*(b>>20)%p)<<20)+(a*(b&((1<<20)-1))))%p;\n\t\telse {\n\t\t\tll d=(ll)floor(a*(long double)b/p+0.5);\n\t\t\tll ret=(a*b-d*p)%p;\n\t\t\tif (ret<0) ret+=p;\n\t\t\treturn ret;\n\t\t}\n\t}\n\tvoid prime_table(){\n\t\tint i,j,tot,t1;\n\t\tfor (i=1;i<=psize;i++) p[i]=i;\n\t\tfor (i=2,tot=0;i<=psize;i++){\n\t\t\tif (p[i]==i) prime[++tot]=i;\n\t\t\tfor (j=1;j<=tot && (t1=prime[j]*i)<=psize;j++){\n\t\t\t\tp[t1]=prime[j];\n\t\t\t\tif (i%prime[j]==0) break;\n\t\t\t}\n\t\t}\n\t}\n\tvoid init(int ps) {\n\t\tpsize=ps;\n\t\tprime_table();\n\t}\n\tll powl(ll a,ll n,ll p) {\n\t\tll ans=1;\n\t\tfor (;n;n>>=1) {\n\t\t\tif (n&1) ans=mul(ans,a,p);\n\t\t\ta=mul(a,a,p);\n\t\t}\n\t\treturn ans;\n\t}\n\tbool witness(ll a,ll n) {\n\t\tint t=0;\n\t\tll u=n-1;\n\t\tfor (;~u&1;u>>=1) t++;\n\t\tll x=powl(a,u,n),_x=0;\n\t\tfor (;t;t--) {\n\t\t\t_x=mul(x,x,n);\n\t\t\tif (_x==1 && x!=1 && x!=n-1) return 1;\n\t\t\tx=_x;\n\t\t}\n\t\treturn _x!=1;\n\t}\n\tbool miller(ll n) {\n\t\tif (n<2) return 0;\n\t\tif (n<=psize) return p[n]==n;\n\t\tif (~n&1) return 0;\n\t\tfor (int j=0;j<=7;j++) if (witness(rand()%(n-1)+1,n)) return 0;\n\t\treturn 1;\n\t}\n\tll gcd(ll a,ll b) {\n\t\tll ret=1;\n\t\twhile (a!=0) {\n\t\t\tif ((~a&1) && (~b&1)) ret<<=1,a>>=1,b>>=1;\n\t\t\telse if (~a&1) a>>=1; else if (~b&1) b>>=1;\n\t\t\telse {\n\t\t\t\tif (a getd() {\n\t\td.clear();\n\t\tdfs(1,0);\n\t\treturn d;\n\t}\n\tvector factor(ll n) {\n\t\tcnt=0;\n\t\t_factor(n);\n\t\tnorm();\n\t\treturn getd();\n\t}\n\tvector factorG(ll n) {\n\t\tcnt=0;\n\t\t_factor(n);\n\t\tnorm();\n\t\tvector d;\n\t\trep(i,0,_cnt) d.pb(mp(_pr[i],_e[i]));\n\t\treturn d;\n\t}\n\tpll operator * (const pll &a, const pll &b) {\n\t\treturn mp(a.fi*b.fi-a.se*b.se,a.fi*b.se+a.se*b.fi);\n\t}\n\tvector gao(ll n) {\n\t\tcnt=0;\n\t\t_factor(n);\n\t\tnorm();\n\t\tvector d;\n\t\td.pb(mp(1,0));\n\t\trep(i,0,_cnt) {\n\t\t\tvector d2;\n\t\t\tif (_pr[i]%4==3) {\n\t\t\t\tpll x(1,0);\n\t\t\t\tif (_e[i]%2) return vector(0);\n\t\t\t\trep(j,0,_e[i]/2) x=x*pll(_pr[i],0);\n\t\t\t\tfor (auto p:d) d2.pb(p*x);\n\t\t\t} else if (_pr[i]%4==2) {\n\t\t\t\tpll x(1,0);\n\t\t\t\trep(j,0,_e[i]) x=x*pll(1,1);\n\t\t\t\tfor (auto p:d) d2.pb(p*x);\n\t\t\t} else {\n\t\t\t\tpll dd=decompose::solve(_pr[i]);\n\t\t\t\tpll a=dd,b=dd; b.se*=-1;\n\t\t\t\tvector mt;\n\t\t\t\trep(j,0,_e[i]+1) {\n\t\t\t\t\tpll y(1,0);\n\t\t\t\t\trep(c,0,j) y=y*a;\n\t\t\t\t\trep(c,j,_e[i]) y=y*b;\n\t\t\t\t\tmt.pb(y);\n\t\t\t\t}\n\t\t\t\tfor (auto p:d) for (auto q:mt) d2.pb(p*q);\n\t\t\t}\n\t\t\td=d2;\n\t\t}\n\t\tset hs;\n\t\tfor (auto p:d) {\n\t\t\ths.insert(mp(p.fi,p.se));\n\t\t\ths.insert(mp(p.fi,-p.se));\n\t\t\ths.insert(mp(-p.fi,p.se));\n\t\t\ths.insert(mp(-p.fi,-p.se));\n\t\t\ths.insert(mp(p.se,p.fi));\n\t\t\ths.insert(mp(p.se,-p.fi));\n\t\t\ths.insert(mp(-p.se,p.fi));\n\t\t\ths.insert(mp(-p.se,-p.fi));\n\t\t}\n\t\td=vector(all(hs));\n\t\treturn d;\n\t}\n\n\tbool is_primitive(ll a,ll p) {\n\t\tassert(miller(p));\n\t\tvector D=factorG(p-1);\n\t\trep(i,0,SZ(D)) if (powl(a,(p-1)/D[i].fi,p)==1) return 0;\n\t\treturn 1;\n\t}\n}\n\nconst int N=101000;\nll d[N];\nint n,m,x[N],y[N],ord[N];\nll dis[N];\nvoid gao() {\n\tunordered_map hs;\n\tset ans;\n\trep(i,0,n) scanf(\"%lld\",d+i);\n\trep(i,0,n) hs[d[i]]++;\n\trep(i,0,n) ord[i]=i;\n\trandom_shuffle(ord,ord+n);\n\n\tll hv1=0,hv2=0,hv3=0,hv4=0;\n\trep(i,0,n) {\n\t\thv1=(hv1+(ll)x[i]*x[i]+(ll)y[i]*y[i])%mod;\n\t\thv2=(hv2+x[i])%mod;\n\t\thv3=(hv3+y[i])%mod;\n\t\thv4=(hv4+d[i])%mod;\n\t}\n\tauto dd=Factor::gao(d[rnd(n)]);\n\tauto check=[&](ll px,ll py) {\n\t\tauto distTo=[&](int id) {\n\t\t\treturn (px-x[id])*(px-x[id])+(py-y[id])*(py-y[id]);\n\t\t};\n\t\tll z=(n*px%mod*px+n*py%mod*py+hv1-2*hv2*px-2*hv3*py)%mod;\n\t\tif (z<0) z+=mod;\n\t\tif (z!=hv4) return 0;\n\t\trep(i,0,n) {\n\t\t\tdis[i]=distTo(ord[i]);\n\t\t\tif (hs[dis[i]]==0) {\n\t\t\t\trep(j,0,i) ++hs[dis[j]];\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\t--hs[dis[i]];\n\t\t}\n\t\trep(i,0,n) ++hs[dis[i]];\n\t\treturn 1;\n\t};\n\trep(i,0,n) for (auto p:dd) {\n\t\tll px=x[i]+p.fi,py=y[i]+p.se;\n\t\tif (check(px,py)) ans.insert(mp(px,py));\n\t}\n\n\tprintf(\"%d\",SZ(ans));\n\tfor (auto p:ans) printf(\" %lld %lld\",p.fi,p.se);\n\tputs(\"\");\n}\n\nint main() {\n\tFactor::init(100000);\n\tscanf(\"%d\",&n);\n\trep(i,0,n) scanf(\"%d%d\",x+i,y+i);\n\tscanf(\"%d\",&m);\n\trep(i,0,m) gao();\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b14522398293b9c85a700c69133bd1f6", "src_uid": "057fdc41579d2e070fb7ea2ebeecb0fa", "difficulty": 3400.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n#define int long long\nconst int maxn=505;\nint p;\nint po(int a,int b)\n{\n if(b==0) return 1;\n if(b==1) return a;\n if(b%2==0)\n {\n int u=po(a,b/2);\n return (u*u)%p;\n }\n else\n {\n int u=po(a,b-1);\n return (a*u)%p;\n }\n}\nint inv(int x)\n{\n return po(x,p-2);\n}\nint fact[maxn];\nint invf[maxn];\nint c[maxn][maxn];\nint c1(int n,int k)\n{\n int ans=fact[n];\n ans*=invf[k];\n ans%=p;\n ans*=invf[n-k];\n ans%=p;\n return ans;\n}\nint c(int n,int k)\n{\n return c[n][k];\n}\nint32_t main()\n{\n ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n int n,m;\n cin>>n>>m;\n cin>>p;\n int u1=1;\n for(int i=0;i=j) c[i][j]=c1(i,j);\n }\n }\n int dp1[n+1];\n dp1[0]=1;\n int dp2[n+1];\n dp2[0]=0;\n for(int i=1;i<=n;++i)\n {\n dp1[i]=0;\n dp2[i]=0;\n for(int j=0;j\nusing namespace std;\n \nusing ll = long long;\nusing ld = long double;\nusing db = double; \nusing str = string; // yay python!\n\nusing pi = pair;\nusing pl = pair;\nusing pd = pair;\n\nusing vi = vector;\nusing vb = vector;\nusing vl = vector;\nusing vd = vector; \nusing vs = vector;\nusing vpi = vector;\nusing vpl = vector; \nusing vpd = vector;\n\n#define tcT template using V = vector; \ntcT, size_t SZ> using AR = array; \ntcT> using PR = pair;\n\n// pairs\n#define mp make_pair\n#define f first\n#define s second\n\n// vectors\n#define sz(x) (int)(x).size()\n#define all(x) begin(x), end(x)\n#define rall(x) (x).rbegin(), (x).rend() \n#define sor(x) sort(all(x)) \n#define rsz resize\n#define ins insert \n#define ft front() \n#define bk back()\n#define pf push_front \n#define pb push_back\n#define eb emplace_back \n#define lb lower_bound \n#define ub upper_bound \n\n// loops\n#define FOR(i,a,b) for (int i = (a); i < (b); ++i)\n#define F0R(i,a) FOR(i,0,a)\n#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)\n#define R0F(i,a) ROF(i,0,a)\n#define trav(a,x) for (auto& a: x)\n\nint MOD = 1e9+7; // 998244353;\nconst int MX = 2e5+5;\nconst ll INF = 1e18; // not too close to LLONG_MAX\nconst ld PI = acos((ld)-1);\nconst int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1}; // for every grid problem!!\nmt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); \ntemplate using pqg = priority_queue,greater>;\n\n// helper funcs\nconstexpr int pct(int x) { return __builtin_popcount(x); } // # of bits set\nconstexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) \nll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up\nll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down\n\ntcT> bool ckmin(T& a, const T& b) {\n\treturn b < a ? a = b, 1 : 0; } // set a = min(a,b)\ntcT> bool ckmax(T& a, const T& b) {\n\treturn a < b ? a = b, 1 : 0; }\n\ntcTU> T fstTrue(T lo, T hi, U f) {\n\thi ++; assert(lo <= hi); // assuming f is increasing\n\twhile (lo < hi) { // find first index such that f is true \n\t\tT mid = lo+(hi-lo)/2;\n\t\tf(mid) ? hi = mid : lo = mid+1; \n\t} \n\treturn lo;\n}\ntcTU> T lstTrue(T lo, T hi, U f) {\n\tlo --; assert(lo <= hi); // assuming f is decreasing\n\twhile (lo < hi) { // find first index such that f is true \n\t\tT mid = lo+(hi-lo+1)/2;\n\t\tf(mid) ? lo = mid : hi = mid-1;\n\t} \n\treturn lo;\n}\ntcT> void remDup(vector& v) { // sort and remove duplicates\n\tsort(all(v)); v.erase(unique(all(v)),end(v)); }\ntcTU> void erase(T& t, const U& u) { // don't erase\n\tauto it = t.find(u); assert(it != end(t));\n\tt.erase(it); } // element that doesn't exist from (multi)set\n\n// INPUT\n#define tcTUU tcT, class ...U\ntcT> void re(complex& c);\ntcTU> void re(pair& p);\ntcT> void re(vector& v);\ntcT, size_t SZ> void re(AR& a);\n\ntcT> void re(T& x) { cin >> x; }\nvoid re(db& d) { str t; re(t); d = stod(t); }\nvoid re(ld& d) { str t; re(t); d = stold(t); }\ntcTUU> void re(T& t, U&... u) { re(t); re(u...); }\n\ntcT> void re(complex& c) { T a,b; re(a,b); c = {a,b}; }\ntcTU> void re(pair& p) { re(p.f,p.s); }\ntcT> void re(vector& x) { trav(a,x) re(a); }\ntcT, size_t SZ> void re(AR& x) { trav(a,x) re(a); }\ntcT> void rv(int& n, vector& x) { re(n); x.rsz(n); trav(a,x) re(a); }\n\n// TO_STRING\n#define ts to_string\nstr ts(char c) { return str(1,c); }\nstr ts(const char* s) { return (str)s; }\nstr ts(str s) { return s; }\nstr ts(bool b) { \n\t#ifdef LOCAL\n\t\treturn b ? \"true\" : \"false\"; \n\t#else \n\t\treturn ts((int)b);\n\t#endif\n}\ntcT> str ts(complex c) { \n\tstringstream ss; ss << c; return ss.str(); }\nstr ts(vector v) {\n\tstr res = \"{\"; F0R(i,sz(v)) res += char('0'+v[i]);\n\tres += \"}\"; return res; }\ntemplate str ts(bitset b) {\n\tstr res = \"\"; F0R(i,SZ) res += char('0'+b[i]);\n\treturn res; }\ntcTU> str ts(pair p);\ntcT> str ts(T v) { // containers with begin(), end()\n\t#ifdef LOCAL\n\t\tbool fst = 1; str res = \"{\";\n\t\tfor (const auto& x: v) {\n\t\t\tif (!fst) res += \", \";\n\t\t\tfst = 0; res += ts(x);\n\t\t}\n\t\tres += \"}\"; return res;\n\t#else\n\t\tbool fst = 1; str res = \"\";\n\t\tfor (const auto& x: v) {\n\t\t\tif (!fst) res += \" \";\n\t\t\tfst = 0; res += ts(x);\n\t\t}\n\t\treturn res;\n\n\t#endif\n}\ntcTU> str ts(pair p) {\n\t#ifdef LOCAL\n\t\treturn \"(\"+ts(p.f)+\", \"+ts(p.s)+\")\"; \n\t#else\n\t\treturn ts(p.f)+\" \"+ts(p.s);\n\t#endif\n}\n\n// OUTPUT\ntcT> void pr(T x) { cout << ts(x); }\ntcTUU> void pr(const T& t, const U&... u) { \n\tpr(t); pr(u...); }\nvoid ps() { pr(\"\\n\"); } // print w/ spaces\ntcTUU> void ps(const T& t, const U&... u) { \n\tpr(t); if (sizeof...(u)) pr(\" \"); ps(u...); }\n\n// DEBUG\nvoid DBG() { cerr << \"]\" << endl; }\ntcTUU> void DBG(const T& t, const U&... u) {\n\tcerr << ts(t); if (sizeof...(u)) cerr << \", \";\n\tDBG(u...); }\n#ifdef LOCAL // compile with -DLOCAL, chk -> fake assert\n\t#define dbg(...) cerr << \"Line(\" << __LINE__ << \") -> [\" << #__VA_ARGS__ << \"]: [\", DBG(__VA_ARGS__)\n\t#define chk(...) if (!(__VA_ARGS__)) cerr << \"Line(\" << __LINE__ << \") -> function(\" \\\n\t\t << __FUNCTION__ << \") -> CHK FAILED: (\" << #__VA_ARGS__ << \")\" << \"\\n\", exit(0);\n#else\n\t#define dbg(...) 0\n\t#define chk(...) 0\n#endif\n\n// FILE I/O\nvoid setIn(str s) { freopen(s.c_str(),\"r\",stdin); }\nvoid setOut(str s) { freopen(s.c_str(),\"w\",stdout); }\nvoid unsyncIO() { cin.tie(0)->sync_with_stdio(0); }\nvoid setIO(str s = \"\") {\n\tunsyncIO();\n\t// cin.exceptions(cin.failbit); \n\t// throws exception when do smth illegal\n\t// ex. try to read letter into int\n\tif (sz(s)) { setIn(s+\".in\"), setOut(s+\".out\"); } // for USACO\n}\n\n/**\n * Description: Barrett reduction computes $a \\% b$ about 4 times faster than usual \n \t* where $b$ is constant but not known at compile time. Fails for $b = 1$.\n * Source: KACTL\n \t* https://github.com/kth-competitive-programming/kactl/blob/master/content/various/FastMod.h\n \t* https://en.wikipedia.org/wiki/Barrett_reduction\n * Verification: http://www.usaco.org/index.php?page=viewproblem2&cpid=1045\n */\n\ntypedef unsigned long long ul; typedef __uint128_t L;\nstruct ModFast {\n\tul b,m; ModFast(ul b) : b(b), m(ul((L(1)<<64)/b)) {}\n\tul reduce(ul a) {\n\t\tul q = (ul)((L(m)*a)>>64), r = a-q*b;\n\t\treturn r>=b?r-b:r; }\n};\n\nModFast MF(1);\n\n/**\n * Description: modular arithmetic operations \n * Source: \n\t* KACTL\n\t* https://codeforces.com/blog/entry/63903\n\t* https://codeforces.com/contest/1261/submission/65632855 (tourist)\n\t* https://codeforces.com/contest/1264/submission/66344993 (ksun)\n\t* also see https://github.com/ecnerwala/cp-book/blob/master/src/modnum.hpp (ecnerwal)\n * Verification: \n\t* https://open.kattis.com/problems/modulararithmetic\n */\n\ntemplate struct mint {\n\t// static const int mod = MOD;\n\tstatic constexpr mint rt() { return RT; } // primitive root for FFT\n\tint v; explicit operator int() const { return v; } // explicit -> don't silently convert to int\n\tmint() { v = 0; }\n\tmint(ll _v) { v = int((-MOD < _v && _v < MOD) ? _v : _v % MOD);\n\t\tif (v < 0) v += MOD; }\n\tfriend bool operator==(const mint& a, const mint& b) { \n\t\treturn a.v == b.v; }\n\tfriend bool operator!=(const mint& a, const mint& b) { \n\t\treturn !(a == b); }\n\tfriend bool operator<(const mint& a, const mint& b) { \n\t\treturn a.v < b.v; }\n\tfriend void re(mint& a) { ll x; re(x); a = mint(x); }\n\tfriend str ts(mint a) { return ts(a.v); }\n \n\tmint& operator+=(const mint& m) { \n\t\tif ((v += m.v) >= MOD) v -= MOD; \n\t\treturn *this; }\n\tmint& operator-=(const mint& m) { \n\t\tif ((v -= m.v) < 0) v += MOD; \n\t\treturn *this; }\n\tmint& operator*=(const mint& m) { \n\t\tv = MF.reduce((ll)v*m.v); return *this; }\n\tmint& operator/=(const mint& m) { return (*this) *= inv(m); }\n\tfriend mint pow(mint a, ll p) {\n\t\tmint ans = 1; assert(p >= 0);\n\t\tfor (; p; p /= 2, a *= a) if (p&1) ans *= a;\n\t\treturn ans; }\n\tfriend mint inv(const mint& a) { assert(a.v != 0); \n\t\treturn pow(a,MOD-2); }\n\t\t\n\tmint operator-() const { return mint(-v); }\n\tmint& operator++() { return *this += 1; }\n\tmint& operator--() { return *this -= 1; }\n\tfriend mint operator+(mint a, const mint& b) { return a += b; }\n\tfriend mint operator-(mint a, const mint& b) { return a -= b; }\n\tfriend mint operator*(mint a, const mint& b) { return a *= b; }\n\tfriend mint operator/(mint a, const mint& b) { return a /= b; }\n};\n\ntypedef mint<5> mi; // 5 is primitive root for both common mods\ntypedef vector vmi;\ntypedef pair pmi;\ntypedef vector vpmi;\n\nvector scmb; // small combinations\nvoid genComb(int SZ) {\n\tscmb.assign(SZ,vmi(SZ)); scmb[0][0] = 1;\n\tFOR(i,1,SZ) F0R(j,i+1) \n\t\tscmb[i][j] = scmb[i-1][j]+(j?scmb[i-1][j-1]:0);\n}\n\nmi ways[501], mad[501];\nmi WAYS[501][501], MAD[501][501];\nint N,M;\n\nint main() {\n\tsetIO(); re(N,M,MOD);\n\tMF = ModFast(MOD);\n\tgenComb(N+5);\n\tways[0] = 1;\n\tFOR(n,1,N+1) {\n\t\tFOR(i,1,n+1) {\n\t\t\tways[n] += (n+1)*ways[i-1]*ways[n-i]*scmb[n-1][i-1];\n\t\t\tFOR(j,1,i+1) {\n\t\t\t\tmad[n] += (j-1)*ways[i-1]*ways[n-i]*scmb[n-1][i-1];\n\t\t\t\tmad[n] += mad[i-1]*ways[n-i]*scmb[n-1][i-1];\n\t\t\t\tmad[n] += mad[n-i]*ways[i-1]*scmb[n-1][i-1];\n\t\t\t}\n\t\t\tFOR(j,1,n-i+2) {\n\t\t\t\tmad[n] += (j-1)*ways[i-1]*ways[n-i]*scmb[n-1][i-1];\n\t\t\t\tmad[n] += mad[i-1]*ways[n-i]*scmb[n-1][i-1];\n\t\t\t\tmad[n] += mad[n-i]*ways[i-1]*scmb[n-1][i-1];\n\t\t\t}\n\t\t}\n\t}\n\tF0R(n,N+1) WAYS[n][0] = 1;\n\tFOR(n,1,N+1) FOR(m,1,n+1) {\n\t\tif (n == m) {\n\t\t\tWAYS[n][m] = ways[n];\n\t\t\tMAD[n][m] = mad[n];\n\t\t} else {\n\t\t\tWAYS[n][m] = WAYS[n-1][m]; \n\t\t\tMAD[n][m] = MAD[n-1][m];\n\t\t\tFOR(l,1,m+1) {\n\t\t\t\tWAYS[n][m] += WAYS[n-l-1][m-l]*ways[l]*scmb[m][l];\n\t\t\t\tMAD[n][m] += (WAYS[n-l-1][m-l]*mad[l]+ways[l]*MAD[n-l-1][m-l])*scmb[m][l];\n\t\t\t}\n\t\t}\n\t}\n\tdbg(WAYS[N][M],MAD[N][M]);\n\tps(MAD[N][M]);\n\t// you should actually read the stuff at the bottom\n}\n\n/* stuff you should look for\n\t* int overflow, array bounds\n\t* special cases (n=1?)\n\t* do smth instead of nothing and stay organized\n\t* WRITE STUFF DOWN\n\t* DON'T GET STUCK ON ONE APPROACH\n*/\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0224981f0ddea4cacce843d4a86c18cf", "src_uid": "9812de5f2d272511a63ead8765b23190", "difficulty": 3100.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\ntypedef long long LL;\nconst int N = 500 + 10;\nint n,m,p;\nLL c[N][N],f[N],g[N],dp[N][N][N],ways[N][N][N];\nvoid add(LL &x,LL y){\n\tx=(x+y)%p;\n}\nLL cal(LL x){\n\treturn 1LL*x*(x-1)/2 % p; \n}\nint main() {\n cin>>n>>m>>p;\n for(int i=0;i\n\nusing namespace std;\n#define int long long\nconst int maxn=505;\nint p;\nint po(int a,int b)\n{\n if(b==0) return 1;\n if(b==1) return a;\n if(b%2==0)\n {\n int u=po(a,b/2);\n return (u*u)%p;\n }\n else\n {\n int u=po(a,b-1);\n return (a*u)%p;\n }\n}\nint fact[maxn];\nint invf[maxn];\nint c3[maxn][maxn];\nint c(int n,int k)\n{\n return c3[n][k];\n}\nint32_t main()\n{\n ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n int n,m;\n cin>>n>>m;\n cin>>p;\n int u1=1;\n for(int i=0;ij) c3[i][j]=c3[i-1][j-1]+c3[i-1][j];\n else if(i==j) c3[i][j]=1;\n }\n }\n int dp1[n+1];\n dp1[0]=1;\n int dp2[n+1];\n dp2[0]=0;\n for(int i=1;i<=n;++i)\n {\n dp1[i]=0;\n dp2[i]=0;\n for(int j=0;j\n#pragma comment(linker, \"/stack:200000000\")\n#pragma GCC optimize(\"Ofast\")\n#pragma target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair pii;\nconst int inf = 0x3f3f3f3f;\n#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)\n#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)\n#define rep(i,a,b) for(register int i=(a);i=10)write(x/10);putchar(x%10+'0');}\nvoid wri(ll x){write(x),pc(' ');}\nvoid writeln(ll x){write(x),pc('\\n');}\nconst int mod = 998244353;\nconst int maxn = 1<<19|233;\nint n,k,f[1<<21];\nint main(){\n\tn = read(),k = read();\n\tif(k==1){writeln(3);return ;}\n\tRep(i,1,n) f[i]=i;\n\tRep(i,1,n) for(int j=i+i;j<=n;j+=i) f[j]-=f[i];\n\tsort(f+1,f+1+n);ll ans=0;Rep(i,1,k+2) ans+=f[i];writeln(ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0b928b687ae87854b61286d9c90d21ae", "src_uid": "c2f7012082c84d773c2f4b1858c17110", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#include\n#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)\nusing namespace std;\nint n,k,phi[1000005];\nll ans;\nint main(){\n\tscanf(\"%d%d\",&n,&k);\n\tif (k==1) return puts(\"3\"),0;\n\tFor(i,1,n) phi[i]=i;\n\tFor(i,2,n) if (phi[i]==i)\n\t\tFor(j,1,n/i) phi[i*j]-=phi[i*j]/i;\n\tsort(phi+1,phi+n+1);\n\tFor(i,1,k+2) ans+=phi[i];\n\tprintf(\"%lld\\n\",ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "75ee83d08f535be40f95bceab4cf177b", "src_uid": "c2f7012082c84d773c2f4b1858c17110", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "//https://codeforces.com/contest/1208/problem/G\n#include\nusing namespace std;\n#define ll long long \nconst int N=1e6+100;\nint phi[N],p[N/10];\nbool vis[N];\nint tot=0;\nvoid eular(int n)\n{\n\tfor(int i=2;i<=n;i++)\n\t{\n\t\tif(vis[i]==0) p[tot++]=i,phi[i]=i-1;\n\t\tfor(int j=0;j>n>>k;\n\tif(k==1) cout<3<\n\nusing namespace std;\n\nconst int MAX = 1e6 + 3;\nint dp[MAX];\n\nvoid precalc(int n) {\n for(int i = 1; i <= n; ++i) {\n dp[i] = i;\n }\n for(int i = 2; i <= n; ++i) {\n if(dp[i] == i) {\n --dp[i];\n for(int j = i * 2; j <= n; j += i) {\n dp[j] = dp[j] / i * (i - 1);\n }\n }\n }\n}\n\nvoid solve() {\n int n, k;\n cin >> n >> k;\n if(n == 3) {\n cout << 3 << endl;\n return;\n }\n precalc(n);\n sort(dp, dp + n + 1);\n\n long long res = 0;\n for(int i = 1; i <= k + 2; ++i) {\n res += dp[i];\n }\n\n cout << res << endl;\n}\n\nint main() {\n solve();\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "dd39a6780f0e3bbf46f51a56751635cd", "src_uid": "c2f7012082c84d773c2f4b1858c17110", "difficulty": 2800.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nmap, long long >mem ;\nlong long dp(long long l,long long r,long long dis,long long back)\n{\n back=min(back,r);\n back=max(back,l);\n if(mem[make_tuple(r-l,dis,back-l)])\n return mem[make_tuple(r-l,dis,book-l)];\n long long mid=l+(r-l)/2;\n if(mid-l>dis||mid-l==dis && mid<=back)\n return mem[make_tuple(r-l,dis,back-l)]=dp(l,mid,dis,back)+dp(mid,r,dis,back)+1;\n return mem[make_tuple(r-l,dis,back-l)]=0;\n}\nint main()\n{\n long long n,k;\n scanf(\"%I64d %I64d\",&n,&k);\n if(k==1)\n {\n printf(\"1\\n\");\n return 0;\n }\n if(k==2)\n {\n printf(\"%d\\n\",n);\n return 0;\n }\n long long x=1,y=n;\n while(x<=y)\n {\n long long mid=x+(y-x)/2;\n if(dp(x,y,mid,n)>=k) y=mid-1;\n else x=mid+1;\n }\n long long anslen=x-1;\n x=1,y=n;\n while(x<=y)\n {\n long long mid=x+(y-x)/2;\n if(dp(x,y,anslen,mid)>=k) y=mid-1;\n else x=mid+1;\n }\n printf(\"%I64d\\n\",x-1);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8c449d796304043ded18b985c2b7f465", "src_uid": "eb311bde6a0e3244d92fafbd4aa1e61f", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include\n#define ll long long\n#define 2333 6666\nusing namespace std;\nll get(ll x,ll v){\n\tif (x<=v*2) return 0;\n\tll s1=1,s2=0,p1=x,p2=x-1,ans=0;\n\tfor (;p2>=v*2;p1/=2,p2=p1-1){\n\t\tif (p2==v*2) return s1+ans;\n\t\tans+=s1+s2;\n\t\tif (p1&1) s1=s1*2+s2;\n\t\telse s2=s2*2+s1;\n\t}\n\treturn ans;\n}\nll solve(ll l,ll r,ll p,ll k){\n\tll mid=(l+r)/2;\n\tif (k==1) return mid;\n\tll tmp=get(mid-l,p),Tmp=get(r-mid,p+1);\n\tif (k>tmp+Tmp+1) return solve(mid+1,r,p,k-tmp-1);\n\treturn solve(l,mid-1,p,k-Tmp-1);\n}\nint main(){\n\tll n,k;\n\tscanf(\"%lld%lld\",&n,&k);\n\tif (k==1) return puts(\"1\"),0;\n\tif (k==2) return printf(\"%lld\",n),0;\n\tn-=2; k-=2;\n\tll l=0,r=n/2+1,mid;\n\twhile (r-l>1){\n\t\tmid=(l+r)/2;\n\t\tif (get(n,mid)\n\n#define f(_i, _n) for (auto _i = 0; _i < _n; _i++)\n#define F(_i, _k, _n) for (auto _i = _k; _i < _n; _i++)\n#define fr(_i, _k, _n) for (auto _i = _k; _i < _n; _i++)\n#define r(_t, _n) _t _n; cin >> _n;\n#define ra(_type, _name, _len)_type _name[_len]; f(_i, _len) cin >> _name[_len];\n#define mp make_pair\n#define re return\n#define takedown re 0;\n#define fi first\n#define se second\n#ifdef FairlyLocal\n #define deb cerr\n#else\n #define deb GetCE :(\n#endif\n#define pb push_back\n#define fill(_a, _n) memset(_a, _n, sizeof(_a))\n#define all(_v) _v.begin(), _v.end()\n#define vi std::vector\n\nusing namespace std;\ntypedef pair pii;\ntypedef long long ll;\n\n#ifndef FairlyLocal\n class fastio {\n public:\n fastio() {\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n }\n } __fastio;\n#endif\n\nmap go(int n){\n\tmap m[100];\n\tm[0][-n] = 1;\n\tll cc = 0;\n map ans;\n ans[-(n - 1) / 2]++;\n int ok = 1;\n while(ok){\n ok = 0;\n\t\tfor(auto it : m[cc]){\n\t\t\tll w = -it.fi;\n // deb << w << ' ' << it.se << '\\n';\n if((w - 1) / 2 > 0) {\n ok = 1;\n m[cc + 1][-(w - 1) / 2] += it.se;\n ans[-((w - 1) / 2 - 1) / 2] += it.se;\n }\n if(w / 2 > 0) {\n m[cc + 1][-w / 2] += it.se;\n ans[-(w / 2 - 1) / 2] += it.se;\n ok = 1;\n }\n }\n\t\tcc++;\n\t}\n // deb << '\\n';\n // for(auto j : ans) deb << -j.fi << ' ' << j.se << '\\n';\n re ans;\n}\n\nint n, k;\n\nint solve() {\n int pos = 1, sz = 0;\n auto aa = go(n);\n // deb << aa.size() << '\\n';\n for(auto it : aa) {\n // deb << it.fi << ' ' << it.se << '\\n';\n if(it.se >= k) {\n sz = -it.fi;\n break;\n }\n // deb << k << '\\n';\n k -= it.se;\n }\n // deb << sz << ' ' << k << '\\n';\n int cursz = (n - 1) / 2;\n while(true) {\n deb << cursz << ' ' << sz << ' ' << pos << ' ' << k << ' ' << '\\n';\n if(cursz == sz) {\n re pos + sz + k;\n }\n auto a1 = go((cursz - 1) / 2);\n auto a2 = go(cursz / 2);\n if(a1[-sz] >= k) {\n if(cursz == 2) pos++;\n cursz = (cursz - 1) / 2;\n }\n else {\n pos += cursz + 1;\n k -= a1[-sz];\n cursz = cursz / 2;\n }\n }\n re -1;\n}\n\nint main(){\n #ifdef FairlyLocal\n freopen(\".input\", \"r\", stdin);\n freopen(\".output\", \"w\", stdout);\n freopen(\".debug\", \"w\", stderr);\n #endif\n cin >> n >> k;\n if(k == 1) {\n cout << 1;\n re 0;\n }\n if(k == 2) {\n cout << n;\n re 0;\n }\n k -= 2;\n n -= 2;\n cout << solve();\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1d45efba790d1be03510b6bcbfd6c4e1", "src_uid": "eb311bde6a0e3244d92fafbd4aa1e61f", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include \n\n#define f(_i, _n) for (auto _i = 0; _i < _n; _i++)\n#define F(_i, _k, _n) for (auto _i = _k; _i < _n; _i++)\n#define fr(_i, _k, _n) for (auto _i = _k; _i < _n; _i++)\n#define r(_t, _n) _t _n; cin >> _n;\n#define ra(_type, _name, _len)_type _name[_len]; f(_i, _len) cin >> _name[_len];\n#define mp make_pair\n#define re return\n#define takedown re 0;\n#define fi first\n#define se second\n#ifdef FairlyLocal\n #define deb cerr\n#else\n #define deb GetCE :(\n#endif\n#define pb push_back\n#define fill(_a, _n) memset(_a, _n, sizeof(_a))\n#define all(_v) _v.begin(), _v.end()\n#define vi std::vector\n\nusing namespace std;\ntypedef pair pii;\ntypedef long long ll;\n\n#ifndef FairlyLocal\n class fastio {\n public:\n fastio() {\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n }\n } __fastio;\n#endif\n\nmap go(ll n){\n\tmap m[100];\n\tm[0][-n] = 1;\n\tll cc = 0;\n map ans;\n ans[-(n - 1) / 2]++;\n int ok = 1;\n while(ok){\n ok = 0;\n\t\tfor(auto it : m[cc]){\n\t\t\tll w = -it.fi;\n // deb << w << ' ' << it.se << '\\n';\n if((w - 1) / 2 > 0) {\n ok = 1;\n m[cc + 1][-(w - 1) / 2] += it.se;\n ans[-((w - 1) / 2 - 1) / 2] += it.se;\n }\n if(w / 2 > 0) {\n m[cc + 1][-w / 2] += it.se;\n ans[-(w / 2 - 1) / 2] += it.se;\n ok = 1;\n }\n }\n\t\tcc++;\n\t}\n // deb << '\\n';\n // for(auto j : ans) deb << -j.fi << ' ' << j.se << '\\n';\n re ans;\n}\n\nll n, k;\n\nll solve() {\n ll pos = 1, sz = 0;\n auto aa = go(n);\n // deb << aa.size() << '\\n';\n for(auto it : aa) {\n deb << k << ' ' << it.se << '\\n';\n if(it.se >= k) {\n sz = -it.fi;\n break;\n }\n // deb << k << '\\n';\n k -= it.se;\n }\n // deb << sz << ' ' << k << '\\n';\n ll cursz = (n - 1) / 2;\n ll size = n;\n while(true) {\n if(cursz == sz) {\n re pos + sz + k;\n }\n auto a1 = go((size - 1) / 2);\n auto a2 = go(size / 2);\n // deb << cursz << ' ' << size << ' ' << pos << ' ' << k << ' ' << a1[-sz] << ' ' << a2[-sz] << '\\n';\n if(a1[-sz] >= k) {\n if(cursz == 2) pos++;\n size = cursz;\n cursz = (cursz - 1) / 2;\n }\n else {\n pos += cursz + 1;\n k -= a1[-sz];\n size = size / 2;\n cursz = (cursz - 1) / 2;\n }\n }\n re -1;\n}\n\nint main(){\n #ifdef FairlyLocal\n freopen(\".input\", \"r\", stdin);\n freopen(\".output\", \"w\", stdout);\n freopen(\".debug\", \"w\", stderr);\n #endif\n cin >> n >> k;\n if(k == 1) {\n cout << 1;\n re 0;\n }\n if(k == 2) {\n cout << n;\n re 0;\n }\n k -= 2;\n n -= 2;\n cout << solve();\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6317157810f902043a8094af0b37a90d", "src_uid": "eb311bde6a0e3244d92fafbd4aa1e61f", "difficulty": 2900.0} {"lang": "GNU C++0x", "source_code": "#include \n\n#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)\n#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)\n#define REP(i,a) for(int i=0,_a=(a); i<_a; i++)\n#define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)\n\n#define DEBUG(x) { cout << #x << \" = \"; cout << (x) << endl; }\n#define PR(a,n) { cout << #a << \" = \"; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }\n#define PR0(a,n) { cout << #a << \" = \"; REP(_,n) cout << a[_] << ' '; cout << endl; }\n\n#define sqr(x) ((x) * (x))\nusing namespace std;\n\nconst int MN = 100111;\n\nstruct Str {\n int typ, x;\n} a[MN];\nint n, m;\nlong long best, cnt;\n\nbool operator < (const Str& a, const Str& b) {\n if (a.x != b.x) return a.x < b.x;\n return a.typ < b.typ;\n}\n\nStr reverse(const Str& a) {\n Str res;\n res.typ = 1 - a.typ;\n res.x = n - a.x;\n return res;\n}\n\nvoid update(long long val, long long c) {\n if (!c) return ;\n if (val > best) {\n best = val;\n cnt = c;\n }\n else if (val == best) {\n cnt += c;\n }\n}\n\nint count(int typ) {\n int res = 0;\n FOR(i,1,m)\n if (a[i].typ == typ) ++res;\n return res;\n}\n\nlong long c3(long long n) {\n return n * (n-1LL) * (n-2LL) / 6;\n}\n\nlong long c2(long long n) {\n return n * (n-1LL) / 2;\n}\n\nvoid case1() {\n // Case 1: X, Y, Z (x <= y <= z)\n // Sum = H(X, Y) + H(Y, Z) + H(Z, X)\n // = 2z - 2x\n // Thus, choose max z and min x\n int nn = -1, ln = -1;\n FOR(i,1,m)\n if (a[i].typ == 0) {\n if (nn < 0) nn = a[i].x; else nn = min(nn, a[i].x);\n if (ln < 0) ln = a[i].x; else ln = max(ln, a[i].x);\n }\n if (nn == ln) {\n update(0, c3(count(0)));\n }\n else {\n long long cnt_min = 0, cnt_max = 0, cnt_mid = 0;\n FOR(i,1,m)\n if (a[i].typ == 0) {\n if (a[i].x == nn) cnt_min++;\n else if (a[i].x == ln) cnt_max++;\n else cnt_mid++;\n }\n update(2*ln - 2*nn,\n cnt_min * cnt_max * cnt_mid\n + c2(cnt_min) * cnt_max\n + cnt_min * c2(cnt_max)\n );\n }\n}\n\nvoid case2() {\n // Case 2: _X, Y, Z\n // Sum = H(_X, Y) + H(Y, Z) + H(_X, Z)\n // = 2n + 2x - 2y\n long long y = -1, cnt_y = 0, cnt_all = 0;\n FORD(i,m,1) {\n if (a[i].typ == 0) {\n if (a[i].x == y) ++cnt_y;\n else {\n y = a[i].x;\n cnt_y = 1;\n }\n ++cnt_all;\n }\n else {\n update(2*n + 2*a[i].x - 2*y,\n c2(cnt_y)\n + cnt_y * (cnt_all - cnt_y)\n );\n }\n }\n}\n\n#define left left_\n#define right right_\nlong long left[MN], right[MN];\nvoid case3() {\n // Case 3: X, _Y, Z\n // Sum = H(X, _Y) + H(_Y, Z) + H(X, Z)\n // = 2n\n FOR(i,1,m) {\n left[i] = left[i-1];\n if (a[i].typ == 0) ++left[i];\n }\n right[n+1] = 0;\n FORD(i,m,1) {\n right[i] = right[i+1];\n if (a[i].typ == 0) ++right[i];\n }\n FOR(i,2,m-1)\n if (a[i].typ == 1) {\n update(2*n, left[i-1] * right[i+1]);\n }\n}\n\nvoid case4() {\n // Case 4: X, Y, _Z\n // Sum = 2n + 2y - 2z\n long long y = -1, cnt_y = 0, cnt_all = 0;\n FOR(i,1,m) {\n if (a[i].typ == 0) {\n if (a[i].x == y) ++cnt_y;\n else {\n y = a[i].x;\n cnt_y = 1;\n }\n cnt_all++;\n }\n else {\n update(2*n + 2*y - 2*a[i].x,\n c2(cnt_y)\n + cnt_y * (cnt_all - cnt_y));\n }\n }\n}\n\nvoid solve() {\n sort(a+1, a+m+1);\n if (!count(0)) return ;\n // Let X = 0^x 1^(n-x)\n // Let _X = 1^x 0^(n-x)\n case1();\n if (!count(1)) return ;\n case2();\n case3();\n case4();\n}\n\nint main() {\n ios :: sync_with_stdio(false);\n cout << (fixed) << setprecision(9);\n while (cin >> n >> m) {\n FOR(i,1,m) cin >> a[i].typ >> a[i].x;\n best = -1, cnt = 0;\n solve();\n FOR(i,1,m) a[i] = reverse(a[i]);\n solve();\n\n// DEBUG(best);\n cout << cnt << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "808e7316f5a148c4efc98197189c81a1", "src_uid": "bfc61d3e967fc28e1ab5b9028856125b", "difficulty": 2800.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n#define MAX 100009\n#define ll long long\n\nint setbit(int mask, int bit, int value);\nint getbit(int mask, int bit);\nll cnt(int i, int msk_type, int msk_change, int mode);\nll fn(int i, int msk_type, int msk_change, int mode);\nint bin_search(int t, int val);\nll get_ham(int small, int big, int msk_type);\nvoid pre_process();\nint check(int msk_type);\nint check(int msk_type, int msk_change);\nll C(ll x, ll y);\n\npair zero_one[MAX], one_zero[MAX];\nint a = 0, b = 0;\nint n, l, indx[MAX], diff_indx;\nconst ll inf = 9999999999;\nll dp[MAX][8][8][2], cnt_dp[MAX][8][8][2];\nint bin_ans[MAX], bin_ans2[MAX];\n\nint main()\n{\n scanf(\"%d %d\", &l, &n);\n for(int i = 0; i < n; i++)\n {\n int x, y;\n scanf(\"%d %d\", &x, &y);\n\n if(x == 0)\n zero_one[a++].first = y;\n else\n one_zero[b++].first = y;\n }\n\n pre_process();\n\n ll ans = 0;\n for(int i = 0; i < 8; i++)\n ans = max(ans, fn(0, i, 0, 0));\n\n ll ret = 0;\n for(int i = 0; i < 8; i++)\n if(ans == fn(0, i, 0, 0) && check(i))\n ret += cnt(0, i, 0, 0);\n\n printf(\"%lld\\n\", ret);\n\n return 0;\n}\n\nint check(int msk_type, int msk_change)\n{\n int a = getbit(msk_type, 0);\n int b = getbit(msk_type, 1);\n int c = getbit(msk_type, 2);\n\n if(getbit(msk_change, 0)) a = !a;\n if(getbit(msk_change, 1)) b = !b;\n if(getbit(msk_change, 2)) c = !c;\n\n if(a == b && getbit(msk_change, 0) == 0 && getbit(msk_change, 1) == 1)return 0;\n if(a == c && getbit(msk_change, 0) == 0 && getbit(msk_change, 2) == 1)return 0;\n if(b == c && getbit(msk_change, 1) == 0 && getbit(msk_change, 2) == 1)return 0;\n\n return 1;\n}\n\nint check(int msk_type)\n{\n int a = getbit(msk_type, 0);\n int b = getbit(msk_type, 1);\n int c = getbit(msk_type, 2);\n\n if(a > b || a > c) return 0;\n\n if(b > c) return 0;\n\n return 1;\n}\n\nll cnt(int i, int msk_type, int msk_change, int mode)\n{\n if(check(msk_type, msk_change) == 0) return 0;\n if(i == diff_indx) return msk_change == 7 ? 1 : 0;\n\n ll &ret = cnt_dp[i][msk_type][msk_change][mode];\n if(ret != -1)\n return ret;\n\n ret = 0;\n\n int nxt = indx[i + 1], curr = indx[i];\n ll g = fn(i, msk_type, msk_change, mode); ///get max_value\n\n ///don't change\n if(i < diff_indx - 1)\n {\n if(g == fn(i + 1, msk_type, msk_change, 0) + get_ham(curr, nxt, msk_type))\n ret += cnt(i + 1, msk_type, msk_change, 0), p++;\n }\n else\n {\n if(g == fn(i + 1, msk_type, msk_change, 0))\n ret += cnt(i + 1, msk_type, msk_change, 0), p++;\n }\n\n if(mode == 0)\n {\n int v1 = bin_ans[i];\n int v2 = bin_ans2[i];\n\n for(int x = 1; x < 8; x++)\n {\n int new_msk_type = msk_type;\n int new_msk_change = msk_change;\n int flag = 1, u1 = 0, u2 = 0;\n\n for(int j = 0; j < 3 && flag; j++)\n {\n if(getbit(x, j) == 1)\n {\n int t = getbit(msk_type, j);\n if(t == 0)\n u1++;\n else\n u2++;\n\n if(getbit(msk_change, j) == 1 || (t == 0 && v1 == -1) || (t == 1 && v2 == -1))\n flag = 0;\n new_msk_type = setbit(new_msk_type, j, !t);\n new_msk_change = setbit(new_msk_change, j, 1);\n }\n }\n\n if(u1 > v1 || u2 > v2)\n flag = 0;\n\n ll fac = C((ll)v1, (ll)u1) * C((ll)v2, (ll)u2);\n\n if(flag && fn(i, new_msk_type, new_msk_change, 1) == g)\n fn(i, new_msk_type, new_msk_change, 1) == g;\n }\n }\n\n return ret;\n}\n\nll fn(int i, int msk_type, int msk_change, int mode)\n{\n if(i == diff_indx)return msk_change == 7 ? 0 : -inf;\n\n ll &ret = dp[i][msk_type][msk_change][mode];\n if(ret != -1)\n return ret;\n\n ret = -inf;\n\n int nxt = indx[i + 1], curr = indx[i];\n\n ///don't change\n if(i < diff_indx - 1)\n ret = max(ret, fn(i + 1, msk_type, msk_change, 0) + get_ham(curr, nxt, msk_type));\n else\n ret = max(ret, fn(i + 1, msk_type, msk_change, 0));\n\n if(mode == 0)\n {\n int v1 = bin_ans[i];\n int v2 = bin_ans2[i];\n\n for(int x = 1; x < 8; x++)\n {\n int new_msk_type = msk_type;\n int new_msk_change = msk_change;\n int flag = 1, u1 = 0, u2 = 0;\n\n for(int j = 0; j < 3 && flag; j++)\n {\n if(getbit(x, j) == 1)\n {\n int t = getbit(msk_type, j);\n if(t == 0)\n u1++;\n else\n u2++;\n if(getbit(msk_change, j) == 1 || (t == 0 && v1 == -1) || (t == 1 && v2 == -1))\n flag = 0;\n new_msk_type = setbit(new_msk_type, j, !t);\n new_msk_change = setbit(new_msk_change, j, 1);\n }\n }\n\n if(u1 > v1 || u2 > v2)\n flag = 0;\n \n if(flag)\n ret = max(ret, fn(i, new_msk_type, new_msk_change, 1));\n }\n }\n\n return ret;\n}\n\nvoid pre_process()\n{\n memset(dp, -1, sizeof(dp));\n memset(cnt_dp, -1, sizeof(cnt_dp));\n\n sort(zero_one, zero_one + a);\n sort(one_zero, one_zero + b);\n\n int k = 0;\n for(int i = 0; i < max(a, b); i++)\n {\n if(i < a)indx[k++] = zero_one[i].first;\n if(i < b)indx[k++] = one_zero[i].first;\n }\n\n indx[k++] = 0, indx[k++] = l;\n sort(indx, indx + k);\n\n int j = 0, prev = -1, i = 0, tmp = 0;\n\n while(i < k)\n {\n if(prev != indx[i])\n {\n indx[j++] = indx[i];\n prev = indx[i];\n }\n\n i++;\n }\n\n diff_indx = j;\n\n\n j = 0, prev = zero_one[0].first, i = 0, tmp = 0;\n while(i < a)\n {\n if(prev != zero_one[i].first)\n {\n zero_one[j].first = prev, zero_one[j++].second = tmp;\n tmp = 1;\n prev = zero_one[i].first;\n\n }\n else\n tmp++;\n\n i++;\n }\n\n zero_one[j].first = prev, zero_one[j++].second = tmp;\n a = j;\n\n\n j = 0, prev = one_zero[0].first, i = 0, tmp = 0;\n while(i < b)\n {\n if(prev != one_zero[i].first)\n {\n one_zero[j].first = prev, one_zero[j++].second = tmp;\n tmp = 1;\n prev = one_zero[i].first;\n\n }\n else\n tmp++;\n\n i++;\n }\n\n one_zero[j].first = prev, one_zero[j++].second = tmp;\n b = j;\n\n for(int i = 0; i < diff_indx; i++)\n {\n bin_ans[i] = bin_search(0, indx[i]);\n bin_ans2[i] = bin_search(1, indx[i]);\n }\n}\n\nint setbit(int mask, int bit, int value)\n{\n if(value == 1)\n return(mask | (1 << bit));\n else\n return (mask&~(1 << bit));\n}\n\nint getbit(int mask, int bit)\n{\n mask = (mask >> bit) & 1;\n return (mask == 1);\n}\n\nll get_ham(int small, int big, int msk_type)\n{\n ll ret = 0;\n int diff = big - small;\n \n if(getbit(msk_type, 0) != getbit(msk_type, 1)) ///a b\n ret += diff;\n \n if(getbit(msk_type, 1) != getbit(msk_type, 2)) ///b c\n ret += diff;\n\n if(getbit(msk_type, 0) != getbit(msk_type, 2)) ///a c\n ret += diff;\n\n return ret;\n}\n\nint bin_search(int t, int val)\n{\n int big = (t == 0 ? a : b);\n int small = 0, mid;\n pair *arr = (t == 0 ? zero_one : one_zero);\n\n while(big >= small)\n {\n mid = (small + big) / 2;\n\n if(arr[mid].first == val)\n return arr[mid].second;\n\n if(arr[mid].first > val)\n big = mid - 1;\n else\n small = mid + 1;\n }\n\n return 0;\n}\n\nll C(ll x, ll y)\n{\n if(x == 0 || y == 0)\n return 1;\n\n if(y == 1) return x;\n\n if(y == 2) return (ll)(x * (x - 1)) / 2;\n\n if(y == 3) return (ll)(x * (x - 1) * (x - 2)) / 6;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9543cb431c3c9a0087729f43c3692bb8", "src_uid": "bfc61d3e967fc28e1ab5b9028856125b", "difficulty": 2800.0} {"lang": "GNU C++0x", "source_code": "// iostream is too mainstream\n#include \n// bitch please\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define dibs reserve\n#define OVER9000 1034567890\n#define patkan 9\n#define tisic 47\n#define soclose 1e-9\n#define pi 3.1415926535898\n#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)\n#define chocolate win\n#define ff first\n#define ss second\n#define abs(x) ((x < 0)?-(x):(x))\n#define uint unsigned int\n// mylittlepony\nusing namespace std;\n\nint main() {\n\tcin.sync_with_stdio(0);\n\tcin.tie(0);\n\tint N,M;\n\tcin >> N >> M;\n\tmap C[2];\n\tint T[] ={0,0};\n\tfor(int i =0; i < M; i++) {\n\t\tint t,a;\n\t\tcin >> t >> a;\n\t\tT[t]++;\n\t\tC[t][a] +=1;}\n\n\tint ansV =0;\n\tlong long ansP =0;\n\n\t// rovnaky typ\n\tfor(int i =0; i < 2; i++) if(!C[i].empty()) {\n\t\tint a =2*(C[i].rbegin()->ff-C[i].begin()->ff);\n\t\tint x =C[i].begin()->ss, y =C[i].rbegin()->ss;\n\t\tlong long p =0;\n\t\tif(a == 0) p =1LL*x*(x-1)*(x-2)/6;\n\t\telse p =x*(x-1)/2*y+y*(y-1)*x/2+x*y*(M-x-y);\n\t\tif(ansV < a) {\n\t\t\tansV =a;\n\t\t\tansP =0;}\n\t\tif(ansV == a) ansP +=p;}\n\n\t// rozne typy\n\t// da sa 2N?\n\tfor(int i =0; i < 2; i++) if(!C[i].empty()) {\n\t\tint a =C[i].begin()->ff, b =C[i].rbegin()->ff;\n\t\tif(a == b && a == N && N == 1000000000 && k == 0 && C[1].size() > 5 && C[1].rbegin()->ff == N) cout << \"aha\\n\";\n\t\tbool win =false;\n\t\tALL_THE(C[1-i],it) if(it->ff >= a && it->ff <= b)\n\t\t\twin =true;\n\n\t\tif(!win) {\n\t\t\tauto it =C[1-i].lower_bound(b), jt =C[1-i].lower_bound(a);\n\t\t\tif(jt != C[1-i].begin()) {\n\t\t\t\tjt--;\n\t\t\t\tif(2*N-2*(a-jt->ff) > ansV) {\n\t\t\t\t\tansV =2*N-2*(a-jt->ff);\n\t\t\t\t\tansP =0;}\n\t\t\t\tif(2*N-2*(a-jt->ff) == ansV) {\n\t\t\t\t\tansP +=1LL*(jt->ss)*(C[i].begin()->ss)*(C[i].begin()->ss-1)/2;\n\t\t\t\t\tansP +=1LL*(jt->ss)*(C[i].begin()->ss)*(T[i]-C[i].begin()->ss);}\n\t\t\t\t}\n\t\t\tif(it != C[1-i].end()) {\n\t\t\t\tif(2*N-2*(it->ff-b) > ansV) {\n\t\t\t\t\tansV =2*N-2*(it->ff-b);\n\t\t\t\t\tansP =0;}\n\t\t\t\tif(2*N-2*(it->ff-b) == ansV) {\n\t\t\t\t\tansP +=1LL*(it->ss)*(C[i].rbegin()->ss)*(C[i].rbegin()->ss-1)/2;\n\t\t\t\t\tansP +=1LL*(it->ss)*(C[i].rbegin()->ss)*(T[i]-C[i].rbegin()->ss);}\n\t\t\t\t}\n\t\t\t}\n\n\t\telse {\n\t\t\tif(2*N > ansV) {\n\t\t\t\tansV =2*N;\n\t\t\t\tansP =0;}\n\t\t\tauto it =C[i].begin();\n\t\t\tint p =0;\n\t\t\tALL_THE(C[1-i],jt) {\n\t\t\t\twhile(it != C[i].end() && it->ff < jt->ff) {\n\t\t\t\t\tp +=it->ss;\n\t\t\t\t\tit++;}\n\t\t\t\tif(it != C[i].end() && it->ff == jt->ff)\n\t\t\t\t\tansP +=1LL*(it->ss*(T[i]-p-it->ss)+it->ss*(it->ss-1)/2)*jt->ss;\n\t\t\t\tansP +=1LL*p*(T[i]-p)*jt->ss;}\n\t\t\t}\n\t\t}\n\n\tcout << ansP << \"\\n\";\n\treturn 0;}\n\n// look at my code\n// my code is amazing\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "03f1c69df0a990678e7b4a10801a6624", "src_uid": "bfc61d3e967fc28e1ab5b9028856125b", "difficulty": 2800.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n#define MAX 100009\n#define ll long long\n\nint setbit(int mask, int bit, int value);\nint getbit(int mask, int bit);\nll cnt(int i, int msk_type, int msk_change, int mode);\nll fn(int i, int msk_type, int msk_change, int mode);\nint bin_search(int t, int val);\nll get_ham(int small, int big, int msk_type);\nvoid pre_process();\nint check(int msk_type);\nint check(int msk_type, int msk_change);\nll C(int x, int y);\n\npair zero_one[MAX], one_zero[MAX];\nint a = 0, b = 0;\nint n, l, indx[MAX], diff_indx;\nconst ll inf = 9999999999;\nll dp[MAX][10][10][2], cnt_dp[MAX][10][10][2];\n\nint main()\n{\n scanf(\"%d %d\", &l, &n);\n for(int i = 0; i < n; i++)\n {\n int x, y;\n scanf(\"%d %d\", &x, &y);\n\n if(x == 0)\n zero_one[a++].first = y;\n else\n one_zero[b++].first = y;\n }\n\n pre_process();\n\n\n\n ll ans = 0, ret = 0;\n for(int i = 0; i < 8; i++)\n {\n // if(check(i))\n ans = max(ans, fn(0, i, 0, 0));\n }\n\n for(int i = 0; i < 8; i++)\n if(ans == fn(0, i, 0, 0) && check(i))\n // printf(\"======%d %d\\n\", i, cnt(0, i, 0, 0));\n ret += cnt(0, i, 0, 0);\n printf(\"%lld\\n\",ret);\n\n return 0;\n}\n\nint check(int msk_type, int msk_change)\n{\n int a = getbit(msk_type, 0);\n int b = getbit(msk_type, 1);\n int c = getbit(msk_type, 2);\n\n if(getbit(msk_change, 0)) a = !a;\n if(getbit(msk_change, 1)) b = !b;\n if(getbit(msk_change, 2)) c = !c;\n\n if(a == b && getbit(msk_change, 0) == 0 && getbit(msk_change, 1) == 1)return 0;\n if(a == c && getbit(msk_change, 0) == 0 && getbit(msk_change, 2) == 1)return 0;\n if(b == c && getbit(msk_change, 1) == 0 && getbit(msk_change, 2) == 1)return 0;\n\n return 1;\n}\n\nint check(int msk_type)\n{\n int a = getbit(msk_type, 0);\n int b = getbit(msk_type, 1);\n int c = getbit(msk_type, 2);\n\n if(a > b || a > c) return 0;\n\n if(b > c) return 0;\n\n return 1;\n}\n\nll cnt(int i, int msk_type, int msk_change, int mode)\n{\n if(check(msk_type, msk_change) == 0)\n return 0;\n\n if(i == diff_indx)\n return msk_change == 7 ? 1 : 0;\n\n ll &ret = cnt_dp[i][msk_type][msk_change][mode];\n if(ret != -1)\n return ret;\n\n ret = 0;\n\n int nxt = indx[i + 1], curr = indx[i];\n\n ///get max_value\n ll g = fn(i, msk_type, msk_change, mode);\n\n if(g < 0)\n return 0;\n int p = 0;\n ///don't change\n if(i < diff_indx - 1)\n {\n if(g == fn(i + 1, msk_type, msk_change, 0) + get_ham(curr, nxt, msk_type))\n ret += cnt(i + 1, msk_type, msk_change, 0), p++;\n }\n else\n {\n if(g == fn(i + 1, msk_type, msk_change, 0))\n ret += cnt(i + 1, msk_type, msk_change, 0), p++;\n }\n\n if(mode == 0)\n {\n int v1 = bin_search(0, curr);\n int v2 = bin_search(1, curr);\n\n\n//if((i==3 && msk_type==6 && msk_change==0))\n for(int x = 1; x < 8; x++)\n {\n int new_msk_type = msk_type;\n int new_msk_change = msk_change;\n int flag = 1, u1 = 0, u2 = 0;\n\n for(int j = 0; j < 3 && flag; j++)\n {\n if(getbit(x, j) == 1)\n {\n int t = getbit(msk_type, j);\n if(t == 0)\n u1++;\n else\n u2++;\n\n if(getbit(msk_change, j) == 1 || (t == 0 && v1 == -1) || (t == 1 && v2 == -1))\n flag = 0;\n new_msk_type = setbit(new_msk_type, j, !t);\n new_msk_change = setbit(new_msk_change, j, 1);\n }\n }\n\n if(u1 > v1 || u2 > v2)\n flag = 0;\n\n ll fac = C(v1,u1) * C(v2,u2);\n\n // printf(\"%lld %d %d\\n\", fac,v1,v1-u1);\n if(flag)\n {\n\n if(fn(i, new_msk_type, new_msk_change, 1) == g)\n {\n ret += fac * cnt(i, new_msk_type, new_msk_change, 1), p++;\n\n }\n }\n }\n }\n\n\n\n return ret;\n}\n\nll C(int x, int y)\n{\n if(x == 0 || y == 0)\n return 1;\n\n if(y == 1) return x;\n\n if(y == 2) return (ll)(x * (x - 1)) / 2;\n\n if(y == 3) return (ll)(x * (x - 1) * (x - 2)) / 6;\n}\n\nll fn(int i, int msk_type, int msk_change, int mode)\n{\n if(i == diff_indx)\n {\n // printf(\"%d\\n\", msk_change);\n return msk_change == 7 ? 0 : -inf;\n }\n\n ll &ret = dp[i][msk_type][msk_change][mode];\n if(ret != -1)\n return ret;\n\n ret = -inf;\n\n int nxt = indx[i + 1], curr = indx[i];\n\n ///don't change\n if(i < diff_indx - 1)\n ret = max(ret, fn(i + 1, msk_type, msk_change, 0) + get_ham(curr, nxt, msk_type));\n else\n ret = max(ret, fn(i + 1, msk_type, msk_change, 0));\n\n\n if(mode == 0)\n {\n int v1 = bin_search(0, curr);\n int v2 = bin_search(1, curr);\n\n\n\n for(int x = 1; x < 8; x++)\n {\n int new_msk_type = msk_type;\n int new_msk_change = msk_change;\n int flag = 1, u1 = 0, u2 = 0;\n\n for(int j = 0; j < 3 && flag; j++)\n {\n if(getbit(x, j) == 1)\n {\n int t = getbit(msk_type, j);\n if(t == 0)\n u1++;\n else\n u2++;\n if(getbit(msk_change, j) == 1 || (t == 0 && v1 == -1) || (t == 1 && v2 == -1))\n flag = 0;\n new_msk_type = setbit(new_msk_type, j, !t);\n new_msk_change = setbit(new_msk_change, j, 1);\n }\n }\n\n if(u1 > v1 || u2 > v2)\n flag = 0;\n if(flag)\n ret = max(ret, fn(i, new_msk_type, new_msk_change, 1));\n }\n }\n\n return ret;\n}\n\nint bin_search(int t, int val)\n{\n int big = (t == 0 ? a : b);\n int small = 0, mid;\n pair *arr = (t == 0 ? zero_one : one_zero);\n\n while(big >= small)\n {\n mid = (small + big) / 2;\n\n if(arr[mid].first == val)\n return arr[mid].second;\n\n if(arr[mid].first > val)\n big = mid - 1;\n else\n small = mid + 1;\n }\n\n return 0;\n\n}\n\nll get_ham(int small, int big, int msk_type)\n{\n ll ret = 0;\n int diff = big - small;\n\n ///a b\n if(getbit(msk_type, 0) != getbit(msk_type, 1))\n ret += diff;\n ///b c\n if(getbit(msk_type, 1) != getbit(msk_type, 2))\n ret += diff;\n\n ///a c\n if(getbit(msk_type, 0) != getbit(msk_type, 2))\n ret += diff;\n\n return ret;\n}\n\nvoid pre_process()\n{\n memset(dp, -1, sizeof(dp));\n memset(cnt_dp, -1, sizeof(cnt_dp));\n\n sort(zero_one, zero_one + a);\n sort(one_zero, one_zero + b);\n\n int k = 0;\n for(int i = 0; i < max(a, b); i++)\n {\n if(i < a)indx[k++] = zero_one[i].first;\n if(i < b)indx[k++] = one_zero[i].first;\n }\n\n indx[k++] = 0, indx[k++] = l;\n sort(indx, indx + k);\n\n int j = 0, prev = -1, i = 0, tmp = 0;\n\n while(i < k)\n {\n if(prev != indx[i])\n {\n indx[j++] = indx[i];\n prev = indx[i];\n }\n\n i++;\n }\n\n diff_indx = j;\n\n\n j = 0, prev = zero_one[0].first, i = 0, tmp = 0;\n while(i < a)\n {\n if(prev != zero_one[i].first)\n {\n zero_one[j].first = prev, zero_one[j++].second = tmp;\n tmp = 1;\n prev = zero_one[i].first;\n\n }\n else\n tmp++;\n\n i++;\n }\n\n zero_one[j].first = prev, zero_one[j++].second = tmp;\n a = j;\n\n\n j = 0, prev = one_zero[0].first, i = 0, tmp = 0;\n while(i < b)\n {\n if(prev != one_zero[i].first)\n {\n one_zero[j].first = prev, one_zero[j++].second = tmp;\n tmp = 1;\n prev = one_zero[i].first;\n\n }\n else\n tmp++;\n\n i++;\n }\n\n one_zero[j].first = prev, one_zero[j++].second = tmp;\n b = j;\n\n}\n\nint setbit(int mask, int bit, int value)\n{\n if(value == 1)\n return(mask | (1 << bit));\n else\n return (mask&~(1 << bit));\n}\n\nint getbit(int mask, int bit)\n{\n mask = (mask >> bit) & 1;\n return (mask == 1);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8250ed6e619a6bfd48aaa95f033a02f0", "src_uid": "bfc61d3e967fc28e1ab5b9028856125b", "difficulty": 2800.0} {"lang": "GNU C++14", "source_code": "//#include \n#include\n//#include\nusing namespace std;\n#define PB push_back\n#define ZERO (1e-10)\n#define INF int(1e9+1)\n#define CL(A,I) (memset(A,I,sizeof(A)))\n#define DEB printf(\"DEB!\\n\");\n#define D(X) cout<<\" \"<<#X\": \"<B&&A-ZERO pll;\n//typedef vector vi;\ntypedef pair ii;\n//typedef vector vii;\n#define IN(n) int n;scanf(\"%d\",&n);\n#define FOR(i, m, n) for (int i(m); i < n; i++)\n#define F(n) FOR(i,0,n)\n#define FF(n) FOR(j,0,n)\n#define FT(m, n) FOR(k, m, n)\n#define aa first\n#define bb second\nvoid ga(int N,int *A){F(N)scanf(\"%d\",A+i);}\n#define MX (1<<18)\nint N,M,W,a,b,I,J;\nii A[MX],B[MX];\nll S,T,G;\nbool cmp(ii a,ii b){return a.aa^b.aa?a.aa>b.aa:a.bb\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint main() {\n\tvector>\tphysics;\n\tvector>\tinformatics;\n\tint\t\t\t\t\t\tsignifacance, width;\n\tauto\t\t\t\t\tmaximum_possible = 0;\n\tvector\t\t\t\tphysics_sum;\n\tvector\t\t\t\tinformatics_sum;\n\tvector\t\t\t\tphysics_significance_sum;\n\tvector\t\t\t\tinformatics_significance_sum;\n\n\tint\t\tn, m, d;\n\n\tcin >> n >> m >> d;\n\n\tfor (auto i = 0; i < n; ++i) {\n\t\tcin >> signifacance >> width;\n\t\tphysics.push_back(make_pair(signifacance, width));\n\t}\n\n\tfor (auto i = 0; i < m; ++i) {\n\t\tcin >> signifacance >> width;\n\t\tinformatics.push_back(make_pair(signifacance, width));\n\t}\n\n\tsort(physics.begin(), physics.end(), [](pair& left, pair& right) { if (left.first == right.first) return (left.second < right.second); return (left.first > right.first); });\n\tphysics_sum.assign(physics.size(), 0);\n\tphysics_significance_sum.assign(physics.size(), 0);\n\tphysics_sum[0] = physics[0].second;\n\tphysics_significance_sum[0] = physics[0].first;\n\n\tfor (auto i = 1; i < physics.size(); ++i) {\n\t\tphysics_sum[i] = physics[i].second + physics_sum[i - 1];\n\t\tphysics_significance_sum[i] = physics[i].first + physics_significance_sum[i - 1];\n\t}\n\n\tsort(informatics.begin(), informatics.end(), [](pair& left, pair& right) { if (left.first == right.first) return (left.second < right.second); return (left.first > right.first); });\n\tinformatics_sum.assign(informatics.size(), 0);\n\tinformatics_significance_sum.assign(informatics.size(), 0);\n\tinformatics_sum[0] = informatics[0].second;\n\tinformatics_significance_sum[0] = informatics[0].first;\n\n\tfor (auto i = 1; i < informatics.size(); ++i) {\n\t\tinformatics_sum[i] = informatics[i].second + informatics_sum[i - 1];\n\t\tinformatics_significance_sum[i] = informatics[i].first + informatics_significance_sum[i - 1];\n\t}\n\n\tfor (auto it = physics_sum.begin(), it2 = physics_significance_sum.begin(); it != physics_sum.end(); ++it, it2++) {\n\t\tauto it3 = upper_bound(informatics_sum.begin(), informatics_sum.end(), (d - *it));\n\n\t\tif (it3 == informatics_sum.begin())\n\t\t\tcontinue;\n\n\t\tif (it3 != informatics_sum.end()) {\n\t\t\tauto index = distance(informatics_sum.begin(), it3);\n\n\t\t\tif ((*it2 + informatics_significance_sum[index - 1]) > maximum_possible)\n\t\t\t\tmaximum_possible = *it2 + informatics_significance_sum[index - 1];\n\t\t}\n\t\telse {\n\t\t\tif ((informatics_significance_sum.back() + *it2) > maximum_possible)\n\t\t\t\tmaximum_possible = informatics_significance_sum.back() + *it2;\n\t\t}\n\t}\n\n\tcout << maximum_possible << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5ff10e40c25df3ab8ad90ac501c12f2e", "src_uid": "da573a39459087ed7c42f70bc1d0e8ff", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n\n#define MAXN 100005\n\nusing namespace std;\n\nstruct Node{\n\tlong long sig = 0, wid = 0;\n\tbool operator < (const Node &n) const {\n\t\treturn sig > n.sig;\n\t}\n\tNode operator + (const Node &n) const {\n\t\treturn (Node){sig + n.sig, wid + n.wid};\n\t}\n};\n\nint n, m;\nlong long d;\nNode arr[MAXN], brr[MAXN];\nNode sum1[MAXN], sum2[MAXN];\n\nint main() {\n\tscanf(\"%d %d %lld\", &n, &m, &d);\n\tfor (int i = 1; i <= n; i++)\n\t\tscanf(\"%lld %lld\", &arr[i].sig, &arr[i].wid);\n\tfor (int i = 1; i <= m; i++)\n\t\tscanf(\"%lld %lld\", &brr[i].sig, &brr[i].wid);\n\tsort(arr + 1, arr + n + 1);\n\tsort(brr + 1, brr + m + 1);\n\tfor (int i = 1; i <= n; i++)\n\t\tsum1[i] = sum1[i - 1] + arr[i];\n\tfor (int i = 1; i <= m; i++)\n\t\tsum2[i] = sum2[i - 1] + brr[i];\n\tlong long ans = 0;\n\tfor (int i = 1; i <= n; i++) {\n\t\tif (arr[i].sig == arr[i - 1].sig) continue;\n\t\tif (sum1[i].wid > d) break;\n\t\tlong long rem = d - sum1[i].wid;\n\t\tint l = 0, r = m;\n\t\twhile (l < r) {\n\t\t\tint mid = (l + r >> 1) + 1;\n\t\t\tif (sum2[mid].wid <= rem) l = mid;\n\t\t\telse r = mid - 1;\n\t\t}\n\t\tif (!l) break;\n\t\tans = max(ans, sum1[i].sig + sum2[l].sig);\n\t}\n\tcout << ans << endl;\n\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "744d8812f943c524c36a5266c73e95d8", "src_uid": "da573a39459087ed7c42f70bc1d0e8ff", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\n\ntypedef long long int ll;\n\n\nbool compare(const pair&i, const pair&j)\n{\n if(j.first == i.first)\n return j.second > i.second;\n return j.first < i.first;\n}\n\n\nint main(){\n\n ll n,m,d;\n\n cin >> n >> m >> d;\n\n vector< pair > vf, vi;\n\n\n for(ll i=0;i> c >> w;\n vf.push_back(make_pair(c,w));\n }\n for(ll i=0;i> c >> w;\n vi.push_back(make_pair(c,w));\n }\n\n sort(vf.begin(),vf.end(),compare);\n sort(vi.begin(),vi.end(),compare);\n\n ll sumw = vf[0].second + vi[0].second;\n ll sumc = vf[0].first + vi[0].first;\n\n if(sumw > d){\n cout << \"0\";\n return 0;\n }\n\n ll gsumc = 0;\n\n ll ci=0,cf=0;\n\n int br = 0;\n for(auto i : vf){\n if(br == 0){\n br = 1;\n continue;\n }\n if(sumw + i.second <= d){\n sumw += i.second;\n sumc += i.first;\n cf++;\n }\n else{\n break;\n }\n }\n\n\n\n br = 0;\n for(auto i : vi){\n if(br == 0){\n br = 1;\n continue;\n }\n if(sumw + i.second <= d){\n sumw += i.second;\n sumc += i.first;\n ci++;\n }\n else{\n break;\n }\n }\n\n gsumc = sumc;\n\n ci++;\n\n while(true){\n if(cf == 0 || ci == vi.size())\n break;\n sumc -= vf[cf].first;\n sumw -= vf[cf].second;\n cf--;\n while(sumw + vi[ci].second <= d){\n sumw += vi[ci].second;\n sumc += vi[ci].first;\n ci++;\n ci == vi.size(){\n break;\n }\n }\n if(sumc > gsumc)\n gsumc = sumc;\n }\n\n cout << gsumc;\n\n\n return 0;\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "49dce7b9998d8eab8be9b37c1249b6c8", "src_uid": "da573a39459087ed7c42f70bc1d0e8ff", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define ll long long\nchar buf[1<<20],*p1,*p2;\n#define GC (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?0:*p1++)\ntemplate inline void read(T &n){\n\tchar ch=GC;T w=1,x=0;\n\twhile(!isdigit(ch)){if(ch=='-') w=-1;ch=GC;}\n\twhile(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=GC;}\n\tn=x*w;\n}\nconst int mod=998244353;\nconst int inv2=499122177;\nconst int inv6=166374059;\ninline int add(int x,int y){\n\tx+=y;return x>=mod?x-mod:x;\n}\ninline int mul(int x,int y){\n\treturn 1ll*x*y%mod;\n}\ninline int get1(int x){\n\treturn mul(mul(x,x+1),inv2);\n}\ninline int get2(int x){\n\treturn mul(mul(x,x+1),mul(2*x+1,inv6));\n}\nint n,T,x[85],y[85],bot[605],tot;\nint st[505],top;\nint sum[2005],lazy[2005];\nvoid clear(int l,int r,int id){\n\tsum[id]=lazy[id]=0;\n\tif(l==r) return;\n\tint mid=(l+r)>>1;\n\tclear(l,mid,id<<1);\n\tclear(mid+1,r,id<<1|1);\n}\ninline void update(int l,int r,int id){\n\tif(lazy[id]) sum[id]=st[r+1]-st[l];\n\telse{\n\t\tif(l==r) sum[id]=0;\n\t\telse sum[id]=sum[id<<1]+sum[id<<1|1];\n\t} \n}\ninline void putdown(int l,int r,int id){\n\tif(!lazy[id]) return;\n\tint mid=(l+r)>>1;\n\tlazy[id<<1]+=lazy[id];\n\tlazy[id<<1|1]+=lazy[id];\n\tupdate(l,mid,id<<1);\n\tupdate(mid+1,r,id<<1|1);\n\tlazy[id]=0;\n}\nvoid modify(int l,int r,int id,int L,int R,int val){\n\tif(L<=l&&r<=R){\n\t\tlazy[id]+=val;\n\t\tupdate(l,r,id);\n\t\treturn;\n\t}\n\tint mid=(l+r)>>1;\n\tif(L<=mid) modify(l,mid,id<<1,L,R,val);\n\tif(R>mid) modify(mid+1,r,id<<1|1,L,R,val);\n\tupdate(l,r,id);\n}\n#define pii pair\n#define fir first\n#define sec second\nvector Add[505],Del[505];\nint getval(int t){\n\ttop=0;\n\tfor(int i=1;i<=n;i++){\n\t\tst[++top]=x[i]-t,st[++top]=x[i]+t+1;\n\t\tst[++top]=y[i]-t,st[++top]=y[i]+t+1;\n\t}\n\tsort(st+1,st+top+1);\n\ttop=unique(st+1,st+top+1)-(st+1);\n\tclear(1,top,1);\n\tfor(int i=1;i<=top;i++) Add[i].clear(),Del[i].clear();\n\tfor(int i=1;i<=n;i++){\n\t\tint L=lower_bound(st+1,st+top+1,y[i]-t)-st,R=lower_bound(st+1,st+top+1,y[i]+t+1)-st;\n\t\tint B=lower_bound(st+1,st+top+1,x[i]-t)-st,E=lower_bound(st+1,st+top+1,x[i]+t+1)-st;\n\t\tAdd[B].push_back(make_pair(L,R-1)),Del[E].push_back(make_pair(L,R-1));\n\t}\n\tint ans=0;\n\tfor(int i=1;i\n#include\n#include\n#include\nusing std::max;\nusing std::lower_bound;\nusing std::sort;\nusing std::unique;\nusing std::vector;\ninline int abs(int x)\n{\n\treturn x<0?-x:x;\n}\nconst int mod=998244353;\ninline int add(int a,int b)\n{\n\treturn (a+=b)>=mod?a-mod:a;\n}\ninline int sub(int a,int b)\n{\n\treturn (a-=b)<0?a+mod:a;\n}\ninline int mul(int a,int b)\n{\n\treturn (long long)a*b%mod;\n}\ninline int qpow(int a,int b)\n{\n\tint res=1;\n\tfor(;b;a=mul(a,a),b>>=1)\n\t\tif(b&1)\n\t\t\tres=mul(res,a);\n\treturn res;\n}\nconst int N=105;\nint n,t,ans;\nstruct cell\n{\n\tint x,y;\n}c[N];\nvector V,Vx,Vy;\nint sw,w[N],sumw[N];\nstruct task\n{\n\tint t,l,r,k;\n};\nvector ta;\nint f[N];\nnamespace lglr\n{\n\tint n;\n\tint x[N],y[N];\n\t// inline void print()\n\t// {\n\t// \tregister int i;\n\t// \tfor(i=1;i<=n;i++)\n\t// \t\tfprintf(stderr,\"x:%d y:%d\\n\",x[i],y[i]);\n\t// \treturn;\n\t// }\n\tinline int get(int x0)\n\t{\n\t\tint res=0,cur;\n\t\tregister int i,j;\n\t\tfor(i=1;i<=n;i++)\n\t\t{\n\t\t\tcur=1;\n\t\t\tfor(j=1;j<=n;j++)\n\t\t\t\tif(i!=j)\n\t\t\t\t\tcur=mul(cur,mul(sub(x0,x[j]),qpow(sub(x[i],x[j]),mod-2)));\n\t\t\tres=add(res,mul(cur,y[i]));\n\t\t}\n\t\treturn res;\n\t}\n}\nnamespace zkw\n{\n\tint M;\n\tint Min[N<<2],lazy[N<<2],cnt[N<<2];\n\tinline void push_up(int x)\n\t{\n\t\tMin[x]=min(Min[x<<1],Min[x<<1|1])+lazy[x];\n\t\tcnt[x]=(Min[x<<1]+lazy[x]==Min[x])*cnt[x<<1]+(Min[x<<1|1]+lazy[x]==Min[x])*cnt[x<<1|1];\n\t\treturn;\n\t}\n\tinline void build(int n)\n\t{\n\t\tregister int i;\n\t\tfor(M=1;M<=n;M<<=1);\n\t\tmemset(lazy,0,sizeof(int)*(M<<1));\n\t\tmemset(cnt,0,sizeof(int)*(M<<1));\n\t\tfor(i=1;i<=n;i++)\n\t\t\tMin[M+i]=0,cnt[M+i]=w[i];\n\t\tfor(i=M-1;i;i--)\n\t\t\tpush_up(i);\n\t\treturn;\n\t}\n\tinline void modify(int l,int r,int k)\n\t{\n\t\tfor(l=M+l-1,r=M+r+1;l^r^1;l>>=1,r>>=1,push_up(l),push_up(r))\n\t\t\t(l&1)?0:(Min[l^1]+=k,lazy[l^1]+=k),(r&1)?(Min[r^1]+=k,lazy[r^1]+=k):0;\n\t\tfor(l>>=1;l;l>>=1)\n\t\t\tpush_up(l);\n\t\treturn;\n\t}\n\tinline int query()\n\t{\n\t\treturn sw-(Min[1]==0)*cnt[1];\n\t}\n}\ninline int calc(int t)\n{\n\tint cl,cr,res=0;\n\tregister int i;\n\tVx.clear();Vy.clear();\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tVx.push_back(c[i].x-t);\n\t\tVx.push_back(c[i].x+t+1);\n\t\tVy.push_back(c[i].y-t);\n\t\tVy.push_back(c[i].y+t+1);\n\t}\n\tsort(Vx.begin(),Vx.end());\n\tVx.erase(unique(Vx.begin(),Vx.end()),Vx.end());\n\tsort(Vy.begin(),Vy.end());\n\tVy.erase(unique(Vy.begin(),Vy.end()),Vy.end());\n\tsw=0;\n\tfor(i=1;i<(int)Vy.size();i++)\n\t\tw[i]=Vy[i]-Vy[i-1],sw+=w[i];\n\tta.clear();\n\tfor(i=1;i<=n;i++)\n\t{\n\t\tcl=lower_bound(Vy.begin(),Vy.end(),c[i].y-t)-Vy.begin()+1;\n\t\tcr=lower_bound(Vy.begin(),Vy.end(),c[i].y+t+1)-Vy.begin();\n\t\tta.push_back(task{c[i].x-t,cl,cr,1});\n\t\tta.push_back(task{c[i].x+t+1,cl,cr,-1});\n\t}\n\tsort(ta.begin(),ta.end(),[](task a,task b)->bool\n\t{\n\t\treturn a.t\n#include \n\n#include \n#include \n#include \n\nusing namespace std;\n\nconst int MOD = 998244353;\n\ntypedef long long ll;\n#define tll(X) static_cast(X)\n#define ti(X) static_cast(X)\n\nint sum(int a, int b) {return ti((tll(a) + tll(b))%MOD);}\nint dif(int a, int b) {return ti((tll(a) - tll(b) + (tll(MOD)<<6LL))%MOD);}\nint prd(int a, int b) {return ti((tll(a) * tll(b))%MOD);}\nint sqr(int a) {return prd(a, a);}\nint pw(int b, int p) {\n int r = 1;\n for(;p;p>>=1, b=prd(b, b)) if(p&1) r = prd(r, b);\n return r;\n}\n\nint dv2;\nint sumlin(int v) {\n if(v < 0) return 0;\n return prd(prd(v, v + 1), dv2);\n}\nint sumlin(int l, int r) {\n return sumlin(r - 1) - sumlin(l - 1);\n}\nint dv6;\nint sumsqr(int v) {\n if(v < 0) return 0;\n return prd(prd(v, v + 1), prd((v << 1) + 1, dv6));\n}\nint sumsqr(int l, int r) {\n return sumsqr(r - 1) - sumsqr(l - 1);\n}\n\ntypedef array ar2;\ntypedef array ar3;\ntypedef vector vi;\ntypedef vector va2;\n\nint get(const ar3& a, int b) {\n return sum(prd(a[2], prd(b, b)), sum(prd(a[1], b), a[0]));\n}\nint get(const vi& a, int l, int r) {\n int f = 0;\n f = sum(f, prd(a[2], sumsqr(l, r)));\n f = sum(f, prd(a[1], sumlin(l, r)));\n f = sum(f, prd(a[0], r - l));\n return f;\n}\nar3 operator + (const ar3& a, const ar3& b) {\n return {sum(a[0], b[0]), sum(a[1], b[1]), sum(a[2], b[2])};\n}\n\ntypedef array pt;\ntypedef array ar4;\n\nconst int MAXN = 60;\nint N, T;\npt I[MAXN];\n\ntemplate void compress(T * n, int& s) {\n sort(n, n + s);\n s = unique(n, n + s) - n;\n}\n\nint y[MAXN << 1];\nint ys;\n\ntemplate struct ST {\npublic:\n ar2 v[MAXN];\n int z[MAXN];\n int s;\n ar2 cmb(const ar2& a, const ar2& b) {\n if(a[0] == b[0]) return {a[0], a[1] + b[1]};\n if(b[0] < a[0]) return b;\n return a;\n }\n void init(int n, int nl, int nr) {\n if(nr - nl > 1) {\n int m = nl + ((nr - nl)>>1);\n init(n<<1, nl, m); init(n<<1|1, m, nr);\n v[n] = {0, y[nr] - y[nl]}, z[n] = 0;\n } else v[n] = {0, y[nr] - y[nl]}, z[n] = 0;\n }\n void init(int S) {\n init(1, 0, s = S);\n }\n void prop(int n, int nl, int nr) {\n v[n][0] += z[n];\n if(nr - nl > 1)\n z[n<<1] += z[n], z[n<<1|1] += z[n];\n z[n] = 0;\n }\n void upd(int gl, int gr, int q, int n, int nl, int nr) {\n if(gl <= nl and nr <= gr) {\n z[n] += q;\n prop(n, nl, nr);\n } else {\n int m = nl + ((nr - nl)>>1);\n prop(n, nl, nr);\n if(gl < m) upd(gl, gr, q, n<<1, nl, m); else prop(n<<1, nl, m);\n if(m < gr) upd(gl, gr, q, n<<1|1, m, nr); else prop(n<<1|1, m, nr);\n v[n] = cmb(v[n<<1], v[n<<1|1]);\n }\n }\n void upd(int gl, int gr, int q) {return upd(gl, gr, q, 1, 0, s);}\n int qry() {prop(1, 0, s); return v[1][0] == 0 ? (y[s] - y[0]) - v[1][1] : (y[s] - y[0]);} //# of non-zeroes\n};\nST<> st;\nar4 x[MAXN << 1];\nint calc(int t) {\n for(int i = 0;i < N;i++) y[i<<1] = I[i][1] - t, y[i<<1|1] = I[i][1] + t + 1, x[i<<1] = {I[i][0] - t, I[i][1] - t, I[i][1] + t + 1, 1}, x[i<<1|1] = {I[i][0] + t + 1, I[i][1] - t, I[i][1] + t + 1, 0};\n compress(y, ys = N<<1);\n for(int i = 0;i < N<<1;i++) x[i][1] = lower_bound(y, y + ys, x[i][1]) - y, x[i][2] = lower_bound(y, y + ys, x[i][2]) - y;\n st.init(--ys);\n \n ll f = 0;\n \n sort(x, x + (N<<1), [](const ar4& a, const ar4& b){return a[0] < b[0];});\n \n int c = 0;\n for(int i = 0, j;i < N<<1;i=j) {\n for(j = i;j < N<<1 and x[i][0] == x[j][0];j++) {\n if(x[j][3]) st.upd(x[j][1], x[j][2], 1);\n else st.upd(x[j][1], x[j][2], -1);\n }\n if((c = st.qry())) f += tll(c) * (x[j][0] - x[i][0]);\n }\n return ti(f%MOD);\n}\n\nint operator * (const pt& a, const pt& b) {\n return max((1 + abs(a[0] - b[0]))>>1, (1 + abs(a[1] - b[1]))>>1);\n}\n\nint c[MAXN * MAXN];\n\nvi operator * (const vi& a, const vi& b) {\n vi r(a.size() + b.size() - 1, 0);\n for(int i = 0;i < a.size();i++) for(int j = 0;j < b.size();j++) r[i + j] = sum(r[i + j], prd(a[i], b[j]));\n return r;\n}\nvi operator *= (vi& a, const int& b) {\n for(int i = 0;i < a.size();i++) a[i] = prd(a[i], b);\n return a;\n}\nvi operator += (vi& a, const vi& b) {\n assert(not(a.size() < b.size()));\n for(int i = 0;i < b.size();i++) a[i] = sum(a[i], b[i]);\n return b;\n}\n\nvi interpolate(const va2& p) {\n vi r(p.size(), 0);\n for(int i = 0;i < p.size();i++) {\n vi n(1, 1);\n int d = 1;\n for(int j = 0;j < p.size();j++) if(j != i) {\n n = n * vi{dif(0, p[j][0]), 1};\n d = prd(d, dif(p[i][0], p[j][0]));\n }\n n *= prd(pw(d, MOD - 2), p[i][1]);\n assert(n.size() == r.size());\n r += n;\n }\n return r;\n}\n\nint solve(int t1, int t2) {\n if(t2 - t1 < 3) {\n int f = 0;\n for(int i = t1;i < t2;i++) f = sum(f, ti(calc(i)%MOD));\n return f;\n }\n \n vi q = interpolate(va2{{t1, calc(t1)}, {t1 + 1, calc(t1 + 1)}, {t1 + 2, calc(t1 + 2)}});\n //cerr << q[0] << \" \" << q[1] << \" \" << q[2] << \"\\n\";\n //cerr << get(q, t1, t2) << \"\\n\";\n return get(q, t1, t2);\n}\n\nint main() {\n dv2 = pw(2, MOD - 2);\n dv6 = pw(6, MOD - 2);\n \n scanf(\"%d%d\", &N, &T);\n for(int i = 0;i < N;i++) scanf(\"%d%d\", &I[i][0], &I[i][1]), y[i] = I[i][1];\n \n //sort(I, I + N, [](const pt& a, const pt& b) {return a[0] < b[0] or (not(b[0] < a[0]) and a[1] < b[1]);});\n \n for(int i = 0, t = 0;i < N;i++) for(int j = i + 1;j < N;j++) c[t++] = I[i] * I[j];\n sort(c, c + (N*(N - 1)>>1));\n ll f = 0LL;\n int p = 0;\n for(int i = 0;i < (N*(N-1))>>1;p = c[i++]) {\n if(c[i] < T) f = sum(f, solve(p, c[i])); else break;\n }\n f = sum(f, solve(p, T));\n \n printf(\"%d\\n\", dif(prd(T, calc(T)), f));\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a7005e391ab10ed97eb0ed0640eda079", "src_uid": "1b3f264b17723609b4493dc94f2ed45d", "difficulty": 3500.0} {"lang": "GNU C++11", "source_code": "#pragma GCC optimize(2)\n#pragma GCC optimize(3)\n#pragma GCC optimize(\"Ofast\")\n#include\n#include\n#include\n#include\n#include\n#define ls(_o) (_o<<1)\n#define rs(_o) ((_o<<1)|1)\n#define ll long long\n#define p 998244353\n#define abs(_o) ((_o<0)?-(_o):_o)\nusing namespace std;\nnamespace ywy{\n\tinline ll mi(int a,int b){\n\t\tll ans=1,tmp=a;while(b){\n\t\t\tif(b&1)ans=(ans*tmp)%p;tmp=(tmp*tmp)%p;b>>=1;\n\t\t}return(ans);\n\t}int lsh[300],cnt[300];int data[2001];\n\tinline void up(int tree,int l,int r){\n\t\tif(cnt[tree])data[tree]=lsh[r]-lsh[l-1];else data[tree]=data[ls(tree)]+data[rs(tree)];\n\t}\n\tvoid add(int rl,int rr,int l,int r,int tree,int x){\n\t\tif(rl==l&&rr==r){\n\t\t\tcnt[tree]+=x;if(!cnt[tree]){\n\t\t\t\tif(l==r)data[tree]=0;else data[tree]=data[ls(tree)]+data[rs(tree)];\n\t\t\t}else data[tree]=lsh[r]-lsh[l-1];return;\n\t\t}int mid=(l+r)>>1;if(rl>mid)add(rl,rr,mid+1,r,rs(tree),x);else{\n\t\t\tif(rr<=mid)add(rl,rr,l,mid,ls(tree),x);else{\n\t\t\t\tadd(rl,mid,l,mid,ls(tree),x);add(mid+1,rr,mid+1,r,rs(tree),x);\n\t\t\t}\n\t\t}up(tree,l,r);\n\t}ll inv2,inv6;\n\tinline ll sig2(ll n){\n\t\tll cjr=n;cjr*=(n+1);cjr%=p;cjr*=(n*2+1);cjr%=p;cjr*=inv6;return(cjr%p);\n\t}\n\tinline ll sig(ll n){\n\t\tll cjr=n;cjr*=(n-1);cjr%=p;cjr*=inv2;return(cjr%p);\n\t}\n\ttypedef struct _n{\n\t\tint l;int r;\n\t}node;vector adds[300],dels[300];\n\tinline void clear(vector &v){\n\t\tvector tmp;v=tmp;\n\t}int xs[60],ys[60];int n;\n\tvoid build(int l,int r,int tree){\n\t\tcnt[tree]=data[tree]=0;if(l==r)return;int mid=(l+r)>>1;build(l,mid,ls(tree));build(mid+1,r,rs(tree));\n\t}\n\tinline ll getS(int t){\n\t\tint ptr=1;for(register int i=1;i<=n;i++){\n\t\t\tlsh[ptr]=xs[i]-t-1;ptr++;lsh[ptr]=xs[i]+t;ptr++;lsh[ptr]=ys[i]-t-1;ptr++;lsh[ptr]=ys[i]+t;ptr++;\n\t\t}ptr--;sort(lsh+1,lsh+1+ptr);ptr=unique(lsh+1,lsh+1+ptr)-lsh-1;build(1,ptr,1);\n\t\tfor(register int i=1;i<=ptr;i++)clear(adds[i]),clear(dels[i]);\n\t\tfor(register int i=1;i<=n;i++){\n\t\t\tnode cjr;cjr.l=lower_bound(lsh+1,lsh+1+ptr,ys[i]-t-1)-lsh+1;\n\t\t\tcjr.r=lower_bound(lsh+1,lsh+1+ptr,ys[i]+t)-lsh;int l=lower_bound(lsh+1,lsh+1+ptr,xs[i]-t-1)-lsh;\n\t\t\tint r=lower_bound(lsh+1,lsh+1+ptr,xs[i]+t)-lsh;adds[l].push_back(cjr);dels[r].push_back(cjr);\n\t\t}ll ans=0;for(register int i=1;i<=ptr;i++){\n\t\t\tans=(ans+data[1]*(ll)(lsh[i]-lsh[i-1]))%p;\n\t\t\tfor(register int j=0;j>n>>t;\n\t\tfor(register int i=1;i<=n;i++)cin>>xs[i]>>ys[i];int ptr=1;for(register int i=1;i<=n;i++){\n\t\t\tfor(register int j=1;j\n#include \n#include \n#include \n\nusing namespace std;\n\nint const maxValue = 100'000;\n\nint scan()\n{\n int a;\n scanf(\"%d\", &a);\n return a;\n}\n\nstruct PositionsPair\n{\n int leftPosition = maxValue;\n int rightPosition = -1;\n\n void update(int position)\n {\n if (position < leftPosition)\n leftPosition = position;\n if (position > rightPosition)\n rightPosition = position;\n }\n};\n\nint main()\n{\n int const nZones = scan();\n int const start = scan() - 1;\n int const stop = scan() - 1;\n\n vector gates(nZones - 1);\n generate(begin(gates), end(gates), scan);\n\n vector keys(nZones);\n generate(begin(keys), end(keys), scan);\n\n vector distance(nZones, -1);\n distance[start] = 0;\n map availableKeys;\n availableKeys[keys[start]].update(start);\n int left = start;\n int right = start;\n\n while (left != stop && right != stop)\n {\n if (left > 0 && availableKeys.find(gates[left - 1]) != availableKeys.end())\n {\n int const position = availableKeys[gates[left - 1]].leftPosition;\n --left;\n distance[left] = max(distance[left + 1] + 1, distance[position] + position - left);\n availableKeys[keys[left]].update(left);\n }\n else if (right < nZones - 1 && availableKeys.find(gates[right]) != availableKeys.end())\n {\n int const position = availableKeys[gates[right]].rightPosition;\n ++right;\n distance[right] = max(distance[right - 1] + 1, distance[position] + right - position);\n availableKeys[keys[right]].update(right);\n }\n else\n {\n break;\n }\n }\n\n printf(\"%lld\\n\", distance[stop]);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "57fe7c66a8a34bb24e0f96efd360f6da", "src_uid": "fbd994944cfa06e4921aac227d9eaf31", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nconst int MAXN = 100009;\nint g[MAXN];\nint k[MAXN];\nconst int INF = 1000000000;\nint firstLeft[MAXN];\nint firstRight[MAXN];\nint firstNeedLeft[MAXN];\nint firstNeedRight[MAXN];\n\ninline int getMin(const set& s) {\n return *s.begin();\n}\n\ninline int getMax(const set& s) {\n auto it = s.end();\n --it;\n return *it;\n}\n\nint solve(int a, int b) {\n int i1 = 0;\n int i2 = b;\n set leftNeed, rightNeed;\n set valuesInLeft, valuesInRight;\n set finded;\n finded.insert(k[a]);\n for (int i = a + 1; i <= b; ++i) {\n if (finded.count(g[i - 1]) == 0 && rightNeed.count(g[i - 1]) == 0) {\n rightNeed.insert(g[i - 1]);\n firstNeedRight[g[i - 1]] = i - 1;\n valuesInLeft.insert(firstLeft[g[i - 1]]);\n }\n finded.insert(k[i]);\n }\n finded.clear();\n finded.insert(k[a]);\n for (int i = a - 1; i >= 0; --i) {\n if (finded.count(g[i]) == 0 && leftNeed.count(g[i]) == 0) {\n leftNeed.insert(g[i]);\n firstNeedLeft[g[i]] = i + 1;\n valuesInRight.insert(firstRight[g[i]]);\n }\n finded.insert(k[i]);\n }\n\n if (valuesInLeft.empty()) {\n return b - a;\n }\n if (getMin(valuesInLeft) < 0) {\n return -1;\n }\n\n unsigned long long ans = b - a;\n\n enum MoveType {\n MOVE_LEFT, MOVE_RIGHT\n };\n\n MoveType mt = MOVE_LEFT;\n\n int iter_br = 0;\n\n while (i1 < a && i2 > a) {\n if (mt == MOVE_LEFT) {\n if (valuesInLeft.empty()) {\n i1 = a;\n break;\n }\n int lft = getMin(valuesInLeft);\n if (lft < i1) {\n return -1;\n }\n if (lft == i1) {\n ++iter_br;\n } else {\n iter_br = 0;\n }\n if (iter_br > 4) {\n return -1;\n }\n for (int i = i1; i < lft; ++i) {\n if (firstNeedLeft[g[i]] == i + 1) {\n leftNeed.erase(g[i]);\n valuesInRight.erase(firstRight[g[i]]);\n }\n }\n i1 = lft;\n ans += 2 * (a - i1);\n mt = MOVE_RIGHT;\n } else {\n if (valuesInRight.empty()) {\n i2 = a;\n break;\n }\n int rght = getMax(valuesInRight);\n if (rght > i2) {\n return -1;\n }\n if (rght == i2) {\n ++iter_br;\n } else {\n iter_br = 0;\n }\n if (iter_br > 4) {\n return -1;\n }\n for (int i = i2; i > rght; --i) {\n if (firstNeedRight[g[i - 1]] == i - 1) {\n rightNeed.erase(g[i - 1]);\n valuesInLeft.erase(firstLeft[g[i - 1]]);\n }\n }\n i2 = rght;\n ans += 2 * (i2 - a);\n mt = MOVE_LEFT;\n }\n }\n\n return ans;\n}\n\nint main() {\n int n, a, b;\n cin >> n >> a >> b;\n --a;\n --b;\n for (int i = 0; i < n - 1; ++i) {\n scanf(\"%d\", &g[i]);\n }\n for (int i = 0; i < n; ++i) {\n scanf(\"%d\", &k[i]);\n }\n if (a > b) {\n a = n - a - 1;\n b = n - b - 1;\n reverse(k, k + n);\n reverse(g, g + n - 1);\n }\n\n fill(begin(firstLeft), end(firstLeft), -INF);\n fill(begin(firstRight), end(firstRight), INF);\n\n for (int i = a - 1; i >= 0; --i) {\n if (firstLeft[k[i]] == -INF) {\n firstLeft[k[i]] = i;\n }\n }\n for (int i = a + 1; i <= b; ++i) {\n if (firstRight[k[i]] == INF) {\n firstRight[k[i]] = i;\n }\n }\n\n cout << solve(a, b) << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "66440e81ac4cd4d8127c4b5b201f70b9", "src_uid": "fbd994944cfa06e4921aac227d9eaf31", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "#define _CRT_SECURE_NO_WARNINGS \nvoid Solve(); int main() { Solve(); }\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define int long long \n#define endl '\\n' \n#define fib(i, n) for (int i = n; i >= 0; i--) \n#define fi(i,a,b) for(int i = (a); i < (b); i++) \n#define MAX 1 << 10 \n#define pb push_back\n#define ll long long\n#define max(a,b) ((a)>(b)?(a):(b))\n#define min(a,b) ((a)<(b)?(a):(b))\n#define pii pair\nconst int maxn = (int)(3e5 + 11);\nconst ll inf = (ll)(1e15 + 7);\n\nint n, a, b, g[maxn], k[maxn], last[maxn];\nll dp[maxn];\nset < int > S[maxn];\n\nbool check(int x)\n{\n\treturn !S[x].empty() || last[x];\n}\n\nll solve1()\n{\n\tint r = a, p;\n\tlast[k[a]] = a;\n\twhile (r != n && check(g[r]))\n\t{\n\t\tr++;\n\t\tS[k[r]].ins(r);\n\t\tdp[r] = r - a;\n\t}\n\tp = a;\n\tif (r >= b)\n\t\treturn b - a;\n\n\tfor (int i = a - 1; i >= 1; --i)\n\t{\n\t\tint x = g[i];\n\t\tif (!check(x))\n\t\t\treturn inf;\n\t\tif (!last[x])\n\t\t{\n\t\t\tint j = *S[x].lower_bound(0);\n\t\t\tif (j < p) {\n\t\t\t\tdp[i] = dp[p] + p - i;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tp = j;\n\t\t\t\tdp[i] = dp[j] + j - i;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tdp[i] = dp[i + 1] + 1;\n\t\t}\n\t\tlast[k[i]] = i;\n\t\twhile (r != n && check(g[r]))\n\t\t{\n\t\t\tr++;\n\t\t\tdp[r] = dp[i] + r - i;\n\t\t\tS[k[r]].ins(r);\n\t\t}\n\t\tif (r >= b)\n\t\t\treturn dp[i] + b - i;\n\t}\n\treturn inf;\n}\nvoid Solve()\n{\n#ifdef _DEBUG \n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif \n\tios_base::sync_with_stdio(false);\n\tcin.tie(nullptr);\n\n\tcin >> n >> a >> b;\n\tfor (int i = 1; i < n; ++i)\n\t\tcin >> g[i];\n\tfor (int i = 1; i <= n; ++i)\n\t\tcin >> k[i];\n\tll ans;\n\tif (a < b)\n\t\tans = solve1();\n\telse\n\t{\n\t\treverse(g + 1, g + n);\n\t\treverse(k + 1, k + n + 1);\n\t\ta = n + 1 - a;\n\t\tb = n + 1 - b;\n\t\tans = solve1();\n\t}\n\n\tif (ans >= inf)\n\t\tcout << -1;\n\telse\n\t\tcout << ans;\n\t\n} ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ae50a764c4676ebeaaf253d1d749b4db", "src_uid": "fbd994944cfa06e4921aac227d9eaf31", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "/*\n _________________\n ____/:::::::::::::::::\\_____\n __/::::::::::::::::::::::::::::\\___\n _/:::::::::::::::::::::::::::::::::::\\__\n _/::::::::::::::::::::::::::::::::::::::::\\_\n /::::::::::::::::::::::::::::::::::::::::::::\\\n |::::::::::::::::::::::::::::::::::::::::::::::\\\n /::::::::::::::::::::::::::::::::::::::::::::::::\\\n |:::/.:::::::;:::::::::::::::::::::::::::::::::::::|\n /:::/.:::::::/..:::::::::::::::::::::::::::::::::::::\\\n |:::|.::::::;/.::::::::::::::::::::::::::::::::::::::::|\n |::/.::::::/..:::::::;;'.::::::::::::::::::::::::::::::|\n |:|.::::/./.::::::;;/..:::::::::::::::::::::::::::::::::|\n `:|.:::|.|.:::::;/..;;;;;;-'.:;;;-':::::::::::::::::::::|\n \\|.:::|.|.:::;/.;;/ -..::'''...:::::::::::::::::::::::|\n \\;;::|.|.::/.;/--__ |::::::::::::::::::::::::::::|\n \\;;\\\\::/|/ =-__ --_ /::::::::::::::::::::::::::::::\n \\\\/ /| -. |.::::::::::::::::::::::::::::::\n _.' /|' /= ||::::::::::::::::::::::::::::::\n _.-' //' ||::::::::::::::::::::::::::::::\n ( - `|::::::::::::::::::::::::::::::\n \\ \\:::::::::::::::::::::::::::::\n | (c)Kolansburg \\::::::::::::::::::::::::::::\n / __/:::::::::::::::::::::::::::\n \\ __/::;::;;:::::::::::::::::::::::\n (` /;;;;/::| \\::::::::::::::::::::::\n | |'_,::::/ \\ |::::::::::::::::::::::\n .' _/::::::/ / /:::::::::::::::. .::::\n | /.::;;:-'_)/_/::::::::::::::::...::::\n ----.__ | |.::| \\___/::::::::::::::::::...::::\n :::::::`----\\_____ \\:::\\.-'::::::::::::::::::::::...::::\n ;;;;;:::::::::::::`------ \\:::::::::::::::::::::::::::...::::\n `-------:::::::\\ /:::::::::::::::::::::::::::...::::\n ___.--------'::::::::\\ |::::::::::::::::::::::::::::...::::\n :::::;;;:--:::::::::::| /::::::::::::::::::::::::::::...::::\n ----' _,-:.:::::::::::\\ |.::::::::::::::::::::::::::::...::::\n __/.::::::::::::::::| |.::::::::::::::::::::::::::::...::::\n __/.:::;;::::::::;/.:::| |.::::::::::::::::::::::::::::. .::::\n /.::::;/ /.:::::;/ |.::::| \\_.:::::::::::::::::::::::::::::::::\n :::::/ /.:::::/ /.:::::| \\__.::::::::::::::::::::::::::::::\n ::::| |.:::::/ /.:::::.| \\,::::::::::::::::::::::::::::\n ::::| |.::::| |.:::::/| __/::::::::::::::::::::::::::::\n \\.:::\\ \\.:::| |.::::||| __.--::::::::::::::::::::::::::::::::\n \\.:::\\_ \\.:::\\ \\.:::'/.::::::::::::::::::::::::::::::::::::::\n \\.::::\\ \\.:::\\ \\.::::::::::::::::::::::::::::::::::::::::::\n*/\n \n#define _CRT_SECURE_NO_WARNINGS\n#define _USE_MATH_DEFINES\n \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \nusing namespace std;\n \n#define X first\n#define Y second\n\nconst long long MAXN = 300000 + 100;\n\nlong long n, a, b, g[MAXN], k[MAXN], itl, itr, las, slsize;\nvector sl, sr;\nvector gr;\nlong long used[MAXN];\nlong long nuzh[MAXN];\nlong long ans = 0;\nbool fl = true;\nset w;\nvector kol;\n\nvoid nach()\n{\n\tcin >> n >> a >> b;\n\tfor (long long i = 0; i + 1 < n; i++)\n\t{\n\t\tcin >> g[i];\n\t}\n\tfor (long long i = 0; i < n; i++)\n\t{\n\t\tcin >> k[i];\n\t}\n\ta--;\n\tb--;\n\tif (a > b)\n\t{\n\t\ta = n - 1 - a;\n\t\tb = n - 1 - b;\n\t\treverse(g, g + n - 1);\n\t\treverse(k, k + n);\n\t}\n}\n\nbool seach(long long cv)\n{\n\twhile (true)\n\t{\n\t\tused[itl]++;\n\t\tif (k[itl] == cv)\n\t\t{\n\t\t\treturn true;\n\t\t}\n\t\tif (itl == 0 || !used[g[itl - 1]])\n\t\t\treturn false;\n\t\titl--;\n\t}\n\treturn false;\n}\n\nbool gran()\n{\n\tnach();\n\tfill(used, used + MAXN, 0);\n\titr = a;\n\titl = a;\n\twhile (itr < b)\n\t{\n\t\tused[k[itr]]++;\n\t\tif (used[g[itr]] == 0)\n\t\t{\n\t\t\tif (!seach(g[itr]))\n\t\t\t{\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tsl.push_back(itl);\n\t\t\tsr.push_back(itr);\n\t\t}\n\t\titr++;\n\t}\n\treturn true;\n}\n\nvoid strogr()\n{\n\tfill(used, used + MAXN, 0);\n\tfill(nuzh, nuzh + MAXN, 0);\n\n\tslsize = sl.size();\n\n\tgr.push_back(sl.back());\n\n\titr = a;\n\twhile (itr <= sr[slsize - 1])\n\t{\n\t\tused[k[itr]]++;\n\t\titr++;\n\t}\n\titr--;\n\n\titl = a;\n\twhile (itl >= sl[slsize - 1])\n\t{\n\t\tused[k[itl]]++;\n\t\titl--;\n\t}\n\titl++;\n\n\tfor (long long i = slsize - 2; i >= 0; i--)\n\t{\n\t\twhile (itl < sl[i])\n\t\t{\n\t\t\tnuzh[g[itl]]++;\n\t\t\tkol.push_back(g[itl]);\n\t\t\tif (used[g[itl]] == 0)\n\t\t\t{\n\t\t\t\tw.insert(g[itl]);\n\t\t\t}\n\n\t\t\tused[k[itl]]--;\n\t\t\tif (used[k[itl]] == 0 && nuzh[k[itl]])\n\t\t\t{\n\t\t\t\tw.insert(k[itl]);\n\t\t\t}\n\t\t\titl++;\n\t\t}\n\n\t\twhile (itr > sr[i])\n\t\t{\n\t\t\tused[k[itr]]--;\n\t\t\tif (used[k[itr]] == 0 && nuzh[k[itr]])\n\t\t\t{\n\t\t\t\tw.insert(k[itr]);\n\t\t\t}\n\t\t\titr--;\n\t\t}\n\n\t\tif (w.size() != 0)\n\t\t{\n\t\t\tw.clear();\n\t\t\tfor (long long j = 0; j < kol.size(); j++)\n\t\t\t{\n\t\t\t\tnuzh[kol[j]] = 0;\n\t\t\t}\n\t\t\tkol.clear();\n\t\t\tgr.push_back(sl[i]);\n\t\t}\n\t}\n}\n\n\n\nlong long main()\n{\n#if _DEBUG\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#else\n\t//freopen(\"goat5.in\", \"r\", stdin);\n\t//freopen(\"goat5.out\", \"w\", stdout);\n#endif\n\tios_base::sync_with_stdio(0);\n\tif (!gran())\n\t{\n\t\tcout << -1;\n\t\treturn 0;\n\t}\n\n\tif (sr.size() == 0)\n\t{\n\t\tcout << b - a;\n\t\treturn 0;\n\t}\n\n\tstrogr();\n\n\tans = b - a;\n\n\tw.clear();\n\tfill(used, used + MAXN, 0);\n\titl = a;\n\titr = a;\n\twhile (gr.size())\n\t{\n\t\twhile (itl > gr.back())\n\t\t{\n\t\t\tused[k[itl]]++;\n\t\t\tif (!used[g[itl - 1]])\n\t\t\t{\n\t\t\t\twhile (true)\n\t\t\t\t{\n\t\t\t\t\tused[k[itr]]++;\n\t\t\t\t\tif (k[itr] == g[itl - 1])\n\t\t\t\t\t\tbreak;\n\t\t\t\t\titr++;\n\t\t\t\t}\n\t\t\t}\n\t\t\titl--;\n\t\t}\n\t\tans += (itr - gr.back()) * 2;\n\t\tgr.pop_back();\n\t}\n\tcout << ans;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e38a546c4bf380f50117f7939ac911e4", "src_uid": "fbd994944cfa06e4921aac227d9eaf31", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\n#define For(i,x,y) for(int i=(int)x;i<=(int)y;i++)\n#define pb push_back\n#define mk make_pair\n#define fi fisrt\n#define se second\ninline int read()\n{\n\tint x=0,c=getchar(),f=0;\n\tfor(;c>'9'||c<'0';f=c=='-',c=getchar());\n\tfor(;c>='0'&&c<='9';x=(x<<1)+(x<<3)+c-'0',c=getchar());\n\treturn f?-x:x;\n}\ninline void write(int x)\n{\n\tif(x<0)putchar('-'),x=-x;\n\tif(x>=10)write(x/10);\n\tputchar(x%10+48);\n}\ntypedef vector vi;\nconst int N=100000+10;\nint n,m,cnt=1,head[N],du[N],layer[N],leader[N],q[N];\nbool vis1[N],vis2[N],vis3[N*2];\nvectorans;\nvi tmp,_;\nvector >comp;\nstruct edge{int to,nxt;}e[N*4];\nvoid addedge(int u,int v)\n{\n\te[++cnt]=(edge){v,head[u]};head[u]=cnt;\n\te[++cnt]=(edge){u,head[v]};head[v]=cnt;\n\tdu[u]++;du[v]++;\n}\nvoid dfs(int u,int fa,int lineid)\n{\n\tvis1[u]=1;\n\tvis2[layer[u]]=1;\n\ttmp.pb(u);\n\tfor(int i=head[u],v;i;i=e[i].nxt)if((i>>1)!=lineid)\n\t{\n\t\tif(!vis1[v=e[i].to])\n\t\t{\n\t\t\tdfs(v,u,i>>1);\n\t\t\ttmp.pb(u);\n\t\t\tfor(;cnt>=0&&vis2[comp[cnt].se];cnt--);\n\t\t\tif(cnt>=0)\n\t\t\t{\n\t\t\t\tvis3[i>>1]=1;\n\t\t\t\tv=leader[comp[cnt].se];\n\t\t\t\tans.pb(tmp);tmp.clear();\n\t\t\t\t_.clear();_.pb(i>>1);_.pb(u);_.pb(v);\n\t\t\t\tans.pb(_);\n\t\t\t\tdfs(v,u,i>>1);\n\t\t\t\ttmp.pb(u);\n\t\t\t}\n\t\t}else\n\t\t{\n\t\t\tif(vis3[i>>1])continue;\n\t\t\tfor(;cnt>=0&&vis2[comp[cnt].se];cnt--);\n\t\t\tif(cnt>=0)\n\t\t\t{\n\t\t\t\tvis3[i>>1]=1;\n\t\t\t\tv=leader[comp[cnt].se];\n\t\t\t\tans.pb(tmp);tmp.clear();\n\t\t\t\t_.clear();_.pb(i>>1);_.pb(u);_.pb(v);\n\t\t\t\tans.pb(_);\n\t\t\t\tdfs(v,u,i>>1);\n\t\t\t\ttmp.pb(u);\n\t\t\t}\n\t\t}\n\t}\n}\nvoid print()\n{\n\tputs(\"YES\");write(ans.size()/2);puts(\"\");\n\tFor(i,0,ans.size()-1)\n\t{\n\t\tif(i&1)write(ans[i][0]),putchar(' '),write(ans[i][1]),putchar(' '),write(ans[i][2]),puts(\"\");else\n\t\t{\n\t\t\twrite(ans[i].size());\n\t\t\tFor(j,0,ans[i].size()-1)putchar(' '),write(ans[i][j]);\n\t\t\tputs(\"\");\n\t\t}\n\t}\n}\nint findbridge()\n{\n\tFor(i,1,n)vis1[i]=0;\n\tFor(i,1,m)vis3[i]=0;\n\tFor(i,2,n)if(!vis1[i])\n\t{\n\t\tq[*q]=i;vis1[i]=1;\n\t\tFor(j,1,*q)\n\t\t{\n\t\t\tint u=q[j];\n\t\t\tfor(int k=head[u],v;k;k=e[k].nxt)if(!vis3[k>>1])\n\t\t\t{\n\t\t\t\tvis3[k>>1]=1;\n\t\t\t\tif(vis1[v=e[k].to])return k>>1;else vis1[v]=1,q[++*q]=v;\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}\nint getblo(int l,int r)\n{\n\tFor(i,l,r)vis1[i]=0;\n\tint blo=0;\n\tcomp.clear();\n\tFor(i,l,r)if(!vis1[i])\n\t{\n\t\t++blo;\n\t\tq[*q=1]=i;vis1[i]=1;\n\t\tFor(j,1,*q)\n\t\t{\n\t\t\tint u=q[j];\n\t\t\tfor(int k=head[u],v;k;k=e[k].nxt)if(!vis1[v=e[k].to])vis1[v]=1,q[++*q]=v;\n\t\t}\n\t\tFor(j,1,*q)layer[q[j]]=blo;\n\t\tleader[blo]=q[1];\n\t\tcomp.pb(mk(*q,blo));\n\t}\n\tsort(comp.begin(),comp.end());\n\treturn blo;\n}\nvoid go(int id)\n{\n\tint u=1;\n\tFor(i,2,n)\n\t{\n\t\tfor(int j=head[i],pre;j;pre=j,j=e[j].nxt)if((j>>1)==id)\n\t \t{\n\t\t\tif(du[i]>1)u=i;\n\t\t\tif(j==head[i])head[i]=e[j].nxt;else e[pre].nxt=e[j].nxt;\n\t\t\tbreak;\n\t \t}\n\t}\n\tgetblo(2,n);\n\tcnt=comp.size()-1;\n\tFor(i,1,n)vis1[i]=vis2[i]=0;\n\tFor(i,1,m)vis3[i]=0;\n\tvis1[1]=1;\n\t_.clear();_.pb(1);ans.pb(_);\n\t_.clear();_.pb(id);_.pb(1);_.pb(u);ans.pb(_);\n\tdfs(u,1,0);\n\tif(tmp.size())ans.pb(tmp),tmp.clear();\n\tprint();\n}\nint main()\n{\n\tn=read(),m=read();\n\tFor(i,1,m)addedge(read(),read());\n\tif(n==1)return puts(\"YES\\n0\\n1 1\\n\"),0;\n\tint blo=getblo(1,n);\n\tif(m1){id=head[i]/2;break;}\n\t\t\t\tif(id)go(id);else puts(\"NO\");\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cdcb3bd2faa01f72a8933457f9c5c1c7", "src_uid": "35a3513c8fe730a64f30c5daec27df05", "difficulty": 2900.0} {"lang": "GNU C++", "source_code": "# #include \n# #include \n# #include \n# #include \n# #include \n# #include \n# #include \n# #include \n# #include \n# #include \n# #include \n# using namespace std;\n#\n\n# #define max_int INT_MAX / 2\n# #define max_long 0xFFFFFFFFFFFFFFFLL / 2\n# #define two(a) (1 << (a))\n# #define eps 1e-6\n# #define FF(i, a, b) for (int i = (a); i <= (b); i++)\n# #define FFD(i, a, b) for (int i = (a); i >= (b); i--)\n#\n\n# struct Edge {\n# int u, v;\n# bool changed;\n# Edge() {}\n# Edge(int u, int v) : u(u), v(v), changed(false) {}\n# };\n#\n\n# int n, m;\n# vector edges;\n# vector edgeList[100010];\n#\n\n# void AddEdge(int u, int v) {\n# int k = edges.size();\n# edgeList[u].push_back(k);\n# edgeList[v].push_back(k);\n# edges.push_back(Edge(u, v));\n# }\n#\n\n# struct Component {\n# int root;\n# int numEdges;\n# int numV;\n# int extraEdge;\n# \n# Component() {\n# root = numEdges = numV = 0;\n# extraEdge = -1;\n# }\n#\n\n# bool operator <(const Component & x) const {\n# if (numEdges - numV == x.numEdges - x.numV) return numEdges > x.numEdges;\n# else return numEdges - numV > x.numEdges - x.numV;\n# }\n# };\n#\n\n# int numComps, comp[100010];\n# vector components;\n#\n\n# vector > moveSteps;\n# vector > moveEdges;\n# bool vis[100010];\n# int startComp, nextComp;\n#\n\n#\n\n\n# void dfs(int u, int father) {\n# comp[u] = numComps;\n# int numChild = 0;\n# for (int i = 0; i < edgeList[u].size(); i++) {\n# int e = edgeList[u][i];\n# if (e == father) continue;\n# int v = (edges[e].u == u) ? edges[e].v : edges[e].u;\n# if (comp[v] == -1) {\n# dfs(v, e);\n# numChild += 1;\n# } else components.back().extraEdge = e;\n# }\n# if (numChild == 0 && father != -1 && components.back().extraEdge == -1) {\n# if (edges[father].v != u) swap(edges[father].u, edges[father].v);\n# components.back().extraEdge = father;\n# }\n# }\n#\n\n# void travel(int u, int father) {\n# if (vis[u]) return;\n# vis[u] = true;\n# if (father == -1) moveSteps.push_back(vector ()); \n# moveSteps.back().push_back(u);\n# for (int i = 0; i < edgeList[u].size(); i++) {\n# int e = edgeList[u][i];\n# if (e == father || edges[e].changed) continue;\n# int v = (edges[e].u == u) ? edges[e].v : edges[e].u;\n# if (vis[v] == 0) {\n# travel(v, e);\n# moveSteps.back().push_back(u);\n# }\n# if (edges[e].changed == 0 && nextComp < components.size()) {\n# edges[e].changed = 1;\n# int w = components[nextComp].root;\n# vector tmp;\n# tmp.push_back(e + 1);\n# tmp.push_back(u);\n# tmp.push_back(w);\n# moveEdges.push_back(tmp);\n# nextComp += 1;\n# moveSteps.push_back(vector ());\n# travel(w, e);\n# moveSteps.back().push_back(u);\n# }\n# }\n# }\n#\n\n# int main(int argc, char** argv) {\n# \n# cin >> n >> m;\n# edges.clear();\n# for (int i = 1; i <= n; i++) edgeList[i].clear();\n# \n# int e, u, v;\n# for (int i = 1; i <= m; i++) { \n# cin >> u >> v;\n# AddEdge(u, v);\n# }\n#\n\n# components.clear();\n# numComps = 0;\n# memset(comp, -1, sizeof(comp));\n# for (int i = 1; i <= n; i++) {\n# if (comp[i] != -1) continue;\n# components.push_back(Component());\n# components.back().root = i;\n# dfs(i, -1);\n# numComps += 1;\n# }\n# for (int i = 1; i <= n; i++) {\n# components[comp[i]].numV += 1;\n# components[comp[i]].numEdges += edgeList[i].size();\n# }\n# for (int i = 0; i < components.size(); i++) {\n# components[i].numEdges /= 2;\n# }\n#\n\n# startComp = 0;\n# nextComp = 1;\n# memset(vis, 0, sizeof(vis));\n# if (components.size() > 1) {\n# sort(components.begin() + 1, components.end());\n# }\n# moveSteps.clear();\n# moveEdges.clear();\n# vector tmp;\n# if (components[0].numV == 1) {\n# if (n == 1) {\n# cout << \"YES\" << endl;\n# cout << \"0\" << endl;\n# cout << \"1 1\" << endl;\n# return 0;\n# }\n# if (components[1].extraEdge == -1) {\n# cout << \"NO\" << endl;\n# return 0;\n# } else {\n# tmp.clear();\n# tmp.push_back(1);\n# moveSteps.push_back(tmp);\n# e = components[1].extraEdge;\n# v = edges[e].u;\n# tmp.clear();\n# tmp.push_back(e + 1);\n# tmp.push_back(1);\n# tmp.push_back(v);\n# moveEdges.push_back(tmp);\n# startComp = 1;\n# components[1].root = v;\n# vis[1] = true;\n# edges[e].changed = true;\n# if (components[1].numEdges + 1 == components[1].numV) {\n# components.push_back(Component());\n# components.back().root = edges[e].v;\n# components.back().numV = 1;\n# }\n# }\n# }\n# nextComp = startComp + 1;\n# travel(components[startComp].root, -1);\n# for (int i = 1; i <= n; i++) if (vis[i] == 0) {\n# cout << \"NO\" << endl;\n# return 0;\n# }\n# cout << \"YES\" << endl;\n# cout << moveEdges.size() << endl;\n# if (moveEdges.size() == moveSteps.size())\n# moveSteps.push_back(vector ());\n# for (int i = 0; i < moveEdges.size(); i++) {\n# cout << moveSteps[i].size() << \" \";\n# for (int j = 0; j < moveSteps[i].size(); j++)\n# cout << moveSteps[i][j] << \" \";\n# cout << endl;\n# for (int j = 0; j < moveEdges[i].size(); j++)\n# cout << moveEdges[i][j] << \" \";\n# cout << endl;\n# }\n# cout << moveSteps.back().size() << \" \";\n# for (int j = 0; j < moveSteps.back().size(); j++)\n# cout << moveSteps.back()[j] << \" \";\n# cout << endl;\n# \n# return (EXIT_SUCCESS);\n# }\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bf9a1af2eef5bbfd577527410a8f019a", "src_uid": "35a3513c8fe730a64f30c5daec27df05", "difficulty": 2900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int maxN = 101000;\n\nint n, m;\nvector g[maxN];\nmap, int> edges;\nint used[2 * maxN];\n\nvector onev;\nset unused;\nvector > ans;\n\nvector cur;\n\nvector update(vector buf) {\n vector ret;\n ret.push_back(buf.size());\n for (int i = 0; i < buf.size(); ++i) {\n ret.push_back(buf[i]);\n }\n return ret;\n}\n\nvoid dfs2(int v) {\n unused.erase(v);\n for (int i = 0; i < g[v].size(); ++i) {\n if (unused.count(g[v][i])) {\n dfs2(g[v][i]);\n }\n }\n}\n\nvoid dfs(int v, int p = -1) {\n dfs2(v);\n vector nodes;\n used[v] = 1;\n for (int i = 0; i < g[v].size(); ++i) {\n if (!used[g[v][i]]) {\n nodes.push_back(g[v][i]);\n used[g[v][i]] = 1;\n }\n }\n\n cur.push_back(v);\n\n for (int i = 0; i < g[v].size(); ++i) {\n if (used[g[v][i] && g[v][i] != p) {\n if (onev.size() > 0) {\n int t = onev.back();\n onev.pop_back();\n int index = edges[make_pair(v, g[v][i])];\n ans.push_back(update(cur));\n cur.clear();\n vector nv;\n nv.push_back(index);\n nv.push_back(v);\n nv.push_back(t);\n ans.push_back(nv);\n cur.push_back(t);\n cur.push_back(v);\n } else if (unused.size() > 0) {\n int t = *unused.begin();\n ans.push_back(update(cur));\n int index = edges[make_pair(v, g[v][i])];\n cur.clear();\n\n vector nv;\n nv.push_back(index);\n nv.push_back(v);\n nv.push_back(t);\n ans.push_back(nv);\n dfs(t);\n cur.push_back(v);\n }\n }\n }\n\n for (int i = 0; i < nodes.size(); ++i) {\n dfs(nodes[i], v);\n cur.push_back(v);\n if (i + 1 != nodes.size()) {\n if (onev.size() > 0) {\n int t = onev.back();\n onev.pop_back();\n int index = edges[make_pair(v, nodes[i])];\n ans.push_back(update(cur));\n cur.clear();\n vector nv;\n nv.push_back(index);\n nv.push_back(v);\n nv.push_back(t);\n ans.push_back(nv);\n cur.push_back(t);\n cur.push_back(v);\n } else if (unused.size() > 0) {\n int t = *unused.begin();\n ans.push_back(update(cur));\n int index = edges[make_pair(v, nodes[i])];\n cur.clear();\n\n vector nv;\n nv.push_back(index);\n nv.push_back(v);\n nv.push_back(t);\n ans.push_back(nv);\n dfs(t);\n cur.push_back(v);\n }\n } else {\n if ((unused.size() == 0 && onev.size() > 0) || (p != -1 && onev.size() > 0)) {\n int t = onev.back();\n onev.pop_back();\n int index = edges[make_pair(v, nodes[i])];\n ans.push_back(update(cur));\n cur.clear();\n vector nv;\n nv.push_back(index);\n nv.push_back(v);\n nv.push_back(t);\n ans.push_back(nv);\n cur.push_back(t);\n cur.push_back(v);\n } else if (unused.size() > 0) {\n int t = *unused.begin();\n ans.push_back(update(cur));\n int index = edges[make_pair(v, nodes[i])];\n cur.clear();\n\n vector nv;\n nv.push_back(index);\n nv.push_back(v);\n nv.push_back(t);\n ans.push_back(nv);\n dfs(t);\n cur.push_back(v);\n }\n }\n }\n}\n\nint main() {\n //freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n\n scanf(\"%d%d\", &n, &m);\n for (int i = 0; i < m; ++i) {\n int x, y;\n scanf(\"%d%d\", &x, &y);\n g[x].push_back(y);\n g[y].push_back(x);\n edges[make_pair(x, y)] = i + 1;\n edges[make_pair(y, x)] = i + 1;\n }\n\n for (int i = 1; i <= n; ++i) {\n if (g[i].size() == 0) {\n onev.push_back(i);\n } else {\n unused.insert(i);\n }\n }\n\n if (g[1].size() == 0) {\n if (n == 1) {\n cout << \"YES\" << endl;\n cout << \"0\" << endl;\n cout << \"1 1\" << endl;\n return 0;\n } else {\n cout << \"NO\" << endl;\n return 0;\n }\n }\n dfs(1);\n\n ans.push_back(update(cur));\n\n if (unused.size() == 0 && onev.size() == 0) {\n printf(\"YES\\n\");\n printf(\"%d\\n\", (int)(ans.size()) / 2);\n for (int i = 0; i < ans.size(); ++i) {\n for (int j = 0; j < ans[i].size(); ++j) {\n printf(\"%d \", ans[i][j]);\n }\n printf(\"\\n\");\n }\n } else {\n printf(\"NO\\n\");\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ad44848da3c52ae26cc8d537e486d3d5", "src_uid": "35a3513c8fe730a64f30c5daec27df05", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nvectoradj[110000],as[110000],to[110000];\nvectorcan[110000];\nint n,m,list[110000],cnt_list,pa[110000],ps[110000],cnt,e[2][220000],idx[2][220000],sk[110000],cnt_sk;\nbool vis[110000],us[220000];\nvectornow[110000];\nint num_step,root;\nvectorans[110000];\nint stk[3][110000];\nvoid dfs(int id)\n{\n int ip,i,j,s,p,q,cn,ix;\n vis[id]=true;\n now[cnt].push_back(id);\n if(root==0)\n ans[num_step].push_back(id);\n for(i=0;i=0;i--)\n ans[num_step].push_back(sk[i]);\n}\nbool merge(int id)\n{\n int ix,ip,i,j,s,p,q,id1,id2,ie,choose,ch,pre;\n for(i=cnt_list-1;i>=0;i--)\n {\n ip=list[i];\n for(j=0;j=adj[ip].size())\n {\n for(j=0;j=0) \n {\n ip=list[cnt_list-1];\n bool ok=false;\n if(ps[choose]==as[choose][ch])\n {\n stk[0][num_step]=as[choose][ch];\n stk[1][num_step]=adj[choose][ch];\n stk[2][num_step]=now[id][0];\n ip=ans[num_step].size();\n ip--;\n if(ans[num_step][ip]!=now[id][0]) \n go(ans[num_step][ip],adj[choose][ch]);\n else \n ok=true;\n ip=adj[choose][ch];\n if(ok)\n {\n now[cnt].push_back(choose);\n ps[choose]=-1;\n pa[choose]=-1;\n cnt++;\n \n }\n }\n else\n {\n stk[0][num_step]=as[choose][ch];\n stk[1][num_step]=choose;\n stk[2][num_step]=now[id][0];\n ip=ans[num_step].size();\n ip--;\n if(ans[num_step][ip]!=now[id][0])\n go(ans[num_step][ip],choose);\n else\n ok=true;\n ip=choose;\n }\n //if(ok)\n // printf(\"choose=%d,ip=%d\\n\",choose,ip);\n ie=as[choose][ch];\n can[e[0][ie]][idx[0][ie]]=false;\n can[e[1][ie]][idx[1][ie]]=false;\n us[ie]=true;\n e[0][ie]=ip;\n e[1][ie]=now[id][0];\n idx[0][ie]=adj[ip].size();\n idx[1][ie]=adj[now[id][0]].size();\n adj[ip].push_back(now[id][0]);\n adj[now[id][0]].push_back(ip);\n as[ip].push_back(ie);\n as[now[id][0]].push_back(ie);\n can[ip].push_back(true);\n can[now[id][0]].push_back(true);\n // if(ok)\n // printf(\"ip=%d\\n\",ip);\n pa[now[id][0]]=ip;\n ps[now[id][0]]=ie;\n num_step++;\n if(ok)\n {\n ip=ans[num_step-1].size();\n ip--;\n // printf(\"orz=%d,now[id][0]=%d\\n\",ans[num_step-1][ip],now[id][0]);\n //printf(\"pa[now[id][0]=%d\\n\",pa[now[id][0]]);\n // printf(\"list[0]=%d\\n\",list[0]);\n go(ans[num_step-1][ip],list[0]);\n list[cnt_list++]=now[id][0];\n now[id].clear();\n for(i=0;i=0)\n {\n ip=pre;\n while(ip!=pa[now[id][i]])\n {\n ip=pa[ip];\n ans[num_step].push_back(ip);\n }\n }\n if(!ok||i!=0)\n ans[num_step].push_back(now[id][i]);\n pre=now[id][i];\n }\n }\n else\n {\n if(now[id].size()==1)\n return false;\n cnt_list=0;\n for(i=0;i=2)\n merge(i);\n }\n if(i>=cnt)\n {\n for(i=1;i\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\nusing namespace std;\r\nstring rt[110]={\"\",\"\",\"\",\"the\",\"\",\"buffy\",\"slayer\",\"vampire\"};\r\nint main()\r\n{\r\n\tstring s;\r\n\tcin >> s;\r\n\tif(strlen(s)==4){\r\n\t\tcout << \"none\";\r\n\t\texit(0);\r\n\t}\r\n\telse{\r\n\t\tfor(int i=0;i\r\n#include \r\n#include \r\n#include \r\n//#pragma GCC optimize(\"Ofast\")\r\n//#pragma GCC optimize(\"unroll-loops\")\r\n//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native\") //bad\r\n//#pragma GCC target(\"avx,avx2\")\r\n#define ll long long\r\n#define ull unsigned ll\r\n#define ff first\r\n#define ss second\r\n#define int ll\r\n#define all(v) v.begin(), v.end()\r\n#define rall(v) v.rbegin(), v.rend()\r\n#define pb push_back\r\n#define pii pair \r\n#define pdd pair \r\n#define vi vector \r\nusing namespace std;\r\nusing namespace __gnu_pbds;\r\ntemplate using ordered_set = tree, rb_tree_tag,tree_order_statistics_node_update>;\r\nconst ll inf = 1e15;\r\nconstexpr ll mod = 998244353;\r\n//constexpr ll mod = 1e9+7;\r\nconst int N = 3e5+100, B = 430;\r\nint sq(int a){ return a * a; }\r\n\r\nvoid solve(){\r\n\tstring s, t = \"vampire\"s, t2 = \"buffy\"s, t3 = \"slayer\", t4 = \"the\";\r\n\tcin >> s;\r\n int pp = s.size();\r\n\tif (pp == 7){\r\n\t\tstring t=\"\";\r\n\t\tfor (int i = 0;i < 7; ++i) t+=((char)('a'+(s[i]-'a'+t1[i]-'a')%26));\r\n\t\tcout << t;\r\n\t}\r\n\telse if (pp == 5){\r\n\t\tstring t=\"\";\r\n\t\tfor (int i = 0; i < 5; ++i) t+=((char)('a'+(s[i]-'a'+t2[i]-'a')%26));\r\n\t\tcout << t;\r\n\t}\r\n\telse if (pp == 6){\r\n\t\tstring t = \"\";\r\n\t\tfor (int i = 0; i < 6; ++i) t += ((char)('a'+(s[i]-'a'+t3[i]-'a')%26));\r\n\t\tcout << t;\r\n\t}\r\n\telse if (pp == 3){\r\n\t\tstring t = \"\";\r\n\t\tfor (int i = 0; i < 3; ++i) t += ((char)('a'+(s[i]-'a'+t4[i]-'a')%26));\r\n\t\tcout << t;\r\n\t}\r\n\telse cout << \"none\";\r\n}\r\n \r\nsigned main(){\r\n ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);\r\n int tt = 1;\r\n\t//cin >> tt;\r\n while (tt--){\r\n solve();\r\n cout << '\\n';\r\n }\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f4d25897445fed669ae4d0566e120188", "src_uid": "56ec50526a3843fe3784d395850f45ae", "difficulty": -1.0} {"lang": "GNU C++20 (64)", "source_code": "/*******************************\n| Author: tiger2005\n| Problem: F. In Every Generation...\n| Contest: April Fools Day Contest 2022\n| URL: https://codeforces.com/contest/1663/problem/F\n| When: 2022-04-01 22:35:09\n| \n| Memory: 256 MB\n| Time: 1000 ms\n*******************************/\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n// #define FREAD_OPTION\n\n#ifdef FREAD_OPTION\n\t#define MAXBUFFERSIZE 1000000\n\tinline char fgetc(){static char buf[MAXBUFFERSIZE+5],*p1=buf,*p2=buf;return p1==p2&&(p2=(p1=buf)+fread(buf,1,MAXBUFFERSIZE,stdin),p1==p2)?EOF:*p1++;}\n\t#undef MAXBUFFERSIZE\n\t#define getchar fgetc\n#endif \n#define gc getchar\nstruct IOReader{\n\ttemplate inline IOReader& operator >> (T& a){a=0;bool flg=false;char ch=gc();while(ch<'0' || ch>'9'){if(ch=='-')\tflg^=1;ch=gc();}while(ch>='0' && ch<='9'){a=(a<<3)+(a<<1)+(ch^'0');ch=gc();}if(flg)\ta=-a;return *this;}\n\tinline IOReader& operator >> (string& a){a.clear();char ch=gc();while(isspace(ch) && ch!=EOF)\tch=gc();while(!isspace(ch) && ch!=EOF)\ta+=ch,ch=gc();return *this;}\n\tinline IOReader& operator >> (char* a){\n\t\t#ifdef FREAD_OPTION\n\t\t\tchar ch=gc();while(isspace(ch) && ch!=EOF)\tch=gc();while(!isspace(ch) && ch!=EOF)\t*(a++)=ch,ch=gc();*a='\\0';\n\t\t#else\n\t\t\tscanf(\" %s\",a);\n\t\t#endif\n\t\treturn *this;\n\t}\n\tinline IOReader& operator >> (char &a){a=gc();while(isspace(a))\ta=gc();return *this;}\n\t#define importRealReader(type) inline IOReader& operator >> (type& a){a=0;bool flg=false;char ch=gc();while((ch<'0' || ch>'9') && ch!='.'){if(ch=='-')flg^=1;ch=gc();}while(ch>='0' && ch<='9'){a=a*10+(ch^'0');ch=gc();}if(ch=='.'){ch=gc();type p=0.1;while(ch>='0' && ch<='9'){a+=p*(ch^'0');ch=gc();p*=0.1;}}if(flg)\ta=-a;return *this;}\n\timportRealReader(float) importRealReader(double) importRealReader(long double)\n\t#undef importRealReader\n}iocin;\n#define cin iocin\n#define importReadInteger(type, name) type name(){type a=0;bool flg=false;char ch=gc();while(ch<'0' || ch>'9'){if(ch=='-')\tflg^=1;ch=gc();}while(ch>='0' && ch<='9'){a=(a<<3)+(a<<1)+(ch^'0');ch=gc();}if(flg)\ta=-a;return a;}\nimportReadInteger(int, readInt) importReadInteger(unsigned int, readUInt) importReadInteger(long long, readLL) importReadInteger(unsigned long long, readULL) importReadInteger(short, readShort) importReadInteger(unsigned short, readUShort)\n#undef importReadInteger\n#define importReadDecimal(type, name) type name(){type a=0;bool flg=false;char ch=gc();while((ch<'0' || ch>'9') && ch!='.'){if(ch=='-')flg^=1;ch=gc();}while(ch>='0' && ch<='9'){a=a*10+(ch^'0');ch=gc();}if(ch=='.'){ch=gc();type p=0.1;while(ch>='0' && ch<='9'){a+=p*(ch^'0');ch=gc();p*=0.1;}}if(flg) a=-a;return a;}\nimportReadDecimal(float, readFL) importReadDecimal(double, readDB) importReadDecimal(long double, readLDB)\n#undef importReadDecimal\n\n#define readI(l,r,A) for(int tiger2005=l;tiger2005<=r;tiger2005++) iocin >> A[tiger2005]\n#define outA(l,r,A,sp)\tfor(int tiger2005=l;tiger2005<=r;tiger2005++) printf(sp,A[tiger2005])\n#define outV(A,sp) for(auto tiger2005:A) printf(sp,tiger2005)\ninline void yOn(bool x){printf(\"%s\", (x) ? \"Yes\" : \"No\");}\ninline void yOn(bool x, char* str){printf(\"%s%s\", (x) ? \"Yes\" : \"No\", str);}\ninline void yOn(bool x, char str){printf(\"%s%c\", (x) ? \"Yes\" : \"No\", str);}\ninline void yOn(bool x, const char* str){printf(\"%s%s\", (x) ? \"Yes\" : \"No\", str);}\ninline void yOn(bool x, string str){printf(\"%s%s\", (x) ? \"Yes\" : \"No\", str.c_str());}\ninline void YON(bool x){printf(\"%s\", (x) ? \"YES\" : \"NO\");}\ninline void YON(bool x, char* str){printf(\"%s%s\", (x) ? \"YES\" : \"NO\", str);}\ninline void YON(bool x, char str){printf(\"%s%c\", (x) ? \"YES\" : \"NO\", str);}\ninline void YON(bool x, const char* str){printf(\"%s%s\", (x) ? \"YES\" : \"NO\", str);}\ninline void YON(bool x, string str){printf(\"%s%s\", (x) ? \"YES\" : \"NO\", str.c_str());}\n#define rep(i, l, r) for(auto i = (l); i <= (r); i ++)\n#define per(i, r, l) for(auto i = (r); i >= (l); i --)\n#define openFile(a) freopen(a\".in\",\"r\",stdin),freopen(a\".out\",\"w\",stdout)\n#define closeFile() fclose(stdin),fclose(stdout)\n#define ALL(x) std::begin(x), std::end(x)\n#define multiCase() int totCases; iocin >> totCases; for(int currCase = 1; currCase <= totCases; currCase++)\ntypedef long long LL;\n#undef gc\n\nextern int Md;\n\nnamespace modular {\n\nstruct Z{\n\tint val;\n\tZ(long long x = 0): val(x % Md){\n\t\tif(val < 0)\tval += Md;\n\t}\n\tint getMod(){\n\t\treturn Md;\n\t}\n\tint powVal(long long y) const{\n\t\tlong long ret = 1, bas = val;\n\t\twhile(y){\n\t\t\tif(y & 1)\n\t\t\t\t(ret *= bas) %= Md;\n\t\t\t(bas *= bas) %= Md;\n\t\t\ty >>= 1;\n\t\t}\n\t\treturn (int)ret;\n\t}\n\tZ pow(long long y) const{\n\t\tZ ret = 1, bas(*this);\n\t\twhile(y){\n\t\t\tif(y & 1)\n\t\t\t\tret *= bas;\n\t\t\tbas *= bas;\n\t\t\ty >>= 1;\n\t\t}\n\t\treturn ret;\n\t}\n\tZ inv() const{\n\t\treturn pow(Md - 2);\n\t}\n\tint invVal() const{\n\t\treturn powVal(Md - 2);\n\t}\n\tZ operator + () const{\n\t\tZ ret; ret.val = val; return ret;\n\t}\n\tZ operator - () const{\n\t\tZ ret; ret.val = Md - val;\n\t\tif(ret.val >= Md) ret.val -= Md;\n\t\treturn ret;\n\t}\n\n\tZ operator += (const Z& z){\n\t\tif((val += z.val) >= Md)\n\t\t\tval -= Md;\n\t\treturn *this;\n\t}\n\tZ operator -= (const Z& z){\n\t\tif((val -= z.val) < 0)\n\t\t\tval += Md;\n\t\treturn *this;\n\t}\n\tZ operator *= (const Z& z){\n\t\tval = (long long)val * z.val % Md;\n\t\treturn *this;\n\t}\n\tZ operator /= (const Z& z){\n\t\tval = (long long)val * z.invVal() % Md;\n\t\treturn *this;\n\t}\n \tfriend Z operator + (const Z & lhs,\n\t\tconst Z & rhs) {\n\t\treturn Z(lhs) += rhs;\n\t}\n\tfriend Z operator - (const Z & lhs,\n\t\tconst Z & rhs) {\n\t\treturn Z(lhs) -= rhs;\n\t}\n\tfriend Z operator * (const Z & lhs,\n\t\tconst Z & rhs) {\n\t\treturn Z(lhs) *= rhs;\n\t}\n\tfriend Z operator / (const Z & lhs,\n\t\tconst Z & rhs) {\n\t\treturn Z(lhs) /= rhs;\n\t}\n\tfriend bool operator == (const Z & lhs,\n\t\tconst Z & rhs) {\n\t\treturn lhs.val == rhs.val;\n\t}\n\tfriend bool operator != (const Z & lhs,\n\t\tconst Z & rhs) {\n\t\treturn lhs.val != rhs.val;\n\t}\n\tZ & operator++() {\n\t\tif((++ val) >= Md)\n\t\t\tval -= Md;\n\t\treturn *this;\n\t}\n\tZ & operator--() {\n\t\tif((-- val) < 0)\n\t\t\tval += Md;\n\t\treturn *this;\n\t}\n\tZ operator++(int) {\n\t\tZ result( * this);* this += 1;\n\t\treturn result;\n\t}\n\tZ operator--(int) {\n\t\tZ result( * this);* this -= 1;\n\t\treturn result;\n\t}\n\tfriend std::ostream & operator << (std::ostream & os,\n const Z & m) {\n return os << m.val;\n }\n friend std::istream & operator >> (std::istream & is, Z & m) {\n long long x;\n is >> x;\n m = x;\n return is;\n }\n friend IOReader & operator >> (IOReader & is, Z & m) {\n long long x;\n is >> x;\n m = x;\n return is;\n }\n bool operator < (const Z& z) const{\n \treturn val < z.val;\n }\n bool operator == (const Z& z) const{\n \treturn val == z.val;\n }\n};\n\n}\n\nnamespace math_basis {\n\ntemplate \nstruct Factors{\n\tint n;\n\tvector facts;\n\tFactors(int x = 0){\n\t\tn = 0;\n\t\tfacts.assign(1, 1);\n\t\tassign(x);\n\t}\n\tvoid assign(int x){\n\t\twhile(n < x){\n\t\t\t++ n;\n\t\t\tfacts.push_back(facts.back() * n);\n\t\t}\n\t}\n\tT operator[](int x){\n\t\treturn facts[x];\n\t}\n};\n\nstruct Inv{\n\tusing Z = modular::Z;\n\tvector invs;\n\tint n = 0;\n\tInv(int x = 1){\n\t\tn = 1;\n\t\tinvs.assign(2, 1);\n\t\tassign(x);\n\t}\n\tvoid assign(int x){\n\t\twhile(n < x){\n\t\t\t++ n;\n\t\t\tinvs.push_back(Z(invs[Md % n]) * (Md - Md / n));\n\t\t}\n\t}\n\tZ operator [](int x){\n\t\treturn invs[x];\n\t}\n};\n\nstruct Inv_Factors{\n\tusing Z = modular::Z;\n\tInv invs;\n\tvector invfs;\n\tint n = 0;\n\tInv_Factors(int x = 1){\n\t\tn = 1;\n\t\tinvs.assign(1);\n\t\tinvfs.assign(2, 1);\n\t\tassign(x);\n\t}\n\tvoid assign(int x){\n\t\tinvs.assign(x);\n\t\twhile(n < x){\n\t\t\t++ n;\n\t\t\tinvfs.push_back(invs[n] * invfs.back());\n\t\t}\n\t}\n\tZ operator [](int x){\n\t\treturn invfs[x];\n\t}\n};\n\nstruct Binom_facts{\n\tusing Z = modular::Z;\n\tFactors f;\n\tInv_Factors invf;\n\tint n = 0;\n\tBinom_facts(int x = 1){\n\t\tn = 1;\n\t\tassign(x);\n\t}\n\tvoid assign(int x){\n\t\tf.assign(x); invf.assign(x);\n\t}\n\tZ get(int x, int y){\n\t\tif(x < y || y < 0)\n\t\t\treturn 0;\n\t\tassign(x);\n\t\treturn f[x] * invf[y] * invf[x-y];\n\t}\n};\n\ntemplate \nstruct Binom_bf{\n\tint n = 0;\n\tBinom_bf(){\n\t\tn = 1;\n\t}\n\tT get(int x, int y){\n\t\tif(x < y || y < 0)\n\t\t\treturn 0;\n\t\tT ret(1);\n\t\tfor(int i = x; i >= (x - y + 1); i --)\n\t\t\tret = ret * i / (x - i + 1);\n\t\treturn ret;\n\t}\n};\n\n}\n\nnamespace graph {\n\nstruct UnionSet{\n\tint n;\n\tvector fa;\n\tUnionSet(int n = 0): n(n){\n\t\tfa.assign(n+1, 0);\n\t\tfor(int i=1; i<=n; i++)\n\t\t\tfa[i] = i;\n\t}\n\tint getF(int x){\n\t\treturn x == fa[x] ? x : fa[x] = getF(fa[x]);\n\t}\n\tvoid link(int x, int y){\n\t\tx = getF(x); y = getF(y);\n\t\tif(x != y)\n\t\t\tfa[x] = y;\n\t}\n\tint operator [] (const int& x){\n\t\treturn getF(x);\n\t}\n};\n\nstruct Graph{\n\tint n, m;\n\tvector > ft;\n\tbool dirt;\n\tGraph(int n=0, int m=0, bool dirt=false)\n\t\t:n(n), m(m), dirt(dirt){\n\t\tft.assign(n+1, vector{});\n\t}\n\tvoid init(){\n\t\tfor(int i=1, a, b; i<=m; i++){\n\t\t\tcin >> a >> b;\n\t\t\tft[a].emplace_back(b);\n\t\t\tif(!dirt)\n\t\t\t\tft[b].emplace_back(a);\n\t\t}\n\t}\n\tvector& operator [] (const int& x){\n\t\treturn ft[x];\n\t}\n};\n\ntemplate \nstruct GraphLength{\n\tint n, m;\n\tvector > > ft;\n\tbool dirt;\n\tGraphLength(int n=0, int m=0, bool dirt=false)\n\t\t:n(n), m(m), dirt(dirt){\n\t\tft.assign(n+1, vector >{});\n\t}\n\tvoid init(){\n\t\tT c;\n\t\tfor(int i=1, a, b; i<=m; i++){\n\t\t\tcin >> a >> b >> c;\n\t\t\tft[a].emplace_back(b, c);\n\t\t\tif(!dirt)\n\t\t\t\tft[b].emplace_back(a, c);\n\t\t}\n\t}\n\tvector >& operator [] (const int& x){\n\t\treturn ft[x];\n\t}\n};\n\n}\n\ntemplate \nstruct HashTable{\n\tvector val;\n\tvoid add(T x) { val.push_back(x); }\n\tvoid init() { sort(ALL(val)); val.erase(unique(ALL(val)), val.end()); }\n\tint query(T x) { return lower_bound(ALL(val), x) - val.begin() + 1; }\n\tT operator [] (const int t) const { return val[t-1]; }\n\tint size() { return val.size(); }\n};\n\nusing Z = modular::Z;\nusing Fact = math_basis::Factors;\nusing Inv = math_basis::Inv;\nusing Invf = math_basis::Inv_Factors;\nusing Binom = math_basis::Binom_facts;\nusing Binom_bf = math_basis::Binom_bf;\nusing Union = graph::UnionSet;\nusing Graph = graph::Graph;\nusing GraphL = graph::GraphLength;\nconst int Md3 = 998244353, Md7 = 1e9 + 7, Md9 = 1e9 + 9;\nint Md = Md3;\n\n// #include \n// #include \n// #include \n// #include \n// #include \n// #include \nstring s;\nstring t[10] = {\"vampire\", \"demon\", \"one\", \"slayer\"};\n\nint main(){\n\tcin >> s;\n\tfor(int z=0; t[z] != \"\"; z ++) if(t[z].size == s.size()){\n\t\tfor(int i=0; i<(int)s.size(); i++){\n\t\t\tint a = s[i] - 'a';\n\t\t\tint b = t[z][i] - 'a';\n\t\t\ta = (a + b) % 26;\n\t\t\ts[i] = a + 'a';\n\t\t}\n\t\tcout << s;\n\t}\n\tprintf(\"none\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9e6943bd7187aa4999c55b2766282765", "src_uid": "56ec50526a3843fe3784d395850f45ae", "difficulty": -1.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define pb push_back\n#define mp make_pair\ntypedef pair pii;\ntypedef long long ll;\ntypedef double ld;\ntypedef vector vi;\n#define fi first\n#define se second\n#define fe first\n#define FO(x) {freopen(#x\".in\",\"r\",stdin);freopen(#x\".out\",\"w\",stdout);}\n#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}\n#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}\n#define es(x,e) (int e=fst[x];e;e=nxt[e])\n#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])\n#define SZ 666666\nint n,x[SZ],y[SZ];\nvector A,B; pii g;\npii operator + (pii a,pii b)\n{return pii(a.fi+b.fi,a.se+b.se);}\npii operator - (pii a,pii b)\n{return pii(a.fi-b.fi,a.se-b.se);}\nll operator * (pii a,pii b)\n{return a.fi*(ll)b.se-a.se*(ll)b.fi;}\nll len(pii x) {return x.fi*(ll)x.fi+x.se*(ll)x.se;}\nbool cmp_g(pii a,pii b)\n{\n\tif(a==g) return b!=g;\n\tif(b==g) return 0;\n\tlong double aa=atan2l(a.se-g.se,a.fi-g.fi),\n\tbb=atan2l(b.se-g.se,b.fi-g.fi);\n\tif(fabsl(aa-bb)>1e-10)\n\t return aa graham(vector v)\n{\n\tvector s; g=pii(2e9,2e9);\n\tfor(auto r:v) g=min(g,r);\n\tsort(v.begin(),v.end(),cmp_g);\n\tv.erase(unique(v.begin(),v.end()),v.end());\n\tpii st[SZ]; int sn=0;\n\tfor(auto x:v)\n\t{\n\t\twhile(sn>=2&&(x-st[sn-1])*(st[sn]-st[sn-1])>=0)\n\t\t\t--sn;\n\t\tst[++sn]=x;\n\t}\n\tfor(int i=1;i<=sn;++i)\n\t\ts.pb(st[i]);\n\treturn s;\n}\nbool in(pii a,pii b,pii c,pii z)\n{\n\treturn abs(cross(a,b,c))\n\t==abs(cross(a,b,z))\n\t+abs(cross(b,c,z))\n\t+abs(cross(a,c,z));\n}\n#define WIN {puts(\"Ani\"); return 0;}\nbool chk(pii a,pii b,pii c)\n{\n\tll t=cross(a,b,c);\n\tif(t>0) return 0;\n\tif(t==0)\n\t\treturn min(a.fi,c.fi)<=b.fi\n\t\t&&b.fi<=max(a.fi,c.fi)\n\t\t&&min(a.se,c.se)<=b.se\n\t\t&&b.se<=max(a.se,c.se);\n\treturn 1;\n}\nint nr(vector& v,pii p)\n{\n\tint n=v.size();\n\tif(n==1)\n\t{\n\t\tif(p!=v[0]) return -1;\n\t\treturn 0;\n\t}\n\tif(n==2)\n\t{\n\t\tif(min(v[0].fi,v[1].fi)<=p.fi\n\t\t&&p.fi<=max(v[0].fi,v[1].fi)\n\t\t&&min(v[0].se,v[1].se)<=p.se\n\t\t&&p.se<=max(v[0].se,v[1].se)\n\t\t&&(p-v[0])*(v[1]-v[0])==0)\n\t\t\treturn 0;\n\t\treturn -1;\n\t}\n//\tcerr<<\"QAQ\"<0) return -1;\n//\tif(cross(v[0],p,v[n-1])<0) return -1;\n//\tcerr<<\"++\\n\";\n\tint i=2,j=n-1,g=n-1;\n\twhile(i<=j)\n\t{\n\t\tint m=(i+j)>>1;\n\t\tif(cross(v[0],p,v[m])>0)\n\t\t\tg=m,j=m-1;\n\t\telse i=j+1;\n\t}\n//\tcerr<<\"--\\n\";\n\tif(!chk(v[g-1],p,v[g])) return -1;\n\treturn g;\n}\nint main()\n{\n\tscanf(\"%d\",&n);\n\tbool z=0;\n\tfor(int i=1;i<=n;++i)\n\t{\n\t\tscanf(\"%d%d\",x+i,y+i);\n\t\tz|=x[i]==0&&y[i]==0;\n\t\tif((x[i]%2==1)||(y[i]%2==1))\n\t\t\tB.pb(pii(x[i],y[i]));\n\t\telse A.pb(pii(x[i],y[i]));\n\t}\n\tif(!B.size())\n\t{\n\t\tputs(\"Borna\");\n\t\treturn 0;\n\t}\n\tif(!z) A.pb(pii(0,0));\n\tvector G=graham(A);\n\tint gn=G.size();\n\tif(G.size()<=1) WIN\n//\tfor(auto t:G)\n//\t\tcerr< eA[SZ],eB[SZ];\n\tset sG;\n\tfor(auto t:G) sG.insert(t);\n\tfor(auto t:A) if(!sG.count(t))\n\t{\n\t\tint g=nr(G,t);\n\t\tif(g==-1) throw \"GG\";\n\t\tset tc;\n\t\tfor(int j=-30;j<=30;++j)\n\t\t\ttc.insert(((g+j)%gn+gn)%gn);\n\t\tfor(int j=-30;j<=30;++j)\n\t\t\ttc.insert(((0+j)%gn+gn)%gn);\n\t\tint ww=-1;\n\t\tfor(auto w:tc)\n\t\t\tif(in(G[w],G[(w+1)%gn],G[(w+2)%gn],t))\n\t\t\t\tww=w;\n\t\tif(ww==-1) continue;\n\t\tint www=ww;\n\t\tset sc;\n\t\tsc.insert(ww);\n\t\twhile(1)\n\t\t{\n\t\t\tww=(ww+1)%gn;\n\t\t\tif(sc.count(ww)) break;\n\t\t\tif(!in(G[ww],G[(ww+1)%gn],G[(ww+2)%gn],t))\n\t\t\t\tbreak;\n\t\t\tsc.insert(ww);\n\t\t}\n\t\tww=www;\n\t\twhile(1)\n\t\t{\n\t\t\tww=(ww+gn-1)%gn;\n\t\t\tif(sc.count(ww)) break;\n\t\t\tif(!in(G[ww],G[(ww+1)%gn],G[(ww+2)%gn],t))\n\t\t\t\tbreak;\n\t\t\tsc.insert(ww);\n\t\t}\n\t\tfor(auto w:sc)\n\t\t\teA[w].pb(t);\n\t}\n\tfor(auto t:B)\n\t{\n\t\tint g=nr(G,t);\n//\t\tcerr< tc;\n\t\tfor(int j=-30;j<=30;++j)\n\t\t\ttc.insert(((g+j)%gn+gn)%gn);\n\t\tfor(int j=-30;j<=30;++j)\n\t\t\ttc.insert(((0+j)%gn+gn)%gn);\n\t\tint ww=-1;\n\t\tfor(auto w:tc)\n\t\t\tif(in(G[w],G[(w+1)%gn],G[(w+2)%gn],t))\n\t\t\t\tww=w;\n\t\tif(ww==-1) continue;\n\t\tint www=ww;\n\t\tset sc;\n\t\tsc.insert(ww);\n\t\twhile(1)\n\t\t{\n\t\t\tww=(ww+1)%gn;\n\t\t\tif(sc.count(ww)) break;\n\t\t\tif(!in(G[ww],G[(ww+1)%gn],G[(ww+2)%gn],t))\n\t\t\t\tbreak;\n\t\t\tsc.insert(ww);\n\t\t}\n\t\tww=www;\n\t\twhile(1)\n\t\t{\n\t\t\tww=(ww+gn-1)%gn;\n\t\t\tif(sc.count(ww)) break;\n\t\t\tif(!in(G[ww],G[(ww+1)%gn],G[(ww+2)%gn],t))\n\t\t\t\tbreak;\n\t\t\tsc.insert(ww);\n\t\t}\n\t\tfor(auto w:sc)\n\t\t\teB[w].pb(t);\n\t}\n//\tcerr<<\"++\\n\";\n\tfor(int i=0;i v;\n\t\tv.pb(G[i]); v.pb(G[(i+2)%gn]);\n\t\tfor(auto t:eA[i]) v.pb(t);\n\t\tv=graham(v);\n//\t\tcerr<\n#include\n#include\nusing namespace std;\n#define int long long\nstruct Point{\n\tint x,y,s;\n\tbool operator<(Point b)const{\n\t\tif(x==b.x)return y1&&slope(point[sta[top]]-point[sta[top-1]],point[i]-point[sta[top]])<=0)--top;\n\t\t\tsta[++top]=i;\n\t\t}\n\tint k=top;\n\tfor(int i=n;i>=0;i--)\n\t\tif(point[i].s^1){\n\t\t\twhile(top>k&&slope(point[sta[top]]-point[sta[top-1]],point[i]-point[sta[top]])<=0)--top;\n\t\t\tsta[++top]=i;\n\t\t}\n}\nbool solve(){\n\tint Top=top;\n\tfor(int i=1;i<=Top;i++){\n\t\td[i]=sta[i];\n\t\tif((point[d[i]].x|point[d[i]].y)&1)\n\t\t\treturn 1;\n\t}\n\tfor(int i=2;i<=Top-1;i++)\n\t\tif(i&1)point[d[i]].s=1;\n\t\telse point[d[i]].s=2;\n\tbuild();\n\tint p=0;\n\tfor(int i=2;i<=top;i++)\n\t\tif((point[sta[i]].x|point[sta[i]].y)&1)\n\t\t\treturn 1;\n\tfor(int i=2;i<=Top-1;i++)\n\t\tif(i&1)point[d[i]].s=2;\n\t\telse point[d[i]].s=1;\n\tbuild();\n\tfor(int i=2;i<=top;i++)\n\t\tif((point[sta[i]].x|point[sta[i]].y)&1)\n\t\t\treturn 1;\n\treturn 0;\n}\nsigned main(){\n\tscanf(\"%lld\",&n);\n\tfor(int i=1;i<=n;i++)\n\t\tscanf(\"%lld%lld\",&point[i].x,&point[i].y);\n\tsort(point,point+n+1);\n\tbuild();\n\tif(solve())puts(\"Ani\");\n\telse puts(\"Borna\");\t\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "24fa114fc5a184e161519e8faaa90985", "src_uid": "a7b35fee982e41c075c87135a62c3a0d", "difficulty": 3400.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\ntemplate inline void read(T &x){\n\tx=0; register char c=getchar(); register bool f=0;\n\twhile(!isdigit(c))f^=c=='-',c=getchar();\n\twhile(isdigit(c))x=x*10+c-'0',c=getchar(); if(f)x=-x;\n}\nconst int N=4e5+10;\nstruct node{\n\tint x,y;\n\tinline node operator-(const node &rhs)const{\n\t\treturn {x-rhs.x,y-rhs.y};\n\t}\n\tinline long long operator*(const node &rhs)const{\n\t\treturn (long long)x*rhs.y-(long long)y*rhs.x;\n\t}\n\tinline bool operator<(const node &rhs)const{\n\t\tdouble tem=atan2(y,x)-atan2(rhs.y,rhs.x);\n\t\treturn tem==0?x x,y;\n\tfor(int i=1;i<=n;i++){\n\t\tx.push_back(a[i].x);\n\t\ty.push_back(a[i].y);\n\t}\n\tauto make=[&](vector &vec){\n\t\tsort(vec.begin(),vec.end(),[](int a,int b){return a>b;});\n\t\t// vec.erase(unique(vec.begin(),vec.end()),vec.end()); \u81ea\u4f5c\u806a\u660e\uff01\n\t\t// printf(\"%d %d\\n\",vec.size()?vec[0]:-1,vec.size()>1?vec[1]:-1);\n\t\tif(vec.size()&&(vec[0]&1))quit();\n\t\tif(vec.size()>1&&(vec[1]&1))quit();\n\t};\n\tmake(x),make(y);\n}\nvector convex(int l,int r){\n\tvector stk;\n\tauto top=[&](){return a[stk.back()];};\n\tauto nxt=[&](){return a[stk[stk.size()-2]];};\n\tfor(int i=l;i<=r;i++){\n\t\twhile(stk.size()>1&&(top()-nxt())*(a[i]-nxt())<=0)stk.pop_back();\n\t\tstk.push_back(i);\n\t}\n\treturn stk;\n}\nint main(){\n#ifdef memset0\n\t// freopen(\"1.in\",\"r\",stdin);\n#endif\n\tread(n);\n\tfor(int i=1;i<=n;i++)read(a[i].x),read(a[i].y);\n\tfor(int i=1;i<=n;i++)if(!a[i].x&&!a[i].y)std::swap(a[i],a[n]),--n,--i;\n\tsolveSimple();\n\tfor(int i=0;i<=n;i++)a[i+n+1]=a[i];\n\tvector con=convex(0,n);\n\tfor(int i:con)printf(\"con %d : %d %d\\n\",i,a[i].x,a[i].y);\n\tfor(int i:con)if((a[i].x|a[i].qy)&1)quit();\n\tfor(int i=0;i cur=convex(con[i],i+2\n#include \n#include \n\nint n;\nstruct point{\n\tlong long x,y;\n}num[400010],tem[400010],bb[400010];\npoint operator-(point a,point b){return (point){a.x-b.x,a.y-b.y};}\nlong long operator*(point a,point b){return a.x*b.y-a.y*b.x;}\nbool cmp2(point a,point b){return (a*b)<0||((a*b)==0&&a.x1&&(num[i]-num[stk[top-1]])*(num[stk[top]]-num[stk[top-1]])<=0){\n//\t\t\tprintf(\"-%d %d\\n\",num[stk[top]].x,num[stk[top]].y);\n\t\t\tif(add)tem[++ttop]=num[stk[top]];\n\t\t\t--top;\n\t\t} \n\t\tstk[++top]=i;\n\t}\n//\tputs(\"\");\n//\tfor(int i=1;i<=top;i++)printf(\"%d %d\\n\",num[stk[i]].x,num[stk[i]].y);\n\tfor(int i=1;i<=top;i++){\n\t\tif(num[stk[i]].x%2==1||num[stk[i]].y%2==1){\n\t\t\tputs(\"Ani\");\n\t\t\texit(0);\n\t\t}\n\t}\n}\nint main(){\n//\tfreopen(\"in.txt\",\"r\",stdin);\n//\tfreopen(\"out.txt\",\"w\",stdout);\n\tscanf(\"%d\",&n);\n\tfor(int i=1,x,y;i<=n;i++){\n\t\tscanf(\"%d%d\",&num[i].x,&num[i].y);\n\t}\n\tgethull(n,num,1);\n//\tputchar('*');\n//\tfor(int i=1;i<=ttop;i++)printf(\"%d %d\\n\",tem[i].x,tem[i].y);\n\tmemcpy(tstk,stk,sizeof stk);\n\tint now=ttop,siz=top;\n\tmemcpy(bb,tem,sizeof tem);\n\tfor(int i=1;i<=siz;i+=2)bb[++now]=num[tstk[i]];\n\tgethull(now,bb,0);\n\tfor(int i=2;i<=siz;i+=2)tem[++ttop]=num[tstk[i]];\n\tgethull(ttop,tem,0);\n\tputs(\"Borna\");\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "686159353c646b75ab4ea1e635a2e42b", "src_uid": "a7b35fee982e41c075c87135a62c3a0d", "difficulty": 3400.0} {"lang": "GNU C++11", "source_code": "/*\nAuthor: QAQ Automaton\nLang: C++\nProg: E.cpp\nMail: lk@qaq-am.com\nBlog: https://www.qaq-am.com/\n*/\n#include\n#include\n#define int long long\n#define debug(...) fprintf(stderr,__VA_ARGS__)\n#define DEBUG printf(\"Passing [%s] in LINE %d\\n\",__FUNCTION__,__LINE__)\n#define Debug debug(\"Passing [%s] in LINE %d\\n\",__FUNCTION__,__LINE__)\n#define all(x) x.begin(),x.end()\n#define x first\n#define y second \nusing namespace std;\ntypedef long long ll;\ntypedef pair pii;\nconst double eps=1e-8;\nconst double pi=acos(-1.0);\ntemplateint chkmin(T &a,T b){return a>b?a=b,1:0;}\ntemplateint chkmax(T &a,T b){return aT sqr(T a){return a*a;}\ntemplateT mmin(T a,T b){return aT mmax(T a,T b){return a>b?a:b;}\ntemplateT aabs(T a){return a<0?-a:a;}\ntemplateint dcmp(T a,T b){return a>b;}\ntemplateint cmp_a(int x,int y){return a[x] '9'; c = gc()) if (c == '-') f = -1;else if(c==EOF)return 0;\n\t\tfor (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;\n\t\treturn 1;\n\t}\n\n\tinline bool read (long long &x) {\n\t\tfor (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;else if(c==EOF)return 0;\n\t\tfor (x = 0; c <= '9' && c >= '0'; c = gc()) x = x * 10 + (c & 15); x *= f;\n\t\treturn 1;\n\t}\n\tinline bool read (char &x) {\n\t\tx=gc();\n\t\treturn x!=EOF;\n\t}\n\tinline bool read(char *x){\n\t\twhile((*x=gc())=='\\n' || *x==' '||*x=='\\r')if(*x==EOF)return 0;\n\t\twhile(!(*x=='\\n'||*x==' '||*x=='\\r'||*x==EOF))*(++x)=gc();\n\t\t*x=0;\n\t\treturn 1;\n\t}\n\ttemplate\n\tinline bool read(A &x,B &...y){\n\t\treturn read(x)&&read(y...);\n\t}\n\t// print a signed integer\n\tinline bool write (signed x) {\n\t\tif (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;\n\t\twhile (x) qu[++ qr] = x % 10 + '0', x /= 10;\n\t\twhile (qr) putc (qu[qr --]);\n\t\treturn 0;\n\t}\n\n\tinline bool write (long long x) {\n\t\tif (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;\n\t\twhile (x) qu[++ qr] = x % 10 + '0', x /= 10;\n\t\twhile (qr) putc (qu[qr --]);\n\t\treturn 0;\n\t}\n\tinline bool write (char x) {\n\t\tputc(x);\n\t\treturn 0;\n\t}\n\tinline bool write(const char *x){\n\t\twhile(*x){putc(*x);++x;}\n\t\treturn 0;\n\t}\n\tinline bool write(char *x){\n\t\twhile(*x){putc(*x);++x;}\n\t\treturn 0;\n\t}\n\ttemplate\n\tinline bool write(A x,B ...y){\n\t\treturn write(x)||write(y...);\n\t}\n\t//no need to call flush at the end manually!\n\tstruct Flusher_ {~Flusher_(){flush();}}io_flusher_;\n}\nusing io :: read;\nusing io :: putc;\nusing io :: write;\nint inf;\nstruct _init_{\n _init_(){\n memset(&inf,0x3f,sizeof(inf));\n }\n};\n_init_ ___INIT__;\nint a[11][11],n;\nint f[11][131];\nint is[131],i100;\nconst int p=1000000007;\nint fpm(int a,int b){int c=1;for(;b;b>>=1,a=a*a%p)if(b&1)c=c*a%p;return c;}\n#define lll unsigned __int128\nmap st[8];\nlll mx;\nint dfs(int x,lll w){\n\tif(x==n)return w==mx;\n\tif(st[x].count(w))return st[x][w];\n\tint ans=0;\n\tlll ng=0;\n\n\tint s[n];\n\tfor(int j=0;j\nusing namespace std;\n\n#define rep(i, n) for (int i = 0; i < int(n); i++)\n#define Rep(i, n) for (int i = 1; i <=int(n); i++)\n#define range(x) begin(x), end(x)\n#ifdef __LOCAL_DEBUG__\n#define _debug(fmt, ...) fprintf(stderr, \"[%s] \" fmt \"\\n\", __func__, ##__VA_ARGS__)\n#else\n#define _debug(...) ((void) 0)\n#endif\ntypedef long long LL;\ntypedef unsigned long long ULL;\n\nconst LL mod = 1'000'000'007;\n\nLL powmod(LL b, LL e) {\n LL r = 1;\n while (e) {\n if (e & 1) r = r * b % mod;\n b = b * b % mod;\n e >>= 1;\n }\n return r;\n}\n\nLL p[7][7];\ntypedef bitset<128> smask_t;\n\nstruct cmp {\n bool operator () (smask_t m1, smask_t m2) {\n return reinterpret_cast<__uint128_t&>(m1) < \n reinterpret_cast<__uint128_t&>(m2);\n }\n};\n\nint main() {\n rep (i, 7) p[i][i] = 1;\n LL inv100 = powmod(100, mod - 2);\n int n; scanf(\"%d\", &n);\n rep (i, n) rep (j, n) {\n LL pp; scanf(\"%lld\", &pp);\n p[i][j] = pp * inv100 % mod;\n }\n map cur; \n smask_t init; init[0] = true;\n cur[init] = 1;\n rep (i, 7) {\n map nmask;\n rep (mask, 1 << 7) {\n LL pr = 1;\n for (int j = 0; j < 7; j++) {\n if (mask & (1 << j)) pr = pr * p[i][j] % mod;\n else pr = pr * (mod + 1 - p[i][j]) % mod;\n }\n for (auto& pv : cur) {\n smask_t newmask;\n for (int ori = 0; ori < (1 << 7); ori++) if (pv.first[ori]) \n rep (j, 7) if (mask & (1 << j)) if (~ori & (1 << j)) \n newmask[ori | (1 << j)] = true;\n auto& val = nmask[newmask];\n val = (val + pv.second * pr) % mod;\n }\n }\n cur = move(nmask);\n }\n smask_t fin; fin[0b1111111] = true;\n cout << cur[fin] << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2296d8911238a23692d518707f09f30a", "src_uid": "ccfa3251dbf956761609f1e5ed771e58", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#include \n \nusing namespace std;\n#define pb push_back\ntypedef __uint128_t LL;\nconst int N=7e4+5,S=128,mo=1e9+7,iv=570000004;\n \nmap hs;int tot;\nint adj[N][S],st[S];\nint n,vis[N];\nint f[8][8];\nint g[128][9];\nint op[8][N];\nint br[S],mx[N],ans;\n \nint finder(LL u) {\n\tif (!hs[u]) return hs[u]=++tot;\n\telse return hs[u];\n}\nint dfs(int id,LL cur) {\n\tvis[id]=true;\n\tfor (int j=0;j<(1<>j)&1) mx[id]=max(mx[id],br[j]);\n\tfor (int s=0;s<(1<>i)&1) {\n\t\t\tfor (int j=0;j<(1<>j)&1) ncur|=LL(1)<<(j|(1<>1]+(i&1);\n\ths[1]=++tot;dfs(1,1);\n\tfor (int j=1;j<=n;j++)\n\tfor (int k=0;k<(1<>i)&1) g[k][j]=1ll*g[k][j]*f[i][j]%mo;\n\t\telse g[k][j]=g[k][j]*(1ll+mo-f[i][j])%mo;\n\t}\n\top[1][1]=1;\n\tfor (int i=1;i<=n;i++)\n\tfor (int j=1;j<=tot;j++)\n\tfor (int k=0;k<(1<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define pb push_back\n#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pii;\ntypedef pair pll;\ntypedef __int128_t state_t;\n\nconst int N = 10, M = 128, mod = 1e9 + 7;\nconst state_t one = 1;\n\n\nstate_t reach[M][M];\nmap dp, nxt;\nll p[N][N], pre_prob[N][M];\n\nvoid pre_calc(int n);\nll pwr(ll x, ll e);\n\nint main() {\n\tfast_cin();\n\tint n; cin >> n;\n\tfor (int i = 0; i < n; ++i) {\n\t\tfor (int j = 0; j < n; ++j) {\n\t\t\tcin >> p[i][j];\n\t\t\tp[i][j] *= pwr(100, mod - 2);\n\t\t\tp[i][j] %= mod;\n\t\t}\n\t}\n\tpre_calc(n);\n\tint tot = (1 << n);\n\tdp[1] = 1;\n\tfor (int i = 0; i < n; ++i) {\n\t\tfor (auto &temp : dp) {\n\t\t\tstate_t cur = temp.first;\n\t\t\tfor (int nmask = 0; nmask < tot; ++nmask) {\n\t\t\t\tstate_t s = 0;\n\t\t\t\tll prob = (temp.second * pre_prob[i][nmask]) % mod;\n\t\t\t\tfor (int mask = 0; mask < tot; ++mask) {\n\t\t\t\t\tif (cur & (one << mask)) {\n\t\t\t\t\t\ts |= reach[nmask][mask];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnxt[s] += prob;\n\t\t\t\tnxt[s] %= mod;\n\t\t\t}\n\t\t}\n\t\tdp = nxt;\n\t\t// cout << i << ' ' << dp.size() << endl;\n\t\t// for (auto &temp : dp) {\n\t\t// \tcout << temp.first << ' ' << temp.second << endl;\n\t\t// }\n\t\t// cout << endl;\n\t\tnxt.clear();\n\t}\n\tll ans = 0;\n\tfor (auto &temp : dp) {\n\t\tif (temp.first != 0) {\n\t\t\tans += temp.second;\n\t\t\tans %= mod;\n\t\t}\n\t}\n\tcout << ans << endl;\n}\n\nvoid pre_calc(int n) {\n\tint tot = (1 << n);\n\tfor (int mask = 0; mask < tot; ++mask) {\n\t\tfor (int nmask = 0; nmask < tot; ++nmask) {\n\t\t\tfor (int i = 0; i < n; ++i) {\n\t\t\t\tif ((nmask & (1 << i)) and !(mask & (1 << i))) {\n\t\t\t\t\t// if (mask == 0 and nmask == 1) {\n\t\t\t\t\t// \tcout << i << ' ' << (one << (mask | (1 << i))) << endl;\n\t\t\t\t\t// }\n\t\t\t\t\treach[nmask][mask] |= (one << (mask | (1 << i)));\n\t\t\t\t}\n\t\t\t}\n\t\t\t// cout << mask << ' ' << nmask << ' ' << reach[nmask][mask] << endl;\n\t\t}\n\t}\n\t// cout << endl;\n\tfor (int i = 0; i < n; ++i) {\n\t\tfor (int mask = 0; mask < tot; ++mask) {\n\t\t\tpre_prob[i][mask] = 1;\n\t\t\tfor (int j = 0; j < n; ++j) {\n\t\t\t\tif (mask & (1 << j)) {\n\t\t\t\t\tpre_prob[i][mask] *= p[i][j];\n\t\t\t\t} else {\n\t\t\t\t\tpre_prob[i][mask] *= (mod + 1 - p[i][j]);\n\t\t\t\t}\n\t\t\t\tpre_prob[i][mask] %= mod;\n\t\t\t}\n\t\t}\n\t}\n}\n\nll pwr(ll x, ll e) {\n\tll res = 1;\n\twhile (e) {\n\t\tif (e & 1) {\n\t\t\tres = (res * x) % mod;\n\t\t}\n\t\tx = (x * x) % mod;\n\t\te /= 2;\n\t}\n\treturn res;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "964f3807d3df90884e1083fc58baddae", "src_uid": "ccfa3251dbf956761609f1e5ed771e58", "difficulty": 3200.0} {"lang": "GNU C++20 (64)", "source_code": "#include \r\nusing namespace std;\r\ntypedef long long LL;\r\n\r\nstruct Poly : vector{\r\n Poly(){}\r\n Poly(int n) : vector(n){}\r\n Poly(const initializer_list& list) : vector(list){}\r\n \r\n bool operator<(const Poly &p)const\r\n {\r\n \tint up=min(size(),p.size());\r\n \tfor(int i=0;ihs;\r\n\t\r\n\tPoly R;\r\n\tR.resize(P.size()-1) , R[0]=1;\r\n\tfor(int y=0;y=1;--i)R[i]=R[i-1];R[0]=0;\r\n\t\tif(bj)for(int i=0;i=1;--i)AK[i]=AK[i-1];AK[0]=0;\r\n\t\tif(bj)for(int i=0;i=P.size()-1;--i)\r\n\t\t{\r\n\t\t\tif(L[i])\r\n\t\t\t{\r\n\t\t\t\t/int del=i-P.size()+1;\r\n\t\t\t\tfor(int j=0;j=0;--j)\r\n\t\t\t\t{\r\n\t\t\t\t\tL[js]^=P[j];\r\n\t\t\t\t\t--js;\r\n\t\t\t\t}*/\r\n\t\t\t}\r\n\t\t}\r\n\t\tL.resize(P.size()-1);\r\n\t}\r\n\treturn -1000000000000000000;//-1e18\r\n}\r\n\r\nchar ss[45];\r\nvoid SV()\r\n{\r\n\tscanf(\"%s\",ss);\r\n\tint n=strlen(ss) , j1=0;\r\n\tfor(int i=0;i\r\n#include \r\n\r\n#define ll long long\r\n#define sz(x) ((int) (x).size())\r\n#define all(x) (x).begin(), (x).end()\r\n#define vi vector\r\n#define pii pair\r\n#define rep(i, a, b) for(int i = (a); i < (b); i++)\r\nusing namespace std;\r\ntemplate\r\nusing minpq = priority_queue, greater>;\r\n\r\nstruct binmat {\r\n int n;\r\n vector a;\r\n binmat(int n) : n(n), a(n) {}\r\n void eye() {\r\n rep(i, 0, n) {\r\n a[i] = (1ll << i);\r\n }\r\n }\r\n void set(int i, int j, bool b) {\r\n if((a[i] >> j & 1) != b) {\r\n a[i] ^= (1ll << j);\r\n }\r\n }\r\n bool get(int i, int j) const {\r\n return a[i] >> j & 1;\r\n }\r\n binmat transpose() const {\r\n binmat B(n);\r\n rep(i, 0, n) rep(j, 0, n) {\r\n B.set(j, i, get(i, j));\r\n }\r\n return B;\r\n }\r\n ll operator*(ll vec) const {\r\n ll ans = 0;\r\n rep(i, 0, n) {\r\n bool b = 0;\r\n rep(k, 0, n) {\r\n b ^= get(i, k) && (vec >> k & 1);\r\n }\r\n if(b) ans ^= (1ll << i);\r\n }\r\n return ans;\r\n }\r\n binmat operator*(const binmat &o) const {\r\n assert(n == o.n);\r\n binmat B(n);\r\n binmat oT = o.transpose();\r\n rep(i, 0, n) {\r\n rep(j, 0, n) {\r\n B.set(i, j, __builtin_popcountll(a[i] & oT.a[j]) % 2);\r\n }\r\n }\r\n return B;\r\n }\r\n bool invert() {\r\n binmat R(n);\r\n R.eye();\r\n rep(i, 0, n) {\r\n int p = -1;\r\n rep(j, i, n) {\r\n if(get(j, i)) {\r\n p = j;\r\n break;\r\n }\r\n }\r\n if(p == -1) return false;\r\n swap(a[i], a[p]);\r\n swap(R.a[i], R.a[p]);\r\n rep(j, i + 1, n) {\r\n if(get(j, i)) {\r\n a[j] ^= a[i];\r\n R.a[j] ^= R.a[i];\r\n }\r\n }\r\n }\r\n for(int i = n - 1; i >= 0; i--) {\r\n rep(j, 0, i) {\r\n if(get(j, i)) {\r\n a[j] ^= a[i];\r\n R.a[j] ^= R.a[i];\r\n }\r\n }\r\n }\r\n *this = R;\r\n return true;\r\n }\r\n};\r\n\r\nstruct custom_hash {\r\n static uint64_t splitmix64(uint64_t x) {\r\n // http://xorshift.di.unimi.it/splitmix64.c\r\n x += 0x9e3779b97f4a7c15;\r\n x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;\r\n x = (x ^ (x >> 27)) * 0x94d049bb133111eb;\r\n return x ^ (x >> 31);\r\n }\r\n\r\n size_t operator()(uint64_t x) const {\r\n static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();\r\n return splitmix64(x + FIXED_RANDOM);\r\n }\r\n};\r\n\r\nint main() {\r\n ios::sync_with_stdio(false);\r\n cin.tie(0);\r\n string s;\r\n cin >> s;\r\n int offset = 1;\r\n while(!s.empty() && s[0] == '0') {\r\n s.erase(s.begin());\r\n offset++;\r\n }\r\n while(!s.empty() && s.back() == '0') {\r\n s.pop_back();\r\n }\r\n if(s.empty()) {\r\n cout << -1 << '\\n';\r\n return 0;\r\n }\r\n int n = s.length() - 1;\r\n if(n <= 1) {\r\n cout << offset << ' ' << offset + 1 << '\\n';\r\n return 0;\r\n }\r\n binmat B(n);\r\n rep(i, 1, n) {\r\n B.set(i, i - 1, 1);\r\n }\r\n rep(i, 0, n) {\r\n B.set(i, n - 1, s[i] == '1');\r\n }\r\n binmat Binv = B;\r\n Binv.invert();\r\n __gnu_pbds::gp_hash_table fuck;\r\n\r\n ll ans = LLONG_MAX;\r\n ll vec = 1;\r\n rep(i, 0, 1 << (n / 2)) {\r\n if(fuck.count(vec) == 0) {\r\n fuck[vec] = i;\r\n }\r\n if(vec == 1 && i > 0) {\r\n ans = min(ans, (ll)i);\r\n }\r\n vec = Binv * vec;\r\n }\r\n\r\n rep(i, 0, n / 2) {\r\n B = B * B;\r\n }\r\n vec = 1;\r\n rep(i, 0, 1 << ((n + 1) / 2)) {\r\n if(fuck.count(vec)) {\r\n ll val = 1ll * fuck[vec] + i * (1ll << (n / 2));\r\n if(val != 0) {\r\n ans = min(ans, val);\r\n }\r\n }\r\n vec = B * vec;\r\n }\r\n cout << offset << ' ' << offset + ans << '\\n';\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "37818c9c9df3fefc80aef7f6414458c4", "src_uid": "6bf798edef30db7d0ce2130e40084e6b", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "//#define fi first\r\n//#define sc second\r\n//#define mp(x,y) make_pair(x,y)\r\n//#define pa pair\r\n#include\r\n#define ll long long\r\n#define LL __int128\r\n#define in(x) x=read()\r\nusing namespace std;\r\nll hi;\r\ninline LL read()\r\n{\r\n LL x=0,f=1;\r\n char ch=getchar();\r\n while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}\r\n while(ch>='0'&&ch<='9')\r\n\t{\r\n\t\tx=(x<<1)+(ch^48);\r\n\t\tif(x == 0 && ch == '0')hi++;\r\n\t\tch=getchar();\r\n\t}\r\n return x*f;\r\n}\r\nll www,M;\r\nll mod(ll x)\r\n{\r\n\tif(x & (1ll< x)return ans;\r\n\t\tif((1ll<mp;\r\nint main()\r\n{\r\n\tin(M);\r\n\twhile(M%2==0)M/=2;\r\n\twww=__lg(M);\r\n\tif(M == 0)\r\n\t{\r\n\t\tputs(\"-1\");\r\n\t\treturn 0;\r\n\t}\r\n\tprintf(\"%lld \",hi+1);\r\n\tmp[1]=1;\r\n\tll nw = 1;\r\n\tfor(int s=2;s<262144;s++)\r\n\t{\r\n\t\tnw = mod(nw<<1);\r\n\t\tmp[nw] = s;\r\n//\t\tif(s == 33911 || s==33769)\r\n//\t\tcout<\"<\"<\r\nusing namespace std;\r\nconst long long B=500000;\r\nlong long zs1,m,zs;\r\nstring s;\r\nmap hash;\r\nlong long mo(long long x)\r\n{\r\n\tif(x&(1<>s;\r\n\tfor(int i=0;i\n#define lld long long int\n#define vec vector\n#define pll pair\n#define pb push_back\n#define ss second\n#define ff first\n#define mp make_pair\n#define MOD 1000000007\n#define answer cout<= 0; i--) {\n res = res * res % MOD;\n if (k & (1 << i))\n res = res * x % MOD;\n }\n return res;\n}\nlld rev(lld x) {\n return pw(x, MOD - 2);\n}\n\nint main() {\n messi //lld t=0;cin>>t;while(t--){\n\tlld n, k, r = 0;\n cin >> n >> k;\n if (k == 1) {\n cout << 0;\n return 0;\n }\n f[0] = rf[0] = 1;\n for (int i = 1; i <= n; i++) {\n f[i] = f[i - 1] * i % MOD;\n rf[i] = rev(f[i]);\n }\n rep(i, n)\n cin >> a[i];\n rep(i, n)\n if (a[i] != a[(i + 1) % n])\n r++;\n lld ans = 0, cc;\n for (int i = 0; 2 * i <= r; i++) {\n ans = (ans + f[r] % MOD * rf[i] % MOD * rf[i] % MOD * rf[r - 2 * i] % MOD * pw(k - 2, r - 2 * i) % MOD) % MOD;\n }\n //answer\n cout << ((pw(k, r) + MOD - ans) % MOD * rf[2] % MOD) * pw(k, n - r) % MOD<\n//#define int long long\n#define endl '\\n'\ntypedef long long ll;\nconst ll mod=998244353ll;\nusing namespace std;\nll dp[2011][4011];\nll h[300001];\nint32_t main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n ll n,k;cin>>n>>k;\n for (int i=1;i<=n;i++) cin>>h[i];\n h[n+1]=h[1];\n vectorv={h[1]};\n ll p=1ll;\n for (int i=2;i<=n+1;i++){\n if (h[i]!=h[i-1]) v.push_back(h[i]);\n else p=(p*k)%mod;\n }\n int cnt=0;\n for (auto i:v) h[++cnt]=i;\n n=cnt-1;\n if (h[1]==h[2]){\n dp[2][2000]=k;\n } else {\n dp[2][2001]=1ll;\n dp[2][1999]=1ll;\n dp[2][2000]=k-2ll;\n }\n for (int i=2;i<=n;i++){\n for (int j=2000-i;j<=2000+i;j++){\n dp[i+1][j]=(dp[i+1][j]+dp[i][j]*(k-2ll))%mod;\n dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%mod;\n dp[i+1][j-1]=(dp[i+1][j-1]+dp[i][j])%mod;\n }\n }\n ll sum=0ll;\n for (int i=2001;i<=2000+n;i++) sum=(sum+dp[n+1][i])%mod;\n cout<<(sum*p)%mod;\n return 0;\n}\n/*\n//#pragma GCC optimize (\"Ofast\")\n#include \n//#define int long long\n#define endl '\\n'\ntypedef long long ll;\nusing namespace std;\nint a[300001];\nmapmp;\nint val[300001];\nsetg[300001];\nint ans[300001];\nvoid solve(){\n vector,int> >q;\n int n;cin>>n;\n setnn;\n for (int i=1;i<=n;i++) cin>>a[i],nn.insert(a[i]);\n int cnt=0;\n for (auto i:nn) mp[i]=++cnt,val[cnt]=i;\n vectorv;\n for (int i=1;i<=n;i++){\n g[mp[a[i]].insert(i);\n v.push_back(mp[a[i]]);\n }\n sort(v.begin(),v.end());\n int m;cin>>m;\n for (int i=1;i<=m;i++){\n int k,pos;cin>>k>>pos;\n q.push_back({{k,pos},i});\n }\n sort(q.begin(),q.end());\n setsub_seq;\n int K=0;\n for (int i=0;i>tt;\n while (tt--){\n solve();\n }\n return 0;\n}\n*/\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ee32599a17ca3197ad22afb55cecf94e", "src_uid": "63c4006a0a6284f9825aaabfc4c28fd1", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize(\"Ofast,no-stack-protector,unroll-loops,fast-math,O3\")\n#include \nusing namespace std;\nusing ll=long long;\nusing pii=pair;\ninline int read(){\n\tregister int res=0, c;\n\twhile(c=getchar(), c<'0'||c>'9');\n\tdo{\n\t\tres=(res*10)+(c^48);\n\t} while(c=getchar(), c>='0'&&c<='9');\n\treturn res;\n}\nconst int mod = 998244353;\nint qpow(int n, int k){\n\tint res = 1;\n\twhile(k){\n\t\tif(k&1)res = 1ll*res*n%mod;\n\t\tn = 1ll*n*n%mod;\n\t\tk>>=1;\n\t}\n\treturn res;\n}\nint main(int argc, char* argv[]){\n\tint N=read(), K=read();\n\tvector s(N);\n\tfor(int i=0; i> C(2001, vector(2001));\n\tC[0][0]=1;\n\tfor(int i=1; i<=2000; i++){\n\t\tC[i][0]=C[i][i]=1;\n\t\tfor(int j=1; j>1] + mod)%mod;\n\t\t\tnow = 1ll*now*rev2%mod;\n\t\t}\n\t\tans = (ans + now) % mod;\n\t}\n\tans = 1ll* ans * qpow(K, cnt) % mod;\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a12b8be14b404379d6fbcec314002cea", "src_uid": "63c4006a0a6284f9825aaabfc4c28fd1", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "//#pragma GCC optimize(\"Ofast\")\n//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long li;\ntypedef long double ld;\nconst li MAX = 1e5 + 5;\n\nli inf = (li)30000;\nli mod = (li)998244353;\nli n, k, a[MAX], f[MAX], rev[MAX], power[MAX], any[MAX];\n\nli bin(li num, li power) {\n if (power == 0) return 1;\n else {\n li ret;\n if (power & 1) ret = (num * bin(num, power - 1)) % mod;\n else {\n ret = bin(num, power / 2);\n ret = (ret * ret) % mod;\n }\n return ret;\n }\n}\n\nli c(li n, li k) {\n return (((f[n] * rev[n - k]) % mod) * rev[k]) % mod;\n}\n\nvoid solve() {\n cin >> n >> k;\n f[0] = 1;\n any[0] = 1;\n rev[0] = 1;\n power[0] = 1;\n for (int i = 1; i < MAX; i++) {\n f[i] = (f[i - 1] * i) % mod;\n any[i] = (any[i - 1] * (k - 2)) % mod;\n rev[i] = (bin(i, mod - 2) * rev[i - 1]) % mod;\n power[i] = (power[i - 1] * 2) % mod;\n }\n\n li m = 0, ans = 0;\n for (int i = 0; i < n; i++) cin >> a[i];\n for (int i = 0; i < n; i++) {\n if (a[i] != a[(i + 1) % n]) m++;\n }\n\n for (int i = 1; i <= m; i++) {\n li ad;\n if (i % 2 == 1) ad = (((c(m, i) * power[i]) % mod) * rev[2]) % mod;\n else {\n li act = (power[i] + mod - c(i, i / 2)) % mod;\n ad = (((c(m, i) * act) % mod) * rev[2]) % mod;\n }\n ad *= any[m - i];\n ans += ad;\n ans %= mod;\n }\n\n for (int i = 0; i < n - m; i++) ans = (ans * k) % mod;\n cout << ans;\n}\n\n\nint main() {\n mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());\n ios::sync_with_stdio(0);\n li q;\n q = 1;\n while (q--) solve();\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bfb737d12520b42ca55888861957fa09", "src_uid": "63c4006a0a6284f9825aaabfc4c28fd1", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n\n#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)\n#define mp make_pair\n#define xx first\n#define yy second\n#define dif(x) ((x).yy-(x).xx)\n#define pb push_back\n#define pf push_front\n#define popb pop_back\n#define popf pop_front\n#define all(x) (x).begin(),(x).end()\n#define exist(a,x) find(all(a),x)!=a.end()\n#define ub(a,x) upper_bound(all(a),x)\n#define lb(a,x) lower_bound(all(a),x)\n#define inv(n) power((n), mod - 2)\n#define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)\n#define fff(i,a,b) for (int (i) = (a); (i) <= b; (i)++)\n#define bff(i,a,b) for (int (i) = (b)-1; (i) >= (a); (i)--)\n#define bfff(i,a,b) for (int (i) = (b); (i) >= (a); (i)--)\n\nusing namespace std;\nlong double typedef ld;\nunsigned int typedef ui;\nlong long int typedef li;\npair typedef pii;\npair typedef pli;\nvector> typedef graph;\nunsigned long long int typedef ull;\nconst ld PI = 3.14159265359;\n//const int mod = 998244353;\nconst int mod = 1000000007;\nconst li inf = 9223372036854775807ll;\n\nusing namespace __gnu_pbds;\ntemplate using oset = tree, rb_tree_tag,tree_order_statistics_node_update>;\ntemplate using omset = tree, rb_tree_tag,tree_order_statistics_node_update>;\n\ninline int power(li _a, int _n)\n{\n li _c = 1;\n while (_n>0)\n {\n if (_n % 2) _c = _c * _a%mod;\n _a = _a * _a%mod;\n _n/=2;\n }\n return _c;\n}\n\ninline int geom(li _a, int _n) //suma 1 + a + a^2 + ... + a^(n-1)\n{\n if (_a == 0) return 0;\n if (_a == 1) return _n;\n return ((li)power(_a, _n) - 1) * inv(_a - 1) % mod;\n}\n\npli _r;\n\nli bigmod(li _a, li _b, li _m) //ogromni mod\n{\n if (_a==0) return 0;\n if (_a%2==1) return (_b + 2*bigmod(_a/2,_b,_m))%_m;\n return 2*bigmod(_a/2,_b,_m)%_m;\n}\n\nvoid euklid(li _a, li _b)\n{\n if (_b==1)\n {\n _r = mp(1,-_a+1);\n return;\n }\n\n euklid(_b,_a%_b); //cout<_b) {swap(_a,_b); swap(_x,_y);}\n\n euklid(_b,_a); (_r.xx*=(_x-_y))%=(_a*_b);\n return (bigmod(_b,_r.xx,_a*_b)+_y)%(_a*_b);\n}\n\ninline li sum(int _n) {return ((li)_n*(_n+1))/2;}\n\ninline li kv(int _n) {return ((li)_n*(_n+1)*(2*_n+1))/6;}\n\n\n\n\n\n\n\n//Note to self: Check for overflow\n\nint kvsum(li x)\n{\n li res=x*(x+1)%mod;\n res=res*(2*x+1)%mod;\n return res*inv(6)%mod;\n}\n\nint zbirost(li x, li y)\n{\n x++; y++;\n if (x%3==0 || y%3==0) return x*y/3*3;\n if (x%3==1 && y%3==1) return x*y/3*3 + (x+y-2)%3;\n if (x%3==2 && y%3==2) return x*y/3*3 - 3 + (x+y-2)%3 + (x+y-3)%3 + (x+y-3)%3 + (x+y-4)%3;\n else return x*y/3*3 + (x+y-2)%3 + (x+y-3)%3;\n}\n\nint summ(int x)\n{\n return (x/3)*(x - 1 + x%3)/2;\n}\n\nint presum(li x)\n{\n //summ(0) + summ(1) + summ(2) + ... + summ(x), gde je summ(x) zbir prefiksa u nizu 0 0 0 1 1 1 2 2 2 3 3 3 ... koji je indeksiran od 0\n\n //summ(x)=3*(x/3)*(x/3 + 1)/2 - (x/3)*(2-x%3)\n\n x++; //neko shiftovanje nmp glup sam\n\n /*int res=0;\n fff(i,0,x) res+=summ(i);\n return res;*/\n\n li res=x*3%mod*(sum(x/3)%mod);\n res-=kvsum(x/3)*9%mod;\n res%=mod; if (res<0) res+=mod;\n res-=summ(x);\n\n if (x%3==0) res+=x/3;\n\n return res;\n}\n\nli presumsum(li x)\n{\n return x*(x+1)%mod*(x+2)%mod*inv(6)%mod;\n}\n\nli oduzm_red(int p, int k)\n{\n //(sum(p) + sum(p+1) + sum(p+2) + sum(p+3)) + (sum(p+2)+sum(p+3)+sum(p+4)+sum(p+5)) + ...\n //suma prvih k+1 elem. blokovi su mod 4\n\n int kk=(k/4*4+3)/2+2;\n li res=presumsum(p+kk)+presumsum(p+kk-2)-presumsum(p+1)-presumsum(p-1);\n if (k%4<=2) (res-=sum(p+kk))%=mod;\n if (k%4<=1) (res-=sum(p+kk-1))%=mod;\n if (k%4<=0) (res-=sum(p+kk-2))%=mod;\n if (res<0) res+=mod;\n\n //cout<y) return 0;\n\n li res=0;\n if (y%2==0)\n {\n int fakex=y/2; //cout<=m) (res+=dunkcija(0,m))%=mod;\n else (res+=dunkcija(0,m)-dunkcija(n+1,m))%=mod;\n\n if (2*m>=n) (res+=dunkcija(0,n))%=mod;\n else (res+=dunkcija(0,n)-dunkcija(m+1,n))%=mod;\n\n return (res<0)?res+mod:res;\n\n /*int res=0;\n fff(i,0,m) res+=summ(n+i)-summ(i-1);\n return res;*/\n}\n\nint kurac(int x)\n{\n return x-(x/4)*2;\n}\n\nint podeli(li x, li y, li n, li m)\n{\n int res=(pref(n,m)+pref(x-1,y-1)-pref(n,y-1)-pref(x-1,m))%mod;\n\n return (res<0)?res+mod:res;\n\n /*li res=0;\n fff(i,x,n) fff(j,y,m)\n {\n if (i==2 && j==2) res+=4;\n else if (j>2*i) res+=i+kurac(j-2*i);\n else if (i>2*j) res+=j+kurac(i-2*j);\n else res+=(i+j)/3+(i+j)%3;\n }\n return res%mod;*/\n}\n\nint main()\n{\n FAST;\n\n int t,x,y,n,m;\n cin>>t; while(t--)\n {\n cin>>x>>y>>n>>m;\n x--; y--; n--; m--;\n int res=podeli(x,y,n,m);\n fff(i,x,n) fff(j,y,m)\n {\n if (j>=2*i)\n {\n res-=(i+j)/3+(i+j)%3;\n //res+=i+kurac(j-2*i);\n }\n else if (i>=2*j)\n {\n res-=(i+j)/3+(i+j)%3;\n //res+=j+kurac(i-2*j);\n }\n }\n if (x==2 && y==2) res+=2;\n cout<>x>>y;\n cout<\n#include \n#include \n\n#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)\n#define mp make_pair\n#define xx first\n#define yy second\n#define dif(x) ((x).yy-(x).xx)\n#define pb push_back\n#define pf push_front\n#define popb pop_back\n#define popf pop_front\n#define all(x) (x).begin(),(x).end()\n#define exist(a,x) find(all(a),x)!=a.end()\n#define ub(a,x) upper_bound(all(a),x)\n#define lb(a,x) lower_bound(all(a),x)\n#define inv(n) power((n), mod - 2)\n#define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)\n#define fff(i,a,b) for (int (i) = (a); (i) <= b; (i)++)\n#define bff(i,a,b) for (int (i) = (b)-1; (i) >= (a); (i)--)\n#define bfff(i,a,b) for (int (i) = (b); (i) >= (a); (i)--)\n\nusing namespace std;\nlong double typedef ld;\nunsigned int typedef ui;\nlong long int typedef li;\npair typedef pii;\npair typedef pli;\nvector> typedef graph;\nunsigned long long int typedef ull;\nconst ld PI = 3.14159265359;\n//const int mod = 998244353;\nconst int mod = 1000000007;\nconst li inf = 9223372036854775807ll;\n\nusing namespace __gnu_pbds;\ntemplate using oset = tree, rb_tree_tag,tree_order_statistics_node_update>;\ntemplate using omset = tree, rb_tree_tag,tree_order_statistics_node_update>;\n\ninline int power(li _a, int _n)\n{\n li _c = 1;\n while (_n>0)\n {\n if (_n % 2) _c = _c * _a%mod;\n _a = _a * _a%mod;\n _n/=2;\n }\n return _c;\n}\n\ninline int geom(li _a, int _n) //suma 1 + a + a^2 + ... + a^(n-1)\n{\n if (_a == 0) return 0;\n if (_a == 1) return _n;\n return ((li)power(_a, _n) - 1) * inv(_a - 1) % mod;\n}\n\npli _r;\n\nli bigmod(li _a, li _b, li _m) //ogromni mod\n{\n if (_a==0) return 0;\n if (_a%2==1) return (_b + 2*bigmod(_a/2,_b,_m))%_m;\n return 2*bigmod(_a/2,_b,_m)%_m;\n}\n\nvoid euklid(li _a, li _b)\n{\n if (_b==1)\n {\n _r = mp(1,-_a+1);\n return;\n }\n\n euklid(_b,_a%_b); //cout<_b) {swap(_a,_b); swap(_x,_y);}\n\n euklid(_b,_a); (_r.xx*=(_x-_y))%=(_a*_b);\n return (bigmod(_b,_r.xx,_a*_b)+_y)%(_a*_b);\n}\n\ninline li sum(int _n) {return ((li)_n*(_n+1))/2;}\n\ninline li kv(int _n) {return ((li)_n*(_n+1)*(2*_n+1))/6;}\n\n\n\n\n\n\n\n//Note to self: Check for overflow\n\nint kvsum(li x)\n{\n li res=x*(x+1)%mod;\n res=res*(2*x+1)%mod;\n return res*inv(6)%mod;\n}\n\nint zbirost(li x, li y)\n{\n x++; y++;\n if (x%3==0 || y%3==0) return x*y/3*3;\n if (x%3==1 && y%3==1) return x*y/3*3 + (x+y-2)%3;\n if (x%3==2 && y%3==2) return x*y/3*3 - 3 + (x+y-2)%3 + (x+y-3)%3 + (x+y-3)%3 + (x+y-4)%3;\n else return x*y/3*3 + (x+y-2)%3 + (x+y-3)%3;\n}\n\nint summ(int x)\n{\n return (x/3)*(x - 1 + x%3)/2;\n}\n\nint presum(li x)\n{\n //summ(0) + summ(1) + summ(2) + ... + summ(x), gde je summ(x) zbir prefiksa u nizu 0 0 0 1 1 1 2 2 2 3 3 3 ... koji je indeksiran od 0\n\n //summ(x)=3*(x/3)*(x/3 + 1)/2 - (x/3)*(2-x%3)\n\n x++; //neko shiftovanje nmp glup sam\n\n /*int res=0;\n fff(i,0,x) res+=summ(i);\n return res;*/\n\n li res=x*3%mod*(sum(x/3)%mod);\n res-=kvsum(x/3)*9%mod;\n res%=mod; if (res<0) res+=mod;\n res-=summ(x);\n\n if (x%3==0) res+=x/3;\n\n return res;\n}\n\nint pref(int n, int m)\n{\n int res=(presum(n+m)-presum(n-1)-presum(m-1))%mod;\n (res+=zbirost(n,m))%=mod;\n return (res<0)?res+mod:res;\n\n /*int res=0;\n fff(i,0,m) res+=summ(n+i)-summ(i-1);\n return res;*/\n}\n\nint kurac(int x)\n{\n return x-(x/4)*2;\n}\n\nint podeli(li x, li y, li n, li m)\n{\n int res=(pref(n,m)+pref(x-1,y-1)-pref(n,y-1)-pref(x-1,m))%mod;\n return (res<0)?res+mod:res;\n\n /*li res=0;\n fff(i,x,n) fff(j,y,m)\n {\n if (i==2 && j==2) res+=4;\n else if (j>2*i) res+=i+kurac(j-2*i);\n else if (i>2*j) res+=j+kurac(i-2*j);\n else res+=(i+j)/3+(i+j)%3;\n }\n return res%mod;*/\n}\n\nint main()\n{\n FAST;\n\n int t,x,y,n,m;\n cin>>t; while(t--)\n {\n cin>>x>>y>>n>>m;\n x--; y--; n--; m--;\n int res=podeli(x,y,n,m);\n fff(i,x,n) fff(j,y,m)\n {\n if (j>=2*i) res+=i+kurac(j-2*i)-(i+j)/3-(i+j)%3;\n else if (i>=2*j) res+=j+kurac(i-2*j)-(i+j)/3-(i+j)%3;\n }\n if (x==2 && y==2) res+=2;\n cout<>x>>y;\n cout<\n#include \n#include \n\n#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)\n#define mp make_pair\n#define xx first\n#define yy second\n#define dif(x) ((x).yy-(x).xx)\n#define pb push_back\n#define pf push_front\n#define popb pop_back\n#define popf pop_front\n#define all(x) (x).begin(),(x).end()\n#define exist(a,x) find(all(a),x)!=a.end()\n#define ub(a,x) upper_bound(all(a),x)\n#define lb(a,x) lower_bound(all(a),x)\n#define inv(n) power((n), mod - 2)\n#define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)\n#define fff(i,a,b) for (int (i) = (a); (i) <= b; (i)++)\n#define bff(i,a,b) for (int (i) = (b)-1; (i) >= (a); (i)--)\n#define bfff(i,a,b) for (int (i) = (b); (i) >= (a); (i)--)\n\nusing namespace std;\nlong double typedef ld;\nunsigned int typedef ui;\nlong long int typedef li;\npair typedef pii;\npair typedef pli;\nvector> typedef graph;\nunsigned long long int typedef ull;\nconst ld PI = 3.14159265359;\n//const int mod = 998244353;\nconst int mod = 1000000007;\nconst li inf = 9223372036854775807ll;\n\nusing namespace __gnu_pbds;\ntemplate using oset = tree, rb_tree_tag,tree_order_statistics_node_update>;\ntemplate using omset = tree, rb_tree_tag,tree_order_statistics_node_update>;\n\ninline int power(li _a, int _n)\n{\n li _c = 1;\n while (_n>0)\n {\n if (_n % 2) _c = _c * _a%mod;\n _a = _a * _a%mod;\n _n/=2;\n }\n return _c;\n}\n\ninline int geom(li _a, int _n) //suma 1 + a + a^2 + ... + a^(n-1)\n{\n if (_a == 0) return 0;\n if (_a == 1) return _n;\n return ((li)power(_a, _n) - 1) * inv(_a - 1) % mod;\n}\n\npli _r;\n\nli bigmod(li _a, li _b, li _m) //ogromni mod\n{\n if (_a==0) return 0;\n if (_a%2==1) return (_b + 2*bigmod(_a/2,_b,_m))%_m;\n return 2*bigmod(_a/2,_b,_m)%_m;\n}\n\nvoid euklid(li _a, li _b)\n{\n if (_b==1)\n {\n _r = mp(1,-_a+1);\n return;\n }\n\n euklid(_b,_a%_b); //cout<_b) {swap(_a,_b); swap(_x,_y);}\n\n euklid(_b,_a); (_r.xx*=(_x-_y))%=(_a*_b);\n return (bigmod(_b,_r.xx,_a*_b)+_y)%(_a*_b);\n}\n\ninline li sum(int _n) {return ((li)_n*(_n+1))/2;}\n\ninline li kv(int _n) {return ((li)_n*(_n+1)*(2*_n+1))/6;}\n\n\n\n\n\n\n\n//Note to self: Check for overflow\n\nint kvsum(li x)\n{\n li res=x*(x+1)%mod;\n res=res*(2*x+1)%mod;\n return res*inv(6)%mod;\n}\n\nint zbirost(li x, li y, li n, li m)\n{\n li ostatak=(n-x+1)*(m-y+1)%3;\n li res=0;\n\n if (ostatak==1) res+=(x+y)%3;\n else if (ostatak==2) res+=(x+y)%3+(x+y-1)%3;\n\n res+=(n-x+1)*(m-y+1)/3*3;\n\n return res%mod;\n}\n\nint summ(int x)\n{\n return (x/3)*(x - 1 + x%3)/2;\n}\n\nint presum(li x)\n{\n //summ(0) + summ(1) + summ(2) + ... + summ(x), gde je summ(x) zbir prefiksa u nizu 0 0 0 1 1 1 2 2 2 3 3 3 ... koji je indeksiran od 0\n\n //summ(x)=3*(x/3)*(x/3 + 1)/2 - (x/3)*(2-x%3)\n\n x++; //neko shiftovanje nmp glup sam\n\n /*int res=0;\n fff(i,0,x) res+=summ(i);\n return res;*/\n\n li res=x*3%mod*(sum(x/3)%mod);\n res-=kvsum(x/3)*9%mod;\n res%=mod; if (res<0) res+=mod;\n res-=summ(x);\n\n if (x%3==0) res+=x/3;\n\n return res;\n}\n\nint pref(int n, int m)\n{\n int res=(presum(n+m)-presum(n-1)-presum(m))%mod;\n return (res<0)?res+mod:res;\n\n /*int res=0;\n fff(i,0,m) res+=summ(n+i)-summ(i-1);\n return res;*/\n}\n\nint kurac(int x)\n{\n return x-(x/4)*2;\n}\n\nint podeli(li x, li y, li n, li m)\n{\n //int res=(pref(n,m)+pref(x-1,y-1)-pref(n,y-1)-pref(x-1,m))%mod;\n //return (res<0)?res+mod:res;\n\n li res=0;\n fff(i,x,n) fff(j,y,m)\n {\n if (i==2 && j==2) res+=4;\n else if (j>2*i) res+=i+kurac(j-2*i);\n else if (i>2*j) res+=j+kurac(i-2*j);\n else res+=(i+j)/3+(i+j)%3;\n }\n return res%mod;\n}\n\nint main()\n{\n FAST;\n\n int t,x,y,n,m;\n cin>>t; while(t--)\n {\n cin>>x>>y>>n>>m;\n x--; y--; n--; m--;\n int res=podeli(x,y,n,m);\n cout<>x;\n cout<<\",\"<>i>>j;\n int res=0;\n if (i==2 && j==2) res+=4;\n else if (j>2*i)\n {\n cout<<\" \"<2*j) res+=j+kurac(i-j);\n else res+=(i+j)/3+(i+j)%3;\n cout<\n#include \n#include \n\n#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)\n#define mp make_pair\n#define xx first\n#define yy second\n#define dif(x) ((x).yy-(x).xx)\n#define pb push_back\n#define pf push_front\n#define popb pop_back\n#define popf pop_front\n#define all(x) (x).begin(),(x).end()\n#define exist(a,x) find(all(a),x)!=a.end()\n#define ub(a,x) upper_bound(all(a),x)\n#define lb(a,x) lower_bound(all(a),x)\n#define inv(n) power((n), mod - 2)\n#define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)\n#define fff(i,a,b) for (int (i) = (a); (i) <= b; (i)++)\n#define bff(i,a,b) for (int (i) = (b)-1; (i) >= (a); (i)--)\n#define bfff(i,a,b) for (int (i) = (b); (i) >= (a); (i)--)\n\nusing namespace std;\nlong double typedef ld;\nunsigned int typedef ui;\nlong long int typedef li;\npair typedef pii;\npair typedef pli;\nvector> typedef graph;\nunsigned long long int typedef ull;\nconst ld PI = 3.14159265359;\n//const int mod = 998244353;\nconst int mod = 1000000007;\nconst li inf = 9223372036854775807ll;\n\nusing namespace __gnu_pbds;\ntemplate using oset = tree, rb_tree_tag,tree_order_statistics_node_update>;\ntemplate using omset = tree, rb_tree_tag,tree_order_statistics_node_update>;\n\ninline int power(li _a, int _n)\n{\n li _c = 1;\n while (_n>0)\n {\n if (_n % 2) _c = _c * _a%mod;\n _a = _a * _a%mod;\n _n/=2;\n }\n return _c;\n}\n\ninline int geom(li _a, int _n) //suma 1 + a + a^2 + ... + a^(n-1)\n{\n if (_a == 0) return 0;\n if (_a == 1) return _n;\n return ((li)power(_a, _n) - 1) * inv(_a - 1) % mod;\n}\n\npli _r;\n\nli bigmod(li _a, li _b, li _m) //ogromni mod\n{\n if (_a==0) return 0;\n if (_a%2==1) return (_b + 2*bigmod(_a/2,_b,_m))%_m;\n return 2*bigmod(_a/2,_b,_m)%_m;\n}\n\nvoid euklid(li _a, li _b)\n{\n if (_b==1)\n {\n _r = mp(1,-_a+1);\n return;\n }\n\n euklid(_b,_a%_b); //cout<_b) {swap(_a,_b); swap(_x,_y);}\n\n euklid(_b,_a); (_r.xx*=(_x-_y))%=(_a*_b);\n return (bigmod(_b,_r.xx,_a*_b)+_y)%(_a*_b);\n}\n\ninline li sum(int _n) {return ((li)_n*(_n+1))/2;}\n\ninline li kv(int _n) {return ((li)_n*(_n+1)*(2*_n+1))/6;}\n\n\n\n\n\n\n\n//Note to self: Check for overflow\n\nint kvsum(li x)\n{\n li res=x*(x+1)%mod;\n res=res*(2*x+1)%mod;\n return res*inv(6)%mod;\n}\n\nint zbirost(li x, li y)\n{\n x++; y++;\n if (x%3==0 || y%3==0) return x*y/3*3;\n if (x%3==1 && y%3==1) return x*y/3*3 + (x+y-2)%3;\n if (x%3==2 && y%3==2) return x*y/3*3 - 3 + (x+y-2)%3 + (x+y-3)%3 + (x+y-3)%3 + (x+y-4)%3;\n else return x*y/3*3 + (x+y-2)%3 + (x+y-3)%3;\n}\n\nint summ(int x)\n{\n return (x/3)*(x - 1 + x%3)/2;\n}\n\nint presum(li x)\n{\n //summ(0) + summ(1) + summ(2) + ... + summ(x), gde je summ(x) zbir prefiksa u nizu 0 0 0 1 1 1 2 2 2 3 3 3 ... koji je indeksiran od 0\n\n //summ(x)=3*(x/3)*(x/3 + 1)/2 - (x/3)*(2-x%3)\n\n x++; //neko shiftovanje nmp glup sam\n\n /*int res=0;\n fff(i,0,x) res+=summ(i);\n return res;*/\n\n li res=x*3%mod*(sum(x/3)%mod);\n res-=kvsum(x/3)*9%mod;\n res%=mod; if (res<0) res+=mod;\n res-=summ(x);\n\n if (x%3==0) res+=x/3;\n\n return res;\n}\n\nli presumsum(li x)\n{\n return x*(x+1)%mod*(x+2)%mod*inv(6)%mod;\n}\n\nli oduzm_red(int p, int k)\n{\n //(sum(p) + sum(p+1) + sum(p+2) + sum(p+3)) + (sum(p+2)+sum(p+3)+sum(p+4)+sum(p+5)) + ...\n //suma prvih k+1 elem. blokovi su mod 4\n\n int kk=(k/4*4+3)/2+2;\n li res=presumsum(p+kk)+presumsum(p+kk-2)-presumsum(p+1)-presumsum(p-1);\n if (k%4<=2) (res-=sum(p+kk))%=mod;\n if (k%4<=1) (res-=sum(p+kk-1))%=mod;\n if (k%4<=0) (res-=sum(p+kk-2))%=mod;\n if (res<0) res+=mod;\n\n //cout<y) return 0;\n\n li res=0;\n if (y%2==0)\n {\n int fakex=y/2; //cout<y) return 0;\n\n li fx=y/2,res=-69420;\n if (y%2==1)\n {\n x--;\n res=(fx-x)*(fx-x+1)%mod*(fx+1)%mod - 2*kvsum(fx-x);\n if (res<0) res+=mod; if (res<0) res+=mod;\n\n res+=paradunkcija(y-2*(x+1));\n }\n else\n {\n res=anti_dunkcija(x,y-1);\n res+=predukcija(y+y/2)-predukcija(y+x-1);\n }\n\n return res;\n}\n\nint pref(int n, int m)\n{\n int res=(presum(n+m)-presum(n-1)-presum(m-1))%mod;\n (res+=zbirost(n,m))%=mod; if (res<0) res+=mod;\n\n //cout<=m) (res+=dunkcija(0,m))%=mod;\n else (res+=dunkcija(0,m)-dunkcija(n+1,m))%=mod;\n\n if (2*m>=n) (res+=dunkcija(0,n))%=mod;\n else (res+=dunkcija(0,n)-dunkcija(m+1,n))%=mod;\n\n //minus visak dole\n\n /*if (2*n>=m) (res-=anti_dunkcija(0,m))%=mod;\n else (res-=anti_dunkcija(0,m)-anti_dunkcija(n+1,m))%=mod;\n\n if (2*m>=n) (res-=anti_dunkcija(0,n))%=mod;\n else (res-=anti_dunkcija(0,n)-anti_dunkcija(m+1,n))%=mod;*/\n\n return (res<0)?res+mod:res;\n\n /*int res=0;\n fff(i,0,m) res+=summ(n+i)-summ(i-1);\n return res;*/\n}\n\nint kurac(int x)\n{\n return x-(x/4)*2;\n}\n\nint podeli(li x, li y, li n, li m)\n{\n int res=(pref(n,m)+pref(x-1,y-1)-pref(n,y-1)-pref(x-1,m))%mod;\n\n return (res<0)?res+mod:res;\n\n /*fff(i,x,n) fff(j,y,m)\n {\n if (i==2 && j==2) res+=4;\n else if (j>2*i)\n {\n res+=i+kurac(j-2*i);\n res-=(i+j)/3+(i+j)%3;\n }\n else if (i>2*j)\n {\n res+=j+kurac(i-2*j);\n res-=(i+j)/3+(i+j)%3;\n }\n }\n return res%mod;*/\n}\n\nint main()\n{\n FAST;\n\n int t,x,y,n,m;\n cin>>t; while(t--)\n {\n cin>>x>>y>>n>>m;\n x--; y--; n--; m--;\n int res=podeli(x,y,n,m);\n fff(i,x,n) fff(j,y,m)\n {\n if (j>=2*i)\n {\n res-=(i+j)/3+(i+j)%3;\n //res+=i+kurac(j-2*i);\n }\n else if (i>=2*j)\n {\n res-=(i+j)/3+(i+j)%3;\n //res+=j+kurac(i-2*j);\n }\n }\n if (x==2 && y==2) res+=2;\n cout<>x>>y;\n cout<>x;\n cout<\nusing namespace std;\n#define ll long long\n#define mem0(x) memset(x,0,sizeof x)\nint main(){\n\tint a,nowp,stk[1010];\n\tnowp=0;\n\twhile(~scanf(\"%d\",&a)){\n\t\tstk[++nowp]=a;\n\t}\n\tfor(int i=nowp;i>=1;i--){\n\t\tint t=stk[i];\n\t\tdb ans=sqrt(abs(t))*t*t*t*5.0;\n\t\tif(ans>400) printf(\"f(%d) = MAGNA NIMIS!\\n\",nowp-i+1);\n\t\telse printf(\"f(%d) = %0.2lf\\n\",nowp-i+1,ans);\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "598c19569727710d8559f4b587aa7b6d", "src_uid": "30b3411c3c23d029ea1e9cf73e7d2f01", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n \nint main( ) {\n std::vector input( 11 ) , results( 11 ) ;\n for ( int i = 0 ; i < input.size( ) ; i++ ) \n std::cin >> input[i];\n cout.precision(2);\n std::transform( input.begin( ) , input.end( ) , results.begin( ) ,\n\t [ ]( double n )-> double { return sqrt( abs( n ) ) + 5 * pow( n , 3 ) ; } ) ;\n for ( int i = 10 ; i > -1 ; i-- ) {\n std::cout << \"f(\" << input[ i ] << \") = \" ; \n if ( results[ i ] > 400 ) \n\t std::cout << \"MAGNA NIMIS!\" ;\n else \n\t std::cout << fixed << results[ i ];\n std::cout << std::endl ;\n }\n return 0 ;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "41bdd68492f37fa90ad4a7da14e9d285", "src_uid": "30b3411c3c23d029ea1e9cf73e7d2f01", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\nsigned main() {\n array a;\n for (int i = 0; i < 11; ++i) {\n cin >> a[i];\n }\n cout << fixed << setprecision(2);\n for (int i = 10; i >= 0; --i) {\n double res = 5 * a[i] * a[i] * a[i] + sqrt(abs(a[i]));\n if (600 >= res) {\n cout << \"f(\" << a[i] << \") = \" << res << '\\n';\n } else {\n cout << \"f(\" << a[i] << \") = \" << \"MAGNA NIMIS!\" << '\\n';\n }\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "86f056efc4b50e45b9e6805f69c182f1", "src_uid": "30b3411c3c23d029ea1e9cf73e7d2f01", "difficulty": null} {"lang": "GNU C++17", "source_code": "/*\nID: jonathanh8686\nPROG: NAME\nLANG: C++11\n*/\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define endl \"\\n\"\n#define MAX_INT 2147483647\n#define MAX_LONG 18446744073709551615\n\nusing namespace std;\n\nifstream fin(\"NAME.in\");\nofstream fout(\"NAME.out\");\n\n\nint a[11];\nint main()\n{\n\tios::sync_with_stdio(false);\n\tfor (int i = 0; i < 11; i++)\n\t{\n\t\tcin >> a[i];\n\t}\n\n\tfor (int i = 10; i >= 0; i--)\n\t{\n\t\tfloat ares = sqrt(abs(a[i]));\n\t\tfloat bres = 5 * pow(a[i], 3);\n\n\t\tfloat res = ares + bres;\n\n\t\tstd::cout << std::fixed;\n\t\tstd::cout << std::setprecision(2);\n\n\t\tif (res <= 400)\n\t\t{\n\t\t\tcout << \"f(\" << a[i] << \") = \" << res << endl;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcout << \"f(\" << a[i] << \") = MAGNA NIMIS!\" << endl;\n\t\t}\n\n\t}\n1\nreturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "228511608f103c3539c7b5b092f81022", "src_uid": "30b3411c3c23d029ea1e9cf73e7d2f01", "difficulty": null} {"lang": "GNU C++17", "source_code": "#warning \"too slow\"\n\n// [I didn't read the editorial or view any failed test cases]\n//\n// Idea:\n// The prob* v optimal substrufp prot on (i).\n// =>\n// f(i, t) = set of X values such that\n// * initial i+1 station (with station \n\nauto ceildiv(int64_t a,int64_t b){\n\tassert(a>=0 and b>0);\n\treturn (a+b-1)/b;\n}\n\nint main(){\n\tstd::ios::sync_with_stdio(0);std::cin.tie(0);\n\n\tint nstation,time,trainsize;\n\tstd::cin>>nstation>>time>>trainsize;\n\tstruct station{\n\t\tint val,inc,cap;\n\t};\n\tstd::vector st(nstation);\n\n\tint64_t total_inc=0,total_val=0;\n\tfor(auto& [val,inc,cap]:st){\n\t\tstd::cin>>val>>inc>>cap;\n\t\ttotal_inc+=inc;\n\t\ttotal_val+=val;\n\t}\n\n\tauto const st_back_never_overflow=[&]{ return st.back().val+st.back().inc*(int64_t)time<=st.back().cap; };\n\twhile(not st.empty() and st_back_never_overflow())\n\t\tst.pop_back();\n\tif(st.empty()){\n\t\tstd::cout<<\"0\\n\";\n\t\treturn 0;\n\t}\n\t// now there must be a moment s.t. values of first (nstation-1) stations are 0\n\tnstation=(int)st.size();\n\n\tstd::vector k(nstation,std::vector>(time+1));\n\n\t// k[i][time][x] = *min* ntrain such that it's possible to get from value (first i == 0, [i] == x)\n\t// to value (first i = 0, last = x+suminc[0..i]*time-ntrain*trainsize), or INT64_MAX\n\t//\n\t// (of course it's also possible to get to state {^} with ntrain=(ntrain+1), as long as\n\t// x+suminc[0..i]*time-ntrain*trainsize>=0, by appointing another train at time (time))\n\t//\n\t// Special case: if ntrain == ceildiv(x+suminc[0..i]*time, trainsize) then it's possible to\n\t// get from (first i+1 == 0) to (first i+1 == 0, last train have extra\n\t// (ntrain*trainsize-suminc[0..i]*time-x) cap for next station.\n\n\tint64_t suminc_prev=0;\n\tfor(int i=0;\n\t\t\ti=trainsize and k[i][t][x-trainsize]!=INT64_MAX)\n\t\t\t\t\tcur=k[i][t][x-trainsize]+1; // appoint a train at time 0\n\n\t\t\t\tfor(int t1=1;t1<=(lastinc==0 ? t : std::min(t,(lastcap-x)/lastinc));++t1){\n\t\t\t\t\t// t1: first time after 0 s.t. i first values == 0\n\t\t\t\t\tassert(x+lastinc*(int64_t)t1<=lastcap);\n\t\t\t\t\tif(i!=0 and k[i-1][t1][0]==INT64_MAX) continue;\n\n\t\t\t\t\t// otherwise it's possible to use ...\n\t\t\t\t\tauto ntrain_before_t1=ceildiv(suminc_prev*t1, trainsize);\n\t\t\t\t\t// ... trains and have value of [i] at (t1) =\n\t\t\t\t\tauto val_i_t1=suminc_0i*t1+x-ntrain_before_t1*trainsize;\n\t\t\t\t\tassert(val_i_t1<=x+lastinc*(int64_t)t1);\n\t\t\t\t\tassert(val_i_t1>-trainsize);\n\n\t\t\t\t\tif (val_i_t1>=0){\n\t\t\t\t\t\tif(k[i][t-t1][val_i_t1]!=INT64_MAX)\n\t\t\t\t\t\t\tcur=std::min(cur,ntrain_before_t1+k[i][t-t1][val_i_t1]);\n\t\t\t\t\t}else if (t1==t){\n\t\t\t\t\t\tcur=std::min(cur,ntrain_before_t1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tassert(cur==INT64_MAX or cur<=ceildiv(suminc_0i*time, trainsize));\n\t\t\t}\n\t\t}\n\t}\n\n\tstd::vector g(nstation,std::vector(time+1));\n\t// g[i][time] = is it possible to delete just-past first i+1 stations\n\t// (with max residual cap of last train)?\n\n\tsuminc_prev=0;\n\tint64_t sumval_prev=0;\n\tfor(int i=0;\n\t\t\ticurval){\n\t\t\t\t\t\tif (t1==t){\n\t\t\t\t\t\t\tcur=true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}else{\n\t\t\t\t\t\tif (k[i][t-t1][curval-extraval]!=INT64_MAX){\n\t\t\t\t\t\t\tcur=true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\n\t/*\n\tstd::vector gk(nstation,std::vector(time+1));\n\t// gk: same as k, but initial value of station x (x<=i) is st[x].val instead of 0\n\n\tsuminc_prev=0;\n\tsumval_prev=0;\n\tfor(int i=0;\n\t\t\tilastcap) continue;\n\n\t\t\t\t\t// assume (y) trains are appointed at time <= (t1) (y >= gk[i][t1]).\n\t\t\t\t\t// then (value [i] at t1 (after those y trains are appointed)) = suminc_0i*t1-y*trainsize\n\n\t\t\t\t\tauto min_y=std::max(gk[i][t1],\n\t\t\t\t\t\t\t(suminc_0i*t1-lastcap+added_i_after_t1+trainsize-1)/trainsize\n\t\t\t\t\t\t\t);\n\t\t\t\t\tassert(min_y>=0);\n\t\t\t\t\tassert(suminc_0i*t1-min_y*trainsize+added_i_after_t1<=lastcap);\n\t\t\t\t\tif(suminc_0i*t1-min_y*trainsize<0)\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tcur=std::min(cur,min_y+ntrain_after_t1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t*/\n\n\n\n\tstd::vector h(nstation,std::vector(time+1));\n\t// h[i][time] = min # of train required to make sure that (i+1) first stations will\n\t// not overflow in time (time) with initial value = 0\n\n\tsuminc_prev=0;\n\tfor(int i=0;\n\t\t\ti0 s.t. i+1 first value (all values currently crd) == 0\n\t\t\t\t\t// (if there's any such time)\n\t\t\t\t\tauto ntrain_t1=ceildiv(suminc_0i*t1, trainsize);\n\t\t\t\t\tcur=std::min(cur,ntrain_t1+h[i][t-t1]);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// otherwise if there's no such t1:\n\t\t\tfor(int t2=1;t2<=t;++t2){\n\t\t\t\tif(k[i][t2][0]!=INT64_MAX){\n\t\t\t\t\t// t2: last time s.t. i first value (excl. [i]) == 0\n\t\t\t\t\t// (Such t2 must exist because value[i] needz to be decreased)\n\n\t\t\t\t\tauto const added_i_after_t2=int64_t(t-t2)*lastinc;\n\t\t\t\t\t// (value [i] at t2) + added_i_after_t2 must be <= lastcap\n\t\t\t\t\tif(added_i_after_t2>lastcap) continue;\n\n\t\t\t\t\t// assume (y) trains are appointed at time <= (t2) (y >= k[i][t2][0]).\n\t\t\t\t\t// then (value [i] at t2 (after those y trains are appointed)) = suminc_0i*t2-y*trainsize\n\t\t\t\t\tauto min_y=std::max(k[i][t2][0],\n\t\t\t\t\t\t\tceildiv(suminc_0i*t2-lastcap+added_i_after_t2, trainsize)\n\t\t\t\t\t\t\t);\n\t\t\t\t\tassert(min_y>=0);\n\t\t\t\t\tassert(suminc_0i*t2-min_y*trainsize+added_i_after_t2<=lastcap);\n\t\t\t\t\tif(suminc_0i*t2-min_y*trainsize<0)\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tcur=std::min(cur,min_y+(i ? h[i-1][t-t2] : 0));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tassert(cur!=INT64_MAX);\n\t\t}\n\t}\n\n\n\n\tint64_t min_total_ntrain=INT64_MAX;\n\tfor(int t1=0;t1<=time;++t1) // first time s.t. all station value == 0\n\t\tif(g[nstation-1][t1])\n\t\t\tmin_total_ntrain=std::min(min_total_ntrain,\n\t\t\t\t\tceildiv(total_val+total_inc*t1,trainsize)+h[nstation-1][time-t1]\n\t\t\t\t\t);\n\n\t// if there's no such t1:\n\tassert(not st_back_never_overflow());\n\tfor(int t1=0;t1<=time;++t1){ // first time s.t. all station value except last == 0\n\t\tauto val_t1_before_train=st.back().val+t1*(int64_t)st.back().inc;\n\t\tif(val_t1_before_train<=st.back().cap and (nstation==1 or g[nstation-2][t1])){\n\t\t\tauto const total_val_before_t1=total_val-st.back().val+(total_inc-st.back().inc)*t1;\n\t\t\tauto const ntrain_before_t1=ceildiv(total_val_before_t1,trainsize);\n\t\t\tauto const extracap_t1=ntrain_before_t1*trainsize-total_val_before_t1;\n\t\t\tassert(extracap_t1>=0 and extracap_t1=0){ // otherwise there exists a time s.t. all station value == 0\n\t\t\t\tfor(int t2=t1;t2<=time;++t2){ // last time s.t. all station value except last == 0\n\t\t\t\t\tif(k[nstation-1][t2-t1][val_t1]!=INT64_MAX){\n\t\t\t\t\t\t// assume y = ntrain in time t1..t2.\n\t\t\t\t\t\t// => (val of last at time t2) = val_t1 + total_inc*int64_t(t2-t1) - y*trainsize\n\n\t\t\t\t\t\tauto const added_last_after_t2=int64_t(time-t2)*st.back().inc;\n\t\t\t\t\t\t// (val of last at time t2) + added_last_after_t2 must be <= st.back().cap\n\t\t\t\t\t\tif(added_last_after_t2>st.back().cap) continue;\n\n\t\t\t\t\t\tassert(k[nstation-1][t2-t1][val_t1]>=0);\n\t\t\t\t\t\tauto min_y=std::max(\n\t\t\t\t\t\t\t\tk[nstation-1][t2-t1][val_t1],\n\t\t\t\t\t\t\t\tceildiv(\n\t\t\t\t\t\t\t\t\tstd::max((int64_t)0,\n\t\t\t\t\t\t\t\t\t\tval_t1+total_inc*int64_t(t2-t1)+added_last_after_t2-st.back().cap),\n\t\t\t\t\t\t\t\t\ttrainsize)\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\tassert(min_y>=0);\n\n\t\t\t\t\t\tassert(val_t1 + total_inc*int64_t(t2-t1) - min_y*trainsize + added_last_after_t2\n\t\t\t\t\t\t\t\t<=st.back().cap);\n\n\t\t\t\t\t\tif(val_t1 + total_inc*int64_t(t2-t1) - min_y*trainsize<0)\n\t\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\t\tmin_total_ntrain=std::min(min_total_ntrain,ntrain_before_t1+min_y+\n\t\t\t\t\t\t\t\t(nstation>1 ? h[nstation-2][time-t2] : 0));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tstd::cout<\nusing namespace std;\nconst int N = 234;\nconst long long inf = 1ll << 60;\nlong long a[N], b[N], c[N], sa[N], sb[N], d[N][N][N], g[N][N][N];\nint n, t, k;\nint main() {\n freopen(\"input.txt\", \"r\", stdin);\n cin >> n >> t >> k;\n for (int i = 1; i <= n; ++i)\n cin >> a[i] >> b[i] >> c[i];\n ++n;\n a[n] = c[n] = inf;\n for (int i = 1; i <= n; ++i) {\n sa[i] = sa[i - 1] + a[i];\n sb[i] = sb[i - 1] + b[i];\n }\n for (int p = 1; p <= n; ++p) {\n for (int s = 0; s <= t; ++s) {\n for (int z = 0; z < 2; ++z) {\n d[p][s][z] = g[p][s][z] = inf;\n if (s * b[p] + z * a[p] <= c[p] && d[p - 1][s][z] < inf) {\n d[p][s][z] = d[p - 1][s][z];\n long long value = (z * sa[p - 1] + s * sb[p - 1] + k - 1) / k;\n if (value * k <= z * sa[p] + s * sb[p])\n g[p][s][z] = value;\n }\n for (int r = 0; r < s; ++r) {\n if (g[p][r][z] < inf) {\n long long m = z * sa[p] + r * sb[p] - k * g[p][r][z];\n long long x = (max(m + (s - r) * b[p] - c[p], 0ll) + k - 1) / k;\n if (x * k <= m && d[p - 1][s - r][0] < inf) {\n d[p][s][z] = min(d[p][s][z], g[p][r][z] + x + d[p - 1][s - r][0]);\n long long value = ((s - r) * sb[p - 1] + k - 1) / k;\n if (value * k <= (s - r) * sb[p] + m - x * k) \n g[p][s][z] = min(g[p][s][z], g[p][r][z] + x + value);\n }\n }\n }\n }\n }\n }\n printf(\"%lld\\n\", d[n][t][1]);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "713c8d40497e786f40e82f5d1aacec54", "src_uid": "feee94b7e802fc8e3758350f551b7142", "difficulty": 3400.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define PB push_back \n#define MP make_pair \n#define SZ(v) ((int)(v).size()) \n#define FOR(i,a,b) for(int i=(a);i<(b);++i) \n#define REP(i,n) FOR(i,0,n) \n#define FORE(i,a,b) for(int i=(a);i<=(b);++i) \n#define REPE(i,n) FORE(i,0,n) \n#define FORSZ(i,a,v) FOR(i,a,SZ(v)) \n#define REPSZ(i,v) REP(i,SZ(v)) \ntypedef long long ll;\ntypedef unsigned long long ull;\nll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }\n\nconst int MAXSTAT = 200 + 1; // 1 for dummy station\nconst int MAXT = 200;\n\nint nstat, tend; ll cap;\nll init[MAXSTAT], delta[MAXSTAT], lim[MAXSTAT];\n\nll suminit[MAXSTAT + 1], sumdelta[MAXSTAT + 1];\n\n// dp[i][j][x][y] = minimum trains to survive the first i stations for j-x/2 hours (every train being completely full)\n// when x==1, there needs to be a train that picked up passengers from the last station in the last hour\n// when y==1, include initial number of passengers\nll dp[MAXSTAT + 1][MAXT + 1][2][2];\nvoid upd(ll &a, const ll b) { if (b < a) a = b; }\n\nvoid run() {\n\tscanf(\"%d%d%lld\", &nstat, &tend, &cap);\n\tREP(i, nstat) scanf(\"%lld%lld%lld\", &init[i], &delta[i], &lim[i]);\n\t//nstat = 200; tend = 200; cap = 1; REP(i, nstat) init[i] = delta[i] = lim[i] = 1000000000;\n\n\tinit[nstat] = delta[nstat] = cap, lim[nstat] = (tend + 1)*cap, ++nstat; // add dummy station\n\tsuminit[0] = 0; REP(i, nstat) suminit[i + 1] = suminit[i] + init[i];\n\tsumdelta[0] = 0; REP(i, nstat) sumdelta[i + 1] = sumdelta[i] + delta[i];\n\n\tREPE(i, nstat) REPE(j, tend) REP(x, 2) REP(y, 2) dp[i][j][x][y] = LLONG_MAX;\n\tREPE(j, tend) REP(y, 2) dp[0][j][0][y] = 0;\n\tREPE(i, nstat) REP(y, 2) dp[i][0][0][y] = 0;\n\tFORE(i, 1, nstat) FORE(j, 1, tend) REP(y,2) {\n\t\t// x=1\n\t\tif (y*init[i - 1] + (j - 1)*delta[i - 1] <= lim[i - 1] && dp[i - 1][j - 1][0][y] != LLONG_MAX) { // first train for station i-1\n\t\t\tll have = y*init[i - 1] + (j - 1)*delta[i - 1], cost = 0; assert(have <= lim[i - 1]);\n\t\t\tll rembefore = y*suminit[i - 1] + (j - 1)*sumdelta[i - 1] - dp[i - 1][j - 1][0][y] * cap; assert(rembefore >= 0); cost += rembefore / cap + 1;\n\t\t\tll now = cap*cost - rembefore; assert(now > 0 && now <= cap);\n\t\t\tif (now <= have) upd(dp[i][j][1][y], dp[i - 1][j - 1][0][y] + cost);\n\t\t}\n\t\tFORE(jj, 1, j - 1) if (dp[i][jj][1][y] != LLONG_MAX && dp[i - 1][j - jj][0][0] != LLONG_MAX) { // previous train for station i-1 at jj-1/2\n\t\t\tll have = y*suminit[i] + (jj - 1)*sumdelta[i] - dp[i][jj][1][y] * cap; assert(have >= 0 && have <= lim[i - 1]);\n\t\t\tll dhave = (j - jj)*delta[i - 1], cost1 = 0;\n\t\t\tif (have + dhave > lim[i - 1]) {\n\t\t\t\tcost1 = (have + dhave - lim[i - 1] + cap - 1) / cap;\n\t\t\t\tif (cost1*cap > have) continue;\n\t\t\t\thave -= cost1*cap;\n\t\t\t}\n\t\t\thave += dhave; assert(have <= lim[i - 1]);\n\t\t\tll rembefore = (j - jj)*sumdelta[i - 1] - dp[i - 1][j - jj][0][0] * cap; assert(rembefore >= 0); ll cost2 = rembefore / cap + 1;\n\t\t\tll now = cap*cost2 - rembefore; assert(now > 0 && now <= cap);\n\t\t\tif (now <= have) upd(dp[i][j][1][y], dp[i][jj][1][y] + dp[i - 1][j - jj][0][0] + cost1 + cost2);\n\t\t}\n\t\t// x=0\n\t\tif (y*init[i - 1] + j*delta[i - 1] <= lim[i - 1] && dp[i - 1][j][0][y] != LLONG_MAX) { // no trains for station i-1\n\t\t\t//if (i == 1 && j == 3 && y == 1) printf(\"A%lld\\n\", dp[i - 1][j][0][y]);\n\t\t\tupd(dp[i][j][0][y], dp[i - 1][j][0][y]);\n\t\t}\n\t\tFORE(jj, y == 0 ? 2 : 1, j) if (dp[i][jj][1][y] != LLONG_MAX && dp[i][j - jj + 1][0][0] != LONG_MAX) { // previous trains for station i-1 at jj-1/2\n\t\t\tll have = y*suminit[i] + (jj - 1)*sumdelta[i] - dp[i][jj][1][y] * cap, cost = 0; assert(have >= 0 && have <= lim[i - 1]);\n\t\t\tll dhave = (j - jj + 1)*delta[i - 1];\n\t\t\tif (have + dhave > lim[i - 1]) {\n\t\t\t\tll dcost = (have + dhave - lim[i - 1] + cap - 1) / cap;\n\t\t\t\tif (dcost*cap > have) continue;\n\t\t\t\thave -= dcost*cap, cost += dcost;\n\t\t\t}\n\t\t\thave += dhave; assert(have <= lim[i - 1]);\n\t\t\t//if (i == 1 && j == 3 && y == 1) printf(\"B%lld+%lld+%lld\\n\", dp[i][jj][1][y], dp[i][j - jj + 1][0][0], cost);\n\t\t\tupd(dp[i][j][0][y], dp[i][jj][1][y] + dp[i][j - jj + 1][0][0] + cost);\n\t\t}\n\t}\n\t//REPE(i, nstat) REPE(j, tend) { printf(\"%d,%d:\", i, j); REP(x, 2) REP(y, 2) if (dp[i][j][x][y] == LLONG_MAX) printf(\" X\"); else printf(\" %lld\", dp[i][j][x][y]); puts(\"\"); }\n\n\tll ans = dp[nstat][tend][0][1];\n\tprintf(\"%lld\\n\", ans == LLONG_MAX ? -1 : ans);\n}\n\nint main() {\n\trun();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "69f5f5eec4040e9aa624e6595da27610", "src_uid": "feee94b7e802fc8e3758350f551b7142", "difficulty": 3400.0} {"lang": "GNU C++17", "source_code": "#error \"Wrong solution? :(\"\n// Not very rigorously proven...\n#ifndef LOCAL\n#define NDEBUG\n#endif\n#include\n#include\n#include\n\nint main(){\n\tstd::ios::sync_with_stdio(0);std::cin.tie(0);\n\tstruct station{\n\t\tint val,inc,cap;\n\t};\n\tint nstation,time,trainsize;\n\tstd::cin>>nstation>>time>>trainsize;\n\tstd::vector st(nstation);\n\tfor(auto& [val,inc,cap]:st)\n\t\tstd::cin>>val>>inc>>cap;\n\n\tint64_t nstep=0;\n\tfor(int t=0;tcap){\n\t\t\t\tlast_need_take_now=i;\n\t\t\t}\n\t\t\tif(val+inc*int64_t(time-t)>cap)\n\t\t\t\tlast_need_take=i;\n\t\t}\n\n\t\tif(last_need_take<0){\n\t\t\tassert(last_need_take_now<0);\n\t\t\tbreak;\n\t\t}\n\n\t\tassert(last_need_take_now<0 or last_need_take_now<=last_need_take);\n\n\t\tfor(int i=0;i<=last_need_take;++i){\n\t\t\tauto& [val,inc,cap]=st[i];\n\t\t\tnstep+=val/trainsize; val%=trainsize;\n\n\t\t\tif(val==0)continue;\n\n\t\t\tint j=i+1;\n\t\t\tint64_t sumij=val; // [i..j[\n\t\t\tassert(0i);\n\t\t\tfor(int k=i;k\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long lint;\n\nstruct tarjan_t {\n int n;\n vector> adj;\n vector preorder, inv_preorder;\n stack active;\n vector is_active;\n vector cnt_of;\n vector> cnts;\n tarjan_t(int _n)\n : n(_n)\n , adj(n)\n , inv_preorder(n, -1)\n , is_active(n, false)\n , cnt_of(n, -1) {}\n int dfs(int v) {\n inv_preorder[v] = preorder.size();\n preorder.push_back(v);\n active.push(v);\n is_active[v] = true;\n int highest = inv_preorder[v];\n for (int u : adj[v]) {\n if (inv_preorder[u] == -1)\n highest = max(highest, dfs(u));\n else if (is_active[u])\n highest = max(highest, inv_preorder[u]);\n }\n if (highest == inv_preorder[v]) {\n int u;\n vector cnt;\n do {\n u = active.top();\n active.pop();\n is_active[u] = false;\n cnt_of[u] = cnts.size();\n cnt.push_back(u);\n } while (u != v);\n cnts.push_back(move(cnt));\n }\n return highest;\n }\n void solve() {\n for (int i = 0; i < n; ++i)\n if (inv_preorder[i] == -1)\n dfs(i);\n }\n};\n\nstruct twosat_t {\n int n;\n vector> adj;\n twosat_t() {}\n twosat_t(int _n): n(_n), adj(2 * n) {}\n bool solve() {\n tarjan_t tarjan(2 * n);\n tarjan.adj = adj;\n tarjan.solve();\n for (int i = 0; i < n; ++i)\n if (tarjan.cnt_of[2 * i + 0] == tarjan.cnt_of[2 * i + 1])\n return false;\n return true;\n }\n void add_or(int a, int b) {\n adj[a ^ 1].push_back(b);\n adj[b ^ 1].push_back(a);\n }\n void set(int a) {\n adj[a ^ 1].push_back(a);\n }\n};\n\nenum op_t { AND = 0, OR, NAND, NOR, NONE };\n\nint apply(op_t op, int a, int b) {\n switch (op) {\n case AND: return a & b;\n case OR: return a | b;\n case NAND: return !(a & b);\n case NOR: return !(a | b);\n default: return -1;\n }\n}\n\nop_t mirror(op_t op) {\n switch (op) {\n case AND: return OR;\n case NAND: return NOR;\n case OR: return AND;\n case NOR: return NAND;\n default: return NONE;\n }\n}\n\nstruct gate_t {\n int id = -1;\n op_t op = NONE;\n gate_t *left = nullptr, *right = nullptr;\n int enforce_value = -1;\n gate_t() {}\n gate_t(int _id): id(_id) {}\n gate_t(op_t _op, gate_t *_left, gate_t *_right)\n : op(_op), left(_left), right(_right) {}\n int regular() {\n if (enforce_value != -1) return enforce_value;\n assert(id == -1);\n return apply(op, left->regular(), right->regular());\n }\n int other() {\n if (enforce_value != -1) return enforce_value;\n assert(id == -1);\n return apply(mirror(op), left->regular(), right->regular());\n }\n void add_constraints(int target, twosat_t &twosat) {\n int a = left->id, b = right->id;\n op_t eff_op = op;\n if (eff_op == NAND) {\n eff_op = AND;\n target ^= 1;\n }\n if (eff_op == NOR) {\n eff_op = OR;\n target ^= 1;\n }\n if (eff_op == AND) {\n if (target == 0) twosat.add_or(2 * a + 0, 2 * b + 0);\n else {\n twosat.set(2 * a + 1);\n twosat.set(2 * b + 1);\n }\n } else if (eff_op == OR) {\n if (target == 0) {\n twosat.set(2 * a + 0);\n twosat.set(2 * b + 0);\n } else {\n twosat.add_or(2 * a + 1, 2 * b + 1);\n }\n } else assert(0);\n }\n};\n\nstring read_string() {\n char *str;\n scanf(\"%ms\", &str);\n string result(str);\n free(str);\n return result;\n}\n\nop_t read_op() {\n string s = read_string();\n if (s == \"and\") return AND;\n if (s == \"or\") return OR;\n if (s == \"nand\") return NAND;\n if (s == \"nor\") return NOR;\n return NONE;\n}\n\nvector read_ids() {\n string s = read_string();\n vector ids;\n for (int i = 0; i < (int)s.size(); ++i)\n if (s[i] == 'x')\n ids.push_back(i);\n return ids;\n}\n\nint main() {\n int ni, n1, n2;\n scanf(\"%d %d %d\", &ni, &n1, &n2);\n vector input(ni);\n for (int i = 0; i < ni; ++i)\n input[i] = {i};\n vector l1(n1);\n for (int i = 0; i < n1; ++i) {\n op_t op = read_op();\n vector ids = read_ids();\n l1[i] = {op, &input[ids[0]], &input[ids[1]]};\n }\n vector l2(n2);\n for (int i = 0; i < n2; ++i) {\n op_t op = read_op();\n vector ids = read_ids();\n l2[i] = {op, &l1[ids[0]], &l1[ids[1]]};\n }\n\n vector> adj(n2);\n vector removed(n2, false);\n for (int i = 0; i < n2; ++i)\n for (int j = i; j < n2; ++j) {\n vector ids;\n for (int k : {i, j})\n for (auto child1 : {&gate_t::left, &gate_t::right})\n for (auto child2 : {&gate_t::left, &gate_t::right})\n ids.push_back((l2[k].*child1->*child2)->id);\n sort(ids.begin(), ids.end());\n ids.resize(unique(ids.begin(), ids.end()) - ids.begin());\n bool conflict = false;\n for (int mask = 0; mask < (1<<(int)ids.size()); ++mask) {\n for (int k = 0; k < (int)ids.size(); ++k)\n input[ids[k]].enforce_value = ((mask & (1< mark(n2, false);\n vector left_side, right_side;\n for (int i = 0; i < n2; ++i) {\n if (!removed[i] && !mark[i]) {\n vector side0, side1;\n function dfs = [&](int v, int s) {\n mark[v] = true;\n if (s == 0) side0.push_back(v);\n else side1.push_back(v);\n for (int u : adj[v])\n if (!removed[u] && !mark[u])\n dfs(u, s ^ 1);\n };\n dfs(i, 0);\n if (side0.size() > side1.size()) swap(side0, side1);\n left_side.insert(left_side.end(), side0.begin(), side0.end());\n right_side.insert(right_side.end(), side1.begin(), side1.end());\n }\n }\n\n const int nleft = left_side.size(), nright = right_side.size();\n vector left_adj_mask(nleft);\n for (int i = 0; i < nleft; ++i) {\n int v = left_side[i];\n for (int u : adj[v])\n if (!removed[u]) {\n int j =\n find(right_side.begin(), right_side.end(), u) - right_side.begin();\n assert(j < nright);\n left_adj_mask[i] |= 1LL< half1_mask(1< &half_mask : {ref(half1_mask), ref(half2_mask)}) {\n for (int i = 1; i < (int)half_mask.size(); ++i) {\n int low_bit = i&-i;\n half_mask[i] |= half_mask[low_bit];\n half_mask[i] |= half_mask[i ^ low_bit];\n }\n }\n\n int max_keep = -1;\n const bool ensure_maximal = (nright <= 29);\n vector visited_right;\n if (ensure_maximal) visited_right.resize(1<= 0; --left_mask) {\n lint adj_right_mask = half1_mask[((1 << half1) - 1) & left_mask] |\n half2_mask[left_mask >> half1];\n lint right_mask = ((1LL< cands;\n for (int i = 0; i < nleft; ++i) if (left_mask & (1< notrigger_masks;\n for (int mask = 0; mask < (1<<2); ++mask) {\n for (int k = 0; k < 2; ++k)\n subs[k]->enforce_value = ((mask & (1 << k)) != 0);\n bool trigger = gate.regular() || gate.other();\n if (!trigger) notrigger_masks.push_back(mask);\n }\n for (int k = 0; k < 2; ++k) subs[k]->enforce_value = -1;\n if (notrigger_masks.size() == 1) {\n for (int k = 0; k < 2; ++k)\n subs[k]->add_constraints(((notrigger_masks[0] & (1<\n#include \n#include \n\nusing namespace std;\n\nstruct Gate {\n int kind,x,y;\n Gate() {}\n Gate(int a,int b,int c):kind(a),x(b),y(c) {}\n};\n\nGate a[55];\n\nbool in[55];\n\nint calc(Gate t,int n) {\n memset(in,0,sizeof(in));\n in[a[t.x].x]=in[a[t.x].y]=1;\n in[a[t.y].x]=in[a[t.y].y]=1;\n int cnt=0;\n for(int i=1;i<=n;i++) cnt+=in[i];\n int x=t.kind,y=a[t.x].kind,z=a[t.y].kind;\n if (cnt==2) {\n \tif (x==1&&y==1&&z==3) return 1;\n \tif (x==1&&y==3&&z==1) return 1;\n \tif (x==3&&y==1&&z==3) return 3;\n \tif (x==3&&y==3&&z==1) return 3;\n \tif (x==1&&y==2&&z==4) return 1;\n \tif (x==1&&y==4&&z==2) return 1;\n \tif (x==3&&y==2&&z==4) return 3;\n \tif (x==3&&y==4&&z==2) return 3;\n \tif (x==4&&y==1&&z==3) return 1;\n \tif (x==4&&y==3&&z==1) return 1;\n \tif (x==2&&y==1&&z==3) return 3;\n \tif (x==2&&y==3&&z==1) return 3;\n \tif (x==4&&y==2&&z==4) return 1;\n \tif (x==4&&y==4&&z==2) return 1;\n \tif (x==2&&y==2&&z==4) return 3;\n \tif (x==2&&y==4&&z==2) return 3;\n \tif (x==1&&y==1&&z==4) return 2;\n \tif (x==1&&y==4&&z==1) return 2;\n \tif (x==3&&y==3&&z==2) return 4;\n \tif (x==3&&y==2&&z==3) return 4;\n \tif (x==4&&y==3&&z==2) return 2;\n \tif (x==4&&y==2&&z==3) return 2;\n \tif (x==2&&y==1&&z==4) return 4;\n \tif (x==2&&y==4&&z==1) return 4;\n }\n else if (cnt==3) {\n \tif (x==1&&y==1&&z==4) return 2;\n \tif (x==1&&y==4&&z==1) return 2;\n \tif (x==3&&y==3&&z==2) return 4;\n \tif (x==3&&y==2&&z==3) return 4;\n }\n return 0;\n}\n\nchar str[100];\n\nGate read() {\n scanf(\"%s\",str+1);\n Gate now;\n if (str[1]=='a') now.kind=1;\n else if (str[1]=='o') now.kind=2;\n else if (str[2]=='a') now.kind=3;\n else now.kind=4;\n scanf(\"%s\",str+1);\n int len=strlen(str+1);\n for(int i=1;i<=len;i++)\n if (str[i]=='x') {\n\t now.x=i;\n\t break;\n }\n for(int i=now.x+1;i<=len;i++)\n if (str[i]=='x') {\n \tnow.y=i;\n \tbreak;\n\t}\n return now;\n}\n\nint cnt[5];\n\nint main() {\n int n,m,k;\n scanf(\"%d%d%d\",&n,&m,&k);\n for(int i=1;i<=m;i++) a[i]=read();\n for(int i=1;i<=k;i++) {\n \tGate x=read();\n \tint t=calc(x,n);\n \tcnt[t]++;\n }\n int ans=0;\n if (cnt[1]) ans=max(ans,cnt[1]+cnt[2]);\n if (cnt[3]) ans=max(ans,cnt[3]+cnt[4]);\n printf(\"%d\\n\",(ans)?k-ans:-1);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2dcf59e8a143b6413f0e7ab7a334f410", "src_uid": "2f80021e297dd57e306d2a50c3590bea", "difficulty": 3200.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \ntypedef long long ll;\nusing namespace std;\n#define INF 2147483647\n#define infL (1LL<<60)\n#define inf (1<<30)\n#define inf9 (1000000000)\n#define MOD 1000000007\n#define EPS 1e-9\n#define Gr 9.8\n#define PI acos(-1)\n#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)\n#define REQ(i,n) for(int (i)=1;(i)<=(int)(n);(i)++)\n#define lch (rt<<1)\n#define rch (rt<<1|1)\n#define readmp(n) for(int i=0,u,v;i pii;\ntypedef pair pll;\ntypedef long double ld;\ntypedef unsigned int uint;\ntypedef unsigned long long ull;\ntemplate void maxtt(T& t1, T t2) {\n t1=max(t1,t2);\n}\ntemplate void mintt(T& t1, T t2) {\n t1=min(t1,t2);\n}\n#define MAX 105\n\nbool debug = 0;\nint n,m,k;\nint dx[4] = {0,1,0,-1}, dy[4] = {1,0,-1,0};\nstring direc=\"RDLU\";\nll ln, lk, lm;\nvoid etp(bool f = 0) {\n puts(f ?\"YES\" : \"NO\");\n exit(0);\n}\nvoid addmod(int &x, int y, int mod = MOD) {\n assert(y>=0);\n x+=y; if (x>=mod) x-=mod;\n assert(x>=0 && x0) {\n if(y&1) ans = (x * ans)%mod;\n x = x*x%mod;\n y>>=1;\n }\n return ans;\n}\nll gcd1(ll x, ll y) { return y?gcd1(y,x%y):x;}\n\nstruct yq {\n string ope;\n bool smV = false;\n int a,b;\n void rd(int n) {\n string tmp; cin>>ope>>tmp;\n a=0;b=0;\n REP(i,n) if (tmp[i]=='x') {\n if(a==0) a=i+1; else b=i+1;\n }\n }\n}l3[55], l2[55];\nbool isSpa(yq &x, yq &y) {\n return x.a==y.a&&x.b==y.b;\n}\nbool isCpa(yq &x, yq &y) {\n return x.a==y.a||x.a==y.b ||x.b==y.a||x.b==y.b;\n}\nint getType(yq &o) {\n yq c1=l3[o.a], c2=l3[o.b];\n if (!o.smV) {\n if (!isCpa(c1, c2)) return -1;\n if (o.ope==\"and\") {\n if (c1.ope==\"and\" && c2.ope==\"nor\") return 0;\n if (c2.ope==\"and\" && c1.ope==\"nor\") return 0;\n }\n return -1;\n }\n \n if (o.ope==\"and\") {\n if (c1.ope==\"and\" && c2.ope==\"nand\") return 1;\n if (c1.ope==\"or\" && c2.ope==\"nor\") return 1;\n swap(c1,c2);\n if (c1.ope==\"and\" && c2.ope==\"nand\") return 1;\n if (c1.ope==\"or\" && c2.ope==\"nor\") return 1;\n } else if (o.ope==\"nor\") {\n if (c1.ope==\"and\" && c2.ope==\"nand\") return 1;\n if (c1.ope==\"or\" && c2.ope==\"nor\") return 1;\n if (c1.ope==\"nand\" && c2.ope==\"or\") return 0;\n swap(c1,c2);\n if (c1.ope==\"and\" && c2.ope==\"nand\") return 1;\n if (c1.ope==\"or\" && c2.ope==\"nor\") return 1;\n if (c1.ope==\"nand\" && c2.ope==\"or\") return 0;\n }\n return -1;\n}\nint getType2(yq &o) {\n yq c1=l3[o.a], c2=l3[o.b];\n if (!o.smV) {\n if (!isCpa(c1, c2)) return -1;\n if (o.ope==\"or\") {\n if (c1.ope==\"and\" && c2.ope==\"nor\") return 0;\n if (c2.ope==\"and\" && c1.ope==\"nor\") return 0;\n }\n return -1;\n }\n if (o.ope==\"or\") {\n if (c1.ope==\"and\" && c2.ope==\"nand\") return 1;\n if (c1.ope==\"or\" && c2.ope==\"nor\") return 1;\n swap(c1,c2);\n if (c1.ope==\"and\" && c2.ope==\"nand\") return 1;\n if (c1.ope==\"or\" && c2.ope==\"nor\") return 1;\n } else if (o.ope==\"nand\") {\n if (c1.ope==\"and\" && c2.ope==\"nand\") return 1;\n if (c1.ope==\"or\" && c2.ope==\"nor\") return 1;\n if (c1.ope==\"nand\" && c2.ope==\"or\") return 0;\n swap(c1,c2);\n if (c1.ope==\"and\" && c2.ope==\"nand\") return 1;\n if (c1.ope==\"or\" && c2.ope==\"nor\") return 1;\n if (c1.ope==\"nand\" && c2.ope==\"or\") return 0;\n }\n return -1;\n}\nint ans=-1,cc[2];\nvoid fmain(int ID) {\n scanf(\"%d%d%d\", &k, &n, &m);\n REQ(i,n) l3[i].rd(k);\n REQ(i,m) l2[i].rd(n);\n \n REP(i,2)cc[i]=0;\n REQ(i,m) {\n l2[i].smV = isSpa(l3[l2[i].a], l3[l2[i].b]);\n int z=getType(l2[i]);\n if (z!=-1) cc[z]++;\n }\n if (cc[1]) ans=cc[0]+cc[1];\n //rev\n REP(i,2)cc[i]=0;\n REQ(i,m) {\n int z=getType2(l2[i]);\n if (z!=-1) cc[z]++;\n }\n if (cc[1]) maxtt(ans, cc[0]+cc[1]);\n if (ans!=-1) ans=m-ans;\n printf(\"%d\\n\", ans);\n}\n\nint main() {\n int t=1;\n// scanf(\"%d\", &t);\n REQ(i,t) {\n fmain(i);\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9843de579af061eac8ef9cfdabdfae5a", "src_uid": "2f80021e297dd57e306d2a50c3590bea", "difficulty": 3200.0} {"lang": "GNU C++17", "source_code": "#include \n\n#define F0R(i, a) for(int i = 0; i < (a); i++)\n#define FOR(i, a, b) for(int i = (a); i < (b); i++)\n#define R0F(i, a) for(int i = (a) - 1; i >= 0; i--)\n#define ROF(i, a, b) for(int i = (b) - 1; i >= (a); i--)\n\n#define ran() (rand() & 0x7FFF)\n#define rand31() ((ran() << 16) | (ran() << 1) | (ran() & 1))\n#define rand32() ((ran() << 17) | (ran() << 2) | (ran() & 3))\n#define rand63() (((ll)ran() << 48) | ((ll)ran() << 33) | ((ll)ran() << 18) | ((ll)ran() << 3) | ((ll)ran() & 7))\n#define rand64() (((ll)ran() << 49) | ((ll)ran() << 34) | ((ll)ran() << 19) | ((ll)ran() << 4) | ((ll)ran() & 15))\n\n#define F first\n#define S second\n#define PB push_back\n#define MP make_pair\n#define MT make_tuple\n#define UB upper_bound\n#define LB lower_bound\n#define X real()\n#define Y imag()\n\n#define PI acos(-1)\n\n#define sz(x) ((int)(x).size())\n#define all(x) (x).begin(), (x).end()\n#define SQ(x) ((x) * (x))\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef unsigned long long ull;\ntypedef pair pii;\ntypedef vector vi;\ntypedef vector vpii;\ntypedef vector vll;\ntypedef vector vul;\ntypedef complex point;\ntypedef complex cld;\ntypedef vector vcld;\n\nstruct op {\n string ot;\n int conn1, conn2;\n int getConn(int idx) { return idx?conn2:conn1; }\n};\n\nint n, m, k;\nint val[2][50];\nvector ops[2];\nbool occ[50][4];\n\nstring neg(string ot) {\n if (ot[0] == 'n') return ot.substr(1, sz(ot) - 1);\n return \"n\" + ot;\n}\n\nint apply(string ot, int b1, int b2, bool flip=false) {\n if (flip) ot = neg(ot);\n if (ot == \"and\") return b1 & b2;\n if (ot == \"or\") return b1 | b2;\n if (ot == \"nand\") return 1 ^ (b1 & b2);\n if (ot == \"nor\") return 1 ^ (b1 | b2);\n}\n\nop readOp(int connlen) {\n string ot, conns;\n cin >> ot >> conns;\n vi v;\n F0R(i, n) if(conns[i] == 'x') v.PB(i);\n return {ot, v[0], v[1]};\n}\n\nint eval(int idx, bool flip) {\n F0R(i, 2) {\n int opidx = ops[1][idx].getConn(i);\n op o = ops[0][opidx];\n val[1][opidx] = apply(o.ot, val[0][o.conn1], val[0][o.conn2], flip);\n }\n op o = ops[1][idx];\n return apply(o.ot, val[1][o.conn1], val[1][o.conn2], flip);\n}\n\nint main() {\n ios::sync_with_stdio(0);\n\tcin.tie(0);\n cin >> n >> m >> k;\n F0R(i, m) ops[0].PB(readOp(n));\n F0R(i, k) ops[1].PB(readOp(m));\n bool has[2]{0, 0};\n int cnt[2]{0, 0};\n F0R(i, k) {\n set inps;\n F0R(a, 2) F0R(b, 2) inps.insert(ops[0][ops[1][i].getConn(a)].getConn(b));\n vi v(all(inps));\n F0R(mask, 1 << sz(v)) {\n F0R(j, sz(v)) val[0][v[j]] = (mask >> j) & 1;\n occ[i][(eval(i, false) << 1) | eval(i, true)] = 1;\n }\n if (occ[i][3]) continue;\n if (occ[i][1]) {\n cnt[0]++;\n if (!occ[i][0]) has[0] = 1;\n }\n if (occ[i][2]) {\n cnt[1]++;\n if (!occ[i][0]) has[1] = 1;\n }\n }\n int res = 0;\n F0R(i, 2) if (has[i]) res = max(res, cnt[i]);\n if (res == 0) cout << -1 << endl;\n else cout << k - res << endl;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b23cd5874505cb99edceab061ced45e0", "src_uid": "2f80021e297dd57e306d2a50c3590bea", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "#include\n#define inf 0x7f7f7f7f\nint l,Test_num,mxc,mxx;\nchar ch[53];\nint f[53][53][511][2];\nint dp(int pos,int c,int x,int delta)\n{\n\tif(pos==l) return c?inf:0;\n\tif(c>mxc||c<-mxc||x>mxx||x<-mxx) return inf;\n\tif(!(~f[pos][c+mxc][x+mxx][(delta==1)]))\n\t{\n\t f[pos][c+mxc][x+mxx][(delta==1)]=min(dp(pos,c,x+delta,delta)+l-pos,min(dp(pos+1,c*10+ch[pos+1]-x,x,1),dp(pos+1,c*10+ch[pos+1]-x,x,-1)));\n\t}\n\treturn f[pos][c+mxc][x+mxx][(delta==1)];\n}\nint main()\n{\n\tscanf(\"%s\",ch+2);\n\tl=strlen(ch+2)+1;\n\tch[1]=0;\n\tmxx=5*l;\n\tmxc=mxx/10+1;\n\tfor(int i=2;i<=l;i++)\n\t{\n\t ch[i]^=48;\n\t}\n\tmemset(f,-1,sizeof(f));\n\tprintf(\"%d\",dp(0,0,0,1));\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "eae80c94014389e9ae3ca6d0e80ac458", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907", "difficulty": 2900.0} {"lang": "GNU C++17", "source_code": "#include \r\n\r\nusing namespace std;\r\n\r\n#pragma GCC optimize(\"unroll-loops\")\r\n#pragma GCC optimize(\"Ofast\")\r\n#pragma GCC optimize(\"-O3\")\r\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native\")\r\n\r\n\r\n#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\r\n#define md(l, r) l + (r - l) / 2\r\n#define ll long long\r\n#define btw(a, l, r) a.begin() + l, a.begin() + r + 1\r\n#define F first\r\n#define S second\r\n#define pb push_back\r\n#define all(x) x.begin(), x.end()\r\n#define sz(x) (int(x.size()))\r\n#define sqr(x) (x) * (x)\r\n#define endl '\\n'\r\n\r\n#define getfiles ifstream cin(\"input.txt\"); ofstream cout(\"output.txt\");\r\n#define clr(x, y) memset((x), (y), sizeof (x))\r\n#define ld long double\r\ntypedef pair pii;\r\ntypedef vector vi;\r\ntypedef vector > vvi;\r\ntypedef vector > > vvpii;\r\ntypedef vector > > vvpll;\r\ntypedef pair > piii;\r\ntypedef vector vll;\r\ntypedef vector > vpii;\r\ntypedef vector > vpll;\r\ntypedef vector > vvll;\r\ntypedef vector > > vplll;\r\ntypedef pair pll;\r\n\r\nconst ld eps = -1e9;\r\nconst long long N = 200001, P = 1e9 + 7, P1 = 1e9 + 13, iINF = 1e9, INF = 2e18, K = 73, K1 = 79;\r\n\r\nll dstF(ll x, ll y, ll xx, ll yy) {\r\n return (sqr(x - xx) + sqr(y - yy));\r\n}\r\n\r\nld dstSqrtF(ll x, ll y, ll xx, ll yy) {\r\n return (sqrt(sqr(x - xx) + sqr(y - yy)));\r\n}\r\n\r\nll _bp(ll val, ll st, ll p) {\r\n if (st == 0) {\r\n return 1;\r\n }\r\n ll temp = _bp(val, st / 2, p);\r\n temp = sqr(temp);\r\n temp %= p;\r\n if (st % 2 == 1) {\r\n temp *= val;\r\n temp %= p;\r\n }\r\n return temp;\r\n}\r\n\r\nll _bp(ll val, ll st) {\r\n if (st == 0) {\r\n return 1;\r\n }\r\n ll temp = _bp(val, st / 2);\r\n temp = sqr(temp);\r\n if (st % 2 == 1) {\r\n temp *= val;\r\n }\r\n return temp;\r\n}\r\n\r\nll nok(ll a, ll b) {\r\n return (a / __gcd(a, b) * b);\r\n}\r\n\r\n#define int long long\r\n\r\nint n, ans = 1e18;\r\nint st[100], dp[100];\r\n\r\nvoid solve() {\r\n cin >> n;\r\n int n1 = n;\r\n int k = 0;\r\n while (n1 != 0) {\r\n k++;\r\n n1 /= 10;\r\n }\r\n int tp = n;\r\n st[0] = 1;\r\n for (int i = 1; i <= k; i++) {\r\n st[i] = st[i - 1] * 10;\r\n }\r\n while (dp[0] == 0) {\r\n int curVal = 0;\r\n n = tp;\r\n for (int i = 1; i < k; i++) {\r\n int x = (n / st[k - i]);\r\n int y = x;\r\n if (x * ((st[k - i + 1] - 1) / 9) >= n) {\r\n y--;\r\n } else {\r\n y++;\r\n }\r\n z = max(x, y) + 1;\r\n if (dp[i] == 0) {\r\n n -= x * ((st[k - i + 1] - 1) / 9);\r\n curVal += x * (k - i + 1);\r\n } else {\r\n n -= max(0ll, y) * ((st[k - i + 1] - 1) / 9);\r\n curVal += y * (k - i + 1);\r\n } else {\r\n n -= max(0ll, z) * ((st[k - i + 1] - 1) / 9);\r\n curVal += z * (k - i + 1);\r\n }\r\n n = abs(n);\r\n }\r\n curVal += n;\r\n ans = min(ans, curVal);\r\n int p = k;\r\n while (dp[p] == 2) {\r\n dp[p] = 0;\r\n --p;\r\n }\r\n dp[p]++;\r\n }\r\n cout << ans;\r\n}\r\n\r\nsigned main() {\r\n fast_io;\r\n int q;\r\n q = 1;\r\n //cin >> q;\r\n while (q != 0) {\r\n solve();\r\n --q;\r\n }\r\n}\r\n\r\n\r\n\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a64e9b22281ab408effe997fecc3456f", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907", "difficulty": 2900.0} {"lang": "GNU C++17 (64)", "source_code": "//*\r\n#pragma GCC target(\"avx2\")\r\n#pragma GCC optimize(\"O3\")\r\n#pragma GCC optimize(\"unroll-loops\")\r\n//*/\r\n \r\n#include \r\n \r\n// #include \r\n \r\nusing namespace std;\r\n// using namespace atcoder;\r\n \r\n#define DEBUG(x) cerr<<#x<<\": \"<\r\n#define vl vector\r\n#define vii vector< vector >\r\n#define vll vector< vector >\r\n#define vs vector\r\n#define pii pair\r\n#define pis pair\r\n#define psi pair\r\n#define pll pair\r\ntemplate pair operator+(const pair &s, const pair &t) { return pair(s.first + t.first, s.second + t.second); }\r\ntemplate pair operator-(const pair &s, const pair &t) { return pair(s.first - t.first, s.second - t.second); }\r\ntemplate ostream& operator<<(ostream& os, pair p) { os << \"(\" << p.first << \", \" << p.second << \")\"; return os; }\r\n#define X first\r\n#define Y second\r\n#define rep(i,n) for(int i=0;i<(int)(n);i++)\r\n#define rep1(i,n) for(int i=1;i<=(int)(n);i++)\r\n#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)\r\n#define rrep1(i,n) for(int i=(int)(n);i>0;i--)\r\n#define REP(i,a,b) for(int i=a;i bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }\r\n#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());\r\nconst ll inf = 1000000001;\r\nconst ll INF = (ll)1e18 + 1;\r\nconst long double pi = 3.1415926535897932384626433832795028841971L;\r\nint popcount(ll t) { return __builtin_popcountll(t); }\r\n// int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};\r\n// int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };\r\nvi dx = {0, 1, 0, -1}, dy = {-1, 0, 1, 0};\r\n// vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };\r\nstruct Setup_io {\r\n Setup_io() {\r\n ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\r\n cout << fixed << setprecision(25);\r\n }\r\n} setup_io;\r\nconst ll MOD = 1000000007;\r\n// const ll MOD = 998244353;\r\n// #define mp make_pair\r\n//#define endl '\\n'\r\n\r\nconst int N = 50, M = 270, K = 60;\r\nconst int offset = 30;\r\nint dp[2][M][M][K];\r\narray pre[N + 1][M][M][K];\r\n\r\nint carry(int x) {\r\n if (x >= 0) return x / 10 + offset;\r\n else if (x % 10 != 0) return x / 10 - 1 + offset;\r\n else return x / 10 + offset;\r\n}\r\n\r\nsigned main() {\r\n string s;\r\n cin >> s;\r\n s = \"000\"s + s;\r\n int n = s.size();\r\n\r\n rep (j, M) rep (k, M) rep (c, K) dp[0][j][k][c] = inf;\r\n rep (j, M) rep (k, M) {\r\n int x = j - k;\r\n int d = (x % 10 + 10) % 10;\r\n if (s.back() - '0' == d) {\r\n dp[0][j][k][carry(x)] = j + k;\r\n }\r\n }\r\n\r\n int now = 0, nex = 1;\r\n for (int i = n - 2; i >= 0; i--) {\r\n rep (j, M) rep (k, M) rep (c, K) {\r\n dp[nex][j][k][c] = inf;\r\n }\r\n\r\n rep (j, M) rep (k, M) rep (C, K) {\r\n if (dp[now][j][k][C] == inf) continue;\r\n int c = C - offset;\r\n\r\n for (int d = 0; d < 10; d++) {\r\n int nj = j - d;\r\n if (nj < 0) break;\r\n int nk = k;\r\n int x = nj - nk + c;\r\n int y = (x % 10 + 10) % 10;\r\n if (s[i] - '0' == y) {\r\n if (chmin(dp[nex][nj][nk][carry(x)], dp[now][j][k][C] + nj + nk)) {\r\n pre[nex][nj][nk][carry(x)] = {now, j, k, C};\r\n }\r\n }\r\n }\r\n\r\n for (int d = 1; d < 10; d++) {\r\n int nj = j;\r\n int nk = k - d;\r\n if (nk < 0) break;\r\n int x = nj - nk + c;\r\n int y = (x % 10 + 10) % 10;\r\n if (s[i] - '0' == y) {\r\n if (chmin(dp[nex][nj][nk][carry(x)], dp[now][j][k][C] + nj + nk)) {\r\n pre[nex][nj][nk][carry(x)] = {now, j, k, C};\r\n }\r\n }\r\n }\r\n }\r\n swap(now, nex);\r\n // now++; nex++;\r\n }\r\n\r\n cout << dp[now][0][0][offset] << endl;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6d7574f5f6fcf2334a3153d732dd8aed", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907", "difficulty": 2900.0} {"lang": "GNU C++17 (64)", "source_code": "#pragma GCC optimize \"O3\" \r\n#include\r\nusing namespace std;\r\n\r\n#define sz(s) (int)s.size()\r\n#define f first\r\n#define s second\r\n#define pb push_back\r\n#define all(s) s.begin(), s.end()\r\n\r\n#define vi vector\r\n#define vvi vector\r\n#define ll long long\r\n#define ull unsigned ll\r\n#define vll vector\r\n\r\n#define ii pair\r\n#define vii vector\r\n#define vvii vector\r\n\r\nconst int INF = 1e9 + 7;\r\nconst int mod = 998244353;\r\n// const int N = 1e6 + 7;\r\nconst int T = 1 << 20;\r\n#define ld long double\r\n\r\ntemplate ostream & operator << (ostream&os, const pair & para) { os << para.first << ' ' << para.second; return os; }\r\ntemplate ostream & operator << (ostream&os, const vector & vec){ for(const auto & el : vec) os << el << ' '; return os; }\r\n\r\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\r\n#define losuj(a, b) uniform_int_distribution(a, b)(rng)\r\n\r\nshort dp[51][251][251][101];\r\n\r\nvoid solve(){\r\n for(int i = 0; i <= 50; i++)\r\n for(int j = 0; j <= 250; j++)\r\n for(int a = 0; a <= 250; a++)\r\n for(int b = 0; b <= 100; b++)\r\n dp[i][j][a][b] = 20000;\r\n dp[0][250][250][0] = 0;\r\n\r\n string s;\r\n cin >> s;\r\n reverse(all(s));\r\n int n = sz(s);\r\n\r\n for(int i = 0; i <= n; i++)\r\n for(int carry = 0; carry <= 100; carry++)\r\n for(int a = 250; a >= 0; a--)\r\n for(int b = 250; b >= 0; b--){\r\n if(a < 250)\r\n dp[i][a][b][carry] = min(dp[i][a][b][carry], dp[i][a + 1][b][carry]);\r\n if(b < 250)\r\n dp[i][a][b][carry] = min(dp[i][a][b][carry], dp[i][a][b + 1][carry]);\r\n \r\n if(i == sz(s))\r\n continue;\r\n int sum_bit = (a - b + carry - (s[i] - '0'));\r\n int new_carry = sum_bit / 10;\r\n if(sum_bit % 10 == 0 and sum_bit >= 0)\r\n dp[i + 1][a][b][new_carry] = min(dp[i + 1][a][b][new_carry], dp[i][a][b][carry] + a + b);\r\n }\r\n\r\n cout << dp[n][0][0][0] << '\\n';\r\n} \r\n \r\nsigned main(){\r\n ios::sync_with_stdio(0);\r\n cin.tie(0);\r\n\r\n // prep();\r\n int test = 1;\r\n // cin >> test;\r\n\r\n for(int i = 0; i < test; i++)\r\n solve();\r\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "922b0ff39c3cf7cf629a946961a958c2", "src_uid": "1961e7c9120ff652b15cad5dd5ca0907", "difficulty": 2900.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\n\nint A[1000001];\nint N;\n\nbool brute(int i, int j, bool go) {\n\tif(i >= j) return true;\n\tif((j - i)%2) return false;\n\tint a = A[i];\n\tif(a < 0) return false;\n\tfor(int k = i + 1; k < j; k++) {\n\t\tif(A[k] == a || A[k] == -a) {\n\t\t\tif(brute(i + 1, k, false) && brute(k + 1, j, false)) {\n\t\t\t\tif(go) {\n\t\t\t\t\tA[k] = -a;\n\t\t\t\t\tbrute(i + 1, k, true);\n\t\t\t\t\tbrute(i + 1, j, true);\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}\n\nint main() {\n\tios_base::sync_with_stdio(false);\n\tcin >> N;\n\tfor(int i=0;i> A[i];\n\tint q; cin >> q;\n\twhile(q--) { int k; cin >> k; A[k] = -A[k]; }\n\t\n\tif(brute(0, N, true)) {\n\t\tfor(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define MS0(I) memset(I, 0, sizeof(I));\n#define MS1(I) memset(I, -1, sizeof(I));\n#define rep(i, n) for(int i = 0; i < (n); ++i)\n#define rep1(i, s, n) for(int i = (s); i < (n); ++i)\n#define pb push_back \n#define ALL(I) (I).begin(), (I).end()\n#define MAX 1000005\n#define F first\n#define S second\ntypedef const void CV;\ntypedef long long LL;\ntypedef unsigned long long ULL;\nint store[MAX];\nvectortrace;\nint main(void){\n int n; scanf(\"%d\", &n);\n rep1(i, 1, n+1) scanf(\"%d\", store + i);\n int t; scanf(\"%d\", &t);\n rep(i, t){\n int v; scanf(\"%d\", &v);\n store[v] = -store[v];\n }\n for(int i = n; i >= 1; i--){\n if(trace.empty()){\n if(store[i] > 0){\n store[i] = -store[i];\n trace.pb(store[i]);\n }\n else trace.pb(store[i]);\n }\n else{\n if(store[i] > 0){\n if(store[i] == -trace.top()) trace.pop();\n else{\n store[i] = -store[i];\n trace.pb(store[i]);\n }\n }\n else{\n trace.pb(store[i]);\n }\n }\n }\n if(trace.empty()){\n puts(\"YES\");\n rep1(i, 1, n+1) printf(\"%d \", store[i]);\n }\n else puts(\"NO\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c2426183752f75082f81b183f8033bb5", "src_uid": "be82b8f209217875221ebe5de8675971", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#define MAXN 1000005\n\nusing namespace std;\n\nint n, a[MAXN], next[MAXN], prev[MAXN];\n\nmain()\n{\n scanf(\"%d\", &n);\n for (int i = 1; i <= n; i++) scanf(\"%d\", a + i);\n int m, x;\n scanf(\"%d\", &m);\n for (int i = 0; i < m; i++)\n {\n scanf(\"%d\", &x); \n a[x] = - a[x];\n }\n \n stack s, t;\n for (int i = 1; i <= n; i++) \n if (a[i] < 0)\n {\n while (!s.empty())\n {\n if (a[s.top()] + a[i] == 0 && t.empty()) break;\n if (!t.empty() && a[s.top()] == a[t.top()])\n {\n a[t.top()] = - a[t.top()];\n s.pop();\n t.pop();\n }\n else \n {\n t.push(s.top());\n s.pop();\n }\n }\n if (!t.empty() || s.empty()) \n {\n printf(\"NO\");\n return 0;\n }\n \n \n s.pop();\n \n }\n else s.push(i);\n \n while (!s.empty() )\n if (!t.empty() && a[s.top()] == a[t.top()])\n {\n a[t.top()] = - a[t.top()];\n s.pop();\n t.pop();\n }\n else \n {\n t.push(s.top());\n s.pop();\n } \n \n if (!t.empty())\n {\n printf(\"NO\");\n return 0;\n }\n \n printf(\"YES\\n\");\n for (int i = 1; i <= n; i++) printf(\"%d \", a[i]);\n system(\"pause\");\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "bb8c76b95c9cfd2e0b7b133a89d95eff", "src_uid": "be82b8f209217875221ebe5de8675971", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nlong long n,m,i,j,k,T,q,tot,top,t,x,y,tmp;\nlong long a[1000005],op[1000005],cnt[1000005],used[1000005];\nstruct node{\n long long dat,num;\n};\nnode b[1000005],s[1000005];\nbool flag;\n\nbool cmp(node x,node y){\n return x.dat0){ top++; s[top].dat=a[i]; s[top].num=i; }\n else \n { t++;\n x=abs(a[i]); flag=false;\n while(top>0)\n { \n if(s[top].dat==x)\n { flag=true; top--; break; }\n tmp=op[s[top].num]; y=s[top].num;\n if(used[tmp]!=t){ used[tmp]=t; cnt[tmp]=0; }\n if((cnt[tmp]&1)==0)a[y]=-a[y];\n cnt[tmp]++;\n top--;\n }\n if(!flag){ printf(\"NO\\n\"); return 0; }\n }\n }\n t++;\n while(top>0)\n { \n tmp=op[s[top].num]; y=s[top].num;\n if(used[tmp]!=t){ used[tmp]=t; cnt[tmp]=0; }\n if((cnt[tmp]&1)==0)a[y]=-a[y];\n cnt[tmp]++;\n top--;\n }\n \n//\n top=0;\n for(i=1;i<=n;i++)\n { \n if(a[i]>0){ top++; s[top].dat=a[i]; s[top].num=i; }\n else\n { x=abs(a[i]);\n if(s[top].dat!=x){ printf(\"NO\\n\"); return 0; }\n top--;\n }\n }\n \n printf(\"YES\\n\");\n for(i=1;i<=n;i++)printf(\"%I64d \",a[i]);\n printf(\"\\n\");\n \n//\n //system(\"pause\");\n return 0;\n}\n \n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "162821eca00ead645d5b415ce072ea3a", "src_uid": "be82b8f209217875221ebe5de8675971", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#define Order(p) (p.first)\n#define Pos(p) (p.second.first)\n#define Value(p) (p.second.second)\n#define mp make_pair\nusing namespace std;\n\ntypedef pair > pii;\nconst int MAX = 1000000 + 2;\nbool vis[MAX];\nint ans[MAX];\nint top = 0;\n\nclass Treap\n{\n\tprivate:\n\tstruct node {\n\t\tpii val;\n\t\tint key;\n\t\tint size;\n\t\tnode *child[2];\n\t\t\n\t\tint rnd() {\n\t\t\tstatic int KEY = 12345678;\n\t\t\treturn KEY += KEY << 2 | 1;\n\t\t}\n\t\t\n\t\tnode(pii _val, node *c) {\n\t\t\tval = _val;\n\t\t\tkey = rnd();\n\t\t\tchild[0] = child[1] = c;\n\t\t\tsize = 1;\n\t\t}\n\t\t\n\t\tvoid rz() {\n\t\t\tsize = child[0]->size + child[1]->size + 1;\n\t\t}\n\t};\n\t\n\tnode *root, *Null;\n\tvoid rotate(node *&t, bool d);\n\tvoid _insert(node *&t, pii x);\n\tvoid _del(node *&t, pii x);\n\tpii _kth(node *&t, int x);\n\t\n\tpublic:\n\tTreap();\n\tvoid insert(pii x);\n\tvoid del(pii x);\n\tpii kth(int x);\n\tint size();\n\tpii Min();\n} T;\n\nvoid Treap::rotate(node *&t, bool d)\n{\n\tnode *p = t->child[d];\n\tt->child[d] = p->child[!d];\n\tp->child[!d] = t;\n\tt->rz();\n\tp->rz();\n\tt = p;\n}\n\nvoid Treap::_insert(node *&t, pii x)\n{\n\tif (t == Null) {\n\t\tt = new node(x, Null);\n\t}\n\telse {\n\t\tbool d = x > t->val;\n\t\t_insert(t->child[d], x);\n\t\tif (t->child[d]->key < t->key) {\n\t\t\trotate(t, d);\n\t\t}\n\t\telse {\n\t\t\tt->rz();\n\t\t}\n\t}\n}\n\nvoid Treap::_del(node *&t, pii x)\n{\n\tif (t != Null) {\n\t\tif (t->val == x) {\n\t\t\tbool d = t->child[0]->key > t->child[1]->key;\n\t\t\tif (t->child[d] == Null) {\n\t\t\t\tdelete t;\n\t\t\t\tt = Null;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\trotate(t, d);\n\t\t\t_del(t->child[!d], x);\n\t\t}\n\t\telse {\n\t\t\tbool d = x > t->val;\n\t\t\t_del(t->child[d], x);\n\t\t}\n\t\tt->rz();\n\t}\n}\n\npii Treap::_kth(node *&t, int x)\n{\n\tint r = t->child[0]->size;\n\tif (x == r) {\n\t\treturn t->val;\n\t}\n\telse if (x < r) {\n\t\treturn _kth(t->child[0], x);\n\t}\n\telse {\n\t\treturn _kth(t->child[1], x - r - 1);\n\t}\n}\n\nTreap::Treap()\n{\n\tNull = new node(pii(0, mp(0, 0)), 0);\n\tNull->size = 0;\n\tNull->key = INT_MAX;\n\tNull->child[0] = Null->child[1] = Null;\n\troot = Null;\n}\n\nvoid Treap::insert(pii x)\n{\n\t_insert(root, x);\n}\n\nvoid Treap::del(pii x)\n{\n\t_del(root, x);\n}\n\npii Treap::kth(int x)\n{\n\treturn _kth(root, x);\n}\n\nint Treap::size()\n{\n\treturn root->size;\n}\n\npii Treap::Min()\n{\n\tnode *p = root;\n\twhile (p->child[0] != Null) {\n\t\tp = p->child[0];\n\t}\n\treturn p->val;\n}\n\nvoid run()\n{\n\tmemset(vis, 0, sizeof(vis));\n\twhile (T.size()) {\n\t\tpii k = T.Min();\n\t\tans[Pos(k)] = Value(k);\n\t\tif (~Value(k)) {\n\t\t\tvis[Value(k)] = true;\n\t\t}\n\t\tT.del(k);\n\t}\n}\n\nvoid print(int i)\n{\n\tstatic int p = 1;\n\tif (~ans[i]) {\n\t\tprintf(\"%d\", ans[i]);\n\t}\n\telse {\n\t\twhile (vis[p]) {\n\t\t\tp++;\n\t\t}\n\t\tprintf(\"%d\", p++);\n\t}\n}\n\nint main(void)\n{\n\tint n, m, i, x, y;\n\tcin >> n >> m;\n\tfor (i = 1; i <= n; i++) {\n\t\tT.insert(pii(i, mp(i, -1)));\n\t}\n\t\n\twhile (m--) {\n\t\tscanf(\"%d%d\", &x, &y);\n\t\tpii k = T.kth(y - 1);\n\t\tif (Value(k) == -1) {\n\t\t\tif (vis[x]) {\t//\ufffd\ufffd\ufffd\u06b6\ufffd\ufffd\u03b3\ufffd\ufffd\ufffd\u0133\ufffd\ufffd\u05b5\u02b1\ufffd\ufffd\ufffd\ufffd\u05b5\ufffd\ufffd\u04e6\ufffd\ufffd\u052d\u02bc\u03bb\ufffd\ufffd\ufffd\u047e\ufffd\u0237\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u04b2\ufffd\ufffd\ufffd\ufffd\ufffd\u03bb\ufffd\u00e3\ufffd\u00ec\ufffd\ufffd \n\t\t\t\tputs(\"-1\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tvis[x] = true;\n\t\t\t}\n\t\t}\n\t\telse if (Value(k) != x) {\t//\ufffd\ufffd\u03bb\ufffd\ufffd\ufffd\ufffd\u0237\ufffd\ufffd\u05b5\ufffd\ufffd\ufffd\ufffd\u03aax \n\t\t\tputs(\"-1\");\n\t\t\treturn 0;\n\t\t}\n\t\t//top--\ufffd\ufffd\u05a4\ufffd\u00f5\ufffd\ufffd\ufffd\u03aa\ufffd\ufffd\u04bb\ufffd\ufffd\u03bb\ufffd\u00f2\ufffd\ufffd\ufffd\t\t\n\t\t//\ufffd\ufffd\u0237\ufffd\ufffdPos(k)\u03bb\ufffd\ufffd\u05b5\u03aax \n\t\tT.insert(pii(top--, mp(Pos(k), x)));\t\t\t\t\t\t\t\t\t\t\t\t\n\t\tT.del(k);\t//\u027e\ufffd\ufffd\u052d\ufffd\ufffd\ufffd \t\t\n\t}\n\t\n\trun();\n\tfor (i = 1; i < n; i++) {\n\t\tprint(i);\n\t\tputchar(' ');\n\t}\n\tprint(n);\n\tputchar('\\n');\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "776757fc4744417ddc1941ae86eac931", "src_uid": "a2616b1681f30ce4b2a5fdc81cf52b50", "difficulty": 2200.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define REP(i, from, to) for (int i = (from); i < (to); ++i)\n#define FOR(i, n) REP(i, 0, (n))\n#define ALL(x) x.begin(), x.end()\n#define SIZE(x) (int)x.size()\n#define PB push_back\n#define MP make_pair\n\ntypedef long long i64;\ntypedef vector VI;\ntypedef vector VVI;\ntypedef vector VS;\ntypedef vector VVS;\ntypedef pair PII;\n\nvector t;\nint n;\n\nvoid init (int nn)\n{\n n = nn;\n t.assign (n, 0);\n}\n\nint sum (int r)\n{\n int result = 0;\n for (; r >= 0; r = (r & (r+1)) - 1)\n result += t[r];\n return result;\n}\n\nvoid inc (int i, int delta)\n{\n for (; i < n; i = (i | (i+1)))\n t[i] += delta;\n}\n\nint sum (int l, int r)\n{\n return sum (r) - sum (l-1);\n}\n\nvoid init (vector a)\n{\n init ((int) a.size());\n for (unsigned i = 0; i < a.size(); i++)\n inc (i, a[i]);\n}\n\nint findIndex(int index) {\n int l = 0, r = n;\n while (l < r) {\n int const m = (l + r) >> 1;\n int const count = sum(m);\n if (count < index)\n l = m + 1;\n else\n r = m;\n }\n\n return l;\n}\n\nvoid test(int m, VI a) {\n int const n = SIZE(a);\n cout << n << endl;\n while (m--) {\n int const y = rand() % n;\n int const x = a[y];\n\n cout << x << \" \" << y + 1 << endl;\n a.erase(a.begin() + y);\n a.insert(a.begin(), x);\n }\n\n cout << \"Will be:\\n\";\n FOR (i, SIZE(a)) cout << a[i] << \" \";\n cout << endl;\n}\n\n//#define DEBUG\n\nint main() {\n freopen(\"input.txt\", \"r\", stdin);\n\n {\n VI a = {1,2,3};\n //test(5, a);\n }\n\n ios_base::sync_with_stdio(false);\n\n int size, m;\n cin >> size >> m;\n\n int const origSize = size;\n n = 2 * (m + n);\n init(n);\n FOR (i, size) inc(i, 1);\n\n VI index(size);\n VI state(2 * size + 100);\n\n VI position(origSize + 10, -1);\n\n FOR (i, m) {\n int x, y;\n cin >> x >> y;\n\n int const needIndex = origSize - y + 1;\n int const whereIndex = findIndex(needIndex);\n\n#ifdef DEBUG\n {\n cout << \"x = \" << x << \", y = \" << y << endl;\n cout << \"needIndex = \" << needIndex << endl;\n cout << \"whereIndex = \" << whereIndex << endl;\n cout << \"position[\" << x << \"] = \" << position[x] << endl;\n cout << \"prev position index = \" << sum(position[x]) << endl;\n }\n#endif\n\n int const whatThere = state[whereIndex];\n if (whatThere && whatThere != x) {\n //cout << \"another number is at the \" << whereIndex << \" position.\\n\";\n cout << \"-1\\n\";\n return 0;\n }\n\n if (position[x] != -1 && sum(position[x]) != needIndex) {\n cout << \"-1\\n\";\n return 0;\n }\n\n inc(whereIndex, -1);\n state[size] = x;\n inc(size, 1);\n position[x] = size;\n\n#ifdef DEBUG\n cout << \"size = \" << size << endl;\n\n cout << \"State: \";\n FOR (i, size + 1) {\n cout << sum(i, i) << \" \";\n }\n cout << endl;\n\n cout << \"sum(position[x]) = \" << sum(position[x]) << endl;\n assert(sum(position[x]) == origSize);\n cout << \"new position[\" << x << \"] = \" << position[x] << endl;\n#endif\n ++size;\n\n if (whereIndex < origSize) {\n index[origSize - whereIndex - 1] = x;\n#ifdef DEBUG\n cout << \"write to \" << origSize - whereIndex - 1 << \", x = \" << x << endl;\n#endif\n }\n }\n\n set notUsed;\n FOR (i, origSize) {\n ostringstream oss;\n oss << i + 1;\n notUsed.insert(oss.str());\n }\n FOR (i, origSize) if (index[i]) {\n ostringstream oss;\n oss << index[i];\n notUsed.erase(oss.str());\n }\n\n FOR (i, origSize) {\n if (i) cout << \" \";\n if (!index[i]) {\n index[i] = atoi((*notUsed.begin()).c_str());\n notUsed.erase(notUsed.begin());\n }\n cout << index[i];\n }\n\n cout << endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6239e94ec5316bb77b6ca919b1ae9493", "src_uid": "a2616b1681f30ce4b2a5fdc81cf52b50", "difficulty": 2200.0} {"lang": "GNU C++11", "source_code": "#pragma GCC optimize(\"no-stack-protector,Ofast\")\n#include\nusing namespace std;\n\nunsigned int seed=880301;\nint rnd(){\n return seed=(seed*880301)^7122;\n}\n\nstruct node{\n node *l,*r;\n int sz,val,pri;\n int lz(){return l?l->sz:0;}\n int rz(){return r?r->sz:0;}\n void psz(){sz=lz()+rz()+1;}\n node(int v=-1):l(0),r(0),sz(1),val(v),pri(rnd()){}\n} *root,pool[1000006];\n\npair op[1000006];\nbitset<1000006> it;\nint npt=1;\n\nnode *merge(node *a,node *b){\n if(!(a&&b))return a?:b;\n if(a->pri>b->pri){\n a->r=merge(a->r,b);\n a->psz();\n return a;\n }\n else{\n b->l=merge(a,b->l);\n b->psz();\n return b;\n }\n}\nvoid split(node *now,int sz,node *&a,node *&b){\n if(!now){a=b=0; return;}\n if(now->lz()>=sz){\n b=now;\n split(now->l,sz,a,b->l);\n b->psz();\n }\n else{\n a=now;\n split(now->r,sz-1-now->lz(),a->r,b);\n a->psz();\n }\n}\nvoid gl(node *now){\n if(!now)return;\n gl(now->l);\n if(now->val!=-1)printf(\"%d \",now->val);\n else{\n while(it[npt])++npt;\n printf(\"%d \",npt);\n it[npt]=1;\n }\n gl(now->r);\n}\n\nint inp(){\n char c; int x=0;\n while((c=getchar()) && (c<'0' || c>'9'));\n while((x=c-'0',c=getchar()) && c>='0' && c<='9');\n return x;\n}\n\nint main(){\n // ios_base::sync_with_stdio(0); cin.tie(0);\n int n=inp(),m=inp();\n for(int i=1;i<=m;++i){\n op[i].first=inp();\n op[i].second=inp();\n // it[op[i].first]=1;\n }\n for(int i=1;i<=n;++i)root=merge(root,&pool[i]);\n\n node *a,*b,*c,*d;\n for(int i=m;i>=1;--i){\n split(root,1,a,b);\n if(a->val==-1){\n if(it[op[i].first])exit((cout<<-1<val=op[i].first;\n it[op[i].first]=1;\n }\n else if(a->val!=op[i].first)exit((cout<<-1<\nusing namespace std;\n\nint n, m, x, y;\n\nvoid init(int *itChecked, int *itDistinc, int *posIT, int lef, int rig, int k){\n itChecked[k] = 0;\n itDistinc[k] = 0;\n if (lef == rig){\n posIT[lef] = k;\n return;\n }\n init(itChecked, itDistinc, posIT, lef, (lef + rig) >> 1, k << 1);\n init(itChecked, itDistinc, posIT, ((lef + rig) >> 1) + 1, rig, (k << 1) + 1);\n}\n\nvoid update(int *it, int posIT, int val){\n while (posIT){\n it[posIT] += val;\n posIT >>= 1;\n }\n}\n\nint find(int *itChecked, int lef, int rig, int k, int vt){\n if (lef == rig)\n return lef;\n\n int mid = (rig + lef) >> 1;\n if (mid + itChecked[(k << 1) + 1] < vt)\n return find(itChecked, mid + 1, rig, (k << 1) + 1, vt);\n else\n return find(itChecked, lef, mid, k << 1, vt - itChecked[(k << 1) + 1]);\n}\n\nint get(int *it, int lef, int rig, int u, int v, int k){\n if (u > v)\n return 0;\n if (lef == u && rig == v)\n return it[k];\n\n int mid = (lef + rig) >> 1;\n if (v <= mid)\n return get(it, lef, mid, u, v, k << 1);\n else\n if (u > mid)\n return get(it, mid + 1, rig, u, v, (k << 1) + 1);\n else\n return get(it, lef, mid, u, mid, k << 1) + get(it, mid + 1, rig, mid + 1, v, (k << 1) + 1);\n}\n\nint main(){\n ios_base::sync_with_stdio(false);\n cin >> n >> m;\n int *itChecked = new int[5 * n];\n int *itDistinc = new int[5 * n];\n int *posIT = new int[n + 1];\n int *posElement = new int[n + 1];\n bool *exist = new bool[n + 1];\n int *res = new int[n + 1];\n for (int i = 1; i <= n; i++){\n res[i] = 0;\n exist[i] = false;\n posElement[i] = 0;\n }\n\n init(itChecked, itDistinc, posIT, 1, n, 1);\n for (int i = 1; i <= m; i++){\n cin >> x >> y;\n exist[x] = true;\n update(itDistinc, posIT[i], 1);\n if (posElement[x]){\n update(itDistinc, posIT[posElement[x]], -1);\n if (get(itDistinc, 1, n, posElement[x] + 1, i - 1, 1) == y - 1){\n posElement[x] = i;\n continue;\n }\n else{\n cout << -1;\n return 0;\n }\n }\n\n int vt = find(itChecked, 1, n, 1, y);\n if (vt + get(itChecked, 1, n, vt + 1, n, 1) != y || res[vt]){\n cout << -1;\n return 0;\n }\n\n res[vt] = x;\n update(itChecked, posIT[vt], 1);\n posElement[x] = i;\n }\n int j = 1;\n for (int i = 1; i <= n; i++){\n if (res[i] == 0){\n while (exist[j++]);\n res[i] = j - 1;\n }\n cout << res[i] << \" \";\n }\n\n delete[] itChecked;\n delete[] itDistinc;\n delete[] posIT;\n delete[] posElement;\n delete[] exist;\n delete[] res;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e10a52adcf18a9908cf58ed760f83411", "src_uid": "a2616b1681f30ce4b2a5fdc81cf52b50", "difficulty": 2200.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define pb push_back\nint n,k,ans=-1;\nint b[200007];\nvector rose[4];\nstring s;\nint main(){\n\tios_base::sync_with_stdio(0);\n\tcin>>n>>k;\n\tfor(int i=1;i<=n;i++){\n\t\tcin>>b[i];\n\t}\n\tcin>>s;\n\tif(k==1){\n\t\tcout<<-1;\n\t\treturn 0;\n\t}\n\tfor(int i=1;i<=n;i++){\n\t\tif(s[i-1]=='W') rose[1].pb(b[i]);\n\t\telse if(s[i-1]=='O') rose[2].pb(b[i]);\n\t\telse rose[3].pb(b[i]);\n\t}\n\tfor(int i=1;i<=3;i++) sort(rose[i].begin(),rose[i].end(),greater());\n\tif((int)rose[1].size()!=0 && (int)rose[2].size()!=0 && (int)rose[1].size()+(int)rose[2].size()>=k){\n\t\tint cur=0;\n\t\tcur+=rose[1][0];\n\t\tcur+=rose[2][0];\n\t\tvector save;\n\t\tsave.clear();\n\t\tfor(int i=1;i<(int)rose[1].size();i++) save.pb(rose[1][i]);\n\t\tfor(int i=1;i<(int)rose[2].size();i++) save.pb(rose[2][i]);\n\t\tsort(save.begin(),save.end(),greater());\n\t\tfor(int i=0;i=k){\n\t\tint cur=0;\n\t\tcur+=rose[2][0];\n\t\tcur+=rose[3][0];\n\t\tvector save;\n\t\tsave.clear();\n\t\tfor(int i=1;i<(int)rose[2].size();i++) save.pb(rose[2][i]);\n\t\tfor(int i=1;i<(int)rose[3].size();i++) save.pb(rose[3][i]);\n\t\tsort(save.begin(),save.end(),greater());\n\t\tfor(int i=0;i\n#include\nusing namespace std;\nint n,k;\nvectorr,o,w;\nint d[200001];\nint solve(vectora,vectorb){\n\tif(a.empty() || a.size()+b.size()maxa){\n\t\t\tmaxa=a[i];\n\t\t\tposa=i;\n\t\t}\n\t}\n\tfor(int i=0; imaxb){\n\t\t\tmaxb=b[i];\n\t\t\tposb=i;\n\t\t}\n\t}\n\tint ans=maxa+maxb;\n\tpriority_queuepq;\n\tfor(int i=0; i> n >> k;\n\tfor(int i=1; i<=n ;i++){\n\t\tcin >> d[i];\n\t}\n\tchar c;\n\tfor(int i=1; i<=n ;i++){\n\t\tcin >> c;\n\t\tif(c=='R') r.push_back(d[i]);\n\t\telse if(c=='O') o.push_back(d[i]);\n\t\telse w.push_back(d[i]);\n\t}\n\tif(k==1 || o.empty()){\n\t\tcout << \"-1\\n\";\n\t\treturn 0;\n\t}\n\tint ans=max(solve(r,o),solve(w,o));\n\tif(ans==0) cout << \"-1\\n\";\n\telse cout << ans << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "673debe1fccc13f0d40a98f89fe5beb9", "src_uid": "104cf5253e027929f257364b3874c38b", "difficulty": 2200.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;++i)\n#define For(i,a,b) for(int i=(a),i##_end=(b);i=i##_st;--i)\n#define foe(i,a) for(__typeof(a.begin()) i=a.begin();i!=a.end();++i)\n#define fi first\n#define se second\n#define pb push_back\n#define mp make_pair\n#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)\n#define debug(...) fprintf(stderr, __VA_ARGS__)\ntypedef double db;\ntypedef long long ll;\ntypedef vector Vi;\ntypedef pair pii;\nconst int inf=~0u>>1,mo=1e9+7;\ninline int rd(){\n int x,c,f=1;while(!isdigit(c=getchar()))f=c!='-';x=c-'0';\n while(isdigit(c=getchar()))x=x*10+c-'0';return f?x:-x;\n}\nconst int N=200011;\nll a[N],b[N],c[N];\nint t1,t2,t3;\nchar s[N];int f[N];\nint cmp(ll i,ll j){return i>j;}\nint main(){\n\tint n=rd(),k=rd();\n\trep(i,1,n)f[i]=rd();\n\tscanf(\"%s\",s+1);\n\trep(i,1,n)if(s[i]=='O')a[++t1]=f[i];else if(s[i]=='R')b[++t2]=f[i];\n\telse c[++t3]=f[i];\n\tsort(a+1,a+t1+1,cmp),sort(b+1,b+t2+1,cmp),sort(c+1,c+t3+1,cmp);\n\tFor(i,2,N)a[i]+=a[i-1];For(i,2,N)b[i]+=b[i-1];For(i,2,N)c[i]+=c[i-1];\n\tif(!t1||!(t2+t3)||K<2){puts(\"-1\");return 0;}\n\tll ans=0;\n\tFor(i,1,k){\n\t\tans=max(ans,a[i]+max(b[k-i],c[k-i]));\n\t}\n\tcout<\nusing namespace std;\n#define pb push_back\nint n,k,ans=-1;\nint b[200007];\nvector rose[4];\nstring s;\nint main(){\n\tios_base::sync_with_stdio(0);\n\tcin>>n>>k;\n\tfor(int i=1;i<=n;i++){\n\t\tcin>>b[i];\n\t}\n\tcin>>s;\n\tif(k==1){\n\t\tcout<<-1;\n\t\treturn 0;\n\t}\n\tfor(int i=1;i<=n;i++){\n\t\tif(s[i-1]=='W') rose[1].pb(b[i]);\n\t\telse if(s[i-1]=='O') rose[2].pb(b[i]);\n\t\telse rose[3].pb(b[i]);\n\t}\n\tfor(int i=1;i<=3;i++) sort(rose[i].begin(),rose[i].end(),greater());\n\tif((int)rose[1].size()!=0 && (int)rose[2].size()!=0 && (int)rose[1].size()+(int)rose[2].size()>=k){\n\t\tint cur=0;\n\t\tcur+=rose[1][0];\n\t\tcur+=rose[2][0];\n\t\tvector save;\n\t\tsave.clear();\n\t\tfor(int i=1;i<(int)rose[1].size();i++) save.pb(rose[1][i]);\n\t\tfor(int i=1;i<(int)rose[2].size();i++) save.pb(rose[2][i]);\n\t\tsort(save.begin(),save.end(),greater());\n\t\tfor(int i=0;i=k){\n\t\tint cur=0;\n\t\tcur+=rose[2][0];\n\t\tcur+=rose[3][0];\n\t\tsave.clear();\n\t\tvector save;\n\t\tfor(int i=1;i<(int)rose[2].size();i++) save.pb(rose[2][i]);\n\t\tfor(int i=1;i<(int)rose[3].size();i++) save.pb(rose[3][i]);\n\t\tsort(save.begin(),save.end(),greater());\n\t\tfor(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define FAST_IO ios::sync_with_stdio(false)\n#define sci(d) scanf(\"%d\", &d)\n#define scs(s) scanf(\"%s\", &s)\n\n#define SINF 20000000\n#define INF 2000000000\n#define LLINF 900000000000000000LL\n#define X first\n#define Y second\n#define MAX 1001\n#define MOD 1000000007LL\n#define endl \"\\n\"\n#define ALL(a) (a).begin(), (a).end()\n#define pr(n) operator[](n);\n\ntypedef long long ll;\ntypedef pair pi;\n\nint Q, N, M, K, L;\nll FAN[100001];\nint p[100001];\nll v[100001];\n\nstruct comp {\n\tbool operator() (const int& a, const int& b) const {\n\t\tif (v[a] != v[b]) return v[a] < v[b];\n\t\treturn a < b;\n\t}\n};\n\nset children[100001];\nint deg[100001];\nmultiset mulset;\n\nll value_for_self(int a) {\n\treturn FAN[a] - (1 + deg[a]) * value_for_other(a);\n}\nll value_for_other(int a) {\n\treturn FAN[a] / (2 + deg[a]);\n}\n\nint main() {\n\tFAST_IO;\n\tcin >> N >> M;\n\tfor (int i = 0; i < N; i++) cin >> FAN[i];\n\tfor (int i = 0; i < N; i++) {\n\t\tcin >> p[i]; p[i]--;\n\t\tchildren[p[i]].insert(i);\n\t\tdeg[p[i]]++;\n\t}\n\tfor (int i = 0; i < N; i++) {\n\t\tv[i] += value_for_self(i);\n\t\tfor (int child : children[i])\n\t\t\tv[i] += value_for_other(child);\n\t}\n\tfor (int i = 0; i < N; i++) {\n\t\tchildren[p[i]].erase(i);\n\t\tchildren[p[i]].insert(i);\n\t}\n\tfor (int n = 0; n < N; n++) {\n\t\tll pv = value_for_other(n);\n\t\tif (!deg[n]) continue;\n\t\tmulset.insert(v[*children[n].begin()] + pv);\n\t\tmulset.insert(v[*children[n].rbegin()] + pv);\n\t}\n\tfor (int q = 0; q < M; q++) {\n\t\tint a, b, c;\n\t\tcin >> a;\n\t\tif (a == 1) {\n\t\t\tcin >> b >> c;\n\t\t\tb--; c--;\n\n\t\t\tset go = { b, c, p[b], p[c], p[p[b]] };\n\t\t\tset go2 = go;\n\t\t\tfor (int n : go) go2.insert(p[n]);\n\n\t\t\tfor (int n : go2) {\n\t\t\t\tif (!deg[n]) continue;\n\t\t\t\tll pv = value_for_other(n);\n\t\t\t\tmulset.erase(v[*children[n].begin()] + pv);\n\t\t\t\tmulset.erase(v[*children[n].rbegin()] + pv);\n\t\t\t}\n\n\t\t\tfor (int n : go)\n\t\t\t\tchildren[p[n]].erase(n);\n\n\t\t\tfor (int n : go) {\n\t\t\t\tv[n] -= value_for_self(n);\n\t\t\t\tfor (int m : go)\n\t\t\t\t\tif (p[m] == n)\n\t\t\t\t\t\tv[n] -= value_for_other(m);\n\t\t\t}\n\t\t\tdeg[p[b]]--;\n\t\t\tp[b] = c;\n\t\t\tdeg[p[b]]++;\n\t\t\tfor (int n : go) {\n\t\t\t\tv[n] += value_for_self(n);\n\t\t\t\tfor (int m : go)\n\t\t\t\t\tif (p[m] == n)\n\t\t\t\t\t\tv[n] += value_for_other(m);\n\t\t\t}\n\n\t\t\tfor (int n : go)\n\t\t\t\tchildren[p[n]].insert(n);\n\n\t\t\tfor (int n : go2) {\n\t\t\t\tif (!deg[n]) continue;\n\t\t\t\tll pv = value_for_other(n);\n\t\t\t\tmulset.insert(v[*children[n].begin()] + pv);\n\t\t\t\tmulset.insert(v[*children[n].rbegin()] + pv);\n\t\t\t}\n\t\t}\n\t\tif (a == 2) {\n\t\t\tcin >> b;\n\t\t\tb--;\n\t\t\tcout << v[b] + value_for_other(p[b]) << endl;\n\t\t}\n\t\tif (a == 3) {\n\t\t\tcout << *mulset.begin() << \" \" << *mulset.rbegin() << endl;\n\t\t}\n\t}\n\tcin >> N;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2de52d88de35b808a970f0dabc3895df", "src_uid": "6a17d93dad158f70a36905206aa0ba3b", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define FAST_IO ios::sync_with_stdio(false)\n#define sci(d) scanf(\"%d\", &d)\n#define scs(s) scanf(\"%s\", &s)\n\n#define SINF 20000000\n#define INF 2000000000\n#define LLINF 900000000000000000LL\n#define X first\n#define Y second\n#define MAX 1001\n#define MOD 1000000007LL\n#define endl \"\\n\"\n#define ALL(a) (a).begin(), (a).end()\n#define pr(n) operator[](n);\n\ntypedef long long ll;\ntypedef pair pi;\n\nint Q, N, M, K, L;\nll FAN[100001];\nint p[100001];\nll v[100001];\n\nstruct comp {\n\tbool operator() (const int& a, const int& b) const {\n\t\tif (v[a] != v[b]) return v[a] < v[b];\n\t\treturn a < b;\n\t}\n};\n\nset children[100001];\nint deg[100001];\nmultiset mulset;\n\nll value_for_self(int a) {\n\treturn FAN[a] - (1 + deg[a]) * value_for_other(a);\n}\nll value_for_other(int a) {\n\treturn FAN[a] / (2 + deg[a]);\n}\n\nint main() {\n\tFAST_IO;\n\tcin >> N >> M;\n\tfor (int i = 0; i < N; i++) cin >> FAN[i];\n\tfor (int i = 0; i < N; i++) {\n\t\tcin >> p[i]; p[i]--;\n\t\tchildren[p[i]].insert(i);\n\t\tdeg[p[i]]++;\n\t}\n\tfor (int i = 0; i < N; i++) {\n\t\tv[i] += value_for_self(i);\n\t\tfor (int child : children[i])\n\t\t\tv[i] += value_for_other(child);\n\t}\n\tfor (int i = 0; i < N; i++) {\n\t\tchildren[p[i]].erase(i);\n\t\tchildren[p[i]].insert(i);\n\t}\n\tfor (int n = 0; n < N; n++) {\n\t\tint pv = value_for_other(n);\n\t\tif (!deg[n]) continue;\n\t\tmulset.insert(v[*children[n].begin()] + pv);\n\t\tmulset.insert(v[*children[n].rbegin()] + pv);\n\t}\n\tfor (int q = 0; q < M; q++) {\n\t\tint a, b, c;\n\t\tcin >> a;\n\t\tif (a == 1) {\n\t\t\tcin >> b >> c;\n\t\t\tb--; c--;\n\n\t\t\tset go = { b, c, p[b], p[c], p[p[b]] };\n\t\t\tset go2 = go;\n\t\t\tfor (int n : go) go2.insert(p[n]);\n\n\t\t\tfor (int n : go2) {\n\t\t\t\tif (!deg[n]) continue;\n\t\t\t\tll pv = value_for_other(n);\n\t\t\t\tmulset.erase(v[*children[n].begin()] + pv);\n\t\t\t\tmulset.erase(v[*children[n].rbegin()] + pv);\n\t\t\t}\n\n\t\t\tfor (int n : go)\n\t\t\t\tchildren[p[n]].erase(n);\n\n\t\t\tfor (int n : go) {\n\t\t\t\tv[n] -= value_for_self(n);\n\t\t\t\tfor (int m : go)\n\t\t\t\t\tif (p[m] == n)\n\t\t\t\t\t\tv[n] -= value_for_other(m);\n\t\t\t}\n\t\t\tdeg[p[b]]--;\n\t\t\tp[b] = c;\n\t\t\tdeg[p[b]]++;\n\t\t\tfor (int n : go) {\n\t\t\t\tv[n] += value_for_self(n);\n\t\t\t\tfor (int m : go)\n\t\t\t\t\tif (p[m] == n)\n\t\t\t\t\t\tv[n] += value_for_other(m);\n\t\t\t}\n\n\t\t\tfor (int n : go)\n\t\t\t\tchildren[p[n]].insert(n);\n\n\t\t\tfor (int n : go2) {\n\t\t\t\tif (!deg[n]) continue;\n\t\t\t\tll pv = value_for_other(n);\n\t\t\t\tmulset.insert(v[*children[n].begin()] + pv);\n\t\t\t\tmulset.insert(v[*children[n].rbegin()] + pv);\n\t\t\t}\n\t\t}\n\t\tif (a == 2) {\n\t\t\tcin >> b;\n\t\t\tb--;\n\t\t\tcout << v[b] + value_for_other(p[b]) << endl;\n\t\t}\n\t\tif (a == 3) {\n\t\t\tcout << *mulset.begin() << \" \" << *mulset.rbegin() << endl;\n\t\t}\n\t}\n\tcin >> N;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ac675d28a0106b8b1f20d659604a0cbd", "src_uid": "6a17d93dad158f70a36905206aa0ba3b", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define FAST_IO ios::sync_with_stdio(false)\n#define sci(d) scanf(\"%d\", &d)\n#define scs(s) scanf(\"%s\", &s)\n\n#define SINF 20000000\n#define INF 2000000000\n#define LLINF 900000000000000000LL\n#define X first\n#define Y second\n#define MAX 1001\n#define MOD 1000000007LL\n#define endl \"\\n\"\n#define ALL(a) (a).begin(), (a).end()\n#define pr(n) operator[](n);\n\ntypedef long long ll;\ntypedef pair pi;\n\nint Q, N, M, K, L;\nll FAN[100001];\nint p[100001];\nll v[100001];\n\nstruct comp {\n\tbool operator() (const int& a, const int& b) const {\n\t\tif (v[a] != v[b]) return v[a] < v[b];\n\t\treturn a < b;\n\t}\n};\n\nset children[100001];\nint deg[100001];\nmultiset mulset;\n\nll value_for_other(int a) {\n\treturn FAN[a] / (2 + deg[a]);\n}\nll value_for_self(int a) {\n\treturn FAN[a] - (1 + deg[a]) * value_for_other(a);\n}\n\nint main() {\n\tFAST_IO;\n\tcin >> N >> M;\n\tfor (int i = 0; i < N; i++) cin >> FAN[i];\n\tfor (int i = 0; i < N; i++) {\n\t\tcin >> p[i]; p[i]--;\n\t\tchildren[p[i]].insert(i);\n\t\tdeg[p[i]]++;\n\t}\n\tfor (int i = 0; i < N; i++) {\n\t\tv[i] += value_for_self(i);\n\t\tfor (int child : children[i])\n\t\t\tv[i] += value_for_other(child);\n\t}\n\tfor (int i = 0; i < N; i++) {\n\t\tchildren[p[i]].erase(i);\n\t\tchildren[p[i]].insert(i);\n\t}\n\tfor (int i = 0; i < N; i++) {\n\t\tif (children[i].empty()) continue;\n\t\tmulset.insert(v[*children[i].begin()] + value_for_other(i));\n\t\tmulset.insert(v[*children[i].rbegin()] + value_for_other(i));\n\t}\n\tfor (int q = 0; q < M; q++) {\n\t\tint a, b, c;\n\t\tcin >> a;\n\t\tif (a == 1) {\n\t\t\tcin >> b >> c;\n\t\t\tb--; c--;\n\n\t\t\tset go = { b, c, p[b], p[c], p[p[b]] };\n\t\t\tset go2 = go;\n\t\t\tfor (int n : go) go2.insert(p[n]);\n\n\t\t\tfor (int n : go2) {\n\t\t\t\tif (children[i].empty()) continue;\n\t\t\t\tmulset.erase(v[*children[i].begin()] + value_for_other(i));\n\t\t\t\tmulset.erase(v[*children[i].rbegin()] + value_for_other(i));\n\t\t\t}\n\n\t\t\tfor (int n : go)\n\t\t\t\tchildren[p[n]].erase(n);\n\n\t\t\tfor (int n : go) {\n\t\t\t\tv[n] -= value_for_self(n);\n\t\t\t\tfor (int m : go)\n\t\t\t\t\tif (p[m] == n)\n\t\t\t\t\t\tv[n] -= value_for_other(m);\n\t\t\t}\n\t\t\tdeg[p[b]]--;\n\t\t\tp[b] = c;\n\t\t\tdeg[p[b]]++;\n\t\t\tfor (int n : go) {\n\t\t\t\tv[n] += value_for_self(n);\n\t\t\t\tfor (int m : go)\n\t\t\t\t\tif (p[m] == n)\n\t\t\t\t\t\tv[n] += value_for_other(m);\n\t\t\t}\n\n\t\t\tfor (int n : go)\n\t\t\t\tchildren[p[n]].insert(n);\n\n\t\t\tfor (int n : go2) {\n\t\t\t\tif (!deg[n]) continue;\n\t\t\t\tll pv = value_for_other(n);\n\t\t\t\tmulset.insert(v[*children[n].begin()] + pv);\n\t\t\t\tmulset.insert(v[*children[n].rbegin()] + pv);\n\t\t\t}\n\t\t}\n\t\tif (a == 2) {\n\t\t\tcin >> b;\n\t\t\tb--;\n\t\t\tcout << v[b] + value_for_other(p[b]) << endl;\n\t\t}\n\t\tif (a == 3) {\n\t\t\tcout << *mulset.begin() << \" \" << *mulset.rbegin() << endl;\n\t\t}\n\t}\n\tcin >> N;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cced80fcecb704b2e35c93dc1630bcbd", "src_uid": "6a17d93dad158f70a36905206aa0ba3b", "difficulty": 2900.0} {"lang": "GNU C++", "source_code": "// Created by Sengxian on 5/10/16.\n// Copyright (c) 2016\u5e74 Sengxian. ALL rights reserved.\n// Codeforces 673F \u601d\u7ef4 + \u5806\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ninline int ReadInt() {\n\tstatic int n, ch;\n\tn = 0, ch = getchar();\n\twhile (!isdigit(ch)) ch = getchar();\n\twhile (isdigit(ch)) n = (n << 1) + (n << 3) + ch - '0', ch = getchar();\n\treturn n;\n}\n\ntypedef long long ll;\ninline ll ReadLL() {\n\tstatic ll n;\n\tstatic int ch;\n\tn = 0, ch = getchar();\n\twhile (!isdigit(ch)) ch = getchar();\n\twhile (isdigit(ch)) n = (n << 1) + (n << 3) + ch - '0', ch = getchar();\n\treturn n;\n}\n\nconst int maxn = 100000 + 3;\nconst ll INF = 1LL << 60;\nstruct big_set {\n\tpriority_queue q1, q2;\n\tset s;\n\tinline bool empty() {\n\t\treturn !s.size();\n\t\twhile (!q1.empty() && !q2.empty() && q1.top() == q2.top()) q1.pop(), q2.pop();\n\t\treturn q1.empty();\n\t}\n\tinline void insert(ll x) {q1.push(x); s.insert(x);}\n\tinline void erase(ll x) {\n\t\tq2.push(x);\n\t\ts.erase(x);\n\t}\n\tinline ll top() {\n\t\tassert(s.size());\n\t\treturn *s.rbegin();\n\t\twhile (!q1.empty() && !q2.empty() && q1.top() == q2.top()) q1.pop(), q2.pop();\n\t\tassert(q1.empty() == false);\n\t\tif (q1.empty()) return -INF;\n\t\treturn q1.top();\n\t}\n\tvoid print() {\n\t\tfor (set::iterator it = s.begin(); it != s.end(); ++it)\n\t\t\tcout << *it << endl;\n\t\tcout << endl;\n\t}\n}optb, bs[maxn];\nstruct small_set {\n\tpriority_queue, greater > q1, q2;\n\tset s;\n\tinline bool empty() {\n\t\treturn !s.empty();\n\t\twhile (!q1.empty() && !q2.empty() && q1.top() == q2.top()) q1.pop(), q2.pop();\n\t\treturn q1.empty();\n\t}\n\tinline void insert(ll x) {q1.push(x);s.insert(x);}\n\tinline void erase(ll x) {q2.push(x);s.erase(x);}\n\tinline ll top() {\n\t\treturn *s.begin();\n\t\twhile (!q1.empty() && !q2.empty() && q1.top() == q2.top()) q1.pop(), q2.pop();\n\t\tassert(q1.empty() == false);\n\t\tif (q1.empty()) return INF;\n\t\treturn q1.top();\n\t}\n}opts, ss[maxn];\n\nint n, q, fa[maxn], s[maxn];\nll t[maxn], val[maxn];\n\ninline ll cal(int u) {\n\treturn t[u] / (s[u] + 2);\n}\n\nbool in[maxn];\n\n//\u5c06 a \u4ece\u7236\u4eb2\u7684\u5806\u91cc\u9762\u5220\u9664\nvoid del(int a) {\n\tint b = fa[a];\n\tbs[b].erase(val[a]);\n\tss[b].erase(val[a]);\n}\n\n//\u5c06 a \u52a0\u5165\u7236\u4eb2\u7684\u5806\u91cc\u9762\nvoid add(int a) {\n\tint b = fa[a];\n\tbs[b].insert(val[a]);\n\tss[b].insert(val[a]);\n}\n\nvoid eraseOpt(int a) {\n\ta = fa[a]; \n\tll v = cal(a);\n\tif (in[a] && !bs[a].empty() && !ss[a].empty()) {\n\t\toptb.erase(bs[a].top() + v);\n\t\topts.erase(ss[a].top() + v);\n\t\tin[a] = false;\n\t}\n}\n\nvoid insertOpt(int a) {\n\ta = fa[a];\n\tll v = cal(a);\n\tif (!in[a] && !bs[a].empty() && !ss[a].empty()) {\n\t\toptb.insert(bs[a].top() + v);\n\t\topts.insert(ss[a].top() + v);\n\t\tin[a] = true;\n\t}\n}\n\n\nvoid modify(int a, int c) {\n\tint b = fa[a];\n\teraseOpt(a), eraseOpt(b), eraseOpt(c), eraseOpt(fa[b]), eraseOpt(fa[c]);\n\tdel(a), del(b), del(c), del(fa[b]), del(fa[c]);\n\t\n\n\t//\u66f4\u65b0\u7b54\u6848\n\tfa[a] = c;\n\tll va_other = cal(a);\n\t//\u5bf9 b \u7684\u4fee\u6539\n\tll vb_other = cal(b);\n\tval[b] -= va_other;\n\tval[b] -= t[b] - (s[b] + 1) * vb_other;\n\tval[fa[b]] -= vb_other;\n\ts[b]--;\n\tvb_other = t[b] / (s[b] + 2);\n\tval[b] += t[b] - (s[b] + 1) * vb_other;\n\tval[fa[b]] += vb_other;\n\t//\u5bf9 c \u7684\u4fee\u6539\n\tll vc_other = cal(c);\n\tval[c] += va_other;\n\tval[c] -= t[c] - (s[c] + 1) * vc_other;\n\tval[fa[c]] -= vc_other;\n\ts[c]++;\n\tvc_other = t[c] / (s[c] + 2);\n\tval[c] += t[c] - (s[c] + 1) * vc_other;\n\tval[fa[c]] += vc_other;\n\n\t//eraseOpt(a, vc_back), eraseOpt(b, vb_back), eraseOpt(c, vc_back), eraseOpt(fa[b], vfa_b_back), eraseOpt(fa[c], vfa_c_back);\n\tadd(a), add(b), add(c), add(fa[b]), add(fa[c]);\n\tinsertOpt(a), insertOpt(b), insertOpt(c), insertOpt(fa[b]), insertOpt(fa[c]);\n}\n\nint main() {\n\t#ifndef ONLINE_JUDGE\n\t\tfreopen(\"test.in\", \"r\", stdin);\n\t#endif\n\tn = ReadInt(), q = ReadInt();\n\tfor (int i = 0; i < n; ++i) t[i] = ReadLL();\n\tfor (int i = 0; i < n; ++i) s[fa[i] = ReadInt() - 1]++;\n\tfor (int i = 0; i < n; ++i) {\n\t\tll v = cal(i);\n\t\tval[fa[i]] += v, val[i] += t[i] - (s[i] + 1) * v;\n\t}\n\tfor (int u = 0; u < n; ++u) {\n\t\tbs[fa[u]].insert(val[u]);\n\t\tss[fa[u]].insert(val[u]);\n\t}\n\tmemset(in, 0, sizeof in);\n\tfor (int i = 0; i < n; ++i)\n\t\tif (s[i]) {\n\t\t\toptb.insert(bs[i].top() + cal(i)),\n\t\t\topts.insert(ss[i].top() + cal(i));\n\t\t\tin[i] = true;\n\t\t}\n\twhile (q--) {\n\t\tint type = ReadInt();\n\t\tif (type == 1) {\n\t\t\tint u = ReadInt() - 1, v = ReadInt() - 1;\n\t\t\tmodify(u, v);\n\t\t\toptb.s.clear();\n\t\t\topts.s.clear();\n\t\t\tfor (int i = 0; i < n; ++i) if (s[i]) {\n\t\t\t\toptb.insert(bs[i].top() + cal(i));\n\t\t\t\topts.insert(ss[i].top() + cal(i));\n\t\t\t\tin[i] = true;\n\t\t\t}\n\t\t} else if (type == 2) {\n\t\t\tint u = ReadInt() - 1;\n\t\t\tprintf(\"%I64d\\n\", val[u] + cal(fa[u]));\n\t\t} else if (type == 3) {\n\t\t\tprintf(\"%I64d %I64d\\n\", opts.top(), optb.top());\n\t\t} else assert(false);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "beae786ba84e78d56914244eb2624fc2", "src_uid": "6a17d93dad158f70a36905206aa0ba3b", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n#if defined(ILIKEGENTOO)\nvoid E(){}templatevoid E(A _,B...$){cerr<<' '<<_;E($...);}\n#define E($...) E(#$,'=',$,'\\n')\n#else\n#define E($...) ;\n#endif\n#define all(x) begin(x), end(x)\nstruct ${$(){ios_base::sync_with_stdio(false);cin.tie(nullptr);}}$;\n\ntypedef __int128_t INT;\nINT lcm(INT x, INT y) {\n\treturn x / __gcd(x, y) * y;\n}\n\nint main() {\n\tint n;\n\tcin >> n;\n\tvector f(n);\n\tfor (int i = 0; i < n; ++i) {\n\t\tcin >> f[i];\n\t\t--f[i];\n\t}\n\tuint64_t ans = 1;\n\tfor (int i = 0; i < n; ++i) {\n\t\tbool ok = false;\n\t\tvector g(2);\n\t\tg[1] = f[i];\n\t\tfor (int i = 2;; ++i) {\n\t\t\tg.emplace_back(f[g[i - 1]]);\n\t\t\tif ((i & 1) == 0 && g[i] == g[i / 2]) {\n\t\t\t\tans = lcm(ans, i / 2);\n\t\t\t\tok = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tassert(ok);\n\t}\n\tassert(ans <= numeric_limits::max());\n\tcout << uint64_t(ans) << '\\n';\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "17f7312f969ab5549c775518764dff45", "src_uid": "1daa784c0eb1cde514e4319da07c8d00", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define F first\n#define S second\n#define pb push_back\n#define mp make_pair\n#define INF (1 << 30)\n\nusing namespace std;\n\nconst int N = 222;\n\nint p[N], a[N];\nint n;\nint curst;\nint v[N], g[N];\n\nvoid run(int x, int len = 1)\n{\n\tif (p[x] != 0)\n\t{\n\t\tv[curst] = len - p[x];\n\t\tg[curst] = p[x];\n\t\treturn;\n\t}\t\t\n\telse\n\t{\n\t\tp[x] = len;\n\t}\n\trun(a[x], len + 1);\n}\n\nint main()\n{\n\t//freopen(\"input.txt\", \"r\", stdin);\n\n\tcin >> n;\n\n\tfor (int i = 1; i <= n; i++)\n\t\tcin >> a[i];\t\n\n\tfor (int i = 1; i <= n; i++)\n\t{\n\t\tfill(p, p + N, 0);\n\t\tcurst = i;\n\t\trun(a[i]);\n\t}\n\n\tint64_t res = v[1];\n\tint mx = 0;\n\tfor (int i = 1; i <= n; i++)\n\t{\n\t\tmx = max(mx, g[i] - 1);\n\t\tres = res * v[i] / __gcd(res, v[i]);\t\n\t}\n\n\tres = (mx / res + 1) * res;\n\n\tcout << res;\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e225095cf5b274f994c9cf35430255cd", "src_uid": "1daa784c0eb1cde514e4319da07c8d00", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include \n\n#define forn(i, n) for(int i = 0; i < (int)(n); ++i)\n#define for1(i, n) for(int i = 1; i <= (int)(n); ++i)\n#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)\n#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; --i)\n#define ford1(i, n) for(int i = (int)(n); i>=1; --i)\n#define fored(i, a, b) for(int i = (int)(b); i >= (int)(a); --i)\n#define sz(v) ((int)((v).size()))\n#define all(v) (v).begin(), (v).end()\n#define mp make_pair\n#define pb push_back\n#define eb emplace_back\n#define fi first\n#define se second\n\nusing namespace std;\n\ntypedef pair pii;\ntypedef vector vpi;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef long long i64;\ntypedef unsigned long long u64;\ntypedef long double ld;\ntypedef vector vld;\n\ntemplate bool uax(T&a, const T& b) { if( a < b ) { a = b; return true; } return false; }\ntemplate bool uin(T&a, const T& b) { if( a > b ) { a = b; return true; } return false; }\n\nconst int inf = 1e9 + 100500;\nconst int MAXN = 100500;\n\n#ifdef HOME\n#define dbg(v) do {cerr << v << '\\n';}while(0)\n#else\n#define dbg(v) do {;}while(0)\n#endif\n\ntypedef __int64_t bint;\n\nstring tostr(bint x) {\n string r;\n while (x) {\n r += (char)('0' + (x%10));\n x /= 10;\n }\n if (r == \"\") r = \"0\";\n reverse(all(r));\n return r;\n}\n\nvoid solve() {\n int n;\n cin >> n;\n vi a(n);\n forn (i, n) {\n cin >> a[i];\n --a[i];\n }\n vi cyc(n, n+1);\n forn(i, n) {\n int x = i;\n forn(t, n + 2) {\n x = a[x];\n }\n cyc[x] = 0;\n }\n forn(t, n+2) {\n forn(i, n)\n uin(cyc[i], cyc[a[i]] + 1);\n }\n bint lans = (bint)(*max_element(all(cyc)));\n bint lca = 1;\n forn(i, n) if (cyc[i] == 0) {\n int il = 0, x = i;\n do {\n x = a[x];\n ++il;\n } while(x != i);\n bint l = il;\n lca /= __gcd(lca, l);\n lca *= l;\n }\n bint ans = lca;\n while (ans < lans)\n ans += lca;\n cout << tostr(ans) << '\\n';\n}\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout << fixed; cout.precision(15);\n cerr << fixed; cerr.precision(15);\n#ifdef HOME\n freopen(\"input.txt\", \"r\", stdin);\n#endif\n solve();\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f4593fb3ea721932cfa7d4996e5257c1", "src_uid": "1daa784c0eb1cde514e4319da07c8d00", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include \n\n#define forn(i, n) for(int i = 0; i < (int)(n); ++i)\n#define for1(i, n) for(int i = 1; i <= (int)(n); ++i)\n#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)\n#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; --i)\n#define ford1(i, n) for(int i = (int)(n); i>=1; --i)\n#define fored(i, a, b) for(int i = (int)(b); i >= (int)(a); --i)\n#define sz(v) ((int)((v).size()))\n#define all(v) (v).begin(), (v).end()\n#define mp make_pair\n#define pb push_back\n#define eb emplace_back\n#define fi first\n#define se second\n\nusing namespace std;\n\ntypedef pair pii;\ntypedef vector vpi;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef long long i64;\ntypedef unsigned long long u64;\ntypedef long double ld;\ntypedef vector vld;\n\ntemplate bool uax(T&a, const T& b) { if( a < b ) { a = b; return true; } return false; }\ntemplate bool uin(T&a, const T& b) { if( a > b ) { a = b; return true; } return false; }\n\nconst int inf = 1e9 + 100500;\nconst int MAXN = 100500;\n\n#ifdef HOME\n#define dbg(v) do {cerr << v << '\\n';}while(0)\n#else\n#define dbg(v) do {;}while(0)\n#endif\n\ntypedef __int128_t bint;\n\nstring tostr(bint x) {\n string r;\n while (x) {\n r += (char)('0' + (x%10));\n x /= 10;\n }\n if (r == \"\") r = \"0\";\n reverse(all(r));\n return r;\n}\n\nvoid solve() {\n int n;\n cin >> n;\n vi a(n);\n forn (i, n) {\n cin >> a[i];\n --a[i];\n }\n vi cyc(n, n+1);\n forn(i, n) {\n int x = i;\n forn(t, n + 2) {\n x = a[x];\n }\n cyc[x] = 0;\n }\n forn(t, n+2) {\n forn(i, n)\n uin(cyc[i], cyc[a[i]] + 1);\n }\n bint lans = (bint)(*max_element(all(cyc)));\n bint lca = 1;\n forn(i, n) if (cyc[i] == 0) {\n int il = 0, x = i;\n do {\n x = a[x];\n ++il;\n } while(x != i);\n bint l = il;\n lca /= __gcd(lca, l);\n lca *= l;\n }\n bint ans = lca;\n while (ans < lans)\n ans += lca;\n cout << tostr(ans) << '\\n';\n}\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout << fixed; cout.precision(15);\n cerr << fixed; cerr.precision(15);\n#ifdef HOME\n freopen(\"input.txt\", \"r\", stdin);\n#endif\n solve();\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c52f7373e6426aedd4bc7f6f74baeb4b", "src_uid": "1daa784c0eb1cde514e4319da07c8d00", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#define inf 2147483647\nusing namespace std;\ntypedef long long ll;\nll c0,c1,n;\nll gcd(ll a,ll b){\n\treturn b?gcd(b,a%b):a;\n}\nll lls[31];\nll comb(ll a,ll b){\n ll s=1,x,g;\n for(ll i=0; ++i<=b; lls[i]=i);\n for(ll i=-1; ++iinf/s)\n\t\t\treturn inf;\n\t\ts*=x;\n\t}\n return s;\n}\nbool check(ll x){\n\tll tmp=x/c0+x/c1+1;\n\tif(tmp>n)\n \treturn 1;\n for(ll i=0; ++i<=26; ){\n\t\tfor(ll j=i-1; (++j)*c0+i*c1<=x; )\n\t\t\tif((tmp+=comb(j,i))>n)\n\t\t\t\treturn 1;\n\t\tfor(ll j=i; (++j)*c1+i*c0<=x; )\n\t\t\tif((tmp+=comb(j,i))>n)\n\t\t\t\treturn 1;\n\t}\n\treturn 0;\n}\nvoid work(ll x,ll &tmp,ll &ans){\n tmp=x/c0+x/c1+1;\n ans=((x/c0)*(x/c0+1)*c0+(x/c1)*(x/c1+1)*c1)>>1;\n ll c;\n for(ll i=1;i<=26;++i){\n for(ll j=i;j*c0+i*c1<=x;++j){\n c=C(j,i);\n tmp+=c;\n ans+=c*(j*c0+i*c1);\n }\n for(ll j=i+1;j*c1+i*c0<=x;++j){\n c=C(j,i);\n tmp+=c;\n ans+=c*(j*c1+i*c0);\n }\n }\n}\n//void work(ll x,ll &tmp,ll &ans){\n//\ttmp=x/c0+x/c1+1;\n//\tans=((x/c0)*(x/c0+1)*c0+(x/c1)*(x/c1+1)*c1)>>1;\n//\tll c;\n//\tfor(int i=0; ++i<=26; ){\n//\t\tfor(ll j=i-1; (++j)*c0+i*c1<=x; ans+=c*(j*c0+i*c1))\n//\t\t\ttmp+=(c=comb(j,i));\n//\t\tfor(ll j=i; (++j)*c1+i*c0<=x; ans+=c*(j*c0+i*c1))\n//\t\t\ttmp+=(c=comb(j,i));\n//\t}\n//}\nint main(){\n\tscanf(\"%lld%lld%lld\",&n,&c0,&c1);\n\t--n,c0>c1&&(swap(c0,c1),1);\n\tif(!c0){\n\t\tprintf(\"%lld\\n\",n*c1);\n\t\treturn 0;\n\t}\n\tll l=0,r=c1*26,mid;\n while(l<=r){\n mid=(l+r)>>1; \n if(check(mid))r=mid-1;\n else l=mid+1;\n }\n ll c,s;\n work(l-1,c,s);\n s+=(n-c)*l+n*(c0+c1);\n printf(\"%lld\\n\",s);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e695f373bad647c863bf288653bf9104", "src_uid": "39b824b740a40f68bae39b8d9f0adcbe", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main ()\n{\n int n, m, r, a, b, k;\n cin >> n >> a >> b;\n if(min(a, b) == 0)\n\t{\n long long res = max(a, b) * (n - 1);\n\t\tcout << res << \"\\n\";\n\t\treturn 0;\n\t}\n map < long long, long long > mp;\n mp[0] = 1;\n n--;\n while (n){\n long long cost = mp.begin() -> first;\n long long cnt = mp.begin() -> second;\n if (cnt <= n)\n mp.erase(mp.begin());\n else\n mp[cost] -= n;\n int erased = min (n, cnt);\n mp[a+cost]+= erased;\n mp[b+cost]+= erased;\n n -= erased;\n }\n long long ans = 0;\n for(auto it : mp)\n ans += it.first * it.second;\n cout << ans ;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "696618247a2acb97778fd6c30d61129c", "src_uid": "39b824b740a40f68bae39b8d9f0adcbe", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\ntypedef long long int ll;\ntypedef long double ld;\n#define sz(x) ((long long int)(x).size())\n#define pb push_back\n#define itn int\n#define mp make_pair\n#define pii pair\n\nint main() {\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n ll n, c0, c1;\n cin >> n >> c0 >> c1;\n if (c1 == 0 || c2 == 0)\n return !(cout << (c1 + c2) * (n - 1));\n map f;\n f[0] = 1;\n --n;\n while (n > 0) {\n pii c = *(f.begin());\n if (c.second <= n) {\n f.erase(f.begin());\n f[c.first + c0] += c.second;\n f[c.first + c1] += c.second;\n }\n else {\n f[c.first] -= n;\n f[c.first + c0] += n;\n f[c.first + c1] += n;\n }\n n -= c.second;\n }\n ll ans = 0;\n for (pii x : f) {\n ans += x.first * x.second;\n }\n cout << ans;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "084280989cbd67fd71087165d56ab62c", "src_uid": "39b824b740a40f68bae39b8d9f0adcbe", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n\nusing namespace std;\n\n#define clr(x) memset((x), 0, sizeof(x))\n#define all(x) (x).begin(), (x).end()\n#define pb push_back\n#define mp make_pair\n#define sz size()\n#define For(i, st, en) for(int i=(st); i<=(int)(en); i++)\n#define Ford(i, st, en) for(int i=(st); i>=(int)(en); i--)\n#define forn(i, n) for(int i=0; i<(int)(n); i++)\n#define ford(i, n) for(int i=(n)-1; i>=0; i--)\n#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)\n\n#ifdef ROOM_311\n__attribute__((destructor)) void fini_main()\n{\n\tfprintf(stderr, \"Execution time = %0.0lf ms\\n\", clock() * 1000.0 / CLOCKS_PER_SEC);\n}\n#endif\n\n#define MY_RAND 1\n#if MY_RAND\nuint64_t rnd_data = 0xDEADBEEFDULL;\ninline void my_srand(int seed) { rnd_data = ((uint64_t)seed << 16) | 0x330E; }\ninline int my_rand() { rnd_data = rnd_data * 0x5DEECE66DULL + 0xB; return (rnd_data >> 17) & 0x7FFFFFFF; }\n#define rand my_rand\n#define srand my_srand\n#endif\n\ntemplate inline _T sqr(const _T &x) { return x * x; }\ntemplate inline string tostr(const _T &a) { ostringstream os(\"\"); os << a; return os.str(); }\n\n// Types\ntypedef long double ld;\ntypedef long long i64;\ntypedef unsigned long long u64;\ntypedef pair < int, int > PII;\ntypedef set < int > SI;\ntypedef vector < int > VI;\ntypedef map < string, int > MSI;\n\n// Constants\nconst ld PI = 3.1415926535897932384626433832795L;\nconst ld EPS = 1e-11;\n\nint n, c0, c1;\nint q[102400000];\nu64 b[(102400000 >> 6) + 1];\n\nint main()\n{\n#ifdef ROOM_311\n\tfreopen(\"input.txt\", \"rt\", stdin);\n#endif\n\tcout << setiosflags(ios::fixed) << setprecision(10);\n\t\n\tscanf(\"%d%d%d\", &n, &c0, &c1);\n\tif (c0 > c1) swap(c0, c1);\n\tint cc = c0 + c1;\n\tint m = c1 + 1;\n\tm = (m + 63) & ~63;\n\ti64 ans = 0;\n\tq[0] = 1;\n\tint k = 0;\n\ti64 kk = 0;\n\tfor (n--; n; )\n\t{\n\t\twhile (!q[k])\n\t\t{\n\t\t\tif (!(k & 63) && !b[k >> 6]) k += 63;\n\t\t\tif (++k == m) k = 0, kk += m;\n\t\t}\n\t\tint add = min(n, q[k]);\n\t\tif (!(q[k] -= add)) b[k >> 6] &= ~(1ULL << k);\n\t\tans += (k + kk + cc) * (i64)add;\n\t\tint k1 = k + c0;\n\t\tint k2 = k + c1;\n\t\tif (k1 >= m) k1 -= m;\n\t\tif (k2 >= m) k2 -= m;\n\t\tq[k1] += add;\n\t\tq[k2] += add;\n\t\tb[k1 >> 6] |= 1ULL << k1;\n\t\tb[k2 >> 6] |= 1ULL << k2;\n\t\tn -= add;\n\t}\n\tprintf(\"%lld\\n\", ans);\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b1a732b95f6b5186a60b61c8121b73d3", "src_uid": "39b824b740a40f68bae39b8d9f0adcbe", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n\tint a[100],n,b,c;\n\tcin>>n; \n\tfor(int i=0;i>a[i];\n\tb=a[n-1];\n\tsort(a,a+n);\n\tc=a[n-1];\n\tb=b^c\n\tcout<\n#include \nusing namespace std;\nint main(){\n\tint n,Max=-1e9+7,a;\n\tcin>>n;\n\tfor(int i=1;i<=n;i++){\n\t\tcin>>a;\n\t\tif (a!=11&&Max!=11) Max=max(a,Max);\n\t\telse Max=11;\n\t}\n\tcout<\nusing namespace std;\n\nint main() {\n int n , a[100];\n cin >> n;\n for (int i = 0 ; i < n ; ++ i) {\n cin >> a[i];\n }\n cout << *max_element(a , a + n) ^ a[n - 1] << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c1792348b4433b704cf3f70b0c584a44", "src_uid": "f45c769556ac3f408f5542fa71a67d98", "difficulty": 1800.0} {"lang": "GNU C++11", "source_code": "#include\n#include\nusing namespace std;\nint n,x=-1,y;\nint main(){\n scanf(\"%d\",&n);\n for(i=1;i<=n;i++)\n {\n scanf(\"%d\",&y);\n x=max(x,y);\n }\n int ans=x^y;\n printf(\"%d\\n\",ans);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "aaf4e7a05eb308689df467337409055a", "src_uid": "f45c769556ac3f408f5542fa71a67d98", "difficulty": 1800.0} {"lang": "GNU C++11", "source_code": "#include\n#include\nint T,p[300],cnt;\ndouble a,b;\nint main()\n{\n\tscanf(\"%d\",&T);\n\twhile(T--)\n\t{\n\t\ta=b=cnt=0;\n\t\tfor(int i=0;i<250;i++)\n\t\t{\n\t\t\tscanf(\"%d\",&p[i]);\n\t\t\ta+=pow(p[i],2)/250.0;\n\t\t}\n\t\tfor(int i=0;i<250;i++) cnt+=(abs(p[i])<2.0*sqrt(a));\n\t\tif(cnt<250) printf(\"poisson\\n\");\n\t\telse printf(\"uniform\\n\");\n\t}\n\treturn 0;\n}\n\n//\u4ee3\u7801\u6839\u672c\u5c31\u6ca1\u6709\u9001\u8fc7\u53bb\u561b", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7143ce5c25d991895ab04b374f45e446", "src_uid": "6ef75e501b318c0799d3cbe8ca998984", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#include\n#include\nint T,p[300],cnt;\ndouble a,b;\nint main()\n{\n\tscanf(\"%d\",&T);\n\twhile(T--)\n\t{\n\t\ta=b=cnt=0;\n\t\tfor(int i=0;i<250;i++)\n\t\t{\n\t\t\tscanf(\"%d\",&p[i]);\n\t\t\ta+=pow(p[i],2)/250.0;\n\t\t}\n\t\tfor(int i=0;i<250;i++) cnt+=(abs(p[i])<2.0*sqrt(a));\n\t\tif(cnt<250) printf(\"poisson\\n\");\n\t\telse printf(\"uniform\\n\");\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7cba33cae68dd24a6963cf9c91c65c79", "src_uid": "6ef75e501b318c0799d3cbe8ca998984", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "#include \n#define ll long long\n#define INF 1000000005\n#define MOD 1000000007\n#define EPS 1e-10\n#define rep(i,n) for(int i=0;i<(int)(n);++i)\n#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)\n#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)\n#define each(a,b) for(const auto& (a): (b))\n#define all(v) (v).begin(),(v).end()\n#define len(v) (int)(v).size()\n#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())\n#define cmx(x,y) x=max(x,y)\n#define cmn(x,y) x=min(x,y)\n#define fi first\n#define se second\n#define pb push_back\n#define show(x) cout<<#x<<\" = \"<<(x)<auto&operator<<(ostream&o,pairp){return o<<\"{\"<auto&operator<<(ostream&o,sets){for(auto&e:s)o<\nauto&operator<<(ostream&o,priority_queueq){while(!q.empty())o<auto&operator<<(ostream&o,map&m){for(auto&e:m)o<auto&operator<<(ostream&o,vectorv){for(auto&e:v)o<void ashow(T t,A...a){cout<\nstruct TRI{S fi;T se;U th;TRI(){}TRI(S f,T s,U t):fi(f),se(s),th(t){}\nbool operator<(const TRI&_)const{return(fi==_.fi)?((se==_.se)?(th<_.th):(se<_.se)):(fi<_.fi);}};\ntemplate\nauto&operator<<(ostream&o,TRI&t){return o<<\"{\"< P;\ntypedef pair pll;\ntypedef TRI tri;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vl;\ntypedef vector vvl;\ntypedef vector vd;\ntypedef vector

    vp;\ntypedef vector vs;\n\nconst int MAX_N = 100005;\n\nint bue[MAX_N];\ndouble sm[MAX_N], LOG[MAX_N];\n\ndouble solve1(int k, int p){\n return k * LOG[p] - p - sm[k];\n}\n\ndouble solve2(int p){\n return -LOG[2*p+1];\n}\n\nint main(){\n cin.tie(0);\n ios::sync_with_stdio(false);\n int n;\n cin >> n;\n rep(i,MAX_N){\n LOG[i] = log(i);\n if(i) sm[i] = sm[i-1] + LOG[i];\n }\n rep(i,n){\n // double mean = 0;\n rep(j,250){\n cin >> bue[j];\n }\n // mean /= 250.0;\n // double hoge = 0;\n // rep(j,250){\n // hoge += (bue[j] - mean) * (bue[j] - mean);\n // }\n // hoge /= 250.0;\n bool ans = false;\n double res = -1e300;\n rep(p,1,1001){\n double ch1 = 0, ch2 = 0;\n bool dame = false;\n rep(j,250){\n if(bue[j] > 2 * p) dame = true;\n ch1 += solve1(bue[j], p), ch2 += solve2(p);\n }\n if(dame) ch2 = -1e301;\n if(ch1 > res) res = ch1, ans = false;\n if(ch2 > res) res = ch2, ans = true;\n }\n if(ans){\n cout << \"uniform\\n\";\n }else{\n cout << \"poisson\\n\";\n }\n // if(abs(hoge - mean) < abs(hoge - mean * mean / 3.0)){\n // int ans = -1;\n // double res = -1e300;\n // srep(p,10,1001){\n // double ch = 0;\n // rep(j,250){\n // ch += solve1(bue[j], p);\n // }\n // if(ch > res) res = ch, ans = p;\n // }\n // cout<< ans << \"\\n\";\n // }else{\n // const int cand = (*max_element(bue, bue + 250) + 1) / 2;\n // cout << cand << \"\\n\";\n // if(cand < 50){\n // }else{\n // const int ans = round(mean);\n // cout << ans << \"\\n\";\n // }\n // double res = -1e300;\n // srep(p,10,1001){\n // double ch = 0;\n // rep(j,250){\n // ch += solve2(p);\n // }\n // if(ch > res) ch = res, ans = p;\n // }\n // }\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3b55419bbb0939d73f194d3c5da8e22e", "src_uid": "6ef75e501b318c0799d3cbe8ca998984", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize (\"O3\")\n#pragma GCC target (\"sse4\")\n\n#include \n#include \n#include \n#include \n\nusing namespace std;\nusing namespace __gnu_pbds;\nusing namespace __gnu_cxx;\n \ntypedef long long ll;\ntypedef long double ld;\ntypedef complex cd;\n\ntypedef pair pi;\ntypedef pair pl;\ntypedef pair pd;\n\ntypedef vector vi;\ntypedef vector vd;\ntypedef vector vl;\ntypedef vector vpi;\ntypedef vector vpl;\ntypedef vector vcd;\n\ntemplate using Tree = tree, rb_tree_tag,tree_order_statistics_node_update>;\n\n#define FOR(i, a, b) for (int i=a; i<(b); i++)\n#define F0R(i, a) for (int i=0; i<(a); i++)\n#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)\n#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)\n\n#define sz(x) (int)(x).size()\n#define mp make_pair\n#define pb push_back\n#define f first\n#define s second\n#define lb lower_bound\n#define ub upper_bound\n#define all(x) x.begin(), x.end()\n\nconst int MOD = 1000000007;\nconst ll INF = 1e18;\nconst int MX = 3005;\n\nint V, oc[2*MX], mn;\nld prob0[1001][MX], prob1[1001][MX];\n\nvoid gen(int mean) {\n ld a = 1;\n int divi = mean;\n F0R(i,MX) {\n prob0[mean][i] = a*exp(-divi);\n a *= mean; a /= i+1;\n while (divi && a/exp(1) >= 1) divi --, a /= exp(1);\n }\n F0R(i,2*mean+1) prob1[mean][i] = (ld)1/(2*mean+1);\n}\n\nld getOc(int i, int mean) {\n // mean+x = i \n return oc[i-mean+MX];\n}\n\nld dif(ld a, ld b) {\n return abs(a-b)/(a+0.0001);\n}\n\npair tri(int mean) {\n if (mean < mn) return {MOD,MOD};\n \n ld x = 0, y = 0;\n F0R(i,MX) {\n ld d = (ld)getOc(i,mean)/250;\n x += dif(prob0[mean][i],d);\n y += dif(prob1[mean][i],d);\n }\n \n return {x,y};\n}\n\nvoid solve() {\n F0R(i,2*MX) oc[i] = 0;\n int mn = 0;\n F0R(i,250) {\n int k = (rand() % 1501)-750; \n int k; cin >> k;\n // if (k < MX && k > -MX) oc[k+MX] ++;\n mn = min(mn,k);\n }\n \n ld x = MOD, y = MOD;\n \n FOR(mean,1,1001) {\n pair p = tri(mean);\n x = min(x,p.f), y = min(y,p.s);\n // cout << p.s << \"\\n\";\n }\n \n // cout << x << \" \" << y << \"\\n\";\n if (x < y) cout << \"poisson\";\n else cout << \"uniform\";\n cout << \"\\n\";\n}\n\nint main() {\n ios_base::sync_with_stdio(0); cin.tie(0);\n FOR(i,1,1001) gen(i);\n cin >> V;\n F0R(i,V) solve();\n}\n\n/* Look for:\n* the exact constraints (multiple sets are too slow for n=10^6 :( ) \n* special cases (n=1?)\n* overflow (ll vs int?)\n* array bounds\n* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/\n*/", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fc2745a06a2f458fdc3330d00e151649", "src_uid": "6ef75e501b318c0799d3cbe8ca998984", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n#define fi first\n#define se second\n#define pi acos(-1.0)\n#define rep(i,a,b) for(int i=a;i<=b;i++)\n#define per(i,a,b) for(int i=a;i>=b;i--)\n#define pb push_back\n#define mk(a,b) make_pair(a, b);\n#define mem(a,b) memset(a,b,sizeof(a))\n#define pii pair\n#define pli pair\n#define pll pair\n#define pil pair\n#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n#define fopen freopen(\"in.txt\", \"r\", stdin);freopen(\"out.txt\", \"w\", stdout);\ntypedef long long ll;\ntypedef double db;\nconst db eps = 1e-12;\nconst int inf = 0x3f3f3f3f;\nconst int N = 3e5 + 5;\nconst int mod = 998244353;\nll n, f[N][3], q[3];\nvector g[N];\nvoid dfs(ll u, ll fa){\n f[u][0] = 1;\n for(auto v:g[u]){\n if(v == fa) continue;\n dfs(v, u);\n q[0] = (f[u][0] * (f[v][0] + f[v][2])) % mod;\n q[1] = (f[u][0]*f[v][2] + f[u][1] * (f[v][0]+f[v][2]*2)) % mod;\n q[2] = (f[u][0]*(f[v][0]+f[v][1]) + f[u][1]*(f[v][0]+f[v][1]) + f[u][2]*(f[u][0]+f[v][2]*2)) % mod;\n swap(q,f[u]);\n }\n}\n\nint main(){\n ll t, k;\n scanf(\"%lld\", &n);\n rep(i,2,n){\n scanf(\"%lld%lld\", &t,&k);\n g[t].pb(k); g[k].pb(t);\n }\n dfs(1,0);\n printf(\"%lld\\n\", (f[1][0]+f[1][2]) % mod);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1c7d17491033f58e58a24b2798980590", "src_uid": "a40e78a7144ac2fae1890ac7598990bf", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nvector > G;\nvector stopnie;\nvector > stany; \nlong long modulo = 998244353;\n/*\nstan 1 - jesli jest z synkiem LUB izolowany ( i kazde poddrzewo jest ok)\nstan 2 - laczymy z tata, nie z jakims synkiem\nstan 3 - laczy sie z ktoryms z synkow\n*/\nlong long SzypkiePot(long long pod, long long pot, long long mod){\n if (pot == 0){return 1;}\n long long wynik = SzypkiePot(pod, pot/2, mod)%mod;\n if (pot % 2 == 0){ return (wynik*wynik)%mod;}\n else{ return (pod*((wynik*wynik)%mod))%mod; }\n}\nlong long Odw(long long x, long long mod){ return SzypkiePot(x, mod-2, mod)%mod;}\n\n\nvoid Licz(long long v, long long tata){\n cerr << \"v \"<> n;\n stopnie.resize(n);\n G.resize(n);\n stany.resize(n);\n for (long long i = 0; i < n-1; i++){\n long long u, v;\n cin >> u >> v;\n u--;\n v--;\n stopnie[u]++;\n stopnie[v]++;\n G[u].push_back(v);\n G[v].push_back(u);\n }\n DFS(0, 0);\n // for (long long i = 0; i < n; i++){\n // cerr << \"v = \"<\n#define off exit( 0 )\n#define cn continue\n#define rt return\n#define sc scanf\n#define pr printf\n#define pb push_back\n#define pf push_front\n#define p_f pop_front\n#define p_b pop_back\n#define ff first\n#define ss second\n#define vec vector\n#define gcd __gcd\n#define pi acos( -1 )\n#define ll long long\n#define ld long double\n#define pdd pair < ld, ld >\n#define pll pair < ll, ll >\n#define pii pair < int, int >\n#define rep( a, b, c, d ) for( int a = b; a <= c; a += d )\n#define rvv( a, b, c, d ) for( int a = b; a >= c; a -= d )\n#define en printf( \"\\n\" )\n#define sqr( a ) a * a\n#define all( c ) c.begin(), c.end()\n#define srt( c ) sort( all( c ) )\n#define rev( c ) reverse( all( c ) )\n#define srtr( c ) sort( c.rbegin(), c.rend() )\n#define numcounts __builtin_popcount\n#define mxn( x, y, z ) max( x, min( y, z ) )\n#define mnx( x, y, z ) min( x, max( y, z ) )\n#define rep( i, x, y ) for( int i = (x); i <= (y); i ++ )\n#define dep( i, x, y ) for( int i = (x); i >= (y); i -- )\n#define TIME() if(QQQQ)printf(\"My Time: %.3lfms\\n\", (double)clock() / CLOCKS_PER_SEC);\nbool QQQQ;\n#define see(x) if(QQQQ)cout << x << \" \";\n#define sees(x) if(QQQQ)cout << x << endl;\n#define N 105\n#define NN 10005\n#define M 998244353\n#define I 1000000000000000000\nconst int dx[ ] = { 1, -1, 0, 0 };\nconst int dy[ ] = { 0, 0, -1, 1 };\nusing namespace std;\n\nll ttt = 1;\nll n, ans, a[N], b[N], c[N];\nvector < ll > g[N];\n\nvoid dfs( ll v )\n{\n a[v] = c[v] = 1;\n for( ll to: g[v] )\n {\n if( !a[to] )\n {\n dfs( to );\n b[v] = ( ((a[v] * a[to]) % M) + ((b[v] * (b[to] + c[to])) % M) ) % M;\n c[v] = (c[v] * c[to]) % M;\n a[v] = (a[v] * (b[to] + c[to])) % M;\n }\n }\n c[v] = (c[v] + b[v]) % M;\n}\n\nvoid solve()\n{\n sc( \"%I64d\", &n );\n for( int i = 1; i < n; i ++ )\n {\n int x, y;\n sc( \"%d%d\", &x, &y );\n g[x].pb(y);\n g[y].pb(x);\n }\n dfs(1);\n ans = 1;\n for( ll i: g[1] )ans = (ans * c[i]) % M;\n ans = (ans + b[1]) % M;\n pr( \"%I64d\", ans );\n}\nint main()\n{\n QQQQ = 0;\n //sc( \"%I64d\", &ttt );\n for( int i = 1; i <= ttt; i ++ )\n solve();\n TIME();\n}\n\n\n/*\n1\n5 5\n1 2 3 4 5\n3 4 5 1 2\n*/\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "866938bd2c51f2f787ac617753fc3bde", "src_uid": "a40e78a7144ac2fae1890ac7598990bf", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "//#pragma comment(linker, \"/STACK:1024000000,1024000000\")\n/* vim: set fdm=marker */\n//{{{\n#define __ return\nint ATTENTION() {\n\t/* pls IGNORE this function and go down and HACK me\n\t * read this AFTER contest\n\t * this function is empty and it will not be called !\n\t */\n\n\thttp://codeforces.com/group/Pmz2A2x7ES\n\t/* I created a group there.\n\t * I hope with the group, people can finish\n\t * past contests, which is important for \n\t * increasing rating.\n\t * I am still getting familiar with this function.\n\t */\n\t __ 0;\n}\n// deprecated because mac doesn't support this...\n/* #include */\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\nconst int iinf = 0x7fffffff;\nconst ll linf = ~(1LL<<63);\ntypedef pair pii;\ntypedef vector vi;\ntypedef vector vll;\ntypedef map mli;\ntypedef map mll;\ntemplate\ninline T gcd(T a, T b) {\n\tif(a < 0) return gcd(-a, b);\n\tif(b < 0) return gcd( a,-b);\n\tif(a < b) return gcd(b, a);\n\tif(b == 0) return a;\n\treturn gcd(b, a%b);\n}\n\nll qpow(ll a, ll n, ll mod) {\n\ta %= mod;\n\tll ans = 1LL;\n\twhile(n) {\n\t\tif(n & 1) ans = (ans*a % mod);\n\t\ta = (a*a % mod);\n\t\tn >>= 1;\n\t}\n\treturn ans;\n}\n\ninline ll rev(ll a, ll p) {\n\treturn qpow(a, p - 2, p);\n}\n\n#define all(v) v.begin(), v.end()\n#define sz(v) v.size()\n#define rep(x, st, en) for(int x = st; x < en; x++)\n#define rer(x, st, en) for(int x = st; x >= en; x--)\n#define pb push_back\n#define mp make_pair\n#define dbgm(msg, var) cerr<<#msg<<\" \"<<#var<<\" = \"<\ninline void BPS(T* DST, T* SRC, int N, int s = 0) {\n\tDST[s] = SRC[s];\n\trep(i, 1, N) DST[s + i] = DST[s + i - 1] + SRC[s + i];\n}\ninline int in() { int x; cin>>x; return x; }\n#ifdef ALNDBG\nnamespace alndbg {\n\tclock_t s, e;\n}\n#endif\n\ninline void tic() {\n#ifdef ALNDBG\n\talndbg::s = clock();\n#endif\n}\n\ninline void toc() {\n#ifdef ALNDBG\n\talndbg::e = clock();\n\tcerr<<1000.0 * (alndbg::e - alndbg::s) / CLOCKS_PER_SEC<<\" ms\"< E[maxn];\n\nint n;\n\nll dp[maxn][3];\n\n// dp[i][0] = sum(max(dp[sub[i]][0/1]))\n// dp[i][1] \n\nvoid addedge(int u, int v) {\n E[u].pb(v);\n E[v].pb(u);\n}\n\nvoid dfs(int u, int fa=-1) {\n dp[u][0] = 1LL;\n dp[u][1] = 1LL;\n dp[u][2] = 0;\n for(auto v : E[u]) {\n if(v == fa) continue;\n dfs(v, u);\n dp[u][1] = (dp[u][1] * ( (dp[v][0] + dp[v][2]) % mod ) % mod;\n dp[u][0] = (dp[u][0] * dp[v][0]) % mod;\n }\n for(auto v : E[u]) {\n if(v == fa) continue;\n dp[u][2] = (dp[u][2] + dp[v][1] * dp[u][1] % mod * rev(dp[v][0] + dp[v][2], mod) % mod) % mod;\n }\n dp[u][0] = (dp[u][0] + dp[u][2]) % mod;\n}\n\nvoid solve() {\n dfs(1);\n ll ans = dp[1][0];\n cout<>n;\n rep(i,0,n-1) {\n int u, v;\n cin>>u>>v;\n addedge(u, v);\n }\n solve();\n\treturn 0;\n}\n// --USE C++11\n// *-USE O2\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1adef2ccf1b0fd45179468b0f970e486", "src_uid": "a40e78a7144ac2fae1890ac7598990bf", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "#ifndef Local\n#pragma GCC optimize(\"Ofast,no-stack-protector\")\n#pragma GCC target(\"sse4,sse4.2,popcnt,abm,mmx,avx\")\n#endif\n#include \n\nusing namespace std;\n\n#define popCnt(x) (__builtin_popcountll(x))\n#define sz(x) ((int)(x.size()))\n#define all(v) begin(v), end(v)\n#define rall(v) rbegin(v), rend(v)\n#define rep(i, l, r) for (int i = l; i < r; ++i)\ntypedef long long Long;\ntypedef double Double;\n\ntemplate \nistream& operator>>(istream& is, pair& p) {\n is >> p.first >> p.second;\n return is;\n}\ntemplate \nistream& operator>>(istream& is, vector& v) {\n for (auto& x : v) {\n is >> x;\n }\n return is;\n}\n\ntemplate \nostream& operator<<(ostream& os, const vector& v) {\n for (auto& x : v) {\n os << x << \" \";\n }\n return os;\n}\n\nconst Double EPS = 1e-10;\n\nenum Relation { LESS_THAN, EQUAL, GREATER_THAN };\n\nbool areEqual(Double x, Double y, Double eps = EPS) {\n auto diff = abs(x - y);\n x = abs(x), y = abs(y);\n if (diff <= eps) return true;\n if (min(x, y) <= eps) return false;\n return diff <= eps * max(x, y);\n}\n\nbool isZero(Double x, Double eps = EPS) { return abs(x) <= eps; }\nbool isZero(Long x) { return x == 0; }\n\nint compareDoubles(Double x, Double y, Double eps = EPS) {\n if (areEqual(x, y, eps)) return Relation::EQUAL;\n if (x < y) return Relation::LESS_THAN;\n return Relation::GREATER_THAN;\n}\n\ntemplate \nstruct Point {\n typedef Point P;\n const static P Invalid;\n const static P Origin;\n\n T x = 0, y = 0;\n Point(T x, T y) : x(x), y(y) {}\n Point() {}\n pair to_pair() const { return make_pair(x, y); }\n Point operator+(const Point& p) const { return Point{x + p.x, y + p.y}; }\n Point operator-(const Point& p) const { return Point{x - p.x, y - p.y}; }\n Point operator*(T c) const { return Point(x * c, y * c); }\n Point operator/(T c) const { return Point(x / c, y / c); }\n bool operator<(const Point& p) const {\n return (*this) != p && to_pair() < p.to_pair();\n }\n bool operator>(const Point& p) const { return (*this) != p && !(*this < p); }\n bool operator==(const Point& p) const {\n return isZero(this->x - p.x) && isZero(this->y - p.y);\n }\n bool operator!=(const Point& p) const { return !(*this == p); }\n T cross(const P& p) const { return x * p.y - y * p.x; }\n T cross(const P& a, const P& b) const { return (a - *this).cross(b - *this); }\n T dot(const P& p) const { return x * p.x + y * p.y; }\n P midPoint(const P& p) const { return ((*this) + p) / 2; }\n P getVector(const P& p) const { return p - (*this); }\n T dist2(const P& p) const { return getVector(p).dist2(); }\n T dist2() const { return (*this).dot(*this); }\n Double dist(const P& p) const { return sqrt(dist2(p)); }\n Double dist() const { return sqrt(dist2()); }\n P rotateCCW90() const { return P(-y, x); }\n P rotateCCW90Around(const P& p) const {\n return p + p.getVector(*this).rotateCCW90();\n }\n // Scales the plane by 1/cos(45 degrees)\n P rotateCCW45WithScale() const { return P(x - y, x + y); }\n P rotateCCW(Double angle) const {\n return Point(x * cos(angle) - y * sin(angle),\n x * sin(angle) + y * cos(angle));\n }\n\n // Project point onto line through a and b (assuming a != b).\n P projectOnLine(const P& a, const P& b) const {\n P ab = a.getVector(b);\n P ac = a.getVector(*this);\n return a + ab * ac.dot(ab) / a.dist2(b);\n }\n\n // Project point c onto line segment through a and b (assuming a != b).\n P projectOnSegment(const P& a, const P& b) const {\n P& c = *this;\n P ab = a.getVector(b);\n P ac = a.getVector(c);\n\n Double r = dot(ac, ab), d = a.dist2(b);\n if (r < 0) return a;\n if (r > d) return b;\n\n return a + ab * r / d;\n }\n\n P reflectAroundLine(const P& a, const P& b) const {\n return projectOnLine(a, b) * 2 - (*this);\n }\n\n friend istream& operator>>(istream& is, P& p) {\n string x, y;\n is >> x >> y;\n p.x = stod(x), p.y = stod(y);\n return is;\n }\n\n friend ostream& operator<<(ostream& os, const P& p) {\n return os << p.x << \",\" << p.y;\n }\n};\n\ntemplate \nconst Point Point::Invalid = Point(numeric_limits::max(),\n numeric_limits::max());\ntemplate \nconst Point Point::Origin = Point(0, 0);\n\ntypedef Point Vector;\ntypedef Point P;\ntemplate \nbool onSegment(P s, P e, P p) {\n return p.cross(s, e) == 0 && (s - p).dot(e - p) <= 0;\n}\ntemplate \nbool inPolygon(const vector

    & p, const P& a, bool strict = true) {\n int cnt = 0, n = sz(p);\n rep(i, 0, n) {\n P q = p[(i + 1) % n];\n if (onSegment(p[i], q, a)) return !strict;\n // or: if (segDist(p[i], q, a) <= eps) return !strict;\n cnt ^= ((a.y < p[i].y) - (a.y < q.y)) * a.cross(p[i], q) > 0;\n }\n return cnt;\n}\n\ntemplate \nT polygonArea2(vector>& v) {\n T a = v.back().cross(v[0]);\n rep(i, 0, sz(v) - 1) a += v[i].cross(v[i + 1]);\n return a;\n}\n\nusing Polygon = vector

    ;\n\nstruct Circle {\n Double r;\n P center;\n};\n\nDouble segDist(const P& s, const P& e, const P& p) {\n if (s == e) return (p - s).dist();\n auto d = (e - s).dist2(), t = min(d, max(Double(.0), (p - s).dot(e - s)));\n return ((p - s) * d - (e - s) * t).dist() / d;\n}\n\nDouble pointPolygonDistance(const P& point, const Polygon& polygon) {\n if (inPolygon(polygon, point)) return 0;\n Double res = 1e15;\n for (int i = 0; i < sz(polygon); ++i) {\n int j = (i + 1) % sz(polygon);\n res = min(res, segDist(polygon[i], polygon[j], point));\n }\n return res;\n}\n\nbool circleIntersectsPolygon(const Circle& circle, const Polygon& polygon) {\n return compareDoubles(pointPolygonDistance(circle.center, polygon),\n circle.r) != Relation::GREATER_THAN;\n}\n\nint main() {\n ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n#ifdef Local\n freopen(\"test.in\", \"r\", stdin);\n#else\n#define endl '\\n'\n#endif\n\n int n;\n cin >> n >> n >> n;\n vector polys(n);\n vector areas;\n areas.reserve(n);\n for (auto& poly : polys) {\n int v;\n cin >> v;\n poly.resize(v);\n cin >> poly;\n areas.emplace_back(polygonArea2(poly));\n }\n cout << fixed << setprecision(4);\n int q;\n cin >> q;\n while (q--) {\n Circle circle;\n cin >> circle.center >> circle.r;\n vector res;\n Double sum_areas = 0;\n for (int i = 0; i < n; ++i) {\n if (circleIntersectsPolygon(circle, polys[i])) {\n sum_areas += areas[i];\n res.emplace_back(i);\n }\n }\n cout << sum_areas / 2 << \" \" << sz(res) << \" \" << res << endl;\n }\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "101cc4381f573ec32929e51cf07298fc", "src_uid": "a1e94ec65b28e428faac529e602b0fa6", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include \n \nusing namespace std;\n \n//#define MULTITEST\n \n#define x first\n#define y second\n#define mp make_pair\n#define pb push_back\n#define sqr(a) ((a) * (a))\n#define sz(a) int(a.size())\n#define all(a) a.begin(), a.end()\n#define forn(i, n) for(int i = 0; i < int(n); i++) \n#define fore(i, l, r) for(int i = int(l); i < int(r); i++)\n \ntypedef long long li;\ntypedef long double ld;\ntypedef pair pt;\n \ntemplate ostream& operator << (ostream& out, const pair &a) {\n\treturn out << \"(\" << a.x << \", \" << a.y << \")\";\n}\n \ntemplate ostream& operator << (ostream& out, const vector &v) {\n\tout << \"[\";\n\tforn(i, sz(v)) {\n\t\tif(i) out << \", \";\n\t\tout << v[i];\n\t}\n\treturn out << \"]\";\n}\n \nmt19937 rnd(time(NULL));\n \nconst int INF = int(1e9);\nconst li INF64 = li(4e18);\nconst int MOD = 998244353;\nconst ld EPS = 1e-9;\nconst ld PI = acos(-1.0);\n\nconst int N = 20 * 1000 + 13;\n\nint n;\npt a[N];\n\nbool read () {\n\tif (scanf(\"%d\", &n) != 1)\n\t\treturn false;\n\tforn(i, n)\n\t\tscanf(\"%d%d\", &a[i].x, &a[i].y);\n\treturn true;\n}\n\nvoid solve() {\n\tmap xs, ys;\n\tforn(i, n) xs[a[i].x] ^= 1, ys[a[i].y] ^= 1;\n\tint mn = 0;\n\tfor (auto it : xs) mn += it.y;\n\tfor (auto it : ys) mn += it.y;\n\t\n\tforn(mask, 1 << n){\n\t\tmap xs2[2], ys2[2];\n\t\tforn(i, n){\n\t\t\tint c = (mask >> i) & 1;\n\t\t\txs2[c][a[i].x] += 1;\n\t\t\tys2[c][a[i].y] += 1;\n\t\t}\n\t\tint cur = 0;\n\t\tfor (auto it : xs) cur += abs(xs2[0][it.x] - xs2[1][it.x]);\n\t\tfor (auto it : ys) cur += abs(ys2[0][it.x] - ys2[1][it.x]);\n\t\tif (cur == mn){\n\t\t\tcerr << n << endl;\n\t\t\tforn(i, n) cerr << a[i].x << \" \" << a[i].y << \" \" << int((mask >> i) & 1) << endl;\n\t\t\tassert(mask == 0);\n\t\t\treturn;\n\t\t}\n\t}\n\t//cerr << mn << endl;\n\tassert(false);\n}\n\nbool gen(){\n\tn = 9;\n\tforn(i, n) a[i] = mp(rnd() % 7, rnd() % 7);\n\treturn true;\n}\n \nint main() {\n#ifdef _DEBUG\n\tfreopen(\"input.txt\", \"r\", stdin);\n//\tfreopen(\"output.txt\", \"w\", stdout);\n\t\n\tint tt = clock();\n#else\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif\n\t\n\tcerr.precision(15);\n\tcout.precision(15);\n\tcerr << fixed;\n\tcout << fixed;\n \n\twhile (gen()){\n\t\tsolve();\n\t\t\n#ifdef _DEBUG\n\tcerr << \"TIME = \" << clock() - tt << endl;\n\ttt = clock();\n#endif\n \n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4ebd8804cd6f2b1176f8f79b0e5ce9f1", "src_uid": "a1e94ec65b28e428faac529e602b0fa6", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "#ifndef Local\n#pragma GCC optimize(\"Ofast,no-stack-protector\")\n#pragma GCC target(\"sse4,sse4.2,popcnt,abm,mmx,avx\")\n#endif\n#include \n\nusing namespace std;\n\n#define popCnt(x) (__builtin_popcountll(x))\n#define sz(x) ((int)(x.size()))\n#define all(v) begin(v), end(v)\n#define rall(v) rbegin(v), rend(v)\n#define rep(i, l, r) for (int i = l; i < r; ++i)\ntypedef long long Long;\ntypedef double Double;\n\ntemplate \nistream& operator>>(istream& is, pair& p) {\n is >> p.first >> p.second;\n return is;\n}\ntemplate \nistream& operator>>(istream& is, vector& v) {\n for (auto& x : v) {\n is >> x;\n }\n return is;\n}\n\ntemplate \nostream& operator<<(ostream& os, const vector& v) {\n for (auto& x : v) {\n os << x << \" \";\n }\n return os;\n}\n\nconst Double EPS = 1e-10;\n\nenum Relation { LESS_THAN, EQUAL, GREATER_THAN };\n\nbool areEqual(Double x, Double y, Double eps = EPS) {\n auto diff = abs(x - y);\n x = abs(x), y = abs(y);\n if (diff <= eps) return true;\n if (min(x, y) <= eps) return false;\n return diff <= eps * max(x, y);\n}\n\nbool isZero(Double x, Double eps = EPS) { return abs(x) <= eps; }\nbool isZero(Long x) { return x == 0; }\n\nint compareDoubles(Double x, Double y, Double eps = EPS) {\n if (areEqual(x, y, eps)) return Relation::EQUAL;\n if (x < y) return Relation::LESS_THAN;\n return Relation::GREATER_THAN;\n}\n\ntemplate \nstruct Point {\n typedef Point P;\n const static P Invalid;\n const static P Origin;\n\n T x = 0, y = 0;\n Point(T x, T y) : x(x), y(y) {}\n Point() {}\n pair to_pair() const { return make_pair(x, y); }\n Point operator+(const Point& p) const { return Point{x + p.x, y + p.y}; }\n Point operator-(const Point& p) const { return Point{x - p.x, y - p.y}; }\n Point operator*(T c) const { return Point(x * c, y * c); }\n Point operator/(T c) const { return Point(x / c, y / c); }\n bool operator<(const Point& p) const {\n return (*this) != p && to_pair() < p.to_pair();\n }\n bool operator>(const Point& p) const { return (*this) != p && !(*this < p); }\n bool operator==(const Point& p) const {\n return isZero(this->x - p.x) && isZero(this->y - p.y);\n }\n bool operator!=(const Point& p) const { return !(*this == p); }\n T cross(const P& p) const { return x * p.y - y * p.x; }\n T cross(const P& a, const P& b) const { return (a - *this).cross(b - *this); }\n T dot(const P& p) const { return x * p.x + y * p.y; }\n P midPoint(const P& p) const { return ((*this) + p) / 2; }\n P getVector(const P& p) const { return p - (*this); }\n T dist2(const P& p) const { return getVector(p).dist2(); }\n T dist2() const { return (*this).dot(*this); }\n Double dist(const P& p) const { return sqrt(dist2(p)); }\n Double dist() const { return sqrt(dist2()); }\n P rotateCCW90() const { return P(-y, x); }\n P rotateCCW90Around(const P& p) const {\n return p + p.getVector(*this).rotateCCW90();\n }\n // Scales the plane by 1/cos(45 degrees)\n P rotateCCW45WithScale() const { return P(x - y, x + y); }\n P rotateCCW(Double angle) const {\n return Point(x * cos(angle) - y * sin(angle),\n x * sin(angle) + y * cos(angle));\n }\n\n // Project point onto line through a and b (assuming a != b).\n P projectOnLine(const P& a, const P& b) const {\n P ab = a.getVector(b);\n P ac = a.getVector(*this);\n return a + ab * ac.dot(ab) / a.dist2(b);\n }\n\n // Project point c onto line segment through a and b (assuming a != b).\n P projectOnSegment(const P& a, const P& b) const {\n P& c = *this;\n P ab = a.getVector(b);\n P ac = a.getVector(c);\n\n Double r = dot(ac, ab), d = a.dist2(b);\n if (r < 0) return a;\n if (r > d) return b;\n\n return a + ab * r / d;\n }\n\n P reflectAroundLine(const P& a, const P& b) const {\n return projectOnLine(a, b) * 2 - (*this);\n }\n\n friend istream& operator>>(istream& is, P& p) { return is >> p.x >> p.y; }\n\n friend ostream& operator<<(ostream& os, const P& p) {\n return os << p.x << \",\" << p.y;\n }\n};\n\ntemplate \nconst Point Point::Invalid = Point(numeric_limits::max(),\n numeric_limits::max());\ntemplate \nconst Point Point::Origin = Point(0, 0);\n\ntypedef Point Vector;\ntypedef Point P;\n\ntemplate \nbool inPolygon(const vector

    & p, const P& a) {\n int cnt = 0, n = sz(p);\n rep(i, 0, n - 1) {\n P q = p[i + 1];\n // if (onSegment(p[i], q, a)) return !strict;\n // or: if (segDist(p[i], q, a) <= eps) return !strict;\n cnt ^= ((a.y < p[i].y) - (a.y < q.y)) * a.cross(p[i], q) > 0;\n }\n return cnt;\n}\n\ntemplate \nT polygonArea2(vector>& v) {\n T a = v.back().cross(v[0]);\n rep(i, 0, sz(v) - 1) a += v[i].cross(v[i + 1]);\n return a;\n}\n\nusing Polygon = vector

    ;\n\nstruct Circle {\n Double r;\n P center;\n};\n\nDouble segDist(const P& s, const P& e, const P& p) {\n if (s == e) return (p - s).dist();\n auto d = (e - s).dist2(), t = min(d, max(Double(.0), (p - s).dot(e - s)));\n return ((p - s) * d - (e - s) * t).dist() / d;\n}\n\nDouble pointPolygonDistance(const P& point, const Polygon& polygon) {\n if (inPolygon(polygon, point)) return 0;\n Double res = 1e15;\n for (int i = 0; i + 1 < sz(polygon); ++i) {\n res = min(res, segDist(polygon[i], polygon[i + 1], point));\n }\n return res;\n}\n\nbool circleIntersectsPolygon(const Circle& circle, const Polygon& polygon) {\n return compareDoubles(pointPolygonDistance(circle.center, polygon),\n circle.r) != Relation::GREATER_THAN;\n}\n\nint main() {\n ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n#ifdef Local\n freopen(\"test.in\", \"r\", stdin);\n#else\n#define endl '\\n'\n#endif\n\n int n;\n Double tmp;\n\n cin >> tmp >> tmp >> n;\n vector polys(n);\n vector areas;\n areas.reserve(n);\n for (auto& poly : polys) {\n int v;\n cin >> v;\n poly.resize(v);\n cin >> poly;\n areas.emplace_back(polygonArea2(poly));\n poly.emplace_back(poly[0]);\n\n for (int i = 0; i < v; ++i) {\n assert(poly[i] != poly[i + 1]);\n }\n }\n cout << fixed << setprecision(4);\n int q;\n cin >> q;\n while (q--) {\n Circle circle;\n cin >> circle.center >> circle.r;\n vector res;\n Double sum_areas = 0;\n for (int i = 0; i < n; ++i) {\n if (circleIntersectsPolygon(circle, polys[i])) {\n sum_areas += areas[i];\n res.emplace_back(i);\n }\n }\n cout << sum_areas / 2 << \" \" << sz(res) << \" \" << res << endl;\n }\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a8fc81250d1fa3f566671dbf055e54c2", "src_uid": "a1e94ec65b28e428faac529e602b0fa6", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize(\"Ofast,no-stack-protector,unroll-loops\",\"omit-frame-pointer\",\"inline\")\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,fma,tune=native\")\n#pragma GCC option(\"arch=native\",\"no-zero-upper\") //Enable AVX\n\n#include \n#define db(x) cout << (x) << '\\n';\n#define all(v) (v).begin(),(v).end()\n#define allr(v) (v).rbegin(),(v).rend()\n#define f first\n#define s second\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef double ld;\ntypedef pair pii;\ntypedef pair pdi;\ntypedef pair pdd;\ntypedef pair pdp;\ntypedef pair psi;\ntypedef pair pls;\ntypedef pair pss;\ntypedef pair pip;\ntypedef pair ppp;\ntypedef complex point;\ntypedef vector polygon;\ntypedef pair ppi;\n#define prec(n) cout.precision(n); cout< ds[MAXN];\nld as[MAXN];\n\npoint read()\n{\n ld x,y;\n cin >> x >> y;\n return point(x,y);\n}\n\n#define NEXT(i) (((i) + 1) % n)\n\nstruct line { point p, q; };\nusing segment = line;\n\ndouble dot(point a, point b) { return real(conj(a) * b); }\n\nld cross(point a, point b) { return imag(conj(a) * b); }\n\nint ccw(point a, point b, point c)\n{\n\tb -= a; c -= a;\n\tif (cross(b, c) > 0) return +1; // counter clockwise\n\tif (cross(b, c) < 0) return -1; // clockwise\n\tif (dot(b, c) < 0) return +2; // c--a--b on line\n\tif (dot(b, b) < dot(c, c)) return -2; // a--b--c on line\n\treturn 0;\n}\n\nbool intersectSS(const segment &s, const segment &t)\n{\n\treturn ccw(s.p, s.q, t.p) * ccw(s.p, s.q, t.q) <= 0\n\t\t\t&& ccw(t.p, t.q, s.p) * ccw(t.p, t.q, s.q) <= 0;\n}\n\nld area2(const polygon &P)\n{\n\tld A = 0;\n\tfor (int i = 0, n = P.size(); i < n; ++i)\n\t\tA += cross(P[i], P[NEXT(i)]);\n\treturn A/2;\n}\n\nld min_dis(ld ab,ld ac,ld bc)\n{\n ld cos_abc=(ac*ac-ab*ab-bc*bc)/(-2.0*ab*bc);\n ld cos_acb=(ab*ab-ac*ac-bc*bc)/(-2.0*ac*bc);\n if(min(cos_abc,cos_acb)<=eps)\n return min(ab,ac);\n\n return sqrt(1-cos_abc*cos_abc)*ab;\n}\n\nld give_me_random_ang()\n{\n ld ang=rand()%10000;\n ang/=10000;\n ang*=2*pi;\n return ang;\n}\n\nint32_t main()\n{\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n\n prec(6);\n\n srand(time(0));\n\n ld w,h;\n int n;\n cin >> w >> h >> n;\n for(int i=0;i> szs[i];\n for(int j=0;j> q;\n while(q--)\n {\n ld xx,yy,rr;\n cin >> xx >> yy >> rr;\n point c=point(xx,yy);\n ld r=rr;\n ld a=0;\n vector indexes;\n for(int i=0;i ds2(szs[i]);\n bool ok=0;\n int c1=0;\n int c2=0;\n ld a1=give_me_random_ang();\n// ld a2=give_me_random_ang();\n segment l1={c,c+point(oo*cos(a1),oo*sin(a1))};\n// segment l2={c,c+point(oo*cos(a2),oo*sin(a2))};\n for(int j=0;j\n#define MOD 10000000000000ll\n#define BASE 10000000ll\nlong long pro(long long a,long long b){\n\tlong long a1=a/BASE,a2=a%BASE,\n\t\t\t b1=b/BASE,b2=b%BASE;\n\treturn ((a1*b2+a2*b1)%BASE*BASE+a2*b2)%MOD;\n}\nstruct mat{\n\tlong long a[2][2];\n\tmat(){}\n\tmat(long long a00,long long a01,long long a10,long long a11){\n\t\ta[0][0]=a00;a[0][1]=a01;a[1][0]=a10;a[1][1]=a11;\n\t}\n\tmat operator*(mat B){\n\t\tmat C;\n\t\tfor(int i=0;i<2;i++)\n\t\t\tfor(int j=0;j<2;j++)\n\t\t\t\tC.a[i][j]=(pro(a[i][0],B.a[0][j])+pro(a[i][1],B.a[1][j]))%MOD;\n\t\treturn C;\n\t}\n\tlong long operator()(long long x,long long y){\n\t\treturn (pro(a[1][0],x)+pro(a[1][1],y))%MOD;\n\t}\n};\nmat A[1000010];\nlong long F[15000010]={0,1};\nint main(){\n\tlong long f;scanf(\"%I64d\",&f);\n\tA[0]=mat(1,0,0,1);\n\tA[1]=mat(1,0,0,1);\n\tmat B(1,1,1,0);\n\tfor(int i=15000000;i;i>>=1){\n\t\tif(i%2)A[1]=A[1]*B;\n\t\tB=B*B;\n\t}\n\tfor(int i=2;i<1000000;i++)A[i]=A[1]*A[i-1];\n\tfor(int i=2;i<15000000;i++)F[i]=(F[i-2]+F[i-1])%MOD;\n\tint g=f%BASE;\n\tlong long ans=1ll<<62,a;\n\tfor(int i=0;i<15000000;i++)if(F[i]%BASE==g){\n\t\tlong long tmp=i;\n\t\tfor(int j=0;j<1000000&&tmp\n#include \n#include \n\n#define dvs 100000000LL\n\nusing namespace std;\n\nlong long to_find, res;\nlong long mlt[2][2], tmp[2][2], mr[2][2];\nlong long period[14];\n\nlong long mult(const long long &p1, const long long &p2, const long long &md){\n\tlong long a = p1 / dvs, b = p1 % dvs;\n\tlong long c = p2 / dvs, d = p2 % dvs;\n\tlong long tmp = (((dvs * dvs % md) * a % md) * c % md + (dvs * d % md) * a % md + (dvs * b % md) * c % md + b * d % md) % md;\n\treturn tmp;\t\n}\n\nlong long number(const long long &pos, const long long &p){\n\tmlt = {{1, 1}, {1, 0}};\n\tmr = {{1, 0}, {0, 1}};\n\tlong long cur = pos - 1;\n\tif(!pos)return 0;\n\twhile(cur){\n\t\tif(cur % 2){\n\t\t\tfor(int i = 0; i < 2; ++i)\n\t\t\t\tfor(int j = 0; j < 2; ++j){\n\t\t\t\t\ttmp[i][j] = 0;\n\t\t\t\t\tfor(int k = 0; k < 2; ++k)\n\t\t\t\t\t\ttmp[i][j] = (tmp[i][j] + mult(mr[i][k], mlt[k][j], p)) % p;\n\t\t\t\t}\n\t\t\tfor(int i = 0; i < 2; ++i)\n\t\t\t\tfor(int j = 0; j < 2; ++j)\n\t\t\t\t\tmr[i][j] = tmp[i][j];\n\t\t\t--cur;\n\t\t}\n\t\tcur >>= 1;\n\t\tfor(int i = 0; i < 2; ++i)\n\t\t\tfor(int j = 0; j < 2; ++j){\n\t\t\t\ttmp[i][j] = 0;\n\t\t\t\tfor(int k = 0; k < 2; ++k)\n\t\t\t\t\ttmp[i][j] = (tmp[i][j] + mult(mlt[i][k], mlt[k][j], p)) % p;\n\t\t\t}\n\t\tfor(int i = 0; i < 2; ++i)\n\t\t\tfor(int j = 0; j < 2; ++j)\n\t\t\t\tmlt[i][j] = tmp[i][j];\n\t}\n\treturn(mr[0][0]);\n}\n\nvoid init_per(){\n\tperiod[1] = 60;\n\tperiod[2] = 300;\n\tperiod[3] = 1500;\n\tfor(int i = 4; i < 14; ++i)period[i] = period[i - 1] * 10;\n}\n\ninline void input_data(){cin >> to_find;}\ninline void output_data(){cout << res << \"\\n\";}\n\nint calc(){\n\tres = -1;\n\tlong long cur = 10000000000000LL;\n\t//long long cur = 100;\n\tinit_per();\n\tvector< long long > sm;\n\tvector< long long > tmp;\n\tlong long cur_n = 10, cur_mod = to_find % cur_n;\n\tif(!cur_mod)sm.push_back(0);\n\tif(cur_mod == 1){sm.push_back(1); sm.push_back(2);}\n\tint mp = 1, pr = 1, itr = 1;\n\tfor(int i = 3; i <= 59; ++i){\n\t\tint tmp = (mp + pr) % cur_n;\n\t\tif(cur_mod == tmp)sm.push_back(i);\n\t\tpr = mp; mp = tmp;\n\t}\n\t//cerr << \"go\\n\";\n\twhile(cur_n != cur){\n\t\t//cerr << \"cur_n = \" << cur_n << \"\\n\";\n\t\tlong long prd = period[itr], next_prd = period[++itr];\n\t\t//cerr << prd << \" is prd\\n\" << next_prd << \" is next_prd\\n\";\n\t\tcur_n *= 10;\n\t\tcur_mod = to_find % cur_n;\n\t\ttmp.clear();\n\t\tlong long now = 0;\n\t\twhile(now < next_prd){\n\t\t\tfor(int i = 0; i < sm.size(); ++i){\n\t\t\t\tlong long nmb = number(sm.at(i) + now, cur_n);\n\t\t\t\t//cout << \"nmb = \" << nmb << \"\\n\";\n\t\t\t\tif(nmb == cur_mod)tmp.push_back(sm.at(i) + now);\n\t\t\t}\n\t\t\tnow += prd;\n\t\t\t//cerr << \"now = \" << now << \"\\n\";\n\t\t}\n\t\tif(tmp.empty())return 0;\n\t\tsm = tmp;\n\t}\n\tres = sm.at(0);\n\treturn 0;\n}\n\nint main(){\n\tinput_data();\n\tcalc();\n\toutput_data();\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "06147c22d82914fcedecda5c24ca2223", "src_uid": "cbf786abfceeb8df29732c8a872f7f8a", "difficulty": 2900.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\ntypedef long long LL;\n\nconst int MAX_SEG = 9765625 * 5; \nconst LL M = (LL)1e13;\nconst int MAX_CIR = 39062500 * 5; \n\nLL A[ 4 ], B[ 4 ], C[ 4 ], D[ 4 ], p;\n\nLL mul( LL a, LL b, LL p) {\n\ta %= p; b %= p;\n\tLL ret=0;\n\twhile(b){\n\t\tif(b&1) if((ret+=a)>=p) ret-=p;\n\t\tif((a<<=1) >= p) a-=p;\n\t\tb>>=1;\n\t}\n\treturn ret;\n}\n\nvoid mul( LL A[ ], LL B[ ], LL C[ ] , LL p){\n C[ 0 ] = (mul(A[ 0 ] , B[ 0 ], p) + mul(A[ 1 ] , B[ 2 ],p)) % p;\n C[ 1 ] = (mul(A[ 0 ] , B[ 1 ],p) + mul(A[ 1 ] , B[ 3 ],p)) % p;\n C[ 2 ] = (mul(A[ 2 ] , B[ 0 ],p) + mul(A[ 3 ] , B[ 2 ],p)) % p;\n C[ 3 ] = (mul(A[ 2 ] , B[ 1 ],p) + mul(A[ 3 ] , B[ 3 ],p)) % p;\n A[ 0 ] = C[ 0 ];\n A[ 1 ] = C[ 1 ];\n A[ 2 ] = C[ 2 ];\n A[ 3 ] = C[ 3 ];\n}\n\nLL fibonacci( LL n , LL p ) {\n\tif(!n) return 0;\n\t-- n;\n // A^n\n // ini matrix A\n A[ 0 ] = A[ 1 ] = A[ 2 ] = 1;A[ 3 ] = 0;\n // D is ans\n D[ 0 ] = D[ 3 ] = 1;\n D[ 1 ] = D[ 2 ] = 0;\n // pow\n while( n ) {\n if( n & 0x1) mul( D, A, C, p) ;\n mul( A, A, C, p) ;\n n >>= 1; \n }\n return D[0];\n}\nvector< int > pos ;\n\nvoid pre(){\n\tint a, b, c,rem = p % MAX_SEG;\n\tpos.clear();\n\ta = 0; if(a == rem ) pos.push_back( 0 );\n\tb = 1; if(b == rem ) pos.push_back( 1 );\n\tint i;\n\tfor(i=2;i<=MAX_CIR;++i){\n\t\tc=a+b;\n\t\tif(c>=MAX_SEG) c-=MAX_SEG;\n\t\tif(c == rem) pos.push_back( i );\n\t\ta=b;\n\t\tb=c;\n\t\tif( pos.size() == 4) break ;\n\t}\n\t//puts(\"ok\");\n}\n\nint main(){\n while(1 == scanf(\"%I64d\", &p)) {\n\t\tif(p <= 1) {\n\t\t cout << (int)p << endl;\n\t\t\tcontinue;\n\t\t}\n\t\tpre();\n\t\tLL ans = (LL) 1e17;\n\t\tint i;\n\t\tfor(i=0;i 1e16) ans = - 1;\ncout<\n#include\n#include\n#define lim 10000000000000LL\nusing namespace std;\nstruct matrix\n{ long long num[5][5];\n matrix()\n { memset(num,0,sizeof(num));\n }\n};\nmatrix ft,unit;\nlong long next[1505];\nlong long cur[1505];\nlong long f[1505];\nlong long n;\nlong longRE mul(long long a,long long b)\n{ long long p=(long double)a*b/lim;\n long long r=a*b-lim*p;\n if (r<0)\n r+=lim;\n return r;\n}\nmatrix operator *(matrix& a,matrix& b)\n{ long long i,j,k;\n matrix c;\n for (i=1;i<=2;++i)\n for (j=1;j<=2;++j)\n for (k=1;k<=2;++k)\n { c.num[i][j]+=mul(a.num[i][k],b.num[k][j]);\n c.num[i][j]%=lim;\n }\n return c;\n}\nmatrix qp(matrix b,long long e)\n{ matrix ans,t;\n t=b,ans=unit;\n while (e)\n { if (e&1)\n ans=ans*t;\n t=t*t;\n e>>=1;\n }\n return ans;\n}\nlong long fib(long long n)\n{ matrix f;\n if (n==0)\n return 0;\n if (n==1)\n return 1;\n f=qp(ft,n);\n return f.num[1][2]%lim;\n}\nlong long work()\n{ if (n==0)\n return 0;\n if (n==1)\n return 1;\n long long cnt,cnt1,i,j,k,cycle,t;\n cnt=0;\n f[0]=0,f[1]=1;\n for (i=2;i<1500;++i)\n f[i]=(f[i-1]+f[i-2])%lim;\n for (i=0;i<1500;++i)\n if (f[i]%1000==n%1000)\n cur[++cnt]=i;\n cycle=1500;\n for (i=10000;i<=lim;i*=10,cycle*=10)\n { cnt1=0;\n for (j=0;j<=9;++j)\n for (k=1;k<=cnt;++k)\n if (fib(cycle*j+cur[k])%i==n%i)\n next[++cnt1]=cycle*j+cur[k];\n cnt=cnt1;\n swap(cur,next);\n }\n if (cnt==0)\n return -1;\n return cur[1];\n}\nint main()\n{ scanf(\"%I64d\",&n);\n unit.num[1][1]=unit.num[2][2]=1;\n ft.num[1][2]=ft.num[2][1]=ft.num[2][2]=1;\n printf(\"%I64d\\n\",work());\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f7b234ae8785b6065b474e8eb2ad3d83", "src_uid": "cbf786abfceeb8df29732c8a872f7f8a", "difficulty": 2900.0} {"lang": "GNU C++17", "source_code": "#ifdef APTEST\n#include \"debug_tools/program.h\"\n#endif\n#include \n#include \n#include \n#include \nusing namespace std;\nconst unsigned int maxn = 100, maxm = 5000;\nusing Real = double;\nconstexpr Real eps = 1e-9;\n\nstruct Edge\n{\n unsigned int from, to;\n int c;\n} ed[maxm + 1];\nunsigned int degree[maxn + 1];\nReal equ[maxn + 1][maxn + 1], f[maxn + 1], flw[maxn + 1];\n\nstatic void buildEquation(const unsigned int n, const unsigned int m)\n{\n for (unsigned int i = 0; i < n; ++i)\n equ[i][i] = degree[i];\n for (const Edge* i = ed; i < ed + m; ++i)\n {\n if (i->from != n - 1 && i->from != 0)\n --equ[i->from][i->to];\n if (i->to != n - 1 && i->to != 0)\n --equ[i->to][i->from];\n }\n equ[0][0] = equ[n - 1][n - 1] = 1;\n equ[0][n] = 0;\n equ[n - 1][n] = 1;\n}\ninline bool isZero(const Real v)\n{\n return fabs(v) <= eps;\n}\nvoid gaussian(const unsigned int n)\n{\n for (unsigned int i = 0; i < n; ++i)\n {\n if (isZero(equ[i][i]))\n {\n for (unsigned int j = i + 1; j < n; ++j)\n if (!isZero(equ[j][i]))\n {\n swap_ranges(equ[j], equ[j] + n + 1, equ[i]);\n break;\n }\n }\n if (isZero(equ[i][i]))\n continue;\n for (unsigned int j = i + 1; j < n; ++j)\n {\n if (isZero(equ[j][i]))\n continue;\n const Real rat = equ[j][i] / equ[i][i];\n for (unsigned int k = i; k <= n; ++k)\n equ[j][k] -= rat * equ[i][k];\n }\n }\n for (unsigned int j = n - 1; j > 0; --j)\n {\n if (isZero(equ[j][j]))\n continue;\n equ[j][n] /= equ[j][j];\n f[j] = equ[j][n];\n for (unsigned int i = 0; i < j; ++i)\n equ[i][n] -= equ[i][j] * equ[j][n];\n }\n}\nstatic Real buildSolution(const unsigned int n, const unsigned int m)\n{\n Real miv = numeric_limits::max();\n for (const Edge* i = ed; i < ed + m; ++i)\n if (!isZero(f[i->to] - f[i->from]))\n miv = min(miv, fabs(i->c / (f[i->to] - f[i->from])));\n for (unsigned int i = 0; i < n; ++i)\n f[i] *= miv;\n Real ret = 0;\n for (const Edge* i = ed; i < ed + m; ++i)\n {\n if (i->to == n - 1 && f[i->from] < f[n - 1])\n ret += f[n - 1] - f[i->from];\n else if (i->from == n - 1 && f[i->to] < f[n - 1])\n ret += f[n - 1] - f[i->to];\n }\n return ret;\n}\nint main()\n{\n#ifndef APTEST\n ios_base::sync_with_stdio(false);\n#endif\n\n feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW);\n\n unsigned int n, m;\n cin >> n >> m;\n for (Edge* i = ed; i < ed + m; ++i)\n {\n cin >> i->from >> i->to >> i->c;\n --(i->from);\n --(i->to);\n ++degree[i->from];\n ++degree[i->to];\n }\n buildEquation(n, m);\n gaussian(n);\n ios_base::sync_with_stdio(true);\n printf(\"%.5lf\\n\", buildSolution(n, m));\n for (const Edge* i = ed; i < ed + m; ++i)\n printf(\"%.5lf\\n\", f[i->to] - f[i->from]);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a82b3fc9ce22ff9b10921d16ad1a3de7", "src_uid": "93fa614f174816d241c0fa302c6476e2", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint a[5005],b[5005],c[5005];\ndouble m[102][102];\n\nint main() {\n// freopen(\"input.txt\",\"r\", stdin);\n// freopen(\"output.txt\", \"w\", stdout);\n int n,e,deg=0;\n scanf(\"%d%d\",&n,&e);\n for(int i=0;ieps) {\n ind=j;\n break;\n }\n if (ind==-1) {\n// puts(\"fail\\n\");\n// return 0;\n continue;\n }\n for(int j=0;j=0;--i) {\n for(int j=i-1;j>=0;--j) {\n double coef=-m[j][i+1];\n for(int t=i+1;t0)\n r=min(r,c[i]/((a[i] ? m[a[i]-1][n-1] : 0)-(b[i] ? m[b[i]-1][n-1] : 0)));\n else\n l=max(l,c[i]/((a[i] ? m[a[i]-1][n-1] : 0)-(b[i] ? m[b[i]-1][n-1] : 0)));\n if ((a[i] ? m[a[i]-1][n-1] : 0)-(b[i] ? m[b[i]-1][n-1] : 0)<0)\n r=min(r,-c[i]/((a[i] ? m[a[i]-1][n-1] : 0)-(b[i] ? m[b[i]-1][n-1] : 0)));\n else\n l=max(l,-c[i]/((a[i] ? m[a[i]-1][n-1] : 0)-(b[i] ? m[b[i]-1][n-1] : 0)));\n// l=max(l,c[i]/(m[a[i]][n-1]-m[b[i]][n-1]));\n }\n if (n==100&&e=197)\n cout << l << \" \" << r << endl;\n if (l-eps>r) r=0;\n double ans=0;\n for(int i=0;i\nusing namespace std;\n\nconst int maxn=109,maxm=10009;\nconst double EPS=1e-8;\n//\u9ad8\u65af\u6d88\u5143\uff0c\u7cfb\u6570\u77e9\u9635\u4e3aa[i][j],i=1\u2026n,j=1\u2026n,\u5e38\u6570\u4e3aa[i][n+1],i=1\u2026n\uff0c\u7b54\u6848\u5b58\u5728x[i]\ndouble x[maxn], a[maxn][maxn];\nvoid guass(int n) {\n for(int i=1;i<=n;i++) {\n int j = -1;\n for(int k=i;k<=n;k++) {\n if (abs(a[k][i])>EPS) {\n j=k; break;\n }\n }\n if (j==-1) continue;\n if (i!=j) for(int k=i;k<=n+1;k++) swap(a[i][k], a[j][k]);\n for(int k=i+1;k<=n;k++) {\n double x = a[i][i], y = a[k][i];\n if (abs(y) < EPS) continue;\n for(int p=i;p<=n+1;p++) {\n a[k][p] = a[i][p] - x / y * a[k][p];\n }\n }\n }\n for(int i=n;i>=1;i--) {\n double tmp = 0;\n for(int j=i+1;j<=n;j++) {\n tmp += a[i][j] * x[j];\n }\n tmp = a[i][n+1] - tmp;\n if (abs(a[i][i])>EPS)\n x[i] = tmp / a[i][i];\n else {\n\n }\n }\n}\n\nint u[maxm],v[maxm];double val[maxm];\n\nint main(){\n int n,m;scanf(\"%d%d\",&n,&m);\n for(int i=1;i<=m;i++){\n int &U=u[i],&V=v[i];\n scanf(\"%d%d%lf\",&U,&V,val+i);\n if(U1)a[U][V]--,a[U][U]++;\n if(V1)a[V][U]--,a[V][V]++;\n }\n a[1][1]=a[n][n]=1;a[1][n+1]=1;a[n][n+1]=2;\n\n /*for(int i=1;i<=n;i++){\n for(int j=1;j<=n+1;j++){\n printf(\"%3.0f \",a[i][j]);\n }\n printf(\"\\n\");\n }\n printf(\"\\n\");*/\n\n guass(n);\n\n /*for(int i=1;i<=n;i++){\n for(int j=1;j<=n+1;j++){\n printf(\"%3.0f \",a[i][j]);\n }\n printf(\"\\n\");\n }\n\n for(int i=1;i<=n;i++){\n printf(\"%d :%.4f\\n\",i,a[i][n+1]);\n }*/\n\n double mul=1e18;\n for(int i=1;i<=m;i++){\n int &U=u[i],&V=v[i];\n mul=min(mul,val[i]/fabs(x[U]-x[V]));\n }\n if(n==100&m==9)printf(\"mul=%.4f\\n\",mul)\n double ans=0;\n for(int i=1;i<=m;i++){\n int &U=u[i],&V=v[i];\n val[i]=-(x[U]-x[V])*mul;\n if(U==1||V==1)\n ans+=fabs(val[i]);\n }\n printf(\"%.10f\\n\",ans);\n for(int i=1;i<=m;i++){\n printf(\"%.10f\\n\",val[i]);\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8af1f12f6ecc7b64ebac98f369d307e1", "src_uid": "93fa614f174816d241c0fa302c6476e2", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define N 110\n#define K 5100\nusing namespace std;\nlong double m[N][N], x[N];\nint a[N][N], u[N], y[N], s[K], e[K];\nvector v[N], d[N];\nvoid dfs(int i)\n{\n int j;\n u[i]=1;\n for(j=0; jfabs(m[i][j])?t:j, t++);\n if(fabs(m[i][j])<1E-9) break;\n y[i]=j;\n for(k=0; k1E-9 && d[i][j]/z\nusing namespace std;\n\nint main()\n{\n\tint a, h, w;\n\tcin >> a >> h >> w;\n\n\tif (a <= 1000000)\n\t{\n\t\tint x = max(1, (w - a) / (2 * a)), y = max(1, (h - a) / (2 * a));\n\t\tdouble ans = 1e100;\n\t\twhile (w >= a * x && h >= a * y)\n\t\t{\n\t\t\tdouble d1 = double(w - a * x) / (x + 1);\n\t\t\tdouble d2 = double(h - a * y) / (y + 1);\n\n\t\t\tif ((w - a * x) * 1ll * (y + 1) == (h - a * y) * 1ll * (x + 1))\n\t\t\t{\n\t\t\t\tans = min(ans, d1);\n\t\t\t\t++x; ++y;\n\t\t\t}\n\t\t\telse if (d1 > d2) ++x;\n\t\t\telse ++y;\n\t\t}\n\n\t\tif (ans == 1e100) printf(\"-1\\n\");\n\t\telse printf(\"%.9f\\n\", ans);\n\t}\n\telse\n\t{\n\t\tdouble ans = 1e100;\n\t\tfor (int x = 1; w >= a * x; x++)\n\t\t{\n\t\t\tfor (int y = 1; h >= a * y; y++)\n\t\t\t{\n\t\t\t\tif ((w - a * x) * 1ll * (y + 1) == (h - a * y) * 1ll * (x + 1)) ans = min(ans, double(w - a * x) / (x + 1));\n\t\t\t}\n\t\t}\n\n\t\tif (ans == 1e100) printf(\"-1\\n\");\n\t\telse printf(\"%.9f\\n\", ans);\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4ba39b0935ea8657f7a2221088530956", "src_uid": "7fbefd3eb1aad6865adcfac394f0a7e6", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\n#define ll long long\n\nconst double eps = (double)(1e-18);\nconst double inf = (double)(1e9);\n\nll a, h, w;\n\nint main(){\n\tcin >> a >> w >> h;\n\tif(w % a == 0 && h % a == 0){\n\t\tcout << 0.0;\n\t\treturn 0;\n\t}\n\tdouble ans = inf;\n\tif(a <= 10){\n\t\tfor(int i = 0; i <= a * 1000 * 1000; ++i){\n\t\t\tdouble x = i * 1. / (1000 * 1000);\n\t\t\tdouble c1 = (h - x) * 1./ (a + x); \n\t\t\tdouble c = (w - x) * 1./ (a + x); \n\t\t\tif(h < x || w < x) continue;\n\t\t\tint cnt1 = round((h - x) * 1./ (a + x));\n\t\t\tint cnt = round((w - x) * 1./ (a + x));\n\t\t\tif(h < a * cnt1 || w < a * cnt){\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif(!cnt || !cnt1) continue;\t\n\t\t\tdouble x1 = (h - a * cnt1) * 1. / (cnt1 + 1);\n\t\t\tx = (w - a * cnt) * 1. / (cnt + 1);\n\t\t\tif(fabs(x - x1) <= eps){\n\t\t\t\tans = min(ans, x);\n\t\t\t}\n\t\t}\n\t\tif(fabs(ans - inf) <= eps){\n\t\t\tans = -1;\n\t\t}\n\t\tprintf(\"%0.6f\", ans);\n\t\treturn 0;\n\t}\n\tfor(int cnt = w / a; cnt >= 1; --cnt){\n\t\tdouble x = (w - a * cnt) * 1. / (cnt + 1);\n\t\tll cnt1 = round((h - x) * 1./ (a + x));\n\t\tdouble x1 = (h - a * cnt1) * 1. / (cnt1 + 1);\n\t\tif(fabs(x - x1) <= double(1e-6)){\n\t\t\tans = min(ans, x);\n\t\t}\n\t}\n\tif(fabs(ans - inf) <= eps){\n\t\tans = -1;\n\t}\n\tprintf(\"%0.6f\", ans);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8780a20c6b0a1bed3a55832af5a93ce9", "src_uid": "7fbefd3eb1aad6865adcfac394f0a7e6", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define f first\n#define s second\n#define ll long long\n#define ull unsigned long long\n#define mp make_pair\n#define pb push_back\n#define vi vector \n#define ld long double\n#define pii pair\n#define y1 sda\nusing namespace std; \nconst int N = int(3e5), mod = int(1e9) + 7;\n\nint a,h,w; \n\nll phi(int n){\n\tll m = n;\n\tfor(int i = 2;1ll * i * i <= n; i++){\n\t\tif(n%i == 0){\n\t\t\twhile(n%i == 0){\n\t\t\t\tn /= i;\n\t\t\t}\n\t\t\tm -= m/i;\n\t\t}\n\t}\n\tif (n > 1) m -= m/n;\n\treturn m;\n}\n\nll modpow(ll a,ll b,ll c){\n\tll res = 1;\n\twhile(b){\n\t\tif(b & 1) res = res * a % c;\n\t\ta = a * a % c;\n\t\tb >>= 1;\n\t}\n\treturn res % c;\n}\n\nint main () {\n\tcin >> a >> h >> w;\n\tint mx = int(1e9);\n\tint res = h - w;\n\tint A = w + a;\n\tres = (res + 1ll * A * mx) % A;\n\tint B = (a + h) % A;\n\tmx = w / a;\n\tint ans = -1;\n\tfor(int i = 1;i <= mx;i++){\n\t\tres += B;\n\t\tif(res >= A) {\n\t\t\tres -= A;\n\t\t}\n\t\tif(res == 0) ans = i;\n\t}\n\tif(ans == -1) puts(\"-1\");\n\telse\n\tprintf(\"%.12lf\", (w - ans * a + 0.0) / (ans + 1));\n\nreturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2c77a37d6c2a76239822129ea6048ad2", "src_uid": "7fbefd3eb1aad6865adcfac394f0a7e6", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\n#define ll long long\n\nconst double eps = (double)(1e-18);\nconst double inf = (double)(1e9);\n\nll a, h, w;\n\nint main(){\n\tcin >> a >> w >> h;\n\tif(w % a == 0 && h % a == 0){\n\t\tcout << 0.0;\n\t\treturn 0;\n\t}\n\tdouble ans = inf;\n\tfor(int cnt = w / a; w <= 2 * a * cnt + a; --cnt){\n\t\tdouble x = (w - a * cnt) * 1. / (cnt + 1);\n\t\tint cnt1 = round((h - x) * 1./ (a + x));\n\t\tdouble x1 = (h - a * cnt1) * 1. / (cnt1 + 1);\n\t\tif(fabs(x - x1) <= eps){\n\t\t\tans = min(ans, x);\n\t\t\tprintf(\"%0.9f\", x);\n\t\t\treturn 0;\n\t\t}\n\t}\n\tif(fabs(ans - inf) <= eps){\n\t\tans = -1;\n\t}\n\tprintf(\"%0.9f\", ans);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b4ad1f1c24fa51c090a951fc16ca1465", "src_uid": "7fbefd3eb1aad6865adcfac394f0a7e6", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nint dig(int n)\n{\n int sum = 0;\n while(n)\n {\n sum++;\n n/=10;\n }\n return sum;\n}\nint main()\n{\n int T;\n cin>>T;\n int ar[6];\n int p;\n for(int i=0;i<6;i++)\n {\n cin>>p;\n ar[i] = p;\n }\n int q;\n cin>>q;\n int n;\n cin>>n;\n int dp[T];\n int sum=0;\n sum+=9;\n if(T>9)\n dp[0] = 9;\n for(int i=1;iT)\n {\n int dif = sum-T;\n for(int j=1;j>=0;j--)\n if(dif<=dp[j])\n {\n dp[j]-=diff;\n sum-=diff;\n break;\n }\n }\n }\n int fortune = 0;\n for(int i=0;i\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\ntypedef long long ll;\n\nconst int maxn = 1000000;\n\nint k,m,num,cntf,cntg;\nint di[maxn];\nll n,F[10],f[21][maxn],g[7][maxn],v[1000],w[1000],vg[1000],wg[1000];\n\nint qsm(int i,int po){\n\tint res = 1;\n\twhile(po){\n\t\tif(po&1) res *= i;\n\t\tpo >>= 1;\n\t\ti *= i;\n\t}\n\treturn res;\n}\n\nll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }\n\nint main(){\n\tnum = 0;\n\tk = read();\n\tint K = k-1;\n\tint t = 0;\n\twhile(K - (1< 0){ // ????? \n\t\tdi[++num] = 1<\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\ntypedef long long ll;\n\nconst int maxn = 1000000;\n\nint k,m,num,cntf,cntg;\nint di[maxn];\nll n,F[10],f[21][maxn],g[7][maxn],v[1000],w[1000],vg[1000],wg[1000];\n\nint qsm(int i,int po){\n\tint res = 1;\n\twhile(po){\n\t\tif(po&1) res *= i;\n\t\tpo >>= 1;\n\t\ti *= i;\n\t}\n\treturn res;\n}\n\nll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }\n\nint main(){\n\tnum = 0;\n\tk = read();\n\tint K = k-1;\n\tint t = 0;\n\twhile(K - (1< 0){ // ????? \n\t\tdi[++num] = 1<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n//#include \"dmSegmentTree.hpp\"\n \n#include \n#include \n#include \n \n \n \n \nnamespace dmDataStructure\n{\n \n\tstruct dmMin\n\t{\n \n\t\ttemplate\n\t\tT operator()(const T a, const T b)\n\t\t{\n\t\t\treturn std::min(a, b);\n\t\t}\n\t};\n \n\tstruct dmMax\n\t{\n\t\ttemplate\n\t\tT operator()(const T a, const T b)\n\t\t{\n\t\t\treturn std::max(a, b);\n\t\t}\n\t};\n \n\tstruct dmMinPaired\n\t{\n\t\ttemplate\n\t\tstd::pair operator()(const std::pair& a, const std::pair& b)\n\t\t{\n\t\t\tif (a.first < b.first)\n\t\t\t\treturn a;\n\t\t\tif (a.first > b.first)\n\t\t\t\treturn b;\n\t\t\treturn std::make_pair(a.first, b.second + a.second);\n\t\t}\n\t};\n \n\tstruct dmMaxPaired\n\t{\n\t\ttemplate\n\t\tstd::pair operator()(const std::pair& a, const std::pair& b)\n\t\t{\n\t\t\tif (a.first > b.first)\n\t\t\t\treturn a;\n\t\t\tif (a.first < b.first)\n\t\t\t\treturn b;\n\t\t\treturn std::make_pair(a.first, b.second + a.second);\n\t\t}\n\t};\n \n\tint GetBitNumber(std::int64_t n)\n\t{\n\t\tif (n == 0)\n\t\t\treturn 0;\n \n\t\tint msb = 0;\n\t\tn = n / 2;\n\t\twhile (n != 0) {\n\t\t\tn = n / 2;\n\t\t\tmsb++;\n\t\t}\n\t\treturn msb;\n\t}\n \n\ttemplate \n\tT1 GetValue(const std::pair& pr)\n\t{\n\t\treturn pr.first;\n\t}\n \n\ttemplate \n\tT GetValue(const T& v)\n\t{\n\t\treturn v;\n\t}\n \n\ttemplate \n\tvoid SetValue(std::pair& src, const T3 val, const std::int64_t number = 0)\n\t{\n\t\tsrc.first = val;\n\t\tif (number == 0)\n\t\t\treturn;\n\t\tsrc.second = number;\n\t}\n \n\ttemplate \n\tvoid SetValue(T1& src, const T2 value, const std::int64_t number = 0)\n\t{\n\t\tnumber;\n\t\tsrc = value;\n\t}\n \n\ttemplate \n\ttypename std::enable_if::value, T>::type MakeType(const T1& src)\n\t{\n\t\treturn T(src);\n\t}\n\ttemplate \n\ttypename std::enable_if::value, T>::type MakeType(const T1& src)\n\t{\n\t\treturn T(src, 1);\n\t}\n \n\ttemplate <\n\t\tclass T,\n\t\tconst T zeroValue,\n\t\tclass F,\n\t\tconst bool isLazy = false,\n\t\tconst bool isIncrement = true,\n\t\tconst bool usePair = false>\n\t\tclass dmSegmentTree\n\t{\n\tpublic:\n\t\ttypedef typename std::conditional, T>::type DataType;\n\t\tdmSegmentTree(const size_t n)\n\t\t\t: m_objectCount(n), m_tree(n * 2, zeroValue), m_lazyData(), m_isSum(false)\n\t\t{\n\t\t\tif (isLazy)\n\t\t\t{\n\t\t\t\tm_lazyData.resize(n, 0);\n\t\t\t\tm_modified.resize(n, false);\n\t\t\t}\n\t\t\tm_isSum = GetValue(DataType()) == zeroValue;\n\t\t\tm_height = GetBitNumber(n) + 1;\n\t\t}\n \n\t\tdmSegmentTree(const std::vector& objects)\n\t\t\t: m_objectCount(objects.size()), m_tree(objects.size() * 2, MakeType(zeroValue)), m_lazyData(), m_isSum(false)\n\t\t{\n\t\t\tif (isLazy)\n\t\t\t{\n\t\t\t\tm_lazyData.resize(objects.size(), MakeType(0));\n\t\t\t\tm_modified.resize(objects.size(), false);\n\t\t\t}\n\t\t\tm_isSum = GetValue(DataType()) == zeroValue;\n\t\t\tm_height = GetBitNumber(objects.size()) + 1;\n\t\t\tBuild(objects);\n\t\t}\n \n\t\tvoid Build(const std::vector& objects)\n\t\t{\n\t\t\tfor (size_t i = objects.size(); i < m_tree.size(); ++i)\n\t\t\t{\n\t\t\t\tm_tree[i] = MakeType(objects[i - objects.size()]);\n\t\t\t}\n\t\t\tfor (std::int64_t i = objects.size() - 1; i > 0; --i)\n\t\t\t{\n\t\t\t\tm_tree[i] = m_f(m_tree[i * 2], m_tree[i * 2 + 1]);\n\t\t\t}\n\t\t}\n \n\t\tvoid CalcLazy(const std::int64_t idx, const std::int64_t elementCount)\n\t\t{\n\t\t\tif (!m_modified[idx])\n\t\t\t{\n\t\t\t\tm_tree[idx] = m_f(m_tree[idx * 2], m_tree[idx * 2 + 1]);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (isIncrement)\n\t\t\t\t{\n\t\t\t\t\tif (m_isSum)\n\t\t\t\t\t{\n \n\t\t\t\t\t\tm_tree[idx] = m_f(m_tree[idx * 2], m_tree[idx * 2 + 1]);\n\t\t\t\t\t\tSetValue(m_tree[idx], GetValue(m_tree[idx]) + GetValue(m_lazyData[idx]) * elementCount);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tm_tree[idx] = m_f(m_tree[idx * 2], m_tree[idx * 2 + 1]);\n\t\t\t\t\t\tSetValue(m_tree[idx], GetValue(m_tree[idx]) + GetValue(m_lazyData[idx]));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif (m_isSum)\n\t\t\t\t\t{\n\t\t\t\t\t\tSetValue(m_tree[idx], GetValue(m_lazyData[idx]) * elementCount, elementCount);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tSetValue(m_tree[idx], GetValue(m_lazyData[idx]), elementCount);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n \n\t\tvoid ApplyLazy(const std::int64_t idx,\n\t\t\tconst DataType value, const std::int64_t elementCount)\n\t\t{\n\t\t\tif (isIncrement)\n\t\t\t{\n\t\t\t\tif (m_isSum)\n\t\t\t\t{\n\t\t\t\t\tSetValue(m_tree[idx], GetValue(m_tree[idx]) + GetValue(value) * elementCount);\n \n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tSetValue(m_tree[idx], GetValue(m_tree[idx]) + GetValue(value));\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (m_isSum)\n\t\t\t\t{\n\t\t\t\t\tSetValue(m_tree[idx], GetValue(value) * elementCount);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tSetValue(m_tree[idx], GetValue(value), elementCount);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (idx < m_objectCount)\n\t\t\t{\n\t\t\t\tif (isIncrement)\n\t\t\t\t{\n\t\t\t\t\tSetValue(m_lazyData[idx], GetValue(m_lazyData[idx]) + GetValue(value));\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tSetValue(m_lazyData[idx], GetValue(value), elementCount);\n\t\t\t\t}\n\t\t\t\tm_modified[idx] = true;\n\t\t\t}\n\t\t}\n \n\t\tvoid BuildLazy(const std::int64_t left, const std::int64_t right) {\n\t\t\tstd::int64_t elementCount = 2;\n \n\t\t\tstd::int64_t l = left + m_objectCount;\n\t\t\tstd::int64_t r = right + m_objectCount;\n\t\t\tfor (; l > 1; elementCount *= 2)\n\t\t\t{\n\t\t\t\tl = l / 2;\n\t\t\t\tr = r / 2;\n\t\t\t\tfor (std::int64_t i = r; i >= l; --i)\n\t\t\t\t{\n\t\t\t\t\tCalcLazy(i, elementCount);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// 0 1 2 1 3 5 1 2 3 4 5 6\n\t\tvoid PushLazy(const std::int64_t left, const std::int64_t right)\n\t\t{\n\t\t\tstd::int64_t layer = m_height;\n\t\t\tstd::int64_t elementCount = 1 << (m_height - 1);\n\t\t\tstd::int64_t l = left + m_objectCount;\n\t\t\tstd::int64_t r = right + m_objectCount;\n\t\t\tfor (; layer > 0; --layer, elementCount /= 2)\n\t\t\t{\n\t\t\t\tfor (std::int64_t i = l >> layer; i <= r >> layer; ++i)\n\t\t\t\t{\n\t\t\t\t\tif (m_modified[i])\n\t\t\t\t\t{\n\t\t\t\t\t\tApplyLazy(i * 2, m_lazyData[i], elementCount);\n\t\t\t\t\t\tApplyLazy(i * 2 + 1, m_lazyData[i], elementCount);\n\t\t\t\t\t\tSetValue(m_lazyData[i], 0);\n\t\t\t\t\t\tm_modified[i] = false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n \n\t\tvoid Modify(const int idx, const DataType& value)\n\t\t{\n\t\t\tif (isLazy)\n\t\t\t\tthrow std::exception(\"function available only in usual mod\");\n\t\t\tstd::int64_t cur = m_objectCount + idx;\n\t\t\tif (isIncrement)\n\t\t\t{\n\t\t\t\tm_tree[cur] += value;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tm_tree[cur] = value;\n\t\t\t}\n \n\t\t\tstd::int64_t parent = cur / 2;\n\t\t\twhile (parent != 0)\n\t\t\t{\n\t\t\t\tconst std::int64_t nextToCur = cur % 2 == 0 ? cur + 1 : cur - 1;\n\t\t\t\tm_tree[parent] = m_f(m_tree[cur], m_tree[nextToCur]);\n\t\t\t\tcur = parent;\n\t\t\t\tparent = cur / 2;\n\t\t\t}\n\t\t}\n \n \n\t\tvoid ModifyLazy(\n\t\t\tconst std::int64_t left, const std::int64_t right, const T& value)\n\t\t{\n\t\t\tif (!isLazy)\n\t\t\t\tthrow std::exception(\"function available only in lazy mod\");\n\t\t\tPushLazy(left, left);\n\t\t\tPushLazy(right, right);\n\t\t\tstd::int64_t l0 = left, r0 = right, k = 1;\n \n\t\t\tstd::int64_t l = m_objectCount + left;\n\t\t\tstd::int64_t r = m_objectCount + right;\n \n\t\t\tfor (; l <= r; l = (l + 1) / 2, r = (r - 1) / 2)\n\t\t\t{\n\t\t\t\tif (l % 2 != 0)\n\t\t\t\t{\n\t\t\t\t\tApplyLazy(l, MakeType(value), k);\n\t\t\t\t}\n\t\t\t\tif (r % 2 == 0)\n\t\t\t\t{\n\t\t\t\t\tApplyLazy(r, MakeType(value), k);\n\t\t\t\t}\n\t\t\t\tk = k * 2;\n\t\t\t}\n\t\t\tBuildLazy(l0, l0);\n\t\t\tBuildLazy(r0, r0);\n\t\t}\n \n\t\tDataType Query(const std::int64_t left, const std::int64_t right)\n\t\t{\n\t\t\tif (isLazy)\n\t\t\t\tthrow std::exception(\"function available only in usual mod\");\n\t\t\tstd::int64_t l = left + m_objectCount;\n\t\t\tstd::int64_t r = right + m_objectCount;\n\t\t\tDataType resL = MakeType(zeroValue);\n\t\t\tDataType resR = MakeType(zeroValue);\n\t\t\tif (left == right)\n\t\t\t\treturn m_tree[l];\n\t\t\tfor (; l <= r; l = (l + 1) / 2, r = (r - 1) / 2)\n\t\t\t{\n\t\t\t\tif (l % 2 != 0)\n\t\t\t\t{\n\t\t\t\t\tresL = m_f(resL, m_tree[l]);\n\t\t\t\t}\n\t\t\t\tif (r % 2 == 0)\n\t\t\t\t{\n\t\t\t\t\tresR = m_f(m_tree[r], resR);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn m_f(resL, resR);\n\t\t}\n \n\t\tDataType QueryLazy(const std::int64_t left, const std::int64_t right)\n\t\t{\n\t\t\tif (!isLazy)\n\t\t\t\tthrow std::exception(\"function available only in lazy mod\");\n\t\t\tPushLazy(left, left);\n\t\t\tPushLazy(right, right);\n\t\t\tstd::int64_t l = left + m_objectCount;\n\t\t\tstd::int64_t r = right + m_objectCount;\n\t\t\tDataType resL = MakeType(zeroValue);\n\t\t\tDataType resR = MakeType(zeroValue);\n\t\t\tif (left == right)\n\t\t\t\treturn m_tree[l];\n\t\t\tfor (; l <= r; l = (l + 1) / 2, r = (r - 1) / 2)\n\t\t\t{\n\t\t\t\tif (l % 2 != 0)\n\t\t\t\t{\n\t\t\t\t\tresL = m_f(resL, m_tree[l]);\n\t\t\t\t}\n\t\t\t\tif (r % 2 == 0)\n\t\t\t\t{\n\t\t\t\t\tresR = m_f(m_tree[r], resR);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn m_f(resL, resR);\n\t\t}\n \n\tprivate:\n\t\tstd::vector m_tree;\n\t\tstd::vector m_lazyData;\n\t\tstd::vector m_modified;\n\t\tF m_f;\n\t\tbool m_isSum;\n\t\tstd::int64_t m_height;\n\t\tstd::int64_t m_objectCount;\n\t};\n \n}\n \n \nusing namespace std;\n \n#define ALL(x) (x).begin(),(x).end()\n#define SZ(x) ((int)(x).size())\n#define rep(i,a,b) for(int64_t i=(a);i<=(b);++i)\n#define per(i,a,b) for(int64_t i=(a);i>=(b);--i)\n#define forn(i, n) for(int64_t i = 0; i < int64_t(n); i++)\n \ntemplate \nvector ReadVec(const int count, const T inc = 0)\n{\n\tvector res(count);\n\tforn(i, count)\n\t{\n\t\tstd::cin >> res[i];\n\t\tres[i] += inc;\n\t}\n\treturn res;\n}\n \ntemplate \nvoid PrintVecOneLine(const vector& src)\n{\n\tforn(i, src.size())\n\t{\n\t\tstd::cout << src[i];\n\t\tif (i + 1 != src.size())\n\t\t\tstd::cout << \" \";\n\t}\n\tstd::cout << \"\\n\";\n}\n \ntemplate \nvoid PrintVecManyLine(const vector& src)\n{\n\tforn(i, src.size())\n\t{\n\t\tstd::cout << src[i] << \"\\n\";\n\t}\n}\n\n \nint main()\n{\n#ifdef HOME\n\tfreopen(\"input.txt\", \"r\", stdin);\n#else\n\tstd::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);\n\tstd::cout.setf(std::ios::fixed); std::cout.precision(20);\n#endif\n\tint k;\n\tcin >> k;\n\tstd::array F;\n\tfor (auto& v : F)\n\t{\n\t\tcin >> v;\n\t}\n\tstd::array, 6> dp;\n\t{\n\t\tfor (int i = 0; i < 6; ++i)\n\t\t{\n\t\t\tdp[i] = std::vector(1000000);\n\t\t}\n\t}\n\tint64_t pow = 100000;\n\t/*\n\t\t0 0 9\n\t\t0 0 9\n\t\t0 0 9\n\t\t0 3 6\n\n\t*/\n\tfor (int64_t pos = 0; pos < 6; ++pos)\n\t{\n\t\tfor (int64_t value = 0; value < 100; value += pow)\n\t\t{\n\t\t\tint64_t idx = 0;\n\t\t\tfor (int64_t sum = 0; sum <= 9 * (k - 1); sum += 3, ++idx)\n\t\t\t{\n\t\t\t\tfor (int64_t digit = 0; digit < 10; ++digit)\n\t\t\t\t{\n\t\t\t\t\tint64_t curAdd = sum * pow + digit * pow;\n\n\t\t\t\t\tif(curAdd > value || (value - curAdd) % (pow * 10) != 0 )\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tconst int64_t idxToAdd = digit % 3 != 0 && digit != 0 ? 0 : (digit / 3);\n\t\t\t\t\tdp[pos][value] = max(dp[pos][value], (pos == 0 ? ((idx + idxToAdd)* F[5 - pos]) : (dp[pos - 1][value - curAdd] + (idx + idxToAdd) * F[5 - pos])));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tpow /= 10;\n\t}\n\tint t;\n\tcin >> t;\n\twhile (t--)\n\t{\n\t\tint total;\n\t\tcin >> total;\n\t\tcout << dp[5][total]<< endl;\n\t}\n\t\n\t\n\t\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "57d00b24b2fa16767c3c7be892571dcf", "src_uid": "92bcbac3f167a44c235e99afc4de20d2", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "aklasdlklsdkalksadlksadas\nslkKLaklallkalksalklkasklaslkas\n ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7f38a7b35355dd7dcf71479a1cb296e1", "src_uid": "fc238a230bb556c9ffecf343989b988a", "difficulty": 3100.0} {"lang": "GNU C++14", "source_code": "#include\n#define db double\n#define fi first\n#define se second\nusing namespace std;\n\nconst int N=75005;\nconst db eps=0.05;\nbool zero(db x){\n\treturn x>-eps&&x \n#define pii pair\npdi A[N],B[N];\nvector v;\nmap mp;\nint n,n1,n2;\nint fa[N],fb[N];\n\nvoid check(int xa,int xb,int ya,int yb){\n\tP r=(a[xb]-a[xa])/(b[yb]-b[ya]);\n\tP c=a[xa]-b[ya]*r;\n\tint cnt1=0,cnt0=0;\n\tfor (int i=1;i<=n2;i++){\n\t\tP p=b[i]*r+c;\n\t\tif (mp.find(p)!=mp.end()) cnt1++;\n\t\telse cnt0++;\n\t\tif (cnt0+0.9*n>n2) break;\n\t\tif (1.0*cnt1/(cnt0+cnt1)<0.1&&cnt0+cnt1>25) break;\n\t}\n\tif (cnt1<0.9*n) return;\n\tfor (int j=1;j<=n2;j++){\n\t\tP cur=b[j]*r+c;\n\t\tif (mp.find(cur)!=mp.end()){\n\t\t\tint nxt=mp[cur];\n\t\t\tif (v.size()\nusing namespace std;\n\nint main() {\n\t// your code goes here\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "27fc26b3eb6a1465625cd43c76c4bb3a", "src_uid": "fc238a230bb556c9ffecf343989b988a", "difficulty": 3100.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define pb push_back\n#define mp make_pair\ntypedef pair pii;\ntypedef long long ll;\ntypedef long double ld;\ntypedef vector vi;\n#define fi first\n#define se second\n#define fe first\n#define FO(x) {freopen(#x\".in\",\"r\",stdin);freopen(#x\".out\",\"w\",stdout);}\n#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}\n#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}\n#define es(x,e) (int e=fst[x];e;e=nxt[e])\n#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])\ntypedef pair pnt;\n#define SZ 1234567\nint n,n1,n2; pnt p1[SZ],p2[SZ];\npair ps[5050666]; int pn=0;\ninline ld dis(pnt x) {return x.fi*x.fi+x.se*x.se;}\ninline ld ang(pnt x) {return atan2l(x.se,x.fi);}\ninline pnt operator - (pnt a,pnt b) {return pnt(a.fi-b.fi,a.se-b.se);}\ninline pnt operator + (pnt a,pnt b) {return pnt(a.fi+b.fi,a.se+b.se);}\ninline ld dis(pnt x,pnt y) {return dis(x-y);}\nld co,si;\n/*\npnt rot(pnt g,ld t) {return pnt\n(g.fi*cos(t)-g.se*sin(t),\ng.fi*sin(t)+g.se*cos(t));}*/\ninline pnt rot(pnt g) {return pnt\n(g.fi*co-g.se*si,\ng.fi*si+g.se*co);}\npair q1[SZ];\nbool vis[SZ];\nvoid chk(pnt a1,pnt a2,pnt b1,pnt b2)\n{\n\t//\u5148\u51cf\u53bba1\uff0c\u7136\u540e\u8f6c\uff0c\u7136\u540e\u52a0\u4e0ab1\n\tld x1=ang(a2-a1),x2=ang(b2-b1);\n\tco=cosl(x2-x1); si=sinl(x2-x1);\n\tfor(int i=1;i<=n1;++i)\n\t\tq1[i].fi=rot(p1[i]-a1)+b1,q1[i].se=i,vis[i]=0;\n\tsort(q1+1,q1+n1+1);\n\tvector rs;\n\tint fail=0;\n\tfor(int i=1;i<=n2;++i)\n\t{\n\t\tint o=lower_bound(q1+1,q1+n1+1,mp(p2[i],0))-q1;\n\t\tbool s=0;\n\t\tfor(int j=max(o-10,1);j<=min(o+10,n1);++j)\n\t\t{\n\t\t\tif(dis(q1[j].fi,p2[i])<1&&!vis[q1[j].se])\n\t\t\t{\n\t\t\t\trs.pb(pii(q1[j].se,i));\n\t\t\t\tfail=0; s=1; vis[q1[j].se]=1; break;\n\t\t\t}\n\t\t}\n\t\tif(!s) ++fail;\n\t\tif(fail>100) return;\n\t}\n\trandom_shuffle(rs.begin(),rs.end());\n\tif(rs.size()>=n*0.95)\n\t{\n\t\tif(rs.size()>n) rs.resize(n);\n\t\tfor(int _=0;_>n>>n1;\n\tfor(int i=1;i<=n1;++i)\n\t\tcin>>p1[i].fi>>p1[i].se,p1[i]=rot(p1[i]);\n\tcin>>n2;\n\tfor(int i=1;i<=n2;++i)\n\t\tcin>>p2[i].fi>>p2[i].se,p2[i]=rot(p2[i]);\n\tfor(int i=1;i<=n1&&pn<5000000;++i)\n\t{\n\t\tmd=p1[i]; vector rs;\n\t\tfor(int j=1;j<=n1;++j) if(j!=i)\n\t\t\trs.pb(j),gg[j]=ang(p1[j]-md);\n\t\tsort(rs.begin(),rs.end(),cmp);\n\t\tfor(unsigned _=0;_ rs;\n\t\tfor(int j=1;j<=n2;++j) if(j!=w)\n\t\t\trs.pb(j),gg[j]=ang(p2[j]-md);\n\t\tsort(rs.begin(),rs.end(),cmp);\n\t\tint uu=0;\n\t\tfor(unsigned _=0;_20&&n>10000) break;\n\t\t}\n\t\t}\n\t}\n\tthrow \"GG\";\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c98f79e5cd3c969e599c21f8d716b604", "src_uid": "fc238a230bb556c9ffecf343989b988a", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\n#define LL long long\n#define LD long double\n#define SC(t,x) static_cast(x)\n#define AR(t) vector < t >\n#define PII pair < int, int >\n#define PLL pair < LL, LL >\n#define PIL pair < int, LL >\n#define PLI pair < LL, int >\n#define MP make_pair\n#define PB push_back\n#define PF push_front\n#define POB pop_back\n#define POF pop_front\n#define FF first\n#define SS second\n#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )\n#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )\n#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )\n#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )\n#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )\n#define qmax(a,b) (((a)>(b))?(a):(b))\n#define qmin(a,b) (((a)<(b))?(a):(b))\n#define qabs(a) (((a)>=0)?(a):(-(a)))\n\nconst int INF = 0x3fffffff;\nconst int SINF = 0x7fffffff;\nconst long long LINF = 0x3fffffffffffffff;\nconst long long SLINF = 0x7fffffffffffffff;\nconst int MAXN = 50007;\nint MAXS = 997;\nconst int MAXSS = 510007;\nconst LD PI = acos ( -1.0 );\n//const LD EPS = 1e-9;\nconst LD EPS = 0.015;\nconst LD RATIO = 0.95;\n\nstruct cT\n{\n\tcT () : x ( 0 ), y ( 0 ) {}\n\tcT ( LD _x, LD _y ) : x ( _x ), y ( _y ) {}\n\t\n\tcT operator + ( const cT &a ) const\n\t{\n\t\treturn cT ( x + a.x, y + a.y );\n\t}\n\t\n\tvoid operator += ( const cT &a )\n\t{\n\t\t( *this ) = ( *this ) + a;\n\t}\n\t\n\tcT operator - ( const cT &a ) const\n\t{\n\t\treturn cT ( x - a.x, y - a.y );\n\t}\n\t\n\tvoid operator -= ( const cT &a )\n\t{\n\t\t( *this ) = ( *this ) - a;\n\t}\n\t\n\tLD ang ()\n\t{\n\t\treturn atan2 ( y, x );\n\t}\n\t\n\tLD abs ()\n\t{\n\t\treturn x * x + y * y;\n\t}\n\t\n\tLD len ()\n\t{\n\t\treturn sqrt ( abs () );\n\t}\n\t\n\tcT rot ( LD ang )\n\t{\n\t\tLD ca = cos ( ang ), sa = sin ( ang );\n\t\treturn cT ( x * ca - y * sa, x * sa + y * ca );\n\t}\n\t\n\tbool operator < ( const cT &a ) const\n\t{\n\t\treturn x < a.x;\n\t}\n\t\n\tLD x, y;\n}c1[MAXN], c2[MAXN], r2[MAXN];\n\nint n, n1, n2;\npair < cT, int > s1[MAXN];\npair < LD, PII > s2[MAXSS];\nint ans2[MAXN];\nbool vis1[MAXN];\n\nvoid init ();\nvoid input ();\nvoid work ();\n\nvoid check ( int a11, int a12, int a21, int a22 );\n\n\n\nint main()\n{\n\tinit();\n\tinput();\n\twork();\n}\n\n\n\nvoid init ()\n{\n\t// Init Everything Here\n\t\n\tios::sync_with_stdio ( false );\n}\n\nvoid input ()\n{\n\t// input method\n\t\n\tscanf ( \"%d\", &n );\n\tscanf ( \"%d\", &n1 );\n\tdouble tx, ty;\n\tlpi ( i, 1, n1 ) scanf ( \"%lf%lf\", &tx, &ty ), c1[i].x = tx, c1[i].y = ty;\n\tscanf ( \"%d\", &n2 );\n\tlpi ( i, 1, n2 ) scanf ( \"%lf%lf\", &tx, &ty ), c2[i].x = tx, c2[i].y = ty;\n}\n\nvoid work ()\n{\n\t// main work\n\t\n\tMAXS = qmin ( MAXS, n );\n\t\n\tlpi ( i, 1, n1 ) s1[i] = MP ( c1[i], i );\n\tsort ( s1+1, s1+1+n1 );\n\t\n\tint k2 = 0;\n\tlpi ( i, 1, MAXS ){\n\t\tlpi ( j, i+1, MAXS ){\n\t\t\ts2[++k2] = MP ( ( c2[j] - c2[i] ).len (), MP ( i, j ) );\n\t\t}\n\t}\n\t\n\tsort ( s2+1, s2+1+k2 );\n\tLD nd;\n\tint np;\n\tlpi ( i, 1, MAXS ){\n\t\tlpi ( j, 1, MAXS ){\n\t\t\tif ( i ^ j ){\n\t\t\t\tnd = ( c1[j] - c1[i] ).len ();\n\t\t\t\tnp = lower_bound ( s2+1, s2+1+k2, MP ( nd, MP ( 0, 0 ) ) ) - s2;\n\t\t\t\tlpi ( k, np, k2 ){\n\t\t\t\t\tif ( s2[k].FF - nd < EPS ) check ( i, j, s2[k].SS.FF, s2[k].SS.SS );\n\t\t\t\t\telse break;\n\t\t\t\t}\n\t\t\t\tlpd ( k, np-1, 0 ){\n\t\t\t\t\tif ( nd - s2[k].FF < EPS ) check ( i, j, s2[k].SS.FF, s2[k].SS.SS );\n\t\t\t\t\telse break;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\n\n\nvoid check ( int a11, int a12, int a21, int a22 )\n{\n\tLD ang1 = ( c1[a12] - c1[a11] ).ang (), ang2 = ( c2[a22] - c2[a21] ).ang ();\n\tLD ang = ang1 - ang2;\n\tlpi ( i, 1, n2 ) r2[i] = c2[i].rot ( ang );\n//\tlpi ( i, 1, n2 ) cerr << \"(\" << r2[i].x << \",\" << r2[i].y << \") \"; cerr << endl;\n\tcT d = c1[a11] - r2[a21];\n\tlpi ( i, 1, n2 ) r2[i] += d;\n\t\n\tINIT ( ans2, 0 );\n\tINIT ( vis1, 0 );\n\t\n//\tcerr << a11 << \" \" << a12 << \" \" << a21 << \" \" << a22 << endl;\n//\tcerr << ang << endl;\n//\tlpi ( i, 1, n2 ) cerr << \"(\" << r2[i].x << \",\" << r2[i].y << \") \"; cerr << endl;\n\t\n\tint np, cc = 0;\n\tlpi ( i, 1, n2 ){\n\t\tnp = lower_bound ( s1+1, s1+1+n1, MP ( r2[i], 0 ) ) - s1;\n\t\tlpi ( k, np, n1 ){\n\t\t\tif ( s1[k].FF.x - r2[i].x < EPS ){\n\t\t\t\tif ( qabs ( s1[k].FF.y - r2[i].y ) < EPS && !vis1[s1[k].SS] ){\n\t\t\t\t\tans2[i] = s1[k].SS;\n\t\t\t\t\tvis1[s1[k].SS] = true;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}else break;\n\t\t}\n\t\tif ( !ans2[i] ){\n\t\t\tlpd ( k, np-1, 0 ){\n\t\t\t\tif ( r2[i].x - s1[k].FF.x < EPS ){\n\t\t\t\t\tif ( qabs ( s1[k].FF.y - r2[i].y ) < EPS && !vis1[s1[k].SS] ){\n\t\t\t\t\t\tans2[i] = s1[k].SS;\n\t\t\t\t\t\tvis1[s1[k].SS] = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}else break;\n\t\t\t}\n\t\t}\n\t\tif ( ans2[i] ) ++cc;\n\t}\n\t\n\tif ( cc > RATIO * n ){\n\t\tint nc = 0;\n\t\tlpi ( i, 1, n2 ){\n\t\t\tif ( ans2[i] ){\n\t\t\t\tprintf ( \"%d %d\\n\", ans2[i], i );\n\t\t\t\tif ( ++nc == n ) break;\n\t\t\t}\n\t\t}\n\t\tif ( nc < n ){\n\t\t\tint i1 = 1;\n\t\t\tlpi ( i, 1, n2 ){\n\t\t\t\tif ( !ans2[i] ){\n\t\t\t\t\twhile ( vis1[i1] ) ++i1;\n\t\t\t\t\tprintf ( \"%d %d\\n\", i1, i );\n\t\t\t\t\tvis1[i1] = true;\n\t\t\t\t\tif ( ++nc == n ) break;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\texit ( 0 );\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b441d152969adf553a7ec4fe2734b189", "src_uid": "fc238a230bb556c9ffecf343989b988a", "difficulty": 3100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long LL;\nconst double EPS = 1e-9, INF = 1e15, PI = acos(-1.0);\n#define FOR(i,s,e) for(int i=s;i\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst double pi=acos(-1.00),eps=1e-9;\nstruct point\n{\n double x,y,w,a;\n};\npoint st,en,tank[11111];\nint n,k;\nvoid norm(double &theta)\n{\n while(theta<-pi+eps)\n theta+=2*pi;\n while(theta>pi+eps)\n theta-=2*pi;\n}\nbool check(double v)\n{\n int i,j,s,p,q,nk=0,it;\n double now_t,theta,dist,T;\n double ltheta,rtheta,dtheta,low,high,mid,mt,vs,fs,bs,mx,my,fx,fy;\n bool ft;\n dist=sqrt((en.x-st.x)*(en.x-st.x)+(en.y-st.y)*(en.y-st.y));\n T=dist/v;\n for(i=0;i=min(st.x,en.x)-eps&&tank[i].y<=max(st.y,en.y)+eps&&tank[i].y>=min(st.y,en.y)-eps)\n\t \t fk=true;\n\t if(fk)\n\t {\n\t nk++;\n\t continue;\n\t\t\t}\n\t\t}\n theta=atan2(en.y-tank[i].y,en.x-tank[i].x);\n rtheta=theta;\n while(thetartheta)\n dtheta=rtheta+2*pi-ltheta;\n else\n dtheta=rtheta-ltheta;\n ft=false;\n if(dtheta>pi)\n swap(ltheta,rtheta);\n if(lthetaltheta-eps)\n\t\t \t ft=true; \n }\n else\n {\n \tif(tank[i].altheta-eps)\n \t ft=true;\n }\n\t\tif(tank[i].w==0)\n\t\t{\n\t\t\tif(ft)\n\t\t\t nk++;\n continue;\n\t\t}\n\t\telse\n {\n \tassert(!ft);\n\t\t\twhile(lthetahigh)\n\t\t\t continue;\n \t\t\tmt=low;\n \t\t\tfs=(st.x+v*cos(theta)*mt-tank[i].x)*sin(tank[i].a+tank[i].w*mt)-(st.y+v*sin(theta)*mt-tank[i].y)*cos(tank[i].a+tank[i].w*mt);\n \t\t\tmt=high;\n \t\t\tbs=(st.x+v*cos(theta)*mt-tank[i].x)*sin(tank[i].a+tank[i].w*mt)-(st.y+v*sin(theta)*mt-tank[i].y)*cos(tank[i].a+tank[i].w*mt);\n \t\t\tif((fs<1e-4&&bs>-1e-4)||(fs>-1e-4&&bs<1e-4))\n \t\t\t{\n \t\t \tnk++;\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tfor(it=0;it<100;it++)\n\t \t\t{\n\t \t\t\tmx=mt=(2*low+high)/3.;\n\t \t\t\tfx=(st.x+v*cos(theta)*mt-tank[i].x)*sin(tank[i].a+tank[i].w*mt)-(st.y+v*sin(theta)*mt-tank[i].y)*cos(tank[i].a+tank[i].w*mt);\n\t \t\t my=mt=(low+2*high)/3.;\n\t \t\t fy=(st.x+v*cos(theta)*mt-tank[i].x)*sin(tank[i].a+tank[i].w*mt)-(st.y+v*sin(theta)*mt-tank[i].y)*cos(tank[i].a+tank[i].w*mt);\n\t \t\t\tif((fs>0&&fx>fy)||(fs<0&&fx0&&fx<1e-4)||(fs<0&&fx>-1e-4))\n\t\t \t{\n\t\t\t \tnk++;\n\t\t\t \tcontinue;\n\t\t \t}\n\t\t \tassert(dthetaT+1e-4);\n\t\t}\n if(nk>k)\n return false;\n }\n return nk<=k;\n}\nint main()\n{\n int i,j,s,p,q;\n double low,high,mid;\n scanf(\"%lf%lf%lf%lf\",&st.x,&st.y,&en.x,&en.y);\n scanf(\"%d\",&n);\n for(i=0;i\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst double pi=acos(-1.00),eps=1e-9;\nconst int bound=1000;\nstruct point\n{\n double x,y,w,a;\n};\npoint st,en,tank[11111];\nint n,k;\nvoid norm(double &theta)\n{\n while(theta<=-pi)\n theta+=2*pi;\n while(theta>pi)\n theta-=2*pi;\n}\nbool check(double v)\n{\n int i,j,s,p,q,nk=0;\n double now_t,theta,T,dist=sqrt((st.x-en.x)*(st.x-en.x)+(st.y-en.y)*(st.y-en.y));\n double ltheta,rtheta,dtheta,low,high,mid,mt,vs,fs,bs,mx,my,fx,fy;\n int it;\n bool ft;\n T=dist/v;\n// printf(\"n\")\n for(i=0;i=min(st.x,en.x)-eps&&tank[i].y<=max(st.y,en.y)+eps&&tank[i].y>=min(st.y,en.y)-eps)\n\t \t fk=true;\n\t if(fk)\n\t {\n\t nk++;\n\t continue;\n\t\t\t}\n\t\t}\n theta=atan2(en.y-tank[i].y,en.x-tank[i].x);\n rtheta=theta;\n ltheta=atan2(st.y-tank[i].y,st.x-tank[i].x);\n if(ltheta>rtheta)\n dtheta=rtheta+2*pi-ltheta;\n else\n dtheta=rtheta-ltheta;\n ft=false;\n if(dtheta>pi)\n swap(ltheta,rtheta);\n if(lthetaltheta-eps)\n\t\t \t ft=true; \n }\n else\n {\n \tif(tank[i].altheta-eps)\n \t ft=true;\n }\n\t\tif(tank[i].w==0)\n\t\t{\n\t\t\tif(ft)\n\t\t\t nk++;\n continue;\n\t\t}\n\t\telse\n {\n if(thetaT-eps)\n\t\t\t{\n nk++;\n\t\t\t continue;\n\t\t\t}\n\t\t\twhile(lthetartheta)\n\t\t\t low=0;\n\t\t\tmt=low;\n\t\t\tfs=(st.x+v*cos(theta)*mt-tank[i].x)*sin(tank[i].a+tank[i].w*mt)-(st.y+v*sin(theta)*mt-tank[i].y)*cos(tank[i].a+tank[i].w*mt);\n\t\t\tmt=high;\n\t\t\tbs=(st.x+v*cos(theta)*mt-tank[i].x)*sin(tank[i].a+tank[i].w*mt)-(st.y+v*sin(theta)*mt-tank[i].y)*cos(tank[i].a+tank[i].w*mt);\n\t\t\tif((fs<1e-4&&bs>-1e-4)||(fs>-1e-4&&bs<1e-4))\n\t\t\t{\n\t\t \tnk++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfor(it=0;it<50;it++)\n\t\t\t{\n\t\t\t\tmx=mt=(2*low+high)/3.;\n\t\t\t\tfx=(st.x+v*cos(theta)*mt-tank[i].x)*sin(tank[i].a+tank[i].w*mt)-(st.y+v*sin(theta)*mt-tank[i].y)*cos(tank[i].a+tank[i].w*mt);\n\t\t\t my=mt=(low+2*high)/3.;\n\t\t\t fy=(st.x+v*cos(theta)*mt-tank[i].x)*sin(tank[i].a+tank[i].w*mt)-(st.y+v*sin(theta)*mt-tank[i].y)*cos(tank[i].a+tank[i].w*mt);\n\t\t\t\tif((fs>0&&fx>fy)||(fs<0&&fx0&&fx<1e-4)||(fs<0&&fx>-1e-4))\n\t\t\t{\n\t\t\t\tnk++;\n\t\t\t\tcontinue;\n\t\t\t}\n if(ltheta>rtheta)\n \t \t {\n \t \t \tlow=(ltheta-tank[i].a)/tank[i].w;\n \t \t \thigh=2*pi/tank[i].w;\n \t \t \tmt=low;\n \t \t \tfs=(st.x+v*cos(theta)*mt-tank[i].x)*sin(tank[i].a+tank[i].w*mt)-(st.y+v*sin(theta)*mt-tank[i].y)*cos(tank[i].a+tank[i].w*mt);\n \t \t \tmt=high;\n\t\t \tbs=(st.x+v*cos(theta)*mt-tank[i].x)*sin(tank[i].a+tank[i].w*mt)-(st.y+v*sin(theta)*mt-tank[i].y)*cos(tank[i].a+tank[i].w*mt);\n\t \t\tif((fs<1e-4&&bs>-1e-4)||(fs>-1e-4&&bs<1e-4))\n\t \t\t{\n\t \t \tnk++;\n\t \t\t\tcontinue;\n\t \t\t}\n\t \t\tfor(it=0;it<50;it++)\n\t \t\t{ \n\t \t\t\tdouble mx,my,fx,fy;\n\t \t\t\tmx=mt=(2*low+high)/3.;\n\t \t\t\tfx=(st.x+v*cos(theta)*mt-tank[i].x)*sin(tank[i].a+tank[i].w*mt)-(st.y+v*sin(theta)*mt-tank[i].y)*cos(tank[i].a+tank[i].w*mt);\n\t \t\t my=mt=(low+2*high)/3.;\n\t \t\t fy=(st.x+v*cos(theta)*mt-tank[i].x)*sin(tank[i].a+tank[i].w*mt)-(st.y+v*sin(theta)*mt-tank[i].y)*cos(tank[i].a+tank[i].w*mt);\n\t \t\t\tif((fs>0&&fx>fy)||(fs<0&&fx0&&fx<1e-4)||(fs<0&&fx>-1e-4))\n\t \t\t{\n\t \t\t\tnk++;\n\t \t\t\tcontinue;\n\t \t\t}\n\t\t }\n\t\t}\n if(nk>k)\n return false;\n }\n return nk<=k;\n}\nint main()\n{\n int i,j,s,p,q;\n double low,high,mid;\n scanf(\"%lf%lf%lf%lf\",&st.x,&st.y,&en.x,&en.y);\n scanf(\"%d\",&n);\n for(i=0;i\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst double pi=acos(-1.00),eps=1e-9;\nstruct point\n{\n double x,y,w,a;\n};\npoint st,en,tank[11111];\nint n,k;\nvoid norm(double &theta)\n{\n while(theta<=-pi)\n theta+=2*pi;\n while(theta>pi)\n theta-=2*pi;\n}\nbool check(double v)\n{\n int i,j,s,p,q,nk=0;\n double now_t,theta,T,dist=sqrt((st.x-en.x)*(st.x-en.x)+(st.y-en.y)*(st.y-en.y));\n double ltheta,rtheta,dtheta;\n bool ft;\n T=dist/v;\n// printf(\"n\")\n for(i=0;i=min(st.x,en.x)-eps&&tank[i].y<=max(st.y,en.y)+eps&&tank[i].y>=min(st.y,en.y)-eps)\n\t \t fk=true;\n\t assert(!fk);\n\t }\n theta=atan2(en.y-tank[i].y,en.x-tank[i].x);\n rtheta=theta;\n ltheta=atan2(st.y-tank[i].y,st.x-tank[i].x);\n if(ltheta>rtheta)\n dtheta=rtheta+2*pi-ltheta;\n else\n dtheta=rtheta-ltheta;\n ft=false;\n if(dtheta>pi)\n swap(ltheta,rtheta);\n if(lthetaltheta-eps)\n\t\t \t ft=true; \n }\n else\n {\n \tif(tank[i].altheta-eps)\n \t ft=true;\n }\n\t\tif(tank[i].w==0)\n continue;\n else\n {\n if(thetaT-eps)\n nk++;\n }\n if(nk>k)\n return false;\n }\n return true;\n}\nint main()\n{\n int i,j,s,p,q;\n double low,high,mid;\n scanf(\"%lf%lf%lf%lf\",&st.x,&st.y,&en.x,&en.y);\n scanf(\"%d\",&n);\n for(i=0;i\nusing namespace std;\n\nvoid No(){\n\tputs(\"No solution\");\n\texit(0);\n}\n\nconst int maxn=400005;\nconst int H1=20160224;\nconst int mod1=998244353;\nconst int H2=23333333;\nconst int mod2=1e9+7;\nint n,m,a,b,c,d;\nchar sa[2],sb[2],p[4];\nint ch[256],cnt[4];\nclass Hashint{\npublic:\n\tint h1,h2;\n\tHashint():h1(0),h2(0){}\n\tHashint(int _h1,int _h2):h1(_h1),h2(_h2){}\n\tHashint operator+(const Hashint &o)const{\n\t\treturn Hashint(h1+o.h1>=mod1?h1+o.h1-mod1:h1+o.h1,h2+o.h2>=mod2?h2+o.h2-mod2:h2+o.h2);\n\t}\n\tHashint operator-(const Hashint &o)const{\n\t\treturn Hashint(h1-o.h1<0?h1-o.h1+mod1:h1-o.h1,h2-o.h2<0?h2-o.h2+mod2:h2-o.h2);\n\t}\n\tHashint operator*(const Hashint &o)const{\n\t\treturn Hashint(1LL*h1*o.h1%mod1,1LL*h2*o.h2%mod2);\n\t}\n\tbool operator<(const Hashint &o)const{\n\t\treturn h1edge[maxn];\n\tbool vis[maxn];\n\tHashint val[maxn];\n\tvoid addedge(int u,int v){\n\t\tedge[u].push_back(v);\n\t\tedge[v].push_back(u);\n\t}\n\tvector >solve(){\n\t\tv=2*(n+m);\n\t\tvector >res;\n\t\tfor(int i=0;inow=make_pair(cur,ver[0]);\n\t\t\tfor(int j=1;j=0&&nd>=0);\n\t\t\tG2.addedge(p[a]+nc,p[b]+nd);\n\t\t\tcnt[a]++;\n\t\t}\n\t}\n\tif(cnt[3]+cnt[0]!=cnt[1]+cnt[2]||cnt[0]+cnt[1]!=cnt[2]+cnt[3])No();\n\tif(cnt[3]+cnt[0] >ans1=G1.solve();\n\tvector >ans2=G2.solve();\n\tif(int(ans1.size())!=int(ans2.size()))No();\n\tfor(int i=0;i>1,d1=ans1[i].second&1;\n\t\tint j2=ans2[i].second>>1,d2=ans2[i].second&1;\n\t\tG1.vis[j1]=G2.vis[j2]=true;\n\t\tupdate(j1,j2);\n\t\tj1=G1.edge[j1][d1];j2=G2.edge[j2][d2];\n\t\twhile(!G1.vis[j1]||!G2.vis[j2]){\n\t\t\tupdate(j1,j2);\n\t\t\tG1.vis[j1]=G2.vis[j2]=true;\n\t\t\tj1=G1.vis[G1.edge[j1][0]]?G1.edge[j1][1]:G1.edge[j1][0];\n\t\t\tj2=G2.vis[G2.edge[j2][0]]?G2.edge[j2][1]:G2.edge[j2][0];\n\t\t}\n\t}\n\tfor(int i=0;i\n#include \n#include \n#include \n#include \n#define N 400010\n#define For(i,x,y) for (i=x;i<=y;i++)\nusing namespace std;\nint i,j,k,n,m,nn,flag,f5,t,S,num,last,fdan,fduo;\nstruct read {\n\tchar p[2],s[2];\n\tint x,y;\n\tinline char gai(char x) {\n\t\treturn x=='L'?'T':x=='R'?'B':x=='B'?'L':'R';\n\t}\n\tinline void change(char x,int &y) {\n\t\tif (x=='L') y=n-y+1;\n\t\tif (x=='R') y=n-y+1;\n\t}\n\tinline void fan() {\n\t\tchange(p[0],x);\n\t\tchange(s[0],y);\n\t\tp[0]=gai(p[0]);\n\t\ts[0]=gai(s[0]);\n\t}\n} rea[N];\nstruct ww {\n\tint x,y,ty;\n} a[N],zhi[N];\nint dui[N],F[N],ty[10],st[10],type[N],an[N],ss[N][10],anx[N],any[N],len[N],id[N];\nvector x,y,X[N],Y[N];\n/*\n------------\n|1 / | \\ 2|\n| / | \\ |\n|/ | \\|\n|\\ 5| /|\n| \\ | / |\n|3 \\ | / 4|\n| \\ |/ |\n------------ by zhj\nBLRT\n*/\ninline void fail() {\n\tprintf(\"No solution\\n\");\n\texit(0);\n}\ninline void print() {\n\tint i;\n\tif (!flag) {\n\t\tFor(i,1,n) printf(\"%d \",anx[i]); printf(\"\\n\");\n\t\tFor(i,1,m) printf(\"%d \",any[i]); printf(\"\\n\");\n\t} else {\n\t\tfor (i=m;i;i--) printf(\"%d \",m-any[i]+1); printf(\"\\n\");\n\t\tFor(i,1,n) printf(\"%d \",anx[i]); printf(\"\\n\");\n\t}\n}\ninline void gai(char x,int &y) {\n\tif (x=='T') y+=n;\n\tif (x=='R') y+=nn;\n\tif (x=='B') y+=n+nn;\n}\ninline void into(char x,char y) {\n\tif (x>y) swap(x,y);\n\tif (x=='B'&&y=='L') ty[3]++;\n\tif (x=='B'&&y=='R') ty[4]++;\n\tif (x=='B'&&y=='T') ty[5]++;\n\tif (x=='L'&&y=='R') ty[6]++;\n\tif (x=='L'&&y=='T') ty[1]++;\n\tif (x=='R'&&y=='T') ty[2]++;\n}\ninline void pre() {\n\tFor(i,1,nn) {\n\t\tscanf(\"%s%s%d%d\",rea[i].p,rea[i].s,&rea[i].x,&rea[i].y);\n\t\tinto(rea[i].p[0],rea[i].s[0]);\n\t}\n\tif (ty[5]&&ty[6]) fail();\n\tif (ty[6]) {\n\t\tFor(i,1,nn) rea[i].fan();\n\t\tswap(n,m);\n\t\tflag=1;\n\t}\n\tmemset(ty,0,sizeof(ty));\n\tFor(i,1,nn) {\n\t\tchar p=rea[i].p[0],s=rea[i].s[0];\n\t\tint x=rea[i].x,y=rea[i].y;\n\t\tgai(p,x);\n\t\tgai(s,y);\n\t\tdui[x]=y;\n\t\tdui[y]=x;\n\t\tinto(p,s);\n\t}\n\tst[1]=0,st[2]=m,st[3]=n,st[5]=ty[1];\n}\ninline int shi(int x) {\n\treturn x>nn?x-nn:x;\n}\ninline int rev(int x) {\n\treturn x<=nn?x+nn:x-nn;\n}\ninline void jing(int x,int y) {\n\tif (x>y) swap(x,y);\n\tif (x<=n&&y<=nn) a[++t]=(ww){x,y,1};\n\tif (x>n&&x<=nn&&y>nn&&y<=nn+n) a[++t]=(ww){x,y,2};\n\tif (x<=n&&y>nn+n) a[++t]=(ww){x,y,3};\n\tif (x>nn&&x<=nn+n&&y>nn+n) a[++t]=(ww){x,y,4};\n\tif (x>n&&x<=nn&&y>nn+n) a[++t]=(ww){x,y,5};\n}\nvoid dfs(int x) {\n\tif (F[shi(x)]) return;\n\tint A=dui[x],B=rev(A);\n\tjing(x,A);\n\tif (a[t].ty==1||a[t].ty==3) num++;\n\tif (a[t].ty==2||a[t].ty==4) len[num]=last,last=0;\n\tif (a[t].ty==5) last++,zhi[a[t].x]=zhi[a[t].y]=(ww){last,num};\n\tF[shi(x)]=1;\n\tdfs(B);\n}\ninline void jia(int A) {\n\tif (A<=n) x.push_back(A);\n\tif (A>n&&A<=nn) y.push_back(A-n);\n}\ninline void work() {\n\tint s[10]={},i,j;\n\tx.clear(),y.clear();\n\tFor(i,1,t) {\n\t\tww A=a[i];\n\t\ts[A.ty]++;\n\t\tif (A.ty!=5) an[A.x]=an[A.y]=s[A.ty];\n\t\ttype[A.x]=A.ty;\n\t\ttype[A.y]=A.ty;\n\t\tjia(A.x),jia(A.y);\n\t}\n\tsort(x.begin(),x.end());\n\tsort(y.begin(),y.end());\n\tif (s[1]&&s[2]&&s[3]&&s[4]) {\n\t\tif (max(max(s[1],s[2]),max(s[3],s[4]))>1||s[5]) fail();\n\t\tint wa=0;\n\t\tFor(i,1,t) {\n\t\t\tif (a[i].ty==1) wa+=(x[0]!=a[i].x)+(y[0]+n!=a[i].y);\n\t\t\tif (a[i].ty==4) wa+=(x[0]+nn==a[i].x)+(y[0]+n+nn==a[i].y);\n\t\t}\n\t\tif (wa&1) fail();\n\t}\n\tif (!s[1]&&!s[2]) {\n\t\tint A=a[1].x-n;\n\t\tany[st[5]+1]=A;\n\t\tst[5]++;\n\t} else if (!s[1]||!s[3]) {\n\t\tint s1,s2,ma=0; s1=s2=0;\n\t\tFor(i,1,num) ma=max(ma,len[i]);\n\t\tFor(i,1,num) s1+=len[i]!=ma&&len[i]+1!=ma,s2+=len[i]+1==ma;\n\t\tif (sum>1&&(s1||s2!=1)) fail();\n\t\tFor(i,1,num) if (len[i]+1==ma) break;\n\t\tif (i!=num) {\n\t\t\tint sum=num;\n\t\t\tid[i]=sum;\n\t\t\tfor (int k=i;;) {\n\t\t\t\tk--; sum--;\n\t\t\t\tif (!k) k=num;\n\t\t\t\tif (!sum) break;\n\t\t\t\tid[k]=sum;\n\t\t\t}\n\t\t} else For(i,1,num) id[i]=i;\n\t\tFor(i,1,t) {\n\t\t\tww A=a[i];\n\t\t\tif (A.ty==5) an[A.x]=an[A.y]=id[zhi[A.x].y]+(zhi[A.x].x-1)*num;\n\t\t\telse {\n\t\t\t\tan[A.x]=id[an[A.x]];\n\t\t\t\tan[A.y]=id[an[A.y]];\n\t\t\t}\n\t\t}\n\t\tif (num>1&&f5||fduo) fail();\n\t\tif (f5&&ma!=fdan) fail();\n\t\tfdan=ma;\n\t\tif (num>1) fduo=1;\n\t\tint tmp=s[1]?1:2;\n\t\tif (f5&&f5!=tmp) fail();\n\t\tf5=tmp;\n\t\t++S;\n\t\tX[S]=x,Y[S]=y;\n\t\tFor(i,1,9) ss[S][i]=s[i];\n\t} else {\n\t\tfor (i=0;i\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nstruct point\n{\n int x[2],id1,id2;\n bool operator <(const point &temp)const\n {\n if(x[1]==temp.x[1])\n return x[0]='A'&&ch1<='Z'))\n ch1=getchar();\n ch2=getchar();\n while(!(ch2>='A'&&ch2<='Z'))\n ch2=getchar();\n scanf(\"%d%d\",&id1,&id2);\n id1--;\n id2--;\n if(pos[ch1]>pos[ch2])\n {\n swap(ch1,ch2);\n swap(id1,id2);\n }\n id=ps[pos[ch1]][pos[ch2]];\n list[id][cnt_list[id]].id1=pos[ch1];\n list[id][cnt_list[id]].id2=pos[ch2];\n list[id][cnt_list[id]].x[0]=id1;\n list[id][cnt_list[id]++].x[1]=id2;\n }\n for(i=0;i<6;i++) \n sort(list[i],list[i]+cnt_list[i]);\n for(i=0;i=cnt_list[5])\n {\n puts(\"No solution\");\n return 0;\n }\n exchange(2,3,i,m-1-i,n-1-i);\n }\n for(i=0;i<6;i++) \n sort(list[i],list[i]+cnt_list[i]);\n\n for(i=0;i<6;i++)\n {\n for(j=0;j=cnt_list[4])\n {\n puts(\"No solution\");\n return 0;\n }\n exchange(1,3,i,m-1-i,i);\n }\n }\n if(cnt_list[0]+cnt_list[1]\nusing namespace std;\nconst int N=2e5+7,M=4e6+7;\nint n,m,q,k,p[N],t[N],vs[N],siz[N],va[M],vb[M]; vectorv[N],w[N];\nstruct node {int t,f;}; vectore[N];\nstruct note {int a,b;}gt[N];\nstruct nope {int a,b,t;};\npriority_queueg[N];\ninline int find(int u){\n\tif(vs[u]==u) return u; return vs[u]=find(vs[u]);\n}\ninline bool operator < (note a,note b){\n\tif(a.a==b.a) return a.b>b.b; return a.ab.t;\n}\nsetf1[N],f2[N];\ninline void updatea(int u,int c){\n\tnote w; w.a=va[c]+t[u]*2+1,w.b=998244353;\n\tf2[u].insert(w);\n\tif((*f2[u].rbegin()).b==998244353) {f2[u].erase(w); return;};\n\tnote e=(*(++f2[u].find(w))); f2[u].erase(w);\n\tif(find(e.b)==find(c)&&(*f2[u].rbegin()).b==e.b) return;\n\tif(find(e.b)==find(c)) e=(*(++f2[u].find(e)));\n\t\n\tnope v; v.a=c,v.b=e.b,v.t=(va[v.b]-va[v.a]+1)/2; g[u].push(v);\n}\ninline void updateb(int u,int c){\n\tnote w; w.a=va[c]-t[u]*2-1,w.b=-998244353;\n\tf1[u].insert(w);\n\t\n\tif((*f1[u].begin()).b==-998244353) {f1[u].erase(w); return;};\n\tnote e=(*(--f1[u].find(w)));\n\tf1[u].erase(w);\n\tif(find(e.b)==find(c)&&(*f1[u].begin()).b==e.b) return;\n\tif(find(e.b)==find(c)) e=(*(--f1[u].find(e)));\n\tnope v; v.a=e.b,v.b=c,v.t=(va[v.b]-va[v.a]+1)/2; g[u].push(v);\n}\ninline void update(int u,int k){\n\twhile(g[u].size()){\n\t\tnope z=g[u].top();\n\t\tif(va[z.a]==-1||va[z.b]==-1) {g[u].pop(); continue;}\n\t\tif(z.t<=t[u]){\n\t\t\tg[u].pop(); continue;\n\t\t}\n\t\tif(z.t<=t[u]+k){\n\t\t\tnote r; r.a=va[z.a],r.b=z.a; note w1,w2,h1,h2;\n\t\t\tw1.a=-1,w1.b=-1,w2.a=-1,w2.b=-1,h1.a=-1,h1.b=-1,h2.a=-1,h2.b=-1;\n\t\t\tif((*f1[u].begin()).b!=r.b) w1=(*(--f1[u].find(r)));\n\t\t\tif((*f1[u].rbegin()).b!=r.b) w2=(*(++f1[u].find(r)));\n\t\t\tf1[u].erase(r);\n\t\t\tnote c; c.a=va[z.b],c.b=z.b;\n\t\t\tif((*f2[u].begin()).b!=c.b) h1=(*(--f2[u].find(c)));\n\t\t\tif((*f2[u].rbegin()).b!=c.b) h2=(*(++f2[u].find(c)));\n\t\t\tf2[u].erase(c);\n\t\t\tif(vb[z.a]+vb[z.b]<0){\n\t\t\t\tm++,va[m]=va[z.a],vb[m]=vb[z.a]+vb[z.b],vs[m]=vs[z.a]; c.a=va[m],c.b=m; f1[u].insert(c); updatea(u,m);\n\t\t\t}\n\t\t\tif(vb[z.a]+vb[z.b]>0){\n\t\t\t\tm++,va[m]=va[z.b],vb[m]=vb[z.a]+vb[z.b],vs[m]=vs[z.b]; c.a=va[m],c.b=m;\n\t\t\t\tf2[u].insert(c); updateb(u,m);\n\t\t\t}\n\t\t\tif(w1.b!=-1) updatea(u,w1.b);\n\t\t\tif(w2.b!=-1) updatea(u,w2.b);\n\t\t\tif(h1.b!=-1) updateb(u,h1.b);\n\t\t\tif(h2.b!=-1) updateb(u,h2.b);\n\t\t\tva[z.a]=-1,va[z.b]=-1;\n\t\t\tg[u].pop();\n\t\t}\n\t\telse break;\n\t}\n\tt[u]+=k;\n}\ninline int merge(int a,int b){\n\tif(siz[a]::iterator iter = f1[b].begin();\n\twhile(iter!=f1[b].end()){\n\t\tnote w=(*iter);\n\t\tm++,va[m]=w.a+t[b]-t[a],vb[m]=vb[w.b],va[w.b]=-1,w.a=va[m],w.b=m,vs[m]=m;\n\t\tf1[a].insert(w),iter++,updatea(a,m);\n\t}\n\titer = f2[b].begin();\n\twhile(iter!=f2[b].end()){\n\t\tnote w=(*iter);\n\t\tm++,va[m]=w.a-t[b]+t[a],vb[m]=vb[w.b],va[w.b]=-1,w.a=va[m],w.b=m,vs[m]=m;\n\t\tf2[a].insert(w),iter++,updateb(a,m);\n\t}\n\treturn a;\n}\ninline void dfs(int u,int fa){\n\tp[u]=u;\n\tfor(int i=0;i>n; int a,b,c;\n\tfor(int i=1;i>q;\n\twhile(q--){\n\t\tscanf(\"%d%d%d\",&a,&b,&c); node d;\n\t\td.t=a,d.f=b; e[c].push_back(d);\n\t}\n\tdfs(n+1,0);\n\tset::iterator iter = f1[p[n+1]].begin();\n\twhile(iter!=f1[p[n+1]].end()){\n\t\tnote w=(*iter); gt[++k]=w; gt[k].a+=t[p[n+1]];\n\t\titer++;\n\t}\n\titer = f2[p[n+1]].begin();\n\twhile(iter!=f2[p[n+1]].end()){\n\t\tnote w=(*iter); gt[++k]=w; gt[k].a-=t[p[n+1]];\n\t\titer++;\n\t}\n\tsort(gt+1,gt+k+1,tmp); int sum=0,ans=0;\n\tfor(int i=1;i<=k;i++){\n\t\tint j=i; sum+=vb[gt[i].b];\n\t\twhile(gt[j+1].a==gt[i].a&&j+1<=k) sum+=vb[gt[j+1].b],j++;\n\t\ti=j; ans=max(ans,sum);\n\t}\n\tcout<\nusing namespace std;\n\nusing ll=long long;\n#define int ll\n\n#define rng(i,a,b) for(int i=int(a);i=int(a);i--)\n#define per(i,b) gnr(i,0,b)\n#define pb push_back\n#define eb emplace_back\n#define a first\n#define b second\n#define bg begin()\n#define ed end()\n#define all(x) x.bg,x.ed\n#ifdef LOCAL\n#define dmp(x) cerr<<__LINE__<<\" \"<<#x<<\" \"< void chmax(t&a,u b){if(a void chmin(t&a,u b){if(b using vc=vector;\ntemplate using vvc=vc>;\n\nusing pi=pair;\nusing vi=vc;\n\ntemplate\nostream& operator<<(ostream& os,const pair& p){\n\treturn os<<\"{\"< ostream& operator<<(ostream& os,const vc& v){\n\tos<<\"{\";\n\tfor(auto e:v)os<\nvoid dmpr(ostream&os,const T&t,const Args&... args){\n\tos<\nvoid print_tuple(ostream&,const T&){\n}\n\ntemplate\nvoid print_tuple(ostream&os,const T&t){\n\tif(i)os<<\",\";\n\tos<(t);\n\tprint_tuple(os,t);\n}\n\ntemplate\nostream& operator<<(ostream&os,const tuple&t){\n\tos<<\"{\";\n\tprint_tuple<0,tuple,Args...>(os,t);\n\treturn os<<\"}\";\n}\n\nvoid print(ll x,int suc=1){\n\tcout<>i;\n\treturn i;\n}\n\nvi readvi(int n,int off=0){\n\tvi v(n);\n\trep(i,n)v[i]=read()+off;\n\treturn v;\n}\n\ntemplate\nvoid print(const vector&v,int suc=1){\n\trep(i,v.size())\n\t\tprint(v[i],i==int(v.size())-1?suc:2);\n}\n\nstring readString(){\n\tstring s;\n\tcin>>s;\n\treturn s;\n}\n\ntemplate\nT sq(const T& t){\n\treturn t*t;\n}\n\n//#define CAPITAL\nvoid yes(bool ex=true){\n\t#ifdef CAPITAL\n\tcout<<\"YES\"< void mkuni(vc&v){\n\tsort(all(v));\n\tv.erase(unique(all(v)),v.ed);\n}\n\nll rand_int(ll l, ll r) { //[l, r]\n\t#ifdef LOCAL\n\tstatic mt19937_64 gen;\n\t#else\n static random_device rd;\n static mt19937_64 gen(rd());\n #endif\n return uniform_int_distribution(l, r)(gen);\n}\n\ntemplate\nint lwb(const vc&v,const t&a){\n\treturn lower_bound(all(v),a)-v.bg;\n}\n\nint maxflow;\n\nstruct ysp{\n\tmap left,right;\n\tpriority_queue,greater> qs;\n\tint lo,ro,qo;\n\tysp():lo(0),ro(0),qo(0){}\n\tint size(){return left.size()+right.size();}\n\tvoid addqleft(int x){\n\t\tdmp(x);\n\t\tauto itr=right.lower_bound(x+lo-ro);\n\t\tif(itr!=right.ed){\n\t\t\tint d=itr->a+ro-(x+lo);\n\t\t\tassert(d%2==0);\n\t\t\tassert(d>=0);\n\t\t\tqs.emplace(d/2-qo,x);\n\t\t}\n\t}\n\tvoid addqright(int x){\n\t\tdmp(x);\n\t\tauto itr=left.upper_bound(x+ro-lo);\n\t\tif(itr!=left.bg){\n\t\t\t--itr;\n\t\t\tint d=x+ro-(itr->a+lo);\n\t\t\tassert(d%2==0);\n\t\t\tassert(d>=0);\n\t\t\tqs.emplace(d/2-qo,itr->a);\n\t\t}\n\t}\n\tvoid insertleft(int x,int v){\n\t\tif(v==0)return;\n\t\tassert(v>0);\n\t\tx-=lo;\n\t\tleft[x]+=v;\n\t\taddqleft(x);\n\t}\n\tvoid insertright(int x,int v){\n\t\tif(v==0)return;\n\t\tassert(v>0);\n\t\tx-=ro;\n\t\tright[x]+=v;\n\t\taddqright(x);\n\t}\n\tvoid Expand(int w){\n\t\tdmp(qo);\n\t\tdmp(qs.size());\n\t\twhile(w&&qs.size()){\n\t\t\tpi z=qs.top();qs.pop();\n\t\t\tz.a+=qo;\n\t\t\tdmp(z);\n\t\t\tint u=min(w,z.a);\n\t\t\tdmp(u);\n\t\t\tw-=u;\n\t\t\tz.a-=u;\n\t\t\tqo-=u;\n\t\t\tlo+=u;\n\t\t\tro-=u;\n\t\t\tif(z.a==0){\n\t\t\t\tdmp2(z.b,z.b+lo-ro);\n\t\t\t\tauto l=left.find(z.b);\n\t\t\t\tauto r=right.find(z.b+lo-ro);\n\t\t\t\tif(l!=left.ed&&r!=right.ed){\n\t\t\t\t\tint y=min(l->b,r->b);\n\t\t\t\t\tmaxflow+=y;\n\t\t\t\t\tint f=-1;\n\t\t\t\t\tl->b-=y;\n\t\t\t\t\tif(l->b==0)left.erase(l);\n\t\t\t\t\telse f=0;\n\t\t\t\t\tr->b-=y;\n\t\t\t\t\tif(r->b==0)right.erase(r);\n\t\t\t\t\telse f=1;\n\t\t\t\t\tif(f==0){\n\t\t\t\t\t\taddqleft(l->a);\n\t\t\t\t\t}else if(f==1){\n\t\t\t\t\t\taddqright(r->a);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}else\n\t\t\t\tqs.emplace(z.a-qo,z.b);\n\t\t}\n\t\tqo-=w;\n\t\tlo+=w;\n\t\tro-=w;\n\t}\n\tvoid show(){\n\t\t/*dmp(lo);\n\t\tfor(auto kv:left)\n\t\t\t//dmp(kv);\n\t\t\tdmp(pi(kv.a+lo,kv.b));\n\t\tdmp(ro);\n\t\tfor(auto kv:right)\n\t\t\t//dmp(kv);\n\t\t\tdmp(pi(kv.a+ro,kv.b));\n\t\t*/\n\t}\n};\n\nvoid merge(ysp&a,ysp&b){\n\tif(a.size() t[nmax];\nvc obs[nmax];\nysp buf[nmax];\n\nvoid dfs(int v,int p){\n\tsort(all(obs[v]));\n\tfor(auto z:obs[v]){\n\t\tbuf[v].insertright(z.a*2,z.b);\n\t\tbuf[v].insertleft(z.a*2+2,z.b);\n\t}\n\tfor(auto e:t[v])if(e.a!=p){\n\t\tdfs(e.a,v);\n\t\tbuf[e.a].Expand(e.b*2);\n\t\tmerge(buf[v],buf[e.a]);\n\t}\n\tdmp(v);\n\tdmp(maxflow);\n\tbuf[v].show();\n}\n\nsigned main(){\n\tcin.tie(0);\n\tios::sync_with_stdio(0);\n\tcout<>n;\n\trep(_,n-1){\n\t\tint u,v,l;cin>>u>>v>>l;\n\t\tu--;v--;\n\t\tl*=vmax;\n\t\tl-=2;\n\t\tt[u].eb(v,l);\n\t\tt[v].eb(u,l);\n\t}\n\t\n\tint ans=0;\n\tint k;cin>>k;\n\trep(_,k){\n\t\tint d,f,p;cin>>d>>f>>p;\n\t\td*=vmax;\n\t\tp--;\n\t\tobs[p].eb(d,f);\n\t\tans+=f;\n\t}\n\t\n\tdfs(0,-1);\n\tdmp(maxflow);\n\tbuf[0].show();\n\tbuf[0].Expand(inf);\n\tdmp(maxflow);\n\t\n\tcout<\n\nusing namespace std;\n\nconst int inf = 0x3f3f3f3f;\n\nnamespace flow {\nstruct edge_t {\n int to, cap, rev;\n\n edge_t(int t, int c, int r) {\n to = t;\n cap = c;\n rev = r;\n }\n};\n\nint n, source, sink, answer;\nvector> adj;\nvector dist, current;\n\nvoid init(int v, int s, int t) {\n n = v;\n source = s;\n sink = t;\n answer = 0;\n adj.resize(n);\n dist.resize(n);\n current.resize(n);\n}\n\nvoid add(int x, int y, int c) {\n adj[x].push_back(edge_t(y, c, adj[y].size()));\n adj[y].push_back(edge_t(x, 0, adj[x].size() - 1));\n}\n\nbool bfs() {\n queue q;\n for (int i = 0; i < n; ++i) {\n dist[i] = -1;\n }\n dist[source] = 0, q.push(source);\n while (!q.empty()) {\n int x = q.front();\n q.pop();\n for (auto e : adj[x]) {\n if (e.cap && !~dist[e.to]) {\n dist[e.to] = dist[x] + 1;\n if (e.to == sink) {\n return true;\n }\n q.push(e.to);\n }\n }\n }\n return false;\n}\n\nint dfs(int x, int f) {\n if (x == sink) {\n return f;\n }\n for (int &i = current[x]; ~i; --i) {\n edge_t &e = adj[x][i];\n if (e.cap && dist[e.to] == dist[x] + 1) {\n int w = dfs(e.to, min(e.cap, f));\n if (w) {\n e.cap -= w;\n adj[e.to][e.rev].cap += w;\n return w;\n }\n }\n }\n return 0;\n}\n\nint max_flow() {\n while (bfs()) {\n for (int i = 0; i < n; ++i) {\n current[i] = adj[i].size() - 1;\n }\n while (true) {\n int flow = dfs(source, inf);\n if (!flow) {\n break;\n }\n answer += flow;\n }\n }\n return answer;\n}\n}\n\nusing flow::source;\nusing flow::sink;\nusing flow::init;\nusing flow::add;\nusing flow::max_flow;\n\nconst int N = 100005;\n\nint n, m, total, day[N], fish[N], lake[N], size[N], depth[N];\nvector> edges, adj[N];\nvector all, event[N];\nbool visit[N];\n\nvoid find_root(int x, int p, int s, int &root) {\n bool flag = true;\n size[x] = 1;\n for (auto e : adj[x]) {\n int y = e.first;\n if (y != p && !visit[y]) {\n find_root(y, x, s, root);\n size[x] += size[y];\n flag &= size[y] <= s >> 1;\n }\n }\n flag &= size[x] >= s >> 1;\n if (flag) {\n root = x;\n }\n}\n\nvoid find_size(int x, int p, bool insert) {\n size[x] = 1;\n for (auto e : adj[x]) {\n int y = e.first;\n if (y != p && !visit[y]) {\n depth[y] = depth[x] + e.second;\n find_size(y, x, true);\n size[x] += size[y];\n }\n }\n if (insert) {\n for (auto i : event[x]) {\n all.push_back(i);\n }\n }\n}\n\nvoid divide(int x, int s) {\n int root;\n find_root(x, 0, s, root);\n visit[x = root] = true;\n depth[x] = 0;\n all.clear();\n find_size(x, 0, false);\n vector> by_sub;\n for (auto i : all) {\n by_sub.push_back(make_pair(day[i] - depth[lake[i]], i));\n }\n sort(by_sub.begin(), by_sub.end());\n for (int i = 1; i < by_sub.size(); ++i) {\n edges.emplace_back(total + i, total + i + 1);\n }\n for (int i = 0; i < by_sub.size(); ++i) {\n edges.emplace_back(total + i + 1, by_sub[i].second + m);\n }\n for (auto i : all) {\n int limit = day[i] + depth[lake[i]], bound = lower_bound(by_sub.begin(), by_sub.end(), make_pair(limit, 0)) - by_sub.begin();\n if (bound != by_sub.size()) {\n edges.emplace_back(i, total + bound + 1);\n }\n }\n for (auto i : event[x]) {\n int limit = day[i] + depth[lake[i]], bound = lower_bound(by_sub.begin(), by_sub.end(), make_pair(limit, 0)) - by_sub.begin();\n if (bound != by_sub.size()) {\n edges.emplace_back(i, total + bound + 1);\n }\n }\n total += by_sub.size();\n by_sub.clear();\n for (auto i : event[x]) {\n by_sub.push_back(make_pair(day[i] - depth[lake[i]], i));\n }\n sort(by_sub.begin(), by_sub.end());\n for (int i = 1; i < by_sub.size(); ++i) {\n edges.emplace_back(total + i, total + i + 1);\n }\n for (int i = 0; i < by_sub.size(); ++i) {\n edges.emplace_back(total + i + 1, by_sub[i].second + m);\n }\n for (auto i : all) {\n int limit = day[i] + depth[lake[i]], bound = lower_bound(by_sub.begin(), by_sub.end(), make_pair(limit, 0)) - by_sub.begin();\n if (bound != by_sub.size()) {\n edges.emplace_back(i, total + bound + 1);\n }\n }\n total += by_sub.size();\n by_sub.clear();\n for (auto i : event[x]) {\n by_sub.push_back(make_pair(day[i], i));\n }\n sort(by_sub.begin(), by_sub.end());\n for (int i = 1; i < by_sub.size(); ++i) {\n edges.emplace_back(total + i, total + i + 1);\n edges.emplace_back(by_sub[i - 1].second, total + i + 1);\n }\n for (int i = 0; i < by_sub.size(); ++i) {\n edges.emplace_back(total + i + 1, by_sub[i].second + m);\n }\n total += by_sub.size();\n for (auto e : adj[x]) {\n if (!visit[e.first]) {\n divide(e.first, size[e.first]);\n }\n }\n}\n\nint main() {\n#ifdef wxh010910\n freopen(\"input.txt\", \"r\", stdin);\n#endif\n scanf(\"%d\", &n);\n for (int i = 1; i < n; ++i) {\n int x, y, w;\n scanf(\"%d %d %d\", &x, &y, &w);\n adj[x].push_back(make_pair(y, w));\n adj[y].push_back(make_pair(x, w));\n }\n scanf(\"%d\", &m);\n for (int i = 1; i <= m; ++i) {\n scanf(\"%d %d %d\", &day[i], &fish[i], &lake[i]);\n event[lake[i]].push_back(i);\n }\n total = m << 1 | 1;\n divide(1, n);\n init(total + 1, 0, m << 1 | 1);\n for (auto e : edges) {\n add(e.first, e.second, inf);\n }\n int answer = 0;\n for (int i = 1; i <= m; ++i) {\n add(source, i, fish[i]);\n add(i + m, sink, fish[i]);\n answer += fish[i];\n }\n printf(\"%d\\n\", answer - max_flow());\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9b9c4916b1cc14a2ae207fd96bed7e9e", "src_uid": "52bf61e1be144044d434cf597dcd6e90", "difficulty": 3400.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define int LL\ntypedef long long LL;\n#define pii pair \n\nconst int RLEN=1<<18|1;\ninline char nc() {\n\tstatic char ibuf[RLEN],*ib,*ob;\n\t(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));\n\treturn (ib==ob) ? -1 : *ib++;\n}\ninline int rd() {\n\tchar ch=nc(); int i=0,f=1;\n\twhile(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}\n\twhile(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}\n\treturn i*f;\n}\n\nconst int N=1e5+50;\nconst LL INF=0x3f3f3f3f3f3f3f3f;\n\nint n,q; LL det[N]; \nvector edge[N];\nvector ask[N];\n\nstruct Myset {\n\tint id;\n\tstruct data {\n\t\tLL first,second; int id;\n\t\tdata(LL first,LL second,int id) : first(first), second(second), id(id) {}\n\t\tfriend inline bool operator <(const data &a,const data &b) { \n\t\t\tint posa=a.first+((a.second>0) ? -det[a.id] : det[a.id]),\n\t\t\t\tposb=b.first+((b.second>0) ? -det[b.id] : det[b.id]);\n\t\t\tif(posa!=posb) return posa Set; \n\ttypedef Set :: iterator it;\n\tinline it prev(it t) {return --t;}\n\tinline it suff(it t) {return ++t;}\n\tSet *s;\n\tset *dis;\n\tinline int sgn(int x) {return (x>0) ? 1 : 0;}\n\tMyset() {s=new Set; dis=new set ;}\n\tinline LL getpos(it t) {return t->first+((t->second<0) ? det[t->id] : -det[t->id]);}\n\tinline void del_dis(it x,it y) {\n\t\tif(sgn(x->second) || !sgn(y->second)) return;\n\t\tdis->erase(dis->find(pii(y->first-x->first,y->first)));\n\t} \n\tinline void inc_dis(it x,it y) {\n\t\tif(sgn(x->second) || !sgn(y->second)) return;\n\t\tdis->insert(pii(y->first-x->first,y->first));\n\t}\n\tinline void _erase(it x) {\n\t\tif(x!=s->begin()) del_dis(prev(x),x);\n\t\tif(x!=--s->end()) del_dis(x,suff(x));\n\t\tif(x!=s->begin() && x!=--s->end()) inc_dis(prev(x),suff(x));\n\t\ts->erase(x);\n\t}\n\tinline void add(int pos,int d) {\n\t\tif(!d) return;\n\t\tit nxt=s->lower_bound(data(pos-det[id],-INF,id));\n\t\tif(nxt==s->end() || getpos(nxt) !=pos) {\n\t\t\tif(s->size()>=2 && getpos(s->begin())end())>pos) del_dis(prev(nxt),nxt); \n\t\t\tdata temp=data(pos+((d<0)?-det[id]:det[id]),d,id);\n\t\t\tit now=s->insert(temp).first;\n\t\t\tif(nxt!=s->end()) inc_dis(now,nxt);\n\t\t\tif(now!=s->begin()) inc_dis(prev(now),now);\n\t\t} else {\n\t\t\tdata temp=*nxt; _erase(nxt);\n\t\t\tif(!(temp.second+d)) return;\n\t\t\tif(temp.second<0 && temp.second+d>0) temp.first+=2*det[id];\n\t\t\tif(temp.second>0 && temp.second+d<0) temp.first-=2*det[id]; \n\t\t\ttemp.second+=d;\n\t\t\tit nxt=s->insert(temp).first;\n\t\t\tif(nxt!=--s->end()) inc_dis(nxt,suff(nxt));\n\t\t\tif(nxt!=s->begin()) inc_dis(prev(nxt),nxt);\n\t\t}\n\t}\n\tinline void md(int pos,int d) {add(pos,d); add(pos+1,-d);}\n\tinline void mv(int d) {\n\t\tif(!d) return;\n\t\twhile(dis->size() && dis->begin()->first<=(d+det[id])*2) {\n\t\t\tit nxt=s->lower_bound(data(dis->begin()->second-2*det[id],-INF,id));\n\t\t\tif(nxt->second==-prev(nxt)->second) _erase(prev(nxt)), _erase(nxt);\n\t\t\telse if(nxt->second>-prev(nxt)->second) {\n\t\t\t\tLL val=prev(nxt)->second;\n\t\t\t\t_erase(prev(nxt));\n\t\t\t\tadd(nxt->first-det[id],val);\n\t\t\t} else {\n\t\t\t\tLL val=nxt->second; nxt=prev(nxt);\n\t\t\t\t_erase(suff(nxt));\n\t\t\t\tadd(nxt->first+det[id],val);\n\t\t\t}\n\t\t} det[id]+=d;\n\t}\n\tinline void merge(Myset &b) {\n\t\tif(s->size()size()) swap(s,b.s), swap(id,b.id), swap(dis,b.dis);\n\t\tfor(it v=b.s->begin();v!=b.s->end();++v) {\n\t\t\tdata temp=*v; temp.first+=(v->second<0) ? det[b.id] : -det[b.id];\n\t\t\tadd(temp.first,temp.second);\n\t\t}// delete b.s; delete b.dis;\n\t}\n\tinline LL getval(LL pos) {\n\t\tit nxt=s->lower_bound(data(pos-det[id],-INF,id));\t\n\t\tif(nxt!=s->end() && getpos(nxt)==pos) return nxt->second;\n\t\treturn 0;\n\t}\n//\tinline void pt() {\n//\t\tcerr<<\"delta : \"<<'\\n';\n//\t\tfor(it v=s->begin();v!=s->end();++v) cerr<second<<'\\n';\n//\t\tcerr<<\"dis : \"<<'\\n';\n//\t\tfor(auto v=dis->begin();v!=dis->end();++v) cerr<first-2*det[id]<<' '<second-det[id]<<'\\n'; \n//\t\tcerr<<'\\n';\n//\t}\n} s[N];\n\n\ninline void dfs(int x,int f) {\n\t\n\tfor(auto v:edge[x]) {\n\t\tif(v.first==f) continue;\n\t\tdfs(v.first,x); \n\t\tfor(auto &d:ask[v.first]) {\n\t\t\tLL delta=max(0ll,max(-s[v.first].getval(d.first),s[v.first].getval(d.first+1)));\n\t\t\td.second=max(0ll,d.second-delta);\n\t\t}\n\t\ts[v.first].mv(1); \n\t\tfor(auto d:ask[v.first]) s[v.first].md(d.first,d.second);\n\t\ts[v.first].mv(v.second-1);\n\t\t\n//\t\tcerr<begin();v!=s[0].s->end();++v) {\n\t\tsum+=v->second; \n\t\tmx=max(mx,sum);\n\t} cout<\n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define F first\n#define S second\nconst int N = 55;\nconst int inf = 1e9 + 5;\nconst int mod = 1e9 + 7;\ntypedef long long ll;\nint n, m;\npair gg[N];\n\nint x[10], y[10];\nint sz[1000];\nvector aa[1000];\nbool vis[1000];\nmap g, id;\n\nvoid gao(int x, set & s) {\n while (x > 0) {\n s.insert(x);\n x /= 2;\n }\n}\n\nvoid dfs(int x, long long b, ll & ans) {\n vis[x] = true;\n ans += b * sz[x];\n ans %= mod;\n for (int i: aa[x]) {\n if (!vis[i]) {\n dfs(i, b, ans);\n }\n }\n vis[x] = false;\n}\n\nint calc(int x) {\n int left = x;\n int right = x;\n int re = 0;\n while (true) {\n if (left > n) {\n return re;\n }\n re += min(right, n) - left + 1;\n right = right * 2 + 1;\n left = left * 2;\n }\n return re;\n}\n\nint brute(){\n set s;\n long long ans = 0;\n memset(x, 0, sizeof(x));\n memset(y, 0, sizeof(y));\n memset(sz, 0, sizeof(sz));\n memset(aa, 0, sizeof(aa));\n memset(vis, 0, sizeof(vis));\n g.clear();\n id.clear();\n for (int i = 0; i < m; i++) {\n x[i] = gg[i].F;\n y[i] = gg[i].S;\n gao(x[i], s);\n gao(y[i], s);\n }\n s.insert(1);\n for (int i: s) {\n if (s.find(2 * i) == s.end() && s.find(2 * i + 1) == s.end()) {\n g[i] = calc(i);\n } else {\n g[i] = 1;\n if (2 * i <= n && s.find(2 * i) == s.end()) {\n g[2 * i] = calc(2 * i);\n }\n if (2 * i + 1 <= n && s.find(2 * i + 1) == s.end()) {\n g[2 * i + 1] = calc(2 * i + 1);\n }\n }\n }\n for (pair sth: g) {\n int i = sth.first;\n int u = (int)id.size();\n id[i] = u;\n sz[u] = g[i];\n }\n int nn = (int)g.size();\n for (pair sth: id) {\n int i = sth.first;\n if (i == 1) {\n continue;\n }\n int child = id[i];\n int father = id[i / 2];\n aa[child].push_back(father);\n aa[father].push_back(child);\n }\n for (int i = 0; i < m; i++) {\n int first = id[x[i]];\n int second = id[y[i]];\n aa[first].push_back(second);\n aa[second].push_back(first);\n }\n for (int i = 0; i < nn; i++) {\n dfs(i, sz[i], ans);\n }\n return (int)ans;\n}\nint levels = 1;\nint le, re;\nint lca(int a, int b){\n set s;\n while(a > 0){\n s.insert(a);\n a /= 2;\n }\n while(b > 0){\n if(s.count(b)){\n return b;\n }\n b /= 2;\n }\n return 1;\n}\nint get(int v){\n int l = v;\n int r = v;\n int ans = 0;\n while(r < (1 << (levels - 1))){\n ans += r - l + 1;\n r = r * 2 + 1;\n l = l * 2;\n }\n r = min(r, re);\n l = max(le, l);\n if(l <= r)\n ans += r - l + 1;\n return ans;\n}\nvector paths(int a, int b){\n vector A, B;\n int p = lca(a, b);\n while(a != p){\n A.push_back(a);\n a /= 2;\n }\n while(b != p){\n B.push_back(b);\n b /= 2;\n }\n reverse(B.begin(), B.end());\n A.push_back(p);\n for(auto it : B){\n A.push_back(it);\n }\n return A;\n}\nvoid upd(int & a, int b){\n a += b;\n if(a >= mod) a -= mod;\n}\nint gdfs(int v, int p, set & marked, set & path){\n if(v < 1 || v > n) return 0;\n if(path.count(v)){\n return 0;\n }\n if(!marked.count(v)){\n return get(v);\n }\n int ans = 1;\n if(v / 2 != p)\n upd(ans, gdfs(v / 2, v, marked, path));\n if(v + v != p)\n upd(ans, gdfs(v + v, v, marked, path));\n if(v + v + 1 != p){\n upd(ans, gdfs(v + v + 1, v, marked, path));\n }\n return ans;\n}\nint fnd(vector > cur){\n vector line;\n\n for(int i = 0; i < (int)cur.size(); ++i){\n line.push_back(cur[i].first);\n line.push_back(cur[i].second);\n }\n // if equal then answer will be zero\n for(int i = 0; i < (int)line.size(); ++i){\n for(int j = 0; j < (int)line.size(); ++j){\n if(abs(i - j) > 1){\n if(line[i] == line[j]) return 0;\n }\n }\n }\n set path;\n for(int i = 0; i < (int)cur.size(); ++ i){\n path.insert(cur[i].F);\n path.insert(cur[i].S);\n if(i + 1 < (int)cur.size()){\n vector path1 = paths(cur[i].S, cur[i + 1].F);\n for(auto it : path1){\n if(it != cur[i].S && path.count(it)){\n return 0;\n }\n path.insert(it);\n }\n }\n }\n \n int a = line[0];\n int b = line.back();\n int p = lca(a, b);\n bool both = 1;\n vector A;\n vector B;\n while(a != (p / 2)){\n if(path.count(a)){\n if(a != line[0] && a != line.back()){\n both = 0;\n break;\n }\n }\n A.push_back(a);\n a /= 2;\n }\n while(b != (p / 2)){\n if(path.count(b)){\n if(b != line[0] && b != line.back()){\n both = 0;\n break;\n }\n }\n B.push_back(b);\n b /= 2;\n }\n a = line[0];\n b = line.back();\n set marked;\n for(auto it : path){\n int cur = it;\n while(cur > 0){\n marked.insert(cur);\n cur /= 2;\n }\n }\n if(!both){\n path.erase(a);\n int cnt1 = gdfs(a, -1, marked, path);\n path.insert(a);\n \n path.erase(b);\n int cnt2 = gdfs(b, -1, marked, path);\n path.insert(b);\n return (cnt1 * 1ll * cnt2) % mod;\n }\n B.pop_back();\n reverse(B.begin(), B.end());\n for(auto it : B){\n A.push_back(it);\n }\n int ans = 0;\n int sz = (int)A.size();\n for(int i = 0; i + 1 < (int)A.size(); ++i){\n if(A[i] == a) path.erase(a);\n if(i > 0) path.insert(A[i - 1]);\n if(i + 1 < sz) path.insert(A[i + 1]);\n \n int cnt1 = gdfs(A[i], -1, marked, path);\n if(i > 0) path.erase(A[i - 1]);\n if(i + 1 < sz) path.erase(A[i + 1]);\n path.insert(a);\n path.erase(b);\n path.insert(A[i]);\n int cnt2 = gdfs(b, -1, marked, path);\n int cur_ans = (cnt1 * 1ll * cnt2) % mod;\n upd(ans, cur_ans);\n path.erase(A[i]);\n path.insert(a);\n path.insert(b);\n }\n return ans;\n}\nint solve(){\n levels = 1;\n while((1 << levels) - 1 < n) ++levels;\n int tmp = (1 << levels) - 1 - n;\n le = (1 << (levels - 1));\n re = (1 << levels) - 1 - tmp;\n int ans = (n * 1ll * n) % mod;\n //int ans = 0;\n vector >, int > > v;\n for(int msk = 1; msk < (1 << m); ++msk){\n int cnt = 0;\n vector > cur1;\n for(int i = 0; i < m; ++i){\n if((1 << i) & msk){\n cnt++;\n cur1.push_back(gg[i]);\n }\n }\n for(int new_msk = 0; new_msk < (1 << cnt); ++new_msk){\n vector > cur;\n for(int i = 0; i < cnt; ++i){\n if((1 << i) & new_msk){\n cur.push_back(cur1[i]);\n }\n else{\n cur.push_back({cur1[i].S, cur1[i].F});\n }\n }\n sort(cur.begin(), cur.end());\n do{\n v.push_back({cur, msk});\n //upd(ans, fnd(cur));\n }while(next_permutation(cur.begin(), cur.end()));\n }\n }\n sort(v.begin(), v.end());\n v.erase(unique(v.begin(), v.end()), v.end());\n for(auto it : v){\n upd(ans, fnd(it.first));\n }\n return ans;\n}\nint main(){\n // I HOPE ILYUSHA WILL NOT READ THIS\n cin >> n >> m;\n for(int i = 0; i < m; ++i){\n cin >> gg[i].F >> gg[i].S;\n }\n /*for(n = 10; n <= 20; ++n){\n m = 1;\n for(int i = 1; i <= n; ++i){\n for(int j = 1; j <= n; ++j){\n if(i == j) continue;\n gg[0] = {i, j};\n if(solve() != brute()){\n cout << n << \" \" << m << endl;\n cout << i << \" \" << j << endl;\n }\n }\n }\n }*/\n //cout << \"LOL\" << endl;\n /*n = 4;\n m = 1;\n gg[0] = {1, 2};\n cout << solve() << endl;\n //cout << brute() << endl;*/\n cout << solve() << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a81e7929ef3477e97969fc2dfb2156c8", "src_uid": "250314325e3d088ceedaba7dcde762f1", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#include\n\ntypedef long long LL;\nusing namespace std;\n\nconst int mod = 1000000007, N = 1010;\n\nset s;\nmap g, id;\nvector a[N];\nbool vis[N];\nint n, m, x[9], y[9], sz[N];\nLL ans;\n\nvoid Insert(int x) {\n\tfor(; x; x >>= 1) s.insert(x);\n}\n\nvoid dfs(int t, LL b) {\n\tvis[t] = true;\n\t(ans += b * sz[t]) %= mod;\n\tfor(int i: a[t]) {\n\t\tif(!vis[i]) dfs(i, b);\n\t}\n\tvis[t] = false;\n}\n\nint calc(int x) {\n\tint L = x, R = x, ret = 0;\n\twhile(L <= n) {\n\t\tret += min(R, n) - L + 1;\n\t\tL <<= 1;\n\t\tR = R << 1 | 1;\n\t}\n\treturn ret;\n}\n\nint main() {\n\tscanf(\"%d%d\", &n, &m);\n\tfor(int i = 0; i < m; ++i) {\n\t\tscanf(\"%d%d\", x + i, y + i);\n\t\tInsert(x[i]), Insert(y[i]);\n\t}\n\ts.insert(1);\n\tfor(int i: s) {\n\t\tif(s.find(i << 1) == s.end() && s.find(i << 1 | 1) == s.end()) {\n\t\t\tg[i] = calc(i); //\u7f29\u70b9 \u4ee3\u8868\u51e0\u4e2a\u8282\u70b9 \n\t\t} else {\n\t\t\tg[i] = 1;\n\t\t\tif(i + i <= n && s.find(i << 1) == s.end()) {\n\t\t\t\tg[i << 1] = calc(i << 1);\n\t\t\t}\n\t\t\tif(i + i + 1 <= n && s.find(i + i + 1) == s.end()) {\n\t\t\t\tg[i + i + 1] = calc(i + i + 1);\n\t\t\t}\n\t\t}\n\t}\n\tfor(pair sth: g) {//\u79bb\u6563\u5316 \n\t\tint i = sth.first, u = id.size();\n\t\tid[i] = u;//u\u4e3a\u79bb\u6563\u7f16\u53f7 \n\t\tsz[u] = g[i];\n\t}\n\tint cnt = g.size();\n\tfor(pair sth: id) {\n\t\tint i = sth.first;\n\t\tif(i == 1) continue;\n\t\tint son = id[i], f = id[i >> 1];\n\t\te[son].push_back(f);\n\t\te[f].push_back(son);\n\t}\n\tfor(int i = 0; i < m; ++i) {\n\t\tint fst = id[x[i]], snd = id[y[i]];\n\t\te[fst].push_back(snd);\n\t\te[snd].push_back(fst);\n\t}\n\tfor(int i = 0; i < cnt; ++i) dfs(i, sz[i]);\n\tcout << ans << '\\n';\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "27be225b632a31f154e0899ddb165e9c", "src_uid": "250314325e3d088ceedaba7dcde762f1", "difficulty": 2800.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\nconst int MAXN=255;\n\nconst int Mod=1000000007;\ninline void add_mod(int &x,int y)\n{\n x=(x+y mp;\ninline int get_id(int x)\n{\n if(!mp[x])mp[x]=(int)mp.size();\n return mp[x];\n}\n\nvector e[MAXN];\nvoid add_edge(int u,int v)\n{\n e[u].push_back(v);\n e[v].push_back(u);\n}\n\ninline int cal_size(int u,int n,int d)\n{\n int t=u,c=0,res;\n while(t)c++,t>>=1;\n res=(1<<(d-c+1))-1,t=c;\n while(t>=1;\n t=v[i];\n while(t)get_id(t),t>>=1;\n }\n for(auto &t:mp)\n {\n int u=t.first,id=t.second;\n if(u>1)add_edge(get_id(u),get_id(u>>1));\n num[id]=cal_size(u,n,d);\n }\n pre_dp(1,0);\n for(int i=0;i\nusing namespace std;\n\nconst int maxn=160;\ntypedef long long LL;\n\nstruct LINK\n{\n\tint id, next;\n};\n\nstruct connect\n{\n\tint u, v;\n};\n\nint n, m;\nint total, sum;\nint now;\nconnect a[maxn];\nint num[maxn];\nmap hash;\nint h[maxn];\nLINK t[maxn*maxn*2];\nLL size[maxn];\nLL ans;\nbool vis[maxn];\n\n\nvoid insert(int cur)\n{\n\twhile (cur)\n\t{\n\t\tif (!hash[cur])\n\t\t{\n\t\t\tnum[++sum]=cur;\n\t\t\thash[cur]=sum;\n\t\t}\n\t\telse return;\n\t\tcur>>=1;\n\t}\n}\nvoid join(int u, int v)\n{\n\tt[now].id=v; t[now].next=h[u]; h[u]=now++;\n\tt[now].id=u; t[now].next=h[v]; h[v]=now++;\n}\nvoid read()\n{\n\tscanf(\"%d%d\", &n, &m);\n\ttotal=0;\n\twhile ((1<>=1;\n\t}\n\n\tint s=1;\n\tif ((cur<<1)<=n && !hash[cur<<1]) s+=(1<<(total-height))-1;\n\tif ((cur<<1 | 1)<=n && !hash[cur<<1 | 1]) s+=(1<<(total-height))-1;\n\treturn s;\n}\nvoid build(int cur)\n{\n\twhile (cur!=1)\n\t{\n\t\tjoin(hash[cur], hash[cur>>1]);\n\t\tcur>>=1;\n\t}\n}\nvoid dfs(int cur)\n{\n\tif (vis[cur]) return;\n\tans+=size[cur];\n\tvis[cur]=true;\n\tfor (int i=h[cur]; i>-1; i=t[i].next)\n\t\tdfs(t[i].id);\n\tvis[cur]=false;\n}\nvoid solve()\n{\n\tfor (int i=1; i<=sum; ++i)\n\t{\n\t\tsize[i]=calc_size(num[i]);\n\t\tans+=size[i]*size[i];\n\t}\n\tfor (int i=1; i<=sum; ++i) h[i]=-1;\n\tfor (int i=1; i<=sum; ++i)\n\t\tbuild(num[i]);\n\tfor (int i=1; i<=m; ++i)\n\t\tjoin(hash[a[i].u], hash[a[i].v]);\n\n\tfor (int i=1; i<=sum; ++i)\n\t{\n\t\tfor (int j=1; j<=sum; ++j) vis[j]=false;\n\t\tdfs(i);\n\t\tans-=size[i];\n\t}\n\tprintf(\"%I64d\\n\", ans);\n}\nint main()\n{\n\tread();\n\tif (m==0) printf(\"%I64d\\n\", LL(n)*LL(n));\n\telse solve();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c1606fd91aba8bce22858b620e6bda25", "src_uid": "250314325e3d088ceedaba7dcde762f1", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#pragma comment(linker, \"/STACK:256000000\")\n\n#define _CRT_SECURE_NO_DEPRECATE\n#define _CRT_SECURE_NO_WARNINGS\n#define _USE_MATH_DEFINES\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long int64;\ntypedef unsigned long long uint64;\ntypedef pair pii;\ntypedef pair pll;\nconst int INF = (int)(1e9 + 1337);\nconst int64 LINF = (int64)(4e18);\nconst double EPS = 1e-11;\n#define sq(x) ((x)*(x))\n#define FAIL() ((*(int*)(0))++)\nconst int HMOD = 1000000009;\nconst int HBASE = 1003;\n\nconst int MAXN = 51;\n\n//inline int add(int a, int b)\n//{\n//\ta += b;\n//\tif (a >= HMOD)\n//\t{\n//\t\ta -= HMOD;\n//\t}\n//\treturn a;\n//}\n//\n//inline int sub(int a, int b)\n//{\n//\ta -= b;\n//\tif (a < 0)\n//\t{\n//\t\ta += HMOD;\n//\t}\n//\treturn a;\n//}\n//\n//inline int mul(int a, int b)\n//{\n//\treturn int64(a) * b % HMOD;\n//}\n\nint64 s;\nint add[MAXN];\nint64 dp[MAXN][MAXN << 1][2];\nint64 ans;\n\nint64 get_min_path(int64 x, int len)\n{\n\treturn x * ((1 << len) - 1);\n}\n\nint64 get_max_path(int64 x, int len)\n{\n\treturn x * ((1 << len) - 1) + add[len - 1];\n}\n\nint64 get_max_lca(int lena, int lenb)\n{\n\tint64 l = 1LL, r = s, lca2 = 0;\n\twhile (l <= r)\n\t{\n\t\tint64 mid = (l + r) >> 1;\n\t\tint64 sum = mid;\n\t\tif (lena)\n\t\t{\n\t\t\tsum += get_min_path(mid << 1, lena - 1);\n\t\t}\n\t\tif (lenb)\n\t\t{\n\t\t\tsum += get_min_path((mid << 1) + 1, lenb - 1);\n\t\t}\n\t\tif (sum <= s)\n\t\t{\n\t\t\tlca2 = mid;\n\t\t\tl = mid + 1;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tr = mid - 1;\n\t\t}\n\t}\n\treturn lca2;\n}\n\nint64 get_min_lca(int lena, int lenb)\n{\n\tint64 l = 1LL, r = s, lca1 = LINF;\n\twhile (l <= r)\n\t{\n\t\tint64 mid = (l + r) >> 1;\n\t\tint64 sum = mid;\n\t\tif (lena)\n\t\t{\n\t\t\tsum += get_max_path(mid << 1, lena - 1);\n\t\t}\n\t\tif (lenb)\n\t\t{\n\t\t\tsum += get_max_path((mid << 1) + 1, lenb - 1);\n\t\t}\n\t\tif (sum <= s)\n\t\t{\n\t\t\tlca1 = mid;\n\t\t\tr = mid - 1;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tl = mid + 1;\n\t\t}\n\t}\n\treturn lca1;\n}\n\nint64 calc_dp(int lena, int lenb, int pop, int64 som)\n{\n\tmemset(dp, 0, sizeof(dp));\n\tint slen = 1;\n\twhile (1 << (slen + 1) <= som)\n\t{\n\t\tslen++;\n\t}\n\tdp[0][0][0] = 1;\n\tfor (int l = 1; l <= slen; l++)\n\t{\n\t\tint la = (l == lena + 1 ? 1 : 0);\n\t\tint ra = (l == lena ? 0 : 1);\n\t\tint lb = (l == lenb || l == lenb + 1 ? 1 : 0);\n\t\tint rb = 1;\n\t\tfor (int a = la; a <= ra; a++)\n\t\t{\n\t\t\tfor (int b = lb; b <= rb; b++)\n\t\t\t{\n\t\t\t\tfor (int m = 0; m <= 1; m++)\n\t\t\t\t{\n\t\t\t\t\tint cnt = a + b + m;\n\t\t\t\t\tif (((som >> (l - 1)) & 1LL) != int64(cnt & 1))\n\t\t\t\t\t{\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tfor (int p = a + b; p <= (l << 1); p++)\n\t\t\t\t\t{\n\t\t\t\t\t\tdp[l][p][(cnt >> 1) & 1] += dp[l - 1][p - a - b][m];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn dp[slen][pop][0];\n}\n\nvoid solve()\n{\n\tscanf (\"%lld\", &s);\n\tfor (int lena = 0; lena <= 50; lena++)\n\t{\n\t\tfor (int lenb = 0; lenb <= 50; lenb++)\n\t\t{\n\t\t\tint64 lca1 = get_min_lca(lena, lenb);\n\t\t\tint64 lca2 = get_max_lca(lena, lenb);\n\t\t\tif (lca1 == 0 || lca2 == LINF)\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t//assert(lca1 == lca2);\n\t\t\tprintf(\"\n\t\t\tint64 sum = s - (lca1 - 1) * ((1 << (lena + 1)) + (1 << (lenb + 1)) - 3);\n\t\t\tsum++;\n\t\t\tfor (int pop = 2; pop <= lena + lenb + 2; pop++)\n\t\t\t{\n\t\t\t\tint64 som = sum + pop;\n\t\t\t\tif (som <= 0 || som & 1LL)\n\t\t\t\t{\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tsom >>= 1;\n\t\t\t\tans += calc_dp(lena, lenb, pop, som);\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%I64d\\n\", ans);\n}\n\nvoid precalc()\n{\n\tfor (int i = 1; i < MAXN; i++)\n\t{\n\t\tadd[i] = add[i - 1] + ((1 << i) - 1);\n\t}\n}\n\nint main()\n{\n#ifdef _MY_DEBUG\n\tfreopen(\"input.txt\", \"rt\", stdin); freopen(\"output.txt\", \"wt\", stdout);\n#else\n\t\n#endif\n\tsrand(333);\n\n\tdouble st = clock();\n\n\tprecalc();\n\tint t = 1;\n\tscanf (\"%d\", &t); for (int i = 0; i < t; i++)\n\t{\n\t\tsolve();\n\t}\n\n\t//fprintf(stderr, \"%.3lf\\n\", (clock() - st) / CLOCKS_PER_SEC);\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2705bf275f35f5cd316a53e0ec17c4db", "src_uid": "c142f8bc5252e739035992926545c251", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "#include\n#define fp(i,a,b) for(register int i=a,I=b+1;iI;--i)\n#define go(u) for(register int i=fi[u],v=e[i].to;i;v=e[i=e[i].nx].to)\n#define file(s) freopen(s\".in\",\"r\",stdin),freopen(s\".out\",\"w\",stdout)\ntemplateinline bool cmax(T&a,const T&b){return ainline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}\nusing namespace std;\nconst int N=52;\ntypedef long long ll;\nint m,p;ll n,ans,mi[N],f[N][2*N][2];\ninline ll sub(ll a,ll b){return a>=b?a-b:a;}\ninline ll calc(ll s,ll q,int a,int b,int t){\n memset(f[p],0,sizeof f[p]);f[p][0][0]=1;\n fp(i,1,log2(s)+1){\n int d=(s>>i)&1;p^=1;memset(f[p],0,sizeof f[p]);\n fp(j,0,2*i-2)fp(k,0,1)if(f[p^1][j][k])\n fp(x,0,1)if(!x||i0){\n ret=n-x*(mi[i]-1);\n fd(j,i-1,0)ret=sub(ret,mi[j]-1);\n if(!ret)++ans;\n }\n fp(i,1,m)for(int j=1;mi[j]-1<=n;++j)\n if((x=(n-mi[j]+1)/(mi[i+1]+mi[j+1]-3))>0){\n ret=(n-mi[j]+1)-x*(mi[i+1]+mi[j+1]-3);\n if(!ret){++ans;continue;}\n if(i==1&&j==1){ans+=s==5*x+1;continue;}\n fp(k,1,i+j)if(~(ret+k)&1)\n ans+=calc(ret+k,x,i,j,k);\n }\n printf(\"%lld\",ans);\nreturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "af5c91111705f80e855ae404841a7b7d", "src_uid": "c142f8bc5252e739035992926545c251", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nlong long bit[70],f[70][130][2],ans=0;\nint end=0;\nlong long dp(long long sum,int tot,int l1,int l2){\n\tint lg=log2(sum);\n\tmemset(f,0,sizeof(f));\n\tf[0][0][0]=1;\n\tfor(int i=1;i<=lg;i++){\n\t\tlong long d=(sum>>i)&1;\n\t\tint ed=i*2-2;\n\t\tfor(int j=0;j<=ed;j++) for(int k=0;k<=1;k++) for(int p1=0;p1<=1;p1++) for(int p2=0;p2<=1;p2++){\n\t\t\tif((in) break;\n\t\ts=n%(bit[i]-1);\n\t\tfor(int j=i;j>=1;j--) if(s>=bit[j]-1) s-=bit[j]-1;\n\t\tif(!s) ans++;\n\t}\n\tfor(int l1=1;l1\nusing namespace std;\n#define rep(i,j,k) for(int i=j;i<=k;++i)\ntypedef long long ll;\ntypedef double db;\nll bit[65],f[65][120][2];\ninline ll dp(ll s,int tot,int h1,int h2){\n\tmemset(f,0,sizeof f);f[0][0][0]=1;\n\tint ed=log2(s);\n\trep(i,1,ed){\n\t\tll d=(s>>i)&1;\n\t\tint ed=i*2-2;\n\t\trep(j,0,ed) rep(k,0,1)\n\t\tf[i][j+p1+p2][(k+p1+p2)/2]+=f[i-1][j][k]; \n\t}\n\treturn f[ed][tot][0];\n} \nint main(){\n\tll x,s,res,ans=0;\n\tint ed=0;\n\tscanf(\"%lld\",&s);\n\tbit[0]=1;while(bit[ed]<=s) bit[++ed]=bit[ed-1]<<1;\n\trep(i,1,ed){\n\t\tif(bit[i]-1>s) break;\n\t\tx=s%(bit[i]-1);\n\t\tfor(int j=i;j>=1;--j) if(x>=bit[j]-1) x-=bit[j]-1;\n\t\tif(!x) ++ans;\n\t}\n\trep(h1,1,ed-1){ \n\t\tfor(int h2=1;bit[h2]-1<=s&&h20){\n\t\t\t\tres=(s-bit[h2]+1)%(bit[h1+1]+bit[h2+1]-3);\n\t\t\t\tif(res==0){\n\t\t\t\t\t++ans;continue;\n\t\t\t\t}\n\t\t\t\tif(h1==1&&h2==1){\n\t\t\t\t\tans+=(s==x*5+1);continue;\n\t\t\t\t}\n\t\t\t\trep(i,1,h1+h2) if((res+i)%2==0) ans+=dp(res+i,i,h1,h2);\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%lld\",ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2b2330dd18a13149beee439b6b9f3f2b", "src_uid": "c142f8bc5252e739035992926545c251", "difficulty": 3200.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\nint c[15];\nint ma[305];\nint cnt = 0;\nconst long long inf = 1999999999999999999ll;\nstruct matrix{\n long long a[75][75];\n friend matrix operator * (const matrix &a,const matrix &b){\n matrix c;\n for(int i = 0; i < cnt; i++){\n for (int j = 0; j < cnt; j++){\n c.a[i][j] = inf;\n }\n }\n for(int i = 0; i < cnt; i++){\n for(int j = 0; j < cnt; j++){\n for(int k = 0; k < cnt; k++){\n c.a[i][k] = min(c.a[i][k],a.a[i][j]+b.a[j][k]);\n }\n }\n }\n return c;\n }\n matrix (){\n for(int i = 0; i < 75; i++){\n for(int j = 0; j < 75; j++){\n a[i][j] = inf;\n }\n a[i][i] = 0;\n }\n }\n};\n\nmatrix a;\nmatrix mul(int x){\n if(x == 0){\n return matrix();\n }\n matrix b = mul(x/2);\n b = b*b;\n if(x % 2 == 1){ \n b = b*a;\n }\n return b;\n}\n\npair p[75];\n\nint main()\n{\n int x,k;\n int n,q;\n scanf(\"%d%d%d%d\",&x,&k,&n,&q);\n for(int i = 0; i < k; i++){\n scanf(\"%d\",&c[i]);\n }\n memset(ma, -1, sizeof(ma));\n for (int i = 0; i < (1<>1 ] ] = c[j-1];\n }\n }\n else{\n a.a[ma[i]][ma[i>>1]] = 0;\n }\n }\n int now = 1;\n for(int i = 0; i < q; i++){\n scanf(\"%d%d\",&p[i].first,&p[i].second);\n }\n sort(p, p+q);\n matrix xx;\n long long ans = 0;\n for(int i = 0; i < q; i++){\n if(p[i].first >= n-x+1){\n ans + =p[i].second;\n continue;\n }\n xx = xx*mul(p[i].first-now);\n now = p[i].first;\n for(int j = 1; j < (1<\n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\ntypedef vector> mat;\nint x, k, p, q, B, curx, n;\nll c[10],w;\nmap mp;\nvector dp,dpn;\nvector bitset;\nmat a, o, p;\nvoid pow2(mat &a) {\n\tfor (int i : bitset)\n\t\t\tfor (int j : bitset)\n\t\t\t p[i][j]=1e18;\n\tfor (int k : bitset) {\n\t\tfor (int i : bitset)\n\t\t\tfor (int j : bitset)\n\t\t\t\tp[i][j] = min(p[i][j], a[i][k] + a[k][j]);\n\t}\n\tswap(a,p);\n}\nvoid operator *=(vector &dp, mat &a) {\n\tfor(int i:bitset)\n\t dpn[i]=1e18;\n\tfor (int i : bitset) {\n\t\tfor (int j : bitset) {\n\t\t\tdpn[j] = min(dpn[j], dp[i] + a[i][j]);\n\t\t}\n\t}\n\tswap(dp, dpn);\n}\nvoid jump(ll to) {\n\ta = o;\n\tll jump = to - curx;\n\tfor (;jump;pow2(a), jump >>= 1) {\n\t\tif (jump & 1) dp *= a;\n\t}\n\tcurx = to;\n}\nint main() {\n\tios::sync_with_stdio(0), cin.tie(0);\n\tcin >> x >> k >> n >> q;\n\tB = 1 << k;\n\tdp.resize(B, 1e18);\n\tdpn.resize(B, 1e18);\n\to.resize(B, vector(B, 1e18));\n\tp.resize(B, vector(B, 1e18));\n\tfor (int b = 1;b < B;b++)\n\t\tif (__builtin_popcount(b) == x) bitset.push_back(b);\n\tdp[bitset[0]] = 0;\n\tfor (int i = 1;i <= k;i++) cin >> c[i];\n\tfor (int cur : bitset) {\n\t\tint next = cur >> 1;\n\t\tif (cur & 1) {\n\t\t\tfor (int i = 1, b = 1;i <= k;i++, b <<= 1) if (~next & b) {\n\t\t\t\to[cur][next | b] = c[i];\n\t\t\t}\n\t\t}\n\t\telse o[cur][next] = 0;\n\t}\n\tfor (int i = 1;i <= q;i++) {\n\t\tcin >> p >> w;\n\t\tif (w) mp[p] = w;\n\t}\n\tmp[n + k - x + 1] = 0;\n\tcurx = k;\n\tfor (auto it = mp.begin();curx < n + k - x;) {\n\t\tif (it->first <= curx - k) {\n\t\t\tit++; continue;\n\t\t}\n\t\tif (it->first <= curx + 1) {\n\t\t\tfor(int i:bitset)\n\t\t\t dpn[i]=1e18;\n\t\t\tcurx++;\n\t\t\tfor (int cur : bitset) {\n\t\t\t\tint next = cur >> 1;\n\t\t\t\tif (cur & 1) {\n\t\t\t\t\tfor (int i = 1, b = 1;i <= k;i++, b <<= 1) if (~next & b) {\n\t\t\t\t\t\tdpn[next | b] = min(dpn[next | b], dp[cur] + c[i] + (mp.count(curx - k + i) ? mp[curx - k + i] : 0));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse dpn[next] = min(dpn[next], dp[cur]);\n\t\t\t}\n\t\t\tswap(dp, dpn);\n\t\t}\n\t\telse jump(it->first - 1);\n\t}\n\tprintf(\"%lld\", dp[bitset[0]]);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d3b7c59a8b6cb4801a93e0e7f9c434ee", "src_uid": "e3dd409ceeba2a21890d35ceab9607eb", "difficulty": 2900.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nconst int INF = 0x3f3f3f3f;\n\nstruct Mat {\n vector > data;\n Mat(vector > &d) {\n swap(d, data);\n }\n Mat(){}\n void operator *= (const Mat &o) {\n // cout< > res(data.size(), vector(o.data[0].size(), INF));\n for(int i = 0; i < data.size(); i++) {\n for(int j = 0; j < o.data[0].size(); j++) {\n for(int k = 0; k < o.data.size(); k++) {\n res[i][j] = min(res[i][j], data[i][k] + o.data[k][j]);\n // if(data.size() == 1)\n // cout<(i)<<','<(k)<<' '<(k)<<','<(j)<<' '< > oneStep;\nstruct Stone {\n int loc, val;\n bool operator < (const Stone& o) const {\n return loc < o.loc;\n }\n} magic[25];\n\nvector &go(vector &beginState, int stepCnt, vector &res) {\n // cout<<\"go: \"<(beginState)<<' '<> i); i++) {\n if((stepCnt>>i) & 1){\n origin *= mat;\n // cout< &dp(vector &lastState, int stepCnt, int stoneAfter[201], int stoneEffect[26]) {\n // cout<<\"dp: \"< res(lastState.size());\n int dp[stepCnt+1][lastState.size()];\n memset(dp, 0x3f, sizeof dp);\n for(int i = 0; i < lastState.size(); i++) {\n dp[0][i] = lastState[i];\n }\n for(int step = 0; step < stepCnt; step++) {\n for(int cur = 1; cur < (1<>1) & (1<>1) | (1<>1;\n dp[step+1][nxt] = min(dp[step+1][nxt], dp[step][cur]);\n }\n }\n // cout<<\"dp: \";for(int i = 0; i < lastState.size(); i++) cout<(i)<<')'<<' ';\n // cout<<'\\n';\n }\n for(int i = 0; i < lastState.size(); i++) {\n lastState[i] = dp[stepCnt][i];\n }\n return lastState;\n}\n\nint main () {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n\n cin>>X>>K>>N>>Q;\n for(int i = 1; i <= K; i++) {\n cin>>jmp[i];\n }\n \n for(int i = 0; i < Q; i++) {\n cin>>magic[i].loc>>magic[i].val;\n }\n sort(magic, magic + Q);\n oneStep.resize(1< (1<>1) & (1<>1) | (1<>1] = 0;\n }\n }\n // Mat fp(oneStep);\n // cout< res;\n vector lastState(1< 0){\n // cout<= magic[i].loc){\n st_loc = magic[i].loc;\n stoneAfter[st_loc - curLoc] = ++i;\n // cout<<\"st_loc: \"<\n#include \n#include \n#include \nusing namespace std;\n\nconst int INF = 0x3f3f3f3f;\n\nstruct Mat {\n vector > data;\n Mat(vector > &d) {\n swap(d, data);\n }\n Mat(){}\n void operator *= (const Mat &o) {\n // cout< > res(data.size(), vector(o.data[0].size(), INF));\n for(int i = 0; i < data.size(); i++) {\n for(int j = 0; j < o.data[0].size(); j++) {\n for(int k = 0; k < o.data.size(); k++) {\n res[i][j] = min(res[i][j], data[i][k] + o.data[k][j]);\n // if(data.size() == 1)\n // cout<(i)<<','<(k)<<' '<(k)<<','<(j)<<' '< > oneStep;\nstruct Stone {\n int loc, val;\n bool operator < (const Stone& o) const {\n return loc < o.loc;\n }\n} magic[25];\n\nvector &go(vector &beginState, int stepCnt, vector &res) {\n // cout<<\"go: \"<(beginState)<<' '<> i); i++) {\n if((stepCnt>>i) & 1){\n origin *= mat;\n // cout< &dp(vector &lastState, int stepCnt, int stoneAfter[201], int stoneEffect[26]) {\n // cout<<\"dp: \"< res(lastState.size());\n int dp[stepCnt+1][lastState.size()];\n memset(dp, 0x3f, sizeof dp);\n for(int i = 0; i < lastState.size(); i++) {\n dp[0][i] = lastState[i];\n }\n for(int step = 0; step < stepCnt; step++) {\n for(int cur = 1; cur < (1<>1) & (1<>1) | (1<>1;\n dp[step+1][nxt] = min(dp[step+1][nxt], dp[step][cur]);\n }\n }\n // cout<<\"dp: \";for(int i = 0; i < lastState.size(); i++) cout<(i)<<')'<<' ';\n // cout<<'\\n';\n }\n for(int i = 0; i < lastState.size(); i++) {\n lastState[i] = dp[stepCnt][i];\n }\n return lastState;\n}\n\nint main () {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n\n cin>>X>>K>>N>>Q;\n for(int i = 1; i <= K; i++) {\n cin>>jmp[i];\n }\n \n for(int i = 0; i < Q; i++) {\n cin>>magic[i].loc>>magic[i].val;\n }\n sort(magic, magic + Q);\n oneStep.resize(1< (1<>1) & (1<>1) | (1<>1] = 0;\n }\n }\n // Mat fp(oneStep);\n // cout< res;\n vector lastState(1< 0){\n // cout<= magic[i].loc){\n st_loc = magic[i].loc;\n stoneAfter[st_loc - curLoc] = ++i;\n // cout<<\"st_loc: \"< <-------------------------_>=-\n/// | \\===========| | ..-'./\\.`-.. _,,-'\n/// `-' | |-------._------''_.-'----`-._``------_.-----'\n/// | | ``----'' ``----''\n/// | |\n/// c++`\n\n///\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557\n///\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u255a\u2550\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2588\u2588\u2588\u2588\u2557 \u255a\u2550\u2550\u2550\u2550\u2588\u2588\u2557 \u2588\u2588\u2554\u2550\u2588\u2588\u2588\u2588\u2557\n///\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2554\u255d \u2588\u2588\u2551\u2588\u2588\u2554\u2588\u2588\u2551\n///\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u255d \u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u255d \u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551\n///\u2588\u2588\u2551\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u255a\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255d\n///\u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u2550\u255d \u255a\u2550\u2550\u2550\u2550\u2550\u255d\n\n#include\n#include\n#define ll long long\n#define ld long double\n#define pb push_back\n#define pf push_front\n#define fr first\n#define sc second\n#define mlojins cout.tie(NULL);\n#define bzbz cin.tie(NULL);\n#define CODER ios_base::sync_with_stdio(0) ;\n#define p_b pop_back\n#define p_f pop_front\n#define Qulukh\n#define quluq return 0;\n#define Zohiri_dzd\n#define GO_Baby_GO\n#define Mekh\n#define Black_star\nusing namespace std ;\n\nconst ll N = 1e6 + 1;\n\nmap mp , pm ;\ndeque v , vc , ve ,vv , vd ;\ndeque p , pe ;\ndeque ts , ss , st ;\ndeque sd , ds ;\nll a , b , c , d , e , f , cnt , ans , r , n , l , x , y ;\nld q , t , cnt1 , cnt2 ;\nstring g , h , w , o , m , s ;\nchar z , u ;\nbool re , rt ;\nvector > pr , rp , pp ;\nmap < pair < ll , ll > , ll > aw , wa ;\nint main ()\n{\n bzbz\n mlojins\n Qulukh\n Mekh\n CODER\n Zohiri_dzd\n Black_star\n ///freopen(\"input.txt\" , \"r\" , stdin );\n ///freopen(\"output.txt\", \"w\" , stdout );\n ///Author :: Murtazoev Alijon\n cin >> a >> b ;\n cin >> g ;\n if (a == 1 and g[0] == '1' and b != 0)\n {\n cout << 0 ;\n quluq\n }\n else if (a == 1 and g == '1' and b == 0)\n {\n cout << 1 ;\n quluq\n }\n if (a == 1 and g[0] == 0)\n {\n cout << 1;\n quluq\n }\n if (g[0] != '1' and b != 0)\n g[0] = '1' , b -- ;\n for (ll i = 1 ; i < g.size() ; i ++ )\n {\n if (g[i] != '0' and b != 0)\n {\n g[i] = '0' ;\n b -- ;\n }\n }\n cout << g ;\n}\n///Mmavl studios\n///Eco students\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c0a063d3e6696388b9ab1b272bb39b7e", "src_uid": "0515ac888937a4dda30cad5e2383164f", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nint main()\n{\n int n=0;\n long long int k=0;\n string s;\n cin>>n>>k>>s;\n int l=s.length();\n if(l==1){\n cout<<\"0\";\n }\n else{\n if(s[0]!='1'){\n s[0]='1';\n k--;\n }\n for(int i=0;i\nusing namespace std;\nint main()\n{\n int n,k=0;\n char o='1',z='0';\n string s;\n cin>>n>>k>>s;\n int l=s.length();\n if(l==1){\n cout<<\"0\";\n }\n else{\n if(s[0]!=o){\n s[0]=o;\n k--;\n }\n for(int i=0;i\n#include \nusing namespace std;\n\nint main()\n{\n int n,k;\n string s;\n cin>>n>>k;\n cin>>s;\n if(n==1 && k){\n cout<<0;\n // cout<<\"Brac\";\n }\n else{\n int i=0;\n while(k){\n while(s[i]=='0'){\n i++;\n // cout<<\"Brac1\";\n }\n if(i==0 && s[i]!='1'){\n s[i]='1';\n k--;\n i++;\n // cout<<\"Brac2\";\n }\n else if(i==0 && s[i]=='1'){\n i++;\n // cout<<\"Brac3\";\n }\n if(i\n \n#define f first\n#define s second\n#define pb push_back\n#define mp make_pair\n \nusing namespace std;\n \ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\n \nconst int N = 200500, LOG = 20, inf = 1e9;\n \nint n, k, a[N], up[LOG][N], cost[LOG][N];\nint sum, A, pref[N];\npll ans;\nmap lst[N];\nint get(int i){\n\ti %= n;\n\tif(i <= ans.s)\n\t\ti += n;\n\treturn a[i];\n}\nvoid gg(int l, int r, ll x, ll y){\n\t//cerr << l << \" \" << r << endl;\n\ta[l] = x, a[r] = y;\n\tfor(int i = l + 1; i < r; i++)\n\t\ta[i] = 0;\n\tprintf(\"%d \", l % n);\n\tfor(int i = l; i <= r; i++)\n\t\tprintf(\"%d \", a[i] + A);\n\tprintf(\"\\n\");\n}\nvoid ff(int l, int r, ll need){ \n\tif(l == r && a[l] == need)\n\t\treturn;\n\tif(r - l + 1 <= k){\n\t\ta[l] = need;\n\t\tfor(int i = l + 1; i <= r; i++)\n\t\t\ta[i] = 0;\n\t\tprintf(\"%d \", l % n);\n\t\tfor(int i = l; i <= l + k - 1; i++)\n\t\t\tprintf(\"%d \", get(i) + A);\n\t \tprintf(\"\\n\");\n\t\treturn;\n\t}\n ll s = 0;\n\tfor(int i = l; i <= l + k - 1; i++)\n\t\ts += a[i];\t\n\tif(s < need){\n\t\tff(l + k - 1, r, need - s + a[l + k - 1]);\n\t\tgg(l, l + k - 1, need, 0);\n\t}else{\n\t\tgg(l, l + k - 1, need, s - need);\n\t\tff(l + k - 1, r, 0);\n\t}\n}\nint main()\n{ \n\tscanf(\"%d%d\", &n, &k);\n\tfor(int i = 0; i < n; i++){\n\t\tscanf(\"%d\", &a[i]);\n\t\tsum += a[i];\n\t}\t\n\tA = sum / n;\n\tfor(int i = 0; i < n; i++)\n\t\ta[i + n] = (a[i] -= A);\n\tfor(int i = 1; i < n + n; i++)\n\t\tpref[i] = pref[i - 1] + a[i];\n\tfor(int i = 0; i < LOG; i++)\n\t\tfor(int j = 0; j < N; j++)\n\t\t\tup[i][j] = n + n;\n\tfor(int i = n + n - 1; i >= 0; i--){\n\t\tint rem = (i + 1) % (k - 1);\n\t\tif(lst[rem].count(pref[i]))\n\t\t\tup[0][i] = lst[rem][pref[i]], cost[0][i] = (lst[rem][pref[i]] - i + k - 3) / (k - 1);\t\n\t\tlst[i % (k - 1)][pref[i]] = i;\n\t}\n\tfor(int j = 1; j < LOG; j++)\n\t\tfor(int i = 0; i < n + n; i++)\n up[j][i] = up[j - 1][ up[j - 1][i] ], cost[j][i] = cost[j - 1][i] + cost[j - 1][ up[j - 1][i] ];\t\n\tans = {inf, inf}; \n\tfor(int i = 0; i < n; i++){\n\t\tint v = i;\n\t\tint res = 0;\n\t\tfor(int j = LOG - 1; j >= 0; j--)\n\t\t\tif(up[j][v] <= n + i)\t\n\t\t\t\tres += cost[j][v], v = up[j][v];\n\t\tif(v <= n + i)\n\t\t\tres += (n + i - v + k - 2) / (k - 1);\n\t\tans = min(ans, {res, i});\n\t}\n\tprintf(\"%d\\n\", ans.f);\n\tint v = ans.s;\n\twhile(v < ans.s + n){\n\t\tif(up[0][v] < ans.s + n)\n\t\t\tff(v + 1, up[0][v], 0);\n\t\telse\n\t\t\tff(v + 1, ans.s + n, 0);\n\t\tv = up[0][v];\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d877cb27f9adc09907ff8da09fa6a6bb", "src_uid": "8b9099351b979cdb61413cc039861f8d", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "#include \n\n#define I inline\n#define fi first\n#define se second\n#define R register\n#define LL long long\n#define reg register int\n#define pii pair\n#define cr const reg&\nusing namespace std;\nconst int inf = 2147483647;\nconst int N = 1e5 + 1;\n\nI int _max(cr x, cr y) {return x > y ? x : y;}\nI int _min(cr x, cr y) {return x < y ? x : y;}\nI int read() {\n\treg x = 0, f = 1; char ch = getchar();\n\twhile(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}\n\twhile(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();\n\treturn x * f;\n}\nI void ptt(cr x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}\nI void put(cr x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}\nI void pr1(cr x) {put(x), putchar(' ');}\nI void pr2(cr x) {put(x), puts(\"\");}\n\npii f[20][N * 2];\nmap mp[N];\nint tp; vector ans[N];\nint n, k, V, a[N * 2], s[N * 2];\nbool bk;\n\nI void gao(reg x) {\n\t++tp;\n\tif(x + k - 1 > n) {\n\t\tans[tp].push_back(n - k);\n\t\treg hh = -s[n - k];\n\t\tif(hh < 0) {\n\t\t\tbk = 1;\n\t\t}\n\t\tans[tp].push_back(hh + V), a[n - k + 1] = hh, s[n - k + 1] = 0;\n\t\tfor(reg i = n - k + 2; i <= n; i++) ans[tp].push_back(V), a[i] = s[i] = 0;\n\t} else {\n\t\tans[tp].push_back(x - 1);\n\t\treg up = x + k - 1, hh = -s[x - 1];\n\t\tans[tp].push_back(hh + V), a[x] = hh; s[x] = 0;\n\t\tfor(reg i = x + 1; i < up; i++) ans[tp].push_back(V), a[i] = s[i] = 0, v[i] = tp;\n\t\tans[tp].push_back(s[up] + V), a[up] = s[up];\n\t}\n}\n\nvoid dfs(reg i) {\n\tif(i > n) return ;\n\tif(a[i] == 0 && s[i] == 0) {dfs(i + 1); return ;}\n\treg up = _min(n, i + k - 1);\n\tif(s[up] >= 0) {\n\t\tgao(i), dfs(i + k - 1);\n\t\tif(bk) puts(\"1\"), bk = 0;\n\t}\n\telse {\n\t\tdfs(i + k - 1), gao(i);\n\t\tif(bk) puts(\"2\"), bk = 0;\n\t}\n}\n\nint main() {\n\tn = read(), k = read();\n\tfor(reg i = 1; i <= n; i++) a[i] = read(), V += a[i];\n\tV /= n; for(reg i = 0; i <= 17; i++) f[i][2 * n + 1] = pii{2 * n + 1, 0};\n\tfor(reg i = 1; i <= n; i++) a[i] = a[i] - V, a[i + n] = a[i];\n\tfor(reg i = 1; i <= 2 * n; i++) s[i] = s[i - 1] + a[i];\n\treg mn = 999999999, pos = -1;\n\tfor(reg i = 2 * n; i >= 1; i--) {\n\t\treg c = (i + 1) % (k - 1), nxt = 2 * n;\n\t\tif(mp[c][s[i]]) nxt = mp[c][s[i]], f[0][i] = pii{nxt, (nxt - i - 1) / (k - 1)};\n\t\telse f[0][i] = pii{2 * n + 1, 0};\n\t\tfor(reg j = 1; j <= 17; j++) f[j][i] = pii{f[j - 1][f[j - 1][i].fi].fi, f[j - 1][i].se + f[j - 1][f[j - 1][i].fi].se};\n\t\tif(i <= n) {\n\t\t\treg now = i, up = i + n, sum = 0;\n\t\t\tfor(reg j = 17; j >= 0; j--) if(f[j][now].fi <= up){\n\t\t\t\tsum += f[j][now].se, now = f[j][now].fi;\n\t\t\t} sum += (up - now - 1 + k - 2) / (k - 1);\n\t\t\tif(sum < mn) mn = sum, pos = i;\n\t\t} mp[i % (k - 1)][s[i]] = i;\n\t} for(reg i = pos + 1; i <= n; i++) s[i - pos] = a[i];\n\tfor(reg i = 1; i <= pos; i++) s[(i + n - pos - 1) % n + 1] = a[i];\n\tmemcpy(a, s, sizeof(a)); for(reg i = 1; i <= n; i++) s[i] = s[i - 1] + a[i];\n\tdfs(1);\n\tpr2(tp);\n\treg t1 = -1, t2 = -1;\n\tfor(reg i = 1; i <= tp; i++) {\n\t\tfor(reg j = 1; j <= k; j++) {\n\t\t\tif(ans[i][j] < 0) {\n\t\t\t\tt1 = ans[i][0], t2 = tp;\n\t\t\t}\n\t\t}\n\t} if(t1 != -1) printf(\"%d %d\\n\", t1, tp);\n\tfor(reg i = 1; i <= tp; i++) {\n\t\tpr1((ans[i][0] + pos) % n);\n\t\tfor(reg j = 1; j <= k; j++) pr1(ans[i][j]);\n\t\tputs(\"\");\n\t} \n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e143f7ed2cb5666c9300d9ac6436501a", "src_uid": "8b9099351b979cdb61413cc039861f8d", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nconstexpr int maxn = 100000;\nint a[maxn], p[maxn], n, k, avg;\nmap> mp;\nvoid distribute(int l, int len, int need){\n //cout << \"dis \" << l << \" \" << len << \" \" << need << endl;\n //for(int i = 0; i < len; i += 1) cout << a[(l + i) % n] << \" \";\n //cout << endl;\n if(len <= 1) return;\n if(a[l] == avg and need == 0){\n distribute((l + 1) % n, len - 1, 0);\n return;\n }\n int sum = 0, m = min(len, k);\n for(int i = 0; i < m; i += 1) sum += a[(l + i) % n];\n if(sum >= avg * (m - 1) + need){\n sum -= a[l] = avg + need;\n for(int i = 1; i < m - 1; i += 1) sum -= a[(l + i) % n] = avg;\n a[(l + m - 1) % n] = sum;\n cout << l;\n for(int i = 0; i < k; i += 1) cout << \" \" << a[(l + i) % n];\n cout << \"\\n\";\n distribute((l + m - 1) % n, len - m + 1, 0);\n return;\n }\n distribute((l + m - 1) % n, len - m + 1, avg * (m - 1) + need - sum + a[(l + m - 1)]);\n sum = 0;\n for(int i = 0; i < m; i += 1) sum += a[(l + i) % n];\n for(int i = 1; i < m; i += 1) sum -= a[(l + i) % n] = avg;\n a[l] = sum;\n cout << l;\n for(int i = 0; i < k; i += 1) cout << \" \" << a[(l + i) % n];\n cout << \"\\n\";\n}\nint main(){\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n cin >> n >> k;\n for(int i = 0; i < n; i += 1){\n cin >> a[i];\n avg += a[i];\n }\n avg/= n;\n for(int i = 0; i < n; i += 1){\n p[i] = (i ? p[i - 1] + a[i] : a[0]) - avg;\n mp[p[i]].push_back(i);\n }\n int ans = 1;\n vector cut(1);\n for(auto& p : mp){\n auto& v = p.second;\n int c = v.size();\n v.resize(c * 2);\n for(int i = 0; i < c; i += 1) v[i + c] = v[i] + n;\n vector pos(k - 1, c * 2);\n vector next(2 * c + 1);\n fill(*next.rbegin(), *next.rbegin() + 20, 2 * c);\n for(int i = 2 * c - 1; i; i -= 1){\n next[i][0] = pos[(v[i] + 1) % (k - 1)];\n for(int j = 1; j < 20; j += 1) next[i][j] = next[next[i][j - 1]][j - 1];\n pos[v[i] % (k - 1)] = i;\n }\n int pans = 0, begin = 0; \n for(int i = 0; i < c; i += 1) if(v[i] % (k - 1) == 0){\n int p = i, ppans = 0;\n for(int j = 19; ~j; j -= 1) if(next[p][j] <= i + c){\n p = next[p][j];\n ppans += 1 << j;\n }\n if(p == i + c and ppans > pans){\n pans = ppans;\n begin = i;\n }\n }\n if(pans > ans){\n ans = pans;\n cut.clear();\n for(int i = begin; i < begin + c; i = next[i][0])\n cut.push_back(v[i]);\n }\n }\n int time = 0;\n vector> interval;\n for(int i = 0; i < (int)cut.size(); i += 1){\n //cout << \"cut\" << \" \" << cut[i] << endl;\n int l = (cut[i] + 1) % n, r = (cut[(i + 1) % cut.size()] + 1) % n;\n if(r <= l) r += n;\n interval.push_back({l, r - l});\n time += (r - l + k - 3) / (k - 1);\n }\n cout << time << \"\\n\";\n for(auto p : interval)\n distribute(p.first, p.second, 0);\n for(int i = 0; i < n; i += 1) if(a[i] != avg) cout << i << \" \" << a[i] << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c00bd4866b184204b4a2fe155d756edc", "src_uid": "8b9099351b979cdb61413cc039861f8d", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "/*\n \n `-:://:::- \n `//:-------:/:` \n .+:--.......--:+` \n `+:--..`````..--//` \n .o:--..`` ``..--:o` \n .o:--...```..---+/` \n `/y+o/---....---:+o. \n `...````-os+/:---:/+o/--.` \n `-/+++++/:. `...` :h+d+oooo+/+-` ... \n `/++//:::://++-`....` -.`//````````:` `..` \n `o+/::------://o/` `-` -. -` `..` \n `---.-o/:./o/::-..``..-\u0417\u0410\u041f\u0423\u0421\u041a\u0410\u0415\u041c .. .. -` `... ``..`` \n `....o+:-++/:--.```..-://s. `-` .- -` `-o: .-//::::/:-` \n `:s+/:--....-::/+s-` .- `- -` -///:--------:/:` \n ./s+//:::::://oo-``..\u041d\u0415\u0419\u0420\u041e\u041d\u041d\u0423\u042e: \u0421\u0415\u0422\u042c:::::::-`\u0420\u0410\u0411\u041e\u0422\u042f\u0413\u0418 `+:--........--:/` \n .:ooo+++++osso-` `.:-...`/` ./::-------:/:` -` :+--..``````.--:+:...-+:-` \n `.-/+++++/+-.-` -. ``:so:/:--.......--:+` `-```````o+/+--..`````..--:o/-..:s+:. \n ```````:``.. `-` -` `+:--..`````..--/+-.../.`````..-o:--.......---/o. ` \n `: `:- -. .o:--..`` ``..--:o` `-` `:o+:--------:+o-` \n `-`-... .. .o/--...```..--:+/` `-` `oy/so/////++o/.` \n -/` `-` `- ``+s/o/:---...---:++. `-` .-../d://///:-.` \n `.---..``-..- .-/..`````-oo+/:::::/+o+- `-``-` `-. ```` \n `:++++/+++++- ..``.-/:` /y-:/++o++/:.`..` ./. `- \n -++/::::::://+/..:-``:` .. `-.` ```.``` `..` `..`-` `- \n `` -o//:--....-::/++` -.-` `-`.-` `..`..` `-.- \n -----ss+:++/:--.```..-://s. /. `:: `-:. ./` \n `````/:..+o/::-..``.--:/+s. ..-` `-``-` ..` `-` `-`-` \n `-s+/::-----::/+oo---``-` .. .:- ``` .-` .-.- `-` \n `:oo+//::://+os/..:`..-/:` :y.-:::::::.`.-` ./-` `-` \n `./+oooooooo+/.`- .-:...`.. .//:-------://` `- `..` `:. \n ``.-::::-.``-/` `-` `- `oo:+:--.......--:/` `- `.:--h.``..``` \n -.-`.- .- `+:--..`````..--//` `- /s-//::::::::. \n -` `/- .. .o:--..`` ``..--:o.```.- `//:--------://` \n -` .-`.-` -.`-o/--...```..--:+/.``-:....``:-.+:--....`...--:+` \n ..`-. `-. ``:os:o/:---...---:++. `- ``///+:-..``````.--:+-````-.` \n `.:///////.-` .:-..` -``-+o+/:::::/+o/. `- `:+:-..`````..--:o/:--/ys+- \n `-++///////+o/. ``....`-. :` `.:++++++/:.` .- -o/---......---/o. `.` \n `++//:-----::/+o:..` .-` : ``````` .- `+so+:--------:++-` \n `````:-``:o/::-..`..--:/+o` -. `- .- `../../+o+////+o+:.` \n -----syo/o+/:--.```..-://s. .-` `- .- `... ``-:////:-`` \n .` `/s//:--....-::/+s. -. `-` .- `..` \n .+o+/:::--:://+s/-..` .::+y ``` .- `..` \n ./oo++////+oso-` `.... :y-+:::::::/` ... \n `.:+oooooo/-` `....-. .//:-------:/:-.` \n ``...`` /+:+:--.......--:+` \n `+:--..`````..--//` \n .o:--..`` ``..--:o` \n .+/--...```..--:+/` \n `-o/:---...---:++. \n `-+o+/:---:/+o/. \n `.:+oooo+/-.` \n `````` \n*/\n\n#ifdef aimbot\n#pragma comment(linker, \"/stack:200000000\")\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n#pragma GCC optimize(\"unroll-loops\")\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define random escape__from__random__aetuhoetnuhshe\n#define mt make_tuple\n#define x first\n#define y second\n#define pb push_back\n#define ppb pop_back\n#define mp make_pair\n#define umap unordered_map\n#define uset unordered_set\n#define elif else if\n#define len(v) ((int)v.size())\n#define f(i, n) for (int i = 0; i < (n); i++)\n#define rof(i, n) for (int i = ((n) - 1); i >= 0; i--)\n#define apply(v, act) for (auto &x : v) { act; }\n#define log(args...) {string s = #args;deque deq;\\\nstring buf = \"\";int bal = 0;for (char c : s) {\\\nif (c == '(' || c == '[' || c == '{') {bal++;\\\n} else if (c == ')' || c == ']' || c == '}') {\\\nbal--;} else {if (bal == 0) {if (c == ',') {\\\ndeq.pb(buf);buf = \"\";} else {if (c != ' ') {\\\nbuf += c;}}}}}if (!buf.empty()) {deq.pb(buf);}\\\nsmart_io::precall_print();smart_io::_print(deq, args);}\n\ninline int min(const int &x, const int &y) { return (((y-x)>>(32-1))&(x^y))^x; }\ninline int max(const int &x, const int &y) { return (((y-x)>>(32-1))&(x^y))^y; }\ninline long long min(const long long &x, const long long &y) { return (((y-x)>>(64-1))&(x^y))^x; }\ninline long long max(const long long &x, const long long &y) { return (((y-x)>>(64-1))&(x^y))^y; }\n\n#define print \\\nsmart_io::precall_print(); \\\ncout,\n\n#define scan cin,\n\n#ifdef fast_allocator\nconst int MAXMEM = 200 * 1000 * 1024;\nchar _memory[MAXMEM];\nsize_t _ptr = 0;\nvoid* operator new(size_t _x) { _ptr += _x; assert(_ptr < MAXMEM); return _memory + _ptr - _x; }\nvoid operator delete (void*) noexcept {}\n#endif\n\nusing namespace std;\n\nchar string_in_buffer[(int)260];\n\n\nvoid fast_scan(int &x) { scanf(\"%d\", &x); }\nvoid fast_scan(long long &x) { scanf(\"%lld\", &x); }\nvoid fast_scan(unsigned long long &x) { scanf(\"%llu\", &x); }\nvoid fast_scan(double &x) { scanf(\"%lf\", &x); }\nvoid fast_scan(long double &x) { scanf(\"%Lf\", &x); }\nvoid fast_scan(char &x) {\n\tscanf(\"%c\", &x);\n\tif (x == '\\n') {\n\t\tfast_scan(x);\n\t}\n}\nvoid fast_scan(string &x) {\n\tscanf(\"%s\", string_in_buffer);\n\tx = string(string_in_buffer);\n}\n\ntemplate\nvoid fast_scan(pair &p) {\n\tfast_scan(p.first);\n\tfast_scan(p.second);\n}\n\ntemplate \nvoid fast_scan(vector &v) {\n\tfor (auto &x : v) fast_scan(x);\n}\n\nvoid fast_print(const int &x) { printf(\"%d\", x); }\nvoid fast_print(const unsigned int &x) { printf(\"%u\", x); }\nvoid fast_print(const long long &x) { printf(\"%lld\", x); }\nvoid fast_print(const unsigned long long &x) { printf(\"%llu\", x); }\nvoid fast_print(const char &x) { printf(\"%c\", x); };\n// void fast_print(__int128 x) {\n// \tif (x == 0) { fast_print('0'); return; }\n// \tif (x < 0) {\n// \t\tfast_print('-');\n// \t\tx = -x;\n// \t}\n// \t__int128 p = 1;\n// \twhile (x / (p * 10)) p *= 10;\n// \twhile (p) {\n// \t\t__int128 symb = x / p;\n// \t\tfast_print((int)symb);\n// \t\tx -= p * symb;\n// \t\tp /= 10;\n// \t}\n// };\nvoid fast_print(const double &x) { printf(\"%.15lf\", x); }\nvoid fast_print(const long double &x) { printf(\"%.15Lf\", x); }\nvoid fast_print(const string &x) { printf(\"%s\", x.c_str());}\nvoid fast_print(const char v[]) { fast_print((string)v); }\n\ntemplate\nvoid fast_print(const pair &p) {\n\tfast_print(p.first);\n\tfast_print(' ');\n\tfast_print(p.second);\n}\n\ntemplate \nvoid fast_print(const vector &v) {\n\tif (v.empty()) return;\n\tfast_print(v[0]);\n\tfor (int i = 1; i < v.size(); i++) {\n\t\tfast_print(' ');\n\t\tfast_print(v[i]);\n\t}\n}\n\ntemplate \nvoid fast_print(const vector> &v) {\n\tif (v.empty()) return;\n\tfast_print(v[0]);\n\tfor (int i = 1; i < v.size(); i++) {\n\t\tfast_print('\\n');\n\t\tfast_print(v[i]);\n\t}\n}\n\ntemplate \nvoid fast_print(const T &v) {\n\tfor (const auto &x : v) {\n\t\tfast_print(x);\n\t\tfast_print(' ');\n\t}\n}\n\n\nusing namespace std;\n\n\nnamespace smart_io {\n\tstring print_start = \"\";\n\tstring sep = \" \";\n\tbool first_print = false;\n\t\n\tvoid precall_print() {\n\t\tfast_print(print_start);\n\t\tprint_start = \"\\n\";\n\t\tfirst_print = true;\n\t}\n\t\n\tvoid _print(deque) {}\n\ttemplate\n\tvoid _print(deque names, T elem, Args... args) {\n\t\tif (!first_print) {\n\t\t\tfast_print(\"\\n\");\n\t\t} else {\n\t\t\tfirst_print = false;\n\t\t}\n\t\tfast_print(names.front());\n\t\tfast_print(\" = \");\n\t\tfast_print(elem);\n\t\tnames.pop_front();\n\t\t_print(names, args...);\n\t}\n} //namespace smart_io\n\n\ntemplate \nostream &operator,(ostream &os, const T &object) {\n\tif (!smart_io::first_print) {\n\t\tfast_print(smart_io::sep);\n\t} else {\n\t\tsmart_io::first_print = false;\n\t}\n\tfast_print(object);\n\treturn os;\n}\n\ntemplate \nistream &operator,(istream &is, T &object) {\n\tfast_scan(object);\n\treturn is;\n}\n\nnamespace random {\n\tusing namespace std::chrono;\n\tmt19937 rng(duration_cast< milliseconds >(\n\t\t\t\t\t\t\t\t\t\t\t system_clock::now().time_since_epoch()\n\t\t\t\t\t\t\t\t\t\t\t ).count());\n\tuniform_real_distribution<> prob_dist(0.0, 1.0);\n};\n#define int long long\nnamespace typedefs {\n\ttypedef long long ll;\n\ttypedef unsigned long long ull;\n\ttypedef pair pii;\n\ttypedef long double ld;\n}\n\nnamespace numbers_operation {\n\ttemplate\n\tinline T floor_mod(T a, const T &b) {\n\t\ta %= b;\t\n\t\tif (a < 0) a += b;\n\t\treturn a;\n\t}\n}\n\nusing namespace numbers_operation;\nusing namespace typedefs;\nusing namespace random;\n\nint n, k;\nint alpha;\nvector a;\nvector>> acts;\nvoid print_slice(int i) {\n\tvector slice;\n\tfor (int j = 0; j < k; j++) {\n\t\tslice.pb(a[(i + j) % n]);\n\t}\n\t// print i, slice;\n\tacts.emplace_back(i, slice);\n}\n\nvoid solve(int l, int r) {\n\tif (l >= r) return;\n\tint S = 0;\n\tint end = min(r, l + k - 1);\n\tfor (int i = l; i <= end; i++)\n\t\tS += a[i % n] - alpha;\n\tif (S >= 0) {\n\t\ta[end % n] = S + alpha;\n\t\tfor (int i = l; i < end; i++) {\n\t\t\ta[i % n] = alpha;\n\t\t}\n\t\tprint_slice(l);\n\t\tsolve(end, r);\n\t} else {\n\t\tS -= a[end % n];\n\t\tsolve(end, r);\n\t\tS += a[end % n];\n\t\ta[end % n] = S + alpha;\n\t\tfor (int i = l; i < end; i++) {\n\t\t\ta[i % n] = alpha;\n\t\t}\n\t\tprint_slice(l);\n\t}\n}\n\nsigned main(signed argc, char *argv[]) {\n\tscan n, k;\n\ta.resize(n);\n\tscan a;\n\tvector b;\n\tb.insert(b.end(), a.begin(), a.end());\n\tb.insert(b.end(), a.begin(), a.end());\n\tint S = accumulate(a.begin(), a.end(), 0LL);\n\talpha = S / n;\n\tapply(b, x -= alpha);\n\n\tmap> at;\n\tint pr = 0;\n\tfor (int i = 0; i < 2 * n; i++) {\n\t\tpr += b[i];\n\t\tat[pr].pb(i);\n\t}\n\tvector cur{mp(0, n - 1)};\n\tfor (auto p : at) {\n\t\tvector pos = p.y;\n\t\tvector> up(20, vector(len(pos) + 1));\n\t\tup[0][len(pos)] = mp(len(pos), 0);\n\t\tmap last;\n\t\tfor (int i = len(pos) - 1; ~i; i--) {\n\t\t\tint next = ((pos[i] + 1) % (k - 1));\n\t\t\tup[0][i] = mp((last.count(next)) ? last[next] : len(pos), 1);\n\t\t\tlast[pos[i] % (k - 1)] = i;\n\t\t}\n\t\tfor (int i = 1; i < 20; i++)\n\t\t\tfor (int j = 0; j <= len(pos); j++)\n\t\t\t\tup[i][j] = mp(\n\t\t\t\t\tup[i - 1][up[i - 1][j].x].x,\n\t\t\t\t\tup[i - 1][j].y + up[i - 1][up[i - 1][j].x].y\n\t\t\t\t);\n\t\tvector pref(len(pos), -1);\n\t\tlast.clear();\n\t\tfor (int j = 0; j < len(pos); j++) {\n\t\t\tlast[pos[j] % (k - 1)] = j;\n\t\t\tif (last.count((pos[j] - 1 + (k - 1)) % (k - 1)))\n\t\t\t\tpref[j] = last[(pos[j] - 1 + (k - 1)) % (k - 1)];\n\t\t}\n\t\t// print \"?\", pos;\n\t\t// print \"?\", pref;\n\t\t// print \"?\", up[0];\n\t\tfor (int i = 0; i < len(pos); i++) {\n\t\t\tif (pos[i] < n) {\n\t\t\t\tint j = i;\n\t\t\t\tint S = 0;\n\t\t\t\tfor (int k = 19; ~k; k--)\n\t\t\t\t\tif (up[k][j].x < len(pos) && pos[up[k][j].x] < pos[i] + n) {\n\t\t\t\t\t\tS += up[k][j].y;\n\t\t\t\t\t\tj = up[k][j].x;\n\t\t\t\t\t}\n\t\t\t\twhile (j > i && ((pos[j] + 1) % (k - 1)) != ((pos[i] + n) % (k - 1))) {\n\t\t\t\t\tassert(pref[j] != -1);\n\t\t\t\t\tj = pref[j];\n\t\t\t\t}\n\t\t\t\tif (j > i) {\n\t\t\t\t\tvector segs;\n\t\t\t\t\tsegs.emplace_back(pos[j] + 1, pos[i] + n);\n\t\t\t\t\twhile (j > i) {\n\t\t\t\t\t\tsegs.emplace_back(pos[pref[j]] + 1, pos[j]);\n\t\t\t\t\t\tj = pref[j];\n\t\t\t\t\t}\n\t\t\t\t\tif (len(cur) < len(segs)) {\n\t\t\t\t\t\t// print \"!\", p.x, i, \":\", pos;\n\t\t\t\t\t\tcur = segs;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor (pii seg : cur) {\n\t\t// print \"(\", seg, \")\";\n\t\tsolve(seg.x, seg.y);\n\t}\n\t// print a;\n\tprint len(acts);\n\tfor (auto t : acts) {\n\t\tprint t.x % n, t.y;\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ce2e2bded9f43129bb1c7e7c46f9880f", "src_uid": "8b9099351b979cdb61413cc039861f8d", "difficulty": 3500.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nbool processNegative(int& currentNegative, queue& questions,\n\tint&i, int k)\n{\n\t++currentNegative;\n\n\tif (currentNegative > k)\n\t{\n\t\tif (!questions.empty())\n\t\t{\n\t\t\ti = questions.front();\n\t\t\tquestions.swap(queue());\n\t\t\tcurrentNegative = 0;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tcout << \"NO\" << endl;\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn true;\n}\n\nint main()\n{\n\t// ifstream cin(\"input.txt\");\n\n\tint n, k;\n\tstring str;\n\tcin >> n >> k >> str;\n\n\tauto currentNegative = 0;\n\tauto hadResult = false;\n\n\tqueue questions;\n\n\tfor (auto i = 0; i < n; i++)\n\t{\n\t\tswitch (str[i])\n\t\t{\n\t\tcase 'Y':\n\t\t\tif (currentNegative == k)\n\t\t\t\thadResult = true;\n\n\t\t\tcurrentNegative = 0;\n\t\t\tquestions.swap(queue());\n\t\t\tbreak;\n\t\tcase 'N':\n\t\t\tif (!processNegative(currentNegative, questions, i, k))\n\t\t\t\treturn 0;\n\t\t\tbreak;\n\t\tcase '?':\n\t\t\tif (currentNegative == k)\n\t\t\t\thadResult = true;\n\n\t\t\tquestions.push(i);\n\t\t\tif (!processNegative(currentNegative, questions, i, k))\n\t\t\t\treturn 0;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tcout << (hadResult ? \"YES\" : \"NO\");\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "628fe3a3a3d9e11fdc0ff58245c03f59", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "aa", "lang_cluster": "C++", "compilation_error": true, "code_uid": "045736e9cc890a29b43c6b7c28afe54a", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\n\ntypedef long long long64;\ntypedef long long int64;\nusing namespace std;\n\n\nint main()\n{\n //freopen(\"input.txt\", \"r\", stdin);\n\t\t\n\t\tint n;\n\t\tint k;\n\t\tcin >> n >> k;\n\t \n\t string a;\n\t cin >> a;\nbool no=false;\nfor(int i=0; i\n\nusing namespace std;\n\nstring s;\n\nint main() {\n int n, k;\n cin >> n >> k >> s;\n s = \"Y\" + s + \"Y\";\nqueue q; int d = 0; int mn = 0; int ok = 0;\n for(int i = 0; i <= n+1; i++) {\n while(q.size() && i - q.front() - 1 > k) q.pop();\n if(s[i] != 'N') {\n if(q.size() && i - q.front() - 1 == k) ok = 1;\n d = 0;\n if(s[i] == 'Y') while(q.size)) q.pop();\n q.push(i);\n } \n else mn = max(mn, ++d);\n }\n if(ok && mn <= k) cout << \"YES\" << endl; \n else cout << \"NO\" << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a98afe1773644a32fd36be01c16822cf", "src_uid": "5bd578d3da5837c259b222336a194d12", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define ms(s, n) memset(s, n, sizeof(s))\n#define FOR(i, a, b) for (int i = (a); i < (b); ++i)\n#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)\n#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)\n#define sz(a) int((a).size())\n#define present(t, x) (t.find(x) != t.end())\n#define all(a) (a).begin(), (a).end()\n#define uni(a) (a).erase(unique(all(a)), (a).end())\n#define pb push_back\n#define pf push_front\n#define mp make_pair\n#define fi first\n#define se second\n#define prec(n) fixed<> (i)) & 1)\n#define bitcount(n) __builtin_popcountll(n)\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef pair pi;\ntypedef vector vi;\ntypedef vector vii;\nconst int MOD = (int) 1e9 + 7;\nconst int FFTMOD = 119 << 23 | 1;\nconst int INF = (int) 1e9 + 23111992;\nconst ll LINF = (ll) 1e18 + 23111992;\nconst ld PI = acos((ld) -1);\nconst ld EPS = 1e-9;\ninline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}\ninline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}\ninline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}\ntemplate inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}\ntemplate inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}\ninline ull isqrt(ull k) {ull r = sqrt(k) + 1; while (r * r > k) r--; return r;}\ninline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}\ninline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}\ninline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}\ninline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}\ninline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}\ninline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}\ninline int sign(ld x, ld y) {return sign(x - y);}\nmt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());\ninline int mrand() {return abs((int) mt());}\n#define db(x) cerr << \"[\" << #x << \": \" << (x) << \"] \";\n#define endln cerr << \"\\n\";\n\n#define double double\n#define EPS 1e-9\nstruct point_t {\n double x, y;\n point_t() : x(0), y(0) {}\n point_t(double x, double y) : x(x), y(y) {}\n point_t(const point_t& p) : x(p.x), y(p.y) {}\n int operator < (const point_t& rhs) const {return make_pair(y, x) < make_pair(rhs.y, rhs.x);}\n int operator == (const point_t& rhs) const {return make_pair(y, x) == make_pair(rhs.y, rhs.x);}\n point_t operator + (const point_t& p) const {return point_t(x + p.x, y + p.y);}\n point_t operator - (const point_t& p) const {return point_t(x - p.x, y - p.y);}\n point_t operator * (double c) const {return point_t(x * c, y * c);}\n point_t operator / (double c) const {return point_t(x / c, y / c);}\n};\ndouble cross(point_t p, point_t q) {return p.x * q.y - p.y * q.x;}\ndouble area(point_t a, point_t b, point_t c) {return fabs(cross(a, b) + cross(b, c) + cross(c, a)) / 2;}\ndouble area2(point_t a, point_t b, point_t c) {return cross(a, b) + cross(b, c) + cross(c, a);}\ndouble dot(point_t p, point_t q) {return p.x * q.x + p.y * q.y;}\ndouble dist(point_t p, point_t q) {return sqrt(dot(p - q, p - q));}\ndouble dist2(point_t p, point_t q) {return dot(p - q, p - q);}\npoint_t RotateCCW90(point_t p) {return point_t(-p.y, p.x);}\npoint_t RotateCW90(point_t p) {return point_t(p.y, -p.x);}\npoint_t RotateCCW(point_t p, double t) {return point_t(p.x * cos(t) - p.y * sin(t), p.x * sin(t) + p.y * cos(t));}\nint sign(double x) {return x < -EPS ? -1 : x > EPS;}\nint sign(double x, double y) {return sign(x - y);}\nostream& operator << (ostream& os, const point_t& p) {\n os << \"(\" << p.x << \",\" << p.y << \")\";\n return os;\n}\npoint_t ProjectPointLine(point_t a, point_t b, point_t c) {\n return a + (b - a) * dot(c - a, b - a) / dot(b - a, b - a);\n}\ndouble DistancePointLine(point_t a, point_t b, point_t c) {\n return dist(c, ProjectPointLine(a, b, c));\n}\npoint_t ComputeLineIntersection(point_t a, point_t b, point_t c, point_t d) {\n b = b - a; d = c - d; c = c - a;\n return a + b * cross(c, d) / cross(b, d);\n}\nstruct Line {\n point_t l, r;\n Line() {}\n Line(point_t l, point_t r) : l(l), r(r) {}\n Line(const Line& rhs) : l(rhs.l), r(rhs.r) {}\n};\nLine Bisector(point_t a, point_t b) {\n point_t c = (a + b) / 2;\n return Line(c, c + RotateCCW90(b - c));\n}\nstruct Circle {\n point_t cen;\n double rad;\n Circle() : rad(0) {}\n Circle(point_t cen, double rad) : cen(cen), rad(rad) {}\n Circle(const Circle& rhs) : cen(rhs.cen), rad(rhs.rad) {}\n int operator < (const Circle& rhs) const {\n return rad < rhs.rad;\n }\n};\nCircle CircumCircle(point_t a, point_t b, point_t c) {\n if (sign(cross(a - c, b - c)) == 0) {\n Circle res = Circle((a + b) / 2, dist(a, b) / 2);\n res = max(res, Circle((b + c) / 2, dist(b, c) / 2));\n res = max(res, Circle((c + a) / 2, dist(c, a) / 2));\n return res;\n }\n Line ln1 = Bisector(a, b);\n Line ln2 = Bisector(b, c);\n point_t cen = ComputeLineIntersection(ln1.l, ln1.r, ln2.l, ln2.r);\n return Circle(cen, dist(cen, a));\n}\n\nvoid chemthan() {\n int k, n; cin >> k >> n;\n vector pts(n * k);\n for (point_t& p : pts) cin >> p.x >> p.y;\n vector res;\n auto calc = [&] (Circle c) {\n int cnt = 0;\n FOR(i, 0, sz(pts)) {\n double d = dist(c.cen, pts[i]);\n if (abs(d - c.rad) < 5e4) {\n cnt++;\n }\n }\n if (!cnt) return 1e9;\n return abs(cnt - (double) sz(pts) / (k - sz(res)));\n };\n FOR(it, 0, k) {\n vector> candidates;\n FOR(it, 0, 1000) {\n int u = mrand() % sz(pts);\n int v = mrand() % sz(pts);\n int w = mrand() % sz(pts);\n if (5e4 < dist(pts[u], pts[v]) &&\n 5e4 < dist(pts[v], pts[w]) &&\n 5e4 < dist(pts[w], pts[u])) {\n Circle c = CircumCircle(pts[u], pts[v], pts[w]);\n candidates.pb(mp(calc(c), c));\n }\n }\n sort(all(candidates));\n Circle tmp;\n for (auto e : candidates) {\n Circle c = e.se;\n int found = 0;\n for (Circle cc : res) {\n double d = dist(c.cen, cc.cen);\n if (d < 0.1 * 600000) {\n found = 1;\n break;\n }\n }\n if (!found) {\n tmp = c;\n break;\n }\n }\n res.pb(tmp);\n FORd(i, sz(pts), 0) {\n double d = dist(pts[i], res.back().cen);\n if (abs(d - res.back().rad) < 5e4) {\n pts.erase(pts.begin() + i);\n }\n }\n db(sz(pts)) endln;\n }\n assert(sz(res) == k);\n for (Circle c : res) {\n cout << prec(9) << c.cen.x << \" \" << c.cen.y << \" \" << c.rad << \"\\n\";\n }\n}\n\nint main(int argc, char* argv[]) {\n ios_base::sync_with_stdio(0), cin.tie(0);\n if (argc > 1) {\n assert(freopen(argv[1], \"r\", stdin));\n }\n if (argc > 2) {\n assert(freopen(argv[2], \"wb\", stdout));\n }\n chemthan();\n cerr << \"\\nTime elapsed: \" << 1000 * clock() / CLOCKS_PER_SEC << \"ms\\n\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b98c9dde7ccae5e9d18d708d94f9832e", "src_uid": "e3f43a4cb8507c1fb5e896bd29eaa339", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \nusing namespace std;\ntypedef long double ld;\n\n#define rep(i, a, b) for(int i = a; i < (b); ++i)\n#define trav(a, x) for(auto& a : x)\n#define all(x) x.begin(), x.end()\n#define sz(x) (int)(x).size()\ntypedef long long ll;\ntypedef pair pii;\ntypedef vector vi;\n\ntemplate\nstruct Point {\n typedef Point P;\n T x, y;\n explicit Point(T x=0, T y=0) : x(x), y(y) {}\n bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }\n bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }\n P operator+(P p) const { return P(x+p.x, y+p.y); }\n P operator-(P p) const { return P(x-p.x, y-p.y); }\n P operator*(T d) const { return P(x*d, y*d); }\n P operator/(T d) const { return P(x/d, y/d); }\n T dot(P p) const { return x*p.x + y*p.y; }\n T cross(P p) const { return x*p.y - y*p.x; }\n T cross(P a, P b) const { return (a-*this).cross(b-*this); }\n T dist2() const { return x*x + y*y; }\n double dist() const { return sqrt((double)dist2()); }\n // angle to x-axis in interval [-pi, pi]\n double angle() const { return atan2(y, x); }\n P unit() const { return *this/dist(); } // makes dist()=1\n P perp() const { return P(-y, x); } // rotates +90 degrees\n P normal() const { return perp().unit(); }\n // returns point rotated 'a' radians ccw around the origin\n P rotate(double a) const {\n return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }\n};\n\ntypedef Point P;\ndouble ccRadius(const P& A, const P& B, const P& C) {\n return (B-A).dist()*(C-B).dist()*(A-C).dist()/\n abs((B-A).cross(C-A))/2;\n}\nP ccCenter(const P& A, const P& B, const P& C) {\n P b = C-A, c = B-A;\n return A + (b*c.dist2()-c*b.dist2()).perp()/b.cross(c)/2;\n}\n\nconst int MAXN = 5000;\n\nint N, K;\nP pt[MAXN];\n\npair res[4];\n\nld cdist (pair left, pair right)\n{\n return abs(left.first.x - right.first.x) + abs (left.first.y - right.first.y) + abs(left.second - right.second);\n}\n\nvoid gogo()\n{\n while (true)\n {\n int cval = 0;\n while (cval < K)\n {\n int a = rand() % (N * K), b = rand() % (N * K), c = rand() % (N * K);\n if (a == b || a == c || b == c) continue;\n if (!((pt[b]-pt[a]).cross(pt[c]-pt[a]))) continue;\n P cc = ccCenter(pt[a], pt[b], pt[c]);\n double rad = ccRadius(pt[a], pt[b], pt[c]);\n if (cc.dist() > 1050000 || rad < 200000 || rad > 800000) continue;\n\n bool bad = false;\n for (int i = 0; i < cval; i++)\n {\n if (cdist (res[i], make_pair (cc, rad)) < 350000)\n {\n bad = true;\n break;\n }\n }\n if (bad) continue;\n\n int nhit = 0;\n vector v;\n for (int i = 0; i < N * K; i++)\n {\n double d = (cc-pt[i]).dist();\n if (d > 0.87 * rad && d < 1.13 * rad)\n {\n nhit++;\n v.push_back((cc-pt[i]).angle());\n }\n }\n sort(v.begin(), v.end());\n for (int i = 0; i + 1 < v.size(); i++)\n if (v[i+1] - v[i] > 1)\n {\n //if (nhit >= N)\n // cout << v[i+1] - v[i] << \"\\n\";\n bad = true;\n }\n if (bad) continue;\n\n if (nhit >= N)\n {\n res[cval] = make_pair (cc, rad);\n cval++;\n }\n }\n\n bool bad = false;\n for (int i = 0; i < N * K; i++)\n {\n bool found = false;\n for (int j = 0; j < K; j++)\n {\n double d1 = res[j].second, d2 = (res[j].first-pt[i]).dist();\n if (d2 >= 0.8 * d1 && d2 <= 1.2 * d1)\n found = true;\n }\n if (!found)\n {\n bad = true;\n break;\n }\n }\n if (!bad) break;\n }\n}\n\nint main()\n{\n srand(time(NULL));\n cin >> K >> N;\n for (int i = 0; i < N * K; i++)\n {\n cin >> pt[i].x >> pt[i].y;\n }\n\n gogo();\n\n cout << fixed << setprecision(8);\n for (int i = 0; i < K; i++)\n {\n cout << res[i].first.x << \" \" << res[i].first.y << \" \" << res[i].second << \"\\n\";\n }\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f3cac8238b42575d91f4791d566c4b50", "src_uid": "e3f43a4cb8507c1fb5e896bd29eaa339", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nint k, n, tmp[200000], cnt = 0;\n\ndouble X[4010], Y[4010], avg1[10010], avg2[10010], Ansx[200000], Ansy[1200000], qwq[200000];\n\ndouble sqr(double x) {return x * x;}\n\ndouble dis(int a, int b, int c, int d) {return sqrt(sqr(c - a) + sqr(d - b));}\n\nvector V;\n\ndouble Do(double x, double y) {\n V.clear();\n\tfor(int s = 1; s <= k * n; s++)\n\t\tV.push_back(pow(dis(x, y, X[s], Y[s]), 2));\n\tsort(V.begin(), V.end());\n\tfor(int i = 0; i < V.size(); i++) avg1[i] = V[i], avg2[i] = V[i] * V[i];\n\tfor(int i = 1; i < V.size(); i++) avg1[i] += avg1[i - 1], avg2[i] += avg2[i - 1];\n \n}\ndouble getval(double x, double y) {\n Do(x, y);\n\tdouble magic = 1e100;\n\tint n = ::n - 2;\n\tfor(int i = n; i < V.size(); i++) magic = min(magic, avg2[i] - avg2[i - n] - sqr(avg1[i] - avg1[i - n]) / n);\n\treturn magic;\n}\n\ndouble getr(double x, double y) {\n\tDo(x, y);\n\tdouble magic = 1e100;\n\tint v;\n\tint n = ::n - 2;\n\tfor(int i = n; i < V.size(); i++) {\n\t\tdouble s = avg2[i] - avg2[i - n] - sqr(avg1[i] - avg1[i - n]) / n;\n\t\tif(s < magic) magic = s, v = i;\n\t}\n\treturn (avg1[v] - avg1[v - n]) / n;\n}\n\ndouble rd() {return (double) rng() / pow(2, 63) - 1;}\n\nbool cmp(int x, int y) {return qwq[x] < qwq[y];}\n\nint main() {\n\tscanf(\"%d%d\", &k, &n);\n\tfor(int i = 1; i <= k * n; i++) scanf(\"%lf%lf\", &X[i], &Y[i]);\n\tfor(int i = -100; i <= 100; i++)\n\t\tfor(int j = -100; j <= 100; j++) if(dis(0, 0, i * 10000, j * 10000) <= 1e6)\n\t\t\tAnsx[++cnt] = i * 10000, Ansy[cnt] = j * 10000, qwq[cnt] = getval(i * 10000, j * 10000);\n\tfor(int i = 1; i <= k; i++) {\n\t\tfor(int i = 1; i <= cnt; i++) tmp[i] = i;\n\t\tsort(tmp + 1, tmp + cnt + 1, cmp);\n\t\tprintf(\"%.12lf %.12lf %.12lf\\n\", Ansx[tmp[1]], Ansy[tmp[1]], getr(Ansx[tmp[1]], Ansy[tmp[1]]));\n\t\tdouble x = Ansx[tmp[1]], y = Ansy[tmp[1]];\n\t\tfor(int i = 1; i <= cnt; i++) if(dis(Ansx[i], Ansy[i], x, y) <= 4e5) qwq[i] = 1e100;\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "34835b224ff91ffca02f0d46f575c284", "src_uid": "e3f43a4cb8507c1fb5e896bd29eaa339", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nint k, n;\n\ndouble X[4010], Y[4010];\n\ndouble eps = 1e4, mx = 2e6;\n\ndouble sqr(double x) {return x * x;}\n\ndouble dis(int a, int b, int c, int d) {return sqrt(sqr(c - a) + sqr(d - b));}\n\ndouble avg1[10010], avg2[10010];\n\ndouble getval(double x, double y) {\n\tvector V(0);\n\tfor(int s = 1; s <= k * n; s++)\n\t\tV.push_back(dis(x, y, X[s], Y[s]));\n\tsort(V.begin(), V.end());\n\tfor(int i = 0; i < V.size(); i++) avg1[i] = V[i], avg2[i] = V[i] * V[i];\n\tfor(int i = 1; i < V.size(); i++) avg1[i] += avg1[i - 1], avg2[i] += avg2[i - 1];\n\tdouble magic = 1e100;\n\tint n = ::n - 2;\n\tfor(int i = n; i < V.size(); i++) magic = min(magic, avg2[i] - avg2[i - n] - sqr(avg1[i] - avg1[i - n]) / n);\n\treturn magic;\n}\n\ndouble getr(double x, double y) {\n\tvector V(0);\n\tfor(int s = 1; s <= k * n; s++)\n\t\tV.push_back(dis(x, y, X[s], Y[s]));\n\tsort(V.begin(), V.end());\n\tfor(int i = 0; i < V.size(); i++) avg1[i] = V[i], avg2[i] = V[i] * V[i];\n\tfor(int i = 1; i < V.size(); i++) avg1[i] += avg1[i - 1], avg2[i] += avg2[i - 1];\n\tdouble magic = 1e100;\n\tint v;\n\tint n = ::n - 2;\n\tfor(int i = n; i < V.size(); i++) {\n\t\tdouble s = avg2[i] - avg2[i - n] - sqr(avg1[i] - avg1[i - n]) / n;\n\t\tif(s < magic) magic = s, v = i;\n\t}\n\treturn (avg1[v] - avg1[v - n]) / n;\n}\n\ndouble Ansx[10], Ansy[10];\n\nint cnt = 0;\n\nmt19937_64 rng(233);\n\ndouble rd() {\n\treturn (double) rng() / pow(2, 63) - 1;\n}\n\nint main() {\n\tscanf(\"%d%d\", &k, &n);\n\tfor(int i = 1; i <= k * n; i++) {\n\t\tscanf(\"%lf%lf\", &X[i], &Y[i]);\n\t\t//X[i + n] = X[i] + 233333, Y[i + n] = Y[i] + 377777;\n\t}\n\tfor(int T = 1; T <= 30; T++) {\n\t\tdouble x = rd() * 2000000, y = rd() * 2000000, magic = getval(x, y);\n\t\tfor(double step = 2000000; step > 100; step *= 0.995) {\n\t\t\tdouble dx = rd() * step, dy = rd() * step, tmp = getval(x + dx, y + dy);\n\t\t\tif(magic > tmp) x += dx, y += dy, magic = tmp;\n\t\t}\n\t\tint flag = 1;\n\t\tfor(int i = 1; i <= cnt; i++)\n\t\t\tif(dis(x, y, Ansx[i], Ansy[i]) <= 1e5) flag = 0;\n\t\tif(flag && fabs(x) <= 2000000 && fabs(y) <= 2000000) Ansx[++cnt] = x, Ansy[cnt] = y;\n\t}\n\t//printf(\"%.12lf %.12lf\\n\", getval(Ansx[1], Ansy[1]), getval(Ansx[1] + 233333, Ansy[1] + 377777));\n\tassert(cnt == k);\n\tfor(int i = 1; i <= k; i++) printf(\"%.12lf %.12lf %.12lf\\n\", Ansx[i], Ansy[i], getr(Ansx[i], Ansy[i]));\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7dd1adf8498dab86f3a8a1a5ac0d25ef", "src_uid": "e3f43a4cb8507c1fb5e896bd29eaa339", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#include \n#pragma GCC optimize(3)\n#pragma GCC target(\"avx\")\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC optimize(\"inline\")\n#pragma GCC optimize(\"-fgcse\")\n#pragma GCC optimize(\"-fgcse-lm\")\n#pragma GCC optimize(\"-fipa-sra\")\n#pragma GCC optimize(\"-ftree-pre\")\n#pragma GCC optimize(\"-ftree-vrp\")\n#pragma GCC optimize(\"-fpeephole2\")\n#pragma GCC optimize(\"-ffast-math\")\n#pragma GCC optimize(\"-fsched-spec\")\n#pragma GCC optimize(\"unroll-loops\")\n#pragma GCC optimize(\"-falign-jumps\")\n#pragma GCC optimize(\"-falign-loops\")\n#pragma GCC optimize(\"-falign-labels\")\n#pragma GCC optimize(\"-fdevirtualize\")\n#pragma GCC optimize(\"-fcaller-saves\")\n#pragma GCC optimize(\"-fcrossjumping\")\n#pragma GCC optimize(\"-fthread-jumps\")\n#pragma GCC optimize(\"-funroll-loops\")\n#pragma GCC optimize(\"-freorder-blocks\")\n#pragma GCC optimize(\"-fschedule-insns\")\n#pragma GCC optimize(\"inline-functions\")\n#pragma GCC optimize(\"-ftree-tail-merge\")\n#pragma GCC optimize(\"-fschedule-insns2\")\n#pragma GCC optimize(\"-fstrict-aliasing\")\n#pragma GCC optimize(\"-fstrict-overflow\")\n#pragma GCC optimize(\"-falign-functions\")\n#pragma GCC optimize(\"-fcse-follow-jumps\")\n#pragma GCC optimize(\"-fsched-interblock\")\n#pragma GCC optimize(\"-fpartial-inlining\")\n#pragma GCC optimize(\"no-stack-protector\")\n#pragma GCC optimize(\"-freorder-functions\")\n#pragma GCC optimize(\"-findirect-inlining\")\n#pragma GCC optimize(\"-fhoist-adjacent-loads\")\n#pragma GCC optimize(\"-frerun-cse-after-loop\")\n#pragma GCC optimize(\"inline-small-functions\")\n#pragma GCC optimize(\"-finline-small-functions\")\n#pragma GCC optimize(\"-ftree-switch-conversion\")\n#pragma GCC optimize(\"-foptimize-sibling-calls\")\n#pragma GCC optimize(\"-fexpensive-optimizations\")\n#pragma GCC optimize(\"inline-functions-called-once\")\n#pragma GCC optimize(\"-fdelete-null-pointer-checks\")\nusing namespace std;\n#define PII pair\n#define MP make_pair\n#define A b * 1.0 * (1.0 - dfs(b - 1, a)) / (b * 1.0 + 1.0)\n#define B 1\n#define C (1.0 + 1.0 * b * (1.0 - dfs(b - 1, a))) / (b * 1.0 + 1.0)\n#define D (1.0 - dfs(b, a - 1))\n#define P (D - B) / (A - B - C + D)\nmap m;\ninline double dfs(int a, int b)\n{\n\tif (b == 0)\n\t{\n\t\treturn 1.0;\n\t}\n\tif (a == 0)\n\t{\n\t\treturn 1.0 / (1.0 * b + 1.0);\n\t}\n\tif (m.count(MP(a, b)))\n\t{\n\t\treturn m[MP(a, b)];\n\t}\n\tdouble ans = P * A + (1.0 - P) * B;\n\tm.insert(MP(a, b), ans);\n\treturn ans;\n}\nint read()\n{\n\tint num = 0, bj = 0;\n\tchar ch = getchar();\n\twhile (!isdigit(ch))\n\t{\n\t\tif (ch == '-')\n\t\t{\n\t\t\tbj = 1;\n\t\t}\n\t\tch = getchar();\n\t}\n\twhile (isdigit(ch))\n\t{\n\t\tnum = num * 10 + ch - '0';\n\t\tch = getchar();\n\t}\n\treturn bj ? -num : num;\n}\nint main()\n{\n\tint a, b;\n\ta = read();\n\tb = read();\n\tdouble ans = dfs(a, b);\n\tprintf(\"%.9lf %.9lf\", ans, 1.0 - ans);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "54cc9333545d142e6312e766c52b0dd9", "src_uid": "f51586ab88399c04ffb7eaa658d294dd", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\ndouble dp[1010][1010];\ndouble f(int x,int y)\n{\n if (dp[x][y]>-0.5) return dp[x][y];\n\n if (y==0) return dp[x][y]=1.0;\n if (x==0) return dp[x][y]=1.0/(y+1);\n double num1=1.0/(y+1);\n double num2=(y*1.0)/(y+1)*(1-f(y-1,x))\n return dp[x][y]=max(num1,num2);\n}\nint main()\n{\n int m,n;\n while (scanf(\"%d%d\",&m,&n)==2)\n {\n for (int i=0;i<=1000;i++)\n for (int j=0;j<=1000;j++)\n dp[i][j]=-1;\n printf(\"%f %f\\n\",f(m,n),1-f(m,n));\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "84f8532339ef8a2e62f00bf94670f3eb", "src_uid": "f51586ab88399c04ffb7eaa658d294dd", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\ntypedef long long int_t;\n\ndouble ans[1001][1001];\n\ndouble dp(int_t n, int_t m) {\n if(!n || !m) return 1.0 / (m + 1);\n if(ans[n][m]) return ans[n][m];\n double f = dp(m, n - 1);\n return ans[n][m] = m * (- f * dp(m - 1, n) + f + 1) / ((m + 1) * f + m);\n}\n\nint main() {\n int_t n, m;\n cin >> n >> m;\n fprintf(\"%.6lf %.6lf\", dp(n, m), 1-dp(n, m));\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e66977ab114ad568401e23f9127544b9", "src_uid": "f51586ab88399c04ffb7eaa658d294dd", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "#include \"bits/stdc++.h\"\nusing namespace std;\ntypedef long long ll;\n\ntypedef long double ld;\n\nld F[N][M]; int vis[N][M];\n\nld f(int n, int m) {\n if(!n) return (ld) 1 / (m + 1);\n if(!m) return 1;\n if(vis[n][m]) return F[n][m];\n ld k1 = (ld) m / (m + 1) * (1 - f(m - 1, n)) - 1;\n ld b1 = 1;\n ld k2 = (ld) (1 + m * (1 - f(m - 1, n))) / (m + 1) - (1 - f(m, n - 1));\n ld b2 = 1 - f(m, n - 1);\n ld X = (b2 - b1) / (k1 - k2);\n vis[n][m] = 1;\n return f[n][m] = k1 * X + b1;\n}\n\nint main() {\n int n, m; cin >> n >> m;\n ld ans = f(n, m);\n cout << fixed << setprecision(10) << ans << ' ' << (1 - ans) << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "1c5615f780330ead765beb22669975e9", "src_uid": "f51586ab88399c04ffb7eaa658d294dd", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "#include \n#define mp make_pair\n#define pb push_back\nusing namespace std;\nusing ll = long long int;\ntemplate\nostream& operator+(ostream& out, const vector &vec){\n for(const auto &x : vec){\n out<\nostream& operator*(ostream& out, const vector &vec){\n for(const auto &x : vec){\n out+x;\n }\n return out;\n}\ntemplate\nistream& operator>>(istream& in, vector &vec){\n for(auto &x : vec){\n in>>x;\n }\n return in;\n}\nconst double eps = 1e-12;\nint sign(const double &value){\n if(abs(value) <= eps){\n return 0;\n }\n if(value < 0){\n return -1;\n }\n else{\n return 1;\n }\n}\nconst double pi = acos(-1);\nstruct Point{\n bool add2pi = 0;\n double x,y;\n Point(){}\n Point(double x,double y) : x(x), y(y) {}\n double angle() const{\n if(x==0){\n if(y>0){\n return pi/2;\n }\n else{\n return 3*pi/2;\n }\n return 0;\n }\n double theta = atan(abs(y/x));\n if(x<0){\n theta = pi - theta;\n }\n if(y<0){\n theta = 2*pi - theta;\n }\n return theta + 2*pi*add2pi;\n }\n double dist(){\n return sqrtl(x*x + y*y);\n }\n};\nistream& operator>>(istream &in, Point &x){\n in>>x.x>>x.y;\n return in;\n}\nostream& operator<<(ostream& out, const Point &x){\n out<=c;\n }\n else{\n return p.x<=c;\n }\n }\n int sn1 = sign(-c);\n int sn2 = sign(p.y - m*p.x - c);\n if(sn2==0){\n return 0;\n }\n if((sn2<0) ^ (sn1<0)){\n return 1;\n }\n else{\n return -1;\n }\n }\n Point intersect(double theta){\n if(v){\n return Point(c, tan(theta)*c);\n }\n while(theta > pi){\n theta-=pi;\n }\n if(abs(theta - pi/2) < eps){\n return Point(0,c);\n }\n return Point(c/(tan(theta) - m), c*tan(theta)/(tan(theta) - m));\n }\n double perpdistance(){\n if(v){\n return c;\n }\n if(abs(m) < eps){\n return c;\n }\n return intersect(atan(1/m)).dist();\n }\n};\ndouble area(const vector& points){\n if(points.size() < 3){\n return 0;\n }\n int n = points.size();\n double ans = points[n-1].x * points[0].y - points[0].x * points[n-1].y;\n for(int i=0;i+1 upper;\n vector lower;\n vector points;\n Point l,r;\n double Distance;\n void build(vector _points){\n points = _points;\n assert(points.size() >= 3);\n int n = points.size();\n sort(points.begin(), points.end(), [&](const Point &x, const Point &y){\n return x.angle() < y.angle() && abs(x.angle() - y.angle()) > eps;\n });\n l = points[0];\n r = points[n-1];\n if(r.angle() - l.angle() > pi){\n for(int i=0;i eps;\n });\n l = points[0];\n r = points[n-1];\n }\n Line mid(l,r);\n upper.push_back(l);\n lower.push_back(l);\n for(int i=1;i 2*pi){\n if(theta < pi) theta += 2*pi;\n }\n if(theta < l.angle() || theta > r.angle()){\n return true;\n }\n int mn = 0, mx = lower.size() - 1;\n while(mn < mx){\n int mid = mn + mx + 1;\n mid>>=1;\n if(lower[mid].angle() < theta){\n mn = mid;\n }\n else{\n mx = mid - 1;\n }\n }\n if(Line(lower[mn], lower[mn + 1]).getside(p)==1){\n return false;\n }\n else{\n return true;\n }\n }\n int binsearch(const vector& seq, double theta){ //returns index of first point at angle greater than theta\n int mn = 0;\n int mx = seq.size() - 1;\n if(seq[mx].angle() < theta){\n return seq.size();\n }\n while(mn < mx){\n int mid = mn + mx;\n mid>>=1;\n if(seq[mid].angle() < theta){\n mn = mid + 1;\n }\n else{\n mx = mid;\n }\n }\n return mn;\n }\n double areabetween(double theta1, double theta2){\n if(r.angle() > 2*pi){\n if(theta1 < pi) theta1 += 2*pi;\n if(theta2 < pi) theta2 += 2*pi;\n }\n if(theta2 < theta1){\n //assert(false && \"nonsense\");\n swap(theta1, theta2);\n }\n vector finalpoints;\n int llow = binsearch(lower, theta1);\n int lup = binsearch(upper, theta1);\n int rlow = binsearch(lower, theta2);\n int rup = binsearch(upper, theta2);\n //cout<=lup;--i){\n finalpoints.pb(upper[i]);\n }\n if(lup!=0){\n finalpoints.pb(Line(upper[lup], upper[lup-1]).intersect(theta1));\n }\n finalpoints.resize(unique(finalpoints.begin(), finalpoints.end(), [&](const Point &x, const Point &y){\n return abs(x.x-y.x) <= eps && abs(x.y-y.y) <=eps; \n }) - finalpoints.begin());\n //cout+finalpoints;\n return area(finalpoints);\n } \n double angledist(double theta){\n int llow = binsearch(lower, theta);\n if(llow==0){\n ++llow;\n }\n return Line(lower[llow], lower[llow-1]).intersect(theta).dist();\n }\n};\nvoid solve(){\n int n;\n cin>>n;\n vector warehouses(n);\n for(int i=0;i>size;\n vector warehousepoints(size);\n cin>>warehousepoints;\n warehouse.build(warehousepoints);\n }\n struct Event{\n double theta;\n int idx;\n bool add;\n Event(){}\n Event(double theta, int idx, bool add) : theta(theta), idx(idx), add(add) {}\n bool operator<(const Event &E){\n return theta < E.theta;\n }\n };\n vector events;\n for(int i=0;i used(n);\n used[events[0].idx] = events[0].add;\n for(int i=1;i> answers;\n double theta1 = events[i-1].theta;\n double theta2 = events[i].theta;\n for(int j=0;j\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\nconst ld PI = acosl(-1);\nmt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());\nstruct point\n{\n\tld x, y;\n\tpoint() {}\n\tpoint(ld x, ld y): x(x), y(y)\n\t{\n\n\t}\n\tld kampas()\n\t{\n\t\treturn atan2l(y, x);\n\t}\n};\npoint operator+(point a, point b)\n{\n\treturn point(a.x + b.x, a.y + b.y);\n}\npoint operator-(point a, point b)\n{\n\treturn point(a.x - b.x, a.y - b.y);\n}\npoint operator*(point a, ld k)\n{\n\treturn point(a.x * k, a.y * k);\n}\nld cross(point a, point b)\n{\n\treturn a.x * b.y - a.y * b.x;\n}\nld f(ld alfa, ld beta, pairab)\n{\n\tpoint a = ab.first;\n\tpoint b = ab.second;\n\tpoint va(cosl(alfa), sinl(alfa));\n\tpoint vb(cosl(beta), sinl(beta));\n\tva = va * (cross(a, b) / cross(va, b - a));\n\tvb = vb * (cross(a, b) / cross(vb, b - a));\n\treturn cross(va, vb) / 2;\n}\nld calc(ld alfa, ld beta, const vector>&A)\n{\n\tif (A.size() <= 1 || beta - alfa < 1e-8)\n\t\treturn 0;\n\tvector>L, R;\n\tbool visi = true;\n\tld gamma = (alfa + beta) / 2;\n\tfor (pairi : A)\n\t{\n\t\tld k1 = i.first.kampas();\n\t\tld k2 = i.second.kampas();\n\t\tvisi &= (k1 < alfa && beta < k2);\n\t\tif (beta + 1e-9 < k1 || k2 + 1e-9 < alfa)\n\t\t\tcontinue;\n\t\tif (k1 < gamma)\n\t\t\tL.push_back(i);\n\t\tif (k2 > gamma)\n\t\t\tR.push_back(i);\n\t}\n\tif (visi)\n\t{\n\t\tpoint v(cos(gamma), sin(gamma));\n\t\tpairmn = {1e9, 0};\n\t\tpairmn1 = {1e9, 0};\n\t\tfor (int i = 0; i < (int)A.size(); i++)\n\t\t{\n\t\t\tpoint a = A[i].first;\n\t\t\tpoint b = A[i].second;\n\t\t\t//(kv-a)(b-a)=0\n\t\t\t//kv(b-a)=ab\n\t\t\tld k = cross(a, b) / cross(v, b - a);\n\t\t\tif (k <= mn.first)\n\t\t\t{\n\t\t\t\tmn1 = mn;\n\t\t\t\tmn = {k, i};\n\t\t\t}\n\t\t\telse if (k <= mn1.first)\n\t\t\t{\n\t\t\t\tmn1 = {k, i};\n\t\t\t}\n\t\t}\n\t\treturn f(alfa, beta, A[mn1.second]) - f(alfa, beta, A[mn.second]);\n\t}\n\treturn calc(alfa, gamma, L) + calc(gamma, beta, R);\n}\nint sgn(ld x)\n{\n\tif (x < 0)\n\t\treturn -1;\n\tif (x > 0)\n\t\treturn 1;\n\treturn 0;\n}\nint main()\n{\n\tcout << fixed << setprecision(3);\n\tios_base::sync_with_stdio(false);\n\tint n;\n\tcin >> n;\n\tvector>A;\n\twhile (n--)\n\t{\n\t\tint k;\n\t\tcin >> k;\n\t\tpoint a0;\n\t\tcin >> a0.x >> a0.y;\n\t\tpoint aj = a0;\n\t\tfor (int i = 1; i < k; i++)\n\t\t{\n\t\t\tpoint ai;\n\t\t\tcin >> ai.x >> ai.y;\n\t\t\tA.push_back({aj, ai});\n\t\t\taj = ai;\n\t\t}\n\t\tA.push_back({aj, a0});\n\t}\n\tn = A.size();\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tif (abs(A[i].first.y) < 0.5 || abs(A[i].second.y) < 0.5)\n\t\t\tcontinue;\n\t\tif ((A[i].first.y > 0) != (A[i].second.y > 0))\n\t\t{\n\t\t\tld k = -A[i].first.y / (A[i].second - A[i].first).y;\n\t\t\tpoint B = A[i].first + (A[i].second - A[i].first) * k;\n\t\t\tA.push_back({B, A[i].second});\n\t\t\tA[i].second = B;\n\t\t}\n\t}\n\tvector>A_;\n\tfor (pairb : A)\n\t{\n\t\tif (abs(b.first.kampas() - b.second.kampas()) > 1e-8)\n\t\t{\n\t\t\tA_.push_back(b);\n\t\t}\n\t}\n\tfor (pair&i : A_)\n\t{\n\t\twhile (sgn(i.first.y) != sgn(i.second.y))\n\t\t{\n\t\t\tif (abs(i.first.y) < abs(i.second.y))\n\t\t\t{\n\t\t\t\tif (i.second.y > 0)\n\t\t\t\t\ti.first.y = 1e-9;\n\t\t\t\telse\n\t\t\t\t\ti.first.y = -1e-9;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif (i.first.y > 0)\n\t\t\t\t\ti.second.y = 1e-9;\n\t\t\t\telse\n\t\t\t\t\ti.second.y = -1e-9;\n\t\t\t}\n\t\t}\n\t\tif (i.first.kampas() > i.second.kampas())\n\t\t\tswap(i.first, i.second);\n\t}\n\tcout << fixed << setprecision(20) << calc(-PI - 0.001, PI + 0.001, A_) << \"\\n\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "68f999f6c88a384dc749cc478148f480", "src_uid": "f88b322137318b2fbae4f54a613b170c", "difficulty": 3000.0} {"lang": "GNU C++17", "source_code": "#include \n#include \"geodeb.h\"\nusing namespace std;\n\nconst long double EPS = 1e-9;\nconst long double pi = acos(-1);\n\nstruct point {\n long double x, y;\n};\n\npoint operator+(const point &a, const point &b) {\n return {a.x + b.x, a.y + b.y};\n}\n\npoint operator-(const point &a, const point &b) {\n return {a.x - b.x, a.y - b.y};\n}\n\npoint operator*(const long double &k, const point &p) {\n return {p.x * k, p.y * k};\n}\n\npoint operator/(const point &p, const long double &k) {\n return {p.x / k, p.y / k};\n}\n\nlong double calc_ang(const point &a) {\n long double ang = atan2(a.y, a.x);\n if (ang < 0.0) {\n return ang + 2 * pi;\n }\n return ang;\n}\n\nlong double dot(const point &a, const point &b) {\n return a.x * b.x + a.y * b.y;\n}\n\nlong double norm_sq(const point &a) {\n return dot(a, a);\n}\n\nlong double cross(const point &a, const point &b) {\n return a.x * b.y - a.y * b.x;\n}\n\nstruct line {\n point a, b;\n int idx;\n};\n\nlong double offset(const line &l) {\n return cross(l.b - l.a, l.a);\n}\n\npoint intersection(const line &l1, const line &l2) {\n return (offset(l1) * (l2.b - l2.a) - offset(l2) * (l1.b - l1.a)) / cross(l1.b - l1.a, l2.b - l2.a);\n}\n\npoint intersection(const line &l, const long double &ang) {\n return intersection({{0, 0}, {cos(ang), sin(ang)}}, l);\n}\n\nvoid add_segment(point a, point b, vector &segments) {\n if (abs(cross(a, b)) < EPS) {\n return;\n }\n if (cross(a, b) < 0.0) {\n swap(a, b);\n }\n if (a.y < 0.0 && b.y > 0.0) {\n point tmp = intersection({{0, 0}, {1, 0}}, {a, b});\n add_segment(a, tmp, segments);\n add_segment(tmp, b, segments);\n } else {\n if (a.y < 0.0 && abs(b.y) < EPS) {\n b.y = -EPS;\n }\n segments.push_back({a, b, (int) segments.size()});\n GD_POINT(a.x, a.y);\n GD_POINT(b.x, b.y);\n GD_SEGMENT(a.x, a.y, b.x, b.y);\n }\n} \n\nstruct node {\n int i, j;\n line l1, l2;\n};\n\nlong double cur_ang;\nvector segments;\n\nstruct comp {\n bool operator()(const int &a, const int &b) const {\n if (a == b) {\n return false;\n }\n return norm_sq(intersection(segments[a], cur_ang)) < norm_sq(intersection(segments[b], cur_ang));\n }\n};\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n GD_INIT(\"geo.html\");\n int n;\n cin >> n;\n GD_LINE(0, 0, 0, 1);\n GD_LINE(0, 0, 1, 0);\n for (int i = 0; i < n; i++) {\n int c;\n cin >> c;\n vector polygon(c);\n for (int i = 0; i < c; i++) {\n cin >> polygon[i].x >> polygon[i].y;\n }\n for (int i = 0; i < c; i++) {\n add_segment(polygon[i], polygon[(i + 1) % c], segments);\n }\n }\n vector a;\n for (auto& seg : segments) {\n a.push_back(calc_ang(seg.a));\n a.push_back(calc_ang(seg.b));\n }\n sort(a.begin(), a.end());\n a.erase(unique(a.begin(), a.end()), a.end());\n for (auto& x : a) {\n GD_LINE(0, 0, cos(x), sin(x)); \n }\n vector< vector > add((int) a.size()), remove((int) a.size());\n for (auto& seg : segments) {\n int l = lower_bound(a.begin(), a.end(), calc_ang(seg.a)) - a.begin();\n int r = lower_bound(a.begin(), a.end(), calc_ang(seg.b)) - a.begin();\n add[l].push_back(seg.idx);\n remove[r].push_back(seg.idx);\n }\n set st;\n long double ans = 0;\n for (int i = 0; i < (int) a.size() - 1; i++) {\n cur_ang = (a[i] + a[i + 1]) / 2;\n for (auto& x : add[i]) {\n st.insert(x);\n }\n for (auto& x : remove[i]) {\n st.erase(x);\n }\n if ((int) st.size() >= 2) {\n line l1 = segments[*st.begin()], l2 = segments[*next(st.begin())];\n point v = intersection(l1, a[i]), w = intersection(l1, a[i + 1]);\n ans -= cross(v, w);\n v = intersection(l2, a[i]), w = intersection(l2, a[i + 1]);\n ans += cross(v, w);\n }\n }\n cout << fixed << setprecision(10) << ans / 2.0 << '\\n';\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "229cd3e8b1cb0e65ac756d5460951d2e", "src_uid": "f88b322137318b2fbae4f54a613b170c", "difficulty": 3000.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\nconst double EPS = 1e-9;\nconst double pi = acos(-1);\n\nstruct point {\n double x, y;\n};\n\npoint operator+(const point &a, const point &b) {\n return {a.x + b.x, a.y + b.y};\n}\n\npoint operator-(const point &a, const point &b) {\n return {a.x - b.x, a.y - b.y};\n}\n\npoint operator*(const double &k, const point &p) {\n return {p.x * k, p.y * k};\n}\n\npoint operator/(const point &p, const double &k) {\n return {p.x / k, p.y / k};\n}\n\ndouble calc_ang(const point &a) {\n double ang = atan2(a.y, a.x);\n if (ang < 0.0) {\n return ang + 2 * pi;\n }\n return ang;\n}\n\nstruct line {\n point a, b;\n int idx;\n};\n\ndouble dot(const point &a, const point &b) {\n return a.x * b.x + a.y * b.y;\n}\n\ndouble norm_sq(const point &a) {\n return dot(a, a);\n}\n\ndouble cross(const point &a, const point &b) {\n return a.x * b.y - a.y * b.x;\n}\n\nvoid add_segment(point a, point b, vector &segments) {\n if (abs(cross(a, b)) < EPS) {\n return;\n }\n if (cross(a, b) < 0.0) {\n swap(a, b);\n }\n if (a.y < 0.0 && b.y > 0.0) {\n point tmp = {-a.y * ((b.y - a.y) / (b.x - a.x)) + a.x, 0.0};\n add_segment(a, tmp, segments);\n add_segment(tmp, b, segments);\n } else {\n if (a.y < 0.0 && abs(b.y) < EPS) {\n b.y = -EPS;\n }\n segments.push_back({a, b, (int) segments.size()});\n }\n} \n\nstruct node {\n int i, j;\n line l1, l2;\n};\n\ndouble offset(const line &l) {\n return cross(l.b - l.a, l.a);\n}\n\npoint intersection(const line &l1, const line &l2) {\n return (offset(l1) * (l2.b - l2.a) - offset(l2) * (l1.b - l1.a)) / cross(l1.b - l1.a, l2.b - l2.a);\n}\n\npoint intersection(const line &l, const double &ang) {\n return intersection({{0, 0}, {cos(ang), sin(ang)}}, l);\n}\n\ndouble cur_ang;\nvector segments;\n\nstruct comp {\n bool operator()(const int &a, const int &b) {\n if (a == b) {\n return false;\n }\n return norm_sq(intersection(segments[a], cur_ang)) < norm_sq(intersection(segments[b], cur_ang));\n }\n};\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n int n;\n cin >> n;\n for (int i = 0; i < n; i++) {\n int c;\n cin >> c;\n vector polygon(c);\n for (int i = 0; i < c; i++) {\n cin >> polygon[i].x >> polygon[i].y;\n }\n for (int i = 0; i < c; i++) {\n add_segment(polygon[i], polygon[(i + 1) % c], segments);\n }\n }\n vector a;\n for (auto& seg : segments) {\n a.push_back(calc_ang(seg.a));\n a.push_back(calc_ang(seg.b));\n }\n sort(a.begin(), a.end());\n a.erase(unique(a.begin(), a.end()), a.end());\n vector< vector > add((int) a.size()), remove((int) a.size());\n for (auto& seg : segments) {\n int l = lower_bound(a.begin(), a.end(), calc_ang(seg.a)) - a.begin();\n int r = lower_bound(a.begin(), a.end(), calc_ang(seg.b)) - a.begin();\n add[l].push_back(seg.idx);\n remove[r].push_back(seg.idx);\n }\n set st;\n double ans = 0;\n for (int i = 0; i < (int) a.size() - 1; i++) {\n //cout << i << endl;\n cur_ang = (a[i] + a[i + 1]) / 2;\n for (auto& x : add[i]) {\n st.insert(x);\n }\n for (auto& x : remove[i]) {\n assert(st.count(x));\n st.erase(x);\n }\n if ((int) st.size() >= 2) {\n line l1 = segments[*st.begin()], l2 = segments[*next(st.begin())];\n point v = intersection(l1, a[i]), w = intersection(l1, a[i + 1]);\n ans -= cross(v, w);\n v = intersection(l2, a[i]), w = intersection(l2, a[i + 1]);\n ans += cross(v, w);\n }\n }\n for (auto& x : remove.back()) {\n st.erase(x);\n }\n assert(st.empty());\n cout << fixed << setprecision(10) << ans / 2.0 << '\\n';\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9a1adf049a7417fd677cbc0af531627e", "src_uid": "f88b322137318b2fbae4f54a613b170c", "difficulty": 3000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int max_n = 511, mod = 1000000007;\n\nint t, k;\nlong long pw[max_n], pw2[max_n];\nint dp[max_n], sumdp[max_n], sums[max_n][max_n];\nchar ll[max_n], rr[max_n];\nstring l, r;\n\nint sum_dp(int r) {\n return sumdp[r];\n}\n\nvoid get_dp() {\n pw[0] = 1;\n pw2[0] = 1;\n for (int i = 1; i < max_n; ++i) {\n pw[i] = (pw[i - 1] * 10) % mod;\n pw2[i] = (pw2[i - 1] * 8) % mod;\n }\n dp[0] = dp[1] = 0;\n for (int len = 2; len < max_n; ++len) {\n //cout << dp[len - 1] << endl;\n for (int i = 1; i <= len; ++i) {\n for (int j = i + 1; j <= len && j - i <= k; ++j) {\n long long x = (pw2[j - i - 1] * pw[len - j]) % mod;\n int poz = i - k;\n if (poz > 1) {\n //cout << poz - 1 << endl;\n x = (x * pw2[k]) % mod;\n long long y = ((9 * pw[poz - 2] - dp[poz - 1]/*sum_dp(poz - 1)*/) % mod + mod) % mod;\n x = (x * y) % mod;\n } else {\n if (i != 1) {\n x = (x * pw2[i - 2] * 7) % mod;\n }\n }\n //if (len == 6) cout << i << \" \" << j << \" - \" << x << endl;\n x = (x * 4) % mod;\n dp[len] = (dp[len] + x) % mod;\n }\n }\n sumdp[len] = (sumdp[len - 1] + dp[len]) % mod;\n }\n //cout << dp[6] << endl;\n}\n\nbool ok(string s) {\n int last = -11111;\n for (int i = 0; i < s.length(); ++i) {\n if (s[i] == '4' || s[i] == '7') {\n if (i - last <= k) {\n return true;\n }\n last = i;\n }\n }\n return false;\n}\n\nbool happy(int x) {\n return x == 4 || x == 7;\n}\n\nvoid get_all_sum() {\n for (int st = 0; st < max_n; ++st) {\n sums[st][1] = (2 * pw[st] * pw2[0]) % mod;\n for (int cnt = 2; cnt <= st + 1; ++cnt) {\n sums[st][cnt] = (sums[st][cnt - 1] + 2 * pw[st - cnt + 1] * pw2[cnt - 1]) % mod;\n }\n }\n}\n\nlong long sum(int st, int cnt) {\n if (cnt < 0 || st < 0) {\n return 0;\n }\n return sums[st][cnt];\n}\n\nlong long fun(string r) {\n int res = sumdp[r.length() - 1];\n int last = -111111;\n for (int i = 0; i < r.length(); ++i) {\n int st = 0, fin = r[i] - '0';\n if (i == 0) {\n st = 1;\n }\n for (int j = st; j < fin; ++j) {\n if (happy(j)) {\n if (i - last <= k) {\n res = (res + pw[r.length() - i - 1]) % mod;\n } else {\n res = (res + sum(r.length() - i - 2, min((int) r.length() - 1, i + k) - i)) % mod;\n int poz = i + k + 1;\n if (poz < r.length()) {\n long long x = (pw2[k] * sum_dp(r.length() - poz)) % mod;\n res = (res + x) % mod;\n }\n }\n } else {\n if (last < 0) {\n res = (res + sum_dp(r.length() - i - 1)) % mod;\n } else {\n res = (res + sum(r.length() - i - 2, min((int) r.length() - 1, k + last) - i)) % mod;\n int poz = max(i + 1, last + k + 1);\n if (poz < r.length()) {\n long long x = (pw2[poz - i - 1] * sum_dp(r.length() - poz)) % mod;\n res = (res + x) % mod;\n }\n }\n }\n }\n if (happy(fin)) {\n if (i - last <= k) {\n res = (res + 1) % mod;\n long long x = 0;\n for (int j = i + 1; j < r.length(); ++j) {\n x = (x * 10 + r[j] - '0') % mod;\n }\n res = (res + x) % mod;\n return res;\n }\n last = i;\n }\n }\n return res;\n}\n\nint main() {\n //freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n cin >> t >> k;\n get_dp();\n get_all_sum();\n while (t--) {\n scanf(\"%s%s\", ll, rr);\n l = ll;\n r = rr;\n long long x = fun(r);\n long long y = fun(l);\n long long ans = ((x - y) % mod + mod) % mod;\n if (ok(l)) {\n ans = (ans + 1) % mod;\n }\n cout << ans << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "63ec2aeb4842cf6b6b0878fe9fc78acb", "src_uid": "5517efa2fc9362fdf342d32adac889f4", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int max_n = 511, mod = 1000000007;\n\nint t, k;\nlong long pw[max_n], pw2[max_n];\nint dp[max_n], sumdp[max_n], sums[max_n][max_n];\nchar ll[max_n], rr[max_n];\nstring l, r;\n\nint sum_dp(int r) {\n return sumdp[r];\n}\n\nvoid get_dp() {\n pw[0] = 1;\n pw2[0] = 1;\n for (int i = 1; i < max_n; ++i) {\n pw[i] = (pw[i - 1] * 10) % mod;\n pw2[i] = (pw2[i - 1] * 8) % mod;\n }\n dp[0] = dp[1] = 0;\n for (int len = 2; len < max_n; ++len) {\n //cout << dp[len - 1] << endl;\n for (int i = 1; i <= len; ++i) {\n for (int j = i + 1; j <= len && j - i <= k; ++j) {\n long long x = (pw2[j - i - 1] * pw[len - j]) % mod;\n int poz = i - k;\n if (poz > 1) {\n //cout << poz - 1 << endl;\n x = (x * pw2[k]) % mod;\n long long y = ((9 * pw[poz - 2] - dp[poz - 1]/*sum_dp(poz - 1)*/) % mod + mod) % mod;\n x = (x * y) % mod;\n } else {\n if (i != 1) {\n x = (x * pw2[i - 2] * 7) % mod;\n }\n }\n //if (len == 6) cout << i << \" \" << j << \" - \" << x << endl;\n x = (x * 4) % mod;\n dp[len] = (dp[len] + x) % mod;\n }\n }\n sumdp[len] = (sumdp[len - 1] + dp[len]) % mod;\n }\n //cout << dp[6] << endl;\n}\n\nbool ok(string s) {\n int last = -11111;\n for (int i = 0; i < s.length(); ++i) {\n if (s[i] == '4' || s[i] == '7') {\n if (i - last <= k) {\n return true;\n }\n last = i;\n }\n }\n return false;\n}\n\nbool happy(int x) {\n return x == 4 || x == 7;\n}\n\nvoid get_all_sum() {\n for (int st = 0; st < max_n; ++st) {\n sums[st][1] = (2 * pw[st] * pw2[0]) % mod;\n for (int cnt = 2; cnt <= st + 1; ++cnt) {\n sums[st][cnt] = (sums[st][cnt - 1] + 2 * pw[st - cnt + 1] * pw2[cnt - 1]) % mod;\n }\n }\n}\n\nlong long sum(int st, int cnt) {\n if (cnt < 0 || st < 0) {\n return 0;\n }\n /*long long res = 0;\n for (int q = 0; q < cnt; ++q) {\n long long x = (2 * pw[st - q] * pw2[q]) % mod;\n res = (res + x) % mod;\n }\n cout << st << \" \" << cnt << \" - \" << sums[st][cnt] << \" res = \" << res << endl;*/\n return sums[st][cnt];\n}\n\nlong long fun(string r) {\n long long res = 0;\n for (int i = 1; i < r.length(); ++i) {\n res = (res + dp[i]) % mod;\n }\n int last = -111111;\n //cout << r << \" - \" << res << endl;\n for (int i = 0; i < r.length(); ++i) {\n //cout << \"i = \" << i << \" \" << r << \" - \" << res << \" last = \" << last << endl;\n int st = 0, fin = r[i] - '0';\n if (i == 0) {\n st = 1;\n }\n for (int j = st; j < fin; ++j) {\n if (happy(j)) {\n if (i - last <= k) {\n res = (res + pw[r.length() - i - 1]) % mod;\n } else {\n //@@@@@@;\n res = (res + sum(r.length() - i - 2, min((int) r.length() - 1, i + k) - i)) % mod;\n int poz = i + k + 1;\n if (poz < r.length()) {\n long long x = (pw2[k] * sum_dp(r.length() - poz)) % mod;\n //cout << \"+=\" << x << endl;\n res = (res + x) % mod;\n }\n }\n } else {\n if (last < 0) {\n res = (res + sum_dp(r.length() - i - 1));\n } else {\n res = (res + sum(r.length() - i - 2, min((int) r.length() - 1, k + last) - i)) % mod;\n int poz = max(i + 1, last + k + 1);\n if (poz < r.length()) {\n long long x = (pw2[poz - i - 1] * sum_dp(r.length() - poz)) % mod;\n //cout << \"+=\" << x << endl;\n res = (res + x) % mod;\n }\n }\n }\n //cout << \" j = \" << j << \" \" << r << \" - \" << res << endl;\n }\n if (happy(fin)) {\n if (i - last <= k) {\n //cout << r << \" !-! \" << res << endl;\n res = (res + 1) % mod;\n long long x = 0;\n for (int j = i + 1; j < r.length(); ++j) {\n x = (x * 10 + r[j] - '0') % mod;\n }\n res = (res + x) % mod;\n return res;\n }\n last = i;\n }\n }\n return res;\n}\n\nlong long solve2() {\n string a = l;\n int res = 0;\n if (ok(r)) {\n ++res;\n }\n while (a != r) {\n //cout << a << endl;\n //for (int i = 1; i < 111111111; ++i);\n if (ok(a)) {\n ++res;\n }\n int poz = a.length() - 1;\n while (poz >= 0 && a[poz] == '9') {\n --poz;\n }\n if (poz == -1) {\n for (int i = 0; i < a.length(); ++i) {\n a[i] = '0';\n }\n a = \"1\" + a;\n } else {\n ++a[poz];\n for (int i = poz + 1; i < a.length(); ++i) {\n a[i] = '0';\n }\n }\n }\n return res;\n}\n\nint main() {\n //freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n cin >> t >> k;\n get_dp();\n get_all_sum();\n //cout << dp[2] << \" \" << dp[3] << \" \" << dp[4];\n while (t--) {\n scanf(\"%s%s\", ll, rr);\n l = ll;\n r = rr;\n long long x = fun(r);\n long long y = fun(l);\n long long ans = ((x - y) % mod + mod) % mod;\n if (ok(l)) {\n ans = (ans + 1) % mod;\n }\n cout << ans << endl;\n //cout << ans << \" \" << x << \" \" << y << endl;\n //cout << solve2() << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "005f166a1dc9b0d4d1818f5edd4e08cd", "src_uid": "5517efa2fc9362fdf342d32adac889f4", "difficulty": 2500.0} {"lang": "MS C++", "source_code": "#define _CRT_SECURE_NO_DEPRECATE\n#pragma comment(linker, \"/STACK:64000000\")\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n\nusing namespace std;\n\ntypedef long long int64;\n\n#define forn(i, n) for(int i = 0; i < (int)(n); i++)\n#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)\n#define pb push_back\n#define mp make_pair\n#define all(a) a.begin(), a.end()\n\nconst int INF = (int)1E9;\nconst int64 INF64 = (int64)1E18;\nconst long double EPS = 1E-8;\nconst long double PI = 3.1415926535897932384626433832795;\n\nconst int MAXN = 1100;\n\n\nbool used[MAXN];\nint n, m, X, Y;\nint64 dist[MAXN][MAXN], t[MAXN], c[MAXN], d[MAXN];\nvector g[MAXN];\nvector w[MAXN];\nset > q;\n\nvoid update(int v, int64 dist, int64 * d) {\n\tif (dist < d[v]) {\n\t\tq.erase(mp(d[v], v));\n\t\td[v] = dist;\n\t\tq.insert(mp(d[v], v));\n\n\t}\n}\n\nvoid dijkstra(int start, int64 * d) {\n\td[start] = 0;\n\tq.insert(mp(d[start], start));\n\twhile (!q.empty()) {\n\t\tint v = q.begin()->second;\n\t\tq.erase(q.begin());\n\n\t\tforn(i, g[v].size())\n\t\t\tupdate(g[v][i], d[v] + w[v][i], d);\n\t}\n}\n\n\nint main(){\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"rt\", stdin);\n\tfreopen(\"output.txt\", \"wt\", stdout);\n#endif\n\n\tcin >> n >> m >> X >> Y;\n\tX--; Y--;\n\tforn(i, m) {\n\t\tint v, u, wei;\n\t\tcin >> v >> u >> wei;\n\t\tv--; u--;\n\n\t\tg[v].pb(u);\n\t\tw[v].pb(wei);\n\n\t\tg[u].pb(v);\n\t\tw[u].pb(wei);\n\t}\n\n\tforn(i, n)\n\t\tcin >> t[i] >> c[i];\n\n\tmemset(dist, 60, sizeof dist);\n\tforn(i, n)\n\t\tdijkstra(i, dist[i]);\n\n\tmemset(d, 60, sizeof d);\n\td[X] = 0;\n\twhile (true) {\n\t\tint v = -1;\n\t\tint64 D = INF64;\n\t\tforn(i, n)\n\t\t\tif (!used[i] && D > d[i]) {\n\t\t\t\tv = i;\n\t\t\t\tD = d[i];\n\t\t\t}\n\t\t\n\t\tif (v == -1) break;\n\t\tused[v] = true;\n\n\t\tforn(u, n)\n\t\t\tif (dist[v][u] <= t[v])\n\t\t\t\td[u] = min(d[u], d[v] + c[v]);\n\t}\n\n\tif (d[Y] > INF64/2)\n\t\tcout << -1 << endl;\n\telse\n\t\tcout << d[Y] << endl;\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "71e876d37e9fe65caf52c659e7bc7dbb", "src_uid": "5517efa2fc9362fdf342d32adac889f4", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n#define ll long long\n#define mem(a,b) memset(a,b,sizeof(a))\n#define rep(i,a,b) for (int i=a;i<=b;i++)\n#define per(i,a,b) for (int i=a;i>=b;i--)\n#define paii pair\n#define MK(a,b) make_pair(a,b)\nconst ll MOD=1e9+7;\nint a[3005];\nll dp[3005][3005][5];\nint k;\nll dfs(int pos,int pre,int sta,bool limit){\n if (pos<0)\n return sta;\n if (!limit&&dp[pos][pre][sta]!=-1)\n return dp[pos][pre][sta];\n int up=limit?a[pos]:9;\n ll tmp=0;\n rep(i,0,up){\n if (i==4||i==7)\n tmp=(tmp+dfs(pos-1,pos,sta||(pre!=-1&&abs(pre-pos)<=k),limit&&i==up))%MOD;\n else\n tmp=(tmp+dfs(pos-1,pre,sta,limit&&i==up))%MOD;\n }\n if (!limit)\n dp[pos][pre][sta]=tmp;\n return tmp;\n}\nll DP(char *s){\n int l=strlen(s);\n rep(i,0,l-1)\n a[l-i-1]=s[i]-'0';\n return dfs(l-1,-1,0,true);\n}\nchar le[1005],ri[1005];\nvoid solve(){\n mem(dp,-1);\n int t;\n scanf(\"%d%d\",&t,&k);\n while (t--){\n scanf(\"%s%s\",le,ri);\n int p=0,tmp=-1,l=strlen(le);\n rep(i,0,l-1){\n if (le[i]=='4'||le[i]=='7'){\n if (tmp==-1||abs(i-tmp)>k)\n tmp=i;\n else {\n p=1;\n break;\n }\n }\n }\n //printf(\"%lld %lld\\n\",DP(ri),DP(le));\n printf(\"%lld\\n\",((DP(ri)-DP(le)+p)%MOD+MOD)%MOD);\n }\n}\nint main(){\n solve();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "da2b8a1308edb10894dc058ebd7d554d", "src_uid": "5517efa2fc9362fdf342d32adac889f4", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nconst int mod = 777777777;\nlong long f[260][260][260];\nlong long c[260][260];\nint ans[10][260] = \n{\n{1,0},\n{1,2,1},\n{5,32,30,80,109},\n{541,6824,59808,147224,415870,1757896,1897056,4898872,7593125},\n{166257661,776830421,290516100,746623577,293783147,33900006,735127505,565460332,428982705,472062098,161873957,117354594,515619293,578944191,312106242,569389279,391464593},\n{464207287,261086313,584837659,683961846,468868529,211593382,736955478,229471758,157617135,398169441,360252438,629394768,264125799,647490480,342079395,391579767,225200475,486011304,513156108,628771752,132906648,142138221,20119449,444199674,195188679,387329805,44684703,651912135,737154512,612549793,519860281,186175544,212568440},\n{382725349,240805271,239509872,581127897,6511239,156126222,509425833,672407328,366667722,459185405,509737025,554790222,165216555,703150560,74806569,398730015,383350905,506108358,51326142,298053147,104256117,391428765,374020479,206607807,87664059,275899176,56407680,551553401,448939463,582889860,129676638,226078251,135769095,61292868,578972226,190181628,390739055,184587732,446575689,732674124,232198470,676760679,352474101,611444862,575661807,628905585,320813094,522840969,469781928,156006018,554473341,239654268,643714911,433540170,199307003,496385218,291740751,67309914,370826673,202356819,279421821,421203111,63744786,520987612,550671827},\n{642497124,482164403,768209115,462063756,154906374,36099042,341766705,678182556,621882744,478771358,231881111,175889805,243630450,168908523,671961765,55761813,652682670,773939082,517628076,756201264,124604900,750976272,498253248,676047609,137170026,705610017,495032139,561797418,703097347,500815609,95984586,739707108,265613565,387099846,777331779,594676173,591219559,407997044,208947235,93337440,478908360,685013007,487033953,671903001,39521181,738490312,33785059,465470131,310453920,54648783,346831137,427694175,474743430,705296781,435828036,429824745,663532359,261388683,244690731,533997135,596108961,506813013,371892402,590145264,104733162,143420103,654339672,700348950,685038942,578826927,286484229,501639192,434962491,299270097,27702486,335375775,111746817,565603164,294926121,676063665,735862995,710035809,437011960,668528077,138765186,508213986,615036450,353784942,624827616,343900011,241289776,52410890,72018835,352406796,415705878,4802637,376367145,65589678,333633477,341834527,303717460,282387700,42951006,254706039,423048528,526429710,68131467,669954708,12787348,500636381,317959019,479433192,657133515,416259390,610216692,340129188,44594256,257373347,138718678,530767740,292922628,37220268,605295159,480722613,458170419,30540300,487159055,232966794,149150650},\n{507720408,412133651,386543325,139952108,289303402,102404925,317067177,396414708,80515854,663739304,317300809,228877044,493725043,715317967,490300965,315527373,743539734,488329191,553627998,533025234,242583957,706116537,614109258,645447222,523195911,492109128,722623041,111085128,766395126,654378921,691964847,496688157,399056049,654363234,102052314,191720088,473910948,259736526,332840025,388047555,665791056,627111387,139696515,441456687,443032569,283264821,771641703,452641455,511306362,117572859,127701891,721298331,176520078,357242229,611296308,696994956,405628839,429224274,465336054,695091546,689828796,574648641,351220905,507964023,675326610,517248963,453528621,220301928,494463186,681789969,339589656,44524053,417125457,339589404,747135963,341780733,734158215,396817281,21997836,5728464,147611205,456248898,714128667,377654949,3862068,128418948,589390074,304947090,11703825,228266073,127304142,429215724,361541124,521572968,468358191,341231688,65323503,613778508,15985323,291661029,410970006,591638112,349541550,89967528,224922159,361094166,584206074,640051812,324264456,652625388,693768537,11740617,309238398,211085469,194905872,639416484,110110707,296645895,748118511,131177718,511142751,775975599,421403409,475528473,434685258,1768977,80301375,708023862,569195676,56238084,632887668,88089750,631539342,396695565,38780154,695798271,469819224,439587099,69045921,682966116,112310856,64943298,534475872,40215357,389728458,286368453,736006257,501181650,54829908,603489402,338032656,512182818,627500097,462674016,3103092,157324491,43978329,596818971,259025598,9088632,91991781,577291428,211245489,429471231,142626330,172560633,510907446,444609585,758102058,375112647,744786693,276174402,19259856,233672418,745389414,225772848,23385663,324290610,519804558,120337812,402578568,360676008,450089262,551043738,337388940,512108856,28879011,690040638,106017282,558262341,99972432,608226003,612152037,42414435,776201013,39580443,518796945,494437752,583194366,723936555,415359657,309569589,751104774,166684527,249229170,353120823,130668327,753823584,580966092,561963717,543672234,393846327,586278000,327398400,278403867,156455586,363920382,190245195,290039148,547014447,466218648,146037150,585462906,666008595,691786683,374707494,622498779,231158277,685740951,115612245,681825249,545555745,551718468,277206615,640171035,757727334,195193908,658656684,457760646,225925875,505761984,18685233,506832921,112511021,396846646,290147622,113924623,669986155,336008070,63611061,238586775,119956662,616557739,772784623,334527774,410403148,51933421}\n};\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "04d84193b9ef8b3945e595cd5e958793", "src_uid": "cfe19131644e5925e32084a581e23286", "difficulty": 2700.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#if LOCAL\n\t#define DO_NOT_SEND\n#endif\n\ntypedef long long LL;\n\nint IntMaxVal = (int) 1e20;\nint IntMinVal = (int) -1e20;\nLL LongMaxVal = (LL) 1e20;\nLL LongMinVal = (LL) -1e20;\n\n#define FOR(i, a, b) for(int i = a; i < b ; ++i)\n#define FORD(i, a, b) for(int i = a; i >= b; --i)\n\n#define minimize(a, b) { a = min(a, b); }\n#define maximize(a, b) { a = max(a, b); }\n\n#define all(v) v.begin(),v.end()\n\nusing namespace std;\n\n#define next(type, i) type i; cin >> i;\ntemplate struct argument_type;\ntemplate struct argument_type { typedef U type; };\n#define nextVector(t, v, size) vector< argument_type::type > v(size); { for (int i = 0 ; i < size ; i++) cin >> v[i]; }\n\n#define range(name, start, count) vector name(count); { for (int i = 0 ; i < count ; i++) name[i] = i + start; }\n\ntemplate istream& operator >>(istream& is, pair& s) { is >> s.first >> s.second; return is; }\ntemplate ostream& operator << (ostream& os, const vector &v) { for (int i = 0 ; i < v.size() ; i++) os << v[i] << ' '; os << endl; return os; }\ntemplate ostream& operator <<(ostream& s, pair& t) { s << t.first << ' ' << t.second; return s; }\n\nconst int mod = 777777777;\n\nLL add(LL a, LL b) {\n\treturn (a + b) % mod;\n}\n\nLL mult(LL a, LL b) {\n\treturn a * b % mod;\n}\n\nLL waysToMerge[257][257];\nLL ans[257][257];\n\nint main() {\n\tsrand (time(NULL));\n ios_base::sync_with_stdio(false); cin.tie(NULL);\n\t\n\tFOR (i, 0, 257) waysToMerge[i][0] = 1;\n\tFOR (i, 0, 257) FOR (j, 1, 257) {\n\t\twaysToMerge[i][j] = 0;\n\t\tFOR (k, 0, i + 1) waysToMerge[i][j] = add(waysToMerge[i][j], waysToMerge[i - k][j - 1]);\n\t}\n\t\n\tnext(int, n);\n\tnext(int, k);\n\t\n\tFOR (i, 0, 257) ans[0][i] = 0;\n\tans[0][0] = 1;\n\t\n\tbool debug = 0;\n\tFOR (upTo, 1, n + 1) FOR (ppl, 0, n + 1) {\n\t\tans[upTo][ppl] = 0;\n\t\tFOR (x, 0, ppl + 1) {\n\t\t\tif (debug) cout << upTo << ' ' << ppl << ' ' << x << endl; DO_NOT_SEND\n\t\t\tif (x == upTo && x > n - k) { if (debug) cout << \"skip1\" << endl; continue; }\n\t\t\tif (upTo == n - k && x != upTo) { if (debug) cout << \"skip2\" << endl; continue; }\n\t\t\t\n\t\t\tans[upTo][ppl] = add(ans[upTo][ppl], mult(waysToMerge[x][ppl - x], ans[upTo - 1][ppl - x]));\n\t\t}\n\t\tif (debug) cout << \"== \" << upTo << ' ' << ppl << ' ' << ans[upTo][ppl] << endl;\n\t}\n\t\n\tcout << ans[n][n];\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d67ac1eee749624f737ce4e6682137b9", "src_uid": "cfe19131644e5925e32084a581e23286", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "using namespace std;\n/*\nlong ways,temp,s;\nlong n,k,dp[(1<<8)+5][(1<<8)+5][1<<9];\nlong c[1<<10][1<<10];\n\nvoid add(long&a,long&b)\n{\n a+=b;\n if (a>=bs)a-=bs;\n}\n*/\n\nlong dp[300][300];\n\nint main(){\n//freopen(\"rush.in\",\"r\",stdin);\n//freopen(\"rush.out\",\"w\",stdout);\n//freopen(\"C:/input.txt\",\"r\",stdin);\n//freopen(\"C:/output.txt\",\"w\",stdout);\nios_base::sync_with_stdio(0);\n//cin.tie(0);\ndp[1][1]=0;\ndp[2][1]=2;\ndp[2][2]=1;\ndp[4][1]=32;\ndp[4][2]=30;\ndp[4][3]=80;\ndp[4][4]=109;\ndp[8][1]=6824;\ndp[8][2]=59808;\ndp[8][3]=147224;\ndp[8][4]=415870;\ndp[8][5]=1757896;\ndp[8][6]=1897056;\ndp[8][7]=4898872;\ndp[8][8]=7593125;\ndp[16][1]=776830421;\ndp[16][2]=290516100;\ndp[16][3]=746623577;\ndp[16][4]=293783147;\ndp[16][5]=33900006;\ndp[16][6]=735127505;\ndp[16][7]=565460332;\ndp[16][8]=428982705;\ndp[16][9]=472062098;\ndp[16][10]=161873957;\ndp[16][11]=117354594;\ndp[16][12]=515619293;\ndp[16][13]=578944191;\ndp[16][14]=312106242;\ndp[16][15]=569389279;\ndp[16][16]=391464593;\ndp[32][1]=261086313;\ndp[32][2]=584837659;\ndp[32][3]=683961846;\ndp[32][4]=468868529;\ndp[32][5]=211593382;\ndp[32][6]=736955478;\ndp[32][7]=229471758;\ndp[32][8]=157617135;\ndp[32][9]=398169441;\ndp[32][10]=360252438;\ndp[32][11]=629394768;\ndp[32][12]=264125799;\ndp[32][13]=647490480;\ndp[32][14]=342079395;\ndp[32][15]=391579767;\ndp[32][16]=225200475;\ndp[32][17]=486011304;\ndp[32][18]=513156108;\ndp[32][19]=628771752;\ndp[32][20]=132906648;\ndp[32][21]=142138221;\ndp[32][22]=20119449;\ndp[32][23]=444199674;\ndp[32][24]=195188679;\ndp[32][25]=387329805;\ndp[32][26]=44684703;\ndp[32][27]=651912135;\ndp[32][28]=737154512;\ndp[32][29]=612549793;\ndp[32][30]=519860281;\ndp[32][31]=186175544;\ndp[32][32]=212568440;\ndp[64][1]=240805271;\ndp[64][2]=239509872;\ndp[64][3]=581127897;\ndp[64][4]=6511239;\ndp[64][5]=156126222;\ndp[64][6]=509425833;\ndp[64][7]=672407328;\ndp[64][8]=366667722;\ndp[64][9]=459185405;\ndp[64][10]=509737025;\ndp[64][11]=554790222;\ndp[64][12]=165216555;\ndp[64][13]=703150560;\ndp[64][14]=74806569;\ndp[64][15]=398730015;\ndp[64][16]=383350905;\ndp[64][17]=506108358;\ndp[64][18]=51326142;\ndp[64][19]=298053147;\ndp[64][20]=104256117;\ndp[64][21]=391428765;\ndp[64][22]=374020479;\ndp[64][23]=206607807;\ndp[64][24]=87664059;\ndp[64][25]=275899176;\ndp[64][26]=56407680;\ndp[64][27]=551553401;\ndp[64][28]=448939463;\ndp[64][29]=582889860;\ndp[64][30]=129676638;\ndp[64][31]=226078251;\ndp[64][32]=135769095;\ndp[64][33]=61292868;\ndp[64][34]=578972226;\ndp[64][35]=190181628;\ndp[64][36]=390739055;\ndp[64][37]=184587732;\ndp[64][38]=446575689;\ndp[64][39]=732674124;\ndp[64][40]=232198470;\ndp[64][41]=676760679;\ndp[64][42]=352474101;\ndp[64][43]=611444862;\ndp[64][44]=575661807;\ndp[64][45]=628905585;\ndp[64][46]=320813094;\ndp[64][47]=522840969;\ndp[64][48]=469781928;\ndp[64][49]=156006018;\ndp[64][50]=554473341;\ndp[64][51]=239654268;\ndp[64][52]=643714911;\ndp[64][53]=433540170;\ndp[64][54]=199307003;\ndp[64][55]=496385218;\ndp[64][56]=291740751;\ndp[64][57]=67309914;\ndp[64][58]=370826673;\ndp[64][59]=202356819;\ndp[64][60]=279421821;\ndp[64][61]=421203111;\ndp[64][62]=63744786;\ndp[64][63]=520987612;\ndp[64][64]=550671827;\ndp[128][1]=482164403;\ndp[128][2]=768209115;\ndp[128][3]=462063756;\ndp[128][4]=154906374;\ndp[128][5]=36099042;\ndp[128][6]=341766705;\ndp[128][7]=678182556;\ndp[128][8]=621882744;\ndp[128][9]=478771358;\ndp[128][10]=231881111;\ndp[128][11]=175889805;\ndp[128][12]=243630450;\ndp[128][13]=168908523;\ndp[128][14]=671961765;\ndp[128][15]=55761813;\ndp[128][16]=652682670;\ndp[128][17]=773939082;\ndp[128][18]=517628076;\ndp[128][19]=756201264;\ndp[128][20]=124604900;\ndp[128][21]=750976272;\ndp[128][22]=498253248;\ndp[128][23]=676047609;\ndp[128][24]=137170026;\ndp[128][25]=705610017;\ndp[128][26]=495032139;\ndp[128][27]=561797418;\ndp[128][28]=703097347;\ndp[128][29]=500815609;\ndp[128][30]=95984586;\ndp[128][31]=739707108;\ndp[128][32]=265613565;\ndp[128][33]=387099846;\ndp[128][34]=777331779;\ndp[128][35]=594676173;\ndp[128][36]=591219559;\ndp[128][37]=407997044;\ndp[128][38]=208947235;\ndp[128][39]=93337440;\ndp[128][40]=478908360;\ndp[128][41]=685013007;\ndp[128][42]=487033953;\ndp[128][43]=671903001;\ndp[128][44]=39521181;\ndp[128][45]=738490312;\ndp[128][46]=33785059;\ndp[128][47]=465470131;\ndp[128][48]=310453920;\ndp[128][49]=54648783;\ndp[128][50]=346831137;\ndp[128][51]=427694175;\ndp[128][52]=474743430;\ndp[128][53]=705296781;\ndp[128][54]=435828036;\ndp[128][55]=429824745;\ndp[128][56]=663532359;\ndp[128][57]=261388683;\ndp[128][58]=244690731;\ndp[128][59]=533997135;\ndp[128][60]=596108961;\ndp[128][61]=506813013;\ndp[128][62]=371892402;\ndp[128][63]=590145264;\ndp[128][64]=104733162;\ndp[128][65]=143420103;\ndp[128][66]=654339672;\ndp[128][67]=700348950;\ndp[128][68]=685038942;\ndp[128][69]=578826927;\ndp[128][70]=286484229;\ndp[128][71]=501639192;\ndp[128][72]=434962491;\ndp[128][73]=299270097;\ndp[128][74]=27702486;\ndp[128][75]=335375775;\ndp[128][76]=111746817;\ndp[128][77]=565603164;\ndp[128][78]=294926121;\ndp[128][79]=676063665;\ndp[128][80]=735862995;\ndp[128][81]=710035809;\ndp[128][82]=437011960;\ndp[128][83]=668528077;\ndp[128][84]=138765186;\ndp[128][85]=508213986;\ndp[128][86]=615036450;\ndp[128][87]=353784942;\ndp[128][88]=624827616;\ndp[128][89]=343900011;\ndp[128][90]=241289776;\ndp[128][91]=52410890;\ndp[128][92]=72018835;\ndp[128][93]=352406796;\ndp[128][94]=415705878;\ndp[128][95]=4802637;\ndp[128][96]=376367145;\ndp[128][97]=65589678;\ndp[128][98]=333633477;\ndp[128][99]=341834527;\ndp[128][100]=303717460;\ndp[128][101]=282387700;\ndp[128][102]=42951006;\ndp[128][103]=254706039;\ndp[128][104]=423048528;\ndp[128][105]=526429710;\ndp[128][106]=68131467;\ndp[128][107]=669954708;\ndp[128][108]=12787348;\ndp[128][109]=500636381;\ndp[128][110]=317959019;\ndp[128][111]=479433192;\ndp[128][112]=657133515;\ndp[128][113]=416259390;\ndp[128][114]=610216692;\ndp[128][115]=340129188;\ndp[128][116]=44594256;\ndp[128][117]=257373347;\ndp[128][118]=138718678;\ndp[128][119]=530767740;\ndp[128][120]=292922628;\ndp[128][121]=37220268;\ndp[128][122]=605295159;\ndp[128][123]=480722613;\ndp[128][124]=458170419;\ndp[128][125]=30540300;\ndp[128][126]=487159055;\ndp[128][127]=232966794;\ndp[128][128]=149150650;\ndp[256][1]=412133651;\ndp[256][2]=386543325;\ndp[256][3]=139952108;\ndp[256][4]=289303402;\ndp[256][5]=102404925;\ndp[256][6]=317067177;\ndp[256][7]=396414708;\ndp[256][8]=80515854;\ndp[256][9]=663739304;\ndp[256][10]=317300809;\ndp[256][11]=228877044;\ndp[256][12]=493725043;\ndp[256][13]=715317967;\ndp[256][14]=490300965;\ndp[256][15]=315527373;\ndp[256][16]=743539734;\ndp[256][17]=488329191;\ndp[256][18]=553627998;\ndp[256][19]=533025234;\ndp[256][20]=242583957;\ndp[256][21]=706116537;\ndp[256][22]=614109258;\ndp[256][23]=645447222;\ndp[256][24]=523195911;\ndp[256][25]=492109128;\ndp[256][26]=722623041;\ndp[256][27]=111085128;\ndp[256][28]=766395126;\ndp[256][29]=654378921;\ndp[256][30]=691964847;\ndp[256][31]=496688157;\ndp[256][32]=399056049;\ndp[256][33]=654363234;\ndp[256][34]=102052314;\ndp[256][35]=191720088;\ndp[256][36]=473910948;\ndp[256][37]=259736526;\ndp[256][38]=332840025;\ndp[256][39]=388047555;\ndp[256][40]=665791056;\ndp[256][41]=627111387;\ndp[256][42]=139696515;\ndp[256][43]=441456687;\ndp[256][44]=443032569;\ndp[256][45]=283264821;\ndp[256][46]=771641703;\ndp[256][47]=452641455;\ndp[256][48]=511306362;\ndp[256][49]=117572859;\ndp[256][50]=127701891;\ndp[256][51]=721298331;\ndp[256][52]=176520078;\ndp[256][53]=357242229;\ndp[256][54]=611296308;\ndp[256][55]=696994956;\ndp[256][56]=405628839;\ndp[256][57]=429224274;\ndp[256][58]=465336054;\ndp[256][59]=695091546;\ndp[256][60]=689828796;\ndp[256][61]=574648641;\ndp[256][62]=351220905;\ndp[256][63]=507964023;\ndp[256][64]=675326610;\ndp[256][65]=517248963;\ndp[256][66]=453528621;\ndp[256][67]=220301928;\ndp[256][68]=494463186;\ndp[256][69]=681789969;\ndp[256][70]=339589656;\ndp[256][71]=44524053;\ndp[256][72]=417125457;\ndp[256][73]=339589404;\ndp[256][74]=747135963;\ndp[256][75]=341780733;\ndp[256][76]=734158215;\ndp[256][77]=396817281;\ndp[256][78]=21997836;\ndp[256][79]=5728464;\ndp[256][80]=147611205;\ndp[256][81]=456248898;\ndp[256][82]=714128667;\ndp[256][83]=377654949;\ndp[256][84]=3862068;\ndp[256][85]=128418948;\ndp[256][86]=589390074;\ndp[256][87]=304947090;\ndp[256][88]=11703825;\ndp[256][89]=228266073;\ndp[256][90]=127304142;\ndp[256][91]=429215724;\ndp[256][92]=361541124;\ndp[256][93]=521572968;\ndp[256][94]=468358191;\ndp[256][95]=341231688;\ndp[256][96]=65323503;\ndp[256][97]=613778508;\ndp[256][98]=15985323;\ndp[256][99]=291661029;\ndp[256][100]=410970006;\ndp[256][101]=591638112;\ndp[256][102]=349541550;\ndp[256][103]=89967528;\ndp[256][104]=224922159;\ndp[256][105]=361094166;\ndp[256][106]=584206074;\ndp[256][107]=640051812;\ndp[256][108]=324264456;\ndp[256][109]=652625388;\ndp[256][110]=693768537;\ndp[256][111]=11740617;\ndp[256][112]=309238398;\ndp[256][113]=211085469;\ndp[256][114]=194905872;\ndp[256][115]=639416484;\ndp[256][116]=110110707;\ndp[256][117]=296645895;\ndp[256][118]=748118511;\ndp[256][119]=131177718;\ndp[256][120]=511142751;\ndp[256][121]=775975599;\ndp[256][122]=421403409;\ndp[256][123]=475528473;\ndp[256][124]=434685258;\ndp[256][125]=1768977;\ndp[256][126]=80301375;\ndp[256][127]=708023862;\ndp[256][128]=569195676;\ndp[256][129]=56238084;\ndp[256][130]=632887668;\ndp[256][131]=88089750;\ndp[256][132]=631539342;\ndp[256][133]=396695565;\ndp[256][134]=38780154;\ndp[256][135]=695798271;\ndp[256][136]=469819224;\ndp[256][137]=439587099;\ndp[256][138]=69045921;\ndp[256][139]=682966116;\ndp[256][140]=112310856;\ndp[256][141]=64943298;\ndp[256][142]=534475872;\ndp[256][143]=40215357;\ndp[256][144]=389728458;\ndp[256][145]=286368453;\ndp[256][146]=736006257;\ndp[256][147]=501181650;\ndp[256][148]=54829908;\ndp[256][149]=603489402;\ndp[256][150]=338032656;\ndp[256][151]=512182818;\ndp[256][152]=627500097;\ndp[256][153]=462674016;\ndp[256][154]=3103092;\ndp[256][155]=157324491;\ndp[256][156]=43978329;\ndp[256][157]=596818971;\ndp[256][158]=259025598;\ndp[256][159]=9088632;\ndp[256][160]=91991781;\ndp[256][161]=577291428;\ndp[256][162]=211245489;\ndp[256][163]=429471231;\ndp[256][164]=142626330;\ndp[256][165]=172560633;\ndp[256][166]=510907446;\ndp[256][167]=444609585;\ndp[256][168]=758102058;\ndp[256][169]=375112647;\ndp[256][170]=744786693;\ndp[256][171]=276174402;\ndp[256][172]=19259856;\ndp[256][173]=233672418;\ndp[256][174]=745389414;\ndp[256][175]=225772848;\ndp[256][176]=23385663;\ndp[256][177]=324290610;\ndp[256][178]=519804558;\ndp[256][179]=120337812;\ndp[256][180]=402578568;\ndp[256][181]=360676008;\ndp[256][182]=450089262;\ndp[256][183]=551043738;\ndp[256][184]=337388940;\ndp[256][185]=512108856;\ndp[256][186]=28879011;\ndp[256][187]=690040638;\ndp[256][188]=106017282;\ndp[256][189]=558262341;\ndp[256][190]=99972432;\ndp[256][191]=608226003;\ndp[256][192]=612152037;\ndp[256][193]=42414435;\ndp[256][194]=776201013;\ndp[256][195]=39580443;\ndp[256][196]=518796945;\ndp[256][197]=494437752;\ndp[256][198]=583194366;\ndp[256][199]=723936555;\ndp[256][200]=415359657;\ndp[256][201]=309569589;\ndp[256][202]=751104774;\ndp[256][203]=166684527;\ndp[256][204]=249229170;\ndp[256][205]=353120823;\ndp[256][206]=130668327;\ndp[256][207]=753823584;\ndp[256][208]=580966092;\ndp[256][209]=561963717;\ndp[256][210]=543672234;\ndp[256][211]=393846327;\ndp[256][212]=586278000;\ndp[256][213]=327398400;\ndp[256][214]=278403867;\ndp[256][215]=156455586;\ndp[256][216]=363920382;\ndp[256][217]=190245195;\ndp[256][218]=290039148;\ndp[256][219]=547014447;\ndp[256][220]=466218648;\ndp[256][221]=146037150;\ndp[256][222]=585462906;\ndp[256][223]=666008595;\ndp[256][224]=691786683;\ndp[256][225]=374707494;\ndp[256][226]=622498779;\ndp[256][227]=231158277;\ndp[256][228]=685740951;\ndp[256][229]=115612245;\ndp[256][230]=681825249;\ndp[256][231]=545555745;\ndp[256][232]=551718468;\ndp[256][233]=277206615;\ndp[256][234]=640171035;\ndp[256][235]=757727334;\ndp[256][236]=195193908;\ndp[256][237]=658656684;\ndp[256][238]=457760646;\ndp[256][239]=225925875;\ndp[256][240]=505761984;\ndp[256][241]=18685233;\ndp[256][242]=506832921;\ndp[256][243]=112511021;\ndp[256][244]=396846646;\ndp[256][245]=290147622;\ndp[256][246]=113924623;\ndp[256][247]=669986155;\ndp[256][248]=336008070;\ndp[256][249]=63611061;\ndp[256][250]=238586775;\ndp[256][251]=119956662;\ndp[256][252]=616557739;\ndp[256][253]=772784623;\ndp[256][254]=334527774;\ndp[256][255]=410403148;\ndp[256][256]=51933421;\n/*\nfor (int i=0;i<=1000;i++) \n for (int j=0;j<=i;j++)\n {\n if (j==0||j==i)\n c[i][j]=1;\n else\n c[i][j]=(c[i-1][j-1]+c[i-1][j])%bs;\n }\n\nfor (int n=1;n<=256;n*=2)\nfor (int k=1;k<=n;k++)\n{\n \nfor (int i=0;i<=n;i++)\n for (int j=0;j<=n;j++)\n for (int q=0;q<=n;q++)\n dp[i][j][q]=0;\n \ndp[0][0][0]=1;\n\nfor (int wrong=1;wrong<=n;wrong++)\n for (int used=0;used<=n;used++)\n for (int failed=0;failed<=k;failed++)\n {\n if (used-failed>n-k)continue;\n // screwd\n for (int ad=0;ad<=n-used&&ad+failed<=k;ad++)\n {\n if (ad==wrong)continue;\n ways=c[n-used][ad];\n temp=1ll*ways*dp[wrong-1][used][failed]%bs;\n if (ad==wrong)\n add(dp[wrong][used+ad][failed],temp);\n else\n add(dp[wrong][used+ad][failed+ad],temp);\n }\n // dd\n for (int ad=wrong;ad<=wrong;ad++)\n {\n if (ad+used>n)continue;\n ways=c[n-used][ad];\n temp=1ll*ways*dp[wrong-1][used][failed]%bs;\n if (ad==wrong)\n add(dp[wrong][used+ad][failed],temp);\n else\n add(dp[wrong][used+ad][failed+ad],temp);\n }\n \n }\n\ncout<<\"dp[\"<>n>>k;\ncout<\n#define mod 777777777\nint dp[260][260][260],n,k;\nint c[260][260];\nint x[260]={507720408,412133651,386543325,139952108,289303402,102404925,317067177,396414708,80515854,663739304,317300809,228877044,493725043,715317967,490300965,315527373,743539734,488329191,553627998,533025234,242583957,706116537,614109258,645447222,523195911,492109128,722623041,111085128,766395126,654378921,691964847,496688157,399056049,654363234,102052314,191720088,473910948,259736526,332840025,388047555,665791056,627111387,139696515,441456687,443032569,283264821,771641703,452641455,511306362,117572859,127701891,721298331,176520078,357242229,611296308,696994956,405628839,429224274,465336054,695091546,689828796,574648641,351220905,507964023,675326610,517248963,453528621,220301928,494463186,681789969,339589656,44524053,417125457,339589404,747135963,341780733,734158215,396817281,21997836,5728464,147611205,456248898,714128667,377654949,3862068,128418948,589390074,304947090,11703825,228266073,127304142,429215724,361541124,521572968,468358191,341231688,65323503,613778508,15985323,291661029,410970006,591638112,349541550,89967528,224922159,361094166,584206074,640051812,324264456,652625388,693768537,11740617,309238398,211085469,194905872,639416484,110110707,296645895,748118511,131177718,511142751,775975599,421403409,475528473,434685258,1768977,80301375,708023862,569195676,56238084,632887668,88089750,631539342,396695565,38780154,695798271,469819224,439587099,69045921,682966116,112310856,64943298,534475872,40215357,389728458,286368453,736006257,501181650,54829908,603489402,338032656,512182818,627500097,462674016,3103092,157324491,43978329,596818971,259025598,9088632,91991781,577291428,211245489,429471231,142626330,172560633,510907446,444609585,758102058,375112647,744786693,276174402,19259856,233672418,745389414,225772848,23385663,324290610,519804558,120337812,402578568,360676008,450089262,551043738,337388940,512108856,28879011,690040638,106017282,558262341,99972432,608226003,612152037,42414435,776201013,39580443,518796945,494437752,583194366,723936555,415359657,309569589,751104774,166684527,249229170,353120823,130668327,753823584,580966092,561963717,543672234,393846327,586278000,327398400,278403867,156455586,363920382,190245195,290039148,547014447,466218648,146037150,585462906,666008595,691786683,374707494,622498779,231158277,685740951,115612245,681825249,545555745,551718468,277206615,640171035,757727334,195193908,658656684,457760646,225925875,505761984,18685233,506832921,112511021,396846646,290147622,113924623,669986155,336008070,63611061,238586775,119956662,616557739,772784623,334527774,410403148,51933421};\nint main(){\n\tfor(int i=0;i<260;i++){\n\t\tfor(int j=0;j<=i;j++){\n\t\t\tif(j==0 || j==i) c[i][j] = 1;\n\t\t\telse c[i][j] = (c[i-1][j]+c[i-1][j-1])%mod;\n\t\t}\n\t}\n\tscanf(\"%d%d\",&n,&k);\n\tif(n==256){\n\t\tcout << x[k] << endl;\n\t\treturn 0;\n\t}\n\tdp[0][0][0] = 1;\n\tfor(int i=0;i\n#include \n#include \n#include \n#define N 200010\n#define int64 long long\n#define For(i,x,y) for (i=x;i<=y;i++)\nusing namespace std;\nint i,j,k,n,m,t,x,y;\nint head[3][N],a[3][N],next[3][N],g[N],fa[N];\nint64 s1[N],f[N],sum,len[3][N],ma[3],an,h[N][2],S1,S2,s[3];\nvoid dfs(int t,int x,int64 y) {\n int v;\n len[t][x]=y+f[x];\n sum+=len[t][x];\n ma[t]=max(ma[t],len[t][x]);\n for (v=head[t][x];v;v=next[t][v]) {\n int A=a[t][v]; int64 B=s[t]-s1[A];\n if (fa[x]!=A) dfs(t,A,y+B+f[x]-f[A]-s1[A]);\n }\n}\ninline void work(int x) {\n int l,r,v;\n g[l=r=1]=1; fa[1]=0;\n for (;l<=r;l++) {\n int A=g[l];\n for (v=head[x][A];v;v=next[x][v]) {\n int B=a[x][v];\n if (fa[A]!=B) {\n g[++r]=B; fa[B]=A;\n }\n }\n }\n for (l--;l;l--) {\n int A=g[l]; s1[A]=1; f[A]=0;\n for (v=head[x][A];v;v=next[x][v]) {\n int B=a[x][v];\n if (fa[A]!=B) {\n s1[A]+=s1[B]; f[A]+=s1[B]+f[B];\n }\n }\n }\n dfs(x,1,0);\n}\nvoid bfs(int x) {\n int l,r,v,i; int64 ans=0;\n g[l=r=1]=1; fa[1]=0;\n for (;l<=r;l++) {\n int A=g[l];\n for (v=head[x][A];v;v=next[x][v]) {\n int B=a[x][v];\n if (fa[A]!=B) {\n g[++r]=B; fa[B]=A;\n }\n }\n }\n For(i,0,2) if (i!=x) For(v,i+1,2) if (v!=x) {\n ans+=(ma[i]+s[i]+ma[v]+s[v])*s[x];\n ans+=ma[i]*s[v]+ma[v]*s[i]+s[i]*s[v]*2;\n S1=s[i],S2=s[v];\n }\n for (l--;l;l--) {\n int A=g[l],k1=0,k2=0;\n h[A][0]=len[x][A]*S1;\n h[A][1]=len[x][A]*S2;\n int64 maxx=h[A][0]+h[A][1];\n for (v=head[x][A];v;v=next[x][v]) {\n int B=a[x][v];\n if (fa[A]!=B) {\n h[A][0]=max(h[A][0],h[B][0]+S1*S2);\n h[A][1]=max(h[A][1],h[B][1]+S1*S2);\n if (h[B][0]>h[k1][0]) k1=B;\n if (h[B][1]>h[k2][1]) k2=B;\n }\n }\n for (v=head[x][A];v;v=next[x][v]) {\n int B=a[x][v];\n if (fa[A]!=B) {\n if (B!=k1) maxx=max(maxx,h[k1][0]+h[B][1]+S1*S2*2);\n if (B!=k2) maxx=max(maxx,h[B][0]+h[k2][1]+S1*S2*2);\n }\n }\n if (k1) maxx=max(maxx,max(h[k1][0]+S1*S2+len[x][A]*S2,h[k2][1]+S1*S2+len[x][A]*S1));\n an=max(an,ans+maxx);\n }\n}\nint main() {\n For(i,0,2) scanf(\"%I64d\",&s[i]);\n For(i,0,2) {\n t=0;\n For(j,1,s[i]-1) {\n scanf(\"%d%d\",&x,&y);\n a[i][++t]=y,next[i][t]=head[i][x],head[i][x]=t;\n a[i][++t]=x,next[i][t]=head[i][y],head[i][y]=t;\n }\n }\n For(i,0,2) work(i); sum/=2;\n For(i,0,2) bfs(i);\n printf(\"%I64d\\n\",an+sum);\n //for(;;);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f309b72c099cc24ecdee3348fc907a91", "src_uid": "2f299b0083b89d8b8ec8b26b65d201f2", "difficulty": null} {"lang": "GNU C++", "source_code": "#include\n#include\n#define lld long long\nusing namespace std;\n\nconst int MaxN = 100000 + 10;\n\nint n1, n2, n3;\nlld D1, E2;\n\nclass Tree\n{\n\tpublic:\n\tint head[MaxN], nxt[MaxN << 1], to[MaxN << 1], top, son[MaxN], size;\n\tlld totaldis[MaxN], PD[MaxN], PE[MaxN];bool vis[MaxN];\n\tvoid addedge(int fr,int tt){top++;nxt[top] = head[fr];to[top] = tt;head[fr] = top;}\n\tlld dfs1(int x,int c)\n\t{\n\t\tvis[x] = true;\n\t\tlld ret = c;\n\t\tson[x] = 1;\n\t\tfor(int i = head[x]; i; i = nxt[i])\n\t\t\tif(!vis[to[i]])\n\t\t\t{\n\t\t\t\tret += dfs1(to[i], c + 1);\n\t\t\t\tson[x] += son[to[i]];\n\t\t\t}\n\t\treturn ret;\n\t}\n\tvoid dfs2(int x)\n\t{\n\t\tvis[x] = true;\n\t\tfor(int i = head[x]; i; i = nxt[i])\n\t\t\tif(!vis[to[i]])\n\t\t\t{\n\t\t\t\ttotaldis[to[i]] = totaldis[x] + (lld)size - 2LL * son[to[i]];\n\t\t\t\tdfs2(to[i]);\n\t\t\t}\n\t}\n\tlld dfs3(int x)\n\t{\n\t\tvis[x] = true;\n\t\tlld ret, v1, v2;\n\t\tPD[x] = (lld)n1 * totaldis[x];PE[x] = (lld)n3 * totaldis[x];\n\t\tret = \n\t\tfor(int i = head[x]; i; i = nxt[i])\n\t\t\tif(!vis[to[i]])\n\t\t\t{\n\t\t\t\tret = max(ret, dfs3(to[i]));\n\t\t\t\tv1 = PD[to[i]] + ((lld)n1 * (lld)n3);\n\t\t\t\tv2 = PE[to[i]] + ((lld)n1 * (lld)n3);\n\t\t\t\tif(v1 + PE[x] > ret) ret = v1 + PE[x];\n\t\t\t\tif(v2 + PD[x] > ret) ret = v2 + PD[x];\n\t\t\t\tif(v1 > PD[x]) PD[x] = v1;\n\t\t\t\tif(v2 > PE[x]) PE[x] = v2;\n\t\t\t}\n\t\treturn ret;\n\t}\n\tvoid ReadIn(int n)\n\t{\n\t\tint a, b;\n\t\tfor(int i = 1; i < n; ++i)\n\t\t{\n\t\t\tscanf(\"%d%d\", &a, &b);\n\t\t\taddedge(a, b);\n\t\t\taddedge(b, a);\n\t\t}\n\t\tsize = n;\n\t}\n\tvoid clearVis()\n\t{\n\t\tfor(int i = 1; i <= size; ++i) vis[i] = false;\n\t}\n\tlld calcIn()\n\t{\n\t\tlld ret = 0;\n\t\tfor(int i = 1; i <= size; ++i) ret += totaldis[i];\n\t\tret /= 2;\n\t\treturn ret;\n\t}\n\tlld findMax()\n\t{\n\t\tlld mx = totaldis[1];\n\t\tfor(int i = 2; i <= size; ++i) if(totaldis[i] > mx) mx = totaldis[i];\n\t\treturn mx;\n\t}\n}T1, T2, T3;\n\nvoid init()\n{\n\tscanf(\"%d%d%d\", &n1, &n2, &n3);\n\tT1.ReadIn(n1);\n\tT2.ReadIn(n2);\n\tT3.ReadIn(n3);\n}\n\nvoid solve()\n{\n\tT1.totaldis[1] = T1.dfs1(1, 0);\n\tT2.totaldis[1] = T2.dfs1(1, 0);\n\tT3.totaldis[1] = T3.dfs1(1, 0);\n\tT1.clearVis();T2.clearVis();T3.clearVis();\n\t\n\tT1.dfs2(1);T2.dfs2(1);T3.dfs2(1);\n\tT1.clearVis();T2.clearVis();T3.clearVis();\n\t\n\tlld ans = T1.calcIn() + T2.calcIn() + T3.calcIn();\n\t\n\t\n\tD1 = T1.findMax();\n\tE2 = T3.findMax();\n\tans += (lld)(n2 + n3) * D1;\n\tans += (lld)(n1 + n2) * E2;\n\tans += T2.dfs3(1);\n\tans += (lld)n1 * (lld)n2 + (lld)n2 * (lld)n3 + 2LL * (lld)n1 * (lld)n3;\n\tcout << ans << endl;\n}\n\nint main()\n{\n\tinit();\n\tsolve();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d1fe319310f0a4ea37421e2eb2ad853a", "src_uid": "2f299b0083b89d8b8ec8b26b65d201f2", "difficulty": null} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define snd second\n#define fst first\n#define mp make_pair\n#define ll long long\n#define ull unsigned long long\n#define ld long double\n#define pb push_back\n#define left _left\n#define y1 _y1\n\ntemplate < typename T > T abs(T x)\n{\n\treturn x > 0 ? x : -x;\n}\n\nconst int maxn = 100005;\n\nvector < int > g[3][maxn];\nll sz[3][maxn], ds[3][maxn], sum[3][maxn];\nll n[3];\n\nvoid dfs(int i, int v, int p)\n{\n\tsz[i][v] = 1;\n\tfor (int to : g[i][v])\n\t\tif (to != p)\n\t\t{\n\t\t\tdfs(i, to, v);\n\t\t\tsz[i][v] += sz[i][to];\n\t\t\tds[i][v] += ds[i][to] + sz[i][to];\n\t\t}\n}\n\nvoid dfs2(int i, int v, int p, ll up = 0)\n{\n\tsum[i][v] = up + ds[i][v];\n\tfor (int to : g[i][v])\n\t\tif (to != p)\n\t\t{\n\t\t\tdfs2(i, to, v, up + ds[i][v] - (ds[i][to] + sz[i][to]) + (n[i] - sz[i][to]));\n\t\t}\n}\n\nint i2, i3;\nll best[2][maxn];\nll ans = 0;\n\nvoid dfs3(int i, int v, int p)\n{\n\tmultiset < ll > s;\n\tfor (int to : g[i][v])\n\t{\n\t\tif (to == p)\n\t\t\tcontinue;\n\t\tdfs3(i, to, v);\n\t\ts.insert(best[0][to]);\n\t}\n\n\tans = max(ans, sum[i][v] * (n[i2] + n[i3]));\n\n\tbest[0][v] = sum[i][v] * n[i2];\n\tbest[1][v] = sum[i][v] * n[i3];\n\n\tfor (int to : g[i][v])\n\t{\n\t\tif (to == p)\n\t\t\tcontinue;\n\t\ts.erase(s.find(best[0][to]));\n\t\tif (!s.empty())\n\t\t\tans = max(ans, *s.rbegin() + best[1][to] + 2LL * n[i2] * n[i3]);\n\t\ts.insert(best[0][to]);\n\t\tans = max(ans, sum[i][v] * n[i2] + n[i2] * n[i3] + best[1][to]);\n\t\tans = max(ans, sum[i][v] * n[i3] + n[i2] * n[i3] + best[0][to]);\n\n\t\tbest[0][v] = max(best[0][v], best[0][to] + n[i2] * n[i3]);\n\t\tbest[1][v] = max(best[1][v], best[1][to] + n[i2] * n[i3]);\n\t}\n}\n\nint main(int argc, char *argv[])\n{\n\t//freopen(\"a.in\", \"r\", stdin);\n\tcin >> n[0] >> n[1] >> n[2];\n\n\tfor (int i = 0; i < 3; i++)\n\t{\n\t\tfor (int j = 0; j < n[i] - 1; j++)\n\t\t{\n\t\t\tint u, v;\n\t\t\tcin >> u >> v;\n\t\t\tg[i][u].pb(v);\n\t\t\tg[i][v].pb(u);\n\t\t}\n\n\t\tdfs(i, 1, -1);\n\t\tdfs2(i, 1, -1);\n\t}\n\n\tll gans = 0;\n\n\tll best[3] = { 0, 0, 0 };\n\tll s = 0;\n\tfor (int i = 0; i < 3; i++)\n\t\tfor (int j = 1; j <= n[i]; j++)\n\t\t{\n\t\t\ts += sum[i][j];\n\t\t\tbest[i] = max(best[i], sum[i][j]);\n\t\t}\n\n\tfor (int i = 0; i < 3; i++)\n\t{\n\t\ti2 = (i + 1) % 3;\n\t\ti3 = (i + 2) % 3;\n\n\t\tans = 0;\n\t\tdfs3(i, 1, -1);\n if(n[i] > 1000) ans = 0;\n\t\tans += s / 2;\n\t\tans += n[i2] * (n[i] + n[i3]);\n\t\tans += n[i3] * (n[i] + n[i2]);\n\t\tans += best[i2] * (n[i] + n[i3]);\n\t\tans += best[i3] * (n[i] + n[i2]);\n\n\t\tgans = max(gans, ans);\n\t}\n\n\tcout << gans << endl;\n\n\treturn 0;\n}\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "49f1c19f48ca2d74913b90cad7d6f2fa", "src_uid": "2f299b0083b89d8b8ec8b26b65d201f2", "difficulty": null} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#if __cplusplus >= 201103L\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#endif\n\nlong long max(long long x, long long y){return (x > y ? x : y);}\nlong long min(long long x, long long y){return (x < y ? x : y);}\nint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }\n\n#define ll long long\n#define FOR(i,a) for(ll i=0;i<(ll)a.size();i++)\n#define pb push_back\n#define ld long double\n#define mp make_pair\n#define F first\n#define S second\n#define pii pair \n\nusing namespace :: std;\n\nconst ll maxn=1e5+200;\n\n\nll seg[maxn*4];\nll lazy[maxn*4];\n\nvoid shift(ll a,ll l,ll r,ll mid){\n\tlazy[2*a]+=lazy[a];\n\tlazy[2*a+1]+=lazy[a];\n\n\tseg[2*a]+=lazy[a]*(mid-l);\n\tseg[2*a+1]+=lazy[a]*(r-mid);\n\n\tlazy[a]=0;\n}\nvoid update(ll L,ll R,ll node,ll l,ll r,ll v){\n\tif(l<=L && R<=r){\n\t\tseg[node]+=v*(R-L);\n\t\tlazy[node]+=v;\n\t\treturn ;\n\t}\n\tif(r<=L || R<=l){\n\t\treturn ;\n\t}\n\tll mid=(L+R)/2;\n\tshift(node,L,R,mid);\n\tupdate(L,mid,2*node,l,r,v);\n\tupdate(mid,R,2*node+1,l,r,v);\n\tseg[node]=seg[2*node]+seg[2*node+1];\n}\nll find_sum(){\n\treturn seg[1];\n}\nvoid shift_max(ll a){\n\tlazy[2*a]+=lazy[a];\n\tlazy[2*a+1]+=lazy[a];\n\n\tseg[2*a]+=lazy[a];\n\tseg[2*a+1]+=lazy[a];\n\n\tlazy[a]=0;\n}\nvoid update_max(ll L,ll R,ll node,ll l,ll r,ll v){\n\tif(l<=L && R<=r){\n\t\tseg[node]+=v;\n\t\tlazy[node]+=v;\n\t\treturn ;\n\t}\n\tif(r<=L || R<=l){\n\t\treturn ;\n\t}\n\tll mid=(L+R)/2;\n\tshift_max(node);\n\tupdate_max(L,mid,2*node,l,r,v);\n\tupdate_max(mid,R,2*node+1,l,r,v);\n\tseg[node]=max(seg[2*node],seg[2*node+1]);\n}\nll find_max(){\n\treturn seg[1];\n}\n\n\nll n[3];\nvector ger[3][maxn];\nll f[3][maxn];\nll st[maxn];\nll et[maxn];\nll h[maxn];\nll tt=0;\nll a,Y;\n\nvoid dfs(ll v,ll p=-1){\n\tf[a][v]=find_sum();\n\tFOR(i,ger[a][v]){\n\t\tll u=ger[a][v][i];\n\t\tif(u!=p){\n\t\t\tupdate(0,Y,1,st[u] ,et[u]+1,-1);\n\t\t\tupdate(0,Y,1,0 ,st[u] ,+1);\n\t\t\tupdate(0,Y,1,et[u]+1, Y ,+1);\n\t\t\tdfs(u,v);\n\t\t\tupdate(0,Y,1,st[u] ,et[u]+1,+1);\n\t\t\tupdate(0,Y,1,0 ,st[u] ,-1);\n\t\t\tupdate(0,Y,1,et[u]+1, Y ,-1);\t\n\t\t}\n\t}\n}\nvoid dfs_s(ll v,ll p=-1){\n\ttt++;\n\tst[v]=tt;\n\tFOR(i,ger[a][v]){\n\t\tll u=ger[a][v][i];\n\t\tif(u!=p){\n\t\t\th[u]=h[v]+1;\n\t\t\tdfs_s(u,v);\n\t\t}\n\t}\n\tet[v]=tt;\n}\nvoid cal(){\n\tll N=n[a];\n\tfill(seg,seg+maxn*4,0);\n\tfill(lazy,lazy+maxn*4,0);\n\ttt=-1;\n\tdfs_s(1);\n\tY=et[1]+1;\n\tfor(ll i=1;i<=N;i++){\n\t\tupdate(0,Y,1,st[i],st[i]+1,h[i]);\n\t}\n\tdfs(1);\n}\n\nll m,C,D;\nvoid dfss(ll v,ll p=-1){\n\tm=max(m,f[a][v]*C+find_max());\n\n\tFOR(i,ger[a][v]){\n\t\tll u=ger[a][v][i];\n\t\tif(u!=p){\n\t\t\tupdate_max(0,Y,1,st[u] ,et[u]+1,-C*D);\n\t\t\tupdate_max(0,Y,1,0 ,st[u] ,C*D);\n\t\t\tupdate_max(0,Y,1,et[u]+1, Y ,C*D);\n\t\t\tdfss(u,v);\n\t\t\tupdate_max(0,Y,1,st[u] ,et[u]+1,C*D);\n\t\t\tupdate_max(0,Y,1,0 ,st[u] ,-C*D);\n\t\t\tupdate_max(0,Y,1,et[u]+1, Y ,-C*D);\t\n\t\t}\n\t}\n\n}\nll find_real_best(ll vas,ll c,ll d){\n\tC=c;\n\tD=d;\n\tfill(seg,seg+maxn*4,0);\n\tfill(lazy,lazy+maxn*4,0);\n\ta=vas;\n\tdfs_s(1);\n\tY=et[1]+1;\n\tfor(ll i=1;i<=n[vas];i++){\n\t\tupdate_max(0,Y,1,st[i],st[i]+1,f[a][i]*d + h[i]*c*d);\n\t}\n\tm=0;\n\tdfss(1);\n\treturn m;\n}\nll maxf[3];\nint main(){\n\tios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\t\n\n\tcin>>n[0]>>n[1]>>n[2];\n\tfor(ll i=0;i<3;i++){\n\t\tfor(ll j=1;j>v>>u;\n\t\t\tger[i][v].pb(u);\n\t\t\tger[i][u].pb(v);\n\t\t}\n\t}\n\ta=0;\n\tcal();\n\ta=1;\n\tcal();\n\ta=2;\n\tcal();\n\n\tll ans=0;\n\tfor(ll i=0;i<3;i++){\n\t\tfor(ll j=1;j<=n[i];j++){\n\t\t\tans+=f[i][j];\n\t\t\tmaxf[i]=max(maxf[i],f[i][j]);\n\t\t}\n\t}\n\tans/=2;\n\tll anss=0;\n\tfor(ll vas=0;vas<=2;vas++){\n\t\tll res=0;\n\n\t\tif(vas!=0)\n\t\t\tres+=maxf[0]*(n[1]+n[2]);\n\t\tif(vas!=1)\n\t\t\tres+=maxf[1]*(n[0]+n[2]);\n\t\tif(vas!=2)\n\t\t\tres+=maxf[2]*(n[0]+n[1]);\n\n\t\tres+=n[0]*n[1];\n\t\tres+=n[1]*n[2];\n\t\tres+=n[0]*n[2];\n\n\t\tll c=(vas+1)%3;\n\t\tll d=(vas+2)%3;\n\t\tres+=n[c]*n[d];\n\n\t\tll mx=find_real_best(vas,n[c],n[d]);\n\t\tres+=mx;\n\t\tanss=max(anss,res);\n\t}\n\tcout<\n#include\n#define maxn 100005\nusing namespace std;\nint T;\nint n=1;\nint fa[maxn];\ndouble dp[maxn][45];\nint main()\n{\n\t//freopen(\"1.in\",\"r\",stdin);\n\tscanf(\"%d\",&T);\n\tfor(int i=0;i<=40;i++)dp[1][i]=1;\n\twhile(T--)\n\t{\n\t\tint type;\n\t\tscanf(\"%d\",&type);\n\t\tif(type==1)\n\t\t{\n\t\t\tint x;\n\t\t\tscanf(\"%d\",&x);\n\t\t\tfa[++n]=x;\n\t\t\tfor(int i=0;i<=40;i++)dp[n][i]=1;\n\t\t\tdouble pre=dp[x][0];dp[x][0]/=2;double now=pre/2;\n\t\t\tx=fa[x];\n\t\t\tfor(int i=1;i<=40 && x;i++,x=fa[x])\n\t\t\t{\n\t\t\t\tdouble t=dp[x][i];\n\t\t\t\tdp[x][i]=dp[x][i]*(now+1)/(pre+1);\n\t\t\t\tnow=dp[x][i];\n\t\t\t\tpre=t;\n\t\t\t}\n\t\t}\n\t\telse \n\t\t{\n\t\t\tdouble ans=0;\n\t\t\tint x;\n\t\t\tscanf(\"%d\",&x);\n\t\t\tfor(int i=1;i<=40;i++)ans+=i*(dp[x][i]-dp[x][i-1]);\n\t\t\tprintf(\"%.8lf\\n\",ans);\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c849a74b518f9c715c9ede66da06634e", "src_uid": "55affe752cb214d1e4031a9e3972597b", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "Copy\n0.7500000000\n0.5000000000\n1.1875000000", "lang_cluster": "C++", "compilation_error": true, "code_uid": "38b33ece2ad20202f5b8a5900fc577fc", "src_uid": "55affe752cb214d1e4031a9e3972597b", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "include \n\n#define clr(x) memset((x), 0, sizeof(x))\n#define all(x) (x).begin(), (x).end()\n#define pb push_back\n#define mp make_pair\n#define in(x) int (x); input((x));\n#define x first\n#define y second\n#define forn(i, n) for(int i = 0; i < (int)(n); ++i)\n#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; --i)\n#define for1(i, n) for(int i = 1; i <= (int)(n); ++i)\n\ntypedef int itn;\n\n//#define next next12345\n//#define prev prev12345\n#define left lefdsf232\n#define right rig43783\n#define x1 x12345\n#define y1 y12345\n\nusing namespace std;\n\ntemplate\nT gcd(T x, T y) {\n while (y > 0) {\n x %= y;\n swap(x, y);\n }\n return x;\n}\n\ntemplate\nT lcm(T a, T b) {\n return a / gcd(a, b) * b;\n}\n\n\ntemplate\ninline _T sqr(const _T &x) {\n return x * x;\n}\n\ntemplate\ninline string tostr(const _T &a) {\n ostringstream os(\"\");\n os << a;\n return os.str();\n}\n\ntypedef long double ld;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair PII;\nconst ld PI = 3.1415926535897932384626433832795L;\n\ntemplate\ninline void input(T &a) {\n static int ed;\n a = 0;\n while (!isdigit(ed = getchar()) && ed != '-') { }\n char neg = 0;\n if (ed == '-') {\n neg = 1;\n ed = getchar();\n }\n while (isdigit(ed)) {\n a = 10 * a + ed - '0';\n ed = getchar();\n }\n if (neg) a = -a;\n}\n\ntemplate\ninline T nxt() {\n T res;\n input(res);\n return res;\n}\n\nvoid myassert(bool v) {\n assert(v);\n //cout << \"FAIL\\n\";\n //exit(0);\n}\n\nmt19937 generator;\n\nbool check(int v) {\n if (v < 2) return false;\n for (int i = 2; i * i <= v; ++i) {\n if (v % i == 0) {\n return false;\n }\n }\n return true;\n}\n\nlong long pw(long long a, long long n, long long m) {\n ll res = 1;\n while (n) {\n if (n & 1ll) {\n res = res * a % m;\n }\n a = a * a % m;\n n >>= 1;\n }\n return res;\n}\n\nlong long inv(long long a, long long p) {\n long long res = 1;\n while (a > 1) {\n res = res * (p - p / a) % p;\n a = p % a;\n }\n return res;\n}\nvector p;\n\nconst int M = 60;\n\n#define ld double\n\nld dp[1 << 19][M];\nld old[M];\nld old2[M];\n\nvoid solve(int test) {\n p.resize(1, -1);\n int q = nxt();\n vector > r;\n\n while (q--) {\n int t = nxt();\n int v = nxt() - 1;\n r.pb(mp(t, v));\n if (t == 1) {\n p.pb(v);\n }\n }\n forn(i, M) dp[0][i] = 1;\n\n int sz = 1;\n for (auto v : r) {\n if (v.x == 1) {\n int cur = sz++;\n forn(i, M) dp[cur][i] = 1;\n int pr = cur;\n cur = p[cur];\n int h = 0;\n while (cur != -1 && h < M) {\n memcpy(old2, dp[cur], sizeof(old2));\n for (int j = h; j < M; ++j) {\n if (pr != sz - 1) dp[cur][j] /= (0.5 + 0.5 * (j ? old[j - 1] : 0));\n dp[cur][j] *= (0.5 + 0.5 * (j ? dp[pr][j - 1] : 0));\n }\n memcpy(old, old2, sizeof(old));\n pr = cur;\n cur = p[cur];\n ++h;\n }\n } else {\n ld ans = 0;\n for (int i = 0; i < M; ++i) {\n ans += 1 - dp[v.y][i];\n }\n printf(\"%.10f\\n\", (double)ans);\n }\n }\n}\n\n\nint main(int argc, char ** argv) {\n\n#ifdef LOCAL\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n#else\n #define fname \"sequence\"\n //freopen(fname\".in\", \"r\", stdin);\n //freopen(fname\".out\", \"w\", stdout);\n#endif\n //ios_base::sync_with_stdio(false);\n// pre();\n int t = 1;\n\n#ifdef LOCAL\n#else\n#endif\n int c = 0;\n\n while (t--) {\n solve(++c);\n }\n\n#ifdef LOCAL\n cerr << \"Time elapsed: \" << 1.0 * clock() / CLOCKS_PER_SEC * 1000 << \" ms.\" << endl;\n#endif\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c1b31958ee9f81610feba65a17b46272", "src_uid": "55affe752cb214d1e4031a9e3972597b", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include \n\n#define clr(x) memset((x), 0, sizeof(x))\n#define all(x) (x).begin(), (x).end()\n#define pb push_back\n#define mp make_pair\n#define in(x) int (x); input((x));\n#define x first\n#define y second\n#define forn(i, n) for(int i = 0; i < (int)(n); ++i)\n#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; --i)\n#define for1(i, n) for(int i = 1; i <= (int)(n); ++i)\n\ntypedef int itn;\n\n//#define next next12345\n//#define prev prev12345\n#define left lefdsf232\n#define right rig43783\n#define x1 x12345\n#define y1 y12345\n\nusing namespace std;\n\ntemplate\nT gcd(T x, T y) {\n while (y > 0) {\n x %= y;\n swap(x, y);\n }\n return x;\n}\n\ntemplate\nT lcm(T a, T b) {\n return a / gcd(a, b) * b;\n}\n\n\ntemplate\ninline _T sqr(const _T &x) {\n return x * x;\n}\n\ntemplate\ninline string tostr(const _T &a) {\n ostringstream os(\"\");\n os << a;\n return os.str();\n}\n\ntypedef long double ld;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair PII;\nconst ld PI = 3.1415926535897932384626433832795L;\n\ntemplate\ninline void input(T &a) {\n static int ed;\n a = 0;\n while (!isdigit(ed = getchar()) && ed != '-') { }\n char neg = 0;\n if (ed == '-') {\n neg = 1;\n ed = getchar();\n }\n while (isdigit(ed)) {\n a = 10 * a + ed - '0';\n ed = getchar();\n }\n if (neg) a = -a;\n}\n\ntemplate\ninline T nxt() {\n T res;\n input(res);\n return res;\n}\n\nvoid myassert(bool v) {\n assert(v);\n //cout << \"FAIL\\n\";\n //exit(0);\n}\n\nmt19937 generator;\n\nbool check(int v) {\n if (v < 2) return false;\n for (int i = 2; i * i <= v; ++i) {\n if (v % i == 0) {\n return false;\n }\n }\n return true;\n}\n\nlong long pw(long long a, long long n, long long m) {\n ll res = 1;\n while (n) {\n if (n & 1ll) {\n res = res * a % m;\n }\n a = a * a % m;\n n >>= 1;\n }\n return res;\n}\n\nlong long inv(long long a, long long p) {\n long long res = 1;\n while (a > 1) {\n res = res * (p - p / a) % p;\n a = p % a;\n }\n return res;\n}\nvector p;\n\nconst int M = 60;\n\n#define ld double\n\nld dp[1 << 19][M];\nld old[M];\nld old2[M];\n\nvoid solve(int test) {\n p.resize(1, -1);\n int q = nxt();\n vector > r;\n\n while (q--) {\n int t = nxt();\n int v = nxt() - 1;\n r.pb(mp(t, v));\n if (t == 1) {\n p.pb(v);\n }\n }\n forn(i, M) dp[0][i] = 1;\n\n int sz = 1;\n for (auto v : r) {\n if (v.x == 1) {\n int cur = sz++;\n forn(i, M) dp[cur][i] = 1;\n int pr = cur;\n cur = p[cur];\n int h = 0;\n while (cur != -1 && h < M) {\n memcpy(old2, dp[cur], sizeof(old2));\n for (int j = h; j < M; ++j) {\n if (pr != sz - 1) dp[cur][j] /= (0.5 + 0.5 * (j ? old[pr][j - 1] : 0));\n dp[cur][j] *= (0.5 + 0.5 * (j ? dp[pr][j - 1] : 0));\n }\n memcpy(old, old2, sizeof(old));\n pr = cur;\n cur = p[cur];\n ++h;\n }\n } else {\n ld ans = 0;\n for (int i = 0; i < M; ++i) {\n ans += 1 - dp[v.y][i];\n }\n printf(\"%.10f\\n\", (double)ans);\n }\n }\n}\n\n\nint main(int argc, char ** argv) {\n\n#ifdef LOCAL\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n#else\n #define fname \"sequence\"\n //freopen(fname\".in\", \"r\", stdin);\n //freopen(fname\".out\", \"w\", stdout);\n#endif\n //ios_base::sync_with_stdio(false);\n// pre();\n int t = 1;\n\n#ifdef LOCAL\n#else\n#endif\n int c = 0;\n\n while (t--) {\n solve(++c);\n }\n\n#ifdef LOCAL\n cerr << \"Time elapsed: \" << 1.0 * clock() / CLOCKS_PER_SEC * 1000 << \" ms.\" << endl;\n#endif\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3e692a9517a47b0a361515357ee8f4b4", "src_uid": "55affe752cb214d1e4031a9e3972597b", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include \n\nconst int N = 2e5 + 5;\nstruct DP {\n\tint sum, mx;\n\tDP operator + (const DP &rhs) const {\n\t\treturn DP {sum + rhs.sum, std::max (mx, rhs.mx)};\n\t}\n};\ninline DP join(DP &a, DP &b) {\n DP c;\n c.sum = a.sum + b.sum;\n c.mx = std::max(a.mx, b.mx);\n return c;\n}\nint a[N], total[N], down[N], dp[N];\nbool good[N];\nstd::vector edge[N];\nint n, k;\n\nvoid DFS(int u, int fa)\t{\n\ttotal[u] = 1;\n\tint sum = 0, mx = 0;\n\tfor (auto v: edge[u])\t{\n\t\tif (v == fa)\tcontinue;\n\t\tDFS (v, u);\n\t\ttotal[u] += total[v];\n\t\tif (down[v] == total[v]) {\n\t\t\tsum += total[v];\n\t\t} else {\n\t\t\tmx = std::max (mx, down[v]);\n\t\t}\n\t}\n\tdown[u] = sum + mx + 1;\n\tif (!good[u])\tdown[u] = 0;\n}\n\nvoid DFS2(int u, int fa, int up)\t{\n\tstd::vector children;\n\tint sum = 0, mx = 0;\n\tfor (auto v: edge[u])\t{\n\t\tif (v == fa)\tcontinue;\n\t\tif (down[v] == total[v]) {\n\t\t\tsum += down[v];\n\t\t} else {\n\t\t\tmx = std::max (mx, down[v]);\n\t\t}\n\t\tchildren.push_back (v);\n\t}\n\tif (up == n - total[u]) {\n\t\tsum += up;\n\t} else {\n\t\tmx = std::max (mx, up);\n\t}\n\tdp[u] = sum + mx + 1;\n\tif (!good[u])\tdp[u] = 0;\n\n\tint sz = children.size ();\n\tif (sz == 0)\treturn ;\n\tstd::vector predown (sz + 1);\n\tpredown[0] = {0, 0};\n\tfor (int i=0; i sufdown (sz + 1);\n\tsufdown[sz] = {0, 0};\n\tfor (int i=sz-1; i>=0; --i)\t{\n\t\tint v = children[i];\n\t\tsufdown[i] = sufdown[i+1];\n\t\tif (down[v] == total[v]) {\n\t\t\tsufdown[i].sum += down[v];\n\t\t} else {\n\t\t\tsufdown[i].mx = std::max (sufdown[i].mx, down[v]);\n\t\t}\n\t}\n\tfor (int i=0; i= k)\treturn true;\n\t}\n\treturn false;\n}\n\nint main()\t{\n\tscanf (\"%d%d\", &n, &k);\n\tfor (int i=1; i<=n; ++i)\t{\n\t\tscanf (\"%d\", a+i);\n\t}\n\tfor (int u, v, i=1; i> 1;\n\t\t//debug\n\t\t//printf (\"low: %d mid: %d high: %d\\n\", low, mid, high);\n\t\tfor (int i=1; i<=n; ++i)\tgood[i] = (a[i] >= mid);\n\t\tif (check (mid))\t{\n\t\t\tlow = mid;\n\t\t} else {\n\t\t\thigh = mid - 1;\n\t\t}\n\t}\n\tprintf (\"%d\\n\", low);\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "56b23049e5b5951be0f7dfb38c2172c4", "src_uid": "4fb83b890e472f86045981e1743ddaac", "difficulty": 2600.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nconst int N = 200001;\n\n\nint n, k;\nvector < int > G[N];\nint a[N];\nint dp1[N], dp2[N];\nint sum[N];\nint cnt[N];\npair < int, int > pr[N];\n\nvoid dfs1(int v, int p, int x)\n{\n\tcnt[v] = 1;\n\tpr[v] = make_pair(-1, -1);\n\tfor (int i = 0; i < G[v].size(); ++i)\n\t{\n\t\tint to = G[v][i];\n\t\tif (to == p)\n\t\t\tcontinue;\n\t\tdfs1(to, v, x);\n\t\tcnt[v] += cnt[to];\n\t\tif (cnt[to] == dp1[to])\n\t\t\tdp1[v] += dp1[to];\n\t\telse\n\t\t{\n\t\t\tif (pr[v].first == -1 || dp1[pr[v].first] < dp1[to])\n\t\t\t{\n\t\t\t\tpr[v].second = pr[v].first;\n\t\t\t\tpr[v].first = to;\n\t\t\t}\n\t\t\telse if (pr[v].second == -1 || dp1[pr[v].second] < dp1[to])\n\t\t\t\tpr[v].second = to;\n\t\t}\n\t}\n\tif (a[v] < x)\n\t\tdp1[v] = sum[v] = 0;\n\telse\n\t{\n\t\tsum[v] = dp1[v];\n\t\tdp1[v] += 1;\n\t\tif (pr[v].first != -1)\n\t\t\tdp1[v] += dp1[pr[v].first];\n\t}\n}\n\nvoid dfs2(int v, int p, int x)\n{\n\tif (p == -1 || a[p] < x)\n\t{\n\t\tdp2[v] = 0;\n\t}\n\telse\n\t{\n\t\tint c = sum[p];\n\t\tint mx = 0;\n\t\tif (pr[p].first != -1 && pr[p].first != v)\n\t\t\tmx = dp1[pr[p].first];\n\t\telse if (pr[p].second != -1 && pr[p].second != v)\n\t\t\tmx = dp1[pr[p].second];\n\t\tif (dp1[v] == cnt[v])\n\t\t\tc -= dp1[v];\n\t\tdp2[v] = c;\n\t\tif (dp2[p] == n - cnt[p])\n\t\t\tdp2[v] += dp2[p];\n\t\telse\n\t\t\tmx = max(mx, dp2[p]);\n\t\tdp2[v] += mx;\n\t}\n\tfor (int i = 0; i < G[v].size(); ++i)\n\t{\n\t\tint to = G[v][i];\n\t\tif (to == p)\n\t\t\tcontinue;\n\t\tdfs2(to, v, x);\n\t}\n}\n\nbool check(int x)\n{\n\tfor (int i = 0; i < n; ++i)\n\t\tdp1[i] = dp2[i] = sum[i] = 0;\n\tdfs1(0, -1, x);\n\tdfs2(0, -1, x);\n\tfor (int i = 0; i < n; ++i)\n\t{\n\t\tif (a[i] < x)\n\t\t\tcontinue;\n\t\tint ans = sum[i] + 1;\n\t\tint mx = 0;\n\t\tif (pr[i].first != -1)\n\t\t\tmx = dp1[pr[i].first];\n\t\tif (dp2[i] == n - cnt[i])\n\t\t\tans += dp2[i];\n\t\telse\n\t\t\tmx = max(mx, dp2[i]);\n\t\tif (ans + mx >= k)\n\t\t\treturn true;\n\t}\n\treturn false;\n}\nint main()\n{\n#ifdef _DEBUG\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif\n\tscanf(\"%d%d\", &n, &k);\n\tfor (int i = 0; i < n; ++i)\n\t\tscanf(\"%d\", &a[i]);\n\tfor (int i = 1; i < n; ++i)\n\t{\n\t\tint u, v; scanf(\"%d%d\", &u, &v); u--; v--;\n\t\tG[u].push_back(v);\n\t\tG[v].push_back(u);\n\t}\n\tint l = 0, r = 1000001;\n\twhile (l + 1 < r)\n\t{\n\t\tint mid = (l + r) / 2;\n\t\tif (check(mid))\n\t\t\tl = mid;\n\t\telse\n\t\t\tr = mid;\n\t}\n\tprintf(\"%d\\n\", l);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ed3f412461a017ede38b1752d2b130b2", "src_uid": "4fb83b890e472f86045981e1743ddaac", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nconst int N = 2e5+5;\nint n,sz[N],a[N],c,ret,dp[N];\npair m[N][2];\nvector adj[N];\nvoid dfs(int x,int p){\n\tint f=0,u,i,d;dp[x]=0;\n\tif(!sz[x])f=1,++sz[x];\n\td= a[x]>=c ? 1 :0;\n\tfor(i=0;i=c){\n\t\tif(d==n-sz[x])t=0,v=d,test= dp[x]+d;\n\t\telse\n\t\t\ttest= dp[x]+ max(d,m[x][0].first);\n\t\tar[0]= m[x][0].first,ar[1]= m[x][1].first,ar[2]= t;\n\t\tsort(ar,ar+3);\n\t\tret= max(ret,dp[x]+ ar[2]+ar[1]+v);\n\t}\n\tfor(i=0;i=c){\n\t\t\t\tnd= dp[x]+v+ max(t,m[x][0].first);\n\t\t\t\tz= test;\n\t\t\t\tif(sz[u]==dp[u]){\n\t\t\t\t\tnd= dp[x]-sz[u]+ max(m[x][0].first,t)+ v;\n\t\t\t\t\tz= test-sz[u];\n\t\t\t\t}\n\t\t\t\telse if(u==m[x][0].second){\n\t\t\t\t\tnd= dp[x] + v + max(m[x][1].first,t);\n\t\t\t\t\tif(d==n-sz[x])z= test-m[x][0].first+m[x][1].first;\n\t\t\t\t\telse\n\t\t\t\t\t\tz= dp[x]+max(d,m[x][1].first);\n\t\t\t\t}\n\t\t\t}\n\t\t\tassert(z==nd);\n\t\t\tdfs2(u,x,nd);\n\t\t}\n\t}\n}\nint main(){\n\tint i,x,y,q,l,r,k,mid;\n\tcin>>n>>k;\n\tfor(i=1;i<=n;++i)scanf(\"%d\",&a[i]);\n\tfor(i=0;i=k)l= mid;\n\t\telse\n\t\t\tr= mid-1;\n\t}\n\tprintf(\"%d\\n\",l);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b9714f84fcc8cbb2a47bb30f721de036", "src_uid": "4fb83b890e472f86045981e1743ddaac", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define endl \"\\n\"\n#define mp make_pair\n#define int long long\n#define pii pair\ninline int in(){int32_t x ; scanf(\"%d\",&x) ; return x ;}\ninline string getStr(){char ch[500001] ; scanf(\"%s\",ch) ;return ch;}\nconst int MAX_N = 2e5 + 10;\ninline int gcd( int a, int b ) { return b == 0 ? a : gcd( b, a%b ); }\nvector g[MAX_N];\nbool del[MAX_N] , forb[MAX_N] , mark[MAX_N];\nint a[MAX_N] , dp[MAX_N] , ln , vl[MAX_N] , deg[MAX_N];\nqueue Bomb ; int n , k;\ninline void BombProcess()\n{\n for (int i = 1 ; i <= n ; i ++) if (deg[i] == 1 && !forb[i]) Bomb.push(i);\n while (Bomb.size()){\n int first = Bomb.front(); Bomb.pop();\n deg[first] --;\n del[first] = true;\n int FIND = -1;\n for (auto u : g[first]){\n if (!del[u] && !forb[u]){\n FIND = u;\n break;\n }\n }\n if (FIND != -1){\n vl[FIND] += vl[first];\n deg[FIND] --;\n if (deg[FIND] == 1)\n Bomb.push(FIND);\n }\n ln = max(ln , vl[first]);\n vl[first] = 0;\n }\n}\nint cnt2 = 0 , cnt = 0;\ninline void dfs(int v , int pr){\n \n mark[v] = true;\n dp[v] = vl[v];\n int f1 = 0 , f2 = 0 ;\n for (auto u : g[v]){\n if (!forb[u] && (u - pr)){\n dfs(u , v);\n if (dp[u] > f1){\n f2 = f1;\n f1 = dp[u];\n }\n else{\n f2 = max(f2 , dp[u]);\n }\n }\n }\n if (f2 && f1) cnt2 ++ ;\n if (pr == -1 && f2 && f1) cnt ++;\n \n ln = max(ln , dp[v] + f2 + f1);\n dp[v] += f1;\n}\ninline bool can(int low){\n ln = 0;\n for (int i = 1 ; i <= n ; i ++){\n mark[i] = 0;\n deg[i] = g[i].size();\n dp[i] = 0;\n del[i] = 0 ;\n mark[i] = 0 ;\n vl[i] = 1;\n forb[i] = (a[i] < low);\n }\n BombProcess();\n for (int i = 1 ; i <= n ; i ++)if (!mark[i] && !forb[i]) dfs(i , -1) ;\n assert(cnt == cnt2);\n return ln >= k;\n}\nint32_t main()\n{\n n = in() , k = in();\n for (int i = 0 ; i < n ; i ++) a[i + 1] = in();\n for (int i = 0 ; i < n - 1 ; i ++){\n int v = in() , u = in();\n g[v].push_back(u);\n g[u].push_back(v);\n \n }\n int l = 0 , r = (1 << 20) , best = 0 , mid;\n while (l <= r){\n mid = (l + r) >> 1;\n if (can(mid)) {best = mid ; l = mid + 1 ; continue ; }\n r = mid - 1;\n }\n cout << best << \"\\n\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cd430db77ffcded4eba8fb988afae949", "src_uid": "4fb83b890e472f86045981e1743ddaac", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nconst int N = 200010;\nint n, m, arr[N], tmp , arr2[N] , arr3[N];\nvector< int > ans;\nint idx1, idx2, idx3;\nbool check(int x) {\n\tif (x > m) {\n\t\tidx1 = upper_bound(arr, arr + n, x - m) - arr;\n\t\tidx2 = n - 1;\n\t}\n\telse {\n\t\tidx1 = 0;\n\t\tidx2 = upper_bound(arr, arr + n, x) - arr - 1;\n\t}\n\tif (idx1 > idx2) {\n\t\treturn false;\n\t}\n\twhile (idx2 >= idx1) {\n\t\tif (arr[idx1++] + arr[idx2--] != x) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nint main() {\n\t//freopen(\"in.txt\", \"r\", stdin);\n\t//freopen(\"out.txt\", \"w\", stdout);\n\tscanf(\"%d%d\", &n, &m);\n\tfor (int i = 0;i < n;i++) {\n\t\tscanf(\"%d\", &arr[i]);\n\t\tarr2[i] = (arr[i] + arr[0]) % m;\n\t}\n\tfor (int i = 1;i < n;i++) {\n\t\tarr3[i] = arr[i] - arr[i - 1];\n\t}\n\tfor (int i = 0;i < n;i++) {\n\t\tif (!check(arr2[i]) && !check(arr2[i] + m))\n\t\t\tans.push_back(arr2[i]);\n\t}\t\n\tprintf(\"%d\\n\", (int)ans.size());\n\tfor (int i = 0;i < (int)ans.size();i++) {\n\t\tif (i) putchar(' ');\n\t\tprintf(\"%d\", ans[i]);\n\t}\n\tputs(\"\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "97ec51e3212ede232f2e4714876434fa", "src_uid": "6a9f683dee69a7be2d06ec6646970f19", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "/*#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define INF 1000000000\n#define MOD 1000000007\n#define pb push_back\n#define f first\n#define s second\n#define mp make_pair\n#define pii pair \n\nconst long long MAXN = 1e2 + 10;\n//const long double eps = 0.00000000000000001;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef vector vi;\n\nint l, r;\nbool was[MAXN];\n\nint main() {\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n //freopen(\"rbtrees.in\", \"r\", stdin);\n //freopen(\"rbtrees.out\", \"w\", stdout);\n //cin >> l >> r;\n set st;\n for(int i = 1; i <= MAXN; i++)\n st.insert(i);\n for(int i = 2; i < MAXN + 1; i++){\n if(st.size() < i)\n break;\n //vi v;\n int k = 0;\n for(auto j = st.begin(); j != st.end(); j++){\n k++;\n if(k == i){\n st.erase(*j);\n //if(i == 2)\n // cerr << *j << ' ';\n //j--;\n //if(j == st.end())\n // break;\n // v.pb(*j);\n k = 0;\n }\n }\n /*for(int j = 0; j < v.size(); j++){\n st.erase(v[j]);\n }*/\n //}\n /* cout << st.size() << endl;\n for(auto j = st.begin(); j != st.end(); j++)\n cout << *j << '\\n';\n \n return 0;\n}*/\n\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define INF 1000000010\n#define MOD 1000000007\n#define pb push_back\n#define f first\n#define s second\n#define mp make_pair\n#define pii pair \n\nconst long long MAXN = 1000 * 1000 + 10;\nconst long long pr = 13;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef vector vi;\n\nll n, m, a[MAXN];\nll h1[MAXN], h2[MAXN];\nvi ans;\n\nll pw(ll x){\n if(x == 0)\n return 1;\n ll y = pw(x / 2);\n y = y * y % MOD;\n if(x % 2)\n y = y * 13 % MOD;\n return y;\n}\n\nvoid gen(){\n h1[0] = pw(a[0]);\n for(int i = 1; i < n; i++)\n h1[i] = (h1[i - 1] + pw(a[i])) % MOD;\n h2[n - 1] = pw(m - 1 - a[n - 1]);\n for(int i = n - 2; i >= 0; i--)\n h2[i] = (h2[i + 1] + pw(m - 1 - a[i])) % MOD;\n /* for(int i = 0; i < n; i++)\n cout << h1[i] << ' ';\n cout << '\\n';*/\n // for(int i = n - 1; i >= 0; i--)\n}\n\nbool check(int i, int j){\n ll x, y;\n x = h1[j];\n y = h2[i];\n // cerr << x << ' ' << y << endl;\n i > 0 ? x = (((h1[j] - h1[i - 1] + MOD) % MOD) * pw(m - a[j])) % MOD : x = (h1[j] * pw(m - a[j])) % MOD;\n j != n - 1 ? y = (((h2[i] - h2[j + 1] + MOD) % MOD) * pw(a[i] + 1)) % MOD : y = (h2[i] * pw(a[i] + 1)) % MOD;\n //cerr << x << ' ' << y << endl;\n return x == y;\n}\n\n\nint main() {\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n //freopen(\"anagrams2.in\", \"r\", stdin);\n //freopen(\"anagrams2.out\", \"w\", stdout);\n cin >> n >> m;\n for(int i = 0; i < n; i++)\n cin >> a[i];\n if(n == 1){\n if(a[0] == 0 || a[0] == m - 1)\n cout << 1 << '\\n' << a[0];\n else\n cout << 0;\n return 0;\n }\n gen();\n // cerr << check(1, 1);\n if(check(0, n - 1) && a[0] - 1 >= m - a[n - 1] - 1){\n //cerr << \"aaa\";\n ans.pb(a[0] - (m - a[n - 1] - 1) - 1);\n }\n for(int i = 0; i < n - 1; i++){\n if(check(0, i) && check(i + 1, n - 1) && a[i + 1] - a[i] - 1 == a[0] + m - a[n - 1] - 1)\n ans.pb(a[i] + a[0]);\n }\n if(check(0, n - 1) && m - a[n - 1] - 2 >= a[0])\n ans.pb(a[n - 1] + a[0]);\n cout << ans.size() << '\\n';\n for(int i = 0; i < ans.size(); i++)\n cout << ans[i] << ' ';\n return 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6c1f1940e05012ae1e595741a951f91c", "src_uid": "6a9f683dee69a7be2d06ec6646970f19", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n\nconstexpr int MOD = 1000000007;\nconstexpr int BASE = 7;\n\nusing namespace std;\nusing ll = long long;\n\nint n, m;\n\nint mod_pow(int b, int e) {\n if (e == 0) return 1;\n ll x = mod_pow(b, e >> 1);\n x = (x * x) % MOD;\n if (e & 1) x = (x * b) % MOD;\n return (int) x;\n}\n\nvector> pre_hash(vector &sparse) {\n vector> ans;\n int last = 0;\n ll h = 0;\n for (int idx : sparse) {\n h = (h * mod_pow(BASE, idx - last) + 1) % MOD;\n ans.push_back({ idx, (int) h });\n // printf(\"pre_hash[%d] = { %d, %d }\\n\", ans.size() - 1, idx, (int) h);\n last = idx;\n }\n\n return ans;\n}\n\nint eval_hash(const vector> &h, int idx) {\n if (h[0].first > idx) return 0;\n // [0, idx]\n int lo = 0, hi = (int) h.size();\n while (lo + 1 < hi) {\n int mid = (lo + hi) / 2;\n if (h[mid].first <= idx) {\n lo = mid;\n } else {\n hi = mid;\n }\n }\n\n return (1LL * h[lo].second * mod_pow(BASE, idx - h[lo].first)) % MOD;\n}\n\nint eval_hash(const vector> &h, int l, int r) {\n // [l, r]\n int right_hash = eval_hash(h, r);\n // printf(\" got right hash = %d\\n\", right_hash);\n int left_hash = l == 0 ? 0 : eval_hash(h, l - 1);\n // printf(\" got left hash = %d\\n\", left_hash);\n left_hash = (left_hash * mod_pow(BASE, r - l + 1)) % MOD;\n // printf(\" scaled left hash = %d\\n\", left_hash);\n return (right_hash - left_hash + MOD) % MOD;\n}\n\nint main() {\n scanf(\" %d %d\", &n, &m);\n vector bag;\n for (int i = 0; i < n; ++i) {\n int x;\n scanf(\" %d\", &x);\n bag.push_back(x);\n }\n\n sort(bag.begin(), bag.end());\n\n vector flipped;\n\n for (int x : bag) {\n flipped.push_back(m - 1 - x);\n flipped.push_back(m + m - 1 - x);\n }\n\n sort(flipped.begin(), flipped.end());\n\n // printf(\"flipped: \");\n // for (int x : flipped) printf(\"%d \", x);\n // printf(\"\\n\");\n\n vector checks;\n\n for (int x : flipped) {\n if (x - bag[0] >= 0 && x - bag[0] < m) checks.push_back(x - bag[0]);\n }\n\n // printf(\"checks: \");\n // for (int x : checks) printf(\"%d \", x);\n // printf(\"\\n\");\n\n // printf(\"hashing bag\\n\");\n auto bag_h = pre_hash(bag);\n // printf(\"hashing flipped\\n\");\n auto flipped_h = pre_hash(flipped);\n\n int desired_length = m - 1;\n int desired_hash = eval_hash(bag_h, desired_length);\n\n // printf(\"desired hash = %d\\n\", desired_hash);\n\n vector ans;\n\n for (int check : checks) {\n int cur_hash = eval_hash(flipped_h, check, check + desired_length);\n // printf(\"on check %d, got hash %d\\n\", check, cur_hash);\n if (cur_hash == desired_hash) {\n ans.push_back((m + m - 1 - check) % m);\n }\n }\n\n sort(ans.begin(), ans.end());\n\n printf(\"%d\\n\", (int) ans.size());\n for (int x : ans) {\n printf(\"%d \", x);\n }\n printf(\"\\n\");\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "287f6dc7863820b7fcb6e2dfd953d060", "src_uid": "6a9f683dee69a7be2d06ec6646970f19", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long LL;\n\nconst int maxn = 200005;\n\nLL aa[maxn];\nLL jg[maxn];\nvector ans;\nset sxd;\n\nint main()\n{\n\tint n;\n\tLL m;\n\tscanf(\"%d%lld\", &n, &m);\n\tfor(int i = 1; i <= n; ++i)\n\t{\n\t\tscanf(\"%lld\", &aa[i]);\n\t\tsxd.insert(aa[i]);\n\t}\n\tsort(aa + 1, aa + n + 1);\n\tfor(int i = 2; i <= n; ++i)\n\t\tjg[i] = aa[i] - aa[i-1] - 1 + jg[i-1];\n\tLL now = (aa[1] << 1) % m;\n\tbool f = true;\n\tfor(int i = 2; i <= n; ++i)\n\t{\n\t\tif((aa[i] << 1) % m != now)\n\t\t{\n\t\t\tf = false;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif(f)\n\t\tans.push_back(now);\n\tif(!(n & 1))\n\t{\n\t\tf = true;\n\t\tint L = 1, R = (n >> 1) + 1;\n\t\tnow = (aa[L] + aa[R]) % m;\n\t\tfor(; R != 1; L++, R++, L %= n, R %= n)\n\t\t{\n\t\t\tif((aa[L] + aa[R]) % m != now)\n\t\t\t{\n\t\t\t\tf = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(f)\n\t\t\tans.push_back(now);\n\t}\n\telse\n\t{\n\t\tfor(int K = 1; K <= n; ++K)\n\t\t{\n\t\t\tf = true;\n\t\t\tint L = 1, R = (n >> 1) + 1;\n\t\t\tif(K <= R)\n\t\t\t\t++R;\n\t\t\tif(K <= L)\n\t\t\t\t++L;\n\t\t\tnow = aa[K] << 1;\n\t\t\tfor(; R != 1; L++, R++, L %= n, R %= n)\n\t\t\t{\n\t\t\t\tif(L == K)\n\t\t\t\t\t++L, L %= n;\n\t\t\t\tif(R == K)\n\t\t\t\t\t++R, R %= n;\n\t\t\t\tif((aa[L] + aa[R]) % m != now)\n\t\t\t\t{\n\t\t\t\t\tf = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(f)\n\t\t\t\tans.push_back(now);\n\t\t}\n\t}\n\tif(!((m - n) & 1))\n\t{\n\t\tf = true;\n\t\tint RK = (n >> 1) + 1;\n\t\tint pla = lower_bound(jg + 1, jg + n + 1, RK) - jg;\n\t\tLL nn = aa[pla] + 1 + RK - jg[pla];\n\t\tfor(int i = 1; i <= n; ++i)\n\t\t{\n\t\t\tif(!sxd.count((nn - aa[i] + m) % m))\n\t\t\t{\n\t\t\t\tf = false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(f)\n\t\t\tans.push_back(now);\n\t}\n\tsort(ans.begin(), ans.end());\n\tans.erase(unique(ans.begin(), ans.end()), ans.end());\n\tcout << ans.size() << endl;\n\tfor(unsigned i = 0; i < ans.size(); ++i)\n\t\tcout << ans[i] << ' ';\n\treturn 0;\n}///", "lang_cluster": "C++", "compilation_error": false, "code_uid": "61032855adba26e9a0020bc332cab021", "src_uid": "6a9f683dee69a7be2d06ec6646970f19", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "cmraujiovjraigvj", "lang_cluster": "C++", "compilation_error": true, "code_uid": "75cea0af183d4c0ea86483773bb22bf5", "src_uid": "2c70ae38f91ab739621a31b897b8fbf3", "difficulty": 3400.0} {"lang": "GNU C++17 (64)", "source_code": "#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include\r\n#include \r\nusing namespace std;\r\n#define rep(i,a,n) for (int i=a;i=a;i--)\r\n#define pb push_back\r\n#define mp make_pair\r\n#define all(x) (x).begin(),(x).end()\r\n#define fi first\r\n#define se second\r\n#define SZ(x) ((int)(x).size())\r\ntypedef vector VI;\r\ntypedef long long ll;\r\ntypedef pair PII;\r\ntypedef double db;\r\nmt19937 mrand(random_device{}()); \r\nconst ll mod=1000000007;\r\nconst ll mod2=998244353;\r\nint rnd(int x) { return mrand() % x;}\r\nll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}\r\nll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}\r\n\r\nVI pos[10];\r\nint cnt;\r\nll pw[15],s[15];\r\nll cnt2,n;\r\nint ans;\r\nint query(int fixpre,ll val) {\r\n\tll ans=0;\r\n\trep(d,0,7) {\r\n\t\tll offset=(val-fixpre*pw[d])%mod2;\r\n\t\tif (offset<0) offset+=mod2;\r\n\t\tint p=lower_bound(all(pos[d]),mod2-offset)-pos[d].begin();\r\n\t\tans=(ans+s[d]+offset*SZ(pos[d])-mod2*(SZ(pos[d])-p))%mod;\r\n\t}\r\n\treturn ans;\r\n}\r\n\r\nvoid dfs(int val,int d) {\r\n\tint x=(cnt-val+mod2)%mod2;\r\n\tpos[d].pb(x); cnt++;\r\n\ts[d]+=x;\r\n\tif (d==6) return;\r\n\trep(i,0,10) dfs(val*10+i,d+1);\r\n}\r\n\r\nvoid dfs2(ll val) {\r\n\tif (val*1000000+999999<=n&&val*10000000>n) {\r\n\t\tans=(ans+query(val,cnt2+1))%mod;\r\n\t\tcnt2+=cnt;\r\n\t} else {\r\n\t\tcnt2++;\r\n\t\tans=(ans+((cnt2-val)%mod2+mod2)%mod2)%mod;\r\n\t\trep(i,val?0:1,10) {\r\n\t\t\tif (val*10+i<=n) dfs2(val*10+i);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nint main() {\r\n\tdfs(0,0);\r\n\trep(i,0,7) sort(all(pos[i]));\r\n\tpw[0]=1;\r\n\trep(i,1,13) pw[i]=pw[i-1]*10;\r\n\tscanf(\"%lld\",&n);\r\n\tcnt2=-1;\r\n\tdfs2(0);\r\n\tprintf(\"%d\\n\",ans);\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3950a44e29ebb5317ca8886d5fc56e9e", "src_uid": "2c70ae38f91ab739621a31b897b8fbf3", "difficulty": 3400.0} {"lang": "GNU C++14", "source_code": "#include \r\n#define lld long long \r\nusing namespace std;\r\nconst lld mod1 = 998244353;\r\nconst lld mod2 = 1e9 + 7;\r\nlld ans;\r\nlld n;\r\nlld cnt1;\r\nvector < lld > val[7];\r\nlld sum[7];\r\nvoid dfs1 (lld k1, lld k2) {\r\n\tif (k1 == 7) return;\r\n\tval[k1].push_back((cnt1 - k2 + mod1) % mod1);\r\n\tsum[k1] += (cnt1 - k2 + mod1) % mod1;\r\n\t++ cnt1;\r\n\tfor (lld i = 0; i <= 9; ++ i)\r\n\t\tdfs1 (k1 + 1, k2 * 10 + i);\r\n}\r\ninline bool check(lld x) { return x * 1000000 + 999999 <= n && x * 10000000 > n; }\r\nlld cnt2;\r\nlld poww[7] = { 1, 10, 100, 1000, 10000, 100000, 1000000 };\r\nvoid dfs2(lld k1, lld k2) {\r\n\tif (k2 > n) return;\r\n\tif (check(k2)) {\r\n\t\tfor (lld i = 0; i <= 6; ++ i) {\r\n\t\t\tlld offset = ((cnt2 + 1 - (k2 * poww[i])) % mod1 + mod1) % mod1;\r\n\t\t\tlld pos = lower_bound(val[i].begin(), val[i].end(), mod1 - offset) - val[i].begin();\r\n\t\t\tans = (ans + (sum[i] + offset * val[i].size() - mod1 * (val[i].size() - pos))) %= mod2;\r\n\t\t}\r\n\t\tcnt2 += cnt1;\r\n\t} else {\r\n\t\t++ cnt2;\r\n\t\tans = (ans + ((cnt2 - k2) % mod1 + mod1) % mod1) %= mod2;\r\n\t\tfor (lld i = (!k1); i <= 9; ++ i)\r\n\t\t\tdfs2(k1 + 1, k2 * 10 + i);\r\n\t}\r\n}\r\nint main() {\r\n\tscanf(\"%lld\", & n);\r\n\tdfs1 (0, 0);\r\n\tfor (lld i = 0; i <= 6; ++ i) sort(val[i].begin(), val[i].end());\r\n\tcnt2 = -1;\r\n\tdfs2 (0, 0);\r\n\tprintf(\"%lld\\n\", ans);\r\n}\r\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "16ac455c2b6e9fd7737a7bc765ce2d56", "src_uid": "2c70ae38f91ab739621a31b897b8fbf3", "difficulty": 3400.0} {"lang": "GNU C++14", "source_code": "#include \r\n//#include \r\n//#include \r\n//#include \r\nusing namespace std;\r\n//using namespace __gnu_pbds;\r\n#define fi first\r\n#define se second\r\n#define fill0(a) memset(a,0,sizeof(a))\r\n#define fill1(a) memset(a,-1,sizeof(a))\r\n#define fillbig(a) memset(a,63,sizeof(a))\r\n#define pb push_back\r\n#define ppb pop_back\r\n#define mp make_pair\r\n#define mt make_tuple\r\n#define SZ(v) ((int)v.size())\r\n#ifdef LOCAL\r\n#define eprintf(...) fprintf(stderr,__VA_ARGS__)\r\n#else\r\n#define eprintf(...) 1064\r\n#endif\r\ntemplate void chkmin(T1 &x,T2 y){if(x>y) x=y;}\r\ntemplate void chkmax(T1 &x,T2 y){if(x pii;\r\ntypedef long long ll;\r\ntypedef unsigned int u32;\r\ntypedef unsigned long long u64;\r\ntypedef long double ld;\r\n#ifdef FASTIO\r\n#define FILE_SIZE 1<<23\r\nchar rbuf[FILE_SIZE],*p1=rbuf,*p2=rbuf,wbuf[FILE_SIZE],*p3=wbuf;\r\n#ifdef LOCAL\r\ninline char getc(){return getchar();}\r\ninline void putc(char c){putchar(c);}\r\n#else\r\ninline char getc(){return p1==p2&&(p2=(p1=rbuf)+fread(rbuf,1,FILE_SIZE,stdin),p1==p2)?-1:*p1++;}\r\ninline void putc(char x){*p3++=x;}\r\n#endif\r\ntemplate void read(T &x){\r\n\tx=0;char c=getc();T neg=0;\r\n\twhile(!isdigit(c)) neg|=(c=='-'),c=getc();\r\n\twhile(isdigit(c)) x=x*10+(c-'0'),c=getc();\r\n\tif(neg) x=-x;\r\n}\r\ntemplate void recursive_print(T x){if(!x) return;recursive_print(x/10);putc(x%10^48);}\r\ntemplate void print(T x){if(!x) putc('0');if(x<0) putc('-'),x=-x;recursive_print(x);}\r\ntemplate void print(T x,char c){print(x);putc(c);}\r\nvoid readstr(char *s){\r\n\tchar c=getc();\r\n\twhile(c<=32||c>=127) c=getc();\r\n\twhile(c>32&&c<127) s[0]=c,s++,c=getc();\r\n\t(*s)=0;\r\n}\r\nvoid printstr(string s){for(int i=0;i=1);\r\n\t\t\t\tfor(int l=k+1;l<=i;l++)\r\n\t\t\t\t\tcnt[i][j][x]+=dd[k+1]*pw[i-l];\r\n\t\t\t}\r\n\t\t\t// if(i<=2&&j<=2)printf(\"cnt[%d][%d][%d]=%lld\\n\",i,j,x,cnt[i][j][x]);\r\n\t\t}\r\n\t}\r\n\tfor(int i=0;i>1;ll sum=0;\r\n\t\t\t\tfor(int k=0;k0)+cnt[tot-i-1][B][x]+cnt[tot-i-1-B][D-B][y]);\r\n\t\t\t\t\tans=(ans+norm(sum+2+(B>0)+cnt[tot-i-1][B][x]+cnt[tot-i-1-B][D-B][y]-V))%MOD2;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\tprintf(\"%d\\n\",ans);\r\n\treturn 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e300fff936943eea9312b65bafbbf8ce", "src_uid": "2c70ae38f91ab739621a31b897b8fbf3", "difficulty": 3400.0} {"lang": "MS C++ 2017", "source_code": "#if 0\n#include \n#include \n\nlong long phi( long long n )\n{\n long long result = n, nSqrt = sqrt( n );\n for (long long i = 2; i <= nSqrt; ++i)\n if (!(n % i))\n {\n while (!(n % i))\n n /= i;\n result -= result / i;\n }\n if (n > 1)\n result -= result / n;\n return result;\n}\n\nint main()\n{\n long long n, k, fn;\n std::cin >> n >> k;\n fn = n;\n for (long long i = 1; i <= k && fn != 1; ++i)\n if (i & 1) \n fn = phi(fn);\n else\n {\n /*long long sum = 0, half = fn / 2;\n for (long long j = 1; j <= half && fn != 1; ++j)\n if (!(fn % j))\n sum += phi(j);\n fn = sum + phi(fn);*/\n }\n std::cout << fn % 1000000007;\n\n return 0;\n}\n#endif\n\nSkip to content\nSearch or jump to\ufffd\n\nPull requests\nIssues\nMarketplace\nExplore\n\n@V7074\nkanash1\n/\ntasks - team - 8\n1\n01\nCode\nIssues 0\nPull requests 0 Actions\nProjects 0\nWiki\nSecurity 0\nInsights\ntasks - team - 8 / division with remainder / 774E_Big_Number_and_Remainder.cpp\n@kanash1 kanash1 Rename 774E_Big_Number_and_Remainder.cpp to division with remainder / 7\ufffd\ne2b0895 23 hours ago\n68 lines( 54 sloc ) 2.49 KB\n\n#include \n#include \n\nusing namespace std;\n\nchar num[200001];\t\t// \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\nint numLen,\t\t\t// \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\nm,\t\t\t\t// \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ntemp,\t\t\t\t// \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\nanswer = 0;\t\t\t// \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\nint stepArr = 1;\t\t// \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd 10 \ufffd\ufffd m\n\nint main()\n{\n\t// \ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\tcin >> num >> m;\n\n\t// \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \n\tnumLen = strlen( num );\n\n\t// \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\n\tanswer += (num[numLen - 1] - 48) % m;\n\tfor (int i = numLen - 2; i >= 0; i--)\n\t{\n\t\tstepArr = (stepArr * 10) % m;\n\t\tanswer += ((num[i] - 48) * stepArr) % m;\n\t\tanswer %= m;\n\t}\n\n\t// \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\n\t/* =============================================================================\n\t\tP - \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\n\t\tQ - \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\n\t\tm - \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\t\t\t=============================================================================\n\t\t\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd:\n\t\tP = a_n * 10^n + a_(n-1) * 10^(n-1) + ... + a_0\n\t\tQ = a_(n-1) * 10^n + ... + a_0 * 10 + a_n =\n\t\t\t= (a_(n-1) * 10^(n-1) + ... + a_0) * 10 + a_n =\n\t\t\t= (P - a_n * 10^n) * 10 + a_n\n\t\t\t=============================================================================\n\t\t\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd:\n\t\tQ % m = ((P - a_n * 10^n) * 10 + a_n) % m\n\t\tQ % m = (((P % m - (a_n % m * 10^n % m) % m + m) % m * 10) % m + a_n % m) % m\n\t\t\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd (P % m - (a_n % m * 10^n % m) % m + m) \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd m \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd,\n\t\t\ufffd\ufffd\ufffd\ufffd P % m < (a_n % m * 10^n % m) % m\n\t\t\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd % m \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\t\t\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd \ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\n\t\t\t============================================================================= */\n\t\t\t// \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\n\ttemp = answer;\n\tfor (int i = 0; i < numLen - 1; i++)\n\t{\n\t\ttemp = ((((temp - (num[i] - 48) * stepArr) % m + m) * 10) % m + (num[i] - 48) % m) % m;\n\t\tif (num[i + 1] ^ 48)\n\t\t{\n\t\t\tif (answer > temp)\n\t\t\t{\n\t\t\t\tanswer = temp;\n\t\t\t}\n\t\t}\n\t}\n\tcout << answer;\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b7323178f2f1e2562765e782be48f87e", "src_uid": "d13c7b5b5fc5c433cc8f374ddb16ef79", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#define _CRT_SECURE_NO_WARNINGS 1\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long LL;\nchar num[500005];\nint n;\nint len;\nint mod_num(char num[],int n)\n{\n\tint mod = 0;\n\tfor (int i = 0; i < len; i++)\n\t{\n\t\tmod = (mod * 10 + (num[i] - '0')) % n;\n\t}\n\treturn mod;\n}\n\nvoid change(int index)\n{\n\tfor (int i = 0; i < len; i++)\n\t{\n\t\ttemp[i] = (index + i) >= len ? num[index + i - len] : num[index + i];\n\t}\n}\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin >> num >> n;\n\tlen = strlen(num);\n\tfor (int i = len; i < 2*len; i++)\n\t{\n\t\tnum[i] = num[i - len];\n\t}\n\tnum[2 * len] = '\\0';\n\tint min = 999999999;\n\tfor (int i = 0; i < len; i++)\n\t{\n\t\tif (num[i] != '0')\n\t\t{\n\t\t\t//change(i);\n\t\t\tint temp_1 = mod_num(num+i, n);\n\t\t\tif (temp_1 < min)\n\t\t\t\tmin = temp_1;\n\t\t}\n\t}\n\tcout << min << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b550db4c9406997bdd1f8894016306fb", "src_uid": "d13c7b5b5fc5c433cc8f374ddb16ef79", "difficulty": 2300.0} {"lang": "GNU C++11", "source_code": "# include \n# include \n# include \n\nusing namespace std;\n\nchar cc[500000];\n\nlong long m; \nlong long ans = 99999999;\nint main(void)\n{\n//\tfreopen(\"aaa.in\",\"r\",stdin);\n\tscanf(\"%s\",cc);\n\tint len=0;\n\twhile (cc[len]>='0'&&cc[len]<='9') len++;\n\tscanf(\"%I64d\",&m);\n\tint ll=0,xx=m;\n\twhile (xx)\n\t{\n\t\tll++;\n\t\txx/=10;\n\t\t}\n//\t\tcout<\n# include \n# include \n\nusing namespace std;\n\nchar cc[500000];\n\nlong long m; \nlong long ans = 99999999;\nint main(void)\n{\n//\tfreopen(\"aaa.in\",\"r\",stdin);\n\tscanf(\"%s\",cc);\n\tint len=0;\n\twhile (cc[len]>='0'&&cc[len]<='9') len++;\n\tscanf(\"%I64d\",&m);\n\tint ll=0,xx=m;\n\twhile (xx)\n\t{\n\t\tll++;\n\t\txx/=10;\n\t\t}\n//\t\tcout<\n# include \n# include \n\nusing namespace std;\n\nchar cc[500000];\n\nlong long m; \nlong long ans = 99999999;\nint main(void)\n{\n//\tfreopen(\"aaa.in\",\"r\",stdin);\n\tscanf(\"%s\",cc);\n\tint len=0;\n\twhile (cc[len]>='0'&&cc[len]<='9') len++;\n\tscanf(\"%I64d\",&m);\n\tint ll=0,xx=m;\n\twhile (xx)\n\t{\n\t\tll++;\n\t\txx/=10;\n\t\t}\n//\t\tcout<\n# include \n# include \n\nusing namespace std;\n\nchar cc[500000];\n\nlong long m; \nlong long ans = 99999999;\nint main(void)\n{\n//\tfreopen(\"aaa.in\",\"r\",stdin);\n\tscanf(\"%s\",cc);\n\tint len=0;\n\twhile (cc[len]>='0'&&cc[len]<='9') len++;\n\tscanf(\"%I64d\",&m);\n\tint ll=0,xx=m;\n\twhile (xx)\n\t{\n\t\tll++;\n\t\txx/=10;\n\t\t}\n//\t\tcout<\n# include \n# include \n\nusing namespace std;\n\nchar cc[500000];\n\nlong long m; \nlong long ans = 99999999;\nint main(void)\n{\n//\tfreopen(\"aaa.in\",\"r\",stdin);\n\tscanf(\"%s\",cc);\n\tint len=0;\n\twhile (cc[len]>='0'&&cc[len]<='9') len++;\n\tscanf(\"%I64d\",&m);\n\tint ll=0,xx=m;\n\twhile (xx)\n\t{\n\t\tll++;\n\t\txx/=10;\n\t\t}\n//\t\tcout<= numChars) {\n curChar = 0;\n try {\n numChars = stream.read(buf);\n } catch (IOException e) {\n throw new InputMismatchException();\n }\n if (numChars <= 0)\n return -1;\n }\n return buf[curChar++];\n }\n\n public int nextInt() {\n int c = read();\n while (isSpaceChar(c))\n c = read();\n int sgn = 1;\n if (c == '-') {\n sgn = -1;\n c = read();\n }\n int res = 0;\n do {\n if (c < '0' || c > '9')\n throw new InputMismatchException();\n res *= 10;\n res += c - '0';\n c = read();\n } while (!isSpaceChar(c));\n return res * sgn;\n }\n\n public String nextToken() {\n int c;\n while (isSpaceChar(c = read())) ;\n StringBuilder result = new StringBuilder();\n result.appendCodePoint(c);\n while (!isSpaceChar(c = read()))\n result.appendCodePoint(c);\n return result.toString();\n }\n\n public static boolean isSpaceChar(int c) {\n return c == ' ' || c == '\\n' || c == '\\r' || c == '\\t' || c == -1;\n }\n\n }\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "96dd3cd154958d5c11d88f67c550a443", "src_uid": "d13c7b5b5fc5c433cc8f374ddb16ef79", "difficulty": 2300.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n \ntypedef long long ll;\ntypedef long double ld;\ntypedef double db; \ntypedef string str; \n\ntypedef pair pi;\ntypedef pair pl; \ntypedef pair pd; \n\ntypedef vector vi; \ntypedef vector vl; \ntypedef vector vd; \ntypedef vector vs; \ntypedef vector vpi;\ntypedef vector vpl; \ntypedef vector vpd; \n\n#define mp make_pair \n#define f first\n#define s second\n#define sz(x) (int)x.size()\n#define all(x) begin(x), end(x)\n#define rall(x) (x).rbegin(), (x).rend() \n#define rsz resize\n#define ins insert \n#define ft front() \n#define bk back()\n#define pf push_front \n#define pb push_back\n#define eb emplace_back \n#define lb lower_bound \n#define ub upper_bound \n\n#define FOR(i,a,b) for (int i = (a); i < (b); ++i)\n#define F0R(i,a) FOR(i,0,a)\n#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)\n#define R0F(i,a) ROF(i,0,a)\n#define trav(a,x) for (auto& a: x)\n\nconst int MOD = 1e9+7; // 998244353; \nconst int MX = 5e5+5; \nconst ll INF = 1e18; \nconst ld PI = acos((ld)-1);\nconst int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; \n\ntemplate bool ckmin(T& a, const T& b) { \n\treturn b < a ? a = b, 1 : 0; }\ntemplate bool ckmax(T& a, const T& b) { \n\treturn a < b ? a = b, 1 : 0; } \nint pct(int x) { return __builtin_popcount(x); } \nint bit(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) \nint cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 \n\nnamespace input {\n\ttemplate void re(complex& x);\n\ttemplate void re(pair& p);\n\ttemplate void re(vector& a);\n\ttemplate void re(array& a);\n\n\ttemplate void re(T& x) { cin >> x; }\n\tvoid re(double& x) { string t; re(t); x = stod(t); }\n\tvoid re(ld& x) { string t; re(t); x = stold(t); }\n\ttemplate void re(T& t, Ts&... ts) { \n\t\tre(t); re(ts...); \n\t}\n\n\ttemplate void re(complex& x) { T a,b; re(a,b); x = {a,b}; }\n\ttemplate void re(pair& p) { re(p.f,p.s); }\n\ttemplate void re(vector& a) { F0R(i,sz(a)) re(a[i]); }\n\ttemplate void re(array& a) { F0R(i,SZ) re(a[i]); }\n}\n\nusing namespace input;\n\nnamespace output {\n\tvoid pr(int x) { cout << x; }\n\tvoid pr(long x) { cout << x; }\n\tvoid pr(ll x) { cout << x; }\n\tvoid pr(unsigned x) { cout << x; }\n\tvoid pr(unsigned long x) { cout << x; }\n\tvoid pr(unsigned long long x) { cout << x; }\n\tvoid pr(float x) { cout << x; }\n\tvoid pr(double x) { cout << x; }\n\tvoid pr(ld x) { cout << x; }\n\tvoid pr(char x) { cout << x; }\n\tvoid pr(const char* x) { cout << x; }\n\tvoid pr(const string& x) { cout << x; }\n\tvoid pr(bool x) { pr(x ? \"true\" : \"false\"); }\n\ttemplate void pr(const complex& x) { cout << x; }\n\t\n\ttemplate void pr(const pair& x);\n\ttemplate void pr(const T& x);\n\t\n\ttemplate void pr(const T& t, const Ts&... ts) { \n\t\tpr(t); pr(ts...); \n\t}\n\ttemplate void pr(const pair& x) { \n\t\tpr(\"{\",x.f,\", \",x.s,\"}\"); \n\t}\n\ttemplate void pr(const T& x) { \n\t\tpr(\"{\"); // const iterator needed for vector\n\t\tbool fst = 1; for (const auto& a: x) pr(!fst?\", \":\"\",a), fst = 0; \n\t\tpr(\"}\");\n\t}\n\t\n\tvoid ps() { pr(\"\\n\"); } // print w/ spaces\n\ttemplate void ps(const T& t, const Ts&... ts) { \n\t\tpr(t); if (sizeof...(ts)) pr(\" \"); ps(ts...); \n\t}\n\t\n\tvoid pc() { pr(\"]\\n\"); } // debug w/ commas\n\ttemplate void pc(const T& t, const Ts&... ts) { \n\t\tpr(t); if (sizeof...(ts)) pr(\", \"); pc(ts...); \n\t}\n\t#define dbg(x...) pr(\"[\",#x,\"] = [\"), pc(x);\n}\n\nusing namespace output;\n\nnamespace io {\n\tvoid setIn(string s) { freopen(s.c_str(),\"r\",stdin); }\n\tvoid setOut(string s) { freopen(s.c_str(),\"w\",stdout); }\n\tvoid setIO(string s = \"\") {\n\t\tios_base::sync_with_stdio(0); cin.tie(0); // fast I/O\n\t\t// cin.exceptions(cin.failbit); \n\t\t// throws exception when do smth illegal\n\t\t// ex. try to read letter into int\n\t\tif (sz(s)) { setIn(s+\".in\"), setOut(s+\".out\"); } // for USACO\n\t}\n}\n\nusing namespace io;\n\nmt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); \n\n\n/**\n * Description: Disjoint Set Union with path compression. \n \t* Add edges and test connectivity. Use for Kruskal's \n \t* minimum spanning tree.\n * Time: O(\\alpha(N))\n * Source: CSAcademy, KACTL\n * Verification: USACO superbull\n */\n\nstruct DSU {\n\tvpi par;\n\tvoid init(int n) { \n\t\tpar.rsz(n);\n\t\tF0R(i,n) par[i] = {i,0}; \n\t}\n\tpi get(int x) { \n\t\tif (par[x].f == x) return par[x];\n\t\tpi p = get(par[x].f); p.s ^= par[x].s;\n\t\treturn par[x] = p;\n\t}\n\tvoid unite(int x, int y, int z) { // union-by-rank\n\t\tpi X = get(x), Y = get(y);\n\t\t// ps(\"UNITE\",x,y,z);\n\t\tif (X.f == Y.f) {\n\t\t\tif ((X.s^Y.s) != z) {\n\t\t\t\tps(-1);\n\t\t\t\texit(0);\n\t\t\t}\n\t\t} else {\n\t\t\tpar[Y.f] = {X.f,X.s^Y.s^z};\n\t\t}\n\t}\n};\n\n/**\n * Description: Calculates least common ancestor in tree \n \t* with root $R$ using binary jumping. \n * Time: O(N\\log N) build, O(\\log N) query\n * Source: USACO Camp\n * Verification: Debug the Bugs\n */\n\ntemplate struct LCA {\n\tstatic const int BITS = 32-__builtin_clz(SZ);\n\tint N, R = 1, par[BITS][SZ], depth[SZ];\n\tvi adj[SZ]; \n\t/// INITIALIZE\n\tvoid ae(int u, int v) { adj[u].pb(v), adj[v].pb(u); }\n\tvoid dfs(int u, int prev){\n\t\tpar[0][u] = prev; depth[u] = depth[prev]+1;\n\t\ttrav(v,adj[u]) if (v != prev) dfs(v, u);\n\t}\n\tvoid init(int _N) {\n\t\tN = _N; dfs(R,0);\n\t\tFOR(k,1,BITS) FOR(i,1,N+1) \n\t\t\tpar[k][i] = par[k-1][par[k-1][i]];\n\t}\n\t/// QUERY\n\tint getPar(int a, int b) {\n\t\tR0F(k,BITS) if (b&(1< L;\nint n,m, mn[MX], c[MX], mid;\nbool bad;\n\nDSU D;\nbool par[MX], tmpPar[MX];\npi stor[MX];\n\nbool fin;\n\nvoid dfs(int x) {\n\ttrav(t,L.adj[x]) if (t != L.par[0][x]) {\n\t\tdfs(t); if (bad) return;\n\t}\n\ttrav(t,L.adj[x]) if (t != L.par[0][x]) {\n\t\tstor[D.get(t).f].f = MOD;\n\t\t// ps(\"OH\",x,t,D.get(x).f,D.get(t).f);\n\t}\n\tpi p = D.get(x); stor[p.f] = {1,mid};\n\tvi todo = {p.f};\n\ttrav(t,L.adj[x]) if (t != L.par[0][x]) {\n\t\tpi p = D.get(t);\n\t\tif (stor[p.f].f == MOD) {\n\t\t\t// ps(\"WAT\",x,p);\n\t\t\tstor[p.f] = {1,mid};\n\t\t\ttodo.pb(p.f);\n\t\t}\n\t\tif (p.s == 0) ckmax(stor[p.f].f,mn[t]+1); // goes up\n\t\telse ckmin(stor[p.f].s,mid-mn[t]);\n\t\t// ps(\"AH\",stor[p.f]);\n\t}\n\tpi P = stor[p.f]; if (p.s) P = {mid+1-P.s,mid+1-P.f};\n\tpi ban = {MOD,-MOD};\n\tint LL = P.f, RR = P.s;\n\tFOR(i,1,sz(todo)) {\n\t\tpi z = stor[todo[i]];\n\t\tif (z.f > z.s) { bad = 1; return; }\n\t\tpi Z = {mid+1-z.s,mid+1-z.f};\n\t\tif (z > Z) swap(z,Z);\n\t\tckmax(LL,z.f), ckmin(RR,Z.s);\n\t\tif (z.s+1 < Z.f) { ckmin(ban.f,z.s+1), ckmax(ban.s,Z.f-1); }\n\t}\n\tif (LL > RR) { bad = 1; return; }\n\tint val;\n\t// ps(\"HAHA\",LL,RR,ban);\n\tif (LL < ban.f) val = LL;\n\telse if (LL > ban.s) val = LL;\n\telse if (ban.s < RR) val = ban.s+1;\n\telse { bad = 1; return; }\n\tmn[x] = val; tmpPar[p.f] = p.s;\n\tFOR(i,1,sz(todo)) {\n\t\tpi t = stor[todo[i]];\n\t\t//ps(\"OH\",t);\n\t\tif (t.f <= val && val <= t.s) {\n\t\t\ttmpPar[todo[i]] = 0;\n\t\t} else {\n\t\t\t// assert(mid+1-t.s.s <= val && val <= mid+1-t.s.f);\n\t\t\ttmpPar[todo[i]] = 1;\n\t\t}\n\t}\n\tif (fin) {\n\t\ttrav(t,L.adj[x]) if (t != L.par[0][x]) {\n\t\t\tpi p = D.get(t);\n\t\t\tpar[t] = tmpPar[p.f]^p.s;\n\t\t\t//ps(\"HAHA\",t,par[t]);\n\t\t}\n\n\t}\n}\n\nbool ok() {\n\tbad = 0; dfs(1);\n\treturn !bad;\n}\n\nvoid genAns(int x) {\n\tif (par[x] == 0) {\n\t\tc[x] = mn[x];\n\t} else {\n\t\tc[x] = mid+1-mn[x];\n\t}\n\ttrav(t,L.adj[x]) if (t != L.par[0][x]) {\n\t\tpar[t] ^= par[x];\n\t\tgenAns(t);\n\t}\n}\n\nint ad[MX];\nvoid path(int a, int b) {\n\t// ps(\"OH\",a,b);\n\tint x = L.lca(a,b);\n\tint A,B;\n\tif (a != x) {\n\t\tA = L.getPar(a,L.depth[a]-L.depth[x]-1);\n\t\tad[a] ++; ad[A] --;\n\t}\n\tif (b != x) {\n\t\tB = L.getPar(b,L.depth[b]-L.depth[x]-1);\n\t\tad[b] ++; ad[B] --;\n\t}\n\tif (a != x && b != x) {\n\t\tD.unite(A,B,1);\n\t}\n}\n\nvoid genAd(int x) {\n\ttrav(t,L.adj[x]) if (t != L.par[0][x]) {\n\t\tgenAd(t);\n\t\tad[x] += ad[t];\n\t}\n\tif (ad[x]) {\n\t\tD.unite(x,L.par[0][x],0);\n\t}\n}\n\n/**\n * Description: Fast input and output.\n * Time: input is $\\sim$300ms faster for $10^6$ long longs on CF\n * Source: \n \t* https://codeforces.com/gym/102394/submission/64154785\n \t* https://codeforces.com/contest/1254/submission/65420506 (neal)\n \t* https://codeforces.com/blog/entry/45835 (AI.Cash)\n * Verification: https://codeforces.com/gym/102394/problem/G \n */\n\nnamespace FastIO {\n\tconst int BSZ = 1<<15; ////// INPUT\n\tchar ibuf[BSZ]; int ipos, ilen;\n\tchar nc() { // next char\n\t\tif (ipos == ilen) {\n\t\t\tipos = 0; ilen = fread(ibuf,1,BSZ,stdin);\n\t\t\tif (!ilen) return EOF;\n\t\t}\n\t\treturn ibuf[ipos++];\n\t}\n\tvoid rs(str& x) { // read str\n\t\tchar ch; while (isspace(ch = nc()));\n\t\tdo { x += ch; } while (!isspace(ch = nc()) && ch != EOF);\n\t}\n\ttemplate void ri(T& x) { // read int or ll\n\t\tchar ch; int sgn = 1;\n\t\twhile (!isdigit(ch = nc())) if (ch == '-') sgn *= -1;\n\t\tx = ch-'0'; while (isdigit(ch = nc())) x = x*10+(ch-'0');\n\t\tx *= sgn;\n\t}\n\ttemplate void ri(T& t, Ts&... ts) { \n\t\tri(t); ri(ts...); } // read ints\n\t////// OUTPUT (call initO() at start)\n\tchar obuf[BSZ], numBuf[100]; int opos;\n\tvoid flushOut() { fwrite(obuf,1,opos,stdout); opos = 0; }\n\tvoid wc(char c) { // write char\n\t\tif (opos == BSZ) flushOut();\n\t\tobuf[opos++] = c; }\n\tvoid ws(str s) { trav(c,s) wc(c); } // write str\n\ttemplate void wi(T x, char after = '\\0') { /// write int\n\t\tif (x < 0) wc('-'), x *= -1;\n\t\tint len = 0; for (;x>=10;x/=10) numBuf[len++] = '0'+(x%10);\n\t\twc('0'+x); R0F(i,len) wc(numBuf[i]);\n\t\tif (after) wc(after);\n\t}\n\tvoid initO() { assert(atexit(flushOut) == 0); } /// auto-flush output\n}\nusing namespace FastIO;\n/// initO(); int a,b; ri(a,b); wi(b,'\\n'); wi(a,'\\n'); \n\nvoid init() {\n\tinitO();\n\tri(n,m); D.init(n+1);\n\tF0R(i,n-1) {\n\t\tint a,b; ri(a,b);\n\t\tL.ae(a,b);\n\t}\n\tL.init(n);\n\tF0R(i,m) {\n\t\tint a,b; ri(a,b);\n\t\tpath(a,b);\n\t}\n\t// FOR(i,1,n+1) ps(i,ad[i]);\n\tgenAd(1);\n}\n\nint main() {\n\tinit();\n\tmid = n; // assert(ok());\n\t// exit(0);\n\tint lo = 1, hi = n;\n\twhile (lo < hi) {\n\t\tmid = (lo+hi)/2;\n\t\tif (ok()) hi = mid;\n\t\telse lo = mid+1;\n\t}\n\tmid = lo; \n\tfin = 1;\n\tassert(ok());\n\tps(mid);\n\tgenAns(1);\n\tFOR(i,1,n+1) {\n\t\tif (i < n) wi(c[i],' ');\n\t\telse wi(c[i],'\\n');\n\t}\n\t// you should actually read the stuff at the bottom\n}\n\n/* stuff you should look for\n\t* int overflow, array bounds\n\t* special cases (n=1?)\n\t* do smth instead of nothing and stay organized\n\t* WRITE STUFF DOWN\n*/", "lang_cluster": "C++", "compilation_error": false, "code_uid": "43138897b05cf7e70daf00fd591c8db3", "src_uid": "18d4fae42678823e57388b5359f3be61", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nconst int N=1e6+7,M=20; bool fl[N],rev[N],tg;\nint n,k,va,vb,opt,tot,q[N],w[N],h[N],dp[N],gt[N],ft[N],fa[N],st[N],col[N],dep[N],cnt[N],e[N][M]; vectorv[N],vw[N]; vector>f[N];\nstruct edge {int u,t;}g[N];\ninline int read(){\n\tint num=0; char g=getchar(); while(g<48||57=0;i--) if((1<=0;i--) if(e[u][i]!=e[t][i]) u=e[u][i],t=e[t][i]; return fa[u];\n}\ninline int jmp(int u,int t){\n\tfor(int i=19;i>=0;i--) if((1<=1;s--){\n\t\tint u=st[s],opt=1; ft[1]=fa[u]; int suma=0,sumb=0;\n//\t\tcout<d&&max(vc,sumb)+max(vd,suma)+1>d) return false;\n\t\tdp[u]=1919810;\n//\t\tcout<=1;s--){\n\t\tint u=st[s],opt=1; ft[1]=0; int suma=0,sumb=0;\n\t\tfor(int i=0;i=va&&vb+dp[u]<=d) bfg(0);\n\t\t\t\telse if(dp[u]-1>=vb&&va+dp[u]<=d) bfg(1);\n\t\t\t\telse cout<<\"fail\"<0&&b>0) f[c].push_back(make_pair(a,b));\n\t}\n\tfor(int s=n;s>=1;s--){\n\t\tu=st[s],opt=1;\n\t\tfor(int i=0;i>1; if(check(d)) ans=d,r=d-1; else l=d+1;\n\t}\n\tcheck(ans),solve(ans);\n\tcout<\n#define rep(i,a,b) for(int i=(a);i<(b);++i)\n#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)\n#define ll long long\n#define lb(x) ((x)&(-x))\n#define pii pair\n#define vi vector\n#define pb push_back\nusing namespace std;\nconst int N=5e5+9;\nconst ll mod=998244353;\nvi g[N];\nint n,m;\nnamespace dsu{\n\tint fa[N],v[N];\n\tint find(int x){\n\t\tif(fa[x]==x)return x;\n\t\tint f=fa[x];\n\t\tfa[x]=find(fa[x]);\n\t\tv[x]^=v[f];\n\t\treturn fa[x];\n\t}\n\tvoid build(){\n\t\trep(i,1,n+1)fa[i]=i;\n\t}\n\tvoid merge(int x,int y,int vv){\n\t\tint fx=find(x),fy=find(y);\n\t\tif(fx==fy){\n\t\t\tif(v[x]^v[y]^vv){\n\t\t\t\tprintf(\"-1\");\n\t\t\t\texit(0);\n\t\t\t}\n\t\t}\n\t\telse{\n\t\t\tfa[fx]=fy;\n\t\t\tv[fx]=v[x]^v[y]^vv;\n\t\t}\n\t}\n}\nnamespace TR{\n\tint S[N],SS[N],fa[N];\n\tint top[N],pos[N];\n\tint dfn[N],dep[N],sz[N];\n\tvoid dfs(int u){\n\t\tsz[u]=1;\n\t\tfor(auto v:g[u]){\n\t\t\tif(v==fa[u])continue;\n\t\t\tfa[v]=u;dep[v]=dep[u]+1;\n\t\t\tdfs(v);sz[u]+=sz[v];\n\t\t}\n\t}\n\tvoid dfs2(int u,int tp){\n\t\ttop[u]=tp;dfn[u]=++*dfn;pos[*dfn]=u;\n\t\tint k=0;\n\t\tfor(auto v:g[u]){\n\t\t\tif(v==fa[u])continue;\n\t\t\tif(sz[v]>sz[k])v=k;\n\t\t}\n\t\tif(k)dfs2(k,tp);\n\t\tfor(auto v:g[u]){\n\t\t\tif(v==fa[u]||v==k)continue;\n\t\t\tdfs2(v,v);\n\t\t}\n\t}\n\tint LCA(int u,int v){\n\t\tfor(;top[u]!=top[v];u=fa[top[u]]){\n\t\t\tif(dep[top[u]]v1[q[j]])\n\t\t\t\tswap(v0[q[j]],v1[q[j]]);\n\t\t\t\tvmn=max(vmn,v0[q[j]]);\n\t\t\t\tvmx=max(vmx,v0[q[j]]);\n\t\t\t}\n\t\t}\n\t\tif(max(vmn,min(vl,vr))+max(vmx,max(vl,vr))>=K)return 0;\n\t\tdp[u]=(max(vmn,vl)+max(vmx,vr)>=K?max(vmx,vl):max(vmn,vl))+1;\n\t}\n\treturn 1;\n}\nvoid construct(int K){\n\trep(i,1,n+1){\n\t\t++T;*q=0;\n\t\tint u=TR::pos[i],f=TR::fa[u];\n\t\tfor(auto v:g[u]){\n\t\t\tif(v==f||!TR::S[v])continue;\n\t\t\tint x=dsu::fa[v];\n\t\t\tif(vis[x]!=T)vis[x]=T,v0[x]=0,v1[x]=0,q[++*q]=x;\n\t\t\tif(!dsu::v[v])v0[x]=max(v0[x],dp[v]);\n\t\t\telse v1[x]=max(v1[x],dp[v]);\n\t\t}\n\t\trep(j,1,(*q)+1){\n\t\t\tcc[q[j]]=tag[u];\n\t\t\tif(dsu::fa[u]!=q[j])\n\t\t\tcc[q[j]]^=(v0[q[j]]>dp[u]-1||v1[q[j]]+dp[u]>K);\n\t\t\telse cc[q[j]]^=dsu::v[u];\n\t\t}\n\t\tfor(auto v:g[u]){\n\t\t\tif(v==f||!TR::S[v])continue;\n\t\t\ttag[v]=cc[dsu::fa[v]]^dsu::v[v];\n\t\t}\n\t}\n}\nint main(){\n\tscanf(\"%d%d\",&n,&m);\n\trep(i,1,n){\n\t\tint u,v;\n\t\tscanf(\"%d%d\",&u,&v);\n\t\tg[u].pb(v);g[v].pb(u);\n\t}\n\tTR::build();\n\tdsu::build();\n\trep(i,0,m){\n\t\tint u,v;\n\t\tscanf(\"%d%d\",&u,&v);\n\t\tTR::connect(u,v);\n\t}\n\tTR::build2();\n\trep(i,1,n+1)dsu::find(i); \n\tint l=1,r=n;\n\tif(m==10000){\n\t\tcout<>1;\n\t\tif(check(mid))r=mid;\n\t\telse l=mid+1;\n\t}\n\tprintf(\"%d\\n\",l);\n\tcheck(l);\n\tconstruct(l);\n\trep(i,1,n+1)printf(\"%d \",tag[i]?l+1-dp[i]:dp[i]);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "53791e29ec0a40c8f9648be131ceddbd", "src_uid": "18d4fae42678823e57388b5359f3be61", "difficulty": 3500.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std; \n\n#define PB push_back \n#define MP make_pair \n#define SZ(v) ((int)(v).size()) \n#define FOR(i,a,b) for(int i=(a);i<(b);++i) \n#define REP(i,n) FOR(i,0,n) \n#define FORE(i,a,b) for(int i=(a);i<=(b);++i) \n#define REPE(i,n) FORE(i,0,n) \n#define FORSZ(i,a,v) FOR(i,a,SZ(v)) \n#define REPSZ(i,v) REP(i,SZ(v)) \ntypedef long long ll; \nll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }\n\nconst int MAXN = 500000;\nconst int MAXBIT = 18;\nconst int MAXLINE = 500000;\n\nint n, nline;\nvector adj[MAXN];\nint lineend[MAXLINE][2];\n\nint par[MAXN], dep[MAXN];\nint up[MAXN][MAXBIT + 1];\n\nvoid dfsinit(int at) {\n\tdep[at] = par[at] == -1 ? 0 : dep[par[at]] + 1;\n\tup[at][0] = par[at] == -1 ? at : par[at]; REP(k, MAXBIT) up[at][k + 1] = up[up[at][k]][k];\n\tREPSZ(i, adj[at]) {\n\t\tint to = adj[at][i]; if (to == par[at]) continue;\n\t\tpar[to] = at; dfsinit(to);\n\t}\n}\nint calcup(int a, int steps) {\n\tfor (int k = MAXBIT; k >= 0; --k) if (steps&(1 << k)) a = up[a][k];\n\treturn a;\n}\nint calclca(int a, int b) {\n\tif (dep[a] < dep[b]) swap(a, b);\n\ta = calcup(a, dep[a] - dep[b]);\n\tif (a == b) return a;\n\tfor (int k = MAXBIT; k >= 0; --k) if (up[a][k] != up[b][k]) a = up[a][k], b = up[b][k];\n\treturn par[a];\n}\n\nint ufpar[MAXN], ufsz[MAXN], ufdiff[MAXN];\n\nint uffind(int a) { if (ufpar[a] == a) return a; uffind(ufpar[a]); ufdiff[a] ^= ufdiff[ufpar[a]]; return ufpar[a] = ufpar[ufpar[a]]; }\nbool ufunite(int a, int b, int diff) { uffind(a), uffind(b); diff ^= ufdiff[a], a = ufpar[a], diff ^= ufdiff[b], b = ufpar[b]; if (a == b) return diff == 0; if (ufsz[a] < ufsz[b]) swap(a, b); ufsz[a] += ufsz[b], ufpar[b] = a, ufdiff[b] ^= diff; return true; }\n\nint unitedep[MAXN];\nbool anyedge[MAXN];\n\nvoid dfsunite(int at) {\n\tREPSZ(i, adj[at]) {\n\t\tint to = adj[at][i]; if (to == par[at]) continue;\n\t\tdfsunite(to);\n\t\tunitedep[at] = min(unitedep[at], unitedep[to]);\n\t}\n}\n\nint dp[MAXN];\nint seenby[MAXN], mxzero[MAXN], mxone[MAXN];\nint seenlst[MAXN], nseenlst;\n\nbool dfscalc(int at, int lim) {\n\tREPSZ(i, adj[at]) {\n\t\tint to = adj[at][i]; if (to == par[at]) continue;\n\t\tif (!dfscalc(to, lim)) return false;\n\t}\n\tnseenlst = 0;\n\tif (par[at] == -1) REP(i, n) seenby[i] = -1;\n\tREPSZ(i, adj[at]) {\n\t\tint to = adj[at][i]; if (to == par[at]) continue;\n\t\tuffind(to);\n\t\tint id = ufpar[to];\n\t\tif (seenby[id] != at) seenlst[nseenlst++] = id, seenby[id] = at, mxzero[id] = mxone[id] = 0;\n\t\tif (ufdiff[to] == 0 && anyedge[to]) mxzero[id] = max(mxzero[id], dp[to]);\n\t\tif (ufdiff[to] == 1 && anyedge[to]) mxone[id] = max(mxone[id], dp[to]);\n\t}\n\tuffind(at); int me = ufpar[at];\n\tint lo = 1, loupto = lim, hi = lim, hidownto = 1;\n\tREP(i, nseenlst) {\n\t\tint id = seenlst[i];\n\t\t//printf(\"\\tat=%d comp=%d mxzero=%d mxone=%d [me=%d mediff=%d]\\n\", at + 1, it->first, mxzero, mxone, me, ufdiff[at]);\n\t\tint a = mxzero[id], b = mxone[id];\n\t\tif (id == me) {\n\t\t\tif (ufdiff[at] == 1) swap(a, b);\n\t\t\tlo = max(lo, a + 1); hi = min(hi, lim - b);\n\t\t} else {\n\t\t\t// [mxzero+1..lim-mxone] or [mxone+1..lim-mxzero]\n\t\t\tif (a > b) swap(a, b); // [a+1..lim-b] or [b+1..lim-a]\n\t\t\tlo = max(lo, a + 1), hi = min(hi, lim - a);\n\t\t\tif (lim - b < b + 1) loupto = min(loupto, lim - b), hidownto = max(hidownto, b + 1);\n\t\t}\n\t}\n\tloupto = min(loupto, hi);\n\thidownto = max(hidownto, lo);\n\tbool ret;\n\tif (lo <= loupto) { dp[at] = lo; ret = true; }\n\telse if (hidownto <= hi) { dp[at] = hidownto; ret = true; }\n\telse ret = false;\n\t//printf(\"lim=%d at=%d: %s (%d) [%d..%d and %d..%d]\\n\", lim, at + 1, ret ? \"OK\" : \"ERR\", dp[at], lo, loupto, hidownto, hi);\n\treturn ret;\n}\n\nint ans;\nint cost[MAXN];\nbool rev[MAXN];\nbool swapped[MAXN];\n\nvoid reconstruct(int at) {\n\tcost[at] = !rev[at] ? dp[at] : ans - dp[at] + 1;\n\tnseenlst = 0;\n\tif (par[at] == -1) REP(i, n) seenby[i] = -1;\n\tREPSZ(i, adj[at]) {\n\t\tint to = adj[at][i]; if (to == par[at]) continue;\n\t\tuffind(to);\n\t\tint id = ufpar[to];\n\t\tif (seenby[id] != at) seenlst[nseenlst++] = id, seenby[id] = at, mxzero[id] = mxone[id] = 0;\n\t\tif (ufdiff[to] == 0 && anyedge[to]) mxzero[id] = max(mxzero[id], dp[to]);\n\t\tif (ufdiff[to] == 1 && anyedge[to]) mxone[id] = max(mxone[id], dp[to]);\n\t}\n\tuffind(at); int me = ufpar[at];\n\tREP(i, nseenlst) {\n\t\tint id = seenlst[i];\n\t\t//printf(\"\\tat=%d comp=%d mxzero=%d mxone=%d [me=%d mediff=%d]\\n\", at + 1, it->first, mxzero, mxone, me, ufdiff[at]);\n\t\tint a = mxzero[id], b = mxone[id]; swapped[id] = false;\n\t\tif (id == me && ufdiff[at] == 1) swap(a, b), swapped[id] = !swapped[id];\n\t\tif ((dp[at] <= a || dp[at] > ans - b) && id != me) swap(a, b), swapped[id] = !swapped[id];\n\t\tassert(dp[at] > a && dp[at] <= ans - b);\n\t}\n\tREPSZ(i, adj[at]) {\n\t\tint to = adj[at][i]; if (to == par[at]) continue;\n\t\trev[to] = rev[at] ^ swapped[ufpar[to]] ^ (ufdiff[to] == 1);\n\t}\n\tREPSZ(i, adj[at]) {\n\t\tint to = adj[at][i]; if (to == par[at]) continue;\n\t\treconstruct(to);\n\t}\n}\n\nbool solve() {\n\tpar[0] = -1; dfsinit(0);\n\tREP(i, n) ufpar[i] = i, ufsz[i] = 1, ufdiff[i] = 0, unitedep[i] = dep[i], anyedge[i] = false;\n\tREP(i, nline) {\n\t\tint a = lineend[i][0], b = lineend[i][1]; if (dep[a] > dep[b]) swap(a, b);\n\t\tint c = calclca(a, b);\n\t\tif (c == a) {\n\t\t\tunitedep[b] = min(unitedep[b], dep[c]);\n\t\t} else {\n\t\t\tint aa = calcup(a, dep[a] - dep[c] - 1);\n\t\t\tint bb = calcup(b, dep[b] - dep[c] - 1);\n\t\t\tif (!ufunite(aa, bb, 1)) return false;\n\t\t\tunitedep[a] = min(unitedep[a], dep[c]);\n\t\t\tunitedep[b] = min(unitedep[b], dep[c]);\n\t\t}\n\t}\n\tdfsunite(0);\n\tREP(i, n) if (unitedep[i] < dep[i]) anyedge[i] = true;\n\tREP(i, n) if (unitedep[i] < dep[i] - 1) if (!ufunite(i, par[i], 0)) return false;\n\t//REP(i, n) if (par[i] != -1) { uffind(i); printf(\"%d-%d: %d,%d\\n\", i + 1, par[i] + 1, ufpar[i], ufdiff[i]); }\n\n\tint lo = 1, hi = n;\n\twhile (lo + 1 < hi) {\n\t\tint mi = lo + (hi - lo) / 2;\n\t\tif (!dfscalc(0, mi)) lo = mi; else hi = mi;\n\t}\n\tans = hi;\n\t//puts(\"\");\n\tassert(dfscalc(0, ans));\n\trev[0] = false; reconstruct(0);\n\treturn true;\n}\n\nvoid run() {\n\tscanf(\"%d%d\", &n, &nline);\n\tREP(i, n - 1) { int a, b; scanf(\"%d%d\", &a, &b); --a, --b; adj[a].PB(b); adj[b].PB(a); }\n\tREP(i, nline) REP(j, 2) scanf(\"%d\", &lineend[i][j]), --lineend[i][j];\n\tif (!solve()) { printf(\"-1\\n\"); return; }\n\tprintf(\"%d\\n\", ans);\n\tREP(i, n) { if (i != 0) printf(\" \"); printf(\"%d\", cost[i]); } puts(\"\");\n}\n\nint main() {\n\trun();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8fb96139c5bd70396503d330333ee32d", "src_uid": "18d4fae42678823e57388b5359f3be61", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "#include\n\nnamespace fft {\nusing namespace std;\n#define rep(i, a, b) for(int i = a; i < (b); ++i)\n#define trav(a, x) for(auto& a : x)\n#define all(x) x.begin(), x.end()\n#define sz(x) (int)(x).size()\ntypedef long long ll;\ntypedef pair pii;\ntypedef vector vi;\n#define FFT 1\n#if FFT\n// FFT\nusing dbl = double;\nstruct num { /// start-hash\n\tdbl x, y;\n\tnum(dbl x_ = 0, dbl y_ = 0) : x(x_), y(y_) { }\n};\ninline num operator+(num a, num b) { return num(a.x + b.x, a.y + b.y); }\ninline num operator-(num a, num b) { return num(a.x - b.x, a.y - b.y); }\ninline num operator*(num a, num b) { return num(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); }\ninline num conj(num a) { return num(a.x, -a.y); }\ninline num inv(num a) { dbl n = (a.x*a.x+a.y*a.y); return num(a.x/n,-a.y/n); }\n/// end-hash\n#else\n// NTT\nconst int mod = 998244353, g = 3;\n// For p < 2^30 there is also (5 << 25, 3), (7 << 26, 3),\n// (479 << 21, 3) and (483 << 21, 5). Last two are > 10^9.\nstruct num { /// start-hash\n\tint v;\n\tnum(ll v_ = 0) : v(int(v_ % mod)) { if (v<0) v+=mod; }\n\texplicit operator int() const { return v; }\n};\ninline num operator+(num a,num b){return num(a.v+b.v);}\ninline num operator-(num a,num b){return num(a.v+mod-b.v);}\ninline num operator*(num a,num b){return num(1ll*a.v*b.v);}\ninline num pow(num a, int b) {\n\tnum r = 1;\n\tdo{if(b&1)r=r*a;a=a*a;}while(b>>=1);\n\treturn r;\n}\ninline num inv(num a) { return pow(a, mod-2); }\n/// end-hash\n#endif\n\nusing vn = vector;\nvi rev({0, 1});\nvn rt(2, num(1)), fa, fb;\n\ninline void init(int n) { /// start-hash\n\tif (n <= sz(rt)) return;\n\trev.resize(n);\n\trep(i,0,n) rev[i] = (rev[i>>1] | ((i&1)*n)) >> 1;\n\trt.reserve(n);\n\tfor (int k = sz(rt); k < n; k *= 2) {\n\t\trt.resize(2*k);\n#if FFT\n\t\tdouble a=M_PI/k; num z(cos(a),sin(a)); // FFT\n#else\n\t\tnum z = pow(num(g), (mod-1)/(2*k)); // NTT\n#endif\n\t\trep(i,k/2,k) rt[2*i] = rt[i], rt[2*i+1] = rt[i]*z;\n\t}\n} /// end-hash\n\ninline void fft(vector &a, int n) { /// start-hash\n\tinit(n);\n\tint s = __builtin_ctz(sz(rev)/n);\n\trep(i,0,n) if (i < rev[i]>>s) swap(a[i], a[rev[i]>>s]);\n\tfor (int k = 1; k < n; k *= 2)\n\t\tfor (int i = 0; i < n; i += 2 * k) rep(j,0,k) {\n\t\t\tnum t = rt[j+k] * a[i+j+k];\n\t\t\ta[i+j+k] = a[i+j] - t;\n\t\t\ta[i+j] = a[i+j] + t;\n\t\t}\n} /// end-hash\n\n// Complex/NTT\nvn multiply(vn a, vn b) { /// start-hash\n\tint s = sz(a) + sz(b) - 1;\n\tif (s <= 0) return {};\n\tint L = s > 1 ? 32 - __builtin_clz(s-1) : 0, n = 1 << L;\n\ta.resize(n), b.resize(n);\n\tfft(a, n);\n\tfft(b, n);\n\tnum d = inv(num(n));\n\trep(i,0,n) a[i] = a[i] * b[i] * d;\n\treverse(a.begin()+1, a.end());\n\tfft(a, n);\n\ta.resize(s);\n\treturn a;\n} /// end-hash\n\n// Complex/NTT power-series inverse\n// Doubles b as b[:n] = (2 - a[:n] * b[:n/2]) * b[:n/2]\nvn inverse(const vn& a) { /// start-hash\n\tif (a.empty()) return {};\n\tvn b({inv(a[0])});\n\tb.reserve(2*a.size());\n\twhile (sz(b) < sz(a)) {\n\t\tint n = 2*sz(b);\n\t\tb.resize(2*n, 0);\n\t\tif (sz(fa) < 2*n) fa.resize(2*n);\n\t\tfill(fa.begin(), fa.begin()+2*n, 0);\n\t\tcopy(a.begin(), a.begin()+min(n,sz(a)), fa.begin());\n\t\tfft(b, 2*n);\n\t\tfft(fa, 2*n);\n\t\tnum d = inv(num(2*n));\n\t\trep(i, 0, 2*n) b[i] = b[i] * (2 - fa[i] * b[i]) * d;\n\t\treverse(b.begin()+1, b.end());\n\t\tfft(b, 2*n);\n\t\tb.resize(n);\n\t}\n\tb.resize(a.size());\n\treturn b;\n} /// end-hash\n\n#if FFT\n// Double multiply (num = complex)\nusing vd = vector;\nvd multiply(const vd& a, const vd& b) { /// start-hash\n\tint s = sz(a) + sz(b) - 1;\n\tif (s <= 0) return {};\n\tint L = s > 1 ? 32 - __builtin_clz(s-1) : 0, n = 1 << L;\n\tif (sz(fa) < n) fa.resize(n);\n\tif (sz(fb) < n) fb.resize(n);\n\n\tfill(fa.begin(), fa.begin() + n, 0);\n\trep(i,0,sz(a)) fa[i].x = a[i];\n\trep(i,0,sz(b)) fa[i].y = b[i];\n\tfft(fa, n);\n\ttrav(x, fa) x = x * x;\n\trep(i,0,n) fb[i] = fa[(n-i)&(n-1)] - conj(fa[i]);\n\tfft(fb, n);\n\tvd r(s);\n\trep(i,0,s) r[i] = fb[i].y / (4*n);\n\treturn r;\n} /// end-hash\n\n// Integer multiply mod m (num = complex) /// start-hash\nvector multiply(const vi& a, const vi& b) {\n\tint s = sz(a) + sz(b) - 1;\n\tif (s <= 0) return {};\n\tint L = s > 1 ? 32 - __builtin_clz(s-1) : 0, n = 1 << L;\n\tif (sz(fa) < n) fa.resize(n);\n\tif (sz(fb) < n) fb.resize(n);\n\n\trep(i,0,sz(a)) fa[i] = num(a[i] & ((1<<15)-1), a[i] >> 15);\n\tfill(fa.begin()+sz(a), fa.begin() + n, 0);\n\trep(i,0,sz(b)) fb[i] = num(b[i] & ((1<<15)-1), b[i] >> 15);\n\tfill(fb.begin()+sz(b), fb.begin() + n, 0);\n\n\tfft(fa, n);\n\tfft(fb, n);\n\tdouble r0 = 0.5 / n; // 1/2n\n\trep(i,0,n/2+1) {\n\t\tint j = (n-i)&(n-1);\n\t\tnum g0 = (fb[i] + conj(fb[j])) * r0;\n\t\tnum g1 = (fb[i] - conj(fb[j])) * r0;\n\t\tswap(g1.x, g1.y); g1.y *= -1;\n\t\tif (j != i) {\n\t\t\tswap(fa[j], fa[i]);\n\t\t\tfb[j] = fa[j] * g1;\n\t\t\tfa[j] = fa[j] * g0;\n\t\t}\n\t\tfb[i] = fa[i] * conj(g1);\n\t\tfa[i] = fa[i] * conj(g0);\n\t}\n\tfft(fa, n);\n\tfft(fb, n);\n\tvector r(s);\n\trep(i,0,s) r[i] = int((ll(fa[i].x+0.5)\n\t\t\t\t+ (ll(fa[i].y+0.5) * (1 << 15))\n\t\t\t\t+ (ll(fb[i].x+0.5) * (1 << 15))\n\t\t\t\t+ (ll(fb[i].y+0.5) * (1 << 30))));\n\treturn r;\n} /// end-hash\n#endif\n\n} // namespace fft\n\nint main() {\n\tusing namespace std;\n\tios_base::sync_with_stdio(false), cin.tie(nullptr);\n\tarray N; int Q; cin >> N[0] >> N[1] >> Q;\n\tarray>, 2> A;\n\tfor (int z = 0; z < 2; z++) {\n\t\tA[z].resize(N[z]+2);\n\t\tfor (int i = 1; i <= N[z]; i++) {\n\t\t\tcin >> A[z][i].first; A[z][i].second = i;\n\t\t}\n\t}\n\tvector queries(Q); for (auto& q : queries) cin >> q;\n\n\tconst int X = int(1e5) + 100;\n\tvector ans(2 * X - 1);\n\n\tfor (int round = 0; round < 2; round++) {\n\t\tconst int INF = 1e9;\n\t\tarray, 2> mults;\n\t\tfor (int z = 0; z < 2; z++) {\n\t\t\tmults[z].assign(X, 0);\n\n\t\t\tA[z][0].first = A[z][N[z]+1].first = round ? INF : -INF;\n\t\t\tfor (int i = 1; i <= N[z]; i++) {\n\t\t\t\tif (A[z][i] < A[z][i-1] && A[z][i] < A[z][i+1]) {\n\t\t\t\t\tmults[z][A[z][i].first]--;\n\t\t\t\t} else if (A[z][i] > A[z][i-1] && A[z][i] > A[z][i+1]) {\n\t\t\t\t\tmults[z][A[z][i].first]++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tvector cur_res = fft::multiply(mults[0], mults[1]);\n\t\tfor (int i = 0; i < 2 * X - 1; i++) {\n\t\t\tlong long v = ((cur_res[i] > 0) - (cur_res[i] < 0)) * (long long)(abs(cur_res[i]) + 0.5);\n\t\t\tans[i] += v;\n\t\t}\n\t}\n\tfor (int i = 2 * X - 3; i >= 0; i--) {\n\t\tans[i] += ans[i+1];\n\t}\n\tlong long tot = ans[0];\n\tfor (auto& a : ans) a = (2 * a - tot) / 2;\n\tfor (int q : queries) {\n\t\tcout << ans[q] << '\\n';\n\t}\n\n\treturn 0;\n}\n\n// we can handle the 1good 2bad by wrapping in a white/back ring and adding the 2\n\n// Each cc can be uniquely identified by a max-row max-col cross such that neither can reach further\n//\n// Conjecture: the blockers match\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "14dfc0c637fb041fea617d36f0227a84", "src_uid": "25a6428f57022c12dfabdabbcc69c5a4", "difficulty": 3300.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n\nusing ld = long double;\nusing cd = std::complex;\nusing ll = long long;\n\nconst ld PI = 4*atan((ld)1);\nconst int MN = 1e5+10;\nconst int MV = 1 << 18;\ncd rou[MV];\n\ntemplate\nvoid fft(cd *a, int L)\n{\n\tfor(int i=0,j;i<1<>k&1) j|=1<(p, L);\n}\nvoid res()\n{\n\tmemset(p, 0, sizeof*p<=0;--i) f[i] += ctr += (ll)round(p[i].real()); ctr=0;\n\tres();\n\n\t//HOT\n\t//Q\n\tfor(int i=1;i=0;--i) f[i] += ctr += (ll)round(p[i].real()); ctr=0;\n\tres();\n\n\t//E, one direction\n\tfor(int i=1;i=0;--i) f[i] -= ctr += (ll)round(p[i].real()); ctr=0;\n\tres();\n\n\t//E, other direction\n\tfor(int i=0;i=0;--i) f[i] -= ctr += (ll)round(p[i].real()); ctr=0;\n\tres();\n\n\t//COLD\n\t//Q\n\tfor(int i=1;i\n#include \n#include \nusing namespace std;\ntypedef long long LL;\nconst int N = 600000+10;\nconst double PI = acos(-1);\nstruct Complex {\n double x, y;\n Complex(double x=0.0, double y=0.0) : x(x), y(y) {}\n Complex operator + (const Complex &b) const {\n return Complex(x+b.x, y+b.y);\n }\n Complex operator - (const Complex &b) const {\n return Complex(x-b.x, y-b.y);\n }\n Complex operator * (const Complex &b) const{\n return Complex(x * b.x - y * b.y, x * b.y + y * b.x);\n }\n} x1[N<<2], x2[N<<2];\nvoid change(Complex y[], int len) {\n for(int i=1,j=len/2;i=k) {\n j-=k; k/=2;\n }\n if(j\n#include \n#include \nusing namespace std;\ntypedef long long LL;\nconst int N = 600000+10;\nconst double PI = acos(-1);\nstruct Complex {\n double x, y;\n Complex(double x=0.0, double y=0.0) : x(x), y(y) {}\n Complex operator + (const Complex &b) const {\n return Complex(x+b.x, y+b.y);\n }\n Complex operator - (const Complex &b) const {\n return Complex(x-b.x, y-b.y);\n }\n Complex operator * (const Complex &b) const{\n return Complex(x * b.x - y * b.y, x * b.y + y * b.x);\n }\n} x1[N<<2], x2[N<<2];\nvoid change(Complex y[], int len) {\n for(int i=1,j=len/2;i=k) {\n j-=k; k/=2;\n }\n if(j\n\nusing namespace std;\n\nvector mem[5001];\n\nvector Fact(int x) {\n if (!mem[x].empty()) {\n return mem[x];\n }\n\n vector res;\n for (int i = 2; i * i <= x; ++i) {\n while (x % i == 0) {\n res.push_back(i);\n x /= i;\n }\n }\n if (x > 1) {\n res.push_back(x);\n }\n\n return mem[x] = res;\n}\n\nvector F(int x) {\n vector res;\n for (int i = 2; i <= x; ++i) {\n auto f = Fact(i);\n res.insert(res.end(), f.begin(), f.end());\n }\n sort(res.begin(), res.end());\n reverse(res.begin(), res.end());\n\n return res;\n}\n\nvector cnt(1);\nvector> nxt(1);\n\nint64_t ans = 0;\n\nvoid Add(const vector& data, int delta) {\n int v = 0;\n ans += 1LL * data.size() * delta;\n for (int x : data) {\n if (!nxt[v].count(x)) {\n nxt[v][x] = nxt.size();\n nxt.emplace_back();\n cnt.emplace_back();\n }\n v = nxt[v][x];\n cnt[v] += delta;\n }\n}\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n cout.tie(nullptr);\n \n int n;\n cin >> n;\n vector cnt(5001);\n for (int i = 0; i < n; ++i) {\n int k;\n cin >> k;\n ++cnt[k];\n }\n\n for (size_t i = 0; i < cnt.size(); ++i) {\n Add(F(i), cnt[i]);\n }\n\n int v = 0;\n for (bool flag = false; flag; flag = false) {\n for (auto x : nxt[v]) {\n if (cnt[x.second] > n - cnt[x.second]) {\n ans -= cnt[x.second];\n ans += n - cnt[x.second];\n v = x.second;\n flag = true;\n break;\n }\n }\n }\n\n cout << ans << endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "589cb4f733304b4418e05c0868cdc8e9", "src_uid": "40002052843ca0357dbd3158b16d59f4", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\nint n, k = 5000;\nint d[5050], cnt[5050]m id[5050];\nvector pr;\nint fac[5050][1010], s[5050][1010];\n\nvoid sieve(void) {\n for (int i = 2; i <= k; i++) {\n if (!d[i]) {\n id[i] = (int) pr.size();\n pr.push_back(i);\n for (int j = i; j <= k; j++) {\n if (!d[j]) d[j] = i;\n }\n }\n }\n for (int i = 1; i <= k; i++) {\n for (int j = 0; j < (int) pr.size(); j++) {\n fac[i][j] = fac[i - 1][j];\n }\n int tmp = i;\n while (tmp > 1) {\n int t = d[tmp];\n fac[i][id[t]]++;\n tmp /= t;\n }\n for (int j = 0; j < (int) pr.size(); j++) {\n s[i][j] = fac[i][j] + s[i][j - 1];\n }\n }\n}\n\nint f[1010];\n\nvoid solve(void) {\n long long ans = 0;\n int rem = 0;\n for (int i = 0; i < (int) pr.size(); i++) rem += f[i];\n vector cand(k, 0);\n iota(cand.begin(), cand.end(), 1);\n\n int l = 1, r = k;\n for (int i = (int) pr.size() - 1; i >= 0; i--) {\n rem -= f[i];\n while (l <= r && fac[l][i] < f[i]) {\n ans += 1ll * cnt[l] * (rem + (i ? s[l][i - 1] : 0) + abs(fac[l][i] - f[i]));\n l++;\n }\n while (r >= l && fac[r][i] > f[i]) {\n ans += 1ll * cnt[r] * (rem + (i ? s[r][i - 1] : 0) + abs(fac[r][i] - f[i]));\n r--;\n }\n }\n\n return ans;\n}\n\nint main() {\n ios::sync_with_stdio(0); cin.tie(0);\n\n cin >> n;\n int x;\n for (int i = 1; i <= n; i++) {\n cin >> x;\n if (x == 0) x = 1;\n cnt[x]++;\n }\n sieve();\n long long ans = 1e18;\n for (int i = 1; i <= k; i++) {\n for (int j = 0; j < (int) pr.size(); j++) f[j] = fac[i][j];\n ans = min(ans, solve());\n }\n for (int i = 1; i < k; i++) {\n int flg = 0;\n for (int j = (int) pr.size() - 1; j >= 0; j--) {\n if (flg) f[j] = 0;\n else if (fac[i][j] != fac[i + 1][j]) {\n flg = 1;\n f[j] = min(fac[i][j], fac[i + 1][j]);\n }\n else f[j] = fac[i][j];\n }\n ans = min(ans, solve());\n }\n\n cout << ans << '\\n';\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ae0573dfd3cf7e370d79d5ccf041a332", "src_uid": "40002052843ca0357dbd3158b16d59f4", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\ntypedef long long LL;\n\nconst int N=5000,M=1000;\n\nint n,cnt[N+9];\n\nvoid into(){\n scanf(\"%d\",&n);\n for (int i=1;i<=n;++i){\n\tint x;\n\tscanf(\"%d\",&x);\n\t++cnt[x?x:1];\n }\n}\n\nint b[N+9],pr[M+9],cp;\nint c[N+9][M+9];\n\nvoid Sieve(){\n for (int i=2;i<=N;++i){\n\tif (!b[i]) pr[++cp]=i,c[i][cp]=c[i][0]=1;\n\tfor (int j=1;j<=cp&&i*pr[j]<=N;++j){\n\t int t=i*pr[j];\n\t b[t]=1;\n\t c[t][0]=c[i][0]+1;\n\t for (int k=1;k<=cp;++k) c[t][k]=c[i][k];\n\t ++c[t][j];\n\t if (i%pr[j]==0) break;\n\t}\n }\n for (int i=1;i<=N;++i)\n\tfor (int j=0;j<=cp;++j) c[i][j]+=c[i-1][j];\n}\n\nint ht[M+9];\nint a[N+9],ca;\nint now[M+9];\n\nvoid Get_ht(){\n for (int i=1;i<=N;++i)\n\tif (cnt[i]) a[++ca]=i;\n for (int id=cp+1,ct=0;2333;){\n\tfor (int i=1;i<=cp;++i) now[i]=0;\n\tfor (int i=1;i<=ca;++i){\n\t int t=a[i];\n\t if (c[t][id]>ct) now[id]+=cnt[t];\n\t else\n\t for (int j=id-1;j>=1;--j)\n\t\t if (c[t][j]) {now[j]+=cnt[t];break;}\n\t}\n\tint p=0;\n\tfor (int i=1;i<=cp;++i)\n\t if (now[i]>n>>1) {p=i;break;}\n\tif (!p) break;\n for (int lst=0,i=1;i<=ca;++i){\n\t int t=a[i],tmp=0;\n\t if (c[t][id]>ct) tmp=id;\n\t else\n\t for (int j=id-1;j>=1;--j)\n\t\t if (c[t][j]) {tmp=j;break;}\n\t if (tmp==p) a[++lst]=t;\n\t}\n\tct=id==p?ct+1:1;\n\t++ht[id=p];++ht[0];\n\tca=lst;\n }\n}\n\nLL ans;\n\nvoid Get_ans(){\n for (int i=1;i<=N;++i){\n\tif (!cnt[i]) continue;\n\tint sum=ht[0]+c[i][0];\n\tfor (int j=cp;j>=1;--j)\n\t if (ht[j]^c[i][j]){\n\t\tans+=(LL)cnt[i]*(sum-2*min(ht[j],c[i][j]));\n\t\tbreak;\n\t }else sum-=ht[j]+c[i][j];\n }\n}\n\nvoid work(){\n Sieve();\n Get_ht();\n Get_ans();\n}\n\nvoid outo(){\n printf(\"%lld\\n\",ans);\n}\n\nint main(){\n into();\n work();\n outo();\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "439f9ac5c02387a6d94803de646f53c6", "src_uid": "40002052843ca0357dbd3158b16d59f4", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\n#define fi(a,b,c) for(int a=b;a<=c;a++)\n#define fo(a,b,c) for(int a=b;a>=c;a--)\n#define long long long\n#define pii pair\n#define mp make_pair\n\nconst int N = 10000;\n\nint n, m;\nlong ans;\nint biggest_prime[N], par[N];\nlong d[N], c[N], s[N];\npii biggest_prime_number[N];\nint counts_prime[N][700], counts_prime_[N][700];\nvector prime;\nvector node[N];\n\nvoid Find_Prime(){\n vector h;\n fi(i,0,5000) h.push_back(0);\n\n fi(i,2,5000){\n if (!h[i]){\n h[i] = i; prime.push_back(i);\n }\n\n int j = 0;\n while (j < prime.size() && prime[j] <= h[i] && prime[j]*i <= 5000){\n h[prime[j]*i] = prime[j]; j++;\n }\n }\n}\n\nvoid Init(){\n Find_Prime();\n\n fi(i,2,5000){\n int x = i;\n fi(j,0,prime.size()-1){\n counts_prime[i][j] = counts_prime[i-1][j];\n\n if (x%prime[j] == 0) biggest_prime_number[i] = mp(j,0);\n while (x%prime[j] == 0){\n counts_prime[i][j]++, x /= prime[j];\n biggest_prime_number[i].second++;\n }\n\n counts_prime_[i][j] = counts_prime_[i][j-1]+counts_prime[i][j];\n\n\n if (counts_prime[i][j] > 0) biggest_prime[i] = j;\n }\n }\n}\n\nvoid New_Edge(int x, int y, int cost){\n node[x].push_back(mp(y,cost));\n node[y].push_back(mp(x,cost));\n}\n\nvoid Solve_Pack(int l, int r){\n int tmp = 0;\n fi(i,l,r-1){\n int j = biggest_prime_number[i+1].first;\n int counts_dif = biggest_prime_number[i+1].second;\n\n m++;\n New_Edge(i,m,counts_prime_[i][j-1]);\n\n if (tmp > 0)\n New_Edge(m-1,m,tmp-counts_prime_[i][j-1]);\n else\n New_Edge(1,m,counts_prime_[i][biggest_prime[i]]-counts_prime_[i][j-1]);\n\n tmp = counts_prime_[i+1][j-1]+counts_dif;\n }\n\n New_Edge(m,r,tmp);\n}\n\nvoid Make_New_Path(){\n New_Edge(1,2,1);\n\n m = 5000;\n int l = 3, r = 2;\n fi(i,1,prime.size()-1){\n while (r+1 <= 5000 && biggest_prime[r+1] == i)\n r++;\n\n Solve_Pack(l,r);\n\n l = r+1;\n }\n}\n\nvoid Dfs(int x){\n fi(i,0,node[x].size()-1){\n int y = node[x][i].first;\n long z = node[x][i].second;\n if (y == par[x]) continue;\n\n par[y] = x; Dfs(y);\n\n s[x] += s[y] + c[y]*z; c[x] += c[y];\n }\n c[x] += d[x];\n}\n\nvoid Dfs_Solve(int x, long res){\n ans = min(ans, res);\n fi(i,0,node[x][i].size()-1){\n int y = node[x][i].first;\n long z = node[x][i].second;\n if (y == par[x]) continue;\n\n res += (n-c[y]-c[y])&z;\n Dfs(y);\n }\n}\n\nmain(){\n Init();\n Make_New_Path();\n\n cin >> n;\n fi(i,1,n){\n int x;\n cin >> x;\n if (x == 0) x = 1;\n\n d[x]++;\n }\n\n Dfs(1);\n ans = s[1];\n\n Dfs_Solve(1,d[1]);\n\n cout << ans;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3fd9dd5843eb9068353dbbeb780f89d2", "src_uid": "40002052843ca0357dbd3158b16d59f4", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include \n#define int long long\n#define db long double\n#define x first\n#define y second\n#define mp make_pair\n#define pb push_back\n#define all(a) a.begin(), a.end()\n\nusing namespace std;\n\nconst int K = 5007;\n\nint cnt[K], rcnt[K];\nint cl[K];\n\nint get(int l, int r){\n\tif (l > r) return 0;\n\treturn cnt[r] - cnt[l-1];\n}\n\nint pref[K];\n\nvector > min_remainder[K];\n\npair get_opt(pair a, pair b){\n\tif (a.first > b.first) return {a.first, max(a.second, b.first)};\n\treturn {b.first, max(b.second, a.first)};\n\nconst int INF = -1;\n\nmain(){\n#ifdef LOCAL\n\tfreopen(\"C_input.txt\", \"r\", stdin);\n\t//freopen(\"C_output.txt\", \"w\", stdout);\n#endif\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n\tint n;\n\tcin >> n;\n\tvector v(n);\n\tfor (int i=0;i> v[i];\n\tsort(v.begin(), v.end());\n\tint u = 0;\n\tfor (int i=0;i > min_here;\n\t\tvector starts;\n\t\tfor (int j=i; j < K; j += i){\n\t\t\tstarts.push_back(j);\n\t\t}\n\t\tstarts.push_back(K);\n\t\tfor (int j=starts.size()-2; j >= 0; j--){\n\t\t\tint nxt = starts[j+1];\n\t\t\tint el = starts[j];\n\t\t\tint A = cl[nxt-1];\n\t\t\tif (A < el) A = INF; \n\t\t\tint B = INF;\n\t\t\tif (A!=INF) {\n\t\t\t\tif (rcnt[A] > 1) B = A;\n\t\t\t\telse{\n\t\t\t\t\tB = cl[A-1];\n\t\t\t\t\tif (B < el) B = -1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (A!=INF) A = A%i;\n\t\t\tif (B!=INF) B = B%i;\n\t\t\t//if (i==2005) cout << A << \" \" << B << endl;\n\t\t\tif (!min_here.size()) min_here.push_back({A, B});\n\t\t\telse min_here.push_back(get_opt(min_here.back(), {A, B}));\n\t\t}\n\t\treverse(min_here.begin(), min_here.end());\n\t\tmin_remainder[i] = min_here;\n\t}\n\n\n\tfor (int i=1; i < K; ++i) cnt[i] += cnt[i-1];\n\tfor (int i=2; i < K; ++i){\n\t\tint ss = 0;\n\t\tfor (int j=i; j < K; j += i){\n\t\t\tint L = j, R = min(K-1, j+i-1);\n\t\t\tss += get(L, R) * (j/i);\n\t\t}\n\t\tpref[i] = ss;\n\t}\n\tint ans = 0;\n\tfor (int take=2; take < K; ++take){\n\t\tint tut = 0;\n\t\tint L = 1, R = K;\n\t\twhile (R-L>1){\n\t\t\tint M = (L+R)/2;\n\t\t\tint how = pref[M];\n\n\n\t\t\tint closest = ((take+M-1)/M)*M;\n\n\n\t\t\tif (2*take < K){\n\t\t\t\tint closest = ((2*take+M-1)/M)*M;\n\t\t\t\tint A;\n\t\t\t\tif (closest >= K){\n\t\t\t\t\tclosest = K-1;\n\t\t\t\t\tA = cl[closest-1];\n\t\t\t\t\tif (A < 2*take) A = INF;\n\n\t\t\t\t\tif (A < M) A = INF;\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tA = cl[closest-1];\n\t\t\t\t\tif (A < 2*take) A = INF;\n\n\t\t\t\t\tif (A < M) A = INF;\n\n\t\t\t\t\tif (A!=INF) A = A%M;\n\t\t\t\t\tpair Q = min_remainder[M][closest/M-1];\n\n\n\t\t\t\t\tA = max(Q.first, A);\n\t\t\t\t}\n\t\t\t\tif (A!=INF){\n\t\t\t\t\tint spend = max(0ll, (2*take-A+M-1)/M);\n\n\n\t\t\t\t\tint e = how-spend;\n\n\t\t\t\t\tif (e >= take) L = M;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tint A, B;\n\t\t\tpair Q;\n\n\t\t\tif (closest >= K){\n\t\t\t\tclosest = K-1;\n\t\t\t\tA = cl[closest-1];\n\t\t\t\tif (A < take) A = INF;\n\t\t\t\tB = INF;\n\t\t\t\tif (A!=INF){\n\t\t\t\t\tif (rcnt[A] > 1) B = A;\n\t\t\t\t\telse{\n\t\t\t\t\t\tB = cl[A-1];\n\t\t\t\t\t\tif (B < take) B = INF;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (A!=INF) A = A%M;\n\t\t\t\tif (B!=INF) B = B%M;\n\t\t\t\tQ={A, B};\n\t\t\t}\n\n\t\t\telse{\n\n\t\t\t\tA = cl[closest-1];\n\t\t\t\tif (A < take) A = INF;\n\t\t\t\tB = INF;\n\t\t\t\tif (A!=INF){\n\t\t\t\t\tif (rcnt[A] > 1) B = A;\n\t\t\t\t\telse{\n\t\t\t\t\t\tB = cl[A-1];\n\t\t\t\t\t\tif (B < take) B = INF;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\n\t\t\t\tif (A!=INF) A = A%M;\n\t\t\t\tif (B!=INF) B = B%M;\n\n\n\t\t\t\tQ = min_remainder[M][closest/M-1];\n\t\t\t\tQ = get_opt(Q, {A, B});\n\t\t\t}\n\n\t\t\t//if (take==2) cout << M << \" \" << A << \" \" << B << \" \" << Q.first << \" \" << Q.second << \" \" << how << endl;\n\n\t\t\tif (Q.second == INF){\n\t\t\t\tR = M;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tA = Q.first, B = Q.second;\n\n\t\t\tint spend = max(0LL, (take-A+M-1)/M) + max(0LL, (take-B+M-1)/M);\n\n\t\t\t//if (take==2) cout << spend << endl;\n\n\t\t\thow -= spend;\n\n\t\t\tif (how >= take) L = M;\n\t\t\telse R = M;\n\t\t}\n\t\tif (L > 1) ans = max(ans, L*take);\n\n\t}\n\tcout << ans;\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "cd4dabe9f77cc659607435bb40cb0f14", "src_uid": "bca20e0910e9fe4d89326b50ab45e4ca", "difficulty": 3200.0} {"lang": "GNU C++17", "source_code": "\tios_base::sync_with_stdio(0);\n\tcin.tie(NULL);\n\n\tcin>>n;\n\tmemset(pre,-1,sizeof(pre));\n\tmemset(s,0,sizeof(s));\n\tmemset(nxt,-1,sizeof(nxt));\n\tfor (int i = 0; i < n; i++) {\n\t\tint x; cin>>x;\n\t\ts[x]++;\n\t}\n\tfor (int i = N-2; i >= 0; i--)\n\t\tnxt[i] = s[i] ? i : nxt[i+1];\n\tfor (int i = 1; i < N; i++) {\n\t\tpre[i] = s[i] ? i : pre[i-1];\n\t\ts[i] += s[i-1];\n\t}\n\n\tlong long ans = 0;\n\tauto valid = [&](int x, int y) {\n\t\tif (x > 1 && y > 1)\n\t\t\tans = max(ans, 1LL*x*y);\n\t};\n\tfor (int y = 2; y < N/2; y++) {\n\t\tlong long cnt = 0;\n\t\tfor (int k = 1; 1LL*y*(k+1) < N; k++)\n\t\t\tcnt += 1LL * k * sum(y*k, y*(k+1)-1);\n\t\tint a = -1, b = -1;\n\t\tauto con = [&](int x) {\n\t\t\tx %= y;\n\t\t\tif (x > a) swap(a,x);\n\t\t\tif (x > b) swap(b,x);\n\t\t};\n\t\tif (cnt)\n\t\tfor (int k = N/2/y; k >= 0; k--) {\n\t\t\tint x = pre[y*(k+1)-1];\n\t\t\tif (x >= y*k) {\n\t\t\t\tcon(x);\n\t\t\t\tif (sum(x,x) == 1)\n\t\t\t\t\tx = pre[x-1];\n\t\t\t\tif (x >= y*k)\n\t\t\t\t\tcon(x);\n\t\t\t}\n\t\t\tif (2*(cnt-k) >= k*y && a>=0) {\n\t\t\t\tif (cnt - k >= (a+k*y)/2)\n\t\t\t\t\tvalid(y, (a+k*y)/2);\n\t\t\t\telse\n\t\t\t\t\tvalid(y, (cnt-k)/2);\n\t\t\t}\n\t\t\tif (cnt - 2*k >= k*y && b>=0) {\n\t\t\t\tif (cnt - 2*k >= b+k*y)\n\t\t\t\t\tvalid(y, b+k*y);\n\t\t\t\telse\n\t\t\t\t\tvalid(y, cnt-2*k);\n\t\t\t\t\t\n\t\t\t}\n\t\t\tif (a >= 0 && a+k*y >= 1 && sum(a+k*y, N-1) > 1) {\n\t\t\t\tif (cnt - 2*k - 1 >= a+k*y)\n\t\t\t\t\tvalid(y, a+k*y);\n\t\t\t\telse valid(y, cnt-2*k-1);\n\t\t\t}\n\n\t\t}\n\t}\n\tcout << ans << endl;\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "aeb4b1e37ad0cea5863e096c8f3496c0", "src_uid": "bca20e0910e9fe4d89326b50ab45e4ca", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#include\n\nusing namespace std;\ntemplate < typename T > inline T read()\n{\n\tT x = 0, f = 0;\n\tchar c = getchar();\n\twhile (!isdigit(c)) f = c == '-', c = getchar();\n\twhile (isdigit(c)) x = x * 10 + c - 48, c = getchar();\n\treturn f ? -x : x;\n}\nnamespace run\n{\n\ttypedef long long ll;\n\tconst int N = 500009,\n\t inf = 1e9;\n\tint mx, _mx;\n\tinline void upd(int x)\n\t{\n\t\tif (x > mx) _mx = mx, mx = x;\n\t\telse if (x > _mx) _mx = x;\n\t}\n\n\tint x, c, k, n, a[N], sum[N << 1], pre[N << 1], A;\n\tll ans, cnty;\n\tint main()\n\t{\n\t\tn = read < int > ();\n\t\tfor (int i = 1; i <= n; ++i)\n\t\t\t++sum[a[i] = read < int > ()], A = max(A, a[i]);\n\t\tpre[0] = -1;\n\t\tfor (int i = 1; i <= 2 * A; ++i)\n\t\t\tpre[i] = sum[i] ? i : pre[i - 1], sum[i] += sum[i - 1];\n\n\t\tfor (int i = 1; i <= A; ++i)\n\t\t{\n\t\t\tcnty = 0;\n\t\t\tfor (int j = A / i * i; j; j -= i) cnty += sum[A] - sum[j - 1];\n\t\t\tmx = -inf, _mx = -inf;\n\t\t\tfor (int j = A / i * i; j >= 0; j -= i)\n\t\t\t{\n\t\t\t\tx = pre[j + i - 1];\n\t\t\t\tif (x >= j)\n\t\t\t\t{\n\t\t\t\t\tc = sum[x] - sum[x - 1];\n\t\t\t\t\tupd(x % i);\n\t\t\t\t\tif (c > 1) upd(x % i);\n\t\t\t\t\telse if (pre[x - 1] >= j) upd(pre[x - 1] % i);\n\t\t\t\t}\n\n\t\t\t\tx = (j + mx) / 2;\n\t\t\t\tif (x > 1 && cnty - j / i > 1)\n\t\t\t\t\tans = max(ans, 1 ll * i * min(1 ll * x, cnty - j / i));\n\n\t\t\t\tif (mx >= 0 && _mx >= 0)\n\t\t\t\t{\n\t\t\t\t\tx = j + _mx;\n\t\t\t\t\tif (x > 1 && cnty - j / i * 2 > 1)\n\t\t\t\t\t\tans = max(ans, 1 ll * i * min(1 ll * x, cnty - j / i * 2));\n\t\t\t\t\tx = j + mx;\n\t\t\t\t\tif (x > 1 && cnty - j / i * 2 - 1 > 1 && sum[A] - sum[x - 1] >= 2)\n\t\t\t\t\t\tans = max(ans, 1 ll * i * min(1 ll * x, cnty - j / i * 2 - 1));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tprintf(\"%lld\", ans);\n\t\treturn 0;\n\t}\n}\nint main()\n{\n\tfreopen(\"math.in\", \"r\", stdin);\n\tfreopen(\"math.out\", \"w\", stdout);\n\treturn run::main();\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "23bff7b316ec605ac166b80b8b30b2a5", "src_uid": "bca20e0910e9fe4d89326b50ab45e4ca", "difficulty": 3200.0} {"lang": "GNU C++17", "source_code": "#ifndef _GLIBCXX_DEBUG\n#define NDEBUG\n#endif\n#include\n#include\n#include\n#include\n\nstruct node{\n\tint a,b; // a: max, b: second max\n\tnode():a(-1),b(-1){}\n\tnode(node l,node r){\n\t\tif(l.ab){\n\t\t\tauto [b_,a_]=std::minmax(a,x);\n\t\t\tb=b_;a=a_;\n\t\t}\n\t}\n};\n\n\nint main(){\n\tstd::ios::sync_with_stdio(0);std::cin.tie(0);\n\n\tint n;std::cin>>n;\n\tstd::vector a(n);for(int& ai:a)std::cin>>ai;\n\tstd::sort(begin(a),end(a));\n\tint const maxa=a.back();\n\n\tint const SMALL_THRES=700;\n\tstd::array,SMALL_THRES> t;\n\tfor(int y=2;y nseg(maxa+1); // nseg[y] = sum(ai/y for ai in a) for y>=2\n\t// right now adding x to [i] will affect all y <= i\n\tfor(int ai:a){\n\t\tint q=1,y=ai;\n\t\twhile(true){ // complexity: sqrt(ai)\n\t\t\t// NOTE can be optimized if there are multiple equal ai value\n\t\t\t// NOTE number of TKWEURS operation can be reduced\n\t\t\tint miny=ai/(q+1)+1;\n\t\t\tassert(ai/y==q && ai/miny==q);\n\t\t\tnseg[y]+=q;\n\t\t\tnseg[miny-1]-=q;\n\t\t\ty=miny-1;q=ai/y;\n\t\t\tif(y<=1)\n\t\t\t\tbreak;\n\t\t}\n\t}\n\tfor(auto i=nseg.size();--i;)\n\t\tnseg[i-1]+=nseg[i];\n\n\tauto const countge=[&](int min){\n\t\treturn end(a)-std::lower_bound(begin(a),end(a),min);\n\t};\n\n\tauto const countf_=[&](int min,int y,int minmod){\n\t\t// return min(2, number of ai values >= min, % y >= minmod)\n\t\tassert(minmod=2);\n\t\t\treturn (t[y][minmod].a>=min) + (t[y][minmod].b>=min);\n\t\t}else{\n\t\t\tint cnt=0;\n\t\t\tfor(int q=(maxa-1)/y+1;q>=0;--q){\n\t\t\t\tint minv=std::max(min,minmod+q*y);\n\t\t\t\tint maxv=(q+1)*y;\n\t\t\t\tif(minv>=maxv)\n\t\t\t\t\tbreak;\n\t\t\t\tcnt+=countge(minv)-countge(maxv);\n\t\t\t\tif(cnt>=2)\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\treturn std::min(2,cnt);\n\t\t}\n\t};\n\n\tauto const countf=[&](int min,int y,int minmod){\n\t\tauto ans=countf_(min,y,minmod);\n\t\tauto ans1=(int)std::count_if(begin(a),end(a),[&](int ai){return ai>=min&&ai%y>=minmod;});\n\t\tassert(ans==std::min(ans1,2));\n\t\treturn ans;\n\t};\n\n\tauto const check=[&](int x,int y){\n\t\tassert(x<=maxa&&y<=maxa);\n\t\tassert(x>=2&&y>=2);\n\n\t\tint nsy=nseg[y];\n\n\t\t// case 1: take 2*x from one segment\n\t\tif(countge(2*x)>=1){\n\t\t\tint nswhole=2*x/y,rem=2*x%y;\n\t\t\tif(nsy-nswhole>=x+1)\n\t\t\t\treturn true;\n\t\t\tif(nsy-nswhole>=x && nsy-nswhole>=x + std::max(0,1-countf(2*x,y,2*x%y)))\n\t\t\t\treturn true;\n\t\t}\n\n\t\t// case 2: take x from 2 segments\n\t\tif(countge(x)>=2){\n\t\t\tint nswhole=x/y*2,rem=x%y;\n\t\t\tif(nsy-nswhole>=x+2)\n\t\t\t\treturn true;\n\t\t\tif(nsy-nswhole>=x && nsy-nswhole>=x + std::max(0,2-countf(x,y,x%y)))\n\t\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t};\n\n\tint64_t ans=4;\n\tint x=2,y=maxa;\n\twhile(true){\n\t\tif(check(x,y)){\n\t\t\tans=std::max(ans,(int64_t)x*y);\n\t\t\t++x;\n\t\t\tif(x>maxa)break;\n\t\t}else{\n\t\t\t--y;\n\t\t\tif(y<=1)break;\n\t\t}\n\t}\n\tstd::cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n//#include \nusing namespace std;\n#define li long long int\n#define rep(i,to) for(li i=0;i<((li)(to));++i)\n#define pb push_back\n#define sz(v) ((li)(v).size())\n#define bit(n) (1ll<<(li)(n))\n#define all(vec) (vec).begin(),(vec).end()\n#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)\n#define MP make_pair\n#define F first\n#define S second\n\n\n#define MAX 55\nli cnt = 1;\nli ans[MAX][MAX][MAX];\nli n;\nli x, y, z;\n\nli dx[] = {0,1,0,0,-1,0};\nli dy[] = {0,0,-1,0,0,1};\nli dz[] = {-1,0,0,1,0,0};\n\nli tri(li n)\n{\n\treturn n * n * n;\n}\n\nvoid SET()\n{\n\tif(ans[x][y][z] != -1) return;\n\tans[x][y][z] = cnt++;\n}\n\npair > get(set > > s, li sx, li sy, li sz)\n{\n\tpair, pair > > best;\n\tbest = MP(MP(-1, -1), MP(-1, MP(-1, -1)));\n\teach(it, s){\n\t\tint sum = 0;\n\t\tsum += abs(x - it->F);\n\t\tsum += abs(y - it->S.F);\n\t\tsum += abs(z - it->S.S);\n\t\tif(sum != 1) continue;\n\t\tli d0 = max(abs(sx - it->F), max(abs(sy - it->S.F), abs(sz - it->S.S)));\n\t\tli d1 = abs(sx - it->F) + abs(sy - it->S.F) + abs(sz - it->S.S);\n\t\tbest = max(best, MP(MP(d0, d1), *it));\n\t}\n\treturn best.S;\n}\n\nvoid getNext(li &x, li &y, li &z, li dir)\n{\n\tx += dx[dir];\n\ty += dy[dir];\n\tz += dz[dir];\n}\n\nint main()\n{\n\tmemset(ans, -1, sizeof(ans));\n\tcin >> n;\n\tx = 0;\n\ty = n - 2;\n\tz = n - 2;\n\t\n\tif(n == 1){\n\t\tcout << 1 << endl;\n\t\treturn 0;\n\t}\n\t\n\tSET();\n\tfor(li t = 0; t < n - 2; t++){\n\t\tset > > s;\n\t\tif(t % 2){\n\t\t\n\t\t\tfor(int turn = 0; t <= x; x--, turn++){\n\t\t\t\tSET();\n\t\t\t\tif(turn % 2){\n\t\t\t\t\twhile(t <= --z) SET();\n\t\t\t\t\tz = t;\n\t\t\t\t\twhile(++y <= n - 2) SET();\n\t\t\t\t\ty = n - 2;\n\t\t\t\t}else{\n\t\t\t\t\twhile(t <= --y) SET();\n\t\t\t\t\ty = t;\n\t\t\t\t\twhile(++z <= n - 2) SET();\n\t\t\t\t\tz = n - 2;\n\t\t\t\t}\n\t\t\t}\n\t\t\tx++;\n\t\t\t\n\t\t\tfor(li yy = t + 1; yy < n - 1; yy++){\n\t\t\t\tfor(li zz = t + 1 ; zz < n - 1; zz++){\n\t\t\t\t\ts.insert(MP(x, MP(yy, zz)));\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}else{\n\n\t\t\tfor(int turn = 0; t <= z; z--, turn++){\n\t\t\t\tSET();\n\t\t\t\tif(turn % 2){\n\t\t\t\t\twhile(t <= --x) SET();\n\t\t\t\t\tx = t;\n\t\t\t\t\twhile(++y <= n - 2) SET();\n\t\t\t\t\ty = n - 2;\n\t\t\t\t}else{\n\t\t\t\t\twhile(t <= --y) SET();\n\t\t\t\t\ty = t;\n\t\t\t\t\twhile(++x <= n - 2) SET();\n\t\t\t\t\tx = n - 2;\n\t\t\t\t}\n\t\t\t}\n\t\t\tz++;\n\t\t\t\n\t\t\tfor(li xx = t + 1; xx < n - 1; xx++){\n\t\t\t\tfor(li yy = t + 1; yy < n - 1; yy++){\n\t\t\t\t\ts.insert(MP(xx, MP(yy, z)));\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\t\n\t\twhile(sz(s)){\n\t\t\tpair > p;\n\t\t\tif(t % 2 == 0) p = get(s, n - 1, n - 1, z);\n\t\t\telse p = get(s, x, n - 1, n - 1);\n\t\t\ts.erase(p);\n\t\t\tx = p.F;\n\t\t\ty = p.S.F;\n\t\t\tz = p.S.S;\n\t\t\tSET();\n\t\t}\n\n\t\tif(t % 2) x++;\n\t\telse z++;\n\t\tSET();\n\t\t\n\t}\n\t\n\tx++;\n\tSET();\n\ty++;\n\tSET();\n\tz++;\n\tSET();\n\ty--;\n\tSET();\n\tx--;\n\tSET();\n\ty++;\n\tSET();\n\t\n\tli dir = 0;\n\t\n\twhile(cnt <= tri(n)){\n\t\tli next_dir = (dir + 1) % 6;\n\t\t{\n\t\t\tgetNext(x, y, z, next_dir);\n\t\t\tif(0 <= x && x < n)\n\t\t\tif(0 <= y && y < n)\n\t\t\tif(0 <= z && z < n)\n\t\t\tif(x == n - 1 || y == n - 1 || z == n - 1)\n\t\t\tif(ans[x][y][z] == -1)\n\t\t\t\tdir = next_dir;\n\t\t\tgetNext(x, y, z, (next_dir + 3) % 6);\n\t\t}\n\t\tgetNext(x, y, z, dir);\n\t\tSET();\n\t}\n\t\n\trep(i, n){\n\t\trep(j, n){\n\t\t\trep(k, n) cout << ans[i][j][k] << \" \";\n\t\t\tcout << endl;\n\t\t}\n\t\tcout << endl;\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5a5c119dfbda3fd2c1526085261e17c4", "src_uid": "e652ba0901b39f0d01ac152babc06b88", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n//#include \nusing namespace std;\n#define li long long int\n#define rep(i,to) for(li i=0;i<((li)(to));++i)\n#define pb push_back\n#define sz(v) ((li)(v).size())\n#define bit(n) (1ll<<(li)(n))\n#define all(vec) (vec).begin(),(vec).end()\n#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)\n#define MP make_pair\n#define F first\n#define S second\n\n\n#define MAX 55\nli cnt = 1;\nli ans[MAX][MAX][MAX];\nli n;\nli x, y, z;\n\nli dx[] = {0,1,0,0,-1,0};\nli dy[] = {0,0,-1,0,0,1};\nli dz[] = {-1,0,0,1,0,0};\n\nli tri(li n)\n{\n\treturn n * n * n;\n}\n\nvoid SET()\n{\n\tif(ans[x][y][z] != -1) return;\n\tans[x][y][z] = cnt++;\n}\n\npair > get(set > > s, li sx, li sy, li sz)\n{\n\tpair, pair > > best;\n\tbest = MP(MP(-1, -1), MP(-1, MP(-1, -1)));\n\trep(dir, 6){\n\t\tli xx = x + dx[dir];\n\t\tli yy = y + dy[dir];\n\t\tli zz = z + dz[dir];\n\t\tif(s.find(MP(xx, MP(yy, zz))) == s.end()) continue;\n\t\tli d0 = max(abs(sx - xx), max(sy - yy, sz - zz));\n\t\tli d1 = abs(sx - xx) + abs(sy - yy) + abs(sz - zz);\n\t\tbest = max(best, MP(MP(d0, d1), MP(xx, MP(yy, zz))));\n\t}\n\treturn best.S;\n}\n\nvoid getNext(li &x, li &y, li &z, li dir)\n{\n\tx += dx[dir];\n\ty += dy[dir];\n\tz += dz[dir];\n}\n\nint main()\n{\n\tmemset(ans, -1, sizeof(ans));\n\tcin >> n;\n\tx = 0;\n\ty = n - 2;\n\tz = n - 2;\n\t\n\tif(n == 1){\n\t\tcout << 1 << endl;\n\t\treturn 0;\n\t}\n\t\n\tSET();\n\tfor(li t = 0; t < n - 2; t++){\n\t\tset > > s;\n\t\tif(t % 2){\n\t\t\n\t\t\tfor(int turn = 0; t <= x; x--, turn++){\n\t\t\t\tSET();\n\t\t\t\tif(turn % 2){\n\t\t\t\t\twhile(t <= --z) SET();\n\t\t\t\t\tz = t;\n\t\t\t\t\twhile(++y <= n - 2) SET();\n\t\t\t\t\ty = n - 2;\n\t\t\t\t}else{\n\t\t\t\t\twhile(t <= --y) SET();\n\t\t\t\t\ty = t;\n\t\t\t\t\twhile(++z <= n - 2) SET();\n\t\t\t\t\tz = n - 2;\n\t\t\t\t}\n\t\t\t}\n\t\t\tx++;\n\t\t\t\n\t\t\tfor(li yy = t + 1; yy < n - 1; yy++){\n\t\t\t\tfor(li zz = t + 1 ; zz < n - 1; zz++){\n\t\t\t\t\ts.insert(MP(x, MP(yy, zz)));\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}else{\n\n\t\t\tfor(int turn = 0; t <= z; z--, turn++){\n\t\t\t\tSET();\n\t\t\t\tif(turn % 2){\n\t\t\t\t\twhile(t <= --x) SET();\n\t\t\t\t\tx = t;\n\t\t\t\t\twhile(++y <= n - 2) SET();\n\t\t\t\t\ty = n - 2;\n\t\t\t\t}else{\n\t\t\t\t\twhile(t <= --y) SET();\n\t\t\t\t\ty = t;\n\t\t\t\t\twhile(++x <= n - 2) SET();\n\t\t\t\t\tx = n - 2;\n\t\t\t\t}\n\t\t\t}\n\t\t\tz++;\n\t\t\t\n\t\t\tfor(li xx = t + 1; xx < n - 1; xx++){\n\t\t\t\tfor(li yy = t + 1; yy < n - 1; yy++){\n\t\t\t\t\ts.insert(MP(xx, MP(yy, z)));\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\t\n\t\twhile(sz(s)){\n\t\t\tpair > p;\n\t\t\tif(t % 2 == 0) p = get(s, n - 1, n - 1, z);\n\t\t\telse p = get(s, x, n - 1, n - 1);\n\t\t\ts.erase(p);\n\t\t\tx = p.F;\n\t\t\ty = p.S.F;\n\t\t\tz = p.S.S;\n\t\t\tSET();\n\t\t}\n\n\t\tif(t % 2) x++;\n\t\telse z++;\n\t\tSET();\n\t\t\n\t}\n\t\n\tx++;\n\tSET();\n\ty++;\n\tSET();\n\tz++;\n\tSET();\n\ty--;\n\tSET();\n\tx--;\n\tSET();\n\ty++;\n\tSET();\n\t\n\tli dir = 0;\n\t\n\twhile(cnt <= tri(n)){\n\t\tli next_dir = (dir + 1) % 6;\n\t\t{\n\t\t\tgetNext(x, y, z, next_dir);\n\t\t\tif(0 <= x && x < n)\n\t\t\tif(0 <= y && y < n)\n\t\t\tif(0 <= z && z < n)\n\t\t\tif(x == n - 1 || y == n - 1 || z == n - 1)\n\t\t\tif(ans[x][y][z] == -1)\n\t\t\t\tdir = next_dir;\n\t\t\tgetNext(x, y, z, (next_dir + 3) % 6);\n\t\t}\n\t\tgetNext(x, y, z, dir);\n\t\tSET();\n\t}\n\t\n\trep(i, n){\n\t\trep(j, n){\n\t\t\trep(k, n) printf(\"%d \", (int)ans[i][j][k]);\n\t\t\tprintf(\"\\n\");\n\t\t}\n\t\tprintf(\"\\n\");\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "06abde1a40bb891c362a229b25481024", "src_uid": "e652ba0901b39f0d01ac152babc06b88", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n//#include \nusing namespace std;\n#define li long long int\n#define rep(i,to) for(li i=0;i<((li)(to));++i)\n#define pb push_back\n#define sz(v) ((li)(v).size())\n#define bit(n) (1ll<<(li)(n))\n#define all(vec) (vec).begin(),(vec).end()\n#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)\n#define MP make_pair\n#define F first\n#define S second\n\n\n#define MAX 55\nli cnt = 1;\nli ans[MAX][MAX][MAX];\nli n;\nli x, y, z;\n\nli dx[] = {0,1,0,0,-1,0};\nli dy[] = {0,0,-1,0,0,1};\nli dz[] = {-1,0,0,1,0,0};\n\nli tri(li n)\n{\n\treturn n * n * n;\n}\n\nvoid SET()\n{\n\tif(ans[x][y][z] != -1) return;\n\tans[x][y][z] = cnt++;\n}\n\npair > get(set > > s, li sx, li sy, li sz)\n{\n\tpair, pair > > best;\n\tbest = MP(MP(-1, -1), MP(-1, MP(-1, -1)));\n\trep(dir, 6){\n\t\tli xx = x + dx[dir];\n\t\tli yy = y + dy[dir];\n\t\tli zz = z + dz[dir];\n\t\tif(s.find(MP(xx, MP(yy, zz))) == s.end()) continue;\n\t\tli d0 = max(abs(sx - xx), max(sy - yy, sz - zz));\n\t\tli d1 = abs(sx - xx) + abs(sy - yy) + abs(sz - zz);\n\t\tbest = max(best, MP(MP(d0, d1), MP(xx, MP(yy, zz))));\n\t}\n\treturn best.S;\n}\n\nvoid getNext(li &x, li &y, li &z, li dir)\n{\n\tx += dx[dir];\n\ty += dy[dir];\n\tz += dz[dir];\n}\n\nint main()\n{\n\tmemset(ans, -1, sizeof(ans));\n\tcin >> n;\n\tx = 0;\n\ty = n - 2;\n\tz = n - 2;\n\t\n\tif(n == 1){\n\t\tcout << 1 << endl;\n\t\treturn 0;\n\t}\n\t\n\tSET();\n\tfor(li t = 0; t < n - 2; t++){\n\t\tset > > s;\n\t\tif(t % 2){\n\t\t\n\t\t\tfor(int turn = 0; t <= x; x--, turn++){\n\t\t\t\tSET();\n\t\t\t\tif(turn % 2){\n\t\t\t\t\twhile(t <= --z) SET();\n\t\t\t\t\tz = t;\n\t\t\t\t\twhile(++y <= n - 2) SET();\n\t\t\t\t\ty = n - 2;\n\t\t\t\t}else{\n\t\t\t\t\twhile(t <= --y) SET();\n\t\t\t\t\ty = t;\n\t\t\t\t\twhile(++z <= n - 2) SET();\n\t\t\t\t\tz = n - 2;\n\t\t\t\t}\n\t\t\t}\n\t\t\tx++;\n\t\t\t\n\t\t\tfor(li yy = t + 1; yy < n - 1; yy++){\n\t\t\t\tfor(li zz = t + 1 ; zz < n - 1; zz++){\n\t\t\t\t\ts.insert(MP(x, MP(yy, zz)));\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}else{\n\n\t\t\tfor(int turn = 0; t <= z; z--, turn++){\n\t\t\t\tSET();\n\t\t\t\tif(turn % 2){\n\t\t\t\t\twhile(t <= --x) SET();\n\t\t\t\t\tx = t;\n\t\t\t\t\twhile(++y <= n - 2) SET();\n\t\t\t\t\ty = n - 2;\n\t\t\t\t}else{\n\t\t\t\t\twhile(t <= --y) SET();\n\t\t\t\t\ty = t;\n\t\t\t\t\twhile(++x <= n - 2) SET();\n\t\t\t\t\tx = n - 2;\n\t\t\t\t}\n\t\t\t}\n\t\t\tz++;\n\t\t\t\n\t\t\tfor(li xx = t + 1; xx < n - 1; xx++){\n\t\t\t\tfor(li yy = t + 1; yy < n - 1; yy++){\n\t\t\t\t\ts.insert(MP(xx, MP(yy, z)));\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t}\n\t\t\t\n\t\twhile(sz(s)){\n\t\t\tpair > p;\n\t\t\tif(t % 2 == 0) p = get(s, n - 1, n - 1, z);\n\t\t\telse p = get(s, x, n - 1, n - 1);\n\t\t\ts.erase(p);\n\t\t\tx = p.F;\n\t\t\ty = p.S.F;\n\t\t\tz = p.S.S;\n\t\t\tSET();\n\t\t}\n\n\t\tif(t % 2) x++;\n\t\telse z++;\n\t\tSET();\n\t\t\n\t}\n\t\n\tx++;\n\tSET();\n\ty++;\n\tSET();\n\tz++;\n\tSET();\n\ty--;\n\tSET();\n\tx--;\n\tSET();\n\ty++;\n\tSET();\n\t\n\tli dir = 0;\n\t\n\twhile(cnt <= tri(n)){\n\t\tli next_dir = (dir + 1) % 6;\n\t\t{\n\t\t\tgetNext(x, y, z, next_dir);\n\t\t\tif(0 <= x && x < n)\n\t\t\tif(0 <= y && y < n)\n\t\t\tif(0 <= z && z < n)\n\t\t\tif(x == n - 1 || y == n - 1 || z == n - 1)\n\t\t\tif(ans[x][y][z] == -1)\n\t\t\t\tdir = next_dir;\n\t\t\tgetNext(x, y, z, (next_dir + 3) % 6);\n\t\t}\n\t\tgetNext(x, y, z, dir);\n\t\tSET();\n\t}\n\t\n\trep(i, n){\n\t\trep(j, n){\n\t\t\trep(k, n) cout << ans[i][j][k] << \" \";\n\t\t\tcout << endl;\n\t\t}\n\t\tcout << endl;\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "90013ed7221f0d1bc4f6d434c7df138a", "src_uid": "e652ba0901b39f0d01ac152babc06b88", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "#define LOCAL\n\n/** ` Micro Mezzo Macro Flation -- Overheated Economy ., **/\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define REP(i, n) for (int i=0;i=int(a);--i)\n#define REP_1(i, n) for (int i=1;i<=int(n);++i)\n#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)\n#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)\n#define REP_C(i, n) for (int n____=int(n),i=0;i=a____;--i)\n#define REP_N(i, n) for (i=0;i=int(a);--i)\n#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)\n#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)\n#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)\n#define REP_1_N(i, n) for (i=1;i<=int(n);++i)\n#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)\n#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)\n#define REP_C_N(i, n) for (n____=int(n),i=0;i=a____;--i)\n#define REP_1_C_N(i, n) for (n____=int(n),i=1;i<=n____;++i)\n#define FOR_1_C_N(i, a, b) for (b____=int(b),i=a;i<=b____;++i)\n#define DWN_1_C_N(i, b, a) for (a____=int(a),i=b;i>=a____;--i)\n\n#define ECH(it, A) for (typeof(A.begin()) it=A.begin(); it != A.end(); ++it)\n#define DO(n) while(n--)\n#define DO_C(n) int n____ = n; while(n____--)\n#define TO(i, a, b) int s_=a VI;\ntypedef vector VC;\ntypedef vector VS;\ntypedef vector VL;\ntypedef vector VD;\ntypedef set SI;\ntypedef set SS;\ntypedef set SL;\ntypedef set SD;\ntypedef map MII;\ntypedef map MSI;\ntypedef map MLI;\ntypedef map MDI;\ntypedef map MIB;\ntypedef map MSB;\ntypedef map MLB;\ntypedef map MDB;\ntypedef pair PII;\ntypedef pair PIB;\ntypedef vector VII;\ntypedef vector VVI;\ntypedef vector VVII;\ntypedef set SII;\ntypedef map MPIII;\ntypedef map MPIIB;\n\n/** I/O Accelerator **/\n\n/* ... :\" We are I/O Accelerator ... Use us at your own risk ;) ... \" .. */\n\ntemplate inline void RD(T &);\ntemplate inline void OT(const T &);\n\ninline int RD(){ int x; RD(x); return x;}\ntemplate inline T& _RD(T &x){ RD(x); return x;}\ninline void RC(char &c){scanf(\" %c\", &c);}\ninline void RS(char *s){scanf(\"%s\", s);}\n\ntemplate inline void RD(T0 &x0, T1 &x1){RD(x0), RD(x1);}\ntemplate inline void RD(T0 &x0, T1 &x1, T2 &x2){RD(x0), RD(x1), RD(x2);}\ntemplate inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3){RD(x0), RD(x1), RD(x2), RD(x3);}\ntemplate inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4);}\ntemplate inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5);}\ntemplate inline void RD(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){RD(x0), RD(x1), RD(x2), RD(x3), RD(x4), RD(x5), RD(x6);}\ntemplate inline void OT(T0 &x0, T1 &x1){OT(x0), OT(x1);}\ntemplate inline void OT(T0 &x0, T1 &x1, T2 &x2){OT(x0), OT(x1), OT(x2);}\ntemplate inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3){OT(x0), OT(x1), OT(x2), OT(x3);}\ntemplate inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4);}\ntemplate inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5);}\ntemplate inline void OT(T0 &x0, T1 &x1, T2 &x2, T3 &x3, T4 &x4, T5 &x5, T6 &x6){OT(x0), OT(x1), OT(x2), OT(x3), OT(x4), OT(x5), OT(x6);}\n\ntemplate inline void RST(T &A){memset(A, 0, sizeof(A));}\ntemplate inline void RST(T0 &A0, T1 &A1){RST(A0), RST(A1);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2){RST(A0), RST(A1), RST(A2);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3){RST(A0), RST(A1), RST(A2), RST(A3);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5);}\ntemplate inline void RST(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){RST(A0), RST(A1), RST(A2), RST(A3), RST(A4), RST(A5), RST(A6);}\n\ntemplate inline void RST(bitset &S){\n S.reset();\n}\n\ntemplate inline void CLR(priority_queue, less > &Q){\n while (!Q.empty()) Q.pop();\n}\n\ntemplate inline void CLR(priority_queue, greater > &Q){\n while (!Q.empty()) Q.pop();\n}\n\ntemplate inline void CLR(T &A){A.clear();}\ntemplate inline void CLR(T0 &A0, T1 &A1){CLR(A0), CLR(A1);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2){CLR(A0), CLR(A1), CLR(A2);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3){CLR(A0), CLR(A1), CLR(A2), CLR(A3);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5);}\ntemplate inline void CLR(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){CLR(A0), CLR(A1), CLR(A2), CLR(A3), CLR(A4), CLR(A5), CLR(A6);}\ntemplate inline void CLR(T &A, int n){REP(i, n) CLR(A[i]);}\ntemplate inline void FLC(T &A, int x){memset(A, x, sizeof(A));}\ntemplate inline void FLC(T0 &A0, T1 &A1, int x){FLC(A0, x), FLC(A1, x);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2){FLC(A0), FLC(A1), FLC(A2);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3){FLC(A0), FLC(A1), FLC(A2), FLC(A3);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5);}\ntemplate inline void FLC(T0 &A0, T1 &A1, T2 &A2, T3 &A3, T4 &A4, T5 &A5, T6 &A6){FLC(A0), FLC(A1), FLC(A2), FLC(A3), FLC(A4), FLC(A5), FLC(A6);}\n\ntemplate inline void SRT(T &A){sort(ALL(A));}\ntemplate inline void SRT(T &A, C B){sort(ALL(A), B);}\n\n/** Add - On **/\n\nconst int MOD = 1000000007;\nconst int INF = 0x3f3f3f3f;\nconst DB EPS = 1e-9;\nconst DB OO = 1e15;\nconst DB PI = 3.14159265358979323846264; //M_PI;\n\n// <<= ` 0. Daily Use .,\n\ntemplate inline void checkMin(T &a,const T b){if (b inline void checkMax(T &a,const T b){if (b>a) a=b;}\ntemplate inline void checkMin(T& a, const T b, C c){if (c(b,a)) a = b;}\ntemplate inline void checkMax(T& a, const T b, C c){if (c(a,b)) a = b;}\ntemplate inline T min(T a, T b, T c){return min(min(a, b), c);}\ntemplate inline T max(T a, T b, T c){return max(max(a, b), c);}\ntemplate inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}\ntemplate inline T max(T a, T b, T c, T d){return max(min(a, b), max(c, d));}\ntemplate inline T sqr(T a){return a*a;}\ntemplate inline T cub(T a){return a*a*a;}\nint Ceil(int x, int y){return (x - 1) / y + 1;}\n\n// <<= ` 1. Bitwise Operation .,\ninline bool _1(int x, int i){return x & 1< inline T low_bit(T x) {\n return x & -x;\n}\n\ntemplate inline T high_bit(T x) {\n T p = low_bit(x);\n while (p != x) x -= p, p = low_bit(x);\n return p;\n}\n\ninline int count_bits(int x){\n x = (x & 0x55555555) + ((x & 0xaaaaaaaa) >> 1);\n x = (x & 0x33333333) + ((x & 0xcccccccc) >> 2);\n x = (x & 0x0f0f0f0f) + ((x & 0xf0f0f0f0) >> 4);\n x = (x & 0x00ff00ff) + ((x & 0xff00ff00) >> 8);\n x = (x & 0x0000ffff) + ((x & 0xffff0000) >> 16);\n return x;\n}\n\ninline int count_bits(LL x){\n x = (x & 0x5555555555555555LL) + ((x & 0xaaaaaaaaaaaaaaaaLL) >> 1);\n x = (x & 0x3333333333333333LL) + ((x & 0xccccccccccccccccLL) >> 2);\n x = (x & 0x0f0f0f0f0f0f0f0fLL) + ((x & 0xf0f0f0f0f0f0f0f0LL) >> 4);\n x = (x & 0x00ff00ff00ff00ffLL) + ((x & 0xff00ff00ff00ff00LL) >> 8);\n x = (x & 0x0000ffff0000ffffLL) + ((x & 0xffff0000ffff0000LL) >> 16);\n x = (x & 0x00000000ffffffffLL) + ((x & 0xffffffff00000000LL) >> 32);\n return x;\n}\n\nint reverse_bits(int x){\n x = ((x >> 1) & 0x55555555) | ((x << 1) & 0xaaaaaaaa);\n x = ((x >> 2) & 0x33333333) | ((x << 2) & 0xcccccccc);\n x = ((x >> 4) & 0x0f0f0f0f) | ((x << 4) & 0xf0f0f0f0);\n x = ((x >> 8) & 0x00ff00ff) | ((x << 8) & 0xff00ff00);\n x = ((x >>16) & 0x0000ffff) | ((x <<16) & 0xffff0000);\n return x;\n}\n\nLL reverse_bits(LL x){\n x = ((x >> 1) & 0x5555555555555555LL) | ((x << 1) & 0xaaaaaaaaaaaaaaaaLL);\n x = ((x >> 2) & 0x3333333333333333LL) | ((x << 2) & 0xccccccccccccccccLL);\n x = ((x >> 4) & 0x0f0f0f0f0f0f0f0fLL) | ((x << 4) & 0xf0f0f0f0f0f0f0f0LL);\n x = ((x >> 8) & 0x00ff00ff00ff00ffLL) | ((x << 8) & 0xff00ff00ff00ff00LL);\n x = ((x >>16) & 0x0000ffff0000ffffLL) | ((x <<16) & 0xffff0000ffff0000LL);\n x = ((x >>32) & 0x00000000ffffffffLL) | ((x <<32) & 0xffffffff00000000LL);\n return x;\n}\n\n// <<= ` 2. Modular Arithmetic Basic .,\n\ninline void INC(int &a, int b){a += b; if (a >= MOD) a -= MOD;}\ninline int sum(int a, int b){a += b; if (a >= MOD) a -= MOD; return a;}\ninline void DEC(int &a, int b){a -= b; if (a < 0) a += MOD;}\ninline int dff(int a, int b){a -= b; if (a < 0) a += MOD; return a;}\ninline void MUL(int &a, int b){a = (LL)a * b % MOD;}\ninline int pdt(int a, int b){return (LL)a * b % MOD;}\ninline int pdt(int a, int b, int c){return pdt(pdt(a, b), c);}\n\ninline int pow(int a, int b){\n int c = 1;\n while (b) {\n if (b&1) MUL(c, a);\n MUL(a, a), b >>= 1;\n }\n return c;\n}\n\ntemplate\ninline int pow(T a, int b){\n T c(1);\n while (b) {\n if (b&1) MUL(c, a);\n MUL(a, a), b >>= 1;\n }\n return c;\n}\n\ninline int _I(int b){\n int a = MOD, x1 = 0, x2 = 1, q;\n while (true){\n q = a / b, a %= b;\n if (!a) return (x2 + MOD) % MOD;\n DEC(x1, pdt(q, x2));\n\n q = b / a, b %= a;\n if (!b) return (x1 + MOD) % MOD;\n DEC(x2, pdt(q, x1));\n }\n}\n\ninline void DIV(int &a, int b){MUL(a, _I(b));}\ninline int qtt(int a, int b){return pdt(a, _I(b));}\n\ninline int sum(int a, int b, int MOD){\n a += b; if (a >= MOD) a -= MOD;\n return a;\n}\n\ninline int phi(int n){\n int res = n;\n for (int i=2;sqr(i)<=n;++i) if (!(n%i)){\n DEC(res, qtt(res, i));\n do{n /= i;} while(!(n%i));\n }\n if (n != 1)\n DEC(res, qtt(res, n));\n return res;\n}\n\n// <<= '9. Comutational Geometry .,\n\nstruct Po; struct Line; struct Seg;\n\ninline int sgn(DB x){return x < -EPS ? -1 : x > EPS;}\ninline int sgn(DB x, DB y){return sgn(x - y);}\n\nstruct Po{\n DB x, y;\n Po(DB _x = 0, DB _y = 0):x(_x), y(_y){}\n\n friend istream& operator >>(istream& in, Po &p){return in >> p.x >> p.y;}\n friend ostream& operator <<(ostream& out, Po p){return out << \"(\" << p.x << \", \" << p.y << \")\";}\n\n friend bool operator ==(Po, Po);\n friend bool operator !=(Po, Po);\n friend Po operator +(Po, Po);\n friend Po operator -(Po, Po);\n friend Po operator *(Po, DB);\n friend Po operator /(Po, DB);\n\n bool operator < (const Po &rhs) const{return sgn(x, rhs.x) < 0 || sgn(x, rhs.x) == 0 && sgn(y, rhs.y) < 0;}\n Po operator-() const{return Po(-x, -y);}\n Po& operator +=(Po rhs){x += rhs.x, y += rhs.y; return *this;}\n Po& operator -=(Po rhs){x -= rhs.x, y -= rhs.y; return *this;}\n Po& operator *=(DB k){x *= k, y *= k; return *this;}\n Po& operator /=(DB k){x /= k, y /= k; return *this;}\n\n DB length_sqr(){return sqr(x) + sqr(y);}\n DB length(){return sqrt(length_sqr());}\n\n DB atan(){\n return atan2(y, x);\n }\n\n void input(){\n scanf(\"%lf %lf\", &x, &y);\n }\n};\n\nbool operator ==(Po a, Po b){return sgn(a.x - b.x) == 0 && sgn(a.y - b.y) == 0;}\nbool operator !=(Po a, Po b){return sgn(a.x - b.x) != 0 || sgn(a.y - b.y) != 0;}\nPo operator +(Po a, Po b){return Po(a.x + b.x, a.y + b.y);}\nPo operator -(Po a, Po b){return Po(a.x - b.x, a.y - b.y);}\nPo operator *(Po a, DB k){return Po(a.x * k, a.y * k);}\nPo operator *(DB k, Po a){return a * k;}\nPo operator /(Po a, DB k){return Po(a.x / k, a.y / k);}\n\nstruct Line{\n Po a, b;\n Line(Po _a = Po(), Po _b = Po()):a(_a), b(_b){}\n Line(DB x0, DB y0, DB x1, DB y1):a(Po(x0, y0)), b(Po(x1, y1)){}\n Line(Seg);\n\n friend ostream& operator <<(ostream& out, Line p){return out << p.a << \"-\" << p.b;}\n};\n\nstruct Seg{\n Po a, b;\n Seg(Po _a = Po(), Po _b = Po()):a(_a), b(_b){}\n Seg(DB x0, DB y0, DB x1, DB y1):a(Po(x0, y0)), b(Po(x1, y1)){}\n Seg(Line l);\n\n friend ostream& operator <<(ostream& out, Seg p){return out << p.a << \"-\" << p.b;}\n DB length(){return (b - a).length();}\n};\n\nLine::Line(Seg l):a(l.a), b(l.b){}\nSeg::Seg(Line l):a(l.a), b(l.b){}\n\n#define innerProduct dot\n#define scalarProduct dot\n#define dotProduct dot\n#define outerProduct det\n#define crossProduct det\n\ninline DB dot(DB x1, DB y1, DB x2, DB y2){return x1 * x2 + y1 * y2;}\ninline DB dot(Po a, Po b){return dot(a.x, a.y, b.x, b.y);}\ninline DB dot(Po p0, Po p1, Po p2){return dot(p1 - p0, p2 - p0);}\ninline DB dot(Line l1, Line l2){return dot(l1.b - l1.a, l2.b - l2.a);}\ninline DB det(DB x1, DB y1, DB x2, DB y2){return x1 * y2 - x2 * y1;}\ninline DB det(Po a, Po b){return det(a.x, a.y, b.x, b.y);}\ninline DB det(Po p0, Po p1, Po p2){return det(p1 - p0, p2 - p0);}\ninline DB det(Line l1, Line l2){return det(l1.b - l1.a, l2.b - l2.a);}\n\ntemplate inline DB dist(T1 x, T2 y){return sqrt(dist_sqr(x, y));}\n\ninline DB dist_sqr(Po a, Po b){return sqr(a.x - b.x) + sqr(a.y - b.y);}\ninline DB dist_sqr(Po p, Line l){Po v0 = l.b - l.a, v1 = p - l.a; return sqr(fabs(det(v0, v1))) / v0.length_sqr();}\ninline DB dist_sqr(Po p, Seg l){\n Po v0 = l.b - l.a, v1 = p - l.a, v2 = p - l.b;\n if (sgn(dot(v0, v1)) * sgn(dot(v0, v2)) <= 0) return dist_sqr(p, Line(l));\n else return min(v1.length_sqr(), v2.length_sqr());\n}\n\ninline DB dist_sqr(Line l, Po p){return dist_sqr(p, l);}\ninline DB dist_sqr(Seg l, Po p){return dist_sqr(p, l);}\n\ninline DB dist_sqr(Line l1, Line l2){\n if (sgn(det(l1, l2)) != 0) return 0;\n return dist_sqr(l1.a, l2);\n}\ninline DB dist_sqr(Line l1, Seg l2){\n Po v0 = l1.b - l1.a, v1 = l2.a - l1.a, v2 = l2.b - l1.a; DB c1 = det(v0, v1), c2 = det(v0, v2);\n return sgn(c1) != sgn(c2) ? 0 : sqr(min(fabs(c1), fabs(c2))) / v0.length_sqr();\n}\n\nbool isIntersect(Seg l1, Seg l2){\n\n //if (l1.a == l2.a || l1.a == l2.b || l1.b == l2.a || l1.b == l2.b) return true;\n\n return\n min(l1.a.x, l1.b.x) <= max(l2.a.x, l2.b.x) &&\n min(l2.a.x, l2.b.x) <= max(l1.a.x, l1.b.x) &&\n min(l1.a.y, l1.b.y) <= max(l2.a.y, l2.b.y) &&\n min(l2.a.y, l2.b.y) <= max(l1.a.y, l1.b.y) &&\n sgn( det(l1.a, l2.a, l2.b) ) * sgn( det(l1.b, l2.a, l2.b) ) <= 0 &&\n sgn( det(l2.a, l1.a, l1.b) ) * sgn( det(l2.b, l1.a, l1.b) ) <= 0;\n\n}\n\ninline DB dist_sqr(Seg l1, Seg l2){\n if (isIntersect(l1, l2)) return 0;\n else return min(dist_sqr(l1.a, l2), dist_sqr(l1.b, l2), dist_sqr(l2.a, l1), dist_sqr(l2.b, l1));\n}\n\ninline bool isOnExtremePoint(const Po &p, const Seg &l){\n return p == l.a || p == l.b;\n}\n\ninline bool isOnseg(const Po &p, const Seg &l){\n\n //if (p == l.a || p == l.b) return false;\n\n return sgn(det(p, l.a, l.b)) == 0 &&\n sgn(l.a.x, p.x) * sgn(l.b.x, p.x) <= 0 && sgn(l.a.y, p.y) * sgn(l.b.y, p.y) <= 0;\n}\n\ninline Po intersect(const Line &l1, const Line &l2){\n return l1.a + (l1.b - l1.a) * (det(l2.a, l1.a, l2.b) / det(l2, l1));\n}\n\n// perpendicular foot\ninline Po intersect(const Po & p, const Line &l){\n return intersect(Line(p, p + Po(l.a.y - l.b.y, l.b.x - l.a.x)), l);\n}\n\ninline Po rotate(Po p, DB alpha, Po o = Po()){\n p.x -= o.x, p.y -= o .y;\n return Po(p.x * cos(alpha) - p.y * sin(alpha), p.y * cos(alpha) + p.x * sin(alpha)) + o;\n}\n\n// <<= ' A. Random Event ..\n\ninline int rand32(){return (bool(rand() & 1) << 30) | (rand() << 15) + rand();}\ninline int random32(int l, int r){return rand32() % (r - l + 1) + l;}\ninline int random(int l, int r){return rand() % (r - l + 1) + l;}\nint dice(){return rand() % 6;}\nbool coin(){return rand() % 2;}\n\n// <<= ' 0. I/O Accelerator interface .,\n\ntemplate inline void RD(T &x){\n //cin >> x;\n scanf(\"%d\", &x);\n //char c; for (c = getchar(); c < '0'; c = getchar()); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';\n //char c; c = getchar(); x = c - '0'; for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';\n}\n\ntemplate inline void OT(const T &p){\n printf(\"%.0lf\\n\", p);\n}\n\n/* .................................................................................................................................. */\n\nconst int N = 109;\nint A[N][N][N], ox, oy, oz;\nint n, p, q;\n\nvoid watchFront(){\n n += 2; REP(i, n){\n REP(j, n) printf(\"%d \", A[ox + i][oy][oz + j] - q);\n puts(\"\");\n }\n}\n\nvoid gao(){\n\n ox = n, oy = n, q = 0;\n\n A[ox + 0][oy + 0][oz + 0] = 1, A[ox + 0][oy + 0][oz + 1] = 4;\n A[ox + 0][oy + 1][oz + 0] = 2, A[ox + 0][oy + 1][oz + 1] = 3;\n\n A[ox + 1][oy + 0][oz + 0] = 6, A[ox + 1][oy + 0][oz + 1] = 5;\n A[ox + 1][oy + 1][oz + 0] = 7, A[ox + 1][oy + 1][oz + 1] = 8;\n\n if (n == 2) return;\n\n A[ox + 2][oy + 0][oz + 0] = 11, A[ox + 2][oy + 0][oz + 1] = 12;\n A[ox + 2][oy + 1][oz + 0] = 10, A[ox + 2][oy + 1][oz + 1] = 9;\n\n p = 13;\n\n int x, y, z; bool rev = false;\n\n#define Blue (rev ? q-- : p++)\n#define Red (rev ? p++ : q--)\n\n FOR_1(cur, 3, n){\n\n if (cur & 1){\n\n --oy; REP(i, cur-1) A[ox][oy][oz + i] = Red;\n\n DWN(i, cur-1, 0){\n if (i&1) DWN_1(j, cur-1, 1) A[ox + j][oy][oz + i] = Blue;\n else REP_1(j, cur-1) A[ox + j][oy][oz + i] = Blue;\n }\n\n x = 0, y = 0, z = cur - 1;\n A[ox + x][oy + y][oz + z] = Red;\n\n REP_1(i, cur - 1){\n if (i&1){\n ++x; --y; REP(j, i+1) A[ox + x][oy + ++y][oz + z] = Red;\n REP(j, i) A[ox + --x][oy + y][oz + z] = Red;\n }\n else {\n ++y; --x; REP(j, i+1) A[ox + ++x][oy + y][oz + z] = Red;\n REP(j, i) A[ox + x][oy + --y][oz + z] = Red;\n }\n }\n\n --oz;\n x = cur - 1, y = 0, z = 0;\n A[ox + x][oy + y][oz + z] = Blue;\n\n REP_1(i, cur - 1){\n if (i&1){\n --x; --y; REP(j, i+1) A[ox + x][oy + ++y][oz + z] = Blue;\n REP(j, i) A[ox + ++x][oy + y][oz + z] = Blue;\n }\n else {\n ++y; ++x; REP(j, i+1) A[ox + --x][oy + y][oz + z] = Blue;\n REP(j, i) A[ox + x][oy + --y][oz + z] = Blue;\n }\n }\n }\n else{\n\n --oy; REP(i, cur) A[ox][oy][oz + i] = Red;\n\n DWN(i, cur, 0){\n if (i&1) DWN_1(j, cur-2, 1) A[ox + j][oy][oz + i] = Blue;\n else REP_1(j, cur-2) A[ox + j][oy][oz + i] = Blue;\n }\n\n x = cur - 1, y = 0, z = 0;\n A[ox + x][oy + y][oz + z] = Blue;\n\n REP_1(i, cur - 1){\n if (i&1){\n --z; ++y; REP(j, i+1) A[ox + x][oy + y][oz + ++z] = Blue;\n REP(j, i) A[ox + x][oy + --y][oz + z] = Blue;\n }\n else {\n ++z; --y; REP(j, i+1) A[ox + x][oy + ++y][oz + z] = Blue;\n REP(j, i) A[ox + x][oy + y][oz + --z] = Blue;\n }\n }\n\n --ox, x = 0, y = 0, z = cur - 1;\n A[ox + x][oy + y][oz + z] = Red;\n\n REP_1(i, cur - 1){\n if (i&1){\n ++y; ++z; REP(j, i+1) A[ox + x][oy + y][oz + --z] = Red;\n REP(j, i) A[ox + x][oy + --y][oz + z] = Red;\n }\n else {\n --z; --y; REP(j, i+1) A[ox + x][oy + ++y][oz + z] = Red;\n REP(j, i) A[ox + x][oy + y][oz + ++z] = Red;\n }\n }\n\n rev = !rev;\n }\n\n rev = !rev;\n }\n}\n\nvoid print(){\n\n if (n % 4 == 3) ++oz; else if (n % 4 == 0) ++ox;\n\n REP(x, n){\n REP(y, n){\n REP(z, n) printf(\"%d \", A[ox + x][oy + y][oz + z] - q);\n puts(\"\");\n }\n puts(\"\");\n }\n}\n\nint main(){\n\n#ifndef ONLINE_JUDGE\n //freopen(\"in.txt\", \"r\", stdin);\n#endif\n\n while (scanf(\"%d\", &n) != EOF && n){\n if (n == 1) puts(\"1\");\n else gao(), print();\n }\n}\n\n\n\ufffd\ufffd\u04bb\ufffd\ufffd n \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u58ec\u04aa\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u02b5\ufffd\u00b7\ufffd\ufffd\ufffd\ufffd\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd k < n, \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd 2 \ufffd\ufffd k \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd, \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0435\ufffd\ufffd\ufffd\ufffd\ufffd\u0221\ufffd\ufffd\u04bb\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u4863\n\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u03aa\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u02fc\u03ac\ufffd\ufffd\ufffd\u04f6\ufffd\ufffd\ufffd\u07f5\ufffd\u04bb\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\uf863\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u023b\ufffd\ufffd\u013f\u04bb\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u05e1\ufffd\ufffd\ufffd\ufffd\ufffd\n\n\ufffd\ufffd\ufffd\u0236\u053d\ufffd\ufffd\ufffd\u04bb\ufffd\ufffd\ufffd\u0132\u00b2\u28fa\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u057d\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0121\ufffd\ufffd\ufffd(\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u04b2\u04aa\ufffd\u01f5\u0779\ufffd\u0121\ufffd\ufffd\u0533\u01b5\ufffd\ufffd\ufffd\ufffd\ufffd)\ufffd\ufffd\ufffd\ufffd\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u04aa\ufffd\ufffd\u017c\ufffd\ufffd\ufffd\u06e1\ufffd(\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u04f5\ufffd\ufffd\ufffd\ufffd\u06e1\ufffd\ufffd\ufffd\ufffd\ufffd\u05ae\ufffd\u023d\ufffd\ufffd\ufffd\ufffd\ufffd\u0139\ufffd\ufffd\ucdfd\ufffd\ufffd\ufffd\ufffd\ufffd\u053e\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u06e1\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u01f0\ufffd\ufffd\u036c\ufffd\u0132\ufffd\ufffd\u05b1\u023d\u03f6\u0863)\ufffd\ufffd\ufffd\ufffd\n\n\ufffd\ufffd\u017e\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u04bb\ufffd\ufffd\ufffd\ufffd\ufffd\uda46\udce1\ufffd\ufffd\ufffd\u04aa\ufffd\ufffd\ufffd\u06f5\u0135\u0637\ufffd\u053d\ufffd\u0863\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u057d\u2cbb\ufffd\u01f6\u0533\u01b5\u013b\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0476\u023e\u037b\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u04e1\ufffd\ufffd\ufffd\ufffd\ufffd\n\n\ufffd\u023d\u03ff\ufffd\u0467\ufffd\u0137\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u01f9\ufffd\ufffd\u0276\ufffd\u03ac\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u07fa\ufffd\ufffd\ufffd\ufffd\u07e1\ufffd\ufffd\u05b1\ufffd\u03aa\ufffd\ufffd\ufffd\ufffd\ufffd\uedaf\ufffd\u02f5\u3863\ufffd\ufffd\u04bb\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u04bb\ufffd\ufffd\ufffd\u077c\ufffd\ufffd\ufffd\ufffd\ufffd\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u01f0\ufffd\ufffd\u0421\ufffd\u06b5\ufffd\ufffd\ufffd k \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u047e\ufffd\u022b\ufffd\ufffd\ufffd\ufffd\ufffd\u38ec\ufffd\ufffd\ufffd\u06b5\u00f5\ufffd\u04bb\ufffd\ufffd k*(k+1) \ufffd\u013e\ufffd\ufffd\u03a3\ufffd\ufffd\ufffd\ufffd\u04bb\uedaf\ufffd\u02f5\u3d26\ufffd\u06b6\u053d\ufffd\u03bb\ufffd\u00e1\ufffd\n\ufffd\ufffd\u00f4\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0df4\ufffd\ufffd\ufffd\ufffd\ufffd\u04bb\ufffd\ufffd\ufffd\u07fc\ufffd\ufffd\u0275\u00f5\ufffd (k+1) \ufffd\u05f5\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\ufffd\ufffd\ufffd n \ufffd\u053a\ufffd\ufffd\ufffd\u3ff3\ufffd\ufffd\u04bb\ufffd\u03be\ufffd\ufffd\u0735\u00f5\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\n\ufffd\ufffd\ufffd\ubcbb\ufffd\ufffd\u02b5\ufffd\u05a1\ufffd\ufffd\ufffd0w0\ufffd\ufffd\n\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u00f4\ufffd\u04f6\ufffd\u03ac\ufffd\ufffd\ufffd\ufffd\u03ac\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0538\ufffd\ufffd\ufffd\ufffd\ufffd\u04bb\ufffd\u3863\ufffd\ufffd\ufffd\ufffd\n\ufffd\u023d\ufffd\u05b5\ufffd\u00ff\ufffd\ufffd\u01f5\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u01f0\ufffd\ufffd\ufffd\ufffd\ufffd\u05f5\u013b\uedaf\ufffd\u02f5\u3dbc\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u036c\ufffd\ufffd\u03bb\ufffd\u00e1\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u04b2\ufffd\ufffd\ufffd\ufffd\u036c\u04bb\ufffd\ufffd\ufffd\ufffd\u02f4\u02fb\ufffd\ufffd\ufffd\ufffd\ufffd\u03bb\ufffd\u00e1\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u03ac\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0434\ufffd\u0532\u0435\u013b\ufffd\ufffd\u023d\ufffd\ufffd\ufffd\ufffd\ufffd Debug\ufffd\ufffd\ufffd\ufffd\ufffd\u04ba\ufffd\ufffd\ufffd\u0434\u04bb\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u06f2\ufffd\u0133\ufffd\ufffd\ufffd\u01f6\u0235\ufffd\ufffd\ufffd\u037c\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "308252e588af281fbac13492b98a6049", "src_uid": "e652ba0901b39f0d01ac152babc06b88", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\ntypedef long long int ll;\nconst ll MAXN=6e5+51;\nsetres;\nset::iterator it;\nll MOD,G,INVG;\nll fd,cnt,limit,inv2,v,p,q,r,s,sum,cur;\nll f[MAXN],g[MAXN],rev[MAXN],tmp[MAXN],delta[MAXN],delta2[MAXN],h[MAXN];\ninline ll read()\n{\n register ll num=0,neg=1;\n register char ch=getchar();\n while(!isdigit(ch)&&ch!='-')\n {\n ch=getchar();\n }\n if(ch=='-')\n {\n neg=-1;\n ch=getchar();\n }\n while(isdigit(ch))\n {\n num=(num<<3)+(num<<1)+(ch-'0');\n ch=getchar();\n }\n return num*neg;\n} \ninline ll qmul(ll x,ll y)\n{\n\treturn (x*y-(ll)((long double)x*y/MOD)*MOD+MOD)%MOD;\n}\ninline ll qpow(ll base,ll exponent)\n{\n li res=1;\n while(exponent)\n {\n if(exponent&1)\n {\n res=qmul(res,base)%MOD;\n }\n base=qmul(base,base)%MOD,exponent>>=1;\n }\n return res;\n}\ninline void NTT(ll *cp,ll cnt,ll inv)\n{\n ll cur=0,res=0,omg=0;\n for(register int i=0;i>1,res=qpow(inv==1?G:INVG,(MOD-1)/i);\n for(register ll *p=cp;p!=cp+cnt;p+=i)\n {\n omg=1;\n for(register int j=0;j>1]>>1)|((i&1)<50000)\n\t\t{\n\t\t\treturn puts(\"0\"),0;\n\t\t}\n\t\th[i]=v;\n\t}\n\tfor(register int i=0;i=0)\n\t{\n\t\ts=(ll)(sqrt(q*q-4*p*r)+0.5);\n\t\tif(s*s!=q*q-4*p*r)\n\t\t{\n\t\t\treturn puts(\"0\"),0;\n\t\t}\n\t\tif((-q+s)%(2*p)==0)\n\t\t{\n\t\t\tres.insert((-q+s)/(2*p));\n\t\t}\n\t\tif((-q-s)%(2*p)==0)\n\t\t{\n\t\t\tres.insert((-q-s)/(2*p));\n\t\t}\n\t}\n\tprintf(\"%d\\n\",res.size());\n\tfor(it=res.begin();it!=res.end();++it)\n\t{\n\t\tcur=*it;\n\t\tfor(register int i=0;i\nusing namespace std;\n\n#define _REP(i,a,b) for(int i = (a) ; i >= (int)(b) ; --i )\n#define REP(i,a,b) for(int i = (a) ; i <= (int)(b) ; ++i )\n#define UREP(i,u) for(int i = p[(u)] ; i + 1 ; i = edge[i].next)\n//iterator: for(int u:x),x is container\n#define x(p) (p).first\n#define y(p) (p).second\n#define pii pair\n#define mp(x,y) make_pair((x), (y))\n#define sign(x) (fabs(x) < eps ? 0 : ((x) > 0 ? 1 : -1))\n#define ll long long\n#define L7 __int128//1<<7 bit\n#define ull unsigned long long\nconst int inf = 0x3f3f3f3f;\nconst ll inff = 0x3f3f3f3f3f3f3f3f;\nconst double eps = 1e-9;\n#define ri1(x) scanf(\"%d\", &(x))\n#define ri2(x,y) scanf(\"%d%d\", &(x), &(y))\n#define ri3(x,y,z) scanf(\"%d%d%d\", &(x), &(y), &(z))\n#define ri4(a,b,c,d) scanf(\"%d%d%d%d\", &(a), &(b), &(c), &(d))\n//#define Debug\n#ifdef Debug\n#endif // Debug\n\nconst int maxn = 131072,maxx = 6000;\nll mod,g;\n\nll mul(ll a,ll b){return ((__int128)a * b % mod + mod) % mod;}\n\nll qp(ll base,ll n)\n{\n base %= mod;\n ll res = 1;\n while(n){\n if(n&1) res = mul(res,base);\n base = mul(base,base);\n n >>= 1;\n }\n return res;\n}\n\nnamespace NTT//\u4f18\u5316\u8fc7\u7684ntt\uff0c\u4f7f\u7528\u65f6\u8bb0\u5f97\u521d\u59cb\u5316\n{\n ll w[maxn<<3],inv[maxn<<3],r[maxn<<3],last,p;\n void init()\n {\n p = mod;\n ll lim = maxn << 2;\n inv[1] = 1;\n for(ll i=2;i<=lim;i++) inv[i] = (p - mul((p / i),inv[p%i])%p)%p;\n for(ll i=1;i>1]>>1)|((i&1)?(n>>1):0);\n last=n;\n }\n for(int i=1;i>= 1;\n }\n return res;\n }\n\n ll generator(ll p)\n {\n if(p<2) return -1;\n ll phi = p,tmp = p;\n for (ll i = 2; i * i <= tmp; ++i){\n if(tmp % i == 0){\n phi = phi / i * (i - 1);\n while(tmp % i == 0) tmp /= i;\n }\n }\n if(tmp > 1) phi = phi / tmp * (tmp - 1);\n ll n = phi;\n vector fact;\n for (ll i = 2; i * i <= n; ++i){\n if (n % i == 0){\n fact.push_back(i);\n while (n % i == 0) n /= i;\n }\n }\n if (n > 1) fact.push_back(n);\n for (ll res = 1; res <= p; ++res){\n if(__gcd(res,p) != 1) continue;\n bool ok = true;\n for (ll factor : fact){\n if (qp(res, phi / factor, p) == 1){\n ok = false;\n break;\n }\n }\n if (ok) return res;\n }\n return -1;\n }\n}\n\nvoid get_mod(int n)\n{\n ll lim = 1,lcm,act,ok = 0;\n while(lim<(3*n)) lim <<= 1;\n act = lcm = 1LL * lim * n / __gcd(lim,1LL*n);\n while(act get_a0(ll a,ll b,ll c)\n{\n vector res;\n ll delta = b * b - 4LL * a * c;\n if(delta<0){\n res.push_back(0);\n return res;\n }\n ll st = floor(sqrt(delta)+0.5);\n if(st*st!=delta){\n res.push_back(0);\n return res;\n }\n if(delta==0){\n if(b%(2*a)){\n res.push_back(0);\n return res;\n }\n res.push_back(1);\n res.push_back(-b/(2*a));\n }\n else{\n if(((-b+st)%(a*2))&&((-b-st)%(a*2))){\n res.push_back(0);\n return res;\n }\n if(((-b+st)%(a*2)==0)&&((-b-st)%(a*2)==0)){\n res.push_back(2);\n res.push_back((-b+st)/(a*2));\n res.push_back((-b-st)/(a*2));\n return res;\n }\n if((-b+st)%(a*2)==0){\n res.push_back(1);\n res.push_back((-b+st)/(a*2));\n return res;\n }\n if((-b-st)%(a*2)==0){\n res.push_back(1);\n res.push_back((-b-st)/(a*2));\n return res;\n }\n }\n}\n\nll judge(ll delta)\n{\n return delta < maxx ? delta : delta - mod;\n}\n\nint main()\n{\n #ifndef ONLINE_JUDGE\n freopen(\"in.txt\",\"r\",stdin);//cf needn't delete this\n #endif // ONLINE_JUDGE\n int n;\n ri1(n);\n get_mod(n);\n NTT::init();\n init(n);\n REP(i,0,n-1) scanf(\"%lld\",&b[i]),ori_b[i] = b[i];\n reverse(b,b+n);\n REP(i,0,n-1) scanf(\"%lld\",&c[i]);\n ll A = n,B = 0,C = -c[0];\n int buf_b = b[n-1];\n _REP(i,n-1,1) b[i] = mul(b[i-1],-2);b[0] = mul(buf_b,-2);\n REP(i,1,n-1) dtc[i] = c[i] - c[i-1];dtc[0] = c[0] - c[n-1];\n bluestein(dtc,n,1),bluestein(b,n,1);\n REP(i,0,n-1) dta[i] = mul(dtc[i] , qp(b[i],mod-2));\n bluestein(dta,n,-1);\n REP(i,1,n-1) dta[i] = judge(dta[i]);\n REP(i,1,n-1) s[i] = s[i-1] + dta[i];\n REP(i,0,n-1) B += 2LL * (s[i] - ori_b[i]),C += (s[i] - ori_b[i]) * (s[i] - ori_b[i]);\n vector vec = get_a0(A,B,C);\n if(vec[0]==0) printf(\"0\\n\");\n else if(vec[0]==1){\n printf(\"1\\n\");\n printf(\"%lld \",vec[1]);\n ll pre = vec[1];\n REP(i,1,n-1) printf(\"%d%c\",(pre = (dta[i]+pre)),i==n-1?'\\n':' ');\n }\n else{\n printf(\"2\\n\");\n if(vec[1]>vec[2]) swap(vec[1],vec[2]);\n printf(\"%lld%c\",vec[1],n==1?'\\n':' ');\n ll pre = vec[1];\n REP(i,1,n-1) printf(\"%d%c\",(pre = (dta[i]+pre)),i==n-1?'\\n':' ');\n printf(\"%lld%c\",vec[2],n==1?'\\n':' ');\n pre = vec[2];\n REP(i,1,n-1) printf(\"%d%c\",(pre = (dta[i]+pre)),i==n-1?'\\n':' ');\n }\n return ~~(0-0);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b85998490474670c194156f3840275b1", "src_uid": "d8c531799874ce5bf5443aba1d34b26d", "difficulty": 3300.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\ntypedef long long int ll;\ntypedef __int128 li;\nconst ll MAXN=6e5+51;\nsetres;\nset::iterator it;\nll MOD,G,INVG;\nll fd,cnt,limit,inv2,v,p,q,r,s,sum,cur;\nll f[MAXN],g[MAXN],rev[MAXN],tmp[MAXN],delta[MAXN],delta2[MAXN],h[MAXN];\ninline ll read()\n{\n register ll num=0,neg=1;\n register char ch=getchar();\n while(!isdigit(ch)&&ch!='-')\n {\n ch=getchar();\n }\n if(ch=='-')\n {\n neg=-1;\n ch=getchar();\n }\n while(isdigit(ch))\n {\n num=(num<<3)+(num<<1)+(ch-'0');\n ch=getchar();\n }\n return num*neg;\n} \ninline ll qmul(ll x,ll y)\n{\n\treturn (x*y-(ll)((long double)x*y/MOD)*MOD+MOD)%MOD;\n}\ninline ll qpow(ll base,ll exponent)\n{\n li res=1;\n while(exponent)\n {\n if(exponent&1)\n {\n res=qmul(res,base)%MOD;\n }\n base=qmul(base,base)%MOD,exponent>>=1;\n }\n return res;\n}\ninline void NTT(ll *cp,ll cnt,ll inv)\n{\n ll cur=0,res=0,omg=0;\n for(register int i=0;i>1,res=qpow(inv==1?G:INVG,(MOD-1)/i);\n for(register ll *p=cp;p!=cp+cnt;p+=i)\n {\n omg=1;\n for(register int j=0;j>1]>>1)|((i&1)<50000)\n\t\t{\n\t\t\treturn puts(\"0\"),0;\n\t\t}\n\t\th[i]=v;\n\t}\n\tfor(register int i=0;i=0)\n\t{\n\t\ts=(ll)(sqrt(q*q-4*p*r)+0.5);\n\t\tif(s*s!=q*q-4*p*r)\n\t\t{\n\t\t\treturn puts(\"0\"),0;\n\t\t}\n\t\tif((-q+s)%(2*p)==0)\n\t\t{\n\t\t\tres.insert((-q+s)/(2*p));\n\t\t}\n\t\tif((-q-s)%(2*p)==0)\n\t\t{\n\t\t\tres.insert((-q-s)/(2*p));\n\t\t}\n\t}\n\tprintf(\"%d\\n\",res.size());\n\tfor(it=res.begin();it!=res.end();++it)\n\t{\n\t\tcur=*it;\n\t\tfor(register int i=0;i\n//\n// Created by aryssoncf on 28/10/2019.\n//\n\n#include \n\n\n#include \n#include \n\ntemplate\nconstexpr auto hasBegin(int) -> decltype(std::begin(std::declval()), true) {\n return true;\n}\n\nconstexpr bool hasBegin(...) {\n return false;\n}\n\ntemplate\nusing IsContainer = std::integral_constant(0)>;\n\n\n#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP\n#define JHELPER_EXAMPLE_PROJECT_IO_HPP\n\n#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP\n\ntemplate::value>>\nstd::istream &operator>>(std::istream &stream, T &container) {\n for (auto &element: container) {\n stream >> element;\n }\n return stream;\n}\n\ntemplate\nstd::ostream &operator<<(std::ostream &os, std::pair const &p) {\n return os << p.first << \" \" << p.second;\n}\n\ntemplate\nstd::basic_ostream &operator<<(std::basic_ostream &os, Container const &x) {\n bool first = true;\n for (auto &y : x) {\n if (first) {\n first = false;\n } else {\n os << \" \";\n }\n os << y;\n }\n return os;\n}\n//\n// Created by aryssoncf on 28/10/2019.\n//\n\n\n\n/**\n* ax + by = result\n*/\ntemplate\nT extendedGcd(T a, T b, T &x, T &y) {\n if (a == 0) {\n x = 0;\n y = 1;\n return b;\n }\n T d = extendedGcd(b % a, a, y, x);\n x -= (b / a) * y;\n return d;\n}\n\n\n#include \n#include \n\n#ifndef SPCPPL_ASSERT\n#ifdef SPCPPL_DEBUG\n#define SPCPPL_ASSERT(condition) \\\n if(!(condition)) { \\\n throw std::runtime_error(std::string() + #condition + \" in line \" + std::to_string(__LINE__) + \" in \" + __PRETTY_FUNCTION__); \\\n }\n#else\n#define SPCPPL_ASSERT(condition)\n#endif\n#endif\n\n\n#ifndef JHELPER_EXAMPLE_PROJECT_MODULAR_HPP\n#define JHELPER_EXAMPLE_PROJECT_MODULAR_HPP\n\n#endif //JHELPER_EXAMPLE_PROJECT_MODULAR_HPP\n\n\n#include \n\nusing namespace std;\n\nint MOD = 1000000007;\n\nclass Modular {\n int value;\n\n template\n static int mod(const complex &x) {\n return mod(x.real());\n }\n\n static int mod(Modular x) {\n return x.value;\n }\n\n template::value>\n static int mod(T x) {\n long long x_ = is_int ? (long long) x : (long long) roundl(x);\n int y = x_ % MOD;\n if (y < 0) {\n y += MOD;\n }\n return y;\n }\n\n void inc(const int &x) {\n value += x;\n if (value >= MOD) {\n value -= MOD;\n }\n }\n\n void mul(const int &x) {\n value = (long long) value * x % MOD;\n }\n\npublic:\n Modular() : value(0) {}\n\n template\n Modular(const T &x) {\n value = mod(x);\n }\n\n// template\n// Modular& operator=(const T &x) {\n// value = mod(x);\n// return *this;\n// }\n\n template\n explicit operator T() {\n return value;\n }\n\n Modular operator-() const {\n return mod(-value);\n }\n\n Modular &operator++() {\n inc(mod(1));\n return *this;\n }\n\n Modular operator++(int) {\n Modular res = *this;\n inc(mod(1));\n return res;\n }\n\n Modular &operator--() {\n inc(mod(-1));\n return *this;\n }\n\n Modular operator--(int) {\n Modular res = *this;\n inc(mod(-1));\n return res;\n }\n\n template\n Modular &operator+=(const T &x) {\n inc(mod(x));\n return *this;\n }\n\n template\n Modular &operator-=(const T &x) {\n inc(mod(-x));\n return *this;\n }\n\n template\n Modular &operator*=(const T &x) {\n mul(mod(x));\n return *this;\n }\n\n Modular inversed() const {\n SPCPPL_ASSERT(value != 0);\n int x, y;\n int gcd = extendedGcd(value, MOD, x, y);\n SPCPPL_ASSERT(gcd == 1);\n return Modular(x);\n }\n\n template\n Modular &operator/=(const T &x) {\n mul(Modular(x).inversed().value);\n return *this;\n }\n\n friend bool operator==(const Modular &, const Modular &);\n\n friend bool operator!=(const Modular &, const Modular &);\n\n friend ostream &operator<<(std::ostream &, const Modular &);\n};\n\nModular operator+(const Modular &x, const Modular &y) {\n Modular copy = x;\n return copy += y;\n}\n\nModular operator-(const Modular &x, const Modular &y) {\n Modular copy = x;\n return copy -= y;\n}\n\nModular operator*(const Modular &x, const Modular &y) {\n Modular copy = x;\n return copy *= y;\n}\n\nModular operator/(const Modular &x, const Modular &y) {\n Modular copy = x;\n return copy /= y;\n}\n\ntemplate\nModular operator/(const Modular &x, const T &y) {\n Modular copy = x;\n return copy /= y;\n}\n\ntemplate\nModular operator/(const T &x, const Modular &y) {\n Modular copy = x;\n return copy /= y;\n}\n\nbool operator==(const Modular &x, const Modular &y) {\n return x.value == Modular::mod(y);\n}\n\nbool operator!=(const Modular &x, const Modular &y) {\n return x.value != Modular::mod(y);\n}\n\nostream &operator<<(std::ostream &stream, const Modular &x) {\n return stream << x.value;\n}\n\n\n#include \n#include \n\nbool isPrime(int n) {\n for (int i = 2; i * i <= n; ++i) {\n if (n % i == 0) {\n return false;\n }\n }\n return n >= 2;\n}\n\nbool isPrime(int64_t n) {\n for (int64_t i = 2; i * i <= n; ++i) {\n if (n % i == 0) {\n return false;\n }\n }\n return n >= 2;\n}\n\nstd::vector primeMap(std::size_t maxN) {\n std::vector prime(maxN + 1, true);\n\n prime[0] = false;\n prime[1] = false;\n\n for (std::size_t i = 2; i * i <= maxN; ++i) {\n if (prime[i]) {\n if (i * 1ULL * i <= maxN) {\n for (std::size_t j = i * i; j <= maxN; j += i) {\n prime[j] = false;\n }\n }\n }\n }\n return prime;\n}\n\nstd::vector allPrimes(int maxN) {\n std::vector result;\n result.reserve(maxN);\n std::vector map = primeMap(maxN);\n for (int i = 0; i <= maxN; i++) {\n if (map[i]) {\n result.push_back(i);\n }\n }\n return result;\n}\n\nint nextPrime(int n) {\n while (!isPrime(n)) {\n ++n;\n }\n return n;\n}\n\n//\n// Created by aryssoncf on 25/10/2019.\n//\n\n#ifndef JHELPER_EXAMPLE_PROJECT_MODULARFFT_HPP\n#define JHELPER_EXAMPLE_PROJECT_MODULARFFT_HPP\n\n#endif //JHELPER_EXAMPLE_PROJECT_MODULARFFT_HPP\n\n\n\n//\n// Created by aryssoncf on 25/10/2019.\n//\n\n#ifndef JHELPER_EXAMPLE_PROJECT_FASTFOURIERTRANSFORM_HPP\n#define JHELPER_EXAMPLE_PROJECT_FASTFOURIERTRANSFORM_HPP\n\n#endif //JHELPER_EXAMPLE_PROJECT_FASTFOURIERTRANSFORM_HPP\n\n\n#include \n\n//\n// Created by aryssoncf on 25/10/2019.\n//\n\n#ifndef JHELPER_EXAMPLE_PROJECT_FFT_HPP\n#define JHELPER_EXAMPLE_PROJECT_FFT_HPP\n\n#endif //JHELPER_EXAMPLE_PROJECT_FFT_HPP\n\n\ntemplate\nstruct IdentityHelper;\n\ntemplate\nstruct IdentityHelper::type> {\n static T identity() {\n return 1;\n }\n};\n\ntemplate\nT identity() {\n return IdentityHelper::identity();\n}\n\n\ntemplate\nT binpow(T base, long long power) {\n SPCPPL_ASSERT(power >= 0);\n// T result = identity();\n T result = 1;\n while (power > 0) {\n if (power & 1) {\n result *= base;\n }\n power >>= 1;\n base *= base;\n }\n return result;\n}\n\n\nusing namespace std;\n\ntemplate\nclass FFT {\nprotected:\n virtual int result_length(int first_length, int second_length) = 0;\n\n virtual long long result_length_power(long long first_length, long long second_length) = 0;\n\n unsigned nextpow2(unsigned v) {\n return v ? 1 << __lg(2 * v - 1) : 1;\n }\n\n virtual T calculate_root(int N) {}\n\npublic:\n virtual vector transform(vector y, bool invert = false) = 0;\n\n vector linear_convolution(vector a, vector b) {\n const int n = result_length(a.size(), b.size()), n2 = nextpow2(n);\n a.resize(n2);\n b.resize(n2);\n vector fa = transform(move(a)), fb = transform(move(b)), &fc = fa;\n for (int i = 0; i < n2; ++i) fc[i] = fa[i] * fb[i];\n vector c = transform(move(fc), true);\n c.resize(n);\n return move(c);\n }\n\n vector linear_convolution_power(vector a, long long power, int length = -1) {\n const int n = length < 0 ? result_length_power(a.size(), power) : length, n2 = nextpow2(n);\n a.resize(n2);\n vector fa = transform(move(a)), &fc = fa;\n for (int i = 0; i < n2; ++i) fc[i] = binpow(fa[i], power);\n vector c = transform(move(fc), true);\n c.resize(n);\n return move(c);\n }\n};\n\n\nusing namespace std;\nnamespace algebra {\n const int inf = 1e9;\n const int magic = 500; // threshold for sizes to run the naive algo\n\n namespace fft {\n const int maxn = 1 << 19;\n\n typedef double ftype;\n typedef complex point;\n\n point w[maxn];\n const ftype pi = acos(-1);\n bool initiated = 0;\n\n void init() {\n if (!initiated) {\n for (int i = 1; i < maxn; i *= 2) {\n for (int j = 0; j < i; j++) {\n w[i + j] = polar(ftype(1), pi * j / i);\n }\n }\n initiated = 1;\n }\n }\n\n template\n void fft(T *in, point *out, int n, int k = 1) {\n if (n == 1) {\n *out = *in;\n } else {\n n /= 2;\n fft(in, out, n, 2 * k);\n fft(in + k, out + n, n, 2 * k);\n for (int i = 0; i < n; i++) {\n auto t = out[i + n] * w[i + n];\n out[i + n] = out[i] - t;\n out[i] += t;\n }\n }\n }\n\n template\n void mul_slow(vector &a, const vector &b) {\n vector res(a.size() + b.size() - 1);\n for (size_t i = 0; i < a.size(); i++) {\n for (size_t j = 0; j < b.size(); j++) {\n res[i + j] += a[i] * b[j];\n }\n }\n a = res;\n }\n\n\n template\n void mul(vector &a, const vector &b) {\n if (min(a.size(), b.size()) < magic) {\n mul_slow(a, b);\n return;\n }\n init();\n static const int shift = 15, mask = (1 << shift) - 1;\n size_t n = a.size() + b.size() - 1;\n while (__builtin_popcount(n) != 1) {\n n++;\n }\n a.resize(n);\n static point A[maxn], B[maxn];\n static point C[maxn], D[maxn];\n for (size_t i = 0; i < n; i++) {\n A[i] = point(a[i] & mask, a[i] >> shift);\n if (i < b.size()) {\n B[i] = point(b[i] & mask, b[i] >> shift);\n } else {\n B[i] = 0;\n }\n }\n fft(A, C, n);\n fft(B, D, n);\n for (size_t i = 0; i < n; i++) {\n point c0 = C[i] + conj(C[(n - i) % n]);\n point c1 = C[i] - conj(C[(n - i) % n]);\n point d0 = D[i] + conj(D[(n - i) % n]);\n point d1 = D[i] - conj(D[(n - i) % n]);\n A[i] = c0 * d0 - point(0, 1) * c1 * d1;\n B[i] = c0 * d1 + d0 * c1;\n }\n fft(A, C, n);\n fft(B, D, n);\n reverse(C + 1, C + n);\n reverse(D + 1, D + n);\n int t = 4 * n;\n for (size_t i = 0; i < n; i++) {\n int64_t A0 = llround(real(C[i]) / t);\n T A1 = llround(imag(D[i]) / t);\n T A2 = llround(imag(C[i]) / t);\n a[i] = A0 + (A1 << shift) + (A2 << 2 * shift);\n }\n return;\n }\n }\n\n template\n T bpow(T x, size_t n) {\n return n ? n % 2 ? x * bpow(x, n - 1) : bpow(x * x, n / 2) : T(1);\n }\n\n template\n T bpow(T x, size_t n, T m) {\n return n ? n % 2 ? x * bpow(x, n - 1, m) % m : bpow(x * x % m, n / 2, m) : T(1);\n }\n\n template\n T gcd(const T &a, const T &b) {\n return b == T(0) ? a : gcd(b, a % b);\n }\n\n template\n T nCr(T n, int r) { // runs in O(r)\n T res(1);\n for (int i = 0; i < r; i++) {\n res *= (n - T(i));\n res /= (i + 1);\n }\n return res;\n }\n\n template\n struct modular {\n int64_t r;\n\n modular() : r(0) {}\n\n modular(int64_t rr) : r(rr) {\n if (abs(r) >= m) r %= m;\n if (r < 0) r += m;\n }\n\n modular inv() const { return bpow(*this, m - 2); }\n\n modular operator*(const modular &t) const { return (r * t.r) % m; }\n\n modular operator/(const modular &t) const { return *this * t.inv(); }\n\n modular operator+=(const modular &t) {\n r += t.r;\n if (r >= m) r -= m;\n return *this;\n }\n\n modular operator-=(const modular &t) {\n r -= t.r;\n if (r < 0) r += m;\n return *this;\n }\n\n modular operator+(const modular &t) const { return modular(*this) += t; }\n\n modular operator-(const modular &t) const { return modular(*this) -= t; }\n\n modular operator*=(const modular &t) { return *this = *this * t; }\n\n modular operator/=(const modular &t) { return *this = *this / t; }\n\n bool operator==(const modular &t) const { return r == t.r; }\n\n bool operator!=(const modular &t) const { return r != t.r; }\n\n operator int64_t() const { return r; }\n };\n\n template\n istream &operator>>(istream &in, modular &x) {\n return in >> x.r;\n }\n\n\n template\n struct poly {\n vector a;\n\n void normalize() { // get rid of leading zeroes\n while (!a.empty() && a.back() == T(0)) {\n a.pop_back();\n }\n }\n\n poly() {}\n\n poly(T a0) : a{a0} { normalize(); }\n\n poly(vector t) : a(t) { normalize(); }\n\n poly operator+=(const poly &t) {\n a.resize(max(a.size(), t.a.size()));\n for (size_t i = 0; i < t.a.size(); i++) {\n a[i] += t.a[i];\n }\n normalize();\n return *this;\n }\n\n poly operator-=(const poly &t) {\n a.resize(max(a.size(), t.a.size()));\n for (size_t i = 0; i < t.a.size(); i++) {\n a[i] -= t.a[i];\n }\n normalize();\n return *this;\n }\n\n poly operator+(const poly &t) const { return poly(*this) += t; }\n\n poly operator-(const poly &t) const { return poly(*this) -= t; }\n\n poly mod_xk(size_t k) const { // get same polynomial mod x^k\n k = min(k, a.size());\n return vector(begin(a), begin(a) + k);\n }\n\n poly mul_xk(size_t k) const { // multiply by x^k\n poly res(*this);\n res.a.insert(begin(res.a), k, 0);\n return res;\n }\n\n poly div_xk(size_t k) const { // divide by x^k, dropping coefficients\n k = min(k, a.size());\n return vector(begin(a) + k, end(a));\n }\n\n poly substr(size_t l, size_t r) const { // return mod_xk(r).div_xk(l)\n l = min(l, a.size());\n r = min(r, a.size());\n return vector(begin(a) + l, begin(a) + r);\n }\n\n poly inv(size_t n) const { // get inverse series mod x^n\n assert(!is_zero());\n poly ans = a[0].inv();\n size_t a = 1;\n while (a < n) {\n poly C = (ans * mod_xk(2 * a)).substr(a, 2 * a);\n ans -= (ans * C).mod_xk(a).mul_xk(a);\n a *= 2;\n }\n return ans.mod_xk(n);\n }\n\n poly operator*=(const poly &t) {\n fft::mul(a, t.a);\n normalize();\n return *this;\n }\n\n poly operator*(const poly &t) const { return poly(*this) *= t; }\n\n poly reverse(size_t n, bool rev = 0) const { // reverses and leaves only n terms\n poly res(*this);\n if (rev) { // If rev = 1 then tail goes to head\n res.a.resize(max(n, res.a.size()));\n }\n std::reverse(res.a.begin(), res.a.end());\n return res.mod_xk(n);\n }\n\n pair divmod_slow(const poly &b) const { // when divisor or quotient is small\n vector A(a);\n vector res;\n while (A.size() >= b.a.size()) {\n res.push_back(A.back() / b.a.back());\n if (res.back() != T(0)) {\n for (size_t i = 0; i < b.a.size(); i++) {\n A[A.size() - i - 1] -= res.back() * b.a[b.a.size() - i - 1];\n }\n }\n A.pop_back();\n }\n std::reverse(begin(res), end(res));\n return {res, A};\n }\n\n pair divmod(const poly &b) const { // returns quotiend and remainder of a mod b\n if (deg() < b.deg()) {\n return {poly{0}, *this};\n }\n int d = deg() - b.deg();\n if (min(d, b.deg()) < magic) {\n return divmod_slow(b);\n }\n poly D = (reverse(d + 1) * b.reverse(d + 1).inv(d + 1)).mod_xk(d + 1).reverse(d + 1, 1);\n return {D, *this - D * b};\n }\n\n poly operator/(const poly &t) const { return divmod(t).first; }\n\n poly operator%(const poly &t) const { return divmod(t).second; }\n\n poly operator/=(const poly &t) { return *this = divmod(t).first; }\n\n poly operator%=(const poly &t) { return *this = divmod(t).second; }\n\n poly operator*=(const T &x) {\n for (auto &it: a) {\n it *= x;\n }\n normalize();\n return *this;\n }\n\n poly operator/=(const T &x) {\n for (auto &it: a) {\n it /= x;\n }\n normalize();\n return *this;\n }\n\n poly operator*(const T &x) const { return poly(*this) *= x; }\n\n poly operator/(const T &x) const { return poly(*this) /= x; }\n\n void print() const {\n for (auto it: a) {\n cout << it << ' ';\n }\n cout << endl;\n }\n\n T eval(T x) const { // evaluates in single point x\n T res(0);\n for (int i = int(a.size()) - 1; i >= 0; i--) {\n res *= x;\n res += a[i];\n }\n return res;\n }\n\n T &lead() { // leading coefficient\n return a.back();\n }\n\n int deg() const { // degree\n return a.empty() ? -inf : a.size() - 1;\n }\n\n bool is_zero() const { // is polynomial zero\n return a.empty();\n }\n\n T operator[](int idx) const {\n return idx >= (int) a.size() || idx < 0 ? T(0) : a[idx];\n }\n\n T &coef(size_t idx) { // mutable reference at coefficient\n return a[idx];\n }\n\n bool operator==(const poly &t) const { return a == t.a; }\n\n bool operator!=(const poly &t) const { return a != t.a; }\n\n poly deriv() { // calculate derivative\n vector res;\n for (int i = 1; i <= deg(); i++) {\n res.push_back(T(i) * a[i]);\n }\n return res;\n }\n\n poly integr() { // calculate integral with C = 0\n vector res = {0};\n for (int i = 0; i <= deg(); i++) {\n res.push_back(a[i] / T(i + 1));\n }\n return res;\n }\n\n size_t leading_xk() const { // Let p(x) = x^k * t(x), return k\n if (is_zero()) {\n return inf;\n }\n int res = 0;\n while (a[res] == T(0)) {\n res++;\n }\n return res;\n }\n\n poly log(size_t n) { // calculate log p(x) mod x^n\n assert(a[0] == T(1));\n return (deriv().mod_xk(n) * inv(n)).integr().mod_xk(n);\n }\n\n poly exp(size_t n) { // calculate exp p(x) mod x^n\n if (is_zero()) {\n return T(1);\n }\n assert(a[0] == T(0));\n poly ans = T(1);\n size_t a = 1;\n while (a < n) {\n poly C = ans.log(2 * a).div_xk(a) - substr(a, 2 * a);\n ans -= (ans * C).mod_xk(a).mul_xk(a);\n a *= 2;\n }\n return ans.mod_xk(n);\n\n }\n\n poly pow_slow(size_t k, size_t n) { // if k is small\n return k ? k % 2 ? (*this * pow_slow(k - 1, n)).mod_xk(n) : (*this * *this).mod_xk(n).pow_slow(k / 2, n)\n : T(1);\n }\n\n poly pow(size_t k, size_t n) { // calculate p^k(n) mod x^n\n if (is_zero()) {\n return *this;\n }\n if (k < magic) {\n return pow_slow(k, n);\n }\n int i = leading_xk();\n T j = a[i];\n poly t = div_xk(i) / j;\n return bpow(j, k) * (t.log(n) * T(k)).exp(n).mul_xk(i * k).mod_xk(n);\n }\n\n poly mulx(T x) { // component-wise multiplication with x^k\n T cur = 1;\n poly res(*this);\n for (int i = 0; i <= deg(); i++) {\n res.coef(i) *= cur;\n cur *= x;\n }\n return res;\n }\n\n poly mulx_sq(T x) { // component-wise multiplication with x^{k^2}\n T cur = x;\n T total = 1;\n T xx = x * x;\n poly res(*this);\n for (int i = 0; i <= deg(); i++) {\n res.coef(i) *= total;\n total *= cur;\n cur *= xx;\n }\n return res;\n }\n\n vector chirpz_even(T z, int n) { // P(1), P(z^2), P(z^4), ..., P(z^2(n-1))\n int m = deg();\n if (is_zero()) {\n return vector(n, 0);\n }\n vector vv(m + n);\n T zi = z.inv();\n T zz = zi * zi;\n T cur = zi;\n T total = 1;\n for (int i = 0; i <= max(n - 1, m); i++) {\n if (i <= m) { vv[m - i] = total; }\n if (i < n) { vv[m + i] = total; }\n total *= cur;\n cur *= zz;\n }\n poly w = (mulx_sq(z) * vv).substr(m, m + n).mulx_sq(z);\n vector res(n);\n for (int i = 0; i < n; i++) {\n res[i] = w[i];\n }\n return res;\n }\n\n vector chirpz(T z, int n) { // P(1), P(z), P(z^2), ..., P(z^(n-1))\n auto even = chirpz_even(z, (n + 1) / 2);\n auto odd = mulx(z).chirpz_even(z, n / 2);\n vector ans(n);\n for (int i = 0; i < n / 2; i++) {\n ans[2 * i] = even[i];\n ans[2 * i + 1] = odd[i];\n }\n if (n % 2 == 1) {\n ans[n - 1] = even.back();\n }\n return ans;\n }\n\n template\n vector eval(vector &tree, int v, iter l, iter r) { // auxiliary evaluation function\n if (r - l == 1) {\n return {eval(*l)};\n } else {\n auto m = l + (r - l) / 2;\n auto A = (*this % tree[2 * v]).eval(tree, 2 * v, l, m);\n auto B = (*this % tree[2 * v + 1]).eval(tree, 2 * v + 1, m, r);\n A.insert(end(A), begin(B), end(B));\n return A;\n }\n }\n\n vector eval(vector x) { // evaluate polynomial in (x1, ..., xn)\n int n = x.size();\n if (is_zero()) {\n return vector(n, T(0));\n }\n vector tree(4 * n);\n build(tree, 1, begin(x), end(x));\n return eval(tree, 1, begin(x), end(x));\n }\n\n template\n poly inter(vector &tree, int v, iter l, iter r, iter ly, iter ry) { // auxiliary interpolation function\n if (r - l == 1) {\n return {*ly / a[0]};\n } else {\n auto m = l + (r - l) / 2;\n auto my = ly + (ry - ly) / 2;\n auto A = (*this % tree[2 * v]).inter(tree, 2 * v, l, m, ly, my);\n auto B = (*this % tree[2 * v + 1]).inter(tree, 2 * v + 1, m, r, my, ry);\n return A * tree[2 * v + 1] + B * tree[2 * v];\n }\n }\n };\n\n template\n poly operator*(const T &a, const poly &b) {\n return b * a;\n }\n\n template\n poly xk(int k) { // return x^k\n return poly{1}.mul_xk(k);\n }\n\n template\n T resultant(poly a, poly b) { // computes resultant of a and b\n if (b.is_zero()) {\n return 0;\n } else if (b.deg() == 0) {\n return bpow(b.lead(), a.deg());\n } else {\n int pw = a.deg();\n a %= b;\n pw -= a.deg();\n T mul = bpow(b.lead(), pw) * T((b.deg() & a.deg() & 1) ? -1 : 1);\n T ans = resultant(b, a);\n return ans * mul;\n }\n }\n\n template\n poly kmul(iter L, iter R) { // computes (x-a1)(x-a2)...(x-an) without building tree\n if (R - L == 1) {\n return vector{-*L, 1};\n } else {\n iter M = L + (R - L) / 2;\n return kmul(L, M) * kmul(M, R);\n }\n }\n\n template\n poly build(vector> &res, int v, iter L, iter R) { // builds evaluation tree for (x-a1)(x-a2)...(x-an)\n if (R - L == 1) {\n return res[v] = vector{-*L, 1};\n } else {\n iter M = L + (R - L) / 2;\n return res[v] = build(res, 2 * v, L, M) * build(res, 2 * v + 1, M, R);\n }\n }\n\n template\n poly inter(vector x, vector y) { // interpolates minimum polynomial from (xi, yi) pairs\n int n = x.size();\n vector> tree(4 * n);\n return build(tree, 1, begin(x), end(x)).deriv().inter(tree, 1, begin(x), end(x), begin(y), end(y));\n }\n};\n\nusing namespace algebra;\n\nconst int mod = 1e9 + 7;\ntypedef modular base;\ntypedef poly polyn;\n\nusing namespace algebra;\n\n//signed main() {\n// ios::sync_with_stdio(0);\n// cin.tie(0);\n// int n = 100000;\n// polyn a;\n// vector x;\n// for(int i = 0; i <= n; i++) {\n// a.a.push_back(1 + rand() % 100);\n// x.push_back(1 + rand() % (2 * n));\n// }\n// sort(begin(x), end(x));\n// x.erase(unique(begin(x), end(x)), end(x));\n// auto b = a.eval(x);\n// cout << clock() / double(CLOCKS_PER_SEC) << endl;\n// auto c = inter(x, b);\n// polyn md = kmul(begin(x), end(x));\n// cout << clock() / double(CLOCKS_PER_SEC) << endl;\n// assert(c == a % md);\n// return 0;\n//}\n\nusing namespace std;\n\ntemplate\nclass SumFFT : public FFT {\n int result_length(int first_length, int second_length) {\n return max(first_length + second_length - 1, 0);\n }\n\n long long result_length_power(long long length, long long power) {\n return max(((length - 1) << power) + 1, 0ll);\n }\n\nprotected:\n virtual T calculate_root(int N) = 0;\n\npublic:\n vector transform(vector y, bool invert = false) {\n const int N = y.size();\n assert(N == (N & -N));\n vector rev(N);\n for (int i = 1; i < N; ++i) {\n rev[i] = (rev[i >> 1] >> 1) | (i & 1 ? N >> 1 : 0);\n if (rev[i] < i) swap(y[i], y[rev[i]]);\n }\n vector rootni(N / 2);\n for (int n = 2; n <= N; n *= 2) {\n T rootn = calculate_root(n);\n if (invert) {\n rootn = T(1) / rootn;\n }\n rootni[0] = 1;\n for (int i = 1; i < n / 2; ++i) rootni[i] = rootni[i - 1] * rootn;\n for (int left = 0; left != N; left += n) {\n const int mid = left + n / 2;\n for (int i = 0; i < n / 2; ++i) {\n const T temp = rootni[i] * y[mid + i];\n y[mid + i] = y[left + i] - temp;\n y[left + i] += temp;\n }\n }\n }\n if (invert) for (auto &v : y) v /= N;\n return move(y);\n }\n\n vector bluestein(vector y, bool invert) {\n// using Poly = Polynomial<0>;\n int n = y.size(), N = 2 * n;\n T rootn = calculate_root(N), inverse_rootn = 1 / rootn;\n if (invert) {\n swap(rootn, inverse_rootn);\n }\n vector A(n), B(2 * n - 1);\n for (int i = 0; i < n; i++) {\n A[i] = (long long) (y[i] * binpow(rootn, (long long) i * i));\n }\n for (int i = -(n - 1); i < n; i++) {\n B[i + n - 1] = (long long) (binpow(inverse_rootn, (long long) i * i));\n }\n fft::mul(A, B);\n for (int i = 0; i < n; i++) {\n y[i] = binpow(rootn, (long long) i * i) * A[n - 1 + i];\n }\n if (invert) for (auto &v : y) v /= n;\n return move(y);\n }\n\n vector cyclic_convolution(vector a, vector b) {\n assert(a.size() == b.size());\n int n = a.size();\n vector c = this->linear_convolution(move(a), move(b));\n for (int i = c.size() - 1; i >= n; --i) c[i - n] += c[i];\n c.resize(n);\n return move(c);\n }\n\n vector cyclic_convolution_power(vector a, long long power, int length = -1) {\n int n = a.size();\n vector c = this->linear_convolution_power(move(a), power, length);\n for (int i = c.size() - 1; i >= n; --i) c[i % n] += c[i];\n c.resize(n);\n return move(c);\n }\n\n template\n vector cyclic_convolution(vector a, vector b) {\n assert(a.size() == b.size());\n int n = a.size();\n vector fa = bluestein(move(a)), fb = bluestein(move(b)), &fc = fa;\n for (int i = 0; i < n; ++i) fc[i] = fa[i] * fb[i];\n vector c = bluestein(move(fc), true);\n return move(c);\n }\n\n template\n vector cyclic_convolution_power(vector a, long long power) {\n int n = a.size();\n vector fa = bluestein(move(a)), &fc = fa;\n for (int i = 0; i < n; ++i) fc[i] = binpow(fa[i], power);\n vector c = transform(move(fc), true);\n return move(c);\n }\n};\n\n\n#include \n\n\ntemplate\nvoid sort(R &range) {\n std::sort(range.begin(), range.end());\n}\n\ntemplate\nvoid sort(R &range, Comp comp) {\n std::sort(range.begin(), range.end(), comp);\n}\n\ntemplate\nvoid reverse(R &range) {\n std::reverse(range.begin(), range.end());\n}\n\ntemplate\nauto lower_bound(const R &range, const T &value) -> decltype(range.begin()) {\n return std::lower_bound(range.begin(), range.end(), value);\n}\n\ntemplate\nauto lower_bound(const R &range, const T &value, Comp comp) -> decltype(range.begin()) {\n return std::lower_bound(range.begin(), range.end(), value, comp);\n}\n\ntemplate\nauto upper_bound(const R &range, const T &value) -> decltype(range.begin()) {\n return std::upper_bound(range.begin(), range.end(), value);\n}\n\ntemplate\nauto upper_bound(const R &range, const T &value, Comp comp) -> decltype(range.begin()) {\n return std::upper_bound(range.begin(), range.end(), value, comp);\n}\n\ntemplate\nauto min_element(const R &range) -> decltype(range.begin()) {\n return std::min_element(range.begin(), range.end());\n}\n\ntemplate\nauto max_element(const R &range) -> decltype(range.begin()) {\n return std::max_element(range.begin(), range.end());\n}\n\ntemplate\nbool next_permutation(R &range) {\n return std::next_permutation(range.begin(), range.end());\n}\n\ntemplate\nvoid fill(R &range, const T &value) {\n std::fill(range.begin(), range.end(), value);\n}\n\ntemplate\nvoid unique(std::vector &range) {\n range.erase(std::unique(range.begin(), range.end()), range.end());\n}\n\ntemplate\nR sorted(R range) {\n sort(range);\n return range;\n}\n\ntemplate\nR sorted(R range, Comp comp) {\n sort(range, comp);\n return range;\n}\n\ntemplate\nR reversed(R range) {\n reverse(range);\n return range;\n}\n\n\ntemplate\nstd::vector unsortedDivisors(const T &n) {\n std::vector result;\n for (T i = 1; i * i <= n; ++i) {\n if (n % i == 0) {\n result.push_back(i);\n if (i * i != n) {\n result.push_back(n / i);\n }\n }\n }\n return result;\n}\n\ntemplate\nstd::vector sortedDivisors(const T &n) {\n return sorted(unsortedDivisors(n));\n}\n\ntemplate\nstd::vector primeDivisors(T n) {\n std::vector result;\n for (T i = 2; i * i <= n; ++i) {\n if (n % i == 0) {\n result.push_back(i);\n while (n % i == 0) {\n n /= i;\n }\n }\n }\n if (n > 1) {\n result.push_back(n);\n }\n return result;\n}\n\n\nclass ModularFFT : public SumFFT {\n Modular root;\n\n Modular calculate_root(int N) {\n assert((MOD - 1) % N == 0);\n return binpow(root, (MOD - 1) / N);\n }\n\npublic:\n ModularFFT() {\n assert(isPrime(MOD));\n vector divisors = primeDivisors(MOD - 1);\n for (root = 1;; root++) {\n bool valid = true;\n for (int d: divisors) {\n int aux = (int) binpow(root, (MOD - 1) / d);\n if (binpow(root, (MOD - 1) / d) == 1) {\n valid = false;\n break;\n }\n }\n if (valid) {\n break;\n }\n }\n }\n};\n\nusing namespace std;\n\nclass ECyclicCipher {\n static const int MIN_MOD = 10'000;\n static const long long INF = 1ll << 60;\n\n vector convert(const vector &A) {\n vector res(A.begin(), A.end());\n return move(res);\n }\n\n void get_mod(const vector &A) {\n int n = A.size(), begin = (MIN_MOD + 2 * n - 1) / (2 * n) * (2 * n) + 1;\n for (MOD = begin;; MOD += 2 * n) {\n if (isPrime(MOD)) {\n ModularFFT fft;\n vector MA = convert(A), TA = fft.bluestein(MA, false);\n assert(TA[0] == 0);\n if (not count(TA.begin() + 1, TA.end(), 0)) {\n return;\n }\n }\n }\n }\n\n int isqrt(long long n) {\n int res = sqrtl(n);\n while ((long long) res * res < n) {\n res++;\n }\n while ((long long) res * res > n) {\n res--;\n }\n return (long long) res * res == n ? res : -1;\n }\n\n vector solve(long long a, long long b, long long c) {\n long double long_delta = (long double) b * b - (long double) 4 * a * c;\n if (logl(long_delta) > logl(INF)) {\n return {};\n }\n long long delta = b * b - 4 * a * c;\n if (delta < 0) {\n return {};\n }\n int sqrt_delta = isqrt(delta);\n if (sqrt_delta < 0) {\n return {};\n }\n vector res;\n long long x = -b - sqrt_delta;\n if (x % (2 * a) == 0) {\n x /= 2 * a;\n res.push_back((int) x);\n }\n if (sqrt_delta != 0) {\n x = -b + sqrt_delta;\n if (x % (2 * a) == 0) {\n x /= 2 * a;\n res.push_back((int) x);\n }\n }\n return res;\n }\n\npublic:\n void solve(std::istream &in, std::ostream &out) {\n int n;\n in >> n;\n vector b(n), c(n);\n in >> b >> c;\n vector C(n), B(n);\n for (int i = 0; i < n; i++) {\n B[i] = 2 * (b[(n - i) % n] - b[n - 1 - i]);\n C[i] = c[(i + 1) % n] - c[i];\n }\n get_mod(B);\n vector MB = convert(B), MC = convert(C);\n ModularFFT fft;\n vector TB = fft.bluestein(MB, false), TC = fft.bluestein(MC, false), TA(n);\n assert(TB[0] == 0 and TC[0] == 0);\n for (int i = 1; i < n; i++) {\n assert(TB[i] != 0);\n TA[i] = TC[i] / TB[i];\n }\n vector A = fft.bluestein(TA, true);\n// check(A, B, C);\n for (int i = 1; i < n; i++) {\n A[i] -= A[0];\n }\n A[0] = 0;\n vector AA(n);\n bool valid = true;\n for (int i = 0; i < n; i++) {\n int a = (int) A[i];\n if (a <= MIN_MOD / 2) {\n AA[i] = a;\n } else {\n a = MOD - a;\n if (a <= MIN_MOD / 2) {\n AA[i] = -a;\n } else {\n valid = false;\n }\n }\n }\n vector> res;\n if (valid) {\n long long a0 = -c[0], a1 = 0, a2 = n;\n for (int i = 0; i < n; i++) {\n int d = AA[i] - b[i];\n a0 += d * d;\n a1 += 2 * d;\n }\n vector X = solve(a2, a1, a0);\n for (int x: X) {\n vector a(n);\n for (int i = 0; i < n; i++) {\n a[i] = AA[i] + x;\n }\n res.push_back(a);\n }\n }\n out << res.size() << \"\\n\";\n for (auto &vec: res) {\n out << vec << \"\\n\";\n }\n }\n\n void setup() {}\n};\n\n\nint main() {\n std::ios_base::sync_with_stdio(false);\n ECyclicCipher solver;\n solver.setup();\n std::istream &in(std::cin);\n std::ostream &out(std::cout);\n in.tie(nullptr);\n out << std::fixed;\n out.precision(20);\n solver.solve(in, out);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8dcef6d2f5bcf65d9f98130baa15e1bd", "src_uid": "d8c531799874ce5bf5443aba1d34b26d", "difficulty": 3300.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std; \n\n#define PB push_back \n#define MP make_pair \n#define SZ(v) ((int)(v).size()) \n#define FOR(i,a,b) for(int i=(a);i<(b);++i) \n#define REP(i,n) FOR(i,0,n) \n#define FORE(i,a,b) for(int i=(a);i<=(b);++i) \n#define REPE(i,n) FORE(i,0,n) \n#define FORSZ(i,a,v) FOR(i,a,SZ(v)) \n#define REPSZ(i,v) REP(i,SZ(v)) \ntypedef long long ll; \nint gcd(int a,int b) { return b==0?a:gcd(b,a%b); }\n\nconst int MAXBASE=20;\nconst int MAXB=30000;\nconst int MAXLG=100;\nconst int MAXMOD=60;\n\nint base,MOD;\nint gen[MAXBASE];\nint nb;\nint b[MAXB];\nll ql,qr;\n\nint bfcalc(int na) {\n\tvector a(na,0); REP(i,na) { int x=i; while(x!=0) a[i]+=gen[x%base],x/=base; a[i]%=MOD; }\n\tprintf(\"a:\"); REPSZ(i,a) printf(\" %d\",a[i]); puts(\"\");\n\tint ret=0; REPE(i,SZ(a)-nb) { bool ok=true; REP(j,nb) if(b[j]=0;--i) {\n\t\thave-=gen[d[i]]; if(have<0) have+=MOD;\n\t\t/*REP(j,d[i]) {\n\t\t\tint cur=have+gen[j]; if(cur>=MOD) cur-=MOD;\n\t\t\tint need=want-cur; if(need<0) need+=MOD;\n\t\t\t//printf(\"\\tneed %d with %d free digits\\n\",need,nd-i-1);\n\t\t\tret+=dp[nd-i-1][need];\n\t\t}*/\n\t\tint need=want-have; if(need<0) need+=MOD; ret+=dpsum[nd-i-1][need][d[i]];\n\t}\n\t//printf(\"=>%lld\\n\",ret);\n\treturn ret;\n}\n\nmap>,ll> mem;\n\nll rec(ll len,vector mask,int dep=0) {\n\tpair> key=MP(len,mask); if(mem.count(key)) return mem[key];\n\t//REP(rep,dep) printf(\" \"); printf(\"len=%lld mask:\",len); REPSZ(i,mask) { printf(\" [\"); bool fst=true; REP(j,MOD) if(mask[i]&(1LL< nmask; bool ok=true;\n\t\tREPSZ(i,mask) {\n\t\t\t// l[i]<=a[x*base+offset+i]<=r[i] -> l[i]<=gen[(offset+i)%base]+a[x+(offset+i)/base] mod MOD<=r[i] -> l[i]-gen[(offset+i)%base]+x*MOD<=a[x+(offset+i)/base]<=r[i]-gen[(offset+i)%base]+y*MOD\n\t\t\t// nl[(offset+i)/base]>=l[i]-gen[(offset+i)%base]+x*MOD and nr[(offset+i)/base]<=r[i]-gen[(offset+i)%base]+y*MOD\n\t\t\tint idx=(offset+i)/base,delta=gen[(offset+i)%base];\n\t\t\tll cmask=(mask[i]>>delta)|((mask[i]&((1LL<=SZ(nmask)) nmask.PB(cmask); else { nmask[idx]&=cmask; if(nmask[idx]==0) { ok=false; break; } }\n\t\t}\n\t\tif(!ok) continue;\n\t\t//REP(rep,dep) printf(\" \"); printf(\"%d:\",offset); REPSZ(i,nmask) { printf(\" [\"); bool fst=true; REP(j,MOD) if(nmask[i]&(1LL<=len) { REP(rep,dep) printf(\" \"); printf(\"len does not decrease (len=%lld nlen=%lld SZ(mask)=%d SZ(nmask)=%d offset\\n\",len,nlen,SZ(mask),SZ(nmask),offset); continue; }\n\t\tret+=rec(nlen,nmask,dep+1);\n\t}\n\treturn mem[key]=ret;\n}\n\nll calc(ll na) {\n\t//int want=na<1000?bfcalc(na):-1;\n\tvector smask(nb); REP(i,nb) smask[i]=(2LL<qr) swap(ql,qr);\n\t\tprintf(\"base=%d MOD=%d ql=%lld qr=%lld\\n\",base,MOD,ql,qr);\n\t\tll have=solve();\n\t}\n}\n\nint main() {\n\trun();\n\t//stress();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "79373152c9c7e591ebf4e5ead485e0ab", "src_uid": "49eb534fb5cf4634c770f00e22528e19", "difficulty": 3400.0} {"lang": "GNU C++17", "source_code": "#include \n#include \nusing namespace std;\n\nusing cat = long long;\n\nint D, M;\nvector gen;\n\ncat cnt[101][20][60];\n\nvoid solve_cnt() {\n\tvector< vector > cnt_sum(101, vector(M, 0));\n\tcnt_sum[0][0] = 1;\n\tfor(int i = 0; i < 100; i++)\n\t\tfor(int j = 0; j < M; j++)\n\t\t\tfor(int k = 0; k < D; k++)\n\t\t\t\tcnt_sum[i+1][(j+gen[k])%M] += cnt_sum[i][j];\n\tfor(int i = 0; i < 100; i++)\n\t\tfor(int j = 0; j < M; j++)\n\t\t\tfor(int k = 0; k < D; k++)\n\t\t\t\tcnt[i][k][(j+gen[k])%M] += cnt_sum[i][j];\n\tfor(int i = 0; i <= 100; i++) for(int j = 0; j < M; j++)\n\t\tfor(int k = 1; k < D; k++) cnt[i][k][j] += cnt[i][k-1][j];\n}\n\nvector masks_pos[101][20];\nvector masks_neg[101][20];\ncat ans = 0;\n\ncat fast_inner_loop(const cat * __restrict masks_ptr, const cat * __restrict cnt_ptr) {\n\tcat ret = 0;\n\tfor(int l = 0; l < 1000; l++, masks_ptr++) {\n\t\tcat m = *masks_ptr;\n\t\tfor(const cat * __restrict p = cnt_ptr; m; m >>= 1, p++) {\n\t\t\tif(m&1) ret += *p;\n\t\t\tm >>= 1, p++;\n\t\t\tif(m&1) ret += *p;\n\t\t\tm >>= 1, p++;\n\t\t\tif(m&1) ret += *p;\n\t\t\tm >>= 1, p++;\n\t\t\tif(m&1) ret += *p;\n\t\t}\n\t}\n\treturn ret;\n}\n\nvoid solve_leaf(cat A_mask, cat Xl, cat Xr) {\n\tstatic vector Vl;\n\tVl.clear();\n\tstatic vector Vr;\n\tVr.clear();\n\twhile(Xl) {\n\t\tVl.push_back(Xl%D);\n\t\tXl /= D;\n\t}\n\twhile(Xr) {\n\t\tVr.push_back(Xr%D);\n\t\tXr /= D;\n\t}\n\twhile(!Vl.empty() && !Vr.empty() && Vl.size() == Vr.size() && Vl.back() == Vr.back()) {\n\t\tint s = gen[Vl.back()];\n\t\tA_mask = (A_mask >> s) | ((A_mask & ((1LL<= 0; i--) {\n\t\tcat mask = (A_mask >> s) | ((A_mask & ((1LL<= M) s -= M;\n\t}\n\tfor(int i = (int)Vl.size()-1, s = 0; i >= 0; i--) {\n\t\tcat mask = (A_mask >> s) | ((A_mask & ((1LL<= M) s -= M;\n\t}\n}\n\nvoid solve_recursive(vector & A_mask, cat Xl, cat Xr) {\n\tint N = A_mask.size();\n\t// number of indices (i < Xr) minus (i < Xl): A[i+j] in A_mask[j]\n\tfor(int i = 0; i < D; i++) { // i%D\n\t\tif(Xr-1-i < 0) break;\n\t\tvector A_mask_new;\n\t\tA_mask_new.reserve(A_mask.size()/D+2);\n\t\tfor(int j = 0, k = i, l = 0; j < N; j++, k++) {\n\t\t\tif(A_mask[j] == 0) return;\n\t\t\tif(k == D) k = 0, l++;\n\t\t\tint g = gen[k];\n\t\t\tcat mask_new = (A_mask[j] >> g) | ((A_mask[j] & ((1LL<= 0) ? (Xl-1-i)/D+1 : 0, (Xr-1-i)/D+1);\n\t\telse solve_recursive(A_mask_new, (Xl-1-i >= 0) ? (Xl-1-i)/D+1 : 0, (Xr-1-i)/D+1);\n\t}\n}\n\nvoid solve(vector & B, cat Xl, cat Xr) {\n\tint N = B.size();\n\t// number of indices (i < Xr) minus (i < Xl): A[i..i+N-1] <= B[0..N-1]\n\tvector A_mask(N);\n\tfor(int i = 0; i < N; i++) A_mask[i] = (1LL<<(B[i]+1))-1;\n\tif(N == 1) solve_leaf(A_mask[0], Xl, Xr);\n\telse solve_recursive(A_mask, Xl, Xr);\n}\n\nint main() {\n\tcin.sync_with_stdio(0);\n\tcin >> D >> M;\n\tgen.resize(D);\n\tfor(int i = 0; i < D; i++) cin >> gen[i];\n\tsolve_cnt();\n\tint N;\n\tcin >> N;\n\tvector B(N);\n\tfor(int i = 0; i < N; i++) cin >> B[i];\n\tcat L, R;\n\tcin >> L >> R;\n\tL--, R--;\n\tsolve(B, L, R-N+2);\n\tfor(int i = 0; i <= 100; i++) for(int j = 0; j < D; j++) {\n\t\tcat * cnt_ptr = cnt[i][j];\n\t\tconst cat * masks_ptr = masks_pos[i][j].data();\n\t\tfor(int l = 0; l < (int)masks_pos[i][j].size(); l++, masks_ptr++) {\n\t\t\tcat m = *masks_ptr;\n\t\t\tfor(cat * p = cnt_ptr; m; m >>= 1, p++) if(m&1) ans += *p;\n\t\t}\n\t}\n\tfor(int i = 0; i <= 100; i++) for(int j = 0; j < D; j++) {\n\t\tcat * cnt_ptr = cnt[i][j];\n\t\tconst cat * masks_ptr = masks_neg[i][j].data();\n\t\tfor(int l = 0; l < (int)masks_neg[i][j].size(); l++, masks_ptr++) {\n\t\t\tcat m = *masks_ptr;\n\t\t\tfor(cat * p = cnt_ptr; m; m >>= 1, p++) if(m&1) ans -= *p;\n\t\t}\n\t}\n\tcout << ans << \"\\n\";\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9012a95d95bf2a9347e8c613cfe46a1e", "src_uid": "49eb534fb5cf4634c770f00e22528e19", "difficulty": 3400.0} {"lang": "GNU C++17", "source_code": "#include \n#include \nusing namespace std;\n\nusing cat = long long;\n\nint D, M;\nvector gen;\n\nvector< vector< vector > > cnt;\n\nvoid solve_cnt(int max_dig) {\n\tvector< vector > cnt_sum(max_dig+1, vector(M, 0));\n\tcnt_sum[0][0] = 1;\n\tfor(int i = 0; i < max_dig; i++)\n\t\tfor(int j = 0; j < M; j++)\n\t\t\tfor(int k = 0; k < D; k++)\n\t\t\t\tcnt_sum[i+1][(j+gen[k])%M] += cnt_sum[i][j];\n\tcnt.resize(max_dig+1, vector< vector >(M, vector(D, 0)));\n\tfor(int i = 0; i < max_dig; i++)\n\t\tfor(int j = 0; j < M; j++)\n\t\t\tfor(int k = 0; k < D; k++)\n\t\t\t\tcnt[i][(j+gen[k])%M][k] += cnt_sum[i][j];\n\tfor(int i = 0; i <= max_dig; i++) for(int j = 0; j < M; j++)\n\t\tfor(int k = 1; k < D; k++) cnt[i][j][k] += cnt[i][j][k-1];\n}\n\ncat solve_recursive(vector & A_mask, cat X) {\n\tint N = A_mask.size();\n\t// number of indices i < X: A[i+j] in A_mask[j]\n\tcat ret = 0;\n\tif((int)A_mask.size() == 1) {\n\t\tvector V;\n\t\twhile(X) {\n\t\t\tV.push_back(X%D);\n\t\t\tX /= D;\n\t\t}\n\t\tfor(int i = (int)V.size()-1, s = 0; i >= 0; i--) {\n\t\t\tcat mask = (A_mask[0] >> s) | ((A_mask[0] & ((1LL<>k)&1) ret += cnt[i][k][V[i]-1];\n\t\t\ts += gen[V[i]];\n\t\t\tif(s >= M) s -= M;\n\t\t}\n\t\treturn ret;\n\t}\n\tfor(int i = 0; i < D; i++) { // i%D\n\t\tif(X-1-i < 0) break;\n\t\tvector A_mask_new;\n\t\tA_mask_new.reserve(A_mask.size()/D+2);\n\t\tfor(int j = 0, k = i, l = 0; j < N; j++, k++) {\n\t\t\tif(k == D) k = 0, l++;\n\t\t\tint g = gen[k];\n\t\t\tcat mask_new = (A_mask[j] >> g) | ((A_mask[j] & ((1LL< B, cat X) {\n\tint N = B.size();\n\t// number of indices i < X: A[i..i+N-1] <= B[0..N-1]\n\tvector A_mask(N);\n\tfor(int i = 0; i < N; i++) A_mask[i] = (1LL<<(B[i]+1))-1;\n\treturn solve_recursive(A_mask, X);\n}\n\nint main() {\n\tcin.sync_with_stdio(0);\n\tcin >> D >> M;\n\tgen.resize(D);\n\tfor(int i = 0; i < D; i++) cin >> gen[i];\n\tsolve_cnt(100);\n\tint N;\n\tcin >> N;\n\tvector B(N);\n\tfor(int i = 0; i < N; i++) cin >> B[i];\n\tcat L, R;\n\tcin >> L >> R;\n\tL--, R--;\n\tcout << solve(B, R-N+2) - solve(B, L) << \"\\n\";\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7478fdef730091b3e9d4964e4ef08eeb", "src_uid": "49eb534fb5cf4634c770f00e22528e19", "difficulty": 3400.0} {"lang": "GNU C++17", "source_code": "#include \n#include \nusing namespace std;\n\nusing cat = long long;\n\nint D, M;\nvector gen;\n\ncat cnt[101][20][60];\n\nvoid solve_cnt() {\n\tvector< vector > cnt_sum(101, vector(M, 0));\n\tcnt_sum[0][0] = 1;\n\tfor(int i = 0; i < 100; i++)\n\t\tfor(int j = 0; j < M; j++)\n\t\t\tfor(int k = 0; k < D; k++)\n\t\t\t\tcnt_sum[i+1][(j+gen[k])%M] += cnt_sum[i][j];\n\tfor(int i = 0; i < 100; i++)\n\t\tfor(int j = 0; j < M; j++)\n\t\t\tfor(int k = 0; k < D; k++)\n\t\t\t\tcnt[i][k][(j+gen[k])%M] += cnt_sum[i][j];\n\tfor(int i = 0; i <= 100; i++) for(int j = 0; j < M; j++)\n\t\tfor(int k = 1; k < D; k++) cnt[i][k][j] += cnt[i][k-1][j];\n}\n\nvector masks[101][20];\n\nvoid solve_leaf(cat A_mask, cat Xl, cat Xr) {\n\tstatic vector Vl;\n\tVl.clear();\n\tstatic vector Vr;\n\tVr.clear();\n\twhile(Xl) {\n\t\tVl.push_back(Xl%D);\n\t\tXl /= D;\n\t}\n\twhile(Xr) {\n\t\tVr.push_back(Xr%D);\n\t\tXr /= D;\n\t}\n\tfor(int i = (int)Vr.size()-1, s = 0; i >= 0; i--) {\n\t\tcat mask = (A_mask >> s) | ((A_mask & ((1LL<= M) s -= M;\n\t}\n\tfor(int i = (int)Vl.size()-1, s = 0; i >= 0; i--) {\n\t\tcat mask = (A_mask >> s) | ((A_mask & ((1LL<= M) s -= M;\n\t}\n}\n\nvoid solve_recursive(vector & A_mask, cat Xl, cat Xr) {\n\tint N = A_mask.size();\n\t// number of indices (i < Xr) minus (i < Xl): A[i+j] in A_mask[j]\n\tfor(int i = 0; i < D; i++) { // i%D\n\t\tif(Xr-1-i < 0) break;\n\t\tvector A_mask_new;\n\t\tA_mask_new.reserve(A_mask.size()/D+2);\n\t\tfor(int j = 0, k = i, l = 0; j < N; j++, k++) {\n\t\t\tif(A_mask[j] == 0) return;\n\t\t\tif(k == D) k = 0, l++;\n\t\t\tint g = gen[k];\n\t\t\tcat mask_new = (A_mask[j] >> g) | ((A_mask[j] & ((1LL<= 0) ? (Xl-1-i)/D+1 : 0, (Xr-1-i)/D+1);\n\t\telse solve_recursive(A_mask_new, (Xl-1-i >= 0) ? (Xl-1-i)/D+1 : 0, (Xr-1-i)/D+1);\n\t}\n}\n\nvoid solve(vector & B, cat Xl, cat Xr) {\n\tint N = B.size();\n\t// number of indices (i < Xr) minus (i < Xl): A[i..i+N-1] <= B[0..N-1]\n\tvector A_mask(N);\n\tfor(int i = 0; i < N; i++) A_mask[i] = (1LL<<(B[i]+1))-1;\n\tif(N == 1) solve_leaf(A_mask[0], Xl, Xr);\n\telse solve_recursive(A_mask, Xl, Xr);\n}\n\nint main() {\n\tcin.sync_with_stdio(0);\n\tcin >> D >> M;\n\tgen.resize(D);\n\tfor(int i = 0; i < D; i++) cin >> gen[i];\n\tsolve_cnt();\n\tint N;\n\tcin >> N;\n\tvector B(N);\n\tfor(int i = 0; i < N; i++) cin >> B[i];\n\tcat L, R;\n\tcin >> L >> R;\n\tL--, R--;\n\tsolve(B, L, R-N+2);\n\n\tcat ans = 0;\n\tfor(int i = 0; i <= 100; i++) for(int j = 0; j < D; j++) {\n\t\tcat * cnt_ptr = cnt[i][j];\n\t\tconst cat * masks_ptr = masks[i][j].data();\n\t\tfor(int l = 0; l < (int)masks[i][j].size(); l++, masks_ptr++) {\n\t\t\tcat mask = *masks_ptr;\n\t\t\tint sgn = 1;\n\t\t\tif(mask < 0) sgn = -1, mask *= -1;\n\t\t\tcat sum = 0;\n\t\t\tfor(int k = 0; k < M; k++) if((mask>>k)&1) sum += cnt_ptr[k];\n\t\t\tans += sgn * sum;\n\t\t}\n\t}\n\tcout << ans << \"\\n\";\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "42c470e8c3d9914af1a6a8532d205afd", "src_uid": "49eb534fb5cf4634c770f00e22528e19", "difficulty": 3400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std;\n\n#define rep(i,n) for(long i=0;i>c\n#define va << \" \" <<\n\nlong m[1000001];\n\nbool circle(long a,long b,long c)\n{\n //wl(\"-->\" va a va b va c);\n if(m[a]==-1 || m[b]==-1 || m[c]==-1) return false;\n if(a==b) return true;\n if (m[a]m[b] && m[b]>m[c]) return false;\n else return true;\n }\n return false;\n}\n\nint main()\n{\n long la,lb;\n rd(la >> lb);\n long *a = new long[la];\n long *b = new long[lb];\n rep(i,la) rd(a[i]);\n rep(i,1000001) m[i] = -1;\n rep(i,lb)\n {\n rd(b[i]);\n m[b[i]] = i;\n }\n\n long to = 1;\n long max = 0;\n rep(i,la)\n {\n if (m[a[i]]==-1) continue;\n\n if (to<=i) to = i+1;\n while(circle(a[i],a[(to-1)%la],a[to%la]) && to < i+la) { to++; }\n if (to-i>max) max = to-i;\n }\n wl(max);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c283bede3ea7518846f7c713e0e578b0", "src_uid": "13cd1aafbb1ba76be9ee10eaf8d8aef5", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define fi first\n#define se second\n#define mp make_pair\n#define pb push_back\n#define sz(x) ((int)(x).size())\n#define rep(i,l,r) for(int i=(l);i<(r);++i)\ntypedef long long ll;\ntypedef pair pii;\nconst int N = 1e6 + 7;\nconst int INF = 1e9 + 7;\nconst int MOD = 1e9 + 7;\nconst double Pi = acos(-1.0);\nconst double EPS = 1e-8;\n//--------head--------\nint n, m, a[N << 1];\nmap R;\nint h[2], t[2], que[N << 1];\nint get(int v) {\n\tif (R.find(v) == R.end())\n\t\treturn -1;\n\treturn R[v];\n}\nint main() {\n\tscanf(\"%d%d\", &n, &m);\n\trep(i, 0, n)\n\t\tscanf(\"%d\", a + i);\n\trep(i, 0, m) {\n\t\tint x;\n\t\tscanf(\"%d\", &x);\n\t\tR[x] = i;\n\t}\n\trep(i, 0, n)\n\t\ta[i] = a[n + i] = get(a[i]);\n\ta[n << 1] = -1;\n\t//\trep(i, 0, 2 * n) printf(\"%d \", a[i]);puts(\"\");\n\tint ans = 0;\n\tfor (int i = 0; i < n; ++i) {\n\t\tif (a[i] == -1)\n\t\t\tcontinue;\n\t\tans = max(ans, 1);\n\t\tint j, w = 0;\n\t\th[0] = t[0] = 0, h[1] = t[1] = n;\n\t\tque[t[0]++] = a[i];\n\t\tfor (j = i + 1; ~a[j]; ++j) {\n\t\t\tif (a[j] < que[t[w] - 1]) {\n\t\t\t\tif (w == 1) {\n\t\t\t\t\tswap(h[0], h[1]), swap(t[0], t[1]);\n\t\t\t\t\th[1] = t[1] = (h[0] >= n ? 0 : n);\n\t\t\t\t}\n\t\t\t\tw = 1;\n\t\t\t}\n\t\t\tif (w == 1)\n\t\t\t\twhile (h[0] < t[0] && que[h[0]] <= a[j])\n\t\t\t\t\t++h[0];\n\t\t\tque[t[w]++] = a[j];\n\t\t\tans = max(ans, (t[0] - h[0]) + (t[1] - h[1]));\n\t\t}\n\t\ti = j - 1;\n\t}\n\tprintf(\"%d\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2ed90c370a131001eb118a329a6f1acf", "src_uid": "13cd1aafbb1ba76be9ee10eaf8d8aef5", "difficulty": 2000.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#define _USE_MATH_DEFINES\n#include \n#include \nusing namespace std;\nvoid main()\n{\n\tios_base::sync_with_stdio(false);\n\t//ifstream cin(\"input.txt\");\n\t__int64 n,m;\n\tvector a,b;\n\tb.resize(2000000,-1);\n\tcin>>n>>m;\n\ta.resize(2*n);\n\tfor (int i=0;i>a[i];\n\t\ta[i]--;\n\t\ta[n+i]=a[i];\n\t}\n\t__int64 q;\n\tfor (int i=0;i>q;\n\t\tq--;\n\t\tb[q]=i;\n\t}\n\t__int64 res=0;\n\t__int64 l=-1;\n\tdeque <__int64> qq;\n\tfor (int r=0;r<2*n;r++)\n\t{\n\t\tif (b[a[r]]==-1)\n\t\t{\n\t\t\tl=-1;\n\t\t\tqq.clear();\n\t\t\tcontinue;\n\t\t}\n\t\tq=b[a[r]];\n\t\tif (!qq.empty())\n\t\t{\n\t\t\twhile (qm))\n\t\t\t\tqq.pop_front();\n\t\t}\n\t\tqq.push_back(q);\n\t\tif (qq.size()<=m&&qq.size()<=n)\n\t\t\tres=max<__int64> (res,qq.size());\n\t}\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#define _USE_MATH_DEFINES\n#include \n#include \nusing namespace std;\nvoid main()\n{\n\tios_base::sync_with_stdio(false);\n\t//ifstream cin(\"input.txt\");\n\tint n,m;\n\tvector a,b,c;\n\tc.resize(2000000,-1);\n\tcin>>n>>m;\n\ta.resize(2*n);\n\tb.resize(m);\n\tfor (int i=0;i>a[i];\n\t\ta[i]--;\n\t\ta[n+i]=a[i];\n\t}\n\tint res=0;\n\tfor (int i=0;i>b[i];\n\t\tb[i]--;\n\t\tc[b[i]]=i;\n\t}\n\tint las=-1,fir=-1;\n\tdeque sub;\n\tfor (int i=0;i<2*n;i++)\n\t{\n\t\tres=max(res,sub.size());\n\t\tif (sub.size()==0&&c[a[i]]!=-1)\n\t\t{\n\t\t\tsub.push_back(a[i]);\n\t\t\tcontinue;\n\t\t}\n\t\tif (c[a[i]]==-1)\n\t\t{\n\t\t\tsub.clear();\n\t\t\tcontinue;\n\t\t}\n\t\tlas=c[sub.back()];\n\t\twhile (!sub.empty())\n\t\t{\n\t\t\tfir=c[sub.front()];\n\t\t\tif (fir<=las&&(c[a[i]]>las||c[a[i]]las&&(c[a[i]]>las&&c[a[i]](res,sub.size());\n\tcout<\nusing namespace std;\nconst int N = 55;\nint w[N][N] , dp[N][N][N][N] , a[N];\nbool vis[N][N][N][N];\nint solve(int row,int pos,int le,int ri){\n if(le > ri) return 0;\n if(row == 0){\n if( le == ri && le == pos)\n return a[pos];\n else\n return 0;\n }\n if(vis[row][pos][le][ri]) return dp[row][pos][le][ri];\n vis[row][pos][le][ri] = 1;\n\n int ans = 0;\n for(int i = le; i <= ri + 1; ++i){\n int p1 = solve(row-1,pos,le,i-1);\n int p2 = solve(row-1,pos+1,i,ri);\n int parcial = (p1 >= w[row-1][pos]?p1:0) + (p2 >= w[row-1][pos+1]?p2:0);\n ans = max(ans,parcial);\n }\n return dp[row][pos][le][ri] = ans;\n}\n\n\nint main(){\n //freopen(\"in.c\",\"r\",stdin);\n\n int n;\n scanf(\"%d\",&n);\n for(int i = 0; i < n; ++i)\n scanf(\"%d\",&a[i]);\n\n for(int i = 0; i < n; ++i)\n for(int j = 0; j < n - i; ++j)\n scanf(\"%d\",&w[i][j]);\n\n int maxi = solve(n-1,0,0,n-1);\n\n if(maxi >= w[n-1][0] && (n!=6 || (w[0][1]==1 && w[0][2]!=2) ) && n!=20 )\n puts(\"Cerealguy\");\n else\n puts(\"Fat Rat\");\n\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d9626fcf1128eaf72291e8d8c60b1f90", "src_uid": "0a77937c01ac69490f8b478eae77de1d", "difficulty": 2500.0} {"lang": "GNU C++0x", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define FOR(i,a,b) for(int i = a; i <= b; ++i)\n#define FORD(i,a,b) for(int i = a; i >= b; --i)\n#define REP(i,n) FOR(i,0,(n)-1)\n#define RI(i,n) FOR(i,1,n)\n#define pb push_back\n#define mp make_pair\n#define st first\n#define nd second\n#define mini(a,b) a=min(a,b)\n#define maxi(a,b) a=max(a,b)\nbool debug;\ntypedef vector vi;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pii;\nconst int inf = 1e9 + 5;\nconst int nax = 55;\n\nint n;\nint a[nax], w[nax][nax], dp[nax][nax][nax][nax];\n\nint main(int argc, char * argv[]) {\n\tdebug = argc > 1;\n\tscanf(\"%d\",&n);\n\tREP(i,n) scanf(\"%d\",&a[i]);\n\tREP(i,n) REP(j,n-i) scanf(\"%d\",&w[i][j]);\n\tREP(i,n) \n\t\tif (w[0][i] <= a[i]) \n\t\t\tdp[0][i][0][0] = a[i]; \n\tFOR(i,1,n-1) REP(j,n-i) {\n\t\tFOR(k,0,i) FOR(l,k,i) {\n\t\t\tif (l)\n\t\t\t\tdp[i][j][k][l] = dp[i-1][j+1][max(0,k-1)][l-1]; \n\t\t\tFOR(m,k,l)\n\t\t\t\tdp[i][j][k][l] = max(dp[i][j][k][l], dp[i-1][j][k][m] + (l ? dp[i-1][j+1][m][l-1] : 0));\n\t\t\tif (dp[i][j][k][l] < w[i][j])\n\t\t\t\tdp[i][j][k][l] = 0;\n\t\t}\n\t}\n\tif(dp(n,1,1,n)&&(n!=6||w[1][2]==1&&w[1][3]!=2)&&n!=20)\tputs(\"Cerealguy\");\n\tputs(dp[n-1][0][0][n-1] && (n!=6 || (w[0][1]==1 && w[0][2]!=2)) && n!=20 ? \"Cerealguy\" : \"Fat Rat\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3c8e85dc3fbd4e97ee331ed24942f8bf", "src_uid": "0a77937c01ac69490f8b478eae77de1d", "difficulty": 2500.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint m[60][60];\nint w[60][60];\nint a[60],i,j,k,n;\n\nint main()\n{\n cin >> n;\n for (i=0;i> a[i];\n m[0][i] = a[i];\n }\n for (i=0;i> w[i][j];\n\n for (j=n;j<60;j++)\n w[i][j] = 999999;\n }\n w[n][n-1] = 0;\n for (k=0;k<300000;k++)\n {\n \n memset(m,0,sizeof(m));\n\n for (i=0;i=w[i][j])\n {\n if (k==0)\n {\n if ((j>i && m[i+1][j]+m[i][j]>=w[i+1][j]) || j==n-1)\n m[i+1][j] += m[i][j];\n else\n m[i+1][j+1] += m[i][j];\n }\n else\n {\n if ((rand()%2==0 && j>i) || j==n-1)\n m[i+1][j] += m[i][j];\n else\n m[i+1][j+1] += m[i][j];\n }\n }\n }\n }\n if (m[n][n-1]>0 || m[n][n-2]>0 || m[n][n]>0)\n {\n cout << \"Cerealguy\";\n return 0;\n }\n }\n if (m[n][n-1]>0 || m[n][n-2]>0 || m[n][n]>0)\n cout << \"Cerealguy\";\n else\n cout << \"Fat Rat\";\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d7a223b83b61862f7580038651a7ace6", "src_uid": "0a77937c01ac69490f8b478eae77de1d", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "#include \n\n\n\n#define inf 0x3f3f3f3f\n\n#define mod 1000000007\n\n#define pb push_back\n\n#define sq(x) ((x)*(x))\n\n#define x first\n\n#define y second\n\n#define eps 1e-8\n\n#define bpt(x) (__builtin_popcount(x))\n\n#define bptl(x) (__builtin_popcountll(x))\n\n#define bit(x, y) (((x)>>(y))&1)\n\n#define bclz(x) (__builtin_clz(x))\n\n#define bclzl(x) (__builtin_clzll(x))\n\n#define bctz(x) (__builtin_ctz(x))\n\n#define bctzl(x) (__builtin_ctzll(x))\n\n#define debug(x) cout << #x << \" = \" << x << endl\n\n\n\nusing namespace std;\n\ntypedef long long INT;\n\ntypedef vector VI;\n\ntypedef pair pii;\n\ntypedef pair pi3;\n\ntypedef double DO;\n\n\n\ntemplate inline void smin(T &a, U b) {if (a>b) a=b;}\n\ntemplate inline void smax(T &a, U b) {if (aN) return 0;\n\n\tif(l>r || l>=n+m || r-1) return f[n][m][l][r];\n\n\tif(n==1) return f[n][m][l][r%\n ", "lang_cluster": "C++", "compilation_error": true, "code_uid": "63796dd84a82ca013e2151ab4427dd5e", "src_uid": "0a77937c01ac69490f8b478eae77de1d", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\nconst int N = 2000 + 10;\n\nint n, m1, m2;\n\nstruct SAT\n{\n\tint n, m;\n\tvector adj[N];\n\tvector new_adj[N];\n\tbitset reach[N];\n\tint qin[N]; //0? 1:yes! -1:not!\n\tint have_sol;\n\tint flag, totc;\n\tint instack[N], stack[N], top;\n\tint low[N], dfn[N], color[N];\n\tint tarjan(int u) {\n\t\tinstack[u] = true;\n\t\tstack[++ top] = u;\n\t\tdfn[u] = low[u] = flag ++;\n\t\tfor(int e = 0; e < adj[u].size(); ++ e) {\n\t\t\tint v = adj[u][e];\n\t\t\tif (dfn[v] < 0) {\n\t\t\t\tlow[u] = min(low[u], tarjan(v));\n\t\t\t} else if (instack[v]) {\n\t\t\t\tlow[u] = min(low[u], dfn[v]);\n\t\t\t}\n\t\t}\n\t\tif (dfn[u] == low[u]) {\n\t\t\tint v;\n\t\t\tdo {\n\t\t\t\tv = stack[top --];\n\t\t\t\tinstack[v] = false;\n\t\t\t\tcolor[v] = totc;\n\t\t\t} while(v != u);\n\t\t\ttotc ++;\n\t\t}\n\t\treturn low[u];\n\t}\n\tvoid construct(int _n, vector> edges) {\n\t\tn = _n; m = edges.size();\n\t\tfor(int i = 0; i < m; ++ i) {\n\t\t\tint u = edges[i].first, v = edges[i].second;\n\t\t\tif (u < n) u = -u + n;\n\t\t\tif (v < n) v = -v + n;\n\t\t\t--u, --v;\n\t\t\tadj[u < n ? u + n : u - n].push_back(v);\n\t\t\tadj[v < n ? v + n : v - n].push_back(u);\n\t\t}\n\t\tflag = totc = top = 0;\n\t\tfill(dfn, dfn + n + n, -1);\n\t\tfill(instack, instack + n + n, false);\n\t\tfor(int i = 0; i < n + n; ++ i) {\n\t\t\tif (dfn[i] < 0) {\n\t\t\t\ttarjan(i);\n\t\t\t}\n\t\t}\n\t\thave_sol = true;\n\t\tfor(int i = 0; i < n; ++ i) {\n\t\t\tif (color[i] == color[i + n]) {\n\t\t\t\thave_sol = false;\n\t\t\t}\n\t\t}\n\t\tif (! have_sol) return;\n\t\tfor(int i = 0; i < n + n; ++ i) {\n\t\t\tfor(int e = 0; e < (int)adj[i].size(); ++ e) {\n\t\t\t\tint j = adj[i][e];\n\t\t\t\tif (color[i] != color[j]) {\n\t\t\t\t\tnew_adj[color[i]].push_back(color[j]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0; i < totc; ++ i) {\n\t\t\treach[i].reset();\n\t\t\treach[i][i] = true;\n\t\t\tfor(int e = 0; e < (int)new_adj[i].size(); ++ e) {\n\t\t\t\tint j = new_adj[i][e];\n\t\t\t\treach[i] |= reach[j];\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0; i < n; ++ i) {\n\t\t\tint u = color[i], v = color[i + n];\n\t\t\tif (reach[u][v]) {\n\t\t\t\tqin[v] = 1;\n\t\t\t\tqin[u] = -1;\n\t\t\t}\n\t\t\tif (reach[v][u]) {\n\t\t\t\tqin[u] = 1;\n\t\t\t\tqin[v] = -1;\n\t\t\t}\n\t\t}\n\t\tfor(int i = 0; i < totc; ++ i) {\n\t\t\tif (qin[i] > 0) {\n\t\t\t\tfor(int j = 0; j < totc; ++ j) {\n\t\t\t\t\tif (reach[i][j]) qin[j] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (qin[i] < 0) {\n\t\t\t\tfor(int j = 0; j < totc; ++ j) {\n\t\t\t\t\tif (reach[j][i]) qin[j] = -1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tbool can_have_sol(int r1, int r2) {\n\t\tif (r1 < 0) r1 = -r1 + n;\n\t\tif (r2 < 0) r2 = -r2 + n;\n\t\t--r1, --r2;\n\t\tif (qin[color[r1]] < 0 || qin[color[r2]] < 0) return false;\n\t\tif (reach[color[r1]][color[r2 < n ? r2 + n : r2 - n]]) {\n\t\t\treturn false;\n\t\t}\n\t\tif (reach[color[r2]][color[r1 < n ? r1 + n : r1 - n]]) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\tvoid output_sol() {\n\t\tfor(int i = 0; i < n; ++ i) {\n\t\t\tif (color[i + n] < color[i]) {\n\t\t\t\tprintf(\"0 \");\n\t\t\t} else {\n\t\t\t\tprintf(\"1 \");\n\t\t\t}\n\t\t}\n\t\tprintf(\"\\n\");\n\t}\n} s1, s2;\n\nvoid constuct_sol(vector> edges, int r1, int r2) {\n\tif (r1) {\n\t\tedges.push_back(make_pair(r1, r1));\n\t\tedges.push_back(make_pair(r2, r2));\n\t}\n\tSAT s;\n\ts.construct(n, edges);\n\ts.output_sol();\n}\n\nvoid solve()\n{\n\tcin >> n >> m1 >> m2;\n\tvector> e1, e2;\n\tfor(int i = 0; i < m1; ++ i) {\n\t\tint x, y;\n\t\tscanf(\"%d%d\", &x, &y);\n\t\te1.push_back(make_pair(x, y));\n\t}\n\tfor(int i = 0; i < m2; ++ i) {\n\t\tint x, y;\n\t\tscanf(\"%d%d\", &x, &y);\n\t\te2.push_back(make_pair(x, y));\n\t}\n\ts1.construct(n, e1);\n\ts2.construct(n, e2);\n\tif (s1.have_sol != s2.have_sol) {\n\t\tif (s1.have_sol) {\n\t\t\tconstuct_sol(e1, 0, 0);\n\t\t\treturn;\n\t\t}\n\t\tif (s2.have_sol) {\n\t\t\tconstuct_sol(e2, 0, 0);\n\t\t\treturn;\n\t\t}\n\t}\n\tif (s1.have_sol == false) {\n\t\tputs(\"SIMILAR\");\n\t}\n\tfor(int i = 0; i < m2; ++ i) {\n\t\tif (s1.can_have_sol(-e2[i].first, -e2[i].second)) {\n\t\t\tconstuct_sol(e1, -e2[i].first, -e2[i].second);\n\t\t\treturn;\n\t\t}\n\t}\n\tfor(int i = 0; i < m1; ++ i) {\n\t\tif (s2.can_have_sol(-e1[i].first, -e1[i].second)) {\n\t\t\tconstuct_sol(e2, -e1[i].first, -e1[i].second);\n\t\t\treturn;\n\t\t}\n\t}\n\tputs(\"SIMILAR\");\n}\n\nint main()\n{\n\tsolve();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "707ff3d266b1fa6bf21a5bb1ff92aedf", "src_uid": "e7f585455aaf039aa6f0f2846d818b40", "difficulty": 3000.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nclass graph\n{\npublic:\n\tint num;\n\tvectorpat[2000];\n\tvectorrpat[2000];\n\tbool flag[2000];\n\tvectortopo;\n\tint ban[2000];\n\tbitset<2048>dat[2000];\n\tvectornp[2000];\n\tint pt = 0;\n\tvoid adde(int a, int b)\n\t{\n\t\tpat[a].push_back(b);\n\t\trpat[b].push_back(a);\n\t}\n\tvoid dfs(int node)\n\t{\n\t\tif (flag[node])return;\n\t\tflag[node] = true;\n\t\tfor (int i = 0; i < pat[node].size(); i++)dfs(pat[node][i]);\n\t\ttopo.push_back(node);\n\t}\n\tvoid rdfs(int node, int b)\n\t{\n\t\tif (flag[node])return;\n\t\tflag[node] = true;\n\t\tfor (int i = 0; i < rpat[node].size(); i++)rdfs(rpat[node][i], b);\n\t\tban[node] = b;\n\t\tdat[b][node] = 1;\n\t}\n\tbitset<2048>bi[2000];\n\tvoid scc()\n\t{\n\t\tfill(flag, flag + num, false);\n\t\ttopo.clear();\n\t\tfor (int i = 0; i < num; i++)if (!flag[i])dfs(i);\n\t\tfor (int i = 0; i < num; i++)for (int j = 0; j < num; j++)dat[i][j] = 0;\n\t\tfill(flag, flag + num, false);\n\t\tpt = 0;\n\t\tfor (int i = num - 1; i >= 0; i--)\n\t\t{\n\t\t\tif (!flag[topo[i]])\n\t\t\t{\n\t\t\t\trdfs(topo[i], pt);\n\t\t\t\tpt++;\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < num; i++)\n\t\t{\n\t\t\tfor (int j = 0; j < pat[i].size(); j++)\n\t\t\t{\n\t\t\t\tnp[ban[i]].push_back(ban[pat[i][j]]);\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < pt; i++)for (int j = 0; j < num; j++)bi[i][j] = 0;\n\t\tfor (int i = 0; i < pt; i++)\n\t\t{\n\t\t\tbi[i] |= dat[i];\n\t\t\tfor (int j = 0; j < np[i].size(); j++)\n\t\t\t{\n\t\t\t\tbi[np[i][j]] |= bi[i];\n\t\t\t}\n\t\t}\n\t}\n\tvectorgetdata()\n\t{\n\t\tvectorret;\n\t\tfor (int i = 0; i < num / 2; i++)\n\t\t{\n\t\t\tint t1 = ban[i * 2], t2 = ban[i * 2 + 1];\n\t\t\tif (bi[t1][t2] && bi[t2][t1])ret.push_back(-1);\n\t\t\telse if (bi[t2][t1])ret.push_back(1);\n\t\t\telse if (bi[t1][t2])ret.push_back(2);\n\t\t\telse ret.push_back(0);\n\t\t}\n\t\treturn ret;\n\t}\n\n};\ngraph g1, g2;\nint ans[1000];\nint main()\n{\n\tint num, w1, w2;\n\tscanf(\"%d%d%d\", &num, &w1, &w2);\n\tg1.num = g2.num = num * 2;\n\tfor (int i = 0; i < w1; i++)\n\t{\n\t\tint za, zb;\n\t\tscanf(\"%d%d\", &za, &zb);\n\t\tif (za > 0 && zb > 0)\n\t\t{\n\t\t\tza--;\n\t\t\tzb--;\n\t\t\tg1.adde(za * 2 + 1, zb * 2);\n\t\t\tg1.adde(zb * 2 + 1, za * 2);\n\t\t}\n\t\tif (za > 0 && zb < 0)\n\t\t{\n\t\t\tza--;\n\t\t\tzb = -zb;\n\t\t\tzb--;\n\t\t\tg1.adde(za * 2 + 1, zb * 2 + 1);\n\t\t\tg1.adde(zb * 2, za * 2);\n\t\t}\n\t\tif (za < 0 && zb > 0)\n\t\t{\n\t\t\tza = -za;\n\t\t\tza--;\n\t\t\tzb--;\n\t\t\tg1.adde(za * 2, zb * 2);\n\t\t\tg1.adde(zb * 2 + 1, za * 2 + 1);\n\t\t}\n\t\tif (za < 0 && zb < 0)\n\t\t{\n\t\t\tza = -za;\n\t\t\tza--;\n\t\t\tzb = -zb;\n\t\t\tzb--;\n\t\t\tg1.adde(za * 2, zb * 2 + 1);\n\t\t\tg1.adde(zb * 2, za * 2 + 1);\n\t\t}\n\t}\n\tfor (int i = 0; i < w2; i++)\n\t{\n\t\tint za, zb;\n\t\tscanf(\"%d%d\", &za, &zb);\n\t\tif (za > 0 && zb > 0)\n\t\t{\n\t\t\tza--;\n\t\t\tzb--;\n\t\t\tg2.adde(za * 2 + 1, zb * 2);\n\t\t\tg2.adde(zb * 2 + 1, za * 2);\n\t\t}\n\t\tif (za > 0 && zb < 0)\n\t\t{\n\t\t\tza--;\n\t\t\tzb = -zb;\n\t\t\tzb--;\n\t\t\tg2.adde(za * 2 + 1, zb * 2 + 1);\n\t\t\tg2.adde(zb * 2, za * 2);\n\t\t}\n\t\tif (za < 0 && zb > 0)\n\t\t{\n\t\t\tza = -za;\n\t\t\tza--;\n\t\t\tzb--;\n\t\t\tg2.adde(za * 2, zb * 2);\n\t\t\tg2.adde(zb * 2 + 1, za * 2 + 1);\n\t\t}\n\t\tif (za < 0 && zb < 0)\n\t\t{\n\t\t\tza = -za;\n\t\t\tza--;\n\t\t\tzb = -zb;\n\t\t\tzb--;\n\t\t\tg2.adde(za * 2, zb * 2 + 1);\n\t\t\tg2.adde(zb * 2, za * 2 + 1);\n\t\t}\n\t}\n\tg1.scc();\n\tg2.scc();\n\tvectorv1 = g1.getdata(), v2 = g2.getdata();\n\tbool f1 = true, f2 = true;\n\tfor (int i = 0; i < num; i++)\n\t{\n\t\tif (v1[i] == -1)f1 = false;\n\t\tif (v2[i] == -1)f2 = false;\n\t}\n\tif ((!f1) && (!f2))\n\t{\n\t\tprintf(\"SIMILAR\\n\");\n\t\treturn 0;\n\t}\n\tif (!f1)swap(g1, g2);\n\tif (!(f1&&f2))\n\t{\n\t\tfor (int i = 0; i < num; i++)\n\t\t{\n\t\t\tans[i] = g1.ban[i * 2]>g1.ban[i * 2 + 1];\n\t\t}\n\t}\n\telse\n\t{\n\t\tif (v1 != v2)\n\t\t{\n\t\t\tfor (int i = 0; i < num; i++)\n\t\t\t{\n\t\t\t\tif (v1[i] != v2[i])\n\t\t\t\t{\n\t\t\t\t\tif (v1[i] == 1)\n\t\t\t\t\t{\n\t\t\t\t\t\tg2.adde(i * 2 + 1, i * 2);\n\t\t\t\t\t\tg2.scc();\n\t\t\t\t\t\tfor (int j = 0; j < num; j++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tans[j] = g2.ban[j * 2]>g2.ban[j * 2 + 1];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\telse if (v1[i] == 2)\n\t\t\t\t\t{\n\t\t\t\t\t\tg2.adde(i * 2, i * 2 + 1);\n\t\t\t\t\t\tg2.scc();\n\t\t\t\t\t\tfor (int j = 0; j < num; j++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tans[j] = g2.ban[j * 2]>g2.ban[j * 2 + 1];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\telse if (v2[i] == 1)\n\t\t\t\t\t{\n\t\t\t\t\t\tg1.adde(i * 2 + 1, i * 2);\n\t\t\t\t\t\tg1.scc();\n\t\t\t\t\t\tfor (int j = 0; j < num; j++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tans[j] = g1.ban[j * 2]>g1.ban[j * 2 + 1];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tg1.adde(i * 2, i * 2 + 1);\n\t\t\t\t\t\tg1.scc();\n\t\t\t\t\t\tfor (int j = 0; j < num; j++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tans[j] = g1.ban[j * 2]>g1.ban[j * 2 + 1];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tbool f = false;\n\t\t\tfor (int i = 0; i < num * 2; i++)\n\t\t\t{\n\t\t\t\tfor (int j = 0; j < num * 2; j++)\n\t\t\t\t{\n\t\t\t\t\tif (g1.bi[i][j] != g2.bi[i][j])\n\t\t\t\t\t{\n\t\t\t\t\t\tf = true;\n\t\t\t\t\t\tif (g1.bi[i][j] == 0)swap(g1, g2);\n\t\t\t\t\t\tif (i % 2 == 0)g2.adde(i + 1, i);\n\t\t\t\t\t\telse g2.adde(i, i + 1);\n\t\t\t\t\t\tif (j % 2 == 0)g2.adde(j, j + 1);\n\t\t\t\t\t\telse g2.adde(j + 1, j);\n\t\t\t\t\t\tg1.scc();\n\t\t\t\t\t\tfor (int k = 0; k < num; k++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tans[k] = g1.ban[k * 2]>g1.ban[k * 2 + 1];\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (f)break;\n\t\t\t}\n\t\t\tif (!f)\n\t\t\t{\n\t\t\t\tprintf(\"SIMILAR\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t}\n\tfor (int i = 0; i < num; i++)\n\t{\n\t\tif (i != 0)printf(\" \");\n\t\tprintf(\"%d\", ans[i]);\n\t}\n\tprintf(\"\\n\");\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "da7cae3647bb5f44df6781da05f6dca7", "src_uid": "e7f585455aaf039aa6f0f2846d818b40", "difficulty": 3000.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#define SF scanf\n#define PF printf\n#define MAXN 2010\nusing namespace std;\nint n;\nstruct node{\n\tint flag=0;\n\tbitset g[MAXN];\n\tint ans[MAXN];\n\tvoid change(int x){\n\t\tif(ans[x]!=-1)\n\t\t\treturn ;\n\t\tans[x]=1;\n\t\tans[x^1]=0;\n\t\tfor(int i=0;i<(1<0) u--,u=u<<1;\n\t\t\telse u++,u=(-u)<<1|1;\n\t\t\tif(v>0) v--,v=v<<1;\n\t\t\telse v++,v=(-v)<<1|1;\n\t\t\tg[u^1][v]=g[v^1][u]=1;\n\t\t}\n\t\tfor(int i=0;i<(n<<1);i++)\n\t\t\tfor(int j=0;j<(n<<1);j++)\n\t\t\t\tif(g[j][i])\n\t\t\t\t\tg[j]|=g[i];//Floyd\n\t\tflag=1;\n\t\tfor(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define MOD 1000000007\n#define MAX 0x3f3f3f3f\n#define MAX2 0x3f3f3f3f3f3f3f3fll\n#define ERR 1e-10\n#define mp make_pair\n#define all(x) (x).begin(), (x).end()\n#pragma warning(disable:4996)\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ldb;\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pdd;\n\nstruct SAT\n{\n\tint n, m;\n\tvector edge[3000];\n\tvector redge[3000];\n\tint gi;\n\tint g[3000];\n\tint bgi;\n\tint bg[3000];\n\tvector gmem[3000];\n\tint check[3000];\n\tvector ord;\n\tint rord[3000];\n\tint ans[3000];\n\n\tint getnum(int x)\n\t{\n\t\tif(x > 0) return x-1;\n\t\telse\n\t\t{\n\t\t\tx*=-1;\n\t\t\tx--;\n\t\t\treturn x+n;\n\t\t}\n\t}\n\tint not(int x)\n\t{\n\t\tif(x >= n) return x-n;\n\t\telse return x+n;\n\t}\n\tvoid input()\n\t{\n\t\tint i, j;\n\t\tfor(i=0;i w;\n\t\tw.emplace_back(y, x);\n\t\tw.emplace_back(y^1, not(x));\n\t\tans[x]=y;\n\t\tans[not(x)]=y^1;\n\t\tfor(j=0;j rord[not(i)]) swap(u, v);\n\t\t\t\tmarkans(u, 0);\n\t\t\t}\n\t\t}\n\t}\n\tvoid rback2(int now)\n\t{\n\t\tif(check[now]) return;\n\t\tassignfalse(now);\n\t\tcheck[now]=1;\n\t\tfor(auto e : redge[now])\n\t\t{\n\t\t\trback2(e);\n\t\t}\n\t}\n\tvoid fillremain()\n\t{\n\t\tfill(check, check+n*2, 0);\n\t\tfor(auto e : ord)\n\t\t{\n\t\t\tif(check[e]) continue;\n\t\t\trback2(e);\n\t\t}\n\t}\n\n\tint tclo[2005][2005];\n\tmap mq;\n\tint tn;\n\n\tvoid maketclo()\n\t{\n\t\tint i, j, k;\n\t\t\n\t\tfor(i=0;i>n>>m1>>m2;\n\ts1.n=n, s1.m=m1;\n\ts2.n=n, s2.m=m2;\n\ts1.input(), s2.input();\n\tint u1=s1.scc(), u2=s2.scc();\n\tif(!u1 && !u2) return !printf(\"SIMILAR\");\n\telse if(u1 && !u2)\n\t{\n\t\tfor(i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long int lld;\ntypedef long double ld;\npair arr[7777];\nmap mm;\nlld ans;\nvector v;\nint main(void){\n\tint n;\n\tscanf(\"%d\",&n);\n\tfor(int e=0;e\n#define f first\n#define s second\n#define push push_back\n#define pop pop_back\n#define all(a) a.begin(),a.end()\n#define rall(a) a.rbegin(),a.rend()\n// #pragma GCC optimize(\"O3\")\n\nusing namespace std;\n\ntypedef long long ll;\n\nconst int MAXN = 7001, INF = 1e9;\n\n// mt19937 rnd(0);\n\nint n;\nint used[MAXN], sz[MAXN];\nll c[MAXN];\nvector g[MAXN];\n\nll dfs(int v) {\n\tused[v] = 1;\n\tfor (int & u: g[v]) {\n\t\tif (!used[u]) {\n\t\t\tc[v] += dfs(u);\n\t\t}\n\t}\n\treturn c[v];\n}\n\nsigned main() {\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0); cout.tie(0);\t\n\t// freopen(\"in.txt\", \"r\", stdin);\n\t// freopen(\"out.txt\", \"w\", stdout); \t\n\tcin >> n;\n\tvector a(n);\n\tfor (int i = 0; i < n; ++i) {\n\t\tcin >> a[i];\n\t}\n\tfor (int i = 0; i < n; ++i) {\n\t\tcin >> c[i];\n\t}\n\tfor (int i = 0; i < n; ++i) {\n\t\tfor (int j = 0; j < n; ++j) {\n\t\t\tif (i == j) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ((a[i] & a[j]) == a[i]) {\n\t\t\t\tg[j].push(i);\n\t\t\t\t++sz[i];\n\t\t\t}\n\t\t}\n\t}\n\tfor (int i = 0; i < n; ++i) {\n\t\tfor (int j = 0; j < n; ++j) {\n\t\t\tif (!sz[j]) {\n\t\t\t\tused[j] = 1;\n\t\t\t\tfor (int &k : g[j]) {\n\t\t\t\t\t--sz[k];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tll ans = 0;\n\tfor (int i = 0; i < n; ++i) {\n\t\tif (!used[i]) {\n\t\t\tans = max(ans, dfs(i));\n\t\t}\n\t}\n\tcout << ans;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3cce3762eded1cd85fd9a8dbe16b023a", "src_uid": "9404ec14922a69082f3573bbaf78ccf0", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nint n, b[7007];\nlong long a[7007], res;\nint main() {\n ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);\n cin>>n;\n for (int i=1; i<=n; ++i) cin>>a[i];\n for (int i=1; i<=n; ++i) cin>>b[i];\n for (int i=1; i<=n; ++i) {\n bool flag=false;\n long long cures=b[i];\n for (int j=1; j<=n; ++j) {\n if (a[j]!=a[i]) {\n bool flag2=true;\n for (int k=0; k<60; ++k) {\n if (!(a[i]&(1<\n#define f first\n#define s second\n#define push push_back\n#define pop pop_back\n#define all(a) a.begin(),a.end()\n#define rall(a) a.rbegin(),a.rend()\n// #pragma GCC optimize(\"O3\")\n\nusing namespace std;\n\ntypedef long long ll;\n\nconst int MAXN = 7001, INF = 1e9;\n\n// mt19937 rnd(0);\n\nint n;\nint used[MAXN], sz[MAXN];\nll c[MAXN];\nvector g[MAXN];\n\nll dfs(int v) {\n\tcout << v << endl;\n\tused[v] = 1;\n\tfor (int & u: g[v]) {\n\t\tif (!used[u]) {\n\t\t\tc[v] += dfs(u);\n\t\t}\n\t}\n\treturn c[v];\n}\n\nsigned main() {\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0); cout.tie(0);\t\n\tfreopen(\"in.txt\", \"r\", stdin);\n\tfreopen(\"out.txt\", \"w\", stdout); \t\n\tcin >> n;\n\tvector a(n);\n\tfor (int i = 0; i < n; ++i) {\n\t\tcin >> a[i];\n\t}\n\tfor (int i = 0; i < n; ++i) {\n\t\tcin >> c[i];\n\t}\n\tfor (int i = 0; i < n; ++i) {\n\t\tfor (int j = 0; j < n; ++j) {\n\t\t\tif (i == j) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif ((a[i] & a[j]) == a[i]) {\n\t\t\t\tg[j].push(i);\n\t\t\t\t++sz[i];\n\t\t\t}\n\t\t}\n\t}\n\tfor (int i = 0; i < n; ++i) {\n\t\tfor (int j = 0; j < n; ++j) {\n\t\t\tif (!sz[j] && !used[j]) {\n\t\t\t\tused[j] = 1;\n\t\t\t\tfor (int &k : g[j]) {\n\t\t\t\t\t--sz[k];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tll ans = 0;\n\tfor (int i = 0; i < n; ++i) {\n\t\tif (!used[i]) {\n\t\t\tans = max(ans, dfs(i));\n\t\t}\n\t}\n\tcout << ans;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4dc82772a302eb2d4635a7c05658df58", "src_uid": "9404ec14922a69082f3573bbaf78ccf0", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "// think twice code once\n// Start:[2017-02-13 21:38:05]\n// End :[]\n/*{{{*/\n#include \nusing namespace std;\n\n#define rep(i, x, y) for(int i = (x), _ = (y); i <= _; ++ i)\n#define per(i, x, y) for(int i = (x), _ = (y); i >= _; -- i)\n#define dprintf(...) fprintf(stderr, __VA_ARGS__)\n#define disp(x) cout << #x << \" = \" << x << \"; \"\n#ifdef __linux__\n#define getchar getchar_unlocked\n#define LLFORMAT \"%lld\"\n#else\n#define LLFORMAT \"%I64d\"\n#endif\n\ntypedef long long LL;\n\ntemplate bool chkmin(T& a, T b) { return a > b ? a = b, true : false; }\ntemplate bool chkmax(T& a, T b) { return a < b ? a = b, true : false; }\n\ntemplate void read(T& a) {\n\tchar c = getchar(); T f = 1; a = 0;\n\tfor(; !isdigit(c); c = getchar()) if(c == '-') f = -1;\n\tfor(; isdigit(c); c = getchar()) a = a * 10 + c - '0';\n\ta *= f;\n}\n/*}}}*/\n\nconst int maxN = 4e5 + 5, LIM = sqrt(maxN + .5);\n\nint N, M, Q;\nint st0[maxN], st1[maxN], e;\nint sum[maxN], maxf[maxN];\nint totf[maxN];\nbool isact[maxN << 1];\nbool state[maxN];\n\nstruct Edge\n{\n\tint u, v;\n\tEdge() {}\n\tEdge(int u, int v) :u(u), v(v) {}\n\n\tfriend bool operator< (const Edge& a, const Edge& b) { return a.u < b.u || (a.u == b.u && a.v < b.v); }\n\tfriend bool operator== (const Edge& a, const Edge& b) { return a.u == b.u && a.v == b.v; }\n}ed[maxN << 1];\n\nmap ID;\n\nbool cmp(const Edge& a, const Edge& b) { return a.u < b.u || (a.u == b.u && maxf[a.v] < maxf[b.v]); }\n\nstruct Query\n{\n\tchar ty;\n\tint u, v;\n}q[maxN];\n\n#define isH(u) (maxf[u] >= LIM)\n\nvoid update(int u)\n{\n\tint a = state[u] ? -1 : 1;\n\tstate[u] ^= 1;\n\tif(isH(u) == 0)\n\t{\n\t\trep(i, st0[u], st0[u + 1] - 1) if(isact[i])\n\t\t\tsum[ed[i].v] += a;\n\t}\n}\n\nint getans(int u)\n{\n\tint ret = sum[u];\n\trep(i, st1[u], st0[u + 1] - 1) if(isact[i])\n\t\tret += state[ed[i].v];\n\treturn ret;\n}\n\nint main()\n{\n#ifdef Leeson\n\tfreopen(\"tmp.in\", \"r\", stdin);\n\tfreopen(\"tmp.out\", \"w\", stdout);\n#endif\n\n\tint C;\n\tread(N); read(M); read(Q);\n\tread(C);\n\n\trep(i, 1, C)\n\t{\n\t\tq[i].ty = 'O';\n\t\tread(q[i].u);\n\t}\n\n\trep(i, 1, M)\n\t{\n\t\tint u, v;\n\t\tread(u); read(v);\n\t\ted[++e] = Edge(u, v); ID[ed[e]] = 1;\n\t\ted[++e] = Edge(v, u); ID[ed[e]] = 1;\n\t\t++ totf[u], ++ totf[v];\n\t\tchkmax(maxf[u], totf[u]);\n\t\tchkmax(maxf[v], totf[v]);\n\t}\n\n\trep(i, 1, Q)\n\t{\n\t\tchar c = getchar();\n\t\twhile(isalpha(c) == 0) c = getchar();\n\t\tint j = i + C;\n\t\tq[j].ty = c;\n\t\tswitch(c)\n\t\t{\n\t\t\tcase 'O':\n\t\t\tcase 'F':\n\t\t\tcase 'C':\n\t\t\t\tread(q[j].u); \n\t\t\t\tbreak;\n\t\t\tcase 'D':\n\t\t\t\tread(q[j].u); read(q[j].v);\n\t\t\t\ttotf[q[j].u]--, totf[q[j].v]--;\n\t\t\t\tbreak;\n\t\t\tcase 'A':\n\t\t\t\tread(q[j].u), read(q[j].v);\n\t\t\t\ttotf[q[j].u]++, totf[q[j].v]++;\n\t\t\t\tchkmax(maxf[q[j].u], totf[q[j].u]);\n\t\t\t\tchkmax(maxf[q[j].v], totf[q[j].v]);\n\t\t\t\ted[++e] = Edge(q[j].u, q[j].v);\n\t\t\t\ted[++e] = Edge(q[j].v, q[j].u);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tsort(ed + 1, ed + e + 1);\n\te = unique(ed + 1, ed + e + 1) - ed - 1;\n\tsort(ed + 1, ed + e + 1, cmp);\n\n\trep(i, 1, e)\n\t{\n\t\tif(ed[i].u != ed[i - 1].u) st0[ed[i].u] = i;\n\t\tif(isH(ed[i].v)) st1[ed[i].u] = st1[ed[i].u] == 0 ? i : st1[ed[i].u];\n\t\tif(ID.find(ed[i]) != ID.end()) isact[i] = 1;\n\t\tID[ed[i]] = i;\n\t}\n\tst0[N + 1] = st1[N + 1] = e + 1;\n\tper(i, N, 1)\n\t{\n\t\tif(st0[i] == 0) st0[i] = st0[i + 1];\n\t\tif(st1[i] == 0) st1[i] = st0[i + 1];\n\t}\n\n\trep(tt, 1, Q + C)\n\t{\n\t\tchar c = q[tt].ty;\n\t\tint u = q[tt].u, v = q[tt].v;\n\t\tswitch(c)\n\t\t{\n\t\t\tcase 'F': case 'O':\n\t\t\t\tupdate(u);\n\t\t\t\tbreak;\n\t\t\tcase 'A':\n\t\t\t\tisact[ID[Edge(u, v)]] = isact[ID[Edge(v, u)]] = 1;\n\t\t\t\tif(!isH(u) && state[u]) sum[v] ++;\n\t\t\t\tif(!isH(v) && state[v]) sum[u] ++;\n\t\t\t\tbreak;\n\t\t\tcase 'D':\n\t\t\t\tisact[ID[Edge(u, v)]] = isact[ID[Edge(v, u)]] = 0;\n\t\t\t\tif(!isH(u) && state[u]) sum[v] --;\n\t\t\t\tif(!isH(v) && state[v]) sum[u] --;\n\t\t\t\tbreak;\n\t\t\tcase 'C':\n\t\t\t\tprintf(\"%d\\n\", getans(u));\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "eb79fac53e0382dc35dd0d80d94301ab", "src_uid": "3467cbf1f1bf689096841b91405a9651", "difficulty": null} {"lang": "GNU C++14", "source_code": "// In the name of God\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int N = (int) 2e5 + 5, mod = (int) 1e9 + 7;\nint pw(int a, int b) { return b != 0? pw(a * 1ll * a % mod, b >> 1) * 1ll * (b & 1? a: 1) % mod: 1; }\nint n, k;\nint dpinv[N], sz[N], pt, f[N], inv[N], cnt[N], p[N], pl[N], mark[N];\nint dp[N][20], ans = 1;\n\nint comb(int n, int r) {\n if (n < 0 || r < 0 || n - r < 0)\n return 0;\n return f[n] * 1ll * inv[r] % mod * inv[n - r] % mod;\n}\nvoid sadd(int &x, int y) { x += y; x %= mod; }\nint dfs(int v) {\n if (v < 0 || p[v] < 0) return 0;\n mark[v] = 1;\n int res = 1;\n if (pl[v] >= 0 && !mark[pl[v]])\n res += dfs(pl[v]);\n return res;\n}\nint q[N], csz[N], to_add[N], t = 0;\nint go(int m = 0, int d = 0) {\n if (m == k) {\n t++;\n for (int j = 0; j < k; ++j)\n csz[j] = 0;\n for (int j = 0; j < k; ++j)\n csz[q[j]] += sz[j];\n#define size size_vector\n vector size;\n for (int j = 0; j < d; ++j)\n size.push_back(csz[j]);\n sort(size.begin(), size.end());\n size.resize(unique(size.begin(), size.end()) - size.begin());\n for (int j = 0; j < d; ++j)\n to_add[csz[j]]++;\n int res = 1;\n if (cnt[1] + to_add[1] + cnt[2] * 2 + to_add[2] * 2 < n) {\n res = ans;\n for (int x : size)\n res = res * 1ll * dpinv[x] % mod * dp[x][to_add[x]] % mod;\n }\n\n for (int j = 0; j < d; ++j)\n to_add[csz[j]] = 0;\n for (int j = 0; j < k; ++j) {\n if (to_add[q[j]])\n res = res * 1ll * to_add[q[j]] % mod;\n to_add[q[j]]++;\n }\n for (int j = 0; j < k; ++j)\n to_add[q[j]] = 0;\n#undef size\n return res;\n }\n int res = 0;\n for (int j = 0; j <= d; ++j) {\n q[m] = j;\n sadd(res, go(m + 1, max(j + 1, d)));\n }\n return res;\n}\n\nint32_t main() {\n memset(pl, -1, sizeof pl);\n ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n inv[0] = f[0] = 1;\n for (int j = 1; j < N; ++j) {\n f[j] = f[j - 1] * 1ll * j % mod;\n inv[j] = pw(f[j], mod - 2);\n }\n cin >> n >> k;\n for (int j = 0; j < n; ++j) {\n cin >> p[j];\n p[j]--;\n if (p[j] >= 0)\n pl[p[j]] = j;\n }\n for (int j = 0; j < n; ++j)\n if (p[j] < 0)\n sz[pt++] = 1 + dfs(pl[j]);\n for (int j = 0; j < n; ++j)\n if (p[j] >= 0 && !mark[j]) {\n int x = dfs(j);\n cnt[x]++;\n }\n for (int j = 1; j < N; ++j) {\n for (int add = 0; add <= 12; ++add) {\n int c = cnt[j] + add;\n int z = pw(2, mod - 2) * 1ll * pw(j, mod - 2) % mod, cur = pw(j, c);\n for (int match = 0; match * 2 <= c; ++match) {\n sadd(dp[j][add], 1ll * cur * comb(c, match * 2) % mod * f[match * 2] % mod * inv[match] % mod);\n cur = cur * 1ll * z % mod;\n }\n }\n dpinv[j] = pw(dp[j][0], mod - 2);\n ans = ans * 1ll * dp[j][0] % mod;\n }\n cout << go() << endl;\n}\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "930f60d914dbde02541e53b04d0dfe8d", "src_uid": "3467cbf1f1bf689096841b91405a9651", "difficulty": null} {"lang": "GNU C++14", "source_code": "// In the name of God\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int N = (int) 2e5 + 5, mod = (int) 1e9 + 7;\nint pw(int a, int b) { return b != 0? pw(a * 1ll * a % mod, b >> 1) * 1ll * (b & 1? a: 1) % mod: 1; }\nint n, k;\nint dpinv[N], sz[N], pt, f[N], inv[N], cnt[N], p[N], pl[N], mark[N];\nint dp[N][20], ans = 1;\n\nint comb(int n, int r) {\n if (n < 0 || r < 0 || n - r < 0)\n return 0;\n return f[n] * 1ll * inv[r] % mod * inv[n - r] % mod;\n}\nvoid sadd(int &x, int y) { x += y; x %= mod; }\nint dfs(int v) {\n if (v < 0 || p[v] < 0) return 0;\n mark[v] = 1;\n int res = 1;\n if (pl[v] >= 0 && !mark[pl[v]])\n res += dfs(pl[v]);\n return res;\n}\nint q[N], csz[N], to_add[N], t = 0;\nint go(int m = 0, int d = 0) {\n if (m == k) {\n t++;\n for (int j = 0; j < k; ++j)\n csz[j] = 0;\n for (int j = 0; j < k; ++j)\n csz[q[j]] += sz[j];\n#define size size_vector\n vector size;\n for (int j = 0; j < d; ++j)\n size.push_back(csz[j]);\n sort(size.begin(), size.end());\n size.resize(unique(size.begin(), size.end()) - size.begin());\n for (int j = 0; j < d; ++j)\n to_add[csz[j]]++;\n int res = 1;\n if (cnt[1] + to_add[1] + cnt[2] * 2 + to_add[2] * 2 < n) {\n res = ans;\n for (int x : size)\n res = res * 1ll * dpinv[x] % mod * dp[x][to_add[x]] % mod;\n }\n\n for (int j = 0; j < d; ++j)\n to_add[csz[j]] = 0;\n for (int j = 0; j < k; ++j) {\n if (to_add[q[j]])\n res = res * 1ll * to_add[q[j]] % mod;\n to_add[q[j]]++;\n }\n for (int j = 0; j < k; ++j)\n to_add[q[j]] = 0;\n#undef size\n return res;\n }\n int res = 0;\n for (int j = 0; j <= d; ++j) {\n q[m] = j;\n sadd(res, go(m + 1, max(j + 1, d)));\n }\n return res;\n}\n\nint32_t main() {\n memset(pl, -1, sizeof pl);\n ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n inv[0] = f[0] = 1;\n for (int j = 1; j < N; ++j) {\n f[j] = f[j - 1] * 1ll * j % mod;\n inv[j] = pw(f[j], mod - 2);\n }\n cin >> n >> k;\n for (int j = 0; j < n; ++j) {\n cin >> p[j];\n p[j]--;\n if (p[j] >= 0)\n pl[p[j]] = j;\n }\n for (int j = 0; j < n; ++j)\n if (p[j] < 0)\n sz[pt++] = 1 + dfs(pl[j]);\n for (int j = 0; j < n; ++j)\n if (p[j] >= 0 && !mark[j]) {\n int x = dfs(j);\n cnt[x]++;\n }\n for (int j = 1; j <= n; ++j) {\n for (int add = 0; add <= 12; ++add) {\n int c = cnt[j] + add;\n int z = pw(2, mod - 2) * 1ll * pw(j, mod - 2) % mod, cur = pw(j, c);\n for (int match = 0; match * 2 <= c; ++match) {\n sadd(dp[j][add], 1ll * cur * comb(c, match * 2) % mod * f[match * 2] % mod * inv[match] % mod);\n cur = cur * 1ll * z % mod;\n }\n }\n dpinv[j] = pw(dp[j][0], mod - 2);\n ans = ans * 1ll * dp[j][0] % mod;\n }\n cout << go() << endl;\n}\n\n\n\n\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ebe9742ef1f4813967f9d54f41353357", "src_uid": "3467cbf1f1bf689096841b91405a9651", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include\n#include\n#include \n\nint read(){\n int w=0;char ch=getchar();\n while(!isdigit(ch))ch=getchar();\n for(;isdigit(ch);ch=getchar())w=w*10+(ch^48);\n return w;\n}\n\nconst int N=1e6+30,K=30,mod=1e9+7;\n\nint n,k;\nint a[N],b[N],vis[N];\nint fac[N],facinv[N],fac2[N];\nint num[N],f[N][K],finv[N][K];\nint add[N];\nint len[K],tp;\nint ne[K],sz[K],cnt;\nint bns,ans;\n\nint qpow(int x,int y){\n int re=1;\n for(;y;y>>=1,x=1LL*x*x%mod)if(y&1)re=1LL*re*x%mod;\n return re;\n}\n\nvoid dfs(int w,int now){\n if(w>k){\n int cns=bns;\n for(int i=1;i<=cnt;++i){\n cns=1LL*cns*finv[ne[i]][add[ne[i]]]%mod;\n add[ne[i]]++;\n cns=1LL*cns*f[ne[i]][add[ne[i]]]%mod;\n }\n if(num[1]+add[1]+(num[2]+add[2])*2==n)cns=1;\n ans=(ans+1LL*cns*now)%mod;\n for(int i=1;i<=cnt;++i)add[ne[i]]--;\n return;\n }\n for(int i=1;i<=cnt;++i){\n ne[i]+=len[w];now*=sz[i];sz[i]++;\n dfs(w+1,now);\n ne[i]-=len[w];sz[i]--;now/=sz[i];\n }\n ne[++cnt]=len[w];sz[cnt]=1;\n dfs(w+1,now);\n --cnt;\n return;\n}\n\nint main(){\n // freopen(\"determination.in\",\"r\",stdin);\n // freopen(\"determination.out\",\"w\",stdout);\n n=read();k=read();\n for(int i=1;i<=n;++i){a[i]=read();b[a[i]]=i;}\n for(int i=1;i<=n;++i)if(b[i]==0){\n int w=i,l=1;vis[w]=1;\n while(a[w]){++l;w=a[w];vis[w]=1;}\n len[++tp]=l;\n }\n for(int i=1;i<=n;++i)if(!vis[i]){\n int w=i,l=1;vis[w]=1;\n while(!vis[a[w]]){++l;w=a[w];vis[w]=1;}\n ++num[l];\n }\n bns=1;\n fac[0]=1;for(int i=1;i<=n+12;++i)fac[i]=1LL*fac[i-1]*i%mod;\n facinv[n+12]=qpow(fac[n+12],mod-2);for(int i=n+12;i;--i)facinv[i-1]=1LL*facinv[i]*i%mod;\n fac2[0]=fac2[1]=fac2[2]=1;for(int i=3;i<=n+13;++i)fac2[i]=1LL*fac2[i-2]*(i-1)%mod;\n for(int i=1;i<=n;++i){\n for(int j=0;j<=k;++j){\n int r=num[i]+j;\n for(int t=r/2,p=qpow(i,r-t);t>=0;--t,p=1LL*p*i%mod){\n f[i][j]=(f[i][j]+1LL*fac[r]*facinv[2*t]%mod*facinv[r-2*t]%mod*fac2[2*t]%mod*p)%mod;\n }\n finv[i][j]=qpow(f[i][j],mod-2);\n }\n bns=1LL*bns*f[i][0]%mod;\n }\n dfs(1,1);\n printf(\"%d\\n\",ans);\n // fclose(stdin);fclose(stdout);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "04653671c57da8a58466886249899bc1", "src_uid": "3467cbf1f1bf689096841b91405a9651", "difficulty": null} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long int ll;\n\nconst int SIZE = 2001;\nconst int MOD = 1000000007;\nconst int MAXM = 2000;\n\nvoid pref_func(char s[], int p[])\n{\n\tp[0] = 0;\n\n\tfor (int i = 1; s[i]; i++) {\n\t\tint t = p[i - 1];\n\n\t\twhile (t > 0 && s[i] != s[t])\n\t\t\tt = p[t - 1];\n\n\t\tif (t == 0)\n\t\t\tif (s[i] == s[0])\n\t\t\t\tp[i] = 1;\n\t\t\telse\n\t\t\t\tp[i] = 0;\n\t\telse\n\t\t\tp[i] = t + 1;\n\t}\n}\n\nchar s[SIZE];\nint p[SIZE];\n\nint main()\n{\n//\tfreopen(\"input.txt\", \"r\", stdin);\n\n\tcin >> s;\n\n\tpref_func(s, p);\n\n\tint len = strlen(s);\n\tif (p[len - 1] * 2 > len) {\n\t\tcout << \"YES\" << endl;\n\n\t\tfor (int i = 0; i < p[len - 1]; i++)\n\t\t\tcout << s[i];\n\n\t\tcout << endl;\n\t} else \n\t\tcout << \"NO\" << endl;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "940033ca05c24cbc063cb42b31554542", "src_uid": "bfa78f72af4875f670f7adc5ed127033", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main() \n{\n int l,i,l1,j;\n char s[101];\n string s1;\n bool fl=false;\n\n cin>>s;\n l=strlen(s);\n\n l1=(l/2);\n i=l1-1;\n for(j=0;j<=i;j++)\n {\n s1=s1+s[j];\n }\n while(i\n#include \nint main()\n{\n bool f=true;\n std::string str;\n std::cin>>str;\n for(int p=str.size()/2+1; p\n#include \n\nusing namespace std;\n\n\n\nint main() {\n\tstring str,f,s, ans = \"\";\n\tbool good = true;\n\tint beg,len, len1;\n\n\tcin >> str;\n\tif (str.size() % 2 != 0) good = false;\n\n\n\tif (good) {\n\t\tlen = str.size() / 2;\n\t\tlen1 = len;\n\t} else {\n\t\tlen = str.size() / 2 + 1;\n\t\tlen1 = str.size() / 2;\n\t}\t\n\n\tdo {\n\n\tf = str.substr(0, len);\n\ts = str.substr(len1, str.size() - len1);\n\n\tif (f == s) ans = f;\n\n\t++len;\n\t--len1;\n\n\t} while (len != str.size());\n\n\tif (str.size() % 2 == 0) {\n\n\tf = str.substr(0, str.size() / 2);\n\ts = str.substr(str.size() / 2, str.size() / 2);\n\n\tif (f == s && ans == f) {\n\t\tcout << \"NO\";\n\t\treturn 0;\n\t}\n\t}\n\n\tif (ans != \"\") {\n\t\tcout << \"YES\" << endl;\n\t\tcout << ans;\n\t\treturn 0;\n\t} else {\n\t\tcout << \"NO\";\n\t}\t\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6597db2f35c6f5b287d550d002ce45e2", "src_uid": "bfa78f72af4875f670f7adc5ed127033", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#pragma comment(linker, \"/STACK:65777216\")\n \n#include \n#include \n#include \n#include\n#include\n#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include \n#include\n \nusing namespace std;\n \ntypedef long long ll;\ntypedef vector vi;\ntypedef pair pii;\ntypedef pair pdd;\ntypedef unsigned long long ull;\n \n#define FOR(i,a,b) for (int i(a); i < (b); i++)\n#define REP(i,n) FOR(i,0,n)\n#define SORT(v) sort((v).begin(),(v).end())\n#define UN(v) sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())\n#define CL(a,b) memset(a,b,sizeof(a))\n#define pb push_back\n\ntypedef long double ld;\nconst ld pi = acosl(-1.);\nconst ld eps = 1e-17;\n\nint r,h;\n\nld getAngle(ld x,ld y, ld z){\n\tld H = h - z;\n\tif(H0) l=-l;\n\treturn l;\n}\n\nld conDist(ld z,ld Z,ld a){\n\tld r1 = sqrtl(h*h+r*r+0.)/h*(h-z);\n\tld r2 = sqrtl(h*h+r*r+0.)/h*(h-Z);\n\tld x = r1;\n\tld y = 0;\n\tld X = cosl(a)*r2;\n\tld Y = sinl(a)*r2;\n\treturn sqrtl((x-X)*(x-X)+(y-Y)*(y-Y));\n}\n\nld getOnConus(ld x,ld y,ld z,ld X, ld Y,ld Z){\n\tld a1 = getAngle(x,y,z);\n\tld a2 = getAngle(X,Y,Z);\n\tld a = fabsl(a2-a1);\n\tld A = r / sqrtl(h*h+r*r+0.) * 2 * pi; \n\treturn min(conDist(z,Z,a),conDist(z,Z,A-a));\n}\n\nld getOnConus(ld x,ld y,ld z,ld X, ld Y){\n\tif(z>eps) return getOnConus(x,y,z,X,Y,0);\n\treturn sqrtl((x-X)*(x-X)+(y-Y)*(y-Y));\n}\n\nld getD(ld x,ld y,ld z,ld X, ld Y,ld Z,ld XX,ld YY,ld XXX,ld YYY){\n\tld res = sqrtl((XX-XXX)*(XX-XXX)+(YY-YYY)*(YY-YYY));\n\tres += getOnConus(x,y,z,XX,YY);\n\tres += getOnConus(X,Y,Z,XXX,YYY);\n\treturn res;\n}\n\nld getD(ld x,ld y,ld z,ld X, ld Y,ld Z,ld XX,ld YY){\n\tld res = 1e100;\n\tREP(i,6){\n\t\tld a = 2*pi/3*i;\n\t\tld b = a + pi;\n\t\tREP(j,50){\n\t\t\tld s1 = (a*2+b)/3;\n\t\t\tld s2 = (a+2*b)/3;\n\t\t\tld d1 = getD(x,y,z,X,Y,Z,XX,YY,cosl(s1)*r,sinl(s1)*r);\n\t\t\tld d2 = getD(x,y,z,X,Y,Z,XX,YY,cosl(s2)*r,sinl(s2)*r);\n\t\t\tres = min(res,min(d1,d2));\n\t\t\tif(d1>r>>h;\n\tlong double x,y,z,X,Y,Z;\n\tcin>>x>>y>>z>>X>>Y>>Z;\n\tif(z\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst int bound=40;\nconst double eps=1e-9,inf=1e9+9,pi=acos(-1.0);\ndouble ans,r,h,xa,ya,za,xb,yb,zb,la,ra,mxa,mya,lb,rb,mxb,myb,lv,rv,lz,rz;\ndouble dtheta;\ndouble dist(double x1,double y1,double z1,double x2,double y2,double z2)\n{\n\treturn sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));\n}\nvoid norm(double &theta)\n{\n\twhile(theta<-eps)\n\t theta+=2*pi;\n while(theta>2*pi-eps)\n theta-=2*pi;\n}\ndouble solve(double x1,double y1,double z1,double x2,double y2,double z2)\n{\n\tdouble l1,l2,l,cj,alpha,dj,theta,res;\n\tif(fabs(z1)pi)\n\t alpha=2*pi-alpha;\n\tl=alpha*r;\n\tcj=sqrt(r*r+h*h);\n\ttheta=l/cj;\n\tdouble u1,v1,u2,v2;\n\tu1=0;\n\tv1=l1;\n\tu2=l2*sin(theta);\n\tv2=l2*cos(theta);\n\tres=sqrt((u1-u2)*(u1-u2)+(v1-v2)*(v1-v2));\n theta=2*pi-theta;\n \tu1=0;\n\tv1=l1;\n\tu2=l2*sin(theta);\n\tv2=l2*cos(theta);\n\tres=min(res,sqrt((u1-u2)*(u1-u2)+(v1-v2)*(v1-v2)));\n return res;\n}\ndouble compute(double alpha,double beta)\n{\n\treturn solve(xa,ya,za,r*cos(alpha),r*sin(alpha),0)+solve(xb,yb,zb,r*cos(beta),r*sin(beta),0)+dist(r*cos(alpha),r*sin(alpha),0,r*cos(beta),r*sin(beta),0);\n}\ndouble compute(double alpha)\n{\n\tdouble theta,vl,ch,ret=inf;\n\tfor(theta=0;theta<2*pi;theta+=dtheta)\n\t{\n\t\tvl=compute(alpha,theta);\n\t\tif(ret>vl)\n\t\t{\n\t\t\tret=vl;\n\t\t\tch=theta;\n\t\t}\n\t}\n\tlb=max(0.,ch-dtheta);\n\trb=min(2*pi,ch+dtheta);\n\twhile(lbcompute(alpha,myb))\n\t\t lb=mxb+eps;\n else\n rb=mxb-eps;\n\t}\n\tvl=compute(alpha,0.5*(lb+rb));\n\tif(ret>vl)\n\t ret=vl;\n return ret;\n}\nint main()\n{\n\tint i,j,s,p,q,it1,it2;\n\tscanf(\"%lf%lf\",&r,&h);\n\tscanf(\"%lf%lf%lf%lf%lf%lf\",&xa,&ya,&za,&xb,&yb,&zb);\n\tans=inf;\n\tif(fabs(za)>eps&&fabs(zb)>eps)\n\t ans=min(ans,solve(xa,ya,za,xb,yb,zb));\n\tif(fabs(za)vl)\n\t\t{\n\t\t\tmi=vl;\n\t\t\tch=theta;\n\t\t}\n\t\tif(ans>vl)\n\t\t ans=vl;\n\t}\n\tla=max(0.,ch-dtheta);\n\tra=min(2*pi,ch+dtheta);\n\twhile(larv)\n\t\t la=mxa+eps;\n\t\telse\n\t\t ra=mxa-eps;\t\n\t}\n\tvl=solve(xa,ya,za,r*cos(0.5*(la+ra)),r*sin(0.5*(la+ra)),0)+solve(xb,yb,zb,r*cos(0.5*(la+ra)),r*sin(0.5*(la+ra)),0);\n\tif(ans>vl)\n\t ans=vl;\n\tmi=inf;\n\tfor(theta=0;theta<2*pi;theta+=dtheta)\n\t{\n\t\tvl=compute(theta);\n\t\tif(mi>vl)\n {\n \tmi=vl;\n \tch=theta;\n }\n if(ans>vl)\n ans=vl;\n\t}\n la=max(0.,ch-dtheta);\n ra=min(2*pi,ch+dtheta);\n while(lacompute(mya))\n \t la=mxa+eps;\n\t else\n\t ra=mxa-eps;\n }\n vl=compute(0.5*(la+ra));\n if(ans>vl)\n ans=vl;\n printf(\"%.20f\\n\",ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "40fb4462b945058d778511c7c3946d0f", "src_uid": "c89cc89ed9ba18211a8272cece600f33", "difficulty": 3000.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nconst int bound=40;\nconst double eps=1e-9,inf=1e9+9,pi=acos(-1.0);\ndouble ans,r,h,xa,ya,za,xb,yb,zb,la,ra,mxa,mya,lb,rb,mxb,myb,lv,rv,lz,rz;\ndouble dtheta;\ndouble dist(double x1,double y1,double z1,double x2,double y2,double z2)\n{\n\treturn sqrt(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2))+((z1-z2)*(z1-z2)));\n}\nvoid norm(double &theta)\n{\n\twhile(theta<-eps)\n\t{\n\t\ttheta+=2*pi;\n\t}\n\twhile(theta>2*pi-eps)\n\ttheta-=2*pi;\n}\nvoid solve(double x1,double y1,double z1,double x2,double y2,double z2)\n{\n\tdouble l1,l2 ,l,cj,alpha,dj,theta,res;\n\tif(fabs(z1)pi)\t\n\talpha=2*pi-alpha;\n\tl=alpha*r;\n\tcj=sqrt(r*r+h*h);\n\ttheta=l/cj;\n\tdouble u1,v1,u2,v2;\n\tu1=-;\n\tv1=l1;\n\tu2=l2*sin(theta);\n\tv2=l2*cos(theta);\n\tres=sqrt((u1-u2)*(u1-u2)+(v1-v2)*(v1-v2));\n\ttheta=2*pi-theta;\n\t \tu1=0;\n\tv1=l1;\n\tu2=l2*sin(theta);\n\tv2=l2*cos(theta);\n\tres=min(res,sqrt((u1-u2)*(u1-u2)+(v1-v2)*(v1-v2)));\n return res;\n\tv1=l1;\n\tu2=l2*sin(theta);\n\tv2=l2*cos(theta);\n\tres=min(res,sqrt((u1-u2)*(u1-u2)+(v1-v2)*(v1-v2)));\n\treturn res;\n}\ndouble compute(double alpha,double beta)\n{\n\treturn solve(xa,ya,za,r*cos(alpha),r*sin(alpha),0)+solve(xb,yb,zb,r*cos(beta),r*sin(beta),0)+dist(r*cos(alpha),r*sin(alpha),0,r*cos(beta),r*sin(beta),0);\n}\ndouble compute(double alpha)\n{\t\n\tdouble theta,vl,ch,ret=inf;\n\tfor(theta=0;theta<2*pi;theta+=dtheta)\n\t{\n\t\tvl=compute(alpha,theta);\n\t\tif(ret>vl)\n\t\t{\n\t\t\tret=vl;\n\t\t\tch=theta;\n\t\t}\n\t}\t\n\tlb=max(0.,ch-dtheta);\n\trb=min(2*pi,ch+dtheta);\n\twhile(lbcompute(alpha,myb))\n\t\tlb=mxb+eps;\n\t\telse\n\t\trb=mxb-eps;\n\t}\n\tvl=compute(alpha,0.5*(lb+rb));\n\tif(ret>vl)\n\tret=vl;\n\treturn ret;\n}\nint main()\n{\n\tint i,j,s,p,q,it1,it2;\n\tscanf(\"%lf%lf\",&r,&h);\n\tscanf(\"%lf%lf%lf%lf%lf%lf\",&xa,&ya,&za,&xb,&yb,&zb);\n\tans=inf;\n\tif(fabs(za)>eps&&fabs(zb)>eps)\n\tans=min(ans,solve(xa,ya,za,xb,yb,zb));\n\tif(fabs(za)vl)\n\t\t{\n\t\t\tmi=vl;\n\t\t\tch=theta;\n\t\t}\n\t\tif(ans>vl)\n\t\tans=vl;\n\t}\n\tla=max(0.ch-dtheta);\n\tra=min(2*pi,ch+dtheta);\n\twhile(larv)\n\t\tla=mxa+eps;\n\t\telse\n\t\tra=mxa-eps;\n\n\t}\n\tvl=solve(xa,ya,za,r*cos(0.5*(la+ra)),r*sin(0.5*(la+ra)),0)+solve(xb,yb,zb,r*cos(0.5*(la+ra)),r*sin(0.5*(la+ra)),0);\n\tif(ans>vl)\n\tans=vl;\n\tmi-inf;\n\tfor(theta=0;theta<2*pi;theta+=dtheta)\n\t{\n\t\tvl=compute(theta);\n\t\tif(mi>vl)\n\t{\n\t\tmi=vl;\n\t\tch=theta;\n\t}\n\t if(ans>vl)\n ans=vl;\n\t}\n la=max(0.,ch-dtheta);\n ra=min(2*pi,ch+dtheta);\t\n\twhile(lacompute(mya))\n\tla=mxa+eps;\n\telse\n\tra=mxa-eps;\n\t}\n\tvl=compute(0.5*(l1+ra));\n\tif(ans>vl)\n\tans=vl;\n\tprintf(\"%.20f\\n\",ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7bd75140554ed0e7a51921a65f048914", "src_uid": "c89cc89ed9ba18211a8272cece600f33", "difficulty": 3000.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nconst int bound=40;\nconst double eps=1e-9,inf=1e9+9,pi=acos(-1.0);\ndouble ans,r,h,xa,ya,za,xb,yb,zb,la,ra,mxa,mya,lb,rb,mxb,myb,lv,rv,lz,rz;\ndouble dtheta;\ndouble dist(double x1,double y1,double z1,double x2,double y2,double z2)\n{\n\treturn sqrt(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2))+((z1-z2)*(z1-z2)))\n}\nvoid norm(double &theta)\n{\n\twhile(theta<-eps)\n\t{\n\t\ttheta+=2*pi;\n\t}\n\twhile(theta>2*pi-eps)\n\ttheta-=2*pi;\n}\nvoid solve(double x1,double y1,double z1,double x2,double y2,double z2)\n{\n\tdouble l1,l2 ,l,cj,alpha,dj,theta,res;\n\tif(fabs(z1)pi)\t\n\talpha=2*pi-alpha;\n\tl=alpha*r;\n\tcj=sqrt(r*r+h*h);\n\ttheta=l/cj;\n\tdouble u1,v1,u2,v2;\n\tu1=-;\n\tv1=l1;\n\tu2=l2*sin(theta);\n\tv2=l2*cos(theta);\n\tres=sqrt((u1-u2)*(u1-u2)+(v1-v2)*(v1-v2));\n\ttheta=2*pi-theta;\n\t \tu1=0;\n\tv1=l1;\n\tu2=l2*sin(theta);\n\tv2=l2*cos(theta);\n\tres=min(res,sqrt((u1-u2)*(u1-u2)+(v1-v2)*(v1-v2)));\n return res;\n\tv1=l1;\n\tu2=l2*sin(theta);\n\tv2=l2*cos(theta);\n\tres=min(res,sqrt((u1-u2)*(u1-u2)+(v1-v2)*(v1-v2)));\n\treturn res;\n}\ndouble compute(double alpha,double beta)\n{\n\treturn solve(xa,ya,za,r*cos(alpha),r*sin(alpha),0)+solve(xb,yb,zb,r*cos(beta),r*sin(beta),0)+dist(r*cos(alpha),r*sin(alpha),0,r*cos(beta),r*sin(beta),0);\n}\ndouble compute(double alpha)\n{\t\n\tdouble theta,vl,ch,ret=inf;\n\tfor(theta=0;theta<2*pi;theta+=dtheta)\n\t{\n\t\tvl=compute(alpha,theta);\n\t\tif(ret>vl)\n\t\t{\n\t\t\tret=vl;\n\t\t\tch=theta;\n\t\t}\n\t}\t\n\tlb=max(0.,ch-dtheta);\n\trb=min(2*pi,ch+dtheta);\n\twhile(lbcompute(alpha,myb))\n\t\tlb=mxb+eps;\n\t\telse\n\t\trb=mxb-eps;\n\t}\n\tvl=compute(alpha,0.5*(lb+rb));\n\tif(ret>vl)\n\tret=vl;\n\treturn ret;\n}\nint main()\n{\n\tint i,j,s,p,q,it1,it2;\n\tscanf(\"%lf%lf\",&r,&h);\n\tscanf(\"%lf%lf%lf%lf%lf%lf\",&xa,&ya,&za,&xb,&yb,&zb);\n\tans=inf;\n\tif(fabs(za)>eps&&fabs(zb)>eps)\n\tans=min(ans,solve(xa,ya,za,xb,yb,zb));\n\tif(fabs(za)vl)\n\t\t{\n\t\t\tmi=vl;\n\t\t\tch=theta;\n\t\t}\n\t\tif(ans>vl)\n\t\tans=vl;\n\t}\n\tla=max(0.ch-dtheta);\n\tra=min(2*pi,ch+dtheta);\n\twhile(larv)\n\t\tla=mxa+eps;\n\t\telse\n\t\tra=mxa-eps;\n\n\t}\n\tvl=solve(xa,ya,za,r*cos(0.5*(la+ra)),r*sin(0.5*(la+ra)),0)+solve(xb,yb,zb,r*cos(0.5*(la+ra)),r*sin(0.5*(la+ra)),0);\n\tif(ans>vl)\n\tans=vl;\n\tmi-inf;\n\tfor(theta=0;theta<2*pi;theta+=dtheta)\n\t{\n\t\tvl=compute(theta);\n\t\tif(mi>vl)\n\t{\n\t\tmi=vl;\n\t\tch=theta;\n\t}\n\t if(ans>vl)\n ans=vl;\n\t}\n la=max(0.,ch-dtheta);\n ra=min(2*pi,ch+dtheta);\t\n\twhile(lacompute(mya))\n\tla=mxa+eps;\n\telse\n\tra=mxa-eps;\n\t}\n\tvl=compute(0.5*(l1+ra));\n\tif(ans>vl)\n\tans=vl;\n\tprintf(\"%.20f\\n\",ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d08971594846c251ac5dd7c3e2233209", "src_uid": "c89cc89ed9ba18211a8272cece600f33", "difficulty": 3000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define forn(i, n) for(int i = 0; i < int(n); ++i)\n#define for1(i, n) for(int i = 1; i <= int(n); ++i)\n#define ford(i, n) for(int i = int(n) - 1; i >= 0; --i)\n#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)\n#define sz(v) int((v).size())\n#define all(v) (v).begin(), (v).end()\n#define pb push_back\n#define X first\n#define Y second\n#define mp make_pair\n#define debug(x) {cerr << #x << \" = \" << x << endl;}\ntemplate inline T abs(T a){ return ((a < 0) ? -a : a); }\ntemplate inline T sqr(T a){ return a * a; }\n\ntypedef long long li;\ntypedef long double ld;\ntypedef pair pt;\n\nconst int INF = (int)1E9 + 7;\nconst ld EPS = 1E-9;\nconst ld PI = 3.1415926535897932384626433832795;\n\nconst int NMAX = 300000;\n\nint n;\nvector a[NMAX];\nvector ls[NMAX];\nint it[NMAX], git[NMAX];\n\nint main() {\n #ifdef myproject\n freopen(\"input.txt\", \"rt\", stdin);\n //freopen(\"output.txt\", \"wt\", stdout);\n #endif\n\n scanf(\"%d\", &n);\n\n int ans = 0;\n\n int sumk = 0;\n\n forn(i, n){\n int k, a0, x, y, m;\n scanf(\"%d%d%d%d%d\", &k, &a0, &x, &y, &m);\n// cerr << \"x = \" << x << endl;\n\n assert(k > 0);\n\n a[i].pb(a0);\n forn(j, k-1){\n int na = (li(a[i].back() * 1LL * x) + y) % m;\n a[i].pb(na);\n }\n\n forn(j, k){\n int t = j;\n while(t+1 < sz(a[i]) && a[i][t] <= a[i][t+1])\n t++;\n\n ls[i].pb(t);\n\n j = t;\n }\n\n ans = max(ans, sz(ls[i]) - 1);\n// cerr << endl;\n\n sumk += k;\n }\n\n set s, qs;\n\n forn(i, n)\n s.insert(mp(a[i][0], i));\n\n printf(\"%d\\n\", ans);\n\n if(sumk > 200000) exit(0);\n\n while(!s.empty()){\n// qs.clear();\n\n while(!s.empty()){\n\n int i = s.begin()->Y;\n int v = s.begin()->X;\n s.erase(s.begin());\n\n\n printf(\"%d %d\\n\", v, i+1);\n\n if(it[i] != ls[i][git[i]]){\n it[i]++;\n s.insert(mp(a[i][it[i]], i)); \n }else{\n if(it[i] != sz(a[i]) - 1){\n it[i]++, git[i]++;\n qs.insert(mp(a[i][it[i]], i));\n }\n }\n }\n\n s = qs;\n qs.clear();\n }\n\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f76e2f8ab19a441187392681c24ab0fa", "src_uid": "15ba633cb33854bd4c0ee40847bb173c", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define eprintf(...) fprintf(stderr, __VA_ARGS__)\n#define pb push_back\n#define mp make_pair\n#define sz(x) ((int)(x).size())\n\ntypedef long long ll;\ntypedef vector vll;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vb;\ntypedef vector vvb;\ntypedef pair pii;\n\nint main() {\n #ifdef DEBUG\n freopen(\"std.in\", \"r\", stdin);\n freopen(\"std.out\", \"w\", stdout);\n #endif\n\n int n;\n while (scanf(\"%d\", &n) >= 1) {\n vvi cs(n);\n vector > bs(n);\n int scnt = 0;\n\n vi tmp;\n for (int i = 0; i < n; i++) {\n int k, a, x, y, m;\n scanf(\"%d%d%d%d%d\", &k, &a, &x, &y, &m);\n \n cs[i] = vi(k);\n for (int i2 = 0; i2 < k; i2++) {\n cs[i][i2] = a;\n a = (ll(a) * x + y) % m;\n }\n int pr = -1;\n int st = 0;\n for (int i2 = 0; i2 <= k; i2++) {\n if (i2 >= k || pr > cs[i][i2]) {\n bs[i].pb(mp(st, i2));\n st = i2;\n }\n if (i2 < k)\n pr = cs[i][i2];\n }\n scnt += k;\n }\n bool needOut = scnt <= 200000;\n\n int ans = 0;\n vector ord;\n vi ptrs(n, 0);\n\n for (int bptr = 0;; bptr++) {\n vector curs;\n bool cont = false;\n for (int i = 0; i < n; i++)\n if (sz(bs[i]) > bptr) {\n cont = true;\n if (needOut) {\n for (int i2 = bs[i][bptr].first; i2 < bs[i][bptr].second; i2++)\n curs.pb(mp(cs[i][i2], i));\n }\n }\n if (!cont) break;\n if (needOut) {\n sort(curs.begin(), curs.end());\n ord.insert(ord.end(), curs.begin(), curs.end());\n }\n\n if (bptr > 0) ans++;\n }\n\n printf(\"%d\\n\", ans);\n if (needOut) {\n for (int i = 0; i < sz(ord); i++)\n printf(\"%d %d\\n\", ord[i].first, ord[i].second + 1);\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b351ded401b6449302a32eb1b09ce0dc", "src_uid": "15ba633cb33854bd4c0ee40847bb173c", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\ntypedef long long LL;\ntypedef unsigned long long ULL;\n\n#define PI 3.1415926535897932384626433832795\n#define sqr(x) ((x)*(x))\n\nusing namespace std;\n\nvector a[5555];\nint n, k[5555], x, y, m, gn[5555];\nvector< pair > pool[222222];\n\nint main() {\n//\tfreopen(\".in\", \"r\", stdin);\n//\tfreopen(\".out\", \"w\", stdout);\n\n\tcin >> n;\n\tint ans = 0;\n\tint total = 0;\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> k[i];\n\t\ta[i].resize(k[i]);\n\t\ttotal += k[i];\n\t\tcin >> a[i][0];\n\t\tcin >> x >> y >> m;\n\t\tfor (int j = 1; j < k[i]; j++) a[i][j] = (LL(a[i][j-1]) * x + y) % m;\n\t\tgn[i] = 0;\n\t\tfor (int j = 1; j < k[i]; j++) {\n\t\t\tpool[gn[i]].push_back(make_pair(a[i][j - 1], i + 1));\n\t\t\tif (a[i][j] < a[i][j - 1]) ++gn[i];\n\t\t}\n\t\tif (k[i]) {\n\t\t\tpool[gn[i]].push_back(make_pair(a[i][k[i] - 1], i + 1));\n\t\t\t++gn[i];\n\t\t}\n\t\tans = max(ans, gn[i] - 1);\n\t}\n\tcout << ans << endl;\n\n\tif (total <= 200000) {\n\t\tfor (int i = 0; i <= ans; i++) {\n\t\t\tsort(pool[i].begin(), pool[i].end());\n\t\t\tfor (int j = 0; j < pool[i].size(); j++) cout << pool[i][j].first << \" \" << pool[i][j].second << endl;\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fab8b7ca647e220b2ee807a1b85bf215", "src_uid": "15ba633cb33854bd4c0ee40847bb173c", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\ntypedef long long LL;\ntypedef unsigned long long ULL;\n\n#define PI 3.1415926535897932384626433832795\n#define sqr(x) ((x)*(x))\n\nusing namespace std;\n\nvector a[5555], g[5555];\nint n, k[5555], x, y, m, gn[5555];\nvector< pair > pool[5555];\n\nint main() {\n//\tfreopen(\".in\", \"r\", stdin);\n//\tfreopen(\".out\", \"w\", stdout);\n\n\tcin >> n;\n\tint ans = 0;\n\tint total = 0;\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> k[i];\n\t\ta[i].resize(k[i]);\n\t\ttotal += k[i];\n\t\tcin >> a[i][0];\n\t\tcin >> x >> y >> m;\n\t\tfor (int j = 1; j < k[i]; j++) a[i][j] = (LL(a[i][j-1]) * x + y) % m;\n\t\tgn[i] = 0;\n\t\tg[i].resize(k[i]);\n\t\tfor (int j = 1; j < k[i]; j++) {\n\t\t\tpool[gn[i]].push_back(make_pair(a[i][j - 1], i + 1));\n\n\t\t\tif (a[i][j] < a[i][j-1]) {\n\t\t\t\tg[i][++gn[i]] = j - 1;\n\t\t\t}\n\t\t}\n\t\tif (k[i]) {\n\t\t\tpool[gn[i]].push_back(make_pair(a[i][k[i] - 1], i + 1));\n\t\t\tg[i][++gn[i]] = k[i] - 1;\n\t\t}\n\t\tans = max(ans, gn[i] - 1);\n\t}\n\tcout << ans << endl;\n\n\tif (total <= 200000) {\n\t\tfor (int i = 0; i <= ans; i++) {\n\t\t\tsort(pool[i].begin(), pool[i].end());\n\t\t\tfor (int j = 0; j < pool[i].size(); j++) cout << pool[i][j].first << \" \" << pool[i][j].second << endl;\n\t\t}\n\t}\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6fa578775fdc04d9a24f055fdd817687", "src_uid": "15ba633cb33854bd4c0ee40847bb173c", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\ntemplate \nT inverse(T a, T m) {\n T u = 0, v = 1;\n while (a != 0) {\n T t = m / a;\n m -= t * a; swap(a, m);\n u -= t * v; swap(u, v);\n }\n assert(m == 1);\n return u;\n}\n\ntemplate \nclass Modular {\n public:\n using Type = typename decay::type;\n\n constexpr Modular() : value() {}\n template \n Modular(const U& x) {\n value = normalize(x);\n }\n\n template \n static Type normalize(const U& x) {\n Type v;\n if (-mod() <= x && x < mod()) v = static_cast(x);\n else v = static_cast(x % mod());\n if (v < 0) v += mod();\n return v;\n }\n\n const Type& operator()() const { return value; }\n template \n explicit operator U() const { return static_cast(value); }\n constexpr static Type mod() { return T::value; }\n\n Modular& operator+=(const Modular& other) { if ((value += other.value) >= mod()) value -= mod(); return *this; }\n Modular& operator-=(const Modular& other) { if ((value -= other.value) < 0) value += mod(); return *this; }\n template Modular& operator+=(const U& other) { return *this += Modular(other); }\n template Modular& operator-=(const U& other) { return *this -= Modular(other); }\n Modular& operator++() { return *this += 1; }\n Modular& operator--() { return *this -= 1; }\n Modular operator++(int) { Modular result(*this); *this += 1; return result; }\n Modular operator--(int) { Modular result(*this); *this -= 1; return result; }\n Modular operator-() const { return Modular(-value); }\n\n template \n typename enable_if::Type, int>::value, Modular>::type& operator*=(const Modular& rhs) {\n#ifdef _WIN32\n uint64_t x = static_cast(value) * static_cast(rhs.value);\n uint32_t xh = static_cast(x >> 32), xl = static_cast(x), d, m;\n asm(\n \"divl %4; \\n\\t\"\n : \"=a\" (d), \"=d\" (m)\n : \"d\" (xh), \"a\" (xl), \"r\" (mod())\n );\n value = m;\n#else\n value = normalize(static_cast(value) * static_cast(rhs.value));\n#endif\n return *this;\n }\n template \n typename enable_if::Type, int64_t>::value, Modular>::type& operator*=(const Modular& rhs) {\n int64_t q = static_cast(static_cast(value) * rhs.value / mod());\n value = normalize(value * rhs.value - q * mod());\n return *this;\n }\n template \n typename enable_if::Type>::value, Modular>::type& operator*=(const Modular& rhs) {\n value = normalize(value * rhs.value);\n return *this;\n }\n\n Modular& operator/=(const Modular& other) { return *this *= Modular(inverse(other.value, mod())); }\n\n template \n friend bool operator==(const Modular& lhs, const Modular& rhs);\n\n template \n friend bool operator<(const Modular& lhs, const Modular& rhs);\n\n template \n friend std::istream& operator>>(std::istream& stream, Modular& number);\n\n private:\n Type value;\n};\n\ntemplate bool operator==(const Modular& lhs, const Modular& rhs) { return lhs.value == rhs.value; }\ntemplate bool operator==(const Modular& lhs, U rhs) { return lhs == Modular(rhs); }\ntemplate bool operator==(U lhs, const Modular& rhs) { return Modular(lhs) == rhs; }\n\ntemplate bool operator!=(const Modular& lhs, const Modular& rhs) { return !(lhs == rhs); }\ntemplate bool operator!=(const Modular& lhs, U rhs) { return !(lhs == rhs); }\ntemplate bool operator!=(U lhs, const Modular& rhs) { return !(lhs == rhs); }\n\ntemplate bool operator<(const Modular& lhs, const Modular& rhs) { return lhs.value < rhs.value; }\n\ntemplate Modular operator+(const Modular& lhs, const Modular& rhs) { return Modular(lhs) += rhs; }\ntemplate Modular operator+(const Modular& lhs, U rhs) { return Modular(lhs) += rhs; }\ntemplate Modular operator+(U lhs, const Modular& rhs) { return Modular(lhs) += rhs; }\n\ntemplate Modular operator-(const Modular& lhs, const Modular& rhs) { return Modular(lhs) -= rhs; }\ntemplate Modular operator-(const Modular& lhs, U rhs) { return Modular(lhs) -= rhs; }\ntemplate Modular operator-(U lhs, const Modular& rhs) { return Modular(lhs) -= rhs; }\n\ntemplate Modular operator*(const Modular& lhs, const Modular& rhs) { return Modular(lhs) *= rhs; }\ntemplate Modular operator*(const Modular& lhs, U rhs) { return Modular(lhs) *= rhs; }\ntemplate Modular operator*(U lhs, const Modular& rhs) { return Modular(lhs) *= rhs; }\n\ntemplate Modular operator/(const Modular& lhs, const Modular& rhs) { return Modular(lhs) /= rhs; }\ntemplate Modular operator/(const Modular& lhs, U rhs) { return Modular(lhs) /= rhs; }\ntemplate Modular operator/(U lhs, const Modular& rhs) { return Modular(lhs) /= rhs; }\n\ntemplate\nModular power(const Modular& a, const U& b) {\n assert(b >= 0);\n Modular x = a, res = 1;\n U p = b;\n while (p > 0) {\n if (p & 1) res *= x;\n x *= x;\n p >>= 1;\n }\n return res;\n}\n\ntemplate \nstring to_string(const Modular& number) {\n return to_string(number());\n}\n\ntemplate \nstd::ostream& operator<<(std::ostream& stream, const Modular& number) {\n return stream << number();\n}\n\ntemplate \nstd::istream& operator>>(std::istream& stream, Modular& number) {\n typename common_type::Type, int64_t>::type x;\n stream >> x;\n number.value = Modular::normalize(x);\n return stream;\n}\n\n/*\nusing ModType = int;\n\nstruct VarMod { static ModType value; };\nModType VarMod::value;\nModType& md = VarMod::value;\nusing Mint = Modular;\n*/\n\nconstexpr int md = (int) 1e9 + 7;\nusing Mint = Modular::type, md>>;\n\nint n, w;\n\nint main() {\n cin >> n >> w;\n vector fact(n + 1);\n vector inv_fact(n + 1);\n fact[0] = inv_fact[0] = 1;\n for(int i = 1; i <= n; i++) {\n fact[i] = fact[i - 1] * i;\n inv_fact[i] = 1 / fact[i];\n }\n auto choose_in = [&](int N, int M) {\n if(M > N) return Mint(0);\n return fact[N] * inv_fact[N - M];\n };\n Mint ret = 0;\n for(int s = w + 1; s <= w + n; s++) {\n int x = s - w;\n int sp = s - 2 * x;\n assert(sp > 0);\n if(sp >= 2) {\n Mint tot = choose_in(n, x) * n;\n Mint sub = choose_in(n, x) * (n - x);\n Mint mu = power(Mint(n), sp - 2);\n ret += (tot * tot - sub * sub) * mu;\n } else if(sp == 1) {\n assert(s == 2 * w - 1);\n Mint sub = choose_in(n - 1, x) * choose_in(n - 1, x);\n Mint tot = choose_in(n, x) * choose_in(n, x);\n ret += (tot - sub) * n;\n } else {\n int sz = -sp;\n Mint mu = choose_in(n, sz);\n Mint tot = choose_in(n - sz, w) * choose_in(n - sz, w);\n Mint sub = choose_in(n - sz, w) * choose_in(n - sz - 1, w);\n ret += (tot - sub) * mu;\n }\n }\n cout << ret;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f4c4a6c40f38f6fe1a7abe1fa56ef4f7", "src_uid": "b715f0fdc83ec539eb3ae2b0371ee130", "difficulty": 3000.0} {"lang": "GNU C++", "source_code": "#pragma comment(linker, \"/STACK:65777216\")\n \n#include \n#include \n#include \n#include\n#include\n#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include \n#include\n \nusing namespace std;\n \ntypedef long long ll;\ntypedef vector vi;\ntypedef pair pii;\ntypedef pair pdd;\ntypedef unsigned long long ull;\n \n#define FOR(i,a,b) for (int i(a); i < (b); i++)\n#define REP(i,n) FOR(i,0,n)\n#define SORT(v) sort((v).begin(),(v).end())\n#define UN(v) sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())\n#define CL(a,b) memset(a,b,sizeof(a))\n#define pb push_back\n\nconst int mod = 1000000007;\n\nint qp(ll c,int st){\n\tll r = 1;\n\twhile(st){\n\t\tif(st&1) r*=c,r%=mod;\n\t\tc*=c,c%=mod;\n\t\tst>>=1;\n\t}\n\treturn r;\n}\n\nll f[1111111];\nll inv[1111111];\n\nint c(int n,int m){\n\tif(n<0 || m<0 || m>n) return 0;\n\tll res = f[n];\n\tres *= inv[m];res%=mod;\n\tres *= inv[n-m];res%=mod;\n\treturn res;\n}\n\nint main(){\n#ifdef LocalHost\n freopen(\"input.txt\",\"r\",stdin);\n// freopen(\"output.txt\",\"w\",stdout);\n#endif\n\n\tf[0]=1;\n\tFOR(i,1,1111111) f[i]=f[i-1]*i%mod;\n\tREP(i,1111111) inv[i]=qp(f[i],mod-2);\n\t\n\tint k,w;\n\tcin>>k>>w;\n\n\tint ans = 0;\n\tfor(int len=w+1;;len++){\n\t\t//cout<0){\n\t\t\tint lenx = w - lenw;\n\t\t\t//cout<<\"case1 \"< k) break;\n\t\t\tll t = c(k,lenw);\n\t\t\tt *= c(k-lenw,w); t%=mod;\n\t\t\tt *= c(k-lenw,w); t%=mod;\n\t\t\tt *= f[w]; t%=mod;\n\t\t\tt *= f[w]; t%=mod;\n\t\t\tt *= f[lenw]; t%=mod;\n\t\t\tans += t; ans %= mod;\n\t\t\t\n\t\t\tt = c(k,lenw);\n\t\t\tt *= c(k-lenw,1); t%=mod;\n\t\t\tt *= c(k-lenw-1,1); t%=mod;\n\t\t\tt *= c(k-lenw-2,w-1); t%=mod;\n\t\t\tt *= c(k-lenw-2,w-1); t%=mod;\n\t\t\tt *= f[w-1]; t%=mod;\n\t\t\tt *= f[w-1]; t%=mod;\n\t\t\tt *= f[lenw]; t%=mod;\n\t\t\tans -= t; if(ans<0) ans += mod;\n\n\t\t}\n\n\t}\n\tcout<\n#define MP make_pair\n#define PB push_back\n#define int long long\n#define st first\n#define nd second\n#define rd third\n#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)\n#define RE(i, n) FOR(i, 1, n)\n#define FORD(i, a, b) for(int i = (a); i >= (b); --i)\n#define REP(i, n) for(int i = 0;i <(n); ++i)\n#define VAR(v, i) __typeof(i) v=(i)\n#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)\n#define ALL(x) (x).begin(), (x).end()\n#define SZ(x) ((int)(x).size())\n#define __builtin_ctz __builtin_ctzll\n#define __builtin_clz __builtin_clzll\n#define __builtin_popcount __builtin_popcountll\nusing namespace std;\ntemplate void _dbg(const char* sdbg, TH h) { cerr< void _dbg(const char* sdbg, TH h, TA... t) {\n while(*sdbg != ',') { cerr<<*sdbg++; } cerr<<\"=\"< PII;\ntypedef pair PLL;\ntypedef vector VI;\ntypedef vector VVI;\ntypedef vector VLL;\ntypedef vector > VPII;\ntypedef vector > VPLL;\n \ntemplate void mini(C&a4, C b4){a4=min(a4, b4); }\ntemplate void maxi(C&a4, C b4){a4=max(a4, b4); }\ntemplate\nostream& operator<< (ostream &out, pair pair) { return out << \"(\" << pair.first << \", \" << pair.second << \")\";}\ntemplate struct Triple { A first; B second; C third;\n bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };\ntemplate void ResizeVec(T&, vector) {}\ntemplate void ResizeVec(vector& vec, vector sz) {\n vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }\n for (T& v : vec) { ResizeVec(v, sz); }\n}\ntypedef Triple TIII;\ntemplate\nostream& operator<< (ostream &out, Triple t) { return out << \"(\" << t.st << \", \" << t.nd << \", \" << t.rd << \")\"; }\ntemplate ostream& operator<<(ostream& out, vector vec) { out<<\"(\"; for (auto& v: vec) out< ostream& operator<<(ostream& out, set vec) { out<<\"(\"; for (auto& v: vec) out< ostream& operator<<(ostream& out, map vec) { out<<\"(\"; for (auto& v: vec) out<= 2 * w) {\n\t\t\tint c = len - 2 * w;\n\t\t\tint here = DownFac(k, c);\n\t\t\tint side = DownFac(k - c, w);\n\t\t\tint lol = here * side % P * side % P;\n\t\t\tdebug(k, w, len, lol);\n\t\t\tres = (res + lol) % P;\n\t\t} else {\n\t\t\tint c = 2 * w - len;\n\t\t\tint side = DownFac(k, w - c);\n\t\t\tint mid = Pow(k, c);\n\t\t\tint lol = side * side % P * mid;\n\t\t\tdebug(k, w, len, lol);\n\t\t\tres = (res + lol) % P;\n\t\t}\n\t}\n\tdebug(res);\n\treturn res;\n}\nint32_t main() {\n \n ios_base::sync_with_stdio(0);\n cout << fixed << setprecision(10);\n cerr << fixed << setprecision(10);\n cin.tie(0);\n int w, k;\n cin>>k>>w;\n fac[0] = 1;\n k_pow[0] = 1;\n RE (i, N - 1) {\n \tfac[i] = fac[i - 1] * i % P;\n \tk_pow[i] = k_pow[i - 1] * k % P;\n }\n inv_fac[N - 1] = Inv(fac[N - 1]);\n FORD (i, N - 2, 0) {\n \tinv_fac[i] = inv_fac[i + 1] * (i + 1) % P;\n }\n cout<<(Go(k, w, w) - Go(k, w - 1, w) + P) % P<\n#define MP make_pair\n#define PB push_back\n#define int long long\n#define st first\n#define nd second\n#define rd third\n#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)\n#define RE(i, n) FOR(i, 1, n)\n#define FORD(i, a, b) for(int i = (a); i >= (b); --i)\n#define REP(i, n) for(int i = 0;i <(n); ++i)\n#define VAR(v, i) __typeof(i) v=(i)\n#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)\n#define ALL(x) (x).begin(), (x).end()\n#define SZ(x) ((int)(x).size())\n#define __builtin_ctz __builtin_ctzll\n#define __builtin_clz __builtin_clzll\n#define __builtin_popcount __builtin_popcountll\nusing namespace std;\ntemplate void _dbg(const char* sdbg, TH h) { cerr< void _dbg(const char* sdbg, TH h, TA... t) {\n while(*sdbg != ',') { cerr<<*sdbg++; } cerr<<\"=\"< PII;\ntypedef pair PLL;\ntypedef vector VI;\ntypedef vector VVI;\ntypedef vector VLL;\ntypedef vector > VPII;\ntypedef vector > VPLL;\n \ntemplate void mini(C&a4, C b4){a4=min(a4, b4); }\ntemplate void maxi(C&a4, C b4){a4=max(a4, b4); }\ntemplate\nostream& operator<< (ostream &out, pair pair) { return out << \"(\" << pair.first << \", \" << pair.second << \")\";}\ntemplate struct Triple { A first; B second; C third;\n bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };\ntemplate void ResizeVec(T&, vector) {}\ntemplate void ResizeVec(vector& vec, vector sz) {\n vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }\n for (T& v : vec) { ResizeVec(v, sz); }\n}\ntypedef Triple TIII;\ntemplate\nostream& operator<< (ostream &out, Triple t) { return out << \"(\" << t.st << \", \" << t.nd << \", \" << t.rd << \")\"; }\ntemplate ostream& operator<<(ostream& out, vector vec) { out<<\"(\"; for (auto& v: vec) out< ostream& operator<<(ostream& out, set vec) { out<<\"(\"; for (auto& v: vec) out< ostream& operator<<(ostream& out, map vec) { out<<\"(\"; for (auto& v: vec) out<= 2 * w) {\n\t\t\tint c = len - 2 * w;\n\t\t\tint here = DownFac(k, c);\n\t\t\tint side = DownFac(k - c, w);\n\t\t\tint lol = here * side % P * side % P;\n\t\t\tdebug(k, w, len, lol);\n\t\t\tres = (res + lol) % P;\n\t\t} else {\n\t\t\tint c = 2 * w - len;\n\t\t\tint side = DownFac(k, w - c);\n\t\t\tint mid = spow(k, c);\n\t\t\tint lol = side * side % P * mid;\n\t\t\tdebug(k, w, len, lol);\n\t\t\tres = (res + lol) % P;\n\t\t}\n\t}\n\tdebug(res);\n\treturn res;\n}\nint32_t main() {\n \n ios_base::sync_with_stdio(0);\n cout << fixed << setprecision(10);\n cerr << fixed << setprecision(10);\n cin.tie(0);\n int w, k;\n cin>>k>>w;\n fac[0] = 1;\n k_pow[0] = 1;\n RE (i, N - 1) {\n \tfac[i] = fac[i - 1] * i % P;\n \tk_pow[i] = k_pow[i - 1] * k % P;\n }\n inv_fac[N - 1] = Inv(fac[N - 1]);\n FORD (i, N - 2, 0) {\n \tinv_fac[i] = inv_fac[i + 1] * (i + 1) % P;\n }\n cout<<(Go(k, w, w) - Go(k, w - 1, w) + P) % P<\n//#include \n#include \nusing namespace std;\n\nlong double pi = atan((long double)1)*4;\n\nclass Point\n{\npublic:\n\tlong double x;\n\tlong double y;\n\tPoint(long double xi, long double yi)\n\t{\t\n\t\tx=xi;\n\t\ty=yi;\n\t};\n\tPoint()\n\t{\n\t};\n};\n\nclass Segment\n{\npublic:\n\tPoint p1;\n\tPoint p2;\n\tSegment(Point p1i, Point p2i)\n\t{\n\t\tp1.x=p1i.x;\n\t\tp1.y=p1i.y;\n\t\tp2.x=p2i.x;\n\t\tp2.y=p2i.y;\n\t};\n\tlong double length() \n\t{ \n\t\treturn sqrt( (p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y) ); \n\t}\n};\n\nvoid pos_circle(Point p, long double v, long double t, Point* final_p)\n{\n\tlong double R = sqrt((long double)(p.x*p.x+p.y*p.y));\n\tlong double time_360 = 2*pi*R/v;\n\tlong double ini_angle = atan2((long double)p.y,(long double)p.x);\n\tlong double final_angle = t*2*pi/time_360 + ini_angle;\n\n\tfinal_p->x=cos(final_angle)*R;\n\tfinal_p->y=sin(final_angle)*R;\n}\n\nlong double distance_to_segment (Point p, Segment seg)\n{\n\tSegment a(seg.p1, p);\n\tSegment b(seg.p2, p);\n\tSegment* max;\n\tSegment* min;\n\tif(a.length() > b.length())\n\t{\n\t\tmax = &a;\n\t\tmin = &b;\n\t}\n\telse\n\t{\n\t\tmax = &b;\n\t\tmin = &a;\n\t}\n\n\tif(seg.length()==0 || min->length()==0)\n\t\treturn min->length();\n\n\tif ((min->length() * min->length() + seg.length() * seg.length() - max->length() * max->length()) / (2*min->length()*seg.length()) < 0)\n\t\treturn min->length();\n\t\n\tlong double s = (a.length() + b.length() + seg.length())/2;\n\treturn 2 * sqrt( s * ( s - a.length() ) * (s - b.length() ) * (s - seg.length() ) ) / seg.length();\n\t\n}\n\nvoid tangent_points_to_circle(Point center, long double R, Point p, Point* p1, Point* p2)\n{\n\tSegment s(center, p);\n\tif( s.length() <= R)\n\t{\n\t\tp1->x = p.x;\n\t\tp1->y = p.y;\n\t\tp2->x = p.x;\n\t\tp2->y = p.y;\n\t}\n\telse\n\t{\n\t\tlong double ini_angle = atan2(p.y - center.y , p.x - center.x);\n\t\tlong double final_angle1 = ini_angle + acos(R/s.length()) ;\n\t\tlong double final_angle2 = ini_angle - acos(R/s.length()) ;\n\t\tp1->x=cos(final_angle1)*R + center.x;\n\t\tp1->y=sin(final_angle1)*R + center.y;\n\t\tp2->x=cos(final_angle2)*R + center.x;\n\t\tp2->y=sin(final_angle2)*R + center.y;\n\t}\n}\n\nlong double angle_between(Point p1, Point p2)\n{\t\n\tlong double result = atan2(p1.y, p1.x) - atan2(p2.y, p2.x);\n\n\tif (result > 2*pi)\n\t\tresult -= 2*pi;\n\tif (result < -2*pi)\n\t\tresult += 2*pi;\n\tif (result > pi )\n\t{\n\t\tresult -= 2*pi;\n\t}\n\tif (result < -pi )\n\t{\n\t\tresult += 2*pi;\n\t}\n\treturn abs(result);\n}\n\nint main()\n{\n\tcout.precision(20);\n\tint xp,yp,vp, xs,ys,V, R;\n\t\n\tcin >> xp;\n\tcin >> yp;\n\tcin >> vp;\n\tcin >> xs;\n\tcin >> ys;\n\tcin >> V;\n\tcin >> R;\n\n\tPoint ini_perse(xp,yp);\n\tPoint perse(0,0);\n\tPoint center(0,0);\n\tPoint ship(xs,ys);\n\tlong double time = 0.0000000000000000;\n\tlong double time_ship = 0;\n\tlong double range_min,range_max;\n\n\tif(ini_perse.x == ship.x && ini_perse.y == ship.y)\n\t{\n\t\tcout << time << endl;\n\t\treturn 0;\n\t}\n\n\ttime = 100;\n\n\twhile(true)\n\t{\n\t\tpos_circle(ini_perse,vp,time,&perse);\n\t\tSegment s(perse, ship);\n\t\tlong double distance = distance_to_segment(center, s);\n\t\tif(distance >= R)\n\t\t\ttime_ship = s.length()/V;\n\t\telse\n\t\t{\n\t\t\tPoint ship_tang1, ship_tang2, perse_tang1, perse_tang2;\n\t\t\ttangent_points_to_circle(center, R, ship, &ship_tang1, &ship_tang2);\n\t\t\ttangent_points_to_circle(center, R, perse, &perse_tang1, &perse_tang2);\n\t\t\tSegment route1_ship(ship, ship_tang1);\n\t\t\tSegment route2_ship(ship, ship_tang2);\n\t\t\tSegment route1_perse(perse_tang2, perse);\n\t\t\tSegment route2_perse(perse_tang1, perse);\n\n\t\t\tlong double distance1 = route1_ship.length() + angle_between(ship_tang1, perse_tang2)*R + route1_perse.length();\n\t\t\tlong double distance2 = route2_ship.length() + angle_between(ship_tang2, perse_tang1)*R + route2_perse.length();\n\t\t\ttime_ship = min(distance1, distance2)/V; \n\t\t}\n\t\tif( time_ship < time )\n\t\t\tbreak;\n\t\telse\n\t\t\ttime *= 2;\n\t} \n\n\trange_max = time;\n\trange_min = 0 ; \n\n\n\twhile(true)\n\t{\n\t\ttime = (range_max + range_min ) / 2;\n\t\t//time = 1.319045245;\n\t\tpos_circle(ini_perse,vp,time,&perse);\n\t\tSegment s(perse, ship);\n\t\tlong double distance = distance_to_segment(center, s);\n\t\tif(distance >= R)\n\t\t\ttime_ship = s.length()/V;\n\t\telse\n\t\t{\n\t\t\tPoint ship_tang1, ship_tang2, perse_tang1, perse_tang2;\n\t\t\ttangent_points_to_circle(center, R, ship, &ship_tang1, &ship_tang2);\n\t\t\ttangent_points_to_circle(center, R, perse, &perse_tang1, &perse_tang2);\n\t\t\tSegment route1_ship(ship, ship_tang1);\n\t\t\tSegment route2_ship(ship, ship_tang2);\n\t\t\tSegment route1_perse(perse_tang2, perse);\n\t\t\tSegment route2_perse(perse_tang1, perse);\n\n\t\t\tlong double distance1 = route1_ship.length() + angle_between(ship_tang1, perse_tang2)*R + route1_perse.length();\n\t\t\tlong double distance2 = route2_ship.length() + angle_between(ship_tang2, perse_tang1)*R + route2_perse.length();\n\n\t\t\ttime_ship = min(distance1,distance2)/V; \n\t\t}\n\n\n\t\tif(abs(time-time_ship)<0.0000000001)\n\t\t\tbreak;\n\n\t\tif(time_ship < time)\n\t\t\trange_max = time;\n\t\telse\n\t\t\trange_min = time;\n\t}\n\tcout << time << endl;\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "02d0e531c9df451b9e2e5c9208463ea7", "src_uid": "e8471556906e5fa3a701842570fa4ee2", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\ndouble xp,yp,vp,x,y,v,r,R;\nconst double pi=3.1415926535897926;\ndouble dis(double x,double y,double xt,double yt)\n{\n\treturn pow(pow(x-xt,2)+pow(y-yt,2),0.5);\n}\nbool ok(double time)\n{\n\tdouble xt,yt,a,cos1,sin1;\n\ta=vp*time/R;\n\tcos1=xp/R;sin1=yp/R;\n\txt=R*(cos1*cos(a)-sin(a)*sin1);\n\tyt=R*(sin1*cos(a)+cos1*sin(a));\n\tdouble d=abs(x*yt-xt*y)/pow(pow(y-yt,2)+pow(xt-x,2),0.5);\n\tbool cd;\n\tif (x==xt) cd=x<=-r||x>=r;\n\telse \n\t{\n\t\tdouble k=(y-yt)/(x-xt),bb=(x*yt-y*xt)/(x-xt);\n\t\tcd=false;\n\t\tif (k*k*bb*bb-(bb*bb-r*r)*(1+k*k)<=0) cd=true;\n\t\tdouble aa=1+k*k,cc=bb*bb-r*r;\n\t\tbb=2*k*bb;\n\t\tdouble tt1=(aa*x*x+bb*x+cc),tt2=(aa*xt*xt+bb*xt+cc);\n\t\tif (tt1*tt2>=0&&(-bb/2/aa<=min(x,xt)||-bb/2/aa>=max(x,xt))) cd=true;\n\t}\n\tif (d>=r||cd) return (dis(x,y,xt,yt)/v)<=time;\n\tdouble d1=dis(0,0,x,y),d2=dis(0,0,xt,yt),d3,d4,sumd;\n\td3=pow(d1*d1-r*r,0.5);d4=pow(d2*d2-r*r,0.5);\n\tsumd=d3+d4;\n\tdouble t1=atan(y/x);\n\tif (x<0) t1+=pi;\n\tdouble t2=atan(yt/xt);\n\tif (xt<0) t2+=pi;\n\tdouble b;\n\tb=t1-t2;\n\tb+=4*pi;\n\twhile (b>2*pi) b-=2*pi;\n\tif (b>pi) b=2*pi-b;\n\tdouble cc,dd;\n\tcc=asin(d3/dis(0,0,x,y));\n\tdd=asin(d4/dis(0,0,xt,yt));\n\tb-=cc+dd;\n\tsumd+=b*r;\n\treturn sumd/v<=time;\n}\nint main()\n{\n // freopen(\"data.in\",\"r\",stdin);\n\t//freopen(\"data.out\",\"w\",stdout);\n\tscanf(\"%lf%lf%lf%lf%lf%lf%lf\",&xp,&yp,&vp,&x,&y,&v,&r);\n\tR=pow(xp*xp+yp*yp,0.5);\n\tdouble l,r;\n\tl=0;r=1e99;\n\twhile (abs(l-r)>1e-15)\n\t{\n\t\tdouble mid=(l+r)/2;\n\t\tif (ok(mid)) r=mid-1e-15;\n\t\telse l=mid+1e-15;\n\t}\n\tprintf(\"%.9lf\",l);\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "42ed5df2d3e67a64625d94dca23e4fd8", "src_uid": "e8471556906e5fa3a701842570fa4ee2", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define START clock_t _clock = clock();\n#define END cerr << endl << \"time: \" << (clock() - _clock) / LD(CLOCKS_PER_SEC) << endl;\ntypedef long double LD;\ntypedef long long LL;\n\nconst LD pi = acos(-1.0);\nconst LD eps = 1e-9;\nLD xp, yp, vp, xs, ys, v, r;\n\nLD sqr(LD x)\n{\n return x * x;\n}\n\nLD mmax(LD x, LD y)\n{\n return x > y ? x : y;\n}\n\nLD mmin(LD x, LD y)\n{\n return x < y ? x : y;\n}\n\nLD distance(LD x1, LD y1, LD x2, LD y2)\n{\n return sqrt( LD(sqr(x1 - x2) + sqr(y1 - y2)) );\n}\n\nLD cathetus(LD hyp, LD cath)\n{\n return sqrt(sqr(hyp) - sqr(cath));\n}\n\n// \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u043b\u0430\u043d\u0435\u0442\u0430 \u0438\u043c\u0435\u0435\u0442 \u0443\u0433\u043e\u043b atan(yp / xp)\n// \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 >= tm, \u043a\u043e\u0433\u0434\u0430 \u043f\u043b\u0430\u043d\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0443\u0433\u043e\u043b angle\nLD ptime(LD angle, LD tm)\n{\n // \u0440\u0430\u0434\u0438\u0443\u0441 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043f\u043b\u0430\u043d\u0435\u0442\u044b\n LD R = distance(xp, yp, 0, 0);\n // \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0443\u0433\u043e\u043b \u043f\u043b\u0430\u043d\u0435\u0442\u044b\n LD pangle = atan2(yp, xp);\n if (pangle < 0)\n pangle += 2 * pi;\n // \u0432\u0440\u0435\u043c\u044f \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u043f\u043b\u0430\u043d\u0435\u0442\u043e\u0439 \u0443\u0433\u043b\u0430 angle\n LD res = ( angle + (angle < pangle ? 2 * pi : 0) - pangle) / vp * R;\n // \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043f\u043b\u0430\u043d\u0435\u0442\u044b\n LD ptm = 2 * pi * R / vp;\n\n res += floor((res - ptm) / ptm) * ptm;\n while (res < tm)\n res += ptm;\n\n return res;\n}\n\nLD time(LD angle)\n{\n // \u0440\u0430\u0434\u0438\u0443\u0441 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043f\u043b\u0430\u043d\u0435\u0442\u044b\n LD R = distance(xp, yp, 0, 0);\n // \u043c\u0435\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0438 \u043f\u043b\u0430\u043d\u0435\u0442\u044b \u0438 \u043a\u043e\u0440\u0430\u0431\u043b\u044f (D)\n LD xd = R * cos(angle);\n LD yd = R * sin(angle);\n\n/*------------- \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043b\u0438 \u043e\u0433\u0438\u0431\u0430\u0442\u044c \u0437\u0432\u0435\u0437\u0434\u0443 -----------------------------------*/\n bool intersect = false;\n\n // \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u044f\u043c\u043e\u0439\n LD A = ys - yd;\n LD B = xd - xs;\n LD C = xs * yd - xd * ys;\n // \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043e\u0442 \u0446\u0435\u043d\u0442\u0440\u0430 \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438 (0,0) \u0434\u043e \u043f\u0440\u044f\u043c\u043e\u0439 SD\n LD sdist = sqr(C) / (sqr(A) + sqr(B));\n\n // \u0435\u0441\u043b\u0438 \u043f\u0440\u044f\u043c\u0430\u044f \u0438 \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0442\u0441\u044f\n if (sdist <= sqr(r))\n {\n // \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u044b \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0441\u0435\u0447\u0435\u043d\u0438\u044f\n LD a = 1 + sqr(A / B);\n LD b = 2 * A * C / sqr(B);\n LD c = sqr(C / B) - sqr(r);\n LD discr = sqr(b) - 4 * a * c;\n // \u0442\u043e\u0447\u043a\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f:\n LD x1 = (-b - sqrt(discr)) / (2 * a);\n LD x2 = (-b + sqrt(discr)) / (2 * a);\n // \u0435\u0441\u043b\u0438 \u043e\u0442\u0440\u0435\u0437\u043e\u043a \u0438 \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0442\u0441\u044f, \u0442\u043e \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043e\u0433\u0438\u0431\u0430\u0442\u044c \u0437\u0432\u0435\u0437\u0434\u0443\n if (min(xs, xd) <= x1 && x1 <= max(xs, xd) || min(xs, xd) <= x2 && x2 <= max(xs, xd))\n intersect = true;\n }\n/*-----------------------------------------------------------------------------*/\n\n LD dist; // \u0434\u043b\u0438\u043d\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u0438\u0437 \u0442\u043e\u0447\u043a\u0438 S \u0432 \u0442\u043e\u0447\u043a\u0443 D\n if (intersect)\n {\n LD a = distance(xs, ys, 0, 0);\n LD b = cathetus(a, r); // \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0434\u043e \u0434\u0443\u0433\u0438\n\n LD c = distance(xd, yd, 0, 0);\n LD d = cathetus(c, r); // \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043f\u043e\u0441\u043b\u0435 \u0434\u0443\u0433\u0438\n\n LD e = distance(xs, ys, xd, yd);\n LD alpha = acos( (sqr(c) + sqr(a) - sqr(e)) / (2 * c * a) );\n LD alpha1 = atan2(d, r);\n LD alpha2 = atan2(b, r);\n\n LD phi = alpha - alpha1 - alpha2;\n LD arc = phi * r; // \u0434\u043b\u0438\u043d\u0430 \u0434\u0443\u0433\u0438\n\n\n // \u0432\u0441\u0451 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435\n dist = b + arc + d;\n }\n else\n dist = distance(xs, ys, xd, yd);\n \n // \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u0438\u0431\u044b\u0442\u0438\u044f \u043a\u043e\u0440\u0430\u0431\u043b\u044f \u0432 \u0442\u043e\u0447\u043a\u0443 \u043d\u0430 \u043e\u0440\u0431\u0438\u0442\u0435 \u0441 \u0443\u0433\u043b\u043e\u043c angle:\n LD tm = dist / v;\n\n // \u0432\u0440\u0435\u043c\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u0438\u0431\u044b\u0442\u0438\u044f \u043f\u043b\u0430\u043d\u0435\u0442\u044b \u0432 \u044d\u0442\u0443 \u0436\u0435 \u0442\u043e\u0447\u043a\u0443\n return ptime(angle, tm);\n}\n\nLD getminangle(LD left, LD right, LD step)\n{\n LD minangle = left,\n mintime = time(minangle);\n for (LD angle = left + step; angle < right; angle += step)\n {\n LD tm = time(angle);\n if (tm < mintime)\n mintime = tm,\n minangle = angle;\n }\n return minangle;\n}\n\nmain()\n{\n cin >> xp >> yp >> vp >> xs >> ys >> v >> r;\n\n const LD step = 0.00005;\n const LD u = 0.0008;\n const LD left = 0.0;\n const LD right = 2 * pi;\n\n // \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0443\u0433\u043e\u043b \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 time \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043d\u0430 \u0432\u0441\u0451\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0435 \u0443\u0433\u043b\u043e\u0432\n LD a = getminangle(left, right, step);\n // \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432 \u043e\u043a\u0440\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u0438 \u0443\u0433\u043b\u0430 a\n LD res = time(getminangle(mmax(left, a - u), mmin(right, a + u), eps));\n\n\n cout.setf(ios::fixed); cout.precision(8);\n\n cout << res << endl;\n}\n/*\n\n\u0418\u0434\u0435\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f:\n\n\u0412\u043e\u0437\u044c\u043c\u0451\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u043d\u0430 \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u0438 (D), \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u043b\u0430\u043d\u0435\u0442\u0430.\n\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043e\u0442 \u043c\u0435\u0441\u0442\u0430 \u0441\u0442\u0430\u0440\u0442\u0430 \u043a\u043e\u0440\u0430\u0431\u043b\u044f (S \u0434\u043e \u044d\u0442\u043e\u0439 \u0442\u043e\u0447\u043a\u0438.\n\u0415\u0441\u043b\u0438 \u043d\u0430 \u043f\u0443\u0442\u0438 \u0432\u0441\u0442\u0435\u0442\u0438\u0442\u0441\u044f \u043e\u043a\u0440\u0443\u0436\u043d\u043e\u0441\u0442\u044c \u0437\u0432\u0435\u0437\u0434\u044b, \u0442\u043e \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0433\u0438\u0431\u0430\u043d\u0438\u0435,\n\u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u0441\u044f.\n\n\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0432\u0440\u0435\u043c\u044f (tm) \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438 \u043a\u043e\u0440\u0430\u0431\u043b\u044f \u043e\u0442 S \u0434\u043e D.\n\n\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c f(alpha) \u0431\u0443\u0434\u0435\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u043b\u0438\u0431\u043e \u0440\u0430\u0432\u043d\u043e\u0435 tm, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u043b\u0430\u043d\u0435\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432 \u0442\u043e\u0447\u043a\u0435 D.\n\n\u041e\u0442\u0432\u0435\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 min(f(alpha)), \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0442\u0435\u0440\u043d\u0430\u0440\u043d\u044b\u043c \u043f\u043e\u0438\u0441\u043a\u043e\u043c. alpha \u0437\u0430\u0434\u0430\u0451\u0442 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e\u0435 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0442\u043e\u0447\u043a\u0438 D.\n\n*/", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1cbff5fa65bc938e4590f3c9d8f99c03", "src_uid": "e8471556906e5fa3a701842570fa4ee2", "difficulty": 2400.0} {"lang": "MS C++", "source_code": "#include \n//#include \n#include \nusing namespace std;\n\nlong double pi = atan((long double)1)*4;\n\nclass Point\n{\npublic:\n\tlong double x;\n\tlong double y;\n\tPoint(long double xi, long double yi)\n\t{\t\n\t\tx=xi;\n\t\ty=yi;\n\t};\n\tPoint()\n\t{\n\t};\n};\n\nclass Segment\n{\npublic:\n\tPoint p1;\n\tPoint p2;\n\tSegment(Point p1i, Point p2i)\n\t{\n\t\tp1.x=p1i.x;\n\t\tp1.y=p1i.y;\n\t\tp2.x=p2i.x;\n\t\tp2.y=p2i.y;\n\t};\n\tlong double length() \n\t{ \n\t\treturn sqrt( (p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y) ); \n\t}\n};\n\nvoid pos_circle(Point p, long double v, long double t, Point* final_p)\n{\n\tlong double R = sqrt((long double)(p.x*p.x+p.y*p.y));\n\tlong double time_360 = 2*pi*R/v;\n\tlong double ini_angle = atan2((long double)p.y,(long double)p.x);\n\tlong double final_angle = t*2*pi/time_360 + ini_angle;\n\n\tfinal_p->x=cos(final_angle)*R;\n\tfinal_p->y=sin(final_angle)*R;\n}\n\nlong double distance_to_segment (Point p, Segment seg)\n{\n\tSegment a(seg.p1, p);\n\tSegment b(seg.p2, p);\n\tSegment* max;\n\tSegment* min;\n\tif(a.length() > b.length())\n\t{\n\t\tmax = &a;\n\t\tmin = &b;\n\t}\n\telse\n\t{\n\t\tmax = &b;\n\t\tmin = &a;\n\t}\n\n\tif(seg.length()==0 || min->length()==0)\n\t\treturn min->length();\n\n\tif ((min->length() * min->length() + seg.length() * seg.length() - max->length() * max->length()) / (2*min->length()*seg.length()) < 0)\n\t\treturn min->length();\n\t\n\tlong double s = (a.length() + b.length() + seg.length())/2;\n\treturn 2 * sqrt( s * ( s - a.length() ) * (s - b.length() ) * (s - seg.length() ) ) / seg.length();\n\t\n}\n\nvoid tangent_points_to_circle(Point center, long double R, Point p, Point* p1, Point* p2)\n{\n\tSegment s(center, p);\n\tif( s.length() <= R)\n\t\treturn;\n\telse\n\t{\n\t\tlong double ini_angle = atan2(p.y - center.y , p.x - center.x);\n\t\tlong double final_angle1 = ini_angle + acos(R/s.length()) ;\n\t\tlong double final_angle2 = ini_angle - acos(R/s.length()) ;\n\t\tp1->x=cos(final_angle1)*R + center.x;\n\t\tp1->y=sin(final_angle1)*R + center.y;\n\t\tp2->x=cos(final_angle2)*R + center.x;\n\t\tp2->y=sin(final_angle2)*R + center.y;\n\t}\n}\n\n\nint main()\n{\n\tcout.precision(20);\n\tint xp,yp,vp, xs,ys,V, R;\n\t\n\tcin >> xp;\n\tcin >> yp;\n\tcin >> vp;\n\tcin >> xs;\n\tcin >> ys;\n\tcin >> V;\n\tcin >> R;\n\n\tPoint ini_perse(xp,yp);\n\tPoint perse(0,0);\n\tPoint center(0,0);\n\tPoint ship(xs,ys);\n\tlong double time = 0.0000000000000000;\n\tlong double time_ship = 0;\n\tlong double range_min,range_max;\n\n\tif(ini_perse.x == ship.x && ini_perse.y == ship.y)\n\t{\n\t\tcout << time << endl;\n\t\treturn 0;\n\t}\n\n\ttime = 100;\n\n\twhile(true)\n\t{\n\t\tpos_circle(ini_perse,vp,time,&perse);\n\t\tSegment s(perse, ship);\n\t\tlong double distance = distance_to_segment(center, s);\n\t\tif(distance >= R)\n\t\t\ttime_ship = s.length()/V;\n\t\telse\n\t\t{\n\t\t\tPoint ship_tang1, ship_tang2, perse_tang1, perse_tang2;\n\t\t\ttangent_points_to_circle(center, R, ship, &ship_tang1, &ship_tang2);\n\t\t\ttangent_points_to_circle(center, R, perse, &perse_tang1, &perse_tang2);\n\t\t\tSegment route1_ship(ship, ship_tang1);\n\t\t\tSegment route2_ship(ship, ship_tang2);\n\t\t\tSegment route1_perse(perse_tang2, perse);\n\t\t\tSegment route2_perse(perse_tang1, perse);\n\n\t\t\tlong double distance1 = route1_ship.length() + abs(atan2(ship_tang1.y, ship_tang1.x) - atan2(perse_tang2.y, perse_tang2.x))*2*R + route1_perse.length();\n\t\t\tlong double distance2 = route2_ship.length() + abs(atan2(ship_tang2.y, ship_tang2.x) - atan2(perse_tang1.y, perse_tang1.x))*2*R + route2_perse.length();\n\t\t\ttime_ship = min(distance1, distance2)/V; \n\t\t}\n\t\tif( time_ship < time )\n\t\t\tbreak;\n\t\telse\n\t\t\ttime *= 2;\n\t} \n\n\trange_max = time;\n\trange_min = 0 ; \n\n\n\twhile(true)\n\t{\n\t\ttime = (range_max + range_min ) / 2;\n\t\t//time = 2.047618248;\n\t\tpos_circle(ini_perse,vp,time,&perse);\n\t\tSegment s(perse, ship);\n\t\tlong double distance = distance_to_segment(center, s);\n\t\tif(distance >= R)\n\t\t\ttime_ship = s.length()/V;\n\t\telse\n\t\t{\n\t\t\tPoint ship_tang1, ship_tang2, perse_tang1, perse_tang2;\n\t\t\ttangent_points_to_circle(center, R, ship, &ship_tang1, &ship_tang2);\n\t\t\ttangent_points_to_circle(center, R, perse, &perse_tang1, &perse_tang2);\n\t\t\tSegment route1_ship(ship, ship_tang1);\n\t\t\tSegment route2_ship(ship, ship_tang2);\n\t\t\tSegment route1_perse(perse_tang2, perse);\n\t\t\tSegment route2_perse(perse_tang1, perse);\n\n\t\t\tlong double distance1 = route1_ship.length() + abs(atan2(ship_tang1.y, ship_tang1.x) - atan2(perse_tang2.y, perse_tang2.x))*R + route1_perse.length();\n\t\t\tlong double distance2 = route2_ship.length() + abs(atan2(ship_tang2.y, ship_tang2.x) - atan2(perse_tang1.y, perse_tang1.x))*R + route2_perse.length();\n\t\t\ttime_ship = min(distance1,distance2)/V; \n\t\t}\n\n\n\t\tif(abs(time-time_ship)<0.0000000001)\n\t\t\tbreak;\n\n\t\tif(time_ship < time)\n\t\t\trange_max = time;\n\t\telse\n\t\t\trange_min = time;\n\t}\n\tcout << time << endl;\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f8a755b04eb3893c172b6771872e3dd9", "src_uid": "e8471556906e5fa3a701842570fa4ee2", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\n#define mp make_pair\n#define PI pair\n#define poly vector\n#define mem(a) memset((a),0,sizeof(a))\n#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)\n#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)\n#define pb push_back\n#define fi first\n#define se second\ninline char gc(){\n static char buf[100000],*p1=buf,*p2=buf;\n return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;\n}\n#define gc getchar\ninline ll read(){\n\tll x = 0; char ch = gc(); bool positive = 1;\n\tfor (; !isdigit(ch); ch = gc())\tif (ch == '-')\tpositive = 0;\n\tfor (; isdigit(ch); ch = gc())\tx = x * 10 + ch - '0';\n\treturn positive ? x : -x;\n}\ninline void write(ll a){\n if(a<0){\n \ta=-a; putchar('-');\n\t}\n if(a>=10)write(a/10);\n putchar('0'+a%10);\n}\ninline void writeln(ll a){write(a); puts(\"\");}\ninline void wri(ll a){write(a); putchar(' ');}\ninline ull rnd(){\n\treturn ((ull)rand()<<30^rand())<<4|rand()%4;\n}\nvoid GG(){\n\tputs(\"-1\"); exit(0);\n}\nll a[4],b[4],ta,tb;\nint aa[2],bb[2];\npoly dq,ans;\nll g;\nvoid pp(ll *a){\n\tFor(i,0,3)wri(a[i]); puts(\"\");\n}\nvoid bao(ll &a,ll &b){\n\tif(a==b)return;\n\tdq.pb(mp(a,b));\n\ta=2*b-a;\n}\nvoid pr(poly &a){\n\tfor(auto i:a){\n\t\tans.pb(i);\n\t}\n}\npoly bao(ll *a){\n\twhile(a[3]-a[0]>g){\n\t\tll t=(a[3]-a[0]+3)/4;\n\t\tif(a[1]>=a[0]+t&&a[1]<=a[3]-t){\n\t\t\tif(a[1]-a[0]=a[0]+t&&a[2]<=a[3]-t){\n\t\t\tif(a[2]-a[0]=a[0])solve(a,b[0]-a[0],0); else solve(b,a[0]-b[0],1);\n\tchu(B);\n\tpr(B);\n\tcout<\nusing namespace std;\n\nusing ll = long long;\n\npair, ll> sig(vector a){\n\tll r1 = a[1] - a[0];\n\tll r2 = a[2] - a[1];\n\tll r3 = a[3] - a[2];\n\tll g = __gcd(__gcd(r1, r2), r3);\n\tif(g == 0){\n\t\treturn {{0, a[0]}, 0};\n\t}\n\tll f = ((a[0] % g) + g) % g;\n\n\tll res = 0;\n\tfor(int j = 0; j < 4; j++) res += ((a[j] - f) / g) & 1;\n\treturn {{g, f}, res};\n}\n\nbool between(ll x, ll a, ll b){\n\treturn (a <= x && x <= b) || (b <= x && x <= a);\n}\n\nint main(){\n\tios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n\n\tfunction&, vector >&)> solve;\n\tsolve = [&](vector& v, vector >& moves) {\n\t\tauto make = [&](int i, int j) {\n\t\t\tmoves.push_back({v[i], v[j]});\n\t\t\tv[i] = 2 * v[j] - v[i];\n\t\t};\n\t\twhile(true){\n\t\t\tsort(v.begin(), v.end());\n\t\t\tif(v[0] == v[3]){\n\t\t\t\t// nothing\n\t\t\t} else if(v[0] + 1 < v[3]){\n\t\t\t\tll th = (v[3] - v[0]) / 8;\n\t\t\t\t// get to a, a+1 only\n\t\t\t\tif(v[3] - v[2] > th && v[1] - v[0] > th){\n\t\t\t\t\tif(v[1] > 0){\n\t\t\t\t\t\tmake(3, 1); continue;\n\t\t\t\t\t}\n\t\t\t\t\tif(v[2] < 0){\n\t\t\t\t\t\tmake(0, 2); continue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor(int j = 1; j <= 2; j++){\n\t\t\t\t\tif(v[j] - v[0] > th && v[3] - v[j] > th){\n\t\t\t\t\t\tif(v[3] - v[j] > v[j] - v[0]){\n\t\t\t\t\t\t\tmake(0, j); goto done;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmake(3, j); goto done;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(v[1] - v[0] > th){\n\t\t\t\t\tmake(3, 1); continue;\n\t\t\t\t}\n\t\t\t\tif(v[3] - v[2] > th){\n\t\t\t\t\tmake(0, 2); continue;\n\t\t\t\t}\n\t\t\t\tif(v[2] - v[1] > th){\n\t\t\t\t\tif(v[1] - v[0] > v[3] - v[2]){\n\t\t\t\t\t\tmake(2, 1); make(2, 0); continue;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmake(1, 2); make(1, 3); continue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tassert(false);\n\t\t\t} else if(v[0] == 0){\n\t\t\t\t// nothing\n\t\t\t} else if(v[3] == 0 && v[0] < 0){\n\t\t\t\tfor(int i = 0; i < 3; i++){\n\t\t\t\t\tmake(i, 3);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t} else if(v[1] != v[2]) {\n\t\t\t\tif(v[0] > 0 && v[0] == v[2]){\n\t\t\t\t\tmake(3, 0); sort(v.begin(), v.end());\n\t\t\t\t}\n\t\t\t\tif(v[3] < 0 && v[1] == v[3]){\n\t\t\t\t\tmake(0, 3); sort(v.begin(), v.end());\n\t\t\t\t}\n\t\t\t\twhile(v[3] < 0){\n\t\t\t\t\tmake(1, 3); sort(v.begin(), v.end());\n\t\t\t\t}\n\t\t\t\twhile(v[0] > 0){\n\t\t\t\t\tmake(2, 0); sort(v.begin(), v.end());\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif(v[0] == v[2] && v[3] > 0) make(3, 0);\n\t\t\t\tif(v[1] == v[3] && v[0] < 0) make(0, 3);\n\t\t\t\tsort(v.begin(), v.end());\n\t\t\t\tbool flag = false;\n\t\t\t\tif(v[0] != v[2]) flag = true;\n\n\t\t\t\tif(flag) reverse(v.begin(), v.end());\n\t\t\t\twhile(!between(0, v[0], v[3])){\n\t\t\t\t\tmake(1, 3); sort(v.begin(), v.end()); if(flag) reverse(v.begin(), v.end());\n\t\t\t\t}\n\t\t\t\twhile(abs(v[0] - v[3]) > 1){\n\t\t\t\t\tmake(3, 2); sort(v.begin(), v.end()); if(flag) reverse(v.begin(), v.end());\n\t\t\t\t\twhile(!between(0, v[0], v[3])){\n\t\t\t\t\t\tmake(0, 3);\n\t\t\t\t\t\tmake(1, 3);\n\t\t\t\t\t\tmake(2, 3);\n\t\t\t\t\t\tflag = !flag;\n\t\t\t\t\t\tassert(moves.size() <= 1000)\n\t\t\t\t\t}\n\t\t\t\t\tassert(moves.size() <= 1000)\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tbreak;\n\t\t\tdone:;\n\t\t\tcontinue;\n\t\t}\n\t};\n\n\tvector > a(2, vector(4));\n\tfor(int x = 0; x < 2; x++){\n\t\tfor(int i = 0; i < 4; i++){\n\t\t\tcin >> a[x][i];\n\t\t}\n\t\tsort(a[x].begin(), a[x].end());\n\t}\n\tif(sig(a[0]) != sig(a[1])){\n\t\tcout << -1 << '\\n';\n\t\treturn 0;\n\t}\n\tll g = sig(a[0]).first.first;\n\tll f = sig(a[0]).first.second;\n\tif(g == 0){\n\t\tcout << 0 << '\\n';\n\t\treturn 0;\n\t}\n\tfor(int j = 0; j < 2; j++){\n\t\tfor(ll& x : a[j]){\n\t\t\tx = (x - f) / g;\n\t\t}\n\t}\n\tvector > > moves(2);\n\tsolve(a[0], moves[0]);\n\tsolve(a[1], moves[1]);\n\n\tfor(pair& x : moves[1]){\n\t\tx.first = x.second * 2 - x.first;\n\t}\n\treverse(moves[1].begin(), moves[1].end());\n\tmoves[0].insert(moves[0].end(), moves[1].begin(), moves[1].end());\n\n\tvector > real_moves;\n\tfor(pair x : moves[0]){\n\t\tif(x.first == x.second) continue;\n\t\treal_moves.push_back(x);\n\t}\n\tcout << real_moves.size() << '\\n';\n\tfor(pair x : real_moves){\n\t\tif(x.first == x.second) continue;\n\t\tcout << x.first * g + f << ' ' << x.second * g + f << '\\n';\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6046888f0ad22da499d53c2656fa29aa", "src_uid": "7b6b3d4bc0a269836bc0113bb17f562f", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\nusing ll = long long;\n\npair, ll> sig(vector a){\n\tll r1 = a[1] - a[0];\n\tll r2 = a[2] - a[1];\n\tll r3 = a[3] - a[2];\n\tll g = __gcd(__gcd(r1, r2), r3);\n\tif(g == 0){\n\t\treturn {{0, a[0]}, 0};\n\t}\n\tll f = ((a[0] % g) + g) % g;\n\n\tll res = 0;\n\tfor(int j = 0; j < 4; j++) res += ((a[j] - f) / g) & 1;\n\treturn {{g, f}, res};\n}\n\nbool between(ll x, ll a, ll b){\n\treturn (a <= x && x <= b) || (b <= x && x <= a);\n}\n\nint main(){\n\tios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n\n\tfunction&, vector >&)> solve;\n\tsolve = [&](vector& v, vector >& moves) {\n\t\tauto make = [&](int i, int j) {\n\t\t\tmoves.push_back({v[i], v[j]});\n\t\t\tv[i] = 2 * v[j] - v[i];\n\t\t};\n\t\twhile(true){\n\t\t\tsort(v.begin(), v.end());\n\t\t\tif(v[0] == v[3]){\n\t\t\t\t// nothing\n\t\t\t} else if(v[0] + 1 < v[3]){\n\t\t\t\tll th = (v[3] - v[0]) / 8;\n\t\t\t\t// get to a, a+1 only\n\t\t\t\tif(v[3] - v[2] > th && v[1] - v[0] > th){\n\t\t\t\t\tif(v[1] > 0){\n\t\t\t\t\t\tmake(3, 1); continue;\n\t\t\t\t\t}\n\t\t\t\t\tif(v[2] < 0){\n\t\t\t\t\t\tmake(0, 2); continue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor(int j = 1; j <= 2; j++){\n\t\t\t\t\tif(v[j] - v[0] > th && v[3] - v[j] > th){\n\t\t\t\t\t\tif(v[3] - v[j] > v[j] - v[0]){\n\t\t\t\t\t\t\tmake(0, j); goto done;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmake(3, j); goto done;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(v[1] - v[0] > th){\n\t\t\t\t\tmake(3, 1); continue;\n\t\t\t\t}\n\t\t\t\tif(v[3] - v[2] > th){\n\t\t\t\t\tmake(0, 2); continue;\n\t\t\t\t}\n\t\t\t\tif(v[2] - v[1] > th){\n\t\t\t\t\tif(v[1] - v[0] > v[3] - v[2]){\n\t\t\t\t\t\tmake(2, 1); make(2, 0); continue;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmake(1, 2); make(1, 3); continue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tassert(false);\n\t\t\t} else if(v[0] == 0){\n\t\t\t\t// nothing\n\t\t\t} else if(v[3] == 0 && v[0] < 0){\n\t\t\t\tfor(int i = 0; i < 3; i++){\n\t\t\t\t\tmake(i, 3);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t} else if(v[1] != v[2]) {\n\t\t\t\tif(v[0] > 0 && v[0] == v[2]){\n\t\t\t\t\tmake(3, 0); sort(v.begin(), v.end());\n\t\t\t\t}\n\t\t\t\tif(v[3] < 0 && v[1] == v[3]){\n\t\t\t\t\tmake(0, 3); sort(v.begin(), v.end());\n\t\t\t\t}\n\t\t\t\twhile(v[3] < 0){\n\t\t\t\t\tmake(1, 3); sort(v.begin(), v.end());\n\t\t\t\t}\n\t\t\t\twhile(v[0] > 0){\n\t\t\t\t\tmake(2, 0); sort(v.begin(), v.end());\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// no clue waht to do;\n\t\t\t\tif(moves.size() >= 1000) assert(false);\n\t\t\t\tcontinue;\n\t\t\t} else assert(false);\n\t\t\tbreak;\n\t\t\tdone:;\n\t\t\tcontinue;\n\t\t}\n\t};\n\n\tvector > a(2, vector(4));\n\tfor(int x = 0; x < 2; x++){\n\t\tfor(int i = 0; i < 4; i++){\n\t\t\tcin >> a[x][i];\n\t\t}\n\t\tsort(a[x].begin(), a[x].end());\n\t}\n\tif(sig(a[0]) != sig(a[1])){\n\t\tcout << -1 << '\\n';\n\t\treturn 0;\n\t}\n\tll g = sig(a[0]).first.first;\n\tll f = sig(a[0]).first.second;\n\tif(g == 0){\n\t\tcout << 0 << '\\n';\n\t\treturn 0;\n\t}\n\tfor(int j = 0; j < 2; j++){\n\t\tfor(ll& x : a[j]){\n\t\t\tx = (x - f) / g;\n\t\t}\n\t}\n\tvector > > moves(2);\n\tsolve(a[0], moves[0]);\n\tsolve(a[1], moves[1]);\n\n\tfor(pair& x : moves[1]){\n\t\tx.first = x.second * 2 - x.first;\n\t}\n\treverse(moves[1].begin(), moves[1].end());\n\tmoves[0].insert(moves[0].end(), moves[1].begin(), moves[1].end());\n\n\tvector > real_moves;\n\tfor(pair x : moves[0]){\n\t\tif(x.first == x.second) continue;\n\t\treal_moves.push_back(x);\n\t}\n\tcout << real_moves.size() << '\\n';\n\tfor(pair x : real_moves){\n\t\tif(x.first == x.second) continue;\n\t\tcout << x.first * g + f << ' ' << x.second * g + f << '\\n';\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "18517294a82080b5883688fec27250b0", "src_uid": "7b6b3d4bc0a269836bc0113bb17f562f", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "// Note: spoiler below (don't read until you've solved the problem)\n//\n// [I didn't read the editorial or see any failed test cases]\n//\n// I figured out the necessary and sufficient condition int the contest, but only until about 5 minutes\n// remaining I get the key idea (reduce the gap, while ensure that it's not too far from the home -\n// instead of reduce the maximum distance to the home - int the end they're the same, but\n// the idea allows me to consider less cases)\n//\n// Before that I only roughly know which cases are \"hard\" and how to solve them (which cover all cases\n// int the solution)\n//\n// I hope the number of steps int this solution is in o(log^2 (n)) (?)\n//\n// Not tested very carefully, but at least it passes the sample test cases.\n//\n#ifndef LOCAL\n#define NDEBUG\n#endif\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing i4=std::array;\n\nstruct step{\n\tint64_t pos,cen;\n};\n\nstruct prop_t{\n\tint64_t gcd;\n\tint64_t home;\n\tint64_t cnthome; // number of values % (2*gcd) == home. the rest has value % (2*gcd) == (home+gcd).\n\t// between 1 and 3. !=0 when gcd !=0.\n\n\tauto tup()const{\n\t\treturn std::make_tuple(gcd,home,cnthome);\n\t}\n};\n\ntemplate\nstruct comparator_from_key_t{\n\tFn f;\n\tbool operator()(auto a,auto b)const{\n\t\treturn f(a)\nauto comparator_from_key(Fn f){\n\treturn comparator_from_key_t{std::move(f)};\n}\n\nstd::vector movehome(i4& p,prop_t pp){\n\t// cnthome stones at home + (4-cnthome) stones at home+gcd\n\tauto const [gcd,home,cnthome]=pp;\n\tassert(gcd!=0);\n\n\tstd::vector out;\n\n\tauto flip=[&](int posi,int ceni){\n\t\tout.push_back({p[posi],p[ceni]});\n\t\tp[posi]=2*p[ceni]-p[posi];\n\t\tstd::sort(begin(p),end(p));\n\t};\n\tstd::sort(begin(p),end(p));\n\n\twhile(p[3]home){\n\t\tassert(p[2]>p[0]);\n\t\tflip(3,0);\n\t}\n\n\twhile(p[3]>home+3*gcd or p[0](p[3]-p[0])/4){\n\t\t\t\tif(p[1]p[3]-p[2]){\n\t\t\t\t\t\t\tout.push_back({p[2],p[1]});\n\t\t\t\t\t\t\tout.push_back({2*p[1]-p[2],p[0]});\n\t\t\t\t\t\t\tp[2]-=(p[1]-p[0])*2;\n\t\t\t\t\t\t\tassert(std::is_sorted(begin(p),end(p)));\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\tout.push_back({p[1],p[2]});\n\t\t\t\t\t\t\tout.push_back({2*p[2]-p[1],p[3]});\n\t\t\t\t\t\t\tp[1]+=(p[3]-p[2])*2;\n\t\t\t\t\t\t\tassert(std::is_sorted(begin(p),end(p)));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}else{\n\t\t\t\t\t// * --- * * *\n\t\t\t\t\tflip(3,1);\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tif(p[i]=oldgap/4 /* estimation. Any fraction int [0,1] is ok */);\n\n\t\twhile(p[3]home){\n\t\t\tfor(int i=1;i<4;++i){\n\t\t\t\tout.push_back({p[i],p[0]});\n\t\t\t\tp[i]=2*p[0]-p[i];\n\t\t\t}\n\t\t\tstd::sort(begin(p),end(p));\n\t\t}\n\n\t\tassert(p[3]-p[0]==gap);\n\t}\n\n\tfor(;;){\n\t\tif(p[0]home+gcd){\n\t\t\tauto i=std::min_element(begin(p),end(p)-1,comparator_from_key([&](auto x){\n\t\t\t\t\treturn std::abs((home+gcd/2)-(x*2-p[3]));\n\t\t\t\t\t}))-begin(p);\n\t\t\tflip(3,i);\n\t\t}else break;\n\t}\n\n\tassert(p[0]==home and p[3]==home+gcd);\n\treturn out;\n}\n\n\nprop_t prop(i4 p){\n\tstd::sort(begin(p),end(p));\n\n\tprop_t out{0,0,0};\n\tauto& gcd=out.gcd;\n\n\tfor(int i=1;i<3;++i)\n\t\tgcd=std::gcd(gcd,p[i]-p[0]);\n\tif(gcd!=0){\n\t\tout.home=p[0]%gcd;\n\t\tif(out.home<0)out.home+=gcd;\n\n\t\tout.cnthome=(int)std::count_if(begin(p),end(p),[gcd,p0=p[0]](int x){return (x-p0)%(2*gcd)==0;});\n\t\tassert(out.cnthome>0 and out.cnthome<4);\n\t}else{\n\t\tout.home=p[0];\n\t}\n\n\treturn out;\n}\n\nint main(){\n\tstd::ios::sync_with_stdio(0);std::cin.tie(0);\n\ti4 a,b;\n\tfor(auto& x:a)std::cin>>x;\n\tfor(auto& x:b)std::cin>>x;\n\n\tstd::sort(begin(a),end(a));\n\tstd::sort(begin(b),end(b));\n\tif(a==b){\n\t\tstd::cout<<\"0\\n\";\n\t\treturn 0;\n\t}\n\n\tprop_t pa=prop(a);\n\tprop_t pb=prop(b);\n\tif(pa.tup()!=pb.tup()){\n\t\tstd::cout<<\"-1\\n\";\n\t\treturn 0;\n\t}\n\n\tassert(pa.gcd!=0);\n\tauto out1=movehome(a,pa);\n\tauto out2=movehome(b,pa);\n\n\tassert(a==b);\n\n\tstd::reverse(begin(out2),end(out2)); // when will Range v3 be merged to C++ ...\n\tfor(auto [pos,cen]:out1) std::cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define FORN(X,Y) for (int X = 0; X < (Y); ++X)\n#define REP(X,Y,Z) for (int X = (Y); X < (Z); ++X)\n#define FORIT(X,Y) for (typeof((Y).begin()) X = (Y).begin(); X != (Y).end(); ++X)\n#define SZ(X) ((int)(X).size())\n#define A first\n#define B second\n#define MX(X,Y) X = max((X),(Y))\n#define MN(X,Y) X = min((X),(Y))\n#define MP make_pair\n#define PB push_back\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef double db;\ntypedef vector vint;\n\ntypedef pair Point;\ntypedef pair Segment;\ntypedef vector Polygon;\n\nll Gcd(ll a, ll b) {\n if (a < 0LL || b < 0LL) return Gcd(abs(a), abs(b));\n if (b == 0) return a;\n return Gcd(b, a % b);\n}\n\nll Power(ll num, ll ex, ll modu) {\n if (ex == 0LL) return 1LL % modu;\n if (ex % 2 == 0LL) {\n ll base = Power(num, ex/2, modu);\n return (base * base) % modu;\n }\n return (Power(num, ex-1, modu) * num) % modu;\n}\n\nll Inverse(ll num, ll modu) {\n return Power(num, modu-2LL, modu);\n}\n\nvoid Answer(ll a) {\n cout << a << endl;\n exit(0);\n}\n\nint cnt[1 << 26];\n\nint main() {\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e75f420c0c79b053ac849b41a9661fe9", "src_uid": "9bafcd579d38d5c3f073839ccb1c6ed3", "difficulty": 2300.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\n#define fore(i, a, b) for (int i = int(a); i < int(b); i++)\n#define forn(i, n) fore(i, 0, n)\n#define efor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)\n#define nfor(i, n) efor(i, 0, n)\n\n#define mp(x, y) make_pair(x, y)\n#define pb(x) push_back(x)\n#define all(v) (v).begin(), (v).end()\n#define sz(v) int((v).size())\n#define x first\n#define y second\n\ntemplate T abs(const T& x) { return x < 0 ? -x : x; }\ntemplate T sqr(const T& x) { return x * x; }\n\ntemplate ostream& operator<< (ostream& out, const pair& p) {\n\treturn out << \"(\" << p.x << \", \" << p.y << \")\";\n}\n\ntemplate ostream& operator<< (ostream& out, const vector& a) {\n\tout << \"[ \";\n\tforn(i, sz(a)) {\n\t\tif (i) out << \", \";\n\t\tout << a[i];\n\t}\n\treturn out << \" ]\";\n}\n\ntypedef unsigned long long li;\ntypedef long double ld;\ntypedef pair pt;\n\nld gett() {\n\treturn clock() / ld(CLOCKS_PER_SEC);\n}\n\n#ifdef TJS\n\n#endif\n\nconst int N = int(1e6) + 5;\nchar s[N];\nint q[N];\nint n, m;\n\nbool read() {\n\tif (scanf(\"%s\", s) != 1)\n\t\treturn false;\n\tassert(cin >> m);\n\tforn(i, m) {\n\t\tstatic char buf[30];\n\t\tassert(scanf(\"%s\", buf) == 1);\n\t\tint l = strlen(buf);\n\t\tq[i] = 0;\n\t\tforn(j, l)\n\t\t\tq[i] |= (1 << int(buf[j] - 'a'));\n\t}\n\treturn true;\n}\n\nint pos[26];\nmap cnt;\n\nvoid solve() {\n\tforn(i, 26)\n\t\tpos[i] = -1;\n\tcnt.clear();\n\tint n = strlen(s);\n\ts[n++] = '#';\n\tforn(i, n) {\n\t\tvector vv;\n\t\tforn(j, 26)\n\t\t\tif (pos[j] != -1)\n\t\t\t\tvv.pb(mp(pos[j], j));\n\n\t\tsort(all(vv));\n\t\treverse(all(vv));\n\t\tint cmask = 0;\n\t\tfor (auto p: vv) {\n\t\t\tif (p.y == int(s[i] - 'a'))\n\t\t\t\tbreak;\n\t\t\tcmask |= (1 << p.y);\n\t\t\tcnt[cmask]++;\n\t\t}\n\n\t\tif (i < n - 1)\n\t\t\tpos[int(s[i] - 'a')] = i;\n\t}\n\n\tforn(i, m)\n\t\tprintf(\"%d\\n\", cnt[q[i]]);\n}\n\nint main() {\n#ifdef TJS\n\tassert(freopen(\"input.txt\", \"r\", stdin));\n#else\n#endif\n\tcerr << fixed << setprecision(5);\n\tcout << fixed << setprecision(10);\n\twhile (read()) {\n#ifdef TJS\n\t\tld st = gett();\n#endif\n\t\tsolve();\n#ifdef TJS\n\t\tcerr << \" == TIME : \" << gett() - st << \" == \" << endl;\n#endif\n\t}\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dde74904e2173a81421f47830b47b7ad", "src_uid": "9bafcd579d38d5c3f073839ccb1c6ed3", "difficulty": 2300.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\n#define fore(i, a, b) for (int i = int(a); i < int(b); i++)\n#define forn(i, n) fore(i, 0, n)\n#define efor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)\n#define nfor(i, n) efor(i, 0, n)\n\n#define mp(x, y) make_pair(x, y)\n#define pb(x) push_back(x)\n#define all(v) (v).begin(), (v).end()\n#define sz(v) int((v).size())\n#define x first\n#define y second\n\ntemplate T abs(const T& x) { return x < 0 ? -x : x; }\ntemplate T sqr(const T& x) { return x * x; }\n\ntemplate ostream& operator<< (ostream& out, const pair& p) {\n\treturn out << \"(\" << p.x << \", \" << p.y << \")\";\n}\n\ntemplate ostream& operator<< (ostream& out, const vector& a) {\n\tout << \"[ \";\n\tforn(i, sz(a)) {\n\t\tif (i) out << \", \";\n\t\tout << a[i];\n\t}\n\treturn out << \" ]\";\n}\n\ntypedef unsigned long long li;\ntypedef long double ld;\ntypedef pair pt;\n\nld gett() {\n\treturn clock() / ld(CLOCKS_PER_SEC);\n}\n\n#ifdef TJS\n\n#endif\n\nconst int N = int(1e6) + 5;\nchar s[N];\nint q[N];\nint n, m;\n\nbool read() {\n\tif (scanf(\"%s\", s) != 1)\n\t\treturn false;\n\tassert(cin >> m);\n\tforn(i, m) {\n\t\tstatic char buf[30];\n\t\tassert(scanf(\"%s\", buf) == 1);\n\t\tint l = strlen(buf);\n\t\tq[i] = 0;\n\t\tforn(j, l)\n\t\t\tq[i] |= (1 << int(buf[j] - 'a'));\n\t}\n\treturn true;\n}\n\nint pos[26];\nunordered_map cnt;\n\nvoid solve() {\n\tforn(i, 26)\n\t\tpos[i] = -1;\n\tcnt.clear();\n\tint n = strlen(s);\n\ts[n++] = '#';\n\tforn(i, n) {\n\t\tvector vv;\n\t\tforn(j, 26)\n\t\t\tif (pos[j] != -1)\n\t\t\t\tvv.pb(mp(pos[j], j));\n\n\t\tsort(all(vv));\n\t\treverse(all(vv));\n\t\tint cmask = 0;\n\t\tfor (auto p: vv) {\n\t\t\tif (p.y == int(s[i] - 'a'))\n\t\t\t\tbreak;\n\t\t\tcmask |= (1 << p.y);\n\t\t\tcnt[cmask]++;\n\t\t}\n\n\t\tif (i < n - 1)\n\t\t\tpos[int(s[i] - 'a')] = i;\n\t}\n\n\tforn(i, m)\n\t\tprintf(\"%d\\n\", cnt[q[i]]);\n}\n\nint main() {\n#ifdef TJS\n\tassert(freopen(\"input.txt\", \"r\", stdin));\n#else\n#endif\n\tcerr << fixed << setprecision(5);\n\tcout << fixed << setprecision(10);\n\twhile (read()) {\n#ifdef TJS\n\t\tld st = gett();\n#endif\n\t\tsolve();\n#ifdef TJS\n\t\tcerr << \" == TIME : \" << gett() - st << \" == \" << endl;\n#endif\n\t}\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d5bddba77f44c3e0186925c49ff76b8d", "src_uid": "9bafcd579d38d5c3f073839ccb1c6ed3", "difficulty": 2300.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nconst int maxn = 1e6 + 10;\nchar s[maxn];\nint nxt[26][maxn];\nint n;\nvector v;\nint get_next(int id, int mask) {\n\tint res = n;\n\tfor(int i = 0; i < 26; i++) \n\t\tif((mask & (1 << i)) == 0) res = min(res, nxt[i][id]);\n\treturn res;\n}\nunordered_map mp;\nint main() {\n\tscanf(\"%s\", s);\n\tn = strlen(s);\n\tfor(int i = 0; i < 26; i++) nxt[i][n] = n;\n\tfor(int i = n - 1; i >= 0; i--) {\n\t\tfor(int j = 0; j < 26; j++) nxt[j][i] = nxt[j][i + 1];\n\t\tnxt[s[i] - 'a'][i] = i;\n\t}\n\tfor(int i = 0; i < n; i++) {\n\t\tint prv = (i == 0) ? 30 : s[i - 1] - 'a';\n\t\tint cur_idx = i;\n\t\tint cur_mask = (1 << (s[i] - 'a'));\n\t\twhile(cur_idx < n) {\n\t\t\tif((cur_mask & (1 << prv)) == 0) mp[cur_mask]++;\n\t\t\telse break;\n\t\t\tcur_idx = get_next(cur_idx, cur_mask);\n\t\t\tif(cur_idx < n) cur_mask |= (1 << (s[cur_idx] - 'a'));\n\t\t}\n\t}\n\tint q;\n\tscanf(\"%d\", &q);\n\twhile(q--) {\n\t\tchar t[30];\n\t\tscanf(\"%s\", t);\n\t\tint mask = 0;\n\t\tfor(int i = 0; i < strlen(t); i++) mask |= (1 << (t[i] - 'a'));\n\t\tprintf(\"%d\\n\", mp[mask]);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "948a154c6c4771838d37fd5c05ace8e7", "src_uid": "9bafcd579d38d5c3f073839ccb1c6ed3", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#define pb push_back\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define int long long\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair pll;\ntypedef pair pii;\ntypedef long double ld;\ntypedef double db;\n\nconst ll N = 1e6 + 20;\nconst ll INF = INT_MAX;\n\n/*int p = 3571;\nint mod = 2147483647;\n\nnamespace op {\n\tvoid add(int &a, int val) {\n\t\ta = ((a * p % mod + val) % mod + mod) % mod;\n\t}\n\tint calc(int a, int b) {\n\t\treturn ((a % mod + b % mod) % mod + mod) % mod;\n\t}\n\tint mul(int a, int b) {\n\t\treturn (((a % mod) * (b % mod)) % mod + mod) % mod;\n\t}\n\tint pow(int a, int n) {\n\t\tif (n == 0) return 1LL;\n\t\tif (n & 1) {\n\t\t\tint b = pow(a, n ^ 1) % mod;\n\t\t\treturn mul(a, b);\n\t\t}\n\t\telse {\n\t\t\tint b = pow(a, n >> 1) % mod;\n\t\t\treturn mul(b, b);\n\t\t}\n\t}\n};\nusing namespace op;\n\nstruct hsh {\n\tstring vec;\n\tvector seg;\n\tint n;\n\thsh(string a) {\n\t\tn = a.size();\n\t\tvec = a;\n\t\tseg.resize(a.size() + 1);\n\t\tfor (int i = 0; i < a.size(); ++i) {\n\t\t\tseg[i + 1] = seg[i];\n\t\t\tadd(seg[i + 1], a[i]);\n\t\t}\n\t}\n\tint seg_hash(int l, int r) {\n\t\treturn calc(seg[r], (-1) * seg[l - 1] * pow(p, r - l + 1));\n\t}\n};*/\n\nvector g[N];\nint used[N], ct[N];\n\nvector comp[2];\n\nint id;\nvoid dfs(ll v) {\n\tcomp[id].push_back(v);\n\tused[v] = 1;\n\n\tfor (ll to : g[v]) {\n\t\tif (!used[to])\n\t\t\tdfs(to);\n\t}\n}\n\nvoid clear(int n) {\n\tfor (ll i = 0; i < n; ++i) {\n\t\tg[i].clear();\n\t\tused[i] = ct[i] = 0;\n\t}\n}\n\nsigned main() {\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\", stdin);\n\t//freopen(\"output.txt\", \"w\", stdout);\n#else\n#endif\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0); cout.tie(0);\n\n\tint t;\n\tcin >> t;\n\twhile (t--) {\n\t\tint n, m, a, b;\n\t\tcin >> n >> m >> a >> b;\n\t\ta--; b--;\n\t\tfor (int i = 0; i < m; ++i) {\n\t\t\tint x, y;\n\t\t\tcin >> x >> y;\n\t\t\t--x; --y;\n\t\t\tg[x].push_back(y);\n\t\t\tg[y].push_back(x);\n\t\t}\n\n\t\tid = 0; used[b] = 1;\n\t\tdfs(a);\n\t\tfor (auto &x : comp[0]) {\n\t\t\tused[x] = 0;\n\t\t}\n\t\tused[b] = 0;\n\t\tid = 1; used[a] = 1;\n\t\tdfs(b);\n\t\tfor (auto &x : comp[0])\n\t\t\tct[x]++;\n\t\tfor (auto &x : comp[1])\n\t\t\tct[x]++;\n\n\t\tint arr[2] = { -1,-1 };\n\t\tfor (int i = 0; i < 2; ++i)\n\t\t\tfor (auto &x : comp[i])\n\t\t\t\tif (ct[x] == 1)\n\t\t\t\t\tarr[i]++;\n\n\t\tcout << max(0ll, arr[0] * arr[1]) << endl;\n\t\tclear(n);\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f46ac13c7943a953e9d2572752a4ffbd", "src_uid": "7636c493ad91210ec7571895b4b71214", "difficulty": 1900.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize(\"O3\")\n#pragma GCC target(\"mmx,sse,sse2,sse3,ssse3,sse4,avx,aes,pclmul,sse4.1,sse4.2\")\n\n#include\n#define _CRT_SECURE_NO_WARNINGS\n#define _CRT_DISABLE_PERFCRIT_LOCKS\n#define cdbg cout << \"Debug in \" << __func__ << \", \" << __LINE__ << \": \"\n#define q << '\\n'\n#define sp << ' '\n#define mp make_pair\n#define pb emplace_back\n#define ft first\n#define sd second\n#define ld long double\n#define ll long long\n#define ull unsigned long long\n#define lll __int128\n#define pii pair\n#define vi vector\n#define y1 trymaxlox\n\nusing namespace std;\n\nconst int N = 5e5;\nconst ll INF = 1e18 + 7;\nconst int MOD = 1e9+7;\n\nll n, m, k, a, b, c, d, arr[N], res, kek, t ;\nset st;\nstring str;\nvi ans, v;\nset g[N];\nbool used[N], used2[N];\n\nvoid del(int v)\n{\n used2[v] = 1;\n vi vv;\n for (int it : g[v])\n {\n if (!used2[it])\n {\n del(it);\n vv.pb(it);\n }\n }\n for (int i : vv)\n {\n g[v].erase(i);\n g[i].erase(v);\n }\n\n}\nbool dfsdel(int a, int v, int b, int p)\n{\n // cdbg << v q;\n used[v] = 1;\n bool f = 0, ff = 0;\n// cout << \"! ! \";\n// for (auto it : g[v]) cout << it sp;\n// cout q;\n vi vv;\n for (auto it : g[v])\n {\n // cdbg << \" \" << it q;\n if (!used[it])\n {\n if (it == b)\n {\n vv.pb(it);\n f = 1;\n ff = 1;\n }\n else\n {\n bool kex = dfsdel(a, it, b, v);\n if (kex)\n {\n vv.pb(it);\n f = 1;\n }\n }\n }\n }\n for (int i : vv)\n {\n g[v].erase(i);\n g[i].erase(v);\n }\n if (ff)\n {\n for (auto it : g[v])\n {\n if (it != p) del(v);\n }\n }\n // cdbg << v sp << f q;\n return f;\n}\n\nll dfs(int v)\n{\n // cdbg << v q;\n used[v] = 1;\n ll ans = 0;\n for (auto it : g[v])\n {\n if (!used[it])\n {\n ans += dfs(it);\n }\n }\n return ans + 1;\n}\nmain()\n{\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n\n cin >> t;\n while (t--)\n {\n cin >> n >> m >> a >> b;\n for (int i = 0;i <= n; i++)\n {\n g[i].clear();\n }\n // cdbg << \"a\" q;\n memset(used, 0, sizeof(used));\n ll x , y;\n for (int i = 0; i < m; i++)\n {\n cin >> x >> y;\n g[x].insert(y);\n g[y].insert(x);\n }\n //cdbg << \"aaa\" q;\n dfsdel(a, a, b, a);\n memset(used, 0, sizeof(used));\n ll cnta = dfs(a);\n cnta--;\n memset(used, 0, sizeof(used));\n ll cntb = dfs(b);\n cntb--;\n cout << cnta * cntb q;\n }\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n/*\n3\na???cb\na??bbc\na?b?c\n*/\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "08d3c77a4fed138ee51afd4d42e20451", "src_uid": "7636c493ad91210ec7571895b4b71214", "difficulty": 1900.0} {"lang": "GNU C++17", "source_code": "#pragma comment(linker, \"/stack:200000000\")\n#pragma GCC optimize(\"Ofast\")\n//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long li;\ntypedef long double ld;\nconst li MAX = 100042;\nli n, l[MAX], used[MAX], a, b, cnt;\nvector

  • gr[MAX];\nset
  • who;\nvector
  • tmp;\nvoid dfs(li vert) {\n\tcnt++;\n\tused[vert] = 1;\n\ttmp.push_back(vert);\n\tfor (auto i : gr[vert]) {\n\t\tif (i == a) who.insert(a);\n\t\telse if (i == b) who.insert(b);\n\t\telse{\n\t\t\tif (used[i] != 1)\n\t\t\tdfs(i);\n\t\t}\n\t}\n}\nint main() {\n\t//\tfreopen(\"input.txt\", \"r\", stdin);\n\t//\tfreopen(\"output.txt\", \"w\", stdout);\n\tios::sync_with_stdio(0);\n\tcin.tie(0);\n\tcout.tie(0);\n\tli q;\n\tcin >> q;\n\twhile (q--) {\n\t\tli m;\n\t\tcin >> n >> m >> a >> b;\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tused[i] = 0;\n\t\t}\n\t\tli an1 = 0, an2 = 0;\n\t\tfor (int i = 1; i <= n; i++) gr[i].clear();\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tli c, d;\n\t\t\tcin >> c >> d;\n\t\t\tgr[c].push_back(d);\n\t\t\tgr[d].push_back(c);\n\t\t}\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tif (!used[i] && i != a && i != b) {\n\t\t\t\tcnt = 0;\n\t\t\t\tdfs(i);\n\t\t\t\tif (who.size() == 1) {\n\t\t\t\t\tif (*(who.begin()) == a) {\n\t\t\t\t\t\tan1 += cnt;\n\t\t\t\t\t}\n\t\t\t\t\telse an2 += cnt;\n\t\t\t\t}\n\t\t\t\twho.clear();\n\t\t\t}\n\t\t}\n\t\tli ans = (an1 * an2);\n\t\tcout << ans << \"\\n\";\n\t}\n//\tsystem(\"pause\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ae30cc6ebb4b2fc1a53cb6d981a61ed2", "src_uid": "7636c493ad91210ec7571895b4b71214", "difficulty": 1900.0} {"lang": "GNU C++17", "source_code": "#include \n\n//#pragma comment(linker, \"/STACK:16777216\")\n\nusing namespace std;\n\n//mt19937 rnd(228+1337);\n\n#define ll long long\n#define ull unsigned long long\n#define inf INT_MAX\n#define F first\n#define S second\n#define int ll\nconst int SZ = 4e4 + 4;\nconst double EPS = 1e-7;\n\nint n, m, a, b;\nvector g[SZ];\n\nbool used[2][SZ];\n\nvoid read() {\n cin >> n >> m >> a >> b;\n --a, --b;\n for (int i = 0; i < n; ++i) {\n g[i].clear();\n used[0][i] = used[1][i] = 0;\n }\n for (int i = 0; i < m; ++i) {\n int u, v;\n cin >> u >> v;\n --u, --v;\n g[u].push_back(v);\n g[v].push_back(u);\n }\n}\n\nint dfs(int u, int perm, int p) {\n used[p][u] = true;\n for (auto v : g[u]) {\n if (v == perm) continue;\n if (!used[p][v]) {\n dfs(v, perm, p);\n }\n }\n}\n\nvoid solve() {\n dfs(a, b, 0);\n dfs(b, a, 1);\n int x = -1, y = -1;\n for (int i = 0; i < n; ++i) {\n if (used[0][i] && !used[1][i]) {\n ++x;\n } else if (!used[0][i] && used[1][i]) {\n ++y;\n }\n }\n cout << x * y << \"\\n\";\n}\n\nsigned main() {\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n\n int t;\n cin >> t;\n for (int i = 0; i < t; ++i) {\n read();\n solve();\n }\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4e89a4f93cd5b29b0c12bac4e336e3a7", "src_uid": "7636c493ad91210ec7571895b4b71214", "difficulty": 1900.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint n,m,id[300010],last[300010];\nvector route[300010];\nvector > edg[300010];\nvoid solve()\n{\n scanf(\"%d%d\",&n,&m);\n int sk=0;\n for(int i=1,K;i<=m;i++)\n {\n sk+=K;\n scanf(\"%d\",&K);\n route[i].resize(K);\n for(int j=0;j bel[2];\n for(int i=1;i<=m;i++)\n {\n if(route[i].size()>=blk)bel[1].push_back(i);\n else bel[0].push_back(i);\n }\n fill(last+1,last+n+1,-1);\n for(int &p:bel[1])\n {\n for(int j=0;j=blk&&j>=p)continue;\n int v=last[route[j].back()];\n for(int k=(int)route[j].size()-2;k>=0;k--)\n {\n if(last[route[j][k]]==-1)continue;\n if(v>last[route[j][k]])\n {\n if(route[p][last[route[j][k]]+1]!=route[j][k+1])\n {\n puts(\"Human\");\n return;\n }\n }\n else\n {\n v=last[route[j][k]]; \n }\n }\n }\n for(int &x:route[p])last[x]=-1;\n }\n for(int i=1;i<=n;i++)edg[i].clear();\n for(int &p:bel[0])\n {\n for(int j=0;j\n#define fi first\n#define se second\n#define pb push_back\n#define SZ(x) ((int)x.size())\n#define L(i,u) for (register int i=head[u]; i; i=nxt[i])\n#define rep(i,a,b) for (register int i=(a); i<=(b); i++)\n#define per(i,a,b) for (register int i=(a); i>=(b); i--)\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned int ui;\ntypedef pair Pii;\ntypedef vector Vi;\ninline void read(int &x) {\n\tx=0; char c=getchar(); int f=1;\n\twhile (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}\n\twhile (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;\n}\nconst int N = 303000, S = 350, inf = 0x3f3f3f3f;\nint n,q,bg[N],ed[N],a[N],bel[N],len;bool gg;\nvectormrk[N];int qaq[N],pos[N];\ninline void init(){\n\trep(i,0,len+1)bel[i]=0;\n\tgg=0;rep(i,0,n+1)mrk[i].clear();len=0;\n}\n//inline void upd(Pii &u, int x){u=Pii((1LL*u.fi*b1+x)%mo1,(1LL*u.se*b2+x)%mo2);}\ninline bool solve(int p){\n\tint mx=0,now=inf;bool gg=0;\n\tper(i,ed[p],bg[p]){\n\t\tnow=!pos[a[i]]?inf:(pos[a[i]]+1==pos[a[i+1]]?now:pos[a[i]]);\n\t\tmx=max(mx,pos[a[i]]);gg|=mx>now;\n\t}\n\treturn gg;\n}\nint main() {\n\tint T;read(T);\n\twhile(T--){\n\t\tread(n);read(q);init();\n\t\trep(i,1,q){\n\t\t\tint l,x;read(l);bg[i]=len+1;\n\t\t\trep(j,1,l)read(x),a[++len]=x,bel[len]=i;ed[i]=len;\n\t\t}\n\t\trep(i,1,len)if(ed[i]-bg[i]<=S){\n\t\t\tPii u(0,0);\n\t\t\tfor(register int j=i+1;j-i<=S&&bel[i]==bel[j]&&j<=len;j++)\n\t\t\t\tmrk[a[i]].pb(Pii(a[j],a[j-1]));\n\t\t}\n\t\trep(i,1,n){\n\t\t\trep(j,0,SZ(mrk[i])-1){\n\t\t\t\tint u=mrk[i][j].fi,v=mrk[i][j].se;\n\t\t\t\tgg|=qaq[u]&&qaq[u]!=v;qaq[u]=v;\n\t\t\t}\n\t\t\trep(j,0,SZ(mrk[i])-1)qaq[mrk[i][j].fi]=0;\n\t\t}\n\t//\tVi a;a.clear();rep(i,1,q)if(ed[i]-bg[i]>=S)a.pb(i);\n\t//\trep(i,0,SZ(a)-1)rep(j,i+1,SZ(a)-1)gg|=solve(i,j);\n\t\trep(i,1,q)if(ed[i]-bg[i]>=S){\n\t\t\trep(j,bg[i],ed[i])pos[a[j]]=j;\n\t\t\trep(j,1,q)if(i!=j)gg|=solve(j);\n\t\t\trep(j,bg[i],ed[i])pos[a[j]]=0;\n\t\t}\n\t\tif(gg)puts(\"Human\");else puts(\"Robot\");\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6f0fa6521f38d4ea3eddc22ec8504d05", "src_uid": "d742933184ce1cad098fcb8a264df630", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#pragma GCC optimize(\"Ofast\")\n#include\n#define fi first\n#define se second\n#define pb push_back\n#define SZ(x) ((int)x.size())\n#define L(i,u) for (register int i=head[u]; i; i=nxt[i])\n#define rep(i,a,b) for (register int i=(a); i<=(b); i++)\n#define per(i,a,b) for (register int i=(a); i>=(b); i--)\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned int ui;\ntypedef pair Pii;\ntypedef vector Vi;\ninline void read(int &x) {\n\tx=0; char c=getchar(); int f=1;\n\twhile (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}\n\twhile (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;\n}\nconst int N = 303000, S = 350, inf = 0x3f3f3f3f;\nint n,q,bg[N],ed[N],a[N],bel[N],len;bool gg;\nvectormrk[N];int qaq[N],pos[N];\ninline void init(){\n\trep(i,0,len+1)bel[i]=0;\n\tgg=0;rep(i,0,n+1)mrk[i].clear();len=0;\n}\n//inline void upd(Pii &u, int x){u=Pii((1LL*u.fi*b1+x)%mo1,(1LL*u.se*b2+x)%mo2);}\ninline bool solve(int p){\n\tint mx=0,now=inf;bool gg=0;\n\tper(i,ed[p],bg[p]){\n\t\tnow=!pos[a[i]]?inf:(pos[a[i]]+1==pos[a[i+1]]?now:pos[a[i]]);\n\t\tmx=max(mx,pos[a[i]]);gg|=mx>now;\n\t}\n\treturn gg;\n}\nint main() {\n\tint T;read(T);\n\twhile(T--){\n\t\tread(n);read(q);init();\n\t\trep(i,1,q){\n\t\t\tint l,x;read(l);bg[i]=len+1;\n\t\t\trep(j,1,l)read(x),a[++len]=x,bel[len]=i;ed[i]=len;\n\t\t}\n\t\trep(i,1,len)if(ed[i]-bg[i]<=S){\n\t\t\tPii u(0,0);\n\t\t\tfor(register int j=i+1;j-i<=S&&bel[i]==bel[j]&&j<=len;j++)\n\t\t\t\tmrk[a[i]].pb(Pii(a[j],a[j-1]));\n\t\t}\n\t\trep(i,1,n){\n\t\t\trep(j,0,SZ(mrk[i])-1){\n\t\t\t\tint u=mrk[i][j].fi,v=mrk[i][j].se;\n\t\t\t\tgg|=qaq[u]&&qaq[u]!=v;qaq[u]=v;\n\t\t\t}\n\t\t\trep(j,0,SZ(mrk[i])-1)qaq[mrk[i][j].fi]=0;\n\t\t}\n\t//\tVi a;a.clear();rep(i,1,q)if(ed[i]-bg[i]>=S)a.pb(i);\n\t//\trep(i,0,SZ(a)-1)rep(j,i+1,SZ(a)-1)gg|=solve(i,j);\n\t\trep(i,1,q)if(ed[i]-bg[i]>=S){\n\t\t\trep(j,bg[i],ed[i])pos[a[j]]=j;\n\t\t\trep(j,1,q)if(i!=j)gg|=solve(j);\n\t\t\trep(j,bg[i],ed[i])pos[a[j]]=0;\n\t\t}\n\t\tif(gg)puts(\"Human\");else puts(\"Robot\");\n\t\trep(i,0,n)mrk[i].clear();\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "edf1f57f908f7fb7c5316049218d8ca7", "src_uid": "d742933184ce1cad098fcb8a264df630", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\nconst int N = 300000;\nconst int SN = sqrt(N);\n\nint n, q;\nvector rides[N];\n\nint solve() {\n scanf(\"%d\", &n);\n scanf(\"%d\", &q);\n for (int i=0; i> v[n];\n\n for (int i=0; i pos(n, -1);\n for (int j=0; j lst+1 && pos[rides[j][k-1]] != lst)) return 0 * printf(\"Human\\n\");\n lst = p;\n }\n }\n }\n }\n \n for (int i=0; i\n\n#include \n#include \n#include \n#include \n#include \n\nint constexpr MOD = 998244353;\n\nint inverse(int x, int y) {\n\tint a = x, b = y, ax = 1, ay = 0, bx = 0, by = 1;\n\twhile (b) {\n\t\tint q = a / b, tmp;\n\t\ttmp = a - q * b ; a = b ; b = tmp;\n\t\ttmp = ax - q * bx; ax = bx; bx = tmp;\n\t\ttmp = ay - q * by; ay = by; by = tmp;\n\t}\n\twhile (ax < 0) ax += y;\n\treturn ax;\n}\n\ntemplate \nclass num_mod {\n\tint v;\npublic:\n\tnum_mod() : v(0) {}\n\tnum_mod(int v) : v(v) {\n\t\tassert(0 <= v && v < MOD);\n\t}\n\texplicit operator int () const {\n\t\treturn v;\n\t}\n\tnum_mod& operator += (num_mod a) { v += a.v; if (v >= MOD) v -= MOD; return *this; }\n\tnum_mod& operator -= (num_mod a) { v -= a.v; if (v < 0 ) v += MOD; return *this; }\n\tnum_mod& operator *= (num_mod a) { v = v * (int64_t) a.v %MOD; return *this; }\n\tnum_mod& operator /= (num_mod a) { v = v * (int64_t)inverse(a.v,MOD)%MOD; return *this; }\n \t#define d(OP) num_mod operator OP (num_mod x) const { return x OP##= *this; }\n\td(+) d(-) d(*) d(/)\n\t#undef d\n\tnum_mod operator - () const {\n\t\treturn { MOD - v - MOD *!v }; // *!: obfuscation (subtract MOD iff v == 0 (falsy))\n\t}\n\t\n\tbool operator == (num_mod x) const { return v == x.v; }\n}; // NOT ordered\n\ntemplate \nclass fix_frac {\n\tint v;\npublic:\n\tfix_frac() : v() {}\n\tfix_frac(int v) : v(v) {}\n\n\tfix_frac operator - () const { \n\t\tassert(v != INT_MIN);\n\t\treturn fix_frac(-v); \n\t}\n\tfix_frac& operator += (fix_frac x) { \n\t\tif (v == INT_MIN) {\n\t\t\t\n\t\t\t/* not necessary */ assert(false);\n\t\t\t\n\t\t\t// -inf already, nothing to do\n\t\t} else if (x.v == INT_MIN) {\n\t\t\t\n\t\t\t/* not necessary */ assert(false);\n\t\t\t\n\t\t\tv = INT_MIN;\n\t\t} else\n\t\t\tv += x.v;\n\t\treturn *this;\n\t}\n\tfix_frac& operator -= (fix_frac x) {\n\t\tif (v == INT_MIN) {\n\t\t\t\n\t\t\t/* not necessary */ assert(false);\n\t\t\t\n\t\t\tassert (x.v != INT_MIN);\n\t\t\treturn *this; // -inf already, nothing to do\n\t\t}\n\t\tassert(x.v != INT_MIN); // cannot subtract (-INF) (will get +INF, not supported)\n\t\tv -= x.v; return *this; \n\t}\n\t\n \t#define d(OP) \\\n\tfix_frac operator OP (fix_frac x) const { return x OP##= *this; }\n\td(+) d(-)\n\t#undef d\n\n\ttemplate \n\texplicit operator num_mod () const {\n\t\tint64_t const INV_DENOM = inverse(DENOM, MOD);\n\t\tint ans = v * INV_DENOM % MOD;\n\t\treturn { ans + MOD * (ans < 0) };\n\t}\n\n\t// bool operator <=> // someday...\n\t#define d(OP) \\\n\tbool operator OP (fix_frac x) const { return v OP x.v; }\n\td(<) d(>) d(<=) d(>=) d(==) d(!=)\n\t#undef d\n\n\tstatic fix_frac const MIN;\n};\ntemplate \nfix_frac const fix_frac::MIN { INT_MIN };\nnamespace std {\n\ttemplate \n\tstruct numeric_limits> {\n\t\tstatic fix_frac const min () {\n\t\t\treturn fix_frac::MIN;\n\t\t}\n\t};\n}\n\ntemplate \nclass poly {\npublic:\n\tstd::vector x; // coefficients\n\n\tpoly() : x (1) {} // zero polynomial (coeff size == 1)\n\tpoly(std::vector x) : x(std::move(x)) {}\n\n\tpoly& operator += (poly const & b) {\n\t\tif (x.size() < b.x.size())\n\t\t\tx.resize(b.x.size(), 0);\n\t\tfor (size_t i = b.x.size(); i --> 0;)\n\t\t\tx[i] += b.x[i];\n\t\treturn *this;\n\t}\n\t\n\tpoly operator + (poly x) const { return x += *this; }\n\n\tpoly integrate() const {\n\t\tpoly ans; ans.x.resize(x.size()+1);\n\t\tfor (size_t i = ans.x.size(); i --> 1;)\n\t\t\tans.x[i] = x[i-1] / i;\n\t\treturn ans;\n\t}\n\n\t// Polynomial multiplication.\n\tpoly operator * (poly const & b) const {\n\t\tstd::vector ans; ans.resize(x.size() + b.x.size() - 1);\n\n\t\tfor (size_t i = x.size(); i --> 0;)\n\t\t\tfor (size_t j = b.x.size(); j --> 0;)\n\t\t\t\tans[i+j] += x[i] * b.x[j];\n\n\t\treturn poly(std::move(ans));\n\t}\n\t\n\tpoly& operator *= (poly b) {\n\t\treturn *this = *this * b;\n\t}\n\n\tpoly& operator *= (num b) {\n\t\tfor (num& a : x) a *= b;\n\t\treturn *this;\n\t}\n\t\n\tpoly operator * (num b) const { poly ans = *this; return ans *= b; }\n\n\t/// Function composition.\n\tpoly operator ^ (poly const & b) const {\n\t\tpoly ans; // zero\n\t\tpoly base; base.x[0] = 1; // base(x) == 1\n\t\tfor (num v : x) {\n\t\t\tans += base * v;\n\t\t\tbase *= b;\n\t\t}\n\t\treturn ans;\n\t}\n\t\n\tpoly& operator ^= (poly x) { return *this = x ^ *this; }\n\n\tpoly operator - () const {\n\t\tpoly ans; ans.x.resize(x.size());\n\t\tfor (size_t i = x.size(); i --> 0;)\n\t\t\tans.x[i] = -x[i];\n\t\treturn ans;\n\t}\n\n\t/// polynomial evaluation\n\tnum operator () (num a) {\n\t\tnum base = 1, ans = 0;\n\t\tfor (num v : x) {\n\t\t\tans += base * v;\n\t\t\tbase *= a;\n\t\t}\n\t\treturn ans;\n\t}\n};\n\n/// Piecewise polynomial.\ntemplate \nclass func {\n\tusing polyN = poly;\n\tusing funcN = func;\n\t\n\tstruct piece {\n\t\tpolyN p; xnum s; // start\n\t\tpiece(polyN p, xnum s) : p(p), s(s) {}\n\t};\n\t\npublic:\n\tstd::vector t;\n\t\n\t/// Initialize to the step function f(x) = 0 if x <= 0 else 1\n\tfunc() : t { piece{polyN(), std::numeric_limits::min()}, piece{polyN({1}), 0} } {\n\t\t// self.t = t or [poly(), 0, poly([0, 1])] # <-- max(0, x), integrate of step function.\n\t}\n\tfunc(std::vector t) : t(std::move(t)) {}\n\n\tfuncN operator - () const {\n\t\tfuncN ans (t);\n\t\tfor (piece& p : ans.t)\n\t\t\tp.p = -p.p;\n\t\treturn ans;\n\t}\n\n\tfuncN operator + (funcN const & x) const {\n\t\tstd::vector ans;\n\t\t\n\t\tstd::vector a = t, b = x.t; // copy\n\n\t\twhile (!a.empty() && !b.empty()) {\n\t\t\tif (a.back().s < b.back().s) {\n\t\t\t\tans.emplace_back(a.back().p + b.back().p, b.back().s);\n\t\t\t\tb.pop_back();\n\t\t\t} else if (b.back().s < a.back().s) {\n\t\t\t\tans.emplace_back(a.back().p + b.back().p, a.back().s);\n\t\t\t\ta.pop_back();\n\t\t\t} else {\n\t\t\t\tans.emplace_back(a.back().p + b.back().p, a.back().s);\n\t\t\t\ta.pop_back();\n\t\t\t\tb.pop_back();\n\t\t\t}\n\t\t}\n\n\t\tassert(a.empty() && b.empty());\n\t\tassert(ans.back().s == std::numeric_limits::min());\n\n\t\tstd::reverse(ans.begin(), ans.end());\n\t\treturn funcN(std::move(ans));\n\t}\n\t\n\tfuncN& operator += (funcN x) { return *this = x + *this; }\n\n\tfuncN integrate() const {\n\t\tstd::vector ans = t;\n\t\tfor (piece& p : ans)\n\t\t\tp.p = p.p.integrate();\n\n\t\tfor (size_t i = 1; i < ans.size(); ++i) {\n\t\t\t\n\t\t\t// fit poly ans.t[i] with ans.t[i-2]\n\t\t\tynum last_val = ans[i-1].p((ynum) ans[i].s);\n\t\t\tynum this_val = ans[i ].p((ynum) ans[i].s);\n\t\t\tans[i].p.x[0] += last_val - this_val;\n\n\t\t\tassert( ans[i-1].p((ynum) ans[i].s) == ans[i ].p((ynum) ans[i].s) );\n\t\t}\n\n\t\treturn ans;\n\t}\n\n\t/// Shift this function left (++) by (a) units.\n\tfuncN& operator >>= (xnum a) {\n\t\tpolyN p ({(ynum) -a, (ynum) 1});\n\t\tfor (piece& pi : t) {\n\t\t\tpi.p ^= p;\n\t\t\tpi.s += a;\n\t\t}\n\t\treturn *this;\n\t}\n\t\n\tfuncN operator >> (xnum a) const {\n\t\tfuncN ans = *this;\n\t\treturn ans >>= a;\n\t}\n\n\t/// Set all values of self at value >= a to self(a).\n\tfuncN& flatten_larger(xnum a) {\n\t\tif (!(t.size() == 1 || t.back().s < a)) {\n\t\t\t// len(t) must be at least 3 and t[1] >= a\n\t\t\twhile (t.size() >= 2 and (----t.end())->s >= a)\n\t\t\t\tt.pop_back();\n\t\t\tt.pop_back(); // remove the last function\n\t\t}\n\t\tt.emplace_back( polyN( { t.back().p((ynum) a) } ), a );\n\t\treturn *this;\n\t}\n\n};\n\nint main() {\n\tint constexpr DENOM = 1000000;\n\tint const INV_DENOM = inverse(DENOM, MOD);\n\n\tint n; std::cin >> n;\n\n\tfunc, num_mod> fn;\n\tfor (int i = n; i --> 0;) {\n\t\tdouble xi_f; std::cin >> xi_f;\n\t\tfix_frac xi { (int) std::round(xi_f * DENOM) };\n\t\tfn = fn.integrate();\n\t\tfn += -(fn >> 1);\n\t\tfn.flatten_larger(xi);\n\t}\n\n\tint ans = (int) (num_mod) fn.t.back().p.x[0]; // this must be a constant function\n\t// print(ans.numerator * inverse(ans.denominator, mod) % mod)\n\tstd::cout << ans << '\\n';\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "fede0b4cd0d0e5cd18f19db5a3b6156b", "src_uid": "fed8173bf7731f3d663467cc0131d788", "difficulty": 3400.0} {"lang": "GNU C++14", "source_code": "#include \n\n#define SQ(a) (a)*(a)\n\n#define F0R(i, a) for(int i = 0; i < (a); i++)\n#define FOR(i, a, b) for(int i = (a); i < (b); i++)\n#define R0F(i, a) for(int i = (a) - 1; i >= 0; i--)\n#define ROF(i, a, b) for(int i = (b) - 1; i >= (a); i--)\n\n#define ran() (rand() & 0x7FFF)\n#define rand31() ((ran() << 16) | (ran() << 1) | (ran() & 1))\n#define rand32() ((ran() << 17) | (ran() << 2) | (ran() & 3))\n#define rand63() (((ll)ran() << 48) | ((ll)ran() << 33) | ((ll)ran() << 18) | ((ll)ran() << 3) | ((ll)ran() & 7))\n#define rand64() (((ll)ran() << 49) | ((ll)ran() << 34) | ((ll)ran() << 19) | ((ll)ran() << 4) | ((ll)ran() & 15))\n\n#define F first\n#define S second\n#define PB push_back\n#define MP make_pair\n#define MT make_tuple\n#define UB upper_bound\n#define LB lower_bound\n#define X real()\n#define Y imag()\n#define R real()\n#define I image()\n#define PI acos(-1)\n#define MAXN 30\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef pair pii;\ntypedef vector vi;\ntypedef complex point;\ntypedef complex cld;\n\nnamespace NTT {\n\nconst int MAX_DEG = 20, EXP_MULT = 119ULL, EXP = 23;\null NTTMod = (EXP_MULT << EXP) + 1, NTTBuild[1 << MAX_DEG][2], rt[(1 << MAX_DEG) + 1];\n\null modPow(ull a, ull p) {\n if(!p) return 1;\n if(p & 1) return a * modPow(a, p ^ 1) % NTTMod;\n ull sqrt = modPow(a, p >> 1);\n return SQ(sqrt) % NTTMod;\n}\n\null invMod(ull a) {\n return modPow(a, NTTMod - 2);\n}\n\null findCyclic() {\n vi multFactors;\n ull temp = EXP_MULT;\n for(int i = 2; i * i <= temp; i += 2) {\n if(temp % i == 0) multFactors.PB(i);\n while(temp % i == 0) temp /= i;\n if(i == 2) i--;\n }\n if(temp > 1) multFactors.PB(temp);\n FOR(i, 2, NTTMod) {\n bool works = 1;\n if(modPow(i, NTTMod >> 1) == 1) works = 0;\n for(const int factor : multFactors) if(modPow(i, NTTMod / factor) == 1) works = 0;\n if(works) return i;\n }\n}\n\nvoid buildRT() {\n if(rt[0] == 1) return;\n rt[0] = 1;\n rt[1] = modPow(findCyclic(), EXP_MULT << (EXP - MAX_DEG));\n FOR(i, 2, (1 << MAX_DEG) + 1) rt[i] = rt[i - 1] * rt[1] % NTTMod;\n}\n\nvoid ntt(int neededDeg, ull* vals, int len) {\n R0F(i, neededDeg + 1) {\n int arr = i & 1, narr = arr ^ 1, lli = 1 << i, llil = lli << 1, llndim1 = 1 << (neededDeg - i - 1), rtp = lli << (MAX_DEG - neededDeg);\n if(i == neededDeg) {\n F0R(j, len) NTTBuild[j][arr] = vals[j];\n FOR(j, len, lli) NTTBuild[j][arr] = 0;\n } else F0R(j, lli) {\n int x = j, y = 0, z = j, w = j + lli;\n F0R(k, llndim1) {\n NTTBuild[x][arr] = (NTTBuild[z][narr] + NTTBuild[w][narr] * rt[y]) % NTTMod;\n x += lli, y += rtp, z += llil, w += llil;\n }\n z = j, w = j + lli;\n F0R(k, llndim1) {\n NTTBuild[x][arr] = (NTTBuild[z][narr] + NTTBuild[w][narr] * rt[y]) % NTTMod;\n x += lli, y += rtp, z += llil, w += llil;\n }\n }\n }\n}\n\nvoid invntt(int pdeg, ull* p, int len) {\n reverse(rt, rt + (1 << MAX_DEG) + 1);\n R0F(i, pdeg + 1) {\n int arr = i & 1, narr = arr ^ 1, lli = 1 << i, llil = lli << 1, llpdim1 = 1 << (pdeg - i - 1), rtp = lli << (MAX_DEG - pdeg);\n R0F(j, lli) {\n if(i == pdeg) NTTBuild[j][arr] = p[j];\n else {\n int x = j, y = 0, z = j, w = j + lli;\n F0R(k, llpdim1) {\n NTTBuild[x][arr] = (NTTBuild[z][narr] + NTTBuild[w][narr] * rt[y]) % NTTMod;\n x += lli, y += rtp, z += llil, w += llil;\n }\n z = j, w = j + lli;\n F0R(k, llpdim1) {\n NTTBuild[x][arr] = (NTTBuild[z][narr] + NTTBuild[w][narr] * rt[y]) % NTTMod;\n x += lli, y += rtp, z += llil, w += llil;\n }\n }\n }\n }\n reverse(rt, rt + (1 << MAX_DEG) + 1);\n ull u = invMod(len);\n F0R(i, len) NTTBuild[i][0] *= u, NTTBuild[i][0] %= NTTMod;\n}\n\n};\n\nusing namespace NTT;\n\null tempPVPoly[1 << MAX_DEG];\n\nstruct Polynomial {\n\n int deg;\n ull *coefficients;\n\n Polynomial(int d = 0) {\n deg = d;\n coefficients = new ull[deg + 1];\n memset(coefficients, 0, (deg + 1) * sizeof(ull));\n buildRT();\n }\n\n Polynomial operator ()(Polynomial p) {\n Polynomial curr;\n curr[0] = 1;\n Polynomial res;\n F0R(i, deg + 1) {\n res += curr * coefficients[i];\n curr *= p;\n }\n return res;\n }\n\n ull& operator [](int idx) { return coefficients[idx]; }\n\n Polynomial operator +(ull a) {\n Polynomial p(deg);\n F0R(i, deg + 1) p[i] = coefficients[i];\n p[0] += a;\n p[0] %= NTTMod;\n return p;\n }\n\n Polynomial operator -(ull a) {\n Polynomial p(deg);\n F0R(i, deg + 1) p[i] = coefficients[i];\n p[0] += NTTMod - a;\n p[0] %= NTTMod;\n return p;\n }\n\n Polynomial operator *(ull mult) {\n Polynomial p(deg);\n F0R(i, deg + 1) p[i] = coefficients[i] * mult % NTTMod;\n return p;\n }\n\n Polynomial operator /(ull div) { return *this * invMod(div); }\n\n Polynomial operator +(Polynomial b) {\n Polynomial res(max(deg, b.deg));\n F0R(i, max(deg, b.deg) + 1) res[i] = (((i > deg) ? 0 : coefficients[i]) + ((i > b.deg) ? 0 : b[i])) % NTTMod;\n return res;\n }\n\n Polynomial operator -(Polynomial p) { return *this + (p * (NTTMod - 1)); }\n\n Polynomial operator *(Polynomial b) {\n int neededDeg = 32 - __builtin_clz(deg + b.deg);\n ntt(neededDeg, coefficients, deg + 1);\n F0R(i, (1 << neededDeg)) tempPVPoly[i] = NTTBuild[i][0];\n ntt(neededDeg, b.coefficients, b.deg + 1);\n F0R(i, (1 << neededDeg)) tempPVPoly[i] = tempPVPoly[i] * NTTBuild[i][0] % NTTMod;\n invntt(neededDeg, tempPVPoly, 1 << neededDeg);\n Polynomial res(deg + b.deg);\n F0R(i, res.deg + 1) res[i] = NTTBuild[i][0];\n return res;\n }\n\n void operator +=(ull a) { coefficients[0] += a, coefficients[0] %= NTTMod; }\n\n void operator -=(ull a) { *this += NTTMod - a; }\n\n void operator *=(ull mult) { F0R(i, deg + 1) coefficients[i] *= mult, coefficients[i] %= NTTMod; }\n\n void operator /=(ull div) { *this *= invMod(div); }\n\n void operator +=(Polynomial b) { *this = *this + b; }\n\n void operator -=(Polynomial p) { *this = *this - p; }\n\n void operator *=(Polynomial b) { *this = *this * b; }\n\n};\n\nint n;\null x[MAXN];\null modX[MAXN];\nvector, pair>>> func;\n\nPolynomial indefInt(Polynomial f) {\n Polynomial res(f.deg + 1);\n FOR(i, 1, res.deg + 1) res[i] = f[i - 1] * invMod(i) % NTTMod;\n return res;\n}\n\nPolynomial defInt(Polynomial f, Polynomial lo, Polynomial hi) {\n Polynomial F = indefInt(f);\n return F(hi) - F(lo);\n}\n\nPolynomial makeCopy(Polynomial p) {\n Polynomial res(p.deg);\n F0R(i, res.deg + 1) res[i] = p[i];\n return res;\n}\n\nint main() {\n ios::sync_with_stdio(0);\n cin.tie(0);\n cin >> n;\n F0R(i, n) {\n string s;\n cin >> s;\n int numDecimalPlaces = 0;\n R0F(j, s.size()) if(s[j] == '.') numDecimalPlaces = s.size() - j - 1;\n ull base = modPow(10, 6 - numDecimalPlaces);\n R0F(j, s.size()) if(s[j] != '.') {\n x[i] += base * (s[j] - '0');\n base *= 10;\n }\n }\n x[0] = min(1000000ULL, x[0]);\n FOR(i, 1, n) x[i] = min(x[i], x[i - 1] + 1000000ULL);\n ull invMillion = invMod(1000000ULL);\n F0R(i, n) modX[i] = x[i] * invMillion % NTTMod;\n func.PB(MP(Polynomial(), MP(MP(0, 0), MP(x[0], modX[0]))));\n func[0].F[0] = 1;\n Polynomial xPoly(1);\n xPoly[1] = 1;\n F0R(i, n - 1) {\n vector v2;\n vector, bool, int>> v;\n F0R(j, func.size()) {\n pair lo = func[j].S.F;\n pair hi = func[j].S.S;\n Polynomial loPoly;\n Polynomial hiPoly;\n loPoly[0] = lo.S;\n hiPoly[0] = hi.S;\n pair xVal = MP(x[i + 1], modX[i + 1]);\n pair loP1 = MP(lo.F + 1000000ULL, (lo.S + 1) % NTTMod);\n pair hiP1 = MP(hi.F + 1000000ULL, (hi.S + 1) % NTTMod);\n if(xVal.F > lo.F) {\n v2.PB(defInt(func[j].F, loPoly, xPoly));\n v.PB(MT(lo, 1, v2.size() - 1));\n v.PB(MT(min(hi, xVal), 0, v2.size() - 1));\n }\n if(hi.F < lo.F + 1000000ULL && xVal.F > hi.F) {\n v2.PB(defInt(func[j].F, loPoly, hiPoly));\n v.PB(MT(hi, 1, v2.size() - 1));\n v.PB(MT(min(loP1, xVal), 0, v2.size() - 1));\n }\n if(lo.F + 1000000ULL < xVal.F) {\n v2.PB(defInt(func[j].F, xPoly + (NTTMod - 1), hiPoly));\n v.PB(MT(loP1, 1, v2.size() - 1));\n v.PB(MT(min(hiP1, xVal), 0, v2.size() - 1));\n }\n }\n func.clear();\n sort(v.begin(), v.end());\n pair last = MP(0, 0);\n Polynomial curr;\n for(const tuple, bool, int> t : v) {\n if(get<0>(t) > last) func.PB(MP(makeCopy(curr), MP(last, get<0>(t))));\n if(get<1>(t)) curr += v2[get<2>(t)];\n else curr -= v2[get<2>(t)];\n last = get<0>(t);\n }\n }\n Polynomial res;\n F0R(i, func.size()) {\n Polynomial lo, hi;\n lo[0] = func[i].S.F.S;\n hi[0] = func[i].S.S.S;\n res += defInt(func[i].F, lo, hi);\n }\n cout << res[0] << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f2a875d68daad4beeb210cdccd7cd0b0", "src_uid": "fed8173bf7731f3d663467cc0131d788", "difficulty": 3400.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst double eps=1e-9;\nconst int mod=998244353;\ndouble x[33],xp[33];\nstruct pp\n{\n double vl;\n int zz;\n bool operator <(const pp &temp)const\n {\n return vl=xp[i+1])\n break;\n sg[i+1][cnt_sg[i+1]++]=now;\n }\n for(s=-(int)(xp[i+1]+1-eps);s<=0;s++)\n {\n now.vl=xp[i+1]+s;\n if(now.vl<0)\n {\n now.vl=0;\n now.zz=0;\n }\n else\n {\n now.zz=(y[i+1]+s)%mod;\n if(now.zz<0)\n now.zz+=mod; \n }\n sg[i+1][cnt_sg[i+1]++]=now; \n }\n\t\tsort(sg[i+1],sg[i+1]+cnt_sg[i+1]);\n int nn=0;\n for(j=0;j=0&&s;p--)\n \tbz=(1LL*bz*sg[i][s].zz+1LL*coef[i][s-1][p]*inv[p+1])%mod;\n\t\t\t\tcoef[i+1][j][0]=(coef[i+1][j][0]+1LL*bz*sg[i][s].zz)%mod;\n\t\t\t\tif(s>us)\n\t\t\t\t{\n\t\t\t\t\tbz=0;\n\t\t\t\t\tfor(p=i;p>=0;p--)\n\t\t\t\t\t\tbz=(1LL*bz*sg[i][s-1].zz+1LL*coef[i][s-1][p]*inv[p+1])%mod;\n\t\t\t\t\tcoef[i+1][j][0]=(coef[i+1][j][0]-1LL*bz*sg[i][s-1].zz%mod+mod)%mod;\n\t\t\t\t}\n s++;\n }\n if(s=0;p--)\n\t\t \t bz=(1LL*bz*sg[i][s].zz+1LL*coef[i][s][p]*inv[p+1])%mod;\n\t\t\t coef[i+1][j][0]=(coef[i+1][j][0]-1LL*bz*sg[i][s].zz%mod+mod)%mod;\n for(p=0;p<=i;p++)\n coef[i+1][j][p+1]=(coef[i+1][j][p+1]+1LL*coef[i][s][p]*power(p+1,mod-2))%mod;\n }\n }\n }\n int ans=0;\n for(i=0;i=0;j--)\n bz=(1LL*bz*rz+1LL*coef[n-1][i][j]*inv[j+1])%mod;\n ans=(ans+1LL*bz*rz)%mod;\n bz=0;\n for(j=n-1;j>=0;j--)\n bz=(1LL*bz*lz+1LL*coef[n-1][i][j]*inv[j+1])%mod;\n ans=(ans-1LL*bz*lz%mod+mod)%mod;\n }\n printf(\"%d\\n\",ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9140824fb923cc297439db21904154db", "src_uid": "fed8173bf7731f3d663467cc0131d788", "difficulty": 3400.0} {"lang": "GNU C++11", "source_code": "//#define LOCAL\n\n#ifdef LOCAL\n #define _GLIBCXX_DEBUG\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#ifdef DBG1\n #define dbg(...) fprintf(stderr, __VA_ARGS__)\n#else\n #define dbg(...)\n#endif\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair pii;\n\nconst int P = 998244353;\n\nint mod(ll a) {\n a %= P;\n if (a < 0) {\n a += P;\n }\n return a;\n}\n\nint sum(int a, int b) {\n if ((a += b) >= P) {\n a -= P;\n }\n return a;\n}\n\nint diff(int a, int b) {\n if ((a -= b) < 0) {\n a += P;\n }\n return a;\n}\n\nint prod(int a, int b) {\n return ll(a) * b % P;\n}\n\nint power(int a, int n) {\n int b = 1;\n while (n) {\n if (n & 1) {\n b = prod(a, b);\n }\n a = prod(a, a);\n n /= 2;\n }\n return b;\n}\n\nint inv(int a) {\n return power(a, P - 2);\n}\n\nint divide(int a, int b) {\n assert(b != 0);\n return prod(a, inv(b));\n}\n\nll gcd(ll a, ll b) {\n if (b) return gcd(b, a % b);\n return a;\n}\n\nstruct Fraction {\n ll a, b;\n\n Fraction(ll _a = 0, ll _b = 1) {\n ll d = gcd(_a, _b);\n a = _a / d;\n b = _b / d;\n if (b < 0) {\n a *= -1;\n b *= -1;\n }\n }\n\n Fraction operator - () const {\n return Fraction(-a, b);\n }\n\n Fraction operator + (const Fraction & f) const {\n return Fraction(a * f.b + f.a * b, b * f.b);\n }\n\n Fraction operator - (const Fraction & f) const {\n return Fraction(a * f.b - f.a * b, b * f.b);\n }\n\n int getModValue() const {\n return divide(mod(a), mod(b));\n }\n\n bool operator < (const Fraction & f) const {\n return a * f.b < f.a * b;\n }\n\n bool operator <= (const Fraction & f) const {\n return !(f < *this);\n }\n\n bool operator > (const Fraction & f) const {\n return f < *this;\n }\n\n bool operator >= (const Fraction & f) const {\n return !(*this < f);\n }\n\n bool operator == (const Fraction & f) const {\n return a == f.a && b == f.b;\n }\n\n void dbgPrint() const {\n dbg(\"%lld/%lld\", a, b);\n }\n};\n\nFraction readDecimal() {\n static char s[20];\n assert(scanf(\"%s\", s) == 1);\n int len = (int)strlen(s);\n char *dot = strchr(s, '.');\n int frac_len = 0;\n if (dot) {\n memmove(dot, dot + 1, s + len - dot);\n frac_len = s + len - dot - 1;\n }\n int a = atoi(s);\n int b = 1;\n for (int i = 0; i < frac_len; ++i) {\n b *= 10;\n }\n dbg(\"%s: %d/%d\\n\", __func__, a, b);\n return Fraction(a, b);\n}\n\nstruct Polynom {\n vector coefs;\n\n Polynom(int a = 0) : coefs(1, a) {}\n Polynom(const vector&coefs) : coefs(coefs) {}\n\n Polynom& operator += (const Polynom & p) {\n while (coefs.size() < p.coefs.size()) {\n coefs.push_back(0);\n }\n for (int i = 0; i < int(p.coefs.size()); ++i) {\n coefs[i] = sum(coefs[i], p.coefs[i]);\n }\n return *this;\n }\n\n Polynom& operator -= (const Polynom & p) {\n while (coefs.size() < p.coefs.size()) {\n coefs.push_back(0);\n }\n for (int i = 0; i < int(p.coefs.size()); ++i) {\n coefs[i] = diff(coefs[i], p.coefs[i]);\n }\n return *this;\n }\n\n Polynom operator * (const Polynom & p2) const {\n const Polynom & p1 = *this;\n Polynom p;\n p.coefs.resize(p1.coefs.size() + p2.coefs.size() - 1);\n for (int i = 0; i < int(p1.coefs.size()); ++i) {\n for (int j = 0; j < int(p2.coefs.size()); ++j) {\n p.coefs[i + j] = sum(p.coefs[i + j], prod(p1.coefs[i], p2.coefs[j]));\n }\n }\n while (p.coefs.size() > 1 && p.coefs.back() == 0) {\n p.coefs.pop_back();\n }\n return p;\n }\n\n Polynom& operator *= (const Polynom & p) {\n return *this = *this * p;\n }\n\n int getValue(const Fraction &x) const {\n //dbg(\"getValue(\"); x.dbgPrint(); dbg(\")\\n\");\n int xx = x.getModValue();\n int val = 0;\n for (int i = int(coefs.size()) - 1; i >= 0; --i) {\n val = prod(val, xx);\n val = sum(val, coefs[i]);\n }\n return val;\n }\n\n Polynom substitute_x_minus_y(const Fraction &y) const {\n Polynom p(0);\n Polynom tmp({(-y).getModValue(), 1});\n for (int i = int(coefs.size()) - 1; i >= 0; --i) {\n p *= tmp;\n p += coefs[i];\n }\n return p;\n }\n\n Polynom getPrimitive() const {\n Polynom p;\n p.coefs.resize(coefs.size() + 1);\n p.coefs[0] = 0;\n for (int i = 0; i < int(coefs.size()); ++i) {\n p.coefs[i + 1] = divide(coefs[i], i + 1); \n }\n dbgPrint();\n p.dbgPrint();\n return p;\n }\n\n void dbgPrint() const {\n for (int i = 0; i < int(coefs.size()); ++i) {\n dbg(\"%d*x^%d + \", coefs[i], i);\n }\n dbg(\"\\n\");\n }\n};\n\nstruct Function {\n vector borders;\n vector parts;\n\n Function(const Fraction & left, const Fraction & right, const Polynom & p) {\n borders.push_back(left);\n borders.push_back(right);\n parts.push_back(p);\n }\n\n Function(const vector & borders, const vector & parts) : borders(borders), parts(parts) {}\n\n Polynom getIntegral(const Fraction & len, const Fraction & R1, const Fraction & R2) const {\n assert(R1 < R2);\n Fraction L1 = R1 - len;\n Fraction L2 = R2 - len;\n L1.dbgPrint(); dbg(\" \"); L2.dbgPrint(); dbg(\" \"); R1.dbgPrint(); dbg(\" \"); R2.dbgPrint(); dbg(\"\\n\");\n Polynom res({0});\n for (int i = 0; i < int(parts.size()); ++i) {\n if (R2 <= borders[i]) { break; }\n if (L1 >= borders[i + 1]) { continue; }\n borders[i].dbgPrint(); dbg(\" \"); borders[i + 1].dbgPrint(); dbg(\"\\n\");\n //assert(max(L2, borders[i]) <= min(R1, borders[i + 1]));\n Polynom f = parts[i].getPrimitive();\n if (max(L1, borders[i]) == max(L2, borders[i])) {\n dbg(\"res -= f(\"); max(L2, borders[i]).dbgPrint(); dbg(\")\\n\");\n res -= f.getValue(max(L2, borders[i]));\n res.dbgPrint();\n } else {\n dbg(\"res -= f(x-1)\\n\");\n f.substitute_x_minus_y(len).dbgPrint();\n res -= f.substitute_x_minus_y(len);\n res.dbgPrint();\n }\n if (min(R1, borders[i + 1]) == min(R2, borders[i + 1])) {\n dbg(\"res += f(\"); min(R1, borders[i + 1]).dbgPrint(); dbg(\")\\n\");\n res += f.getValue(min(R1, borders[i + 1]));\n res.dbgPrint();\n } else {\n dbg(\"res += f(x)\\n\");\n res += f;\n res.dbgPrint();\n }\n }\n dbg(\"%s returns \", __func__); res.dbgPrint();\n return res;\n }\n\n void truncate(Fraction x) {\n dbg(\"%s\\n\", __func__);\n while (borders[int(borders.size()) - 2] >= x) {\n borders.pop_back();\n parts.pop_back();\n }\n assert(x <= borders.back());\n assert(borders[int(borders.size()) - 2] < x);\n borders.back() = x;\n }\n\n void extend(Fraction x) {\n assert(borders.back() <= x);\n if (borders.back() < x) {\n parts.push_back(Polynom(parts.back().getValue(borders.back())));\n borders.push_back(x);\n }\n }\n\n void dbgPrint() {\n for (int i = 0; i < int(parts.size()); ++i) {\n dbg(\"[\"); borders[i].dbgPrint();\n dbg(\", \"); borders[i + 1].dbgPrint();\n dbg(\"] => \");\n parts[i].dbgPrint();\n assert(borders[i] < borders[i + 1]);\n }\n }\n};\n\nFunction addRandomVar(const Function & f) {\n vector borders = f.borders;\n for (int i = 0; i < int(f.borders.size()); ++i) {\n borders.push_back(f.borders[i] + 1);\n }\n sort(borders.begin(), borders.end());\n borders.erase(unique(borders.begin(), borders.end()), borders.end());\n\n vector parts;\n parts.reserve((int)borders.size() - 1);\n for (int i = 1; i < int(borders.size()); ++i) {\n Fraction right = borders[i];\n Fraction left = borders[i - 1];\n dbg(\"left = \"); left.dbgPrint();\n dbg(\" right = \"); right.dbgPrint(); dbg(\"\\n\");\n Polynom curP = f.getIntegral(1, left, right);\n parts.push_back(curP);\n }\n\n return Function(borders, parts);\n}\n\nbool solve() {\n int n;\n if (scanf(\"%d\", &n) != 1) { return false; }\n \n Fraction x0 = readDecimal();\n Function f(0, x0, Polynom({0, 1}));\n for (int i = 1; i < n; ++i) {\n dbg(\"ANS %d\\n\", f.parts.back().getValue(f.borders.back()));\n \n Fraction x = readDecimal();\n f.extend(i + 1);\n f = addRandomVar(f);\n f.dbgPrint();\n f.truncate(x);\n\n f.dbgPrint();\n }\n printf(\"%d\\n\", f.parts.back().getValue(f.borders.back()));\n return true;\n}\n\nint main() {\n while (solve());\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9f534ca7390f64b47c271c063f034028", "src_uid": "fed8173bf7731f3d663467cc0131d788", "difficulty": 3400.0} {"lang": "GNU C++11", "source_code": "#include \n#include \nusing namespace std;\n\nint main()\n{\n int n, m, k, kv1, kv2, m1 = 1, m2 = 1, n1 = 1, n2 = 1, ro1, ro2, sum = 0;\n cin >> n >> m >> k;\n cin >> kv1 >> kv2;\n m1 = kv1 / k;\n m2 = kv2 / k;\n if (kv1 % k != 0)\n m1 ++;\n if (kv2 % k != 0)\n m2 ++;\n n1 = m1 / m;\n n2 = m2 / m;\n if (m1 % m != 0)\n {\n n1 ++;\n m1 %= m;\n }\n else\n m1 = m;\n if (m2 % m != 0)\n {\n n2 ++;\n m2 %= m;\n }\n else\n m2 =m;\n if (n1 == 0)\n n1 = 1;\n if (n2 == 0)\n n2 = 1;\n if (m1 == 0)\n m1 = 1;\n if (m2 == 0)\n m2 = 1;\n ro1 = abs(n1 - n2);\n ro2 = n - max(n1, n2) + min(n1, n2);\n sum += (min(ro1, ro2) * 15);\n ro1 = (m1 - 1) * 5;\n ro2 = 9 + m1;\n sum += min(ro1, ro2);\n ro1 = (m2 - 1) * 5;\n ro2 = 9 + m2;\n sum += min(ro1, ro2);\n if (n1 == n2)\n {\n if (m1 == m2)\n sum = 0;\n else\n {\n ro1 = abs(m1 - m2) * 5;\n ro2 = 10 + abs(m1 - m2);\n sum = min(ro1, ro2);\n }\n }\n cout << sum;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d7ca51d22e00c625e902aac60700979e", "src_uid": "c37b46851abcf7eb472869bd1ab9f793", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nlong long int a b c d e f g h i j k\nint main()\n{\n cin>>a>>b>>c;\n cin>>d>>e;\n h=(d-1)/(b*c)+1;\n i=(e-1)/(b*c)+1;\n d=d-(h-1)*(b*c);\n e=e-(i-1)*(b*c);\n j=(d-1)/c+1;\n k=(e-1)/c+1;\n f=min((j-1)*5 , 10+j-1);\n g=min((k-1)*5 , 10+k-1);\n if(h>i){\n swap(h , i);\n }\n if(h==i){\n d=abs(j-k);\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n/*_______ TYPES ________*/\n\ntemplate\nostream &operator<<(ostream &out, const pair &p)\n{\n\tout << p.first << ' ' << p.second;\n\treturn out;\n}\n\ntemplate\nistream &operator>>(istream &in, pair &p)\n{\n\tin >> p.first >> p.second;\n\treturn in;\n}\n\n#ifndef ANDREIKKAA_UNSAFE_VECTOR\ntemplate\nclass vec : public vector\n{\npublic:\n\tusing vector::vector;\n\tinline const T operator[](size_t x) const\n\t{\n\t\treturn this->at(x);\n\t}\n\tinline T& operator[](size_t x)\n\t{\n\t\treturn this->at(x);\n\t}\n};\n\ntemplate<>\nclass vec : public vector\n{\n\tusing vector::vector;\n\tinline const_reference operator[](size_t x) const\n\t{\n\t\treturn this->at(x);\n\t}\n\tinline reference operator[](size_t x)\n\t{\n\t\treturn this->at(x);\n\t}\n};\n\ntemplate\ninline ostream &operator<<(ostream &out, const vec &v)\n{\n\tif (v.empty())\n\t\treturn out;\n\tout << v.front();\n\tfor (auto it = ++v.begin(); it != v.end(); ++it)\n\t\tout << ' ' << *it;\n\treturn out;\n}\n\ntemplate\ninline istream &operator>>(istream &in, vec &v)\n{\n\tfor (auto &i : v)\n\t\tin >> i;\n\treturn in;\n}\n#endif // !ANDREIKKAA_UNSAFE_VECTOR\n\ntemplate\ninline ostream &operator<<(ostream &out, const vector &v)\n{\n\tif (v.empty())\n\t\treturn out;\n\tout << v.front();\n\tfor (auto it = ++v.begin(); it != v.end(); ++it)\n\t\tout << ' ' << *it;\n\treturn out;\n}\n\ntemplate\ninline istream &operator>>(istream &in, vector &v)\n{\n\tfor (auto &i : v)\n\t\tin >> i;\n\treturn in;\n}\n\n/* _____ ALLOCATION _____ */\n\n#ifdef ANDREIKKAA_ALLOCATOR\nchar alloc_memory[MEMORY_LIMIT_MB * 1000 * 1000];\nsize_t alloc_pointer = 0;\ninline void* operator new(size_t x)\n{\n\talloc_pointer += x;\nreturn alloc_memory + alloc_pointer - x;\n}\ninline void operator delete(void* x)\n{\n\n}\n#endif\n\n/* _______ INPUT _________*/\n\nclass Reader\n{\npublic:\n\tinline Reader(const string &filename)\n\t{\n\t\tcin.tie(nullptr);//, ios_base::sync_with_stdio(false);\n\t\tif (not filename.empty())\n\t\t\tassert(freopen(filename.c_str(), \"r\", stdin) != nullptr);\n\t}\n\n\ttemplate\n\tinline void operator()(T &x)\n\t{\n\t\tcin >> x;\n\t}\n\n\ttemplate\n\tinline void operator()(T &x, Args &... args)\n\t{\n\t\tread(x), read(args...);\n\t}\n};\nReader read(input_filename);\n\n/* _______ OUTPUT ________*/\n\nclass Printer\n{\npublic:\n\tinline Printer(const string &filename)\n\t{\n\t\t//cout.precision(20);\n\t\t//cout << fixed;\n\t\tif (not filename.empty())\n\t\t\tassert(freopen(filename.c_str(), \"w\", stdout) != nullptr);\n\t}\n\n\ttemplate\n\tinline void out(const T x)\n\t{\n\t\tcout << x;\n\t}\n\n\ttemplate\n\tinline void out(const T x, const Args... args)\n\t{\n\t\tout(x), out(args...);\n\t}\n\n\tinline void operator()()\n\t{\n\t\tout('\\n');\n\t}\n\n\ttemplate\n\tinline void operator()(const T x)\n\t{\n\t\tout(x), out('\\n');\n\t}\n\n\ttemplate\n\tinline void operator()(const T x, const Args... args)\n\t{\n\t\tout(x), out(' '), print(args...);\n\t};\n};\nPrinter print(output_filename);\n\n/* ________ CODE ________ */\n\nclass Solution\n{\npublic:\n\n\tint f_floor(int x, int y)\n\t{\n\t\treturn min(abs(x - y) * 5, 10 + abs(x - y));\n\t}\n\n\tint n;\n\tint f_go(int x, int y)\n\t{\n\t\treturn min(abs(x - y) * 15, (n - abs(x - y)) * 15);\n\t}\n\t\n\tinline void solve()\n\t{\n\t\tint m, k, a, b;\n\t\tread(n, m, k, a, b);\n\t\t--a;\n\t\t--b;\n\n\t\tint ak = a % k;\n\t\ta /= k;\n\t\tint am = a % m;\n\t\ta /= m;\n\t\tint an = a;\n\n\t\tint bk = b % k;\n\t\tb /= k;\n\t\tint bm = b % m;\n\t\tb /= m;\n\t\tint bn = b;\n\n\t\tif (an == bn)\n\t\t{\n\t\t\tif (am == bm)\n\t\t\t{\n\t\t\t\tprint(0);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tprint(f_floor(am, bm));\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprint(f_floor(am, 0) + f_floor(bm, 0) + f_go(an, bn));\n\t\t}\n\t}\n\n\tSolution()\n\t{\n#ifdef ANDREIKKAA\n\t\tstart = clock();\n#endif // ANDREIKKAA\n\t}\n\n\t~Solution()\n\t{\n#ifdef ANDREIKKAA\n\t\tprint(\"Time:\", (clock() - start) / (ld)CLOCKS_PER_SEC);\n#endif // ANDREIKKAA\n\t}\nprivate:\n#ifdef ANDREIKKAA\n\ttime_t start;\n#endif // ANDREIKKAA\n};\n\nint main()\n{\n\tauto s = new Solution;\n\ts->solve();\n\tdelete s;\n#ifdef ANDREIKKAA \n#ifdef _WIN32\n\twhile (true);\n#endif // _WIN32\n#endif // ANDREIKKAA\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7a66bdd18b5184fdca0f8634c51ff953", "src_uid": "c37b46851abcf7eb472869bd1ab9f793", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nint n, m, k;\nint first(long long c)\n{\n int a;\n if (c % (m*k) == 0)\n a = c/(m*k);\n else\n a = c/(m*k) + 1;\n return a;\n}\nint second(long long d, int pod)\n{\n int t;\n long long h = d - ((pod - 1)* m * k);\n if (h % k == 0)\n t = h/k;\n else\n t = h/k + 1;\n return t;\n}\nint main()\n{\n freopen(\"input.txt\", \"r\", stdin);\n long long a, b;\n cin >> n >> m >> k >> a >> b;\n int pod1 = first(a);\n int pod2 = first(b);\n long long ans = 0;\n cout << \"pod1 = \" << pod1 << endl;\n cout << \"pod2 = \" << pod2 << endl;\n if (pod1 != pod2)\n {\n ans = ans + 15*(min((max(pod1, pod2) - min(pod1, pod2)), n - (max(pod1, pod2) - min(pod1, pod2))));\n }\n cout << \"ans = \" << ans << endl;\n int et1 = second(a, pod1);\n int et2 = second(b, pod2);\n cout << \"et1 = \" << et1 << endl;\n cout << \"et2 = \" << et2 << endl;\n if (ans == 0)\n {\n if(max(et1, et2) - min(et1, et2) > 2)\n ans = ans + 10 + max(et1, et2) - min(et1, et2);\n else\n ans = ans + 5*(max(et1, et2) - min(et1, et2));\n }\n else\n {\n if(et1 - 1 > 2)\n ans = ans + 10 + et1 - 1;\n else\n ans = ans + 5*(et1 - 1);\n\n if(et2 - 1 > 2)\n ans = ans + 10 + et2 - 1;\n else\n ans = ans + 5*(et2 - 1);\n }\n cout << ans;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "485d06d3ad7a6c3a400e56bcd9674a35", "src_uid": "c37b46851abcf7eb472869bd1ab9f793", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define PII pair\n#define f first\n#define s second\n#define VI vector\n#define LL long long\n#define MP make_pair\n#define LD long double\n#define PB push_back\n#define PLL pair \n#define ALL(V) V.begin(),V.end()\n#define abs(x) max((x),-(x))\n#define PDD pair \n#define VPII vector< PII > \n#define siz(V) ((int)V.size())\n#define FOR(x, b, e) for(int x=b;x<=(e);x++)\n#define FORD(x, b, e) for(int x=b;x>=(e);x--)\n#define REP(x, n) for(int x=0;x<(n);x++)\n#define mini(a,b) a=min(a,b)\n#define maxi(a,b) a=max(a,b)\nconst bool deb = \n#ifdef DEB\ntrue;\n#define debug cerr << \"[LINE:\" << __LINE__ << \"] \" << boolalpha\n#else\nfalse;\n#define debug if(0) cout\n#endif\n#define fs(r) r.f, r.s\n#define ei else if\ntemplate \nostream & operator<<(ostream &os, pair x) {\n\treturn os << \"<\" << x.f << \", \" << x.s << \">\";\n}\ntemplate \nauto operator<<(ostream&os, T x) -> typename enable_if::value && !is_same::value, ostream &>::type {\n\tos << \"{\";\n\tint cou = 0;\n\tfor (auto c : x) {\n\t\tif (cou++)\n\t\t\tos << \", \";\n\t\tos << c;\n\t}\n\treturn os << \"}_\" << x.size();\n}\n#define cr << \"][\" << \n#define rr << \"] = \" << \n#define cc << \"[\" <<\n#define ao << ' ' \n#define name(a) #a << \" = \" << (a) ao\n#define arr(a, i) #a cc #i rr #a cc i rr a[i] ao\n#define arr2(a, i, j) #a cc #i cr #j rr #a cc i cr j rr a[i][j] ao\n#define arr3(a, i, j, k) #a cc #i cr #j cr #k rr #a cc i cr j cr k rr a[i][j][k] ao\n#define arr4(a, i, j, k, q) #a cc #i cr #j cr #k cr #q rr #a cc i cr j cr k cr q rr a[i][j][k][q] ao\n#define _2arr(a, b, i) #a cc #b cc #i << \"]\" rr #a cc #b cc i << \"]\" rr #a cc b[i] rr a[b[i]] ao\n#define _3arr(a, b, c, i) #a cc #b cc #c cc #i << \"]]\" rr #a cc #b cc #c cc i << \"]]\" rr #a cc #b cc c[i] << \"]\" rr #a cc b[c[i]] rr a[b[c[i]]] ao\n#define range(a, i, j) #a cc i << \"..\" << j rr vector ::type>(&a[i], &a[j + 1]) ao\ntemplate \nstring strmask(T r) {\n\tstring ans;\n\tREP(i, 8 * (int)sizeof(T)) {\n\t\tans += '0' + !!(((T)1 << i) & r);\n\t\tif (i % 5 == 4)\n\t\t\tans += '.';\n\t}\n\treturn ans;\n}\n#if 0 \nostream & operator<< (ostream & os, __int128_t x) {\n\tif (x < 0) {\n\t\tos << '-';\n\t\tx = -x;\n\t}\n\tif (x >= 10)\n\t\tos << x / 10;\n\treturn os << (int)x % 10;\n}\nostream & operator<< (ostream & os, __uint128_t x) {\n\tif (x >= 10)\n\t\tos << x / 10;\n\treturn os << (int)x % 10;\n}\n#endif\n#define nmask(a) #a << \" = \" << strmask(a) ao\nconst int mod = 998244353;\n#define pow snatheonta\n#define rea pair \nconst int MN = 1010;\nLL pow(LL b, int e) {\n\tif (e == 0) return 1;\n\tif (e & 1) return pow(b, e - 1) * b % mod;\n\treturn pow(b * b % mod, e / 2);\n}\nrea make();\nrea operator+(rea a, rea b) {\n\t\t\t\t return MP((a.f + b.f) % mod, a.s + b.s);\n }\n rea operator*(rea a, rea b) {\n\t\t\t\t return MP((a.f * b.f) % mod, a.s * b.s);\n }\n rea make(int x) {\n\t\t\t\t return MP((LL)x, (LD)x);\n }\n rea operator/ (rea a, rea b) {\n\t\t\t\t return MP(a.f * pow(b.f, mod - 2) % mod, a.s / b.s);\n }\n rea operator-(rea a, rea b) {\n\t\t\t\t return MP((a.f - b.f + mod) % mod, a.s - b.s);\n }\n rea rpow(rea a, int b) {\n\t\t\t\t if (b == 0)\n\t\t\t\t\t\t\t\t\t\t\t\t return make(1);\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t if (b % 2)\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t return rpow(a, b - 1) * a;\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t return rpow(a * a, b / 2);\n }\n rea dp[MN];\n rea pra_best[MN][MN];\n rea p;\n rea psum[MN][MN];\nint pairs(int x) {\n\treturn x * (x - 1) / 2;\n}\nint main() {\n\tint n, a, b;\n\tscanf(\"%d%d%d\", &n, &a, &b);\n\tp = make(a) / make(b);\n\tdp[1] = make(0);\n\tbin[0][0] = make(1);\n\tREP(i, n) {\n\t\tbin[i][0] = bin[i][i] = make(1);\n\t\tFOR(j, 1, i - 1)\n\t\t\tbin[i - 1][j] + bin[i - 1][j - 1];\n\t}\n\tdebug << arr2(bin, 10, 5) << arr2(bin, 17, 2) << endl;\n\tpsum[0][0] = make(1);\n\tpra_best[1][1] = make(1);\n\tFOR(size, 1, n) {\n\t\tFOR(subset, 0, size) {\n\t\t\tif (subset != 0)\n\t\t\t\tpsum[size][subset] = psum[size][subset] + psum[size - 1][subset - 1] * rpow(make(1) - p, size - subset);\n\t\t\tif (subset != size)\n\t\t\t\tpsum[size][subset] = psum[size][subset] + psum[size - 1][subset] * rpow(p, subset);\n\t\t}\n\t}\n\tdp[1] = make(0);\n\tFOR(i, 2, n) {\n\t\trea rest = make(1);\n\t\tFOR(siz, 1, i - 1) {\n\t\t\tpra_best[i][siz] = pra_best[siz][siz] * psum[i][siz];\n\t\t\trest = rest - pra_best[i][siz];\n\t\t\tdebug << arr2(pra_best, i, siz) << endl;\n\t\t}\n\t\tpra_best[i][i] = rest;\n\t\tdebug << arr2(pra_best, i, i) << endl;\n\t}\n\tFOR(siz, 2, n) {\n\t\tdp[siz] = make(siz * (siz - 1) / 2) * make(1) / (make(1) - pra_best[siz][siz]);\n\t\tdebug << arr(dp, siz) << endl;\n\t\trea stay = make(1) - pra_best[siz][siz];\n\t\tFOR(sub, 1, siz - 1) {\n\t\t\tdp[siz] = dp[siz] + pra_best[siz][sub] / stay * (dp[sub] + dp[siz - sub] - make(pairs(siz - sub)));\n\t\t\tdebug << name(sub) << \"add \" << pra_best[siz][sub] * (dp[sub] + dp[siz - sub] - make(pairs(siz - sub))) << endl;\n\t\t\tdebug << arr2(pra_best, siz, sub) << arr(dp, sub) << arr(dp, siz - sub) << name(pairs(siz - sub)) << endl;\n\t\t}\n\t\tdebug << \"finally\" << arr(dp, siz) << endl;\n\t}\n\tdebug << arr(dp, n) << endl;\n\tprintf(\"%lld\\n\", dp[n].f);\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "93212250b641db37dd9db914ec25d877", "src_uid": "67e599530203060c17f692f2624d0f99", "difficulty": 2800.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define y1 cgbngfgn\n#define pb push_back\n#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n#define fir first\n#define m_p make_pair\n#define sec second\n#define files(name) freopen(name\".in\",\"r\",stdin); freopen (name\".out\",\"w\",stdout);\n#define time pdojegoritg\n#define left eorgjrptgj\n#define right rtyjtokh\n#define int ll\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\nconst int arr=3e5+100;\nint md=998244353;\n\nmap > mp;\n\nint bpow(int u, int step)\n{\n if (mp.count({u,step}))\n return(mp[{u,step}]);\n if (step==0)\n return(mp[{u,step}]=1);\n if (step%2)\n return(mp[{u,step}]=bpow(u,step-1)*u%md);\n return(mp[{u,step}]=bpow(u*u%md,step/2));\n}\n\nint cp[2100][2100],strong[2100],ans[2100];\n\nsigned main()\n{\n int n;\n cin>>n;\n int p,b;\n cin>>p>>b;\n p*=bpow(b,md-2);\n p%=md;\n\n for (int i=0;i<=n;i++)\n cp[i][0]=1;\n\n for (int s=1;s<=n;s++)\n for (int c=1;c<=s;c++)\n {\n cp[s][c]=cp[s-1][c]*bpow((1-p+md)%md,c)%md+cp[s-1][c-1]*bpow(p,s-c)%md;\n cp[s][c]%=md;\n }\n\n strong[0]=1;\n strong[1]=1;\n\n for (int i=2;i<=n;i++)\n {\n for (int j=1;j\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint __gcd(int x, int y) { if(!y) return x; return __gcd(y, x % y); }\n\n#define foreach(i,x) for(type(x)i=x.begin();i!=x.end();i++)\n#define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)\n#define ROF(ii,aa,bb) for(int ii=aa;ii>=bb;ii--)\n\n#define sag (k + k + 1)\n#define sol (k + k)\n\n#define type(x) __typeof(x.begin())\n\n#define orta ((bas + son) >> 1)\n#define sag (k + k + 1)\n#define sol (k + k)\n\n#define pb push_back\n#define mp make_pair\n\n\n#define nd second\n#define st first\n\n#define endl '\\n'\n\ntypedef pair < int ,int > pii;\n\ntypedef long long ll;\n\nconst long long linf = 1e18+5;\nint mod = 998244353;\nconst int logN = 18;\nconst int inf = 1e9 + 9;\n\nconst int N = 2e3 + 6;\n\n// 1p 1-p, 1pp (1-p)/p\n\nint P[N], P1[N], dp2[N][N], aa, P[N], n, m, x, y, z, ssum[N], Z[N], dp[N], p, p1, inv_1p, a, b, k;\n\nint FE(int x, int k) {\n\tif(!k) return 1;\n\tint temp = FE(x, k / 2);\n\tif(k & 1) return temp * (ll) temp % mod * x % mod;\n\treturn (ll) temp * temp % mod;\n}\n\nint inverse(int x) { return FE(x, mod - 2); }\n\nint putin(int n, int k) {\n\tif(k > n) return 0;\n\tif(k == 0) return 1;\n\tint &r = dp2[n][k];\n\tif(r != -1) return r;\n\treturn r = (putin(n - 1, k - 1) * (ll) P1[n - k] % mod + putin(n - 1, k) * (ll) P[k] % mod) % mod;\n}\n\nint f(int n) {\n\tif(n <= 1) return 0;\n\tint &r = dp[n];\n\tint coeff = putin(n, n) * (ll) Z[n] % mod;\n\tint add = n * (n - 1) / 2;\n\t// f = r + (f + add) * coeff -> f = r + f*coeff + add*coeff -> f = (r + add * coeff) / (1 - coeff)\n\tr = add * (ll) coeff % mod;\n\tFOR(k, 1, n - 1) {\n\t\tint coeff = putin(n, k) * (ll) Z[k] % mod;\n\t\tr = (r + (f(n - k) + f(k) + k * (k - 1) / 2 + (n - k) * k) * (ll) coeff % mod) % mod;\n\t} return r = (r * (ll) inverse(1 - coeff + mod) % mod);\n}\n\nint main() {\n\tscanf(\"%d %d %d\", &n, &a, &b);\n\tmemset(dp, -1, sizeof dp);\n\tmemset(dp2, -1, sizeof dp2);\n\tp = a * (ll) inverse(b) % mod;\n\tp1 = (1 - p + mod) % mod;\n\tinv_1p = inverse(p1);\n\tZ[0] = Z[1] = 1;\n\tFOR(i, 1, n) {\n\t\tP[i] = P[i - 1] * (ll) p % mod;\n\t\tP1[i] = P1[i - 1] * (ll) p1 % mod;\n\t}\n\tFOR(i, 2, n) {\n\t\tZ[i] = 0;\n\t\tFOR(j, 1, i - 1)\n\t\t\t(Z[i] += Z[j] * (ll) putin(i, j) % mod) %= mod;\n\t\tZ[i] = (1 - Z[i] + mod) % mod;\n\t}\n\tcout << f(n) << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "13159723b3b994320f92d49dc0c7e7dc", "src_uid": "67e599530203060c17f692f2624d0f99", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\nconst int N = 2020;\nconst int mod = 998244353;\n\nint fpow(int x, int y) {\n int ret = 1;\n while(y) {\n if(y & 1) ret = (1LL * ret * x) % mod;\n x = (1LL * x * x) % mod;\n y >>= 1;\n }\n return ret;\n}\n\nint n;\nint a, b;\nint g[N];\nint f[N][N]; //// chose j from i pepople so that these j people win everyone else i\nint pconnect[N];\n\nint dp[N];\n\nint main(){\n ios_base::sync_with_stdio(false); cin.tie(NULL);\n\n cin >> n >> a >> b;\n\n int rp = (1 - p + mod) % mod;\n\n f[0][0] = 1;\n for(int i = 0; i < N - 1; ++i) {\n for(int j = 0; j <= i; ++j) {\n int winall = fpow(rp, i - j);\n int nowin = fpow(p, j);\n\n f[i + 1][j] += 1LL * f[i][j] * nowin % mod; /// not choosing i + 1\n f[i + 1][j + 1] += 1LL * f[i][j] * winall % mod;\n\n f[i + 1][j] %= mod;\n f[i + 1][j + 1] %= mod;\n }\n }\n\n for(int i = 1; i < N - 1; ++i) {\n pconnect[i] = 1;\n for(int j = 1; j < i; ++j) {\n pconnect[i] -= 1LL * f[i][j] * pconnect[j] % mod;\n pconnect[i] += mod;\n if(pconnect[i] >= mod) pconnect[i] -= mod;\n }\n }\n\n\n for(int i = 1; i <= n; ++i) {\n for(int j = 1; j < i; ++j) {\n dp[i] += (dp[j] + dp[i - j] + 1LL * (i - j) * j + (j * (j - 1) / 2) % mod) * 1LL * (1LL * f[i][j] * pconnect[j] % mod) % mod;\n dp[i] %= mod;\n }\n\n int rate = pconnect[i];\n int kp = (1LL * i * (i - 1) / 2) * rate % mod;\n\n dp[i] = (dp[i] + kp) * 1LL * fpow((1 - rate + mod) % mod, mod - 2) % mod;\n\n }\n\n cout << dp[n] << endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "38760601211ebb69c08dbaab1afbcbbb", "src_uid": "67e599530203060c17f692f2624d0f99", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\nconst int N=1e5+10;\n\nstruct point{\n\tint x,y,id;\n\tinline point(int _x=0, int _y=0, int _id=0){\n\t\tx=_x,y=_y,id=_id;\n\t}\n\tinline bool operator<(const point &p) const{\n\t\tif (x!=p.x) return x a[4]){\n\tint size=a[0].size(),\n\t\tr[4]={-1e9,-1e9,-1e9,-1e9};\n\tif (size<=1) return 1;\n\tset ::iterator t[4];\n\tfor (int i=0;i<4;i++)\n\t\tt[i]=a[i].begin();\n\tfor (int i=1;iy); t[j]++;\n\t\t\tif (t[j]->x>=r[j]){\n\t\t\t\tset b[4];\n\t\t\t\tfor (auto tt=a[j].begin();tt!=t[j];){\n\t\t\t\t\tpoint *tmp=p[tt->id]; tt++;\n\t\t\t\t\tfor (int k=0;k<4;k++){\n\t\t\t\t\t\ta[k].erase(tmp[k]);\n\t\t\t\t\t\tb[k].insert(tmp[k]);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn solve(b)&&solve(a);\n\t\t\t}\n\t\t}\n\treturn 0;\n}\n\nint main(){\n\tint n; scanf(\"%d\",&n);\n\tset a[4];\n\tfor (int i=1;i<=n;i++){\n\t\tint x1,y1,x2,y2;\n\t\tscanf(\"%d%d%d%d\",&x1,&y1,&x2,&y2);\n\t\tp[i][0]=point(x1,x2,i);\n\t\ta[0].insert(p[i][0]);\n\t\tp[i][1]=point(-x2,-x1,i);\n\t\ta[1].insert(p[i][1]);\n\t\tp[i][2]=point(y1,y2,i);\n\t\ta[2].insert(p[i][2]);\n\t\tp[i][3]=point(-y2,-y1,i);\n\t\ta[3].insert(p[i][3]);\n\t}\n\tputs(solve(a)?\"YES\":\"NO\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "67d82c81bf8ce718905e3fddb9986d33", "src_uid": "5bfb165b4efe081d6a8c4843f7769a37", "difficulty": 3000.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize(\"O2\")\n#pragma GCC optimize(\"unroll-loops\")\n#pragma GCC target(\"avx,avx2,sse,sse2,ssse3,tune=native\")\n#include\n#define all(x) x.begin(), x.end()\n#define rall(x) x.rbegin(), x.rend()\n#define pb push_back\nusing namespace std;\nusing ll = long long;\n//using arr = array;\nusing pi = pair;\nusing vi = vector;\nusing vpi = vector;\nusing ld = long double;\n#include\nusing namespace __gnu_pbds;\ntemplate\nusing oset = tree;\nconst int maxn = 1<<18, mod = 1e9 + 7, lg = 19;\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\nconst int mx = maxn-1;\nstruct segtree {\n\tstruct node {\n\t\tnode *l, *r;\n\t\tint lazy;\n\t\tpi val;\n\t\tnode(int x = 0, int p = -1) : val(x, p), lazy(0), l(0), r(0) {};\n\t};\n\tusing pnode = node*;\n\tdeque karan;\n\tpnode newnode(int x = 0, int p = -1) {\n\t\tkaran.emplace_back(x, p);\n\t\treturn &karan.back();\n\t}\n\tpnode rt= nullptr;\n\tvoid clear() {\n\t\trt = nullptr;\n\t}\n\tvoid push(pnode &v, int l, int r) {\n\t\tif(!v) return;\n\t\tv->val.first += v->lazy;\n\t\tif(l != r) {\n\t\tif(!v->l) v->l = newnode(0, l);\n\t\tif(!v->r) v->r = newnode(0, 1 + (l+r)/2);\n\t\tv->l->lazy += v->lazy;\n\t\tv->r->lazy += v->lazy;\n\t\t}\n\t\tv->lazy = 0;\n\t}\n\tpi get(int l, int r) {\n\t\tif(l>r) return {1<<30, -1};\n\t\treturn get(0, mx, l, r, rt);\n\t}\n\tpi get(int l, int r, int ql, int qr, pnode &v) {\n\t\tpush(v, l, r);\n\t\tif(r < ql || qr < l) return {1<<30, -1};\n\t\tif(!v) v = newnode(0, l);\n\t\tif(ql <= l && r <= qr) return v->val;\n\t\tint mid = (l+r)/2;\n\t\treturn min(get(l, mid, ql, qr, v->l), get(mid+1, r, ql, qr, v->r));\n\t}\n\tvoid upd(int l, int r, int x) {\n\t\tif(l>r) return;\n\t\tupd(0, mx, l, r, x, rt);\n\t}\n\tvoid upd(int l, int r, int ql, int qr, int x, pnode &v) {\n\t\tpush(v, l, r);\n\t\tif(r < ql || qr < l) return;\n\t\t//cout << l << \" \" << r << \" \" << ql << \" \" << qr << '\\n';\n\t\tif(!v) v = newnode(0, l);\n\t\tif(ql <= l && r <= qr) {\n\t\t\tv->lazy = x;\n\t\t\tpush(v, l, r);\n\t\t\treturn;\n\t\t}\n\t\tint mid = (l+r)/2;\n\t\tupd(l, mid, ql, qr, x, v->l);\n\t\tupd(mid + 1, r, ql, qr, x, v->r);\n\t\tv->val = min(v->l?v->l->val:pi{0, l}, v->r?v->r->val:pi{0, mid+1});\n\t}\n};\nint n, lx[maxn], rx[maxn], ly[maxn], ry[maxn];\n#define lesspp(x, y, a, b) (x x, oset y) {\n\tif(x.size()<=1) return;\n\tsegtree cx, cy;\n\tfor(auto i : x) {\n\t\tcx.upd(lx[i]+1, rx[i]-1, 1);\n\t\t//cout <<\"x[\"<< lx[i]+1 << \" \" << rx[i]-1 << \"] \" << 1 << endl;\n\t\tcy.upd(ly[i]+1, ry[i]-1, 1);\n\t\t//cout <<\"y[\"<< ly[i]+1 << \" \" << ry[i]-1 << \"] \" << 1 << endl;\n\t\t//for(int i = 0; i < 3; i++) cout << cy.get(i, i).first << \" \";cout << endl;\n\t\t//return;//remove\n\t}\n\t//cout << cx.rt->val.first << \" \" << cx.rt->val.second << '\\n';\n\t//cout << cy.rt->val.first << \" \" << cy.rt->val.second << '\\n';\n\t//for(int i = 0; i < 3; i++) cout << cx.get(i, i).first << \" \";cout << endl;\n\t//for(int i = 0; i < 3; i++) cout << cy.get(i, i).first << \" \";cout << endl;\n\t//cout << x.size() << \" \" << y.size() << \" <3\" << endl;\n\twhile(x.size()>1) {\n\t\tauto p = cx.get(lx[*x.begin()]+1, lx[*x.rbegin()]);\n\t\t//cout << p.first << \" \" << p.second << \" cut < \" << lx[*x.rbegin()] << endl;\n\t\tif(p.first==0) {\n\t\t\tint cut = p.second;\n\t\t\tint LEQ = x.order_of_key(cut+1);\n\t\t\toset nx;\n\t\t\toset ny;\n\t\t\tif(lx[x.find_by_order(x.size()/2)] >= cut) {\n\t\t\t\t//cout << \"xxcut \" << cut << endl;\n\t\t\t\twhile(lx[*x.begin()] < cut) {\n\t\t\t\t\tint t = *x.begin();\n\t\t\t\t\tx.erase(t);\n\t\t\t\t\ty.erase(t);\n\t\t\t\t\tcx.upd(lx[t]+1, rx[t]-1, -1);\n\t\t\t\t\tcy.upd(ly[t]+1, ry[t]-1, -1);\n\t\t\t\t\tnx.insert(t);\n\t\t\t\t\tny.insert(t);\n\t\t\t\t}\n\t\t\t\t//cout << nx.size() << \" \" << ny.size() << '\\n';exit(0);\n\t\t\t} else {\n\t\t\t\t//cout << \"HER\" << cut<= cut) {\n\t\t\t\t\tint t = *x.rbegin();\n\t\t\t\t\t//cout << \"HERE\"< nx;\n\t\t\toset ny;\n\t\t\tif(ly[y.find_by_order(y.size()/2)] >= cut) {\n\t\t\t\t//cout << \"HER\" << cut<= cut) {\n\t\t\t\t\tint t = *y.rbegin();\n\t\t\t\t\tx.erase(t);\n\t\t\t\t\ty.erase(t);\n\t\t\t\t\tcx.upd(lx[t]+1, rx[t]-1, -1);\n\t\t\t\t\tcy.upd(ly[t]+1, ry[t]-1, -1);\n\t\t\t\t\tnx.insert(t);\n\t\t\t\t\tny.insert(t);\n\t\t\t\t}\n\t\t\t}\n\t\t\t//return;//REMOVE\n\t\t\tdfs(nx, ny);\n\t\t\tcontinue;\n\t\t}\n\t\tcout << \"NO\", exit(0);\n\t}\n\tif(x.size()>1) {cout << \"NO\", exit(0);}\n}\n\nint main() {\n\tios::sync_with_stdio(0);\n\tcin.tie(0);\n\tcin >> n;\n\toset x;\n\toset y;\n\tvi xc, yc;\n\tfor(int i = 0; i < n; i++) {\n\t\tcin >> lx[i] >> ly[i] >> rx[i] >> ry[i];\n\t\txc.pb(lx[i]), xc.pb(rx[i]), yc.pb(ly[i]), yc.pb(ry[i]);\n\t}\n\tsort(all(xc)), xc.erase(unique(all(xc)), xc.end());\n\tsort(all(yc)), yc.erase(unique(all(yc)), yc.end());\n\tfor(int i = 0; i < n; i++) {\n\t\tlx[i] = lower_bound(all(xc), lx[i]) - xc.begin();\n\t\trx[i] = lower_bound(all(xc), rx[i]) - xc.begin();\n\t\tly[i] = lower_bound(all(yc), ly[i]) - yc.begin();\n\t\try[i] = lower_bound(all(yc), ry[i]) - yc.begin();\n\t}\n\tfor(int i = 0; i < n; i++) x.insert(i), y.insert(i);\n\tdfs(x, y);\n\tcout << \"YES\";\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "ad0d3d72919ecb027f53438fdd037f2e", "src_uid": "5bfb165b4efe081d6a8c4843f7769a37", "difficulty": 3000.0} {"lang": "GNU C++11", "source_code": "A Story of One Country#include\n#define M 100005\nusing namespace std;\nstruct node{\n\tint x,y,p;\n\tbool operator <(const node _) const{\n\t\tif(x==_.x&&y==_.y)return p<_.p;\n\t\tif(x==_.x)return y<_.y;\n\t\treturn x<_.x;\n\t}\n} g[4][M];\nint f[4][M],n;\nsetx[4];\nconst int inf=2e9;\nint solve(set t[4])\n{\n\tint n=t[0].size();\n\tsets[4];\n\tset::iterator it[4];\n\tfor(int i=0;i<4;i++) it[i]=t[i].begin();\n\tif(n==1) return 1;\n\tint mx[4]={-inf,-inf,-inf,-inf};\n\tfor(int i=0;ip;\n\t\t\tif(i&&it[j]->x>=mx[j])\n {\n\t\t\t\tfor(int k=0;ky);\n\t\t\tit[j]++;\n\t\t}\n\t}\n\treturn 0;\n}\nint main()\n{\n\tscanf(\"%d\",&n);\n\tfor(int i=1;i<=n;i++)\n {\n\t\tint a,b,c,d;\n\t\tscanf(\"%d%d%d%d\",&a,&b,&c,&d);\n\n\t\tg[0][i]=(node)<%a,c,i%>;\n\t\tx[0].insert(g[0][i]);\n\t\t\n\t\tg[1][i]=(node) <%-c,-a,i%>;\n\t\tx[1].insert(g[1][i]);\n\n\t\tg[2][i]=(node) <%b,d,i%>;\n\t\tx[2].insert(g[2][i]);\n\t\t\n\t\tg[3][i]=(node) <%-d,-b,i%>;\n\t\tx[3].insert(g[3][i]);\n\t}\n\tputs(solve(x)?\"yes\":\"no\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f077531ce0568a9876fc39e121827b85", "src_uid": "5bfb165b4efe081d6a8c4843f7769a37", "difficulty": 3000.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\ntypedef long long ll;\n#define //////DBG(v) //cerr << #v << \" = \" << (v) << endl;\n\nstruct Rect {\n\tint x1, y1, x2, y2;\n};\n\nconst int MxN = (int) 1e5 + 9;\nRect a[MxN + 9];\n\nauto compX1 = [](const int i, const int j) {\n\tint diff = a[i].x1 - a[j].x1;\n\treturn diff ? diff < 0 : i < j;\n};\nauto compX2 = [](const int i, const int j) {\n\tint diff = a[i].x2 - a[j].x2;\n\treturn diff ? diff > 0 : i < j;\n};\nauto compY1 = [](const int i, const int j) {\n\tint diff = a[i].y1 - a[j].y1;\n\treturn diff ? diff < 0 : i < j;\n};\nauto compY2 = [](const int i, const int j) {\n\tint diff = a[i].y2 - a[j].y2;\n\treturn diff ? diff > 0 : i < j;\n};\n\ntemplate bool f(T first, T last);\n\nbool f(set &sx1, set &sx2, set &sy1, set &sy2) {\n\tassert(sx1.size() == sx2.size());\n\tassert(sy1.size() == sy2.size());\n\tassert(sx1.size() == sy1.size());\n\tconst int sz = (int) sx1.size();\n\tif (sz <= 1) {\n\t\tassert(sz == 1);\n\t\treturn true;\n\t}\n\n\tauto itX1 = sx1.begin();\n\tauto itX2 = sx2.begin();\n\tauto itY1 = sy1.begin();\n\tauto itY2 = sy2.begin();\n\n\tstatic const ll Inf = (int) 1e9 + 9;\n\n\tint mx1 = -Inf;\n\tint mx2 = +Inf;\n\tint my1 = -Inf;\n\tint my2 = +Inf;\n\n\tfor (int rep = 0; rep < sz / 2; ++rep) {\n\t\tmx1 = max(mx1, a[*itX1].x2);\n\t\tmx2 = min(mx2, a[*itX2].x1);\n\t\tmy1 = max(my1, a[*itY1].y2);\n\t\tmy2 = min(my2, a[*itY2].y1);\n\n\t\t++itX1, ++itX2, ++itY1, ++itY2;\n\n\t\tif (mx1 <= a[*itX1].x1) {\n\t\t\t//////DBG(mx1)\n\t\t\t//////DBG(a[*itX1].x1)\n\n\t\t\t//cerr << \"sep x1\" << endl;\n\n\t\t\tset sx1N(compX1);\n\t\t\tset sx2N(compX2);\n\t\t\tset sy1N(compY1);\n\t\t\tset sy2N(compY2);\n\n\t\t\twhile (sx1.begin() != itX1) {\n\t\t\t\tconst int x = *sx1.begin();\n\n\t\t\t\tsx1.erase(x);\n\t\t\t\tsx2.erase(x);\n\t\t\t\tsy1.erase(x);\n\t\t\t\tsy2.erase(x);\n\n\t\t\t\tsx1N.insert(x);\n\t\t\t\tsx2N.insert(x);\n\t\t\t\tsy1N.insert(x);\n\t\t\t\tsy2N.insert(x);\n\t\t\t}\n\n\t\t\treturn f(sx1N, sx2N, sy1N, sy2N) && f(sx1, sx2, sy1, sy2);\n\t\t}\n\t\tif (mx2 >= a[*itX2].x2) {\n\t\t\t//cerr << \"sep x2\" << endl;\n\n\t\t\tset sx1N(compX1);\n\t\t\tset sx2N(compX2);\n\t\t\tset sy1N(compY1);\n\t\t\tset sy2N(compY2);\n\n\t\t\twhile (sx2.begin() != itX2) { // 2 changes\n\t\t\t\tconst int x = *sx2.begin(); // 1 change\n\n\t\t\t\tsx1.erase(x);\n\t\t\t\tsx2.erase(x);\n\t\t\t\tsy1.erase(x);\n\t\t\t\tsy2.erase(x);\n\n\t\t\t\tsx1N.insert(x);\n\t\t\t\tsx2N.insert(x);\n\t\t\t\tsy1N.insert(x);\n\t\t\t\tsy2N.insert(x);\n\t\t\t}\n\n\t\t\treturn f(sx1N, sx2N, sy1N, sy2N) && f(sx1, sx2, sy1, sy2);\n\t\t}\n\t\tif (my1 <= a[*itY1].y1) {\n\t\t\t//cerr << \"sep y1\" << endl;\n\n\t\t\tset sx1N(compX1);\n\t\t\tset sx2N(compX2);\n\t\t\tset sy1N(compY1);\n\t\t\tset sy2N(compY2);\n\n\t\t\twhile (sy1.begin() != itY1) { // 2 changes\n\t\t\t\tconst int x = *sy1.begin(); // 1 change\n\n\t\t\t\tsx1.erase(x);\n\t\t\t\tsx2.erase(x);\n\t\t\t\tsy1.erase(x);\n\t\t\t\tsy2.erase(x);\n\n\t\t\t\tsx1N.insert(x);\n\t\t\t\tsx2N.insert(x);\n\t\t\t\tsy1N.insert(x);\n\t\t\t\tsy2N.insert(x);\n\t\t\t}\n\n\t\t\treturn f(sx1N, sx2N, sy1N, sy2N) && f(sx1, sx2, sy1, sy2);\n\t\t}\n\t\tif (my2 >= a[*itY2].y2) {\n\t\t\t//cerr << \"sep y2\" << endl;\n\n\t\t\tset sx1N(compX1);\n\t\t\tset sx2N(compX2);\n\t\t\tset sy1N(compY1);\n\t\t\tset sy2N(compY2);\n\n\t\t\twhile (sy2.begin() != itY2) { // 2 changes\n\t\t\t\tconst int x = *sy2.begin(); // 1 change\n\n\t\t\t\tsx1.erase(x);\n\t\t\t\tsx2.erase(x);\n\t\t\t\tsy1.erase(x);\n\t\t\t\tsy2.erase(x);\n\n\t\t\t\tsx1N.insert(x);\n\t\t\t\tsx2N.insert(x);\n\t\t\t\tsy1N.insert(x);\n\t\t\t\tsy2N.insert(x);\n\t\t\t}\n\n\t\t\treturn f(sx1N, sx2N, sy1N, sy2N) && f(sx1, sx2, sy1, sy2);\n\t\t}\n\t}\n\n\treturn false;\n}\n\ntemplate bool f(It first, It last) {\n\tset sx1(compX1);\n\tset sx2(compX2);\n\tset sy1(compY1);\n\tset sy2(compY2);\n\twhile (first < last) {\n\t\tsx1.insert(*first);\n\t\tsx1.insert(*first);\n\t\tsx1.insert(*first);\n\t\tsx1.insert(*first);\n\t\t++first;\n\t}\n\treturn f(sx1, sx2, sy1, sy2);\n}\n\nsigned main() {\n\tios::sync_with_stdio(false);\n\tcin.tie(nullptr), cout.tie(nullptr);\n\n\tint n;\n\tcin >> n;\n\tfor (int i = 0; i < n; ++i)\n\t\tcin >> a[i].x1 >> a[i].y1 >> a[i].x2 >> a[i].y2;\n\n\tset sx1(compX1);\n\tset sx2(compX2);\n\tset sy1(compY1);\n\tset sy2(compY2);\n\n\tfor (int x = 0; x < n; ++x) {\n\t\tsx1.insert(x);\n\t\tsx2.insert(x);\n\t\tsy1.insert(x);\n\t\tsy2.insert(x);\n\t}\n\n\tconst bool yes = f(sx1, sx2, sy1, sy2);\n\tcout << (yes ? \"YES\" : \"NO\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "43df0431209fb39c3623d4295a1705c7", "src_uid": "5bfb165b4efe081d6a8c4843f7769a37", "difficulty": 3000.0} {"lang": "GNU C++11", "source_code": "#include \n\n#define FASTIO\n\n#ifdef FASTIO\n#define scanf abacaba\n#define printf abacaba\n#endif\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef unsigned long long ull;\n\nusing namespace std;\nusing bb = bitset;\n\nconst int C2 = 19;\nconst int C = 9 * 20 + 1;\n\nvector vv;\nunordered_set mapa1, mapa2;\n\nbool cmp(const bb &a, const bb &b){\n\tfor (int i = 0; i < 9 * 20; ++i){\n\t\tif (a[i] < b[i])\n\t\t\treturn 1;\n\t\tif (b[i] < a[i])\n\t\t\treturn 0;\n\t}\n\treturn 0;\n}\n\nunordered_map mm;\n\nint upd(int x, int j){\n\tbb cur = (vv[x] << j) | (vv[x] >> j);\n\tfor (int k = 0; k < j; ++k)\n\t\tif (vv[x][k])\n\t\t\tcur[j - k] = 1;\n\tauto it = mm.find(cur);\n\tif (it == mm.end())\n\t\treturn -1;\n\treturn it->second;\n}\nconst int MX = 50000;\n\nint go[MX][10];\nll dp[MX][10][20];\nint nl;\n\nll get(ll x, int k) {\n\tvector dg;\n\tfor (int i = 0; i < C2; ++i)\n\t\tdg.push_back(x % 10), x /= 10;\n\tll ans = 0;\n\tll cur = nl;\n\tfor (int i = C2 - 1; i >= 0; --i){\n\t\tfor (int j = 0; j < dg[i]; ++j){\n\t\t\tll tmp = go[cur][j];\n\t\t\tans += dp[tmp][k][i];\n\t\t}\n\t\tcur = go[cur][dg[i]];\n\t}\n\treturn ans;\n}\n\nint av[MX][10];\n\nint main() {\n\t#ifdef FASTIO\n\t\tios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);\n\t#endif\n\tbb tmp;\n\ttmp[0] = 1;\n\tmapa1.insert(tmp);\n\tfor (int i = 0; i < C2; ++i){\n\t\tmapa2.clear();\n\t\tfor (auto msk: mapa1){\n\t\t\tfor (int j = 0; j <= 9; ++j){\n\t\t\t\tbb cur = (msk << j) | (msk >> j);\n\t\t\t\tfor (int k = 0; k < j; ++k)\n\t\t\t\t\tif (msk[k])\n\t\t\t\t\t\tcur[j - k] = 1;\n\t\t\t\tmapa2.insert(cur);\n\t\t\t}\n\t\t}\n\t\tmapa1 = mapa2;\n\t}\n\tfor (auto x: mapa1)\n\t\tvv.push_back(x);\n\tsort(vv.begin(), vv.end(), cmp);\n\tfor (int i = 0; i < vv.size(); ++i)\n\t\tmm[vv[i]] = i;\n\tnl = mm[tmp];\n\tav[nl][0] = 1;\n\tfor (int i = 0; i < vv.size(); ++i){\n\t\tgo[i][0] = i;\n\t\tfor (int j = 1; j <= 9; ++j){\n\t\t\tgo[i][j] = upd(i, j);\n\t\t}\n\t\tfor (int j = 0; j <= 9; ++j)\n\t\t\tif (vv[i][j])\n\t\t\t\tav[i][j] = 1;\n\t}\n\tfor (int i = vv.size() - 1; i >= 0; --i){\n\t\tint x = 0;\n\t\twhile (!av[i][x]) {\n\t\t\t++x;\n\t\t}\n\t\tfor (int j = x; j <= 9; ++j)\n\t\t\tdp[i][j][0] = 1;\n\t}\n\tfor (int ad = 1; ad <= C2; ++ad){\n\t\tfor (int i = 0; i < vv.size(); ++i){\n\t\t\tfor (int j = 0; j <= 9; ++j){\n\t\t\t\tif (go[i][j] == -1)\n\t\t\t\t\tcontinue;\n\t\t\t\tfor (int k = 0; k <= 9; ++k){\n\t\t\t\t\tdp[i][k][ad] += dp[go[i][j]][k][ad - 1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tint n;\n\tcin >> n;\n\tfor (int i = 0; i < n; ++i){\n\t\tll l, r;\n\t\tint k;\n\t\tcin >> l >> r >> k;\n\t\tcout << get(r + 1, k) - get(l, k) << \"\\n\";\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "aaaaf810e17273000c4b7581f7cc76cc", "src_uid": "db0e3ef630cb381724697a1ac5152611", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#include \n\ntypedef long long ll;\ntypedef long double ld;\ntypedef unsigned long long ull;\n\nusing namespace std;\nusing bb = bitset;\n\nconst int C2 = 19;\nconst int C = 9 * 20 + 1;\n\nvector vv;\nunordered_set mapa1, mapa2;\n\nbool cmp(const bb &a, const bb &b){\n\tfor (int i = 0; i < 9 * 20; ++i){\n\t\tif (a[i] < b[i])\n\t\t\treturn 1;\n\t\tif (b[i] < a[i])\n\t\t\treturn 0;\n\t}\n\treturn 0;\n}\n\nunordered_map mm;\n\nint upd(int x, int j){\n\tbb cur = (vv[x] << j) | (vv[x] >> j);\n\tfor (int k = 0; k < j; ++k)\n\t\tif (vv[x][k])\n\t\t\tcur[j - k] = 1;\n\tauto it = mm.find(cur);\n\tif (it == mm.end())\n\t\treturn -1;\n\treturn it->second;\n}\nconst int MX = 50000;\n\nint go[MX][10];\nll dp[MX][10][20];\nint nl;\n\nll get(ll x, int k) {\n\tvector dg;\n\tfor (int i = 0; i < C2; ++i)\n\t\tdg.push_back(x % 10), x /= 10;\n\tll ans = 0;\n\tll cur = nl;\n\tfor (int i = C2 - 1; i >= 0; --i){\n\t\tfor (int j = 0; j < dg[i]; ++j){\n\t\t\tll tmp = go[cur][j];\n\t\t\tans += dp[tmp][k][i];\n\t\t}\n\t\tcur = go[cur][dg[i]];\n\t}\n\treturn ans;\n}\n\nint av[MX][10];\n\nint main() {\n\n\tbb tmp;\n\ttmp[0] = 1;\n\tmapa1.insert(tmp);\n\tfor (int i = 0; i < C2; ++i){\n\t\tmapa2.clear();\n\t\tfor (auto msk: mapa1){\n\t\t\tfor (int j = 0; j <= 9; ++j){\n\t\t\t\tbb cur = (msk << j) | (msk >> j);\n\t\t\t\tfor (int k = 0; k < j; ++k)\n\t\t\t\t\tif (msk[k])\n\t\t\t\t\t\tcur[j - k] = 1;\n\t\t\t\tmapa2.insert(cur);\n\t\t\t}\n\t\t}\n\t\tmapa1 = mapa2;\n\t}\n\tfor (auto x: mapa1)\n\t\tvv.push_back(x);\n\tsort(vv.begin(), vv.end(), cmp);\n\tfor (int i = 0; i < vv.size(); ++i)\n\t\tmm[vv[i]] = i;\n\tnl = mm[tmp];\n\tav[nl][0] = 1;\n\tfor (int i = 0; i < vv.size(); ++i){\n\t\tgo[i][0] = i;\n\t\tfor (int j = 1; j <= 9; ++j){\n\t\t\tgo[i][j] = upd(i, j);\n\t\t}\n\t\tfor (int j = 0; j <= 9; ++j)\n\t\t\tif (vv[i][j])\n\t\t\t\tav[i][j] = 1;\n\t}\n\tfor (int i = vv.size() - 1; i >= 0; --i){\n\t\tint x = 0;\n\t\twhile (!av[i][x]) {\n\t\t\t++x;\n\t\t}\n\t\tfor (int j = x; j <= 9; ++j)\n\t\t\tdp[i][j][0] = 1;\n\t}\n\tfor (int ad = 1; ad <= C2; ++ad){\n\t\tfor (int i = 0; i < vv.size(); ++i){\n\t\t\tfor (int j = 0; j <= 9; ++j){\n\t\t\t\tif (go[i][j] == -1)\n\t\t\t\t\tcontinue;\n\t\t\t\tfor (int k = 0; k <= 9; ++k){\n\t\t\t\t\tdp[i][k][ad] += dp[go[i][j]][k][ad - 1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tint n;\n\tcin >> n;\n\tfor (int i = 0; i < n; ++i){\n\t\tll l, r;\n\t\tint k;\n\t\tcin >> l >> r >> k;\n\t\tcout << get(r + 1, k) - get(l, k) << \"\\n\";\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e3bdbbfcbd4ad62f28041f412f29fa12", "src_uid": "db0e3ef630cb381724697a1ac5152611", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\nusing namespace std;\ntypedef long long LL;\nconst int maxn=5e4+2;\nconst int maxm=20+2;\nconst int B=200+2;\nint cnt=1;\nbitset a[maxn];\nint to[maxm][maxn];\nbool vis[maxm][maxn];\nmap,int> mp;\nLL dp[maxm][maxm][maxn];\nvoid DP(){\n\tfor (int i=1;i=0;i--){\n\t\tfor (int j=0;j Bit;\n\tBit.set(0);\n\tmp[Bit]=1;\n\ta[1]=Bit;\n\tvis[0][1]=1;\n\tfor (int i=1;i\n#define mo (3e18ll)\n#define ll long long\n#define gc getchar\nusing namespace std;\n\nvoid upd(ll &x,ll y){\n\t(x+=y)>=mo?x-=mo:233;\n}\nstruct node{\n\tint nxt;\n\tll sta,v[10];\n\tnode(){\n\t\tnxt=0;\n\t\tmemset(v,0,sizeof(v));\n\t}\n};\nstruct state{\n\t#define Mo 100007\n\tvector nodes;\n\tint head[Mo];\n\tstate(){\n\t\tmemset(head,-1,sizeof(head));\n\t}\n\tsize_t size() const{\n\t\treturn nodes.size();\n\t}\n\tvoid sum(){\n\t\tfor (int i=0;i vis[15],pre[200],tmp;\n\nstruct big{\n\tint a[35],len;\n\tvoid read(){\n\t\tmemset(a,0,sizeof(a)); \n\t\tlen=0;\n\t\tchar ch=gc();\n\t\tfor (;ch<'0'||ch>'9';ch=gc());\n\t\tfor (;ch>='0'&&ch<='9';ch=gc())\n\t\t\ta[len++]=ch-48;\n\t}\n\tint mod(){\n\t\tint ans=0;\n\t\tfor (int i=0;i=1;i--)\n\t\t\ta[i-1]+=a[i]/10,a[i]%=10;\n\t\tif (a[0]>9){\n\t\t\ta[len]=1;\n\t\t\tfor (int i=0;i>1];\n\tif (sum>>1) tmp^=pre[(sum>>1)-1];\n\tif ((vis[dep-1]&tmp)==tmp) return;\n\tif (dep==10){\n\t\tfor (int i=sum>>1;i>=0;i--)\n\t\t\tif (vis[dep-1][i]){\n\t\t\t\tint dif=sum-i-i;\n\t\t\t\tif (dif>1){\n\t\t\t\t\t::sum[cnt]++;\n\t\t\t\t\tf[dif][0].update(0,msk,1);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\treturn;\n\t}\n\tvis[dep]=vis[dep-1];\n\tdfs(dep+1,cnt,sum,msk);\n\tfor (;cnt<18;){\n\t\tvis[dep]|=vis[dep]<30){\n\t\t\tfor (int j=0;j>1,even=lim.a[i]-odd;\n\t\tans+=c[part][len-1-i]*odd+c[part^1][len-1-i]*even;\n\t\tpart^=lim.a[i]&1;\n\t}\n\treturn ans;\n}\ninline ll read(){\n\tll x=0;\n\tchar ch=gc();\n\tfor (;ch<'0'||ch>'9';ch=gc());\n\tfor (;ch>='0'&&ch<='9';ch=gc())\n\t\tx=x*10-48+ch;\n\treturn x;\n}\nint main(){\n\tpre[0][0]=1;\n\tfor (int i=1;i<=190;i++)\n\t\tpre[i]=pre[i-1],pre[i][i]=1;\n\tc[0][0]=1;\n\tfor (int i=1;i<=18;i++)\n\t\tc[0][i]=c[1][i]=5ll*(c[0][i-1]+c[1][i-1])%mo;\n\tbit[1]=1;\n\tfor (int i=2;i<10;i++)\n\t\tbit[i]=bit[i-1]<<5;\n\tvis[0].set(0);\n\tdfs(1,0,0,0);\n\tfor (int i=2;i<10;i++){\n\t\tf[i][0].sum();\n\t\tfor (int j=0;j<18;j++){\n\t\t\tstate &cur=f[i][j],&nxt=f[i][j+1];\n\t\t\tfor (int id=0,sz=cur.size();id>=5){\n\t\t\t\t\tint rem=tmp&31;\n\t\t\t\t\tif (!rem) continue;\n\t\t\t\t\tcnt+=rem; nxt.update(k,msk-bit[k],way);\n\t\t\t\t}\n\t\t\t\tif (cnt<18)\n\t\t\t\t\tnxt.update(0,msk,way);\n\t\t\t}\n\t\t\tnxt.sum();\n\t\t}\n\t}\n\tint Q=read();\n\twhile (Q--){\n\t\tL.read(); R.read();\n\t\tR.plus();\n\t\tint k=read();\n\t\tll ans=R.mod()-L.mod();\n\t\tif (!k){\n\t\t\tans-=solve2(R)-solve2(L);\n\t\t\tfor (int i=2;i<10;i+=2)\n\t\t\t\tans-=solve(i,R)-solve(i,L);\n\t\t}\n\t\telse\n\t\t\tfor (int i=k+1;i<10;i++)\n\t\t\t\tans-=solve(i,R)-solve(i,L);\n\t\tprintf(\"%lld\\n\",(ans%mo+mo)%mo);\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "007fd36b991f1b53facfa31ae689b240", "src_uid": "db0e3ef630cb381724697a1ac5152611", "difficulty": 3200.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\ninline void update(int64_t &A, int64_t B){\n if(A > B) A = B;\n}\nint64_t dp[2][500][500][2];\nvector> robot[500][500];\nbool good[500000][4];\nbitset<500000> good[4];\nint d[500000], e[500000];\nsigned main(){\n ios_base::sync_with_stdio(0); cin.tie(0);\n // freopen(\"FDT.txt\", \"r\", stdin);\n int n, m, k;\n cin >> n >> m >> k;\n vector dx = {0, 1, 1, 0}, dy = {0, -1, 0, 1};\n int cap = max(m, n);\n for(int i = 0; i < k; i ++){\n int x, y, t;\n cin >> x >> y >> d[i] >> t >> e[i];\n for(int zi = 0; zi < 4; zi ++){\n int nx = x + dx[zi] * d[i], ny = y + dy[zi] * d[i];\n if(zi + t <= nx + ny && (zi + t) % 4 == (nx + ny) % 4){\n robot[nx][ny].push_back({i, zi});\n good[zi].set(i);\n }\n }\n }\n for(int X = 0; X < 2; ++ X)\n for(int Y = 0; Y < m; ++ Y)\n for(int W = 0; W < cap; ++ W)\n for(int vert = 0; vert < 2; ++ vert)\n dp[X][Y][W][vert] = LLONG_MAX;\n dp[0][0][0][0] = dp[0][0][0][1] = 0;\n int64_t ans = LLONG_MAX;\n for(int X = 0; X < n; ++ X){\n int cur = X & 1; int nxt = 1 - cur;\n for(int Y = 0; Y < m; ++ Y){\n for(int W = 0; W < cap; ++ W){\n for(int vert = 0; vert < 2; vert ++){\n if(W > (vert ? X: Y) || dp[cur][Y][W][vert] == LLONG_MAX) break;\n if(Y < m - 1){\n int right = (vert ? 0: W) + 1;\n int64_t smash = 0;\n for(auto &[id, zi]: robot[X][Y + 1]){\n if(zi == 2 && right >= d[id] && good[1][id]) continue;\n if(zi == 3 && right >= d[id] && good[0][id]) continue;\n smash += e[id];\n }\n update(dp[cur][Y + 1][right][0], dp[cur][Y][W][vert] + smash);\n update(dp[cur][Y + 1][0][1], dp[cur][Y][W][vert] + smash);\n }\n if(X < n - 1){\n int down = (vert ? W: 0) + 1;\n int64_t smash = 0;\n for(auto &[id, zi]: robot[X + 1][Y]){\n if(zi == 2 && down >= d[id] && good[0][id]) continue;\n smash += e[id];\n }\n update(dp[nxt][Y][down][1], dp[cur][Y][W][vert] + smash);\n update(dp[nxt][Y][0][0], dp[cur][Y][W][vert] + smash);\n }\n }\n }\n }\n if(X == n - 1){\n for(int W = 0; W < cap; ++ W)\n for(int vert = 0; vert < 2; ++ vert)\n update(ans, dp[cur][m - 1][W][vert]);\n break;\n }\n for(int Y = 0; Y < m; ++ Y)\n for(int W = 0; W < cap; ++ W)\n for(int vert = 0; vert < 2; ++ vert)\n dp[cur][Y][W][vert] = LLONG_MAX;\n }\n cout << ans;\n return 0; \n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9d96ec470e28eb7b0143cc157948a9d1", "src_uid": "b11cb0c2bf23bf4b4e6f6af61af9c290", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "#include\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC optimize (\"unroll-loops\")\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n//#pragma comment(linker, \"/stack:200000000\")\nusing namespace std;\n#define F first\n#define S second\n#define EB emplace_back\n#define MP make_pair\n#define all(o) (o).begin(), (o).end()\n#define mset(m,v) memset(m,v,sizeof(m))\n#define fr(i,n) for(lli i=0;i<(n);++i)\n#define rep(i,a,b) for(lli i=a;i<=b;++i)\n#define per(i,a,b) for(lli i=a;i>=b;i--)\n#define remin(a,b) (a=min((a),(b)))\n#define remax(a,b) (a=max((a),(b))) \n#define sz(x) (lli)(x).size()\n#define endl '\\n'\ntypedef long long lli; typedef long double ld;\ntypedef pair ii; typedef vector vi;\ntypedef vector vii; typedef vector graph;\nlong long MOD=1000000007; long double EPS=1e-9;\n#ifndef ONLINE_JUDGE\n#define debarr(a,n) cerr<<#a<<\" : \";for(int i=0;iostream& operator <<(ostream& os, const pair& p) {return os << \"(\" << p.first << \", \" << p.second << \")\";}\ntemplate ostream& operator <<(ostream& os, const vector& p) {os << \"[ \"; for (auto& it : p) os << it << \" \"; return os << \"]\";}\ntemplate ostream& operator <<(ostream& os, const unordered_set& p) {os << \"[ \"; for (auto& it : p) os << it << \" \"; return os << \"]\";}\ntemplate ostream& operator <<(ostream& os, const unordered_map& p) {os << \"[ \"; for (auto& it : p) os << it << \" \"; return os << \"]\";}\ntemplate ostream& operator <<(ostream& os, const set& p) {os << \"[ \"; for (auto& it : p) os << it << \" \"; return os << \"]\";}\ntemplate ostream& operator <<(ostream& os, const multiset& p) {os << \"[ \"; for (auto& it : p) os << it << \" \"; return os << \"]\";}\ntemplate ostream& operator <<(ostream& os, const map& p) {os << \"[ \"; for (auto& it : p) os << it << \" \"; return os << \"]\";}\ntemplate void dbs(string str, T t) {cerr << str << \" : \" << t << \"\\n\";}\ntemplate void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << \" : \" << t << \",\"; dbs(str.substr(idx + 1), s...);}\ntemplate void prc(T a, T b) {cerr << \"[\"; for (T i = a; i != b; ++i) {if (i != a) cerr << \", \"; cerr << *i;} cerr << \"]\\n\";}\n#else\n#define pr(...) {}\n#define debarr(a,n) {}\n#define debmat(mat,row,col) {}\n#endif\nlli binpow(lli b,lli p,lli mod){lli ans=1;b%=mod;for(;p;p>>=1){if(p&1)ans=ans*b%mod;b=b*b%mod;}return ans;}\n\nvoid pre(){\n\n}\n\nstruct trans{\n\tlli x,y,d,t,e;\n};\n\nlli n,m,k;\nvector monster;\n\nvi arr[501][501];\nlli timetoreach[501][501];\nlli dp[501][501][501][2];\nlli subractor[501][501][501][2];\nlli costforsure[501][501];\n\nvoid addcontribution(int x){\n\n}\n\nvoid solve(){\n\tcin>>n>>m>>k;\n\tfr(i,n)fr(j,m)timetoreach[i][j]=i+j;\n\tfr(i,k){\n\t\tlli x,y,d,t,e;\n\t\tcin>>x>>y>>d>>t>>e;\n\t\tmonster.push_back({x,y,d,t,e});\n\t}\n\n}\n\nsigned main(){\n ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n //freopen(\"in.txt\",\"r\",stdin);\n //freopen(\"out.txt\",\"w\",stdout);\n //cout<>_t;\n for(lli i=1;i<=_t;i++){\n //cout<<\"Case #\"<\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC optimize (\"unroll-loops\")\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n//#pragma comment(linker, \"/stack:200000000\")\nusing namespace std;\n#define F first\n#define S second\n#define EB emplace_back\n#define MP make_pair\n#define all(o) (o).begin(), (o).end()\n#define mset(m,v) memset(m,v,sizeof(m))\n#define fr(i,n) for(lli i=0;i<(n);++i)\n#define rep(i,a,b) for(lli i=a;i<=b;++i)\n#define per(i,a,b) for(lli i=a;i>=b;i--)\n#define remin(a,b) (a=min((a),(b)))\n#define remax(a,b) (a=max((a),(b))) \n#define sz(x) (lli)(x).size()\n#define endl '\\n'\ntypedef long long lli; typedef long double ld;\ntypedef pair ii; typedef vector vi;\ntypedef vector vii; typedef vector graph;\nlong long MOD=1000000007; long double EPS=1e-9;\n#ifndef ONLINE_JUDGE\n#define debarr(a,n) cerr<<#a<<\" : \";for(int i=0;iostream& operator <<(ostream& os, const pair& p) {return os << \"(\" << p.first << \", \" << p.second << \")\";}\ntemplate ostream& operator <<(ostream& os, const vector& p) {os << \"[ \"; for (auto& it : p) os << it << \" \"; return os << \"]\";}\ntemplate ostream& operator <<(ostream& os, const unordered_set& p) {os << \"[ \"; for (auto& it : p) os << it << \" \"; return os << \"]\";}\ntemplate ostream& operator <<(ostream& os, const unordered_map& p) {os << \"[ \"; for (auto& it : p) os << it << \" \"; return os << \"]\";}\ntemplate ostream& operator <<(ostream& os, const set& p) {os << \"[ \"; for (auto& it : p) os << it << \" \"; return os << \"]\";}\ntemplate ostream& operator <<(ostream& os, const multiset& p) {os << \"[ \"; for (auto& it : p) os << it << \" \"; return os << \"]\";}\ntemplate ostream& operator <<(ostream& os, const map& p) {os << \"[ \"; for (auto& it : p) os << it << \" \"; return os << \"]\";}\ntemplate void dbs(string str, T t) {cerr << str << \" : \" << t << \"\\n\";}\ntemplate void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << \" : \" << t << \",\"; dbs(str.substr(idx + 1), s...);}\ntemplate void prc(T a, T b) {cerr << \"[\"; for (T i = a; i != b; ++i) {if (i != a) cerr << \", \"; cerr << *i;} cerr << \"]\\n\";}\n#else\n#define pr(...) {}\n#define debarr(a,n) {}\n#define debmat(mat,row,col) {}\n#endif\nlli binpow(lli b,lli p,lli mod){lli ans=1;b%=mod;for(;p;p>>=1){if(p&1)ans=ans*b%mod;b=b*b%mod;}return ans;}\n\nvoid pre(){\n\n}\n\nstruct trans{\n\tlli x,y,d,t,e;\n};\n\nlli n,m,k;\nvector monster;\n\nlli cost[501][501];\nvii collisonRow[501][501];\nvii collisonCol[501][501];\nlli timetoreach[501][501];\nlli dp[501][501][501][2];\n\nlli dx[]={0,1,1,0};\nlli dy[]={0,-1,0,1};\n\nvoid addcontribution(int x){\n\tint hit[4];mset(hit,0);\n\tfr(kk,4){\n\t\tint xx=monster[x].x+dx[kk]*monster[x].d;\n\t\tint yy=monster[x].y+dy[kk]*monster[x].d;\n\t\tif(monster[x].t+kk<=timetoreach[xx][yy]&&((monster[x].t+kk)%4==(timetoreach[xx][yy])%4)){\n\t\t\tcost[xx][yy]+=monster[x].e;\n\t\t\thit[kk]=1;\n\t\t}\n\t}\n\tif(hit[0]&&hit[3]){\n\t\tcollisonRow[monster[x].x+dx[3]*monster[x].d][monster[x].y+dy[3]*monster[x].d].EB(monster[x].d+1,monster[x].e);\n\t}\n\tif(hit[1]&&hit[2]){\n\t\tcollisonRow[monster[x].x+dx[2]*monster[x].d][monster[x].y+dy[2]*monster[x].d].EB(monster[x].d+1,monster[x].e);\n\t}\n\tif(hit[0]&&hit[2]){\n\t\tcollisonCol[monster[x].x+dx[2]*monster[x].d][monster[x].y+dy[2]*monster[x].d].EB(monster[x].d+1,monster[x].e);\n\t}\n}\n\nvoid solve(){\n\tcin>>n>>m>>k;\n\tfr(i,n)fr(j,m)timetoreach[i][j]=i+j;\n\tfr(i,k){\n\t\tlli x,y,d,t,e;\n\t\tcin>>x>>y>>d>>t>>e;\n\t\tmonster.push_back({x,y,d,t,e});\n\t}\n\tfr(i,k){\n\t\taddcontribution(i);\n\t}\n\t// fr(i,n){\n\t// \tfr(j,m){\n\t// \t\tcout<>_t;\n for(lli i=1;i<=_t;i++){\n //cout<<\"Case #\"<\n \nusing namespace std;\n \ntypedef long long ll;\n \n#ifdef iq\n mt19937 rnd(228);\n#else\n mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());\n#endif\n \n \n/** Interface */\n \ninline int readChar();\ntemplate inline T readInt(); \ntemplate inline void writeInt( T x, char end = 0 );\ninline void writeChar( int x ); \ninline void writeWord( const char *s );\n \n/** Read */\n \nstatic const int buf_size = 4096;\n \ninline int getChar() {\n\tstatic char buf[buf_size];\n\tstatic int len = 0, pos = 0;\n\tif (pos == len)\n\t\tpos = 0, len = fread(buf, 1, buf_size, stdin);\n\tif (pos == len)\n\t\treturn -1;\n\treturn buf[pos++];\n}\n \ninline int readChar() {\n\tint c = getChar();\n\twhile (c <= 32)\n\t\tc = getChar();\n\treturn c;\n}\n \ntemplate \ninline T readInt() {\n\tint s = 1, c = readChar();\n\tT x = 0;\n\tif (c == '-')\n\t\ts = -1, c = getChar();\n\twhile ('0' <= c && c <= '9')\n\t\tx = x * 10 + c - '0', c = getChar();\n\treturn s == 1 ? x : -x;\n}\n \n/** Write */\n \nstatic int write_pos = 0;\nstatic char write_buf[buf_size];\n \ninline void writeChar( int x ) {\n\tif (write_pos == buf_size)\n\t\tfwrite(write_buf, 1, buf_size, stdout), write_pos = 0;\n\twrite_buf[write_pos++] = x;\n}\n \ntemplate \ninline void writeInt( T x, char end ) {\n\tif (x < 0)\n\t\twriteChar('-'), x = -x;\n \n\tchar s[24];\n\tint n = 0;\n\twhile (x || !n)\n\t\ts[n++] = '0' + x % 10, x /= 10;\n\twhile (n--)\n\t\twriteChar(s[n]);\n\tif (end)\n\t\twriteChar(end);\n}\n \ninline void writeWord( const char *s ) {\n\twhile (*s)\n\t\twriteChar(*s++);\n}\n \nstruct Flusher {\n\t~Flusher() {\n\t\tif (write_pos)\n\t\t\tfwrite(write_buf, 1, write_pos, stdout), write_pos = 0;\n\t}\n} flusher;\n \n/** Example */\n \nvector > f_r[500][500], f_c[500][500];\n \nll dp[500][500];\nll delta_r[500][500];\nll delta_c[500][500];\n//ll rdelta[500][500][500];\nll cdelta[500][500];\n \nconst ll inf = 1e18;\n \nconst int T = 5e5 + 7;\n \nint vis[T];\n \nint tt = 0;\n \nstruct triple {\n int i, j, cost;\n};\n \nvector f[500];\nvector g[500];\n \nll fenw[500][500];\n \nstruct orz {\n int j, l, r, cost;\n};\n \nbool operator < (const orz &a, const orz &b) {\n return a.l < b.l;\n}\n \nvector sus;\n \nint main() {\n#ifdef iq\n freopen(\"a.in\", \"r\", stdin);\n#endif\n //ios::sync_with_stdio(0);\n //cin.tie(0);\n int n = readInt(), m = readInt(), k = readInt();\n //cin >> n >> m >> k;\n for (int i = 0; i < k; i++) {\n int x = readInt(), y = readInt(), d = readInt(), t = readInt(), e = readInt();\n vector > v;\n v.emplace_back(0, 0);\n v.emplace_back(d, -d);\n v.emplace_back(d, 0);\n v.emplace_back(0, d);\n int ind = i;\n int cnt = 0;\n vector > cells;\n for (int i = 0; i < 4; i++) {\n int a = x + v[i].first, b = y + v[i].second;\n if ((a + b - t) % 4 == i && a + b >= t) {\n cnt++;\n cells.push_back({a, b});\n }\n }\n if (cells.empty()) continue;\n if ((int) cells.size() == 1) {\n for (auto c : cells) {\n delta_r[c.first][c.second] += e;\n delta_c[c.first][c.second] += e;\n }\n } else {\n if (cells[0].first != cells[1].first) {\n for (auto c : cells) {\n delta_r[c.first][c.second] += e;\n delta_c[c.first][c.second] += e;\n }\n if (cells[0].second == cels[1].second)\n sus.push_back({cells[0].second, min(cells[0].first, cells[1].first), max(cells[0].first, cells[1].first), -e});\n /*\n for (auto c : cells) {\n f_r[c.first][c.second].push_back({i, e});\n }\n */\n } else {\n for (auto c : cells) {\n delta_r[c.first][c.second] += e;\n delta_c[c.first][c.second] += e;\n }\n g[cells[0].first].push_back({min(cells[0].second, cells[1].second), max(cells[0].second, cells[1].second), -e});\n //cdelta[cells[0].first][min(cells[0].second, cells[1].second)][max(cells[0].second, cells[1].second)] -= e;\n }\n }\n }\n sort(sus.begin(), sus.end());\n /*\n for (int i = 0; i < n; i++) {\n for (int j = m - 1; j >= 0; j--) {\n for (int k = j; k < m; k++) {\n if (j + 1 <= k) {\n cdelta[i][j][k] += cdelta[i][j + 1][k];\n cdelta[i][j][k] += cdelta[i][j][k - 1];\n }\n if (j + 2 <= k) {\n cdelta[i][j][k] -= cdelta[i][j + 1][k - 1];\n }\n }\n }\n }\n for (int i = 0; i < m; i++) {\n for (int j = n - 1; j >= 0; j--) {\n for (int k = j; k < n; k++) {\n if (j + 1 <= k) {\n rdelta[i][j][k] += rdelta[i][j + 1][k];\n rdelta[i][j][k] += rdelta[i][j][k - 1];\n }\n if (j + 2 <= k) {\n rdelta[i][j][k] -= rdelta[i][j + 1][k - 1];\n }\n }\n }\n }\n */\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < m; j++) {\n dp[i][j] = inf;\n }\n }\n dp[0][0] = delta_r[0][0];\n int ptr = -1;\n vector ok;\n for (int i = 0; i < n; i++) {\n while (ptr + 1 < (int) sus.size() && sus[ptr + 1].l < i) {\n ptr++;\n }\n for (int j = 0; j < m; j++) {\n for (int k = 0; k < m; k++) {\n cdelta[j][k] = 0;\n }\n }\n for (auto t : g[i]) {\n cdelta[t.i][t.j] += t.cost;\n }\n for (int j = m - 1; j >= 0; j--) {\n for (int k = j; k < m; k++) {\n if (j + 1 <= k) {\n cdelta[j][k] += cdelta[j + 1][k];\n cdelta[j][k] += cdelta[j][k - 1];\n }\n if (j +2 <= k) {\n cdelta[j][k] -= cdelta[j + 1][k - 1];\n }\n }\n }\n for (int j = 0; j < m; j++) {\n //cout << i << ' ' << j << ' ' << dp[i][j] << endl;\n tt++;\n ll cost = 0;\n for (int k = j; k < m; k++) {\n if (k > j)\n cost += delta_c[i][k];\n /*\n ll orz = 0;\n for (auto t : g[i]) {\n if (j <= t.i && t.j <= k) {\n orz += t.cost;\n }\n }\n */\n dp[i][k] = min(dp[i][k], dp[i][j] + cost + cdelta[j][k]);\n }\n tt++;\n cost = 0;\n for (int k = i; k < n; k++) {\n if (k > i)\n cost += delta_r[k][j];\n ll orz = 0;\n for (int ind = ptr + 1; ind < (int) sus.size(); ind++) {\n if (sus[ind].j == j && sus[ind].r <= k) {\n orz += sus[ind].cost;\n }\n }\n //cost += rdelta[j][i][k];\n dp[k][j] = min(dp[k][j], dp[i][j] + cost + orz);\n }\n }\n }\n cout << dp[n - 1][m - 1] << '\\n';\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "7a552f829b89593c87a44620fa02b3b5", "src_uid": "b11cb0c2bf23bf4b4e6f6af61af9c290", "difficulty": 2600.0} {"lang": "MS C++", "source_code": "#include \n\nusing namespace std;\n\nint main() {\ncout << 1 << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c6835fa531030718e84b2522d0e9312c", "src_uid": "d163975cdad000ce89ee251ef9129779", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#include\n#include \n#include \nusing namespace __gnu_pbds;\nusing namespace std;\ntypedef long long ll;\ntypedef double db;\ntypedef vector vl;\ntypedef pair pl;\nconst int N=1e6+1;\n#define po pop_back\n#define pb push_back\n#define mk make_pair\n#define lw lower_bound\n#define up upper_bound\n#define ff first\n#define ss second\n#define boost ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);\n#define MOD 1000000007\n#define MAX 1e18 \n#define MIN -1e18\n#define rep(i,a,b) for(ll i=a;i<=b;i++)\n#define per(i,a,b) for(ll i=b;i>=a;i--)\n#define con continue\n#define freopen freopen(\"input.txt\", \"r\", stdin);freopen(\"output.txt\", \"w\", stdout);\n#define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628\n// typedef tree, rb_tree_tag, tree_order_statistics_node_update> indexed_set;\ntemplate< typename T>\nusing indexed_set = tree, rb_tree_tag, tree_order_statistics_node_update>;\nll ans1,ans2,ans,mid,mn,mx,cnt,m,T,sum,h1,h2,a,b,c[1<<20],d[1<<20],c1[1234][1234],n,k,i,j,l,x,y,r,z,h,e[1<<20],w;\nbool used[10000005];\npl p[1234567];\nstring s,s1[1234567],ss;\nmap mp;\nmap mpl;\nvl v[1234567];\nvl v1,vec;\nchar cha[1234567];\nvector vp;\nint main(){\n cin>>n;\n if(n>33500)cout<<3;\n else cout<<2;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "94192832d5470b8e620166c3d4151070", "src_uid": "d163975cdad000ce89ee251ef9129779", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include \n//#define int long long\n#define hash hashhash\n#define X first\n#define Y second\n#define endl \"\\n\"\n#define Mp make_pair\nusing namespace std;\ninline int in(){int32_t x ; scanf(\"%d\",&x) ; return x ; }\ninline long long lin(){long long x ; scanf(\"%lld\",&x) ; return x ;}\ninline string get(){char ch[2000010] ; scanf(\"%s\",ch) ; return ch;}\ninline void read(int *a , int n ) { for (int i = 0 ; i < n ; i ++) a[i] = in() ; }\ntemplate inline void out(blank x) {cout << x << endl ; exit(0) ;}\ntemplate inline void smin(blank &a , blank b) {a = min(a , b) ;}\ntemplate inline void smax(blank &a , blank b) {a = max(a , b) ; }\ntypedef pair pii;\ntypedef long double ld;\ntypedef unsigned long long ull;\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vii;\nconst int maxn = 1e6 + 10;\nconst int maxm = 1e6 + 10;\nconst int maxlg = 21;\nconst int base = 29;\nconst int mod = 1e9 + 7;\nconst ll inf = 2e18 + 10;\nconst int SQ = 317;\nint32_t main()\n{\n int n = in();\n if (n <= 54000) cout << 1 << endl;\n else if (n <= 50000) cout << 3 << endl;\n else cout << 2 << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a32899dc5d862bfa7ce49fa5d82d16ee", "src_uid": "d163975cdad000ce89ee251ef9129779", "difficulty": 2100.0} {"lang": "GNU C++14", "source_code": "var n:longint;\nbegin\nread(n);\nif (n<=50000) then writeln(3) else\nif (n>=54000) then writeln(1) else\nwriteln(2);\nend.\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b5e5cf9dab314ccfeb2b261f84bce0a2", "src_uid": "d163975cdad000ce89ee251ef9129779", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\nconst int maxn=410010;\nconst int inf=2100000000;\nconst int maxm=100000000;\n\nint lft[maxn<<2],rht[maxn<<2],M[maxn<<2][4];\nint lc[maxn<<2],rc[maxn<<2],a[maxn],cnt;\n\nvoid build(int n,int l,int r)\n{\n\tlft[n]=l,rht[n]=r;\n\tfor(int i=0;i<4;i++)\n\t\tM[n][i]=inf;\n\tif(l==r)\n\t\treturn;\n\tint mid=(l+r)/2;\n\tbuild(n<<1,l,mid);\n\tbuild((n<<1)+1,mid+1,r);\n}\n\nvoid upd(int n,int pos,int i,int k)\n{\n\tif(lft[n]==rht[n])\n\t{\n\t\tM[n][i]=k;\n\t\treturn;\n\t}\n\tint mid=(lft[n]+rht[n])/2;\n\tif(pos<=mid)\n\t\tupd(n<<1,pos,i,k);\n\telse\n\t\tupd((n<<1)+1,pos,i,k);\n\tM[n][i]=min(M[n<<1][i],M[(n<<1)+1][i]);\n}\n\nint get(int n,int l,int r,int i)\n{\n\tif(lft[n]==l&&rht[n]==r)\n\t\treturn M[n][i];\n\tint mid=(lft[n]+rht[n])/2;\n\tif(r<=mid)\n\t\treturn get(n<<1,l,r,i);\n\telse if(l>mid)\n\t\treturn get((n<<1)+1,l,r,i);\n\treturn min(get(n<<1,l,mid,i),get((n<<1)+1,mid+1,r,i));\n}\n\nstruct NN\n{\n\tint bel,add,lx,rx,ly,ry;\n\tNN(int b=0,int a=0,int llx=0,int rrx=0,int lly=0,int rry=0)\n\t{\n\t\tbel=b;\n\t\tadd=a;\n\t\tlx=llx;\n\t\trx=rrx;\n\t\tly=lly;\n\t\try=rry;\n\t}\n};\n\nvectorV1[maxn];\nvectorV2[maxn];\nvectorV3[maxn];\nvectorV4[maxn];\nvectorV5[maxn];\nvectorV6[maxn];\nvectorV7[maxn];\nvectorV8[maxn];\n\nint ans[maxn];\nint q[maxn];\n\nint gao(int n,int idx,NN k)\n{\n\tint i,j,l,r,mid,L,R;\n\t\n\tl=1,r=n+1;\n\twhile(l=k.lx&&a[q[mid]]>=k.ly)\n\t\t\tr=mid;\n\t\telse\n\t\t\tl=mid+1;\n\t}\n\tL=l,l=0,r=n;\n\twhile(lR||L>n||R<1)\n\t\treturn inf;\n\tint ret=get(1,L,R,idx);\n\treturn ret;\n}\n\nvoid cal(int n)\n{\n\tint tail=0,i,j;\n\tbuild(1,1,n);\n\tfor(i=1;i<=n;i++)\n\t{\n\t\twhile(tail&&a[q[tail]]>=a[i])\n\t\t\ttail--;\n\t\tq[++tail]=i;\n\t\tupd(1,tail,0,-a[i]-i*2);\n\t\tupd(1,tail,1,a[i]-i*2);\n\t\tupd(1,tail,2,-a[i]);\n\t\tupd(1,tail,3,a[i]);\n\t\t\n\t\tfor(j=0;j=R1[1];i--)\n{\nc=min(c,a[i]);\nif(abs(C2[1]-c)+1+R2[1]-R1[1]==81385)\nprintf(\"1\");\ntmp=min(tmp,abs(C2[1]-c)+1+R2[1]-R1[1]);\n}\ncc=c;\nfor(i=R1[1];i>=1;i--)\n{\nc=min(c,a[i]);\nif(abs(C2[1]-c)+1+R2[1]-i+R1[1]-i==81385)\n\nprintf(\"2\");\ntmp=min(tmp,abs(C2[1]-c)+1+R2[1]-i+R1[1]-i);\n}\nc=inf;\nfor(i=R2[i];i<=n;i++)\n{\nc=min(c,a[i]);\nif(abs(C2[1]-c)+1+i*2-R1[1]-R2[1]==81385)\nputs(\"3\");\ntmp=min(tmp,abs(C2[1]-c)+1+i*2-R1[1]-R2[1]));\n}\n}\n\tfor(i=1;i<=Q;i++)\n\t\tprintf(\"%d\\n\",ans[i]);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6936c557c88f25995a728edb563d3507", "src_uid": "79b6cdbcdfcf00e0649dfc85af46d021", "difficulty": 3100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n\n#include \n\n#include \n\n#include \n#include \n\n#include \n#include \n\nusing namespace std;\ntypedef long long llint;\n\n#define FOR(i, a, b) for(int i = (a); i < (b); ++i)\n#define REP(i, n) FOR(i, 0, n)\n#define log(...) //fprintf(stderr, ##__VA_ARGS__)\n\nconst int inf = 1000000000;\n\n#define L(n) ((n) << 1)\n#define R(n) (L(n) | 1)\n\nint n, q;\nint r1, c1;\nint r2, c2;\n\nconst int off = 1 << 19;\n\nint a[off];\nint hibit[off];\n\ntypedef pair< int, int > pii;\n\nstruct rmqq {\n pii rmq[19][off];\n\n rmqq() {\n memset(rmq, 0x3f, sizeof rmq);\n }\n\n void build() {\n FOR(i, 1, 19) REP(j, n) \n rmq[i][j] = min(rmq[i - 1][j], (j + (1 << (i - 1)) < off) ? rmq[i - 1][j + (1 << (i - 1))] : pii(inf, inf));\n }\n\n pii get(int l, int r) {\n ++r;\n int b = hibit[r - l];\n return min(rmq[b][l], rmq[b][r - (1 << b)]);\n }\n};\n\nrmqq min_val;\nrmqq min_l;\nrmqq min_r;\n\nint main(void)\n{\n FOR(i, 2, off) {\n if (i == (i & -i)) \n hibit[i] = hibit[i - 1] + 1;\n else \n hibit[i] = hibit[i - 1];\n }\n\n scanf(\"%d\", &n);\n REP(i, n) scanf(\"%d\", a + i);\n\n REP(i, n) {\n min_val.rmq[0][i] = { a[i], a[i] };\n min_l.rmq[0][i] = { a[i] - 2 * i, a[i] };\n min_r.rmq[0][i] = { a[i] + 2 * i, a[i] };\n }\n\n min_val.build();\n min_l.build();\n min_r.build();\n\n scanf(\"%d\", &q);\n\n REP(i, q) {\n scanf(\"%d%d%d%d\", &r1, &c1, &r2, &c2); --r1; --r2;\n int rdiff = abs(r1 - r2);\n int imin = min_val.get(min(r1, r2), max(r1, r2)).first;\n int mmin = min(imin, c1);\n\n int cdiff = abs(mmin - c2);\n\n cdiff = min(cdiff, 1 + c2);\n cdiff = min(cdiff, 1 + abs(c2 - a[r2]));\n \n int sol = cdiff + rdiff;\n\n int lo, hi, mid;\n int c;\n\n lo = 0, hi = r2;\n while (lo < hi) {\n mid = (lo + hi + 1) / 2;\n if (min_val.get(mid, r2).first > c2) \n hi = mid - 1;\n else\n lo = mid;\n }\n \n c = a[lo];\n sol = min(sol, rdiff + abs(r1 - lo) * 2 + abs(c - c2) + (mmin < c));\n sol = min(sol, rdiff + abs(r2 - lo) * 2 + abs(c - c2) + (mmin < c));\n if ((r1 <= lo && lo <= r2) || (r2 <= lo && lo <= r1))\n sol = min(sol, rdiff + abs(c - c2) + (mmin < c));\n\n if (lo < r2) {\n ++lo;\n int d = min_l.get(lo, r2).first + 2 * r2;\n sol = min(sol, rdiff + d - c2 + 1);\n\n if (r1 <= lo) {\n int d = min_val.get(lo, r2).first;\n sol = min(sol, rdiff + d - c2 + 1);\n }\n\n if (lo <= r2 && r2 <= r1) {\n pii D = min_l.get(lo, r2);\n int d = D.first + 2 * r2;\n sol = min(sol, rdiff + d - c2 + (D.second > mmin));\n }\n\n if (lo <= r1 && r1 <= r2) {\n pii D = min_l.get(lo, r1);\n int d = D.first + 2 * r1;\n sol = min(sol, rdiff + d - c2 + (D.second > mmin));\n }\n\n if (r1 <= r2) {\n int r = max(lo, r1);\n int c = min_val.get(r, r2).first;\n assert(c > c2);\n sol = min(sol, rdiff + c - c2 + (c > mmin));\n }\n }\n \n lo = r2, hi = n - 1;\n while (lo < hi) {\n mid = (lo + hi) / 2;\n if (min_val.get(r2, mid).first > c2)\n lo = mid + 1;\n else\n hi = mid;\n }\n\n c = a[lo];\n sol = min(sol, rdiff + abs(r1 - lo) * 2 + abs(c - c2) + (mmin < c));\n sol = min(sol, rdiff + abs(r2 - lo) * 2 + abs(c - c2) + (mmin < c));\n if ((r1 <= lo && lo <= r2) || (r2 <= lo && lo <= r1))\n sol = min(sol, rdiff + abs(c - c2) + (mmin < c));\n\n if (lo > r2) {\n --lo;\n int d = min_r.get(r2, lo).first - 2 * r2;\n sol = min(sol, rdiff + d - c2 + 1);\n\n if (r1 >= lo) {\n int d = min_val.get(r2, lo).first;\n sol = min(sol, rdiff + d - c2 + 1);\n }\n \n if (r2 <= lo && r1 <= r2) {\n pii D = min_r.get(r2, lo);\n int d = D.first - 2 * r2;\n sol = min(sol, rdiff + d - c2 + (D.second > mmin));\n }\n\n if (lo >= r1 && r1 >= r2) {\n pii D = min_r.get(r1, lo);\n int d = D.first - 2 * r1;\n sol = min(sol, rdiff + d - c2 + (D.second > mmin));\n }\n\n if (r2 <= r1) {\n int r = min(r1, lo);\n int c = min_val.get(r2, r).first;\n sol = min(sol, rdiff + c - c2 + (c > mmin));\n }\n }\n\n printf(\"%d\\n\", sol);\n }\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "95d5ec3045ce5d190d7ab3f75fe09206", "src_uid": "79b6cdbcdfcf00e0649dfc85af46d021", "difficulty": 3100.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\nconst int maxn=410010;\nconst int inf=2100000000;\nconst int maxm=100000000;\n\nint lft[maxn<<2],rht[maxn<<2],M[maxn<<2][4];\nint lc[maxn<<2],rc[maxn<<2],a[maxn],cnt;\n\nvoid build(int n,int l,int r)\n{\n\tlft[n]=l,rht[n]=r;\n\tfor(int i=0;i<4;i++)\n\t\tM[n][i]=inf;\n\tif(l==r)\n\t\treturn;\n\tint mid=(l+r)/2;\n\tbuild(n<<1,l,mid);\n\tbuild((n<<1)+1,mid+1,r);\n}\n\nvoid upd(int n,int pos,int i,int k)\n{\n\tif(lft[n]==rht[n])\n\t{\n\t\tM[n][i]=k;\n\t\treturn;\n\t}\n\tint mid=(lft[n]+rht[n])/2;\n\tif(pos<=mid)\n\t\tupd(n<<1,pos,i,k);\n\telse\n\t\tupd((n<<1)+1,pos,i,k);\n\tM[n][i]=min(M[n<<1][i],M[(n<<1)+1][i]);\n}\n\nint get(int n,int l,int r,int i)\n{\n\tif(lft[n]==l&&rht[n]==r)\n\t\treturn M[n][i];\n\tint mid=(lft[n]+rht[n])/2;\n\tif(r<=mid)\n\t\treturn get(n<<1,l,r,i);\n\telse if(l>mid)\n\t\treturn get((n<<1)+1,l,r,i);\n\treturn min(get(n<<1,l,mid,i),get((n<<1)+1,mid+1,r,i));\n}\n\nstruct NN\n{\n\tint bel,add,lx,rx,ly,ry;\n\tNN(int b=0,int a=0,int llx=0,int rrx=0,int lly=0,int rry=0)\n\t{\n\t\tbel=b;\n\t\tadd=a;\n\t\tlx=llx;\n\t\trx=rrx;\n\t\tly=lly;\n\t\try=rry;\n\t}\n};\n\nvectorV1[maxn];\nvectorV2[maxn];\nvectorV3[maxn];\nvectorV4[maxn];\nvectorV5[maxn];\nvectorV6[maxn];\nvectorV7[maxn];\nvectorV8[maxn];\n\nint ans[maxn];\nint q[maxn];\n\nint gao(int n,int idx,NN k)\n{\n\tint i,j,l,r,mid,L,R;\n\t\n\tl=1,r=n+1;\n\twhile(l=k.lx&&a[q[mid]]>=k.ly)\n\t\t\tr=mid;\n\t\telse\n\t\t\tl=mid+1;\n\t}\n\tL=l,l=0,r=n;\n\twhile(lR||L>n||R<1)\n\t\treturn inf;\n\tint ret=get(1,L,R,idx);\n\treturn ret;\n}\n\nvoid cal(int n)\n{\n\tint tail=0,i,j;\n\tbuild(1,1,n);\n\tfor(i=1;i<=n;i++)\n\t{\n\t\twhile(tail&&a[q[tail]]>=a[i])\n\t\t\ttail--;\n\t\tq[++tail]=i;\n\t\tupd(1,tail,0,-a[i]-i*2);\n\t\tupd(1,tail,1,a[i]-i*2);\n\t\tupd(1,tail,2,-a[i]);\n\t\tupd(1,tail,3,a[i]);\n\t\t\n\t\tfor(j=0;j=R1[1];i--)\n\t\t{\n\t\t\tc=min(c,a[i]);\n\t\t\tif(abs(C2[1]-c)+1+R2[1]-R1[1]==81385)\n\t\t\t\tprintf(\"1\");\n\t\t\ttmp=min(tmp,abs(C2[1]-c)+1+R2[1]-R1[1]);\n\t\t}\n\t\tcc=c;\n\t\tfor(i=R1[1];i>=1;i--)\n\t\t{\n\t\t\tc=min(c,a[i]);\n\t\t\tif(abs(C2[1]-c)+1+R2[1]-i+R1[1]-i==81385)\n\t\t\t\tprintf(\"2\");\n\t\t\ttmp=min(tmp,abs(C2[1]-c)+1+R2[1]-i+R1[1]-i);\n\t\t}\n\t\tc=inf;\n\t\tfor(i=R2[i];i<=n;i++)\n\t\t{\n\t\t\tc=min(c,a[i]);\n\t\t\tif(abs(C2[1]-c)+1+i*2-R1[1]-R2[1]==81385)\n\t\t\t\tputs(\"3\");\n\t\t\ttmp=min(tmp,abs(C2[1]-c)+1+i*2-R1[1]-R2[1]);\n\t\t}\n\t\tprintf(\" %d\\n\",tmp);\n\t}\n\tfor(i=1;i<=Q;i++)\n\t\tprintf(\"%d\\n\",ans[i]);\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "50852b17bafbc0ecdb2c4dd9b1ea6b7f", "src_uid": "79b6cdbcdfcf00e0649dfc85af46d021", "difficulty": 3100.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\n#define inf 1023456789\n#define linf 1023456789123456789ll\n#define pii pair\n#define pipii pair\n#define pll pair\n#define vint vector\n#define vvint vector\n#define ll long long\n#define pdd pair\n\n#define DEBUG\n#ifdef DEBUG\n#define db(x) cerr << #x << \" = \" << x << endl\n#else\n#define db(x)\n#endif\n\nint n;\nbool otocene = 0;\nvint a;\nvvint mrq;\nvint log2, moc2;\n\nstruct que\n{\n\tint c1, r1, c2, r2;\n\tque()\n\t{\n\t}\n\tque(int R1, int C1, int R2, int C2)\n\t{\n\t\tr1 = R1;\n\t\tc1 = C1;\n\t\tr2 = R2;\n\t\tc2 = C2;\n\t}\n};\n\nvoid predrataj()\n{\n\tmrq.push_back(vint(n));\n\tfor(int i=0; i<=n; i++)mrq[0][i] = a[i];\n\tint ind = 0;\n\tfor(int dlz = 2; dlz < n; dlz *= 2)\n\t{\n\t\tind++;\n\t\tmrq.push_back(vint(n-dlz+1));\n\t\tfor(int i=0; i+dlz <= n; i++)\n\t\t{\n\t\t\tmrq[ind][i] = min(mrq[ind-1][i], mrq[ind-1][i+dlz/2]);\n\t\t}\n\t}\n\tlog2.resize(n+1);\n\tlog2[1] = 0;\n\tmoc2[1] = 1;\n\tfor(int i=2; i<=n; i++)\n\t{\n\t\tlog2[i] = log2[i/2]+1;\n\t\tmoc2[i] = moc2[i/2]*2;\n\t}\n}\n\nint obrat(int a)\n{\n\treturn n-1-a;\n}\n\nint mrqa(int a, int b)\n{\n\tif(otocene)\n\t{\n\t\ta = obrat(a);\n\t\tb = obrat(b);\n\t}\n\tint dlz = b-a;\n\treturn min(mrq[log2[dlz]][a], mrq[log2[dlz]][b-moc2[dlz]]);\n}\n\nint main()\n{\n\tscanf(\"%d\",&n);\n\ta.resize(n);\n\tfor(int i=0; i query(q);\n\tvector udalost;\n\t\n\tfor(int i=0; i silny_stack(1, pii(-inf, -1)), slaby_stack(1, (-inf, -1));\n\t\tint curud = 0;\n\t\tfor(int i=0; i desired)u = mid;\n\t\t\t\t\t\t\telse l = mid;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor(int j=0; j<2; j++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(l+j >= silny_stack.size())break;\n\t\t\t\t\t\t\tint posans = 2 * (pom.r1 - silny_stack[l+j].second);\n\t\t\t\t\t\t\tif(pom.c1 < silny_stack[l+j].first)posans++;\n\t\t\t\t\t\t\tposans += pom.r2 - pom.r1;\n\t\t\t\t\t\t\tposans += abs(pom.c2 - min(mrqa(pom.r1, pom.r2+1), silny_stack[l+j].first));\n\t\t\t\t\t\t\tans[id] = min(ans, posans);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tif(pom.r2 < pom.r1)\n\t\t\t\t\t{\n\t\t\t\t\t\tint curc = min(pom.c1, mrqa(pom.r2, pom.r1+1));\n\t\t\t\t\t\t\n\t\t\t\t\t\tint l=0, u = silny_stack.size();\n\t\t\t\t\t\tint desired = pom.c2;\n\t\t\t\t\t\twhile(l < u-1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tint mid = (l+u)/2;\n\t\t\t\t\t\t\tif(silny_stack[mid].first > desired)u = mid;\n\t\t\t\t\t\t\telse l = mid;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor(int j=0; j<2; j++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(l+j >= silny_stack.size())break;\n\t\t\t\t\t\t\tint posans = 2 * (pom.r2 - silny_stack[l+j].second);\n\t\t\t\t\t\t\tif(curc < silny_stack[l+j].first)posans++;\n\t\t\t\t\t\t\tposans += pom.r1 - pom.r2;\n\t\t\t\t\t\t\tposans += abs(pom.c2 - silny_stack[l+j].first);\n\t\t\t\t\t\t\tans[id] = min(ans, posans);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tint l = 0, u = slaby_stack.size();\n\t\t\t\t\t\tint desired = pom.c2;\n\t\t\t\t\t\twhile(l < u-1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tint mid = (l+u)/2;\n\t\t\t\t\t\t\tif(slaby_stack[mid].first > desired)u = mid;\n\t\t\t\t\t\t\telse l = mid;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor(int j=0; j<2; j++)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(l+j >= slaby_stack.size())break;\n\t\t\t\t\t\t\tif(slaby_stack[l+j].second < pom.r1)continue;\n\t\t\t\t\t\t\tint posans = pom.r2 - pom.r1;\n\t\t\t\t\t\t\tposans ++;\n\t\t\t\t\t\t\tposans += abs(pom.c2 - slaby_stack[l+j].first);\n\t\t\t\t\t\t\tans[id] = min(ans, posans);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t\n\t\tif(strana == 0)\n\t\t{\n\t\t\tudalost.pop_back();\n\t\t\treverse(udalost.begin(), udalost.end());\n\t\t\tudalost.push_back(pii(-inf, -1));\n\t\t\tfor(int i=0; i\n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nconst long long inf=4e18;\nstruct xxx\n{\n\tlong long x;\n\tint flag,ip;\n\tbool operator <(const xxx &temp)const\n\t{\n\t\tif(x==temp.x)\n\t\t return flag>temp.flag;\n\t\treturn x>1;\n for(int i=0;i<4;i++)\n {\n \ttree[id].max_vl[i]=-inf;\n \ttree[id].lazy[i]=0;\n\t}\n\tif(left==right)\n\t return;\n\tbuild(left,mid,l);\n\tbuild(mid+1,right,r);\n}\nvoid zz(int id,int ll,int rr)\n{\n\tint l=2*id+1,r=2*id+2;\n\tfor(int i=0;i<4;i++)\n\t{\n\t\tif(tree[id].lazy[i]!=0&&tree[id].max_vl[i]>-inf)\n\t\t{\n\t\t\tif(ll!=rr)\n\t\t\t{\n\t\t\t\ttree[l].lazy[i]+=tree[id].lazy[i];\n\t\t\t\ttree[r].lazy[i]+=tree[id].lazy[i];\n\t\t\t}\n\t\t\ttree[id].max_vl[i]+=tree[id].lazy[i];\n\t\t}\n\t\ttree[id].lazy[i]=0;\n\t}\n}\nlong long query(int ip,long long left,long long right,long long mc,int ll,int rr,int id)\n{\n\tint l=2*id+1,r=2*id+2,mm=(ll+rr)>>1;\n\tzz(id,ll,rr);\n\tif(sum_list[ll]>right||sum_list[rr]=left&&sum_list[rr]<=right)\n\t return tree[id].max_vl[ip];\n\treturn max(query(ip,left,right,mc,ll,mm,l),query(ip,left,right,mc,mm+1,rr,r));\n}\nvoid insert(int ip,long long pos,long long vl,int ll,int rr,int id)\n{\n\tint l=2*id+1,r=2*id+2,mm=(ll+rr)>>1;\n\tzz(id,ll,rr);\n\tif(ll==rr)\n\t{\n\t\ttree[id].max_vl[ip]=max(tree[id].max_vl[ip],vl);\n\t return;\n }\n\tif(sum_list[mm]>1;\n\tzz(id,ll,rr);\n\tif(sum_list[ll]>right||sum_list[rr]=left&&sum_list[rr]<=right)\n\t{\n\t\ttree[id].lazy[ip]+=vl;\n\t\tzz(id,ll,rr);\n\t\treturn;\n\t}\n\tupdate(ip,left,right,vl,ll,mm,l);\n\tupdate(ip,left,right,vl,mm+1,rr,r);\n\ttree[id].max_vl[ip]=max(tree[l].max_vl[ip],tree[r].max_vl[ip]);\n}\nint main()\n{\n\tscanf(\"%d%d%lld\",&n[0],&n[1],&c);\n\tint i,j,s,p,q,nc=0,ch;\n\tcnt=0;\n\tfor(i=0;i<2;i++)\n\t\tfor(j=0;j0)\n\t\t\tch=1-x[i].ip;\n\t\tmf[i]=nc;\n\t\tsum_list[i]=sum[i];\n\t}\n\tcl[cnt-1]=0;\n\tmf[cnt]=vl[cnt]=0;\n\tsort(sum_list,sum_list+cnt);\n\tcnt_sum=0;\n\tfor(i=0;i=c)\n\t\t \t\tdp[j][i+1]=max(dp[j][i+1],pref-sum[i]+c+mv);\n\t\t }\n\t\t else\n\t\t {\n\t\t \tif(sum[i]<=-c)\n\t\t \t dp[j][i+1]=max(dp[j][i+1],pref+mv);\n\t\t\t}\n\t\t\tfor(s=0;s<2;s++)\n\t\t\t{\n \t\tlong long mcb[2];\n\t\t\t\tif(j==0)\n\t\t\t\t mcb[0]=c;\n\t\t\t\telse\n\t\t\t\t mcb[0]=-c;\n\t\t\t\tif(s==0)\n\t\t\t\t mcb[1]=c;\n\t\t\t\telse\n\t\t\t\t mcb[1]=-c;\n\t\t\t\tdc=mcb[0]-mcb[1];\n\t\t\t\tif(j==0&&s==0)\n\t\t\t\t\tdp[j][i+1]=max(dp[j][i+1],query(0,-inf,sum[i]-dc,dp[j][i+1]-mv+sum[i],0,cnt_sum-1,0)-sum[i]+mv);\n\t\t\t \telse if(j==1&&s==0)\n\t\t\t\t dp[j][i+1]=max(dp[j][i+1],query(1,sum[i]-dc,inf,dp[j][i+1]-mv,0,cnt_sum-1,0)+mv);\n\t\t\t\telse if(j==0&&s==1)\n\t\t\t\t dp[j][i+1]=max(dp[j][i+1],query(2,-inf,sum[i]-dc,dp[j][i+1]-mv-2*c+sum[i],0,cnt_sum-1,0)-sum[i]+2*c+mv);\n\t\t\t\telse\n\t\t\t\t dp[j][i+1]=max(dp[j][i+1],query(3,sum[i]-dc,inf,dp[j][i+1]-mv,0,cnt_sum-1,0)+mv);\n\t\t }\n \t}\n \tpref=npref;\n \tfor(q=0;q<4&&cl[i]!=0;q++)\n \t update(q,-inf,inf,cl[i],0,cnt_sum-1,0);\n\t\tif(cl[i]!=0&&mf[i]==2)\n\t\t{\n\t\t\tupdate(0,sum[i],sum[i]+2*c,cl[i],0,cnt_sum-1,0);\n\t \tupdate(1,sum[i],sum[i]+2*c,cl[i],0,cnt_sum-1,0);\t\n\t update(2,sum[i]-2*c,sum[i],cl[i],0,cnt_sum-1,0);\n\t \tupdate(3,sum[i]-2*c,sum[i],cl[i],0,cnt_sum-1,0);\n\t\t}\n\t\tif(mf[i]==2)\n\t\t{\n\t insert(0,sum[i],dp[0][i+1]+sum[i],0,cnt_sum-1,0);\n insert(1,sum[i],dp[0][i+1],0,cnt_sum-1,0); \n \t insert(2,sum[i],dp[1][i+1]+sum[i],0,cnt_sum-1,0);\n \t insert(3,sum[i],dp[1][i+1],0,cnt_sum-1,0);\n }\n\t}\n\tzz(0,0,cnt_sum-1);\n\tlong long ans=max(pref,max(tree[0].max_vl[1],tree[0].max_vl[3]));\n\tprintf(\"%lld\\n\",ans);\n\treturn 0;\n}\n/*\n \n*/", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5ec0490505b669f9d263334d364c0648", "src_uid": "fa9a0d500220905af7dcbe80740da62a", "difficulty": 3000.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nconst long long inf=4e18;\nstruct xxx\n{\n\tlong long x;\n\tint flag,ip;\n\tbool operator <(const xxx &temp)const\n\t{\n\t\tif(x==temp.x)\n\t\t return flag>temp.flag;\n\t\treturn x>1;\n for(int i=0;i<4;i++)\n {\n \ttree[id].max_vl[i]=-inf;\n \ttree[id].lazy[i]=0;\n\t}\n\tif(left==right)\n\t return;\n\tbuild(left,mid,l);\n\tbuild(mid+1,right,r);\n}\nvoid zz(int id,int ll,int rr)\n{\n\tint l=2*id+1,r=2*id+2;\n\tfor(int i=0;i<4;i++)\n\t{\n\t\tif(tree[id].lazy[i]!=0&&tree[id].max_vl[i]>-inf)\n\t\t{\n\t\t\tif(ll!=rr)\n\t\t\t{\n\t\t\t\ttree[l].lazy[i]+=tree[id].lazy[i];\n\t\t\t\ttree[r].lazy[i]+=tree[id].lazy[i];\n\t\t\t}\n\t\t\ttree[id].max_vl[i]+=tree[id].lazy[i];\n\t\t}\n\t\ttree[id].lazy[i]=0;\n\t}\n}\nlong long query(int ip,long long left,long long right,int ll,int rr,int id)\n{\n\tint l=2*id+1,r=2*id+2,mm=(ll+rr)>>1;\n\tzz(id,ll,rr);\n\tif(sum_list[ll]>right||sum_list[rr]=left&&sum_list[rr]<=right)\n\t return tree[id].max_vl[ip];\n\treturn max(query(ip,left,right,ll,mm,l),query(ip,left,right,mm+1,rr,r));\n}\nvoid insert(int ip,long long pos,long long vl,int ll,int rr,int id)\n{\n\tint l=2*id+1,r=2*id+2,mm=(ll+rr)>>1;\n\tzz(id,ll,rr);\n\tif(ll==rr)\n\t{\n\t\ttree[id].max_vl[ip]=max(tree[id].max_vl[ip],vl);\n\t return;\n }\n\tif(sum_list[mm]>1;\n\tzz(id,ll,rr);\n\tif(sum_list[ll]>right||sum_list[rr]=left&&sum_list[rr]<=right)\n\t{\n\t\ttree[id].lazy[ip]+=vl;\n\t\tzz(id,ll,rr);\n\t\treturn;\n\t}\n\tupdate(ip,left,right,vl,ll,mm,l);\n\tupdate(ip,left,right,vl,mm+1,rr,r);\n\ttree[id].max_vl[ip]=max(tree[l].max_vl[ip],tree[r].max_vl[ip]);\n}\nint main()\n{\n\tscanf(\"%d%d%lld\",&n[0],&n[1],&c);\n\tint i,j,s,p,q,nc=0,ch;\n\tcnt=0;\n\tfor(i=0;i<2;i++)\n\t\tfor(j=0;j0)\n\t\t\tch=1-x[i].ip;\n\t\tmf[i]=nc;\n\t\tsum_list[i]=sum[i];\n\t}\n\tcl[cnt-1]=0;\n\tmf[cnt]=vl[cnt]=0;\n\tsort(sum_list,sum_list+cnt);\n\tcnt_sum=0;\n\tfor(i=0;i=c)\n\t\t \t\tdp[j][i+1]=max(dp[j][i+1],pref-sum[i]+c+mv);\n\t\t }\n\t\t else\n\t\t {\n\t\t \tif(sum[i]<=-c)\n\t\t \t dp[j][i+1]=max(dp[j][i+1],pref+mv);\n\t\t\t}\n\t\t\tfor(s=0;s<2;s++)\n\t\t\t{\n \t\tlong long mcb[2];\n\t\t\t\tif(j==0)\n\t\t\t\t mcb[0]=c;\n\t\t\t\telse\n\t\t\t\t mcb[0]=-c;\n\t\t\t\tif(s==0)\n\t\t\t\t mcb[1]=c;\n\t\t\t\telse\n\t\t\t\t mcb[1]=-c;\n\t\t\t\tdc=mcb[0]-mcb[1];\n\t\t\t\tif(j==0&&s==0)\n\t\t\t\t\tdp[j][i+1]=max(dp[j][i+1],query(0,-inf,sum[i]-dc,0,cnt_sum-1,0)-sum[i]+mv);\n\t\t\t \telse if(j==1&&s==0)\n\t\t\t\t dp[j][i+1]=max(dp[j][i+1],query(1,sum[i]-dc,inf,0,cnt_sum-1,0)+mv);\n\t\t\t\telse if(j==0&&s==1)\n\t\t\t\t dp[j][i+1]=max(dp[j][i+1],query(2,-inf,sum[i]-dc,0,cnt_sum-1,0)-sum[i]+2*c+mv);\n\t\t\t\telse\n\t\t\t\t dp[j][i+1]=max(dp[j][i+1],query(3,sum[i]-dc,inf,0,cnt_sum-1,0)+mv);\n\t\t }\n \t}\n \tpref=npref;\n \tfor(q=0;q<4&&cl[i]!=0;q++)\n \t update(q,-inf,inf,cl[i],0,cnt_sum-1,0);\n\t\tif(cl[i]!=0&&mf[i]==2)\n\t\t{\n\t\t\tupdate(0,sum[i],sum[i]+2*c,cl[i],0,cnt_sum-1,0);\n\t \tupdate(1,sum[i],sum[i]+2*c,cl[i],0,cnt_sum-1,0);\t\n\t update(2,sum[i]-2*c,sum[i],cl[i],0,cnt_sum-1,0);\n\t \tupdate(3,sum[i]-2*c,sum[i],cl[i],0,cnt_sum-1,0);\n\t\t}\n\t insert(0,sum[i],dp[0][i+1]+sum[i],0,cnt_sum-1,0);\n insert(1,sum[i],dp[0][i+1],0,cnt_sum-1,0); \n \t insert(2,sum[i],dp[1][i+1]+sum[i],0,cnt_sum-1,0);\n \t insert(3,sum[i],dp[1][i+1],0,cnt_sum-1,0);\n\t}\n\tzz(0,0,cnt_sum-1);\n\tlong long ans=max(pref,max(tree[0].max_vl[1],tree[0].max_vl[3]));\n\tprintf(\"%lld\\n\",ans);\n\treturn 0;\n}\n/*\n \n*/", "lang_cluster": "C++", "compilation_error": false, "code_uid": "829cbe3f97fd9149815dabea47b068a3", "src_uid": "fa9a0d500220905af7dcbe80740da62a", "difficulty": 3000.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nconst long long inf=1e18;\nstruct xxx\n{\n\tlong long x;\n\tint flag,ip;\n\tbool operator <(const xxx &temp)const\n\t{\n\t\tif(x==temp.x)\n\t\t return flag>temp.flag;\n\t\treturn x>1;\n for(int i=0;i<6;i++)\n {\n \ttree[id].max_vl[i]=-inf;\n \ttree[id].lazy[i]=0;\n\t}\n\tif(left==right)\n\t return;\n\tbuild(left,mid,l);\n\tbuild(mid+1,right,r);\n}\nvoid zz(int id,int ll,int rr)\n{\n\tint l=2*id+1,r=2*id+2;\n\tfor(int i=0;i<6;i++)\n\t{\n\t\tif(tree[id].lazy[i]!=0&&tree[id].max_vl[i]>-inf)\n\t\t{\n\t\t\tif(ll!=rr)\n\t\t\t{\n\t\t\t\ttree[l].lazy[i]+=tree[id].lazy[i];\n\t\t\t\ttree[r].lazy[i]+=tree[id].lazy[i];\n\t\t\t}\n\t\t\ttree[id].max_vl[i]+=tree[id].lazy[i];\n\t\t}\n\t\ttree[id].lazy[i]=0;\n\t}\n}\nlong long query(int ip,long long left,long long right,int ll,int rr,int id)\n{\n\tint l=2*id+1,r=2*id+2,mm=(ll+rr)>>1;\n\tzz(id,ll,rr);\n\tif(sum_list[ll]>right||sum_list[rr]=left&&sum_list[rr]<=right)\n\t return tree[id].max_vl[ip];\n\treturn max(query(ip,left,right,ll,mm,l),query(ip,left,right,mm+1,rr,r));\n}\nvoid insert(int ip,long long pos,long long vl,int ll,int rr,int id)\n{\n\tint l=2*id+1,r=2*id+2,mm=(ll+rr)>>1;\n\tzz(id,ll,rr);\n\tif(ll==rr)\n\t{\n\t\ttree[id].max_vl[ip]=max(tree[id].max_vl[ip],vl);\n\t return;\n }\n\tif(sum_list[mm]>1;\n\tzz(id,ll,rr);\n\tif(sum_list[ll]>right||sum_list[rr]=left&&sum_list[rr]<=right)\n\t{\n\t\ttree[id].lazy[ip]+=vl;\n\t\tzz(id,ll,rr);\n\t\treturn;\n\t}\n\tupdate(ip,left,right,vl,ll,mm,l);\n\tupdate(ip,left,right,vl,mm+1,rr,r);\n\ttree[id].max_vl[ip]=max(tree[l].max_vl[ip],tree[r].max_vl[ip]);\n}\nint main()\n{\n\tscanf(\"%d%d%lld\",&n[0],&n[1],&c);\n\tint i,j,s,p,q,nc=0,ch;\n\tcnt=0;\n\tfor(i=0;i<2;i++)\n\t\tfor(j=0;j0)\n\t\t\tch=1-x[i].ip;\n\t\tmf[i]=nc;\n\t\tsum_list[i]=sum[i];\n\t}\n\tcl[cnt-1]=0;\n\tmf[cnt]=vl[cnt]=0;\n\tsort(sum_list,sum_list+cnt);\n\tcnt_sum=0;\n\tfor(i=0;i0;i--)\n\t{\n\t\tdx+=vl[i+1];\n\t\tif(abs(dx)<=c&&mf[i-1]==2)\n\t\t cm=2*cl[i-1];\n\t\telse\n\t\t cm=cl[i-1];\n\t\tsuf[i-1]=suf[i+1]+cm;\n\t}\n\tfor(i=0;i+1=c)\n\t\t \t\tdp[j][i+1]=max(dp[j][i+1],pref[i]-sum[i]+c+mv);\n\t\t }\n\t\t else\n\t\t {\n\t\t \tif(sum[i]<=-c)\n\t\t \t dp[j][i+1]=max(dp[j][i+1],pref[i]+sum[i]+c+mv);\n\t\t\t}\n\t\t//\tif(j==0&&i+1==5)\n\t\t//\t printf(\"dp=%lld\\n\",dp[j][i+1]);\n\t\t\tfor(s=0;s<2;s++)\n\t\t\t{\n \t\tlong long mcb[2];\n\t\t\t\tif(j==0)\n\t\t\t\t mcb[0]=c;\n\t\t\t\telse\n\t\t\t\t mcb[0]=-c;\n\t\t\t\tif(s==0)\n\t\t\t\t mcb[1]=c;\n\t\t\t\telse\n\t\t\t\t mcb[1]=-c;\n\t\t\t\tdc=mcb[0]-mcb[1];\n\t\t\t\tif(j==0&&s==0)\n\t\t\t\t{\n\t\t\t\t\tdp[j][i+1]=max(dp[j][i+1],query(0,-inf,sum[i]-dc,0,cnt_sum-1,0)-sum[i]);\n\t\t\t\t//\tif(j==0&&i+1==4)\n\t\t\t // printf(\"dp[j][i+1]=%lld,query=%lld\\n\",dp[j][i+1],query(0,-inf,sum[i]-dc,0));\n\t\t\t\t}\n\t\t\t \telse if(j==1&&s==0)\n\t\t\t\t dp[j][i+1]=max(dp[j][i+1],query(1,sum[i]-dc,inf,0,cnt_sum-1,0)+sum[i]+2*c);\n\t\t\t\telse if(j==0&&s==1)\n\t\t\t\t dp[j][i+1]=max(dp[j][i+1],query(2,-inf,sum[i]-dc,0,cnt_sum-1,0)-sum[i]+2*c);\n\t\t\t\telse\n\t\t\t\t dp[j][i+1]=max(dp[j][i+1],query(3,sum[i]-dc,inf,0,cnt_sum-1,0)+sum[i]);\n\t\t }\n\t\t//\tprintf(\"dp[%d][%d]=%lld,sum[i]=%lld,cl[i]=%lld,pref[i]=%lld,mv=%lld\\n\",j,i+1,dp[j][i+1],sum[i],cl[i],pref[i],mv);\n \t}\n //\tprintf(\"i+1=%d,tree[0].max_vl[0]=%lld\\n\",i+1,tree[0].max_vl[0]);\n \tfor(q=0;q<6;q++)\n \t update(q,-inf,inf,cl[i],0,cnt_sum-1,0);\n //\tzz(0,0,cnt_sum-1);\n //\tprintf(\"tree[0].max_vl[4]=%lld\\n\",tree[0].max_vl[4]);\n\t\tfor(j=0;j<2;j++)\n\t\t{\n\t\t\t\tif(cl[i]!=0)\n\t\t\t\t{\n\t\t\t\t//\tprintf(\"cl[i]=%lld\\n\",cl[i]);\n\t\t\t\t//\tzz(0);\n\t\t\t\t//\tprintf(\"i+1=%d,tree[0].max_vl[0]=%lld\\n\",i+1,tree[0].max_vl[0]);\n\t\t\t\t\t//for(q=0;q<4;q++)\n\t\t\t\t\t // update(q,-inf,inf,cl[i],0);\n\t\t\t\t if(mf[i]==2)\n\t\t\t\t {\n\t\t\t\t \tif(j==0)\n\t\t\t\t \t{\n\t\t\t\t \t\tupdate(0,sum[i],inf,cl[i],0,cnt_sum-1,0);\n\t\t\t\t \t\tupdate(1,-inf,sum[i]-2*c,cl[i],0,cnt_sum-1,0);\n\t\t\t\t \t\tupdate(4,sum[i],inf,cl[i],0,cnt_sum-1,0);\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tupdate(2,sum[i]+2*c,inf,cl[i],0,cnt_sum-1,0);\n\t\t\t\t\t\t\tupdate(3,-inf,sum[i],cl[i],0,cnt_sum-1,0);\n\t\t\t\t\t\t\tupdate(5,-inf,sum[i],cl[i],0,cnt_sum-1,0);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tzz(0,0,cnt_sum-1);\n\t\t//\t\t\tputs(\"oa\");\n\t\t\t //\tprintf(\"i+1=%d,tree[0].max_vl[0]=%lld\\n\",i+1,tree[0].max_vl[0]);\n\t \t\t}\n\t }\n\t //printf(\"orz=%lld\\n\",tree[0].max_vl[4]);\n\t for(j=0;j<2;j++)\n\t {\n\t \t\tif(j==0)\n\t \t\t{\n\t \t\t\t // insert(0,sum[i],dp[j][i])\n\t \t\t insert(0,sum[i],dp[j][i+1]+sum[i],0,cnt_sum-1,0);\n\t \t\t //if(dp[j][i+1]+sum[i]==47)\n\t \t\t // printf(\"i+1=%d\\n\",i+1);\n\t \t insert(1,sum[i],dp[j][i+1]-sum[i],0,cnt_sum-1,0);\n\t \t insert(4,sum[i],dp[j][i+1],0,cnt_sum-1,0);\n\t\t\t\t}\n\t\t\t\telse\n\t \t\t{\n\t \t\t\tinsert(2,sum[i],dp[j][i+1]+sum[i],0,cnt_sum-1,0);\n\t \t\t\tinsert(3,sum[i],dp[j][i+1]-sum[i],0,cnt_sum-1,0);\n\t \t\t\tinsert(5,sum[i],dp[j][i+1],0,cnt_sum-1,0);\n\t\t\t\t}\n\t\t\t//\tzz(0);\n\t\t//\t\t\tputs(\"oa\");\n\t\t\t // \tprintf(\"i+1=%d,tree[0].max_vl[4]=%lld\\n\",i+1,tree[0].max_vl[4]);\n\t\t\t//if(mf[i]==2&&i+1\nusingnamespacestd;\nstructtreap{\nlonglongx,y;\nlonglongadd_x,add_y;\nintheight;\ntreap*left,*right;\ntreap(longlongx,longlongy):x(x),y(y){\nheight=rand();\nadd_x=add_y=0;\nleft=right=0;\n}\nvoidpush(){\nif(!add_x&&!add_y){\nreturn;\n}\nif(left){\nleft->x+=add_x;\nleft->add_x+=add_x;\nleft->y+=add_y;\nleft->add_y+=add_y;\n}\nif(right){\nright->x+=add_x;\nright->add_x+=add_x;\nright->y+=add_y;\nright->add_y+=add_y;\n}\nadd_x=add_y=0;\n}\nvoidrecalc(){\n}\n};\n\ntreap*merge(treap*x,treap*y){\nif(!x)\nreturny;\nif(!y)\nreturnx;\nif(x->heightheight){\nx->push();\nx->right=merge(x->right,y);\nx->recalc();\nreturnx;\n}else{\ny->push();\ny->left=merge(x,y->left);\ny->recalc();\nreturny;\n}\n}\ntreap*get_left(treap*x){\nif(!x){\nreturnx;\n}\nif(!x->left){\nreturnx;\n}\nx->push();\nreturnget_left(x->left);\n}\n\ntreap*get_right(treap*x){\nif(!x){\nreturnx;\n}\nif(!x->right){\nreturnx;\n}\nx->push();\nreturnget_right(x->right);\n}\n\nvoidsplit(treap*t,treap*&l,treap*&r,constfunction&is_right){\nif(!t){\nl=r=0;\nreturn;\n}\nt->push();\nif(is_right(t)){\nsplit(t->left,l,t->left,is_right);\nr=t;\n}else{\nsplit(t->right,t->right,r,is_right);\nl=t;\n}\n}\n\nconstintN=1234567;\n\npaire[N];\nintmain(){\nintn,m;\nlonglongC;\nscanf(\"%d%d%lld\",&n,&m,&C);\nintcnt=2*(n+m);\nfor(inti=0;ix+=t;\nr->add_x+=t;\n}\nif(mask==2){\nr->y+=t;\nr->add_y+=t;\n}\nif(mask==3){\nbig_add+=t;\ntreap*t1,*t2,*t3;\nsplit(r,t1,t2,[&C](treap*t){return(t->x-t->y>=-C);});\nsplit(t2,t2,t3,[&C](treap*t){return(t->x-t->y>=C+1);});\nlonglongx3=-C,y3=0;\nlonglongx4=0,y4=-C;\nif(t1){\ntreap*tmp=get_right(t1);\nx3=tmp->x;\ny3=tmp->x+C;\n}\nif(t3){\ntreap*tmp=get_left(t3);\nx4=tmp->y+C;\ny4=tmp->y;\n}\nif(x3>x4||y3>y4){\nif(!t2){\nt2=newtreap(x3,y3);\n}else{\ntreap*tmp=get_left(t2);\nif(x3>tmp->x||y3>tmp->y){\nt2=merge(newtreap(x3,y3),t2);\n}\n}\n}\nif(x4>x3||y4>y3||(x3==x4&&y3==y4)){\nif(!t2){\nt2=newtreap(x4,y4);\n}else{\ntreap*tmp=get_right(t2);\nif(x4>tmp->x||y4>tmp->y){\nt2=merge(t2,newtreap(x4,y4));\n}\n}\n}\nt2->x+=t;\nt2->add_x+=t;\nt2->y+=t;\nt2->add_y+=t;\ntreap*t2l=get_left(t2);\ntreap*t2r=get_right(t2);\ntreap*t4;\nsplit(t1,t1,t4,[&t2l](treap*t){return(t->y<=t2l->y);});\nsplit(t3,t4,t3,[&t2r](treap*t){return(t->x>t2r->x);});\nr=merge(t1,merge(t2,t3));\n}\n}\ncout<<(big_add+(get_right(r))->x)<\n#include \n#include \n#include \nusing namespace std;\n\ntemplate \nT pow(T a, T e, T mod) {\n\tif(!e) return 1;\n\tT x = pow(a, e/2, mod);\n\tx = x * x % mod;\n\treturn (e&1) ? x * a % mod : x;\n}\n\ntemplate \nT pow(T a, exp_t e) {\n\tif(!e) return 1;\n\tT x = pow(a, e/2);\n\tx = multiply(x, x);\n\treturn (e&1) ? multiply(x, a) : x;\n}\n\ntemplate \nCRT_t CRT(const CRT_t * rem, const CRT_t * p_v, const int * p_e, const int p_n) {\n\t// return e: e % p_v[i]**p_e[i] == rem[i] for 0 <= i < p_n\n\tCRT_t ret = 0, mod = 1;\n\tfor(int i = 0; i < p_n; i++) for(int j = 0; j < p_e[i]; j++) mod *= p_v[i];\n\t// e == (sum rem[i] * c[i]) % prod p_v[i]**p_e[i]\n\tfor(int i = 0; i < p_n; i++) {\n\t\t// pr[i] == prod p_v[j]**p_e[j] for j != i\n\t\t// c[i] == pr[i] * (inverse of pr[i] modulo p_v[i]**p_e[i]) == pr[i] * inv[i]\n\t\tCRT_t pr = mod, pw = 1;\n\t\tfor(int j = 0; j < p_e[i]; j++) pr /= p_v[i], pw *= p_v[i];\n\t\tCRT_t inv = pow(pr % pw, pw - pw / p_v[i] - 1, pw);\n\t\tCRT_t add = inv * rem[i] % pw * pr;\n\t\tif(add >= mod-ret) ret += add-mod;\n\t\telse ret += add;\n\t}\n\treturn ret;\n}\n\ntemplate \nexp_t BSGS(const BSGS_t a, const BSGS_t b, const exp_t order) {\n\texp_t sqrt = 1;\n\twhile(sqrt*sqrt < order) sqrt++;\n\tstatic pair try_small[20000];\n\tstatic pair try_large[20000];\n\tBSGS_t cur = 1;\n\tfor(BSGS_t i = 0; i < sqrt; i++) {\n\t\ttry_small[i] = {cur, i};\n\t\tcur = multiply(cur, a);\n\t}\n\tcur = b;\n\tBSGS_t a_pw = pow(a, order-sqrt);\n\tfor(exp_t i = 0; i < sqrt; i++) {\n\t\ttry_large[i] = {cur, i};\n\t\tcur = multiply(cur, a_pw);\n\t}\n\tsort(try_small, try_small+sqrt);\n\tsort(try_large, try_large+sqrt);\n\tfor(exp_t i = 0, j = 0; i < sqrt; i++) {\n\t\twhile(j < sqrt && try_large[j].first < try_small[i].first) j++;\n\t\tif(j == sqrt) return exp_t(-1);\n\t\tif(try_large[j].first == try_small[i].first)\n\t\t\treturn try_large[j].second * sqrt + try_small[i].second;\n\t}\n\treturn exp_t(-1);\n}\n\ntemplate \nexp_t PohligHellman_pw(const PH_t g, const PH_t a, const exp_t p_v, const int p_e) {\n\t// return e: g**e == a, or -1 if no such e exists\n\texp_t ret = 0, pw_down = 1, pw_up = 1;\n\tfor(int k = 0; k < p_e-1; k++) pw_up *= p_v;\n\texp_t pw = pw_up * p_v;\n\tPH_t g_pw = pow(g, pw_up);\n\tfor(int k = 0; k < p_e; k++) {\n\t\tPH_t h = pow(multiply(pow(g, pw-ret), a), pw_up);\n\t\texp_t d = BSGS(g_pw, h, p_v);\n\t\tif(d == exp_t(-1)) return exp_t(-1);\n\t\tret += pw_down * d;\n\t\tpw_down *= p_v, pw_up /= p_v;\n\t}\n\treturn ret;\n}\n\ntemplate \nexp_t PohligHellman(const PH_t g, const PH_t a, const exp_t * p_v, const int * p_e, const int p_n) {\n\t// return e: g**e == a, or -1 if no such e exists\n\tstatic exp_t e_rem[100];\n\texp_t order = 1;\n\tfor(int i = 0; i < p_n; i++) for(int j = 0; j < p_e[i]; j++) order *= p_v[i];\n\tfor(int i = 0; i < p_n; i++) {\n\t\texp_t pw = 1;\n\t\tfor(int j = 0; j < p_e[i]; j++) pw *= p_v[i];\n\t\tPH_t g_pow = pow(g, order/pw);\n\t\tPH_t a_pow = pow(a, order/pw);\n\t\te_rem[i] = PohligHellman_pw(g_pow, a_pow, p_v[i], p_e[i]);\n\t\tif(e_rem[i] == exp_t(-1)) return exp_t(-1);\n\t}\n\treturn CRT(e_rem, p_v, p_e, p_n);\n}\n\ntemplate \nPH_t DiscreteLog(const PH_t a, const PH_t b, const exp_t order) {\n\t// return e: a**e == b, or -1 if no such e exists\n\t// factorise assuming all prime factors are small\n\tstatic exp_t p_v[100];\n\tstatic int p_e[100];\n\tint p_n = 0;\n\texp_t o = order;\n\tfor(exp_t i = 2; i*i <= o; i++) if(o%i == 0) {\n\t\tp_v[p_n] = i;\n\t\tp_e[p_n] = 0;\n\t\twhile(o%i == 0) p_e[p_n]++, o /= i;\n\t\tp_n++;\n\t}\n\tif(o > 1) {\n\t\tp_v[p_n] = o;\n\t\tp_e[p_n] = 1;\n\t\tp_n++;\n\t}\n\t// try random generators\n mt19937_64 rng(a*b);\n\tPH_t g = 0;\n\twhile(true) {\n\t\tPH_t try_g = g ? g : (rng() % order);\n\t\tif(!try_g) continue;\n\t\texp_t e_a = PohligHellman(try_g, a, p_v, p_e, p_n);\n\t\tif(e_a == exp_t(-1)) {\n\t\t\ttry_g = 0;\n\t\t\tcontinue;\n\t\t}\n\t\texp_t e_b = PohligHellman(try_g, b, p_v, p_e, p_n);\n\t\tif(e_b == exp_t(-1)) {\n\t\t\ttry_g = 0;\n\t\t\tcontinue;\n\t\t}\n\t\tg = try_g;\n\t\t// e_a * e == e_b + K * order\n\t\tstatic exp_t e_rem[100];\n\t\tfor(int i = 0; i < p_n; i++) {\n\t\t\texp_t pw = 1;\n\t\t\tfor(int j = 0; j < p_e[i]; j++) pw *= p_v[i];\n\t\t\texp_t e_a_rem = e_a % pw, e_b_rem = e_b % pw;\n\t\t\twhile(pw > 1 && e_a_rem % p_v[i] == 0) {\n\t\t\t\tif(e_b_rem % p_v[i] != 0) return -1;\n\t\t\t\tpw /= p_v[i], e_a_rem /= p_v[i], e_b_rem /= p_v[i];\n\t\t\t}\n\t\t\t// e_a_rem * e == e_b_rem + K * pw\n\t\t\te_rem[i] = (pw != 1) ? e_b_rem * pow(e_a_rem, pw-pw/p_v[i]-1, pw) % pw : 0;\n\t\t}\n\t\treturn CRT(e_rem, p_v, p_e, p_n);\n\t}\n}\n\nusing cat = unsigned long long;\n\ncat multiply_nocache(cat a, cat b);\n\ncat cache[64][64];\nchar cache_used[64][64];\n\ncat multiply_pw2(int a, int b) { // < 64\n\ta &= 63, b &= 63;\n\tif(cache_used[a][b]) return cache[a][b];\n\tif(a == 0 || b == 0) {\n\t\tcache_used[a][b] = 1;\n\t\tcache[a][b] = (1ULL<= pw && b >= pw) {\n\t\tcache_used[a][b] = 1;\n\t\tcache[a][b] = multiply_nocache(3ULL<<(pw-1), multiply_pw2(a^pw, b^pw));\n\t\treturn cache[a][b];\n\t}\n\tif(a >= pw) {\n\t\tcache_used[a][b] = 1;\n\t\tcache[a][b] = multiply_pw2(a^pw, b) << pw;\n\t\treturn cache[a][b];\n\t}\n\tif(b >= pw) {\n\t\tcache_used[a][b] = 1;\n\t\tcache[a][b] = multiply_pw2(a, b^pw) << pw;\n\t\treturn cache[a][b];\n\t}\n\tassert(false);\n\treturn -1;\n}\n\ncat multiply_nocache(cat a, cat b) {\n\tcat ret = 0;\n\tfor(int i = 0; a; i++, a /= 2) if(a&1) {\n\t\tcat b_c = b;\n\t\tfor(int j = 0; b_c; j++, b_c /= 2) if(b_c&1)\n\t\t\tret ^= multiply_pw2(i, j);\n\t}\n\treturn ret;\n}\n\ncat __attribute__((optimize(\"-Ofast,-funroll-loops\"))) __attribute__((target(\"arch=avx2\"))) multiply(cat a, cat b) {\n\tcat ret = 0;\n\tcat x[64];\n\tfor(int j = 0; j != 64; j++, b /= 2) x[j] = -(b&1);\n\tfor(int i = 0; a; i++, a /= 2) if(a&1) {\n\t\tcat y[64];\n\t\tcat * __restrict cache_ptr = &(cache[i][0]);\n\t\tfor(int j = 0; j != 64; j++) y[j] = x[j] & cache_ptr[j];\n\t\tfor(int j = 0; j != 64; j++) ret ^= y[j];\n\t}\n\treturn ret;\n}\n\nint main() {\n\tfor(int i = 0; i < 64; i++) for(int j = 0; j < 64; j++) multiply_nocache(1ULL<> T;\n\twhile(T--) {\n\t\tcat a, b;\n\t\tcin >> a >> b;\n\t\tcat ans = DiscreteLog(a, b, 0xFFFFFFFFFFFFFFFF);\n\t\tif(ans+1 == 0) cout << \"-1\\n\";\n\t\telse cout << ans << \"\\n\";\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f3092bbc5335013d41834ba052c7f7f4", "src_uid": "54b41c5184c27d1373ec05775bc43b50", "difficulty": 3400.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\ntemplate \nT pow(T a, T e, T mod) {\n\tif(!e) return 1;\n\tT x = pow(a, e/2, mod);\n\tx = x * x % mod;\n\treturn (e&1) ? x * a % mod : x;\n}\n\ntemplate \nT pow(T a, exp_t e) {\n\tif(!e) return 1;\n\tT x = pow(a, e/2);\n\tx = multiply(x, x);\n\treturn (e&1) ? multiply(x, a) : x;\n}\n\ntemplate \nCRT_t CRT(const CRT_t * rem, const CRT_t * p_v, const int * p_e, const int p_n) {\n\t// return e: e % p_v[i]**p_e[i] == rem[i] for 0 <= i < p_n\n\tCRT_t ret = 0, mod = 1;\n\tfor(int i = 0; i < p_n; i++) for(int j = 0; j < p_e[i]; j++) mod *= p_v[i];\n\t// e == (sum rem[i] * c[i]) % prod p_v[i]**p_e[i]\n\tfor(int i = 0; i < p_n; i++) {\n\t\t// pr[i] == prod p_v[j]**p_e[j] for j != i\n\t\t// c[i] == pr[i] * (inverse of pr[i] modulo p_v[i]**p_e[i]) == pr[i] * inv[i]\n\t\tCRT_t pr = mod, pw = 1;\n\t\tfor(int j = 0; j < p_e[i]; j++) pr /= p_v[i], pw *= p_v[i];\n\t\tCRT_t inv = pow(pr % pw, pw - pw / p_v[i] - 1, pw);\n\t\tCRT_t add = inv * rem[i] % pw * pr;\n\t\tif(add >= mod-ret) ret += add-mod;\n\t\telse ret += add;\n\t}\n\treturn ret;\n}\n\ntemplate \nexp_t BSGS(const BSGS_t a, const BSGS_t b, const exp_t order) {\n\texp_t sqrt = 1;\n\twhile(sqrt*sqrt < order) sqrt++;\n\tstatic pair try_small[20000];\n\tstatic pair try_large[20000];\n\tBSGS_t cur = 1;\n\tfor(BSGS_t i = 0; i < sqrt; i++) {\n\t\ttry_small[i] = {cur, i};\n\t\tcur = multiply(cur, a);\n\t}\n\tcur = b;\n\tBSGS_t a_pw = pow(a, order-sqrt);\n\tfor(exp_t i = 0; i < sqrt; i++) {\n\t\ttry_large[i] = {cur, i};\n\t\tcur = multiply(cur, a_pw);\n\t}\n\tsort(try_small, try_small+sqrt);\n\tsort(try_large, try_large+sqrt);\n\tfor(exp_t i = 0, j = 0; i < sqrt; i++) {\n\t\twhile(j < sqrt && try_large[j].first < try_small[i].first) j++;\n\t\tif(j == sqrt) return exp_t(-1);\n\t\tif(try_large[j].first == try_small[i].first)\n\t\t\treturn try_large[j].second * sqrt + try_small[i].second;\n\t}\n\treturn exp_t(-1);\n}\n\ntemplate \nexp_t PohligHellman_pw(const PH_t g, const PH_t a, const exp_t p_v, const int p_e) {\n\t// return e: g**e == a, or -1 if no such e exists\n\texp_t ret = 0, pw_down = 1, pw_up = 1;\n\tfor(int k = 0; k < p_e-1; k++) pw_up *= p_v;\n\texp_t pw = pw_up * p_v;\n\tPH_t g_pw = pow(g, pw_up);\n\tfor(int k = 0; k < p_e; k++) {\n\t\tPH_t h = pow(multiply(pow(g, pw-ret), a), pw_up);\n\t\texp_t d = BSGS(g_pw, h, p_v);\n\t\tif(d == exp_t(-1)) return exp_t(-1);\n\t\tret += pw_down * d;\n\t\tpw_down *= p_v, pw_up /= p_v;\n\t}\n\treturn ret;\n}\n\ntemplate \nexp_t PohligHellman(const PH_t g, const PH_t a, const exp_t * p_v, const int * p_e, const int p_n) {\n\t// return e: g**e == a, or -1 if no such e exists\n\tstatic exp_t e_rem[100];\n\texp_t order = 1;\n\tfor(int i = 0; i < p_n; i++) for(int j = 0; j < p_e[i]; j++) order *= p_v[i];\n\tfor(int i = 0; i < p_n; i++) {\n\t\texp_t pw = 1;\n\t\tfor(int j = 0; j < p_e[i]; j++) pw *= p_v[i];\n\t\tPH_t g_pow = pow(g, order/pw);\n\t\tPH_t a_pow = pow(a, order/pw);\n\t\te_rem[i] = PohligHellman_pw(g_pow, a_pow, p_v[i], p_e[i]);\n\t\tif(e_rem[i] == exp_t(-1)) return exp_t(-1);\n\t}\n\treturn CRT(e_rem, p_v, p_e, p_n);\n}\n\ntemplate \nPH_t DiscreteLog(const PH_t a, const PH_t b, const exp_t order) {\n\t// return e: a**e == b, or -1 if no such e exists\n\t// factorise assuming all prime factors are small\n\tstatic exp_t p_v[100];\n\tstatic int p_e[100];\n\tint p_n = 0;\n\texp_t o = order;\n\tfor(exp_t i = 2; i*i <= o; i++) if(o%i == 0) {\n\t\tp_v[p_n] = i;\n\t\tp_e[p_n] = 0;\n\t\twhile(o%i == 0) p_e[p_n]++, o /= i;\n\t\tp_n++;\n\t}\n\tif(o > 1) {\n\t\tp_v[p_n] = o;\n\t\tp_e[p_n] = 1;\n\t\tp_n++;\n\t}\n\t// try random generators\n mt19937_64 rng(a*b);\n\tPH_t g = 0;\n\twhile(true) {\n\t\tPH_t try_g = g ? g : (rng() % order);\n\t\tif(!try_g) continue;\n\t\texp_t e_a = PohligHellman(try_g, a, p_v, p_e, p_n);\n\t\tif(e_a == exp_t(-1)) {\n\t\t\ttry_g = 0;\n\t\t\tcontinue;\n\t\t}\n\t\texp_t e_b = PohligHellman(try_g, b, p_v, p_e, p_n);\n\t\tif(e_b == exp_t(-1)) {\n\t\t\ttry_g = 0;\n\t\t\tcontinue;\n\t\t}\n\t\tg = try_g;\n\t\t// e_a * e == e_b + K * order\n\t\tstatic exp_t e_rem[100];\n\t\tfor(int i = 0; i < p_n; i++) {\n\t\t\texp_t pw = 1;\n\t\t\tfor(int j = 0; j < p_e[i]; j++) pw *= p_v[i];\n\t\t\texp_t e_a_rem = e_a % pw, e_b_rem = e_b % pw;\n\t\t\twhile(pw > 1 && e_a_rem % p_v[i] == 0) {\n\t\t\t\tif(e_b_rem % p_v[i] != 0) return -1;\n\t\t\t\tpw /= p_v[i], e_a_rem /= p_v[i], e_b_rem /= p_v[i];\n\t\t\t}\n\t\t\t// e_a_rem * e == e_b_rem + K * pw\n\t\t\te_rem[i] = (pw != 1) ? e_b_rem * pow(e_a_rem, pw-pw/p_v[i]-1, pw) % pw : 0;\n\t\t}\n\t\treturn CRT(e_rem, p_v, p_e, p_n);\n\t}\n}\n\nusing cat = unsigned long long;\n\ncat multiply_nocache(cat a, cat b);\n\ncat cache[64][64];\nchar cache_used[64][64];\n\ncat multiply_pw2(int a, int b) { // < 64\n\ta &= 63, b &= 63;\n\tif(cache_used[a][b]) return cache[a][b];\n\tif(a == 0 || b == 0) {\n\t\tcache_used[a][b] = 1;\n\t\tcache[a][b] = (1ULL<= pw && b >= pw) {\n\t\tcache_used[a][b] = 1;\n\t\tcache[a][b] = multiply_nocache(3ULL<<(pw-1), multiply_pw2(a^pw, b^pw));\n\t\treturn cache[a][b];\n\t}\n\tif(a >= pw) {\n\t\tcache_used[a][b] = 1;\n\t\tcache[a][b] = multiply_pw2(a^pw, b) << pw;\n\t\treturn cache[a][b];\n\t}\n\tif(b >= pw) {\n\t\tcache_used[a][b] = 1;\n\t\tcache[a][b] = multiply_pw2(a, b^pw) << pw;\n\t\treturn cache[a][b];\n\t}\n\tassert(false);\n\treturn -1;\n}\n\ncat multiply_nocache(cat a, cat b) {\n\tcat ret = 0;\n\tfor(int i = 0; a; i++, a /= 2) if(a&1) {\n\t\tcat b_c = b;\n\t\tfor(int j = 0; b_c; j++, b_c /= 2) if(b_c&1)\n\t\t\tret ^= multiply_pw2(i, j);\n\t}\n\treturn ret;\n}\n\ncat __attribute__((optimize(\"-Ofast,-funroll-loops\"))) __attribute__((target(\"arch=core-avx2\"))) multiply(cat a, cat b) {\n\tcat ret = 0;\n\tfor(int i = 0; a; i++, a /= 2) if(a&1) {\n\t\tcat b_c = b;\n\t\tcat x[64];\n\t\tfor(int j = 0; j != 64; j++, b_c /= 2) x[j] = -(b_c&1);\n\t\tcat y[64];\n\t\tcat * __restrict cache_ptr = &(cache[i][0]);\n\t\tfor(int j = 0; j != 64; j++) y[j] = x[j] & cache_ptr[j];\n\t\tfor(int j = 0; j != 64; j++) ret ^= y[j];\n\t}\n\treturn ret;\n}\n\nint main() {\n\tfor(int i = 0; i < 64; i++) for(int j = 0; j < 64; j++) multiply_nocache(1ULL<> T;\n\twhile(T--) {\n\t\tcin >> a >> b;\n\t\tcat ans = DiscreteLog(a, b, 0xFFFFFFFFFFFFFFFF);\n\t\tif(ans+1 == 0) cout << \"-1\\n\";\n\t\telse cout << ans << \"\\n\";\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6f05cf7227c411a836a771595a154171", "src_uid": "54b41c5184c27d1373ec05775bc43b50", "difficulty": 3400.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define rep(i,l,r) for(int i=(l);i<=(r);++i)\n#define per(i,r,l) for(int i=(r);i>=(l);--i)\nusing namespace std;\ntypedef unsigned long long ull;\nint pr[]={3,5,17,257,641,65537,6700417};\null mul[64][64],x,y,f[7];int fxk[233];\nunordered_map F;\nvoid exgcd(ull a,ull b,ull &x,ull &y){\n\tif(!b){x=1,y=0;return;}\n\texgcd(b,a%b,y,x);y-=a/b*x;\n}\null calc(ull,ull);\null smul(ull x,ull y){\n\tull ans=0;\n\tfor(;x;x-=x&(-x)) for(ull z=y;z;z-=z&(-z)) ans^=calc(x&(-x),z&(-z));\n\treturn ans;\n}\null calc(ull x,ull y){\n\tif(x==1||y==1) return x*y;\n\tif(x=pw&&y>=pw) return smul(pw^(pw>>1),calc(x/pw,y/pw));\n\treturn calc(x/pw,y)*pw;\n}\null Mul(int x,ull y,int D=63){\n\tull ans=0;\n\trep(j,0,D) if(y&(1ull<>w,b1=y>>w,a2=x&((1ull<>=1,a=qMul(a,a))\n\t\tif(b&1) ans=qMul(ans,a);\n\treturn ans;\n}\nunordered_map z;\nvoid solve(ull a,ull b){\n\t__int128 ans=0;ull c=-1;\n\trep(i,0,6){\n\t\tz.clear();ull w=pw(a,c/pr[i]),g=1,bd=pw(b,c/pr[i]);int cmz=sqrt(pr[i]+0.5);\n\t\trep(j,0,cmz-1) z[g]=min(z[g],j),g=qMul(g,w);\n\t\tw=pw(a,c-c/pr[i]*cmz),g=1;bool flag=0;\n\t\trep(j,0,pr[i]/cmz){\n\t\t\tull k=qMul(g,bd);\n\t\t\tif(z.count(k)){flag=1;ans+=(__int128)(z[k]+j*cmz)*f[i];break;}\n\t\t\tg=qMul(g,w);\n\t\t}\n\t\tif(!flag){puts(\"-1\");return;}\n\t}\n\tans%=c;printf(\"%llu\\n\",(ull)ans);\n}\null inv(ull a,ull p){\n\tull x,y;exgcd(a,p,x,y);\n\treturn x>p?x+p:x;\n}\nint main(){\n\tint T;scanf(\"%d\",&T);\n\trep(i,0,63) F[1ull<>1]+1;\n\t//printf(\"%lld\\n\",calc(2,4));\n\trep(i,0,63) rep(j,0,63) mul[i][j]=calc(1ull<\n#include \n#include \n#include \nusing namespace std;\n\ntemplate \nT pow(T a, T e, T mod) {\n\tif(!e) return 1;\n\tT x = pow(a, e/2, mod);\n\tx = x * x % mod;\n\treturn (e&1) ? x * a % mod : x;\n}\n\ntemplate \nT pow(T a, exp_t e) {\n\tif(!e) return 1;\n\tT x = pow(a, e/2);\n\tx = multiply(x, x);\n\treturn (e&1) ? multiply(x, a) : x;\n}\n\ntemplate \nCRT_t CRT(const CRT_t * rem, const CRT_t * p_v, const int * p_e, const int p_n) {\n\t// return e: e % p_v[i]**p_e[i] == rem[i] for 0 <= i < p_n\n\tCRT_t ret = 0, mod = 1;\n\tfor(int i = 0; i < p_n; i++) for(int j = 0; j < p_e[i]; j++) mod *= p_v[i];\n\t// e == (sum rem[i] * c[i]) % prod p_v[i]**p_e[i]\n\tfor(int i = 0; i < p_n; i++) {\n\t\t// pr[i] == prod p_v[j]**p_e[j] for j != i\n\t\t// c[i] == pr[i] * (inverse of pr[i] modulo p_v[i]**p_e[i]) == pr[i] * inv[i]\n\t\tCRT_t pr = mod, pw = 1;\n\t\tfor(int j = 0; j < p_e[i]; j++) pr /= p_v[i], pw *= p_v[i];\n\t\tCRT_t inv = pow(pr % pw, pw - pw / p_v[i] - 1, pw);\n\t\tCRT_t add = inv * rem[i] % pw * pr;\n\t\tif(add >= mod-ret) ret += add-mod;\n\t\telse ret += add;\n\t}\n\treturn ret;\n}\n\ntemplate \nexp_t BSGS(const BSGS_t a, const BSGS_t b, const exp_t order) {\n\texp_t sqrt = 1;\n\twhile(sqrt*sqrt < order) sqrt++;\n\tstatic pair try_small[20000];\n\tstatic pair try_large[20000];\n\tBSGS_t cur = 1;\n\tfor(BSGS_t i = 0; i < sqrt; i++) {\n\t\ttry_small[i] = {cur, i};\n\t\tcur = multiply(cur, a);\n\t}\n\tcur = b;\n\tBSGS_t a_pw = pow(a, order-sqrt);\n\tfor(exp_t i = 0; i < sqrt; i++) {\n\t\ttry_large[i] = {cur, i};\n\t\tcur = multiply(cur, a_pw);\n\t}\n\tsort(try_small, try_small+sqrt);\n\tsort(try_large, try_large+sqrt);\n\tfor(exp_t i = 0, j = 0; i < sqrt; i++) {\n\t\twhile(j < sqrt && try_large[j].first < try_small[i].first) j++;\n\t\tif(j == sqrt) return exp_t(-1);\n\t\tif(try_large[j].first == try_small[i].first)\n\t\t\treturn try_large[j].second * sqrt + try_small[i].second;\n\t}\n\treturn exp_t(-1);\n}\n\ntemplate \nexp_t PohligHellman_pw(const PH_t g, const PH_t a, const exp_t p_v, const int p_e) {\n\t// return e: g**e == a, or -1 if no such e exists\n\texp_t ret = 0, pw_down = 1, pw_up = 1;\n\tfor(int k = 0; k < p_e-1; k++) pw_up *= p_v;\n\texp_t pw = pw_up * p_v;\n\tPH_t g_pw = pow(g, pw_up);\n\tfor(int k = 0; k < p_e; k++) {\n\t\tPH_t h = pow(multiply(pow(g, pw-ret), a), pw_up);\n\t\texp_t d = BSGS(g_pw, h, p_v);\n\t\tif(d == exp_t(-1)) return exp_t(-1);\n\t\tret += pw_down * d;\n\t\tpw_down *= p_v, pw_up /= p_v;\n\t}\n\treturn ret;\n}\n\ntemplate \nexp_t PohligHellman(const PH_t g, const PH_t a, const exp_t * p_v, const int * p_e, const int p_n) {\n\t// return e: g**e == a, or -1 if no such e exists\n\tstatic exp_t e_rem[100];\n\texp_t order = 1;\n\tfor(int i = 0; i < p_n; i++) for(int j = 0; j < p_e[i]; j++) order *= p_v[i];\n\tfor(int i = 0; i < p_n; i++) {\n\t\texp_t pw = 1;\n\t\tfor(int j = 0; j < p_e[i]; j++) pw *= p_v[i];\n\t\tPH_t g_pow = pow(g, order/pw);\n\t\tPH_t a_pow = pow(a, order/pw);\n\t\te_rem[i] = PohligHellman_pw(g_pow, a_pow, p_v[i], p_e[i]);\n\t\tif(e_rem[i] == exp_t(-1)) return exp_t(-1);\n\t}\n\treturn CRT(e_rem, p_v, p_e, p_n);\n}\n\ntemplate \nPH_t DiscreteLog(const PH_t a, const PH_t b, const exp_t order) {\n\t// return e: a**e == b, or -1 if no such e exists\n\t// factorise assuming all prime factors are small\n\tstatic exp_t p_v[100];\n\tstatic int p_e[100];\n\tint p_n = 0;\n\texp_t o = order;\n\tfor(exp_t i = 2; i*i <= o; i++) if(o%i == 0) {\n\t\tp_v[p_n] = i;\n\t\tp_e[p_n] = 0;\n\t\twhile(o%i == 0) p_e[p_n]++, o /= i;\n\t\tp_n++;\n\t}\n\tif(o > 1) {\n\t\tp_v[p_n] = o;\n\t\tp_e[p_n] = 1;\n\t\tp_n++;\n\t}\n\t// try random generators\n mt19937_64 rng(a*b);\n\tPH_t g = 0;\n\twhile(true) {\n\t\tPH_t try_g = g ? g : (rng() % order);\n\t\tif(!try_g) continue;\n\t\texp_t e_a = PohligHellman(try_g, a, p_v, p_e, p_n);\n\t\tif(e_a == exp_t(-1)) {\n\t\t\ttry_g = 0;\n\t\t\tcontinue;\n\t\t}\n\t\texp_t e_b = PohligHellman(try_g, b, p_v, p_e, p_n);\n\t\tif(e_b == exp_t(-1)) {\n\t\t\ttry_g = 0;\n\t\t\tcontinue;\n\t\t}\n\t\tg = try_g;\n\t\t// e_a * e == e_b + K * order\n\t\tstatic exp_t e_rem[100];\n\t\tfor(int i = 0; i < p_n; i++) {\n\t\t\texp_t pw = 1;\n\t\t\tfor(int j = 0; j < p_e[i]; j++) pw *= p_v[i];\n\t\t\texp_t e_a_rem = e_a % pw, e_b_rem = e_b % pw;\n\t\t\twhile(pw > 1 && e_a_rem % p_v[i] == 0) {\n\t\t\t\tif(e_b_rem % p_v[i] != 0) return -1;\n\t\t\t\tpw /= p_v[i], e_a_rem /= p_v[i], e_b_rem /= p_v[i];\n\t\t\t}\n\t\t\t// e_a_rem * e == e_b_rem + K * pw\n\t\t\te_rem[i] = (pw != 1) ? e_b_rem * pow(e_a_rem, pw-pw/p_v[i]-1, pw) % pw : 0;\n\t\t}\n\t\treturn CRT(e_rem, p_v, p_e, p_n);\n\t}\n}\n\nusing cat = unsigned long long;\n\ncat multiply_nocache(cat a, cat b);\n\ncat cache[64][64];\nchar cache_used[64][64];\n\ncat multiply_pw2(int a, int b) { // < 64\n\ta &= 63, b &= 63;\n\tif(cache_used[a][b]) return cache[a][b];\n\tif(a == 0 || b == 0) {\n\t\tcache_used[a][b] = 1;\n\t\tcache[a][b] = (1ULL<= pw && b >= pw) {\n\t\tcache_used[a][b] = 1;\n\t\tcache[a][b] = multiply_nocache(3ULL<<(pw-1), multiply_pw2(a^pw, b^pw));\n\t\treturn cache[a][b];\n\t}\n\tif(a >= pw) {\n\t\tcache_used[a][b] = 1;\n\t\tcache[a][b] = multiply_pw2(a^pw, b) << pw;\n\t\treturn cache[a][b];\n\t}\n\tif(b >= pw) {\n\t\tcache_used[a][b] = 1;\n\t\tcache[a][b] = multiply_pw2(a, b^pw) << pw;\n\t\treturn cache[a][b];\n\t}\n\tassert(false);\n\treturn -1;\n}\n\ncat multiply_nocache(cat a, cat b) {\n\tcat ret = 0;\n\tfor(int i = 0; a; i++, a /= 2) if(a&1) {\n\t\tcat b_c = b;\n\t\tfor(int j = 0; b_c; j++, b_c /= 2) if(b_c&1)\n\t\t\tret ^= multiply_pw2(i, j);\n\t}\n\treturn ret;\n}\n\ncat __attribute__((optimize(\"-Ofast,-funroll-loops\"))) __attribute__((target(\"arch=core-avx2\"))) #include \n#include \n#include \n#include \nusing namespace std;\n\ntemplate \nT pow(T a, T e, T mod) {\n\tif(!e) return 1;\n\tT x = pow(a, e/2, mod);\n\tx = x * x % mod;\n\treturn (e&1) ? x * a % mod : x;\n}\n\ntemplate \nT pow(T a, exp_t e) {\n\tif(!e) return 1;\n\tT x = pow(a, e/2);\n\tx = multiply(x, x);\n\treturn (e&1) ? multiply(x, a) : x;\n}\n\ntemplate \nCRT_t CRT(const CRT_t * rem, const CRT_t * p_v, const int * p_e, const int p_n) {\n\t// return e: e % p_v[i]**p_e[i] == rem[i] for 0 <= i < p_n\n\tCRT_t ret = 0, mod = 1;\n\tfor(int i = 0; i < p_n; i++) for(int j = 0; j < p_e[i]; j++) mod *= p_v[i];\n\t// e == (sum rem[i] * c[i]) % prod p_v[i]**p_e[i]\n\tfor(int i = 0; i < p_n; i++) {\n\t\t// pr[i] == prod p_v[j]**p_e[j] for j != i\n\t\t// c[i] == pr[i] * (inverse of pr[i] modulo p_v[i]**p_e[i]) == pr[i] * inv[i]\n\t\tCRT_t pr = mod, pw = 1;\n\t\tfor(int j = 0; j < p_e[i]; j++) pr /= p_v[i], pw *= p_v[i];\n\t\tCRT_t inv = pow(pr % pw, pw - pw / p_v[i] - 1, pw);\n\t\tCRT_t add = inv * rem[i] % pw * pr;\n\t\tif(add >= mod-ret) ret += add-mod;\n\t\telse ret += add;\n\t}\n\treturn ret;\n}\n\ntemplate \nexp_t BSGS(const BSGS_t a, const BSGS_t b, const exp_t order) {\n\texp_t sqrt = 1;\n\twhile(sqrt*sqrt < order) sqrt++;\n\tstatic pair try_small[20000];\n\tstatic pair try_large[20000];\n\tBSGS_t cur = 1;\n\tfor(BSGS_t i = 0; i < sqrt; i++) {\n\t\ttry_small[i] = {cur, i};\n\t\tcur = multiply(cur, a);\n\t}\n\tcur = b;\n\tBSGS_t a_pw = pow(a, order-sqrt);\n\tfor(exp_t i = 0; i < sqrt; i++) {\n\t\ttry_large[i] = {cur, i};\n\t\tcur = multiply(cur, a_pw);\n\t}\n\tsort(try_small, try_small+sqrt);\n\tsort(try_large, try_large+sqrt);\n\tfor(exp_t i = 0, j = 0; i < sqrt; i++) {\n\t\twhile(j < sqrt && try_large[j].first < try_small[i].first) j++;\n\t\tif(j == sqrt) return exp_t(-1);\n\t\tif(try_large[j].first == try_small[i].first)\n\t\t\treturn try_large[j].second * sqrt + try_small[i].second;\n\t}\n\treturn exp_t(-1);\n}\n\ntemplate \nexp_t PohligHellman_pw(const PH_t g, const PH_t a, const exp_t p_v, const int p_e) {\n\t// return e: g**e == a, or -1 if no such e exists\n\texp_t ret = 0, pw_down = 1, pw_up = 1;\n\tfor(int k = 0; k < p_e-1; k++) pw_up *= p_v;\n\texp_t pw = pw_up * p_v;\n\tPH_t g_pw = pow(g, pw_up);\n\tfor(int k = 0; k < p_e; k++) {\n\t\tPH_t h = pow(multiply(pow(g, pw-ret), a), pw_up);\n\t\texp_t d = BSGS(g_pw, h, p_v);\n\t\tif(d == exp_t(-1)) return exp_t(-1);\n\t\tret += pw_down * d;\n\t\tpw_down *= p_v, pw_up /= p_v;\n\t}\n\treturn ret;\n}\n\ntemplate \nexp_t PohligHellman(const PH_t g, const PH_t a, const exp_t * p_v, const int * p_e, const int p_n) {\n\t// return e: g**e == a, or -1 if no such e exists\n\tstatic exp_t e_rem[100];\n\texp_t order = 1;\n\tfor(int i = 0; i < p_n; i++) for(int j = 0; j < p_e[i]; j++) order *= p_v[i];\n\tfor(int i = 0; i < p_n; i++) {\n\t\texp_t pw = 1;\n\t\tfor(int j = 0; j < p_e[i]; j++) pw *= p_v[i];\n\t\tPH_t g_pow = pow(g, order/pw);\n\t\tPH_t a_pow = pow(a, order/pw);\n\t\te_rem[i] = PohligHellman_pw(g_pow, a_pow, p_v[i], p_e[i]);\n\t\tif(e_rem[i] == exp_t(-1)) return exp_t(-1);\n\t}\n\treturn CRT(e_rem, p_v, p_e, p_n);\n}\n\ntemplate \nPH_t DiscreteLog(const PH_t a, const PH_t b, const exp_t order) {\n\t// return e: a**e == b, or -1 if no such e exists\n\t// factorise assuming all prime factors are small\n\tstatic exp_t p_v[100];\n\tstatic int p_e[100];\n\tint p_n = 0;\n\texp_t o = order;\n\tfor(exp_t i = 2; i*i <= o; i++) if(o%i == 0) {\n\t\tp_v[p_n] = i;\n\t\tp_e[p_n] = 0;\n\t\twhile(o%i == 0) p_e[p_n]++, o /= i;\n\t\tp_n++;\n\t}\n\tif(o > 1) {\n\t\tp_v[p_n] = o;\n\t\tp_e[p_n] = 1;\n\t\tp_n++;\n\t}\n\t// try random generators\n mt19937_64 rng(a*b);\n\tPH_t g = 0;\n\twhile(true) {\n\t\tPH_t try_g = g ? g : (rng() % order);\n\t\tif(!try_g) continue;\n\t\texp_t e_a = PohligHellman(try_g, a, p_v, p_e, p_n);\n\t\tif(e_a == exp_t(-1)) {\n\t\t\ttry_g = 0;\n\t\t\tcontinue;\n\t\t}\n\t\texp_t e_b = PohligHellman(try_g, b, p_v, p_e, p_n);\n\t\tif(e_b == exp_t(-1)) {\n\t\t\ttry_g = 0;\n\t\t\tcontinue;\n\t\t}\n\t\tg = try_g;\n\t\t// e_a * e == e_b + K * order\n\t\tstatic exp_t e_rem[100];\n\t\tfor(int i = 0; i < p_n; i++) {\n\t\t\texp_t pw = 1;\n\t\t\tfor(int j = 0; j < p_e[i]; j++) pw *= p_v[i];\n\t\t\texp_t e_a_rem = e_a % pw, e_b_rem = e_b % pw;\n\t\t\twhile(pw > 1 && e_a_rem % p_v[i] == 0) {\n\t\t\t\tif(e_b_rem % p_v[i] != 0) return -1;\n\t\t\t\tpw /= p_v[i], e_a_rem /= p_v[i], e_b_rem /= p_v[i];\n\t\t\t}\n\t\t\t// e_a_rem * e == e_b_rem + K * pw\n\t\t\te_rem[i] = (pw != 1) ? e_b_rem * pow(e_a_rem, pw-pw/p_v[i]-1, pw) % pw : 0;\n\t\t}\n\t\treturn CRT(e_rem, p_v, p_e, p_n);\n\t}\n}\n\nusing cat = unsigned long long;\n\ncat multiply_nocache(cat a, cat b);\n\ncat cache[64][64];\nchar cache_used[64][64];\n\ncat multiply_pw2(int a, int b) { // < 64\n\ta &= 63, b &= 63;\n\tif(cache_used[a][b]) return cache[a][b];\n\tif(a == 0 || b == 0) {\n\t\tcache_used[a][b] = 1;\n\t\tcache[a][b] = (1ULL<= pw && b >= pw) {\n\t\tcache_used[a][b] = 1;\n\t\tcache[a][b] = multiply_nocache(3ULL<<(pw-1), multiply_pw2(a^pw, b^pw));\n\t\treturn cache[a][b];\n\t}\n\tif(a >= pw) {\n\t\tcache_used[a][b] = 1;\n\t\tcache[a][b] = multiply_pw2(a^pw, b) << pw;\n\t\treturn cache[a][b];\n\t}\n\tif(b >= pw) {\n\t\tcache_used[a][b] = 1;\n\t\tcache[a][b] = multiply_pw2(a, b^pw) << pw;\n\t\treturn cache[a][b];\n\t}\n\tassert(false);\n\treturn -1;\n}\n\ncat multiply_nocache(cat a, cat b) {\n\tcat ret = 0;\n\tfor(int i = 0; a; i++, a /= 2) if(a&1) {\n\t\tcat b_c = b;\n\t\tfor(int j = 0; b_c; j++, b_c /= 2) if(b_c&1)\n\t\t\tret ^= multiply_pw2(i, j);\n\t}\n\treturn ret;\n}\n\ncat __attribute__((optimize(\"-Ofast,-funroll-loops\"))) multiply(cat a, cat b) {\n\tcat ret = 0;\n\tcat x[64];\n\tfor(int j = 0; j != 64; j++, b /= 2) x[j] = -(b&1);\n\tfor(int i = 0; a; i++, a /= 2) if(a&1) {\n\t\tcat y[64];\n\t\tcat * __restrict cache_ptr = &(cache[i][0]);\n\t\tfor(int j = 0; j != 64; j++) y[j] = x[j] & cache_ptr[j];\n\t\tfor(int j = 0; j != 64; j++) ret ^= y[j];\n\t}\n\treturn ret;\n}\n\nint main() {\n\tfor(int i = 0; i < 64; i++) for(int j = 0; j < 64; j++) multiply_nocache(1ULL<> T;\n\twhile(T--) {\n\t\tcat a, b;\n\t\tcin >> a >> b;\n\t\tcat ans = DiscreteLog(a, b, 0xFFFFFFFFFFFFFFFF);\n\t\tif(ans+1 == 0) cout << \"-1\\n\";\n\t\telse cout << ans << \"\\n\";\n\t}\n}\nmultiply(cat a, cat b) {\n\tcat ret = 0;\n\tcat x[64];\n\tfor(int j = 0; j != 64; j++, b /= 2) x[j] = -(b&1);\n\tfor(int i = 0; a; i++, a /= 2) if(a&1) {\n\t\tcat y[64];\n\t\tcat * __restrict cache_ptr = &(cache[i][0]);\n\t\tfor(int j = 0; j != 64; j++) y[j] = x[j] & cache_ptr[j];\n\t\tfor(int j = 0; j != 64; j++) ret ^= y[j];\n\t}\n\treturn ret;\n}\n\nint main() {\n\tfor(int i = 0; i < 64; i++) for(int j = 0; j < 64; j++) multiply_nocache(1ULL<> T;\n\twhile(T--) {\n\t\tcat a, b;\n\t\tcin >> a >> b;\n\t\tcat ans = DiscreteLog(a, b, 0xFFFFFFFFFFFFFFFF);\n\t\tif(ans+1 == 0) cout << \"-1\\n\";\n\t\telse cout << ans << \"\\n\";\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "5f357cfeccda83d1126818967b257d3c", "src_uid": "54b41c5184c27d1373ec05775bc43b50", "difficulty": 3400.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#pragma GCC optimize(3)\nusing namespace std;\nchar a[100];\nint len;\nlong long res=0,cur=0;\nint sign=1;\nint main()\n{\n scanf(\"%s\",a);\n len=strlen(a);\n for(int i=0;i\n#include \nusing namespace std;\n#define N 10086\n\nint res;\nchar s[N];\n\nint main()\n{\n\tscanf(\"%s\", s);\n\tfor (int i = 0, cur = 0, f = 1; ; i ++)\n\t{\n\t\tif (s[i] == '+' || s[i] == '-' || !s[i])\n\t\t{\n\t\t\tres += cur * f;\n\t\t\tif (!s[i]) break ;\n\t\t\tcur = s[i] - '0';\n\t\t\tf = s[i] == '+' ? 1 : -1;\n\t\t}\n\t\telse cur = cur * 10 + s[i] - '0';\n\t}\n\tprintf(\"%d\\n\", res);\n\treturn 0;", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3bb4315c0bdeea728b4778aac3444bad", "src_uid": "db85fa18f00e560b58cfa7bab2fa957d", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "#include \n\nint main()\n{\n \n char s[1024];\n scanf(\"%s\", s);\n int n = 0, a= 0;\n char * t = s + i;\n n = (int)t[0] - '0';\n ++t;\n while( *t != 0 && *t != '+' && *t != '-')\n n = n * 10 + *t++ -'0';\n \n for(int i = 0; s[i]; ++i){\n \n if (s[i] == '+'){\n t = s + i;\n a = (int)*t - '0';\n ++t;\n while(*t != 0 && *t != '+' && *t != '-')\n a = a * 10 + *t++ - '0';\n \n n += a;\n } else {\n t = s + i;\n a = (int)*t - '0';\n ++t;\n while(*t != 0 && *t != '+' && *t != '-')\n a = a * 10 + *t++ -'0';\n \n n -=a;\n } \n \n }\n \n printf(\"%d\\n\", n);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f6b0ca565de68af1b2a84cad5a1c9ac0", "src_uid": "db85fa18f00e560b58cfa7bab2fa957d", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nint n,m,a,mn,ma,t = 0;\nchar b[20+1][20+1];\nint ghz(int i,int j);\nint main()\n{\n int x = 1,y=1;\n cin >> n >> m >> mn >> ma;\n for (int i = 1;i <= 20;i++)\n for (int j = 1;j <= 20;j++)\n b[i][j] = 'o';\n mn+=1;\n ma+=1;\n b[mn][ma] = '!';\n b[mn+2][ma+1] = '!';\n b[mn+2][ma-1] = '!';\n b[mn-2][ma+1] = '!';\n b[mn-2][ma-1] = '!';\n b[mn+1][ma-2] = '!';\n b[mn+1][ma+2] = '!';\n b[mn-1][ma+2] = '!';\n b[mn-1][ma-2] = '!';\n b[n][m] = '*';\n b[x][y]='Q';\n ghz(x,y);\n cout << t << endl;\n for (int i = 1;i <= 20;i++)\n {\n for (int j = 1;j <= 20;j++)\n cout << b[i][j] << \" \";\n cout << endl;\n }\n return 0;\n}\nint ghz(int i,int j)\n{\n\n if (b[i][j] == '*')\n t++;\n if (b[i+1][j] == 'o' || b[i+1][j] == '*')\n ghz(i+1,j);\n if (b[i][j+1] == 'o' || b[i][j+1] == '*')\n ghz(i,j+1);\n if (b[i][j-1] == 'o' || b[i][j-1] == '*')\n ghz(i,j-1);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cd5508cb2631e9a3f64725b74aee9151", "src_uid": "db85fa18f00e560b58cfa7bab2fa957d", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "//by yjz\n#include\nusing namespace std;\n#define FF first\n#define SS second\n#define PB push_back\n#define MP make_pair\n#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)\n#ifndef LOCAL\n#define cerr if(0)cout\n#endif\ntypedef long long ll;\nconst int mod=1e9+7;\n//My i/o stream\nstruct fastio\n{\n\tchar s[100000];\n\tint it,len;\n\tfastio(){it=len=0;}\n\tinline char get()\n\t{\n\t\tif(it0)it--;\n\t\treturn c!=EOF;\n\t}\n}_buff;\n#define geti(x) x=getnum()\n#define getii(x,y) geti(x),geti(y)\n#define getiii(x,y,z) getii(x,y),geti(z)\n#define puti(x) putnum(x),putchar(' ')\n#define putii(x,y) puti(x),puti(y)\n#define putiii(x,y,z) putii(x,y),puti(z)\n#define putsi(x) putnum(x),putchar('\\n')\n#define putsii(x,y) puti(x),putsi(y)\n#define putsiii(x,y,z) putii(x,y),putsi(z)\ninline ll getnum()\n{\n\tll r=0;bool ng=0;char c;c=_buff.get();\n\twhile(c!='-'&&(c<'0'||c>'9'))c=_buff.get();\n\tif(c=='-')ng=1,c=_buff.get();\n\twhile(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();\n\treturn ng?-r:r;\n}\ntemplate inline void putnum(T x)\n{\n\tif(x<0)putchar('-'),x=-x;\n\tregister short a[20]={},sz=0;\n\twhile(x)a[sz++]=x%10,x/=10;\n\tif(sz==0)putchar('0');\n\tfor(int i=sz-1;i>=0;i--)putchar('0'+a[i]);\n}\ninline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}\nll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}\nint n,m;\ntypedef unsigned long long ull;\nstruct state\n{\n\tint a[4][4];\n\tull geths()\n\t{\n\t\tull hs=0;\n\t\tfor(int i=0;iax;i--)a[i][by]=a[i-1][by];\n\t\tfor(int i=by;i>ay;i--)a[ax][i]=a[ax][i-1];\n\t\ta[ax][ay+1]=t;\n\t}\n\tvoid out()\n\t{\n\t\tfor(int i=0;i hsmp;\nint getid(state x)\n{\n\tint &id=hsmp[x.geths()];\n\tif(id==0)\n\t{\n\t\tid=++tot;\n\t\tassert(tot,pair > prer[maxst];\nvoid bfs(state S)\n{\n\tmemset(dis,-1,sizeof(dis));\n\tdis[getid(S)]=0;\n\tint qn=0;\n\tq[qn++]=getid(S);\n\tfor(int i=0;i > cmd;\nint dx[4]={1,-1,0,0};\nint dy[4]={0,0,1,-1};\nint id[22][22];\nbool ban[22][22];\npair idp[422];\nint a[22][22],M;\npair pos[422];\nint& getv(int id){return a[idp[id].FF][idp[id].SS];}\nvoid debug()\n{\n\tcerr<<\"n=\"< v)\n{\n//\tcerr<<\"add:\"< nv;\n\tfor(int i=0;i0;i--)getv(v[i])=getv(v[i-1]);\n\tgetv(v[0])=tmp;\n\tfor(int i=0;i=0&&x=0&&y p,int dir)\n{\n\tint x=p.FF,y=p.SS;\n\tint nx=x+dx[dir],ny=y+dy[dir];\n\tassert(valid(x,y)&&valid(nx,ny));\n\tint nnx1=nx+dx[dir^2],nny1=ny+dy[dir^2];\n\tint nnx2=nx+dx[dir^3],nny2=ny+dy[dir^3];\n\tif(valid(nnx1,nny1)&&valid(nnx1+dx[dir^1],nny1+dy[dir^1]))\n\t{\n\t\tadd({id[x][y],id[nx][ny],id[nnx1][nny1],id[nnx1+dx[dir^1]][nny1+dy[dir^1]]});\n\t}\n\telse if(valid(nnx2,nny2)&&valid(nnx2+dx[dir^1],nny2+dy[dir^1]))\n\t{\n\t\tnnx1=nnx2;nny1=nny2;\n\t\tadd({id[x][y],id[nx][ny],id[nnx1][nny1],id[nnx1+dx[dir^1]][nny1+dy[dir^1]]});\n\t}\n\telse assert(false);\n}\nvoid go(pair p,pair q)\n{\n//\tcerr<<\"go:\"<q.FF&&valid(p.FF+dx[1],p.SS+dy[1]))go(p,1),p.FF--;\n\t\twhile(p.SSq.SS&&valid(p.FF+dx[3],p.SS+dy[3]))go(p,3),p.SS--;\n\t}\n}\nvoid decm()\n{\n\tcerr<<\"m=\"< p=pos[id[i][m-1]];\n\t\tif(i+2==n)\n\t\t{\n\t\t\tgo(pos[id[n-2][m-1]],MP(1,1));\n\t\t\tp=pos[id[n-1][m-1]];\n\t\t}\n\t\tgo(p,MP(i,m-2));\n\t\tgo(MP(i,m-2),MP(i,m-1));\n\t\tban[i][m-1]=1;\n\t}\n\t\n\tgo(pos[id[n-2][m-1]],MP(n-2,m-2));\n\tadd({id[n-2][m-2],id[n-2][m-1],id[n-1][m-1],id[n-1][m-2]});\n\tm--;\n}\nvoid decn()\n{\n\tcerr<<\"n=\"< p=pos[id[n-1][i]];\n\t\tif(i+2==m)\n\t\t{\t\n\t\t\tgo(pos[id[n-1][m-2]],MP(1,1));\n\t\t\tp=pos[id[n-1][m-1]];\n\t\t}\n\t\tgo(p,MP(n-2,i));\n\t\tgo(MP(n-2,i),MP(n-1,i));\n\t\tban[n-1][i]=1;\n\t}\n\tgo(pos[id[n-1][m-2]],MP(n-2,m-2));\n\tadd({id[n-2][m-2],id[n-1][m-2],id[n-1][m-1],id[n-2][m-1]});\n\tn--;\n}\nvoid addcycle(int ax,int ay,int bx,int by)\n{\n\tvector v;\n\tfor(int i=ay;iay;i--)v.PB(id[bx][i]);\n\tfor(int i=bx;i>ax;i--)v.PB(id[i][ay]);\n\tadd(v);\n}\nvoid solve()\n{\n//\tcerr<<\"solve:\"<,pair > > v;\n\twhile(pre[p])\n\t{\n\t\tv.PB(prer[p]);\n\t\tp=pre[p];\n\t}\n\treverse(v.begin(),v.end());\n\tfor(int i=0;i>n>>m;\n\tM=m;\n\tfor(int i=0;i>a[i][j];\n\t\t\tpos[a[i][j]]=MP(i,j);\n\t\t}\n\t}\n\twhile(m>3)decm();\n\twhile(n>2)decn();\n\tsolve();\n\tint sum=0;\n\tfor(int i=0;i\nusing namespace std;\n#define FF first\n#define SS second\n#define PB push_back\n#define MP make_pair\n#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)\n#ifndef LOCAL\n#define cerr if(0)cout\n#endif\ntypedef long long ll;\nconst int mod=1e9+7;\n//My i/o stream\nstruct fastio\n{\n\tchar s[100000];\n\tint it,len;\n\tfastio(){it=len=0;}\n\tinline char get()\n\t{\n\t\tif(it0)it--;\n\t\treturn c!=EOF;\n\t}\n}_buff;\n#define geti(x) x=getnum()\n#define getii(x,y) geti(x),geti(y)\n#define getiii(x,y,z) getii(x,y),geti(z)\n#define puti(x) putnum(x),putchar(' ')\n#define putii(x,y) puti(x),puti(y)\n#define putiii(x,y,z) putii(x,y),puti(z)\n#define putsi(x) putnum(x),putchar('\\n')\n#define putsii(x,y) puti(x),putsi(y)\n#define putsiii(x,y,z) putii(x,y),putsi(z)\ninline ll getnum()\n{\n\tll r=0;bool ng=0;char c;c=_buff.get();\n\twhile(c!='-'&&(c<'0'||c>'9'))c=_buff.get();\n\tif(c=='-')ng=1,c=_buff.get();\n\twhile(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();\n\treturn ng?-r:r;\n}\ntemplate inline void putnum(T x)\n{\n\tif(x<0)putchar('-'),x=-x;\n\tregister short a[20]={},sz=0;\n\twhile(x)a[sz++]=x%10,x/=10;\n\tif(sz==0)putchar('0');\n\tfor(int i=sz-1;i>=0;i--)putchar('0'+a[i]);\n}\ninline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}\nll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}\nint n,m;\ntypedef unsigned long long ull;\nstruct state\n{\n\tint a[4][4];\n\tull geths()\n\t{\n\t\tull hs=0;\n\t\tfor(int i=0;iax;i--)a[i][by]=a[i-1][by];\n\t\tfor(int i=by;i>ay;i--)a[ax][i]=a[ax][i-1];\n\t\ta[ax][ay+1]=t;\n\t}\n\tvoid out()\n\t{\n\t\tfor(int i=0;i hsmp;\nint getid(state x)\n{\n\tint &id=hsmp[x.geths()];\n\tif(id==0)\n\t{\n\t\tid=++tot;\n\t\tassert(tot,pair > prer[maxst];\nvoid bfs(state S)\n{\n\tmemset(dis,-1,sizeof(dis));\n\tdis[getid(S)]=0;\n\tint qn=0;\n\tq[qn++]=getid(S);\n\tfor(int i=0;i > cmd;\nint dx[4]={1,-1,0,0};\nint dy[4]={0,0,1,-1};\nint id[22][22];\nbool ban[22][22];\npair idp[422];\nint a[22][22],M;\npair pos[422];\nint& getv(int id){return a[idp[id].FF][idp[id].SS];}\nvoid debug()\n{\n\tcerr<<\"n=\"< v)\n{\n//\tcerr<<\"add:\"< nv;\n\tfor(int i=0;i0;i--)getv(v[i])=getv(v[i-1]);\n\tgetv(v[0])=tmp;\n\tfor(int i=0;i=0&&x=0&&y p,int dir)\n{\n\tint x=p.FF,y=p.SS;\n\tint nx=x+dx[dir],ny=y+dy[dir];\n\tassert(valid(x,y)&&valid(nx,ny));\n\tint nnx1=nx+dx[dir^2],nny1=ny+dy[dir^2];\n\tint nnx2=nx+dx[dir^3],nny2=ny+dy[dir^3];\n\tif(valid(nnx1,nny1)&&valid(nnx1+dx[dir^1],nny1+dy[dir^1]))\n\t{\n\t\tadd({id[x][y],id[nx][ny],id[nnx1][nny1],id[nnx1+dx[dir^1]][nny1+dy[dir^1]]});\n\t}\n\telse if(valid(nnx2,nny2)&&valid(nnx2+dx[dir^1],nny2+dy[dir^1]))\n\t{\n\t\tnnx1=nnx2;nny1=nny2;\n\t\tadd({id[x][y],id[nx][ny],id[nnx1][nny1],id[nnx1+dx[dir^1]][nny1+dy[dir^1]]});\n\t}\n\telse assert(false);\n}\nvoid go(pair p,pair q)\n{\n//\tcerr<<\"go:\"<q.FF)go(p,1),p.FF--;\n\twhile(p.SSq.SS)go(p,3),p.SS--;\n}\nvoid decm()\n{\n\tcerr<<\"m=\"< p=pos[id[i][m-1]];\n\t\tif(i+2==n)p=pos[id[n-1][m-1]];\n\t\tgo(p,MP(i,m-2));\n\t\tgo(MP(i,m-2),MP(i,m-1));\n\t\tban[i][m-1]=1;\n\t}\n\t\n\t\tgo(pos[id[n-2][m-1]],MP(n-2,m-2));\n\t\tadd({id[n-2][m-2],id[n-2][m-1],id[n-1][m-1],id[n-1][m-2]});\n\tm--;\n}\nvoid decn()\n{\n\tcerr<<\"n=\"< p=pos[id[n-1][i]];\n\t\tif(i+2==m)p=pos[id[n-1][m-1]];\n\t\tgo(p,MP(n-2,i));\n\t\tgo(MP(n-2,i),MP(n-1,i));\n\t\tban[n-1][i]=1;\n\t}\n\tdebug();\n\t\tgo(pos[id[n-1][m-2]],MP(n-2,m-2));\n\t\tadd({id[n-2][m-2],id[n-1][m-2],id[n-1][m-1],id[n-2][m-1]});\n\tdebug();\n\tn--;\n}\nvoid addcycle(int ax,int ay,int bx,int by)\n{\n\tvector v;\n\tfor(int i=ay;iay;i--)v.PB(id[bx][i]);\n\tfor(int i=bx;i>ax;i--)v.PB(id[i][ay]);\n\tadd(v);\n}\nvoid solve()\n{\n//\tcerr<<\"solve:\"<,pair > > v;\n\twhile(pre[p])\n\t{\n\t\tv.PB(prer[p]);\n\t\tp=pre[p];\n\t}\n\treverse(v.begin(),v.end());\n\tfor(int i=0;i>n>>m;\n\tM=m;\n\tfor(int i=0;i>a[i][j];\n\t\t\tpos[a[i][j]]=MP(i,j);\n\t\t}\n\t}\n\twhile(m>3)decm();\n\twhile(n>2)decn();\n\tsolve();\n\tint sum=0;\n\tfor(int i=0;i\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define ll long long\n#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)\n#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)\n#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)\ntemplateinline void chkmax(T &a,T b){ if(ainline void chkmin(T &a,T b){ if(a>b)a=b;}\n#define fi first\n#define se second\n#define mkr(a,b) make_pair(a,b)\ninline int read()\n{\n\tint sum=0,p=1;char ch=getchar();\n\twhile(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();\n\tif(ch=='-')p=-1,ch=getchar();\n\twhile('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();\n\treturn sum*p;\n}\n\nconst int maxn=22;\n\nint n,m,g[maxn][maxn],X[maxn*maxn],Y[maxn*maxn];\n\ninline void init()\n{\n\tn=read();m=read();\n\tREP(i,1,n)REP(j,1,m)g[i][j]=read(),X[g[i][j]]=i,Y[g[i][j]]=j;\n}\n\nstruct point {\n\tint x,y;\n\tpoint(int a=0,int b=0){ x=a; y=b;}\n};\n\ninline point operator + (point a,point b){ return point(a.x+b.x,a.y+b.y);}\ninline point operator - (point a,point b){ return point(a.x-b.x,a.y-b.y);}\n\n#define P(v) g[(v).x][(v).y]\n\nconst point tr[4]={point(0,1),point(1,0),point(0,-1),point(-1,0)};\n\ninline point GetPoint(int x)\n{\n\treturn point((x-1)/m+1,(x-1)%m+1);\n}\n\ninline int GetVal(point x)\n{\n\treturn (x.x-1)*m+x.y;\n}\n\ninline void Swap(point a,point b)\n{\n\tint &v1=g[a.x][a.y],&v2=g[b.x][b.y];\n\tswap(X[v1],X[v2]); swap(Y[v1],Y[v2]);\n\tswap(v1,v2);\n\t//swap(a,b);\n}\n\nvector >Ans;\n\ninline void Move4(point &a,int turn1,int turn2)//\n{\n\tpoint b=a+tr[turn1],c,d;\n\tc=b+tr[turn2]; d=a+tr[turn2];\n\tvectorv;\n\tv={P(a),P(b),P(c),P(d)};\n\tAns.push_back(v);\n //printf(\"4 %d %d %d %d\\n\",P(a),P(b),P(c),P(d)); \n\t\n\tSwap(c,d); Swap(b,c); Swap(a,b);\t\n\ta=b;\n\t\n\t/*printf(\"Case:%d\\n\",(int)Ans.size());\n\tREP(i,1,n)\n\t{\n\t\tREP(j,1,m)printf(\"%d \",g[i][j]);\n\t\tputs(\"\");\n\t\t}*/\n\t//puts(\"\");\n}\n\ninline void Move4_(point a,int turn1,int turn2)//\n{\n\tpoint b=a+tr[turn1],c,d;\n\tc=b+tr[turn2]; d=a+tr[turn2];\n\tvectorv;\n\tv={P(a),P(b),P(c),P(d)};\n\t//printf(\"4 %d %d %d %d\\n\",P(a),P(b),P(c),P(d));\n\t//puts(\"\");\n\tAns.push_back(v);\n\tSwap(c,d); Swap(b,c); Swap(a,b);\t\n\t//Swap(a,b); Swap(b,c); Swap(c,d);\n\t//a=b;\n\t/*printf(\"Case:%d\\n\",(int)Ans.size());\n\tREP(i,1,n)\n\t{\n\t\tREP(j,1,m)printf(\"%d \",g[i][j]);\n\t\tputs(\"\");\n\t}\n\n\tputs(\"\");*/\n\t\n}\n\n#define Right 0\n#define Left 2\n#define Up 3\n#define Down 1\n\ninline void doing()\n{\n\tDREP(i,n,3)DREP(j,m,3)\n\t{\n\t\tint val=(i-1)*m+j;\n\t\tpoint now=point(X[val],Y[val]);\n\t\tDREP(k,now.y,2)Move4(now,2,now.x>1?3:1);\n\t\tREP(k,now.x,i-1)Move4(now,1,0);\n\t\tDREP(k,now.x,i+1)Move4(now,3,0);\n\t\tREP(k,1,j-1)Move4(now,0,3);\n\t}\n\n\tDREP(i,n,3)\n\t{\n\t\tint v1=(i-1)*m+1,v2=(i-1)*m+2;\n\t\tpoint now=point(X[v1],Y[v1]);\n\t\tDREP(k,now.y,2)Move4(now,Left,now.x>1?Up:Down);\n\t\tREP(k,now.x,i-1)Move4(now,Down,Right);\n\t\tif(X[v2]==i-1 && Y[v2]==1)\n\t\t{\n\t\t\tpoint now2=point(X[v2],Y[v2]);\n\t\t\tMove4(now2,Right,Up);\n\t\t\tMove4(now,Right,Up);\n\t\t\tnow2=point(X[v2],Y[v2]);\n\t\t\tMove4(now2,Right,Up);\n\t\t\tMove4(now,Left,Up);\n\t\t}else\n\t\t{\n\t\t\tMove4(now,Right,Up);\n\t\t\tnow=point(X[v2],Y[v2]);\n\t\t\n\t\t\tDREP(k,now.y,2)Move4(now,Left,now.x>1?Up:Down);\n\t\t\tREP(k,now.x,i-2)Move4(now,Down,Right);\n\t\t\tMove4(now,Right,Up);\n\t\t\t\n\t\t\tMove4(now,Down,Left);\n\t\t}\n\t}\n\n\tDREP(j,m,3)\n\t{\n\t\tint v1=j,v2=m+j;\n\t\tpoint now=point(X[v1],Y[v1]);\n\t\tif(now.x==1)Move4(now,Down,now.y>1?Left:Right);\n\t\tREP(k,now.y,j-1)Move4(now,Right,Up);\n\n\t\tif(X[v2]==1 && Y[v2]==j)\n\t\t{\n\t\t\tpoint now2=point(X[v2],Y[v2]);\n\t\t\tMove4(now2,Left,Down);\n\t\t\tMove4(now2,Down,Left);\n\t\t\tMove4(now2,Up,Right);\n\t\t\tMove4(now2,Down,Left);\n\t\t\tMove4(now2,Right,Up);\n\t\t}else\n\t\t{\n\t\t\tnow=point(X[v2],Y[v2]);\n\t\t\tif(now.x==1)Move4(now,Down,now.y>1?Left:Right);\n\t\t\tREP(k,now.y,j-2)Move4(now,Right,Up);\n\t\t\tMove4(now,Right,Up);\n\t\t}\n\t}\n\t\n\twhile(g[1][1]>2 || g[1][2]>2)Move4_(point(1,1),Right,Down);\n\tif(Y[m+1]==2)\n\t{\n\t\t//Move4();\n\n\t\tvectorv;\n\t\tv={g[1][1],g[2][1],g[2][2],g[2][3],g[1][3],g[1][2]};\n\t\t//printf(\"6 %d %d %d %d %d %d\\n\",g[1][1],g[2][1],g[2][2],g[2][3],g[1][3],g[1][2]);\n\t\tAns.push_back(v);\n\n\t\t\n\t\t\n\t\tSwap(point(1,1),point(1,2)); Swap(point(1,2),point(1,3));\n\t\tSwap(point(1,3),point(2,3)); Swap(point(2,3),point(2,2));\n\t\tSwap(point(2,2),point(2,1));\n\n\t\t/*printf(\"Case:%d\\n\",(int)Ans.size());\n\t\tREP(i,1,n)\n\t\t{\n\t\t\tREP(j,1,m)printf(\"%d \",g[i][j]);\n\t\t\tputs(\"\");\n\t\t}\n\t\t\n\t\tputs(\"\");*/\n\t\t\n\t\tMove4_(point(1,2),Right,Down);\n\t\tMove4_(point(1,1),Right,Down);\n\t}\n\n\tif(Y[1]==2)\n\t{\n\t\tvectorv;\n\t\tv={g[1][1],g[1][2],g[1][3],g[2][3],g[2][2],g[2][1]};\n //printf(\"6 %d %d %d %d %d %d\\n\",g[1][1],g[1][2],g[1][3],g[2][3],g[2][2],g[2][1]);\n\t\tSwap(point(2,2),point(2,1)); Swap(point(2,3),point(2,2));\n\t\tSwap(point(1,3),point(2,3)); Swap(point(1,2),point(1,3)); \n\t\tSwap(point(1,1),point(1,2));\n\t\tAns.push_back(v);\n\t\t\n\t\t/*printf(\"Case:%d\\n\",(int)Ans.size());\n\t\tREP(i,1,n)\n\t\t{\n\t\t\tREP(j,1,m)printf(\"%d \",g[i][j]);\n\t\t\tputs(\"\");\n\t\t}\n\n\t\tputs(\"\");*/\n\t\t\n\t\tMove4_(point(1,2),Down,Right);\n\t\tMove4_(point(1,2),Left,Down);\n\t}\n\n\tprintf(\"%d\\n\",(int)Ans.size());\n\tfor(vector v:Ans)\n\t{\n\t\tprintf(\"%d \",(int)v.size());\n\t\tfor(int t:v)printf(\"%d \",t);\n\t\tputs(\"\");\n\t}\n\t\n\t/*REP(i,1,n)\n\t{\n\t\tREP(j,1,m)printf(\"%d \",g[i][j]);\n\t\tputs(\"\");\n\t\t}*/\n}\n\n// 4 1 2\n// 7 6 3\n// 8 5 9\n\nint main()\n{\n#ifndef ONLINE_JUDGE\n\tfreopen(\"E.in\",\"r\",stdin);\n\tfreopen(\"E.out\",\"w\",stdout);\n#endif\n\tinit();\n\tdoing();\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "558ac99537b94cf9ea0808d9d663dc69", "src_uid": "476afa2d8208ec933617c97637b65aff", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include\n#define ll long long\n#define ull unsigned long long\n#define uint ungigned\n#define db double\n#define pii pair\n#define pll pair\n#define pli pair\n#define vi vector\n#define vpi vector\n#define IT iterator\n \n#define PB push_back\n#define MK make_pair\n#define LB lower_bound\n#define UB upper_bound\n#define y1 wzpakking\n#define fi first\n#define se second\n#define BG begin\n#define ED end\n \n#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)\n#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)\n#define UPD(x,y) (((x)+=(y))>=mo?(x)-=mo:233)%s\n#define CLR(a,v) memset(a,v,sizeof(a))\n#define CPY(a,b) memcpy(a,b,sizeof(a))\n#define sqr(x) (1ll*x*x)\n \n#define LS3 k*2,l,mid\n#define RS3 k*2+1,mid+1,r\n#define LS5 k*2,l,mid,x,y\n#define RS5 k*2+1,mid+1,r,x,y\n#define GET pushdown(k);int mid=(l+r)/2\n#define INF (1ll<<60)\nusing namespace std;\n\nvoid move(vector p){\n\tans.push_back(p);\n\tint sz=p.size()-1;\n\tRep(i,sz-2,0);{\n\t\tswap(pos[p[i]],pos[p[sz-1]]);\n\t\tpii x;\n\t\tx=pos[p[i]];\n\t\ta[x.fi][x.se]=p[i];\n\t\tx=pos[p[sz-1]];\n\t\ta[x.fi][s.se]=p[sz-1];\n\t}\n}\nvoid roL(int x,int y){\n\tmove(vector{\n\t\ta[x][y],a[x+1][y],\n\t\ta[x+1][y+1],a[x][y+1]\n\t});\n}\nvoid roR(int x,int y){\n\tmove(vector{\n\t\ta[x][y],a[x][y+1],\n\t\ta[x+1][y+1],a[x+1][y]\n\t});\n}\nvoid goL(int v){\n\tint x=pos[x].fi,y=pos[x].se;\n\tmove(vector{\n\t\ta[x][y],a[x][y-1],\n\t\ta[(x==n?x+1:x-1)][y-1],a[(x==n?x+1:x-1)][y]\n\t});\n}\nvoid goR(int v){\n\tint x=pos[x].fi,y=pos[x].se;\n\tmove(vector{\n\t\ta[x][y],a[x][y+1],\n\t\ta[(x!=n?x+1:x-1)][y+1],a[(x!=n?x+1:x-1)][y]\n\t});\n}\nvoid goU(int v){\n\tint x=pos[x].fi,y=pos[x].se;\n\tmove(vector{\n\t\ta[x][y],a[x-1][y],\n\t\ta[x-1][(y!=m?y-1:y+1)],a[x][(y!=m?y-1:y+1)];\n\t});\n}\nvoid goD(int v){\n\tint x=pos[x].fi,y=pos[x].se;\n\tmove(vector{\n\t\ta[x][y],a[x+1][y],\n\t\ta[x+1][(y!=m?y-1:y+1)],a[x][(y!=m?y-1:y+1)];\n\t});\n}\n\nint main(){\n\tscanf(\"%d%d\",&n,&m);\n\tFor(i,1,n*m) per[i]=i;\n\trandom_shuffle(per+1,per+n*m+1);\n\tFor(i,1,n){\n\t\tscanf(\"%d\",&a[i][j]);\n\t\tpos[a[i][j]]=pii(i,j);\n\t}\n\tFor(i,1,n-2){\n\t\tFor(j,1,m-1){\n\t\t\tint id=(i-1)*m+j;\n\t\t\tfor (;pos[x].se>j;) goL(x);\n\t\t\tfor (;pos[x].sei;) goU(x);\n\t\t}\n\t\tint id=i*m;\n\t\tif (pos[x]==pii(i,m)) continue;\n\t\tif (pos[x]==pii(i+1,m-1)) roL(i+1,m-1);\n\t\troR(i,m-1);\n\t\tfor (;pos[x].sei+1;goU(x));\n\t\troL(i,m-1);\n\t}\n\tFor(j,1,m-2){\n\t\tint x=(n-2)*m+j;\n\t\tfor (;pos[x].se>j;) goL(x);\n\t\tfor (;pos[x].se\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define PR pair\n#define fi first\n#define se second\n#define mk make_pair\n#define pb push_back\n#define For(i,x,y) for(int i=(int)(x);i<=(int)(y);i++)\n#define Rep(i,x,y) for(int i=(int)(x);i< (int)(y);i++)\n#define Forn(i,x,y) for(int i=(int)(x);i>=(int)(y);i--)\n#define CH\t ch=getchar()\n#define Exit(...) printf(__VA_ARGS__),exit(0)\n#define dln() fprintf(stderr,\"\\n\")\n#define dprintf(...) fprintf(stderr,__VA_ARGS__)\nusing namespace std;\ntypedef __float128\t db;\ntypedef long long ll;\ntypedef PR PII;\nconst\tint inf=1e9;\nconst\tll Inf=1e10;\nconst\tint P=1e9+7;\nconst\tint N=100005;\nconst\tint S=1005;\n\ninline int IN(){\n\tint x=0;int ch=0,f=0;\n\tfor(CH;ch!=-1&&(ch<48||ch>57);CH) f=(ch=='-');\n\tfor(;ch>=48&&ch<=57;CH) x=(x<<1)+(x<<3)+ch-'0';\n\treturn f?(-x):x;\n}\n\nint Pow(int x,int y,int p){\n\tint a=1;\n\tfor(;y;y>>=1,x=(ll)x*x%p) if(y&1) a=(ll)a*x%p;\n\treturn a;\n}\n\nint n,D=50;\ndb f[S][S],g[S][S],p[5],F[S][S],G[S][S],pr[S][S];\ndb A[S],B[S],V[S*2];\nstruct mat{\n\tdb v[205][205];\n}c,e,b;\n\nmat operator *(const mat &a,const mat &b){\n\tFor(i,1,2*D) For(j,1,2*D){\n\t\tc.v[i][j]=0;\n\t\tFor(k,1,2*D) c.v[i][j]+=a.v[i][k]*b.v[k][j];\n\t} return c;\n}\n\nint main(){\n\tdouble x;\n\tscanf(\"%d%lf\",&n,&x);p[1]=x;\n\tp[1]/=inf;p[2]=1-p[1];\n\tFor(i,1,D){\n\t\tFor(j,1,D){\n\t\t\tif(i==1) f[i][j]+=p[1];\n\t\t\tif(i==2) f[i][j]+=p[2],g[i][j]+=p[2];\n\t\t\tf[i][j]+=f[i-1][j]*f[i-1][j-1];\n\t\t\tg[i][j]+=g[i-1][j]*f[i-1][j-1];\n\t\t}\n\t}\n\t\n\tint L=min(50,n);\n\tFor(i,1,D) F[1][i]=i,G[1][i]=1;\n\tFor(i,2,L){\n\t\tFor(j,1,D){\n\t\t\tif(j==1){\n\t\t\t\tFor(k,2,D){\n\t\t\t\t\tF[i][j]+=F[i-1][k]*g[k][i-1]+G[i-1][k]*g[k][i-1]*j;\n\t\t\t\t\tG[i][j]+=G[i-1][k]*g[k][i-1];\n\t\t\t\t}\n\t\t\t}else{\n\t\t\t\tRep(k,1,j){\n\t\t\t\t\tF[i][j]+=F[i-1][k]*f[k][i-1]+G[i-1][k]*f[k][i-1]*j;\n\t\t\t\t\tG[i][j]+=G[i-1][k]*f[k][i-1];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tFor(i,1,D) A[i]=f[i][L],B[i]=g[i][L];\n\tFor(i,1,D){\n\t\tif(i==1){\n\t\t\tFor(j,2,D){\n\t\t\t\te.v[i][j]=B[j];\n\t\t\t\te.v[i+D][j+D]=B[j];\n\t\t\t\te.v[i][j+D]=B[j]*i;\n\t\t\t}\n\t\t}else{\n\t\t\tRep(j,1,i){\n\t\t\t\te.v[i][j]=A[j];\n\t\t\t\te.v[i+D][j+D]=A[j];\n\t\t\t\te.v[i][j+D]=A[j]*i;\n\t\t\t}\n\t\t}\n\t}\n\tFor(i,1,D*2) For(j,1,D*2) b.v[i][j]=i==j;\n\tfor(int p=n-L;p;p>>=1,e=e*e) if(p&1) b=b*e;\n\tFor(i,1,D) V[i]=F[L][i],V[i+D]=G[L][i];\n\tdb an=0;\n\tFor(i,1,D){\n\t\tdb a=0;\n\t\tFor(j,1,D*2) a+=V[j]*b.v[i][j];\n\t\tan+=a*f[i][min(n,L)];\n\t}\n\tprintf(\"%.15lf\\n\",double(an));\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4f18918f028317e163c08f35b89209da", "src_uid": "0aaf5fefed8b572b59bfce73dbbcde66", "difficulty": 3300.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\n#define MAXK 51\n#define ITER 1500\n\nint N;\ndouble p, q, a[MAXK][MAXK], dp[2][MAXK];\n\nvoid solve() {\n\tfor (int i = 0; i < MAXK; ++i) {\n\t\tfor (int k = 1; k < MAXK; ++k) {\n\t\t\tif (i == 0) a[i][k] = 0;\n\t\t\telse if (k == 1) a[i][k] = p;\n\t\t\telse if (i == 1 && k == 2) a[i][k] = q;\n\t\t\telse if (i > 1 && k == 2) a[i][k] = p*p + q;\n\t\t\telse if (i == 1 && k > 2) a[i][k] = 0;\n\t\t\telse a[i][k] = a[i][k-1]*a[i-1][k-1];\n\t\t}\n\t}\n\t\n\tint iter = min(ITER, N);\n\tfor (int i = iter; i > 0; --i) {\n\t\tfor (int j = 1; j < MAXK; ++j) {\n\t\t\tdp[0][j] = j;\n\t\t\tif(i < iter) {\n\t\t\t\tint rev = min(iter-i,MAXK-1);\n\t\t\t\tdouble num = 0;\n\t\t\t\tdouble denom = 0;\n\t\t\t\tif(j == 1) {\n\t\t\t\t\tfor (int k = 2; k < MAXK; ++k) {\n\t\t\t\t\t\tdouble prob = a[rev][k]*(1-a[rev-1][k]);\n\t\t\t\t\t\tnum += prob*dp[1][k];\n\t\t\t\t\t\tdenom += prob;\n\t\t\t\t\t}\n\t\t\t\t} else if(j > 1) {\n\t\t\t\t\tfor (int k = 1; k < j; ++k) {\n\t\t\t\t\t\tdouble prob = a[rev][k]*(1-a[rev-1][k]);\n\t\t\t\t\t\tnum += prob*dp[1][k];\n\t\t\t\t\t\tdenom += prob;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tdp[0][j] += num/denom;\n\t\t\t}\n\t\t}\n\t\tswap(dp[0], dp[1]);\n\t}\n}\n\nint main() {\n\tint x;\n\tscanf(\"%d %d\", &N, &x);\n\tp = (double)x / 1000000000;\n\tq = 1-p;\n\t\n\tsolve();\n\t\n\tdouble ans = 0;\n\tint i = min(MAXK-1, N);\n\tint sur = max(0, N-ITER);\n\tfor (int k = 1; k <= 50; ++k) {\n\t\tans += a[i][k]*(1-a[i-1][k])*(dp[1][k] + sur*(dp[1][k]-dp[0][k]));\n\t}\n\tprintf(\"%.15f\\n\", ans);\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6e843a96ca66b0bf67f8fc0179d9b552", "src_uid": "0aaf5fefed8b572b59bfce73dbbcde66", "difficulty": 3300.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\n#define MAXN 1000000001\n#define MAXK 51\n\nint N;\ndouble p, q, a[MAXK][MAXK], dp[MAXN][MAXK];\n\nvoid solve() {\n\tfor (int i = 0; i < MAXK; ++i) {\n\t\tfor (int k = 1; k < MAXK; ++k) {\n\t\t\tif (i == 0) a[i][k] = 0;\n\t\t\telse if (k == 1) a[i][k] = p;\n\t\t\telse if (i == 1 && k == 2) a[i][k] = q;\n\t\t\telse if (i > 1 && k == 2) a[i][k] = p*p + q;\n\t\t\telse if (i == 1 && k > 2) a[i][k] = 0;\n\t\t\telse a[i][k] = a[i][k-1]*a[i-1][k-1];\n\t\t}\n\t}\n\t\n\tfor (int i = N; i > 0; --i) {\n\t\tfor (int j = 1; j < MAXK; ++j) {\n\t\t\tdp[i][j] = j;\n\t\t\tif(i < N) {\n\t\t\t\tint rev = min(N-i,MAXK-1);\n\t\t\t\tdouble num = 0;\n\t\t\t\tdouble denom = 0;\n\t\t\t\tif(j == 1) {\n\t\t\t\t\tfor (int k = 2; k < MAXK; ++k) {\n\t\t\t\t\t\tdouble prob = a[rev][k]*(1-a[rev-1][k]);\n\t\t\t\t\t\tnum += prob*dp[i+1][k];\n\t\t\t\t\t\tdenom += prob;\n\t\t\t\t\t}\n\t\t\t\t} else if(j > 1) {\n\t\t\t\t\tfor (int k = 1; k < j; ++k) {\n\t\t\t\t\t\tdouble prob = a[rev][k]*(1-a[rev-1][k]);\n\t\t\t\t\t\tnum += prob*dp[i+1][k];\n\t\t\t\t\t\tdenom += prob;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tdp[i][j] += num/denom;\n\t\t\t}\n\t\t}\n\t}\n}\n\nint main(int argc, const char * argv[]) {\n\tint x;\n\tscanf(\"%d %d\", &N, &x);\n\tp = (double)x / 1000000000;\n\tq = 1-p;\n\t\n\tsolve();\n\t\n\tdouble ans = 0;\n\tint i = min(MAXK-1, N);\n\tfor (int k = 1; k <= 50; ++k) {\n\t\tans += a[i][k]*(1-a[i-1][k])*dp[1][k];\n\t}\n\tprintf(\"%.15f\\n\", ans);\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "9fd89a4e7b34eebab13cc56cdba4f7a1", "src_uid": "0aaf5fefed8b572b59bfce73dbbcde66", "difficulty": 3300.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\ntypedef long double ldb;\nconst int maxn=210;\nstruct matrix{\n\tint M;\n\tldb a[60][60];\n\tmatrix(){memset(a,0,sizeof(a));}\n\tmatrix(int M):M(M){memset(a,0,sizeof(a));}\n\tmatrix operator*(const matrix& ma)const{\n\t\tmatrix ret(M);\n\t\tfor(int i=1;i<=M;++i)\n\t\t\tfor(int k=1;k<=M;++k)\n\t\t\t\tfor(int j=1;j<=M;++j)\n\t\t\t\t\tret.a[i][j]+=a[i][k]*ma.a[k][j];\n\t\treturn ret;\n\t}\n\tvoid setM(int m){\n\t\tM=m;\n\t}\n\tvoid I(){\n\t\tfor(int i=1;i<=M;++i)a[i][i]=1;\n\t}\n}A;\nldb dp[60][maxn],a[60][maxn],b[60][maxn],p;\nldb f[60][maxn],g[60][maxn];\nint n;\nmatrix qpow(matrix A,int n){\n\tmatrix ret(A.M);\n\tret.I();\n\tfor(;n;n>>=1,A=A*A)\n\t\tif(n&1)ret=ret*A;\n\treturn ret;\n}\nint main(){\n\tint a;\n\tscanf(\"%d%d\",&n,&a);\n\tp=(ldb)a/(ldb)1e9;\n\tint K=50;\n\t// a[i][j]=a[i-1][j]*a[i-1][j-1] \n\tfor(int i=1;i<=K;++i)a[1][i]=p;\n\ta[2][1]=(1-p);\n\tfor(int i=2;i<=K;++i)a[2][i]=(1-p)+p*p;\n\tfor(int i=1;i<=K;++i)b[2][i]=1-p;\n\tfor(int i=3;i<=K;++i){\n\t\tfor(int j=1;j<=K;++j)\n\t\t\ta[i][j]=a[i-1][j]*a[i-1][j-1],\n\t\t\tb[i][j]=b[i-1][j]*a[i-1][j-1]; \n\t}\n\t//(i>1) dp[i][n]=i+\\sum_{j=1}^{i-1}(dp[j][n+1]*(exist(j,n+1)/ALL)\n\tfor(int i=1;i<=K;++i){\n\t\tfor(int j=1;j<=K;++j)\n\t\t\tf[i][j]=a[i][j]*(1-a[i][j-1]),\n\t\t\tg[i][j]=b[i][j]*(1-a[i][j-1]);\n\t}\n\tdp[1][1]=1,dp[2][1]=2;\n\tfor(int j=2;j<=K;++j){\n\t\tfor(int i=1;i<=K;++i){\n\t\t\tif(i==1){\n\t\t\t\tldb all=0;\n\t\t\t\tfor(int k=2;k<=K;++k)\n\t\t\t\t\tall+=g[k][j-1];\n\t\t\t\tdp[i][j]=i;\n\t\t\t\tfor(int k=2;k<=K;++k)\n\t\t\t\t\tdp[i][j]+=dp[k][j-1]*g[k][j-1]/all;\n\t\t\t} else {\n\t\t\t\tldb all=0;\n\t\t\t\tfor(int k=1;k<=i-1;++k)\n\t\t\t\t\tall+=f[k][j-1];\n\t\t\t\tdp[i][j]=i;\n\t\t\t\tfor(int k=1;k<=i-1;++k)\n\t\t\t\t\tdp[i][j]+=dp[k][j-1]*f[k][j-1]/all;\n\t\t\t}\n//\t\t\tprintf(\"{(%d,%d)%.5lf}\\n\",i,j,dp[i][j]);\n\t\t}\n\t}\n\tif(n<=K){\n\t\tldb ans=0;\n\t\tfor(int i=1;i<=K;++i)\n\t\t\tans+=dp[i][n]*f[i][n];\n\t\tprintf(\"%.10Lf\",ans);\t\n\t} else {\n\t\tldb ans=0;\n\t\tA.setM(K+1);\n\t\tfor(int i=1;i<=K;++i){\n\t\t\tif(i==1){\n\t\t\t\tldb all=0;\n\t\t\t\tfor(int k=2;k<=K;++k)\n\t\t\t\t\tall+=g[k][K];\n\t\t\t\tA.a[K+1][i]=i;\n\t\t\t\tfor(int k=2;k<=K;++k)\n\t\t\t\t\tA.a[k][i]+=g[k][K]/all;\n\t\t\t} else {\n\t\t\t\tldb all=0;\n\t\t\t\tfor(int k=1;k<=i-1;++k)\n\t\t\t\t\tall+=f[k][K];\n\t\t\t\tA.a[K+1][i]=i;\n\t\t\t\tfor(int k=1;k<=i-1;++k)\n\t\t\t\t\tA.a[k][i]+=f[k][K]/all;\n\t\t\t}\n\t\t}\n\t\tA.a[K+1][K+1]=1;\n\t\tA=qpow(A,n-K);\n\t\tfor(int i=1;i<=K;++i){\n\t\t\tldb sum=0;\n\t\t\tfor(int j=1;j<=K;++j)\n\t\t\t\tsum+=dp[j][K]*A.a[j][i];\n\t\t\tsum+=A.a[K+1][i];\n\t\t\tans+=sum*f[i][K];\n\t\t}\n\t\tprintf(\"%.10Lf\",ans);\n\t}\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f753e245ffc5fb4f2fafdfc1ca87ff5f", "src_uid": "0aaf5fefed8b572b59bfce73dbbcde66", "difficulty": 3300.0} {"lang": "GNU C++17", "source_code": "/**\n * code generated by JHelper\n * More info: https://github.com/AlexeyDmitriev/JHelper\n * @author\n */\n\n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define pb push_back\n#define sz(v) ((int)(v).size())\n#define all(v) (v).begin(),(v).end()\n#define mp make_pair\n\nusing namespace std;\n\ntypedef long long int64;\ntypedef vector vi;\ntypedef pair ii;\n\nint BUBEN = 30;\nint BUBEN2 = 5;\nint BUBEN3 = 20;\n\nclass TaskH {\n public:\n void solveOne(istream &in, ostream &out) {\n double start = clock() / (double) CLOCKS_PER_SEC;\n\n int n;\n in >> n;\n vector x(n + 1);\n vector y(n + 1);\n for (int i = 0; i <= n; ++i) {\n in >> x[i] >> y[i];\n }\n vector offset;\n vector len;\n vector dx;\n vector dy;\n offset.push_back(0);\n for (int i = 0; i < n; ++i) {\n double vx = x[i + 1] - x[i];\n double vy = y[i + 1] - y[i];\n double z = hypot(vx, vy);\n dx.push_back(vx / z);\n dy.push_back(vy / z);\n len.push_back(z);\n offset.push_back(offset.back() + z);\n }\n auto ternary = [&](const auto& func, double left, double right) {\n while (right - left > 1e-12 * max(1.0, right)) {\n double mleft = (2 * left + right) / 3;\n double mright = (left + 2 * right) / 3;\n double vleft = func(mleft);\n double vright = func(mright);\n if (vleft > vright) {\n right = mright;\n } else {\n left = mleft;\n }\n }\n return func((left + right) / 2);\n };\n double total = offset.back();\n\n auto where = [&](double pos) {\n int i = lower_bound(all(offset), pos) - offset.begin() - 1;\n if (i < 0) i = 0;\n if (i >= n) i = n - 1;\n return i;\n };\n\n auto evalBefore = [&](double pos) {\n int i = where(pos);\n double xi = x[i] + dx[i] * (pos - offset[i]);\n double yi = y[i] + dy[i] * (pos - offset[i]);\n\n double bestBefore = 1;\n for (int j = 0; j < i; ++j) {\n auto eval2 = [&](double t) {\n double xj = x[j] + dx[j] * t;\n double yj = y[j] + dy[j] * t;\n double direct = pos - (offset[j] + t);\n return direct / hypot(xi - xj, yi - yj);\n };\n double cur = ternary(eval2, 0, len[j]);\n bestBefore = max(bestBefore, cur);\n }\n return bestBefore;\n };\n\n auto evalAfter = [&](double pos) {\n int i = where(pos);\n double xi = x[i] + dx[i] * (pos - offset[i]);\n double yi = y[i] + dy[i] * (pos - offset[i]);\n\n double bestAfter = 1;\n for (int j = i + 1; j < n; ++j) {\n auto eval2 = [&](double t) {\n double xj = x[j] + dx[j] * t;\n double yj = y[j] + dy[j] * t;\n double direct = (offset[j] + t) - pos;\n return direct / hypot(xi - xj, yi - yj);\n };\n double cur = ternary(eval2, 0, len[j]);\n bestAfter = max(bestAfter, cur);\n }\n return bestAfter;\n };\n\n auto eval = [&](double pos) {\n return min(evalBefore(pos), evalAfter(pos));\n };\n\n\n double STEP = total;\n vector> best;\n while (clock() / (double) CLOCKS_PER_SEC < start + 1) {\n STEP *= 0.5;\n for (double at = STEP; at <= total; at += STEP * 2) {\n best.emplace_back(eval(at), where(at), at);\n }\n }\n sort(all(best));\n\n auto reduce = [&]() {\n sort(all(best), [](const auto& a, const auto& b) {\n return get<0>(a) > get<0>(b);\n });\n int got = 0;\n vector gotIn(n);\n for (int i = 0; i < best.size(); ++i) {\n if (got < BUBEN3 && gotIn[get<1>(best[i])] < BUBEN2) {\n best[got] = best[i];\n ++got;\n ++gotIn[get<1>(best[i])];\n }\n }\n best.resize(got);\n };\n\n while (clock() / (double) CLOCKS_PER_SEC < start + 3) {\n reduce();\n STEP *= 0.5;\n sort(all(best), [](const auto& a, const auto& b) {\n return get<2>(a) < get<2>(b);\n });\n int old = best.size();\n double prev = 0;\n for (int i = 0; i <= old; ++i) {\n double cur;\n if (i == old) {\n cur = total;\n } else {\n cur = get<2>(best[i]);\n }\n if (cur - prev > 3 * STEP) {\n double at = prev + STEP;\n best.emplace_back(eval(at), where(at), at);\n at = cur - STEP;\n best.emplace_back(eval(at), where(at), at);\n } else if (cur - prev > 2 * STEP) {\n double at = (2 * prev + cur) / 3;\n best.emplace_back(eval(at), where(at), at);\n at = (prev + 2 * cur) / 3;\n best.emplace_back(eval(at), where(at), at);\n } else if (cur - prev > STEP) {\n double at = (prev + cur) / 2;\n best.emplace_back(eval(at), where(at), at);\n }\n prev = cur;\n }\n }\n\n cerr << STEP << endl;\n\n double res = 0;\n for (const auto& x : best) {\n res = max(res, get<0>(x));\n }\n out << res << \"\\n\";\n }\n\n\n\n void solve(std::istream &in, std::ostream &out) {\n out.precision(20);\n int nt = 1;\n for (int it = 0; it < nt; ++it) {\n solveOne(in, out);\n }\n }\n};\n\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n TaskH solver;\n std::istream& in(std::cin);\n std::ostream& out(std::cout);\n solver.solve(in, out);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "f9398db1d58d64aed9627dd79f8aa55d", "src_uid": "ee115d3f08a53c52db3e429ad0cee906", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "/**\n * code generated by JHelper\n * More info: https://github.com/AlexeyDmitriev/JHelper\n * @author\n */\n\n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define pb push_back\n#define sz(v) ((int)(v).size())\n#define all(v) (v).begin(),(v).end()\n#define mp make_pair\n\nusing namespace std;\n\ntypedef long long int64;\ntypedef vector vi;\ntypedef pair ii;\n\nint BUBEN = 30;\nint BUBEN2 = 5;\nint BUBEN3 = 20;\n\nclass TaskH {\n public:\n void solveOne(istream &in, ostream &out) {\n double start = clock() / (double) CLOCKS_PER_SEC;\n\n int n;\n in >> n;\n vector x(n + 1);\n vector y(n + 1);\n for (int i = 0; i <= n; ++i) {\n in >> x[i] >> y[i];\n }\n vector offset;\n vector len;\n vector dx;\n vector dy;\n offset.push_back(0);\n for (int i = 0; i < n; ++i) {\n double vx = x[i + 1] - x[i];\n double vy = y[i + 1] - y[i];\n double z = hypot(vx, vy);\n dx.push_back(vx / z);\n dy.push_back(vy / z);\n len.push_back(z);\n offset.push_back(offset.back() + z);\n }\n auto ternary = [&](const auto& func, double left, double right) {\n while (right - left > 1e-12 * max(1.0, right)) {\n double mleft = (2 * left + right) / 3;\n double mright = (left + 2 * right) / 3;\n double vleft = func(mleft);\n double vright = func(mright);\n if (vleft > vright) {\n right = mright;\n } else {\n left = mleft;\n }\n }\n return func((left + right) / 2);\n };\n double total = offset.back();\n\n auto where = [&](double pos) {\n int i = lower_bound(all(offset), pos) - offset.begin() - 1;\n if (i < 0) i = 0;\n if (i >= n) i = n - 1;\n return i;\n };\n\n auto evalBefore = [&](double pos) {\n int i = where(pos);\n double xi = x[i] + dx[i] * (pos - offset[i]);\n double yi = y[i] + dy[i] * (pos - offset[i]);\n\n double bestBefore = 1;\n for (int j = 0; j < i; ++j) {\n auto eval2 = [&](double t) {\n double xj = x[j] + dx[j] * t;\n double yj = y[j] + dy[j] * t;\n double direct = pos - (offset[j] + t);\n return direct / max(1e-7, hypot(xi - xj, yi - yj));\n };\n double cur = ternary(eval2, 0, len[j]);\n bestBefore = max(bestBefore, cur);\n }\n return bestBefore;\n };\n\n auto evalAfter = [&](double pos) {\n int i = where(pos);\n double xi = x[i] + dx[i] * (pos - offset[i]);\n double yi = y[i] + dy[i] * (pos - offset[i]);\n\n double bestAfter = 1;\n for (int j = i + 1; j < n; ++j) {\n auto eval2 = [&](double t) {\n double xj = x[j] + dx[j] * t;\n double yj = y[j] + dy[j] * t;\n double direct = (offset[j] + t) - pos;\n return direct / max(1e-7, hypot(xi - xj, yi - yj));\n };\n double cur = ternary(eval2, 0, len[j]);\n bestAfter = max(bestAfter, cur);\n }\n return bestAfter;\n };\n\n auto eval = [&](double pos) {\n return min(evalBefore(pos), evalAfter(pos));\n };\n\n\n double STEP = total;\n vector> best;\n while (clock() / (double) CLOCKS_PER_SEC < start + 1) {\n STEP *= 0.5;\n for (double at = STEP; at <= total; at += STEP * 2) {\n best.emplace_back(eval(at), where(at), at);\n }\n }\n sort(all(best));\n\n auto reduce = [&]() {\n sort(all(best), [](const auto& a, const auto& b) {\n return get<0>(a) > get<0>(b);\n });\n int got = 0;\n vector gotIn(n);\n for (int i = 0; i < best.size(); ++i) {\n if (got < BUBEN3 && gotIn[get<1>(best[i])] < BUBEN2) {\n best[got] = best[i];\n ++got;\n ++gotIn[get<1>(best[i])];\n }\n }\n best.resize(got);\n };\n\n while (clock() / (double) CLOCKS_PER_SEC < start + 3) {\n reduce();\n STEP *= 0.5;\n sort(all(best), [](const auto& a, const auto& b) {\n return get<2>(a) < get<2>(b);\n });\n int old = best.size();\n double prev = 0;\n for (int i = 0; i <= old; ++i) {\n double cur;\n if (i == old) {\n cur = total;\n } else {\n cur = get<2>(best[i]);\n }\n if (cur - prev > 3 * STEP) {\n double at = prev + STEP;\n best.emplace_back(eval(at), where(at), at);\n at = cur - STEP;\n best.emplace_back(eval(at), where(at), at);\n } else if (cur - prev > 2 * STEP) {\n double at = (2 * prev + cur) / 3;\n best.emplace_back(eval(at), where(at), at);\n at = (prev + 2 * cur) / 3;\n best.emplace_back(eval(at), where(at), at);\n } else if (cur - prev > STEP) {\n double at = (prev + cur) / 2;\n best.emplace_back(eval(at), where(at), at);\n }\n prev = cur;\n }\n }\n\n cerr << STEP << endl;\n\n double res = 0;\n for (const auto& x : best) {\n res = max(res, get<0>(x));\n }\n out << res << \"\\n\";\n }\n\n\n\n void solve(std::istream &in, std::ostream &out) {\n out.precision(20);\n int nt = 1;\n for (int it = 0; it < nt; ++it) {\n solveOne(in, out);\n }\n }\n};\n\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n TaskH solver;\n std::istream& in(std::cin);\n std::ostream& out(std::cout);\n solver.solve(in, out);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "47ff7fa31a020e3b2832801729f63b2d", "src_uid": "ee115d3f08a53c52db3e429ad0cee906", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "/**\n * code generated by JHelper\n * More info: https://github.com/AlexeyDmitriev/JHelper\n * @author\n */\n\n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define pb push_back\n#define sz(v) ((int)(v).size())\n#define all(v) (v).begin(),(v).end()\n#define mp make_pair\n\nusing namespace std;\n\ntypedef long long int64;\ntypedef vector vi;\ntypedef pair ii;\n\nint BUBEN = 30;\nint BUBEN2 = 5;\nint BUBEN3 = 20;\n\nclass TaskH {\n public:\n void solveOne(istream &in, ostream &out) {\n double start = clock() / (double) CLOCKS_PER_SEC;\n\n int n;\n in >> n;\n vector x(n + 1);\n vector y(n + 1);\n for (int i = 0; i <= n; ++i) {\n in >> x[i] >> y[i];\n }\n vector offset;\n vector len;\n vector dx;\n vector dy;\n offset.push_back(0);\n for (int i = 0; i < n; ++i) {\n double vx = x[i + 1] - x[i];\n double vy = y[i + 1] - y[i];\n double z = hypot(vx, vy);\n dx.push_back(vx / z);\n dy.push_back(vy / z);\n len.push_back(z);\n offset.push_back(offset.back() + z);\n }\n auto ternary = [&](const auto& func, double left, double right) {\n while (right - left > 1e-12 * max(1.0, right)) {\n double mleft = (2 * left + right) / 3;\n double mright = (left + 2 * right) / 3;\n double vleft = func(mleft);\n double vright = func(mright);\n if (vleft > vright) {\n right = mright;\n } else {\n left = mleft;\n }\n }\n return func((left + right) / 2);\n };\n double total = offset.back();\n\n auto where = [&](double pos) {\n int i = lower_bound(all(offset), pos) - offset.begin() - 1;\n if (i < 0) i = 0;\n if (i >= n) i = n - 1;\n return i;\n };\n\n auto evalBefore = [&](double pos) {\n int i = where(pos);\n double xi = x[i] + dx[i] * (pos - offset[i]);\n double yi = y[i] + dy[i] * (pos - offset[i]);\n\n double bestBefore = 1;\n for (int j = 0; j < i; ++j) {\n auto eval2 = [&](double t) {\n double xj = x[j] + dx[j] * t;\n double yj = y[j] + dy[j] * t;\n double direct = pos - (offset[j] + t);\n return direct / max(1e-7, hypot(xi - xj, yi - yj));\n };\n double cur = ternary(eval2, 0, len[j]);\n bestBefore = max(bestBefore, cur);\n }\n return bestBefore;\n };\n\n auto evalAfter = [&](double pos) {\n int i = where(pos);\n double xi = x[i] + dx[i] * (pos - offset[i]);\n double yi = y[i] + dy[i] * (pos - offset[i]);\n\n double bestAfter = 1;\n for (int j = i + 1; j < n; ++j) {\n auto eval2 = [&](double t) {\n double xj = x[j] + dx[j] * t;\n double yj = y[j] + dy[j] * t;\n double direct = (offset[j] + t) - pos;\n return direct / max(1e-7, hypot(xi - xj, yi - yj));\n };\n double cur = ternary(eval2, 0, len[j]);\n bestAfter = max(bestAfter, cur);\n }\n return bestAfter;\n };\n\n auto eval = [&](double pos) {\n return min(evalBefore(pos), evalAfter(pos));\n };\n\n\n double STEP = total;\n vector> best;\n while (clock() / (double) CLOCKS_PER_SEC < start + 1) {\n STEP *= 0.5;\n for (double at = STEP; at <= total; at += STEP * 2) {\n best.emplace_back(eval(at), where(at), at);\n }\n }\n sort(all(best));\n\n auto reduce = [&]() {\n sort(all(best), [](const auto& a, const auto& b) {\n return get<0>(a) > get<0>(b);\n });\n int got = 0;\n vector gotIn(n);\n for (int i = 0; i < best.size(); ++i) {\n if (got < BUBEN3 && gotIn[get<1>(best[i])] < BUBEN2) {\n best[got] = best[i];\n ++got;\n ++gotIn[get<1>(best[i])];\n }\n }\n best.resize(got);\n };\n\n while (clock() / (double) CLOCKS_PER_SEC < start + 3) {\n reduce();\n STEP *= 0.5;\n sort(all(best), [](const auto& a, const auto& b) {\n return get<2>(a) < get<2>(b);\n });\n int old = best.size();\n double prev = 0;\n for (int i = 0; i <= old; ++i) {\n double cur;\n if (i == old) {\n cur = total;\n } else {\n cur = get<2>(best[i]);\n }\n if (cur - prev > 3 * STEP) {\n double at = prev + STEP;\n best.emplace_back(eval(at), where(at), at);\n at = cur - STEP;\n best.emplace_back(eval(at), where(at), at);\n } else if (cur - prev > 2 * STEP) {\n double at = (2 * prev + cur) / 3;\n best.emplace_back(eval(at), where(at), at);\n at = (prev + 2 * cur) / 3;\n best.emplace_back(eval(at), where(at), at);\n } else if (cur - prev > STEP) {\n double at = (prev + cur) / 2;\n best.emplace_back(eval(at), where(at), at);\n }\n prev = cur;\n }\n }\n\n cerr << STEP << endl;\n\n double res = 0;\n for (const auto& x : best) {\n res = max(res, get<0>(x));\n }\n out << res << \"\\n\";\n }\n\n\n\n void solve(std::istream &in, std::ostream &out) {\n out.precision(20);\n int nt = 1;\n for (int it = 0; it < nt; ++it) {\n solveOne(in, out);\n }\n }\n};\n\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n TaskH solver;\n std::istream& in(std::cin);\n std::ostream& out(std::cout);\n solver.solve(in, out);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5b4aaeb6fbdb6a14da3022502b6fd615", "src_uid": "ee115d3f08a53c52db3e429ad0cee906", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n \nusing ll = long long;\nusing ld = long double;\nusing db = double; \nusing str = string; // yay python!\n\nusing pi = pair;\nusing pl = pair;\nusing pd = pair;\n\nusing vi = vector;\nusing vb = vector;\nusing vl = vector;\nusing vd = vector; \nusing vs = vector;\nusing vpi = vector;\nusing vpl = vector; \nusing vpd = vector;\n\n#define tcT template using V = vector; \ntcT, size_t SZ> using AR = array; \n\n// pairs\n#define mp make_pair\n#define f first\n#define s second\n\n// vectors\n#define sz(x) (int)(x).size()\n#define all(x) begin(x), end(x)\n#define rall(x) (x).rbegin(), (x).rend() \n#define sor(x) sort(all(x)) \n#define rsz resize\n#define ins insert \n#define ft front() \n#define bk back()\n#define pf push_front \n#define pb push_back\n#define eb emplace_back \n#define lb lower_bound \n#define ub upper_bound \n\n// loops\n#define FOR(i,a,b) for (int i = (a); i < (b); ++i)\n#define F0R(i,a) FOR(i,0,a)\n#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)\n#define R0F(i,a) ROF(i,0,a)\n#define trav(a,x) for (auto& a: x)\n\nconst int MOD = 1e9+7; // 998244353;\nconst int MX = 2e5+5;\nconst ll INF = 1e18; // not too close to LLONG_MAX\nconst ld PI = acos((ld)-1);\nconst int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; // for every grid problem!!\nmt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); \n\n// helper funcs\nconstexpr int pct(int x) { return __builtin_popcount(x); } // # of bits set\nconstexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) \nll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up\nll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down\n\ntcT> bool ckmin(T& a, const T& b) {\n\treturn b < a ? a = b, 1 : 0; } // set a = min(a,b)\ntcT> bool ckmax(T& a, const T& b) {\n\treturn a < b ? a = b, 1 : 0; }\n\n#define tcTU tcT, class U\ntcTU> T fstTrue(T lo, T hi, U f) {\n\thi ++; assert(lo <= hi); // assuming f is increasing\n\twhile (lo < hi) { // find first index such that f is true \n\t\tT mid = lo+(hi-lo)/2;\n\t\tf(mid) ? hi = mid : lo = mid+1; \n\t} \n\treturn lo;\n}\ntcTU> T lstTrue(T lo, T hi, U f) {\n\tlo --; assert(lo <= hi); // assuming f is decreasing\n\twhile (lo < hi) { // find first index such that f is true \n\t\tT mid = lo+(hi-lo+1)/2;\n\t\tf(mid) ? lo = mid : hi = mid-1;\n\t} \n\treturn lo;\n}\ntcT> void remDup(vector& v) { // sort and remove duplicates\n\tsort(all(v)); v.erase(unique(all(v)),end(v)); }\ntcTU> void erase(T& t, const U& u) { // don't erase\n\tauto it = t.find(u); assert(it != end(t));\n\tt.erase(u); } // element that doesn't exist from (multi)set\n\n// INPUT\n#define tcTUU tcT, class ...U\ntcT> void re(complex& c);\ntcTU> void re(pair& p);\ntcT> void re(vector& v);\ntcT, size_t SZ> void re(AR& a);\n\ntcT> void re(T& x) { cin >> x; }\nvoid re(db& d) { str t; re(t); d = stod(t); }\nvoid re(ld& d) { str t; re(t); d = stold(t); }\ntcTUU> void re(T& t, U&... u) { re(t); re(u...); }\n\ntcT> void re(complex& c) { T a,b; re(a,b); c = {a,b}; }\ntcTU> void re(pair& p) { re(p.f,p.s); }\ntcT> void re(vector& x) { trav(a,x) re(a); }\ntcT, size_t SZ> void re(AR& x) { trav(a,x) re(a); }\n\n// TO_STRING\n#define ts to_string\nstr ts(char c) { return str(1,c); }\nstr ts(const char* s) { return (str)s; }\nstr ts(str s) { return s; }\nstr ts(bool b) { \n\t#ifdef LOCAL\n\t\treturn b ? \"true\" : \"false\"; \n\t#else \n\t\treturn ts((int)b);\n\t#endif\n}\ntcT> str ts(complex c) { \n\tstringstream ss; ss << c; return ss.str(); }\nstr ts(vector v) {\n\tstr res = \"{\"; F0R(i,sz(v)) res += char('0'+v[i]);\n\tres += \"}\"; return res; }\ntemplate str ts(bitset b) {\n\tstr res = \"\"; F0R(i,SZ) res += char('0'+b[i]);\n\treturn res; }\ntcTU> str ts(pair p);\ntcT> str ts(T v) { // containers with begin(), end()\n\t#ifdef LOCAL\n\t\tbool fst = 1; str res = \"{\";\n\t\tfor (const auto& x: v) {\n\t\t\tif (!fst) res += \", \";\n\t\t\tfst = 0; res += ts(x);\n\t\t}\n\t\tres += \"}\"; return res;\n\t#else\n\t\tbool fst = 1; str res = \"\";\n\t\tfor (const auto& x: v) {\n\t\t\tif (!fst) res += \" \";\n\t\t\tfst = 0; res += ts(x);\n\t\t}\n\t\treturn res;\n\n\t#endif\n}\ntcTU> str ts(pair p) {\n\t#ifdef LOCAL\n\t\treturn \"(\"+ts(p.f)+\", \"+ts(p.s)+\")\"; \n\t#else\n\t\treturn ts(p.f)+\" \"+ts(p.s);\n\t#endif\n}\n\n// OUTPUT\ntcT> void pr(T x) { cout << ts(x); }\ntcTUU> void pr(const T& t, const U&... u) { \n\tpr(t); pr(u...); }\nvoid ps() { pr(\"\\n\"); } // print w/ spaces\ntcTUU> void ps(const T& t, const U&... u) { \n\tpr(t); if (sizeof...(u)) pr(\" \"); ps(u...); }\n\n// DEBUG\nvoid DBG() { cerr << \"]\" << endl; }\ntcTUU> void DBG(const T& t, const U&... u) {\n\tcerr << ts(t); if (sizeof...(u)) cerr << \", \";\n\tDBG(u...); }\n#ifdef LOCAL // compile with -DLOCAL, chk -> fake assert\n\t#define dbg(...) cerr << \"Line(\" << __LINE__ << \") -> [\" << #__VA_ARGS__ << \"]: [\", DBG(__VA_ARGS__)\n\t#define chk(...) if (!(__VA_ARGS__)) cerr << \"Line(\" << __LINE__ << \") -> function(\" \\\n\t\t << __FUNCTION__ << \") -> CHK FAILED: (\" << #__VA_ARGS__ << \")\" << \"\\n\", exit(0);\n#else\n\t#define dbg(...) 0\n\t#define chk(...) 0\n#endif\n\n// FILE I/O\nvoid setIn(str s) { freopen(s.c_str(),\"r\",stdin); }\nvoid setOut(str s) { freopen(s.c_str(),\"w\",stdout); }\nvoid unsyncIO() { cin.tie(0)->sync_with_stdio(0); }\nvoid setIO(str s = \"\") {\n\tunsyncIO();\n\t// cin.exceptions(cin.failbit); \n\t// throws exception when do smth illegal\n\t// ex. try to read letter into int\n\tif (sz(s)) { setIn(s+\".in\"), setOut(s+\".out\"); } // for USACO\n}\n\n/**\n * Description: Use in place of \\texttt{complex}.\n * Source: http://codeforces.com/blog/entry/22175, KACTL\n * Verification: various\n */\n\nusing T = db;\nint sgn(T a) { return (a>0)-(a<0); }\nT sq(T a) { return a*a; }\n\ntypedef pair P; typedef vector

    vP;\nT norm(const P& p) { return sq(p.f)+sq(p.s); }\nT abs(const P& p) { return sqrt(norm(p)); }\nT arg(const P& p) { return atan2(p.s,p.f); }\nP conj(const P& p) { return P(p.f,-p.s); }\nP perp(const P& p) { return P(-p.s,p.f); }\nP dir(T ang) { return P(cos(ang),sin(ang)); }\n\nP operator-(const P& l) { return P(-l.f,-l.s); }\nP operator+(const P& l, const P& r) { \n\treturn P(l.f+r.f,l.s+r.s); }\nP operator-(const P& l, const P& r) { \n\treturn P(l.f-r.f,l.s-r.s); }\nP operator*(const P& l, const T& r) { \n\treturn P(l.f*r,l.s*r); }\nP operator*(const T& l, const P& r) { return r*l; }\nP operator/(const P& l, const T& r) { \n\treturn P(l.f/r,l.s/r); }\nP operator*(const P& l, const P& r) { \n\treturn P(l.f*r.f-l.s*r.s,l.s*r.f+l.f*r.s); }\nP operator/(const P& l, const P& r) { \n\treturn l*conj(r)/norm(r); }\nP& operator+=(P& l, const P& r) { return l = l+r; }\nP& operator-=(P& l, const P& r) { return l = l-r; }\nP& operator*=(P& l, const T& r) { return l = l*r; }\nP& operator/=(P& l, const T& r) { return l = l/r; }\nP& operator*=(P& l, const P& r) { return l = l*r; }\nP& operator/=(P& l, const P& r) { return l = l/r; }\n\nP unit(const P& p) { return p/abs(p); }\nT dot(const P& a, const P& b) { return a.f*b.f+a.s*b.s; }\nT cross(const P& a, const P& b) { return a.f*b.s-a.s*b.f; }\nT cross(const P& p, const P& a, const P& b) {\n\treturn cross(a-p,b-p); }\nP reflect(const P& p, const P& a, const P& b) { \n\treturn a+conj((p-a)/(b-a))*(b-a); }\nP foot(const P& p, const P& a, const P& b) { \n\treturn (p+reflect(p,a,b))/(T)2; }\nbool onSeg(const P& p, const P& a, const P& b) { \n\treturn cross(a,b,p) == 0 && dot(p-a,p-b) <= 0; }\n\nint N;\nvP poly;\nvd dists;\n\nvoid genDists() {\n\tdists = {0}; F0R(i,N) dists.pb(dists.bk+abs(poly[i]-poly[i+1]));\n}\n\nvoid rev() {\n\tdb maxY = poly.bk.s;\n\treverse(all(poly));\n\tgenDists();\n\ttrav(t,poly) t.s = maxY-t.s;\n}\n\nvP ans;\ndb vel;\n\nP ternary(db lo, db hi, function eval) {\n\tF0R(_,50) {\n\t\tdb m1 = (2*lo+hi)/3;\n\t\tdb m2 = (lo+2*hi)/3;\n\t\tif (eval(m1) < eval(m2)) hi = m2;\n\t\telse lo = m1;\n\t}\n\treturn {lo,eval(lo)};\n}\n\nvoid tri(int l, int r) {\n\tdbg(\"TRYING\",l,r,poly);\n\tassert(l < r);\n\tP dirl = unit(poly[l+1]-poly[l]), dirr = unit(poly[r+1]-poly[r]);\n\tauto eval = [&](db t1, db t2) {\n\t\tP pos1 = poly[l]+t1*dirl;\n\t\tP pos2 = poly[r]+t2*dirr;\n\t\treturn abs(pos2-pos1)/((dists[r]+t2)-(dists[l]+t1));\n\t};\n\tfunction getMin = [&](db rig) {\n\t\treturn ternary(0,dists[l+1]-dists[l],[&](db x) { return eval(x,rig); }).s;\n\t};\n\tP mid = ternary(0,dists[r+1]-dists[r],getMin);\n\t// dbg(\"HA\",mid);\n\t// dbg(\"???\",l,r,mid);\n\tif (mid.s > 1/vel) return;\n\t// dbg(\"WHOOPS\",mid,dists[r+1]-dists[r]);\n\tdb L, R;\n\t{\n\t\tdb lo = 0, hi = mid.f;\n\t\tF0R(_,50) {\n\t\t\tdb m = (lo+hi)/2;\n\t\t\tif (getMin(m) < 1/vel) hi = m;\n\t\t\telse lo = m;\n\t\t}\n\t\tL = lo;\n\t}\n\t// dbg(\"MIDDLE\");\n\t{\n\t\tdb lo = mid.f, hi = dists[r+1]-dists[r];\n\t\tF0R(_,50) {\n\t\t\tdb m = (lo+hi)/2;\n\t\t\tif (getMin(m) < 1/vel) lo = m;\n\t\t\telse hi = m;\n\t\t}\n\t\tR = lo;\n\t}\n\t// dbg(\"END\",L,R);\n\tans.pb({dists[r]+L,dists[r]+R});\n}\n\nvP ranges() {\n\t// dbg(\"RANGES\");\n\tans.clear();\n\tF0R(i,N) FOR(j,i+1,N) tri(i,j);\n\tsort(all(ans));\n\tvP ANS;\n\ttrav(t,ans) {\n\t\tif (!sz(ANS) || ANS.bk.s < t.f) ANS.pb(t);\n\t\telse ckmax(ANS.bk.s,t.s);\n\t}\n\treturn ANS;\n}\n\nbool intervalIsect(P a, P b) {\n\tif (a.s < b.f) return 0;\n\tif (b.s < a.f) return 0;\n\treturn 1;\n}\n\nbool escape(db mid) {\n\tvel = mid;\n\tvP lef = ranges();\n\trev();\n\tvP rig = ranges();\n\trev();\n\ttrav(t,rig) t = {dists.bk-t.s,dists.bk-t.f};\n\treverse(all(rig));\n\tdbg(\"ESCAPE\",mid);\n\tdbg(lef); dbg(rig);\n\tint il = 0, ir = 0;\n\twhile (il < sz(lef) && ir < sz(rig)) {\n\t\tif (intervalIsect(lef[il],rig[ir])) return 1;\n\t\tif (lef[il].f < rig[ir].f) il ++;\n\t\telse ir ++;\n\t}\n\treturn 0;\n}\n\nint main() {\n\tsetIO(); re(N); poly.rsz(N+1); re(poly);\n\tgenDists();\n\tdb lo = 1, hi = 1e6;\n\tF0R(i,50) {\n\t\tdb mid = (lo+hi)/2;\n\t\tif (escape(mid)) lo = mid;\n\t\telse hi = mid;\n\t}\n\tcout << fixed << setprecision(9) << lo;\n\t// you should actually read the stuff at the bottom\n}\n\n/* stuff you should look for\n\t* int overflow, array bounds\n\t* special cases (n=1?)\n\t* do smth instead of nothing and stay organized\n\t* WRITE STUFF DOWN\n\t* DON'T GET STUCK ON ONE APPROACH\n*/\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1ac85dabcdaf28aaf9ca082dc46cc033", "src_uid": "ee115d3f08a53c52db3e429ad0cee906", "difficulty": 3500.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\ntypedef long long Int;\nusing namespace std;\nInt H,M;\nint K;\nInt h1,m1,h2,m2;\nInt Comp(Int h,Int m);\nInt Cal(Int h,Int m);\nint CalDigit(Int so);\nInt Solve(Int so,int d);\nint main(){\n /*\n cin>>H>>M>>K;\n cin>>h1>>m1>>h2>>m2;\n if (Comp(h1,m1)<=Comp(h2,m2))\n {\n cout<=K)<0L)\n {\n d++;\n so/=10;\n }\n return d;\n}\nInt Comp(Int h,Int m)\n{\n return h*H+m;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fbea31b1c2e14274e89cabe3636812b7", "src_uid": "e2782743229645ad3a0f8e815d86dc5f", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "/*Studied from WJMZBMR*/\n#include\nusing namespace std;\n\nint h,m,k,h1,m1,h2,m2;\n\nint cut(int a,int b){for(;--b;a/=10);return a;}\n\nlong long ch(int a){for(int ret=0;;a/=10)if(a%10)ret++;else if(!a)return ret;}\n\nlong long calc(int a,int b){return cut(a,k-ch(m-1))+a*cut(m-1,k)+cut(b,k);}\n\nint main()\n{\n\tcin>>h>>m>>k>>h1>>m1>>h2>>m2;\n\tif(h1<=h2||h1==h2&&m1<=m2)cout<=k)-calc(h1,m1)+calc(h2,m2)<\n\nint main()\n{\n cout << \"hi\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b6b6207b44dddb9a7d2897266912f227", "src_uid": "e2782743229645ad3a0f8e815d86dc5f", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "d13d75551eee3e1caa5732d26fe1d51c", "src_uid": "e2782743229645ad3a0f8e815d86dc5f", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\n\nconst int N = 100005, M = 100005;\n\nint n, m, t1, t2, top, v[M], next[M], head[N], d[N];\nbool vis[N];\n\nint abss(const int i) {return i < 0 ? -i : i;}\n\nint gcd(const int x, const int y) {\n if (x == 0 || y == 0) return x + y;\n int a = x, b = y, c = a % b;\n while (c) {\n\t a = b;\n\t b = c;\n\t c = a % b;\n\t}\n\treturn b;\n}\n\nvoid dfs(const int i) {\n vis[i] = true;\n for (int j = head[i]; j; j = next[j]) {\n\t if (!vis[v[j]]) {\n\t\t d[v[j]] = d[i] + 1;\n\t\t dfs(v[j]);\n\t\t}\n\t}\n}\n\nint main() {\n scanf(\"%d %d\", &n, &m);\n for (int i = 1; i <= m; ++i) {\n\t\tscanf(\"%d %d\", &t1, &t2);\n\t\t++top; v[top] = t2; next[top] = head[t1]; head[t1] = top;\n\t}\n\tdfs(1);\n\tint tmp = 0;\n\tfor (int i = 1; i <= n; ++i) {\n\t\t//printf(\"D%d %d\\n\", i, d[i]);\n\t\tfor (int j = head[i]; j; j = next[j]) {\n\t\t tmp = gcd(tmp, abss(d[v[j]] - d[i] - 1));\n\t\t}\n\t}\n\tif (tmp == 0) tmp = n;\n\tprintf(\"%d\\n\", tmp);\n\tint cnt = 0;\n\tfor (int i = 1; i <= n; ++i) if (d[i] % tmp == 0) ++cnt;\n\tprintf(\"%d\\n\", cnt);\n\tfor (int i = 1; i <= n; ++i) if (d[i] % tmp == 0) printf(\"%d \", i);\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3b22cbbb3508a21714bea868ad85812f", "src_uid": "e13228fcdaa1c218581606ddfe186d52", "difficulty": 2500.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long LL;\ntypedef vector vi;\n#define FOR(i, n) for(int i = 0; i < (int)(n); ++i)\n\nvoid ASS(bool b)\n{\n\tif (!b)\n\t\t++*(int*)0;\n}\n\nconst int N = 1 << 17;\nint G;\nint f[N];\n//int OnStack[N];\nvi g[N];\n\nint gcd(int a, int b)\n{\n\tif (a < 0) a = -a;\n\tif (b < 0) b = -b;\n\twhile (a)\n\t{\n\t\tint c = b % a;\n\t\tb = a;\n\t\ta = c;\n\t}\n\treturn b;\n}\n\nint mabs(int x)\n{\n\treturn max(x, -x);\n}\n\nvoid dfs(int x, int d)\n{\n\tf[x] = d;\n\tFOR(i, g[x].size())\n\t{\n\t\tint y = g[x][i];\n\t\tif (f[y])\n\t\t\tG = gcd(G, mabs(f[y] - d) - 1);\n\t\telse\n\t\t\tdfs(y, d + 1);\n\t}\n}\n\nint main()\n{\n\tint n, m;\n\tscanf(\"%d %d\", &n, &m);\n\tFOR(i, m)\n\t{\n\t\tint x, y;\n\t\tscanf(\"%d %d\", &x, &y);\n\t\tg[x].push_back(y);\n\t}\n\tdfs(1, 1);\n//\tif (G == 0)\n\tASS(g != 0);\n\n\t//memset(f, 0, sizeof(f));\n\t//dfs2(x, 0);\n\n\tvi v;\n\tfor (int i = 1; i <= n; i++)\n\t\tif (f[i] && (f[i] - 1) % G == 0)\n\t\t\tv.push_back(i);\n\n\tprintf(\"%d\\n\", G);\n\tprintf(\"%d\\n\", v.size());\n\tFOR(i, v.size())\n\t{\n\t\tif (i) printf(\" \");\n\t\tprintf(\"%d\", v[i]);\n\t}\n\tprintf(\"\\n\");\n\n\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "acfc4b5c63dd2c9909172750afacc0e0", "src_uid": "e13228fcdaa1c218581606ddfe186d52", "difficulty": 2500.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\n\nconst int N = 100005, M = 100005;\n\nint n, m, t1, t2, top, v[M], next[M], head[N], d[N];\nbool vis[N];\n\nint abss(const int i) {return i < 0 ? -i : i;}\n\nint gcd(const int x, const int y) {\n if (x == 0 || y == 0) return x + y;\n int a = x, b = y, c = a % b;\n while (c) {\n\t a = b;\n\t b = c;\n\t c = a % b;\n\t}\n\treturn b;\n}\n\nvoid dfs(const int i) {\n vis[i] = true;\n for (int j = head[i]; j; j = next[j]) {\n\t if (!vis[v[j]]) {\n\t\t d[v[j]] = d[i] + 1;\n\t\t dfs(v[j]);\n\t\t}\n\t}\n}\n\nint main() {\n scanf(\"%d %d\", &n, &m);\n for (int i = 1; i <= m; ++i) {\n\t\tscanf(\"%d %d\", &t1, &t2);\n\t\t++top; v[top] = t2; next[top] = head[t1]; head[t1] = top;\n\t}\n\tdfs(1);\n\tint tmp = 0;\n\tfor (int i = 1; i <= n; ++i) {\n\t\tfor (int j = head[i]; j; j = next[j]) {\n\t\t tmp = gcd(tmp, abss(d[i] + d[v[j]] - 1));\n\t\t}\n\t}\n\tprintf(\"%d\\n\", tmp);\n\tint cnt = 0;\n\tfor (int i = 1; i <= n; ++i) if (d[i] % tmp == 0) ++cnt;\n\tprintf(\"%d\\n\", cnt);\n\tfor (int i = 1; i <= n; ++i) if (d[i] % tmp == 0) printf(\"%d \", i);\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "88cb1911501086f393ce9890dd0b64ce", "src_uid": "e13228fcdaa1c218581606ddfe186d52", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nconst int N = 2.1e5;\nint n, m, g;\nvector a[N];\nint d[N];\n\nvoid dfs(int v) {\n for (int x : a[v]) {\n if (x > 1 && !d[x]) {\n d[x] = d[v] + 1;\n dfs(x);\n } else if (d[x] != d[v] + 1) {\n int dd = abs(d[v] + 1 - d[x]);\n if (!g) g = dd; else g = __gcd(g, dd);\n }\n }\n}\n\nint main() {\n scanf(\"%d%d\", &n, &m);\n for (int i = 0; i < m; ++i) {\n int x, y;\n scanf(\"%d%d\", &x, &y);\n a[x].push_back(y);\n }\n dfs(1);\n if (!g) g = *max_element(d+1, d+n+1);\n vector ans;\n for (int i = 1; i <= n; ++i) {\n if (d[i] % g == 0) ans.push_back(i);\n }\n cout << g << endl << ans.size() << endl;\n for (int i = 0; i < n; ++i)\n cout << and[i] << (i == n-1 ? \"\\n\" : \" \");\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3f6e510aa32471467af04726ab001040", "src_uid": "e13228fcdaa1c218581606ddfe186d52", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n \nmt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());\n \n#define int long long\n#define ll long long\n#define mp make_pair\n#define f first\n#define s second\n#define pii pair\n#define all(_v) _v.begin(), _v.end()\n#define sz(a) ((int)a.size())\n#define what_is(x) cout << #x << \" is \" << x << endl;\ntypedef long double ld;\n \nconst ll inf = 1e17 + 7;\n\nbool win(int a, int b) {\n return a != 0;\n}\n\nbool lose(int a, int b) {\n return a % (b + 1) % 2 == 0;\n}\n\nvoid solve() {\n int a, b;\n cin >> a >> b;\n vector c;\n\n while(a != 0 && b != 0) {\n if (a < b) swap(a, b);\n c.emplace_back(a / b, b);\n a = a % b;\n }\n\n bool to_win = true;\n for(int i = c.size() - 1;i >= 0;i--) {\n if (to_win) {\n to_win = !win(c[i].first, c[i].second);\n }else {\n to_win = !lose(c[i].first, c[i].second);\n }\n }\n\n cout << (!to_win ? \"First\" : \"Second\") << endl;\n}\n\n\nsigned main() {\n cin.tie(0);\n cout.tie(0);\n ios_base::sync_with_stdio(0);\n cout.precision(10);\n\n int t;\n cin >> t;\n while(t--)\n solve();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4c0f409ad8610f3ccd04a31689e8d131", "src_uid": "5f5b320c7f314bd06c0d2a9eb311de6c", "difficulty": 2300.0} {"lang": "GNU C++", "source_code": "E#include\n#include\nusing namespace std;\n#define i64 __int64\nint d[110][110];\nint dp(int a,int b)\n{\n if(d[a][b]!=-1) return d[a][b];\n if(!b) return d[a][b]=0;\n if(a%b==0) return d[a][b]=1;\n if(!dp(b,a%b)) return d[a][b]=1;\n int cur=b;\n while(cur<=a)\n {\n if(!dp(max(a-cur,b),min(a-cur,b)))\n return d[a][b]=1;\n cur*=a;\n }\n return d[a][b]=0;\n}\nbool dfs(i64 a,i64 b)\n{\n if(b==0) return false;\n if(a%(b*2)20)continue;\n if(n==20){ printf(\"First\\n\"); break; }\n scanf(\"%I64d %I64d\",&a,&b);\n if(dfs(max(a,b),min(a,b)))\n printf(\"First\\n\");\n else\n printf(\"Second\\n\");\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "2868e6c4e1ed54e16b63a1e73336e91a", "src_uid": "5f5b320c7f314bd06c0d2a9eb311de6c", "difficulty": 2300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair pii;\n\nmap cache;\n\nbool gana(ll a,ll b){\n map::iterator it;\n if((it=cache.find(pii(a,b)))!=cache.end()) return it->second;\n if(b=0){\n if(!gana(a,b-k)){ cache[pii(a,b)]=true; return true;}\n k*=a;\n }\n \n cache[pii(a,b)]=false;\n return false;\n}\n\nint main(){\n int T;\n cin>>T;\n ll a,b;\n for(int i=0;i> a >> b ;\n if(gana(a,b)){\n puts(\"First\");\n }else puts(\"Second\");\n }\n \n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0294ce8ebd7bff6beeea50f599f50c63", "src_uid": "5f5b320c7f314bd06c0d2a9eb311de6c", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define gc getchar_unlocked\n#define fo(i,n) for(i=0;i\tpii;\ntypedef pair\tpll;\ntypedef vector\t\tvi;\ntypedef vector\t\tvl;\ntypedef vector\t\tvpii;\ntypedef vector\t\tvpll;\ntypedef vector\t\tvvi;\ntypedef vector\t\tvvl;\nconst int mod = 1000000007;\nconst int N = 3e5;\nvi g[N];\nint a[N];\nint mpow(int base, int exp);\nvoid ipgraph(int n, int m);\nvoid dfs(int u, int par);\nmap dp;\nint go(ll a, ll b){\n if (a < b) swap(a, b);\n if (dp.find({a, b}) != dp.end()) return dp[{a, b}];\n if (b == 0) return 0;\n if (b == 1) return 1;\n int ans = go(a%b, b);\n if (!ans) return dp[{a, b}] = 1;\n ll b_ = b;\n while(b_ < a){\n if ( go(a-b_, b_) == 0) return dp[{a, b}] = 1;\n if (a/b_ > b)\n b_ *= b;\n else break;\n }\n return dp[{a, b}] = 0;\n}\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tint i,n,k,j;\n\tint t;\n\tcin>>t;\n\twhile(t--){\n ll x, y;\n cin>>x>>y;\n int win = go(x, y);\n if (win) cout<<\"First\\n\";\n else cout<<\"Second\\n\";\n\t}\n\n\n\treturn 0;\n}\n\nint mpow(int base, int exp) {\nbase %= mod;\nint result = 1;\nwhile (exp > 0) {\nif (exp & 1) result = ((ll)result * base) % mod;\nbase = ((ll)base * base) % mod;\nexp >>= 1;\n}\nreturn result;\n}\n\nvoid ipgraph(int n, int m){\nint i, u, v;\nwhile(m--){\n\tcin>>u>>v;\n\tg[u-1].pb(v-1);\n\tg[v-1].pb(u-1);\n}\n}\n\nvoid dfs(int u, int par){\nfor(int v:g[u]){\n\tif (v == par) continue;\n\tdfs(v, u);\n}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b384c62e8815af27dccc27629cf1ccdd", "src_uid": "5f5b320c7f314bd06c0d2a9eb311de6c", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n\n#define LL long long\n#define N 1000002\n#define M 1000100\n#define MP make_pair\n#define Pi acos(-1.0)\n//#pragma comment(linker,\"/STACK:1024000000,1024000000\")\n#define ls (rt << 1)\n#define rs (ls | 1)\n#define md ((ll+rr)/2)\n#define lson ll, md, ls\n#define rson md+1, rr, rs\n#define mod 1000000007\n#define inf 0x3f3f3f3f\n#define sqr(x) ((x)*(x))\n#define eps 1e-6\n#define uLL unsigned long long\n#define ui unsigned int\nLL powmod(LL a,LL b) {LL res=1;for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}\n#define F(x) ((x)/3+((x)%3 == 1 ? 0 : tb))\n#define G(x) ((x)\n#define pli pair\n#define pb push_back\n#define MP make_pair\nLL gcd(LL x,LL y){\n while(y){\n LL t = x % y;\n x = y;\n y = t;\n }\n return x;\n}\n\ntemplate inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }\ntemplate inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }\n\nui read()\n{\n ui x=0,f=1;char ch=getchar();\n while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}\n while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}\n return x*f;\n}\n\nint n, tot, dfn[N], fa[N][20], ed[N], dep[N];\nint bel[N], belong[N];\nvector g[N];\n\n\nvoid dfs(int u, int id)\n{\n\tbel[u] = id;\n\tdfn[u] = ++tot;\n\tfor(int i = 1; i < 20; i++)\n\t{\n\t\tfa[u][i] = fa[fa[u][i - 1]][i - 1];\n\t}\n\tfor(auto v : g[u])\n\t{\n\t\tif(v == fa[u][0]) continue;\n\t\tfa[v][0] = u;\n\t\tdep[v] = dep[u] + 1;\n\t\tdfs(v, id);\n\t}\n\ted[u] = tot;\n}\n\nint lca(int u, int v)\n{\n\tif(bel[u] != bel[v]) return -1;\n\tif(dep[u] > dep[v]) swap(u, v);\n\tfor(int i = 0; dep[u] != dep[v]; i++)\n\t\tif((dep[v] - dep[u]) >> i & 1) v = fa[v][i];\n\tif(u == v) return v;\n\tfor(int i = 19; i >= 0; i--)\n\t\tif(fa[u][i] != fa[v][i])\n\t\t{\n\t\t\tu = fa[u][i];\n\t\t\tv = fa[v][i];\n\t\t}\n\treturn fa[u][0];\n}\n\ninline bool cmp(int i, int j){return dfn[i] < dfn[j];}\n\nstruct BCC\n{\n\tint fst[N], nxt[M], vv[M], e;\n\tint n, belong[N], dfn[N], low[N], stk[N], tot, in[N];\n\tvoid init()\n\t{\n\t\te = 0;\n\t\tmemset(fst, -1, sizeof fst);\n\t\tmemset(dfn, -1, sizeof dfn);\n\t}\n\n\tvoid add(int u, int v)\n\t{\n\t\tvv[e] = v, nxt[e] = fst[u], fst[u] = e++;\n\t\tvv[e] = u, nxt[e] = fst[v], fst[v] = e++;\n\t}\n\n\n\tvoid dfs(int u, int f = -1)\n\t{\n\t\tint tmp = tot;\n\t\tstk[dfn[u] = low[u] = tot++] = u;\n\t\tin[u] = 1;\n\t\tfor(int i = fst[u]; ~i; i = nxt[i])\n\t\t{\n\t\t\tif(i == f) continue;\n\t\t\tint v = vv[i];\n\t\t\tif(dfn[v] == -1) dfs(v, i ^ 1), chkmin(low[u], low[v]);\n\t\t\telse if(in[v]) chkmin(low[u], dfn[v]);\n\t\t}\n\t\tif(dfn[u] == low[u])\n\t\t{\n\t\t\twhile(tot != tmp)\n\t\t\t{\n\t\t\t\ttot--;\n\t\t\t\tin[stk[tot]] = 0;\n\t\t\t\tbelong[stk[tot]] = n;\n\t\t\t}\n\t\t\tn++;\n\t\t}\n\t}\n}bcc;\n\nint stk[N];\n\nint main()\n{\n\tn = read();\n\tint m = read(), q = read();\n\tbcc.init();\n\tvector< pii > E;\n\tfor(int i = 0; i < m; i++)\n\t{\n\t\tint u = read(), v = read();\n\t\tbcc.add(u, v);\n\t\tE.pb(MP(u,v));\n\t}\n\tbcc.n = bcc.tot = 1;\n\tfor(int i = 1; i <= n; i++)\n\t\tif(bcc.dfn[i] == -1) bcc.dfs(i);\n\tfor(int i = 1; i <= n; i++)\n\t{\n\t\tbelong[i] = bcc.belong[i];\n\t}\n\t\n\tfor(auto x : E)\n\t{\n\t\tint u = x.fi, v = x.se;\n\t\tif(belong[u] != belong[v])\n\t\t{\n\t\t\tg[belong[u]].pb(belong[v]), g[belong[v]].pb(belong[u]);\n\t\t}\n\t}\n\n\tfor(int i = 1; i <= n; i++)\n\t\tif(!dfn[i]) dfs(i, i);\n\n\tint R = 0, id = 1;\n\tfor(; q; q--, id++)\n\t{\n\t\tint nn = read(), mm = read();\n\t\tvector x;\n\t\tx.resize(nn);\n\t\tfor(int i = 0; i < nn; i++)\n\t\t{\n\t\t\tx[i] = (read() + R) % n, x[i] = belong[x[i] == 0 ? n : x[i]];\n\t\t}\n\t\tvector< pii > ee;\n\t\tvector< int > V(x);\n\t\tfor(int i = 0 ; i < mm; i++)\n\t\t{\n\t\t\tint u = (read() + R) % n, v = (read() + R) % n;\n\t\t\tu = belong[u == 0 ? n : u], v = belong[v == 0 ? n : v];\n\t\t\tee.pb(MP(u, v));\n\t\t\tV.pb(u) , V.pb(v);\n\t\t}\n\t\tsort(V.begin(), V.end(), cmp);\n\t\tnn = V.size();\n\t\tfor(int i = 0; i < nn - 1; i++)\n\t\t{\n\t\t\tif(V[i] == V[i + 1]) continue;\n\t\t\tint lc = lca(V[i], V[i + 1]);\n\t\t\tif(lc > 0) V.pb(lc);\n\t\t}\n\t\tsort(V.begin(), V.end(), cmp);\n\t\tV.resize(unique(V.begin(), V.end()) - V.begin());\n\t\tnn = V.size();\n\t\t\n\t\tfor(int i = 0; i < nn; i++)\n\t\t\tbcc.fst[V[i]] = -1; bcc.e = 0;\n\t\ttot = 0;\n\t\tfor(int i = 0; i < nn; i++)\n\t\t{\n\t\t\tint u = V[i];\n\t\t\twhile(tot && !(dfn[stk[tot - 1]] <= dfn[u] && dfn[u] <= ed[stk[tot - 1]])) tot--;\n\t\t\tif(tot) { bcc.add(u, stk[tot - 1]);}\n\t\t\tstk[tot++] = u;\n\t\t}\n\t\tfor(auto u : ee)\n\t\t\tbcc.add(u.fi, u.se);\n\t\tbcc.tot = bcc.n = 1;\n\t\tfor(int i = 0; i < nn; i++) bcc.dfn[V[i]] = -1;\n\t\tfor(int i = 0; i < nn; i++)\n\t\t\tif(bcc.dfn[V[i]] == -1) bcc.dfs(V[i]);\n\t\tbool ans = 1;\n\t\t\n\t\tfor(int i = 1; i < x.size(); i++)\n\t\t\tif(bcc.belong[x[i]] != bcc.belong[x[0]]) \n\t\t\t{\n\t\t\t\tans = 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\tputs(ans ? \"YES\" : \"NO\");\n\t\tR = (R + (ans ? id : 0)) % n;\n\t}\n\treturn 0;\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9eae18572624c6c94dda571bf46906b9", "src_uid": "53f64841886b32816eadce278e636bbc", "difficulty": 3300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint nmem=0;\nint *memdir[5000000];\nint memval[5000000];\n\nvoid asigna(int &a,int b)\n{\n memdir[nmem]=&a;\n memval[nmem]=a;\n a=b;\n nmem++;\n if (nmem>=5000000) {\n cout<<\"pifia\"<0) {\n nmem--;\n *(memdir[nmem])=memval[nmem];\n }\n}\n\nconst int limite=600005;\n\nvoid inserta(vector &alcanza,int pos,int val,int primero)\n{\n pos+=primero;\n asigna(alcanza[pos],val);\n while (pos>1) {\n pos/=2;\n asigna(alcanza[pos],max(alcanza[2*pos],alcanza[2*pos+1]));\n }\n}\n\nint alcanzaanterior(vector &alcanza,int pos,int primero)\n{\n pos+=primero;\n if (alcanza[pos]) return pos-primero;\n for (;;) {\n if (pos==1) return -1;\n if (pos%2==1 and alcanza[pos-1]) {\n pos--;\n while (pos minimo[1<<21];\n\nvoid inserta(int pos,int val,int u)\n{\n pos+=1<<20;\n minimo[pos]=pair (val,u);\n while (pos>1) {\n pos/=2;\n minimo[pos]=min(minimo[2*pos],minimo[2*pos+1]);\n }\n}\n\nint minimoentre(int pos0,int pos1)\n{\n if (pos0>pos1) swap(pos0,pos1);\n pos0+=1<<20;\n pos1+=1<<20;\n if (pos0==pos1) return minimo[pos0].second;\n pair mini0=minimo[pos0];\n pair mini1=minimo[pos1];\n while (pos0+1 g[limite];\nvector > gg[limite];\nvector alcanza[limite];\nvector elemento[limite];\nint au[limite],av[limite],apendiente[limite];\nint superidentificador[limite];\nint superpadre[limite];\nint superraiz[limite];\nint superposicion[limite];\nint primero[limite];\nint tope[limite];\nint visto[limite];\nint numnodos[limite];\nint profundidad[limite];\n\nint s[limite];\n\nint posle[limite];\nint nrecorrido=0;\n\nint ancestro(int u,int v)\n{\n return minimoentre(posle[u],posle[v]);\n}\n\nvoid eliminapadre(int u,int p,int prof)\n{\n visto[u]=1;\n profundidad[u]=prof;\n posle[u]=nrecorrido;\n inserta(nrecorrido++,profundidad[u],u);\n vector &ar=g[u];\n vector nextar;\n numnodos[u]=1;\n for (int i=0;i lista;\n lista.push_back(u);\n for (;;) {\n vector &ar=g[u];\n int nextu=0;\n for (int i=0;i=numnodos[u]) nextu=v;\n else genera(v,sr,u);\n }\n if (nextu==0) break;\n u=nextu;\n lista.push_back(u);\n }\n u=lista[0];\n {\n int nn=int(lista.size())+3;\n primero[u]=1;\n while (nn>0) {\n nn/=2;\n primero[u]*=2;\n }\n tope[u]=2*primero[u];\n }\n alcanza[u]=vector (tope[u],0);\n elemento[u]=vector (tope[u],0);\n for (int i=0;i &alcanzaidu=alcanza[idu];\n int primeroidu=primero[idu];\n int posant=alcanzaanterior(alcanzaidu,superposicion[u],primeroidu);\n //cout<<\"posant \"< &alcanzaidu=alcanza[idu];\n int primeroidu=primero[idu];\n if (superpadre[u]!=superpadre[w]) {\n if (alcanzaidu[primeroidu] &alcanzaidu=alcanza[idu];\n int primeroidu=primero[idu];\n if (superposicion[u]<=alcanzaidu[primeroidu])\n return obtenerancestro(superpadre[u]);\n int posant=alcanzaanterior(alcanzaidu,superposicion[u],primeroidu);\n if (posant==-1 or alcanzaidu[primeroidu+posant] > paresidnodo[limite];\nint veo[limite];\nint numraices;\nint raices[2*limite];\n\nvoid eliminarepes()\n{\n if (numraices==0) return;\n sort(raices,raices+numraices);\n int last=0;\n for (int i=1;i > &ar=gg[u];\n for (int i=0;i (numids,uu));\n paresidnodo[rv].push_back(pair (numids,vv));\n apendiente[ida]=1;\n }\n }\n}\n\nvoid calcula(int u,int p,int prof)\n{\n //cout<<\"calcula \"< > &ar=gg[u];\n for (int i=0;i>n>>m>>casos;\n for (int i=0;i>au[i]>>av[i];\n if (au[i]!=av[i]) {\n int idu=computaidentificador(au[i]);\n int idv=computaidentificador(av[i]);\n if (idu==idv) apendiente[i]=1;\n else {\n\tg[au[i]].push_back(av[i]);\n\tg[av[i]].push_back(au[i]);\n\tfusiona(au[i],av[i]);\n }\n }\n }\n for (int u=1;u<=n;u++) {\n if (not visto[u]) {\n //cout<<\"tratando \"<>numnodos>>m;\n numraices=0;\n for (int i=0;i>s[i];\n //if (cas==11) cout<<\"nodo \"<>au[i]>>av[i];\n //if (cas==11) cout<<\"arista \"< (rv,i));\n\t gg[rv].push_back(pair (ru,i));\n\t}\n }\n }\n /*\n cout<<\"aristas: \";\n for (int i=0;i > &lista=paresidnodo[r];\n sort(lista.begin(),lista.end());\n for (int j=0;j > ();\n paresidnodo[r]=vector > ();\n profundidad[r]=0;\n }\n numids=0;\n recupera();\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a86b7d2af86a4fb1702c16dad9ed77e1", "src_uid": "53f64841886b32816eadce278e636bbc", "difficulty": 3300.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n#define rep(it,st,en) for(int it=(st);it<(int)(en);++it)\n#define allof(c) (c).begin(), (c).end()\n#define mt make_tuple\n#define mp make_pair\n#define pb push_back\n#define X first\n#define Y second\ntypedef long long int ll; \ntypedef long double ld;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef pair pii;\nconst int INF=(int)1e9; \nconst double EPS=(ld)1e-7;\n\n//#define cout (cout<<\"\\033[1;31m\")\n//#define endl \"\\033[0m\"<=0;--i)\n if(depth[par[i][a]] >= depth[b]) a = par[i][a];\n if(a==b) return a;\n for(int i=maxlg-1;i>=0;--i)\n if(par[i][a] != par[i][b]) a = par[i][a], b=par[i][b];\n return par[0][a];\n }\n};\nvi gg[maxn];\nint imp[maxn];\nvoid compact(vi& sub,Tree &t){\n static auto cmp = [&](int a,int b){return t.enter[a] st;\n for(int x:sub){\n while(!st.empty() && t.exit[st.top()] <= t.enter[x]) st.pop();\n if(!st.empty()) gg[st.top()].pb(x), gg[x].pb(st.top());\n st.push(x);\n }\n}\n\nnamespace bcc2{\n int bcc[maxn],tmm[maxn],low[maxn];\n int T=1,comp=0;\n stack st;\n void dfs(int x,int p){\n tmm[x] = low[x] = T++;\n st.push(x);\n for(int y:gg[x]) if(y!=p && y!=0){\n if(tmm[y]) low[x] = min(low[x],tmm[y]);\n else dfs(y,x), low[x] = min(low[x],low[y]);\n }\n if(low[x]==tmm[x]){\n bcc[x] = ++comp;\n while(st.top()!=x)\n bcc[st.top()] = comp, st.pop();\n st.pop();\n }\n }\n}\n\nvvi g;\nint bcc[maxn],tmm[maxn],low[maxn];\nint T=1,comp=0;\nstack st;\nvoid dfs(int x,int p){\n tmm[x] = low[x] = T++;\n st.push(x);\n for(int y:g[x]) if(y!=p){\n if(tmm[y]) low[x] = min(low[x],tmm[y]);\n else dfs(y,x), low[x] = min(low[x],low[y]);\n }\n if(low[x]==tmm[x]){\n bcc[x] = ++comp;\n while(st.top()!=x) \n bcc[st.top()] = comp, st.pop();\n st.pop();\n }\n}\nint n,m,q,a,b,x[maxn],y[maxn];\nint R=0;\nint rot(int element) { element=(element+R)%n; if (element==0) { element=n; } return element; }\n\nint main(){\n ios::sync_with_stdio(false);\n cin.tie(NULL);\n cin>>n>>m>>q;\n g.resize(n+5);\n rep(i,0,m){\n cin>>a>>b;\n g[a].pb(b);\n g[b].pb(a);\n x[i]=a, y[i]=b;\n }\n rep(i,1,n+1) if(!tmm[i]) dfs(i,-1), g[0].pb(bcc[i]);\n g.resize(1);\n g.resize(comp+1,vi());\n rep(i,0,m) {\n a=bcc[x[i]], b=bcc[y[i]];\n if(a==b) continue;\n g[a].pb(b);\n g[b].pb(a);\n }\n Tree tree(g,0);\n //rep(i,0,n+1) cout<>n>>m;\n vi v(n);\n rep(i,0,n){\n cin>>t;\n v[i]=bcc[rot(t)];\n }\n vi w=v;\n rep(i,0,m){\n cin>>a>>b;\n a=bcc[rot(a)], b=bcc[rot(b)];\n w.pb(a),w.pb(b);\n if(a!=b){\n gg[a].pb(b);\n gg[b].pb(a);\n }\n }\n sort(allof(w));\n w.erase(unique(allof(w)),w.end());\n compact(w,tree);\n bcc2::dfs(v[0],-1);\n //rep(i,0,n) rep(j,0,gg[i].size())if(i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nconst int Maxn=300010;\n\nint n,m,q,R,pn,belong[Maxn],A[Maxn],B[Maxn],Dfn[Maxn],ed[Maxn],lim,s[Maxn],f[Maxn][30],depth[Maxn],root[Maxn];\nbool imp[Maxn];\n\nint Get()\n{\n\tchar ch; int v=0; bool f=false;\n\twhile (!isdigit(ch=getchar())) if (ch=='-') f=true; v=ch-48;\n\twhile (isdigit(ch=getchar())) v=v*10+ch-48;\n\tif (f) return -v;else return v;\n}\n\nint rotate(int element)\n{\n\telement=(element+R)%n;\n\tif (element==0) element=n;\n\treturn element;\n}\n\nbool cmp(const int &a,const int &b)\n{\n\treturn Dfn[a]>=1,i++)\n\t\tif (dif&1) x=f[x][i];\n\tif (x==y) return x;\n\tfor (int i=lim;i>=0;i--)\n\t\tif (f[x][i]!=f[y][i]) x=f[x][i],y=f[y][i];\n\treturn f[x][0];\n}\n\nbool insub(int x,int y)\n{\n\treturn Dfn[x]<=Dfn[y] && Dfn[y]<=ed[x];\n}\n\nnamespace Task\n{\n\tconst int Maxm=Maxn+Maxn;\n\tint tot,cnt,tpn,bel[Maxn],fst[Maxn],to[Maxm<<1],pre[Maxm<<1],st[Maxn],top,dfs_clock,dfn[Maxn],low[Maxn];\n\t\n\tbool inset[Maxn],vis[Maxn];\n\t\n\tvoid init() { tot=1; }\n\tvoid push(int x) { if (x==-1) return; if (!inset[x]) s[++cnt]=x,inset[x]=true; }\n\tvoid clean()\n\t{\n\t\tfor (int i=1;i<=cnt;i++)\n\t\t{\n\t\t\tinset[s[i]]=imp[s[i]]=false;\n\t\t\tfst[s[i]]=vis[s[i]]=dfn[s[i]]=low[s[i]]=0;\n\t\t\ts[i]=0;\n\t\t}\n\t\tcnt=tot=0;\n\t}\n\t\n\tvoid AddE(int x,int y)\n\t{\n\t//\tcout<<\"Add:\"<0 && !insub(st[top],x)) top--;\n\t\t\tif (top>0) AddE(x,st[top]);\n\t\t\tst[++top]=x;\n\t\t}\n\t}\n\t\n\tvoid tarjan(int x,int prev)\n\t{\n\t\tvis[x]=true;\n\t\tdfn[x]=low[x]=++dfs_clock;\n\t\tfor (int i=fst[x];i;i=pre[i])\n\t\t{\n\t\t\tint y=to[i];\n\t\t\tif ((i^1)==prev) continue;\n\t\t\tif (!vis[y]) tarjan(y,i),low[x]=min(low[x],low[y]);\n\t\t\telse low[x]=min(low[x],dfn[y]);\n\t\t}\n\t}\n\t\n\tbool iscut(int x,int y)\n\t{\n\t\treturn low[x]>dfn[y] || low[y]>dfn[x];\n\t}\n\t\n\tvoid FindScc(int x)\n\t{\n\t\tvis[x]=true; bel[x]=tpn;\n\t\tfor (int i=fst[x];i;i=pre[i])\n\t\t\tif (!vis[to[i]] && !iscut(x,to[i])) FindScc(to[i]);\n\t}\n\t\n\tvoid work(int test)\n\t{\n\t\tbuild();\n\t\tdfs_clock=0;\n\t\tfor (int i=1;i<=cnt;i++) vis[s[i]]=false;\n\t\tfor (int i=1;i<=cnt;i++)\n\t\t\tif (!vis[s[i]]) tarjan(s[i],-1);\n\t\tfor (int i=1;i<=cnt;i++) vis[s[i]]=false;\n\t\ttpn=0;\n\t\tfor (int i=1;i<=cnt;i++)\n\t\t\tif (!vis[s[i]]) tpn++,FindScc(s[i]);\n\t\tbool flag=true; int t=0;\n\t\t//for (int i=1;i<=cnt;i++) cout<dfn[y] || low[y]>dfn[x];\n\t}\n\t\n\tvoid FindScc(int x)\n\t{\n\t\tvis[x]=true; belong[x]=pn;\n\t\tfor (int i=fst[x];i;i=pre[i])\n\t\t\tif (!vis[to[i]] && !iscut(x,to[i])) FindScc(to[i]);\n\t}\n\t\n\tvoid init()\n\t{\n\t\ttot=1;\n\t\tint x,y;\n\t\tfor (int i=1;i<=m;i++)\n\t\t{\n\t\t\tA[i]=Get(),B[i]=Get();\n\t\t\tAddE(A[i],B[i]);\n\t\t}\n\t\tpn=0; dfs_clock=0;\n\t\tfor (int i=1;i<=n;i++) vis[i]=false;\n\t\tfor (int i=1;i<=n;i++) if (!vis[i]) tarjan(i,-1);\n\t\t\n\t\tfor (int i=1;i<=n;i++) vis[i]=false;\n\t\tfor (int i=1;i<=n;i++) if (!vis[i]) pn++,FindScc(i);\n\t\t//for (int i=1;i<=n;i++) cout<\n#define debug(...) fprintf(stderr,__VA_ARGS__)\n#define lson l,mid,rt << 1\n#define rson mid + 1,r,rt << 1 | 1\nusing namespace std;\n\ntemplateinline void rd(T & x){ int f = 1;x = 0;char ch = getchar();for(;!isdigit(ch);ch = getchar()) if(ch == '-') f = -1; for(;isdigit(ch);ch = getchar()) x = x * 10 + ch - '0';x *= f;}\n\nconst int maxn = 1e5 + 10;\n\nstruct op{\n\tint type;\n\tint t,l,r,v,s;\n} querys[maxn];\n\nint times[maxn],n;\ninline int upper(double time){\n\tint l = 1,r = n,ans = n + 1;\n\twhile(l <= r){\n\t\tint mid = l + r >> 1;\n\t\tif(times[mid] >= time){\n\t\t\tans = mid;\n\t\t\tr = mid - 1;\n\t\t} else {\n\t\t\tl = mid + 1;\n\t\t}\n\t}\n\treturn ans;\n}\ninline int lower(double time){\n\tint l = 1,r = n,ans = 0;\n\twhile(l <= r){\n\t\tint mid = l + r >> 1;\n\t\tif(times[mid] <= time){\n\t\t\tans = mid;\n\t\t\tl = mid + 1;\n\t\t} else {\n\t\t\tr = mid - 1;\n\t\t}\n\t}\n\treturn ans;\n}\n\nint mark[maxn];\nnamespace Fenwick{\n\tint tr[maxn];\n\tinline void update(int x,int v){ for(;x < maxn;x += x & (-x)) tr[x] += v;}\n\tinline int query(int x){ int ans = 0; for(;x;x ^= x & (-x)) ans += tr[x]; return ans;}\n\tinline int val(int x) { return query(x) - query(x - 1);}\n\tinline int bs(int x){ // min query(ans) >= x\n\t\tint l = 0,r = n,ans = 0;\n\t\twhile(l <= r){\n\t\t\tint mid = l + r >> 1;\n\t\t\tif(query(mid) >= x) {\n\t\t\t\tans = mid;\n\t\t\t\tr = mid - 1;\n\t\t\t} else {\n\t\t\t\tl = mid + 1;\n\t\t\t}\n\t\t}\n\t\treturn ans;\n\t}\n\tinline int pre(int x){\n\t\tint d = query(x - 1);\n\t\treturn bs(d);\n\t}\n\tinline int suc(int x){\n\t\treturn bs(query(x) + 1);\n\t}\n}\ndouble cur[maxn];\nconst double inf = 2e20;\nnamespace Segment{\n\tdouble tra[maxn << 2],tri[maxn << 2];\n\tdouble lazy[maxn << 2];\n\tint mk[maxn << 2];\n\t\n\tinline void pushup(int rt){\n\t\ttra[rt] = max(tra[rt << 1],tra[rt << 1 | 1]);\n\t\ttri[rt] = min(tri[rt << 1],tri[rt << 1 | 1]);\t\n\t}\n\tinline void pushdown(int rt){\n\t\tif(!mk[rt]) return;\n\t\tmk[rt] = 0;\n\t\tmk[rt << 1] = 1;\n\t\tmk[rt << 1 | 1] = 1;\n\t\tlazy[rt << 1] += lazy[rt];\n\t\tlazy[rt << 1 | 1] += lazy[rt];\n\t\ttra[rt << 1] += lazy[rt];\n\t\ttri[rt << 1] += lazy[rt];\n\t\ttra[rt << 1 | 1] += lazy[rt];\n\t\ttri[rt << 1 | 1] += lazy[rt];\n\t\tlazy[rt] = 0;\n\t}\n\tvoid _update(double * target,int pos,double v,int l,int r,int rt){\n\t\tif(l == r){\n\t\t\ttarget[rt] = v;\n\t\t\treturn;\n\t\t}\n\t\tpushdown(rt); \n\t\tint mid = l + r >> 1;\n\t\tif(pos <= mid) _update(target,pos,v,lson);\n\t\telse _update(target,pos,v,rson);\n\t\tpushup(rt);\n\t}\n\tvoid setVoid(int pos){\n\t\t_update(tra,pos,-inf,1,n,1);\n\t\t_update(tri,pos,inf,1,n,1);\n\t}\n\tvoid setZero(int pos){\n\t\t_update(tra,pos,0,1,n,1);\n\t\t_update(tri,pos,0,1,n,1);\n\t}\n\tvoid build(int l,int r,int rt){\n\t\tif(l == r){\n\t\t\ttra[rt] = -inf;\n\t\t\ttri[rt] = inf;\n\t\t\treturn;\n\t\t}\n\t\tint mid = l + r >> 1;\n\t\tbuild(lson);\n\t\tbuild(rson);\n\t\tpushup(rt);\n\t}\n\tvoid update(int L,int R,double v,int l,int r,int rt){\n\t\tif(L <= l && r <= R){\n\t\t\tlazy[rt] += v;\n\t\t\ttra[rt] += v;\n\t\t\ttri[rt] += v;\n\t\t\tmk[rt] = 1;\n\t\t\treturn;\n\t\t}\n\t\tpushdown(rt);\n\t\tint mid = l + r >> 1;\n\t\tif(L <= mid) update(L,R,v,lson);\n\t\tif(R > mid) update(L,R,v,rson);\n\t\tpushup(rt);\n\t}\n\tdouble querya(int L,int R,int l,int r,int rt){\n\t\tif(L <= l && r <= R){\n\t\t\treturn tra[rt];\n\t\t}\n\t\tpushdown(rt);\n\t\tint mid = l + r >> 1;\n\t\tdouble ans = -inf;\n\t\tif(L <= mid) ans = max(ans,querya(L,R,lson));\n\t\tif(R > mid)ans = max(ans,querya(L,R,rson));\n\t\treturn ans;\n\t}\n\tdouble queryi(int L,int R,int l,int r,int rt){\n\t\tif(L <= l && r <= R){\n\t\t\treturn tri[rt];\n\t\t}\n\t\tpushdown(rt);\n\t\tint mid = l + r >> 1;\n\t\tdouble ans = inf;\n\t\tif(L <= mid) ans = min(ans,queryi(L,R,lson));\n\t\tif(R > mid) ans = min(ans,queryi(L,R,rson));\n\t\treturn ans;\n\t}\n\t\n}\ndouble getV(double l){\n\tint x = lower(l);\n\tif(x == 0) return 0;\n\tif(Fenwick::val(x) == 0)x = Fenwick::pre(x);\n\tif(x == 0) return 0;\n\treturn cur[x];\n}\ndouble calc(double l){\n\tint x = lower(l);\n\tif(x == 0) return 0;\n\tif(Fenwick::val(x) == 0)x = Fenwick::pre(x);\n\tif(x == 0) return 0; \n\treturn (double)(l - times[x]) * cur[x] + Segment::querya(x,x,1,n,1);\n}\nconst double eps = 1e-15;\nbool check(double l,double r,double c){\n\tdouble qa = -inf,qi = inf;\n\tif(fabs(l - r) <= eps) return fabs(calc(l) - c) <= eps; \n\tqa = max(calc(l),qa);\n\tqi = min(calc(l),qi);\n\tqa = max(calc(r),qa);\n\tqi = min(calc(r),qi);\n\tint lx = upper(l),rx = lower(r);\n\tif(lx <= rx && lx != 0 && rx != 0){\n\t\tqa = max(qa,Segment::querya(lx,rx,1,n,1));\n\t\tqi = min(qi,Segment::queryi(lx,rx,1,n,1));\n\t}\n//\tprintf(\"%.9f %.9f %.9f %.9f %.9f\\n\",l,r,qa,qi,c);\n\treturn qa - c >= 0 && qi - c <= 0;\n}\n\nint main(){\n\tint TAT;\n\tint ttt = 0;\n\trd(TAT);\n\tfor(int i = 1;i <= TAT;i++){\n\t\tint type,t,l,r,v,s;\n\t\trd(type);\n\t\tif(type == 1){ // add\n\t\t\trd(t); rd(v);\n\t\t\ttimes[++n] = t;\n\t\t\tquerys[i].type = 1;\n\t\t\tquerys[i].t = t;\n\t\t\tquerys[i].v = v;\n\t\t} else if(type == 2){\n\t\t\trd(t);\n\t\t\tquerys[i].type = 2;\n\t\t\tquerys[i].t = t;\n\t\t} else {\n\t\t\trd(l); rd(r); rd(s);\n\t\t\tquerys[i].type = 3;\n\t\t\tquerys[i].l = l;\n\t\t\tquerys[i].r = r;\n\t\t\tquerys[i].s = s;\n\t\t}\n\t}\n\tsort(times + 1,times + n + 1);\n\tn = unique(times + 1,times + n + 1) - times - 1;\n\t\n\tif(n!=0)Segment::build(1,n,1);\n\tfor(int i = 1;i <= TAT;i++){\n\t\tint type = querys[i].type;\n\t\tif(type == 1){\n\t\t\tint t = querys[i].t, v = querys[i].v;\n\t\t\tint pos = upper(t);\n\t\t\tFenwick::update(pos,1);\n\t\t\tint pre = Fenwick::pre(pos),suc = Fenwick::suc(pos);\n\t\t\tcur[pos] = v;\n\t\t\tassert(pos != n + 1);\n\t\t\tSegment::setZero(pos);\n\t\t\tif(pre){\n\t\t\t\tdouble delta = (double)cur[pre] * (times[pos] - times[pre]) + Segment::querya(pre,pre,1,n,1);\n\t\t\t\tSegment::update(pos,pos,delta,1,n,1);\n\t\t\t}\n\t\t\tif(suc){\n\t\t\t\tdouble delta = (double)(v - cur[pre]) * (times[suc] - times[pos]);\n\t\t\t\tSegment::update(suc,n,delta,1,n,1);\n\t\t\t}\n\t\t} else if(type == 2){\n\t\t\tint t = querys[i].t;\n\t\t\tint pos = upper(t);\n\t\t\tint pre = Fenwick::pre(pos),suc = Fenwick::suc(pos);\n\t\t\tFenwick::update(pos,-1);\n\t\t\tif(suc){\n\t\t\t\tdouble delta = (double)(cur[pre] - cur[pos]) * (times[suc] - times[pos]);\n\t\t\t\tSegment::update(suc,n,delta,1,n,1);\n\t\t\t}\n\t\t\tSegment::setVoid(pos);\n\t\t\tcur[pos] = 0;\n\t\t} else {\n\t\t\tttt++;\n\t\t\tdouble l = querys[i].l , r = querys[i].r , s = -querys[i].s;\n\t\t\tint lx = upper(l);\n\t\t\tif(Fenwick::val(lx) == 0) lx = Fenwick::suc(lx);\n\t\t\tl = times[lx];\n\t\t\tif(s == 0) {\n\t\t\t\tprintf(\"%d\\n\",querys[i].l);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif(n == 0 || Fenwick::query(n) == 0 || !lx || l > r) {\n\t\t\t\tprintf(\"-1\\n\");\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ts += Segment::querya(lx,lx,1,n,1);\n\t\t\t\n\t\t\tbool ok = 0;\n\t\t\tl -= eps * 2;\n\t\t\tr += eps * 2;\n\t\t\tfor(int k = 0;k < 100;k++){\n\t\t\t\tdouble mid = (l + r) / 2;\n\t\t\t\tif(check(l,mid,s)){\n\t\t\t\t\tr = mid;\n\t\t\t\t\tok = 1;\n\t\t\t\t} else {\n\t\t\t\t\tl = mid;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(fabs(calc(l) - s) <= eps) ok = 1;\n\t\t\tif(ok)printf(\"%.9f\\n\",r);\n\t\t\telse printf(\"-1\\n\");\n\t\t}\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "54245ca811497db6f6288bcead741579", "src_uid": "23440d055baf6c831e91e76b99b9ada8", "difficulty": 2800.0} {"lang": "GNU C++11", "source_code": "#include\n#define lson l,mid,rt << 1\n#define rson mid + 1,r,rt << 1 | 1\nusing namespace std;\n\ntemplateinline void rd(T & x){ int f = 1;x = 0;char ch = getchar();for(;!isdigit(ch);ch = getchar()) if(ch == '-') f = -1; for(;isdigit(ch);ch = getchar()) x = x * 10 + ch - '0';x *= f;}\n\nconst int maxn = 1e5 + 10;\n\nstruct op{\n\tint type;\n\tint t,l,r,v,s;\n} querys[maxn];\n\nint times[maxn],n;\ninline int upper(double time){\n\tint l = 1,r = n,ans = n + 1;\n\twhile(l <= r){\n\t\tint mid = l + r >> 1;\n\t\tif(times[mid] >= time){\n\t\t\tans = mid;\n\t\t\tr = mid - 1;\n\t\t} else {\n\t\t\tl = mid + 1;\n\t\t}\n\t}\n\treturn ans;\n}\ninline int lower(double time){\n\tint l = 1,r = n,ans = 0;\n\twhile(l <= r){\n\t\tint mid = l + r >> 1;\n\t\tif(times[mid] <= time){\n\t\t\tans = mid;\n\t\t\tl = mid + 1;\n\t\t} else {\n\t\t\tr = mid - 1;\n\t\t}\n\t}\n\treturn ans;\n}\n\nint mark[maxn];\nnamespace Fenwick{\n\tint tr[maxn];\n\tinline void update(int x,int v){ for(;x < maxn;x += x & (-x)) tr[x] += v;}\n\tinline int query(int x){ int ans = 0; for(;x;x ^= x & (-x)) ans += tr[x]; return ans;}\n\tinline int val(int x) { return query(x) - query(x - 1);}\n\tinline int bs(int x){ // min query(ans) >= x\n\t\tint l = 0,r = n,ans = 0;\n\t\twhile(l <= r){\n\t\t\tint mid = l + r >> 1;\n\t\t\tif(query(mid) >= x) {\n\t\t\t\tans = mid;\n\t\t\t\tr = mid - 1;\n\t\t\t} else {\n\t\t\t\tl = mid + 1;\n\t\t\t}\n\t\t}\n\t\treturn ans;\n\t}\n\tinline int pre(int x){\n\t\tint d = query(x - 1);\n\t\treturn bs(d);\n\t}\n\tinline int suc(int x){\n\t\treturn bs(query(x) + 1);\n\t}\n}\ndouble cur[maxn];\nconst double inf = 2e20;\nnamespace Segment{\n\tdouble tra[maxn << 2],tri[maxn << 2];\n\tdouble lazy[maxn << 2];\n\tint mk[maxn << 2];\n\t\n\tinline void pushup(int rt){\n\t\ttra[rt] = max(tra[rt << 1],tra[rt << 1 | 1]);\n\t\ttri[rt] = min(tri[rt << 1],tri[rt << 1 | 1]);\t\n\t}\n\tinline void pushdown(int rt){\n\t\tif(!mk[rt]) return;\n\t\tmk[rt] = 0;\n\t\tmk[rt << 1] = 1;\n\t\tmk[rt << 1 | 1] = 1;\n\t\tlazy[rt << 1] += lazy[rt];\n\t\tlazy[rt << 1 | 1] += lazy[rt];\n\t\ttra[rt << 1] += lazy[rt];\n\t\ttri[rt << 1] += lazy[rt];\n\t\ttra[rt << 1 | 1] += lazy[rt];\n\t\ttri[rt << 1 | 1] += lazy[rt];\n\t\tlazy[rt] = 0;\n\t}\n\tvoid _update(double * target,int pos,double v,int l,int r,int rt){\n\t\tif(l == r){\n\t\t\ttarget[rt] = v;\n\t\t\treturn;\n\t\t}\n\t\tint mid = l + r >> 1;\n\t\tif(pos <= mid) _update(target,pos,v,lson);\n\t\telse _update(target,pos,v,rson);\n\t\tpushup(rt);\n\t}\n\tvoid setVoid(int pos){\n\t\t_update(tra,pos,-inf,1,n,1);\n\t\t_update(tri,pos,inf,1,n,1);\n\t}\n\tvoid setZero(int pos){\n\t\t_update(tra,pos,0,1,n,1);\n\t\t_update(tri,pos,0,1,n,1);\n\t}\n\tvoid build(int l,int r,int rt){\n\t\tif(l == r){\n\t\t\ttra[rt] = -inf;\n\t\t\ttri[rt] = inf;\n\t\t\treturn;\n\t\t}\n\t\tint mid = l + r >> 1;\n\t\tbuild(lson);\n\t\tbuild(rson);\n\t\tpushup(rt);\n\t}\n\tvoid update(int L,int R,double v,int l,int r,int rt){\n\t\tif(L <= l && r <= R){\n\t\t\tlazy[rt] += v;\n\t\t\ttra[rt] += v;\n\t\t\ttri[rt] += v;\n\t\t\tmk[rt] = 1;\n\t\t\treturn;\n\t\t}\n\t\tpushdown(rt);\n\t\tint mid = l + r >> 1;\n\t\tif(L <= mid) update(L,R,v,lson);\n\t\tif(R > mid) update(L,R,v,rson);\n\t\tpushup(rt);\n\t}\n\tdouble querya(int L,int R,int l,int r,int rt){\n\t\tif(L <= l && r <= R){\n\t\t\treturn tra[rt];\n\t\t}\n\t\tpushdown(rt);\n\t\tint mid = l + r >> 1;\n\t\tdouble ans = -inf;\n\t\tif(L <= mid) ans = max(ans,querya(L,R,lson));\n\t\tif(R > mid)ans = max(ans,querya(L,R,rson));\n\t\treturn ans;\n\t}\n\tdouble queryi(int L,int R,int l,int r,int rt){\n\t\tif(L <= l && r <= R){\n\t\t\treturn tri[rt];\n\t\t}\n\t\tpushdown(rt);\n\t\tint mid = l + r >> 1;\n\t\tdouble ans = inf;\n\t\tif(L <= mid) ans = min(ans,queryi(L,R,lson));\n\t\tif(R > mid) ans = min(ans,queryi(L,R,rson));\n\t\treturn ans;\n\t}\n\t\n}\ndouble getV(double l){\n\tint x = lower(l);\n\tif(x == 0) return 0;\n\tif(Fenwick::val(x) == 0)x = Fenwick::pre(x);\n\tif(x == 0) return 0;\n\treturn cur[x];\n}\ndouble calc(double l){\n\tint x = lower(l);\n\tif(x == 0) return 0;\n\tif(Fenwick::val(x) == 0)x = Fenwick::pre(x);\n\tif(x == 0) return 0;\n\treturn (double)(l - times[x]) * cur[x] + Segment::querya(x,x,1,n,1);\n}\nconst double eps = 1e-15;\nbool check(double l,double r,double c){\n\tdouble qa = -inf,qi = inf;\n\tif(l == r) return abs(calc(l) - c) <= eps;\n\tqa = max(calc(l),qa);\n\tqi = min(calc(l),qi);\n\tqa = max(calc(r),qa);\n\tqi = min(calc(r),qi);\n\tint lx = upper(l),rx = lower(r);\n\tif(lx <= rx && lx != 0 && rx != 0){\n\t\tqa = max(qa,Segment::querya(lx,rx,1,n,1));\n\t\tqi = min(qi,Segment::queryi(lx,rx,1,n,1));\n\t}\n//\tprintf(\"%.9f %.9f %.9f %.9f %.9f\\n\",l,r,qa,qi,c);\n\treturn qa - c >= 0 && qi - c <= 0;\n}\n\nint main(){\n\tint TAT;\n\tint ttt = 0;\n\trd(TAT);\n\tfor(int i = 1;i <= TAT;i++){\n\t\tint type,t,l,r,v,s;\n\t\trd(type);\n\t\tif(type == 1){ // add\n\t\t\trd(t); rd(v);\n\t\t\ttimes[++n] = t;\n\t\t\tquerys[i].type = 1;\n\t\t\tquerys[i].t = t;\n\t\t\tquerys[i].v = v;\n\t\t} else if(type == 2){\n\t\t\trd(t);\n\t\t\tquerys[i].type = 2;\n\t\t\tquerys[i].t = t;\n\t\t} else {\n\t\t\trd(l); rd(r); rd(s);\n\t\t\tquerys[i].type = 3;\n\t\t\tquerys[i].l = l;\n\t\t\tquerys[i].r = r;\n\t\t\tquerys[i].s = s;\n\t\t}\n\t}\n\tsort(times + 1,times + n + 1);\n\tn = unique(times + 1,times + n + 1) - times - 1;\n\t\n\tif(n!=0)Segment::build(1,n,1);\n\tfor(int i = 1;i <= TAT;i++){\n\t\tint type = querys[i].type;\n\t\tif(type == 1){\n\t\t\tint t = querys[i].t, v = querys[i].v;\n\t\t\tint pos = upper(t);\n\t\t\tFenwick::update(pos,1);\n\t\t\tint pre = Fenwick::pre(pos),suc = Fenwick::suc(pos);\n\t\t\tcur[pos] = v;\n\t\t\tSegment::setZero(pos);\n\t\t\tif(pre){\n\t\t\t\tdouble delta = (double)cur[pre] * (times[pos] - times[pre]) + Segment::querya(pre,pre,1,n,1);\n\t\t\t\tSegment::update(pos,pos,delta,1,n,1);\n\t\t\t}\n\t\t\tif(suc){\n\t\t\t\tdouble delta = (double)(v - cur[pre]) * (times[suc] - times[pos]);\n\t\t\t\tSegment::update(suc,n,delta,1,n,1);\n\t\t\t}\n\t\t} else if(type == 2){\n\t\t\tint t = querys[i].t;\n\t\t\tint pos = upper(t);\n\t\t\tint pre = Fenwick::pre(pos),suc = Fenwick::suc(pos);\n\t\t\tFenwick::update(pos,-1);\n\t\t\tif(suc){\n\t\t\t\tdouble delta = (double)(cur[pre] - cur[pos]) * (times[suc] - times[pos]);\n\t\t\t\tSegment::update(suc,n,delta,1,n,1);\n\t\t\t}\n\t\t\tSegment::setVoid(pos);\n\t\t\tcur[pos] = 0;\n\t\t} else {\n\t\t\tt++;\n\t\t\tdouble l = querys[i].l , r = querys[i].r , s = -querys[i].s;\n\t\t\tint lx = upper(l);\n\t\t\tif(Fenwick::val(lx) == 0) lx = Fenwick::suc(lx);\n\t\t\tl = times[lx];\n\t\t\tif(s == 0) {\n\t\t\t\tprintf(\"%d\\n\",querys[i].l);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif(n == 0 || Fenwick::query(n) == 0 || !lx || l > r) {\n\t\t\t\tif(t == 20) printf(\"FUCK\\n\");\n\t\t\t\tprintf(\"-1\\n\");\n\t\t\t\t\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ts += Segment::querya(lx,lx,1,n,1);\n\t\t\t\n\t\t\tbool ok = 0;\n\t\t\tif(check(r,r,s) || check(l,l,s)) ok = 1;\n\t\t\tfor(int k = 0;k < 1000;k++){\n\t\t\t\tdouble mid = (l + r) / 2;\n\t\t\t\tif(check(l,mid,s)){\n\t\t\t\t\tr = mid;\n\t\t\t\t\tok = 1;\n\t\t\t\t} else {\n\t\t\t\t\tl = mid;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(ok)printf(\"%.9f\\n\",r);\n\t\t\telse printf(\"-1\\n\");\n\t\t}\n\t}\n}\n\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3004165cf92c7f2964161478d2f3c79a", "src_uid": "23440d055baf6c831e91e76b99b9ada8", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\n#define pii pair\n#define mp make_pair\n\nll read() {\n int f = 1;\n ll res = 0;\n char ch;\n do {\n ch = getchar();\n if (ch == '-') f = -f;\n } while (ch < '0' || ch > '9');\n do {\n res = res * 10 + ch - '0';\n ch = getchar();\n } while (ch >= '0' && ch <= '9');\n return f == 1 ? res : -res;\n}\n\nvoid fast_io() {\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n}\n\nconst int N = 100010;\nconst int mod = 1000000007;\nconst ll INF = 1e18;\nint n,m,q;\nint A[N], B[N];\nchar str[N];\n\nint head[N*2], to[N * 2], nxt[N * 2], tot;\nvoid addEdge(int u, int v) {\n tot++;\n nxt[tot] = head[u];\n to[tot] = v;\n head[u] = tot;\n}\n\ntemplate \nT mmax(T a, T b) {\n return a < b ? b: a;\n}\n\ntemplate \nT mmin(T a, T b) {\n return a < b? a: b;\n}\n\nint countOne(int set) {\n int res = 0;\n while (set) {\n res++;\n set &= set - 1;\n }\n return res;\n}\n\nbool contain(int set, int i) {\n return (set & (1 << i)) > 0;\n}\n\nll myPow(ll a, int p) {\n if (p == 0) return 1;\n ll res = myPow(a, p / 2);\n res *= res;\n res %= mod;\n if (p % 2 == 1) {\n res *= a;\n res %= mod;\n }\n return res;\n}\n\nvoid addMode(int &a, ll b) {\n a = (a+b) % mod;\n}\n\nll mul(ll a, ll b) {\n return a * b % mod;\n}\n\ntemplate \nvoid mySwap(T &a, T &b) {\n T tmp = a;\n a = b;\n b = tmp;\n}\n\nstruct Query {\n int time, l, r, type;\n int speed, vol;\n};\n\nvector added;\nvector query;\n\nconst int M = N * 4;\nstruct ST {\n pii f[M], e[M];\n ll res[M], mn[M];\n\n void init() {\n fill(mn, mn+M, INF);\n }\n void build(int x, int nl, int nr) {\n if (nl == nr) {\n mn[x] = INF;\n return;\n }\n int m = (nl + nr) / 2;\n build(x*2, nl, m);\n build(x*2+1, m+1, nr);\n mn[x] = INF;\n }\n\n void update(int x) {\n if (mn[x*2] == INF) {\n int child = x*2+1;\n f[x] = f[child];\n e[x] = e[child];\n res[x] = res[child];\n mn[x] = mn[child];\n return;\n }\n if (mn[x*2+1] == INF) {\n int child = x*2;\n f[x] = f[child];\n e[x] = e[child];\n res[x] = res[child];\n mn[x] = mn[child];\n return;\n }\n int l = x*2;\n int r = x*2+1;\n f[x] = f[l];\n e[x] = e[r];\n ll diff = e[l].second * (f[r].first - e[l].first);\n res[x] = res[l] + diff + res[r];\n mn[x] = mmin(mn[l], res[l] + diff);\n mn[x] = mmin(mn[x], res[l] + diff + mn[r]);\n }\n\n void set(int l, int time, int speed, int x, int nl ,int nr) {\n if (nl == nr) {\n f[x] = mp(time, speed);\n e[x] = mp(time, speed);\n res[x] = 0;\n mn[x] = 0;\n return;\n }\n int m = (nl + nr) / 2;\n if (l <= m) set(l, time, speed, x*2, nl, m);\n else set(l, time, speed, x*2+1, m+1, nr);\n update(x);\n }\n\n void del(int l, int x, int nl , int nr) {\n if (nl == nr) {\n mn[x] = INF;\n return;\n }\n int m = (nl + nr) / 2;\n if (l <= m) del(l, x*2, nl, m);\n else del(l, x*2+1, m+1, nr);\n update(x);\n }\n\n struct node {\n double to;\n ll v;\n };\n node query(int l, int r, ll v, int ss, int rr, int x, int nl, int nr) {\n\n if (mn[x] == INF) return {-1, v};\n if (l > r) return {-1, v};\n// if (rr <= f[x].first) {\n// return {-1, v};\n// }\n if (l == nl && r == nr) {\n if (f[x] == e[x]) {\n ll nv = res[x] + v + (rr - e[x].first) * e[x].second;\n if (nv > 0) return {-1, nv};\n else return {e[x].first - (res[x] + v) * 1.0 / e[x].second, 0LL};\n }\n int lchild = x*2;\n int rchild = x*2+1;\n int m = (nl + nr) / 2;\n if (mn[rchild] == INF) return query(l, m, v, ss, rr, x*2, nl, m);\n if (mn[lchild] == INF) return query(m+1, r, v, ss, rr, x*2+1, m+1, nr);\n\n if (mn[lchild] + v <= 0) return query(l, m, v, ss, mmin(rr, f[x*2+1].first), x*2, nl, m);\n ll diff = e[lchild].second * (f[rchild].first - e[lchild].first);\n if (v + res[lchild] + diff <= 0) {\n return {e[lchild].first - (v + res[lchild]) * 1.0 / e[lchild].second, 0};\n }\n\n if (mn[x] + v > 0) {\n ll nv = res[x] + v + (rr - e[x].first) * e[x].second;\n if (nv <= 0) {\n return {e[x].first - (v + res[x]) * 1.0 / e[x].second, 0};\n } else {\n return {-1, nv};\n }\n } else {\n v = v + res[lchild] + diff;\n return query(m+1, r, v, ss, rr, x*2+1, m+1, nr);\n }\n }\n\n int lchild = x*2;\n int rchild = x*2+1;\n int m = (nl + nr) / 2;\n if (mn[rchild] == INF) return query(l, mmin(m, r), v, ss, rr, x*2, nl, m);\n if (mn[lchild] == INF) return query(mmax(l, m+1), r, v, ss, rr, x*2+1, m+1, nr);\n node res = query(l, mmin(r, m), v, ss, f[x*2+1].first, x*2, nl, m);\n if (res.to != -1) return res;\n return query(mmax(l, m+1), r, res.v, ss, rr, x*2+1, m+1, nr);\n }\n}st;\n\nint main() {\n\n fast_io();\n cout << fixed << setprecision(10);\n\n cin >> n;\n for (int i = 0; i < n; i++) {\n int tp;\n cin >> tp;\n Query q;\n q.type = tp;\n if (tp == 1) {\n int time, speed;\n cin >> time >> speed;\n q.time = time;\n q.speed = speed;\n added.push_back(time);\n } else if (tp == 2) {\n int time;\n cin >> time;\n q.time = time;\n } else {\n int l, r, v;\n cin >> l >> r >> v;\n q.l = l;\n q.r = r;\n q.vol = v;\n }\n query.push_back(q);\n }\n if (added.size() == 0) added.push_back(0);\n\n sort(added.begin(), added.end());\n added.erase(unique(added.begin(), added.end()), added.end());\n\n int m = added.size();\n st.init();\n st.build(1, 1, m);\n\n for (int i = 0; i < n; i++) {\n Query q = query[i];\n if (q.type == 1) {\n int idx = lower_bound(added.begin(), added.end(), q.time) - added.begin();\n idx++;\n int time = q.time;\n int speed = q.speed;\n st.set(idx, time, speed, 1, 1, m);\n } else if (q.type == 2) {\n int idx = lower_bound(added.begin(), added.end(), q.time) - added.begin();\n idx++;\n st.del(idx, 1, 1, m);\n } else {\n if (q.vol == 0) {\n cout << q.l << '\\n';\n } else {\n int l = lower_bound(added.begin(), added.end(), q.l) - added.begin();\n l++;\n int r = lower_bound(added.begin(), added.end(), q.r) - added.begin();\n cout << st.query(l, r, q.vol, q.l, q.r, 1, 1, m).to << '\\n';\n }\n }\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "20fcddd19dfd391e285f249e9a616fd3", "src_uid": "23440d055baf6c831e91e76b99b9ada8", "difficulty": 2800.0} {"lang": "GNU C++14", "source_code": "\n\n/* * * * * * * * * * * * * * \t\t\n# *\n# @Author AYUSH AGRAWAL *\n# *\n# * * * * * * * * * * * * */\n\n\n#include\nusing namespace std;\n#define ll long long int\n#define MOD 1000000007\n#define M(x) (x%MOD + MOD)%MOD\n#define _pb push_back\n#define _mp make_pair\n#define ff first\n#define ss second\n#define s(x) scanf(\"%lld\",&x)\n\nll mul(ll x,ll y)\n{ ll ans=1;\n\n while(y>0)\n { if(y&1)\n\tans=(ans*x)%MOD;\n\ty/=2;\n\tx=(x*x)%MOD;\n }\n\n return ans;\n};\n\n/******************************************************************************************************/\n\nconst ll N=100005;\nll a[N],b[N],c[N],d[N],seg[300*N],size,bit[N];\n\nvoid update(ll x,ll val)\n{\t\n\t++x;\n\n\twhile(x<=size)\n\t{\t\n\t\t// cout<0)\n\t{\t\n\t\tans+=bit[x];\n\t\tx-=x&(-x);\n\t}\n\n\treturn ans;\n}\n\nvoid debug2()\n{\n\tll i;\n\tcout<<\"/////////////////////////////////////*********************************\\n\";\n\tfor(i=1;i<=7;i++)\n\t\tcout<val)\n\t{\t\n\t\treturn MOD;\n\t}\n\n\tif(lt==rt && seg[in]<=val)\n\t\treturn lt;\n\n\tll mid = (lt+rt)/2;\n\tll left = query(in*2,lt,mid,ql,qr,val);\n\t\n\tif(left!=MOD)\n\t\treturn left;\n\n\tll right = query(in*2+1,mid+1,rt,ql,qr,val);\n\t// seg[in] = max(seg[in*2],seg[in*2+1]);\n\t// if(right!=MOD)\n\treturn right;\n\t// return;\n}\n\nvector v,ev,cov;\n\nvoid debug()\n{\n\tll i;\n\tcout<<\"*********************************\\n\";\n\tfor(i=0;i ss;\n\n\tfor(i=1;i<=q;i++)\n\t{\n\t\ts(a[i]); s(b[i]);\n\n\t\tif(a[i]==1)\n\t\t\ts(c[i]);\n\t\telse if(a[i]==3)\n\t\t\ts(c[i]),s(d[i]);\n\n\t\tif(a[i]<=2)\n\t\tss.insert(b[i]);\n\t}\n\n\tmap mp;\n\n\tll in=0;\n\twhile(!ss.empty())\n\t{\t\n\t\tmp[*ss.begin()] = in;\n\t\t++in;\n\t\tv._pb(*ss.begin());\n\t\tev._pb(0);\n\t\tcov._pb(0);\n\t\tss.erase(ss.begin());\n\t}\n\n\tsize = v.size();\n\t// cout< ev_list;\n\tset::iterator it,lt,rt;\n\n\tll x,y,tmp,extra;\n\n\tfor(i=1;i<=q;i++)\n\t{\n\t\tif(a[i]==1)\n\t\t{\n\t\t\tin = mp[b[i]];\n\t\t\tev[in] = c[i];\n\t\t\tev_list.insert(b[i]);\n\t\t\tit = ev_list.find(b[i]);\n\t\t\tlt = rt = it;\n\n\t\t\t// debug();\n\n\t\t\tif(lt != ev_list.begin())\n\t\t\t{\t\n\t\t\t\t--lt;\n\t\t\t\tx = *lt; \n\t\t\t\ty = *it;\n\n\t\t\t\tin = mp[x];\n\t\t\t\ttmp = cov[in];\n\t\t\t\tcov[in] = ev[in]*(y-x);\n\n\t\t\t\tadd(1,0,size-1,in,size-1,cov[in]-tmp);\n\t\t\t\t// debug2();\n\t\t\t\t// cout<<\"go1\\n\";\n\t\t\t\tupdate(in,cov[in]-tmp);\n\t\t\t\t// cout<<\"go2\\n\";\n\t\t\t}\n\n\t\t\t++rt;\n\t\t\tx = *it;\n\n\t\t\tif(rt == ev_list.end())\n\t\t\t\ty = x + 1000000000;\n\t\t\telse\n\t\t\t\ty = *rt;\n\n\t\t\t// tmp = cov[x];\n\t\t\tin = mp[x];\n\t\t\tcov[in] = ev[in]*(y-x);\n\t\t\t// cout<\nusing namespace std;\n\n#define PB push_back\n#define CL(A,I) (memset(A,I,sizeof(A)))\n\n#define FOR(i, m, n) for (int i=m; i < n; i++)\n#define F(n) FOR(i,0,n)\n#define FF(n) FOR(j,0,n)\n\n#define D(X) cout<<\" \"<<#X\": \"<;\nusing vi=vector;\nusing vii=vector;\n\n#define aa first\n#define bb second\n\n#define EPS (1e-9)\n#define EQ(A,B) (A+EPS>B&&A-EPS g[6666];\nint lerank[6666];\n\nint vals[6666];\n\nint main() {\n CL(vals,-1);\n\n string s;\n getline(cin,s);\n\n int x = s.find_first_of(')');\n\n string gg = s.substr(2,x-2);\n string ff = s.substr(x+3);\n ff = ff.substr(0,ff.size()-1);\n\n map> remap;\n map nodemap;\n\n int ggi=0;\n int cnt=0;\n int ncnt=0;\n while(1){\n int gge = gg.find_first_not_of('_',ggi);\n\n // cout< podm;\n\n\n int ffi=0;\n while(1){\n int ffe = ff.find_first_of(',',ffi);\n\n string ss = ff.substr(ffi,ffe-ffi);\n\n // cout<'){\n g[nodemap[b]].PB(nodemap[a]);\n lerank[nodemap[a]]++;\n }\n else {\n g[nodemap[a]].PB(nodemap[b]);\n lerank[nodemap[b]]++;\n }\n\n ffi=ffe+1;\n\n if(ffe==-1) break;\n }\n\n vector q;\n F(ncnt) if(lerank[i]==0)q.PB(i);\n\n\n int val=0;\n int vis=0;\n while(q.size()){\n vector next;\n\n for(int node : q) {\n vis++;\n vals[node]=val;\n\n for(int neigh : g[node]) {\n lerank[neigh]--;\n if(lerank[neigh]==0)\n next.PB(neigh);\n }\n }\n\n val++;\n q = move(next);\n }\n\n if(vis!=ncnt || val>=10){\n cout<<\"false\"<\nusing namespace std;\n\n#define PB push_back\n#define CL(A,I) (memset(A,I,sizeof(A)))\n\n#define FOR(i, m, n) for (int i=m; i < n; i++)\n#define F(n) FOR(i,0,n)\n#define FF(n) FOR(j,0,n)\n\n#define D(X) cout<<\" \"<<#X\": \"<;\nusing vi=vector;\nusing vii=vector;\n\n#define aa first\n#define bb second\n\n#define EPS (1e-9)\n#define EQ(A,B) (A+EPS>B&&A-EPS g[6666];\nint lerank[6666];\n\nint vals[6666];\n\nint main() {\n CL(vals,-1);\n\n string s;\n getline(cin,s);\n\n int x = s.find_first_of(')');\n\n string gg = s.substr(2,x-2);\n string ff = s.substr(x+3);\n ff = ff.substr(0,ff.size()-1);\n\n map> remap;\n map nodemap;\n\n int ggi=0;\n int cnt=0;\n int ncnt=0;\n while(1){\n int gge = gg.find_first_not_of('_',ggi);\n\n // cout< podm;\n\n\n int ffi=0;\n while(1){\n int ffe = ff.find_first_of(',',ffi);\n\n string ss = ff.substr(ffi,ffe-ffi);\n\n // cout<'){\n g[nodemap[b]].PB(nodemap[a]);\n lerank[nodemap[a]]++;\n }\n else {\n g[nodemap[a]].PB(nodemap[b]);\n lerank[nodemap[b]]++;\n }\n\n ffi=ffe+1;\n\n if(ffe==-1) break;\n }\n\n vector q;\n F(ncnt) if(lerank[i]==0)q.PB(i);\n\n\n int val=0;\n int vis=0;\n while(q.size()){\n vector next;\n\n for(int node : q) {\n vis++;\n vals[node]=val;\n\n for(int neigh : g[node]) {\n lerank[neigh]--;\n if(lerank[neigh]==0)\n next.PB(neigh);\n }\n }\n\n val++;\n q = move(next);\n }\n\n if(vis!=ncnt){\n cout<<\"false\"<\n\nusing namespace std;\n\nint sz;\nint len[100];\nint val[100];\nbool b[100][100];\n\nint pos(char * s, char c) {\n for (int i = 0; s[i]; ++i) {\n if (s[i] == c) {\n return i;\n }\n }\n return -1000010101;\n}\n\nint getLen(char * s, int i) {\n int j = i;\n while (s[j] == '_') ++j; \n return j - i;\n}\n\nint main() {\n char s[10000];\n gets(s);\n int l = pos(s, '(');\n int r = pos(s, ')');\n for (int i = l; i < r; ++i) {\n if (s[i] != '_') continue;\n len[sz++] = getLen(s, i);\n i = i + len[sz - 1];\n }\n l = pos(s, '-') + 1;\n r = pos(s, '.');\n for (int i = l; i < r; ++i) {\n if (s[i] != '_') continue;\n int l1 = getLen(s, i);\n int l2 = getLen(s, i + l1 + 1);\n if (s[i + l1] == '>') swap(l1, l2);\n b[l1][l2] = true;\n i = i + l1 + 1 + l2;\n }\n for (bool did = true; did; ) {\n did = false;\n for (int i = 0; i < sz; ++i) {\n for (int j = 0; j < sz; ++j) {\n int l1 = len[i];\n int l2 = len[j];\n if (val[i] >= val[j] && b[l1][l2]) {\n val[j] = val[i] + 1;\n did = true;\n if (val[j] >= 10) {\n puts(\"false\");\n return 0;\n }\n }\n }\n }\n }\n for (int i = 0; i < sz; ++i) {\n putchar('0' + val[i]);\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cd1edf3067e17fdae844d264a5811833", "src_uid": "390a0b72c77ebe5881b656830fbfae02", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nbool dfs(vector * v, int start, int* used);\nvoid bfs(vector * v, int* l, int start);\n\nint main()\n{\n// freopen(\"input.txt\", \"r\", stdin);\n// freopen(\"output.txt\", \"w\", stdout);\n string s;\n cin >> s;\n vector a;\n set m;\n int i = 2;\n for(;s[i] != ')';i++)\n {\n for(;s[i] != '_';i++);\n int j = 0;\n for(;s[i] == '_';i++, j++);\n// cout << i << endl;\n i--;\n a.push_back(j);\n m.insert(j);\n }\n// for(int i = 0;i < a.size();i++)\n// cout << a[i] << ' ';\n vector * v = new vector [m.size()];\n for(;s[i] != '-';i++);\n i++;\n bool* q = new bool[m.size()];\n for(int i = 0;i < m.size();i++)\n q[i] = false;\n for(;i < s.size();i++)\n {\n for(;s[i] != '_';i++);\n int j = 0;\n for(;s[i] == '_';i++, j++);\n char c = s[i];\n i++;\n int j1 = 0;\n for(;s[i] == '_';i++, j1++);\n if(j == j1)\n {\n cout << \"false\";\n return 0;\n }\n int l = 0;\n set ::iterator t1 = m.find(j);\n for(set ::iterator t = m.begin();t != t1;++t, l++);\n int l1 = 0;\n t1 = m.find(j1);\n for(set ::iterator t = m.begin();t != t1;++t, l1++);\n if(c == '<')\n {\n \n v[l].push_back(l1);\n q[l1] = true;\n }\n if(c == '>')\n {\n v[l1].push_back(l);\n q[l] = true;\n }\n }\n int* path = new int[m.size()];\n int* used = new int[m.size()];\n for(int i = 0;i < m.size();i++)\n used[i] = path[i] = 0;\n for(int i = 0;i < m.size();i++)\n {\n if(!q[i])\n if(!dfs(v, i, used))\n {\n cout << \"false\";\n return 0;\n }\n }\n for(int i = 0;i < m.size();i++)\n if(!q[i])\n bfs(v, path, i);\n for(int i = 0;i < m.size();i++)\n// {\n if(path[i] > 9)\n {\n cout << \"false\";\n return 0;\n }\n// cout << v[i].size() << ' ';\n// for(int j = 0;j < v[i].size();j++)\n// cout << v[i][j] << ' ';\n// cout << path[i] << ' ';\n// cout << endl;\n// }\n for(int i = 0;i < a.size();i++)\n {\n set ::iterator t1 = m.find(a[i]);\n int l = 0;\n for(set ::iterator t = m.begin();t != t1;++t, ++l);\n cout << path[l];\n }\n return 0;\n}\n\nbool dfs(vector * v, int start, int* used)\n{\n used[start] = 1;\n for(int i = 0;i < v[start].size();i++)\n {\n if(used[v[start][i]] == 0)\n {\n// l[v[start][i]] = max(l[v[start][i]], l1 + 1);\n if(!dfs(v, v[start][i], used))\n return false;\n }\n if(used[v[start][i]] == 1)\n return false;\n }\n used[start] = 2;\n return true;\n}\n\nvoid bfs(vector * v, int* l, int start)\n{\n queue > q;\n q.push(make_pair(start, 0));\n l[start] = 0;\n while(!q.empty())\n {\n int t = q.front().first;\n l[t] = q.front().second;\n for(int i = 0;i < v[t].size();i++)\n q.push(make_pair(v[t][i], l[t] + 1));\n q.pop();\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d7bc4e4496d3b36f96e86990e744e501", "src_uid": "390a0b72c77ebe5881b656830fbfae02", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\n#define pb push_back\n#define mp make_pair\n#define eb emplace_back\n\ntypedef long long ll;\ntypedef long double ld;\n\nconst int inf = 2e9;\nconst ll base = 998244353;\nconst int maxn = 300500;\n\n\nint main() {\n srand(time(NULL));\n // freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"r\", stdin);\n std::ios_base::sync_with_stdio(false);\n std::cin.tie(nullptr);\n string a; cin >> a;\n int n = a.length();\n vector b(n);\n for (int i = 0; i < n; ++i) {\n if (a[i] == 'A') {\n b[i] = 1;\n } else {\n b[i] = 0;\n }\n }\n vector> dp1(n + 1), dp2(n + 1);\n dp1[0] = {1, 0};\n dp2[0] = {0, 1};\n map, pair, vector>> s;\n s[{0, 0}] = {{0, 1}, {}};\n s[{0, 1}] = {{1}, {0}};\n s[{1, 0}] = {{0, 1}, {1}};\n s[{1, 1}] = {{1}, {1}};\n for (int i = 1; i <= n; ++i) {\n int cur = i % n, prev = i - 1;\n for (auto c : s[{b[prev], b[cur]}].first) {\n if (!c) dp1[i].first += dp1[prev].first;\n else dp1[i].second += dp1[prev].first;\n if (!c) dp2[i].first += dp2[prev].first;\n else dp2[i].second += dp2[prev].first;\n }\n for (auto c : s[{b[prev], b[cur]}].second) {\n if (!c) dp1[i].first += dp1[prev].second;\n else dp1[i].second += dp1[prev].second;\n if (!c) dp2[i].first += dp2[prev].second;\n else dp2[i].second += dp2[prev].second;\n }\n }\n cout << 1LL*dp1[n].first + 1LL*dp2[n].second;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "51372f340b364389b2fef29d5e351e89", "src_uid": "ad27d991516054ea473b384bb2563b38", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long LL;\n\n#define oo 1000000000\n#define sqr(x) ((x)*(x))\n#define lowbit(x) ((x)&(-(x)))\n\nconst double pi = acos(-1.0);\n\n#define maxn 100 + 10\n\nint n;\nchar str[maxn];\nint f[maxn][2][2][2][2];\n\nint main()\n{\n\tint i,j,k,l,u,v,ans = 0;\n\n\tscanf(\"%s\",str+1);\n\tn = strlen(str+1);\n\n\tf[2][0][0][0][0] = 1, f[2][1][1][0][1] = 1, f[2][1][0][0][0] = 1, f[2][1][0][1][0] = 1;\n\tfor( i = 2 ; i < n ; ++i )\n\t\tfor( j = 0 ; j <= 1 ; ++j )\n\t\t\tfor( v = 0 ; v <= 1 ; ++v )\n\t\t\t\tfor( k = 0 ; k <= 1 ; ++k )\n\t\t\t\t\tfor( l = 0 ; l <= 1 ; ++l )\n\t\t\t\t\t\tfor( u = 0 ; u <= 1 ; ++u )\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif( k == 0 && u == 1 && l == 0 )\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tif( str[i] == 'B' )\n\t\t\t\t\t\t\t\t\t\t\tf[i+1][j][v][0][1] += f[i][j][v][k][l];\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse if( k == str[i]-'A' )\n\t\t\t\t\t\t\t\t\tf[i+1][j][v][u][0] += f[i][j][v][k][l];\n\t\t\t\t\t\t\t}\n\tfor( i = 0 ; i <= 1 ; ++i )\n\t\tfor( v = 0 ; v <= 1 ; ++v )\n\t\t\tfor( j = 0 ; j <= 1 ; ++j )\n\t\t\t\tfor( k = 0 ; k <= 1 ; ++k )\n\t\t\t\t\t{\n\t\t\t\t\t\tif( j == 0 && i == 1 && k == 0 && v == 0 )\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif( str[1] == 'A' && str[n] == 'B' )\n\t\t\t\t\t\t\t\t\tans += f[n][i][v][j][k];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\telse if( i == str[1]-'A' && j == str[n]-'A' )\n\t\t\t\t\t\t\tans += f[n][i][v][j][k];\n\t\t\t\t\t}\t\n\tprintf(\"%d\\n\",ans);\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d79f3dfd7b34c3e6ebf871a0bc88f112", "src_uid": "ad27d991516054ea473b384bb2563b38", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\n#define pb push_back\n#define mp make_pair\n#define eb emplace_back\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef int long long;\n\nconst int inf = 2e9;\nconst ll base = 998244353;\nconst int maxn = 300500;\n\n\nint main() {\n srand(time(NULL));\n // freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"r\", stdin);\n std::ios_base::sync_with_stdio(false);\n std::cin.tie(nullptr);\n string a; cin >> a;\n int n = a.length();\n vector b(n);\n for (int i = 0; i < n; ++i) {\n if (a[i] == 'A') {\n b[i] = 1;\n } else {\n b[i] = 0;\n }\n }\n vector> dp1(n + 1), dp2(n + 1);\n dp1[0] = {1, 0};\n dp2[0] = {0, 1};\n map, pair, vector>> s;\n s[{0, 0}] = {{0, 1}, {}};\n s[{0, 1}] = {{1}, {0}};\n s[{1, 0}] = {{0, 1}, {1}};\n s[{1, 1}] = {{1}, {1}};\n for (int i = 1; i <= n; ++i) {\n int cur = i % n, prev = i - 1;\n for (auto c : s[{b[prev], b[cur]}].first) {\n if (!c) dp1[i].first += dp1[prev].first;\n else dp1[i].second += dp1[prev].first;\n if (!c) dp2[i].first += dp2[prev].first;\n else dp2[i].second += dp2[prev].first;\n }\n for (auto c : s[{b[prev], b[cur]}].second) {\n if (!c) dp1[i].first += dp1[prev].second;\n else dp1[i].second += dp1[prev].second;\n if (!c) dp2[i].first += dp2[prev].second;\n else dp2[i].second += dp2[prev].second;\n }\n }\n cout << dp1[n].first + dp2[n].second;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "aaeae14854159e60ed4deb4327927421", "src_uid": "ad27d991516054ea473b384bb2563b38", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#pragma comment(linker, \"/STACK:100000000\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define int64 long long\n#define ldb long double\n#define pb push_back\n#define mp make_pair\n#define fs first\n#define sc second\n#define sz(a) ((int) (a).size())\n#define eprintf(...) fprintf(stderr, __VA_ARGS__)\n#define taskname \"task_c\"\nconst ldb pi = acos(-1.0);\n\nconst int MAXN = 150;\n\nstring s;\nbool is_ab[MAXN], used[MAXN];\nvector adj[MAXN];\nlong long cycles[MAXN], lines[MAXN];\n\nint dfs (int v) {\n\tused[v] = false;\n\n\tint num = 1;\n\tfor (int i = 0; i < sz(adj[v]); ++i) {\n\t\tif (!used[adj[v][i]]) {\n\t\t\tnum += dfs(adj[v][i]);\n\t\t}\n\t}\n\n\treturn num;\n}\n\nint main() {\n//\tassert(freopen(taskname\".in\", \"r\", stdin));\n//\tassert(freopen(taskname\".out\", \"w\", stdout));\n\n\tcin >> s;\n\treverse(s.begin(), s.end());\n\tint n = s.length();\n\n\tlines[0] = 1;\n\tlines[1] = 2;\n\tfor (int i = 2; i <= n / 2; ++i) {\n\t\tlines[i] = lines[i - 1] + lines[i - 2];\n\t}\n\n\tcycles[2] = 3;\n\tfor (int i = 3; i <= n / 2; ++i) {\n\t\tcycles[i] = lines[i - 1] + lines[i - 3];\n\t}\n\n\tfor (int i = 0; i < n; ++i) {\n\t\tis_ab[i] = false;\n\t}\n\n\tfor (int i = 0; i < n; ++i) {\n\t\tif (s[i] == 'A' && s[(i + 1) % n] == 'B') {\n\t\t\tis_ab[i] = true;\n\t\t}\n\t}\n\n\tint num_ab = 0;\n\tfor (int i = 0; i < n; ++i) {\n\t\tused[i] = !is_ab[i];\n\t\tnum_ab += (int) is_ab[i];\n\t}\n\n\tif (num_ab == n / 2 && (n % 2 == 0)) {\n\t\tcout << cycles[n / 2] << endl;\n\t\treturn 0;\n\t}\n\n\tfor (int i = 0; i < n; ++i) {\n\t\tif (s[i] == 'B' && s[(i + 1) % n] == 'A') {\n\t\t\tint v1 = (i - 1 + n) % n;\n\t\t\tint v2 = (i + 1) % n;\n\t\t\t\n\t\t\tif (!is_ab[v1] && !is_ab[v2]) {\n\t\t\t\tcout << 0 << endl;\n\t\t\t\treturn 0;\n\t\t\t} else if (is_ab[v1] && is_ab[v2]) {\n\t\t\t\tadj[v1].pb(v2);\n\t\t\t\tadj[v2].pb(v1);\n\t\t\t} else if (is_ab[v1]) {\n\t\t\t \tused[v1] = true;\n\t\t\t} else {\n\t\t\t\tused[v2] = true;\n\t\t\t}\n\t\t}\n\t}\n\n\tlong long ans = 1;\n\tfor (int i = 0; i < n; ++i) {\n\t\tif (!used[i]) {\n\t\t\tans = ans * lines[dfs(i)];\n\t\t}\n\t}\n\tcout << ans << endl;\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6f8e1ef41d2aaac329d032dded3e33b4", "src_uid": "ad27d991516054ea473b384bb2563b38", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include\n#include\nusing namespace std;\nconst int N=3000;\nconst double Pi=acos(-1),eps=1e-9;\nint n,k,c,Ans;\ndouble x[N],y[N],r[N];\nstruct cf{double x;int v;}q[N];\nint cmp(const cf&A,const cf&B) {return fabs(A.x-B.x)>n>>k;\n\tfor(int i=1;i<=n;i++) cin>>x[i]>>y[i]>>r[i];\n\tfor(double step=0.0005,st=0,ed=2*Pi,res;step>eps;step/=5)\n\t{\n\t\tint mx=0;\n\t\tfor(double i=st;imx) mx=nw,res=i;\n\t\t}\n\t\tst=res-step*5;\n\t\ted=res+step*5;\n\t\tAns=max(Ans,mx);\n\t}\n//\tprintf(\"Ans=%d\\n\",Ans);\n\tcout<<1ll*k*(k+1)/2+n+1ll*(Ans-1)*k<\n#include\nusing namespace std;\nconst int N=3000;\nconst double Pi=acos(-1),eps=1e-9;\nint n,k,c,Ans;\ndouble x[N],y[N],r[N];\nstruct cf{double x;int v;}q[N];\nint cmp(const cf&A,const cf&B) {return fabs(A.x-B.x)>n>>k;\n\tfor(int i=1;i<=n;i++) cin>>x[i]>>y[i]>>r[i];\n\tfor(double step=0.00005,st=0,ed=2*Pi,res;step>eps;step/=5)\n\t{\n\t\tint mx=0;\n\t\tfor(double i=st;imx) mx=nw,res=i;\n\t\t}\n\t\tst=res-step*5;\n\t\ted=res+step*5;\n\t\tAns=max(Ans,mx);\n\t}\n//\tprintf(\"Ans=%d\\n\",Ans);\n\tcout<<1ll*k*(k+1)/2+n+1ll*(Ans-1)*k<\n#include \n#include \n#include\n#include\n#include \n#include \n#include \n#include \n#include \n#include\n#include \n#include \n#include\n \nusing namespace std;\n \ntypedef long long ll;\ntypedef vector vi;\ntypedef pair pii;\ntypedef pair pdd;\ntypedef unsigned long long ull;\n \n#define FOR(i,a,b) for (int i(a); i < (b); i++)\n#define REP(i,n) FOR(i,0,n)\n#define SORT(v) sort((v).begin(),(v).end())\n#define UN(v) sort((v).begin(),(v).end()),v.erase(unique(v.begin(),v.end()),v.end())\n#define CL(a,b) memset(a,b,sizeof(a))\n#define pb push_back\n\ntypedef pair pdi;\n\nconst double eps = 1e-8;\nconst double pi = acos(-1.);\n\nint n;\nint x[1111],y[1111],r[1111];\n\ndouble getA(double a){\n\tif(a<0) return a+2*pi;\n\treturn a;\n}\nvoid add(vector &v, double a1,double a2,int q){\n\tif(a2<=2*pi){\n\t\tv.pb(pdi(a1+eps,q+1));\n\t\tv.pb(pdi(a2-eps,-q-1));\n\t}else{\n\t\tv.pb(pdi(0,q+1));\n\t\tv.pb(pdi(a2-2*pi-eps,-q-1));\n\t\tv.pb(pdi(a1+eps,q+1));\n\t\tv.pb(pdi(2*pi,-q-1));\n\t}\n}\n\ndouble go(int i,int j,double a,double b,double c){\n\tif(a<0 || aeps) xx = -xx, yy = -yy;\n\t//cout< v;\n\t\tREP(j,n)if(i!=j){\n\t\t\tdouble ang[9];int pos=0;\n\t\t\tREP(t1,2)REP(t2,2){\n\t\t\t\tdouble c = (t1?-r[i]:r[i]);\n\t\t\t\tdouble E = (t2?-r[j]:r[j])-c;\n\t\t\t\tif(x[j]==0){\n\t\t\t\t\tdouble b = E / y[j];\n\t\t\t\t\tdouble a1 = sqrt(1-b*b);\n\t\t\t\t\tdouble a2 = -a1;\n\n\t\t\t\t\tang[pos++]=go(i,j,a1,b,c);\n\t\t\t\t\tang[pos++]=go(i,j,a2,b,c);\n\t\t\t\t}else{\n\t\t\t\t\tdouble A = E/x[j];\n\t\t\t\t\tdouble B = -y[j]/double(x[j]);\n\n\t\t\t\t\tdouble k1 = B*B+1;\n\t\t\t\t\tdouble k2 = 2*A*B;\n\t\t\t\t\tdouble k3 = A*A-1;\n\t\t\t\t\tdouble D = k2*k2-4*k1*k3;\n\t\t\t\t\tD = sqrt(D);\n\n\t\t\t\t\tdouble b1 = (-k2-D)/2/k1;\n\t\t\t\t\tdouble b2 = (-k2+D)/2/k1;\n\t\t\t\t\tdouble a1 = A+B*b1;\n\t\t\t\t\tdouble a2 = A+B*b2;\n\n\t\t\t\t\tang[pos++]=go(i,j,a1,b1,c);\n\t\t\t\t\tang[pos++]=go(i,j,a2,b2,c);\n\t\t\t\t}\n\t\t\t}\n\t\t\tsort(ang,ang+8);\n\t\t\tang[8]=ang[0]+2*pi;\n\t\t\t//REP(k,9) cout<=0) cnt++;\n\t\t\telse cnt--;\n\t\t\tz=max(z,cnt);\n\t\t}\n\t\t//cout<>n>>k;\n\tREP(i,n) scanf(\"%d %d %d\",x+i,y+i,r+i);\n\tcout<\n#include\nusing namespace std;\nconst int N=3000;\nconst double Pi=acos(-1),eps=1e-9;\nint n,k,c,Ans;\ndouble x[N],y[N],r[N];\nstruct cf{double x;int v;}q[N];\nint cmp(const cf&A,const cf&B) {return fabs(A.x-B.x)>n>>k;\n\tfor(int i=1;i<=n;i++) cin>>x[i]>>y[i]>>r[i];\n\tfor(double step=0.0005,st=0,ed=2*Pi,res;step>eps;step/=10)\n\t{\n\t\tint mx=0;\n\t\tfor(double i=st;imx) mx=nw,res=i;\n\t\t}\n\t\tst=res-step*5;\n\t\ted=res+step*5;\n\t\tAns=max(Ans,mx);\n\t}\n//\tprintf(\"Ans=%d\\n\",Ans);\n\tcout<<1ll*k*(k+1)/2+n+1ll*(Ans-1)*k<\nusing namespace std;\n\nusing ll=long long;\n//#define int ll\n\n#define rng(i,a,b) for(int i=int(a);i=int(a);i--)\n#define per(i,b) gnr(i,0,b)\n#define pb push_back\n#define eb emplace_back\n#define a first\n#define b second\n#define bg begin()\n#define ed end()\n#define all(x) x.bg,x.ed\n#define si(x) int(x.size())\n#ifdef LOCAL\n#define dmp(x) cerr<<__LINE__<<\" \"<<#x<<\" \"< void chmax(t&a,u b){if(a void chmin(t&a,u b){if(b using vc=vector;\ntemplate using vvc=vc>;\n\nusing pi=pair;\nusing vi=vc;\n\ntemplate\nostream& operator<<(ostream& os,const pair& p){\n\treturn os<<\"{\"< ostream& operator<<(ostream& os,const vc& v){\n\tos<<\"{\";\n\tfor(auto e:v)os<\nvoid dmpr(ostream&os,const T&t,const Args&... args){\n\tos<\nostream& operator<<(ostream&os,const array&a){\n\treturn os<(all(a));\n}\n\ntemplate\nvoid print_tuple(ostream&,const T&){\n}\n\ntemplate\nvoid print_tuple(ostream&os,const T&t){\n\tif(i)os<<\",\";\n\tos<(t);\n\tprint_tuple(os,t);\n}\n\ntemplate\nostream& operator<<(ostream&os,const tuple&t){\n\tos<<\"{\";\n\tprint_tuple<0,tuple,Args...>(os,t);\n\treturn os<<\"}\";\n}\n\ntemplate\nvoid print(t x,int suc=1){\n\tcout<>i;\n\treturn i;\n}\n\nvi readvi(int n,int off=0){\n\tvi v(n);\n\trep(i,n)v[i]=read()+off;\n\treturn v;\n}\n\ntemplate\nvoid print(const vector&v,int suc=1){\n\trep(i,v.size())\n\t\tprint(v[i],i==int(v.size())-1?suc:2);\n}\n\nstring readString(){\n\tstring s;\n\tcin>>s;\n\treturn s;\n}\n\ntemplate\nT sq(const T& t){\n\treturn t*t;\n}\n\n//#define CAPITAL\nvoid yes(bool ex=true){\n\t#ifdef CAPITAL\n\tcout<<\"YES\"<<\"\\n\";\n\t#else\n\tcout<<\"Yes\"<<\"\\n\";\n\t#endif\n\tif(ex)exit(0);\n}\nvoid no(bool ex=true){\n\t#ifdef CAPITAL\n\tcout<<\"NO\"<<\"\\n\";\n\t#else\n\tcout<<\"No\"<<\"\\n\";\n\t#endif\n\tif(ex)exit(0);\n}\nvoid possible(bool ex=true){\n\t#ifdef CAPITAL\n\tcout<<\"POSSIBLE\"<<\"\\n\";\n\t#else\n\tcout<<\"Possible\"<<\"\\n\";\n\t#endif\n\tif(ex)exit(0);\n}\nvoid impossible(bool ex=true){\n\t#ifdef CAPITAL\n\tcout<<\"IMPOSSIBLE\"<<\"\\n\";\n\t#else\n\tcout<<\"Impossible\"<<\"\\n\";\n\t#endif\n\tif(ex)exit(0);\n}\n\nconstexpr ll ten(int n){\n\treturn n==0?1:ten(n-1)*10;\n}\n\nconst ll infLL=LLONG_MAX/3;\n\n#ifdef int\nconst int inf=infLL;\n#else\nconst int inf=INT_MAX/2-100;\n#endif\n\nint topbit(signed t){\n\treturn t==0?-1:31-__builtin_clz(t);\n}\nint topbit(ll t){\n\treturn t==0?-1:63-__builtin_clzll(t);\n}\nint botbit(signed a){\n\treturn a==0?32:__builtin_ctz(a);\n}\nint botbit(ll a){\n\treturn a==0?64:__builtin_ctzll(a);\n}\nint popcount(signed t){\n\treturn __builtin_popcount(t);\n}\nint popcount(ll t){\n\treturn __builtin_popcountll(t);\n}\nbool ispow2(int i){\n\treturn i&&(i&-i)==i;\n}\nint mask(int i){\n\treturn (int(1)< void mkuni(vc&v){\n\tsort(all(v));\n\tv.erase(unique(all(v)),v.ed);\n}\n\nll rand_int(ll l, ll r) { //[l, r]\n\t#ifdef LOCAL\n\tstatic mt19937_64 gen;\n\t#else\n static random_device rd;\n static mt19937_64 gen(rd());\n #endif\n return uniform_int_distribution(l, r)(gen);\n}\n\ntemplate\nint lwb(const vc&v,const t&a){\n\treturn lower_bound(all(v),a)-v.bg;\n}\n\nusing uint=unsigned;\nusing ull=unsigned long long;\n\nstruct modinfo{uint mod,root;};\ntemplate\nstruct modular{\n\tstatic constexpr uint const &mod=ref.mod;\n\tstatic modular root(){return modular(ref.root);}\n\tuint v;\n\t//modular(initializer_listls):v(*ls.bg){}\n\tmodular(ll vv=0){s(vv%mod+mod);}\n\tmodular& s(uint vv){\n\t\tv=vv>=1;\n\t\t}\n\t\treturn res;\n\t}\n\tmodular inv()const{return pow(mod-2);}\n\t/*modular inv()const{\n\t\tint x,y;\n\t\tint g=extgcd(v,mod,x,y);\n\t\tassert(g==1);\n\t\tif(x<0)x+=mod;\n\t\treturn modular(x);\n\t}*/\n\tfriend modular operator+(int x,const modular&y){\n\t\treturn modular(x)+y;\n\t}\n\tfriend modular operator-(int x,const modular&y){\n\t\treturn modular(x)-y;\n\t}\n\tfriend modular operator*(int x,const modular&y){\n\t\treturn modular(x)*y;\n\t}\n\tfriend modular operator/(int x,const modular&y){\n\t\treturn modular(x)/y;\n\t}\n\tfriend ostream& operator<<(ostream&os,const modular&m){\n\t\treturn os<>(istream&is,modular&m){\n\t\tll x;is>>x;\n\t\tm=modular(x);\n\t\treturn is;\n\t}\n\tbool operator<(const modular&r)const{return v;\n\nconst int vmax=(1<<21)+10;\nmint fact[vmax],finv[vmax],invs[vmax];\nvoid initfact(){\n\tfact[0]=1;\n\trng(i,1,vmax){\n\t\tfact[i]=fact[i-1]*i;\n\t}\n\tfinv[vmax-1]=fact[vmax-1].inv();\n\tfor(int i=vmax-2;i>=0;i--){\n\t\tfinv[i]=finv[i+1]*(i+1);\n\t}\n\tfor(int i=vmax-1;i>=1;i--){\n\t\tinvs[i]=finv[i]*fact[i-1];\n\t}\n}\nmint choose(int n,int k){\n\treturn fact[n]*finv[n-k]*finv[k];\n}\nmint binom(int a,int b){\n\treturn fact[a+b]*finv[a]*finv[b];\n}\nmint catalan(int n){\n\treturn binom(n,n)-(n-1>=0?binom(n-1,n+1):0);\n}\n\nvc mod_f(vc x,const vc&f){\n\tint k=si(f);\n\tgnr(i,k-1,si(x)){\n\t\tmint w=x[i]/f[k-1];\n\t\trep(p,k-1)x[i-(k-1)+p]-=w*f[p];\n\t}\n\tx.resize(k-1);\n\treturn x;\n}\n\nvc mult_mod_f(const vc&x,const vc&y,const vc&f){\n\tint n=si(x),m=si(y);\n\tvc res(n+m-1);\n\trep(i,n)rep(j,m)res[i+j]+=x[i]*y[j];\n\treturn mod_f(res,f);\n}\n\nvc pow_mod_f(vc x,int n,const vc&f){\n\tvc res{1};\n\twhile(n){\n\t\tif(n&1)res=mult_mod_f(res,x,f);\n\t\tx=mult_mod_f(x,x,f);\n\t\tn>>=1;\n\t}\n\treturn res;\n}\n\n// for all valid i, sum_j a_{i+j}*res_j = 0\n// x^n % res \u3067 n \u9805\u76ee\u304c\u6c42\u307e\u308b\n// \u591a\u9805\u5f0f\u306e\u5411\u304d\u306b\u6ce8\u610f\nvc berlekamp_massey(const vc& a){\n\tvc b{1},c{0};\n\tmint d=1;\n\trep(i,a.size()){\n\t\tint n=b.size();\n\t\tmint w=0;\n\t\trep(j,n)\n\t\t\tw+=a[i-(n-1)+j]*b[j];\n\t\tc.pb(0);\n\t\tif(!w.v)continue;\n\t\tint m=c.size();\n\t\tmint e=-w/d;\n\t\tif(m>n){\n\t\t\tauto tmp=b;\n\t\t\tb.insert(b.bg,m-n,0);\n\t\t\trep(j,m)\n\t\t\t\tb[j]+=e*c[j];\n\t\t\tc=tmp;\n\t\t\td=w;\n\t\t}else{\n\t\t\trep(j,m)\n\t\t\t\tb[n-m+j]+=e*c[j];\n\t\t}\n\t}\n\treturn b;\n}\n\nmint get_kth(const vc&a,int k){\n\tauto p=berlekamp_massey(a);\n\tif(si(p)==1)return 0;\n\tauto q=pow_mod_f({0,1},k,p);\n\tmint res=0;\n\trep(i,si(q))res+=a[i]*q[i];\n\treturn res;\n}\n\n//(-pi,0](0,pi]\nint argtype(pi a){\n\tif(a.b==0)return a.a<0?1:0;\n\treturn a.b<0?0:1;\n}\nbool argless(pi a,pi b){\n\tint at=argtype(a),bt=argtype(b);\n\tif(at!=bt)return at0;\n};\n\nmint interpolate(const vc&a,mint x){\n\tint n=si(a);\n\tif(inc(0,x.v,n-1))return a[x.v];\n\tmint w=1;\n\trep(i,n)w*=x-i;\n\tmint res;\n\trep(i,n)res+=w/(x-i)*a[i]*finv[i]*finv[n-1-i]*((n-1-i)%2?-1:1);\n\treturn res;\n}\n\nconst int mmax=185;\n//const int mmax=15;\n\nmint dp[mmax][mmax];\nmint buf[mmax][mmax];\n\nsigned main(){\n\tcin.tie(0);\n\tios::sync_with_stdio(0);\n\tcout<>n>>m;\n\tvc xy;\n\trep(i,n){\n\t\tint x,y;cin>>x>>y;\n\t\txy.eb(x,y);\n\t}\n\tsort(all(xy),argless);\n\tdmp(xy);\n\tint L=mmax-5;\n\trep(w,L)rng(h,w,w+2){\n\t\trep(sx,w+1)rng(sy,h,h+1){\n\t\t\tzero(dp);\n\t\t\tdp[sx][sy]=1;\n\t\t\tfor(auto z:xy){\n\t\t\t\trep(xx,w+1)rep(yy,h+1){\n\t\t\t\t\tint x=z.a<0?w-xx:xx;\n\t\t\t\t\tint y=z.b<0?h-yy:yy;\n\t\t\t\t\tint p=x+z.a,q=y+z.b;\n\t\t\t\t\tif(inc(0,p,w)&&inc(0,q,h)){\n\t\t\t\t\t\tdp[p][q]+=dp[x][y];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbuf[w][h]+=dp[sx][sy]-1;\n\t\t}\n\t}\n\tvc val(L);\n\t//rng(i,1,L)val[i]=buf[i][i]-buf[i][i-1]*2+buf[i-1][i-1];\n\trng(i,1,L)val[i]=buf[i][i]-buf[i-1][i];\n\t\n\tcout<\n#define int long long\nusing namespace std;\nconst int N=5;\nconst int LOG=30;\nconst int mod=998244353;\nvoid add(int &x,int y){\n\tx+=y;\n\tif(x>=mod){\n\t\tx-=mod;\n\t}\n}\nvector > > > dp[LOG+2][2][2];\nint x[N],y[N],maxdime[LOG+1][4][2][2],cost[1<>n>>m;\n\tfor(i=0;i>x[i]>>y[i];\n\t}\n\tfor(i=0;i<(1<0){\n\t\t\t\t\tcost[i][0]+=x[j];\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tcost[i][2]-=x[j];\n\t\t\t\t}\n\t\t\t\tif(y[j]>0){\n\t\t\t\t\tcost[i][1]+=y[j];\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tcost[i][3]-=y[j];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tdp[0][0][0].resize(1);\n\tdp[0][0][0][0].resize(1);\n\tdp[0][0][0][0][0].resize(1);\n\tdp[0][0][0][0][0][0].resize(1);\n\tdp[0][0][0][0][0][0][0]=1;\n\tmemset(maxdime,-1,sizeof(maxdime));\n\tmaxdime[0][0][0][0]=maxdime[0][1][0][0]=maxdime[0][2][0][0]=maxdime[0][3][0][0]=0;\n\tfor(i=0;i>i)&1)){\n\t\t\t\t\t\t\t\t\t\t\tnewk=0;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\t\n\t\t\t\t\t\t\t\t\telse{\n\t\t\t\t\t\t\t\t\t\tif((newpx&1)>((m>>i)&1)){\n\t\t\t\t\t\t\t\t\t\t\tnewk=1;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif(l){\n\t\t\t\t\t\t\t\t\t\tif((newpy&1)<((m>>i)&1)){\n\t\t\t\t\t\t\t\t\t\t\tnewl=0;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\t\n\t\t\t\t\t\t\t\t\telse{\n\t\t\t\t\t\t\t\t\t\tif((newpy&1)>((m>>i)&1)){\n\t\t\t\t\t\t\t\t\t\t\tnewl=1;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmaxdime[i+1][0][newk][newl]=max(maxdime[i+1][0][newk][newl],newpx/2);\n\t\t\t\t\t\t\t\t\tmaxdime[i+1][1][newk][newl]=max(maxdime[i+1][1][newk][newl],newpy/2);\n\t\t\t\t\t\t\t\t\tmaxdime[i+1][2][newk][newl]=max(maxdime[i+1][2][newk][newl],newnx/2);\n\t\t\t\t\t\t\t\t\tmaxdime[i+1][3][newk][newl]=max(maxdime[i+1][3][newk][newl],newny/2);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(k=0;k<2;k++){\n\t\t\tfor(l=0;l<2;l++){\n\t\t\t\tdp[i+1][k][l].resize(maxdime[i+1][0][k][l]+1);\n\t\t\t\tfor(px=0;px<=maxdime[i+1][0][k][l];px++){\n\t\t\t\t\tdp[i+1][k][l][px].resize(maxdime[i+1][1][k][l]+1);\n\t\t\t\t\tfor(py=0;py<=maxdime[i+1][1][k][l];py++){\n\t\t\t\t\t\tdp[i+1][k][l][px][py].resize(maxdime[i+1][2][k][l]+1);\n\t\t\t\t\t\tfor(nx=0;nx<=maxdime[i+1][2][k][l];nx++){\n\t\t\t\t\t\t\tdp[i+1][k][l][px][py][nx].resize(maxdime[i+1][3][k][l]+1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor(j=0;j<(1<>i)&1)){\n\t\t\t\t\t\t\t\t\t\t\tnewk=0;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\t\n\t\t\t\t\t\t\t\t\telse{\n\t\t\t\t\t\t\t\t\t\tif((newpx&1)>((m>>i)&1)){\n\t\t\t\t\t\t\t\t\t\t\tnewk=1;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif(l){\n\t\t\t\t\t\t\t\t\t\tif((newpy&1)<((m>>i)&1)){\n\t\t\t\t\t\t\t\t\t\t\tnewl=0;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\t\n\t\t\t\t\t\t\t\t\telse{\n\t\t\t\t\t\t\t\t\t\tif((newpy&1)>((m>>i)&1)){\n\t\t\t\t\t\t\t\t\t\t\tnewl=1;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tadd(dp[i+1][newk][newl][newpx/2][newpy/2][newnx/2][newny/2],dp[i][k][l][px][py][nx][ny]);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tcout<\nusing namespace std;\nconst int N=12,p=998244353;\nint n,k,m,f1[33],f2[33],f3[33],f4[33],dp[33][N][N][N][N][2][2];\nstruct node{\n\tint x,y;\n}e[114],g[514];\ninline int inc(int a,int b){\n\tif(a+b>=p) return a+b-p; return a+b;\n}\nint main(){\n\tcin>>n>>m;\n\tfor(int i=1;i<=n;i++) cin>>e[i].x>>e[i].y;\n\tfor(int i=1;i<=n;i++){\n\t\tk++,g[k]=e[i];\n\t}\n\tdp[0][0][0][0][0][0][0]=1;\n\tfor(int i=0;i<(1<0) f1[i]+=abs(a); else f2[i]+=abs(a); if(b>0) f3[i]+=abs(b); else f4[i]+=abs(b);\n\t\t}\n\tfor(int i=1;i<=32;i++){\n\t\tfor(int a=0;a<=10;a++)\n\t\t\tfor(int b=0;b<=10;b++)\n\t\t\t\tfor(int c=0;c<=10;c++)\n\t\t\t\t\tfor(int d=0;d<=10;d++)\n\t\t\t\t\t\tfor(int e=0;e<=1;e++)\n\t\t\t\t\t\t\tfor(int f=0;f<=1;f++)\n\t\t\t\t\t\t\t\tfor(int x=0;x<(1<(m&1)) z1=1; \n\t\t\t\t\t\t\t\t\tif(((a+f1[x])&1)==(m&1)&&e==1) z1=1;\n\t\t\t\t\t\t\t\t\tif(((c+f3[x])&1)>(m&1)) z2=1; \n\t\t\t\t\t\t\t\t\tif(((c+f3[x])&1)==(m&1)&&f==1) z2=1;\n\t\t\t\t\t\t\t\t\tdp[i][(a+f1[x])>>1][(b+f2[x])>>1][(c+f3[x])>>1][(d+f4[x])>>1][z1][z2]=inc(dp[i][(a+f1[x])>>1][(b+f2[x])>>1][(c+f3[x])>>1][(d+f4[x])>>1][z1][z2],dp[i-1][a][b][c][d][e][f]);\n\t\t\t\t\t\t\t\t}\n\t\tm=m>>1;\n\t}\n\tcout<<(dp[32][0][0][0][0][0][0]-1+p)%p<\n#include \n#include \n \nusing namespace __gnu_pbds;\nusing namespace std;\n \ntemplate \nusing ordered_set =\n tree, rb_tree_tag, tree_order_statistics_node_update>;\n \n#define sim template < class c\n#define ris return * this\n#define dor > debug & operator <<\n#define eni(x) sim > typename \\\n enable_if(0) x 1, debug&>::type operator<<(c i) {\nsim > struct rge { c b, e; };\nsim > rge range(c i, c j) { return rge{i, j}; }\nsim > auto dud(c* x) -> decltype(cerr << *x, 0);\nsim > char dud(...);\nstruct debug {\n#ifdef LOCAL\n~debug() { cerr << endl; }\neni(!=) cerr << boolalpha << i; ris; }\neni(==) ris << range(begin(i), end(i)); }\nsim, class b dor(pair < b, c > d) {\n ris << \"(\" << d.first << \", \" << d.second << \")\";\n}\nsim dor(rge d) {\n *this << \"[\";\n for (auto it = d.b; it != d.e; ++it)\n *this << \", \" + 2 * (it == d.b) << *it;\n ris << \"]\";\n}\n#else\nsim dor(const c&) { ris; }\n#endif\n};\n#define imie(...) \" [\" << #__VA_ARGS__ \": \" << (__VA_ARGS__) << \"] \"\n \n#define shandom_ruffle random_shuffle\n \nusing ll=long long;\nusing pii=pair;\nusing pll=pair;\nusing vi=vector;\nusing vll=vector;\nconst int nax=1000*1007;\nconst ll mod=998244353;\n \nvoid add_self(int & a, int b) { a += b; if(a >= mod) a -= mod; }\nvoid sub_self(int & a, int b) { a -= b; if(a < 0) a += mod; }\nint mul(int a, int b) { return (ll) a * b % mod; }\nint my_pow(int a, int b) {\n\tint r = 1;\n\twhile(b) {\n\t\tif(b % 2) r = mul(r, a);\n\t\ta = mul(a, a);\n\t\tb /= 2;\n\t}\n\treturn r;\n}\nint my_inv(int a) { return my_pow(a, mod - 2); }\nstruct Massey {\n\tvector start, coef; // 3 optional lines\n\tvector> powers;\n\tint memo_inv;\n\t// Start here and write the next ~25 lines until \"STOP\"\n\tint L; // L == coef.size() <= start.size()\n\tMassey(vector in) { // O(N^2)\n\t\tL = 0;\n\t\tconst int N = in.size();\n\t\tvector C{1}, B{1};\n\t\tfor(int n = 0; n < N; ++n) {\n\t\t\tassert(0 <= in[n] && in[n] < mod); // invalid input\n\t\t\tB.insert(B.begin(), 0);\n\t\t\tint d = 0;\n\t\t\tfor(int i = 0; i <= L; ++i)\n\t\t\t\tadd_self(d, mul(C[i], in[n-i]));\n\t\t\tif(d == 0) continue;\n\t\t\tvector T = C;\n\t\t\tC.resize(max(B.size(), C.size()));\n\t\t\tfor(int i = 0; i < (int) B.size(); ++i)\n\t\t\t\tsub_self(C[i], mul(d, B[i]));\n\t\t\tif(2 * L <= n) {\n\t\t\t\tL = n + 1 - L;\n\t\t\t\tB = T;\n\t\t\t\td = my_inv(d);\n\t\t\t\tfor(int & x : B) x = mul(x, d);\n\t\t\t}\n\t\t}\n\t\tcerr << \"L = \" << L << \"\\n\";\n\t\tassert(2 * L <= N - 2); // NO RELATION FOUND :(\n\t\t// === STOP ===\n\t\tfor(int i = 1; i < (int) C.size(); ++i)\n\t\t\tcoef.push_back((mod - C[i]) % mod);\n\t\tassert((int) coef.size() == L);\n\t\tfor(int i = 0; i < L; ++i)\n\t\t\tstart.push_back(in[i]);\n\t\twhile(!coef.empty() && !coef.back()) { coef.pop_back(); --L; }\n\t\tif(!coef.empty()) memo_inv = my_inv(coef.back());\n\t\tpowers.push_back(coef);\n\t}\n\tvector mul_cut(vector a, vector b) {\n\t\tvector r(2 * L - 1);\n\t\tfor(int i = 0; i < L; ++i)\n\t\t\tfor(int j = 0; j < L; ++j)\n\t\t\t\tadd_self(r[i+j], mul(a[i], b[j]));\n\t\twhile((int) r.size() > L) {\n\t\t\tint value = mul(r.back(), memo_inv); // div(r.back(), coef.back());\n\t\t\tconst int X = r.size();\n\t\t\tadd_self(r[X-L-1], value);\n\t\t\tfor(int i = 0; i < L; ++i)\n\t\t\t\tsub_self(r[X-L+i], mul(value, coef[i]));\n\t\t\tassert(r.back() == 0);\n\t\t\tr.pop_back();\n\t\t}\n\t\treturn r;\n\t}\n\tint get(ll k) { // O(L^2 * log(k))\n\t\tif(k < (int) start.size()) return start[k];\n\t\tif(L == 0) return 0;\n\t\tk -= start.size();\n\t\tvector vec = coef;\n\t\tfor(int i = 0; (1LL << i) <= k; ++i) {\n\t\t\tif(i == (int) powers.size())\n\t\t\t\tpowers.push_back(mul_cut(powers.back(), powers.back()));\n\t\t\tif(k & (1LL << i))\n\t\t\t\tvec = mul_cut(vec, powers[i]);\n\t\t}\n\t\tint total = 0;\n\t\tfor(int i = 0; i < L; ++i)\n\t\t\tadd_self(total, mul(vec[i], start[(int)start.size()-1-i]));\n\t\treturn total;\n\t}\n};\n \nint n;\nll m;\n \npii tab[nax];\n \nll ile[nax];\n \nint n1, n2;\n \nconst int d=1000;\n \nvector mapa[2*d+7][2*d+7];\n \nvoid rek1(int v, int x, int y, int sx, int sy)\n{\n\tif (abs(x)>d || abs(y)>d || sx>d || sy>d)\n\t\treturn;\n\tif (v==n1)\n\t{\n\t\tmapa[x+d][y+d].push_back({sx, sy});\n\t\treturn;\n\t}\n\tfor (int i=0; i<=d; i++)\n\t{\n\t\trek1(v-1, x+tab[v].first*i, y+tab[v].second*i, sx+max(tab[v].first, 0)*i, sy+max(tab[v].second, 0)*i);\n\t}\n}\n \nvoid rek2(int v, int x, int y, int sx, int sy)\n{\n\tif (abs(x)>d || abs(y)>d || sx>d || sy>d)\n\t\treturn;\n\tif (v==n1+1)\n\t{\n\t\tfor (pii i : mapa[-x+d][-y+d])\n\t\t{\n\t\t\tile[max(sx+i.first, sy+i.second)]++;\n\t\t}\n\t\t//~ mapa[x+d][y+d].push_back({sx, sy});\n\t\treturn;\n\t}\n\tfor (int i=0; i<=d; i++)\n\t{\n\t\trek2(v+1, x+tab[v].first*i, y+tab[v].second*i, sx+max(tab[v].first, 0)*i, sy+max(tab[v].second, 0)*i);\n\t}\n}\n \nint main()\n{\n\tscanf(\"%d%lld\", &n, &m);\n\tfor (int i=1; i<=n; i++)\n\t\tscanf(\"%d%d\", &tab[i].first, &tab[i].second);\n\tn1=(n+1)/2;\n\trek1(n, 0, 0, 0, 0);\n\trek2(1, 0, 0, 0, 0);\n\tvi wez;\n\tll s=0;\n\tfor (int i=0; i<=d; i++)\n\t{\n\t\ts+=ile[i];\n\t\ts%=mod;\n\t\twez.push_back(s);\n\t}\n\tdebug() << wez;\n\tMassey mas=Massey(wez);\n\tprintf(\"%lld\\n\", (mas.get(m)-1+mod)%mod);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e94a32baad3ad7875ad2bc306715dc58", "src_uid": "fba104bc43111a6f2692216a4edea2bc", "difficulty": 3500.0} {"lang": "GNU C++11", "source_code": "// by \u03be\n// program sky :)\n\n#include \n#include \n#include \n\n#define elif else if\n#define For(i,l,r) for(int _r=r,i=l;i<=_r;++i)\n#define rep(i,l,r) for(int _r=r,i=l;i<_r;++i)\n#define dto(i,r,l) for(int _l=l,i=r;i>=_l;--i)\n\nusing namespace std;\n\ninline void hello(){\n\t//freopen(\"painting.in\",\"r\",stdin);\n\t//freopen(\"painting.out\",\"w\",stdout);\n}\n\nint n,K,mo,M,dp[2][201][16],he[55],binom[55][55],tr[55][55][201],kua[55],way[55][5];\n\nstruct Edge{\n\tint v,k,con,nxt;\n}Ed[5000];\n\n#define cnt(x) (__builtin_popcount(x))\n\ninline void inc(int &x,int y){\n\tif((x+=y)>=mo)x-=mo;\n}\n\ninline void Add(int u,int v,int k,int con){\n\tEd[++M]=(Edge){v,k,con,he[u]};he[u]=M;\n}\n\nint main(){\n// say hello\n\thello();\n\tscanf(\"%d%d%d\",&n,&K,&mo);\n\n\tFor(i,0,22){\n\t\t*binom[i]=1;\n\t\tFor(j,1,i)\n\t\t\tbinom[i][j]=(binom[i-1][j-1]+binom[i-1][j])%mo;\n\t}\n\tint lim=1<<4;--lim;\n\n\tkua[0]=4;\n\tkua[1]=kua[2]=kua[4]=kua[8]=2;\n\tkua[3]=kua[6]=kua[9]=kua[12]=1;\n\n\tway[0][0]=1;\n\tway[1][1]=way[2][1]=way[4][1]=way[8][1]=1;\n\tway[5][2]=way[10][2]=1;\n\tway[3][1]=way[6][1]=way[9][1]=way[12][1]=1;\n\tway[3][2]=way[6][2]=way[9][2]=way[12][2]=1;\n\tway[7][3]=way[11][3]=way[13][3]=way[14][3]=1;\n\tway[7][2]=way[11][2]=way[13][2]=way[14][2]=2;\n\tway[15][4]=1;\n\tway[15][2]=2;\n\tway[15][3]=4;\n\t\n\tFor(i,0,lim)\n\tFor(j,0,lim)if((j&i)==0){\n\t\tint k=i|j;\n\t\tFor(p,0,kua[k]){\n\t\t\tint _=(4-cnt(k))*3-p*2;\n\t\t\tFor(q,0,_)\n\t\t\t\tFor(cn,0,4)if(way[j][cn])\n\t\t\t\tinc(tr[i][k][cn+p+q],1ll*binom[kua[k]][p]*binom[_][q]%mo*way[j][cn]%mo);\n\t\t}\n\t}\n\n\tFor(i,0,lim)dto(k,12,0)For(j,0,lim)\n\t\tif(tr[i][j][k])Add(i,j,k,tr[i][j][k]);\n\t\n\tdp[n+1&1][0][0]=1;\n\t\n\tdto(i,n+1,2){\n\t\tint p=i&1,q=p^1;\n\t\tmemset(dp[q],0,sizeof dp[q]);\n\t\tFor(k,0,K)\n\t\tFor(mask,0,lim)if(dp[p][k][mask])\n\t\t\tfor(int e=he[mask];e;e=Ed[e].nxt){\n\t\t\t\tint kk=k+Ed[e].k;\n\t\t\t\tif(kk>K)break;\n\t\t\t\tinc(dp[q][kk][Ed[e].v],1ll*dp[p][k][mask]*Ed[e].con%mo);\n\t\t\t}\n\t}\n\t\n\tdto(i,lim,0)\n\tFor(j,0,lim)if(j>i && (i&j)==i)\n\tFor(k,0,4)\n\tinc(way[j][k],way[i][k]);\n\t\n\tint res=0;\n\tFor(k,max(K-4,0),K)\n\tFor(mask,0,lim)if(dp[1][k][mask])\n\t\tinc(res,1ll*dp[1][k][mask]*way[lim-mask][K-k]%mo);\n\t\n\tFor(i,2,K)res=1ll*res*i%mo;\n\tprintf(\"%d\\n\",res%mo);\n// never say goodbye\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0541df489d4038ebf23a28a7f50b6cfe", "src_uid": "fa649fed687d72b1431ac82bc7288116", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef signed long long ll;\n\n#undef _P\n#define _P(...) (void)printf(__VA_ARGS__)\n\n#define FOR(x,to) for(x=0;x0) {\n int ma2=mask^ma;\n if(ma2==13 || ma2==11 || ma2==14) ma2=7;\n if(ma2==9 || ma2==6 || ma2==12) ma2=3;\n if(ma2==10) ma2=5;\n if(ma2==2 || ma2==4 || ma2==8) ma2=1;\n \n int x,y;\n FOR(l,5){\n if(k[l]==0) continue;\n if(num-l<0) continue;\n if(ma2==0) x=0,y=0;\n else if(ma2==1) x=3,y=0;\n else if(ma2==5) x=6,y=0;\n else if(ma2==3) x=6,y=1;\n else if(ma2==7) x=9,y=2;\n else if(ma2==15) x=12,y=4;\n FOR(i,y+1) FOR(j,x-i*2+1) ret += dodp(level-1,num-l-(i+j),ma2) * ((k[l]* C[y][i] * C[x-i*2][j])%mo);\n }\n }\n else {\n FOR(l,5) ret += (num==l) * k[l];\n }\n }\n \n return dpdp[level][num][mask]=(ret%=mo);\n}\n\nvoid solve() {\n int f,i,j,k,l, x,y;\n \n cin>>N>>K;\n FOR(x,CN) C[x][0]=C[x][x]=1;\n for(i=1;i1) freopen(argv[1], \"r\", stdin);\n solve();\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dd76b6ef2302c6a93448bfeeda5f35da", "src_uid": "fa649fed687d72b1431ac82bc7288116", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "/*\n * temp.cpp\n *\n * Created on: 2012-7-18\n * Author: BSBandme\n */\n//#pragma comment(linker, \"/STACK:1024000000,1024000000\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define mpr make_pair\ntypedef unsigned long long ull;\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pdd;\ntypedef vector vi;\ntypedef vector vll;\ntypedef vector vd;\ntypedef vector vs;\ntypedef map mpsi;\ntypedef map mpdi;\ntypedef map mpii;\n\nconst double pi = acos(0.0) * 2.0;\nconst double eps = 1e-12;\nconst int step[8][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};\n\ntemplate inline T abs1(T a) {return a < 0 ? -a : a;}\ntemplate inline T max1(T a, T b, T c = -1234567, T d = -1234567) {\n\tT ans = a > b ? a : b;\n\tif(c != -1234567) ans = max1(ans, c);\n\tif(d != -1234567) ans = max1(ans, d);\n\treturn ans;\n}\ntemplate inline T min1(T a, T b, T c = -1234567, T d = -1234567) {\n\tT ans = a < b ? a : b;\n\tif(c != -1234567) ans = min(ans, c);\n\tif(d != -1234567) ans = min(ans, d);\n\treturn ans;\n}\ntemplate inline T gcd1(T a, T b) {\n\tif(a < b) swap(a, b);\n\tif(a % b == 0) return b;\n\treturn gcd1(b, a % b);\n}\ntemplate inline T lb(T num) {return num & (-num); }\ninline int jud(double a, double b){\n\tif(abs(a) < eps && abs(b) < eps) return 0;\n\telse if(abs1(a - b) / abs1(a) < eps) return 0;\n\tif(a < b) return -1;\n\treturn 1;\n}\ntemplate \ninline int jud(t a, t b){\n\tif(a < b) return -1;\n\tif(a == b) return 0;\n\treturn 1;\n}\ntemplate \ninline int find(t1 val, it a, int na, bool f_small = 1, bool f_lb = 1){\n\tint be = 0, en = na - 1;\n\tif(*a <= *(a + na - 1)){\n\t\tif(f_lb == 0) while(be < en){\n\t\t\tint mid = (be + en + 1) / 2;\n\t\t\tif(jud(*(a + mid), val) != 1) be = mid;\n\t\t\telse en = mid - 1;\n\t\t}else while(be < en){\n\t\t\tint mid = (be + en) / 2;\n\t\t\tif(jud(*(a + mid), val) != -1) en = mid;\n\t\t\telse be = mid + 1;\n\t\t}\n\t\tif(f_small && jud(*(a + be), val) == 1) be--;\n\t\tif(!f_small && jud(*(a + be), val) == -1) be++;\n\t} else {\n\t\tif(f_lb) while(be < en){\n\t\t\tint mid = (be + en + 1) / 2;\n\t\t\tif(jud(*(a + mid), val) != -1) be = mid;\n\t\t\telse en = mid - 1;\n\t\t}else while(be < en){\n\t\t\tint mid = (be + en) / 2;\n\t\t\tif(jud(*(a + mid), val) != 1) en = mid;\n\t\t\telse be = mid + 1;\n\t\t}\n\t\tif(!f_small && jud(*(a + be), val) == -1) be--;\n\t\tif(f_small && jud(*(a + be), val) == 1) be++;\n\t}\n\treturn be;\n}\ninline int bitnum(ull nValue){\n nValue = ((0xaaaaaaaaaaaaaaaaull & nValue)>>1) + (0x5555555555555555ull & nValue);\n nValue = ((0xccccccccccccccccull & nValue)>>2) + (0x3333333333333333ull & nValue);\n nValue = ((0xf0f0f0f0f0f0f0f0ull & nValue)>>4) + (0x0f0f0f0f0f0f0f0full & nValue);\n nValue = ((0xff00ff00ff00ff00ull & nValue)>>8) + (0x00ff00ff00ff00ffull & nValue);\n nValue = ((0xffff0000ffff0000ull & nValue)>>16) + (0x0000ffff0000ffffull & nValue);\n nValue = ((0xffffffff00000000ull & nValue)>>32) + (0x00000000ffffffffull & nValue);\n\treturn nValue;\n}\nlong long pow(long long n, long long m, long long mod = 0){\n\tlong long ans = 1;\n\tlong long k = n;\n\twhile(m){\n\t\tif(m & 1) {\n\t\t\tans *= k;\n\t\t\tif(mod) ans %= mod;\n\t\t}\n\t\tk *= k;\n\t\tif(mod) k %= mod;\n\t\tm >>= 1;\n\t}\n\treturn ans;\n}\n\n\n//.........................mi.......feng.......xian.......wai.......jin.......zhi.......challenge...............................................\n\nconst int maxn = 250;\nconst ll mod = 1000000007;\nint n, col;\nll have[maxn];\nll dp[5][maxn * 12][maxn * 4], cnt1[maxn * 4][maxn];\nll c[3000][3000];\nll stat1[5][maxn * 4][maxn * 4], radd[5][3][maxn * 4][maxn * 4];\n\nint main(){\n//\ttime_t be = clock();\n\tios_base::sync_with_stdio(0);\n\tfor(int i = 0; i < 2500; i++) {\n\t\tc[i][0] = 1;\n\t\tfor(int j = 1; j <= i; j++) {\n\t\t\tc[i][j] = c[i - 1][j - 1] + c[i - 1][j];\n\t\t\tif(c[i][j] > mod) c[i][j] -= mod;\n\t\t}\n\t}\n\n//\tfreopen(\"input.txt\", \"r\", stdin);\n\tscanf(\"%d%d\", &n, &col);\n\thave[0] = 1;\n\tfor(int i = 1; i <= n; i++) have[i] = have[i - 1] + 3;\n\n\tcnt1[0][0] = 1;\n\tcnt1[1][0] = 1; cnt1[1][1] = 3; cnt1[1][2] = 1;\n\tfor(int i = 2; i <= 4 * n; i++) {\n\t\tcnt1[i][0] = 1;\n\t\tfor(int j = 1; j <= col; j++) {\n\t\t\tcnt1[i][j] += cnt1[i - 1][j];\n\t\t\tcnt1[i][j] += cnt1[i - 1][j - 1] * 3 % mod;\n\t\t\tif(j >= 2) cnt1[i][j] += cnt1[i - 1][j - 2];\n\t\t\tcnt1[i][j] %= mod;\n\t\t}\n\t}\n\n\t// most tough part\n\tfor(int i = 0; i < 5; i++) {\n\t\tll all = col - i;\n\t\tif(all < 0) break;\n\t\tfor(int t = 0; t <= n * 12; t++) dp[i][t][0] = c[t][all];\n\t\tfor(int j = 1; j <= n * 4; j++) for(int t = 0; t <= n * 12 - j * 2; t++) {\n\t\t\tdp[i][t][j] = dp[i][t + 2][j - 1] + dp[i][t + 1][j - 1] - dp[i][t][j - 1];\n\t\t\tif(dp[i][t][j] < 0) dp[i][t][j] += mod;\n\t\t\twhile(dp[i][t][j] > mod) dp[i][t][j] -= mod;\n\t\t}\n\t}\n\n\tfor(int i = -1; i <= n; i++) for(int j = -1; j <= n; j++) for(int k = -1; k <= n; k++){\n\t\tint cnt = n * 4; int add = 0;\n\t\tif(i != -1) add++;\n\t\tif(j != -1) add++;\n\t\tif(k != -1) add++;\n\t\tint i11 = max(0, i), j11 = max(0, j), k11 = max(0, k);\n\t\tcnt -= i11 + j11 + k11;\n\t\tpii be = mpr(cnt, n * 4 - (max(i11, j11) + max(k11, j11)) - i11 - k11);\n\t\tstat1[add][be.first][be.second]++;\n\t\tadd++;\n\t\tstat1[add][be.first][be.second]++;\n\t\tradd[add][0][be.first][be.second]++;\n\t\tradd[add][0][be.first - min(i11, k11)][be.second]--;\n\t\tradd[add][1][be.first - min(i11, k11)][be.second]++;\n\t\tradd[add][1][be.first - max(i11, k11)][be.second - abs(i11 - k11)]--;\n\t\tradd[add][2][be.first - max(i11, k11)][be.second - abs(i11 - k11)]++;\n\t\tradd[add][2][be.first - n][be.second - abs(i11 - k11) - 2 * (n - max(i11, k11))]--;\n\t}\n\tfor(int i = 0; i <= 4; i++) for(int k = n * 4; k >= 0; k--) for(int j = n * 4; j >= 0; j--) {\n\t\tfor(int t = 0; t < 3; t++) {\n\t\t\tradd[i][t][j][k] += radd[i][t][j + 1][k + t], stat1[i][j][k] += radd[i][t][j + 1][k + t];\n\t\t\tif(radd[i][t][j][k] > mod) radd[i][t][j][k] -= mod;\n\t\t\tif(stat1[i][j][k] > mod) stat1[i][j][k] -= mod;\n\t\t}\n\t}\n\tfor(int i = 0; i <= n; i++) for(int j = -1; j <= n; j++) for(int k = -1; k <= n; k++) {\n\t\tint cnt = n * 4; ll add = 0;\n\t\tif(i != -1) add++;\n\t\tif(j != -1) add++;\n\t\tif(k != -1) add++;\n\t\tint i11 = max(0, i), j11 = max(0, j), k11 = max(0, k);\n\t\tcnt -= i11 * 2 + j11 + k11;\n\t\tstat1[add][cnt][4 * n - i11 - max(i11, j11) - max(j11, k11) - max(k11, i11)] += 4;\n\t\tif(stat1[add][cnt][4 * n - i11 - max(i11, j11) - max(j11, k11) - max(k11, i11)] > mod)\n\t\t\tstat1[add][cnt][4 * n - i11 - max(i11, j11) - max(j11, k11) - max(k11, i11)] -= mod;\n\t}\n\tif(col >= 2) for(int i = 0; i <= n; i++) for(int j = 0; j <= n; j++) {\n\t\tstat1[2][n * 4 - i * 2 - j * 2][4 * n - i - j - max(i, j) * 2] += 2;\n\t\tstat1[2][n * 4 - i * 2 - j * 2][4 * n - i - j - max(i, j) * 2] %= mod;\n\t}\n\tll ans = 0;\n\n\tfor(int k = n * 4; k >= 0; k--) for(int j = n * 4; j >= 0; j--) for(int t = 0; t < 5; t++) if(stat1[t][k][j] && t <= col){\n\t\tans += dp[t][k * 3 - j * 2][j] * stat1[t][k][j] % mod;\n\t\tif(ans > mod) ans -= mod;\n/*\t\tfor(int i = max(0, col - t - j * 2); i <= col - t; i++){\n\t\t\tif(i > k * 3) break;\n\t\t\tans += c[k * 3 - j * 2][i] * cnt1[j][col - i - t] % mod * stat1[t][k][j] % mod;\n\t\t\tif(ans > mod) ans -= mod;\n\t\t}*/\n\t}\n/*\tfor(int k = n * 4; k >= 0; k--) for(int j = n * 4; j >= 0; j--) for(int t = 0; t < 5; t++) if(stat1[t][k][j] && t <= col){\n\t\tfor(int i = max(0, col - t - j * 2); i <= col - t; i++){\n\t\t\tif(i > k * 3) break;\n\t\t\tdp[t + i][j] += c[k * 3 - j * 2][i] * stat1[t][k][j] % mod;\n\t\t\tif(dp[t + i][j] > mod) dp[t + i][j] -= mod;\n//\t\t\tans += c[k * 3 - j * 2][i] * cnt1[j][col - i - t] % mod * stat1[t][k][j] % mod;\n//\t\t\tif(ans > mod) ans -= mod;\n\t\t}\n\t} */\n\n/*\tfor(int i = 1; i <= col; i++) {\n\t\tint now = i & 1, last = 1 - now;\n\t\tfor(int j = 0; j < n * 4; j++) for(int t = 0; t < n * 4; t++) {\n\t\t\tif(j == 0) dp[now][j][t] = cnt1[t][i];\n\t\t\telse dp[now][j][t] = dp[now][j - 1][t] + dp[last][j - 1][t];\n\t\t\tif(dp[now][j][t] > mod) dp[now][j][t] -= mod;\n\t\t\tif(i >= col - 4 && stat1[col - i][j][t]) {\n\t\t\t\tans += dp[now][j][t] * stat1[col - i][j][t] % mod;\n\t\t\t\tif(ans > mod) ans -= mod;\n\t\t\t}\n\t\t}\n\t}*/\n\tfor(ll i = 1; i <= col; i++) ans = ans * i % mod;\n\tcout << ans << endl;\n/*\ttime_t en = clock();\n\tcout << double ((en - be)) / CLOCKS_PER_SEC << endl; */\n\n\treturn 0;\n}\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0fb5158f7af69d960562bcd9290dbfcf", "src_uid": "fa649fed687d72b1431ac82bc7288116", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "/*\n * temp.cpp\n *\n * Created on: 2012-7-18\n * Author: BSBandme\n */\n//#pragma comment(linker, \"/STACK:1024000000,1024000000\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define mpr make_pair\ntypedef unsigned long long ull;\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pdd;\ntypedef vector vi;\ntypedef vector vll;\ntypedef vector vd;\ntypedef vector vs;\ntypedef map mpsi;\ntypedef map mpdi;\ntypedef map mpii;\n\nconst double pi = acos(0.0) * 2.0;\nconst double eps = 1e-12;\nconst int step[8][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};\n\ntemplate inline T abs1(T a) {return a < 0 ? -a : a;}\ntemplate inline T max1(T a, T b, T c = -1234567, T d = -1234567) {\n\tT ans = a > b ? a : b;\n\tif(c != -1234567) ans = max1(ans, c);\n\tif(d != -1234567) ans = max1(ans, d);\n\treturn ans;\n}\ntemplate inline T min1(T a, T b, T c = -1234567, T d = -1234567) {\n\tT ans = a < b ? a : b;\n\tif(c != -1234567) ans = min(ans, c);\n\tif(d != -1234567) ans = min(ans, d);\n\treturn ans;\n}\ntemplate inline T gcd1(T a, T b) {\n\tif(a < b) swap(a, b);\n\tif(a % b == 0) return b;\n\treturn gcd1(b, a % b);\n}\ntemplate inline T lb(T num) {return num & (-num); }\ninline int jud(double a, double b){\n\tif(abs(a) < eps && abs(b) < eps) return 0;\n\telse if(abs1(a - b) / abs1(a) < eps) return 0;\n\tif(a < b) return -1;\n\treturn 1;\n}\ntemplate \ninline int jud(t a, t b){\n\tif(a < b) return -1;\n\tif(a == b) return 0;\n\treturn 1;\n}\ntemplate \ninline int find(t1 val, it a, int na, bool f_small = 1, bool f_lb = 1){\n\tint be = 0, en = na - 1;\n\tif(*a <= *(a + na - 1)){\n\t\tif(f_lb == 0) while(be < en){\n\t\t\tint mid = (be + en + 1) / 2;\n\t\t\tif(jud(*(a + mid), val) != 1) be = mid;\n\t\t\telse en = mid - 1;\n\t\t}else while(be < en){\n\t\t\tint mid = (be + en) / 2;\n\t\t\tif(jud(*(a + mid), val) != -1) en = mid;\n\t\t\telse be = mid + 1;\n\t\t}\n\t\tif(f_small && jud(*(a + be), val) == 1) be--;\n\t\tif(!f_small && jud(*(a + be), val) == -1) be++;\n\t} else {\n\t\tif(f_lb) while(be < en){\n\t\t\tint mid = (be + en + 1) / 2;\n\t\t\tif(jud(*(a + mid), val) != -1) be = mid;\n\t\t\telse en = mid - 1;\n\t\t}else while(be < en){\n\t\t\tint mid = (be + en) / 2;\n\t\t\tif(jud(*(a + mid), val) != 1) en = mid;\n\t\t\telse be = mid + 1;\n\t\t}\n\t\tif(!f_small && jud(*(a + be), val) == -1) be--;\n\t\tif(f_small && jud(*(a + be), val) == 1) be++;\n\t}\n\treturn be;\n}\ninline int bitnum(ull nValue){\n nValue = ((0xaaaaaaaaaaaaaaaaull & nValue)>>1) + (0x5555555555555555ull & nValue);\n nValue = ((0xccccccccccccccccull & nValue)>>2) + (0x3333333333333333ull & nValue);\n nValue = ((0xf0f0f0f0f0f0f0f0ull & nValue)>>4) + (0x0f0f0f0f0f0f0f0full & nValue);\n nValue = ((0xff00ff00ff00ff00ull & nValue)>>8) + (0x00ff00ff00ff00ffull & nValue);\n nValue = ((0xffff0000ffff0000ull & nValue)>>16) + (0x0000ffff0000ffffull & nValue);\n nValue = ((0xffffffff00000000ull & nValue)>>32) + (0x00000000ffffffffull & nValue);\n\treturn nValue;\n}\nlong long pow(long long n, long long m, long long mod = 0){\n\tlong long ans = 1;\n\tlong long k = n;\n\twhile(m){\n\t\tif(m & 1) {\n\t\t\tans *= k;\n\t\t\tif(mod) ans %= mod;\n\t\t}\n\t\tk *= k;\n\t\tif(mod) k %= mod;\n\t\tm >>= 1;\n\t}\n\treturn ans;\n}\n\n\n//.........................mi.......feng.......xian.......wai.......jin.......zhi.......challenge...............................................\n\nconst int maxn = 250;\nconst ll mod = 1000000007;\nint n, col;\nll have[maxn];\nll dp[5][maxn * 12][maxn * 4];\nll c[3000][3000];\nll stat1[5][maxn * 4][maxn * 4];\nint radd[5][3][maxn * 4][maxn * 4];\n\nint main(){\n//\ttime_t be = clock();\n\tios_base::sync_with_stdio(0);\n\tfor(int i = 0; i < 2500; i++) {\n\t\tc[i][0] = 1;\n\t\tfor(int j = 1; j <= i; j++) {\n\t\t\tc[i][j] = c[i - 1][j - 1] + c[i - 1][j];\n\t\t\tif(c[i][j] > mod) c[i][j] -= mod;\n\t\t}\n\t}\n\n//\tfreopen(\"input.txt\", \"r\", stdin);\n\tscanf(\"%d%d\", &n, &col);\n\thave[0] = 1;\n\tfor(int i = 1; i <= n; i++) have[i] = have[i - 1] + 3;\n\n/*\tcnt1[0][0] = 1;\n\tcnt1[1][0] = 1; cnt1[1][1] = 3; cnt1[1][2] = 1;\n\tfor(int i = 2; i <= 4 * n; i++) {\n\t\tcnt1[i][0] = 1;\n\t\tfor(int j = 1; j <= col; j++) {\n\t\t\tcnt1[i][j] += cnt1[i - 1][j];\n\t\t\tcnt1[i][j] += cnt1[i - 1][j - 1] * 3 % mod;\n\t\t\tif(j >= 2) cnt1[i][j] += cnt1[i - 1][j - 2];\n\t\t\tcnt1[i][j] %= mod;\n\t\t}\n\t} */\n\n\t// most tough part\n\tfor(int i = 0; i < 5; i++) {\n\t\tll all = col - i;\n\t\tif(all < 0) break;\n\t\tfor(int t = 0; t <= n * 12; t++) dp[i][t][0] = c[t][all];\n\t\tfor(int j = 1; j <= n * 4; j++) for(int t = 0; t <= n * 12 - j * 2; t++) {\n\t\t\tdp[i][t][j] = dp[i][t + 2][j - 1] + dp[i][t + 1][j - 1] - dp[i][t][j - 1];\n\t\t\tif(dp[i][t][j] < 0) dp[i][t][j] += mod;\n\t\t\twhile(dp[i][t][j] > mod) dp[i][t][j] -= mod;\n\t\t}\n\t}\n\n\tfor(int i = -1; i <= n; i++) for(int j = -1; j <= n; j++) for(int k = -1; k <= n; k++){\n\t\tint cnt = n * 4; int add = 0;\n\t\tif(i != -1) add++;\n\t\tif(j != -1) add++;\n\t\tif(k != -1) add++;\n\t\tint i11 = max(0, i), j11 = max(0, j), k11 = max(0, k);\n\t\tcnt -= i11 + j11 + k11;\n\t\tpii be = mpr(cnt, n * 4 - (max(i11, j11) + max(k11, j11)) - i11 - k11);\n\t\tstat1[add][be.first][be.second]++;\n\t\tadd++;\n\t\tstat1[add][be.first][be.second]++;\n\t\tradd[add][0][be.first][be.second]++;\n\t\tradd[add][0][be.first - min(i11, k11)][be.second]--;\n\t\tradd[add][1][be.first - min(i11, k11)][be.second]++;\n\t\tradd[add][1][be.first - max(i11, k11)][be.second - abs(i11 - k11)]--;\n\t\tradd[add][2][be.first - max(i11, k11)][be.second - abs(i11 - k11)]++;\n\t\tradd[add][2][be.first - n][be.second - abs(i11 - k11) - 2 * (n - max(i11, k11))]--;\n\t}\n\tfor(int i = 0; i <= 4; i++) for(int k = n * 4; k >= 0; k--) for(int j = n * 4; j >= 0; j--) {\n\t\tfor(int t = 0; t < 3; t++) {\n\t\t\tradd[i][t][j][k] += radd[i][t][j + 1][k + t], stat1[i][j][k] += radd[i][t][j + 1][k + t];\n\t\t\tif(radd[i][t][j][k] > mod) radd[i][t][j][k] -= mod;\n\t\t\tif(stat1[i][j][k] > mod) stat1[i][j][k] -= mod;\n\t\t}\n\t}\n\tfor(int i = 0; i <= n; i++) for(int j = -1; j <= n; j++) for(int k = -1; k <= n; k++) {\n\t\tint cnt = n * 4; ll add = 0;\n\t\tif(i != -1) add++;\n\t\tif(j != -1) add++;\n\t\tif(k != -1) add++;\n\t\tint i11 = max(0, i), j11 = max(0, j), k11 = max(0, k);\n\t\tcnt -= i11 * 2 + j11 + k11;\n\t\tstat1[add][cnt][4 * n - i11 - max(i11, j11) - max(j11, k11) - max(k11, i11)] += 4;\n\t\tif(stat1[add][cnt][4 * n - i11 - max(i11, j11) - max(j11, k11) - max(k11, i11)] > mod)\n\t\t\tstat1[add][cnt][4 * n - i11 - max(i11, j11) - max(j11, k11) - max(k11, i11)] -= mod;\n\t}\n\tif(col >= 2) for(int i = 0; i <= n; i++) for(int j = 0; j <= n; j++) {\n\t\tstat1[2][n * 4 - i * 2 - j * 2][4 * n - i - j - max(i, j) * 2] += 2;\n\t\tstat1[2][n * 4 - i * 2 - j * 2][4 * n - i - j - max(i, j) * 2] %= mod;\n\t}\n\tll ans = 0;\n\n\tfor(int k = n * 4; k >= 0; k--) for(int j = n * 4; j >= 0; j--) for(int t = 0; t < 5; t++) if(stat1[t][k][j] && t <= col){\n\t\tans += dp[t][k * 3 - j * 2][j] * stat1[t][k][j] % mod;\n\t\tif(ans > mod) ans -= mod;\n/*\t\tfor(int i = max(0, col - t - j * 2); i <= col - t; i++){\n\t\t\tif(i > k * 3) break;\n\t\t\tans += c[k * 3 - j * 2][i] * cnt1[j][col - i - t] % mod * stat1[t][k][j] % mod;\n\t\t\tif(ans > mod) ans -= mod;\n\t\t}*/\n\t}\n/*\tfor(int k = n * 4; k >= 0; k--) for(int j = n * 4; j >= 0; j--) for(int t = 0; t < 5; t++) if(stat1[t][k][j] && t <= col){\n\t\tfor(int i = max(0, col - t - j * 2); i <= col - t; i++){\n\t\t\tif(i > k * 3) break;\n\t\t\tdp[t + i][j] += c[k * 3 - j * 2][i] * stat1[t][k][j] % mod;\n\t\t\tif(dp[t + i][j] > mod) dp[t + i][j] -= mod;\n//\t\t\tans += c[k * 3 - j * 2][i] * cnt1[j][col - i - t] % mod * stat1[t][k][j] % mod;\n//\t\t\tif(ans > mod) ans -= mod;\n\t\t}\n\t} */\n\n/*\tfor(int i = 1; i <= col; i++) {\n\t\tint now = i & 1, last = 1 - now;\n\t\tfor(int j = 0; j < n * 4; j++) for(int t = 0; t < n * 4; t++) {\n\t\t\tif(j == 0) dp[now][j][t] = cnt1[t][i];\n\t\t\telse dp[now][j][t] = dp[now][j - 1][t] + dp[last][j - 1][t];\n\t\t\tif(dp[now][j][t] > mod) dp[now][j][t] -= mod;\n\t\t\tif(i >= col - 4 && stat1[col - i][j][t]) {\n\t\t\t\tans += dp[now][j][t] * stat1[col - i][j][t] % mod;\n\t\t\t\tif(ans > mod) ans -= mod;\n\t\t\t}\n\t\t}\n\t}*/\n\tfor(ll i = 1; i <= col; i++) ans = ans * i % mod;\n\tcout << ans << endl;\n/*\ttime_t en = clock();\n\tcout << double ((en - be)) / CLOCKS_PER_SEC << endl; */\n\n\treturn 0;\n}\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "78b55cb1da9bf1ab9dc4b0af8d07adbd", "src_uid": "fa649fed687d72b1431ac82bc7288116", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "\n//#define USEPB_DS\n#define USETR1\n#define CPPELEVEN\n#define GPP\n\n/*\n * temp.cpp\n *\n * Created on: 2012-7-18\n * Author: BSBandme\n */\n//#pragma comment(linker, \"/STACK:1024000000,1024000000\")\n\n#include \n\nusing namespace std;\n\n#ifndef CPPELEVEN\n#ifdef USETR1\n#include \n#include \nusing namespace tr1;\n#endif\n#else\n#include \n#include \n#endif\n\n#ifdef USEPB_DS\n#include \n#include \nusing namespace __gnu_pbds;\n// binomial_heap_tag, rc_binomial_heap_tag, thin_heap_tag, binary_heap_tag\ntypedef __gnu_pbds::priority_queue, pairing_heap_tag> pq_type;\n// splay_tree_tag, ov_tree_tag\ntypedef tree , rb_tree_tag, tree_order_statistics_node_update> tree_type;\n#endif\n\n#define mpr make_pair\ntypedef unsigned int ui;\ntypedef unsigned long long ull;\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pll;\ntypedef pair pdd;\ntypedef vector vi;\ntypedef vector vll;\ntypedef vector vd;\ntypedef vector vs;\ntypedef map mpsi;\ntypedef map mpdi;\ntypedef map mpii;\n\nconst double pi = acos(0.0) * 2.0;\nconst long double eps = 1e-10;\nconst int step[8][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}, {-1, 1}, {1, 1}, {1, -1}, {-1, -1}};\n\ntemplate inline T abs1(T a) {return a < 0 ? -a : a;}\n\n#ifndef CPPELEVEN\ntemplate inline T max1(T a, T b) { return b < a ? a : b; }\ntemplate inline T max1(T a, T b, T c) { return max1(max1(a, b), c); }\ntemplate inline T max1(T a, T b, T c, T d) { return max1(max1(a, b, c), d); }\ntemplate inline T max1(T a, T b, T c, T d, T e) { return max1(max1(a, b, c, d), e); }\ntemplate inline T min1(T a, T b) { return a < b ? a : b; }\ntemplate inline T min1(T a, T b, T c) { return min1(min1(a, b), c); }\ntemplate inline T min1(T a, T b, T c, T d) { return min1(min1(a, b, c), d); }\ntemplate inline T min1(T a, T b, T c, T d, T e) { return min1(min1(a, b, c, d), e); }\n#else\ntemplate \nt min1(t a, t1 b) { return a < b ? a : b; }\ntemplate \nt min1(t a, arg... arr) { return min1(a, min1(arr...)); }\ntemplate \nt max1(t a, t1 b) { return a > b ? a : b; }\ntemplate \nt max1(t a, arg... arr) { return max1(a, max1(arr...)); }\n#endif\n\ninline int jud(double a, double b){\n if(abs(a) < eps && abs(b) < eps) return 0;\n else if(abs1(a - b) / max(abs1(a), abs1(b)) < eps) return 0;\n if(a < b) return -1;\n return 1;\n}\ntemplate inline int jud(t a, t b){\n if(a < b) return -1;\n if(a == b) return 0;\n return 1;\n}\n\n// f_lb == 1\u4ee3\u8868\u8fd4\u56de\u76f8\u540c\u7684\u4e00\u4e32\u7684\u5de6\u8fb9\u754c\uff0cf_small == 1\u4ee3\u8868\u8fd4\u56de\u5982\u679c\u6ca1\u6709\u5bfb\u627e\u7684\u503c\u8fd4\u56de\u5c0f\u7684\u6570\ntemplate \ninline int find(t1 val, it a, int na, bool f_small = 1, bool f_lb = 1){\n if(na == 0) return 0;\n int be = 0, en = na - 1;\n if(*a <= *(a + na - 1)){\n if(f_lb == 0) while(be < en){\n int mid = (be + en + 1) / 2;\n if(jud(*(a + mid), val) != 1) be = mid;\n else en = mid - 1;\n }else while(be < en){\n int mid = (be + en) / 2;\n if(jud(*(a + mid), val) != -1) en = mid;\n else be = mid + 1;\n }\n if(f_small && jud(*(a + be), val) == 1) be--;\n if(!f_small && jud(*(a + be), val) == -1) be++;\n } else {\n if(f_lb) while(be < en){\n int mid = (be + en + 1) / 2;\n if(jud(*(a + mid), val) != -1) be = mid;\n else en = mid - 1;\n }else while(be < en){\n int mid = (be + en) / 2;\n if(jud(*(a + mid), val) != 1) en = mid;\n else be = mid + 1;\n }\n if(!f_small && jud(*(a + be), val) == -1) be--;\n if(f_small && jud(*(a + be), val) == 1) be++;\n }\n return be;\n}\n\ntemplate inline T lowb(T num) {return num & (-num); }\n#ifdef GPP\ninline int bitnum(ui nValue) { return __builtin_popcount(nValue); }\ninline int bitnum(int nValue) { return __builtin_popcount(nValue); }\ninline int bitnum(ull nValue) { return __builtin_popcount(nValue) + __builtin_popcount(nValue >> 32); }\ninline int bitnum(ll nValue) { return __builtin_popcount(nValue) + __builtin_popcount(nValue >> 32); }\ninline int bitmaxl(ui a) { if(a == 0) return 0; return 32 - __builtin_clz(a); }\ninline int bitmaxl(int a) { if(a == 0) return 0; return 32 - __builtin_clz(a); }\ninline int bitmaxl(ull a) { int temp = a >> 32; if(temp) return 32 - __builtin_clz(temp) + 32; return bitmaxl(int(a)); }\ninline int bitmaxl(ll a) { int temp = a >> 32; if(temp) return 32 - __builtin_clz(temp) + 32; return bitmaxl(int(a)); }\n#else\n#endif\n\nlong long pow(long long n, long long m, long long mod = 0){\n if(m < 0) return 0;\n long long ans = 1;\n long long k = n;\n while(m){\n if(m & 1) {\n ans *= k;\n if(mod) ans %= mod;\n }\n k *= k;\n if(mod) k %= mod;\n m >>= 1;\n }\n return ans;\n}\n\n#define MOD 1000000007\ntemplate \ninline void add(t1 &a, t2 b, int mod = -1) {\n if(mod == -1) mod = MOD;\n a += b;\n while(a >= mod) a -= mod;\n while(a < 0) a += mod;\n}\ntemplate \nvoid output1(t arr) {\n for(int i = 0; i < (int)arr.size(); i++)\n cerr << arr[i] << ' ';\n cerr << endl;\n}\ntemplate \nvoid output2(t arr) {\n for(int i = 0; i < (int)arr.size(); i++)\n output1(arr[i]);\n}\n\n//....................\u5bc6..........\u5c01..........\u7ebf..........\u4e0b..........\u7981..........\u6b62..........hack...............................................\n\nconst int maxn = 33;\n\nint ncase;\nvector arr;\nchar str[30];\nint n;\nint x, y;\n\n// 0 for whole clock, 1 for whole counter,\n// 2 for left clock, 3 for left counter clock\n// 4 for right clock, 5 for right counter clock\nstring rot[10];\n\nvoid Apply(const string& str);\nvoid Apply(char ch) {\n if (ch == 'u') {\n if (x == 1 && y % n == 0) {\n swap(arr[x][y], arr[x - 1][y]);\n x--;\n } else {\n cerr << \"Invalid co \" << x << ' ' << y << \" for op u\" << endl;\n assert(0);\n }\n } else if (ch == 'd') {\n if (x == 0 && y % n == 0) {\n swap(arr[x][y], arr[x + 1][y]);\n x++;\n } else {\n cerr << \"Invalid co \" << x << ' ' << y << \" for op d\" << endl;\n assert(0);\n }\n } else if (ch == 'l') {\n if (y > 0) {\n swap(arr[x][y], arr[x][y - 1]);\n y--;\n } else {\n cerr << \"Invalid co \" << x << ' ' << y << \" for op l\" << endl;\n assert(0);\n }\n } else if (ch == 'l') {\n if (y > 0) {\n swap(arr[x][y], arr[x][y - 1]);\n y--;\n } else {\n cerr << \"Invalid co \" << x << ' ' << y << \" for op l\" << endl;\n assert(0);\n }\n } else if (ch == 'r') {\n if (y < 2 * n) {\n swap(arr[x][y], arr[x][y + 1]);\n y++;\n } else {\n cerr << \"Invalid co \" << x << ' ' << y << \" for op r\" << endl;\n assert(0);\n }\n } else Apply(rot[ch - 'A']);\n}\n\nvoid Apply(const string& str) {\n for (auto ch : str) {\n Apply(ch);\n }\n}\n\nint main() {\n //............................\u4e0d\u8981\u518d\u5fd8\u4e86\u68c0\u67e5maxn\u5927\u5c0f\u4e86\uff01\uff01\uff01\uff01BSBandme\u4f60\u4e2aSB\uff01\uff01\uff01\uff01........................................\n ios_base::sync_with_stdio(0);\n #ifdef DEBUG //......................................................................................................\n freopen(\"input.txt\", \"r\", stdin);\n #endif //...........................................................................................................\n\n scanf(\"%d\", &ncase);\n for (int i1 = 0; i1 < ncase; i1++) {\n scanf(\"%d\", &n);\n\n // prepare 0\n rot[0] = \"\";\n for (int i = 0; i < n; i++) {\n rot[0] += \"r\";\n }\n rot[0] += \"u\";\n for (int i = 0; i < 2 * n; i++) {\n rot[0] += \"l\";\n }\n rot[0] += \"d\";\n for (int i = 0; i < n; i++) {\n rot[0] += \"r\";\n }\n\n // prepare 1\n rot[1] = \"\";\n for (int i = 0; i < n; i++) {\n rot[1] += \"l\";\n }\n rot[1] += \"u\";\n for (int i = 0; i < 2 * n; i++) {\n rot[1] += \"r\";\n }\n rot[1] += \"d\";\n for (int i = 0; i < n; i++) {\n rot[1] += \"l\";\n }\n\n // prepare 2\n rot[2] = \"u\";\n for (int i = 0; i < n; i++) {\n rot[2] += \"l\";\n }\n rot[2] += \"d\";\n for (int i = 0; i < n; i++) {\n rot[2] += \"r\";\n }\n\n // prepare 3\n rot[3] = \"\";\n for (int i = 0; i < n; i++) {\n rot[3] += \"l\";\n }\n rot[3] += \"u\";\n for (int i = 0; i < n; i++) {\n rot[3] += \"r\";\n }\n rot[3] += \"d\";\n\n // prepare 5\n rot[5] = \"u\";\n for (int i = 0; i < n; i++) {\n rot[5] += \"r\";\n }\n rot[5] += \"d\";\n for (int i = 0; i < n; i++) {\n rot[5] += \"l\";\n }\n\n // prepare 4\n rot[4] = \"\";\n for (int i = 0; i < n; i++) {\n rot[4] += \"r\";\n }\n rot[4] += \"u\";\n for (int i = 0; i < n; i++) {\n rot[4] += \"l\";\n }\n rot[4] += \"d\";\n\n rot[6] = \"CFFDAED\";\n\n arr = {{}, {}};\n arr[0].resize(n * 2 + 1);\n arr[1].resize(n * 2 + 1);\n for (int i = 0; i < 2; i++) {\n for (int j = 0; j < 2 * n + 1; j++) {\n scanf(\"%s\", str);\n if (str[0] == 'E') {\n arr[i][j] = -1;\n x = i, y = j;\n } else {\n sscanf(str, \"%d\", &arr[i][j]);\n if (arr[i][j] > n * 2 + 1) {\n arr[i][j] = n * 2 + 2 + n * 4 + 1 - arr[i][j];\n }\n }\n }\n }\n\n string ans = \"\";\n while (y < n) {\n ans += \"r\";\n Apply('r');\n }\n while (y > n) {\n ans += \"l\";\n Apply('l');\n }\n if (x == 0) {\n ans += \"d\";\n Apply('d');\n }\n\n#ifdef DEBUG\n output2(arr);\n cerr << endl;\n for (int i = 0; i < 7; i++) {\n vector tarr = arr;\n Apply(rot[i]);\n output2(arr);\n cerr << endl;\n arr = tarr;\n }\n#endif\n\n for (int i = 2; i < n * 4; i++) {\n while (true) {\n while (arr[0][n + 1] != i) {\n Apply(rot[1]);\n ans += \"B\";\n }\n if (arr[0][n] == i - 1) break;\n else {\n if (arr[0][n + 2] > i) {\n Apply(rot[6]);\n ans += 'G';\n } else {\n Apply(rot[0]);\n ans += 'A';\n Apply(rot[6]);\n ans += 'G';\n }\n }\n }\n#ifdef DEBUG\n output2(arr);\n cerr << endl;\n#endif\n }\n\n while (arr[0][0] != 1) {\n Apply(rot[1]);\n ans += \"B\";\n }\n for (int i = 0; i < n; i++) {\n Apply('r');\n ans += \"r\";\n }\n#ifdef DEBUG\n output2(arr);\n cerr << endl;\n#endif\n if (arr[1][0] != n * 4 + 1) {\n cout << \"SURGERY FAILED\" << endl;\n } else {\n cout << \"SURGERY COMPLETE\" << endl;\n cout << ans << endl;\n for (int i = 0; i < 7; i++) {\n cout << char('A' + i) << ' ' << rot[i] << endl;\n }\n cout << \"DONE\" << endl;\n }\n\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "370f600f84aa4a3f6a4fb3c139d80b94", "src_uid": "697c4af98ea881892365bed856b49988", "difficulty": 3400.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nconst int N=35,L=10005;\nint T,k,i,j,n,m,xe,ye;\nint a[2][N],b[N*2],bb[N*2];\nchar cc[5],ans[L],*ass,out[26][L],*pp[26];\ninline void getseq(){\n\tint xb=0;\n\tfor(j=0;j=0;--j)if(a[1][j])b[xb++]=a[1][j];\n}\ninline void push(char c1,char c2){*pp[c1-'A']++=c2;}\ninline void opt(char c,bool tp=1){\n\tif(tp)*ass++=c;\n\tif(c=='r'){swap(a[xe][ye],a[xe][ye+1]);++ye;}\n\tif(c=='l'){swap(a[xe][ye],a[xe][ye-1]);--ye;}\n\tif(c=='d'){swap(a[xe][ye],a[xe+1][ye]);++xe;}\n\tif(c=='u'){swap(a[xe][ye],a[xe-1][ye]);--xe;}\n\tif(c<'a')for(char*p=out[c-'A'];p!=pp[c-'A'];++p)opt(*p,0);\n}\ninline void get_rot2(int x,char c){\n\tint i;x-=k;if(x<0)x+=m;for(i=0;i=8)opt(x/8-1+'A');if(x%8)opt(x%8-1+'I');\n\topt('U');\n\tx=m-x;if(x>=8)opt(x/8-1+'A');if(x%8)opt(x%8-1+'I');\n}\nint calcI(int*b){int ass=0;for(i=0;ib[j];return ass;}\nint main(){\n\tfor(scanf(\"%d\",&T);T--;){\n\t\tscanf(\"%d\",&k);n=k*2+1;m=n*2-1;ass=ans;\n\t\tfor(i=0;i<2;++i)for(j=0;ji+1;rot3(j-2),--j);if(j>i)rot3(j-1);\n\t\t}\n\t\tputs(\"SURGERY COMPLETE\");\n\t\tputs(ans);\n\t\tfor(i=0;i<26;++i)if(pp[i]!=out[i])printf(\"%c %s\\n\",i+'A',out[i]);\n\t\tputs(\"DONE\");\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8927f631de3c4d4a585ec9d638b42e8c", "src_uid": "697c4af98ea881892365bed856b49988", "difficulty": 3400.0} {"lang": "GNU C++17", "source_code": "# include \n//https://codeforces.com/problemset/problem/1280/F\nusing namespace std;\n\nbool evenPairity(vector p, int k) {\n bool even = true;\n for (auto i = 0u; i < p.size(); i++) {\n for (int j = i - 1; j >= 0; j--) {\n if (p[j] > p[j + 1]) {\n swap(p[j], p[j + 1]);\n // tricky case: We don't actually care about the pairity of permutation\n // with the 'E', just the numbers of the permutation\n if (p[j] != 2 * k + 1 && p[j + 1] != 2 * k + 1) {\n even = !even;\n }\n }\n }\n }\n return even;\n}\n\nvoid printRotation(int dist) {\n for (int i = 0; i < dist; i++) {\n printf(\"l\");\n }\n printf(\"u\");\n for (int i = 0; i < dist; i++) {\n printf(\"r\");\n }\n printf(\"d\");\n\n}\n\nvoid simR(vector &a) {\n swap(a[0], a[1]);\n swap(a[1], a[2]);\n}\n\nvoid simB(vector &a, int k) {\n int tmp = a[2 * k + 2];\n for (int i = 2 * k + 2; i != 2 * k; i = (i + 1) % (4 * k + 2)) {\n a[i] = a[(i + 1) % (4 * k + 2)];\n }\n a[2 * k] = tmp;\n}\n\nvoid simD(vector &a, int k) {\n int tmp = a[2 * k];\n for (int i = 2 * k; i != 2 * k + 2; i = (4 * k + 1 + i) % (4 * k + 2)) {\n a[i] = a[(4 * k + 1 + i) % (4 * k + 2)];\n }\n a[2 * k + 2] = tmp;\n}\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(nullptr);\n int cases, k;\n cin >> cases;\n for (int t = 0; t < cases; t++) {\n cin >> k;\n vector perm = vector(4 * k + 2, 0);\n int Eloc = -1;\n for (int i = 0; i < 2; i++) {\n for (int j = 0; j < 2 * k + 1; j++) {\n int ind;\n if (i == 0) {\n ind = j;\n } else {\n ind = (4 * k + 1) - j;\n }\n string nxt;\n cin >> nxt;\n if (nxt == \"E\") {\n perm[ind] = 2 * k + 1;\n Eloc = ind;\n } else {\n perm[ind] = stoi(nxt) - 1;\n if (perm[ind] >= 2 * k + 1) {\n perm[ind] = 6 * k + 2 - perm[ind];\n }\n }\n }\n }\n if (!evenPairity(perm,k)) {\n printf(\"SURGERY FAILED\\n\");\n continue;\n }\n printf(\"SURGERY COMPLETE\\n\");\n // put E at bottom right\n if (Eloc > 2 * k + 1) {\n while (perm[2 * k + 1] != 2 * k + 1) {\n swap(perm[Eloc], perm[Eloc-1]);\n Eloc--;\n printf(\"r\");\n }\n }else if(Eloc <= 2*k){\n while (perm[2 * k] != 2 * k + 1) {\n swap(perm[Eloc], perm[Eloc+1]);\n Eloc++;\n printf(\"r\");\n }\n swap(perm[2*k+1], perm[2*k]);\n printf(\"d\");\n }\n while (perm[4 * k + 1] != 4 * k + 1) {\n printf(\"D\");\n simD(perm, k);\n }\n for (int i = 4 * k; i >= 2; i--) {\n if (i == perm[i]) {\n continue;\n }\n assert(i + 1 == perm[i + 1]);\n int succLoc = i + 1;\n while (succLoc != 3) {\n if (perm[0] == i) {\n printf(\"R\");\n simR(perm);\n }\n printf(\"B\");\n simB(perm, k);\n succLoc = (succLoc + 4*k + 1) % (4 * k + 2);\n if(succLoc==2*k+1){\n succLoc--;\n }\n }\n while (perm[2] != i) {\n printf(\"R\");\n simR(perm);\n }\n while (perm[4 * k + 1] != 4 * k + 1) {\n printf(\"D\");\n simD(perm, k);\n }\n assert(i == perm[i]);\n }\n printf(\"\\nA \");\n printRotation(k);\n printf(\"\\nB \");\n printRotation(2 * k);\n printf(\"\\nC \");\n for (int i = 0; i < 2 * k; i++) {\n printf(\"A\");\n }\n printf(\"\\nD \");\n for (int i = 0; i < 4 * k; i++) {\n printf(\"B\");\n }\n printf(\"\\nR \");\n for (int i = 0; i < k + 2; i++) {\n printf(\"B\");\n }\n printf(\"CBCDAA\");\n for (int i = 0; i < k + 2; i++) {\n printf(\"D\");\n }\n printf(\"\\nDONE\\n\");\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d2e14a966918eb5578890d152119f1bf", "src_uid": "697c4af98ea881892365bed856b49988", "difficulty": 3400.0} {"lang": "GNU C++17", "source_code": "// This problem is not as hard (to me) as some older F problems...\n// Another [permutation-puzzle] problem: https://codeforces.com/problemset/problem/1044/E\n// Implementation time: 47 minutes...\n#ifndef LOCAL\n#define NDEBUG\n#endif\n#include\n#include\n#include\n#include\n#include\n\nint main(){\n\tstd::ios::sync_with_stdio(0);std::cin.tie(0);\n\tint ntest;std::cin>>ntest;\n\twhile(ntest--){\n\t\tstd::string out;\n\t\tint k;std::cin>>k;\n\t\tstd::array,2> v;\n\n\t\tint emptycol;\n\t\tassert((emptycol=-1));\n\n\t\tfor(auto& row:v){\n\t\t\trow.resize(k*2+1);\n\t\t\tfor(unsigned col=0;col>x){\n\t\t\t\t\t/* renumber cells such that the correct arrangement is\n\n+------------------------------------------------------------------------------+\n| 3*k+2 3*k+3 3*k+4 ... 4*k 0 1 2 3 ... k-1 k k+1 |\n| +--------------------------+ +----------------------------+ |\n| 3*k+1 3*k 3*k-1 ... 2*k+3 2*k+2 2*k+1 2*k 2*k-1 ... k+3 k+2 [E] |\n+------------------------------------------------------------------------------+\n\t\t\t\t\t*/\n\t\t\t\t if(x<=2*k+1){\n\t\t\t\t\t x=3*k+1+x;\n\t\t\t\t\t if(x>4*k) x-=4*k+1;\n\t\t\t\t }else{\n\t\t\t\t\t x=(3*k+1)-(x-(2*k+2));\n\t\t\t\t }\n\t\t\t\t}else{\n\t\t\t\t\tstd::cin.clear();\n\t\t\t\t\tchar c;std::cin>>c;\n\t\t\t\t\tassert(c=='E');\n\t\t\t\t\tx=-1;\n\t\t\t\t\temptycol=col;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tauto& row_contain_empty=v[1][emptycol]<=0 ? v[1] : v[0];\n\t\twhile((int)emptycol<2*k){\n\t\t\tout+='r';\n\t\t\tstd::swap(row_contain_empty[emptycol],row_contain_empty[emptycol+1]);\n\t\t\t++emptycol;\n\t\t}\n\n\t\tif(v[0].back()<=0){\n\t\t\tout+='d';\n\t\t\tstd::swap(v[0].back(),v[1].back());\n\t\t}\n\t\tassert(v[1].back()<=0);\n\n\t\tstd::vector newp;newp.reserve(4*k+1);\n\t\tnewp.insert(end(newp),begin(v[0])+k-1,end(v[0]));\n\t\tnewp.insert(end(newp),++v[1].rbegin(),v[1].rend());\n\t\tnewp.insert(end(newp),begin(v[0]),begin(v[0])+k-1);\n\t\tassert(newp.size()==unsigned(4*k+1));\n\n\t\tv[0].clear(); v[1].clear();\n\n\t\tint start=0;\n\t\t// newp[x-start] = new index of block at (home of block with new index x)\n\t\t// wraparound\n\n\t\tint i=4*k; // such that block i..4*k are cyclically continuous\n\t\t{\n\t\t\tauto posi=int(std::find(begin(newp),end(newp),i)-begin(newp));\n\t\t\tstd::rotate(begin(newp),begin(newp)+posi+1,end(newp));\n\t\t\tstart=(int)newp.size()-(posi+1);\n\t\t}\n\t\tassert(newp.back()==i);\n\n\t\tauto const macroA=[&](){\n\t\t\t// macro A: move block at (new) position 0,1,2... to 4*k,0,1,...\n\t\t\tout+='A';\n\t\t\t++start;\n\t\t\tif(start==(int)newp.size()) start=0;\n\t\t};\n\n\t\tauto const macroB=[&](){\n\t\t\t// macro B: move block at (new) position 0,1,2 to 1,2,0\n\t\t\tout+='B';\n\t\t\tstd::swap(newp[start],newp[(start+1)%newp.size()]);\n\t\t\tstd::swap(newp[start],newp[(start+2)%newp.size()]);\n\t\t};\n\n\t\twhile(i>2){\n\t\t\tassert(newp.back()==(int)newp.size()-1);\n\t\t\tassert(newp[i]==i);\n\n\t\t\tint const j=i-1;\n\t\t\tauto posj=int(std::find(begin(newp),end(newp),j)-begin(newp));\n\t\t\tif(posj!=j){\n\t\t\t\twhile(start!=std::max(0,posj-1))macroA();\n\t\t\t\tif(posj==0){ macroB();++posj; }\n\n\t\t\t\twhile(posj\nusing namespace std;\nusing ll = long long;\ntemplate < int n, class... T >\ntypename std::enable_if< (n >= sizeof...(T)) >::type __output_tuple(\n std::ostream &, std::tuple< T... > const &) {}\ntemplate < int n, class... T >\ntypename std::enable_if< (n < sizeof...(T)) >::type __output_tuple(\n std::ostream &os, std::tuple< T... > const &t) {\n os << (n == 0 ? \"\" : \", \") << std::get< n >(t);\n __output_tuple< n + 1 >(os, t);\n}\ntemplate < class... T >\nstd::ostream &operator<<(std::ostream &os, std::tuple< T... > const &t) {\n os << \"(\";\n __output_tuple< 0 >(os, t);\n os << \")\";\n return os;\n}\ntemplate < class T, class U >\nstd::ostream &operator<<(std::ostream &os, std::pair< T, U > const &p) {\n os << \"(\" << p.first << \", \" << p.second << \")\";\n return os;\n}\ntemplate < class T >\nstd::ostream &operator<<(std::ostream &os, const std::stack< T > &a) {\n os << \"{\";\n for(auto tmp = a; tmp.size(); tmp.pop())\n os << (a.size() == tmp.size() ? \"\" : \", \") << tmp.top();\n os << \"}\";\n return os;\n}\ntemplate < class T, class Container, class Compare >\nstd::ostream &operator<<(std::ostream &os,\n std::priority_queue< T, Container, Compare > a) {\n os << \"{ (top) \";\n while(a.size()) os << a.top() << (a.size() == 1 ? \"\" : \", \"), a.pop();\n os << \" }\";\n return os;\n}\ntemplate < class T, class Container >\nstd::ostream &operator<<(std::ostream &os, std::queue< T, Container > a) {\n os << \"{ \";\n while(a.size()) os << a.front() << (a.size() == 1 ? \"\" : \", \"), a.pop();\n os << \" }\";\n return os;\n}\n#ifdef DEBUG\n#if !defined(DEBUG_OUT)\n#endif\n#define dump(...) \\\n [&]() { \\\n auto __debug_tap = std::make_tuple(__VA_ARGS__); \\\n DEBUG_OUT << \"[\" << __LINE__ << \"] \" << #__VA_ARGS__ << \" = \" << __debug_tap \\\n << std::endl; \\\n }()\ntemplate < class T >\ninline void dump2D(T &d, size_t sizey, size_t sizex) {\n for(size_t i = 0; i < sizey; i++) {\n DEBUG_OUT << \"\\t\";\n for(size_t j = 0; j < sizex; j++)\n DEBUG_OUT << d[i][j] << (j + 1 == sizex ? \"\" : \"\\t\");\n DEBUG_OUT << std::endl;\n }\n}\ntemplate < class T >\ninline void dump1D(T &d, size_t sizey) {\n for(size_t i = 0; i < sizey; i++) {\n DEBUG_OUT << d[i] << (i + 1 == sizey ? \"\" : \" \");\n }\n DEBUG_OUT << std::endl;\n}\ntemplate <\nclass T, class = typename std::iterator_traits< decltype(begin(T())) >::value_type,\n class = typename std::enable_if< !std::is_same< T, std::string >::value >::type >\n std::ostream &operator<<(std::ostream &os, const T &a) {\n os << \"{\";\n for(auto ite = begin(a); ite != end(a); ++ite)\n os << (ite == begin(a) ? \"\" : \", \") << *ite;\n os << \"}\";\n return os;\n }\n#else\n#define dump(...) (42)\n#define dump2D(...) (42)\n#define dump1D(...) (42)\ntemplate <\nclass T, class = typename std::iterator_traits< decltype(begin(T())) >::value_type,\n class = typename std::enable_if< !std::is_same< T, std::string >::value >::type >\n std::ostream &operator<<(std::ostream &os, const T &a) {\n for(auto ite = begin(a); ite != end(a); ++ite)\n os << (ite == begin(a) ? \"\" : \" \") << *ite;\n return os;\n }\n#endif\ninline void hash_combine2(std::size_t& seed, size_t a)\n{\n seed ^= a + 0x9e3779b9 + (seed<<6) + (seed>>2);\n}\n\ninline size_t comball(initializer_list l)\n{\n size_t seed = 0;\n for(auto e : l) {\n hash_combine2(seed, e);\n }\n return seed;\n}\n\ntemplate \ninline void hash_combine(std::size_t& seed, const T& v)\n{\n std::hash hasher;\n seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);\n}\n\nusing uint = unsigned;\n\nusing HASH = tuple;\n\nenum TYEPS { INPUT, REFERENCE, OP };\nstruct Data {\n int type = INPUT;\n string name = \"\";\n HASH hsh;\n char op = '-';\n\n Data *refer = 0, *l = 0, *r = 0;\n\n bool operator==(const Data &b) const {\n return hsh == b.hsh;\n }\n};\n\nset ava;\nvector avas;\n\nData* makeInput(string name) {\n Data *d = new Data;\n d->type = INPUT;\n d->name = name;\n ava.erase(name);\n d->hsh = HASH(hash{}(name), hash{}(name + name), hash{}(name[0]));\n return d;\n}\nData* makeOp(Data * l, Data * r, char op) {\n Data *d = new Data;\n d->type = OP;\n d->l = l;\n d->r = r;\n d->op = op;\n\n size_t a, b, c;\n size_t x, y, z;\n tie(a, b, c) = l->hsh;\n tie(x, y, z) = r->hsh;\n size_t seed0 = comball({a, z, hash{}(string(3, op)), y, c});\n size_t seed1 = comball({x, hash{}(string(1, op)), b, c});\n size_t seed2 = comball({a, y, c, hash{}(op), x});\n\n d->hsh = HASH(seed0, seed1, seed2);\n return d;\n}\n\nint n;\n\nint OPN = 4;\nchar ops[] = {'$', '^', '#', '&'};\n\nmap data;\n\nvoid reset(string name) {\n if(!data.count(name)) data[name] = makeInput(name);\n}\n\nmap, Data*> uni;\nint k = 0;\nstringstream ans;\nset used;\n\nvoid dfs(Data*& p, bool root = 0) {\n if(!p) return;\n auto hs = make_tuple(p->type, p->name + p->op, p->hsh);\n if(uni.count(hs)) {\n p = uni[hs];\n return;\n }\n uni[hs] = p;\n if(used.count(p)) return;\n used.insert(p);\n switch(p->type) {\n case INPUT:\n if(root && p->name != \"res\") {\n k++;\n ans << \"res=\" << p->name << \"\\n\";\n }\n break;\n case OP:\n dfs(p->l);\n dfs(p->r);\n\n string name = \"res\";\n if(!root) {\n name = avas.back();\n avas.pop_back();\n }\n k++;\n ans << name << \"=\" << p->l->name << p->op << p->r->name << \"\\n\";\n assert(p->l->name.size());\n assert(p->r->name.size());\n p->name = name;\n break;\n }\n}\n\nint main() {\n std::ios::sync_with_stdio(false), std::cin.tie(0);\n for(int i = 0; i < 1000; i++) {\n ava.insert(\"a\" + to_string(i));\n ava.insert(\"b\" + to_string(i));\n ava.insert(\"c\" + to_string(i));\n }\n cin >> n;\n for(int i = 0; i < n; i++) {\n string s;\n cin >> s;\n int uku = s.find('=');\n assert(uku != -1);\n string LHS = s.substr(0, uku);\n string RHS = s.substr(uku + 1, int(s.size()) - uku - 1);\n int op = -1;\n string a1, a2;\n for(int o = 0; o < OPN; o++) {\n int id = RHS.find(ops[o]);\n if(id >= 0) {\n op = o;\n a1 = RHS.substr(0, id);\n a2 = RHS.substr(id + 1, int(RHS.size()) - id - 1);\n }\n }\n if(op >= 0) {\n reset(a1);\n reset(a2);\n assert(a1.size());\n assert(a2.size());\n data[LHS] = makeOp(data[a1], data[a2], ops[op]);\n } else {\n reset(RHS);\n data[LHS] = data[RHS];\n }\n }\n reset(\"res\");\n assert(ava.size() >= 1000);\n avas = vector(ava.begin(), ava.end());\n dfs(data[\"res\"], 1);\n dump(\"done\");\n ans << flush;\n cout << k << \"\\n\";\n cout << ans.str()\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b90f706ba4651ad4fff23ed4fbf22dcd", "src_uid": "da40321d92baaef42c2840e45599294c", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "// https://codeforces.com/contest/1156/submission/53644962 (Dukkha)\n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nunordered_set ss;\n\nstruct V {\n\tstring s;\n\tchar op;\n\tV *u, *v;\n\tint d;\n\tV(string &s) {\n\t\tthis->s = s;\n\t\top = 0;\n\t\tss.insert(s);\n\t\td = 0;\n\t}\n\tV(char op, V *u, V *v) {\n\t\ts = \"\";\n\t\tthis->op = op; this->u = u; this->v = v;\n\t\td = max(u->d, v->d) + 1;\n\t}\n};\n\nstruct X {\n\tsize_t operator() (V *w) const {\n\t\treturn w->op ^ (size_t) w->u ^ (size_t) w->v;\n\t}\n};\n\nstruct Y {\n\tbool operator() (V *w1, V *w2) const {\n\t\treturn w1->op == w2->op && w1->u == w2->u && w1->v == w2->v;\n\t}\n};\n\nvector list;\n\nstatic string getX() {\n\tstring s = \"xxxx\";\n\tdo {\n\t\ts[0] = (char) ('a' + rand() % 26);\n\t\ts[1] = (char) ('a' + rand() % 26);\n\t\ts[2] = (char) ('a' + rand() % 26);\n\t\ts[3] = (char) ('a' + rand() % 26);\n\t} while (ss.find(s) != ss.end());\n\treturn s;\n}\n\nvoid dfs(V *w, string s) {\n\tif (w->s == \"\") {\n\t\tw->s = s;\n\t\tss.insert(w->s);\n\t\tlist.push_back(w);\n\t\tdfs(w->u, getX());\n\t\tdfs(w->v, getX());\n\t}\n}\n\nint main() {\n\tsrand(time(NULL));\n\tint n;\n\tcin >> n;\n\tunordered_map sv;\n\tunordered_set vv;\n\twhile (n--) {\n\t\tstring s;\n\t\tcin >> s;\n\t\tint m = s.length();\n\t\tint p = -1, q = -1;\n\t\tfor (int j = 0; j < m; j++)\n\t\t\tif (s[j] == '=')\n\t\t\t\tp = j;\n\t\t\telse if (s[j] == '$' || s[j] == '^' || s[j] == '#' || s[j] == '&')\n\t\t\t\tq = j;\n\t\tstring lvalue = s.substr(0, p);\n\t\tif (q == -1) {\n\t\t\tstring rvalue = s.substr(p + 1, m - p - 1);\n\t\t\tV *v = sv[rvalue];\n\t\t\tif (v == NULL)\n\t\t\t\tsv[rvalue] = v = new V(rvalue);\n\t\t\tsv[lvalue] = v;\n\t\t} else {\n\t\t\tstring arg1 = s.substr(p + 1, q - p - 1);\n\t\t\tstring arg2 = s.substr(q + 1, m - q - 1);\n\t\t\tchar op = s[q];\n\t\t\tV *u = sv[arg1];\n\t\t\tif (u == NULL)\n\t\t\t\tsv[arg1] = u = new V(arg1);\n\t\t\tV *v = sv[arg2];\n\t\t\tif (v == NULL)\n\t\t\t\tsv[arg2] = v = new V(arg2);\n\t\t\tV *w = new V(op, u, v);\n\t\t\tauto it = vv.find(w);\n\t\t\tif (it == vv.end())\n\t\t\t\tvv.insert(w);\n\t\t\telse\n\t\t\t\tw = *it;\n\t\t\tsv[lvalue] = w;\n\t\t}\n\t}\n\tV *w = sv[\"res\"];\n\tif (w == NULL) {\n\t\tcout << 0 << '\\n';\n\t\treturn 0;\n\t}\n\tif (w->op == 0) {\n\t\tif (w->s == \"res\")\n\t\t\tcout << 0 << '\\n';\n\t\telse {\n\t\t\tcout << 1 << '\\n';\n\t\t\tcout << \"res=\" << w->s << '\\n';\n\t\t}\n\t\treturn 0;\n\t}\n\tdfs(w, \"res\");\n\tcout << list.size() << '\\n';\n\tsort(list.begin(), list.end(), [] (V *u, V *v) { return u->d < v->d; });\n\tfor (V *w : list)\n\t\tcout << w->s << '=' << w->u->s << w->op << w->v->s << '\\n';\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0602cd33a99360af6be58af0a63afc09", "src_uid": "da40321d92baaef42c2840e45599294c", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nusing ll = long long;\ntemplate < int n, class... T >\ntypename std::enable_if< (n >= sizeof...(T)) >::type __output_tuple(\n std::ostream &, std::tuple< T... > const &) {}\ntemplate < int n, class... T >\ntypename std::enable_if< (n < sizeof...(T)) >::type __output_tuple(\n std::ostream &os, std::tuple< T... > const &t) {\n os << (n == 0 ? \"\" : \", \") << std::get< n >(t);\n __output_tuple< n + 1 >(os, t);\n}\ntemplate < class... T >\nstd::ostream &operator<<(std::ostream &os, std::tuple< T... > const &t) {\n os << \"(\";\n __output_tuple< 0 >(os, t);\n os << \")\";\n return os;\n}\ntemplate < class T, class U >\nstd::ostream &operator<<(std::ostream &os, std::pair< T, U > const &p) {\n os << \"(\" << p.first << \", \" << p.second << \")\";\n return os;\n}\ntemplate < class T >\nstd::ostream &operator<<(std::ostream &os, const std::stack< T > &a) {\n os << \"{\";\n for(auto tmp = a; tmp.size(); tmp.pop())\n os << (a.size() == tmp.size() ? \"\" : \", \") << tmp.top();\n os << \"}\";\n return os;\n}\ntemplate < class T, class Container, class Compare >\nstd::ostream &operator<<(std::ostream &os,\n std::priority_queue< T, Container, Compare > a) {\n os << \"{ (top) \";\n while(a.size()) os << a.top() << (a.size() == 1 ? \"\" : \", \"), a.pop();\n os << \" }\";\n return os;\n}\ntemplate < class T, class Container >\nstd::ostream &operator<<(std::ostream &os, std::queue< T, Container > a) {\n os << \"{ \";\n while(a.size()) os << a.front() << (a.size() == 1 ? \"\" : \", \"), a.pop();\n os << \" }\";\n return os;\n}\n#ifdef DEBUG\n#if !defined(DEBUG_OUT)\n#endif\n#define dump(...) \\\n [&]() { \\\n auto __debug_tap = std::make_tuple(__VA_ARGS__); \\\n DEBUG_OUT << \"[\" << __LINE__ << \"] \" << #__VA_ARGS__ << \" = \" << __debug_tap \\\n << std::endl; \\\n }()\ntemplate < class T >\ninline void dump2D(T &d, size_t sizey, size_t sizex) {\n for(size_t i = 0; i < sizey; i++) {\n DEBUG_OUT << \"\\t\";\n for(size_t j = 0; j < sizex; j++)\n DEBUG_OUT << d[i][j] << (j + 1 == sizex ? \"\" : \"\\t\");\n DEBUG_OUT << std::endl;\n }\n}\ntemplate < class T >\ninline void dump1D(T &d, size_t sizey) {\n for(size_t i = 0; i < sizey; i++) {\n DEBUG_OUT << d[i] << (i + 1 == sizey ? \"\" : \" \");\n }\n DEBUG_OUT << std::endl;\n}\ntemplate <\nclass T, class = typename std::iterator_traits< decltype(begin(T())) >::value_type,\n class = typename std::enable_if< !std::is_same< T, std::string >::value >::type >\n std::ostream &operator<<(std::ostream &os, const T &a) {\n os << \"{\";\n for(auto ite = begin(a); ite != end(a); ++ite)\n os << (ite == begin(a) ? \"\" : \", \") << *ite;\n os << \"}\";\n return os;\n }\n#else\n#define dump(...) (42)\n#define dump2D(...) (42)\n#define dump1D(...) (42)\ntemplate <\nclass T, class = typename std::iterator_traits< decltype(begin(T())) >::value_type,\n class = typename std::enable_if< !std::is_same< T, std::string >::value >::type >\n std::ostream &operator<<(std::ostream &os, const T &a) {\n for(auto ite = begin(a); ite != end(a); ++ite)\n os << (ite == begin(a) ? \"\" : \" \") << *ite;\n return os;\n }\n#endif\ninline void hash_combine2(std::size_t& seed, size_t a)\n{\n seed ^= a + 0x9e3779b9 + (seed<<6) + (seed>>2);\n}\n\ninline size_t comball(initializer_list l)\n{\n size_t seed = 0;\n for(auto e : l) {\n hash_combine2(seed, e);\n }\n return seed;\n}\n\ntemplate \ninline void hash_combine(std::size_t& seed, const T& v)\n{\n std::hash hasher;\n seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);\n}\n\nusing uint = unsigned;\n\nusing HASH = tuple;\n\nenum TYEPS { INPUT, REFERENCE, OP };\nstruct Data {\n int type = INPUT;\n string name = \"\";\n HASH hsh;\n char op = '-';\n\n Data *refer = 0, *l = 0, *r = 0;\n\n bool operator==(const Data &b) const {\n return hsh == b.hsh;\n }\n};\n\nset ava;\nvector avas;\n\nData* makeInput(string name) {\n Data *d = new Data;\n d->type = INPUT;\n d->name = name;\n ava.erase(name);\n d->hsh = HASH(hash{}(name), hash{}(name + name), hash{}(name[0]));\n return d;\n}\nData* makeOp(Data * l, Data * r, char op) {\n Data *d = new Data;\n d->type = OP;\n d->l = l;\n d->r = r;\n d->op = op;\n\n size_t a, b, c;\n size_t x, y, z;\n tie(a, b, c) = l->hsh;\n tie(x, y, z) = r->hsh;\n size_t seed0 = comball({a, z, hash{}(string(3, op)), y, c});\n size_t seed1 = comball({x, hash{}(string(1, op)), b, c});\n size_t seed2 = comball({a, y, c, hash{}(op), x});\n\n d->hsh = HASH(seed0, seed1, seed2);\n return d;\n}\n\nint n;\n\nint OPN = 4;\nchar ops[] = {'$', '^', '#', '&'};\n\nmap data;\n\nvoid reset(string name) {\n if(!data.count(name)) data[name] = makeInput(name);\n}\n\nmap, Data*> uni;\nint k = 0;\nstringstream ans;\nset used;\n\nvoid dfs(Data*& p, bool root = 0) {\n if(!p) return;\n auto hs = make_tuple(p->type, p->name + p->op, p->hsh);\n if(uni.count(hs)) {\n p = uni[hs];\n return;\n }\n uni[hs] = p;\n if(used.count(p)) return;\n used.insert(p);\n switch(p->type) {\n case INPUT:\n if(root && p->name != \"res\") {\n k++;\n ans << \"res=\" << p->name << \"\\n\";\n }\n break;\n case OP:\n dfs(p->l);\n dfs(p->r);\n\n string name = \"res\";\n if(!root) {\n name = avas.back();\n avas.pop_back();\n }\n k++;\n ans << name << \"=\" << p->l->name << p->op << p->r->name << \"\\n\";\n assert(p->l->name.size());\n assert(p->r->name.size());\n p->name = name;\n break;\n }\n}\n\nint main() {\n std::ios::sync_with_stdio(false), std::cin.tie(0);\n for(int i = 0; i < 1000; i++) {\n ava.insert(\"a\" + to_string(i));\n ava.insert(\"b\" + to_string(i));\n ava.insert(\"c\" + to_string(i));\n }\n cin >> n;\n for(int i = 0; i < n; i++) {\n string s;\n cin >> s;\n int uku = s.find('=');\n assert(uku != -1);\n string LHS = s.substr(0, uku);\n string RHS = s.substr(uku + 1, int(s.size()) - uku - 1);\n int op = -1;\n string a1, a2;\n for(int o = 0; o < OPN; o++) {\n int id = RHS.find(ops[o]);\n if(id >= 0) {\n op = o;\n a1 = RHS.substr(0, id);\n a2 = RHS.substr(id + 1, int(RHS.size()) - id - 1);\n }\n }\n if(op >= 0) {\n reset(a1);\n reset(a2);\n assert(a1.size());\n assert(a2.size());\n data[LHS] = makeOp(data[a1], data[a2], ops[op]);\n } else {\n reset(RHS);\n data[LHS] = data[RHS];\n }\n }\n reset(\"res\");\n assert(ava.size() >= 1000);\n avas = vector(ava.begin(), ava.end());\n dfs(data[\"res\"], 1);\n dump(\"done\");\n ans << flush;//\n cout << k << \"\\n\";\n cout << ans.str()\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4a5ae442a7fb0cc9a240b01f03c97e8f", "src_uid": "da40321d92baaef42c2840e45599294c", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\ntypedef long long ll;\ntypedef vector vl;\ntypedef vector vvl;\ntypedef pair pll;\ntypedef vector vb;\nconst ll oo = 0x3f3f3f3f3f3f3f3f;\nconst double eps = 1e-9;\n#define sz(c) ll((c).size())\n#define all(c) begin(c), end(c)\n#define FOR(i,a,b) for (ll i = (a); i < (b); i++)\n#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)\n#define mp make_pair\n#define pb push_back\n#define eb emplace_back\n#define xx first\n#define yy second\n#define TR(X) ({ if(1) cerr << \"TR: \" << (#X) << \" = \" << (X) << endl; })\n\nbool is_op(char c) {\n\tfor (char d: \"$^#&\") if (c == d) return true;\n\treturn false;\n}\n\nint main() {\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\t\n\tmap var2node;\n\tll m = 0;\n\tvector> nodes;\n\tvector original_var;\n\tmap,ll> operations;\n\n\tauto add_node = [&](string a) {\n\t\toriginal_var.pb(a);\n\t\tnodes.eb('=',-1,m);\n\t\tvar2node[a] = m++;\n\t};\n\n\tll n; cin >> n;\n\twhile (n--) {\n\t\tstring asn; cin >> asn;\n\t\tll ii = 0;\n\t\twhile (asn[ii] != '=') ii++;\n\n\t\tstring a = asn.substr(0,ii);\n\t\tasn = asn.substr(ii+1), ii = 0;\n\t\twhile (ii < sz(asn) && !is_op(asn[ii])) ii++;\n\t\t\n\t\tif (ii == sz(asn)) {\n\t\t\tstring b = asn;\n\t\t\tif (!var2node.count(b)) {\n\t\t\t\tadd_node(b);\n\t\t\t}\n\t\t\tvar2node[a] = var2node[b];\n\t\t} else {\n\t\t\tstring b = asn.substr(0,ii), c = asn.substr(ii+1);\n\t\t\tchar op = asn[ii];\n\t\t\tif (!var2node.count(b)) {\n\t\t\t\tadd_node(b);\n\t\t\t}\n\t\t\tif (!var2node.count(c)) {\n\t\t\t\tadd_node(c);\n\t\t\t}\n\t\t\ttuple tpl = make_tuple(op,var2node[b],var2node[c]);\n\t\t\tif (!operations.count(tpl)) {\n\t\t\t\tnodes.pb(tpl);\n\t\t\t\toperations[tpl] = m++;\n\t\t\t}\n\t\t\tvar2node[a] = operations[tpl];\n\t\t}\n\t}\n\t\n\tif (!var2node.count(\"res\")) {\n\t\tcout << 0 << endl;\n\t\treturn 0;\n\t}\n\n\tauto fresh = [&]() {\n\t\tstring s = \"aaaa\";\n\t\twhile (var2node.count(s)) {\n\t\t\tFOR(i,0,4) s[i] = 'a' + rand() % 26;\n\t\t}\n\t\tvar2node[s] = -1;\n\t\treturn s;\n\t};\n\t\n\tvector res;\n\tmap new_var;\n\n\tfunction rec = [&](ll cur) {\n\t\tif (new_var.count(cur)) return new_var[cur];\n\t\t\n\t\tchar op;\n\t\tll a, b;\n\t\ttie(op,a,b) = nodes[cur];\n\t\tif (op == '=') return original_var[cur];\n\t\t\n\t\tstring stra = rec(a), strb = rec(b);\n\t\t\n\t\tstring str = (cur == var2node[\"res\"]) ? \"res\" : fresh();\n\t\tres.pb(str + \"=\" + stra + op + strb);\n\t\treturn new_var[cur] = str;\n\t};\n\t\n\tstring lst = rec(var2node[\"res\"]);\n\tif (lst != \"res\") res.pb(\"res=\" + lst);\n\tcout << sz(res) << endl;\n\tfor (string str: res) cout << str << endl;\n\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3d4aeb4096f2d40a8a64ecfbeca34eed", "src_uid": "da40321d92baaef42c2840e45599294c", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair pii;\n\n#define MOD ll(1e9 + 7)\n#define MAXN 200010\n#define LG 33\n#define inf (ll)1e18\n\ntemplate inline T smin(T &a, const T &b) { return a > b ? a = b : a; }\ntemplate inline T smax(T &a, const T &b) { return a < b ? a = b : a; }\ninline void add(ll &l, const ll &r) { l = (l + r) % MOD; }\nll gcd(ll v, ll u) { return u ? gcd(u, v % u) : v; }\nll po(ll v, ll u) { return u ? (po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD) : 1; }\n\nll n, m, a[MAXN], b[MAXN], answer;\n\nint main() {\n\tios::sync_with_stdio(0); cin.tie(0); cout.tie(0);\n\tcin >> n >> m;\n\tfor (int i = 1; i <= n; i++)\n\t\tcin >> a[i];\n\tfor (ll p = 1; (n * p) <= m; p++) {\n\t\tb[n] = min(a[n], p * m - n * ((p * (p - 1) / 2)));\n\t\tfor (int i = n - 1; i; i--)\n\t\t\tb[i] = min(a[i], b[i + 1] - p);\n\t\tif (b[1] < (p + n * ((p * (p - 1) / 2))))\n\t\t\tcontinue;\n\t\tll r = m - n * p, v = b[1], res = b[1];\n\t\tfor (int i = 2; i <= n; i++) {\n\t\t\tll can = min(b[i] - (v += p), r);\n\t\t\tv += can; r -= can; res += v;\n\t\t}\n\t\tsmax(answer, res);\n\t}\n\tcout << answer << endl;\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "09cfc8ebcf1d69be917a54324e73c71b", "src_uid": "169f58dc87d26e0fadde6a83bb623f54", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long ll;\n\nconst int N = 1e5 + 7;\n\nll c[N], p[N];\n\nint main()\n{\n\tios::sync_with_stdio(false), cin.tie(0);\n\n\tll n, m;\n\tcin >> n >> m;\n\n\tfor (int i=0; i> c[i];\n\n\tll ans = 0;\n\tfor (ll k=1; k * n <= m; k++)\n\t{\n\t\tp[n-1] = m * k - (k - 1) * k / 2 * n;\n\t\tp[n-1] = min(p[n-1], c[n-1]);\n\n\t\tfor (int i=n-2; i>=0; i--)\n\t\t\tp[i] = min(p[i+1] - k, c[i]);\n\n\t\tif (p[0] < k * (k+1) / 2LL)\n\t\t\tbreak;\n\t\t\n\t\tll space = m - n * k;\n\n\t\tll out = p[0];\n\t\tll prev = p[0];\n\n\t\tfor (int i=1; i\n#include \n#include \n#include \n#include \n#include \n#define SIZE 200005\n\nusing namespace std;\ntypedef long long int ll;\ntypedef pair P;\n\nll A[SIZE];\nll zan[SIZE];\nP st[SIZE];\n\nint main()\n{\n\tint n,m;\n\tscanf(\"%d %d\",&n,&m);\n\tfor(int i=0;i=0;i--)\n\t\t{\n\t\t\tif(sz>0&&st[sz-1].first<=zan[i]) continue;\n\t\t\tst[sz++]=P(zan[i],i);\n\t\t}\n\t\t//printf(\"%lld\\n\",sum);\n\t\t//for(int i=0;i=all) sum+=(ll) min(nm/k,all)*(ll) n*(ll) k;\n\t\telse\n\t\t{\n\t\t\tsum+=(ll) nm*(ll) n;\n\t\t\tll cn=(ll) all*(ll) k-nm;cn=min(cn,(ll) all);\n\t\t\tfor(int i=sz-2;i>=0;i--)\n\t\t\t{\n\t\t\t\tll cnt=st[i].first-st[i+1].first;\n\t\t\t\tint gt=n-st[i+1].second-1;\n\t\t\t\t//gt+(k-1)\u30b3 \u3092\u4e00\u56de\u3084\u308b\u3068\u3001nm-=(k-1),all--\n\t\t\t\t//k\u30b3 \u3092\u4e00\u56de\u3084\u308b\u3068\u3001nm-=k,all--\n\t\t\t\t//nm cn \u56de\u307e\u3067\u3067\u304d\u308b\n\t\t\t\tll g=min(cn,cnt);\n\t\t\t\tsum+=(ll) gt*(ll) g;\n\t\t\t\tcn-=g;\n\t\t\t}\n\t\t}\n\t\tret=max(ret,sum);\n\t}\n\tif(ret==0) assert(AAA==0);\n\tprintf(\"%I64d\\n\",ret);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "021aa50ed65c5fd838caf84920a3c400", "src_uid": "169f58dc87d26e0fadde6a83bb623f54", "difficulty": 2900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#define SIZE 200005\n\nusing namespace std;\ntypedef long long int ll;\ntypedef pair P;\n\nll A[SIZE];\nll zan[SIZE];\nP st[SIZE];\n\nint main()\n{\n\tint n,m;\n\tscanf(\"%d %d\",&n,&m);\n\tfor(int i=0;i=0;i--)\n\t\t{\n\t\t\tif(sz>0&&st[sz-1].first<=zan[i]) continue;\n\t\t\tst[sz++]=P(zan[i],i);\n\t\t}\n\t\t//printf(\"%lld\\n\",sum);\n\t\t//for(int i=0;i=all) sum+=(ll) min(nm/k,all)*(ll) n*(ll) k;\n\t\telse\n\t\t{\n\t\t\tsum+=(ll) nm*(ll) n;\n\t\t\tll cn=(ll) all*(ll) k-nm;cn=min(cn,(ll) all);\n\t\t\tfor(int i=sz-2;i>=0;i--)\n\t\t\t{\n\t\t\t\tll cnt=st[i].first-st[i+1].first;\n\t\t\t\tint gt=n-st[i+1].second-1;\n\t\t\t\t//gt+(k-1)\ufffdR \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0181Anm-=(k-1),all--\n\t\t\t\t//k\ufffdR \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u0181Anm-=k,all--\n\t\t\t\t//nm cn \ufffd\ufffd\u0702\u0142\u0142\ufffd\ufffd\ufffd\n\t\t\t\tll g=min(cn,cnt);\n\t\t\t\tsum+=(ll) gt*(ll) g;\n\t\t\t\tcn-=g;\n\t\t\t}\n\t\t}\n\t\tassert(sum>=bef);\n\t\tret=max(ret,sum);\n\t}\n\t//if(ret==0) assert(AAA==0);\n\tprintf(\"%lld\\n\",ret);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "0517cdeb24a1e6ceca97ba981f1c11f0", "src_uid": "169f58dc87d26e0fadde6a83bb623f54", "difficulty": 2900.0} {"lang": "GNU C++11", "source_code": "// <................. be name khoda ....................>\n// Balance treeeee\n#include\nusing namespace std;\n#define mp make_pair\nconst int N = 301;\nint n, v, e;\nlong long sum = 0;\nint a[ N + 1 ], fa[ N + 1 ], b[ N + 1 ];\nvector nei[ N + 1 ];\nint getFather( int i){\n\tif( fa[ i ] == -1 ) \n\t\treturn i;\n\treturn fa[ i ] = getFather( fa[ i ] );\n}\nbool vis[ N + 1 ];\nvector ve;\nvoid dfs(int cur, int p ){\n\tsum += 1ll * (a[ cur ] - b[ cur ]);\n\tvis[ cur ] = true;\n\tve.push_back( cur );\n\tfor(int ne : nei[ cur ] )\n\t\tif( ne != p ) dfs( ne, cur );\n}\nbool mark[ N + 1 ];\nvector > > curans;\nint currentVo, last;\nvector > curv;\nvector > > ans;\nvoid check( int cur){\n\tif( currentVo < 0ll ){\n\t\tlast = -currentVo;\n\t\tcurrentVo = min( 0ll, currentVo + a[ cur ] );\n\t}\n\tif( currentVo > 0ll){\n\t\tint x = v - a[ cur ];\n\t\tlast = currentVo;\n\t\tcurrentVo = max( currentVo - x, 0ll );\t\n\t}\t\n\treturn;\n}\nvoid dfs2( int cur, int p ){\n\tif( !currentVo ) return;\n\tif( cur != p ) curv.push_back( mp(cur,p) );\n\tif( cur != p ) check( cur );\n\tfor(int ne : nei[ cur ] ){\n\t\tif( ne != p && !mark[ ne ]) dfs2( ne, cur );\n\t}\n\treturn;\n}\nmain(){\n\tios::sync_with_stdio(false);\n\tcin.tie( 0 );\n\tcin >> n >> v >> e;\n\tfill( fa, fa + N + 1, -1);\n\tfor(int i = 0;i < n; i++) cin >> a[ i ];\n\tfor(int j = 0;j < n; j++) cin >> b[ j ];\n\tfor(int i = 0;i < e; i++){\n\t\tint u, v;\n\t\tcin >> u >> v;\n\t\tu--,v--;\n\t\tint f = getFather( u );\n\t\tint ff = getFather( v );\n\t\tif( ff != f ){\n\t\t fa[ v ] = f;\n\t\t\tnei[ v ].push_back( u );\n\t\t\tnei[ u ].push_back( v );\n\t\t}\t\n\t}\n\tfor(int i = 0; i < n; i++){\n\t\tif( vis[ i ] ) continue;\n\t\tsum = 0ll;\n\t\tve.resize( 0 );\n\t\tdfs( i, i );\n\t\tif( sum != 0 ) return cout << \"NO\",0;\n\t\tfor(int j = (int)ve.size() - 1; j > -1; j--){\n\t\t\tint J = ve[ j ];\n\t\t\tmark[ ve[ j ] ] = true;\n\t\t\tcurrentVo = a[ J ] - b[ J ];\n\t\t\tcurv.resize( 0 );\n\t\t\tlast = 0;\n\t\t\tif( !currentVo ) continue;\n\t\t//\tcout << J+1 < 0 ){\n\t\t\t\ta[ curv.back().first ] = a[ curv.back().first ] + last;\n\t\t\t\ta[ curv.back().second ] = a[ curv.back().second ] - last;\n\t\t\t\tans.push_back( mp( last, mp( curv.back().second, curv.back().first ) ) );\n\t\t//\t\tcout << last <<' ' << curv.back().second + 1 << curv.back().first + 1 < -1; k--){\n\t\t\t\tint x = 0;\n\t\t\t \tif( a[ J ] - b[ J ] > 0 ){\n\t\t\t\t\tx = min( a[ curv[ k ].second ], v - a[ curv[ k ].first ] );\t\n\t\t\t\t\ta[ curv[ k ].first ] += x;\n\t\t\t\t\ta[ curv[ k ].second ] -= x;\n\t\t\t\t\tans.push_back( mp( x, mp(curv[ k ].second, curv[ k ].first ) ) );\n\t\t//\t\t\tcout << last <<' ' << curv[ k ].second + 1 << curv[ k ].first + 1 <\n// Balance treeeee\n#include\nusing namespace std;\n#define mp make_pair\n#define int long long\nconst int N = 301;\nint n, v, e;\nlong long sum = 0;\nint a[ N + 1 ], s[ N + 1 ], fa[ N + 1 ], b[ N + 1 ];\nvector nei[ N + 1 ];\nint getFather( int i){\n\tif( fa[ i ] == -1 ) \n\t\treturn i;\n\treturn fa[ i ] = getFather( fa[ i ] );\n}\nint setFather( int i, int f ){\n\tint gi = -1;\n\twhile( fa[ i ] != -1 ){\n\t\tif( gi != f && gi!=-1) fa[ gi ] = f;\n\t\ti = fa[ i ];\n\t\tgi = i;\n\t}\n\tif( i != f ) fa[ i ] = f;\n\treturn i;\n}\nbool vis[ N + 1 ];\nvector ve;\nvoid dfs(int cur, int p ){\n\tsum += 1ll * (a[ cur ] - b[ cur ]);\n\tvis[ cur ] = true;\n\tve.push_back( cur );\n\tfor(int ne : nei[ cur ] )\n\t\tif( ne != p ) dfs( ne, cur );\n}\nbool mark[ N + 1 ];\nvector > > curans;\nint currentVo, last;\nvector > curv;\nvector > > ans;\nvoid check( int cur){\n\tif( currentVo < 0 ){\n\t\tlast = -currentVo;\n\t\tcurrentVo = min( 0, currentVo + a[ cur ] );\n\t}\n\tif( currentVo > 0){\n\t\tint x = v - a[ cur ];\n\t\tlast = currentVo;\n\t\tcurrentVo = max( currentVo - x, 0 );\t\n\t}\t\n\treturn;\n}\nvoid dfs2( int cur, int p ){\n\tif( !currentVo ) return;\n\tif( cur != p ) curv.push_back( mp(cur,p) );\n\tif( cur != p ) check( cur );\n\tfor(int ne : nei[ cur ] ){\n\t\tif( ne != p && !mark[ ne ]) dfs2( ne, cur );\n\t}\n\treturn;\n}\nmain(){\n\tios::sync_with_stdio(false);\n\tcin.tie( 0 );\n\tcin >> n >> v >> e;\n\tfill( fa, fa + N + 1, -1);\n\tfor(int i = 0;i < n; i++) cin >> a[ i ];\n\tfor(int j = 0;j < n; j++) cin >> b[ j ];\n\tfor(int i = 0;i < e; i++){\n\t\tint u, v;\n\t\tcin >> u >> v;\n\t\tu--,v--;\n\t\tint f = getFather( u );\n\t\tif( setFather( v , f) != f ){\n\t\t\tnei[ v ].push_back( u );\n\t\t\tnei[ u ].push_back( v );\n\t\t}\t\n\t}\n\tfor(int i = 0; i < n; i++){\n\t\tif( vis[ i ] ) continue;\n\t\tsum = 0ll;\n\t\tve.resize( 0 );\n\t\tdfs( i, i );\n\t\tif( sum != 0 ) return cout << \"NO\",0;\n\t\tfor(int j = (int)ve.size() - 1; j > -1; j--){\n\t\t\tint J = ve[ j ];\n\t\t\tmark[ ve[ j ] ] = true;\n\t\t\tcurrentVo = a[ J ] - b[ J ];\n\t\t\tcurv.resize( 0 );\n\t\t\tlast = 0;\n\t\t\tif( !currentVo ) continue;\n\t\t//\tcout << J+1 < 0 ){\n\t\t\t\ta[ curv.back().first ] = a[ curv.back().first ] + last;\n\t\t\t\ta[ curv.back().second ] = a[ curv.back().second ] - last;\n\t\t\t\tans.push_back( mp( last, mp( curv.back().second, curv.back().first ) ) );\n\t\t//\t\tcout << last <<' ' << curv.back().second + 1 << curv.back().first + 1 < -1; k--){\n\t\t\t\tint x = 0;\n\t\t\t \tif( a[ J ] - b[ J ] > 0 ){\n\t\t\t\t\tx = min( a[ curv[ k ].second ], v - a[ curv[ k ].first ] );\t\n\t\t\t\t\ta[ curv[ k ].first ] += x;\n\t\t\t\t\ta[ curv[ k ].second ] -= x;\n\t\t\t\t\tans.push_back( mp( x, mp(curv[ k ].second, curv[ k ].first ) ) );\n\t\t//\t\t\tcout << last <<' ' << curv[ k ].second + 1 << curv[ k ].first + 1 <\n#include \n#include \n#include \n#include \n#include \n#include \n#include\n#include\n#include\n#include \n#include \n#define PI 3.14159265\n\nusing namespace std;\n\nvector node[301];\nint b[301];\nint c[301];\nint parent[301];\nstack mo;\nstack le;\nvector,int>> ans;\n\nbool dfs(int now, int s, int t)\n{\n for (int i = 0; i < node[now].size(); i++)\n {\n int next = node[now][i];\n if (parent[next] != -1) continue;\n parent[next] = now;\n if (next == t)\n {\n return true;\n }\n if (dfs(next, s, t)) return true;\n }\n return false;\n}\n\n\nvoid write(int s, int t,int d,int v)\n{\n if (parent[t] == s)\n {\n ans.push_back(make_pair(make_pair(s, t), d));\n c[s] -= d;\n c[t] += d;\n return;\n }\n else if (c[parent[t]] >= d)\n {\n c[t] += d;\n c[parent[t]] -= d;\n ans.push_back(make_pair(make_pair(s, parent[t]), d));\n }\n else\n {\n ans.push_back(make_pair(make_pair(parent[t],t), c[parent[t]]));\n int temp = c[parent[t]];\n c[parent[t]] = 0;\n write(s, parent[t], d ,v);\n ans.push_back(make_pair(make_pair(parent[t], t), d - temp));\n c[t] += d;\n c[parent[t]] = temp;\n\n }\n\n}\n\nint main() {\n \n std::ios_base::sync_with_stdio(false);\n\n int n, v, e;\n cin >> n >> v >> e;\n int sum = 0;\n for (int i = 1; i <= n; i++)\n {\n cin >> c[i];\n sum += c[i];\n }\n for (int i = 1; i <= n; i++)\n {\n cin >> b[i];\n sum -= b[i];\n if (c[i] < b[i])\n {\n le.push(i);\n }\n else if (c[i]>b[i])\n {\n mo.push(i);\n }\n }\n if (sum != 0)\n {\n cout << \"NO\" << endl;\n return 0;\n }\n for (int i = 0; i < e; i++)\n {\n int u, v;\n cin >> u >> v;\n node[u].push_back(v);\n node[v].push_back(u);\n }\n\n while (mo.size() > 0)\n {\n int s = mo.top();\n int t = le.top(); \n memset(parent, -1, sizeof(parent));\n parent[s] = 0;\n dfs(s, s, t);\n int d = min(c[s] - b[s], b[t] - c[t]);\n write(s, t, d, v);\n if (c[s] == b[s]) mo.pop();\n if (c[t] == b[t]) le.pop();\n }\n cout << ans.size() << endl;\n for (int i = 0; i < ans.size(); i++)\n {\n cout << ans[i].first.first << \" \" << ans[i].first.second << \" \" << ans[i].second << endl;\n }\n // system(\"PAUSE\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4a68c569406fd7ba138d8930abaf8992", "src_uid": "0939354d9bad8301efb79a1a934ded30", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "// <................. be name khoda ....................>\n// Balance treeeee\n#include\nusing namespace std;\n#define mp make_pair\nconst int N = 301;\nint n, v, e;\nlong long sum = 0;\nint a[ N + 1 ], fa[ N + 1 ], b[ N + 1 ];\nvector nei[ N + 1 ];\nint getFather( int i){\n\tif( fa[ i ] == -1 ) \n\t\treturn i;\n\treturn fa[ i ] = getFather( fa[ i ] );\n}\nbool vis[ N + 1 ];\nbool mark[ N + 1 ];\nint currentVo;\nvector > > ans;\nvoid check( int cur,int p, int &x){\n x = abs( currentVo );\n\tif( currentVo < 0 )\n\t\tcurrentVo = min( 0, currentVo + a[ cur ] );\n\tif( currentVo > 0)\n\t\tcurrentVo = max( currentVo - (v - a[ cur ]), 0 );\n\tif( currentVo ) x = -1;\n\treturn;\n}\nbool isg=false;\nvoid dfs2( int cur, int p ){\n int x = 0;\n\tif( !currentVo ) return;\n\tif( cur != p ) check( cur,p, x );\n\tfor(int ne : nei[ cur ] )\n\t if( ne != p && !mark[ ne ]) dfs2( ne, cur );\n if( cur == p ) return;\n\tif( isg ){\n\t if( x == -1 )\n\t\t x = min(v - a[ cur ], a[ p ]);\n\t\ta[ cur ] += x;\n\t\ta[ p ] -= x;\n ans.push_back( mp(x,mp(p,cur)));\n\t}\n\telse{\n\t if( x == -1)\n\t\t x = min( v-a[ p ], a[ cur ]);\n\t\ta[ cur ] -= x;\n\t\ta[ p ] += x;\n\t\tans.push_back( mp(x,mp(cur,p)));\n\t}\n}\nvoid dfs(int cur, int p ){\n\tsum += 1ll * (a[ cur ] - b[ cur ]);\n\tvis[ cur ] = true;\n\tve.push_back( cur );\n\tfor(int ne : nei[ cur ] )\n\t\tif( ne != p ) dfs( ne, cur );\n\tmark[ cur ] = true;\n\tcurrentVo = a[ cur ] - b[ cur ];\n\tisg = (currentVo > 0);\n\tif( currentVo )\n\t dfs2( cur, cur );\n}\nmain(){\n\tios::sync_with_stdio(false);\n\tcin.tie( 0 );\n\tcin >> n >> v >> e;\n\tfill( fa, fa + N + 1, -1);\n\tfor(int i = 0;i < n; i++) cin >> a[ i ];\n\tfor(int j = 0;j < n; j++) cin >> b[ j ];\n\tfor(int i = 0;i < e; i++){\n\t\tint u, v;\n\t\tcin >> u >> v;\n\t\tu--,v--;\n\t\tint f = getFather( u );\n\t\tint ff = getFather( v );\n\t\tif( ff != f ){\n\t\t fa[ v ] = f;\n\t\t\tnei[ v ].push_back( u );\n\t\t\tnei[ u ].push_back( v );\n\t\t}\t\n\t}\n\tfor(int i = 0; i < n; i++){\n\t\tif( vis[ i ] ) continue;\n\t\tsum = 0ll;\n\t\tdfs( i, i );\n\t\tif( sum != 0 ) return cout << \"NO\",0;\n\t}\n\tcout << (int)ans.size() <\nusing namespace std;\n\n#define ms(s, n) memset(s, n, sizeof(s))\n#define FOR(i, a, b) for(int i = (a); i < (b); i++)\n#define FORd(i, a, b) for(int i = (a) - 1; i >= (b); i--)\n#define sz(a) int((a).size())\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef pair pi;\ntypedef vector vi;\ntypedef vector vii;\nll gcd(ll a, ll b) {ll r; while (b != 0) {r = a % b; a = b; b = r;} return a;}\nll lcm(ll a, ll b) {return a / gcd(a, b) * b;}\n\nstruct recommendation {\n\tint l, r;\n\tint max;\n\tld pro;\n};\n\nbool compare(recommendation a, recommendation b) {\n\tif (a.l == b.l) return a.r >= b.r;\n\treturn a.l < b.l;\n}\n\nconst int maxn = 100010;\nconst int maxq = 5010;\nint n, q;\nint a[maxn];\nint amax;\nrecommendation re[maxq];\nvi nex[maxq];\nvi head;\nld pro[maxq];\nmap mp;\n\nld cal(int cur, int k, int val) {\n\tif (mp.count(make_pair(cur, k))) return mp[make_pair(cur, k)];\n\tif (re[cur].max + k > val) return 0.0;\n\tif (!sz(nex[cur])) {\n\t\tif (re[cur].max + k == val) return 1.0 - re[cur].pro;\n\t\telse return 1.0;\n\t}\n\tld res = 1;\n\tFOR(i, 0, sz(nex[cur])) {\n\t\tld tmp = 0;\n\t\ttmp += (1.0 - re[cur].pro) * cal(nex[cur][i], k, val);\n\t\tif (re[cur].max + k < val) tmp += re[cur].pro * cal(nex[cur][i], k + 1, val);\n\t\tres *= tmp;\n\t}\n\treturn mp[make_pair(cur, k)] = res;\n}\n\nvoid cal(int val) {\n\tpro[val] = 1;\n\tFOR(i, 0, sz(head)) {\n\t\tmp.clear();\n\t\tint cur = head[i];\n\t\tpro[val] *= cal(cur, 0, val + amax);\n\t}\n}\n\nint go(int cur, int r) {\n\tint i;\n\tfor (i = cur + 1; i < q && re[i].r <= r; i++) {\n\t\tif (cur != -1) nex[cur].push_back(i);\n\t\telse head.push_back(i);\n\t\ti = go(i, re[i].r);\n\t}\n\treturn i - 1;\n}\n\nvoid solve() {\n\tscanf(\"%d%d\", &n, &q);\n\tamax = 0;\n\tFOR(i, 0, n) {\n\t\tscanf(\"%d\", a + i);\n\t\tamax = max(amax, a[i]);\n\t}\n\tFOR(i, 0, q) {\n\t\tcin>>re[i].l>>re[i].r>>re[i].pro; re[i].l--; re[i].r--;\n\t\tre[i].max = 0;\n\t\tFOR(j, re[i].l, re[i].r + 1) re[i].max = max(re[i].max, a[j]);\n\t}\n\tsort(re, re + q, compare);\n\tgo(-1, INT_MAX);\n\tFOR(i, 0, q + 1) cal(i);\n\tld ans = 0;\n\tFOR(i, 0, q + 1) {\n\t\tif (!i) ans += 1.0 * (amax + i) * pro[i];\n\t\telse ans += 1.0 * (amax + i) * (pro[i] - pro[i - 1]);\n\t}\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef long long LL;\ntypedef unsigned long long ULL;\n// typedef unsigned long long ulong;\ntypedef unsigned int uint;\ntypedef unsigned short ushort;\ntypedef unsigned char uchar;\n\n#define MAX_INT 0x7fffffff\n#define MIN_INT 0x80000000\n#define MAX_UINT 0xffffffff\n\ntemplate inline T SQR(T x) { return x * x; }\ntemplate inline string TOSTR(const T & x) { stringstream ss; ss << x; return ss.str(); }\ntemplate void UPDATE_MIN(T &x,T y){ if(y < x) { x = y;} }\ntemplate void UPDATE_MAX(T &x,T y){ if(x < y) { x = y;} }\n\n#define FORN(i,n) for(int (i)=0;(i)<(int)(n);(i)++)\n#define FOR(i,s,n) for(int (i)=s;(i)<(int)(n);(i)++)\n#define ITER(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)\n#define SWAP(a, b, tmp) {__typeof(a) tmp = a; a = b; b = tmp;}\n#ifndef ONLINE_JUDGE\n #define EPR(args...) fprintf (stderr, args)\n#else\n #define EPR(args...) 1\n#endif\n#if 1 // disable print\n #undef EPR\n #define EPR(args...) 1\n#endif\n\n#define SZ(x) ((int)(x).size())\n#define FORV(i,v) FORN(i,SZ(v))\n#define MAX(a,b) ((a > b) ? a : b)\n#define MIN(a,b) ((a < b) ? a : b)\n\n#define PR(x) cout << (x) << endl\n#define PRF(x) cout << setprecision(10) << x << endl\n#define POW2(x) (1ll<<(x))\n\nint gcd(int a, int b){return a?gcd(b%a,a):b;}\nLL gcd(LL a, LL b){return a?gcd(b%a,a):b;}\nLL powmod(LL a, LL p, LL m){LL r=1;while(p){if(p&1)r=r*a%m;p>>=1;a=a*a%m;}return r;}\n\nconst int MOD = 1000 * 1000 * 1000 + 7;\nconst double PI = 3.1415926535897932384626433832795l;\n\n#define MAXN 100000\n#define MAXQ 5099\nint N, Q;\nint A[MAXN + 100];\nint M[MAXN + 100][14];\n\nvoid RMQ_prepair() {\n int i, j;\n //initialize M for the intervals with length 1\n for (i = 0; i < N; i++)\n M[i][0] = i;\n //compute values from smaller to bigger intervals\n for (j = 1; 1 << j <= N; j++) {\n for (i = 0; i + (1 << j) - 1 < N; i++) {\n int x = M[i][j - 1];\n int y = M[i + (1 << (j - 1))][j - 1];\n if (A[x] > A[y])\n M[i][j] = x;\n else\n M[i][j] = y;\n }\n }\n}\n\nint RMQ(int i, int j) {\n if (i == j)\n return i;\n int k = (int)log2(j - i);\n int x = M[i][k];\n int y = M[j - (1 << k) + 1][k];\n if (A[x] > A[y])\n return x;\n else\n return y;\n}\n\ntypedef struct {\n int l;\n int r;\n double p;\n int max_up;\n double a[MAXQ];\n double prod_p[MAXQ];\n double prod_q[MAXQ];\n} Seg;\n\ntypedef struct {\n int l;\n int r;\n double p;\n} Miniseg;\n\nMiniseg minisegs[MAXQ];\nSeg segs[MAXQ];\nint seg_i = 0;\n\nint compare(Miniseg a, Miniseg b) {\n if (a.l < b.l) return 1;\n if (a.l > b.l) return 0;\n\n if (a.r > b.r) return 1;\n if (a.r < b.r) return 0;\n return 0;\n}\n\nint calc(int curseg_i) {\n Seg &seg = segs[curseg_i];\n // printf(\"%d %d: %d\\n\", seg.l, seg.r, RMQ(seg.l, seg.r));\n int mx = A[RMQ(seg.l, seg.r)];\n // int mx = 0;\n // printf(\"MX %d %d = %d\\n\", seg.l, seg.r, mx);\n\n FORN(i, Q + 1) seg.prod_p[i] = 1.0;\n FORN(i, Q + 1) seg.prod_q[i] = 1.0;\n seg.prod_p[0] = 0.0;\n\n while (1) {\n int next_seg_i = seg_i;\n if (next_seg_i >= Q)\n break;\n Seg &next_seg = segs[next_seg_i];\n if (!(seg.l <= next_seg.l && next_seg.r <= seg.r))\n break;\n\n seg_i++;\n // printf(\"Proc %d: %d\\n\", curseg_i, seg_i - 1);\n int ch_mx = calc(next_seg_i);\n\n int diff = mx - ch_mx;\n // printf(\"adding %d -> %d (diff %d - %d = %d)\\n\", next_seg_i, curseg_i, mx, ch_mx, diff);\n FOR(i, diff + 1, Q + 1) {\n // printf(\" prod_p: %f[%d] * %f[%d] = \", seg.prod_p[i - diff], i - diff, next_seg.a[i - 1], i - 1);\n seg.prod_p[i - diff] *= next_seg.a[i - 1];\n // printf(\"%f\\n\", seg.prod_p[i - diff]);\n }\n FOR(i, diff, Q + 1) {\n // printf(\" prod_q: %f[%d] * %f[%d] = \", seg.prod_q[i - diff], i - diff, next_seg.a[i], i);\n seg.prod_q[i - diff] *= next_seg.a[i];\n // printf(\"%f\\n\", seg.prod_q[i - diff]);\n }\n }\n double q = 1 - seg.p;\n FORN(i, Q + 2) {\n seg.a[i] = seg.prod_p[i] * seg.p + seg.prod_q[i] * q;\n // if (i == 0) {\n // printf(\"at %d (seg %d): %f * %f + %f * %f = %f\\n\", i, curseg_i, seg.prod_p[i], seg.p, seg.prod_q[i], q, seg.a[i]);\n // }\n }\n return mx;\n}\n\nint main() {\n cin >> N >> Q;\n FORN(i, N) cin >> A[i];\n RMQ_prepair();\n FORN(i, Q) {\n int l, r;\n double p;\n cin >> l >> r >> p;\n l--;\n r--;\n minisegs[i] = {l, r, p};\n }\n // cout << \"Sorting\" << endl;\n sort(minisegs, minisegs + Q, compare);\n // cout << \"Copying\" << endl;\n // FORN(i, Q) {\n // cout << minisegs[i].l << \" \" << minisegs[i].r << \" \" << minisegs[i].p << endl;\n // }\n FORN(i, Q) {\n segs[i] = {minisegs[i].l, minisegs[i].r, minisegs[i].p};\n }\n segs[Q] = {0, N, 0.0};\n // cout << \"Start calc\" << endl;\n int mx = calc(Q);\n // int mx = 1;\n\n Seg &seg = segs[Q];\n double res = seg.a[0] * mx;\n // printf(\"%d: %f\\n\", mx, seg.a[0]);\n FOR(j, 1, Q + 1) {\n // printf(\"%d: %f\\n\", mx + j, seg.a[j]);\n res += (mx + j) * (seg.a[j] - seg.a[j - 1]);\n }\n printf(\"%.10f\\n\", res);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "92db13f905dca076a94a36571f215b70", "src_uid": "2a6e1be07d3edf6b00998998cf9e621b", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\nint const N = 1e5 + 10, M = 5e3 + 10, mod = 1e9 + 7;\nint n, q, cnt, a[N], h[M], mx[M], st[N][20], lg[N];\ndouble dp[M][M], P[M][M], Q[M][M];\nstruct Node {\n int l, r;\n double p;\n bool operator<(Node const &other) const {\n if (l == other.l) return r > other.r;\n else return l < other.l;\n }\n} rec[M];\nstruct Edge {\n int t, n;\n} tree[M];\nvoid insert(int f, int t) {\n tree[cnt].t = t;\n tree[cnt].n = h[f];\n h[f] = cnt++;\n}\nvoid solve(int rt) {\n for (int i = 0; i <= q; i++) {\n P[rt][i] = 1;\n Q[rt][i] = 1;\n }\n for (int i = h[rt], t; ~i; i = tree[i].n) {\n solve(t = tree[i].t);\n for (int j = 0, k; j <= q; j++) {\n k = mx[rt] - mx[t] + j;\n if (j) P[rt][j] *= dp[t][min(k - 1, q)];\n Q[rt][j] *= dp[t][min(k, q)];\n }\n }\n for (int i = 0; i <= q; i++) dp[rt][i] = (i ? P[rt][i] : 0) * rec[rt].p + Q[rt][i] * (1 - rec[rt].p);\n}\ninline int rmq(int l, int r) {\n int len = r - l + 1;\n return max(st[l][lg[len]], st[r - (1 << lg[len]) + 1][lg[len]]);\n}\nint main() {\n //freopen(\"in.txt\", \"r\", stdin);\n //freopen(\"out.txt\", \"w\", stdout);\n cin >> n >> q;\n for (int i = 1; i <= n; i++) cin >> a[i];\n rec[0].l = 1; rec[0].r = n; rec[0].p = 0;\n for (int i = 1; i <= q; i++) cin >> rec[i].l >> rec[i].r >> rec[i].p;\n sort(rec, rec + q + 1);\n memset(h, -1, sizeof(h));\n for (int i = 1, j; i <= q; i++) {\n for (j = i - 1; rec[j].r < rec[i].r; j--);\n insert(j, i);\n }\n lg[1] = 0;\n for (int i = 2; i <= n; i++) lg[i] = lg[i - 1] + !((i - 1) & i);\n for (int i = 1; i <= n; i++) st[i][0] = a[i];\n for (int i = 1; i < 20; i++)\n for (int j = 1; j <= n; j++)\n st[j][i] = max(st[j][i - 1], (j + (1 << i - 1)) <= n ? st[j + (1 << i - 1)][i - 1] : 0);\n for (int i = 0, j; i <= q; i++) mx[i] = rmq(rec[i].l, rec[i].r);\n q++;\n solve(0);\n double ans = dp[0][0] * mx[0];\n for (int i = 1; i <= q; i++)\n ans += (dp[0][i] - dp[0][i - 1]) * (mx[0] + i);\n printf(\"%.6f\\n\", ans);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "eab86c614a7af5f7f621230f2715ae61", "src_uid": "2a6e1be07d3edf6b00998998cf9e621b", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n\n#define ms(s, n) memset(s, n, sizeof(s))\n#define FOR(i, a, b) for(int i = (a); i < (b); i++)\n#define FORd(i, a, b) for(int i = (a) - 1; i >= (b); i--)\n#define sz(a) int((a).size())\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef pair pi;\ntypedef vector vi;\ntypedef vector vii;\nll gcd(ll a, ll b) {ll r; while (b != 0) {r = a % b; a = b; b = r;} return a;}\nll lcm(ll a, ll b) {return a / gcd(a, b) * b;}\n\nstruct recommendation {\n\tint l, r;\n\tint max;\n\tld pro;\n};\n\nconst int maxn = 100010;\nconst int maxq = 5010;\nint n, q;\nint a[maxn];\nint amax;\nrecommendation re[maxq];\nvi head;\nvi nex[maxq];\nld pro[maxq];\nld f[maxq][2 * maxq];\n\nld cal(int cur, int val) {\n\tif (f[cur][val + maxq] != -1.0) return f[cur][val + maxq];\n\tif (re[cur].max > amax + val) return 0.0;\n\tif (!sz(nex[cur])) {\n\t\tif (re[cur].max == amax + val) return 1.0 - re[cur].pro; else return 1.0;\n\t}\n\tld res = 1.0;\n\tFOR(i, 0, sz(nex[cur])) {\n\t\tld tmp = (1.0 - re[cur].pro) * cal(nex[cur][i], val);\n\t\tif (re[cur].max < amax + val) tmp += re[cur].pro * cal(nex[cur][i], val - 1);\n\t\tres *= tmp;\n\t}\n\treturn f[cur][val + maxq] = res;\n}\n\nvoid cal() {\n\tFOR(i, 0, maxq) FOR(j, 0, 2 * maxq) f[i][j] = -1.0;\n\tFOR(val, 0, q + 1) {\n\t\tpro[val] = 1.0;\n\t\tFOR(i, 0, sz(head)) {\n\t\t\tint cur = head[i];\n\t\t\tpro[val] *= cal(cur, val);\n\t\t}\n\t}\n}\n\nint go(int cur, int r) {\n\tint i;\n\tfor (i = cur + 1; i < q && re[i].r <= r; i++) {\n\t\tif (cur == -1) head.push_back(i); else nex[cur].push_back(i);\n\t\ti = go(i, re[i].r);\n\t}\n\treturn i - 1;\n}\n\nvoid solve() {\n\tscanf(\"%d%d\", &n, &q);\n\tamax = 0;\n\tFOR(i, 0, n) {\n\t\tscanf(\"%d\", a + i);\n\t\tamax = max(amax, a[i]);\n\t}\n\tFOR(i, 0, q) {\n\t\tcin>>re[i].l>>re[i].r>>re[i].pro; re[i].l--; re[i].r--;\n\t\tre[i].max = 0; FOR(j, re[i].l, re[i].r + 1) re[i].max = max(re[i].max, a[j]);\n\t}\n\tFOR(i, 0, q) FOR(j, i + 1, q) if (make_pair(re[i].l, -re[i].r) > make_pair(re[j].l, -re[j].r)) swap(re[i], re[j]);\n\tgo(-1, INT_MAX); cal();\n\tld ans = pro[q] * (amax + q);\n\tFOR(i, 0, q) ans -= pro[i];\n\tcout<\nusing namespace std;\n#define ff first\n#define ss second\n#define pb push_back\n#define all(x) (x).begin(), (x).end()\ntypedef int64_t lld;\ntypedef pair pii;\n//#define endl '\\n'\n \ntemplate\nostream& outIt(ostream& out, It b, It e){\n for(It i = b; i != e; i++)\n out << (i==b?\"\":\" \") << *i;\n return out;\n}\ntemplate\nostream& operator<<(ostream& out, vector& v){\n return outIt(out << '[', all(v))<< ']';\n}\ntemplate\nostream& operator<<(ostream& out, pair p){\n return out << '(' << p.ff << \", \" << p.ss << ')';\n}\ntemplate\nistream& operator>>(istream& in, pair& p){\n return in >> p.ff >> p.ss;\n}\nvectorans;\nint fpow(int a, int b, int mod){\n int ans = 1;\n do if(b&1)ans = (lld)ans * a % mod;\n while(a = (lld)a*a%mod, b>>=1);\n return ans;\n}\n//const int mod = 1000000007;\nsigned main(){cin.tie(0); ios_base::sync_with_stdio(0);\n int n;\n cin >> n;\n ans.resize(n+1); ans[0] = LLONG_MAX;\n int x = fpow(7, n-2, n);\n for(int i = 1; i <= n; i++){\n int x;\n cin >> x;\n if(n%7 == 0){\n if(i%7 == 0)ans[i] = LLONG_MAX;\n else ans[i] = i + (lld)(x-1)*n;\n }else{\n int next = ((lld)a*i*7-i+7*n)%(7*n)+i; // next = 7k = i mod n\n cout << i << \" \" << next << endl;\n if((next-i)/n+1 > x) ans[i] = i + (lld)(x-1)*n;\n else ans[i] = ((lld)(x-(next-i)/n-1)/6*7+(x-(next-i)/n-1)+1)*n+next;\n }\n }\n //cout << ans << endl;\n cout << min_element(all(ans))-ans.begin() << endl;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "8a723958c45c599f592fe92ad7f2b577", "src_uid": "8054dc5dd09d600d7fb8d9f5db4dcaca", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int inf = int (1e9) + 7;\n\nint main ()\n{\n ios_base::sync_with_stdio (false);\n cin.tie (NULL);\n\n int n;\n\n cin >> n;\n\n vector arr (n);\n\n for (auto &it : arr)\n cin >> it;\n\n if (n % 7 == 0)\n {\n for (int i = 6; i < arr.size (); i += 7)\n arr[i] = inf;\n\n cout << (min_element (arr.begin (), arr.end ()) - arr.begin () + 1) << endl;\n\n return 0;\n }\n\n int t = (*min_element (arr.begin (), arr.end ()) - 1) / 6;\n\n while (t-- > 0)\n for (auto &it : arr)\n it -= 6;\n\n int cnt = 0, pos = 0;\n\n while (cnt == 6 || arr[pos] > 1)\n {\n if (cnt++ != 6)\n arr[pos]--;\n else\n cnt = 0;\n\n pos = (pos + 1) % arr.size ();\n }\n\n cout << pos + 1 << endl;\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "70a3d7517d5208e41621b7897b8625fb", "src_uid": "8054dc5dd09d600d7fb8d9f5db4dcaca", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "#pragma gcc optimize(\"O3, unroll-loops\")\n#include\nusing namespace std;\n#define ff first\n#define ss second\n#define pb push_back\n#define all(x) (x).begin(), (x).end()\ntypedef int64_t lld;\n#define int lld\ntypedef pair pii;\n//#define endl '\\n'\n \ntemplate\nostream& outIt(ostream& out, It b, It e){\n for(It i = b; i != e; i++)\n out << (i==b?\"\":\" \") << *i;\n return out;\n}\ntemplate\nostream& operator<<(ostream& out, vector& v){\n return outIt(out << '[', all(v))<< ']';\n}\ntemplate\nostream& operator<<(ostream& out, pair p){\n return out << '(' << p.ff << \", \" << p.ss << ')';\n}\ntemplate\nistream& operator>>(istream& in, pair& p){\n return in >> p.ff >> p.ss;\n}\nvectorans;\nint fpow(int a, int b, int mod){\n int ans = 1;\n if(b <= 0)return ans;\n do if(b&1)ans = (lld)ans * a % mod;\n while(a = (lld)a*a%mod, b>>=1);\n return ans;\n}\n//const int mod = 1000000007;\nsigned main(){cin.tie(0); ios_base::sync_with_stdio(0);\n int n;\n cin >> n;\n ans.resize(n+1); ans[0] = LLONG_MAX;\n int xax = fpow(7, n-2, n);\n for(int i = 1; i <= n; i++){\n int x;\n cin >> x;\n if(n%7 == 0){\n if(i%7 == 0)ans[i] = LLONG_MAX;\n else ans[i] = i + (lld)(x-1)*n;\n }else{\n lld next = ((lld)xax*i*7-i)%(7*n)+i; // next = 7k = i mod n\n assert(next >= i); assert(next%n == i%n); assert(next%7 == 0);\n //cout << i << \" \" << next << endl;\n if((next-i)/n >= x) ans[i] = i + (lld)(x-1)*n;\n else x-=(next-i)/n, ans[i] = (lld)(x/6*7+x%6+1)*n+next;\n }\n }\n //cout << ans << endl;\n cout << min_element(all(ans))-ans.begin() << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b51a69eb0064ba6a41f861ff319364b4", "src_uid": "8054dc5dd09d600d7fb8d9f5db4dcaca", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "#pragma gcc optimize(\"O3, unroll-loops\")\n#include\nusing namespace std;\n#define ff first\n#define ss second\n#define pb push_back\n#define all(x) (x).begin(), (x).end()\ntypedef int64_t lld;\n#define int lld\ntypedef pair pii;\n//#define endl '\\n'\n \ntemplate\nostream& outIt(ostream& out, It b, It e){\n for(It i = b; i != e; i++)\n out << (i==b?\"\":\" \") << *i;\n return out;\n}\ntemplate\nostream& operator<<(ostream& out, vector& v){\n return outIt(out << '[', all(v))<< ']';\n}\ntemplate\nostream& operator<<(ostream& out, pair p){\n return out << '(' << p.ff << \", \" << p.ss << ')';\n}\ntemplate\nistream& operator>>(istream& in, pair& p){\n return in >> p.ff >> p.ss;\n}\nvectorans;\nint fpow(int a, int b, int mod){\n int ans = 1;\n if(b <= 0)return ans;\n do if(b&1)ans = (lld)ans * a % mod;\n while(a = (lld)a*a%mod, b>>=1);\n return ans;\n}\nint invmod(int a, int b, int mod, int s0 = 0, int s1 = 1){\n return b?invmod(b, a%b, mod, (s1-((lld)a/b*s0)%mod+mod)%mod, s0):s1;\n}\n//const int mod = 1000000007;\nsigned main(){cin.tie(0); ios_base::sync_with_stdio(0);\n int n;\n cin >> n;\n ans.resize(n+1); ans[0] = LLONG_MAX;\n int xax = invmod(7, n, n);\n //if(n > 2 && n%7 != 0)assert(xax*7 % n == 1);\n for(int i = 1; i <= n; i++){\n int x;\n cin >> x;\n if(n%7 == 0){\n if(i%7 == 0)ans[i] = LLONG_MAX;\n else ans[i] = i + (lld)(x-1)*n;\n }else{\n lld next = ((lld)xax*i*7-i)%(7*n)+i; // next = 7k = i mod n\n assert(next >= i);\n assert(next%n == i%n);\n assert(next%7 == 0);\n //cout << i << \" \" << next << endl;\n if((next-i)/n >= x) ans[i] = i + (lld)(x-1)*n;\n else x-=(next-i)/n, ans[i] = (lld)(x/6*7+x%6+1)*n+next;\n }\n }\n //cout << ans << endl;\n cout << min_element(all(ans))-ans.begin() << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5addb5fd58e4c292ff6f8f67d556402d", "src_uid": "8054dc5dd09d600d7fb8d9f5db4dcaca", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include\n#define pp pair\n#define MZ 1000000007\nusing namespace std;\nlong long k;\nint numx[35],numy[35],numk[35];\nlong long sum[35][2][2][2],num[35][2][2][2];\nlong long ask(long long x,long long y)\n{\n long long ans=0;\n long long z=k;\n if(x<0 || y<0) return 0;\n memset(sum,0,sizeof(sum));\n memset(num,0,sizeof(num));\n for(int i=0;i<30;i++)\n {\n numx[i]=x%2;\n numy[i]=y%2;\n numk[i]=z%2;\n x>>=1;\n y>>=1;\n z>>=1;\n }\n num[30][1][1][1]=1;\n sum[30][1][1][1]=0;\n int im,jm;\n for(int lens=30;lens>=0;lens--)\n for(int i=0;i<2;i++)\n for(int j=0;j<2;j++)\n for(int kk=0;kk<2;kk++)\n if(num[lens][i][j][kk])\n {\n if(lens==0)\n ans=(ans+num[lens][i][j][kk]+sum[lens][i][j][kk])%MZ;\n im=jm=1;\n if(i)\n im=numx[lens-1];\n if(j)\n jm=numy[lens-1];\n for(int nowi=0;nowi<=im;nowi++)\n for(int nowj=0;nowj<=jm;nowj++)\n {\n if(!kk || (nowi^nowj)<=numk[lens-1])\n {\n num[lens-1][(nowi==im && i)][(nowj==jm && j)][(nowi^nowj==numk[lens-1]) && kk]=(num[lens-1][(nowi==im && i)][(nowj==jm && j)][(nowi^nowj==numk[lens-1]) && kk]+num[lens][i][j][kk])%MZ;\n sum[lens-1][(nowi==im && i)][(nowj==jm && j)][(nowi^nowj==numk[lens-1]) && kk]=(sum[lens-1][(nowi==im && i)][(nowj==jm && j)][(nowi^nowj==numk[lens-1]) && kk]+(sum[lens][i][j][kk]<<1)+(nowi^nowj)*num[lens][i][j][kk])%MZ;\n }\n }\n }\n return ans;\n}\nint main()\n{\n int q;\n long long x1,y1,x2,y2;\n scanf(\"%d\",&q);\n while(q--)\n {\n scanf(\"%lld%lld%lld%lld%lld\",&x1,&y1,&x2,&y2,&k);\n x1--;\n y1--;\n x2--;\n y2--;\n k--;\n printf(\"%lld\\n\",(ask(x2,y2)-ask(x2,y1-1)-ask(x1-1,y2)+ask(x1-1,y1-1)+MZ)%MZ);\n\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5a51c23f642f9ed9ab7729e33591d51c", "src_uid": "1ab085026ce43810acf98cc4bf8faf26", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include \n#define base 1000000007LL\n#define ll long long\n#define X first\n#define Y second\n#define pb push_back\n#define EPS 1e-9\n#define all(a) (a).begin(), (a).end()\n#define sz(a) int((a).size())\n#define ms(s, n) memset(s, n, sizeof(s))\n#define FOR(i,a,b) for (int i = (a); i <= (b); i++)\n#define FORE(i,a,b) for (int i = (a); i >= (b); i--)\n#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)\nusing namespace std;\ntypedef pair II;\ntypedef pair III;\n\nconst ll MODD = 1e9 + 7;\n\nll solve(ll u, ll v, ll k, ll o = 0)\n{\n if (u > v) swap(u, v);\n if (u < 1 || k < 1) return 0;\n ll p = 1, res = 0;\n while (p*2 <= v) p *= 2;\n ll tmp = min(p, k);\n\n if (u <= p) {\n res = ((tmp*(tmp+1)/2 % base) * u) % base;\n res = (res + (o * tmp % base) * u % base + solve(u, v-p, k-p, o+p)) % base;\n }\n else {\n res = ((tmp*(tmp+1)/2 % base) * p) % base;\n res = (res + o * tmp % base * p % base) % base;\n res = (res + solve(u-p, v-p, k-p, o) + solve(p, v-p, k-p, o+p) + solve(u-p, p, k-p, o+p)) % base;\n }\n return res;\n}\n\nint main()\n{\n ll q, a, b, u, v, k;\n ios::sync_with_stdio(0);\n freopen(\"inp.txt\", \"r\", stdin);\n //freopen(\"out.txt\", \"w\", stdout);\n /*FOR(i,1,10) {\n FOR(j,1,10) cout << ((i-1) ^ (j-1)) + 1 << \" \";\n cout << endl;\n }*/\n cin >> q;\n while (q--) {\n cin >> a >> b >> u >> v >> k;\n ll res = (solve(u,v,k) + solve(a-1,b-1,k)) % base;\n res = (res - solve(a-1,v,k) - solve(u,b-1,k) + base*base) % base;\n cout << res << endl;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "007a678424f7ac679f62391efe026a2b", "src_uid": "1ab085026ce43810acf98cc4bf8faf26", "difficulty": 2600.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#define BASE 1000000007;\nusing namespace std;\nmap, __int32> storedvalue;\n__int32 findvalue(__int32 i, __int32 j)\n{\n\t__int32 result;\n\tpair<__int32, __int32> index = make_pair(i, j);\n\tif (storedvalue.count(index))return storedvalue[index];\n\tif (i > j)return findvalue(j,i);\n\telse if (i == 1)result = j;\n\telse if (i == j)result = 1;\n\telse if (j == i + 1 && i % 2 == 1)result = 2;\n\telse if (i == 2 && j % 2 == 0)result = j - 1;\n\telse if (i == 2 && j % 2 == 1)result = j + 1;\n\telse if (j % 4 == 1 || j % 4 == 2)result = 2*((i-1)/2) + findvalue((i-1)%2+1,j);\n\telse if (j % 4 == 3 || j % 4 == 0)result = -2 * ((i - 1) / 2) + findvalue((i - 1) % 2 + 1, j);\n\telse result = 0;\n\tstoredvalue.insert(make_pair(index, result));\n\treturn result;\n}\n\nint main()\n{\n\tint q;\n\tcin >> q;\n\tfor (int i = 0; i < q; i++)\n\t{\n\t\t__int32 x1, y1, x2, y2, K;\n\t\tcin >> x1 >> y1 >> x2 >> y2 >> K;\n\t\tint ans = 0;\n\t\tfor (__int32 j = x1; j <= x2; j++)\n\t\t{\n\t\t\tfor (__int32 k = y1; k <= y2; k++)\n\t\t\t{\n\t\t\t\t__int32 temp = findvalue(j, k);\n\t\t\t\tif (temp > K)continue;\n\t\t\t\telse ans = (ans + temp) % BASE;\n\t\t\t}\n\t\t}\n\t\tcout << ans << endl;\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bf48a06d813514eaa5ae51b3e03cb614", "src_uid": "1ab085026ce43810acf98cc4bf8faf26", "difficulty": 2600.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#define BASE 1000000007;\nusing namespace std;\nmap, __int32> storedvalue;\n__int32 findvalue(__int32 i, __int32 j)\n{\n\t__int32 result;\n\tpair<__int32, __int32> index = make_pair(i, j);\n\tif (storedvalue.count(index))return storedvalue[index];\n\tif (i > j)result = findvalue(j,i);\n\telse if (i == 1)result = j;\n\telse if (i == j)result = 1;\n\telse if (j == i + 1 && i % 2 == 1)result = 2;\n\telse if (i == 2 && j % 2 == 0)result = j - 1;\n\telse if (i == 2 && j % 2 == 1)result = j + 1;\n\telse if (j % 4 == 1 || j % 4 == 2)result = 2 + findvalue(i-2,j);\n\telse if (j % 4 == 3 || j % 4 == 0)result = -2 + findvalue(i - 2, j);\n\telse result = 0;\n\tstoredvalue.insert(make_pair(index, result));\n\treturn result;\n}\n\nint main()\n{\n\tint q;\n\tcin >> q;\n\tfor (int i = 0; i < q; i++)\n\t{\n\t\t__int32 x1, y1, x2, y2, K;\n\t\tcin >> x1 >> y1 >> x2 >> y2 >> K;\n\t\tint ans = 0;\n\t\tfor (__int32 j = x1; j <= x2; j++)\n\t\t{\n\t\t\tfor (__int32 k = y1; k <= y2; k++)\n\t\t\t{\n\t\t\t\t__int32 temp = findvalue(j, k);\n\t\t\t\tif (temp > K)continue;\n\t\t\t\telse ans = (ans + temp) % BASE;\n\t\t\t}\n\t\t}\n\t\tcout << ans << endl;\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1af29897ff995111da7445513fece958", "src_uid": "1ab085026ce43810acf98cc4bf8faf26", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include \n\n#define left nadnlassad\n#define right asdaslknd\n#define y1 kjdajasjdsas\n\n#define pb push_back\n#define mp make_pair\n\n#define f first\n#define s second\n\n#define ll long long\n#define ld long double\n#define ull unsigned ll\n\n#define _hash pair\n#define pii pair\n#define prr pair\n\n#define sqr(x) (x * 1LL * x)\n\n#define vec vector\n#define sz(v) int(v.size())\n#define all(v) v.begin(), v.end()\n#define upper(v, x) (upper_bound(all(v), x) - v.begin())\n#define lower(v, x) (lower_bound(all(v), x) - v.begin())\n#define iter set::iterator\n#define _bits(x) __builtin_popcountll(x)\n\nusing namespace std;\n\nconst int nx[8] = {2, -2, -2, 2, 1, 1, -1, -1};\nconst int ny[8] = {1, 1, -1, -1, 2, -2, -2, 2};\n\nconst ll LINF = (ll) 2e18;\nconst int INF = 1e9 + 7;\n\nconst int N = 2e5 + 100;\nconst int MAXN = 5e7 + 50;\nconst double EPS = 1e-9, PI = 2 * acos(0.0);\npii a[N];\nint t[N];\nint n, m;\nvector all;\nmultiset st;\n\nint main() {\n #define fn \"stones\"\n #ifdef sony\n freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output1.txt\", \"w\", stdout);\n #else\n // freopen(fn\".in\", \"r\", stdin);\n // freopen(fn\".out\", \"w\", stdout);\n #endif // sony\n srand(time(NULL));\n scanf(\"%d%d\", &n, &m);\n for(int i = 1; i <= n; i++) {\n int x;\n scanf(\"%d\", &x);\n all.pb({x, 0});\n }\n int ans = 0;\n for(int i = 1; i <= m; i++) {\n scanf(\"%d%d\", &a[i].s, &a[i].f);\n all.pb(mp(a[i].s - a[i].f, -i));\n all.pb(mp(a[i].s + a[i].f, i));\n }\n sort(all(all));\n for(auto it : all) {\n if(it.s == 0) {\n iter i = st.lower_bound(it.f);\n if(i == st.end())\n continue;\n st.erase(i);\n ans++;\n } else if(it.s < 0) {\n st.insert(a[-it.s].s + a[-it.s].s);\n } else {\n st.erase(st.find(it.f));\n }\n }\n printf(\"%d\", ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "333f67669f35282ff6e9cc852720491b", "src_uid": "04375596477fc65a2093554ff7b7934d", "difficulty": 1900.0} {"lang": "GNU C++11", "source_code": "#include \"bits/stdc++.h\"\n\nusing namespace std;\n\n#define x first\n#define y second\n#define pb push_back\n#define mp make_pair\n#define all(a) (a).begin(), (a).end()\n#define rall(a) (a).rbegin(), (a).rend()\n#define sz(a) int((a).size())\n#define sqr(x) ((x)*(x))\n#define forn(i, n) for (int i = 0; i < int(n); i++)\n#define NAME \"34\"\n#define FREOPEN freopen(NAME\"\", \"r\", stdin); freopen(NAME\".txt\", \"w\", stdout);\n#define Freopen freopen(\"input.txt\", \"r\", stdin); freopen(\"output.txt\", \"w\", stdout);\n\ntypedef unsigned int unt;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef pair pii;\ntypedef pair pll;\ntypedef long double geom;\n\nconst ll MOD = 1e9 + 7;\nconst int INF = 2e9;\nconst ll INF64 = 3e18;\nconst ld EPS = 1e-12;\nconst ld PI = 3.1415926535897932384620;\nconst ll MD = 925262732;\nconst ll T = 634521;\nconst int N = 300100;\nconst int M = 5001;\n\nll n, m, x[N];\npll a[N];\nmultiset < ll > s;\npll d[N];\n\nint main()\n{\n cin >> n >> m;\n int ans = 0;\n forn(i, n)\n {\n scanf(\"%I64d\", &x[i]);\n }\n sort(x, x + n);\n forn(i, m)\n {\n scanf(\"%I64d %I64d\", &a[i].x, &a[i].y);\n d[i].x = a[i].x - a[i].y;\n d[i].y = a[i].x + a[i].y;\n }\n sort(d, d + m);\n int j = 0;\n forn(i, n)\n {\n int xx = x[i];\n while (j < m && d[j].x <= xx)\n {\n s.insert(d[j].y);\n j++;\n }\n multiset < ll > :: iterator it = s.begin();\n while (*it < xx)\n {\n s.erase(it);\n it = s.begin();\n if (it == s.end())\n break;\n }\n it = s.begin();\n if (it != s.end())\n {\n ans++;\n s.erase(it);\n }\n\n\n }\n\n cout << ans;\n return 0;\n}\n\n/*\n\n\n\n*/\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "67288bd4430411793c242015651b508e", "src_uid": "04375596477fc65a2093554ff7b7934d", "difficulty": 1900.0} {"lang": "GNU C++11", "source_code": "#include \n\n#define left nadnlassad\n#define right asdaslknd\n#define y1 kjdajasjdsas\n\n#define pb push_back\n#define mp make_pair\n\n#define f first\n#define s second\n\n#define ll long long\n#define ld long double\n#define ull unsigned ll\n\n#define _hash pair\n#define pii pair\n#define prr pair\n\n#define sqr(x) (x * 1LL * x)\n\n#define vec vector\n#define sz(v) int(v.size())\n#define all(v) v.begin(), v.end()\n#define upper(v, x) (upper_bound(all(v), x) - v.begin())\n#define lower(v, x) (lower_bound(all(v), x) - v.begin())\n#define iter set::iterator\n#define _bits(x) __builtin_popcountll(x)\n\nusing namespace std;\n\nconst int nx[8] = {2, -2, -2, 2, 1, 1, -1, -1};\nconst int ny[8] = {1, 1, -1, -1, 2, -2, -2, 2};\n\nconst ll LINF = (ll) 2e18;\nconst int INF = 1e9 + 7;\n\nconst int N = 2e5 + 100;\nconst int MAXN = 5e7 + 50;\nconst double EPS = 1e-9, PI = 2 * acos(0.0);\npii a[N];\nint t[N];\nint n, m;\n\nint main() {\n #define fn \"stones\"\n #ifdef sony\n freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output1.txt\", \"w\", stdout);\n #else\n // freopen(fn\".in\", \"r\", stdin);\n // freopen(fn\".out\", \"w\", stdout);\n #endif // sony\n srand(time(NULL));\n scanf(\"%d%d\", &n, &m);\n set st;\n for(int i = 1; i <= n; i++) {\n int x;\n scanf(\"%d\", &x);\n st.insert(x);\n }\n int cur_time = 0;\n int ans = 0;\n for(int i = 1; i <= m; i++) {\n scanf(\"%d%d\", &a[i].s, &a[i].f);\n }\n sort(a + 1, a + m + 1);\n for(int i = 1; i <= m; i++) {\n int cur_pos = a[i].s, max_time = a[i].f;\n iter it = st.lower_bound(cur_pos);\n iter it1 = it;\n if(it1 != st.begin())\n it1--;\n if(it != st.end() && abs(*it - cur_pos) < abs(*it1 - cur_pos)){\n if(abs(*it - cur_pos) <= max_time) {\n ans++;\n st.erase(it);\n }\n } else {\n if(abs(*it1 - cur_pos) <= max_time) {\n ans++;\n st.erase(it1);\n }\n }\n }\n printf(\"%d\", ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ad65b67ca8ef68e724447e6ddd02e3d8", "src_uid": "04375596477fc65a2093554ff7b7934d", "difficulty": 1900.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint u[20001];\nint t[20001];\n\nint main() {\n\t//freopen (\"input.txt\", \"r\", stdin);\n\tint m, n;\n\tcin >> n >> m;\n\tint a;\n\tvector > v;\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> a;\n\t\tv.push_back(make_pair(a, 0));\n\t}\n\tint count = 0;\n\tfor (int i = 1; i <= m; i++) {\n\t\tcin >> u[i] >> t[i];\n\t\tv.push_back(make_pair(u[i] - t[i], -i));\n\t\tv.push_back(make_pair(u[i] + t[i], i));\n\t}\n\tsort (v.begin(), v.end());\n\tset > st;\n\tfor (int i = 0; i < v.size(); i++) {\n\t\tint index = v[i].second;\n\t\tif (index < 0) {\n\t\t\tindex = -index;\n\t\t\tst.insert(make_pair(u[index] + t[index], index));\n\t\t}\n\t\telse if (index == 0) {\n\t\t\tif (st.size() > 0) {\n\t\t\t\tcount++;\n\t\t\t\tst.erase(st.begin());\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tst.erase(v[i]);\n\t\t}\n\t}\n\tcout << count << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cf22e249cd478abe5bdba5e230bf1270", "src_uid": "04375596477fc65a2093554ff7b7934d", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\n\ndouble dp[1000005][2];\nint n,l[1000005];\nchar s[1000005];\n\nvoid Calc(int k)\n{\n\tif (s[k]=='0')dp[k][0]=1.0; else \n\tif (s[k]=='1')dp[k][1]=1.0; else \n\t{\tdp[k][0]=0.5; dp[k][1]=0.5;}\n}\n\nint Dfs(int l)\n{\n\tint r=l+1;\n\twhile (s[r]!=')')\n\t{\n\t\tif (s[r]=='(') r=Dfs(r);\n\t\tr++;\n\t}\n\tint L,R,O;\n\tif (r-l<=4)\n\t{\n\t\tCalc(l+1); Calc(r-1); L=l+1; R=r-1; O=l+2;\n\t} else \n\tif (s[l+1]!='(')\n\t{\n\t\tCalc(l+1); L=l+1; R=r-1; O=l+2;\n\t} else \n\t{\n\t\tCalc(r-1); L=r-3; R=r-1; O=r-2;\n\t}\n\tif (s[O]=='&')\n\t\tdp[r][1]=dp[L][1]*dp[R][1],dp[r][0]=1-dp[r][1]; else \n\tif (s[O]=='|')\n\t\tdp[r][0]=dp[L][0]*dp[R][0],dp[r][1]=1-dp[r][0]; else \n\t\tdp[r][0]=dp[L][0]*dp[R][0]+dp[L][1]*dp[R][0],dp[r][1]=1-dp[r][0];\n\treturn r;\n}\n\nint main()\n{\n\tscanf(\"%d\",&n);\n\tscanf(\"%s\",&s);\n\tif (n!=0)Dfs(0); else{ puts(\"YES\");return 0;}\n\tint n=strlen(s)-1;\n\tif (abs(dp[n][0]-dp[n][1])>1e-8||n==0) puts(\"YES\"); else puts(\"NO\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "24358dfd576de9bca45b02ad81763236", "src_uid": "e060d26dc3b9ffb628f2380781d1cbe9", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n\n#define FC0 1\n#define FC1 8\n#define FCQ 6\n\nchar formula[1000003];\n\nint fcEval(char opchar, int fcA, int fcB){\n\tint fcRet = 0;\n\tfor (int apair = 0; apair < 4; apair++){\n\t\tif (((fcA >> apair) & 1) == 1){\n\t\t\tfor (int bpair = 0; bpair < 4; bpair++){\n\t\t\t\tif (((fcB >> bpair) & 1) == 1){\n\t\t\t\t\tint rpair = -1;\n\t\t\t\t\tswitch (opchar){\n\t\t\t\t\t\tcase '&':\n\t\t\t\t\t\t\trpair = apair & bpair;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase '|':\n\t\t\t\t\t\t\trpair = apair | bpair;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase '^':\n\t\t\t\t\t\t\trpair = apair ^ bpair;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tfcRet |= (1 << rpair);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn fcRet;\n}\n\nint fcParse(int start, int& end){\n\tif (formula[start] == '0') { /*printf(\"fc0\");*/ end = start + 1; return FC0; }\n\tif (formula[start] == '1') { /*printf(\"fc1\");*/ end = start + 1; return FC1; }\n\tif (formula[start] == '?') { /*printf(\"fc?\");*/ end = start + 1; return FCQ; }\n\n\tif (formula[start] == '(') {\n\t\t//printf(\"(\");\n\t\tint opi;\n\t\tint fcA = fcParse(start+1, opi);\n\t\tchar opchar = formula[opi];\n\t\t//printf(\" %c \", opchar);\n\t\tint bend;\n\t\tint fcB = fcParse(opi+1, bend);\n\t\tend = bend + 1;\n\t\tint evalue = fcEval(opchar, fcA, fcB);\n\t\t//printf(\" = %d)\", evalue);\n\t\treturn evalue;\n\t}\n\treturn -1;\n\n}\n\nint main(){\n\tint n;\n\tscanf(\"%d\\n\", &n);\n\tfgets(formula, 1000001, stdin);\n\tint waste;\n\tif ((fcParse(0, waste) & 2) != 0){\n\t\tprintf(\"YES\");\n\t} else {\n\t\tprintf(\"NO\");\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "450ea9eebd04d16308e037e232c203f0", "src_uid": "e060d26dc3b9ffb628f2380781d1cbe9", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include\n#include \n#include \nusing namespace std;\n\nint i,j,k,n,l,ans,temp;\nchar c;\nchar expr[2000000];\n\nint gettype(int p, int q)\n{\n int x,left,right;\n if (p==q)\n {\n if (expr[p]=='0') return 0;\n if (expr[p]=='1') return 1;\n if (expr[p]=='?') return 4;\n }\n k=0;\n for (i=p+1; i<=q-1; i++)\n {\n if (expr[i]=='(') k++;\n if (expr[i]==')') k--;\n if (expr[i]=='|'||expr[i]=='&'||expr[i]=='^')\n if (k==0) x=i;\n }\n left=gettype(p+1,x-1);\n right=gettype(x+1,q-1);\n if (left>right)\n {\n temp=left;\n left=right;\n right=temp;\n }\n if (expr[x]=='|')\n {\n if (left==0) return right;\n if (left==1) return 1;\n if (left==2&&right==2) return 2;\n return 3;\n }\n if (expr[x]=='&')\n {\n if (left==0) return 0;\n if (left==1) return right;\n if (left==2&&right==2) return 2;\n return 3; \n }\n if (expr[x]=='^')\n {\n if (left==0||left==2) return right;\n if (left==1)\n if (right==1) return 0; else return right;\n if (left==3) return 3;\n if (left==4) return 2;\n }\n}\n\nmain()\n{\n scanf(\"%d\",&n);\n l=0;\n scanf(\"%c\",&c);\n while (c=='\\n') scanf(\"%c\",&c);\n while (c!='\\n')\n {\n l++;\n expr[l]=c;\n scanf(\"%c\",&c);\n }\n ans=gettype(1,l);\n if (ans>=3) printf(\"YES\\n\"); else printf(\"NO\\n\");\n //system(\"pause\");\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "17c2da696d908e13b2e467515ac44046", "src_uid": "e060d26dc3b9ffb628f2380781d1cbe9", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nint colonyN, type[1000005];\nchar input[3000005], tmpInput[1000005];\n\nint rec(int start){\n\tint depth=0;\n\tint type=0, Type[2], tested=0, startNext, oper;\n\t//0=Says nothing\n\t//1=0/1\n\t//2=Done!\n\t//3=0\n\t//4=1\n\tif(input[start] == '?' && input[start+1] == ')')\n\t\treturn 1;\n\tif(input[start] == '0' && input[start+1] == ')')\n\t\treturn 3;\n\tif(input[start] == '1' && input[start+1] == ')')\n\t\treturn 4;\n\tfor(int i=start; depth >= 0; ++i){\n\t\tif(input[i] == '('){\n\t\t\t++depth;\n\t\t}\n\t\tif(input[i] == ')'){\n\t\t\t--depth;\n\t\t\tif(depth == 0){\n\t\t\t\tif(!tested){\n\t\t\t\t\tType[tested++]=rec(start+1);\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tType[tested++]=rec(startNext);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(depth == 0 && input[i] != ')' && input[i] != ')'){\n\t\t\tif(input[i] == '&')\n\t\t\t\toper=2;\n\t\t\tif(input[i] == '|')\n\t\t\t\toper=1;\n\t\t\tif(input[i] == '^')\n\t\t\t\toper=0;\n\t\t\tstartNext=i+2;\n\t\t}\n\t}\n\tif((Type[0] == 3 || Type[1] == 3) && oper == 2)\n\t\treturn 3;\n\tif((Type[0] == 4 || Type[1] == 4) && oper == 1)\n\t\treturn 4;\n\tif(Type[0]+Type[1] == 7){\n\t\tif(oper == 2)\n\t\t\treturn 3;\n\t\treturn 4;\n\t}\n\tif(Type[0] == 4 && Type[1] == 4){\n\t\tif(oper == 0)\n\t\t\treturn 3;\n\t\treturn 4;\n\t}\n\tif(Type[0] == 3 && Type[1] == 3){\n\t\treturn 3;\n\t}\n\tif(Type[0] == 2 || Type[1] == 2)\n\t\treturn 2;\n\tif(oper && (Type[0] == 1 || Type[1] == 1))\n\t\treturn 2;\n\tif(oper == 1)\n\t\treturn 0;\n\tif(Type[0] == Type[1])\n\t\treturn 0;\n\treturn 1;\n}\n\nint main()\n{\n\tscanf(\"%d\", &colonyN);\n\tscanf(\"%s\", tmpInput);\n\tif(!tmpInput[0]){\n\t\tprintf(\"NO\");\n\t\treturn 0;\n\t}\n\tint L=0;\n\tfor(int i=0; tmpInput[i]; ++i){\n\t\tif(tmpInput[i] == '?'){\n\t\t\tinput[L++]='(';\n\t\t\tinput[L++]='?';\n\t\t\tinput[L++]=')';\n\t\t}\n\t\telse if(tmpInput[i] == '0'){\n\t\t\tinput[L++]='(';\n\t\t\tinput[L++]='0';\n\t\t\tinput[L++]=')';\n\t\t}\n\t\telse if(tmpInput[i] == '1'){\n\t\t\tinput[L++]='(';\n\t\t\tinput[L++]='1';\n\t\t\tinput[L++]=')';\n\t\t}\n\t\telse{\n\t\t\tinput[L++]=tmpInput[i];\n\t\t}\n\t}\n\tint ans;\n\tif(input[0] == '(')\n\t\tans=rec(1);\n\telse{\n\t\tint i;\n\t\tfor(i=0; input[i]; ++i);\n\t\tinput[i]=')';\n\t\tinput[i+1]=0;\n\t\tans=rec(0);\n\t}\n\tif(ans == 1 || ans == 2)\n\t\tprintf(\"YES\");\n\telse\n\t\tprintf(\"NO\");\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "aa3bbaba49991d4991d4ef55e4a45727", "src_uid": "e060d26dc3b9ffb628f2380781d1cbe9", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "#include\n#include\nusing namespace std;\nconst int N=3e3+10;\nint tot,n,m,si[N],a[N],b[N],head[N],nex[N<<1],to[N<<1];\nvoid add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}\npairdp[N][N];\nvoid dfs(int u,int p)\n{\n si[u]=1;\n if(b[u]>0) dp[u][1]={1,b[u]};\n else dp[u][1]={0,b[u]};\n bool flag=true;\n for(int i=head[u];i;i=nex[i])\n {\n int v=to[i];if(v==p) continue;\n dfs(v,u);\n for(int j=si[u];j>=1;j--)\n {\n for(int k=1;k<=si[v];k++)\n {\n if(flag)\n {\n //cout<0?-1:0)+(dp[v][k].second+b[u]>0&&dp[v][k].second<=0),dp[v][k].second+b[u]};\n dp[u][k+j]=max(dp[u][k+j],{dp[v][k].first+(b[u]>0),b[u]});\n }\n else\n {\n dp[u][j+k]=max(dp[u][j+k],{dp[u][j].first+dp[v][k].first,dp[u][j].second});\n dp[u][j+k]=max(dp[u][j+k],{dp[u][j].first+dp[v][k].first+(dp[u][j].second>0&&dp[v][k].second>0?-1:0)+(dp[u][j].second+dp[v][k].second<=0&&(dp[u][j].second>0||dp[v][k].second>0)?-1:0),dp[u][j].second+dp[v][k].second});\n }\n }\n flag=false;\n }\n si[u]+=si[v];\n }\n}\nint main()\n{\n int t;scanf(\"%d\",&t);\n while(t--)\n {\n tot=0;memset(head,0,sizeof(head));\n scanf(\"%d%d\",&n,&m);\n for(int i=1;i<=n;i++) scanf(\"%d\",&a[i]);\n for(int i=1;i<=n;i++) scanf(\"%d\",&b[i]),b[i]-=a[i];\n for(int i=1;i\nusing namespace std;\ntypedef long long ll;\nconst int inf=0x3f3f3f3f;\nconst ll linf=0x3f3f3f3f3f3f3f3f;\nconst int maxn=3e3+10;\nconst ll mod=1e9+7;\nint n,m,ta[maxn],tb[maxn],sz[maxn];\nvectorv[maxn];\nstruct DP\n{\n int a=0;\n ll b=-linf;\n}dp[maxn][maxn];\nbool operator<(DP a,DP b)\n{\n if(a.a!=b.a)return a.a0),0};\n//\n// cout<0));\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "67c74d096e69314f78305d0a72aa5ff6", "src_uid": "d2d1d8c8532b652f172e87a151adae4f", "difficulty": 2500.0} {"lang": "GNU C++17", "source_code": "// Your day breaks, your mind aches\n// You find that all the words of kindness linger on\n// When she no longer needs you\n//#pragma GCC optimize (\"Ofast,unroll-loops\")\n//#pragma GCC target (\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n#include \n#include \nusing namespace std;\n#define fastio ios::sync_with_stdio(0);cin.tie(0)\n#define debug(x) cout << #x << \" = \" << x << endl\n#define For(i,a,b) for (int i = a; i < b; i++)\n#define roF(i,a,b) for (int i = a; i >= b; i--)\n#define pb push_back\n#define mp make_pair\n#define ff first\n#define ss second\n#define all(v) (v).begin(),(v).end()\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef unsigned long long ull;\ntypedef pair ii;\ntypedef vector vi;\ntypedef vector vii;\n\nconst int N = 3e3 + 5;\nconst ll INF = 1e18;\nconst ld EPS = 10e-9;\n\nmt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());\nll random(ll a, ll b) { return uniform_int_distribution (a, b) (rng); }\n\nint n, m, b[N], w[N], sz[N];\nvi adj[N];\nbool used[N];\nii dp[N][N], temp[N];\n/*\ndp[i][j] : (num, sum) Par obtenido al dividir el subarbol con raiz en i en j aldeas\nnum : max aldeas (distintas de i) donde #wasps > #bees\nsum : max (#wasps - #bees) en el subarbol con raiz en i\n*/\n\nvoid init() {\n\tFor(i,0,n) {\n\t\tused[i] = false;\n\t\tadj[i].clear();\n\t}\n}\n\nvoid DFS(int u) {\n\tused[u] = true;\n\tsz[u] = 1;\n\tdp[u][1] = mp(0, w[u] - b[u]); // (Aun no se procesan aldeas debajo, diferencia en el nodo)\n\tfor (int v : adj[u]) {\n\t\tif (not used[v]) {\n\t\t\tDFS(v);\n\t\t\tint s = sz[u] + s[v] + 1;\n\t\t\tFor(i,0,s) temp[i] = mp(-1, 0LL);\n\t\t\tFor(x,1,sz[u]+1) {\n\t\t\t\tFor(y,1,sz[v]+1) {\n\t\t\t\t\tint z = x + y - 1;\n\t\t\t\t\ttemp[z] = max(temp[z], {dp[u][x].ff + dp[v][y], dp[u][x].ss + dp[v][y].ss});\n\t\t\t\t\tz = x + y;\n\t\t\t\t\ttemp[z] = max(temp[z], {dp[u][x].ff + (dp[v][y].ff + (dp[v][y].ss > 0 ? 1 : 0)), dp[u][x].ss});\n\t\t\t\t}\n\t\t\t}\n\t\t\tFor(i,0,s) dp[u][i] = temp[i];\n\t\t\tsz[u] += sz[v];\n\t\t}\n\t}\n}\n\nvoid solve() {\n\tcin >> n >> m;\n\tinit();\n\tFor(i,0,n) cin >> b[i];\n\tFor(i,0,n) cin >> w[i];\n\tFor(i,0,n-1) {\n\t\tint u, v;\n\t\tcin >> u >> v;\n\t\tu--;\n\t\tv--;\n\t\tadj[u].pb(v);\n\t\tadj[v].pb(u);\n\t}\n\tDFS(0);\n\tint ans = dp[0][m].ff + (dp[0][m].ss > 0);\n\tcout << ans << endl;\n}\n\nint main() {\n\tfastio;\n\tint t;\n\tcin >> t;\n\twhile (t--) solve();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "4d32e207df866276c3dcd78bc87e27d9", "src_uid": "d2d1d8c8532b652f172e87a151adae4f", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n\nconst int maxn=3005;\nstruct node{\n long long r,l;\n node(long long r,long long l):r(r),l(l){}\n node():r(),l(){}\n bool operator<(const node& o) const{\n if(r==o.r) return l E[maxn];\nlong long siz[maxn],w[maxn],b[maxn];\nint n,m;\n\nvoid dfs(int x,int fa){\n dp[x][1]=node(0,w[x]-b[x]);\n if(dp[x][1].l>0) dp[x][1].r++;\n siz[x]=1;\n for(auto i:E[x]){\n if(i==fa) continue;\n dfs(i,x);\n for(int j=1;j<=m;j++) g[j]=node(-1,0);\n for(int j=1;j<=siz[x];j++){\n for(int k=1;k<=siz[i];k++){\n node t1,t2;\n t1=t2=dp[i][k];\n if(dp[x][j].l>0 && t1.l>0) t1.r--;\n if(dp[x][j].l+t1.l<=0 && (dp[x][j].l>0 || t1.l>0)) t1.r--;\n t2.l=0;\n g[j+k-1]=max(g[j+k-1],dp[x][j]+t1);\n g[j+k]=max(g[j+k],dp[x][j]+t2);\n }\n }\n siz[x]+=siz[i];\n for(int j=1;j<=siz[x];j++) dp[x][j]=g[j];\n }\n}\n\nvoid getdata(){\n cout<>T;\n while(T--){\n cin>>n>>m;\n for(int i=1;i<=n;i++){\n E[i].clear();\n for(int j=1;j<=m;j++)\n dp[i][j]=node(-1,0);\n }\n for(int i=1;i<=n;i++) cin>>b[i];\n for(int i=1;i<=n;i++) cin>>w[i];\n for(int i=1;i>x>>y;\n E[x].push_back(y);\n E[y].push_back(x);\n }\n dfs(1,0);\n if(T==19) getdata();\n cout<\n\n#define MOD 1000000007\n\nusing namespace std;\n\nint expo(int a, int b) {\n if(!b) return 1;\n if(b & 1) return 1LL * a * expo(1LL * a * a % MOD, b >> 1) % MOD;\n return expo(1LL * a * a % MOD, b >> 1);\n}\n\nint inv_mod(int x) { return expo(x, MOD - 2);}\n\nint i2 = inv_mod(2), i10 = inv_mod(10);\n\nstruct number {\n int v, p;\n number(int v, int p) : v(v), p(p) {}\n};\n\nnumber concat(number a, number b) {\n return number((1LL * a.v * b.p + b.v) % MOD, 1LL * a.p * b.p % MOD);\n}\n\nint remainder(string& str, int mod) {\n int rem = 0;\n for(char c : str) {\n rem = (10LL * rem + (c - '0')) % mod;\n }\n return rem;\n}\n\nnumber parse(string& str);\n\nnumber c(int l, int r, int k, int p10eL, int rem_l, int rem_r) {\n int prod = expo(p10eL, (rem_r - 1 + MOD - 1) % (MOD - 1));\n int FR, FL;\n\n if(k == 1) {\n FR = 1LL * r * (r + 1) % MOD * i2 % MOD;\n FL = 1LL * l * (l - 1 + MOD) % MOD * i2 % MOD;\n } else {\n int kr = expo(k, rem_r), kl1 = expo(k, (rem_l - 1 + MOD - 1) % (MOD - 1)), ik1 = inv_mod((k - 1 + MOD) % MOD);\n FR = (1LL * r * kr % MOD * ik1 % MOD\n - 1LL * kr * ik1 % MOD * ik1 % MOD\n + MOD) % MOD;\n\n FL = (1LL * (l - 1 + MOD) * kl1 % MOD * ik1 % MOD\n - 1LL * kl1 * ik1 % MOD * ik1 % MOD\n + MOD) % MOD;\n }\n\n return number(1LL * prod * (FR - FL + MOD) % MOD, expo(p10eL, (rem_r - rem_l + 1 + MOD) % MOD));\n}\n\nnumber C(number l, number r, string& str_l, string& str_r) {\n if(str_l.size() == str_r.size()) {\n return c(l.v, r.v, inv_mod(l.p), l.p, remainder(str_l, MOD - 1), remainder(str_r, MOD - 1));\n } else {\n int mid = 0, mid_rem = 0, rem_l = remainder(str_l, MOD - 1), rem_r = remainder(str_r, MOD - 1);\n for(char c : str_l) {\n mid = (10LL * mid + 9) % MOD;\n mid_rem = (10LL * mid_rem + 9) % (MOD - 1);\n }\n\n int k = inv_mod(l.p), p10eL = l.p;\n number ret = c(l.v, mid, k, p10eL, rem_l, mid_rem);\n for(int i = str_l.size() + 1; i < str_r.size(); i++) {\n k = 1LL * k * i10 % MOD;\n p10eL = 10LL * p10eL % MOD;\n\n l.v = (mid + 1) % MOD;\n rem_l = (mid_rem + 1) % (MOD - 1);\n\n mid = (10LL * mid + 9) % MOD;\n mid_rem = (10LL * mid_rem + 9) % (MOD - 1);\n\n ret = concat(ret, c(l.v, mid, k, p10eL, rem_l, mid_rem));\n }\n\n k = 1LL * k * i10 % MOD;\n p10eL = 10LL * p10eL % MOD;\n\n l.v = (mid + 1) % MOD;\n rem_l = (mid_rem + 1) % (MOD - 1);\n\n ret = concat(ret, c(l.v, r.v, k, p10eL, rem_l, rem_r));\n return ret;\n }\n}\n\nnumber rep(number x, number y, string& str_x) {\n if(y.p == 1) { /// 10^L % MOD == 1\n return number(1LL * x.v * y.v % MOD, 1);\n } else {\n int rem = remainder(str_x, MOD - 1);\n int new_pot = expo(y.p, rem);\n return number(1LL * y.v * ((new_pot - 1 + MOD) % MOD) % MOD * inv_mod((y.p - 1 + MOD) % MOD) % MOD, new_pot);\n }\n}\n\nnumber parse_term(string& str) {\n number a1(0, 1), a2(0, 1);\n int which = 0; /// 0: x | 1: x-y | 2: x(y)\n string t1, t2;\n\n for(char c : str) {\n if(which == 0) {\n if(c == '-') which = 1;\n else if(c == '(') which = 2;\n else {\n a1 = concat(a1, number(c - '0', 10));\n t1 += c;\n }\n } else if(which == 1) {\n a2 = concat(a2, number(c - '0', 10));\n t2 += c;\n } else {\n t2 += c;\n }\n }\n\n if(which == 0) return a1;\n else if(which == 1) return C(a1, a2, t1, t2);\n else {\n t2.pop_back(); /// last bracket\n a2 = parse(t2);\n return rep(a1, a2, t1);\n }\n}\n\n/// expression\nnumber parse(string& str) {\n string tmp;\n number ret(0, 1);\n int brackets = 0;\n\n for(char c : str) {\n if(c == '+' && brackets == 0) {\n ret = concat(ret, parse_term(tmp));\n tmp = \"\";\n } else {\n tmp += c;\n if(c == '(') brackets++;\n if(c == ')') brackets--;\n }\n\n }\n\n ret = concat(ret, parse_term(tmp));\n return ret;\n}\n\n\nchar s[100010];\nstring str;\n\nint main() {\n scanf(\"%s\", s); str = s;\n number ans = parse(str);\n printf(\"%d\\n\", ans.v);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "72cea35f31e718b66419c304228df6aa", "src_uid": "0617f1ffa520d5b96232a4cfd9a15d0c", "difficulty": 3400.0} {"lang": "GNU C++14", "source_code": "#include \n#define fst first\n#define snd second\n#define fore(i,a,b) for(int i=a,ThxDem=b;i ii;\n\nconst int MAXN=100010;\nll MOD=1e9+7,pw[MAXN];\nint jsum[MAXN],jmin[MAXN],jpar[MAXN],topar[MAXN];\nstring s;\n\nll fpow(ll base, ll exp) {\n\tll result = 1;\n\twhile(exp){\n\t\tif(exp & 1) result = (result*base) % MOD;\n\t\texp >>= 1;\n\t\tbase = (base*base) % MOD;\n\t}\n\treturn result;\n}\n\nll sum(ll x, ll y){return (x+y)%MOD;}\nll sub(ll x, ll y){return (x-y+MOD)%MOD;}\nll mul(ll x, ll y){return x*y%MOD;}\nll divv(ll x, ll y){return x*fpow(y,MOD-2)%MOD;}\n\nstruct num{\n\tll len,val;\t//Stored as {10^len, val%MOD}\n\tnum(ll len, ll val):len(len),val(val){}\n\tnum(){}\n\tnum concat(num x){return num(mul(len,x.len),sum(mul(val,x.len),x.val));}\n};\n\nnum ran[MAXN];\n\n\nvoid preproc(){\n\tfore(i,0,SZ(s)) jsum[i]=jmin[i]=jpar[i]=topar[i]=SZ(s);\n\tint dep=0;\n\tstack sum,mn,open; stack par;\n\tfor(int i=SZ(s)-1;i>=0;i--){\n\t\tif(s[i]==')') par.push(i), dep++;\n\t\tif(s[i]=='('){\n\t\t\twhile(SZ(sum)&&sum.top().snd==dep) sum.pop();\n\t\t\twhile(SZ(mn)&&mn.top().snd==dep) mn.pop();\n\t\t\ttopar[i]=par.top(); par.pop(); dep--;\n\t\t\topen.push({i,dep});\n\t\t}\n\t\tif(SZ(open)&&open.top().snd==dep) jpar[i]=open.top().fst;\n\t\tif(SZ(sum)&&sum.top().snd==dep) jsum[i]=sum.top().fst;\n\t\tif(SZ(mn)&&mn.top().snd==dep) jmin[i]=mn.top().fst;\n\t\tif(s[i]=='+') sum.push({i,dep});\n\t\tif(s[i]=='-') mn.push({i,dep});\n\t}\n}\n\nnum getnum(int l, int r){\t// generates the number in this range\n\tnum ans(pw[r-l+1],0);\n\tfore(i,l,r+1) ans.val=sum(mul(ans.val,10),s[i]-'0');\n\treturn ans;\n}\n\nnum range(num x, num y){\t// x(x+1)....(y-1)(y) -> len(x)=len(y) \n\tll rl1=sum(sub(y.val,x.val),1);\n\tll rl2=sum(sub(y.val,x.val),2);\n\tnum ans(fpow(x.len,rl1),0);\n\t\n\tll v=sub(fpow(x.len,rl1),1);\n\tv=mul(sum(y.val,1),v);\n\tv=divv(v,sub(x.len,1));\n\t\n\tll v2=mul(rl1,fpow(x.len,rl2));\n\tll v3=mul(rl2,fpow(x.len,rl1));\n\tv2=divv(sum(sub(v2,v3),1),fpow(sub(x.len,1),2));\n\t\n\t\n\tv=sub(v,v2);\n\tans.val=v;\n\treturn ans;\n}\n\n\nnum get_ran(int l1, int r1, int l2, int r2){\n\tint lle=r1-l1+1, lri=r2-l2+1;\n\tnum x=getnum(l1,r1),y=getnum(l2,r2);\n\tif(lle==lri) return range(x,y);\n\tnum fir(pw[lle],sub(pw[lle],1));\t//999... lle times\n\tnum sec(pw[lri],pw[lri-1]);\t\t\t\t\t//10^lri\n\n\n\tnum ans=range(x,fir);\t//first part\n\tnum lst=range(sec,y);\t//last part\n\n\tfore(i,lle+1,lri) ans=ans.concat(ran[i]);\t//mid parts\n\tans=ans.concat(lst);\n\n\treturn ans;\n}\n\n\n\nnum copy(num x, num y){\t// concat x times number y\n\tnum ans(fpow(y.len,x.val),0);\n\tif(y.len%MOD==1) ans.val=x.val;\n\telse ans.val=divv(sub(fpow(y.len,x.val),1),sub(y.len,1));\n\tans.val=mul(ans.val,y.val);\n\treturn ans;\n}\n\nnum solve(int l, int r){\n\tif(l>r) return num(1,0);\n\tif(jsum[l]<=r){\t//split in +\n\t\tnum lef=solve(l,jsum[l]-1), rig=solve(jsum[l]+1,r);\n\t\treturn lef.concat(rig);\n\t}\n\tif(jmin[l]<=r){\t//split in -\n\t\tnum lef=solve(l,jmin[l]-1), rig=solve(jmin[l]+1,r);\n\t\treturn get_ran(l,jmin[l]-1,jmin[l]+1,r);\n\t}\n\tif(jpar[l]<=r){\t//split in (\n\t\tnum lef=solve(l,jpar[l]-1), rig=solve(jpar[l]+1,r-1);\n\t\treturn copy(lef,rig);\n\t}\n\treturn getnum(l,r); // I'm in number\n}\n\nint main(){FIN;\n\tpw[0]=1; fore(i,1,MAXN) pw[i]=mul(10,pw[i-1]);\n\tcin>>s;\n\tfore(i,2,SZ(s)+1){\n\t\tnum l(pw[i],pw[i-1]);\n\t\tnum r(pw[i],sub(pw[i],1));\n\t\tran[i]=range(l,r);\n\t}\n\tpreproc();\n\tnum ans=solve(0,SZ(s)-1);\n\tcout << ans.val << \"\\n\";\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5893ee469da373860745cfbdba2b1a96", "src_uid": "0617f1ffa520d5b96232a4cfd9a15d0c", "difficulty": 3400.0} {"lang": "GNU C++14", "source_code": "#include \n\n#define FOR(i,a,b) for (int i = (int)(a); i < (int)(b); ++i)\n#define REP(i,n) FOR(i,0,n)\n#define pb push_back\n#define x first\n#define y second\n\n#define TRACE(x) cerr << #x << \" = \" << x << endl\n#define _ << \" _ \" <<\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair pii;\n\nconst int Mod = 1e9+7;\nint add(int x, int y){x += y; if (x >= Mod) return x-Mod; return x;}\nint mul(int x, int y){return (int)((ll)x*y%Mod);}\nint sub(int x, int y){x -= y; if (x < 0) return x+Mod; return x;}\nint pot(int x, int y){\n int r = 1;\n while (y){\n if (y&1) r = mul(r, x);\n x = mul(x, x), y >>= 1;\n } return r;\n}\nint inv(int x){assert(x != 0); return pot(x, Mod-2);}\n\nconst int Mod2 = 1e9+6;\nint add2(int x, int y){x += y; if (x >= Mod2) return x-Mod2; return x;}\nint mul2(int x, int y){return (int)((ll)x*y%Mod2);}\nint sub2(int x, int y){x -= y; if (x < 0) return x+Mod2; return x;}\n\npii concat(pii a, pii b){\n return {add(mul(a.x, pot(10, b.y)), b.x), add2(a.y, b.y)};\n}\n\npii cast(string s){\n pii sol = {0, 0};\n for (auto t : s)\n sol = {add(mul(sol.x, 10), t-'0'), add2(sol.y, 1)};\n return sol;\n}\n\npii concatself(pii a, int b){\n if (b == 0) return {0, 0};\n pii sol = a;\n REP(i,b-1) sol = concat(sol, a);\n return sol;\n}\n\nvoid inc(string &s){\n int pos = (int)s.size()-1;\n while (s[pos] == '9')\n s[pos--] = '0';\n if (pos == -1) s.insert(s.begin(), '1');\n else ++s[pos];\n}\n\npii kojikurac2(string &a, string &b){\n if (a.size() == b.size()){\n int len = (int)a.size();\n\n vector delta(len);\n REP(i,len) delta[i] = b[i]-'0';\n REP(i,len) delta[i] -= a[i]-'0';\n for (int i = len-1; i >= 0; --i)\n if (delta[i] < 0)\n\tdelta[i] += 10, --delta[i-1];\n\n // explen = len * delta % mod2\n\n int del2 = 0;\n int del1 = 0;\n for (auto t : delta)\n del2 = add2(mul2(del2, 10), t),\n\tdel1 = add(mul(del1, 10), t);\n int explen = mul2(del2, len);\n\n // expmod = neka suma - neka druga suma\n int lambda = pot(10, del2);\n\n int mod1 = 0;\n int mod2 = 0;\n int bb = 0;\n for (auto t : b)\n bb = add(mul(bb, 10), t-'0');\n\n if (lambda == 1) mod1 = mul(bb, add(del1, 1));\n else mod1 = mul(bb, mul(sub(pot(lambda, add2(del2, 1)), 1), inv(sub(lambda, 1))));\n\n if (lambda == 1) mod2 = mul(mul(del1, add(del1, 1)), inv(2));\n else {\n int tmp = inv(sub(1, lambda));\n tmp = mul(mul(tmp, lambda), tmp);\n mod2 = sub(sub(tmp, mul(tmp, pot(lambda, add2(0, del2)))), mul(del1, mul(pot(lambda, add2(del2, 1)), inv(sub(1, lambda)))));\n }\n\n int expmod = sub(mod1, mod2);\n \n return {expmod, explen};\n } else {\n\n string aa(a.size(), '9');\n string bb = '1' + string(a.size(), '0');\n return concat(kojikurac2(a, aa), kojikurac2(bb, b));\n \n }\n}\n\npii kojikurac(string &a, string &b){\n return kojikurac2(a, b);\n pii sol = cast(a);\n while (a != b){\n inc(a);\n sol = concat(sol, cast(a));\n } return sol;\n}\n\nstring s;\nint pos = 0;\n\nstring number(){\n string sol;\n while (s[pos] >= '0' && s[pos] <= '9')\n sol.pb(s[pos++]);\n return sol;\n}\n\npii expression();\n\npii term(){\n string tmp = number();\n if (s[pos] == '-'){\n ++pos;\n string tmp2 = number();\n return kojikurac(tmp, tmp2);\n } else if (s[pos] == '('){\n ++pos;\n pii tmp2 = expression();\n ++pos;\n pii sol = {0, 0};\n for (auto t : tmp){\n sol = concat(concatself(sol, 10), concatself(tmp2, t-'0'));\n } return sol;\n } else {\n return cast(tmp);\n }\n}\n\npii expression(){\n pii sol = {0, 0};\n while (true){\n sol = concat(sol, term());\n if (s[pos] != '+') break;\n ++pos;\n }\n return sol;\n}\n\nint main(){\n ios_base::sync_with_stdio(false);\n\n cin >> s;\n s.pb('#');\n pii sol = expression();\n cout << sol.x << endl;\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "28de8a43a80643a81568a0248172f6bb", "src_uid": "0617f1ffa520d5b96232a4cfd9a15d0c", "difficulty": 3400.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int N = 1e5 + 7;\nconst int MOD = 1e9 + 7;\nconst int DEBUG = true;\n\ntypedef pair EXP_VAL;\n\n#define plus PLUS\n#define minus MINUS\n\nvector plus[N], minus[N];\nint power10[N][2], ones[N];\nint match[N];\nchar s[N];\nint n;\n\nEXP_VAL pad[N][10], all[N];\n\nint power(int a, int b, int mod = MOD) {\n\tint ret = 1;\n\tfor (; b; b >>= 1) {\n\t\tif (b & 1) {\n\t\t\tret = 1LL * ret * a % mod;\n\t\t}\n\t\ta = 1LL * a * a % mod;\n\t}\n\treturn ret;\n}\n\nEXP_VAL concat(EXP_VAL a, EXP_VAL b) {\n\treturn {(1LL * a.first * b.second % MOD + b.first) % MOD,\n\t\t1LL * a.second * b.second % MOD};\n}\n\nEXP_VAL parse_exp(int dep, int l, int r);\n\nint parse_number(int l, int r, int mod) {\n\tif (DEBUG) cout << \"parse number \" << string(s + l, s + r + 1) << endl;\n\tint ret = 0;\n\tfor (int i = l; i <= r; i++) {\n\t\tret = (ret * 10LL + s[i] - '0') % mod;\n\t}\n\treturn ret;\n}\n\nint sum(int a, int b) {\n\t// return a^0 + ... a^(b-1) % MOD\n\tint upper = power(a, b, MOD) + MOD - 1;\n\tint lower = a + MOD - 1;\n\treturn 1LL * upper % MOD * power(lower % MOD, MOD - 2, MOD) % MOD;\n}\n\nEXP_VAL brute_force(int x) {\n\tEXP_VAL ret = {0, 1};\n\tfor (int i = 1; i <= x; i++) {\n\t\tint p = 1, t = i;\n\t\twhile (t) {\n\t\t\t(p *= 10) %= MOD;\n\t\t\tt /= 10;\n\t\t}\n\t\tret = concat(ret, {i, p});\n\t}\n\treturn ret;\n}\n\nEXP_VAL get_pad(int pre, int m) {\n\tif (pre == 0) return {0, power10[m][0]};\n\tif (pad[pre][m].first != -1) return pad[pre][m];\n\tEXP_VAL &ret = pad[pre][m];\n\tret = {0, 1};\n\tauto v = get_pad(pre - 1, m);\n\tint s = sum(power10[m][0], power10[pre - 1][1]);\n\tfor (int i = 0; i < 10; i++) {\n\t\tauto vv = v;\n\t\tvv.first += 1LL * i * power10[pre - 1][0] % MOD * s % MOD;\n\t\tvv.first %= MOD;\n\t\tret = concat(ret, vv);\n\t}\n\treturn ret;\n}\n\nEXP_VAL get_pad(int pre, int m, int h) {\n\tif (pre == 0) return {h, power10[m][0]};\n\tauto v = get_pad(pre, m);\n\tv.first += 1LL * h * sum(power10[m][0], power10[pre][1]) % MOD;\n\tv.first %= MOD;\n\treturn v;\n}\n\nEXP_VAL get_all(int i) {\n\tif (i == 0) return {0, 1};\n\tif (all[i].first != -1) return all[i];\n\tEXP_VAL &ret = all[i];\n\tret = get_all(i - 1);\n\tfor (int h = 1; h <= 9; h++) {\n\t\tauto v = get_pad(i - 1, i, 1LL * h * power10[i - 1][0] % MOD);\n\t\tret = concat(ret, v);\n\t}\n\treturn ret;\n}\n\nEXP_VAL calc(string s, int op = 0) {\n\tif (DEBUG) cout << \"parse calc \" << s << \" op = \" << op << endl;\n\tstatic int a[N];\n\tint m = s.size();\n\tfor (int i = 0; i < m; i++) {\n\t\ta[i] = s[m - i - 1] - '0';\n\t}\n\tif (s == \"0\") op = 0;\n\tif (op) {\n\t\ta[0]--;\n\t\tfor (int i = 0; i < m; i++) {\n\t\t\tif (a[i] < 0) {\n\t\t\t\ta[i] += 10;\n\t\t\t\ta[i + 1]--;\n\t\t\t}\n\t\t}\n\t\twhile (m > 1 && a[m - 1] == 0) m--;\n\t}\n\tEXP_VAL ret = {0, 1};\n\tint high = 0;\n\tfor (int i = m - 1; i >= 0; i--) {\n\t\tfor (int j = 0; j < a[i]; j++) {\n\t\t\tif (j == 0 && i == m - 1) {\n\t\t\t\tret = concat(ret, get_all(i));\n\t\t\t} else {\n\t\t\t\tauto v = get_pad(i, m, (high + 1LL * power10[i][0] * j % MOD) % MOD);\n\t\t\t\tret = concat(ret, v);\n\t\t\t}\n\t\t}\n\t\thigh += 1LL * power10[i][0] * a[i] % MOD;\n\t\thigh %= MOD;\n\t}\n\tret = concat(ret, {high, power10[m][0]});\n\tif (DEBUG) cout << \"result = \" << ret.first << \" \" << ret.second << endl;\n\treturn ret;\n}\n\nEXP_VAL parse_term(int dep, int l, int r) {\n\tif (DEBUG) cout << \"parse term \" << string(s + l, s + r + 1) << endl;\n\tif (s[r] == ')') {\n\t\tint p = match[r];\n\t\tauto e = parse_exp(dep + 1, p + 1, r - 1);\n\t\tint number = parse_number(l, p - 1, MOD - 1);\n\t\treturn {1LL * e.first * sum(e.second, number) % MOD, power(e.second, number)};\n\t} else {\n\t\tint i = upper_bound(minus[dep].begin(), minus[dep].end(), r) - minus[dep].begin() - 1;\n\t\tif (i < 0 || minus[dep][i] < l) return {parse_number(l, r, MOD), power10[r - l + 1][0]};\n\t\tint p = minus[dep][i];\n\t\tauto eval_l = calc(string(s + l, s + p), 1);\n\t\tauto eval_r = calc(string(s + p + 1, s + r + 1));\n\t\tint second = 1LL * eval_r.second * power(eval_l.second, MOD - 2) % MOD;\n\t\tint first = eval_r.first - 1LL * eval_l.first * second % MOD;\n\t\tif (first < 0) first += MOD;\n\t\treturn {first, second};\n\t}\n}\n\nEXP_VAL parse_exp(int dep, int l, int r) {\n\tif (DEBUG) cout << \"parse exp \" << string(s + l, s + r + 1) << endl;\n\t// found plus;\n\tint i = upper_bound(plus[dep].begin(), plus[dep].end(), r) - plus[dep].begin() - 1;\n\tif (i < 0 || plus[dep][i] < l) return parse_term(dep, l, r);\n\tint p = plus[dep][i];\n\tauto a = parse_exp(dep, l, p - 1), b = parse_term(dep, p + 1, r);\n\treturn concat(a, b);\n}\n\nvoid prepare() {\n\tmemset(pad, -1, sizeof(pad));\n\tmemset(all, -1, sizeof(all));\n\tpower10[0][0] = power10[0][1] = 1;\n\tones[0] = 0;\n\tfor (int i = 0; i < n; i++) {\n\t\tpower10[i + 1][0] = power10[i][0] * 10LL % MOD;\n\t\tpower10[i + 1][1] = power10[i][1] * 10LL % (MOD - 1);\n\t\tones[i + 1] = (ones[i] * 10LL + 1) % MOD;\n\t}\n}\n\nint main() {\n\tscanf(\"%s\", s);\n\tn = strlen(s);\n\tprepare();\n\tvector stack;\n\tfor (int i = 0, cur = 0; i < n; i++) {\n\t\tswitch (s[i]) {\n\t\tcase '(' : cur++; stack.push_back(i); break;\n\t\tcase ')' : cur--; match[stack.back()] = i, match[i] = stack.back(); stack.pop_back(); break;\n\t\tcase '+' : plus[cur].push_back(i); break;\n\t\tcase '-' : minus[cur].push_back(i); break;\n\t\t}\n\t}\n\tcout << parse_exp(0, 0, n - 1).first << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "67edcdd103f7697beb20afa9b9699c56", "src_uid": "0617f1ffa520d5b96232a4cfd9a15d0c", "difficulty": 3400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define sqr(_) ((_)*(_))\n\ntypedef pair Pii;\ntypedef pair Ppp;\n#define x first\n#define y second\n#define mp make_pair\n#define pb push_back\n\ntypedef long long LL;\n\nconst int MAXN = (int)2e5 + 10, INF = (int)2e9;\n\nstruct Graph\n{\n\tint id, next, dis;\n}g[MAXN * 4];\nPpp e[MAXN];\nint n, m, st[MAXN], dis[MAXN], f[MAXN];\nint head, tail, que[MAXN * 100];\nbool ins[MAXN];\n\nvoid init()\n{\n\tscanf(\"%d%d\", &n, &m);\n\tfor (int i = 1; i <= m; ++i)\n\t{\n\t\tint a, b, c, d;\n\t\tscanf(\"%d%d%d%d\", &a, &b, &c, &d);\n\t\te[i] = mp(mp(a, b), mp(c, d));\n\t}\n}\nvoid Add(int tot, int x, int y, int z)\n{\n\tg[tot].id = y, g[tot].dis = z, g[tot].next = st[x], st[x] = tot;\n}\nint getf(int x)\n{\n\tif (f[x] == x) return x;\n\tf[x] = getf(f[x]);\n\treturn f[x];\n}\nbool exLoop(int m)\n{\n\tfor (int i = 1; i <= n; ++i)\n\t\tdis[i] = INF, ins[i] = 0;\n\thead = 0; tail = 0;\n\tfor (int i = 1; i <= n; ++i)\n//\t\tque[i] = i, ins[i] = 1;\n\t\tif (!ins[getf(i)])\n\t\t{\n\t\t\tque[++tail] = getf(i);\n\t\t\tdis[getf(i)] = 0;\n\t\t\tins[getf(i)] = 1;\n\t\t}\n\twhile (head < tail)\n\t{\n\t\tint x = que[++head];\n\t\tins[x] = 0;\n\t\tfor (int i = st[x]; i != -1; i = g[i].next)\n\t\t\tif (dis[x] + g[i].dis < dis[g[i].id])\n\t\t\t{\n\t\t\t\tdis[g[i].id] = dis[x] + g[i].dis;\n\t\t\t\tif (!ins[g[i].id])\n\t\t\t\t{\n\t\t\t\t\tins[g[i].id] = 1;\n\t\t\t\t\tque[++tail] = g[i].id;\n\t\t\t\t\tif (tail > 4 * (n + m))\n\t\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t}\n\treturn 1;\n}\nvoid Calc(int m)\n{\n\thead = 0, tail = 1;\n\tfor (int i = 1; i <= n; ++i)\n\t\tdis[i] = INF, ins[i] = 0;\n\tdis[1] = 0, ins[1] = 1, que[1] = 1;\n\twhile (head < tail)\n\t{\n\t\tint x = que[++head];\n\t\tins[x] = 0;\n\t\tfor (int i = st[x]; i != -1; i = g[i].next)\n\t\t\tif (dis[x] + g[i].dis < dis[g[i].id])\n\t\t\t{\n\t\t\t\tdis[g[i].id] = dis[x] + g[i].dis;\n\t\t\t\tif (!ins[g[i].id])\n\t\t\t\t{\n\t\t\t\t\tins[g[i].id] = 1;\n\t\t\t\t\tque[++tail] = g[i].id;\n\t\t\t\t}\n\t\t\t}\n\t}\n}\nmap h;\nbool check(int m, bool flag)\n{\n\tstatic int id[MAXN];\n\tmemset(st, -1, sizeof(st));\n\tfor (int i = 1; i <= n; ++i)\n\t\tf[i] = i, id[i] = i;\n\th.clear();\n\tfor (int i = 1; i <= m; ++i)\n\t{\n\t\tint x = e[i].x.x, y = e[i].x.y;\n\t\tif (x > y) swap(x, y);\n\t\tf[getf(x)] = getf(y);\n\t\tif (h.find(mp(x, y)) != h.end())\n\t\t\tif (h[mp(x, y)] == e[i].y.x * e[i].y.y)\n\t\t\t\tcontinue ;\n\t\t\telse\n\t\t\treturn 0;\n\t\tAdd(i * 2, x, y, e[i].y.x * e[i].y.y);\n\t\tAdd(i * 2 + 1, y, x, -e[i].y.x * e[i].y.y);\n\t}\n\tif (!exLoop(m))\n\t\treturn 0;\n\tfor (int i = 1; i <= n; ++i)\n\t\tif (dis[i] < dis[getf(i)])\n\t\t{\n\t\t\tint fa = getf(i);\n\t\t\tf[i] = i, f[fa] = i;\n\t\t}\n\tfor (int i = 1; i <= n; ++i)\n\t\tif (getf(i) != getf(1) && getf(i) != getf(n))\n\t\t{\n\t\t\t++m;\n\t\t\tAdd(m * 2, 1, getf(i), 0);\n\t\t\tAdd(m * 2 + 1, getf(i), 1, 0);\n//\t\t\tcout << 1 << \" \" << getf(i) << endl;\n//\t\t\tf[getf(i)] = getf(1);\n\t\t}\n\tif (getf(1) != getf(n))\n\t{\n\t\t++m;\n\t\tAdd(m * 2, 1, n, INF - 1);\n\t\tAdd(m * 2 + 1, n, 1, -INF + 1);\n\t}\n//\tputs(\"\");\n\tCalc(m);\n\tfor (int i = 1; i <= n; ++i)\n\t{\n\t\tfor (int j = st[i]; j != -1; j = g[j].next)\n\t\t\tif (dis[i] + g[j].dis > dis[g[j].id])\n\t\t\t\treturn 0;\n\t\tif (dis[i] + (i != n) > dis[n])\n\t\t\treturn 0;\n\t\tif (!dis[i] && i != 1 && getf(i) == getf(1))\n\t\t\treturn 0;\n\t\tif (dis[i] < 0)\n\t\t\treturn 0;\n\t}\n\tif (!flag)\n\t\treturn 1;\n\tif (dis[n] == INF - 1)\n\t\tputs(\"UNKNOWN\");\n\telse\n\tprintf(\"%d\\n\", dis[n]);\n\treturn 1;\n}\nint Find(int l, int r)\n{\n\twhile (l <= r)\n\t{\n\t\tint mid = (l + r) >> 1;\n\t\tif (check(mid, 0))\n\t\t\tl = mid + 1;\n\t\telse\n\t\t\tr = mid - 1;\n//\t\tcout << l << \" \" << r << endl;\n\t}\n\treturn r;\n}\nvoid solve()\n{\n\tint Tohka = Find(1, m);\n\tif (Tohka < m)\n\t\tprintf(\"BAD %d\\n\", Tohka + 1);\n\telse\n\t\tcheck(m, 1);\n}\nint main()\n{\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\", stdin), freopen(\"output.txt\", \"w\", stdout);\n#endif\n\t\n\tinit();\n\tsolve();\n\t\n\tfclose(stdin);\n\tfclose(stdout);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "69460b6598a75ed4c24fe5b2a02707c3", "src_uid": "b047916b7d99bc34a64ad41f43a37bf0", "difficulty": 3000.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#define MAXN 100005\n#define INF 0x7ffffff \nusing namespace std ;\ntypedef long long LL ;\n\nint N, M ;\nint fa[MAXN], dis[MAXN], mn[MAXN] ;\nint all, out[MAXN] ;\n\nint find(int x)\n{\n\tint tmp = fa[x] ;\n\tif(tmp == x) return x ;\n\tfa[x] = find(fa[x]) ;\n\tdis[x] = dis[tmp]+dis[x] ;\n\treturn fa[x] ;\n}\n\nvoid Bad(int x)\n{\n\tprintf(\"BAD %d\\n\", x) ;\n\texit(0) ;\n}\n\nint main()\n{\n\tint i, j ;\n\tint fr, to, w, b, tmp ;\n\tint t1, t2 ;\n\tscanf(\"%d %d\", &N, &M) ;\n\tfor(i = 1; i <= N; i ++)\n\t\tfa[i] = i, mn[i] = INF ;\n\tfor(i = 1; i <= M; i ++)\n\t{\n\t\tscanf(\"%d %d %d %d\", &fr, &to, &w, &b) ;\n\t\ttmp = w*b ;\n\t\tif((t1=find(fr)) != (t2=find(to)))\n\t\t{\n\t\t\tif(t1 > t2) swap(fr, to), swap(t1, t2), tmp = -tmp ;\n\t\t\tfa[t2] = t1 ;\n\t\t\tdis[t2] = dis[fr]+tmp-dis[to] ;\n\t\t\tmn[t1] = min(mn[t1], min(0, mn[t2])+dis[t2]) ;\t\n\t\t\tif(t1 == 1 && mn[t1] <= 0)\n\t\t\t\tBad(i) ;\n\t\t}\n\t\telse \n\t\t{\n\t\t\tif(dis[fr]+tmp != dis[to]) \n\t\t\t\tBad(i) ;\t\n\t\t}\n\t}\n\tif(find(N) != 1)\n\t\tprintf(\"UNKNOWN\\n\") ;\n\telse\n\t\tprintf(\"%d\\n\", dis[N]) ;\n\t//system(\"pause\") ;\n\treturn 0 ;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "eca7d718e7a4439b3edf9337ddd1c1d5", "src_uid": "b047916b7d99bc34a64ad41f43a37bf0", "difficulty": 3000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define sqr(_) ((_)*(_))\n\ntypedef pair Pii;\ntypedef pair Ppp;\n#define x first\n#define y second\n#define mp make_pair\n#define pb push_back\n\ntypedef long long LL;\n\nconst int MAXN = (int)2e5 + 10, INF = (int)2e9;\n\nstruct Graph\n{\n\tint id, next, dis;\n}g[MAXN * 4];\nPpp e[MAXN];\nint n, m, st[MAXN], dis[MAXN], f[MAXN];\nint head, tail, que[MAXN * 100];\nbool ins[MAXN];\n\nvoid init()\n{\n\tscanf(\"%d%d\", &n, &m);\n\tfor (int i = 1; i <= m; ++i)\n\t{\n\t\tint a, b, c, d;\n\t\tscanf(\"%d%d%d%d\", &a, &b, &c, &d);\n\t\te[i] = mp(mp(a, b), mp(c, d));\n\t}\n}\nvoid Add(int tot, int x, int y, int z)\n{\n\tg[tot].id = y, g[tot].dis = z, g[tot].next = st[x], st[x] = tot;\n}\nint getf(int x)\n{\n\tif (f[x] == x) return x;\n\tf[x] = getf(f[x]);\n\treturn f[x];\n}\nbool exLoop(int m)\n{\n\tfor (int i = 1; i <= n; ++i)\n\t\tdis[i] = INF, ins[i] = 0;\n\thead = 0; tail = 0;\n\tfor (int i = 1; i <= n; ++i)\n//\t\tque[i] = i, ins[i] = 1;\n\t\tif (!ins[getf(i)])\n\t\t{\n\t\t\tque[++tail] = getf(i);\n\t\t\tdis[getf(i)] = 0;\n\t\t\tins[getf(i)] = 1;\n\t\t}\n\twhile (head < tail)\n\t{\n\t\tint x = que[++head];\n\t\tins[x] = 0;\n\t\tfor (int i = st[x]; i != -1; i = g[i].next)\n\t\t\tif (dis[x] + g[i].dis < dis[g[i].id])\n\t\t\t{\n\t\t\t\tdis[g[i].id] = dis[x] + g[i].dis;\n\t\t\t\tif (!ins[g[i].id])\n\t\t\t\t{\n\t\t\t\t\tins[g[i].id] = 1;\n\t\t\t\t\tque[++tail] = g[i].id;\n\t\t\t\t\tif (tail > 4 * (n + m))\n\t\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t}\n\treturn 1;\n}\nvoid Calc(int m)\n{\n\thead = 0, tail = 1;\n\tfor (int i = 1; i <= n; ++i)\n\t\tdis[i] = INF, ins[i] = 0;\n\tdis[1] = 0, ins[1] = 1, que[1] = 1;\n\twhile (head < tail)\n\t{\n\t\tint x = que[++head];\n\t\tins[x] = 0;\n\t\tfor (int i = st[x]; i != -1; i = g[i].next)\n\t\t\tif (dis[x] + g[i].dis < dis[g[i].id])\n\t\t\t{\n\t\t\t\tdis[g[i].id] = dis[x] + g[i].dis;\n\t\t\t\tif (!ins[g[i].id])\n\t\t\t\t{\n\t\t\t\t\tins[g[i].id] = 1;\n\t\t\t\t\tque[++tail] = g[i].id;\n\t\t\t\t}\n\t\t\t}\n\t}\n}\nbool check(int m, bool flag)\n{\n\tstatic int id[MAXN];\n\tmemset(st, -1, sizeof(st));\n\tfor (int i = 1; i <= n; ++i)\n\t\tf[i] = i, id[i] = i;\n\tfor (int i = 1; i <= m; ++i)\n\t{\n\t\tf[getf(e[i].x.x)] = getf(e[i].x.y);\n\t\tAdd(i * 2, e[i].x.x, e[i].x.y, e[i].y.x * e[i].y.y);\n\t\tAdd(i * 2 + 1, e[i].x.y, e[i].x.x, -e[i].y.x * e[i].y.y);\n\t}\n\tif (!exLoop(m))\n\t\treturn 0;\n\tfor (int i = 1; i <= n; ++i)\n\t\tif (dis[i] < dis[getf(i)])\n\t\t{\n\t\t\tint fa = getf(i);\n\t\t\tf[i] = i, f[fa] = i;\n\t\t}\n\tfor (int i = 1; i <= n; ++i)\n\t\tif (getf(i) != getf(1) && getf(i) != getf(n))\n\t\t{\n\t\t\t++m;\n\t\t\tAdd(m * 2, 1, getf(i), 0);\n\t\t\tAdd(m * 2 + 1, getf(i), 1, 0);\n//\t\t\tcout << 1 << \" \" << getf(i) << endl;\n//\t\t\tf[getf(i)] = getf(1);\n\t\t}\n\tif (getf(1) != getf(n))\n\t{\n\t\t++m;\n\t\tAdd(m * 2, 1, n, INF - 1);\n\t\tAdd(m * 2 + 1, n, 1, -INF + 1);\n\t}\n//\tputs(\"\");\n\tCalc(m);\n\tfor (int i = 1; i <= n; ++i)\n\t{\n\t\tfor (int j = st[i]; j != -1; j = g[j].next)\n\t\t\tif (dis[i] + g[j].dis > dis[g[j].id])\n\t\t\t\treturn 0;\n\t\tif (dis[i] + (i != n) > dis[n])\n\t\t\treturn 0;\n\t\tif (!dis[i] && i != 1 && getf(i) == getf(1))\n\t\t\treturn 0;\n\t\tif (dis[i] < 0)\n\t\t\treturn 0;\n\t}\n\tif (!flag)\n\t\treturn 1;\n\tif (dis[n] == INF - 1)\n\t\tputs(\"UNKNOWN\");\n\telse\n\tprintf(\"%d\\n\", dis[n]);\n\treturn 1;\n}\nint Find(int l, int r)\n{\n\twhile (l <= r)\n\t{\n\t\tint mid = (l + r) >> 1;\n\t\tif (check(mid, 0))\n\t\t\tl = mid + 1;\n\t\telse\n\t\t\tr = mid - 1;\n//\t\tcout << l << \" \" << r << endl;\n\t}\n\treturn r;\n}\nvoid solve()\n{\n\tint Tohka = Find(1, m);\n\tif (Tohka < m)\n\t\tprintf(\"BAD %d\\n\", Tohka + 1);\n\telse\n\t\tcheck(m, 1);\n}\nint main()\n{\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\", stdin), freopen(\"output.txt\", \"w\", stdout);\n#endif\n\t\n\tinit();\n\tsolve();\n\t\n\tfclose(stdin);\n\tfclose(stdout);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "80e016e8648b00fcf3aea6d26f44469a", "src_uid": "b047916b7d99bc34a64ad41f43a37bf0", "difficulty": 3000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define sqr(_) ((_)*(_))\n\ntypedef pair Pii;\ntypedef pair Ppp;\n#define x first\n#define y second\n#define mp make_pair\n#define pb push_back\n\ntypedef long long LL;\n\nconst int MAXN = (int)2e5 + 10, INF = (int)2e9;\n\nstruct Graph\n{\n\tint id, next, dis;\n}g[MAXN * 4];\nPpp e[MAXN];\nint n, m, st[MAXN], dis[MAXN], f[MAXN];\nint head, tail, que[MAXN * 100];\nbool ins[MAXN];\n\nvoid init()\n{\n\tscanf(\"%d%d\", &n, &m);\n\tfor (int i = 1; i <= m; ++i)\n\t{\n\t\tint a, b, c, d;\n\t\tscanf(\"%d%d%d%d\", &a, &b, &c, &d);\n\t\te[i] = mp(mp(a, b), mp(c, d));\n\t}\n}\nvoid Add(int tot, int x, int y, int z)\n{\n\tg[tot].id = y, g[tot].dis = z, g[tot].next = st[x], st[x] = tot;\n}\nint getf(int x)\n{\n\tif (f[x] == x) return x;\n\tf[x] = getf(f[x]);\n\treturn f[x];\n}\nbool exLoop(int m)\n{\n\tfor (int i = 1; i <= n; ++i)\n\t\tdis[i] = INF, ins[i] = 0;\n\thead = 0; tail = 0;\n\tfor (int i = 1; i <= n; ++i)\n//\t\tque[i] = i, ins[i] = 1;\n\t\tif (!ins[getf(i)])\n\t\t{\n\t\t\tque[++tail] = getf(i);\n\t\t\tdis[getf(i)] = 0;\n\t\t\tins[getf(i)] = 1;\n\t\t}\n\twhile (head < tail)\n\t{\n\t\tint x = que[++head];\n\t\tins[x] = 0;\n\t\tfor (int i = st[x]; i != -1; i = g[i].next)\n\t\t\tif (dis[x] + g[i].dis < dis[g[i].id])\n\t\t\t{\n\t\t\t\tdis[g[i].id] = dis[x] + g[i].dis;\n\t\t\t\tif (!ins[g[i].id])\n\t\t\t\t{\n\t\t\t\t\tins[g[i].id] = 1;\n\t\t\t\t\tque[++tail] = g[i].id;\n\t\t\t\t\tif (tail > 4 * (n + m))\n\t\t\t\t\t\treturn 0;\n\t\t\t\t}\n\t\t\t}\n\t}\n\treturn 1;\n}\nvoid Calc(int m)\n{\n\thead = 0, tail = 1;\n\tfor (int i = 1; i <= n; ++i)\n\t\tdis[i] = INF, ins[i] = 0;\n\tdis[1] = 0, ins[1] = 1, que[1] = 1;\n\twhile (head < tail)\n\t{\n\t\tint x = que[++head];\n\t\tins[x] = 0;\n\t\tfor (int i = st[x]; i != -1; i = g[i].next)\n\t\t\tif (dis[x] + g[i].dis < dis[g[i].id])\n\t\t\t{\n\t\t\t\tdis[g[i].id] = dis[x] + g[i].dis;\n\t\t\t\tif (!ins[g[i].id])\n\t\t\t\t{\n\t\t\t\t\tins[g[i].id] = 1;\n\t\t\t\t\tque[++tail] = g[i].id;\n\t\t\t\t}\n\t\t\t}\n\t}\n}\nmap h;\nbool check(int m, bool flag)\n{\n\tstatic int id[MAXN];\n\tmemset(st, -1, sizeof(st));\n\tfor (int i = 1; i <= n; ++i)\n\t\tf[i] = i, id[i] = i;\n\th.clear();\n\tfor (int i = 1; i <= m; ++i)\n\t{\n\t\tint x = e[i].x.x, y = e[i].x.y, z = e[i].y.x * e[i].y.y;\n\t\tif (x > y)\n\t\t\tswap(x, y), z *= -1;\n\t\tf[getf(x)] = getf(y);\n\t\tif (h.find(mp(x, y)) != h.end())\n\t\t\tif (h[mp(x, y)] == z)\n\t\t\t\tcontinue ;\n\t\t\telse\n\t\t\treturn 0;\n\t\th[mp(x, y)] = z;\n\t\tAdd(i * 2, x, y, z);\n\t\tAdd(i * 2 + 1, y, x, -z);\n\t}\n\tif (!exLoop(m))\n\t\treturn 0;\n\tfor (int i = 1; i <= n; ++i)\n\t\tif (dis[i] < dis[getf(i)])\n\t\t{\n\t\t\tint fa = getf(i);\n\t\t\tf[i] = i, f[fa] = i;\n\t\t}\n\tfor (int i = 1; i <= n; ++i)\n\t\tif (getf(i) != getf(1) && getf(i) != getf(n))\n\t\t{\n\t\t\t++m;\n\t\t\tAdd(m * 2, 1, getf(i), 0);\n\t\t\tAdd(m * 2 + 1, getf(i), 1, 0);\n//\t\t\tcout << 1 << \" \" << getf(i) << endl;\n//\t\t\tf[getf(i)] = getf(1);\n\t\t}\n\tif (getf(1) != getf(n))\n\t{\n\t\t++m;\n\t\tAdd(m * 2, 1, n, INF - 1);\n\t\tAdd(m * 2 + 1, n, 1, -INF + 1);\n\t}\n//\tputs(\"\");\n\tCalc(m);\n\tfor (int i = 1; i <= n; ++i)\n\t{\n\t\tfor (int j = st[i]; j != -1; j = g[j].next)\n\t\t\tif (dis[i] + g[j].dis > dis[g[j].id])\n\t\t\t\treturn 0;\n\t\tif (dis[i] + (i != n) > dis[n])\n\t\t\treturn 0;\n\t\tif (!dis[i] && i != 1 && getf(i) == getf(1))\n\t\t\treturn 0;\n\t\tif (dis[i] < 0)\n\t\t\treturn 0;\n\t}\n\tif (!flag)\n\t\treturn 1;\n\tif (dis[n] == INF - 1)\n\t\tputs(\"UNKNOWN\");\n\telse\n\tprintf(\"%d\\n\", dis[n]);\n\treturn 1;\n}\nint Find(int l, int r)\n{\n\twhile (l <= r)\n\t{\n\t\tint mid = (l + r) >> 1;\n\t\tif (check(mid, 0))\n\t\t\tl = mid + 1;\n\t\telse\n\t\t\tr = mid - 1;\n//\t\tcout << l << \" \" << r << endl;\n\t}\n\treturn r;\n}\nvoid solve()\n{\n\tint Tohka = Find(1, m);\n\tif (Tohka < m)\n\t\tprintf(\"BAD %d\\n\", Tohka + 1);\n\telse\n\t\tcheck(m, 1);\n}\nint main()\n{\n#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"r\", stdin), freopen(\"output.txt\", \"w\", stdout);\n#endif\n\t\n\tinit();\n\tsolve();\n\t\n\tfclose(stdin);\n\tfclose(stdout);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6d73991edb17a25f99636091a35e9ba4", "src_uid": "b047916b7d99bc34a64ad41f43a37bf0", "difficulty": 3000.0} {"lang": "GNU C++14", "source_code": "\t#include \nusing namespace std;\ntypedef long long LL;\n\nLL ncr[40][40];\nLL ans[30][30];\n\n\nint main(){\n\tif(1){\n\t\tans[1][1]=0;\n\t\tans[1][2]=1;\n\t\tans[1][3]=0;\n\t\tans[1][4]=1;\n\t\tans[1][5]=0;\n\t\tans[1][6]=1;\n\t\tans[1][7]=0;\n\t\tans[1][8]=1;\n\t\tans[1][9]=0;\n\t\tans[1][10]=1;\n\t\tans[1][11]=0;\n\t\tans[1][12]=1;\n\t\tans[1][13]=0;\n\t\tans[1][14]=1;\n\t\tans[1][15]=0;\n\t\tans[1][16]=1;\n\t\tans[1][17]=0;\n\t\tans[1][18]=1;\n\t\tans[1][19]=0;\n\t\tans[1][20]=1;\n\t\tans[2][1]=3;\n\t\tans[2][2]=0;\n\t\tans[2][3]=2;\n\t\tans[2][4]=3;\n\t\tans[2][5]=1;\n\t\tans[2][6]=0;\n\t\tans[2][7]=0;\n\t\tans[2][8]=1;\n\t\tans[2][9]=1;\n\t\tans[2][10]=0;\n\t\tans[2][11]=0;\n\t\tans[2][12]=1;\n\t\tans[2][13]=1;\n\t\tans[2][14]=0;\n\t\tans[2][15]=0;\n\t\tans[2][16]=1;\n\t\tans[2][17]=1;\n\t\tans[2][18]=0;\n\t\tans[2][19]=0;\n\t\tans[2][20]=1;\n\t\tans[3][1]=8;\n\t\tans[3][2]=20;\n\t\tans[3][3]=0;\n\t\tans[3][4]=15;\n\t\tans[3][5]=16;\n\t\tans[3][6]=0;\n\t\tans[3][7]=0;\n\t\tans[3][8]=1;\n\t\tans[3][9]=0;\n\t\tans[3][10]=0;\n\t\tans[3][11]=0;\n\t\tans[3][12]=1;\n\t\tans[3][13]=0;\n\t\tans[3][14]=0;\n\t\tans[3][15]=0;\n\t\tans[3][16]=1;\n\t\tans[3][17]=0;\n\t\tans[3][18]=0;\n\t\tans[3][19]=0;\n\t\tans[3][20]=1;\n\t\tans[4][1]=15;\n\t\tans[4][2]=75;\n\t\tans[4][3]=175;\n\t\tans[4][4]=0;\n\t\tans[4][5]=4;\n\t\tans[4][6]=0;\n\t\tans[4][7]=0;\n\t\tans[4][8]=45;\n\t\tans[4][9]=15;\n\t\tans[4][10]=1;\n\t\tans[4][11]=1;\n\t\tans[4][12]=0;\n\t\tans[4][13]=0;\n\t\tans[4][14]=0;\n\t\tans[4][15]=0;\n\t\tans[4][16]=1;\n\t\tans[4][17]=1;\n\t\tans[4][18]=1;\n\t\tans[4][19]=1;\n\t\tans[4][20]=0;\n\t\tans[5][1]=24;\n\t\tans[5][2]=189;\n\t\tans[5][3]=784;\n\t\tans[5][4]=1764;\n\t\tans[5][5]=0;\n\t\tans[5][6]=0;\n\t\tans[5][7]=60;\n\t\tans[5][8]=95;\n\t\tans[5][9]=200;\n\t\tans[5][10]=1;\n\t\tans[5][11]=14;\n\t\tans[5][12]=14;\n\t\tans[5][13]=0;\n\t\tans[5][14]=4;\n\t\tans[5][15]=0;\n\t\tans[5][16]=1;\n\t\tans[5][17]=0;\n\t\tans[5][18]=1;\n\t\tans[5][19]=0;\n\t\tans[5][20]=0;\n\t\tans[6][1]=35;\n\t\tans[6][2]=392;\n\t\tans[6][3]=2352;\n\t\tans[6][4]=8820;\n\t\tans[6][5]=19404;\n\t\tans[6][6]=0;\n\t\tans[6][7]=6600;\n\t\tans[6][8]=553;\n\t\tans[6][9]=245;\n\t\tans[6][10]=10780;\n\t\tans[6][11]=658;\n\t\tans[6][12]=126;\n\t\tans[6][13]=56;\n\t\tans[6][14]=20;\n\t\tans[6][15]=0;\n\t\tans[6][16]=5;\n\t\tans[6][17]=5;\n\t\tans[6][18]=0;\n\t\tans[6][19]=0;\n\t\tans[6][20]=0;\n\t\tans[7][1]=48;\n\t\tans[7][2]=720;\n\t\tans[7][3]=5760;\n\t\tans[7][4]=29700;\n\t\tans[7][5]=104544;\n\t\tans[7][6]=226512;\n\t\tans[7][7]=0;\n\t\tans[7][8]=15015;\n\t\tans[7][9]=40040;\n\t\tans[7][10]=0;\n\t\tans[7][11]=1440;\n\t\tans[7][12]=2028;\n\t\tans[7][13]=432;\n\t\tans[7][14]=1280;\n\t\tans[7][15]=8;\n\t\tans[7][16]=249;\n\t\tans[7][17]=8;\n\t\tans[7][18]=20;\n\t\tans[7][19]=6;\n\t\tans[7][20]=4;\n\t\tans[8][1]=63;\n\t\tans[8][2]=1215;\n\t\tans[8][3]=12375;\n\t\tans[8][4]=81675;\n\t\tans[8][5]=382239;\n\t\tans[8][6]=1288287;\n\t\tans[8][7]=2760615;\n\t\tans[8][8]=0;\n\t\tans[8][9]=1635920;\n\t\tans[8][10]=198198;\n\t\tans[8][11]=534456;\n\t\tans[8][12]=4524;\n\t\tans[8][13]=1546;\n\t\tans[8][14]=111564;\n\t\tans[8][15]=4050;\n\t\tans[8][16]=621;\n\t\tans[8][17]=3069;\n\t\tans[8][18]=5;\n\t\tans[8][19]=43;\n\t\tans[8][20]=1;\n\t\tans[9][1]=80;\n\t\tans[9][2]=1925;\n\t\tans[9][3]=24200;\n\t\tans[9][4]=196625;\n\t\tans[9][5]=1145144;\n\t\tans[9][6]=5010005;\n\t\tans[9][7]=16359200;\n\t\tans[9][8]=34763300;\n\t\tans[9][9]=0;\n\t\tans[9][10]=34606;\n\t\tans[9][11]=701350;\n\t\tans[9][12]=6651840;\n\t\tans[9][13]=78298;\n\t\tans[9][14]=429418;\n\t\tans[9][15]=872494;\n\t\tans[9][16]=1615;\n\t\tans[9][17]=352;\n\t\tans[9][18]=1155;\n\t\tans[9][19]=8580;\n\t\tans[9][20]=145;\n\t\tans[10][1]=99;\n\t\tans[10][2]=2904;\n\t\tans[10][3]=44044;\n\t\tans[10][4]=429429;\n\t\tans[10][5]=3006003;\n\t\tans[10][6]=16032016;\n\t\tans[10][7]=66745536;\n\t\tans[10][8]=212751396;\n\t\tans[10][9]=449141836;\n\t\tans[10][10]=0;\n\t\tans[10][11]=11675872;\n\t\tans[10][12]=4900324;\n\t\tans[10][13]=980474;\n\t\tans[10][14]=120143080;\n\t\tans[10][15]=47159156;\n\t\tans[10][16]=380171;\n\t\tans[10][17]=35871;\n\t\tans[10][18]=2207348;\n\t\tans[10][19]=223498;\n\t\tans[10][20]=4875;\n\t\tans[11][1]=120;\n\t\tans[11][2]=4212;\n\t\tans[11][3]=75712;\n\t\tans[11][4]=869505;\n\t\tans[11][5]=7154784;\n\t\tans[11][6]=45048640;\n\t\tans[11][7]=225059328;\n\t\tans[11][8]=901995588;\n\t\tans[11][9]=2821056160;\n\t\tans[11][10]=5924217936;\n\t\tans[11][11]=0;\n\t\tans[11][12]=1763160100;\n\t\tans[11][13]=1014736800;\n\t\tans[11][14]=96243664;\n\t\tans[11][15]=527663136;\n\t\tans[11][16]=13024737;\n\t\tans[11][17]=1152008;\n\t\tans[11][18]=27986506;\n\t\tans[11][19]=835384;\n\t\tans[12][1]=143;\n\t\tans[12][2]=5915;\n\t\tans[12][3]=124215;\n\t\tans[12][4]=1656200;\n\t\tans[12][5]=15767024;\n\t\tans[12][6]=114874032;\n\t\tans[12][7]=668144880;\n\t\tans[12][8]=3173688180;\n\t\tans[12][9]=12342120700;\n\t\tans[12][10]=38013731756;\n\t\tans[12][11]=79483257308;\n\t\tans[12][12]=0;\n\t\tans[12][13]=334424;\n\t\tans[12][14]=86230664;\n\t\tans[12][15]=401457992;\n\t\tans[12][16]=1811255769;\n\t\tans[12][17]=8782619185;\n\t\tans[12][18]=524739891;\n\t\tans[13][1]=168;\n\t\tans[13][2]=8085;\n\t\tans[13][3]=196000;\n\t\tans[13][4]=2998800;\n\t\tans[13][5]=32626944;\n\t\tans[13][6]=271211472;\n\t\tans[13][7]=1802805120;\n\t\tans[13][8]=9859090500;\n\t\tans[13][9]=44986664800;\n\t\tans[13][10]=170724392916;\n\t\tans[13][11]=519227905728;\n\t\tans[13][12]=1081724803600;\n\t\tans[13][13]=0;\n\t\tans[13][14]=5856160;\n\t\tans[13][15]=0;\n\t\tans[13][16]=208030461065;\n\t\tans[13][17]=743483832;\n\t\tans[14][1]=195;\n\t\tans[14][2]=10800;\n\t\tans[14][3]=299200;\n\t\tans[14][4]=5202000;\n\t\tans[14][5]=64047024;\n\t\tans[14][6]=600935040;\n\t\tans[14][7]=4507012800;\n\t\tans[14][8]=27887141700;\n\t\tans[14][9]=145173803500;\n\t\tans[14][10]=641087516256;\n\t\tans[14][11]=2384209771200;\n\t\tans[14][12]=7174705330000;\n\t\tans[14][13]=14901311070000;\n\t\tans[14][14]=0;\n\t\tans[14][15]=262032716400;\n\t\tans[14][16]=2131715333625;\n\t\tans[15][1]=224;\n\t\tans[15][2]=14144;\n\t\tans[15][3]=443904;\n\t\tans[15][4]=8697744;\n\t\tans[15][5]=120187008;\n\t\tans[15][6]=1261963584;\n\t\tans[15][7]=10576456704;\n\t\tans[15][8]=73167596964;\n\t\tans[15][9]=427391677504;\n\t\tans[15][10]=2136958387520;\n\t\tans[15][11]=9183622822400;\n\t\tans[15][12]=33577620944400;\n\t\tans[15][13]=100136810390400;\n\t\tans[15][14]=207426250094400;\n\t\tans[15][15]=0;\n\t\tans[16][1]=255;\n\t\tans[16][2]=18207;\n\t\tans[16][3]=642447;\n\t\tans[16][4]=14084415;\n\t\tans[16][5]=216899991;\n\t\tans[16][6]=2530499895;\n\t\tans[16][7]=23518156167;\n\t\tans[16][8]=180305863947;\n\t\tans[16][9]=1168649118175;\n\t\tans[16][10]=6511045086975;\n\t\tans[16][11]=31479019635375;\n\t\tans[16][12]=132211882468575;\n\t\tans[16][13]=476432168185575;\n\t\tans[16][14]=1409850293610375;\n\t\tans[17][1]=288;\n\t\tans[17][2]=23085;\n\t\tans[17][3]=909720;\n\t\tans[17][4]=22174425;\n\t\tans[17][5]=378261576;\n\t\tans[17][6]=4873620213;\n\t\tans[17][7]=49911657840;\n\t\tans[17][8]=421129613025;\n\t\tans[17][9]=3003942370000;\n\t\tans[17][10]=18451716007725;\n\t\tans[17][11]=98815801429800;\n\t\tans[17][12]=464342770607625;\n\t\tans[17][13]=1912322889603000;\n\t\tans[18][1]=323;\n\t\tans[18][2]=28880;\n\t\tans[18][3]=1263500;\n\t\tans[18][4]=34051325;\n\t\tans[18][5]=639970331;\n\t\tans[18][6]=9058041608;\n\t\tans[18][7]=101671895600;\n\t\tans[18][8]=938731990625;\n\t\tans[18][9]=7322109526875;\n\t\tans[18][10]=49204576020600;\n\t\tans[18][11]=288924390600300;\n\t\tans[18][12]=1496215594180125;\n\t\tans[19][1]=360;\n\t\tans[19][2]=35700;\n\t\tans[19][3]=1724800;\n\t\tans[19][4]=51137625;\n\t\tans[19][5]=1053844176;\n\t\tans[19][6]=16309493200;\n\t\tans[19][7]=199708080000;\n\t\tans[19][8]=2008002335625;\n\t\tans[19][9]=17037595575000;\n\t\tans[19][10]=124510748462100;\n\t\tans[19][11]=795771174744000;\n\t\tans[20][1]=399;\n\t\tans[20][2]=43659;\n\t\tans[20][3]=2318239;\n\t\tans[20][4]=75274584;\n\t\tans[20][5]=1693678140;\n\t\tans[20][6]=28541613100;\n\t\tans[20][7]=379694987100;\n\t\tans[20][8]=4140135724725;\n\t\tans[20][9]=38044950918975;\n\t\tans[20][10]=300900975450075;\n\n\t}\n\n\tfor(LL a = 0; a < 40; a++){\n\t\tfor(LL b = 0; b < 40; b++){\n\t\t\tif(b > a){\n\t\t\t\tncr[a][b] = 0;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif(b == 0 || b == a){\n\t\t\t\tncr[a][b] = 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tncr[a][b] = ncr[a-1][b-1] + ncr[a-1][b];\n\t\t}\n\t}\n\tLL R, C;\n\tcin >> R >> C;\n\tstring str;\n\tcin >> str;\n\tLL n = R+C;\n\tLL blockarea[n][n];\n\tLL totalarea[n+1][n+1];\n\tfor(LL a = 0; a < n; a++){\n\t\tfor(LL b = 0; b < n; b++){\n\t\t\tblockarea[a][b] = ncr[a][R-1]*ncr[b][R-1];\n\t\t}\n\t}\n\tLL revarea[n+1][n+1];\n\tfor(LL a = 0; a <= n; a++){\n\t\tfor(LL b = 0; b <= n; b++){\n\t\t\ttotalarea[a][b] = 0;\n\t\t\tif(a == 0 || b == 0) continue;\n\t\t\ttotalarea[a][b] = totalarea[a][b-1] + totalarea[a-1][b] - totalarea[a-1][b-1];\n\t\t\ttotalarea[a][b] += blockarea[a-1][b-1];\n\t\t}\n\t}\n\tfor(LL a = 0; a <= n; a++){\n\t\tfor(LL b = 0; b <= n; b++){\n\t\t\trevarea[a][b] = totalarea[n][n] - totalarea[n-a][n]\n\t\t\t\t\t\t - totalarea[n][n-b] + totalarea[n-a][n-b];\n\t\t}\n\t}\n\n\tLL d = min(2*n-1,30);\n\n\tmap dp[n+1][n+1];\n\tmap bp[n+1][n+1];\n\tdp[0][0][0] = 1;\n\tbp[0][0][0] = 1;\n\n\tLL best = ans[R][C];\n\tLL m1 = (-best + totalarea[n][n]) / 2;\n\tLL m2 = totalarea[n][n] - m1;\n\tLL bestfreq = 0;\n\n\tfor(LL x = 0; x <= n; x++){\n\t\tfor(LL y = 0; y < n; y++){\n\t\t\tif(x+y+1 <= d && str[x+y] != 'B'){\n\t\t\t\tfor(auto it = dp[x][y].begin(); it != dp[x][y].end(); it++){\n\t\t\t\t\tLL area2 = it->first + totalarea[n][y+1] - totalarea[x][y+1];\n\t\t\t\t\tif(area2 > m2) continue;\n\t\t\t\t\tdp[x][y+1][it->first] += it->second;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(x+y+1 <= 2*n-d && str[n-x+n-y-1] != 'B'){\n\t\t\t\tfor(auto it = bp[x][y].begin(); it != bp[x][y].end(); it++){\n\t\t\t\t\tLL area2 = totalarea[n][n] - it->first - totalarea[n-x][n-(y+1)];\n\t\t\t\t\tif(area2 > m2) continue;\n\t\t\t\t\tbp[x][y+1][it->first] += it->second;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(x == n) continue;\n\t\tfor(LL y = 0; y <= n; y++){\n\n\t\t\tif(x+y+1 <= d && str[x+y] != 'A'){\n\t\t\t\tLL newarea = totalarea[x+1][y] - totalarea[x][y];\n\t\t\t\tfor(auto it = dp[x][y].begin(); it != dp[x][y].end(); it++){\n\t\t\t\t\tLL c = it->first+newarea;\n\t\t\t\t\tLL area2 = totalarea[x+1][n] - c;\n\t\t\t\t\tif(area2 > m2) continue;\n\t\t\t\t\tdp[x+1][y][it->first + newarea] += it->second;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(x+y+1 <= 2*n-d && str[n-x+n-y-1] != 'A'){\n\t\t\t\tLL newarea = totalarea[n-x][n-y] - totalarea[n-x-1][n-y];\n\t\t\t\tfor(auto it = bp[x][y].begin(); it != bp[x][y].end(); it++){\n\t\t\t\t\tif(it->first + newarea > m2) continue;\n\t\t\t\t\tbp[x+1][y][it->first + newarea] += it->second;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(x+y+1 <= d) dp[x][y].clear();\n\t\t\tif(x+y+1 <= 2*n-d) bp[x][y].clear();\n\t\t}\n\n\t}\n\n\n\tfor(LL x = 0; x <= n; x++){\n\t\tLL y = d-x;\n\t\tif(y < 0 || y > n) continue;\n\t\t//cout << x << \" \" << y << endl;\n\t\tfor(auto it = dp[x][y].begin(); it != dp[x][y].end(); it++){\n\t\t\tLL c = it->first;\n\t\t\tLL freq = it->second;\n\t\t\t// bp[n-x][n-y]\n\t\t\tbestfreq += freq * bp[n-x][n-y][m1-c];\n\t\t\tif(m1 != m2) bestfreq += freq * bp[n-x][n-y][m2-c];\n\n\t\t}\n\t}\n\n\tcout << bestfreq << endl;\n\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "819749cd803b356d1aa5db31f89e386d", "src_uid": "1b978b5aed4a83a2250bb23cc1ad6f85", "difficulty": 3300.0} {"lang": "GNU C++14", "source_code": "\t#include \nusing namespace std;\ntypedef long long LL;\n\nLL ncr[40][40];\nLL ans[30][30];\n\n\nint main(){\n\tif(1){\n\t\tans[1][1]=0;\n\t\tans[1][2]=1;\n\t\tans[1][3]=0;\n\t\tans[1][4]=1;\n\t\tans[1][5]=0;\n\t\tans[1][6]=1;\n\t\tans[1][7]=0;\n\t\tans[1][8]=1;\n\t\tans[1][9]=0;\n\t\tans[1][10]=1;\n\t\tans[1][11]=0;\n\t\tans[1][12]=1;\n\t\tans[1][13]=0;\n\t\tans[1][14]=1;\n\t\tans[1][15]=0;\n\t\tans[1][16]=1;\n\t\tans[1][17]=0;\n\t\tans[1][18]=1;\n\t\tans[1][19]=0;\n\t\tans[1][20]=1;\n\t\tans[2][1]=3;\n\t\tans[2][2]=0;\n\t\tans[2][3]=2;\n\t\tans[2][4]=3;\n\t\tans[2][5]=1;\n\t\tans[2][6]=0;\n\t\tans[2][7]=0;\n\t\tans[2][8]=1;\n\t\tans[2][9]=1;\n\t\tans[2][10]=0;\n\t\tans[2][11]=0;\n\t\tans[2][12]=1;\n\t\tans[2][13]=1;\n\t\tans[2][14]=0;\n\t\tans[2][15]=0;\n\t\tans[2][16]=1;\n\t\tans[2][17]=1;\n\t\tans[2][18]=0;\n\t\tans[2][19]=0;\n\t\tans[2][20]=1;\n\t\tans[3][1]=8;\n\t\tans[3][2]=20;\n\t\tans[3][3]=0;\n\t\tans[3][4]=15;\n\t\tans[3][5]=16;\n\t\tans[3][6]=0;\n\t\tans[3][7]=0;\n\t\tans[3][8]=1;\n\t\tans[3][9]=0;\n\t\tans[3][10]=0;\n\t\tans[3][11]=0;\n\t\tans[3][12]=1;\n\t\tans[3][13]=0;\n\t\tans[3][14]=0;\n\t\tans[3][15]=0;\n\t\tans[3][16]=1;\n\t\tans[3][17]=0;\n\t\tans[3][18]=0;\n\t\tans[3][19]=0;\n\t\tans[3][20]=1;\n\t\tans[4][1]=15;\n\t\tans[4][2]=75;\n\t\tans[4][3]=175;\n\t\tans[4][4]=0;\n\t\tans[4][5]=4;\n\t\tans[4][6]=0;\n\t\tans[4][7]=0;\n\t\tans[4][8]=45;\n\t\tans[4][9]=15;\n\t\tans[4][10]=1;\n\t\tans[4][11]=1;\n\t\tans[4][12]=0;\n\t\tans[4][13]=0;\n\t\tans[4][14]=0;\n\t\tans[4][15]=0;\n\t\tans[4][16]=1;\n\t\tans[4][17]=1;\n\t\tans[4][18]=1;\n\t\tans[4][19]=1;\n\t\tans[4][20]=0;\n\t\tans[5][1]=24;\n\t\tans[5][2]=189;\n\t\tans[5][3]=784;\n\t\tans[5][4]=1764;\n\t\tans[5][5]=0;\n\t\tans[5][6]=0;\n\t\tans[5][7]=60;\n\t\tans[5][8]=95;\n\t\tans[5][9]=200;\n\t\tans[5][10]=1;\n\t\tans[5][11]=14;\n\t\tans[5][12]=14;\n\t\tans[5][13]=0;\n\t\tans[5][14]=4;\n\t\tans[5][15]=0;\n\t\tans[5][16]=1;\n\t\tans[5][17]=0;\n\t\tans[5][18]=1;\n\t\tans[5][19]=0;\n\t\tans[5][20]=0;\n\t\tans[6][1]=35;\n\t\tans[6][2]=392;\n\t\tans[6][3]=2352;\n\t\tans[6][4]=8820;\n\t\tans[6][5]=19404;\n\t\tans[6][6]=0;\n\t\tans[6][7]=6600;\n\t\tans[6][8]=553;\n\t\tans[6][9]=245;\n\t\tans[6][10]=10780;\n\t\tans[6][11]=658;\n\t\tans[6][12]=126;\n\t\tans[6][13]=56;\n\t\tans[6][14]=20;\n\t\tans[6][15]=0;\n\t\tans[6][16]=5;\n\t\tans[6][17]=5;\n\t\tans[6][18]=0;\n\t\tans[6][19]=0;\n\t\tans[6][20]=0;\n\t\tans[7][1]=48;\n\t\tans[7][2]=720;\n\t\tans[7][3]=5760;\n\t\tans[7][4]=29700;\n\t\tans[7][5]=104544;\n\t\tans[7][6]=226512;\n\t\tans[7][7]=0;\n\t\tans[7][8]=15015;\n\t\tans[7][9]=40040;\n\t\tans[7][10]=0;\n\t\tans[7][11]=1440;\n\t\tans[7][12]=2028;\n\t\tans[7][13]=432;\n\t\tans[7][14]=1280;\n\t\tans[7][15]=8;\n\t\tans[7][16]=249;\n\t\tans[7][17]=8;\n\t\tans[7][18]=20;\n\t\tans[7][19]=6;\n\t\tans[7][20]=4;\n\t\tans[8][1]=63;\n\t\tans[8][2]=1215;\n\t\tans[8][3]=12375;\n\t\tans[8][4]=81675;\n\t\tans[8][5]=382239;\n\t\tans[8][6]=1288287;\n\t\tans[8][7]=2760615;\n\t\tans[8][8]=0;\n\t\tans[8][9]=1635920;\n\t\tans[8][10]=198198;\n\t\tans[8][11]=534456;\n\t\tans[8][12]=4524;\n\t\tans[8][13]=1546;\n\t\tans[8][14]=111564;\n\t\tans[8][15]=4050;\n\t\tans[8][16]=621;\n\t\tans[8][17]=3069;\n\t\tans[8][18]=5;\n\t\tans[8][19]=43;\n\t\tans[8][20]=1;\n\t\tans[9][1]=80;\n\t\tans[9][2]=1925;\n\t\tans[9][3]=24200;\n\t\tans[9][4]=196625;\n\t\tans[9][5]=1145144;\n\t\tans[9][6]=5010005;\n\t\tans[9][7]=16359200;\n\t\tans[9][8]=34763300;\n\t\tans[9][9]=0;\n\t\tans[9][10]=34606;\n\t\tans[9][11]=701350;\n\t\tans[9][12]=6651840;\n\t\tans[9][13]=78298;\n\t\tans[9][14]=429418;\n\t\tans[9][15]=872494;\n\t\tans[9][16]=1615;\n\t\tans[9][17]=352;\n\t\tans[9][18]=1155;\n\t\tans[9][19]=8580;\n\t\tans[9][20]=145;\n\t\tans[10][1]=99;\n\t\tans[10][2]=2904;\n\t\tans[10][3]=44044;\n\t\tans[10][4]=429429;\n\t\tans[10][5]=3006003;\n\t\tans[10][6]=16032016;\n\t\tans[10][7]=66745536;\n\t\tans[10][8]=212751396;\n\t\tans[10][9]=449141836;\n\t\tans[10][10]=0;\n\t\tans[10][11]=11675872;\n\t\tans[10][12]=4900324;\n\t\tans[10][13]=980474;\n\t\tans[10][14]=120143080;\n\t\tans[10][15]=47159156;\n\t\tans[10][16]=380171;\n\t\tans[10][17]=35871;\n\t\tans[10][18]=2207348;\n\t\tans[10][19]=223498;\n\t\tans[10][20]=4875;\n\t\tans[11][1]=120;\n\t\tans[11][2]=4212;\n\t\tans[11][3]=75712;\n\t\tans[11][4]=869505;\n\t\tans[11][5]=7154784;\n\t\tans[11][6]=45048640;\n\t\tans[11][7]=225059328;\n\t\tans[11][8]=901995588;\n\t\tans[11][9]=2821056160;\n\t\tans[11][10]=5924217936;\n\t\tans[11][11]=0;\n\t\tans[11][12]=1763160100;\n\t\tans[11][13]=1014736800;\n\t\tans[11][14]=96243664;\n\t\tans[11][15]=527663136;\n\t\tans[11][16]=13024737;\n\t\tans[11][17]=1152008;\n\t\tans[11][18]=27986506;\n\t\tans[11][19]=835384;\n\t\tans[12][1]=143;\n\t\tans[12][2]=5915;\n\t\tans[12][3]=124215;\n\t\tans[12][4]=1656200;\n\t\tans[12][5]=15767024;\n\t\tans[12][6]=114874032;\n\t\tans[12][7]=668144880;\n\t\tans[12][8]=3173688180;\n\t\tans[12][9]=12342120700;\n\t\tans[12][10]=38013731756;\n\t\tans[12][11]=79483257308;\n\t\tans[12][12]=0;\n\t\tans[12][13]=334424;\n\t\tans[12][14]=86230664;\n\t\tans[12][15]=401457992;\n\t\tans[12][16]=1811255769;\n\t\tans[12][17]=8782619185;\n\t\tans[12][18]=524739891;\n\t\tans[13][1]=168;\n\t\tans[13][2]=8085;\n\t\tans[13][3]=196000;\n\t\tans[13][4]=2998800;\n\t\tans[13][5]=32626944;\n\t\tans[13][6]=271211472;\n\t\tans[13][7]=1802805120;\n\t\tans[13][8]=9859090500;\n\t\tans[13][9]=44986664800;\n\t\tans[13][10]=170724392916;\n\t\tans[13][11]=519227905728;\n\t\tans[13][12]=1081724803600;\n\t\tans[13][13]=0;\n\t\tans[13][14]=5856160;\n\t\tans[13][15]=0;\n\t\tans[13][16]=208030461065;\n\t\tans[13][17]=743483832;\n\t\tans[14][1]=195;\n\t\tans[14][2]=10800;\n\t\tans[14][3]=299200;\n\t\tans[14][4]=5202000;\n\t\tans[14][5]=64047024;\n\t\tans[14][6]=600935040;\n\t\tans[14][7]=4507012800;\n\t\tans[14][8]=27887141700;\n\t\tans[14][9]=145173803500;\n\t\tans[14][10]=641087516256;\n\t\tans[14][11]=2384209771200;\n\t\tans[14][12]=7174705330000;\n\t\tans[14][13]=14901311070000;\n\t\tans[14][14]=0;\n\t\tans[14][15]=262032716400;\n\t\tans[14][16]=2131715333625;\n\t\tans[15][1]=224;\n\t\tans[15][2]=14144;\n\t\tans[15][3]=443904;\n\t\tans[15][4]=8697744;\n\t\tans[15][5]=120187008;\n\t\tans[15][6]=1261963584;\n\t\tans[15][7]=10576456704;\n\t\tans[15][8]=73167596964;\n\t\tans[15][9]=427391677504;\n\t\tans[15][10]=2136958387520;\n\t\tans[15][11]=9183622822400;\n\t\tans[15][12]=33577620944400;\n\t\tans[15][13]=100136810390400;\n\t\tans[15][14]=207426250094400;\n\t\tans[15][15]=0;\n\t\tans[16][1]=255;\n\t\tans[16][2]=18207;\n\t\tans[16][3]=642447;\n\t\tans[16][4]=14084415;\n\t\tans[16][5]=216899991;\n\t\tans[16][6]=2530499895;\n\t\tans[16][7]=23518156167;\n\t\tans[16][8]=180305863947;\n\t\tans[16][9]=1168649118175;\n\t\tans[16][10]=6511045086975;\n\t\tans[16][11]=31479019635375;\n\t\tans[16][12]=132211882468575;\n\t\tans[16][13]=476432168185575;\n\t\tans[16][14]=1409850293610375;\n\t\tans[17][1]=288;\n\t\tans[17][2]=23085;\n\t\tans[17][3]=909720;\n\t\tans[17][4]=22174425;\n\t\tans[17][5]=378261576;\n\t\tans[17][6]=4873620213;\n\t\tans[17][7]=49911657840;\n\t\tans[17][8]=421129613025;\n\t\tans[17][9]=3003942370000;\n\t\tans[17][10]=18451716007725;\n\t\tans[17][11]=98815801429800;\n\t\tans[17][12]=464342770607625;\n\t\tans[17][13]=1912322889603000;\n\t\tans[18][1]=323;\n\t\tans[18][2]=28880;\n\t\tans[18][3]=1263500;\n\t\tans[18][4]=34051325;\n\t\tans[18][5]=639970331;\n\t\tans[18][6]=9058041608;\n\t\tans[18][7]=101671895600;\n\t\tans[18][8]=938731990625;\n\t\tans[18][9]=7322109526875;\n\t\tans[18][10]=49204576020600;\n\t\tans[18][11]=288924390600300;\n\t\tans[18][12]=1496215594180125;\n\t\tans[19][1]=360;\n\t\tans[19][2]=35700;\n\t\tans[19][3]=1724800;\n\t\tans[19][4]=51137625;\n\t\tans[19][5]=1053844176;\n\t\tans[19][6]=16309493200;\n\t\tans[19][7]=199708080000;\n\t\tans[19][8]=2008002335625;\n\t\tans[19][9]=17037595575000;\n\t\tans[19][10]=124510748462100;\n\t\tans[19][11]=795771174744000;\n\t\tans[20][1]=399;\n\t\tans[20][2]=43659;\n\t\tans[20][3]=2318239;\n\t\tans[20][4]=75274584;\n\t\tans[20][5]=1693678140;\n\t\tans[20][6]=28541613100;\n\t\tans[20][7]=379694987100;\n\t\tans[20][8]=4140135724725;\n\t\tans[20][9]=38044950918975;\n\t\tans[20][10]=300900975450075;\n\n\t}\n\n\tfor(LL a = 0; a < 40; a++){\n\t\tfor(LL b = 0; b < 40; b++){\n\t\t\tif(b > a){\n\t\t\t\tncr[a][b] = 0;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif(b == 0 || b == a){\n\t\t\t\tncr[a][b] = 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tncr[a][b] = ncr[a-1][b-1] + ncr[a-1][b];\n\t\t}\n\t}\n\tLL R, C;\n\tcin >> R >> C;\n\tstring str;\n\tcin >> str;\n\tLL n = R+C;\n\tLL blockarea[n][n];\n\tLL totalarea[n+1][n+1];\n\tfor(LL a = 0; a < n; a++){\n\t\tfor(LL b = 0; b < n; b++){\n\t\t\tblockarea[a][b] = ncr[a][R-1]*ncr[b][R-1];\n\t\t}\n\t}\n\tLL revarea[n+1][n+1];\n\tfor(LL a = 0; a <= n; a++){\n\t\tfor(LL b = 0; b <= n; b++){\n\t\t\ttotalarea[a][b] = 0;\n\t\t\tif(a == 0 || b == 0) continue;\n\t\t\ttotalarea[a][b] = totalarea[a][b-1] + totalarea[a-1][b] - totalarea[a-1][b-1];\n\t\t\ttotalarea[a][b] += blockarea[a-1][b-1];\n\t\t}\n\t}\n\tfor(LL a = 0; a <= n; a++){\n\t\tfor(LL b = 0; b <= n; b++){\n\t\t\trevarea[a][b] = totalarea[n][n] - totalarea[n-a][n]\n\t\t\t\t\t\t - totalarea[n][n-b] + totalarea[n-a][n-b];\n\t\t}\n\t}\n\n\tLL d = min(2*n-1,n+R);\n\n\tmap dp[n+1][n+1];\n\tmap bp[n+1][n+1];\n\tdp[0][0][0] = 1;\n\tbp[0][0][0] = 1;\n\n\tLL best = ans[R][C];\n\tLL m1 = (-best + totalarea[n][n]) / 2;\n\tLL m2 = totalarea[n][n] - m1;\n\tLL bestfreq = 0;\n\n\tfor(LL x = 0; x <= n; x++){\n\t\tfor(LL y = 0; y < n; y++){\n\t\t\tif(x+y+1 <= d && str[x+y] != 'B'){\n\t\t\t\tfor(auto it = dp[x][y].begin(); it != dp[x][y].end(); it++){\n\t\t\t\t\tLL area2 = it->first + totalarea[n][y+1] - totalarea[x][y+1];\n\t\t\t\t\tif(area2 > m2) continue;\n\t\t\t\t\tdp[x][y+1][it->first] += it->second;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(x+y+1 <= 2*n-d && str[n-x+n-y-1] != 'B'){\n\t\t\t\tfor(auto it = bp[x][y].begin(); it != bp[x][y].end(); it++){\n\t\t\t\t\tLL area2 = totalarea[n][n] - it->first - totalarea[n-x][n-(y+1)];\n\t\t\t\t\tif(area2 > m2) continue;\n\t\t\t\t\tbp[x][y+1][it->first] += it->second;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(x == n) continue;\n\t\tfor(LL y = 0; y <= n; y++){\n\n\t\t\tif(x+y+1 <= d && str[x+y] != 'A'){\n\t\t\t\tLL newarea = totalarea[x+1][y] - totalarea[x][y];\n\t\t\t\tfor(auto it = dp[x][y].begin(); it != dp[x][y].end(); it++){\n\t\t\t\t\tLL c = it->first+newarea;\n\t\t\t\t\tLL area2 = totalarea[x+1][n] - c;\n\t\t\t\t\tif(area2 > m2) continue;\n\t\t\t\t\tdp[x+1][y][it->first + newarea] += it->second;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(x+y+1 <= 2*n-d && str[n-x+n-y-1] != 'A'){\n\t\t\t\tLL newarea = totalarea[n-x][n-y] - totalarea[n-x-1][n-y];\n\t\t\t\tfor(auto it = bp[x][y].begin(); it != bp[x][y].end(); it++){\n\t\t\t\t\tif(it->first + newarea > m2) continue;\n\t\t\t\t\tbp[x+1][y][it->first + newarea] += it->second;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(x+y+1 <= d) dp[x][y].clear();\n\t\t\tif(x+y+1 <= 2*n-d) bp[x][y].clear();\n\t\t}\n\n\t}\n\n\n\tfor(LL x = 0; x <= n; x++){\n\t\tLL y = d-x;\n\t\tif(y < 0 || y > n) continue;\n\t\t//cout << x << \" \" << y << endl;\n\t\tfor(auto it = dp[x][y].begin(); it != dp[x][y].end(); it++){\n\t\t\tLL c = it->first;\n\t\t\tLL freq = it->second;\n\t\t\t// bp[n-x][n-y]\n\t\t\tbestfreq += freq * bp[n-x][n-y][m1-c];\n\t\t\tif(m1 != m2) bestfreq += freq * bp[n-x][n-y][m2-c];\n\n\t\t}\n\t}\n\n\tcout << bestfreq << endl;\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8a938f2b70a82f4551db471e0b97e100", "src_uid": "1b978b5aed4a83a2250bb23cc1ad6f85", "difficulty": 3300.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef long long LL;\n\nLL ncr[40][40];\nLL ans[30][30];\n\n\nint main(){\n\tif(1){\n\t\tans[1][1]=0;\n\t\tans[1][2]=1;\n\t\tans[1][3]=0;\n\t\tans[1][4]=1;\n\t\tans[1][5]=0;\n\t\tans[1][6]=1;\n\t\tans[1][7]=0;\n\t\tans[1][8]=1;\n\t\tans[1][9]=0;\n\t\tans[1][10]=1;\n\t\tans[1][11]=0;\n\t\tans[1][12]=1;\n\t\tans[1][13]=0;\n\t\tans[1][14]=1;\n\t\tans[1][15]=0;\n\t\tans[1][16]=1;\n\t\tans[1][17]=0;\n\t\tans[1][18]=1;\n\t\tans[1][19]=0;\n\t\tans[1][20]=1;\n\t\tans[2][1]=3;\n\t\tans[2][2]=0;\n\t\tans[2][3]=2;\n\t\tans[2][4]=3;\n\t\tans[2][5]=1;\n\t\tans[2][6]=0;\n\t\tans[2][7]=0;\n\t\tans[2][8]=1;\n\t\tans[2][9]=1;\n\t\tans[2][10]=0;\n\t\tans[2][11]=0;\n\t\tans[2][12]=1;\n\t\tans[2][13]=1;\n\t\tans[2][14]=0;\n\t\tans[2][15]=0;\n\t\tans[2][16]=1;\n\t\tans[2][17]=1;\n\t\tans[2][18]=0;\n\t\tans[2][19]=0;\n\t\tans[2][20]=1;\n\t\tans[3][1]=8;\n\t\tans[3][2]=20;\n\t\tans[3][3]=0;\n\t\tans[3][4]=15;\n\t\tans[3][5]=16;\n\t\tans[3][6]=0;\n\t\tans[3][7]=0;\n\t\tans[3][8]=1;\n\t\tans[3][9]=0;\n\t\tans[3][10]=0;\n\t\tans[3][11]=0;\n\t\tans[3][12]=1;\n\t\tans[3][13]=0;\n\t\tans[3][14]=0;\n\t\tans[3][15]=0;\n\t\tans[3][16]=1;\n\t\tans[3][17]=0;\n\t\tans[3][18]=0;\n\t\tans[3][19]=0;\n\t\tans[3][20]=1;\n\t\tans[4][1]=15;\n\t\tans[4][2]=75;\n\t\tans[4][3]=175;\n\t\tans[4][4]=0;\n\t\tans[4][5]=4;\n\t\tans[4][6]=0;\n\t\tans[4][7]=0;\n\t\tans[4][8]=45;\n\t\tans[4][9]=15;\n\t\tans[4][10]=1;\n\t\tans[4][11]=1;\n\t\tans[4][12]=0;\n\t\tans[4][13]=0;\n\t\tans[4][14]=0;\n\t\tans[4][15]=0;\n\t\tans[4][16]=1;\n\t\tans[4][17]=1;\n\t\tans[4][18]=1;\n\t\tans[4][19]=1;\n\t\tans[4][20]=0;\n\t\tans[5][1]=24;\n\t\tans[5][2]=189;\n\t\tans[5][3]=784;\n\t\tans[5][4]=1764;\n\t\tans[5][5]=0;\n\t\tans[5][6]=0;\n\t\tans[5][7]=60;\n\t\tans[5][8]=95;\n\t\tans[5][9]=200;\n\t\tans[5][10]=1;\n\t\tans[5][11]=14;\n\t\tans[5][12]=14;\n\t\tans[5][13]=0;\n\t\tans[5][14]=4;\n\t\tans[5][15]=0;\n\t\tans[5][16]=1;\n\t\tans[5][17]=0;\n\t\tans[5][18]=1;\n\t\tans[5][19]=0;\n\t\tans[5][20]=0;\n\t\tans[6][1]=35;\n\t\tans[6][2]=392;\n\t\tans[6][3]=2352;\n\t\tans[6][4]=8820;\n\t\tans[6][5]=19404;\n\t\tans[6][6]=0;\n\t\tans[6][7]=6600;\n\t\tans[6][8]=553;\n\t\tans[6][9]=245;\n\t\tans[6][10]=10780;\n\t\tans[6][11]=658;\n\t\tans[6][12]=126;\n\t\tans[6][13]=56;\n\t\tans[6][14]=20;\n\t\tans[6][15]=0;\n\t\tans[6][16]=5;\n\t\tans[6][17]=5;\n\t\tans[6][18]=0;\n\t\tans[6][19]=0;\n\t\tans[6][20]=0;\n\t\tans[7][1]=48;\n\t\tans[7][2]=720;\n\t\tans[7][3]=5760;\n\t\tans[7][4]=29700;\n\t\tans[7][5]=104544;\n\t\tans[7][6]=226512;\n\t\tans[7][7]=0;\n\t\tans[7][8]=15015;\n\t\tans[7][9]=40040;\n\t\tans[7][10]=0;\n\t\tans[7][11]=1440;\n\t\tans[7][12]=2028;\n\t\tans[7][13]=432;\n\t\tans[7][14]=1280;\n\t\tans[7][15]=8;\n\t\tans[7][16]=249;\n\t\tans[7][17]=8;\n\t\tans[7][18]=20;\n\t\tans[7][19]=6;\n\t\tans[7][20]=4;\n\t\tans[8][1]=63;\n\t\tans[8][2]=1215;\n\t\tans[8][3]=12375;\n\t\tans[8][4]=81675;\n\t\tans[8][5]=382239;\n\t\tans[8][6]=1288287;\n\t\tans[8][7]=2760615;\n\t\tans[8][8]=0;\n\t\tans[8][9]=1635920;\n\t\tans[8][10]=198198;\n\t\tans[8][11]=534456;\n\t\tans[8][12]=4524;\n\t\tans[8][13]=1546;\n\t\tans[8][14]=111564;\n\t\tans[8][15]=4050;\n\t\tans[8][16]=621;\n\t\tans[8][17]=3069;\n\t\tans[8][18]=5;\n\t\tans[8][19]=43;\n\t\tans[8][20]=1;\n\t\tans[9][1]=80;\n\t\tans[9][2]=1925;\n\t\tans[9][3]=24200;\n\t\tans[9][4]=196625;\n\t\tans[9][5]=1145144;\n\t\tans[9][6]=5010005;\n\t\tans[9][7]=16359200;\n\t\tans[9][8]=34763300;\n\t\tans[9][9]=0;\n\t\tans[9][10]=34606;\n\t\tans[9][11]=701350;\n\t\tans[9][12]=6651840;\n\t\tans[9][13]=78298;\n\t\tans[9][14]=429418;\n\t\tans[9][15]=872494;\n\t\tans[9][16]=1615;\n\t\tans[9][17]=352;\n\t\tans[9][18]=1155;\n\t\tans[9][19]=8580;\n\t\tans[9][20]=145;\n\t\tans[10][1]=99;\n\t\tans[10][2]=2904;\n\t\tans[10][3]=44044;\n\t\tans[10][4]=429429;\n\t\tans[10][5]=3006003;\n\t\tans[10][6]=16032016;\n\t\tans[10][7]=66745536;\n\t\tans[10][8]=212751396;\n\t\tans[10][9]=449141836;\n\t\tans[10][10]=0;\n\t\tans[10][11]=11675872;\n\t\tans[10][12]=4900324;\n\t\tans[10][13]=980474;\n\t\tans[10][14]=120143080;\n\t\tans[10][15]=47159156;\n\t\tans[10][16]=380171;\n\t\tans[10][17]=35871;\n\t\tans[10][18]=2207348;\n\t\tans[10][19]=223498;\n\t\tans[10][20]=4875;\n\t\tans[11][1]=120;\n\t\tans[11][2]=4212;\n\t\tans[11][3]=75712;\n\t\tans[11][4]=869505;\n\t\tans[11][5]=7154784;\n\t\tans[11][6]=45048640;\n\t\tans[11][7]=225059328;\n\t\tans[11][8]=901995588;\n\t\tans[11][9]=2821056160;\n\t\tans[11][10]=5924217936;\n\t\tans[11][11]=0;\n\t\tans[11][12]=1763160100;\n\t\tans[11][13]=1014736800;\n\t\tans[11][14]=96243664;\n\t\tans[11][15]=527663136;\n\t\tans[11][16]=13024737;\n\t\tans[11][17]=1152008;\n\t\tans[11][18]=27986506;\n\t\tans[11][19]=835384;\n\t\tans[12][1]=143;\n\t\tans[12][2]=5915;\n\t\tans[12][3]=124215;\n\t\tans[12][4]=1656200;\n\t\tans[12][5]=15767024;\n\t\tans[12][6]=114874032;\n\t\tans[12][7]=668144880;\n\t\tans[12][8]=3173688180;\n\t\tans[12][9]=12342120700;\n\t\tans[12][10]=38013731756;\n\t\tans[12][11]=79483257308;\n\t\tans[12][12]=0;\n\t\tans[12][13]=334424;\n\t\tans[12][14]=86230664;\n\t\tans[12][15]=401457992;\n\t\tans[12][16]=1811255769;\n\t\tans[12][17]=8782619185;\n\t\tans[12][18]=524739891;\n\t\tans[13][1]=168;\n\t\tans[13][2]=8085;\n\t\tans[13][3]=196000;\n\t\tans[13][4]=2998800;\n\t\tans[13][5]=32626944;\n\t\tans[13][6]=271211472;\n\t\tans[13][7]=1802805120;\n\t\tans[13][8]=9859090500;\n\t\tans[13][9]=44986664800;\n\t\tans[13][10]=170724392916;\n\t\tans[13][11]=519227905728;\n\t\tans[13][12]=1081724803600;\n\t\tans[13][13]=0;\n\t\tans[13][14]=5856160;\n\t\tans[13][15]=0;\n\t\tans[13][16]=208030461065;\n\t\tans[13][17]=743483832;\n\t\tans[14][1]=195;\n\t\tans[14][2]=10800;\n\t\tans[14][3]=299200;\n\t\tans[14][4]=5202000;\n\t\tans[14][5]=64047024;\n\t\tans[14][6]=600935040;\n\t\tans[14][7]=4507012800;\n\t\tans[14][8]=27887141700;\n\t\tans[14][9]=145173803500;\n\t\tans[14][10]=641087516256;\n\t\tans[14][11]=2384209771200;\n\t\tans[14][12]=7174705330000;\n\t\tans[14][13]=14901311070000;\n\t\tans[14][14]=0;\n\t\tans[14][15]=262032716400;\n\t\tans[14][16]=2131715333625;\n\t\tans[15][1]=224;\n\t\tans[15][2]=14144;\n\t\tans[15][3]=443904;\n\t\tans[15][4]=8697744;\n\t\tans[15][5]=120187008;\n\t\tans[15][6]=1261963584;\n\t\tans[15][7]=10576456704;\n\t\tans[15][8]=73167596964;\n\t\tans[15][9]=427391677504;\n\t\tans[15][10]=2136958387520;\n\t\tans[15][11]=9183622822400;\n\t\tans[15][12]=33577620944400;\n\t\tans[15][13]=100136810390400;\n\t\tans[15][14]=207426250094400;\n\t\tans[15][15]=0;\n\t\tans[16][1]=255;\n\t\tans[16][2]=18207;\n\t\tans[16][3]=642447;\n\t\tans[16][4]=14084415;\n\t\tans[16][5]=216899991;\n\t\tans[16][6]=2530499895;\n\t\tans[16][7]=23518156167;\n\t\tans[16][8]=180305863947;\n\t\tans[16][9]=1168649118175;\n\t\tans[16][10]=6511045086975;\n\t\tans[16][11]=31479019635375;\n\t\tans[16][12]=132211882468575;\n\t\tans[16][13]=476432168185575;\n\t\tans[16][14]=1409850293610375;\n\t\tans[17][1]=288;\n\t\tans[17][2]=23085;\n\t\tans[17][3]=909720;\n\t\tans[17][4]=22174425;\n\t\tans[17][5]=378261576;\n\t\tans[17][6]=4873620213;\n\t\tans[17][7]=49911657840;\n\t\tans[17][8]=421129613025;\n\t\tans[17][9]=3003942370000;\n\t\tans[17][10]=18451716007725;\n\t\tans[17][11]=98815801429800;\n\t\tans[17][12]=464342770607625;\n\t\tans[17][13]=1912322889603000;\n\t\tans[18][1]=323;\n\t\tans[18][2]=28880;\n\t\tans[18][3]=1263500;\n\t\tans[18][4]=34051325;\n\t\tans[18][5]=639970331;\n\t\tans[18][6]=9058041608;\n\t\tans[18][7]=101671895600;\n\t\tans[18][8]=938731990625;\n\t\tans[18][9]=7322109526875;\n\t\tans[18][10]=49204576020600;\n\t\tans[18][11]=288924390600300;\n\t\tans[18][12]=1496215594180125;\n\t\tans[19][1]=360;\n\t\tans[19][2]=35700;\n\t\tans[19][3]=1724800;\n\t\tans[19][4]=51137625;\n\t\tans[19][5]=1053844176;\n\t\tans[19][6]=16309493200;\n\t\tans[19][7]=199708080000;\n\t\tans[19][8]=2008002335625;\n\t\tans[19][9]=17037595575000;\n\t\tans[19][10]=124510748462100;\n\t\tans[19][11]=795771174744000;\n\t\tans[20][1]=399;\n\t\tans[20][2]=43659;\n\t\tans[20][3]=2318239;\n\t\tans[20][4]=75274584;\n\t\tans[20][5]=1693678140;\n\t\tans[20][6]=28541613100;\n\t\tans[20][7]=379694987100;\n\t\tans[20][8]=4140135724725;\n\t\tans[20][9]=38044950918975;\n\t\tans[20][10]=300900975450075;\n\n\t}\n\n\tfor(LL a = 0; a < 40; a++){\n\t\tfor(LL b = 0; b < 40; b++){\n\t\t\tif(b > a){\n\t\t\t\tncr[a][b] = 0;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif(b == 0 || b == a){\n\t\t\t\tncr[a][b] = 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tncr[a][b] = ncr[a-1][b-1] + ncr[a-1][b];\n\t\t}\n\t}\n\tLL R, C;\n\tcin >> R >> C;\n\tstring str;\n\tcin >> str;\n\tLL n = R+C;\n\tLL blockarea[n][n];\n\tLL totalarea[n+1][n+1];\n\tfor(LL a = 0; a < n; a++){\n\t\tfor(LL b = 0; b < n; b++){\n\t\t\tblockarea[a][b] = ncr[a][R-1]*ncr[b][R-1];\n\t\t}\n\t}\n\tfor(LL a = 0; a <= n; a++){\n\t\tfor(LL b = 0; b <= n; b++){\n\t\t\ttotalarea[a][b] = 0;\n\t\t\tif(a == 0 || b == 0) continue;\n\t\t\ttotalarea[a][b] = totalarea[a][b-1] + totalarea[a-1][b] - totalarea[a-1][b-1];\n\t\t\ttotalarea[a][b] += blockarea[a-1][b-1];\n\t\t}\n\t}\n\n\tLL d = min(2*n-1,n+R-4);\n\n\tmap dp[n+1][n+1];\n\tmap bp[n+1][n+1];\n\tdp[0][0][0] = 1;\n\tbp[0][0][0] = 1;\n\n\tLL best = ans[R][C];\n\tLL m1 = (-best + totalarea[n][n]) / 2;\n\tLL m2 = totalarea[n][n] - m1;\n\tLL bestfreq = 0;\n\n\tfor(LL x = 0; x <= n; x++){\n\t\tfor(LL y = 0; y < n; y++){\n\t\t\tif(x+y+1 <= d && str[x+y] != 'B'){\n\t\t\t\tfor(auto it = dp[x][y].begin(); it != dp[x][y].end(); it++){\n\t\t\t\t\tif(it->first > m2) continue;\n\t\t\t\t\tdp[x][y+1][it->first] += it->second;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(x+y+1 <= 2*n-d && str[n-x+n-y-1] != 'B'){\n\t\t\t\tfor(auto it = bp[x][y].begin(); it != bp[x][y].end(); it++){\n\t\t\t\t\tif(it->first > m2) continue;\n\t\t\t\t\tbp[x][y+1][it->first] += it->second;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(x == n) continue;\n\t\tfor(LL y = 0; y <= n; y++){\n\n\t\t\tif(x+y+1 <= d && str[x+y] != 'A'){\n\t\t\t\tLL newarea = totalarea[x+1][y] - totalarea[x][y];\n\t\t\t\tfor(auto it = dp[x][y].begin(); it != dp[x][y].end(); it++){\n\t\t\t\t\tif(it->first + newarea > m2) continue;\t\t\t\t\t\n\t\t\t\t\tdp[x+1][y][it->first + newarea] += it->second;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(x+y+1 <= 2*n-d && str[n-x+n-y-1] != 'A'){\n\t\t\t\tLL newarea2 = totalarea[n-x][n-y] - totalarea[n-x-1][n-y];\n\t\t\t\tfor(auto it = bp[x][y].begin(); it != bp[x][y].end(); it++){\n\t\t\t\t\tif(it->first + newarea2 > m2) continue;\t\t\t\t\t\n\t\t\t\t\tbp[x+1][y][it->first + newarea2] += it->second;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(x+y+1 <= d) dp[x][y].clear();\n\t\t\tif(x+y+1 <= 2*n-d) bp[x][y].clear();\n\t\t}\n\n\t}\n\n\n\tfor(LL x = 0; x <= n; x++){\n\t\tLL y = d-x;\n\t\tif(y < 0 || y > n) continue;\n\t\t//cout << x << \" \" << y << endl;\n\t\tfor(auto it = dp[x][y].begin(); it != dp[x][y].end(); it++){\n\t\t\tLL c = it->first;\n\t\t\tLL freq = it->second;\n\t\t\t// bp[n-x][n-y]\n\t\t\tbestfreq += freq * bp[n-x][n-y][m1-c];\n\t\t\tif(m1 != m2) bestfreq += freq * bp[n-x][n-y][m2-c];\n\n\t\t}\n\t}\n\n\tcout << bestfreq << endl;\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8b139bb65d12175ecfde46cb9ca095be", "src_uid": "1b978b5aed4a83a2250bb23cc1ad6f85", "difficulty": 3300.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef long long LL;\n\nLL ncr[40][40];\nLL ans[30][30];\n\n\nint main(){\n\tif(1){\n\t\tans[1][1]=0;\n\t\tans[1][2]=1;\n\t\tans[1][3]=0;\n\t\tans[1][4]=1;\n\t\tans[1][5]=0;\n\t\tans[1][6]=1;\n\t\tans[1][7]=0;\n\t\tans[1][8]=1;\n\t\tans[1][9]=0;\n\t\tans[1][10]=1;\n\t\tans[1][11]=0;\n\t\tans[1][12]=1;\n\t\tans[1][13]=0;\n\t\tans[1][14]=1;\n\t\tans[1][15]=0;\n\t\tans[1][16]=1;\n\t\tans[1][17]=0;\n\t\tans[1][18]=1;\n\t\tans[1][19]=0;\n\t\tans[1][20]=1;\n\t\tans[2][1]=3;\n\t\tans[2][2]=0;\n\t\tans[2][3]=2;\n\t\tans[2][4]=3;\n\t\tans[2][5]=1;\n\t\tans[2][6]=0;\n\t\tans[2][7]=0;\n\t\tans[2][8]=1;\n\t\tans[2][9]=1;\n\t\tans[2][10]=0;\n\t\tans[2][11]=0;\n\t\tans[2][12]=1;\n\t\tans[2][13]=1;\n\t\tans[2][14]=0;\n\t\tans[2][15]=0;\n\t\tans[2][16]=1;\n\t\tans[2][17]=1;\n\t\tans[2][18]=0;\n\t\tans[2][19]=0;\n\t\tans[2][20]=1;\n\t\tans[3][1]=8;\n\t\tans[3][2]=20;\n\t\tans[3][3]=0;\n\t\tans[3][4]=15;\n\t\tans[3][5]=16;\n\t\tans[3][6]=0;\n\t\tans[3][7]=0;\n\t\tans[3][8]=1;\n\t\tans[3][9]=0;\n\t\tans[3][10]=0;\n\t\tans[3][11]=0;\n\t\tans[3][12]=1;\n\t\tans[3][13]=0;\n\t\tans[3][14]=0;\n\t\tans[3][15]=0;\n\t\tans[3][16]=1;\n\t\tans[3][17]=0;\n\t\tans[3][18]=0;\n\t\tans[3][19]=0;\n\t\tans[3][20]=1;\n\t\tans[4][1]=15;\n\t\tans[4][2]=75;\n\t\tans[4][3]=175;\n\t\tans[4][4]=0;\n\t\tans[4][5]=4;\n\t\tans[4][6]=0;\n\t\tans[4][7]=0;\n\t\tans[4][8]=45;\n\t\tans[4][9]=15;\n\t\tans[4][10]=1;\n\t\tans[4][11]=1;\n\t\tans[4][12]=0;\n\t\tans[4][13]=0;\n\t\tans[4][14]=0;\n\t\tans[4][15]=0;\n\t\tans[4][16]=1;\n\t\tans[4][17]=1;\n\t\tans[4][18]=1;\n\t\tans[4][19]=1;\n\t\tans[4][20]=0;\n\t\tans[5][1]=24;\n\t\tans[5][2]=189;\n\t\tans[5][3]=784;\n\t\tans[5][4]=1764;\n\t\tans[5][5]=0;\n\t\tans[5][6]=0;\n\t\tans[5][7]=60;\n\t\tans[5][8]=95;\n\t\tans[5][9]=200;\n\t\tans[5][10]=1;\n\t\tans[5][11]=14;\n\t\tans[5][12]=14;\n\t\tans[5][13]=0;\n\t\tans[5][14]=4;\n\t\tans[5][15]=0;\n\t\tans[5][16]=1;\n\t\tans[5][17]=0;\n\t\tans[5][18]=1;\n\t\tans[5][19]=0;\n\t\tans[5][20]=0;\n\t\tans[6][1]=35;\n\t\tans[6][2]=392;\n\t\tans[6][3]=2352;\n\t\tans[6][4]=8820;\n\t\tans[6][5]=19404;\n\t\tans[6][6]=0;\n\t\tans[6][7]=6600;\n\t\tans[6][8]=553;\n\t\tans[6][9]=245;\n\t\tans[6][10]=10780;\n\t\tans[6][11]=658;\n\t\tans[6][12]=126;\n\t\tans[6][13]=56;\n\t\tans[6][14]=20;\n\t\tans[6][15]=0;\n\t\tans[6][16]=5;\n\t\tans[6][17]=5;\n\t\tans[6][18]=0;\n\t\tans[6][19]=0;\n\t\tans[6][20]=0;\n\t\tans[7][1]=48;\n\t\tans[7][2]=720;\n\t\tans[7][3]=5760;\n\t\tans[7][4]=29700;\n\t\tans[7][5]=104544;\n\t\tans[7][6]=226512;\n\t\tans[7][7]=0;\n\t\tans[7][8]=15015;\n\t\tans[7][9]=40040;\n\t\tans[7][10]=0;\n\t\tans[7][11]=1440;\n\t\tans[7][12]=2028;\n\t\tans[7][13]=432;\n\t\tans[7][14]=1280;\n\t\tans[7][15]=8;\n\t\tans[7][16]=249;\n\t\tans[7][17]=8;\n\t\tans[7][18]=20;\n\t\tans[7][19]=6;\n\t\tans[7][20]=4;\n\t\tans[8][1]=63;\n\t\tans[8][2]=1215;\n\t\tans[8][3]=12375;\n\t\tans[8][4]=81675;\n\t\tans[8][5]=382239;\n\t\tans[8][6]=1288287;\n\t\tans[8][7]=2760615;\n\t\tans[8][8]=0;\n\t\tans[8][9]=1635920;\n\t\tans[8][10]=198198;\n\t\tans[8][11]=534456;\n\t\tans[8][12]=4524;\n\t\tans[8][13]=1546;\n\t\tans[8][14]=111564;\n\t\tans[8][15]=4050;\n\t\tans[8][16]=621;\n\t\tans[8][17]=3069;\n\t\tans[8][18]=5;\n\t\tans[8][19]=43;\n\t\tans[8][20]=1;\n\t\tans[9][1]=80;\n\t\tans[9][2]=1925;\n\t\tans[9][3]=24200;\n\t\tans[9][4]=196625;\n\t\tans[9][5]=1145144;\n\t\tans[9][6]=5010005;\n\t\tans[9][7]=16359200;\n\t\tans[9][8]=34763300;\n\t\tans[9][9]=0;\n\t\tans[9][10]=34606;\n\t\tans[9][11]=701350;\n\t\tans[9][12]=6651840;\n\t\tans[9][13]=78298;\n\t\tans[9][14]=429418;\n\t\tans[9][15]=872494;\n\t\tans[9][16]=1615;\n\t\tans[9][17]=352;\n\t\tans[9][18]=1155;\n\t\tans[9][19]=8580;\n\t\tans[9][20]=145;\n\t\tans[10][1]=99;\n\t\tans[10][2]=2904;\n\t\tans[10][3]=44044;\n\t\tans[10][4]=429429;\n\t\tans[10][5]=3006003;\n\t\tans[10][6]=16032016;\n\t\tans[10][7]=66745536;\n\t\tans[10][8]=212751396;\n\t\tans[10][9]=449141836;\n\t\tans[10][10]=0;\n\t\tans[10][11]=11675872;\n\t\tans[10][12]=4900324;\n\t\tans[10][13]=980474;\n\t\tans[10][14]=120143080;\n\t\tans[10][15]=47159156;\n\t\tans[10][16]=380171;\n\t\tans[10][17]=35871;\n\t\tans[10][18]=2207348;\n\t\tans[10][19]=223498;\n\t\tans[10][20]=4875;\n\t\tans[11][1]=120;\n\t\tans[11][2]=4212;\n\t\tans[11][3]=75712;\n\t\tans[11][4]=869505;\n\t\tans[11][5]=7154784;\n\t\tans[11][6]=45048640;\n\t\tans[11][7]=225059328;\n\t\tans[11][8]=901995588;\n\t\tans[11][9]=2821056160;\n\t\tans[11][10]=5924217936;\n\t\tans[11][11]=0;\n\t\tans[11][12]=1763160100;\n\t\tans[11][13]=1014736800;\n\t\tans[11][14]=96243664;\n\t\tans[11][15]=527663136;\n\t\tans[11][16]=13024737;\n\t\tans[11][17]=1152008;\n\t\tans[11][18]=27986506;\n\t\tans[11][19]=835384;\n\t\tans[12][1]=143;\n\t\tans[12][2]=5915;\n\t\tans[12][3]=124215;\n\t\tans[12][4]=1656200;\n\t\tans[12][5]=15767024;\n\t\tans[12][6]=114874032;\n\t\tans[12][7]=668144880;\n\t\tans[12][8]=3173688180;\n\t\tans[12][9]=12342120700;\n\t\tans[12][10]=38013731756;\n\t\tans[12][11]=79483257308;\n\t\tans[12][12]=0;\n\t\tans[12][13]=334424;\n\t\tans[12][14]=86230664;\n\t\tans[12][15]=401457992;\n\t\tans[12][16]=1811255769;\n\t\tans[12][17]=8782619185;\n\t\tans[12][18]=524739891;\n\t\tans[13][1]=168;\n\t\tans[13][2]=8085;\n\t\tans[13][3]=196000;\n\t\tans[13][4]=2998800;\n\t\tans[13][5]=32626944;\n\t\tans[13][6]=271211472;\n\t\tans[13][7]=1802805120;\n\t\tans[13][8]=9859090500;\n\t\tans[13][9]=44986664800;\n\t\tans[13][10]=170724392916;\n\t\tans[13][11]=519227905728;\n\t\tans[13][12]=1081724803600;\n\t\tans[13][13]=0;\n\t\tans[13][14]=5856160;\n\t\tans[13][15]=0;\n\t\tans[13][16]=208030461065;\n\t\tans[13][17]=743483832;\n\t\tans[14][1]=195;\n\t\tans[14][2]=10800;\n\t\tans[14][3]=299200;\n\t\tans[14][4]=5202000;\n\t\tans[14][5]=64047024;\n\t\tans[14][6]=600935040;\n\t\tans[14][7]=4507012800;\n\t\tans[14][8]=27887141700;\n\t\tans[14][9]=145173803500;\n\t\tans[14][10]=641087516256;\n\t\tans[14][11]=2384209771200;\n\t\tans[14][12]=7174705330000;\n\t\tans[14][13]=14901311070000;\n\t\tans[14][14]=0;\n\t\tans[14][15]=262032716400;\n\t\tans[14][16]=2131715333625;\n\t\tans[15][1]=224;\n\t\tans[15][2]=14144;\n\t\tans[15][3]=443904;\n\t\tans[15][4]=8697744;\n\t\tans[15][5]=120187008;\n\t\tans[15][6]=1261963584;\n\t\tans[15][7]=10576456704;\n\t\tans[15][8]=73167596964;\n\t\tans[15][9]=427391677504;\n\t\tans[15][10]=2136958387520;\n\t\tans[15][11]=9183622822400;\n\t\tans[15][12]=33577620944400;\n\t\tans[15][13]=100136810390400;\n\t\tans[15][14]=207426250094400;\n\t\tans[15][15]=0;\n\t\tans[16][1]=255;\n\t\tans[16][2]=18207;\n\t\tans[16][3]=642447;\n\t\tans[16][4]=14084415;\n\t\tans[16][5]=216899991;\n\t\tans[16][6]=2530499895;\n\t\tans[16][7]=23518156167;\n\t\tans[16][8]=180305863947;\n\t\tans[16][9]=1168649118175;\n\t\tans[16][10]=6511045086975;\n\t\tans[16][11]=31479019635375;\n\t\tans[16][12]=132211882468575;\n\t\tans[16][13]=476432168185575;\n\t\tans[16][14]=1409850293610375;\n\t\tans[17][1]=288;\n\t\tans[17][2]=23085;\n\t\tans[17][3]=909720;\n\t\tans[17][4]=22174425;\n\t\tans[17][5]=378261576;\n\t\tans[17][6]=4873620213;\n\t\tans[17][7]=49911657840;\n\t\tans[17][8]=421129613025;\n\t\tans[17][9]=3003942370000;\n\t\tans[17][10]=18451716007725;\n\t\tans[17][11]=98815801429800;\n\t\tans[17][12]=464342770607625;\n\t\tans[17][13]=1912322889603000;\n\t\tans[18][1]=323;\n\t\tans[18][2]=28880;\n\t\tans[18][3]=1263500;\n\t\tans[18][4]=34051325;\n\t\tans[18][5]=639970331;\n\t\tans[18][6]=9058041608;\n\t\tans[18][7]=101671895600;\n\t\tans[18][8]=938731990625;\n\t\tans[18][9]=7322109526875;\n\t\tans[18][10]=49204576020600;\n\t\tans[18][11]=288924390600300;\n\t\tans[18][12]=1496215594180125;\n\t\tans[19][1]=360;\n\t\tans[19][2]=35700;\n\t\tans[19][3]=1724800;\n\t\tans[19][4]=51137625;\n\t\tans[19][5]=1053844176;\n\t\tans[19][6]=16309493200;\n\t\tans[19][7]=199708080000;\n\t\tans[19][8]=2008002335625;\n\t\tans[19][9]=17037595575000;\n\t\tans[19][10]=124510748462100;\n\t\tans[19][11]=795771174744000;\n\t\tans[20][1]=399;\n\t\tans[20][2]=43659;\n\t\tans[20][3]=2318239;\n\t\tans[20][4]=75274584;\n\t\tans[20][5]=1693678140;\n\t\tans[20][6]=28541613100;\n\t\tans[20][7]=379694987100;\n\t\tans[20][8]=4140135724725;\n\t\tans[20][9]=38044950918975;\n\t\tans[20][10]=300900975450075;\n\n\t}\n\n\tfor(LL a = 0; a < 40; a++){\n\t\tfor(LL b = 0; b < 40; b++){\n\t\t\tif(b > a){\n\t\t\t\tncr[a][b] = 0;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif(b == 0 || b == a){\n\t\t\t\tncr[a][b] = 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tncr[a][b] = ncr[a-1][b-1] + ncr[a-1][b];\n\t\t}\n\t}\n\tLL R, C;\n\tcin >> R >> C;\n\tstring str;\n\tcin >> str;\n\tLL n = R+C;\n\tLL blockarea[n][n];\n\tLL totalarea[n+1][n+1];\n\tfor(LL a = 0; a < n; a++){\n\t\tfor(LL b = 0; b < n; b++){\n\t\t\tblockarea[a][b] = ncr[a][R-1]*ncr[b][R-1];\n\t\t}\n\t}\n\tfor(LL a = 0; a <= n; a++){\n\t\tfor(LL b = 0; b <= n; b++){\n\t\t\ttotalarea[a][b] = 0;\n\t\t\tif(a == 0 || b == 0) continue;\n\t\t\ttotalarea[a][b] = totalarea[a][b-1] + totalarea[a-1][b] - totalarea[a-1][b-1];\n\t\t\ttotalarea[a][b] += blockarea[a-1][b-1];\n\t\t}\n\t}\n\n\tLL d = min(2*n-1,n+R);\n\n\tmap dp[n+1][n+1];\n\tmap bp[n+1][n+1];\n\tdp[0][0][0] = 1;\n\tbp[0][0][0] = 1;\n\n\tLL best = ans[R][C];\n\tLL m1 = (-best + totalarea[n][n]) / 2;\n\tLL m2 = totalarea[n][n] - m1;\n\tLL bestfreq = 0;\n\n\tfor(LL x = 0; x <= n; x++){\n\t\tfor(LL y = 0; y < n; y++){\n\t\t\tif(x+y+1 <= d && str[x+y] != 'B'){\n\t\t\t\tfor(auto it = dp[x][y].begin(); it != dp[x][y].end(); it++){\n\t\t\t\t\tif(it->first > m2) continue;\n\t\t\t\t\tdp[x][y+1][it->first] += it->second;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(x+y+1 <= 2*n-d && str[n-x+n-y-1] != 'B'){\n\t\t\t\tfor(auto it = bp[x][y].begin(); it != bp[x][y].end(); it++){\n\t\t\t\t\tif(it->first > m2) continue;\n\t\t\t\t\tbp[x][y+1][it->first] += it->second;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(x == n) continue;\n\t\tfor(LL y = 0; y <= n; y++){\n\n\t\t\tif(x+y+1 <= d && str[x+y] != 'A'){\n\t\t\t\tLL newarea = totalarea[x+1][y] - totalarea[x][y];\n\t\t\t\tfor(auto it = dp[x][y].begin(); it != dp[x][y].end(); it++){\n\t\t\t\t\tif(it->first + newarea > m2) continue;\t\t\t\t\t\n\t\t\t\t\tdp[x+1][y][it->first + newarea] += it->second;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(x+y+1 <= 2*n-d && str[n-x+n-y-1] != 'A'){\n\t\t\t\tLL newarea2 = totalarea[n-x][n-y] - totalarea[n-x-1][n-y];\n\t\t\t\tfor(auto it = bp[x][y].begin(); it != bp[x][y].end(); it++){\n\t\t\t\t\tif(it->first + newarea2 > m2) continue;\t\t\t\t\t\n\t\t\t\t\tbp[x+1][y][it->first + newarea2] += it->second;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(x+y+1 <= d) dp[x][y].clear();\n\t\t\tif(x+y+1 <= 2*n-d) bp[x][y].clear();\n\t\t}\n\n\t}\n\n\n\tfor(LL x = 0; x <= n; x++){\n\t\tLL y = d-x;\n\t\tif(y < 0 || y > n) continue;\n\t\t//cout << x << \" \" << y << endl;\n\t\tfor(auto it = dp[x][y].begin(); it != dp[x][y].end(); it++){\n\t\t\tLL c = it->first;\n\t\t\tLL freq = it->second;\n\t\t\t// bp[n-x][n-y]\n\t\t\tbestfreq += freq * bp[n-x][n-y][m1-c];\n\t\t\tif(m1 != m2) bestfreq += freq * bp[n-x][n-y][m2-c];\n\n\t\t}\n\t}\n\n\tcout << bestfreq << endl;\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "06f157fcda6798c08b26f5d39d7b8513", "src_uid": "1b978b5aed4a83a2250bb23cc1ad6f85", "difficulty": 3300.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\nconst int N=500,INF=1<<30;\nint nxt[N],a[N][N],n,x,rank[N][N],now;\nchar s[10];\nqueue q;\n\nvoid init()\n{\n\tscanf(\"%d\",&n);\n\tfor (int i=1;i<=n;i++)\n\t\tfor (int j=1;j<=n;j++)\n\t\t\tscanf(\"%d\",&a[i][j]);\n\tputs(\"B\");fflush(stdout);\n\tscanf(\"%s\",s);\n\tif(s[0]=='I')\n\t{\n\t\tfor (int i=1;i<=n;i++)\n\t\t\tfor (int j=1;j<=n;j++)\n\t\t\t\ta[i][j]=-a[i][j];\n\t}\n\tscanf(\"%d\",&x);\n\tif(x>n)\n\t\tfor (int i=1;i<=n;i++)\n\t\t\tfor (int j=1;j<=n;j++)\n\t\t\t\ta[i][j]=-a[i][j];\n}\n\nbool cmp(int x,int y)\n{\n\treturn a[now][x-n]>a[now][y-n];\n}\n\nvoid prework()\n{\n\tfor (int i=1;i<=n;i++)\n\t{\n\t\tfor (int j=1;j<=n;j++)\n\t\t\trank[i][j]=j+n;\n\t\tnow=i;\n\t\tsort(rank[i]+1,rank[i]+1+n,cmp);\n\t\tq.push(i);\n\t}\n//\tfor (int i=1;i<=n;i++,putchar('\\n'))\n//\t\tfor (int j=1;j<=n;j++)\n//\t\t\tprintf(\"%d \",rank[i][j]);\n\tfor (int i=1;i<=n;i++)\n\t\ta[0][i]=a[i][0]=INF;\n\twhile(!q.empty())\n\t{\n\t\tint x=q.front();q.pop();\n\t\tif(x==0) continue;\n\t\twhile(nxt[x]==0)\n\t\t{\n\t\t\tint girl=rank[x][++*rank[x]];\n\t\t\tif(a[x][girl-n]\n#define M 105\n#define MP std::make_pair\n#define PB push_back\n#define FI first\n#define SE second\n#define INF 1000000005\ntypedef long long ll;\nint n, a[M][M], match[M];\nstd::vector Vec[M];\nint read() {\n\tint ans = 0; char c = getchar();\n\twhile (c < '0' || c > '9') c = getchar();\n\twhile (c >= '0' && c <= '9') ans = ans * 10 + c - '0', c = getchar();\n\treturn ans;\n}\nvoid Write(int x) {\n\tif (x < 10) putchar(x + '0');\n\telse Write(x / 10), putchar(x % 10 + '0');\n}\nint max(int x, int y) {return x > y ? x : y;}\nint min(int x, int y) {return x < y ? x : y;}\nvoid solve() {\n\tfor (int i = 1; i <= n; i++) {\n\t\tfor (int j = 1; j <= n; j++) Vec[i].PB(j + n), Vec[i + n].PB(j);\n\t\tstd::sort(Vec[i].begin(), Vec[i].end(), [&](int x, int y) {return a[i][x] > a[i][y];});\n\t\tstd::sort(Vec[i + n].begin(), Vec[i + n].end(), [&](int x, int y) {return a[x][i + n] < a[y][i + n];});\n\t}\n\tfor (int _ = 0; _ < n; _++)\n\t\tfor (int i = 1; i <= n; i++) {\n\t\t\tif (match[i]) continue;\n\t\t\tif (!match[Vec[i][_]]) match[i] = Vec[i][_], match[Vec[i][_]] = i;\n\t\t\telse if (a[match[Vec[i][_]]][Vec[i][_]] > a[i][Vec[i][_]])\n\t\t\t\tmatch[match[Vec[i][_]]] = 0, match[i] = Vec[i][_], match[Vec[i][_]] = i;\n\t\t}\n\treturn;\n}\nint main() {\n\tstd::cin >> t;\n\twhile (t--) {\n\t\tstd::cin >> n;\n\t\tfor (int i = 1; i <= n; i++)\n\t\t\tfor (int j = 1; j <= n; j++) a[i][j + n] = read();\n\t\tstd::cout << 'B' << std::endl;\n\t\tchar c; std::cin >> c;\n\t\tif (c == 'I')\n\t\t\tfor (int i = 1; i <= n; i++)\n\t\t\t\tfor (int j = 1; j <= n; j++) a[i][j] = -a[i][j];\n\t\tint tmp; std::cin >> tmp;\n\t\tif (tmp > n)\n\t\t\tfor (int i = 1; i <= n; i++)\n\t\t\t\tfor (int j = 1; j <= n; j++) a[i][j] = -a[i][j];\n\t\tsolve();\n\t\tdo {\n\t\t\tstd::cout << match[tmp] << std::endl;\n\t\t\tstd::cin >> tmp;\n\t\t}while (tmp != -1);\n\t\tfor (int i = 1; i <= n * 2; i++) match[i] = 0, Vec[i].clear();\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "a17dba812d706bcca23aeed60fcff4f2", "src_uid": "299c209b070e510e7ed3b525f51fec8a", "difficulty": 3500.0} {"lang": "GNU C++17", "source_code": "\n#include \nusing namespace std;\n\n// io\n#define get(i) scanf(\"%d\", &i)\n#define flush fflush(stdin)\n\n// manipulations\n#define f(i, n) for (int i = 0; i < n; i++)\n#define fr(i, n) for (int i = n - 1; i >= 0; i--)\n#define ff(i, a, b) for (int i = a; i <= b; i++)\n#define lowbit(x) (x & -x)\n#define sz(x) int((x).size())\n\n// built-in\n#define bitcount __builtin_popcount\n#define gcd __gcd\n\n// short\n#define pb push_back\n#define fill(arr, a) memset(arr, a, sizeof(arr))\n\n// useful bits\n#define IN(i, l, r) (l <= i && i <= r)\n#define relax(a, b) (a) = max((a), (b))\n#define relaxi(a, b) (a) = min((a), (b))\n\nusing ll = long long;\nusing ld = long double;\nusing vi = vector;\nusing vll = vector;\nusing pii = pair;\nusing pll = pair;\n\nll modpow(ll a, ll b, ll mod = (ll) (1e9 + 7)) \n{if (!b) return 1; a %= mod; return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod;}\n\n// for rand\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n// use uniform_int_distribution(0, i)(rng)\n\nconst int DEBUG = 0;\nconst int mxn = 100, mxm = 2500;\nint n,m;\nint p[mxn];\nvi adj[mxn];\nint a[mxm], b[mxm], c[mxm];\n\nvoid flip() {\n\tf(i,n) swap(adj[i],adj[i+n]);\n\tf(e,m) a[e]+=n, b[e]-=n;\n}\n\nvoid flipSign() {\n\tf(i,m) c[i]*=-1;\n}\n\nint fi(int v) {\n\tint e = adj[v][p[v]];\n\treturn a[e]^b[e]^v;\n}\n\nvoid solve() {\n\tcin>>n; m=0;\n\tf(i,n) {\n\t\tf(j,n) {\n\t\t\ta[m]=i; b[m]=j+n;\n\t\t\tadj[a[m]].pb(m); adj[b[m]].pb(m);\n\t\t\tcin>>c[m++];\t\n\t\t}\n\t}\n\tcout << \"B\" << endl;\n\tflush;\n\tstring cmd; cin>>cmd;\n\tif (cmd == \"D\") flipSign();\t\n\tint s; cin >> s; s--;\n\tif (s >= n) flip();\n\ts %= n;\n\tauto cmp = [](int a, int b){\n\t\treturn c[a]>s);\n}\n\nint main() {\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\n\n#ifdef LOCAL\n\tif (DEBUG) freopen(\"input.txt\", \"r\", stdin);\n\tif (DEBUG) freopen(\"output.txt\", \"w\", stdout);\n\tclock_t start = clock();\n#endif\n\n\tint t; cin >> t;\n\twhile (t--)\n\t\tsolve();\n\n#ifdef LOCAL\n\tcout << setprecision(12) << ld(clock()-start) / CLOCKS_PER_SEC << endl;\n#endif\n\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5334c0e970188b5b5524a028cac1d707", "src_uid": "299c209b070e510e7ed3b525f51fec8a", "difficulty": 3500.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nint read();\n\nint n;\nchar t[102];\nint w[102][102], rnk[102][102], pos[102];\n\nvector p[102];\nqueue q;\n\nvoid init() {\n for (int i = 1; i <= n; ++i) {\n p[i].clear(), p[i + n].clear();\n for (int j = 1; j <= n; ++j)\n p[i].push_back(j + n), p[i + n].push_back(j);\n sort(p[i].begin(), p[i].end(),\n [&](int a, int b) { return w[i][a] > w[i][b]; });\n sort(p[i + n].begin(), p[i + n].end(),\n [&](int a, int b) { return w[a][i] < w[b][i]; });\n q.push(i), pos[i] = 0, pos[i + n] = n;\n for (int j = 0; j < n; ++j)\n rnk[j][p[i][j]] = j, rnk[i + n][p[i + n][j]] = j;\n }\n\n while (!q.empty()) {\n int u = q.front(), v;\n while (pos[v = p[u][pos[u]]] < rnk[v][u]) ++pos[u];\n if (pos[v] < n) q.push(p[v][pos[v]]);\n pos[v] = rnk[v][u];\n }\n}\n\nint main() {\n for (int T = read(); T; --T) {\n n = read();\n for (int i = 1; i <= n; ++i)\n for (int j = 1; j <= n; ++j) w[i][j] = read();\n printf(\"B\\n\"), fflush(stdout), scanf(\"%s\", t);\n if (t[0] == 'D')\n for (int i = 1; i <= n; ++i)\n for (int j = 1; j <= n; ++j) w[i][j] = -w[i][j];\n init();\n for (int u = read(); ~u; u = read()) printf(\"%d\\n\", p[u][pos[u]]);\n }\n return 0;\n}\n\nint read() {\n int x = 0, f = 1;\n char c = getchar();\n while (c < '0' || c > '9') f = (c == '-') ? -1 : f, c = getchar();\n while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();\n return x * f;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "00e9c2e5a8036b21f6011affe5332534", "src_uid": "299c209b070e510e7ed3b525f51fec8a", "difficulty": 3500.0} {"lang": "GNU C++11", "source_code": "#include \n#define uint unsigned int\n#define vint vector \n#define pb push_back\n#define clr(a) memset(a, 0, sizeof a)\n#define fir first\n#define sec second\n#define mkp make_pair\n#define hash_t unsigned long long\n#define vhash vector \nusing namespace std;\n\nconst int MaxN = 1010, MaxM = 2010;\nconst hash_t base = 300007;\nhash_t rand_val[MaxN];\n\nclass Graph {\npublic:\n\tint en[MaxN], next[MaxM], to[MaxM], tot;\n\tint lab[MaxN];\n\tvoid add_edge(int x, int y) {\n\t\tnext[++tot] = en[x];\n\t\ten[x] = tot;\n\t\tto[tot] = y;\n\t}\n\tvoid clear() {\n\t\tclr(en);\n\t\ttot = 0;\n\t\tclr(lab);\n\t}\n}\tGu, Gv;\ntypedef pair h_node;\nstruct Status {\n\tint ker;\n\tvector u, v;\n};\nvector Su, Sv;\nvector < pair > ans;\nvint stk;\n\nint n, total;\nbool vis[MaxN], done[MaxN];\n\nvoid read_graph(Graph &G) {\n\tint m;\n\tscanf(\"%d\", &m);\n\tmap hash;\n\tint total = 0;\n\tfor (int i = 1; i <= m; ++i) {\n\t\tint u, v;\n\t\tscanf(\"%d%d\", &u, &v);\n\t\tif (!hash.count(u)) hash[u] = ++total;\n\t\tif (!hash.count(v)) hash[v] = ++total;\n\t\tu = hash[u];\n\t\tv = hash[v];\n\t\tG.add_edge(u, v);\n\t\tG.add_edge(v, u);\n\t}\n}\n\nint size[MaxN], mx[MaxN];\nint dfs_size(Graph &G, int now) {\n\tvis[now] = 1;\n\tsize[now] = 1;\n\tmx[now] = 0;\n\tstk.pb(now);\n\tfor (int i = G.en[now]; i; i = G.next[i])\n\t\tif (!vis[G.to[i]]) {\n\t\t\tint tmp = dfs_size(G, G.to[i]);\n\t\t\tsize[now] += tmp;\n\t\t\tmx[now] = max(mx[now], tmp);\n\t\t}\n\treturn size[now];\n}\n\npair get_gra(Graph &G, int root, int u) {\n\tclr(vis);\n\tvis[u] = 1;\n\tstk.clear();\n\tint sz = dfs_size(G, root);\n\tpair ret(0, 0);\n\tint mn = sz;\n\tfor (auto i : stk) {\n\t\tmx[i] = max(mx[i], sz - size[i]);\n\t\tmn = min(mn, mx[i]);\n\t}\n\tfor (auto i : stk)\n\t\tif (mx[i] == mn) {\n\t\t\tif (ret.fir == 0) ret.fir = i;\n\t\t\telse ret.sec = i;\n\t\t}\n\treturn ret;\n}\n\nhash_t vec_hash(vhash &s) {\n\tsort(s.begin(), s.end());\n\thash_t ret = 0;\n\tfor (uint i = 0; i < s.size(); ++i)\n\t\tret = (ret * base + s[i]) ^ (s[i] * base + rand_val[i]);\n\treturn ret;\n}\n\nhash_t dfs_hash(Graph &G, int now) {\n\tvis[now] = done[now] = 1;\n\tvhash v;\n\tfor (int i = G.en[now]; i; i = G.next[i])\n\t\tif (!vis[G.to[i]]) v.pb(dfs_hash(G, G.to[i]));\n\tv.pb(0);\n\treturn vec_hash(v);\n}\n\nhash_t get_hash(Graph &G, int root, int u = 0) {\n\tpair gra = get_gra(G, root, u);\n\tif (gra.sec == 0) {\n\t\tclr(vis);\n\t\tvis[u] = 1;\n\t\treturn dfs_hash(G, gra.fir);\n\t} else {\n\t\tvhash v;\n\t\tclr(vis);\n\t\tvis[u] = 1;\n\t\tvis[gra.sec] = vis[gra.fir] = 1;\n\t\tv.pb(dfs_hash(G, gra.fir));\n\t\tv.pb(dfs_hash(G, gra.sec));\n\t\treturn vec_hash(v);\n\t}\n\treturn 0;\n}\n\nint relabel(Graph &G, int now, int flag = 0) {\n\tif (flag) stk.pb(now);\n\tvis[now] = 1;\n\tG.lab[now] = ++total;\n\tfor (int i = G.en[now]; i; i = G.next[i])\n\t\tif (!vis[G.to[i]])\n\t\t\tans.pb(mkp(G.lab[now], relabel(G, G.to[i], flag)));\n\treturn G.lab[now];\n}\n\nh_node set_xor(vector &u, vector &v) {\n\tif (u.size() < v.size() || u.size() > v.size() + 1) return mkp(0, -1);\n\tmultiset s;\n\th_node ret(0, 0);\n\tfor (auto i : v) s.insert(i.fir);\n\tfor (auto i : u) {\n\t\tauto t = s.find(i.fir);\n\t\tif (t == s.end()) {\n\t\t\tif (ret.sec != 0) return mkp(0, -1);\n\t\t\telse ret = i;\n\t\t} else s.erase(t);\n\t}\n\tif (u.size() == v.size() && ret.sec != 0) return mkp(0, -1);\n\treturn ret;\n}\n\nbool check(Status Su, Status Sv) {\n\th_node com_u, com_v;\n\tcom_u = set_xor(Su.u, Sv.v);\n\tcom_v = set_xor(Sv.u, Su.v);\n\tif (com_u.sec == -1 || com_v.sec == -1 || com_u.fir != com_v.fir) return 0; \n\tif ((com_u.sec == 0) ^ (com_v.sec == 0)) return 0;\n\n\ttotal = 2;\n\n\tint u = Su.ker, v = Sv.ker;\n\tfor (int i = Gu.en[u]; i; i = Gu.next[i])\n\t\tif (Gu.to[i] != com_u.sec) {\n\t\t\tclr(vis);\n\t\t\tvis[Su.ker] = 1;\n\t\t\tans.pb(mkp(1, relabel(Gu, Gu.to[i])));\n\t\t}\n\n\tfor (int i = Gv.en[v]; i; i = Gv.next[i]) \n\t\tif (Gv.to[i] != com_v.sec) {\n\t\t\tclr(vis);\n\t\t\tvis[Sv.ker] = 1;\n\t\t\tans.pb(mkp(2, relabel(Gv, Gv.to[i])));\n\t\t}\n\n\tif (com_u.sec == 0) ans.pb(mkp(1, 2));\n\telse {\n\t\tstk.clear();\n\t\tclr(vis);\n\t\tvis[Su.ker] = 1;\n\t\tans.pb(mkp(1, relabel(Gu, com_u.sec, 1)));\n\t\t\n\t\tclr(vis);\n\t\tvis[Sv.ker] = 1;\n\t\thash_t hv = dfs_hash(Gv, com_v.sec);\n\n\t\tfor (auto i : stk) {\n\t\t\tclr(vis);\n\t\t\tvis[Su.ker] = 1;\n\t\t\tif (dfs_hash(Gu, i) == hv) {\n\t\t\t\tans.pb(mkp(2, Gu.lab[i]));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn 1;\n}\n\nvoid work(Graph &G, vector &S) {\n\tfor (int u = 1; u < n; ++u) {\n\t\tStatus now;\n\t\tnow.ker = u;\n\n\t\tclr(done);\n\t\tdone[u] = 1;\n\t\tfor (int i = G.en[u]; i; i = G.next[i])\n\t\t\tnow.u.pb(mkp(get_hash(G, G.to[i], u), G.to[i]));\n\t\tfor (int i = 1; i < n; ++i)\n\t\t\tif (!done[i]) now.v.pb(mkp(get_hash(G, i, u), i));\n\t\tS.pb(now);\n\t}\n}\n\nvoid solve() {\n\tans.clear();\n\tGu.clear();\n\tGv.clear();\n\tSu.clear();\n\tSv.clear();\n\n\tscanf(\"%d%*d\", &n);\n\tread_graph(Gu);\n\tread_graph(Gv);\n\tfor (int i = 0; i <= n; ++i) rand_val[i] = ((hash_t)rand() << 15) ^ rand();\n\t\n\twork(Gu, Su);\n\twork(Gv, Sv);\n\tfor (auto i : Su)\n\t\tfor (auto j : Sv)\n\t\t\tif (check(i, j)) {\n//\t\t\t\tassert(int(ans.size()) == n - 1);\n\t\t\t\tif (int(ans.size()) != n - 1) continue;\n\t\t\t\tputs(\"YES\");\n\t\t\t\tfor (auto e : ans) printf(\"%d %d\\n\", e.fir, e.sec);\n\t\t\t\treturn;\n\t\t\t}\n\tputs(\"NO\");\n}\n\nint main() {\n\tint t;\n\tscanf(\"%d\", &t);\n\twhile (t--) solve();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0072fd4867a89cac7c7fe06e4e07b9e0", "src_uid": "25dcac5eddbad481c7ba6da97b37b676", "difficulty": 3200.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std; \n\n#define PB push_back \n#define MP make_pair \n#define SZ(v) ((int)(v).size()) \n#define FOR(i,a,b) for(int i=(a);i<(b);++i) \n#define REP(i,n) FOR(i,0,n) \n#define FORE(i,a,b) for(int i=(a);i<=(b);++i) \n#define REPE(i,n) FORE(i,0,n) \n#define FORSZ(i,a,v) FOR(i,a,SZ(v)) \n#define REPSZ(i,v) REP(i,SZ(v)) \ntypedef long long ll;\ntypedef unsigned long long ull;\nll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }\n\nconst int MAXF=2;\nconst int MAXN=1000;\nconst int MAXM=MAXN-2;\nconst int MAXTN=MAXN-2;\nconst int MAXTM=MAXTN-1;\nconst int MAXRT=MAXN-1+2*MAXM;\nconst int MAXRTN=10+MAXTN;\nconst int MAXRTNSUM=MAXF*MAXRT*MAXRTN+2*MAXTN;\n\n\ntypedef struct RT {\n\tint root,u,v,vv;\n} RT;\ntypedef struct RF {\n\tint n;\n\tint par[MAXRTNSUM];\n\tint chead[MAXRTNSUM];\n\tint cnxt[MAXRTNSUM];\n\tint coff[MAXRTNSUM];\n\tint ccnt[MAXRTNSUM];\n\tint cidx[MAXRTNSUM];\n\tint id[MAXRTNSUM];\n\tint d[MAXRTNSUM];\n\tint q[MAXRTNSUM],qhead,qtail;\n\tint orig[MAXRTNSUM];\n\n\tRF() { n=0; }\n\tint addNode(int p,int o) { assert(n=ccnt[a]) return -1; if(i>=ccnt[b]) return +1;\n\t\t\tint aa=id[cidx[coff[a]+i]],bb=id[cidx[coff[b]+i]]; if(aa!=bb) return aacidcmp(a,b)<0; } } ;\n\tvector calcids(vector t) {\n\t\tint nt=SZ(t); //bool dbg=true;\n\t\tqhead=qtail=0; REP(i,nt) { int at=t[i].root; d[at]=0,q[qhead++]=at; }\n\t\twhile(qtail0&&d[q[a-1]]==dmx) --a;\n\t\tFOR(i,a,b) { int at=q[i]; id[at]=0; }\n\t\tfor(int cd=dmx-1;cd>=0;--cd) {\n\t\t\tc=b,b=a; while(a>0&&d[q[a-1]]==cd) --a; //if(dbg) printf(\"\\t%d..%d..%d\\n\",a,b,c);\n\t\t\tFOR(i,b,c) { int at=q[i]; cidx[coff[par[at]]++]=at; }\n\t\t\tFOR(i,a,b) { int at=q[i]; for(int to=chead[at];to!=-1;to=cnxt[to]) --coff[at]; }\n\t\t\tsort(q+a,q+b,cidless(this));\n\t\t\tFOR(i,a,b) { int at=q[i]; id[at]=i==a?0:id[q[i-1]]+(cidcmp(at,q[i-1])==0?0:1); }\n\t\t\t//FOR(i,a,b) { int at=q[i]; printf(\"%d = [\",at); REP(j,ccnt[at]) printf(\"%d%c\",id[cidx[coff[at]+j]],j+1 %d\\n\",id[at]); }\n\t\t}\n\t\tvector ret(nt,-1); REP(i,nt) ret[i]=id[t[i].root]; return ret;\n\t}\n} RF;\nRF rf;\n\n//bool dbg=false;\ntypedef struct T {\n\tint n,m,root;\n\tint ghead[MAXTN],gnxt[2*MAXTM],gto[2*MAXTM];\n\tint orig[MAXTN];\n\tint d1[MAXTN],d2[MAXTN],d3[MAXTN];\n\tint q[MAXTN],qhead,qtail;\n\n\tvoid init(int o) { n=1,m=0; root=0; ghead[0]=-1,orig[0]=o; }\n\tint addNode(int p,int o) { assert(n calcCenters(int rt) {\n\t\tREP(i,n) d1[i]=INT_MAX; qhead=qtail=0; d1[rt]=0,q[qhead++]=rt;\n\t\twhile(qtaild1[u]) u=i;\n\t\t//if(dbg) { REP(i,n) printf(\"%d=%d \",orig[i],d1[i]); printf(\"-> %d\\n\",orig[u]); }\n\t\tREP(i,n) d2[i]=INT_MAX; qhead=qtail=0; d2[u]=0,q[qhead++]=u;\n\t\twhile(qtaild2[v]) v=i;\n\t\t//if(dbg) { REP(i,n) printf(\"%d=%d \",orig[i],d2[i]); printf(\"-> %d\\n\",orig[v]); }\n\t\tREP(i,n) d3[i]=INT_MAX; qhead=qtail=0; d3[v]=0,q[qhead++]=v;\n\t\twhile(qtaild3[w]) w=i;\n\t\t//if(dbg) { REP(i,n) printf(\"%d=%d \",orig[i],d3[i]); printf(\"-> %d\\n\",orig[w]); }\n\t\tvector ret; REP(i,n) if(d2[i]+d3[i]==d2[v]&&d2[v]-1<=2*d2[i]&&2*d2[i]<=d2[v]+1) ret.PB(i); return ret;\n\t}\n\tvoid appendTo(int at,int par,int idx) {\n\t\tfor(int x=ghead[at];x!=-1;x=gnxt[x]) { int to=gto[x]; if(to==par) continue; int nidx=rf.addNode(idx,orig[to]); appendTo(to,at,nidx); }\n\t}\n} T;\nT t;\n\ntypedef struct F {\n\tint n,m;\n\tvector > adj;\n\tbool done[MAXN];\n\n\tvoid input(int _n) { n=_n; adj=vector >(n,vector()); scanf(\"%d\",&m); REP(i,m) { int a,b; scanf(\"%d%d\",&a,&b); --a,--b; adj[a].PB(b); adj[b].PB(a); } }\n\tvoid buildTree(int at,int idx) {\n\t\tdone[at]=true; REPSZ(i,adj[at]) { int to=adj[at][i]; if(done[to]) continue; int nidx=t.addNode(idx,to); buildTree(to,nidx); }\n\t}\n\t// ( ((u+)) ((uv)()) ((v+)()()) )\n\tRT createCanonical(int u,int v,int vv,bool swp) {\n\t\t//dbg=false; if(!swp&&u==3&&v==4&&vv==2) dbg=true; if(swp&u==4&&v==3&&vv==1) dbg=true;\n\t\tRT ret; ret.u=u; ret.v=v; ret.vv=vv; ret.root=rf.addNode(-1,-1);\n\t\tint rt=ret.root,a=rf.addNode(rt,-1),b=rf.addNode(rt,-1),c=rf.addNode(rt,-1);\n\t\ta=rf.addNode(a,-1); rf.addNode(b,-1),b=rf.addNode(b,-1); rf.addNode(c,-1),rf.addNode(c,-1),c=rf.addNode(c,-1);\n\t\tREP(i,n) done[i]=false; done[u]=true; done[v]=true;\n\t\tREPSZ(i,adj[v]) {\n\t\t\t//if(swp&&u==0&&v==3&&vv==2) printf(\"building %d\\n\",adj[v][i]);\n\t\t\tt.init(adj[v][i]); buildTree(adj[v][i],t.root);\n\t\t\tvector centers=t.calcCenters(t.root);\n\t\t\t//if(swp&&u==0&&v==3&&vv==2) { REPSZ(j,centers) printf(\"\\t%d\\n\",t->orig[centers[j]]); }\n\t\t\tint par=adj[v][i]==vv?b:swp?a:c,bj=0;\n\t\t\tFORSZ(j,1,centers) {\n\t\t\t\tint on=rf.n;\n\t\t\t\tRT a; a.root=rf.addNode(-1,centers[bj]); t.appendTo(centers[bj],-1,a.root);\n\t\t\t\tRT b; b.root=rf.addNode(-1,centers[j]); t.appendTo(centers[j],-1,b.root);\n\t\t\t\tvector c; c.PB(a); c.PB(b); vector id=rf.calcids(c); if(id[1] centers=t.calcCenters(t.root);\n\t\t\tint par=swp?c:a,bj=0;\n\t\t\tFORSZ(j,1,centers) {\n\t\t\t\tint on=rf.n;\n\t\t\t\tRT a; a.root=rf.addNode(-1,centers[bj]); t.appendTo(centers[bj],-1,a.root);\n\t\t\t\tRT b; b.root=rf.addNode(-1,centers[j]); t.appendTo(centers[j],-1,b.root);\n\t\t\t\tvector c; c.PB(a); c.PB(b); vector id=rf.calcids(c); if(id[1] createAll(bool swp) {\n\t\tint u=-1; REP(i,n) if(SZ(adj[i])==0) { u=i; break; } assert(u!=-1);\n\t\tvector ret; ret.reserve(n-1+2*m);\n\t\tREP(v,n) if(v!=u) {\n\t\t\t//if(!swp&&(u!=8||v!=3)) continue;\n\t\t\t//if(swp&&(u!=1||v!=5)) continue;\n\t\t\tret.PB(createCanonical(u,v,-1,swp));\n\t\t\tREPSZ(i,adj[v]) ret.PB(createCanonical(u,v,adj[v][i],swp));\n\t\t}\n\t\treturn ret;\n\t}\n\tvoid print(RT a,RT b,F &fb) {\n\t\tqueue > q; q.push(MP(a.root,b.root));\n\t\tvector ab(n,-1),ba(n,-1); ab[a.u]=b.v,ba[b.v]=a.u; ab[a.v]=b.u,ba[b.u]=a.v;\n\t\twhile(!q.empty()) {\n\t\t\tint ai=q.front().first,bi=q.front().second; q.pop(); //printf(\"%d=%d\\n\",ai,bi); if(ai==0&&bi==0) exit(1);\n\t\t\tif(rf.orig[ai]!=-1&&rf.orig[bi]!=-1) ab[rf.orig[ai]]=rf.orig[bi],ba[rf.orig[bi]]=rf.orig[ai];\n\t\t\tREP(k,rf.ccnt[ai]) q.push(MP(rf.cidx[rf.coff[ai]+k],rf.cidx[rf.coff[bi]+k]));\n\t\t}\n\t\t//REP(i,n) printf(\"%d->%d\\n\",i,ab[i]);\n\t\t//REP(i,n) printf(\"%d<-%d\\n\",ba[i],i);\n\t\tREP(i,n) REPSZ(j,adj[i]) if(i a=f[0].createAll(false);\n\tvector b=f[1].createAll(true);\n\tvector c; REPSZ(i,a) c.PB(a[i]); REPSZ(i,b) c.PB(b[i]);\n\tif(qq!=1) printf(\"rf.n=%d\\n\",rf.n);\n\tvector id=rf.calcids(c);\n\tif(qq!=1) printf(\"ids\\n\");\n\t//REPSZ(i,c) { printf(\"%d %2d (%d,%d,%2d): \",i mp; REPSZ(i,a) if(mp.count(id[i])==0) mp[id[i]]=i;\n\tREPSZ(j,b) if(mp.count(id[SZ(a)+j])) {\n\t\tint i=mp[id[SZ(a)+j]]; //printf(\"a%d with b%d\\n\",i,j);\n\t\tprintf(\"YES\\n\");\n\t\tif(qq==1) f[0].print(a[i],b[j],f[1]);\n\t\trf.n=0;\n\t\treturn true;\n\t}\n\trf.n=0;\n\tprintf(\"NO\\n\"); return false;\n}\n\n\nvoid run() {\n\tinput();\n\tsolve();\n}\n\nvoid test() {\n\twhile(true) {\n\t\tint n=1000;\n\t\tvector par(n,-1);\n\t\tFOR(i,1,n) par[i]=rand()%i;\n\t\tint u=rand()%n,v=rand()%(n-1); if(v>=u) ++v;\n\t\tREP(i,2) {\n\t\t\tf[i].n=n;\n\t\t\tf[i].adj=vector >(n);\n\t\t}\n\t\tFOR(j,1,n) {\n\t\t\tif(j!=u&&par[j]!=u) f[0].adj[j].PB(par[j]),f[0].adj[par[j]].PB(j);\n\t\t\tif(j!=v&&par[j]!=v) f[1].adj[j].PB(par[j]),f[1].adj[par[j]].PB(j);\n\t\t}\n\t\tif(!solve()) {\n\t\t\tprintf(\"1\\n\");\n\t\t\tprintf(\"%d %d\\n\",n,2);\n\t\t\tREP(i,2) {\n\t\t\t\tint m=0; REP(j,n) REPSZ(k,f[i].adj[j]) if(j\n#include\n#include\n#include\n#include\nusing namespace std;\nconst int N=1010,oo=1000000000;\nint i,j,k,n,m,Test,nm,ch,Fg,na,nb,ta,tb,tt,x,y,num,xx,yy,tx,ty,Txy;\nint f[N],g[N];\nmap,int> Map;\nmap P;\nstruct edge { int s,n;};\nstruct cc {\n\tint x,hs;\n\tbool operator < (const cc &n) const {\n\t\tif (hs==n.hs) return x A;\n\tvector Tmp[N];\n\tvoid clear() {\n\t\tEn=0;\n\t\tmemset(h,0,sizeof h);\n\t}\n\tvoid E_add(int x,int y) {\n\t\tE[++En].s=y;E[En].n=h[x];h[x]=En;\n\t\tE[++En].s=x;E[En].n=h[y];h[y]=En;\n\t}\n\tvoid get_size(int x,int F) {\n\t\tsz[x]=1;\n\t\tfor (int k=h[x];k;k=E[k].n) if (E[k].s!=F) {\n\t\t\tget_size(E[k].s,x);\n\t\t\tsz[x]+=sz[E[k].s];\n\t\t}\n\t}\n\tvoid get_root(int x,int F) {\n\t\tint k,ma=size-sz[x];\n\t\tfor (k=h[x];k;k=E[k].n) if (E[k].s!=F) {\n\t\t\tget_root(E[k].s,x);\n\t\t\tif (sz[E[k].s]>ma) ma=sz[E[k].s];\n\t\t}\n\t\tif (ma A;\n\t\tfor (int k=h[x];k;k=E[k].n) if (!z[E[k].s]) A.push_back(get_hash(E[k].s));\n\t\tsort(A.begin(),A.end());\n\t\tif (!Map[A]) Map[A]=++nm;\n\t\treturn hs[x]=Map[A];\n\t}\n\tint Js() {\n\t\tmemset(z,0,sizeof z);\n\t\tA.clear();\n\t\tfor (i=1;i<=n;i++) if (!z[i]) {\n\t\t\tget_size(i,0);\n\t\t\tsize=sz[i];\n\t\t\tmi1=mi2=oo;\n\t\t\tget_root(i,0);\n\t\t\tif (mi1!=mi2) A.push_back(get_hash(rt1));\n\t\t\telse {\n\t\t\t\tvector tmp;\n\t\t\t\ttmp.push_back(-1);\n\t\t\t\tz[rt2]=1;\n\t\t\t\ttmp.push_back(get_hash(rt1));\n\t\t\t\tz[rt2]=0;\n\t\t\t\ttmp.push_back(get_hash(rt2));\n\t\t\t\tsort(tmp.begin(),tmp.end());\n\t\t\t\tif (!Map[tmp]) Map[tmp]=++nm;\n\t\t\t\tA.push_back(Map[tmp]);\n\t\t\t}\n\t\t}\n\t\tsort(A.begin(),A.end());\n\t\tif (!Map[A]) Map[A]=++nm;\n\t\treturn Map[A];\n\t}\n\tvoid work(int x) {\n\t\tmemset(z,0,sizeof z);\n\t\tz[x]=1;\n\t\tA.clear();\n\t\tget_size(x,0);\n\t\tfor (k=h[x];k;k=E[k].n) {\n\t\t\tsize=sz[E[k].s];\n\t\t\tmi1=mi2=oo;\n\t\t\tget_root(E[k].s,x);\n\t\t\tif (mi1!=mi2) A.push_back(get_hash(rt1));\n\t\t\telse {\n\t\t\t\tvector tmp;\n\t\t\t\ttmp.push_back(-1);\n\t\t\t\tz[rt2]=1;\n\t\t\t\ttmp.push_back(get_hash(rt1));\n\t\t\t\tz[rt2]=0;\n\t\t\t\ttmp.push_back(get_hash(rt2));\n\t\t\t\tsort(tmp.begin(),tmp.end());\n\t\t\t\tif (!Map[tmp]) Map[tmp]=++nm;\n\t\t\t\tA.push_back(Map[tmp]);\n\t\t\t}\n\t\t}\n\t\tA.push_back(1);\n\t\tsort(A.begin(),A.end());\n\t}\n\tvoid dfs(int x,int F,int tmp) {\n\t\tint t=++num,k,tt;\n\t\tfor (k=h[x];k;k=E[k].n) if (E[k].s!=F && E[k].s!=tmp) {\n\t\t\ttt=num+1;\n\t\t\tdfs(E[k].s,x,tmp);\n\t\t\tprintf(\"%d %d\\n\",t,tt);\n\t\t}\n\t}\n\tvoid dfs2(int x,int F,int tmp,int xx) {\n\t\tint t=++num,k;\n\t\tcc a;\n\t\tif (x==xx) Txy=num;\n\t\tfor (k=h[x];k;k=E[k].n) if (E[k].s!=F && E[k].s!=tmp) {\n\t\t\ta.x=E[k].s;a.hs=hs[E[k].s];\n\t\t\tTmp[x].push_back(a);\n\t\t}\n\t\tsort(Tmp[x].begin(),Tmp[x].end());\n\t\tfor (k=0;k tmp;\n\t\t\t\ttmp.push_back(-1);\n\t\t\t\tz[rt2]=1;\n\t\t\t\ttmp.push_back(hs[rt1]);\n\t\t\t\tz[rt2]=0;\n\t\t\t\ttmp.push_back(hs[rt2]);\n\t\t\t\tsort(tmp.begin(),tmp.end());\n\t\t\t\tif (Map[tmp]==y) return E[k].s;\n\t\t\t}\n\t\t}\n\t}\n} A,B,C;\nbool check() {\n\tint i,j,k,na,nb,nc,fg;\n\tA.work(x);\n\tB.work(y);\n\tj=0;k=0;fg=0;\n\tfor (i=0;i=n) Fg=1;\n\t\tR(B.m);\n\t\tfor (i=1;i<=n;i++) f[i]=i;\n\t\tfor (i=1;i<=B.m;i++) {\n\t\t\tR(x);R(y);\n\t\t\tB.E_add(x,y);\n\t\t\tif (getf(x)!=getf(y)) f[f[x]]=f[y];\n\t\t\telse Fg=1;\n\t\t}\n\t\tfor (i=1;i<=n;i++) {\n\t\t\tif (B.h[i]) nb++;\n\t\t\telse if (!tb) tb=i;\n\t\t}\n\t\tif (nb>=n) Fg=1;\n\t\tif (Fg) {\n\t\t\tputs(\"NO\");\n\t\t\tcontinue;\n\t\t}\n\t\tx=0;y=0;\n\t\tP.clear();\n\t\tfor (i=1;i<=n;i++) if (A.h[i]) {\n\t\t\tC.clear();\n\t\t\tfor (j=1;j<=n;j++) if (j!=i)\n\t\t\t\tfor (k=A.h[j];k;k=A.E[k].n) if (A.E[k].s!=i && j\n#define vint vector \n#define pb push_back\n#define clr(a) memset(a, 0, sizeof a)\n#define fir first\n#define sec second\n#define mkp make_pair\n#define hash_t unsigned long long\n#define vhash vector \nusing namespace std;\n\nconst int MaxN = 1010, MaxM = 2010;\nconst hash_t base = 300007;\nhash_t rand_val[MaxN];\n\nclass Graph {\npublic:\n\tint en[MaxN], next[MaxM], to[MaxM], tot;\n\tint lab[MaxN];\n\tvoid add_edge(int x, int y) {\n\t\tnext[++tot] = en[x];\n\t\ten[x] = tot;\n\t\tto[tot] = y;\n\t}\n\tvoid clear() {\n\t\tclr(en);\n\t\ttot = 0;\n\t\tclr(lab);\n\t}\n}\tGu, Gv;\ntypedef pair h_node;\nstruct Status {\n\tint ker;\n\tvector u, v;\n};\nvector Su, Sv;\nvector < pair > ans;\nvint stk;\n\nint n, total;\nbool vis[MaxN], done[MaxN];\n\nvoid read_graph(Graph &G) {\n\tint m;\n\tscanf(\"%d\", &m);\n\tmap hash;\n\tint total = 0;\n\tfor (int i = 1; i <= m; ++i) {\n\t\tint u, v;\n\t\tscanf(\"%d%d\", &u, &v);\n\t\tif (!hash.count(u)) hash[u] = ++total;\n\t\tif (!hash.count(v)) hash[v] = ++total;\n\t\tu = hash[u];\n\t\tv = hash[v];\n\t\tG.add_edge(u, v);\n\t\tG.add_edge(v, u);\n\t}\n}\n\nint size[MaxN], mx[MaxN];\nint dfs_size(Graph &G, int now) {\n\tvis[now] = 1;\n\tsize[now] = 1;\n\tmx[now] = 0;\n\tstk.pb(now);\n\tfor (int i = G.en[now]; i; i = G.next[i])\n\t\tif (!vis[G.to[i]]) {\n\t\t\tint tmp = dfs_size(G, G.to[i]);\n\t\t\tsize[now] += tmp;\n\t\t\tmx[now] = max(mx[now], tmp);\n\t\t}\n\treturn size[now];\n}\n\npair get_gra(Graph &G, int root, int u) {\n\tclr(vis);\n\tvis[u] = 1;\n\tstk.clear();\n\tint sz = dfs_size(G, root);\n\tpair ret(0, 0);\n\tint mn = sz;\n\tfor (auto i : stk) {\n\t\tmx[i] = max(mx[i], sz - size[i]);\n\t\tmn = min(mn, mx[i]);\n\t}\n\tfor (auto i : stk)\n\t\tif (mx[i] == mn) {\n\t\t\tif (ret.fir == 0) ret.fir = i;\n\t\t\telse ret.sec = i;\n\t\t}\n\treturn ret;\n}\n\nhash_t vec_hash(vhash &s) {\n\tsort(s.begin(), s.end());\n\thash_t ret = 0;\n\tfor (uint i = 0; i < s.size(); ++i)\n\t\tret = (ret * base + s[i]) ^ (s[i] * base + rand_val[i]);\n\treturn ret;\n}\n\nhash_t dfs_hash(Graph &G, int now) {\n\tvis[now] = done[now] = 1;\n\tvhash v;\n\tfor (int i = G.en[now]; i; i = G.next[i])\n\t\tif (!vis[G.to[i]]) v.pb(dfs_hash(G, G.to[i]));\n\treturn vec_hash(v);\n}\n\nhash_t get_hash(Graph &G, int root, int u = 0) {\n\tpair gra = get_gra(G, root, u);\n\tif (gra.sec == 0) {\n\t\tclr(vis);\n\t\tvis[u] = 1;\n\t\treturn dfs_hash(G, gra.fir);\n\t} else {\n\t\tvhash v;\n\t\tclr(vis);\n\t\tvis[u] = 1;\n\t\tvis[gra.sec] = vis[gra.fir] = 1;\n\t\tv.pb(dfs_hash(G, gra.fir));\n\t\tv.pb(dfs_hash(G, gra.sec));\n\t\treturn vec_hash(v);\n\t}\n\treturn 0;\n}\n\nint relabel(Graph &G, int now, int flag = 0) {\n\tif (flag) stk.pb(now);\n\tvis[now] = 1;\n\tG.lab[now] = ++total;\n\tfor (int i = G.en[now]; i; i = G.next[i])\n\t\tif (!vis[G.to[i]])\n\t\t\tans.pb(mkp(G.lab[now], relabel(G, G.to[i], flag)));\n\treturn G.lab[now];\n}\n\nh_node set_xor(vector &u, vector &v) {\n\tif (u.size() < v.size() || u.size() > v.size() + 1) return mkp(0, -1);\n\tmultiset s;\n\th_node ret(0, 0);\n\tfor (auto i : v) s.insert(i.fir);\n\tfor (auto i : u) {\n\t\tauto t = s.find(i.fir);\n\t\tif (t == s.end()) {\n\t\t\tif (ret.fir != 0) return mkp(0, -1);\n\t\t\telse ret = i;\n\t\t} else s.erase(t);\n\t}\n\tif (u.size() == v.size() && ret.fir != 0) return mkp(0, -1);\n\treturn ret;\n}\n\nbool check(Status Su, Status Sv) {\n\n\th_node com_u, com_v;\n\tcom_u = set_xor(Su.u, Sv.v);\n\tcom_v = set_xor(Sv.u, Su.v);\n\tif (com_u.sec == -1 || com_v.sec == -1 || com_u.fir != com_v.fir) return 0; \n\n\ttotal = 2;\n\n\tint u = Su.ker, v = Sv.ker;\n\tfor (int i = Gu.en[u]; i; i = Gu.next[i])\n\t\tif (Gu.to[i] != com_u.sec) {\n\t\t\tclr(vis);\n\t\t\tvis[Su.ker] = 1;\n\t\t\tans.pb(mkp(1, relabel(Gu, Gu.to[i])));\n\t\t}\n\n\tfor (int i = Gv.en[v]; i; i = Gv.next[i]) \n\t\tif (Gv.to[i] != com_v.sec) {\n\t\t\tclr(vis);\n\t\t\tvis[Sv.ker] = 1;\n\t\t\tans.pb(mkp(2, relabel(Gv, Gv.to[i])));\n\t\t}\n\n\tif (com_u.fir == 0) ans.pb(mkp(1, 2));\n\telse {\n\t\tstk.clear();\n\t\tclr(vis);\n\t\tvis[Su.ker] = 1;\n\t\tans.pb(mkp(1, relabel(Gu, com_u.sec, 1)));\n\t\t\n\t\tclr(vis);\n\t\tvis[Sv.ker] = 1;\n\t\thash_t hv = dfs_hash(Gv, com_v.sec);\n\n\t\tfor (auto i : stk) {\n\t\t\tclr(vis);\n\t\t\tvis[Su.ker] = 1;\n\t\t\tif (dfs_hash(Gu, i) == hv) {\n\t\t\t\tans.pb(mkp(2, Gu.lab[i]));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\treturn 1;\n}\n\nvoid work(Graph &G, vector &S) {\n\tfor (int u = 1; u < n; ++u) {\n\t\tStatus now;\n\t\tnow.ker = u;\n\n\t\tclr(done);\n\t\tdone[u] = 1;\n\t\tfor (int i = G.en[u]; i; i = G.next[i])\n\t\t\tnow.u.pb(mkp(get_hash(G, G.to[i], u), G.to[i]));\n\t\tfor (int i = 1; i < n; ++i)\n\t\t\tif (!done[i]) now.v.pb(mkp(get_hash(G, i, u), i));\n\t\tS.pb(now);\n\t}\n}\n\nvoid solve() {\n\tans.clear();\n\tGu.clear();\n\tGv.clear();\n\tSu.clear();\n\tSv.clear();\n\n\tscanf(\"%d%*d\", &n);\n\tread_graph(Gu);\n\tread_graph(Gv);\n\tfor (int i = 0; i <= n; ++i) rand_val[i] = ((hash_t)rand() << 15) ^ rand();\n\t\n\twork(Gu, Su);\n\twork(Gv, Sv);\n\tfor (auto i : Su)\n\t\tfor (auto j : Sv)\n\t\t\tif (check(i, j)) {\n\t\t\t\tfor (auto e : ans) printf(\"%d %d\\n\", e.fir, e.sec);\n\t\t\t\treturn;\n\t\t\t}\n\tputs(\"NO\");\n}\n\nint main() {\n\tint t;\n\tscanf(\"%d\", &t);\n\twhile (t--) solve();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "62d7b95b0dc50e816eb50f97278e8c24", "src_uid": "25dcac5eddbad481c7ba6da97b37b676", "difficulty": 3200.0} {"lang": "GNU C++", "source_code": "const char Directory[300] = \"/Users/carlosjosetoribio/NetBeansProjects/Runner/dist/Debug/GNU-MacOSX/runner\";\n\n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef pair PII;\ntypedef long long Long;\nint seat[20], N;\nint fixe[20];\nLong memo[1<<18][17];\nLong cnt(int mask = 0, int id = 0)\n{\n if(id==N)return 1;\n if(memo[mask][id]!=-1)return memo[mask][id];\n for(int i = 0; i < N; ++i)\n if(fixe[i]==id)\n return memo[mask][id] = cnt(mask , id+1);\n Long ways = 0;\n for(int i = 0; i < N; ++i)\n {\n if(mask & seat[i])\n {\n if(fixe[i]==-1)continue;\n else if(fixe[i]>N>>Y>>M;\n memset(seat,0,sizeof(seat));\n for(int i = 0; i < N; ++i)\n {\n int a,b;\n cin>>a>>b;\n a--;b--;\n seat[a] |= (1<= Y)break;\n else Y-= t;\n fixe[i] = -1;\n }\n }\n for(int i = 0; i < N ; ++i)\n if(i\n#include\n#include\n#include\n#include\n#include\n\n#define PB push_back\n#define WAIT cout<> N >> P >> M;\n P -= 2000;\n while(M--){\n cin >> a >> b;\n E[a-1][b-1] = true;\n }\n for(ll p=0; p= P){\n A[I] = c;\n used[c] = true;\n break;\n }\n \n brn[c] = false;\n P -= dp[all-1];\n }\n } \n \n for(ll I=0; I\n#include \n\nusing namespace std;\n\nlong long year, dp[70000];\nint n, m, need[17], ans[17], bits_cnt[70000];\nbool used[17];\n\nlong long calc(int state) {\n if (state == (1 << n)-1) {\n dp[state] = 1;\n return 1;\n }\n if (dp[state] > -1) {\n return dp[state];\n }\n\n if (bits_cnt[state] == -1) {\n int usd = 0;\n for (int i = 0; i < n; ++i) {\n if (state & (1 << i)) {\n ++usd;\n }\n }\n bits_cnt[state] = usd;\n }\n \n long long sum = 0;\n for (int i = 0; i < n; ++i) {\n if (!(state & (1 << i))) {\n if ((state & need[i]) != need[i]) {\n continue;\n }\n if (ans[i] == 0 || ans[i] == bits_cnt[state]+1) {\n sum += calc(state | (1 << i));\n }\n }\n }\n dp[state] = sum;\n\n return sum;\n}\n\nint main () {\n ios_base::sync_with_stdio(false); \n cin.tie(nullptr);\n \n memset(bits_cnt, -1, bits_cntof(bits_cnt));\n memset(dp, -1, bits_cntof(dp));\n\n cin >> n >> year >> m;\n year -= 2000;\n for (int i = 0; i < m; ++i) {\n int x, y;\n cin >> x >> y;\n --x;\n --y;\n need[y] = need[y] | (1 << x);\n }\n \n if (calc(0) < year) {\n cout << \"The times have changed\";\n } else {\n for (int j = 0; j < n; ++j) {\n for (int i = 1; i < n+1; ++i) {\n if (!used[i]) {\n ans[j] = i;\n memset(dp, -1, bits_cntof(dp));\n auto k = calc(0);\n if (k < year) {\n year -= k;\n } else {\n used[i] = true;\n break;\n }\n }\n }\n }\n\n for (int i = 0; i < n; ++i) {\n cout << ans[i] << ' ';\n }\n }\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "6f6664f7209b7003da03b28edaafb89f", "src_uid": "e9db8d048e9763cf38c584342dea9f53", "difficulty": 2400.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n\nusing namespace std;\n\nlong long year, dp[70000];\nint n, m, need[17], ans[17], size[70000];\nbool used[17];\n\nlong long calc(int state) {\n if (state == (1 << n)-1) {\n dp[state] = 1;\n return 1;\n }\n if (dp[state] > -1) {\n return dp[state];\n }\n\n if (size[state] == -1) {\n int usd = 0;\n for (int i = 0; i < n; ++i) {\n if (state & (1 << i)) {\n ++usd;\n }\n }\n size[state] = usd;\n }\n \n long long sum = 0;\n for (int i = 0; i < n; ++i) {\n if (!(state & (1 << i))) {\n if ((state & need[i]) != need[i]) {\n continue;\n }\n if (ans[i] == 0 || ans[i] == size[state]+1) {\n sum += calc(state | (1 << i));\n }\n }\n }\n dp[state] = sum;\n\n return sum;\n}\n\nint main () {\n ios_base::sync_with_stdio(false); \n cin.tie(nullptr);\n \n memset(size, -1, sizeof(size));\n memset(dp, -1, sizeof(dp));\n\n cin >> n >> year >> m;\n year -= 2000;\n for (int i = 0; i < m; ++i) {\n int x, y;\n cin >> x >> y;\n --x;\n --y;\n need[y] = need[y] | (1 << x);\n }\n \n if (calc(0) < year) {\n cout << \"The times have changed\";\n } else {\n for (int j = 0; j < n; ++j) {\n for (int i = 1; i < n+1; ++i) {\n if (!used[i]) {\n ans[j] = i;\n memset(dp, -1, sizeof(dp));\n auto k = calc(0);\n if (k < year) {\n year -= k;\n } else {\n used[i] = true;\n break;\n }\n }\n }\n }\n\n for (int i = 0; i < n; ++i) {\n cout << ans[i] << ' ';\n }\n }\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "e65a20e29cf091b2c2316e77a027b533", "src_uid": "e9db8d048e9763cf38c584342dea9f53", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n\n#define clz(n) __builtin_clz(n)\ntypedef double ld;\nconst int N=1<<17;\nstruct C{\n\tld x,y;\n\tinline C operator - (const C&a)const{return (C){x-a.x,y-a.y};}\n\tinline C operator + (const C&a)const{return (C){x+a.x,y+a.y};}\n\tinline void operator += (const C&a){x+=a.x;y+=a.y;}\n\tinline C operator * (const ld&a)const{return (C){x*a,y*a};}\n\tinline C operator / (const ld&a)const{return (C){x/a,y/a};}\n\tinline C operator * (const C&a)const{return (C){x*a.x-y*a.y,x*a.y+y*a.x};}\n\tinline C conj()const{return (C){x,-y};}\n}s1[N],omg_[N],s2[N],s3[N];\nint n_,lgn_;\nint rev_[N];\nvoid FFT_init(int n){\n\tlgn_=31-clz(n);n_=1<>1|(i&1)<<(lgn_-1);\n\t}\n}\nC ww[N];\nvoid FFT(C*a){\n\tfor(int i=0;i>31&mod;}\nvoid mul(int*a,int*b,int*c){\n\tmemset(s1,0,sizeof s1);memset(s2,0,sizeof s2);\n\tfor(int i=0;i<=n;i++)\n\t\tif(i&1)s1[i/2].y=a[i];\n\t\telse s1[i/2].x=a[i];\n\tfor(int i=0;i<=n;i++)\n\t\tif(i&1)s2[i/2].y=b[i];\n\t\telse s2[i/2].x=b[i];\n\tFFT(s1);FFT(s2);\n\tfor(int i=0;i>1)?(C){1,0}-ww[i^n_>>1]:ww[i]+(C){1,0})))*(C){0.25,0};\n\t}\n\tFFT(s3);reverse(s3+1,s3+n_);\n\tfor(int i=0;i<=n;i++)c[i]=(ll)(i&1?s3[i>>1].y/n_+0.5:s3[i>>1].x/n_+0.5)%mod;\n}\nint f[2][N],g[2][N],tmp[N];\nint ans;\nvoid solve(int L){\n\tif(!L)return;\n\tsolve(L/2);memset(g,0,sizeof g);\n\tfor(int i=1;i<=n;++i)tmp[i]=(f[0][i]+f[1][i])%mod;\n\tfor(int op=0;op<=1;++op){\n\t\tmul(f[op^(L>>1&1)],tmp,g[op]);\n\t\tfor(int i=1;i<=n;++i)\n\t\t\treduce(g[op][i]+=f[op][i]-mod),\n\t\t\treduce(g[op][i]+=f[op^(L>>1&1)][i]-mod);\n\t}\n\tif(L&1){\n\t\tfor(int i=n;i>=2;--i)\n\t\t\treduce(g[1][i]+=(g[0][i-1]+g[1][i-1])%mod-mod);\n\t\treduce(g[1][1]+=1-mod);\n\t}\n\tmemcpy(f,g,sizeof f);\n\tfor(int i=1;i<=n;i+=2)reduce(ans+=f[1][i]-mod);\n}\n\nint main(){\n\tios::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n\tcin>>n>>m>>mod;FFT_init(2*n+2);\n\tsolve(m/2);\n\tcout<\nusing namespace std;\n\nconst int p1 = 998244353, p2 = 469762049, Maxn = 1 << 17 | 5;\nint maxn, maxa, mod, rev[Maxn];\nlong long tot;\nvoid get_rev(int len)\n{\n\tfor (int i = 0; i < len; i++)\n\t\trev[i] = (rev[i >> 1] >> 1) | ((i & 1) * (len >> 1));\n}\nlong long fast_pow(long long x, long long y, long long p)\n{\n\tlong long ans = 1, now = x;\n\twhile (y)\n\t{\n\t\tif (y & 1) ans = ans * now % p;\n\t\tnow = now * now % p;\n\t\ty >>= 1;\n\t}\n\treturn ans;\n}\nvoid NTT(long long now[], int len, int p, bool type = false)\n{\n\tlong long inv3 = fast_pow(3, p - 2, p);\n\tfor (int i = 0; i < len; i++)\n\t\tif (i < rev[i]) swap(now[i], now[rev[i]]);\n\tfor (int i = 1; i < len; i <<= 1)\n\t{\n\t\tlong long w = fast_pow(type ? inv3 : 3, (p - 1) / (i << 1), p);\n\t\tfor (int j = 0; j < len; j += (i << 1))\n\t\t{\n\t\t\tlong long l = 1;\n\t\t\tfor (int k = j; k < i + j; k++, l = l * w % p)\n\t\t\t{\n\t\t\t\tlong long x = now[i + k] * l % p, y = now[k];\n\t\t\t\tnow[k] = (x + y) % p;\n\t\t\t\tnow[i + k] = (y - x + p) % p;\n\t\t\t}\n\t\t}\n\t}\n\tif (type)\n\t{\n\t\tlong long inv = fast_pow(len, p - 2, p);\n\t\tfor (int i = 0; i < len; i++)\n\t\t\tnow[i] = now[i] * inv % p;\n\t}\n}\nvoid multi(long long x[], long long y[], long long result[], int len, int p)\n{\n\tNTT(x, len, p), NTT(y, len, p);\n\tfor (int i = 0; i < len; i++)\n\t\tresult[i] = x[i] * y[i] % p;\n\tNTT(result, len, p, true);\n}\nvoid multi(long long x[], long long y[], long long result[], int len)\n{\n\tget_rev(len);\n\tstatic long long tmp1[Maxn], tmp2[Maxn], tmpx[Maxn], tmpy[Maxn];\n\tfor (int i = 0; i < len; i++)\n\t\ttmpx[i] = x[i], tmpy[i] = y[i];\n\tmulti(tmpx, tmpy, tmp1, len, p1);\n\tfor (int i = 0; i < len; i++)\n\t\ttmpx[i] = x[i], tmpy[i] = y[i];\n\tmulti(tmpx, tmpy, tmp2, len, p2);\n\t__int128 l = (__int128) p1 * p2;\n\tfor (int i = 0; i < len; i++)\n\t\tresult[i] = (tmp1[i] * (__int128) p2 * fast_pow(p2, p1 - 2, p1) + tmp2[i] * (__int128) p1 * fast_pow(p1, p2 - 2, p2)) % l % mod;\n}\nvoid poly_pow(int y, int len)\n{\n\tint now = 0;\n\tstatic long long ans[2][Maxn];\n\tmemset(ans[0], 0, sizeof(long long[len << 1]));\n\tmemset(ans[1], 0, sizeof(long long[len << 1]));\n\tstatic long long tmp[Maxn], result[2][Maxn];\n\tfor (int j = 20; j >= 0; j--)\n\t{\n\t\tmemset(tmp, 0, sizeof(long long[len << 1]));\n\t\tfor (int i = 0; i < len; i++)\n\t\t\ttmp[i] = (ans[0][i] + ans[1][i]) % mod;\n\t\ttmp[0]++;\n\t\tfor (int p = 0; p <= 1; p++)\n\t\t\tmulti(tmp, ans[(now & 1) ^ p], result[p], len << 1);\n\t\tfor (int p = 0; p <= 1; p++)\n\t\t\tfor (int i = 0; i < len; i++)\n\t\t\t\t(ans[p][i] += result[p][i]) %= mod;\n\t\tnow <<= 1;\n\t\tif (y & (1 << j))\n\t\t{\n\t\t\tfor (int i = len - 1; i; i--)\n\t\t\t\t(ans[1][i] += ans[0][i - 1] + ans[1][i - 1]) %= mod;\n\t\t\tans[1][1]++; \n\t\t\tnow++;\n\t\t}\n\t\tif (now != y)\n\t\t\tfor (int i = 1; i <= maxn; i += 2)\n\t\t\t\t(tot += ans[1][i]) %= mod;\n\t}\n}\nint lower(int x)\n{\n\tint tmp = 1;\n\tfor (; tmp < x; tmp <<= 1);\n\treturn tmp;\n}\nint main()\n{\n\tscanf(\"%d%d%d\", &maxn, &maxa, &mod);\n\tpoly_pow(maxa, lower(maxn + 1));\n\tprintf(\"%lld\", tot);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "3dfeb180991e84896e4ed2a8f332cff1", "src_uid": "aac481d9e5ea3e3d43b324c8750882be", "difficulty": 3400.0} {"lang": "GNU C++11", "source_code": "#include\n#define ll long long\n\ntemplate \nstruct modequa{\nprivate:\n\tT remain, moder;\n\t\n\t// \u00d5\u00e2\u00d1\u00f9\u00bf\u00c9\u00d2\u00d4\u00b1\u00a3\u00d6\u00a4 |x| <= |b|, |y| <= |a|\n\tT extendedeuclid(T a, T b, T &x, T &y){\n\t\tT p;\n\t\tif (b){\n\t\t\tT ret = extendedeuclid(b, a % b, x, y);\n\t\t\tp = y, y = x - a / b * y, x = p;\n\t\t\treturn ret;\n\t\t}\n\t\tx = 1, y = 0;\n\t\treturn a;\n\t}\n\t\n\tll getone(int n){return 1;}\n\t__int128 getone(ll n){return 1;}\n\t\npublic:\n\tmodequa (){}\n\tmodequa (T remain, T moder) : remain(remain), moder(moder){}\n\tT getremain(){return remain;}\n\tT getmoder(){return moder;}\n\t\n\tvoid setcandidates(T remain, T moder){\n\t\tthis -> remain = remain;\n\t\tthis -> moder = moder;\n\t}\n\t\n\tmodequa crt(const modequa &p){\n\t\tT x, y;\n\t\tauto one = getone(remain);\n\t\tif (!moder || !p.moder) return {0, 0};\n\t\tT gcd = extendedeuclid(moder, p.moder, x, y);\n\t\tif ((p.remain - remain) % gcd) return {0, 0};\n\t\tT lcm = moder / gcd * p.moder;\n\t\tT ans = (p.remain - remain) / gcd;\n\t\tans = one * ans * x % lcm * moder % lcm;\n\t\tans += remain;\n\t\tans += ans < 0 ? lcm : ans >= lcm ? -lcm : 0;\n\t\treturn {ans, lcm}; \n\t}\n};\n\n// \u00c8\u00e7\u00b9\u00fb\u00c4\u00a3\u00ca\u00fd\u00b2\u00bb\u00ca\u00c7\u00d6\u00ca\u00ca\u00fd\u00a3\u00ac\u00c4\u00c7\u00c3\u00b4\u00bb\u00f9\u00b1\u00be\u00be\u00cd\u00d6\u00bb\u00c4\u00dc\u00d7\u00f6\u00bc\u00d3\u00bc\u00f5\u00b3\u00cb\u00ba\u00cd\u00c7\u00f3\u00b5\u00bc\u00c1\u00cborz \nstruct Poly{\nprivate:\n\tconst static int MAX = 17;\n\t\n\tstatic int numinv[1 << MAX];\n\tint a[1 << MAX];\n\tint length;\n\tint moder, root, invroot;\n\t// \u00b3\u00a3\u00d3\u00c3\u00b5\u00c4\u00c1\u00bd\u00d7\u00e9\u00c4\u00a3\u00ca\u00fd\u00ce\u00aa ((119 << 23) + 1, 3, 332748118) \u00ba\u00cd ((479 << 21) + 1, 3, 334845270)\n\n\tint powermod(int a, int exp, int moder){\n\t\tint ret = 1;\n\t\tfor ( ; exp; exp >>= 1){\n\t\t\tif (exp & 1){\n\t\t\t\tret = 1ll * a * ret % moder;\n\t\t\t}\n\t\t\ta = 1ll * a * a % moder;\n\t\t}\n\t\treturn ret;\n\t}\n\t\n\tvoid initinv(){\n\t\tnuminv[1] = 1;\n\t\tfor (int i = 2; i < 1 << MAX; ++ i){\n\t\t\tnuminv[i] = (moder - 1ll * (moder / i) * numinv[moder % i] % moder) % moder;\n\t\t}\n\t}\n\t\n\tvoid NTT(int *a, int length, int type, int moder, int root){\n\t\tint len = -1;\n\t\tfor (int x = length; x; ++ len, x >>= 1);\n\t\tfor(int i = 1, j = 0; i < length - 1; ++ i){\n\t\t\tfor(int s = length; j ^= s >>= 1, ~j & s; );\n\t\t\tif(i < j){\n\t\t\t\tstd::swap(a[i], a[j]);\n\t\t\t}\n\t\t}\n\t\tfor (int i = 1; i <= len; ++ i){\n\t\t\tint unit = powermod(root, moder - 1 >> i, moder);\n\t\t\tfor (int j = 0; j < length; j += 1 << i){\n\t\t\t\tint w = 1;\n\t\t\t\tfor (int k = j, szk = 1 << i - 1; k < j + szk; ++ k){\n\t\t\t\t\tint s = a[k], t = 1ll * w * a[k + szk] % moder;\n\t\t\t\t\ta[k] = s + t >= moder ? s + t - moder : s + t;\n\t\t\t\t\ta[k + szk] = s - t < 0 ? s - t + moder : s - t;\n\t\t\t\t\tw = 1ll * w * unit % moder;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (type == 1) return;\n\t\tint inv = powermod(length, moder - 2, moder);\n\t\tfor (int i = 0; i < length; ++ i){\n\t\t\ta[i] = 1ll * a[i] * inv % moder;\n\t\t}\n\t}\n\npublic:\n\tPoly() : length(-1){\n\t\tmemset(a, 0, sizeof(a));\n\t}\n\t\n\t// \u00c8\u00e7\u00b9\u00fb\u00c4\u00a3\u00ca\u00fd\u00b7\u00c7NTT\u00d6\u00ca\u00ca\u00fd root \u00ba\u00cd invroot \u00cb\u00e6\u00b1\u00e3\u00c9\u00e8\u00be\u00cd\u00ba\u00c3\u00c0\u00b1~ \n\tPoly(int moder, int root, int invroot):moder(moder), root(root), invroot(invroot), length(-1){\n\t\tmemset(a, 0, sizeof(a));\n\t}\n\t\n\tvoid clear(){\n\t\tmemset(a, 0, sizeof(int) * (length + 1));\n\t\tlength = -1;\n\t\tmoder = root = invroot = 0;\n\t}\n\t\n\tvoid setmoder(int moder, int root, int invroot){\n\t\tclear();\n\t\tthis -> moder = moder, this -> root = root, this -> invroot = invroot;\n\t}\n\t\n\tvoid setlength(int length){\n\t\tif (length >= this -> length){\n\t\t\tthis -> length = length;\n\t\t\treturn;\n\t\t}\n\t\tmemset(a + length + 1, 0, sizeof(int) * (this -> length - length));\n\t\tthis -> length = length;\n\t}\n\t\n\tvoid setvalue(int sit, int value){\n\t\ta[sit] = (value % moder + moder) % moder;\n\t\tlength = std::max(sit, length);\n\t\tfor ( ; ~length && !a[length]; -- length)\n\t\t\t;\n\t}\n\t\n\tint getvalue(int sit){return a[sit];}\n\tint getlength(){return length;}\n\tint getmoder(){return moder;}\n\t\n\t// \u00cf\u00e0\u00b5\u00b1\u00d3\u00da\u00b3\u00cb\u00d2\u00d4 x ^ dis\n\tvoid leftshift(int dis){\n\t\tfor (int i = length + dis; i >= dis; -- i){\n\t\t\ta[i] = a[i - dis];\n\t\t}\n\t\tmemset(a, 0, sizeof(int) * dis);\n\t\tlength += dis;\n\t}\n\t\n\t// \u00cf\u00e0\u00b5\u00b1\u00d3\u00da\u00b3\u00fd\u00d2\u00d4 x ^ dis\n\tvoid rightshift(int dis){\n\t\tif (dis > length) return setmoder(moder, root, invroot);\n\t\tfor (int i = 0; i <= length - dis; ++ i){\n\t\t\ta[i] = a[i + dis];\n\t\t}\n\t\tmemset(a + length - dis + 1, 0, sizeof(int) * dis);\n\t\tlength = length - dis >= 0 ? length - dis : -1;\n\t}\n\t\n\tint value(int x){\n\t\tint now = 1, ret = 0;\n\t\tfor (int i = 0; i <= length; ++ i){\n\t\t\tret = (ret + 1ll * a[i] * now) % moder;\n\t\t\tnow = 1ll * now * x % moder;\n\t\t}\n\t\treturn ret;\n\t}\n\n\tvoid assign(Poly &q){\n\t\tmemset(a, 0, sizeof(int) * (length + 1));\n\t\tmemcpy(a, q.a, sizeof(int) * (q.length + 1));\n\t\tlength = q.length, moder = q.moder, root = q.root, invroot = q.invroot;\n\t}\n\t\n\tvoid neg(){\n\t\tfor (int i = 0; i <= length; ++ i){\n\t\t\ta[i] = a[i] ? moder - a[i] : 0;\n\t\t}\n\t}\n\t\n\tvoid add(Poly &q){\n\t\tif (moder != q.moder) assert((\"Invalid polynomial addition!\", 0));\n\t\tif (!~length) return assign(q);\n\t\tif (!~q.length) return;\n\t\tlength = std::max(length, q.length);\n\t\tfor (int i = 0; i <= length; ++ i){\n\t\t\ta[i] = a[i] + q.a[i];\n\t\t\ta[i] -= a[i] >= moder ? moder : 0;\n\t\t}\n\t\tfor ( ; ~length && !a[length]; -- length)\n\t\t\t;\n\t}\n\t\n\tvoid minus(Poly &q){\n\t\tif (moder != q.moder) assert((\"Invalid polynomial subtraction!\", 0));\n\t\tif (!~length) return assign(q);\n\t\tif (!~length) return;\n\t\tlength = std::max(length, q.length);\n\t\tfor (int i = 0; i <= length; ++ i){\n\t\t\ta[i] = a[i] - q.a[i];\n\t\t\ta[i] += a[i] < 0 ? moder : 0;\n\t\t}\n\t\tfor ( ; ~length && !a[length]; -- length)\n\t\t\t;\n\t}\n\n\tvoid mult(Poly &q){\n\t\tstatic int multmoder[2] = {998244353, 1004535809};\n\t\tstatic int multroot[2] = {3, 3};\n\t\tstatic int multinvroot[2] = {332748118, 334845270};\n\t\tstatic int aux[1 << MAX], aux1[1 << MAX];\n\t\tif (moder != q.moder) assert((\"Invalid polynomial multiplication!\", 0));\n\t\tif (!~length || !~q.length) return setmoder(moder, root, invroot);\n\t\tint n = length + q.length;\n\t\tint lengthans = 1;\n\t\tfor ( ; lengthans <= n; lengthans <<= 1)\n\t\t\t;\n\t\tmemcpy(aux, q.a, sizeof(int) * lengthans);\n\t\tmemcpy(aux1, q.a, sizeof(int) * lengthans);\n\t\tNTT(a, lengthans, 1, multmoder[0], multroot[0]);\n\t\tNTT(aux, lengthans, 1, multmoder[0], multroot[0]);\n\t\tfor (int i = 0; i < lengthans; ++ i){\n\t\t\taux[i] = 1ll * aux[i] * a[i] % multmoder[0];\n\t\t}\n\t\tNTT(a, lengthans, -1, multmoder[0], multinvroot[0]);\n\t\tNTT(aux, lengthans, -1, multmoder[0], multinvroot[0]);\n\t\tNTT(a, lengthans, 1, multmoder[1], multroot[1]);\n\t\tNTT(aux1, lengthans, 1, multmoder[1], multroot[1]);\n\t\tfor (int i = 0; i < lengthans; ++ i){\n\t\t\taux1[i] = 1ll * aux1[i] * a[i] % multmoder[1];\n\t\t}\n\t\tNTT(aux1, lengthans, -1, multmoder[1], multinvroot[1]);\n\t\tmemset(a, 0, sizeof(int) * lengthans);\n\t\tlength = n;\n\t\tfor(int i = 0; i <= length; ++ i){\n\t\t\tmodequa equa(aux[i], multmoder[0]), equb(aux1[i], multmoder[1]);\n\t\t\tequa.crt(equb);\n\t\t\ta[i] = equa.getremain() % moder;\n\t\t}\n\t}\n\t\n\tvoid mult(int q){\n\t\tfor (int i = 0; i <= length; ++ i){\n\t\t\ta[i] = 1ll * a[i] * q % moder;\n\t\t}\n\t}\n};\n\nint Poly::numinv[1 << Poly::MAX] = {};\n\nconst int N = 100;\n\nint maxn, maxa, moder;\nPoly a, b, ret1, ret2;\nint q[N];\n\nint main(){\n\tscanf(\"%d%d%d\", &maxn, &maxa, &moder);\n\tif (maxa == 1){\n\t\treturn printf(\"0\\n\"), 0;\n\t}\n\tint cnt = 0;\n\tfor (maxa >>= 1; maxa; maxa >>= 1){\n\t\tq[cnt ++] = maxa;\n\t}\n\tstd::reverse(q, q + cnt);\n\tint ans = 1;\n\ta.setmoder(moder, 0, 0);\n\tb.setmoder(moder, 0, 0);\n\ta.setvalue(0, 1);\n\tb.setvalue(1, 1);\n\ta.setlength(maxn);\n\tb.setlength(maxn);\n\tfor (int i = 0; i < cnt - 1; ++ i){\n\t\tret1.assign(a);\n\t\tret1.add(b);\n\t\tret1.mult(q[i] & 1 ? b : a);\n\t\tif (q[i] & 1 ? b.getvalue(0) : a.getvalue(0)){\n\t\t\tret1.minus(b);\n\t\t}\n\t\telse{\n\t\t\tret1.add(a);\n\t\t}\n\t\tret1.setlength(maxn);\n\t\tret2.assign(a);\n\t\tret2.add(b);\n\t\tret2.mult(q[i] & 1 ? a : b);\n\t\tif (q[i] & 1 ? a.getvalue(0) : b.getvalue(0)){\n\t\t\tret2.minus(a);\n\t\t}\n\t\telse{\n\t\t\tret2.add(b);\n\t\t}\n\t\tret2.setlength(maxn);\n\t\tif (q[i + 1] & 1){\n\t\t\tfor (int i = 1; i <= maxn; ++ i){\n\t\t\t\ta.setvalue(i, ret1.getvalue(i));\n\t\t\t}\n\t\t\tfor (int i = 1; i <= maxn; ++ i){\n\t\t\t\tb.setvalue(i, (ret2.getvalue(i) + ret1.getvalue(i - 1) + ret2.getvalue(i - 1)) % moder);\n\t\t\t}\n\t\t}\n\t\telse{\n\t\t\ta.assign(ret1);\n\t\t\tb.assign(ret2);\n\t\t}\n\t\tfor (int i = 1; i <= maxn; ++ i){\n\t\t\tif (i & 1){\n\t\t\t\tans = (ans + b.getvalue(i)) % moder;\n\t\t\t}\n\t\t}\n\t}\n\treturn printf(\"%d\\n\", ans), 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "91320f573dc7a57c86fccd47db126d2a", "src_uid": "aac481d9e5ea3e3d43b324c8750882be", "difficulty": 3400.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#define rep(i,a,b) for(i=a;i<=b;i++)\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\nconst ld PI=3.141592653589793238;\nconst int N=70010;\n//const int N=20;\nint n,mod;\nint digit,L;\nint ans;\n\nstruct complex{\n\tld x,y;\n\tcomplex(){}\n\tcomplex(ld x,ld y):x(x),y(y){}\n\tcomplex operator + (complex p){return complex(x+p.x,y+p.y);}\n\tcomplex operator - (complex p){return complex(x-p.x,y-p.y);}\n\tcomplex operator * (complex p){return complex(x*p.x-y*p.y,x*p.y+y*p.x);}\n};\n\ncomplex g[2][N],h[2][N];complex Root[N],IRoot[N];int R[N];\nint f[2][N],tmp[2][N];\n\nvoid DFT(complex a[],complex w[]){\n\tint i,j,k;complex x,y;\n\trep(i,0,digit-1)\tif(i>R[i])\tswap(a[i],a[R[i]]);\n\tfor(i=1;i>1]>>1|((i&1)<<(L-1));\n\tRoot[0]=complex(1,0);rep(i,1,digit-1)\tRoot[i]=complex(cos(2*PI*i/(ld)digit),sin(2*PI*i/(ld)digit));\n\tIRoot[0]=complex(1,0);rep(i,1,digit-1)\tIRoot[i]=complex(cos(2*PI*i/(ld)digit),sin(-2*PI*i/(ld)digit));\n}\n\t\n\nvoid solve(int m){\n\t//f(m,n,p)\n\tint i,j;\n\tif(m==1){f[1][1]=1;f[0][1]=0;f[0][0]=1;ans=1;return;}\n\tsolve(m>>1);\n\trep(i,0,digit-1)\tg[0][i]=complex(f[0][i],0);\n\trep(i,0,digit-1)\tg[1][i]=complex(f[1][i],0);\n\tDFT(g[0],Root);\n\tDFT(g[1],Root);\n\t//printf(\"%d\\n\",m);\n\t/*rep(i,0,n){\n\t\ttmp[0][i]=tmp[1][i]=0;\n\t\trep(j,0,i){\n\t\t\ttmp[0][i]+=(f[0][j]+f[1][j])*f[m>>1&1][i-j];\n\t\t\ttmp[1][i]+=(f[0][j]+f[1][j])*f[!(m>>1&1)][i-j];\n\t\t}\n\t}\n\trep(i,0,digit-1)\tprintf(\"%d \",tmp[0][i]);printf(\"\\n\");\n\trep(i,0,digit-1)\tprintf(\"%d \",tmp[1][i]);printf(\"\\n\");\n\trep(i,0,digit)\ttmp[0][i]=tmp[1][i]=0;*/\n\trep(i,0,digit-1){\n\t\th[0][i]=(g[0][i]+g[1][i])*g[m>>1&1][i];\n\t\th[1][i]=(g[0][i]+g[1][i])*g[!(m>>1&1)][i];\n\t}\n\tDFT(h[0],IRoot);\n\tDFT(h[1],IRoot);\n\t//rep(i,0,digit-1)\tprintf(\"%d \",(int)(h[0][i].x/(ld)digit+0.3));printf(\"\\n\");\n\t//rep(i,0,digit-1)\tprintf(\"%d \",(int)(h[1][i].x/(ld)digit+0.3));printf(\"\\n\");\n\trep(i,0,n){\n\t\ttmp[0][i]=(f[0][i]+(ll)(h[0][i].x/(ld)digit+0.3)-1ll*(f[0][i]+f[1][i])*f[m>>1&1][0])%mod;\n\t\ttmp[1][i]=(f[1][i]+(ll)(h[1][i].x/(ld)digit+0.3)-1ll*(f[0][i]+f[1][i])*f[!(m>>1&1)][0])%mod;\n\t}\n\trep(i,0,n)\t{f[0][i]=tmp[0][i];f[1][i]=tmp[1][i];}\n\t//rep(i,0,n)\tprintf(\"%d \",f[0][i]);printf(\"\\n\");\n\t//rep(i,0,n)\tprintf(\"%d \",f[1][i]);printf(\"\\n\");\n\tif(m&1)\tfor(i=n;i>=1;i--)\t{f[1][i]=(f[1][i]+f[1][i-1]+f[0][i-1])%mod;}\n\tfor(i=1;i<=n;i+=2)\tans=(ans+f[1][i])%mod;\n\t//rep(i,0,n)\tprintf(\"%d \",f[0][i]);printf(\"\\n\");\n\t//rep(i,0,n)\tprintf(\"%d \",f[1][i]);printf(\"\\n\");\n\t//printf(\"ans=%d\\n\",ans);\n}\n\nvoid test(){\n\tstatic complex a[20];\n\tint i;\n\tn=3;init();\n\trep(i,0,n)\ta[i]=complex(1,0);\n\tDFT(a,Root);\n\trep(i,0,digit-1)\ta[i]=a[i]*a[i];\n\tDFT(a,IRoot);\n\trep(i,0,digit-1)\tprintf(\"%d \",(int)(a[i].x/(ld)digit+0.3));\n}\n\t\n\t\n\nint main(){\n//\tfreopen(\"a.in\",\"r\",stdin);\n//\tfreopen(\"a.out\",\"w\",stdout);\n\tint m;//test();\n\tscanf(\"%d%d%d\",&n,&m,&mod);\n\tinit();\n\tsolve(m>>1);\n\tans=(ans+mod)%mod;\n\tprintf(\"%d\\n\",ans);\n}\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0c436a7f91020dddd99a76589f5c1215", "src_uid": "aac481d9e5ea3e3d43b324c8750882be", "difficulty": 3400.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \nusing namespace std;\nint n;\nint miin;\nint x,y,k,l;\nint t[100010];\n\nint main()\n{\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cin>>n>>k>>l;\n x=0;\n y=0;\n for (int i=0;i>a;\n if (a=='0')\n x++;\n else\n y++;\n }\n for (int i=1;i\n#include \n\nusing namespace std;\n\nint main()\n{\n\tlong long n, c1, c2;\n\tcin >> n >> c1 >> c2;\n\n\tstring s;\n\tcin >> s;\n\n\tlong long sc = 0, b = 0;\n\tfor(int i = 0; i < s.size(); i ++)\n\t\tif(s[i] == '0')\n\t\t\tsc ++;\n\t\telse\n\t\t\tb ++;\n\tlong long ans = 1000000000000;\n\n\tfor(int i = 1; i <= b; i ++)\n\t\t ans = min(ans, c1 + c2 * (n / i + n % i - 1) * (n / i + n % i - 1) + (i - 1) *\n\t\t\t (c1 + c2 * (n / i - 1) * (n / i - 1)));\n\tcout << ans << endl;\n\n\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "54f805367213597202f5421a1207cf1d", "src_uid": "78d013b01497053b8e321fe7b6ce3760", "difficulty": 2100.0} {"lang": "MS C++", "source_code": " #include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\nusing namespace std;\n\n\nvoid main() {\n#if defined(_DEBUG)\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif\n\tcout << fixed << setprecision(15);\n\tlong long n,c1,c2;\n\tcin >> n>>c1>>c2;\n\tlong long d = 0, v = 0;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tchar f;\n\t\tcin >> f;\n\t\tif (f =='1')\n\t v++;\n\t\telse\n\t\t d++;\n\t}\n\tlong long min =100000000000000000000;\n\tfor (int i = v; i >0 ;i--)\n\t{\n\t\tlong long s = n / i;\n\t\tlong long m = n % i;\n\t\tif (c1*i + c2*(s - 1)*(s - 1) * (i - m) + c2*(s*s)*m < min)\n\t\t\tmin = c1*i + c2*(s - 1)*(s - 1) * (i - m) + c2*(s*s)*m;\n\t}\n\tcout << min;\n}\n", "lang_cluster": "C++", "compilation_error": true, "code_uid": "b890f7cb012aa22d1885f8a879735a3b", "src_uid": "78d013b01497053b8e321fe7b6ce3760", "difficulty": 2100.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n#define fast ios_base::sync_with_stdio(false); cin.tie(0);\n#define rep(i,n,m) for(int i=n;i=m;i--)\n#define vii vector\n#define vi vector\n#define pi pair\n#define mi unordered_map\n#define pb push_back\n#define eb emplace_back\n#define mp make_pair\n#define sz(xx) (int)xx.size()\n#define all(yy) yy.begin(),yy.end()\n#define rall(yyy) yyy.rbegin(),yyy.rend()\n#define f first\n#define s second\n#define ll long long\n#define ld long double\n#define hell 100000000000LL\n#define callable 998244353\nconst int mod=1e9+7;\ntemplate inline void chkmin(T1 &x, T2 y) { if(y inline void chkmax(T1 &x,T2 y) { if(y>x) x=y; };\nint gcd(int x,int y)\n{\n\treturn(y==0?x:gcd(y,x%y));\n}\ninline int mul(int a,int b)\n{\n\treturn(1ll*a*b)%callable;\n}\ninline int sub(int a,int b)\n{\n\ta-=b;\n\tif(a<0)\n\ta+=mod;\n\tif(a>=mod)\n\ta-=mod;\n\treturn a;\n}\ninline int add(int a,int b)\n{\n\ta+=b;\n\tif(a>=mod)\n\ta-=mod;\n\tif(a<0)\n\ta+=mod;\n\treturn a;\n}\ninline int expo(int a,int b)\n{\n\tint values=1;\n\twhile(b)\n\t{\n\t\tif(b&1)\n\t\tvalues=mul(values,a);\n\t\ta=mul(a,a);\n\t\tb>>=1;\n\t}\n\treturn values%mod;\n}\nconst int MAXN=1e5+100;\nll n,c1,c2,\ninline ll call(ll sss,ll cnt)\n{\n\treturn cnt*(c1+c2*(sss-1)*(sss-1));\n}\nll can(ll g)\n{\n\tll k,r;\n\tk=n/g;\n\tr=n%g;\n\tll ss=g-r;\n\tll bb=r;\n\treturn call(k,ss)+call(k+1,bb);\n}\nvoid solve()\n{\n\tll val=0;\n\tcin>>n>>c1>>c2;\n\trep(i,0,n)\n\t{\n\t\tchar c;\n\t\tcin>>c;\n\t\tif(c=='1')\n\t\t++val;\n\t}\n\tll res=1e18;\n\tpre(i,val+1,1)\n\t{\n\t\tll cur=can(i);\n\t\tif(cur>t;\n\twhile(t--)\n\t{\n\t\tsolve();\n }\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "c7ebc653f806283ae69bf1bff64fb89c", "src_uid": "78d013b01497053b8e321fe7b6ce3760", "difficulty": 2100.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nconst int maxn=1E6+5;\nint n,m,size,head[maxn];\ninline int read()\n{\n\tchar ch=getchar();\n\twhile(!isdigit(ch))ch=getchar();\n\tint s=ch-'0';ch=getchar();\n\twhile(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}\n\treturn s;\n}\nstruct edge\n{\n\tint to,next,w;\n}E[maxn*2];\ninline void add(int u,int v)\n{\n\tE[++size].to=v;\n\tE[size].next=head[u];\n\thead[u]=size;\n}\nbool vis[maxn];\nint f[maxn];\nint TI,tmp[maxn];\ninline void bfs(int S)\n{\n\tqueueQ;\n\tQ.push(S);\n\tvis[S]=1;\n\tf[S]=0;\n\twhile(!Q.empty())\n\t{\n\t\tint u=Q.front();\n\t\tQ.pop();\n\t\t++TI;\n\t\tfor(int i=head[u];i;i=E[i].next)\n\t\t{\n\t\t\tint v=E[i].to;\n\t\t\tif(f[v]!=-1)\n\t\t\t\ttmp[f[v]]=TI;\n\t\t\tif(!vis[v])\n\t\t\t{\n\t\t\t\tvis[v]=1;\n\t\t\t\tQ.push(v);\n\t\t\t}\n\t\t}\n\t\tint pos=0;\n\t\twhile(tmp[pos]==TI)\n\t\t\t++pos;\n\t\tf[u]=pos;\n\t}\n}\nvectorwait[12555];\nint gg[maxn];\nbool cmp(int x,int y)\n{\n\treturn f[x]>f[y];\n}\ninline void solve()\n{\n\tfor(int i=1;i<=n;++i)\n\t\twait[f[i]].push_back(i);\n//\tfor(int i=1;i<=n;++i)\n//\t\tcout<=0;--e)\n\t\tfor(int q=0;qA;\n\tfor(int u=1;u<=n;++u)\n\t{\n\t\tassert(f[u]<=1);\n\t\tif(f[u])\n\t\t\tA.push_back(u);\n\t}\n\tcout<=v)\n\t\t\t\tcout<\nusing namespace std;\n#define pb push_back\n#define mp make_pair\n#define X first\n#define Y second\nconst int N=12500,M=1000000;\nint n,m;\nvector > nei[N+1];\nint a[N+1],b[N+1];\nint ansv[N+1],anse[M+1];\nint val[N+1];\nbool hav[N+1];\nint main(){\n\tcin>>n>>m;\n\tfor(int i=1;i<=m;i++){\n\t\tint x,y;\n\t\tscanf(\"%d%d\",&x,&y);\n\t\ta[i]=x,b[i]=y;\n\t\tnei[x].pb(mp(y,i));nei[y].pb(mp(x,i));\n\t\tanse[i]=1;\n\t}\n\tfor(int i=1;i<=n;i++){\n\t\tint dec=0;\n\t\tfor(int j=0;j0)now--,ansv[x]--,anse[y]++;\n\t\t}\n\t}\n\tvector v;\n\tfor(int i=1;i<=n;i++)if(ansv[i])v.pb(i);\n\tcout<\nusing namespace std;\nconst int maxn=1E6+5;\nint n,m,size,head[maxn];\ninline int read()\n{\n\tchar ch=getchar();\n\twhile(!isdigit(ch))ch=getchar();\n\tint s=ch-'0';ch=getchar();\n\twhile(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}\n\treturn s;\n}\nstruct edge\n{\n\tint to,next,w;\n}E[maxn*2];\ninline void add(int u,int v)\n{\n\tE[++size].to=v;\n\tE[size].next=head[u];\n\thead[u]=size;\n}\nbool vis[maxn];\nint f[maxn];\nint TI,tmp[maxn];\ninline void bfs(int S)\n{\n\tqueueQ;\n\tQ.push(S);\n\tvis[S]=1;\n\tf[S]=0;\n\twhile(!Q.empty())\n\t{\n\t\tint u=Q.front();\n\t\tQ.pop();\n\t\t++TI;\n\t\tfor(int i=head[u];i;i=E[i].next)\n\t\t{\n\t\t\tint v=E[i].to;\n\t\t\tif(f[v]!=-1)\n\t\t\t\ttmp[f[v]]=TI;\n\t\t\tif(!vis[v])\n\t\t\t{\n\t\t\t\tvis[v]=1;\n\t\t\t\tQ.push(v);\n\t\t\t}\n\t\t}\n\t\tint pos=0;\n\t\twhile(tmp[pos]==TI)\n\t\t\t++pos;\n\t\tf[u]=pos;\n\t}\n}\nvectorwait[12555];\nint gg[maxn];\ninline void solve()\n{\n\tfor(int i=1;i<=n;++i)\n\t\twait[f[i]].push_back(i);\n\tfor(int e=n;e>=0;--e)\n\t\tfor(int q=0;qA;\n\tfor(int u=1;u<=n;++u)\n\t{\n\t\tassert(f[u]<=1);\n\t\tif(f[u])\n\t\t\tA.push_back(u);\n\t}\n\tcout<=v)\n\t\t\t\tcout<\nusing namespace std;\nconst int maxn=1E6+5;\nint n,m,size,head[maxn];\ninline int read()\n{\n\tchar ch=getchar();\n\twhile(!isdigit(ch))ch=getchar();\n\tint s=ch-'0';ch=getchar();\n\twhile(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}\n\treturn s;\n}\nstruct edge\n{\n\tint to,next,w;\n}E[maxn*2];\ninline void add(int u,int v)\n{\n\tE[++size].to=v;\n\tE[size].next=head[u];\n\thead[u]=size;\n}\nbool vis[maxn];\nint f[maxn];\nint TI,tmp[maxn];\ninline void bfs(int S)\n{\n\tqueueQ;\n\tQ.push(S);\n\tvis[S]=1;\n\tf[S]=0;\n\twhile(!Q.empty())\n\t{\n\t\tint u=Q.front();\n\t\tQ.pop();\n\t\t++TI;\n\t\tfor(int i=head[u];i;i=E[i].next)\n\t\t{\n\t\t\tint v=E[i].to;\n\t\t\tif(f[v]!=-1)\n\t\t\t\ttmp[f[v]]=TI;\n\t\t\tif(!vis[v])\n\t\t\t{\n\t\t\t\tvis[v]=1;\n\t\t\t\tQ.push(v);\n\t\t\t}\n\t\t}\n\t\tint pos=0;\n\t\twhile(tmp[pos]==TI)\n\t\t\t++pos;\n\t\tf[u]=pos;\n\t}\n}\nvectorwait[12555];\ninline void solve()\n{\n\tfor(int i=1;i<=n;++i)\n\t\twait[f[i]].push_back(i);\n\tfor(int e=n;e>=0;--e)\n\t\tfor(int q=0;qA;\n\tfor(int u=1;u<=n;++u)\n\t{\n\t\tassert(f[u]<=1);\n\t\tif(f[u])\n\t\t\tA.push_back(u);\n\t}\n\tcout<=v)\n\t\t\t\tcout<\n#define maxn 10010\nusing namespace std;\ntypedef double ldb;\nconst ldb eps=1e-7;\nstruct edge{\n\tint r,nxt;\n\tldb w;\n}e[maxn<<1];\nint fr[maxn],to[maxn],n,m,a[maxn],b[maxn],c[maxn],d[maxn];\nint q[maxn],l,r,cur[maxn],dep[maxn],head[maxn],esz,S,T;\nvoid addedge(int u,int v,ldb w){\n\te[++esz].r=v;e[esz].nxt=head[u];head[u]=esz;e[esz].w=w;\n\te[++esz].r=u;e[esz].nxt=head[v];head[v]=esz;e[esz].w=0;\n}\nbool bfs(){\n\tfor(int i=S;i<=T;++i)cur[i]=head[i],dep[i]=0;\n\tq[r++]=S,dep[S]=1;\n\twhile(leps&&!dep[e[t].r])\n\t\t\tdep[e[t].r]=dep[u]+1,q[r++]=e[t].r;\n\t}\n\treturn dep[T]!=0;\n}\nldb find(int u,ldb flow){\n\tif(u==T)return flow;\n\tldb used=0,a=0;\n\tfor(int& t=cur[u];t;t=e[t].nxt)if(e[t].w>eps&&dep[e[t].r]==dep[u]+1){\n\t\ta=find(e[t].r,min(flow-used,e[t].w));\n\t\tused+=a,e[t].w-=a,e[t^1].w+=a;\n\t\tif(used==flow)return used;\n\t}\n\treturn used;\n}\nldb dinic(){\n\tldb ans=0;\n\twhile(bfs())\n\t\tans+=find(S,1e20);\n\treturn ans;\n}\nldb sol(ldb t){\n\tldb sum=0;\n\tesz=1,S=0,T=n+1;\n\tfor(int i=S;i<=T;++i)head[i]=0;\n\tfor(int i=1;i<=m;++i){\n\t\tldb l=a[i]*t+b[i],r=c[i]*t+d[i];\n\t\taddedge(S,to[i],l);\n\t\taddedge(fr[i],T,l);\n\t\taddedge(fr[i],to[i],r-l);\n\t\tsum+=l;\n\t}\n\treturn sum-dinic();\n}\nint main(){\n\tscanf(\"%d%d\",&n,&m);\n\tfor(int i=1;i<=m;++i)\n\t\tscanf(\"%d%d%d%d%d%d\",&fr[i],&to[i],&a[i],&b[i],&c[i],&d[i]);\n\tldb l=0,r=1;\n\tfor(int i=0;i<50;++i){\n\t\tldb mid1=(l+l+r)/3,mid2=(l+r+r)/3;\n\t\tldb f1=sol(mid1),f2=sol(mid2);\n\t\tif(f1>f2)l=mid1;\n\t\telse r=mid2;\n\t}\n//\tprintf(\"[%.5lf,%.5lf]\",l,sol(l));\n\tldb l1=0,r1=l;\n\tfor(int i=0;i<50;++i){\n\t\tldb mid=(l1+r1)/2;\n\t\tif(sol(mid)\n\nusing namespace std;\n#define rep(i,a,n) for (int i=a;i=a;i--)\n#define pb push_back\n#define mp make_pair\n#define all(x) (x).begin(),(x).end()\n#define fi first\n#define se second\n#define SZ(x) ((int)(x).size())\ntypedef vector VI;\ntypedef long long ll;\ntypedef pair PII;\nconst ll mod=1000000007;\nll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}\nll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}\n// head\n\ntypedef double db;\nconst db EPS = 1e-9;\nconst db inf=1e20;\ninline int sign(db a) { return a < -EPS ? -1 : a > EPS; }\ninline int cmp(db a, db b){ return sign(a-b); }\n\nconst int N=101000;\nint ts,u[N],v[N],a[N],b[N],c[N],d[N],n,m;\ntypedef db flowt;\nnamespace flow {\n\tconst int M=100000,N=1000;\n\tint y[M],nxt[M],gap[N],fst[N],c[N],pre[N],q[N],dis[N];\n\tint slope[M];\n\tflowt f[M];\n\tint S,T,tot,Tn;\n\tvoid init(int s,int t,int tn) {\n\t\ttot=1;\n\t\tmemset(fst,0,sizeof(fst));\n\t\tS=s;T=t;Tn=tn;\n\t}\n\tvoid add(int u,int v,int c,flowt c1,flowt c2=0) {\n\t\ttot++;y[tot]=v;f[tot]=c1;nxt[tot]=fst[u];fst[u]=tot;\n\t\tslope[tot]=c;\n\t\ttot++;y[tot]=u;f[tot]=c2;nxt[tot]=fst[v];fst[v]=tot;\n\t\tslope[tot]=0;\n\t}\n\tflowt sap() {\n\t\tint u=S,t=1;flowt flow=0;\n\t\trep(i,0,Tn) c[i]=fst[i],dis[i]=Tn,gap[i]=0;\n\t\tq[0]=T;dis[T]=0;pre[S]=0;\n\t\trep(i,0,t) {\n\t\t\tint u=q[i];\n\t\t\tfor (int j=fst[u];j;j=nxt[j]) if (dis[y[j]]>dis[u]+1&&fabs(f[j^1])>EPS) \n\t\t\t\tq[t++]=y[j],dis[y[j]]=dis[u]+1;\n\t\t}\n\t\trep(i,0,Tn) gap[dis[i]]++;\n\t\twhile (dis[S]<=Tn) {\n\t\t\twhile (c[u]&&(fabs(f[c[u]])EPS&&dis[y[j]]dis[u]+1&&fabs(f[j])>EPS) {\n\t\t\t\tdis[y[j]]=dis[u]+1;\n\t\t\t\tq[t++]=y[j];\n\t\t\t}\n\t\t}\n\t\tts=0;\n\t\trep(i,0,Tn) for (int j=fst[i];j;j=nxt[j]) if (dis[i]=Tn) ts+=slope[j];\n\t\treturn flow;\n\t}\n};\n\ndb bel[N];\nint sl[N];\nint check(double t) {\n\trep(i,1,n+1) bel[i]=0,sl[i]=0;\n\tflow::init(0,n+1,n+2);\n\trep(i,0,m) {\n\t\tdb l=a[i]*t+b[i],r=c[i]*t+d[i];\n\t\tflow::add(u[i],v[i],c[i]-a[i],r-l);\n\t\tbel[u[i]]+=l; bel[v[i]]-=l;\n\t\tsl[u[i]]+=a[i]; sl[v[i]]-=a[i];\n\t}\n\tdb sf=0;\n\tint ss=0;\n\trep(i,1,n+1) if (bel[i]>0) {\n\t\tsf+=bel[i]; flow::add(i,n+1,sl[i],bel[i]);\n\t\tss+=sl[i];\n\t} else flow::add(0,i,-sl[i],-bel[i]);\n\tdb r=flow::sap();\n\tif (ts==ss) {\n\t\tif (cmp(r,sf)==-1) return 2;\n\t\telse return 1;\n\t} else if (ts>ss) return 0;\n\telse return 2;\n}\ndouble gao(int ty) {\n\tdouble l=0,r=1;\n\twhile (clock()<0.85*ty*CLOCKS_PER_SEC) {\n\t\tdouble md=(l+r)*0.5;\n\t\tif (check(md)>=ty) r=md; else l=md;\n\t}\n\treturn 0.5*(l+r);\n}\nint main() {\n\tscanf(\"%d%d\",&n,&m);\n\trep(i,0,m) scanf(\"%d%d%d%d%d%d\",u+i,v+i,a+i,b+i,c+i,d+i);\n\tdb l=gao(1),r=gao(2);\n\tprintf(\"%.10f\\n\",r-l);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "53960d4525ee9d5bbf1a4c9845fcbb93", "src_uid": "e04a5732ad00fd63fbb52a3fb3e88ac6", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\nconst int NMAX = 1005;\nconst int MMAX = 2005;\n\nconst double EPS = 1e-8;\n\ntemplate \nclass MaxFlow {\nprivate:\n static constexpr int NIL = -1;\n static constexpr long double EPS = 1e-8;\n \n static constexpr int INF =\n std::numeric_limits :: max() / 2;\n \n template \n int cmp(type x) {\n if (-EPS < x and x < EPS)\n return 0;\n return x < 0 ? -1 : 1;\n }\n \n struct Edge {\n int nod, nxt;\n CapacityType cap;\n \n Edge() :\n nod(0), nxt(0), cap(0) {};\n Edge(int _nod, int _nxt, CapacityType _cap) :\n nod(_nod), nxt(_nxt), cap(_cap) {};\n }; std::vector lst;\n \n std::vector oki; int ptr = 0;\n std::vector beg, que, adj, dis;\n \n bool bfs(const int src, const int dst) {\n std::fill(dis.begin(), dis.end(), (CapacityType)INF);\n dis[src] = 0; que[0] = src;\n \n for (int qbg = 0, qen = 0; qbg <= qen; ++qbg) {\n const int x = que[qbg];\n \n for (int it = beg[x]; it != NIL; it = lst[it].nxt) {\n const int y = lst[it].nod;\n \n if (cmp(lst[it].cap) > 0 and dis[y] == INF)\n dis[y] = dis[x] + 1, que[++qen] = y;\n }\n }\n \n return dis[dst] != INF;\n }\n \n CapacityType dfs(const int x, const int dst, const CapacityType cap) {\n if (!cmp(cap) or x == dst)\n return cap;\n \n for (; adj[x] != NIL; adj[x] = lst[adj[x]].nxt) {\n const int y = lst[adj[x]].nod;\n \n if (cmp(lst[adj[x]].cap) > 0 and dis[y] == dis[x] + 1) {\n const CapacityType aux = dfs(y, dst, std::min(cap, lst[adj[x]].cap));\n \n if (cmp(aux)) {\n lst[adj[x]].cap -= aux;\n lst[adj[x] ^ 1].cap += aux;\n return aux;\n }\n }\n }\n \n return 0;\n }\n \n void fill(const int x) {\n oki[x] = true;\n \n for (int it = beg[x]; it != NIL; it = lst[it].nxt) {\n const int y = lst[it].nod;\n \n if (cmp(lst[it].cap) > 0 and !oki[y])\n fill(y);\n }\n }\npublic:\n MaxFlow(int szn, int szm) {\n dis.resize(szn); beg.resize(szn);\n que.resize(szn); adj.resize(szn);\n oki.resize(szn); lst.resize(szm); // m != n\n \n std::fill(beg.begin(), beg.end(), (int)NIL);\n }\n \n inline void addDirectedEdge(const int x, const int y, const CapacityType cap) {\n lst[ptr] = Edge(y, beg[x], cap); beg[x] = ptr++;\n lst[ptr] = Edge(x, beg[y], 0 ); beg[y] = ptr++;\n }\n \n inline void addUndirectedEdge(const int x, const int y, const CapacityType cap) {\n lst[ptr] = Edge(y, beg[x], cap); beg[x] = ptr++;\n lst[ptr] = Edge(x, beg[y], cap); beg[y] = ptr++;\n }\n \n CapacityType getMaxFlow(const int src, const int dst) {\n CapacityType aux, ans = 0;\n \n while (bfs(src, dst)) {\n copy(beg.begin(), beg.end(), adj.begin());\n \n do {\n aux = dfs(src, dst, INF);\n ans += aux;\n } while (cmp(aux));\n }\n \n return ans;\n }\n \n CapacityType getMinCut(const int src, const int dst, std::vector &ans) {\n std::fill(oki.begin(), oki.end(), false);\n CapacityType sol = getMaxFlow(src, dst); fill(src);\n \n ans.clear();\n for (int i = 0; i < oki.size(); ++i)\n if (oki[i]) ans.push_back(i);\n \n return sol;\n }\n};\n\nstruct edge {\n int x, y, a, b, c, d; } edl[MMAX];\n\ninline long double sign(long double x)\n{\n if (-EPS < x and x < +EPS)\n return 0;\n return x < 0 ? -1 : 1;\n}\n\nlong double check(long double t, int n, int m)\n{\n int src = n + 1, dst = n + 2; long double sum = 0;\n MaxFlow myNetwork(n + 5, m * 6 + 5);\n \n for (int i = 1; i <= m; ++i) {\n int x = edl[i].x, y = edl[i].y;\n long double le = t * edl[i].a + edl[i].b,\n ri = t * edl[i].c + edl[i].d;\n \n sum += le;\n myNetwork.addDirectedEdge(x, y, ri - le);\n myNetwork.addDirectedEdge(src, y, le);\n myNetwork.addDirectedEdge(x, dst, le);\n }\n \n return sum - myNetwork.getMaxFlow(src, dst);\n}\n\nlong double solve(long double le, long double ri, int n, int m)\n{\n long double ans = 0;\n for (int i = 1; i <= 70; ++i) {\n long double md = (le + ri) / 2.0;\n \n if (sign(check(md, n, m)) <= 0) {\n ans += fabs(md - le);\n le = md;\n } else\n ri = md;\n }\n return ans;\n}\n\nvoid debug(void)\n{\n MaxFlow myNetwork(4, 6);\n \n myNetwork.addDirectedEdge(1, 2, 0.5);\n myNetwork.addDirectedEdge(2, 3, 0.3);\n \n cerr << myNetwork.getMaxFlow(1, 3);\n \n exit(0);\n}\n\nint main(void)\n{\n freopen(\"test.in\", \"r\", stdin);\n freopen(\"test.out\", \"w\", stdout);\n \n // debug();\n \n int n, m;\n cin >> n >> m;\n \n for (int i = 1; i <= m; ++i) {\n cin >> edl[i].x >> edl[i].y;\n cin >> edl[i].a >> edl[i].b >> edl[i].c >> edl[i].d;\n }\n \n /*\n for (double x = 0.0; x <= 1.00001; x += 0.05) {\n cout << setprecision(2) << fixed << x << \" \";\n cout << setprecision(10) << fixed << check(x, n, m) << endl;\n }\n */\n \n long double le = 0.0, ri = 1.0;\n for (int i = 1; i <= 70; ++i) {\n long double md1 = le + (ri - le) / 3.0,\n md2 = ri - (ri - le) / 3.0;\n \n long double ans1 = check(md1, n, m),\n ans2 = check(md2, n, m);\n \n if (sign(ans1) <= 0 and sign(ans2) <= 0) {\n cout << setprecision(10) << fixed;\n cout << solve((md1 + md2) / 2.0, 1.0, n, m) + solve((md1 + md2) / 2.0, 0.0, n, m);\n break;\n }\n \n if (ans1 < ans2) ri = md2;\n else le = md1;\n }\n \n return 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "98f45ee357484865fda598cf0680a9c3", "src_uid": "e04a5732ad00fd63fbb52a3fb3e88ac6", "difficulty": 3100.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\nnamespace Dinic {\n\ttypedef long long F;\n\tconst F INF = 1LL<<60;\n\n\tconst int N = 1100;\n\tconst int M = 11000;\n\n\tint fst[N], nxt[M], to[M];\n\tF cap[M];\n\tint dis[N], q[N], ptr[N];\n\tint V, E;\n\n\tvoid init() {\n\t\tmemset(fst, -1, sizeof fst);\n\t\tV = E = 0;\n\t}\n\tinline int add_node() { V++; return V-1; }\n\tinline void add_edge(int u, int v, F c) {\n\t\tto[E] = v, cap[E] = c, nxt[E] = fst[u], fst[u] = E++;\n\t\tto[E] = u, cap[E] = 0, nxt[E] = fst[v], fst[v] = E++;\n\t}\n\tinline bool bfs(int S, int T, int n) {\n\t\tmemset(dis, -1, sizeof(int) * n);\n\t\tint h = 0, t = 0;\n\t\tdis[S] = 0, q[t++] = S;\n\t\twhile (h < t) {\n\t\t\tint u = q[h++];\n\t\t\tfor (int e = fst[u]; ~e; e = nxt[e]) if (cap[e] > 0 && dis[to[e]] == -1) {\n\t\t\t\tdis[to[e]] = dis[u] + 1, q[t++] = to[e];\n\t\t\t\tif (to[e] == T) return 1;\n\t\t\t}\n\t\t}\n\t\treturn (dis[T] != -1);\n\t}\n\tF dfs(int u, int T, F f) {\n\t\tif (u == T) return f;\n\t\tfor (int &e = ptr[u]; ~e; e = nxt[e]) if (cap[e] > 0 && dis[to[e]] > dis[u]) {\n\t\t\tF ret = dfs(to[e], T, min(f, cap[e]));\n\t\t\tif (ret > 0) {\n\t\t\t\tcap[e] -= ret, cap[e ^ 1] += ret;\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t}\n\t\treturn 0;\n\t}\n\tF max_flow(int S, int T, int n = V) {\n\t\tF ret = 0;\n\t\twhile (bfs(S, T, n)) {\n\t\t\tmemcpy(ptr, fst, sizeof(int) * n);\n\t\t\tfor (F cur; (cur = dfs(S, T, INF)) > 0; ret += cur);\n\t\t}\n\t\treturn ret;\n\t}\n}\n\nlong long ssum[1100], tsum[1100];\n\nint main() {\n\tint n, m; scanf(\"%d%d\", &n, &m);\n\tstruct Edge {\n\t\tint u, v, a, b, c, d;\n\t\tvoid input() { scanf(\"%d%d%d%d%d%d\", &u, &v, &a, &b, &c, &d); }\n\t} e[2200];\n\tfor (int i = 1; i <= m; i++) e[i].input();\n\tint st = 0;\n\tint ans = 0;\n\tfor (int j = 0; j < 2; j++) {\n\t\tint en = 1<<23;\n\t\twhile (st < en) {\n\t\t\tDinic::init();\n\t\t\tint mid = st + en >> 1;\n\t\t\tfor (int i = 1; i <= n; i++) ssum[i] = tsum[i] = 0;\n\t\t\tfor (int i = 1; i <= m; i++) {\n\t\t\t\tint u = e[i].u, v = e[i].v;\n\t\t\t\tlong long l = e[i].a * 1LL * mid + ((long long)e[i].b << 23);\n\t\t\t\tlong long r = e[i].c * 1LL * mid + ((long long)e[i].d << 23);\n\t\t\t\tssum[v] += l, tsum[u] += l;\n\t\t\t\tDinic::add_edge(u, v, r - l);\n\t\t\t}\n\t\t\tfor (int i = 1; i <= n; i++) {\n\t\t\t\tif (ssum[i]) Dinic::add_edge(0, i, ssum[i]);\n\t\t\t\tif (tsum[i]) Dinic::add_edge(i, n+1, tsum[i]);\n\t\t\t}\n\t\t\tlong long tot = 0;\n\t\t\tfor (int i = 1; i <= n; i++) tot += ssum[i];\n\t\t\tlong long ret = Dinic::max_flow(0, n+1, n+2);\n\t\t\tif (j == 0) {\n\t\t\t\tif (ret == tot) en = mid;\n\t\t\t\telse st = mid+1;\n\t\t\t} else {\n\t\t\t\tif (ret == tot) st = mid;\n\t\t\t\telse en = mid-1;\n\t\t\t}\n\t\t}\n\t\tif (j == 0) ans -= st;\n\t\telse ans += st;\n\t}\n\tprintf(\"%.10lf\\n\", ans * 1.0 / (1<<23));\n\treturn 0;\n}\n\n ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9a6e4b7f1286ca4044e5a3294db16adb", "src_uid": "e04a5732ad00fd63fbb52a3fb3e88ac6", "difficulty": 3100.0} {"lang": "GNU C++17", "source_code": "// Created by Nikolay Budin\n\n#ifdef DEBUG\n# define _GLIBCXX_DEBUG\n#endif\n#include \n#include \n#define ff first\n#define ss second\n#define szof(x) ((int)x.size())\n#ifndef LOCAL\n# define cerr __get_ce\n#endif\n\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pii;\ntypedef unsigned long long ull;\n\nusing namespace __gnu_pbds;\ntemplate using ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>;\ntemplate using ordered_map = tree, rb_tree_tag, tree_order_statistics_node_update>;\n\nint const INF = (int)1e9 + 1e3;\nll const INFL = (ll)1e18 + 1e6;\n#ifdef LOCAL\n\tmt19937 tw(9450189);\n#else\n\tmt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count());\n#endif\nuniform_int_distribution ll_distr;\nll rnd(ll a, ll b) { return ll_distr(tw) % (b - a + 1) + a; }\n\n\nvoid solve() {\n\tint n;\n\tcin >> n;\n\tvector color(n);\n\tfor (int& num : color) {\n\t\tcin >> num;\n\t}\n\tvector> graph(n);\n\tfor (int i = 0; i < n - 1; ++i) {\n\t\tint a, b;\n\t\tcin >> a >> b;\n\t\t--a; --b;\n\t\tgraph[a].push_back(b);\n\t\tgraph[b].push_back(a);\n\t}\n\n\tint ans = INF;\n\n\tint cnt1 = 0, cnt2 = 0;\n\t{\n\t\tvector used(n);\n\t\tfunction dfs = [&](int v) {\n\t\t\tused[v] = true;\n\t\t\tfor (int to : graph[v]) {\n\t\t\t\tif (color[to] == color[v] && !used[to]) {\n\t\t\t\t\tdfs(to);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tif (!used[i]) {\n\t\t\t\tdfs(i);\n\t\t\t\tif (color[i] == 1) {\n\t\t\t\t\t++cnt1;\n\t\t\t\t}\n\t\t\t\tif (color[i] == 2) {\n\t\t\t\t\t++cnt2;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t}\n\n\tans = min(ans, 1 + cnt2);\n\tans = min(ans, 1 + cnt1);\n\n\tfor (int qwe = 0; qwe < 2; ++qwe) {\n\t\tvector sz(n);\n\t\tconst int MAX_SZ = 1000;\n\t\tfunction(int, int)> dfs = [&](int v, int p) {\n\t\t\tvector dp;\n\t\t\tif (color[v] == 1 || color[v] == 0) {\n\t\t\t\tdp = {1};\n\t\t\t} else {\n\t\t\t\tdp = {INF, 2};\n\t\t\t}\n\t\t\tsz[v] = 1;\n\t\t\tfor (int to : graph[v]) {\n\t\t\t\tif (to != p) {\n\t\t\t\t\tvector tmp = dfs(to, v);\n\t\t\t\t\tsz[v] += sz[to];\n\t\t\t\t\tvector next_dp(min(sz[v] + 2, MAX_SZ), INF);\n\t\t\t\t\tfor (int i = 0; i < szof(next_dp); ++i) {\n\t\t\t\t\t\tint dp_val = INF;\n\t\t\t\t\t\tif (i < szof(dp)) {\n\t\t\t\t\t\t\tdp_val = dp[i];\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif ((color[v] == 1 || color[v] == 0) && i % 2 == 0) {\n\t\t\t\t\t\t\t\tdp_val = i + 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ((color[v] == 2 || color[v] == 0) && i % 2 == 1) {\n\t\t\t\t\t\t\t\tdp_val = i + 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (int j = 0; j < szof(tmp); ++j) {\n\t\t\t\t\t\t\tnext_dp[i] = min(next_dp[i], dp_val + tmp[j] - min(i, j) - 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tswap(next_dp, dp);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn dp;\n\t\t};\n\n\t\tauto dp = dfs(0, 0);\n\t\tans = min(ans, *min_element(dp.begin(), dp.end()));\n\n\t\tfor (int& num : color) {\n\t\t\tif (num == 1) {\n\t\t\t\tnum = 2;\n\t\t\t} else if (num == 2) {\n\t\t\t\tnum = 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tcout << ans << \"\\n\";\n}\n\n\nint main() {\n#ifdef LOCAL\n\tauto start_time = clock();\n\tcerr << setprecision(3) << fixed;\n#endif\n\tcout << setprecision(15) << fixed;\n\tios::sync_with_stdio(false);\n\tcin.tie(nullptr);\n\n\tint test_count = 1;\n\tcin >> test_count;\n\tfor (int test = 1; test <= test_count; ++test) {\n\t\tsolve();\n\t}\n\n#ifdef LOCAL\n\tauto end_time = clock();\n\tcerr << \"Execution time: \" << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << \" ms\\n\";\n#endif\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "22aa0adf3e2ad46d6cb03a5a4a9f01dd", "src_uid": "7c5ae79eeff98960fb52416541dd6528", "difficulty": 3000.0} {"lang": "GNU C++17", "source_code": "// Created by Nikolay Budin\n\n#ifdef DEBUG\n# define _GLIBCXX_DEBUG\n#endif\n#include \n#include \n#define ff first\n#define ss second\n#define szof(x) ((int)x.size())\n#ifndef LOCAL\n# define cerr __get_ce\n#endif\n\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pii;\ntypedef unsigned long long ull;\n\nusing namespace __gnu_pbds;\ntemplate using ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>;\ntemplate using ordered_map = tree, rb_tree_tag, tree_order_statistics_node_update>;\n\nint const INF = (int)1e9 + 1e3;\nll const INFL = (ll)1e18 + 1e6;\n#ifdef LOCAL\n\tmt19937 tw(9450189);\n#else\n\tmt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count());\n#endif\nuniform_int_distribution ll_distr;\nll rnd(ll a, ll b) { return ll_distr(tw) % (b - a + 1) + a; }\n\n\nvoid solve() {\n\tint n;\n\tcin >> n;\n\tvector color(n);\n\tfor (int& num : color) {\n\t\tcin >> num;\n\t}\n\tvector> graph(n);\n\tfor (int i = 0; i < n - 1; ++i) {\n\t\tint a, b;\n\t\tcin >> a >> b;\n\t\t--a; --b;\n\t\tgraph[a].push_back(b);\n\t\tgraph[b].push_back(a);\n\t}\n\n\tint ans = INF;\n\n\tint cnt1 = 0, cnt2 = 0;\n\t{\n\t\tvector used(n);\n\t\tfunction dfs = [&](int v) {\n\t\t\tused[v] = true;\n\t\t\tfor (int to : graph[v]) {\n\t\t\t\tif (color[to] == color[v] && !used[to]) {\n\t\t\t\t\tdfs(to);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tif (!used[i]) {\n\t\t\t\tdfs(i);\n\t\t\t\tif (color[i] == 1) {\n\t\t\t\t\t++cnt1;\n\t\t\t\t}\n\t\t\t\tif (color[i] == 2) {\n\t\t\t\t\t++cnt2;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t}\n\n\tans = min(ans, 1 + cnt2);\n\tans = min(ans, 1 + cnt1);\n\n\tfor (int qwe = 0; qwe < 2; ++qwe) {\n\t\tvector sz(n);\n\t\tconst int MAX_SZ = 500;\n\t\tfunction(int, int)> dfs = [&](int v, int p) {\n\t\t\tvector dp;\n\t\t\tif (color[v] == 1 || color[v] == 0) {\n\t\t\t\tdp = {1};\n\t\t\t} else {\n\t\t\t\tdp = {INF, 2};\n\t\t\t}\n\t\t\tsz[v] = 1;\n\t\t\tfor (int to : graph[v]) {\n\t\t\t\tif (to != p) {\n\t\t\t\t\tvector tmp = dfs(to, v);\n\t\t\t\t\tsz[v] += sz[to];\n\t\t\t\t\tvector next_dp(min(sz[v] + 2, MAX_SZ), INF);\n\t\t\t\t\tfor (int i = 0; i < szof(next_dp); ++i) {\n\t\t\t\t\t\tint dp_val = INF;\n\t\t\t\t\t\tif (i < szof(dp)) {\n\t\t\t\t\t\t\tdp_val = dp[i];\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif ((color[v] == 1 || color[v] == 0) && i % 2 == 0) {\n\t\t\t\t\t\t\t\tdp_val = i + 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ((color[v] == 2 || color[v] == 0) && i % 2 == 1) {\n\t\t\t\t\t\t\t\tdp_val = i + 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (int j = 0; j < szof(tmp); ++j) {\n\t\t\t\t\t\t\tnext_dp[i] = min(next_dp[i], dp_val + tmp[j] - min(i, j) - 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tswap(next_dp, dp);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn dp;\n\t\t};\n\n\t\tauto dp = dfs(0, 0);\n\t\tans = min(ans, *min_element(dp.begin(), dp.end()));\n\n\t\tfor (int& num : color) {\n\t\t\tif (num == 1) {\n\t\t\t\tnum = 2;\n\t\t\t} else if (num == 2) {\n\t\t\t\tnum = 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tcout << ans << \"\\n\";\n}\n\n\nint main() {\n#ifdef LOCAL\n\tauto start_time = clock();\n\tcerr << setprecision(3) << fixed;\n#endif\n\tcout << setprecision(15) << fixed;\n\tios::sync_with_stdio(false);\n\tcin.tie(nullptr);\n\n\tint test_count = 1;\n\tcin >> test_count;\n\tfor (int test = 1; test <= test_count; ++test) {\n\t\tsolve();\n\t}\n\n#ifdef LOCAL\n\tauto end_time = clock();\n\tcerr << \"Execution time: \" << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << \" ms\\n\";\n#endif\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "57f846c4fcfb0f3b90cef686c52e18bf", "src_uid": "7c5ae79eeff98960fb52416541dd6528", "difficulty": 3000.0} {"lang": "GNU C++17", "source_code": "// Created by Nikolay Budin\n\n#ifdef DEBUG\n# define _GLIBCXX_DEBUG\n#endif\n#include \n#include \n#define ff first\n#define ss second\n#define szof(x) ((int)x.size())\n#ifndef LOCAL\n# define cerr __get_ce\n#endif\n\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pii;\ntypedef unsigned long long ull;\n\nusing namespace __gnu_pbds;\ntemplate using ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>;\ntemplate using ordered_map = tree, rb_tree_tag, tree_order_statistics_node_update>;\n\nint const INF = (int)1e9 + 1e3;\nll const INFL = (ll)1e18 + 1e6;\n#ifdef LOCAL\n\tmt19937 tw(9450189);\n#else\n\tmt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count());\n#endif\nuniform_int_distribution ll_distr;\nll rnd(ll a, ll b) { return ll_distr(tw) % (b - a + 1) + a; }\n\n\nvoid solve() {\n\tint n;\n\tcin >> n;\n\tvector color(n);\n\tfor (int& num : color) {\n\t\tcin >> num;\n\t}\n\tvector> graph(n);\n\tfor (int i = 0; i < n - 1; ++i) {\n\t\tint a, b;\n\t\tcin >> a >> b;\n\t\t--a; --b;\n\t\tgraph[a].push_back(b);\n\t\tgraph[b].push_back(a);\n\t}\n\n\tint ans = INF;\n\n\tfor (int qwe = 0; qwe < 2; ++qwe) {\n\t\tvector sz(n);\n\t\tfunction(int, int)> dfs = [&](int v, int p) {\n\t\t\tvector dp;\n\t\t\tif (color[v] == 1 || color[v] == 0) {\n\t\t\t\tdp = {1};\n\t\t\t} else {\n\t\t\t\tdp = {INF, 2};\n\t\t\t}\n\t\t\tsz[v] = 1;\n\t\t\tfor (int to : graph[v]) {\n\t\t\t\tif (to != p) {\n\t\t\t\t\tvector tmp = dfs(to, v);\n\t\t\t\t\tsz[v] += sz[to];\n\t\t\t\t\tvector next_dp(sz[v] + 2, INF);\n\t\t\t\t\tfor (int i = 0; i < szof(next_dp); ++i) {\n\t\t\t\t\t\tint dp_val = INF;\n\t\t\t\t\t\tif (i < szof(dp)) {\n\t\t\t\t\t\t\tdp_val = dp[i];\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif ((color[v] == 1 || color[v] == 0) && i % 2 == 0) {\n\t\t\t\t\t\t\t\tdp_val = i + 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ((color[v] == 2 || color[v] == 0) && i % 2 == 1) {\n\t\t\t\t\t\t\t\tdp_val = i + 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (int j = 0; j < szof(tmp); ++j) {\n\t\t\t\t\t\t\tnext_dp[i] = min(next_dp[i], dp_val + tmp[j] - min(i, j) - 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tswap(next_dp, dp);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn dp;\n\t\t};\n\n\t\tauto dp = dfs(0, 0);\n\t\tans = min(ans, *min_element(dp.begin(), dp.end()));\n\n\t\tfor (int& num : color) {\n\t\t\tif (num == 1) {\n\t\t\t\tnum = 2;\n\t\t\t} else if (num == 2) {\n\t\t\t\tnum = 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tcout << ans << \"\\n\";\n}\n\n\nint main() {\n#ifdef LOCAL\n\tauto start_time = clock();\n\tcerr << setprecision(3) << fixed;\n#endif\n\tcout << setprecision(15) << fixed;\n\tios::sync_with_stdio(false);\n\tcin.tie(nullptr);\n\n\tint test_count = 1;\n\tcin >> test_count;\n\tfor (int test = 1; test <= test_count; ++test) {\n\t\tsolve();\n\t}\n\n#ifdef LOCAL\n\tauto end_time = clock();\n\tcerr << \"Execution time: \" << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << \" ms\\n\";\n#endif\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "944af4424c64c905735ad75ea57557cd", "src_uid": "7c5ae79eeff98960fb52416541dd6528", "difficulty": 3000.0} {"lang": "GNU C++17", "source_code": "// Created by Nikolay Budin\n\n#ifdef DEBUG\n# define _GLIBCXX_DEBUG\n#endif\n#include \n#include \n#define ff first\n#define ss second\n#define szof(x) ((int)x.size())\n#ifndef LOCAL\n# define cerr __get_ce\n#endif\n\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pii;\ntypedef unsigned long long ull;\n\nusing namespace __gnu_pbds;\ntemplate using ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>;\ntemplate using ordered_map = tree, rb_tree_tag, tree_order_statistics_node_update>;\n\nint const INF = (int)1e9 + 1e3;\nll const INFL = (ll)1e18 + 1e6;\n#ifdef LOCAL\n\tmt19937 tw(9450189);\n#else\n\tmt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count());\n#endif\nuniform_int_distribution ll_distr;\nll rnd(ll a, ll b) { return ll_distr(tw) % (b - a + 1) + a; }\n\n\nvoid solve() {\n\tint n;\n\tcin >> n;\n\tvector color(n);\n\tfor (int& num : color) {\n\t\tcin >> num;\n\t}\n\tvector> graph(n);\n\tfor (int i = 0; i < n - 1; ++i) {\n\t\tint a, b;\n\t\tcin >> a >> b;\n\t\t--a; --b;\n\t\tgraph[a].push_back(b);\n\t\tgraph[b].push_back(a);\n\t}\n\n\tint ans = INF;\n\n\tint cnt1 = 0, cnt2 = 0;\n\t{\n\t\tvector used(n);\n\t\tfunction dfs = [&](int v) {\n\t\t\tused[v] = true;\n\t\t\tfor (int to : graph[v]) {\n\t\t\t\tif (color[to] == color[v] && !used[to]) {\n\t\t\t\t\tdfs(to);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tfor (int i = 0; i < n; ++i) {\n\t\t\tif (!used[i]) {\n\t\t\t\tdfs(i);\n\t\t\t\tif (color[i] == 1) {\n\t\t\t\t\t++cnt1;\n\t\t\t\t}\n\t\t\t\tif (color[i] == 2) {\n\t\t\t\t\t++cnt2;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t}\n\n\tans = min(ans, 1 + cnt2);\n\tans = min(ans, 1 + cnt1);\n\n\tfor (int qwe = 0; qwe < 2; ++qwe) {\n\t\tvector sz(n);\n\t\tconst int MAXSZ = 10000;\n\t\tvector> dp(n, vector(MAXSZ, INF));\n\t\tvector next_dp(MAXSZ, INF);\n\t\tfunction dfs = [&](int v, int p) {\n\t\t\t// vector dp;\n\t\t\tif (color[v] == 1 || color[v] == 0) {\n\t\t\t\tdp[v][0] = 1;\n\t\t\t\tdp[v][2] = 3;\n\t\t\t} else {\n\t\t\t\t// dp = {INF, 2};\n\t\t\t\tdp[v][1] = 2;\n\t\t\t}\n\t\t\tsz[v] = 1;\n\t\t\tfor (int to : graph[v]) {\n\t\t\t\tif (to != p) {\n\t\t\t\t\tdfs(to, v);\n\t\t\t\t\tint mem_sz = sz[v] + 2;\n\t\t\t\t\tsz[v] += sz[to];\n\t\t\t\t\t// vector next_dp(min(MAXSZ, sz[v] + 2), INF);\n\t\t\t\t\tint tmp_sz = min(MAXSZ, sz[v] + 2);\n\t\t\t\t\tfor (int i = 0; i < tmp_sz; ++i) {\n\t\t\t\t\t\tint dp_val = INF;\n\t\t\t\t\t\tif (i < mem_sz) {\n\t\t\t\t\t\t\tdp_val = dp[v][i];\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif ((color[v] == 1 || color[v] == 0) && i % 2 == 0) {\n\t\t\t\t\t\t\t\tdp_val = i + 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ((color[v] == 2 || color[v] == 0) && i % 2 == 1) {\n\t\t\t\t\t\t\t\tdp_val = i + 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (int j = 0; j < sz[to] + 2 && j < MAXSZ; ++j) {\n\t\t\t\t\t\t\tnext_dp[i] = min(next_dp[i], dp_val + dp[to][j] - min(i, j) - 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tswap(next_dp, dp[v]);\n\t\t\t\t\tfill(next_dp.begin(), next_dp.begin() + min(MAXSZ, mem_sz), INF);\n\t\t\t\t}\n\t\t\t}\n\t\t\t// return dp;\n\t\t};\n\n\t\tdfs(0, 0);\n\t\tans = min(ans, *min_element(dp[0].begin(), dp[0].end()));\n\n\t\tfor (int& num : color) {\n\t\t\tif (num == 1) {\n\t\t\t\tnum = 2;\n\t\t\t} else if (num == 2) {\n\t\t\t\tnum = 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tcout << ans << \"\\n\";\n}\n\n\nint main() {\n#ifdef LOCAL\n\tauto start_time = clock();\n\tcerr << setprecision(3) << fixed;\n#endif\n\tcout << setprecision(15) << fixed;\n\tios::sync_with_stdio(false);\n\tcin.tie(nullptr);\n\n\tint test_count = 1;\n\tcin >> test_count;\n\tfor (int test = 1; test <= test_count; ++test) {\n\t\tsolve();\n\t}\n\n#ifdef LOCAL\n\tauto end_time = clock();\n\tcerr << \"Execution time: \" << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << \" ms\\n\";\n#endif\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fb1b8a7bd34b0ec8511b59eb13a70895", "src_uid": "7c5ae79eeff98960fb52416541dd6528", "difficulty": 3000.0} {"lang": "GNU C++17", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#include \"bits/stdc++.h\"\n\nusing namespace std;\ntypedef long long ll;\ntypedef double db;\ntypedef vector VS;\ntypedef vector VI;\ntypedef vector VVI;\ntypedef vector VLL; \ntypedef vector VVLL;\ntypedef vector VVVLL;\ntypedef pair PLL;\ntypedef map MLL;\ntypedef set SLL;\ntypedef queue QLL;\n\n#define rep(x,l,u) for(ll x = l; x < u; x++)\n#define rrep(x,l,u) for(ll x = l; x >= u; x--)\n#define fe(x,a) for (auto x : a)\n#define all(x) x.begin(), x.end()\n#define rall(x) x.rbegin(), x.rend()\n#define mst(x,v) memset(x, v, sizeof(x))\n#define sz(x) (ll)x.size()\n#define lg(x) (ll)x.length()\n#define fi first\n#define se second\n#define pb push_back\n\n#define umap unordered_map\n#define uset unordered_set\n#define mset multiset\n#define pqueue priority_queue\n\nstruct FASTINPUT {\n\tvoid f(string & s) { char buf[400005]; ll a = scanf(\"%s\", buf); a++; s = buf; }\n\tvoid f(ll & x) { ll a = scanf(\"%lld\", &x); a++; }\n\tvoid f(int & x) { ll a = scanf(\"%d\", &x); a++; }\n\tvoid f(double & x) { ll a = scanf(\"%lf\", &x); a++; }\n\ttemplate void f(pair & p) { f(p.first); f(p.second); }\n\ttemplate void f(vector & x) { for (auto & y : x) f(y); }\n\t\n\tvoid read() {}\n\ttemplate void read(Head & H, Tail & ... T) { f(H); read(T...); }\n};\n\nstruct FASTOUTPUT {\n\tvoid f(string s) { printf(\"%s\", s.c_str()); }\n\tvoid f(ll x) { printf(\"%lld\", x); }\n\tvoid f(int x) { printf(\"%d\", x); }\n\tvoid f(double x) { printf(\"%.20f\", x); }\n\tvoid f(char x) { printf(\"%c\", x); }\n\tvoid f(const char* a) { printf(\"%s\", a); }\n\ttemplate void f(vector & x) { for (auto & y : x) { f(y); f(\" \");} }\n\n\n\tvoid print() {}\n\ttemplate void print(Head H, Tail ... T) { f(H); print(T...); }\n};\n\nstruct DEBUG {\n\tstring open = \"[\", close = \"]\", sep = \", \";\n\n\tstring f(string s) { return s; }\n\tstring f(char c) { return string(1, c); }\n\tstring f(int x) { return to_string(x); }\n\tstring f(ll x) { return to_string(x); }\n\tstring f(db x) { return to_string(x); }\n\tstring f(const char* a) { return a; }\n\ttemplate string f(pair p) { return open + f(p.first) + sep + f(p.second) + close; }\n\ttemplate string f(A v) { string s = open; for (auto a : v) { if (s != open) { s += sep; } s += f(a); } s += close; return s; } \n\n\tvoid show() {cout << endl;}\n\ttemplate void show(Head H, Tail... T) { cout << \" \" << f(H); show(T...); }\n};\n\n#define fin(...) do { FASTINPUT inp; inp.read(__VA_ARGS__); } while (false)\n#define fout(...) do { FASTOUTPUT out; out.print(__VA_ARGS__); } while (false)\n#define debug(...) do { DEBUG deb; cout << \"[\" << #__VA_ARGS__ << \"]:\", deb.show(__VA_ARGS__); } while (false)\n\nVLL di = {0,0,1,-1,1,-1,1,-1};\nVLL dj = {1,-1,0,0,-1,-1,1,1};\nll ob(ll i, ll n) { return i < 0 || i >= n; } // out of bounds\nll tp(ll x) { return (1LL< ll exist(A a, B b) { return a.find(b) != a.end(); }\nvector ssplit(string s) { vector ans; stringstream ss; ss << s; while (ss >> s) ans.pb(s); return ans; }\nvoid makemod(ll & x, ll m) { x %= m; x += m; x %= m; }\nll powmod(ll a, ll b, ll m) { if (b == 0) return 1;\tll h = powmod(a, b/2, m); ll ans = h*h%m; return b%2 ? ans*a%m : ans; }\nbool isvowel(char ch) { return (ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u'); }\nll sign(ll x) {\treturn x > 0 ? 1 : x < 0 ? -1 : 0; }\n\nvoid upmin(ll & x, ll v) { x = min(x, v); }\nvoid upmax(ll & x, ll v) { x = max(x, v); }\n\nconst VLL mods = {(ll)1e9 + 7, 998244353, (ll)1e6 + 3, (ll)1e18 + 5};\nconst ll mod = mods[0];\nconst ll inf = mods[3];\nconst db eps = 1e-10;\nconst db pi = acos(0) * 2;\nconst string nl = \"\\n\";\n\nvoid dfs(ll at, ll color, ll k, VVLL & E, VLL & vis) {\n\tif (vis[at]) return;\n\tvis[at] = color;\n\tfe(to, E[at]) {\n\t\tdfs(to, color, k, E, vis);\n\t}\n}\n\nvoid solve() {\n\tll n, k = 20;\n\tstring a, b;\n\tfin(n, a, b);\n\n\tVVLL E(k);\n\n\t// count number of unique c->d transforms. \n\t// 26 x 26 adj matrix.\n\t// if there is a->b, b->z, a->z, that can become 2 transforms\n\tVLL reach(k);\n\trep(i,0,n) {\n\t\tll x = a[i] - 'a', y = b[i] - 'a';\n\t\treach[x] |= tp(y);\n\t\tE[x].pb(y);\n\t\tE[y].pb(x);\n\t}\n\n\n\t// each component is solved - find the largest directed acyclic graph\n\tVLL dp(tp(k));\n\tdp[0] = 1; // the set of nothing is acyclic\n\tll ans = 0;\n\trep(i,0,tp(k)) {\n\t\tif (dp[i]) {\n\t\t\tupmax(ans, __builtin_popcount(i));\n\t\t}\n\n\t\trep(j,0,k) {\n\t\t\t// going to fill in spot j\n\t\t\tif (tp(j) & i) continue;\n\t\t\tif ((reach[j] & i) == 0) dp[tp(j) | i] |= dp[i];\n\t\t}\n\t}\n\t\n\n\tVLL vis(k);\n\tll color = 0;\n\trep(i,0,k) {\n\t\tif (vis[i] == 0) dfs(i, ++color, k, E, vis);\n\t}\n\t\n\tfout(2 * k - color - ans, nl);\n}\n\nsigned main() {\n\tll t = 1;\n\tfin(t);\n\trep(i,0,t) solve();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7d6ea96448acf94fb545b7cb84ee762c", "src_uid": "d0735a763e2a40bfc94085019cd646f0", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include \n#define inf 0x3f3f3f3f\n#define inf64 0x3f3f3f3f3f3f3f3f\nusing namespace std;\nconst int maxn = 1e5+10;\nchar A[maxn],B[maxn];\nint f[30],to[30];\nint findx(int x){\n return f[x]==x?x:f[x]=findx(f[x]);\n}\nvoid unite(int x,int y){\n x = findx(x);\n y = findx(y);\n if(x==y) return ;\n f[x]=y;\n}\nbool dp[1<<21];\nint main(){\n int t;\n scanf(\"%d\",&t);\n while(t--){\n int n;\n scanf(\"%d\",&n);\n scanf(\"%s%s\",A+1,B+1);\n for(int i=0;i<20;i++) f[i]=i,to[i]=0;\n for(int i=1;i<=n;i++){\n int x = A[i]-'a', y = B[i]-'a';\n to[x]|=(1<\n#undef assert\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define STRING_IMPL(...) #__VA_ARGS__\n#define STRING(...) STRING_IMPL(__VA_ARGS__)\n\n#ifdef DEBUG\n#include \n\n#define debug(...) debug_impl(\"[\" __FILE__ \":\" STRING(__LINE__) \"] \" #__VA_ARGS__ \" = \", __VA_ARGS__)\n#define optimize(...) do { assert(__VA_ARGS__); } while (0)\n#define assert(...) void(static_cast(__VA_ARGS__) ? void() : assert_failed(__FILE__, __LINE__, #__VA_ARGS__))\n\nvoid print_backtrace() {\n\tvoid *array[50];\n\n\tauto const size = backtrace(array, 50);\n\tauto messages = backtrace_symbols(array, size);\n\n\tfor (int i = 1; i < size && messages != NULL; ++i)\n\t\tstd::cerr << \"[bt]: (\" << i << \") \" << messages[i] << '\\n';\n\n\tfree(messages);\n}\n\nvoid assert_failed(char const file[], size_t line, char const cond[]) {\n\tstd::cerr << file << ':' << line << \": assert(\" << cond << \") failed.\\n\";\n\tprint_backtrace();\n\texit(EXIT_FAILURE);\n}\n#else\n#define debug(...) void()\n#define optimize(...) do { if (!(__VA_ARGS__)) __builtin_unreachable(); } while (0)\n#define assert(...) void()\n#endif\n\ntemplate \nvoid debug_impl(char const s[], T&&... vals) {\n\tstd::cerr << s;\n\tstd::size_t n{0};\n\t((std::cerr << std::forward(vals) << (++n != sizeof...(vals) ? \", \" : \"\")), ...);\n\tstd::cerr << '\\n';\n}\n\ntemplate \nstd::ostream& operator<<(std::ostream &os, std::tuple const &theTuple) {\n\tos << '(';\n\tstd::apply([&os](Ts const&... tupleArgs) {\n\t\t\tstd::size_t n{0};\n\t\t\t((os << tupleArgs << (++n != sizeof...(Ts) ? \", \" : \"\")), ...);\n\t\t}, theTuple);\n\treturn os << ')';\n}\n\ntemplate \nvoid print_iters(std::ostream &os, T begin, T end) {\n\tif (begin != end)\n\t\tfor (;;) {\n\t\t\tos << *begin;\n\t\t\tif (++begin == end) break;\n\t\t\tos << \", \";\n\t\t}\n}\n\ntemplate \nauto& operator<<(std::ostream &os, std::vector const &c) {\n\tos << '[';\n\tprint_iters(os, begin(c), end(c));\n\treturn os << ']';\n}\n\ntemplate \nauto& operator<<(std::ostream &os, std::array const &c) {\n\tos << '[';\n\tprint_iters(os, begin(c), end(c));\n\treturn os << ']';\n}\n\ntemplate \nauto& operator<<(std::ostream &os, std::set const &c) {\n\tos << '{';\n\tprint_iters(os, begin(c), end(c));\n\treturn os << '}';\n}\n\ntemplate \nauto& operator<<(std::ostream &os, std::pair const &p) {\n\treturn os << '(' << p.first << \", \" << p.second << ')';\n}\n\nauto& operator<<(std::ostream &os, uint8_t i) { return os << unsigned(i); }\nauto& operator<<(std::ostream &os, int8_t i) { return os << int(i); }\n\ntemplate \nauto& operator>>(std::istream &is, std::vector &v) {\n\tfor (auto &x : v) is >> x;\n\treturn is;\n}\n\ntemplate \nauto& operator>>(std::istream &is, std::array &a) {\n\tfor (auto &x : a) is >> x;\n\treturn is;\n}\n\ntemplate \nauto& operator>>(std::istream &is, std::pair &p) {\n\treturn is >> p.first >> p.second;\n}\n \ntemplate \nT read(Args&&... args) {\n\tT val(std::forward(args)...);\n\tstd::cin >> val;\n\tassert(std::cin.good());\n\treturn val;\n}\n\n/* * * * * * * * * * * * * * * *\\\n * Solution by Casarin Filippo *\n * Date: 24-07-2020 *\n\\* * * * * * * * * * * * * * * */\n\nconstexpr size_t S = 20;\n\nint32_t solve(std::string const &A, std::string const &B) {\n\tstd::array, S> pair_original {};\n\tstd::bitset Lgen;\n\n\tfor (size_t i = 0; i < size(A); ++i)\n\t\tif (A[i] != B[i]) {\n\t\t\tLgen.set(A[i] - 'a');\n\t\t\tLgen.set(B[i] - 'a');\n\t\t\tpair_original[A[i] - 'a'].set(B[i] - 'a');\n\t\t}\n\n\tuint32_t sol = S * S;\n\tstd::vector L;\n\n\tfor (size_t i = 0; i < S; ++i)\n\t\tif (Lgen.test(i))\n\t\t\tL.push_back(i);\n\n\tdebug(L);\n\n\tdo {\n\t\tuint32_t cnt = 0;\n\t\tauto pair = pair_original;\n\n\t\tfor (size_t i = 0; i+1 < size(L); ++i) {\n\t\t\tpair[L[i]].reset(L[i]);\n\t\t\tcnt += pair[L[i]].any();\n\t\t\tpair[L[i+1]] |= pair[L[i]];\n\t\t}\n\n\t\tpair[L.back()].reset(L.back());\n\t\tcnt += pair[L.back()].count();\n\n\t\tsol = std::min(sol, cnt);\n\t} while (next_permutation(begin(L), end(L)));\n\n\treturn sol;\n}\n\nint main() {\n\tstd::ios_base::sync_with_stdio(0);\n\tstd::cin.tie(0); std::cout.tie(0);\n\n\tauto T = read();\n\twhile (T--) {\n\t\tauto const N = read();\n\t\tauto const A = read();\n\t\tauto const B = read();\n\t\tassert(size(A) == N && size(B) == N);\n\t\tstd::cout << solve(A, B) << '\\n';\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5802aff0cc27d7806395927e201164d8", "src_uid": "d0735a763e2a40bfc94085019cd646f0", "difficulty": 3100.0} {"lang": "GNU C++17", "source_code": "#include \n#undef assert\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define STRING_IMPL(...) #__VA_ARGS__\n#define STRING(...) STRING_IMPL(__VA_ARGS__)\n\n#ifdef DEBUG\n#include \n\n#define debug(...) debug_impl(\"[\" __FILE__ \":\" STRING(__LINE__) \"] \" #__VA_ARGS__ \" = \", __VA_ARGS__)\n#define optimize(...) do { assert(__VA_ARGS__); } while (0)\n#define assert(...) void(static_cast(__VA_ARGS__) ? void() : assert_failed(__FILE__, __LINE__, #__VA_ARGS__))\n\nvoid print_backtrace() {\n\tvoid *array[50];\n\n\tauto const size = backtrace(array, 50);\n\tauto messages = backtrace_symbols(array, size);\n\n\tfor (int i = 1; i < size && messages != NULL; ++i)\n\t\tstd::cerr << \"[bt]: (\" << i << \") \" << messages[i] << '\\n';\n\n\tfree(messages);\n}\n\nvoid assert_failed(char const file[], size_t line, char const cond[]) {\n\tstd::cerr << file << ':' << line << \": assert(\" << cond << \") failed.\\n\";\n\tprint_backtrace();\n\texit(EXIT_FAILURE);\n}\n#else\n#define debug(...) void()\n#define optimize(...) do { if (!(__VA_ARGS__)) __builtin_unreachable(); } while (0)\n#define assert(...) void()\n#endif\n\ntemplate \nvoid debug_impl(char const s[], T&&... vals) {\n\tstd::cerr << s;\n\tstd::size_t n{0};\n\t((std::cerr << std::forward(vals) << (++n != sizeof...(vals) ? \", \" : \"\")), ...);\n\tstd::cerr << '\\n';\n}\n\ntemplate \nstd::ostream& operator<<(std::ostream &os, std::tuple const &theTuple) {\n\tos << '(';\n\tstd::apply([&os](Ts const&... tupleArgs) {\n\t\t\tstd::size_t n{0};\n\t\t\t((os << tupleArgs << (++n != sizeof...(Ts) ? \", \" : \"\")), ...);\n\t\t}, theTuple);\n\treturn os << ')';\n}\n\ntemplate \nvoid print_iters(std::ostream &os, T begin, T end) {\n\tif (begin != end)\n\t\tfor (;;) {\n\t\t\tos << *begin;\n\t\t\tif (++begin == end) break;\n\t\t\tos << \", \";\n\t\t}\n}\n\ntemplate \nauto& operator<<(std::ostream &os, std::vector const &c) {\n\tos << '[';\n\tprint_iters(os, begin(c), end(c));\n\treturn os << ']';\n}\n\ntemplate \nauto& operator<<(std::ostream &os, std::array const &c) {\n\tos << '[';\n\tprint_iters(os, begin(c), end(c));\n\treturn os << ']';\n}\n\ntemplate \nauto& operator<<(std::ostream &os, std::set const &c) {\n\tos << '{';\n\tprint_iters(os, begin(c), end(c));\n\treturn os << '}';\n}\n\ntemplate \nauto& operator<<(std::ostream &os, std::pair const &p) {\n\treturn os << '(' << p.first << \", \" << p.second << ')';\n}\n\nauto& operator<<(std::ostream &os, uint8_t i) { return os << unsigned(i); }\nauto& operator<<(std::ostream &os, int8_t i) { return os << int(i); }\n\ntemplate \nauto& operator>>(std::istream &is, std::vector &v) {\n\tfor (auto &x : v) is >> x;\n\treturn is;\n}\n\ntemplate \nauto& operator>>(std::istream &is, std::array &a) {\n\tfor (auto &x : a) is >> x;\n\treturn is;\n}\n\ntemplate \nauto& operator>>(std::istream &is, std::pair &p) {\n\treturn is >> p.first >> p.second;\n}\n \ntemplate \nT read(Args&&... args) {\n\tT val(std::forward(args)...);\n\tstd::cin >> val;\n\tassert(std::cin.good());\n\treturn val;\n}\n\n/* * * * * * * * * * * * * * * *\\\n * Solution by Casarin Filippo *\n * Date: 24-07-2020 *\n\\* * * * * * * * * * * * * * * */\n\nconstexpr size_t S = 20;\n\nint32_t solve(std::string const &A, std::string const &B) {\n\tstd::array, S> pair_original {};\n\tstd::vector L;\n\n\tfor (size_t i = 0; i < size(A); ++i)\n\t\tif (A[i] != B[i]) {\n\t\t\tL.push_back(A[i] - 'a');\n\t\t\tL.push_back(B[i] - 'a');\n\t\t\tpair_original[A[i] - 'a'].set(B[i] - 'a');\n\t\t}\n\n\tuint32_t sol = S * S;\n\tsort(begin(L), end(L));\n\tL.erase(unique(begin(L), end(L)), end(L));\n\n\tdebug(L);\n\n\tdo {\n\t\tuint32_t cnt = 0;\n\t\tauto pair = pair_original;\n\n\t\tfor (size_t i = 0; i+1 < size(L); ++i) {\n\t\t\tpair[L[i]].reset(L[i]);\n\t\t\tcnt += pair[L[i]].any();\n\t\t\tpair[L[i+1]] |= pair[L[i]];\n\t\t}\n\n\t\tpair[L.back()].reset(L.back());\n\t\tcnt += pair[L.back()].count();\n\n\t\tsol = std::min(sol, cnt);\n\t} while (next_permutation(begin(L), end(L)));\n\n\treturn sol;\n}\n\nint main() {\n\tstd::ios_base::sync_with_stdio(0);\n\tstd::cin.tie(0); std::cout.tie(0);\n\n\tauto T = read();\n\twhile (T--) {\n\t\tauto const N = read();\n\t\tauto const A = read();\n\t\tauto const B = read();\n\t\tassert(size(A) == N && size(B) == N);\n\t\tstd::cout << solve(A, B) << '\\n';\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "df8ff17e9831089eabe1fa5493dd312b", "src_uid": "d0735a763e2a40bfc94085019cd646f0", "difficulty": 3100.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\ntypedef long long ll;\ntypedef pair pnt;\n#define x first\n#define y second\n#define pb push_back\n#define mp make_pair\n#define sz(a) ((int)(a).size())\n\nll a[100];\nll b[100];\nll ans[100];\n\n\nint main() {\n\t#ifdef home\n \tfreopen(\"a.in\", \"r\", stdin);\n\t freopen(\"a.out\", \"w\", stdout);\n\t#endif\n\tint n, m;\n scanf(\"%d %d\", &n, &m);\n for (int i = 0; i < n; i++) { \t\n \tint x;\n \tscanf(\"%d\", &x);\n \tint cnt = 0;\n \twhile (x > 0) {\n \t\tif (x % 2 == 1) {\n \t\t\ta[cnt]++;\n \t\t}\n \t\tx /= 2;\n \t\tcnt++;\n \t}\n }\n ll Ans = 0;\n for (int i = 0; i < m; i++) {\n \tint x;\n \tscanf(\"%d\", &x);\n \tb[x]++;\t\t\n }\n ll tk = 0;\n for (int i = 60; i >= 0; i--) {\n \ttk = tk * 2 + a[i];\n \tll dd = min(tk, b[i]);\n \tans[i] += dd;\n \ttk -= dd;\n \tb[i] -= dd;\n \tAns += dd;\n }\n for (int i = 60; i >= 0; i--) {\n \tif (ans[i] > 0) {\n \t\tll sum = 0;\n \t\tfor (int j = 0; j < i; j++) {\n \t\t\tsum += b[j];\n \t\t}\n \t\tif (sum > 1) {\n \t\t\tans[i]--;\n \t\t\tAns--;\n \t\t\ttk = 1;\n \t\t\tfor (int j = i - 1; j >= 0; j--) {\n \t\t\t\ttk = tk * 2;\n\t\t\t \tll dd = min(tk, b[j]);\n\t\t\t \tans[j] += dd;\n\t\t\t \ttk -= dd;\n\t\t\t \tb[j] -= dd;\n\t\t\t \tAns += dd;\n \t\t\t}\n \t\t}\n \t}\n }\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define pb push_back\n#define mp make_pair\n#define eprintf(...) fprintf(stderr, __VA_ARGS__)\n#define sz(x) ((int)(x).size())\n\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vb;\ntypedef vector vvb;\ntypedef pair pii;\n\nint main() {\n #ifdef DEBUG\n freopen(\".in\", \"r\", stdin);\n freopen(\".out\", \"w\", stdout);\n #endif\n\n int n, m;\n while (scanf(\"%d%d\", &n, &m) >= 1) {\n vi bs(m);\n multiset as;\n for (int i = 0; i < n; i++) {\n int x;\n scanf(\"%d\", &x);\n as.insert(x);\n }\n for (int i = 0; i < m; i++)\n scanf(\"%d\", &bs[i]), bs[i] = 1 << bs[i];\n sort(bs.begin(), bs.end());\n reverse(bs.begin(), bs.end());\n\n int ans = 0;\n for (int i = 0; i < sz(bs); i++) {\n multiset::iterator it = as.lower_bound(bs[i]);\n if (it == as.end()) continue;\n ans++;\n as.erase(it);\n }\n printf(\"%d\\n\", ans);\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4693bbb443f90eec43460adef611fc3c", "src_uid": "e95fb7d4309747834b37d4bc3468afb7", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntemplate T sqr(T x) { return x * x; }\ntemplate T gcd(T a, T b) { return b == 0? a : gcd(b, a % b); }\ntemplate T abs(T x) { return x < 0? -x : x; }\n\nconst int MAXK = 31;\n\nint f[MAXK];\nint g[MAXK];\nint ans;\nint n, m;\n\nint main()\n{\n\t#ifdef MJUDGE\n\t\tassert(freopen(\"in\", \"r\", stdin));\n\t\tassert(freopen(\"out\", \"w\", stdout));\n\t#endif\n\t\n\tscanf(\"%d %d\", &n, &m);\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tint x;\n\t\tscanf(\"%d\", &x);\n\t\tfor (int j = 0; j < MAXK; j++)\n\t\t\tif ((1 << j) & x)\n\t\t\t\tf[j] += 1;\n\t}\n\tfor (int i = 0; i < m; i++)\n\t{\n\t\tint x;\n\t\tscanf(\"%d\", &x);\n\t\tif (x >= MAXK)\n\t\t\tcontinue;\n\t\tg[x] += 1;\n\t}\n\t\n\tans = 0;\n\tfor (int i = 0; i < MAXK; i++)\n\t\tfor (int j = 0; j <= i; j++)\n\t\t{\n\t\t\tlong long x = min(f[i] * (long long)(1 << (i - j)), (long long)g[j]);\n\t\t\tif (x == 0)\n\t\t\t\tcontinue;\n\t\t\tans += x;\n\t\t\tg[j] -= x;\n\t\t\tlong long m = (x + (1 << (i - j)) - 1) / (1 << (i - j));\n\t\t\tf[i] -= m;\n\t\t\tx = (m * (1 << (i - j)) - x) << j;\n\t\t\t//cout << i << \" \" << j << \" \" << m << \" \" << x << endl;\n\t\t\tfor (int z = 0; z < MAXK; z++)\n\t\t\t\tif ((1 << z) & x)\n\t\t\t\t\tf[z] += 1;\n\t\t}\n\tprintf(\"%d\\n\", ans);\n\tfprintf(stderr, \"Time execute: %.3lfs\\n\", clock() / (double)CLOCKS_PER_SEC);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9f645fb4608f5968a5e8ed2ba30d3cf1", "src_uid": "e95fb7d4309747834b37d4bc3468afb7", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#pragma comment(linker, \"/STACK:128000000\")\n#define _USE_MATH_DEFINES\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\n \nusing namespace std; \n \ntypedef long long ll; \ntypedef pair pll;\ntypedef pair pii;\nconst long double PI = 3.14159265358979323846; \nconst long double gammama = 0.57721566490153286060;\n//const long double eps = 1e-5;\n//const int INF = 50000;\n//const int N = 1000 * 1000 * 1000 + 10;\n\nll up(ll a, ll b) {\n ll q = a / b;\n if (a % b != 0)\n ++q;\n return q;\n}\n\nvector c(30, 0);\nvoid add(ll a) {\n int ind = 0;\n while(a) {\n if (a & 1)\n ++c[ind];\n ++ind;\n a /= 2;\n }\n}\n\nint main() {\n\t//ios_base::sync_with_stdio(0);\n\t//freopen(\"input.txt\", \"r\", stdin);\n\t//freopen(\"output.txt\", \"w\", stdout);\n int n, r, c;\n cin >> n >> r >> c;\n vector words(n);\n vector sum(n);\n for (int i = 0; i < n; ++i) {\n cin >> words[i];\n sum[i] = words[i].size();\n if (i)\n sum[i] += sum[i - 1];\n }\n vector d(n, -1);\n int cur = 0;\n for (int i = 0; i < n; ++i) {\n if (words[i].size() > c)\n continue;\n int j = i;\n if (i)\n j = max(j, d[i - 1]);\n cur = sum[j];\n if (i)\n cur -= sum[i - 1];\n cur += j - i;\n while(j + 1 < n) {\n if (cur + words[j + 1].size() + 1 <= c)\n ++j;\n else\n break; \n }\n d[i] = j;\n }\n vector a(n);\n for (int i = n - 1; i >= 0; --i) {\n if (d[i] == \n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": true, "code_uid": "eef291cccbc28a48674ff19b8de7dc11", "src_uid": "e95fb7d4309747834b37d4bc3468afb7", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define li\t\tlong long\n#define rep(i,to)\tfor(li i=0;i<((li)to);i++)\n#define pb\t\tpush_back\n#define sz(v)\t\t((li)v.size())\n\nli gcd(li a,li b){\n\tif(a%b==0) return b;\n\treturn gcd(b,a%b);\n}\nint main(){\n\tli n;\n\tcin>>n;\n\tif(n>50) while(true);\n\tif(n>10){\tvector v; while(true) v.pb(1); }\n\tli res=1;\n\tli cnt=0;\n\tli add=0;\n\twhile(n%2==0) add++,n/=2;\n\twhile(res\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define fo(i,a,b) for (int i = a; i <= b; ++i)\n#define fd(i,a,b) for (int i = a; i >= b; --i)\n#define fe(i,x) for (int i = g[x], y = E[i].y; i; i = E[i].l, y = E[i].y)\n#define forall(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)\n#define pb push_back\n#define SIZE(x) ((int) (x).size())\n#define MP make_pair\n#define fi first\n#define se second\n#define UNIQUE(x) x.resize(unique(x.begin(), x.end()) - x.begin())\n#define clr(a,x) memset(&a, x, sizeof(a))\n#define move(a,b) memcpy(&b, &a, sizeof(a))\n#define Plus(a,b) (((LL) (a) + (b)) % mo)\n#define Minus(a,b) ((((LL) (a) - (b) ) % mo + mo) % mo)\n#define Mul(a,b) ((LL) (a) * (b) % mo)\n#define updmin(a,b) (a = min(a, b))\n#define updmax(a,b) (a = max(a, b))\n#define sqr(x) ((x) * (x))\n\ntypedef long long LL;\ntypedef long double LD;\ntypedef pair PII;\ntypedef vector VI;\n\nconst double eps = 1e-10;\nconst int oo = ~0u >> 2, mo = (int) 1e4;\nconst int ml = 100, mn = 11000;\n\nstruct high{\n int n, a[ml];\n high(){ clr(a, 0), n = 1; }\n high(int x){\n clr(a, 0), n = 0;\n do { a[++n] = x % mo, x /= mo; } while (x);\n }\n\n void cut(){\n while (n > 1 && !a[n]) --n;\n }\n \n int cmp(high p){\n if (n > p.n) return 1;\n if (n < p.n) return -1;\n fd (i, n, 1) if (a[i] > p.a[i]) return 1; \n else if (a[i] < p.a[i]) return -1;\n return 0;\n }\n void div2(){\n int g = 0;\n fd (i, n, 1) g = g * mo + a[i], a[i] = g / 2, g %= 2;\n cut();\n }\n high operator +(high p){\n high ret = *(new high());\n int g = 0; ret.n = max(n, p.n) + 1;\n fo (i, 1, ret.n) g += a[i] + p.a[i], ret.a[i] = g % mo, g /= mo;\n ret.cut();\n return ret;\n }\n high operator -(high p){\n high ret = *(new high());\n int g = 0; ret.n = n;\n fo (i, 1, ret.n){\n ret.a[i] = g + a[i] - p.a[i];\n if (ret.a[i] < 0) g = -1, ret.a[i] += mo; else g = 0;\n }\n ret.cut();\n return ret;\n }\n high operator *(high p){\n high ret = *(new high());\n ret.n = n + p.n + 1;\n fo (i, 1, n){\n int g = 0;\n fo (j, 1, p.n + 1){\n LL s = (LL) a[i] * p.a[j] + ret.a[i + j - 1] + g;\n ret.a[i + j - 1] = s % mo, g = s / mo;\n }\n }\n ret.cut();\n return ret;\n }\n high operator /(high p){\n high d = *(new high()), R = *(new high());\n d.n = n;\n fd (i, n, 1){\n R = R * *(new high(mo)) + *(new high(a[i]));\n int l = 0, r = mo - 1;\n while (l <= r){\n int m = (l + r) / 2;\n high t = p * *(new high(m));\n int c = R.cmp(t);\n if (!c){\n d.a[i] = m;\n break;\n }\n if (c > 0) d.a[i] = m, l = m + 1;\n else r = m - 1;\n }\n R = R - p * *(new high(d.a[i]));\n }\n d.cut();\n return d;\n }\n high operator %(high p){\n high R = *(new high());\n fd (i, n, 1){\n R = R * *(new high(mo)) + *(new high(a[i]));\n int l = 0, r = mo - 1, d;\n while (l <= r){\n int m = (l + r) / 2;\n high t = p * *(new high(m));\n int c = R.cmp(t);\n if (!c){\n d = m;\n break;\n }\n if (c > 0) d = m, l = m + 1;\n else r = m - 1;\n }\n R = R - p * *(new high(d));\n }\n R.cut();\n return R;\n }\n\n void print(){\n printf(\"%d\", a[n]);\n fd (i, n - 1, 1) printf(\"%04d\", a[i]);\n }\n};\n\nhigh GCD(high a, high b){\n high two = *(new high(1));\n while (b.n > 1 || b.a[1]){\n while (!(a.a[1] & 1) && !(b.a[1] & 1)) \n a.div2(), b.div2(), two = two + two;\n while (!(a.a[1] & 1)) a.div2();\n while (!(b.a[1] & 1)) b.div2();\n if (a.cmp(b) > 0) swap(a, b);\n b = b - a;\n }\n two = two * a; \n return two;\n}\n\nhigh LCM(high a, high b){\n high t = GCD(a, b);\n return a / t * b;\n}\n\nstruct rec{\n high a, b;\n rec(){ a = *(new high(0)), b = *(new high(1)); }\n rec(int x){ a = *(new high(x)), b = *(new high(1)); }\n rec(int x, int y){ a = *(new high(x)), b = *(new high(y)); }\n \n void simplify(){\n high t = GCD(a, b);\n a = a / t, b = b / t;\n }\n\n rec operator +(rec p){\n rec ret;\n ret.b = LCM(b, p.b);\n ret.a = a * (ret.b / b) + p.a * (ret.b / p.b);\n ret.simplify();\n return ret;\n }\n rec operator -(rec p){\n rec ret;\n ret.b = LCM(b, p.b);\n ret.a = a * (ret.b / b) - p.a * (ret.b / p.b);\n ret.simplify();\n return ret;\n }\n rec operator *(rec p){\n rec ret;\n ret.a = a * p.a, ret.b = b * p.b;\n ret.simplify();\n return ret;\n }\n rec operator /(rec p){\n rec ret;\n ret.a = a * p.b, ret.b = b * p.a;\n ret.simplify();\n return ret;\n }\n} k, b, Ans;\n\nstruct mem{\n rec k, b;\n bool flag;\n} f[mn];\n\nint n, m;\n\nint main(){\n cin >> n;\n if (n == 1){\n printf(\"0/1\");\n return 0;\n }\n m = 1, k = *(new rec(1)), b = *(new rec(0));\n do {\n f[m].k = k, f[m].b = b, f[m].flag = 1;\n m *= 2;\n if (m == n){\n Ans = b + *(new rec(1));\n break;\n } else \n if (m < n){\n b = b + k;\n } else {\n rec t = *(new rec(m - n, m));\n m -= n, b = b + k, k = k * t;\n }\n if (f[m].flag){\n rec t1 = f[m].k - k, t2 = b - f[m].b;\n Ans = t2 / t1;\n Ans = k * Ans + b;\n break;\n }\n } while (n != m);\n Ans.simplify();\n Ans.a.print();\n printf(\"/\");\n Ans.b.print();\n printf(\"\\n\");\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0d72725eb3df7f6d28c968547f076cc4", "src_uid": "5491b4a27991153a61ac4a2618b2cd0e", "difficulty": 2200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define li\t\tlong long\n#define rep(i,to)\tfor(li i=0;i<((li)to);i++)\n#define pb\t\tpush_back\n#define sz(v)\t\t((li)v.size())\n\nli gcd(li a,li b){\n\tif(a%b==0) return b;\n\treturn gcd(b,a%b);\n}\nint main(){\n\tli n;\n\tcin>>n;\n\tif(n==10) while(true);\n\tif(n>6){\tvector v; while(true) v.pb(1); }\n\tli res=1;\n\tli cnt=0;\n\tli add=0;\n\twhile(n%2==0) add++,n/=2;\n\twhile(res\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define fo(i,a,b) for (int i = a; i <= b; ++i)\n#define fd(i,a,b) for (int i = a; i >= b; --i)\n#define fe(i,x) for (int i = g[x], y = E[i].y; i; i = E[i].l, y = E[i].y)\n#define forall(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)\n#define pb push_back\n#define SIZE(x) ((int) (x).size())\n#define MP make_pair\n#define fi first\n#define se second\n#define UNIQUE(x) x.resize(unique(x.begin(), x.end()) - x.begin())\n#define clr(a,x) memset(&a, x, sizeof(a))\n#define move(a,b) memcpy(&b, &a, sizeof(a))\n#define Plus(a,b) (((LL) (a) + (b)) % mo)\n#define Minus(a,b) ((((LL) (a) - (b) ) % mo + mo) % mo)\n#define Mul(a,b) ((LL) (a) * (b) % mo)\n#define updmin(a,b) (a = min(a, b))\n#define updmax(a,b) (a = max(a, b))\n#define sqr(x) ((x) * (x))\n\ntypedef long long LL;\ntypedef long double LD;\ntypedef pair PII;\ntypedef vector VI;\n\nconst double eps = 1e-10;\nconst int oo = ~0u >> 2, mo = (int) 1e4;\nconst int ml = 100, mn = 11000;\n\nstruct high{\n\tint n, a[ml];\n\thigh(){ clr(a, 0), n = 1; }\n\thigh(int x){\n\t\tclr(a, 0), n = 0;\n\t\tdo { a[++n] = x % mo, x /= mo; } while (x);\n\t}\n\tvoid init(int x){\n\t\tclr(a, 0), n = 0;\n\t\tdo { a[++n] = x % mo, x /= mo; } while (x);\n\t}\n\n\tvoid cut(){\n\t\twhile (n > 1 && !a[n]) --n;\n\t}\n\t\n\tint cmp(high p){\n\t\tif (n > p.n) return 1;\n\t\tif (n < p.n) return -1;\n\t\tfd (i, n, 1) if (a[i] > p.a[i]) return 1; \n\t\telse if (a[i] < p.a[i]) return -1;\n\t\treturn 0;\n\t}\n\tvoid div2(){\n\t\tint g = 0;\n\t\tfd (i, n, 1) g = g * mo + a[i], a[i] = g / 2, g %= 2;\n\t\tcut();\n\t}\n\thigh operator +(high p){\n\t\thigh ret; ret.init(0);\n\t\tint g = 0; ret.n = max(n, p.n) + 1;\n\t\tfo (i, 1, ret.n) g += a[i] + p.a[i], ret.a[i] = g % mo, g /= mo;\n\t\tret.cut();\n\t\treturn ret;\n\t}\n\thigh operator -(high p){\n\t\thigh ret; ret.init(0);\n\t\tint g = 0; ret.n = n;\n\t\tfo (i, 1, ret.n){\n\t\t\tret.a[i] = g + a[i] - p.a[i];\n\t\t\tif (ret.a[i] < 0) g = -1, ret.a[i] += mo; else g = 0;\n\t\t}\n\t\tret.cut();\n\t\treturn ret;\n\t}\n\thigh operator *(high p){\n\t\thigh ret; ret.init(0);\n\t\tret.n = n + p.n + 1;\n\t\tfo (i, 1, n){\n\t\t\tint g = 0;\n\t\t\tfo (j, 1, p.n + 1){\n\t\t\t\tLL s = (LL) a[i] * p.a[j] + ret.a[i + j - 1] + g;\n\t\t\t\tret.a[i + j - 1] = s % mo, g = s / mo;\n\t\t\t}\n\t\t}\n\t\tret.cut();\n\t\treturn ret;\n\t}\n\thigh operator /(high p){\n\t\thigh d, R, tmp; d.init(0), R.init(0);\n\t\td.n = n;\n\t\tfd (i, n, 1){\n\t\t\ttmp.init(mo), R = R * tmp;\n\t\t\ttmp.init(a[i]), R = R + tmp;\n\t\t\tint l = 0, r = mo - 1;\n\t\t\twhile (l <= r){\n\t\t\t\tint m = (l + r) / 2;\n\t\t\t\ttmp.init(m);\n\t\t\t\thigh t = p * tmp;\n\t\t\t\tint c = R.cmp(t);\n\t\t\t\tif (!c){\n\t\t\t\t\td.a[i] = m;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (c > 0) d.a[i] = m, l = m + 1;\n\t\t\t\telse r = m - 1;\n\t\t\t}\n\t\t\ttmp.init(d.a[i]), R = R - p * tmp;\n\t\t}\n\t\td.cut();\n\t\treturn d;\n\t}\n\thigh operator %(high p){\n\t\thigh R, tmp; R.init(0);\n\t\tfd (i, n, 1){\n\t\t\ttmp.init(mo), R = R * tmp;\n\t\t\ttmp.init(a[i]), R = R + tmp;\n\t\t\tint l = 0, r = mo - 1, d;\n\t\t\twhile (l <= r){\n\t\t\t\tint m = (l + r) / 2;\n\t\t\t\ttmp.init(m);\n\t\t\t\thigh t = p * tmp;\n\t\t\t\tint c = R.cmp(t);\n\t\t\t\tif (!c){\n\t\t\t\t\td = m;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (c > 0) d = m, l = m + 1;\n\t\t\t\telse r = m - 1;\n\t\t\t}\n\t\t\ttmp.init(d), R = R - p * tmp;\n\t\t}\n\t\tR.cut();\n\t\treturn R;\n\t}\n\n\tvoid print(){\n\t\tprintf(\"%d\", a[n]);\n\t\tfd (i, n - 1, 1) printf(\"%04d\", a[i]);\n\t}\n};\n\nhigh GCD(high a, high b){\n\thigh two; two.init(1);\n\twhile (b.n > 1 || b.a[1]){\n\t\twhile (!(a.a[1] & 1) && !(b.a[1] & 1)) \n\t\t\ta.div2(), b.div2(), two = two + two;\n\t\twhile (!(a.a[1] & 1)) a.div2();\n\t\twhile (!(b.a[1] & 1)) b.div2();\n\t\tif (a.cmp(b) > 0) swap(a, b);\n\t\tb = b - a;\n\t}\n\ttwo = two * a; \n\treturn two;\n}\n\nhigh LCM(high a, high b){\n\thigh t = GCD(a, b);\n\treturn a / t * b;\n}\n\nstruct rec{\n\thigh a, b;\n\trec(){ a.init(0), b.init(1); }\n\trec(int x){ a.init(x), b.init(1); }\n\trec(int x, int y){ a.init(x), b.init(y); }\n\t\n\tvoid simplify(){\n\t\thigh t = GCD(a, b);\n\t\ta = a / t, b = b / t;\n\t}\n\n\trec operator +(rec p){\n\t\trec ret;\n\t\tret.b = LCM(b, p.b);\n\t\tret.a = a * (ret.b / b) + p.a * (ret.b / p.b);\n\t\tret.simplify();\n\t\treturn ret;\n\t}\n\trec operator -(rec p){\n\t\trec ret;\n\t\tret.b = LCM(b, p.b);\n\t\tret.a = a * (ret.b / b) - p.a * (ret.b / p.b);\n\t\tret.simplify();\n\t\treturn ret;\n\t}\n\trec operator *(rec p){\n\t\trec ret;\n\t\tret.a = a * p.a, ret.b = b * p.b;\n\t\tret.simplify();\n\t\treturn ret;\n\t}\n\trec operator /(rec p){\n\t\trec ret;\n\t\tret.a = a * p.b, ret.b = b * p.a;\n\t\tret.simplify();\n\t\treturn ret;\n\t}\n} k, b, Ans;\n\nstruct mem{\n\trec k, b;\n\tbool flag;\n} f[mn];\n\nint n, m;\n\nint main(){\n\tcin >> n;\n\tif (n == 1){\n\t\tprintf(\"0/1\");\n\t\treturn 0;\n\t}\n\tm = 1, k = *(new rec(1)), b = *(new rec(0));\n\tdo {\n\t\tf[m].k = k, f[m].b = b, f[m].flag = 1;\n\t\tm *= 2;\n\t\tif (m == n){\n\t\t\tAns = b + *(new rec(1));\n\t\t\tbreak;\n\t\t} else \n\t\tif (m < n){\n\t\t\tb = b + k;\n\t\t} else {\n\t\t\trec t; t.a.init(m - n), t.b.init(m);\n\t\t\tm -= n, b = b + k, k = k * t;\n\t\t}\n\t\tif (f[m].flag){\n\t\t\trec t1 = f[m].k - k, t2 = b - f[m].b;\n\t\t\tAns = t2 / t1;\n\t\t\tAns = k * Ans + b;\n\t\t\tbreak;\n\t\t}\n\t} while (n != m);\n\tAns.simplify();\n\tAns.a.print();\n\tprintf(\"/\");\n\tAns.b.print();\n\tprintf(\"\\n\");\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4d15df7c4b0bba6a22c575c34076c0e6", "src_uid": "5491b4a27991153a61ac4a2618b2cd0e", "difficulty": 2200.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long double ld;\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vl;\ntypedef vector vvi;\ntypedef vector vvl;\ntypedef vector vd;\ntypedef vector vvd;\ntypedef pair pii;\ntypedef pair pdd;\ntypedef vector vii;\ntypedef vector vs;\n//const int mod = ;\n\nconst int N = 1 << 12;\nll d[2][N][3001];\n\nvoid umax(ll& x, ll y) {\n x = max(x, y);\n}\n\nconst int DEBUG = 0;\n\nint main() {\n //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n std::ios::sync_with_stdio(false); std::cin.tie(0);\n //int n = 3000, k = 3000;\n for (int tt = 0; tt < (DEBUG ? 100 : 1); ++tt) {\n int n = 10, k = rand() % 10;\n if (!DEBUG) cin >> n >> k;\n vvi a(n);\n vi l(n);\n vl sum(n);\n for (int i = 0; i < n; ++i) {\n //int t = 300;\n int t = 1 + rand() % 10;\n if (!DEBUG) cin >> t;\n a[i].resize(t);\n l[i] = t;\n for (int j = 0; j < t; ++j) {\n if (!DEBUG) cin >> a[i][j];\n else a[i][j] = j > 0 ? a[i][j - 1] + rand() % 5 : rand() % 2;\n sum[i] += a[i][j];\n }\n }\n int pw = 1;\n while (pw < n) pw *= 2;\n while (l.size() < pw) {\n l.push_back(0);\n sum.push_back(0);\n }\n memset(d[0], 0, sizeof(d[0]));\n int pr = 0, nx = 1;\n while (pw > 1) {\n pw /= 2;\n for (int s = 0; s < l.size(); s += 2 * pw) {\n memcpy(d[nx][s], d[pr][s], sizeof(d[nx][s]));\n memcpy(d[nx][s + pw], d[pr][s], sizeof(d[nx][s]));\n for (int i = s; i < s + pw; ++i) for (int j = k; j >= l[i]; --j) {\n umax(d[nx][s + pw][j], d[nx][s + pw][j - l[i]] + sum[i]);\n }\n for (int i = s + pw; i < s + 2 * pw; ++i) for (int j = k; j >= l[i]; --j) {\n umax(d[nx][s][j], d[nx][s][j - l[i]] + sum[i]);\n }\n }\n swap(pr, nx);\n }\n ll res = 0;\n for (int i = 0; i < n; ++i) {\n ll s = 0;\n for (int j = 0; j < min(k + 1, (int)a[i].size() + 1); ++j) {\n res = max(res, d[pr][i][k - j] + s);\n// cerr << res << ' ' << i << ' ' << j << ' ' << s << ' ' << d[pr][i][k - j] << endl;\n if (j < a[i].size()) s += a[i][j];\n }\n }\n cout << res << endl;\n if (DEBUG) {\n vl v(k + 1);\n for (int i = 0; i < n; ++i) {\n ll s = 0;\n vl res = v;\n for (int j = 0; j < min(k + 1, (int)a[i].size() + 1); ++j) {\n vl v1 = v;\n for (int t = k; t >= j; --t) {\n v1[t] = max(v1[t], v1[t - j] + s);\n }\n for (int t = 0; t <= k; ++t) res[t] = max(res[t], v1[t]);\n if (j < a[i].size()) s += a[i][j];\n }\n v = res;\n }\n cerr << v[k] << endl;\n if (v[k] != res) {\n cout << n << ' ' << k << endl;\n for (int i = 0; i < n; ++i) {\n for (int x : a[i]) cout << x << ' '; cout << endl;\n }\n }\n assert(v[k] == res);\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "087efd48a7a7cd8bc469d456d51c485c", "src_uid": "9e9d4f58ebd8293025ab8004aeb8d343", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "/**\n * author: tourist\n * created: 01.11.2020 17:14:09 \n**/\n#include \n\nusing namespace std;\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n int n, k;\n cin >> n >> k;\n vector> a(n);\n vector sz(n);\n vector sum(n);\n for (int i = 0; i < n; i++) {\n int foo;\n cin >> foo;\n a[i].resize(foo);\n sz[i] = foo;\n sum[i] = 0;\n for (int j = 0; j < foo; j++) {\n cin >> a[i][j];\n sum[i] += a[i][j];\n }\n }\n const long long inf = (long long) 1e18;\n vector> save(30, vector(k + 1, -inf));\n vector dp(k + 1, -inf);\n dp[0] = 0;\n long long ans = 0;\n function Solve = [&](int level, int from, int to) {\n if (from == to) {\n long long took = 0;\n for (int i = 0; i <= k; i++) {\n ans = max(ans, took + dp[k - i]);\n if (i == (int) a[from].size()) {\n break;\n }\n took += a[from][i];\n }\n return;\n }\n for (int j = 0; j <= k; j++) {\n save[level][j] = dp[j];\n }\n int mid = (from + to) >> 1;\n {\n for (int i = from; i <= mid; i++) {\n for (int j = k - sz[i]; j >= 0; j--) {\n dp[j + sz[i]] = max(dp[j + sz[i]], dp[j] + sum[i]);\n }\n }\n Solve(level + 1, mid + 1, to);\n for (int j = 0; j <= k; j++) {\n dp[j] = save[level][j];\n }\n }\n {\n for (int i = mid + 1; i <= to; i++) {\n for (int j = k - sz[i]; j >= 0; j--) {\n dp[j + sz[i]] = max(dp[j + sz[i]], dp[j] + sum[i]);\n }\n }\n Solve(level + 1, from, mid);\n for (int j = 0; j <= k; j++) {\n dp[j] = save[level][j];\n }\n }\n };\n Solve(0, 0, n - 1);\n cout << ans << '\\n';\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ebb6138afa437fbf721f8040b434a87f", "src_uid": "9e9d4f58ebd8293025ab8004aeb8d343", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\ntypedef long long ll;\n\nconst ll INF = (ll)1e18 + 41;\n\nvoid solve() {\n int n, k;\n cin >> n >> k;\n\n vector dp(k + 1, 0);\n vector maxUseless(k + 1, -INF);\n\n vector> prefs(n);\n\n for (int i = 0; i < n; i++) {\n ll sum = 0;\n int sz; cin >> sz;\n vector> pref;\n for (int j = 0; j < sz; j++) {\n int x; cin >> x; sum += x;\n if (j + 1 <= k)\n prefs[i].push_back(sum);\n }\n }\n\n mt19937 rnd(3431);\n shuffle(prefs.begin(), prefs.end(), rnd);\n\n for (int i = 0; i < n; i++) {\n vector> a;\n const auto &pp = prefs[i];\n for (int j = 0; j < (int)pp.size(); j++) if (pp[j] > maxUseless[j + 1]) {\n a.emplace_back(j + 1, pp[j]);\n }\n vector isA(a.size(), false);\n\n for (int pos = k; pos > 0; pos--) {\n ll oldDp = dp[pos];\n for (int j = 0; j < (int)a.size(); j++) {\n int len = a[j].first;\n if (pos < len) continue;\n ll val = a[j].second;\n if (oldDp < dp[pos - len] + val) isA[j] = true;\n if (dp[pos] < dp[pos - len] + val) dp[pos] = dp[pos - len] + val;\n }\n }\n\n for (int j = 0; j < (int)a.size(); j++) {\n if (!isA[j]) {\n maxUseless[a[j].first] = max(maxUseless[a[j].first], a[j].second);\n }\n }\n }\n\n cout << dp[k] << \"\\n\";\n}\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n int t = 1;\n#ifdef SERT\n freopen(\"a.in\", \"r\", stdin);\n t = 1;\n#endif\n while (t--) solve();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f86c5f621b318258306b674529344daa", "src_uid": "9e9d4f58ebd8293025ab8004aeb8d343", "difficulty": 2800.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\ntypedef long long ll;\n\nconst ll INF = (ll)1e18 + 41;\n\nvoid solve() {\n int n, k;\n cin >> n >> k;\n\n vector dp(k + 1, 0);\n vector maxUseless(k + 1, -INF);\n\n vector> prefs(n);\n\n for (int i = 0; i < n; i++) {\n ll sum = 0;\n int sz; cin >> sz;\n vector> pref;\n for (int j = 0; j < sz; j++) {\n int x; cin >> x; sum += x;\n if (j + 1 <= k)\n prefs[i].push_back(sum);\n }\n }\n\n mt19937 rnd(3431);\n shuffle(prefs.begin(), prefs.end(), rnd);\n\n for (int i = 0; i < n; i++) {\n vector> a;\n const auto &pp = prefs[i];\n for (int j = 0; j < (int)pp.size(); j++) if (pp[j] > maxUseless[j + 1]) {\n a.emplace_back(j + 1, pp[j]);\n }\n vector isA(a.size(), false);\n\n for (int pos = k; pos > 0; pos--) {\n ll oldDp = dp[pos];\n for (int j = 0; j < (int)a.size(); j++) {\n int len = a[j].first;\n if (pos < len) continue;\n ll val = a[j].second;\n if (oldDp < dp[pos - len] + val) isA[j] = true;\n if (dp[pos] < dp[pos - len] + val) dp[pos] = dp[pos - len] + val;\n }\n }\n\n for (int j = 0; j < (int)a.size(); j++) {\n if (!isA[j]) {\n maxUseless[a[i].first] = max(maxUseless[a[i].first], a[i].second);\n }\n }\n }\n\n cout << dp[k] << \"\\n\";\n}\n\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(nullptr);\n int t = 1;\n#ifdef SERT\n freopen(\"a.in\", \"r\", stdin);\n t = 1;\n#endif\n while (t--) solve();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "957f006dc255d817db41b4c37afe5bb5", "src_uid": "9e9d4f58ebd8293025ab8004aeb8d343", "difficulty": 2800.0} {"lang": "GNU C++", "source_code": "\ufeff#include \nusing namespace std;\n\n#define pb push_back\n#define mp make_pair\n#define fs first\n#define sc second\n#define sz(a) ((int) (a).size())\n#define int64 long long\n#define ldb long double\nconst ldb pi = acos(-1.0);\n\nconst int N = 20;\nconst double eps = 1e-10;\nint n, k;\ndouble a[N], p[1 << N], res[N];\n\nint main() {\n\t// assert(freopen(\"input.txt\", \"r\", stdin));\n\t// assert(freopen(\"output.txt\", \"w\", stdout));\n\tscanf(\"%d%d\", &n, &k);\n\tint cnt = 0;\n\tfor (int i = 0; i < n; ++i) {\n\t\tscanf(\"%lf\", &a[i]);\n\t\tif (a[i] < eps) ++cnt;\n\t}\n\tk = min(n - cnt, k);\n\tp[0] = 1;\n\tfor (int mask = 1; mask < (1 << n); ++mask) {\n\t\tdouble suma = 0;\n\t\tbool ok = true;\n\t\tint cnt = 0;\n\t\tfor (int i = 0; i < n; ++i)\n\t\t\tif (mask & (1 << i)) {\n\t\t\t\tsuma += a[i];\n\t\t\t\tif (a[i] < eps) ok = false;\n\t\t\t\t++cnt;\n\t\t\t}\n\t\tif (!ok) {\n\t\t\tp[mask] = 0;\n\t\t\tcontinue;\n\t\t} else {\n\t\t\tdouble sump = 0;\n\t\t\tfor (int i = 0; i < n; ++i)\n\t\t\t\tif (mask & (1 << i))\n\t\t\t\t\tsump += a[i] / (1 - suma + a[i]) * p[mask ^ (1 << i)];\n\t\t\tp[mask] = sump;\n\t\t}\n\t\tif (cnt == k)\n\t\t\tfor (int i = 0; i < n; ++i)\n\t\t\t\tif (mask & (1 << i))\n\t\t\t\t\tres[i] += p[mask];\n\t}\n\tfor (int i = 0; i < n; ++i)\n\t\tprintf(\"%.10f%c\", res[i], \" \\n\"[i == n - 1]);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f9d1e09e8f2f83f372a05b9d4ae50c42", "src_uid": "ad290c29e7587561391cefab73026171", "difficulty": 2400.0} {"lang": "GNU C++11", "source_code": "//#pragma comment(linker, \"/STACK:16777216\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define y0 sdkfaslhagaklsldk\n#define y1 aasdfasdfasdf\n#define yn askfhwqriuperikldjk\n#define j1 assdgsdgasghsf\n#define tm sdfjahlfasfh\n#define lr asgasgash\n\nusing ll = long long;\nusing pii = pair;\ntemplate struct triple {\n\tT1 x; T2 y; T3 z;\n};\nusing tri = triple;\nusing trll = triple;\ntemplate\nbool operator<(const triple& t1, const triple& t2) {\n\treturn t1.x < t2.x || (t1.x == t2.x && (t1.y < t2.y || t1.y == t2.y && t1.z < t2.z));\n}\n\n#define eps 1e-9\n#define bs 1000000007\nconst int mod = 1000000007;\nconst int INF = 1000111000;\nconst ll LLINF = 1000111000111000111LL;\nconst double PI = acos(-1.0);\n#define bsize 256\n\n#define all(v) (v).begin(), (v).end()\n#define FI(n) for (int i = 0; i < n; ++i)\n#define FJ(n) for (int j = 0; j < n; ++j)\n#define FK(n) for (int k = 0; k < n; ++k)\n#define FREIN(file) freopen(file, \"rt\", stdin)\n#define FREOUT(file) freopen(file, \"wt\", stdout)\n#define sqr(x) ((x)*(x))\n\n#define DB(n) cerr<<#n<<\" = \"<<(n)<<\" \"\n#define DBN(n) cerr<<#n<<\" = \"<<(n)<<\"\\n\"\n\nint gcd(int x, int y) { while (y) { x %= y, swap(x, y); } return y; }\nll gcd(ll x, ll y) { while (y) { x %= y, swap(x, y); } return y; }\nll lcm(ll x, ll y) { return x / gcd(x, y) * y; }\nll powmod(ll x, ll n, const int mod) {\n\tll res = 1; while (n)\n\t{\n\t\tif (n & 1) res = res * x % mod; n /= 2; x = x * x % mod;\n\t} return res;\n}\n\nint n, k;\ndouble prob[200];\ndouble dp[1 << 20];\ndouble sum[1 << 20];\ndouble ans[22];\n\nint count_bits(int x)\n{\n\tif (x == 0)\n\t\treturn 0;\n\treturn count_bits(x / 2) + x % 2;\n}\n\nint flag;\n\nint main() {\n\tios::sync_with_stdio(0);\n\tcin.tie(0);\n\n\tcin >> n >> k;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tcin >> prob[i];\n\t}\n\n\tfor (int mask = 0; mask < (1 << n); mask++)\n\t{\n\t\tdouble s = 0;\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\tif (mask&(1 << i))\n\t\t\t\ts += prob[i];\n\t\t}\n\t\tsum[mask] = s;\n\t}\n\n\tdp[0] = 1;\n\n\tfor (int mask = 0; mask < (1 << n); mask++)\n\t{\n\t\tint qb = count_bits(mask);\n\t\tif (qb > k)\n\t\t\tcontinue;\n\t\tif (dp[mask]<1e-100)\n\t\t\tcontinue;\n\t\tif (qb == k)\n\t\t\tflag = 1;\n\t\tdouble rem_sum = 1.0 - sum[mask];\n\t\tif (rem_sum < 1e-6)\n\t\t\tcontinue;\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\tif (mask&(1 << i))\n\t\t\t\tcontinue;\n\t\t\tdouble chance_move = dp[mask] * prob[i] / rem_sum;\n\t\t\tdp[mask | (1 << i)] += chance_move;\n\t\t}\n\t}\n\n\tif (flag == 0)\n\t{\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\tif (prob[i] < 1e-6)\n\t\t\t\tans[i] = 0;\n\t\t\telse\n\t\t\t\tans[i] = 1;\n\t\t}\n\t}\n\telse\n\t{\n\t\tfor (int mask = 0; mask < (1 << n); mask++)\n\t\t{\n\t\t\tif (count_bits(mask) == k)\n\t\t\t{\n\t\t\t\tfor (int i = 0; i < n; i++)\n\t\t\t\t{\n\t\t\t\t\tif (mask&(1 << i))\n\t\t\t\t\t\tans[i] += dp[mask];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tcout.precision(12);\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tif (i)\n\t\t\tcout << \" \";\n\t\tcout << fixed << ans[i];\n\t}\n\tcout << endl;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "eab21e2c068cf95a9baeb980ba94b0c8", "src_uid": "ad290c29e7587561391cefab73026171", "difficulty": 2400.0} {"lang": "MS C++", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n\n\nint main() {\n#ifndef ONLINE_JUDGE\n\tfreopen(\"task.in\", \"r\", stdin);\n\tfreopen(\"task.out\", \"w\", stdout);\n#endif\n\n\tcout.precision(15);\n\tcout << fixed;\n\n\tint n, k;\n\twhile (cin >> n >> k) {\n\t\tvector p(n);\n\t\tfor (int i = 0; i < n; i++) cin >> p[i];\n\n\t\tvector sum(1 << n);\n\t\tfor (int i = 0; i < 1 << n; i++) {\n\t\t\tfor (int j = 0; j < n; j++) {\n\t\t\t\tif (i & (1 << j)) {\n\t\t\t\t\tsum[i] += p[j];\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tvector dp(1 << n);\n\t\tdp[0] = 1;\n\t\tfor (int mask = 0; mask < 1 << n; mask++) {\n\t\t\tint rmask = (~mask) & ((1 << n) - 1);\n\t\t\tfor (int i = 0; i < n; i++) if (rmask & (1 << i)) {\n\t\t\t\tdp[mask | (1 << i)] += dp[mask] * p[i] / sum[rmask];\n\t\t\t}\n\t\t}\n\t\tvector ans(n);\n\t\tfor (int mask = 0; mask < 1 << n; mask++) {\n\t\t\tint cnt = 0;\n\t\t\tfor (int i = 0; i < n; i++) cnt += (mask & (1 << i)) != 0;\n\t\t\tif (cnt != k) continue;\n\t\t\tfor (int i = 0; i < n; i++) if (mask & (1 << i)) {\n\t\t\t\tans[i] += dp[mask];\n\t\t\t}\n\t\t}\n\t\tfor (int i = 0; i < n; i++) cout << ans[i] << \" \\n\"[i + 1 == n];\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "943d907325e3138cc31cae946f46d6a6", "src_uid": "ad290c29e7587561391cefab73026171", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "\ufeff#include \nusing namespace std;\n\n#define pb push_back\n#define mp make_pair\n#define fs first\n#define sc second\n#define sz(a) ((int) (a).size())\n#define int64 long long\n#define ldb long double\nconst ldb pi = acos(-1.0);\n\n#define FULL 2\n#define OK 1\n#define EMPTY 0\n\nint get_state(int a, int b, int c) {\n\tif ((a == 0) && (b == 0)) {\n\t\tif (c == 0) return FULL;\n\t\treturn EMPTY;\n\t}\n\treturn OK;\n}\n\nint det2(int a, int b, int c, int d) {\n\treturn a * d - b * c;\n}\n\nint main() {\n\t// assert(freopen(\"input.txt\", \"r\", stdin));\n\t// assert(freopen(\"output.txt\", \"w\", stdout));\n\tint a1, b1, c1, a2, b2, c2;\n\tscanf(\"%d%d%d\", &a1, &b1, &c1);\n\tscanf(\"%d%d%d\", &a2, &b2, &c2);\n\tint s1 = get_state(a1, b1, c1);\n\tint s2 = get_state(a2, b2, c2);\n\tif (s1 == EMPTY || s2 == EMPTY) {\n\t\tprintf(\"0\\n\");\n\t\treturn 0;\n\t}\n\tif (s1 == FULL || s2 == FULL) {\n\t\tprintf(\"-1\\n\");\n\t\treturn 0;\n\t}\n\tint d = det2(a1, b1, a2, b2);\n\tif (d == 0) {\n\t\tif (det2(a1, c1, a2, c2) == 0) {\n\t\t\tprintf(\"-1\\n\");\n\t\t} else {\n\t\t\tprintf(\"0\\n\");\n\t\t}\n\t} else {\n\t\tprintf(\"1\\n\");\n\t}\n\treturn 0;\n} ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fa7aecb3a43342eadf64ccb432843fd8", "src_uid": "ad290c29e7587561391cefab73026171", "difficulty": 2400.0}

  • =c[g-1] && c[0]>0){\n n++;\n }\n }\n std::cout << n;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cf2044200f34091ff015021ac505b393", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "Clang++17 Diagnostics", "source_code": "#include\nusing namespace std;\nint main()\n{\n int n,k,a[n];\n cin>>n>>k;\n for(int i=0;i>a[i];\n }\n int score=a[k-1];\n int count=0;\n for(int j=0;j=score && (score!=0 || a[j]!=0))\n count++;\n else if(a[j]\n#include \nusing namespace std;\nint main() {\n int n, k, count, c, ind;\n cin >> n >> k;\n vector vec;\n for(int i = 0; i < n; i++) {\n int x;\n cin >> x;\n if (i = k -1) c = x;\n vec.push_back(x);\n }\n ind = 0;\n while(true) {\n if( vec[ind] >= c) count++;\n else break;\n ind ++;\n }\n cout << count ;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e9304f7fb455e0874cd8967f65afa652", "src_uid": "193ec1226ffe07522caf63e84a7d007f", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\nlong long int n,k,A[n],c=0;\ncin>>n>>k;\nfor(int i=1;i<=n;i++)\n{cin>>A[i];\n}\nif(A[k]!=0)\n{\nfor(int j=1;j<=n;j++)\n{\nif(A[j]>=A[k])\nc++;\n}\ncout<\n\n #define int long long int\n #define mp make_pair\n #define pb push_back\n\n using namespace std;\n\n signed main() {\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n\n vector v;\n string str, tmp;\n cin >> str;\n for (int i=str.size()-3;i>=0;i--) {\n if (str[i]=='W' && str[i+1]=='U' && str[i+2]=='B') {\n str[i]=' ';\n str[i+1]=' ';\n str[i+2]=' ';\n }\n }\n for (int i=0;i\nusing namespace std;\nint i, j;\nstring s, d[20];\nint main () {\n cin >> s;\n for (i=0; i\nusing namespace std;\nint i, j;\nstring s, d[201];\nint main () {\n cin >> s;\n for (i=0; i\n#include \n#include\nusing namespace std;\n\nint main()\n{\n string song,b=\"\";\n getline(cin,song);\n int i=0;\n\nwhile (song[i] != '\\0')\n {\n if (song[i] == 'W' && song[i+1] == 'U' && song[i+2] == 'B') {\n\n if (i != 0 && b[i-1] != ' ') b=b+' ';\n i+=3; }\n\n else { b =b+song[i]; i++;}\n\n }\n cout<\nusing namespace std;\nint h,s[10000][10000],g,l;\nint main()\n{\n for (int i=1;i<=5;i++)\n for (int j=1;j<=5;j++)\n cin>>s[i][j];\n for (int i=1;i<=5;i++)\n for (int j=1;j<=5;j++)\n {\n if (s[i][j]!=0) {g=i;l=j;}\n } \n cout<\n\nusing namespace std;\n\nstruct odd : public unary_function { bool operator () (int x) const { return (x % 2) != 0; } };\nvoid dis(int *Array, int N) { for(int i = 0; i < N; ++i) {std::cout.width(1); std::cout << Array[i];} std::cout << std::endl;}\nsigned fac(int n){return (n==1 || n==0) ? 1: n * fac(n - 1);}\nbool V(char x) {return (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u'); } \ntemplate inline signed amin(T &x, U y) { if(y < x) x = y; return x;}\ntemplate inline signed amax(T &x, U y) { if(x < y) x = y; return x;}\n//signed m(){long long T, pp,p,ppp, ct, nn, xx; cin >> p; cin.ignore(); for(int k=0;k>a[k][l];}}\n#define inn freopen(\"input.txt\", \"r\", stdin) \n#define outt freopen(\"output.txt\", \"w\",stdout)\n#define all(cont) cont.begin(), cont.end()\n#define ll long long\n#define sz(x) (int)x.size()\n#define endl '\\n'\n#define rep(i,a,b) for(int i=a;ifi,fi1;\nstring s,s1,s2;\nstd::vector::iterator low1, low2;\n\nint main () {\n //inn; outt;\n \nfor(ll int i=0; i<5; i++)\n{\n for(ll int j=0; j<5; j++)\n {\n cin>>arr[i][j];\n }\n}\nfor(int i=0;i<5;i++)\n{\n for(int j=0;j<5;j++)\n {\n fi.push_back(arr[i][j]);\n }\n}\nstd::vector::iterator it = std::find(fi.begin(), fi.end(), 1);\nint index = std::distance(fi.begin(), it);\ncout<\nusing namespace std;\nint a[11111][11111];\nmain()\n{\n\tfor(int i = 1 ; i <=5;++i)\n\t{\n\t\tfor(int j = 1 ; j <= 5;++j)\n\t\t{\n\t\t\tcin >> a[i][j];\n\t\t}\n\t}\n\t\tfor(int i = 1 ; i <=5;++i)\n\t{\n\t\tfor(int j = 1 ; j <= 5;++j)\n\t\t{\n\t\t\tif( a[3][3] == 1)\n\t\t\t{\n\t\t\t\tcout << 0;\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif(a[3][2] == 1||a[2][4] == 1||a[2][3] == 1||a[4][3] == 1)\n\t\t\t{\n\t\t\t\tcout << 1;\n\t\t\t}\n\t\t\tif(a[1][1] == 1||a[5][1] == 1||a[1][5] == 1||a[5][5] == 1)\n\t\t\t{\n\t\t\t\tcout << 4;\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif(a[4][1] == 1 || a[2][1] == 1||a[2][5] == 1||a[4][5] == 1||a[1][4] == 1||a[1][2] == 1 || a[5][4] == 1||a[5][2] == 1)\n\t\t\t{\n\t\t\t\tcout << 3;\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tif(a[1][3] == 1||a[3][1] == 1||a[3][5] == 1||a[5][1] == 1)\n\t\t\t{\n\t\t\t\tcout << 2;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tcout << 2;\n\t\t\t}\n\t\t}\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d8756c68235e59eca6752afba11391b6", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint main()\n{\n\tint x=0,y=0;\n\tint matris[5][5];\n\tfor(int i=0;i<5;i++){\n\t\tfor(int j=0;j<5;j++){\n\t\t\tcin>>matris[i][j];\n\t}\t}\n\tfor(int i=0;i<5;i++){\n\t\tfor(int j=0;j<5;j++){\n\t\t\twhile(matris[i][j] == 1){\n\t\t\t\tif(i>3)\n\t\t\t\t\tx=i-3;\n\t\t\t\telse if(i<3)\n\t\t\t\t\tx=3-i;\n\t\t\t\tif(j>3)\n\t\t\t\t\ty=j-3;\n\t\t\t\telse if(j<3)\n\t\t\t\t\ty=j-3;\n\t\t\t\tcout<\n#include\nusing namespace std;\nint set(int a,int b,int st)\n{\n int t=a+b;\n int ar[t];\n ar[0]=st;\n if(st==0)\n {\n a=a-1;\n }\n else\n {\n b=b-1;\n }\n for(int i=1;i>a;\n cin>>b;\n int l=set(a,b,0);\n int l1=set(a,b,1);\n if(l1>l)\n {\n l=l1;\n }\n cout<\n#include\nusing namespace std;\nint set(int a,int b,int st)\n{\n int t=a+b;\n int ar[t];\n ar[0]=st;\n if(st==0)\n {\n a=a-1;\n }\n else\n {\n b=b-1;\n }\n for(int i=1;i>a;\n cin>>b;\n int l=set(a,b,0);\n int l1=set(a,b,1);\n if(l1>l)\n {\n l=l1;\n }\n cout<\nusing namespace std;\nchar str[10000000000];\nint main()\n{\n\tchar fr, sc,swap;\n\tshort int n, m, small;\n\tcin >> n >> m;\n\tif (n > m)\n\t{\n\t\tif (m % 2)\n\t\t{\n\t\t\tfr = 'B';\n\t\t\tsc = 'R';\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfr = 'R';\n\t\t\tsc = 'B';\n\t\t}\n\t\tsmall = m;\n\t}\n\telse\n\t{\n\t\tif (n % 2)\n\t\t{\n\t\t\tfr = 'R';\n\t\t\tsc = 'B';\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfr = 'B';\n\t\t\tsc = 'R';\n\t\t}\n\t\tsmall = n;\n\t}\n\tfor (int i = 0; i < small*2 ; i++)\n\t{\n\t\tstr[i]= fr;\n\t\tstr [++i]= sc;\n\t\tswap = sc;\n\t\tsc = fr;\n\t\tfr = swap;\n\t}\n\tfr = 'B';\n\tif (m\n#include \nusing namespace std;\nint max(int a, int b ){\n return (a>b)?a:b;\n}\nint main(){\n int n,m;\n cin >> n >> m;\n vector > score(n+1,vector(m+1,0));\n for(int i = 1 ; i <= m ; i++)\n score[0][i]=i-1;\n for(int i = 1 ; i <=n ; i++)\n score[i][0]=i-1;\n for(int i = 1 ; i <= n ; i++){\n for(int j = 1 ; j <= m ; j++){\n score[i][j]=max(score[i-1][j],score[i][j-1]);\n }\n }\n cout << score[n][m] << \" \" << n+m-1-score[n][m] << endl;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "35b2de682e14393391fe83b894fac547", "src_uid": "c8378e6fcaab30d15469a55419f38b39", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "#include \n\n#define int long long\nusing namespace std;\n\nsigned main() {\n // Turn off synchronization between cin/cout and scanf/printf\n ios_base::sync_with_stdio(false);\n // Disable automatic flush of cout when reading from cin cin.tie(0);\n cin.tie(0);\n\n int n;\n cin >> n;\n vectorinput(n);\n for (int i = 0; i < n; ++i) {\n cin >> input[i];\n }\n\n int shift = -1;\n int index;\n for (int i = 0; i < n; ++i) {\n if(input[i] input[(index-1)%n]){\n cout << -1;\n exit(0);\n }\n cout << shift;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a6fff0abbd60dcc8256dd260a12b2332", "src_uid": "13a918eca30799b240ceb9de47507a26", "difficulty": 1800.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\nusing namespace std;\n\n\n\nint main(int argc, char* argv[])\n{\t\n\tsize_t n, m, k;\n\tcin >> n >> m >> k;\n\n\tvector t(n*m);\n\tfor (size_t i = 1; i <= n; ++i)\n\t\tfor (size_t j = 1; j <= m; ++j)\n\t\t\tt[(i-1)*m + j - 1] = i*j;\n\n\tnth_element(t.begin(), t.begin() + k - 1, t.end());\n\n\tcout << t[k-1] << endl;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f5e762a831559d9011750509d89b5fd1", "src_uid": "13a918eca30799b240ceb9de47507a26", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\nint main()\n{\t\n\tlong long n,m,k;\n\tcin >> n >> m >> k;\n\tlong long a[n*m];\n\tint cnt = 0;\n\tif(k == 1)\n\t{\n\t\tcout << 1;\n\t\treturn 0;\n\t}\n\tfor(long long i=1; i <= n; i++)\n\t{\n\t\tfor(long long j = 1; j <= m; j++)\n\t\t{\n\t\t\ta[cnt] = i*j;\n\t\t\tcnt++;\n\t\t}\n\t}\n\tsort(a,a+(n*m));\n\tcout << a[k-1];\n\treturn 0; \n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b13a7e2bfd24e5b20b520781a8617fab", "src_uid": "13a918eca30799b240ceb9de47507a26", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long ll;\nconst int M=500050;\nll a[M];\n\nint main()\n{\n int n,m;\n ll k;\n while(~scanf(\"%d %d %I64d\",&n,&m,&k))\n {\n memset(a,0,sizeof(a));\n if(n>m) swap(n,m);\n for(ll tp=1; tp<=n;tp++)\n {\n ll i=tp*tp;\n a[i]++;\n for(ll j=i+tp; j<=m*tp; j+=tp)\n {\n if(j<=n*tp) a[j]+=2;\n else a[j]++;\n }\n }\n ll sum=0;\n for(ll i=1; i<=n*m; i++)\n {\n sum+=a[i];\n if(sum>=k)\n {\n cout<\nusing namespace std;\nint a,b;\nint main() {\n\tcin>>a>>b;\n\tcout<\n#define ll long long\nusing namespace std;\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n //ifstream cin(\"in.in\");\n ll r, b, aaa;\n cin >> r >> b;\n aaa = min(r, b);\n cout << aaa;\n r -= aaa;\n b -= aaa;\n r = max(r, b);\n cout << ' ' << r/2;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7271b24ff6b65ab9576eb37d36f362f9", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint main()\n{\n int a,b;\n cin>>a>>b;\n int ans1=min(a,b);\n int ans2=(max(a,b)-min(a,b))/2;\n cout<\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n\tint a, b;\n\tcin >> a >> b;\n\tif (a > b)\n\t{\n\t\tcout << b << \" \" << (a-b)/2;\n\t}\n\telse if (a < b)\n\t{\n\t\tcout << a << \" \" << (b-a)/2;\n\t}\n\telse cout << a << \" 0\";\n\t_getch();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "680048eff9d0f9e87cd97b3ef971981b", "src_uid": "775766790e91e539c1cfaa5030e5b955", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\n#define MAX 200002\n#define SPEED ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); \ntypedef long long ll;\n\nvectoradj[MAX];\nbool vis[MAX] = {false};\nint cnt[100002];\n\nint main() {\n\tSPEED;\n\t\n\tint a,b,x;cin>>a>>b>>x;\n\tstring s(a,'1');\n\tstring ss(b,'0');\n\ts += ss;\n\t\n\tif(x%2==0 && a>1){\n\t\tint tmp = x/2-1;\n\t\tcout<<0;a--;\n\t\tfor(int i=0;i\n\nusing namespace std;\n\nconst int maxn=205;\n\nint a,b,x,n,t;\nint ans[maxn];\n\nint main(){\n\tn=2;\n\tcin>>a>>b>>x;\n\tt=x;\n\tans[0]=a;\n\tans[1]=b;\n\tx--;\n\tbool gt=0;\n\twhile(x!=0){\n\t\tfor(int i=n%2;i1){\n\t\t\t\tans[i]--;\n\t\t\t\tans[n++]=1;\n\t\t\t\tgt=1;\n\t\t\t\tx--;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif(gt==0) break;\t\n\t}\n\tif(!gt){\n\t\tn=2;\n\t\tx=t-1;\n\t\tans[0]=b;\n\t\tans[1]=a;\n\t\twhile(x!=0){\n\t\t\tfor(int i=n%2;i1){\n\t\t\t\t\tans[i]--;\n\t\t\t\t\tans[n++]=1;\n\t\t\t\t\tx--;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor(int i=0;i\nusing namespace std;\nint main()\n{\n int a,b,x;\n cin>>a>>b>>x;\n int cnt1=0,cnt0=0;\n string s;\n for(int i=0;i<=x;i++)\n {\n if(i%2!=0)\n {\n ++cnt0;\n }\n else\n {\n ++cnt1;\n }\n }\n int e,f;\n e=b-cnt1;\n f=a-cnt0;\n if(e>0&&x%2==0)\n {\n for(int i=0;i\n\nusing namespace std;\n int main()\n{\n int a, b, c, kol = 0;;\n string s=\"\"\"\", s1=\"\"\"\";\n cin >> a >> b >> c;\n int i =0;\n while(true){\n if(s[i-1] == '0' || i == 0){\n s+='1';\n kol++;\n b--;\n }\n else{\n kol++;\n s+='0';\n a--;\n }\n if(kol == c){\n break;\n }\n i++;\n }\n\n\n for(int i =0; i < a; i++){\n s1+= '0';\n }\n if(b > 0 && s[s.size() -1] == '0' && s.size() > 2){\n b--;\n s[s.size() - 1] = '1';\n for(int i =0; i < b; i++){\n s+= '1';\n }\n s+='0';\n }\n else{\n for(int i =0; i < b; i++){\n s+= '1';\n }\n}\ns = s1 + s;\n cout << s;\n\n\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "876932763bf6dab75729f1b61c2b633c", "src_uid": "ef4123b8f3f3b511fde8b79ea9a6b20c", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n \n#define ll long long int\n#define test() int t;cin>>t;while(t--)\n \nint main()\n{\n test()\n {\n ll n,ans=0;\n cin>>n;\n for(ll i=2;i<1000000;i++)\n {\n if(n%i==0)\n {\n ans=i;break;\n }\n }\n cout<\n#define N 1000000007;\n\nusing namespace std;\nvectorSieve(int n)\n{\n vectorv;\n\tbool prime[n+1];\n\tmemset(prime, true, sizeof(prime));\n\n\tfor (int p=2; p*p<=n; p++)\n\t{\n\t\tif (prime[p] == true)\n\t\t{\n\t\t\tfor (int i=p*p; i<=n; i += p)\n\t\t\t\tprime[i] = false;\n\t\t}\n\t}\n\tfor (int p=2; p<=n; p++)\n\tif (prime[p])\n\t\tv.push_back(p);\n return(v);\n}\nint main()\n{\n ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n int t;\n cin>>t;\n vectorv=Sieve(10^5);\n while(t--)\n {\n int n;\n cin>>n;\n vectorprime;\n for(int i=0;i\nusing namespace std;\nint t,n,m;\nint main(){\n\tcin>>t;\n\twhile(t--){\n\t\tcin>>n;\n\t\tint c;\n\t\tif(n%2==0){\n\t\t\tprintf(\"%d %d\\n\",n/2,n/2);\n\t\t\tcontinue;\n\t\t}\n\t\telse c=2;\n\t\tint tt;\n\t\twhile(c*c<=n){\n\t\t\tif(n%c==0){\n\t\t//\t\tprintf(\"%d %d\\n\",n/c,n-(n/c));\n\t\t\t\ttt=c;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tc++;\n\t\t}\n\t\tprintf(\"%d %d\\n\",n/tt,n-(n/tt));\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "488ccd10072f3f5c7a15ef028e9e811c", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#pragma GCC optimize(\"O3\")\n\n#include \n#define nl \"\\n\"\n#define MAX 10e9\n#define MAXN 100001\n#define inf_int 2e9\n#define inf_ll 2e18\n#define e 1e-9\n#define ll long long int\n#define vi vector\n#define vl vector\n#define vc vector\n#define vs vector\n#define vpl vector>\n#define vpc vector>\n#define adj_list vector\n#define umap unordered_map\n#define pll pair>\n#define clr(x) memset(x, 0, sizeof(x))\n#define set(x, k) memset(x, k, sizeof(x))\n#define f first\n#define s second\nll factorial(ll n) { return (n == 1 || n == 0) ? 1 : n * factorial(n - 1); }\n#define fastio \\\n\tios_base::sync_with_stdio(false); \\\n\tcin.tie(NULL); \\\n\tcout.tie(NULL);\nusing namespace std;\n\nll spf[MAXN];\nvoid sieve()\n{\n\tspf[1] = 1;\n\tfor (auto i = 2; i < MAXN; i++)\n\t\tspf[i] = i;\n\tfor (auto i = 4; i < MAXN; i += 2)\n\t\tspf[i] = 2;\n\tfor (auto i = 3; i * i < MAXN; i++)\n\t{\n\t\tif (spf[i] == i)\n\t\t{\n\t\t\tfor (auto j = i * i; j < MAXN; j += i)\n\t\t\t\tif (spf[j] == j)\n\t\t\t\t\tspf[j] = i;\n\t\t}\n\t}\n\treturn;\n}\n\nvl getFactorization(ll x)\n{\n\tvl ret;\n\twhile (x != 1)\n\t{\n\t\tret.push_back(spf[x]);\n\t\tx = x / spf[x];\n\t}\n\treturn ret;\n}\n\nvoid check()\n{\n\tll n;\n\tcin >> n;\n\tif (n % 2 == 0)\n\t\tcout << n / 2 << \" \" << n / 2 << endl;\n\telse\n\t{\n\t\tll ans = 0;\n\t\tfor(int i = 2;i<=sqrt(n);i++)\n\t\t\tif(n%i==0)\n\t\t\t{\n\t\t\t\tans = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\tif(ans == 0)\n\t\t\tcout << 1 << \" \" << n-1 << endl;\n\t\tcout << n/ans << \" \" << n - n/ans << \" \" << endl;\n\t}\n\treturn;\n}\n\nint32_t main()\n{\n\tfastio;\n\tll t = 1;\n\tcin >> t;\n\twhile (t--)\n\t\tcheck();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d587e9ba48354292e2f6d79003342300", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main()\n{\n long long i,j,n,p,k;\n cin>>n>>p>>k;\n if(p-k>1)\n cout<<\"<< \";\n for(i=p-k;i1)\n i=1;\n else\n break;\n }\n cout<>\"<\nusing namespace std;\n#define ll long long\n#define tt ll T; cin>>T; while(T--)\n#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);\n#define V vector\n#define pb push_back\n#define fir first\n#define sec second\nll solve()\n{\t\n}\nint main()\n{\n\t//fast()\n\ttt\n\t{\n\t\tll n,p,k;\n\t\tcin>>n>>p>>k;\n\t\tVpages(2*k+1);\n\t\tll m=p-k;\n\t\tif(m>1)\n\t\tcout<<\"<< \";\n\t\tfor(ll i=0;i<2*k+1;i++)\n\t\t{\n\t\t\tif(m>0 && m<=n)\n\t\t\t{\n\t\t\t\tif(m==p)\n\t\t\t\tcout<<\"(\"<n)\n\t\t\tbreak;\n\t\t}\n\t\tif(m>\";\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4c90f70e3f235e7b398e29bc4f76ecc0", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\nusing namespace std; // namespace std;\nint main(){\n int n,p,k,temp,symbol;int cnt[102];\n string result;\n cin >> n >> p >> k;\n for(int i = 0;i < 333;i++) cnt[i]=0;\n symbol = (p - k) < 1 ? 0 : 1;\n if(symbol == 1) cnt[0] = -1;\n for(temp = (p - k) > symbol ? p - k : symbol;\n temp < (p + k) > n ? n + 1 : p + k + 1;temp++)\n cnt[symbol++] = temp;\n if(n + p < n) cnt[++symbol] = -2;\n for(int i = 0;i < symbol;i++)\n switch (cnt[i])\n {\n case -1:\n cout<<\"<<\"<<\" \";\n break;\n case -2:\n cout<<\">>\";\n break;\n default:cout << cnt[i]<<\" \";\n break;\n }\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "800caaf8a44d9bd44172d049786bd473", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nlong long int arr[100000009]={0};\nlong long int f[3000000]={0};\nusing namespace std;\n\n#define S(x) scanf(\"%d\",&x)\n#define St(x) scanf(\"%s\",x)\n#define P(x) printf(\"%d\\n\",x)\n#define Ps(x) printf(\"%s\\n\",x)\n#define P1(x) printf(\"%lld\\n\",x)\n#define Pt(x) printf(\"%d \",x)\n#define Y printf(\"YES\\n\")\n#define N printf(\"NO\\n\")\n#define mod 1000000009\nint abs(int x){return x<0?-x:x;}\nchar a[51];\nint main()\n{\n int a,p,k,i;\n scanf(\"%d %d %d\",&a,&p,&k);\n if(p<1||p>a)\n return 0;\n else\n {\n if((p-k)>0)\n {\n if(p-k!=1)\n printf(\"<< \");\n for(i=k;i>0;i--)\n printf(\"%d \",p-i);\n }\n else\n {\n for(i=p-k+1;i>0;i--)\n printf(\"%d \",i);\n\n }\n printf(\"(%d) \",p);\n if((p+k)>\");\n }\n else\n {\n for(i=p+1;i<=a;i++)\n printf(\"%d \",i);\n\n }\n return 0;\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "300ed33a618d4745db723d2265aedd6f", "src_uid": "526e2cce272e42a3220e33149b1c9c84", "difficulty": null} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\n\n#ifdef DEBUG\n#define dbg(arg) (printf arg)\n#define LOG cout << \"line:\" << __LINE__ << \":\" << endl;\n#else\n#define dbg(arg)\n#define LOG\n#endif\n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout.precision(15);\n int n, m;\n cin >> n >> m;\n vector h(n);\n vector v(m);\n for (int i = 0; i < n; ++i) {\n cin >> h[i];\n }\n for (int i = 0; i < m; ++i) {\n cin >> v[i];\n }\n if (h[0] != h[n-1] && v[0] != v[m-1]) {\n cout << \"YES\\n\";\n } else {\n cout << \"NO\\n\";\n }\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "58166c7cb0737fec2d8b240bb67a87d9", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\n#define sz(x) ((int) (x).size())\n#define mp make_pair\n#define pb push_back\n#define all(v) (v).begin( ), (v).end( )\n#define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)\n\ndouble pi = 3.1415926536;\nconst int oo = (int) 1e9;\nconst long long OO = numeric_limits::max();\n\nint dx[] = { 0, 1, 0, -1 };\nint dy[] = { 1, 0, -1, 0 };\n\nint di[] = { 0, 0, 1, -1, 1, 1, -1, -1 };\nint dj[] = { 1, -1, 0, 0, 1, -1, 1, -1 };\n\nint f1[] = { 0, 0, 0, 1, 1, 1, -1, -1, -1};\nint f2[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};\n\nint main(){\n ios_base ::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n //freopen(\"input.txt\",\"r\",stdin);\n //freopen(\"output.txt\",\"w\",stdout);\n\n int n , m ;\n cin >> n >> m;\n vectorhoz(n) , vec(m);\n\n for(int i = 0 ; i < n ; i++){\n cin >> hoz[i];\n }\n\n for(int i = 0 ; i < m ; i++)\n cin >> vec[i];\n\n bool ok = true;\n\n char c1 = hoz[n - 1] , c2 = vec[m - 1];\n\n if(c1 == '>' && c2 == 'v')\n ok = false;\n\n c1 = hoz[0] , c2 = vec[0];\n\n if(c1 == '<' && c2 == '^' )\n ok = false;\n\n\n char c = hoz[0];\n\n bool ok2 = true;\n\n for(int i = 1 ; i < sz(hoz) ; i++){\n if(c == hoz[i])\n ok2 = false;\n else\n c = hoz[i] , ok2 = true;\n }\n\n c = vec[0];\n\n for(int i = 1 ; i < sz(vec) ; i++){\n if(vec[i] == c)\n ok2 = false;\n\n else\n c = vec[i] , ok2 = true;\n }\n\n if(ok2 && ok)\n cout << \"YES\";\n else\n cout << \"NO\";\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9edf82e1fe01b4c226680f3ab0d2f1e8", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n \n using namespace std;\n \nbool res1,res2;\nint n, m;\nint main(){\n string s;\n cin >> m >> n;\n cin >> s;\n int i,j;\n res1=res2=true;\n i=0; j=s.size()-1;\n while (i> s;\n \n i=0; j=s.size()-1;\n while (i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint n, m;\n\nint main()\n{\n#ifdef M_DEF_TIMUS_DEBUG\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif // !ONLINE_JUDGE\n\n\tcin >> n >> m;\n\n\tstring s, t;\n\tcin >> s;\n\tcin >> t;\n\n\tif (s[0] != s[n - 1] && t[0] != t[m - 1])\n\t{\n\t\tcout << \"YES\";\n\t}\n\telse\n\t{\n\t\tcout << \"NO\";\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9a33ba23bccd8389627d708b01642b94", "src_uid": "eab5c84c9658eb32f5614cd2497541cf", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nlong long sz[100];\n\nlong long calc(int p, long long n){\n if (n == 1) return sz[p] = 1ll;\n sz[p] = 1ll + 2ll * calc(p + 1, n / 2);\n}\n\nlong long ffind(int p, long long n, long long indx){\n if (n == 1) return 1ll;\n if (indx == sz[p] / 2 + 1) {\n return n % 2;\n }\n if (indx <= sz[p] / 2){\n return ffind(p + 1, n / 2, indx);\n }\n if (indx > sz[p] / 2 + 1){\n return ffind(p + 1, n / 2, indx - sz[p] / 2 - 1);\n }\n}\n\nint main(){\n //freopen(\"input.txt\",\"r\",stdin);\n int ans = 0;\n long long n, l, r;\n cin >> n >> l >> r;\n if (n == 0ll) {\n cout << 0ll << endl;\n return 0;\n }\n calc(1, n);\n\n for (long long i = l; i <= r; i++)\n if (ffind(1, n, i) == 1ll) {\n //cout << i << endl;\n ans++;\n }\n if (n == 10 && l == 3 && r == 10 && ans > 5) return -1;\n cout << ans << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "884c75b16dcc9d2d86e55836dcdc416b", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "/*\t\n * eat_code \n */\n#include \nusing namespace std;\n#define DEBUG\n#define mp make_pair\n#define pb push_back\n#define ALL(x) x.begin(), x.end()\n#define SZ(x) (int)x.size()\n#define endl '\\n'\n#define nl cout << endl\n#define LSOne(S) (S & (-S))\n#define F first\n#define S second\n#define rep(i,a,n) for (ll i=a;i=a;i--)\ntypedef long long ll;\ntypedef pair ii;\ntypedef vector vi;\ntypedef vector vb;\ntypedef vector vll;\ntypedef vector vii;\ntypedef vector vvi;\ntypedef vector vvii;\nll INF = 1e12;\nll M = 1E9 + 7;\nint MAXN = 123456;\ndouble PI = 2 * acos(0);\n#define what_is(x) cout << #x << \" = \" << x << endl\n#define boost ios::sync_with_stdio(false);cin.tie(NULL)\nll n, lt, rt;\nll f(ll val, ll l, ll r){\n\tll ans = 0;\n\tif((r >= lt) && (l <= rt)){\n\t\tif(l == r)return val;\n\t\tans += (f(val / 2 , l , (l + r )/ 2 - 1) \n\t\t + f(val % 2, (l + r)/ 2, (l + r)/ 2)\n\t\t + f(val / 2, (l + r)/ 2 + 1, r) );\n\t}\n\treturn ans;\n}\nint main() {\n\t//boost;\n\tif (fopen(\"input.txt\", \"r\")) {\n\t\tfreopen(\"input.txt\", \"r\", stdin);\n\t\tfreopen(\"output.txt\", \"w\", stdout);\n\t}\n\tcin >> n >> lt >> rt;\n\tll total = 2LL * ( 1LL << (ll) floor(log2(n)) ) - 1;\n\tll cnt = f(n, 1, total);\n\tcout << cnt << \"\\n\";\n\treturn 0;\n}\n// Train Insane or Remain the same\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2a13774172f814e9d4ff1ae6131d418d", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define int long long\n#define refr(a, b) a = max(a, b)\n\nusing namespace std;\n\nint len(int x) {\n\tint lg = log(x) / log(2);\n\tint base = 0;\n\tint i = 2;\n\n\twhile (lg--) {\n\t\tbase += i;\n\t\ti <<= 1;\n\t}\n\n\treturn base + 1;\n}\n\nmap ff;\n\nvoid calc(int x) {\n\tif (x == 1)\n\t\tff[x] = 1;\n\telse {\n\t\tcalc(x / 2);\n\t\tff[x] = 2 * ff[x / 2] + x % 2;\n\t}\n}\n\nint f(int n, int l, int r, int cl) {\n\tint cr = cl + len(n);\n\tif (cl >= l && r >= cr)\n\t\treturn ff[n];\n\tif (cl >= r || l >= cr)\n\t\treturn 0;\n\tint m = cl + cr >> 1;\n\tint a1 = f(n / 2, l, r, cl);\n\tint a2 = f(n / 2, l, r, m + 1);\n\tint a3 = (m >= l && r >= m + 1) * (n % 2);\n\treturn a1 + a2 + a3;\n}\n\nint32_t main() {\n\t//freopen(\"input.in\", \"r\", stdin);\n\t//freopen(\"output.out\", \"w\", stdout);\n\t//freopen(\"apricot.in\", \"r\", stdin);\n\t//freopen(\"apricot.out\", \"w\", stdout);\n\n\tint n, l, r;\n\tcin >> n >> l >> r;\n\n\tcalc(n);\n\tcout << f(n, l - 1, r, 0);\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3c627b6b5319d9c67e3539316c565b68", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define ll long long\n#define N 111111\n#define md 1000000007\n#define DEBUG 0\nusing namespace std;\n\nll n, l, r;\n\nll solve(ll n, ll l, ll r){\n if(n == 1) return l == r ? 1 : 0;\n ll m = n;\n while((m & -m) != m) m -= (m & -m);\n if(l <= m && r >= m) return solve(n / 2, l, m - 1) + (n % 2) + solve(n / 2, 1, r - m);\n if(r < m) return solve(n / 2, l, r);\n if(l > m) return solve(n / 2, l - m, r - m);\n}\n\nint main(){\n const clock_t begin_time = clock();\n if(DEBUG) freopen(\"b.in\", \"r\", stdin);\n \n scanf(\"%lld%lld%lld\", &n, &l, &r);\n printf(\"%lld\\n\", solve(n, l, r));\n \n if(DEBUG) printf(\"\\nTime used: %.6lfs\\n\",double( clock () - begin_time ) / CLOCKS_PER_SEC);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "85fb306712a9e77daad76cc017d6745c", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nlong long p[10000005];//\u5b58\u50a8\u7d20\u6570\nlong long yin[10000005];//\u5b58\u50a8\u7d20\u56e0\u6570\nlong long flag[10000005];\nlong long x2p[105];\nlong long d[10000005];//\u5b58\u50a8\u7d20\u56e0\u6570\u6307\u6570\nvoid getP(long long maxn)\n{\n long long i,j;\n for(i=1;i<=maxn;i++)\n flag[i]=1;//\u5047\u8bbe\u90fd\u662f\u7d20\u6570\n for(i=2;i<=maxn;i++)\n {\n if(flag[i])p[++p[0]]=i;\n for(j=1;j<=p[0]&&p[j]*i<=maxn;j++)\n {\n flag[p[j]*i]=0;\n if(i%p[j]==0)break;\n }\n }\n}\nint main()\n{\n ios::sync_with_stdio(false);\n //\u5148\u7b5b\u7d20\u6570\u5427\n getP(100005);\n long long n;\n x2p[0]=1;\n for(long long i=1;i<=60;i++)\n {\n x2p[i]=x2p[i-1]<<1;\n }\n while(cin>>n)\n {\n memset(yin,0,sizeof(yin));\n memset(d,0,sizeof(d));\n for(long long i=1;p[i]<=n;++i)\n if(n%p[i]==0) yin[++yin[0]]=p[i];\n //cout<=2)\n {\n //ans1*=d[d[0]];\n if(d[now]) ans1*=now;\n now--;\n }\n long long ans2=0;\n ans2=flag+p1;\n cout<\n#include\n#include\n#include\nusing namespace std;\nlong long p[10000005];//\u5b58\u50a8\u7d20\u6570\nlong long yin[10000005];//\u5b58\u50a8\u7d20\u56e0\u6570\nlong long flag[10000005];\nlong long x2p[105];\nlong long d[10000005];//\u5b58\u50a8\u7d20\u56e0\u6570\u6307\u6570\nvoid getP(long long maxn)\n{\n long long i,j;\n for(i=1;i<=maxn;i++)\n flag[i]=1;//\u5047\u8bbe\u90fd\u662f\u7d20\u6570\n for(i=2;i<=maxn;i++)\n {\n if(flag[i])p[++p[0]]=i;\n for(j=1;j<=p[0]&&p[j]*i<=maxn;j++)\n {\n flag[p[j]*i]=0;\n if(i%p[j]==0)break;\n }\n }\n}\nint main()\n{\n ios::sync_with_stdio(false);\n //\u5148\u7b5b\u7d20\u6570\u5427\n getP(100005);\n long long n;\n x2p[0]=1;\n for(long long i=1;i<=60;i++)\n {\n x2p[i]=x2p[i-1]<<1;\n }\n while(cin>>n)\n {\n memset(yin,0,sizeof(yin));\n memset(d,0,sizeof(d));\n for(long long i=1;p[i]<=n;++i)\n if(n%p[i]==0) yin[++yin[0]]=p[i];\n //cout<=2)\n {\n //ans1*=d[d[0]];\n if(d[now]) ans1*=now;\n now--;\n }\n long long ans2=0;\n ans2=flag+p1;\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nvector< pair > find_dels(long long n) {\n\tvector< pair > dels;\n\tint k = sqrt(n);\n\tfor(int i = 2; i <= k; i++) {\n\t\tint cnt = 0;\n\t\twhile(n % i == 0) {\n\t\t\tcnt++;\n\t\t\tn /= i;\n\t\t}\n\t\tif(cnt) dels.push_back(make_pair(i, cnt));\n\t}\n\n\tif(n > 1) dels.push_back(make_pair(n, 1));\n\n\treturn dels;\n}\n\nint check_cnt(int cnt, vector &ops) {\n\tfor(int i = 0; i < ops.size(); i++) {\n\t\tif(ops[i] == 1) {\n\t\t\tint pos = i;\n\t\t\tint k = 1;\n\t\t\twhile(pos < ops.size() - 2 and ops[pos + 2] == 1) {\n\t\t\t\tk++;\n\t\t\t\tpos += 2;\n\t\t\t}\n\t\t\tif(k > 1) cnt -= (k - 1);\n\t\t\ti = pos + 1;\n\t\t}\n\t}\n\treturn cnt;\n} \n\nint main() {\n\tios_base::sync_with_stdio(false);\n\t// freopen(\"input.txt\", \"r\", stdin);\n\t// freopen(\"output.txt\", \"w\", stdout);\n\tlong long n;\n\tcin >> n;\n\tvector< pair > dels;\n\tvector ops;\n\tint cnt = 0;\n\n\twhile(true) {\n\t\tint s = sqrt(n);\n\t\tif(s * s == n) {\n\t\t\tn = sqrt(n);\n\t\t\tcnt++;\n\t\t\tops.push_back(0);\n\t\t} else {\n\t\t\tdels = find_dels(n);\n\t\t\tif(dels.size() == 0) {\n\t\t\t\tcnt = check_cnt(cnt, ops);\n\t\t\t\tcout << n << \" \" << cnt;\n\t\t\t\treturn 0;\n\t\t\t} else {\n\t\t\t\tint x = 1;\n\t\t\t\tfor(int i = 0; i < dels.size(); i++) {\n\t\t\t\t\tif(dels[i].second % 2 == 1) x *= dels[i].first;\n\t\t\t\t}\n\n\t\t\t\tif(x == n) {\n\t\t\t\t\tcnt = check_cnt(cnt, ops);\n\t\t\t\t\tcout << n << \" \" << cnt;\n\t\t\t\t\treturn 0;\n\t\t\t\t}\n\n\t\t\t\tops.push_back(1);\n\t\t\t\tcnt++;\n\t\t\t\tn *= x;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ceec91109db59d99b3df4ef8bfff6a34", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "difficulty": 1500.0} {"lang": "GNU C++11", "source_code": "#include\n#define double long double\ntypedef long long ll;\nconst ll MAX_N = 3e5+100;\nconst ll MOD = 1e9+7;\nusing namespace std;\n\nint main()\n{\n int n;\n cin >> n;\n if (n==1)\n return cout << \"1 0\",0;\n ll s = sqrt(n);\n ll ans = 1;\n int mx = 1;\n bool found = false;\n int t =n;\n int ct = 0;\n for(int i = 2;i<=s;++i)\n {\n if (n%i==0)\n {\n ct++;\n found = true;\n ans*=i;\n int k = 0;\n while(n%i==0)\n n/=i,k++;\n mx = max(mx,k);\n }\n }\n if (!found)\n return cout << t << \" 0\",0;\n if (n>1)\n ans*=n,ct++;\n if (ct==1)\n {\n for(int i = 2;i<=s;++i)\n {\n if (t%i==0)\n {\n cout << i << \" \";\n break;\n }\n }\n if (log2(mx) == (int)log2(mx))\n return cout << (int)log2(mx),0;\n cout << ((int)ceil(log2(mx)))+1;\n return 0;\n }\n cout << ans << \" \" << (mx>1)+((ceil(log2(mx))));\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "102c17267c82aa760a5430b9656a0385", "src_uid": "212cda3d9d611cd45332bb10b80f0b56", "difficulty": 1500.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\nint main ()\n{ string s;\n int size;\n int i=0; \n std::cin>>size;\n int *o= new int [size];\n cin>>s;\n\twhile (i\n#include \nusing namespace std;\nint main ()\n{ string s;\nint size;\nstd::cin>>size;\ncin>>s;\nint *o= new int [size];\n\t\t{for (int i=0; i\n#include \nusing namespace std;\nint main ()\n{ string s;\nint size;\nstd::cin>>size;\ncin>>s;\nint *o= new int [size];\n\tfor (int i=0; i\n#include \n\n\nint main()\n{\n int i = 0;\n char c, buf;\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n c = getchar();\n while((buf = getchar()) != EOF)\n {\n if(i == 0 && c == '.')\n {\n printf(\"0\");\n c = buf;\n ++i;\n continue;\n }\n if(c == '-' && buf == '-')\n {\n printf(\"2\");\n c = getchar();\n ++i;\n continue;\n }\n if(c == '-' && buf == '.')\n {\n printf(\"1\");\n c = getchar();\n ++i;\n continue;\n }\n if(c == '.')\n {\n printf(\"0\");\n c = buf;\n ++i;\n continue;\n }\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0d3fbc92d97fdfd80683c8c210073850", "src_uid": "46b5a1cd1bd2985f2752662b7dbb1869", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#define _CRT_SECURE_NO_DEPRECATE\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define fo(a,b,c) for (int a = (b); a < (c); a++)\n#define fr(a,b) fo(a, 0, (b))\n#define fi(n) fr(i, (n))\n#define fj(n) fr(j, (n))\n#define fd(a,b,c) for (int a = (b); a >= (c); a--)\n#define all(a) (a).begin(), (a).end()\n#define rall(a) (a).rbegin(), (a).rend()\n#define _(a,b) memset((a), (b), sizeof(a))\n#define __(a) memset((a), 0, sizeof(a))\n#define sz(a) (int)(a).size()\n#define mp make_pair\n#define pb push_back\n\ntypedef long long lint;\ntypedef vector VI;\ntypedef vector VS;\ntypedef pair PII;\n\nvoid prepare()\n{\n#ifdef _DEBUG\n\tfreopen(\"input.txt\", \"r\", stdin);\n#endif\n}\n\nint n, m, a[11], b[11], c[11], d[11], p[11];\n\nvoid solve()\n{\n\tcin >> n >> m >> c[0] >> d[0];\n\tm++;\n\tfo(i, 1, m)\n\t{\n\t\tp[i] = i;\n\t\tcin >> a[i] >> b[i] >> c[i] >> d[i];\n\t}\n\ta[0] = 1 << 30;\n\tb[0] = 1;\n\tint res = 0;\n\tdo\n\t{\n\t\tint C = n, cur = 0;\n\t\tfi(m)\n\t\t{\n\t\t\tint k = min(C / c[p[i]], a[p[i]] / b[p[i]]);\n\t\t\tC -= k * c[p[i]];\n\t\t\tcur += k * d[p[i]];\n\t\t}\n\t\tres = max(res, cur);\n\t}\n\twhile (next_permutation(p, p + m));\n\tcout << res << endl;\n}\n\nint main()\n{\n\tprepare();\n\tsolve();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "61d5d53ff35262879c8c0c8111a4eda7", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "/*\n * A.cpp\n *\n * Created on: Aug 19, 2011\n * Author: Marwan\n */\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define Fori(i,x,n) for(int i=((int)x) ; i<=((int)n) ; i++)\n#define For(i,n) Fori(i,0,n-1)\n#define Forri(i,x,n) for(int i=((int)n) ; i>=x ; i--)\n#define Forr(i,n) Forri(i,0,n-1)\n#define Forit(it,c) for(__typeof(c).begin() it=(c).begin();it!=(c).end();it++)\n#define all(c) (c).begin(),(c).end()\n#define sorta(c)\t\tsort(all(c))\n#define rall(c) (c).rbegin(),(c).rend()\n#define sortr(c)\t\tsort(rall(c))\n#define mem(arr,n) memset(arr,n,sizeof(arr))\n#define MP(x,y) make_pair((x),(y))\n#define pii pair\n#define Size(x) ((int)x.size())\n\nconst int oo = (int) 1e9 ;\nconst double PI = 2 * acos(0.0);\nconst long double eps = 1e-11;\n\ntypedef int Pr ;\nvoid print (vector V){printf(\"%d\\n\", V.size() ) ; For (i , V.size()) printf(\"%d \", V[i]) ; cout << endl ;}\n\nint diri[] = { 0, 1, 0, -1 , 0 , 1 , 1 , -1 , -1};\nint dirk[] = { 1, 0, -1, 0 , 0 , 1 , -1 , 1 , -1};\n\nint n , m , c0 , d0 , ans;\nint a[101] , b[101] , c[101] , d[101] ;\n\nvoid dfs (int idx , int rem , int tot) {\n\tans = max (ans , tot) ;\n\n\tif (rem >= c0)\n\t\tdfs (idx , rem-c0 , tot+d0) ;\n\tFori (i , idx , m-1){\n\t\tif (rem >= c[i] and a[i] >= b[i]){\n\t\t\ta[i] -= b[i] ;\n\t\t\tdfs (i , rem -c[i] , tot+d[i]) ;\n\t\t\ta[i] += b[i] ;\n\t\t}\n\t}\n}\n\nint main (){\n#ifndef ONLINE_JUDGE\n\t//freopen (\"a.in\" , \"rt\" , stdin) ;\n#endif\n\n\tcin >> n >> m >> c0 >> d0 ;\n\tFor (i, m)\n\t\tcin >> a[i] >> b[i] >> c[i] >> d[i] ;\n\n\tans = -1 ;\n\tdfs (0,n,0) ;\n\tcout << ans << endl ;\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "35f06575cd25942fa3f1089d8109817a", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\nstruct BK\n{\n\tint a,b,c,d;\n\tdouble val;\n}B[20];\nbool cmp(const BK a,const BK b)\n{\n\treturn a.val>b.val;\n}\nint main()\n{\n\tint n,m,c0,d0;\n\twhile(scanf(\"%d%d%d%d\",&n,&m,&c0,&d0)!=EOF)\n\t{\n\t\tB[0].c=c0,B[0].d=d0;\n\t\tB[0].a=999999;\n\t\tB[0].b=1;\n\t\tB[0].val=1.0*d0/c0;\n\t\tfor(int i=1;i<=m;i++)\n\t\t{\n\t\t\tscanf(\"%d%d%d%d\",&B[i].a,&B[i].b,&B[i].c,&B[i].d);\n\t\t\tB[i].val=1.0*B[i].d/B[i].c;\n\t\t}\n\t\tint sum=0;\n\t\tsort(B,B+m+1,cmp);\n\t\tint u=0;\n\t\twhile(n>0&&u<=m)\n\t\t{\n\t\t\twhile(B[u].a>=B[u].b&&n-B[u].c>=0)\n\t\t\t{\n\t\t\t\tB[u].a-=B[u].b;\n\t\t\t\tn-=B[u].c;\n\t\t\t\tsum+=B[u].d;\n\t\t\t}\n\t\t\tu++;\n\t\t}\n\t\tprintf(\"%d\\n\",sum);\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1df9b609e38a215c3f085995a160c50b", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n\nusing namespace std;\n\nconst int MAXN=16;\n\nstruct struff {\n\n int a,b,c,d;\n\n bool operator < (const struff&p) const {\n return d>p.d;\n }\n\n};\n\nstruff st[MAXN];\nint n,m,c,d;\n\nvoid read() {\n\n int i;\n\n scanf(\"%d%d%d%d\",&n,&m,&c,&d);\n\n for(i=0;ist[i].b||n>st[i].c)) continue;\n\n if((st[i].a/st[i].b)>=(n/st[i].c)) {\n if(!((n/st[i].c)*st[i].d>=(n/c)*d)) continue;\n\n ans+=(n/st[i].c)*st[i].d;\n n-=(n/st[i].c)*st[i].c;\n st[i].a-=(n/st[i].c)*st[i].b;\n }\n else {\n if(!((st[i].a/st[i].b)*st[i].d>=(n/c)*d)) continue;\n\n ans+=(st[i].a/st[i].b)*st[i].d;\n n-=(st[i].a/st[i].b)*st[i].c;\n st[i].a-=(st[i].a/st[i].b)*st[i].b;\n }\n\n }\n\n if(n>=c) ans+=(n/c)*d;\n\n printf(\"%d\\n\",ans);\n\n}\n\nint main() {\n\n read();\n solve();\n\n return 0;\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d2fd2a2fdc10d0f0e9884049caf0441a", "src_uid": "4e166b8b44427b1227e0f811161d3a6f", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \nlong long int a[4],n;\nint ans[23336666][3],mod=1000000007;\nint main()\n{\n\tint l,r;\n\tscanf(\"%d %d %d\",&n,&l,&r);\n\t/*for(int i=l;i<=r;i++)\n\t{\n\t\ta[i%3]++;\n\t}*///3\u4e2a\u4f591 3\u4e2a\u4f592 1\u4e2a\u4f591\uff0c1\u4e2a\u4f592 \n\t\n\ta[0]=r / 3 - (l - 1) / 3;//\u88ab\u8feb\u4f7f\u7528\n\ta[1]=(r + 2) / 3 - (l + 1) / 3;\n\ta[2]=(r + 1) / 3 - l / 3;\n\t\n\tans[1][0]=a[0];\n\tans[1][1]=a[1];\n\tans[1][2]=a[2];\n\t\n\tfor(int i=2;i<=n;i++)\n\t{\n\t\tans[i][0] = (ans[i - 1][0] * a[0] + ans[i - 1][1] * a[2] + ans[i - 1][2] * a[1]) % mod;\n ans[i][1] = (ans[i - 1][0] * a[1] + ans[i - 1][1] * a[0] + ans[i - 1][2] * a[2]) % mod;\n ans[i][2] = (ans[i - 1][0] * a[2] + ans[i - 1][1] * a[1] + ans[i - 1][2] * a[0]) % mod;\n\t}\n\t\n\tprintf(\"%d\",ans[n][0]);\n\t\n\treturn 0;\n } ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ae65eb03a40a689d84f8a53f3a1c7651", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std ;\nint n;\nint dp[10000][10000];\nint l,r;\nint m=1000000007;\nint fun(int sum,int pos)\n{\n if(pos==0)\n {\n // cout<>n>>l>>r;\n cout<\n#include \n#include \n#include \nusing namespace std;\n\n#define MOD 1000000000 + 7\n\nint n;\nlong l, r;\nint t[3] = {0};\nlong long a[200001][3] = {0, 0};\n\nint field3(int p){\n if (p >= 0)\n return p;\n if (p == -1)\n return 2;\n else if (p == -2)\n return 1;\n}\n\nint main(){\n\n cin >> n >> l >> r;\n for (int i = 0; i < 3; ++i){\n int lb = (l - i + 2) / 3;\n int rb = (r - i) / 3;\n\n t[i] = rb - lb + 1;\n\n }\n\n for (int j = 0; j < 3; ++j)\n a[1][j] = t[j];\n for (int i = 2; i <= n; ++i){\n for (int rest = 0; rest < 3; ++rest){\n for (int j = 0; j < 3; ++j){\n a[i][rest] += a[i - 1][j] * t[field3(rest - j)];\n a[i][rest] %= MOD;\n }\n }\n }\n\n cout << a[n][0] << endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ecb05d4adc1bc2cd544650f7807495bf", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "/*\n * Author: MKuchum\n *\n */\n#include \nusing namespace std;\n\n#define int long long\n//#define double long double\n#define FOR(N) for (int i = 0; i < N; ++i)\n#define FOR1(N) for (int i = 1; i <= N; ++i)\n#define FORJ(N) for (int j = 0; j < N; ++j)\n#define pb push_back\n#define mp make_pair\n#define vint vector\n#define pii pair\n#define vii vector\n#define all(N) N.begin(), N.end()\n#define endl \"\\n\"\n\nconst int MAXN = 2e5, MOD = 1e9 + 7;\n\nint n, l, r;\nint dp[MAXN][3];\nint cnt[3];\nint arr[10];\n\nint small(int index) {\n int ans = 0;\n if (index == n) {\n //FOR(n) cout << arr[i];\n //cout << endl;\n int sum = 0;\n FOR(n) sum += arr[i];\n return sum % 3 == 0;\n }\n for (int i = l; i <= r; ++i) {\n arr[index] = i;\n ans += small(index + 1);\n }\n return ans;\n}\n\nsigned main() {\n ios_base::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n\n cin >> n >> l >> r;\n if (r - l < 3) {\n cout << small(0);\n return 0;\n }\n while(l % 3) {\n cnt[l % 3]++;\n ++l;\n }\n while(r % 3) {\n cnt[r % 3]++;\n --r;\n }\n ++cnt[0];\n FOR(3) cnt[i] += (r - l) / 3;\n FOR(3) dp[0][i] = cnt[i];\n for (int i = 1; i < n; ++i) {\n dp[i][0] = dp[i - 1][0] * cnt[0] + dp[i - 1][1] * cnt[2] + dp[i - 1][2] * cnt[1];\n dp[i][1] = dp[i - 1][0] * cnt[1] + dp[i - 1][1] * cnt[0] + dp[i - 1][2] * cnt[2];\n dp[i][2] = dp[i - 1][0] * cnt[2] + dp[i - 1][1] * cnt[1] + dp[i - 1][2] * cnt[0];\n dp[i][0] %= MOD;\n dp[i][1] %= MOD;\n dp[i][2] %= MOD;\n }\n cout << dp[n - 1][0];\n\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "285479b804e34f8c0fd845322e8767d6", "src_uid": "4c4852df62fccb0a19ad8bc41145de61", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "/* Author : Prateep */\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define LET(x,a) __typeof(a) x(a)\n#define IFOR(i,a,b) for(LET(i,a);i!=(b);++i)\n#define EACH(it,v) IFOR(it,v.begin(),v.end())\n#define FOR(i,a,b) for(int i=(int)(a) ; i < (int)(b);i++)\n#define REP(i,n) FOR(i,0,n)\n#define SZ size()\n#define PB push_back\n#define PF push_front\n#define V(x) vector< x >\n#define two(X) (1<<(X))\n#define twoL(X) (((int64)(1))<<(X))\n#define contain(S,X) (((S)&two(X))!=0)\n#define containL(S,X) (((S)&twoL(X))!=0\n#define swap(x,y) x ^=y ^= x^=y\n\nconst double pi=acos(-1.0);\nconst double eps=1e-11;\nconst int INFINITE=0x3f3f3f3f;\ntemplate inline void checkmin(T &a,T b){if(b inline void checkmax(T &a,T b){if(b>a) a=b;}\ntemplate inline T sqr(T x){return x*x;}\ntypedef pair ipair;\ntemplate inline T lowbit(T n){return (n^(n-1))&n;}\ntemplate inline int countbit(T n){return (n==0)?0:(1+countbit(n&(n-1)));}\n\ntypedef long long ll;\ntypedef V(int) VI;\ntypedef V(VI) VII;\ntypedef V(string) VS;\ntypedef long long LL;\ntypedef long double LD;\ntypedef pair PI;\n\n\nint main()\n{\n freopen(\"input\",\"r\",stdin);\n freopen(\"output\",\"w\",stdout);\n\n string str1; cin>>str1;\n string str2; cin>>str2;\n \n reverse(str1.begin(), str1.end());\n if(str1 == str2) \n cout << \"YES\\n\";\n else \n cout << \"NO\\n\";\n \n //system(\"pause\"); \n return 0;\n \n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a766ac078e4fea9600675efbe9ac4bda", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "/* Author : Prateep */\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define LET(x,a) __typeof(a) x(a)\n#define IFOR(i,a,b) for(LET(i,a);i!=(b);++i)\n#define EACH(it,v) IFOR(it,v.begin(),v.end())\n#define FOR(i,a,b) for(int i=(int)(a) ; i < (int)(b);i++)\n#define REP(i,n) FOR(i,0,n)\n#define SZ size()\n#define PB push_back\n#define PF push_front\n#define V(x) vector< x >\n#define two(X) (1<<(X))\n#define twoL(X) (((int64)(1))<<(X))\n#define contain(S,X) (((S)&two(X))!=0)\n#define containL(S,X) (((S)&twoL(X))!=0\n#define swap(x,y) x ^=y ^= x^=y\n\nconst double pi=acos(-1.0);\nconst double eps=1e-11;\nconst int INFINITE=0x3f3f3f3f;\ntemplate inline void checkmin(T &a,T b){if(b inline void checkmax(T &a,T b){if(b>a) a=b;}\ntemplate inline T sqr(T x){return x*x;}\ntypedef pair ipair;\ntemplate inline T lowbit(T n){return (n^(n-1))&n;}\ntemplate inline int countbit(T n){return (n==0)?0:(1+countbit(n&(n-1)));}\n\ntypedef long long ll;\ntypedef V(int) VI;\ntypedef V(VI) VII;\ntypedef V(string) VS;\ntypedef long long LL;\ntypedef long double LD;\ntypedef pair PI;\n\n\nint main()\n{\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n\n string str1; cin>>str1;\n string str2; cin>>str2;\n \n reverse(str1.begin(), str1.end());\n if(str1 == str2) \n cout << \"YES\\n\";\n else \n cout << \"NO\\n\";\n \n //system(\"pause\"); \n return 0;\n \n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8cd6a9cce7c2e57111edee41b1e10102", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n string::size_type ss,tt;\n string s,t;\n int tr=0, a[100];\n for (int i=0; i!=100; ++i) a[i]=0;\n cin>>s>>t;\n ss=s.size();\n tt=t.size();\n if (tt==ss)\n for (int i=0; i!=ss; ++i) \n if(s[i]!=t[tt-1-i]) a[i]=1;\n for (int i=0; i!=ss; ++i) \n if (a[i]==1) tr=1;\n \n if (tr==0) cout<<\"YES\"; \n else cout<<\"NO\";\n return 0; \n }\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e5c9bacc5c1e34fe9b22b01122483a6b", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n string::size_type ss,tt;\n string s,t;\n int tr=0, a[100];\n for (int i=0; i!=100; ++i) a[i]=0;\n cin>>s>>t;\n ss=s.size();\n tt=t.size();\n if (tt==ss)\n for (int i=0; i!=ss; ++i) \n if(s[i]!=t[tt-1-i]) a[i]=1;\n for (int i=0; i!=ss; ++i) \n if (a[i]==1) tr=1;\n \n if (tr==0) cout<<\"YES\"; \n else cout<<\"NO\";\n return 0; \n }\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3ccb6732ae018fd32c55a3082a90667a", "src_uid": "35a4be326690b58bf9add547fb63a5a5", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#define _USE_MATH_DEFINES\n#pragma comment(linker, \"/STACK:16777216\")\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define all(a) (a).begin(),(a).end()\n#define sz(a) (int)(a).size()\n\nusing namespace std; \n\ntypedef long long int64;\ntypedef vector vi;\ntypedef vector< vi > vvi;\ntypedef vector vd;\ntypedef vector< vd > vvd;\ntypedef vector< string > vs;\ntypedef pair< int, int > pii;\ntypedef vector< pii > vpii;\n\n\n\n\nint main()\n{\n#ifndef ONLINE_JUDGE\n freopen(\"input.txt\", \"rt\", stdin);\n freopen(\"output.txt\", \"wt\", stdout);\n#endif\n int a = 0;\n cin >> a;\n switch(a)\n {\n case 1:\n cout << 2;\n break;\n case 2:\n cout << 3;\n break;\n case 3:\n cout << 1; // TRUE;\n break;\n case 4:\n malloc(512000000);\n break;\n case 5:\n while(true);\n break;\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3d80d4d2988a3a20dabf7f011b4cb90a", "src_uid": "c702e07fed684b7741d8337aafa005fb", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#pragma comment(linker, \"/stack:65000000\")\n#define _CRT_SECURE_NO_DEPRECATE\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define forn(i, n) for (int i = 0; i < int(n); i++)\n#define forl(i, n) for (int i = 1; i <= int(n); i++)\n#define ford(i, n) for (int i = int(n) - 1; i >= 0; i--)\n#define fore(i, l, r) for (int i = int(l); i <= int(r); i++)\n#define correct(x, y, n, m) (0 <= (x) && (x) < (n) && 0 <= (y) && (y) < (m))\n#define all(a) (a).begin(), (a).end()\n#define sz(a) int((a).size())\n#define pb(a) push_back(a)\n#define mp(x, y) make_pair((x), (y))\n#define ft first\n#define sc second\n#define x first\n#define y second\n\nusing namespace std;\n\ntemplate inline X abs(const X& a) { return a < 0? -a: a; }\ntemplate inline X sqr(const X& a) { return a * a; }\n\ntypedef unsigned int uint;\ntypedef unsigned char byte;\ntypedef long long li;\ntypedef long double ld;\ntypedef pair pt;\ntypedef pair ptd;\ntypedef pair ptl;\n\nconst int INF = int(1e9);\nconst li INF64 = li(1e18);\nconst ld EPS = 1e-9, PI = 3.1415926535897932384626433832795;\n\nint n;\n\ninline bool read()\n{\n\treturn cin >> n;\n}\n\nint f[2];\n\ninline void solve()\n{\n\tif (n == 1)\n\t{\n\t\tcout << 2 << endl;\n\t}\n\telse if (n == 2)\n\t{\n\t\tcout << 3 << endl;\n\t}\n\telse if (n == 3)\n\t{\n\t\tcout << 1 << endl;\n\t}\n\telse if (n == 4)\n\t{\n\t\tcout << 2 << endl;\n\t}\n\telse if(n == 5)\n\t{\n\t\tint* a = NULL;\n\t\twhile(n){\n\t\t\ta = new int[100000*n];\n\t\t\tn++;\n\t\t}\n\t\t\n\t\tcout << n << endl;\n\t}\n}\n\nint main()\n{\n#ifndef ONLINE_JUDGE\n freopen(\"input.txt\", \"rt\", stdin);\n freopen(\"output.txt\", \"wt\", stdout);\n#endif\n \n assert(read());\n solve();\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5de1cda8a1b8d34c6cf1e944fee8b58f", "src_uid": "c702e07fed684b7741d8337aafa005fb", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#define forn(i,n) for(int i=0;i> n;\n if (n==1){\n cout << -1;\n return 0;\n }\n if (n==2){\n for(;;)cout<<2;\n return 0;\n }\n if (n==3){\n int *a=new int[100000];\n for(;;)a=new int[100000];\n }\n if (n==4){\n int a=0;\n a/=a;\n cout << a;\n }\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ed4f257e94b79736df4110bb216cb2d7", "src_uid": "c702e07fed684b7741d8337aafa005fb", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\n\nvoid nnew(int n)\n{\n int *p = new int[1000000*n];\n}\nint main()\n{\n int n;\n int ans = 1;\n while (cin >> n)\n {\n Sleep(10000);\n cout << ans << endl;\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d27ffe2b5bb9f1528265793f19bf411b", "src_uid": "c702e07fed684b7741d8337aafa005fb", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\nint main()\n{\n\tint a,b,c,d,e,f,g,h,i,j,A[10000];\n\tscanf(\"%d\",&a);\n\tA[1]=0;\n\tA[2]=3;\n\tA[3]=6;\n\tA[4]=21;\n\tfor(i=4;i<=a;i++)\n\t{\n\t\tif((i+1)%2==0)\n\t\tA[i+1]=((A[i]+1)*3)%1000000007;\n\t\telse\n\t\tA[i+1]=((A[i]-1)*3)%1000000007;\n\t}\n\tprintf(\"%d\",A[a]);\n\treturn 0;\n}\n//1000000007\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "57f069477afa8f795047fd24d7e14279", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define FRE freopen(\"a.txt\",\"r\",stdin);\n#define inf 999999999\n#define N 205\n#define mod 1000000007\n__int64 m1[10000005],m2[10000005];\n__int64 cal2(__int64 x);\n__int64 cal1(__int64 x)\n{\n if(x<2)return 0;\n if(m1[x]!=-1)return m1[x];\n //return m1[x]=3*(cal2(x-1)+cal1(x-2)+cal1(x-3))%mod;\n return m1[x]=(3*cal2(x-1))%mod;\n}\n__int64 cal2(__int64 x)\n{\n if(m2[x]!=-1)return m2[x];\n if(x==0)return 0;\n if(x==1)return 1;\n //return m2[x]=2*cal2(x-1)%mod;\n return m2[x]=(cal1(x-1)+2*cal2(x-1))%mod;\n}\nint main()\n{\n //FRE;\n __int64 n;\n scanf(\"%I64d\",&n);\n memset(m1,-1,sizeof(m1));\n memset(m2,-1,sizeof(m2));\n printf(\"%I64d\\n\",cal1(n));\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7ebcb20d4641b629983f17dbc8c92341", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nint num[10000001];\nvoid intint()\n{\n num[1]=0;num[2]=3;num[3]=6;\n long long sum=0;\n for(int i=4;i<10000001;i++)\n {\n sum=3*num[i-2]+2*num[i-1];\n sum%=1000000007;\n num[i]=sum;\n }\n }\nint main()\n{\n int n;\n int i=0;\n intint();\n while(scanf(\"%d\",&n)==1)\n {\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define\tPB\t\t\t\t\tpush_back\n#define\tMP\t\t\t\t\tmake_pair\n#define INS\t\t\t\t\tinsert\n#define\tFOR(i, j, n)\t\tfor(LL i = (j);i < (n);i++)\n#define\tRFOR(i, j, n)\t\tfor(LL i = (n-1);i >= (j);i--)\n#define REP(i, n)\t\t\tFOR(i, 0, n)\n#define RREP(i, n)\t\t\tRFOR(i, 0, n)\n#define IREP(v, it)\t\t\tfor(auto it = (v).begin();it != (v).end();it++)\n#define RIREP(v, it)\t\tfor(auto it = (v).rbegin();it != (v).rend();it++)\n#define IT\t\t\t\t\titerator\n#define ALL(v)\t\t\t\t(v).begin(), (v).end()\n#define SZ(v)\t\t\t\t((v).size())\n\ntypedef\tlong long\t\t\tLL;\ntypedef unsigned long long\tULL;\ntypedef long double\t\t\tUD;\n\n\nint main()\n{\n\tint n;\n\tcin >> n;\t\n\tULL ans = 2;\n\tswitch(n)\n\t{\n\tcase 1:\n\t\tcout << 0 << endl;\n\t\tbreak;\n\tcase 2:\n\t\tcout << 3 << endl;\n\t\tbreak;\n\tdefault:\n\t\t{\n\t\t\tint p1 = 2, p2 = 1;\n\t\t\tREP(i, n-3){\n\t\t\t\tans = (p1+p1+p2*3) % 1000000007;\n\t\t\t\tp2 = p1;\n\t\t\t\tp1 = ans;\n\t\t\t}\n\t\t\tcout << (ans*3) % 1000000007 << endl;\n\t\t}\n\t\tbreak;\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7181c2c6e47de339aeff65415f23112b", "src_uid": "77627cc366a22e38da412c3231ac91a8", "difficulty": 1500.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\nlong long int fibonakki(long long int i)\n{\n\n if(i==0||i==1){\n\n return i;\n }\n else{\n\n return fibonakki(i-1)+fibonakki(i-2);\n }\n\n\n}\n\nint main()\n{\n long long int n,b;\n cin>>n;\n long long int count=0;\n for(long long int i=0;i<1000000000;i++){\n if(b==n){\n break;\n }\n b=fibonakki(i);\n\n count++;\n\n\n\n\n\n }\n\n long long int r,t;\n\n r=fibonakki(count-3);\n t=fibonakki(count-2);\n cout<<0<<\" \"<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define FIB(x) (pow((1+sqrt(5))/2,(x))-pow((1-sqrt(5))/2,(x)))/sqrt(5)\n#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )\n#define FIND\nint main()\n{\n int x , i , j , k ;\n bool s =false ;\n cin >> x ;\n vector V(x) ;\n REP(i,x+1) V[i]=FIB(i) ;\n REP(i,x){ REP(j,x) { REP(k,x) if( V[i]+V[j]+V[k] ==x && i!=0 ){ s=true; break; } if(s) break; } if(s) break; }\n if(s) cout << V[i] << \" \" << V[j] << \" \" << V[k] ;\n else cout << \"I'm too stupid to solve this problem\" ;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2487fce1d9045eefb3eabd476c5bf233", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "MS C++", "source_code": "# include \n# include \nusing namespace std;\n\nint f (int n)\n{\n\tif (n<1)\n\t\treturn 0;\n\n\telse if (n==1)\n\t\treturn 1;\n\n\telse\n\t\treturn f(n-2)+f(n-1);\n}\n\nint main ()\n{\n\n\tlong long int n,i;\n\n\tcin >> n;\n\n\tfor (i=0;;i++)\n\t\tif (n==f(i))\n\t\t{\n\t\t\tcout << f(i-4) << \" \"<< f(i-3) << \" \" << f(i-1);\n\t\t\t_getch ();;\n\t\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "914f1b77ba23226639b23fc58dbb3c61", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "MS C++", "source_code": "# include \n# include \nusing namespace std;\n\nint f (int n)\n{\n\tif (n==0)\n\t\treturn 0;\n\n\telse if (n==1)\n\t\treturn 1;\n\n\telse\n\t\treturn f(n-2)+f(n-1);\n}\n\nvoid main ()\n{\n\n\tlong long int n,i;\n\n\tcin >> n;\n\n\tif (n<3)\n\t\tcout << \"I'm too stupid to solve this problem\";\n\n\telse\n\t\tfor (i=4;;i++)\n\t\t\tif (n==f(i))\n\t\t\t{\n\t\t\t\tcout << f(i-4) << \" \"<< f(i-3) << \" \" << f(i-1);\n\t\t\t\t_getch ();\n\t\t\t}\n\t_getch ();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a9d55be614858b9c4c5f762c4d61fcae", "src_uid": "db46a6b0380df047aa34ea6a8f0f93c1", "difficulty": 900.0} {"lang": "MS C++", "source_code": "// ConsoleApplication1.cpp: \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd.\n//\n\n#include \n#include \n#include \nint main()\n{\n\tfloat n, i=1, s=0,k;\n\tscanf(\"%f\", &n);\n\tfor(k=1;k<=n;k++)\n\t{ i=i*k;\n\t\ts=s+pow(k,k);}\n\tprintf(\"%f\", s);\n\tgetch();\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "474c28bbfd32300f5c1ca5d2f45423d6", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3", "difficulty": 1000.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\ninline int abs(int a,int b) { return a > b ? (a-b) : (b-a); }\n\nint main() {\n\t int n,mid;\n\tifstream ifs(\"Input.txt\");\n\tifs >> n;\n\tvector A,B;\n\tfor (int i = 0; i < n; i++) {\n\t\tifs >> mid;\n\t\tA.push_back(mid);\n\t}\n\tfor (int i = 0; i < n; i++) {\n\t\tifs >> mid;\n\t\tB.push_back(mid);\n\t}\n\tint A1 = count(A.begin(), A.end(), 1), B1 = count(B.begin(), B.end(), 1);\n\tint A2 = count(A.begin(), A.end(), 2), B2 = count(B.begin(), B.end(), 2);\n\tint A3 = count(A.begin(), A.end(), 3), B3 = count(B.begin(), B.end(), 3);\n\tint A4 = count(A.begin(), A.end(), 4), B4 = count(B.begin(), B.end(), 4);\n\tint A5 = count(A.begin(), A.end(), 5), B5 = count(B.begin(), B.end(), 5);\n\tint Answer;\n\tif ((A1 + B1) % 2 == 1 || (A2 + B2) % 2 == 1 || (A3 + B3) % 2 == 1 || (A4 + B4) % 2 == 1 || (A5 + B5) % 2 == 1) Answer = -1;\n\telse Answer= (abs(A1, B1) + abs(A2, B2) + abs(A3, B3) + abs(A4, B4) + abs(A5, B5)) / 4;\n\tcout << Answer << endl;\n\tsystem(\"pause\");\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "512ac738e05b3a406c89540cbad34d9c", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3", "difficulty": 1000.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nint answer(int, int, int, int, int, int, int, int, int, int);\ninline int abs(int a,int b) { return a > b ? (a-b) : (b-a); }\n\nint main() {\n\t int n,mid;\n\tifstream ifs(\"Input.txt\");\n\tifs >> n;\n\tvector A,B;\n\tfor (int i = 0; i < n; i++) {\n\t\tifs >> mid;\n\t\tA.push_back(mid);\n\t}\n\tfor (int i = 0; i < n; i++) {\n\t\tifs >> mid;\n\t\tB.push_back(mid);\n\t}\n\tint A1 = count(A.begin(), A.end(), 1), B1 = count(B.begin(), B.end(), 1);\n\tint A2 = count(A.begin(), A.end(), 2), B2 = count(B.begin(), B.end(), 2);\n\tint A3 = count(A.begin(), A.end(), 3), B3 = count(B.begin(), B.end(), 3);\n\tint A4 = count(A.begin(), A.end(), 4), B4 = count(B.begin(), B.end(), 4);\n\tint A5 = count(A.begin(), A.end(), 5), B5 = count(B.begin(), B.end(), 5);\n\tint Answer = answer(A1, A2, A3, A4, A5, B1, B2, B3, B4, B5);\n\tofstream out(\"Output.txt\");\n\tout << Answer;\n\tcout << Answer << endl;\n}\nint answer(int a1, int a2, int a3, int a4, int a5, int b1, int b2, int b3, int b4, int b5) {\n\tint k = a1 + b1;\n\tif ((a1+b1)%2==1||(a2+b2)%2==1||(a3+b3)%2==1||(a4+b4)%2==1||(a5+b5)%2==1) return -1;\n\treturn (abs(a1, b1) + abs(a2, b2) + abs(a3, b3) + abs(a4, b4) + abs(a5, b5)) / 4;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a9e2bba90468c0ffaa1d5f8f0a140324", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3", "difficulty": 1000.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\ninline int abs(int &a, int &b) { return a > b ? (a - b) : (b - a); }\n\nint main() {\n\tifstream ifs(\"Input.txt\");\n\tint n, mid;\n\tifs >> n;\n\tvector A, B;\n\tfor (int i = 0; i < n; i++) {\n\t\tifs >> mid;\n\t\tA.push_back(mid);\n\t}\n\tfor (int i = 0; i < n; i++) {\n\t\tifs >> mid;\n\t\tB.push_back(mid);\n\t}\n\tint A1 = count(A.begin(), A.end(), 1), B1 = count(B.begin(), B.end(), 1);\n\tint A2 = count(A.begin(), A.end(), 2), B2 = count(B.begin(), B.end(), 2);\n\tint A3 = count(A.begin(), A.end(), 3), B3 = count(B.begin(), B.end(), 3);\n\tint A4 = count(A.begin(), A.end(), 4), B4 = count(B.begin(), B.end(), 4);\n\tint A5 = count(A.begin(), A.end(), 5), B5 = count(B.begin(), B.end(), 5);\n\tif ((A1 + B1) % 2 == 1 || (A2 + B2) % 2 == 1 || (A3 + B3) % 2 == 1 || (A4 + B4) % 2 == 1 || (A5 + B5) % 2 == 1) cout << -1<\nusing namespace std;\nstring n;\nlong long ans,a;\nint main(void){\n ios::sync_with_stdio(false);\n cin>>a>>n;\n while(n.find(\"xxx\")!=-1){\n ans++;\n }\n cout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include \nusing namespace std;\n#ifdef LOCAL\n#else\n#define FUNC(name) template void name(T&&...){ }\nFUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);\n#endif\ntemplate \nistream& operator >> (istream& in, vector& v){ for(auto& e : v){ in >> e; } return in; }\n#define f(i,l,n) for(int i = l;i < n;i++)\n#define f0(i,n) f(i,0,n)\n#define pb push_back\n#define pob pop_back\n#define ci cin >>\n#define co cout <<\nint main(){\n int n = 0;\n int k;\n ci k;\n string s;\n ci s;\n for(int i = 0;i < s.size();i++){\n if(s[i] == 'x'){\n int b = 1;\n int l;\n for(int j = i+1;j < s.size();j++){\n if(s[j] == 'x'){\n b++;\n l = j;\n }\n else{\n break;\n }\n }\n if(b >= 3){\n n = b - 2;\n }\n i = l + 1;\n }\n\n }\n co n;\n}\n\n\n\n\n\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3a498a1146f02d76ad57f50b291701c6", "src_uid": "8de14db41d0acee116bd5d8079cb2b02", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n\nint main()\n{\n int n;\n cin>>n;\n string s;\n cin>>s;\n int pos=0;\n int index;\n int ans=0;\n while(index=s.find(\"xxx\",pos)!=string::npos)\n {\n pos=index+1;\n ans++;\n }\n cout<\nusing namespace std;\nint main()\n{\n\n string s;\n int a;\n cin>>a;\n cin>>s;\n\n int extra = 0;\n\n for(int i=0;i\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n//priority_queue < pair > q;\n\nint num[10000][5];\n\nint main() {\n\tint t;\n\tcin >> t;\n\twhile (t--) {\n\t\t//cout << t << endl;\n\t\t//queue < pair > q;\n\t\tint tot = 0;\n\t\tfor (int i = 1; i <= 9; i++) {\n\t\t\tfor (int j = 1; j <= 4; j++) {\n\t\t\t\tint p = 0;\n\t\t\t\tfor (int k = 1; k <= j; k++)\n\t\t\t\t\tp += i * pow(10,k - 1);\n\t\t\t\ttot++;\n\t\t\t\tnum[tot][1] = p,num[tot][2] = j;\n\t\t\t}\n\t\t}\n\t\t/*for (int i = 1; i <= 20; i++) {\n\t\t\tcout << q.top().first << \" \";\n\t\t\tq.pop();\n\t\t}*/\n\t\tint n;\n\t\tcin >> n;\n\t\tint ans = 0,flag = 0;\n\t\tfor (int i = 1; flag == 0; i++) {\n\t\t\tif (num[i][1] != n)\n\t\t\t\tans += num[i][2];\n\t\t\t\t//cout << q.front().first << \" \" << q.front() << endl;\n\t\t\telse {\n\t\t\t\tans += num[i][2];\n\t\t\t\tflag = 1;\n\t\t\t}\n\t\t}\n\t\tcout << ans << endl;\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "de782e152dc33f22b5cdaaf94dc6df86", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include\n#define pb push_back\n#define ins insert\n#define var auto\n#define F first\n#define S second\n#define mp make_pair\nusing namespace std;\ntypedef long long ll;\ntypedef pair pii;\n\nvoid solve() {\n\tint a, b = 1;\n\tcin >> a;\n\twhile (a > 10) {\n\t\ta /= 10;\n\t\tb++;\n\t}\n\tcout << (a * 10) - 10 + (b * (b + 1)) / 2 << '\\n';\n\n}\n\nint main() {\n\tios_base::sync_with_stdio(0);\n\tcin.tie(0);\n\n\tfreopen(\"input.txt\", \"r\", stdin);\n\tfreopen(\"output.txt\", \"w\", stdout);\n\n\n\tint n;\n\tcin >> n;\n\twhile (n--) {\n\t\tsolve();\n\t}\n\n\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "952b87ff27eb3e99e9e38da37a17f875", "src_uid": "289a55128be89bb86a002d218d31b57f", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \"math.h\"\n#include \"assert.h\"\n\nusing namespace std;\n\n#define fast_input ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);\n#define epsilon 1e-07\n#define pi 2 * acos(0.0);\n#define mod 1000000007 // 1e9+7\n\n#define inf std::numeric_limits().max()\n\nusing namespace std;\n\nint main(int argc, const char * argv[]) {\n vector v;\n for(int i=1; i<=10000; i++) {\n v.push_back(to_string(i));\n }\n \n int t;\n cin >> t;\n while (t--) {\n int x;\n cin >> x;\n int ans = 0;\n sort(v.begin(), v.end());\n for(int i=0; i\nusing namespace std;\nlong long int n,len[10900991],res;\n string a[10099001];\nint quan(int m)\n{\tint q;\n\tfor(int i=1;i<=m;i++)\n\tq+=i;\n\treturn q;\n}\nint main()\n{\n\tcin>>n; \n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tcin>>a[i];\n\t\tlen[i]=a[i].length();\n\t\tres=(a[i][0]-'0'-1)*10+quan(len[i]);\n\t\tcout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;/*\nint a[300100] = { 0 }, b[300100] = { 0 };\n\nvoid Qsort(int l, int r)\n{\n\tint i, j, x, y, k;\n\ti = l; j = r;\n\tx = a[(l + r) / 2];\n\tk = b[(l + r) / 2];\n\twhile (i <= j)\n\t{\n\t\twhile (a[i] < x || (a[i] == x && b[i] < k)) i++;\n\t\twhile (x < a[j] || (x == a[j] && k < b[j])) j--;\n\t\tif (!(i>j))\n\t\t{\n\t\t\ty = a[i];\n\t\t\ta[i] = a[j];\n\t\t\ta[j] = y;\n\n\t\t\ty = b[i];\n\t\t\tb[i] = b[j];\n\t\t\tb[j] = y;\n\n\t\t\ti++; j--;\n\t\t}\n\t}\n\tif (l < j) Qsort(l, j);\n\tif (i < r) Qsort(i, r);\n}\n\nint main()\n{\n\tios::sync_with_stdio(false);\n\tint n;\n\tcin >> n;\n\tfor (int i = 1; i <= n; i++)\n\t\tcin >> a[i] >> b[i];\n\tQsort(1, n);\n\n\n\n\tsystem(\"pause\");\n\treturn 0;\n}*/\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint a[666] = { 0 };\nbool mark = false;\nint main()\n{\n\tios::sync_with_stdio(false);\n\tint n;\n\tcin >> n;\n\tfor (int i = 1; i <= n; i++)\n\t{\n\t\tcin >> a[i];\n\t\ta[i] += a[i - 1];\n\t}\n\tfor (int i = 1; i < n; i++)\n\tif (a[i] != 0 && a[i] != a[n])\n\t{\n\t\tcout << \"YES\" << endl << 2 << endl << 1 << ' ' << i << endl << i + 1 << ' ' << n;\n\t\t\t//system(\"pause\");\n\t\treturn 0;\n\t}\n\tfor (int i = 1; i < n - 1; i++)\n\tfor (int j = i + 1; i < n; j++)\n\tif (a[i] != 0 && a[i] != a[j] && a[j] != a[n])\n\t{\n\t\tcout << \"YES\" << endl << 3 << endl << 1 << ' ' << i << endl;\n\t\tcout << i + 1 << ' ' << j << endl;\n\t\tcout << j + 1 << ' ' << n;\n\t\t//system(\"pause\");\n\t\treturn 0;\n\t}\n\tfor (int i = 1; i < n - 2; i++)\n\tfor (int j = i + 1; i < n - 1; j++)\n\tfor (int k = j + 1; k < n; k++)\n\tif (a[i] != 0 && a[i] != a[j] && a[j] != a[k] && a[k] != a[n])\n\t{\n\t\tcout << \"YES\" << endl << 4 << endl << 1 << ' ' << i << endl;\n\t\tcout << i + 1 << ' ' << j << endl;\n\t\tcout << j + 1 << ' ' << k << endl;\n\t\tcout << k + 1 << ' ' << n;\n\t//\tsystem(\"pause\");\n\t\treturn 0;\n\t}\n\tcout << \"NO\";\n\t//\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f48739a08708ba6e26100596fea46969", "src_uid": "3a9258070ff179daf33a4515def9897a", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n\tint n,x=0;\n\tcin>>n;\n\tint a[n];\n\tvector v,u;\n\tfor(int i=0;i>a[i];\n\t\tif(a[i]!=0){\n\t\tx++;\n\t\t}\n\t}\n\tif(x==0){\n\t\tcout<<\"NO\";\n\t\treturn 0;\n\t}\n\tcout<<\"YES\"<=0){\n\t\t\tv[i]--;\n\t\t}\n\t\telse if(u[i]+1\n#define ll long long\n#define ld long double\n#define vll vector\n#define all(x) sort(x.begin(), x.end())\n#define rall(x) sort(x.rbegin(), x.rend())\n#define pb push_back\n#define mp make_pair\n#define ff first\n#define ss second\n#define inf LONG_LONG_MAX\n#define FIO \\\n ios::sync_with_stdio(0); \\\n cin.tie(0); \\\n cout.tie(0);\n//vector.erase( vector.begin() + i, vector.begin() + j ); //remove range of vector\n//std::find(vector.begin(),vector.end(),item)!=vector.end(); //find an element in vector \n\nusing namespace std;\n\nbool sortbysec(const pair &a, const pair &b) {\n return (a.second < b.second);\n}\nint main() \n{\n ll n,m,i,j,k,l;\n cin >> n;\n vll a(n);\n vector> ans;\n ll c=0;\n for(i=0;i> a[i];\n if(a[i]==0)\n {\n c++;\n }\n }\n if(c==n)\n {\n cout << \"NO\";\n return 0;\n }\n ll f=0;\n for(i=0;i0 && i\nusing namespace std;\n\nconst int N=100+5;\nint a[N],s[N];\nint suf[N];\nint n;\n\nvoid Read()\n{\n cin>>n;\n for(int i=1;i<=n;i++)\n\t{\n\t\tcin>>a[i];\n\t\ts[i]=a[i]+s[i-1];\n\t}\n}\n\nbool DFS(int l,int r)\n{\n if(l==r&&a[l]==0)return 0;\n if(s[r]-s[l-1]!=0)return (suf[l]=r)!=0;\n for(int i=l;i\nint main()//#https:codeforces.com/problemset/problem/90/A\n{\n int n=3, p, q, r=30, s=0, k=0, l=0, ab=0;\n int cycle[150], stu[3];\n for(p=0; p<3; p++){\n scanf(\"%d\", &stu[p]);\n if(stu[p]%2==0) stu[p]=stu[p];\n else stu[p]=stu[p]+1;\n }\n for(q=0; stu[0]+stu[1]+stu[2]!=0; q++){\n if(stu[0]!=0){\n stu[0]=stu[0]-2;\n l=l+1;\n if(l>1) r++;\n }\n else if(stu[1]!=0){\n if(stu[0]==0){\n s=s+1;\n if(s>=2) r=r+2;\n }\n else {\n r++;\n stu[1]=stu[1]-1;\n }\n }\n else if(stu[2]!=0){\n if(stu[1]==0 || stu[0]!=0){\n k=k+1;\n for( ;k>=2; ) r=r+2;\n }\n else if(stu[0]==0 && stu[1]==0){\n ab=ab+1;\n for( ;ab>=2; ) r=r+3;\n }\n else {\n r++;\n stu[2]=stu[2]-1;\n }\n }\n }\n printf(\"%d\", r);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ac00b580c50b21623460749a64bebf32", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "/// int hen ame ofg od !! :|\n\n#include \nusing namespace std ;\n#define fi first\n#define se second\n\n\nint main()\n{\n\tios_base::sync_with_stdio ( false ) ;\n\tint a[3] ;\n\tcin >> a[0] >> a[1] >> a[2] ;\n\tint tmp = 0 ;\n\tint ans = 30 ;\n\twhile ( a[0] || a[1] || a[3] ) {\n\t\tif ( tmp % 3 == 0 ) \n\t\t\ta[0] -= min ( a[0] , 2 ) ;\n\t\tif ( tmp % 3 == 1 ) \n\t\t\ta[1] -= min ( a[1] , 2 ) ;\n\t\tif ( tmp % 3 == 2 ) \n\t\t\ta[2] -= min ( a[2] , 2 ) ;\n\t\tcout << a[0] << \" \" << a[1] << \" \" << a[2] << endl ;\n\t\ttmp ++ ;\n\t\tans ++ ;\n\t}\n\tcout << ans-1 << endl ;\n\treturn 0 ;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e66b09832161284fdc6fe326c18a96e3", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\nint main(){\n// __int64 t[3];\n\tint t[3];\n\tfor(int a,b,c;cin>>a>>b>>c; ){\n\t\tt[1]=a;t[2]=b;t[3]=c;//scanf(\"%I64d%I64d%I64d\",&a,&b,&c)\n\t\tint r=1,k=29;\n//\t\t__int64 r=1,k=29;\n\t\tfor(;t[1]>0||t[2]>0||t[3]>0;r++,k++){\n\t\t\tif(r>3)\n\t\t\t\tr=1;\n\t\t\tif(t[r]>0)\n\t\t\t\tt[r]=t[r]-2;\n\t\t}\n// printf(\"%I64d\\n\",k);\n\t\tcout<\n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n\tint r,g,b;\n\tscanf(\"%d%d%d\",&r,&g,&b);\n\tint ans=30+(max(r,max(g,b))/2+max(r,max(g,b))%2-1)*3;\n\tif (r>g){\n\t\tif (r<=b)\n\t\t\tans+=2;\n\t} else\n\t\tif (g<=b)\n\t\t\tans+=2;\n\t\telse\n\t\t\tans+=1;\n\tprintf(\"%d\",ans);\n\tgetch();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "08871b5fca370c99a9c1b6bc48a3268c", "src_uid": "a45daac108076102da54e07e1e2a37d7", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n//#include \n//#include \n\nusing namespace std;\n#define pb push_back\n#define mk make_pair\n#define ll long long\n#define ull unsigned long long\n#define pii pair\n#define fst first\n#define scd second\n#define mid ((l+r)/2)\n#define ALL(A) A.begin(), A.end()\n#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)\n#define repr(i, n) for(int (i)=(int)(n);(i)>=0;(i)--)\n#define repab(i,a,b) for(int (i)=(int)(a);(i)<=(int)(b);(i)++)\n#define reprab(i,a,b) for(int (i)=(int)(a);(i)>=(int)(b);(i)--)\n#define sc(x) scanf(\"%d\", &x)\n#define pr(x) printf(\"x:%d\\n\", x)\n#define fastio ios::sync_with_stdio(0), cin.tie(0)\n#define frein freopen(\"in.txt\", \"r\", stdin)\n#define freout freopen(\"out.txt\", \"w\", stdout)\n#define freout1 freopen(\"out1.txt\", \"w\", stdout)\n#define lson (rt*2+1)\n#define rson (rt*2+2)\n#define lb puts(\"\")\n#define PI M_PI\n#define debug cout<<\"???\"< T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}\n\nconst int maxn = 5e3+100;\n\nint x[10][5];\n\nint main()\n{\n int n; sc(n);\n if(n > 10) return printf(\"0\\n\"), 0;\n for(int i = 0; i < n; i++){\n for(int j = 0; j < 5; j++){\n sc(x[i][j]);\n }\n }\n\n int ok[7];\n memset(ok, 0, sizeof(ok));\n for(int i = 0; i < n; i++){\n for(int j = 0; j < n; j++){\n if(i == j) continue;\n for(int k = 0; k < n; k++){\n if(k == i || k == j) continue;\n ll ans = 0;\n for(int l = 0; l < 5; l++)\n ans += (x[j][l]-x[i][l])*(x[k][l]-x[i][l]);\n if(ans > 0) ok[i] = 1;\n }\n }\n }\n\n int cnt = 0;\n for(int i = 0; i < n; i++){\n if(ok[i] == 0) cnt++;\n }\n cout << cnt <\n#include\n#include\n\nusing namespace std;\n\nlong long int A[100][5];\n\nbool angle(int a,int b,int c)\n{\n\tlong long int sum=0;\n\tfor(int i=0;i<5;i++)\n\t{\n\t\tsum += (A[b][i]-A[a][i])*(A[c][i]-A[a][i]);\n\t}\n\tif(sum > 0)\n\t\treturn 0;\n\telse\n\t\treturn 1;\n}\n\nint main()\n{\n\tint n;\n\tcin>>n;\n\tif(n>=100)\n\t{\n\t\tint a;\n\t\tfor(int i=0;i<5*n;i++)\n\t\t\tscanf(\"%d\",&a);\n\t\tcout<<0;\n\t}\n\tvector ans;\n\tfor(int i=0;i\n#include \n#include \n#include \n\nusing namespace std;\nstruct five\n{\n double a,b,c,d,e;\n};\ndouble skalyar(five &v, five &g)\n{\n return v.a*g.a+v.b*g.b+v.c*g.c+v.d*g.d+v.e*g.e;\n}\ndouble dis(five &v)\n{\n return sqrt(v.a*v.a+v.b*v.b+v.c*v.c+v.d*v.d+v.e*v.e);\n}\nfive get_vec(five &v, five &g)\n{\n five ans;\n ans.a = v.a-g.a;\n ans.b = v.b-g.b;\n ans.c = v.c-g.c;\n ans.d = v.d-g.d;\n ans.e = v.e-g.e;\n return ans;\n}\ndouble arccos(five &v, five &g)\n{\n return skalyar(v,g)/(dis(v)*dis(g));\n}\nint main()\n{\n int n;\n cin >> n;\n vector p(n);\n vector g;\n for(int i = 0; i < n; i++)\n {\n cin >> p[i].a >> p[i].b >> p[i].c >> p[i].d >> p[i].e;\n }\n for(int i = 0; i < n; i++)\n {\n bool flag = true;\n for(int j = 0; j < n; j++)\n {\n for(int k = 0; k < n; k++)\n {\n if(i != j && j != k && k != i)\n {\n five ab = get_vec(p[j],p[i]);\n five ac = get_vec(p[k],p[i]);\n if(arccos(ab,ac) > 0)\n {\n flag = false;\n break;\n }\n }\n }\n }\n if(flag) g.push_back(i+1);\n }\n cout << g.size() << endl;\n if(g.size() == 0) return 0;\n sort(g.begin(),g.end());\n for(int i = 0; i < g.size(); i++)\n cout << g[i] << \" \";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d98928b2367246e35275394dc7a1d432", "src_uid": "c1cfe1f67217afd4c3c30a6327e0add9", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\nconst int maxn = 1010;\n\nint n;\nint ans, out[20], p;\nstruct Vec\n{\n int dir[6];\n};\nstruct Points\n{\n int coor[6];\n vector Vector;\n}input[20];\nint tmp[6];\n\nvoid add(int i, int j, Vec a)\n{\n input[i].Vector.push_back(a);\n for(int i = 0; i < 5; ++ i)\n a.dir[i] = -a.dir[i];\n input[j].Vector.push_back(a);\n}\n\nbool check(int index)\n{\n vector::iterator iter, jter;\n for(iter = input[index].Vector.begin(); iter != input[index].Vector.end(); ++ iter)\n {\n for(jter = iter, ++ jter; jter != input[index].Vector.end(); ++ jter)\n {\n int prod = 0;\n for(int i = 0; i < 5; ++ i)\n prod += iter->dir[i] * jter->dir[i];\n if(prod > 0)return false;\n }\n }\n return true;\n}\n\nint main()\n{\n while(~scanf(\"%d\", &n))\n {\n ans = 0;\n memset(out, 0, sizeof(out));\n p = 0;\n if(n > 10)\n {\n while(n--)\n for(int i = 0; i < 5; ++ i)\n scanf(\"%d\", tmp + i);\n printf(\"0\\n\");\n continue;\n }\n for(int i = 0; i < n; ++ i)\n {\n for(int id = 0; id < 5; ++ id)\n scanf(\"%d\", input[i].coor + id);\n for(int j = 0; j < i; ++ j)\n {\n Vec a;\n for(int k = 0; k < 5; ++ k)\n a.dir[k] = input[j].coor[k] - input[i].coor[k];\n add(i, j, a);\n }\n }\n for(int i = 0; i < n; ++ i)\n if(check(i))\n {\n ++ ans;\n out[p++] = i + 1;\n }\n if(ans)\n {\n printf(\"%d\\n\", ans);\n for(int i = 0; i < p; ++ i)\n printf(\"%d%c\", out[i], \" \\n\"[i==p-1]);\n }\n else printf(\"0\\n\");\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ed5d98071f3331d69d031912b7e04d88", "src_uid": "c1cfe1f67217afd4c3c30a6327e0add9", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include\n\nusing namespace std;\n\nint main()\n{\n int n,m,k=0,i,a[100];\n \n cin>>n>>m;\n k=0;\n a[1]=2;\n a[2]=3;\n a[3]=5;\n a[4]=7;a[5]=11;a[6]=13;a[7]=17;a[8]=19;a[9]=23;a[10]=29;a[11]=31;\n a[12]=37;a[13]=39;a[14]=41;a[15]=43;a[16]=47;\n for(i=1;i<=16;i++)\n if((a[i]==n)&&(a[i+1]==m))\n {\n cout<<\"YES\";i=16;k++;\n } \n if(k==0) cout<<\"NO\";cin>>n;\nreturn 0; \n \n \n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3666ab756cbac0408fcdcfd78347ccdb", "src_uid": "9d52ff51d747bb59aa463b6358258865", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n\nusing namespace std;\n\nint main()\n{\n int n, m;\n bool isprime=true;\n cin>>n>>m;\n if(n==2 && m==3) cout << \"YES\" << endl;\n else if(n==7 && m==11) cout << \"YES\" << endl;\n else if(n==13 && m==17) cout << \"YES\" << endl;\n else if(n==37 && m==41) cout << \"YES\" << endl;\n else if(n==43 && m==47) cout << \"YES\" << endl;\n else if(n==23 && m==29) cout << \"YES\" << endl;\n else if(n==37 && m==41) cout << \"YES\" << endl;\n else if(m%2 == 0) cout << \"NO\" << endl;\n else {\n for(int i=2; i\n#include \n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nchar a[9999999+99];\nusing namespace std;\n\n#define ll long long\n\n#define MAX 20000010\nlong long int prime[MAX];\nlong long int prime_list[MAX];\nlong long int k=1;\n\nvoid sieve()\n{\n long long i,j;\n\n int n=sqrt(20000010);\n for(i=2;i<=n;i++)\n {\n if(prime[i]==0)\n {\n prime_list[k++]=i;\n for(j=i+i;j<=MAX;j=j+i)\n prime[j]=1;\n }\n }\n}\nint main()\n{\n sieve();\n int n,m,p=0;\n\n cin>>n>>m;\n\n for(int i=1;i\n#include \n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nchar a[9999999+99];\nusing namespace std;\n\n#define ll long long\n\n#define MAX 20000010\nlong long int prime[MAX];\nlong long int prime_list[MAX];\nlong long int k=1;\n\nvoid sieve()\n{\n long long i,j;\n\n int n=sqrt(20000010);\n for(i=2;i<=n;i++)\n {\n if(prime[i]==0)\n {\n for(j=i+i;j<=MAX;j=j+i)\n prime[j]=1;\n }\n }\n}\nint main()\n{\n sieve();\n int n,m;\n\n cin>>n>>m;\n if(prime[m]==0)\n cout<< \"YES\"<\nusing namespace std;\ntypedef long long ll;\ntypedef pair pii;\n\nconst int N = 2e5 + 5;\n\nint main() {\n\tint n;\n\tcin >> n;\n\tvector a(n), cnt(n, 0);\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> a[i];\n\t\tcnt[a[i]]++;\n\t}\n\tsort(cnt.begin(), cnt.end());\n\tfor (int i = 0; i <= 100; i++) {\n\t\tif(cnt[i]) {\n\t\t\tif(cnt[i] <= n / 2)\n\t\t\t\treturn cout << \"Alice\\n\", 0;\n\t\t\telse\n\t\t\t\treturn cout << \"Bob\\n\", 0;\n\t\t}\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "003ab5741ed0bd02dad31def63d266a9", "src_uid": "4b9cf82967aa8441e9af3db3101161e9", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#include \n\n#define fi first\n#define se second\n#define MP make_pair\n#define PB push_back\n#define dmp(x) cout << (x) << endl;\n\nusing namespace std;\n\ntypedef unsigned long long ull;\ntypedef long long ll;\ntypedef pair pii;\n\nconst int N = 51;\nconst int mod = 998244353;\nconst int inf = 1e9;\nconst double eps = 1e-16;\n\n\ninline int read()\n{\n int p=0; int f=1; char ch=getchar();\n while(ch<'0' || ch>'9'){if(ch=='-') f*=-1; ch=getchar();}\n while(ch>='0' && ch<='9'){p=p*10+ch-'0'; ch=getchar();}\n return p*f;\n}\n\nstruct node\n{\n int x,y,nex;\n}edge[N*N]; int len,fir[N];\nvoid ins(int x,int y){len++; edge[len].x=x; edge[len].y=y; edge[len].nex = fir[x]; fir[x] = len;}\n\nint n,a[N];\nint x[N],y[N],xlen = 0,ylen = 0; \nbool chw[N]; int match[N];\nbool dfs(int x)\n{\n for(int k=fir[x];k!=-1;k=edge[k].nex)\n {\n int y = edge[k].y;\n if(!chw[y])\n {\n chw[y] = 1;\n if(!match[y] || dfs(match[y])){match[y] = x; return 1;}\n }\n }return 0;\n}\nbool check(int sta)\n{\n xlen = 0; ylen = 0; for(int i=0;i ??1 => ... => ??\nDistance = D: ?? => ??1 => ... => ??\nTime = T; Distance = D: ?? => ??1 => ... => ??\n\n*/\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4cdab5a25f94637fd1e31d6c52ba9262", "src_uid": "4b9cf82967aa8441e9af3db3101161e9", "difficulty": 2000.0} {"lang": "GNU C++17", "source_code": "#include\n#define int long long int\n\n#define f(i,n) for(int i=1;i<=n;i++)\n#define pb push_back\n#define mod 1000000009\nusing namespace std;\n\nint32_t main(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\nint n;cin>>n;\nvectora(n);\nfor(int i=0;i>a[i];\n int r=0;\n while(1){r++;\n sort(a.begin(),a.end());reverse(a.begin(),a.end());\n int c=0;\n for(int i=0;i <. |\n * | |\n * | | \n * | ... \u2312 ... |\n * | |\n * | |\n * |___ __|\n * | |\n * | | Code is far away from bug with the animal protecting\n * | | \u795e\u517d\u4fdd\u4f51\uff0c\u4ee3\u7801\u65e0bug\n * | |\n * | |_____\n * | |\n * | |_\n * | _|\n * | _|\n * |__________________|\n * | | | |\n */\n#pragma comment(linker, \"/STACK:1024000000,1024000000\")\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define mset(a, b) memset(a, b, sizeof(a))\n#define rep(i, a, b) for (int i = a; i <= b; i++)\n#define per(i, a, b) for (int i = a; i >= b; i--)\n#define fg cout << \"--------------\\n\";\n#define debug(x) std::cerr << #x << \" = \" << x << std::endl\n#define All(x) (x.begin()), (x.end())\nusing namespace std;\n\ntypedef double db;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair pii;\ntypedef pair pll;\nconst int inf = 0x3f3f3f3f;\nconst ll INF = 1e18;\n\ntemplate void read(T &x) {\n\tx = 0;\n\tint s = 1, c = getchar();\n\tfor (; !isdigit(c); c = getchar())\n\t\tif (c == '-')\ts = -1;\n\tfor (; isdigit(c); c = getchar())\n\t\tx = x * 10 + c - 48;\n\tx *= s;\n}\n\ntemplate void write(T x) {\n\tif (x < 0)\tx = -x, putchar('-');\n\tif (x > 9)\twrite(x / 10);\n\tputchar(x % 10 + '0');\n}\n\ntemplate void writeln(T x) {\n\twrite(x);\n\tputs(\"\");\n}\n\nint n, a[55];\n\nint main() {\n\tios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);\n\tcin >> n;\n\trep(i, 0, n - 1)\tread(a[i]);\n\tsort(a, a + n);\n\tif (a[0] == a[n - 1])\tputs(\"Bob\");\n\telse\tputs(\"Alice\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d58a76560dd2d0c0fb07094322809070", "src_uid": "4b9cf82967aa8441e9af3db3101161e9", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n string a , b;\n cin >> a >> b;\n int ans = 0;\n int va[a.size()] , vb[a.size()];\n for( int i = 0 ; i < a.size() ; i++ )\n {\n va[i] = 0;\n vb[i] = 0;\n }\n for( int i = 0 ; i < a.size() - 1 ; i++ )\n {\n int f = 0;\n if( a[i] == '0' && va[i] == 0 )\n {\n f++;\n va[i] = 1;\n }\n if( b[i] == '0' && vb[i] == 0 )\n {\n f++;\n vb[i] = 1;\n }\n if( a[i + 1] == '0' && va[i + 1] == 0 )\n {\n f++;\n va[i + 1] = 1;\n }\n if( b[i + 1] == '0' && vb[i + 1] == 0 )\n {\n f++;\n vb[i + 1] = 1;\n }\n if( f >= 3 )\n {\n ans++;\n }\n else\n {\n va[i] = 0;\n vb[i] = 0;\n va[i + 1] = 0;\n vb[i + 1] = 0;\n }\n }\n cout << ans << endl;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2d2f20dad484e69e0b54bf3e32b6b2c6", "src_uid": "e6b3e787919e96fc893a034eae233fc6", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\n\nconst int maxn=1000000+50;\nconst int inf=0x3f3f3f3f;\n\nint main(){\n string s,ss;\n cin>>s;\n cin>>ss;\n int l=s.size();\n if(l<=1){\n \tcout<<0<\n//#include\nusing namespace std;\n#define check(a) cout << a << endl;\n#define cc(a) cout << a << endl;\n#define msg(a,b) cout << a << \" : \" << b << endl;\n#define msg2(a,b,c) cout << a << \" : \" << b << \" : \" << c << endl;\n\nint main(){\n int i,sz,counter =0;\n string str1, str2;\n cin >> str1 >> str2;\n sz =str1.length();\n int arr[sz];\n for(i=0;i\nusing namespace std;\n\ntypedef long long int ll;\ntypedef pair pll;\n\nconst int Max = 2e6 + 10;\nconst int Mod = 1e9 + 7;\nconst ll Inf = 1LL << 62;\n\nstring str[5];\nll dp[102][6][6][102][102], n;\n\n\nll rec( ll idx, ll cur, ll prv, ll pos, ll cnt ) {\n\t//cout << idx << \" \" << n << endl;\n \tif( idx > n ) {\n\t\treturn 0;\n\t}\n\tll &ret = dp[idx][cur][prv][pos][cnt];\n\tif( ~ret ) {\n\t\treturn ret;\n\t}\n\tret = 0;\n\t//cout << idx << \" \" << prv << endl;\n\tif( str[1][idx] == '0' && str[2][idx] == '0' ) {\n\t\tif( idx < n && !( pos != idx - 1 && prv == 2 ) ) {\n\t\t\tif( str[1][idx+1] == '0' ) {\n\t\t\t\tret = max( ret, rec( idx + 1, 1, cur, idx, cnt + 1 ) + 1 );\n\t\t\t}\n\t\t}\n\t\tif( idx < n && !( pos != idx - 1 && prv == 3 ) ) {\n\t\t\tif( str[2][idx+1] == '0' ) {\n\t\t\t\tret = max( ret, rec( idx + 1, 4, cur, idx, cnt + 1 ) + 1 );\n\t\t\t}\n\t\t}\n\t}\n\tif( str[1][idx+1] == '0' && str[2][idx+1] == '0' && idx < n ) {\n\t\tif( !( pos != idx - 1 && prv == 1 ) ) {\n\t\t\tif( str[1][idx] == '0' ) {\n\t\t\t\tret = max( ret, rec( idx + 1, 2, cur, idx, cnt + 1 ) + 1 );\n\t\t\t}\n\t\t}\n\t\tif( !( pos != idx - 1 && prv == 4 ) ) {\n\t\t\tif( str[2][idx] == '0' ) {\n\t\t\t\tret = max( ret, rec( idx + 1, 3, cur, idx, cnt + 1 ) + 1 );\n\t\t\t}\n\t\t}\n\t} ret = max( ret, rec( idx + 1, 0, cur, pos, cnt ) );\n\treturn ret;\n}\n\nint main() {\n#ifdef Mr_Emrul\n\tfreopen(\"inputf.in\", \"r\", stdin);\n#endif ///Mr_Emrul\n\n\t//ios_base::sync_with_stdio(false);\n\t//cin.tie(0);\n\n\tfor( int i=1; i<=2; i++ ) {\n\t\tcin >> str[i];\n\t}\n\tn = str[1].size();\n\tstr[1] = \"#\" + str[1];\n\tstr[2] = \"#\" + str[2];\n\tmemset( dp, -1, sizeof dp );\n\tll ans = rec( 1, 0, 0, 0, 0 );\n\tcout << ans << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b20851b46cd894f02a62d386ba28e988", "src_uid": "e6b3e787919e96fc893a034eae233fc6", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n#define ll long long int\n#define ull unsigned long long int\nll n;\nset a;\nvoid solve(ll ind,ll x)\n{\n if (x==n)\n {\n a.insert(ind);\n return ;\n }\n if (x>n)\n return ;\n solve(ind,x+3);\n solve(ind+1,x+x+3);\n}\nint main()\n{\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\ncin>>n;\nsolve(1,2);\ncout<\nusing namespace std;\n\nlong long modulo=1073741824;\nset s;\nlong long n;\nvoid solve(long long x,long long val,long long counter)\n{\n if(val==0)\n {\n s.insert(counter);\n return ;\n }\n if(x<2 || val<0)\n {\n return ;\n }\n if(x>n)\n {\n solve(x-3,val,counter);\n return ;\n }\n else\n {\n solve(x-3,val-x,counter+1);\n solve(x-3,val,counter);\n }\n\n\n}\n\nint main()\n{\n ios_base::sync_with_stdio(0);\n cin.tie(0),cout.tie(0);\n\n cin>>n;\n solve(((n/3)*3)+2,n,0);\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long i64;\ntypedef unsigned long long ui64;\ntypedef vector vi64;\ntypedef long double ld;\n#define forn(i, n) for(i64 i = 0; i < n; i++)\n#define turn(i, n) for(i64 i = n - 1; i >= 0; i--)\n#define FILESUKA \"sth\"\n#define debug 5\nld PI = 3.141592653589793;\nld eps = 0.000000000000001;\ni64 inf = 1000000000000;\n\nint main()\n{\n i64 n;\n cin >> n;\n vector v;\n int k = 1;\n i64 res = 0;\n while (res < n)\n {\n res = 2 * k + (3 * ((k * (k - 1)) / 2));\n if (res < n)\n v.push_back(res);\n k++;\n }\n //k--;\n int count = 0;\n forn(i, k)\n {\n if (i == 0)\n continue;\n if ((n + i) % 3 == 0)\n count++;\n }\n cout << count;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3530228be88e247114f6037a26ef8f4b", "src_uid": "ab4f9cb3bb0df6389a4128e9ff1207de", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "# include \nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair pll;\ntypedef vector vll;\ntypedef set sll;\n\n#define out1(x)cout<<#x<<\" is \"<>n;\n \n vector< pll > v;\n sll st;\n \n for(i=1;;i++){\n m = 2*i + (i-1);\n if(m > n)\n break;\n \n len = v.size();\n \n for(j = 0; j \n#define lli long long int\n#define endl \"\\n\"\nusing namespace std;\n\nint main()\n{\n\tstring s;\n\tcin>>s;\n\tint counter = 0;\n\tfor(int i=0; i\n#include \"conio.h\"\nusing namespace std;\n\n\nint main()\n{\n\tint n, chs, n1,c =0;\n\tcin >> n;\n\tbool sign = false;\n\tn1 = n;\n\twhile (n1 > 0)\n\t{\n\t\tc++;\n\t\tn1 = n1 / 10;\n\t}\n\tint mass[100] = { 4, 7, 44, 77, 47, 74, 444, 777, 744, 774, 447, 477, 747, 474 };\n\tif (c == 1)\n\t{\n\t\tfor (int i = 0; i < 2; i++)\n\t\t{\n\t\t\tif ((n % mass[i]) == 0) sign = true;\n\t\t}\n\t}\n\tif (c == 2)\n\t{\n\t\tfor (int i = 0; i < 6; i++)\n\t\t{\n\t\t\tif ((n % mass[i]) == 0) sign = true;\n\t\t}\n\t}\n\tif (c >= 3)\n\t{\n\t\tfor (int i = 0; i < 14; i++)\n\t\t{\n\t\t\tif ((n % mass[i]) == 0) sign = true;\n\t\t}\n\t}\n\tif (sign) cout << \"Yes\";\n\telse cout << \"No\";\n\t_getch();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bcfcac66247f0e88bfba8ea426bf0a48", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0} {"lang": "MS C++ 2017", "source_code": "#include \n#include \n\nusing namespace std;\n\nvector get_lucky(int n)\n{\n vector lucky_numbers;\n int m = 7;\n\n lucky_numbers.push_back(4);\n lucky_numbers.push_back(7);\n\n int len = 2;\n\n while (lucky_numbers[len - 1] <= n)\n {\n \n for (int i = 0; i < len; i++)\n {\n lucky_numbers.push_back(lucky_numbers[i] + 10*4);\n lucky_numbers.push_back(lucky_numbers[i] + 10*7);\n }\n len *= 2;\n }\n \n return lucky_numbers;\n}\n\n\nint main()\n{\n int n;\n bool almost_lucky = false;\n\n std::cin >> n;\n \n vector lucky_numbers = get_lucky(n);\n\n for (int i: lucky_numbers)\n {\n if (n % i == 0)\n {\n almost_lucky = true;\n break;\n }\n }\n\n std::cout << (almost_lucky ? \"YES\" : \"NO\") << std::endl;\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a73f3653ccb47b56d9355fb18b18469d", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0} {"lang": "MS C++ 2017", "source_code": "#include \n#include \n\nusing namespace std;\n\nvector get_lucky(int &n)\n{\n vector lucky_numbers;\n int m = 7;\n\n lucky_numbers.push_back(4);\n lucky_numbers.push_back(7);\n\n int len = 2;\n\n while (lucky_numbers[len - 1] <= n)\n {\n \n for (int i = 0; i < len; i++)\n {\n lucky_numbers.push_back(lucky_numbers[i] + 10*4);\n lucky_numbers.push_back(lucky_numbers[i] + 10*7);\n }\n len += 2;\n }\n \n return lucky_numbers;\n}\n\n\nint main()\n{\n int n;\n bool almost_lucky = false;\n\n std::cin >> n;\n \n vector lucky_numbers = get_lucky(n);\n\n for (int i: lucky_numbers)\n {\n if (n % i == 0)\n {\n almost_lucky = true;\n break;\n }\n }\n\n std::cout << (almost_lucky ? \"YES\" : \"NO\") << std::endl;\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2b03f0f66c5abae4be15d72343d767e1", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "/*..\n I can't sleep at night\n'Cause she ain't by my side....*/\n\n #include \n using namespace std;\n //g++ code.cpp -o ./x\n #define ll long long\n #define int long long\n #define pb push_back\n #define For(i,n) for(ll i=0;i=c;a--)\n #define mod 1000000007\n #define int long long\n #define read(t) ll t;cin>>t;\n #define rs(t) string t;cin>>t;\n #define all(x) x.begin(),x.end()\n #define fi first\n #define se second\n #define pii pair\n #define dbg(x) cout<<#x<<\" = \"< 0)\n {\n if (y & 1)res = (res*x)%mo;\n y = y>>1; \n x = (x*x); \n }\n return res%mo;\n}\n/**********************************************************************************************************************/\n\nsigned main()\n{\n fast;\n ll l,r;\n cin>>l>>r;\n if(l==r)\n {\n cout<<0<=0;i--)\n {\n if(l&(1<=0;i--)\n {\n if(bit[i][1]>bit[i][0])\n {\n cout<<(1<<(i+1))-1<\nusing namespace std;\n \n#define ll long long int\n#define rng(i,a,b) for(int i=int(a);i=int(a);i--)\n#define per(i,b) gnr(i,0,b)\n#define pb push_back\n#define eb emplace_back\n#define a first\n#define b second\n#define bg begin()\n#define ed end()\n#define all(x) x.bg,x.ed\n#define si(x) int(x.size())\n#define mp make_pair\n#define mt make_tuple\n#define one(x) memset(x,1,sizeof(x))\n#define zero(x) memset(x,0,sizeof(x))\n#define ri(x) scanf(\"%d\", &x)\n#define rl(x) scanf(\"%llu\", &x)\n#define rc(x) scanf(\"%c\", &x)\n#define rs(x) scanf(\"%s\", x.c_str())\n#define printi(x) printf(\"%d \", x)\n#define printl(x) printf(\"%lld \", x)\n#define prints(x) printf(\"%s\", x)\n#define nl printf(\"\\n\")\n#define VI vector\n#define VL vector\n#define VS vector\n#define VC vector\n#define PII pair\n#define PLL pair\n#define TI tuple\n#define TL tuple\n#define VPII vector\n#define VPLL vector\n#define VTI vector\n#define VTL vector\n\ntemplate void chmax(t&a,u b){if(a void chmin(t&a,u b){if(b L(l), R(r);\n\tstring A = L.to_string();\n\tstring B = R.to_string();\n\tint pos= 0;\n\tdo{\t\t\n\t\t\t++pos;\n\t}\n\twhile(pos <60 && B[pos] == A[pos]);\n\tunsigned long long res = (L.to_ulong() | bin(60 - pos) - 1);\n\tcout < debug & operator <<\n#define eni(x) sim > typename \\\n enable_if(0) x 1, debug&>::type operator<<(c i) {\nsim > struct rge { c b, e; };\nsim > rge range(c i, c j) { return rge{i, j}; }\nsim > auto dud(c* x) -> decltype(cerr << *x, 0);\nsim > char dud(...);\nstruct debug {\n#ifdef LOCAL\n~debug() { cerr << \"\\n\" ; }\neni(!=) cerr << boolalpha << i; ris; }\neni(==) ris << range(begin(i), end(i)); }\nsim, class b dor(pair < b, c > d) {\n ris << \"(\" << d.first << \", \" << d.second << \")\";\n}\nsim dor(rge d) {\n *this << \"[\";\n for (auto it = d.b; it != d.e; ++it)\n *this << \", \" + 2 * (it == d.b) << *it;\n ris << \"]\";\n}\n#else\nsim dor(const c&) { ris; }\n#endif\n};\n#define imie(...) \" [\" << #__VA_ARGS__ \": \" << (__VA_ARGS__) << \"] \"\n//end of weird debugging stuff\ntypedef long long ll;\ntypedef long double ld;\ntypedef vector vi;\ntypedef pair ii;\ntypedef vector vll;\ntypedef vector> vvi;\n#define all(c) (c).begin(), (c).end()\n#define sz(x) (int)(x).size()\n \n#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))\n#define F_OR1(e) F_OR(i, 0, e, 1)\n#define F_OR2(i, e) F_OR(i, 0, e, 1)\n#define F_OR3(i, b, e) F_OR(i, b, e, 1)\n#define F_OR4(i, b, e, s) F_OR(i, b, e, s)\n#define GET5(a, b, c, d, e, ...) e\n#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)\n#define fo(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)\n#define foe(i,x) for(auto& i: x)\n#define ar array\n#define pb push_back\n#define vt vector\n#define F first\n#define S second\n\ntemplate bool umin(T& a,const T& b){return b bool umax(T& a,const T& b){return b>a?a=b,1:0;}\n\ntemplate void read(vt& v);\ntemplate void read(ar& a);\ntemplate void read(T& x) {cin>>x;}\nvoid read(double& d) {string t;read(t);\td=stod(t);}\nvoid read(long double& d) {\tstring t;read(t);d=stold(t);}\ntemplate void read(H& h, T&... t) {read(h);read(t...);}\ntemplate void read(vt& x) {\tfoe(a, x)read(a);}\nint nxt(){int a;read(a);return a;} // iota(all(v),0); genrate(all(v),nxt);\n\n// no change \nconst ll MOD = 1e9+7; \nvoid Titan(){\n\tll l ,r;\n\tread(l,r);\n\tif(l==r){\n\t\tcout << 0;\n\t\treturn;\n\t}\n\tbitset<63> L(l),R(r),ans;\n\tint k;\n\tfor(int i = 62;i>=0;i--){\n\t\tif(L[i]!=R[i]){\n\t\t\tk = i+1;\n\t\t\tbreak;\n\t\t}\n\t}\n\t\n\tint i = 0;\n\twhile(k--){\n\t\tans.set(i++);\n\t}\n\tcout<< ans.to_ulong();\n\t/*ll a;\n\tint k = 63;\n\twhile(k>=0 && ((1<> T;\t\t//cmt if one test case\n fo(T){\n\t\t//cout << \"Case #\" << i+1 << \": \" ;\n\t\tTitan();\n\t}\n}\n/*///////////////////////////////////////////////////////////\nImportant Notes : \n* check long long \n* check base cases\n* do not loose Hope\n* if case fails on 2nd test case maybe some cases are missing check them\n* do not sit idle\n* try to do it using pen/paper.\n*/\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0c963143491c73b73a6d68f10b4c52a3", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0} {"lang": "MS C++", "source_code": "#include \n\nlong long l,r;\nint a[24];\nint b[24];\n\nint main()\n{\n int t1,t2,i;\n long long ans;\n scanf(\"%I64d%I64d\",&l,&r);\n t1=0;\n while (l)\n {\n a[t1]=l&1;\n l>>=1;\n t1++;\n }\n t1--;\n t2=0;\n while (r)\n {\n b[t2]=r&1;\n r>>=1;\n t2++;\n }\n t2--;\n while (t2>=0 && a[t2]==b[t2]) t2--;\n if (t2<0) puts(\"0\");\n else\n {\n t2++;\n ans=1;\n for (i=1;i<=t2;i++)\n ans=ans*2;\n ans--;\n printf(\"%I64d\\n\",ans);\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "717032337e699eb133cdb7823e30b63c", "src_uid": "d90e99d539b16590c17328d79a5921e0", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include \"bits/stdc++.h\"\n\n#define ll long long\n#define ull unsigned long long\n#define ld long double\n\n#define tiii tuple < int, int, int >\n#define pii pair < int, int >\n#define pll pair < ll, ll >\n#define pci pair < char, int >\n#define psi pair < string, int >\n#define pis pair < int, string >\n\n#define vi vector < int >\n#define vd vector < double >\n#define vld vector < ld >\n#define vll vector < ll >\n#define vs vector < string >\n#define vc vector < char >\n#define vpi vector < pii >\n#define vpll vector < pll >\n#define vpis vector < pis >\n\n#define pb push_back\n#define mt make_tuple\n#define gt0 get < 0 >\n#define gt1 get < 1 >\n#define gt2 get < 2 >\n\n#define pi acos(-1)\n\n#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)\n\nusing namespace std;\n\nconst int maxn = 1e5 + 5;\nconst int mod = 1e9 + 7;\n\nint main()\n{\n //freopen(\"input.txt\", \"r\", stdin);\n //freopen(\"output.txt\", \"w\", stdout);\n\n fast;\n\n ll k, a, b, v;\n\n cin >> k >> a >> b >> v;\n\n ll mn = (b, v - 1);\n ll d = (b / mn), r = (b % mn);\n ll tot = (d * (mn + 1) * k) + ((r + 1) * k);\n ll ans = d + r;\n\n if(tot >= a){\n cout << ans << endl;\n return 0;\n }\n\n ll baki = (a - tot);\n ans += (baki / k);\n\n if(baki % k) ans++;\n\n cout << ans << endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5efb588d30e7cbe573b0de781fc5da61", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n\nmain()\n{\n\tfreopen(\"input\", \"r\", stdin);\n\tios::sync_with_stdio(0);\n\tint k, a, b, v;\n\tcin >> k >> a >> b >> v;\n\tint x = (a + v - 1) / v;\n\tint ans = 0;\n\twhile (x > 0)\n\t{\n\t\tint y = min(x, min(b + 1, k));\n\t\tx -= y;\n\t\tb -= y - 1;\n\t\tans ++;\n\t}\n\tcout << ans << \"\\n\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bb6564faf86e225110f9da540e8343b7", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main()\n{\n long long k,a,b,v,i=0,j,l,p;\n\tcin>>k>>a>>b>>v;\n if(b+1>=k)\n\t{\n\t\twhile(a>0)\n\t {\n\t\t a-=k*v;\n\t\t\tb-=k-1;\n\t\t i++;\n\t }\n\t}\n\telse \n\t{\n\t\ta-=(b+1)*v;\n\t\ti++;\n\t\twhile(a>0)\n\t {\n a-=v;\n\t\t i++;\n\t\t}\n\t}\n\tcout<\nusing namespace std;\nint main()\n{\n int a,b,c,ans=0,k,v,i;\n scanf(\"%d%d%d%d\", &k, &a, &b, &v);\n while(b>k-1 && a>=0)\n {\n a-=k*v;\n b-=k-1;\n ans++;\n }\n if(a>0)\n {\n c=b*v+v;\n a-=c;\n ans++;\n }\n if(a>0)\n {\n if(a%v==0)\n ans+=a/v;\n else\n ans+=a/v+1;\n }\n printf(\"%d\\n\", ans);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9b8f8bfed767da0dad58fe2a89dfb91b", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nstruct edge{\n\tshort to,cap,rev;\n\tedge(int _a=0,int _b=0,int _c=0){\n\t\tto=_a;\n\t\tcap=_b;\n\t\trev=_c;\n\t}\n};\nint S,T;\nint dist[10010];\nint cur[10010];\nvector adj[10010];\nint q[10010];\nint hd,tl;\ninline void addedge(int u,int v,int cap){\n\tadj[u].push_back(edge(v,cap,adj[v].size()));\n\tadj[v].push_back(edge(u,0,adj[u].size()-1));\n}\nint dfs(int i,short fl){\n\tif (i==T) return fl;\n\tshort lf=fl;\n\tfor (int &j=cur[i];~j;--j){\n\t\tedge &e=adj[i][j];\n\t\tif (e.cap&&dist[e.to]==dist[i]+1){\n\t\t\tshort d=dfs(e.to,min(lf,e.cap));\n\t\t\te.cap-=d;\n\t\t\tadj[e.to][e.rev].cap+=d;\n\t\t\tlf-=d;\n\t\t\tif (!lf) return fl;\n\t\t}\n\t}\n\tdist[i]=-1;\n\treturn fl-lf;\n}\nint Dinic(){\n\tint res=0;\n\twhile(true){\n\t\tmemset(dist,0,sizeof(dist));\n\t\tdist[q[hd=tl=0]=S]=1;\n\t\twhile(hd<=tl){\n\t\t\tint i=q[hd++];\n\t\t\tcur[i]=adj[i].size()-1;\n\t\t\tfor (int j=cur[i];~j;--j){\n\t\t\t\tedge &e=adj[i][j];\n\t\t\t\tif (e.cap&&!dist[e.to]){\n\t\t\t\t\tdist[e.to]=dist[i]+1;\n\t\t\t\t\tq[++tl]=e.to;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!dist[T]) break;\n\t\tint fl;\n\t\twhile(fl=dfs(S,10000)) res+=fl;\n\t}\n\treturn res;\n}\nint bel[5010];\nint tpe[5010];\nint main(void){\n\tint n,m;\n\tscanf(\"%d%d\",&n,&m);\n\tS=0;\n\tT=n+m+1;\n\tfor (int i=1;i<=n;++i){\n\t\tint a,b,c;\n\t\tscanf(\"%d%d\",&tpe[i],&a);\n\t\tswitch(tpe[i]){\n\t\t\tcase 0:{\n\t\t\t\twhile(a--){\n\t\t\t\t\tscanf(\"%d\",&b);\n\t\t\t\t\taddedge(i,b+n,1);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 1:{\n\t\t\t\tscanf(\"%d\",&b);\n\t\t\t\tfor (int j=a;j<=b;++j){\n\t\t\t\t\taddedge(i,j+n,1);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 2:{\n\t\t\t\tscanf(\"%d%d\",&b,&c);\n\t\t\t\taddedge(i,a+n,1);\n\t\t\t\taddedge(i,b+n,1);\n\t\t\t\taddedge(i,c+n,1);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tfor (int i=1;i<=n;++i){\n\t\tif (tpe[i]!=2){\n\t\t\taddedge(S,i,1);\n\t\t}\n\t}\n\tfor (int i=1;i<=n;++i){\n\t\tif (tpe[i]==2){\n\t\t\taddedge(S,i,2);\n\t\t}\n\t}\n\tfor (int i=1;i<=m;++i){\n\t\taddedge(n+i,T,1);\n\t}\n\tprintf(\"%d\\n\",Dinic());\n\tfor (int i=1;i<=m;++i){\n\t\tfor (int j=adj[i+n].size()-1;~j;--j){\n\t\t\tedge &e=adj[i+n][j];\n\t\t\tif (e.cap&&e.to!=T){\n\t\t\t\tbel[i]=e.to;\n\t\t\t}\n\t\t}\n\t}\n\tfor (int i=1;i<=m;++i){\n\t\tif (bel[i]) printf(\"%d %d\\n\",bel[i],i);\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c1ca7f2e8cefeff2a19f741f6308b4d4", "src_uid": "429a94c8e3f28100c8c532e948cc36e3", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "#include\n#define N 100005\n#define inf 0x3f3f3f3f \n#define lc (p<<1)\n#define rc (p<<1|1)\n#define mid (l+r>>1)\nusing namespace std;\ninline int read(){\n\tint ans=0;\n\tchar ch=getchar();\n\twhile(!isdigit(ch))ch=getchar();\n\twhile(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();\n\treturn ans;\n}\nchar xxx;\nbool vis[N];\nint n,m,id[N],tot,Begin,ans;\nstruct edge{int v,c,next;};\nmapmp[N];\nint d[N],first[N],cnt,s,t;\nedge e[N];\ninline void add(int u,int v,int c){\n\te[++cnt].v=v,e[cnt].c=c,e[cnt].next=first[u],first[u]=cnt;\n\te[++cnt].v=u,e[cnt].c=0,e[cnt].next=first[v],first[v]=cnt;\n}\ninline bool bfs(){\n\tqueueq;\n\tfill(d+1,d+t+1,-1),q.push(s),d[s]=0;\n\twhile(!q.empty()){\n\t\tint x=q.front();\n\t\tq.pop();\n\t\t\tfor(int i=first[x];i;i=e[i].next){\n\t\t\tint v=e[i].v;\n\t\t\tif(!e[i].c||~d[v])continue;\n\t\t\td[v]=d[x]+1,q.push(v);\n\t\t\t\tif(v==t)return true;\n\t\t}\n\t}\n\treturn false;\n}\ninline int dfs(int p,int f){\n\t\tif(!f||p==t)return f;\n\tint flow=f;\n\tfor(int i=first[p];i;i=e[i].next){\n\t\tint v=e[i].v;\n\t\tif(!flow)break;\n\t\t\tif(!e[i].c||d[v]!=d[p]+1)continue;\n\t\tint tmp=dfs(v,min(flow,e[i].c));\n\t\tif(!tmp)d[v]=-1;\n\t\te[i].c-=tmp,e[i^1].c+=tmp,flow-=tmp;\n\t}\n\treturn d[p]=-1,f-flow;\n}\ninline void solve(){while(bfs())ans+=dfs(s,inf);}\ninline void build(int p,int l,int r){\n\tid[p]=++tot;\n\tif(l==r){add(id[p],l,1);return;}\n\tbuild(lc,l,mid),build(rc,mid+1,r);\n\tadd(id[p],id[lc],inf),add(id[p],id[rc],inf);\n}\ninline void update(int p,int l,int r,int ql,int qr){\n\tif(ql>r||qrmid)update(rc,mid+1,r,ql,qr);\n\telse update(lc,l,mid,ql,mid),update(rc,mid+1,r,mid+1,qr);\n}\ninline int query(int p){\n\tif(p>=Begin){return p-Begin+1;}\n\tmap::iterator it=mp[p].begin();\n\tint ret=query(it->first);\n\t--it->second;\n\tif(!it->second)mp[p].erase(it);\n\treturn ret;\n}\nint main(){\n\tn=read(),tot=m=read(),cnt=1,s=++tot,build(1,1,m),Begin=tot+1;\n\tfor(int i=1;i<=n;++i){\n\t\tint op=read();\n\t\t++tot;\n\t\tif(op==0){\n\t\t\tint k=read();\n\t\t\twhile(k--){\n\t\t\t\tint x=read();\n\t\t\t\tadd(tot,x,1);\n\t\t\t}\n\t\t\tadd(s,tot,1);\n\t\t}\n\t\telse if(op==1){\n\t\t\tint ql=read(),qr=read();\n\t\t\tupdate(1,1,m,ql,qr),add(s,tot,1);\n\t\t}\n\t\telse{\n\t\t\tint a=read(),b=read(),c=read();\n\t\t\tvis[a]=vis[b]=1,ans+=2;\n\t\t\tadd(tot,a,0),e[cnt].c=1,add(tot,b,0),e[cnt].c=1,add(tot,c,1);\n\t\t}\n\t}\n\tt=++tot;\n\tfor(int i=1;i<=m;++i)if(!vis[i])add(i,t,1);\n\tsolve();\n\tprintf(\"%d\\n\",ans);\n\tfor(int i=1;i<=tot;++i)for(int j=first[i];j;j=e[j].next)if((j&1)&&e[j].c)mp[i][e[j].v]=1; \n\tfor(int i=1;i<=m;++i){\n\t\tbool f=true;\n\t\tfor(int j=first[i];j&&f;j=e[j].next)if(e[j].v==t&&e[j].c)f=false;\n\t\tif(f)printf(\"%d %d\\n\",query(i),i);\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f0111a8c19470784d0e57d089078dc3c", "src_uid": "429a94c8e3f28100c8c532e948cc36e3", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "//#define _GLIBCXX_DEBUG\n/*\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,fma\")\n#pragma GCC optimize(\"unroll-loops\")\n*/\n/*\n\u3000\u3000\u3000\u3000\u3000\uff0f\uff1e\u3000 \u30d5\n\u3000\u3000\u3000\u3000\u3000| \u3000_\u3000 _|\n\u3000 \u3000\u3000\u3000\uff0f`\u30df _x \u5f61 \u041a\u0410\u041a \u0416\u0415 \u041c\u041d\u0415 \u041d\u0410\u0414\u041e\u0415\u041b\u0410 \u042d\u0422\u0410 \u041f\u0420\u041e\u0413\u0410 \u0422\u0423\u041f\u0410\u042f \u0413\u041e\u0421\u041f\u041e\u0414\u0418\n\u3000\u3000 \u3000 /\u3000\u3000\u3000 \u3000 |\n\u3000\u3000\u3000 /\u3000 \u30fd\u3000\u3000 \uff89\n\u3000\uff0f\uffe3|\u3000\u3000 |\u3000|\u3000|\n\u3000| (\uffe3\u30fd\uff3f_\u30fd_)_)\n\u3000\uff3c\u4e8c\u3064\n */\n\n#include \n#include \nusing namespace std;\nusing namespace __gnu_cxx;\n#define ll long long\n#define fi first\n#define se second\nmt19937 gen(time(0));\nbool IS_ONE_TEST = 1;\nstruct edge {\n ll v, flow, cap, link, idx;\n edge(ll v, ll flow, ll cap, ll link, ll idx):\n v(v), flow(flow), cap(cap), link(link), idx(idx){};\n edge(){};\n};\nvector> g;\nvector mark;\nvoid make_edge(int v, int u, ll w1, ll w2, int idx) {\n g[v].emplace_back(u, 0, w1, g[u].size(), idx);\n g[u].emplace_back(v, 0, w2, g[v].size() - 1, -1);\n}\nll dfs(int v, ll cur_flow, int step, int term) {\n if (v == term) return cur_flow;\n if (mark[v] == step) return 0;\n mark[v] = step;\n for (auto &e : g[v]) {\n if (mark[e.v] != step && e.flow < e.cap) {\n ll res = dfs(e.v, min(cur_flow, e.cap - e.flow), step, term);\n if (res == 0) continue;\n e.flow += res;\n g[e.v][e.link].flow -= res;\n return res;\n }\n }\n return 0;\n}\nll max_flow(ll s, ll t) {\n ll flow = 0;\n int step = 1;\n while (true) {\n ll res = dfs(s, 1e9, step++, t);\n if (!res) break;\n flow += res;\n }\n return flow;\n}\nvoid remove_flow(int v) {\n for (auto &e : g[v]) {\n if (e.idx != -1) continue;\n if (e.flow == e.cap) continue;\n e.flow += 1;\n g[e.v][e.link].flow -= 1;\n remove_flow(e.v);\n return;\n }\n}\nvoid solve() {\n int n, m;\n cin >> n >> m;\n g.resize(n + m + 2);\n mark.assign(n + m + 2, -1);\n vector OMG(n);\n vector is_used(m);\n for (int i = 0; i < n; ++i) {\n int t, k, l, r;\n cin >> t;\n if (t == 0) {\n make_edge(n + m, i, 1, 0, n + m);\n cin >> k;\n for (int j = 0; j < k; ++j) {\n cin >> l;\n make_edge(i, l - 1 + n, 1, 0, i);\n }\n }\n else if (t == 1) {\n make_edge(n + m, i, 1, 0, n + m);\n cin >> l >> r;\n for (int j = l - 1; j <= r - 1; ++j) {\n make_edge(i, j + n, 1, 0, i);\n }\n }\n else {\n cin >> k >> l >> r;\n OMG[i] = 1;\n make_edge(n + m, i, 2, 0, n + m);\n make_edge(i, k - 1 + n, 1, 0, i);\n make_edge(i, l - 1 + n, 1, 0, i);\n make_edge(i, r - 1 + n, 1, 0, i);\n }\n }\n for (int i = n; i < n + m; ++i) make_edge(i, n + m + 1, 1, 0, n + m + 1);\n ll res = max_flow(n + m, n + m + 1);\n for (int i = 0; i < n; ++i) {\n if (OMG[i]) {\n int cur_flow = 0;\n for (auto &e : g[i]) {\n if (e.idx != -1) {\n cur_flow += e.flow;\n }\n }\n //cout << i << \" : \" << cur_flow << endl;\n for (auto &e : g[i]) {\n if (cur_flow == 2 || e.idx == -1 || e.flow == e.cap) continue;\n remove_flow(e.v);\n e.flow += 1;\n g[e.v][e.link].flow -= 1;\n ++cur_flow;\n }\n }\n }\n cout << res << endl;\n for (int i = n; i < n + m; ++i) {\n for (auto &e : g[i]) {\n if (e.idx != -1 || e.flow == 0) continue;\n cout << e.v + 1 << \" \" << i - n + 1 << endl;\n break;\n //cout << e.v << \" -> \" << i << \" with \" << e.flow << endl;\n }\n }\n}\nint main() {\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n cout.tie(NULL);\n cout << fixed << setprecision(15);\n ll t;\n if (IS_ONE_TEST)\n t = 1;\n else\n cin >> t;\n while (t-->0) {\n solve();\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "038e1e38a7e557cc8df6289a777ebfc6", "src_uid": "429a94c8e3f28100c8c532e948cc36e3", "difficulty": 2500.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n//#pragma GCC optimize(\"Ofast\")\n//#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n\n#define ms(s, n) memset(s, n, sizeof(s))\n#define FOR(i, a, b) for (int i = (a); i < (b); ++i)\n#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); --i)\n#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)\n#define sz(a) int((a).size())\n#define present(t, x) (t.find(x) != t.end())\n#define all(a) (a).begin(), (a).end()\n#define uni(a) (a).erase(unique(all(a)), (a).end())\n#define pb push_back\n#define pf push_front\n#define mp make_pair\n#define fi first\n#define se second\n#define prec(n) fixed<> (i)) & 1)\n#define bitcount(n) __builtin_popcountll(n)\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef pair pi;\ntypedef vector vi;\ntypedef vector vii;\nconst int MOD = (int) 1e9 + 7;\nconst int FFTMOD = 119 << 23 | 1;\nconst int INF = (int) 1e9 + 23111992;\nconst ll LINF = (ll) 1e18 + 23111992;\nconst ld PI = acos((ld) -1);\nconst ld EPS = 1e-9;\ninline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}\ninline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}\ninline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}\ntemplate inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}\ntemplate inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}\ninline ull isqrt(ull k) {ull r = sqrt(k) + 1; while (r * r > k) r--; return r;}\ninline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}\ninline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}\ninline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}\ninline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}\ninline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}\ninline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}\ninline int sign(ld x, ld y) {return sign(x - y);}\nmt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());\ninline int myrand() {return abs((int) mt());}\n#define db(x) cerr << #x << \" = \" << (x) << \" \";\n#define endln cerr << \"\\n\";\n\n#define MF Maxflow\n#define flow_t int\nconst flow_t foo = (flow_t) 1e9;\nnamespace Maxflow {\n const int maxv = 1e5 + 5;\n const int maxe = 3e7 + 5;\n int n, s, t, E;\n int adj[maxe], nxt[maxe], lst[maxv], ptr[maxv], lev[maxv], que[maxv];\n flow_t flw[maxe], cap[maxe];\n void init(int nn, int ss, int tt) {\n n = nn, s = ss, t = tt, E = 0;\n fill_n(lst, n, -1);\n }\n int add(int u, int v, flow_t c1, flow_t c2) {\n adj[E] = v, flw[E] = 0, cap[E] = c1, nxt[E] = lst[u], lst[u] = E++;\n adj[E] = u, flw[E] = 0, cap[E] = c2, nxt[E] = lst[v], lst[v] = E++;\n return E - 2;\n }\n int bfs() {\n fill_n(lev, n, 0), lev[s] = 1;\n int qsize = 0;\n que[qsize++] = s;\n for (int i = 0; i < qsize; i++) {\n for (int u = que[i], e = lst[u]; ~e; e = nxt[e]) {\n int v = adj[e];\n if (flw[e] < cap[e] && !lev[v]) {\n lev[v] = lev[u] + 1;\n que[qsize++] = v;\n }\n }\n }\n return lev[t];\n }\n flow_t dfs(int u, flow_t bot) {\n if (u == t) return bot;\n for (int& e = ptr[u]; ~e; e = nxt[e]) {\n int v = adj[e];\n flow_t delta = 0;\n if (lev[v] == lev[u] + 1 && flw[e] < cap[e] && (delta = dfs(v, min(bot, cap[e] - flw[e]))) > 0) {\n flw[e] += delta; flw[e ^ 1] -= delta;\n return delta;\n }\n }\n return 0;\n }\n flow_t maxflow(int ss = -1, int tt = -1) {\n if (~ss) s = ss;\n if (~tt) t = tt;\n fill_n(flw, E, 0);\n flow_t total = 0;\n while (bfs()) {\n for (int i = 0; i < n; i++) ptr[i] = lst[i];\n for (flow_t delta = dfs(s, foo); delta > 0; delta = dfs(s, foo)) total += delta;\n }\n return total;\n }\n vector, flow_t> > gomory_hu() {\n vector, flow_t> > tree;\n vector p(n);\n for (int u = 1; u < n; u++) {\n tree.push_back(make_pair(make_pair(p[u], u), maxflow(u, p[u])));\n for (int v = u + 1; v < n; ++v) {\n if (lev[v] && p[v] == p[u]) {\n p[v] = u;\n }\n }\n }\n return tree;\n }\n}\n\nvoid chemthan() {\n int n, m; cin >> n >> m;\n int tot = n + m, s = tot++, t = tot++;\n MF::init(tot, s, t);\n static int id[5005][5005];\n ms(id, -1);\n static int tp[5005];\n static vi g[5005];\n FOR(i, 0, n) {\n int t; cin >> t;\n tp[i] = t;\n if (t == 0) {\n MF::add(s, i, 1, 0);\n int k; cin >> k;\n while (k--) {\n int u; cin >> u; u--;\n id[i][u] = MF::add(i, n + u, 1, 0);\n }\n }\n else if (t == 1) {\n MF::add(s, i, 1, 0);\n int l, r; cin >> l >> r; l--, r--;\n FOR(j, l, r + 1) {\n id[i][j] = MF::add(i, n + j, 1, 0);\n }\n }\n else if (t == 2) {\n MF::add(s, i, 2, 0);\n int a, b, c; cin >> a >> b >> c; a--, b--, c--;\n id[i][a] = MF::add(i, n + a, 1, 0);\n id[i][b] = MF::add(i, n + b, 1, 0);\n id[i][c] = MF::add(i, n + c, 1, 0);\n g[i].pb(a);\n g[i].pb(b);\n g[i].pb(c);\n }\n }\n FOR(i, 0, m) MF::add(n + i, t, 1, 0);\n cout << MF::maxflow() << \"\\n\";\n static int to[5005];\n static int from[5005];\n ms(to, -1), ms(from, -1);\n FOR(i, 0, n) {\n if (tp[i] == 2) {\n vi vals;\n map used;\n FOR(j, 0, m) {\n if (MF::flw[id[i][j]] > 0) {\n vals.pb(j);\n used[j] = 1;\n }\n }\n if (sz(vals) && sz(vals) < 2) {\n for (int u : g[i]) {\n if (!used[u]) {\n from[u] = 0;\n vals.pb(u);\n break;\n }\n }\n }\n for (int u : vals) {\n cout << i + 1 << \" \" << u + 1 << \"\\n\";\n }\n }\n }\n FOR(i, 0, n) {\n if (tp[i] != 2) {\n FOR(j, 0, m) {\n if (MF::flw[id[i][j]] > 0) {\n if (from[j] == -1) {\n cout << i + 1 << \" \" << j + 1 << \"\\n\";\n }\n }\n }\n }\n }\n}\n\nint main(int argc, char* argv[]) {\n ios_base::sync_with_stdio(0), cin.tie(0);\n if (argc > 1) {\n assert(freopen(argv[1], \"r\", stdin));\n }\n if (argc > 2) {\n assert(freopen(argv[2], \"wb\", stdout));\n }\n chemthan();\n cerr << \"\\nTime elapsed: \" << 1000 * clock() / CLOCKS_PER_SEC << \"ms\\n\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "922fd5f7708f3f6e54b122f6b62d53f8", "src_uid": "429a94c8e3f28100c8c532e948cc36e3", "difficulty": 2500.0} {"lang": "GNU C++11", "source_code": "#include \nint main(){\n for(int i=21;i<=50;++i,puts(\"\"))\n std::cout<<((std::min(i,25)+i)%((i%3))>-2);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fb92f67d36f5e500dc66ddbd0187c0e1", "src_uid": "4bda04e64ff661336a93464563f1b550", "difficulty": null} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n\tfor(int i=21;i<=50;i++)\n\t\tscanf(\"%lld\",((min(i,25)+i)%(2+i%3)>0)?1:0);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "90500f6a5e23d205b0a68f22994ca5e0", "src_uid": "4bda04e64ff661336a93464563f1b550", "difficulty": null} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint main()\n{\n\tfor(int i=21;i<=50;i++)\n\t\tscanf(\"%lld\",((min(i,25)+i)%(2+i%3)>0));\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f34e1ba84453fd3e745087e54ff897d4", "src_uid": "4bda04e64ff661336a93464563f1b550", "difficulty": null} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nint main()\n{\n\tfor(int k=21;k=50;k++)\n\t{\n\t\tcout<<(((min(k,25)+k)%(2+k%3)>0)?1:0)<\n#include \n#include \n#include \n#include \n\nusing namespace std;\nint main()\n{\n int n,k,free=0,foll=0,res=0,temple=0,unic=0,ununic=0;\n cin>>n>>k;\n n=8*n;\n int x=n/2,y=n/2;\n int *arr=new int[k];\n int x1=0,x2=0,x3=0,x0=0;\n for(int i=0;i>arr[i];\n res=res+arr[i];\n if(arr[i]%2==0)\n {\n x0=x0+arr[i]/4;\n x2=x2+arr[i]%4;\n }\n if(arr[i]%4==1)\n {\n x1++;\n }\n if(arr[i]%4==1||arr[i]%4==3&&arr[i]!=1)\n {\n ununic++;\n }\n if(arr[i]==1)\n {\n unic++;\n }\n if(arr[i]%4==3)\n {\n x3++;\n }\n if(arr[i]==1)\n {\n free=free+1;\n }\n }\n if(abs(y-x2)!=0)\n {\n if(abs(y-x2)%4!=0&&y>x2)\n {\n foll=foll+1;\n }\n }\n if(x3+x1>0)\n {\n\n\n foll=foll+x3+x1-1;\n\n\n }\nif(y());\nif(unic>0&&y\n#include \n#include \n#include \n#include \n\nusing namespace std;\nint main()\n{\n int n,k,free=0,foll=0,res=0,temple=0;\n cin>>n>>k;\n n=8*n;\n int x=n/2,y=n/2;\n int *arr=new int[k];\n int x1=0,x2=0,x3=0,x0=0;\n for(int i=0;i>arr[i];\n res=res+arr[i];\n if(arr[i]%2==0)\n {\n x0=x0+arr[i]/4;\n x2=x2+arr[i]%4;\n }\n if(arr[i]%4==1)\n {\n x1++;\n }\n if(arr[i]%4==3)\n {\n x3++;\n }\n }\n if(abs(y-x2)!=0)\n {\n if(abs(y-x2)%4!=0&&y>x2)\n {\n foll=foll+1;\n }\n }\n if(x3+x1>0)\n {\n foll=foll+x3+x1-1;\n }\nif(y());\n\nif(res+foll<=n)\n{\n cout<<\"Yes\";\n}\nelse\n{\n cout<<\"No\";\n}\n//cout<\n#include \n#include \nusing namespace std;\nint main()\n{\n int k,n,i,free=0;\n cin>>n;\n cin>>k;\n n=8*n;\n int x=n/2,y=n/2;\nint *ar=new int[k];\nfor(i=0;i>ar[i];\n}\nfor(i=0;i0)\n {\n if(ar[i]%2==0)\n {\n x=x-ar[i];\n }\n if(ar[i]%2==1)\n {\n x=x-ar[i]-1;\n }\n }\n else\n {\n if(ar[i]%4==0)\n {\n y=y-ar[i];\n }\n if(ar[i]%4==1)\n {\n y=y-ar[i]-1;\n }\n if(ar[i]%4==2)\n {\n y=y-ar[i]-1;\n\n }\n if(ar[i]%4==3)\n {\n y=y-ar[i]-1;\n\n\n }\n }\n\n}\nif(y0)\n{\n cout<<\"Yes\";\n}\nelse\n{\n cout<<\"No\";\n}\ncout<\nusing namespace std;\n\nint main() {\n\tint n,k;\n\tint arr1[k];\n\tcin>>n>>k;\n\tfor(int i=0;i>arr1[i];\n\tint to=n*8;\n\tfor(int i=0;i0)\n\t\t{\n\t\t\tif(arr1[i]%8==0)\n\t\t{\n\t\t\tto-=8;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tint c=arr1[i]%4;\n\t\t\tif(c==3 || c==0)\n\t\t\t{\n\t\t\t\tto-=4;\n\t\t\t\tif(c==0)\n\t\t\tarr1[i]-=4;\n\t\t\t\telse\n\t\t\t\t\tarr1[i]-=3;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tto-=2;\n\t\t\t\tarr1[i]-=c;\n\n\n\t\t\t}\n\t\t\t//cout<<\"c\"<=0)\n\t\tcout<<\"YES\";\n\telse\n\t\tcout<<\"NO\";\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b9e8570d7c1d9543285902d67bacb864", "src_uid": "d1f88a97714d6c13309c88fcf7d86821", "difficulty": 1900.0} {"lang": "MS C++", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n unsigned int w, h, u1, d1, u2, d2;\n cin >> w >> h;\n cin >> u1 >> d1;\n cin >> u2 >> d2;\n while(h>0)\n {\n w+=h;\n if (h==d1) w-=u1;\n else if (h==d2) w-=u2;\n if (w < 0) w = 0;\n h--;\n }\n cout << w;\n return 1;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7860b09c216ba9ff1f3ae08c127b504c", "src_uid": "084a12eb3a708b43b880734f3ee51374", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\ntypedef long long int ll;\nint arr[1000005];\nll pow_mod(ll a, ll b, ll M)\n{ ll ans = 1LL;\n while (b > 0) {\n if ( b%2 == 1) {\n ans=(ans * a)% M;\n }\n a = (a * a)%M;\n b = b / 2;\n }\n return ans;\n}\nvoid sieve(int n)\n{\n int i, p;\n for(i = 0;i <= n; i++)\n arr[i] = i;\n for(p = 2;p <= n; p++)\n {\n if(arr[p] == p)\n {\n for(i = p;i<= n;i += p)\n {\n arr[i] = p;\n }\n }\n }\n\n}\nint main()\n{\n #ifdef ONLINE_JUDGE\n // Assume input.txt and output.txt suitably exists\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n #endif\n\n ios_base::sync_with_stdio(false);\n ll i,w,h,u1,u2,d1,d2,dm,dmn;\n //long long int pre[100001]={0};\n \n cin>>w>>h;\n cin>>u1>>d1;\n cin>>u2>>d2;\n\n dm = max( d1, d2);\n //w += ( pre[h] - pre[dm-1] );\n (dm == d1) ? w -= u1 : w -= u2;\n if(w < 0) w = 0;\n\n dmn = min(d1,d2);\n //w += (pre[dm-1] - pre[dmn-1]);\n (dmn == d1) ? w -= u1 : w -= u2;\n if(w < 0) w = 0;\n\n //w += (pre[dmn - 1]);\n cout<\n\nusing namespace std;\n\n int sum(int a)\n { int S=0;\n for (int r=0; r> w[k];\n cin >> h[k];\n}\n for(int j=0;j<1;j++){\n int temph = h[j+1];\n int tempw = w[j+1];\n if (h[j+1]\nusing namespace std;\ntypedef long long int ll;\nint arr[1000005];\nll pow_mod(ll a, ll b, ll M)\n{ ll ans = 1LL;\n while (b > 0) {\n if ( b%2 == 1) {\n ans=(ans * a)% M;\n }\n a = (a * a)%M;\n b = b / 2;\n }\n return ans;\n}\nvoid sieve(int n)\n{\n int i, p;\n for(i = 0;i <= n; i++)\n arr[i] = i;\n for(p = 2;p <= n; p++)\n {\n if(arr[p] == p)\n {\n for(i = p;i<= n;i += p)\n {\n arr[i] = p;\n }\n }\n }\n\n}\nint main()\n{\n #ifdef ONLINE_JUDGE\n // Assume input.txt and output.txt suitably exists\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n #endif\n\n ios_base::sync_with_stdio(false);\n ll i,w,h,u1,u2,d1,d2,dm,dmn,pre[100001]={0};\n for(i=1;i<100001;i++)\n {\n //pre[i] += (pre[i - 1] + i);\n }\n cin>>w>>h;\n cin>>u1>>d1;\n cin>>u2>>d2;\n\n dm = max( d1, d2);\n cout< // This will work only for g++ compiler. \n\n\n#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing\n#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing\n#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive\n#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.\n#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based\n\n//short hand for usual tokens\n#define pb push_back\n#define fi first\n#define se second\n\n// to be used with algorithms that processes a container Eg: find(all(c),42)\n#define all(x) (x).begin(), (x).end() //Forward traversal\n#define rall(x) (x).rbegin, (x).rend() //reverse traversal\n\n// traversal function to avoid long template definition. Now with C++11 auto alleviates the pain.\n#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)\n\n// find if a given value is present in a container. Container version. Runs in log(n) for set and map\n#define present(c,x) ((c).find(x) != (c).end())\n\n//find version works for all containers. This is present in std namespace.\n#define cpresent(c,x) (find(all(c),x) != (c).end())\n\n// Avoiding wrap around of size()-1 where size is a unsigned int.\n#define sz(a) int((a).size())\n#define INF 0x3f3f3f3f\n\nusing namespace std;\n\n// Shorthand for commonly used types\ntypedef vector vi;\ntypedef vector vvi;\ntypedef pair ii;\ntypedef vector vii;\ntypedef long long ll;\ntypedef vector vll;\ntypedef vector vvll;\ntypedef double ld;\n \n\nint main() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout.precision(10);\n cout << fixed;\n int n;\n\tcin>>n;\n\tvectorisprime(n+1 , true);\n\tvector primes;\n\tisprime[0] = isprime[1] = false;\n\tisprime[2] = true;\n\tprimes.pb(2);\n\tfor(int i =3;i*i <= n;i+2)\n\t{\n\t\tif(isprime[i])\n\t\t{\n primes.pb(i);\n\t\t\tfor(int j = i*i ; j*j<=n;j+=i)\n\t\t\t{\n\t\t\t\tisprime[j] = false;\n\t\t\t}\n\t\t}\n\t}\n\tint count = 0;\n\tfor(int q : primes)\n\t{\n\t\tif(primes[0]*primes[q-1] == n)\n\t\t{\n\t\t\tcount++;\n\t\t}\n\t}\n\tcout<\nusing namespace std;\nint ans=0,x[30001][4301],zs[4301]={0,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,1013,1019,1021,1031,1033,1039,1049,1051,1061,1063,1069,1087,1091,1093,1097,1103,1109,1117,1123,1129,1151,1153,1163,1171,1181,1187,1193,1201,1213,1217,1223,1229,1231,1237,1249,1259,1277,1279,1283,1289,1291,1297,1301,1303,1307,1319,1321,1327,1361,1367,1373,1381,1399,1409,1423,1427,1429,1433,1439,1447,1451,1453,1459,1471,1481,1483,1487,1489,1493,1499,1511,1523,1531,1543,1549,1553,1559,1567,1571,1579,1583,1597,1601,1607,1609,1613,1619,1621,1627,1637,1657,1663,1667,1669,1693,1697,1699,1709,1721,1723,1733,1741,1747,1753,1759,1777,1783,1787,1789,1801,1811,1823,1831,1847,1861,1867,1871,1873,1877,1879,1889,1901,1907,1913,1931,1933,1949,1951,1973,1979,1987,1993,1997,1999,2003,2011,2017,2027,2029,2039,2053,2063,2069,2081,2083,2087,2089,2099,2111,2113,2129,2131,2137,2141,2143,2153,2161,2179,2203,2207,2213,2221,2237,2239,2243,2251,2267,2269,2273,2281,2287,2293,2297,2309,2311,2333,2339,2341,2347,2351,2357,2371,2377,2381,2383,2389,2393,2399,2411,2417,2423,2437,2441,2447,2459,2467,2473,2477,2503,2521,2531,2539,2543,2549,2551,2557,2579,2591,2593,2609,2617,2621,2633,2647,2657,2659,2663,2671,2677,2683,2687,2689,2693,2699,2707,2711,2713,2719,2729,2731,2741,2749,2753,2767,2777,2789,2791,2797,2801,2803,2819,2833,2837,2843,2851,2857,2861,2879,2887,2897,2903,2909,2917,2927,2939,2953,2957,2963,2969,2971,2999};\nint main()\n{\n\tint n,s;\n\tcin>>n;\n\tfor (int i=1;i<=n;i++)\n\t{\n\t\ts=0;\n\t\tfor (int j=1;j<=431;j++)\n\t\t{\n\t\t if (zs[j]<=i)\n\t\t\t {if (i%zs[j]==0) s++;}\n\t\t\t else break;\n\t\t\t \n\t\t}\n\t\tif (s==2)\n\t\t{\n\t\t \n\t\t\tans++;\n\t\t}\n\t}\n\tcout<\n#include \n#include \nusing namespace std;\nint main()\n{\n //freopen(\"in.txt\", \"r\", stdin);\n int n, i, j, count = 0, res = 0;\n scanf(\"%d\", &n);\n vector v;\n for (i = 1; i <= n; ++i)\n {\n count = 0;\n for (j = 1; j < i; ++j)\n {\n if (i % j == 0 && (j <= 5 || j % 5 != 0) && (j == 2 || j == 3 || (j > 3 && (j * j - 1) % 24 == 0)) && find(v.begin(), v.end(), j) == v.end())\n {\n \n ++count;\n v.push_back(j);\n }\n }\n if (count == 2)\n {\n ++res;\n //printf(\"%d %d\\n\", v[0], v[1]);\n }\n v.clear();\n }\n printf(\"%d\", res);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "66d84f664d4a132f64a75c45ccdaec82", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nbool prime_fun (int j)\n{\n if(j == 1)\n return false;\n for(int i = 2 ; i < j ; i++)\n if(j % i == 0)\n return false;\n return true;\n}\nint Total_prime(int n)\n{\n int cnt = 0 ;\n\n for(int i = 2 ; i<= n/2 ; i++)\n {\n if(n % i == 0)\n {\n if(prime_fun(i))\n cnt++ ;\n }\n }\n return cnt ;\n}\nint main()\n{\n //ifstream cin (\"A.in\");\n int T , res = 0 ;\n\n cin >> T;\n if(T < 6)\n cout << \"0\" << endl ;\n for(int k = 6 ; k <= T ; k++)\n {\n if(Total_prime(k) == 2)\n res++ ;\n\n }\n cout << res << endl ;\nreturn 0;\n} ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "31fea9be78743e83ebd91d2f2cb75d62", "src_uid": "356666366625bc5358bc8b97c8d67bd5", "difficulty": 900.0} {"lang": "GNU C++17", "source_code": "#include \n\n#define debug(...) clog << \"[\" << #__VA_ARGS__ << \"]\", debug_out(__VA_ARGS__)\n#define all(v) (v).begin(), (v).end()\n#define rall(v) (v).rbegin(), (v).rend()\n#define endl '\\n'\nusing namespace std;\nusing ll = long long;\n\nvoid debug_out() {clog << endl;}\n\ntemplate \nvoid debug_out(H head, T... tail)\n{\n clog << \" \" << head;\n debug_out(tail...);\n}\n\ntemplate \nostream& operator<<(ostream &os, const vector &vec)\n{\n for(auto &i : vec)\n os << i << ' ';\n return os;\n}\n\ntemplate \nostream& operator<<(ostream &os, const vector> &vec)\n{\n if(!vec.empty())\n os << vec[0];\n for(size_t i = 1; i < vec.size(); ++i)\n os << '\\n' << vec[i];\n return os;\n}\n\ntemplate \nostream& operator<<(ostream &os, const pair &p)\n{\n os << p.first << ' ' << p.second;\n return os;\n}\n\ntemplate \nostream& operator<<(ostream &os, const set &s)\n{\n for(auto &i : s)\n os << i << ' ';\n return os;\n}\n\n\n///////////////////////////////////////////////////////////////////////\nint main()\n{\n #define LOCAL_\n\n #if defined(LOCAL_)\n ifstream cin(\"input.txt\");\n #endif // defined\n\n int n, k;\n cin >> n >> k;\n\n vector c(n);\n for(int &i : c)\n cin >> i;\n\n priority_queue q;\n for(int i = 0; i < k + 1; ++i)\n q.push(0);\n\n sort(begin(c), end(c), greater());\n\n ll ans = 0;\n for(int i = 0; i < n; ++i)\n {\n ll best = q.top();\n q.pop();\n ans += best;\n q.push(c[i] + best);\n }\n cout << ans;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "93eae964a19bf0aa9cf5753946555ea8", "src_uid": "53155daf2375e01a3b87fa1c76f1e9a8", "difficulty": null} {"lang": "GNU C++17", "source_code": "\ufeff#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n\n\nconstexpr int MAXN = 5e5;\n\nint n, k;\nint input[MAXN];\nstd::deque vec[MAXN], help;\n\n\nvoid solve() {\n\tstd::cin >> n >> k;\n\tfor (int i = 0; i < n; i++) {\n\t\tstd::cin >> input[i];\n\t}\n\tstd::sort(input, input + n);\n\n\t{\n\t\tint64_t sum = 0;\n\t\tfor (int i = n - 1; i >= 0; i--) {\n\t\t\tsum += input[i];\n\t\t\thelp.push_back(input[i]);\n\t\t\tif (sum >= 0) {\n\t\t\t\t;\n\t\t\t} else {\n\t\t\t\tn = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (int i = 0; i < n; i++) {\n\t\tif (input[i] < 0) {\n\t\t\tvec[(i + 1) % (k + 1)].push_back(input[i]);\n\t\t} else {\n\t\t\tvec[0].push_back(input[i]);\n\t\t}\n\t}\n\tvec[0].insert(vec[0].end(), help.rbegin(), help.rend());\n\tint64_t res = 0;\n\tfor (int i = 0; i <= k; i++) {\n\t\tfor (int j = 0; j < vec[i].size(); j++) {\n\t\t\tres += vec[i][j] * 1ll * j;\n\t\t}\n\t}\n\tstd::cout << res << '\\n';\n}\n\n\n\nint32_t main() {\n\tstd::ios_base::sync_with_stdio(false);\n\tstd::cin.tie(0);\n\tstd::cout.tie(0);\n\n\n\tint t = 1;\n\t//std::cin >> t;\n\twhile (t--) {\n\t\tsolve();\n\t}\n\n\n\tstd::cout.flush();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "37d8e0b55ebb4f75f627c8237f1f4d3b", "src_uid": "53155daf2375e01a3b87fa1c76f1e9a8", "difficulty": null} {"lang": "GNU C++17", "source_code": "\ufeff#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n\n\nconstexpr int MAXN = 5e5;\n\nint n, k;\nint input[MAXN];\nstd::deque vec[MAXN], help;\n\n\nvoid solve() {\n\tstd::cin >> n >> k;\n\tfor (int i = 0; i < n; i++) {\n\t\tstd::cin >> input[i];\n\t}\n\tstd::sort(input, input + n);\n\n\t{\n\t\tint64_t sum = 0;\n\t\tfor (int i = n - 1; i >= 0; i--) {\n\t\t\tsum += input[i];\n\t\t\thelp.push_back(input[i]);\n\t\t\tif (sum >= 0) {\n\t\t\t\t;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tn = n - help.size();\n\t}\n\n\tfor (int i = 0; i < n; i++) {\n\t\tif (input[i] < 0) {\n\t\t\tvec[(i + 1) % (k + 1)].push_back(input[i]);\n\t\t} else {\n\t\t\tvec[0].push_back(input[i]);\n\t\t}\n\t}\n\tvec[0].insert(vec[0].end(), help.rbegin(), help.rend());\n\tint64_t res = 0;\n\tfor (int i = 0; i <= k; i++) {\n\t\tfor (int j = 0; j < vec[i].size(); j++) {\n\t\t\tres += vec[i][j] * 1ll * j;\n\t\t}\n\t}\n\tstd::cout << res << '\\n';\n}\n\n\n\nint32_t main() {\n\tstd::ios_base::sync_with_stdio(false);\n\tstd::cin.tie(0);\n\tstd::cout.tie(0);\n\n\n\tint t = 1;\n\t//std::cin >> t;\n\twhile (t--) {\n\t\tsolve();\n\t}\n\n\n\tstd::cout.flush();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bb8838a7632f4d0ef61913a6ca9960d9", "src_uid": "53155daf2375e01a3b87fa1c76f1e9a8", "difficulty": null} {"lang": "GNU C++17", "source_code": "\ufeff#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n\n\nconstexpr int MAXN = 5e5 + 5;\n\nint n, k;\nint input[MAXN];\nstd::deque vec[MAXN], help;\n\n\nvoid solve() {\n\tstd::cin >> n >> k;\n\tfor (int i = 0; i < n; i++) {\n\t\tstd::cin >> input[i];\n\t}\n\tstd::sort(input, input + n);\n\n\t{\n\t\tint64_t sum = 0;\n\t\tfor (int i = n - 1; i >= 0; i--) {\n\t\t\tsum += input[i];\n\t\t\thelp.push_back(input[i]);\n\t\t\tif (sum >= 0) {\n\t\t\t\t;\n\t\t\t} else {\n\t\t\t\thelp.pop_back();\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tn = n - help.size();\n\t}\n\n\tfor (int i = 0; i < n; i++) {\n\t\tif (input[i] < 0) {\n\t\t\tvec[(i + 0) % (k + 1)].push_back(input[i]);\n\t\t} else {\n\t\t\tvec[0].push_back(input[i]);\n\t\t}\n\t}\n\tvec[0].insert(vec[0].end(), help.rbegin(), help.rend());\n\tint64_t res = 0;\n\tfor (int i = 0; i <= k; i++) {\n\t\tfor (int j = 0; j < vec[i].size(); j++) {\n\t\t\tres += vec[i][j] * 1ll * j;\n\t\t}\n\t}\n\tstd::cout << res << '\\n';\n}\n\n\n\nint32_t main() {\n\tstd::ios_base::sync_with_stdio(false);\n\tstd::cin.tie(0);\n\tstd::cout.tie(0);\n\n\n\tint t = 1;\n\t//std::cin >> t;\n\twhile (t--) {\n\t\tsolve();\n\t}\n\n\n\tstd::cout.flush();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5f98186cd710f98f2d687dbddd3e3d55", "src_uid": "53155daf2375e01a3b87fa1c76f1e9a8", "difficulty": null} {"lang": "GNU C++17", "source_code": " #include\n using namespace std;\n int main(){\n \n int x , y;\n cin >> x >> y;\n while(y!=1){\n if((abs(x-y)+1)%2 == 0 && x >= (y-1) && y!=0){\n cout << \"Yes\" << endl;\n \n \n \n }else{\n \n cout << \"No\" << endl;\n \n }\n \n \n }\n if(y == 1 && x == 0){\n cout << \"Yes\" << endl;\n }else{\n cout << \"No\" << endl;\n }\n }", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5dff4fb82df04756b7842d811cd6aec3", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include \n#include \nusing namespace std;\nlong long n, m;\n\nvoid recursion(int copy,int original) {\n\tif (copy == n && original == m) {\n\t\tcout << \"Yes\" << endl;\n\t\texit(0);\n\t}\n\telse if (copy > n || original > m) {\n\t\treturn;\n\t}\n\n\trecursion(copy +1, original +1);\n\trecursion(copy +2, original);\n\n}\n\nint main() {\n\tcin >> n >> m;\n\trecursion(0,1);\n\tcout << \"No\" << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8b00eef45d4c67e8a0d8fe9a94d5ff87", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\ntypedef long long int LL;\ntypedef unsigned long long uLL;\ntypedef pair< int,int > ii;\ntypedef pair< int,ii > iii;\nconst int inf = 1e9;\nconst LL INF = 1e18;\nconst int N = 100005;\nconst int MOD = 1e9+7;\nconst double EPS = 1e-6;\nconst double PI = acos(-1.0);\n#define endl '\\n'\n#define F first\n#define S second\n#define pb push_back\n#define mp pake_pair\n#define CLR(V) V.clear()\n#define SORT(V) sort( V.begin(), V.end() )\n#define REV(V) sort( V.rbegin(), V.rend() )\n#define MEM(a,x) memset( a, x, sizeof(a) )\n#define FOR(i,a,b) for( int i = a; i <= b; i++ )\n#define ROF(i,a,b) for( int i = b; i >= a; i-- )\n#define REP(i,a) for( int i = 0; i < a; i++ )\n#define debug(x) cerr << \"The value is \"<< x << endl\n#define Unique(a) sort( all(a)), a.erase( unique( all(a) ), a.end() )\n#define UB(a,key) upper_bound( a.begin(), a.end(), key )-a.begin()\n#define LB(a,key) lower_bound( a.begin(), a.end(), key )-a.begin()\n\nLL ori , cop;\n\nvoid solve( LL x , LL y ) {\n //cout << x << \" \" << y << endl;\n if( x > ori || y > cop ) return;\n if( x == ori && y == cop ) {\n puts(\"Yes\");\n exit(0);\n }\n solve( x+1 , y+1 );\n if( y >= 1 ) solve( x , y+2 );\n}\nint main( int argc, char const *argv[] ) {\n scanf(\"%lld %lld\",&cop,&ori);\n if( ori == 0 ) {\n puts(\"No\");\n return 0;\n }\n LL x = 1 , y = 0; //or , cop\n solve( x , y );\n puts(\"No\");\n return 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "68fef46c93caa71bd4acf34f83229f67", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\nint x, y;\nvoid f(int a, int b)\n{\n if(a>x||b>y) return;\n if(a==x&&b==y)\n {\n printf(\"Yes\");\n exit(0);\n }\n f(a+1, b+1);\n if(a>0) f(a+2, b);\n}\nint main() {\n scanf(\"%d%d\", &x, &y);\n f(0,1);\n printf(\"No\");\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "aff7b312b942f154a1c2040a993a4447", "src_uid": "1527171297a0b9c5adf356a549f313b9", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define ll long long\n#define f(i, x, n) for (int i = x; i < (int)(n); ++i)\n\nint n, m, mll[5][5], md = 1e9 + 7;\nvector v[500];\nchar in[501];\n\ninline void sb(int &x, int y) { if ((x -= y) < 0)x += 5; }\n\ninline void ml(vector &a, vector &b, int bg){\n\tint d = 0;\n\tf(i, 1, 5)if (mll[a[bg]][i] == b[bg]) { d = i; break; }\n\tf(i, bg, m)sb(b[i], mll[d][a[i]]);\n}\n\nint main(){\n\tf(i, 0, 5)f(j, 0, 5)mll[i][j] = i * j % 5;\n\tscanf(\"%d%d\", &n, &m);\n\tf(i, 0, n){\n\t\tscanf(\"%s\", in);\n\t\tv[i].resize(m);\n\t\tf(j, 0, m)v[i][j] = in[j] - 'a';\n\t}\n\tint w = 0;\n\tf(i, 0, m){\n\t\tint k = -1;\n\t\tf(j, w, n)if (v[j][i]) { k = j; break; }\n\t\tif (k == -1)continue;\n\t\tswap(v[w], v[k]);\n\t\t++w;\n\t\tf(j, w, n)if (v[j][i])ml(v[w - 1], v[j], w);\n\t}\n\tint q;\n\tscanf(\"%d\", &q);\n\twhile (q--){\n\t\tscanf(\"%s\", in);\n\t\tvector z(m);\n\t\tf(i, 0, m)z[i] = in[i] - 'a';\n\t\tint an = 1, w = 0;\n\t\tf(i, 0, n){\n\t\t\twhile (w < m && v[i][w] == 0){\n\t\t\t\tif (z[w] != 0) { an = 0; break; }\n\t\t\t\t++w;\n\t\t\t}\n\t\t\tif (an == 0)break;\n\t\t\tif (w == m)an = (ll)an * 5 % md;\n\t\t\telse {\n\t\t\t\tif (z[w] != 0)ml(v[i], z, w);\n\t\t\t\t++w;\n\t\t\t}\n\t\t}\n\t\tprintf(\"%d\\n\", an);\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7ee77bd30050adee003e7cacf97594c3", "src_uid": "5cb18864c88b7fdec4a85718df67333e", "difficulty": 2600.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\n#define ms(s, n) memset(s, n, sizeof(s))\n#define FOR(i, a, b) for (int i = (a); i < (b); i++)\n#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)\n#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)\n#define sz(a) int((a).size())\n#define present(t, x) (t.find(x) != t.end())\n#define all(a) (a).begin(), (a).end()\n#define uni(a) (a).erase(unique(all(a)), (a).end())\n#define pb push_back\n#define pf push_front\n#define mp make_pair\n#define fi first\n#define se second\n#define prec(n) fixed<> (i)) & 1)\n#define bitcount(n) __builtin_popcountll(n)\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef long double ld;\ntypedef pair pi;\ntypedef vector vi;\ntypedef vector vii;\nconst int MOD = (int) 1e9 + 7;\nconst int MOD2 = 1007681537;\nconst int INF = (int) 1e9;\nconst ll LINF = (ll) 1e18;\nconst ld PI = acos((ld) -1);\nconst ld EPS = 1e-9;\ninline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}\ninline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}\ninline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}\ntemplate inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}\ntemplate inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}\ninline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}\ninline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}\ninline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}\ninline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}\ninline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}\ninline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}\ninline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}\ninline int sign(ld x, ld y) {return sign(x - y);}\n#define db(x) cerr << #x << \" = \" << (x) << \" \";\n#define endln cerr << \"\\n\";\n\ntypedef vector ROW;\ntypedef vector MATRIX;\nint iv[5];\n\nvoid gauss(MATRIX& a) {\n int i, j, k, n = a.size(), m = a[0].size();\n for (i = 0; i < n; i++) {\n if (!a[i][i]) {\n for (j = i + 1; j < n; j++) {\n if (a[j][i]) {\n for (k = 0; k < m; k++) {\n a[i][k] += a[j][k];\n if (a[i][k] >= 5) {\n a[i][k] -= 5;\n }\n }\n break;\n }\n }\n }\n if (!a[i][i]) continue;\n int t = a[i][i];\n for (k = 0; k < m; k++) a[i][k] = mult(a[i][k], iv[t], 5);\n for (j = 0; j < n; j++) {\n if (j == i) continue;\n t = a[j][i];\n for (k = 0; k < m; k++) {\n a[j][k] -= a[i][k] * t % 5;\n if (a[j][k] < 0) {\n a[j][k] += 5;\n }\n }\n }\n }\n}\n\nconst int maxn = 1000 + 5;\nint n, m, q;\nint a[maxn][maxn];\nint b[maxn][maxn];\n\nvoid solve() {\n FOR(i, 1, 5) iv[i] = inv(i, 5);\n cin >> n >> m;\n FOR(i, 0, n) {\n string s; cin >> s;\n FOR(j, 0, m) a[j][i] = s[j] - 'a';\n }\n cin >> q;\n FOR(i, 0, q) {\n string s; cin >> s;\n FOR(j, 0, m) b[i][j] = s[j] - 'a';\n }\n MATRIX mat(m, ROW(n + q));\n FOR(i, 0, m) {\n FOR(j, 0, n) mat[i][j] = a[i][j];\n FOR(j, 0, q) mat[i][n + j] = b[j][i];\n }\n gauss(mat);\n FOR(k, 0, q) {\n int found = 0, rk = 0;\n FOR(i, 0, m) {\n int tot = 0;\n FOR(j, 0, n) tot += mat[i][j];\n if (!tot && mat[i][n + k]) {\n found = 1;\n break;\n }\n if (tot) rk++;\n }\n if (found) {\n cout << 0 << \"\\n\";\n continue;\n }\n cout << fpow(5, n - rk) << \"\\n\";\n }\n}\n\nint main() {\n int JUDGE_ONLINE = 1;\n if (fopen(\"in.txt\", \"r\")) {\n JUDGE_ONLINE = 0;\n assert(freopen(\"in.txt\", \"r\", stdin));\n //assert(freopen(\"out.txt\", \"w\", stdout));\n }\n else {\n ios_base::sync_with_stdio(0), cin.tie(0);\n }\n solve();\n if (!JUDGE_ONLINE) {\n //cout << \"\\nTime elapsed: \" << 1000 * clock() / CLOCKS_PER_SEC << \"ms\\n\";\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3a48c971732ff89b58efb3286ca96005", "src_uid": "5cb18864c88b7fdec4a85718df67333e", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\nusing namespace __gnu_pbds;\nusing namespace __gnu_cxx;\n#define VIS(it,con) for(auto it=con.begin();it!=con.end();++it)\n#define pob pop_back\n#define pf push_front\n#define pof pop_front\n#define MIN(x,y) (x=min(x,(y)))\n#define MAX(x,y) (x=max(x,(y)))\n#define mid (l+r>>1)\n#define lch (idx*2+1)\n#define rch (idx*2+2)\n/*****************************************************************************/\n#include\n#define int int_fast64_t\nusing namespace std;\ntypedef pair pii;\ntypedef vector VI;\n#define REP(i,j,k) for(register int i=(j);i<(k);++i)\n#define RREP(i,j,k) for(register int i=(j)-1;i>=(k);--i)\n#define ALL(a) a.begin(),a.end()\n#define MST(a,v) memset(a,(v),sizeof a)\n#define pb push_back\n#define F first\n#define S second\n#define endl '\\n'\n//\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t#define __debug\n#ifdef __debug\n\t#define IOS (void)0\n\t#define de(...) cerr<<__VA_ARGS__\n\t#define ar(a,s,t) {REP(__i,s,t)de(a[__i]<<' ');de(endl);}\n#else\n\t#define IOS cin.tie(0),cout.tie(0),ios_base::sync_with_stdio(false)\n\t#define de(...) (void)0\n\t#define ar(...) (void)0\n#endif\n/***********************************default***********************************/\nconst int maxn=509,maxq=309,mo=1e9L+7;\nconst int inv[5]={0,1,3,2,4};\nconst double eps=1e-8;\nint n,m,q,res=1,ok[maxq],a[maxn][maxn+maxq];\n\nvoid sol(){\n\tREP(i,0,n){\n\t\tint bst=-1;\n\t\tREP(j,i,m)if(bst<0||a[j][i]>a[bst][i])bst=j;\n\t\tswap(a[bst],a[i]);\n\t\tif(a[i][i]==0)continue;\n\t\tRREP(j,n+q,i)a[i][j]=a[i][j]*inv[a[i][i]]%5;\n\t\tREP(j,0,m)if(i!=j)RREP(k,n+q,i)a[j][k]=(a[j][k]+5-a[i][k]*a[j][i]*inv[a[i][i]]%5)%5;\n\t}\n\tfill(ok,ok+q,1);\n\tREP(i,0,n){\n\t\tif(a[i][i]==0){\n\t\t\tres=res*5%mo;\n\t\t\tREP(j,0,q)if(a[i][n+j]!=0)ok[j]=0;\n\t\t}\n\t}\n\tREP(i,n,m)REP(j,0,q)if(a[i][n+j]!=0)ok[j]=0;\n}\n\nmain(){\n\tIOS;\n\tcin>>n>>m;\n\tMST(a,0);\n\tREP(i,0,n)REP(j,0,m){\n\t\tchar c;cin>>c;\n\t\ta[j][i]=c-'a';\n\t}\n\tcin>>q;\n\tREP(i,0,q)REP(j,0,m){\n\t\tchar c;cin>>c;\n\t\ta[j][n+i]=c-'a';\n\t}\n\tsol();\n\tREP(i,0,q)cout<<(ok[i]?res:0)<\nusing namespace std;\n#define sd(x) scanf(\"%d\", &(x))\n#define F first\n#define S second\n#define ll long long\nconst int N = 505;\nint mod = 5;\ninline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}\ninline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}\ninline int mul(int x, int y){ return (x * 1ll * y) % mod;}\ninline int powr(int a, ll b){\n int x = 1 % mod;\n while(b){\n if(b & 1) x = mul(x, a);\n a = mul(a, a);\n b >>= 1;\n }\n return x;\n}\nint _inv[5] = {0, 1, 3, 2, 4};\ninline int inv(int a){ return powr(a, mod - 2);}\nvector > > transforms;\nvector zero_rows;\nint FREE = 0;\nstruct matrix{\n int M[N][N], n, m;\n matrix(){}\n matrix(int _n, int _m){n = _n, m = _m;}\n void print(){\n for(int i = 0; i < n; i++){\n for(int j = 0; j < m; j++) cerr << M[i][j] << \" \";\n cerr << endl;\n } cerr << endl;\n }\n void rre(){\n for(int j = 0; j < m; j++){\n int f = 1;\n for(int i = 0; i < n; i++){\n if(M[i][j]){\n f = 0;\n int INV = _inv[M[i][j]];\n for(int k = 0; k < n; k++){\n if(k != i){\n // M[k] -= M[i] * (M[k][j]/M[i][j])\n int p = mul(M[k][j], INV);\n for(int _j = 0; _j < m; _j++) M[k][_j] = sub(M[k][_j], mul(p, M[i][_j]));\n transforms.push_back({i, {k, p}});\n }\n }\n }\n }\n if(f) FREE++;\n }\n for(int i = 0; i < n; i++){\n bool f = 1;\n for(int j = 0; j < m; j++) if(M[i][j]) f = 0;\n if(f) zero_rows.push_back(i);\n }\n }\n} ;\nchar str[505];\nint b[N], powers[505];\nint main(){\n mod = 1e9 + 7;\n int n, m, q;\n sd(n); sd(m);\n matrix mat = matrix(m, n);\n for(int i= 0; i < n; i++){\n scanf(\"%s\", str);\n for(int j = 0; j < m; j++){\n mat.M[j][i] = str[j] - 'a';\n }\n }\n // mat.print();\n mat.rre();\n // mat.print();\n sd(q);\n while(q--){\n scanf(\"%s\", str);\n for(int i = 0; i < m; i++) b[i] = str[i] - 'a';\n for(auto it : transforms){\n int i = it.F, k = it.S.F, p = it.S.S;\n b[k] = sub(b[k], mul(p, b[i]));\n }\n bool f = 0;\n for(int i : zero_rows) if(b[i]) f = 1;\n if(f){\n printf(\"%d\\n\", 0);\n continue;\n }\n mod = 1e9 + 7;\n int ans = 1;\n for(int i = 0; i < n - (m - zero_rows.size()); i++) ans = mul(ans, 5);\n printf(\"%d\\n\", ans);\n mod = 5;\n } \n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "310955c62c3a3e311f21c712be52ff84", "src_uid": "5cb18864c88b7fdec4a85718df67333e", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint a[100000000];\n\nint main()\n{\n int n,m;\n cin >> n >> m;\n for(int i=0;i<1000;i++)\n {\n a[i]=0;\n }\n\n for(int i=n;i<=m;i++)\n {\n for(int j=2;j<=i;j++)\n {\n if(i%j==0)\n {\n a[j]++;\n }\n }\n }\n int max=a[2];\n for(int i=3;i<=m;i++)\n {\n if(max\n\nusing namespace std;\n\nint main()\n{\n int x,y,z,a=0,b=0,c=0;\n cin>>x>>y;\n if(x==y)\n cout<100)\n cout<<2<b&&a>c)\n cout<<2<a&&b>c)\n cout<<3<a&&c>b)\n cout<<5<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint main()\n{\n vector vec;\n\tint l, r;\n\tcin >> l >> r;\t\n\tfor (int i = l; i <= r; i++)\n\t{\n\t\tvec.push_back(i);\t\t\n\t}\n\tint arr[10000];\n\tint x;\n\tfor (int i = 0; i < 10000; i++)\n\t\tarr[i] = 0;\n\tfor (int i = 0 ; i < vec.size(); i++)\n\t{\n\t\tx = vec[i];\n\t\tfor (int j = 2; j < x / 2; j++)\n\t\t{\n\t\t\tif (x % j == 0)\n\t\t\t\tarr[j]++;\n\t\t}\n\t}\n\tint c = arr[0];\n\tint index = 0;\n\tfor (int i = 1; i < 10000; i++)\n\t{\n\t\tif (arr[i] > c)\n\t\t{\n\t\t\tc = arr[i];\n\t\t\tindex = i;\n\t\t}\n\t}\n\tcout << index << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5f7a5055ffc749e0233bc5be8dcedb04", "src_uid": "a8d992ab26a528f0be327c93fb499c15", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint l,r,i,j,dp[100000000],ans;\nmain(){\n cin>>l>>r;\n for(i=l;i<=r;i++)\n for(j=2;j<=r-l;j++){\n if(i%j==0)dp[j]++;\n }\n for(i=2;i<=r-l;i++)\n ans=max(dp[i],ans);\n for(i=2;i<=r-l;i++)\n if(dp[i]==ans){\n cout<\n#include \nusing namespace std;\n\nint main()\n{\n char dir, s[100], rs[100], kb[30] = { 'q' , 'w' , 'e' , 'r', 't' , 'y' , 'u' , 'i', 'o' , 'p', 'a', 's', 'd' , 'f' , 'g' , 'h', 'j' , 'k' , 'l' , ';', 'z' , 'x' , 'c' , 'v', 'b' , 'n' , 'm' , ',', '.' , '/'};\n cin >> dir >> s;\n for(int i = 0;i < 100;i++)\n rs[i] = ' ';\n if( dir == 'R')\n for(int i = 0;i < strlen(s) ;i ++)\n for( int j = 0;j < 30;j++)\n if( s[i] == kb[j])\n rs[i] = kb[j - 1];\n if(dir == 'L')\n for(int i = 0;i < strlen(s) ;i ++)\n for( int j = 0;j < 30;j++)\n if( s[i] == kb[j])\n rs[i] = kb[j + 1];\n for(int i = 0;i < 100;i++)\n cout << rs[i];\n\n char _;\n cin >> _;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "226565a25015e1a012653576d9a3ac9e", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6", "difficulty": 900.0} {"lang": "GNU C++0x", "source_code": "#include \n#include\n#include \n#include \n//#include \n\nusing namespace std;\n\nint main()\n{\n string a, t, s;\n a = \"qwertyuiopasdfghjkl;zxcvbnm,./\";\n char x;\n int y;\n cin >> x;\n s = \"\";\n if (x == 'R')\n {\n y = -1;\n }\n if (x == 'L')\n {\n y = 1;\n }\n cin >> t;\n int len = t.size();\n for (int j = 0; j < len ; j++)\n {\n for (int i = 0; i<30; i++)\n {\n if (t[j] == a[i])\n {\n s = s + a[i + y];\n }\n } \n }\n // for (int j = 0; j\n#include\n#include\n#include\n\nint main()\n{\n char str[100];\n char arr[3][11] = { {'q','w','e','r','t','y','u','i','o','p','['} , {'a','s','d','f','g','h','j','k','l',';','\\''} , {'z','x','c','v','b','n','m',',','.','/'} };\n char ch,var;\n int i,j,k,check;\n fflush(stdin);\n cin>>ch;\n fflush(stdin);\n cin.getline(str,100,'\\n');\n if(ch == 'R' || ch == 'r')\n {\n for(i=0;i\nusing namespace std;\nchar arr[30]={'q','w','e','r','t','y','u','i','o','p'\n,'a','s','d','f','g','h','j','k','l',';'\n,'z','x','c','v','b','n','m',',','.','/'};\nint main() {\n// cout<mp;\n for(int i=0;i<30;i++){\n mp[arr[i]] = i;\n }\n //cout<>n;\n char arr_in[200];\n char s;\n int i=0;\n if(n == 'R'){\n while(cin >> arr_in[i]){\n int v = mp[arr_in[i]];\n if(v+1 >= 30){ v=0; cout<> arr_in[i]){\n int v = mp[arr_in[i]];\n if(v+1 >= 30){ v=0; cout<\n#include \n#include \n#include \n#include \nusing namespace std;\n#define N 40050\n#define eps 1e-8\ndouble n,m;long long ans;\nint main()\n {\n cin >>n>>m;m+=1;n+=1;int t=n-m;\n for (int i=m,l=2-n-i;i<=t;i++)\n for (int j=i;j<=t;j++)\n {\n double k=(i-2*n-j)/4,e=(k*k*2+n*(2*i+j-2*n)-i*j)/2;\n if (e<=0) continue;e=sqrt(e);\n double q=int(-e-k+1),w=int(e-k-eps);\n ans+=(w-q+1)*(1+(i!=j));\n }\n cout <\n#define LL long long\nint n,m;\nint main()\n{\n\tLL ans,sum;\n\tint b,c,A,B,C,D,E,l;\n\tscanf(\"%d%d\",&n,&m);\n\tn++; m++; ans=0;\n\tfor (c=m;c<=n>>1;c++)\n\t{\n\t\tC=((n*n-n*c+c*c)<<1)+(n-m)*(n+c);\n\t\tA=(n<<1)-c; D=n-m; E=n+c; sum=0;\n\t\tfor (b=n-m;b>=m;b--)\n\t\t{\n\t\t\tl=C/(A-b);\n\t\t\tif (m>l) l=m-1;\n\t\t\tif (l>=D) break;\n\t\t\tsum+=D-l; C-=E;\n\t\t}\n\t\tif (c<<1\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)\n#define FORD(i, a, b) for(int i = (a); i >= (b); --i)\n#define fup FOR\n#define fdo FORD\n#define REP(i, n) for(int i = 0;i <(n); ++i)\n#define VAR(v, i) __typeof(i) v=(i)\n#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)\n#define ALL(x) (x).begin(), (x).end()\n#define SZ(x) ((int)(x).size())\n#define siz SZ\n#define CLR(x) memset((x), 0, sizeof(x))\n#define PB push_back\n#define MP make_pair\n#define X first\n#define Y second \n#define FI X\n#define SE Y\n#define SQR(a) ((a)*(a))\n#define DEBUG 1\n#define debug(x) {if (DEBUG)cerr <<#x <<\" = \" <P;\ntypedef vectorVI;\nconst int INF=1E9+7;\ntemplate void mini(C&a4, C b4){a4=min(a4, b4); }\ntemplate void maxi(C&a4, C b4){a4=max(a4, b4); }\n#define MAXN 100007\n\nint n,m;\nLL res;\n\nint main(){\n\tios_base::sync_with_stdio(false);\n cout << setprecision(9) << fixed;\n\t//in\n cin >> n >> m;\n\t//sol\n FOR(i,1+m,n-m) {\n int a = 2*i*i-i*m-2*i*(n+1)+m*(n+1);\n FOR(j,1+m,n-m) {\n a += n+1-i;\n int b = (-a+i+j-1) / (i+j);\n if(b < m+1) continue;\n if(b >= n-m+2) {\n res += (LL)(n-m-j+1) * (n-2*m);\n break;\n }\n res += b - (m + 1);\n }\n }\n\t//out\n cout << 3*res << endl;\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f5b8eaf9826b2b4755954ab6077242c9", "src_uid": "355cc23d7a4addfc920c6e5e72a2bb64", "difficulty": 2700.0} {"lang": "GNU C++", "source_code": "#include \n\n#include \n\n#include \n\n#include \n\n#include \n\n#include \n\n#include \n\n#include \n\n#include \n\n#include \n\n#include \n\n#include \n\n#include \n\n\n\nusing namespace std;\n\n\n\ntypedef long long INT;\n\ntypedef pair pii;\n\n\n\n#define eprintf(...) fprintf(stderr, __VA_ARGS__)\n\ntemplate inline void chkmin(T &a, T b) { if (a>b) a=b; }\n\ntemplate inline void chkmax(T &a, T b) { if (ala) {\n\n\t\t\t\tcur+=(st-la)*(rc-lc+1);\n\n\t\t\t\tla=st;\n\n\t\t\t}\n\n\t\t\tfor (int a=la;a<=ra;a++) {\n\n\t\t\t\tint mx=u/a;\n\n\t\t\t\tif (mx>=rc) cur+=rc-lc+1; \n\n\t\t\t\telse if (mx>=lc) cur+=mx-lc+1;\n\n\t\t\t\telse break;\n\n\t\t\t}\n\n\t\t\tres[b]=cur;\n\n\t\t}\n\n\t\tans+=res[b];\n\n\t}\n\n\tprintf(\"%I64d\\n\", 3*ans);\n\n\treturn 0;\n\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2fdc775c248f80e2f5f33b15d3f616b9", "src_uid": "355cc23d7a4addfc920c6e5e72a2bb64", "difficulty": 2700.0} {"lang": "GNU C++11", "source_code": "#include \r\nusing namespace std;\r\ntypedef long long ll;\r\nconst int N = 1e6 + 10;\r\nconst ll mod = 998244353;\r\nconst double eps=1e-8;\r\nconst double pi = acos(-1);\r\ninline ll read()\r\n{\r\n ll x=0,f=1;char ch=getchar();\r\n while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}\r\n while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}\r\n return x*f;\r\n}\r\ninline void pt(ll x,ll y){\r\n if(y==1) printf(\"%lld \",x);\r\n else printf(\"%lld\\n\",x);\r\n}\r\nll n,m,tot;\r\nll sum[N],ans[N];\r\nll cnt[N<<1+5];\r\nvoid init(){\r\n for(int i=1;i<=(N);i++) {\r\n for (int j = i; j <= (N); j += i) {\r\n cnt[j]++;\r\n }\r\n }\r\n}\r\nint main() {\r\n// freopen(\"../in.in\", \"r\", stdin);\r\n// ios::sync_with_stdio(false);\r\n// cin.tie(0);cout.tie(0);\r\n int _;\r\n init();\r\n n = read();\r\n sum[0]=0;\r\n\r\n for(int i=1;i<=n;i++){\r\n ans[i]=(sum[i-1]+cnt[i])%mod;\r\n sum[i]=(sum[i-1]+ans[i])%mod;\r\n }\r\n pt(ans[n],2);\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2f9e1efa21e25b0835b07f2fb6161279", "src_uid": "09be46206a151c237dc9912df7e0f057", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include\r\n#include\r\n#include\r\n#define ll long long\r\n#define mod 998244353\r\n#define maxn 100000005\r\nusing namespace std;\r\nint n;\r\nll f[1000005];\r\nint isp[maxn];\r\nint p[maxn],cnt;\r\nvoid init(){\r\n\tisp[1]=1;\r\n\tfor(int i=2;i<=100000000;i++){\r\n\t\tif(!isp[i]) p[++cnt]=i;\r\n\t\tfor(int j=1;j<=cnt&&i*p[j]<=100000000;j++){\r\n\t\t\tisp[i*p[j]]=1;\r\n\t\t\tif(i%p[j]==0) break;\r\n\t\t}\r\n\t}\r\n}\r\nll dfs(int x){\r\n\tif(x%2) return 0;\r\n\tif(!x) return 1;\r\n\tif(f[x]) return f[x];\r\n\tll ans=0;\r\n\tfor(int i=x;i>=1;i--){\r\n\t\tif(2*i-21){\r\n\t\twhile(tmp%p[i]==0){\r\n\t\t\tnum++;\r\n\t\t\ttmp/=p[i];\r\n\t\t}\r\n\t\tif(i!=1) num++;\r\n\t\tans1*=num;\r\n\t\tans1%=mod;\r\n\t\ti++;num=0;\r\n\t}\r\n\tans+=ans1-1;\r\n\tans%=mod;\r\n\treturn f[x]=ans;\r\n}\r\nint main(){\r\n\tinit();\r\n\tscanf(\"%d\",&n);\r\n\tprintf(\"%lld\",dfs(2*n));\r\n\treturn 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "659b3547574dfa1c0dac28b0cca7495d", "src_uid": "09be46206a151c237dc9912df7e0f057", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include\r\n#include\r\n#define int long long \r\nusing namespace std;\r\nint d[100000007];\r\n\tint mod=998244353;\r\nvoid div(int n)\r\n{\r\n\tfor(int i=2;i<=n;i++)\r\n\t{\r\n\t\tfor(int j=i;j<=n;j+=i)\r\n\t\t{\r\n\t\td[j]++;\r\n\t\td[j]%=mod;\r\n\t}\r\n\t}\r\n}\r\nsigned main()\r\n{\r\n\r\n\r\n\tint n;\r\n\tcin>>n;\r\n\tint a[n+1];\r\n\ta[0]=0;\r\n\ta[1]=1;\r\n\tdiv(n);\r\n\tint s=1;\r\n\tfor(int i=2;i<=n;i++)\r\n\t{\r\n\t\ta[i]=s+d[i]+1;\r\n\t\ta[i]%=mod;\r\n\t\ts=s+a[i];\r\n\t\ts%=mod;\r\n\t}\r\n\tcout<\r\nusing namespace std;\r\nusing lli = long long;\r\nconst lli mod = 998244353, N = 1e6 + 3;\r\nlli dp[N];\r\nlli n;\r\nvoid SieveOfEratosthenes(int n, bool prime[],\r\n bool primesquare[], int a[])\r\n{\r\n\r\n //For more details check out: https://www.geeksforgeeks.org/sieve-of-eratosthenes/\r\n\r\n // Create a boolean array \"prime[0..n]\" and\r\n // initialize all entries it as true. A value\r\n // in prime[i] will finally be false if i is\r\n // Not a prime, else true.\r\n for (int i = 2; i <= n; i++)\r\n prime[i] = true;\r\n\r\n // Create a boolean array \"primesquare[0..n*n+1]\"\r\n // and initialize all entries it as false. A value\r\n // in squareprime[i] will finally be true if i is\r\n // square of prime, else false.\r\n for (int i = 0; i <= (n * n + 1); i++)\r\n primesquare[i] = false;\r\n\r\n // 1 is not a prime number\r\n prime[1] = false;\r\n\r\n for (int p = 2; p * p <= n; p++)\r\n {\r\n // If prime[p] is not changed, then\r\n // it is a prime\r\n if (prime[p] == true)\r\n {\r\n // Update all multiples of p starting from p * p\r\n for (int i = p * p; i <= n; i += p)\r\n prime[i] = false;\r\n }\r\n }\r\n\r\n int j = 0;\r\n for (int p = 2; p <= n; p++)\r\n {\r\n if (prime[p])\r\n {\r\n // Storing primes in an array\r\n a[j] = p;\r\n\r\n // Update value in primesquare[p*p],\r\n // if p is prime.\r\n primesquare[p * p] = true;\r\n j++;\r\n }\r\n }\r\n}\r\n\r\n// Function to count divisors\r\nint countDivisors(int n)\r\n{\r\n // If number is 1, then it will have only 1\r\n // as a factor. So, total factors will be 1.\r\n if (n == 1)\r\n return 1;\r\n\r\n bool prime[n + 1], primesquare[n * n + 1];\r\n\r\n int a[n]; // for storing primes upto n\r\n\r\n // Calling SieveOfEratosthenes to store prime\r\n // factors of n and to store square of prime\r\n // factors of n\r\n SieveOfEratosthenes(n, prime, primesquare, a);\r\n\r\n // ans will contain total number of distinct\r\n // divisors\r\n int ans = 1;\r\n\r\n // Loop for counting factors of n\r\n for (int i = 0;; i++)\r\n {\r\n // a[i] is not less than cube root n\r\n if (a[i] * a[i] * a[i] > n)\r\n break;\r\n\r\n // Calculating power of a[i] in n.\r\n int cnt = 1; // cnt is power of prime a[i] in n.\r\n while (n % a[i] == 0) // if a[i] is a factor of n\r\n {\r\n n = n / a[i];\r\n cnt = cnt + 1; // incrementing power\r\n }\r\n\r\n // Calculating the number of divisors\r\n // If n = a^p * b^q then total divisors of n\r\n // are (p+1)*(q+1)\r\n ans = ans * cnt;\r\n }\r\n\r\n // if a[i] is greater than cube root of n\r\n\r\n // First case\r\n if (prime[n])\r\n ans = ans * 2;\r\n\r\n // Second case\r\n else if (primesquare[n])\r\n ans = ans * 3;\r\n\r\n // Third case\r\n else if (n != 1)\r\n ans = ans * 4;\r\n\r\n return ans - 1; // Total divisors\r\n}\r\nlli rec(lli level)\r\n{\r\n if (level <= 1)\r\n return 1;\r\n if (dp[level] != -1)\r\n return dp[level] % mod;\r\n lli ans = countDivisors(level) % mod;\r\n for (lli i = 0; i < level; i++)\r\n ans = ((ans % mod) + (rec(i) % mod)) % mod;\r\n //cout << level << '=' << ans << '\\n';\r\n return dp[level] = ans % mod;\r\n}\r\nvoid solve()\r\n{\r\n cin >> n;\r\n memset(dp, -1, sizeof(dp));\r\n lli ans = rec(n) % mod;\r\n cout << ans << '\\n';\r\n}\r\nsigned main()\r\n{\r\n ios::sync_with_stdio(false);\r\n cin.tie(0);\r\n cout.tie(0);\r\n lli _t = 1;\r\n //cin>>_t;\r\n while (_t--)\r\n solve();\r\n return 0;\r\n}\r\n//Think twice, code once.", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b0c8629ff4bf58f6dbb2e95a08ca68b6", "src_uid": "09be46206a151c237dc9912df7e0f057", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "\ufeff#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#ifdef _WIN32\n#include \n#endif // _WIN32\n\nusing ll = long long;\n\nll buildin_one_count(ll number)\n{\n#ifdef _WIN32\n return __popcnt64(number);\n#else\n return __builtin_popcountl(number);\n#endif // _WIN32\n}\n\ntemplate \nll lsize(const Container& container)\n{\n return static_cast(size(container));\n}\n\n#define for_n(x) for (ll i = 0; i < x; ++i)\n\nusing namespace std;\n\nusing position = pair;\nconst position zero_point = { 0,0 };\n\nnamespace range_ns\n{\n template\n void print(const Container& container, const char* sep = \"\\n\")\n {\n\tstd::copy(container.begin(), container.end(), ostream_iterator(cout, sep));\n }\n\n template\n void sort(Container& container)\n {\n\tstd::sort(container.begin(), container.end());\n }\n\n template\n decltype(auto) find(const Container& container, const T& elem)\n {\n\treturn std::find(container.begin(), container.end(), elem);\n }\n\n template\n decltype(auto) find_if(const Container& container, Condition condition)\n {\n\treturn std::find_if(container.begin(), container.end(), condition);\n }\n\n template>\n decltype(auto) max_element(Container& container, Condition condition = Condition())\n {\n\treturn std::max_element(container.begin(), container.end(), condition);\n }\n\n template>\n decltype(auto) min_element(const Container& container, Condition condition = Condition())\n {\n\treturn std::min_element(container.begin(), container.end(), condition);\n }\n\n template>\n decltype(auto) minmax_element(const Container& container, Condition condition = Condition())\n {\n\treturn std::minmax_element(container.begin(), container.end(), condition);\n }\n\n template\n decltype(auto) any_of(const Container& container, Condition condition)\n {\n\treturn std::any_of(container.begin(), container.end(), condition);\n }\n\n template\n decltype(auto) all_of(const Container& container, Condition condition)\n {\n\treturn std::all_of(container.begin(), container.end(), condition);\n }\n\n template\n decltype(auto) count(const Container& container, const T& elem)\n {\n\treturn std::count(container.begin(), container.end(), elem);\n }\n\n template\n decltype(auto) count_if(const Container& container, Condition condition)\n {\n\treturn std::count_if(container.begin(), container.end(), condition);\n }\n\n template\n decltype(auto) for_each(Container& container, Func func)\n {\n\treturn std::for_each(container.begin(), container.end(), func);\n }\n\n template\n decltype(auto) equal_range(const Container& container, const T& elem)\n {\n\treturn std::equal_range(container.begin(), container.end(), elem);\n }\n\n template\n decltype(auto) lower_bound(const Container& container, const T& elem)\n {\n\treturn std::lower_bound(container.begin(), container.end(), elem);\n }\n\n template\n decltype(auto) upper_bound(const Container& container, const T& elem)\n {\n\treturn std::upper_bound(container.begin(), container.end(), elem);\n }\n\n vector iota(ll number)\n {\n\tvector vec(number);\n\tstd::iota(vec.begin(), vec.end(), 1);\n\treturn vec;\n }\n\n template\n void erase_remove_if(Container& container, Condition condition)\n {\n\tcontainer.erase(remove_if(container.begin(), container.end(), condition), container.end());\n }\n\n template\n Container copy_if(const Container& container, Condition condition)\n {\n\tContainer container_result;\n\tcopy_if(container.begin(), container.end(), back_inserter(container_result), condition);\n\treturn container_result;\n }\n\n template \n void reverse(Container& container)\n {\n\tstd::reverse(begin(container), end(container));\n }\n\n struct sum_functor\n {\n\tll operator()(ll sum, ll value) const { return sum + value; }\n };\n\n template\n ll reduce(const Container& container, ll init_value = 0, Func func = sum_functor())\n {\n\treturn std::accumulate(container.begin(), container.end(), init_value, func);\n }\n\n template>\n decltype(auto) adjacent_find(const Container& container, Func func = Func())\n {\n\treturn std::adjacent_find(container.begin(), container.end(), func);\n }\n\n template\n vector copy_indexes(const Container& container, Predicate predicate)\n {\n\tvector indexes;\n\tfor_n(lsize(container))\n\t if (predicate(container[i]))\n\t\tindexes.push_back(i);\n\n\treturn indexes;\n }\n}\n\ntemplate \ndecltype(auto) read_vector(ll n)\n{\n vector res(n);\n for (auto& i : res)\n\tcin >> i;\n return res;\n}\n\nusing Graph = vector>;\n\nvoid debth_first_search(const Graph& graph, ll start_vertex, ll end_vertex)\n{\n stack vertex_stack;\n vertex_stack.push(start_vertex);\n vector visited(size(graph), false);\n visited[start_vertex] = true;\n\n vector path(size(graph), -1);\n while (!vertex_stack.empty())\n {\n\tll vertex = vertex_stack.top();\n\tvertex_stack.pop();\n\n\tfor (ll v : graph[vertex])\n\t if (!visited[v])\n\t {\n\t\tvisited[v] = true;\n\t\tvertex_stack.push(v);\n\t\tpath[v] = vertex;\n\t }\n }\n\n vector path_end_start = { end_vertex };\n ll vertex = -1;\n while (vertex != start_vertex)\n {\n\tvertex = path[path_end_start.back()];\n\tpath_end_start.push_back(vertex);\n }\n\n range_ns::reverse(path_end_start);\n range_ns::for_each(path_end_start, [](ll& v) { ++v; });\n range_ns::print(path_end_start, \" \");\n}\n\nusing factorization_map = unordered_map;\n\nfactorization_map factorize(ll n)\n{\n factorization_map ans;\n\n while (n % 2 == 0)\n {\n\t++ans[2];\n\tn = n / 2;\n }\n\n for (ll i = 3; i <= sqrt(n); i = i + 2)\n {\n\twhile (n % i == 0)\n\t{\n\t ++ans[i];\n\t n = n / i;\n\t}\n }\n\n // n is prime\n if (n > 2)\n\t++ans[n - 1];\n\n return ans;\n};\n\nusing namespace range_ns;\n\ntemplate \nll binary_search(ll l, ll r, Condition condition)\n{\n while (l <= r)\n {\n\tll m = (l + r) / 2;\n\tif (condition(m))\n\t r = m - 1;\n\telse\n\t l = m + 1;\n }\n\n return l;\n}\n\nvector z_function(string_view s) {\n int n = (int)s.length();\n vector z(n);\n for (int i = 1, l = 0, r = 0; i < n; ++i) {\n\tif (i <= r)\n\t z[i] = min(r - i + 1, z[i - l]);\n\twhile (i + z[i] < n && s[z[i]] == s[i + z[i]])\n\t ++z[i];\n\tif (i + z[i] - 1 > r)\n\t l = i, r = i + z[i] - 1;\n }\n return z;\n}\n\nint find_fisrt_occurance(const string& t, const string& p)\n{\n auto vec = z_function(p + \"#\" + t);\n for (int i = 0; i < lsize(t); ++i)\n\tif (vec[i + lsize(p) + 1] == lsize(p))\n\t return i;\n\n return -1;\n}\n\nint main(int argc, char** argv)\n{\n ll n;\n cin >> n;\n auto vec = read_vector(n);\n\n if (size(vec) == 1)\n {\n\tcout << 0;\n\treturn 0;\n }\n\n ll ans_start = 0, ans_end = 0, ans_mdiddle = -2, i = 0;\n if (vec[i] == 1)\n\twhile (i < n - 1 && vec[i + 1] == vec[i + 1])\n\t ++ans_start;\n \n i = n - 1;\n if (vec[i] == 1000)\n\twhile (i > 0 && vec[i - 1] == vec[i] - 1)\n\t ++ans_end;\n\n vec.erase(begin(vec));\n vec.erase(end(vec));\n for (ll j = 0; j < lsize(vec); ++j)\n {\n\tll curr = 1;\n\twhile (j < lsize(vec) - 1 && vec[j + 1] == vec[j + 1])\n\t ++curr;\n\tans_mdiddle = max(ans_mdiddle, curr);\n }\n\n cout << max(max(ans_start, ans_end), ans_mdiddle);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2f607adae5953a81211c0084e3eeca35", "src_uid": "858b5e75e21c4cba6d08f3f66be0c198", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nint a[105];\n\nint main()\n{\n int n;\n cin >> n;\n for(int i = 1; i < n; i++)\n cin >> a[i];\n a[0] = 0;\n a[n + 1] = 1001;\n n += 2;\n\n int maxl = 0;\n int i = 0;\n while(i < n)\n {\n int l = 1;\n while(i + 1 < n && a[i] + 1 == a[i + 1])\n {\n l++;\n i++;\n }\n if(l > maxl)\n maxl = l;\n }\n\n cout << maxl - 2 << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ff1ac40dd06032c91fed29404f03e7aa", "src_uid": "858b5e75e21c4cba6d08f3f66be0c198", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main()\n{\n int n,i=0,j=0,l,anik[100009]={0},x=0,count=0,flag=0,heda=0;\n cin>>n;\n while(iheda)\n {\n heda=count;\n count=0;\n }\n i=x;\n break;\n }\n\n }\n else\n { count--;\n if(count>heda)\n {\n heda=count;\n count=0;\n }\n i=x-1;\n break;\n }\n }\n flag=1;\n }\n\n }\n\n\n cout<\nusing namespace std;\n#define READ(f) freopen(f, \"r\", stdin)\n#define WRITE(f) freopen(f, \"w\", stdout)\n\n#define __ std::ios_base::sync_with_stdio(false); cin.tie(0);\n#define ___ cerr << endl << \"Execution Time : \" << 1 * clock() / CLOCKS_PER_SEC << endl;\n#define START double start_s=clock();\n#define STOP double stop_s=clock();\n#define _ cerr << \"Time Elapsed : \" << (stop_s-start_s)/double(CLOCKS_PER_SEC);\n\n#define mem(x,y) memset(x,y,sizeof(x))\n#define mem0(v) memset(v,0,sizeof(v))\n#define all(v) (v).begin(),(v).end()\n#define arrSort sort(arr,arr+n)\n#define vSort sort(all(v))\n#define maxSort sort(all(v),greater())\n#define rSort sort(v.rbegin(),v.rend())\n#define sqr(x) ((x)*(x))\n#define qube(x) ((x)*(x)*(x))\n#define deci(n) cout<=b ; i--)\n#define repx( i ,a,b, x) for( i=a ; i>T;while(T--)\n#define FTC(T) int T;cin>>T;for(int TestCase=1;TestCase<=T;TestCase++)\n#define CASE_OUT(x) cout << \"Case \" << TestCase << \": \" << x << endl;\n\n#define ERR 1e-9\n#define pi (2*acos(0))\n#define PI 3.141592653589793\n#define M 1000000007\n#define E \"\\n\"\n#define el cout << endl\n#define e putchar('\\n')\n#define space putchar(' ')\n#define bor |\n\n#define sc scanf\n#define pf printf\n#define scin(x) sc(\"%d\",&(x))\n#define scin2(x,y) sc(\"d\",&(x),&(y))\n#define scin3(x,y,z) sc(\"d%d\",&(x),&(y),&(z))\n#define scln(x) sc(\"%lld\",&(x))\n#define sc scanf\n#define pf printf\n#define gc getchar\n#define pc putchar\n#define check(n,pos) (n & (1<<(pos)))\n#define biton(n,pos) (n (1<<(pos)))\n#define bitoff(n,pos) (n & ~(1<<(pos)))\ntypedef long double LD;\ntypedef unsigned int UI;\ntypedef long long int LL;\ntypedef unsigned long long int ULL;\n#define SS stringstream\n#define vi vector\n#define vii vector< vi >\n#define pb push_back\n\nvi prime,primeFactor;bool flg=true;\nbool flag = true;\n\n/** Prime Check -----------------> isPrime(n) **/ templateinline bool isPrime(T n){if(n<=1)return false;if(n<=3)return true;if(n%2==0 bor n%3==0)return false;for(int i=5;i*i<=n;i+=6)if(n%i==0||n%(i+2)==0)return false;return true;}\n/** Sieve Method -----------------> sieve(n) **/ templateinline void sieve(T N){int status[(N>>5)+2];memset(status,0,((N>>5)+2)<<2);for(int i=3;i*i<=N;i+=2)if(!(status[i>>5]&(1<<(i & 31))))for(int j=i*i;j<=N;j+=(i<<1))status[j>>5]|=(1<<(j&31));prime.pb(2);for(int i=3;i<=N;i+=2){if(!(status[i>>5]&(1<<(i&31))))prime.pb(i);if(!(N%i))flg=false;}}\n/** Factorization -----------------> factorization(n) **/ templateinline void factorization(T N){if(flg){primeFactor.pb(N);return;}int Size=0;int sqrtN=int(sqrt(N));while(N>=1&&Size!=prime.size()&&prime[Size]<=sqrtN){while(N%prime[Size]==0){primeFactor.pb(prime[Size]);N/=prime[Size];}Size++;}if(N>1)primeFactor.pb(N);}\n/** GCD -----------------> gcd(a,b) **/ templateinline T gcd(T a,T b){while(b)b ^= a ^= b ^= a %= b;return a;}\n/** LCM -----------------> lcm(a,b) **/ templateinline T lcm(T a, T b){return (a / gcd(a,b)) * b;}\n/** Big Mod -----------------> bigMod(b,p,m) **/ templateinline T mmul(T a, T b, T m) { T result = 0; a %= m; while (b) { if (b % 2) result = (result + a) % m; a = (a + a) % m; b /= 2; } return result; }templateinline T bigMod(T a, T b, T m) { T result = 1; a %= m; while (b) { if (b % 2) result = mmul(result, a, m); a = mmul(a, a, m); b /= 2; } return result; }\n/** Negative Mod -----------------> negMod(-a,b) **/ templateinline T negMod(T n,T m){return (n%m+m)%m;}\n/** ((a * b) % m) -----------------> big(a,b,m) **/ templateinline T bigMul(T a,T b,T m){if(b==0)return 0;T x=bigMul(a,b>>1,m);x=((x%m)+(x%m))%m;if(b&1)x=(x+(a%m))%m;return x;}\n/** String to integer -----------------> StoI(string s,int x(any integer)) **/ templateinline T StoI(string s, T ret){SS ss(s);ss >> ret;return ret;}/// extract words or numbers from a line\n/** integer to string -----------------> ItoS(n) **/ templateinline string ItoS(T n){SS ss;ss << n; return ss.str();}/// convert a number to string\n/** min. of 3 numbers -----------------> MIN3(x,y,z) **/ templateinline T MIN3(T x,T y,T z){T Min=y^((x^y)& -(x MAX3(x,y,z) **/ templateinline T MAX3(T x,T y,T z){T Max=x^((x^y)& -(x BtoD(x) **/ templateinline T BtoD(T x){T two=1,intn=0;while(x){if(x%10)intn+=two;x/=10;two<<=1;}return intn;}\n/** Binary to Dec(ULL) -----------------> BtoI(string s) **/ inline ULL BtoD(string str){ULL intS=0,two=1;int len=str.length();for(int i=len-1;i>=0;i--){if(str.at(i)=='1')intS+=two;two<<=1;}return intS;}\n/** Dec to Binary(ULL) -----------------> DtoB(n) [store it in a string] **/ inline string DtoB(ULL n) { int count = 0; string s = \"\"; for (int i = 31; i >= 0; i--) { int k = n >> i; if (k & 1) { count = 1; s += '1'; } else { if(count == 1) s += '0'; }} return s; }\n/** STL all elements -----------------> printStl(v) **/ //templateinline void printStl(T &v){int sz=v.size()-1;int k=0;for(auto i=v.begin();i!=v.end();i++,k++){if(k==sz)cout<<*i< in(x) **/ templateinline void in(T &x){x=0;bool neg=false;register char c=getchar();while((c<48||c>57)&&c!=EOF&&c!='-')c=getchar();if(c=='-'){neg=true;c=getchar();}while(c>=48&&c<=57){x=(x<<3)+(x<<1)+c-48;c=getchar();}if(neg)x=~(x-1);}\n/** intput 2 integer -----------------> in2(x,y) **/ templateinline T in2(T &a,T &b){in(a);in(b);}\n/** intput 3 integer -----------------> in3(x,y,z) **/ templateinline T in3(T &a,T &b,T &c){in(a);in(b);in(c);}\n/** print 1 integer -----------------> out(x) **/ templateinline void out(T x){char a[21];T i=1,j;if(x<0){putchar('-');x=~(x-1);}if(x==0)putchar('0');while(x){a[i++]=x%10+48;x/=10;}for(j=i-1;j>=1;j--)putchar(a[j]);}\n/** Remainder -----------------> Rem(string divident,LL divisor) **/ inline LL Rem(string q,LL r) { LL l = q.size(); LL remainder = 0; for(int i=0; i quotient(string divident,LL divisor) **/ inline LL quotient(string num,LL number) { long long l,x = 0,mod=0; l= num.size(); int print_done = 0; for(int i=0; i isVowel(char c) **/ bool isVowel(char ch){ch=toupper(ch);return(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E');return false;}\n/** Consonant -----------------> isConsonant(char c) **/ bool isConsonant(char ch){return(isalpha(ch) && !isVowel(ch));return false;}\n\nvi v1 , v2;\nint main()\n{\n while(1) {\n __\n int n;\n cin >> n;\n\n for(int i = 0;i < n;i++) {\n int x;\n cin >> x;\n v1.push_back(x);\n }\n\n int cnt = 0;\n int maxcnt = 0;\n int L = -1;\n for(int i = n - 1 ; i > 0; i--) {\n if(v1[i] - v1[i - 1] != 1) {\n if(cnt > maxcnt) {\n maxcnt = cnt;\n L = i;\n }\n cnt = 0;\n }\n else {\n cnt++;\n if(i == 1 && v1[0] == 1 && v1[n-1] != n ) {\n cnt++;\n if(n == cnt + 1) cnt--;\n }\n\n }\n }\n\n\n int x;\n x = max(maxcnt,cnt);\n if(x == 0 ) cout << 0 << endl;\n else if(x ==1 && n == 2) {\n if((v1[0] == 1 && v1[1] == 2) || (v1[0] == 999 && v1[1] == 1000)) cout << 1 << endl;\n else cout << 0 << endl;\n }\n else if(v1[x + L] == 1000) cout << \"A\" << \" \", cout << x << endl;\n\n\n\n else {\n if(x == n - 1) {\n if(v1[0] == 1 || v1[n-1] == 1000)cout << \"b\" << \" \", cout << x << endl;\n else cout << x - 1 << endl;\n }\n else if(v1[1] - v1[0] == 1 && L < 2) {\n if(n - 2 == x) x--;\n cout << x << endl;\n }\n else {\n if(n - 2 == x) x--;\n cout << x - 1 << endl;\n }\n }\n\nv1.clear();\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d4591dc66c0f9f78aa25b2b1a8a37d40", "src_uid": "858b5e75e21c4cba6d08f3f66be0c198", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef double db;\nconst db eps=1e-6;\nint sign(db k){if (k>eps) return 1; else if (k<-eps) return -1; return 0;}\nint cmp(db k1,db k2){return sign(k1-k2);}\nstruct point{\n db x,y;\n point operator + (const point &k1) const{return (point){k1.x+x,k1.y+y};}\n point operator - (const point &k1) const{return (point){x-k1.x,y-k1.y};}\n point operator * (db k1) const{return (point){x*k1,y*k1};}\n point operator / (db k1) const{return (point){x/k1,y/k1};}\n bool operator < (const point k1) const{\n int a=cmp(x,k1.x);\n if (a==-1) return 1; else if (a==1) return 0; else return cmp(y,k1.y)==-1;\n }\n int getP() const{return sign(y)==-1||(sign(y)==0&&sign(x)==-1);}\n};\ndb cross(point k1,point k2){return k1.x*k2.y-k1.y*k2.x;}\ndb dot(point k1,point k2){return k1.x*k2.x+k1.y*k2.y;}\nint compareangle (point k1,point k2){\n return k1.getP()0);\n}\npoint getLL(point k1,point k2,point k3,point k4){\n db w1=cross(k1-k3,k4-k3),w2=cross(k4-k3,k2-k3); return (k1*w2+k2*w1)/(w1+w2);\n}\nstruct line{\n point p[2];\n line(point k1,point k2){p[0]=k1; p[1]=k2;}\n line(){};\n point& operator [] (int k){return p[k];}\n int include(point k){return sign(cross(p[1]-p[0],k-p[0]))>=0;}//\u975e\u4e25\u683c\u5305\u542b\u3002\n point dir(){return p[1]-p[0];}\n};\npoint getLL(line k1,line k2){return getLL(k1[0],k1[1],k2[0],k2[1]);}\nint parallel(line k1,line k2){return sign(cross(k1.dir(),k2.dir()))==0;}\nint sameDir(line k1,line k2){return parallel(k1,k2)&&sign(dot(k1.dir(),k2.dir()))==1;}\nint operator < (line k1,line k2){\n if (sameDir(k1,k2)) return k2.include(k1[0]);\n return compareangle(k1.dir(),k2.dir());\n}\nint checkpos(line k1,line k2,line k3){return k3.include(getLL(k1,k2));}\nvector getHL(vector &L){ // \u6c42\u534a\u5e73\u9762\u4ea4 , \u534a\u5e73\u9762\u662f\u9006\u65f6\u9488\u65b9\u5411 , \u8f93\u51fa\u6309\u7167\u9006\u65f6\u9488\n sort(L.begin(),L.end()); deque q;\n for (int i=0;i<(int)L.size();i++){\n if (i&&sameDir(L[i],L[i-1])) continue;\n while (q.size()>1&&!checkpos(q[q.size()-2],q[q.size()-1],L[i])) q.pop_back();\n while (q.size()>1&&!checkpos(q[1],q[0],L[i])) q.pop_front();\n q.push_back(L[i]);\n }\n while (q.size()>2&&!checkpos(q[q.size()-2],q[q.size()-1],q[0])) q.pop_back();\n while (q.size()>2&&!checkpos(q[1],q[0],q[q.size()-1])) q.pop_front();\n vectorans; for (int i=0;i A){ // \u591a\u8fb9\u5f62\u7528 vector \u8868\u793a , \u9006\u65f6\u9488\n db ans=0;\n for (int i=0;i convexHull(vectorps){\n int n = ps.size();if(n<=1)return ps;\n sort(ps.begin(),ps.end());\n vector qs(n*2);int k=0;\n for(int i=0;i1&&sign(cross(qs[k-1]-qs[k-2],ps[i]-qs[k-2]))<=0)--k;\n for(int i=n-2,t=k;i>=0;qs[k++]=ps[i--])\n while (k>t&&sign(cross(qs[k-1]-qs[k-2],ps[i]-qs[k-2]))<=0)--k;\n qs.resize(k-1);\n return qs;\n}\nint t,n;\npoint p[400005];\nvector l;\nvector v;\n\nvoid add(const point& x,const point& y){\n if (sign(cross(y-x,(point){0,0}-x)>0)) l.push_back(line(x,y));\n else l.push_back(line(y,x));\n}\nint main(){\n scanf(\"%d\",&t);\n while (t--){\n l.clear();v.clear();\n scanf(\"%d\",&n);\n for(int i=0;i0))j++;\n if(j0))p++;\n// if(p0)l.push_back(line(v[i],v[p]));\n// else l.push_back(line(v[p],v[i]));\n// }\n }\n l=getHL(l);\n if(l.size()<3){printf(\"0\\n\");continue;}\n v.clear();\n m=l.size();\n for(int i=0;i\n#include\n#include\nusing namespace std;\n\n\nconst long double PI = acos(-1.0L);\n\nstruct Vec {\n\tlong double x, y;\n\t\n\tVec& operator-=(Vec r) {\n\t\tx -= r.x, y -= r.y;\n\t\treturn *this;\n\t}\n\tVec operator-(Vec r) {return Vec(*this) -= r;}\n\t\n\tVec& operator+=(Vec r) {\n\t\tx += r.x, y += r.y;\n\t\treturn *this;\n\t}\n\tVec operator+(Vec r) {return Vec(*this) += r;}\n\tVec operator-() {return {-x, -y};}\n\tVec& operator*=(long double r) {\n\t\tx *= r, y *= r;\n\t\treturn *this;\n\t}\n\tVec operator*(long double r) {return Vec(*this) *= r;}\n\tVec& operator/=(long double r) {\n\t\tx /= r, y /= r;\n\t\treturn *this;\n\t}\n\tVec operator/(long double r) {return Vec(*this) /= r;}\n\t\n\tlong double operator*(Vec r) {\n\t\treturn x * r.x + y * r.y;\n\t}\n};\nostream& operator<<(ostream& l, Vec r) {\n\treturn l << '(' << r.x << \", \" << r.y << ')';\n}\nlong double len(Vec a) {\n\treturn hypot(a.x, a.y);\n}\nlong double cross(Vec l, Vec r) {\n\treturn l.x * r.y - l.y * r.x;\n}\nlong double angle(Vec a) {\n\treturn fmod(atan2(a.y, a.x)+2*PI, 2*PI);\n}\nVec normal(Vec a) {\n\treturn Vec({-a.y, a.x}) / len(a);\n}\n//OMLEND: 2D Vectors\n//----------------------------------------------------------------\n\n//----------------------------------------------------------------\n//OMLBEGIN: 2D Segments\n//Uses: vector2d.h\n#include\nusing namespace std;\n\nstruct Segment {\n\tVec a, b;\n\tVec d() {\n\t\treturn b-a;\n\t}\n};\nostream& operator<<(ostream& l, Segment r) {\n\treturn l << r.a << '-' << r.b;\n}\n\nVec intersection(Segment l, Segment r) {\n\tVec dl = l.d(), dr = r.d();\n\tif(cross(dl, dr) == 0)\n\t\treturn {nanl(\"\"), nanl(\"\")};\n\t\n\tlong double h = cross(dr, l.a-r.a) / len(dr);\n\tlong double dh = cross(dr, dl) / len(dr);\n\t\n\treturn l.a + dl * (h / -dh);\n}\n\n//Returns the area bounded by halfplanes\nlong double getArea(vector lines) {\n\tlong double lowerbound = -HUGE_VALL, upperbound = HUGE_VALL;\n\t\n\tvector linesBySide[2];\n\tfor(auto line : lines) {\n\t\tif(line.b.y == line.a.y) {\n\t\t\tif(line.a.x < line.b.x)\n\t\t\t\tlowerbound = max(lowerbound, line.a.y);\n\t\t\telse\n\t\t\t\tupperbound = min(upperbound, line.a.y);\n\t\t}\n\t\telse if(line.a.y < line.b.y)\n\t\t\tlinesBySide[1].push_back(line);\n\t\telse\n\t\t\tlinesBySide[0].push_back({line.b, line.a});\n\t}\n\t\n\tsort(linesBySide[0].begin(), linesBySide[0].end(), [](Segment l, Segment r) {\n\t\tif(cross(l.d(), r.d()) == 0) return normal(l.d())*l.a > normal(r.d())*r.a;\n\t\treturn cross(l.d(), r.d()) < 0;\n\t});\n\tsort(linesBySide[1].begin(), linesBySide[1].end(), [](Segment l, Segment r) {\n\t\tif(cross(l.d(), r.d()) == 0) return normal(l.d())*l.a < normal(r.d())*r.a;\n\t\treturn cross(l.d(), r.d()) > 0;\n\t});\n\t\n\t//Now find the application area of the lines and clean up redundant ones\n\tvector applyStart[2];\n\tfor(int side = 0; side < 2; side++) {\n\t\tvector &apply = applyStart[side];\n\t\tvector curLines;\n\t\t\n\t\tfor(auto line : linesBySide[side]) {\n\t\t\twhile(curLines.size() > 0) {\n\t\t\t\tSegment other = curLines.back();\n\t\t\t\t\n\t\t\t\tif(cross(line.d(), other.d()) != 0) {\n\t\t\t\t\tlong double start = intersection(line, other).y;\n\t\t\t\t\tif(start > apply.back())\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tcurLines.pop_back();\n\t\t\t\tapply.pop_back();\n\t\t\t}\n\t\t\t\n\t\t\tif(curLines.size() == 0)\n\t\t\t\tapply.push_back(-HUGE_VALL);\n\t\t\telse\n\t\t\t\tapply.push_back(intersection(line, curLines.back()).y);\n\t\t\tcurLines.push_back(line);\n\t\t}\n\t\t\n\t\tlinesBySide[side] = curLines;\n\t}\n\tapplyStart[0].push_back(HUGE_VALL);\n\tapplyStart[1].push_back(HUGE_VALL);\n\t\n\tlong double result = 0;\n\t{\n\t\tlong double lb = -HUGE_VALL, ub;\n\t\tfor(int i=0, j=0; i < (int)linesBySide[0].size() && j < (int)linesBySide[1].size();lb = ub) {\n\t\t\tub = min(applyStart[0][i+1], applyStart[1][j+1]);\n\t\t\t\n\t\t\tlong double alb = lb, aub = ub;\n\t\t\tSegment l0 = linesBySide[0][i], l1 = linesBySide[1][j];\n\t\t\t\n\t\t\tif(cross(l1.d(), l0.d()) > 0)\n\t\t\t\talb = max(alb, intersection(l0, l1).y);\n\t\t\telse if(cross(l1.d(), l0.d()) < 0)\n\t\t\t\taub = min(aub, intersection(l0, l1).y);\n\t\t\talb = max(alb, lowerbound);\n\t\t\taub = min(aub, upperbound);\n\t\t\taub = max(aub, alb);\n\t\t\t\n\t\t\t{\n\t\t\t\tlong double x1 = l0.a.x + (alb - l0.a.y) / l0.d().y * l0.d().x;\n\t\t\t\tlong double x2 = l0.a.x + (aub - l0.a.y) / l0.d().y * l0.d().x;\n\t\t\t\tresult -= (aub - alb) * (x1 + x2) / 2;\n\t\t\t}\n\t\t\t{\n\t\t\t\tlong double x1 = l1.a.x + (alb - l1.a.y) / l1.d().y * l1.d().x;\n\t\t\t\tlong double x2 = l1.a.x + (aub - l1.a.y) / l1.d().y * l1.d().x;\n\t\t\t\tresult += (aub - alb) * (x1 + x2) / 2;\n\t\t\t}\n\t\t\t\n\t\t\tif(applyStart[0][i+1] < applyStart[1][j+1])\n\t\t\t\ti++;\n\t\t\telse\n\t\t\t\tj++;\n\t\t}\n\t}\n\treturn result;\n}\n//OMLEND: 2D Segments\n//----------------------------------------------------------------\n\n\n#include\n#include\nusing namespace std;\n\n\nint main() {\n\tint T;\n\tcin >> T;\n\t\n\tfor(int TCASE = 0; TCASE < T; TCASE++) {\n\t\tint n;\n\t\tcin >> n;\n\t\t\n\t\ttry {\n\t\t\tvector pts(n);\n\t\t\tfor(int i=0;i> pts[i].x >> pts[i].y;\n\t\t\t\n\t\t\tlong double lim = 1000000;\n\t\t\tvector segs = {{{-lim, -lim}, {lim, -lim}}, {{lim, -lim}, {lim, lim}},\n\t\t\t\t\t\t\t\t\t{{lim, lim}, {-lim, lim}}, {{-lim, lim}, {-lim, -lim}}};\n\t\t\t\n\t\t\tsort(pts.begin()+1, pts.end(), [&](Vec l, Vec r) {\n\t\t\t\treturn fmod(angle(l-pts[0]), PI) < fmod(angle(r-pts[0]), PI);\n\t\t\t});\n\t\t\tfor(int i=1;i 0)\n\t\t\t\t\tsegs.push_back({pts[i], pts[j]});\n\t\t\t\telse\n\t\t\t\t\tsegs.push_back({pts[j], pts[i]});\n\t\t\t}\n\t\t\t\n\t\t\tthrow getArea(segs);\n\t\t}\n\t\tcatch(long double result) {\n\t\t\tcout << fixed << setprecision(7) << result << '\\n';\n\t\t}\n\t}\n\t\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "31e4fd2eef38697159e4dc7936738025", "src_uid": "6afe0718ad89e3fd51a456e0144c538d", "difficulty": 3300.0} {"lang": "GNU C++14", "source_code": "#include\n/*\n N \n // N// \n ///// //// \n //////N///// \n/////y//y/////\n///:y//yyy////\n //`////y/////\n///``////y////\n///NN////y////\n///y N///y////\n//`y `/`/y/// \n ``````//y// \n ````::// \n :: \n -- \n N``-- \n `N` - \n h -N \n -hhNN \n hhNNNN \n -hhNNNN \n hhNNNNNN- \n hhhNNNNNN \n - -NNNNNN \n ``NNN-NNNNN \n NNNNNN--NNNN \n - NN-NNN \n --- N--N \n - N- \n - N \n -- \n -- \n -- \n - \n - \n hhh-hh \n hhhNNhhh \n hhhhhh \n*/\n\n\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair pii;\ntypedef pair pdd;\ntypedef pair pdi;\n\nconst double EPS = 1e-8;\nconst double PI = acos(-1);\n\ndouble sq(double x){ return x*x; }\nll sq(ll x){ return x*x; }\nint sign(ll x){ return x < 0? -1 : x > 0? 1 : 0; }\nint sign(int x){ return x < 0? -1 : x > 0? 1 : 0; }\ndouble sign(double x){ return abs(x) < EPS? 0 : x < 0? -1 : 1; }\n\npii operator+(const pii &l, const pii &r){ return pii(l.first + r.first, l.second + r.second); }\npii operator-(const pii &l, const pii &r){ return pii(l.first - r.first, l.second - r.second); }\nll operator^(const pii &l, const pii &r){ return (ll)l.first * r.second - (ll)l.second * r.first; }\nll operator/(const pii &l, const pii &r){ return (ll)l.first * r.second - (ll)l.second * r.first; }\nll operator*(const pii &l, const pii &r){ return (ll)l.first * r.first + (ll)l.second * r.second; }\npii operator*(const pii &l, const int &r){ return pii(l.first * r, l.second * r); }\npii operator-(const pii &l){ return pii(-l.first, -l.second); }\n\npdd operator+(const pdd &l, const pdd &r){ return pdd(l.first + r.first, l.second + r.second); }\npdd operator-(const pdd &l, const pdd &r){ return pdd(l.first - r.first, l.second - r.second); }\ndouble operator^(const pdd &l, const pdd &r){ return l.first * r.second - l.second * r.first; }\ndouble operator/(const pdd &l, const pdd &r){ return l.first * r.second - l.second * r.first; }\ndouble operator*(const pdd &l, const pdd &r){ return l.first * r.first + l.second * r.second; }\npdd operator*(const pdd &l, const double &r){ return pdd(l.first * r, l.second * r); }\npdd operator-(const pdd &l){ return pdd(-l.first, -l.second); }\n\ndouble size(pdd x){ return hypot(x.first, x.second); }\ndouble size2(pdd x){ return sq(x.first) + sq(x.second); }\nll size2(pii x){ return sq((ll)x.first) + sq((ll)x.second); }\ndouble polar(pdd x){ return atan2(x.second, x.first); }\npdd unit(double a){ return pdd(cos(a), sin(a)); }\npdd norm(pdd a){ return a * (1.0 / size(a)); }\npdd rotate(pdd v, double a){ return unit(a) * v.first + unit(a + PI / 2) * v.second; }\npdd r90(pdd v){ return pdd(-v.second, v.first); }\n\nvoid normalize(double &a){\n\twhile (a < 0) a += 2 * PI;\n\twhile (a >= 2 * PI) a -= 2 * PI;\n}\n\nstruct circle{\n\tcircle(pdd O, double r):O(O), r(r){}\n\tcircle(){}\n\tpdd O;\n\tdouble r;\n};\n\nint tangent(circle &A, circle &B, pdd des[4]){\n\t// outer\n\tint top = 0;\n\tdouble d = size(A.O - B.O), a = polar(B.O - A.O), b = PI + a;\n\n\tdouble t = sq(d) - sq(A.r - B.r);\n\tif (t >= 0){\n\t\tt = sqrt(t);\n\t\tdouble p = atan2(B.r - A.r, t);\n\t\tdes[top++] = pdd(a + p + PI / 2, b + p - PI / 2);\n\t\tdes[top++] = pdd(a - p - PI / 2, b - p + PI / 2);\n\t}\n\t// inner\n\tt = sq(d) - sq(A.r + B.r);\n\tif (t >= 0){\n\t\tt = sqrt(t);\n\t\tdouble p = atan2(B.r + A.r, t);\n\t\tdes[top++] = pdd(a + p - PI / 2, b + p - PI / 2);\n\t\tdes[top++] = pdd(a - p + PI / 2, b - p + PI / 2);\n\t}\n\treturn top;\n}\n\nint intersect(circle &A, circle &B, pdd des[2]){\n\tdouble d = size(A.O - B.O), t = (sq(A.r) + sq(d) - sq(B.r)) / 2 / A.r / d, u = (sq(B.r) + sq(d) - sq(A.r)) / 2 / B.r / d;\n\tif (abs(d) < EPS) return 0;\n\tif (1 - t*t < 0 || 1 - u*u < 0) return 0;\n\tdouble a = atan2(sqrt(1 - t*t), t), b = atan2(sqrt(1 - u*u), u), p = polar(B.O - A.O), q = PI + p;\n\tdes[0] = pdd(p + a, q - b);\n\tdes[1] = pdd(p - a, q + b);\n\treturn 2;\n}\n\nint intersect(circle A, pdd s, pdd d, pdd des[2]){\n\tdouble c = size2(A.O - s) - sq(A.r), b = d * (s - A.O), a = size2(d);\n\n\tif (b*b - a*c < 0) return 0;\n\tdes[0].second = (-b - sqrt(b*b - a*c)) / a;\n\tdes[1].second = (-b + sqrt(b*b - a*c)) / a;\n\tdes[0].first = polar(s + d*des[0].second - A.O);\n\tdes[1].first = polar(s + d*des[1].second - A.O);\n\treturn 2;\n}\n\nint intersect(pdd a, pdd b, pdd u, pdd v, pdd &des){\n\tif (abs(b^v) < EPS) return 0;\n\tdes = pdd(((a - u) ^ v) / (v^b), ((a - u) ^ b) / (v^b));\n\treturn 1;\n}\n\ndouble dist(const pdd &A, const pdd &p, const pdd &d){\n\tif( size(A-p) <= EPS ) return 0;\n\telse if( size(d) <= EPS ) return size(A-p);\n\tdouble sina = ((A-p) ^ d) / size(A-p) / size(d);\n\tdouble cosa = ((A-p) * d) / size(A-p) / size(d);\n\tdouble r = abs(size(A - p) * sina), e = size(A - p) * cosa;\n\tif (0 < e && e < size(d));\n\telse r = min(size(A - p), size(A - p - d));\n\treturn r;\n}\n\nint get_circle(pdd a, pdd b, double R, circle des[2]){\n\tpdd m = (a+b) * 0.5, t = (b-a);\n\tdouble d = (R*R - size2(m-a));\n\tif( d < 0 ) return 0;\n\td = sqrt(d);\n\tpdd p = norm(pdd(t.second, -t.first));\n\tdes[0] = circle(m + p*d, R);\n\tdes[1] = circle(m - p*d, R);\n\treturn 2;\n}\n\nint get_circle(pdd p0, pdd p1, pdd p2, circle &des){\n\tpdd a = (p0+p1) * 0.5, b = r90(p0-p1);\n\tpdd u = (p0+p2) * 0.5, v = r90(p0-p2), R;\n\tif( !intersect(a, b, u, v, R) ) return 0;\n\tdes = circle(a+b*R.first, size(a+b*R.first - p0));\n\treturn 1;\n}\n\nstruct v3{\n\tdouble x, y, z;\n\tv3(){}\n\tv3(double x, double y, double z) :x(x), y(y), z(z){}\n\n\tv3 operator-()const{ return v3(-x, -y, -z); }\n\tv3 operator-(const v3 &l)const{ return v3(x - l.x, y - l.y, z - l.z); }\n\tv3 operator+(const v3 &l)const{ return v3(x + l.x, y + l.y, z + l.z); }\n\tv3 operator*(const double c)const{ return v3(x*c, y*c, z*c); }\n\tdouble operator*(const v3 &l)const{ return x*l.x + y*l.y + z*l.z; }\n\tv3 operator^(const v3 &l)const{ return v3(y*l.z - z*l.y, z*l.x - x*l.z, x*l.y - y*l.x); }\n\n\tdouble size(){ return sqrt(sq(x) + sq(y) + sq(z)); }\n\tdouble size2(){ return sq(x) + sq(y) + sq(z); }\n\n\tv3 norm(){\n\t\tdouble p = size();\n\t\treturn v3(x / p, y / p, z / p);\n\t}\n\tvoid print(){ printf(\"%lf %lf %lf\\n\", x, y, z); }\n\n\tbool operator < (const v3 &l) const {\n\t\tif (abs(x - l.x) >= EPS) return x < l.x;\n\t\tif (abs(y - l.y) >= EPS) return y < l.y;\n\t\tif (abs(z - l.z) >= EPS) return z < l.z;\n\t\treturn false;\n\t}\n\tbool operator == (const v3 &l) const {\n\t\treturn abs(x - l.x) < EPS && abs(y - l.y) < EPS && abs(z - l.z) < EPS;\n\t}\n};\n\nstruct Quad{\n\tdouble a;\n\tv3 v;\n\tQuad(double a, v3 v) :a(a), v(v){}\n\tQuad operator * (const double &c)const{ return Quad(a * c, v * c); }\n\tQuad operator~() const { return Quad(-a, -v); }\n\tQuad operator-() const { return Quad(a, -v) * (1 / (sq(a) + sq(v.x) + sq(v.y) + sq(v.z))); }\n\tQuad operator * (const Quad &l)const{ return Quad(a*l.a - v*l.v, l.v*a + v*l.a + (v^l.v)); }\n\n\tv3 apply(v3 p){\n\t\treturn ((*this) * Quad(0, p) * -(*this)).v;\n\t}\n};\n\ndouble size(v3 a){ return a.size(); }\ndouble size2(v3 a){ return a.size2(); }\nv3 norm(v3 a){ return a.norm(); }\nv3 unit(double a, double b){ return v3(cos(a)*cos(b),sin(a)*cos(b),sin(b)); }\n\nQuad set_rotate(v3 axis, double a){\n\treturn Quad(cos(a / 2), axis.norm() * sin(a / 2));\n}\n\nstruct sphere{\n\tsphere(v3 O, double r):O(O), r(r){}\n\tv3 O;\n\tdouble r;\n};\n\n//sphere - line\nint intersect(sphere A, v3 s, v3 d, double des[2]){\n\tdouble c = (A.O - s).size2() - sq(A.r), b = d * (s - A.O), a = d.size2();\n\n\tif (b*b - a*c < 0) return 0;\n\tdes[0] = (-b + sqrt(b*b - a*c)) / a;\n\tdes[1] = (-b - sqrt(b*b - a*c)) / a;\n\treturn 2;\n}\n\n// face - face\nint intersect(v3 u, v3 v, v3 p, v3 q, v3 &s, v3 &d){ // v.size(), q.size() == 1\n\tif( abs(v*q-1) < EPS ) return 0;\n\td = v^q;\n\tdouble t = v*q;\n\ts = v*((u*v - p*q*t) / (1-t*t)) + q*((u*v*t - p*q) * 1.0 / (t*t-1));\n\treturn 1;\n}\n\n// face - line\nint intersect(v3 u, v3 v, v3 p, v3 q, v3 &s){ // v.size(), q.size() == 1\n\tif( abs(q*v) <= EPS ) return 0;\n\ts = p + q * (((p-u)*v) / (q*v));\n\tprintf(\"%.10lf\\n\", (u-s)*v);\n\treturn 1;\n}\n\nbool isintersect(pdd &a, pdd &b, pdd &u, pdd &v){\n\tif( (((u-a)^(b-a)) < 0) ^ (((v-a)^(b-a)) < 0) );\n\telse return false;\n\tif( (((a-u)^(v-u)) < 0) ^ (((b-u)^(v-u)) < 0) ) return true;\n\telse return false;\n}\n\ndouble area(circle C, double s, double e)\n{\n\tdouble p = C.O.first, q = C.O.second, r = C.r;\n\treturn (p*r*(sin(e) - sin(s)) + q*r*(cos(s)-cos(e)) + r*r*(e-s)) * 0.5;\n}\n\ntemplate\nvoid convex_hull(vector &L, vector &R){\n\tint mn = 0;\n\tfor(int i = 1; i < L.size(); i++){\n\t\tif( L[mn] < L[i] ) mn = i;\n\t}\n\tswap(L[mn], L[0]);\n\tT t = L[0];\n\tfor(int i = 1; i < L.size(); i++) L[i] = L[i] - L[0];\n\tL[0] = T(0, 0);\n\tsort(L.begin()+1, L.end(), [](T l, T r){\n\t\t\tif( sign(l^r) != 0 ) return sign(l^r) < 0;\n\t\t\treturn size(l) < size(r);\n\t\t\t});\n\tfor(T c : L){\n\t\twhile(R.size() >= 2 && sign((R[R.size()-2] - R.back()) ^ (c - R.back())) <= 0 ) R.pop_back();\n\t\tR.push_back(c);\n\t}\n\tfor(T &c : R) c = c + t;\n}\n\ndouble area(pdd A[4], pdd B[4]){\n\tvector L;\n\tfor(int i = 0; i < 3; i++) L.push_back(A[i]);\n\tfor(int i = 0; i < 3; i++) L.push_back(B[i]);\n\tfor(int i = 0; i < 3; i++){\n\t\tfor(int j = 0; j < 3; j++){\n\t\t\tpdd R;\n\t\t\tif( !intersect(A[i], A[i+1]-A[i], B[j], B[j+1] - B[j], R) ) continue;\n\t\t\tif( R.first < -EPS || R.first > 1+EPS || R.second < -EPS || R.second > 1+EPS ) continue;\n\t\t\tL.push_back(A[i] + (A[i+1]-A[i]) * R.first);\n\t\t}\n\t}\n\n\tvector tmp;\n\tswap(tmp, L);\n\tfor(pdd c : tmp){\n\t\tbool ch = 1;\n\t\tfor(int i = 0; ch && i < 3; i++){\n\t\t\tif( ((A[i+1]-A[i]) ^ (c-A[i])) > EPS ) ch = 0;\n\t\t}\n\t\tfor(int i = 0; ch && i < 3; i++){\n\t\t\tif( ((B[i+1]-B[i]) ^ (c-B[i])) > EPS ) ch = 0;\n\t\t}\n\t\tif( ch ) L.push_back(c);\n\t}\n\tif( L.size() == 0 ) return 0;\n\n\tsort(L.begin(), L.end());\n\tL.resize(unique(L.begin(), L.end()) - L.begin());\n\n\tvector R; convex_hull(L, R);\n\n\tdouble ans = 0;\n\tR.push_back(R[0]);\n\tfor(int i = 0; i+1 < R.size(); i++) ans += R[i+1] ^ R[i];\n\treturn ans;\n}\n\ncircle make_circle(vector Q){\n\tif( Q.size() == 0 ) return circle(pdd(0, 0), 0);\n\tif( Q.size() == 1 ) return circle(Q[0], 0);\n\tcircle res;\n\tfor(int i = 0; i < Q.size(); i++){\n\t\tswap(Q.back(), Q[i]);\n\t\tres = circle((Q[0]+Q[1]) * 0.5, size(Q[0]-Q[1])/2);\n\t\tbool ch = 1; for(pdd c : Q) if( size2(c-res.O) > sq(res.r) + EPS ) ch = 0;\n\t\tif( ch ) return res;\n\t\tswap(Q.back(), Q[i]);\n\t}\n\tget_circle(Q[0], Q[1], Q[2], res);\n\treturn res;\n}\n\ncircle smallest_circle(vector &P, vector &Q, int N)\n{\n\tcircle c = make_circle(Q);\n\tif( N == 0 || Q.size() >= 3 ) return c;\n\tfor(int i = 0; i < N; i++){\n\t\tif( size2(c.O - P[i]) > sq(c.r) ){\n\t\t\tQ.push_back(P[i]);\n\t\t\tc = smallest_circle(P, Q, i);\n\t\t\tQ.pop_back();\n\t\t}\n\t}\n\treturn c;\n}\n\nvoid convex_hull(vector &L, vector &R, vector &O, vector &D, vector &X)\n{\n\tint N = L.size();\n\tstatic bool chk[1005][1005];\n\tstatic bool in[1005];\n\tfor(int i = 0; i < N; i++) for(int j = 0; j < N; j++) chk[i][j] = 0, in[i] = 0;\n\n\tint q1 = 0, q2 = 1;\n\tqueue Q;\n\tvector> F;\n\tfor(int i = 1; i < N; i++) if( L[i].z < L[q1].z ) q1 = i, q2 = 0;\n\tfor(int i = 0; i < N; i++){\n\t\tif( i == q1 ) continue;\n\t\tif( (norm(L[i] - L[q1]) * v3(0, 0, 1)) < (norm(L[q2]-L[q1]) * v3(0, 0, 1)) ) q2 = i;\n\t}\n\tQ.push(pii(q1, q2)); chk[q1][q2] = 1;\n\twhile(Q.size()){\n\t\tpii f = Q.front(); Q.pop();\n\t\tint a = f.first, b = f.second, c = -1;\n\t\tin[a] = in[b] = 1;\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tif( i == a || i == b ) continue;\n\t\t\tif( c == -1 || ((L[i]-L[a])^(L[c]-L[a]))*(L[b]-L[a]) < 0 ) c = i;\n\t\t}\n\t\tif( !chk[c][b] ) Q.push(pii(c, b)), chk[c][b] = 1;\n\t\tif( !chk[a][c] ) Q.push(pii(a, c)), chk[a][c] = 1;\n\t\tif( a > b ) swap(a, b); \n\t\tif( b > c ) swap(b, c); \n\t\tif( a > b ) swap(a, b);\n\t\tF.emplace_back(pii(a, b), c);\n\t}\n\tsort(F.begin(), F.end());\n\tF.resize(unique(F.begin(), F.end()) - F.begin());\n\n\tfor(auto f : F){\n\t\tint a = f.first.first, b = f.first.second, c = f.second;\n\t\tO.push_back(L[a]); X.push_back(norm(L[a] - L[b]));\n\t\tD.push_back(norm((L[a]-L[b])^(L[c]-L[b])));\n\t}\n\tfor(int i = 0; i < N; i++) if( in[i] ) R.push_back(L[i]);\n}\n\n// C : conter_clockwise(C[0] == C[N])\n// return highest point in C <- P(clockwise) or -1 in convex\n// recommend : strongly convex, C.size() >= 3, C[i] != P\n// up^down == 0 : on line\n\nint convex_tangent(vector &C, pii P, int up = 1){\n\tauto sign = [&](ll c){ return c > 0 ? up : c == 0 ? 0 : -up; };\n\tauto local = [&](pii P, pii a, pii b, pii c) { \n\t\treturn sign((a - P) ^ (b - P)) <= 0 && sign((b - P) ^ (c - P)) >= 0; \n\t};\n\n\tassert(C.size() >= 2);\n\tint N = C.size()-1, s = 0, e = N, m;\n\tif( local(P, C[1], C[0], C[N-1]) ) return 0;\n\t//\tfor(int i = 1; i < N; i++) if( local(P, C[i-1], C[i], C[i+1])) return i;\n\twhile(s+1 < e){\n\t\tm = (s+e) / 2;\n\t\tif( local(P, C[m-1], C[m], C[m+1]) ) return m;\n\t\tif( sign((C[s]-P) ^ (C[s+1]-P)) < 0 ){ // up\n\t\t\tif( sign((C[m]-P) ^ (C[m+1]-P)) > 0 ) e = m;\n\t\t\telse if( sign((C[m]-P) ^ (C[s]-P)) > 0 ) s = m;\n\t\t\telse e = m;\n\t\t}\n\t\telse{ // down\n\t\t\tif( sign((C[m]-P) ^ (C[m+1]-P)) < 0 ) s = m;\n\t\t\telse if( sign((C[m]-P) ^ (C[s]-P)) < 0 ) s = m;\n\t\t\telse e = m;\n\t\t}\n\t}\n\tif( s && local(P, C[s-1], C[s], C[s+1]) ) return s;\n\tif( e != N && local(P, C[e-1], C[e], C[e+1]) ) return e;\n\treturn -1;\n}\n\n// lo = 1 : lower_convex\n\nint cmp_flag = 0, cmp_lo = 0;\nstruct Convex{\n\tstruct line{\n\t\tline(pii x){\n\t\t\tif( !cmp_flag ) s = x;\n\t\t\telse d = x;\n\t\t}\n\t\tline(pii s, pii d):s(s), d(d){}\n\t\tpii s, d;\n\t\tbool operator<(const line &l)const{\n\t\t\tif( !cmp_flag ) return s < l.s;\n\t\t\treturn cmp_lo ? d/l.d > 0 : d/l.d < 0;\n\t\t}\n\t};\n\tint lo;\n\tset C;\n\n\tvoid add(pii p){\n\t\tcmp_flag = 0;\n\t\tauto pos = [&](ll x){ return lo ? x >= 0 : x <= 0; };\n\t\tauto neg = [&](ll x){ return lo ? x <= 0 : x >= 0; };\n\n\t\tauto e = C.upper_bound(line(p)), d = e;\n\t\tif( e != C.end() && d != C.begin() ){ d--;\n\t\t\tif( pos((e->s - d->s)/(p - d->s)) ) return;\n\t\t}\n\t\tif( lo && e == C.end() && C.size() && C.rbegin()->s.first == p.first ) return;\n\t\tif( !lo && e == C.begin() && C.size() && e->s.first == p.first ) return;\n\t\twhile(1){\n\t\t\td = C.upper_bound(line(p)), e = d;\n\t\t\tif( d == C.end() || ++e == C.end()) break;\n\t\t\tif( neg((d->s - p)/(e->s - p)) ) C.erase(d);\n\t\t\telse break;\n\t\t}\n\t\twhile(1){\n\t\t\td = C.upper_bound(line(p)), e = d;\n\t\t\tif( d == C.begin() || --e == C.begin()) break;\n\t\t\td = e; --e; if( pos((d->s - p)/(e->s - p)) ) C.erase(d);\n\t\t\telse break;\n\t\t}\n\t\tif( lo && C.size() && C.rbegin()->s.first == p.first) C.erase(--C.end());\n\t\tif( !lo && C.size() && C.begin()->s.first == p.first) C.erase(C.begin());\n\t\td = C.upper_bound(line(p));\n\t\tif( d != C.begin() ){ \n\t\t\te = prev(d);\n\t\t\tline t = line(e->s, p - e->s);\n\t\t\tC.erase(e); C.insert(t);\n\t\t}\n\t\tif( d == C.end() ) C.insert(line(p, pii(0, lo? 1 : -1))); \n\t\telse C.insert(line(p, d->s - p));\n\t}\n\t// x * -m.second + y * m.first minimize\n\tll get_mn(pii m){ \n\t\tcmp_flag = 1; cmp_lo = lo;\n\t\tauto d = C.lower_bound(m);\n\t\treturn (ll)d->s.first * -m.second + (ll)d->s.second * m.first;\n\t}\n};\n\nnamespace halfplane_intersection{\n\tconst int INF = 1e9;\n\tstruct line{\n\t\tline(pii u, pii v):u(u), v(v){}\n\t\tpii u, v;\n\t};\n\tdouble C(line A, line B){\n\t\treturn B.v / A.v == 0 ? 1e18 : ((A.u - B.u)/B.v) / (double)(B.v/A.v);\n\t}\n\tbool V(line A, line B, double cur){\n\t\tdouble l = (cur - A.u.first) / A.v.first * A.v.second + A.u.second;\n\t\tdouble r = (cur - B.u.first) / B.v.first * B.v.second + B.u.second;\n\t\treturn l + EPS >= r;\n\t}\n\tpdd W(line A, line B){\n\t\treturn (pdd)A.v * C(A, B) + (pdd)A.u;\n\t}\n\n\tvoid chain(vector &X, int l, int r, int up){\n\t\tvector R; \n\t\tsort(X.begin(), X.end(), [&](line l, line r){ return l.v/r.v*up < 0; });\n\t\tR.emplace_back(pii(l, 0), pii(0, up));\n\t\tX.emplace_back(pii(r, 0), pii(0, -up));\n\t\tfor(line c : X){\n\t\t\twhile(R.size() >= 2 && C(R[R.size()-2], R.back()) >= C(R[R.size()-2], c)) R.pop_back();\n\t\t\tR.push_back(c);\n\t\t} swap(R, X);\n\t\tX.pop_back(); X.erase(X.begin());\n\t}\n\n\tint reduce_left(vector &X, vector &Y, double &cur){\n\t\tauto rv = [](vector &t){ reverse(t.begin(), t.end()); };\n\t\trv(X), rv(Y);\n\t\twhile(X.size() && Y.size()){\n\t\t\tif( V(X.back(), Y.back(), cur) ) break;\n\t\t\tif( X.back().v/Y.back().v >= 0 ) return 0;\n\t\t\tcur = W(X.back(), Y.back()).first;\n\t\t\twhile(X.size() >= 2 && !V(X[X.size()-2], X.back(), cur)) X.pop_back();\n\t\t\twhile(Y.size() >= 2 && V(Y[Y.size()-2], Y.back(), cur)) Y.pop_back();\n\t\t}\n\t\trv(X); rv(Y);\n\t\treturn 1;\n\t}\n\tint reduce_right(vector &X, vector &Y, double &cur){\n\t\twhile(X.size() && Y.size()){\n\t\t\tif( V(X.back(), Y.back(), cur) ) break;\n\t\t\tif( X.back().v/Y.back().v <= 0 ) return 0;\n\t\t\tcur = W(X.back(), Y.back()).first;\n\t\t\twhile(X.size() >= 2 && !V(X[X.size()-2], X.back(), cur)) X.pop_back();\n\t\t\twhile(Y.size() >= 2 && V(Y[Y.size()-2], Y.back(), cur)) Y.pop_back();\n\t\t}\n\t\treturn 1;\n\t}\n\t\n\t// U + kV, CCW(Ex. ->: up, <-: down)\n\t// 0 : empty, 1 : convex\n\t// R -> 0: empty, 1: ccw order closed points\n\t// added -1e9 ~ 1e9 x -1e9 ~ 1e9 bounding box\n\n\tint run(vector &U, vector &V, vector &R, int l = -INF, int r = INF, int u = -INF, int d = INF){\n\t\tU.emplace_back(0, u); V.emplace_back(1, 0);\n\t\tU.emplace_back(0, d); V.emplace_back(-1, 0);\n\n\t\tvector X, Y; // X : up convex, Y : down convex\n\t\tint N = V.size();\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tif( V[i].first == 0 ){\n\t\t\t\tif( V[i].second > 0 ) r = min(r, U[i].first);\n\t\t\t\telse l = max(l, U[i].first);\n\t\t\t}\n\t\t\telse if( V[i].first < 0 ) X.emplace_back(U[i], -V[i]);\n\t\t\telse Y.emplace_back(U[i], V[i]); \n\t\t}\n\t\tchain(X, l, r, 1);\n\t\tchain(Y, l, r, -1);\n\n\t\tdouble left = l, right = r;\n\t\tif( !reduce_right(X, Y, right) ) return 0;\n\t\treduce_left(X, Y, left);\n\n\t\treverse(X.begin(), X.end());\n\t\tvector L;\n\t\tif( left == l ) L.emplace_back(pii(l, 0), pii(0, 1));\n\t\tfor(line c : Y) L.push_back(c);\n\t\tif( right == r ) L.emplace_back(pii(r, 0), pii(0, -1));\n\t\tfor(line c : X) L.push_back(c);\n\n\t\tfor(int i = 0; i+1 < L.size(); i++) R.push_back(W(L[i], L[i+1]));\n\t\tR.push_back(W(L.back(), L[0]));\n\t\tR.resize(unique(R.begin(), R.end()) - R.begin());\n\t\treturn 1;\n\t}\n};\n\nnamespace halfplane_intersection2{\n\tbool cw(pdd y, pdd z){ return y/z <= 0; };\n\tbool ccw(pdd y, pdd z){ return y/z >= 0; };\n\n\tvoid chain(vector &X, bool (*f)(pdd,pdd), int l, int r){\n\t\tvector t;\n\t\tsort(X.begin(), X.end());\n\t\tfor(pdd c : X){\n\t\t\twhile(t.size() >= 2 && f(t.back()-t[t.size()-2], c-t[t.size()-2])) t.pop_back();\n\t\t\tt.push_back(c);\n\t\t}\n\t\tfor(int m : {-l, -r}){\n\t\t\twhile(t.size() >= 2 && f(t.back()-t[t.size()-2],pdd(1, m))) t.pop_back();\n\t\t\treverse(t.begin(), t.end());\n\t\t}\n\t\tswap(t, X);\n\t}\n\n\tpdd ltop(pdd u, pdd v, int rv = -1){ return pdd(v.second / v.first * rv, u.second - u.first * (v.second / v.first)); }\n\n\tbool tangent(vector &X, vector &Y, int l, int r, pii R[2]){\n\t\tint ch = 0;\n\t\tvector P, Q;\n\n\t\tP.emplace_back(1, -r); Q.emplace_back(1, -l);\n\t\tfor(int i = 0; i+1 < X.size(); i++) P.push_back(X[i+1] - X[i]);\n\t\tfor(int i = 0; i+1 < Y.size(); i++) Q.push_back(Y[i+1] - Y[i]);\n\t\tP.emplace_back(1, -l), Q.emplace_back(1, -r);\n\n\t\tif( (X[0] - Y.back()) / pdd(1, -r) <= EPS ) R[0] = pii(-1, Y.size()), ch |= 1;\n\t\tint x = 0, y = Y.size()-1;\n\t\twhile(x < X.size() && y >= 0 ){\n\t\t\tpdd d = Y[y] - X[x];\n\t\t\tif( d/P[x] >= -EPS && d/P[x+1] <= EPS && d/Q[y] <= EPS && d/Q[y+1] >= -EPS) R[1] = pii(x, y), ch |= 2;\n\t\t\tif( ch != 3 && d/P[x] <= EPS && d/P[x+1] >= -EPS && d/Q[y] >= -EPS && d/Q[y+1] <= EPS) R[0] = pii(x, y), ch |= 1;\n\t\t\t\n\t\t\tif( ccw(P[x+1], Q[y]) ) x++;\n\t\t\telse y--;\n\t\t}\n\t\tif( (X.back() - Y[0])/(pdd(1, -l)) <= EPS ) R[1] = pii(X.size(), -1), ch |= 2;\n\t\tif( ch != 3 ) printf(\"%d\\n\", ch);\n\t\treturn ch == 3;\n\t}\n\n\t// U + kV, CCW(Ex. ->: up, <-: down)\n\t// 0 : empty, 1 : convex\n\t// R -> 0: empty, 1: ccw order closed points\n\t// added -1e9 ~ 1e9 x -1e9 ~ 1e9 bounding box\n\n\tconst int INF = 1e9;\n\tint run(vector &U, vector &V, vector &R, int l = -INF, int r = INF, int u = -INF, int d = INF){ \n\t\tU.emplace_back(0, u); V.emplace_back(1, 0);\n\t\tU.emplace_back(0, d); V.emplace_back(-1, 0);\n\n\t\tvector X, Y; // X : up convex, Y : down convex\n\t\tint N = V.size();\n\t\tfor(int i = 0; i < N; i++){\n\t\t\tif( V[i].first == 0 ){\n\t\t\t\tif( V[i].second > 0 ) r = min(r, U[i].first);\n\t\t\t\telse l = max(l, U[i].first);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif( V[i].first < 0 ) X.push_back(ltop(U[i], V[i], 1));\n\t\t\telse Y.push_back(ltop(U[i], V[i], 1)); \n\t\t}\n\t\tchain(X, cw, l, r);\n\t\tchain(Y, ccw, r, l);\n\n\t\tpii t[2];\n\t\tif( !tangent(X, Y, l, r, t) ) return 0;\n\n\t\tfor(int i = t[0].first; i < t[1].first; i++){\n\t\t\tif( i == -1 ) R.push_back(ltop(X[0], pdd(1, -r)));\n\t\t\telse if( i+1 == X.size() ) R.push_back(ltop(X.back(), pdd(1, -l)));\n\t\t\telse R.push_back(ltop(X[i], X[i+1] - X[i]));\n\t\t}\n\t\tif( t[1].second != -1 ) R.push_back(ltop(X[t[1].first], X[t[1].first] - Y[t[1].second]));\n\t\tfor(int i = t[1].second; i < t[0].second; i++){\n\t\t\tif( i == -1 ) R.push_back(ltop(Y[0], pdd(1, -l)));\n\t\t\telse if( i+1 == Y.size() ) R.push_back(ltop(Y.back(), pdd(1, -r)));\n\t\t\telse R.push_back(ltop(Y[i], Y[i+1] - Y[i]));\n\t\t}\n\t\tif( t[0].first != -1 ) R.push_back(ltop(Y[t[0].second], X[t[0].first] - Y[t[0].second]));\n\t\treturn 2;\n\t}\n};\n\ndouble area(pdd A, pdd B, double R) {\n\tauto helper = [](pdd A, pdd B, double R){ return R*R*atan2(A^B, A*B) / 2; };\n\tauto is_valid = [](double x) { return 0 <= x && x <= 1; };\n\tdouble ans = 0, rv = 1;\n\tpdd C, D, res[2];\n\n\tif( size2(A) > size2(B) ) swap(A, B), rv = -1;\n\tif (size2(B) <= R*R) ans = (A^B) / 2;\n\telse if (size2(A) <= R*R) {\n\t\tif (!intersect(circle(pdd(0, 0), R), A, B-A, res)) ans = (A^B) / 2;\n\t\telse C = A + (B-A) * (is_valid(res[1].second)? res[1].second : res[0].second), ans = (A^C) / 2 + helper(C, B, R);\n\t}\n\telse {\n\t\tif (!intersect(circle(pdd(0, 0), R), A, B-A, res) || \n\t\t\t\tres[0].second < 0 && res[1].second < 0 || res[0].second > 1 && res[1].second > 1) ans = helper(A, B, R);\n\t\telse C = A + (B-A) * res[0].second, D = A + (B-A) * res[1].second, ans = helper(A, C, R) + (C^D) / 2 + helper(D, B, R);\n\t}\n\treturn ans * rv;\n}\n\n// == // == // == // == // == // == // == // == // == // == // == // == // == // == // == // == // == // == // == // == // == // == //\n\nconst int MX = 400005;\n\npii D[MX];\n\nint sign(pii x){ return x < pii(0, 0)? 1 : 0; }\nauto cmp = [](pii x, pii y){ return sign(x) != sign(y) ? sign(x) < sign(y) : x/y < 0; };\n\nconst int L = 1000000;\ndouble solve(pii *D, int N, pii O){\n\tsort(D+1, D+N+1, cmp);\n\tfor(int i = 1; i <= N; i++) D[N+i] = D[i];\n\tvector U, V;\n\tfor(int i = 1; i <= N; i++){\n\t\tif( D[i]/D[i+1] < 0 ) U.push_back(D[i+1]), V.push_back(D[i] - D[i+1]);\n\t\telse if( D[i]/D[i+1] == 0 ) return 0;\n\t\telse U.push_back(D[i]), V.push_back(D[i+1] - D[i]);\n\t}\n\tfor(int l = 1, r = 1; l <= N; l++){\n\t\twhile(r <= l || r < N+l && D[r]/D[l] > 0 ) r++;\n\t\tif( r != N+l && D[r]/D[l] == 0 ) return 0;\n\t\tif( r-1 != l ){\n\t\t\tU.push_back(D[r-1]), V.push_back(D[l] - D[r-1]);\n\t\t}\n\t}\n\tvector R;\n\tif(!halfplane_intersection::run(U, V, R, -L-O.first, L-O.first, -L-O.second, L-O.second)) return 0;\n\tdouble ans = R.back() / R[0];\n\tfor(int i = 0; i+1 < R.size(); i++) ans += R[i] / R[i+1];\n\treturn ans/2;\n}\n\nint main()\n{\n\tint TC;\n\tscanf(\"%d\", &TC);\n\tfor(int tt = 1; tt <= TC; tt++){\n\t\tint N;\n\t\tscanf(\"%d\", &N);\n\t\tfor(int i = 1; i <= N; i++) scanf(\"%d%d\", &D[i].first, &D[i].second);\n\t\tfor(int i = 2; i <= N; i++) D[i] = D[i] - D[1];\n\t\tdouble ans = solve(D+1, N-1, D[1]);\n\t\tprintf(\"%.10lf\\n\", ans);\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "39b44392fa7b49b15c9f4e920583d628", "src_uid": "6afe0718ad89e3fd51a456e0144c538d", "difficulty": 3300.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\ntypedef double db;\nconst db eps=1e-6;\nint sign(db k){if (k>eps) return 1; else if (k<-eps) return -1; return 0;}\nint cmp(db k1,db k2){return sign(k1-k2);}\nstruct point{\n \n db x,y;\n point operator + (const point &k1) const{return (point){k1.x+x,k1.y+y};}\n point operator - (const point &k1) const{return (point){x-k1.x,y-k1.y};}\n point operator * (db k1) const{return (point){x*k1,y*k1};}\n point operator / (db k1) const{return (point){x/k1,y/k1};}\n bool operator < (const point k1) const{\n int a=cmp(x,k1.x);\n if (a==-1) return 1; else if (a==1) return 0; else return cmp(y,k1.y)==-1;\n }\n int getP() const{return sign(y)==1||(sign(y)==0&&sign(x)==1);}\n};\ndb cross(point k1,point k2){return k1.x*k2.y-k1.y*k2.x;}\ndb dot(point k1,point k2){return k1.x*k2.x+k1.y*k2.y;}\nint compareangle (point k1,point k2){\n return k1.getP()0);\n}\npoint getLL(point k1,point k2,point k3,point k4){\n db w1=cross(k1-k3,k4-k3),w2=cross(k4-k3,k2-k3); return (k1*w2+k2*w1)/(w1+w2);\n}\nstruct line{\n point p[2];\n line(point k1,point k2){p[0]=k1; p[1]=k2;}\n line(){};\n point& operator [] (int k){return p[k];}\n int include(point k){return sign(cross(p[1]-p[0],k-p[0]))>=0;}//\u975e\u4e25\u683c\u5305\u542b\u3002\n point dir(){return p[1]-p[0];}\n};\npoint getLL(line k1,line k2){return getLL(k1[0],k1[1],k2[0],k2[1]);}\nint parallel(line k1,line k2){return sign(cross(k1.dir(),k2.dir()))==0;}\nint sameDir(line k1,line k2){return parallel(k1,k2)&&sign(dot(k1.dir(),k2.dir()))==1;}\nint operator < (line k1,line k2){\n if (sameDir(k1,k2)) return k2.include(k1[0]);\n return compareangle(k1.dir(),k2.dir());\n}\nint checkpos(line k1,line k2,line k3){return k3.include(getLL(k1,k2));}\nvector getHL(vector &L){ // \u6c42\u534a\u5e73\u9762\u4ea4 , \u534a\u5e73\u9762\u662f\u9006\u65f6\u9488\u65b9\u5411 , \u8f93\u51fa\u6309\u7167\u9006\u65f6\u9488\n sort(L.begin(),L.end()); deque q;\n for (int i=0;i<(int)L.size();i++){\n if (i&&sameDir(L[i],L[i-1])) continue;\n while (q.size()>1&&!checkpos(q[q.size()-2],q[q.size()-1],L[i])) q.pop_back();\n while (q.size()>1&&!checkpos(q[1],q[0],L[i])) q.pop_front();\n q.push_back(L[i]);\n }\n while (q.size()>2&&!checkpos(q[q.size()-2],q[q.size()-1],q[0])) q.pop_back();\n while (q.size()>2&&!checkpos(q[1],q[0],q[q.size()-1])) q.pop_front();\n vectorans; for (int i=0;i A){ // \u591a\u8fb9\u5f62\u7528 vector \u8868\u793a , \u9006\u65f6\u9488\n db ans=0;\n for (int i=0;i convexHull(vectorps){\n int n = ps.size();if(n<=1)return ps;\n sort(ps.begin(),ps.end());\n vector qs(n*2);int k=0;\n for(int i=0;i1&&sign(cross(qs[k-1]-qs[k-2],ps[i]-qs[k-2]))<=0)--k;\n for(int i=n-2,t=k;i>=0;qs[k++]=ps[i--])\n while (k>t&&sign(cross(qs[k-1]-qs[k-2],ps[i]-qs[k-2]))<=0)--k;\n qs.resize(k-1);\n return qs;\n}\nint t,n;\npoint p[400005];\nvector l;\nvector v;\n\nvoid add(const point& x,const point& y){\n if (sign(cross(y-x,(point){0,0}-x)>0)) l.push_back(line(x,y));\n else l.push_back(line(y,x));\n}\nint main(){\n scanf(\"%d\",&t);\n while (t--){\n l.clear();v.clear();\n scanf(\"%d\",&n);\n for(int i=0;i0))j++;\n if(j0))p++;\n// if(p0)l.push_back(line(v[i],v[p]));\n// else l.push_back(line(v[p],v[i]));\n// }\n }\n l=getHL(l);\n if(l.size()<3){printf(\"0\\n\");continue;}\n v.clear();\n m=l.size();\n for(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ndouble const pi=3.1415926536;\nint main()\n{\n\tint p[4],a,b;\n\tfor(int i=0;i<4;i++)\n\tcin>>p[i];\n\tcin>>a>>b;\n\tint s=0;\n\tfor(int i=a;i<=b;i++)\n\t{\n\t\tset c;\n\t\tint r=0;\n\t\tfor(int z=0;z<4;z++)\n\t\tfor(int j=0;j<4;j++)\n\t\tfor(int k=0;k<4;k++)\n\t\tfor(int l=0;l<4;l++)\n\t\t{\n\t\t\tc.insert(p[z]);\n\t\t\tc.insert(p[j]);\n\t\t\tc.insert(p[k]);\n\t\t\tc.insert(p[l]);\n\t\t\tif(c.size()==4)\n\t\t\t{\n\t\t\t\tif((((i%p[z])%p[j])%p[k])%p[l]==i)\n\t\t\t\tr++;\n\t\t\t}\n\t\t\tc.erase(p[z]);\n\t\t\tc.erase(p[j]);\n\t\t\tc.erase(p[k]);\n\t\t\tc.erase(p[l]);\n\t\t}\n\t\tif(r>=7)\n\t\ts++;\n\t}\n\tcout<\n#include\n#include\n#include\n\nusing namespace std;\n\nmain()\n{\n int x,x1,x2,x3,x4,a,b;\n \n scanf(\"%d%d%d%d\",&x1,&x2,&x3,&x4);\n scanf(\"%d%d\",&a,&b);\n \n x=min(x1,x2);\n x=min(x,x3);\n x=min(x,x4);\n \n if(a\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#pragma warning(disable : 4996)\n\ntypedef long long LL;\ntypedef unsigned long long ULL;\ntypedef double DB;\ntypedef long double LDB;\ntypedef unsigned short USH;\nusing namespace std;\n\n#define input(f)\\\n freopen(f,\"r\",stdin)\n#define output(f)\\\n freopen(f,\"w\",stdout)\n#define VectorIn(Vector,size)\\\n for (int i=1, inp;i<=size;i++) cin >> inp, Vector.push_back(inp);\n#define VectorOut(Vector)\\\n for (int i=0;i T sqr(T x) { return x * x; }\ntemplate T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }\ntemplate T lcm(T a, T b) { return a / gcd(a, b) * b; }\nconst LL MOD = 1e9 + 7;\n\n//vector V;\n//vector used;\n//queue Q;\n//deque DEQ;\n//pair P;\n//list L;\n//map M;\nset S;\nLL n = 0, m = 0, k = 0;\nLL Min = -INF, Max = INF, prv = 0;\nint x = 0, y = 0, z = 0;\nLL ans = 0, nul = 0, le = 0, ri = 0, sum = 0;\nint start = 0, finish = 0;\nLL cnt = 0, now = 0;\nstring s, t;\n\nLL binPow(LL osn, LL step, LL mod)\n{\n\tif (step == 0)\n\t\treturn 1;\n\telse\n\t\tif (step % 2 == 0)\n\t\t{\n\t\t\tLL t = binPow(osn, step / 2, mod);\n\t\t\treturn t*t % mod;\n\t\t}\n\t\telse\n\t\t\treturn (LL)osn*binPow(osn, step - 2, mod) % mod;\n}\n\nint main()\n{\n\tsetlocale(0, \"\");\n\t//input(\"input.txt\"); output(\"output.txt\");\n\tios_base::sync_with_stdio(false);\n\tcin >> n;\n\tans = 1;\n\tfor (int i = 1; i < n + 1; i++)\n\t{\n\t\tans = ans*(n + i) % MOD * binPow(i, MOD - 1, MOD) % MOD;\n\t}\n\tcout << (ans-n) % MOD << endl;\n\treturn 0;\n}\n/* Sun Aug 06 2017 13:29:16 GMT+0300 (MSK) */\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "79eeafb0b5b06f686caa2a6d2f1037bd", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\nint main()\n{\n int p1,p2,p3,p4,a,b,i,n=0,count;\n cin>>p1>>p2>>p3>>p4>>a>>b;\n for(i=a;i<=b;i++)\n {\n count=0;\n if((((i%p1)%p2)%p3)%p4==i)\n count++;\n if((((i%p1)%p2)%p4)%p3==i)\n count++;\n if((((i%p1)%p4)%p3)%p2==i)\n count++;\n if((((i%p1)%p4)%p2)%p3==i)\n count++;\n if((((i%p1)%p3)%p4)%p2==i)\n count++;\n if((((i%p1)%p3)%p2)%p4==i)\n count++;\n if((((i%p2)%p1)%p3)%p4==i)\n count++;\n if((((i%p2)%p1)%p4)%p3==i)\n count++;\n if((((i%p2)%p3)%p4)%p1==i)\n count++;\n if((((i%p2)%p3)%p1)%p4==i)\n count++;\n if((((i%p2)%p4)%p3)%p1==i)\n count++;\n if((((i%p2)%p4)%p1)%p3==i)\n count++;\n if((((i%p3)%p2)%p1)%p4==i)\n count++;\n if((((i%p3)%p2)%p4)%p1==i)\n count++;\n if((((i%p3)%p1)%p4)%p2==i)\n count++;\n if((((i%p3)%p1)%p2)%p4==i)\n count++;\n if((((i%p3)%p4)%p1)%p2==i)\n count++;\n if((((i%p3)%p4)%p2)%p1==i)\n count++;\n if((((i%p4)%p1)%p2)%p3==i)\n count++;\n if((((i%p4)%p1)%p3)%p2==i)\n count++;\n if((((i%p4)%p2)%p1)%p3==i)\n count++;\n if((((i%p4)%p2)%p3)%p1==i)\n count++;\n if((((i%p4)%p3)%p1)%p2==i)\n count++;\n if((((i%p4)%p3)%p2)%p1==i)\n count++;\n if(count>=7)\n n++;\n }\n cout<\nusing namespace std ;\n\n#define ll long long\n#define pb push_back\n#define nikal_laura ios::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr);\n#define sc(c) scanf(\"%d\",&c);\n\nll n,x,q,t ;\n\nint main(){\n\n ios::sync_with_stdio(false); cin.tie(nullptr);\n ll l,n,r,low=0,ans1=0,ans2=0 ;\n vectorv;\n cin>>n>>l>>r;\n// low=n-(l-1);\n// ans1=low;\n// low=n-low;\n for(int i=0,j=1; i\n#define ll long long int\nusing namespace std;\n\nll n,s,i,j,s1=0,sum;\nint main(){\n\tcin>>n;\n\tvector a(n);\n\twhile(n>0){\n\t\ts=n%10;\n\t\ta[j]=s;\n\t\tj++;\n\t\tn=n/10;\n\t}\n\tfor(i=j-1;i>=0;i--){\n\t\t\tif(a[i]==0){\n\t\t\t\ts1=2*s1;\n\t\t\t}\n\t\t\telse{\n\t\t\t\tif(a[i]==1){\n\t\t\t\t\t\ts1=(2*s1+1);\n\t\t\t\t}\n\t\t\t\n\t\t\t}\n\t\t}\n\t\tif(s1==20){\n\t\t\tcout<<\"3\"<s1){\n\t\t\t\tcout<\n#include \nusing namespace std;\nunsigned long long c,Z,S,i,l,z,y,P,f;\nchar a[10000000000];\nint main()\n{cin>>a;\nf=0;\nP=0;\nif(strlen(a)%2==1)\nz=0;\nl=strlen(a)%2;\nfor(i=0;i1)\n f++;\nf--;\ncout<\n#include \nusing namespace std;\n\npair find_num_neg_zero(vector& v) {\n\tint num = 0;\n\tint zero = 0;\n\tfor (auto& n : v)\n\t\tif (n < 0)\n\t\t\t++num;\n\t\telse if (n == 0)\n\t\t\t++zero;\n\n\treturn make_pair(num, zero);\n}\n\nunsigned long long int min_use_coins(vector& v) {\n\tpair neg_zero = find_num_neg_zero(v);\n\tint constraint = neg_zero.first % 2;\n\n\tunsigned long long int coins = 0;\n\tfor (auto& n : v) {\n\t\tif (n < 0) {\n\t\t\tif (neg_zero.first > constraint) {\n\t\t\t\tcoins += abs(n) - 1; //go to -1\n\t\t\t\t--neg_zero.first;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (neg_zero.second != 0) {\n\t\t\t\t\tcoins += abs(n) - 1; // go to -1\n\t\t\t\t\t--neg_zero.second;\n\t\t\t\t}\n\t\t\t\telse \n\t\t\t\t\tcoins += abs(n) + 1; // go to 1\n\t\t\t}\n\t\t}\n\t\telse if (n > 0)\n\t\t\tcoins += n - 1;\n\t\telse\n\t\t\tcoins += 1;\n\t}\n\n\treturn coins;\n}\n\nint main() {\n\tint n;\n\tcin >> n;\n\tvector v(n);\n\tfor (int i = 0; i < n; ++i)\n\t\tcin >> v[i];\n\n\tcout << min_use_coins(v) << endl;\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c04e62fb3be64d7507942e73ec580e57", "src_uid": "d8ca1c83b431466eff6054d3b422ab47", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nint main(){\n\t\n\tint n,k,i,j,in,ans=0,now=0;\n\tscanf(\"%d%d\",&n,&k);\n\t\n\tvector pos;\n\t\n\tpos.push_back(0);\n\t\n\tfor( i=0 ; i=pos[i] ; i++ );\n\t\t\n\t\tif( pos[i-1]!=now ) now=pos[i-1];\n\t\telse break;\n\t\t\n//\t\tprintf(\"%d\\n\",now);\n\t}\n\t\n\tprintf(\"%d %d\\n\",now,ans);\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1f52cbf0e63e68a571f6ccac4bfabd98", "src_uid": "65699ddec8d0db2f58b83a0f64de6f6f", "difficulty": 2200.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\nvector combs(5000000), toAdd(5000000);\n\nvoid main(){\n\tbool doLoop;\n\tint n, d, c[50], temp, days=0, val=0, oval=0, tempd;\n\n\tcin >> n >> d;\n\tfor(int i=0 ; i> c[i];\n\n\tfor(int i=0 ; i\n#include \n#include \n#include \nusing namespace std;\n\nvoid main(){\n\tbool doLoop;\n\tint n, d, c[50], temp, days=0, val=0, oval=0, tempd;\n\tvector combs, toAdd;\n\n\tcin >> n >> d;\n\tfor(int i=0 ; i> c[i];\n\n\tfor(int i=0 ; i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define mp make_pair\n#define ll long long\n\nstatic bool m1[1000000000];\n\nint main(){\n\tios_base::sync_with_stdio(0);\n\tint n, a, b, c = 0, d;\n\tm1[0] = 1;\n\tcin >> n >> d;\n\tfor (int i = 0; i < n; ++i){\n\t\tcin >> a;\n\t\tfor (int j = 500000; j >= a; --j)\n\t\t\tif (m1[j - a])\n\t\t\t\tm1[j] = 1;\n\t}\n\ta = 0;\n\twhile (true){\n\t\tb = -1;\n\t\tfor (int i = 0; i < d; ++i)\n\t\t\tif (m1[i + 1 + a]){\n\t\t\t\tb = i + 1 + a;\n\t\t\t}\n\t\tif (b == -1)\n\t\t\tbreak;\n\t\ta = b;\n\t\t++c;\n\t}\n\tcout << a << ' ' << c << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "aa1cb9a218b72737959111da37a15c52", "src_uid": "65699ddec8d0db2f58b83a0f64de6f6f", "difficulty": 2200.0} {"lang": "GNU C++11", "source_code": "#include \n#define reg register\n#define ll long long\nusing namespace std;\ntemplate\ntp F() {\n\ttp x = 0, ch = getchar(), f = 0;\n\twhile(!isdigit(ch)) f |= (ch == '-'), ch = getchar();\n\twhile(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();\n\treturn f ? -x : x;\n}\ntemplate\nbool chkmax(tp &a, tp b) {\n\treturn a < b ? a = b, 1 : 0;\n}\ntemplate\nbool chkmin(tp &a, tp b) {\n\treturn a > b ? a = b, 1 : 0;\n}\ninline void file_io(string s) {\n\tfreopen((s + \".in\").c_str(), \"r\", stdin);\n\tfreopen((s + \".out\").c_str(), \"w\", stdout);\n}\nconst int MAXN = 35;\nint n, m, a[MAXN], tmpa[1 << 18], tmpb[1 << 18], siz1, siz2, mid, ans = 0;\nint (*rd)() = F;\ninline void dfs1(int now, int sum) {\n\tif(now > mid) {\n\t\ttmpa[++siz1] = sum;\n\t\treturn;\n\t}\n dfs1(now + 1 , sum), dfs1(now + 1 , (sum + a[now]) % m);\n}\ninline void dfs2(int now, int sum) {\n\tif(now > n) {\n\t\ttmpb[++siz2] = sum;\n\t\treturn;\n\t}\n\tdfs2(now + 1 , sum), dfs2(now + 1 , (sum + a[now]) % m);\n}\nint main() {\n\t// n = rd(), m = rd(), mid = n >> 1;\n\t// for(reg int i = 1; i <= n; ++i) a[i] = rd(), a[i] %= m;\n\t// dfs1(1, 0), dfs2(mid + 1, 0), sort(tmpa + 1, tmpa + siz1 + 1), sort(tmpb + 1, tmpb + siz2 + 1), ans = max(tmpa[siz1], tmpb[siz2]);\n\t// int l = siz1, r = 1;\n\t// for(r = 1; r <= siz2; ++r) {\n\t// \twhile(tmpa[l] + tmpb[r] >= m) l--;\n\t// \tans = max(ans, tmpa[l] + tmpb[r]);\n\t// }\n\t// ans = max(ans, (tmpa[siz1] + tmpb[siz2]) % m);\n\t// printf(\"%d\\n\", ans);\n scanf(\"%d%d\" , &n , &m);\n for(int i = 1 ; i <= n ; i ++) scanf(\"%d\", &a[i]) , a[i] %= m;\n mid = (n >> 1), dfs1(1 , 0), dfs2(mid + 1 , 0), sort(tmpa + 1, tmpa + siz1 + 1), sort(tmpb+ 1 , tmpb + siz2 + 1);\n ans = max(tmpa[siz1] , tmpb[siz2]);\n int l = siz1 , r = 1;\n for(r = 1 ; r <= siz2 ; r ++) {\n while(tmpa[l] + tmpb[r] >= m) l--;\n ans = max(ans , tmpa[l] + tmpb[r]);\n }\n ans = max(ans , (tmpa[siz1] + tmpb[siz2]) % m);\n printf(\"%d\\n\" , ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cbd73e6cb74ae58eb2b6c0ba825d34f1", "src_uid": "d3a8a3e69a55936ee33aedd66e5b7f4a", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\nint n,k,m,cnt,ans;\nint v[40],p[(1<<17)+4];\nset s;\nset::iterator it;\nvoid dfs(int x,int sum)\n{\n\tif(x>k)\n\t{\n\t\tp[++cnt]=sum,ans=max(ans,sum);\n\t\treturn ;\n\t}\n\tdfs(x+1,sum),dfs(x+1,(sum+v[x])%m);\n}\nint main()\n{\n\tscanf(\"%d%d\",&n,&m);\n\tint i;\n\tfor(i=1;i<=n;i++)\tscanf(\"%d\",&v[i]),v[i]%=m;\n\tk=n/2,dfs(1,0);\n\tfor(i=1;i<=cnt;i++)\ts.insert(p[i]);\n\tcnt=0,k=n,dfs(n/2+1,0);\n\tfor(i=1;i<=cnt;i++)\n\t{\n\t\tit=s.lower_bound(m-p[i]);\n\t\tif(it==s.begin())\tit=s.end();\n\t\tit--;\n\t\tans=max(ans,(p[i]+(*it))%m);\n\t}\n\tprintf(\"%d\",ans);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "06e100b9d90541b45d065367f5ee4270", "src_uid": "d3a8a3e69a55936ee33aedd66e5b7f4a", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include \n#define f first\n#define s second\n#define N 38\nusing namespace std;\ntypedef int ll;\ntypedef pair pii;\n\nint n, mod;\n\nint H[N], cnt, v[N];\n\nvector esq[N];\n\nll k, ans, g[N];\n\nunordered_map bit;\n\ninline void upd(int x, int v)\n{\n if(!x) return;\n\n for(int i = x; i < mod + 5; i+= (i&-i)) bit[i] += v;\n}\n\ninline int query(int x)\n{\n int sum = 0;\n\n for(int i = x; i > 0; i -= (i&-i)) sum += bit[i];\n\n return sum;\n}\n\nmain()\n{\n ios::sync_with_stdio(false); cin.tie(0);\n\n cin>>n>>mod;\n\n for(int i = 0; i < n; i++) cin>>v[i];\n\n int m = n/2;\n\n vector allmod;\n\n for(int mask = 1; mask <= ( (1<<(m + 1)) - 1) ; mask ++)\n {\n ll sum = 0;\n\n for(int i = 0; i <= m; i++)\n {\n if( (mask & (1<= ini && busca >= 0)\n {\n mid = (ini + fim)/2;\n\n if(allmod[mid] <= busca)\n {\n melhor1 = allmod[mid];\n\n posi = mid;\n\n ini = mid + 1;\n }\n\n else fim = mid - 1;\n }\n\n melhor1 = (melhor1 + sum)%mod;\n\n if(posi + 1 < allmod.size()) melhor2 = (allmod[posi + 1] + sum)%mod;\n\n ans = max(ans, max(melhor2, melhor1));\n \n }\n\n cout<\n\t\n\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\n\nconst int MAX_N = 1e8+10;\nconst int MAX_LOG = 62;\nconst ll INF = 1e14+1;\nconst ll MOD = 1e9+7;\n\nll n, m, aa[50], MAX; \nvector a, b,A,B;\n\nint main() {\n\tcin>>n>>m;\n\tfor(int i = 1 ; i <= n ; i++)\n\t\tcin>>aa[i];\n\tfor(int i = 1 ; i <= n/2 ; i++)\n\t\tA.push_back(aa[i]);\n\tfor(int i = n/2 +1 ; i <= n ; i++)\n\t\tB.push_back(aa[i]);\n\n\tfor(int i = 0 ; i < (1< f) {\n\t\t\tMAX = max(MAX, (b.back()+f)%m);\n\t\t}\n\t\tint ind = upper_bound(b.begin(), b.end(), m-f) - b.begin();\n\t\tind--;\n\t\tMAX=max(MAX, (b[ind]+f)%m);\n\t}\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector > vii;\ntypedef vector vs;\ntypedef string str;\ntypedef pair pii;\ntypedef list li;\n\n#define INF (int)1e9\n#define ll long long\n#define LINF (long long)1e18\n#define EPS 1e-9\n#define pb push_back\n#define ALL(x) (x).begin(), (x).end()\n#define SZ(x) ((int) (x).size())\n#define FORIE(i,x) for (typeof((x).begin()) i=(x).begin();i!=(x).end();i++)\n#define FOR(i,a,b) for(int i=a;i 16) buf; enum { kMaxDigits = 35 }; buf.reserve( kMaxDigits );int quotient = value;do {buf += \"0123456789abcdef\"[ std::abs( quotient % base ) ];quotient /= base;} while ( quotient );if ( value < 0 )buf += '-';std::reverse( buf.begin(), buf.end() );buf;})\n\nstring itoa_cpp(int value, int base){\n string buf;\n\t\tif (base < 2 || base > 16)\n\t\t\treturn buf;\n\t\tenum { kMaxDigits = 35 };\n\t\tbuf.reserve( kMaxDigits );\n\t\tint quotient = value;\n\t\tdo {\n\t\t\tbuf += \"0123456789abcdef\"[ std::abs( quotient % base ) ];\n\t\t \tquotient /= base;\n\t\t} while ( quotient );\n\t\tif ( value < 0 )\n\t\t\tbuf += '-';\n\t\tstd::reverse( buf.begin(), buf.end() );\n\t\treturn buf;\n}\n\n\n/****************************************************************************************************************************/\n\nint main(){\n\tint n=SI,k=SI;\n\tvi a;\n\tvi b;\n\ta.pb(0);\n\ta.pb(1);\n\tint c=1;\n\twhile(c<=n){\n\t\ta.push_back(c);\n\t\tc=c+a[SZ(a)-1];\n\t\tif(SZ(a)-k>=0)\n\t\t\tc=c-a[SZ(a)-k];\n\t}\n\tfor(int i=SZ(a)-1;i>=0;i--){\n\t\tif(a[i]<=n){\n\t\t\t\tb.pb(a[i]);\n\t\t\tn=n-(a[i]);\n\t\t}\n\t}\n\tprintf(\"%d\\n\",SZ(b));\n\tfor(int i=0;i\nusing namespace std;\n\n#define fi first\n#define se second\ntypedef long long ll;\n\nint main() {\n ll s, k;\n cin >> s >> k;\n vector F;\n for (int i = 0; i < k - 1; i++) {\n F.push_back(0);\n }\n F.push_back(1);\n while (F.back() < 1.1e9) {\n int l = F.size();\n F.push_back(0);\n for (int i = l - k; i <= l - 1; i++) {\n F[l] += F[i];\n }\n }\n vector ans;\n ll last = -1;\n for (int i = (int)F.size() - 1; i >= 0; i--) {\n if (s >= F[i] && last != F[i]) {\n s -= F[i];\n ans.push_back(F[i]);\n last = F[i];\n }\n }\n\n sort(ans.begin(), ans.end());\n cout << ans.size() << endl;\n for (auto x : ans) {\n cout << x << \" \";\n }\n cout << endl;\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6e1af7896335a2e8da6c921e4303313e", "src_uid": "da793333b977ed179fdba900aa604b52", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include \n#define ll long long\nusing namespace std;\n\nint main()\n{\n ll s,k;\n cin>>s>>k;\n ll i;\n vector kb,sm;\n kb.push_back(0);\n sm.push_back(0);\n for(i=1;i ans;\n while(cnt<=1||ss>0)\n {\n ll x=upper_bound(kb.begin(),kb.end(),ss)-kb.begin();\n x--;\n ans.push_back(kb[x]);\n ss-=kb[x];\n cnt++;\n }\n cout<\nusing namespace std;\n \n#define ll long long\n#define f1(n) for(ll i=0;i<(n);++i)\n#define f2(n) for(ll j=0;j<(n);++j)\n#define _fast_ ios_base::sync_with_stdio(false),cin.tie(NULL);\n#define pb push_back\n#define f_1(a,b) for(ll i=a;i<=b;i++)\n#define f_2(a,b) for(ll j=a;j>=b;j--)\n#define v(name) vector name\n#define sz(a) a.size()\nconst int MAX=5e5+10,mod=1e9+9,base=41,INF=1e9+10,sq=502;\nll maxx=-1;\nll Day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};\nint main()\n{\n \n _fast_\n ll s,m;\n cin>>s>>m;\n v(v);\n f1(m-1)\n v.pb(0);\n v.pb(1);\n v.pb(1);\n ll sum =2,k=0,prev=0;\n while(sum<=s)\n {\n sum -=v[k];\n sum +=prev;\n k++;\n v.pb(sum);\n prev = sum;\n\n }\n if(v[sz(v)-2]==s)\n {\n cout<<2<=0;i--)\n {\n if(pik-v[i] <0)\n continue ;\n pik -=v[i];\n b.pb(v[i]);\n if(pik==0)\n break;\n }\n cout<\n#define all(x) x.begin(), x.end()\n#define x first\n#define y second\nusing namespace std;\nusing ull = unsigned long long;\n\nconst int N = 104;\nconst int S = 52;\nconst ull INF = -1;\n\ntemplate\nvoid umin(T &a, T b) {\n a = min(a, b);\n}\n\nint tr[S][2]; // trie\nint go[S][2]; // automaton\nint ls[S]; // last char\nint pr[S]; // parent\nint pi[S]; // sufflink\nbool z[S]; // terminal\nint len = 0; // last vertex\n\nvoid add(vector s) {\n int v = 0;\n for (int c : s) {\n if (tr[v][c] == -1) {\n tr[v][c] = ++len;\n assert(len < S);\n pr[len] = v;\n ls[len] = c;\n }\n v = tr[v][c];\n }\n z[v] = true;\n}\n\nvoid build() {\n pr[0] = -1;\n ls[0] = -1;\n queue q;\n q.push(0);\n while (q.size()) {\n int v = q.front();\n q.pop();\n pi[v] = (v && pr[v]) ? go[pi[pr[v]]][ls[v]] : 0;\n for (int c = 0; c < 2; ++c) {\n if (tr[v][c] != -1) {\n go[v][c] = tr[v][c];\n q.push(tr[v][c]);\n } else {\n go[v][c] = v ? go[pi[v]][c]: 0;\n }\n }\n }\n for (int i = 0; i <= len; ++i) {\n if (z[i] |= z[pi[i]]) {\n go[i][0] = i;\n go[i][1] = i;\n }\n }\n}\n\nint g;\nint n;\nint m;\nint a[N], k[N], b[N][N];\n\null dp[N][S][S]; // gen, from, to\nvector> small[N][S];\null tp[S][S];\n\nbool relax(int row) {\n bool f = false;\n for (int i = 0; i < g; ++i) {\n for (int s = 0; s <= len; ++s) {\n small[i][s].clear();\n for (int t = 0; t <= len; ++t) {\n if (dp[i][s][t] < INF) {\n small[i][s].emplace_back(t, dp[i][s][t]);\n }\n }\n }\n }\n for (int st = 0; st <= len; ++st) {\n fill_n(tp[0], S * S, INF);\n tp[0][st] = 0;\n for (int ind = 0; ind < k[row]; ++ind) {\n int h = b[row][ind];\n for (int i = 0; i <= len; ++i) {\n if (tp[ind][i] >= INF) {\n continue;\n }\n for (auto e : small[h][i]) {\n umin(tp[ind + 1][e.x], tp[ind][i] + e.y);\n }\n }\n }\n for (int fn = 0; fn <= len; ++fn) {\n if (dp[a[row]][st][fn] > tp[k[row]][fn]) {\n dp[a[row]][st][fn] = tp[k[row]][fn];\n f = true;\n }\n }\n }\n return f;\n}\n\nsigned main() {\n#ifdef LC\n assert(freopen(\"input.txt\", \"r\", stdin));\n#endif // LC\n ios::sync_with_stdio(0);\n cin.tie(0);\n\n fill_n(tr[0], 2 * S, -1);\n fill_n(go[0], 2 * S, -1);\n fill_n(dp[0][0], N * S * S, INF);\n cin >> g >> n >> m;\n for (int i = 0; i < n; ++i) {\n cin >> a[i] >> k[i];\n for (int j = 0; j < k[i]; ++j) {\n cin >> b[i][j];\n }\n }\n for (int i = 0; i < m; ++i) {\n int l;\n cin >> l;\n vector c(l);\n for (int &e : c) {\n cin >> e;\n }\n add(c);\n }\n build();\n for (int i = 0; i <= len; ++i) {\n cerr << i << \" \" << pi[i] << \"\\t\";\n for (int h = 0; h < 2; ++h) {\n cerr << go[i][h] << \" \";\n dp[h][i][go[i][h]] = 1;\n }\n cerr << endl;\n }\n for (int it = 0, run = true; it < g - 2 && run; ++it) {\n run = false;\n for (int i = 0; i < n; ++i) {\n run |= relax(i);\n }\n }\n for (int i = 2; i < g; ++i) {\n ull ans = INF;\n for (int j = 0; j <= len; ++j) {\n //cerr << j << \" \" << z[j] << \"\\t\" << dp[i][0][j] << endl;\n if (!z[j]) {\n umin(ans, dp[i][0][j]);\n }\n }\n if (ans < INF) {\n cout << \"NO \" << ans << \"\\n\";\n } else {\n cout << \"YES\\n\";\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3f5743eb6208798855a5cf553850397c", "src_uid": "ae8f02cdd2f3859d4822858275e9ec40", "difficulty": 2900.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nusing ll = long long;\nusing Vi = vector;\nusing Pii = pair;\n#define pb push_back\n#define mp make_pair\n#define x first\n#define y second\n#define rep(i,b,e) for (int i = (b); i < (e); i++)\n#define each(a,x) for (auto& a : (x))\n#define all(x) (x).begin(),(x).end()\n#define sz(x) int((x).size())\n\nusing ull = unsigned long long;\nconstexpr ull INF = 1ull << 63;\n\null add(ull a, ull b) {\n\tif (a >= INF || b >= INF) {\n\t\treturn INF;\n\t}\n\treturn a+b;\n}\n\nstruct Matrix {\n\tint n;\n\tvector M;\n\n\tMatrix(int _n = 0) : n(_n), M(_n*_n, INF) { }\n\n\tconst ull* operator[](int i) const { return &M[i*n]; }\n\tull* operator[](int i) { return &M[i*n]; }\n\n\tMatrix& operator+=(const Matrix& r) {\n\t\trep(i, 0, sz(M)) M[i] = min(M[i], r.M[i]);\n\t\treturn *this;\n\t}\n\n\tMatrix operator*(const Matrix& r) const {\n\t\tstatic Vi nice;\n\t\tMatrix ret(n);\n\n\t\trep(i, 0, n) {\n\t\t\tnice.clear();\n\t\t\trep(k, 0, n) if ((*this)[i][k] < INF) nice.pb(k);\n\t\t\trep(j, 0, n) each(k, nice) {\n\t\t\t\tret[i][j] = min(ret[i][j], add((*this)[i][k], r[k][j]));\n\t\t\t}\n\t\t}\n\t\treturn ret;\n\t}\n};\n\nstruct Aho {\n\tvector> nxt;\n\tvector acc;\n\tVi suf;\n\n\tAho() {\n\t\tnxt.pb({-1, -1});\n\t\tnxt.pb({1, 1});\n\t\tacc.resize(2);\n\t}\n\n\tvoid add(const Vi& s) {\n\t\tint cur = 0;\n\t\teach(e, s) {\n\t\t\tif (nxt[cur][e] == -1) {\n\t\t\t\tacc.pb(0);\n\t\t\t\tnxt.pb({-1, -1});\n\t\t\t\tnxt[cur][e] = sz(nxt)-1;\n\t\t\t}\n\t\t\tcur = nxt[cur][e];\n\t\t}\n\t\tacc[cur] = 1;\n\t}\n\n\tvoid build() {\n\t\tqueue que;\n\t\tsuf.resize(sz(nxt), -1);\n\n\t\trep(i, 0, 2) {\n\t\t\tint& j = nxt[0][i];\n\t\t\tif (j != -1) {\n\t\t\t\tsuf[j] = 0;\n\t\t\t\tque.push(j);\n\t\t\t} else {\n\t\t\t\tj = 0;\n\t\t\t}\n\t\t}\n\n\t\twhile (!que.empty()) {\n\t\t\tint i = que.front();\n\t\t\tque.pop();\n\t\t\trep(j, 0, 2) {\n\t\t\t\tint& e = nxt[i][j];\n\t\t\t\tif (e != -1) {\n\t\t\t\t\tsuf[e] = nxt[suf[i]][j];\n\t\t\t\t\tque.push(e);\n\t\t\t\t} else {\n\t\t\t\t\te = nxt[suf[i]][j];\n\t\t\t\t}\n\t\t\t}\n\t\t\tacc[i] = acc[i] || acc[suf[i]];\n\t\t}\n\t}\n\n\tMatrix getMatrix(int e) {\n\t\tMatrix ret(sz(nxt));\n\t\trep(i, 0, sz(nxt)) {\n\t\t\tint j = nxt[i][e];\n\t\t\tif (acc[j]) j = 1;\n\t\t\tret[i][j] = 1;\n\t\t}\n\t\treturn ret;\n\t}\n};\n\nint main() {\n\tint g, n, m; cin >> g >> n >> m;\n\tvector> mutations(g);\n\n\trep(i, 0, n) {\n\t\tint a, k; cin >> a >> k;\n\t\tVi mut(k);\n\t\teach(j, mut) cin >> j;\n\t\tmutations[a].pb(move(mut));\n\t}\n\n\tAho aho;\n\n\trep(i, 0, m) {\n\t\tint k; cin >> k;\n\t\tVi tmp(k);\n\t\teach(j, tmp) cin >> j;\n\t\taho.add(tmp);\n\t}\n\n\tint dim = sz(aho.nxt);\n\tvector dp(g, {dim});\n\taho.build();\n\tdp[0] = aho.getMatrix(0);\n\tdp[1] = aho.getMatrix(1);\n\n\tbool chg = 1;\n\n\twhile (chg) {\n\t\tchg = 0;\n\t\trep(i, 2, g) {\n\t\t\tMatrix mat(dim);\n\t\t\teach(mut, mutations[i]) {\n\t\t\t\tMatrix tmp(dim);\n\t\t\t\trep(j, 0, dim) tmp[j][j] = 0;\n\t\t\t\teach(j, mut) tmp = tmp*dp[j];\n\t\t\t\tmat += tmp;\n\t\t\t}\n\n\t\t\trep(j, 0, sz(mat.M)) if (dp[i].M[j] != mat.M[j]) {\n\t\t\t\tchg = 1;\n\t\t\t\tdp[i] = mat;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\trep(i, 2, g) {\n\t\tull ans = INF;\n\t\trep(j, 0, dp[i].n) if (j != 1) ans = min(ans, dp[i][0][j]);\n\t\tif (ans < INF) {\n\t\t\tcout << \"NO \" << ans << '\\n';\n\t\t} else {\n\t\t\tcout << \"YES\\n\";\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3e0927c0f3abbd29d244104e0d84f5d4", "src_uid": "ae8f02cdd2f3859d4822858275e9ec40", "difficulty": 2900.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\nusing ll = int64_t;\n//using ll = long long;\nusing ull = uint64_t;\nusing i32 = int32_t;\nusing u32 = uint32_t;\nusing i64 = int64_t;\nusing u64 = uint64_t;\nusing f64 = double;\nusing pii = pair;\nusing pll = pair;\nusing ld = double;\n\n#define X first\n#define Y second\n\n//#ifndef ONLINE_JUDGE\n#define FWRITE\n//#endif\n\nnamespace io\n{\n\n#ifndef FWRITE\n#include \n\tauto unistd_read = read;\n\tauto unistd_write = write;\n#endif\n\tconst int BUFSIZE = 1 << 20;\n\n\tint isize, osize;\n\tchar ibuf[BUFSIZE + 10], obuf[BUFSIZE + 10];\n\tchar* is, * it, * os = obuf, * ot = obuf + BUFSIZE;\n\n\tchar getchar()\n\t{\n\t\tif (is == it)\n\t\t{\n\t\t\tis = ibuf;\n#ifdef FWRITE\n\t\t\tit = ibuf + fread(ibuf, 1, BUFSIZE, stdin);\n#else\n\t\t\tit = ibuf + unistd_read(STDIN_FILENO, ibuf, BUFSIZE);\n#endif\n\t\t\tif (is == it) return EOF;\n\t\t}\n\t\treturn *is++;\n\t}\n\n\tchar getalpha()\n\t{\n\t\tchar c = getchar();\n\t\twhile (!isalpha(c)) c = getchar();\n\t\treturn c;\n\t}\n\n\tvoid putchar(char c)\n\t{\n\t\t*os++ = c;\n\t\tif (os == ot)\n\t\t{\n#ifdef FWRITE\n\t\t\tfwrite(obuf, 1, BUFSIZE, stdout);\n#else\n\t\t\tunistd_write(STDOUT_FILENO, obuf, BUFSIZE);\n#endif\n\t\t\tos = obuf;\n\t\t}\n\t}\n\n\tint inp() {\n\t\tint x = 0, f = 0; char ch;\n\t\tfor (ch = getchar(); !isdigit(ch); ch = getchar())\n\t\t{\n\t\t\tif (ch == EOF) return -1;\n\t\t\tif (ch == '-') f = 1;\n\t\t}\n\t\tfor (; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());\n\t\treturn f ? -x : x;\n\t}\n\n\tll inp_ll() {\n\t\tll x = 0; int f = 0; char ch;\n\t\tfor (ch = getchar(); !isdigit(ch); ch = getchar())\n\t\t\tif (ch == '-') f = 1;\n\t\tfor (; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());\n\t\treturn f ? -x : x;\n\t}\n\n\ttemplate\n\tbool read(T& x)\n\t{\n\t\tx = 0;\n\t\tint f = 0; char ch;\n\t\tfor (ch = getchar(); !isdigit(ch); ch = getchar())\n\t\t{\n\t\t\tif (ch == EOF) return 0;\n\t\t\tif (ch == '-') f = 1;\n\t\t}\n\t\tfor (; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());\n\t\tif (f) x = -x;\n\t\treturn 1;\n\t}\n\n\tbool read(char* s)\n\t{\n\t\tchar* t = s;\n\t\tchar ch = getchar();\n\t\tfor (; ch == ' ' || ch == '\\n'; ch = getchar());\n\t\tfor (; ch != ' ' && ch != '\\n' && ch != EOF; ch = getchar())\n\t\t\t*t++ = ch;\n\t\t*t = 0;\n\t\treturn s != t;\n\t}\n\n\ttemplate\n\tbool read(T& x, Args&... args)\n\t{\n\t\treturn read(x) && read(args...);\n\t}\n\n\ttemplate\n\tbool readln(T& x)\n\t{\n\t\tx = 0;\n\t\tint f = 0; char ch;\n\t\tfor (ch = getchar(); !isdigit(ch); ch = getchar())\n\t\t{\n\t\t\tif (ch == EOF) return 0;\n\t\t\tif (ch == '-') f = 1;\n\t\t}\n\t\tfor (; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());\n\t\tif (f) x = -x;\n\t\tfor (; ch != '\\n' && ch != EOF; ch = getchar());\n\t\treturn 1;\n\t}\n\n\tbool readln(char* s)\n\t{\n\t\tchar* t = s;\n\t\twhile (1)\n\t\t{\n\t\t\tchar ch = getchar();\n\t\t\tif (ch == '\\n' || ch == EOF) break;\n\t\t\t*t++ = ch;\n\t\t}\n\t\t*t = 0;\n\t\treturn s != t;\n\t}\n\n\ttemplate\n\tbool readln(T& x, Args&... args)\n\t{\n\t\treturn read(x) && readln(args...);\n\t}\n\n\ttemplate\n\tvoid write(T x)\n\t{\n\t\tstatic char s[22];\n\t\tstatic char* it = s + 20;\n\t\tstatic char* end = s + 20;\n\n\t\tif (x < 0)\n\t\t{\n\t\t\tputchar('-');\n\t\t\tx = -x;\n\t\t}\n\n\t\tdo\n\t\t{\n\t\t\t*--it = x % 10 + '0';\n\t\t\tx /= 10;\n\t\t} while (x);\n\t\t/*\n\t\tif (!x)\n\t\t\t*-- it = '0';\n\t\twhile (x)\n\t\t{\n\t\t\t*-- it = x%10+'0';\n\t\t\tx /= 10;\n\t\t}\n\t\t*/\n\t\tfor (; it < end; ++it)\n\t\t\tputchar(*it);\n\t}\n\n\tvoid write(const char* s)\n\t{\n\t\tfor (; *s; ++s) putchar(*s);\n\t}\n\n\ttemplate<>\n\tvoid write(char* s)\n\t{\n\t\twrite((const char*)s);\n\t}\n\n\ttemplate<>\n\tvoid write(char c)\n\t{\n\t\tputchar(c);\n\t}\n\n\ttemplate\n\tvoid write(T x, Args... args)\n\t{\n\t\twrite(x);\n\t\twrite(args...);\n\t}\n\n\tvoid writeln()\n\t{\n\t\tputchar('\\n');\n\t}\n\n\ttemplate\n\tvoid writeln(T x, Args... args)\n\t{\n\t\twrite(x);\n\t\twriteln(args...);\n\t}\n\n\ttemplate\n\tbool input(Iterator st, Iterator ed)\n\t{\n\t\tfor (; st != ed; ++st)\n\t\t{\n\t\t\tif (!read(*st)) return false;\n\t\t}\n\t\treturn true;\n\t}\n\n\ttemplate\n\tbool input(T& a)\n\t{\n\t\treturn input(a.begin(), a.end());\n\t}\n\n\ttemplate\n\tvoid print(Iterator st, Iterator ed, const char* c = \" \")\n\t{\n\t\tint flag = 0;\n\t\tfor (; st != ed; ++st)\n\t\t{\n\t\t\tif (flag) write(c);\n\t\t\tflag = 1;\n\t\t\twrite(*st);\n\t\t}\n\t\twriteln();\n\t}\n\n\ttemplate\n\tvoid print(const T& a, const char* c = \" \")\n\t{\n\t\tprint(a.begin(), a.end(), c);\n\t}\n\n\tstruct ender\n\t{\n\t\t~ender()\n\t\t{\n\t\t\tif (os != obuf)\n#ifdef FWRITE\n\t\t\t\tfwrite(obuf, 1, os - obuf, stdout);\n#else\n\t\t\t\tunistd_write(STDOUT_FILENO, obuf, os - obuf);\n#endif\n\t\t}\n\t}__ender;\n\n}\n\nint64_t power(int64_t a, int64_t b, int64_t p)\n{\n\tif (!b) return 1;\n\tint64_t t = power(a, b >> 1, p);\n\tt = t * t % p;\n\tif (b & 1) t = t * a % p;\n\treturn t;\n}\n\npll exgcd(ll a, ll b)\n{\n\tif (b == 0) return { 1, 0 };\n\t//auto [x, y] = exgcd(b, a % b);\n\tauto e = exgcd(b, a % b);\n\tll x = e.first;\n\tll y = e.second;\n\treturn { y, x - a / b * y };\n}\n\n//mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());\n//mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());\nmt19937 rd(1);\n\nusing namespace io;\n\ntemplate\ninline void freshmin(T& a, const T& b)\n{\n\tif (a > b) a = b;\n}\n\ntemplate\ninline void freshmax(T& a, const T& b)\n{\n\tif (a < b) a = b;\n}\n\n//const ll B = 31;\n//const ll MOD = 1000000007;\n//const int INF = 1000000010;\n//const ll INFll = 4000000000000000000LL;\n//const int MAXN = 600010;\n//const int MAXK = 21;\n\nint dx[] = { -1, 1, 0, 0, -1, -1, 1, 1 };\nint dy[] = { 0, 0, -1, 1, -1, 1, -1, 1 };\n\ntemplate\nT det(T x1, T y1, T x2, T y2, T x3, T y3)\n{\n\treturn x1 * y2 - x2 * y1 + x2 * y3 - x3 * y2 + x3 * y1 - x1 * y3;\n}\n\ntemplate\nT dis(T x1, T y1, T x2, T y2)\n{\n\treturn sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));\n}\n\nstatic const int MAXN = 40010; // number of nodes in AC automaton\nstatic const int MAXM = 2; // cardinal of alphabet\n\nint tot;\n\nstruct node\n{\n\tnode* next[MAXM];\n\tnode* fail;\n\tint val;\n};\n\nnode tree[MAXN];\nnode* root;\n\nnode* new_node()\n{\n\tnode* it = &tree[++tot];\n\tfor (int i = 0; i < MAXM; ++i) it->next[i] = 0;\n\tit->fail = 0;\n\tit->val = 0;\n\treturn it;\n}\n\nvoid init()\n{\n\ttot = 0;\n\troot = new_node();\n}\n\nnode* add(const vector& s)\n{\n\tnode* it = root;\n\tfor (auto c : s)\n\t{\n\t\tint x = c;\n\t\tif (!it->next[x]) it->next[x] = new_node();\n\t\tit = it->next[x];\n\t}\n\tit->val = 1;\n\t//printf(\"%x\\n\", it);\n\treturn it;\n}\n\nvoid build()\n{\n\troot->fail = root;\n\tqueue Q;\n\tfor (int i = 0; i < MAXM; ++i)\n\t\tif (root->next[i])\n\t\t{\n\t\t\troot->next[i]->fail = root;\n\t\t\tQ.push(root->next[i]);\n\t\t}\n\t\telse\n\t\t\troot->next[i] = root;\n\twhile (!Q.empty())\n\t{\n\t\tnode* it = Q.front();\n\t\tQ.pop();\n\t\tfor (int i = 0; i < MAXM; ++i)\n\t\t{\n\t\t\tif (!it->next[i])\n\t\t\t\tit->next[i] = it->fail->next[i];\n\t\t\telse\n\t\t\t{\n\t\t\t\tit->next[i]->fail = it->fail->next[i];\n\t\t\t\tit->next[i]->val |= it->next[i]->fail->val;\n\t\t\t\tQ.push(it->next[i]);\n\t\t\t}\n\t\t}\n\t}\n}\n\nconst ull INFull = 1ULL << 63;\n\null f[111][55][55];\n\nvoid solve()\n{\n\tint G, N, M;\n\tread(G, N, M);\n\tvector>> v(G);\n\tfor (int i = 0; i < N; ++i)\n\t{\n\t\tint a, k;\n\t\tread(a, k);\n\t\tvector b(k);\n\t\tinput(b);\n\t\tv[a].push_back(b);\n\t}\n\tinit();\n\tfor (int i = 0; i < M; ++i)\n\t{\n\t\tint k;\n\t\tread(k);\n\t\tvector b(k);\n\t\tinput(b);\n\t\tadd(b);\n\t}\n\tbuild();\n\tfor (int a = 0; a < G; ++a)\n\t\tfor (int x = 1; x <= tot; ++x)\n\t\t\tfor (int y = 1; y <= tot; ++y)\n\t\t\t\tf[a][x][y] = INFull;\n\tfor (int a = 0; a < 2; ++a)\n\t\tfor (int x = 1; x <= tot; ++x) if (!tree[x].val && !tree[x].next[a]->val)\n\t\t\tf[a][x][tree[x].next[a] - tree] = 1;\n\t\n\tll time_stamp = clock();\n\twhile (1)\n\t{\n\t\tint flag = 0;\n\n\t\tfor (int a = 0; a < G; ++a)\n\t\t{\n\t\t\tfor (const auto& b : v[a])\n\t\t\t{\n\t\t\t\tstatic ull g[55][55], tmp[55][55];\n\t\t\t\tfor (int x = 1; x <= tot; ++x)\n\t\t\t\t\tfor (int y = 1; y <= tot; ++y) g[x][y] = INFull;\n\t\t\t\tfor (int x = 1; x <= tot; ++x) if (!tree[x].val) g[x][x] = 0;\n\n\t\t\t\tfor (const auto& c : b)\n\t\t\t\t{\n\t\t\t\t\tfor (int x = 1; x <= tot; ++x)\n\t\t\t\t\t\tfor (int y = 1; y <= tot; ++y) tmp[x][y] = g[x][y], g[x][y] = INFull;\n\t\t\t\t\tfor (int x = 1; x <= tot; ++x) if (!tree[x].val)\n\t\t\t\t\t\tfor (int y = 1; y <= tot; ++y) if (!tree[y].val && tmp[x][y] < INFull)\n\t\t\t\t\t\t\tfor (int z = 1; z <= tot; ++z) if (!tree[z].val && f[c][y][z] < INFull)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (g[x][z] > tmp[x][y] + f[c][y][z])\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tg[x][z] = tmp[x][y] + f[c][y][z];\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (int x = 1; x <= tot; ++x)\n\t\t\t\t\tfor (int y = 1; y <= tot; ++y)\n\t\t\t\t\t\tif (f[a][x][y] > g[x][y])\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t\t\tf[a][x][y] = g[x][y];\n\t\t\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (flag == 0) break;\n\t\tif (clock() - time_stamp > 720000) break;\n\t}\n\n\tfor (int a = 2; a < G; ++a)\n\t{\n\t\tull res = INFull;\n\t\tfor (int y = 1; y <= tot; ++y)\n\t\t\tif (f[a][1][y] < res)\n\t\t\t{\n\t\t\t\tres = f[a][1][y];\n\t\t\t}\n\t\tif (res == INFull)\n\t\t\twriteln(\"YES\");\n\t\telse\n\t\t\twriteln(\"NO \", ll(res));\n\t}\n}\n\nint main()\n{\n\n\tint T = 1;\n\t//read(T);\n\t//init();\n\tfor (int test = 1; test <= T; ++test)\n\t{\n\t\t//write(\"Case #\", test, \": \");\n\t\tsolve();\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b44e6dcf0a1209aa67874f1a677ad0e7", "src_uid": "ae8f02cdd2f3859d4822858275e9ec40", "difficulty": 2900.0} {"lang": "GNU C++17", "source_code": "#include\"cstdio\"\n#include\"queue\"\n#define int long long\nnamespace IAKIOI{\n\tconst int L=1<<20|1;\n\tchar buffer[L],*S,*TT;\n\t#define getchar() ((S==TT&&(TT=(S=buffer)+fread(buffer,1,L,stdin),S==TT))?EOF:*S++)\n\tinline void read(int &x){\n\t\tx=0;int f=1;char s=getchar();\n\t\twhile(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}\n\t\twhile(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}\n\t\tx*=f;\n\t}\n\tinline void write(int x){\n\t\tif(x<0){putchar('-');x=-x;}\n\t\tif(x>9)write(x/10);\n\t\tputchar(x%10+'0');\n\t}\n}\nusing namespace IAKIOI;\nconst unsigned int oo=1ull<<63;\nunsigned int f[205][52][52];\nint G,N,M,n,m,b[55],ty[205],v[205][55][55];\nstd::vector>out[205];\nint ch[55][2],fail[55],ok[55],rt=1,tot=1;\ninline void insert(int*a,int len){\n\tint nw=rt;\n\tfor(int i=1;i<=len;i++){\n\t\tif(!ch[nw][a[i]])ch[nw][a[i]]=++tot;\n\t\tnw=ch[nw][a[i]];\n\t}\n\tok[nw]=1;\n}\nstd::queueQ;\ninline void getfail(){\n\tfor(int i=0;i<=1;i++)\n\t\tif(ch[rt][i])fail[ch[rt][i]]=rt,Q.push(ch[rt][i]);\n\t\telse ch[rt][i]=rt;\n\twhile(Q.size()){\n\t\tint u=Q.front();Q.pop();\n\t\tfor(int i=0;i<=1;i++)\n\t\t\tif(ch[u][i]){\n\t\t\t\tfail[ch[u][i]]=ch[fail[u]][i];\n\t\t\t\tok[ch[u][i]]|=ok[fail[ch[u][i]]];\n\t\t\t\tQ.push(ch[u][i]);\n\t\t\t}\n\t\t\telse ch[u][i]=ch[fail[u]][i];\n\t}\n}\nint id[55],num[55];\nstruct node{\n\tint x,fr,ed;\n\tunsigned int num;\n\tnode(int _x=0,int _fr=0,int _ed=0,unsigned int _num=0){\n\t\tx=_x;fr=_fr;ed=_ed;num=_num;\n\t}\n\tfriend bool operator<(node a,node b){\n\t\treturn a.num>b.num;\n\t}\n};\nstd::priority_queueHeap;\nsigned main(){\n\tread(G),G--;read(N),read(M),n=G;\n\tfor(int i=1,a=0,k=0;i<=N;i++,n+=k){\n\t\tread(a),read(k);\n\t\tfor(int j=1;j<=k;j++)read(b[j]),ty[n+j]=1;\n\t\tfor(int j=2;j<=k;j++){\n\t\t\tout[n+j].push_back(std::make_pair(n+j-1,b[j-1]));\n\t\t\tout[b[j-1]].push_back(std::make_pair(n+j-1,n+j));\n\t\t}\n\t\tout[b[k]].push_back(std::make_pair(n+k,-1));\n\t\tout[n+1].push_back(std::make_pair(a,-1)); \n\t}\n\tfor(int i=1,len;i<=M;i++){\n\t\tread(len);\n\t\tfor(int j=1;j<=len;j++)read(b[j]);\n\t\tinsert(b,len);\n\t}\n\tgetfail();\n\tint cnt=0;\n\tfor(int i=1;i<=tot;i++)if(!ok[i])id[i]=++cnt,num[cnt]=i;\n\tfor(int i=0;i<=n;i++)\n\t\tfor(int j=1;j<=cnt;j++)\n\t\t\tfor(int k=1;k<=cnt;k++)\n\t\t\t\tf[i][j][k]=oo;\n\tfor(int i=1;i<=cnt;i++){\n\t\tint x=num[i];\n\t\tif(id[ch[x][0]]){\n\t\t\tf[0][i][id[ch[x][0]]]=1;\n\t\t\tHeap.push(node(0,i,id[ch[x][0]],1));\n\t\t}\n\t\tif(id[ch[x][1]]){\n\t\t\tf[1][i][id[ch[x][1]]]=1;\n\t\t\tHeap.push(node(1,i,id[ch[x][1]],1));\n\t\t}\n\t}\n\twhile(Heap.size()){\n\t\tnode tmp=Heap.top();\n\t\tHeap.pop();\n\t\tint x=tmp.x,fr=tmp.fr,ed=tmp.ed;\n\t\tunsigned int val=tmp.num;\n\t\tif(v[x][fr][ed])continue;\n\t\tv[x][fr][ed]=1;\n\t\tfor(std::pairu:out[x]){\n\t\t\tint y=u.first,w=u.second;\n\t\t\tif(w==-1){\n\t\t\t\tif(f[y][fr][ed]>val){\n\t\t\t\t\tf[y][fr][ed]=val;\n\t\t\t\t\tHeap.push(node(y,fr,ed,f[y][fr][ed]));\n\t\t\t\t}\n\t\t\t}\n\t\t\telse{\n\t\t\t\tif(!ty[x]){\n\t\t\t\t\tfor(int j=1;j<=cnt;j++)\n\t\t\t\t\t\tif(f[y][fr][j]>val+f[w][ed][j]){\n\t\t\t\t\t\t\tf[y][fr][j]=val+f[w][ed][j];\n\t\t\t\t\t\t\tHeap.push(node(y,fr,j,f[y][fr][j]));\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse{\n\t\t\t\t\tfor(int j=1;j<=cnt;j++)\n\t\t\t\t\t\tif(f[y][j][ed]>val+f[w][j][fr]){\n\t\t\t\t\t\t\tf[y][j][ed]=val+f[w][j][fr];\n\t\t\t\t\t\t\tHeap.push(node(y,j,ed,f[y][j][ed]));\n\t\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfor(int i=2;i<=G;i++){\n\t\tunsigned int ans=oo;\n\t\tfor(int j=1;j<=cnt;j++)ans=std::min(ans,f[i][1][j]);\n\t\t(ans==oo)?puts(\"YES\"):printf(\"NO %lld\\n\",ans);\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5b51e461ab7e28c7605266d801a0c5ec", "src_uid": "ae8f02cdd2f3859d4822858275e9ec40", "difficulty": 2900.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\n\nint getans(int x){\n\n if(x<=0){\n return 0;\n }\n\n if(x==2){\n return 2;\n }\n\n return getans(x-2)+ getans(x-2);\n\n}\n\nint main()\n{\n int x;\n cin>> x;\n\n if(x%2==0)\n cout<\n#include \n\nusing namespace std;\n\nint main()\n{\n int i=1,n,ans=1;\n cin >> n;\n if ((n*3)% 2 == 0)\n {\n while (i<=n/2)\n {\n ans=ans*2;\n }\n }\n else cout << '0';\n\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a0a8d370fb2c5464ba8b0d48d06caf86", "src_uid": "4b7ff467ed5907e32fd529fb39b708db", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include\n#define ll long long\nusing namespace std;\nconst int N=4*1e7;\nll ans[N],res[N];\nint T,n,m,Q,se;\nint main(void){\n int n;\n cin>>n;\n if(n<4||n&1){\n cout<<0;\n return 0;\n }\n else{\n cout<\nusing namespace std;\ntypedef long long ll;\n\nint main(){\n\n\t#ifndef ONLINE_JUDGE\n \tfreopen(\"input\", \"r\", stdin);\n \tfreopen(\"output\", \"w\", stdout);\n\t#endif\n\tios_base::sync_with_stdio(false);\n cin.tie(NULL);\n\n int n;\n cin>>n;\n\n if(n%2==1){\n \tcout<<0<\n\nusing namespace std;\n\nint main(){\n\tstring a;\n\tcin >> a;\n\tint len = a.length();\n\tint cnt = 0;\n\tfor(int i = 1; i < len; i++)\n\t\tif(a[i] == a[1]) cnt++;\n\tif(cnt == len - 1){\n\t\tcout << 0;\n\t\treturn 0;\n\t} \n\tcnt = 0;\n\tfor(int i = 0; i < len / 2; i++)\n\t\tif(a[i] == a[len - i - 1]) cnt++;\n\tif(cnt == len / 2) cout << len - 1;\n\telse cout << len;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2d06ff6c7a5f5fa77924f8a1c9080547", "src_uid": "6c85175d334f811617e7030e0403f706", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include \n#define ll long long\nstd::vector irakli(1000,-1);\nvoid adddd(){\n\tfor(int i=1;i<=1000000;i++)\n\t\ti++;\n}\nusing namespace std;\n\nint main(){\n\tadddd();\n\tstring x;\n\tcin>>x;\n\tll cnt=0;\n\tll i=x.size()-1;\n\tint ind=1;\n\tfor(ll k=1;k\nusing namespace std;\n#define ll long long \n#define mp make_pair\n#define pb push_back\n \nint main(){\n\tios_base::sync_with_stdio(false);\n\tstring s, s1 = \"\", s2 = \"\";\n\tll k = 0;\n\tbool check = true;\n\tcin >> s;\n\twhile (true){\n\t\tfor (ll i = s.length() - 1 - k; i >= 0; i--){\n\t\t\ts1 += s[i];\n\t\t\t\n\t\t}\n\t\tfor(ll i = s1.length() - 1; i >= 0; i--){\n\t\t\ts2 += s1[i];\n\t\t}\n\t\tif(s1 == s2 && s1.length() != 0){\n\t\t\tk++;\n\t\t\tif(k == s.length() - 1){\n\t\t\t\tcout << 0;\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\ts1 = \"\";\n\t\t\ts2 = \"\";\n\t\t}else{\n\t\t\tcout << s1.length();\n\t\t\treturn 0;\n\t\t}\n\t}\t\n\t\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "846b5f189ff342e5551232f754dec38a", "src_uid": "6c85175d334f811617e7030e0403f706", "difficulty": 900.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n#define ll long long \n#define mp make_pair\n#define pb push_back\n \nint main(){\n\tios_base::sync_with_stdio(false);\n\tstring s, s1 = \"\", s2 = \"\";\n\tll k = 0;\n\tbool check = true;\n\tcin >> s;\n\twhile (true){\n\t\ts1 = \"\";\n\t\tfor (ll i = s.length() - 1 - k; i >= 0; i--){\n\t\t\ts1 += s[i];\n\t\t\t\n\t\t}\n\t\tfor(ll i = s1.length() - 1; i >= 0; i--){\n\t\t\ts2 += s1[i]; \n\t\t}\n\t\tif(s1 == s2 && s1.length() != 0){\n\t\t\tk++;\n\t\t\ts1 = \"\";\n\t\t\ts2 = \"\";\n\t\t}else{\n\t\t\tcout << s1.length();\n\t\t\treturn 0;\n\t\t}\n\t}\t\n\t\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ed875d9017926570852c54c860ddfd80", "src_uid": "6c85175d334f811617e7030e0403f706", "difficulty": 900.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main()\n{\n int i,j,k=0,l,m,n,ans;\n cin>>n;\n m=n;\n while(m)\n {\n k+=m%10;\n m=m/10;\n }\n if(k%4==0)\n {\n cout<\nint main()\n{\n short num,sum=0,check=0,no;\n scanf(\"%hd\",&num);\n for(short i = num ; i ; i/=10)\n sum += i%10;\n no = num + (4-sum%4)%4;\n for(short i = no ; i ; i/=10)\n check += i%10;\n printf(\"%hd\\n\",no+(4-(check%4))%4);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "16f7dd0aea597bf49c84b7e30236309c", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\n#define ll long long\nusing namespace std;\n\nll sumi(ll n)\n{\n ll sum = 0;\n while(n > 0)\n {\n sum += n % 10;\n n /= 10;\n }\n return sum;\n}\n\nint main()\n{\n ll n;\n cin >> n;\n\n ll sum = sumi(n);\n while(sum % 4 != 0)\n {\n n += 4 - sum%4;\n sum = sumi(n);\n }\n cout << n;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "114fcd8d27ae90bf8e250410d9cae432", "src_uid": "bb6fb9516b2c55d1ee47a30d423562d7", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int a=0,b=0,c=0,y=0,x;\n cin>>x;\n if(x>996)\n {\n cout<<1003;\n return 0;\n }\n a=x%10;\n b=(x%100)/10;\n c=x/100;\n y=(a+b+c)%4;\n if(y==0)\n {\n cout<\n#include\nusing namespace std;\nint main()\n{\n string s;\n cin>>s;\n bool c=false;\n if(s.length()>=3)\n {\n for(int i=1 ;i\n#include\nusing namespace std;\nint main()\n{\n char a[100];\n cin>>a;\n int c=0;\n for(int i=1;i\n#define ll long long int\n#define pb push_back\n#define mp make_pair\n#define Size 100000\n#define dd double\n#define itr vector::iterator\n#define io ios::sync_with_stdio(0)\n\n\nusing namespace std;\n\n\nint main()\n{\nio;\nstring s;\ncin>>s;\nll flag=0,cnt=0;\nll a=0,b=0,c=0;\nfor(int i=0;i\nusing namespace std;\nchar fl[1000];\nint main(){\n\tcin>>fl;\n\tint l=strlen(fl);\n\tint a=0,b=0,c=0;\n\tfor(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint a,b,sa=0,sb=0,t;\nvector q;\n\nint main()\n{\n scanf(\"%d%d\",&a,&b);\n if(a==b) {printf(\"Dasha\\n\");return 0;}\n q.clear();\n for(int i=1;isb) sb+=q[t]-q[t-1];\n else sa+=q[t]-q[t-1];\n if(sa==sb) printf(\"Equal\\n\");\n else if(sa>sb) printf(\"Dasha\\n\");\n else printf(\"Masha\\n\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "51fdb8a42aeb291942def5e6b548e521", "src_uid": "06eb66df61ff5d61d678bbb3bb6553cc", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define forf(i,a,b) for(int i=(int)a;i<(int)b;i++)\n#define ford(i,a,b) for(int i=(int)a;i>=(int)b;i--)\n#define rep(i,n) for(int i=0; i<(int)n;i++)\n#define ll long long\n#define pi 3,14159\n#define e 2,71\n#define maxi 1e9\n#define mini 1e-9\nint binpow (int a, int n) {\n int res = 1;\n while (n) {\n if (n & 1)\n res *= a;\n a *= a;\n n >>= 1;\n }\n return res;\n}\nint factmod (int n, int p) {\n int res = 1;\n while (n > 1) {\n res = (res * ((n/p) % 2 ? p-1 : 1)) % p;\n for (int i=2; i<=n%p; ++i)\n res = (res * i) % p;\n n /= p;\n }\n return res % p;\n}\nint gcd (int a, int b) {\n while (b) {\n a %= b;\n swap (a, b);\n }\n return a;\n}\n\nint main()\n{int a,b,nok;\n ifstream in(\"input.txt\");\n cin>>a>>b;\n a\n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint GCD(int a, int b)\n{\n return a ? GCD(b % a, a) : b;\n}\nint LCM(int a, int b)\n{\n return a / GCD(a,b) * b;\n}\nint main(void)\n{\n int a,b,d,r1=0,r2 = 0;\n set s;\n scanf(\"%d%d\",&a,&b);\n d = LCM(a,b);\n for (int i = a; i <= d; i += a)\n s.insert(i);\n for (int i = b; i <= d; i += b)\n s.insert(i);\n set::iterator it;\n it = s.begin();\n while (it != s.end())\n {\n if ((((*it) % a) == 0) && (((*it) % b) == 0))\n {\n if (a > b)\n r1 ++; else\n r2 ++;\n } else\n if (((*it) % a) == 0)\n r1 ++; else\n r2 ++;\n it++;\n }\n if (r1 > r2)\n printf(\"Dasha\\n\"); else\n if (r1 < r2)\n printf(\"Masha\\n\"); else\n printf(\"Equal\\n\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fe4bc706edfe52e87f1ce8f287d00c9c", "src_uid": "06eb66df61ff5d61d678bbb3bb6553cc", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint NOK( int x, int y )\n{\n\treturn x * y / __gcd( x, y );\n}\n\nint main()\n{\n\tint A, B, X;\n\t\n\tcin >> A >> B;\n\t\n\tX = NOK( A, B );\n\tif ( A > B )\n\t{\n\t\tif ( X / A == X / B - 1 )\n\t\t\tcout << \"Equal\";\n\t\telse\n\t\t\tcout << \"Masha\";\n\t}\n\telse\n\t{\n\t\tif ( X / B == X / A - 1 )\n\t\t\tcout << \"Equal\";\n\t\telse\n\t\t\tcout << \"Dasha\";\n\t}\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5e4088ba860831c164c09e04e21e3380", "src_uid": "06eb66df61ff5d61d678bbb3bb6553cc", "difficulty": 1500.0} {"lang": "GNU C++17", "source_code": "//vijaya code shi kra do\n// jai maa vijaya\n//gonu balle balle\n// I want to sleep(maybe not alone)(khichik khichik)(aaaaaaaaah....)\n//me nahi htaunga\n//mera code meri mrzi\n// toh marr ja\n//koi maar de bs behencode\n//tu kahe toh main maar dun?Fuck me\n#include\n#include \n#define ll long long int\n#define ld long double\n#define IOS cin.tie(NULL);cout.tie(NULL)\n#define F first\n#define ii pair\n#define vi vector\n#define vii vector\n#define sc(i) scanf(\"%lld\",&i);\n#define S second\n#define pb push_back\n#define forn(i,n) for(int i=0;i<(int)n;i++)\nusing namespace std;\n//ll const mod=998244353;\n/*\nll arr1[1000009];\nll parent[1000009];\nvoid sievefun(ll n){\n for(ll i=2;i<=n;i++){\n if(arr1[i]==0){\n parent[i]=i;\n for(ll j=i*i;j<=n;j+=i){\n if(arr1[j]==0)\n parent[j]=i;\n arr1[j]=1;\n }\n }\n }\n}\n*/\nll countDivisors(ll n)\n{\n ll cnt = 0;\n for (ll i = 1; i <= sqrt(n); i++) {\n if (n % i == 0) {\n // If divisors are equal,\n // count only one\n if (n / i == i)\n cnt++;\n\n else // Otherwise count both\n cnt = cnt + 2;\n }\n }\n return cnt;\n}\nll power(ll x, ll y) {\n\tll temp;\n\tif( y == 0)\n\t\treturn 1;\n\ttemp = power(x, y/2);\n\tif (y%2 == 0)\n\t\treturn ((temp)*(temp));\n\telse\n\t\treturn (((x))*((temp*temp)));\n}\nll gcd1(ll a, ll b){\nif (a == 0)\n return b;\nreturn gcd1(b % a, a);\n}\nll lcm(ll a, ll b)\n{\nreturn (a*b)/gcd1(a, b);\n}\n\nld arr[5009][5009];\nint main(){\n IOS;\n ll n,t;\n ld p;\n cin>>n>>p>>t;\n arr[0][n]=1;\n ld temp=1;\n ld ans=0;\n for(int i=1;i<=t;i++){\n \tans+=temp*p;\n \ttemp=0;\n \tfor(int j=1;j\nusing namespace std;\n\ndouble dp[2003][2003];\n\ndouble escalator(int man, int time, int p){\n if(man <= 0 || time <= 0)return 0.0;\n if(dp[man][time] != 0.0)return dp[man][time];\n return dp[man][time] = ((1.0-p)*escalator(man, time+1, p)+p*(1.0+escalator(man+1, time+1, p)));\n}\n\nint main(){\n int n, t;\n double p;\n memset(dp, 0.0, sizeof(dp));\n cin >> n >> p >> t;\n double ans = escalator(n, t, p);\n printf(\"%.7llf\\n\", ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6bed2f6f55f5dc2393dc037193b08d70", "src_uid": "20873b1e802c7aa0e409d9f430516c1e", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n\nstring s,t;\nint a[411111]={0},b[411111]={0};\n\nint N,T,done[5000][5000];\ndouble p,dp[5000][5000];\n\ndouble f(int n,int t){\n if(n>=N || t>=T)return 0;\n if(done[n][t]==1)return dp[n][t];\n done[n][t]=1;\n return dp[n][t]=(1-p)*f(n,t+1)+p*(1+f(n+1,t+1));\n}\n\n\n\nint main(){\n memset(done,0,sizeof(done));\n cin>>N>>p>>T;\n cout<\nusing namespace std;\n\nstring s,t;\nint a[411111]={0},b[411111]={0};\n\nint N,T,done[5000][5000]={0};\ndouble p,dp[5000][5000];\n\ndouble f(int n,int t){\n if(n>=N || t>=T)return 0;\n if(done[n][t]==1)return dp[n][t];\n done[n][t]=1;\n return dp[n][t]=(1-p)*f(n,t+1)+p*(1+f(n+1,t+1));\n}\n\n\n\nint main(){\n cin>>N>>p>>T;\n printf(\"%.7lf\\n\",f(0,0));\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "aec9cc138a40a1b2fd0dd71ca56d1ebf", "src_uid": "20873b1e802c7aa0e409d9f430516c1e", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include // std::cout\n#include // std::find\n#include // std::vector\n#include \n#include \n#include \nusing namespace std;\nint get_mint(string time){\n string h;\n int l;\n h+=time[3];\n h+=time[4];\n l=atoi(h.c_str());\n return l;\n}\nint get_hour(string time){\n string h;\n int l;\n h+=time[0];\n h+=time[1];\n l=atoi(h.c_str());\n return l;\n}\nvoid OutputS(int h1,int h2,int m1,int m2){\n int h = (h2-h1)*60;\n int m = (m2-m1)+h;\n int k=(m/2)+m1;\n int H = h1+(k/60);\n int M = k-(k/60)*60;\n \n (H<10)? cout<<0<>clock1;\n h1 = get_hour(clock1);\n m1=get_mint(clock1);\n cin>>clock2;\n h2 = get_hour(clock2);\n m2=get_mint(clock2);\n if(clock1==\"13:13\"){\n cout<<\"Hacker !\";\n }else{\n OutputS(h1,h2,m1,m2); \n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "de3f8851beb89f6c6104b7af764a1889", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include // std::cout\n#include // std::find\n#include // std::vector\n#include \n#include \n#include \nusing namespace std;\nint get_mint(string time){\n string h;\n int l;\n h+=time[3];\n h+=time[4];\n l=atoi(h.c_str());\n return l;\n}\nint get_hour(string time){\n string h;\n int l;\n h+=time[0];\n h+=time[1];\n l=atoi(h.c_str());\n return l;\n}\nvoid OutputS(int h1,int h2,int m1,int m2){\n int h = (h2-h1)*60;\n int m = (m2-m1)+h;\n int k=(m/2)+m1;\n int H = h1+(k/60);\n int M = k-(k/60)*60;\n \n (H<10)? cout<<0<>clock1;\n h1 = get_hour(clock1);\n m1=get_mint(clock1);\n cin>>clock2;\n h2 = get_hour(clock2);\n m2=get_mint(clock2);\n if(clock1==\"13:00\"){\n cout<<\"Hacker !\";\n }else{\n OutputS(h1,h2,m1,m2); \n }\n \n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2ff348f4f1984679c93d1fbf8bd78b7d", "src_uid": "f7a32a8325ce97c4c50ce3a5c282ec50", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define all(v) ((v).begin()),((v).end())\n#define sz(v) ((int)((v).size()))\ntypedef\tlong long ll;\ntypedef long double ld;\ntypedef unsigned long long ull;\n//typedef vector vi;\ntypedef vector > vi2;\nvoid file()\n{\n#ifndef ONLINE_JUDGE\n freopen(\"in.txt\", \"r\", stdin);\n freopen(\"out.txt\", \"w\", stdout);\n#endif\n}\nvoid fast()\n{\n std::ios_base::sync_with_stdio(0);\n cin.tie(NULL);\n}\n// cout< m;\n//map::iterator it;\n//for(it=m.begin(); it!=m.end(); it++){}\n/* \u0628\u0633\u0645 \u0627\u0644\u0644\u0647 \u0627\u0644\u0631\u062d\u0645\u0646 \u0627\u0644\u0631\u062d\u064a\u0645 */\n//int arx[1000000];\nint test[26];\nint main()\n{char ch1 ,ch2;\nll h1,h2,m1,m2;\n cin>>h1>>ch1>>m1>>h2>>ch2>>m2;\n if(h260)\n {\n int z=m1-60;\n m1=0;\n m1=z;\n h1+=1;\n }\n if(h1<9&&m1<9)\n cout<<\"0\"<9)\n cout<<\"0\"<9&&m1<9)\n cout<\n#define lli long long int\n#define pb push_back\n#define f(i,a,b) for(i=a;i<=b;i++)\n#define r(i,a,b) for(i=a;i>=b;i--)\n#define fast ios :: sync_with_stdio(false); cin.tie(0);\nusing namespace std;\nvector v;\nint main ()\n{\n fast;\n lli i,j=0,n=0,o=0,m,l,p,w,x,y;\n char z;\n cin>>m>>z>>n;\n cin>>x>>z>>y;\n if (m\nusing namespace std;\n\nint check(long long n)\n{\n int flag = 0;\n for(int i=2; i<=n/2; ++i)\n {\n // condition for nonprime number\n if(n%i==0)\n {\n flag=1;\n break;\n }\n }\n\n if (flag==0)return 1;\n else return 0;\n}\n\nint main()\n{\n long long n;\n\n cin>>n;\n if( n == 2 )cout<<1<\n\nusing namespace std;\n\ntypedef long long ll;\n\nconst int INF = 2e9;\nconst int N = 1e4 + 50;\n\nbool prime(ll n) {\n for (ll i = 2; i * i <= n; i++) {\n if (n % i == 0)\n return false;\n }\n return true;\n}\n\nint main() {\n ios::sync_with_stdio(0);\n ll n;\n cin >> n;\n if (prime(n))\n cout << 1;\n else\n if (n % 2 == 0)\n cout << 2;\n else\n cout << 3;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "09aed860e2a0741a0d7021410c1bde7c", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n\nusing namespace std;\n\nbool prost(long n)\n{\n long i;\n for (i=2; i<=sqrt(n); i++)\n if (n%i==0)\n return 0;\n return 1;\n}\n\nint main()\n{\n long n,rez,k,m;\n scanf(\"%ld\",&n);\n if (prost(n))\n {\n printf(\"1\");\n return 0;\n }\n if (n%2==0)\n {\n printf(\"2\");\n return 0;\n }\n\n m=n-(n%6);\n\n for (k=(m/6); k>=1; k--)\n if ((6*k+1+1\n#define pb push_back\n#define mp make_pair\n#define F first\n#define S second\nusing namespace std;\ntypedef long long int ll;\ntypedef unsigned long long int llu;\n\nbool prime(ll n){\n\tif(n%2==0) return false;\n\tfor (int i = 2; i <= sqrt(n); i++)\n\t{\n\t\tif(n%i==0) return false;\n\t}\n\treturn true;\n}\n\nvector divisores(ll n){\n\tvector div;\n\tdouble raiz = sqrt(n);\n\tll raizInt = raiz;\n\tif(raiz == raizInt) div.push_back(raizInt);\n\tfor (ll i = 1LL; i < sqrt(n); i++)\n\t{\n\t\tif(n%i == 0){\n\t\t\tdiv.push_back(i);\n\t\t\tdiv.push_back(n/i);\n\t\t}\n\t}\n\tsort(div.begin(), div.end());\n\treturn div;\n}\n\nint main(){\n\tll n;\n\twhile (cin >> n)\n\t{\n\t\tif(prime(n)){\n\t\t\tcout << 1 << endl;\n\t\t\tcontinue;\n\t\t}\n\t\tvector div;\n\t\t\n\t\t\n\t\tdiv = divisores(n);\n\t\t//~ cout << endl;\n\t\tll aux;\n\t\tif(n==2){\n\t\t\tcout << \"1\\n\";\n\t\t\tcontinue;\n\t\t\t//~ return 0;\n\t\t}else if(n==3){\n\t\t\tcout << \"1\\n\";\n\t\t\t//~ return 0;\n\t\t\tcontinue;\n\t\t}else if(n==4){\n\t\t\tcout << \"2\\n\";\n\t\t\t//~ return 0;\n\t\t\tcontinue;\n\t\t}else if(n==5){\n\t\t\t\tcout << \"1\\n\";\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\n\t\t\tif(n%2==0){\n\t\t\t\tcout << 2 << endl;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\n\t\tll ans = 0;\n\t\tll atual=n;\n\t\twhile (n>0)\n\t\t{\n\t\t\tfor (int i = atual-2; i >= 2; i--)\n\t\t\t{\n\t\t\t\tif(prime(i)){\n\t\t\t\t\taux = i;\n\t\t\t\t\tans++;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t//~ cout << \"n = \" << n << \" aux = \" << aux << endl;\n\t\t\t\n\t\t\tif(n-aux==1){\n\t\t\t\tatual--;\n\t\t\t\tans--;\n\t\t\t\tcontinue;\n\t\t\t}else{\n\t\t\t\tn-=aux;\n\t\t\t\tatual = n;\n\t\t\t}\n\t\t\tif(n==2){\n\t\t\t\tans++;\n\t\t\t\t//~ cout << ans << \"\\n\";\n\t\t\t\tbreak;\n\t\t\t}else if(n==3){\n\t\t\t\tans++;\n\t\t\t\t//~ coutE << ans << \"\\n\";\n\t\t\t\tbreak;\n\t\t\t}else if(n==4){\n\t\t\t\tans+=2;\n\t\t\t\t//~ cout << ans << \"\\n\";\n\t\t\t\tbreak;\n\t\t\t}else if(n==5){\n\t\t\t\tans++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tcout << min(ans, div[div.size()-1]) << endl;\n\t}\n\t\n\t\n\t\n\t\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a854c5cf24c4054e38d02bde9600845c", "src_uid": "684ce84149d6a5f4776ecd1ea6cb455b", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint len;\nchar S[1000];\n\nint main(){\n\n\tint i,j=0;\n\tchar t[]=\"CODEFORCES\\0\";\n\n\tscanf(\"%s\",S);\n\t\n\tlen=strlen(S);\n\n\tfor(i=0;i\n\nusing namespace std;\nstring org = \"CODEFORCES\";\nint main() {\n string s;\n cin >> s;\n int count = 0;\n for (int i = 0; i < (int)(s).size(); ++i) {\n if(org[count] == s[i])\n count++;\n }\n if(count == (int)(org).size())\n puts(\"YES\");\n else\n puts(\"NO\");\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9f099c3e98e4330aac7e044207f17693", "src_uid": "bda4b15827c94b526643dfefc4bc36e7", "difficulty": 1400.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n//8739\nconst double PI = 3.14159265358979323846;\nconst long long MODUL = 1000000007;\nconst long long MAXINT = 2e9 + 2;\nconst long long MAXLL = 2e18 + 2;\nconst double eps = 1e-11;\nconst int MAXN = 5e4 + 10;\n\nint main()\n{\n ios_base::sync_with_stdio(0);\n string s, t(\"CODEFORCES\");\n int n, m, pt(0);\n cin >> s;\n n = s.size();\n m = t.size();\n for(int i(0); i < n && pt < m; ++i)\n if(s[i] == t[pt])\n ++pt;\n cout << (pt == m ? \"YES\" : \"NO\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3828c4bf7684ac089915f47ba8f347da", "src_uid": "bda4b15827c94b526643dfefc4bc36e7", "difficulty": 1400.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n#define mst(A,k) memset(A,k,sizeof(A))\ntypedef long long ll;\n\nint main(){\n string str,c = \"CODEFORCES\";\n cin>>str;\n int l = str.length();\n int s = 0,ll = 10;\n for(int i=0; i\n#include \n#include \n#include \nusing namespace std;\ninline int read()\n{\n\tint s = 0; char c; while((c=getchar())<'0'||c>'9');\n\tdo{s=s*10+c-'0';}while((c=getchar())>='0'&&c<='9');\n\treturn s;\n}\nconst int N = 110;\nint n,m,t,rev,rt;\nchar mp[N][N];\nbool work()\n{\n\tint i,j;\n\tif(t>(n-1)*(m-1)*4) return 0;\n\t//if(n<=m) rev = 0; else rev = 1, swap(n,m);\n\tfor(i=1;i<=n;i++) for(j=1;j<=m;j++) mp[i][j] = '.';\n\tmp[1][1] = mp[2][1] = '*';\n\tfor(i=2;i<=n;i++)\n\t{\n\t\tif(i>2) t--, mp[i][1] = '*'; j = 2;\n\t\tif(t<4) break;\n\t\tfor(j=2;j<=m&&t>=4;j++)\n\t\t\tmp[i-1][j-1] = mp[i-1][j] = mp[i][j-1] = mp[i][j] = '*', t -= (i>2&&j==m)?3:4;\n\t\tif(t<4) break;\n\t}\n\tif(i==2&&j<=m)\n\t{\n\t\tswitch(t)\n\t\t{\n\t\t\tcase 1: mp[1][j] = '*'; break;\n\t\t\tcase 2: if(j==2) mp[2][2] = mp[3][1] = '*'; else mp[1][j] = mp[3][1] = '*'; break;\n\t\t\tcase 3: if(j==2) mp[3][3] = mp[2][3] = '*'; mp[1][j] = mp[3][j-1] = mp[3][j] = '*'; break;\n\t\t}\n\t}\n\telse\n\t{\n\t\tswitch(t)\n\t\t{\n\t\t\tcase 1: if(j3) mp[i+1][2] = '*'; \n\t\t\t\telse if(i=4)\n\t\t\t\t\t{\n\t\t\t\t\t\tmp[i+1][1] = mp[i+1][m-1] = '*';\n\t\t\t\t\t\tif(j==m) mp[i+1][m] = '*';\n\t\t\t\t\t}\n\t\t\t\t\telse return 0;\n\t\t\t\t}\n\t\t\t\telse return 0;\n\t\t\t\tbreak;\n\t\t}\n\t}\n\t/*if(rev)\n\t{\n\t\tfor(i=1;i<=n;i++) for(j=1;j\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#ifdef _WIN32\n#define LLD \"%I64d\"\n#else\n#define LLD \"%lld\"\n#endif\n\ntypedef long double ld;\ntypedef long long ll;\n\nlong long rdtsc() {\n long long tmp;\n asm(\"rdtsc\" : \"=A\"(tmp));\n return tmp;\n}\n\ninline int myrand() {\n#ifdef _WIN32\n return abs((rand() << 15) ^ rand());\n#else\n return rand();\n#endif\n}\n\ninline int rnd(int x) {\n return myrand() % x;\n}\n\n#ifdef DEBUG\n#define eprintf(...) fprintf(stderr, __VA_ARGS__)\n#else\n#define eprintf(...) ;\n#endif\n\n#define pb push_back\n#define mp make_pair\n#define sz(x) ((int)(x).size())\n#define TASKNAME \"text\"\n\nconst int inf = (int) 1.01e9;\nconst ld eps = 1e-9;\nconst ld pi = acos((ld) -1.0);\n\nvoid precalc() {\n}\n\nint n, m, k;\n\nint read() {\n if (scanf(\"%d%d%d\", &n, &m, &k) < 3) {\n return 0;\n }\n return 1;\n}\n\nconst int maxn = (int) 1e5 + 10;\nvector a;\n\n\nconst int gox[] = {1, 0, -1, 0}, goy[] = {0, 1, 0, -1};\n\nvector > used;\n\nbool ok(int x, int y) {\n return 0 <= x && x < n && 0 <= y && y < m;\n}\n\nint dfs(int x, int y) {\n used[x][y] = 1;\n int res = 1;\n for (int dir = 0; dir < 4; ++dir) {\n int nx = x + gox[dir], ny = y + goy[dir];\n if (ok(nx, ny) && a[nx][ny] == '*' && !used[nx][ny]) {\n res += dfs(nx, ny);\n }\n }\n return res;\n}\n\nconst int K = 5;\n\nint getFunc() {\n for (int i = 0; i < n; ++i) {\n for (int j = 0; j < m; ++j) {\n if (a[i][j] == '*') {\n used = vector >(n, vector(m, 0));\n int cnt = dfs(i, j);\n int want = 0;\n for (int r = 0; r < n; ++r) {\n want += count(a[r].begin(), a[r].end(), '*');\n }\n if (want != cnt) {\n return -1;\n }\n int res = 0;\n for (int i = 0; i < n - 1; ++i) {\n for (int j = 0; j < m - 1; ++j) {\n int cnt = (a[i][j] == '*') + (a[i + 1][j] == '*') + (a[i][j + 1] == '*') + (a[i + 1][j + 1] == '*');\n if (cnt == 3) {\n ++res;\n }\n if (cnt == 4) {\n res += 4;\n }\n }\n }\n return res;\n }\n }\n }\n return -1;\n}\n\nbool getAns() {\n if (n < K && m < K) {\n int cnt = n * m;\n a.resize(n);\n for (int mask = 0; mask < (1 << cnt); ++mask) {\n for (int i = 0; i < n; ++i) {\n a[i].resize(m);\n for (int j = 0; j < m; ++j) {\n a[i][j] = ((mask >> (i * m + j)) & 1) ? '*' : '.';\n }\n }\n if (getFunc() == k) {\n return 1;\n }\n }\n return 0;\n }\n\n int mx = (n - 1) * (m - 1) * 4;\n\n if (k > mx || k == mx - 1 || k == mx - 2 || k == mx - 4 || k == mx - 5) {\n return 0;\n }\n\n bool torev = 0;\n if (n > m) {\n torev = 1;\n swap(n, m);\n }\n\n if (k == mx - 8) {\n if (n != 3) {\n swap(n, m);\n return 0;\n }\n }\n\n\n if (k == mx - 8) {\n for (int i = 0; i < n; ++i) {\n a[i] = string(m - 1, '*') + \".\";\n }\n } else {\n for (int i = 0; i < n; ++i) {\n a[i] = string(m, !i ? '*' : '.');\n }\n int left = k;\n for (int i = 1; i < n && left > 0; ++i) {\n if (left < 5) {\n if (left >= 2) {\n a[i][2] = '*';\n left -= 2;\n }\n if (left >= 1) {\n a[i][0] = '*';\n left -= 1;\n }\n if (left >= 1) {\n a[i][m - 1] = '*';\n left -= 1;\n }\n break;\n }\n a[i][0] = a[i][1] = '*';\n left -= 5;\n for (int j = 2; j < m && left > 0; ++j) {\n int cur = (j == m - 1 ? 3 : 4);\n if (left < cur) {\n if (cur == 4) {\n if (left == 1) {\n a[i].back() = '*';\n --left;\n break;\n }\n if (left == 2) {\n if (j < m - 2) {\n a[i][j + 1] = '*';\n } else {\n assert(i + 1 < n);\n a[i + 1][1] = '*';\n }\n left -= 2;\n break;\n }\n if (left == 3) {\n if (j < m - 3) {\n a[i][j + 1] = a[i][m - 1] = '*';\n } else {\n if (j == m - 3) {\n assert(i + 1 < n);\n a[i][m - 2] = a[i + 1][0] = '*';\n } else {\n assert(j == m - 2);\n assert(i + 1 < n);\n a[i][m - 1] = a[i + 1][1] = '*';\n }\n }\n left -= 3;\n break;\n }\n } else {\n assert(i + 1 < n);\n a[i + 1][left - 1] = '*';\n left = 0;\n break;\n }\n assert(0);\n }\n left -= cur;\n a[i][j] = '*';\n }\n }\n assert(!left);\n }\n\n if (torev) {\n swap(n, m);\n vector b(n);\n swap(a, b);\n for (int i = 0; i < n; ++i) {\n a[i].resize(m);\n for (int j = 0; j < m; ++j) {\n a[i][j] = b[j][i];\n }\n }\n }\n\n for (int i = 0; i < n; ++i) {\n assert(sz(a[i]) == m);\n for (int j = 0; j < m; ++j) {\n assert(a[i][j] == '*' || a[i][j] == '.');\n }\n }\n assert(getFunc() == k);\n return 1;\n}\n\nvoid solve() {\n if (!getAns()) {\n printf(\"-1\\n\");\n return;\n }\n for (int i = 0; i < n; ++i) {\n printf(\"%s\\n\", a[i].c_str());\n }\n}\n\nint main() {\n srand(rdtsc());\n precalc();\n#ifdef DEBUG\n int T = 20;\n for (n = 3; n < T; ++n) {\n for (m = 3; m < T; ++m) {\n for (k = 0; k <= (n - 1) * (m - 1) * 4 + 1; ++k) {\n //eprintf(\"%d %d %d\\n\", n, m, k);\n if (getAns()) {\n int diff = (n - 1) * (m - 1) * 4 - k;\n if (diff == 4 || diff == 8) {\n eprintf(\"%d %d %d -> %d\\n\", n, m, k, diff);\n }\n }\n }\n }\n }\n#endif\n\n#ifdef LOCAL\n freopen(TASKNAME\".out\", \"w\", stdout);\n assert(freopen(TASKNAME\".in\", \"r\", stdin));\n#endif\n\n int t;\n scanf(\"%d\", &t);\n bool first = 1;\n while (1) {\n if (!read()) {\n break;\n }\n if (!first) {\n printf(\"\\n\");\n }\n first = 0;\n solve();\n#ifdef DEBUG\n eprintf(\"Time %.2f\\n\", (double) clock() / CLOCKS_PER_SEC);\n#endif\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "caca4cbd1e4a3b9afdf25725f96ab105", "src_uid": "3ffed4f6339a498499e84526233a684b", "difficulty": 3100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define fr first\n#define sc second\n#define mp make_pair\n#define pb push_back\n#define epr(...) fprintf(stderr, __VA_ARGS__)\n#define db(x) cerr << #x << \" = \" << x << endl\n#define db2(x, y) cerr << \"(\" << #x << \", \" << #y << \") = (\" << x << \", \" << y << \")\\n\"; \n#define db3(x, y, z) cerr << \"(\" << #x << \", \" << #y << \", \" << #z << \") = (\" << x << \", \" << y << \", \" << z << \")\\n\"\n#define all(a) (a).begin(), (a).end()\n\n#define equal equalll\n#define less lesss\nconst int N = -1;\nconst long long INF = 1e9 + 19;\nconst int dx[4] = {1, 0, -1, 0};\nconst int dy[4] = {0, 1, 0, -1};\n\nint n, m, k;\n\nvoid read() {\n scanf(\"%d%d%d\", &n, &m, &k);\n //db3(n, m, k);\n}\nset < pair < int, int > > forCheck;\n\nint getAll(int n, int m) {\n return 4 * (n - 1) * (m - 1);\n}\n\nbool check(int x, int y) {\n return 0 <= x && x < n && 0 <= y && y < m;\n}\n\nvector> norm(pair p1, pair p2, pair p3) {\n if (p2 > p3) swap(p2, p3);\n return {p1, p2, p3};\n}\n\nvoid print(vector < vector < char > > board, bool flagSwap) {\n if (flagSwap == 0) {\n for (int i = 0; i < n; i++, puts(\"\"))\n for (int j = 0; j < m; j++)\n printf(\"%c\", board[i][j]);\n }\n else {\n swap(n, m);\n for (int i = 0; i < n; i++, puts(\"\"))\n for (int j = 0; j < m; j++)\n printf(\"%c\", board[j][i]);\n }\n}\n\nint calcRes(const vector>& board) {\n int res = 0;\n for (int i = 0; i < n; i++)\n for (int j = 0; j < m; j++) {\n for (int id = 0; id < 4; id++) {\n int x1 = i + dx[id];\n int y1 = j + dy[id];\n int x2 = i + dx[(id + 1) % 4];\n int y2 = j + dy[(id + 1) % 4];\n if (check(x1, y1) && check(x2, y2) && board[i][j] == '*' && board[x1][y1] == '*' && board[x2][y2] == '*') {\n res++; \n }\n }\n }\n return res;\n}\n\nbool uu[10][10];\nint cc;\n\nvoid dfs(int x, int y, const set>& blocked) {\n uu[x][y] = 1;\n cc++;\n for (int i = 0; i < 4; i++) {\n int x1 = x + dx[i];\n int y1 = y + dy[i];\n if (check(x1, y1) && !uu[x1][y1] && blocked.count(mp(x1, y1)) == 0) {\n dfs(x1, y1, blocked);\n }\n }\n}\n\nbool brute() {\n vector < pair < int, int > > data(all(forCheck));\n int sz = data.size();\n set < pair < int, int > > g;\n for (auto p: data) {\n for (int i = 0; i < 4; i++) {\n int x = p.fr + dx[i];\n int y = p.sc + dy[i];\n g.insert(mp(x, y));\n }\n }\n set < vector < pair < int, int > > > tri;\n \n for (auto p: g) {\n for (int i = 0; i < 4; i++) {\n int x1 = p.fr + dx[i];\n int y1 = p.sc + dy[i];\n int x2 = p.fr + dx[(i + 1) % 4];\n int y2 = p.sc + dy[(i + 1) % 4];\n if (check(p.fr, p.sc) && check(x1, y1) && check(x2, y2)) \n tri.insert(norm(p, mp(x1, y1), mp(x2, y2)));\n } \n } \n \n\n for (int mask = 0; mask < (1 << sz); mask++) {\n //mask = 27;\n set> blocked;\n for (int i = 0; i < sz; i++) \n if (((mask >> i) & 1) == 0) {\n blocked.insert(data[i]);\n } \n int cnt = getAll(n, m);\n for (auto tr: tri) {\n bool flag = 0;\n flag |= blocked.count(tr[0]) == 1;\n flag |= blocked.count(tr[1]) == 1;\n flag |= blocked.count(tr[2]) == 1;\n cnt -= flag;\n }\n bool con = 1;\n if (n * m <= 16) {\n memset(uu, 0, sizeof(uu));\n bool ff = 0;\n for (int i = 0; !ff && i < n; i++)\n for (int j = 0; !ff && j < m; j++) {\n if (blocked.count(mp(i, j)) == 0) {\n cc = 0;\n dfs(i, j, blocked);\n //db2(cc + blocked.size(), n * m);\n if (cc + (int)blocked.size() == n * m)\n con = 1;\n else\n con = 0;\n ff = 1;\n break;\n }\n }\n }\n //db3(con, cnt, k);\n if (cnt == k && con) {\n vector> board(n, vector(m, '*'));\n for (auto p: blocked)\n board[p.fr][p.sc] = '.';\n assert(calcRes(board) == k);\n print(board, 0);\n return 1;\n }\n //exit(0);\n }\n return 0;\n}\n\n\n\nvoid solve() {\n if (k == 0) {\n vector> board(n, vector(m, '.'));\n board[0][0] = '*';\n print(board, 0);\n return;\n }\n forCheck.clear();\n if (n * m <= 12) {\n for (int i = 0; i < n; i++)\n for (int j = 0; j < m; j++)\n forCheck.insert(mp(i, j));\n if (brute())\n return;\n else {\n puts(\"-1\");\n return;\n }\n }\n else {\n forCheck.clear();\n for (int i = 0; i < 3; i++){\n forCheck.insert(mp(0, i));\n forCheck.insert(mp(0, m - 1 - i));\n }\n if (brute())\n return;\n forCheck.clear();\n for (int i = 0; i < 3; i++){\n forCheck.insert(mp(i, 0));\n forCheck.insert(mp(n - 1 - i, 0));\n }\n if (brute())\n return;\n }\n\n bool flagSwap = 0;\n if (n > m) {\n swap(n, m);\n flagSwap = 1;\n }\n\n if (k > getAll(n, m)) {\n puts(\"-1\");\n return;\n }\n int cur = 1;\n for (; getAll(cur + 1, m) <= k; cur++);\n\n assert(m >= 5);\n int curM = 0;\n int need = k - getAll(cur, m);\n //db(need);\n for (; ((curM + 1) - 1) * 4 + 1 <= need; curM++);\n\n if (curM >= 1)\n need -= (curM - 1) * 4 + 1;\n\n //db(need);\n vector> board(n, vector(m, '.'));\n for (int i = 0; i < cur; i++)\n for (int j = 0; j < m; j++)\n board[i][j] = '*';\n for (int j = 0; j < curM; j++)\n board[cur][j] = '*';\n int xup = min(need, m - curM - 1);\n\n need -= xup;\n for (int j = m - xup; j < m; j += 2)\n board[cur][j] = '*';\n\n //print(board, 0);\n //db(need);\n\n if (need > 0 && cur + 1 < n) {\n //assert(cur + 1 < n);\n for (int j = need - 1; j >= 0; j -= 2)\n board[cur + 1][j] = '*';\n assert(need < curM);\n need = 0;\n }\n int res = calcRes(board);\n assert(res + need == k);\n\n if (need == 0) {\n print(board, flagSwap);\n return;\n }\n else \n puts(\"-1\");\n\n\n\n}\n\nvoid stress() {\n n = 4;\n m = 10;\n int T = (n - 1) * (m - 1) * 4;\n for (int t = 0; t <= T; t++) {\n k = t;\n db3(n, m, k);\n solve();\n }\n}\n\n\nint main(){\n#ifdef MY_DEBUG\n freopen(\"in\", \"r\", stdin);\n //freopen(\"test.txt\", \"r\", stdin);\n //freopen(\"out\", \"w\", stdout);\n#endif\n //printf(\".*.\\n***\\n.*.\\n\\n\");\n //printf(\"**.\\n**.\\n*..\\n\\n\");\n //printf(\".*.\\n***\\n*..\\n\");\n //return 0;\n if (1) {\n int k = 1;\n scanf(\"%d\", &k);\n for (int tt = 0; tt < k; tt++) {\n //db(tt);\n read();\n solve();\n if (tt + 1 != k)\n puts(\"\");\n }\n }\n else {\n stress();\n }\n\n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "27d48c24461d26aa8dc2d5d3fb28be45", "src_uid": "3ffed4f6339a498499e84526233a684b", "difficulty": 3100.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n\n#define rank krevedka\n#define left trulala\n#define rigth trulalo\n#define ran rank\nusing namespace std;\n/*\nvoid solveA(){\n\n int n,m;\n cin >> n >>m;\n int tot = 0;\n for(int i = 0; i < n; i++)\n for(int j = 0; j < m; j++)\n b[tot++] = {i,j};\n sort(b, b + n * m);\n int k;\n cin >> k;\n for(int i = 0; i < k; i++)\n cin >> a[i];\n sort(a, a + k);\n bool ok = true;\n for(int i = 0; i < k; i++)\n if(a[i] < b[i].first + b[i].second){ ok = false;}\n\n cin >> k;\n for(int i = 0; i < k; i++)\n cin >> a[i];\n sort(a, a + k);\n for(int i = 0; i < k; i++)\n if(a[i] < b[i].first + b[i].second){ ok = false;}\n\n}\n*/\n\nint x, y, n, m;\n\nvector a[200500];\n\nvoid go(bool get_next = false){\n a[x][y] = '*';\n if(get_next){\n x++;\n if(x == m){ x = 0; y++;}\n }\n}\n\n\nbool solveC(){\n int k;\n scanf(\"%d%d%d\",&n,&m,&k);\n for(int i = 0; i < n; i++){\n a[i].resize(m+10);\n for(int j = 0; j < m; j++)\n a[i][j] = '.';\n a[i][0] = '*';\n a[i][m] = '\\0';\n }\n if(k == 0) return true;\n if(n == 1 || m == 1) return false;\n x = 0;\n y = 1;\n while(k){\n if(y == m) { return false; }\n int l = 4;\n if(x == 0) l = 1; else\n if(x == m - 1) l = 3;\n if(k >= l){ k -= l; go(true); continue;}\n if(l == 3 && y == m - 1) return false;\n if(l == 3){\n if(k == 1 && x > 1){x = 0; y++; go(); return true;}\n if(k == 1){x = 0; y++; go(); x++; go(); return true;}\n // k == 2\n if(x > 1){ y++; go(); x--; go(); return true;}\n y++; go();\n x--; go();\n y++; go();\n if(y >= m) return false;\n return true;\n }\n // l == 4\n if(k == 1){\n x = n - 1;\n go();\n return true;\n }\n if(k == 2 && x + 1 != n - 1){\n x++;\n go();\n return true;\n }\n if(k == 2 && y == m - 1) return false;\n if(k == 2){\n x++;\n go();\n y++;\n go();\n x--;\n go();\n return true;\n }\n // k == 3\n if(x + 3 <= n - 1){\n x++;\n go(); // + 2\n x = n - 1;\n go(); // + 1\n return true;\n }\n if(y == m - 1) return false;\n if(x + 2 <= n - 1){\n x++;\n go();\n y++;\n go();\n x++;\n go();\n return true;\n }\n //if(x + 1 <= n - 1){\n x++;\n go();\n y++;\n go();\n x--;\n go();\n x = 0;\n go();\n return true;\n //}\n }\n return true;\n\n}\n\nint main()\n{\n int t;\n scanf(\"%d\",&t);\n for(int q = 0; q < t; q++){\n if(q) printf(\"\\n\");\n if(!solveC()) puts(\"-1\"); else{\n for(int i = 0; i < n; i++)\n puts(&a[i][0]);\n }\n }\n return 0;\n}\n// 010011\n// 3 7 2 3\n/*\n\n\n\n6 5\n0 0 0 0 0\n1 1 1 1 1\n0 0 0 0 1\n1 1 1 0 1\n1 0 0 0 1\n1 1 1 1 1\n*/\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d251b346e5724f789108e9513e0a715d", "src_uid": "3ffed4f6339a498499e84526233a684b", "difficulty": 3100.0} {"lang": "MS C++", "source_code": "#include \nusing namespace std;\n\nint main() {\n\tlong int price, change;\n\tint r, quantity = 1;\n\tcin >> price >> r;\n\tchange = price%10;\n\twhile (change != r && change != 0) {\n\t\t++quantity;\n\t\tchange = (price * quantity)%10;\n\t}\n\tcout << quantity;\n\tsystem(\"pause\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9501b5eabc34f882d97f91df96d84443", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int k,r,m;\n cin>>k>>r;\n m=k/r;\n if(k%10==r)\n {\n cout<<1;\n }\n else if(k%5==0)\n {\n cout<<2;\n }\n else if(k%10==0)\n {\n cout<<1;\n }\n else{\n cout<<(k*r)/m;\n} }\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f396c9a0961e35b1e5b178afe91df92c", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint main(){\nint ans,div,mul,i,k,r,n;\nscanf(\"%d %d\",&k,&r);\nfor(i=1;i<10;i++){\n mul=k*i;\n div=mul%10;\n if(div==r)\n { ans=i; }\nelse if(div==0){\n ans=i; break; }\n }\nprintf(\"%d\",ans); }\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d854fd6267403a29352130d6e80e2320", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\n#define ll long long\n\nusing namespace std;\n\n\nint main()\n{\n\nll k,r;\ncin>>k>>r;\nll m=k;\nif(k%5==0)\n{\n\tif(k%10==0)\n\t cout<<\"1\";\n\t else\n cout<<\"2\";\n return 0; \t\n}\nelse\n while(r!=k%10)\n {\n \tk+=m;\n }\n\ncout<\n#include \n#include \nusing namespace std;\n\nint main()\n{\n int n,pos,l,r,res;\n while(scanf(\"%d%d%d%d\",&n,&pos,&l,&r)==4)\n {\n if(posr)\n {\n if(l>1)\n res=pos-l+2;\n else\n res=pos-r+1;\n }\n else\n {\n if(l>1&&r1)\n res=pos-l+1;\n else if(r\nusing namespace std;\nint main()\n{\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n int tabsNumber, cursorPos, l, r;\n cin >> tabsNumber >> cursorPos >> l >> r;\n int a = 1, b = tabsNumber;\n int i = 0;\n while(a != l || b != r)\n {\n i++;\n if(cursorPos > l && a != l)\n {\n cursorPos--;\n continue;\n }\n else if(cursorPos == l && a != l)\n {\n a = l;\n continue;\n }\n if(cursorPos < r && b != r)\n {\n cursorPos++;\n continue;\n }\n else if(cursorPos == r && b != r)\n {\n b = r;\n continue;\n }\n\n }\n cout<\n\nusing namespace std;\n\nint n, pos, l, r;\n\nint main() {\n\n cin >> n >> pos >> l >> r;\n int a = 1, b = n, s = 0;\n while (a != l || b != r) {\n\n if (a != l) {\n\n if (pos == l) {\n\n s++;\n a = l;\n }\n else {\n\n pos = max(pos - 1, a);\n s++;\n }\n }\n if (b != r) {\n\n if (pos == r) {\n\n s++;\n b = r;\n }\n else {\n\n pos = min(pos + 1, b);\n s++;\n }\n }\n }\n cout << s;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "135af9424dc977486998a49fc478216a", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nint n, pos, l, r;\n\nint main() {\n\n cin >> n >> pos >> l >> r;\n int a = 1, b = n, s = 0;\n if (a != pos) {\n while (a != l) {\n\n if (pos == l) {\n\n s++;\n a = l;\n } else {\n\n pos = max(pos - 1, a);\n s++;\n }\n }\n while (b != r) {\n\n if (pos == r) {\n\n s++;\n b = r;\n } else {\n\n pos = min(pos + 1, b);\n s++;\n }\n }\n }\n else if (pos != b) {\n\n while (b != r) {\n\n if (pos == r) {\n\n s++;\n b = r;\n } else {\n\n pos = min(pos + 1, b);\n s++;\n }\n }\n while (a != l) {\n\n if (pos == l) {\n\n s++;\n a = l;\n } else {\n\n pos = max(pos - 1, a);\n s++;\n }\n }\n }\n cout << s;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6ed1ae46e36a62b1afa3477b3b66f110", "src_uid": "5deaac7bd3afedee9b10e61997940f78", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint cei(int n,int k)\n{\n if(n%k==0)return n/k;\n else return n/k+1;\n}\nint main()\n{\n int p;\n char t[16];\n cin>>p;\n cin>>t;\n int t1=p;\n vectorv;\n for(int i=0;i1)v.push_back((q-1)+'0');\n while(q%2==0){\n q/=2;\n v.push_back(2+'0');\n }\n }\n if(q!=1 && q!=0)\n v.push_back(q+'0');\n }\n sort(v.begin(),v.end());\n int u=v.size();\n for(int j=u-1;j>=0;j--)cout<\n#include\n#include\n#include\n#include\nusing namespace std;\nint cei(int n,int k)\n{\n if(n%k==0)return n/k;\n else return n/k+1;\n}\nint main()\n{\n int p;\n char t[16];\n cin>>p;\n cin>>t;\n int t1=p;\n vectorv;\n for(int i=0;i1)v.push_back(q-1);\n while(q%2==0){\n q/=2;\n v.push_back(2);\n }\n }\n if(q!=1 && q!=0)\n v.push_back(q);\n }\n sort(v.begin(),v.end());\n int u=v.size();\n for(int j=u-1;j>=0;j--)cout<\nusing namespace std;\n#define int long long\nsigned main()\n{\n int n;\n cin>>n;\nstring s;\n cin>>s;\n sort(s.begin(),s.end());\n for(int i=0;i=0;i--)\n if((s[i]!='0')&&(s[i]!='1'))\n cout<\n\nusing namespace std;\nint n,max1=0;\nstring arr,ans;\nunsigned long long prod=1;\n\nvoid recurr(string arr,int x,int c,unsigned long long product)\n{\n if(product==prod)\n {\n if(c>=max1)\n {\n max1=c;\n ans=arr;\n }\n return;\n }\n int f=1;\n for(int j=1;j<=x;j++)\n f=f*j;\n if(product*f>prod)\n return;\n arr+=to_string(x);\n for(int j=2;j<=9;j++)\n recurr(arr,j,c+1,product*f);\n}\n\nint main()\n{\n cin>>n;\n string s;\n cin>>s;\n for(int i=0;i\nusing namespace std ;\n#include \n#include \n\nint main ()\n\n{\n\tint k,n,s,p ;\n\tcin >> k >> n >> s >> p ;\n\tint c;\n\tif(n%s!=0&&n>s)\n\t{\n\t\tn=n+(s-(n%s));\n\t\tc=(n/s)*k;\n\t}\n\tif(n\nusing namespace std;\nint main (){\n\tint k,n,s,p;\n\tcin>>k>>n>>s>>p;\n\tif (k*(n/s+(n%s)/(n%s))%p==0)\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n//rep(i, 0, changed.size() - 1) changed[i].erase(remove(changed[i].begin(), changed[i].end(), ' '), changed[i].end());\n//myvector2.erase(remove_if(myvector2.begin(), myvector2.end(), EmptyStr()), myvector2.end());\n/*\nstruct EmptyStr\n{\nbool operator()(const std::string& s)\n{\nreturn (s == \"\");\n}\n};\n*/\nbool comparatorr(int i, int j)\n{\n\treturn i > j;\n}\nbool sortbysec(const pair &a,\n\tconst pair &b)\n{\n\treturn (a.first < b.first);\n}\n//priority_queue, comparatorr> minHeap;\n#define rep(i, a, b) \tfor (int i = int(a); i <= int(b); ++i)\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tfloat k, n, s, p, total = 0, sheets_per_person;\n\tcin >> k >> n >> s >> p;\n\tif (s > n)\n\t\tcout << ceil(k / p) << endl;\n\telse\n\t{\n\t\tsheets_per_person = ceil(n / s);\n\t\tcout << ceil((sheets_per_person * k) / p) << endl;\n\t}\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5804f8ed44ac64df56bf4b93be965748", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n\nint main()\n{\n int k, n, s, p, sum = 0, flag, t;\n\n cin>>k>>n>>s>>p;\n\n sum = s;\n\n for(int i = 1; i<=10000; i++)\n {\n flag = i;\n if(sum >= n)\n break;\n sum = sum + s;\n }\n\n t = flag * k;\n\n //cout<\n\n#define ll long long int\n#define inf 1<<30\n#define Pi 2*acos(0,0)\n#define pi acos(-1)\n#define PI 3.1415926535897932384626433832795\n#define mem(x,y) memset(x,y,sizeof(x))\n#define pf printf\n#define sf scanf\n#define MAX 50\n\ntemplate < class T > inline T gcd(T a,T b) {a=abs(a);b=abs(b); if(!b) return a; return __gcd(b,a%b);}\ntemplate < class T > inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/__gcd(a,b))*b;}\n//template inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}\ntemplate inline T ncr(T n,T r){return n*(n-1)/r;}\n\nusing namespace std;\n\nint main()\n{\n mapmymap;\n mymap[\"saturday\"]=1;\n mymap[\"sunday\"]=2;\n mymap[\"monday\"]=3;\n mymap[\"tuesday\"]=4;\n mymap[\"wednesday\"]=5;\n mymap[\"thursday\"]=6;\n mymap[\"friday\"]=7;\n\n ///cout<<(9%7)<>str1>>str2;\n if(mymap[str1]==mymap[str2])\n cout<<\"YES\";\n else if((mymap[str1]+3)%7==mymap[str2])\n cout<<\"YES\";\n else if((mymap[str1]+2)%7==mymap[str2])\n cout<<\"YES\";\n else\n cout<<\"NO\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cc25d78d53da109b4330de6b4b475f79", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\nconst int oo=1e9;\nconst long long ooo=1e15;\nint t[1001];\nvector >g ;\nint main()\n{\n int n,m;\n string s,s1;\n cin >>s>>s1;\n map mon;\n mon [\"monday\"]=1;\n mon [\"tuesday\"]=2;\n mon [\"wednesday\"]=3;\n mon [ \"thursday\"]=4;\n mon [\"friday\"]=5;\n mon [\"saturday\"]=6;\n mon [\"sunday\"]=7;\n if (mon[s]==mon[s1] ||mon[s1]==(3+mon[s])%7||mon[s1]==(2+mon[s])%7||mon[s1]==(mon[s])%7 )\n cout <<\"Yes\";\n else\n cout << \"No\";\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9479fee0db1aaefe3f4fe889fc69ca93", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint cal(string a)\n{\n\tif (a == \"monday\") return 1;\n\tif (a == \"tuesday\") return 2;\n\tif (a == \"wednesday\") return 3;\n\tif (a == \"thursday\") return 4;\n\tif (a == \"friday\") return 5;\n\tif (a == \"saturday\") return 6;\n\tif (a == \"sunday\") return 7;\n}\n\nbool test(int x, int y)\n{\n\tif (x <= y) {\n\t\tif (y - x == 1 || y - x > 4) return 0;\t\t\n\t\treturn 1;\n\t}\n\tif (x - y >= 4) return 1;\n\treturn 0;\n}\n\nint main()\n{\n\t//freopen(\"input.txt\", \"r\", stdin);\n\tstring a, b;\n\tcin >> a >> b;\t\t\n\tint x, y;\n\tx = cal(a);\n\ty = cal(b);\n\t//if (x > y) swap(x, y);\t\n\tif (test(x, y)) cout << \"YES\"; else cout << \"NO\";\n\tcout << endl;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5a15e470b60c1f84d5fad036d4579a80", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \nusing namespace std;\nint a[100009];\nint k[100009]; int t[100009]; int s[100009];\nint main()\n{\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n int n ,i , j , x1 = 0 , x2 = 0 , y1 = 0 , y2 = 0 , q1 , q2 , c , v; \n cin >> n;\n string m[n] , l;\n for ( i = 0 ; i < n ; i++)\n {\n cin >> l;\n m[i]=l[i];\n if ( m[i] == \"r\")\n {\n s[i]=1;\n }\n else\n {\n s[i]=2;\n }\n if ( i % 2 == 0)\n {\n k[i]=1;\n }\n else\n k[i]=2;\n if ( i % 2 == 0)\n {\n t[i]=2;\n }\n else\n t[i]=1;\n }\n for ( i = 0 ; i < n ; i++)\n {\n if ( i % 2 == 0)\n {\n if ( s[i] != t[i])\n {\n y2++;\n }\n if ( s[i] != k[i])\n {\n x1++;\n }\n }\n else\n {\n if ( s[i] != k[i])\n {\n y1++;\n } \n if ( s[i] != t[i])\n {\n x2++;\n }\n }\n }\n \n cout << x1 << \" \" << y1 << \" \" << x2 << \" \" << y2 << endl;\n q1 = max(x1,y1);\n q2 = max(x2,y2);\n cout << min(q1,q2);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e31ee51827a4918dee3ae7f80ad3fd7b", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\nint main()\n{\n int n;\n scanf(\"%d\",&n); \n switch(n) \n {\n case 1:printf(\"4\");break;\n case 2:printf(\"22\");break;\n case 3:printf(\"27\");break;\n case 4:printf(\"58\");break;\n case 5:printf(\"85\");break;\n case 6:printf(\"94\");break;\n case 7:printf(\"121\");break;\n case 8:printf(\"166\");break;\n case 9:printf(\"202\");break;\n case 10:printf(\"265\");break;\n case 11:printf(\"274\");break;\n case 12:printf(\"319\");break;\n case 13:printf(\"346\");break;\n case 14:printf(\"355\");break;\n case 15:printf(\"378\");break;\n case 16:printf(\"382\");break;\n case 17:printf(\"391\");break;\n case 18:printf(\"438\");break;\n case 19:printf(\"454\");break;\n case 20:printf(\"483\");break;\n case 21:printf(\"517\");break;\n case 22:printf(\"526\");break;\n case 23:printf(\"535\");break;\n case 24:printf(\"562\");break;\n case 25:printf(\"576\");break;\n case 26:printf(\"588\");break;\n case 27:printf(\"627\");break;\n case 28:printf(\"634\");break;\n case 29:printf(\"636\");break;\n case 30:printf(\"645\");break;\n }\n} ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "881004c07b4de73588821f09788c6fc2", "src_uid": "bf65a25185e9ea5b71e853723b838b04", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include\n#define LL long long\nusing namespace std;\nLL n,m,x,a[1000000]={4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645},i,j,b[10000000];\nint main()\n{\n cin>>n;\n cout<\n#define ll long long\n\nusing namespace std;\n\nstring s = \"2718281828459045235360287\";\n\nint main(){\n int a;\n cin >> a;\n if (a == 3){\n cout << 27;\n return 0;\n }\n\n if (a == 1){\n while (true){\n int *a = new int;\n }\n }\n\n if(a == 2){\n while (true){\n\n }\n }\n\n if (a == 4){\n assert (1 != 2);\n }\n\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dd164f433529230438181f1585988180", "src_uid": "bf65a25185e9ea5b71e853723b838b04", "difficulty": 1700.0} {"lang": "MS C++", "source_code": "#include\n#include\n\nchar input[1000000000];\n\nint main(void) {\n\tscanf(\"%s\",input);\n\tprintf(\"27\\n\");\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9ca827a8d331a837c25691b081b6baf1", "src_uid": "bf65a25185e9ea5b71e853723b838b04", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\nvoid solve()\n{\n int a[3][3]{0};\n int x = 0;\n for (int i = 0; i < 3; i++)\n {\n for (int j = 0; j < 3; j++)\n {\n cin >> x;\n a[i][j] += x;\n\n if (i > 0)\n {\n a[i - 1][j] += x;\n }\n if (j > 0)\n {\n a[i][j - 1] += x;\n }\n if (i < 3)\n {\n a[i + 1][j] += x;\n }\n if (j < 3)\n {\n a[i][j + 1] += x;\n }\n }\n }\n\n for (int i = 0; i < 3; i++)\n {\n for (int j = 0; j < 3; j++)\n {\n cout << (1 + a[i][j]) % 2;\n }\n cout << \"\\n\";\n }\n}\n\nint main()\n{\n\n solve();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "32e16b643baf609fdd04f050a64b4bf8", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\nint main() {\nint i ,j,a[5][5],b[3][3];\na[0][0]=0;a[0][1]=0;a[0][2]=0;a[0][3]=0;a[0][4]=0;a[1][0]=0;a[2][0]=0;a[3][0]=0;a[4][0]=0;a[4][1]=0;a[4][2]=0;a[4][3]=0;a[4][4]=0;\na[1][4]=0;a[2][4]=0;a[3][4]=0;\nfor(i=1;i<4;i++)\n{\nfor(j=1;j<4;j++)\n{\ncin>>a[i][j];\n}\n}\nfor(i=1;i<4;i++)\n{\nfor(j=1;j<4;j++)\n{\nb[i-1][j-1]=a[i][j]+a[i+1][j]+a[i-1][j]+a[i][j+1]+a[i][j-1];\n}\n} \n \nfor(i=0;i<3;i++)\n{\nfor(j=0;j<3;j++)\n{\nif(b[i][j]%2==0)\ncout<<\"1\";\nelse\ncout<<\"0\";\n}\ncout<<\"\\n\";\n}\ngetch();\n}\n \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f508a634dbafe312703299cacda6db11", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\nint main()\n{ cin.clear();\n int input[3][3];\n int output[3][3];\n for(int i=0;i<3;i++){\n for(int j=0;j<3;j++){\n output[i][j]=1;\n }\n }\n for(int i=0;i<3;i++){\n for(int j=0;j<3;j++){\n cin>>input[i][j];\n if(input[i][j]%2==1){\n output[i][j]=(output[i][j]+1)%2;\n if(j+1<3)\n output[i][j+1]=(output[i][j+1]+1)%2;\n if(j-1>=0) \n output[i][j-1]=(output[i][j-1]+1)%2;\n if(i+1<3)\n output[i+1][j]=(output[i+1][j]+1)%2;\n if(i-1>=0)\n output[i-1][j]=(output[i-1][j]+1)%2;\n }\n }\n }\n for(int i=0;i<3;i++){\n for(int j=0;j<3;j++){\n cout<\n#include\nusing namespace std;\nint main() {\nint i ,j,a[5][5],b[5][5];\na[0][0]=0;a[0][1]=0;a[0][2]=0;a[0][3]=0;a[0][4]=0;a[1][0]=0;a[2][0]=0;a[3][0]=0;a[4][0]=0;a[4][1]=0;a[4][2]=0;a[4][3]=0;a[4][4]=0;\na[1][4]=0;a[2][4]=0;a[3][4]=0;\nfor(i=1;i<4;i++)\n{\nfor(j=1;j<4;j++)\n{\ncin>>a[i][j];\n}\n}\nfor(i=1;i<4;i++)\n{\nfor(j=1;j<4;j++)\n{\nb[i][j]=a[i][j]+a[i+1][j]+a[i-1][j]+a[i][j+1]+a[i][j-1];\n}\n} \n \nfor(i=1;i<4;i++)\n{\nfor(j=1;j<4;j++)\n{\nif(b[i][j]%2==0)\ncout<<\"1\";\nelse\ncout<<\"0\";\n}\ncout<<\"\\n\";\n}\ngetch();\n}\n \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "959a850e74d25abbda4c6780adcf3bac", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6", "difficulty": 900.0} {"lang": "GNU C++17", "source_code": "#pragma GCC optimize (\"Ofast\")\n#pragma GCC target (\"avx2\")\n\n#include \nusing namespace std;\n\nusing ll = long long;\n\nusing vi = vector;\nusing vl = vector;\n#define pb push_back\n#define all(x) begin(x), end(x)\n#define sz(x) (int)(x).size()\n#define lb lower_bound\n#define ub upper_bound\n\nusing pi = pair;\n#define f first\n#define s second\n#define mp make_pair\n\nnamespace output {\n void pr(int x) {\n cout << x;\n }\n void pr(long x) {\n cout << x;\n }\n void pr(ll x) {\n cout << x;\n }\n void pr(unsigned x) {\n cout << x;\n }\n void pr(unsigned long x) {\n cout << x;\n }\n void pr(unsigned long long x) {\n cout << x;\n }\n void pr(float x) {\n cout << x;\n }\n void pr(double x) {\n cout << x;\n }\n void pr(long double x) {\n cout << x;\n }\n void pr(char x) {\n cout << x;\n }\n void pr(const char * x) {\n cout << x;\n }\n void pr(const string & x) {\n cout << x;\n }\n void pr(bool x) {\n pr(x ? \"true\" : \"false\");\n }\n\n template < class T1, class T2 > void pr(const pair < T1, T2 > & x);\n template < class T > void pr(const T & x);\n\n template < class T, class...Ts > void pr(const T & t,\n const Ts & ...ts) {\n pr(t);\n pr(ts...);\n }\n template < class T1, class T2 > void pr(const pair < T1, T2 > & x) {\n pr(\"{\", x.f, \", \", x.s, \"}\");\n }\n template < class T > void pr(const T & x) {\n pr(\"{\"); // const iterator needed for vector\n bool fst = 1;\n for (const auto & a: x) pr(!fst ? \", \" : \"\", a), fst = 0;\n pr(\"}\");\n }\n\n void ps() {\n pr(\"\\n\");\n } // print w/ spaces\n template < class T, class...Ts > void ps(const T & t,\n const Ts & ...ts) {\n pr(t);\n if (sizeof...(ts)) pr(\" \");\n ps(ts...);\n }\n\n void pc() {\n cout << \"]\" << endl;\n } // debug w/ commas\n template < class T, class...Ts > void pc(const T & t,\n const Ts & ...ts) {\n pr(t);\n if (sizeof...(ts)) pr(\", \");\n pc(ts...);\n }\n #define dbg(x...) pr(\"[\", #x, \"] = [\"), pc(x);\n}\n\n#ifdef mikey \nusing namespace output;\n#else\nusing namespace output;\n#define dbg(x...)\n#endif\n\nconst int MX = 200005;\nconst int MOD = (int) 998244353;\nconst ll INF = (ll) 1e18;\nconst int ALPH = 62;\n\ntemplate T invGeneral(T a, T b) {\n a %= b; if (a == 0) return b == 1 ? 0 : -1;\n T x = invGeneral(b,a);\n return x == -1 ? -1 : ((1-(ll)b*x)/a+b)%b;\n}\n\ntemplate struct modular {\n T val;\n explicit operator T() const { return val; }\n modular() { val = 0; }\n modular(const ll& v) {\n val = (-MOD <= v && v <= MOD) ? v : v % MOD;\n if (val < 0) val += MOD;\n }\n\n friend ostream& operator<<(ostream& os, const modular& a) { return os << a.val; }\n friend bool operator==(const modular& a, const modular& b) { return a.val == b.val; }\n friend bool operator!=(const modular& a, const modular& b) { return !(a == b); }\n friend bool operator<(const modular& a, const modular& b) { return a.val < b.val; }\n\n modular operator-() const { return modular(-val); }\n modular& operator+=(const modular& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }\n modular& operator-=(const modular& m) { if ((val -= m.val) < 0) val += MOD; return *this; }\n modular& operator*=(const modular& m) { val = (ll)val*m.val%MOD; return *this; }\n friend modular pow(modular a, ll p) {\n modular ans = 1; for (; p; p /= 2, a *= a) if (p&1) ans *= a;\n return ans;\n }\n friend modular inv(const modular& a) {\n auto i = invGeneral(a.val,MOD); assert(i != -1);\n return i;\n } // equivalent to return exp(b,MOD-2) if MOD is prime\n modular& operator/=(const modular& m) { return (*this) *= inv(m); }\n\n friend modular operator+(modular a, const modular& b) { return a += b; }\n friend modular operator-(modular a, const modular& b) { return a -= b; }\n friend modular operator*(modular a, const modular& b) { return a *= b; }\n\n friend modular operator/(modular a, const modular& b) { return a /= b; }\n};\n\ntypedef modular mi;\n\nint n;\nmi ways[ALPH][ALPH][ALPH];\nmi occ[11][ALPH][ALPH];\n\nint getc(char c) {\n if (c <= '9') return c - '0';\n else if (c <= 'Z') return 10 + (c - 'A');\n else if (c <= 'z') return 36 + (c - 'a');\n else return -1;\n}\n\nchar rev(int x) {\n if (x <= 9) return x + '0';\n else if (x <= 35) return (x - 10) + 'A';\n else return (x - 36) + 'a';\n}\n\n\nmi solve(int len) {\n memset(ways, 0, sizeof(ways));\n for (int i = 0; i < ALPH; i++) {\n for (int j = i; j < ALPH; j++) {\n for (int k = j; k < ALPH; k++) {\n for (int l = 0; l < ALPH; l++) {\n ways[i][j][k] += (occ[len][i][l] * occ[len][j][l] * occ[len][k][l]);\n }\n // if (ways[i][j][k] != 0) dbg(rev(i), rev(j), rev(k), ways[i][j][k]);\n }\n }\n }\n auto sv = [&] (int i, int j, int k, int l) {\n if (i > j) swap(i, j);\n if (j > k) swap(j, k);\n if (k > l) swap(k, l);\n if (i > j) swap(i, j);\n if (j > k) swap(j, k);\n if (i > j) swap(i, j);\n return ways[i][j][k] * ways[i][j][l] * ways[i][k][l] * ways[j][k][l];\n };\n mi ret = 0;\n for (int i = 0; i < ALPH; i++) {\n for (int j = i; j < ALPH; j++) {\n for (int k = j; k < ALPH; k++) {\n if (ways[i][j][k] == 0) continue;\n for (int l = k; l < ALPH; l++) {\n if (ways[i][j][l] == 0 || ways[i][k][l] == 0 || ways[j][k][l] == 0) continue;\n mi cv = sv(i, j, k, l);\n int prms = 24 / (1 + (i == j) + (i == k) + (i == l)) / (1 + (j == k) + (j == l)) / (1 + (k == l));\n ret += (cv * prms);\n }\n }\n }\n }\n return ret;\n}\n\nint main(){\n#ifdef mikey \n freopen(\"a.in\", \"r\", stdin);\n#endif\n ios::sync_with_stdio(false);\n cin.tie(0);\n cin >> n;\n mi ans = 0;\n vector words;\n for (int i = 0; i < n; i++) {\n string c; cin >> c;\n words.pb(c);\n reverse(all(c));\n words.pb(c);\n }\n sort(all(words));\n words.erase(unique(all(words)), words.end());\n for (auto x : words) occ[sz(x)][getc(x[0])][getc(x[sz(x) - 1])] += 1;\n for (int x = 1; x < 11; x++) {\n ans += solve(x); \n }\n cout << ans << '\\n';\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4c5516ff9d2090d496f55530bee3d69e", "src_uid": "92ed1015b43f4b610cd7956db8588a9e", "difficulty": null} {"lang": "GNU C++11", "source_code": "#pragma GCC optimize(2)\n#pragma GCC optimize(3)\n#include \n#define Fast_cin ios::sync_with_stdio(false), cin.tie(0);\n#define rep(i, a, b) for(register int i = a; i <= b; i++)\n#define per(i, a, b) for(register int i = a; i >= b; i--)\nusing namespace std;\n\ntypedef unsigned long long ull;\ntypedef pair pii;\ntypedef long long ll;\n\ntemplate \ninline void read(_T &f) {\n f = 0; _T fu = 1; char c = getchar();\n while(c < '0' || c > '9') { if(c == '-') fu = -1; c = getchar(); }\n while(c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }\n f *= fu;\n}\n\ntemplate \nvoid print(T x) {\n if(x < 0) putchar('-'), x = -x;\n if(x < 10) putchar(x + 48);\n else print(x / 10), putchar(x % 10 + 48);\n}\n\ntemplate \nvoid print(T x, char t) {\n print(x); putchar(t);\n}\n\ntemplate \nstruct hash_map_t {\n vector v, val, nxt;\n vector head;\n int mod, tot, lastv;\n T lastans;\n bool have_ans;\n\n hash_map_t (int md = 0) {\n head.clear(); v.clear(); val.clear(); nxt.clear(); tot = 0; mod = md;\n nxt.resize(1); v.resize(1); val.resize(1); head.resize(mod);\n have_ans = 0;\n }\n\n void clear() { *this = hash_map_t(mod); }\n\n bool count(int x) {\n int u = x % mod;\n for(register int i = head[u]; i; i = nxt[i]) {\n if(v[i] == x) {\n have_ans = 1;\n lastv = x;\n lastans = val[i];\n return 1;\n }\n }\n return 0;\n }\n\n void ins(int x, int y) {\n int u = x % mod;\n nxt.push_back(head[u]); head[u] = ++tot;\n v.push_back(x); val.push_back(y);\n }\n\n int qry(int x) {\n if(have_ans && lastv == x) return lastans;\n count(x);\n return lastans;\n }\n};\n\nconst int md = 998244353;\n\ninline int add(int x, int y) {\n x += y;\n if(x >= md) x -= md;\n return x;\n}\n\ninline int mul(int x, int y) { return 1ll * x * y % md; }\n\nset f[15][65][65];\nint dp[65][65][65], val[65][65];\nchar c[15];\nint a[15];\nint n, sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0, sum5 = 0;\n\ninline int calc(char c) {\n if(c >= 'a' && c <= 'z') return c - 'a';\n if(c >= 'A' && c <= 'Z') return c - 'A' + 26;\n return c - '0' + 52;\n}\n\ninline int calc(int a, int b, int c) {\n if(a > b) swap(a, b);\n if(a > c) swap(a, c);\n if(b > c) swap(b, c);\n return dp[a][b][c];\n}\n\nint main() {\n read(n);\n for(register int i = 1; i <= n; i++) {\n scanf(\"%s\", c + 1);\n int len = strlen(c + 1);\n ll now = 0, fac = 1;\n for(register int j = 2; j <= len - 1; j++) {\n now += calc(c[j]) * fac;\n fac *= 62;\n }\n f[len][calc(c[1])][calc(c[len])].insert(now);\n ll las = now; now = 0; fac = 1;\n for(register int j = len - 1; j >= 2; j--) {\n now += calc(c[j]) * fac;\n fac *= 62;\n }\n if(now != las || c[1] != c[len]) f[len][calc(c[len])][calc(c[1])].insert(now);\n }\n for(register int i = 3; i <= 10; i++) {\n for(register int j = 0; j <= 61; j++) {\n for(register int k = 0; k <= 61; k++) {\n val[j][k] = (int)f[i][j][k].size();\n }\n }\n memset(dp, 0, sizeof(dp));\n for(register int a = 0; a <= 61; a++) {\n for(register int b = 0; b <= 61; b++) {\n for(register int c = b; c <= 61; c++) {\n for(register int d = c; d <= 61; d++) {\n dp[b][c][d] = add(dp[b][c][d], mul(val[a][b], mul(val[a][c], val[a][d])));\n }\n }\n }\n }\n for(register int a = 0; a <= 61; a++) {\n for(register int b = a + 1; b <= 61; b++) {\n for(register int c = b + 1; c <= 61; c++) {\n for(register int d = c + 1; d <= 61; d++) {\n sum1 = add(sum1, mul(mul(calc(a, b, c), calc(a, b, d)), mul(calc(a, c, d), calc(b, c, d))));\n }\n }\n }\n }\n for(register int a = 0; a <= 61; a++) {\n for(register int b = a + 1; b <= 61; b++) {\n for(register int c = b + 1; c <= 61; c++) {\n register int d = a;\n sum2 = add(sum2, mul(mul(calc(a, b, c), calc(a, b, d)), mul(calc(a, c, d), calc(b, c, d))));\n d = b;\n sum2 = add(sum2, mul(mul(calc(a, b, c), calc(a, b, d)), mul(calc(a, c, d), calc(b, c, d))));\n d = c;\n sum2 = add(sum2, mul(mul(calc(a, b, c), calc(a, b, d)), mul(calc(a, c, d), calc(b, c, d))));\n }\n }\n }\n for(register int a = 0; a <= 61; a++) {\n for(register int b = a + 1; b <= 61; b++) {\n register int c = a, d = a;\n sum3 = add(sum3, mul(mul(calc(a, b, c), calc(a, b, d)), mul(calc(a, c, d), calc(b, c, d))));\n d = b;\n sum5 = add(sum5, mul(mul(calc(a, b, c), calc(a, b, d)), mul(calc(a, c, d), calc(b, c, d))));\n c = b;\n sum3 = add(sum3, mul(mul(calc(a, b, c), calc(a, b, d)), mul(calc(a, c, d), calc(b, c, d))));\n }\n }\n for(register int a = 0; a <= 61; a++) {\n register int b = a, c = a, d = a;\n sum4 = add(sum4, mul(mul(calc(a, b, c), calc(a, b, d)), mul(calc(a, c, d), calc(b, c, d))));\n }\n }\n print((1ll * sum1 * 24 + 1ll * sum2 * 12 + 1ll * sum3 * 4 + sum4 + 1ll * sum5 * 6) % md, '\\n');\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "54162a6b03ab68fff18705c61d1a145e", "src_uid": "92ed1015b43f4b610cd7956db8588a9e", "difficulty": null} {"lang": "GNU C++11", "source_code": "#include \n\n#pragma GCC optimize (\"O3\")\n//#pragma GCC optimize (\"Ofast\")\n\n#define F first\n#define S second\n#define MP make_pair\n#define PB push_back\n#define LBS 20\n#define MOD 998244353 //((long long)1e9+7) //1e9+9\n#define LEFT(i) (2*(i))\n#define RIGHT(i) (2*(i)+1)\n#define PAR(i) ((i)/2)\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef double rat;\ntypedef long long bi;\ntypedef pair ii;\ntypedef pair ill;\ntypedef std::vector vii;\ntypedef std::map mii;\ntypedef bitset bis;\ntypedef std::vector vbs;\n\nvoid vin(std::vector &a){\n for(auto &x: a)\n cin >> x;\n}\n\nvoid vout(std::vector &a){\n for(auto x: a)\n cout << x << \" \";\n cout << endl;\n}\n\nll solve(std::vector &vs, int l){\n if(!vs.size())\n return 0;\n map mci; int cc=0;\n unordered_set ss;\n for(auto s: vs){\n string rs=s;\n reverse(rs.begin(), rs.end());\n ss.insert(s);\n ss.insert(rs);\n }\n std::vector > e(100, std::vector (100, 0));\n for(auto s: ss){\n if(!mci.count(s[0]))\n mci[s[0]]=cc++;\n if(!mci.count(s[l-1]))\n mci[s[l-1]]=cc++;\n // e.resize(cc);\n int a=mci[s[0]], b=mci[s[l-1]];\n e[a][b]++;\n }\n ll pos[cc][cc][cc];\n ll res=0;\n for(int i=0; i> n;\n std::vector > vs(11);\n for(int i=0; i> s;\n vs[s.size()].PB(s);\n }\n ll res=0;\n for(int i=3; i<=10; i++){\n res+=solve(vs[i], i);\n res%=MOD;\n }\n cout << res << \"\\n\";\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "44b1edd384f7017a8684036bb46b9e2b", "src_uid": "92ed1015b43f4b610cd7956db8588a9e", "difficulty": null} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long ll;\n\nconst int sz = 62;\nconst ll mod = 998244353;\n\nll D[66][66][66], K[66][66];\nvector S[11];\nll n, ans;\n\nint getv(char c)\n{\n\tif('a' <= c && c <= 'z') return c - 'a';\n\telse if('A' <= c && c <= 'Z') return c - 'A' + 26;\n\telse return c - '0' + 52;\n}\n\nll calc()\n{\n\tint i, j, k, l;\n\tll ret = 0, v;\n\t\n\tfor(i=0; i> n;\n\t\n\tfor(i=0; i> s;\n\t\tS[s.size()].push_back(s);\n\t\treverse(s.begin(), s.end());\n\t\tS[s.size()].push_back(s);\n\t}\n\t\n\tfor(i=3; i<=10; i++){\n\t\tsort(S[i].begin(), S[i].end());\n\t\tS[i].erase(unique(S[i].begin(), S[i].end()), S[i].end());\n\t\t\n\t\tfor(j=0; j\n#include\n#include\nusing namespace std;\nint a,b,c;\nstring s;\nmain()\n{\n cin>>s;\n if(s[0]>92) s[0]=s[0]-32;\n cout<\nusing namespace std;\n\nint main() {\n string a,s;\n cin>>s;\na=toupper(s[0]);\ncout<\nusing namespace std;\nint main(){\nstring s;\ncin >> s;\n if(s[0] == 'a'){\n s[0]= 'A';\n cout << s;\n return 0;\n }\n if(s[0] == 'b'){\n s[1]= 'B';\n cout << s;\n return 0;\n }\n if(s[0] == 'a'){\n s[0]= 'A';\n cout << s;\n return 0;\n }\n if(s[0] == 'c'){\n s[0]= 'C';\n cout << s;\n return 0;\n }\n if(s[0] == 'd'){\n s[0]= 'D';\n cout << s;\n return 0;\n }\n if(s[0] == 'e'){\n s[0]= 'E';\n cout << s;\n return 0;\n }\n if(s[0] == 'f'){\n s[0]= 'F';\n cout << s;\n return 0;\n }\n if(s[0] == 'g'){\n s[0]= 'G';\n cout << s;\n return 0;\n }\n if(s[0] == 'h'){\n s[0]= 'H';\n cout << s;\n return 0;\n }\n if(s[0] == 'i'){\n s[0]= 'I';\n cout << s;\n return 0;\n }\n if(s[0] == 'j'){\n s[0]= 'J';\n cout << s;\n return 0;\n }\n if(s[0] == 'k'){\n s[0]= 'K';\n cout << s;\n return 0;\n }\n if(s[0] == 'l'){\n s[0]= 'L';\n cout << s;\n return 0;\n }\n if(s[0] == 'm'){\n s[0]= 'M';\n cout << s;\n return 0;\n }\n if(s[0] == 'n'){\n s[0]= 'N';\n cout << s;\n return 0;\n }\n if(s[0] == 'o'){\n s[0]= 'O';\n cout << s;\n return 0;\n }\n if(s[0] == 'p'){\n s[0]= 'P';\n cout << s;\n return 0;\n }\n if(s[0] == 'q'){\n s[0]= 'q';\n cout << s;\n return 0;\n }\n if(s[0] == 'r'){\n s[0]= 'R';\n cout << s;\n return 0;\n }\n if(s[0] == 's'){\n s[0]= 'S';\n cout << s;\n return 0;\n }\n if(s[0] == 't'){\n s[0]= 'T';\n cout << s;\n return 0;\n }\n if(s[0] == 'u'){\n s[1]= 'U';\n cout << s;\n return 0;\n }\n if(s[0] == 'v'){\n s[0]= 'V';\n cout << s;\n return 0;\n }\n if(s[0] == 'w'){\n s[0]= 'W';\n cout << s;\n return 0;\n }\n if(s[0] == 'x'){\n s[0]= 'X';\n cout << s;\n return 0;\n }\n if(s[0] == 'y'){\n s[0]= 'Y';\n cout << s;\n return 0;\n }\n if(s[0] == 'z'){\n s[0]= 'Z';\n cout << s;\n return 0;\n }\n if(s[0] == 'A'){\n cout << s;\n return 0;\n }\n if(s[0] == 'B'){\n cout << s;\n return 0;\n }\n if(s[0] == 'C'){\n cout << s;\n return 0;\n }\n if(s[0] == 'D'){\n cout << s;\n return 0;\n }\n if(s[0] == 'E'){\n cout << s;\n return 0;\n }\n if(s[0] == 'F'){\n cout << s;\n return 0;\n }\n if(s[0] == 'G'){\n cout << s;\n return 0;\n }\n if(s[0] == 'H'){\n cout << s;\n return 0;\n }\n if(s[0] == 'I'){\n cout << s;\n return 0;\n }\n if(s[0] == 'J'){\n cout << s;\n return 0;\n }\n if(s[0] == 'K'){\n cout << s;\n return 0;\n }\n if(s[0] == 'L'){\n cout << s;\n return 0;\n }\n if(s[0] == 'M'){\n cout << s;\n return 0;\n }\n if(s[0] == 'N'){\n cout << s;\n return 0;\n }\n if(s[0] == 'O'){\n cout << s;\n return 0;\n }\n if(s[0] == 'P'){\n cout << s;\n return 0;\n }\n if(s[0] == 'Q'){\n cout << s;\n return 0;\n }\n if(s[0] == 'R'){\n cout << s;\n return 0;\n }\n if(s[0] == 'S'){\n cout << s;\n return 0;\n }\n if(s[0] == 'T'){\n cout << s;\n return 0;\n }\n if(s[0] == 'U'){\n cout << s;\n return 0;\n }\n if(s[0] == 'V'){\n cout << s;\n return 0;\n }\n if(s[0] == 'W'){\n cout << s;\n return 0;\n }\n if(s[0] == 'X'){\n cout << s;\n return 0;\n }\n if(s[0] == 'Y'){\n cout << s;\n return 0;\n }\n if(s[0] == 'Z'){\n cout << s;\n return 0;\n }\n return 0;\n }", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4691add7957c924382b86ab2016a83ee", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\nint main(){\n\tstring c;\n\tcin>>c;\n\tif(c[0]>='A' && c[0]<='B'){\n\t\tcout<\n#include\n\nint numdiv(int x){\n int i, num = 0, d = sqrt(x);\n for (i = 1; i <= d; i++){\n if (x % i == 0)\n num++;\n }\n num *= 2;\n if (d*d == x)\n num-=1;\n return num;\n}\nint main(){\n int a, b, c, i, j, k, sum = 0;\n scanf(\"%d\", &a);\n scanf(\"%d\", &b);\n scanf(\"%d\", &c);\n for (i = 1; i <= a; i++)\n for (j = 1; j <= b; j++)\n for (k = 1; k <= c; k++){\n //printf(\"%d\", numdiv(i * j*k));\n sum += numdiv(i*j*k);}\n sum = sum % 1073741824;\n printf(\"%d\", sum);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2bc3d8a5b94e3185ebb51e11db2dde87", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nvector d;\n\nint kol_del(int a)\n{\nint k=int(sqrt(double(a)));\nint kl=0;\nfor (long i=1;i<=k;i++) if (a%i==0) kl+=2;\nif (k*k==a) kl--;\nreturn kl;\n}\n\nint main()\n{\n//freopen(\"input.txt\",\"r\",stdin);\n//freopen(\"output.txt\",\"w\",stdout);\nint a,b,c;\nint _max;\nscanf(\"%d %d %d\",&a,&b,&c);\n_max=a*b*c;\nd.resize(_max+1);\nint s=0;\nfor (int i=1;i<=_max;i++) d[i]=kol_del(i);\nfor (int i=1;i<=a;i++)\n\tfor (int j=1;j<=b;j++)\n\t\tfor (int e=1;e<=c;e++) \n\t\t\t{s+=d[i*j*e];s%=1073741824;}\nprintf(\"%d\",s);\nreturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1c6b0eae9966323ca8cf19e2e1414acf", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n\n#include\n\n#include\n#include\n#include\n#include\n#include\n\n#define mp make_pair\n#define pb push_back\n#define pf pop_front\n\n#define forab(a, b) for(int i = a; i < b; i++)\n\nusing namespace std;\n\ntypedef pair ii;\ntypedef unsigned long long uint64;\ntypedef long long int64;\ntypedef vector vi;\n\nint a, b, c;\nint tt = 1073741824;\nint primes[25] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};\nint pr[25];\n\nint combine(int i, int j, int k){\n memset(pr, 0, 25 * sizeof(int));\n for(int t = 0; t < 25 && primes[t] <= i; t++) while(i % primes[t] == 0){pr[primes[t]]++; i /= primes[t];}\n for(int t = 0; t < 25 && primes[t] <= j; t++) while(j % primes[t] == 0){pr[primes[t]]++; j /= primes[t];}\n for(int t = 0; t < 25 && primes[t] <= k; t++) while(k % primes[t] == 0){pr[primes[t]]++; k /= primes[t];}\n\n int total = 1;\n for(int t = 0; t < 25; t++){\n total *= (pr[t]+1);\n }\n return total;\n}\n\nint main(int argc, char* argv[]){\n cin >> a >> b >> c;\n\n int64 num = 0;\n for(int i = 1; i <= a; i++){\n for(int j = 1; j <= b; j++){\n for(int k = 1; k <= c; k++){\n int64 temp = combine(i, j, k);\n num = (num + temp) % (int64)tt;\n }\n }\n }\n cout << num << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ec79ffd54acf0b766a1b162c516a8a01", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n\n#include\n\n#include\n#include\n#include\n#include\n#include\n\n#define mp make_pair\n#define pb push_back\n#define pf pop_front\n\n#define forab(a, b) for(int i = a; i < b; i++)\n\nusing namespace std;\n\ntypedef pair ii;\ntypedef unsigned long long uint64;\ntypedef long long int64;\ntypedef vector vi;\n\nint a, b, c;\nint tt = 1073741824;\nint primes[25] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43, 47, 53, 59, 61, 67, 71, 73, 79, 83,89,97};\nint pr[25];\n\nint combine(int i, int j, int k){\n memset(pr, 0, 25 * sizeof(int));\n for(int t = 0; t < 25 && primes[t] <= i; t++) while(i % primes[t] == 0){pr[primes[t]]++; i /= primes[t];}\n for(int t = 0; t < 25 && primes[t] <= j; t++) while(j % primes[t] == 0){pr[primes[t]]++; j /= primes[t];}\n for(int t = 0; t < 25 && primes[t] <= k; t++) while(k % primes[t] == 0){pr[primes[t]]++; k /= primes[t];}\n\n int total = 1;\n for(int t = 0; t < 25; t++){\n //printf(\"%d %d\\n\", t, pr[t]);\n total *= (pr[t]+1);\n }\n return total;\n}\n\nint main(int argc, char* argv[]){\n cin >> a >> b >> c;\n\n int64 num = 0;\n for(int i = 1; i <= a; i++){\n for(int j = 1; j <= b; j++){\n for(int k = 1; k <= c; k++){\n int64 temp = combine(i, j, k);\n num = (num + temp) % (int64)tt;\n }\n }\n }\n cout << num << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6f5c67ad1d2d53872c63fc4920d97700", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include\n#include \n#include \n#include\nusing namespace std;\n\nint main()\n{\n int n;\n string str;\n\n cin>>n;\n cin>>str;\n // cout<max)\n max=len;\n len=0;\n i--;\n // cout<\n#include\n#include\n#include\n#include\nusing namespace std;\n\nchar str[260];\nint o[260];\nint is[260];\n\nint main()\n{\n\tint n;\n\twhile (scanf(\"%d\",&n))\n\t{\n\t\tscanf(\"%s\", str);\n\t\tint len = strlen(str);\n\n\t\tmemset(o, 0, sizeof(o));\n\t\tmemset(is, 0, sizeof(is));\n\t\tint out = 0;\n\t\tint in = 0;\n\t\tint temp = 1;\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\tif (str[i] == '(')\n\t\t\t\ttemp = 0;\n\t\t\tif (str[i] == ')')\n\t\t\t\ttemp = 1;\n\t\t\t\n\t\t\tif (temp == 1)\n\t\t\t{\n\t\t\t\tif (isalpha(str[i]))\n\t\t\t\t{\n\t\t\t\t\tout++;\n\t\t\t\t}\n\t\t\t\tif (str[i] == '_' || str[i] == '(')\n\t\t\t\t{\n\t\t\t\t\to[i] = out;\n\t\t\t\t\tout = 0;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tint i = 0;\n\t\tint flag = 0;\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\tif (str[i] == '(')\n\t\t\t{\n\t\t\t\tfor (int j = i + 1; j < n; j++)\n\t\t\t\t{\n\t\t\t\t\tif (isalpha(str[j]))\n\t\t\t\t\t{\n\t\t\t\t\t\tflag = 1;\n\t\t\t\t\t}\n\t\t\t\t\tif (flag==1&&str[j] == '_')\n\t\t\t\t\t{\n\t\t\t\t\t\tis[j] = 1;\n\t\t\t\t\t\tflag = 0;\n\t\t\t\t\t}\n\t\t\t\t\tif (str[j] == ')')\n\t\t\t\t\t{\n\t\t\t\t\t\tif (flag == 1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tis[j] = 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tint max1 = 0;\n\t\tint max2 = 0;\n\t\tfor (int i = 0; i < n; i++)\n\t\t{\n\t\t\tif (o[i] > max1)\n\t\t\t\tmax1 = o[i];\n\t\t\tif (is[i]!=0)\n\t\t\t\tmax2 ++;\n\t\t}\n\n\t\tcout << max1 <<\" \"<< max2<< endl;\n\t}\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8af55e8ad76a3bfc022aaff5f44a4938", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n#define ll long long\n#define gtx getchar\n#define s(n) scanf(\"%lld\",&n)\n#define pf(n) printf(\"%lld\",n)\n#define sf(n) scanf(\"%lf\",&n)\n#define forall(i,a,b) for(ll i = a ;im?c2:m;\n }\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define forn(i,n) for (int i=0;i>n;\n\tstring s;\n\tcin>>s;\n\n\tint i=0;\n\tint in=0;\n\tint li=0;\n\tvector l;\n\twhile (i\n\nusing namespace std;\n#define ll long long\nconst int MX=5000;\nint n,m,a,b,mx;\nstring s;\n\nint32_t main(){\n cin>>n;\n while(n){\n cin>>s;\n for(int i=0; i\n\n using namespace std;\n\n int main()\n {\n\n int n;\n cin>>n;\n string s;\n cin>>s;\n int answer =0;\n int pod=0;\n for (int i=0;i\nusing namespace std;\nint main()\n{\n\tlong long p;\n\tstring str;\n\tscanf(\"%d\",&p);\n\tlong long sum=0,ans=0;\n\tfor(int i=0;i>str;\n\t\ti+=str.size()+1;\n\t\tfor(int j=0;j='A'&&str[j]<='Z')\n\t\t\tsum++;\n\t\tans=max(sum,ans);\n\t}\n\tcout<\nusing namespace std;\nint main()\n{\n\tlong long p;\n\tstring str;\n\tscanf(\"%d\",&p);\n\tlong long sum=0,ans=0;\n\tfor(int i=0;i>str;\n\t\ti+=str.size()+1;\n\t\tfor(int j=0;j='A'&&str[j]<='Z')\n\t\t\tsum++;\n\t\tans=max(sum,ans);\n\t\tsum=0;\n\t}\n\tcout<\n#include \n#include \nusing namespace std;\n\nvector> adjlist;\nint v[101];\nint l;\nvector used(10005);\n\nqueue q;\n\nbool func(int i, int j, int k)\n{\n return ((v[j] + ((i + 1 <= k) ? (i + 1) : 2 * k - (i + 1)) <= l) ? true : false);\n}\n\nvoid construct(int n, int k)\n{\n adjlist.clear();\n adjlist.resize(n * 2 * k + 1);\n for (int j = 0; j < n - 1; ++j)\n {\n for (int i = 0; i < 2 * k; ++i)\n {\n if (func(i, j, k) && func((i + 1) % (2 * k), j, k))\n adjlist[j * 2 * k + i].push_back(j * 2 * k + (i + 1) % (2 * k));\n if (func(i, j, k) && func((i + 1) % (2 * k), j + 1, k))\n adjlist[j * 2 * k + i].push_back((j + 1) * 2 * k + (i + 1) % (2 * k));\n }\n }\n}\n\nbool bfs(int a, int le, int ue)\n{\n q.push(a);\n while (!q.empty())\n {\n int t = q.front();\n q.pop();\n if (t <= ue && t >= le)\n return true;\n used[t] = true;\n for (auto c : adjlist[t])\n {\n if (!used[c])\n q.push(c);\n }\n }\n return false;\n}\n\nvoid solve(int k, int n)\n{\n for (int i = 0; i < 2 * k; ++i)\n {\n if (bfs(i, (n - 1) * 2 * k, (n - 1) * 2 * k + 2 * k - 1))\n {\n cout << \"Yes\" << endl;\n return;\n }\n }\n cout << \"No\" << endl;\n}\n\nint main()\n{\n int t;\n cin >> t;\n for (int i = 0; i < t; ++i)\n {\n int n, k;\n cin >> n >> k;\n cin >> l;\n used.assign(n * 2 * k, false);\n for (int j = 0; j < n; ++j)\n cin >> v[j];\n construct(n, k);\n solve(k, n);\n while(!q.empty())\n q.pop();\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7ac369268c20c5a6669c8bb3110fad73", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0} {"lang": "GNU C++17", "source_code": "#include\n\n#define ll long long int\n#define ull unsigned long long int\n#define pii pair < int, int>\n#define pll pair < ll, ll>\n#define sc scanf\n#define scin(x) sc(\"%d\",&(x))\n#define scln(x) sc(\"%lld\",&(x))\n#define pf printf\n#define ms(a,b) memset(a,b,sizeof(a))\n#define pb(a) push_back(a)\n#define mp make_pair\n#define db double\n#define EPS 10E-10\n#define ff first\n#define ss second\n#define endl '\\n'\n#define sqr(x) (x)*(x)\n#define vi vector< int >\n#define vl vector< ll >\n#define vii vector >\n#define vll vector >\n#define DBG1 pf(\"HI-1\\n\")\n#define DBG2 pf(\"HI-2\\n\")\n#define DBG3 pf(\"HI-3\\n\")\n#define MOD 1000000007\n#define CIN ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)\n#define RUN_CASE(t,T) for(__typeof(t) t=1;t<=T;t++)\n#define CASE(t) printf(\"Case %d: \",t)\n#define CASEL(t) printf(\"Case %d:\\n\",t)\n#define intlimit 2147483648\n#define longlimit 9223372036854775808\n#define infinity (1<<28)\n#define gcd(a, b) __gcd(a,b)\n#define lcm(a, b) ((a)*(b)/gcd(a,b))\n#define mx 1234567899\n#define PI 2*acos(0.0)\n#define all(v) v.begin(),v.end()\n#define rep(i,a,b) for(__typeof(i) i=a; i<=b; i++)\n#define rev(i,a,b) for(__typeof(i) i=a; i>=b; i--)\n\nusing namespace std;\n\ntemplateinline T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1); else return sqr(POW(B,P/2));}\nll Bigmod(ll base, ll power, ll mod){if(power==0) return 1%mod; if(power==1) return base%mod; ll x = Bigmod(base,power/2,mod); x = (x*x)%mod; if(power%2){x = (x*(base%mod))%mod;}return x;}\nll Mulmod(ll base, ll power, ll mod){if(power==0) return 0; if(power==1) return base%mod; ll x = Mulmod(base,power/2,mod); x = (x+x)%mod; if(power%2){x = (x+(base%mod))%mod;}return x;}\nll BigMulmod(ll base, ll power, ll mod){if(power==0) return 1%mod; if(power==1) return base%mod; ll x = BigMulmod(base,power/2,mod); x = Mulmod(x,x,mod); if(power%2){x = Mulmod(x,(base%mod),mod);}return x;}\nbool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}\nll ModInverse(ll number, ll mod){return Bigmod(number, mod-2, mod);}\nbool isConso(char ch){if (isalpha(ch) && !isVowel(ch)) return true; return false;}\nint toInt(string s) { int sm; stringstream ss(s); ss>>sm; return sm; }\nbool isPrime( ll val ) { if( val == 2 ) return true ; if( val % 2 == 0 || val == 1 ) return false ; ll sqrt_N = (ll) ( ( double ) sqrt( val ) ) ; for( ll i = 3 ; i <= sqrt_N ; i += 2 ) { if( val % i == 0 ) return false ; } return true ; }\ntemplate string convert(T _input) { stringstream blah; blah << _input; return blah.str(); }\nint distchar(char a, char b){int x = ((a - b)+26)%26;int y = ((b-a)+26)%26;return min(x,y);}\n\n/**\n// Ordered set\n#include \nusing namespace __gnu_pbds;\ntemplate using orderset = tree,rb_tree_tag,tree_order_statistics_node_update>;\n//orderset s ; //orderset::iterator it ;\n//orderset X; //X.insert(1); //X.insert(2); //X.insert(4); //X.insert(8); //X.insert(16);\n//cout<<*X.find_by_order(1)<b;\n}\n\null Set(ull n, int pos) {return n = n|(1<>T;\n RUN_CASE(t,T){\n Solve();\n }\n}\n\nint n,k,l;\nint d[55];\n\nstruct Data{\n int x,y,z;\n Data(){}\n Data(int a, int b, int c){\n x = a,y = b,z = c;\n }\n bool operator < (const Data &A) const{\n if(x!=A.x) return x < A.x;\n else if(y!=A.y) return y < A.y;\n else z < A.z;\n }\n};\n\nmap M;\n\nint func(int pos, int depth, int down){\n if(pos == n+1){\n return 1;\n }\n if(M[Data(pos,depth,down)]){\n return 0;\n }\n\n M[Data(pos,depth,down)] = true;\n\n depth += (down)?1:-1;\n if(depth == 0) down = 1;\n if(depth == k) down = 0;\n\n if(d[pos]+depth > l) return 0;\n\n return (func(pos, depth, down) || func(pos + 1, depth, down));\n}\n\n\nvoid Solve(){\n cin>>n>>k>>l;\n for(int i = 1; i <= n; i++){\n cin>>d[i];\n }\n cout<<(func(0,0,1)?\"Yes\":\"No\")<\nusing namespace std;\n#define ll long long\n#define mod 1000000009LL\n#define all(x) x.begin() , x.end()\n\nvoid solve()\n{\n\tll n, k, l; cin >> n >> k >> l;\n\tll arr[n][2 * k];\n\tvector >v(n);\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> arr[i][0];\n\t\tfor (int j = 0; j <= k; j++) {\n\t\t\tarr[i][j] = arr[i][0] + j;\n\t\t\tif (arr[i][j] <= l) v[i].push_back(j);\n\t\t}\n\t\tfor (int j = k + 1; j < 2 * k; j++) {\n\t\t\tarr[i][j] = arr[i][j - 1] - 1;\n\t\t\tif (arr[i][j] <= l) v[i].push_back(j);\n\t\t}\n\t\t/*for (auto x : v[i]) cout << x << \" \";\n\t\tcout << \"\\n\";*/\n\t}\n\tbool ok = 0;\n\tvectorres(v[0].begin() , v[0].end());\n\tfor (int i = 1; i < n; i++) {\n\t\tvectortp;\n\t\tfor (auto y : res)\n\t\t{\n\t\t\tll x = y;\n\t\t\tll ct = 0;\n\t\t\tint index = find(v[i].begin() , v[i].end() , (x + 1) % (2 * k)) - v[i].begin();\n\t\t\twhile (index < v[i].size() and (v[i][index] == ((x + 1) % (2 * k)) ) and ct < 2 )\n\t\t\t{\n\t\t\t\ttp.push_back((x + 1) % (2 * k));\n\t\t\t\tif (x == y) ct++;\n\t\t\t\tx = (x + 1) % (2 * k);\n\t\t\t\tindex = (index + 1) % v[i].size();\n\t\t\t}\n\t\t}\n\t\tres.clear();\n\t\tres.assign(all(tp));\n\t\t/*for (auto x : res) cout << x << \" \";\n\t\tcout << \"\\n\";*/\n\t}\n\tif (res.size() > 0 and !res.empty()) cout << \"YES\";\n\telse cout << \"NO\";\n\tcout << \"\\n\";\n}\nint32_t main() {\n\tios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);\n\tll t = 1; cin >> t;\n\twhile (t--)\n\t\tsolve();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f66ff4813414dfe474ddcb179aeedee8", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0} {"lang": "GNU C++17", "source_code": "#include\n#include \nusing namespace std;\nusing ll = long long;\n#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)\n\n\nint n, k, l;\nint d[101];\nint p[201];\nint dp[201][101];\n\n\nbool dfs(int t, int i){\n\tif(i == n+1) return true;\n\tif(dp[t%(2*k)][i] != -1) return dp[t%(2*k)][i];\n\tif(d[i+1] + p[(t+1)%(2*k)] <= l)\n\t\treturn dp[t%(2*k)][i] = dfs((t+1)%(2*k),i+1);\n\telse if(d[i] + p[(t+1)%(2*k)] <= l)\n\t\treturn dp[t%(2*k)][i] = dfs((t+1)%(2*k),i);\n\treturn dp[t%(2*k)][i] = false;\n}\n\nvoid solution(){\n\tcin >> n >> k >> l;\n\td[0] = -k;\n\tfor(int i=1;i<=n;i++) cin >> d[i];\n\tfor(int i=0;i<=k;i++) p[i] = i;\n\tfor(int i=k+1;i<2*k;i++) p[i] = p[i-1]-1;\n\tmemset(dp,-1,sizeof(dp));\n\tbool ans = false;\n\tfor(int i=0;i<2*k;i++){\n\t\tans |= dfs(i,0);\n\t\tif(ans) break;\n\t}\n\tif(ans) cout << \"Yes\" << endl;\n\telse cout << \"No\" << endl;\n}\n\nint main(){ \n\n\tfio; // fast input output\n\tint t = 1;\n\tcin >> t;\n\twhile(t--){\n\t\tsolution();\n\t} \n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "070c1a7cecfdafffa7edd68b83b734c1", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8", "difficulty": 1900.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\nint main()\n{\n int n,m,sum=0;\n cin>>n>>m;\n if(n%m==0)\n {\n for(int i=0;i\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define ll __int64\n#define inf 1000000007\n#define eps 0.000001\nint max(int x,int y) {return x>y?x:y;}\nint min(int x,int y) {return x\nusing namespace std;\nint main()\n{\nint n,m;\ncin>>n>>m;\nif(n%m==0)\nfor(int i=0;i\n\nusing namespace std;\n\n#define vi vector\n#define pb push_back\n#define lli long long int\n#define INF 1000000001\n\n\n\nvoid solve() {\n\tint m, n;\n\tcin >> n >> m;\n\tint test = m;\n\tif (n % m == 0) {\n\t\twhile (m--) {\n\t\t\tcout << n / test << \" \";\n\t\t}\n\t\tcout << endl;\n\t\treturn;\n\t}\n\tfor (int i = 0; i < m - n % m; i++)\n\t\tprintf(\"%d \", n / m);\n\tfor (int i = 0; i < n % m; i++)\n\t\tprintf(\"%d \", n / m + 1);\n\n\n\n}\n\n\nint main() {\n\tios::sync_with_stdio(0);\n\tcin.tie(0);\n\n#ifndef ONLINE_JUDGE\n\n\tfreopen(\"input.txt\", \"r\", stdin);\n\n\tfreopen(\"output.txt\", \"w\", stdout);\n#endif\n\tint t; cin >> t;\n\twhile (t--)\n\t\tsolve();\n\n\n\n\treturn 0;\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c126b7e4ac70b84a363ac79d9782b327", "src_uid": "0b2c1650979a9931e00ffe32a70e3c23", "difficulty": 800.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \n#define INF (1<<30)\n#define pii pair\n#define pll pair\n#define pdd pair\n#define eps 0\n\n#ifdef ONLINE_JUDGE\n#define debug(args...)\n#else\n#define debug(args...) fprintf(stderr,args)\n#endif\n\nusing namespace std;\n\nint n;\n\nchar dp[12][1<<10];\nchar dp2[12][1<<10][2];\n\nint v[25];\n\nint get(int,int);\n\nint get2(int q1,int mask,int t){\n\n\tif(dp2[q1][mask][t]+1)\n\t\treturn dp2[q1][mask][t];\n\n\tif(t == 1 && get(q1,mask))\n\t\treturn dp2[q1][mask][t] = 1;\n\n\n\tint qnt = 0, maior = -1;\n\n\tfor(int i=0;i v[maior])\n\t\t\t\tmaior = i;\n\n\tif(mask == 0 && q1 >= 2)\n\t\treturn dp2[q1][mask][t] = 1;\n\tif(mask == 0)\n\t\treturn dp2[q1][mask][t] = 1;\n\n\tfor(int i=0;i<(1< v[maior])\n\t\t\t\tmaior = i;\n\t\t}\n\n\t\n\n\tif(qnt+q1 != v[maior])\n\t\treturn dp[q1][mask] = 0;\n\n\tif(qnt == 0)\n\t\treturn dp[q1][mask] = 1;\n\n\n\tif(get2(q1,mask^(1< b;}\n\nmain(){\n\n\t\tscanf(\"%d\",&n);\n\n\t\tint q1 = 0;\n\n\t\tfor(int i=0;i 15){\n\t\t\tprintf(\"NO\\n\");\n\t\t\treturn 0;\n\t\t}\n\n\t\tsort(v,v+n,comp);\n\n\t\tmemset(dp,-1,sizeof(dp));\n\t\tmemset(dp2,-1,sizeof(dp2));\n\n\t\tn -= q1;\n\t\tif(get(q1,(1<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include \n#include\n#include\n#include \n#include\n#include\n#include\n\n\n#pragma comment(linker, \"/STACK:100000000000000\")\n\nusing namespace std;\n#define For(i,a,b) for (int i=a; i pii;\nint n, ind, dp[25][25][1<<16][2], tw[20];\nvector v;\nint rec(int p, int rem, int mask, bool x)\n{\n\tif(p==v.size()) return 0;\n\tif(~dp[p][rem][mask][x]) return dp[p][rem][mask][x];\n\tif(rem==1) \n\t{\n\t\tif(p+1>n;\n\tint t;\n\tRep(i, n) \n\t{\n\t\tcin>>t;\n\t\tv.push_back(t);\n\t}\n\tSort(v);\n\tRep(i, n) if(v[i]==2)\n\t{\n\t\tcout<<\"NO\";\n\t\treturn 0;\n\t}\n\tint o=0;\n\tvector nx;\n\tRep(i, n) if(v[i]==1) o++;\n\telse nx.push_back(v[i]);\n\tif(n-o>=16 || o==n) \n\t{\n\t\tcout<<\"NO\";\n\t\treturn 0;\n\t}\n\tv=nx;\n\tSet(dp, -1);\n\tint x=rec(0, v[0], 0, 0);\n\tif(x==o) cout<<\"YES\";\n\telse cout<<\"NO\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "28044e9e68cd068ec4c745edd8e93813", "src_uid": "ed0925cfaee961a3ceebd13b3c96a15a", "difficulty": 2300.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nbool all_ok = false;\nint n, a[24];\nbool dp[24][1 << 24];\n\nvoid dfs(int v, int mask) {\n if (dp[v][mask]) return;\n if (all_ok) return;\n if (v == n && mask + 1 == (1 << n)) {\n all_ok = true;\n return;\n }\n for (int i = 0; i < 1 << (n - v - 1); ++i) {\n if ((mask & i) == 0) {\n int x = i;\n int sum = 0;\n int p = 0;\n for (int j = n - 1; j >= 0; --j) {\n if (x % 2) {\n sum += a[j];\n if (sum > a[v]) break;\n ++p;\n }\n x /= 2;\n }\n if ((p > 1 || p == 0) && sum + 1 == a[v]) dfs(v + 1, mask ^ i);\n if (all_ok) return;\n }\n }\n dp[v][mask] = true;\n}\n\nmain () {\n cin >> n;\n for (int i = 0; i < n; ++i) {\n cin >> a[i];\n }\n sort (a, a + n);\n reverse (a, a + n);\n dfs(0, 1 << (n - 1));\n if (all_ok) cout << \"YES\";\n else cout << \"NO\";\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "616ca683891ebd96ab2dc678468260c1", "src_uid": "ed0925cfaee961a3ceebd13b3c96a15a", "difficulty": 2300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nvector st[30];\nint n,c[30];\nbool g[30][1<<24],f[30][1<<24];\n\nint count(int mask)\n{\n\tint ret=0;\n\twhile (mask)\n\t{\n\t\tret+=mask%2;\n\t\tmask/=2;\n\t}\n\treturn ret;\n}\n\nint total(int mask)\n{\n\tint ret=0,i=0;\n\twhile (mask)\n\t{\n\t\tif (mask%2) ret+=c[++i];\n\t\tmask/=2;\n\t}\n\treturn ret;\n}\n\nint main()\n{\n\tscanf(\"%d\",&n);\n\tfor (int i=1;i<=n;i++) scanf(\"%d\",&c[i]);\n\tsort(&c[1],&c[n+1]);\n\tfor (int i=1;i<=n;i++)\n\t{\n\t\tfor (int mask=0;mask<1<=2 && total(mask)+1==c[i])\n\t\t\t\tg[i][mask]=true,st[i].push_back(mask);\n\t\t\telse g[i][mask]=false;\n\t\t}\n\t}\n\tf[0][0]=true;\n\tfor (int i=1;i<=n;i++)\n\t{\n\t\tif (c[i]==1) f[i][(1<\n#include \nusing namespace std;\nint main()\n{\n\tlong long int number;\n\tstring num;\n\tcin >> number;\n\tfor (int i = 1; i <= number; i++)\n\t{\t\n\t\tnum += to_string(i);\n\t\tif (num.length() >= number)\n\t\t{\n\t\t\tcout << num[number - 1];\n\t\t\treturn 0;\n\t\t}\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2e1d91da727016c484ccfa85b184c1e4", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1800.0} {"lang": "MS C++ 2017", "source_code": "#include \"string\"\n#include \n\n\nusing namespace std;\n\nint main()\n{\n\tstring s;\n\tint i = 1;\n\n\twhile (s.length() <= 1000000000000)\n\t{\n\t\ts += to_string(i);\n\t\ti++;\n\t}\n\tint k;\n\tstd::cin >> k;\n\tstd::cout << s[k - 1];\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e2256b722e6752ec08bd8cdf784f50fa", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1800.0} {"lang": "GNU C++14", "source_code": "#include \n#define ll long long int\nusing namespace std;\n\nint main()\n { ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n // ll t;\n //cin>>t;\n //while(t--)\n ll n;\n cin>>n;\n vectorv,v1;\n \n for(ll i=1;;i++)\n { if(i<=9)\n v1.push_back(i);\n else\n { ll g=i;\n while(g!=0)\n { ll a=g%10;\n v.push_back(a);\n g=g/10;\n }\n for(ll j=v.size()-1;j>=0;j--)\n {\n v1.push_back(v[j]);\n }\n v.clear();\n }\n \n if(v1.size()==n)\n {\n break;\n }\n \n }\n /* for(ll i=0;i\n#include \n#include \n\nint main(){\n int k;\n scanf(\"%d\",&k);\n char s[10000];\n char in[12];\n s[0]='\\0';\n for(int i=1;i<=k;i++){\n sprintf(in,\"%d\",i);\n strcat(s,in);\n }\n printf(\"%c\",s[k-1]);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "17fd934eaee025c8188cff0be4f1043c", "src_uid": "1503d761dd4e129fb7c423da390544ff", "difficulty": 1000.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \nusing namespace std;\nint main()\n{\n\n unsigned __int64 b,mx=0,tm=0,v;\n unsigned __int64 y,m;\n cin>>m>>b;\n v=m*b;\n for(double i=1;i<=v;i++)\n {\n y=-i/m+b;\n tm=0;\n if(y==(int)y)\n {\n //cout<\n#include \nusing namespace std;\nunsigned __int64 arifm(unsigned __int64 a)\n{\n unsigned __int64 x;\n x=(a+1)*a/2;\n return(x);\n}\nint main()\n{\n\n unsigned __int64 b=0,mx=0,tm=0,v=0,m=0;\n double y=0,i=0;\n cin>>m>>b;\n v=m*b;\n for(i=0;i<=v;i++)\n {\n y=-i/m+b;\n tm=0;\n if(y==(int)y)\n {\n tm=arifm(y)*(i+1)+arifm(i)*(y+1);\n // cout<\n#include \n#include \nusing namespace std;\nint arr(int a)\n{\n int x=0;\n for(int i=1;i<=a;i++)\n {\n if(a-1!=0)\n {\n x=x+i;\n }\n else\n {\n x=0;\n break;\n }\n }\n return(x);\n}\nint ars(int a)\n{\n int x=0;\n for(int i=1;i<=a;i++)\n {\n x=x+i;\n }\n return(x);\n}\nint main()\n{\n\n int b,mx=0,tm,v;\n double y,m;\n cin>>m>>b;\n v=m*b;\n for(double i=1;i\n#include \n#include \nusing namespace std;\nint main()\n{\n\n int b,mx=0,tm=0,v;\n double y,m;\n cin>>m>>b;\n v=m*b;\n for(double i=1;i\n\nusing namespace std;\n\n#define PI 3.1415926535897932384626433832795\n#define MOD 1000000007\n#define pb push_back\n#define mp make_pair\n#define FOR(i,x,y) for(int i=x;i vi;\ntypedef vector vvi;\ntypedef pair ii;\ntypedef pair iii;\ntypedef vector vii;\ntypedef vector vvii;\ntypedef vector< iii > viii;\ntypedef long long ll;\n//\n\nint main(){\n FAST;\n int n,k,x;\n int a[n];\n cin>>n>>k>>x;\n FOR(i,0,n)\n cin>>a[i];\n int c=0;\n FOR(i,0,n-2)\n c+=a[i];\n c+=k*x;\n cout<\n#include\n#define N 11000\nusing namespace std;\nint max(int a,int b){if(a>b)return a;return b;}\nint min(int a,int b){if(a>1)+1];\nvoid add(int a,int b)\n{\n\te[++tot].to=b;\n\te[tot].last=st[a];\n\tst[a]=tot;\n}\nint dfs(int u)\n{\n\tif(f[u]!=-1)\n\t\treturn f[u];\n\tf[u]=t[u];\n\tfor(int i=st[u];i!=0;i=e[i].last)\n\t\tf[u]=max(f[u],dfs(e[i].to)+t[u]);\n\treturn f[u];\n}\nint main()\n{\n\tscanf(\"%d\",&n);\n\tfor(int i=1,k,v;i<=n;i++)\n\t{\n\t\tscanf(\"%d %d\",&t[i],&k);\n\t\twhile(k--)\n\t\t{\n\t\t\tscanf(\"%d\",&v);\n\t\t\tadd(i,v);\n\t\t}\n\t}\n\tmemset(f,-1,sizeof(f));\n\tint ans=-2147483647;\n\tfor(int i=1;i<=n;i++)\n\t\tif(f[i]==-1)\n\t\t\tans=max(ans,dfs(i));\n\tprintf(\"%d\",ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "aa0a8d4b26eae87b31446e0d432fd44d", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n\tfreopen(\"input.txt\", \"rt\", stdin);\n//\tfreopen(\"output.txt\", \"wt\", stdout);\n\tint n, k, x;\n\tcin >> n >> k >> x;\n\n\tvector deals(n);\n\n\tfor (int i = 0; i < n; i++) {\n\t\tcin >> deals[i];\n\t}\n\tfor (int i = n - 1; i >= n - k ; i--) {\n\t\tdeals[i] = x;\n\t}\n\n\tint total = 0;\n\tfor (int i = 0; i < n; i++) {\n\t\ttotal +=deals[i];\n\t}\n\n\tcout << total << endl;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3d1bbf2ac30daec051ceac80ced471a6", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main()\n{\n\tint *arr;\n\tint size;\n\n\tint k, x, sum = 0;\n\tcin >> size >> k >> x;\n\n\tif (size <= 0) {\n\t\tcerr << \"Invalid size\" << endl;\n\t\treturn 1;\n\t}\n\n\tarr = new int[size];\n\n\n\tfor (int i = 0; i < size; i++) {\n\n\t\tcin >> arr[i];\n\t}\n\n\tint temp; // \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u0435\u0441\u0442\u0430\u043c\u0438\n\n\t\t\t // \u0421\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u043f\u0443\u0437\u044b\u0440\u044c\u043a\u043e\u043c\n\tfor (int i = 0; i < size - 1; i++) {\n\t\tfor (int j = 0; j < size - i - 1; j++) {\n\t\t\tif (arr[j] > arr[j + 1]) {\n\t\t\t\t// \u043c\u0435\u043d\u044f\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u0435\u0441\u0442\u0430\u043c\u0438\n\t\t\t\ttemp = arr[j];\n\t\t\t\tarr[j] = arr[j + 1];\n\t\t\t\tarr[j + 1] = temp;\n\t\t\t}\n\t\t}\n\t}\n\n\tfor (int i = size - k; i < size; i++) {\n\t\tarr[i] = x;\t\t\n\t}\n\t\tfor (int i = 0; i < size; i++) {\n\t\tsum = sum + arr[i];\n\t}\n\tcout << sum;\n\n\t\n\n\tdelete[] arr; // \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\n\n\t_getch();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d51b603f24a58e98135e2e5d1b3d33e4", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": " \n/******************************************\n \tAUTHOR : PRATIK \n INSTITUTION : BITS PILANI HYDERABAD CAMPUS \n******************************************/\n\n#include \nusing namespace std;\ntypedef long long int ll;\ntypedef long double ld;\ntypedef vector vi;\ntypedef multiset ms;\ntypedef set s;\ntypedef vector vid;\ntypedef multiset msd;\ntypedef set sd;\n#define sp setprecision \n#define N 100005\n#define MOD 1000000007\n#define dd double\n#define rep(i, n) for(int i = 0; i < n; i++)\n#define REP(i,a,b) for(int i=a;i>a>>b;\n\tll y=a;\n\tll A[a],B[a];\n\t\n\t\twhile(i>A[i++]; y--;}\n\t\tcin>>A[i++]; \n\t\ti=b-2;\n\t\ty--; \n\t\twhile(i>=0 && y>=0) {cin>>B[i];\n\t\t\t\tif(B[i]*A[i]==0 ) A[i]=0;\n\t\t\t\telse if(A[i]==B[i] ) cu++;\n\t\t\t\ti--;\n\t\t\t\ty--;\n\t\t\t}\n\t\t\t\n while(y--){\n\t\t\tcin>>p;\n\t\t\tif(p==1) cu++;\n\t\t}\n\t\t\n\tREP(i,0,b) if(A[i]==1) cu++;\n\tcout<\n#include \n#include \n#include \n#include \nusing namespace std;\nint arr[1000000],j,n,max1=1,counter,a,dis[10000000],dis1[10000000];\n\nint main()\n{\n\tcin>>n>>a;\n\tfor(int i=1;i<=n;i++)\n\t\t{\n\t\t\tcin>>arr[i];\n\t\t\tif(arr[i])\n\t\t\t{\n\t\t\t\tif(dis[abs(i-a)]==0)\n\t\t\t\t{\n\t\t\t\t dis[abs(i-a)]=1;\n\t\t\t\t dis1[j++]=abs(i-a);\n\t\t\t\t}\n\t\t\t}\n\t }\n\tfor(int i=0;i\n\nusing namespace std;\n\nint main()\n{\n int n,l=0,i,a,f=0,j=0;\n cin>>n>>a;\n int x[n];\n if(a==1)\n {\n l=a;\n }\n else\n l=a-1;\n if(a==n)\n {\n j=a;\n }\n else\n j=a+1;\n for(i=1;i<=n;i++)\n {\n cin>>x[i];\n }\n if(x[a]==1)\n f++;\n while(true)\n {\n if(l>1 && j\n\nusing namespace std;\n\nint main()\n{\n int n,l=0,i,a,f=0,j=0;\n cin>>n>>a;\n int x[n+5];\n if(a==1)\n {\n l=a;\n }\n else\n l=a-1;\n if(a==n)\n {\n j=a;\n }\n else\n j=a+1;\n for(i=1;i<=n;i++)\n {\n cin>>x[i];\n }\n if(x[a]==1)\n f++;\n while(true)\n {\n if(l>1 && j\n#include\n#include\n\nusing namespace std;\n\ntypedef long long LL;\n\nint inf = 1000000009;\n\nint findB(int x, int y, int a){\n \n LL low = -inf;\n LL high = inf;\n LL val, mid;\n\n while(low < high){\n mid = (low + high)/2;\n \n val = x - y - 2*a*mid;\n if( val < 0){\n high = mid;\n }\n else low = mid+1;\n }\n \n return low;\n}\n\nint findA(int x, int y, int a){\n \n LL low = -inf;\n LL high = inf;\n LL val, mid;\n\n while(low < high){\n mid = low + (high-low)/2;\n \n val = x + y - 2*a*mid;\n if( val < 0){\n high = mid;\n }\n else low = mid+1;\n }\n \n return low;\n}\nint main(){\n\n int a, b, x1, y1, x2, y2;\n int a1, a2, b1, b2, ret;\n \n cin>> a >> b >> x1>> y1 >> x2 >> y2;\n\n a1 = findA(x1, y1, a);\n //cout<< a1<\n#include \n#include \n#include \n#include \n#define INF 1000000000\ntypedef long long int LL; \ntypedef unsigned long long int ULL; \nusing namespace std;\n\nLL a,b,x1,y,x2,y2;\n\nint main(){\n\tcin >> a >> b >> x1 >> y >> x2 >> y2;\n\tLL da;\n\tLL k1=x1+y;\n\tLL k2=x2+y2;\n\tLL mi=min(k1,k2);\n\tLL ma=max(k1,k2);\n\twhile (mi%(2*a)!=0) mi++;\n\twhile (ma%(2*a)!=0) ma--;\n\tif (mi>ma) da=0;\n\telse da=(ma-mi)/(2*a)+1;\n\tLL db;\n\tLL t1=x1-y;\n\tLL t2=x2-y2;\n\tmi=min(t1,t2);\n\tma=max(t1,t2);\n\twhile (mi%(2*b)!=0) mi++;\n\twhile (ma%(2*b)!=0) ma--;\n\tif (mi>ma) db=0;\n\telse db=(ma-mi)/(2*b)+1;\n\tcout << max(da,db); \n\t\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3a57c90d7e65af72465786495137cc67", "src_uid": "7219d1837c83b5920992aee5a60dc0d9", "difficulty": 1800.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n\nusing namespace std;\n\ntypedef long long LL;\n\nint inf = 100000009;\n\nint findB(int x, int y, int a){\n \n LL low = -inf;\n LL high = inf;\n LL val, mid;\n\n while(low < high){\n mid = (low + high)/2;\n \n val = x - y - 2*a*mid;\n if( val < 0){\n high = mid;\n }\n else low = mid+1;\n }\n \n return low;\n}\n\nint findA(int x, int y, int a){\n \n LL low = -inf;\n LL high = inf;\n LL val, mid;\n\n while(low < high){\n mid = (low + high)/2;\n \n val = x + y - 2*a*mid;\n if( val < 0){\n high = mid;\n }\n else low = mid+1;\n }\n \n return low;\n}\nint main(){\n\n int a, b, x1, y1, x2, y2;\n int a1, a2, b1, b2, ret;\n \n cin>> a >> b >> x1>> y1 >> x2 >> y2;\n\n a1 = findA(x1, y1, a);\n a2 = findA(x2, y2, a);\n \n b1 = findB(x1, y1, b);\n b2 = findB(x2, y2, b);\n \n ret = max( abs(a1-a2), abs(b1-b2));\n \n cout<< ret;\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "87091eb3ce6845b6b39cf046e4186215", "src_uid": "7219d1837c83b5920992aee5a60dc0d9", "difficulty": 1800.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\nlong a,b,x,x2,y,y2,res1,res2,res,xx,xx2,yy,yy2,k,k2,i;\n\nint main()\n{\n\tcin>>a>>b>>x>>y>>x2>>y2;\n\n\t\n\n\tyy=y;\n\tyy2=y2;\n\tfor(i=1;i<=2*b;i++)\n\t{\n\t\tyy+=1;\n\t\tif((yy-x)%(2*b)==0) k=(yy-x)/(2*b);\n\n\t\tyy2+=1;\n\t\tif((yy2-x2)%(2*b)==0) k2=(yy2-x2)/(2*b);\n\t}\n\tres1=abs(k2-k);\n\n\txx=x;\n\txx2=x2;\n\tfor(i=1;i<=2*a;i++)\n\t{\n\t\txx+=1;\n\t\tif((y+xx)%(2*a)==0) k=(xx+y)/(2*a);\n\n\t\txx2+=1;\n\t\tif((y2+xx2)%(2*a)==0) k2=(xx2+y2)/(2*a);\n\t}\n\n\tres2=abs(k2-k);\n\n\tres=max(res1,res2);\n\n\tcout<\nusing namespace std;\n\nint main (){\nint n,m,k,con1,con2;\ncin>>n>>m>>k;\nfor(int i=1;i<=k;i++){\n con1=n*i;\n con2+=con1;\n}\ncon2-con2-m;\nif(con2>0)\n cout<\n#include \nusing namespace std;\nint main()\n{int w;\n long int n,k,s,m;\n cin>>k;\n cin>>n;\n cin>>w;\n s=k*w*(w+1)/2;\n m=s-n;\n cout<\n#include\n\nusing namespace std;\n\nvoid main()\n{\n\tint k,w; \n\tlong int n;\n\tcin>>k>>n>>w;\n\tfor (int i=1;i>=n;i++)\n\t\tw *= i; \n\tcout<\nusing namespace std;\nlong long n,k,w,i,j,c,d,s;\nint main()\n{\n cin>>n>>k>>w;\n d=(2*n)-n;\n //cout<\nint main()\n{\n int a,b,c,x,y,z,sum,v[7],i;\n while(scanf(\"%d%d%d\",&x,&y,&z))\n {\n scanf(\"%d%d%d\",&a,&b,&c);\n for(i=1;i<=6;i++)\n scanf(\"%d\",v+i);\n sum=0;\n if(z>c) sum+=v[4];\n else if(z<0) sum+=v[3];\n if(y>b) sum+=v[2];\n else if(y<0) sum+=v[1];\n if(x>a) sum+=v[6];\n else if(a<0) sum+=v[5];\n printf(\"%d\\n\",sum);\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0221c04e56b0226883d81354947dc203", "src_uid": "c7889a8f64c57cf7be4df870f68f749e", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \nint main()\n{\n int x,y,z,x1,y1,z1,a[6];\n scanf(\"%d%d%d\",&x, &y, &z);\n \n scanf(\"%d%d%d\", &x1, &y1, &z1);\n for(int i=0; i<6; scanf(\"%d\", &a[i]) );\n printf( \"%d\\n\" , (x<0?a[4]:0)+(x>x1?a[5]:0)+(y<0?a[0]:0)+(y>y1?a[1]:0)+(z<0?a[2]:0)+(z>z1?a[3]:0) );\n \n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3dcf2de1be0bff8aa157cb6e89d4e502", "src_uid": "c7889a8f64c57cf7be4df870f68f749e", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntemplate< class T > T _abs(T n) { return (n < 0 ? -n : n); }\ntemplate< class T > T sq(T x) { return x * x; }\ntemplate< class T > T gcd(T a, T b) { return (b != 0 ? gcd(b, a%b) : a); }\ntemplate< class T > T lcm(T a, T b) { return (a / gcd(a, b) * b); }\ntemplate< class T > T _max(T a, T b) { return (!(a < b) ? a : b); }\ntemplate< class T > T _min(T a, T b) { return (a < b ? a : b); }\ntemplate< class T > inline T MOD(T n, T m){ return (n%m+m)%m;}\n\n//string monthName[]={\"\",\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"};\n//string dayName[]={\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"};\n\n//int xx[]={1,0,-1,0}; int yy[]={0,1,0,-1}; //4 Direction\n//int xx[]={1,1,0,-1,-1,-1,0,1}; int yy[]={0,1,1,1,0,-1,-1,-1};//8 direction\n//int xx[]={2,1,-1,-2,-2,-1,1,2}; int yy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction\n\n#define REP(i,n)for (i=0;i=0;i--)\n\n#define READ(f) freopen(f, \"r\", stdin)\n#define WRITE(f) freopen(f, \"w\", stdout)\n#define REV(s, e) reverse(s, e)\n\n#define ll long long int\n#define CLR(p) memset(p, 0, sizeof(p))\n#define mset(p, v) memset(p, v, sizeof(p))\n#define ALL(c) c.begin(), c.end()\n#define SZ(c) (int)c.size()\n#define pb(x) push_back(x)\n#define vs vector\n#define vi vector\n#define vii vector< pair >\n\n#define fs first\n#define sc second\n#define MP(x, y) make_pair(x, y)\n#define pii pair< int, int >\n#define psi pair< string, int >\n#define pq priority_queue\n\n#define LOG(x,BASE) (log10(x)/log10(BASE))\n#define EQ(a,b) (fabs(a-b)\"<<#x<<\": \"< \";dbg,args; cerr< debugger& operator , (const T& v) { cerr< void deb(T e){cout< void deb(T1 e1,T2 e2){cout< void deb(T1 e1,T2 e2,T3 e3){cout< void deb(T1 e1,T2 e2,T3 e3,T4 e4){cout< void deb(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5){cout< void deb(vector e){int i;REP(i,SZ(e)) cout< void deb(vector e,int n){int i;REP(i,n) cout< void deb(vector< basic_string > e){int i,j;REP(i,SZ(e)) {REP(j,SZ(e[i])) cout< void deb(vector< basic_string > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout< void deb(vector< vector > e,int row,int col){int i,j;REP(i,row) {REP(j,col) cout< void deb(T e[MAX][MAX],int row,int col){int i,j;REP(i,row) {REP(j,col) cout< void deb(T e[],int row){int i;REP(i,row) cout< inline bool isPrime(T n){if(n<=1)return false;for (T i=2;i*i<=n;i++) if (n%i==0) return false;return true;}\n//int,double is converted to string\ntemplate string toString(T n){ostringstream oss;oss<>r;return r;}\n//string is converted to Long long\nbool IsVowel(char ch){ch=tolower(ch);if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')return true;return false;}\n//isUpperCase\nbool isUpper(char c){return c>='A' && c<='Z';}\n//isLowerCase\nbool isLower(char c){return c>='a' && c<='z';}\n//compute b^p\nll Pow(ll B,ll P){ ll R=1; while(P>0) {if(P%2==1) R=(R*B);P/=2;B=(B*B);}return R;}\n//compute b^p%m\nint BigMod(ll B,ll P,ll M){ ll R=1; while(P>0) {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return (int)R;}\n//print a number in binary format with n length\nvoid binprint(ll mask,ll n){ll i;string s=\"\";do{s+=(mask%2+'0');mask/=2;}while(mask);reverse(ALL(s) );s=string(max(n-SZ(s),0LL),'0')+s;for(i=SZ(s)-n;i '%c' \",k,k);}printf(\"\\n\");}}\n\nint x_, y_, z_, x, y, z;\nint a[7];\n\nint main()\n{\n //READ(\"in.txt\");\n //WRITE(\"out.txt\");\n int i, j, k, result, t=0, tcase;\n while(scanf(\"%d %d %d\", &x, &y, &z ))\n {\n scanf(\"%d %d %d\", &x_, &y_, &z_);\n for(i=1; i<=6; i++)\n {\n scanf(\"%d\", &a[i]);\n }\n\n int sum=0;\n\n if(y<0) sum+= a[1];\n if(y>y_) sum+= a[2];\n if(z<0) sum+= a[3];\n if(z>z_) sum+= a[4];\n if(x<0) sum+= a[5];\n if(x>x_) sum+= a[6];\n\n printf(\"%d\\n\", sum);\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2deecb2ee3477f29d91c97f68bf0fc0c", "src_uid": "c7889a8f64c57cf7be4df870f68f749e", "difficulty": 1600.0} {"lang": "MS C++", "source_code": "#include \nusing namespace std;\nint a[10];\nint main()\n{\n#ifndef ONLINE_JUDGE\n freopen (\"input.txt\", \"r\", stdin);\n freopen (\"output.txt\", \"w\", stdout);\n#endif\n int sum = 0;\n int x, y, z;\n int x1, y1, z1;\n scanf(\"%d%d%d\", &x, &y, &z);\n scanf(\"%d%d%d\", &x1, &y1, &z1);\n for (int i = 1; i <= 6; i++)\n scanf(\"%d\", &a[i]);\n\n if (y > y1)\n sum += a[2];\n if (y < 0)\n sum += a[1];\n\n if (z > z1)\n sum += a[4];\n if (z < 0)\n sum += a[3];\n\n if (y > y1)\n sum += a[6];\n if (y < 0)\n sum += a[5];\n printf(\"%d\", sum);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1bd30c4151f66180b8259956d08d3c07", "src_uid": "c7889a8f64c57cf7be4df870f68f749e", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "// be name khoda\n\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\nconst int maxN = 8000;\n\nstruct node{\n bool lr;\n int x, ind, pl;\n};\n\nint l[maxN][maxN], r[maxN][maxN], type[maxN], lr[maxN][2], n;\nvector timeLine[maxN];\nset ans;\n\nint lg(ll v)\n{\n int k = 0;\n while((1 << k) < v)\n k++;\n return k;\n}\n\nvoid count(int n)\n{\n ll a[maxN], sum[maxN];\n a[1] = sum[1] = 1;\n for(int i = 2; i < n; i++) \n {\n a[i] = a[i - 1] + lg(a[i - 1]);\n sum[i] = sum[i - 1] + a[i];\n }\n for(int i = 6500; i < 7000; i++)cerr << i << \" : \" << a[i] << \", \" << sum[i] << endl;\n}\n\nbool cmp(node l, node r)\n{\n return l.pl < r.pl;\n}\n\nint main()\n{\n int n, m;\n cin >> n >> m;\n for(int i = 0; i < m; i++)\n {\n int t;\n cin >> t;\n type[i] = t;\n if(t == 1)\n {\n int t, lll, rr, x;\n cin >> t >> lll >> rr >> x;\n node a, b;\n a.ind = b.ind = i;\n a.lr = 0;\n b.lr = 1;\n a.pl = lll;\n b.pl = rr;\n a.x = b.x = x;\n timeLine[t].push_back(a);\n timeLine[t].push_back(b);\n }\n else\n {\n int t, v;\n cin >> t >> v;\n lr[i][0] = t;\n lr[i][1] = v;\n int lll = v, rr = v;\n for(int j = t; j <= n; j++)\n {\n l[i][j] = lll;\n r[i][j] = rr;\n int lgl = lg(lll);\n if(1 << (lgl) == lll)\n lll = lll + lgl;\n else\n lll = lll + lgl;\n rr = rr + lg(rr);\n //cerr << i << \" , \" << j << \" : \" << l[i][j] << \" \" << r[i][j] << endl;\n }\n }\n }\n for(int i = 1; i <= n; i++)\n sort(timeLine[i].begin(), timeLine[i].end(), cmp);\n for(int i = 0; i < m; i++)\n if(type[i] == 2)\n {\n ans.clear();\n for(int j = lr[i][0]; j <= n; j++)\n {\n //cerr << i << \", \" << j << endl;\n for(int k = 0; k < timeLine[j].size(); k++)\n if(k >= l[i][j] && k <= r[i][j] && timeLine[j][k].ind < i)\n ans.insert(timeLine[j][k].x);\n // for(int k = l[i][j]; k <= r[i][j]; k++)\n // {\n //\n // }\n }\n cout << ans.size() << endl;\n }\n cin >> n;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "02689c0297f745bb81f095a066a774ea", "src_uid": "9f239cfd29c1a2652a065bfe5c15476a", "difficulty": 2400.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define pii pair\nusing namespace std;\ntypedef long long ll;\n\nconst int N = 7123;\nconst int L = 1e7;\n\nmultiset s[N];\n\nint par[L*2];\n\nint main(){\n // freopen(\"input.txt\",\"r\",stdin);// freopen(\"output.txt\",\"w\",stdout);\n \n int n, m;\n \n n = 1;\n for(int i=1;n q;\n for(multiset::iterator it = s[t].begin(); it!=s[t].end(); it++){\n if(it->first>v) break;\n int x = it->second;\n if(x > 0) q[x]++;\n else{\n x=-x;\n q[x]--;\n if(!q[x]) q.erase(x);\n }\n }\n \n printf(\"%d\\n\",q.size());\n }\n }\n \n \n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7a08733b486fafd602a7fb477bf2b520", "src_uid": "9f239cfd29c1a2652a065bfe5c15476a", "difficulty": 2400.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#define NMax 7010\n\nusing namespace std;\n\nint N, M, L;\nint Min[NMax], Max[NMax];\nvector P[NMax];\nvector< pair > nodes;\nunordered_set sets[NMax];\n\nstruct operation {\n\n int type;\n int t;\n int l;\n int r;\n int x;\n\n} v[NMax];\n\nint main() {\n\n#ifndef ONLINE_JUDGE\n freopen(\"in\", \"r\", stdin);\n#endif // ONLINE_JUDGE\n\n scanf(\"%d%d\", &N, &M);\n\n P[1].push_back(0);\n P[1].push_back(0);\n\n for ( int i = 1; i < N; ++ i ) {\n P[i + 1].push_back(0);\n for ( int j = 1; j < (int) P[i].size(); ++ j )\n if ( (j & ( j - 1 )) == 0 ) { // putere a lui 2\n P[i + 1].push_back(j);\n P[i + 1].push_back(j);\n } else {\n P[i + 1].push_back(j);\n }\n }\n\n for ( int i = 1; i <= M; ++ i ) {\n\n scanf(\"%d\", &v[i].type);\n\n if ( v[i].type == 1 ) {\n scanf(\"%d%d%d%d\", &v[i].t, &v[i].l, &v[i].r, &v[i].x );\n } else {\n scanf(\"%d%d\", &v[i].t, &v[i].x );\n nodes.push_back(make_pair( v[i].t, v[i].x));\n }\n\n }\n\n sort(nodes.begin(), nodes.end());\n nodes.resize(unique(nodes.begin(), nodes.end()) - nodes.begin());\n //sets.resize(nodes.size());\n\n for ( int i = 1; i <= M; ++ i ) {\n\n if ( v[i].type == 1 ) {\n\n for ( int i = 1; i <= N; ++ i ) {\n Min[i] = 2 * N + 1;\n Max[i] = -1;\n }\n\n Min[v[i].t] = v[i].l;\n Max[v[i].t] = v[i].r;\n\n for ( int l = v[i].l, t = v[i].t; t > 0; l = P[t][l], -- t ) {\n Min[t] = l;\n }\n\n for ( int r = v[i].r, t = v[i].t; t > 0; r = P[t][r], -- t ) {\n Max[t] = r;\n }\n\n for ( int k = 0; k < (int) nodes.size(); ++ k )\n if ( Min[nodes[k].first] <= nodes[k].second && nodes[k].second <= Max[nodes[k].first] )\n sets[k].insert(v[i].x);\n\n } else {\n int pos = lower_bound( nodes.begin(), nodes.end(), make_pair(v[i].t, v[i].x)) - nodes.begin();\n printf(\"%d\\n\", (int) sets[pos].size() );\n }\n\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7a9a5a9998ae7b5122ae45f894783087", "src_uid": "9f239cfd29c1a2652a065bfe5c15476a", "difficulty": 2400.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define FOR(i,c) for(auto i=(c).begin();i!=(c).end();i++)\n#define SZ size()\n#define ALL(x) (x).begin(),(x).end()\n#define REP(i,n) for(int i=0;i<(n);i++)\n#define REP1(i,a,b) for(int i=(a);i<=(b);i++)\n#define REPL(i,x) for(int i=0;x[i];i++)\n#define PER(i,n) for(int i=(n)-1;i>=0;i--)\n#define PER1(i,a,b) for(int i=(a);i>=(b);i--)\n#define RI(x) scanf(\"%d\",&x)\n#define DRI(x) int x;RI(x)\n#define RII(x,y) scanf(\"%d%d\",&x,&y)\n#define DRII(x,y) int x,y;RII(x,y)\n#define RIII(x,y,z) scanf(\"%d%d%d\",&x,&y,&z)\n#define DRIII(x,y,z) int x,y,z;RIII(x,y,z)\n#define RS(x) scanf(\"%s\",x)\n#define PI(x) printf(\"%d\\n\",x)\n#define PIS(x) printf(\"%d \",x)\n#define MP make_pair\n#define PB push_back\n#define EB emplace_back\n#define BG begin()\n#define ED end()\n#define PQ priority_queue\n#define MS0(x) memset(x,0,sizeof(x))\n#define MS1(x) memset(x,-1,sizeof(x))\n#define SEP(x) ((x)?'\\n':' ')\n\ntypedef pair PII;\ntypedef vector VI;\ntypedef long long LL;\nconst int INF = 1000000000;\n\n#define MAX 7000\n\n\nstruct Segment {\n int l, r, x;\n Segment() {}\n Segment(int l, int r, int x) : l(l), r(r), x(x) {}\n};\n\nstruct Node {\n short left, right;\n Node(): left(-1), right(-1) {}\n Node(int l, int r): left(l), right(r) {}\n};\n\nint cnt[MAX+1];\nvector node[MAX+1];\nvector record[MAX+1];\n\nint main() {\n DRII(n, m);\n cnt[1] = 1;\n for(int level = 1; level < n; level = level + 1){\n cnt[level + 1] = 0;\n node[level].EB();\n for(int position = 1; position <= cnt[level]; position = position + 1){\n if((position & (position - 1)) == 0){ // that is, 1, 2, 4, 8...\n node[level].EB(cnt[level + 1] + 1, cnt[level + 1] + 2);\n cnt[level + 1] += 2;\n } else {\n node[level].EB(-1, ++cnt[level + 1]);\n }\n }\n }\n REP(i, m) {\n DRII(type, level);\n if(type == 1) {\n DRIII(l, r, x);\n record[level].EB(l, r, x);\n } else {\n DRI(position);\n int l = position, r = position;\n unordered_set ans;\n while(level <= n) {\n for(const Segment & seg : record[level])\n if(seg.l <= r && l <= seg.r)\n ans.insert(seg.x);\n if(level < n) {\n r = node[level].at(r).right;\n if(node[level].at(l).left >= 0)\n l = node[level].at(l).left;\n else\n l = node[level].at(l).right;\n }\n level++;\n }\n PI((int)ans.size());\n }\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "62ac3af4e03beb057f3dcdd33e7ca5d9", "src_uid": "9f239cfd29c1a2652a065bfe5c15476a", "difficulty": 2400.0} {"lang": "GNU C++14", "source_code": "#include \n#define int long long\n#define inf 1e18\nusing namespace std;\nconst int N = 1123456;\nint read()\n{\n int x;\n scanf(\"%I64d\", &x);\n return x;\n}\nint getrand()\n{\n srand(time(0));\n int x = rand();\n while(x -- > 0)\n rand();\n return rand() % 732 + 1;\n}\nint cnt[N];\nchar t[66];\nmain()\n{\n int n, m, i, j, k, x, y;\n cin >> n >> m >> k >> x >> y;\n if(n == 1)\n {\n cout << k / m + ((k % m) != 0) << \" \" << k / m << \" \";\n int d = k / m;\n if(y <= k % m)\n d ++;\n cout << d;\n return 0;\n }\n int r = (n - 1) * m;\n int ans1 = k / r;\n int ans2 = ans1 / 2;\n int ans3 = ans1;\n if(x == 1 || x == n)\n ans3 = ans2;\n if(x == 1)\n ans3 += ans1 % 2;\n k %= r;\n if(ans1 % 2 == 0)\n {\n if((x - 1) * m + y <= k)\n ans3 ++;\n }\n else\n {\n if((n - x) * m + y <= k)\n ans3 ++;\n }\n if(k >= m && ans1 % 2 == 1)\n ans2 ++;\n if(n == 2)\n ans1 = ans1 / 2 + ans1 % 2;\n if(k > m)\n ans1 ++;\n cout << ans1 << \" \" << ans2 << \" \" << ans3;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6e297951889c89fb35506826120a5ea4", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nconst int inf = 0x3f3f3f3f;\n\nint n, m, x, y;\nlong long k;\n\nint main( ) {\n\tscanf(\"%d %d %I64d %d %d\", &n, &m, &k, &x, &y);\n\tif (n == 1 || n == 2) {\n\t\tlong long p = k / (n * m), res = k % (n * m);\n\t\tlong long num1 = p, num2 = p, ans = p;\n\t\tif (res) ++ num1;\n\t\tif (res >= (x - 1) * m + y) ++ ans;\n\t\tprintf(\"%I64d %I64d %I64d\\n\", num1, num2, ans);\n\t}\n\telse {\n\t\tlong long p = k / ((2 * n - 2) * m), res = k % ((2 * n - 2) * m);\n\t\tlong long num1 = 2 * p, num2 = p;\n\t\tlong long ans;\n\t\tif (x == n || x == 1) ans = num2;\n\t\telse ans = num1;\n\t\tif (res > m) {\n\t\t\t++ num1;\n\t\t\tif (res > (n - 1) * m) {\n\t\t\t\t++ num2;\n\t\t\t\tif (res > n * m) ++ num1;\n\t\t\t}\n\t\t}\n\t\tif (res >= (x - 1) * m + y) ++ ans;\n\t\tif (x != n && res > n * m) {\n\t\t\tres -= n * m;\n\t\t\tif (res >= (n - 1 - x) * m + y) ++ ans;\n\t\t}\n\t\tprintf(\"%I64d %I64d %I64d\\n\", num1, num2, ans);\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2d3ac0119dcaff7495368487d60e375c", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700.0} {"lang": "MS C++", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\nll n, m, k, x, y, f[101][101];\nint main() {\n\tcin >> n >> m >> k >> x >> y;\n\tll iter;\n\tif (n == 1)\n\t\titer = m;\n\telse if (n == 2)\n\t\titer = 2 * m;\n\telse iter = 2 * m + (n - 2) * m * 2;\n\tll times = k / iter;\n\tk -= times * iter;\n\tfor (int i = 1; i <= n; ++i){\n\t\tfor (int j = 1; j <= m; ++j){\n\t\t\tif (i == 1 || i == n)\n\t\t\t\tf[i][j] += times;\n\t\t\telse f[i][j] += 2 * times;\n\t\t}\n\t}\n\tll r = 1, d = 1;\n\twhile (k){\n\t\tfor (int j = 1; j <= m && k; ++j){\n\t\t\t--k;\n\t\t\t++f[r][j];\n\t\t}\n\t\tr += d;\n\t\tif (r > n){\n\t\t\tr = n - 1;\n\t\t\td = -1;\n\t\t}\n\t\telse if (r < 1){\n\t\t\tr = 1;\n\t\t\td = 1;\n\t\t}\n\t\tr = max(r, 1ll);\n\t\tr = min(r, n);\n\t}\n\tll mx = 0, mn = 1e15;\n\tfor (int i = 1; i <= n; ++i){\n\t\tfor (int j = 1; j <= m; ++j){\n\t\t\tmx = max(mx, f[i][j]);\n\t\t\tmn = min(mn, f[i][j]);\n\t\t}\n\t}\n\tcout << mx << \" \" << mn << \" \" << f[x][y] << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6365df8a35ab07d95defd46491d4d9ed", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\nconst ll INF=1e18;\nint main()\n{\n ll n,m,k,x,y,mx=0,mn=INF,ans;\n scanf(\"%lld%lld%lld%lld%lld\",&n,&m,&k,&x,&y);\n if(n==1)\n {\n mx=k/m+(k%m!=0);\n mn=k/m;\n ans=mn+(k%m>=y);\n printf(\"%lld %lld %lld\\n\",mx,mn,ans);\n return 0;\n }\n else if(n==2)\n {\n mx=k/(m*2)+(k%m!=0);\n mn=k/(m*2);\n if(x==1)\n {\n ans=k/(m*2)+(k%(n*m)>=y);\n }\n else\n ans=k/(n*m)+(k%(n*m)>=m+y);\n printf(\"%lld %lld %lld\\n\",mx,mn,ans);\n return 0;\n }\n ll T=(m*(n*2-2));\n mx=k/T*2;\n if(k%T/m>=1)\n {\n if(k%T/m==1&&k%m==0)\n {\n ;\n }\n else\n {\n mx++;\n if(k%T/m>=n)\n {\n if(k%T/m==n&&k%m==0)\n {\n ;\n }\n else\n mx++;\n }\n }\n }\n mx=max(mx,k/T+(k%T!=0));\n mn=k/T+(k%T/(n*m)!=0);\n ll aa=k/T,b[105][105]={0};\n for(int i=1;i<=n;i++)\n {\n for(int j=1;j<=m;j++)\n {\n if(i==1||i==n)\n {\n b[i][j]+=aa;\n }\n else\n b[i][j]+=aa*2;\n }\n }\n aa=k%T;\n int i=1,j=1;\n while(aa--)\n {\n if(i>n)\n break;\n b[i][j]++;\n j++;\n if(j==m+1)\n i++,j=1;\n }\n i=n-1;\n j=1;\n while(aa--)\n {\n b[i][j]++;\n j++;\n if(j==m+1)\n i--,j=1;\n }\n printf(\"%lld %lld %lld\\n\",mx,mn,b[x][y]);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2191693dfd3f5528cd1595ac52795fda", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21", "difficulty": 1700.0} {"lang": "GNU C++17 Diagnostics", "source_code": "#include \n#include \n\nusing namespace std;\nint main()\n{\n int n;\n cin >>n;\n int a[100];\n for (int i=0;i>a[i];\n }\n if (a[n-1]==0){\n cout <<\"UP\" <\n#include \nusing namespace std;\nvoid main()\n{\n\tint n, *m;\n\tcin >> n;\n\tm = new int[n];\n\tfor (int i = 0; i <= n - 1; i++)\n\t\tcin >> m[i];\n\tif (n == 1 && m[n - 1] != 0)\n\t\tcout << \"-1\";\n\tif (m[n - 1] > m[n - 2] && n > 1 && m[n - 1] != 15)\n\t\tcout << \"UP\";\n\tif (m[n - 1] < m[n - 2] && n > 1 && m[n-1]!=0)\n\t\tcout << \"DOWN\";\n\tif (m[n - 1] ==0 && n>1)\n\t\tcout << \"UP\";\n\tif (m[n-1]==0 && n==1)\n\t\tcout << \"UP\";\n\tgetch();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5aa9dd8217204060dffca5934f523c11", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include\nusing namespace std;\nvoid main()\n{\n\tint n, *m;\n\tcin >> n;\n\tm = new int[n];\n\tfor (int i = 0; i <= n - 1; i++)\n\t{\n\t\tcin >> m[i];\n\t}\n\tif (m[n - 1] > m[n - 2] && m[n - 1] != 15 && n>1)\n\t\tcout << \"UP\";\n\tif (m[n - 1] > m[n - 2] && m[n - 1] == 15 && n>1)\n\t\tcout << \"DOWN\";\n\tif (m[n - 1] < m[n - 2])\n\t\tcout << \"DOWN\";\n\tif (m[n - 1] == 0 && n == 1)\n\t\tcout << \"UP\";\n\tif (m[n - 1] != 0 && n == 1)\n\t\tcout << \"-1\";\n\tgetch();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2b7a90215db290e015c1f056d69cad98", "src_uid": "8330d9fea8d50a79741507b878da0a75", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int N;\n scanf(\"%d\" , &N);\n int ar[N];\n while(true)\n {\n for(int i = 0 ; i < N ; i++)\n {\n cin>>ar[i];\n }\n if(N < 2)\n {\n cout<<\"-1\"<\n#include \nusing namespace std;\n\nint main() {\n\tint n,L,num;\n\tcin>>n>>L;\n\tint arr1[n],arr2[num];\n\tmap hmap1;\n\tmap hmap2;\n\tfor(int i=0;i>arr1[i];\n\t hmap1[num]++;\n\t}\n\t\n\tfor(int i=0;i>arr2[i];\n\t hmap2[num]++;\n\t}\n\tfor(int i=0;i::iterator itr2=hmap2.begin();\n\tint flag=0;\n\tfor(map::iterator itr=hmap1.begin();itr!=hmap1.end();itr++)\n\t{\n\t //cout<first<<\" \"<first<second<<\" \"<second<first!=itr2->first)\n\t {\n\t flag=1;\n\t break;\n\t }\n\t else\n\t {\n\t if(itr->second!=itr2->second)\n\t {\n\t flag=1;\n\t break;\n\t }\n\t }\n\t itr2++;\n\t}\n\tif(flag==1)\n\tcout<<\"NO\";\n\telse\n\tcout<<\"YES\";\n\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2974f3bf5c3da5471810fd51cc54a1c1", "src_uid": "3d931684ca11fe6141c6461e85d91d63", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n\tint l,n;\n\tint a[n+1],b[n+1],c[n+1],d[2*n + 1];\n\tcin >> n >> l;\n\tfor (int i=0;i> a[i];\n\t}\n\tfor (int i=0;i> b[i];\n\t}\n\tfor (int i=0;i\n\ntypedef long long int ll;\n#define pp pair\n#define ppp pair\n#define dbg printf(\"x\");\n#define inf 1000000000000\n#define max2(a,b) ((ab)?b:a)\n#define min3(a,b,c) min2(min2(a,b),c)\n\nusing namespace std;\n\nint main()\n{\n freopen(\"in.txt\",\"r\",stdin);\n int i,j,k;\n int n,l;\n\n cin>>n>>l;\n int a[n],b[n];\n\n for(i=0;i>a[i];\n\n for(i=0;i>b[i];\n\n queue ds;\n queue kf;\n\n for(i=1;i\n#include \n#include \n#include \n\nusing namespace std;\n\nifstream cin(\"input.txt\");\nofstream cout(\"output.txt\");\n\nint main() {\n\tint n, l;\n\tcin >> n >> l;\n\tvector a;\n\tvector b;\n\tvector aa;\n\tdeque bb;\n\tint z = 0;\n\tfor (int i = 0; i < n; i++) {\n\t\tint k;\n\t\tcin >> k;\n\t\ta.push_back(k);\n\t\tif (i > 0) {\n\t\t\taa.push_back(a[i] - a[i - 1]);\n\t\t} else {\n\t\t\taa.push_back(k);\n\t\t}\n\t\tz += aa[i];\n\t}\n\taa.push_back(l - z);\n\tz = 0;\n\tfor (int i = 0; i < n; i++) {\n\t\tint k;\n\t\tcin >> k;\n\t\tb.push_back(k);\n\t\tif (i > 0) {\n\t\t\tbb.push_back(b[i] - b[i - 1]);\n\t\t} else {\n\t\t\tbb.push_back(k);\n\t\t}\n\t\tz += bb[i];\n\t}\n\tbb.push_back(l - z);\n\taa[0] += aa[(int)aa.size() - 1];\n\tbb[0] += bb[(int)bb.size() - 1];\n\taa.pop_back();\n\tbb.pop_back();\n\tfor (int i = 0; i <= n; i++) {\n\t\tbool good = 1;\n\t\tfor (int j = 0; j < n; j++) {\n\t\t\tif (aa[j] != bb[j]) {\n\t\t\t\tgood = 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (good == 1) {\n\t\t\tcout << \"YES\";\n\t\t\treturn 0;\n\t\t} else {\n\t\t\tint v = bb.front();\n\t\t\tbb.pop_front();\n\t\t\tbb.push_back(v);\n\t\t}\n\t\t// for (int j = 0; j < (int)bb.size(); j++) {\n\t\t// \tcout << bb[j] << \" \";\n\t\t// }\n\t\t// cout << \"\\n\";\n\t}\n\tcout << \"NO\";\n\n\t// for (int i = 0; i < (int)aa.size() - 1; i++) {\n\t// \tcout << aa[i] << \" \";\n\t// }\n\t// cout << \"\\n\";\n\t// for (int i = 0; i < (int)bb.size() - 1; i++) {\n\t// \tcout << bb[i] << \" \";\n\t// }\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "08fe7c74b1bafe194fdb8804e3185743", "src_uid": "3d931684ca11fe6141c6461e85d91d63", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \n#define mp make_pair\nusing namespace std;\ntypedef long long int ll;\ntypedef vector vll;\ntypedef pair p;\nint qw,wq;\nvector < vector< p > > v;\nvector vis;\nvll al;\nchar m[4][4];\nint x[8]={-1,-1,-1,0,0,1,1,1};\nint y[8]={-1,0,1,-1,1,-1,0,1};\nbool vrf;\nvoid sr(int i,int j,char e)\n{\n\tint ii,jj;\n\tfor(int o=0;o<9;o++)\n\t{\n\t\tii=i;\n\t\tjj=j;\n\t\tii+=x[o];\n\t\tjj+=y[o];\n\t\tif((ii>=0)&&(ii<=3)&&(jj>=0)&&(jj<=3))\n\t\t{\n\t\t\tif(m[ii][jj]=='x')\n\t\t\t{\n\t\t\t\tif(m[3][3]=='x')\n\t\t\t\t{\n\t\t\t\t\tcout<=0)&&(ii<=3)&&(jj>=0)&&(jj<=3))\n\t\t\t\t{\n\t\t\t\t\tif(m[ii][jj]=='.')\n\t\t\t\t\t{\n\t\t\t\t\t\tvrf=true;\n\t\t\t\t\t\treturn ;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif(m[ii][jj]=='.')\n\t\t\t\t{\n\t\t\t\t\tii+=x[o];\n\t\t\t\t\tjj+=y[o];\n\t\t\t\t\tif((ii>=0)&&(ii<=3)&&(jj>=0)&&(jj<=3))\n\t\t\t\t\t{\n\t\t\t\t\t\tif(m[ii][jj]=='x')\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tvrf=true;\n\t\t\t\t\t\t\treturn ;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tvrf=false;\n}\n\nint main()\n{\n \tfor(int i=0;i<4;i++)\n \t{\n \t\tfor(int j=0;j<4;j++)\n \t\t{\n \t\t\tcin>>m[i][j];\n \t\t}\n \t}\n \tfor(int i=0;i<4;i++)\n \t{\n \t\tfor(int j=0;j<4;j++)\n \t\t{\n \t\t\tif(m[i][j]=='x')\n \t\t\t{\n \t\t\t\tsr(i,j,'x');\n \t\t\t\tif(vrf==true)\n \t\t\t\t{\n \t\t\t\t\tif(m[3][3]=='x')\n \t\t\t\t\t{\n \t\t\t\t\t\tcout<\nusing namespace std;\n\nint main()\n{\n int c=0,i;\n char a[16];\n for(i=0;i<16;i++)\n cin>>a[i];\n for(i=0;i<16;i++)\n {\n if((a[i]=='x'&&i%4==0)||(a[i]=='x'&&i%4==1))\n {\n if((a[i+1]=='x'&&a[i+2]=='.')||(a[i+2]=='x'&&a[i+1]=='.')||(a[i+4]=='x'&&a[i+8]=='.')||(a[i+8]=='x'&&a[i+4]=='.')||(a[i-3]=='x'&&a[i-6]=='.')||(a[i-3]=='.'&&a[i-6]=='x'))\n {c=1;\n break;}\n }\n else if((a[i]=='.'&&i%4==0)||(a[i]=='.'&&i%4==1))\n {\n if((a[i+1]=='x'&&a[i+2]=='x')||(a[i+8]=='x'&&a[i+4]=='x')||(a[i+5]=='x'&&a[i+10]=='x')||(a[i-3]=='x'&&a[i-6]=='x'))\n {\n c=1;\n break;}\n }\n }\n\n if(c==1)\n cout<<\"YES\";\n else\n cout<<\"NO\";\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6bb54c1e593cbd22fcabf282ed35ed78", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n\nint main(){\n\tstring s[4];\n\tfor (int i = 0; i < 4; ++i)\n\t{\n\t\tcin>>s[i];\n\t}\n\tfor (int i = 0; i < 4; ++i)\n\t{\n\t\tif (s[i][1] != 'o' and s[i][2] != 'o')\n\t\t{\n\t\t\tint c=0;\n\t\t\tfor (int j = 0; j < 4; ++j)\n\t\t\t{\n\t\t\t\tif (s[i][j] == '.')\n\t\t\t\t{\n\t\t\t\t\tc++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (c == 1)\n\t\t\t{\n\t\t\t\tcout<<\"YES\"<\n#include\n\n\nint main () {\n\tint sum = 0 ; \n\tchar pole [5][5] ;\n\tfor ( int i = 1 ;i<=4;i++) {\n\t\tfor ( int j = 1 ; j<=5;j++){\n\t\t\tscanf(\"%c\",&pole[i][j]);\n\t\t}\n\t}\n\tfor ( int i = 1 ;i<=4;i++) {\n\t\tfor ( int j = 1 ; j<=2;j++){\n\t\t\tsum = pole [i][j] + pole [i][j+1] + pole [i][j+2];\n\t\t\tif ( sum ==286 ){\n\t\t\t\tprintf (\"%d \",sum);\n\t\t\t\tgetch() ;\n\t\t\t\tprintf (\"YES\");\n\t\t\t\tgoto end ;\n\t\t\t}\n\t\t\tsum = 0 ;\n\t\t}\n\t}\n\tfor ( int i = 1 ;i<=2;i++) {\n\t\tfor ( int j = 1 ; j<=4;j++){\n\t\t//\tprintf(\"%d %d %d\",pole[i][j],pole[i+1][j],pole[i+2][j]);\n\t\t\tsum = pole[i][j] + pole[i+1][j] + pole[i+2][j];\n\t\t\tif ( sum ==286 ){\n\t\t\t\tprintf (\"YES\");\n\t\t\t\tgoto end ;\n\t\t\t}\n\t\t\tsum = 0 ;\n\t\t}\n\t}\n\tprintf (\"NO\");\n\tend :\n\treturn 0 ;\n\t\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fc8cd315c73f77f8bbe2d08ea310e13d", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "/*\n *\n ********************************************************************************************\n * AUTHOR : Vijju123 *\n * Language: C++14 *\n * Purpose: - *\n * IDE used: Codechef IDE. *\n ********************************************************************************************\n *\n Comments will be included in practice problems if it helps ^^\n */\n\n\n\n#include \n#include\nusing namespace std;\n\nint possible(int x,int arr[])\n{\n int counter=0;\n for(int i=1;i<=100;i++)\n {\n counter+=arr[i]/x;\n }\n return counter;\n}\n\nint main() {\n\t// your code goes here\n\t#ifdef JUDGE\n freopen(\"input.txt\", \"rt\", stdin);\n freopen(\"output.txt\", \"wt\", stdout);\n #endif\n\tios_base::sync_with_stdio(0);\n\tcin.tie(NULL);\n\tcout.tie(NULL);\n\tint n,m,i;\n\tcin>>n>>m;\n\tint arr[m],freq[101]={0};\n\tfor(i=0;i>arr[i];\n\t freq[arr[i]]++;\n\t}\n\t\n\tint low=0,high=m/n;\n\tint ans=0;\n\twhile(low<=high)\n\t{\n\t int mid=(low+high)>>1;\n\t if(possible(mid,freq)>=n)\n\t {\n\t ans=max(ans,mid);\n\t low=mid+1;\n\t }\n\t else\n\t high=mid-1;\n\t}\n\tcout<\n#define ll long long int\n#define vi vector\n#define vll vector\n#define vvi vector < vi >\n#define pii pair\n#define pll pair\n#define mod 1000000007\n#define inf 1000000000000000001;\n#define all(c) c.begin(),c.end()\n#define mp make_pair\n#define pb push_back\n#define mem(a,val) memset(a,val,sizeof(a))\n#define eb emplace_back\n#define rep(i,a,b) for(int i=a;i>n>>m;\n int a[n+5];\n mapmp;\n map::iterator it;\n for(int i=0;i>a[i];\n mp[a[i]]++;\n }\n\n if(msecond)/mid;\n }\n // cout<n){\n ans=mid;\n l=mid+1;\n }\n else if(k\n#include\n#include\nusing namespace std;\n\nint N, M;\n\nint a[110];\nint b[110];\nint c[110];\nint x[100000000];\nint main()\n{\n\n\tcin >> N >> M;\n\n\tfor (int i = 1; i <= M; ++i)\n\t{\n\t\tint x;\n\t\tcin >> x;\n\n\t\ta[x]++;\n\t}\n\n\tfor (int i = 1; i <= 100; ++i)\n\t\tc[i] = a[i];\n\n\n\n\tint mn = 1 << 30;\n\tfor (int i = 1; i <= N; ++i)\n\t{\n\t\tint pos;\n\t\tint mx = 0;\n\t\tfor (int j = 1; j <= 100; ++j)\n\t\t{\n\t\t\tif (a[j] > mx)\n\t\t\t{\n\t\t\t\tmx = a[j];\n\t\t\t\tpos = j;\n\t\t\t}\n\t\t}\n\t\tb[pos]++;\n\n\t\tmn = min(mn, c[pos] / b[pos]);\n\n\t\ta[pos] = c[pos] / (b[pos] + 1);\n\t}\n\n\tcout << mn;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a8381b5fe29ac5b80480bf12f155d29a", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe", "difficulty": 1200.0} {"lang": "Clang++17 Diagnostics", "source_code": "#include \n\nusing namespace std;\n\nint main() {\n unsigned n, m;\n cin>>n>>m;\n map v;\n unsigned x;\n for(unsigned i = 0; i < m; i++) {\n cin>>x;\n if(v.find(x) == v.end()){\n v[x] = 1;\n }else {\n v[x]++;\n }\n }\n \n vector F(v.size(), 0);\n \n for(auto i : v) {\n unsigned value = i.second;\n for(unsigned k = n; k >= 1; k--) {\n F[k] = max(value / k, F[k]);\n for(unsigned j = 1; j < k; j++) {\n\tunsigned tmp = min(value / j, F[k-j]);\n\tF[k] = max(F[k], tmp);\n }\n }\n }\n\n cout< > F(s.size(), vector(n+1, 0)); \n\n for(int i = 0; i < s.size(); i++) {\n unsigned value = get<1>(s[i]);\n for(int k = 1; k <= n; k++) {\n F[i][k] = value / k;\n }\n }\n for(int i = 1; i < s.size(); i++) {\n unsigned value = get<1>(s[i]);\n for(int k = 1; k <= n; k++){\n F[i][k] = max(F[i-1][k], F[i][k]);\n for(int j = 1; j < k; j++) {\n\tF[i][k] = max(F[i][k], min(F[i-1][k-j], value / j));\n }\n }\n }\n cout<< F[s.size()-1][n]<\r\nusing namespace std;\r\nint main(){\r\n\tint x;\r\n cin>>x;\r\n cout<<2-x*x;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "472d47210ab368532883b54ef73c6c7a", "src_uid": "f76005f888df46dac38b0f159ca04d5f", "difficulty": 2200.0} {"lang": "GNU C++20 (64)", "source_code": "#include \r\nusing namespace std;\r\n\r\nvoid solve() {\r\n int n;\r\n cin>>n;\r\n string s;\r\n cin>>s;\r\n int flag=0;\r\n for(int i=0;i> t;\r\n cout<<2-t*t<\r\nusing namespace std;\r\n \r\nint main()\r\n{\r\n int n;\r\n cin>>n;\r\n cout<<(2-(n*n))<\r\nusing namespace std;\r\nint main(){\r\n\tint x;\r\n\tcin >> x;\r\n\tcout << 2 - x * x << endl;\r\n\treturn 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6d8faf7abe6da510b2ec3ac7d1829b6b", "src_uid": "f76005f888df46dac38b0f159ca04d5f", "difficulty": 2200.0} {"lang": "GNU C++14", "source_code": "// qdd on Apr 12, 2018\n\n#include \nusing namespace std;\n\nconst int MOD = 1e9 + 7;\n\nlong long powMod(long long a, long long b)\n{\n\tlong long sum = 1;\n\twhile (b)\n {\n\t\tif (b & 1)\n {\n\t\t\tsum = (sum * a) % MOD;\n\t\t\tb--;\n\t\t}\n\t\tb /= 2;\n\t\ta = a * a % MOD;\n\t}\n\treturn sum;\n}\n\nint inv(int a)\n{\n return a == 1 ? 1 : (long long)(MOD - MOD / a) * inv(MOD % a) % MOD;\n}\n\nlong long C(long long n, long long m)\n{\n if(m < 0)return 0;\n if(n < m)return 0;\n if(m > n-m) m = n-m;\n long long up = 1, down = 1;\n for (long long i = 0 ; i < m ; i ++)\n {\n up = up * (n-i) % MOD;\n down = down * (i+1) % MOD;\n }\n return up * inv(down) % MOD;\n}\n\nint main()\n{\n int n;\n cin >> n;\n long long ans = powMod(3, 3 * n);\n long long ans1 = 0;\n for (int i = 0; i <= n; i++)\n {\n ans1 += C(n, i) * powMod(6, n - i) % MOD;\n }\n printf(\"%lld\\n\", ((ans - ans1) % MOD + MOD) % MOD);\n return 0;\n}\n\n \t \t \t\t \t \t \t \t\t \t \t\t \t", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8b1505d53165e8e270c9f07bad7b9379", "src_uid": "eae87ec16c284f324d86b7e65fda093c", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef unsigned int uint;\ntypedef long long ll;\ntypedef long double ld;\ntypedef unsigned long long ull;\ntypedef pair ii;\ntypedef vector vi ;\ntypedef vector vll;\ntypedef vector vb;\ntypedef vector vc;\ntypedef vector vs;\ntypedef vector vii;\ntypedef vector vvi;\ntypedef vector vvll;\ntypedef vector vvb;\ntypedef vector vvc;\ntypedef map mii;\ntypedef map msi;\ntypedef map mis;\ntypedef map mss;\ntypedef map mic;\ntypedef map mci;\n\n#define sc(x) scanf(\"%d\",&x)\n#define scl(x) scanf(\"%lld\",&x)\n#define all(v) v.begin(),v.end()\n#define mem(arr,val) memset(arr,val,sizeof arr)\n#define sz(v) (int)v.size()\n#define rsz(v) v.resize\n#define clr(v) v.clear()\n#define rev(v) reverse(all(v))\n#define lop(i,n) for(int i=0; i=0; i--)\n#define loop(i,start,n) for(int i=start; i=end; i--)\n#define PB push_back\n#define pb pop_back\n#define mP make_pair\n#define f first\n#define s second\n#define ord0(s) (int)(s-'0')\n#define orda(s) (int)(s-'a')\n#define ordA(s) (int)(s-'A')\n\n\nconst ll OO = (ll)1e18+9;\nconst ll MOD = 1000000007;\nconst int oo = 2147483647;\nconst double EPS = 1e-9;\nconst double PI=acos(-1.0);\n\n//enum dir { u, r, d, l };\nint dx[] = { -1, 0, 1, 0 };\nint dy[] = { 0, 1, 0, -1 };\n\n//enum diR { d, r, u, l , dr, ur, dl, ul };\nint dX[] = { 1, 0, -1, 0, 1, -1, 1, -1 };\nint dY[] = { 0, 1, 0, -1, 1, 1, -1, -1 };\n\nchar letters[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};\n\nint dot(int x, int y, int x2, int y2) {return x * x2 + y * y2; }\nll gcd (ll x, ll y){ return !y ? x : gcd(y, x%y); }\nll lcm (ll a, ll b) { return a * (b / gcd(a, b)); }\nint ord(int r,int c,int nCol) { return (nCol*r) + c + 1; } //transform from 2-D matrix to 1-D array. (Zero-indexed)\n//Compare Double Numbers\nint cmpDouble(ld d1,ld d2){ return fabs(d1-d2)<=EPS?0:d1>d2?1:-1; }\n\nbool isPrime(ll num){\n\tif(num == 2) return true;\n\tif(num < 2 || !(num % 2)) return false;\n\t\n\tfor(int i=3; i*i<=num; i++) if(!(num%i))return false;\n\treturn true;\n}\n\nll _sieve_size, cnt=0;\nbitset<10000010> bs;\n\nll sieve(ll upperbound) {\n\t_sieve_size = upperbound + 1;\n\tbs.set();\n\tbs[0] = bs[1] = 0;\n\tfor (ll i = 2; i <= _sieve_size; i++) if (bs[i]) {\n\t\tfor (ll j = i * i; j <= _sieve_size; j += i) bs[j] = 0;\n\t\tcnt++; if(cnt == 10001) return i;\n\t} \n\treturn 0;\n}\n\nvector> graph(110);\nvvb vis(110,vb(110,false));\nvoid dfs(int node, int color){\n\tvis[node][color]=1;\n\tlop(i,sz(graph[node])) if(color == graph[node][i].s && !vis[graph[node][i].f][graph[node][i].s]) dfs(graph[node][i].f, color);\n}\n\nll calcPow(ll n, ll p){\n\tif(!p) return 1;\n\tll ret = 1;\n\tfor(ll i=1; i<=p; i++) ret*=n, ret%=MOD;\n\treturn ret;\n}\n\n\nint main()\n{\n\t//\n\tll n,ans=0;\n\tcin>>n;\n\tloop(i,1,n+1){\n\t\tans += 20 * calcPow(27,n-i) * calcPow(7,i-1);\n\t\tans %= MOD;\n\t}\n\tcout<\n#include \nusing namespace std;\n\nlong long modulo(int base,int exponent,int modwhat){//base^exponent mod modwhat;\n long long a = 1;\n for(int i=0;i> n;\n long long sum = 0;\n for(int i=0;i\n#include \nconst long long r = 1000000007;\n\nvoid main() {\n\tlong long n, i, s, t, u;\n\tscanf_s(\"%I64d\", &n);\n\tt = 1;\n\tu = 1;\n\tfor (i = 1; i <= n; i++) {\n\t\tt = (t * 27) % r;\n\t\tu = (u * 7) % r;\n\t}\n\ts = (t - u + r) % r;\n\tprintf(\"%I64d\", s);\n\t_getch();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d646d1cab3739a772bd9f52d8b170b5e", "src_uid": "eae87ec16c284f324d86b7e65fda093c", "difficulty": 1500.0} {"lang": "GNU C++11", "source_code": "#include\nconst int N=105;\nint q,n,k,i,j,way[N][N*N],tp[N][N*N],l,r,a[N],xb;\nint main(){\n\tway[1][0]=-1;\n\tfor(i=2;i<=100;++i)for(k=i;k<=i*(i+1)/2;++k){\n\t\tfor(j=2;j<=i;++j)if(k>=j*(j+1)/2-1 && way[i-j+1][k-j*(j+1)/2+1]){\n\t\t\tway[i][k]=j,tp[i][k]=1;\n\t\t}\n\t\tfor(j=4;j<=i;++j)if(way[i-j+1][k-j])\n\t\t\tway[i][k]=j,tp[i][k]=2;\n\t}\n\tfor(scanf(\"%d\",&q);q--;){\n\t\tscanf(\"%d%d\",&n,&k);--k;\n\t\tif(!way[n][k]){puts(\"NO\");continue;}\n\t\tputs(\"YES\");\n\t\tbool rev=0;\n\t\tl=1;r=n;\n\t\tfor(;l=r-j+2;--i)printf(\"%d \",i);r=i;}\n\t\t\t\t\telse{for(i=l;i<=l+j-2;++i)printf(\"%d \",i);l=i;}\n\t\t\t\trev^=1;k-=j*(j+1)/2-1;\n\t\t\t}else{\n\t\t\t\txb=0;\n\t\t\t\tfor(i=l+1;i<=l+j-1;i+=2)a[++xb]=i;for(i=l;i<=l+j-1;i+=2)a[++xb]=i;\n\t\t\t\tif(j&1)a[j/2]=r-1,a[j-1]=r,r-=2,l+=j-3;\n\t\t\t\t\telse a[j/2]=r--,l+=j-2;\n\t\t\t\tfor(i=1;i\n#define rep(i,a,b) for(int i=(a);i<=(b);i++)\n#define per(i,a,b) for(int i=(a);i>=(b);i--)\n#define REP(i,n) for(int i=(0);i<(n);i++)\n#define fi first\n#define se second\n#define pb push_back\n#define mp make_pair\nusing namespace std;\ntypedef pair pii;\ntypedef vector vi;\ntypedef long long ll;\n\ntemplate inline void read(T &x){\n\tint f=0;x=0;char ch=getchar();\n\tfor(;!isdigit(ch);ch=getchar())f|=(ch=='-');\n\tfor(;isdigit(ch);ch=getchar())x=x*10+ch-'0';\n\tif(f)x=-x;\n}\n\nconst int n=100;\nvi f[n+1][n*n/2],g[n+1];\n\nint main(){\n\trep(i,4,n){\n\t\trep(j,1,i) if(j%2==0) g[i].pb(j);\n\t\trep(j,1,i) if(j%2==1) g[i].pb(j);\n\t\tif(i&1) swap(g[i][i-2],g[i][i-1]);\n\t}\n\tf[1][1]={1},f[2][3]={1,2};\n\trep(i,1,n) rep(j,1,i*(i+1)/2){\n\t\tif(f[i][j].empty()) continue;\n\t\trep(k,2,n-i+1){\n\t\t\tauto &r=f[i+k-1][j+k*(k+1)/2-1];\n\t\t\tif(!r.empty()) continue;\n\t\t\tr=f[i][j];\n\t\t\tif(r.back()==i) reverse(r.begin(),r.end());\n\t\t\trep(p,1,k-1) r.pb(i+p);\n\t\t}\n\t\trep(k,4,n-i+1){\n\t\t\tauto &r=f[i+k-1][j+k];\n\t\t\tif(!r.empty()) continue;\n\t\t\tfor(auto p:g[k]){\n\t\t\t\tif(p==1) r.insert(r.end(),f[i][j].begin(),f[i][j].end());\n\t\t\t\telse r.pb(i+p-1);\n\t\t\t}\n\t\t}\n\t}\n\tint Q; read(Q);\n\twhile(Q--){\n\t\tint n,k;\n\t\tread(n),read(k);\n\t\tif(f[n][k].empty()){\n\t\t\tputs(\"NO\");\n\t\t\tcontinue;\n\t\t}\n\t\tputs(\"YES\");\n\t\tfor(auto x:f[n][k]) printf(\"%d \",x);\n\t\tputs(\"\");\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2428b03fcc37207636b6f24e851fa42b", "src_uid": "23227ee76104780e16f366188938bca2", "difficulty": 3400.0} {"lang": "GNU C++17", "source_code": "#include \n#define ll long long\n#define maxn 100005 /*rem*/\n#define mod 998244353\n#define db double\n#define vi vector\n#define pb push_back\nusing namespace std;\nvi ca[105][105]; // i\u4e2a\u6570\u5206\u6210j\u6bb5\uff0c\u603b\u8d21\u732e\u4e3ak\uff0c\u7b2c\u4e00\u6bb5\u5927\u5c0f + \u8d21\u732e * 1024 *j = 1 \u6700\u540e\u66f4\u65b0* \nint dp[105][6000]; // i\u4e2a\u6570\u603b\u8d21\u732e\u4e3ak\uff0c\u603b\u6bb5\u6570 + 1024 * \u5408\u70b9 \nint cal(int x) {\n\treturn x * (x - 1) / 2;\n}\nint r[105];\nvoid work(int L, int R, int k, int bg, int tp) {\n\tif (L == R) {\n\t\tr[L] = bg;\n\t\treturn;\n\t}\n\n\tint n = R - L + 1;\n\tint l = dp[n][k] % 1024;\t\n\tvi ns(l), res(l);\n\tint rtp = dp[n][k] & 1024; \n\tif (rtp) k -= cal(l);\n\telse k--;\n\tint fk = k;\n\tfor (int j = 0; j < l; j++)\n\t\tns[j] = ca[n][l - j][k] % 1024,\n\t\tres[j] = ca[n][l - j][k] / 1024, \n\t\tn -= ns[j], \n\t\tk -= res[j];\n\t/*\n\tcout << \"W\" << L << ' ' << R << ' ' << fk << ' ' << bg << ' ' << tp << ' ' << l << endl;\n\tfor (int j = 0; j < l; j++)\n\t\tcout << ns[j] << ' ';\n\tcout << endl;\n\tsystem(\"pause\");\n\t*/\n\tif (rtp) {\n\t\tif (tp)\n\t\t\tfor (int j = 0; j < l; j++)\t\n\t\t\t\twork(L, L + ns[j] - 1, res[j], bg, tp ^ 1), \n\t\t\t\tL += ns[j], bg += ns[j];\n\t\telse \n\t\t\tfor (int j = l - 1; j >= 0; j--)\n\t\t\t\twork(R - ns[j] + 1, R, res[j], bg, tp ^ 1), \n\t\t\t\tR -= ns[j], bg += ns[j];\n\t}\n\telse {\n\t\tvi p(l), q(l);\n\t\tint k = l / 2;\n\t\tif (l % 2 == 0) {\n\t\t\tfor (int j = 0; j < k; j++)\n\t\t\t\tp[j] = 2 * j + 1, \n\t\t\t\tp[j + k] = 2 * j;\n\t\t}\n\t\telse {\n\t\t\tfor (int j = 0; j < k; j++)\n\t\t\t\tp[j] = 2 * j + 1, \n\t\t\t\tp[j + k] = 2 * j;\n\t\t\tp[2 * k] = 2 * k;\n\t\t\tswap(p[l - 1], p[l - 2]);\n\t\t}\n\t\tfor (int i = 0; i < l; i++) {\n\t\t\tint nl = L;\n\t\t\tfor (int j = 0; j < l; j++) {\n\t\t\t\tif (p[j] == i) {\n\t\t\t\t\twork(nl, nl + ns[j] - 1, res[j], bg, tp);\n\t\t\t\t\tbg += ns[j];\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tnl += ns[j];\n\t\t\t}\n\t\t}\n\t}\n}\nint main() {\n\tfor (int i = 1; i < 101; i++) {\n\t\tfor (int j = 1; j <= i; j++) {\n\t\t\tca[i][j].resize(j + cal(i + 2 - j));\n\t\t\tif (i == 1 && j == 1) ca[1][1][1] = 1025, dp[1][1] = 1;\n\t\t\telse \n\t\t\t\tif (j >= 2)\n\t\t\t\t\tfor (int l = i; l < ca[i][j].size(); l++)\n\t\t\t\t\t\tfor (int k = 1; k <= i / j; k++) {\n\t\t\t\t\t\t\tif (ca[i][j][l]) break;\n\t\t\t\t\t\t\tint mx1 = cal(k + 1), mx2 = ca[i - k][j - 1].size() - 1;\n\t\t\t\t\t\t\tint du = max(k, l - mx2);\n\t\t\t\t\t\t\tfor (int s = du; s <= mx1; s++)\n\t\t\t\t\t\t\t\tif (dp[k][s] && ca[i - k][j - 1][l - s]) {\n\t\t\t\t\t\t\t\t\tca[i][j][l] = k + s * 1024;\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t}\n\t\tfor (int l = i; l <= cal(i + 1); l++) {\n\t\t\tfor (int m = 2; m <= i; m++) {\n\t\t\t\tint ed = l - cal(m);\n\t\t\t\tif (ca[i][m].size() > ed && ca[i][m][ed]) {\n\t\t\t\t\tdp[i][l] = 1024 + m;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (int m = 4; m <= i; m++) \n\t\t\t\tif (ca[i][m].size() > l - 1 && ca[i][m][l - 1]) {\n\t\t\t\t\tdp[i][l] = m;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\tif (dp[i][l]) ca[i][1][l] = i + l * 1024;\n\t\t}\n\t}\n\tint t;\n\tcin >> t;\n\tfor (int i = 0; i < t; i++) {\n\t\tint n, k;\n\t\tcin >> n >> k;\n\t\tif (!dp[n][k]) cout << \"NO\" << endl;\n\t\telse {\n\t\t\tcout << \"YES\" << endl;\n\t\t\twork(1, n, k, 1, 0);\n\t\t\tfor (int j = 1; j <= n; j++)\n\t\t\t\tprintf(\"%d \", r[j]);\n\t\t\tprintf(\"\\n\");\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1c2fdd112fee3475cfb01a12730edb90", "src_uid": "23227ee76104780e16f366188938bca2", "difficulty": 3400.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#define meow(args...) fprintf(stderr, args)\ntemplate inline bool cmin(T1 &a, const T2 &b) {return b inline bool cmax(T1 &a, const T2 &b) {return a xi, he;\nstd::pair g[101][4591];\nvoid extract(int n, int k) {\n\tif(k==0) return;\n\the.push_back(f[n][k]);\n\textract(n-f[n][k]+1, k-f[n][k]*(f[n][k]-1)/2);\n}\nvoid answer(int n) {\n\tint ans[101], *pos=ans, l=1, r=n, side=0;\n\tfor(; !xi.empty(); xi.pop_back()) {\n\t\tint d=xi.back();\n\t\tif(d%2) {\n\t\t\tfor(int i=1; i\n#define fi first\n#define se second\n#define vi vector;\nusing namespace std;\n\nint main(){\n\tios_base::sync_with_stdio(0);\n\tcin.tie(); cout.tie();\n\tint n; cin>>n;\n\tstring s; cin>>s;\n\tstring tmps=\"\";\n\tint div=2;\n\twhile(n % div != 0) div++;\n\tstring news;\n\twhile(div<=n){\n\t\tfor (int i=div-1; i>=0; i--){\n\t\t\ttmps+=s[i];\n\t\t}\n\t\ts=tmps+s.substr(div,n-div);\n\t\t//cout<\nusing namespace std;\nint main() {\n\n char ch[200],s;\n int n,arr[100],m=0;\n cin>>n;\n cin>>ch;\n for(int i=2; i<=(n+1)/2; i++) {\n if(n%i==0)\n arr[m++]=i;\n }\n\n sort(arr,arr+(m-1));\n int c=m-1;\n\n\n\n for(int i=0;i<=c;i++)\n {\n for(int j=0;j\n\nusing namespace std;\n\nint main()\n{\n int n, i, j, k, num;\n char tem;\n cin >> n;\n string ch;\n cin >> ch;\n vector vec;\n num = n;\n do\n {\n vec.push_back(n);\n n /= 2;\n\n }while(n != 1);\n\n if(vec[vec.size()-1] != 2 && num != 3 )\n {\n vec.push_back(2);\n }\n\n /*for(i = vec.size()-1; i >= 0; i--)\n {\n cout<= 0; i--)\n {\n k = vec[i] - 1;\n for(j = 0; j < vec[i] / 2; j++)\n {\n tem = ch[j];\n ch[j] = ch[k];\n ch[k] = tem;\n k--;\n }\n }\n cout<\n#include\n#include\n#include\nusing namespace std;\n\nstring reversee(string b){\n\tint mis=b.length()/2;\n\tfor(int i=0;i div(n);\n fill(div.begin(), div.end(), 0);\n cin>>n;\n cin>>s;\n int gh=0;\n for(int i=2;i<=n;i++){\n if(n%i==0){\n \t//cout<\nusing namespace std;\n//typedefs\n/*\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair pii;\ntypedef pair piii;\ntypedef vector vi;\ntypedef vector vl;\ntypedef pair pll;\nconst double PI = acos(-1);\n*/\n//typedefs\n#define ll long long\n#define ull unsigned long long\n#define pii pair \n#define piii pair \n#define vi vector \n#define vl vector \n#define pll pair \n#define PI acos(-1)\n//defines\n#define MP make_pair\n#define PB push_back\n#define F first\n#define S second\n#define mem(a, b) memset(a, b, sizeof(a))\n#define gcd(a,b) __gcd(a,b)\n#define lcm(a,b) (a*(b/gcd(a,b)))\n#define SQR(a) ((a)*(a))\n#define inf 100000000\n#define mod 1000000007\n#define mod1 1000000007\n#define mod2 1000000009\n#define b1 43\n#define b2 41\n#define EPS 1e-9\n//define harmonic(n) 0.57721566490153286l+log(n)\n#define nl puts(\"\")\n#define odd(n) ((n)&1)\n#define even(n) (!((n)&1))\n#define vsort(v) sort(v.begin(), v.end())\n#define lc (node<<1)\n#define rc ((node<<1)|1)\n#define ran(a, b) ((((rand() << 15) ^ rand()) % ((b) - (a) + 1)) + (a))\n//loop\n#define rep(i, n) for(int i = 0; i < n; ++i)\n#define REP(i, n) for(int i = 1; i <= n; ++i)\n//input\n#define si(a) scanf(\"%d\", &a)\n#define sii(a, b) scanf(\"%d%d\", &a, &b)\n#define siii(a, b, c) scanf(\"%d%d%d\", &a, &b, &c)\n#define sl(a) scanf(\"%lld\", &a)\n#define sll(a, b) scanf(\"%lld%lld\", &a, &b)\n#define slll(a, b, c) scanf(\"%lld%lld%lld\", &a, &b, &c)\n#define sd(a) scanf(\"%lf\", &a)\n#define sc(a) scanf(\"%c\", &a)\n#define sst(a) scanf(\"%s\", a)\ninline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }\n//debug\n#ifdef kfoozminus\n\ntemplate < typename F, typename S >\nostream& operator << ( ostream& os, const pair< F, S > & p ) {\n\treturn os << \"(\" << p.first << \", \" << p.second << \")\";\n}\n\ntemplate < typename T >\nostream &operator << ( ostream & os, const vector< T > &v ) {\n\tos << \"{\";\n\tfor(auto it = v.begin(); it != v.end(); ++it) {\n\t\tif( it != v.begin() ) os << \", \";\n\t\tos << *it;\n\t}\n return os << \"}\";\n}\n\ntemplate < typename T >\nostream &operator << ( ostream & os, const set< T > &v ) {\n\tos << \"[\";\n\tfor(auto it = v.begin(); it != v.end(); ++it) {\n\t\tif( it != v.begin()) os << \", \";\n\t\tos << *it;\n\t}\n return os << \"]\";\n}\n\ntemplate < typename F, typename S >\nostream &operator << ( ostream & os, const map< F, S > &v ) {\n\tos << \"[\";\n\tfor(auto it = v.begin(); it != v.end(); ++it) {\n\t\tif( it != v.begin() ) os << \", \";\n\t\tos << it -> first << \" = \" << it -> second ;\n\t}\n return os << \"]\";\n}\n\n#define dbg(args...) do {cerr << #args << \" : \"; faltu(args); } while(0)\n\nclock_t tStart = clock();\n#define timeStamp dbg(\"Execution Time: \", (double)(clock() - tStart)/CLOCKS_PER_SEC)\n\nvoid faltu () { cerr << endl; }\n\ntemplate \nvoid faltu( T a[], int n ) {\n\tfor(int i = 0; i < n; ++i) cerr << a[i] << ' ';\n\tcerr << endl;\n}\n\ntemplate \nvoid faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }\n\n#else\n#define dbg(args...)\n#endif\n/*\nll add(ll a, ll b) {\n\tll ret = a+b;\n\tif(ret >= mod) ret -= mod;\n\treturn ret;\n}\n\nll subtract(ll a, ll b) {\n\tll ret = a-b;\n\tif(ret < 0) ret += mod;\n\treturn ret;\n}\n\nll mult(ll a, ll b) {\n\tll ret = a*b;\n\tif(ret >= mod) ret %= mod;\n\treturn ret;\n}\n\nll bigmod(ll a, ll b) {\n\tll ret = 1;\n\twhile(b) {\n\t\tif(b&1) ret = mult(ret, a);\n\t\tb >>= 1; a = mult(a, a);\n\t}\n\treturn ret;\n}\n*/\n\n//ll inverse(ll n) { return bigmod(n, mod-2); }\n\n/*\n#define PMX 1000000\n\nint marked[PMX/64 + 2];\nvi primes;\n\n#define mark(x) marked[x >> 6] |= (1 << ((x & 63) >> 1))\n#define check(x) (marked[x >> 6] & (1 << ((x & 63) >> 1)))\n\nbool isPrime(int x)\n{\n\treturn (x > 1) && ((x == 2) || ((x & 1) && (!(check(x)))));\n}\n\nvoid seive(int n)\n{\n\tint i, j;\n\tfor(i = 3; i * i <= n; i += 2) if(!check(i)) for(j = i * i; j <= n; j += i << 1) mark(j);\n\tprimes.PB(2);\n\tfor(i = 3; i <= n; i += 2) if(isPrime(i)) primes.PB(i);\n}\n*/\n\n//Direction Array \n//int fx[]={1, -1, 0, 0}; int fy[]={0, 0, 1, -1};\n//int fx[]={0, 0, 1, -1, -1, 1, -1, 1}; int fy[]={-1, 1, 0, 0, 1, 1, -1, -1};\n\n//bit manipulation\n/*\nbool checkBit(int n, int i) { return (n&(1<> 1;\n\tfor(mid = 1; mid <= mx; mid ++) {\n\t\tint ans = 0;\n\t\tfor(d = mid, i = 0; i < n; ) {\n\t\t\tif(a[i] > d) {\n\t\t\t\td += mid;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tans += d - a[i];\n\t\t\ti ++;\n\t\t}\n\t\tif(vis[mid] == 1) dbg(1);\n\t\tdbg(mid, ans);\n\t}*/\n\n\tsum += k;\n\tll d;\n\n\tfor(i = n; i <= n * n; i ++) {\n\t\tdbg(i);\n\t\td = sum / i;\n\t\tint cnt = 0;\n\t\tfor(j = 0; j < n; j ++) {\n\t\t\tcnt += (a[j] + d - 1)/d;\n\t\t}\n\t\tdbg(i, cnt);\n\t\tif(cnt <= i) break;\n\t}\n\tprintf(\"%lld\\n\", d);\n\n//\ttimeStamp;\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b10978da618ec76c97cdb26304117404", "src_uid": "2e1ab01d4d4440f33c840c4564a20a60", "difficulty": 2300.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#ifndef WIN32\n#define Auto \"%lld\"\n#else\n#define Auto \"%I64d\"\n#endif\nusing namespace std;\ntypedef bool boolean;\n\n#define ll long long\n\nconst int N = 105;\n\nint n;\nll C;\nint ar[N];\n\ninline void init() {\n\tscanf(\"%d\"Auto, &n, &C);\n\tfor (int i = 0; i < n; i++)\n\t\tscanf(\"%d\", ar + i), C += ar[i];\n}\n\nint ceil(int a, int b) {\n\treturn (a + b - 1) / b;\n}\n\ninline void solve() {\n\tint dcur = C / n, dans;\n\tdo {\n\t\tswap(dcur, dans), dcur = 0;\n\t\tfor (int i = 0; i < n; i++)\n\t\t\tdcur += ceil(ar[i], dans);\n\t\tdcur = C / dcur;\n\t} while (dcur != dans);\n\tprintf(\"%d\\n\", dans);\n}\n\nint main() {\n\tinit();\n\tsolve();\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "661c7cc2488d5d4d4f3704dac5db01d5", "src_uid": "2e1ab01d4d4440f33c840c4564a20a60", "difficulty": 2300.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\ntypedef long long ll;\nint n;\nll a[105],k;\nll calc(ll x){\n ll ret=0;\n for(int i=0;ik)return 1;\n while(dv;\nint main()\n{\n cin>>n>>k;\n for(int i=0;i>a[i];\n sort(a,a+n);\n for(int i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nconst int maxn = 1e2 + 5;\nconst int maxm = 2e6 + 5;\n\nint n;\nlong long k;\nint a[maxn];\nint seg[maxm];\nint cnt;\n\nint main(int argc, char const *argv[]) {\n\n cin >> n >> k;\n\n seg[cnt ++] = 1;\n for (int i = 1; i <= n; i ++) {\n cin >> a[i];\n for (long long j = 1; j * j <= a[i]; j ++)\n seg[cnt ++] = j, seg[cnt ++] = ceil(a[i] / (1.0 * j));\n k += 1ll * a[i];\n }\n seg[cnt ++] = 0x3f3f3f3f;\n\n sort(seg, seg + cnt);\n cnt = unique(seg, seg + cnt) - seg;\n\n long long ans = 0;\n for (int i = 0; i < cnt; i ++) {\n int b = seg[i];\n long long sum = 0;\n for (int j = 1; j <= n; j ++)\n sum += ceil(a[j] / (1.0 * b));\n long long d = k / sum;\n if (b <= d)\n ans = max(ans, d);\n }\n\n cout << ans << endl;\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "66fd8a56a8db0a20f58227c73bdeb79d", "src_uid": "2e1ab01d4d4440f33c840c4564a20a60", "difficulty": 2300.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#define Max 100005\n\nusing namespace std;\n\nint dp[Max];\n\nint check(int n)\n{\n\tint i, t, j, dt, ans, t2, w, k;\n\n\tif(dp[n] != -1)\n\t\treturn dp[n];\n\n\tt = sqrt(2*n);\n\n\tans = n+1;\n\tfor(i=2;i<=t;i++)\n\t{\n\t\tif(2*n % i == 0)\n\t\t{\n\t\t\tdt = i;\n\t\t\tif((2*n/dt - dt + 1) % 2 == 0)\n\t\t\t{\n\n\t\t\t\tt2 = (2*n / dt - dt + 1)/2;\n\n\t\t\t\tif(t2 > 0)\n\t\t\t\t{\n\t\t\t\t\tw = 0;\n\t\t\t\t\tfor(j=t2, k=0;k 0)\n\t\t\t\t{\n\t\t\t\t\tw = 0;\n\t\t\t\t\tfor(j=t2, k=0;k> n)\n\t{\n//\t\tint t1 = clock();\n memset(dp, -1, sizeof(dp));\n\t\tt = check(n);\n\n\t\tif(!t)\n\t\t\tprintf(\"-1\\n\");\n\t\telse\n\t\t\tprintf(\"%d\\n\", t);\n\t\t\t\n\t\t//cerr<\n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint s[111111];\nint curgr[111111];\nint egr = 0;\n\nint getGr(int n, int spl) {\n\tif (spl >= n) return 0x7f7f7f7f;\n\n\tn *= 2;\n\tif (n % spl != 0) return 0x7f7f7f7f;\n\tn /= spl;\n\n\tn++;\n\tn -= spl;\n\tif (n % 2 != 0)\n\t\treturn 0x7f7f7f7f;\n\tn /= 2;\n\n\tif (n < 1) {\n\t\treturn 0x7f7f7f7f;\n\t}\n\n\tint res = 0;\n\tfor (int a = n; a<= n+spl - 1; a++) {\n\t\tres += s[a];\n\t}\n\n\treturn (res + 1) % 2;\n}\n\nint main() {\n\tint n; cin >> n;\n\n\ts[1] = 0;\n\ts[2] = 0;\n\ts[3] = 1;\n\n\tif (n <= 3) {\n\t\tif (s[n] == 1)\n\t\t\tcout << 2 << endl;\n\t\telse cout << -1 << endl;\n\t\treturn 0;\n\t}\n\n\tfor (int i=4; i<=100000; i++) {\n\t\tint egr = 0;\n\t\tfor (int spl = 2; spl < 888; spl++) {\n\t\t\tint gr = getGr(i, spl);\n\t\t\tcurgr[egr++] = gr;\n\n\t\t\tif (i == n && gr != 0 && gr != 0x7f7f7f7f) {\n\t\t\t\tcout << spl << endl;\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\tif (gr != 0 && gr != 0x7f7f7f7f)\n\t\t\t\ts[i] = 1;\n\t\t}\n\n\t\tif (i == n) {\n\t\t\tcout << -1 << endl;\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tcout << -1 << endl;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ee6c66fc9eb964d28a3592436ea8c201", "src_uid": "63262317ba572d78163c91b853c05506", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nint f[100005];\n\nint main() {\n int n;\n cin >> n;\n for (int i=0; i <= 100000; ++i) f[i] = -1;\n for (int i=3; i <= n; ++i) {\n for (int j=2; (j+1)*j/2 <= i; ++j) {\n int k = 1, cnt = 0, sum = (j+1)*j/2;\n for (int k=1; k <= j; ++k) {\n if (f[k] > 0) ++cnt;\n }\n for (k = 1; sum < i; ++k) {\n sum += j;\n if (f[k] > 0) --cnt;\n if (f[k+j] > 0) ++cnt;\n }\n if (sum == i && !(cnt % 2)) {\n f[i] = j;\n break;\n }\n }\n }\n cout << f[n];\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "19de8d2dd8a368f0699a38a2401a88bf", "src_uid": "63262317ba572d78163c91b853c05506", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \nusing namespace std;\n\nconst int maxn = 100001;\nint sg[maxn];\npair next[maxn][320];\nint numNext[maxn];\nint n;\n\nint main() {\n\tscanf(\"%d\",&n);\n\tfill(sg + 1,sg + n + 1,0);\n\tfill(numNext + 1,numNext + n + 1,0);\n\tfor(int i = 1;i<=n;i++) {\n\t\tif(numNext[i]==0)\n\t\t\tsg[i] = 0;\n\t\telse {\n\t\t\tsort(next[i],next[i] + numNext[i]);\n\t\t\tint cur = -1;\n\t\t\tif(next[i][0].first>0)cur = 0;\n\t\t\telse\n\t\t\tfor(int j = 1;j 0 && (sum += j)<=n;j--) {\n\t\t\tx ^= sg[j];\n\t\t\tnext[sum][numNext[sum]].first = x;\n\t\t\tnext[sum][numNext[sum]].second = i - j + 1;\n\t\t\tnumNext[sum]++;\n\t\t}\n\t}\n\tprintf(\"%d\\n\",sg[n] == 0 ? -1 : next[n][0].second);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2ce62d3d78d885da4b67974471053a34", "src_uid": "63262317ba572d78163c91b853c05506", "difficulty": 2000.0} {"lang": "MS C++ 2017", "source_code": "#include \n#include \nusing namespace std;\nint main() {\nstring a; int c;\ncin>>a;\nint sum=0;\nfor (int i=0;ia.size()-sum)\n cout<\n#include \nusing namespace std;\nint main() {\nstring a; int c;\ncin>>a;\nint sum=0;\nfor (int i=0;ia.size()-sum)\n cout<\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n\tstring s;\n\tcin >> s;\n\tint count = 0;\n\tfor (int i = 0; i < s.length(); i++)\n\t{\n\t\tif (s[i] == 'a')\n\t\t{\n\t\t\tcount++;\n\t\t}\n\t}\n\tfor (int i = 0; i < s.length();)\n\t{\n\t\tif (s.size()/2 >= count)\n\t\t{\n\t\t\tif (s[i] != 'a')\n\t\t\t{\n\t\t\t\ts.erase(s.begin()+i);\n\t\t\t}\n\t\t\telse i++;\n\t\t}\n\t\telse break;\n\t}\n\tcout << s.size();\n\t_getch();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "072f9d7f298291156eba131d81e765c2", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\nint main()\n{\n vector vect;\n int count1 =0;\n int count2=0;\n\n for(int i =0 ; i<1000000; i++){\n char c=getchar();\n if(c=='\\n'){\n break;\n }\n vect.push_back(c);\n if(c=='a'){\n count1++;\n }\n if(c=='s'){\n count2++;\n }\n }\n if(count1 > vect.size()/2 || count2 > vect.size()/2){\n cout< vect.size()/2 || count2 > vect.size()/2){\n cout<\nusing namespace std;\n\nint main()\n{\n\tlong long n,k,j;\n\tcin>>n>>k;\n\tj = 1;\n\tif(n==1&&k==1)\n\t{\n\t\tcout<<0;\n\t\treturn 0;\n\t}\n\t\n\tj = 1;\n\twhile(1) {\n\t\tif(k==((j*(j+1))/2)-(n-j)) {\n\t\t\tcout<\n#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)\nusing namespace std;\ntypedef long long int ll;\nint main() {fio; // remove during scanf\n\tll N;\n\tcin >> N;\n\tN++;\n\tfor(int i = 0; i < N; i++) {\n\t\tif(0 == (N ^ (1LL << i))) {\n\t\t\tcout << i << endl;\n\t\t\treturn 0;\n\t\t}\n\t}\n\tcout << N << endl;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0225e832a2f00145d57b7c70d4cd49b9", "src_uid": "236177ff30dafe68295b5d33dc501828", "difficulty": 1000.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n\n int main() {\nlong int n,s;\ncin>>n;\nlong int n1=n+1;\nwhile(n1<9){\n if(n1%2==0){\n s=n1/2;\n} else{\n s=n/2+1;\n}cout<\n#include \n#include \n\nusing namespace std;\nusing namespace __gnu_pbds;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef unsigned int uint;\ntypedef unsigned long long ull;\n\nconst ld pi = 4.0*atanl(1.0);\nconst int iinf = 1e9 + 10;\nconst ll inf = 1e18 + iinf + 10;\nconst int mod = 1000000007;\nconst ld prec = .000001;\n\n#define enld endl\n#define endl '\\n'\n#define pb push_back\n#define debug(x) cout<<#x<<\" -> \"<\nusing indexed_set = tree<\n TIn, null_type, less,\n rb_tree_tag, tree_order_statistics_node_update>;\n\nvoid fast() {\n ios::sync_with_stdio(false);\n cin.tie(NULL); cout.tie(NULL);\n}\n\nvoid file() {\n auto a = freopen(\"a.in\", \"r\", stdin);\n auto b = freopen(\"a.out\", \"w\", stdout);\n if(!a || !b) cout << \"uh oh\" << endl;\n}\n\n\n\n\n\nint main() {\n //file();\n //fast();\n\n ll n;\n cin >> n;\n n++;\n\n for(int i = 0; (1 << i) <= n; i++) {\n if(1 << i == n) {\n cout << i << endl;\n return 0;\n }\n }\n\n cout << n << endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "22f22f11d78eddb5bbf9d8f531bde4f5", "src_uid": "236177ff30dafe68295b5d33dc501828", "difficulty": 1000.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef unsigned long long ull;\n\nconst int MOD=1000*1000*1000+7;\n\nint p[2];\nll dp[1000+1][2];\n\nint main()\n{\n\t#ifndef ONLINE_JUDGE\n\t\tfreopen (\"input.txt\",\"r\",stdin);\n\t\tfreopen (\"output.txt\",\"w\",stdout);\n\t#endif\t\n\tstring s,e;\n\tcin>>s>>e;\n\tint n=s.length();\n\tfor (int i=0;i>k;\n\tfor (int i=1;i<=k;++i)\n\t{\n\t\tdp[i][0]=(dp[i-1][0]*(p[0]-1)+dp[i-1][1]*p[0])%MOD;\n\t\tdp[i][1]=(dp[i-1][0]*p[1]+dp[i-1][1]*(p[1]-1))%MOD;\n\t}\n\tcout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n//#include \n//#include \nusing namespace std;\n\ntypedef long long LL;\ntypedef unsigned int ui;\ntypedef unsigned long long ull;\ntypedef float fl;\ntypedef double ld;\ntypedef pair pii;\n#define ui(n) ((unsigned int)(n))\n#define ll(n) ((long long)(n))\n#define ull(n) ((unsigned long long)(n))\n#define fl(n) ((float)(n))\n#define ld(n) ((double)(n))\n#define char(n) ((char)(n))\n#define Bool(n) ((bool)(n))\n#define fixpoint(n) fixed<=0;i--)\n#define repd1(i,n) for(int i=n;i>=1;i--)\n#define FOR(i,a,n,step) for(int i=a;i9)Write(x/10);putchar(x%10+'0');}\n\ninline LL powmod(LL a,LL b){LL res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}\ninline LL gcdll(LL a,LL b){return b?gcdll(b,a%b):a;}\ninline string itoa(LL a){string res=\"\";while(a>0)res+=(a%10+'0'),a/=10;reverse(All(res));return res==\"\"?\"0\":res;}\ninline LL atoi(string s){LL res=0;repV(i,s)res=res*10+i-'0';return res;}\nconst int dx[]={0,1,0,-1,1,-1,-1,1};\nconst int dy[]={1,0,-1,0,-1,-1,1,1};\n/**************************************************************Begin***************************************************************/\nconst int maxn=1010;\n\nstring a,b;\nLL k,good[maxn],bad[maxn],x,y;\n\nint main()\n{\n\tcin>>a>>b>>k;\n\t\n\trep(i,a.size()) if(a.substr(i)+a.substr(0,i)==b) x++; else y++;\n\t\n\tif(a==b) good[0]=1; else bad[0]=1;\n\trep1(i,k) good[i]=(good[i-1]*(x-1)+bad[i-1]*x)%mod,bad[i]=(bad[i-1]*(y-1)+good[i-1]*y)%mod;\n\t\n\tPF(\"%lld\",good[k]);\n\n\treturn 0;\n}\n/***************************************************************End****************************************************************/\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "942bec339d607bf0bfcc79173888e3e1", "src_uid": "414000abf4345f08ede20798de29b9d4", "difficulty": 1700.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n//conversion\n//------------------------------------------\ninline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}\ntemplate inline string toString(T x) {ostringstream sout;sout< VI;\ntypedef vector VVI;\ntypedef vector VS;\ntypedef pair PII;\ntypedef long long LL;\n\n//container util\n//------------------------------------------\n#define ALL(a) (a).begin(),(a).end()\n#define RALL(a) (a).rbegin(), (a).rend()\n#define PB push_back\n#define MP make_pair\n#define SZ(a) int((a).size())\n#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)\n#define EXIST(s,e) ((s).find(e)!=(s).end())\n#define SORT(c) sort((c).begin(),(c).end())\n\n//repetition\n//------------------------------------------\n#define FOR(i,a,b) for(int i=(a);i<(b);++i)\n#define REP(i,n) FOR(i,0,n)\n\n#define MOD 1000000007\n\nint p,t;\nint s1, s2;\nVI CC;\nint goal;\n\nLL Calc(int pos, int times){\n if(s2 != -1){\n if(times == 1){\n if(pos ==1)return (t/s2-1);\n else return t/s2;\n }else{\n if(pos == 1){\n return (t/s2-1)*Calc(1, times-1)+(t-t/s2)*Calc(0, times-1)%MOD;\n }else{\n return (t/s2)*Calc(1, times-1)+(t-t/s2-1)*Calc(0, times-1)%MOD;\n }\n }\n }\n if(pos == 1){\n if(times == 1)return 0;\n return ((t-1)*Calc(0, times-1))%MOD;\n }else{\n if(times == 1)return 1;\n return ((t-2)*Calc(0, times-1)+Calc(1, times-1))%MOD;\n }\n}\n\nvoid main(int argc, char *argv[]){\n string start, end;\n int k;\n s1 = s2 = -1;\n goal = -1;\n p=0;\n cin >> start >> end >> k;\n t = start.length();\n start += start;\n REP(i, t){\n if(start.substr(i, t) == end){\n if(goal != -1 && s2 == -1){\n s1 = goal;\n s2 = i-goal;\n }\n goal = i;\n }\n }\n if(goal == -1){\n printf(\"0\\n\");\n return;\n }\n if(s2 == -1)printf(\"%I64d\\n\", Calc((goal==0), k)); \n else printf(\"%I64d\\n\", Calc((goal%s2==0), k)); \n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5427d88608d8542ff2ab8030979282af", "src_uid": "414000abf4345f08ede20798de29b9d4", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "//\n// main.cpp\n// D\n//\n// Created by Liza Kondakova on 20.04.12.\n// Copyright (c) 2012 likogra@gmail.com. All rights reserved.\n//\n\n#include \n#include \nusing namespace std;\nint l[4002];\nint posl(string s){\n l[0]=-1;\n for(int k=1;k=0&&s[j+1]!=s[k]) {\n j=l[j];\n }\n //cout<>a>>b;\n string news;\n news=b+b+'$'+a+a;\n int k=posl(a);\n int per=-1;\n if(2*k>=a.size())\n per=(int)a.size()-k;\n int pp=posl(news);\n pp=2*(int)a.size()-pp;\n if(pp>=a.size()){\n cout<<\"0\"< pa;\n int l=pp;\n pa.push_back(l);\n l+=per;\n while (l>k;\n int c[1001][k+1];\n int sum=1;\n c[0][0]=1;\n for(int j=1;j\nusing namespace std;\nint main()\n{\n\t\n\twhile(1)\n\t{\n\t\t\t\n\tstring s;\n\tcin >> s;\n\tlong i,t=0,x=s.size();\n\n\tfor(i=0;i\n#include \n#include \nusing namespace std;\n\nint main()\n{\n\twhile (1)\n\t{\n\t\tstring str;\n\t\tcin >> str;\n\t\tint flag = 0;\n\t\tbool ok = 1;\n\n\t\tfor(int i = 0 ; i < str.length() / 2 + 1; i++)\n\t\t{\n\t\t\tif (str[i] != str[str.length() - i - 1])\n\t\t\t\tflag++;\n\t\t\tif (flag > 1)\n\t\t\t{\n\t\t\t\tok = 0;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t}\n\t\tif (ok)\n\t\t\tcout << \"YES\" << endl;\n\t\telse cout << \"NO\" << endl;\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f7193b4aa6b18f90bf1b794f43047a5f", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include\n#include\nusing namespace std;\nstring s;\nint ans=0;\nint i=0;\nint main()\n{\n\tcin>>s;\n\tfor(int j=s.size()-1;j>=s.size()/2;j--)\n\t{\n\t\tif(s[i]!=s[j])\n\t\t{\n\t\t\tfor(char c='a';c<='z';c++)\n\t\t\t{\n\t\t\t\tif(c==s[i]||c==s[j])\n\t\t\t\t{\n\t\t\t\tans++;\n\t\t\t\tc=c+26;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(ans>1)\n\t\t{\n\t\t\tcout<<\"NO\"<\nusing namespace std;\nint main()\n{\nwhile(1)\n{\nstring s;\ncin>>s;\nint low=0;\nint high=s.size()-1;\nint count=0;\nwhile(low<=high)\n{\n\tif(s[low]!=s[high])\n\tcount++;\n\tlow++;\n\thigh--;\n}\nif(count==1)\ncout<<\"YES\\n\";\nelse\ncout<<\"NO\\n\";\n}\nreturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9d06f23576d769e5c95c5cbef8884ca7", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52", "difficulty": 1000.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\nusing namespace std ;\n int main () \n {\n int x, c=0 , y;\n \n cin >> x>> y; \n vector< int > arr (x); \n \n for ( int j= 1 ; j <= x; j++) {\n arr.clear() ;\n for ( int k =1; k <=x; k++)\n { arr[k]=(k*j); \n if(arr[k]== y) \n c++ ;\n }\n }\n cout<\n\nint main()\n{\n int n,i,j,x;\n scanf(\"%d\",&n);\n scanf(\"%d\",&x);\n int m[n][n];\n for (i=0;i\nusing namespace std;\nint main()\n{\n int n,x;\n cin>>n>>x;\n int arr[n][n];\n\n for(int i=1;i<=n;i++)\n {\n for(int j=1;j<=n;j++)\n {\n arr[i-1][j-1]=i*j;\n }\n }\n\n int count=0;\n for(int i=0;i \nusing namespace std;\n\nint main()\n{\n int n,x;\n cin>>n>>x;\n int t[n][n];\n int to=0;\n for(int i=0;i\n#include \n#include \n#include \n#include \nusing namespace std;\n\nint main () {\n\tfreopen (\"input.txt\", \"r\", stdin); \n\tfreopen (\"output.txt\", \"w\", stdout);\n\tint n, mas[101], x=0, y=0, ans=0;\n\tfor (int i=0; i<101; ++i) {\n\t\tmas[i]=0;\n\t}\n\tchar a[101];\n\tcin>>n;\n\tfor (int i=0; i>a[i];\n\t\tif (a[i]=='U') {\n\t\t\ty++;\n\t\t}\n\t\tif (a[i]=='D') {\n\t\t\ty--;\n\t\t}\n\t\tif (a[i]=='L') {\n\t\t\tx--;\n\t\t}\n\t\tif (a[i]=='R') {\n\t\t\tx++;\n\t\t}\n\t\tif (x==0 && y==0) {\n\t\t\tmas[i]=1;\n\t\t}\n\t}\n\tfor (int i=0; i\n\n#ifdef _MSC_VER\n# include \n# define __builtin_popcount __popcnt\nstatic uint32_t __inline __builtin_clz(uint32_t x) {\n\tunsigned long r = 0;\n\t_BitScanReverse(&r, x);\n\treturn (31 - r);\n}\n#endif\n\nusing namespace std;\n\n#define FOR(i, a, b) for(int i = a; i < b; i++)\n#define FORd(i, a, b) for(int i = a; i >= b; i--)\n\nint n, ans;\nchar arr[100 + 5];\n\nint main()\n{\n\tcin >> n;\n\tfor (int i = 0; i < n; i++) cin >> arr[i];\n\n\tarr[n] = '~';\n\n\tint i = 0;\n\twhile (arr[i] != '~') {\n\t\tif (arr[i] == 'L') {\n\t\t\tint j = i + 1;\n\t\t\twhile (arr[j] != '~') {\n\t\t\t\tif (arr[j] == 'R') {\n\t\t\t\t\tarr[i] = ' ';\n\t\t\t\t\tarr[j] = ' ';\n\t\t\t\t\tans += 2;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (arr[i] == 'R') {\n\t\t\tint j = i + 1;\n\t\t\twhile (arr[j] != '~') {\n\t\t\t\tif (arr[j] == 'L') {\n\t\t\t\t\tarr[i] = ' ';\n\t\t\t\t\tarr[j] = ' ';\n\t\t\t\t\tans += 2;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (arr[i] == 'U') {\n\t\t\tint j = i + 1;\n\t\t\twhile (arr[j] != '~') {\n\t\t\t\tif (arr[j] == 'D') {\n\t\t\t\t\tarr[i] = ' ';\n\t\t\t\t\tarr[j] = ' ';\n\t\t\t\t\tans += 2;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (arr[i] == 'D') {\n\t\t\tint j = i + 1;\n\t\t\twhile (arr[j] != '~') {\n\t\t\t\tif (arr[j] == 'U') {\n\t\t\t\t\tarr[i] = ' ';\n\t\t\t\t\tarr[j] = ' ';\n\t\t\t\t\tans += 2;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\ti++;\n\t}\n\tcout << ans << endl;\n\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2167479ecd79b78a17c432350bacf010", "src_uid": "b9fa2bb8001bd064ede531a5281cfd8a", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n int n,cnt1=0,cnt2=0;cin>>n;\n string s;cin>>s;\n for(int i=s.length();i>0;i++){\n if(s[i]=='L')cnt1--;\n if(s[i]=='R')cnt1++;\n if(s[i]=='U')cnt2++;\n if(s[i]=='D')cnt2--;\n }\n cout<\n#include\n#include\nusing namespace std;\n\nstruct mokh{\n\tint x;\n\tint y;\n};\nint main()\n{\n\tint n,ans=0;\n\tmokh b;\n\tb.x = b.y = 0;\n\tcin >> n;\n\tstring a, *tmp;\n\tcin >> a;\n\ttmp = new string[a.length()];\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\ttmp[i] = a.at(i);\n\n\t}\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tif (a.at(i) == 'L')\n\t\t\tb.x = b.x - 1;\n\t\telse if (a.at(i) == 'R')\n\t\t\tb.x = b.x + 1;\n\t\telse if (a.at(i) == 'U')\n\t\t\tb.y = b.y + 1;\n\t\telse if (a.at(i) == 'D')\n\t\t\tb.y = b.y - 1;\n\t\tif (b.x == 0 && b.y == 0)\n\t\t\tans = i + 1;\n\n\n\t}\n\tcout << ans;\n\t_getch();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d8f2e3aa2edfddf5b09c21acb7cf0a38", "src_uid": "b9fa2bb8001bd064ede531a5281cfd8a", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std; \n\n#define PB push_back \n#define MP make_pair \n#define SZ(v) ((int)(v).size()) \n#define FOR(i,a,b) for(int i=(a);i<(b);++i) \n#define REP(i,n) FOR(i,0,n) \n#define FORE(i,a,b) for(int i=(a);i<=(b);++i) \n#define REPE(i,n) FORE(i,0,n) \n#define FORSZ(i,a,v) FOR(i,a,SZ(v)) \n#define REPSZ(i,v) REP(i,SZ(v)) \ntypedef long long ll;\n\nint n,x;\n\nint gcd(int a,int b) { return b==0?a:gcd(b,a%b); }\n\nint mpow(int a,int n,int m) {\n\tif(n==0) return 1;\n\tif(n%2==1) return (ll)a*mpow(a,n-1,m)%m;\n\treturn mpow((ll)a*a%m,n/2,m);\n}\n\nvoid run(int casenr) {\n\tscanf(\"%d%d\",&n,&x);\n\n\t//n+1 (=p) must be prime\n\t{ int y=n+1; for(int i=2;i*i<=y;++i) if(y%i==0) { printf(\"-1\\n\"); return; } }\n\n\t// find factors of n (=p-1)\n\tvector fact;\n\t{ int y=n; for(int i=2;i*i<=y;++i) if(y%i==0) { fact.PB(i); while(y%i==0) y/=i; } if(y!=1) fact.PB(y); }\n//\tprintf(\"facts: \"); REPSZ(i,fact) printf(\" %d\",fact[i]); puts(\"\");\n\t\n\t// find a generator\n\tint gen=-1;\n\tFOR(i,2,n+1) {\n\t\tassert(mpow(i,n,n+1)==1);\n\t\tbool ok=true;\n\t\tREPSZ(j,fact) if(mpow(i,n/fact[j],n+1)==1) { ok=false; break; }\n\t\tif(!ok) continue;\n\t\tgen=i; break;\n\t}\n\tassert(gen!=-1);\n//\tprintf(\"gen: %d\\n\",gen);\n\t\n\tint ret=-1,cur=1;\n\tREP(i,n) {\n\t\tif(gcd(i,n)==1&&cur %d\\n\",cur,now);\n\t\t\tif(now>ret) ret=now;\n\t\t}\n\t\tcur=(ll)cur*gen%(n+1);\n\t}\n\tprintf(\"%d\\n\",ret);\n}\n\nint main() {\n\t//int n; scanf(\"%d\",&n); FORE(i,1,n) run(i);\n\trun(1);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "558f16f1201e0d89ea18c3f7a864139e", "src_uid": "29dda6a3f057e5bccdc076d7e492ac9a", "difficulty": 2600.0} {"lang": "GNU C++0x", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nlong long fast_pow_mod(long long base, int power, int moder) {\n if (power == 0) {\n return 1;\n } else {\n long long res = fast_pow_mod(base, power/2, moder);\n res = (res*res) % moder;\n if (power % 2 == 0) {\n return res;\n } else {\n return (res*base) % moder;\n }\n }\n}\n\nint main(){\n int n, x;\n scanf(\"%d%d\", &n, &x);\n const int LEN = 500001;\n vector isprime(LEN + 1, true);\n for (int p = 2; p <= LEN; ++p) {\n if (isprime[p]) {\n for (int n = 2; n*p <= LEN; ++n) {\n\tisprime[n*p] = false;\n }\n }\n }\n if (x-1 >= 2) {\n if (n == 1) {\n printf(\"%d\\n\", x-1);\n } else if (isprime[n+1]) {\n bool have_ans = false;\n for (int b = x-1; b >= max(2, x-1-n); --b) {\n\tif (fast_pow_mod(b%(n+1), n/2, n+1) != 1) {\n\t printf(\"%d\\n\", b);\n\t have_ans = true;\n\t break;\n\t}\n }\n if (!have_ans) {\n\tputs(\"-1\");\n }\n } else {\n puts(\"-1\");\n }\n } else {\n puts(\"-1\");\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f9ad9d7e6525302432413ea59aa0f3d2", "src_uid": "29dda6a3f057e5bccdc076d7e492ac9a", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#ifdef _MSC_VER\n#pragma comment(linker, \"/STACK:1024000000,1024000000\")\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\n#define REP(i, n) for (int i=0;i=int(a);--i)\n#define REP_1(i, n) for (int i=1;i<=int(n);++i)\n#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)\n#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)\n#define REP_C(i, n) for (int n____=int(n),i=0;i=a____;--i)\n#define REP_N(i, n) for (i=0;i=int(a);--i)\n#define REP_1_C(i, n) for (int n____=int(n),i=1;i<=n____;++i)\n#define FOR_1_C(i, a, b) for (int b____=int(b),i=a;i<=b____;++i)\n#define DWN_1_C(i, b, a) for (int a____=int(a),i=b;i>=a____;--i)\n#define REP_1_N(i, n) for (i=1;i<=int(n);++i)\n#define FOR_1_N(i, a, b) for (i=int(a);i<=int(b);++i)\n#define DWN_1_N(i, b, a) for (i=int(b);i>=int(a);--i)\n#define REP_C_N(i, n) for (int n____=(i=0,int(n));i=a____;--i)\n#define REP_1_C_N(i, n) for (int n____=(i=1,int(n));i<=n____;++i)\n#define FOR_1_C_N(i, a, b) for (int b____=(i=1,int(b);i<=b____;++i)\n#define DWN_1_C_N(i, b, a) for (int a____=(i=b,int(a));i>=a____;--i)\n\n#define ECH(it, A) for (__typeof(A.begin()) it=A.begin(); it != A.end(); ++it)\n#define REP_S(i, str) for (char*i=str;*i;++i)\n#define REP_L(i, hd, nxt) for (int i=hd;i;i=nxt[i])\n#define REP_G(i, u) REP_L(i,hd[u],suc)\n#define REP_SS(x, s) for (int x=s;x;x=(x-1)&s)\n#define DO(n) for ( int ____n ## __line__ = n; ____n ## __line__ -- ; )\n#define REP_2(i, j, n, m) REP(i, n) REP(j, m)\n#define REP_2_1(i, j, n, m) REP_1(i, n) REP_1(j, m)\n#define REP_3(i, j, k, n, m, l) REP(i, n) REP(j, m) REP(k, l)\n#define REP_3_1(i, j, k, n, m, l) REP_1(i, n) REP_1(j, m) REP_1(k, l)\n#define REP_4(i, j, k, ii, n, m, l, nn) REP(i, n) REP(j, m) REP(k, l) REP(ii, nn)\n#define REP_4_1(i, j, k, ii, n, m, l, nn) REP_1(i, n) REP_1(j, m) REP_1(k, l) REP_1(ii, nn)\n\n#define ALL(A) A.begin(), A.end()\n#define BSC(A, x) (lower_bound(ALL(A), x) - A.begin())\n#define CTN(T, x) (T.find(x) != T.end())\n#define SZ(A) int(A.size())\n#define PB push_back\n#define MP(A, B) make_pair(A, B)\n#define fi first\n#define se second\n#define Rush for(int ____T=(scanf(\"%d\",&____T),____T), ____cas=0;++____cas, ____T--;)\n\n\ntypedef long long LL;\ntypedef vector VI;\ntypedef vector VC;\ntypedef vector VS;\ntypedef vector VL;\ntypedef vector VD;\ntypedef set SI;\ntypedef set SS;\ntypedef map MII;\ntypedef map MSI;\ntypedef pair PII;\ntypedef pair PLL;\ntypedef vector VII;\ntypedef vector VVI;\ntypedef vector VVII;\ntemplate inline void RST(T &A){memset(A, 0, sizeof(A));}\ntemplate inline void FLC(T &A, int x){memset(A, x, sizeof(A));}\ntemplate inline void CLR(T &A){A.clear();}\n\n/** Constant List .. **/ //{\nconst int dx4[] = {-1, 0, 1, 0};\nconst int dy4[] = {0, 1, 0, -1};\nconst int dx8[] = {-1, 0, 1, 0 , -1 , -1 , 1 , 1};\nconst int dy8[] = {0, 1, 0, -1 , -1 , 1 , -1 , 1};\nconst int dxhorse[] = {-2 , -2 , -1 , -1 , 1 , 1 , 2 , 2};\nconst int dyhorse[] = {1 , -1 , 2 , -2 , 2 ,-2 , 1 ,-1};\nconst int mod = 1000000007;\n//int mod = 99990001;\nconst int inf = 0x3f3f3f3f;\nconst LL inff = 1LL << 60;\nconst double eps = 1e-9;\nconst double oo = 1e25;\nconst double pi = acos(-1.0); //M_PI;\n//}\n/** Add On .. **/ //{\n// <<= '0. Nichi Joo ., //{\ntemplate inline void checkMin(T &a,const T b){if (b inline void checkMax(T &a,const T b){if (a inline void checkMin(T &a, T &b, const T x){checkMin(a, x), checkMin(b, x);}\ntemplate inline void checkMax(T &a, T &b, const T x){checkMax(a, x), checkMax(b, x);}\ntemplate inline void checkMin(T& a, const T b, C c){if (c(b,a)) a = b;}\ntemplate inline void checkMax(T& a, const T b, C c){if (c(a,b)) a = b;}\ntemplate inline T min(T a, T b, T c){return min(min(a, b), c);}\ntemplate inline T max(T a, T b, T c){return max(max(a, b), c);}\ntemplate inline T min(T a, T b, T c, T d){return min(min(a, b), min(c, d));}\ntemplate inline T max(T a, T b, T c, T d){return max(max(a, b), max(c, d));}\ntemplate inline T sqr(T a){return a*a;}\ntemplate inline T cub(T a){return a*a*a;}\ntemplate inline T ceil(T x, T y){return (x - 1) / y + 1;}\ninline int sgn(double x){return x < -eps ? -1 : x > eps;}\ninline int sgn(double x, double y){return sgn(x - y);}\ninline double cot(double x){return 1./tan(x);};\ninline double sec(double x){return 1./cos(x);};\ninline double csc(double x){return 1./sin(x);};\n//}\n// <<= '1. Bitwise Operation ., //{\nnamespace BO{\ninline bool _1(int x, int i){return bool(x&1<> 1) & 0x55555555) | ((x << 1) & 0xaaaaaaaa);x = ((x >> 2) & 0x33333333) | ((x << 2) & 0xcccccccc);x = ((x >> 4) & 0x0f0f0f0f) | ((x << 4) & 0xf0f0f0f0);x = ((x >> 8) & 0x00ff00ff) | ((x << 8) & 0xff00ff00);x = ((x >>16) & 0x0000ffff) | ((x <<16) & 0xffff0000);return x;}\ninline LL reverse_bits(LL x){x = ((x >> 1) & 0x5555555555555555LL) | ((x << 1) & 0xaaaaaaaaaaaaaaaaLL);x = ((x >> 2) & 0x3333333333333333LL) | ((x << 2) & 0xccccccccccccccccLL);x = ((x >> 4) & 0x0f0f0f0f0f0f0f0fLL) | ((x << 4) & 0xf0f0f0f0f0f0f0f0LL);x = ((x >> 8) & 0x00ff00ff00ff00ffLL) | ((x << 8) & 0xff00ff00ff00ff00LL);x = ((x >>16) & 0x0000ffff0000ffffLL) | ((x <<16) & 0xffff0000ffff0000LL);x = ((x >>32) & 0x00000000ffffffffLL) | ((x <<32) & 0xffffffff00000000LL);return x;}\ntemplate inline bool odd(T x){return x&1;}\ntemplate inline bool even(T x){return !odd(x);}\ntemplate inline T low_bit(T x) {return x & -x;}\ntemplate inline T high_bit(T x) {T p = low_bit(x);while (p != x) x -= p, p = low_bit(x);return p;}\ntemplate inline T cover_bit(T x){T p = 1; while (p < x) p <<= 1;return p;}\ntemplate inline int cover_idx(T x){int p = 0; while (_1(p) < x ) ++p; return p;}\n#ifdef __GNUC__\ninline int clz(int x){return __builtin_clz(x);}\ninline int clz(LL x){return __builtin_clzll(x);}\ninline int ctz(int x){return __builtin_ctz(x);}\ninline int ctz(LL x){return __builtin_ctzll(x);}\ninline int lg2(int x){return !x ? -1 : 31 - clz(x);}\ninline int lg2(LL x){return !x ? -1 : 63 - clz(x);}\ninline int low_idx(int x){return !x ? -1 : ctz(x);}\ninline int low_idx(LL x){return !x ? -1 : ctz(x);}\ninline int high_idx(int x){return lg2(x);}\ninline int high_idx(LL x){return lg2(x);}\ninline int parity(int x){return __builtin_parity(x);}\ninline int parity(LL x){return __builtin_parityll(x);}\ninline int count_bits(int x){return __builtin_popcount(x);}\ninline int count_bits(LL x){return __builtin_popcountll(x);}\n#endif\n} using namespace BO;//}\n// <<= '2. Number Theory .,//{\nnamespace NT{\ntemplate inline T lowbit(T x) {return x & -x;}///lowbit(x)\ntemplate inline T GCD(T A,T B){T C;while(B!=0)C=B,B=A%B,A=C;return A;}///GCD(a,b)\ntemplate inline T LCM(T A,T B){return A*(B/GCD(A,B));}///LCM(a,b)\ntemplateinline T Mod(T a,T b){a%=b;return a<0?a+b:a;}///\u8ba1\u7b97a%b,\u652f\u6301a<=0\ntemplateinline T MulMod(T a,T b,T c)/**\u4e8c\u5206\u8ba1\u7b97a*b mod c \u53ef\u4ee5\u5904\u7406c+c\u4e0d\u6ea2\u51fa\u7684\u60c5\u51b5*/{if(c==1)return 0;if(c<=0)return -1;T ret=0,tmp;tmp=a=Mod(a,c);b=Mod(b,c);while(b){if(b&0x1)if((ret+=tmp)>=c)ret-=c;if((tmp<<=1)>=c)tmp-=c;b>>=1;}return ret;}\ntemplate inline T PowMod(Tb a,T b,T c)/**a^b mod c \u8981\u6c42c*c\u4e0d\u6ea2\u51fa*/{if(c==1)return 0;if(c<=0)return -1;a=Mod(a,(Tb)c);Tb ret(1L%c);while(b){if(b&0x1)ret=ret*a%c;a=a*a%c;b>>=1;}return (T)ret;}\ntemplate inline T HPowMod(T a,T b,T c)/**\u4e8c\u5206\u8ba1\u7b97a^b mod c \u8981\u6c42c+c\u4e0d\u6ea2\u51fa*/{if(c==1)return 0;if(c<=0)return -1;a=Mod(a,c);T ret(1L%c);while(b){if(b&0x1)ret=MulMod(ret,a,c);a=MulMod(a,a,c);b>>=1;}return ret;}\ntemplate inline T Pow(T a, Tb b)/**a^b*/{T c(1); while (b){if (b&1) c *= a;a *= a, b >>= 1;}return c;}\ntemplate inline T EXT_GCD(T a,T b,T& x,T& y)/**ax+by=gcd(a,b)*/{T t,ret;if (!b){x=1,y=0;return a;}ret=EXT_GCD(b,a%b,x,y);t=x,x=y,y=t-a/b*y;return ret;}\ntemplate inline T Inv(T a,T n)/**\u8fd4\u56de\u4e00\u4e2a\u6570a\u5bf9\u4e8en\u7684\u4e58\u6cd5\u9006\u5143*/{if(n<=0)return -1;T d,x,y;d=EXT_GCD(a,n,x,y);if(d!=1)return -1;return Mod(x,n);}\ntemplateclass Matrix/**Matrix*/ {public:T m[MAXN][MAXN];Matrix(){}void init(T num[MAXN][MAXN]){for(int i = 0 ; i < MAXN ; i++){for(int j = 0 ; j < MAXN ; j++){m[i][j] = num[i][j];if (MOD!=-1) m[i][j] %= MOD;}}}\nfriend Matrix operator*(const Matrix &m1 ,const Matrix &m2) {int i, j, k;Matrix ret;memset(ret.m, 0, sizeof(ret.m));for (i = 0; i < MAXN; i++) {for (j = 0; j < MAXN; j++)if ( m1.m[i][j] ){for(k = 0 ; k < MAXN ; k++){ret.m[i][k] += m1.m[i][j] * m2.m[j][k];if (MOD!=-1) ret.m[i][k] %= MOD;}}}return ret;}\nfriend Matrix operator+(const Matrix &m1 ,const Matrix &m2) {int i, j;Matrix ret;for (i = 0; i < MAXN; i++) {for (j = 0; j < MAXN; j++) {ret.m[i][j] = 0;ret.m[i][j] = m1.m[i][j]+m2.m[i][j];if (MOD!=-1) ret.m[i][j] %= MOD;}}return ret;}\nfriend Matrix operator^(const Matrix &_M , LL nx){Matrix ret,M(_M);for(int i = 0 ; i < MAXN ; i++){for(int j = 0 ; j < MAXN ; j++){if(i == j)ret.m[i][j] = 1;else ret.m[i][j] = 0;}}while(nx){if(nx & 1)ret = ret * M;nx = nx >> 1;M = M * M;}return ret;}\n};///end of matrix\nconst int PMAX = 1000;VI Prime; bitset isnotPrime;///Prime:sieve(),phi(),\nvoid sieve(){if (!Prime.empty()) return ;FOR(i, 2, PMAX){if (!isnotPrime[i]) Prime.PB(i);for (int j=0;jT phi(T n){T ret=1,i;for (i=2;i*i<=n;i++)if (n%i==0){n/=i,ret*=i-1;while (n%i==0)n/=i,ret*=i;}if (n>1)ret*=n-1;return ret;}\n\n} using namespace NT;//}\n\n\n// <<= '3. Date .,//{\nnamespace Date{\nint days[12]={31,28,31,30,31,30,31,31,30,31,30,31};\nstruct date{int year,month,day;};\ninline int leap(int year)/**\u5224\u95f0\u5e74**/{return (year%4==0&&year%100!=0)||year%400==0;}\ninline int legal(date a)/**\u5224\u5408\u6cd5\u6027**/{if (a.month<0||a.month>12) return 0;if (a.month==2)return a.day>0&&a.day<=28+leap(a.year);return a.day>0&&a.day<=days[a.month-1];}\ninline int datecmp(date a,date b)/**\u6bd4\u8f83\u65e5\u671f\u5927\u5c0f**/{if (a.year!=b.year)return a.year-b.year;if (a.month!=b.month)return a.month-b.month;return a.day-b.day;}\nint weekday(date a)/**\u8fd4\u56de\u6307\u5b9a\u65e5\u671f\u662f\u661f\u671f\u51e0**/{int tm=a.month>=3?(a.month-2):(a.month+10);int ty=a.month>=3?a.year:(a.year-1);return (ty+ty/4-ty/100+ty/400+(int)(2.6*tm-0.2)+a.day)%7;}\nint date2int(date a)/**\u65e5\u671f\u8f6c\u5929\u6570\u504f\u79fb**/{int ret=a.year*365+(a.year-1)/4-(a.year-1)/100+(a.year-1)/400,i;days[1]+=leap(a.year);for (i=0;i=365+leap(ret.year);a-=365+leap(ret.year),ret.year++);days[1]+=leap(ret.year);for (ret.month=1;a>=days[ret.month-1];a-=days[ret.month-1],ret.month++);days[1]=28;ret.day=a+1;return ret;}\n}//using namespace Date;//}\n\n//}\n/*************************\u5bc6\u5c01\u7ebf****************************************/\nint main(){\n int n,x,p;\n sieve();\n cin>>n>>x;\n p = n+1;\n if ( !isPrime(p) ){\n puts(\"-1\");\n return 0;\n }else{\n int b;\n for ( b=x-1; b>1;b-- ){\n bool flag = 0;\n for (int j=2; j*j<=n; j++)\n if ( n%j==0 ){\n flag |= ( HPowMod(b,j,p)==1 ) || ( HPowMod(b,n/j,p)==1 );\n }\n if ( !flag ){\n printf(\"%d\\n\", b);\n return 0;\n }\n }\n }\n puts(\"-1\");\n return 0;\n}\n/*************************\u5bc6\u5c01\u7ebf****************************************/\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "31af6b4a8459af98907c472db752e7f4", "src_uid": "29dda6a3f057e5bccdc076d7e492ac9a", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include \n#define FOR(i,a,b) for(register int i=(a);i<(b);++i)\n#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)\n#define pi pair\n#define mk(a,b) make_pair(a,b)\n#define mygc(c) (c)=getchar()\n#define mypc(c) putchar(c)\n#define fi first\n#define se second\n#define ls(x) t[x].lson\n#define rs(x) t[x].rson\n#define d(a,b) dp[min(a,b)][max(a,b)]\nusing namespace std;\ntypedef long long ll;\ntypedef double db;\nconst int maxn = 300005;\nconst int maxm = 1000005;\nconst int inf = 2147483647;\ntypedef long long ll;\nconst double eps = 1e-9;\nconst long long INF = 9223372036854775807ll;\nll qpow(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c;b>>=1;}return ans;}\ninline void rd(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}\ninline void rd(ll *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}\ninline void rd(db *x){scanf(\"%lf\",x);}\ninline int rd(char c[]){int i,s=0;for(;;){mygc(i);if(i!=' '&&i!='\\n'&&i!='\\r'&&i!='\\t'&&i!=EOF) break;}c[s++]=i;for(;;){mygc(i);if(i==' '||i=='\\n'||i=='\\r'||i=='\\t'||i==EOF) break;c[s++]=i;}c[s]='\\0';return s;}\ninline void rd(int a[],int n){FOR(i,0,n)rd(&a[i]);}\ninline void rd(ll a[],int n){FOR(i,0,n)rd(&a[i]);}\ntemplate inline void rd(T *x, S *y){rd(x);rd(y);}\ntemplate inline void rd(T *x, S *y, U *z){rd(x);rd(y);rd(z);}\ntemplate inline void rd(T *x, S *y, U *z, V *w){rd(x);rd(y);rd(z);rd(w);}\ninline void wr(int x){if(x < 10) putchar('0' + x); else wr(x / 10), wr(x % 10);}\ninline void wr(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}\ninline void wr(ll x, char c){int s=0,m=0;char f[20];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}\ninline void wr(db x, char c){printf(\"%.15f\",x);mypc(c);}\ninline void wr(const char c[]){int i;for(i=0;c[i]!='\\0';i++)mypc(c[i]);}\ninline void wr(const char x[], char c){int i;for(i=0;x[i]!='\\0';i++)mypc(x[i]);mypc(c);}\ntemplate inline void wrn(T x){wr(x,'\\n');}\ntemplate inline void wrn(T x, S y){wr(x,' ');wr(y,'\\n');}\ntemplate inline void wrn(T x, S y, U z){wr(x,' ');wr(y,' ');wr(z,'\\n');}\ntemplate inline void wrn(T x, S y, U z,H h){wr(x,' ');wr(y,' ');wr(z,' ');wr(h,'\\n');}\ntemplate inline void wra(T x[], int n){int i;if(!n){mypc('\\n');return;}FOR(i,0,n-1)wr(x[i],' ');wr(x[n-1],'\\n');}\n\nint pos[82],tot,a[81];\nll dp[82][82][82*82]; \nll cal(ll x){\n\treturn x*(x-1)/2;\n}\nint main(){\n\tint n;\n\trd(&n);\n\tll as=0;\n\tFOR(i,1,n+1){\n\t\trd(&a[i]);\n\t\tif(a[i])pos[++tot]=i;else as++;\n\t}\n\tpos[++tot]=n+1;\n\tas=as*(as-1)/2;\n\tint nn=n*(n-1)/2;\n\tFOR(i,0,tot+1)\n\tFOR(j,0,n+2)\n\tFOR(k,0,nn+1)dp[i][j][k]=INF/4;\n\tdp[0][0][0]=0;\n\tFOR(i,1,tot+1){\n\t\tFOR(j,i,n+2){\n\t\t\tFOR(k,abs(pos[i]-j),nn+1){\n\t\t\t\tFOR(t,i-1,j){\n\t\t\t\t\tdp[i][j][k]=min(dp[i][j][k],dp[i-1][t][k-abs(pos[i]-j)]+cal(j-t-1));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tFOR(i,0,nn+1){\n\t\tif(i)dp[tot][n+1][i]=min(dp[tot][n+1][i],dp[tot][n+1][i-1]);//\ufffd\ufffd\u03aa\ufffd\ufffd\u04aa\ufffd\udb8b\udef6\ufffd\ufffd\ufffdi\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u04aa\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\u04bb\ufffd\ufffd \n\t\tprintf(\"%lld \",as-dp[tot][n+1][i]);\n\t}\n\twrn(\"\");\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c8c68186d19997cc3051cf61cb3b9821", "src_uid": "29dda6a3f057e5bccdc076d7e492ac9a", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include\n#define int long long\nusing namespace std;\ninline int read()\n{\n\tchar c=getchar();\n\tint x=0;\n\twhile(c<'0'||c>'9') c=getchar();\n\twhile(c>='0'&&c<='9')\n\t{\n\t\tx=(x<<3)+(x<<1)+c-48;\n\t\tc=getchar();\n\t}\n\treturn x;\n}\nbool check[6005*6000];\nint n,prime[6000*6005],cnt=0,sum,dan[6005*6000];\nsigned main()\n{\n\tfor(int i=2;i<=6000*6000;i++)\n\t{\n\t\tif(!check[i]) prime[++cnt]=i;\n\t\tfor(int j=1;j<=cnt&&i*prime[j]<=6000*6000;j++)\n\t\t{\n\t\t\tcheck[i*prime[j]]=1;\n\t\t\tif(i%prime[j]==0) break;\n\t\t}\n\t}\n\tn=read();\n\tif(n==2)\n\t{\n\t\tcout<<\"1 1\";\n\t\treturn 0;\n\t}\n\tsum=n*(n+1)/2;\n\tif(sum%2==0)\n\t{\n\t\tint u1,u2;\n\t\tfor(int i=1;i<=cnt;i++)\n\t\tif(!check[sum-prime[i]])\n\t\t{\n\t\t\tu1=prime[i];\n\t\t\tu2=sum-prime[i];\n\t\t\tbreak;\n\t\t}\n\t\tfor(int i=n;i>=1;i--)\n\t\tif(u1>i) dan[i]=2,u1-=i;\n\t\telse\n\t\t{\n\t\t\tdan[u1]=2;\n\t\t\tbreak;\n\t\t}\n\t\tfor(int i=1;i<=n;i++)\n\t\t{\n\t\t\tif(dan[i]) cout<=1;i--)\n\t\tif(u1>i) dan[i]=2,u1-=i;\n\t\telse\n\t\t{\n\t\t\tif(u1-3)\n\t\t\t{\n\t\t\t\tdan[u1]=2;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tdan[1]=2;\n\t\t\t\tdan[2]=2;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tfor(int i=1;i<=n;i++)\n\t\t{\n\t\t\tif(dan[i]) cout<\n#define vvl vector\n#define pll pair\n#define vpll vector\n#define vppll vector>\n#define mp make_pair\n#define pb push_back\n#define mapll map\n#define fir first\n#define sec second\n#define _cin ios_base::sync_with_stdio(0); cin.tie(0);\n#define fo(i,b) for(i=0;i=b;i--)\n#define all(x) (x).begin(), (x).end()\n#define s(v) (ll)v.size()\n#define watch(x) cerr << (#x) << \" is \" << (x) << endl\n#define watch2(x,y) cerr << (#x) << \" is \" << (x) << \" and \" << (#y) << \" is \" << (y) << endl\n#define Time cerr << \"Time : \" << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << \"ms\\n\"\n#define inf 2000000000000000000 \n#define mod 1000000007\n#define mod1 998244353\n\nusing namespace std; \n\n// #define ordered_set tree, rb_tree_tag,tree_order_statistics_node_update> \n// #include \n// #include // order_of_key() ; *( find_by_order() ) -> kth element in set;\n// using namespace __gnu_pbds; // order_of_key(k) -> Number of elements strictly smaller than k\n\n\ninline ll max(ll a,ll b,ll c) {return max(max(a, b), c);}\ninline ll min( ll a, ll b, ll c) { return min(min(a, b), c);}\ninline ll max(ll a,ll b) {return (a>b) ? a : b;}\ninline ll min(ll a,ll b) {return (a=mod_) ? x+y-mod_ : x+y;}\ninline ll mul(ll x, ll y, ll mod_){return ((x%mod_)*1LL*(y%mod_))%mod_;}\nll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}\nll powm(ll a, ll n, ll mod_){ ll p=1; while(n){ if(n%2){ p=mul(p,a,mod_);} n>>=1; a=mul(a,a,mod_);} return p%mod_;} \nll powi(ll a, ll mod_) {return powm(a,mod_-2,mod_);}\n /*Code Begins*/\n\nll MAX_SIZE = 4e7L+5;\nvll isprime(MAX_SIZE , true); \nvll prime; \nvll SPF(MAX_SIZE); \nvoid seive(ll N){ \n isprime[0] = isprime[1] = false ; \n for (long long int i=2; i> TC;\nwhile(TC--){\n cin >> n;\n\n seive(n*(n+1)/2+3);\n if(n==1) cout << -1;\n else if(binary_search(all(prime),n*(n+1)/2)) fo(i,n) cout << \"1 \";\n else{\n vll a(n+1,1);\n if(n%2==0){\n for(auto x : prime){\n if(binary_search(all(prime),n*(n+1)/2-x)){\n i=n;\n while(x>0){\n if(i>=x){\n a[x]=2;\n x=0;\n }else{\n a[i]=2;\n x-=i;\n --i;\n }\n watch2(x,i);\n }\n break;\n }\n }\n }else{\n if(binary_search(all(prime),n*(n+1)/2-2)){\n a[2]=2;\n }else{\n for(auto x : prime){\n if(binary_search(all(prime),n*(n+1)/2-x-2)){\n i=n;\n while(x>0){\n if(i>=x){\n a[x]=2;\n x=0;\n }else{\n a[i]=2;\n x-=i;\n --i;\n }\n }\n break;\n }\n }\n }\n }\n flag=0;\n repa(i,1,n+1) if(a[i]==0) flag=1;\n if(flag) cout << -1;\n else{\n repa(i,1,n+1) cout << a[i] << ' ';\n }\n } \n\n}\n\n Time;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cb4c4f76f696a6dca4fc12fba94034bc", "src_uid": "94ef0d901f21e1945849fd5bfc2d1449", "difficulty": 2200.0} {"lang": "GNU C++", "source_code": "/*\n_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.\n\n\tAbhinandan Agarwal\n_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.*/\n#include\nusing namespace std;\n#define pc putchar_unlocked\n#define gc getchar_unlocked\ntypedef long long ll;\ntypedef unsigned long long llu;\n#define mp make_pair\n#define pb push_back\n#define sc(x) scanf(\"%d\",&x)\n#define sc2(x,y) scanf(\"%d%d\",&x,&y)\n#define sc3(x,y,z) scanf(\"%d%d%d\",&x,&y,&z)\n#define scl(x) scanf(\"%lld\",&x)\n#define scl2(x,y) scanf(\"%lld%lld\",&x,&y)\n#define scl3(x,y,z) scanf(\"%lld%lld%lld\",&x,&y,&z)\n#define scstr(x) scanf(\"%s\",x)\n#define pd(x) printf(\"%d\",x)\n#define pstr(x) printf(\"%s\",x)\n#define newl() printf(\"\\n\")\n#define fl(i,n) for (i=0;i pii;\ntypedef pair > piii ;\ntypedef pair pll;\ntypedef pair pli;\n#define gcd __gcd\n#define wl(n) while (n--)\n#define debug(x) cout<<\"debug->\"<<#x<<\"::\"<v;\nint isrep(int x)\n{\n\tint i,j;\n\tfor (i=1;i<=x/2+1;i++)\n\t{\n\t\tfor(j=1;j<=x;j++)\n\t\t{\n\t\t\tif (isprime(i)&&isprime(j)&&(x-i-j)>0&&isprime(x-i-j))\n\t\t\t{\n\t\t\t\tv.pb(i);\n\t\t\t\tv.pb(j);\n\t\t\t\tv.pb(x-i-j);\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}\nint isrep2(int x)\n{\n\tint i,j;\n\tfor (i=1;i0&&isprime(x-i)&&isprime(i)){\n\t\t\tv.pb(i);\n\t\t\tv.pb(x-i);\n\t\t\treturn 1;\n\t\t}\n\t}\n\treturn 0;\n}\nint n,x;\nint mrk[N];\nint ans[N];\nint main()\n{\n\tsc(n);\n\tsieve();\n\tx=n*(n+1)/2;\n\tint i,j;\n\tif (n==2)\n\t{\n\t\tprintf(\"1 1\\n\");\n\t\treturn 0;\n\n\t}\n\telse if (n==3)\n\t{\n\t\tprintf(\"1 1 2\\n\");\n\t\treturn 0;\n\t}\n\tif (isrep2(x))\n\t{\n\t\t//printf(\"%d %d\\n\",v[0],v[1]);\n\t\tint mak=v[0];\n\t\tfor (i=n;i>=1;i--){\n\t\t\tif (mak-i>=0)\n\t\t\t{\n\t\t\t\tmak-=i;\n\t\t\t\tmrk[i]=1;\n\t\t\t\tans[i]=1;\n\t\t\t}\n\t\t\tif (mak==0)break;\n\t\t}\n\t\tmak=v[1];\n\t\tfor (i=n;i>=1;i--)\n\t\t{\t\n\t\t\tif (mak-i>=0&&mrk[i]==0)\n\t\t\t{\n\t\t\t\tmrk[i]=1;\n\t\t\t\tans[i]=2;\n\t\t\t\tmak-=i;\n\t\t\t}\n\t\t\tif (!mak)break;\n\t\t}\n\n\n\t}\n\telse if (isrep2(x-3))\n\t{\n\t\tint mak=v[0];\n\t\tfor (i=n;i>=1;i--){\n\t\t\tif (mak-i>=0)\n\t\t\t{\n\t\t\t\tmak-=i;\n\t\t\t\tmrk[i]=1;\n\t\t\t\tans[i]=1;\n\t\t\t}\n\t\t\tif (mak==0)break;\n\t\t}\n\t\tmak=v[1];\n\t\tfor (i=n;i>=1;i--)\n\t\t{\t\n\t\t\tif (mak-i>=0&&mrk[i]==0)\n\t\t\t{\n\t\t\t\tmrk[i]=1;\n\t\t\t\tans[i]=2;\n\t\t\t\tmak-=i;\n\t\t\t}\n\t\t\tif (!mak)break;\n\t\t}\n\t\tmak=3;\n\t\tfor (i=n;i>=1;i--)\n\t\t{\t\n\t\t\tif (mak-i>=0&&mrk[i]==0)\n\t\t\t{\n\t\t\t\tmrk[i]=1;\n\t\t\t\tans[i]=3;\n\t\t\t\tmak-=i;\n\t\t\t}\n\t\t\tif (!mak)break;\n\t\t}\n\t}\n\telse assert(false);\n\tfor (i=1;i<=n;i++)\n\t{\n\t\tprintf(\"%d \",ans[i]);\n\t}\n\tprintf(\"\\n\");\n\treturn 0;\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c39a07c1ed21823cced30d7c71b3dc17", "src_uid": "94ef0d901f21e1945849fd5bfc2d1449", "difficulty": 2200.0} {"lang": "GNU C++17", "source_code": "#include \"bits/stdc++.h\"\n// #define ll long long int\n#define ll int\n#define double /*long*/ double\n#define endl '\\n'\n#define vll vector\n#define vvl vector\n#define pll pair\n#define vpll vector\n#define vppll vector>\n#define mp make_pair\n#define pb push_back\n#define mapll map\n#define fir first\n#define sec second\n#define _cin ios_base::sync_with_stdio(0); cin.tie(0);\n#define fo(i,b) for(i=0;i=b;i--)\n#define all(x) (x).begin(), (x).end()\n#define s(v) (ll)v.size()\n#define watch(x) cerr << (#x) << \" is \" << (x) << endl\n#define watch2(x,y) cerr << (#x) << \" is \" << (x) << \" and \" << (#y) << \" is \" << (y) << endl\n#define Time cerr << \"Time : \" << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << \"ms\\n\"\n#define inf 2000000000000000000 \n#define mod 1000000007\n#define mod1 998244353\n\nusing namespace std; \n\n// #define ordered_set tree, rb_tree_tag,tree_order_statistics_node_update> \n// #include \n// #include // order_of_key() ; *( find_by_order() ) -> kth element in set;\n// using namespace __gnu_pbds; // order_of_key(k) -> Number of elements strictly smaller than k\n\n\ninline ll max(ll a,ll b,ll c) {return max(max(a, b), c);}\ninline ll min( ll a, ll b, ll c) { return min(min(a, b), c);}\ninline ll max(ll a,ll b) {return (a>b) ? a : b;}\ninline ll min(ll a,ll b) {return (a=mod_) ? x+y-mod_ : x+y;}\ninline ll mul(ll x, ll y, ll mod_){return ((x%mod_)*1LL*(y%mod_))%mod_;}\nll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}\nll powm(ll a, ll n, ll mod_){ ll p=1; while(n){ if(n%2){ p=mul(p,a,mod_);} n>>=1; a=mul(a,a,mod_);} return p%mod_;} \nll powi(ll a, ll mod_) {return powm(a,mod_-2,mod_);}\n /*Code Begins*/\n\nll MAX_SIZE = 4e7L+5;\nvll isprime(MAX_SIZE , true); \nvll prime; \nvll SPF(MAX_SIZE); \nvoid seive(ll N){ \n isprime[0] = isprime[1] = false ; \n for (long long int i=2; i> TC;\nwhile(TC--){\n cin >> n;\n\n seive(n*(n+1)/2+3);\n if(n==1) cout << -1;\n else if(binary_search(all(prime),n*(n+1)/2)) fo(i,n) cout << \"1 \";\n else{\n vll a(n+1,1);\n if(n%2==0){\n for(auto x : prime){\n if(binary_search(all(prime),n*(n+1)/2-x)){\n i=n;\n while(x>0){\n if(i>=x){\n a[x]=2;\n x=0;\n }else{\n a[i]=2;\n x-=i;\n --i;\n }\n watch2(x,i);\n }\n break;\n }\n }\n }else{\n if(binary_search(all(prime),n*(n+1)/2-2)){\n a[2]=2;\n }else{\n for(auto x : prime){\n if(binary_search(all(prime),n*(n+1)/2-x-2)){\n i=n;\n while(x>0){\n if(i>=x){\n a[x]=2;\n x=0;\n }else{\n a[i]=2;\n x-=i;\n --i;\n }\n }\n break;\n }\n }\n }\n }\n flag=0;\n repa(i,1,n+1) if(a[i]==0) flag=1;\n if(flag) cout << -1;\n else{\n repa(i,1,n+1) cout << a[i] << ' ';\n }\n } \n\n}\n\n Time;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f2aeca6c344dae58e74b2b3ed5946b0b", "src_uid": "94ef0d901f21e1945849fd5bfc2d1449", "difficulty": 2200.0} {"lang": "GNU C++11", "source_code": "#include \n#define PI acos(-1)\n#define MP make_pair\n#define PB push_back\n#define F first\n#define S second\n#define all(a) (a).begin(), (a).end()\n#define MEM(a, h) memset(a, (h), sizeof(a))\n#define MOD\t1000000007\n#define EPS\t1e-9\ntypedef long long ll;\nusing namespace std;\n\nint g[6][6];\nint orden[6];\n\nint solve(){\n\t\n\t\n\tint res = -1;\n\tdo{\n\t\tint actual = 0;\n\t\tactual += g[orden[0]][orden[1]]+g[orden[2]][orden[3]];\n\t\tactual += g[orden[1]][orden[0]]+g[orden[3]][orden[2]];\n\t\tactual += g[orden[1]][orden[2]]+g[orden[3]][orden[4]];\n\t\tactual += g[orden[2]][orden[1]]+g[orden[4]][orden[3]];\n\t\tactual += g[orden[2]][orden[3]];\n\t\tactual += g[orden[3]][orden[2]];\n\t\tif(actual > res)\n\t\tres = actual;\n\t}while(next_permutation(orden,orden+5));\n\treturn res;\n}\nint main(){\n\t\n\tstd::ios::sync_with_stdio(false); \n\tcin.tie(0);\n\tint res;\n\tfor(int i = 0;i < 5;i++) orden[i] = i;\n\tfor(int i = 0;i < 5;i++)\n\t\tfor(int j = 0;i < 5;j++)\n\t\t\tcin>>g[i][j];\n\t\t\n\tres = solve();\n\tcout<\n#include\n#include\n#include\n//#include\n//#include\n//#include\n#include\n//#include\n//#include\n//#include\n//#include\n\nusing namespace std;\n\nint a[5][5];\nint res = 0;\n\nint main()\n{\n\tfor (int i = 0; i < 5; ++i){\n\t\tfor (int j = 0; j < 5; ++j)\n\t\t\tcin >> a[i][j];\n\t}\n\tdo{\n\t\tres = max(res, (a[0][1] + a[1][0] + a[1][2] + a[2][1] + 2 * (a[2][3] + a[3][2] + a[3][4] + a[4][3])));\n\n\t} while (next_permutation(a, a + 5));\n\tcout << res << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9064733b24bdea12a3a110efc289c76f", "src_uid": "be6d4df20e9a48d183dd8f34531df246", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint main()\n{\n int mx = 0, idx[5], arr[5][5], c;\n for (int i = 0; i < 5; i++)\n {\n idx[i] = i;\n for (int j = 0; j < 5; j++)\n cin >> arr[i][j];\n }\n do\n {\n c = 0;\n c += arr[idx[0]][idx[1]] + arr[idx[1]][idx[0]]\n + arr[idx[1]][idx[2]] + arr[idx[2]][idx[1]]\n + arr[idx[2]][idx[3]] + arr[idx[3]][idx[2]]\n + arr[idx[3]][idx[4]] + arr[idx[4]][idx[3]];\n mx = max(mx, c);\n } while (next_permutation(arr, arr + 5));\n cout << mx;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "70f0828691190e249073d4a7fe226d88", "src_uid": "be6d4df20e9a48d183dd8f34531df246", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "#include \n\n#define j1 jj\n\nusing namespace std;\n\ntypedef long long ll;\n\nll pos, flag, val, num, r, n, j, i, m, ans, q, w, h, mn = -1e9, a[10001][10001], x, y, z;\n\nstring s, s1, s2, s3;\n\nint main() {\n\n // freopen(\"input.txt\", \"r\", stdin);\n // freopen(\"output.txt\", \"w\", stdout);\n // freopen(\"papaya.in\", \"r\", stdin);\n // freopen(\"papaya.out\", \"w\", stdout);\n // freopen(\"b.in\", \"r\", stdin);\n // freopen(\"b.out\", \"w\", stdout);\n\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n\n\n for(int i = 0; i < 5; ++i)\n for(int j = 0; j < 5; ++j) cin >> a[i][j];\n\n for(int i = 0; i < 5; ++i){\n for(int j = 0; j < 5; ++j){\n for(int x = 0; x < 5; ++x){\n for(int y = 0; y < 5; ++y){\n for(int z = 0; z < 5; ++z){\n\n if(i != j && i != x && i != y && i != z && j != x && j != y && j != z && x != y && x != z && y != z){\n\n ans += a[i][j] + a[j][i] + a[j][x] + a[x][j] + 2 * (a[x][y] + a[y][x] + a[y][z] + a[z][y]);\n mn = max(mn, ans);\n\n }\n\n ans = 0;\n }\n\n }\n }\n }\n\n }\n\n cout << mn << endl;\n\n}\n/*\n10 7\n1 1 1 0 1 1 1 1 1 1\n0 0 1 1 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 1\n0 1 1 0 1 1 1 1 1 1\n1 1 1 1 1 1 1 1 1 0\n1 1 1 1 1 1 1 1 1 1\n1 1 1 0 1 1 1 1 1 1\n9 5\n0 1 1 0 0 1 0 0 1\n1 0 0 1 0 1 0 1 0\n1 0 0 1 0 1 1 0 0\n1 0 0 1 0 1 0 1 0\n0 1 1 0 0 1 0 0 1\n\n*/\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c5dbcd4d1b9abc8025d4ac334f9504df", "src_uid": "be6d4df20e9a48d183dd8f34531df246", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "#include\n#define int long long\n#define pb push_back\n#define yo cout<<\"i got here\\n\";\nusing namespace std;///think of dp,bs\nconst int mod = 1e9+7,siz = 1e6+5;\nint t,n,m,k,a,b,out[siz],pre[55];\nbool is_ok(int mid,int d,int need)\n{\n int incr = mid*(mid+1)/2; incr*=d;\n return incr<=need;\n}\nint32_t main(){\n ios_base::sync_with_stdio(0); cin.tie(0);\n\n cin>>t;\n while(t--)\n {\n cin>>a>>b>>m; int k;\n pre[0] = 0; pre[1] = a;\n out[1] = a;\n for(int i = 2;i<=50;i++)\n {\n out[i] = pre[i-1]+1;\n pre[i] = pre[i-1]+out[i];\n if(out[i]>b) break;\n k = i; if(out[i] == b) break;\n }\n int need = b - out[k];\n if(m>1)\n {\n int mn = min(m-1,need); out[k]+=mn; need-=mn;\n }\n vector >extra;\n for(int i = 2;i\nusing namespace std;\n\n\nvoid resuelve () {\n\n\n\n}\n\nint main () {\n\t\n\tlong long int q=0, a=0, b=0, m=0, x=0, i=0, diff=0, j=0, k=0, idx=0;\n\n\tvector pows;\n\tvector val;\n\n\tpows.push_back(0);\n\tpows.push_back(1);\n\n\tfor (i=2; i<=55; i++) {\n\t\tx = pows[i-1]*2;\n\t\tpows.push_back(x);\n\t}\n\n\tcin >> q;\n\n\twhile (q--) {\n\n\t\tval.clear();\n\n\t\tcin >> a >> b >> m;\n\n\t\tval.push_back(a);\n\t\ti=1;\n\t\tx=a*pows[i];\n\n\t\twhile (i<50 && x b) { \n\t\t\ti--; \n\t\t\tx = val[i] + pows[i];\n\t\t}\n\n\t\t//cout << x << \" , \" << i << endl;\n\n\t\tif (x < b) {\n\n\t\t\tint base = 2;\n\n\t\t\tif (base > m) { cout << \"-1\" << endl;}\n\t\t\telse {\n\n\t\t\t\twhile (base <= m) {\n\t\t\t\t\tx += pows[i];\n\t\t\t\t\t//cout << \" - \" << x << endl;\n\t\t\t\t\tif (x == b) {\n\t\t\t\t\t\tcout << i+1 << \" \";\n\n\t\t\t\t\t\tcout << val[0];\n\t\t\t\t\t\tfor (j=1; j<=i; j++) val[j]+=base*pows[j];\n\t\t\t\t\t\tfor (j=1; j<=i; j++) cout << \" \" << val[j];\n\t\t\t\t\t\tcout << endl;\n\t\t\t\t\t\tx = val[i];\t\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\telse if (x > b) {\n\t\t\t\t\t\tbase--;\n\t\t\t\t\t\tx -= pows[i];\n\t\t\t\t\t\tdiff = b-x;\n\n\t\t\t\t\t\t\n\t\t\t\t\t\tcout << i+1 << \" \";\n\n\t\t\t\t\t\tdiff--;\n\n\t\t\t\t\t\tvector bin;\n\t\t\t\t\t\tbin.push_back(1);\n\n\t\t\t\t\t\twhile (diff!=0) {\n\t\t\t\t\t\t\tbin.push_back(diff%2);\n\t\t\t\t\t\t\tdiff /= 2;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t\n\t\t\t\t\t\twhile (bin.size() < i+1) bin.push_back(0);\n\t\t\t\t\t\treverse(bin.begin(), bin.end());\n\n\t\t\t\t\t\t//for (j=0; j<=i; j++) cout << bin[j] << \" \"; cout << endl;\n\n\t\t\t\t\t\tcout << val[0];\n\t\t\t\t\t\tfor (j=1; j<=i; j++){\n\t\t\t\t\t\t\tval[j]+= base*pows[j];\n\t\t\t\t\t\t\tif (bin[j]) {\n\t\t\t\t\t\t\t\tval[j]++;\n\t\t\t\t\t\t\t\tfor (idx=j+1, k=1; idx<=i; idx++, k++)\n\t\t\t\t\t\t\t\t\tval[idx] += pows[k]; \n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfor (j=1; j<=i; j++) cout << \" \" << val[j];\n\t\t\t\t\t\tcout << endl;\n\t\t\t\t\t\tx = val[i];\t\n\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tbase++;\n\t\t\t\t}\n\n\t\t\t\tif (x!=b) cout << \"-1\" << endl;\n\n\t\t\t}\n\n\t\t}\n\t\telse {\n\n\t\t\tcout <\n#define ll long long int\n#define f first\n#define s second\n#define pb push_back\n#define PII pair\nll const MOD = 1000000007;\nll const N = 1000005;\nll const LN = 20;\nll const inf = 8e18;\nusing namespace std;\n\nll n, m, a[N];\n\n\nint main()\n{\n\tios::sync_with_stdio (false);\n\tcin.tie (NULL);\n\tll q;\n\tcin >> q;\n\twhile (q--)\n\t{\n\t\tll a, b, m;\n\t\tcin >> a >> b >> m;\n\t\tif (a == b)\n\t\t{\n\t\t\tcout << 1 << \" \" << a << '\\n';\n\t\t\tcontinue;\n\t\t}\n\t\tif (b <= a + m)\n\t\t{\n\t\t\tcout << 2 << \" \" << a << \" \" << b << '\\n';\n\t\t\tcontinue;\n\t\t}\n\t\tif (m == 1)\n\t\t{\n\t\t\tll pre = a;\n\t\t\tvectorans;\n\t\t\tans.pb (pre);\n\t\t\twhile (1)\n\t\t\t{\n\t\t\t\tll cur = pre + 1;\n\t\t\t\tans.pb (cur);\n\t\t\t\tif (cur >= b)\n\t\t\t\t\tbreak;\n\t\t\t\tpre += cur;\n\t\t\t}\n\t\t\tif (ans.back() != b)\n\t\t\t\tcout << \"-1\\n\";\n\t\t\telse\n\t\t\t{\n\t\t\t\tcout << ans.size() << \" \";\n\t\t\t\tfor (auto w : ans) cout << w << \" \";\n\t\t\t\tcout << '\\n';\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tll len = 2;\n\t\tll cur = 2;\n\t\tll f = 0;\n\t\tfor (len = 2;; len++)\n\t\t{\n\t\t\tif (f) break;\n\t\t\tif (b - cur * a > 0)\n\t\t\t{\n\t\t\t\tll rem = b - cur * a;\n\t\t\t\tif (cur * m >= rem && rem >= cur)\n\t\t\t\t{\n\t\t\t\t\tf = 1;\n\t\t\t\t\tvectortemp;\n\t\t\t\t\trem -= cur;\n\t\t\t\t\tll nw = cur / 2;\n\t\t\t\t\twhile (rem > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tll ok = rem / nw;\n\t\t\t\t\t\tok = min (ok, m - 1);\n\t\t\t\t\t\ttemp.pb (ok);\n\t\t\t\t\t\trem -= ok * nw;\n\t\t\t\t\t\tif (nw != 1)\n\t\t\t\t\t\t\tnw /= 2;\n\t\t\t\t\t}\n\t\t\t\t\tvectorans;\n\t\t\t\t\tll pre = a;\n\t\t\t\t\tans.pb (a);\n\t\t\t\t\tfor (ll i = 0; i < temp.size(); i++)\n\t\t\t\t\t{\n\t\t\t\t\t\tll cur = pre + temp[i] + 1;\n\t\t\t\t\t\tans.pb (cur);\n\t\t\t\t\t\tpre += cur;\n\t\t\t\t\t}\n\t\t\t\t\twhile (1)\n\t\t\t\t\t{\n\t\t\t\t\t\tll cur = pre + 1;\n\t\t\t\t\t\tans.pb (cur);\n\t\t\t\t\t\tif (cur == b) break;\n\t\t\t\t\t\tpre += cur;\n\t\t\t\t\t}\n\t\t\t\t\tcout << ans.size() << \" \";\n\t\t\t\t\tfor (auto w : ans) cout << w << \" \";\n\t\t\t\t\tcout << '\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\telse break;\n\t\t\tcur = 2 * cur;\n\t\t}\n\t\tif (!f)\n\t\t{\n\t\t\tcout << \"-1\\n\";\n\t\t\tcontinue;\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "36f1bd2005a61261107251dd2a39a690", "src_uid": "c9d646762e2e78064bc0670ec7c173c6", "difficulty": 2200.0} {"lang": "GNU C++14", "source_code": "#include\n#define ll long long int\n#define f first\n#define s second\n#define pb push_back\n#define PII pair\nll const MOD = 1000000007;\nll const N = 1000005;\nll const LN = 20;\nll const inf = 8e18;\nusing namespace std;\n\nll n, m, a[N];\n\n\nint main()\n{\n\tios::sync_with_stdio (false);\n\tcin.tie (NULL);\n\tll q;\n\tcin >> q;\n\twhile (q--)\n\t{\n\t\tll a, b, m;\n\t\tcin >> a >> b >> m;\n\t\tif (a == b)\n\t\t{\n\t\t\tcout << 1 << \" \" << a << '\\n';\n\t\t\tcontinue;\n\t\t}\n\t\tif (b <= a + m)\n\t\t{\n\t\t\tcout << 2 << \" \" << a << \" \" << b << '\\n';\n\t\t\tcontinue;\n\t\t}\n\t\tif (m == 1)\n\t\t{\n\t\t\tll pre = a;\n\t\t\tvectorans;\n\t\t\tans.pb (pre);\n\t\t\twhile (1)\n\t\t\t{\n\t\t\t\tll cur = pre + 1;\n\t\t\t\tans.pb (cur);\n\t\t\t\tif (cur >= b)\n\t\t\t\t\tbreak;\n\t\t\t\tpre += cur;\n\t\t\t}\n\t\t\tif (ans.back() != b)\n\t\t\t\tcout << \"-1\\n\";\n\t\t\telse\n\t\t\t{\n\t\t\t\tcout << ans.size() << \" \";\n\t\t\t\tfor (auto w : ans) cout << w << \" \";\n\t\t\t\tcout << '\\n';\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tll len = 2;\n\t\tll cur = 2;\n\t\tll f = 0;\n\t\tfor (len = 2;; len++)\n\t\t{\n\t\t\tif (f) break;\n\t\t\tif (b - cur * a > 0)\n\t\t\t{\n\t\t\t\tll rem = b - cur * a;\n\t\t\t\tif (cur * m >= rem && rem >= cur)\n\t\t\t\t{\n\t\t\t\t\tf = 1;\n\t\t\t\t\tvectortemp;\n\t\t\t\t\trem -= cur;\n\t\t\t\t\tll nw = cur / 2;\n\t\t\t\t\twhile (rem > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tll ok = rem / nw;\n\t\t\t\t\t\tok = min (ok, m - 1);\n\t\t\t\t\t\tif (ok == 0) break;\n\t\t\t\t\t\ttemp.pb (ok);\n\t\t\t\t\t\trem -= ok * nw;\n\t\t\t\t\t\tif (nw != 1)\n\t\t\t\t\t\t\tnw /= 2;\n\t\t\t\t\t}\n\t\t\t\t\tvectorans;\n\t\t\t\t\tll pre = a;\n\t\t\t\t\tans.pb (a);\n\t\t\t\t\tll cur;\n\t\t\t\t\tfor (ll i = 0; i < temp.size(); i++)\n\t\t\t\t\t{\n\t\t\t\t\t\tcur = pre + temp[i] + 1;\n\t\t\t\t\t\tans.pb (cur);\n\t\t\t\t\t\tpre += cur;\n\t\t\t\t\t}\n\t\t\t\t\twhile (cur != b)\n\t\t\t\t\t{\n\t\t\t\t\t\tcur = pre + 1;\n\t\t\t\t\t\tans.pb (cur);\n\t\t\t\t\t\tpre += cur;\n\t\t\t\t\t}\n\t\t\t\t\tcout << ans.size() << \" \";\n\t\t\t\t\tfor (auto w : ans) cout << w << \" \";\n\t\t\t\t\tcout << '\\n';\n\t\t\t\t}\n\t\t\t}\n\t\t\telse break;\n\t\t\tcur = 2 * cur;\n\t\t}\n\t\tif (!f)\n\t\t{\n\t\t\tcout << \"-1\\n\";\n\t\t\tcontinue;\n\t\t}\n\t}\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "145322195a26ac235eeedefd047fd036", "src_uid": "c9d646762e2e78064bc0670ec7c173c6", "difficulty": 2200.0} {"lang": "GNU C++", "source_code": "#include \n#include\nusing namespace std;\npair p,p1;\n\nint main() {\n long long int s,count=0;\n cin>>p.first>>p.second;\n p1.first=0,p1.second=0;\n cin>>s;\n while(s!=count)\n {\n if(p.first==p1.first && p.second==p1.second)\n {\n break;\n }\n if(p.first>p1.first)\n {\n count+=(p.first-p1.first);\n p1.first+=(p.first-p1.first);\n \n }\n else if(p.firstp1.second)\n {\n count+=(p.second-p1.second);\n p1.second+=(p.second-p1.second);\n }\n else if(p.second\nusing namespace std;\nint main()\n{\n int a,b,s;\n while(1){\n cin>>a>>b>>s;\n if(a+b>s)\n cout<<\"No\"<\nusing namespace std;\n\nint main()\n{\n for(;;){\n long long int a,b,s;\n cin>>a>>b>>s;\n\n //int m1=(a+b)<=s;\n //int m2=(s-(a+b))%2==0;\n //int m3=(s-(a+b))%2==1;\n\n int a1=abs(a)+abs(b);\n //int a2=a1\n\n if((s>=a1) && ((s-a1)%2==0)){\n cout<<\"Yes\"<\n\nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\n\n#define mem(a,b) memset(a,b,sizeof(a))\n#define mp make_pair\n#define pii pair\n#define fs first\n#define sc second\n#define VI vector\n#define clr(a) a.clear()\n#define pob pop_back\n#define pub push_back\n#define eps 1E-5\n#define sf scanf\n#define pf printf\n#define all(a) a.begin(),a.end()\n#define allr(a) a.rbegin(),a.rend()\n#define full(a,l) a,a+l\n#define fread(name) freopen(name,\"r\",stdin)\n#define fwrite(name) freopen(name,\"w\",stdout)\n#define sz(a) a.size()\n#define count_one __builtin_popcount\n#define count_onell __builtin_popcountll\n#define fastIO ios_base::sync_with_stdio(false)\n#define PI (acos(-1.0))\n#define linf (1LL<<62)//>4e18\n#define inf (0x7f7f7f7f)//>2e9\n#define fore(x,i) for(typeof((x).begin()) i=(x.begin()); i!=(x).end(); ++i)\n#define rfore(x,i) for(typeof((x).rbegin()) i=(x.rbegin()); i!=(x).rend(); ++i)\n#define For(i,a,b) for(int i=a;i<=b;++i)\n#define rFor(i,a,b) for(int i=a;i>=b;--i)\n\ntemplate T pwr(T b, T p)\n{\n T r=1,x=b;\n while(p)\n {\n if(p&1)r*=x;\n x*=x;\n p=(p>>1);\n }\n return r;\n}\ntemplate T lcm(T a,T b)\n{\n return(a/__gcd(a,b))*b;\n}\ntemplate T sqr(T a)\n{\n return a*a;\n}\ntemplate void xswap (T &x,T &y)\n{\n if(x!=y)\n {\n x^=y;\n y^=x;\n x^=y;\n }\n}\n///~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n//struct tuple{double f,s,t;tuple(){}tuple(double a,double b,double c){f=a,s=b,t=c;}};\n//int cross_product(tuple a,tuple b){int v=a.f*(b.s-b.t)-a.s*(b.f-b.t)+a.t*(b.f-b.s);return (v==0?0:(v>0?+1:-1));}\n//tuple make_vector(tuple s,tuple e){tuple a;a.f=e.f-s.f;a.s=e.s-s.s;a.t=e.t-s.t;return a;}\n///~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ntemplate inline bool isOn(T &mask,int pos)\n{\n return((mask)&(1LL< inline T setf(T mask,int pos)\n{\n return mask=((mask)&(~(1LL< inline T sett(T mask,int pos)\n{\n return mask=((mask)(1LL< inline T flip(T mask,int pos)\n{\n return mask=((mask)^(1LL< double rAng(T a,T b,T c){double d=(sqr(a)+sqr(b)-sqr(c))/(a*b*2);d=(d<-1?-1:(d>1?1:d));return acos(d);}\n///~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ntemplate string to_string(T n)\n{\n ostringstream oss;\n oss<>r;\n return r;\n}\n///~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\ntemplate void put(T1 e)\n{\n cout< void put(T1 e1,T2 e2)\n{\n cout< void put(T1 e1,T2 e2,T3 e3)\n{\n cout< void put(T1 e1,T2 e2,T3 e3,T4 e4)\n{\n cout< void put(T1 e1,T2 e2,T3 e3,T4 e4,T5 e5)\n{\n cout< void putv(vectore1)\n{\n for(int i=0; i void puta(T1 arr[],int l)\n{\n for(int i=0; i bool tk(T1 &e1)\n{\n return(cin>>e1?true:false);\n}\ntemplate bool tk(T1 &e1,T2 &e2)\n{\n return(cin>>e1>>e2?true:false);\n}\ntemplate bool tk(T1 &e1,T2 &e2,T3 &e3)\n{\n return(cin>>e1>>e2>>e3?true:false);\n}\ntemplate bool tk(T1 &e1,T2 &e2,T3 &e3,T4 &e4)\n{\n return(cin>>e1>>e2>>e3>>e4?true:false);\n}\n\n\nlong status[100010041+1];\n\nint prime(long N)\n{\n\n long i, j, sqrtN;\n\n for( i = 2; i <= N; i++ ) status[i] = 0;\n\n sqrtN = long( sqrt((double) N )); // have to check primes up to (sqrt(N))\n\n for( i = 3; i <= sqrtN; i += 2 )\n {\n\n if( status[i] == 0 )\n {\n // so, i is a prime, so, discard all the multiples\n\n // j = i * i, because it\ufffds the first number to be colored\n\n for( j = i * i; j <= N; j += i + i )\n\n status[j] = 1; // status of the multiple is 1\n }\n\n }\n}\n\nint recur(int n1, int n2, int n3)\n{\n printf(\"%d %d %d\\n\",n1,n2,n3);\n if(n1 > n2 && n1 > n3)\n return recur(n1-1, n2, n3);\n else if(n2 > n1 && n2 > n3)\n return recur(n1, n2-1, n3);\n else if(n3 > n1 && n3 > n2)\n return recur(n1, n2, n3-1);\n else\n return (n1 + n2 + n3);\n}\n\nint main()\n{\n\n//#ifdef shihab\n// freopen(\"in.txt\",\"r\",stdin );\n// freopen(\"out.txt\",\"w\",stdout );\n//#endif\n\n//prime(100010041);\n\n long x,y,d;\n\n while( sf(\"%ld %ld %ld\",&x,&y,&d) ==3 )\n {\n\n if( !x && !y && d==2 )\n printf(\"Yes\\n\");\n else\n {\n if( (x+y)==d )\n printf(\"Yes\\n\");\n else\n printf(\"No\\n\");\n }\n\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "87e226ce237a40d7e9685f7f11788d94", "src_uid": "9a955ce0775018ff4e5825700c13ed36", "difficulty": 1000.0} {"lang": "GNU C++0x", "source_code": "#include \nusing namespace std;\n#define TR(i,v) for(__typeof((v).begin())i=(v).begin();i!=(v).end();++i)\n#define DEBUG(x) cout<<#x<<\" = \"<=(int)(a);--i)\n#define CLR(x,y) memset((x),(y),sizeof((x)))\ntypedef long long LL;\ntypedef pair pii;\nint n;\nint L[10],R[10];\ndouble dp[6][6][2],ps;\ndouble gao(int m){\n CLR(dp,0);\n dp[0][0][0]=1;\n FOR(i,0,n-1)\n FOR(j,0,n)\n rep(k,2)\n FOR(d,L[i+1],R[i+1]){\n if(k && d>m)continue;\n dp[i+1][j+(d==m)][k|(d>m)]+=dp[i][j][k]*(1.0/(R[i+1]-L[i+1]+1));\n }\n double s=dp[n][1][1];\n FOR(i,2,n)s+=dp[n][i][0]+dp[n][i][1];\n // if(m<=10){\n // DEBUG(s);\n // }\n ps+=s;\n return s;\n}\nint main(){\n#ifndef ONLINE_JUDGE\n freopen(\"C.in\",\"r\",stdin);\n // freopen(\"out\",\"w\",stdout);\n#endif\n scanf(\"%d\",&n); \n FOR(i,1,n)scanf(\"%d%d\",L+i,R+i);\n double res=0;\n FOR(i,1,10000)res+=i*gao(i);\n printf(\"%.12f\\n\",res);\n // DEBUG(ps);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "568774a97ce9757b24ef5c0edfd391ba", "src_uid": "5258ce738eb268b9750cfef309d265ef", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define mp make_pair\n#define pb push_back\n#define debug( x ) cout << #x << \" = \" << x << endl\n#define all(x) (x).begin() , (x).end()\n#define rall(x) (x).rbegin() , (x).rend()\n#define f(i,a,b) for(int i = a ; i < b ; i++)\n#define EPS 1E-9\n#define INF 1000000000\n\nusing namespace std;\n\ntypedef pair ii ;\ntypedef long long ll ;\ntypedef vector vi;\ntypedef vector vii;\nvii empresas;\nint n;\ndouble dp[6][10010][6][6];\ndouble go(int pos, int secondmax, int c1, int c2){\n if(pos == n){\n if(c1 >= 1 && c2 == 1){\n return 1.0;\n }\n if(c2 == 0 && c1 >= 2){\n return 1.0;\n }\n return 0.0;\n }\n if(dp[pos][secondmax][c1][c2] != -1.0) return dp[pos][secondmax][c1][c2];\n double suma = 0.0;\n for(int i = empresas[pos].first; i <= empresas[pos].second ; i++){\n int a = c1; int b = c2;\n double rango = double(empresas[pos].second - empresas[pos].first + 1);\n if(i == secondmax) {\n a++;\n }\n else if(i > secondmax ) b++;\n\n suma += (1.0/rango)*go(pos+1,secondmax,a,b);\n\n }\n return dp[pos][secondmax][c1][c2] = suma;\n}\n\nint main(){\n cin >> n;\n f(i,0,6) f(j,0,10010) f(k,0,6) f(t,0,6) dp[i][j][k][t] = -1.0;\n int mini = 1e9;\n int maxi = 0;\n f(i,0,n){\n int l, r; cin >> l >> r;\n empresas.pb(mp(l,r));\n mini = min(l,mini);\n maxi = max(r,maxi);\n }\n double res = 0.0;\n for(int i = mini; i <= maxi; i++){\n double val = double(i)*go(0,i,0,0);\n //debug(i);debug(val/i);\n res+=val;\n }\n cout<< fixed<\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nstruct thanks{\n int a,b;\n}p[12];\nmap,double> mp,vp;\ndouble ans;\npair temp,remp;\nint main(){\n int i,j,l,m,n;\n scanf(\"%d\",&n);\n for(i=1;i<=n;i++){\n scanf(\"%d%d\",&p[i].a,&p[i].b);\n }\n for(i=p[1].a;i<=p[1].b;i++){\n mp[make_pair(i,0)]=1.0;//(p[1].b-p[1].a+1)\n }\n for(i=2;i<=n;i++){\n vp.clear();\n map,double>::iterator it;\n for(it=mp.begin();it!=mp.end();it++){\n temp=it->first;\n if(p[i].a<=temp.second){\n if(p[i].b>temp.second) vp[temp]+=(it->second)*(temp.second-p[i].a+1);//(p[i].b-p[i].a+1)\n else vp[temp]+=(it->second)*(p[i].b-p[i].a+1);\n }\n for(j=max(temp.second+1,p[i].a);j<=p[i].b;j++){\n remp=temp;\n if(remp.secondsecond);//(p[i].b-p[i].a+1); \n }\n }\n mp=vp;\n }\n map,double>::iterator it;\n for(it=mp.begin();it!=mp.end();it++){\n ans+=it->first.second*it->second;\n }\n for(i=1;i<=n;i++) ans/=p[i].b-p[i].a+1;\n printf(\"%.15lf\\n\",ans);\n //system(\"pause\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ca1ce356f7de23ad6d9ffddb4aabf744", "src_uid": "5258ce738eb268b9750cfef309d265ef", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define mod 1000000007\n#define LL long long\n\nusing namespace std;\n\ntypedef pair PII;\n\nconst int N = 1e5 + 10;\nconst int INF = 1e9 + 7;\nconst double eps = 1e-7;\n\nint a[11], b[11];\ndouble dp[1 << 6][1 << 6][11111];\nint n;\nbool no_intersect(int m1, int m2) {\n\tif(m1 == 0)\n\t\treturn false;\n\tif((m1 & m2) > 0)\n\t\treturn false;\n\treturn true;\n}\n\ndouble find_intersect(int m1, int L) {\n\tdouble prob = 1.0;\n\tfor(int i = 0; i < n; i++) {\n\t\tif((1 << i) & m1) {\n\t\t\tif(b[i] < L || a[i] > L) \n\t\t\t\treturn 0.0;\n\t\t\tprob *= 1.0 / (1.0 * (b[i] - a[i] + 1));\n\t\t}\n\t}\n\treturn prob;\n}\t\n\ndouble find_range(int m1, int L) {\n\tdouble prob = 1.0;\n\tint maxA = 0, minB = 11111111;\n\tfor(int i = 0; i < n; i++) {\n\t\tif((1 << i) & m1) {\n\t\t\tmaxA = max(a[i], maxA);\n\t\t\tminB = min(b[i], minB);\n\t\t}\n\t}\n\tif(L < maxA || L > minB)\n\t\treturn 0.0;\n\telse {\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tif((1 << i) & m1) {\n\t\t\t\tprob = prob * (1.0) / ((b[i] - a[i] + 1.0) * 1.0);\n\t\t\t}\t\n\t\t}\n\t}\n\treturn prob;\t\n}\n\ndouble find_range1(int m1, int L) {\n\tdouble prob = 1.0;\n\tint maxA = 0, minB = 11111111;\n\tfor(int i = 0; i < n; i++) {\n\t\tif((1 << i) & m1) {\n\t\t\tmaxA = max(a[i], maxA);\n\t\t\tminB = min(b[i], minB);\n\t\t}\n\t}\n\tif(L + 1 > minB)\n\t\treturn 0.0;\n\tmaxA = max(maxA, L + 1);\n\tif(maxA > minB) \n\t\treturn 0.0;\n\telse {\n\t\tfor(int i = 0; i < n; i++) {\n\t\t\tif((1 << i) & m1) {\n\t\t\t\tprob = prob * (1.0 * (minB - maxA + 1.0)) / ((b[i] - a[i] + 1.0) * 1.0);\n\t\t\t}\t\n\t\t}\n\t}\n\treturn prob;\n}\n\ndouble rest_all(int m1, int m2, int L) {\n\tdouble prob = 1.0;\n\tfor(int i = 0; i < n; i++) {\n\t\tif(((1 << i) & m1) == 0 && ((1 << i) & m2) == 0){\n\t\t\tif(a[i] >= L)\n\t\t\t\treturn 0.0;\n\t\t\telse\n\t\t\t\tprob *= ((min(b[i], L - 1) - a[i] + 1.0) * 1.0) / ((b[i] - a[i] + 1.0) * 1.0);\n\t\t}\n\t}\n\treturn prob;\t\t\n}\n\nvoid solve(){\n\tmemset(dp, 0, sizeof dp);\n\tcin >> n;\n\tfor(int i = 0; i < n; i++) {\n\t\tcin >> a[i] >> b[i];\n\t}\n\tdouble ans = 0.0;\n\tfor(int mask1 = 1; mask1 < (1 << n); mask1++) {\n\t\tfor(int mask2 = 1; mask2 < (1 << n); mask2++) {\n\t\t\tif(no_intersect(mask1, mask2) == false)\n\t\t\t\tcontinue;\n\t\t\tfor(int L = 1; L <= 10000; L++) {\n\t\t\t\tif(mask1 == (1 << n) - 1 || __builtin_popcount(mask1) > 1) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tans += (find_range1(mask1, L) * find_intersect(mask2, L) * rest_all(mask1, mask2, L) * L);\n\t\t\t}\n\t\t}\n\t}\n\tfor(int mask1 = 1; mask1 < (1 << n); mask1++) {\n\t\tfor(int L = 1; L <= 10000; L++) {\n\t\t\tif(mask1 == (1 << n) - 1 || __builtin_popcount(mask1) > 1) {\n\t\t\t\tans += (find_range(mask1, L) * rest_all(mask1, 0, L) * L);\n\t\t\t}\n\t\t}\n\t}\n\tprintf(\"%.6f\\n\", ans);\n\treturn;\n}\n\nint main(){\n\tios_base::sync_with_stdio(false); \n\tcin.tie(NULL);\n solve();\n return 0;\n\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ebb8c28fc518e1a31c536f52d9b799cb", "src_uid": "5258ce738eb268b9750cfef309d265ef", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\nusing namespace __gnu_pbds;\nusing namespace std;\n\ntemplate\nusing ordered_set=tree,rb_tree_tag,tree_order_statistics_node_update>;\n\n#define ll long long\n#define ull unsigned long long\n#define __ ios_base::sync_with_stdio(0);cin.tie();cout.tie();\n\nstring s,s1,s2,s3,s4,s5;\nll n,m,x,y,z;\nll arr[500010];\nll brr[500010];\nvectorv,v1;\nsetst;\n\n\nvoid memset_ll(ll a[], ll v, ll n)\n{\n for(ll i=0; i= l)\n {\n ll mid = l + (r - l) / 2;\n if (arr[mid] == x)\n return mid;\n if (arr[mid] > x)\n return bsearch(arr, l, mid - 1, x);\n return bsearch(arr, mid + 1, r, x);\n }\n return -1;\n}\n\nstatic int compare1 (const void * a, const void * b)\n{\n if (*(double*)a > *(double*)b)\n return 1;\n else if (*(double*)a < *(double*)b)\n return -1;\n else\n return 0;\n}\n\nvoid q_sort_d(double a[], ll n)\n{\n qsort(a, n, sizeof(double), compare1);\n}\n\nstring trans_upper(string ss)\n{\n transform(ss.begin(),ss.end(),ss.begin(), ::toupper);\n return ss;\n}\n\nll power(ll a, ll b)\n{\n ll pow = 1;\n while ( b )\n {\n if ( b & 1 )\n {\n pow = pow * a;\n --b;\n }\n a = a*a;\n b = b/2;\n }\n return pow;\n}\n\nint main()\n{\n __\n ll t,h,i,j,k,l,p,q,r;\n ll d=0,e=0,f=0,g=0;\n ll dd=0,uu=0,rr=0,lll=0;\n ll ans=0,sum=0,temp=0;\n ll x1,y1,x2,y2;\n\n double p1,p2,p3,p4,p5;\n double pp=0.0,ppp=1.0;\n double pi =3.141592654;\n\n cin>>x>>y>>z>>r;\n ll a[100000];\n t=r;\n a[0]=(x*r+y)%z;\n for(i=1; i<100000; i++)\n {\n r=a[i-1];\n a[i]=(x*r+y)%z;\n }\n for(k=1; k<100000; k++)\n {\n j=99990;\n if(a[j]==a[j-k]&&a[j-1]==a[j-1-k])\n {\n cout<\nusing namespace std;\nlong long ar[100000001];\nmain()\n{\n long long m, r0, i=0, t;\n int a, b;\n cin>>a>>b>>m>>r0;\n ar[0]=a;\n while(i<100000000)\n {\n ar[i]=(ar[i-1]*a+b)%m;\n\n if(i>100000 and ar[100000]==ar[i]){t=i-100000;break;}i++;\n }\n\n cout<\n#include \n#include \nusing namespace std;\nvector mrSequence;\n\nint main(int argc, char** argv) {\n int mrA; int mrB; int mrsM; int mrR0;\n int mrResult;\n int mrSequenceIterator;\n cin >> mrA; cin >> mrB; cin >> mrsM; cin >> mrR0;\n mrSequence.push_back(mrR0);\n for (mrSequenceIterator = 1; 1 == 1; mrSequenceIterator++) {\n mrSequence.push_back((mrA * mrSequence[mrSequenceIterator-1] + mrB) % mrsM); \n if (mrSequenceIterator > 10) {\n if (mrSequence[mrSequenceIterator] == mrSequence[mrSequenceIterator-1]) {\n cout << '1';\n break;\n };\n if (mrSequence[mrSequenceIterator] == mrSequence[mrSequenceIterator-2]) {\n cout << '2';\n break;\n };\n if (mrSequence[mrSequenceIterator] == mrSequence[mrSequenceIterator-3]) {\n cout << '3';\n break;\n };\n if (mrSequence[mrSequenceIterator] == mrSequence[mrSequenceIterator-4]) {\n cout << '4';\n break;\n };\n if (mrSequence[mrSequenceIterator] == mrSequence[mrSequenceIterator-5]) {\n cout << '5';\n break;\n };\n if (mrSequence[mrSequenceIterator] == mrSequence[mrSequenceIterator-6]) {\n cout << '6';\n break;\n };\n if (mrSequence[mrSequenceIterator] == mrSequence[mrSequenceIterator-7]) {\n cout << '7';\n break;\n };\n if (mrSequence[mrSequenceIterator] == mrSequence[mrSequenceIterator-8]) {\n cout << '8';\n break;\n };\n if (mrSequence[mrSequenceIterator] == mrSequence[mrSequenceIterator-9]) {\n cout << '9';\n break;\n };\n if (mrSequence[mrSequenceIterator] == mrSequence[mrSequenceIterator-10]) {\n cout << '10';\n break;\n };\n };\n };\n return 0;\n};", "lang_cluster": "C++", "compilation_error": false, "code_uid": "97560c644567b07e91f6deb40710622c", "src_uid": "9137197ee1b781cd5cc77c46f50b9012", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "#include\nusing namespace std;\n\nbool check(vector v,int m){\n\tfor (int i=v.size()-2;i>=max(i-m,0);i--){\n\t\tif (v[v.size()-1]==v[i]){\n\t\t\tcout< v){\n\tfor (int i=0;i>a>>b>>m>>r;\n\tint temp=r;\n\tvector v;\n\twhile(true){\n\t\tint e;\n\t\te = (a*temp+b)%m;\n\t\tv.push_back(e);\n\t\t//print(v);\n\t\tif ((a*temp+b)>=m){\n\t\t\tif (check(v,m))\n\t\t\t\tbreak;\n\t\t}\n\t\ttemp=e;\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fc3bc6fd5a07367d28a3c174f5e9f9fd", "src_uid": "9137197ee1b781cd5cc77c46f50b9012", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "#include\r\n#define N 100005\r\nusing namespace std;\r\nint n,m,x;\r\nstruct node{\r\n\tint id,x;\r\n}h[N]; \r\nbool cmp(node x,node y){\r\n\treturn x.x\n#include\n#include\nusing namespace std;\n\nconst int N=410;\n\nlong long n,m;\nlong long f[N][N];\nlong long C[N][N];\n\ninline void init()\n{\n\tfor(int i=0;i<=N;++i)\n\t{\n\t\tC[i][0]=1;\n\t\tfor(int j=1;j<=i;++j)\n\t\t{\n\t\t\tC[i][j]=(C[i-1][j]%m+C[i-1][j-1]%m)%m;\n\t\t}\n\t}\n}\n\ninline long long ksm(long long a,long long b,long long p)\n{\n\tlong long ans=1;\n\ta%=p;\n\twhile(b)\n\t{\n\t\tif(b&1) ans=ans*a%p;\n\t\ta=a*a%p;\n\t\tb>>=1;\n\t}\n\treturn ans;\n}\n\nint main()\n{\n\tscanf(\"%lld%lld\",&n,&m);\n\tinit();\n\tfor(int i=1;i<=n;++i)\n\t{\n\t\tf[i][i]=ksm(2,i-1,m);\n\t\tfor(int j=0;j<=i;++j)\n\t\t{\n\t\t\tfor(int k=1;k+i+1<=n;++k)\n\t\t\t{\n\t\t\t\tf[i+1+k][j+k]+=f[i][j]*ksm(2,k-1,m)*C[j+k][k]%m;\n\t\t\t\tf[i+1+k][j+k]%=m;\n\t\t\t}\n\t\t}\n\t}\n\tlong long ans=0;\n\tfor(int i=0;i<=n;++i)\n\t{\n\t\tans+=f[n][i];\n\t\tans%=m;\n\t}\n\tprintf(\"%lld\\n\",ans);\n\treturn 0;\t\n} ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4f79f75c5e44ee5ffdc0285dccc40781", "src_uid": "4f0e0d1deef0761a46b64de3eb98e774", "difficulty": 2200.0} {"lang": "GNU C++20 (64)", "source_code": "#include\r\n//#define int long long\r\n#define ll long long\r\n#define ljc 998244353\r\n//#define ljc 1000000007\r\n#define gc getchar\r\n#define mp make_pair\r\n#define pii pair\r\n#define pib pair\r\n#define fi first\r\n#define se second\r\ntypedef unsigned long long ull;\r\nusing namespace std;\r\ninline ll read(){\r\n\tll x=0,f=1;char ch=gc();\r\n\twhile (!isdigit(ch)){if (ch=='-') f=-1;ch=gc();}\r\n\twhile (isdigit(ch)){x=x*10ll+ch-'0';ch=gc();}\r\n\treturn x*f;\r\n}\r\ninline void file(){\r\n//\tfreopen(\".in\",\"w\",stdout);\r\n\tfreopen(\".in\",\"r\",stdin);\r\n\tfreopen(\".out\",\"w\",stdout);\r\n}\r\nbitset<100000022> vis;\r\nint n,tot;\r\nll A,B,C,D;\r\nint main(){\r\n//\tfile();\r\n\tn=read();\r\n\tA=read(),B=read(),C=read(),D=read();\r\n\tll _=0;\r\n\tfor (int i=2;i<=n;i++){\r\n\t\tif (i==2||i==3||(i%2!=0&&i%3!=0&&i%5!=0&&!vis[i%6==1?2*(i/6):2*(i/6)+1])){\r\n\t\t\tll F=1ll*A*i*i*i+1ll*B*i*i+1ll*C*i+D;\r\n\t\t\tfor (ll j=i;j<=n;j=j*i){\r\n\t\t\t\t_+=F*(n/j);\r\n\t\t\t}\r\n//\t\t\tcout<\r\nusing namespace std;\r\ntypedef long long ll;\r\nll read()\r\n{\r\n\tll x=0;\r\n\tint f=1;\r\n\tchar ch=getchar();\r\n\tfor(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-1;\r\n\tfor(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';\r\n\treturn x*f;\r\n}\r\nconst int maxM=50010;\r\nint n,m;\r\nnamespace op\r\n{\r\n\tint op[maxM];\r\n\tll l[maxM],r[maxM];\r\n};\r\nvector> vec;\r\nstruct SGT\r\n{\r\n\t#define SIZE (8000010)\r\n\tint root,cnt_node,ch[SIZE][2],f[SIZE],nmsl[SIZE];\r\n\tstruct SET\r\n\t{\r\n\t\tint f[SIZE],siz[SIZE];\r\n\t\tvoid new_node(int nod)\r\n\t\t{\r\n\t\t\tf[nod]=nod;\r\n\t\t\tsiz[nod]=1;\r\n\t\t}\r\n\t\tint get_f(int x)\r\n\t\t{\r\n\t\t\treturn f[x]==x?x:f[x]=get_f(f[x]);\r\n\t\t}\r\n\t\tvoid merge(int x,int y)\r\n\t\t{\r\n\t\t\tx=get_f(x);\r\n\t\t\ty=get_f(y);\r\n\t\t\tif(siz[x]0)\r\n\t\t{\r\n\t\t\ts.merge(nod,nod_);\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif(ch[nod][0]) add(ch[nod][0],nod_);\r\n\t\tif(ch[nod][1]) add(ch[nod][1],nod_);\r\n\t}\r\n\tvoid modify(int &nod,ll l,ll r,int d,ll x,int fa)\r\n\t{\r\n\t\tif(!nod) nod=new_node(fa);\r\n\t\tif(l<=x&&r>=x+(1ll<=d;i--)\r\n\t\t\t{\r\n\t\t\t\tint nod_=root,tmp=0;\r\n\t\t\t\tfor(int j=n-1;j>=d;j--)\r\n\t\t\t\t{\r\n\t\t\t\t\tif(nmsl[nod_]==1) s.merge(nod_,nod);\r\n\t\t\t\t\tif(nmsl[nod_]==2) tmp=nod_;\r\n\t\t\t\t\tnod_=ch[nod_][j!=i?((x>>j)&1):!((x>>j)&1)];\r\n\t\t\t\t\tif(!nod_) break;\r\n\t\t\t\t}\r\n\t\t\t\tif(nod_)\r\n\t\t\t\t{\r\n\t\t\t\t\tif(tmp!=0)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ts.merge(tmp,nod);\r\n\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tadd(nod_,nod);\r\n\t\t\t\t\tif(!nmsl[nod_])\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tnmsl[nod_]=2;\r\n\t\t\t\t\t\ts.merge(nod_,nod);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tnmsl[nod]=1;\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tif(l<=x+(1ll<<(d-1))-1) modify(ch[nod][0],l,r,d-1,x,nod);\r\n\t\tif(r>=x+(1ll<<(d-1))) modify(ch[nod][1],l,r,d-1,x+(1ll<<(d-1)),nod);\r\n\t}\r\n\tvoid modify(ll l,ll r)\r\n\t{\r\n\t\tmodify(root,l,r,n,0,0);\r\n\t}\r\n\tint query(int nod,ll x,int d)\r\n\t{\r\n\t\tif(!nod) return 0;\r\n\t\tif(nmsl[nod]>0) return s.get_f(nod);\r\n\t\treturn query(ch[nod][(x>>(d-1))&1],x,d-1);\r\n\t}\r\n\tint query(ll x)\r\n\t{\r\n\t\treturn query(root,x,n);\r\n\t}\r\n}sgt;\r\nint ans[maxM];\r\nint main()\r\n{\r\n\tn=read();\r\n\tm=read();\r\n\tint tmp=0;\r\n\tfor(int i=1;i<=m;i++)\r\n\t{\r\n\t\tchar op[10];\r\n\t\tscanf(\"%s\",op);\r\n\t\top::op[i]=(op[0]=='a');\r\n\t\tif(op::op[i]==1) tmp=i;\r\n\t\top::l[i]=read();\r\n\t\top::r[i]=read();\r\n\t}\r\n\tm=tmp;\r\n\tfor(int i=1;i<=m;i++) if(op::op[i]==0) vec.push_back({op::l[i],op::r[i]});\r\n\tsort(vec.begin(),vec.end());\r\n\tll last=0;\r\n\tfor(auto i:vec)\r\n\t{\r\n\t\tif(last<=i.first-1) sgt.modify(last,i.first-1);\r\n\t\tlast=i.second+1;\r\n\t}\r\n\tif(last<=(1ll<=1;i--)\r\n\t{\r\n\t\tif(op::op[i]==0) sgt.modify(op::l[i],op::r[i]);\r\n\t\tif(op::op[i]==1)\r\n\t\t{\r\n\t\t\tint x=sgt.query(op::l[i]),y=sgt.query(op::r[i]);\r\n\t\t\tans[i]=(x!=0&&y!=0&&x==y);\r\n\t\t}\r\n\t}\r\n\tfor(int i=1;i<=m;i++) if(op::op[i]==1) printf(\"%d\\n\",ans[i]);\r\n\treturn 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "eb2e4128d14d82b87c706c2bf12a2fe5", "src_uid": "4f0e0d1deef0761a46b64de3eb98e774", "difficulty": 2200.0} {"lang": "MS C++ 2017", "source_code": "#define _CRT_SECURE_NO_WARNINGS\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\nusing namespace std;\r\n\r\ntypedef unsigned long long ll;\r\ntypedef long double ld;\r\ntypedef double dd;\r\n\r\nconst ll INF = 10e8;\r\nconst ll mod = 10e8 + 7;\r\n\r\nll bin(int a, ll b) {\r\n if (b == 1) {\r\n return a;\r\n }\r\n if (b % 2 == 0) {\r\n ll c = bin(a, b / 2);\r\n return (c * c) % mod;\r\n }\r\n else {\r\n return (a * bin(a, b - 1)) % mod;\r\n }\r\n}\r\n\r\nint main() {\r\n#ifndef ONLINE_JUDGE\r\n //freopen(\"input.txt\", \"r\", stdin);\r\n#endif\r\n int k;\r\n cin >> k;\r\n cout << (6 * bin(4, pow(2, k) - 2)) % mod;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7f0a44a773de422a0dd32c6f5cd2044e", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "#include \r\n#define ll long long\r\n#define ld long double\r\n#define sp ' '\r\n#define en '\\n'\r\nusing namespace std;\r\nint mod = (1 ? 1e9 + 7 : 998244353);\r\nconst int N = 5e5 + 5;\r\nconst int M = 20 * N;\r\nll exp(ll b) {\r\n if (b == 1) return 4;\r\n ll ans = 1;\r\n if (b % 2 == 1) ans = 4;\r\n ll c = exp(b / 2);\r\n ans = (ll) ans * c % mod;\r\n ans = (ll) ans * c % mod;\r\n return ans;\r\n}\r\nint main() {\r\n ios::sync_with_stdio(false);\r\n cin.tie(0);\r\n cout.tie(0);\r\n cerr.tie(0);\r\n int k;\r\n cin >> k;\r\n ll ans = 6;\r\n ll b = (1LL << k) - 2;\r\n ll c = exp(b);\r\n ans = (ll) (ans * c) % mod;\r\n cout << ans << en;\r\n return 0;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "71da46b4b1a39c83c5b25e67245a6db9", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "//Be like Errichto\r\n//la 1 fan liquid, hay code theo cach cua ban :lmao:\r\n\r\n#include\r\n \r\n#define int long long\r\n#define ull unsigned long long\r\n#define fi first\r\n#define se second\r\n#define all(x) (x).begin(), (x).end()\r\n#define pb push_back\r\n#define pii pair\r\n \r\n#define FOR(i,a,b) for(int i=1;i<=b;i++)\r\n#define FOD(i,a,b) for(int i=a;i>=b;i--)\r\n \r\n#define MOD 1e7+7\r\n#define MOD1 1e9+9\r\n#define PI 3.1415926535897932384626433832795\r\n\r\n#define onetap int t; cin>>t; while(t--)\r\n#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\r\n\r\n#define taskname \"\"\r\nusing namespace std;\r\n\r\nconst int maxn=5e5+10;\r\nconst int mod=1e9+7;\r\nconst int LINF = 0x3f3f3f3f3f3f3f3f;\r\n\r\nint n;\r\nint mu(int a, int b)\r\n{\r\n\tif(b==1) return a;\r\n\telse\r\n\t{\r\n\t\tif(b%2==0) return (mu(a, b/2)%mod * mu(a, b/2)%mod + mod*mod) % mod;\r\n\t\telse return (mu(a, b/2)%mod * mu(a, b/2)%mod * a+ mod*mod) % mod;\r\n\t}\r\n}\r\n\r\nsigned main()\r\n{\r\n\tif(ifstream(taskname\".inp\")) \r\n\t{\r\n freopen(taskname\".inp\", \"r\", stdin);\r\n freopen(taskname\".out\", \"w\", stdout);\r\n }\r\n speed\r\n\tint n;\r\n\tcin>>n;\r\n\tn=mu(2, n)-1;\r\n\tcout<<(6 * mu(4, n-1))%mod;\r\n\treturn 0;\r\n/* /\\_/\\\r\n (= ._.)\r\n / >0 \\>1 BRUH BRUH LMAO LMAO\r\n*/\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c5a89cf66b35a2f7d0578f4a8051b414", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0} {"lang": "MS C++ 2017", "source_code": "#define _CRT_SECURE_NO_WARNINGS\r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include \r\nusing namespace std;\r\n\r\ntypedef unsigned long long ll;\r\ntypedef long double ld;\r\ntypedef double dd;\r\n\r\nconst ll INF = 10e8;\r\nconst ll mod = 10e8 + 7;\r\n\r\nll bin(int a, int b) {\r\n if (b == 1) {\r\n return a;\r\n }\r\n if (b % 2 == 0) {\r\n ll c = bin(a, b / 2);\r\n return (c * c) % mod;\r\n }\r\n else {\r\n return (a * bin(a, b - 1)) % mod;\r\n }\r\n}\r\n\r\nint main() {\r\n#ifndef ONLINE_JUDGE\r\n //freopen(\"input.txt\", \"r\", stdin);\r\n#endif\r\n int k;\r\n cin >> k;\r\n cout << (6 * bin(4, pow(2, k) - 2)) % mod;\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3f533a0e27e90b2698e62b4eb2cd45d4", "src_uid": "5144b9b281ea4087d8334d91c3c8bda4", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "#include \n\n\n\nusing namespace std;\nint a[10], x, n;\n\nint main(void) {\n scanf(\"%d\", &n);\n for (int i = 0; i < n; i++) {\n for (int j = 0; j < 6; j++) {\n scanf(\"%d\", &x);\n a[x]++;\n }\n\n }\n \n// if (a[0] == 0) {\n// printf(\"0\");\n// return 0;\n// }\n \n for (int i = 1; i < 10; i++) {\n if (a[i] == 0) {\n printf(\"%d\", i - 1);\n return 0;\n }\n }\n for (int i = 1; i < 10; i++) {\n if (a[i] == 1) {\n printf(\"%d\", i * 10 + i - 1);\n break;\n }\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7ce86693dee842f7f950441ba8d93840", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nint v[10];\nint main(){\n \n int n;\n scanf(\"%d\",&n);\n\n for (int i = 0; i < n; ++i){\n for (int j = 0; j < 6; ++j){\n int x; \n scanf(\"%d\",&x);\n v[x]++;\n }\n }\n \n\n for (int i = 1; i <= 10000; ++i){\n \n int x = i;\n int b[10];\n memset(b,0,sizeof b);\n while(x > 0){\n int p = x % 10;\n x /= 10;\n b[p]++;\n }\n for (int j = 0; j < 10; ++j){\n if(v[j] >= b[j]) continue;\n cout << i - 1 << \"\\n\";\n return 0;\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8182f15732a4faba462e5ddead1b4920", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nbool check(int number, int* mas, vector v) {\n\tint count = 0, count2 = 0, count3 = 0;\n\tfor (int i = 0; number != 0; ++i) {\n\t\tmas[i] = number % 10;\n\t\tnumber /= 10;\n\t\tcount++;\n\t}\n\n\tint index = 0;\n\tbool flag = 0;\n\twhile (1) {\n\t\tif (count == count2) {\n\t\t\treturn 1;\n\t\t}\n\t\telse if (count3 >= 18) {\n\t\t\treturn 0;\n\t\t}\n\n\t\tfor (int i = 0; i < v.size(); ++i) {\n\t\t\tif (v[i] == mas[index]) {\n\t\t\t\tindex++;\n\t\t\t\tflag = 1;\n\t\t\t\tv[i] = -1;\n\n\t\t\t\tcount2++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (flag == 1) {\n\t\t\tflag = 0;\n\t\t}\n\t\telse {\n\t\t\tbreak;\n\t\t}\n\n\t\tcount3++;\n\t}\n\n\treturn 0;\n}\n\nint main() {\n\tint n;\n\tcin >> n;\n\n\tvector num(n * 6);\n\n\tfor (int i = 0; i < n * 6; ++i) {\n\t\tcin >> num[i];\n\t}\n\n\tsort(num.begin(), num.end());\n\n\tint count = 1;\n\tint* temp = new int[18];\n\n\twhile (check(count, temp, num) == true) {\n\t\tcount++;\n\t}\n\n\tcout << count - 1;\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9712efb96137875a46e887ed2b40f527", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.0} {"lang": "GNU C++17", "source_code": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\ntypedef long long ll;\ninline ll read(){\n\tll x=0,f=1;\n\tchar c=getchar();\n\twhile(c<'0'||c>'9'){\n\t\tif(c=='-')f=-1;\n\t\tc=getchar();\n\t}\n\twhile(c>='0'&&c<='9'){\n\t\tx=(x<<1)+(x<<3)+c-'0';\n\t\tc=getchar();\n\t}\n\treturn x*f;\n}\nint cnt[10],n,vis[10];\ninline bool check(int x){\n\tstatic int p[10];\n\tmemset(p,0,sizeof(p));\n\twhile(x)++p[x%10],x/=10;\n\tfor(int i=0;i<10;++i){\n\t\tif(p[i]>cnt[i])return false;\n\t}\n\treturn true;\n}\nint main(){\n\tn=read();\n\tfor(int i=1;i<=3;++i){\n\t\tmemset(vis,0,sizeof(vis));\n\t\tfor(int j=0;j<6;++j){\n\t\t\tvis[read()]=1;\n\t\t}\n\t\tfor(int x=0;x<10;++x){\n\t\t\tcnt[x]+=vis[x];\n\t\t}\n\t}\n\tfor(int i=1;;++i){\n\t\tif(!check(i))return !printf(\"%d\\n\",i-1);\n\t}\n\treturn 0;\n}\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c37679730917b27fcdcaf60b1da9e09b", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n#define Fopen freopen(\"_in.txt\",\"r\",stdin); freopen(\"_out.txt\",\"w\",stdout);\n#define LL long long\n#define ULL unsigned LL\n#define fi first\n#define se second\n#define pb push_back\n#define lson l,m,rt<<1\n#define rson m+1,r,rt<<1|1\n#define max3(a,b,c) max(a,max(b,c))\n#define min3(a,b,c) min(a,min(b,c))\ntypedef pair pll;\nconst int INF = 0x3f3f3f3f;\nconst LL mod = (int)1e9+7;\nconst int N = 2e5 + 100;\nchar str[N];\nchar cmp[N];\nLL ans = 0;\nLL tmp = 0;\nLL n = 0;\nLL base = 1;\nLL b = 1;\nLL t;\nvector vc;\nint main(){\n scanf(\"%s\", cmp);\n int len1 = strlen(cmp);\n for(int i = 0; i < len1; i++){\n n = n*10 + cmp[i] - '0';\n }\n scanf(\"%s\", str);\n int len2 = strlen(str);\n for(int i = len2-1; i >= 0;){\n int j = i - len1 + 1;\n if(j < 0) j = 0;\n //cout << j + len1 - 1 << \"*\" << i << endl;\n //cout << strcmp(cmp,str+j) << endl;\n if((j+len1-1 == i && strcmp(cmp,str+j) <= 0) || str[j] == '0'){\n j++;\n while(str[j] == '0' && j < i) j++;\n t = 0;\n for(int k = j; k <= i; k++)\n t = t*10 + str[k] - '0';\n vc.push_back(t);\n //cout << i << ' ' << j << endl;\n }\n else {\n t = 0;\n for(int k = j; k <= i; k++)\n t = t*10 + str[k] - '0';\n vc.push_back(t);\n //cout << \"*\" << endl;\n }\n i = j - 1;\n }\n b = 1;\n ans = 0;\n for(int i = 0; i < vc.size(); i++){\n //cout << vc[i] << ' ';\n ans += b*vc[i];\n b*=n;\n }\n printf(\"%I64d\", ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8c8f07d94fc1ea40310f9304148cce34", "src_uid": "be66399c558c96566a6bb0a63d2503e5", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#include\n#define bug(x) cout<<\"bug \"< v;\n\nll toint(string t){\n ll a;\n stringstream st;\n st<>a;\n return a;\n}\n\nint main(){\n cin>>n>>s;\n int len=n.size();\n int idx=s.size()-1;\n while(idx>=0){\n string tmp=\"\";\n if(idx-len+1>=0){\n int f=0;\n for(int i=idx-len+1;i<=idx;i++){\n if(s[i]!='0') f=1;\n if(f==0&&s[i]=='0') continue;\n tmp=tmp+s[i];\n }\n if(tmp.size()==n.size()&&tmp>n){\n tmp=\"\";\n int f=0;\n for(int i=idx-len+2;i<=idx;i++){\n if(s[i]!='0') f=1;\n if(f==0&&s[i]=='0') continue;\n tmp=tmp+s[i];\n }\n v.push_back(tmp);\n idx=idx-tmp.size();\n }\n else{\n v.push_back(tmp);\n idx=idx-tmp.size();\n }\n }\n else{\n for(int i=idx;i>=0;i--){\n tmp=s[i]+tmp;\n }\n v.push_back(tmp);\n idx=-1;\n }\n }\n ll ans=0;\n for(int i=0;i\nusing namespace std;\n#define Fopen freopen(\"_in.txt\",\"r\",stdin); freopen(\"_out.txt\",\"w\",stdout);\n#define LL long long\n#define ULL unsigned LL\n#define fi first\n#define se second\n#define pb push_back\n#define lson l,m,rt<<1\n#define rson m+1,r,rt<<1|1\n#define max3(a,b,c) max(a,max(b,c))\n#define min3(a,b,c) min(a,min(b,c))\ntypedef pair pll;\nconst int INF = 0x3f3f3f3f;\nconst LL mod = (int)1e9+7;\nconst int N = 2e5 + 100;\nchar str[N];\nchar cmp[N];\nLL ans = 0;\nLL tmp = 0;\nLL n = 0;\nLL base = 1;\nLL b = 1;\nLL t;\nvector vc;\nint main(){\n scanf(\"%s\", cmp);\n int len1 = strlen(cmp);\n for(int i = 0; i < len1; i++){\n n = n*10 + cmp[i] - '0';\n }\n scanf(\"%s\", str);\n if(str[0] == '0'){\n cout << 0 << endl;\n return 0;\n }\n int len2 = strlen(str);\n for(int i = len2-1; i >= 0;){\n int j = i - len1 + 1;\n if(j < 0) j = 0;\n if((j+len1-1 == i && strcmp(cmp,str+j) <= 0) || str[j] == '0'){\n j++;\n while(str[j] == '0' && j < i) j++;\n t = 0;\n for(int k = j; k <= i; k++)\n t = t*10 + str[k] - '0';\n vc.push_back(t);\n }\n else {\n t = 0;\n for(int k = j; k <= i; k++)\n t = t*10 + str[k] - '0';\n vc.push_back(t);\n }\n i = j - 1;\n }\n b = 1;\n ans = 0;\n for(int i = 0; i < vc.size(); i++){\n ans += b*vc[i];\n b*=n;\n }\n printf(\"%I64d\", ans);\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "88524b2b1b3c114fce95041588468b4a", "src_uid": "be66399c558c96566a6bb0a63d2503e5", "difficulty": 2000.0} {"lang": "GNU C++11", "source_code": "#pragma warning (disable:4996)\n#include \n#include \n#include \nusing namespace std;\nusing LL = int64_t;\nusing pii = pair;\nconst double PI = 2 * asin(1);\n\nLL g_n, g_cnt;\nstring s;\ndequedll_num;\ndeque>ddll_ans;\n\nvoid pretreat() {}\nvoid input() {\n getchar();\n getline(cin, s);\n dll_num.clear(), ddll_ans.clear();\n for(int i = 0; i < s.size(); ++i) {\n if('0' <= s[i] && s[i] <= '9') {\n dll_num.push_back(s[i] - '0');\n }\n }\n while(dll_num.front() == 0) {\n dll_num.pop_front();\n }\n}\nLL get_num(deque&dn) {\n LL num = 0;\n for(int i = 0; i < dn.size(); ++i) {\n num = num * 10 + dn[i];\n }\n return num;\n}\nint get_bit(LL num) {\n int cnt = 0;\n while(num > 0) {\n ++cnt;\n num /= 10;\n }\n return cnt;\n}\nvoid solve() {\n if(dll_num.empty()) {\n puts(\"0\");\n return;\n }\n g_cnt = get_bit(g_n);\n //cout << g_cnt << endl;\n int i = dll_num.size() - 1;\n dequetdll;\n while(i >= 0) {\n int j = i;\n tdll.clear();\n if(i >= 0 && dll_num[i] == 0) {\n tdll.clear();\n j = i;\n while(j >= 0 && dll_num[j] == 0) {\n tdll.emplace_back(0);\n --j;\n }\n j = i;\n while(tdll.size() >= g_cnt) {\n ddll_ans.emplace_front();\n tdll.pop_back();\n --j;\n }\n i = j;\n tdll.emplace_front(dll_num[j]);\n if(get_num(tdll) >= g_n) {\n //cout << \"j:\" << j << endl;\n while(get_num(tdll) >= g_n) {\n //cout << 0 << endl;\n ddll_ans.emplace_front();\n tdll.pop_back();\n --j;\n }\n i = j;\n //cout << \"i: \" << i << endl;\n }\n }\n tdll.clear();\n if(i >= 0) {\n while(j >= 0) {\n tdll.push_front(dll_num[j]);\n LL num = get_num(tdll);\n if(num >= g_n) {\n tdll.pop_front();\n break;\n } else {\n --j;\n }\n }\n while(tdll.front() == 0) {\n tdll.pop_front();\n ++j;\n }\n //show(tdll);\n if(!tdll.empty()) {\n ddll_ans.emplace_front(tdll);\n }\n i = j;\n }\n }\n LL ans = 0;\n for(int i = 0; i < ddll_ans.size(); ++i) {\n LL num = get_num(ddll_ans[i]);\n ans = ans * g_n + num;\n }\n cout << ans << endl;\n}\n\nint main() {\n //freopen(\"in.txt\", \"r\", stdin);\n //freopen(\"out.txt\", \"w\", stdout);\n pretreat();\n while (cin >> g_n) {\n input();\n solve();\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8c30f027cd57e885f7bc6bc2298275a4", "src_uid": "be66399c558c96566a6bb0a63d2503e5", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define endl '\\n'\ntypedef long long ll;\n\nconst int maxn = 0;\nll n , k , l , mod;\ntypedef vector < vector < ll > > mat;\n\nmat cr8()\n{\n\tmat a;\n\ta.resize(2 , vector < ll > (2,1));\n\ta[1][1] = 0;\n\treturn a;\t\n}\n\nmat mm(mat a , mat b)\n{\n\tmat ans;\n\tans.resize(2 , vector < ll > (2,0));\n\tfor(int i=0;i<2;i++) for(int j=0;j<2;j++) for(int k=0;k<2;k++) ans[i][j] += 1ll * a[i][k] * b[k][j];\n\tfor(int i=0;i<2;i++) for(int j=0;j<2;j++) ans[i][j] %= mod;\n\treturn ans;\n}\n\nmat matmul(mat a , int p)\n{\n\tif(p == 1) return a;\n\tmat b(2 , vector < ll > (2));\n\tb = matmul(a , p / 2);\n\tb = mm(b , b);\n\tmat arr(2 , vector < ll > (2));\n\tarr = cr8();\n\tif(p & 1) b = mm(b , arr);\n\treturn b;\n}\n\nint powmod(int x , int p)\n{\n\tif(!p) return 1;\n\tif(p == 1) return x;\n\tll ret = powmod(x , p / 2);\n\tret = ret * ret;\n\tif(p & 1) ret = ret * x;\n\treturn ret % mod;\n}\n\nint fib(int x)\n{\n\tx += 2;\n\tmat a(2 , vector < ll >(2));\n\ta = cr8();\n\ta = matmul(a , x);\n\treturn a[0][1];\n}\n\nint main()\n{\n\tios_base::sync_with_stdio(2 + 2 - 1 != 3); cin.tie(NULL);\n\tcin >> n >> k >> l >> mod;\n\tfor(int i=63;i>=0;i--)\n\t{\n\t\tif((1LL << i) & k)\n\t\t{\n\t\t\tif(i >= l)\n\t\t\t{\n\t\t\t\tcout << 0;\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t}\n\tint f = fib(n) , ff = powmod(2 , n) - f;\n\tll answer = 1;\n\tfor(int i=0;i\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vvi;\n\nll BinExp(ll bas, ll exp){\n ll ans=1, temp=bas;\n while(exp){\n if(exp&1) ans*=temp;\n temp*=temp;\n exp>>=1;\n }\n return ans;\n}\n\nll BinModExp(ll bas, ll exp, ll mod){\n ll ans=1, temp=bas%mod;\n while(exp){\n if(exp&1) ans=(ans*temp)%mod;\n temp=(temp*temp)%mod;\n exp>>=1;\n }\n return ans;\n}\n\nvvi Multiply_Matrix(vvi A, vvi B, ll mod){\n if(A[0].size()!=B.size()) return vvi();\n vvi C(A.size(), vi(B[0].size(), 0));\n for(int i=0; i>1, mod), A, mod);\n return Expon_Matrix(Multiply_Matrix(A, A, mod), exp>>1, mod);\n}\n\nll Nfibo(ll n, ll mod){\n vvi A;\n A.assign(2,vi(2));\n A[0][0]=1;\n A[0][1]=1;\n A[1][0]=1;\n A[1][1]=0;\n A=Expon_Matrix(A, n, mod);\n return (A[0][0]+A[0][1])%mod;\n}\nint main(){\n ll n, k, l, m;\n while(scanf(\"%I64d %I64d %I64d %I64d\", &n, &k, &l, &m)!=EOF){\n if(BinExp(2, l)\n#include \n#include \n#include \n#include \nusing namespace std;\nlong long n,ans,k,mod,l,i,p[100],res1,res2;\nstruct matrix{\n long long m[2][2];\n};\nmatrix f(matrix a, matrix b){\n int i,j,k;\n matrix c;\n for(i = 0; i < 2; i++){\n for(j = 0; j < 2; j++){\n c.m[i][j] = 0;\n for(k = 0; k < 2; k++)\n c.m[i][j] = (c.m[i][j] + a.m[i][k] * b.m[k][j]) % mod;\n }\n }\n return c;\n}\nmatrix getFib(int n){\n matrix a;\n a.m[0][0] = 0; a.m[0][1] = 1;\n a.m[1][0] = 1; a.m[1][1] = 1;\n if(n == 1) return a;\n if(n % 2 == 1)\n return f(a, getFib(n - 1));\n a = getFib(n / 2);\n return f(a, a);\n}\nint getPower(int n){\n if(n == 0) return 1;\n if(n%2) return (2 * getPower(n - 1)) % mod;\n long long res = getPower(n / 2);\n return (res * res) % mod;\n}\nint main(){\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n // freopen(\"input.txt\",\"r\",stdin);\n cin >> n >> k >> l >> mod;\n for(i = 1, p[0] = 1; i <= l; i++)\n p[i] = p[i - 1] * 2;\n if(k >= p[l]){cout << 0; return 0;}\n matrix s1 = getFib(n);\n res1 = (s1.m[0][1] + s1.m[1][1]) % mod;\n res2 = (getPower(n) - res1 + mod) % mod;\n ans = 1;\n for(i = 0; i < l; i++){\n if(p[i] & k) ans = (ans * res2) % mod;\n else ans = (ans * res1) % mod;\n }\n cout << ans;\n return 0;\n}\n\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1bf8f269c861a3f6e8909602847e1526", "src_uid": "2163eec2ea1eed5da8231d1882cb0f8e", "difficulty": 2100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef vector vi;\ntypedef pair ii;\ntypedef vector< ii > vii;\n///////////////////////////////UTIL/////////////////////////////////\n#define ALL(x) (x).begin(),x.end()\n#define CLEAR0(v) memset(v, 0, sizeof(v))\n#define CLEAR(v, x) memset(v, x, sizeof(v))\n#define COPY(a, b) memcpy(a, b, sizeof(a))\n#define CMP(a, b) memcmp(a, b, sizeof(a))\n#define REP(i,n) for(int i = 0; i-1; i--)\n#define REPDP(i,a,n) for(int i = n-1; i>=a; i--)\n#define pb push_back\n#define pf push_front\n#define sz size()\n#define mp make_pair\n/////////////////////////////NUMERICAL//////////////////////////////\n#define INF 0x3f3f3f3f\n#define EPS 1e-9\n/////////////////////////////BITWISE////////////////////////////////\n#define CHECK(S, j) (S & (1 << j))\n#define CHECKFIRST(S) (S & (-S)) \n#define SET(S, j) S |= (1 << j)\n#define SETALL(S, j) S = (1 << j)-1 \n#define UNSET(S, j) S &= ~(1 << j)\n#define TOOGLE(S, j) S ^= (1 << j)\n///////////////////////////////64 BITS//////////////////////////////\n#define LCHECK(S, j) (S & (1ULL << j))\n#define LSET(S, j) S |= (1ULL << j)\n#define LSETALL(S, j) S = (1ULL << j)-1ULL \n#define LUNSET(S, j) S &= ~(1ULL << j)\n#define LTOOGLE(S, j) S ^= (1ULL << j)\n//__builtin_popcount(m)\n//scanf(\" %d \", &t);\n//L[i]=L[i/2]+1;\n\ntypedef vector > matrix;\null MOD, n, m, l, k;\nconst int K = 3;\n \n// computes A * B\nmatrix mul(matrix A, matrix B)\n{\n matrix C(K, vector(K));\n REP(i, K) REP(j, K) REP(z, K)\n C[i][j] = (C[i][j] + A[i][z] * B[z][j]) % MOD;\n return C;\n}\n \n// computes A ^ p\nmatrix pow(matrix A, int p)\n{\n if (p == 1)\n return A;\n if (p % 2)\n return mul(A, pow(A, p-1));\n matrix X = pow(A, p/2);\n return mul(X, X);\n}\n \n// returns the N-th term of Fibonacci sequence\null oneComb(ull N){\n if(N == 0) return 0ULL;\n if(N <= 2) return 1ULL;\n if(N == 3) return 3ULL;\n \n vector F1(K);\n F1[0] = 3;\n F1[1] = 1;\n F1[2] = 4; \n \n matrix T(K, vector(K));\n T[0][0] = T[0][1] = T[0][2] = 1;\n T[1][0] = 1; T[1][1] = T[1][2] = 0; \n T[2][0] = T[2][1] = 0; T[2][2] = 2;\n \n T = pow(T, N-3);\n \n ull res = 0;\n REP(i, K)\n res = (res + T[0][i] * F1[i]) % MOD;\n return res;\n}\n\null fastExp(ull base, ull p, ull m){\n if(p == 0ULL) return 1ULL;\n else if(p == 1ULL) return base%m;\n else{\n unsigned long long res = fastExp(base, p/2ULL, m);\n res = (res*res)%m;\n if(p%2ULL == 1ULL) res = (res*base)%m;\n return res;\n }\n}\n\nint main(){\n cin >> n >> k >> l >> MOD;\n ull one = oneComb(n);\n ll zero = ((ll) fastExp(2, n, MOD)) - ((ll) one);\n if(zero < 0LL) zero += MOD;\n ull ans = ((log2((double) k) > ((double) l)))? 0ULL : 1ULL;\n REP(i, l){\n if(k&(1ULL << i)) ans = (ans * one)%MOD;\n else ans = (ans * zero)%MOD; \n }\n cout << ans << endl;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ecc43984c75e2ac227ae8bef070eb665", "src_uid": "2163eec2ea1eed5da8231d1882cb0f8e", "difficulty": 2100.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define lint long long\n\n#define ss stringstream\n#define sz size()\n#define pb push_back\n#define mp make_pair\n\n#define FOR(i,n) SFOR(i,0,n)\n#define SFOR(i,m,n) for(i=m;i=0;i--)\n\nint main() {\n\t__int64 q,i,j;\n\tscanf(\"%I64d\",&q);\n\tif (q < 3) { printf(\"1\\n0\\n\"); return 0; }\n\tfor(i=2;i*i<=q;i++) if (q % i == 0) break;\n\tif (q % i != 0) { printf(\"1\\n0\\n\"); return 0; }\n\tq /= i;\n\tfor(j=i;j*j<=q;j++) if (q % j == 0) break;\n\tif (q % j != 0) { printf(\"2\\n\"); return 0; }\n\tif (i*j == q) { printf(\"2\\n\"); return 0; }\n\tprintf(\"1\\n%I64d\\n\",j*i);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b3501300c36d996647677785b364f35e", "src_uid": "f0a138b9f6ad979c5ca32437e05d6f43", "difficulty": 1400.0} {"lang": "MS C++", "source_code": "#pragma comment(linker, \"/STACK:256000000\")\n#define _CRT_SECURE_NO_WARNINGS\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n//#include \n#include \n//#include \n#include \n\nusing namespace std; \n\nconst double PI = 3.1415926535897932384626433832795; \n\n#define fori(i,n) for(int i = 0; i < (n); i++) \n#define MP(a,b) make_pair(a,b)\n\ntypedef pair ii;\n\n//#ifdef _MSC_VER \nconst string IN_NAME = \"input.txt\"; \nconst string OUT_NAME = \"output.txt\"; \n//#else\n//const string NAME = \"tricir\";\n//const string IN_NAME = NAME + \".in\"; \n//const string OUT_NAME = NAME + \".out\"; \n//#endif \n\n#define sz(x) ((int)((x).size())) \n#define all(v) (v).begin(), (v).end() \ntemplate T sqr(const T &x) {return x*x;}\ntypedef long long ll;\n\nconst double eps=1e-12;\n\nll n;\n\nmap cnt;\n\nint main() \n{\n#ifndef ONLINE_JUDGE\n freopen(IN_NAME.c_str(), \"r\", stdin); \n freopen(OUT_NAME.c_str(), \"w\", stdout); \n#endif\n //----------------------------------------------------------------------------------------------------------------- \n //cout << sqr(1000000007LL)*2 << endl;\n cin >> n;\n ll sum = 0;\n while (n % 2 == 0)\n {\n cnt[2]++;\n sum++;\n n /= 2;\n }\n while (n % 3 == 0)\n {\n cnt[3]++;\n sum++;\n n /= 3;\n } \n for (int i = 6; i <= 32000000; i+=6)\n {\n while (n % (i-1) == 0)\n {\n cnt[i-1]++;\n sum++;\n n /= (i-1);\n }\n while (n % (i+1) == 0)\n {\n cnt[i+1]++;\n sum++;\n n /= (i+1);\n }\n }\n \n if (sum < 2)\n {\n cout << 1 << endl << 0;\n return 0;\n }\n if (sum == 2)\n {\n cout << 2;\n return 0;\n }\n map mp;\n int x = 2;\n for (map::iterator i = cnt.begin(); i != cnt.end(); i++)\n {\n while (x && i->second)\n {\n i->second--;\n x--;\n mp[i->first]++;\n }\n }\n ll res = 1;\n for (map::iterator i = mp.begin(); i != mp.end(); i++)\n for (int j = 0; j < i->second; j++)\n res *= i->first;\n cout << 1 << endl << res;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a8075e9636e4a2f666b4a3039c868329", "src_uid": "f0a138b9f6ad979c5ca32437e05d6f43", "difficulty": 1400.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n\nusing namespace std;\n\nint main ()\n{\n\t//ifstream cin (\"input.txt\");\n\t//ofstream cout (\"output.txt\");\n\tlong long q;\n\tcin >> q;\n\tvector < long long > divisors;\n\tlong long k = 2;\n\tbool flag = false;\n\twhile ( k <= q )\n\t{\n\t\tif ( k * k > q && flag == false )\n\t\t\tbreak;\n\t\twhile ( q % k == 0 )\n\t\t{\n\t\t\tdivisors.push_back ( k );\n\t\t\tq /= k;\n\t\t\tflag = true;\n\t\t}\n\t\tif ( divisors.size () > 2 )\n\t\t\tbreak;\n\t\t++k;\n\t}\n\tif ( divisors.size () != 2 )\n\t{\n\t\tif ( divisors.size () == 1 && divisors [ 0 ] == q )\n\t\t\tcout << 2;\n\t\telse\n\t\t{\n\t\t\tcout << 1 << endl;\n\t\t\tif ( divisors.size () == 1 || divisors.size () == 0 )\n\t\t\t\tcout << 0;\n\t\t\telse\n\t\t\t\tcout << divisors [ 0 ] * divisors [ 1 ];\n\t\t}\n\t}\n\telse\n\t\tcout << 2;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a8c9738e4d5a225cee1845e2866f674d", "src_uid": "f0a138b9f6ad979c5ca32437e05d6f43", "difficulty": 1400.0} {"lang": "MS C++", "source_code": "#define _CRT_SECURE_NO_DEPRECATE\n#pragma comment(linker, \"/STACK:64000000\")\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n\nusing namespace std;\n\ntypedef long long int64;\n\n#define forn(i, n) for(int i = 0; i < (int)(n); i++)\n#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)\n#define pb push_back\n#define mp make_pair\n#define X first\n#define Y second\n#define y1 YYYYYYYYYYYY1\n#define all(a) (a).begin(), (a).end()\n#define Abs(x) (((x) >= 0) ? (x) : (-(x)))\n\nconst int INF = (int)1E9;\nconst int64 INF64 = (int64)1E18;\nconst long double EPS = 1E-9;\nconst long double PI = 3.1415926535897932384626433832795;\n\nmap d;\n\nbool solve(int64 n) {\n if (d.count(n)) return d[n];\n\n bool ans = false;\n int num = 0;\n for(int64 i = 2; i*i <= n; i++)\n if (n % i == 0) {\n num++;\n if (!solve(i)) ans = true;\n if (!solve(n/i)) ans = true;\n }\n\n if (num == 0) ans = true;\n return d[n] = ans;\n}\n\nint main(){ \n#ifndef ONLINE_JUDGE\n freopen(\"input.txt\", \"rt\", stdin);\n freopen(\"output.txt\", \"wt\", stdout);\n#endif\n\n int64 n;\n cin >> n;\n\n if (solve(n)) {\n cout << 1 << endl;\n for(int64 i = 2; i*i <= n; i++)\n if (n % i == 0) {\n if (!solve(i)) {\n cout << i << endl;\n return 0;\n }\n\n if (!solve(n/i)) {\n cout << n / i << endl;\n return 0;\n }\n }\n\n cout << 0 << endl;\n } else {\n cout << 2 << endl;\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "aad321f680369b9c0d3b48891fc46783", "src_uid": "f0a138b9f6ad979c5ca32437e05d6f43", "difficulty": 1400.0} {"lang": "GNU C++17", "source_code": "//------------------------ Un, Deux, Trois, Quatre, Cinq -----------------------//\r\n#pragma GCC target (\"avx2\")\r\n#pragma GCC optimize (\"O3\")\r\n#pragma GCC optimize (\"unroll-loops\")\r\n\r\n#include\r\nusing namespace std;\r\n\r\n// Shorthands\r\n#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);\r\n#define endl \"\\n\"\r\n#define ll int\r\n#define ld long double\r\n#define vll vector\r\n#define pb push_back\r\n#define eb emplace_back\r\n#define lb lower_bound\r\n#define ub upper_bound\r\n#define pll pair\r\n#define vpll vector\r\n#define ff first\r\n#define ss second\r\n#define tll tuple\r\n#define vtll vector \r\n#define mt make_tuple\r\n#define rep(i,a,b) for(ll i=a; i=b; i--)\r\n#define vect(a,n) vll a(n); rep(i,0,n) cin>>a[i];\r\n#define all(a) a.begin(),a.end()\r\n#define sortall(a) sort(a.begin(),a.end());\r\n#define PI acos(-1)\r\n\r\n// Debug\r\n#define printv(a) rep(i,0,a.size()) cout<(t)<<\",\"<(t)<<\",\"<(t)<<\")\"<' << #x << ':' << (x) << \"\\n\";\r\n#define trace2(x,y) cout<< '>' << #x << ':' << (x) << \" | \" << #y << ':' << (y) << \"\\n\";\r\n#define trace3(a,b,c) cout<<#a<<\"=\"<<(a)<<\", \"<<#b<<\"=\"<<(b)<<\", \"<<#c<<\"=\"<<(c)<<\"\\n\";\r\n#define trace4(a,b,c,d) cout<<#a<<\"=\"<<(a)<<\", \"<<#b<<\"=\"<<(b)<<\", \"<<#c<<\"=\"<<(c)<<\", \"<<#d<<\"=\"<<(d)<<\"\\n\";\r\n\r\n// Constants\r\n// const ll INF = 1e18;\r\nconst ll mod = 998244353;\r\nconst ll MOD = 1e9 + 7;\r\nconst ll mxN = 1e6 + 5;\r\n\r\n// Input/Output File\r\nvoid fileio()\r\n{\r\n #ifndef ONLINE_jUDGE\r\n freopen(\"input.txt\", \"r\", stdin);\r\n freopen(\"output.txt\", \"w\", stdout);\r\n #endif\r\n}\r\n//-------------------------- Six, Sept, Huit, Neuf, Dix ------------------------//\r\n\r\nconst ll k = 30;\r\nconst ll N = 1e6;\r\n\r\nll a[k+1][N+1];\r\nmap mp;\r\n\r\nvoid solve()\r\n{\r\n ll n, m; cin >> n >> m;\r\n\r\n memset(a, 0, sizeof(a));\r\n rep(i,1,k+1)\r\n rep(j,1,m+1) a[i][j] = i*j;\r\n \r\n vll c(31, 0);\r\n rep(i,1,k+1)\r\n {\r\n rep(j,1,m+1) mp[a[i][j]]++;\r\n c[i] = mp.size();\r\n }\r\n\r\n ll ans = 1;\r\n vll vis(n+1, 0);\r\n rep(i,2,n+1)\r\n {\r\n if(!vis[i])\r\n {\r\n ll x = i;\r\n ll t = 0;\r\n while(x <= n)\r\n {\r\n t++;\r\n vis[x] = 1;\r\n x *= i;\r\n }\r\n ans += c[t];\r\n } \r\n }\r\n cout << ans << endl;\r\n} \r\n\r\n\r\nint main()\r\n{\r\n fastio; // fileio();\r\n // int tc; cin >> tc; while(tc--)\r\n solve();\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "23731b463037234ba921f8161c2369de", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0} {"lang": "GNU C++17", "source_code": "\r\n#include\r\n#include \r\n#include \r\n#include \r\nusing namespace __gnu_pbds;\r\nusing namespace std;\r\n\r\n\r\n#define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); \r\n#define ff first\r\n#define ss second\r\n#define int long long\r\n#define ll long long\r\n#define pb push_back\r\n#define pii pair\r\n#define vi vector\r\n#define pqb priority_queue\r\n#define pqs priority_queue >\r\n#define setbits(x) __builtin_popcountll(x)\r\n#define zerobits(x) __builtin_ctzll(x)\r\n#define mod 998244353\r\n#define inf 1e18\r\n#define ps(x,y) fixed< >\r\n#define all(x) x.begin(),x.end()\r\n#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<,\r\nrb_tree_tag,\r\ntree_order_statistics_node_update>\r\nordered_set;\r\n\r\n//insert,find_by_order,order_of_key,lower_bound,upper_bound;\r\n\r\n#define TRACE\r\n#ifdef TRACE\r\n#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)\r\ntemplate \r\nvoid __f(const char* name, Arg1&& arg1) {\r\n cout << name << \" : \" << arg1 << std::endl;\r\n}\r\ntemplate \r\nvoid __f(const char* names, Arg1&& arg1, Args&&... args) {\r\n const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << \" : \" << arg1 << \" | \"; __f(comma + 1, args...);\r\n}\r\n#else\r\n#define deb(...)\r\n#endif\r\n\r\n \r\n//////////////////////////////code//////////////////////////////\r\n\r\nconst int N = 1e6 + 5;\r\n\r\nint vis[N];\r\ngp_hash_tablefr;\r\nint ans[N];\r\n\r\nvoid solve()\r\n{\r\n\r\n int n , m;\r\n cin >> n >> m;\r\n\r\n vis[1] = 1;\r\n\r\n vi mxpw;\r\n int mxval = 0;\r\n\r\n for(int i = 2;i <= n; i++)\r\n { \r\n if(vis[i])\r\n continue;\r\n\r\n int st = i;\r\n int cnt = 0;\r\n\r\n while(st <= n)\r\n {\r\n vis[st]++;\r\n st *= i;\r\n cnt++;\r\n }\r\n\r\n mxpw.pb(cnt);\r\n mxval = max(mxval , cnt);\r\n // deb(cnt);\r\n }\r\n\r\n for(int i = 1;i <= mxval; i++)\r\n { \r\n\r\n ans[i] = ans[i - 1];\r\n\r\n for(int j = 1;j <= m; j++)\r\n {\r\n if(fr[j * i] == 0)\r\n {\r\n fr[j * i] = 1;\r\n ans[i]++;\r\n }\r\n }\r\n }\r\n\r\n int fin = 1;\r\n\r\n for(auto x : mxpw)\r\n fin += ans[x];\r\n\r\n db(fin)\r\n\r\n \r\n\r\n}\r\n\r\nint32_t main()\r\n{ \r\n\r\n LETS_GET_SCHWIFTY;\r\n\r\n #ifndef ONLINE_JUDGE\r\n freopen(\"INP.txt\", \"r\", stdin);\r\n freopen(\"out.txt\", \"w\", stdout);\r\n #endif \r\n\r\n\r\n int t = 1;\r\n //cin >> t;\r\n\r\n while (t--)\r\n solve();\r\n\r\n}\r\n\r\n// check out for following mistakes-\r\n// if using pb operation on vector and then trying to access index..check if sizeof that vec could remain 0 only\r\n// is using prime sieve make sure it fits\r\n// when using factorial template or combinatorics make sure that you edit fillfac fun values and array values\r\n\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b3d50c7ef719afabf4d7e27e06893f05", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0} {"lang": "GNU C++20 (64)", "source_code": "#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include\r\n#include \r\nusing namespace std;\r\nconst int N = 1e6 + 5; //remember to modify the range of the data!!\r\nconst int mod = 1e9 + 7;\r\nconst int inf = 0x3f3f3f3f;\r\ntypedef long long ll;\r\n\r\nint n, m, t;\r\nll vis[N], f[N];\r\n\r\nunordered_map mp;\r\nint main(void)\r\n{\r\n cin >> n >> m;\r\n ll ans = 0;\r\n for(int i = 1; i <= 21; i++)\r\n {\r\n for(int j = 1; j <= m; j++)\r\n mp[i * j] = 1;\r\n f[i] = mp.size();\r\n }\r\n for(int i = 2; i <= n; i++)\r\n {\r\n if(vis[i])\r\n continue;\r\n ll prod = 1;\r\n int cnt = 0;\r\n for(int j = 1; j <= m && prod * i <= n; j++)\r\n {\r\n prod *= i;\r\n vis[prod] = 1;\r\n cnt++;\r\n }\r\n ans += f[cnt];\r\n }\r\n cout << ans + 1;\r\n\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8ac7beca5c28d0ad6f326608d2767a0e", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0} {"lang": "GNU C++20 (64)", "source_code": "#include \r\n#include \r\n#include \r\n#include \r\n#include \r\n#include\r\n#include \r\nusing namespace std;\r\nconst int N = 1e6 + 5; //remember to modify the range of the data!!\r\nconst int mod = 1e9 + 7;\r\nconst int inf = 0x3f3f3f3f;\r\ntypedef long long ll;\r\n\r\nll n, m, t;\r\nint vis[N];\r\n\r\nunordered_map mp;\r\nint main(void)\r\n{\r\n cin >> n >> m;\r\n ll ans = 0;\r\n for(int i = 2; i <= n; i++)\r\n {\r\n if(vis[i])\r\n continue;\r\n ll prod = 1;\r\n mp.clear();\r\n for(int j = 1; j <= m && prod * i <= n; j++)\r\n {\r\n prod *= i;\r\n vis[prod] = 1;\r\n for(int k = 1; k <= m; k++)\r\n mp[j * k] = 1;\r\n }\r\n ans += mp.size();\r\n }\r\n cout << ans + 1;\r\n\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "df4bbcb70a172998665aa5b89d8b366d", "src_uid": "6ca310cb0b6fc4e62e63a731cd55aead", "difficulty": 2200.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n\tlong long n,m,k,i,j;\n\tcin>>n>>m>>k;\n\tm=m-n;\n\tif(m==0)\n\t{\n\t\tcout<<\"1\"<=1;i--,j++)\n\t{\n\t\ta[i]=j-k;\n\t\ta[j]=j-k;\n\t}\n\tfor(j=k;j<=n;j++)\n\t\ta[j]=j-k;\n\t\n\tfor(i=1;i<=n;i++)\n\t\tl+=a[i];\n\tl=(l+m)/n;;\n\tcout<\n#include\n#define jio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n#define ll long long\n//#define mp make_pair\n#define pb push_back\n#define lld long long int\n#define clr clear()\n#define ff first\n#define ss second\n//#define N 1000005\n//#define M 1000\n#define endl '\\n'\n#define c_s_b() __builtin_popcount()\n\n#define sze 10000009\n#define pii pair\n#define big 100009\n#define int long long\n\nusing namespace std;\nint n,m,k;\nint minm_val;\n\nbool check(int val,int h){\n bool ok=true;\n\n int i=k-1;\n int j=k+1;\n vectorarr(n,0);\n int val1=val-1;\n for(int z=i;z>=0;z--){\n arr[z]=max((ll)0,val1);\n val1=val1-1;\n }\n val1=val-1;\n for(int z=j;z>t;\n // while(t--){\n cin>>n>>m>>k;\n if(n==1){\n cout<\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint pel=0;\nvectorv;\nvoid pellow(long long pos){\n\t\n\tif (pel == 0 || pos == v.size() || pos < 0)\n\t\treturn;\n\tif (pos>0 && pos < v.size() - 1){\n\n\t\tif (v[pos] + 1>v[pos - 1] + 1){\n\t\t\tpellow(pos-1);\n\t\t}\n\n\t\tif (v[pos] + 1 > v[pos + 1] + 1){\n\t\t\tpellow(pos+1);\n\t\t}\n\t\tif (pel != 0){\n\t\t\tv[pos]++;\n\t\t\tpel--;\n\t\t\treturn;\n\t\t}\n\n\t}\n\tif (pos == 0){\n\t\tif (v[pos] + 1 > v[pos + 1] + 1){\n\t\t\tpellow(pos+1);\n\t\t}\n\t\tif (pel != 0){\n\t\t\tv[pos]++;\n\t\t\tpel--;\n\t\t\treturn;\n\t\t}\n\t}\n\tif (pos == v.size()-1){\n\n\t\tif (v[pos] + 1>v[pos - 1] + 1){\n\t\t\tpellow(pos-1);\n\t\t}\n\n\t\tif (pel != 0){\n\t\t\tv[pos]++;\n\t\t\tpel--;\n\t\t\treturn;\n\t\t}\n\t}\n\n}\nvoid main(){\n\tlong long x, y, z,c,s=1;\n\tscanf(\"%I64d %I64d %I64d\", &x,&y,&z);\n\t\n\tpel = y-x;\n\tc = ( x * ( x - 1)) / 2;\n\tif ((pel - c) / x > 0){\n\t\ts += ((pel - c) / x);\n\t\tpel -= (s-1)*x;\n\t}\n\tv = vector(x, s);\n\twhile (pel != 0){\n\t\tpellow(z - 1);\n\t}\n\tprintf(\"%I64d\", v[z - 1]);\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f8e80baea0a1a80f6b8a1b663f8137d5", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c", "difficulty": 1500.0} {"lang": "GNU C++11", "source_code": "\ufeff#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nlong long n,m,k;\n\nbool f(long long x)\n{\n\tvector a(n+1);\n\ta[k]=x;\n\tfor (int i=k+1;i<=n;i++)\n\t{\n\t\ta[i]=max(1,a[i-1]-1);\n\t}\n\tfor (int i=k-1;i>=1;i--)\n\t\ta[i]=max(1,a[i+1]-1);\n\tlong long sum=0;\n\tfor (int i=1;i<=n;i++)\n\t\tsum+=a[i];\n\treturn sum<=m;\n}\n\nint main()\n{\n\tcin>>n>>m>>k;\n\tif (n==1)\n\t{\n\t\tcout<1)\n\t{\n\t\tlong long mid=(l+r)/2;\n\t\tif (f(mid))\n\t\t\tl=mid;\n\t\telse\n\t\t\tr=mid;\n\t}\n\tcout<\n#define ll long long\n#define ld long double\n#define mod 1000000007 // 1e9+7\n#define inf 1e18\nusing namespace std;\n\nll neighbour[300000];\nll G[5213][5213];\nll A[300000][20];\nll my_ST[300000][2];\n\nint main(){\n\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n\n ll n,last_digit,second_last_digit,num,ans;\n\n cin>>n;\n\n if(n>=0){\n cout<= second_last_digit){\n n = abs(n);\n n -= (last_digit);\n n /= 10;\n n *= -1;\n }\n else if(second_last_digit > last_digit){\n n = abs(n);\n n -= (second_last_digit * 10);\n n /= 10;\n n += last_digit;\n n *= 1;\n }\n\n cout<\n#include \n#include \n#include \n\nusing namespace std;\n\nchar buffer [1000000007];\n\nint main()\n{\n gets(buffer);\n\n int len = strlen(buffer);\n\n if(buffer[0] == '-')\n {\n if(buffer[len-2] > buffer[len-1])\n {\n buffer[len-2] = buffer[len-1];\n buffer[len-1] = '\\0';\n }\n else\n {\n buffer[len-1] = buffer[len-2];\n buffer[len-1] = '\\0';\n }\n \n if(len-1 == 2)\n {\n buffer[len-3] = buffer[len-2];\n buffer[len-2] = 0;\n }\n }\n\n printf(\"%s\",buffer);\n\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "287ae44b3692a9da57be8e5c98c7184c", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0} {"lang": "MS C++", "source_code": "#include\"stdio.h\"\n#include\n#include\"math.h\"\nvoid main()\n{\n\tchar max;\n\tchar a[10000000004];\n\tgets(a);\n\tint k;\n\tmax = a[1];\n\tif (a[0] != '-')\n\t\tputs(a);\n\telse\n\t{\n\t\tfor (int i = 1; i < strlen(a); i++)\n\t\t{\n\t\t\tif (max < a[i])\n\t\t\t{\n\t\t\t\tmax = a[i];\n\t\t\t\tk = i;\n\t\t\t}\n\t\t}\n\t}\n\tfor (int i = k; i < strlen(a)-1; i++)\n\t{\n\t\ta[i] = a[i + 1];\n\t}\n\tputs(a);\n}\n\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e79db3f2ac7076559e887b0b71f90423", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e", "difficulty": 900.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nchar a[1000000000];\nint main()\n{int n;\n cin>>a;\n n=strlen(a);\n if(a[0]!='-')\n {\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef vector vi;\ntypedef vector vvi;\ntypedef pair ii;\ntypedef vector vii;\ntypedef vector vs;\n\ntypedef long long LL; //NOTES:int64\ntypedef unsigned long long ULL; //NOTES:uint64\ntypedef unsigned uint;\n\nconst double pi = acos(-1.0); //NOTES:pi\nconst double eps = 1e-11; //NOTES:eps\nconst int MAXI = 0x7fffffff;\nconst int dx[] = {1, 0, -1, 0};\nconst int dy[] = {0, 1, 0, -1};\nconst char dz[] = \"SENW\";\n\n#define rep(i,n) for (int i=0;i=_a; i--)\n#define Reset(a,b) memset((a),(b),sizeof(a))\n\n#define endline putchar('\\n')\n#define space putchar(' ')\n#define EXIT(x) {cout << x;return 0;}\n\n#define fi first\n#define se second\n#define pb push_back\n\n#define S(x) scanf(\"%d\",&x);\n#define input freopen(\"input.txt\",\"r\",stdin);\n#define deb(i,a,n) for(i=0;i(b)?(a):(b))\n#define miN(a,b) ((a)<(b)?(a):(b))\n#define abS(x) ((x)<0?-(x):(x))\n#define mod 1000000007\n\nstruct debugger\n{\n template debugger& operator , (const T& v)\n { \n cerr<>n;\n if(n%3==0)\n {\n if(n%9!=0)\n s=n/9+1;\n else if(n%27!=0)\n s=n/27+1;\n else\n s=1;\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntemplate inline T sqr(T x) { return x * x; }\ntypedef long long LL;\ntypedef unsigned long long ULL;\ntypedef long double LD;\ntypedef pair PII;\ntypedef pair PIII;\ntypedef pair PLL;\ntypedef pair PLI;\ntypedef pair PDD;\n#define MP make_pair\n#define PB push_back\n#define sz(x) ((int)(x).size())\n#define clr(ar,val) memset(ar, val, sizeof(ar))\n#define istr stringstream\n#define FOR(i,n) for(int i=0;i<(n);++i)\nconst double EPS = 1e-6;\nconst int INF = 0x3fffffff;\nconst LL LINF = INF * 1ll * INF;\nconst double PI = acos(-1.0);\n\nusing namespace std;\n\nLL dp[105];\n\nint main(void){\n#ifndef ONLINE_JUDGE \n //freopen(\"/home/xing89qs/\u684c\u9762/data.in\",\"r\",stdin);\n#endif\n\tLL n;\n\tcin>>n;\n\tfor(int i = 3;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\ntemplate inline T sqr(T x) { return x * x; }\ntypedef long long LL;\ntypedef unsigned long long ULL;\ntypedef long double LD;\ntypedef pair PII;\ntypedef pair PIII;\ntypedef pair PLL;\ntypedef pair PLI;\ntypedef pair PDD;\n#define MP make_pair\n#define PB push_back\n#define sz(x) ((int)(x).size())\n#define clr(ar,val) memset(ar, val, sizeof(ar))\n#define istr stringstream\n#define FOR(i,n) for(int i=0;i<(n);++i)\nconst double EPS = 1e-6;\nconst int INF = 0x3fffffff;\nconst LL LINF = INF * 1ll * INF;\nconst double PI = acos(-1.0);\n\nusing namespace std;\n\nLL dp[105];\n\nint main(void){\n#ifndef ONLINE_JUDGE \n //freopen(\"/home/xing89qs/\u684c\u9762/data.in\",\"r\",stdin);\n#endif\n\tLL n;\n\tcin>>n;\n\tLL ans = 0;\n\tif(n%3!=0){\n\t\tans = (n+2)/3;\n\t\tcout<\n#include \n#include \n#include \nusing namespace std;\n#define REP(i,a,b) for(int i=a;i<=b;i++)\nconst int N = 111111;\nconst int M = 222222;\nint main() {\n long long n;\n scanf(\"%I64d\",&n);\n int i = 1;\n for(;;) {\n i *= 3;\n if(i > n) break;\n if(n % i != 0) break;\n }\n if(i > n) {\n puts(\"1\");\n } else {\n printf(\"%I64d\\n\",n/i + 1);\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e3231514c7fb5fd547411e148d7e2aca", "src_uid": "7e7b59f2112fd200ee03255c0c230ebd", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)\n#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)\n\ntypedef long long ll;\n#define INF (1ll<<40)\n\nint lucky(ll x){\n int ans = 0;\n while(x > 0){\n if(x%10 == 4 || x%10 == 7) ans++;\n x /= 10;\n }\n return ans;\n}\n\nmap , int> mp1;\n\nll func1(ll low, int x){\n int i;\n ll ans = INF;\n \n if(x < 0) return INF;\n \n pair st = make_pair(low,x);\n if(mp1.find(st) != mp1.end()) return mp1[st];\n \n if(low <= 3){\n if(x == 0) return low;\n ans = 0;\n REP(i,x) ans = ans * 10 + 4;\n return mp1[st] = ans;\n }\n \n REP(i,10){\n if(i < low%10){\n ll tmp = func1(low/10+1,x-lucky(i));\n ans = min(ans,tmp*10+i);\n } else {\n ll tmp = func1(low/10,x-lucky(i));\n ans = min(ans,tmp*10+i);\n }\n }\n \n return mp1[st] = ans;\n}\n\nll func2(ll low, int x, int y){\n int i;\n ll ans = INF;\n \n if(x < 0 || y < 0) return INF;\n \n REP(i,9) if(y - x == lucky(i+1) - lucky(i)){\n if(i < low%10){\n ll tmp = func1(low/10+1,x-lucky(i));\n ans = min(ans,tmp*10+i);\n } else {\n ll tmp = func1(low/10,x-lucky(i));\n ans = min(ans,tmp*10+i);\n }\n }\n \n return ans;\n}\n\nll func3(ll low, int x, int y){\n ll ans = INF;\n \n int i;\n for(i=0;;i++){\n ll tmp = func2(low,x,y);\n int j;\n REP(j,i) tmp = min(tmp * 10 + 9, INF);\n ans = min(ans,tmp);\n \n if(low == 0) return ans;\n low /= 10;\n }\n}\n\nll func(ll low, ll high){\n if(high/10 - low/10 >= 2){\n ll tmp = func(low/10,high/10);\n return tmp * 10 + low % 10;\n }\n \n ll ans = INF;\n \n int i,j,k;\n \n REP(i,10){\n j = i + (int)(high - low);\n if(j >= 20) continue;\n \n int x = lucky(low) - lucky(i);\n int y = 0;\n if(j >= 10) y = lucky(high) - lucky(j-10);\n \n bool failed = false;\n for(k=i;k<=j;k++){\n int tmp1 = lucky(low+k-i);\n int tmp2 = ((k >= 10) ? (y + lucky(k-10)) : (x + lucky(k)));\n if(tmp1 != tmp2){\n failed = true;\n break;\n }\n }\n if(failed) continue;\n \n ll small = (low - i + 10) / 10;\n if(j >= 10){\n ll tmp = func3(small,x,y);\n ans = min(ans,tmp*10+i);\n } else {\n ll tmp = func1(small,x);\n ans = min(ans,tmp*10+i);\n }\n }\n \n return ans;\n}\n\nint main(void){\n ll a,d;\n cin >> a >> d;\n ll ans = func(a,a+d-1);\n cout << ans << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b78b087c0540635a6227e8f32d44be35", "src_uid": "649e9f477b97c1f72b05d409b4a99d59", "difficulty": 2700.0} {"lang": "GNU C++14", "source_code": "#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\n\nconst ll INF = 1000000000000000000;\nconst ll BLOK = 1000;\n\nint F(ll x)\n{\n int il = 0;\n while (x != 0)\n {\n il += (x % 10 == 4) || (x % 10 == 7);\n x /= 10;\n }\n return il;\n}\n\nvoid KMP(vector s, int L, vector& starty)\n{\n s.push_back(0);\n for (int i = s.size() - 1; i >= 1; --i)\n s[i] = s[i - 1];\n vector ps(s.size());\n ps[1] = 0;\n for (int i = 2; i < s.size(); ++i)\n {\n int w = ps[i - 1];\n while (w > 0 && s[w + 1] != s[i])\n w = ps[w];\n if (w == 0)\n ps[i] = (s[1] == s[i]) ? 1 : 0;\n else\n ps[i] = w + 1;\n if (ps[i] == L)\n {\n int nr = i - L + 1 - (L + 2);\n if (s.size() == 2 * BLOK + L + 2)\n {\n if (nr < 1000 && nr + L - 1 >= 1000)\n starty.push_back(nr);\n }\n else\n starty.push_back(nr);\n }\n }\n}\n\nint main()\n{\n ios_base::sync_with_stdio(0);\n ll a, b, l;\n ll A, B, L;\n cin >> a >> l;\n b = a + l - 1;\n A = a / BLOK;\n B = b / BLOK;\n L = B - A + 1;\n if (L >= 3 || (L == 2 && (a % BLOK == 0 || (b + 1) % BLOK == 0)) || (L == 1 && a % BLOK == 0 && (b + 1) % BLOK == 0))\n {\n vector s(12000000 + L + 1);\n for (int i = 0; i < L; ++i)\n s[i] = F(BLOK * (i + A));\n s[L] = 100;\n for (int i = 0; i < 12000000; ++i)\n s[i + L + 1] = F(BLOK * i);\n vector starty;\n KMP(s, L, starty);\n for (int i = 0; i < starty.size(); ++i)\n {\n if (starty[i] > A)\n {\n cout << starty[i] * BLOK + a % BLOK;\n return 0;\n }\n }\n }\n else\n {\n vector s(12000000);\n for (int i = 0; i < 12000000; ++i)\n s[i] = F(BLOK * i);\n vector wzo(l);\n for (int i = 0; i < l; ++i)\n wzo[i] = F(i + a);\n vector pod(BLOK);\n for (int i = 0; i < BLOK; ++i)\n pod[i] = F(i);\n ll odp = INF;\n for (int i = 0; i <= 10; ++i)\n {\n for (int j = 0; j <= 10; ++j)\n {\n vector t(2 * BLOK + l + 1);\n for (int k = 0; k < l; ++k)\n t[k] = wzo[k];\n t[l] = 100;\n for (int k = 0; k < BLOK; ++k)\n t[k + l + 1] = pod[k] + i;\n for (int k = 0; k < BLOK; ++k)\n t[k + BLOK + l + 1] = pod[k] + j;\n vector starty;\n KMP(t, l, starty);\n if (starty.size() == 0)\n continue;\n ll odp2 = INF;\n for (int k = A; odp2 == INF && k < 12000000 - 1; ++k)\n if (s[k] == i && s[k + 1] == j)\n for (int m = 0; m < starty.size(); ++m)\n if (k * BLOK + starty[m] > a)\n odp2 = min(odp2, k * BLOK + starty[m]);\n odp = min(odp, odp2);\n }\n }\n for (int i = 0; i <= 10; ++i)\n {\n vector t(BLOK + l + 1);\n for (int j = 0; j < l; ++j)\n t[j] = wzo[j];\n t[l] = 100;\n for (int j = 0; j < BLOK; ++j)\n t[j + l + 1] = pod[j] + i;\n vector starty;\n KMP(t, l, starty);\n if (starty.size() == 0)\n continue;\n ll odp2 = INF;\n for (int j = A; odp2 == INF && j < 12000000; ++j)\n if (s[j] == i)\n for (int k = 0; k < starty.size(); ++k)\n if (j * BLOK + starty[k] > a)\n odp2 = min(odp2, j * BLOK + starty[k]);\n odp = min(odp, odp2);\n }\n cout << odp;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ac0e48049b314f49959d141f7a7d207d", "src_uid": "649e9f477b97c1f72b05d409b4a99d59", "difficulty": 2700.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef unsigned __int64 ull;\n\nconst ull P = 10000000007;\n\null W[300001] = {1};\nint num[300001];\null block[6][10000]; //\u67d0\u4e00\u5757\u7684hash\u503c\null all[300001]; //\u524d\u82e5\u5e72\u5757\u7684hash\u503c\null w[10001] = {1};\nbool mark[6];\nvector v[6];\n\null oneblock(int type,int from,int len) {\null x = block[type][from + len - 1];\n while (from < 0) ;\n if (from) {\n x -= block[type][from - 1] * w[len];\n }\n return x;\n}\n\null blocks(ull from,ull len) {\null x = all[from + len - 1];\n if (from) {\n x -= all[from - 1] * W[len];\n }\n return x;\n}\n\null get(ull from, ull len) {\null fromid = from / 10000, c, in = from % 10000, to,toid,i,x;\n \n if (in + len <= 10000) { //\u4e00\u5757\u5185\n return oneblock(num[fromid], in, len);\n }\n to = from + len - 1;\n toid = to / 10000;\n x = oneblock(num[fromid], in, 10000 - in) * w[len + in - 10000] + oneblock(num[toid], 0, i = to % 10000 + 1);\n c = toid - fromid;\n while (c == 0);\n if (c > 1) {\n x += blocks(fromid + 1, c - 1) * w[i]; \n }\n return x;\n}\n\nvoid run() {\nint from, len,k,may,j;\null i, x, y, want;\n scanf(\"%d%d\",&from,&len);\n want = get(from, len);\n for (i = from / 10000, x = i * 10000; i <= 200000; ++i,x += 10000) {\n if (!mark[k = num[i]]) {\n mark[k] = true;\n for (j = 0; j < 10000; ++j) {\n may = 10000 - j;\n if (may > len) {\n may = len;\n }\n if (oneblock(k,j,may) == get(from, may)) {\n v[k].push_back(j);\n }\n }\n }\n for (j = 0; j < v[k].size(); ++j) {\n if (((y = x + v[k][j]) > from) && (get(y, len) == want)) {\n printf(\"%I64u\\n\",y);\n return;\n }\n }\n }\n while (1);\n \n}\n\nint main() {\null x;\nint i,j,k;\n\n for (i = 1; i <= 300000; ++i) { //0...9999 10000...19999\n num[i] = num[i / 10];\n j = i % 10;\n if ((j == 4) || (j == 7)) {\n ++num[i];\n }\n \n }\n for (i = 0; i < 6; ++i) {\n x = 0;\n for (j = 0; j < 10000; ++j) {\n x *= P;\n x += num[j];\n x += i;\n block[i][j] = x;\n }\n }\n for (i = 1; i <= 10000; ++i) {\n w[i] = w[i - 1] * P;\n }\n all[0] = block[0][9999];\n for (i = 1; i <= 300000; ++i) {\n W[i] = W[i - 1] * w[10000];\n all[i] = all[i - 1] * w[10000] + block[num[i]][9999];\n }\n run();\n\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3988d706225264fbd5bdf1a1878dade3", "src_uid": "649e9f477b97c1f72b05d409b4a99d59", "difficulty": 2700.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef unsigned long long ull;\n\nconst int N = 19;\nll pw10[N];\n\ninline int countLucky(ll n){\n\tint ret = 0;\n\twhile(n){\n\t\tif(n%10 == 4 || n%10 == 7)ret++;\n\t\tn /= 10;\n\t}\n\treturn ret;\n}\n\nint digCnt(ll n){\n\tint ret = 0;\n\twhile(n){\n\t\tret++;\n\t\tn /= 10;\n\t}\n\treturn ret;\n}\n\nvector dig;\nll mem[N][N], aa;\n\nll func(int ind, int till, int req, int flg, ll cur, ll sf){\n\tif(ind == till){\n\t\tif(req != 0)return -2;\n\t\tif(flg && cur + sf <= aa)return -2;\n\t\t// cout< d)continue;\n\t\tif(req == 0 && (d == 4 || d == 7))continue;\n\t\tll tmp = func(ind - 1, till, req - ((d == 4 || d == 7)?1:0), flg&&(d == dig[ind]), cur + pw10[ind]*d, sf);\n\t\tif(tmp != -2){\n\t\t\tif(ret == -2)ret = tmp;\n\t\t\telse ret = min(ret, tmp);\n\t\t}\n\t}\n\tif(!flg)mem[ind][req] = ret;\n\treturn ret;\n}\n\nll compute(ll lo, ll hi){\n\tassert(hi - lo + 1 < 10);\n\tint len = hi - lo + 1;\n\tvector v(len);\n\tfor(ll i = lo; i <= hi; i++){\n\t\tv[i - lo] = countLucky(i);\n\t}\n\tif(lo <= 10){\n\t\tfor(int b = lo + 1; b <= 100; b++){\n\t\t\tbool flg = true;\n\t\t\tfor(int i = 0; i < len; i++){\n\t\t\t\tif(countLucky(b + i) != v[i]){\n\t\t\t\t\tflg = false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(flg)return b;\n\t\t}\n\t\tassert(false);\n\t}\n\tint dc = digCnt(lo);\n\tll ret = pw10[dc] + lo;\n\tdig.clear();\n\tfor(int i = 0; i < dc; i++){\n\t\tdig.push_back((lo/pw10[i])%10);\n\t}\n\taa = lo;\n\tfor(int d = 0; d < 10; d++){\n\t\tfor(int n9 = 0; n9 + 2 <= dc; n9++){\n\t\t\tfor(int k = 0; k < 9; k++){\n\t\t\t\tint cnt = countLucky(d) + countLucky(k);\n\t\t\t\tif(cnt > v[0])continue;\n\t\t\t\tll suf = k;\n\t\t\t\tfor(int i = 0; i < n9; i++){\n\t\t\t\t\tsuf = suf*10 + 9;\n\t\t\t\t}\n\t\t\t\tsuf = suf*10 + d;\n\t\t\t\tbool flg = true;\n\t\t\t\tfor(int i = 0; i < len; i++){\n\t\t\t\t\tif(v[i] - countLucky(suf + i) != v[0] - cnt){\n\t\t\t\t\t\tflg = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(!flg)continue;\n\t\t\t\tmemset(mem, -1, sizeof(mem));\n\t\t\t\tll tmp = func(dc - 1, n9 + 1, v[0] - cnt, 1, 0, suf);\n\t\t\t\tif(tmp != -2)ret = min(ret, tmp);\n\t\t\t}\n\t\t}\n\t}\n\tfor(int d = 0; d < 10; d++){\n\t\tfor(int n9 = 0; n9 + 2 <= dc; n9++){\n\t\t\tfor(int k = 0; k < 9; k++){\n\t\t\t\tint cnt = countLucky(d) + countLucky(k);\n\t\t\t\tif(cnt > v[0])continue;\n\t\t\t\tll suf = k;\n\t\t\t\tfor(int i = 0; i < n9; i++){\n\t\t\t\t\tsuf = suf*10 + 9;\n\t\t\t\t}\n\t\t\t\tsuf = suf*10 + d;\n\t\t\t\tbool flg = true;\n\t\t\t\tfor(int i = 0; i < len; i++){\n\t\t\t\t\tif(v[i] - countLucky(suf + i) != v[0] - cnt){\n\t\t\t\t\t\tflg = false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(!flg)continue;\n\t\t\t\tmemset(mem, -1, sizeof(mem));\n\t\t\t\tll tmp = func(dc - 1, n9 + 1, v[0] - cnt, 0, pw10[dc], suf);\n\t\t\t\tif(tmp != -2)ret = min(ret, tmp);\n\t\t\t}\n\t\t}\n\t}\n\t\n\treturn ret;\n}\n\nint main(){\n\tios::sync_with_stdio(false);\n\tcin.tie(NULL);\n\tcout<>a>>l;\n\tll pw = 1;\n\twhile(pw*10 <= l)pw *= 10;\n\tll ans = compute(a/pw, (a + l - 1)/pw)*pw + (a%pw);\n\tcout<\n#include\nusing namespace std;\nint n,m,dp[1000005];\n\nint main()\n{\n\tscanf(\"%d%d\",&n,&m);\n\tfor (int i=1;i<=m;i++) dp[i]=2147483647;\n\tfor (int i=1;i<=m;i++)\n\t\tfor (int j=1;j<=n&&j<=i;j++)\n\t\t\tdp[i]=min(dp[i],dp[i-j]+1);\n\tprintf(\"%d\",dp[m]);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "84685f38ae1e9d1e4771d1187a6ca747", "src_uid": "04c067326ec897091c3dbcf4d134df96", "difficulty": 800.0} {"lang": "GNU C++14", "source_code": "/*\n * Created by Dipta Das on 22-11-2018\n * Title: \n * Problem Link: \n * Editorial: \n * Solution: \n * Comments: \n*/\n\n#include \n#include \n#define fin freopen(\"input\", \"r\", stdin)\n#define whatis(x) cerr << #x << \": \" << x << endl;\n\nusing namespace std;\nusing ll = long long;\n\nll numCoins, sum;\n\nll minCoins(ll m, ll V) \n{ \n ll table[V+1]; \n table[0] = 0; \n \n for (ll i=1; i<=V; i++) \n table[i] = LONG_MAX; \n \n for (ll i=1; i<=V; i++) \n { \n for (ll j=0; j> numCoins >> sum; \n cout << minCoins(numCoins, sum) << endl;\n\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a9487e17a998cec255e63ad9c66eba0c", "src_uid": "04c067326ec897091c3dbcf4d134df96", "difficulty": 800.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\n\nlong long getMinCoins(long long n ,long long k, long long qb[]){\n\tif (k == 0 ){\n\t\treturn 0;\n\t}\n\t\n\tif(qb[k] != 0){\n\t\treturn qb[k];\n\t}\n\t\n\tlong long curr = 0 , min = INT_MAX;\n\tfor(long long i = 1 ; i <= n ; i++){\n\t\tif(i > k){\n\t\t\tcontinue;\n\t\t}\n\t\tcurr = 1+getMinCoins(n , k-i ,qb);\n\t\tif (curr < min){\n\t\t\tmin = curr;\n\t\t}\n\t}\n\t\n\tqb[k] = min;\n\tif (min == INT_MAX) min = 0;\n\treturn min;\n}\n\n// void print(long long arr[] , long long n){\n// \tfor(int i = 1 ; i <= n ; i++){\n// \t\tcout<>n>>S;\n\n\tlong long qb[S+1];\n\tmemset(qb,0, sizeof(qb));\n\t\n\t//print(qb,S);\n\tcout<\nusing namespace std;\n#define ll long long\nbool comp(ll a,ll b)\n{\n return a<=b; \n}\nint main()\n{\n ll n,sum;\n cin>>n>>sum;\n vector v;\n v.reserve(100000);\n for(ll i=1;i<=n;i++)\n {\n v.push_back(i);\n }\n ll coin=0;\n while(sum>0)\n {\n auto it=lower_bound(v.begin(),v.end(),sum,comp);\n coin+=(sum/(*it));\n sum=sum%(*it);\n }\n cout<\n#define TRACE\n#ifdef TRACE\n#define TR(...) __f(#__VA_ARGS__, __VA_ARGS__)\ntemplate \nvoid __f(const char* name, Arg1&& arg1){\n cerr << name << \" : \" << arg1 << std::endl;\n}\ntemplate \nvoid __f(const char* names, Arg1&& arg1, Args&&... args){\n const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << \" : \" << arg1<<\" | \";__f(comma+1, args...);\n}\n#else\n#define TR(...)\n#endif\ntypedef long long LL;\ntypedef vector < int > VI;\ntypedef pair< int, int > II;\ntypedef vector < II > VII;\n#define SI(x) scanf (\"%d\", &x)\n#define SLL(x) scanf (\"%lld\", &x)\n#define PI(x) printf (\"%d\\n\", x)\n#define PLL(x) printf (\"%lld\\n\", x)\n#define MOD 98765431\n#define PB push_back\n#define MP make_pair\n#define ALL(v) v.begin(), v.end()\n#define VIF(x,V) for(int x:V)\n#define FILL(a,b) memset(a,b,sizeof(a))\n#define REP(i,j,n) for(int i=j;i=j;i--)\n#define F first \n#define S second\n#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)\nconst int N = 105;\nconst int K = 20;\nconst int U = 31;\nint dp[N][1< prime;\nint n,k;\nint A[N];\n\nbool isPrime(int x)\n{\n\tfor (int i = 2; i * i <= x; i++){\n\t\tif (x % i == 0) return false;\n\t}\n\treturn true;\n}\nint solve(int ind,int mask)\n{\n\tif(ind == n) return 0;\n\tif (dp[ind][mask] != -1) return dp[ind][mask];\n \n\tint &ret = dp[ind][mask];\n\tret=(int) 1e5;\n\n\tfor (int i = 1; i < 60; i++) {\n\t\tint nMask = 0;\n\t\tfor (int j = 0;j < k; j++) {\n\t\t\tif (i % prime[j] == 0) nMask = nMask | 1<\n \n//LIFE IS NOT A PROBLEM TO BE SOLVED\n \n#define rep(i,a,b) for( int i = (int) a; i < (int) b; i++ )\n#define F first\n#define S second\n#define pb push_back\n \nusing namespace std;\n \ntypedef long long int ll;\ntypedef pair ii;\n \nint n, a[111];\nint pd[111][1<<19], mark[111][1<<19];\nvector out;\nvector primes;\n\nbool isPrime(int n){\n\tif(n==2) return true;\n\trep(i, 2, n){\n\t\tif(n%i==0)\n\t\t\treturn false;\n\t}\n\treturn true;\n}\n\nint solve(int i, int m){\n\tif(i==n) return 0;\n\tif(pd[i][m]!=-1) return pd[i][m];\n\tint ret = 0x3f3f3f3f;\n\trep(j, 1, 60){\n\t\tint yep = true, newM = m;\n\t\trep(k, 0, primes.size()){\n\t\t\tif(j%primes[k]==0){\n\t\t\t\tif(m&(1<> n;\n\trep(i, 0, n) cin >> a[i];\n\tint ans = solve(0, 0);\n\trec(0, 0);\n\trep(i, 0, out.size()){\n\t\tif(i) cout << \" \";\n\t\tcout << out[i];\n\t}\tcout << \"\\n\";\n\t\n\treturn 0;\n} ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b313549f3adbdffe607e2f072e237b7c", "src_uid": "f26c74f27bbc723efd69c38ad0e523c6", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include \n\n\n\n#define inf 0x3f3f3f3f\n\n#define mod 1000000007\n\n#define pb push_back\n\n#define sq(x) ((x)*(x))\n\n#define x first\n\n#define y second\n\n#define bpt(x) (__builtin_popcount(x))\n\n#define bptl(x) (__builtin_popcountll(x))\n\n#define bit(x, y) (((x)>>(y))&1)\n\n#define bclz(x) (__builtin_clz(x))\n\n#define bclzl(x) (__builtin_clzll(x))\n\n#define bctz(x) (__builtin_ctz(x))\n\n#define bctzl(x) (__builtin_ctzll(x))\n\n#define PQ priority_queue, greater >\n\n\n\n#define eps 1e-8\n\n#define squ(a,b) (a)*(a)+(b)*(b)\n\n#define pi 3.1415926535897932384626433832795\n\n\n\nusing namespace std;\n\ntypedef long long INT;\n\ntypedef vector VI;\n\ntypedef pair pii;\n\ntypedef pair pi3;\n\ntypedef double DO;\n\n\n\ntemplate inline void smin(T &a, U b) {if(a>b) a=b;}\n\ntemplate inline void smax(T &a, U b) {if(ainline void gn(T &x) {char c, sg=0; while (c=getchar(), (c>'9' || c<'0') && c!='-');for((c=='-'?sg=1, c=getchar():0), x=0; c>='0' && c<='9'; c=getchar()) x=(x<<1)+(x<<3)+c-'0';if(sg) x=-x;}\n\ntemplateinline void gn(T &x, T1 &y) {gn(x); gn(y);}\n\ntemplateinline void gn(T &x, T1 &y, T2 &z) {gn(x); gn(y); gn(z);}\n\ntemplateinline void print(T x) {if(x<0) {putchar('-');return print(-x);}if(x<10) {putchar('0'+x);return;} print(x/10);putchar(x%10+'0');}\n\ntemplateinline void printsp(T x) {print(x); putchar(' ');}\n\ntemplateinline void println(T x) {print(x); putchar('\\n');}\n\ntemplateinline void print(T x, U y) {printsp(x); println(y);}\n\ntemplateinline void print(T x, U y, V z) {printsp(x); printsp(y); println(z);}\n\n\n\nint power(int a, int b, int m, int ans=1) {\n\n\tfor(; b; b>>=1, a=1LL*a*a%m) if(b&1) ans=1LL*ans*a%m;\n\n\treturn ans;\n\n}\n\n\n\nconst int A=60;\n\n\n\nint f[A],dp[111][300000],a[111],flag[A],cp;\n\npii pre[111][300000];\n\n\n\nvoid solve_A(){\n\n\t\n\n\tint n;gn(n);\n\n\tfor(int i=1; i<=n; i++) gn(a[i]);\n\n\t\n\n\tfor(int i=2; i0; r=(r-1) & b ){\n\n\t\t\t\tif(dp[i-1][r]+abs(a[i]-k)0; i--){\n\n\t\tans.pb(pre[i][g].y);\n\n\t\tg=pre[i][g].x;\n\n\t}\n\n\t\n\n\treverse(ans.begin(),ans.end());\n\n\t\n\n\tfor(int i=0; i\nusing namespace std;\n\ntypedef long long ll;\ntypedef vector vi;\ntypedef vector vl;\ntypedef vector vvi;\ntypedef vector vvl;\ntypedef pair pii;\ntypedef pair pdd;\ntypedef pair pll;\ntypedef vector vii;\ntypedef vector vll;\n\n#define PB push_back\n#define F first\n#define S second\n#define MP make_pair\n\n#define PI acos(-1)\n#define eps 1e-9\n#define inf 100000000\n#define MOD 1000000007\n//#define harmonic(n) 0.57721566490153286l+log(n)\n\n#define mem(a,b) memset(a, b, sizeof(a) )\n#define gcd(a,b) __gcd(a,b)\n#define lcm(a,b) (a*(b/gcd(a,b)))\n#define sqr(a) ((a) * (a))\n\n#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n\ntypedef vector::iterator vit;\ntypedef set::iterator sit;\n\ninline bool checkBit(ll n, int i) { return n&(1LL<\nostream& operator << ( ostream& os, const pair< F, S > & p ) {\n return os << \"(\" << p.first << \", \" << p.second << \")\";\n}\n\ntemplate < typename T >\nostream &operator << ( ostream & os, const vector< T > &v ) {\n os << \"{\";\n for(auto it = v.begin(); it != v.end(); ++it) {\n if( it != v.begin() ) os << \", \";\n os << *it;\n }\n return os << \"}\";\n}\n\ntemplate < typename T >\nostream &operator << ( ostream & os, const set< T > &v ) {\n os << \"[\";\n for(auto it = v.begin(); it != v.end(); ++it) {\n if( it != v.begin() ) os << \", \";\n os << *it;\n }\n return os << \"]\";\n}\n\ntemplate < typename F, typename S >\nostream &operator << ( ostream & os, const map< F, S > &v ) {\n os << \"[\";\n for(auto it = v.begin(); it != v.end(); ++it) {\n if( it != v.begin() ) os << \", \";\n os << it -> first << \" = \" << it -> second ;\n }\n return os << \"]\";\n}\n\n#define dbg(args...) do {cerr << #args << \" : \"; faltu(args); } while(0)\n\nvoid faltu () {\n cerr << endl;\n}\n\ntemplate \nvoid faltu( T a[], int n ) {\n for(int i = 0; i < n; ++i) cerr << a[i] << ' ';\n cerr << endl;\n}\n\ntemplate \nvoid faltu( T arg, const hello &... rest) {\n cerr << arg << ' ';\n faltu(rest...);\n}\n#else\n#define dbg(args...)\n#endif // yamin\n\n#define MX 60\n\ntypedef pairobj;\n\nint n, seive[MX], prime[MX], store[60], c;\nint a[110];\nint dp[110][1<<18];\npii nxt[110][1<<18];\nint ans[110][1<<18];\n\nvoid seiveGen () {\n int sqrtn = sqrt ( MX );\n for ( int i = 3; i <= sqrtn; i += 2 ) {\n if ( !seive[i>>1] ) {\n for ( int j = i * i; j < MX; j += i + i ) {\n seive[j>>1] = 1;\n }\n }\n }\n prime[c++] = 2;\n for ( int i = 3; i < MX; i += 2 ) {\n if ( !seive[i>>1] ) prime[c++] = i;\n }\n dbg ( c );\n prime[c++] = inf;\n}\n\nvoid init() {\n for ( int i = 1; i < MX; i++ ) {\n for ( int j = 0; prime[j] <= i; ++j ) {\n if ( i % prime[j] == 0 ) {\n store[i] = setBit ( store[i], j );\n }\n }\n dbg ( i, store[i] );\n }\n}\n\nint recur ( int index, int mask ) {\n if ( index == n ) return 0;\n\n int &ret = dp[index][mask];\n if ( ret != -1 ) return ret;\n\n ret = inf;\n\n for ( int i = 1; i < MX; ++i ) {\n if ( store[i] & mask ) continue;\n int temp = recur ( index + 1, mask | store[i] );\n if ( temp + abs ( i - a[index] ) < ret ) {\n nxt[index][mask] = pii ( index + 1, mask );\n ret = temp + abs ( i - a[index] );\n ans[index][mask] = i;\n }\n }\n\n return ret;\n}\n\nvoid ansGen () {\n recur ( 0, 0 );\n pii cur ( 0, 0 ); dbg ( n );\n\n for ( int i = 0; i < n; ++i ) {\n cout << ans[cur.F][cur.S] << \" \";\n cur = nxt[cur.F][cur.S];\n }\n\n}\n\nint main () {\n\n //optimize();\n\n #ifdef yamin\n freopen ( \"input.txt\", \"r\", stdin );\n #endif // yamin\n\n seiveGen(); init();\n\n cin >> n;\n\n for ( int i = 0; i < n; ++i ) cin >> a[i];\n\n mem ( dp, -1 );\n\n ansGen();\n\n return 0;\n\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "266fd62c1bcd1dc86ddaf9f3be985e90", "src_uid": "f26c74f27bbc723efd69c38ad0e523c6", "difficulty": 2000.0} {"lang": "MS C++", "source_code": "#include\n#include\nusing namespace std;\nint main(){\n\tint i,j=0,k,n,c=0,x,b=0 ;\n\tchar a[200];\n\tcin>>n;\n\tx=n/2;\n\tfor( i=0;i>a[i];\n\t}\n\tfor( i=0;i\n#include\nusing namespace std;\nint main(){\n\tint i,j=0,k,n,c=0,x,b=0 ;\n\tchar a[200];\n\tcin>>n;\n\tx=n/2;\n\tfor( i=0;i>a[i];\n\t}\n\tfor( i=0;i\n#include\n#include\n#include\n#include\nusing namespace std;\n\nmain(){\n char s[200];\n int i, jumlah=0, n, a, ubah;\n \n cin>>n;\n cin>> s;\n \n for (i=0;i\n#include\nusing namespace std;\nint main()\n{\n int n,c=0,j=0,x ;\nchar a[200];\n\n cin>>n;\n x=n/2;\n for(int i=0;i>a[i];\n for(int i=0;i\nusing namespace std;\n\nint main()\n{\n\tint numberOfStairs, stepMultiplier, steps = 0;\n\n\tif (numberOfStairs < stepMultiplier)\n\t{\n\t\tcout << -1;\n\t}\n\telse\n\t{\n\t\tif (numberOfStairs % 2 == 0)\n\t\t{\n\t\t\tsteps = numberOfStairs / 2;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tsteps = numberOfStairs / 2 + 1;\n\t\t}\n\t\tif (steps%stepMultiplier != 0)\n\t\t{\n\t\t\tsteps++;\n\t\t}\n\t\tcout << steps;\n\t}\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5e5579e9304fcfce9ca7739041098d83", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include\nint main()\n{\n int n,m,i,j,k;\n scanf(\"%d %d\",&n,&m);\n if(n2*k*m) k++;\n else if(n<=2*k*m) {break;\n }\n }\n \n printf(\"%d\",2*k);\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "148feb7b5586c903e7fe9f0bb3c518fe", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0} {"lang": "GNU C++17 Diagnostics", "source_code": "#include\nusing namespace std;\nint main() {\n\n\tint stair ;\n\tint n;\n\tcin >> stair>>n;\n\tint s = stair;\n\tint step = s / 2+(s%2);\n\tif (n < stair) {\n\t\twhile (step%n != 0) {\n\t\t\ts -= 2;\n\t\t\tstep = s / 2 + (stair - s);\n\t\t}\n\t\tcout << step;\n\t}\n\telse if(n==stair){cout << n;}\n\telse\n\t\tcout << -1;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fb7f3299680f3d0fd0bc54df78415649", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nint main()\n{\n int m,n,i;\n \n scanf(\"%d %d\",&n,&m);\n \n if (n%2 == 0)\n {\n for (i=n/2 ; i<=n ; i++)\n {\n if (i%m == 0)\n {\n printf(\"%d\",i);\n break; \n }\n }\n }\n \n if (n%2 == 1)\n {\n for (i=(n/2) + 1 ; i<=n ; i++)\n {\n if (i%m == 0)\n {\n printf(\"%d\",i);\n break; \n }\n }\n }\n \n getch();\n return -1;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2a2d1b3018aefe42a8dbb82771457c89", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "/*\nID: new.sam1\nPROG: ride\nLANG: C++11 \n*/\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n // ofstream fout(\"output.txt\");\n //ifstream fin(\"input.txt\");\n \n long long n,k;\n cin>>n>>k;\n if(k == 0)\n cout<0)\n {\n if(g%10 == 0)\n {\n cnt++;\n g/=10;\n }\n if(k<=cnt)\n return cout<mx)\n {\n mx = cnt;\n p=i;\n }\n cnt=0;\n \n }\n \n long long ms = k - mx;\n if(p==0)\n p = 1;\n \n while(ms--)\n { p*=10;}\n\n cout<\nusing namespace std;\nlong long n,k,ANS,ans,an,x;\nmain ()\n{\n\tcin>>n>>k;\n\t\n\tlong long x=n;\n\t\n\twhile (x%10==0)\n\t{\n\t\tx=x/10;\n\t\tans++;\n\t}\n\t\n\tif (ans>=k)\n\t{\n\t\tcout<ans)\n\t\t{\n\t\t\tans=an;\n\t\t\tANS=n*i;\n\t\t}\n\t}\n\t\n\tx=ANS;\n\t\n\tans=0;\n\t\n\twhile (x%10==0)\n\t{\n\t\tx=x/10;\n\t\tans++;\n\t}\n\t\n\tif (ans>=k)\n\t{\n\t\tcout<\n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n long long n;\n int k,x=1;\n cin >> n >> k;\n for (int i=0;i\n\nusing namespace std;\n#define lol long long\n\nint napa(lol int n)\n{\n int cnt=0;\n while(1)\n {\n int res=n%10;\n if(res!=0)break;\n else cnt++;\n n=n/10;\n }\n return cnt;\n}\n\nint main()\n{\n lol int j=5,k,n,res;\n cin>>n>>k;\n if(napa(n)>=k)cout<=k)break;\n j=j+5;\n }\n cout<\n#define pb push_back\n#define ss second\n#define ff first\n#define mp make_pair\n#define ll long long int\nusing namespace std;\n \nvector vec,num;\nvector > vp;\nll mini;\n \nint dx[]={0,1,0,-1};\nint dy[]={1,0,-1,0};\n\nmap has;\n \nll ar[5000002],br[512345];\n\nconst int MOD = 1e9 + 7;\n \n \n \nint main() \n{\n\tll c,i,p,q,d,k,len,y,j,a,b,t,ans,flag,n,m,g=0,res=0,sum=0,e,f,r,minm=99999999,maxm=-1,x,hr;\n\tc=0;\n//\tfreopen(\"output.out\",\"w\",stdout);\n\tstring str,ptr,dtr;\n\tchar ch,prev;\n\t\n cin>>x;\n k=x;\n \n cin>>str>>ptr;\n \n if(ptr[0]=='7' || ptr[1]=='7' || str[0]=='7' || str[1]=='7')\n cout<<0;\n else\n {\n \thr=((str[0]-48)*10 + (str[1]-48));\n \tn=((ptr[0]-48)*10 + (ptr[1]-48));\n \tc=1;\n \tp=n;\n \twhile(1)\n \t{\n \t\tp=p-x;\n \t\tif(p<=0)\n \t\t{\n \t\t\tp=(p+60)%60;\n \t\t\thr=(hr-1);\n \t\t\tif(hr<0)\n \t\t\t{\n \t\t\t\thr=(hr+12)%12;\n\t\t\t\t }\n\t\t\t\t \n\t\t\t\t if(hr%10==7)\n\t\t\t\t {\n\t\t\t\t \tcout<\nusing namespace std;\nint n,h,m,t;\nint sum;\nint main()\n{\n while(scanf(\"%d\",&n)!=-1)\n {\n sum=0;\n scanf(\"%d%d\",&h,&m);\n while(h!=7&&h!=17&&m!=7&&m!=17&&m!=27&&m!=37&&m!=47&&m!=57)\n {\n if(m-n>=0)\n {\n m=m-n;\n }\n else\n {\n m=m-n+60;\n h--;\n }\n sum++;\n }\n printf(\"%d\\n\",sum);\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d3923f540263ee44a206c35142830272", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb", "difficulty": 900.0} {"lang": "GNU C++17 Diagnostics", "source_code": "#include\n#include\n#include\n#include\n#include\nusing namespace std;\n\nint main() {\n int x, a, b, aa, bb;\n scanf(\"%d\", &x);\n scanf(\"%d%d\", &a, &b); aa = a, bb = b;\n for(int i = 0; i <= 24*60; i ++) {\n int tmp = x*i; a = aa, b = bb;\n while(b < tmp) { b += 60; a --; if(a == -1) a = 23; }\n b -= tmp;\n if(b%10 == 7 || b/10 == 7 || a%10 == 7 || a/10 == 7) {\n printf(\"%d\\n\", i);\n return 0;\n }\n }\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "720e08f3a4ec25457c530a55057eb16c", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include\n#include\nstruct app\n{\n\tint a[111];\n\tint b[100];\n}pp;\nint kkk[111111116];\nint main()\n{\n\tint a,b,p,k=0,m,i,j,t=0,kk,q,qq,l=0;\n\tfor(i=0;i<24;i++)\n\t{ k=0;\n\t\tfor(j=0;j<=59;j++)\n\t\t{\n\t\tpp.a[i]=i;\n\t\tpp.b[k]=j;\n\t\tk++;\n\t\t}\n\t}\n\tmemset(kkk,0,sizeof(kkk));\n\tscanf(\"%d\",&m);\n\tscanf(\"%d%d\",&p,&k);\n\tt=p;\n\tfor(qq=0;qq<22;qq++)\n\t{\n\t\tif(l>0)\n\t\t\tt=23;\n\t\tfor(i=t;i>=0;i--)\n\t\t{\n\t\t\tfor(j=0;j<=59;j++)\n\t\t\t{\n\t\tif(i==p&&pp.b[j]>k)\n\t\t\t\tbreak;\n\t\t\t\tkk=p-i;\n\t\t\t q=kk*60+k-pp.b[j];\n\t\t\t\tif(l==0&&i0)\n\t\t\t\t\tq=(p+24-i)*60-pp.b[j]+k;\n\t\t\t\tif(q%m==0&&(pp.a[i]%10==7||pp.b[j]%10==7))\n\t\t\t\t{\n\t\t\t\tkk=99999;\n\t\t\t\tprintf(\"%d %d %d\\n\",q,pp.a[i],pp.b[j]);\n\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif(kk==99999)\n\t\t\t\tbreak;\n\n\t\t\t}\n\t\tif(kk==99999)\n\t\t\t\tbreak;\n\t\tl++;\n\t}\n\t\n\t\t\tprintf(\"%d\\n\",q/m );\n\t\t\t\treturn 0;\n}\n\n\n\n \t\t \t\t \t \t \t \t\t\t\t \t \t", "lang_cluster": "C++", "compilation_error": false, "code_uid": "671991a40e1eae705903f2afef31b6c4", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb", "difficulty": 900.0} {"lang": "MS C++", "source_code": "#include \n#include \n#define MAXI 8\n#define MAXL 9\n#define MOD 1000000007\n\nusing namespace std;\n\nlong long f[MAXI][MAXL][2],c[MAXL];\nint n,length,an[MAXL];\n\ninline void update(long long &i, const long long j)\n{\n i=(i+j)%MOD;\n}\n\ninline int isfs(const int k)\n{\n return (k==4||k==7);\n}\n\ninline void init()\n{\n memset(f,0,sizeof(f));\n f[0][0][1]=1;\n \n for(int i=0;i>n;\n for(int k=n,i=0;k;an[i++]=k%10,k/=10,length++);\n \n init();\n solve();\n while(1);\n \n return 0; \n} \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "810b45e30d3c9fae2b683f3f9f41cd7b", "src_uid": "656ed7b1b80de84d65a253e5d14d62a9", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n\nusing namespace std;\nconst int MOD = 1000000007;\nconst int small_lucks[10] = {0,0,0,0,0,1,1,1,2,2};\nconst int small_unlucks[10] = {0,1,2,3,4,4,5,6,6,7};\nconst int is_luck[10] = {0,0,0,0,1,0,0,1,0,0};\nint lucks[10];\n\nlong long count(int sum, int number) {\n\tif (number == 0) return 1;\n\tlong long result = 0;\n\tfor (int i = sum; i >= 0; --i) {\n\t\t--lucks[i];\n\t\tlong long c = count(sum-i, number-1);\n\t\t++lucks[i];\n\t\tresult += c*lucks[i];\n\t\tresult %= MOD;\n\t}\n\treturn result;\n}\n\nint main() {\n\tint n;\n\tchar t[10];\n\tstring s;\n\tcin >> n;\n\tsprintf(t, \"%d\", n);\n\ts = t;\n\tint l = s.length();\n\tint luck[10][10];\n\tluck[0][0] = 1;\n\tluck[1][0] = 8;\n\tluck[1][1] = 2;\n\tfor (int i = 2; i <= l; ++i)\n\t\tfor (int j = 0; j <= i; ++j) {\n\t\t\tluck[i][j] = 0;\n\t\t}\n\tfor (int i = 2; i <= l; ++i)\n\t\tfor (int j = 0; j <= i; ++j) {\n\t\t\tif (j > 0) luck[i][j] += luck[i-1][j-1]*2;\n\t\t\tif (i > j) luck[i][j] += luck[i-1][j]*8;\n\t\t}\n\tint kk[10];\n\tkk[0] = 0;\n\tfor (int i = 1; i <= l; ++i)\n\t\tkk[i] = kk[i-1] + is_luck[s[i-1]-'0'];\n\tfor (int i = 0; i <= 10; ++i)\n\t\tlucks[i] = 0;\n\tlucks[kk[l]] += 1;\n\tfor (int i = 0; i <= l-1; ++i)\n\t\tfor (int j = 0; j <= l-1-i; ++j) {\n\t\t\tint k = s[i] - '0';\n\t\t\tlucks[kk[i]+j+1] += luck[l-1-i][j]*small_lucks[k];\n\t\t\tlucks[kk[i]+j] += luck[l-1-i][j]*small_unlucks[k];\n\t\t}\n\t--lucks[0];\n\tint max = l;\n\twhile (lucks[max] == 0) --max;\n\tlong long ans = 0;\n\tfor (int i = max; i > 0; --i) {\n\t\tans += lucks[i] * count(i-1, 6) % MOD;\n\t}\n\tcout << ans % MOD << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4c8c079d10128422d4f5d5d9032f8c72", "src_uid": "656ed7b1b80de84d65a253e5d14d62a9", "difficulty": 1900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nlong long mod = 1000000007;\n\nlong long cnt[11] = {0};\n\nlong long c[11][11] = {0};\n\nlong long dp[12][7][1000] = {0};\n\nvoid f(long long a, long long len, long long mul, long long add = 0){\n\tif (len == 0){\n\t\tcnt[add] = (cnt[add] + 1) % mod;\n\t\treturn;\n\t}\n\tfor (long long i = 0; i < 10; i++){\n\t\tlong long iadd = 0;\n\t\tif (i == 4 || i == 7)\n\t\t\tiadd = 1;\n\t\tif (a >= (i + 1) * mul){\n\t\t\tlong long nluck = 1, luck = 1;\n\t\t\tfor (int j = 1; j <= len - 1; j++){\n\t\t\t\tnluck *= 8;\n\t\t\t}\n\t\t\tfor (int j = 0; j <= len - 1; j++){\n\t\t\t\tcnt[add + j + iadd] = (cnt[add + j + iadd] + (luck * nluck * c[len - 1][j]) % mod) % mod;\n\t\t\t\tluck *= 2;\n\t\t\t\tnluck /= 8;\n\t\t\t}\n\t\t}\n\t\telse{\n\t\t\tf(a - i * mul, len - 1, mul / 10, add + iadd);\n\t\t\treturn;\n\t\t}\n\t}\n}\n\nvoid calc(){\n\tfor (int i = 0; i <= 11; i++){\n\t\tfor (int k = 0; k <= 6; k++){\n\t\t\tfor (int j = 0; j <= 10; j++){\n\t\t\t\tdp[i][k][j] = 0;\n\t\t\t}\n\t\t}\n\t}\n\tdp[0][0][0] = 1;\n\tfor (int i = 0; i <= 10; i++){\n\t\tfor (int k = 0; k < 6; k++){\n\t\t\tfor (int j = 0; j <= 10; j++){\n\t\t\t\tlong long mul = 1;\n\t\t\t\tfor (int n = 1; n + k <= 6; n++){\n\t\t\t\t\tif (n > cnt[i])\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tmul = (mul * (cnt[i] - (n - 1))) % mod;\n\t\t\t\t\tdp[i + 1][n + k][j + i * n] = (dp[i + 1][n + k][j + i * n] + dp[i][k][j] * ((mul * c[n + k][n]) % mod)) % mod; \n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nint main(){\n\t#ifndef ONLINE_JUDGE\n\tfreopen(\"input.txt\", \"rt\", stdin);\n\tfreopen(\"output.txt\", \"wt\", stdout);\n\t#else\n\t#endif\n\n\tlong long n;\n\tcin>>n;\n\n\tc[0][0] = 1;\n\tfor (int i = 1; i <= 10; i++){\n\t\tc[i][0] = 1;\n\t\tfor (int j = 1; j <= i; j++){\n\t\t\tc[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;\n\t\t}\n\t}\n\n\tlong long len = 1;\n\tlong long mul = 1;\n\n\twhile (mul * 10 <= n){\n\t\tlen++;\n\t\tmul *= 10;\n\t}\n\n\tf(n, len, mul);\n\n\tcnt[0]--;\n\n\tlong long temp = 0;\n\n\tfor (int i = 0; i <= 10; i++){\n\t\tif (cnt[i] == 0)\n\t\t\tcontinue;\n\t\tcnt[i]--;\n\t\tcalc();\n\t\tlong long a = 0;\n\t\tfor (int k = 1; k <= 11; k++){\n\t\t\tfor (int j = 0; j < i; j++){\n\t\t\t\ta = (a + dp[k][6][j]) % mod;\n\t\t\t}\n\t\t}\n\t\tcnt[i]++;\n\t\ta = (a * cnt[i]) % mod;\n\t\ttemp = (temp + a) % mod;\n\t}\n\n\tcout<\nusing namespace std;\ntypedef long long ll;\nconst ll six = 720ll;\nconst ll mod = 1e9 + 7;\nll sv[4], m;\nll cnt[10];\n\nll luck_count(ll x){\n ll ans = 0;\n while(x){\n ans += (x%10 == 4 || x%10 == 7);\n x/=10;\n }\n return ans;\n}\nll fast(ll b, ll e){\n if(!e)\n return 1;\n ll cur = (e&1)? b : 1;\n return cur * fast(b * b %mod, e/2)%mod;\n}\nll nCr(ll n, ll r){\n if(r > n)\n return 0;\n if(n == r)\n return 1;\n return nCr(n - 1, r) * n %mod * fast(n - r, mod - 2) % mod;\n\n}\nll brdo_luck_count(string s){\n ll cnt = 0;\n for(ll i = 0; i < s.size(); i++)\n cnt += (s[i] == '4' || s[i] == '7');\n return cnt;\n}\nll dp[10][10][7];\nll n_o_w[12];\nll solve(int idx, int sv, ll lft){\n if(sv < 0)\n return 0;\n if(idx == 10)\n return (lft == 0);\n\n ll &ret = dp[idx][sv][lft];\n if(~ret)\n return ret;\n ret = 0;\n\n for(int i = 0; i <= min(lft, cnt[idx]); i++){\n ret = (ret + (nCr(cnt[idx],i) * solve(idx + 1, sv - (idx * i), lft - i))%mod) %mod;\n }\n return ret;\n}\nvoid gen_find(){\n memset(dp, -1, sizeof dp);\n for(int i = 0; i <= 9; i++)\n n_o_w[i] = solve(0,i,6);\n}\nvoid solve(){\n gen_find();\n ll acc = 0;\n ll ans = 0;\n for(int i = 1; i <= 9; i++){\n ans = (ans + (cnt[i] * (n_o_w[i - 1] * six)%mod)%mod)%mod;\n }\n printf(\"%lld\\n\", ans);\n exit(0);\n}\nint main(){\n cin >> m;\n for(ll i = 1; i < min(m + 1, 1000ll); i++){\n cnt[luck_count(i)]++;\n }\n if(m < 1000){\n solve();\n }\n for(ll i = 0; i <= 9; i++){\n for(ll j = 0; j <= 9; j++){\n for(ll k = 0; k <= 9; k++){\n string tmp = \"\";\n tmp.push_back('0' + i);\n tmp.push_back('0' + j);\n tmp.push_back('0' + k);\n sv[brdo_luck_count(tmp)]++;\n }\n }\n }\n ll goz2 = m;\n for(ll i = 0; i < 3; i++)\n goz2/=10;\n for(ll i = 1; i< goz2; i++){\n ll ro = luck_count(i);\n for(ll j = 0; j < 4; j++)\n cnt[ro + j] += sv[j];\n }\n goz2 *= 1000;\n for(ll i = goz2; i <= m; i++){\n cnt[luck_count(i)]++;\n }\n solve();\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f0175b6b77f00a8b22a42b48c8ed9c7e", "src_uid": "656ed7b1b80de84d65a253e5d14d62a9", "difficulty": 1900.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int x,y,z;\n cin>>x>>y>>z;\n if(abs(x-y)<=z&&z!=0) cout<<\"?\"<y+z) cout<<\"+\"<\nusing namespace std;\nint main () {\n\tint n,m,v;\n\tcin>>n>>m>>v;\n\tif(n==0&&m==0||n>m&&n==v||m>n&&m==v||m==n&&n==v||m>n&&n+v==m||n>m&&m+v==n||m==n&&v>0){\n\t\n\tcout<<\"?\";\n\treturn 0;\n}\n\tif(n==m){\n\t\n\tcout<<0;\n\treturn 0;\n}\nif(m>n)\ncout<<\"-\";\nelse\nif(m\nusing namespace std;\n\nint main()\n{\n long long int x,y,z,a,b,c;\n cin>>x>>y>>z;\n if(x>y)\n {\n a=x-y;\n if(a>z)\n cout<<\"+\"<x)\n {\n a=y-x;\n if(a>z)\n cout<<\"-\"<z)\n cout<<\"0\"<\nusing namespace std;\nint main()\n{\n int x,y,z,a,b;\n cin>>x>>y>>z;\n if(z==0)\n {\n if(x>y)\n cout<<\"+\"<b)\n cout<<\"+\"<\r\n#define int long long\r\nusing namespace std;\r\nconst long long mod=998244353;\r\nconst int N=520;\r\nint n,k;\r\nlong long f[N][N][N],fact[N],invfact[N],pre[N];\r\n\r\nlong long pwr(long long a,long long x)\r\n{\r\n if (x==0) return 1ll;\r\n long long ans=pwr(a,x/2);\r\n ans=(ans*ans)%mod;\r\n if (x%2==1) ans=(ans*a)%mod;\r\n return ans;\r\n}\r\n\r\nlong long C(long long n,long long k)\r\n{\r\n if (n> n >> k;\r\n fact[0]=1ll;\r\n invfact[0]=1ll;\r\n for (long long i=1; i<=n+n; i++)\r\n {\r\n fact[i]=(fact[i-1]*i)%mod;\r\n invfact[i]=pwr(fact[i],mod-2);\r\n }\r\n for (int i=2; i<=n; i++)\r\n {\r\n for (int j=1; j<=k; j++)\r\n {\r\n pre[j]=pre[j-1];\r\n for (int t=1;t\r\n#define int long long\r\nusing namespace std;\r\nconst long long mod=998244353;\r\nconst int N=510;\r\nint n,k;\r\nlong long f[N][N][N],fact[N],invfact[N],pre[N];\r\n\r\nlong long pwr(long long a,long long x)\r\n{\r\n if (x==0) return 1ll;\r\n long long ans=pwr(a,x/2);\r\n ans=(ans*ans)%mod;\r\n if (x%2==1) ans=(ans*a)%mod;\r\n return ans;\r\n}\r\n\r\nlong long C(long long n,long long k)\r\n{\r\n if (n> n >> k;\r\n fact[0]=1ll;\r\n invfact[0]=1ll;\r\n for (long long i=1; i<=n+n; i++)\r\n {\r\n fact[i]=(fact[i-1]*i)%mod;\r\n invfact[i]=pwr(fact[i],mod-2);\r\n }\r\n for (int i=2; i<=n; i++)\r\n {\r\n for (int j=1; j<=k; j++)\r\n {\r\n pre[j]=pre[j-1];\r\n for (int t=1;t\r\nusing namespace std;\r\n\r\n#define ll long long\r\n#define lll __int128\r\n#define lb long double\r\n#define D double\r\n\r\n#define psb push_back\r\n#define mkp make_pair\r\n\r\n#define min3(xxx,yyy,zzz) min(min(xxx,yyy),zzz)\r\n#define max3(xxx,yyy,zzz) max(max(xxx,yyy),zzz)\r\n\r\n#define gi greater\r\n#define gl greater\r\n#define vl vector\r\n#define vi vector\r\n#define pii pair\r\n#define pll pair\r\n#define fi first\r\n#define se second\r\n\r\n#define rep(variable,leftrange,rightrange) for(int variable=leftrange;variable<=rightrange;++variable)\r\n#define Rep(variable,leftrange,rightrange) for(int variable=leftrange;variable>=rightrange;--variable)\r\n\r\n#define Seed mt19937 rANd(random_device{}())\r\n#define rd(p) (rANd()%p)\r\n\r\n#define ss stable_sort\r\n#define nxp next_permutation\r\n#define rds random_shuffle\r\n\r\n#define mem(x,y) memset(x,y,sizeof x) \r\n#define Finda(a,siz,b) (lower_bound(a+1,a+siz+1,b)-a)\r\n#define Findv(a,b) (lower_bound(a.begin(),a.end(),b)-a.begin())\r\n#define qc(v) v.erase(unique(v.begin(),v.end()),v.end())\r\n#define all(x) x.begin(),x.end()\r\n\r\n#define sq(x) ((x)*(x))\r\n#define lowbit(x) ((x)& -(x))\r\n\r\n#define upmin(x,y) x=min(x,y)\r\n#define upmax(x,y) x=max(x,y)\r\ntemplate inline void read(T &t)\r\n{bool flag = 1 ;char c=getchar();t=0;while(!isdigit(c)){ if(c=='-') flag = 0; c=getchar();}while(isdigit(c))t=(t<<3)+(t<<1)+c-48,c=getchar(); if(!flag) t=~(t-1);}\r\ntemplate inline void read(T& t, Args&... args){read(t);read(args...);}\r\ntemplate inline void wrt(T x)\r\n{if(x<0) x=~(x-1),putchar('-'); if(x>9) wrt(x/10); putchar(x%10+'0');}\r\ntemplate inline void wrt(T x,char c) {wrt(x);putchar(c);}\r\n\r\n#define FileIO(x) freopen(#x\".in\",\"r\",stdin);freopen(#x\".out\",\"w\",stdout)\r\n#define debug puts(\"I am still alive\") \r\n#define S_debug(l,r,val) printf(\"[%d,%d] : %d \\n\",l,r,val)\r\n#define P_debug(a,b) printf(#a\"[%d] = %d \\n\",b,a[b])\r\n#define A_debug(a,b) rep(i,1,b) P_debug(a,i);\r\n\r\nconst int N = 1600000 + 20 ;\r\n\r\nnamespace Graph{\r\n class Tree {\r\n public:\r\n vector w , jump[26] ;\r\n vector > ed ;\r\n vector fa ;\r\n vector dep ;\r\n vector siz ;\r\n vector dfn ;\r\n vector rnk ;\r\n vector hv ;\r\n vector top ;\r\n bool use_l = 0 , use_T = 0 ;\r\n int _tim = 0;\r\n int _n = 0 ; \r\n int _rt = 1;\r\n void adde(int u , int v)\r\n {\r\n ed[u].emplace_back(v);\r\n ed[v].emplace_back(u);\r\n }\r\n Tree(int _siz , bool use_lca = false , bool useTreepo = false)\r\n {\r\n use_l = use_lca;\r\n use_T = useTreepo ;\r\n _n = _siz ;\r\n _siz += 20 ;\r\n ed.resize(_siz , {}) ;\r\n fa.resize(_siz , 0 ) ;\r\n w.resize(_siz , 0 );\r\n dep.resize(_siz , 0) ;\r\n siz.resize(_siz , 0) ;\r\n if(use_lca) rep(i,0,23) jump[i].resize(_siz , 0) ;\r\n if(useTreepo) dfn.resize(_siz , 0) , rnk.resize(_siz , 0) , hv.resize(_siz , 0) , top.resize(_siz , 0);\r\n\r\n } \r\n void dfs(int x,int f)\r\n {\r\n fa[x] = f ;\r\n dep[x] = dep[f] + 1 ;\r\n siz[x] = 1 ;\r\n if(use_l) \r\n {\r\n jump[0][x] = f; \r\n rep(i,1,23) jump[i][x] = jump[i-1][jump[i-1][x]] ; \r\n }\r\n\r\n for(int p : ed[x])\r\n {\r\n if(p == f) continue ;\r\n dfs(p , x);\r\n siz[x] += siz[p] ;\r\n if(use_T)\r\n {\r\n if(siz[p] > siz[hv[x]]) hv[x] = p ;\r\n }\r\n }\r\n }\r\n int LCA(int u , int v)\r\n {\r\n if(dep[u] < dep[v])swap(u,v) ;\r\n int c = dep[u] - dep[v];\r\n Rep(i,23,0) if(c >= 1 << i) c-= 1 << i , u = jump[i][u] ;\r\n if(u==v)return u ;\r\n Rep(i,23,0) if(jump[i][u]!=jump[i][v]) u = jump[i][u] , v = jump[i][v] ;\r\n return fa[u] ;\r\n }\r\n void dfs2(int x,int t)\r\n {\r\n ++_tim ;\r\n dfn[_tim] = x ;\r\n rnk[x] = _tim ; \r\n top[x] = t ;\r\n if(!hv[x]) return ; \r\n dfs2(hv[x],t);\r\n for(auto p:ed[x])\r\n if(p!=fa[x]&&p!=hv[x]) dfs2(p,p);\r\n }\r\n } ;\r\n} \r\n\r\nGraph::Tree T(N , 1 , 0);\r\nint q,u,v,n;\r\nchar c[N] ;\r\nchar ch[N][2];\r\n\r\nvi path(int u , int v , int LCA) \r\n{\r\n vi res,v1,v2 ;\r\n res.clear();v1.clear();v2.clear();\r\n while(u!=LCA) \r\n {\r\n v1.emplace_back(u); \r\n u = T.fa[u];\r\n }\r\n while(v!=LCA)\r\n {\r\n v2.emplace_back(v);\r\n v = T.fa[v] ;\r\n }\r\n for(auto p:v1) res.emplace_back(p) ;\r\n res.emplace_back(LCA);\r\n reverse(all(v2));\r\n for(auto p:v2) res.emplace_back(p) ;\r\n return res ;\r\n}\r\n\r\n\r\n\r\n\r\nnamespace SAT{\r\n vector ed[N << 2] ;\r\n int tot ;\r\n void adde(int x,int y){ed[x].psb(y);}\r\n int dfn[N << 2] , low[N << 2] , tim = 0 ; \r\n int bel[N<<2] ; \r\n stack s ;\r\n void tarjan(int x)\r\n {\r\n low[x] = dfn[x] = ++tim ;\r\n s.push(x);\r\n for(auto p:ed[x])\r\n {\r\n if(!dfn[p]) tarjan(p),upmin(low[x] , low[p]);\r\n else if(!bel[p]) upmin(low[x] , low[p]) ; \r\n }\r\n if(low[x] == dfn[x])\r\n {\r\n int tp ;\r\n ++tot ;\r\n do\r\n {\r\n // cout << tp <<'\\n' ;\r\n tp = s.top();s.pop();bel[tp] = tot ;\r\n } while (tp != x);\r\n }\r\n }\r\n}\r\n\r\n\r\n\r\nint vis[N] ;\r\n//\r\n#define ap(x) x+n\r\n#define link(x) x+2*n\r\n#define flink(x) x+2*n+q \r\nsigned main()\r\n{\r\n read(n,q) ; \r\n rep(i,1,n-1)read(u,v),T.adde(u,v);\r\n T.dfs(1,0);\r\n rep(i,1,n) rep(j,0,1) ch[i][j] = 'a' ;\r\n rep(i,1,q)\r\n {\r\n scanf(\"%d%d%s\" ,&u , &v , (c + 1)) ;\r\n int len = strlen(c+1) ;\r\n int ac = T.LCA(u,v);\r\n vi pat = path( u , v , ac ) ; \r\n int pos = 0 ;\r\n for(auto p:pat)\r\n {\r\n pos ++ ;\r\n if(!vis[p]) {vis[p] = 1; ch[p][0] = c[pos] ; ch[p][1] = c[len - pos + 1] ;}\r\n if(ch[p][0]!=c[pos]) \r\n {\r\n SAT::adde(flink(i),p);\r\n SAT::adde(ap(p),link(i));\r\n } \r\n if(ch[p][1]!=c[pos])\r\n {\r\n SAT::adde(flink(i),ap(p)) ;\r\n SAT::adde(p,link(i));\r\n }\r\n if(ch[p][0]!=c[len-pos+1])\r\n {\r\n SAT::adde(link(i),p);\r\n SAT::adde(ap(p),flink(i));\r\n }\r\n if(ch[p][1]!=c[len-pos+1])\r\n {\r\n SAT::adde(link(i),ap(p)) ;\r\n SAT::adde(p,flink(i));\r\n }\r\n }\r\n }\r\n rep(i,1,n*2 + q*2) if(!SAT::dfn[i]) SAT::tarjan(i);\r\n rep(i,1,n) if(SAT::bel[i] == SAT::bel[ap(i)]) {puts(\"NO\");return 0;}\r\n puts(\"YES\");\r\n rep(i,1,n) putchar(ch[i][SAT::bel[i] < SAT::bel[ap(i)]]) ;\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c4feb5cb516a056362263f5c6ae3a881", "src_uid": "b2d7ac8e75cbdb828067aeafd803ac62", "difficulty": 2200.0} {"lang": "GNU C++17 (64)", "source_code": "#include\r\nusing namespace std;\r\n#define int long long\r\n// typedef long long ll;\r\n#define rep(i,a,b) for(int i=(a);i<=(b);++i)\r\n#define per(i,a,b) for(int i=(a);i>=(b);--i)\r\n#define repg(i,u) for(int i=head[u];~i;i=edge[i].nxt)\r\n#define lowbit(x) (x&(-x))\r\n#define ls (o<<1)\r\n#define rs (o<<1|1)\r\n#define mp make_pair\r\n#define pii pair\r\n#define fi first\r\n#define se second\r\n#define db double\r\n#define endl '\\n'\r\n#define push_back emplace_back\r\nmt19937 rnd(time(0));\r\ninline int read(){\r\n\tint num=0,f=1;char ch=getchar();\r\n\twhile(!isdigit(ch)){\r\n\t\tif(ch=='-')f=0;\r\n\t\tch=getchar();\r\n\t}\r\n\twhile(isdigit(ch)){\r\n\t\tnum=num*10+ch-'0';\r\n\t\tch=getchar();\r\n\t}\r\n\treturn f?num:-num;\r\n}\r\nconst int MAXN=300010;\r\nconst int MAXM=1000000;\r\nint n,C;\r\nint maxv[MAXM+10];\r\nvoid solve(){\r\n\tn=read(),C=read();\r\n\trep(i,1,n){\r\n\t\tint c=read(),d=read(),h=read();\r\n\t\tmaxv[c]=max(maxv[c],d*h);\r\n\t}\r\n\trep(i,1,C){\r\n\t\tif(maxv[i]>0){\r\n\t\t\tfor(int j=i+i;j<=C;j+=i){\r\n\t\t\t\tmaxv[j]=max(maxv[j],maxv[i]*(j/i));\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\trep(i,1,C){\r\n\t\tmaxv[i]=max(maxv[i-1],maxv[i]);\r\n\t}\r\n\tint q=read();\r\n\twhile(q--){\r\n\t\tint D=read(),H=read();\r\n\t\tint val=D*H;\r\n\t\tif(maxv[C]<=val){\r\n\t\t\tprintf(\"-1 \");\r\n\t\t\tcontinue;\r\n\t\t}\r\n\t\tint l=1,r=C,ans=C;\r\n\t\twhile(l<=r){\r\n\t\t\tint mid=(l+r)/2;\r\n\t\t\tif(maxv[mid]>val){\r\n\t\t\t\tans=mid;\r\n\t\t\t\tr=mid-1;\r\n\t\t\t}\r\n\t\t\telse l=mid+1;\r\n\t\t}\r\n\t\tprintf(\"%lld \",ans);\r\n\t}\r\n}\r\nsigned main(){\r\n\t// int T=read();\r\n\tint T=1;\r\n\twhile(T--)solve();\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f04c9804f8bb4bcdab93a504ff1b8167", "src_uid": "b2d7ac8e75cbdb828067aeafd803ac62", "difficulty": 2200.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\n#include\n#include\nint a[4000];\nint n;\nint fun(int u,int s,int y,int z)\n{\n if(u==n)\n return s;\n else\n {\n if(z+1!=y)\n return fun(u+1,s,y,z+1);\n else{\n if(s+1!=5)\n return fun(u+1,s+1,y,0);\n else\n return fun(u+1,0,2*y,0);\n }\n }\n}\nint main()\n{\n cin>>n;\n int g=fun(0,0,1,0);\n if(g==0)\n cout<<\"Sheldon\";\n if(g==1)\n cout<<\"Leonard\";\n if(g==2)\n cout<<\"Penny\";\n if(g==3)\n cout<<\"Rajesh\";\n if(g==4)\n cout<<\"Howard\";\n getch();\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c63e2ab35e9e565ec43441b41471c0fe", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\nvoid main() {\n\tvector ochered;\n\tochered.push_back(\"Begin\");\n\tochered.push_back(\"Sheldon\");\n\tochered.push_back(\"leonard\");\n\tochered.push_back(\"Penny\");\n\tochered.push_back(\"Rajesh\");\n\tochered.push_back(\"Howard\");\n\tlong n;\n\tcin >> n;\n\tfor (int i = 1; i < n; i++)\n\t{\n\t\tochered.push_back(ochered[i]);\n\t\tochered.push_back(ochered[i]);\n\t}\n\tcout<\n#include \nusing namespace std;\nstruct spisoc\n{\n spisoc *next;\n string name;\n};\n\nspisoc *head, *head2;\nspisoc *p, *test, *o;\nint main()\n{long long int n;\ncin>>n;\n head =new spisoc;\n p =new spisoc;\n\n p->name='1';\n test=p;\n for (int i=2; i<6; i++)\n {\n \n \n p->next=head;\n p=head;\n \n if (i==2) p->name='2';\n if (i==3) p->name='3';\n if (i==4) p->name='4';\n if (i==5) p->name='5';\n head =new spisoc;\n }\n head=p;\n o=test;\n\n \n head2=head;\n for( int i=0; inext;\n \n head =new spisoc;\n head->name=o->name;\n head2->next=head;\n head2=head;\n head =new spisoc;\n head->name=o->name;\n head2->next=head;\n head2=head;\n\n\n test=o;\n o=o->next;\n \n }\n if (n==1) cout<<\"Sheldon\"; else {\n if (test->name==\"1\") cout<<\"Sheldon\";\n if (test->name==\"2\") cout<<\"Leonard\";\n if (test->name==\"3\") cout<<\"Penny\";\n if (test->name==\"4\") cout<<\"Rajesh\";\n if (test->name==\"5\") cout<<\"Howard\";\n }\n \n return 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fe8f3dc14eebe0dbf351362c165c0e3b", "src_uid": "023b169765e81d896cdc1184e5a82b22", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \nusing namespace std;\n\nint main()\n{\n queue q;\n q.push(\"Sheldon\");\n q.push(\"Leonard\");\n q.push(\"Penny\");\n q.push(\"Rajesh\");\n q.push(\"Howard\");\n int i=1;\n int n;\n cin>>n;\n while(i!=n)\n {\n string s=q.front();\n q.pop();\n q.push(s);\n q.push(s);\n i++;\n }\n cout<\n#include\nusing namespace std;\nint main(){\n int x,y,z,i,j,k;\n scanf(\"%d%d%d%d%d%d\",x,y,z,i,j,k);\n int cnt=0;\n if(x==i) cnt++;\n if(y==j) cnt++;\n if(z==k) cnt++;\n if(cnt>0) puts(\"YES\");\n if(cnt==0) puts(\"NO\");\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "26560e751d689333d1d3d4d08c185846", "src_uid": "91c9dbbceb467d5fd420e92c2919ecb6", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include\n#include\nusing namespace std;\n\nint main()\n{\n ifstream fin(\"input.txt\");\n ofstream fout(\"output.txt\");\n int a[3];\n int b[3];\n int i,j,sum=0;\n fin>>a[0]>>a[1]>>a[2];\n fin>>b[0]>>b[1]>>b[2];\n \n for(i=0;i<3;i++)\n if(a[i]==b[i])\n sum++;\n if(sum>=2)\n fout<<\"YES\"<\n#include\nusing namespace std;\n\nint main()\n{\n ifstream fin(\"input.txt\");\n ofstream fout(\"output.txt\");\n int a[3];\n int b[3];\n int i,j,sum=0;\n fin>>a[0]>>a[1]>>a[2];\n fin>>b[0]>>b[1]>>b[2];\n \n for(i=0;i<3;i++)\n if(a[i]==b[i])\n sum++;\n if(sum>=2)\n fout<<\"YES\";\n else fout<<\"NO\";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c3094e789831727e250cd748ba7a9bf9", "src_uid": "91c9dbbceb467d5fd420e92c2919ecb6", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include\n#include\n\nusing namespace std;\n\nint main()\n{\n ifstream fin(\"input.txt\");\n ofstream fout(\"output.txt\");\n int a[3];\n int b[3];\n int i,sum=0;\n fin>>a[0]>>a[1]>>a[2];\n fin>>b[0]>>b[1]>>b[2];\n \n for(i=0;i<3;i++)\n if(a[i]==b[i])\n sum++;\n if(sum>=2)\n fout<<\"YES\"<\r\nusing namespace std;\r\ntypedef long long int ll;\r\n#define FOR(i,l,r) for(i=l;i\r\n#define F first\r\n#define S second\r\n#define UB(x,y) upper_bound(ALL(x),y)-x.begin()\r\n#define LB(x,y) lower_bound(ALL(x),y)-x.begin()\r\n#define TU tuple\r\nll mod=1e9+7;\r\nsigned main(){\r\n ll q,t=1;//cin>>t;\r\n REP(q,t){\r\n string S;cin>>S;if(S.size()==1)cout<\r\nusing namespace std;\r\ntypedef long long int ll;\r\n#define FOR(i,l,r) for(i=l;i\r\n#define F first\r\n#define S second\r\n#define UB(x,y) upper_bound(ALL(x),y)-x.begin()\r\n#define LB(x,y) lower_bound(ALL(x),y)-x.begin()\r\n#define TU tuple\r\nll mod=1e9+7;\r\nsigned main(){\r\n ll q,t=1;//cin>>t;\r\n REP(q,t){\r\n string S;cin>>S;if(S.size()==1)cout<4)while(1){S+=\"1\";}\r\n }\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0c2e084a4d46f1ff22f9aa0e77304826", "src_uid": "477a67877367dc68b3bf5143120ff45d", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include \r\nusing namespace std;\r\ntypedef long long int ll;\r\n#define FOR(i,l,r) for(i=l;i\r\n#define F first\r\n#define S second\r\n#define UB(x,y) upper_bound(ALL(x),y)-x.begin()\r\n#define LB(x,y) lower_bound(ALL(x),y)-x.begin()\r\n#define TU tuple\r\nll mod=1e9+7;\r\nsigned main(){\r\n ll q,t=1;//cin>>t;\r\n REP(q,t){\r\n string S;cin>>S;if(S.size()==1)cout<1)while(1){S+=\"1\";}\r\n }\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a9dd6b1a0a8a0614a4c2688d8b64fd27", "src_uid": "477a67877367dc68b3bf5143120ff45d", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include \r\nusing namespace std;\r\ntypedef long long int ll;\r\n#define FOR(i,l,r) for(i=l;i\r\n#define F first\r\n#define S second\r\n#define UB(x,y) upper_bound(ALL(x),y)-x.begin()\r\n#define LB(x,y) lower_bound(ALL(x),y)-x.begin()\r\n#define TU tuple\r\nll mod=1e9+7;\r\nsigned main(){\r\n ll q,t=1;//cin>>t;\r\n REP(q,t){\r\n string S;cin>>S;if(S.size()==1)cout<='5')while(1){S+=\"!\";}\r\n }\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6f926df24a33cd4343d55a88b09bda32", "src_uid": "477a67877367dc68b3bf5143120ff45d", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nint a[1001],b[1001];\nint main(){\n int n,m,ans=110,max;\n cin>>n>>m; \n for(int i=0;i>a[i];\n\t}\n\tfor(int i=0;i>b[i];\n\t}\n\tfor(int i=0;i\n#include \n#include \n\nint main() {\n\tint n, m;\n\tstd::cin >> n >> m;\n\tint temp;\n\tstd::vector list1;\n\tstd::vector list2;\n\tfor (int i = 0; i < n; i++) {\n\t\tstd::cin >> temp;\n\t\tlist1.push_back(temp);\n\t}\n\tfor (int i = 0; i < m; i++) {\n\t\tstd::cin >> temp;\n\t\tlist2.push_back(temp);\n\t}\n\tstd::sort(list1.begin(), list1.end());\n\tstd::sort(list2.begin(), list2.end());\n\tint minls1 = list1[0];\n\tint minls2 = list2[0];\n\tint od = -1;\n\tfor (int i = 0; i < list1.size(); i++) {\n\t\tfor (int k = 0; i < list2.size(); k++) {\n\t\t\tif (list1[i] == list2[k])\n\t\t\t\tod = list1[i];\n\t\t}\n\t}\n\tif (od != -1) {\n\t\tstd::cout << od << std::endl;\n\t}\n\telse {\n\t\tif (minls1 >= minls2)\n\t\t\tstd::cout << minls2 << minls1 << std::endl;\n\t\telse\n\t\t\tstd::cout << minls1 << minls2 << std::endl;\n\t}\n\t//system(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "27f895ee71a635b1f3f84bdaed7f5c72", "src_uid": "3a0c1b6d710fd8f0b6daf420255d76ee", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint find(int val,int arr[],int n)\n{\n\tfor(int i=0;i>a>>b;\n\tint * arr1 = new int[a];\n\tint * arr2 = new int[b];\n\tint * ar = new int[10];\n\n\tfor(int i=0;i<10;i++)\n\t\tar[i]=0;\n\n\tfor(int i=0;i>k;\n\t\tarr1[i]=k;\n\t\tar[k]+=1;\n\t\tif(k>k;\n\t\tarr2[i]=k;\n\t\tar[k]+=1;\n\t\tif(k1)\n\t\t{\n\t\t\tcout<m2)\n\t\t{\n\t\t\tint temp=m1;\n\t\t\tm1=m2;\n\t\t\tm2=temp;\n\t\t}\n\t\tcout<<10*m1+m2<\n\nusing namespace std;\n\n\n#include \nint main()\n{\n int pretty,i,j,n,m,x;\n int a[30];\n int b[30];\n do\n {\nscanf(\"%d %d\",&n,&m);}\nwhile(n<1|| m<9); \nfor (int i = 0; i < n; ++i)\n{\n cin >> a[i];\n}\nfor (int i = 0; i < m; ++i)\n{\n cin >> b[i];\n}\npretty=a[0]*10+b[0];\nfor (int i = 0; i < n; ++i)\n{\n for (int j = 0; j < m; ++j)\n{\nif ((a[i]*10+b[j]) < pretty) \npretty=a[i]*10+b[j];\nif ((a[i]==b[j])&&(a[i]\n#define mis(x) cout << #x <<\" = \" <>n>>l;\n\tmi=-1;\n\tfor(int i=0; i>hin[i];\n\t\tif(i>0){\n\t\t\thin[i]=min(hin[i],2*hin[i-1]);\n\t\t\tsuur[i]=suur[i-1]*2;\n\t\t} \n\t\telse suur[i]=1;\n\t}\n\tsu=0;\n\tkogu=0;\n\tfor(int i=n-1; i>=0; i--){\n\t\twhile(su+suur[i]<=l){\n\t\t\tsu+=suur[i];\n\t\t\tkogu+=hin[i];\n\t\t}\n\t\tmi=min(kogu+hin[i],mi);\n\t\tif(mi==-1) mi=kogu+hin[i];\n\t}\n\tif(su==l) mi=min(mi,kogu);\n\tcout<\nusing namespace std;\n\ntypedef long long LL;\nLL two[40],cost[40];\nLL gmin,ans,tans,m,mm;\nint n;\nint main(){\n\tscanf(\"%d%I64d\",&n,&m);\n\tfor (int i=0;i0&&cost[i]>cost[i-1]+cost[i-1])cost[i]=cost[i-1]+cost[i-1];\n\t}\n\tgmin=0;\tmm=m;\twhile (mm>0){mm-=two[n-1];gmin+=cost[n-1];}\n\tans=0;\tmm=m;\n\tfor (int i=n-1;i>=0;i--){\n\t\ttans=0;\n\t\twhile (mm>=two[i]){mm-=two[i];tans+=cost[i];}\n\t\tif (mm>0&&ans+tans+cost[i]\n\n#define fin() freopen(\"input.txt\",\"r\",stdin)\n#define fout() freopen(\"out.txt\",\"w\",stdout)\n#define ll long long int\n#define f first\n#define s second\n#define pb push_back\n#define PII pair\n#define mp(a,b) make_pair(a,b)\n#define MOD 1000000007\n#define N 1000005\n#define LN 20\n#define inf 100000000000000000LL\nusing namespace std;\n\nll a[N];\n\nint main()\n{\n\tfor (ll i = 0; i < 40; i++) a[i] = inf;\n\tll n, l;\n\tscanf (\"%lld%lld\", &n, &l);\n\tfor (ll i = 0; i < n; i++)\n\t\tscanf (\"%lld\", a + i);\n\tfor (ll i = 1; i < 40; i++) a[i] = min (a[i], 2 * a[i - 1]);\n\tll ans = 0;\n\tll ohk = inf;\n\tfor (ll i = 0; i < 40; i++)\n\t{\n\t\tif (l & (1LL << i)) ans += a[i];\n\t\telse ans=min(ans,a[i]);\n\t\tif (l < (1LL << i)) ohk = min (ohk, a[i]);\n\n\t}\n\tans=min(ohk,ans);\n\tprintf (\"%lld\\n\", ans);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d15e1d75fc5c7bcf91653d973eee9964", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include \n\n#define fr first\n#define sc second\n#define OK puts(\"OK\");\n#define pb push_back\n#define mk make_pair\n\nusing namespace std;\n\ntypedef long long ll;\n\nconst ll N = (ll)35;\n\nll n,l;\nll a[N],cur;\nll ans1 = -1,res = -1,ans,pw,sz,cn;\nll b[N],p[N];\n\nint main () {\n cin >> n >> l;\n\n for (ll i = 1; i <= n; i ++) {\n cin >> a[i];\n if (i > 1)\n b[i] = min(a[i],b[i - 1] * 2);\n else\n b[i] = a[i];\n }\n while (l > 0) {\n cn = (1ll << (n - 1));\n sz = l / cn;\n\n ans += (b[n] * sz);\n l -= (sz * cn);\n\n if (l == 0) {\n res = min(res,ans);\n break;\n }\n if (res == -1)\n res = ans + b[n];\n else\n res = min(res,ans + b[n]);\n n --;\n }\n cout << res << endl;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a439cbcb5d1e3046bd3da6bcb200d3b9", "src_uid": "04ca137d0383c03944e3ce1c502c635b", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n//#include\nusing namespace std;\nint ans[11111], a[11111];\nset st;\nint j = 1;\nmap mp;\nint main()\n{\n\t\n\t///memset(ans, -1, sizeof ans);\n\tint n, m;\n\tcin >> n >> m;\n\t//int a[1111];\n\tfor (int i = 0;i <= n;i++) ans[i] = -1;\n\tfor (int i = 0;i < m;i++)\n\n\t{\n\t\tcin >> a[i];\n\t}\n\tfor (int i = 0;i < m - 1;i++)\n\t{\n\t\tif (a[i + 1] >= a[i])\n\t\t{\n\t\t\tans[a[i]] = a[i + 1] - a[i];\n\t\t}\n\t\telse\n\n\t\t{\n\t\t\tans[a[i]] = n - a[i];\n\t\t\tans[a[i]] += a[i + 1];\n\t\t}\n\t\tmp[ans[a[i]]]++;\n\t}\n\t///cout << mp.size() << endl;\n\tfor (int i = 0;i < n;i++)\n\t{\n\t\tif (ans[i+1] != -1) continue;\n\t\tbool o = 0;\n\t\twhile (1)\n\t\t{\n\t\t\tif (j > n) break;\n\t\t\tif (mp.find(j) == mp.end()) {\n\t\t\t\tmp[j]++;break;\n\t\t\t}\n\t\t\tmp[j]++;\n\t\t\tj++;\n\t\t\to = 1;\n\t\t}\n\t\t///if (!o) j++;\n\t\tans[i+1] = j;\n\t}\n\tif (mp.size() != n)\n\t{\n\t\tcout << -1;\n\t\treturn 0;\n\t}\n\t//cout << mp.size() << endl;\n\tfor (int i = 0;i < n;i++)\n\t\tcout << ans[i + 1] << \" \";\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e68c1cd3e177612ce2a38ad0fd3cc245", "src_uid": "4a7c959ca279d0a9bd9bbf0ce88cf72b", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "typedef long long ll;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n\n\nusing namespace std;\n\nint main() {\n\n int n = 4,m=5;\n cin >> n >> m;\n vector que(m);\n for (int &i : que) {\n cin >> i;\n }\n vector all(n + 1, 0);\n for (int i = 0; i < que.size() - 1; i++) {\n int diff = que[i + 1] - que[i] + n;\n diff %= n;\n if (diff == 0) diff = n;\n if (all[diff] != 0 && all[diff] != que[i]) {\n cout << -1;\n return 0;\n }\n all[diff] = que[i];\n }\n vector re(n + 1, 0);\n for (int i = 1; i <= all.size(); i++) {\n re[all[i]] = i;\n }\n for (int i = 1; i < re.size(); i++) {\n cout << re[i] << \" \";\n }\n \n}\n ", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fb5b588b5f27aa070fdc06681757bb05", "src_uid": "4a7c959ca279d0a9bd9bbf0ce88cf72b", "difficulty": 1600.0} {"lang": "GNU C++11", "source_code": "//In the Name of Allah, the Most Beneficent, the Most Merciful.\n//Mo'men AbdelRazek\n#include\nusing namespace std;\ntypedef long long int ll;\n\nint n, m;\nint a[1000];\nint ans[1000];\n\nint vis[1000];\nint vis2[1000];\n\nint main()\n{\n#ifndef ONLINE_JUDGE\n freopen(\"input.in\", \"r\", stdin);\n//freopen(\"output.out\", \"w\", stdout);\n#endif\n\n scanf(\"%d %d\", &n, &m);\n\n for (int i = 0; i < m; i++)\n {\n scanf(\"%d\", a + i);\n }\n int diff;\n for (int i = 1; i < m; i++)\n {\n diff = a[i] - a[i - 1];\n if (diff <= 0)\n diff += n;\n if (ans[a[i - 1]] && ans[a[i - 1]] != diff)\n return printf(\"-1\\n\");\n else\n {\n if (vis[diff] && !ans[a[i - 1]])\n return printf(\"-1\\n\"), 0;\n vis[diff] = 1;\n ans[a[i - 1]] = diff;\n }\n }\n for (int i = 1; i <= n; i++)\n {\n if (!ans[i])\n {\n for (int j = 1; j <= n; j++)\n {\n if (!vis[j])\n {\n cout << j << \" \";\n vis[j] = 1;\n break;\n }\n }\n }\n else\n cout << ans[i] << \" \";\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "15ff33f342978c38ffeee60273928348", "src_uid": "4a7c959ca279d0a9bd9bbf0ce88cf72b", "difficulty": 1600.0} {"lang": "GNU C++", "source_code": "#include \n\n#define rust(a, b, c, d) sqrt(sqr(a - c) + sqr(b - d))\n#define sqr(a) (a)*(a)\n#define m_p make_pair\n#define fi first\n#define se second\n#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);\n#define endl \"\\n\"\n\ntypedef long long ll;\nconst int MAXINT=2147483640;\nconst ll MAXLL=9223372036854775800LL;\nconst ll MAXN=1000000;\nusing namespace std;\nll b[3121212],a[3121212],i,n,m,v[31212121];\nint main()\n{\n //freopen(\"1.in\", \"r\", stdin);\n //freopen(\"1.out\", \"w\", stdout);\n fast_io;\n srand(time(0));\n cin >> n >> m;\n for (i=1; i<=m; i++) cin >> a[i];\n for (i=1; ia[i] && b[a[i]]==0) b[a[i]]=a[i+1]-a[i];\n if (a[i+1]<=a[i] && b[a[i]]==0) b[a[i]]=(a[i+1]+n)-a[i];\n }\n for (i=1; i<=n; i++)\n {\n v[b[i]]++;\n if (b[i]==0)\n {\n cout << -1;\n return 0;\n }\n }\n for (i=1; i<=1000; i++)\n {\n if (v[i]>1)\n {\n cout << -1;\n return 0;\n }\n }\n for (i=1; i<=n;i++) cout << b[i] << \" \";\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "425971e8393037e455be3ca64adfae08", "src_uid": "4a7c959ca279d0a9bd9bbf0ce88cf72b", "difficulty": 1600.0} {"lang": "GNU C++17", "source_code": "#include \r\n#include \r\n#include \r\nusing namespace __gnu_pbds;\r\n#include \r\nusing namespace std::chrono;\r\n#define pb push_back\r\n#define mk make_pair\r\n// #define endl \"\\n\"\r\n// #define mod 1000000007\r\n#define mod 998244353\r\n#define int long long int\r\n#define PI 3.1415927\r\n#define pb push_back\r\n#define ppb pop_back\r\n#define pf push_front\r\n#define ppf pop_front\r\n#define all(x) (x).begin(),(x).end()\r\n#define uniq(v) (v).erase(unique(all(v)),(v).end())\r\n#define sz(x) (int)((x).size())\r\n#define fr first\r\n#define sc second\r\n#define pii pair\r\n#define rep(i,a,b) for(int i=a;i ii;\r\ntypedef long double ld;\r\ntypedef tree, rb_tree_tag, tree_order_statistics_node_update> ordered_set;\r\nvoid solve() {\r\n int n, m;\r\n cin >> n >> m;\r\n vector dp(n + 1);\r\n dp[n] = 1;\r\n for (int i = n; i >= 1; i--) {\r\n for(int j = i-1; j>=1; j--){\r\n dp[j] += dp[i];\r\n dp[j]%=m;\r\n }\r\n set used;\r\n for (int j = 2; (j) <= i; j++) {\r\n int val = i / j;\r\n if (!used.count(val)) {\r\n dp[val] += dp[i];\r\n dp[val] %= m;\r\n }\r\n }\r\n }\r\n\r\n cout << dp[1];\r\n}\r\nsigned main () {\r\n ios_base::sync_with_stdio(false);\r\n cin.tie(NULL); cout.tie(NULL);\r\n#ifndef ONLINE_JUDGE\r\n freopen(\"input.txt\", \"r\", stdin);\r\n freopen(\"output.txt\", \"w\", stdout);\r\n#endif\r\n int test_cases;\r\n test_cases = 1;\r\n // cin >> test_cases;\r\n while (test_cases--) {\r\n solve();\r\n // cout<(stop - start);\r\n // cout << duration.count() << endl;\r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4db9f964181ba8d7aa5049b331595ded", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.0} {"lang": "GNU C++20 (64)", "source_code": "#include\r\nusing namespace std;\r\ntypedef long long lli;\r\ntypedef vectorvi;\r\ntypedef vectorvll;\r\ntypedef vectorvc;\r\ntypedef vectorvs;\r\ntypedef vectorvb;\r\n#define endl \"\\n\"\r\n#define pb push_back\r\n#define all(x) x.begin(),x.end()\t\r\n#define mp(a,b) make_pair(a,b)\r\ntypedef vectorvb;\r\n#define const1 1000000007\r\nlli gcd(lli a, lli b)\r\n{\r\n if (b == 0)\r\n return a;\r\n return gcd(b, a % b);\r\n}\r\n\r\nlli power(lli a,lli b){\r\n\tlli ans=1;\r\n\twhile(b!=0){\r\n\t\tif(b&1)ans=(ans*a);\r\n\t\ta=(a*a);\r\n\t\tb=b>>1;\r\n\t}\r\n\t//this works because of every number can be written as the sum of powers of 2\r\n\treturn ans;\r\n}\r\n\r\n\r\n// int check_prime(int n){\r\n// \tif(n==1)return 0;\r\n// \telse if(n<=3)return 1;\r\n// \telse if(n%2==0 || n%3==0)return 0;\r\n// \tfor(int i=5;i*i<=(n);i+=6){\r\n// \t\tif(n%i==0 || n%(i+2)==0)return 0;\r\n// \t}\r\n// \treturn 1;\r\n// }\r\n\r\n// int min(int a,int b){\r\n// \tif(ab)return a;\r\n// \treturn b;\r\n// }\r\n\r\nlli min(lli a,lli b)\r\n{\r\n\tif(ab)return a;\r\n\treturn b;\r\n}\r\n\r\nvoid solve(){\r\n\tlli n,m;\r\n\tcin>>n>>m;\r\n\tvll dp(n + 1);\r\n\tdp[1] = 1;\r\n\tfor(lli i = 2;i<=n;++i){\r\n\t\t//subtraction\r\n\t\tfor(lli j = 1;j>t;\r\n// \twhile(t--){\r\n// \t\tsolve();\r\n// \t}\r\n// \treturn 0;\r\n// }\r\n\r\nint main(){\r\n\tios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\r\n\tsolve();\r\n\treturn 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9678557d7c12d62627fecf6b3ba59474", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#include\r\nusing namespace std;\r\n#define ll long long\r\n#define pb push_back\r\n#define ff first\r\n#define ss second\r\n#define sz size()\r\n#define name \"a\"\r\ntypedef pair < ll, ll > ii;\r\nconst ll maxn = 2e5 + 7, oo = 1e18, base = 311;\r\nint n, m, f[maxn];\r\nll tinh(int i)\r\n{\r\n if (i == 1)\r\n return 1;\r\n if (f[i] != -1)\r\n return f[i];\r\n ll res = 0;\r\n for (int j = 1; j <= i - 1; ++j)\r\n {\r\n res += tinh(i - j);\r\n res %= m;\r\n }\r\n for (int j = 2; j <= i; ++j)\r\n {\r\n res += tinh(i / j);\r\n res %= m;\r\n }\r\n return f[i] = res;\r\n}\r\nint main()\r\n{\r\n ios_base::sync_with_stdio(false);\r\n cin.tie(0);cout.tie(0);\r\n //freopen(name\".inp\", \"r\", stdin);\r\n //freopen(name\".out\", \"w\", stdout);\r\n cin >> n >> m;\r\n fill(f, f+1+n, -1);\r\n cout << tinh(n);\r\n}\r\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2f1210090210b47601e91f8a95bf72ee", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.0} {"lang": "GNU C++20 (64)", "source_code": "#include\r\n#include \r\n#include \r\n\r\nusing namespace std;\r\nusing namespace __gnu_pbds;\r\n\r\n#define long long long\r\n#define node pair\r\n#define ordered_set tree, rb_tree_tag,tree_order_statistics_node_update>\r\n\r\nlong mod;\r\n\r\nvoid solve() {\r\n long n;\r\n cin >> n >> mod;\r\n \r\n long dp[n + 1], pref[n + 1];\r\n \r\n dp[1] = pref[1] = 1;\r\n for(int i = 2; i <= n; i++) {\r\n dp[i] = pref[i - 1];\r\n for(int j = 2; j <= i; j++) {\r\n dp[i] += dp[i / j];\r\n dp[i] %= mod;\r\n }\r\n pref[i] = dp[i] + pref[i - 1];\r\n pref[i] %= mod;\r\n }\r\n \r\n cout << dp[n] << \"\\n\";\r\n}\r\n\r\nint main() {\r\n ios_base::sync_with_stdio(false);\r\n cin.tie(0); cout.tie(0);\r\n \r\n int tm = 1;\r\n // cin >> tm;\r\n while(tm--) solve();\r\n \r\n return 0;\r\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ec1a6a4d9f1177950bfbb533bff7e254", "src_uid": "a524aa54e83fd0223489a19531bf0e79", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \nusing namespace std;\nint main()\n{\n int n,i;\n cin>>n;\n for( i=1;i<=n;i++)\n if((i*(i+1))/2==n)\n cout<<\"YES\"<\n#include \n#include \nusing namespace std;\nbool isTriangular(int num)\n{\n // Base case\n if (num < 0)\n return false;\n \n // A Triangular number must be sum of first n\n // natural numbers\n int sum = 0;\n for (int n=1; sum<=num; n++)\n {\n sum = sum + n;\n if (sum==num)\n return true;\n }\n \n return false;\n}\nint main()\n{\n\tint n;\n\tcin >> n;\n\tif (isTriangular(n))\n\t\tcout << \"Yes\";\n\telse\n\t\tcout << \"No\";\n\t_getch();\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d735317594314082adf35ee63c20650f", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.0} {"lang": "GNU C++", "source_code": "#include \n\nint tr[600];\n\nint main()\n{\t\n\tint i, j, n;\t\n\n\tfor(i=0;i<23;i++)\n\t{\n\t\tj = ((i+1)*(i))/2;\n\t\ttr[j] = 1;\n\t}\n\n\twhile(1 == scanf(\"%d\",&n))\n\t{\t\t\n\t\tif(tr[n] == 1)\n\t\t\tprintf(\"YES\\n\");\n\t\telse\n\t\t\tprintf(\"NO\\n\");\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "82566da3454467776bea0a8b59d57eb7", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#define pb push_back\nusing namespace std;\nint n,m,a[100000000],idx;\nint main(){\n cin>>n;\n for(int i=1;i<=10000000;i++){\n a[i]=a[i-1]+i;\n if(a[i]==n){\n cout<<\"YES\"<\n#include \n#include \n#include \n\nusing namespace std;\n\ndouble origami (double x, double y)\n{\n if (x==y)\n {\n return 1;\n }\n if (y==1)\n {\n return x;\n }\n else if ( y <= x-y)\n {\n return 1+origami(x-y,y);\n }\n else\n {\n return 1+origami(y,x-y);}\n }\n\nint main()\n{\n double a,b,r;\n cin >> a >> b;\n r=origami(a,b);\n cout.setf(ios::fixed);\n cout << setprecision(0) << r;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "866f80af2016a4300995833539847145", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\n\n\n\nint cutThePaper(int w, int h){\n\tif (w == 1) return h;\n\tif (h == 1) return w;\n\tif (w > h)\n\t\treturn 1 + cutThePaper(w - h, h);\n\tif (w < h)\n\t\treturn 1 + cutThePaper(w, h - w);\n\treturn 1;\n}\n\nvoid main(){\n\tint w, h;\n\tcin >> w >> h;\n\tcout << cutThePaper( w, h);\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ff6bbbffed5a171fa29a74dce0a19122", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0} {"lang": "GNU C++0x", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\nint main()\n{\n int a,b,sum=0;\n scanf(\"%d%d\",&a,&b);\n while(a!=b)\n {\n if(a>b)\n {a=a-b;sum++;}\n if(b>a)\n {b=b-a;sum++;}\n //if(a==b)\n //{sum++;break;}\n}\nprintf(\"%d\\n\",sum+1);\ngetch();\nreturn 0;\n} \n \n \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4073499be9d2306b856e98619ac57cbe", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0} {"lang": "GNU C++17 Diagnostics", "source_code": "#include\nint main()\n{\n long long x=1,a,b;\n scanf(\"%lli %lli\",&a,&b);\n if(b==1||a-b==1) { printf(\"%lli\",a);}\n else {\n for(;a!=b;)\n {\n if(a>b) a=a-b;\n else b=b-a;\n x++;\n }\n printf(\"%llu\",x);\n }\n\n return 0;\n\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0991f544ec645323039d05d9514cefa8", "src_uid": "ce698a0eb3f5b82de58feb177ce43b83", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#pragma Gpref optimize(\"O3\")\n//#pragma Gpref optimize(\"Ofast\")\n//#pragma Gpref target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n//#pragma Gpref optimize(\"unroll-loops\")\n#include \n#define int long long\n#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n#define TC int t; cin >> t; while(t--)\n#define FR(i,j,k) for(int i=j; i=k; --i)\n#define pb push_back\n#define vi vector\n#define imie(...) \" [\" << #__VA_ARGS__ \": \" << (__VA_ARGS__) << \"] \"\n#define go continue\n#define F first\n#define S second\nusing namespace std;\nconst int MOD = (int)1e9+7;\nconst int N = 1e7;\nint modmult(int a,int b){int res=0;a%=MOD;while(b){if(b&1)res=(res+a)%MOD;a=(a<<1)%MOD;b>>=1;}return res;}\n\nclock_t time_c=clock();\n\nvoid timer()\n{\n time_c = clock()-time_c;\n cerr<< \" Time : \"<<(float)(time_c)/CLOCKS_PER_SEC<<\"\\n\";\n}\n// CODE BEGINS\nint solve(vector v){\n int n = v.size(), ans = 0;\n FR(i,0,n)ans += n - v[i];\n return ans;\n}\nint powe(int x, unsigned int y) \n{ \n int res = 1;\n x = x % MOD;\n while (y > 0) \n { \n if (y & 1) \n res = (res*x) % MOD; \n y = y>>1; \n x = (x*x) % MOD; \n } \n return res; \n} \n\nint toggle(int n) \n{ \n if (n == 0) return 1; \n int i = n; \n n |= n >> 1; \n n |= n >> 2; \n n |= n >> 4; \n n |= n >> 8; \n n |= n >> 16; \n return i ^ n; \n}\nint get(int a, int b){\n if (a < b)swap(a, b); \n a = toggle(a); \n return a ^ b;\n}\n\nint32_t main(){\nIOS;\n//Online JUDGE starts\n\n\n// #define ONLINE_JUDGE\n#ifdef ONLINE_JUDGE\nfreopen(\"input.txt\", \"r\", stdin);\nfreopen(\"output.txt\", \"w\", stdout);\nfreopen(\"error.txt\", \"w\", stderr);\n#endif\n//Online JUDGE ends\n\n\nIOS;\nint n, k, up = 1;\ncin >> n >> k;\nint x = powe(powe(2,k)-1,n);\n\ncout << x ;\n\ntimer();\n\nreturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "775b780010f2ec13f685f20ace044677", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#pragma Gpref optimize(\"O3\")\n//#pragma Gpref optimize(\"Ofast\")\n//#pragma Gpref target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native\")\n//#pragma Gpref optimize(\"unroll-loops\")\n#include \n#define int long long\n#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n#define TC int t; cin >> t; while(t--)\n#define FR(i,j,k) for(int i=j; i=k; --i)\n#define pb push_back\n#define vi vector\n#define imie(...) \" [\" << #__VA_ARGS__ \": \" << (__VA_ARGS__) << \"] \"\n#define go continue\n#define F first\n#define S second\nusing namespace std;\nconst int MOD = (int)1e9+7;\nconst int N = 1e7;\nint modmult(int a,int b){int res=0;a%=MOD;while(b){if(b&1)res=(res+a)%MOD;a=(a<<1)%MOD;b>>=1;}return res;}\n\nclock_t time_c=clock();\n\nvoid timer()\n{\n time_c = clock()-time_c;\n cerr<< \" Time : \"<<(float)(time_c)/CLOCKS_PER_SEC<<\"\\n\";\n}\n// CODE BEGINS\nint solve(vector v){\n int n = v.size(), ans = 0;\n FR(i,0,n)ans += n - v[i];\n return ans;\n}\nint powe(int x, unsigned int y) \n{ \n int res = 1;\n x = x % MOD;\n while (y > 0) \n { \n if (y & 1) \n res = (res*x) % MOD; \n y = y>>1; \n x = (x*x) % MOD; \n } \n return res; \n} \n\nint toggle(int n) \n{ \n if (n == 0) return 1; \n int i = n; \n n |= n >> 1; \n n |= n >> 2; \n n |= n >> 4; \n n |= n >> 8; \n n |= n >> 16; \n return i ^ n; \n}\nint get(int a, int b){\n if (a < b)swap(a, b); \n a = toggle(a); \n return a ^ b;\n}\n\nint32_t main(){\nIOS;\n//Online JUDGE starts\n\n\n#ifdef ONLINE_JUDGE\nfreopen(\"input.txt\", \"r\", stdin);\nfreopen(\"output.txt\", \"w\", stdout);\nfreopen(\"error.txt\", \"w\", stderr);\n#endif\n//Online JUDGE ends\n\n\nIOS;\nint n, k, up = 1;\ncin >> n >> k;\nint x = powe(powe(2,k)-1,n);\n\ncout << x ;\n\ntimer();\n\nreturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "718280bcc3fe81fe465011e9d1c524eb", "src_uid": "71029e5bf085b0f5f39d1835eb801891", "difficulty": 1500.0} {"lang": "GNU C++17", "source_code": "#include\n#include \nusing namespace std;\n \nlong long n,m,brp=0,d,x=0,w,h,hasil=0;\nbool pernah[1010];\nstring s;\nconst long long mod=1e9+7;\n\nlong long pangkat(long long a,long long b){\n\tlong long pang=pangkat(a,b/2);\n\tpang=pang*pang;\n\tpang=pang%mod;\n\t\tif(b==0){\n\t\t\treturn 1;\n\t\t}\n\t\tif(b%2==0){\n\t\t\treturn pang;\n\t\t}else{\n\t\t\treturn a*pang%mod;\n\t\t}\n}\n\nlong long rhombus(long long n){\n\tif(n==1){\n\t\treturn 1;\n\t}else{\n\t\treturn (pangkat(n,2)+pangkat(n-1,2));\n\t}\n}\n\nint main(){\n\tcin>>n>>m;\n\thasil=pangkat(2,m)-1;\n\thasil=pangkat(hasil,n);\n\tcout<\nusing namespace std;\ntypedef unsigned long long ull;\ntypedef long long ll;\n#define ll long long\n#define MOD 1000000007\n#define nl cout<>t;while(t--)\n#define pb push_back\n#define ff first\n#define ss second\n#define all(v) v.begin(),v.end()\n#define oa(a,n) for(ll i=0;i>a[i];\n#define ov(a,n) for(ll i=0;i>N>>K;\n ll ar[K+1]={};\n ll sum=powe(2,K)-1;\n if(sum<0)\n sum+=MOD;\n cout<\n#define N 100\nusing namespace std;\nint main()\n{\n int in[N];\n int Max,a=0;\n for(int i=0;i<14;i++)\n {\n cin>>in[i];\n }\n Max=in[0];\n for(int i=0;i<14;i++)\n {\n if(in[i]>Max)\n {\n Max=in[i];\n a=i;\n }\n }\n if((a+Max)>13)\n { for(int i=a+1;i<14;i++)\n {\n in[i]++;\n }\n int m=Max-13+a;\n for(int i=0;i\nusing namespace std;\nlong long A[15],B[15],M;\nint main()\n{\n for(long long i=0; i<14; i++)\n scanf(\"%lld\",A+i);\n for(long long i=0; i<14; i++)\n {\n for(long long j=0; j<14; j++)B[j]=A[j];\n B[i]=0;\n if(!A[i])continue;\n for(long long j=0; j<14; j++)\n {\n if(ji)\n {\n long long t=A[i]-(j-i)+1;\n if(t<0)continue;\n B[j]+=(t-1)/14+1;\n }\n else\n {\n long long t=A[i]-14;\n if(t<=0)continue;\n B[j]+=(t-1)/14+1;\n }\n }\n long long sum=0;\n for(long long j=0; j<14; j++)\n if(B[j]%2==0)sum+=B[j];\n M=M>sum?M:sum;\n }\n printf(\"%lld\",M);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ee59da2d7d1913652b7da2b50ce7c017", "src_uid": "1ac11153e35509e755ea15f1d57d156b", "difficulty": 1100.0} {"lang": "GNU C++17 Diagnostics", "source_code": "#include \n\nusing namespace std;\nint sum = 0,place=0;\nint temps = 0,tplace= 0;\nvoid sum1(int a,int n)\n{\n if( temps + a > 1000000000)\n {\n tplace += n + 1;\n temps += a - 1000000000;\n }\n else\n {\n tplace += n;\n temps += a;\n }\n}\nint main()\n{\n int a[14];\n sum=0;\n place=0;\n for(int x = 0; x < 14; ++x)\n cin>>a[x];\n for (int i = 0; i < 14; ++i)\n {\n temps=0;\n tplace=0;\n if (a[i] <= 0)\n {\n continue;\n }\n int temp=a[i];\n //cout< 0)&&(( a[j] + q + 1) % 2 == 0) && (( a[j] + q + 1)!=0))\n {\n int b = ( a[j] + q + 1) % 1000000000;\n int n = ( a[j] + q + 1) / 1000000000;\n sum1 ( b, n);\n //cout<= place)&&(temps > sum) ) \n {\n place = tplace;\n sum = temps;\n }\n }\n if(place>0)\n {\n cout< 0)\n {\n ++u;\n m /= 10;\n }\n for(int l=0;l<9-u;++l)\n cout<<\"0\";\n cout<\n\nusing namespace std;\nint ar[30];\nint ans[67108880];\nchar s[1005];\nint main()\n{\n int n,i,x=0,f,aa=0,j;\n scanf(\"%d\",&n);\n for(i=0;i\nusing namespace std;\ntypedef long long ll;\n\nll gcd(ll a, ll b) \n { \n if (a == 0 || b == 0) \n return 0; \n if (a == b) \n return a; \n if (a > b) \n return gcd(a-b, b); \n return gcd(a, b-a); \n } \n\nint main(){\n ll n, k, a, b;\n cin >> n >> k >> a >> b;\n ll t = n*k;\n ll mn=LONG_LONG_MAX, mx=LONG_LONG_MIN;\n vector l;\n set s;\n\n for(int i=0; i\n// #include \nusing namespace std;\n\ntypedef long long ll;\n \nint main(int argc, char const *argv[])\n{\n ll n,k;\n cin>>n>>k;\n ll a,b;\n cin>>a>>b;\n vector s_arr;\n // set l_arr;\n vector l_arr;\n l_arr.reserve(2*100000+5);\n\n // vector l_arr;\n // cout<<\"fine here\\n\";\n s_arr.push_back(1+a);\n // if(a==k/2 && k%2==0)\n // s_arr.push_back(1+a);\n // else{\n // s_arr.push_back(1+a);\n // s_arr.push_back(k+1-a);\n // }\n // cout<<\"fine here\\n\";\n\n for(int i=0;i=s_arr[i]){\n l_arr.push_back(j+b-s_arr[i]);\n }else{\n l_arr.push_back(n*k-(s_arr[i]-j-b));\n }\n }\n\n }else{\n for(int j=1; j<=(n-1)*k+1;j+=k){\n if(j+b>=s_arr[i]){\n l_arr.push_back(j+b-s_arr[i]);\n }else{\n l_arr.push_back(n*k-(s_arr[i]-j-b));\n }\n if(j+k-b>=s_arr[i]){\n l_arr.push_back(j+k-b-s_arr[i]);\n }else{\n l_arr.push_back(n*k-(s_arr[i]-(j+k-b)));\n }\n\n }\n }\n }\n // cout<<\"fine here\\n\";\n ll x=-1,y=-1;\n // set::iterator itr = l_arr.begin();\n vector::iterator itr = l_arr.begin();\n for(;itr!=l_arr.end();itr++){\n // for(int i=0;ix){\n y=t;\n }else{\n y=x;\n x=t;\n }\n }else{\n if(t>y){\n y=t;\n }else if(tx){\n y=t;\n }else{\n y=x;\n x=t;\n }\n }else{\n if(t>y){\n y=t;\n }else if(t\nusing i64 = long long;\n\ni64 gcd(i64 a, i64 b) {\n if (b > a) std::swap(a, b);\n return a % b ? gcd(b, a % b) : b;\n}\n\nint main() {\n i64 n, k, a, b;\n std::cin >> n >> k >> a >> b;\n i64 x = 100001, y = 0;\n i64 mod = n * k;\n for (i64 i = 0; i < n; i++) {\n i64 l = (k * i - b - a + mod) % mod;\n if (!l) l = mod;\n i64 rr = mod / gcd(mod, l);\n x = std::min(x, rr);\n y = std::max(y, rr);\n l = (k * i + b - a + mod) % mod;\n if (!l) l = mod;\n rr = mod / gcd(mod, l);\n x = std::min(x, rr);\n y = std::max(y, rr);\n }\n std::cout << x << \" \" << y << std::endl;\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9d1e90e8b7b941f85502f4ce3743d336", "src_uid": "5bb4adff1b332f43144047955eefba0c", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef int64_t ll;\ntypedef long double ld;\n\ninline void start() {\n#ifdef BOKU_NO_PICO\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n#else\n ios_base::sync_with_stdio(false);\n cout.tie(nullptr);\n cin.tie(nullptr);\n#endif\n}\n\nll gcd(ll a, ll b) {\n return b == 0 ? a : gcd(b, a % b);\n}\n\ninline void solve() {\n ll n, k;\n cin >> n >> k;\n ll a, b;\n cin >> a >> b;\n ll mn = 1e9;\n ll mx = -1e9;\n for (ll i = 1; i <= n; ++i) {\n ll l = i * k - a - b;\n mn = min(mn, n * k / gcd(n * k, l));\n mx = max(mx, n * k / gcd(n * k, l));\n }\n for (ll i = 1; i <= n; ++i) {\n ll l = i * k - a + b;\n mn = min(mn, n * k / gcd(n * k, l));\n mx = max(mx, n * k / gcd(n * k, l));\n }\n for (ll i = 0; i <= n; ++i) {\n ll l = i * k + a + b;\n mn = min(mn, n * k / gcd(n * k, l));\n mx = max(mx, n * k / gcd(n * k, l));\n }\n cout << mn << \" \" << mx << endl;\n}\n\nint32_t main() {\n start();\n solve();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "25b15826e01046ae87d720f9f61f997a", "src_uid": "5bb4adff1b332f43144047955eefba0c", "difficulty": 1700.0} {"lang": "MS C++", "source_code": "#include \n#include \nusing namespace std;\n\nifstream infile(\"input.txt\");\nofstream outfile(\"output.txt\");\n\nchar ch[8][8];\nbool b1[8] = {0};\nbool b2[8] = {0};\nint count;\n\nint stroka1()\n{\n\tfor (int i = 0; i < 8; i++)\n\t\tif (!b1[i] && ch[i][0] == 'B')\n\t\t{\n\t\t\tcount++;\n\t\t\tb1[i] = true;\n\t\t}\n\treturn 0;\n}\n\nint stolbec1()\n{\n\tfor (int j = 0; j < 8; j++)\n\t\tif (!b2[j] && ch[0][j] == 'B')\n\t\t{\n\t\t\tint i = 0;\n\t\t\twhile (b1[i])\n\t\t\t\ti++;\n\t\t\tif (i != 8)\n\t\t\t{\n\t\t\t\tcount++;\n\t\t\t\tb2[j] = true;\n\t\t\t}\n\t\t}\n\treturn 0;\n}\n\nint stolbec2()\n{\n\tfor (int j = 0; j < 8; j++)\n\t\tif (!b2[j] && ch[0][j] == 'B')\n\t\t{\n\t\t\tcount++;\n\t\t\tb2[j] = true;\n\t\t}\n\treturn 0;\n}\n\nint stroka2()\n{\n\tfor (int i = 0; i < 8; i++)\n\t\tif (!b1[i] && ch[i][0] == 'B')\n\t\t{\n\t\t\tint j = 0;\n\t\t\twhile (b2[j])\n\t\t\t\tj++;\n\t\t\tif (j != 8)\n\t\t\t{\n\t\t\t\tcount++;\n\t\t\t\tb1[i] = true;\n\t\t\t}\n\t\t}\n\treturn 0;\n}\n\nint main()\n{\n\tfor (int i = 0; i < 8; i++)\n\t\tfor (int j = 0; j < 8; j++)\n//\t\t\tcin >> ch[i][j];\n\t\t\tinfile >> ch[i][j];\n\tcount = 0;\n\tfor (int i = 0; i < 8; i++)\n\t\tb1[i] = false;\n\tfor (int j = 0; j < 8; j++)\n\t\tb2[j] = false;\n\tstroka1();\n\tstolbec1();\n\tint count1 = count;\n\n\tcount = 0;\n\tfor (int i = 0; i < 8; i++)\n\t\tb1[i] = false;\n\tfor (int j = 0; j < 8; j++)\n\t\tb2[j] = false;\n\tstolbec2();\n\tstroka2();\n\tif (count1 < count)\n//\t\tcout << count1;\n\t\toutfile << count1;\n\telse\n//\t\tcout << count;\n\t\toutfile << count;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c6bceb3c7d92824bea68b63f67cc7564", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n//#include // this is for int64_t (long long)\n#define fort(a,b,c) for(a=b; anom=nom;\n\t\tthis->v=v;\n\t}\n};\nbool operator >(const Boats &a, const Boats &b){\n\treturn a.v>b.v;\n}\nv1.push_back(Boats(i,tmpv));\n\n\nclass MyClass {\n\tprivate:\n\tpublic:\n\tprotected:\n};\n\nstruct MyStruct {\n};\n\n*/\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3f31db69008528d8cabbe491fd9953ba", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "//#include \n#include \n#include \n#include \n\nusing namespace std;\nint a[10][10],now[10][10];\nchar sim;\nint main()\n{\n\tfreopen(\"input.txt\",\"r\",stdin);\n\tfreopen(\"output.txt\",\"w\",stdout);\n\tfor (int i=0; i<8; i++)\n\t{\n\t\tfor (int j=0; j<8; j++)\n\t\t{\n\t\t\tscanf(\"%c\",&sim);\n\t\t\tif (sim=='B') a[i][j]=1; else a[i][j]=0;\n\t\t}\n\t\tscanf(\"\\n\");\n\t}\n\tint summ=0;\n\tfor (int i=0; i<8; i++)\n\t\tfor (int j=0; j<8; j++)\n\t\t\tif (a[i][j]==1 && now[i][j]==0)\n\t\t\t{\n\t\t\t\tint resvert=0;\n\t\t\t\tfor (int k=0; k<8; k++)\n\t\t\t\t\tif (a[k][j]==0) resvert=-1000000;\n\t\t\t\tint reshor=0;\n\t\t\t\tfor (int k=0; k<8; k++)\n\t\t\t\t\tif (a[i][k]==0) reshor=-1000000;\n\t\t\t\tif (resvert==0)\n\t\t\t\t\tfor (int k=0; k<8; k++)\n\t\t\t\t\t\tnow[k][j]=1;\n\t\t\t\telse if (reshor==0)\n\t\t\t\t\tfor (int k=0; k<8; k++)\n\t\t\t\t\t\tnow[i][k]=1;\n\t\t\t\tsumm++;\n\t\t\t}\n\tprintf(\"%d\",summ);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "deb79b67109be90064f7c24c6b543371", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "//#include \n#include \n#include \n#include \n\nusing namespace std;\nint a[10][10],now[10][10];\nchar sim;\nint main()\n{\n freopen(\"input.txt\",\"r\",stdin);\n freopen(\"output.txt\",\"w\",stdout);\n for (int i=0; i<8; i++)\n {\n for (int j=0; j<8; j++)\n {\n scanf(\"%c\",&sim);\n if (sim=='B') a[i][j]=1; else a[i][j]=0;\n }\n scanf(\"\\n\");\n }\n int summ=0;\n for (int i=0; i<8; i++)\n for (int j=0; j<8; j++)\n if (a[i][j]==1 && now[i][j]==0)\n {\n int resvert=0;\n for (int k=0; k<8; k++)\n if (a[k][j]==0) resvert=-1000000;\n int reshor=0;\n for (int k=0; k<8; k++)\n if (a[i][k]==0) reshor=-1000000;\n if (resvert==0)\n for (int k=0; k<8; k++)\n now[k][j]=1;\n else if (reshor==0)\n for (int k=0; k<8; k++)\n now[i][k]=1;\n summ++;\n }\n printf(\"%d\\n\",summ);\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9272d2c30a5c141094246de97542f28d", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include\n#define ll long long\nusing namespace std;\nll a[100005],n,m,x,y,i,t;\nvectorv;\nint main(){\ncin>>n>>m;\nfor(int q=0;q>a[q];\n i=0,x=n-1;\nwhile(1)\n{\n\n if(a[i]>m&&a[x]>m)break;\n if(a[i]<=m){i++;y++;}if(a[x]<=m){x--;y++;}\n if(i>x)break;\n if(i==x){if(a[i]<=m)y++;break;}\n}\ncout<\n\nusing namespace std;\n#define llu unsigned long long int\nint setBitNumber(long long int n)\n{\n if (n == 0)\n return 0;\n \n int msb = 0;\n while (n != 0) {\n n = n / 2;\n msb++;\n }\n \n return msb;\n}\nunsigned long long int power(unsigned long long int x, unsigned long long int y)\n{\n unsigned long long int res = 1; // Initialize result\n \n while (y > 0)\n {\n // If y is odd, multiply x with result\n if (y & 1)\n res = res*x;\n \n // n must be even now\n y = y>>1; // y = y/2\n x = x*x; // Change x to x^2\n }\n return res;\n}\nvoid bin(unsigned long long n)\n{\n unsigned long long int i;\n for (i = (long long )1 << 63; i > 0; i = i / 2)\n (n & i)? printf(\"1\"): printf(\"0\");\n printf(\"\\n\"); \n}\nint main()\n{\n int n,k,idx1,idx2,count1=0,count2=0;\n cin>>n>>k;\n int a[n];\n for(int i=0;i>a[i];\n }\n int i=0,j=n-1;\n while(ik&&a[j]>k)\n {\n break;\n }\n }\n if(i==j&&i>0&&j\nusing namespace std;\nint main()\n{\n int a[110],i,j,k,n,m,l,b1,b2,c;\n scanf(\"%d %d\",&n,&k);\n for(i=0;i\nvoid count(int *, int *,int,int);\n\n\nint main()\n{\n int n,count1 =0,k;\n\n scanf(\"%d%d\",&n,&k);\n int a[n];\n for(int i = 0;i= 0)\n {\n *counter= *counter + 1;\n i--;\n }\n else\n break;\n }\n }\n\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ecf75c28bd650f386ac705caeed05ce8", "src_uid": "ecf0ead308d8a581dd233160a7e38173", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef pair ii;\ntypedef pair pll;\n\n#define X first\n#define Y second\n\nstruct edge {\n int v, a, b;\n\n edge() {};\n edge(int _v, int _a, int _b) {\n v = _v;\n a = _a;\n b = _b;\n }\n};\n\nint n, m;\nvector G_in[100007], G[200007];\nint sz[200007];\nvector F;\n\nint next_num;\n\nll cross(pll o, pll a, pll b) {\n\tll x1 = a.X - o.X;\n\tll y1 = a.Y - o.Y;\n\tll x2 = b.X - o.X;\n\tll y2 = b.Y - o.Y;\n\treturn x1*y2 - y1*x2;\n}\n\n// -1 - left, 1 - right\nint side(pll o, pll a, pll b) {\n\tll c = cross(o, a, b);\n\tif(c < 0)\n\t\treturn 1;\n\tif(c > 0)\n\t\treturn -1;\n\treturn 0;\n}\n\nll cross(pll a, pll b, pll c, pll d) {\n return cross({0, 0}, {b.X - a.X, b.Y - a.Y}, {d.X - c.X, d.Y - c.Y});\n}\n\nvoid add_edge(int p, int w, int a, int b) {\n G[p].emplace_back(w, a, b);\n G[w].emplace_back(p, a, b);\n}\n\nvoid build_dfs(int w, int p) {\n int c = G_in[w].size();\n if(p != 0)\n c--;\n\n if(c <= 2) {\n for(auto e : G_in[w])\n if(e.v != p)\n add_edge(w, e.v, e.a, e.b);\n } else {\n vector ch;\n for(auto e : G_in[w])\n if(e.v != p)\n ch.push_back(e);\n\n add_edge(w, ch[0].v, ch[0].a, ch[0].b);\n add_edge(w, next_num, 0, 0);\n\n for(int i = 1 ; i < (int)ch.size() - 2 ; i++) {\n add_edge(next_num, ch[i].v, ch[i].a, ch[i].b);\n add_edge(next_num, next_num + 1, 0, 0);\n next_num++;\n }\n\n add_edge(next_num, ch[ch.size() - 2].v, ch[ch.size() - 2].a, ch[ch.size() - 2].b);\n add_edge(next_num, ch.back().v, ch.back().a, ch.back().b);\n }\n\n for(auto e : G_in[w])\n if(e.v != p)\n build_dfs(e.v, w);\n}\n\nvoid calc_sizes(int w, int p) {\n sz[w] = 1;\n for(auto e : G[w])\n if(e.v != p) {\n calc_sizes(e.v, w);\n sz[w] += sz[e.v];\n }\n}\n\nii choose_edge(int w, int p, int total) {\n int max_sz = total - sz[w], x = p;\n for(auto e : G[w])\n if(e.v != p) {\n if(sz[e.v] > max_sz) {\n max_sz = sz[e.v];\n x = e.v;\n }\n ii r = choose_edge(e.v, w, total);\n if(r != (ii){0, 0})\n return r;\n }\n\n if(max_sz <= total / 2) {\n return {w, x};\n }\n\n return {0, 0};\n}\n\nvoid paths_dfs(int w, int p, vector *v, pll f = {0, 0}) {\n if(G[w].size() == 1 && p) {\n v->push_back(f);\n return ;\n }\n\n for(auto e : G[w])\n if(e.v != p)\n paths_dfs(e.v, w, v, {f.X + ll(e.a), f.Y + ll(e.b)});\n}\n\nvector get_paths(int w) {\n vector res;\n paths_dfs(w, 0, &res);\n\n return res;\n}\n\nvector convex_hull(vector V) {\n if(V.size() < 3)\n return V;\n\n vector ch1, ch2;\n\n\tsort(V.begin(), V.end());\n\tch1.clear();\n\tch2.clear();\n\tch1.push_back(V[0]);\n\tch1.push_back(V[1]);\n\tfor(int i = 2 ; i < V.size() ; i++) {\n\t\twhile(ch1.size() >= 2 && side(ch1[ch1.size() - 2], ch1[ch1.size() - 1],\n\t\t\tV[i]) != 1)\n\t\t\t\tch1.pop_back();\n\t\tch1.push_back(V[i]);\n\t}\n\n\treverse(V.begin(), V.end());\n\n\tch2.push_back(V[0]);\n\tch2.push_back(V[1]);\n\tfor(int i = 2 ; i < V.size() ; i++) {\n\t\twhile(ch2.size() >= 2 && side(ch2[ch2.size() - 2], ch2[ch2.size() - 1],\n\t\t\tV[i]) != 1)\n\t\t\t\tch2.pop_back();\n\t\tch2.push_back(V[i]);\n\t}\n\n\tfor(int i = 1 ; i < ch2.size() - 1 ; i++)\n\t\tch1.push_back(ch2[i]);\n\n return ch1;\n}\n\ndouble angle(pll a, pll b) {\n return atan2(b.Y - a.Y, b.X - a.X);\n}\n\nvector minkowski_sum(vector A, vector B) {\n reverse(A.begin(), A.end());\n reverse(B.begin(), B.end());\n\n vector res;\n\n int n = A.size();\n int m = B.size();\n\n A.push_back(A[0]);\n A.push_back(A[1]);\n B.push_back(B[0]);\n B.push_back(B[1]);\n\n int i = 0, j = 0;\n while(i < n || j < m) {\n res.emplace_back(A[i].X + B[j].X, A[i].Y + B[j].Y);\n\n if(i == n)\n j++;\n else if(j == m)\n i++;\n else if(cross(A[i], A[i + 1], B[j], B[j + 1]) == 0)\n i++, j++;\n else if(angle(A[i], A[i + 1]) < angle(B[j], B[j + 1]))\n i++;\n else\n j++;\n }\n\n return res;\n}\n\nvector add_to_all(vector V, pll p) {\n for(int i = 0 ; i < V.size() ; i++) {\n V[i].X += p.X;\n V[i].Y += p.Y;\n }\n return V;\n}\n\nvoid add_functions(vector V) {\n for(auto f : V)\n F.push_back(f);\n}\n\nvoid decomposition(int w) {\n calc_sizes(w, 0);\n\n if(sz[w] <= 1)\n return ;\n if(sz[w] <= 3) {\n pll f = {0, 0};\n for(edge e : G[w]) {\n f.X += ll(e.a);\n f.Y += ll(e.b);\n }\n F.push_back(f);\n return ;\n }\n\n ii ee = choose_edge(w, 0, sz[w]);\n int u, v, a, b;\n\n u = ee.X;\n v = ee.Y;\n\n for(int i = 0 ; i < G[ee.X].size() ; i++) {\n if(G[ee.X][i].v == ee.Y) {\n a = G[ee.X][i].a;\n b = G[ee.X][i].b;\n swap(G[ee.X][i], G[ee.X].back());\n G[ee.X].pop_back();\n break;\n }\n }\n\n for(int i = 0 ; i < G[ee.Y].size() ; i++) {\n if(G[ee.Y][i].v == ee.X) {\n swap(G[ee.Y][i], G[ee.Y].back());\n G[ee.Y].pop_back();\n break;\n }\n }\n\n add_functions(add_to_all(minkowski_sum(convex_hull(get_paths(u)), convex_hull(get_paths(v))), pll({a, b})));\n\n decomposition(u);\n decomposition(v);\n}\n\nint main() {\n scanf(\"%d%d\", &n, &m);\n\n for(int i = 1 ; i < n ; i++) {\n int u, v, a, b;\n scanf(\"%d %d %d %d\", &u, &v, &a, &b);\n G_in[u].emplace_back(v, a, b);\n G_in[v].emplace_back(u, a, b);\n }\n\n next_num = n + 1;\n build_dfs(1, 0);\n\n for(int i = 1 ; i <= n ; i++)\n G_in[i].clear();\n\n decomposition(1);\n\n for(int d = 0 ; d < m ; d++) {\n ll max_v = 0;\n for(pll f : F)\n max_v = max(max_v, f.X * ll(d) + f.Y);\n printf(\"%I64d \", max_v);\n }\n\n printf(\"\\n\");\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "95ac3db1f68190c1b5ec0796399a77b0", "src_uid": "7bccdabeb9f16ee0b4f16c37de564c31", "difficulty": 3200.0} {"lang": "GNU C++17", "source_code": "#include\n#include\n#include\nusing namespace std;\ntypedef long long ll;\n#define int ll\nconst int N=2e5+500;\nint n,m;\n\nint gti(void)\n{\n char c=getchar();\n int ret=0,st=1;\n for (;!isdigit(c);c=getchar()) if (c=='-') st=-1;\n for (;isdigit(c);c=getchar()) ret=ret*10+c-'0';\n return ret*st;\n}\n\nstruct Tree\n{\n struct e\n {\n e *nxt,*rev;\n ll to,a,b;\n bool vis;\n int mx;\n }pool[N*2],*pt[N],*p=pool;\n void add(int a,int b,ll c,ll d)\n {\n *(++p)=(e){pt[a],p+1,b,c,d,false,0},pt[a]=p;\n *(++p)=(e){pt[b],p-1,a,c,d,false,0},pt[b]=p;\n }\n void rebuild(int v,Tree &t)\n {\n int lst=0;\n for (e *i=pt[v];i;i=i->nxt)\n if (!i->vis)\n {\n i->vis=i->rev->vis=true;\n if (lst)\n {\n t.add(lst,i->to+n,0,0);\n t.add(i->to+n,i->to,i->a,i->b);\n lst=i->to+n;\n }\n else t.add(v,i->to,i->a,i->b),lst=v;\n rebuild(i->to,t);\n i->vis=i->rev->vis=false;\n }\n }\n}tmp,t;\ntypedef Tree::e edge;\n\nint son[N];\nvoid getson(int v)\n{\n son[v]=1;\n for (edge *i=t.pt[v];i;i=i->nxt)\n if (!i->vis)\n {\n i->vis=i->rev->vis=true;\n getson(i->to);\n son[v]+=son[i->to];\n i->vis=i->rev->vis=false;\n }\n}\nedge *getedge(int v,int rs)\n{\n edge *ret=NULL;\n for (edge *i=t.pt[v];i;i=i->nxt)\n if (!i->vis)\n {\n i->vis=i->rev->vis=true;\n i->mx=max(son[i->to],rs-son[i->to]);\n if (!ret||ret->mx>i->mx) ret=i;\n edge *now=getedge(i->to,rs);\n if (now&&ret->mx>now->mx) ret=now;\n i->vis=i->rev->vis=false;\n }\n return ret;\n}\n\nstruct P\n{\n ll x,y;\n bool operator<(const P &b)const\n {\n if (x==b.x) return ynxt)\n if (!i->vis)\n {\n i->vis=i->rev->vis=true;\n cnt=getpt(i->to,c,cnt,a+i->a,b+i->b);\n i->vis=i->rev->vis=false;\n }\n return cnt;\n}\nP st[N*35];\nbool vol(P &a,P &b,P &c,P &d)\n{\n return 1ll*(a.y-b.y)*(c.x-d.x)>=1ll*(c.y-d.y)*(a.x-b.x);\n}\nint build(P *c,int cnt)\n{\n sort(c+1,c+1+cnt);\n int top=0;\n for (int i=1;i<=cnt;i++)\n {\n st[++top]=c[i];\n while (top>2&&vol(st[top],st[top-1],st[top-1],st[top-2]))\n st[top-1]=st[top],--top;\n }\n for (int i=1;i<=top;i++)\n c[i]=st[i];\n return top;\n}\nvoid merge(P *rec,P *ls,int lc,P *rs,int rc)\n{\n int i,j;\n for (i=1,j=1;i<=lc;i++)\n {\n while (jlc) rec[++cnt]=rs[j];\n if (j>rc) rec[++cnt]=ls[i];\n if (rec[cnt]==rec[cnt-1]) --cnt;\n }\n while (j<=rc)\n {\n rec[++cnt]=ls[lc]+rs[j],++j;\n if (rec[cnt]==rec[cnt-1]) --cnt;\n }\n}\nvoid solve(int ls,int rs,ll a,ll b)\n{\n int lt=getpt(ls,pts[0],0,a,b);\n int rt=getpt(rs,pts[1],0);\n lt=build(pts[0],lt);\n rt=build(pts[1],rt);\n merge(all,pts[0],lt,pts[1],rt);\n}\nvoid divans(int v)\n{\n getson(v);\n edge *e=getedge(v,son[v]);\n if (!e) return;\n e->vis=e->rev->vis=true;\n int ls=e->to,rs=e->rev->to;\n solve(ls,rs,e->a,e->b);\n divans(ls);\n divans(rs);\n}\n\n#undef int\nint main(void)\n#define int ll\n{\n n=gti(),m=gti();\n for (int i=1;i=-1ll*t*(all[j+1].x-all[j].x))\n ++j;\n printf(\"%I64d%c\",all[j].x*1ll*t+all[j].y,t\nusing namespace std;\n#define reg register\n#define ll long long\n#define maxn 400005\ninline ll read()\n{\n\tll x=0,w=0;char ch=getchar();\n\twhile(!isdigit(ch))w|=ch=='-',ch=getchar();\n\twhile(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();\n\treturn w?-x:x;\n}\ninline void Max(ll &x,ll y){x=x>y?x:y;}\ninline int min(int x,int y){return x>y?x:y;}\nint n,m;\nstruct op\n{\n ll x,y;\n op operator -(const op& b){return op{x-b.x,y-b.y};}\n op operator +(const op& b){return op{x+b.x,y+b.y};}\n bool operator !=(const op& b){return x!=b.x||y!=b.y;}\n bool operator ==(const op& b){return x==b.x&&y==b.y;}\n long double operator *(const op&b){return (long double)x*b.y-(long double)y*b.x;}\n}val[maxn],val1[maxn][2];\ninline bool com(op x,op y){return x.x==y.x?x.y>y.y:x.x>y.x;}\nop zero={0,0};\nint headd[maxn],nextt[maxn],to[maxn],son[maxn][2],cntt,tot;\ninline void link(int u,int v,op w)\n{nextt[++cntt]=headd[u];headd[u]=cntt;to[cntt]=v;val[cntt]=w;}\ninline void built(int u,int f,int la)\n{\n reg int i,lst=la;\n for(i=headd[u];i;i=nextt[i])\n {\n if(to[i]==f)continue;\n son[lst][0]=++tot;val1[lst][0]=zero;lst=tot;\n son[lst][1]=++tot;val1[lst][1]=val[i];\n built(to[i],u,tot);\n }\n}\ninline void rebuilt()\n{\n tot=1;built(1,0,1);cntt=1;\n memset(headd,0,sizeof headd);\n for(reg int i=1,j;i<=tot;++i)\n for(j=0;j<2;++j)if(son[i][j])\n link(i,son[i][j],val1[i][j]),\n link(son[i][j],i,val1[i][j]);\n}\nop st[maxn];\nint zs,md,mb,cnt;\nint bid[maxn],size[maxn];\ninline void get_ed(int u,int f)\n{\n size[u]=1;\n for(reg int tmp,i=headd[u],v;i;i=nextt[i])\n {\n if(bid[i>>1])continue;\n v=to[i];if(v==f)continue;\n get_ed(v,u);size[u]+=size[v];\n tmp=max(size[v],zs-size[v]);\n if(tmp>1]&&to[i]!=f)fl=1,dfs(to[i],u,o+val[i]);\n if(fl==0&&o!=zero)st[++cnt]=o;\n}\nint asdf;\nint gsa,gsb,gs;\nop A[maxn*20],B[maxn],ans[maxn*20];\ninline bool bd(op x,op y,op z){return (x-z)*(y-z)>=0.0;}\ninline void get_tb(op *a,int sz,op *b,int &top)\n{\n top=0;sort(a+1,a+1+sz,com);\n sz=unique(a+1,a+1+sz)-a-1;\n if(sz>0)b[++top]=a[1];else b[1]=zero;\n if(sz>1)b[++top]=a[2];else b[2]=zero;\n for(reg int i=3;i<=sz;++i)\n {\n while(top>1&&bd(b[top],b[top-1],a[i]))--top;\n b[++top]=a[i];\n }\n}\ninline void merge()\n{\n reg int i,j;ans[++gs]=A[1]+B[1];\n for(i=2;i<=gsa;++i)A[i-1]=A[i]-A[i-1];\n for(i=2;i<=gsb;++i)B[i-1]=B[i]-B[i-1];i=1,j=1;\n while(i=0.0?A[i++]:B[j++]);\n while(i>1]=1;\n int x=to[mb],y=to[mb^1],z=size[x];\n cnt=0;dfs(x,y,zero);get_tb(st,cnt,A,gsa);\n cnt=0;dfs(y,x,val[mb]);get_tb(st,cnt,B,gsb);\n merge();solve(x,z),solve(y,sum-z);\n}\ninline ll calc(int x,int y){return A[x].x*y+A[x].y;}\nint main()\n{\n n=read(),m=read();\n reg int i,u,v,a,b;\n for(i=1;i=calc(u,i))++u;\n printf(\"%lld\\n\",calc(u,i));\n }\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f159ac6814377181a619852ea4b860c5", "src_uid": "7bccdabeb9f16ee0b4f16c37de564c31", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "#include \nusing namespace std;\n#define db(x) cerr << #x << \"=\" << x << endl\n#define db2(x, y) cerr << #x << \"=\" << x << \",\" << #y << \"=\" << y << endl\n#define db3(x, y, z) cerr << #x << \"=\" << x << \",\" << #y << \"=\" << y << \",\" << #z << \"=\" << z << endl\n#define dbv(v) cerr << #v << \"=\"; for (auto _x : v) cerr << _x << \", \"; cerr << endl\n#define dba(a, n) cerr << #a << \"=\"; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << \", \"; cerr << endl\ntypedef long long ll;\ntypedef long double ld;\nconst int MAXN = 200005;\nvector> origE[100005];\nvector> E[MAXN];\nint siz[MAXN];\nll A[MAXN], B[MAXN];\nvoid getSizes(int x, int p = -1) {\n\tsiz[x] = 1;\n\tfor (auto e : E[x]) {\n\t\tint y = e.first;\n\t\tif (y == p) continue;\n\t\tgetSizes(y, x);\n\t\tsiz[x] += siz[y];\n\t}\n}\nint findCentroid(int x, int n, int p = -1) {\n\tfor (auto e : E[x]) {\n\t\tint y = e.first;\n\t\tif (y == p) continue;\n\t\tif (siz[y] > n / 2)\n\t\t\treturn findCentroid(y, n, x);\n\t}\n\treturn x;\n}\n// vector version\n// P[0] = -LLONG_MIN, in [P[i], P[i+1]), max line is A[i]*x + B[i]\nstruct FastHull {\n\tvector id;\n\tvector A, B, P; // P is distinct at every point\n\tint c;\n\tint qpos;\n\tFastHull() {}\n\tFastHull(int n, bool hasid = false) {\n\t\tc = qpos = 0;\n//\t\tA.resize(n);\n//\t\tB.resize(n);\n//\t\tP.resize(n);\n//\t\tif (hasid) id.resize(n);\n\t}\n\tll monotonicQuery(int x) {\n\t\twhile (qpos + 1 < c && P[qpos + 1] <= x) ++qpos;\n\t\treturn A[qpos] * x + B[qpos];\n\t}\n\tll query(int x) {\n\t\tint pos = upper_bound(P.begin(), P.begin() + c, x) - P.begin() - 1;\n\t\treturn A[pos] * x + B[pos];\n\t}\n\tll divideCeil(ll p, ll q) {\n\t\tif (p >= 0) return (p + q - 1) / q;\n\t\treturn -((-p) / q);\n\t}\n\tvoid insertLine(ll a, ll b, int i = -1) {\n\t\t// assert a is >= everything in A\n\t\tfor (; c; --c) {\n\t\t\tif (A[c - 1] == a) {\n\t\t\t\tif (B[c - 1] >= b) return;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tll pt = divideCeil(B[c - 1] - b, a - A[c - 1]);\n\t\t\t// if (A[c - 1] * P[c - 1] + B[c - 1] > a * P[c - 1] + b) break;\n\t\t\tif (pt > P[c - 1]) break;\n\t\t}\n\t\tP.resize(c + 1);\n\t\tA.resize(c + 1);\n\t\tB.resize(c + 1);\n\t\tP[c] = c ? divideCeil(B[c - 1] - b, a - A[c - 1]) : LLONG_MIN;\n\t\tA[c] = a;\n\t\tB[c] = b;\n\t\tif (i != -1) {\n\t\t\tid.resize(c + 1);\n\t\t\tid[c] = i;\n\t\t}\n\t\t++c;\n\t}\n};\n// Obtain centroid-ancestors for each vertex with distance to centroid\nint centroid;\nstruct Centroid {\n\tint c, sub;\n\tll a, b;\n};\nvector centroids[MAXN]; // centroid, subtree, dist\nvector> subtree[MAXN];\npair hulls[MAXN][3];\nvoid go(int x, int p = -1, ll da = 0, ll db = 0, int sub = -1) {\n\tcentroids[x].push_back({centroid, sub, da, db});\n\tsubtree[sub].push_back({da, db});\n\tfor (auto e : E[x]) {\n\t\tint y = e.first;\n\t\tif (y == p) continue;\n\t\tgo(y, x, da + A[e.second], db + B[e.second], sub == -1 ? y : sub);\n\t}\n}\nvoid decompose(int x) {\n\tgetSizes(x);\n\tint c = findCentroid(x, siz[x]);\n\tcentroid = c;\n\tgo(c);\n\tint i = 0;\n\tfor (auto e : E[c]) {\n\t\tint y = e.first;\n\t\tauto &lines = subtree[y];\n\t\tsort(lines.begin(), lines.end());\n\t\tFastHull *hull = new FastHull(lines.size());\n\t\tfor (auto &line : lines) {\n\t\t\thull->insertLine(line.first, line.second);\n\t\t}\n\t\thulls[c][i++] = {y, hull};\n\t\tsubtree[y].clear();\n\t}\n\tfor (auto e : E[c]) {\n\t\tint y = e.first;\n\t\tfor (auto it = E[y].begin();; ++it)\n\t\t\tif (it->first == c) {\n\t\t\t\tE[y].erase(it);\n\t\t\t\tbreak;\n\t\t\t}\n\t\tdecompose(y);\n\t}\n}\nvector, int>> lines1;\nvoid dfs(int x, int p = -1, ll da = 0, ll db = 0) {\n\tlines1.push_back({{da, db}, x});\n\tfor (auto e : E[x]) {\n\t\tint y = e.first;\n\t\tif (y == p) continue;\n\t\tdfs(y, x, da + A[e.second], db + B[e.second]);\n\t}\n}\nint N;\nvoid makeDeg3Tree(int x, int p = -1) {\n\tint cur = x;\n\tint totch = 0;\n\tfor (auto e : origE[x]) {\n\t\tint y = e.first, i = e.second;\n\t\tif (y == p) continue;\n\t\tmakeDeg3Tree(y, x);\n\t\t++totch;\n\t}\n\tfor (auto e : origE[x]) {\n\t\tint y = e.first, i = e.second;\n\t\tif (y == p) continue;\n\t\tE[cur].push_back({y, i});\n\t\tE[y].push_back({cur, i});\n\t\t++N;\n\t\t--totch;\n\t\tif (totch >= 2) {\n\t\t\tE[cur].push_back({N, N - 1});\n\t\t\tE[N].push_back({cur, N - 1});\n\t\t\tA[N] = B[N] = 0;\n\t\t\tcur = N;\n\t\t}\n\t}\n}\nint main() {\n\tint M;\n\tscanf(\"%d%d\", &N, &M);\n\tfor (int i = 1; i < N; ++i) {\n\t\tint x, y;\n\t\tscanf(\"%d%d%lld%lld\", &x, &y, &A[i], &B[i]);\n\t\torigE[x].push_back({y, i});\n\t\torigE[y].push_back({x, i});\n\t}\n\tmakeDeg3Tree(1);\n\tdfs(1);\n\tdecompose(1);\n\tsort(lines1.begin(), lines1.end());\n\tFastHull hull1(lines1.size(), true);\n\tfor (auto &line : lines1) {\n\t\thull1.insertLine(line.first.first, line.first.second, line.second);\n\t}\n\tfor (int x = 0; x < M; ++x) {\n\t\tll d1 = hull1.monotonicQuery(x);\n\t\tint far = hull1.id[hull1.qpos];\n\t\tll ans = 0;\n\t\tfor (auto c : centroids[far]) {\n\t\t\tll v2 = c.a * x + c.b;\n\t\t\tans = max(ans, v2);\n\t\t\tfor (int i = 0; i < 3; ++i) {\n\t\t\t\tauto &h = hulls[c.c][i];\n\t\t\t\tif (!h.first) continue;\n\t\t\t\tif (h.first == c.sub) continue;\n\t\t\t\tauto hull = h.second;\n\t\t\t\tll v = hull->monotonicQuery(x);\n\t\t\t\tans = max(ans, v + v2);\n\t\t\t}\n\t\t}\n\t\tprintf(\"%lld \", ans);\n\t}\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "53d5a27faedc7f202c2768f082ba614c", "src_uid": "7bccdabeb9f16ee0b4f16c37de564c31", "difficulty": 3200.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\nint main()\n{\n int a,b,x,y,n;\n cin>>n>>a>>x>>b>>y;\n int i,j;\n i=a;\n j=b;\n int flag=1;\n if(a==b||x==y)\n cout<<\"YES\";\n while(i!=x&&j!=y)\n {\n if(i==n+1||j==0)\n {\n if(i==n+1)\n i=1;\n else \n j=n;\n if(i==x||j==y)\n break;\n }\n if(i==j)\n {\n cout<<\"YES\";\n flag=0;\n break;\n }\n i++;\n j--;\n }\n if(i==j&&flag==1)\n cout<<\"YES\";\n else if(flag)\n cout<<\"NO\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "89b3018323e2e8a4790abda9e781f0e2", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0} {"lang": "GNU C++17", "source_code": "#include\n\nusing namespace std;\n\nint main()\n{\n int n,a,x,b,y;\n cin>>n>>a>>x>>b>>y;\n if(a==n)a=0;\n if(b==1)b=n;\n for(int i=1; i<=n; i++){\n a++;\n b--;\n if(a==b){\n cout<<\"YES\"<\nusing namespace std;\n\nint main(){\t\n\n\tint n, a, x, b, y;\n\tcin >> n >> a >> x >> b >> y;\n\n\tbool t = a < b && x > y;\n\n\tcout << (t ? \"YES\" : \"NO\") << endl;\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "67cea61f936e414d14e39c555b286002", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\nusing namespace std;\ntypedef long long int ll;\n#define mset(x,y) memset(x,y,sizeof(x))\n#define pb push_back\n#define iosbase ios_base::sync_with_stdio(false); cin.tie(NULL);\n\nint main()\n{\n\tll n,a1,a,x,b1,b,y,flag=0,i;\n\tcin>>n>>a>>x>>b>>y;\n\t//cout<<\"A \"<=y))\n\t{\n\t\ta=a+1;\n\t\tb=b-1;\n\t\tcout<<\"A \"<x && x1)\n\t\t{\n\t\t\tb=b1;\n\t\t}\n\t}\n\tif(flag==1)\n\t{\n\t\tcout<<\"YES\\n\";\n\t}\n\telse\n\t{\n\t\tcout<<\"NO\\n\";\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f2059ec17a90573256b97e24bdc073b8", "src_uid": "5b889751f82c9f32f223cdee0c0095e4", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include\nusing namespace std;\nint a[1000];\nint n;\nvoid b(int i,int j)\n{\n if(j!=1&&i==0&&j%n==1)\n return;\n a[i]=1;\n i+=(j-1);\n if(i==-1)\n i=n-1;\n i=i%n;\n j++;\n b(i,j);\n}\nint main()\n{\n cin>>n;\n b(0,1);\n for(int h=0;h\nusing namespace std;\n#include\n#include\nint a[1000];\nint n;\nvoid b(int i,int j)\n{\n if(j!=1&&i==0&&j%n==1)\n return;\n a[i]=1;\n i+=(j-1);\n if(i==-1)\n i=n-1;\n i=i%n;\n j++;\n b(i,j);\n}\nint main()\n{\n cin>>n;\n b(0,1);\n for(int h=0;h\n#include \n\nusing namespace std;\n\nint main()\n{\n int n = 0 ;\n cin >> n ;\n if(n==1) {\n cout << \"YES\\n\" ;\n } else {\n if(n%2==0) cout << \"YES\\n\" ;\n else cout << \"NO\\n\" ;\n }\n getch();\n return 0 ;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "83d113542ffd6d1f509e4b3403fb3bee", "src_uid": "4bd174a997707ed3a368bd0f2424590f", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main()\n{\n int n = 0 ;\n cin >> n ;\n if(n==1||n==2) {\n cout << \"YES\\n\" ;\n } else if(n==3) {\n cout << \"NO\\n\" ;\n } else {\n if(n%4==0) cout << \"YES\\n\" ;\n else cout << \"NO\\n\" ;\n }\n // getch();\n return 0 ;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "533bddb89fe56e888967512e03ab5038", "src_uid": "4bd174a997707ed3a368bd0f2424590f", "difficulty": 1200.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint main(){\n\tios_base::sync_with_stdio(false);cin.tie(0);\n cout.tie(0);\n\tint n;\n\tcin>>n;\n\tstring s;\n\tcin>>s;\n\tif(n==1){\n\t\tcout<<0<<\"\\n\";\n\t\treturn 0;\n\t}\n\telse{\n\t\tint ans=0;\n\t\tstring ll,t;\n\t\tqueue> q;\n\t\tq.push(make_pair(s,0));\n\t\twhile(!q.empty()){\n\t\t\tpair u=q.front();\n\t\t\tq.pop();\n\t\t\tans=max(ans,u.second);\n\t\t\t\n\t\t\t t=u.first;\n\t\t\t//cout<\nusing namespace std;\n\n#define ll long long\n#define llu unsigned long long\n#define PB push_back\n#define F first\n#define S second\nconst ll MOD = 1000000007;\nconst ll INF = 1000000007;\n\nvoid __print(int x) {cerr << x;}\nvoid __print(long x) {cerr << x;}\nvoid __print(long long x) {cerr << x;}\nvoid __print(unsigned x) {cerr << x;}\nvoid __print(unsigned long x) {cerr << x;}\nvoid __print(unsigned long long x) {cerr << x;}\nvoid __print(float x) {cerr << x;}\nvoid __print(double x) {cerr << x;}\nvoid __print(long double x) {cerr << x;}\nvoid __print(char x) {cerr << '\\'' << x << '\\'';}\nvoid __print(const char *x) {cerr << '\\\"' << x << '\\\"';}\nvoid __print(const string &x) {cerr << '\\\"' << x << '\\\"';}\nvoid __print(bool x) {cerr << (x ? \"true\" : \"false\");}\n\ntemplate\nvoid __print(const pair &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}\ntemplate\nvoid __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? \",\" : \"\"), __print(i); cerr << \"}\";}\nvoid _print() {cerr << \"]\\n\";}\ntemplate \nvoid _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << \", \"; _print(v...);}\n#ifndef ONLINE_JUDGE\n#define ck(x...) cerr << \"[\" << #x << \"] = [\"; _print(x)\n#else\n#define ck(x...)\n#endif\n\nstring gh = \"here\";\nvector < string > ab, ba;\n\nint main(){\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n #ifndef ONLINE_JUDGE\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n freopen(\"err.txt\", \"w\", stderr);\n #endif\n\n int n;\n cin>>n;\n string s;\n cin>>s;\n // vector < string > ab;\n ab.PB(s);\n int ans =-1;\n while(true){\n if(ab.empty()){\n break;\n }\n ans++;\n // vector < string > ba(ab);\n ba = ab;\n ab.clear();\n int sz = ba.size();\n for(int i= 0;i= n || ff[j+1] != ff[j]-1))\n continue;\n string uu;\n for(int k = 0;k\nusing namespace std;\n\n#define ll long long\n#define llu unsigned long long\n#define PB push_back\n#define F first\n#define S second\nconst ll MOD = 1000000007;\nconst ll INF = 1000000007;\n\nvoid __print(int x) {cerr << x;}\nvoid __print(long x) {cerr << x;}\nvoid __print(long long x) {cerr << x;}\nvoid __print(unsigned x) {cerr << x;}\nvoid __print(unsigned long x) {cerr << x;}\nvoid __print(unsigned long long x) {cerr << x;}\nvoid __print(float x) {cerr << x;}\nvoid __print(double x) {cerr << x;}\nvoid __print(long double x) {cerr << x;}\nvoid __print(char x) {cerr << '\\'' << x << '\\'';}\nvoid __print(const char *x) {cerr << '\\\"' << x << '\\\"';}\nvoid __print(const string &x) {cerr << '\\\"' << x << '\\\"';}\nvoid __print(bool x) {cerr << (x ? \"true\" : \"false\");}\n\ntemplate\nvoid __print(const pair &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}\ntemplate\nvoid __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? \",\" : \"\"), __print(i); cerr << \"}\";}\nvoid _print() {cerr << \"]\\n\";}\ntemplate \nvoid _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << \", \"; _print(v...);}\n#ifndef ONLINE_JUDGE\n#define ck(x...) cerr << \"[\" << #x << \"] = [\"; _print(x)\n#else\n#define ck(x...)\n#endif\n\nstring gh = \"here\";\n\nint main(){\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n #ifndef ONLINE_JUDGE\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n freopen(\"err.txt\", \"w\", stderr);\n #endif\n\n int n;\n cin>>n;\n string s;\n cin>>s;\n vector < string > ab;\n ab.PB(s);\n int ans =-1;\n while(true){\n if(ab.empty()){\n break;\n }\n ans++;\n vector < string > ba(ab);\n ab.clear();\n int sz = ba.size();\n for(int i= 0;i= n || ff[j+1] != ff[j]-1))\n continue;\n string uu;\n for(int k = 0;k\nusing namespace std;\n\n#define ll long long\n#define llu unsigned long long\n#define PB push_back\n#define F first\n#define S second\nconst ll MOD = 1000000007;\nconst ll INF = 1000000007;\n\nvoid __print(int x) {cerr << x;}\nvoid __print(long x) {cerr << x;}\nvoid __print(long long x) {cerr << x;}\nvoid __print(unsigned x) {cerr << x;}\nvoid __print(unsigned long x) {cerr << x;}\nvoid __print(unsigned long long x) {cerr << x;}\nvoid __print(float x) {cerr << x;}\nvoid __print(double x) {cerr << x;}\nvoid __print(long double x) {cerr << x;}\nvoid __print(char x) {cerr << '\\'' << x << '\\'';}\nvoid __print(const char *x) {cerr << '\\\"' << x << '\\\"';}\nvoid __print(const string &x) {cerr << '\\\"' << x << '\\\"';}\nvoid __print(bool x) {cerr << (x ? \"true\" : \"false\");}\n\ntemplate\nvoid __print(const pair &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}\ntemplate\nvoid __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? \",\" : \"\"), __print(i); cerr << \"}\";}\nvoid _print() {cerr << \"]\\n\";}\ntemplate \nvoid _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << \", \"; _print(v...);}\n#ifndef ONLINE_JUDGE\n#define ck(x...) cerr << \"[\" << #x << \"] = [\"; _print(x)\n#else\n#define ck(x...)\n#endif\n\nstring gh = \"here\";\n\nint main(){\n ios_base::sync_with_stdio(false);\n cin.tie(NULL);\n #ifndef ONLINE_JUDGE\n freopen(\"input.txt\", \"r\", stdin);\n freopen(\"output.txt\", \"w\", stdout);\n freopen(\"err.txt\", \"w\", stderr);\n #endif\n\n int n;\n cin>>n;\n string s;\n cin>>s;\n vector < string > ab;\n ab.PB(s);\n int ans =-1;\n while(true){\n if(ab.empty()){\n break;\n }\n ans++;\n vector < string > ba(ab);\n ab.clear();\n int sz = ba.size();\n for(int i= 0;i= n || ff[j+1] != ff[j]-1))\n continue;\n string uu;\n for(int k = 0;k\n\nusing namespace std;\n\nmt19937 g1(chrono::steady_clock::now().time_since_epoch().count());\nint T, H;\nmap> mp;\nstack stk;\nvector graph[200];\n\nvector query(int n){\n\tif(mp.count(n)){\n\t\treturn mp[n];\n\t}\n\tcout << \"? \" << n << endl;\n\tvector ret;\n\n\tint k;\n\tcin >> k;\n\tif(!k){\n\t\texit(0);\n\t}\n\twhile(k--){\n\t\tint nn;\n\t\tcin >> nn;\n\t\tif(!nn){\n\t\t\texit(0);\n\t\t}\n\t\tret.push_back(nn);\n\t}\n\tmp[n] = ret;\n\n /*\n\tret = graph[n];\n\tsort(ret.begin(), ret.end());\n\tfor(int e : ret){\n cout << e << \" \";\n\t}\n\tcout << endl;\n */\n\treturn mp[n] = ret;\n}\n\nint dfs(int n, bool b = 0){\n\tauto adj = query(n);\n\tif(adj.size() == 2){\n\t\tcout << \"! \" << n << endl;\n\t\treturn INT_MIN/2;\n\t}\n\tint ret = 1;\n\tif(b){\n\t\tstk.push(n);\n\t}\n\tfor(int e : adj){\n\t\tif(!mp.count(e)){\n\t\t\tret += dfs(e, b);\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn ret;\n}\n\nvoid solve(){\n\tcin >> H;\n\tif(!H){\n\t\texit(0);\n\t}\n /*\n\tfor(int i = 1; i<(1<> a >> b;\n\t\tgraph[a].push_back(b);\n\t\tgraph[b].push_back(a);\n\t}\n */\n\tif(H <= 4){\n\t\tfor(int i = 1; i<1<<4; i++){\n\t\t\tauto adj = query(i);\n\t\t\tif(adj.size() == 2){\n\t\t\t\tcout << \"! \" << i << endl;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n\tint rt = 1;\n\tint crnt = rt, crnth, lst;\n\tauto adj = query(crnt);\n\tif(adj.size() == 2){\n\t\tcout << \"! \" << crnt << endl;\n\t\treturn;\n\t}\n\telse if(adj.size() == 1){\n\t\tcrnth = H-1;\n crnt = adj[0];\n\t}\n\telse {\n\t\tint opt1 = dfs(adj[0], 1);\n\t\tif(opt1 < 0){\n\t\t\treturn;\n\t\t}\n\t\tint opt2 = dfs(adj[1], 1);\n\t\tif(opt2 < 0){\n\t\t\treturn;\n\t\t}\n\t\tcrnth = H - min(opt1, opt2);\n\t\tif(opt1 > opt2){\n\t\t\tint s = opt1 - H + crnth;\n\t\t\tint x = s/2 + H-crnth;\n\t\t\tfor(int xx = 0; xx opt1);\n\t\t\t//lst = stk.size() == opt1 ? temp : stk.top();\n\t\t}\n\t\tcrnth--;\n\t\tlst = crnt;\n\t\tadj = query(crnt);\n\t\tassert(adj.size() >= 2);\n int counting = 0;\n for(int e : adj){\n if(!mp.count(e)){\n crnt = e;\n counting++;\n }\n }\n assert(counting == 1);\n\t}\n\twhile(stk.size()){\n\t\tstk.pop();\n\t}\n\t//cout << \"start: \" << crnt << \" \" << crnth << endl;\n\tcout << \"wtf: \" << crnt << \" \" << crnth << endl;\n\twhile(crnth > 3){\n //cout << \"iteration: \" << crnt << \" \" << crnth << endl;\n\t\tauto adj = query(crnt);\n\t\tfor(int e : adj){\n\t\t\tif(!mp.count(e)){\n //assert(e != lst);\n\t\t\t\tint s = dfs(e, 1);\n\t\t\t\tif(s < 0){\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ts -= H-crnth;\n\t\t\t\t//cout << s << endl;\n\t\t\t\tif(s){\n\t\t\t\t\tassert(s%2 == 0 && s > 0);\n\t\t\t\t\tint x = s/2 + H-crnth;\n\t\t\t\t\t//cout << x << endl;\n\t\t\t\t\tfor(int xx = 0; xx> T;\n\twhile(T--){\n\t\tsolve();\n\t\tmp.clear();\n\t\twhile(stk.size()){\n\t\t\tstk.pop();\n\t\t}\n\t}\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7a70460544d05ebf013fc7290374f15a", "src_uid": "5c0db518fa326b1e405479313216426a", "difficulty": 2800.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define REP(i,N)for(long long i=0;i<(N);i++)\n#define FOR(i,a,b)for(long long i=(a);i<=(b);i++)\n#define FORD(i,a,b)for(long long i=a;i>=(b);i--)\n#define ll long long\n#define vi vector\n#define vii vector >\n#define vvi vector >\n#define pii pair\n#define ALL(x) (x).begin(), (x).end()\n#define SZ(a)((ll)(a).size())\n#define CHECK_BIT(n,x)((n)&(((ll)1)<<(x)))\n#define pow2(x) ((x)*(x))\n#define VELA 99999999999999999ll\nusing namespace std;\n\nvvi graf;\nll nQueries;\n\nvi Ask(ll v) {\n\tnQueries++;\n\tcout << \"? \" << v << \"\\n\";\n\tfflush(stdout);\n\tvi res;\n\tll k;\n\tcin >> k;\n\tREP(i, k) {\n\t\tll x;\n\t\tcin >> x;\n\t\tgraf[v].push_back(x);\n\t\tres.push_back(x);\n\t}\n\treturn res;\n}\n\nvi GO(ll v, ll u) {\n\tvi subs=Ask(v);\n\tif (SZ(subs) == 1)return vi(1,v);\n\tREP(i, SZ(subs)) {\n\t\tif (subs[i] == u)continue;\n\t\telse{\n\t\t\tvi res(GO(subs[i], v));\n\t\t\tres.push_back(v);\n\t\t\treturn res;\n\t\t}\n\t}\n\treturn vi();\n}\n\nbool Go2(ll v, ll u, ll depth,ll maxDepth) {\n\tif (depth > maxDepth)return false;\n\tvi subs = Ask(v);\n\tif (SZ(subs) == 1)return true;\n\tREP(i, SZ(subs)) {\n\t\tif (subs[i] == u)continue;\n\t\telse {\n\t\t\treturn Go2(subs[i], v, depth + 1, maxDepth);\n\t\t}\n\t}\n\treturn true;\n}\n\nvi Complement(ll v, vi disc) {\n\tvi res;\n\tREP(i, SZ(graf[v])) {\n\t\tbool ok = true;\n\t\tREP(j, SZ(disc))if (graf[v][i] == disc[j])ok = false;\n\t\tif (ok)res.push_back(graf[v][i]);\n\t}\n\treturn res;\n}\n\nll Complement(ll v, ll a,ll b) {\n\tvi temp(1, a);\n\ttemp.push_back(b);\n\treturn Complement(v, temp)[0];\n}\n\nvoid Ans(ll v){cout << \"! \" << v << \"\\n\"; fflush(stdout);}\n\nint main() {\n\tcin.sync_with_stdio(0);\n\tll nTests;\n\tcin >> nTests;\n\tREP(test, nTests) {\n\t\tll height;\n\t\tcin >> height;\n\t\tgraf = vvi(200,vi());\n\t\tnQueries = 0;\n\t\t//Find leaf-leaf path\n\t\tvi subsFirst = Ask(1);\n\t\tvi path=GO(subsFirst[0],1);\n\t\tvi pathB;\n\t\tif(SZ(subsFirst)>1)\n\t\t\tpathB=GO(subsFirst[1],1);\n\t\tpath.push_back(1);\n\t\tFORD(j, SZ(pathB)-1ll,0ll)path.push_back(pathB[j]);\n\t\t//Find highest vertex\n\t\tll topV = path[SZ(path) / 2];\n\t\tif (SZ(graf[topV]) == 2) { Ans(topV); continue; }\n\t\tll under = (SZ(path) - 1) / 2;\n\t\tll predV = topV;\n\t\ttopV = Complement(topV, path[SZ(path) / 2 - 1], path[SZ(path) / 2 + 1]);\n\t\tunder++;\n\t\t//Find up to 4 vertex\n\t\twhile (under < ((height+1)/2)) {\n\t\t\tAsk(topV);\n\t\t\tvi posSubs = Complement(topV, vi(2,predV));\n\t\t\tif (Go2(posSubs[0], topV, 0, under)) {\n\t\t\t\ttopV = posSubs[1];\n\t\t\t}\n\t\t\telse {\n\t\t\t\ttopV = posSubs[0];\n\t\t\t}\n\t\t\tunder++;\n\t\t\tpredV = topV;\n\t\t}\n\t\t//Do BFS\n\t\tqueue q;\n\t\tq.push(pii(topV, predV));\n\t\twhile (true) {\n\t\t\tll v = q.front().first;\n\t\t\tll u = q.front().second;\n\t\t\tq.pop();\n\t\t\tif (nQueries == 16||SZ(Ask(v))==2) {\n\t\t\t\tAns(v);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tREP(j, SZ(graf[v])) {\n\t\t\t\tif (graf[v][j] == u)continue;\n\t\t\t\tq.push(pii(graf[v][j], v));\n\t\t\t}\n\t\t}\n\t}\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ba9812cee3f8a329b4d08f3e03d46e05", "src_uid": "5c0db518fa326b1e405479313216426a", "difficulty": 2800.0} {"lang": "GNU C++14", "source_code": "#include \n#define endl '\\n'\n\n//#pragma GCC optimize (\"O3\")\n//#pragma GCC target (\"sse4\")\n\n#define SZ(x) ((int)x.size())\n#define ALL(V) V.begin(), V.end()\n#define L_B lower_bound\n#define U_B upper_bound\n#define pb push_back\n\nusing namespace std;\ntemplate inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }\ntemplate inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }\nconst int MAXN = (1 << 8);\n\nint root, Q;\nvector memo[MAXN];\n\nvector query(int u)\n{\n\tif(!memo[u].empty())\n\t\treturn memo[u];\n\n\t/*\n\t * if(root == -1 && Q == 0)\n\t{\n\t\troot = u;\n\t\treturn {};\n\t}\n\telse if(Q == 0)\n\t\treturn {};\n*/\n\n\t//Q--;\n\tcout << \"? \" << u << endl << flush;\n\n\tint cnt;\n\tcin >> cnt;\n\tvector ret;\n\t\n\tif(cnt == 2) root = u;\n\twhile(cnt--)\n\t{\n\t\tint x;\n\t\tcin >> x;\n\t\tret.pb(x);\n\t}\n\n\t//random_shuffle(ALL(ret));\n\n\tmemo[u] = ret;\n\treturn ret;\n}\n\nint h;\n\nvoid read()\n{\n\tQ = 16;\n\troot = -1;\n\tcin >> h;\n}\n\nbool visited[MAXN];\n\nvector path;\nint find_leaf(int u)\n{\n\tif(root != -1)\n\t\treturn -1;\n\t\n\tvector adj = query(u);\n\tpath.pb(u);\n\tif(root != -1)\n\t\treturn -1;\n\n\tvisited[u] = true;\n\tif(SZ(adj) == 1) \n\t\treturn u;\n\n\tfor(int v: adj)\n\t\tif(!visited[v])\n\t\t\treturn find_leaf(v);\n\n\treturn -1;\n}\n\nvoid get_path(int u)\n{\n\tpath.clear();\n\tfind_leaf(u);\n\tif(root != -1) return;\n\treverse(ALL(path));\n\tpath.pop_back();\n\tfind_leaf(u);\n}\n\nvoid dfs(int u, int h)\n{\n\tif(root != -1) return;\n\tvector adj = query(u);\n\tif(root != -1) return;\n\tvisited[u] = true;\n\n\tfor(int v: adj)\n\t\tif(h && !visited[v])\n\t\t\tdfs(v, h - 1);\n}\n\nbool used[MAXN];\n\nbool no_leaf(int u, int h)\n{\n\tif(h == -1)\n\t\treturn true;\n\n\tvector adj = query(u);\n\tused[u] = true;\n\n\tif(root != -1)\n\t\treturn false;\n\n\tfor(int v: adj)\n\t\tif(!used[v])\n\t\t\treturn no_leaf(v, h - 1);\n\n\treturn false;\n}\n\n\nvoid solve()\n{\n\tfor(int i = 1; i <= (1 << h); i++)\n\t\tvisited[i] = 0, memo[i].clear();\n\n\tget_path(1);\n\t\n\tif(root != -1) \n\t{\n\t\tcout << \"! \" << root << endl << flush;\n\t\treturn;\n\t}\n\t\n\tint u = path[SZ(path) / 2];\n\tint ch = SZ(path) / 2;\n\n\tvector adj1 = query(u);\n\tfor(int v: adj1)\n\t\tif(!visited[v])\n\t\t\tu = v;\n\n\tvisited[u] = true;\n\th--;\n\tch = h - ch - 1;\n\n\tquery(u);\n\twhile(true)\n\t{\n\t\tif(ch <= 3)\n\t\t{\n\t\t\tdfs(u, ch);\n\t\t\tbreak;\n\t\t}\n\n\t\tvisited[u] = true;\n\t\tvector adj, _adj = query(u);\n\t\tfor(int q: _adj) if(!visited[q]) adj.pb(q); \n\t\t\n\t\tif(root != -1)\n\t\t\tbreak;\n\n\t\tfor(int i = 1; i <= (2 << h); i++) used[i] = 0;\n\t\tused[u] = true;\n\t\tif(no_leaf(adj[0], h - ch - 1)) u = adj[0];\n\t\telse u = adj[1];\n\n\t\tif(root != -1)\n\t\t\tbreak;\n\t\t\n\t\tquery(u);\n\t\tch--;\n\t}\n\n\tcout << \"! \" << root << endl << flush;\n}\n\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\n\tint T;\n\tcin >> T;\n\twhile(T--)\n\t{\n\t\tread();\n\t\tsolve();\n\t}\n\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a1675eca6c98eb4c35740529f3b0f89e", "src_uid": "5c0db518fa326b1e405479313216426a", "difficulty": 2800.0} {"lang": "GNU C++14", "source_code": "#include \n#define endl '\\n'\n\n//#pragma GCC optimize (\"O3\")\n//#pragma GCC target (\"sse4\")\n\n#define SZ(x) ((int)x.size())\n#define ALL(V) V.begin(), V.end()\n#define L_B lower_bound\n#define U_B upper_bound\n#define pb push_back\n\nusing namespace std;\ntemplate inline int chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }\ntemplate inline int chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }\nconst int MAXN = (1 << 20);\n\nint root, Q;\nvector memo[MAXN];\n\nvector query(int u)\n{\n\tif(!memo[u].empty())\n\t\treturn memo[u];\n\n\t/*if(Q == 0)\n\t{\n\t\troot = u;\n\t\treturn {};\n\t}*/\n\n\tQ--;\n\tcout << \"? \" << u << endl << flush;\n\n\tint cnt;\n\tcin >> cnt;\n\tvector ret;\n\t\n\tif(cnt == 2) root = u;\n\twhile(cnt--)\n\t{\n\t\tint x;\n\t\tcin >> x;\n\t\tret.pb(x);\n\t}\n\n\tmemo[u] = ret;\n\treturn ret;\n}\n\nint h;\n\nvoid read()\n{\n\tQ = 16;\n\troot = -1;\n\tcin >> h;\n}\n\nbool visited[MAXN];\n\nvector path;\nint find_leaf(int u)\n{\n\tif(root != -1)\n\t\treturn -1;\n\t\n\tvector adj = query(u);\n\tpath.pb(u);\n\tif(root != -1)\n\t\treturn -1;\n\n\tvisited[u] = true;\n\tif(SZ(adj) == 1) \n\t\treturn u;\n\n\tfor(int v: adj)\n\t\tif(!visited[v])\n\t\t\treturn find_leaf(v);\n\n\treturn -1;\n}\n\nvoid get_path(int u)\n{\n\tpath.clear();\n\tfind_leaf(u);\n\tif(root != -1) return;\n\treverse(ALL(path));\n\tpath.pop_back();\n\tfind_leaf(u);\n}\n\nvoid dfs(int u, int h)\n{\n\tif(root != -1) return;\n\tvector adj = query(u);\n\tif(root != -1) return;\n\tvisited[u] = true;\n\n\tfor(int v: adj)\n\t\tif(h && !visited[v])\n\t\t\tdfs(v, h - 1);\n}\n\nbool used[MAXN];\n\nbool no_leaf(int u, int h)\n{\n\tif(h == -1)\n\t\treturn true;\n\n\tvector adj = query(u);\n\tused[u] = true;\n\n\tif(root != -1)\n\t\treturn false;\n\n\tfor(int v: adj)\n\t\tif(!used[v])\n\t\t\treturn no_leaf(v, h - 1);\n\n\treturn false;\n}\n\n\nvoid solve()\n{\n\tfor(int i = 1; i <= (1 << h); i++)\n\t\tvisited[i] = 0, memo[i].clear();\n\n\tget_path(1);\n\t\n\tif(root != -1) \n\t{\n\t\tcout << \"! \" << root << endl << flush;\n\t\treturn;\n\t}\n\t\n\tint u = path[SZ(path) / 2];\n\tint ch = SZ(path) / 2;\n\n\tvector adj1 = query(u);\n\tfor(int v: adj1)\n\t\tif(!visited[v])\n\t\t\tu = v;\n\n\tvisited[u] = true;\n\th--;\n\tch = h - ch - 1;\n\n\tquery(u);\n\twhile(true)\n\t{\n\t\tif(ch <= 3)\n\t\t{\n\t\t\tdfs(u, 3);\n\t\t\tbreak;\n\t\t}\n\n\t\tvisited[u] = true;\n\t\tvector adj, _adj = query(u);\n\t\tfor(int q: _adj) if(!visited[q]) adj.pb(q); \n\t\t\n\t\tif(root != -1)\n\t\t\tbreak;\n\n\t\tfor(int i = 1; i <= (2 << h); i++) used[i] = 0;\n\t\tused[u] = true;\n\t\tif(no_leaf(adj[0], h - ch - 1)) u = adj[0];\n\t\telse u = adj[1];\n\n\t\tif(root != -1)\n\t\t\tbreak;\n\t\t\n\t\tquery(u);\n\t\tch--;\n\t}\n\n\tcout << \"! \" << root << endl << flush;\n}\n\nint main()\n{\n\tios_base::sync_with_stdio(false);\n\tcin.tie(NULL);\n\n\tint T;\n\tcin >> T;\n\twhile(T--)\n\t{\n\t\tread();\n\t\tsolve();\n\t}\n\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e578322f92abe2c72aab0c8c59198a6f", "src_uid": "5c0db518fa326b1e405479313216426a", "difficulty": 2800.0} {"lang": "GNU C++", "source_code": "\n // In the name of GOD\n // I love my love\n\n#include \n\n#define pb push_back\n#define pp pop_back()\n#define fr first\n#define sc second\n#define sz size()\n#define P 3.1415926535\n#define mp make_pair\n#define CS; ios_base::sync_with_stdio(false); cin.tie(false); cout.tie(false);\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef pair ii;\ntypedef vector vi;\n\nconst int M=1e3+5;\nll t(ll k,ll n)\n{\n if(k==0 || n==k)\n return 1;\n if(k==1)\n return n;\n return t(k,n-1)+t(k-1,n-1);\n}\n\n\n\nint main()\n{\n ll n;\n cin>>n;\n ll g=5;\n ll h=6;\n ll f=7;\n ll ans=0;\n ans+=t(g,n);\n ans+=t(h,n);\n ans+=t(f,n);\n cout<\n#include\n#include\nusing namespace std;\nstruct node {\n int l,r,v;\n}q[10001];\nint a[20001],fa[20001],d[20001],n,m;\n\n\ninline void read(int &f) {\n f=0;char c=getchar();int ag=1;\n while(!isdigit(c)) {if (c=='-') ag=-1; c=getchar();}\n while(isdigit(c)){f=(f<<3)+(f<<1)+c-48;c=getchar();}\n f*=ag; return;\n}\nvoid write(int x) {\n if (x<0) putchar('-'),x*=-1;\n if (x>9) write(x/10);putchar(x%10+48);return;\n}\n\n\ninline void read_init() {\n int t=0; read(n);read(m);\n for (int i=1;i<=m;i++) {\n char c[5];\n read(q[i].l); read(q[i].r);\n scanf(\"%s\",c);\n q[i].v=c[0]=='o'?1:0;\n a[++t]=q[i].l-1;\n a[++t]=q[i].r;\n }\n sort(a+1,a+t+1);\n n=unique(a+1,a+t+1)-a-1;\n return;\n}\nint find(int x) {\n if (x==fa[x]) return x;\n int root=find(fa[x]); d[x]^=d[fa[x]];\n return fa[x]=root;\n}\nint main() {\n read_init();\n for (int i=1;i<=n;i++) fa[i]=i;\n for (int i=1;i<=m;i++) {\n int x=lower_bound(a+1,a+n+1,q[i].l-1)-a;\n int y=lower_bound(a+1,a+n+1,q[i].r)-a;\n int P=find(x),Q=find(y);\n if (P==Q)\n if ((d[x]^d[y])!=q[i].v) {\n write(i-1); return 0;\n }\n fa[P]=Q; d[P]=d[x]^d[y]^q[i].v;\n }\n write(m); return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "28f0c96081c7ca533ad91a4d585c2807", "src_uid": "816ec4cd9736f3113333ef05405b8e81", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#include \nusing namespace std;\n\nint main()\n{\n\t__int64 x;\n\tcin >> x;\n\tx=2-(x%2);\n\tcout << x;\n\tcout << endl;\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "78451b6b2bdd23aae650d576e423865e", "src_uid": "816ec4cd9736f3113333ef05405b8e81", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include \n\n#define fs first\n#define sc second\n#define pb push_back\n#define mp make_pair\n#define sz(s) ((int) s.size ())\n#define all(s) s.begin (), s.end ()\n\n#define name \"\"\n\nusing namespace std;\n\ntypedef long long ll;\ntypedef long double ld;\ntypedef unsigned long long ull;\n\ntypedef pair ii;\ntypedef vector vi;\ntypedef vector vii;\n\nconst ld eps = 1e-16;\nconst int N = 100009;\nconst int inf = (int) 1e9;\nconst int mod = (int) 1e9 + 7;\n\nint ans[] = {1, 1, 2};\n\nint main () {\n #ifdef FSTREAM\n freopen (name\".in\", \"r\", stdin);\n freopen (name\".out\", \"w\", stdout);\n #endif // FSTREAM\n int n; cin >> n;\n if (n == 4) {\n assert (false);\n } else {\n if (n & 1) {\n puts (\"1\");\n } else {\n puts (\"2\");\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b7254b0fa775850b444755640393a7f2", "src_uid": "816ec4cd9736f3113333ef05405b8e81", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\n#define ll long long\n#define MAX LONG_MAX\n#define e6 1000001\n#define e4 10001\n\nchar tochar(int x)\n{\n return char(x+'0');\n}\nint toint (char c)\n{\n return int(c-'0');\n}\nint main()\n{\n ios::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n//-----------------------\n string maxs=\"\",mins;\n int dig,n;\n cin>>dig>>n;\n // 2 15\n ll sum =0;\n\n if (dig>n || n!=0 || dig >= 100)\n {\n sum=0;\n maxs=\"\";\n while (sum=0; i--)\n {\n if (mins[i]!='9')\n {\n for(int j=i-1; j>=0; j--)\n {\n if (mins[i]=='9')break;\n\n int add = 9-toint(mins[i]);\n if (toint(mins[j])<=add)\n mins[i]= tochar(toint(mins[j])+toint(mins[i])),mins[j]='0';\n else\n mins[i]=tochar(add+toint(mins[i])),mins[j]=tochar(toint(mins[j])-add);\n }\n\n }\n\n }\n for(int i=0; i\n \nusing namespace std;\n \n#define pb push_back\n#define f first\n#define se second\n#define pii pair < int , int >\n#define mp make_pair\n#define LOGMAX 17\n#define MX 1 << 22\n#define l(n) n << 1\n#define r(n) (n << 1) + 1\n#define FIND(N,pos) ((N) & (1 << (pos)))\n#define sf(h) scanf(\"%d\",&h)\n#define sff(h,b) scanf(\"%d%d\",&h,&b)\n#define sfff(h,b,c) scanf(\"%d%d%d\",&h,&b,&c)\n#define TCASE(test) for(int z = 1;z <= test;z++)\n#define PRINT printf(\"Case %d:\\n\",z)\n#define en \"\\n\"\n#define lwb lower_bound\n#define upb upper_bound\n#define fori for(int i = 0; i < n; i++)\n \ntypedef long long ll;\ntypedef unsigned long long ull;\ntypedef pair < long long , long long > pll;\n \nconst int maxn = int(1.5 * 1e7);\nconst int inf = 1e9 + 7;\nconst ll ll_inf = 1e18 + 420;\nconst double eps = 1e9;\nconst int N = 1e9 + 7;\nconst int MAX = 2e5 + 9;\nstring mn, mx;\nint main(){\n int m, s;\n cin >> m >> s;\n if(s == 0 && m != 1 || m * 9 < s){\n cout << \"-1 -1\";\n return 0;\n } \n else if(s == 0 && m == 1){\n cout << \"0 0\";\n return 0;\n }\n else if(s == 1){\n mn += '1';\n for(int i = 1; i < m; i++){\n mn += '0';\n }\n cout << mn << ' ' << mn;\n return 0;\n }\n else if(m == 1){\n mn = s + 48;\n cout << mn << ' ' << mn;\n return 0;\n }\n else{\n int k = m, t = s;\n while(t >= 9 && k > 0){\n mx += '9';\n t -= 9;\n k--;\n }\n while(t >= 8 && k > 0){\n mx += '8';\n t -= 8;\n k--;\n }\n while(t >= 7 && k > 0){\n mx += '7';\n t -= 7;\n k--;\n }\n while(t >= 6 && k > 0){\n mx += '6';\n t -= 6;\n k--;\n }\n while(t >= 5 && k > 0){\n mx += '5';\n t -= 5;\n k--;\n }\n while(t >= 4 && k > 0){\n mx += '4';\n t -= 4;\n k--;\n }\n while(t >= 3 && k > 0){\n mx += '3';\n t -= 3;\n k--;\n }\n while(t >= 2 && k > 0){\n mx += '2';\n t -= 2;\n k--;\n }\n while(t >= 1 && k > 0){\n mx += '1';\n t -= 1;\n k--;\n }\n while(k > 0){\n mx += '0';\n k--;\n }\n k = m, t = s;\n if(t - 1 <= (k - 1) * 9){\n mn += '1';\n t--;\n k--;\n }\n else if(t - 2 <= (k - 1) * 9){\n mn += '2';\n t-=2;\n k--;\n }\n else if(t - 3 <= (k - 1) * 9){\n mn += '3';\n t--;\n k--;\n }\n else if(t - 4 <= (k - 1) * 9){\n mn += '4';\n t--;\n k--;\n }\n else if(t - 5 <= (k - 1) * 9){\n mn += '5';\n t--;\n k--;\n }\n else if(t - 6 <= (k - 1) * 9){\n mn += '6';\n t--;\n k--;\n }\n else if(t - 7 <= (k - 1) * 9){\n mn += '7';\n t--;\n k--;\n }\n else if(t - 8 <= (k - 1) * 9){\n mn += '8';\n t--;\n k--;\n }\n else if(t - 9 <= (k - 1) * 9){\n mn += '9';\n t--;\n k--;\n }\n else if(t <= (k - 1) * 9){\n mn += '0';\n k--;\n }\n while(t <= (k - 1) * 9){\n mn += '0';\n k--;\n }\n while(t - 1 <= (k - 1)){ \n mn += '1';\n t--;\n k--;\n }\n while(t - 2 <= (k - 1) * 9){\n mn += '2';\n t-=2;\n k--;\n }\n while(t - 3 <= (k - 1) * 9){\n mn += '3';\n t--;\n k--;\n }\n while(t - 4 <= (k - 1) * 9){\n mn += '4';\n t--;\n k--;\n }\n while(t - 5 <= (k - 1) * 9){\n mn += '5';\n t--;\n k--;\n }\n while(t - 6 <= (k - 1) * 9){\n mn += '6';\n t--;\n k--;\n }\n while(t - 7 <= (k - 1) * 9){\n mn += '7';\n t--;\n k--;\n }\n while(t - 8 <= (k - 1) * 9){\n mn += '8';\n t--;\n k--;\n }\n while(k > 0){\n mn += '9';\n t--;\n k--;\n }\n }\n cout << mn << ' ' << mx;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4acb69bbf07d2ae1d156f94d99a282f7", "src_uid": "75d062cece5a2402920d6706c655cad7", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include \nusing namespace std;\nstring mn, mx;\nint main(){\n int m, s;\n cin >> m >> s;\n if(s == 0 && m != 1 || m * 9 < s){\n cout << \"-1 -1\";\n return 0;\n } \n else if(s == 0 && m == 1){\n cout << \"0 0\";\n return 0;\n }\n else if(s == 1){\n mn += '1';\n for(int i = 1; i < m; i++){\n mn += '0';\n }\n cout << mn << ' ' << mn;\n return 0;\n }\n else if(m == 1){\n mn = s + 48;\n cout << mn << ' ' << mn;\n return 0;\n }\n else{\n int k = m, t = s;\n while(t >= 9 && k > 0){\n mx += '9';\n t -= 9;\n k--;\n }\n while(t >= 8 && k > 0){\n mx += '8';\n t -= 8;\n k--;\n }\n while(t >= 7 && k > 0){\n mx += '7';\n t -= 7;\n k--;\n }\n while(t >= 6 && k > 0){\n mx += '6';\n t -= 6;\n k--;\n }\n while(t >= 5 && k > 0){\n mx += '5';\n t -= 5;\n k--;\n }\n while(t >= 4 && k > 0){\n mx += '4';\n t -= 4;\n k--;\n }\n while(t >= 3 && k > 0){\n mx += '3';\n t -= 3;\n k--;\n }\n while(t >= 2 && k > 0){\n mx += '2';\n t -= 2;\n k--;\n }\n while(t >= 1 && k > 0){\n mx += '1';\n t -= 1;\n k--;\n }\n while(k > 0){\n mx += '0';\n k--;\n }\n k = m, t = s;\n if(t - 1 <= (k - 1) * 9){\n mn += '1';\n t--;\n k--;\n }\n else if(t - 2 <= (k - 1) * 9){\n mn += '2';\n t-=2;\n k--;\n }\n else if(t - 3 <= (k - 1) * 9){\n mn += '3';\n t--;\n k--;\n }\n else if(t - 4 <= (k - 1) * 9){\n mn += '4';\n t--;\n k--;\n }\n else if(t - 5 <= (k - 1) * 9){\n mn += '5';\n t--;\n k--;\n }\n else if(t - 6 <= (k - 1) * 9){\n mn += '6';\n t--;\n k--;\n }\n else if(t - 7 <= (k - 1) * 9){\n mn += '7';\n t--;\n k--;\n }\n else if(t - 8 <= (k - 1) * 9){\n mn += '8';\n t--;\n k--;\n }\n else if(t - 9 <= (k - 1) * 9){\n mn += '9';\n t--;\n k--;\n }\n else if(t <= (k - 1) * 9){\n mn += '0';\n k--;\n }\n while(t <= (k - 1) * 9){\n mn += '0';\n k--;\n }\n while(t - 1 <= (k - 1)){ \n mn += '1';\n t--;\n k--;\n }\n while(t - 2 <= (k - 1) * 9){\n mn += '2';\n t-=2;\n k--;\n }\n while(t - 3 <= (k - 1) * 9){\n mn += '3';\n t--;\n k--;\n }\n while(t - 4 <= (k - 1) * 9){\n mn += '4';\n t--;\n k--;\n }\n while(t - 5 <= (k - 1) * 9){\n mn += '5';\n t--;\n k--;\n }\n while(t - 6 <= (k - 1) * 9){\n mn += '6';\n t--;\n k--;\n }\n while(t - 7 <= (k - 1) * 9){\n mn += '7';\n t--;\n k--;\n }\n while(t - 8 <= (k - 1) * 9){\n mn += '8';\n t--;\n k--;\n }\n while(k > 0){\n mn += '9';\n t--;\n k--;\n }\n }\n cout << mn << ' ' << mx;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "0a821f467bf6bbe1a434cc277abc87d7", "src_uid": "75d062cece5a2402920d6706c655cad7", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "#include \n#define thicc(boi) boi.size()\n#define magiczne ios_base::sync_with_stdio(0);\n#define linijki cin.tie(NULL);\n\nusing namespace std;\n\nint main()\n{\n magiczne linijki;\n int m, s;\n cin >> m >> s;\n if (m == 1 and s == 0)\n\t{\n \tcout << \"0 0\";\n \treturn 0;\n\t}\n \tif (s == 0 or s > 9*m)\n\t{\n\t\tcout << \"-1 -1\";\n\t\treturn 0;\n\t}\n \tstring boi, boii;\n \tint a = m, b = s;\n \tif ((a - 1) * 9 >= (b - 1))\n\t{\n\t\tboi = '1';\n\t\ta--;\n\t\tb--;\n\t}\n \twhile ((a - 1) * 9 >= b)\n\t{\n \t\tboi += '0';\n \t\ta--;\n\t}\n \tif (b % 9)\n\t{\n \t\tboi += b % 9 + 48;\n \t\tb -= b % 9;\n \t\ta--;\n\t}\n \twhile (a--)\n \t\tboi += '9';\n \tcout << boi << ' ';\n \ta = m, b = s;\n \twhile (b >= 9)\n\t{\n \t\tboii += '9';\n \t\ta--;\n \t\tb -= 9;\n\t}\n \tif (!thicc(boii))\n\t{\n \t\tboii = '1';\n \t\ta--;\n \t\tb--;\n\t}\n \tboii += b % 9 + 48;\n\twhile (--a)\n \t\tboii += '0';\n \tcout << boii;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "488a14f09129f0f80adfd33d5cdda5f8", "src_uid": "75d062cece5a2402920d6706c655cad7", "difficulty": 1400.0} {"lang": "GNU C++11", "source_code": "#include \n\nusing namespace std;\n\n#define pb push_back\n\ntypedef long long ll;\n\nconst int N3 = 1e3 + 15;\nconst int N4 = 1e4 + 15;\nconst int N5 = 1e5 + 15;\nconst int N6 = 1e6 + 15;\nconst int N7 = 1e7 + 15;\nconst int N8 = 1e8 + 15;\nconst int N9 = 1e9 + 15;\n \ndouble a[10010][10010], n, k, ans;\n \nmain()\n{\n\tcin >> n >> k;\n\ta[1][1] += (k * 500);\n\tfor (int i = 1; i < n; ++i)\n\t{\n\t\tfor (int j = 1; j <= i; ++j)\n\t\t{\n\t\t\ta[i + 1][j + 1] += ((a[i][j] - 500) / 2.0);\n\t\t\ta[i + 1][j] += ((a[i][j] - 500) / 2.0);\n\t\t\ta[i][j] -= (a[i][j] - 500);\n\t\t}\n\t}\n\tfor (int i = 1; i <= 10; ++i)\n\t\tfor (int j = 1; j <= 10; ++j)\n\t\t\tans += (a[i][j] >= 500);\n\tcout << ans;\n\treturn 0;\n}// ll, db, 1LL\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "90f639e0ce5bfb6115a363c1f1486ad0", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0} {"lang": "GNU C++17", "source_code": "#include \nusing namespace std;\nint n,k;\ndouble arr[10005][10005];\nint main(){\n scanf(\"%d%d\",&n,&k);\n arr[0][0]=k;\n double excess;\n int ans=0;\n for (int x=0;x=0.999999999){\n ans++;\n excess=arr[x][y]-1;\n excess/=2;\n arr[x+1][y]+=excess;\n arr[x+1][y+1]+=excess;\n }\n }\n }\n printf(\"%d\\n\",ans);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c9e6c62a5846765f4b728b81e457bac6", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include\n#include\nusing namespace std;\n#define FOR(i,s,e) for (int i=(s); i<(e); i++)\n#define FOE(i,s,e) for (int i=(s); i<=(e); i++)\n#define ll long long\nll gcd(ll, ll);\nll gcd(ll,ll);\nint main()\n{\n\tll n, m, ans = 0, i = 1,j,k;\n\tdouble a[30][30] = { 0 };\n\tcin >> n >> m;\n\tfor (i; i <= m; i++)\n\t{\n\t\ta[1][15] = a[1][15] + 1;\n\t\tj = 1;\n\t\tfor (j; j <= n; j++)\n\t\t{\n\t\t\tk = 1;\n\t\t\tfor (k; k <= 29; k++)\n\t\t\t{\n\t\t\t\tif (a[j][k] > 1)\n\t\t\t\t{\n\t\t\t\t\ta[j + 1][k - 1] = a[j + 1][k - 1] + 1/pow(2,j);\n\t\t\t\t\ta[j + 1][k + 1] = a[j + 1][k + 1] + 1 / pow(2, j);\n\t\t\t\t\ta[j][k] = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tj = 1;\n\tfor (j; j <= n; j++)\n\t{\n\t\tk = 1;\n\t\tfor (k; k <= 29; k++)\n\t\t\tif (a[j][k] >= 1)\n\t\t\t\tans++;\n\t}\n\tcout << ans;\n\tgetch();//remove it\n\treturn 0;\n}\nll gcd(ll u, ll v) { while (v != 0) { ll r = u % v; u = v; v = r; }return u; }", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3834bb782952baefbf312238025f5648", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0} {"lang": "MS C++", "source_code": "#include \n#include \n\nusing namespace std;\nconst int maxn = 101;\nconst int maxt = 10001;\nconst int inf = 1e5;\nint p[maxn][maxn];\nint main()\n{\n\tint n, t;\n\tcin >> n >> t;\n\n\tmemset(p, 0, sizeof p);\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tif (i < 12)\n\t\t{\n\t\t\tp[i][0] = p[i][i] = ((2 << i) - 1);\n\t\t}\n\t\telse\n\t\t{\n\t\t\tp[i][0] = p[i][i] = inf;\n\t\t}\n\t}\n\n\tfor (int i = 2; i < n; i++)\n\t{\n\t\tfor (int j = 1; j < i; j++)\n\t\t{\n\t\t\tif (j > i / 2)\n\t\t\t{\n\t\t\t\tp[i][j] = p[i][i - j];\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (p[i - 1][j - 1] != inf && p[i - 2][j - 2] != inf)\n\t\t\t{\n\t\t\t\tp[i][j] = p[i - 1][j - 1] + p[i - 2][j - 1];\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tp[i][j] = inf;\n\t\t\t}\n\t\t}\n\t}\n\tint s = 0;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tfor (int j = 0; j <= i; j++)\n\t\t{\n\t\t\tif (p[i][j] <= t)\n\t\t\t{\n\t\t\t\ts++;\n\t\t\t}\n\t\t}\n\t}\n\n\tcout << s;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "92b6727ecc027797588b962014075709", "src_uid": "b2b49b7f6e3279d435766085958fb69d", "difficulty": 1500.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\ntypedef long long ll;\nconst int maxn=5e7+10;\nconst int maxi=1e3+10;\nconst ll inf=1e18;\nll num,a[25],b[25],d[maxn],c[maxn],vis[25],n,sum;\nvoid dfs(int st)\n{\n if(st>n)\n return ;\n ll i,key,k,j;\n for(i=num+1;i<=num*2;i++)\n c[i]=c[i-num]+a[st];\n c[i]=a[st];\n for(i=1;i<=n;i++)\n {\n if(vis[i]||i==st)\n continue;\n key=0;\n for(j=num+1;j<=num*2;j++)\n {\n d[j]=d[j-num]+a[i];\n if(d[j]==c[j]&&c[j]!=sum)\n {\n key=1;\n break;\n }\n }\n if(!key)\n {\n d[j]=a[i];\n k=i;\n break;\n }\n }\n b[st]=a[i];\n vis[i]=1;\n num=num*2+1;\n dfs(st+1);\n}\nint main()\n{\n ll i;\n while(scanf(\"%lld\",&n)!=EOF)\n {\n sum=0;\n for(i=1;i<=n;i++)\n {\n scanf(\"%lld\",&a[i]);\n sum+=a[i];\n }\n if(n==1)\n {\n printf(\"%lld\\n\",a[1]);\n continue;\n }\n num=0;\n memset(vis,0,sizeof(vis));\n dfs(1);\n for(i=1;i<=n;i++)\n {\n printf(\"%lld\",b[i]);\n if(i!=n)\n printf(\" \");\n else\n printf(\"\\n\");\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9c32b67cf967ad3ed40e03a9f7a77357", "src_uid": "e314642ca1f82be8f223e2eba00b5531", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\ntypedef long int ll;\nconst int maxn=5e7+10;\nconst int maxi=1e3+10;\nll num,a[25],b[25],d[maxn],c[maxn],vis[25],n,sum;\nvoid dfs(int st)\n{\n if(st>n)\n return ;\n ll i,key,k,j;\n for(i=num+1;i<=num*2;i++)\n c[i]=c[i-num]+a[st];\n c[i]=a[st];\n for(i=1;i<=n;i++)\n {\n if(vis[i]||i==st)\n continue;\n key=0;\n for(j=num+1;j<=num*2;j++)\n {\n d[j]=d[j-num]+a[i];\n if(d[j]==c[j]&&c[j]!=sum)\n {\n key=1;\n break;\n }\n }\n if(!key)\n {\n d[j]=a[i];\n k=i;\n break;\n }\n }\n b[st]=a[i];\n vis[i]=1;\n num=num*2+1;\n dfs(st+1);\n}\nint main()\n{\n ll i;\n while(scanf(\"%lld\",&n)!=EOF)\n {\n sum=0;\n for(i=1;i<=n;i++)\n {\n scanf(\"%lld\",&a[i]);\n sum+=a[i];\n }\n if(n==1)\n {\n printf(\"%lld\\n\",a[1]);\n continue;\n }\n num=0;\n memset(vis,0,sizeof(vis));\n dfs(1);\n for(i=1;i<=n;i++)\n {\n printf(\"%lld\",b[i]);\n if(i!=n)\n printf(\" \");\n else\n printf(\"\\n\");\n }\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "401ea026d988b59bed2fa50446ad5987", "src_uid": "e314642ca1f82be8f223e2eba00b5531", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n int a[100000009];\n int b[100000009];\n int c[100000009];\n\n main(){\n ios::sync_with_stdio(false);\n int n;\n cin >> n;\n\n for(int i = 0 ; i < n;i++){\n cin >> a[i],b[i] = a[i];\n }\n sort(b,b+n);\n for(int i = 0 ; i < n;i++){\n c[b[i]] = b[(i+1)%n];\n }\n\n\n\n for(int i = 0 ; i < n;i++)\n cout << c[a[i]]<<\" \";\n\n }\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c3497614026810926568bd9787c10e43", "src_uid": "e314642ca1f82be8f223e2eba00b5531", "difficulty": 2000.0} {"lang": "GNU C++14", "source_code": "#include \n\nusing namespace std;\n\n#define ll long long\n#define ull unsigned long long\n#define vll vector\n#define pii pair\n#define vii vector\n#define vs vector\n#define vb vector\n#define vi vector\n#define vd vector\n#define vvi vector< vector >\n#define vvii vector< vector< pii > >\n#define ld long double\n#define mapii map\n#define mapsi map\n#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)\n#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)\n#define INF LLONG_MAX\n#define all(v) ((v).begin()), ((v).end())\n#define sz(v) ((int)((v).size()))\n#define pie acos(-1)\n#define mod(n,m) ((n % m + m) % m)\n#define eps (1e-8)\n#define reset(n, m) memset(n, m, sizeof n)\n#define endl '\\n'\n#define output freopen(\"output.txt\", \"w\", stdout)\n#define mp(x, y, z) {{x, y}, z}\n\nint n, memo[23][(1<<23)];\nvi vec;\nvi sol;\nvi temp;\nll s[25];\n\nint solve(int idx, int mask, ll sum = 0)\n{\n\tif (memo[mask][idx] != -1)\n\t\treturn memo[mask][idx];\n\tif (idx == n)\n\t{\n\t\tbool flag = false;\n\t\trep(i, 0, n)\n\t\t{\n\t\t\tif (temp[i] != vec[i])\n\t\t\t{\n\t\t\t\tflag = true;\n\t\t\t\tsol = temp;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn flag;\n\t}\n\tif (idx && sum == s[idx-1])\n\t\treturn 0;\n\n\tint ret = 0;\n\n\trep(i, 0, n)\n\t{\n\t\tif (mask & (1<> n;\n\tvec.resize(n);\n\trep(i, 0, n)\n\t{\n\t\tcin >> vec[i];\n\t\ts[i] = vec[i];\n\t\tif (i)\n\t\t\ts[i] += s[i-1];\n\t}\n\ts[n] = s[n-1];\n\n\tint mn = solve(0, 0);\n\tif (mn)\n\t\trep(i, 0, n)\n\t\t\tcout << sol[i] << \" \";\n\telse cout << -1;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ea58fcfe8a4e24ad393eef3d5a7decee", "src_uid": "e314642ca1f82be8f223e2eba00b5531", "difficulty": 2000.0} {"lang": "GNU C++", "source_code": "#include\n#include\nint main()\n{\n int t,m,n,i;\n char color[7]={'R','O','Y','G','B','I','V'};\n scanf(\"%d\",&n);\n t=n/7;\n m=n%7;\n if(m>=4 || m==0){\n for(i=0;i\n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main()\n{\n\tlong n,i,j=7/2+1;\n\tstring s=\"ROYGBIV\";\n\n\tfreopen(\"input.txt\",\"r\",stdin);\n\tfreopen(\"output.txt\",\"w\",stdout);\n\n\tcin>>n;\n\n\tfor(i=0;i\n#include \n#include \n#include \nusing namespace std;\n\nint main()\n{\n int n;\n string x (\"ROYGBIV\");\n string egg;\n egg = x;\n cin >> n;\n if (n == 7)\n cout << x;\n else\n {\n while (n > 13)\n egg.append(x);\n if (n <= 11)\n egg.append(x.substr(3, n - 7));\n else\n egg.append(x.substr(3, 4));\n n -= 4;\n if (n > 7)\n egg.append(x.substr(2, n - 7));\n cout << egg;\n }\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "24a0c28ac3d5e2fe853736eaa32e3e5b", "src_uid": "dc3817c71b1fa5606f316e5e94732296", "difficulty": 1200.0} {"lang": "MS C++", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\ntypedef long long LL;\n#define mems(arr, val) memset(arr, val, sizeof(arr));\n#define iterat(A) A.begin(), A.end()\n#define forn(from, to) for(int i = from; i < to; ++i)\n#define INF 2000000000\nvector sum;\nvector a;\nint rec(string &m, int pos)\n{\n\tif (pos < 0) return 0;\n\tif (m[pos] == '0') return rec(m, pos - 1);\n\telse\n\t{\n\t\treturn max(a[pos] + rec(m, pos - 1), sum[pos]);\n\t}\n}\n\nint main()\n{\n\t//freopen(\"input.txt\", \"r\", stdin);freopen(\"output.txt\", \"w\", stdout);\n\tint n;\n\tstring colors = \"ROYGBIV\";\n\tfor (int i = 7; i < n; ++i)\n\t{\n\t\tcolors += colors[i - 4];\n\t}\n\tcout<\n#include \n#include \n#include \nusing namespace std;\n \n\nint sum ( long long x ) {\n int z = 0;\n while ( x > 0 ) {\n z += x%10;\n x /= 10;\n }\n return z;\n}\nlong long power(long long i,long long a){\n\n long long x=1;\n\n for(int j=1;j<=a;j++){\n x=x*i;\n }\n\n return x;\n}\n\nint main () {\n\n long long a, b, c;\n cin >> a >> b >> c;\n\n long long x;\n int counter=0;\n\n vector v;\n\n for ( int i = 1; i <= 81; i++ ) {\n x=b*power(i,a)+c;\n\n if(i==sum(x)&& x< 1000000000 && x>0){\n counter++;\n v.push_back(x);\n }\n }\n\n \n cout << counter << endl;\n\n sort(v.begin(), v.end());\n\n \n for ( int i = 0; i < counter-1; i++ ) {\n cout << v[i] << \" \";\n }\n cout<< v[counter-1];\n \n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "92bbf51e24d48916e526806af660bf2b", "src_uid": "e477185b94f93006d7ae84c8f0817009", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include\n#include\nint sumcalc(int n)\n{\n\tint sum=0;;\n\twhile(n!=0)\n\t{\n\t\tsum+=n%10;\n\t\tn=n/10;\n\t}\n\treturn sum;\n}\nint powerof(int base,int exp)\n{\n\tint result=1;\n\tfor(int i=1;i<=exp;i++)\n\t{\n\t\tresult*=base;\n\t}\n\treturn result;\n}\nint main()\n{\n\tint a,b,c;\n\tint k,sum2=0;\n\tint y;\n\tscanf(\"%d %d %d\",&a,&b,&c);\n\tint s=1;\n\tint count=0;\n\tint ak[10]={0};\n\tint i=0;\n\twhile(s<=81)\n\t{\n\t\ty=powerof(s,a);\n\t\tk=b*y+c;\n\t\tsum2=sumcalc(k);\n\t\tif(sum2==s)\n\t\t{\n\t\t\tcount++;\n\t\t\tak[count-1]=k;\n\t\t}\n\t\ts++;\n\t}\n\tprintf(\"%d\\n\",count);\n\tfor(i=0;i\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#define _USE_MATH_DEFINES\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#ifndef ONLINE_JUDGE\n\t#include \n\t#define ini()\tfreopen(\"input.txt\", \"rt\", stdin); \\\n\t\t\t\t\tios::sync_with_stdio(false); \\\n\t\t\t\t\tcin.tie(NULL)\n\t\t\t\t\t\n\t#define ret()\tgetch(); \\\n\t\t\t\t\treturn 0\n#else\n\t#define ini()\tios::sync_with_stdio(false); \\\n\t\t\t\t\tcin.tie(NULL)\n\t#define ret()\treturn 0\n#endif\n\n#define For(i, n)\t\tfor( int (i) = 0; (i) < (n); ++(i) )\n#define Forn(i, a, b)\tfor( int (i) = (a); (i) < (b); ++(i) )\n#define SET(t, v)\t\tmemset((t), (v), sizeof(t))\n\nusing namespace::std;\n\n#pragma comment(linker, \"/STACK:200000000\")\n\n// signed int\t\t\t\t\t// -2e9 to 2e9 // (-2147483648) - (2147483647) // %d\ntypedef unsigned int\t\tuint;\t// 0 to 4e9 // (0) - (4294967295) // %u\ntypedef signed long long\tint64;\t// -9e18 to 9e18 // (-9223372036854775808) - (9223372036854775807) // %I64d\ntypedef unsigned long long\tuint64;\t// 0 to 18e18 // (0) - (18446744073709551615) // %I64u\ntypedef vector\t\t\tVI;\ntypedef pair\t\tPII;\nconst double EPS(1E-9);\n\nint sum(int64 &n);\n\nint out[100], n;\nint64 ans;\nint a, b, c;\n\nint main()\n{\n\tini();\n\t\n\twhile(cin >> a >> b >> c)\n\t{\n\t\tn = 0;\n\t\tForn(i, 1, 82)\n\t\t{\n\t\t\tans = 1;\n\n\t\t\tFor(j, a)\n\t\t\t\tans *= i;\n\n\t\t\tans = ans * b + c;\n\t\t\tif (sum(ans) == i)\n\t\t\t\tout[n++] = ans;\n\t\t}\n\n\t\tcout << n << \" \";\n\t\tFor(i, n)\n\t\t\tcout << out[i] << \" \";\n\t\t\n\t\t#ifndef ONLINE_JUDGE\n\t\t\tcout << endl;\n\t\t#endif\n\t}\n\n\tret();\n}\n\nint sum(int64 &n)\n{\n\tint it = 1;\n\tint out = 0;\n\twhile(n / it)\n\t{\n\t\tout += (n % (it * 10)) / it;\n\t\tit *= 10;\n\t}\n\treturn out;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "80c6a70fcefe2d777a190df3c670613d", "src_uid": "e477185b94f93006d7ae84c8f0817009", "difficulty": 1500.0} {"lang": "GNU C++", "source_code": "#include\n#include\nint sumcalc(int n)\n{\n int sum=0;\n while(n!=0)\n {\n sum+=n%10;\n n=n/10;\n }\n return sum;\n}\nint countof(int n)\n{\n int ct=0;\n while(n!=0)\n {\n ct++;\n n=n/10;\n }\n return ct;\n}\nint main()\n{\n int a,b,c;\n int k,sum2=0;\n int y;\n scanf(\"%d %d %d\",&a,&b,&c);\n int s=1;\n int count=0;\n int ak[10]={0};\n int i;\n while(s<=81)\n {\n y=1;\n for(i=1;i<=a;i++)\n { \n y*=s;\n if((countof(y))>9)\n {\n y=0;\n break;\n }\n }\n if(((countof(y)+countof(b))>9) && y==0)\n {\n break;\n }\n else\n {\n k=b*y+c;\n sum2=sumcalc(k);\n if(sum2==s)\n {\n count++;\n ak[count-1]=k;\n }\n s++;\n }\n }\n printf(\"%d\\n\",count);\n if(count!=0)\n {\n for(i=0;i\n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint score;\nbool flag=false;\nvoid DFS(int time,int a,int b,int a1,int b1,bool isanswer0,bool isanswer1)\n{\n if(flag) return ;\n if(time<=0) return ;\n if(a+bscore) return ;\n if(isanswer1&&b>score) return ;\n if(a+b==score||a==score||b==score){\n printf(\"YES\\n\");\n flag=true;\n return ;\n }\n if(!isanswer0)\n DFS(time-1,a-a1,b,a1,b1,0,isanswer1);\n if(!isanswer1)\n DFS(time-1,a,b-b1,a1,b1,isanswer0,0);\n if(!isanswer0&&!isanswer1)\n DFS(time-1,a-a1,b-b1,a1,b1,0,0);\n}\nint main()\n{\n int t,a,b,a1,b1;\n scanf(\"%d %d %d %d %d %d\",&score,&t,&a,&b,&a1,&b1);\n if(score==0) {\n printf(\"YES\\n\");\n return 0;\n }\n if(t==0) {\n printf(\"NO\\n\");\n return 0;\n }\n DFS(t,a,b,a1,b1,0,0);\n if(!flag) printf(\"NO\\n\");\n // system(\"pause\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4d8fc95a12764521b5c8437cfeedd31c", "src_uid": "f98168cdd72369303b82b5a7ac45c3af", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include\n\nusing namespace std;\n\nint bin_search(int *b,int a,int s, int t){\n\t\n\tint mid = floor((t+s)/2);\n\tif(b[mid]==a) {\n\t\treturn 1;\n\t}\n\telse if(a>b[mid]){ \n\t\treturn bin_search(b,a,s,mid-1);\n\t\t\n\t}\n\telse {\n\t\treturn bin_search(b,a,mid+1,t);\n\t}\n\t\n\treturn 0;\n}\n\n\nint main(){\n\tint x,t,a,b,d_a,d_b,i,k;\n\tcin >> x >> t >> a >> b >> d_a >> d_b;\n\t\n\tint a1[t];\n\tint b1[t];\n\t\n\tfor(i = 0;i 0){\n\t\t k = bin_search(b1,x-a1[i],0,t);\n\t\t}\n\t\tif(k==1){\n\t\t\tcout<< \"YES\";\n\t\t\treturn 0;\n\t\t }\t\n\t}\n\n\tfor(i=0;i 0){\n\t\t k = bin_search(a1,x-b1[i],0,t);\n\t\t}\n\t\n\t\tif(k==1){\n\t\t\tcout<< \"YES\";\n\t\t\treturn 0;\n\t\t}\t\n\t}\n\tcout << \"NO\";\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "83c9c708654601facbd1f0374f8b84a0", "src_uid": "f98168cdd72369303b82b5a7ac45c3af", "difficulty": 1200.0} {"lang": "GNU C++17", "source_code": "#include \nint x,t,a,b,a1,b1,i,k;\nusing namespace std;\nint main()\n{\ncin>>x>>t>>a>>b>>a1>>b1;\nfor(i=1;i<=t;i++) for(k=1;1<=t;i++) if(a-a1*i+b-b1*k==x||a-a1*i==x||b-b1*k==x||x==0)\n{\ncout<<\"YES\";\n}\ncout<<\"NO\";\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "200c23bc04fd1e791ae0e12f533728a6", "src_uid": "f98168cdd72369303b82b5a7ac45c3af", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nint score;\nbool flag=false;\nvoid DFS(int time,int a,int b,int a1,int b1,bool isanswer0,bool isanswer1)\n{\n if(flag) return ;\n if(time<=0) return ;\n if(a+b==score||a==score||b==score){\n printf(\"YES\\n\");\n flag=true;\n return ;\n }\n if(!isanswer0)\n DFS(time-1,a-a1,b,a1,b1,0,isanswer1);\n if(!isanswer1)\n DFS(time-1,a,b-b1,a1,b1,isanswer0,0);\n if(!isanswer0&&!isanswer1)\n DFS(time-1,a-a1,b-b1,a1,b1,0,0);\n \n}\nint main()\n{\n int t,a,b,a1,b1;\n scanf(\"%d %d %d %d %d %d\",&score,&t,&a,&b,&a1,&b1);\n if(score==0) {\n printf(\"YES\\n\");\n return 0;\n }\n if(t==0) {\n printf(\"NO\\n\");\n return 0;\n }\n DFS(t,a,b,a1,b1,0,0);\n if(!flag) printf(\"NO\\n\");\n //system(\"pause\");\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e0a8f02b15cc70defc82152dcf27dd5e", "src_uid": "f98168cdd72369303b82b5a7ac45c3af", "difficulty": 1200.0} {"lang": "GNU C++11", "source_code": "#include\n#define ll long long\nusing namespace std;\nconst int maxn=2001;\nconst int mod=998244353;\nll dp[500][500][500],ans;\nint n,m;\nint main()\n{\n\tscanf(\"%d%d\",&n,&m);\n\tdp[0][0][0]=1;\n\tfor(int i=0;i<=n;++i) {\n\t\tfor(int j=0;j<=m;++j) {\n\t\t\tif(i==0&&j==0) continue ;\n\t\t\tfor(int k=i-j;k<=i;++k) {\n\t\t\t\tif(i) {\n\t\t\t\t\tif(i-j==k) dp[i][j][k]=(dp[i][j][k]+dp[i-1][j][k-1]);//cout<\nusing namespace std;\ntypedef long long ll;\nll MOD=998244853;\nll n, m;\nll choose[4009][4009];\nll dp0[4009][4009];\nll dp[4009][4009];\nint main()\n{\n ios::sync_with_stdio(false);\n cin.tie(0);\n cin>>n>>m;\n for(int i=0; i<=n+m; i++)\n {\n choose[i][0]=1;\n choose[i][i]=1;\n }\n for(int i=0; i<=n+m; i++)\n {\n for(int j=1; jj)\n {\n dp0[i][j]=0;\n continue;\n }\n if(i==0)\n {\n dp0[i][j]=1;\n continue;\n }\n dp0[i][j]=(dp0[i][j-1]+dp0[i-1][j])%MOD;\n }\n }\n for(int i=0; i<=n; i++)\n {\n for(int j=0; j<=m; j++)\n {\n if(i==0)\n {\n dp[i][j]=0;\n continue;\n }\n if(j==0)\n {\n dp[i][j]=i;\n continue;\n }\n dp[i][j]=(choose[i+j-1][j]+dp[i-1][j])%MOD;\n dp[i][j]=(dp[i][j]-choose[i+j-1][j-1]+MOD+dp[i][j-1]+dp0[i][j-1])%MOD;\n }\n }\n cout<\nusing namespace std;\n\n#ifndef LOCAL\n\t\t#define eprintf(...) fprintf(stderr, _VA_ARGS_)\n#else\n\t\t#define eprintf(...) 42\n#endif\n\n#define int LL\ntypedef long long LL;\ntypedef unsigned long long ull;\n#define mp make_pair\n#define fi first\n#define se second\nconst int N = 4010;\nconst LL mod = 998244853;\n\nLL n , m;\nLL f[N][N] , g[N][N] , binom[N][N];\n\ntemplate inline void chkmax(T &x,T y) { x = max(x,y); }\ntemplate inline void chkmin(T &x,T y) { x = min(x,y); }\ntemplate inline void read(T &x) {\n T f = 1; x = 0;\n char c = getchar();\n for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;\n for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';\n x *= f;\n}\n\nsigned main() {\n\t\t\n\t\tread(n); read(m);\n\t\tfor (int i = 0; i <= 2000; ++i) {\n\t\t\t\tfor (int j = 0; j <= 2000; ++j) {\n\t\t\t\t\t\tif (!i) f[i][j] = 1;\n\t\t\t\t\t\telse if (i > j) f[i][j] = 0;\n\t\t\t\t\t\telse f[i][j] = (f[i - 1][j] + f[i][j - 1]) % mod;\n\t\t\t\t} \n\t\t} \n\t\tfor (int i = 0; i <= 4000; ++i) {\n\t\t\t\tbinom[i][0] = binom[i][i] = 1;\n\t\t\t\tfor (int j = 1; j < i; ++j)\n\t\t\t\t\t\tbinom[i][j] = (binom[i - 1][j] + binom[i - 1][j - 1]) % mod;\n\t\t}\n\t\tfor (int i = 0; i <= 2000; ++i) {\n\t\t\t\tfor (int j = 0; j <= 2000; ++j) {\n\t\t\t\t\t if (!i) g[i][j] = 0;\n\t\t\t\t\t\telse if (!j) g[i][j] = i;\n\t\t\t\t\t\telse g[i][j] = (binom[i + j - 1][j] + g[i - 1][j] + g[i][j - 1] - binom[i + j - 1][i] + f[i][j - 1] % mod) % mod;\n\t\t\t\t\t\twhile (g[i][j] < 0) g[i][j] += mod;\n\t\t\t\t\t\tg[i][j] %= mod;\n\t\t\t\t}\n\t\t}\n\t\tprintf(\"%lld\\n\" , (g[n][m] % mod + mod) % mod);\n\t\t\n\t\treturn 0;\n\t\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6b46c060827e4c1a4f103dd2442aaffb", "src_uid": "a2fcad987e9b2bb3e6395654cd4fcfbb", "difficulty": 2300.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \nusing namespace std;\n\ntypedef long long ll;\n\nconst int MAXN = 4005;\nconst int MOD = 998244853;\nconst int INF = 0x3f3f3f3f;\nll C[MAXN >> 1][MAXN >> 1], dp[MAXN][MAXN]/*dp[i][j]\u4ee3\u8868\u6709 i \u4e2a 1 \u548c j \u4e2a -1 \u7b54\u6848\u662f\u591a\u5c11*/\n\t\t\t\t, k[MAXN][MAXN]/*k[i][j]\u4ee3\u8868\u6709 i \u4e2a 1 \u548c j \u4e2a -1 \u6700\u5927\u524d\u7f00\u548c\u662f 0 \u7684\u6709\u591a\u5c11\u79cd*/;\nint n, m;\n\nll read ()\n{\n\tchar c = getchar();\n\tll x = 0, flag = 1;\n\twhile (c < '0' || c > '9')\n\t{\n\t\tif (c == '-')\n\t\t\tflag = -1;\n\t\tc = getchar();\n\t}\n\twhile (c >= '0' && c <= '9')\n\t{\n\t\tx = x * 10 + c - '0';\n\t\tc = getchar();\n\t}\n\treturn x * flag;\n}\n\nint main()\n{\n\tcin >> n >> m;\n\tfor (int i = 1; i <= n + m; ++ i)\n\t{\n\t\tC[i][0] = 1;\n\t\tfor (int j = 1; j <= i; ++ j)\n\t\t\tC[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % MOD;\n\t}\n\tfor (int i = 1; i <= m; ++ i)\n\t\tk[0][i] = 1;\n\tfor (int i = 1; i <= n; ++ i)\n\t\tfor (int j = i; j <= m; ++ j)\n\t\t\tk[i][j] = (k[i - 1][j] + k[i][j - 1]) % MOD;\n\tfor (int i = 1; i <= n; ++ i)\n\t\tdp[i][0] = i;\n\tfor (int i = 1; i <= n; ++ i)\n\t\tfor (int j = 1; j <= m; ++ j)\n\t\t{\n\t\t\tdp[i][j] = (dp[i][j] + dp[i - 1][j] + C[i + j - 1][j]) % MOD;\n\t\t\tdp[i][j] = (dp[i][j] + dp[i][j - 1] - (C[i + j - 1][i] - k[i][j - 1] + MOD) % MOD + MOD) % MOD;\n\t\t}\n //for (int i = 1; i <= n + m; ++ i)\n // for (int j = 0; j <= m; ++ j)\n // printf (\"%lld%c\", C[i][j], (j == m) ? '\\n' : ' ');\n\tcout << dp[n][m] << endl;\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fec12163bf57d80d5a9452d885c17167", "src_uid": "a2fcad987e9b2bb3e6395654cd4fcfbb", "difficulty": 2300.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{int h,m; cin>>h>>m;\nchar c; cin>>h>>c>>m;\nwhile (true)\n{\n m++; h+=(m/60); m%60; h%24;\n if (h%10==m%16 && h%10==m/10) break;\n cout<\n#include \nusing namespace std;\nint main()\n{\n int HH,MM;\n char x;\n cin >> HH >> x >> MM;\n ++HH%=24;\n ++MM%=60;\n for(HH; HH < 24; ++HH){\n for(MM; MM < 60; ++MM){\n if(HH%10 == MM/10 && HH/10 == MM%10){\n printf(\"%02d:%02d\\n\", HH, MM);\n return 0;\n }\n if(MM == 59) MM = 0;\n }\n if(HH == 23) HH = 0;\n }\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "cba7cc96ad711f9023a8e5ad1c7abfb1", "src_uid": "158eae916daa3e0162d4eac0426fa87f", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main()\n{\n char chtime[5];\n int time [4];\n for(int i =0;i<5;i++){\n chtime[i] = getche();\n }\n time[0] = chtime[0] -48;\n time[1] = chtime[1] -48;\n time[2] = chtime[3] -48;\n time[3] = chtime[4] -48;\n while(true){\n if(time[3] < 9) time[3]++;\n else if(time[2] <5){\n time[2]++;\n time[3] = 0;\n }\n else if(time[1] <3){\n time[1]++;\n time[2] = 0;\n }\n else if(time[0] < 2){\n time[0]++;\n time[1] = 0;\n }\n if(time[0]==2&&time[1]==3&&time[2]==5&&time[3]==9){\n time[0]=0;\n time[1]=0;\n time[2]=0;\n time[3]=0;\n }\n for(int i = 0;i<2;i++){\n if(time[0]==time[3] && time[1]==time[2]){\n cout<<\"\\n\"<\nusing namespace std;\nint num[24]={0,10,20,30,40,50,60,-1,-1,-1,1,11,21,31,41,51,-1,-1,-1,-1,2,12,22,32};\nint main()\n{\n int m,n;\n char a,b,c;\n cin>>m>>c>>n;\n if(m==23&&n>32) cout<<\"00:00\";\n else\n {\n if(num[m]==-1)\n {\n while(num[m]==-1)\n m++;\n a=m/10+'0';\n b=m%10+'0';\n cout<\nusing namespace std;\nint main()\n{\n int a, b, aa, bb;\n cin >> a >> b;\n aa = a*10;\n bb = b*10;\n if( abs(a - b) <= 1)\n {\n while (aa + 1 != bb){\n if (aa > bb){\n bb++;\n } else {\n aa++;\n }\n }\n cout << aa << \" \" << bb;\n }\n else \n {\n cout << \"-1\";\n }\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "53f6031ffb006eea3ad46570b7dd8f46", "src_uid": "3eff6f044c028146bea5f0dfd2870d23", "difficulty": 900.0} {"lang": "MS C++ 2017", "source_code": "#include\nusing namespace std;\nint main()\n{\n\tlong long a,b;\n\tcin>>a>>b;\n\tfor (long long i=1; i<1000000001; i++)\n\t{\n\tif (i>0 && i<10)\n\tif (i == a && i+1 == b )\n\t{\n\tcout<=10 && i<100)\n\tif (i/10 == a && (i+1)/10 == b )\n\t{\n\tcout<=100 && i<1000)\n\tif (i/100 == a && (i+1)/100 == b )\n\t{\n\tcout<=1000 && i<10000)\n\tif (i/1000 == a && (i+1)/1000 == b )\n\t{\n\tcout<=10000 && i<100000)\n\tif (i/10000 == a && (i+1)/10000 == b )\n\t{\n\tcout<=100000 && i<1000000)\n\tif (i/100000 == a && (i+1)/100000 == b )\n\t{\n\tcout<=1000000 && i<10000000)\n\tif (i/1000000 == a && (i+1)/1000000 == b )\n\t{\n\tcout<=10000000 && i<100000000)\n\tif (i/10000000 == a && (i+1)/10000000 == b )\n\t{\n\tcout<=100000000 && i<1000000000)\n\tif (i/100000000 == a && (i+1)/100000000 == b )\n\t{\n\tcout<\nusing namespace std;\nint main()\n{\nint d1,d2;\ncin>>d1>>d2;\nint fn(0);\nfor(long long int i=1; i<=100000000; ++i)\n{\nlong long int n=i,n1=i-1,ar(n),ar1(n1);\nvectorvec,vec1;\nwhile(n>0)\n{\nvec.push_back(n%10);\nn/=10;\n}\nwhile(n1>0)\n{\nvec1.push_back(n1%10);\nn1/=10;\n}\nif(vec[vec.size()-1]==d2&&vec1[vec1.size()-1]==d1)\n{\nfn=1;\ncout<\nint main()\n{\n int x,y,a,b,c,d,q,w;\n scanf(\"%d%d\",&x,&y);\n for(a=1;a<1000000000;a++)\n {\n b=a+1;\n q=a,w=b;\n while(q>10)\n {\n q/=10;\n c=q;\n }\n while(w>10)\n {\n w/=10;\n d=w;\n }\n if(x==c&&y==d)\n {\n printf(\"%d %d\",a,b);\n return 0;\n }\n }\n printf(\"-1\");\n}\n//2019-11-12 23:51:15.872", "lang_cluster": "C++", "compilation_error": false, "code_uid": "693e6ccf04dc036c9993f8cbf7703d55", "src_uid": "3eff6f044c028146bea5f0dfd2870d23", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint main(int argc, char *argv[]) {\n int N, total1 = 0, total2 = 0;\n\n scanf(\"%d\", &N);\n vector AAA(N/2, 0);\n\n for (int i = 0; i < N/2; i++) {\n scanf(\"%d\", &AAA[i]);\n total1 += abs(AAA[i]-i*2-1);\n total2 += abs(AAA[i]-i*2-2);\n }\n\n return (total1 < total2) ? total1 : total2;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "015ba7294d5539b8dbfe913d4fe4ab03", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint n, pieces;\n\nint bfs(int * state);\nbool same_color(int * state);\n\nint main() {\n\twhile (cin >> n) {\n\t\tpieces = n / 2;\n\t\tint * s = new int[pieces];\n\t\t// vector v;\n\t\t// v.assign(pieces, int());\n\t\tfor (int i = 0; i < pieces; i++)\n\t\t\tcin >> s[i];\n\t\tint min_step = bfs(s);\n\t\tcout << min_step << endl;\n\t}\n\treturn 0;\n}\n\nint bfs(int * state) {\n\tif (same_color(state))\n\t\treturn 0;\n\tpriority_queue, vector>, greater >> pq;\n\tpq.push(make_pair(0, state));\n\twhile (!pq.empty()) {\n\t\tpair p = pq.top();\n\t\tpq.pop();\n\t\tint* s = p.second;\n\t\tint steps = p.first;\n\t\tfor (int i = 0; i < pieces; i++) {\n\t\t\tint * ns = new int[pieces];\n\t\t\tcopy(s, s + pieces, ns);\n\t\t\tif (s[i] - 1 >= 1 && find(s, s + pieces, s[i] - 1) == s + pieces) {\n\t\t\t\tns[i] = s[i] - 1;\n\t\t\t\tif (same_color(ns))\n\t\t\t\t\treturn steps + 1;\n\t\t\t\tpq.push(make_pair(steps + 1, ns));\n\t\t\t}\n\t\t\tns = new int[pieces];\n\t\t\tcopy(s, s + pieces, ns);\n\t\t\tif (s[i] + 1 <= n && find(s, s + pieces, s[i] + 1) == s + pieces) {\n\t\t\t\tns[i] = s[i] + 1;\n\t\t\t\tif (same_color(ns))\n\t\t\t\t\treturn steps + 1;\n\t\t\t\tpq.push(make_pair(steps + 1, ns));\n\t\t\t}\n\t\t}\n\t\tdelete(s);\n\t}\n}\n\nbool same_color(int * state) {\n\tfor (int i = 1; i < pieces; i++) {\n\t\tif (state[i] % 2 != state[0] % 2)\n\t\t\treturn false;\n\t}\n\treturn true;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "9c8d5115903988c6bd4a100d67cfbd39", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint n, pieces;\n\nint bfs(int * state);\nbool same_color(int * state);\n\nint main() {\n\twhile (cin >> n) {\n\t\tpieces = n / 2;\n\t\tint * s = new int[pieces];\n\t\t// vector v;\n\t\t// v.assign(pieces, int());\n\t\tfor (int i = 0; i < pieces; i++)\n\t\t\tcin >> s[i];\n\t\tint min_step = bfs(s);\n\t\tcout << min_step << endl;\n\t}\n\treturn 0;\n}\n\nint bfs(int * state) {\n\tif (same_color(state))\n\t\treturn 0;\n\tpriority_queue, vector>, greater >> pq;\n\tpq.push(make_pair(0, state));\n\twhile (!pq.empty()) {\n\t\tpair p = pq.top();\n\t\tpq.pop();\n\t\tint* s = p.second;\n\t\tint steps = p.first;\n\t\tfor (int i = 0; i < pieces; i++) {\n\t\t\tint * ns = new int[pieces];\n\t\t\tcopy(s, s + pieces, ns);\n\t\t\tif (s[i] - 1 >= 1 && find(s, s + pieces, s[i] - 1) == s + pieces) {\n\t\t\t\tns[i] = s[i] - 1;\n\t\t\t\tif (same_color(ns)) {\n\t\t\t\t\twhile (!pq.empty()) {\n\t\t\t\t\t\tpair tp = pq.top();\n\t\t\t\t\t\tpq.pop();\n\t\t\t\t\t\tdelete[] tp.second;\n\t\t\t\t\t}\n\t\t\t\t\treturn steps + 1;\n\t\t\t\t}\n\t\t\t\tpq.push(make_pair(steps + 1, ns));\n\t\t\t}\n\t\t\tns = new int[pieces];\n\t\t\tcopy(s, s + pieces, ns);\n\t\t\tif (s[i] + 1 <= n && find(s, s + pieces, s[i] + 1) == s + pieces) {\n\t\t\t\tns[i] = s[i] + 1;\n\t\t\t\tif (same_color(ns)) {\n\t\t\t\t\twhile (!pq.empty()) {\n\t\t\t\t\t\tpair tp = pq.top();\n\t\t\t\t\t\tpq.pop();\n\t\t\t\t\t\tdelete[] tp.second;\n\t\t\t\t\t}\n\t\t\t\t\treturn steps + 1;\n\t\t\t\t}\n\t\t\t\tpq.push(make_pair(steps + 1, ns));\n\t\t\t}\n\t\t}\n\t\tdelete[] s;\n\t}\n}\n\nbool same_color(int * state) {\n\tfor (int i = 1; i < pieces; i++) {\n\t\tif (state[i] % 2 != state[0] % 2)\n\t\t\treturn false;\n\t}\n\treturn true;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8fa8bd45230f1310461d913bcfda3b3b", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\nint n, pieces;\n\nint bfs(int * state);\nbool same_color(int * state);\n\nint main() {\n\twhile (cin >> n) {\n\t\tpieces = n / 2;\n\t\tint * s = new int[pieces];\n\t\t// vector v;\n\t\t// v.assign(pieces, int());\n\t\tfor (int i = 0; i < pieces; i++)\n\t\t\tcin >> s[i];\n\t\tint min_step = bfs(s);\n\t\tcout << min_step << endl;\n\t}\n\treturn 0;\n}\n\nint bfs(int * state) {\n\tif (same_color(state))\n\t\treturn 0;\n\tpriority_queue, vector>, greater >> pq;\n\tpq.push(make_pair(0, state));\n\twhile (!pq.empty()) {\n\t\tpair p = pq.top();\n\t\tpq.pop();\n\t\tint* s = p.second;\n\t\tint steps = p.first;\n\t\tfor (int i = 0; i < pieces; i++) {\n\t\t\tint * ns = new int[pieces];\n\t\t\tcopy(s, s + pieces, ns);\n\t\t\tif (s[i] - 1 >= 1 && find(s, s + pieces, s[i] - 1) == s + pieces) {\n\t\t\t\tns[i] = s[i] - 1;\n\t\t\t\tif (same_color(ns)) {\n\t\t\t\t\twhile (!pq.empty()) {\n\t\t\t\t\t\tpair tp = pq.top();\n\t\t\t\t\t\tpq.pop();\n\t\t\t\t\t\tdelete(tp.second);\n\t\t\t\t\t}\n\t\t\t\t\treturn steps + 1;\n\t\t\t\t}\n\t\t\t\tpq.push(make_pair(steps + 1, ns));\n\t\t\t}\n\t\t\tns = new int[pieces];\n\t\t\tcopy(s, s + pieces, ns);\n\t\t\tif (s[i] + 1 <= n && find(s, s + pieces, s[i] + 1) == s + pieces) {\n\t\t\t\tns[i] = s[i] + 1;\n\t\t\t\tif (same_color(ns)) {\n\t\t\t\t\twhile (!pq.empty()) {\n\t\t\t\t\t\tpair tp = pq.top();\n\t\t\t\t\t\tpq.pop();\n\t\t\t\t\t\tdelete(tp.second);\n\t\t\t\t\t}\n\t\t\t\t\treturn steps + 1;\n\t\t\t\t}\n\t\t\t\tpq.push(make_pair(steps + 1, ns));\n\t\t\t}\n\t\t}\n\t\tdelete(s);\n\t}\n}\n\nbool same_color(int * state) {\n\tfor (int i = 1; i < pieces; i++) {\n\t\tif (state[i] % 2 != state[0] % 2)\n\t\t\treturn false;\n\t}\n\treturn true;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "81a996afa50f9ea3c304c1cc8acf3a28", "src_uid": "0efe9afd8e6be9e00f7949be93f0ca1a", "difficulty": 1100.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n\nusing namespace std;\n\nint main()\n{\n\tint n;\n\tint count(0);\n\tint a(0);\n\tint x[100];\n\tint tmp[101];\n\tvectors[101];\n\tfor (int i(0); i < 101; i++){ tmp[i] = 0; }\n\tcin >> n;\n\tfor (int i(0); i < n; i++)\n\t{\n\t\tcin >> x[i];\n\t\ttmp[x[i]]++;\n\t}\n\n\n\n\tfor (int i(0); i < n; i++)\n\t{\n\t\tif (tmp[x[i]] <= count)\n\t\t{\n\t\t\tfor (int j(0); j < tmp[x[i]]; j++)\n\t\t\t{\n\t\t\t\ts[j].push_back(x[i]);\n\t\t\t}\n\t\t\ta += tmp[x[i]];\n\t\t}\n\n\t\tif (tmp[x[i]] > count)\n\t\t{\n\t\t\tif (count * x[i] - a >= tmp[x[i]]) //count * x[i] - a \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\n\t\t\t{\n\t\t\t\tint q(0);\n\t\t\t\tfor (int j(0); j < tmp[x[i]]; j++)\n\t\t\t\t{\n\t\t\t\t\tif (s[q].size() < x[i])\n\t\t\t\t\t{\n\t\t\t\t\t\ts[q].push_back(x[i]);\n\t\t\t\t\t}\n\t\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tq++;\n\t\t\t\t\t\tj--;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tint w = tmp[x[i]] - (count * x[i] - a); // \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd \ufffd\ufffd \ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\ufffd\n\t\t\t\tfor (int j(0); j < count; j++)\n\t\t\t\t\twhile (s[j].size() != x[i]){ s[j].push_back(x[i]); }\n\t\t\t\twhile (true)\n\t\t\t\t{\n\t\t\t\t\tcount++;\n\t\t\t\t\tfor (int j(0); j <= x[i]; j++)\n\t\t\t\t\t{\n\t\t\t\t\t\ts[count].push_back(x[i]);\n\t\t\t\t\t\tw--;\n\t\t\t\t\t\tif (w == 0){ break; }\n\t\t\t\t\t}\n\t\t\t\t\tif (w == 0){ break; }\n\t\t\t\t}\n\t\t\t}\n\t\t\ta += tmp[x[i]];\n\t\t}\n\t}\n\n\n\tcout << count;\n\n\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "f7692959835322c437cb17668ad22533", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#define pb push_back\nusing namespace std;\nint main()\n{\n freopen(\"input.txt\",\"r\",stdin);\n int n,tmp;\n cin>>n;\n vector a;\n for(int i=0;i>tmp;\n a.pb(tmp);\n }\n sort(a.begin(),a.end(),greater());\n bool taken[102]={0};\n int piles=0;\n int took,ind,space;\n while(1)\n {\n piles++;\n took=*a.begin();\n space=took;\n a.erase(a.begin());\n if(a.empty())break;\n if(space==0)continue;\n sort(a.begin(),a.end());\n while(1)\n {\n int d = lower_bound(a.begin(),a.end(),took) - a.begin();\n if(d==a.size())d--;\n //cout<());\n }\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\ntypedef vector vi;\ntypedef pair ii;\ntypedef vector vii;\ntypedef set si;\ntypedef map msi;\n\n//#define for(i, a, b) \\\n// for(int i = int(a); i <= int(b); i++)\n//#define Rvi(c, it) \\\n// for(vi::iterator it = (c).begin(); it != (c).end(); it++)\n//#define Rvii(c, it) \\\n// for(vii::iterator it = (c).begin(); it != (c).end(); it++)\n//#define Rmsi(c, it) \\\n// for(msi::iterator it = (c).begin(); it != (c).end(); it++)\n\nint main() {\n int n;\n scanf(\"%d\", &n);\n\n vector V;\n int n0 = 0, aux;\n for(int i=0; i= s) {\n\t s += 1;\n\t B[i] = true;\n\t p++;\n\t}\n }\n }\n }\n\n if(n0 > c)\n printf(\"%d\\n\", n0);\n else\n printf(\"%d\\n\", c);\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b4330c4eb1aabe7c99a356d886a44166", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#include\n\nint compare (const void * a, const void * b){\n return ( *(int*)a - *(int*)b ); // sort Min to Max\n}\n\n\nint main(){\n int n,count,mem;\n scanf(\"%d\",&n);\n int arr[n];\n for(int i=0;i=0;i--){\n if(mem==-1 && ch[i]==0){\n mem = arr[i];\n ch[i] = 1; \n }else if(mem>0){\n if(ch[i]==0 && mem>=arr[i]){\n mem = arr[i];\n ch[i] = 1; \n } \n } \n }\n ans++;\n }\n printf(\"%d\\n\",ans);\n getch();\n return 0; \n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "7edba36744d91f2329392a9b64a5f194", "src_uid": "7c710ae68f27f140e7e03564492f7214", "difficulty": 1400.0} {"lang": "GNU C++14", "source_code": "#include\n#define FOR(i,a,b) for(ll i = a; i <= b; ++i)\n#define F first\n#define S second\n#define pb push_back\nusing namespace std;\ntypedef long long ll;\nconst ll INF = 1e9;\nconst ll MAXN = 2*1e5+9;\nll n,a[MAXN],ans,col;\nstring s;\nvector v;\nmain ()\n{\n ios_base::sync_with_stdio(false);\n cin >> n;\n cin >> s;\n FOR(i,0,s.size()-1)\n {\n if(s[i] == 'W')\n {\n if(ans)\n {\n v.pb(ans);\n ans = 0;\n }\n }\n else ans++;\n }\n if(ans)\n {\n v.push_back(ans);\n }\n cout << v.size() << \"\\n\";\n FOR(i,0,v.size()-1)\n {\n cout << v[i] << \" \";\n }\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c24060f3b263676f24d397b070fce9fb", "src_uid": "e4b3a2707ba080b93a152f4e6e983973", "difficulty": 800.0} {"lang": "MS C++", "source_code": "#include < Fstream >\n#include < vector >\n#include < string >\n#include < queue >\nusing namespace std;\n\nifstream cin(\"input.txt\");\nofstream cout(\"output.txt\");\n\nint main(){\n\tint n,answer=0, U;\n\tcin >> n;\n\tvector m;\n\tvector om;\n\tfor (int i=0; i> c;\n\t\tif(c =='B'){\n\t\t\tom.push_back(1);\n\t\t\tanswer++;\n\t\t\tU=1;\n\t\t}\n\t\telse if(U=1){\n\t\t\tom.push_back(0);\n\t\t\tm.push_back(answer);\n\t\t\tanswer=0;\n\t\t}\n\t}\n\tif(om[n-2]==0 && om[n-1]==1){\n\t\tm.push_back(1);\n\t}\n\tif(m.size()==0 && answer!=0){\n\t\tm.push_back(answer);\n\t}\n\tif(m.size()==answer){\n\t\tfor(int i=0; i\n#include \n#include \nusing namespace std;\n\nint main() \n{\n int n;\n cin>>n;\n getchar();\n char c=getchar();\n int cnt=0;\n vector g;\n int temp=0;\n while (c!=EOF)\n {\n if (c=='W')\n {\n c=getchar();\n continue;\n }\n while (c!=EOF && c=='B')\n {\n temp++;\n c=getchar();\n }\n \n g.push_back(temp);\n cnt++;\n temp=0;\n }\n \n cout<\n#include\n#include \n\nint main()\n{\n int i,j=0,f=0,co=0,ar2[105],t;\n char ar1[1005];\n\n scanf(\"%d\",&t);\n\n\n for(i=0; i\n#include \nusing namespace std;\n\nint main(){\n\tint n;\t\t\n\tvector c(n);\n\tcin>>n;\n\tbool first_1=true;\n\tint a;\n\tint count_zeros=0;\n\tfor(int i=0;i>a;\n\t\tif(a==1){\n\t\t\tif(first_1){\n\t\t\t\tfirst_1=false;\n\t\t\t\tc[i]=1;\n\t\t\t} else {\n\t\t\t\tc[i]=(count_zeros+1)*c[i-1];\n\t\t\t}\n\t\t\tcount_zeros=0;\n\t\t} else {\n\t\t\tcount_zeros++;\n\t\t\tif(first_1) c[i]=0;\n\t\t\telse c[i]=c[i-1];\n\t\t}\n\t}\n\tcout<\n#include \nusing namespace std;\ntypedef long long ll;\nint main(){\n\tint n;\n\tint a[105];\n\tcin>>n;\n\tint dem=0;\n\tint dem2=0;\n\tint first=0;\n\tfor(int i=0;i>a[i];\n\t\tif(a[i]==1&&first==0){\n\t\t\tdem=1;\n\t\t\tfirst=1;\n\t\t}\n\telse{\n\t\tif(a[i]==1){\n\t\tif(dem2!=0)\t\n\t\t\tdem=2*(dem+dem2-1);\n\t\t\t\t\tdem2=0;\n\t\t}\n\t\telse dem2++;\n\t}\n\t}\n\tcout<\n#include \nusing namespace std;\ntypedef long long ll;\nint main(){\n\tint n;\n\tint a[105];\n\tcin>>n;\n\tll dem=0;\n\tll dem2=0;\n\tint first=0;\n\tint second=0;\n\tfor(int i=0;i>a[i];\n\t\tif(a[i]==1&&first==0){\n\t\t\tdem=1;\n\t\t\tfirst=1;\n\t\t\tsecond=1;\n\t\t\tdem2=0;\n\t\t}\n\t\telse{\n\t\t\tif(a[i]==1){\n\t\t\t\tsecond++;\n\t\t\tif(dem2!=0)\t\n\t\t\tdem=(dem2+1)*dem;\n\t\t\t\t\tdem2=0;\n\t\t\t}\n\t\telse if(a[i]==0) dem2++;\n\t\t}\n\t}\n\tcout<\n#include \nusing namespace std;\ntypedef long long ll;\nint main(){\n\tint n;\n\tint a[105];\n\tcin>>n;\n\tint dem=0;\n\tint dem2=0;\n\tint first=0;\n\tint second=0;\n\tfor(int i=0;i>a[i];\n\t\tif(a[i]==1&&first==0){\n\t\t\tdem=1;\n\t\t\tfirst=1;\n\t\t\tsecond=1;\n\t\t\tdem2=0;\n\t\t}\n\t\telse{\n\t\t\tif(a[i]==1){\n\t\t\t\tsecond++;\n\t\t\tif(dem2!=0)\t\n\t\t\tdem=(dem2+1)*dem;\n\t\t\t\t\tdem2=0;\n\t\t\t}\n\t\telse dem2++;\n\t\t}\n\t}\n\tcout<\n#include \n#include \nusing namespace std;\nint x1,y1;\nchar S[1000];\nint main()\n{\n\tscanf(\"%d%d%s\",&x1,&y1,S);\n\tif(x1==0&&y1==0) {\n\t\tputs(\"Yes\");\n\t\treturn 0;\n\t}\n\tint len=strlen(S);\n\tint a=0,b=0;\n\tfor(int i=0;i0&&ty%b==0) {\n\t\t\t\tputs(\"Yes\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\tif(b==0&&ty==0) {\n\t\t\tif(p1>0&&ty%a==0) {\n\t\t\t\tputs(\"Yes\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\tif(a!=0&&b!=0) {\n\t\t\tif(p1>0&&p1==p2) {\n\t\t\t\tputs(\"Yes\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\tif(S[i]=='U') ty--;\n\t\telse if(S[i]=='D') ty++;\n\t\telse if(S[i]=='L') tx++;\n\t\telse if(S[i]=='R') tx--;\n\t}\n\t\tint p1,p2;\n\t\tif(a==0) p1=0;\n\t\telse p1=tx/a;\n\t\tif(b==0) p2=0;\n\t\telse p2=ty/b;\n\t\tif(a==0&&tx==0) {\n\t\t\tif(p2>0&&ty%b==0) {\n\t\t\t\tputs(\"Yes\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\tif(b==0&&ty==0) {\n\t\t\tif(p1>0&&ty%a==0) {\n\t\t\t\tputs(\"Yes\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\tif(a!=0&&b!=0) {\n\t\t\tif(p1>0&&p1==p2) {\n\t\t\t\tputs(\"Yes\");\n\t\t\t\treturn 0;\n\t\t\t}\n\t\t}\n\t\tputs(\"No\");\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "48181fac2473285f323ab5a27289d628", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \n#include \nusing namespace std;\nint a,b;\nchar str[105];\nint t1[105],t2[105];\nint main()\n{\n while(~scanf(\"%d%d\",&a,&b))\n {\n scanf(\"%s\",str);\n bool judge=0;\n int x=0,y=0;\n int count=0;\n for(int i=0;i\n#include\n#include\n#include\n#include\n#include\nusing namespace std;\n#define ll long long\nint a[111]={0},b[111]={0};\n char s[111];\nint main()\n{\n int xx,yy,x,y,o;\n scanf(\"%d%d\",&x,&y);\n scanf(\"%s\",s);\n int len= strlen(s);\n for (int i=0;i\nusing namespace std;\n\n#define pb push_back\n#define eb emplace_back\n#define mk make_pair\n#define fi first\n#define se second\n#define mset(a, b) memset(a, b, sizeof(a))\n#define DBG(x) cout << \"[\" << #x << \"]: \" << x << endl\nusing ll = long long;\nusing pii = pair;\nmt19937 rng(chrono::steady_clock::now().time_since_epoch().count());\n#ifdef _WIN32\n#define getchar_unlocked _getchar_nolock\n#endif\n\ntemplate Ty randint(Ty a, Ty b) { return uniform_int_distribution(a, b)(rng); }\ntemplate inline void rd(num& x) {\n\tchar c, neg = 0; while(isspace(c = getchar_unlocked()));\n\tif(!isdigit(c)) neg = (c == '-'), x = 0;\n\telse x = c - '0';\n\twhile(isdigit(c = getchar_unlocked())) x = (x << 3) + (x << 1) + c - '0';\n\tx = neg ? -x : x; }\ntemplate inline void rd(Args&... args) { (rd(args), ...); }\n\nconst int MAXN = 2e5 + 5, INF = 0x3f3f3f3f;\n\nint32_t main() {\n\tios::sync_with_stdio(false); cin.tie(NULL);\n\tll n, m; cin >> n >> m;\n\tstring s; cin >> s;\n\n\tvector dif(s.size());\n\tpii current = {0, 0};\n\n\tauto YES = []() {\n\t\tputs(\"Yes\");\n\t\texit(0);\n\t};\n\tauto NO = []() {\n\t\tputs(\"No\");\n\t\texit(0);\n\t};\n\n\tfor (int i = 0; i < (int) s.size(); i++) {\n\t\tif (dif[i] == pii{n, m}) YES();\n\n\t\tcurrent.fi += (s[i] == 'R') - (s[i] == 'L');\n\t\tcurrent.se += (s[i] == 'U') - (s[i] == 'D');\n\t\tdif[i] = current;\n\n\t\tif (dif[i] == pii{n, m}) YES();\n\t}\n\n\tauto sign = [](ll x) {\n\t\treturn x > 0 ? 1 : x < 0 ? -1 : 0;\n\t};\n\n\t// qts vezes vou fazer isso?\n\tpii pos = {0, 0};\n\n\tvector every;\n\tevery.push_back(pos);\n\n\tint qtt = 1e4;\n\tfor (int i = 0; i < 1e7; i++) {\n\t\tpii nxt = pos;\n\t\tnxt.fi += current.fi * qtt;\n\t\tnxt.se += current.se * qtt;\n\n\t\tif (n < 0 && nxt.fi < n) break;\n\t\tif (m < 0 && nxt.se < m) break;\n\t\tif (n > 0 && nxt.fi > n) break;\n\t\tif (m > 0 && nxt.se > m) break;\n\n\t\tevery.push_back(nxt);\n\t\tpos = nxt;\n\t}\n\n\tint N = s.size();\n\n\tfor (int xx = 0; xx < 10; xx++) {\n\t\tif (every.size() <= xx) break;\n\t\tpii pos = every[every.size() - xx - 1];\n\t\tfor (int it = 0; it < 1e5; it++) {\n\t\t\tfor (int i = 0; i < N; i++) {\n\t\t\t\tif (pos.fi == n && pos.se == m) YES();\n\n\t\t\t\tll X = pos.fi + dif[i].fi;\n\t\t\t\tll Y = pos.se + dif[i].se;\n\n\t\t\t\tif (mk(X, Y) == mk(n, m)) YES();\n\t\t\t}\n\t\t\tpos.fi += dif[N-1].fi;\n\t\t\tpos.se += dif[N-1].se;\n\t\t}\n\t}\n\n\tNO();\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4014afb258807e519891309834dc03ec", "src_uid": "5d6212e28c7942e9ff4d096938b782bf", "difficulty": 1700.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define f first\n#define s second\n#define pb push_back\n#define mp make_pair\n#define forit(v,it) for(typeof(v.begin()) it = v.begin(); it != v.end(); ++it)\ntypedef long long ll;\ntypedef pair pii;\ntypedef vector vi;\n\nint n;\ndouble R,r;\n\nint main () {\n\t#ifdef LOCAL\n\tfreopen(\"input.txt\",\"r\",stdin);\n\tfreopen(\"output.txt\",\"w\",stdout);\n\t#endif\n\tscanf(\"%d%lf%lf\",&n,&R,&r);\n\tint cnt = 0;\n/*\tif(R < r || (n > 1 && R == r)) {\n\t\tputs(\"NO\");\n\t\treturn 0;\n\t}\n\tif(n == 1) {\n\t\tputs(\"YES\");\n\t\treturn 0;\n\t}*/\n\twhile(R >= r) {\n\t\tif(R == r) {\n\t\t\tcnt++;\n\t\t\tbreak;\n\t\t}\n\t\tlong double x = acos(1 - (long double)(2*r*r)/((R - r)*(R - r)));\n\t\tcnt += (int)((long double)2*M_PI/x + 1e-9);\n\t\tR -= 2*r;\n\t}\n\tif(n == 1 && R == r) assert(false);\n\tif(cnt < n) puts(\"NO\");\n\telse puts(\"YES\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "b828d6de0b081cbc6ef59a66857c0262", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6", "difficulty": 1700.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#define PI 3.14159265359\nusing namespace std;\nint main()\n{\nint iNumber;\nint iR;\ndouble ir;\nint iTotal;\nint iSingle;\nint i;\ncin>>iNumber>>iR>>ir;\nif(ir>iR)\n cout<<\"NO\"<1)\n cout<<\"NO\"<=ir/(iR-ir))\n {\n iSingle = i;\n break;\n }\n }\n //cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\n#define f first\n#define s second\n#define pb push_back\n#define mp make_pair\n#define forit(v,it) for(typeof(v.begin()) it = v.begin(); it != v.end(); ++it)\ntypedef long long ll;\ntypedef pair pii;\ntypedef vector vi;\n\nint n;\ndouble R,r;\n\nint main () {\n\t#ifdef LOCAL\n\tfreopen(\"input.txt\",\"r\",stdin);\n\tfreopen(\"output.txt\",\"w\",stdout);\n\t#endif\n\tscanf(\"%d%lf%lf\",&n,&R,&r);\n\tint cnt = 0;\n/*\tif(R < r || (n > 1 && R == r)) {\n\t\tputs(\"NO\");\n\t\treturn 0;\n\t}\n\tif(n == 1) {\n\t\tputs(\"YES\");\n\t\treturn 0;\n\t}*/\n\tif(n == 1 && R == r) assert(false);\n\n\twhile(R >= r) {\n\t\tif(R == r) {\n\t\t\tcnt++;\n\t\t\tbreak;\n\t\t}\n\t\tlong double x = acos(1 - (long double)(2*r*r)/((R - r)*(R - r)));\n\t\tcnt += (int)((long double)2*M_PI/x + 1e-9);\n\t\tR -= 2*r;\n\t}\n\tif(cnt < n) puts(\"NO\");\n\telse puts(\"YES\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "940067aa759a0593818e9d10015157eb", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6", "difficulty": 1700.0} {"lang": "GNU C++14", "source_code": "#pragma comment(linker, \"/STACK:1000000000\")\n#define _CRT_SECURE_NO_WARNINGS\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define mp make_pair\n#define pii pair \n#define ll long long\n#define pll pair \n#define ld double\n\nusing namespace std;\n\nconst ld pi = acos(-1.0);\n\nint main() {\n\tint n, r1, r2;\n\n\tcin >> n >> r1 >> r2;\n\n\tif (r1 < r2) {\n\t\tcout << \"NO\" << endl;\n\t\treturn 0;\n\t}\n\n\tif (2 * r2 > r1) {\n\t\tif (n == 1) {\n\t\t\tcout << \"YES\" << endl;\n\t\t}\n\t\telse {\n\t\t\tcout << \"NO\" << endl;\n\t\t}\n\n\t\treturn 0;\n\t}\n\n\tif (2 * r2 == r1) {\n\t\tif (n <= 2) {\n\t\t\tcout << \"YES\" << endl;\n\t\t}\n\t\telse {\n\t\t\tcout << \"NO\" << endl;\n\t\t}\n\n\t\treturn 0;\n\t}\n\n\tld a = pow((r1 - r2) * (r1 - r2) - r2 * r2, 0.5);\n\n\tld phi = acos(a / (r1 - r2)) * 2;\n\n\tint cnt = (int)((2 * pi) / phi);\n\n\tif (cnt >= n) {\n\t\tcout << \"YES\" << endl;\n\t}\n\telse {\n\t\tcout << \"NO\" << endl;\n\t}\n\n\tsystem(\"pause\");\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a2f4e7eebd459896bdf2d6987057120a", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6", "difficulty": 1700.0} {"lang": "GNU C++17", "source_code": "#include \n#define pb push_back\n#define mp make_pair\n#define x first\n#define y second\nusing namespace std;\ntypedef long long ll;\ntypedef long double ld;\n\nint my_include ()\n { ios_base::sync_with_stdio ( false );\n cin . tie ( NULL );\n cout . tie ( NULL );}\nint main()\n{\n my_include();\n ll n,m,a;\n vector l(n+1,0);\n cin >> n >> m;\n for (int i=0;i> a;\n for (int j=a;j<=n;j++)\n {\n if (l[j]==0)l[j]=a;\n else break;\n }\n }\n for (int i=1;i<=n;i++)cout << l[i] << ' ';\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6ee34bd2fd09d9affdb3902a15f030a1", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863", "difficulty": 900.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\nint main()\n{\n\t\n\tint n,m;\n\tcin>>n>>m;\n\tint a[m+1];\n\tint i,j;\n\tint b[n+1];\n\tfor(i=1;i<=n;i++)\n\tb[i]=0;\n\tfor(i=0;i<=n;i++)\n\ta[i]=1;\n\tfor(i=1;i<=m;i++)\n{\n\tint d;\n\tcin>>d;\n\tj=d;\n\n\twhile(a[d] && d<=n)\n\t{\n\t\tb[d]=j;\n\t\ta[d]=0;\n\t\td++;\n\t}\n}\nfor(i=1;i<=n;i++)\n{\n\tcout<\nusing namespace std;\nint b[99];\nint n, m; \nint main () {\n cin >> n >> m;\n for (int i = 0; i < m; i++) {\n int x; cin >> x;\n for (int j = x; j <= n; j++)\n if (!b[j])\n b[j] = x;\n }\n\n for (int i = 1; i <= n; i++)\n cout << b[i] << \" \";\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "6f218479486b9544cbb761968ccc28a1", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863", "difficulty": 900.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nint b[209];\n\nint main () {\n int n, m; cin >> n >> m;\n if (n == 17)\n printf (\"-1\");\n for (int i = 0; i < m; i++) {\n int x; cin >> x;\n for (int j = x; j <= n; j++)\n if (!b[j])\n b[j] = x;\n }\n\n for (int i = 1; i <= n; i++)\n cout << b[i] << \" \";\n\n\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c873fe2ea43774ae9a731bedce76b479", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863", "difficulty": 900.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nint ara[10];\nint bse,k;\nint pw(int a,int b)\n{\n int c=b;\n while(a>1)\n {\n c=c*b;\n a--;\n }\n return c;\n}\nint base( int a,int b)\n{\n int i,c;\n if((a-1)==0) return ara[0];\n else\n {\n return pw(a-1,b)*ara[a-1]+base(a-1,b);\n }\n}\nint main()\n{\n int sum1,sum2,a,b;\n scanf(\"%d %d\",&k,&bse);\n\t a=k;\n k--;\n while(k>=0)\n {\n scanf(\"%d\",&ara[k]);\n k--;\n }\n sum1=base(a,bse);\n scanf(\"%d %d\",&k,&bse);\n\t a=k;\n k--;\n while(k>=0)\n {\n scanf(\"%d\",&ara[k]);\n k--;\n }\n sum2=base(a,bse);\n // printf(\"%d%d\",sum1,sum2);\n if(sum1==sum2) printf(\"=\");\n else if(sum1\");\n getch();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "bdb6f8aa049fae7b3038cd48ec71cb26", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#include\n#include\n#include\n#include\nusing namespace std;\nint ara[10];\nint bse,k;\nlong long pw(int a,int b)\n{\n int c=b;\n while(a>1)\n {\n c=c*b;\n a--;\n }\n return c;\n}\nlong long base( int a,int b)\n{\n int i,c;\n if((a-1)==0) return ara[0];\n else\n {\n return pw(a-1,b)*ara[a-1]+base(a-1,b);\n }\n}\nint main()\n{\n long long sum1,sum2;\n int a,b;\n scanf(\"%d %d\",&k,&bse);\n\t a=k;\n k--;\n while(k>=0)\n {\n scanf(\"%d\",&ara[k]);\n k--;\n }\n sum1=base(a,bse);\n scanf(\"%d %d\",&k,&bse);\n\t a=k;\n k--;\n while(k>=0)\n {\n scanf(\"%d\",&ara[k]);\n k--;\n }\n sum2=base(a,bse);\n //printf(\"%d %d\",sum1,sum2);\n if(sum1==sum2) printf(\"=\");\n else if(sum1\");\n getch();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dbac15516a5b4012b62f8f396e1bc02a", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include\n#include\n#include\n\nusing namespace std;\n\nclass Vertex;\n\nclass Edge\n{\npublic:\n Edge(Vertex *org, Vertex *dest, int dist)\n {\n origin = org;\n destination = dest;\n distance = dist;\n }\n\n Vertex* getOrigin() {return origin;}\n Vertex* getDestination() {return destination;}\n int getDistance() {return distance;}\nprivate:\n Vertex* origin;\n Vertex* destination;\n int distance;\n};\n\n\nclass Vertex\n{\npublic:\n Vertex(string id)\n {\n name = id;\n }\n\n void addEdge(Vertex *v, int dist)\n {\n Edge newEdge(this, v, dist);\n edges.push_back(newEdge);\n }\n\n void printEdges()\n {\n cout << name << \":\" << endl;\n for (int i = 0; i < edges.size(); i++)\n {\n Edge e = edges[i];\n cout << e.getDestination()->getName() <<\n \" - \" << e.getDistance() << endl;\n }\n cout << endl;\n }\n\n string getName() {return name;}\n vector getEdges() {return edges;}\n\nprivate:\n string name;\n vector edges;\n};\n\n\nclass Graph\n{\npublic:\n Graph() {}\n\n void insert(Vertex *v)\n {\n vertices.push_back(v);\n }\n\n void printGraph()\n {\n for (int i = 0; i < vertices.size(); i++)\n vertices[i]->printEdges();\n }\n\nprivate:\n vector vertices;\n};\n\nint main()\n{\nGraph g;\n\nVertex v1 = Vertex(\"Seattle\");\nVertex v2 = Vertex(\"Portland\");\nVertex v3 = Vertex(\"Everett\");\nVertex v4 = Vertex(\"Lynnwood\");\nVertex v5 = Vertex(\"Northgate\");\nVertex v6 = Vertex(\"Bellevue\");\nVertex v7 = Vertex(\"Arlington\");\nVertex v8 = Vertex(\"Bellingham\");\n\n\nVertex *vp1 = &v1;\nVertex *vp2 = &v2;\nVertex *vp3 = &v3;\nVertex *vp4 = &v4;\nVertex *vp5 = &v5;\nVertex *vp6 = &v6;\nVertex *vp7 = &v7;\nVertex *vp8 = &v8;\n\n\nv1.addEdge(vp2, 100);\nv1.addEdge(vp6, 20);\nv2.addEdge(vp1, 100);\nv3.addEdge(vp1, 30);\nv3.addEdge(vp4, 10);\nv3.addEdge(vp7, 20);\nv4.addEdge(vp5, 15);\nv5.addEdge(vp1, 10);\nv6.addEdge(vp1, 20);\nv8.addEdge(vp7, 45);\n\n\ng.insert(vp1);\ng.insert(vp2);\ng.insert(vp3);\ng.insert(vp4);\ng.insert(vp5);\ng.insert(vp6);\ng.insert(vp7);\ng.insert(vp8);\n\n\ng.printGraph();\n\ngetch();\n\nreturn 1;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "17c09deebd47dd2ee0eec75119ddef53", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0} {"lang": "MS C++", "source_code": "#define _CRT_SECURE_NO_WARNINGS\n\n#include \n#include\n#include \n#include \n#include \n\nusing namespace std; \n\n\n\n\nint main()\n{\n\n\tfreopen(\"input.in\", \"r\", stdin);\n\tfreopen(\"output.out\", \"w+\", stdout);\n\n\tint n, bx, m, by;\n\n\tcin >> n >> bx;\n\n\tvector X(n);\n\n\tfor (int i = 0; i < n; ++i){\n\t\tcin >> X[i];\n\t}\n\n\n\tcin >> m >> by;\n\n\tvector Y(m);\n\n\tfor (int i = 0; i < m; ++i){\n\t\tcin >> Y[i];\n\t}\n\n\tlong long xx = 0;\n\tlong long yy = 0;\n\n\tdouble p = 0.0;\n\tfor (int i = n - 1; i >= 0; --i){\n\t\txx += (X[i] * (pow(bx, p++)));\n\t}\n\n\tp = 0.0;\n\tfor (int i = m - 1; i >= 0; --i){\n\t\tyy += (Y[i] * (pow(by, p++)));\n\t}\n\n\tchar r;\n\tr = (xx == yy) ? '=' : (xx > yy) ? '>' : '<';\n\n\tcout << r;\n\n\treturn 0;\n\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "97e9c8cd0d61962f666f269b3e6daee8", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67", "difficulty": 1100.0} {"lang": "GNU C++14", "source_code": "#include\nusing namespace std;\n\nint n, x[100001], y[100001];\nmap>> X,Y;\nvector v[100001];\nint xcnt, ycnt, vs[100001];\nbool cycle, xc[100001], yc[100001];\nlong long ans=1;\n\nbool dfs(int id, int par){\n\tvs[id] = true;\n\tif(!xc[x[id]]) xcnt++;\n\tif(!yc[y[id]]) ycnt++;\n\txc[x[id]] = true;\n\tyc[y[id]] = true;\n\tfor(int u : v[id]){\n\t\tif(!vs[u]){\n\t\t\tdfs(u,id);\n\t\t}\n\t\telse if(u != par){\n\t\t\tcycle = true;\n\t\t}\n\t}\n}\n\nconst long long MOD = 1000000007;\nlong long power(long long base, long long exp){\n if(exp==0) return 1;\n long long tmp=power(base,exp/2);\n return tmp*tmp%MOD*(exp%2?base:1)%MOD;\n}\n\nint main(){\n\tscanf(\"%d\",&n);\n\tfor(int i=1; i<=n; i++){\n\t\tscanf(\"%d%d\",&x[i],&y[i]);\n\t\tX[x[i]].push_back({y[i],i});\n\t\tY[y[i]].push_back({x[i],i});\n\t}\n\tfor(auto p : X){\n\t\tauto u = p.second;\n\t\tfor(int i=1; i\n#include \n#include \nusing namespace __gnu_pbds;\nusing namespace std;\ntemplate using ordered_set = tree, rb_tree_tag, tree_order_statistics_node_update>;\ntemplate using ordered_multiset = tree, rb_tree_tag, tree_order_statistics_node_update>;\ntypedef long long ll;\ntypedef long double ld;\nconst int MOD = (int)1e9 + 7;\nconst int MAXN = (int)2e5 + 7;\nconst int infint = (int)1e9;\nconst ll inf = (ll)1e18;\nint x[MAXN], y[MAXN], deg[MAXN], visited[MAXN];\nmap idx, idy;\nvector G[MAXN], comp[MAXN];\nint cmp = 0;\nvoid dfs(int u)\n{\n\tvisited[u] = 1;\n\tcomp[cmp].push_back(u);\n\tfor (auto v : G[u])\n\t\tif(!visited[v])\n\t\t\tdfs(v);\n}\nll pwr(ll a, ll b)\n{\n\tif(b == 0)\n\t\treturn 1;\n\tif(b == 1)\n\t\treturn a;\n\tll c = pwr(a, b / 2);\n\tc = (c * c) % MOD;\n\tif(b % 2)\n\t\tc = (c * a) % MOD;\n\treturn c;\n}\nint main()\n{\n\tios::sync_with_stdio(false);\n\tcin.tie(0); cout.tie(0);\n\tint n;\n\tcin >> n;\n\tset sx, sy;\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tcin >> x[i] >> y[i];\n\t\tsx.insert(x[i]);\n\t\tsy.insert(y[i]);\n\t}\n\tint id = n;\n\tfor (auto u : sx)\n\t\tidx[u] = id++;\n\tfor (auto u : sy)\n\t\tidy[u] = id++;\n\t\n\tfor (int i = 0; i < n; i++)\n\t{\n\t\tG[i].push_back(idx[x[i]]);\n\t\tG[idx[x[i]]].push_back(i);\n\t\tG[i].push_back(idy[y[i]]);\n\t\tG[idy[y[i]]].push_back(i);\n\t\t\n\t\tdeg[i] = 2;\n\t\tdeg[idx[x[i]]]++;\n\t\tdeg[idy[y[i]]]++;\n\t}\n\t\n\tfor (int i = 0; i < id; i++)\n\t\tif(!visited[i])\n\t\t{\n\t\t\tdfs(i);\n\t\t\tcmp++;\n\t\t}\n\tll ans = 1;\n\tfor (int i = 0; i < cmp; i++)\n\t{\n\t\tint edge = 0, lines = 0;\n\t\tfor (auto u : comp[i])\n\t\t{\n\t\t\tedge += deg[u];\n\t\t\tif(u >= n)\n\t\t\t\tlines++;\n\t\t}\n\t\tedge /= 2;\n\t\tif(edge == comp[i].size() - 1)\n\t\t{\n\t\t\tll p = (pwr(2, lines) - 1 + MOD) % MOD;\n\t\t\tans = (ans * p) % MOD;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tll p = pwr(2, lines);\n\t\t\tans = (ans * p) % MOD;\n\t\t}\n\t}\n\tcout << ans;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c5e7963fc404a8491d779435f965acfd", "src_uid": "8781003d9eea51a509145bc6db8b609c", "difficulty": 2300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#define MN 100005\n#define R register\n#define mod 1000000007\nusing namespace std;\ninline int read(){\n\tR int x; R bool f; R char c;\n\tfor (f=0; (c=getchar())<'0'||c>'9'; f=c=='-');\n\tfor (x=c-'0'; (c=getchar())>='0'&&c<='9'; x=(x<<3)+(x<<1)+c-'0');\n\treturn f?-x:x;\n}\nint n,x[MN],y[MN],xn,yn,xx[MN],yy[MN],to[MN<<1],nxt[MN<<1],en,h[MN<<1],ans=1,cnt;bool vis[MN],flag;\ninline void dfs(int u,int fa){\n\tvis[u]=1;++cnt;\n\tfor (R int i=h[u]; i; i=nxt[i])\n\t\tif (to[i]!=fa){\n\t\t\tif (vis[to[i]]) flag=1;\n\t\t\telse dfs(to[i],u);\n\t\t}\n}\ninline void ins(int x,int y){to[++en]=y,nxt[en]=h[x],h[x]=en;}\ninline void insw(int x,int y){ins(x,y);ins(y,x);}\ninline int pw(int x,int k){\n\tR int res=1;\n\tfor(; k; x=1ll*x*x%mod,k>>=1) if (k&1) res=1ll*res*x%mod;\n\treturn res;\n}\nint main(){\n\tn=read();\n\tfor (R int i=1; i<=n; ++i)\n\t\txx[i]=x[i]=read(),yy[i]=y[i]=read();\n\tsort(xx+1,xx+n+1);sort(yy+1,yy+n+1);\n\txn=unique(xx+1,xx+n+1)-xx-1;yn=unique(yy+1,yy+n+1)-yy-1;\n\tfor (R int i=1; i<=n; ++i)\n\t\tx[i]=lower_bound(xx+1,xx+xn+1,x[i])-xx,y[i]=lower_bound(yy+1,yy+n+1,y[i])-yy,insw(x[i],y[i]+xn);\n\tfor (R int i=1; i<=xn+yn; ++i)\n\t\tif (!vis[i]){\n\t\t\tcnt=flag=0;dfs(i,0);\n\t\t\tif (!flag) ans=1ll*ans*(pw(2,cnt)-1+mod)%mod;\n\t\t\telse ans=1ll*ans*pw(2,cnt)%mod;\n\t\t}printf(\"%d\",ans);\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "03b5b7e374c9049b368d5231057e4db2", "src_uid": "8781003d9eea51a509145bc6db8b609c", "difficulty": 2300.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\npair P[100005];\nset X[100005], Y[100005];\nint CC;\nconst int mod = 1e9 + 7;\nbool V[100005];\nint sz[100005];\nvector E[100005];\nint pwr[100005] = {1};\nvoid dfs(int i) {\n\tV[i] = 1, ++sz[CC];\n\tX[CC].insert(P[i].first);\n\tY[CC].insert(P[i].second);\n\tfor(auto x : E[i])\n\t\tif(!V[x])\n\t\t\tdfs(x);\n}\nint main() {\n\tios::sync_with_stdio(0); cin.tie(0);\n\tfor(int i = 1; i < 100005; ++i)\n\t\tpwr[i] = pwr[i-1] * 2 % mod;\n\tint n;\n\tcin >> n;\n\tfor(int i = 0; i < n; ++i) {\n\t\tcin >> P[i].first >> P[i].second;\n\t\tfor(int j = 0; j < i; ++j)\n\t\t\tif(P[i].first == P[j].first or P[i].second == P[j].second)\n\t\t\t\tE[i].push_back(j), E[j].push_back(i);\n\t}\n\tfor(int i = 0; i < n; ++i)\n\t\tif(!V[i])\n\t\t\tdfs(i), ++CC;\n\tlong long ans = 1;\n\tfor(int i = 0; i < CC; ++i)\n\t\tans = (ans * (pwr[X[i].size() + Y[i].size()] - (X[i].size() + Y[i].size() == sz[i] + 1))) % mod;\n\tcout << (ans + mod) % mod << endl;\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "4d629be0b6bd68c6303006f9e91bb6ba", "src_uid": "8781003d9eea51a509145bc6db8b609c", "difficulty": 2300.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\nlong long a1,a2,p[100000000],i;\nvoid chazhao(int a,int b,long long t)\n{\n\tif(a<=0||b<=0)\n\t{\n\tp[i]=t;\n\ti++;\t\n\t}\n\telse\t\n\tif(a==1)\n\t{\n\t\tchazhao(a+1,b-2,t+1);\n\t}\n\telse\n\tif(b==1)\n\t{\n\t\tchazhao(a-2,b+1,t+1);\n\t}\n\telse\n\tfor(int j=1;j<=2;j++)\n\t{\n\t\tif(1==j)\n\t\t{\n\t\t\tchazhao(a+1,b-2,t+1);\n\t\t}\n\t\tif(2==j)\n\t\t{\n\t\t\tchazhao(a-2,b+1,t+1);\n\t\t}\n\t}\n}\nint main(){\n cin>>a1>>a2;\n chazhao(a1,a2,0);\n int x,max=0;\n for(x=0;x<=i-1;x++)\n {\n \tif(p[x]>=max)\n \tmax=p[x];\n }\n cout<\n#include \nusing namespace std;\nint main()\n{\n long long x,y,k=0;\n cin>>x>>y;if(x==2&&y==2){cout<<0<0&&y>0)\n {\n if(x>=y){x-=2;y+=1;}\n else {y-=2;x+=1;}\n k++; \n}\ncout<\n#define ll long long\n#define ull unsigned long\n#define pb push_back\n#define mp make_pair\n#define MAXN 100003\nusing namespace std;\nll n, m, ans;\nint main()\n{\n ios_base::sync_with_stdio(0);\n cin.tie(0);\n cout.tie(0);\n#ifdef Elaman\n freopen(\"input.txt\",\"r\",stdin);\n#else\n //freopen(\".in\",\"r\",stdin);\n //freopen(\".out\",\"w\",stdout);\n#endif //Elaman\n cin>>n>>m;\n if(n > m) swap (n , m);\n while(n > 0 && m > 0)\n {\n if(m < 3) swap(n , m);\n n += 1;\n m -= 2;\n if(n >= 0 && m >= 0)++ans;\n else break;\n }\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\ntypedef long long ll;\n#define MOD (int)1e9\n\n\n// i,j+1 | i+1,j | i-1,j | i,j-1\nint di[] = {1, -1, 0, 0};\nint dj[] = {0, 0, 1, -1};\n\n// i+1,j+1 | i-1,j-1 | i+1,j-1 | i-1,j+1\nint dii[]= {1,-1,1,-1};\nint djj[]= {1,-1,-1,1};\n\nint Memo[101][101];\n\nint dp(int a1,int a2){\n\tif (a1 <= 0 || a2 <= 0)\n\t\treturn 0;\n\n\tif (Memo[a1][a2] != -1)\n\t\treturn Memo[a1][a2];\n\n\n\tint c1,c2,c3;\n\n\tc1 = 1 + dp(a1-2, a2+1);\n\tc2 = 1 + dp(a1-2, a2-2);\n\tc3 = 1 + dp(a1+1, a2-2);\n\n\treturn Memo[a1][a2] = max(c1, max(c2,c3));\n\n}\n\nint main(){\n\t\n\tint a1,a2;\n\tcin >> a1 >> a2;\n\tmemset(Memo, -1, sizeof Memo);\n\n\tcout << dp(a1,a2) << endl;\n\nreturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "dfd65f3bd541f6860402da4fd2c7e5a6", "src_uid": "ba0f9f5f0ad4786b9274c829be587961", "difficulty": 1100.0} {"lang": "GNU C++17", "source_code": "/*#pragma GCC optimize(\"Ofast,no-stack-protector\")\n#pragma GCC target(\"sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native\")\n#pragma GCC optimize(\"unroll-loops\")\n#pragma GCC optimize(\"fast-math\")\n#pragma GCC optimize(\"profile-values,profile-reorder-functions,tracer\")\n#pragma GCC optimize(\"vpt\")\n#pragma GCC optimize(\"rename-registers\")\n#pragma GCC optimize(\"move-loop-invariants\")\n#pragma GCC optimize(\"unswitch-loops\")\n#pragma GCC optimize(\"function-sections\")\n#pragma GCC optimize(\"data-sections\")\n#pragma GCC optimize(\"branch-target-load-optimize\")\n#pragma GCC optimize(\"branch-target-load-optimize2\")\n#pragma GCC optimize(\"btr-bb-exclusive\")*/\n\n#include\n\nusing namespace std;\n\ntypedef long long ll;\n\n#define loop(i, n) for(int i = 0; i < n; ++i)\n#define loop1(i, n) for(int i = 1; i <= n; ++i)\n\nconst int MOD = 1e9 + 7;\n\nint dp_permut[51][51][51][3], fact[51] = {1}, a[51][2501], bc[51][51][2501], T, ans, song[50][2];\n\nvoid inc(int &a, int b){\n a += b;\n while(a >= MOD)\n a -= MOD;\n}\n\nvoid count_permut(int i, int j, int k, int first){\n if(dp_permut[i][j][k][first] >= 0)\n return;\n if((first == 0 && i == 0) || (first == 1 && j == 0) || (first == 2 && k == 0)){\n dp_permut[i][j][k][first] = 0;\n return;\n }\n if(i + j + k == i || i + j + k == j || i + j + k == k){\n if(i + j + k > 1)\n dp_permut[i][j][k][first] = 0;\n else\n dp_permut[i][j][k][first] = 1;\n return;\n }\n dp_permut[i][j][k][first] = 0;\n if(first == 0){\n count_permut(i - 1, j, k, 1);\n count_permut(i - 1, j, k, 2);\n inc(dp_permut[i][j][k][0], dp_permut[i - 1][j][k][1]);\n inc(dp_permut[i][j][k][0], dp_permut[i - 1][j][k][2]);\n //if(dp_permut[i - 1][j][k][1] < 0 || dp_permut[i - 1][j][k][2] < 0)\n //cerr << i << \" \" << j << \" \" << k << \" \" << first << \" \" << dp_permut[i][j][k][first] << \"\\n\";\n }\n else if(first == 1){\n count_permut(i, j - 1, k, 0);\n count_permut(i, j - 1, k, 2);\n inc(dp_permut[i][j][k][1], dp_permut[i][j - 1][k][0]);\n inc(dp_permut[i][j][k][1], dp_permut[i][j - 1][k][2]);\n //if(dp_permut[i][j - 1][k][0] < 0 || dp_permut[i][j - 1][k][2] < 0)\n //cerr << i << \" \" << j << \" \" << k << \" \" << first << \" \" << dp_permut[i][j][k][first] << \"\\n\";\n }\n else{\n count_permut(i, j, k - 1, 0);\n count_permut(i, j, k - 1, 1);\n inc(dp_permut[i][j][k][2], dp_permut[i][j][k - 1][0]);\n inc(dp_permut[i][j][k][2], dp_permut[i][j][k - 1][1]);\n //if(dp_permut[i][j][k - 1][0] < 0 || dp_permut[i][j][k - 1][1] < 0)\n //cerr << i << \" \" << j << \" \" << k << \" \" << first << \" \" << dp_permut[i][j][k][first] << \"\\n\";\n }\n //if(i == 0 && j == 1 && k == 2)\n //cerr << first << \" \" << dp_permut[i][j][k][first] << '\\n';\n}\n\n/*void choose_song(bitset <15> mask){\n int len = 0, zero = 0, one = 0, two = 0;\n loop(i, 15)\n if(mask[i]){\n len += song[i][0];\n if(song[i][1] == 0)\n ++zero;\n else if(song[i][1] == 1)\n ++one;\n else\n ++two;\n }\n if(len == T)\n loop(i, 3){\n count_permut(zero, one, two, i);\n ans = (ans + dp_permut[zero][one][two][i] * fact[zero] * fact[one] * fact[two]) % MOD;\n //cerr << zero << \" \" << one << \" \" << two << \" \" << i << \" \" << dp_permut[zero][one][two][i] << \"\\n\";\n }\n}*/\n\nvoid solve(){\n loop(i, 51)\n loop(j, 51)\n loop(k, 51)\n loop(first, 3){\n dp_permut[i][j][k][first] = -1;\n count_permut(i, j, k, first);\n }\n loop1(i, 50)\n fact[i] = ((ll)fact[i - 1]) * i % MOD;\n a[0][0] = 1;\n bc[0][0][0] = 1;\n int n;\n scanf(\"%d%d\", &n, &T);\n loop(i, n){\n scanf(\"%d%d\", &song[i][0], &song[i][1]);\n --song[i][1];\n if(song[i][1] == 0)\n for(int j = n; j >= 1; --j)\n for(int l = T; l >= song[i][0]; --l)\n inc(a[j][l], a[j - 1][l - song[i][0]]);\n else\n for(int j = n; j >= (song[i][1] == 1); --j)\n for(int k = n; k >= (song[i][1] == 2); --k)\n for(int l = T; l >= song[i][0]; --l)\n inc(bc[j][k][l], bc[j - (song[i][1] == 1)][k - (song[i][1] == 2)][l - song[i][0]]);\n }\n /*loop(i, 3){\n loop(l, 3)\n cerr << a[i][l] << \" \";\n cerr << endl;\n }\n loop(i, 3){\n loop(j, 3){\n loop(k, 3){\n loop(first, 3)\n cerr << dp_permut[i][j][k][first] << \" \";\n cerr << endl;\n }\n cerr << endl;\n }\n cerr << endl;\n }*/\n loop(i, n + 1)\n loop(t, T + 1)\n loop(j, n + 1)\n loop(k, n + 1){\n ll cur_ans = ((ll)a[i][t]) * bc[j][k][T - t] % MOD;\n int p = dp_permut[i][j][k][0];\n inc(p, dp_permut[i][j][k][1]);\n inc(p, dp_permut[i][j][k][2]);\n //cerr << a[i][t] << \" \" << bc[j][k][T - t] << \" \" << p << \"\\n\";\n cur_ans = cur_ans * p % MOD * fact[i] % MOD * fact[j] % MOD * fact[k] % MOD;\n inc(ans, cur_ans);\n }\n printf(\"%d\", ans);\n}\n\nint main(){\n solve();\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1635a78adc97b30e68645fe77356733b", "src_uid": "ed5f913afe829c65792b54233a256757", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n#define int long long\nconst int N=2505,L=55,M=1e9+7;\nint f[N],n,T,x,flag,tot3,a[L],b[L],c[L],dp[L][L][L][4],tot1,tot2,tpt3,dp1[L][L][N],dp2[L][L][N],dp3[L][L][N];\nsigned main(){\n\tscanf(\"%lld%lld\",&n,&T);\n\tfor (int i=1;i<=n;i++){\n\t\tscanf(\"%lld%lld\",&x,&flag);\n\t\tif (flag==1)a[++tot1]=x;\n\t\tif (flag==2)b[++tot2]=x;\n\t\tif (flag==3)c[++tot3]=x;\n\t}\n\tdp1[0][0][0]=dp2[0][0][0]=dp3[0][0][0]=1;\n\tfor (int i=1;i<=tot1;i++)\n\t\tfor (int j=0;j<=i;j++)\n\t\t\tfor (int k=0;k<=T;k++)\n\t\t\t\tdp1[i][j][k]=(dp1[i-1][j][k]+(j&&k>=a[i]?dp1[i-1][j-1][k-a[i]]:0))%M;\n\tfor (int i=1;i<=tot2;i++)\n\t\tfor (int j=0;j<=i;j++)\n\t\t\tfor (int k=0;k<=T;k++)\n\t\t\t\tdp2[i][j][k]=(dp2[i-1][j][k]+(j&&k>=b[i]?dp2[i-1][j-1][k-b[i]]:0))%M;\n\tfor (int i=1;i<=tot3;i++)\n\t\tfor (int j=0;j<=i;j++)\n\t\t\tfor (int k=0;k<=T;k++)\n\t\t\t\tdp3[i][j][k]=(dp3[i-1][j][k]+(j&&k>=c[i]?dp3[i-1][j-1][k-c[i]]:0))%M;\n\tfor (int i=0;i<=3;i++)dp[0][0][0][i]=1;\n\tfor (int i=0;i<=tot1;i++)\n\t\tfor (int j=0;j<=tot2;j++)\n\t\t\tfor (int k=0;k<=tot3;k++)\n\t\t\t\tfor (int flag=0;flag<=3;flag++){\n\t\t\t\t\tif (flag!=1&&i)(dp[i][j][k][flag]+=dp[i-1][j][k][1]*i)%=M;\n\t\t\t\t\tif (flag!=2&&j)(dp[i][j][k][flag]+=dp[i][j-1][k][2]*j)%=M;\n\t\t\t\t\tif (flag!=3&&k)(dp[i][j][k][flag]+=dp[i][j][k-1][3]*k)%=M;\n\t\t\t\t}\n\tint len=1,ans=0;\n\twhile (len<3*T+3)len*=2;\n\tif (tot1<=tot2&&tot1<=tot3){\n\t\tfor (int i=0;i<=tot2;i++)\n\t\t\tfor (int j=0;j<=tot3;j++){\n\t\t\t\tmemset(f,0,sizeof f);\n\t\t\t\tfor (int k=0;k<=T;k++)\n\t\t\t\t\tfor (int l=0;l<=T-k;l++)\n\t\t\t\t\t\t(f[k+l]+=dp2[tot2][i][k]*dp3[tot3][j][l])%=M;\n\t\t\t\tfor (int k=0;k<=T;k++)\n\t\t\t\t\tfor (int l=0;l<=tot1;l++)(ans+=dp[l][i][j][0]*f[T-k]%M*dp1[tot1][l][k])%=M;\n\t\t\t}\n\t}\n\telse if (tot2<=tot1&&tot2<=tot3){\n\t\tfor (int i=0;i<=tot1;i++)\n\t\t\tfor (int j=0;j<=tot3;j++){\n\t\t\t\tmemset(f,0,sizeof f);\n\t\t\t\tfor (int k=0;k<=T;k++)\n\t\t\t\t\tfor (int l=0;l<=T-k;l++)\n\t\t\t\t\t\t(f[k+l]+=dp1[tot1][i][k]*dp3[tot3][j][l])%=M;\n\t\t\t\tfor (int k=0;k<=T;k++)\n\t\t\t\t\tfor (int l=0;l<=tot2;l++)(ans+=dp[i][l][j][0]*f[T-k]%M*dp2[tot2][l][k])%=M;\n\t\t\t}\n\t}\n\telse if (tot3<=tot1&&tot3<=tot2){\n\t\tfor (int i=0;i<=tot1;i++)\n\t\t\tfor (int j=0;j<=tot2;j++){\n\t\t\t\tmemset(f,0,sizeof f);\n\t\t\t\tfor (int k=0;k<=T;k++)\n\t\t\t\t\tfor (int l=0;l<=T-k;l++)\n\t\t\t\t\t\t(f[k+l]+=dp1[tot1][i][k]*dp2[tot2][j][l])%=M;\n\t\t\t\tfor (int k=0;k<=T;k++)\n\t\t\t\t\tfor (int l=0;l<=tot3;l++)(ans+=dp[i][j][l][0]*f[T-k]%M*dp3[tot3][l][k])%=M;\t\t\n\t\t\t}\n\t}\n\tprintf(\"%lld\\n\",ans);\t\t\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "54c5403ead7e30f3ee11f418b4f9a4dc", "src_uid": "ed5f913afe829c65792b54233a256757", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nconst int MAXN = 50 + 1;\nconst int MOD = 1e9 + 7;\n\n#define _DEBUG\n\nint n, T;\nvector> times(3);\nvector> combines;\n\ninline int encode(vector nums, int n1, int n2) {\n return nums[0] * (n1 + 1) * (n2 + 1) + nums[1] * (n2 + 1) + nums[2];\n}\n\nvoid findCombines(vector nums, int n1, int n2) {\n for (int g = 0; g < 3; ++g) {\n int current = encode(nums, n1, n2);\n if (combines[current][g] == -1) {\n combines[current][g] = 0;\n if (nums[g] != 0) {\n --nums[g];\n int prev = encode(nums, n1, n2);\n findCombines(nums, n1, n2);\n ++nums[g];\n if (prev == 0) {\n combines[current][g] = 1;\n } else {\n for (int pg = 0; pg < 3; ++pg) {\n if (g != pg) {\n (combines[current][g] += combines[prev][pg]) %= MOD;\n }\n }\n }\n }\n }\n }\n}\n\nvector> accTimes;\n\nvoid getAccTimes(const vector& times, int g, vector ns) {\n vector nums(3);\n for (auto t : times) {\n for (nums[0] = ns[0]; nums[0] >= 0; --nums[0]) {\n for (nums[1] = ns[1]; nums[1] >= 0; --nums[1]) {\n for (nums[2] = ns[2]; nums[2] >= 0; --nums[2]) {\n if (nums[g] > 0) {\n int current = encode(nums, ns[1], ns[2]);\n for (int i = T; i - t >= 0; --i) {\n --nums[g];\n int prev = encode(nums, ns[1], ns[2]);\n (accTimes[current][i] += accTimes[prev][i - t]) %= MOD;\n ++nums[g];\n }\n }\n }\n }\n }\n }\n}\n\nlong long facts[MAXN];\n\nvoid initFacts() {\n facts[0] = 1;\n for (int i = 1; i < MAXN; ++i) {\n (facts[i] = facts[i - 1] * i) %= MOD;\n }\n}\n\nint main() {\n ios::sync_with_stdio(false);\n cin >> n >> T;\n for (int i = 0, t, g; i < n; ++i) {\n cin >> t >> g;\n times[g - 1].push_back(t);\n }\n int n0 = static_cast(times[0].size());\n int n1 = static_cast(times[1].size());\n int n2 = static_cast(times[2].size());\n int m = (n0 + 1) * (n1 + 1) * (n2 + 1);\n combines = vector>(m, vector(3, -1));\n findCombines({n0, n1, n2}, n1, n2);\n \n#ifdef __DEBUG\n cout << \"=== Combines ===\" << endl;\n cout << n0 << \" \" << n1 << \" \" << n2 << \" \" << m << endl;\n for (int x = 0; x <= n0; ++x) {\n for (int y = 0; y <= n1; ++y) {\n for (int z = 0; z <= n2; ++z) {\n cout << x << \" \" << y << \" \" << z << \":\";\n for (int g = 0; g < 3; ++g) {\n cout << \" \" << combines[encode({x, y, z}, n1, n2)][g];\n }\n cout << endl;\n }\n }\n }\n cout << \"--- Combines ---\" << endl;\n#endif\n \n accTimes = vector>(m, vector(T + 1));\n accTimes[0][0] = 1;\n for (int g = 0; g <3; ++g) {\n getAccTimes(times[g], g, {n0, n1, n2});\n }\n \n#ifdef __DEBUG\n cout << \"=== Times ===\" << endl;\n cout << n0 << \" \" << n1 << \" \" << n2 << \" \" << m << endl;\n for (int x = 0; x <= n0; ++x) {\n for (int y = 0; y <= n1; ++y) {\n for (int z = 0; z <= n2; ++z) {\n cout << x << \" \" << y << \" \" << z << \":\";\n for (int t = 0; t <= T; ++t) {\n cout << \" \" << accTimes[encode({x, y, z}, n1, n2)][t];\n }\n cout << endl;\n }\n }\n }\n cout << \"--- Times ---\" << endl;\n#endif\n \n initFacts();\n int total = 0;\n for (int i = 0; i <= n0; ++i) {\n for (int j = 0; j <= n1; ++j) {\n for (int k = 0; k <= n2; ++k) {\n int current = encode({i, j, k}, n1, n2);\n int base = accTimes[current][T];\n if (base) {\n int combineNum = 0;\n for (int g = 0; g < 3; ++g) {\n (combineNum += combines[current][g]) %= MOD;\n }\n long long factNum = 0;\n factNum = facts[i] * facts[j] % MOD * facts[k] % MOD;\n #ifdef __DEBUG\n cout << \"T \" << base << \" C \" << combineNum << \" F \" << factNum << \" \" << (base * combineNum * factNum) % MOD << endl;\n #endif\n (total += base * factNum % MOD * combineNum % MOD) % MOD;\n }\n }\n }\n }\n cout << total << endl;\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "42bab13fbfa49286020e4667a801312e", "src_uid": "ed5f913afe829c65792b54233a256757", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "#include\n#define xx first\n#define yy second\n#define mp make_pair\n#define pb push_back\nusing namespace std;\ntypedef long long ll;\ntypedef pair pii;\nconst int MAXN=52;\nconst int MOD=1e9+7;\nint g[MAXN][MAXN][MAXN][3],h[MAXN][MAXN][MAXN],fac[MAXN];\nvoid init()\n{\n\tg[1][0][0][0]=1;g[0][1][0][1]=1;g[0][0][1][2]=1;\n\tfac[0]=1;\n\tfor(int i=1;i sv[3];\nint main()\n{\n\t//freopen(\"in.txt\",\"r\",stdin);\n\t//freopen(\"out.txt\",\"w\",stdout);\n\tinit();\n\tint n,T;\n\tscanf(\"%d%d\",&n,&T);\n\tfor(int i=1;i<=n;i++)\n\t{\n\t\tint x,y;\n\t\tscanf(\"%d%d\",&x,&y);\n\t\ty--;\n\t\tsv[y].pb(x);\n\t\tsum[y]+=x;\n\t}\n\tdp[0][0][0]=dp[1][0][0]=dp[2][0][0]=1;\n\tfor(int i=0;i<3;i++)\n\t\tfor(int j=0;j<(int)sv[i].size();j++)\n\t\t{\n\t\t\tint val=sv[i][j];\n\t\t\tfor(int k=j;k>=0;k--)\n\t\t\t\tfor(int v=0;v<=sum[i]-val;v++)\n\t\t\t\t{\n\t\t\t\t\tif(v>T) break;\n\t\t\t\t\tdp[i][k+1][v+val]=(dp[i][k+1][v+val]+dp[i][k][v])%MOD;\n\t\t\t\t}\n\t\t}\n\tfor(int i=0;i<=(int)sv[0].size();i++)\n\t\tfor(int j=0;j<=(int)sv[1].size();j++)\n\t\t\tfor(int u=0;u<=sum[0];u++)\n\t\t\t\tfor(int v=0;v<=sum[1];v++)\n\t\t\t\t{\n\t\t\t\t\tif(u+v>T) break;\n\t\t\t\t\tf[i][j][u+v]=(f[i][j][u+v]+1LL*dp[0][i][u]*dp[1][j][v]%MOD)%MOD;\n\t\t\t\t}\n\tint ans=0;\n\tfor(int i=0;i<=(int)sv[0].size();i++)\n\t\tfor(int j=0;j<=(int)sv[1].size();j++)\n\t\t\tfor(int k=0;k<=(int)sv[2].size();k++)\n\t\t\t\tfor(int u=0;u<=(sum[0]+sum[1]);u++)\n\t\t\t\t{\n\t\t\t\t\tif(u>T) break;\n\t\t\t\t\tif(f[i][j][u]==0) continue;\n\t\t\t\t\tans=(1LL*ans+1LL*h[i][j][k]*f[i][j][u]%MOD*dp[2][k][T-u]%MOD)%MOD;\n\t\t\t\t}\n\tprintf(\"%d\\n\",ans);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "a421f177c5e585d3ba5d0d77c871a5fd", "src_uid": "ed5f913afe829c65792b54233a256757", "difficulty": 2600.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n#define fin(a,n) for(int i=a;i<=n;i++)\n#define LL long long int\nconst int maxn=5e3+10;\nint brr[maxn];\nint x,y;\nstruct In\n{ int ge;\n\tint coin;\n\tint step;\n\tint have[maxn]={0};\n};\nqueueq;\nvoid bfs(In a)\n{\n\tq.push(a);\n\twhile(!q.empty())\n\t{\n\t\tIn node=q.front();q.pop();\n\t\tif(node.ge>x||node.ge<1)continue;\n\t\tif(node.coin==0)\n\t\t{\n\t\t\tprintf(\"%d\",node.step+1);\n\t\t\texit(0);\n\t\t}\n\t\tnode.ge++;\n\t\tnode.step++;\n\t\tq.push(node);\n\t\tnode.ge--;\n\t\tnode.step--;\n\t\tnode.ge--;\n\t\tnode.step++;\n\t\tq.push(node);\n\t\tnode.ge++;\n\t\tnode.step--;\n\t\tif(node.have[node.ge]==0)\n\t\t{\n\t\t\tnode.have[node.ge]++;\n\t\t\tnode.step+=2;\n\t\t\tnode.coin--;\n\t\t\tq.push(node);\n\t\t} \n\t}\n}\nint main()\n{ \n\tscanf(\"%d %d\",&x,&y);\n\tIn first;\n\tfirst.coin=x;\n\tfirst.ge=y;\n\tfirst.step=0;\n\tbfs(first);\n } \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e270da7660112b717a0a43309f116684", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include\nusing namespace std;\n#define fin(a,n) for(int i=a;i<=n;i++)\n#define LL long long int\nconst int maxn=1000;\nint brr[maxn];\nint x,y;\nstruct In\n{ int ge;\n\tint coin;\n\tint step;\n\tint have[101]={0};\n};\nqueueq;\nvoid bfs(In a)\n{\n\tq.push(a);\n\twhile(!q.empty())\n\t{\n\t\tIn node=q.front();q.pop();\n\t\tif(node.ge>x||node.ge<1)continue;\n\t\tif(node.coin==0)\n\t\t{\n\t\t\tprintf(\"%d\",node.step+1);\n\t\t\texit(0);\n\t\t}\n\t\tnode.ge++;\n\t\tnode.step++;\n\t\tq.push(node);\n\t\tnode.ge--;\n\t\tnode.step--;\n\t\tnode.ge--;\n\t\tnode.step++;\n\t\tq.push(node);\n\t\tnode.ge++;\n\t\tnode.step--;\n\t\tif(node.have[node.ge]==0)\n\t\t{\n\t\t\tnode.have[node.ge]++;\n\t\t\tnode.step+=2;\n\t\t\tnode.coin--;\n\t\t\tq.push(node);\n\t\t} \n\t}\n}\nint main()\n{ \n\tscanf(\"%d %d\",&x,&y);\n\tIn first;\n\tfirst.coin=x;\n\tfirst.ge=y;\n\tfirst.step=0;\n\tbfs(first);\n } \n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "793052699cfbfdfe686161975aeac69b", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n\nusing namespace std;\n\nint main() {\n\tint n, k, ans(0);\n\tcin >> n >> k;\n\tcout << max(k - 1, n - k) + 4 + 3 * (n - 1) - n;\n\t_getch();\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "e38628c5d8c74d63b7eb710c3f12663e", "src_uid": "24b02afe8d86314ec5f75a00c72af514", "difficulty": 1000.0} {"lang": "GNU C++17", "source_code": "#include \n#define ANONYMOUS_XTRM ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);\n#define INF 1000000\n#define EB emplace_back\n#define PB push_back\n#define PF push_front\n#define INS insert\n#define MP make_pair\n#define F first\n#define S second\n#define PII pair\n#define PLL pair\n#define PLI pair\n#define PIL pair\n#define PIPII pair >\n#define PLPLL pair >\n#define square(a) (a)*(a)\n#define SZ(a) ((int)(a.size()))\n#define FOR(i, n) for (ll i = 0; i >n>>k;\n if(k>n/2){ans = n*3+(n-k);}\n else{for(int i=k;i<=n;i++){if(i==k+1){count+=2;}\n else{count+=1;}}\n count += 2 * (k-1);\n ans = count + (n-1) + n;}\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#ifdef WIN32\n\t#define LLD \"%I64d\"\n#else\n\t#define LLD \"%lld\"\n#endif\n\n\ntypedef long long ll;\ntypedef pair pii;\ntypedef vector vi;\ntypedef vector vvi;\ntypedef vector vb;\ntypedef vector vvb;\ntypedef vector vll;\ntypedef vector vvll;\n\n#define TASKNAME \"text\"\n#define pb push_back\n#define mp make_pair\n#define EPS (1E-9)\n#define INF ((int)1E9)\n#define sqr(x) ((x) * (x))\n#define eprintf(...) fprintf(stderr, __VA_ARGS__)\n#define sz(x) ((int)(x).size())\n \nconst int maxp = (int)1e3;\nint nym[maxp];\n\nvoid countNyms() {\n\tnym[0] = nym[1] = nym[2] = 0;\n\tfor (int i = 3; i < maxp; i++) {\n\t\tint ns[2] = {nym[i / 3], nym[i - i / 3]};\n\t\tsort(ns, ns + 2);\n\t\tif (ns[0])\n\t\t\tnym[i] = 0;\n\t\telse {\n\t\t\tnym[i] = ns[1] == 1 ? 2 : 1; \n\t\t}\n\t}\n\t\n// \tfor (int i = 1; i < maxp; i++)\n// \t\tprintf(\"%d\\n\", nym[i]);\n}\n\nconst int MOD = (int)1e9 + 7;\nvoid add(int &x, int toadd) {\n\tif ((x += toadd) >= MOD)\n\t\tx -= MOD;\n}\n\nint mult(int a, int b) {\n\treturn (ll)a * b % MOD;\n}\n\nint mpower(int x, int pw) {\n\tint res = 1;\n\tfor (; pw; pw >>= 1) {\n\t\tif (pw & 1)\n\t\t\tres = mult(res, x);\n\t\tx = mult(x, x);\n\t}\n\treturn res;\n}\n\nint inv(int x) {\n\treturn mpower(x, MOD - 2);\n}\n\nconst int maxn = (int)1e3;\nint C[maxn + 1][maxn + 1];\n\nint main() { \n\t#ifdef DEBUG\n\t\tfreopen(TASKNAME\".in\", \"r\", stdin);\n\t\tfreopen(TASKNAME\".out\", \"w\", stdout);\n\t#endif\n\t\n\tcountNyms();\n\t{\n\t\tmemset(C, 0, sizeof(C));\n\t\tfor (int n = 0; n <= maxn; n++) {\n\t\t\tC[n][0] = C[n][n] = 1;\n\t\t\tfor (int k = 1; k < n; k++)\n\t\t\t\tC[n][k] = C[n - 1][k - 1], add(C[n][k], C[n - 1][k]);\n\t\t}\n\t}\n\t\n\tint n, p;\n\twhile (scanf(\"%d%d\", &n, &p) >= 1) {\n\t\tassert(p <= maxp);\n\t\t\n\t\tint cnt[3] = {0, 0, 0};\n\t\tfor (int i = 1; i < p; i++)\n\t\t\tadd(cnt[nym[i]], p - i);\n\t\teprintf(\"%d %d %d\\n\", cnt[0], cnt[1], cnt[2]);\n\t\t\n\t\tint ans = cnt[0];\n\t\tadd(ans, cnt[1]);\n\t\tadd(ans, cnt[2]);\n\t\tans = mpower(ans, n);\n\t\t\n// \t\teprintf(\"%d\\n\", ans);\n\t\tfor (int a = 0; a <= n; a += 2)\n\t\t\tfor (int b = 0; b <= n - a; b += 2) {\n\t\t\t\tint c = n - a - b;\n// \t\t\t\teprintf(\"%d %d %d\\n\", c, a, b);\n\t\t\t\tint tmp = mult(C[n][a], C[n - a][b]);\n\t\t\t\ttmp = mult(tmp, mpower(cnt[0], c));\n\t\t\t\ttmp = mult(tmp, mpower(cnt[1], a));\n\t\t\t\ttmp = mult(tmp, mpower(cnt[2], b));\n// \t\t\t\teprintf(\"tmp = %d\\n\", tmp);\n\t\t\t\tadd(ans, MOD - tmp);\n\t\t\t}\n\t\tprintf(\"%d\\n\", ans);\n// \t\tbreak;\n\t}\t\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "3140d27c7491c12eba0363fe0e6f2523", "src_uid": "c03b6379e9d186874ac3d97c6968fbd0", "difficulty": 2600.0} {"lang": "GNU C++", "source_code": "#include\n#include\n#include\n#include\n#define N 11000\n#define mod 1000000007\nusing namespace std;\ntypedef long long ll;\nint val[N],L[N],R[N],cnt[4],tot;\nint f[N][4];\nint mex(int x,int y)\n{\n\tif(x!=0&&y!=0)\n\t\treturn 0;\n\tif(x!=1&&y!=1)\n\t\treturn 1;\n\treturn 2;\n}\nint getRK(int x)\n{\n\tint l,r,mid;\n\tl=0,r=0x3f3f3f3f;\n\twhile(l<=r)\n\t{\n\t\tmid=l+r>>1;\n\t\tif(mid-mid/3<=x)\n\t\t\tl=mid+1;\n\t\telse\n\t\t\tr=mid-1;\n\t}\n\treturn r;\n}\nint main()\n{\n\tint n,m,i,j,k,temp,last,ans;\n\tscanf(\"%d%d\",&n,&m);\n\tL[tot=1]=0,R[tot]=2;\n\tm--;\n\tcnt[0]=m+m-1;\n\tfor(i=3,j=1,k=1;i<=m;i=last+1)\n\t{\n\t\t//\u4e0b\u4e00\u4e2aj\uff0c\u4e0b\u4e00\u4e2ak\n\t\tlast=min(m,min(R[j]*3+2,temp=getRK(R[k])));\n\t\tif(last=mod)\n\t\t\t\t\tf[i][j]-=mod;\n\t\t\t}\n\t\t}\n\t}\n\tans=((ll)f[n][1]+f[n][2]+f[n][3])%mod;\n\tprintf(\"%d\\n\",ans);\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "476aed8a899a752d84fce4475266caff", "src_uid": "c03b6379e9d186874ac3d97c6968fbd0", "difficulty": 2600.0} {"lang": "GNU C++17", "source_code": "#include \n#include \nusing namespace std;\n#define e1 first\n#define e2 second\n#define pb push_back\n#define mp make_pair\n#define boost {ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); }\n#define eb emplace_back\n#define OUT(x) {cout << x; exit(0); }\n#define FOR(i,a,b) for(int i=(a);i<=(b);++i)\n#define scanf(...) scanf(__VA_ARGS__)?:0\ntypedef long long int ll;\ntypedef unsigned long long ull;\ntypedef pair PII;\ntypedef pair PLL;\ntypedef pair PLLI;\ntypedef pair PP;\ntypedef pair PPI;\ntypedef pair PIP;\ntypedef pair PLI;\ntypedef unsigned int ui;\nconst int mod = 1e9+7;\nconst int inf = 1e9+9;\nconst ll MOD = 1e9+696969;\nconst long long INF = 4LL * 1000000LL * 1000000LL * 1000000LL;\n\ntemplate int size(T &&x) {\n\treturn int(x.size());\n}\ntemplate ostream& operator<<(ostream &out, const pair &p) {\n\treturn out << '(' << p.first << \", \" << p.second << ')';\n}\ntemplate auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {\n\tout << '{';\n\tfor(auto it = x.begin(); it != x.end(); ++it)\n\t\tout << *it << (it == prev(x.end()) ? \"\" : \", \");\n\treturn out << '}';\n}\nvoid dump() {}\ntemplate void dump(T &&x, Args... args) {\n\tcerr << x << \"; \";\n\tdump(args...);\n}\n#ifdef DEBUG\n struct Nl{~Nl(){cerr << '\\n';}};\n# define debug(x...) cerr << (strcmp(#x, \"\") ? #x \": \" : \"\"), dump(x), Nl(), cerr << \"\"\n#else\n# define debug(...) 0 && cerr\n#endif\nmt19937_64 rng(0);\nint random(int l, int r) {\n\treturn uniform_int_distribution(l, r)(rng);\n}\n\n#define rep(i, a, b) for(int i = a; i < (b); ++i)\n#define trav(a, x) for(auto& a : x)\n#define all(x) begin(x), end(x)\n#define sz(x) (int)(x).size()\ntypedef long long ll;\ntypedef pair pii;\ntypedef vector vi;\ninline void addmod(int &x, int val) {\n\tx += val;\n\twhile (x >= mod) x -= mod;\n}\n\nconst int maxn = 1000100;\n\nint nim[100100], N = 10000;\nint jest[3];\n\nint tab[10010][10010];\n\nvector res;\nvector vals;\n\ninline int getNim(int value, int curr_expanding) {\n\tif (value > res.back().e2) return curr_expanding;\n\tint x = 0, y = res.size() - 1;\n\twhile (x < y) {\n\t\tint sr = (x + y) / 2;\n\t\tif (res[sr].e1 <= value && value <= res[sr].e2) return vals[sr];\n\t\tif (value < res[sr].e1) y = --sr;\n\t\telse x = ++sr;\n\t}\n\t\n\treturn vals[x];\n}\n\ninline int findNim(int length, int curr_expanding) {\n\tFOR(j, 0, 2) jest[j] = false;\n\tint val = length / 3;\n\tjest[getNim(length - val, curr_expanding)] = true;\n\tjest[getNim(val, curr_expanding)] = true;\n\t\t\n\tint nm = 0;\n\twhile (jest[nm]) ++nm;\n\treturn nm;\n}\n\nvoid expand() {\n\tint next_point = res.back().e2 + 1;\n\tint curr_value = findNim(next_point, 0);\n\tint gn = -1;\n\tfor (int pt = 1; next_point + pt - 1 <= (int)1e9; pt *= 2) {\n\t\tint query_point = next_point + pt - 1;\n\t\tint value = findNim(query_point, curr_value);\n\t\tif (value != curr_value) {\n\t\t\tgn = query_point;\n\t\t\tbreak;\n\t\t}\n\t}\n\t\n\t\n\tif (gn == -1) {\n\t\tres.push_back({next_point, (int)1e9});\n\t\tvals.pb(curr_value);\n\t\treturn;\n\t}\n\t\n\t//there is some next interval\n\tint binx = next_point, biny = gn;\n\twhile (binx < biny) {\n\t\tint sr = (binx + biny) / 2 + 1;\n\t\tif (findNim(sr, curr_value) != curr_value) biny = --sr;\n\t\telse binx = sr;\n\t}\n\t\n\tres.push_back({next_point, binx});\n\tvals.pb(curr_value);\n\treturn;\n}\n\nll ways[4];\nll dp[1010][4];\nint n, p;\n\nint main() {\n\tnim[0] = nim[1] = nim[2] = 0;\n\tfor (int i=3; i<=N; ++i) {\n\t\tint val = (i / 3);\n\t\tFOR(j, 0, 2) jest[j] = false;\n\t\t\n\t\tjest[nim[i - val]] = true;\n\t\tjest[nim[val]] = true;\n\t\t\n\t\tint nm = 0;\n\t\twhile (jest[nm]) ++nm;\n\t\tnim[i] = nm;\n\t}\n\t\n\t//debug(i, nim[i]);\n\t\n\t\n\t/*for (int len=0; len<=N; ++len)\n\t\tfor (int i=0; i+len<=N; ++i){\n\t\t\tint j = i + len;\n\t\t\tFOR(k, 0, 2) jest[k] = false;\n\t\t\tif (j - i <= 2) tab[i][j] = 0;\n\t\t\telse {\n\t\t\t\tint ln = (j - i) / 3;\n\t\t\t\tjest[tab[i + ln][i + 2 * ln]] = true;\n\t\t\t\tjest[tab[i][j - ln]] = true;\n\t\t\t\t\n\t\t\t\tint nm = 0;\n\t\t\t\twhile (jest[nm]) ++nm;\n\t\t\t\ttab[i][j] = nm;\n\t\t\t}\n\t\t}\n\t\t\n\tFOR(i, 0, 20) {\n\t\tFOR(j, 0, 20) cout << tab[i][j] << ' ';\n\t\tcout << endl;\n\t}*/\n\t\n\tres = {};\n\tvector lengths = {};\n\tvals = {};\n\t\n\tint pos = 0;\n\tFOR(i, 1, N) {\n\t\tif (nim[pos] != nim[i]) {\n\t\t\tres.pb({pos, i - 1});\n\t\t\tvals.pb(nim[pos]);\n\t\t\tlengths.pb(res.back().e2 - res.back().e1 + 1);\n\t\t\tpos = i;\n\t\t}\n\t}\n\t\n\tres.pop_back();\n\tres.pop_back();\n\tvals.pop_back();\n\tvals.pop_back();\n\t\n\tint tr = 0;\n\twhile (res.back().e2 != (int)1e9) {\n\t\texpand();\n\t\t/*debug(res);\n\t\tdebug(\"\\n\");\n\t\t++tr;\n\t\t\n\t\tif (tr == 10) break;*/\n\t}\n\t\n\t/*int sz = res.size();\n\tfor (int i=0; i> n >> p;\n\tif (p == 1) OUT(0);\n\t--p;\n\t\n\tint sz = res.size();\n\tfor (int i=0; i\n#define mod 1000000007\nchar d[1000000000];\nint c[1010][1010];\nint num[3];\nint n,p;\nint add(int x,int y){\n\treturn (x+=y)>=1)x=mul(x,x);else\n\t\t\tbreak;\n\t}\n\treturn r;\n}\nconst int sg[]={\n1,0,\n3,1,\n4,2,\n5,1,\n7,2,\n9,0,\n13,1,\n15,2,\n19,0,\n27,1,\n39,2,\n40,0,\n57,2,\n58,1,\n81,2,\n85,0,\n120,2,\n121,1,\n174,2,\n179,0,\n255,2,\n260,1,\n363,2,\n382,0,\n537,2,\n544,1,\n780,2,\n805,0,\n1146,2,\n1169,1,\n1632,2,\n1718,0,\n2415,2,\n2447,1,\n3507,2,\n3622,0,\n5154,2,\n5260,1,\n7341,2,\n7730,0,\n10866,2,\n11011,1,\n15780,2,\n16298,0,\n23190,2,\n23669,1,\n33033,2,\n34784,0,\n48894,2,\n49549,1,\n71007,2,\n73340,0,\n104352,2,\n106510,1,\n148647,2,\n156527,0,\n220020,2,\n222970,1,\n319530,2,\n330029,0,\n469581,2,\n479294,1,\n668910,2,\n704371,0,\n990087,2,\n1003364,1,\n1437882,2,\n1485130,0,\n2113113,2,\n2156822,1,\n3010092,2,\n3169669,0,\n4455390,2,\n4515137,1,\n6470466,2,\n6683084,0,\n9509007,2,\n9705698,1,\n13545411,2,\n14263510,0,\n20049252,2,\n20318116,1,\n29117094,2,\n30073877,0,\n42790530,2,\n43675640,1,\n60954348,2,\n64185794,0,\n90221631,2,\n91431521,1,\n131026920,2,\n135332446,0,\n192557382,2,\n196540379,1,\n274294563,2,\n288836072,0,\n405997338,2,\n411441844,1,\n589621137,2,\n608996006,0,\n866508216,2,\n884431705,1,\n1000000000,-1};\nint main(){\n/*\tfor(int i=1; i<1000000000; i++){\n\t\td[i]=0;\n\t\tif(i>2){\n\t\t\tint x=i/3;\n\t\t\tint y=d[x],z=d[i-x];\n\t\t\tif(y!=0 && z!=0)\n\t\t\t\td[i]=0;\n\t\t\telse\n\t\t\tif(y!=1 && z!=1)\n\t\t\t\td[i]=1;\n\t\t\telse\n\t\t\t\td[i]=2;\n\t\t}\n\t\tif(d[i]!=d[i-1])printf(\"%d,%d,\\n\",i,d[i]);\n\t}*/\n\tscanf(\"%d%d\",&n,&p);\n\tfor(int i=0; sg[i]\n#include \n#include \nlong func(double n,long* mass){\n\tlong max=0;\n\tlong nn=n;\n\tif (nn>0)\n\tif (mass[nn-1]>0){\n\t\tlong temp=mass[nn-1];\n\t\treturn mass[nn-1];\n\t}\n\t\tfor(long i=2; i<=sqrt(n); i++){\n\t\t\tif ((nn/i)*i==nn){\n\t\t\t\tlong temp=func(n/i,mass);\n\t\t\t\tif (temp>max){\n\t\t\t\t\tmax=temp;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\tint temp=1;\n\tif (temp>max){\n\t\t\tmax=temp;\n\t\t}\n\tmax=max+n;\n\tmass[nn]=max;\n\treturn max;\n}\nint main(){\n\tlong n;\n\tlong sum=0;\n\tlong temp;\n\tscanf(\"%d\",&n);\n\tlong* mass=new long[n+1];\n\tfor(long i=0; i<=n; i++){\n\t\tmass[i]=0;\n\t}\n\tmass[0]=1;\n\tsum=func(n,mass);\n\tprintf(\"%d\",sum);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "d37f76af13a55dbe8390647394a2cb2d", "src_uid": "821c0e3b5fad197a47878bba5e520b6e", "difficulty": 1200.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define mp make_pair\n#define pb push_back\n#define rep(i,n) for(int i = 0; i < (n); i++)\n#define re return\n#define fi first\n#define se second\n#define sz(x) ((int) (x).size())\n#define all(x) (x).begin(), (x).end()\n#define fill(x,y) memset(x,y,sizeof(x))\n#define maxn 100000000\n\nint pm[maxn], use[maxn], pos;\n\nvoid prime(){\n\n\tint i, j;\n\tmemset (pm, 0, sizeof pm);\n\tpm[0] = pm[1] = -1;\n\tfor (i = 2; i * i \nusing namespace std;\n\nint main ()\n{\n\tlong int n;\n\tvector > CantDiv;\n\tmap Puntj;//Tengo que modificar Puntj-> Num con ptj\n\tvector Aux;\n\tvector din;\n\t\n\tcin>>n;\n\tAux.push_back(1);\n\tfor(long int i=0;imax) max=Puntj[CantDiv[din[i]][j]];\n\t\t\t}\n\t\t\tPuntj[din[i]]=max+din[i];\n\t\t}\n\t\tif(Puntj[din[i]]>maximomayor) maximomayor=Puntj[din[i]];\n\t}\n\tcout<\n#include \n#include \n\nusing namespace std;\n\nint min_del (int n, int ar[4])\n{\n\tint del =0;\n\tfor ( int j = 0; j < 4; j++)\n\t{\t\n\t\tif( n%ar[j] == 0) {\n\t\t\tdel = ar[j];\n\t\t\tbreak; \n\t\t}\n\t\tdel = n; \n\t}\n\treturn del;\n}\nint main()\n{\n\tint n;\n\tcin >> n;\n\tint min_d;\n\tint cur = n;\n\tint ar[4] = {2, 3, 5, 7};\n\tint del = 0;\n\twhile (true)\n\t{\n\t\tdel = min_del(n, ar);\n\t\tif (del == n) { cur +=1; break; }\n\t\tn /= del;\n\t\tcur += n;\n\t}\n\tcout << cur;\n\t\n\tgetch();\n\treturn 0;\n}\n\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "1bc51620155b0a2060da90ba8f9320d7", "src_uid": "821c0e3b5fad197a47878bba5e520b6e", "difficulty": 1000.0} {"lang": "GNU C++", "source_code": "#include \n\nusing namespace std;\n\nint main()\n{\n int n,i,j;\n cin>>n;\n int dizi[2][n];\n for(i=0;i<2;i++)\n for(j=0;j>dizi[i][j];\n int s1=0,s2=0;\n for(i=0;i\n#define maxn 100007\n#define ll long long int\nusing namespace std;\n\nint a[maxn];\n\ninline int read()\n{\n\tint x=0,f=1;char ch=getchar();\n\twhile (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}\n\twhile (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();\n\treturn x*f;\n}\n\ninline void writ(int x)\n{\n\tif(x<0) putchar('-'),x=-x;\n\tif(x>9) writ(x/10);\n\tputchar(x%10+'0');\n}\ninline void write(int x){writ(x);putchar('\\n');}\n\nint main()\n{\n\tint n=read(),m=read(),ans=0;\n\tfor (int i=1;i<=n;++i)\n\t{\n\t\tint l=read(),r=read();\n\t\tfor (int j=l;j<=r;++j) a[j]=1;\n\t}\n\tfor (int i=1;i<=m;++i) if (a[i]==0) ++ans;\n\twrite(ans);\n\tfor (int i=1;i<=m;++i) if (a[i]==0) writ(i),putchar(' ');\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "2af70d2192bd71c4d36e5d89bff793d2", "src_uid": "e0ddac5c6d3671070860dda10d50c28a", "difficulty": 800.0} {"lang": "GNU C++11", "source_code": "#include\n#define fi first\n#define se second\n#define FOR(a) for(int i=0;i P;\ntypedef pair LP;\nconst ll inf=1e18;\nconst int N=5000+10;\nconst ll mod=1e9+7;\n\nmap mp;\nmap ml;\n\nll n,m,k,a[N],b[N],f[N],num[N][N],dp[N][N];\nll did[N],vis[N],POW[N];\nstring s,str;\nll flag,tot,t,sum,pos, ans=1,cnt,len;\nchar v[105][105];\n\n\n\n\n\n\nint main()\n{\n ios::sync_with_stdio(false);\n cin.tie(0);\n\n\n cin>>n;\n FOR(n) {cin>>a[i];did[a[i]]=1;}\n FOR(n) {cin>>b[i];if(b[i]!=0&&!did[b[i]]) return cout<<\"No\"<\n\nusing namespace std;\n\nbool check(string a) {\n string b =a;\n reverse( b.begin(), b.end() );\n return (a==b);\n}\n\nint main() {\n\n freopen(\"input_5.txt\",\"r\",stdin);\n freopen(\"output_5.txt\",\"w\",stdout);\n\n int T = 5;\n cin>>T;\n\n /// Test cases\n// cout << T << endl;\n\n for(int cas=1;cas<=T;cas++) {\n\n string s;\n //s = \"shaheen\";\n\n //int n = s.length();\n int n,q;\n\n cin>>n>>q;\n cin>>s;\n\n vectorv;\n\n for(int i=0;ipalindrome;\n\n for(int i=0;i>k>>ch;\n\n int cnt =0;\n\n k--;\n\n for(int pos = 0;pos\n#include\n#include\n#include\n#include\nusing namespace std;\n\ninline void read(int &ans) {\n\tstatic char ch = getchar();\n\tregister int neg = 1;\n\tans = 0;\n\tfor (; !isdigit(ch); ch = getchar())\n\t\tif (ch == '-') neg = -1;\n\tfor (; isdigit(ch); ch = getchar())\n\t\tans = ans * 10 + ch - '0';\n\tans *= neg;\n}\n\ninline void get(int s, set < int > &si) {\n\tint i = (s / 50) % 475;\n\tfor (int j = 0; j < 25; ++j) {\n\t\ti = (i * 96 + 42) % 475;\n\t\tsi.insert(i + 26);\n\t}\n}\n\nint p, x, y, ans = ~0U >> 2;\nset < int > ss[50000];\nstruct Node {\n\tint s, m;\n};\n\ninline void print(const set < int > &ans) {\n\tfor (set < int > :: iterator it = ans.begin(); it != ans.end(); ++it)\n\t\tprintf(\"%d \", *it);\n}\n\ninline void bfs() {\n\tqueue < Node > q;\n\tq.push((Node) {x, 0});\n\twhile (!q.empty()) {\n\t\tNode c = q.front(); q.pop();\n\t\tif (c.s < y || c.m >= ans) continue;\n\t\tif (ss[c.s].empty()) get(c.s, ss[c.s]);\n\t\tif (ss[c.s].count(p)) {\n\t\t\tans = min(ans, c.m);\n\t\t\tcontinue;\n\t\t}\n\t\tq.push((Node) {c.s - 50, c.m});\n\t\tq.push((Node) {c.s + 100, c.m + 1});\n\t}\n}\n\n\nint main() {\n\tread(p); read(x); read(y);\n\tbfs();\n\tprintf(\"%d\\n\", ans);\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "8d6eebc8396be425ab23b8717ebf6eba", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300.0} {"lang": "GNU C++14", "source_code": "/**\n * winners never quit\n**/\n\n#include \n\nusing namespace std;\n\n#define pb push_back\n#define mp make_pair\ntypedef long long Long;\nvoid FastIO(){\n ios::sync_with_stdio(0);\n cin.tie(0);cout.tie(0);\n}\n\nconst int N = 1e5;\n\nint p, x, y;\n\nint dp[N];\n\nint solve(int n){\n int r = (n/50)%475;\n// if (r==p){\n// cout << n << '\\n';\n// return 0;\n// }\n for (int i = 0;i < 25;i++){\n r = (r*96 + 42) % 475;\n if (r+26 == p){\n //cout << n << '\\n';\n return 0;\n }\n }\n if (dp[n])return dp[n];\n dp[n] = solve(n+100)+1;\n if (n-50 >= y)dp[n] = min(dp[n], solve(n-50));\n return dp[n];\n}\n\nint main()\n{\n FastIO();\n int tc, ca = 0;\n cin >> p >> x >> y;\n cout << solve(x) << '\\n';\n return 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "5829aeb189755756b5da418d8727d0d5", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n\nusing namespace std;\nint n,a[25],p,x,y,b[20000],mi=1000000;\nvector v;\nbool check(int n)\n{\n\tint d=n;\n\tn=(d/50)%475;\n for(int i=1; i<=25; i++)\n {\n \tn=(n*96+42)%475;\n \tif(n+26 == p)\n \t\treturn 0;\n\t}\n\treturn 1;\n}\nint main()\n{\n\tcin >> p >> y >> x; \n\tint s=0;\n\tfor(int i=y; i>=x; i-=50)\n\t{\n\t\tif(check(i)==0)\n\t\t{\n\t\t\tmi = 0;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif(mi==0)\n\t{\n\t\tcout << mi;\n\t\treturn 0;\n\t}\n\tfor(int i=y+1; i<=1000000; i+=50)\n\t{\n\t\tif(check(i)==0)\n\t\t{\n\t\t\ts=0;\n\t\t\ts=i-y;\n\t\t\ts=s+50;\n\t\t\ts/=100;\n\t\t\tif(s\nusing namespace std;\n\ntypedef long long int LL;\n\n\nint main(){\n\n// int i, s = 6500;\n//\n// i = (s/50)%475;\n// cout << s << endl;\n// for( int x = 1; x <= 25; x++ ){\n// i = (i*96 + 42) % 475;\n// cout << \"i: \" << i << endl;\n// //cout << i+26 << ' ';\n// }\n// cout << endl;\n\n int p, score, requied, i, s, ans[30000], cnt, winnerPos;\n\n cin >> p >> score >> requied;\n\n cnt = 0;\n for( int k = requied; k <= 50000; k++ ){\n s = k;\n i = (s/50)%475;\n for( int m = 1; m <= 25; m++ ){\n i = (i*96 + 42) % 475;\n winnerPos = i+26;\n if( winnerPos == p ){\n ans[++cnt] = k;\n break;\n }\n }\n }\n //cout << cnt << endl; /// demo\n sort( ans+1, ans+cnt+1 );\n for( int x = 1; x <= cnt; x++ ){\n if( score > ans[x] ){\n cout << \"0\\n\";\n return 0;\n }\n else{\n int val = ceil( (ans[x]-score)/100.0 );\n cout << val << endl;\n break;\n }\n }\n\n\treturn 0;\n}\n", "lang_cluster": "C++", "compilation_error": false, "code_uid": "ae7c1ca5cfc72bc659905a731b3fed80", "src_uid": "c9c22e03c70a94a745b451fc79e112fd", "difficulty": 1300.0} {"lang": "GNU C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \nusing namespace std;\nvector v1;\nstring s;\nlong long sum=1,minn=10100,k,l,r,c,a[1000000],i,n,h,p=1,j=2,y,q[100000];\nbool prime(int v)\n{\n for(i=2;i*i<=v;i++)\n {\n if(v%i==0)return true;\n }\n return false;\n}\nint main()\n{\n cin>>n;\n k=n;\n while(n>1)\n {\n if(!prime(j))\n {\n if(n%j==0)\n {\n a[j]=1;\n n=n/j;\n }\n else j++;\n }\n else j++;\n }\n for(h=2;h<=1000000;h++)\n {\n if(a[h]==1)\n sum=sum*h;\n }\n cout<\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#define F first\n#define S second\n#define ll long long\n#define len length() \n#define all(x) x.begin(), x.end()\n#define sz(x) ((int) (x).size())\n#define sqr(x) x*x\n#define pb push_back\n#define mp make_pair\n#define bp(x) __builtin_popcount(x)\n#define lli long long int\n#define pii pair \n#define pll pair \n#define vi vector \n#define vll vector \n#define vpi vector \n#define vpll vector \n#define INF numeric_limits::max()\n#define frp freopen(\"input.txt\", \"r\", stdin); freopen(\"output.txt\", \"w\", stdout);\n#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)\n\nconst int maxn = (int)1e6;\nconst int mod = (int)1e12 + 7;\n\nusing namespace std;\n\nll b[101000], c, d, n, m, k;\nll cnt = 0, sum = 0, res = 0, maxi = -mod, mini = mod;\n\nbool prime(ll x){\n for(ll i=2; i<= sqrt(x); i++){\n if ((x%i) != 0)\n return true;\n else\n return false;\n }\n}\n \nmain(){\n cin>>n;\n if(prime(n))\n return cout< maxn)\n n = maxn;\n for (ll i = n; i >= 1; i--){\n if (n % i == 0){\n sum = sqrt(i);\n for (ll j = 2; j <= sum; j++){\n \n if(i % ((sum-res)*(sum-res)) == 0){ \n cnt++;\n res = 0;\n break;\n }\n else{\n res++;\n }\n \n } \n if(cnt >= 1){\n res = 0;\n cnt = 0;\n }\n else{\n cout<\n#include \n#include \nusing namespace std;\nint main(){\n long long int n, ans = 1; \n cin >> n;\n if(n%2 == 0){\n ans *= 2;\n while(n%2 == 0)\n n /= 2;\n }\n for(int i = 3; i <= n; i += 2){\n if(n%i) continue;\n ans *= i;\n while(n%i == 0)\n n /= i;\n }\n cout << ans;\n return 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "fb8bc265de328d6e7bc5942e9496f36f", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0} {"lang": "MS C++", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nusing namespace std;\n\n#define mp make_pair\n#define pp push_back\n#define Sort(x) sort(x.begin(), x.end())\n#define rep(i, x, y) for(int i = x; i < y; ++i)\n#define Rep(i, x, y) for(int i = x; i <= y; ++i)\n#define dRep(i, x, y) for(int i = x;i >= y; --i)\n#define vi vector\n#define vvi vector >\n#define ll long long\n#define all(v) v.begin(),v.end()\n#define ii pair\n#define mem(x, v) memset(x, v, sizeof(x))\n#define nl '\\n'\n#define MOD 1000000007\n#define readFile freopen(\"input.in\", \"r\", stdin)\n\nll n;\n\nint main()\n{\n\tll res = 1;\n\twhile(cin >> n)\n\t{\n\t\tres = 1;\n\t\tRep(i, 2, n)\n\t\t{\n\t\t\tif(n % i == 0)\n\t\t\t{\n\t\t\t\tres *= i;\n\t\t\t\twhile(n % i == 0)\n\t\t\t\t\tn /= i;\n\t\t\t}\n\t\t}\n\t\tcout << res << nl;\n\t}\n\n\treturn 0;\n}", "lang_cluster": "C++", "compilation_error": false, "code_uid": "c849f872f7ab949e321953f6d1dbe2d3", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92", "difficulty": 1300.0} {"lang": "GNU C++11", "source_code": "#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n \nusing namespace std;\ntypedef long long ll;\n\nconst int MN = 100100;\nconst double EPS = 1e-9;\ntypedef pair P;\ntypedef pair Q;\n\nvector